On this page
wpdb::get_blog_prefix( int $blog_id = null ): string
Gets blog prefix.
Parameters
$blog_idint Optional-
Default:
null
Return
string Blog prefix.
Source
File: wp-includes/class-wpdb.php. View all references
public function get_blog_prefix( $blog_id = null ) {
if ( is_multisite() ) {
if ( null === $blog_id ) {
$blog_id = $this->blogid;
}
$blog_id = (int) $blog_id;
if ( defined( 'MULTISITE' ) && ( 0 === $blog_id || 1 === $blog_id ) ) {
return $this->base_prefix;
} else {
return $this->base_prefix . $blog_id . '_';
}
} else {
return $this->base_prefix;
}
}
Related
Uses
| Uses | Description |
|---|---|
| is_multisite() wp-includes/load.php | If Multisite is enabled. |
Used By
| Used By | Description |
|---|---|
| wp_register_persisted_preferences_meta() wp-includes/user.php | Registers the user meta property for persisted preferences. |
| wp_initialize_site() wp-includes/ms-site.php | Runs the initialization routine for a given site. |
| wp_default_packages_inline_scripts() wp-includes/script-loader.php | Adds inline scripts required for the WordPress JavaScript packages. |
| WP_User::for_site() wp-includes/class-wp-user.php | Sets the site to operate on. Defaults to the current site. |
| WP_Roles::for_site() wp-includes/class-wp-roles.php | Sets the site to operate on. Defaults to the current site. |
| wp_get_users_with_no_role() wp-includes/user.php | Gets the user IDs of all users with no role on this site. |
| get_author_user_ids() wp-admin/includes/deprecated.php | Get all user IDs. |
| get_editable_user_ids() wp-admin/includes/deprecated.php | Gets the IDs of any users who can edit posts. |
| get_nonauthor_user_ids() wp-admin/includes/deprecated.php | Gets all users who are not authors. |
| WP_User::update_user_level_from_caps() wp-includes/class-wp-user.php | Updates the maximum user level for the user. |
| WP_User::remove_all_caps() wp-includes/class-wp-user.php | Removes all of the capabilities of the user. |
| WP_User::_init_caps() wp-includes/class-wp-user.php | Sets up capability object properties. |
| get_users_of_blog() wp-includes/deprecated.php | Get users for the site. |
| WP_User_Query::prepare_query() wp-includes/class-wp-user-query.php | Prepares the query variables. |
| update_user_option() wp-includes/user.php | Updates user option with global blog capability. |
| delete_user_option() wp-includes/user.php | Deletes user option with global blog capability. |
| count_users() wp-includes/user.php | Counts number of users who have each of the user roles. |
| get_user_option() wp-includes/user.php | Retrieves user option that can be either per Site or per Network. |
| is_user_option_local() wp-includes/ms-deprecated.php | Check whether a usermeta key has to do with the current blog. |
| get_most_recent_post_of_user() wp-includes/ms-functions.php | Gets a user’s most recent post. |
| install_blog() wp-includes/ms-deprecated.php | Install an empty blog. |
| wpmu_validate_blog_signup() wp-includes/ms-functions.php | Processes new site registrations. |
| get_blog_list() wp-includes/ms-deprecated.php | Deprecated functionality to retrieve a list of all sites. |
| switch_to_blog() wp-includes/ms-blogs.php | Switch the current blog. |
| restore_current_blog() wp-includes/ms-blogs.php | Restore the current blog, after calling switch_to_blog() . |
| wpdb::tables() wp-includes/class-wpdb.php | Returns an array of WordPress tables. |
| wpdb::set_prefix() wp-includes/class-wpdb.php | Sets the table prefix for the WordPress tables. |
| wpdb::set_blog_id() wp-includes/class-wpdb.php | Sets blog ID. |
Changelog
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wpdb/get_blog_prefix