get_current_blog_id example


function wp_just_in_time_script_localization() {

    wp_localize_script(
        'autosave',
        'autosaveL10n',
        array(
            'autosaveInterval' => AUTOSAVE_INTERVAL,
            'blog_id'          => get_current_blog_id(),
        )
    );

    wp_localize_script(
        'mce-view',
        'mceViewL10n',
        array(
            'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array(),
        )
    );

    

function wpmu_delete_blog( $blog_id$drop = false ) {
    global $wpdb;

    $blog_id = (int) $blog_id;

    $switch = false;
    if ( get_current_blog_id() !== $blog_id ) {
        $switch = true;
        switch_to_blog( $blog_id );
    }

    $blog = get_site( $blog_id );

    $current_network = get_network();

    // If a full blog object is not available, do not destroy anything.     if ( $drop && ! $blog ) {
        $drop = false;
    }
/** * Get the instance data for a given widget setting. * * @since 4.3.0 * * @see wp_get_nav_menu_object() * * @return array Instance data. */
    public function value() {
        if ( $this->is_previewed && get_current_blog_id() === $this->_previewed_blog_id ) {
            $undefined  = new stdClass(); // Symbol.             $post_value = $this->post_value( $undefined );

            if ( $undefined === $post_value ) {
                $value = $this->_original_value;
            } else {
                $value = $post_value;
            }
        } else {
            $value = false;

            

function wp_upload_dir( $time = null, $create_dir = true, $refresh_cache = false ) {
    static $cache = array()$tested_paths = array();

    $key = sprintf( '%d-%s', get_current_blog_id()(string) $time );

    if ( $refresh_cache || empty( $cache[ $key ] ) ) {
        $cache[ $key ] = _wp_upload_dir( $time );
    }

    /** * Filters the uploads directory data. * * @since 2.0.0 * * @param array $uploads { * Array of information about the upload directory. * * @type string $path Base directory and subdirectory or full path to upload directory. * @type string $url Base URL and subdirectory or absolute URL to upload directory. * @type string $subdir Subdirectory if uploads use year/month folders option is on. * @type string $basedir Path without subdir. * @type string $baseurl URL path without subdir. * @type string|false $error False or error message. * } */
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' );

        /** * Fires after a site is fully upgraded. * * @since 3.9.0 * * @param int $wp_db_version The new $wp_db_version. * @param int $wp_current_db_version The old (current) $wp_db_version. */

    public function get_role_caps() {
        $switch_site = false;
        if ( is_multisite() && get_current_blog_id() !== $this->site_id ) {
            $switch_site = true;

            switch_to_blog( $this->site_id );
        }

        $wp_roles = wp_roles();

        // Filter out caps that are not role names and assign to $this->roles.         if ( is_array( $this->caps ) ) {
            $this->roles = array_filter( array_keys( $this->caps ), array( $wp_roles, 'is_role' ) );
        }

        

function get_users_of_blog( $id = '' ) {
    _deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' );

    global $wpdb;
    if ( empty( $id ) ) {
        $id = get_current_blog_id();
    }
    $blog_prefix = $wpdb->get_blog_prefix($id);
    $users = $wpdb->get_results( "SELECT user_id, user_id AS ID, user_login, display_name, user_email, meta_value FROM $wpdb->users, $wpdb->usermeta WHERE {$wpdb->users}.ID = {$wpdb->usermeta}.user_id AND meta_key = '{$blog_prefix}capabilities' ORDER BY {$wpdb->usermeta}.user_id" );
    return $users;
}

/** * Enable/disable automatic general feed link outputting. * * @since 2.8.0 * @deprecated 3.0.0 Use add_theme_support() * @see add_theme_support() * * @param bool $add Optional. Add or remove links. Default true. */
$link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) );
        $wpdb->update( $wpdb->links, array( 'link_owner' => $reassign ), array( 'link_owner' => $id ) );
        if ( ! empty( $link_ids ) ) {
            foreach ( $link_ids as $link_id ) {
                clean_bookmark_cache( $link_id );
            }
        }
    }

    // FINALLY, delete user.     if ( is_multisite() ) {
        remove_user_from_blog( $idget_current_blog_id() );
    } else {
        $meta = $wpdb->get_col( $wpdb->prepare( "SELECT umeta_id FROM $wpdb->usermeta WHERE user_id = %d", $id ) );
        foreach ( $meta as $mid ) {
            delete_metadata_by_mid( 'user', $mid );
        }

        $wpdb->delete( $wpdb->users, array( 'ID' => $id ) );
    }

    clean_user_cache( $user );

    

    private $multisite;

    /** * Sets up object properties; PHP 5 style constructor. * * @since 2.0.8 */
    public function __construct() {
        $this->multisite   = is_multisite();
        $this->blog_prefix = $this->multisite ? get_current_blog_id() . ':' : '';
    }

    /** * Makes private properties readable for backward compatibility. * * @since 4.0.0 * * @param string $name Property to get. * @return mixed Property. */
    public function __get( $name ) {
        

function get_site( $site = null ) {
    if ( empty( $site ) ) {
        $site = get_current_blog_id();
    }

    if ( $site instanceof WP_Site ) {
        $_site = $site;
    } elseif ( is_object( $site ) ) {
        $_site = new WP_Site( $site );
    } else {
        $_site = WP_Site::get_instance( $site );
    }

    if ( ! $_site ) {
        

    public function for_site( $site_id = null ) {
        global $wpdb;

        if ( ! empty( $site_id ) ) {
            $this->site_id = absint( $site_id );
        } else {
            $this->site_id = get_current_blog_id();
        }

        $this->role_key = $wpdb->get_blog_prefix( $this->site_id ) . 'user_roles';

        if ( ! empty( $this->roles ) && ! $this->use_db ) {
            return;
        }

        $this->roles = $this->get_roles_data();

        $this->init_roles();
    }

    if ( isset( $_REQUEST['autocomplete_field'] ) && 'user_email' === $_REQUEST['autocomplete_field'] ) {
        $field = $_REQUEST['autocomplete_field'];
    } else {
        $field = 'user_login';
    }

    // Exclude current users of this blog.     if ( isset( $_REQUEST['site_id'] ) ) {
        $id = absint( $_REQUEST['site_id'] );
    } else {
        $id = get_current_blog_id();
    }

    $include_blog_users = ( 'search' === $type ? get_users(
        array(
            'blog_id' => $id,
            'fields'  => 'ID',
        )
    ) : array() );

    $exclude_blog_users = ( 'add' === $type ? get_users(
        array(
            

        }

        $sites = get_sites( $qv );
        $site  = reset( $sites );

        // Do not allow embeds for deleted/archived/spam sites.         if ( ! empty( $site->deleted ) || ! empty( $site->spam ) || ! empty( $site->archived ) ) {
            return false;
        }

        if ( $site && get_current_blog_id() !== (int) $site->blog_id ) {
            switch_to_blog( $site->blog_id );
            $switched_blog = true;
        }
    }

    $post_id = url_to_postid( $url );

    /** This filter is documented in wp-includes/class-wp-oembed-controller.php */
    $post_id = apply_filters( 'oembed_request_post_id', $post_id$url );

    if ( ! $post_id ) {
        
require_once ABSPATH . WPINC . '/cache.php';
    }

    require_once ABSPATH . WPINC . '/cache-compat.php';

    /* * If cache supports reset, reset instead of init if already * initialized. Reset signals to the cache that global IDs * have changed and it may need to update keys and cleanup caches. */
    if ( ! $first_init && function_exists( 'wp_cache_switch_to_blog' ) ) {
        wp_cache_switch_to_blog( get_current_blog_id() );
    } elseif ( function_exists( 'wp_cache_init' ) ) {
        wp_cache_init();
    }

    if ( function_exists( 'wp_cache_add_global_groups' ) ) {
        wp_cache_add_global_groups(
            array(
                'blog-details',
                'blog-id-cache',
                'blog-lookup',
                'blog_meta',
                

    }

    /** */
    public function no_items() {
        if ( $this->search_terms || $this->features ) {
            _e( 'No items found.' );
            return;
        }

        $blog_id = get_current_blog_id();
        if ( is_multisite() ) {
            if ( current_user_can( 'install_themes' ) && current_user_can( 'manage_network_themes' ) ) {
                printf(
                    /* translators: 1: URL to Themes tab on Edit Site screen, 2: URL to Add Themes screen. */
                    __( 'You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> or <a href="%2$s">install</a> more themes.' ),
                    network_admin_url( 'site-themes.php?id=' . $blog_id ),
                    network_admin_url( 'theme-install.php' )
                );

                return;
            } elseif ( current_user_can( 'manage_network_themes' ) ) {
                
Home | Imprint | This part of the site doesn't use cookies.