is_main_site 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()
            )

    public function column_cb( $item ) {
        // Restores the more descriptive, specific name for use within this method.         $blog = $item;

        if ( ! is_main_site( $blog['blog_id'] ) ) :
            $blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
            ?> <label class="label-covers-full-cell" for="blog_<?php echo $blog['blog_id']; ?>"> <span class="screen-reader-text"> <?php                 /* translators: %s: Site URL. */
                printf( __( 'Select %s' )$blogname );
                ?> </span> </label> <input type="checkbox" id="blog_<?php echo $blog['blog_id']; ?>" name="allblogs[]" value="


/** * Deprecated functionality to determin if the current site is the main site. * * @since MU (3.0.0) * @deprecated 3.0.0 Use is_main_site() * @see is_main_site() */
function is_main_blog() {
    _deprecated_function( __FUNCTION__, '3.0.0', 'is_main_site()' );
    return is_main_site();
}

/** * Deprecated functionality to validate an email address. * * @since MU (3.0.0) * @deprecated 3.0.0 Use is_email() * @see is_email() * * @param string $email Email address to verify. * @param bool $check_domain Deprecated. * @return string|false Valid email address on success, false on failure. */


    return $result;
}

/** * Corrects 404 redirects when NOBLOGREDIRECT is defined. * * @since MU (3.0.0) */
function maybe_redirect_404() {
    if ( is_main_site() && is_404() && defined( 'NOBLOGREDIRECT' ) ) {
        /** * Filters the redirect URL for 404s on the main site. * * The filter is only evaluated if the NOBLOGREDIRECT constant is defined. * * @since 3.0.0 * * @param string $no_blog_redirect The redirect URL defined in NOBLOGREDIRECT. */
        $destination = apply_filters( 'blog_redirect_404', NOBLOGREDIRECT );

        

    }

    /** * Checks if updates are intercepted by a filter. * * @since 5.2.0 * * @return array The test results. */
    public function test_wp_version_check_attached() {
        if ( ( ! is_multisite() || is_main_site() && is_network_admin() )
            && ! has_filter( 'wp_version_check', 'wp_version_check' )
        ) {
            return array(
                'description' => sprintf(
                    /* translators: %s: Name of the filter used. */
                    __( 'A plugin has prevented updates by disabling %s.' ),
                    '<code>wp_version_check()</code>'
                ),
                'severity'    => 'fail',
            );
        }
    }
// favicon.ico -- only if installed at the root.         $favicon_rewrite = ( empty( $home_path['path'] ) || '/' === $home_path['path'] ) ? array( 'favicon\.ico$' => $this->index . '?favicon=1' ) : array();

        // Old feed and service files.         $deprecated_files = array(
            '.*wp-(atom|rdf|rss|rss2|feed|commentsrss2)\.php$' => $this->index . '?feed=old',
            '.*wp-app\.php(/.*)?$' => $this->index . '?error=403',
        );

        // Registration rules.         $registration_pages = array();
        if ( is_multisite() && is_main_site() ) {
            $registration_pages['.*wp-signup.php$']   = $this->index . '?signup=true';
            $registration_pages['.*wp-activate.php$'] = $this->index . '?activate=true';
        }

        // Deprecated.         $registration_pages['.*wp-register.php$'] = $this->index . '?register=true';

        // Post rewrite rules.         $post_rewrite = $this->generate_rewrite_rules( $this->permalink_structure, EP_PERMALINK );

        /** * Filters rewrite rules used for "post" archives. * * @since 1.5.0 * * @param string[] $post_rewrite Array of rewrite rules for posts, keyed by their regex pattern. */
$wp_list_table->prepare_items();

$details = get_site( $id );
if ( ! $details ) {
    wp_die( __( 'The requested site does not exist.' ) );
}

if ( ! can_edit_network( $details->site_id ) ) {
    wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
}

$is_main_site = is_main_site( $id );

if ( $action ) {
    switch_to_blog( $id );
    $allowed_themes = get_option( 'allowedthemes' );

    switch ( $action ) {
        case 'enable':
            check_admin_referer( 'enable-theme_' . $_GET['theme'] );
            $theme  = $_GET['theme'];
            $action = 'enabled';
            $n      = 1;
            
/* translators: %s: User login. */
                                            __( 'Warning! User cannot be modified. The user %s is a network administrator.' ),
                                            esc_html( $user->user_login )
                                        )
                                    );
                                }

                                $userfunction = 'all_spam';
                                $blogs        = get_blogs_of_user( $user_id, true );

                                foreach ( (array) $blogs as $details ) {
                                    if ( ! is_main_site( $details->userblog_id ) ) { // Main site is not a spam!                                         update_blog_status( $details->userblog_id, 'spam', '1' );
                                    }
                                }

                                $user_data         = $user->to_array();
                                $user_data['spam'] = '1';

                                wp_update_user( $user_data );
                                break;

                            case 'notspam':
                                
