function add_meta_boxes() { // ========= register WP-rendered metaboxes ============ $post_type = pp_find_post_type(); if (!current_user_can('pp_assign_roles') || apply_filters('pp_disable_exception_ui', false, 'post', 0, $post_type)) { return; } $hidden_types = apply_filters('pp_hidden_post_types', array()); if (!empty($hidden_types[$post_type])) { return; } if (!in_array($post_type, pp_get_enabled_post_types())) { if (!in_array($post_type, array('revision')) && pp_get_option('display_hints')) { $type_obj = get_post_type_object($post_type); if ($type_obj->public) { if (!in_array($post_type, apply_filters('pp_unfiltered_post_types', array()))) { add_meta_box("pp_enable_type", __('Press Permit Settings', 'pp'), array(&$this, 'draw_settings_ui'), $post_type, 'advanced', 'default', array()); } } } return; } //if ( ! $this->_roles_editable( $src_name, $object_type ) ) // return; $ops = _pp_can_set_exceptions('read', $post_type, array('via_item_source' => 'post', 'for_item_source' => 'post')) ? array('read' => true) : array(); $operations = apply_filters('pp_item_edit_exception_ops', $ops, 'post', $post_type); foreach (array_keys($operations) as $op) { if ($op_obj = pp_get_op_object($op, $post_type)) { // $screen = null, $context = 'advanced', $priority = 'default', $callback_args = null add_meta_box("pp_{$op}_{$post_type}_exceptions", sprintf(__('%s Exceptions', 'pp'), $op_obj->noun_label), array(&$this, 'draw_exceptions_ui'), $post_type, 'advanced', 'default', array('op' => $op)); } } }
public static function item_update_process_exceptions($via_item_source, $for_item_source, $item_id, $args = array()) { $defaults = array_fill_keys(array('is_new', 'set_parent', 'last_parent', 'disallow_manual_entry', 'force_for_item_type'), false); $args = apply_filters('pp_item_update_process_roles_args', array_merge($defaults, array('via_item_type' => '', 'for_item_status' => ''), (array) $args, compact('via_item_source', 'for_item_source', 'item_id')), $via_item_source, $for_item_source, $item_id); if (!defined('PP_EXTRA_ITEM_UPDATE_ARGS')) { $args['for_item_status'] = ''; } extract($args, EXTR_SKIP); if ($can_assign_roles = current_user_can('pp_assign_roles')) { if (apply_filters('pp_disable_exception_edit', false, $via_item_source, $item_id)) { $can_assign_roles = false; } } if (!$disallow_manual_entry) { $disallow_manual_entry = defined('XMLRPC_REQUEST'); } $posted_exceptions = isset($_POST['pp_exceptions']) ? $_POST['pp_exceptions'] : array(); if ($posted_exceptions && !$disallow_manual_entry && $can_assign_roles) { foreach (array_keys($posted_exceptions) as $for_item_type) { $_for_type = '(all)' == $for_item_type ? '' : $for_item_type; if ($_for_type && 'post' == $for_item_source && !post_type_exists($_for_type)) { continue; } if ('term' == $for_item_source && !taxonomy_exists($_for_type)) { continue; } foreach (array_keys($posted_exceptions[$for_item_type]) as $op) { if (!_pp_can_set_exceptions($op, $for_item_type, compact('via_item_source', 'via_item_type', 'item_id', 'for_item_source'))) { continue; } foreach (array_keys($posted_exceptions[$for_item_type][$op]) as $agent_type) { $args['for_item_type'] = $_for_type; $args['operation'] = $op; $args['agent_type'] = $agent_type; if (ppc_assign_exceptions($posted_exceptions[$for_item_type][$op][$agent_type], $agent_type, $args)) { // assignments[assign_for][agent_id] = has_access $roles_customized = true; // may be true already based on a prior role edit } } // end foreach group type } } } if ('post' == $via_item_source && 'post' == $for_item_source) { if ($post = get_post($item_id)) { if ('attachment' == $post->post_type) { // don't propagate page exceptions to attachments return; } } } self::inherit_parent_exceptions($item_id, compact('via_item_source', 'via_item_type', 'set_parent', 'last_parent', 'is_new')); }
function add_meta_boxes() { // ========= register WP-rendered metaboxes ============ global $typenow; $taxonomy = isset($_REQUEST['taxonomy']) ? pp_sanitize_key($_REQUEST['taxonomy']) : ''; if (!in_array($taxonomy, pp_get_enabled_taxonomies())) { return; } $tt_id = !empty($_REQUEST['tag_ID']) ? pp_termid_to_ttid((int) $_REQUEST['tag_ID'], $taxonomy) : 0; $post_type = !empty($_REQUEST['pp_universal']) ? '' : $typenow; $hidden_types = apply_filters('pp_hidden_post_types', array()); $hidden_taxonomies = apply_filters('pp_hidden_taxonomies', array()); if (!empty($hidden_taxonomies[$taxonomy]) || $post_type && !empty($hidden_types[$post_type])) { return; } //TODO: selectively enable role assignment by non-administrator if (!current_user_can('pp_assign_roles') || apply_filters('pp_disable_exception_ui', false, 'term', $tt_id, $post_type)) { return; } //if ( ! $this->_roles_editable( $src_name, $object_type ) ) // return; $tx = get_taxonomy($taxonomy); $type_obj = get_post_type_object($post_type); $register_type = $post_type ? $post_type : 'post'; $ops = _pp_can_set_exceptions('read', $post_type, array('via_item_source' => 'term', 'via_item_type' => $taxonomy, 'for_item_source' => 'post')) ? array('read' => true) : array(); $operations = apply_filters('pp_item_edit_exception_ops', $ops, 'post', $taxonomy, $post_type); $boxes = array(); foreach (array_keys($operations) as $op) { if ($op_obj = pp_get_op_object($op, $post_type)) { if ('assign' == $op) { $title = $post_type ? sprintf(__('%1$s %2$s %3$s Exceptions', 'pp'), $type_obj->labels->singular_name, $tx->labels->singular_name, $op_obj->noun_label) : sprintf(__('%1$s %2$s Exceptions (all post types)', 'pp'), $tx->labels->singular_name, $op_obj->noun_label); } elseif (in_array($op, array('read', 'edit'))) { $title = $post_type ? sprintf(__('%1$s %2$s Exceptions (all post statuses)', 'pp'), $type_obj->labels->singular_name, $op_obj->noun_label) : sprintf(__('%1$s Exceptions (all post types, statuses)', 'pp'), $op_obj->noun_label); } else { $title = $post_type ? sprintf(__('%1$s %2$s Exceptions', 'pp'), $type_obj->labels->singular_name, $op_obj->noun_label) : sprintf(__('%1$s Exceptions (all post types)', 'pp'), $op_obj->noun_label); } pp_set_array_elem($boxes, array($op, "pp_{$op}_{$post_type}_exceptions")); $boxes[$op]["pp_{$op}_{$post_type}_exceptions"]['for_item_type'] = $post_type; $boxes[$op]["pp_{$op}_{$post_type}_exceptions"]['title'] = $title; } } $boxes = apply_filters('pp_term_exceptions_metaboxes', $boxes, $taxonomy, $post_type); foreach ($boxes as $op => $boxes) { foreach ($boxes as $box_id => $_box) { // $screen = null, $context = 'advanced', $priority = 'default', $callback_args = null add_meta_box($box_id, $_box['title'], array(&$this, 'draw_exceptions_ui'), $register_type, 'normal', 'default', array('for_item_type' => $_box['for_item_type'], 'op' => $op)); } } }
$topic = sanitize_text_field(str_replace('\\\\:', ',', $_GET['pp_topic'])); $omit_admins = (bool) $_GET['pp_omit_admins']; $context = isset($_GET['pp_context']) ? pp_sanitize_key($_GET['pp_context']) : ''; if (strpos($topic, ',')) { $arr_topic = explode(',', $topic); if (isset($arr_topic[1])) { if (taxonomy_exists($context)) { $verified = true; $ops = _pp_can_set_exceptions($arr_topic[0], $arr_topic[1], array('via_item_source' => 'term', 'via_item_type' => $context, 'for_item_source' => 'post')) ? array('read' => true) : array(); $operations = apply_filters('pp_item_edit_exception_ops', $ops, 'post', $context, $arr_topic[1]); if (!in_array($arr_topic[0], $operations)) { die(-1); } } elseif (post_type_exists($arr_topic[1])) { $verified = true; $ops = _pp_can_set_exceptions($arr_topic[0], $arr_topic[1], array('via_item_source' => 'post', 'for_item_source' => 'post')) ? array('read' => true) : array(); $operations = apply_filters('pp_item_edit_exception_ops', $ops, 'post', $arr_topic[1]); if (!in_array($arr_topic[0], $operations)) { die(-1); } } } } elseif ('member' == $topic) { $verified = true; $group_type = pp_group_type_exists($context) ? $context : 'pp_group'; if (!pp_has_group_cap('pp_manage_members', $agent_id, $group_type)) { die(-1); } } elseif ('select-author' == $topic) { $verified = true; $post_type = post_type_exists($context) ? $context : 'page';