Make WordPress Core

Ticket #15800: 15800.5.patch

File 15800.5.patch, 8.5 KB (added by johnjamesjacoby, 9 years ago)
  • src/wp-admin/includes/ms.php

    diff --git a/src/wp-admin/includes/ms.php b/src/wp-admin/includes/ms.php
    index 5464b61..4ecb01f 100644
    a b  
    10281028</script>
    10291029<?php
    10301030}
     1031
     1032/**
     1033 * Output the HTML for a network's "Edit Site" tabular interface
     1034 *
     1035 * @since 4.6.0
     1036 *
     1037 * @link https://core.trac.wordpress.org/ticket/15800 discussion
     1038 *
     1039 * @param $args {
     1040 *     Optional. Array or string of Query parameters.
     1041 *
     1042 *     @type int     $blog_id   The site ID. Default is the current site.
     1043 *     @type array   $links     The tabs to include with (label|url|cap) keys
     1044 *     @type string  $selected  The ID of the selected link
     1045 * }
     1046 */
     1047function network_edit_site_nav( $args = array() ) {
     1048
     1049        /**
     1050         * Filter the links that appear on site-editing network pages
     1051         *
     1052         * Default tabs: 'site-info', 'site-users', 'site-themes', and 'site-settings'
     1053         *
     1054         * @since 4.6.0
     1055         *
     1056         * @param array Array of links
     1057         */
     1058        $links = apply_filters( 'network_edit_site_nav_links', array(
     1059                'site-info'     => array( 'label' => __( 'Info' ),     'url' => 'site-info.php',     'cap' => 'manage_sites' ),
     1060                'site-users'    => array( 'label' => __( 'Users' ),    'url' => 'site-users.php',    'cap' => 'manage_sites' ),
     1061                'site-themes'   => array( 'label' => __( 'Themes' ),   'url' => 'site-themes.php',   'cap' => 'manage_sites' ),
     1062                'site-settings' => array( 'label' => __( 'Settings' ), 'url' => 'site-settings.php', 'cap' => 'manage_sites' )
     1063        ) );
     1064
     1065        // Parse arguments
     1066        $r = wp_parse_args( $args, array(
     1067                'blog_id'  => isset( $_GET['blog_id'] ) ? (int) $_GET['blog_id'] : 0,
     1068                'links'    => $links,
     1069                'selected' => 'site-info',
     1070        ) );
     1071
     1072        /**
     1073         * Filter the arguments used to output links that appear on site-editing
     1074         * network pages
     1075         *
     1076         * @since 4.6.0
     1077         *
     1078         * @param array $r    Parsed arguments
     1079         * @param array $args Original arguments
     1080         */
     1081        $r = apply_filters( 'network_edit_site_nav_args', $r, $args );
     1082
     1083        // Setup the links array
     1084        $screen_links = array();
     1085
     1086        // Loop through tabs
     1087        foreach ( $r['links'] as $link_id => $link ) {
     1088
     1089                // Skip link if user can't access
     1090                if ( ! current_user_can( $link['cap'], $r['blog_id'] ) ) {
     1091                        continue;
     1092                }
     1093
     1094                // Link classes
     1095                $classes = array( 'nav-tab' );
     1096                if (
     1097
     1098                        // Selected is set by parent
     1099                        ( $r['selected'] === $link_id )
     1100
     1101                        ||
     1102
     1103                        // Selected is assumed by $pagenow global
     1104                        ( $link['url'] === $GLOBALS['pagenow'] )
     1105                ) {
     1106                        $classes[] = 'nav-tab-active';
     1107                }
     1108
     1109                // Escape each class
     1110                $esc_classes = implode( ' ', array_map( 'esc_attr', $classes ) );
     1111
     1112                // Get the URL for this link
     1113                $url = add_query_arg( array( 'id' => $r['blog_id'] ), network_admin_url( $link['url'] ) );
     1114
     1115                // Add link to nav links
     1116                $screen_links[ $link_id ] = '<a href="' . esc_url( $url ) . '" id="' . esc_attr( $link_id ) . '" class="' . $esc_classes . '">' . esc_html( $link['label'] ) . '</a>';
     1117        }
     1118
     1119        // Start a buffer
     1120        ob_start();
     1121
     1122        // All done!
     1123        echo '<h2 class="nav-tab-wrapper wp-clearfix">';
     1124        echo implode( '', $screen_links );
     1125        echo '</h2>';
     1126
     1127        // Output the nav
     1128        echo ob_get_clean();
     1129}
  • src/wp-admin/network/site-info.php

    diff --git a/src/wp-admin/network/site-info.php b/src/wp-admin/network/site-info.php
    index b18d804..868e88c 100644
    a b  
    143143<div class="wrap">
    144144<h1 id="edit-site"><?php echo $title; ?></h1>
    145145<p class="edit-site-actions"><a href="<?php echo esc_url( get_home_url( $id, '/' ) ); ?>"><?php _e( 'Visit' ); ?></a> | <a href="<?php echo esc_url( get_admin_url( $id ) ); ?>"><?php _e( 'Dashboard' ); ?></a></p>
    146 <h2 class="nav-tab-wrapper nav-tab-small wp-clearfix">
    147146<?php
    148 $tabs = array(
    149         'site-info'     => array( 'label' => __( 'Info' ),     'url' => 'site-info.php'     ),
    150         'site-users'    => array( 'label' => __( 'Users' ),    'url' => 'site-users.php'    ),
    151         'site-themes'   => array( 'label' => __( 'Themes' ),   'url' => 'site-themes.php'   ),
    152         'site-settings' => array( 'label' => __( 'Settings' ), 'url' => 'site-settings.php' ),
    153 );
    154 foreach ( $tabs as $tab_id => $tab ) {
    155         $class = ( $tab['url'] == $pagenow ) ? ' nav-tab-active' : '';
    156         echo '<a href="' . $tab['url'] . '?id=' . $id .'" class="nav-tab' . $class . '">' . esc_html( $tab['label'] ) . '</a>';
    157 }
    158 ?>
    159 </h2>
    160 <?php
     147
     148network_edit_site_nav( array(
     149        'blog_id'  => $id,
     150        'selected' => 'site-info'
     151) );
     152
    161153if ( ! empty( $messages ) ) {
    162154        foreach ( $messages as $msg ) {
    163155                echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>';
  • src/wp-admin/network/site-settings.php

    diff --git a/src/wp-admin/network/site-settings.php b/src/wp-admin/network/site-settings.php
    index b945ea7..a5cdc6d 100644
    a b  
    9595<div class="wrap">
    9696<h1 id="edit-site"><?php echo $title; ?></h1>
    9797<p class="edit-site-actions"><a href="<?php echo esc_url( get_home_url( $id, '/' ) ); ?>"><?php _e( 'Visit' ); ?></a> | <a href="<?php echo esc_url( get_admin_url( $id ) ); ?>"><?php _e( 'Dashboard' ); ?></a></p>
    98 <h2 class="nav-tab-wrapper nav-tab-small wp-clearfix">
     98
    9999<?php
    100 $tabs = array(
    101         'site-info'     => array( 'label' => __( 'Info' ),     'url' => 'site-info.php'     ),
    102         'site-users'    => array( 'label' => __( 'Users' ),    'url' => 'site-users.php'    ),
    103         'site-themes'   => array( 'label' => __( 'Themes' ),   'url' => 'site-themes.php'   ),
    104         'site-settings' => array( 'label' => __( 'Settings' ), 'url' => 'site-settings.php' ),
    105 );
    106 foreach ( $tabs as $tab_id => $tab ) {
    107         $class = ( $tab['url'] == $pagenow ) ? ' nav-tab-active' : '';
    108         echo '<a href="' . $tab['url'] . '?id=' . $id .'" class="nav-tab' . $class . '">' . esc_html( $tab['label'] ) . '</a>';
    109 }
    110 ?>
    111 </h2>
    112 <?php
     100
     101network_edit_site_nav( array(
     102        'blog_id'  => $id,
     103        'selected' => 'site-settings'
     104) );
     105
    113106if ( ! empty( $messages ) ) {
    114107        foreach ( $messages as $msg )
    115108                echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>';
  • src/wp-admin/network/site-themes.php

    diff --git a/src/wp-admin/network/site-themes.php b/src/wp-admin/network/site-themes.php
    index d48e2ca..6d13fb2 100644
    a b  
    149149<div class="wrap">
    150150<h1 id="edit-site"><?php echo $title; ?></h1>
    151151<p class="edit-site-actions"><a href="<?php echo esc_url( get_home_url( $id, '/' ) ); ?>"><?php _e( 'Visit' ); ?></a> | <a href="<?php echo esc_url( get_admin_url( $id ) ); ?>"><?php _e( 'Dashboard' ); ?></a></p>
    152 <h2 class="nav-tab-wrapper nav-tab-small wp-clearfix">
    153152<?php
    154 $tabs = array(
    155         'site-info'     => array( 'label' => __( 'Info' ),     'url' => 'site-info.php'     ),
    156         'site-users'    => array( 'label' => __( 'Users' ),    'url' => 'site-users.php'    ),
    157         'site-themes'   => array( 'label' => __( 'Themes' ),   'url' => 'site-themes.php'   ),
    158         'site-settings' => array( 'label' => __( 'Settings' ), 'url' => 'site-settings.php' ),
    159 );
    160 foreach ( $tabs as $tab_id => $tab ) {
    161         $class = ( $tab['url'] == $pagenow ) ? ' nav-tab-active' : '';
    162         echo '<a href="' . $tab['url'] . '?id=' . $id .'" class="nav-tab' . $class . '">' . esc_html( $tab['label'] ) . '</a>';
    163 }
    164 ?>
    165 </h2><?php
     153
     154network_edit_site_nav( array(
     155        'blog_id'  => $id,
     156        'selected' => 'site-themes'
     157) );
    166158
    167159if ( isset( $_GET['enabled'] ) ) {
    168160        $enabled = absint( $_GET['enabled'] );
  • src/wp-admin/network/site-users.php

    diff --git a/src/wp-admin/network/site-users.php b/src/wp-admin/network/site-users.php
    index 77122e8..cced8a4 100644
    a b  
    204204<div class="wrap">
    205205<h1 id="edit-site"><?php echo $title; ?></h1>
    206206<p class="edit-site-actions"><a href="<?php echo esc_url( get_home_url( $id, '/' ) ); ?>"><?php _e( 'Visit' ); ?></a> | <a href="<?php echo esc_url( get_admin_url( $id ) ); ?>"><?php _e( 'Dashboard' ); ?></a></p>
    207 <h2 class="nav-tab-wrapper nav-tab-small wp-clearfix">
    208207<?php
    209 $tabs = array(
    210         'site-info'     => array( 'label' => __( 'Info' ),     'url' => 'site-info.php'     ),
    211         'site-users'    => array( 'label' => __( 'Users' ),    'url' => 'site-users.php'    ),
    212         'site-themes'   => array( 'label' => __( 'Themes' ),   'url' => 'site-themes.php'   ),
    213         'site-settings' => array( 'label' => __( 'Settings' ), 'url' => 'site-settings.php' ),
    214 );
    215 foreach ( $tabs as $tab_id => $tab ) {
    216         $class = ( $tab['url'] == $pagenow ) ? ' nav-tab-active' : '';
    217         echo '<a href="' . $tab['url'] . '?id=' . $id .'" class="nav-tab' . $class . '">' . esc_html( $tab['label'] ) . '</a>';
    218 }
    219 ?>
    220 </h2><?php
     208
     209network_edit_site_nav( array(
     210        'blog_id'  => $id,
     211        'selected' => 'site-users'
     212) );
    221213
    222214if ( isset($_GET['update']) ) :
    223215        switch($_GET['update']) {