wp_schedule_event
takes a hook as parameter, not a function. Try:
wp_schedule_event(time(), 'daily', 'my_daily_event');
add_action('my_daily_event', array(&$this, 'my_widget_cron'));
if ( !wp_next_scheduled( 'my_daily_event' ) ) {
wp_schedule_event(time(), 'hourly', 'my_daily_event')
}
If you remove the widget from the sidebar, the cron will still continue to run.
You can run the following code (outside of the widget class) to clear it:
if ( !is_active_widget('your_widget_callback_function') && wp_next_scheduled( 'my_daily_event' ) ) {
wp_clear_scheduled_hook('my_daily_event');
}
Related Posts:
- How to exclude certain widget from showing up on home/front page? [duplicate]
- How to append custom text to the output of ‘categories widget’?
- Customize Widget Navigation
- Update widget form after drag-and-drop (WP save bug)
- How do register_sidebar() and get_sidebar() work together?
- How to add a new product type on woocommerce product types? [closed]
- WordPress hook before inserting post into database
- Making Custom Fields Standard in the Admin UI
- Add custom html to last sub-menu item
- Why isn’t is_home() working correctly?
- Widgets vs. Theme Mods
- Widgets not working in Customizr but working in Appearance
- Get the sidebar ID in which the current widget was dropped
- Any Hook Called When Post Becomes Published?
- When using the block.getSaveElement hook can you output different markup based on whether or not you are in the edit view or the live page view?
- How Can A Widget With Only One Instance Be Defined?
- Customise search form in the Widget
- Print shortcode in custom action hook not where the shortcode is entered
- Disable email field on WooCommerce customer account details
- Customizing the default logout page of WordPress
- Is there a filter hook that I can use to change how taxonomy term names are displayed?
- How to Register and Display Widget for Custom taxonomy
- register_sidebar ‘after_widget’ on custom-built widgets not implementing, caused nested widgets
- Add ‘Right Now’ widget to custom dashboard
- Count widgets of a certain type
- Widget Javascript code (ajax)
- Custom widget select options needs to stay selected after save
- Custom Widget form function common elements
- Updating Widget options in custom install.php
- Edit admin post page
- Modify a theme to insert custom widgets?
- How did I enable atom feeds in a fresh WP3 install?
- How to update preview when custom setting changed in my custom widget
- Child Theme – how to add new widget on a specific place?
- Warning: Creating default object… when altering Customize panels
- Adding custom field in all widgets, but at the top of the form, in admin area
- How do I change the markup only of a built-in widget?
- Is it possible to make widget return only data (eg, array)?
- Viewing checkout page removes fees from mini cart
- Allow a Widget to be used one time only?
- Search widget will search everything in the site, how to limit to only search gallery name
- Disable widgets in customizer for sidebar
- Unable to edit the “customize” section and the “widget” section is populating unknown code
- Choose sidebars column in widgets.php page [closed]
- Can’t receive $args[ ] to my custom widget
- Organizing the position of widgetized areas in the backend
- how to convert Html block to dynamic widget?
- I’d like to move the Widgets Panel to the bottom of the list in Customizer
- Create small dashboard widget
- Widgets won’t save
- Customizing the Widget content markup
- Widget title markup in register_sidebar
- Sticky menu for WP custom menubars
- How to load a mycred hook from a plugin?
- Customise the Category Widget
- What’s the right way to share data between widgets?
- WooCommer Product Category Loop – How to change the display order of the rating and price?
- Hook before user is created and make some custom validation
- Add custom border across footer widget area
- How to make WordPress search page use a relative path
- How can Use custom input field in functions.php page?
- customer specific email attachment
- Customize section does not show my widget areas
- Widget recent comment filter by post meta_value
- How could I change contact details in the footer?
- Make Widget appear on Dashboard
- How to narrow the area between buttons on Helium theme sidebar? [closed]
- How to hide or remove a custom widget area when empty
- Execute function with jQuery if widget added or removed?
- Still desperate about multiple TinyMCEs in widgets – is there any good solution to this yet?
- Check get_post value after wp-admin login
- How to append the excerpt to the content in the single post page?
- Custom Admin Section
- How to define active widget with js in a customizer
- Creating Action Hooks For Automatic File Inclusion
- Confused about customising widgets
- Customizing the built-in Media Playlist
- Special characters showing in fallback font
- customize footer widgets area
- How do I include the sidebar (with Widgets) in a custom theme?
- Particle.js not loading in WordPress Gutenberg
- Hover Hide-Visible Additional CSS not working in WordPress website, but shows properly in Customize window
- Add a custom field for sorting the products in a specific category WOOCOMMERCE – Second try
- Multiple wp.editor in a custom widget using JQuery
- Allow multisite admins only to create users with one specific user role?
- Where to store reusable content that is not a page
- Add or Create Custom Structure Tags to Permalink
- How to edit alternate inactive themes in “Appearance -> Customise” screen?
- Prevent Multisite from creating sample page, sample post and sample comments
- Is it necessary to prefix theme_mod, section id and panel id in the customizer?
- Setup database structure with books, authors, languages etc. for publishing house [closed]
- Editing a post template
- Query for specific custom field
- WordPress widget and customize.php not working in Ubuntu16.04 VPS
- WordPress broken after changing URL
- Advanced WordPress plugin activation detection
- add an option to the read page
- Gravity Forms – gform_field_value – query custom table breaks functions.php
- WordPress archive index page
- Dynamically Filtering Posts by Data Points – Any Pointers?