Make WordPress Core

Ticket #15800: 0001-Enhance-tabs-15800.patch

File 0001-Enhance-tabs-15800.patch, 7.3 KB (added by Bueltge, 11 years ago)
  • wp-admin/includes/ms.php

    From 09c947f374377dc1c07dec8f39dd80676c1bc0ad Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Frank=20B=C3=BCltge?= <frank@bueltge.de>
    Date: Wed, 5 Mar 2014 15:13:12 +0100
    Subject: [PATCH] Enhance tabs #15800
    
    ---
     wp-admin/includes/ms.php           | 54 ++++++++++++++++++++++++++++++++++++++
     wp-admin/network/site-info.php     | 15 ++---------
     wp-admin/network/site-settings.php | 15 ++---------
     wp-admin/network/site-themes.php   | 15 ++---------
     wp-admin/network/site-users.php    | 15 ++---------
     5 files changed, 62 insertions(+), 52 deletions(-)
    
    diff --git wp-admin/includes/ms.php wp-admin/includes/ms.php
    index f048417..75ec3d8 100644
    function revoke_super_admin( $user_id ) { 
    769769        return false;
    770770}
    771771
     772/**
     773 * Output the html for the network Edit Site page tabs
     774 *
     775 * @since 3.9.0
     776 *
     777 * @uses apply_filters() Calls 'network_edit_site_tabs' on 'info', 'users', 'themes', and settings tabs.
     778 * @uses apply_filters() Calls 'network_edit_site_tab_html' on 'tab_html
     779 *
     780 * @param int $id The blog_id of the current site being edited.
     781 */
     782function network_edit_site_tabs( $id ) {
     783                global $pagenow;
     784               
     785                $default = array(
     786                        'site-info'     => array( 'label' => __( 'Info' ), 'url' => 'site-info.php' ),
     787                        'site-users'    => array( 'label' => __( 'Users' ), 'url' => 'site-users.php' ),
     788                        'site-themes'   => array( 'label' => __( 'Themes' ), 'url' => 'site-themes.php' ),
     789                        'site-settings' => array( 'label' => __( 'Settings' ), 'url' => 'site-settings.php' ),
     790                );
     791                $tabs = apply_filters( 'network_edit_site_tabs', $default, $id, $pagenow );
     792               
     793                foreach ( $tabs as $tab_id => $tab ) {
     794                       
     795                        if ( isset( $tab[ 'menu-slug' ] ) && isset( $tab[ 'callback-function' ] ) ) {
     796                               
     797                                $menu_slug = plugin_basename( $tab[ 'menu-slug' ] );
     798                               
     799                                $html = sprintf(
     800                                        '<a href="%s" class="nav-tab %s">%s</a>',
     801                                        add_query_arg( array( 'id' => $id ), network_admin_url( 'admin.php?page=' . $tab[ 'menu-slug' ] ) ),
     802                                        isset( $_GET[ 'page' ] ) && $menu_slug == $_GET[ 'page' ] ? ' nav-tab-active' : '',
     803                                        esc_html( $tab[ 'label' ] )
     804                                );
     805                               
     806                                echo $html;
     807                                 
     808                                $admin_page_hooks[ $menu_slug ] = sanitize_title( $tab[ 'label' ] );
     809                        } else {
     810                               
     811                                // Set class for stylesheet
     812                                $class    = ( $tab[ 'url' ] == $pagenow ) ? ' nav-tab-active' : '';
     813                                // Adds aria-selected to each of the tabs
     814                                $selected = ( $tab[ 'url' ] == $pagenow ) ? 'true' : 'false';
     815                                // Markup for each tab
     816                                $tab_html = '<a href="' . $tab['url'] . '?id=' . $id . '" class="nav-tab'
     817                                        . $class . '" role="tab" aria-controls="' . sanitize_title( $tab_id ) . '" aria-selected="'
     818                                        . $selected . '">' . esc_html( $tab[ 'label' ] ) . '</a>';
     819                               
     820                                echo apply_filters( 'network_edit_site_tab_html', $tab_html, $tab, $class, $id );
     821                        }
     822                }
     823}
     824 
     825
    772826/**
    773827 * Whether or not we can edit this network from this page
    774828 *
  • wp-admin/network/site-info.php

    diff --git wp-admin/network/site-info.php wp-admin/network/site-info.php
    index 6607b8f..44017c0 100644
    require( ABSPATH . 'wp-admin/admin-header.php' ); 
    9797
    9898<div class="wrap">
    9999<h2 id="edit-site"><?php echo $title_site_url_linked ?></h2>
    100 <h3 class="nav-tab-wrapper">
    101 <?php
    102 $tabs = array(
    103         'site-info'     => array( 'label' => __( 'Info' ),     'url' => 'site-info.php'     ),
    104         'site-users'    => array( 'label' => __( 'Users' ),    'url' => 'site-users.php'    ),
    105         'site-themes'   => array( 'label' => __( 'Themes' ),   'url' => 'site-themes.php'   ),
    106         'site-settings' => array( 'label' => __( 'Settings' ), 'url' => 'site-settings.php' ),
    107 );
    108 foreach ( $tabs as $tab_id => $tab ) {
    109         $class = ( $tab['url'] == $pagenow ) ? ' nav-tab-active' : '';
    110         echo '<a href="' . $tab['url'] . '?id=' . $id .'" class="nav-tab' . $class . '">' . esc_html( $tab['label'] ) . '</a>';
    111 }
    112 ?>
     100<h3 class="nav-tab-wrapper" role="tablist">
     101<?php network_edit_site_tabs( $id ); ?>
    113102</h3>
    114103<?php
    115104if ( ! empty( $messages ) ) {
  • wp-admin/network/site-settings.php

    diff --git wp-admin/network/site-settings.php wp-admin/network/site-settings.php
    index 5e1ffdd..4243c64 100644
    require( ABSPATH . 'wp-admin/admin-header.php' ); 
    8888
    8989<div class="wrap">
    9090<h2 id="edit-site"><?php echo $title_site_url_linked ?></h2>
    91 <h3 class="nav-tab-wrapper">
    92 <?php
    93 $tabs = array(
    94         'site-info'     => array( 'label' => __( 'Info' ),     'url' => 'site-info.php'     ),
    95         'site-users'    => array( 'label' => __( 'Users' ),    'url' => 'site-users.php'    ),
    96         'site-themes'   => array( 'label' => __( 'Themes' ),   'url' => 'site-themes.php'   ),
    97         'site-settings' => array( 'label' => __( 'Settings' ), 'url' => 'site-settings.php' ),
    98 );
    99 foreach ( $tabs as $tab_id => $tab ) {
    100         $class = ( $tab['url'] == $pagenow ) ? ' nav-tab-active' : '';
    101         echo '<a href="' . $tab['url'] . '?id=' . $id .'" class="nav-tab' . $class . '">' . esc_html( $tab['label'] ) . '</a>';
    102 }
    103 ?>
     91<h3 class="nav-tab-wrapper" role="tablist">
     92<?php network_edit_site_tabs( $id ); ?>
    10493</h3>
    10594<?php
    10695if ( ! empty( $messages ) ) {
  • wp-admin/network/site-themes.php

    diff --git wp-admin/network/site-themes.php wp-admin/network/site-themes.php
    index 646eb08..fec2b3c 100644
    require( ABSPATH . 'wp-admin/admin-header.php' ); ?> 
    136136
    137137<div class="wrap">
    138138<h2 id="edit-site"><?php echo $title_site_url_linked ?></h2>
    139 <h3 class="nav-tab-wrapper">
    140 <?php
    141 $tabs = array(
    142         'site-info'     => array( 'label' => __( 'Info' ),     'url' => 'site-info.php'     ),
    143         'site-users'    => array( 'label' => __( 'Users' ),    'url' => 'site-users.php'    ),
    144         'site-themes'   => array( 'label' => __( 'Themes' ),   'url' => 'site-themes.php'   ),
    145         'site-settings' => array( 'label' => __( 'Settings' ), 'url' => 'site-settings.php' ),
    146 );
    147 foreach ( $tabs as $tab_id => $tab ) {
    148         $class = ( $tab['url'] == $pagenow ) ? ' nav-tab-active' : '';
    149         echo '<a href="' . $tab['url'] . '?id=' . $id .'" class="nav-tab' . $class . '">' . esc_html( $tab['label'] ) . '</a>';
    150 }
    151 ?>
     139<h3 class="nav-tab-wrapper" role="tablist">
     140<?php network_edit_site_tabs( $id ); ?>
    152141</h3><?php
    153142
    154143if ( isset( $_GET['enabled'] ) ) {
  • wp-admin/network/site-users.php

    diff --git wp-admin/network/site-users.php wp-admin/network/site-users.php
    index 322400b..7184100 100644
    var current_site_id = <?php echo $id; ?>; 
    181181
    182182<div class="wrap">
    183183<h2 id="edit-site"><?php echo $title_site_url_linked ?></h2>
    184 <h3 class="nav-tab-wrapper">
    185 <?php
    186 $tabs = array(
    187         'site-info'     => array( 'label' => __( 'Info' ),     'url' => 'site-info.php'     ),
    188         'site-users'    => array( 'label' => __( 'Users' ),    'url' => 'site-users.php'    ),
    189         'site-themes'   => array( 'label' => __( 'Themes' ),   'url' => 'site-themes.php'   ),
    190         'site-settings' => array( 'label' => __( 'Settings' ), 'url' => 'site-settings.php' ),
    191 );
    192 foreach ( $tabs as $tab_id => $tab ) {
    193         $class = ( $tab['url'] == $pagenow ) ? ' nav-tab-active' : '';
    194         echo '<a href="' . $tab['url'] . '?id=' . $id .'" class="nav-tab' . $class . '">' . esc_html( $tab['label'] ) . '</a>';
    195 }
    196 ?>
     184<h3 class="nav-tab-wrapper" role="tablist">
     185<?php network_edit_site_tabs( $id ); ?>
    197186</h3><?php
    198187
    199188if ( isset($_GET['update']) ) :