/* * 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.) */

            


$details = get_site( $id );
if ( ! $details ) {
    wp_die( __( 'The requested site does not exist.' ) );
}

if ( ! can_edit_network( $details->site_id ) ) {
    wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
}

$is_main_site = is_main_site( $id );

switch_to_blog( $id );

$action = $wp_list_table->current_action();

if ( $action ) {

    switch ( $action ) {
        case 'newuser':
            check_admin_referer( 'add-user', '_wpnonce_add-new-user' );
            $user = $_POST['user'];
            
esc_url( $url ),
                        /* translators: %s: Importer name. */
                        esc_attr( sprintf( __( 'Run %s' )$data[0] ) ),
                        __( 'Run Importer' )
                    );

                    $is_plugin_installed = true;
                }
            }

            if ( empty( $action ) ) {
                if ( is_main_site() ) {
                    $url    = wp_nonce_url(
                        add_query_arg(
                            array(
                                'action' => 'install-plugin',
                                'plugin' => $plugin_slug,
                                'from'   => 'import',
                            ),
                            self_admin_url( 'update.php' )
                        ),
                        'install-plugin_' . $plugin_slug
                    );
                    
/** * 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' );
        


        if ( ! is_blog_installed() ) {
            return;
        }

        wp_check_mysql_version();
        wp_cache_flush();
        pre_schema_upgrade();
        make_db_current_silent();
        upgrade_all();
        if ( is_multisite() && is_main_site() ) {
            upgrade_network();
        }
        wp_cache_flush();

        if ( is_multisite() ) {
            update_site_meta( get_current_blog_id(), 'db_version', $wp_db_version );
            update_site_meta( get_current_blog_id(), 'db_last_updated', microtime() );
        }

        delete_transient( 'wp_core_block_css_files' );

        

}

$menu[75]                     = array( __( 'Tools' ), 'edit_posts', 'tools.php', '', 'menu-top menu-icon-tools', 'menu-tools', 'dashicons-admin-tools' );
    $submenu['tools.php'][5]  = array( __( 'Available Tools' ), 'edit_posts', 'tools.php' );
    $submenu['tools.php'][10] = array( __( 'Import' ), 'import', 'import.php' );
    $submenu['tools.php'][15] = array( __( 'Export' ), 'export', 'export.php' );
    /* translators: %s: Number of critical Site Health checks. */
    $submenu['tools.php'][20] = array( sprintf( __( 'Site Health %s' )$site_health_count ), 'view_site_health_checks', 'site-health.php' );
    $submenu['tools.php'][25] = array( __( 'Export Personal Data' ), 'export_others_personal_data', 'export-personal-data.php' );
    $submenu['tools.php'][30] = array( __( 'Erase Personal Data' ), 'erase_others_personal_data', 'erase-personal-data.php' );
if ( is_multisite() && ! is_main_site() ) {
    $submenu['tools.php'][35] = array( __( 'Delete Site' ), 'delete_site', 'ms-delete-site.php' );
}
if ( ! is_multisite() && defined( 'WP_ALLOW_MULTISITE' ) && WP_ALLOW_MULTISITE ) {
    $submenu['tools.php'][50] = array( __( 'Network Setup' ), 'setup_network', 'network.php' );
}

$menu[80]                               = array( __( 'Settings' ), 'manage_options', 'options-general.php', '', 'menu-top menu-icon-settings', 'menu-settings', 'dashicons-admin-settings' );
    $submenu['options-general.php'][10] = array( _x( 'General', 'settings screen' ), 'manage_options', 'options-general.php' );
    $submenu['options-general.php'][15] = array( __( 'Writing' ), 'manage_options', 'options-writing.php' );
    $submenu['options-general.php'][20] = array( __( 'Reading' ), 'manage_options', 'options-reading.php' );
    $submenu['options-general.php'][25] = array( __( 'Discussion' ), 'manage_options', 'options-discussion.php' );
    
$details = get_site( $id );
if ( ! $details ) {
    wp_die( __( 'The requested site does not exist.' ) );
}

if ( ! can_edit_network( $details->site_id ) ) {
    wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
}

$parsed_scheme = parse_url( $details->siteurl, PHP_URL_SCHEME );
$is_main_site  = is_main_site( $id );

if ( isset( $_REQUEST['action'] ) && 'update-site' === $_REQUEST['action'] ) {
    check_admin_referer( 'edit-site' );

    switch_to_blog( $id );

    // Rewrite rules can't be flushed during switch to blog.     delete_option( 'rewrite_rules' );

    $blog_data           = wp_unslash( $_POST['blog'] );
    $blog_data['scheme'] = $parsed_scheme;

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