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 |
---|---|
637 | * @param string $to Path to old WordPress installation. |
638 | * @return WP_Error|null WP_Error on failure, null on success. |
639 | */ |
640 | function update_core($from, $to) { |
641 | global $wp_filesystem, $_old_files, $_new_bundled_files, $wpdb; |
642 |
|
643 | @set_time_limit( 300 ); |
644 |
|
645 | // Sanity check the unzipped distribution |
646 | apply_filters( 'update_feedback', __('Verifying the unpacked files…') ); |
647 | $distro = ''; |
648 | $roots = array( '/wordpress/', '/wordpress-mu/' ); |
649 | foreach ( $roots as $root ) { |
650 | if ( $wp_filesystem->exists( $from . $root . 'readme.html' ) && $wp_filesystem->exists( $from . $root . 'wp-includes/version.php' ) ) { |
651 | $distro = $root; |
652 | break; |
653 | } |
654 | } |
655 | if ( ! $distro ) { |
Line | Code |
683 | $wp_filesystem->delete($from, true); |
684 |
|
685 | if ( !$mysql_compat && !$php_compat ) |
686 | 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 ) ); |
687 | elseif ( !$php_compat ) |
688 | 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 ) ); |
689 | elseif ( !$mysql_compat ) |
690 | 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 ) ); |
691 |
|
692 | apply_filters( 'update_feedback', __( 'Preparing to install the latest version…' ) ); |
693 |
|
694 | // Don't copy wp-content, we'll deal with that below |
695 | $skip = array( 'wp-content' ); |
696 | $check_is_writable = array(); |
697 |
|
698 | // Check to see which files don't really need updating - only available for 3.7 and higher |
699 | if ( function_exists( 'get_core_checksums' ) ) { |
700 | $checksums = get_core_checksums( $wp_version, isset( $wp_local_package ) ? $wp_local_package : 'en_US' ); |
701 | if ( is_array( $checksums ) && isset( $checksums[ $wp_version ] ) ) |
Line | Code |
728 |
|
729 | // Store package-relative paths (the key) of non-writable files in the WP_Error object. |
730 | $error_data = version_compare( $old_wp_version, '3.7-beta2', '>' ) ? array_keys( $files_not_writable ) : ''; |
731 |
|
732 | if ( $files_not_writable ) |
733 | 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 ) ); |
734 | } |
735 | } |
736 |
|
737 | apply_filters( 'update_feedback', __( 'Enabling Maintenance mode…' ) ); |
738 | // Create maintenance file to signal that we are upgrading |
739 | $maintenance_string = '<?php $upgrading = ' . time() . '; ?>'; |
740 | $maintenance_file = $to . '.maintenance'; |
741 | $wp_filesystem->delete($maintenance_file); |
742 | $wp_filesystem->put_contents($maintenance_file, $maintenance_string, FS_CHMOD_FILE); |
743 |
|
744 | apply_filters( 'update_feedback', __( 'Copying the required files…' ) ); |
745 | // Copy new versions of WP files into place. |
746 | $result = _copy_dir( $from . $distro, $to, $skip ); |
747 | if ( is_wp_error( $result ) ) |
748 | $result = new WP_Error( $result->get_error_code(), $result->get_error_message(), substr( $result->get_error_data(), strlen( $to ) ) ); |
749 |
|
750 | // Check to make sure everything copied correctly, ignoring the contents of wp-content |
751 | $skip = array( 'wp-content' ); |
752 | $failed = array(); |
753 | if ( is_array( $checksums ) ) { |
Line | Code |
801 | $wp_lang_dir = $wp_filesystem->find_folder($lang_dir); |
802 | if ( $wp_lang_dir ) { |
803 | $result = copy_dir($from . $distro . 'wp-content/languages/', $wp_lang_dir); |
804 | if ( is_wp_error( $result ) ) |
805 | $result = new WP_Error( $result->get_error_code() . '_languages', $result->get_error_message(), substr( $result->get_error_data(), strlen( $wp_lang_dir ) ) ); |
806 | } |
807 | } |
808 | } |
809 |
|
810 | apply_filters( 'update_feedback', __( 'Disabling Maintenance mode…' ) ); |
811 | // Remove maintenance file, we're done with potential site-breaking changes |
812 | $wp_filesystem->delete( $maintenance_file ); |
813 |
|
814 | // 3.5 -> 3.5+ - an empty twentytwelve directory was created upon upgrade to 3.5 for some users, preventing installation of Twenty Twelve. |
815 | if ( '3.5' == $old_wp_version ) { |
816 | if ( is_dir( WP_CONTENT_DIR . '/themes/twentytwelve' ) && ! file_exists( WP_CONTENT_DIR . '/themes/twentytwelve/style.css' ) ) { |
817 | $wp_filesystem->delete( $wp_filesystem->wp_themes_dir() . 'twentytwelve/' ); |
818 | } |
819 | } |
Line | Code |
872 | // Remove old files |
873 | foreach ( $_old_files as $old_file ) { |
874 | $old_file = $to . $old_file; |
875 | if ( !$wp_filesystem->exists($old_file) ) |
876 | continue; |
877 | $wp_filesystem->delete($old_file, true); |
878 | } |
879 |
|
880 | // Upgrade DB with separate request |
881 | apply_filters('update_feedback', __('Upgrading database…')); |
882 | $db_upgrade_url = admin_url('upgrade.php?step=upgrade_db'); |
883 | wp_remote_post($db_upgrade_url, array('timeout' => 60)); |
884 |
|
885 | // Remove working directory |
886 | $wp_filesystem->delete($from, true); |
887 |
|
888 | // Force refresh of update information |
889 | if ( function_exists('delete_site_transient') ) |
890 | delete_site_transient('update_core'); |