wpdb::get_blog_prefix() WordPress Method

The wpdb::get_blog_prefix() method is used to get the blog prefix for the current site. This is useful for creating table names that are specific to the current site.

wpdb::get_blog_prefix( int $blog_id = null ) #

Gets blog prefix.


Parameters

$blog_id

(int)(Optional)

Default value: null


Top ↑

Return

(string) Blog prefix.


Top ↑

Source

File: wp-includes/wp-db.php

	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;
		}
	}


Top ↑

Changelog

Changelog
VersionDescription
3.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.