Ticket #21749: 21749.diff

File 21749.diff, 10.7 KB (added by nacin, 9 months ago)
Line 
1Index: wp-admin/includes/class-wp-ms-themes-list-table.php
2===================================================================
3--- wp-admin/includes/class-wp-ms-themes-list-table.php (revision 21695)
4+++ wp-admin/includes/class-wp-ms-themes-list-table.php (working copy)
5@@ -277,27 +277,28 @@
6                        'delete' => ''
7                );
8 
9-               $theme_key = $theme->get_stylesheet();
10+               $theme_key = $stylesheet = $theme->get_stylesheet();
11+               $theme_key = urlencode( $theme_key );
12 
13                if ( ! $allowed ) {
14                        if ( ! $theme->errors() )
15-                               $actions['enable'] = '<a href="' . esc_url( wp_nonce_url($url . 'action=enable&amp;theme=' . $theme_key . '&amp;paged=' . $page . '&amp;s=' . $s, 'enable-theme_' . $theme_key) ) . '" title="' . esc_attr__('Enable this theme') . '" class="edit">' . ( $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ) ) . '</a>';
16+                               $actions['enable'] = '<a href="' . esc_url( wp_nonce_url($url . 'action=enable&amp;theme=' . $theme_key . '&amp;paged=' . $page . '&amp;s=' . $s, 'enable-theme_' . $stylesheet) ) . '" title="' . esc_attr__('Enable this theme') . '" class="edit">' . ( $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ) ) . '</a>';
17                } else {
18-                       $actions['disable'] = '<a href="' . esc_url( wp_nonce_url($url . 'action=disable&amp;theme=' . $theme_key . '&amp;paged=' . $page . '&amp;s=' . $s, 'disable-theme_' . $theme_key) ) . '" title="' . esc_attr__('Disable this theme') . '">' . ( $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ) ) . '</a>';
19+                       $actions['disable'] = '<a href="' . esc_url( wp_nonce_url($url . 'action=disable&amp;theme=' . $theme_key . '&amp;paged=' . $page . '&amp;s=' . $s, 'disable-theme_' . $stylesheet) ) . '" title="' . esc_attr__('Disable this theme') . '">' . ( $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ) ) . '</a>';
20                }
21 
22                if ( current_user_can('edit_themes') )
23-                       $actions['edit'] = '<a href="' . esc_url('theme-editor.php?theme=' .  $theme_key ) . '" title="' . esc_attr__('Open this theme in the Theme Editor') . '" class="edit">' . __('Edit') . '</a>';
24+                       $actions['edit'] = '<a href="' . esc_url('theme-editor.php?theme=' .  $theme_key) . '" title="' . esc_attr__('Open this theme in the Theme Editor') . '" class="edit">' . __('Edit') . '</a>';
25 
26-               if ( ! $allowed && current_user_can( 'delete_themes' ) && ! $this->is_site_themes && $theme_key != get_option( 'stylesheet' ) && $theme_key != get_option( 'template' ) )
27+               if ( ! $allowed && current_user_can( 'delete_themes' ) && ! $this->is_site_themes && $stylesheet != get_option( 'stylesheet' ) && $stylesheet != get_option( 'template' ) )
28                        $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=delete-selected&amp;checked[]=' . $theme_key . '&amp;theme_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'bulk-themes' ) ) . '" title="' . esc_attr__( 'Delete this theme' ) . '" class="delete">' . __( 'Delete' ) . '</a>';
29 
30-               $actions = apply_filters( 'theme_action_links', array_filter( $actions ), $theme_key, $theme, $context );
31-               $actions = apply_filters( "theme_action_links_$theme_key", $actions, $theme_key, $theme, $context );
32+               $actions = apply_filters( 'theme_action_links', array_filter( $actions ), $stylesheet, $theme, $context );
33+               $actions = apply_filters( "theme_action_links_$stylesheet", $actions, $stylesheet, $theme, $context );
34 
35                $class = ! $allowed ? 'inactive' : 'active';
36                $checkbox_id = "checkbox_" . md5( $theme->get('Name') );
37-               $checkbox = "<input type='checkbox' name='checked[]' value='" . esc_attr( $theme_key ) . "' id='" . $checkbox_id . "' /><label class='screen-reader-text' for='" . $checkbox_id . "' >" . __('Select') . " " . $theme->display('Name') . "</label>";
38+               $checkbox = "<input type='checkbox' name='checked[]' value='" . esc_attr( $stylesheet ) . "' id='" . $checkbox_id . "' /><label class='screen-reader-text' for='" . $checkbox_id . "' >" . __('Select') . " " . $theme->display('Name') . "</label>";
39 
40                $id = sanitize_html_class( $theme->get_stylesheet() );
41 
42@@ -341,7 +342,7 @@
43                                        if ( $theme->get('ThemeURI') )
44                                                $theme_meta[] = '<a href="' . $theme->display('ThemeURI') . '" title="' . esc_attr__( 'Visit theme homepage' ) . '">' . __( 'Visit Theme Site' ) . '</a>';
45 
46-                                       $theme_meta = apply_filters( 'theme_row_meta', $theme_meta, $theme_key, $theme, $status );
47+                                       $theme_meta = apply_filters( 'theme_row_meta', $theme_meta, $stylesheet, $theme, $status );
48                                        echo implode( ' | ', $theme_meta );
49 
50                                        echo "</div></td>";
51@@ -349,7 +350,7 @@
52 
53                                default:
54                                        echo "<td class='$column_name column-$column_name'$style>";
55-                                       do_action( 'manage_themes_custom_column', $column_name, $theme_key, $theme );
56+                                       do_action( 'manage_themes_custom_column', $column_name, $stylesheet, $theme );
57                                        echo "</td>";
58                        }
59                }
60@@ -357,8 +358,8 @@
61                echo "</tr>";
62 
63                if ( $this->is_site_themes )
64-                       remove_action( "after_theme_row_$theme_key", 'wp_theme_update_row' );
65-               do_action( 'after_theme_row', $theme_key, $theme, $status );
66-               do_action( "after_theme_row_$theme_key", $theme_key, $theme, $status );
67+                       remove_action( "after_theme_row_$stylesheet", 'wp_theme_update_row' );
68+               do_action( 'after_theme_row', $stylesheet, $theme, $status );
69+               do_action( "after_theme_row_$stylesheet", $stylesheet, $theme, $status );
70        }
71 }
72Index: wp-admin/includes/class-wp-upgrader.php
73===================================================================
74--- wp-admin/includes/class-wp-upgrader.php     (revision 21695)
75+++ wp-admin/includes/class-wp-upgrader.php     (working copy)
76@@ -1500,14 +1500,14 @@
77 
78                $preview_link = add_query_arg( array(
79                        'preview'    => 1,
80-                       'template'   => $template,
81-                       'stylesheet' => $stylesheet,
82-               ), trailingslashit( get_home_url() ) );
83+                       'template'   => urlencode( $template ),
84+                       'stylesheet' => urlencode( $stylesheet ),
85+               ), trailingslashit( home_url() ) );
86 
87                $activate_link = add_query_arg( array(
88                        'action'     => 'activate',
89-                       'template'   => $template,
90-                       'stylesheet' => $stylesheet,
91+                       'template'   => urlencode( $template ),
92+                       'stylesheet' => urlencode( $stylesheet ),
93                ), admin_url('themes.php') );
94                $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
95 
96@@ -1517,7 +1517,7 @@
97                $install_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate &#8220;%s&#8221;'), $name ) ) . '">' . __('Activate') . '</a>';
98 
99                if ( is_network_admin() && current_user_can( 'manage_network_themes' ) )
100-                       $install_actions['network_enable'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=enable&amp;theme=' . $stylesheet, 'enable-theme_' . $stylesheet ) ) . '" title="' . esc_attr__( 'Enable this theme for all sites in this network' ) . '" target="_parent">' . __( 'Network Enable' ) . '</a>';
101+                       $install_actions['network_enable'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=enable&amp;theme=' . urlencode( $stylesheet ), 'enable-theme_' . $stylesheet ) ) . '" title="' . esc_attr__( 'Enable this theme for all sites in this network' ) . '" target="_parent">' . __( 'Network Enable' ) . '</a>';
102 
103                if ( $this->type == 'web' )
104                        $install_actions['themes_page'] = '<a href="' . self_admin_url('theme-install.php') . '" title="' . esc_attr__('Return to Theme Installer') . '" target="_parent">' . __('Return to Theme Installer') . '</a>';
105@@ -1564,14 +1564,14 @@
106 
107                        $preview_link = add_query_arg( array(
108                                'preview'    => 1,
109-                               'template'   => $template,
110-                               'stylesheet' => $stylesheet,
111-                       ), trailingslashit( get_home_url() ) );
112+                               'template'   => urlencode( $template ),
113+                               'stylesheet' => urlencode( $stylesheet ),
114+                       ), trailingslashit( home_url() ) );
115 
116                        $activate_link = add_query_arg( array(
117                                'action'     => 'activate',
118-                               'template'   => $template,
119-                               'stylesheet' => $stylesheet,
120+                               'template'   => urlencode( $template ),
121+                               'stylesheet' => urlencode( $stylesheet ),
122                        ), admin_url('themes.php') );
123                        $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
124 
125Index: wp-admin/includes/theme.php
126===================================================================
127--- wp-admin/includes/theme.php (revision 21695)
128+++ wp-admin/includes/theme.php (working copy)
129@@ -23,7 +23,7 @@
130 
131        ob_start();
132        if ( empty( $redirect ) )
133-               $redirect = wp_nonce_url('themes.php?action=delete&stylesheet=' . $stylesheet, 'delete-theme_' . $stylesheet);
134+               $redirect = wp_nonce_url('themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet);
135        if ( false === ($credentials = request_filesystem_credentials($redirect)) ) {
136                $data = ob_get_contents();
137                ob_end_clean();
138Index: wp-admin/includes/class-wp-themes-list-table.php
139===================================================================
140--- wp-admin/includes/class-wp-themes-list-table.php    (revision 21695)
141+++ wp-admin/includes/class-wp-themes-list-table.php    (working copy)
142@@ -128,7 +128,7 @@
143                        $activate_link = wp_nonce_url( "themes.php?action=activate&amp;template=" . urlencode( $template ) . "&amp;stylesheet=" . urlencode( $stylesheet ), 'switch-theme_' . $stylesheet );
144 
145                        $preview_link = esc_url( add_query_arg(
146-                               array( 'preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'preview_iframe' => true, 'TB_iframe' => 'true' ),
147+                               array( 'preview' => 1, 'template' => urlencode( $template ), 'stylesheet' => urlencode( $stylesheet ), 'preview_iframe' => true, 'TB_iframe' => 'true' ),
148                                home_url( '/' ) ) );
149 
150                        $actions = array();
151@@ -143,7 +143,7 @@
152                                        . __( 'Live Preview' ) . '</a>';
153 
154                        if ( ! is_multisite() && current_user_can( 'delete_themes' ) )
155-                               $actions['delete'] = '<a class="submitdelete deletion" href="' . wp_nonce_url( "themes.php?action=delete&amp;stylesheet=$stylesheet", 'delete-theme_' . $stylesheet )
156+                               $actions['delete'] = '<a class="submitdelete deletion" href="' . wp_nonce_url( 'themes.php?action=delete&amp;stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet )
157                                        . '" onclick="' . "return confirm( '" . esc_js( sprintf( __( "You are about to delete this theme '%s'\n  'Cancel' to stop, 'OK' to delete." ), $title ) )
158                                        . "' );" . '">' . __( 'Delete' ) . '</a>';
159 
160Index: wp-admin/theme-editor.php
161===================================================================
162--- wp-admin/theme-editor.php   (revision 21695)
163+++ wp-admin/theme-editor.php   (working copy)
164@@ -46,7 +46,7 @@
165 wp_reset_vars( array( 'action', 'error', 'file', 'theme' ) );
166 
167 if ( $theme )
168-       $stylesheet = urldecode( $theme );
169+       $stylesheet = $theme;
170 else
171        $stylesheet = get_stylesheet();
172 
173@@ -68,7 +68,7 @@
174        $relative_file = 'style.css';
175        $file = $allowed_files['style.css'];
176 } else {
177-       $relative_file = urldecode( stripslashes( $file ) );
178+       $relative_file = stripslashes( $file );
179        $file = $theme->get_stylesheet_directory() . '/' . $relative_file;
180 }
181