WordPress.org

Make WordPress Core

Ticket #18690: 18690.template.php.diff

File 18690.template.php.diff, 5.0 KB (added by mbijon, 7 years ago)

Modified .wp-admin/includes/template.php, to output nested divs. TO-WORK REQUIRES: nested array of content from add_contextual_help(), CSS formatting. (!!! Currently outputs debugging content from add_contextual_help(), MUST-REMOVE for production !!!)

  • wp-admin/includes/template.php

     
    18101810        <div id="contextual-help-wrap" class="hidden">
    18111811        <?php
    18121812        $contextual_help = '';
    1813         if ( isset($_wp_contextual_help[$screen->id]) ) {
    1814                 $contextual_help .= '<div class="metabox-prefs">' . $_wp_contextual_help[$screen->id] . "</div>\n";
     1813        if ( isset($_wp_contextual_help[$screen->id]) && is_array($_wp_contextual_help[$screen->id]) ) {
     1814                $contextual_help .= '<div class="metabox-prefs">';
     1815               
     1816                /*
     1817                 * Loop through ['contextual-help-tabs']
     1818                 *   - It's a nested array where $key=>$value >> $title=>$content
     1819                 * Has no output so can only loop the array once
     1820                 */
     1821                $contextual_help_tabs = ''; // store looped content for later
     1822                $contextual_help_panels = ''; // store looped content for later
     1823                foreach( $_wp_contextual_help[$screen->id]['contextual-help-tabs'] as $tab_title => $tab_content ) {
     1824                        // Make sure title isn't blank, then generate title/content as pair
     1825                        if ( isset($tab_title) ) {
     1826                                // We use slug as the linkname, but don't check uniqueness
     1827                                $tabname_slug = sanitize_title($tab_title, '', 'save');
     1828                               
     1829                                $contextual_help_tabs .= '<li class="' . $tabname_slug . '">';
     1830                                $contextual_help_tabs .= '<a href="#' . $tabname_slug . '">';
     1831                                $contextual_help_tabs .= $tab_title;
     1832                                $contextual_help_tabs .= '</a>';
     1833                                $contextual_help_tabs .= '</li>';
     1834                               
     1835                                $contextual_help_panels .= '<div id="' . $tabname_slug . '">';
     1836                                // Prevent
     1837                                if ( isset($tab_content) ) {
     1838                                        $contextual_help_panels .= $tab_content;
     1839                                }
     1840                                $contextual_help_panels .= '</div>';
     1841                        }
     1842                }
     1843               
     1844                // Start output from loop: Tabbed help content
     1845                $contextual_help .= '<div class="contextual-help-tabs-wrap">';
     1846                $contextual_help .= '<ul class="contextual-help-tabs">';
     1847                $contextual_help .= $contextual_help_tabs;
     1848                $contextual_help .= '</ul>';
     1849                $contextual_help .= $contextual_help_panels;
     1850                $contextual_help .= '</div>';
     1851                // End: Tabbed help content
     1852               
     1853                // Links to right of tabs
     1854                $contextual_help .= '<div class="contextual-help-links">';
     1855                if ( isset($_wp_contextual_help[$screen->id]['contextual-help-links']) ) {
     1856                        $contextual_help .= $_wp_contextual_help[$screen->id]['contextual-help-links'];
     1857                }
     1858                $contextual_help .= '</div>'; // end links
     1859               
     1860                $contextual_help .= '</div>'; // end metabox
     1861               
     1862        } elseif ( isset($_wp_contextual_help[$screen->id]) ) {
     1863                $contextual_help .= '<div class="metabox-prefs">Screen: ' . $screen->id . '.' . $_wp_contextual_help[$screen->id] . '</div>\n';
    18151864        } else {
    18161865                $contextual_help .= '<div class="metabox-prefs">';
    1817                 $default_help = __('<a href="http://codex.wordpress.org/" target="_blank">Documentation</a>');
     1866                $default_help  = __('<a href="http://codex.wordpress.org/" target="_blank">Documentation</a>');
    18181867                $default_help .= '<br />';
    18191868                $default_help .= __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>');
    18201869                $contextual_help .= apply_filters('default_contextual_help', $default_help);
    1821                 $contextual_help .= "</div>\n";
     1870                $contextual_help .= '</div>\n';
    18221871        }
    18231872
    18241873        echo apply_filters('contextual_help', $contextual_help, $screen->id, $screen);
     
    18351884 *
    18361885 * @param string $screen The handle for the screen to add help to.  This is usually the hook name returned by the add_*_page() functions.
    18371886 * @param string $help Arbitrary help text
     1887 *      || @param array $help Creates tabs & links columns within help text in array.
     1888 *              $key is tab title. $value is tab content.
    18381889 */
    18391890function add_contextual_help($screen, $help) {
    18401891        global $_wp_contextual_help;
     
    18441895
    18451896        if ( !isset($_wp_contextual_help) )
    18461897                $_wp_contextual_help = array();
     1898// DEBUGGING
     1899// !!! MUST REMOVE !!!
     1900$tabbed = array('Dashboard tab' => '<p>Ma quande lingues coalesce, li grammatica del resultant lingue es plu simplic e regulari quam ti del coalescent lingues. Li nov lingua franca va esser plu simplic e regulari quam li existent Europan lingues. It va esser tam simplic quam Occidental: in fact, it va esser Occidental. A un Angleso it va semblar un simplificat Angles, quam un skeptic Cambridge amico dit me que Occidental es.</p>',
     1901                'Tab 2' => '<p>Li Europan lingues es membres del sam familie. Lor separat existentie es un myth. Por scientie, musica, sport etc, li tot Europa usa li sam vocabularium. Li lingues differe solmen in li grammatica, li pronunciation e li plu commun vocabules. Omnicos directe al desirabilita; de un nov lingua franca: on refusa continuar payar custosi traductores. It solmen va esser necessi far uniform grammatica, pronunciation e plu sommun paroles.</p>');
     1902$help = array('contextual-help-tabs' => $tabbed);
     1903$help['contextual-help-links'] = '<a href="http://codex.wordpress.org/" target="_blank">Documentation</a><br /><br /><a href="http://wordpress.org/support/" target="_blank">Support Forums</a>';
     1904// !!! /End REMOVE
    18471905
    18481906        $_wp_contextual_help[$screen->id] = $help;
    18491907}