/** * Create module Backbone template * for administration * * @since 2.0 * @return void */ public function template_condition() { if (WPCACore::post_types()->has(get_post_type())) { echo WPCAView::make("module/condition_template", array('id' => $this->id, 'placeholder' => $this->placeholder, 'default' => $this->default_value))->render(); } }
public function initiate() { parent::initiate(); if (is_admin()) { global $q_config; //Disable multilanguage if (is_array($q_config["post_type_excluded"])) { foreach (WPCACore::post_types()->get_all() as $name => $post_type) { $q_config["post_type_excluded"][] = $name; } $q_config["post_type_excluded"][] = WPCACore::TYPE_CONDITION_GROUP; } } }
/** * Constructor * * @param string $id * @param string $title * @param boolean $ajax * @param string $description */ public function __construct($id, $title, $ajax = false, $description = "") { $this->id = $id; $this->name = $title; $this->ajax = $ajax; $this->description = $description; if (is_admin()) { add_action('wpca/modules/admin-box', array(&$this, 'meta_box_content')); add_action('wpca/modules/save-data', array(&$this, 'save_data')); add_filter('wpca/modules/print-data', array(&$this, 'print_group_data'), 10, 2); foreach (WPCACore::post_types()->get_all() as $post_type) { add_filter('manage_' . $post_type->name . '_columns', array(&$this, 'metabox_preferences')); } if ($this->ajax) { add_action('wp_ajax_wpca/module/' . $this->id, array(&$this, 'ajax_print_content')); } } add_filter('wpca/modules/context-data', array(&$this, 'parse_context_data')); }
/** * Register taxonomies to sidebar post type * * @since 1.0 * @return void */ public function add_taxonomies_to_sidebar() { foreach ($this->_get_taxonomies() as $tax) { foreach (WPCACore::post_types()->get_all() as $post_type) { register_taxonomy_for_object_type($tax->name, $post_type->name); } } }
/** * Automatically select child of selected parent * * @since 1.0 * @param string $new_status * @param string $old_status * @param WP_Post $post * @return void */ public function post_ancestry_check($new_status, $old_status, $post) { if (!WPCACore::post_types()->has($post->post_type) && $post->post_type != WPCACore::TYPE_CONDITION_GROUP) { $status = array('publish', 'private', 'future'); // Only new posts are relevant if (!in_array($old_status, $status) && in_array($new_status, $status)) { $post_type = get_post_type_object($post->post_type); if ($post_type->hierarchical && $post_type->public && $post->post_parent) { // Get sidebars with post ancestor wanting to auto-select post $query = new WP_Query(array('post_type' => WPCACore::TYPE_CONDITION_GROUP, 'meta_query' => array('relation' => 'AND', array('key' => WPCACore::PREFIX . $this->id, 'value' => WPCACore::PREFIX . 'sub_' . $post->post_type, 'compare' => '='), array('key' => WPCACore::PREFIX . $this->id, 'value' => get_ancestors($post->ID, $post->post_type), 'type' => 'numeric', 'compare' => 'IN')))); if ($query && $query->found_posts) { foreach ($query->posts as $sidebar) { add_post_meta($sidebar->ID, WPCACore::PREFIX . $this->id, $post->ID); } } } } } }
/** * Remove sidebars from multilingual list * * @since 1.0 * @param array $post_types * @return array */ public function remove_sidebar_multilingual($post_types) { foreach (WPCACore::post_types()->get_all() as $post_type) { unset($post_types[$post_type->name]); } return $post_types; }
/** * Create restrict post type and add it to WPCACore * * @since 0.1 * @return void */ public function create_restrict_type() { // Register the sidebar type register_post_type(RUA_App::TYPE_RESTRICT, array('labels' => array('name' => __('Access Levels', RUA_App::DOMAIN), 'singular_name' => __('Access Level', RUA_App::DOMAIN), 'add_new' => _x('Add New', 'level', RUA_App::DOMAIN), 'add_new_item' => __('Add New Access Level', RUA_App::DOMAIN), 'edit_item' => __('Edit Access Level', RUA_App::DOMAIN), 'new_item' => __('New Access Level', RUA_App::DOMAIN), 'all_items' => __('Access Levels', RUA_App::DOMAIN), 'view_item' => __('View Access Level', RUA_App::DOMAIN), 'search_items' => __('Search Access Levels', RUA_App::DOMAIN), 'not_found' => __('No Access Levels found', RUA_App::DOMAIN), 'not_found_in_trash' => __('No Access Levels found in Trash', RUA_App::DOMAIN), 'parent_item_colon' => __('Extend Level', RUA_App::DOMAIN), 'ca_title' => __('Grant explicit access to', RUA_App::DOMAIN), 'ca_not_found' => __('No content. Please add at least one condition group to restrict content.', RUA_App::DOMAIN)), 'capabilities' => array('edit_post' => RUA_App::CAPABILITY, 'read_post' => RUA_App::CAPABILITY, 'delete_post' => RUA_App::CAPABILITY, 'edit_posts' => RUA_App::CAPABILITY, 'delete_posts' => RUA_App::CAPABILITY, 'edit_others_posts' => RUA_App::CAPABILITY, 'publish_posts' => RUA_App::CAPABILITY, 'read_private_posts' => RUA_App::CAPABILITY), 'show_ui' => true, 'show_in_menu' => 'users.php', 'query_var' => false, 'rewrite' => false, 'hierarchical' => true, 'menu_position' => 26.099, 'supports' => array('title', 'page-attributes'), 'menu_icon' => '')); WPCACore::post_types()->add(RUA_App::TYPE_RESTRICT); }
/** * Create sidebar post type * Add it to content aware engine * * @return void */ public function init_sidebar_type() { // Register the sidebar type register_post_type(CAS_App::TYPE_SIDEBAR, array('labels' => array('name' => __('Sidebars', "content-aware-sidebars"), 'singular_name' => __('Sidebar', "content-aware-sidebars"), 'add_new' => _x('Add New', 'sidebar', "content-aware-sidebars"), 'add_new_item' => __('Add New Sidebar', "content-aware-sidebars"), 'edit_item' => __('Edit Sidebar', "content-aware-sidebars"), 'new_item' => __('New Sidebar', "content-aware-sidebars"), 'all_items' => __('All Sidebars', "content-aware-sidebars"), 'view_item' => __('View Sidebar', "content-aware-sidebars"), 'search_items' => __('Search Sidebars', "content-aware-sidebars"), 'not_found' => __('No sidebars found', "content-aware-sidebars"), 'not_found_in_trash' => __('No sidebars found in Trash', "content-aware-sidebars"), 'ca_title' => __('Display sidebar with', "content-aware-sidebars"), 'ca_not_found' => __('No content. Please add at least one condition group to make the sidebar content aware.', "content-aware-sidebars")), 'capabilities' => array('edit_post' => CAS_App::CAPABILITY, 'read_post' => CAS_App::CAPABILITY, 'delete_post' => CAS_App::CAPABILITY, 'edit_posts' => CAS_App::CAPABILITY, 'delete_posts' => CAS_App::CAPABILITY, 'edit_others_posts' => CAS_App::CAPABILITY, 'publish_posts' => CAS_App::CAPABILITY, 'read_private_posts' => CAS_App::CAPABILITY), 'show_ui' => true, 'show_in_menu' => true, 'query_var' => false, 'rewrite' => false, 'menu_position' => 25.099, 'supports' => array('title', 'page-attributes'), 'menu_icon' => 'dashicons-welcome-widgets-menus')); WPCACore::post_types()->add(CAS_App::TYPE_SIDEBAR); }