- File:
-
- 1 edited
-
trunk/wp-admin/includes/class-wp-upgrader.php (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/class-wp-upgrader.php
r19246 r21064 375 375 $this->strings['downloading_package'] = __('Downloading update from <span class="code">%s</span>…'); 376 376 $this->strings['unpack_package'] = __('Unpacking the update…'); 377 $this->strings['deactivate_plugin'] = __('Deactivating the plugin…');378 377 $this->strings['remove_old'] = __('Removing the old version of the plugin…'); 379 378 $this->strings['remove_old_failed'] = __('Could not remove the old plugin.'); … … 413 412 // Force refresh of plugin update information 414 413 delete_site_transient('update_plugins'); 414 wp_cache_delete( 'plugins', 'plugins' ); 415 415 416 416 return true; … … 457 457 // Force refresh of plugin update information 458 458 delete_site_transient('update_plugins'); 459 wp_cache_delete( 'plugins', 'plugins' ); 459 460 } 460 461 … … 538 539 // Force refresh of plugin update information 539 540 delete_site_transient('update_plugins'); 541 wp_cache_delete( 'plugins', 'plugins' ); 540 542 541 543 return $results; … … 595 597 596 598 if ( is_plugin_active($plugin) ) { 597 $this->skin->feedback('deactivate_plugin');598 599 //Deactivate the plugin silently, Prevent deactivation hooks from running. 599 600 deactivate_plugins($plugin, true); … … 663 664 $this->strings['process_failed'] = __('Theme install failed.'); 664 665 $this->strings['process_success'] = __('Theme installed successfully.'); 666 /* translators: 1: theme name, 2: version */ 667 $this->strings['process_success_specific'] = __('Successfully installed the theme <strong>%1$s %2$s</strong>.'); 668 $this->strings['parent_theme_search'] = __('This theme requires a parent theme. Checking if it is installed…'); 669 /* translators: 1: theme name, 2: version */ 670 $this->strings['parent_theme_prepare_install'] = __('Preparing to install <strong>%1$s %2$s</strong>…'); 671 /* translators: 1: theme name, 2: version */ 672 $this->strings['parent_theme_currently_installed'] = __('The parent theme, <strong>%1$s %2$s</strong>, is currently installed.'); 673 /* translators: 1: theme name, 2: version */ 674 $this->strings['parent_theme_install_success'] = __('Successfully installed the parent theme, <strong>%1$s %2$s</strong>.'); 675 $this->strings['parent_theme_not_found'] = __('<strong>The parent theme could not be found.</strong> You will need to install the parent theme, <strong>%s</strong>, before you can use this child theme.'); 676 } 677 678 function check_parent_theme_filter($install_result, $hook_extra, $child_result) { 679 // Check to see if we need to install a parent theme 680 $theme_info = $this->theme_info(); 681 682 if ( ! $theme_info->parent() ) 683 return $install_result; 684 685 $this->skin->feedback( 'parent_theme_search' ); 686 687 if ( ! $theme_info->parent()->errors() ) { 688 $this->skin->feedback( 'parent_theme_currently_installed', $theme_info->parent()->display('Name'), $theme_info->parent()->display('Version') ); 689 // We already have the theme, fall through. 690 return $install_result; 691 } 692 693 // We don't have the parent theme, lets install it 694 $api = themes_api('theme_information', array('slug' => $theme_info->get('Template'), 'fields' => array('sections' => false, 'tags' => false) ) ); //Save on a bit of bandwidth. 695 696 if ( ! $api || is_wp_error($api) ) { 697 $this->skin->feedback( 'parent_theme_not_found', $theme_info->get('Template') ); 698 // Don't show activate or preview actions after install 699 add_filter('install_theme_complete_actions', array(&$this, 'hide_activate_preview_actions') ); 700 return $install_result; 701 } 702 703 // Backup required data we're going to override: 704 $child_api = $this->skin->api; 705 $child_success_message = $this->strings['process_success']; 706 707 // Override them 708 $this->skin->api = $api; 709 $this->strings['process_success_specific'] = $this->strings['parent_theme_install_success'];//, $api->name, $api->version); 710 711 $this->skin->feedback('parent_theme_prepare_install', $api->name, $api->version); 712 713 add_filter('install_theme_complete_actions', '__return_false', 999); // Don't show any actions after installing the theme. 714 715 // Install the parent theme 716 $parent_result = $this->run( array( 717 'package' => $api->download_link, 718 'destination' => WP_CONTENT_DIR . '/themes', 719 'clear_destination' => false, //Do not overwrite files. 720 'clear_working' => true 721 ) ); 722 723 if ( is_wp_error($parent_result) ) 724 add_filter('install_theme_complete_actions', array(&$this, 'hide_activate_preview_actions') ); 725 726 // Start cleaning up after the parents installation 727 remove_filter('install_theme_complete_actions', '__return_false', 999); 728 729 // Reset child's result and data 730 $this->result = $child_result; 731 $this->skin->api = $child_api; 732 $this->strings['process_success'] = $child_success_message; 733 734 return $install_result; 735 } 736 737 function hide_activate_preview_actions($actions) { 738 unset($actions['activate'], $actions['preview']); 739 return $actions; 665 740 } 666 741 … … 671 746 672 747 add_filter('upgrader_source_selection', array(&$this, 'check_package') ); 748 add_filter('upgrader_post_install', array(&$this, 'check_parent_theme_filter'), 10, 3); 673 749 674 750 $options = array( … … 682 758 683 759 remove_filter('upgrader_source_selection', array(&$this, 'check_package') ); 760 remove_filter('upgrader_post_install', array(&$this, 'check_parent_theme_filter'), 10, 3); 684 761 685 762 if ( ! $this->result || is_wp_error($this->result) ) … … 688 765 // Force refresh of theme update information 689 766 delete_site_transient('update_themes'); 767 search_theme_directories( true ); 768 foreach ( wp_get_themes() as $theme ) 769 $theme->cache_delete(); 690 770 691 771 return true; … … 734 814 // Force refresh of theme update information 735 815 delete_site_transient('update_themes'); 816 search_theme_directories( true ); 817 foreach ( wp_get_themes() as $theme ) 818 $theme->cache_delete(); 736 819 737 820 return true; … … 821 904 // Force refresh of theme update information 822 905 delete_site_transient('update_themes'); 906 search_theme_directories( true ); 907 foreach ( wp_get_themes() as $theme ) 908 $theme->cache_delete(); 823 909 824 910 return $results; … … 836 922 return $source; 837 923 838 if ( ! file_exists( $working_directory . 'style.css' ) ) // A proper archive should have a style.css file in the single subdirectory 924 // A proper archive should have a style.css file in the single subdirectory 925 if ( ! file_exists( $working_directory . 'style.css' ) ) 839 926 return new WP_Error( 'incompatible_archive', $this->strings['incompatible_archive'], __('The theme is missing the <code>style.css</code> stylesheet.') ); 840 927 841 $info = get_theme_data( $working_directory . 'style.css' ); 842 if ( empty($info['Name']) ) 928 $info = get_file_data( $working_directory . 'style.css', array( 'Name' => 'Theme Name', 'Template' => 'Template' ) ); 929 930 if ( empty( $info['Name'] ) ) 843 931 return new WP_Error( 'incompatible_archive', $this->strings['incompatible_archive'], __("The <code>style.css</code> stylesheet doesn't contain a valid theme header.") ); 844 932 845 if ( empty($info['Template']) && ! file_exists( $working_directory . 'index.php' ) ) // If no template is set, it must have at least an index.php to be legit. 933 // If it's not a child theme, it must have at least an index.php to be legit. 934 if ( empty( $info['Template'] ) && ! file_exists( $working_directory . 'index.php' ) ) 846 935 return new WP_Error( 'incompatible_archive', $this->strings['incompatible_archive'], __('The theme is missing the <code>index.php</code> file.') ); 847 936 … … 871 960 $theme = isset($theme['theme']) ? $theme['theme'] : ''; 872 961 873 if ( $theme != get_stylesheet() ) // If not current962 if ( $theme != get_stylesheet() ) // If not current 874 963 return $return; 875 964 876 // Ensure stylesheet name hasnt changed after the upgrade:965 // Ensure stylesheet name hasnt changed after the upgrade: 877 966 // @TODO: Note, This doesn't handle the Template changing, or the Template name changing. 878 967 if ( $theme == get_stylesheet() && $theme != $this->result['destination_name'] ) { 879 968 $theme_info = $this->theme_info(); 880 969 $stylesheet = $this->result['destination_name']; 881 $template = !empty($theme_info['Template']) ? $theme_info['Template'] : $stylesheet;970 $template = $theme_info->get_template(); 882 971 switch_theme($template, $stylesheet, true); 883 972 } … … 912 1001 return false; 913 1002 } 914 return get_theme_data(WP_CONTENT_DIR . '/themes/' . $theme . '/style.css');1003 return wp_get_theme( $theme, WP_CONTENT_DIR . '/themes/' ); 915 1004 } 916 1005 … … 934 1023 $this->strings['unpack_package'] = __('Unpacking the update…'); 935 1024 $this->strings['copy_failed'] = __('Could not copy files.'); 1025 $this->strings['copy_failed_space'] = __('Could not copy files. You may have run out of disk space.' ); 936 1026 } 937 1027 … … 986 1076 require(ABSPATH . 'wp-admin/includes/update-core.php'); 987 1077 1078 if ( ! function_exists( 'update_core' ) ) 1079 return new WP_Error( 'copy_failed_space', $this->strings['copy_failed_space'] ); 1080 988 1081 return update_core($working_dir, $wp_dir); 989 1082 } … … 1107 1200 $this->plugin = $this->upgrader->plugin_info(); 1108 1201 if ( !empty($this->plugin) && !is_wp_error($this->result) && $this->plugin_active ){ 1109 show_message(__('Reactivating the plugin…'));1110 1202 echo '<iframe style="border:0;overflow:hidden" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&networkwide=' . $this->plugin_network_active . '&plugin=' . $this->plugin, 'activate-plugin_' . $this->plugin) .'"></iframe>'; 1111 1203 } … … 1291 1383 1292 1384 function before() { 1293 parent::before( $this->theme_info['Name']);1385 parent::before( $this->theme_info->display('Name') ); 1294 1386 } 1295 1387 1296 1388 function after() { 1297 parent::after($this->theme_info['Name']); 1298 } 1389 parent::after( $this->theme_info->display('Name') ); 1390 } 1391 1299 1392 function bulk_footer() { 1300 1393 parent::bulk_footer(); … … 1304 1397 ); 1305 1398 1306 $update_actions = apply_filters('update_bulk_theme_complete_actions', $update_actions, $this->theme_info );1399 $update_actions = apply_filters('update_bulk_theme_complete_actions', $update_actions, $this->theme_info ); 1307 1400 if ( ! empty($update_actions) ) 1308 1401 $this->feedback(implode(' | ', (array)$update_actions)); … … 1363 1456 $install_actions['plugins_page'] = '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Return to Plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>'; 1364 1457 1365 1366 1458 if ( ! $this->result || is_wp_error($this->result) ) { 1367 1459 unset( $install_actions['activate_plugin'] ); … … 1398 1490 1399 1491 function before() { 1400 if ( !empty($this->api) ) { 1401 /* translators: 1: theme name, 2: version */ 1402 $this->upgrader->strings['process_success'] = sprintf( __('Successfully installed the theme <strong>%1$s %2$s</strong>.'), $this->api->name, $this->api->version); 1403 } 1492 if ( !empty($this->api) ) 1493 $this->upgrader->strings['process_success'] = sprintf( $this->upgrader->strings['process_success_specific'], $this->api->name, $this->api->version); 1404 1494 } 1405 1495 … … 1409 1499 1410 1500 $theme_info = $this->upgrader->theme_info(); 1411 if ( empty( $theme_info) )1501 if ( empty( $theme_info ) ) 1412 1502 return; 1413 $name = $theme_info['Name']; 1503 1504 $name = $theme_info->display('Name'); 1414 1505 $stylesheet = $this->upgrader->result['destination_name']; 1415 $template = !empty($theme_info['Template']) ? $theme_info['Template'] : $stylesheet; 1416 1417 $preview_link = htmlspecialchars( add_query_arg( array('preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'preview_iframe' => 1, 'TB_iframe' => 'true' ), trailingslashit(esc_url(get_option('home'))) ) ); 1418 $activate_link = wp_nonce_url("themes.php?action=activate&template=" . urlencode($template) . "&stylesheet=" . urlencode($stylesheet), 'switch-theme_' . $template); 1419 1420 $install_actions = array( 1421 'preview' => '<a href="' . $preview_link . '" class="thickbox thickbox-preview" title="' . esc_attr(sprintf(__('Preview “%s”'), $name)) . '">' . __('Preview') . '</a>', 1422 'activate' => '<a href="' . $activate_link . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate “%s”'), $name ) ) . '">' . __('Activate') . '</a>' 1423 ); 1506 $template = $theme_info->get_template(); 1507 1508 $preview_link = add_query_arg( array( 1509 'preview' => 1, 1510 'template' => $template, 1511 'stylesheet' => $stylesheet, 1512 ), trailingslashit( get_home_url() ) ); 1513 1514 $activate_link = add_query_arg( array( 1515 'action' => 'activate', 1516 'template' => $template, 1517 'stylesheet' => $stylesheet, 1518 ), admin_url('themes.php') ); 1519 $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet ); 1520 1521 $install_actions = array(); 1522 $install_actions['preview'] = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-customize" title="' . esc_attr( sprintf( __('Preview “%s”'), $name ) ) . '">' . __('Preview') . '</a>'; 1523 $install_actions['preview'] .= '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize" title="' . esc_attr( sprintf( __('Preview “%s”'), $name ) ) . '">' . __('Live Preview') . '</a>'; 1524 $install_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate “%s”'), $name ) ) . '">' . __('Activate') . '</a>'; 1424 1525 1425 1526 if ( is_network_admin() && current_user_can( 'manage_network_themes' ) ) 1426 $install_actions['network_enable'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=enable&theme=' . $ template, 'enable-theme_' . $template) ) . '" title="' . esc_attr__( 'Enable this theme for all sites in this network' ) . '" target="_parent">' . __( 'Network Enable' ) . '</a>';1527 $install_actions['network_enable'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=enable&theme=' . $stylesheet, 'enable-theme_' . $stylesheet ) ) . '" title="' . esc_attr__( 'Enable this theme for all sites in this network' ) . '" target="_parent">' . __( 'Network Enable' ) . '</a>'; 1427 1528 1428 1529 if ( $this->type == 'web' ) … … 1464 1565 1465 1566 $update_actions = array(); 1466 if ( !empty($this->upgrader->result['destination_name']) && 1467 ($theme_info = $this->upgrader->theme_info()) && 1468 !empty($theme_info) ) { 1469 1470 $name = $theme_info['Name']; 1567 if ( ! empty( $this->upgrader->result['destination_name'] ) && $theme_info = $this->upgrader->theme_info() ) { 1568 $name = $theme_info->display('Name'); 1471 1569 $stylesheet = $this->upgrader->result['destination_name']; 1472 $template = !empty($theme_info['Template']) ? $theme_info['Template'] : $stylesheet; 1473 1474 $preview_link = htmlspecialchars( add_query_arg( array('preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'TB_iframe' => 'true' ), trailingslashit(esc_url(get_option('home'))) ) ); 1475 $activate_link = wp_nonce_url("themes.php?action=activate&template=" . urlencode($template) . "&stylesheet=" . urlencode($stylesheet), 'switch-theme_' . $template); 1476 1477 $update_actions['preview'] = '<a href="' . $preview_link . '" class="thickbox thickbox-preview" title="' . esc_attr(sprintf(__('Preview “%s”'), $name)) . '">' . __('Preview') . '</a>'; 1478 $update_actions['activate'] = '<a href="' . $activate_link . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate “%s”'), $name ) ) . '">' . __('Activate') . '</a>'; 1479 1480 if ( ( ! $this->result || is_wp_error($this->result) ) || $stylesheet == get_stylesheet() ) 1481 unset($update_actions['preview'], $update_actions['activate']); 1570 $template = $theme_info->get_template(); 1571 1572 $preview_link = add_query_arg( array( 1573 'preview' => 1, 1574 'template' => $template, 1575 'stylesheet' => $stylesheet, 1576 ), trailingslashit( get_home_url() ) ); 1577 1578 $activate_link = add_query_arg( array( 1579 'action' => 'activate', 1580 'template' => $template, 1581 'stylesheet' => $stylesheet, 1582 ), admin_url('themes.php') ); 1583 $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet ); 1584 1585 if ( get_stylesheet() == $stylesheet ) { 1586 $update_actions['preview'] = '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize" title="' . esc_attr( sprintf( __('Customize “%s”'), $name ) ) . '">' . __('Customize') . '</a>'; 1587 } else { 1588 $update_actions['preview'] = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-customize" title="' . esc_attr( sprintf( __('Preview “%s”'), $name ) ) . '">' . __('Preview') . '</a>'; 1589 $update_actions['preview'] .= '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize" title="' . esc_attr( sprintf( __('Preview “%s”'), $name ) ) . '">' . __('Live Preview') . '</a>'; 1590 $update_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate “%s”'), $name ) ) . '">' . __('Activate') . '</a>'; 1591 } 1592 1593 if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() ) 1594 unset( $update_actions['preview'], $update_actions['activate'] ); 1482 1595 } 1483 1596
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)