~canonical-sysadmins/wordpress/4.5.3

« back to all changes in this revision

Viewing changes to wp-admin/includes/theme.php

  • Committer: Ryan Finnie
  • Date: 2015-08-31 16:09:47 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: ryan.finnie@canonical.com-20150831160947-1h6rfxby9z1ec62u
Merge WP4.3 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 *
12
12
 * @since 2.8.0
13
13
 *
 
14
 * @global WP_Filesystem_Base $wp_filesystem Subclass
 
15
 *
14
16
 * @param string $stylesheet Stylesheet of the theme to delete
15
17
 * @param string $redirect Redirect to page when complete.
16
 
 * @return mixed
 
18
 * @return void|bool|WP_Error When void, echoes content.
17
19
 */
18
20
function delete_theme($stylesheet, $redirect = '') {
19
21
        global $wp_filesystem;
25
27
        if ( empty( $redirect ) )
26
28
                $redirect = wp_nonce_url('themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet);
27
29
        if ( false === ($credentials = request_filesystem_credentials($redirect)) ) {
28
 
                $data = ob_get_contents();
29
 
                ob_end_clean();
 
30
                $data = ob_get_clean();
 
31
 
30
32
                if ( ! empty($data) ){
31
33
                        include_once( ABSPATH . 'wp-admin/admin-header.php');
32
34
                        echo $data;
38
40
 
39
41
        if ( ! WP_Filesystem($credentials) ) {
40
42
                request_filesystem_credentials($redirect, '', true); // Failed to connect, Error and request again
41
 
                $data = ob_get_contents();
42
 
                ob_end_clean();
 
43
                $data = ob_get_clean();
 
44
 
43
45
                if ( ! empty($data) ) {
44
46
                        include_once( ABSPATH . 'wp-admin/admin-header.php');
45
47
                        echo $data;
121
123
 * @since 2.7.0
122
124
 * @see get_theme_update_available()
123
125
 *
124
 
 * @param object $theme Theme data object.
 
126
 * @param WP_Theme $theme Theme data object.
125
127
 */
126
128
function theme_update_available( $theme ) {
127
129
        echo get_theme_update_available( $theme );
134
136
 *
135
137
 * @since 3.8.0
136
138
 *
 
139
 * @staticvar object $themes_update
 
140
 *
137
141
 * @param WP_Theme $theme WP_Theme object.
138
142
 * @return false|string HTML for the update link, or false if invalid info was passed.
139
143
 */
140
144
function get_theme_update_available( $theme ) {
141
 
        static $themes_update;
 
145
        static $themes_update = null;
142
146
 
143
147
        if ( !current_user_can('update_themes' ) )
144
148
                return false;
475
479
                        'actions'      => array(
476
480
                                'activate' => current_user_can( 'switch_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=activate&stylesheet=' . $encoded_slug ), 'switch-theme_' . $slug ) : null,
477
481
                                'customize' => ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) ? wp_customize_url( $slug ) : null,
478
 
                                'preview'   => add_query_arg( array(
479
 
                                        'preview'        => 1,
480
 
                                        'template'       => urlencode( $theme->get_template() ),
481
 
                                        'stylesheet'     => urlencode( $slug ),
482
 
                                        'preview_iframe' => true,
483
 
                                        'TB_iframe'      => true,
484
 
                                ), home_url( '/' ) ),
485
482
                                'delete'   => current_user_can( 'delete_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=delete&stylesheet=' . $encoded_slug ), 'delete-theme_' . $slug ) : null,
486
483
                        ),
487
484
                );
561
558
        </script>
562
559
        <?php
563
560
}
564
 
add_action( 'customize_controls_print_footer_scripts', 'customize_themes_print_templates' );