Make WordPress Core

Ticket #20537: 20537.2.diff

File 20537.2.diff, 2.0 KB (added by jeremyfelt, 9 years ago)
  • src/wp-cron.php

     
    5858if ( false === $crons = _get_cron_array() )
    5959        die();
    6060
     61$spawn_cron  = true;
     62$current_site = null;
     63if ( is_multisite() ) {
     64        $current_site = get_blog_details();
     65        // Don't process cron for suspended blogs.
     66        if ( $current_site->archived || $current_site->spam || $current_site->deleted ) {
     67                $spawn_cron = false;
     68        }
     69}
     70/** This filter is documented in wp-includes/cron.php */
     71if ( true === apply_filters( 'spawn_cron_for_site', $spawn_cron, $current_site ) ) {
     72        die();
     73}
     74unset( $spawn_cron, $current_site );
     75
    6176$keys = array_keys( $crons );
    6277$gmt_time = microtime( true );
    6378
  • src/wp-includes/cron.php

     
    342342        if ( false === $crons = _get_cron_array() )
    343343                return;
    344344
     345        $spawn_cron  = true;
     346        $current_site = null;
     347        if ( is_multisite() ) {
     348                $current_site = get_blog_details();
     349                // Don't process cron for suspended sites.
     350                if ( $current_site->archived || $current_site->spam || $current_site->deleted ) {
     351                        $spawn_cron = false;
     352                }
     353        }
     354        /**
     355         * Filter whether to spawn cron for a site.
     356         *
     357         * @since 4.6.0
     358         *
     359         * @param bool         $spawn_cron   Whether to spawn a cron process for a site. Defaults to true for single
     360         *                                   site and non-suspended sites in multisite. False for suspended sites
     361         *                                   in multisite.
     362         * @param null|WP_Site $current_site Null if single site. The site for which cron will spawn if multisite.
     363         */
     364        if ( false === apply_filters( 'spawn_cron_for_site', $spawn_cron, $current_site ) ) {
     365                return;
     366        }
     367        unset( $spawn_cron, $current_site );
     368
    345369        $gmt_time = microtime( true );
    346370        $keys = array_keys( $crons );
    347371        if ( isset($keys[0]) && $keys[0] > $gmt_time )