Ticket #48491: 48491.6.diff
File 48491.6.diff, 19.6 KB (added by , 4 years ago) |
---|
-
wp-admin/customize.php
diff --git a/wp-admin/customize.php b/wp-admin/customize.php index 4954ca99ba..d1032fb5eb 100644
a b do_action( 'customize_controls_print_styles' ); 171 171 * @since 3.4.0 172 172 */ 173 173 do_action( 'customize_controls_print_scripts' ); 174 175 // Need to use \ReflectionObject as $wp_customize->theme is protected class. 176 $reflection_obj = new \ReflectionObject( $wp_customize ); 177 $reflection_theme = $reflection_obj->getProperty( 'theme' ); 178 $reflection_theme->setAccessible( true ); 179 $customize_theme = $reflection_theme->getValue( $wp_customize ); 180 $wp_compatible = is_wp_version_compatible( $customize_theme->get( 'RequiresWP' ) ); 181 $php_compatible = is_php_version_compatible( $customize_theme->get( 'RequiresPHP' ) ); 182 174 183 ?> 175 184 </head> 176 185 <body class="<?php echo esc_attr( $body_class ); ?>"> 177 186 <div class="wp-full-overlay expanded"> 178 187 <form id="customize-controls" class="wrap wp-full-overlay-sidebar"> 179 188 <div id="customize-header-actions" class="wp-full-overlay-header"> 180 <?php $save_text = $wp_customize->is_theme_active() ? __( 'Publish' ) : __( 'Activate & Publish' ); ?> 181 <div id="customize-save-button-wrapper" class="customize-save-button-wrapper" > 182 <?php submit_button( $save_text, 'primary save', 'save', false ); ?> 183 <button id="publish-settings" class="publish-settings button-primary button dashicons dashicons-admin-generic" aria-label="<?php esc_attr_e( 'Publish Settings' ); ?>" aria-expanded="false" disabled></button> 184 </div> 189 <?php if ( $wp_customize && $php_compatible ) : ?> 190 <?php $save_text = $wp_customize->is_theme_active() ? __( 'Publish' ) : __( 'Activate & Publish' ); ?> 191 <div id="customize-save-button-wrapper" class="customize-save-button-wrapper" > 192 <?php submit_button( $save_text, 'primary save', 'save', false ); ?> 193 <button id="publish-settings" class="publish-settings button-primary button dashicons dashicons-admin-generic" aria-label="<?php esc_attr_e( 'Publish Settings' ); ?>" aria-expanded="false" disabled></button> 194 </div> 195 <?php else: ?> 196 <?php $save_text = $wp_customize->is_theme_active() ? __( 'Publish' ) : __( 'Activate & Publish' ); ?> 197 <div id="customize-save-button-wrapper" class="customize-save-button-wrapper disabled" > 198 <a class="button disabled"><?php esc_html_e( $save_text ); ?></a> 199 </div> 200 <?php endif; ?> 185 201 <span class="spinner"></span> 186 202 <button type="button" class="customize-controls-preview-toggle"> 187 203 <span class="controls"><?php _e( 'Customize' ); ?></span> -
wp-admin/includes/theme.php
diff --git a/wp-admin/includes/theme.php b/wp-admin/includes/theme.php index 47168057e0..4a5a32c0f5 100644
a b function wp_prepare_themes_for_js( $themes = null ) { 654 654 } 655 655 656 656 $prepared_themes[ $slug ] = array( 657 'id' => $slug, 658 'name' => $theme->display( 'Name' ), 659 'screenshot' => array( $theme->get_screenshot() ), // @todo Multiple screenshots. 660 'description' => $theme->display( 'Description' ), 661 'author' => $theme->display( 'Author', false, true ), 662 'authorAndUri' => $theme->display( 'Author' ), 663 'version' => $theme->display( 'Version' ), 664 'tags' => $theme->display( 'Tags' ), 665 'parent' => $parent, 666 'active' => $slug === $current_theme, 667 'hasUpdate' => isset( $updates[ $slug ] ), 668 'hasPackage' => isset( $updates[ $slug ] ) && ! empty( $updates[ $slug ]['package'] ), 669 'update' => get_theme_update_available( $theme ), 670 'actions' => array( 657 'id' => $slug, 658 'name' => $theme->display( 'Name' ), 659 'screenshot' => array( $theme->get_screenshot() ), // @todo Multiple screenshots. 660 'description' => $theme->display( 'Description' ), 661 'author' => $theme->display( 'Author', false, true ), 662 'authorAndUri' => $theme->display( 'Author' ), 663 'version' => $theme->display( 'Version' ), 664 'tags' => $theme->display( 'Tags' ), 665 'requires' => $theme->display( 'RequiresWP' ), 666 'requires_php' => $theme->display( 'RequiresPHP' ), 667 'wp_compatible' => is_wp_version_compatible( $theme->display( 'RequiresWP' ) ), 668 'php_compatible' => is_php_version_compatible( $theme->display( 'RequiresPHP' ) ), 669 'parent' => $parent, 670 'active' => $slug === $current_theme, 671 'hasUpdate' => isset( $updates[ $slug ] ), 672 'hasPackage' => isset( $updates[ $slug ] ) && ! empty( $updates[ $slug ]['package'] ), 673 'update' => get_theme_update_available( $theme ), 674 'actions' => array( 671 675 'activate' => current_user_can( 'switch_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=activate&stylesheet=' . $encoded_slug ), 'switch-theme_' . $slug ) : null, 672 676 'customize' => $customize_action, 673 677 'delete' => current_user_can( 'delete_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=delete&stylesheet=' . $encoded_slug ), 'delete-theme_' . $slug ) : null, … … function customize_themes_print_templates() { 754 758 755 759 <# if ( data.hasUpdate ) { #> 756 760 <div class="notice notice-warning notice-alt notice-large" data-slug="{{ data.id }}"> 761 <# if ( data.wp_compatible && data.php_compatible ) { #> 757 762 <h3 class="notice-title"><?php _e( 'Update Available' ); ?></h3> 758 763 {{{ data.update }}} 764 <# } else { #> 765 <h3 class="notice-title"><?php _e( 'Update incompatible' ); ?></h3> 766 <p><?php printf( 767 /* translators: %s: WordPress version, %s: PHP version */ 768 __( 'This theme is incompatible with your current installation. This theme requires at least WordPress %s and PHP %s.' ), 769 '{{{ data.requires }}}', 770 '{{{ data.requires_php }}}' 771 ); ?></p> 772 <# } #> 759 773 </div> 760 774 <# } #> 761 775 -
wp-admin/theme-install.php
diff --git a/wp-admin/theme-install.php b/wp-admin/theme-install.php index 944e9d7d0a..52900a6bdd 100644
a b if ( $tab ) { 285 285 $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' ); 286 286 ?> 287 287 <# if ( data.activate_url ) { #> 288 <a class="button button-primary activate" href="{{ data.activate_url }}" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a> 288 <# if ( data.wp_compatible && data.php_compatible ) { #> 289 <a class="button button-primary activate" href="{{ data.activate_url }}" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a> 290 <# } else { #> 291 <a class="button button-primary disabled" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a> 292 <# } #> 289 293 <# } #> 290 294 <# if ( data.customize_url ) { #> 291 295 <a class="button load-customize" href="{{ data.customize_url }}"><?php _e( 'Live Preview' ); ?></a> … … if ( $tab ) { 315 319 <button class="previous-theme"><span class="screen-reader-text"><?php _e( 'Previous theme' ); ?></span></button> 316 320 <button class="next-theme"><span class="screen-reader-text"><?php _e( 'Next theme' ); ?></span></button> 317 321 <# if ( data.installed ) { #> 318 <a class="button button-primary activate" href="{{ data.activate_url }}"><?php _e( 'Activate' ); ?></a> 319 <# } else { #> 320 <a href="{{ data.install_url }}" class="button button-primary theme-install" data-name="{{ data.name }}" data-slug="{{ data.id }}"><?php _e( 'Install' ); ?></a> 322 <# if ( data.wp_compatible && data.php_compatible ) { #> 323 <a class="button button-primary activate" href="{{ data.activate_url }}"><?php _e( 'Activate' ); ?></a> 324 <# } else { #> 325 <a class="button button-primary disabled"><?php _e( 'Activate' ); ?></a> 326 <# } #> 327 <# } else { #> 328 <# <?php if ( $wp_compatible && $php_compatible ) : ?> #> 329 <a href="{{ data.install_url }}" class="button button-primary theme-install" data-name="{{ data.name }}" data-slug="{{ data.id }}"><?php _e( 'Install' ); ?></a> 330 <# <?php else: ?> #> 331 <a class="button button-primary theme-install disabled"><?php _e( 'Install' ); ?></a> 332 <# <?php endif; ?> #> 321 333 <# } #> 322 334 </div> 323 335 <div class="wp-full-overlay-sidebar-content"> -
wp-admin/themes.php
diff --git a/wp-admin/themes.php b/wp-admin/themes.php index 53bb1049a7..f7b03d675f 100644
a b foreach ( $themes as $theme ) : 323 323 324 324 <?php if ( $theme['hasUpdate'] ) : ?> 325 325 <div class="update-message notice inline notice-warning notice-alt"> 326 <?php if ( $theme['hasPackage'] ) : ?> 327 <p><?php _e( 'New version available. <button class="button-link" type="button">Update now</button>' ); ?></p> 326 <?php if ( $theme['wp_compatible'] && $theme['php_compatible'] ): ?> 327 <?php if ( $theme['hasPackage'] ) : ?> 328 <p><?php _e( 'New version available. <button class="button-link" type="button">Update now</button>' ); ?></p> 329 <?php else : ?> 330 <p><?php _e( 'New version available.' ); ?></p> 331 <?php endif; ?> 328 332 <?php else : ?> 329 <p><?php _e( ' New version available.' ); ?></p>333 <p><?php _e( 'Version update incompatible.' ); ?></p> 330 334 <?php endif; ?> 331 335 </div> 332 336 <?php endif; ?> … … foreach ( $themes as $theme ) : 358 362 /* translators: %s: Theme name. */ 359 363 $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' ); 360 364 ?> 361 <a class="button activate" href="<?php echo $theme['actions']['activate']; ?>" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a> 362 <?php if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?> 363 <a class="button button-primary load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Live Preview' ); ?></a> 364 <?php } ?> 365 <?php if ( $theme['wp_compatible'] && $theme['php_compatible'] ): ?> 366 <a class="button activate" href="<?php echo $theme['actions']['activate']; ?>" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a> 367 <?php if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?> 368 <a class="button button-primary load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Live Preview' ); ?></a> 369 <?php } ?> 370 <?php else : ?> 371 <a class="button disabled" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a> 372 <a class="button button-primary load-customize hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a> 373 <?php endif; ?> 365 374 <?php } ?> 366 375 367 376 </div> … … if ( ! is_multisite() && current_user_can( 'edit_themes' ) && $broken_themes ) { 488 497 <# } #> 489 498 490 499 <# if ( data.hasUpdate ) { #> 491 <# if ( data.hasPackage ) { #> 492 <div class="update-message notice inline notice-warning notice-alt"><p><?php _e( 'New version available. <button class="button-link" type="button">Update now</button>' ); ?></p></div> 500 <# if ( data.wp_compatible && data.php_compatible ) { #> 501 <div class="update-message notice inline notice-warning notice-alt"> 502 <# if ( data.hasPackage ) { #> 503 <p><?php _e( 'New version available. <button class="button-link" type="button">Update now</button>' ); ?></p></div> 504 <# } else { #> 505 <div class="update-message notice inline notice-warning notice-alt"><p><?php _e( 'New version available.' ); ?></p></div> 506 <# } #> 493 507 <# } else { #> 494 <div class="update-message notice inline notice-warning notice-alt"><p><?php _e( 'New version available.' ); ?></p></div> 508 <div class="notice inline notice-warning notice-alt"> 509 <p><?php _e( 'Update incompatible.' ); ?></p></div> 495 510 <# } #> 496 511 <# } #> 497 512 … … if ( ! is_multisite() && current_user_can( 'edit_themes' ) && $broken_themes ) { 522 537 /* translators: %s: Theme name. */ 523 538 $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' ); 524 539 ?> 525 <a class="button activate" href="{{{ data.actions.activate }}}" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a> 526 <a class="button button-primary load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Live Preview' ); ?></a> 540 <# if ( data.wp_compatible && data.php_compatible ) { #> 541 <a class="button activate" href="{{{ data.actions.activate }}}" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a> 542 <a class="button button-primary load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Live Preview' ); ?></a> 543 <# } else { #> 544 <a class="button disabled" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a> 545 <a class="button button-primary load-customize hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a> 546 <# } #> 527 547 <# } #> 528 548 </div> 529 549 </div> … … if ( ! is_multisite() && current_user_can( 'edit_themes' ) && $broken_themes ) { 565 585 566 586 <# if ( data.hasUpdate ) { #> 567 587 <div class="notice notice-warning notice-alt notice-large"> 568 <h3 class="notice-title"><?php _e( 'Update Available' ); ?></h3> 569 {{{ data.update }}} 588 <# if ( data.wp_compatible && data.php_compatible ) { #> 589 <h3 class="notice-title"><?php _e( 'Update Available' ); ?></h3> 590 {{{ data.update }}} 591 <# } else { #> 592 <h3 class="notice-title"><?php _e( 'Update incompatible' ); ?></h3> 593 <p><?php printf( 594 /* translators: %s: WordPress version, %s: PHP version */ 595 __( 'This theme is incompatible with your current installation. This theme requires at least WordPress %s and PHP %s.' ), 596 '{{{ data.requires }}}', 597 '{{{ data.requires_php }}}' 598 ); ?></p> 599 <# } #> 570 600 </div> 571 601 <# } #> 572 602 <p class="theme-description">{{{ data.description }}}</p> … … if ( ! is_multisite() && current_user_can( 'edit_themes' ) && $broken_themes ) { 596 626 /* translators: %s: Theme name. */ 597 627 $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' ); 598 628 ?> 599 <# if ( data.actions.activate ) { #>629 <# if ( data.actions.activate && data.wp_compatible && data.php_compatible ) { #> 600 630 <a href="{{{ data.actions.activate }}}" class="button activate" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a> 631 <a href="{{{ data.actions.customize }}}" class="button button-primary load-customize hide-if-no-customize"><?php _e( 'Live Preview' ); ?></a> 632 <# } else { #> 633 <a class="button disabled" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a> 634 <a class="button button-primary load-customize hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a> 601 635 <# } #> 602 <a href="{{{ data.actions.customize }}}" class="button button-primary load-customize hide-if-no-customize"><?php _e( 'Live Preview' ); ?></a>603 636 </div> 604 637 605 638 <# if ( ! data.active && data.actions['delete'] ) { #> -
wp-admin/update-core.php
diff --git a/wp-admin/update-core.php b/wp-admin/update-core.php index 9d21ac8c2c..b147fa363f 100644
a b function list_theme_updates() { 479 479 <tbody class="plugins"> 480 480 <?php 481 481 foreach ( $themes as $stylesheet => $theme ) { 482 $checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) ); 482 $checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) ); 483 $compatible_php = is_php_version_compatible( $theme->get( 'RequiresPHP' ) ); 484 $compat = ''; 485 $annotation = ''; 486 if ( ! $compatible_php && current_user_can( 'update_php' ) ) { 487 $compat .= '<br>' . __( 'This update doesn’t work with your version of PHP.' ) . ' '; 488 $compat .= sprintf( 489 /* translators: %s: URL to Update PHP page. */ 490 __( '<a href="%s">Learn more about updating PHP</a>.' ), 491 esc_url( wp_get_update_php_url() ) 492 ); 493 494 $annotation = wp_get_update_php_annotation(); 495 496 if ( $annotation ) { 497 $compat .= '</p><p><em>' . $annotation . '</em>'; 498 } 499 } 483 500 ?> 484 501 <tr> 485 502 <td class="check-column"> 486 <input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $stylesheet ); ?>" /> 487 <label for="<?php echo $checkbox_id; ?>" class="screen-reader-text"> 488 <?php 489 /* translators: %s: Theme name. */ 490 printf( __( 'Select %s' ), $theme->display( 'Name' ) ); 491 ?> 492 </label> 503 <?php if ( $compatible_php ) : ?> 504 <input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $stylesheet ); ?>" /> 505 <label for="<?php echo $checkbox_id; ?>" class="screen-reader-text"> 506 <?php 507 /* translators: %s: Theme name. */ 508 printf( __( 'Select %s' ), $theme->display( 'Name' ) ); 509 ?> 510 </label> 511 <?php endif; ?> 493 512 </td> 494 513 <td class="plugin-title"><p> 495 514 <img src="<?php echo esc_url( $theme->get_screenshot() ); ?>" width="85" height="64" class="updates-table-screenshot" alt="" /> … … function list_theme_updates() { 501 520 $theme->display( 'Version' ), 502 521 $theme->update['new_version'] 503 522 ); 523 echo $compat . $annotation; 504 524 ?> 505 525 </p></td> 506 526 </tr> -
wp-includes/customize/class-wp-customize-theme-control.php
diff --git a/wp-includes/customize/class-wp-customize-theme-control.php b/wp-includes/customize/class-wp-customize-theme-control.php index 10f09d180b..5dd0873d40 100644
a b class WP_Customize_Theme_Control extends WP_Customize_Control { 90 90 </div> 91 91 92 92 <# if ( 'installed' === data.theme.type && data.theme.hasUpdate ) { #> 93 <div class="update-message notice inline notice-warning notice-alt" data-slug="{{ data.theme.id }}"> 94 <p> 95 <?php 96 if ( is_multisite() ) { 97 _e( 'New version available.' ); 98 } else { 99 printf( 100 /* translators: %s: "Update now" button. */ 101 __( 'New version available. %s' ), 102 '<button class="button-link update-theme" type="button">' . __( 'Update now' ) . '</button>' 103 ); 104 } 105 ?> 106 </p> 107 </div> 93 <# if ( data.theme.wp_compatible && data.theme.php_compatible ) { #> 94 <div class="update-message notice inline notice-warning notice-alt" data-slug="{{ data.theme.id }}"> 95 <p> 96 <?php 97 if ( is_multisite() ) { 98 _e( 'New version available.' ); 99 } else { 100 printf( 101 /* translators: %s: "Update now" button. */ 102 __( 'New version available. %s' ), 103 '<button class="button-link update-theme" type="button">' . __( 'Update now' ) . '</button>' 104 ); 105 } 106 ?> 107 </p> 108 </div> 109 <# } else { #> 110 <div class="update-message notice inline notice-warning notice-alt" data-slug="{{ data.theme.id }}"> 111 <p> 112 <?php _e( 'Update Incompatible.' ); ?> 113 </p> 114 </div> 115 <# } #> 108 116 <# } #> 109 117 110 118 <# if ( data.theme.active ) { #> … … class WP_Customize_Theme_Control extends WP_Customize_Control { 121 129 <div class="theme-id-container"> 122 130 <h3 class="theme-name" id="{{ data.section }}-{{ data.theme.id }}-name">{{ data.theme.name }}</h3> 123 131 <div class="theme-actions"> 124 <button type="button" class="button button-primary preview-theme" aria-label="<?php echo esc_attr( $preview_label ); ?>" data-slug="{{ data.theme.id }}"><?php _e( 'Live Preview' ); ?></button> 132 <# if ( data.theme.wp_compatible && data.theme.php_compatible ) { #> 133 <button type="button" class="button button-primary preview-theme" aria-label="<?php echo esc_attr( $preview_label ); ?>" data-slug="{{ data.theme.id }}"><?php _e( 'Live Preview' ); ?></button> 134 <# } else { #> 135 <button class="button button-primary disabled" aria-label="<?php echo esc_attr( $preview_label ); ?>"><?php _e( 'Live Preview' ); ?></button> 136 <# } #> 125 137 </div> 126 138 </div> 127 139 <div class="notice notice-success notice-alt"><p><?php _ex( 'Installed', 'theme' ); ?></p></div>