Here is the solution:
register_activation_hook( __FILE__, 'rest_api_hook' );
/**
* Runs only when the plugin is activated.
*/
function rest_api_hook() {
/* Create data */
set_transient( 'rest_api', true, 5 );
}
/* Add notice */
add_action( 'admin_notices', 'rest_api_hook_exec' );
/**
* Rest API Notice on Activation.
*/
function rest_api_hook_exec() {
/* Check transient, if is available display notice */
if( get_transient( 'rest_api' ) ) {
// Execute script
wp_enqueue_script('activation_data_api', plugins_url('assets/js/activation_data_api.js', __FILE__));
// Delete script after executing
delete_transient( 'rest_api' );
}
}
Related Posts:
- Using register_activation_hook in classes
- Custom plugin: Trying to show saved data on frontend
- How to set a custom path, for ajax image upload folder in admin?
- action hook wp_head higher priority as all other plugins/hooks
- How to call function at the bottom of post using plugin?
- wp_loaded hook block script enquequing
- Adding widgets to my plugin page instead of WordPress dashboard
- Adding function to Genesis genesis_header [closed]
- How to remove the message ‘We could not find any results for your search’ without changing template files and without adding posts/pages?
- using filter and hook inside class
- get Woocommerce product format json for WP_Query
- Register/enqueue scripts only on certain admin pages
- How do I remove an action hook inside a class that is called by another class?
- Add Imports to Existing WordPress Import Map
- what is correct way to hook when update post
- error_log() output for print_r() appearing on page
- Allow only 1 taxonomy per custom post type [duplicate]
- Remove Woocommerce product link
- Do I require the use of nonce?
- Retrieve multiple values passed to a single attribute in a shortcode
- How can I remove “Proudly powered by WordPress” from twentyeleven without modifying footer.php?
- How can I hook into and edit the text of a wp_nav_menu tag?
- How to change date language without changing the entire site language?
- Check if page parent has certain template
- Save selected item from dropdown menu in a meta box as a metadata value for a custom post type
- Prevent publish status/date saved on transition_post_status hook
- OOP Plugin Development. Including external object
- Authenticating to WordPress, using my own authentication two-factor system
- Use composer to load custom classes [closed]
- Woocommerce, recognize the loop of related products
- Why when I instantiate wp_error in a validation method my user registration method stops working?
- Create table in database when activating plugin
- Executing `createimagefrompng()` from save_post hook (or equivalent hook)
- Problem with WordPress Ajax form
- Getting my head round WordPress filter
- allow user to select pages from dropdown in my plugin
- Delete option value from array using update_option()
- Using Font Awesome as post thumbnail
- admin-ajax.php responding with 0
- custom shortcode will not display the wrapped content
- How to restrict wp generate attachment metadata() to certain intermediate image sizes
- WordPress php filter admin_body_class not working
- Common abstract class for plugins
- Same log message keeps on printing to debug.log file thousand of times
- Append HTML Using Shortcode
- Create onClick Event to Re-load a Widget
- Accessing the database from a plugin outside of action hooks
- Adding subdomain to home_url for “add_menu_page”
- How to select the contents in the text view textrea in wp_editor?
- Trying to build simple deposit code that hooks into woocommerce
- user_profile_update_errors hook not executing
- Update results, Before deleting the related category [closed]
- How to auto fetch customer details in Woocommerce in checkout page
- Can’t upload image using media_sideload_image
- I want to add custom add to cart link [closed]
- Execute long and heavy processes
- What exactly do this function declared into functions.php file of a WP theme?
- How to use html inside a functions.php code?
- WordPress Environment: Dynamic Page using shortcode – how to change the page name for sharing
- Extend Woocommerce Widget Class – WC_Widget_Product_Categories
- plugin add action hook is not working :
- zip unzip attachments in wordpress
- wordpress admin plugin menu custom css
- How can I hook into the wp_mail function used by BackWPup?
- how to Update 15k products on plugin activation with meta_option
- Hooks for post saving make a post-new.php to load latest post’s data
- Adding Additional Variables on Menus Page
- Using flickr api in custom wordpress plugin
- Toolbar Hidden in a Virtual Page
- PHP: $_SESSION destroyed after page reload for my custom session
- How to correctly escape an echo
- Payment field disappears on custom Paypal plugin
- Adding image upload in tag section – WordPress plugin development
- How to Remove Theme Style CSS inside Custom Plugin?
- Creating plugin with front-end pages
- How to Send Pingbacks for all Posts in WordPress?
- I am having errors with checkout on wordpress
- How to edit post meta data before publishing the post it self wordpress?
- How can I update the price when someone enters postcode or zip code in woocommerce checkout page?
- 400 bad request admin-ajax file upload
- Update user meta when an external link in admin notice is clicked
- Help hooking into user_register
- Input field duplicates on form submit by jQuery
- Unable to pass variable to database
- Gravity Forms Marketo Plugin Feed [closed]
- Add custom filter to register data in array
- Trouble using wordpress functions in a pop-up modal form
- MySQL update text field with ‘
- how can I make content from a plugin hidden when user is logged in? [duplicate]
- Change Checkout “Place Order” text if cart has a specific product
- display php code in header using wp_head()
- How to pass and validate nonce in custom REST routes
- ajax problems on loading page [closed]
- php was updated – critical error [closed]
- wp_mail – send emails after 24 hours from users registration
- Compare user meta values before update them
- Capture the Selected Radio Button Value between two files in wordpress theme
- How to change product SKU’s in bulk with a plugin
- JQuery UI Autocomplete showing as bullets
- Custom plugin with dynamic child pages listing database records