Ticket #21413: 21413.2.diff

File 21413.2.diff, 7.3 KB (added by DrewAPicture, 3 months ago)

Refreshed and cleanup on themes.php

Line 
1Index: wp-admin/admin-header.php
2===================================================================
3--- wp-admin/admin-header.php   (revision 23402)
4+++ wp-admin/admin-header.php   (working copy)
5@@ -98,9 +98,8 @@
6 </script>
7 
8 <?php
9-// If the customize-loader script is enqueued, make sure the customize
10-// body classes are correct as early as possible.
11-if ( wp_script_is( 'customize-loader', 'queue' ) && current_user_can( 'edit_theme_options' ) )
12+// Make sure the customize body classes are correct as early as possible.
13+if (  current_user_can( 'edit_theme_options' ) )
14        wp_customize_support_script();
15 ?>
16 
17Index: wp-admin/css/wp-admin-rtl.css
18===================================================================
19--- wp-admin/css/wp-admin-rtl.css       (revision 23402)
20+++ wp-admin/css/wp-admin-rtl.css       (working copy)
21@@ -1305,19 +1305,14 @@
22        margin-right: -330px;
23 }
24 
25-.theme-options .load-customize {
26-       margin-right: 0;
27-       margin-left: 30px;
28-       float: right;
29-}
30-
31 .theme-options span {
32        float: right;
33        margin-right: 0;
34        margin-left: 10px;
35 }
36 
37-.theme-options ul {
38+.theme-options ul,
39+.theme-options .load-customize {
40        float: right;
41 }
42 
43Index: wp-admin/css/wp-admin.css
44===================================================================
45--- wp-admin/css/wp-admin.css   (revision 23402)
46+++ wp-admin/css/wp-admin.css   (working copy)
47@@ -4759,11 +4759,6 @@
48        padding-bottom: 10px;
49 }
50 
51-.theme-options .load-customize {
52-       margin-right: 30px;
53-       float: left;
54-}
55-
56 .theme-options span {
57        float: left;
58        margin-right: 10px;
59@@ -4773,7 +4768,8 @@
60        color: #999;
61 }
62 
63-.theme-options ul {
64+.theme-options ul,
65+.theme-options .load-customize {
66        float: left;
67        margin: 0;
68 }
69Index: wp-admin/includes/menu.php
70===================================================================
71--- wp-admin/includes/menu.php  (revision 23402)
72+++ wp-admin/includes/menu.php  (working copy)
73@@ -73,7 +73,7 @@
74        $new_parent = $first_sub[2];
75        // If the first submenu is not the same as the assigned parent,
76        // make the first submenu the new parent.
77-       if ( $new_parent != $old_parent ) {
78+       if ( $new_parent != $old_parent && 'customize.php' != $new_parent ) {
79                $_wp_real_parent_file[$old_parent] = $new_parent;
80                $menu[$id][2] = $new_parent;
81 
82Index: wp-admin/menu-header.php
83===================================================================
84--- wp-admin/menu-header.php    (revision 23402)
85+++ wp-admin/menu-header.php    (working copy)
86@@ -53,7 +53,7 @@
87                        $class[] = 'wp-has-submenu';
88                        $submenu_items = $submenu[$item[2]];
89                }
90-
91+               
92                if ( ( $parent_file && $item[2] == $parent_file ) || ( empty($typenow) && $self == $item[2] ) ) {
93                        $class[] = ! empty( $submenu_items ) ? 'wp-has-current-submenu wp-menu-open' : 'current';
94                } else {
95@@ -82,7 +82,9 @@
96                if ( false !== strpos( $class, 'wp-menu-separator' ) ) {
97                        echo '<div class="separator"></div>';
98                } elseif ( $submenu_as_parent && ! empty( $submenu_items ) ) {
99-                       $submenu_items = array_values( $submenu_items );  // Re-index.
100+                       $temp_submenu_items = $submenu_items = array_values( $submenu_items );  // Re-index.
101+                       if ( 'customize.php' == $submenu_items[0][2] )
102+                               $submenu_items[0][2] = 'themes.php';
103                        $menu_hook = get_plugin_page_hook( $submenu_items[0][2], $item[2] );
104                        $menu_file = $submenu_items[0][2];
105                        if ( false !== ( $pos = strpos( $menu_file, '?' ) ) )
106@@ -93,6 +95,7 @@
107                        } else {
108                                echo "\n\t<a href='{$submenu_items[0][2]}'$class $aria_attributes>$arrow<div class='wp-menu-image'>$img</div><div class='wp-menu-name'>$title</div></a>";
109                        }
110+                       $submenu_items = $temp_submenu_items;
111                } elseif ( ! empty( $item[2] ) && current_user_can( $item[1] ) ) {
112                        $menu_hook = get_plugin_page_hook( $item[2], 'admin.php' );
113                        $menu_file = $item[2];
114@@ -105,7 +108,7 @@
115                                echo "\n\t<a href='{$item[2]}'$class $aria_attributes>$arrow<div class='wp-menu-image'>$img</div><div class='wp-menu-name'>{$item[0]}</div></a>";
116                        }
117                }
118-
119+               
120                if ( ! empty( $submenu_items ) ) {
121                        echo "\n\t<ul class='wp-submenu wp-submenu-wrap'>";
122                        echo "<li class='wp-submenu-head'>{$item[0]}</li>";
123@@ -140,6 +143,9 @@
124                                ) {
125                                        $class[] = 'current';
126                                }
127+                               
128+                               if ( ! empty( $sub_item[3] ) )
129+                                       $class[] = $sub_item[3];
130 
131                                $class = $class ? ' class="' . join( ' ', $class ) . '"' : '';
132 
133Index: wp-admin/menu.php
134===================================================================
135--- wp-admin/menu.php   (revision 23402)
136+++ wp-admin/menu.php   (working copy)
137@@ -136,18 +136,16 @@
138 
139 $menu[59] = array( '', 'read', 'separator2', '', 'wp-menu-separator' );
140 
141-if ( current_user_can( 'switch_themes') ) {
142-       $menu[60] = array( __('Appearance'), 'switch_themes', 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'none' );
143-               $submenu['themes.php'][5]  = array(__('Themes'), 'switch_themes', 'themes.php');
144-               if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) )
145-                       $submenu['themes.php'][10] = array(__('Menus'), 'edit_theme_options', 'nav-menus.php');
146-} else {
147-       $menu[60] = array( __('Appearance'), 'edit_theme_options', 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'none' );
148-               $submenu['themes.php'][5]  = array(__('Themes'), 'edit_theme_options', 'themes.php');
149-               if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) )
150-                       $submenu['themes.php'][10] = array(__('Menus'), 'edit_theme_options', 'nav-menus.php' );
151-}
152+$appearance_cap = current_user_can( 'switch_themes') ? 'switch_themes' : 'edit_theme_options';
153+
154+$menu[60] = array( __('Appearance'), $appearance_cap, 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'div' );
155+       $submenu['themes.php'][4] = array( __( 'Customize' ), $appearance_cap, 'customize.php', 'hide-if-no-customize' );
156+       $submenu['themes.php'][5] = array(__( 'Themes' ), $appearance_cap, 'themes.php');
157+       if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) )
158+               $submenu['themes.php'][10] = array(__( 'Menus' ), 'edit_theme_options', 'nav-menus.php');
159 
160+unset( $appearance_cap );
161+
162 // Add 'Editor' to the bottom of the Appearance menu.
163 if ( ! is_multisite() )
164        add_action('admin_menu', '_add_themes_utility_last', 101);
165Index: wp-admin/themes.php
166===================================================================
167--- wp-admin/themes.php (revision 23402)
168+++ wp-admin/themes.php (working copy)
169@@ -161,6 +161,12 @@
170                        $class = '';
171                        if ( 'themes.php' == $item[2] || 'theme-editor.php' == $item[2] )
172                                continue;
173+                       if ( 'customize.php' == $item[2] ) {
174+                               if ( current_user_can( 'edit_theme_options' ) )
175+                                       $class = ' class="load-customize hide-if-no-customize"';
176+                               else
177+                                       continue;
178+                       }
179                        // 0 = name, 1 = capability, 2 = file
180                        if ( ( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file)) )
181                                $class = ' class="current"';
182@@ -187,12 +193,7 @@
183        if ( $options || current_user_can( 'edit_theme_options' ) ) :
184        ?>
185        <div class="theme-options">
186-               <?php if ( current_user_can( 'edit_theme_options' ) ) : ?>
187-               <a id="customize-current-theme-link" href="<?php echo wp_customize_url(); ?>" class="load-customize hide-if-no-customize" title="<?php echo esc_attr( $customize_title ); ?>"><?php _e( 'Customize' ); ?></a>
188-               <?php
189-               endif; // edit_theme_options
190-               if ( $options ) :
191-               ?>
192+               <?php if ( $options ) : ?>
193                <span><?php _e( 'Options:' )?></span>
194                <ul>
195                        <?php foreach ( $options as $option ) : ?>