/** * Create post meta fields * @global array $wp_registered_sidebars * @return void */ private function init_metadata() { global $wp_registered_sidebars; // List of sidebars $sidebar_list = array(); foreach ($wp_registered_sidebars as $sidebar) { $sidebar_list[$sidebar['id']] = $sidebar['name']; } $this->metadata = new WPCAObjectManager(); $this->metadata->add(new WPCAMeta('exposure', __('Exposure', "content-aware-sidebars"), 1, 'select', array(__('Singular', "content-aware-sidebars"), __('Singular & Archive', "content-aware-sidebars"), __('Archive', "content-aware-sidebars"))), 'exposure')->add(new WPCAMeta('handle', _x('Handle', 'option', "content-aware-sidebars"), 0, 'select', array(0 => __('Replace', "content-aware-sidebars"), 1 => __('Merge', "content-aware-sidebars"), 2 => __('Manual', "content-aware-sidebars"), 3 => __('Forced replace', "content-aware-sidebars")), __('Replace host sidebar, merge with it or add sidebar manually.', "content-aware-sidebars")), 'handle')->add(new WPCAMeta('host', __('Host Sidebar', "content-aware-sidebars"), 'sidebar-1', 'select', $sidebar_list), 'host')->add(new WPCAMeta('merge_pos', __('Merge Position', "content-aware-sidebars"), 1, 'select', array(__('Top', "content-aware-sidebars"), __('Bottom', "content-aware-sidebars")), __('Place sidebar on top or bottom of host when merging.', "content-aware-sidebars")), 'merge_pos'); }
/** * Add post type to the manager * * @since 1.0 * @param int|WP_Post $post_type */ public function add($post_type, $name = "") { if (!is_object($post_type)) { $post_type = get_post_type_object($post_type); } parent::add($post_type, $post_type->name); }
/** * Create and populate metadata fields * * @since 0.1 * @return void */ private function _init_metadata() { $role_list = array(-1 => __("Do not synchronize", RUA_App::DOMAIN), 0 => __('Not logged-in', RUA_App::DOMAIN)); $posts_list = array(); if (is_admin()) { foreach (get_editable_roles() as $id => $role) { $role_list[$id] = $role['name']; } //TODO: autocomplete instead of getting all pages foreach (get_posts(array('posts_per_page' => -1, 'orderby' => 'post_title', 'order' => 'ASC', 'post_type' => 'page')) as $post) { $posts_list[$post->ID] = $post->post_title; } } $this->metadata = new WPCAObjectManager(); $this->metadata->add(new WPCAMeta('exposure', __('Exposure', RUA_App::DOMAIN), 1, 'select', array(__('Singular', RUA_App::DOMAIN), __('Singular & Archive', RUA_App::DOMAIN), __('Archive', RUA_App::DOMAIN))), 'exposure')->add(new WPCAMeta('role', __('Synchronized Role'), -1, 'select', $role_list), 'role')->add(new WPCAMeta('handle', _x('Action', 'option', RUA_App::DOMAIN), 0, 'select', array(0 => __('Redirect', RUA_App::DOMAIN), 1 => __('Tease', RUA_App::DOMAIN)), __('Redirect to another page or show teaser.', RUA_App::DOMAIN)), 'handle')->add(new WPCAMeta('page', __('Page'), 0, 'select', $posts_list, __('Page to redirect to or display content from under teaser.', RUA_App::DOMAIN)), 'page')->add(new WPCAMeta('duration', __('Duration'), "day", 'select', array("day" => __("Days", RUA_App::DOMAIN), "week" => __("Weeks", RUA_App::DOMAIN), "month" => __("Months", RUA_App::DOMAIN), "year" => __("Years", RUA_App::DOMAIN)), __('Set to 0 for unlimited.', RUA_App::DOMAIN)), 'duration'); apply_filters("rua/metadata", $this->metadata); }
/** * Add module to manager * * @since 1.0 * @param object $class * @param string $name */ public function add($class, $name) { if ($class && $class instanceof WPCAModule_Base) { parent::add($class, $name); } }
/** * Add module to manager * * @since 1.0 * @param object $class * @param string $name */ public function add($class, $name) { if ($class && class_exists($class)) { parent::add($class, $name); } }