本文整理汇总了PHP中wpdb::get_blog_prefix方法的典型用法代码示例。如果您正苦于以下问题:PHP wpdb::get_blog_prefix方法的具体用法?PHP wpdb::get_blog_prefix怎么用?PHP wpdb::get_blog_prefix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wpdb
的用法示例。
在下文中一共展示了wpdb::get_blog_prefix方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reinit
/**
* Reinitialize the object
*
* Recreates the role objects. This is typically called only by switch_to_blog()
* after switching wpdb to a new site ID.
*
* @since 3.5.0
* @access public
*/
public function reinit()
{
// There is no need to reinit if using the wp_user_roles global.
if (!$this->use_db) {
return;
}
// Duplicated from _init() to avoid an extra function call.
$this->role_key = $this->db->get_blog_prefix() . 'user_roles';
$this->roles = get_option($this->role_key);
if (empty($this->roles)) {
return;
}
$this->role_objects = array();
$this->role_names = array();
foreach (array_keys($this->roles) as $role) {
$this->role_objects[$role] = new WP_Role($role, $this->roles[$role]['capabilities']);
$this->role_names[$role] = $this->roles[$role]['name'];
}
}
示例2: for_blog
/**
* Set the site to operate on. Defaults to the current site.
*
* @since 3.0.0
*
* @param int $blog_id Optional. Site ID, defaults to current site.
*/
public function for_blog($blog_id = '')
{
if (!empty($blog_id)) {
$cap_key = $this->db->get_blog_prefix($blog_id) . 'capabilities';
} else {
$cap_key = '';
}
$this->_init_caps($cap_key);
}
示例3: prepare_query
//.........这里部分代码省略.........
$field = 'ID' === $field ? 'ID' : sanitize_key($field);
$this->query_fields[] = "{$this->db->users}.{$field}";
}
$this->query_fields = implode(',', $this->query_fields);
} elseif ('all' == $qv['fields']) {
$this->query_fields = "{$this->db->users}.*";
} else {
$this->query_fields = "{$this->db->users}.ID";
}
if (isset($qv['count_total']) && $qv['count_total']) {
$this->query_fields = 'SQL_CALC_FOUND_ROWS ' . $this->query_fields;
}
$this->query_from = "FROM {$this->db->users}";
$this->query_where = "WHERE 1=1";
// Parse and sanitize 'include', for use by 'orderby' as well as 'include' below.
if (!empty($qv['include'])) {
$include = wp_parse_id_list($qv['include']);
} else {
$include = false;
}
$blog_id = 0;
if (isset($qv['blog_id'])) {
$blog_id = absint($qv['blog_id']);
}
if ($qv['has_published_posts'] && $blog_id) {
if (true === $qv['has_published_posts']) {
$post_types = get_post_types(array('public' => true));
} else {
$post_types = (array) $qv['has_published_posts'];
}
foreach ($post_types as &$post_type) {
$post_type = $this->db->prepare('%s', $post_type);
}
$posts_table = $this->db->get_blog_prefix($blog_id) . 'posts';
$this->query_where .= " AND {$this->db->users}.ID IN ( SELECT DISTINCT {$posts_table}.post_author FROM {$posts_table} WHERE {$posts_table}.post_status = 'publish' AND {$posts_table}.post_type IN ( " . join(", ", $post_types) . " ) )";
}
// Meta query.
$this->meta_query = new WP_Meta_Query();
$this->meta_query->parse_query_vars($qv);
if (isset($qv['who']) && 'authors' == $qv['who'] && $blog_id) {
$who_query = array('key' => $this->db->get_blog_prefix($blog_id) . 'user_level', 'value' => 0, 'compare' => '!=');
// Prevent extra meta query.
$qv['blog_id'] = $blog_id = 0;
if (empty($this->meta_query->queries)) {
$this->meta_query->queries = array($who_query);
} else {
// Append the cap query to the original queries and reparse the query.
$this->meta_query->queries = array('relation' => 'AND', array($this->meta_query->queries, $who_query));
}
$this->meta_query->parse_query_vars($this->meta_query->queries);
}
$roles = array();
if (isset($qv['role'])) {
if (is_array($qv['role'])) {
$roles = $qv['role'];
} elseif (is_string($qv['role']) && !empty($qv['role'])) {
$roles = array_map('trim', explode(',', $qv['role']));
}
}
$role__in = array();
if (isset($qv['role__in'])) {
$role__in = (array) $qv['role__in'];
}
$role__not_in = array();
if (isset($qv['role__not_in'])) {
$role__not_in = (array) $qv['role__not_in'];
示例4: getPrefix
/**
* {@inheritdoc}
*/
public function getPrefix()
{
return $this->_db->get_blog_prefix();
}
示例5: membership_db_prefix
function membership_db_prefix(wpdb $wpdb, $table, $useprefix = true)
{
$membership_prefix = '';
if ($useprefix) {
$membership_prefix = 'm_';
}
$global = is_multisite() && filter_var(MEMBERSHIP_GLOBAL_TABLES, FILTER_VALIDATE_BOOLEAN);
$prefix = $wpdb->get_blog_prefix($global ? MEMBERSHIP_GLOBAL_MAINSITE : null);
$table_name = $prefix . $membership_prefix . $table;
if ($global && defined('MULTI_DB_VERSION') && function_exists('add_global_table')) {
add_global_table($membership_prefix . $table);
}
return $table_name;
}
示例6: __construct
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.Superglobals)
* @codeCoverageIgnore
*/
public function __construct($connection = null, $tablePrefix = null)
{
$this->_db = $GLOBALS['wpdb'];
$tablePrefix = $this->_db->get_blog_prefix();
parent::__construct($connection, $tablePrefix);
}