function ensure_init() { global $scoper; if (!isset($scoper) || is_null($scoper)) { require_once SCOPER_ABSPATH . '/role-scoper_main.php'; $scoper = new Scoper(); scoper_init(); } if (empty($scoper->data_sources)) { $scoper->load_config(); } }
function scoper_startup_error($msg_id = '') { // this is the normal situation on first pass after activation if ('wp_role_type' == $msg_id) { awp_notice('Role Scoper cannot operate because the "WP" Role Type is no longer supported. Please re-activate <a href="http://downloads.wordpress.org/plugin/role-scoper/download/">Role Scoper version 1.2.8 or earlier</a>, set Roles > Options > Role Type to "RS", then re-establish Roles and Restrictions before upgrading. <strong>All content is hidden until you deactivate this Role Scoper version.</strong>', 'role-scoper'); } // To prevent inadverant content exposure, default to blocking all content if another plugin steals wp_set_current_user definition. if ('plugins.php' != $GLOBALS['pagenow']) { add_filter('posts_where', create_function('$a', "return 'AND 1=2';"), 99); add_filter('posts_results', create_function('$a', "return array();"), 1); add_filter('get_pages', create_function('$a', "return array();"), 99); add_filter('get_bookmarks', create_function('$a', "return array();"), 99); add_filter('get_categories', create_function('$a', "return array();"), 99); add_filter('get_terms', create_function('$a', "return array();"), 99); add_filter('option_sticky_posts', create_function('$a', "return false;"), 99); // Also run interference for all custom-defined where_hook, request_filter or results_filter require_once dirname(__FILE__) . '/role-scoper_main.php'; global $scoper, $wpdb, $current_user; $buffer_user = $current_user; require_once dirname(__FILE__) . '/role-scoper_init.php'; $scoper = new Scoper(); $scoper->load_config(); $GLOBALS['current_user'] = $buffer_user; foreach ($scoper->data_sources->get_all() as $src) { if (!empty($src->query_hooks->request)) { add_filter($src->query_hooks->request, create_function('$a', "return 'SELECT * FROM {$wpdb->posts} WHERE 1=2';"), 99); } if (!empty($src->query_hooks->where)) { add_filter($src->query_hooks->where, create_function('$a', "return 'AND 1=2';"), 99); } if (!empty($src->query_hooks->results)) { add_filter($src->query_hooks->results, create_function('$a', "return array();"), 1); } } } }
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' ); }