WP hooks navigation: Home/browse • Actions index • Filters index
To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).
The best way to understand what a hook does is to look at where it occurs in the source code.
do_action( "hook_name" )
apply_filters( "hook_name", "what_to_filter" )
.Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.
This hook occurs 6 times in this file.
Line | Code |
---|---|
787 | * 2. Before Maintenance Mode is enabled. |
788 | * 3. Before WordPress begins copying over the necessary files. |
789 | * 4. Before Maintenance Mode is disabled. |
790 | * 5. Before the database is upgraded. |
791 | * |
792 | * @since 2.5.0 |
793 | * |
794 | * @param string $feedback The core update feedback messages. |
795 | */ |
796 | apply_filters( 'update_feedback', __( 'Verifying the unpacked files…' ) ); |
797 |
|
798 | // Sanity check the unzipped distribution. |
799 | $distro = ''; |
800 | $roots = array( '/wordpress/', '/wordpress-mu/' ); |
801 | foreach ( $roots as $root ) { |
802 | if ( $wp_filesystem->exists( $from . $root . 'readme.html' ) && $wp_filesystem->exists( $from . $root . 'wp-includes/version.php' ) ) { |
803 | $distro = $root; |
804 | break; |
805 | } |
Line | Code |
836 |
|
837 | if ( !$mysql_compat && !$php_compat ) |
838 | return new WP_Error( 'php_mysql_not_compatible', sprintf( __('The update cannot be installed because WordPress %1$s requires PHP version %2$s or higher and MySQL version %3$s or higher. You are running PHP version %4$s and MySQL version %5$s.'), $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version ) ); |
839 | elseif ( !$php_compat ) |
840 | return new WP_Error( 'php_not_compatible', sprintf( __('The update cannot be installed because WordPress %1$s requires PHP version %2$s or higher. You are running version %3$s.'), $wp_version, $required_php_version, $php_version ) ); |
841 | elseif ( !$mysql_compat ) |
842 | return new WP_Error( 'mysql_not_compatible', sprintf( __('The update cannot be installed because WordPress %1$s requires MySQL version %2$s or higher. You are running version %3$s.'), $wp_version, $required_mysql_version, $mysql_version ) ); |
843 |
|
844 | /** This filter is documented in wp-admin/includes/update-core.php */ |
845 | apply_filters( 'update_feedback', __( 'Preparing to install the latest version…' ) ); |
846 |
|
847 | // Don't copy wp-content, we'll deal with that below |
848 | // We also copy version.php last so failed updates report their old version |
849 | $skip = array( 'wp-content', 'wp-includes/version.php' ); |
850 | $check_is_writable = array(); |
851 |
|
852 | // Check to see which files don't really need updating - only available for 3.7 and higher |
853 | if ( function_exists( 'get_core_checksums' ) ) { |
854 | // Find the local version of the working directory |
Line | Code |
888 | // Store package-relative paths (the key) of non-writable files in the WP_Error object. |
889 | $error_data = version_compare( $old_wp_version, '3.7-beta2', '>' ) ? array_keys( $files_not_writable ) : ''; |
890 |
|
891 | if ( $files_not_writable ) |
892 | return new WP_Error( 'files_not_writable', __( 'The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.' ), implode( ', ', $error_data ) ); |
893 | } |
894 | } |
895 |
|
896 | /** This filter is documented in wp-admin/includes/update-core.php */ |
897 | apply_filters( 'update_feedback', __( 'Enabling Maintenance mode…' ) ); |
898 | // Create maintenance file to signal that we are upgrading |
899 | $maintenance_string = '<?php $upgrading = ' . time() . '; ?>'; |
900 | $maintenance_file = $to . '.maintenance'; |
901 | $wp_filesystem->delete($maintenance_file); |
902 | $wp_filesystem->put_contents($maintenance_file, $maintenance_string, FS_CHMOD_FILE); |
903 |
|
904 | /** This filter is documented in wp-admin/includes/update-core.php */ |
905 | apply_filters( 'update_feedback', __( 'Copying the required files…' ) ); |
906 | // Copy new versions of WP files into place. |
907 | $result = _copy_dir( $from . $distro, $to, $skip ); |
908 | if ( is_wp_error( $result ) ) |
909 | $result = new WP_Error( $result->get_error_code(), $result->get_error_message(), substr( $result->get_error_data(), strlen( $to ) ) ); |
910 |
|
911 | // Since we know the core files have copied over, we can now copy the version file |
912 | if ( ! is_wp_error( $result ) ) { |
913 | if ( ! $wp_filesystem->copy( $from . $distro . 'wp-includes/version.php', $to . 'wp-includes/version.php', true /* overwrite */ ) ) { |
914 | $wp_filesystem->delete( $from, true ); |
Line | Code |
971 | if ( $wp_lang_dir ) { |
972 | $result = copy_dir($from . $distro . 'wp-content/languages/', $wp_lang_dir); |
973 | if ( is_wp_error( $result ) ) |
974 | $result = new WP_Error( $result->get_error_code() . '_languages', $result->get_error_message(), substr( $result->get_error_data(), strlen( $wp_lang_dir ) ) ); |
975 | } |
976 | } |
977 | } |
978 |
|
979 | /** This filter is documented in wp-admin/includes/update-core.php */ |
980 | apply_filters( 'update_feedback', __( 'Disabling Maintenance mode…' ) ); |
981 | // Remove maintenance file, we're done with potential site-breaking changes |
982 | $wp_filesystem->delete( $maintenance_file ); |
983 |
|
984 | // 3.5 -> 3.5+ - an empty twentytwelve directory was created upon upgrade to 3.5 for some users, preventing installation of Twenty Twelve. |
985 | if ( '3.5' == $old_wp_version ) { |
986 | if ( is_dir( WP_CONTENT_DIR . '/themes/twentytwelve' ) && ! file_exists( WP_CONTENT_DIR . '/themes/twentytwelve/style.css' ) ) { |
987 | $wp_filesystem->delete( $wp_filesystem->wp_themes_dir() . 'twentytwelve/' ); |
988 | } |
989 | } |
Line | Code |
1043 | foreach ( $_old_files as $old_file ) { |
1044 | $old_file = $to . $old_file; |
1045 | if ( !$wp_filesystem->exists($old_file) ) |
1046 | continue; |
1047 | $wp_filesystem->delete($old_file, true); |
1048 | } |
1049 |
|
1050 | // Upgrade DB with separate request |
1051 | /** This filter is documented in wp-admin/includes/update-core.php */ |
1052 | apply_filters( 'update_feedback', __( 'Upgrading database…' ) ); |
1053 | $db_upgrade_url = admin_url('upgrade.php?step=upgrade_db'); |
1054 | wp_remote_post($db_upgrade_url, array('timeout' => 60)); |
1055 |
|
1056 | // Clear the cache to prevent an update_option() from saving a stale db_version to the cache |
1057 | wp_cache_flush(); |
1058 | // (Not all cache backends listen to 'flush') |
1059 | wp_cache_delete( 'alloptions', 'options' ); |
1060 |
|
1061 | // Remove working directory |