private function redirect_to_first_poll() { require_once dirname(__FILE__) . '/../../PollManager.php'; $posts = FCA_FBC_PollManager::get_instance()->find_all_posts(); if (empty($posts)) { FCA_AdminLocation::redirect_to_admin_location(FCA_AdminLocation::compose(FCA_AdminLocation::TYPE_POST_CREATE, array(FCA_AdminLocation::KEY_POST_TYPE => self::POST_TYPE))); } else { FCA_AdminLocation::redirect_to_admin_location(FCA_AdminLocation::compose(FCA_AdminLocation::TYPE_POST_EDIT, array(FCA_AdminLocation::KEY_POST_ID => $posts[0]->ID))); } }
public function register_post_type() { require_once dirname(__FILE__) . '/../PollManager.php'; $can_create = !FCA_FBC_PollManager::get_instance()->did_reach_maximum_number_of_polls(); register_post_type(self::POST_TYPE, array('menu_icon' => 'dashicons-feedback', 'labels' => array('name' => self::NAME_PLURAL, 'singular_name' => self::NAME, 'add_new' => 'Create', 'add_new_item' => 'Create ' . self::NAME, 'edit_item' => 'Edit ' . self::NAME, 'new_item' => 'New ' . self::NAME, 'all_items' => 'All ' . self::NAME_PLURAL, 'view_item' => 'View ' . self::NAME, 'search_items' => 'Search ' . self::NAME, 'not_found' => 'No ' . self::NAME . ' Found', 'not_found_in_trash' => 'No ' . self::NAME . ' in Trash', 'parent_item_colon' => '', 'menu_name' => FCA_FBC_PLUGIN_NAME), 'public' => false, 'exclude_from_search' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => array('slug' => self::POST_TYPE), 'has_archive' => false, 'hierarchical' => false, 'menu_position' => 105, 'supports' => array('title' => false), 'register_meta_box_cb' => array($this, 'register_meta_boxes'), 'capability_type' => 'post', 'capabilities' => array('create_posts' => $can_create), 'map_meta_cap' => true)); }
/** * @return array */ private function get_polls() { if (is_null($this->polls)) { require_once dirname(__FILE__) . '/../../PollManager.php'; $poll_manager = FCA_FBC_PollManager::get_instance(); $polls = array(); foreach ($poll_manager->find_all_active() as $poll_id => $poll_data) { $polls[$poll_id] = array('data' => $poll_data, 'html' => $this->compress_html($this->render_poll($poll_data))); } $this->polls = $polls; } return $this->polls; }