本文整理汇总了PHP中is_content_administrator_rs函数的典型用法代码示例。如果您正苦于以下问题:PHP is_content_administrator_rs函数的具体用法?PHP is_content_administrator_rs怎么用?PHP is_content_administrator_rs使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_content_administrator_rs函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: flt_sticky_posts
function flt_sticky_posts($post_ids)
{
if ($post_ids && !is_content_administrator_rs()) {
global $wpdb;
$post_ids = scoper_get_col(apply_filters('objects_request_rs', "SELECT ID FROM {$wpdb->posts} WHERE ID IN ('" . implode("','", $post_ids) . "')", 'post'));
}
return $post_ids;
}
示例2: flt_recent_comments
function flt_recent_comments($query)
{
// Due to missing get_comments hook prior to WP 3.1, this filter operates on every front-end query.
// If query doesn't pertain to comments, skip out with as little overhead as possible.
if (strpos($query, 'comment') && strpos($query, "ELECT") && !strpos($query, 'posts as parent') && !strpos($query, "COUNT") && strpos($query, "comment_approved")) {
if (!is_attachment() && !is_content_administrator_rs()) {
global $wpdb;
if (strpos($query, " {$wpdb->posts} ")) {
return $query;
}
if (awp_is_plugin_active('wp-wall')) {
$options = WPWall_GetOptions();
if (strpos($query, 'comment_post_ID=' . $options['pageId'])) {
return $query;
}
}
if (strpos($query, $wpdb->comments)) {
$query = str_replace(" post_status = 'publish'", " {$wpdb->posts}.post_status = 'publish'", $query);
// theoretically, a slight performance enhancement if we can simplify the query to skip filtering of attachment comments
if (defined('SCOPER_NO_ATTACHMENT_COMMENTS') || false !== strpos($query, 'comment_post_ID =')) {
if (!strpos($query, "JOIN {$wpdb->posts}")) {
$query = preg_replace("/FROM\\s*{$wpdb->comments}\\s*WHERE /", "FROM {$wpdb->comments} INNER JOIN {$wpdb->posts} ON {$wpdb->posts}.ID = {$wpdb->comments}.comment_post_ID WHERE ", $query);
}
$query = apply_filters('objects_request_rs', $query, 'post', '', array('skip_teaser' => true));
} else {
$query = str_replace("user_id ", "{$wpdb->comments}.user_id ", $query);
$query = str_replace("SELECT {$wpdb->comments}.* FROM {$wpdb->comments}", "SELECT DISTINCT {$wpdb->comments}.* FROM {$wpdb->comments}", $query);
if (!strpos($query, ' DISTINCT ')) {
$query = str_replace("SELECT ", "SELECT DISTINCT ", $query);
}
$post_types = array_diff(get_post_types(array('public' => true)), array('attachment'));
$post_type_in = "'" . implode("','", $post_types) . "'";
$join = "LEFT JOIN {$wpdb->posts} as parent ON parent.ID = {$wpdb->posts}.post_parent AND parent.post_type IN ({$post_type_in}) AND {$wpdb->posts}.post_type = 'attachment'";
$use_post_types = scoper_get_option('use_post_types');
$where = array();
foreach ($post_types as $type) {
if (!empty($use_post_types[$type])) {
$where_post = apply_filters('objects_where_rs', '', 'post', $type, array('skip_teaser' => true));
} else {
$where_post = "AND 1=1";
}
$where[] = "{$wpdb->posts}.post_type = '{$type}' {$where_post}";
$where[] = "{$wpdb->posts}.post_type = 'attachment' AND parent.post_type = '{$type}' " . str_replace("{$wpdb->posts}.", "parent.", $where_post);
}
$where = agp_implode(' ) OR ( ', $where, ' ( ', ' ) ');
if (!strpos($query, "JOIN {$wpdb->posts}")) {
$query = str_replace("WHERE ", "INNER JOIN {$wpdb->posts} ON {$wpdb->posts}.ID = {$wpdb->comments}.comment_post_ID {$join} WHERE ( {$where} ) AND ", $query);
} else {
$query = str_replace("WHERE ", "{$join} WHERE {$where} AND ", $query);
}
}
}
}
}
return $query;
}
示例3: user_can_admin_object_rs
function user_can_admin_object_rs($src_name, $object_type, $object_id = false, $any_obj_role_check = false, $user = '')
{
if (is_content_administrator_rs()) {
return true;
}
global $scoper;
// TODO: is this necessary?
$is_new_object = !$object_id && false !== $object_id || 'post' == $src_name && !empty($GLOBALS['post']) && 'auto-draft' == $GLOBALS['post']->post_status;
if ($is_new_object) {
$status_name = 'post' == $src_name ? 'draft' : '';
} else {
$status_name = sanitize_key($scoper->data_sources->detect('status', $src_name, $object_id));
}
// TODO: is multi-value array ever passed?
if (is_array($object_type)) {
if (count($object_type) == 1) {
$object_type = reset($object_type);
} else {
// only WP roles should ever have multiple sources / otypes
$object_type = $scoper->data_sources->get_from_db('type', $src_name, $object_id);
}
}
$base_caps_only = $is_new_object;
// Possible TODO: re-implement OP_ADMIN distinction with admin-specific capabilities
//$admin_caps = $scoper->cap_defs->get_matching($src_name, $object_type, OP_ADMIN_RS, $status_name, $base_caps_only);
$admin_caps = $scoper->cap_defs->get_matching($src_name, $object_type, OP_EDIT_RS, $status_name, $base_caps_only);
$delete_caps = $scoper->cap_defs->get_matching($src_name, $object_type, OP_DELETE_RS, $status_name, $base_caps_only);
$reqd_caps = array_merge(array_keys($admin_caps), array_keys($delete_caps));
if (!$reqd_caps) {
return true;
}
// apparantly this src/otype has no admin caps, so no restriction to apply
// Note on 'require_full_object_role' argument:
// Normally we want to disregard "others" cap requirements if a role is assigned directly for an object
// This is an exception - we need to retain a "delete_others" cap requirement in case it is the
// distinguishing cap of an object administrator
$return = cr_user_can($reqd_caps, $object_id, 0, array('require_full_object_role' => true, 'skip_revision_allowance' => true));
if (!$return && !$object_id && $any_obj_role_check) {
// No object ID was specified, and current user does not have the cap blog-wide. Credit user for capability on any individual object.
// Possible TODO: re-implement OP_ADMIN distinction with admin-specific capabilities
//$admin_caps = $scoper->cap_defs->get_matching($src_name, $object_type, OP_ADMIN_RS, STATUS_ANY_RS);
$admin_caps = $scoper->cap_defs->get_matching($src_name, $object_type, OP_EDIT_RS, STATUS_ANY_RS);
$delete_caps = $scoper->cap_defs->get_matching($src_name, $object_type, OP_DELETE_RS, STATUS_ANY_RS);
if ($reqd_caps = array_merge(array_keys($admin_caps), array_keys($delete_caps))) {
if (!defined('DISABLE_QUERYFILTERS_RS')) {
global $cap_interceptor;
if ($cap_interceptor->user_can_for_any_object($reqd_caps)) {
$return = true;
}
}
}
}
return $return;
}
示例4: act_attachment_access
function act_attachment_access()
{
if (is_admin() || defined('DISABLE_QUERYFILTERS_RS') || is_content_administrator_rs() || !scoper_get_option('file_filtering')) {
return;
}
// if ( is_attachment() ) { as of WP 2.6, is_attachment() returns false for custom permalink attachment URL
if (is_attachment_rs()) {
//rs_errlog( 'IS an attachment:' );
require_once dirname(__FILE__) . '/attachment-template_rs.php';
AttachmentTemplate_RS::attachment_access();
}
}
示例5: flt_comments_clauses
function flt_comments_clauses($clauses, &$qry_obj)
{
global $wpdb;
if (is_content_administrator_rs()) {
$stati = array_merge(get_post_stati(array('public' => true)), get_post_stati(array('private' => true)));
if (!defined('SCOPER_NO_ATTACHMENT_COMMENTS')) {
$stati[] = 'inherit';
}
$status_csv = "'" . implode("','", $stati) . "'";
$clauses['where'] = preg_replace("/\\s*AND\\s*{$wpdb->posts}.post_status\\s*=\\s*[']?publish[']?/", "AND {$wpdb->posts}.post_status IN ({$status_csv})", $clauses['where']);
}
return $clauses;
}
示例6: _validate_assigner_roles
function _validate_assigner_roles($scope, $src_or_tx_name, $item_id, $roles)
{
if (!$item_id && !is_user_administrator_rs()) {
return false;
}
$user_has_role = array();
if (TERM_SCOPE_RS == $scope) {
foreach (array_keys($roles) as $role_handle) {
$role_attributes = $this->scoper->role_defs->get_role_attributes($role_handle);
$args = array('src_name' => $role_attributes->src_name, 'object_type' => $role_attributes->object_type);
$user_has_role[$role_handle] = $this->user_has_role_in_term($role_handle, $src_or_tx_name, $item_id, $args);
}
} else {
if ($require_blogwide_editor = scoper_get_option('role_admin_blogwide_editor_only')) {
global $current_user;
$is_user_administrator = is_user_administrator_rs();
$is_content_administrator = is_content_administrator_rs();
}
foreach (array_keys($roles) as $role_handle) {
// a user must have a blog-wide edit cap to modify editing role assignments (even if they have Editor role assigned for some current object)
if ($require_blogwide_editor) {
if (!$is_user_administrator && 'admin' == $require_blogwide_editor) {
$user_has_role[$role_handle] = false;
continue;
}
if (!$is_content_administrator && 'admin_content' == $require_blogwide_editor) {
$user_has_role[$role_handle] = false;
continue;
}
$src_name = $this->scoper->role_defs->member_property($role_handle, 'src_name');
$object_type = $this->scoper->role_defs->member_property($role_handle, 'object_type');
static $can_edit_blogwide;
if (!isset($can_edit_blogwide)) {
$can_edit_blogwide = array();
}
if (!isset($can_edit_blogwide[$src_name][$object_type])) {
$can_edit_blogwide[$src_name][$object_type] = $this->scoper->user_can_edit_blogwide($src_name, $object_type, array('require_others_cap' => true));
}
if (!$can_edit_blogwide[$src_name][$object_type]) {
$user_has_role[$role_handle] = false;
continue;
}
}
if (!empty($this->scoper->role_defs->role_caps[$role_handle])) {
$user_has_role[$role_handle] = cr_user_can(array_keys($this->scoper->role_defs->role_caps[$role_handle]), $item_id);
}
}
}
return $user_has_role;
}
示例7: flt_admin_bar_menu
function flt_admin_bar_menu(&$bar)
{
if (is_content_administrator_rs()) {
return;
}
$type = 'new-content';
foreach (get_post_types(array('public' => true), 'object') as $_post_type => $type_obj) {
$var = 'new-' . $_post_type;
if (isset($bar->menu->{$type}['children']->{$var})) {
if (!cr_user_can($type_obj->cap->edit_posts, 0, 0, array('skip_id_generation' => true, 'skip_any_object_check' => true))) {
unset($bar->menu->{$type}['children']->{$var});
}
}
}
}
示例8: get_page_titles
function get_page_titles()
{
global $wpdb;
$is_administrator = is_content_administrator_rs();
if (!$is_administrator) {
remove_filter('get_pages', array('ScoperHardway', 'flt_get_pages'), 1, 2);
}
// don't retrieve post_content, to save memory
$all_pages = scoper_get_results("SELECT ID, post_parent, post_title, post_date, post_date_gmt, post_status, post_name, post_modified, post_modified_gmt, guid, menu_order, comment_count FROM {$wpdb->posts} WHERE post_type = 'page'");
foreach (array_keys($all_pages) as $key) {
$all_pages[$key]->post_content = '';
}
// add an empty post_content property to each item, in case some plugin filter requires it
$all_pages = apply_filters('get_pages', $all_pages);
if (!$is_administrator) {
add_filter('get_pages', array('ScoperHardway', 'flt_get_pages'), 1, 2);
}
return scoper_get_property_array($all_pages, 'ID', 'post_title');
}
示例9: police_xmlrpc_action
function police_xmlrpc_action($method_name)
{
if (function_exists('is_content_administrator_rs') && is_content_administrator_rs()) {
return;
}
switch ($method_name) {
// This method has no business passing an empty array of categories. It usually means none are selected for a new post, and does not provide a hook for RS to filtering the default category prior to insertion
case 'mt.setPostCategories':
global $scoper_last_raw_post_data;
if (empty($scoper_last_raw_post_data)) {
return;
}
if (!$this->load_ixr()) {
return;
}
$msg = new IXR_Message($scoper_last_raw_post_data);
if ($msg->parse()) {
// params[0] = object id, params[3] = categories
if (is_array($msg->params) && !empty($msg->params[0]) && isset($msg->params[3]) && !$msg->params[3]) {
if ($terms = wp_get_object_terms($msg->params[0], 'category', array('fields' => 'ids'))) {
foreach ($terms as $key => $val) {
$terms[$key] = (int) $val;
}
// otherwise wp_set_object_terms will store as a new category named "id"
if (empty($this->scheduled_term_restoration)) {
$this->scheduled_term_restoration = array();
add_action('set_object_terms', array(&$this, 'maybe_restore_object_terms'), 99, 6);
}
$this->scheduled_term_restoration[$msg->params[0]]['category'] = $terms;
}
}
}
break;
// 'mt.setPostCategories'
}
// end switch
}
示例10: act_maybe_hide_quickedit
function act_maybe_hide_quickedit()
{
if (is_content_administrator_rs()) {
return;
}
$object_type = awp_post_type_from_uri();
if (!$GLOBALS['scoper']->user_can_edit_blogwide('post', $object_type, array('require_others_cap' => true))) {
echo "<div id='rs_hide_quickedit'></div>";
}
}
示例11: scoper_init
function scoper_init()
{
global $scoper;
// Work around bug in More Taxonomies (and possibly other plugins) where category taxonomy is overriden without setting it public
foreach (array('category', 'post_tag') as $taxonomy) {
if (isset($GLOBALS['wp_taxonomies'][$taxonomy])) {
$GLOBALS['wp_taxonomies'][$taxonomy]->public = true;
}
}
if (IS_MU_RS && agp_is_plugin_network_active(SCOPER_BASENAME)) {
global $scoper_sitewide_options;
$scoper_sitewide_options = apply_filters('sitewide_options_rs', $scoper_sitewide_options);
}
require_once dirname(__FILE__) . '/wp-cap-helper_cr.php';
WP_Cap_Helper_CR::establish_status_caps();
WP_Cap_Helper_CR::force_distinct_post_caps();
WP_Cap_Helper_CR::force_distinct_taxonomy_caps();
if (is_admin()) {
require_once dirname(__FILE__) . '/admin/admin-init_rs.php';
// TODO: why is the require statement up top not sufficient for NGG 1.7.2 uploader?
scoper_admin_init();
}
//log_mem_usage_rs( 'scoper_admin_init done' );
require_once dirname(__FILE__) . '/scoped-user.php';
require_once dirname(__FILE__) . '/role-scoper_main.php';
//log_mem_usage_rs( 'require role-scoper_main' );
if (empty($scoper)) {
// set_current_user may have already triggered scoper creation and role_cap load
$scoper = new Scoper();
//log_mem_usage_rs( 'new Scoper done' );
$scoper->init();
}
// ensure that content administrators (as defined by SCOPER_CONTENT_ADMIN_CAP) have all caps for custom types by default
if (is_content_administrator_rs()) {
global $current_rs_user;
if (!empty($current_rs_user)) {
// user object not set when scoper_init() is manually invoked to support htaccess rule generation on plugin activation
foreach (get_post_types(array('public' => true, '_builtin' => false)) as $name) {
$current_rs_user->assigned_blog_roles[ANY_CONTENT_DATE_RS]["rs_{$name}_editor"] = true;
}
$taxonomies = get_taxonomies(array('public' => true, '_builtin' => false));
$taxonomies[] = 'nav_menu';
foreach ($taxonomies as $name) {
$current_rs_user->assigned_blog_roles[ANY_CONTENT_DATE_RS]["rs_{$name}_manager"] = true;
}
$current_rs_user->merge_scoped_blogcaps();
$GLOBALS['current_user']->allcaps = array_merge($GLOBALS['current_user']->allcaps, $current_rs_user->allcaps);
$GLOBALS['current_user']->assigned_blog_roles = $current_rs_user->assigned_blog_roles;
}
}
if (!empty($_GET['action']) && 'expire_file_rules' == $_GET['action']) {
require_once dirname(__FILE__) . '/attachment-helper_rs.php';
scoper_requested_file_rule_expire();
}
//log_mem_usage_rs( 'scoper->init() done' );
}
示例12: add_main_filters
function add_main_filters()
{
$is_admin = is_admin();
$is_administrator = is_content_administrator_rs();
$disable_queryfilters = defined('DISABLE_QUERYFILTERS_RS');
$frontend_admin = false;
if (!defined('DOING_CRON')) {
if ($this->is_front()) {
if (!$disable_queryfilters) {
require_once dirname(__FILE__) . '/query-interceptor-front_rs.php';
}
if (!$is_administrator) {
require_once dirname(__FILE__) . '/qry-front_non-administrator_rs.php';
$GLOBALS['feed_interceptor'] = new FeedInterceptor_RS();
// file already required in role-scoper.php
}
require_once dirname(__FILE__) . '/template-interceptor_rs.php';
$GLOBALS['template_interceptor'] = new TemplateInterceptor_RS();
$frontend_admin = !scoper_get_option('no_frontend_admin');
// potential performance enhancement
if (!empty($_REQUEST['s']) && function_exists('relevanssi_query')) {
require_once dirname(__FILE__) . '/relevanssi-helper-front_rs.php';
$rel_helper_rs = new Relevanssi_Search_Filter_RS();
}
}
// ===== Filters which are always loaded (except on plugin scripts), for any access type
include_once dirname(__FILE__) . '/hardway/wp-patches_agp.php';
// simple patches for WP
if ($this->is_front() || 'edit.php' == $GLOBALS['pagenow']) {
require_once dirname(__FILE__) . '/query-interceptor-base_rs.php';
$GLOBALS['query_interceptor_base'] = new QueryInterceptorBase_RS();
// listing filter used for role status indication in edit posts/pages and on front end by template functions
}
}
// ===== Filters which support automated role maintenance following content creation/update
// Require an explicitly set option to skip these for front end access, just in case other plugins modify content from the front end.
if ($is_admin || defined('XMLRPC_REQUEST') || $frontend_admin || defined('DOING_CRON')) {
require_once dirname(__FILE__) . '/admin/cache_flush_rs.php';
require_once dirname(__FILE__) . '/admin/filters-admin_rs.php';
$GLOBALS['scoper_admin_filters'] = new ScoperAdminFilters();
if (defined('RVY_VERSION')) {
// Support Revisionary references to $scoper->filters_admin (TODO: eventually phase this out)
$this->filters_admin =& $GLOBALS['scoper_admin_filters'];
}
}
// =====
}
示例13: user_can_associate_main
function user_can_associate_main($post_type)
{
if (is_content_administrator_rs()) {
return true;
}
if ('no_parent_filter' == scoper_get_option('lock_top_pages')) {
return true;
}
if (!($post_type_obj = get_post_type_object($post_type))) {
return true;
}
if (!$post_type_obj->hierarchical) {
return true;
}
// currently used only for page type, or for all if constant is set
$top_pages_locked = scoper_get_option('lock_top_pages');
if ('page' == $post_type || defined('SCOPER_LOCK_OPTION_ALL_TYPES')) {
if ('1' === $top_pages_locked) {
// only administrators can change top level structure
return false;
} elseif ('no_parent_filter' === $top_pages_locked) {
return true;
} else {
$reqd_caps = 'author' === $top_pages_locked ? array($post_type_obj->cap->publish_posts) : array($post_type_obj->cap->edit_others_posts);
$roles = $GLOBALS['scoper']->role_defs->qualify_roles($reqd_caps);
return array_intersect_key($roles, $GLOBALS['current_rs_user']->blog_roles[ANY_CONTENT_DATE_RS]);
}
} else {
return true;
}
}
示例14: display_ui_user_roles
function display_ui_user_roles($user, $groups_only = false)
{
global $scoper;
$blog_roles = array();
$term_roles = array();
$blog_roles = $user->get_blog_roles_daterange('rs', array('include_role_duration_key' => true, 'enforce_duration_limits' => false));
// arg: return array with additional key dimension for role duration
// for Administrators, display any custom post General Roles which were auto-assigned to maintain default editing rights
global $current_rs_user;
if ($current_rs_user->ID == $user->ID) {
if (is_content_administrator_rs()) {
$blog_roles[''][''] = isset($blog_roles['']['']) ? array_merge($current_rs_user->assigned_blog_roles['']) : $current_rs_user->assigned_blog_roles[''];
}
}
foreach ($this->scoper->taxonomies->get_all() as $taxonomy => $tx) {
$term_roles[$taxonomy] = $user->get_term_roles_daterange($taxonomy, 'rs', array('include_role_duration_key' => true, 'enforce_duration_limits' => false));
}
// arg: return array with additional key dimension for role duration
$duration_limits_enabled = scoper_get_option('role_duration_limits');
$content_date_limits_enabled = scoper_get_option('role_content_date_limits');
$html = '';
if ($groups_only) {
if (IS_MU_RS && scoper_get_option('mu_sitewide_groups', true)) {
global $blog_id;
$list = scoper_get_blog_list(0, 'all');
$blog_path = '';
foreach ($list as $blog) {
if ($blog['blog_id'] == $blog_id) {
$blog_path = $blog['path'];
break;
}
}
$group_caption = sprintf(__('Group Roles %1$s(for %2$s)%3$s', 'scoper'), '<span style="font-weight: normal">', rtrim($blog_path, '/'), '</span>');
} else {
$group_caption = __('Group Roles', 'scoper');
}
} else {
$html .= "<div id='userprofile_rolesdiv_rs' class='rs-scoped_role_profile'>";
$html .= "<h3>" . __('Scoped Roles', 'scoper') . "</h3>";
$wp_blog_roles = array_intersect_key($user->assigned_blog_roles[''], $scoper->role_defs->get_matching('wp'));
if (!empty($wp_blog_roles)) {
$display_names = array();
foreach (array_keys($wp_blog_roles) as $role_handle) {
$display_names[] = $scoper->role_defs->get_display_name($role_handle);
}
$html .= sprintf(__("<strong>Assigned WordPress Role:</strong> %s", 'scoper'), implode(", ", $display_names));
if ($contained_roles = $this->scoper->role_defs->get_contained_roles(array_keys($wp_blog_roles), false, 'rs')) {
$display_names = array();
foreach (array_keys($contained_roles) as $role_handle) {
$display_names[] = $this->scoper->role_defs->get_display_name($role_handle);
}
$html .= '<br /><span class="rs-gray">';
$html .= sprintf(__("(contains %s)", 'scoper'), implode(", ", $display_names));
$html .= '</span>';
}
}
$html .= '<br /><br />';
}
$display_names = array();
foreach (array_keys($blog_roles) as $duration_key) {
if (is_serialized($duration_key)) {
$role_date_limits = unserialize($duration_key);
$role_date_limits->date_limited = true;
} else {
$role_date_limits = array();
}
foreach (array_keys($blog_roles[$duration_key]) as $date_key) {
$display_names = array();
if (is_serialized($date_key)) {
$content_date_limits = unserialize($date_key);
$content_date_limits->content_date_limited = true;
} else {
$content_date_limits = array();
}
$date_caption = '';
if ($role_date_limits || $content_date_limits) {
$limit_class = '';
// unused byref arg
$limit_style = '';
// unused byref arg
$link_class = '';
// unused byref arg
ScoperAdminUI::set_agent_formatting(array_merge((array) $role_date_limits, (array) $content_date_limits), $date_caption, $limit_class, $link_class, $limit_style, false);
// arg: no title='' wrapper around date_caption
$date_caption = '<span class="rs-gray"> ' . trim($date_caption) . '</span>';
}
if ($rs_blog_roles = $this->scoper->role_defs->filter($blog_roles[$duration_key][$date_key], array('role_type' => 'rs'))) {
foreach (array_keys($rs_blog_roles) as $role_handle) {
$display_names[] = $this->scoper->role_defs->get_display_name($role_handle);
}
$url = "admin.php?page=rs-general_roles";
$linkopen = "<strong><a href='{$url}'>";
$linkclose = "</a></strong>";
$list = implode(", ", $display_names);
if ($groups_only) {
$html .= sprintf(_n('<strong>%1$sGeneral Role%2$s</strong>%4$s: %3$s', '<strong>%1$sGeneral Roles%2$s</strong>%4$s: %3$s', count($display_names), 'scoper'), $linkopen, $linkclose, $list, $date_caption);
} else {
$html .= sprintf(_n('<strong>Additional %1$sGeneral Role%2$s</strong>%4$s: %3$s', '<strong>Additional %1$sGeneral Roles%2$s</strong>%4$s: %3$s', count($display_names), 'scoper'), $linkopen, $linkclose, $list, $date_caption);
}
if ($contained_roles = $this->scoper->role_defs->get_contained_roles(array_keys($rs_blog_roles), false, 'rs')) {
//.........这里部分代码省略.........
示例15: flt_objects_listing
function flt_objects_listing($results, $src_name, $object_types, $args = array())
{
global $wpdb;
// it's not currently necessary or possible to log listed revisions from here
//if ( isset($wpdb->last_query) && strpos( $wpdb->last_query, "post_type = 'revision'") )
// return $results;
// if currently listed IDs are not already in post_cache, make our own equivalent memcache
// ( create this cache for any data source, front end or admin )
if ('post' == $src_name) {
global $wp_object_cache;
}
$listed_ids = array();
//if ( ('post' != $src_name) || empty($wp_object_cache->cache['posts']) ) {
if (empty($this->scoper->listed_ids[$src_name])) {
if ($col_id = $this->scoper->data_sources->member_property($src_name, 'cols', 'id')) {
$listed_ids = array();
// In edit.php, WP forces all objects into recordset for hierarchical post types. But for perf enchancement, we need to know IDs of items which are actually listed
if ('edit.php' == $GLOBALS['pagenow']) {
$post_type = !empty($_GET['post_type']) ? sanitize_key($_GET['post_type']) : 'post';
$determine_listed_ids = !is_content_administrator_rs() && is_post_type_hierarchical($post_type) && !empty($GLOBALS['query_interceptor']->last_request[$src_name]) && !strpos($GLOBALS['query_interceptor']->last_request[$src_name], 'LIMIT ');
if ($determine_listed_ids) {
// mimic recordset paging used in edit.php
$pagenum = isset($_GET['paged']) ? absint($_GET['paged']) : 0;
if (empty($pagenum)) {
$pagenum = 1;
}
$edit_per_page = 'edit_' . $post_type . '_per_page';
$per_page = (int) get_user_option($edit_per_page);
if (empty($per_page) || $per_page < 1) {
$per_page = 20;
}
$per_page = apply_filters($edit_per_page, $per_page);
$per_page = apply_filters('edit_posts_per_page', $per_page, $post_type);
if (count($results) <= $per_page) {
$determine_listed_ids = false;
}
}
} else {
$determine_listed_ids = false;
}
if ($determine_listed_ids) {
// Construct and execute a secondary query (for IDs only) which includes the paging clause that would be used if edit.php did not defeat it
$pgstrt = ($pagenum - 1) * $per_page . ', ';
$limits = ' LIMIT ' . $pgstrt . $per_page;
global $wpdb;
$qry = $GLOBALS['query_interceptor']->last_request[$src_name] . $limits;
$qry = str_replace("{$wpdb->posts}.*", "{$wpdb->posts}.ID", $qry);
$_results = scoper_get_results($qry);
foreach ($_results as $row) {
if (isset($row->{$col_id})) {
$listed_ids[$row->{$col_id}] = true;
}
}
} else {
// No secondary query, just buffer all IDs in the results set
foreach ($results as $row) {
if (isset($row->{$col_id})) {
$listed_ids[$row->{$col_id}] = true;
}
}
}
if (empty($this->scoper->listed_ids)) {
$this->scoper->listed_ids = array();
}
$this->scoper->listed_ids[$src_name] = $listed_ids;
}
} else {
return $results;
}
//}
// now determine what restrictions were in place on these results
// (currently only for post data source, front end or manage posts/pages)
//
// possible todo: support other data sources, WP role type
if ('edit.php' == $GLOBALS['pagenow']) {
if (scoper_get_otype_option('restrictions_column', 'post') || scoper_get_otype_option('term_roles_column', 'post') || scoper_get_otype_option('object_roles_column', 'post')) {
global $scoper_role_usage;
require_once dirname(__FILE__) . '/role_usage_rs.php';
$scoper_role_usage = new Role_Usage_RS();
$scoper_role_usage->determine_role_usage_rs('post', $listed_ids);
}
}
return $results;
}