/** * Renders the tab. * * It displays the tab description (if available) and renders the form tag. * Inside the form tag, it iterates through all the sections belonging to this tab and calls each one's `render()` function. * * If no sections are available for this tab, the function will try to call the tab callback function to generate the output. * * If the tab is draggable (i.e. uses meta boxes), the meta boxes are handled in here as well. * * @since 0.5.0 */ public function render() { $parent_screen = $this->get_parent(); $parent_menu = $parent_screen->get_parent(); if ('options-general.php' !== $parent_menu->menu_slug) { settings_errors($this->slug); } /** * This action can be used to display additional content on top of this tab. * * @since 0.5.0 * @param string the slug of the current tab * @param array the arguments array for the current tab * @param string the slug of the current screen */ do_action('wpod_tab_before', $this->slug, $this->args, $parent_screen->slug); if (!empty($this->args['description'])) { echo '<p class="description">' . $this->args['description'] . '</p>'; } if (count($this->get_children()) > 0) { $this->render_sections(); } elseif ($this->args['callback'] && is_callable($this->args['callback'])) { call_user_func($this->args['callback']); } else { App::doing_it_wrong(__METHOD__, sprintf(__('There are no sections to display for tab %s. Either add some or provide a valid callback function instead.', 'options-definitely'), $this->slug), '0.5.0'); } if ('draggable' == $this->args['mode']) { $this->print_metaboxes_script(); } /** * This action can be used to display additional content at the bottom of this tab. * * @since 0.5.0 * @param string the slug of the current tab * @param array the arguments array for the current tab * @param string the slug of the current screen */ do_action('wpod_tab_after', $this->slug, $this->args, $parent_screen->slug); }
/** * Renders the screen. * * It displays the title and (optionally) description of the screen. * Then it displays the tab navigation (if there are multiple tabs) and the currently active tab. * * @since 0.5.0 */ public function render() { $parent_menu = $this->get_parent(); echo '<div class="wrap">'; echo '<h1>' . $this->args['title'] . '</h1>'; /** * This action can be used to display additional content on top of this screen. * * @since 0.5.0 * @param string the slug of the current screen * @param array the arguments array for the current screen * @param string the slug of the current menu */ do_action('wpod_screen_before', $this->real_slug, $this->args, $parent_menu->slug); if (!empty($this->args['description'])) { echo '<p class="description">' . $this->args['description'] . '</p>'; } $tabs = $this->get_children(); $tabs = array_filter($tabs, array('WPDLib\\Util\\Util', 'current_user_can')); if (count($tabs) > 0) { $current_tab = Admin::instance()->get_current('tab', $this); if (count($tabs) > 1) { $this->render_tab_navigation($tabs, $current_tab); } $current_tab->render(); } else { App::doing_it_wrong(__METHOD__, sprintf(__('There are no tabs to display for the screen %s. Either add some or adjust the required capabilities.', 'options-definitely'), $this->real_slug), '0.5.0'); } /** * This action can be used to display additional content at the bottom of this screen. * * @since 0.5.0 * @param string the slug of the current screen * @param array the arguments array for the current screen * @param string the slug of the current menu */ do_action('wpod_screen_after', $this->real_slug, $this->args, $parent_menu->slug); echo '</div>'; }
/** * Renders the section. * * It displays the title and description (if available) for the section. * Then it shows the fields of this section or, if no fields are available, calls the callback function. * * @since 0.5.0 * @param boolean $metabox if this function is called inside a metabox, this parameter needs to be true, otherwise it has to be explicitly false */ public function render($metabox = true) { // only display the title if the section is not displayed as a metabox if (null !== $metabox || false === $metabox) { echo '<h3>' . $this->args['title'] . '</h3>'; } $parent_tab = $this->get_parent(); /** * This action can be used to display additional content on top of this section. * * @since 0.5.0 * @param string the slug of the current section * @param array the arguments array for the current section * @param string the slug of the current tab */ do_action('wpod_section_before', $this->slug, $this->args, $parent_tab->slug); if (!empty($this->args['description'])) { echo '<p class="description">' . $this->args['description'] . '</p>'; } if (count($this->get_children()) > 0) { $table_atts = array('class' => 'form-table wpdlib-form-table'); /** * This filter can be used to adjust the form table attributes. * * @since 0.5.0 * @param array the associative array of form table attributes * @param WPOD\Components\Section current section instance */ $table_atts = apply_filters('wpod_table_atts', $table_atts, $this); echo '<table' . FieldManager::make_html_attributes($table_atts, false, false) . '>'; do_settings_fields($parent_tab->slug, $this->slug); echo '</table>'; } elseif ($this->args['callback'] && is_callable($this->args['callback'])) { call_user_func($this->args['callback']); } else { App::doing_it_wrong(__METHOD__, sprintf(__('There are no fields to display for section %s. Either add some or provide a valid callback function instead.', 'options-definitely'), $this->slug), '0.5.0'); } /** * This action can be used to display additional content at the bottom of this section. * * @since 0.5.0 * @param string the slug of the current section * @param array the arguments array for the current section * @param string the slug of the current tab */ do_action('wpod_section_after', $this->slug, $this->args, $parent_tab->slug); }