当前位置: 首页>>代码示例>>PHP>>正文


PHP wpdb::get_blog_prefix方法代码示例

本文整理汇总了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'];
     }
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:28,代码来源:class-wp-roles.php

示例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);
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:16,代码来源:class-wp-user.php

示例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'];
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:67,代码来源:class-wp-user-query.php

示例4: getPrefix

 /**
  * {@inheritdoc}
  */
 public function getPrefix()
 {
     return $this->_db->get_blog_prefix();
 }
开发者ID:JBZoo,项目名称:CrossCMS,代码行数:7,代码来源:Database.php

示例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;
}
开发者ID:vilmark,项目名称:vilmark_main,代码行数:14,代码来源:functions.php

示例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);
 }
开发者ID:jbzoo,项目名称:sqlbuilder,代码行数:11,代码来源:Wordpress.php


注:本文中的wpdb::get_blog_prefix方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。