The php code at apache, and therefor wordpress, is executed only as a response to an http request, therefor you can not “wait for event” the way you try to do. You will either have to trigger the required action via http, a specifically crafted URL for example, or load wordpress from the CLI, and after it has bootstraped, execute your code. You can look at the code of wordpress CLI utility https://github.com/wp-cli/wp-cli to learn how ir can be done.
Related Posts:
- Who are the most trusted plugin developers? [closed]
- Get plugin_dir_url() from one level deep within plugin
- Notify Admins about Plugin Merge
- Adding Featured Image in Post List
- Why does including a file in theme’s functions.php not work?
- WooCommerce – Call to undefined function is_woocommerce()
- OEmbed from Pinterest
- Should I use RIPS tool to test my themes and plugins?
- Add Top-Level Menu that opens URL
- flush_rewrite_rules() not working on plugin activation
- Determine plugin name from within plugin_action_links filter
- Plugin Functionality Only for Editor and Administrator
- Plugin to hide admin menu (vertical menu bar)
- Issue with post request to admin-post.php
- action-scheduler vs wp-background-processing
- Do you clean up your self-written plugins’ at deactivation?
- How do I turn a custom post type into a plugin?
- Global matrix for shortcodes/content for every page
- How to add class in plugin only for network site?
- Plugin Development sqlite or WordPress’ database
- How to write a plugin to add users to a mail list
- WordPress plugin for activating other plugins
- Pulling data from custom plugin settings using PHP shortcode and Javascript
- Does WP identify plugin by plugin name or plugin_basename?
- AJAX search posts and pages
- Combine scripts from all extensions of the plugin when an extension is activated
- Modifying Author Link to add Author Meta in URL
- WordPress plugin creation how to execute .sql in order to insert multiple rows at activation of plugin
- Checkbox conflict in my custom plugin admin page
- How to create a custom post type that contains another custom post type?
- How to create a custom shortcode based on the layout?
- Can a Plugin Override New User Default Role Type
- Add action to fire when a published post is updated
- How to let user store a file in plugin directory but not have it get deleted on update?
- Great blogs site resources/tutorial for WordPress Developers? [closed]
- Plugins ignored a line breaks or tag in the WordPress comment functions
- How to get path or root of plugin folder, not file or dir?
- How to make multiple admin pages for one plugin?
- Create custom pages with a plugin
- Is it possible for a plugin to force reading and writing of uploaded images to a database instead of to a filesystem?
- Amazon.com intergration with WordPress?
- Change letters for day name
- (WordPress 5.8.3) Function.php or a plugin for better performance? [duplicate]
- Set Multiple Meta Values as an Array Using dispatch( ‘core/editor’ ).editPost() Call in Gutenberg/JS
- Elementor Custom Control: How to get input value?
- Minimize and Uglify WordPress Plugin Files
- Comment “like” problem – “users who like this” avatar linking to current user profile instead of “liker’s” profile
- I want to generate the pdf and save it in library?
- How do I make sure that my plugin only runs on article detail pages?
- WordPress API functions not working at AJAX functions.php call
- How do I show content from a plugin using the template the site is currently working with?
- How to check homepage contain blog post?
- Create “new pages” within the admin section of plugin
- More gentle way to hook WordPress custom url
- Creating a plugin that will display text on every page
- auto activate plugin when theme is active
- Xamp installed local wordpress not allowing to publish or install plugin
- How to Call Specific .PHP file on add_submenu_page selection in Plugin Development?
- WordPress cron job running more than once
- Using sessions or an alternative in a plugin
- Correct way to expand custom WordPress plugin functions
- How to access a wordpress plugin page or add posts without doing it from the WordPress dashboard?
- Hide content for specific users with id
- adding dynamic/multiple slug values in ‘option_none_value’
- Update wordpress user roles not working as excepted
- WordPress UPDATE queries on MySQL database stuck
- is it possible to fetch data from a remote api while admin is writing a new post?
- Checkbox field that add a subscription product and change prices of other products in checkout and cart page
- Can’t access 3rd party API, code works on local server but not on wordpress
- Custom author page for custom role
- Dynamical slug on custom post type
- Storing Array of values into wordpress options
- Using WordPress to create a simple web app (SaaS) [closed]
- Front End Page Not Loading Header Footer
- Media Upload to custom database and Custom Directory
- Where do the section input fields values are stored in database
- WordPress Add advertising ads befor and after content with periority [closed]
- View more posts of a sub-category
- Can plugin automatically update if i hide the update notification?
- Creating a user ‘add custom field’ section
- Display_rows() and column_cb() strange behaviour
- WordPress plugin options need to delete after deactivate & uninstall
- How can I pass value to function in add_menu_page?
- How to show post attachment image
- Can a developer adopt a plugin marked as “not updated in over 2 years”?
- Making a Custom Post Type Publish Loop
- How wordpress plugin hooks works? [duplicate]
- Post curl function save twice using plugin hook function wordpress
- How to hide a piece of code from a wordpress web page?
- How to dispaly post informations (such as titles) in an admin plugin menu page?
- Someone Comment 1000 times in a Day in My WordPress Site, What Can i Do
- get_option returning a different value from what’s saved
- Plugin: Custom menu item problem
- Getting warning of Missing argument 2 for wpdb::prepare()
- Unable to pass arguments from plugin form to filter hook using ajax, the data is transferring via ajax but unable to pass as arguments in filter hooks
- How to update changes to multiple sites at the same time
- wp_handle_upload – specified file failed upload test
- Why am I getting an error when requiring a file in my plugin?
- Running a function using Crown WordPress on one day a week, for example, Mondays of every week
- How to make a Template page to show the information of different things Shop and Product page?