/** * Prepare the HTML fields that can be displayed * * @since 1.0.0 * * @return array */ protected function prepare_fields() { // Prepare the return value. $nav = array(); $pages = array(); MS_Model_Pages::create_missing_pages(); $page_types = MS_Model_Pages::get_page_types(); $page_types_menu = array('memberships', 'register', 'account'); $page_types_rest = array_diff($page_types, $page_types_menu); // Prepare NAV fields. $menu_action = MS_Controller_Pages::AJAX_ACTION_TOGGLE_MENU; $menu_nonce = wp_create_nonce($menu_action); foreach ($page_types_menu as $type) { $nav_exists = MS_Model_Pages::has_menu($type); $nav[$type] = array('type' => MS_Helper_Html::INPUT_TYPE_RADIO_SLIDER, 'id' => 'nav_' . $type, 'value' => $nav_exists, 'title' => $page_types[$type], 'ajax_data' => array('action' => $menu_action, 'item' => $type, '_wpnonce' => $menu_nonce)); } $nav['sep'] = array('type' => MS_Helper_Html::TYPE_HTML_SEPARATOR); // Prepare PAGES fields. $pages_action = MS_Controller_Pages::AJAX_ACTION_UPDATE_PAGES; $pages_nonce = wp_create_nonce($pages_action); foreach ($page_types as $type => $label) { $page_id = MS_Model_Pages::get_setting($type); $title = sprintf('<strong>%1$s</strong><span class="lbl-details">: %2$s</span>', $label, MS_Model_Pages::get_description($type)); $pages[$type] = array('id' => $type, 'type' => MS_Helper_Html::INPUT_TYPE_WP_PAGES, 'title' => $title, 'value' => $page_id, 'field_options' => array('no_item' => __('- Select a page -', MS_TEXT_DOMAIN)), 'ajax_data' => array('field' => $type, 'action' => $pages_action, '_wpnonce' => $pages_nonce)); } $fields = array('nav' => $nav, 'pages' => $pages); return apply_filters('ms_view_settings_page_setup_prepare_fields', $fields, $this); }