You’re calling $this->update_product();
too early, I guess just after you’ve constructed the object? It is then calling wp_update_post before everything else has finished loading, in this case the $wp_rewrite global which isn’t available until the setup_theme event.
You should probably call update_product() from the init hook instead:
add_action( 'init', [ $this, 'update_product' ] );
Related Posts:
- Who are the most trusted plugin developers? [closed]
- Get plugin_dir_url() from one level deep within plugin
- Redirect to settings page after install
- Notify Admins about Plugin Merge
- How does WordPress determine the primary plugin PHP file?
- Adding Featured Image in Post List
- Why does including a file in theme’s functions.php not work?
- 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
- Having separate plugins and themes folder for multi-site setup
- 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
- Add keywords meta to index.php page
- 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
- Checkbox conflict in my custom plugin admin page
- How to create a custom post type that contains another custom post type?
- 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 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?
- 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?
- Activate Plugin Automatically After Set Time
- Using sessions or an alternative in a plugin
- Correct way to expand custom WordPress plugin functions
- 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]
- 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?
- How to customize ‘recurrance’ of’ wp_schedule_event’?
- woocommerce blank page after clicking add to cart [closed]
- Create Array from data in the OPTIONS table
- Saving plugin data returns “You do not have sufficient permissions to access this page.”
- Apache rewrite rules and wordpress problem
- WordPress automatic plugin update
- Active Plugins for current blog in WP Multisite Network? [duplicate]
- Many Field in Front End User Registration form insert as post
- Call current post parameters inside a plugin
- How to list posts that appear in two categories
- Load my plugin before cache
- How to get current template file used by WordPress?
- Is it possible to debug plugins with Xcode?
- how to set approval of admin for wordpress posts submitted by the user?
- WordPress Plugin Reviewer
- Plugin to display text before a post
- Get all the related data from WordPress DB
- Deprecated error notice
- Admin access to WordPress site with installing plugin
- Plugin to Display Content on Page
- WordPress s2 member plugin not working [closed]
- How to load plugin static data from cloudfront
- How to Replicate Elementor Licensing Model
- How do I save meta key value in the save function?
- Redux Framework slides field – How Can i add new placeholder Filed? [closed]