Changeset 25568 for trunk/src/wp-admin/includes/class-wp-upgrader.php
- Timestamp:
- 09/23/2013 09:37:25 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-upgrader.php
r25566 r25568 1099 1099 } 1100 1100 1101 function upgrade() { 1102 return $this->bulk_upgrade(); 1103 } 1104 1105 function bulk_upgrade() { 1101 function upgrade( $update = false ) { 1102 if ( $update ) 1103 $update = array( $update ); 1104 return $this->bulk_upgrade( $update ); 1105 } 1106 1107 function bulk_upgrade( $language_updates = array() ) { 1106 1108 1107 1109 $this->init(); 1108 1110 $this->upgrade_strings(); 1109 1111 1110 $language_updates = wp_get_translation_updates(); 1112 if ( ! $language_updates ) 1113 $language_updates = wp_get_translation_updates(); 1111 1114 1112 1115 if ( empty( $language_updates ) ) 1113 1116 return true; 1114 1117 1115 $this->skin->feedback( 'starting_upgrade' ); 1118 if ( 'upgrader_process_complete' == current_filter() ) 1119 $this->skin->feedback( 'starting_upgrade' ); 1116 1120 1117 1121 add_filter( 'upgrader_source_selection', array( &$this, 'check_package' ), 10, 3 ); … … 1288 1292 1289 1293 // Defaults: 1290 $upgrade_dev = false; 1291 $upgrade_minor = false; // @TODO: Update for release by toggling to true.1294 $upgrade_dev = false; // TODO Enable 1295 $upgrade_minor = false; // TODO Enable 1292 1296 $upgrade_major = false; 1293 1297 … … 1473 1477 // Next up, do we actually have it enabled for this type of update? 1474 1478 switch ( $type ) { 1479 case 'language': 1480 $upgrade = false; // TODO Enable 1481 break; 1475 1482 case 'core': 1476 1483 $upgrade = Core_Upgrader::should_upgrade_to_version( $item->current ); … … 1531 1538 $context = get_theme_root( $item ); 1532 1539 break; 1540 case 'language': 1541 $upgrader = new Language_Pack_Upgrader( $skin ); 1542 $context = WP_LANG_DIR; 1543 break; 1533 1544 } 1534 1545 … … 1552 1563 $skin->feedback( __( 'Updating Plugin: %s' ), $item_name ); 1553 1564 break; 1565 case 'language': 1566 if ( 'theme' == $item->type ) { 1567 $theme = wp_get_theme( $item->slug ); 1568 $skin->feedback( sprintf( 1569 __( 'Updating the %1$s language files for the %2$s Theme' ), 1570 $item->language, 1571 $theme->Get( 'Name' ) 1572 ) ); 1573 $item_name = sprintf( 1574 __( '%1$s translation for the %2$s Theme' ), 1575 $item->language, 1576 $theme->Get( 'Name' ) 1577 ); 1578 } elseif ( 'plugin' == $item->type ) { 1579 $plugin_data = get_plugins( '/' . $item->slug ); 1580 $plugin_data = array_shift( $plugin_data ); 1581 $skin->feedback( sprintf( 1582 __( 'Updating the %1$s language files for the %2$s Plugin' ), 1583 $item->language, 1584 $plugin_data['Name'] 1585 ) ); 1586 $item_name = sprintf( 1587 __( '%1$s translation for the %2$s Plugin' ), 1588 $item->language, 1589 $plugin_data['Name'] 1590 ); 1591 } else { 1592 $skin->feedback( sprintf( 1593 __( 'Updating %s translation' ), 1594 $item->language 1595 ) ); 1596 $item_name = sprintf( 1597 __( '%s translation' ), 1598 $item->language 1599 ); 1600 } 1601 1602 break; 1554 1603 } 1555 1604 … … 1594 1643 if ( ! add_site_option( $lock_name, microtime( true ), HOUR_IN_SECONDS / 2 ) ) 1595 1644 return; 1645 1646 // Don't automatically run these thins, as we'll handle it ourselves 1647 remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20, 3 ); 1648 remove_action( 'upgrader_process_complete', 'wp_version_check' ); 1649 remove_action( 'upgrader_process_complete', 'wp_update_plugins' ); 1650 remove_action( 'upgrader_process_complete', 'wp_update_themes' ); 1596 1651 1597 1652 // Next, Plugins … … 1617 1672 } 1618 1673 1619 // Finally, Process any core upgrade1674 // Next, Process any core upgrade 1620 1675 wp_version_check(); // Check for Core updates 1621 1676 $core_update = find_core_auto_update(); … … 1625 1680 } 1626 1681 1627 // Cleanup, These won't trigger any updates this time due to the locking transient1682 // Cleanup, and check for any pending translations 1628 1683 wp_version_check(); // check for Core updates 1629 1684 wp_update_themes(); // Check for Theme updates 1630 1685 wp_update_plugins(); // Check for Plugin updates 1686 1687 // Finally, Process any new translations 1688 $language_updates = wp_get_translation_updates(); 1689 if ( $language_updates ) { 1690 foreach ( $language_updates as $update ) { 1691 self::upgrade( 'language', $update ); 1692 } 1693 // Clear existing caches 1694 wp_clean_plugins_cache(); 1695 wp_clean_themes_cache(); 1696 delete_site_transient( 'update_core' ); 1697 1698 wp_version_check(); // check for Core updates 1699 wp_update_themes(); // Check for Theme updates 1700 wp_update_plugins(); // Check for Plugin updates 1701 } 1631 1702 1632 1703 /** … … 1635 1706 * @since 3.7.0 1636 1707 * 1637 * @param bool Whether or not email should be sent to administrator. Default true. 1638 * @param bool|array $core_update An array of core update data, false otherwise. 1639 * @param object $theme_updates Object containing theme update properties. 1640 * @param object $plugin_updates Object containing plugin update properties. 1641 * @param array $upgrade_results An array of the upgrade results keyed by upgrade type, and plugin/theme slug. 1708 * @param bool Whether or not email should be sent to administrator. Default true. 1709 * @param bool|array $core_update An array of core update data, false otherwise. 1710 * @param object $theme_updates Object containing theme update properties. 1711 * @param object $plugin_updates Object containing plugin update properties. 1712 * @param array $language_updates Array containing the Language updates available. 1713 * @param array $upgrade_results Array of the upgrade results keyed by upgrade type, and plugin/theme slug. 1642 1714 */ 1643 if ( apply_filters( 'enable_auto_upgrade_email', true, $core_update, $theme_updates, $plugin_updates, self::$upgrade_results ) )1715 if ( apply_filters( 'enable_auto_upgrade_email', true, $core_update, $theme_updates, $plugin_updates, $language_updates, self::$upgrade_results ) ) 1644 1716 self::send_email(); 1645 1717 … … 1703 1775 } 1704 1776 1777 // Languages 1778 if ( isset( self::$upgrade_results['language'] ) ) { 1779 $success_languages = wp_list_filter( self::$upgrade_results['language'], array( 'result' => true ) ); 1780 1781 if ( $success_languages ) 1782 $body[] = sprintf( _n( 'The following language file was successfully updated: %s', 'The following language files were successfully updated: %s', count( $success_languages ) ), implode( ', ', wp_list_pluck( $success_languages, 'name' ) ) ); 1783 if ( $success_languages != self::$upgrade_results['language'] ) { 1784 // Failed updates 1785 $failed_languages = array(); 1786 foreach ( self::$upgrade_results['language'] as $language ) { 1787 if ( ! $language->result || is_wp_error( $language->result ) ) 1788 $failed_languages[] = $language; 1789 } 1790 $body[] = sprintf( _n( 'The following language file failed to successfully update: %s', 'The following language files failed to successfully update: %s', count( $failed_languages ) ), implode( ', ', wp_list_pluck( $failed_languages, 'name' ) ) ); 1791 } 1792 } 1793 1705 1794 $body[] = ''; 1706 1795 $body[] = __( 'Below is the upgrade logs for update performed' ); 1707 1796 1708 foreach ( array( 'core', 'plugin', 'theme' ) as $type ) {1797 foreach ( array( 'core', 'plugin', 'theme', 'language' ) as $type ) { 1709 1798 if ( ! isset( self::$upgrade_results[ $type ] ) ) 1710 1799 continue;
Note: See TracChangeset
for help on using the changeset viewer.