Changeset 25859
- Timestamp:
- 10/21/2013 10:28:07 PM (11 years ago)
- Location:
- trunk/src/wp-admin/includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-upgrader-skins.php
r25836 r25859 592 592 */ 593 593 class Automatic_Upgrader_Skin extends WP_Upgrader_Skin { 594 pr ivate$messages = array();594 protected $messages = array(); 595 595 596 596 function request_filesystem_credentials( $error = false, $context = '' ) { -
trunk/src/wp-admin/includes/class-wp-upgrader.php
r25851 r25859 1098 1098 1099 1099 add_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 ); 1100 1101 /** 1102 * Language pack upgrader, for updating translations of plugins, themes, and core. 1103 * 1104 * @package WordPress 1105 * @subpackage Upgrader 1106 * @since 3.7.0 1107 */ 1100 1108 class Language_Pack_Upgrader extends WP_Upgrader { 1101 1109 … … 1569 1577 1570 1578 /** 1571 * WordPress automatic background updater.1579 * The WordPress automatic background updater. 1572 1580 * 1581 * @package WordPress 1582 * @subpackage Upgrader 1573 1583 * @since 3.7.0 1574 1584 */ 1575 1585 class WP_Automatic_Updater { 1576 1586 1587 /** 1588 * Tracks update results during processing. 1589 * 1590 * @var array 1591 */ 1577 1592 protected $update_results = array(); 1578 1593 1579 function is_disabled() { 1594 /** 1595 * Whether the entire automatic updater is disabled. 1596 * 1597 * @since 3.7.0 1598 */ 1599 public function is_disabled() { 1580 1600 // Background updates are disabled if you don't want file changes. 1581 1601 if ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS ) … … 1588 1608 $disabled = defined( 'AUTOMATIC_UPDATER_DISABLED' ) && AUTOMATIC_UPDATER_DISABLED; 1589 1609 1610 /** 1611 * Filter whether to entirely disable background updates. 1612 * 1613 * There are more fine-grained filters and controls for selective disabling. 1614 * This filter parallels the AUTOMATIC_UPDATER_DISABLED constant in name. 1615 * 1616 * @since 3.7.0 1617 * @param bool $disabled Whether the updater should be disabled. 1618 */ 1590 1619 return apply_filters( 'automatic_updater_disabled', $disabled ); 1591 1620 } 1592 1621 1593 1622 /** 1594 * Check for GIT/SVN checkouts. 1623 * Check for version control checkouts. 1624 * 1625 * Checks for Subversion, Git, Mercurial, and Bazaar. It recursively looks up the 1626 * filesystem to the top of the drive, erring on the side of detecting a VCS 1627 * checkout somewhere. 1628 * 1629 * ABSPATH is always checked in addition to whatever $context is (which may be the 1630 * wp-content directory, for example). The underlying assumption is that if you are 1631 * using version control *anywhere*, then you should be making decisions for 1632 * how things get updated. 1633 * 1634 * @since 3.7.0 1635 * 1636 * @param string $context The filesystem path to check, in addition to ABSPATH. 1595 1637 */ 1596 function is_vcs_checkout( $context ) {1638 public function is_vcs_checkout( $context ) { 1597 1639 $context_dirs = array( untrailingslashit( $context ) ); 1598 1640 if ( $context !== ABSPATH ) … … 1606 1648 do { 1607 1649 $check_dirs[] = $context_dir; 1608 } while ( $context_dir != dirname( $context_dir ) && $context_dir = dirname( $context_dir ) ); 1650 1651 // Once we've hit '/' or 'C:\', we need to stop. dirname will keep returning the input here. 1652 if ( $context_dir == dirname( $context_dir ) ) 1653 break; 1654 1655 // Continue one level at a time. 1656 } while ( $context_dir = dirname( $context_dir ) ); 1609 1657 } 1610 1658 … … 1618 1666 } 1619 1667 } 1668 1669 /** 1670 * Filter whether the automatic updater should consider a filesystem location to be potentially 1671 * managed by a version control system. 1672 * 1673 * @since 3.7.0 1674 * 1675 * @param bool $checkout Whether a VCS checkout was discovered at $context or ABSPATH, or anywhere higher. 1676 * @param string $context The filesystem context (a path) against which filesystem status should be checked. 1677 */ 1620 1678 return apply_filters( 'automatic_updates_is_vcs_checkout', $checkout, $context ); 1621 1679 } … … 1623 1681 /** 1624 1682 * Tests to see if we can and should update a specific item. 1683 * 1684 * @since 3.7.0 1685 * 1686 * @param string $type The type of update being checked: 'core', 'theme', 'plugin', 'translation'. 1687 * @param object $item The update offer. 1688 * @param string $context The filesystem context (a path) against which filesystem access and status 1689 * should be checked. 1625 1690 */ 1626 function should_update( $type, $item, $context ) {1691 public function should_update( $type, $item, $context ) { 1627 1692 if ( $this->is_disabled() ) 1628 1693 return false; … … 1642 1707 $update = ! empty( $item->autoupdate ); 1643 1708 1644 // And does the user / plugins want it? 1645 // Plugins may filter on 'auto_update_plugin', and check the 2nd param, $item, to only enable it for certain Plugins/Themes 1709 /** 1710 * Filter whether to automatically update core, a plugin, a theme, or a language. 1711 * 1712 * The dynamic portion of the hook name, $type, refers to the type of update 1713 * being checked. Can be 'core', 'theme', 'plugin', or 'translation'. 1714 * 1715 * Generally speaking, plugins, themes, and major core versions are not updated by default, 1716 * while translations and minor and development versions for core are updated by default. 1717 * 1718 * See the filters allow_dev_auto_core_updates, allow_minor_auto_core_updates, and 1719 * allow_major_auto_core_updates more straightforward filters to adjust core updates. 1720 * 1721 * @since 3.7.0 1722 * 1723 * @param bool $update Whether to update. 1724 * @param object $item The update offer. 1725 */ 1646 1726 $update = apply_filters( 'auto_update_' . $type, $update, $item ); 1647 1727 … … 1680 1760 } 1681 1761 1682 function update( $type, $item ) { 1683 1762 /** 1763 * Update an item, if appropriate. 1764 * 1765 * @since 3.7.0 1766 * 1767 * @param string $type The type of update being checked: 'core', 'theme', 'plugin', 'translation'. 1768 * @param object $item The update offer. 1769 */ 1770 public function update( $type, $item ) { 1684 1771 $skin = new Automatic_Upgrader_Skin; 1685 1772 … … 1699 1786 $context = get_theme_root( $item ); 1700 1787 break; 1701 case ' language':1788 case 'translation': 1702 1789 $upgrader = new Language_Pack_Upgrader( $skin ); 1703 1790 $context = WP_CONTENT_DIR; // WP_LANG_DIR; … … 1724 1811 $skin->feedback( __( 'Updating plugin: %s' ), $item_name ); 1725 1812 break; 1726 case ' language':1813 case 'translation': 1727 1814 $language_item_name = $upgrader->get_name_for_update( $item ); 1728 1815 $item_name = sprintf( __( 'Translations for %s' ), $language_item_name ); … … 1758 1845 1759 1846 /** 1760 * Kicks off a update request for each item in the update "queue". 1847 * Kicks off the background update process, looping through all pending updates. 1848 * 1849 * @since 3.7.0 1761 1850 */ 1762 function run() {1851 public function run() { 1763 1852 global $wpdb, $wp_version; 1764 1853 … … 1851 1940 if ( $language_updates ) { 1852 1941 foreach ( $language_updates as $update ) { 1853 $this->update( ' language', $update );1942 $this->update( 'translation', $update ); 1854 1943 } 1855 1944 … … 1867 1956 if ( ! empty( $this->update_results ) ) { 1868 1957 $development_version = false !== strpos( $wp_version, '-' ); 1958 /** 1959 * Filter whether to send a debugging email for each automatic background update. 1960 * 1961 * @since 3.7.0 1962 * @param bool $development_version By default, emails are sent if the install is a development version. 1963 * Return false to avoid the email. 1964 */ 1869 1965 if ( apply_filters( 'automatic_updates_send_debug_email', $development_version ) ) 1870 1966 $this->send_debug_email(); … … 1881 1977 * If we tried to perform a core update, check if we should send an email, 1882 1978 * and if we need to avoid processing future updates. 1979 * 1980 * @param object $update_result The result of the core update. Includes the update offer and result. 1883 1981 */ 1884 1982 protected function after_core_update( $update_result ) { … … 1957 2055 } 1958 2056 2057 /** 2058 * Sends an email upon the completion or failure of a background core update. 2059 * 2060 * @since 3.7.0 2061 * 2062 * @param string $type The type of update being checked: 'core', 'theme', 'plugin', 'translation'. 2063 * @param object $core_update The update offer that was attempted. 2064 * @param mixed $result Optional. The result for the core update. Can be WP_Error. 2065 */ 1959 2066 protected function send_email( $type, $core_update, $result = null ) { 1960 2067 update_site_option( 'auto_core_update_notified', array( … … 1965 2072 ) ); 1966 2073 1967 if ( ! apply_filters( 'automatic_updates_send_email', true, $type, $core_update, $result ) ) 2074 /** 2075 * Filter whether to send an email following an automatic background core update. 2076 * 2077 * @since 3.7.0 2078 * 2079 * @param bool $send Whether to send the email. Default true. 2080 * @param string $type The type of email to send. Can be one of 'success', 'fail', 'manual', 'critical'. 2081 * @param object $core_update The update offer that was attempted. 2082 * @param mixed $result The result for the core update. Can be WP_Error. 2083 */ 2084 if ( ! apply_filters( 'auto_core_update_send_email', true, $type, $core_update, $result ) ) 1968 2085 return; 1969 2086 … … 2056 2173 $headers = ''; 2057 2174 2058 $email = compact( 'to', 'body', 'subject', 'headers' ); 2059 $email = apply_filters( 'automatic_update_send_email', $email, $type, $core_update, $result ); 2175 $email = compact( 'to', 'subject', 'body', 'headers' ); 2176 /** 2177 * Filter the email sent following an automatic background core update. 2178 * 2179 * @since 3.7.0 2180 * 2181 * @param array $email { 2182 * Array of email arguments that will be passed to wp_mail(). 2183 * 2184 * @type string $to The email recipient. An array of emails can be returned, as handled by wp_mail(). 2185 * @type string $subject The email's subject. 2186 * @type string $body The email message body. 2187 * @type string $headers Any email headers, defaults to no headers. 2188 * } 2189 * @param string $type The type of email being sent. Can be one of 'success', 'fail', 'manual', 'critical'. 2190 * @param object $core_update The update offer that was attempted. 2191 * @param mixed $result The result for the core update. Can be WP_Error. 2192 */ 2193 $email = apply_filters( 'auto_core_update_email', $email, $type, $core_update, $result ); 2060 2194 2061 2195 wp_mail( $email['to'], $email['subject'], $email['body'], $email['headers'] ); 2062 2196 } 2063 2197 2198 /** 2199 * Prepares and sends an email of a full log of background update results, useful for debugging and geekery. 2200 * 2201 * @since 3.7.0 2202 */ 2064 2203 protected function send_debug_email() { 2065 2204 $update_count = 0; … … 2084 2223 } 2085 2224 2086 // Plugins, Themes, Languages2087 foreach ( array( 'plugin', 'theme', ' language' ) as $type ) {2225 // Plugins, Themes, Translations 2226 foreach ( array( 'plugin', 'theme', 'translation' ) as $type ) { 2088 2227 if ( ! isset( $this->update_results[ $type ] ) ) 2089 2228 continue; … … 2129 2268 $body[] = ''; 2130 2269 2131 foreach ( array( 'core', 'plugin', 'theme', ' language' ) as $type ) {2270 foreach ( array( 'core', 'plugin', 'theme', 'translation' ) as $type ) { 2132 2271 if ( ! isset( $this->update_results[ $type ] ) ) 2133 2272 continue;
Note: See TracChangeset
for help on using the changeset viewer.