Ejemplo n.º 1
0
/**
 * Convert a screen string to a screen object
 *
 * @since 3.0.0
 *
 * @param string $hook_name The hook name (also known as the hook suffix) used to determine the screen.
 * @return nxt_Screen Screen object.
 */
function convert_to_screen($hook_name)
{
    if (!class_exists('nxt_Screen')) {
        _doing_it_wrong('convert_to_screen(), add_meta_box()', __("Likely direct inclusion of nxt-admin/includes/template.php in order to use add_meta_box(). This is very wrong. Hook the add_meta_box() call into the add_meta_boxes action instead."), '3.3');
        return (object) array('id' => '_invalid', 'base' => '_are_belong_to_us');
    }
    return nxt_Screen::get($hook_name);
}
Ejemplo n.º 2
0
/**
 * Add contextual help text for a page.
 *
 * Creates an 'Overview' help tab.
 *
 * @since 2.7.0
 * @deprecated 3.3.0
 * @deprecated Use get_current_screen()->add_help_tab()
 * @see nxt_Screen
 *
 * @param string    $screen The handle for the screen to add help to.  This is usually the hook name returned by the add_*_page() functions.
 * @param string    $help   The content of an 'Overview' help tab.
 */
function add_contextual_help($screen, $help)
{
    _deprecated_function(__FUNCTION__, '3.3', 'get_current_screen()->add_help_tab()');
    if (is_string($screen)) {
        $screen = convert_to_screen($screen);
    }
    nxt_Screen::add_old_compat_help($screen, $help);
}
Ejemplo n.º 3
0
    /**
     * Render the screen's help section.
     *
     * This will trigger the deprecated filters for backwards compatibility.
     *
     * @since 3.3.0
     */
    public function render_screen_meta()
    {
        // Call old contextual_help_list filter.
        self::$_old_compat_help = apply_filters('contextual_help_list', self::$_old_compat_help, $this);
        $old_help = isset(self::$_old_compat_help[$this->id]) ? self::$_old_compat_help[$this->id] : '';
        $old_help = apply_filters('contextual_help', $old_help, $this->id, $this);
        // Default help only if there is no old-style block of text and no new-style help tabs.
        if (empty($old_help) && empty($this->_help_tabs)) {
            $default_help = apply_filters('default_contextual_help', '');
            if ($default_help) {
                $old_help = '<p>' . $default_help . '</p>';
            }
        }
        if ($old_help) {
            $this->add_help_tab(array('id' => 'old-contextual-help', 'title' => __('Overview'), 'content' => $old_help));
        }
        $has_sidebar = !empty($this->_help_sidebar);
        $help_class = 'hidden';
        if (!$has_sidebar) {
            $help_class .= ' no-sidebar';
        }
        // Time to render!
        ?>
		<div id="screen-meta" class="metabox-prefs">

			<div id="contextual-help-wrap" class="<?php 
        echo esc_attr($help_class);
        ?>
">
				<div id="contextual-help-back"></div>
				<div id="contextual-help-columns">
					<div class="contextual-help-tabs">
						<ul>
						<?php 
        foreach ($this->_help_tabs as $i => $tab) {
            $link_id = "tab-link-{$tab['id']}";
            $panel_id = "tab-panel-{$tab['id']}";
            $classes = $i == 0 ? 'active' : '';
            ?>

							<li id="<?php 
            echo esc_attr($link_id);
            ?>
" class="<?php 
            echo esc_attr($classes);
            ?>
">
								<a href="<?php 
            echo esc_url("#{$panel_id}");
            ?>
">
									<?php 
            echo esc_html($tab['title']);
            ?>
								</a>
							</li>
						<?php 
        }
        ?>
						</ul>
					</div>

					<?php 
        if ($has_sidebar) {
            ?>
					<div class="contextual-help-sidebar">
						<?php 
            echo self::$this->_help_sidebar;
            ?>
					</div>
					<?php 
        }
        ?>

					<div class="contextual-help-tabs-wrap">
						<?php 
        foreach ($this->_help_tabs as $i => $tab) {
            $panel_id = "tab-panel-{$tab['id']}";
            $classes = $i == 0 ? 'active' : '';
            $classes .= ' help-tab-content';
            ?>

							<div id="<?php 
            echo esc_attr($panel_id);
            ?>
" class="<?php 
            echo esc_attr($classes);
            ?>
">
								<?php 
            // Print tab content.
            echo $tab['content'];
            // If it exists, fire tab callback.
            if (!empty($tab['callback'])) {
                call_user_func_array($tab['callback'], array($this, $tab));
            }
            ?>
							</div>
						<?php 
        }
        ?>
					</div>
				</div>
			</div>
		<?php 
        // Add screen options
        if ($this->show_screen_options()) {
            $this->render_screen_options();
        }
        ?>
		</div>
		<?php 
        if (!$this->_help_tabs && !$this->show_screen_options()) {
            return;
        }
        ?>
		<div id="screen-meta-links">
		<?php 
        if ($this->_help_tabs) {
            ?>
			<div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle">
			<a href="#contextual-help-wrap" id="contextual-help-link" class="show-settings"><?php 
            _e('Help');
            ?>
</a>
			</div>
		<?php 
        }
        if ($this->show_screen_options()) {
            ?>
			<div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle">
			<a href="#screen-options-wrap" id="show-settings-link" class="show-settings"><?php 
            _e('Screen Options');
            ?>
</a>
			</div>
		<?php 
        }
        ?>
		</div>
		<?php 
    }