public static function get_instance() { if (null == self::$instance) { self::$instance = new self(); } return self::$instance; }
/** * Generate the configuration for help tab. * * The configuration needs to contain three keys: * - title: Title of the tab. * - template: Name of the Twig template (assuming the 'help' namespace is available) * - context: Context object for Twig. * * @param string $page_name Name of current page. * @return array|null Help tab configuration array or null when no help tab should be displayed. * @since 2.0 */ private function get_help_config($page_name) { switch ($page_name) { case Types_Admin_Menu::PAGE_NAME_FIELD_CONTROL: return Types_Page_Field_Control::get_instance()->get_help_config(); default: return null; } }
/** * Show link to Control Custom Field * * @since 1.8.0 * */ function wpcf_admin_fields_list_metabox_to_custom_fields_control() { $form['table-1-open'] = array('#type' => 'markup', '#markup' => '<table class="wpcf-types-form-table widefat js-wpcf-slugize-container"><thead><tr><th>' . __('Post Field Control', 'wpcf') . '</th></tr></thead><tbody>', '_builtin' => true); $form['table-row-1-open'] = array('#type' => 'markup', '#markup' => '<tr><td>', '_builtin' => true); $form['table-row-1-content-1'] = array('#type' => 'markup', '#markup' => '<p>' . __('You can control Post Fields by removing them from the groups, changing type or just deleting.', 'wpcf'), '_builtin' => true); $form['table-row-1-content-2'] = array('#type' => 'markup', '#markup' => sprintf(' <a class="button" href="%s">%s</a></p>', Types_Page_Field_Control::get_page_url(Types_Field_Utils::DOMAIN_POSTS), __('Post Field Control', 'wpcf')), '_builtin' => true); $form['table-row-1-close'] = array('#type' => 'markup', '#markup' => '</td></tr>', '_builtin' => true); $form['table-1-close'] = array('#type' => 'markup', '#markup' => '</tbody></table>', '_builtin' => true); $form = wpcf_form(__FUNCTION__, $form); echo $form->renderForm(); }
/** * Show box with a link to Term Field Control page. */ function show_term_field_control_box() { $form = array(); $form['table-1-open'] = array('#type' => 'markup', '#markup' => '<table class="wpcf-types-form-table widefat js-wpcf-slugize-container"><thead><tr><th>' . __('Term Field Control', 'wpcf') . '</th></tr></thead><tbody>', '_builtin' => true); $form['table-row-1-open'] = array('#type' => 'markup', '#markup' => '<tr><td>', '_builtin' => true); $form['table-row-1-content-1'] = array('#type' => 'markup', '#markup' => '<p>' . __('You can control Term Fields by removing them from the groups, changing type or just deleting.', 'wpcf'), '_builtin' => true); $form['table-row-1-content-2'] = array('#type' => 'markup', '#markup' => sprintf(' <a class="button" href="%s">%s</a></p>', Types_Page_Field_Control::get_page_url(Types_Field_Utils::DOMAIN_TERMS), __('Term Field Control', 'wpcf')), '_builtin' => true); $form['table-row-1-close'] = array('#type' => 'markup', '#markup' => '</td></tr>', '_builtin' => true); $form['table-1-close'] = array('#type' => 'markup', '#markup' => '</tbody></table>', '_builtin' => true); $form = wpcf_form(self::PAGE_NAME . '-field-control-box', $form); echo $form->renderForm(); }
/** * Check if an on-demand submenu should be added, and jumpstart it's controller if needed. * * On-demand submenu means that the submenu isn't displayed normally, it appears only when its page is loaded. * * Note: All page controllers should inherit from Types_Page_Abstract. * * @param array $pages Array of menu item definitions. * @param string $page_name * @return array Updated item definition array. * @since 2.0 */ private function maybe_add_ondemand_submenu($pages, $page_name) { $page = null; switch ($page_name) { case self::PAGE_NAME_FIELD_CONTROL: $page = Types_Page_Field_Control::get_instance(); break; case self::PAGE_NAME_HELPER: Types_Page_Hidden_Helper::get_instance(); break; } if ($page instanceof Types_Page_Abstract) { // Jumpstart the page controller. try { $page->prepare(); } catch (Exception $e) { wp_die($e->getMessage()); } $pages[$page_name] = array('slug' => $page_name, 'menu_title' => $page->get_title(), 'page_title' => $page->get_title(), 'callback' => $page->get_render_callback(), 'load_hook' => $page->get_load_callback(), 'capability' => $page->get_required_capability(), 'contextual_help_hook' => array(Types_Asset_Help_Tab_Loader::get_instance(), 'add_help_tab')); // todo we might need to handle adding URL parameters to submenu URLs in some standard way, it's common scenario for ondemand submenus } return $pages; }