Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter jneto81

    (@jneto81)

    This is not about removing, it’s about avoiding to schedule the future update check .

    I’m analyzing all my wordpress queries ( 600+ per request in Admin ) and with my filter_cron_events

    $ignore = array(
    ‘wp_version_check’,
    ‘wp_update_plugins’,
    ‘wp_update_themes’,
    ‘wp_maybe_auto_update’,
    );

    i reduce 8 update queries, 2 per hook. ( sometimes, the cron queries are very heavy )

    Without my filter, wordpress is always removing the events from the cron ( + 4 queries ) and scheduling again ( + 4 queries ) for the next check in the future.

    With my filter, i never schedule the next check ( -4 queries ), so if it’s not in the cron, we don’t need to remove them ( – 4 queries ).

    Hope you understand.

    By the way, i’m using wordpress 4.11 for now and can’t upgrade.

    Thread Starter jneto81

    (@jneto81)

    Thanks.

    But you duplicate the wp_update_themes, and forget the wp_maybe_auto_update

    
    	/**
    	 * Filter cron events
    	 *
    	 * @since 		1.5.0
    	 */
    	public function filter_cron_events($event) {
    		switch( $event->hook ) {
    			case 'wp_version_check':
    			case 'wp_update_plugins':
    			case 'wp_update_themes':
    			case 'wp_update_themes':
    				$event = false;
    				break;
    		}
    		return $event;
    	}
    

    Hello,

    thanks for the plugin update with filter_cron_events.

    I must ask again, do we need to use get_plugins function ?
    Like a said before, i have a lot plugins, and the get_plugins function is heavy for me.

    I’m using this plugin but it doesn’t solve all my problems.

    I my case, i had to add this code

    
        add_action('schedule_event', array($this, 'filter_cron_events'));
    
        function filter_cron_events($event) {
    
            $ignore = array(
                'wp_version_check',
                'wp_update_plugins',
                'wp_update_themes',
                'wp_maybe_auto_update',
            );
    
            if ( in_array($event->hook, $ignore) ){
                return false;
            }
            return $event;
        }
    
    

    to avoid adding the events to the cron, in the database.

    The wp_clear_scheduled_hook just delete the events, but with my code i don’t need to delete the events, because they aren’t added to the cron. With this i reduce 8 queries for each request.
    Updates in wp_options / cron are heavy.

    Hello,

    do we need to use the get_plugins function ?
    I have more than 150 plugins and the get_plugins function take more than 150ms each request. Can we just use a empty plugins list instead, to improve performance ?

Viewing 5 replies - 1 through 5 (of 5 total)