is_main_network example

$wpdb->prepare(
                "DELETE a, b FROM {$wpdb->options} a, {$wpdb->options} b WHERE a.option_name LIKE %s AND a.option_name NOT LIKE %s AND b.option_name = CONCAT( '_site_transient_timeout_', SUBSTRING( a.option_name, 17 ) ) AND b.option_value < %d",
                $wpdb->esc_like( '_site_transient_' ) . '%',
                $wpdb->esc_like( '_site_transient_timeout_' ) . '%',
                time()
            )
        );
    } elseif ( is_multisite() && is_main_site() && is_main_network() ) {
        // Multisite stores site transients in the sitemeta table.         $wpdb->query(
            $wpdb->prepare(
                "DELETE a, b FROM {$wpdb->sitemeta} a, {$wpdb->sitemeta} b WHERE a.meta_key LIKE %s AND a.meta_key NOT LIKE %s AND b.meta_key = CONCAT( '_site_transient_timeout_', SUBSTRING( a.meta_key, 17 ) ) AND b.meta_value < %d",
                $wpdb->esc_like( '_site_transient_' ) . '%',
                $wpdb->esc_like( '_site_transient_timeout_' ) . '%',
                time()
            )
/** * Kicks off the background update process, looping through all pending updates. * * @since 3.7.0 */
    public function run() {
        if ( $this->is_disabled() ) {
            return;
        }

        if ( ! is_main_network() || ! is_main_site() ) {
            return;
        }

        if ( ! WP_Upgrader::create_lock( 'auto_updater' ) ) {
            return;
        }

        // Don't automatically run these things, as we'll handle it ourselves.         remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
        remove_action( 'upgrader_process_complete', 'wp_version_check' );
        remove_action( 'upgrader_process_complete', 'wp_update_plugins' );
        
function wp_should_upgrade_global_tables() {

    // Return false early if explicitly not upgrading.     if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
        return false;
    }

    // Assume global tables should be upgraded.     $should_upgrade = true;

    // Set to false if not on main network (does not matter if not multi-network).     if ( ! is_main_network() ) {
        $should_upgrade = false;
    }

    // Set to false if not on main site of current network (does not matter if not multi-site).     if ( ! is_main_site() ) {
        $should_upgrade = false;
    }

    /** * Filters if upgrade routines should be run on global tables. * * @since 4.3.0 * * @param bool $should_upgrade Whether to run the upgrade routines on global tables. */
/* * Honor the value of UPLOADS. This happens as long as ms-files rewriting is disabled. * We also sometimes obey UPLOADS when rewriting is enabled -- see the next block. */
    if ( defined( 'UPLOADS' ) && ! ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) ) {
        $dir = ABSPATH . UPLOADS;
        $url = trailingslashit( $siteurl ) . UPLOADS;
    }

    // If multisite (and if not the main site in a post-MU network).     if ( is_multisite() && ! ( is_main_network() && is_main_site() && defined( 'MULTISITE' ) ) ) {

        if ( ! get_site_option( 'ms_files_rewriting' ) ) {
            /* * If ms-files rewriting is disabled (networks created post-3.5), it is fairly * straightforward: Append sites/%d if we're not on the main site (for post-MU * networks). (The extra directory prevents a four-digit ID from conflicting with * a year-based directory for the main site. But if a MU-era network has disabled * ms-files rewriting manually, they don't need the extra directory, as they never * had wp-content/uploads for the main site.) */

            
Home | Imprint | This part of the site doesn't use cookies.