Ticket #19270: 19270.2.diff

File 19270.2.diff, 3.2 KB (added by martythornley, 11 months ago)
Line 
1Index: wp-admin/themes.php
2===================================================================
3--- wp-admin/themes.php (revision 21092)
4+++ wp-admin/themes.php (working copy)
5@@ -151,9 +151,14 @@
6        <?php
7        // Pretend you didn't see this.
8        $options = array();
9+
10+       if ( current_user_can( 'edit_theme_options' ) )
11+               $options['customize'] =  '<a id="customize-current-theme-link" href="' . wp_customize_url(). '" class="load-customize hide-if-no-customize" title="' . esc_attr( $customize_title ) .'">Customize</a>';
12+                       
13        if ( is_array( $submenu ) && isset( $submenu['themes.php'] ) ) {
14                foreach ( (array) $submenu['themes.php'] as $item) {
15                        $class = '';
16+                       $name = sanitize_file_name( strtolower( $item[0] ) );
17                        if ( 'themes.php' == $item[2] || 'theme-editor.php' == $item[2] )
18                                continue;
19                        // 0 = name, 1 = capability, 2 = file
20@@ -163,40 +168,40 @@
21                                $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index.
22                                $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]);
23                                if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))
24-                                       $options[] = "<a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>";
25+                                       $options[$name] = "<a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>";
26                                else
27-                                       $options[] = "<a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>";
28+                                       $options[$name] = "<a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>";
29                        } else if ( current_user_can($item[1]) ) {
30                                if ( file_exists(ABSPATH . 'wp-admin/' . $item[2]) ) {
31-                                       $options[] = "<a href='{$item[2]}'$class>{$item[0]}</a>";
32+                                       $options[$name] = "<a href='{$item[2]}'$class>{$item[0]}</a>";
33                                } else {
34-                                       $options[] = "<a href='themes.php?page={$item[2]}'$class>{$item[0]}</a>";
35+                                       $options[$name] = "<a href='themes.php?page={$item[2]}'$class>{$item[0]}</a>";
36                                }
37                        }
38                }
39        }
40-
41-       if ( $options || current_user_can( 'edit_theme_options' ) ) :
42+       $options = apply_filters( 'theme_option_links' , $options , $ct->stylesheet );
43        ?>
44-       <div class="theme-options">
45-               <?php if ( current_user_can( 'edit_theme_options' ) ) : ?>
46-               <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>
47-               <?php
48-               endif; // edit_theme_options
49-               if ( $options ) :
50-               ?>
51-               <span><?php _e( 'Options:' )?></span>
52-               <ul>
53-                       <?php foreach ( $options as $option ) : ?>
54-                               <li><?php echo $option; ?></li>
55-                       <?php endforeach; ?>
56-               </ul>
57-       </div>
58-       <?php
59-               endif; // options
60-       endif; // options || edit_theme_options
61-       ?>
62 
63+       <?php if ( $options || current_user_can( 'edit_theme_options' ) ) { ?>
64+               <?php if ( $options ) { ?>
65+                       <div class="theme-options">                             
66+                               <?php
67+                                       if ( isset( $options['customize'] ) ) {
68+                                               echo $options['customize'];
69+                                               unset( $options['customize'] );
70+                                       }
71+                               ?>
72+                               <span><?php _e( 'Options:' )?></span>
73+                               <ul>
74+                                       <?php foreach ( $options as $key => $option ) : ?>
75+                                               <li class="<?php echo $key; ?>"><?php echo $option; ?></li>
76+                                       <?php endforeach; ?>
77+                               </ul>
78+                       </div>
79+               <?php }; ?>
80+       <?php }; ?>
81+
82 </div>
83 
84 <br class="clear" />