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?
- When to use Exceptions vs Error Objects vs just plain false/null
- WordPress and event-driven programming – what is it about?
- WordPress URL Rewrite not working
- How to remove a metabox from menu editor page?
- simple wordpress ajax plugin not working when not logged in
- Audio Player not loading when the content is loaded through Ajax, MediaElement.js no applied
- Saving metabox repeatable fields
- how to create and show sessions in word press?
- do not show web page section when using advanced custom fields pro
- How to get all existing post types
- New Plugin Review
- Create custom blocks for bootstrap
- Query String being Removed Creating a Pagination Issue within a Custom Plugin
- wp_insert_post() is returning the correct post ID, no failure, but the post content does not get updated
- Randomise upload filenames (or another solution to hide the original image URL from theft?)
- Setting up 2 SMTP accounts: 1 for wordpress and 1 for woocommerce
- WordPress Scheduled Event Request Blocking
- How to pass arguments to add_action() or retrieve return value of called function?
- How to set up VS Code for WP plugin/theme development in 2021? [closed]
- Saving an array of dynamic repeater data as post_meta
- WordPress wpform plugin submit and get multiple checked value from checkbox [closed]
- Remove metabox from WordPress menu editor page?
- Improve page speed loading using CDN and async or defer attribute
- How to add an arrow to menu items has submenus
- Script to browser problem PHP
- Don’t insert if permalink is the same?
- Store a default value for a transient on plugin activation
- wp query foreach deleting record returning only first or last item
- PHP > Scheduled Tasks > Sending daily email with dynamic API variables
- WordPress Custom field Colors
- “Undefined index” error when saving empty array with checkboxes
- Is it save to use eval for a jQuery callback method coming from the database?
- Scheduling an event inside plugin class is not working
- How to catch wordpress post ID when it’s published
- How to Change CSS Colors from Custom Plugin Settings Page
- Passing the name of selected color from the custom component to `render_callback`
- Any ideas why I am getting “I’m getting “wp-admin/admin-ajax.php 401 (Unauthorized)”
- Cant register rest routs from class instance
- Save user total active time after login in wordpress [closed]
- wordpress frontend editor to add extra css to website
- How to pass hook variable to function?
- PHP: How to access db the right way in plugin?
- select a single val though a table in wordpress
- WordPress – Get Posts with Category data
- How to use wp_send_json() and output the value with ajax?
- Problem with inserting multiple images in gallery of each WooCommerce product programmatically
- Is it possible to access admin-ajax.php using PHP?
- Call to “admin_notices” hook from a static method
- How to Create custom block for displaying information in content section which act like shortcode
- How to detect and handle the time difference between server and user in WordPress?
- How to setup the Email piping in WordPress plugin?
- Reliable way to add nonce to HTTP Header in WordPress?
- Getting an error when my plugin is updated, but the files update correctly
- Use wp_head hook on template page
- Creating a POP Alert
- ssl redirect function is not working
- Adding custom field to product category and show it to shop/category shop page
- WordPress Plugin Development – get_option error
- how to add new PHP page in WordPress plugin
- How can I get my WordPress plugin to receive data and relay it in an ajax/php request to a remote server that requires authentication?
- Get original value in save_post action hooka
- Constant expression contains invalid operations plugin class properties visibility
- Gutenberg blocks shortcodes compatibility
- Save custom field on WP_List_Table
- Load script and styles using an array of resources
- not able to access $_POST on backend profile update
- Custom Plugin Develoment, Form Action
- WordPress Query Crashes Browser
- How to Request a User to Register on Landing at a Site, Then Automatically Delete the Users Password on Logout?
- Plugin Modification Change Functionality For Logged User Only
- How can I move the posted-on date above the post and below the entry-header?
- INCOMING: Wall of code for form and $_POST, not updating custom field’s value
- add shortcode heading showing multiple time
- Post formating on Home page
- calling a function from a class in your template
- WP multisite network plugin fails to see classes loaded with spl autoload
- AJAX & PHP | Call a specific PHP function from a PHP file via AJAX?
- What is this mark for “? function()” [closed]
- using a shortcode in a hyperlink
- Implement OAuth2 in custom plugin
- login redirect based on user role not work as expected
- redirect user from login page if is logged
- How to lock users account until approvation
- Variable ++ in query loop
- transition_post_status hook, works – but not if the post is new
- WordPress REST API – Custom field not added to pages
- Woocommerce – add tracking code to another email template