当前位置: 首页>>代码示例>>PHP>>正文


PHP get_core_checksums函数代码示例

本文整理汇总了PHP中get_core_checksums函数的典型用法代码示例。如果您正苦于以下问题:PHP get_core_checksums函数的具体用法?PHP get_core_checksums怎么用?PHP get_core_checksums使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_core_checksums函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update_core


//.........这里部分代码省略.........
    }
    $wp_filesystem->chmod($versions_file, FS_CHMOD_FILE);
    require WP_CONTENT_DIR . '/upgrade/version-current.php';
    $wp_filesystem->delete($versions_file);
    $php_version = phpversion();
    $mysql_version = $wpdb->db_version();
    $old_wp_version = $wp_version;
    // The version of WordPress we're updating from
    $development_build = false !== strpos($old_wp_version . $wp_version, '-');
    // a dash in the version indicates a Development release
    $php_compat = version_compare($php_version, $required_php_version, '>=');
    if (file_exists(WP_CONTENT_DIR . '/db.php') && empty($wpdb->is_mysql)) {
        $mysql_compat = true;
    } else {
        $mysql_compat = version_compare($mysql_version, $required_mysql_version, '>=');
    }
    if (!$mysql_compat || !$php_compat) {
        $wp_filesystem->delete($from, true);
    }
    if (!$mysql_compat && !$php_compat) {
        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));
    } elseif (!$php_compat) {
        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));
    } elseif (!$mysql_compat) {
        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));
    }
    /** This filter is documented in wp-admin/includes/update-core.php */
    apply_filters('update_feedback', __('Preparing to install the latest version…'));
    // Don't copy wp-content, we'll deal with that below
    // We also copy version.php last so failed updates report their old version
    $skip = array('wp-content', 'wp-includes/version.php');
    $check_is_writable = array();
    // Check to see which files don't really need updating - only available for 3.7 and higher
    if (function_exists('get_core_checksums')) {
        // Find the local version of the working directory
        $working_dir_local = WP_CONTENT_DIR . '/upgrade/' . basename($from) . $distro;
        $checksums = get_core_checksums($wp_version, isset($wp_local_package) ? $wp_local_package : 'en_US');
        if (is_array($checksums) && isset($checksums[$wp_version])) {
            $checksums = $checksums[$wp_version];
        }
        // Compat code for 3.7-beta2
        if (is_array($checksums)) {
            foreach ($checksums as $file => $checksum) {
                if ('wp-content' == substr($file, 0, 10)) {
                    continue;
                }
                if (!file_exists(ABSPATH . $file)) {
                    continue;
                }
                if (!file_exists($working_dir_local . $file)) {
                    continue;
                }
                if (md5_file(ABSPATH . $file) === $checksum) {
                    $skip[] = $file;
                } else {
                    $check_is_writable[$file] = ABSPATH . $file;
                }
            }
        }
    }
    // If we're using the direct method, we can predict write failures that are due to permissions.
    if ($check_is_writable && 'direct' === $wp_filesystem->method) {
        $files_writable = array_filter($check_is_writable, array($wp_filesystem, 'is_writable'));
        if ($files_writable !== $check_is_writable) {
            $files_not_writable = array_diff_key($check_is_writable, $files_writable);
            foreach ($files_not_writable as $relative_file_not_writable => $file_not_writable) {
开发者ID:rlgod,项目名称:WordPress,代码行数:67,代码来源:update-core.php

示例2: check_files

 function check_files()
 {
     global $wp_version;
     $checksums = get_core_checksums($wp_version);
     if (empty($checksums[$wp_version]) || !is_array($checksums[$wp_version])) {
         return false;
     }
     foreach ($checksums[$wp_version] as $file => $checksum) {
         // Skip files which get updated
         if ('wp-content' == substr($file, 0, 10)) {
             continue;
         }
         if (!file_exists(ABSPATH . $file) || md5_file(ABSPATH . $file) !== $checksum) {
             return false;
         }
     }
     return true;
 }
开发者ID:openify,项目名称:wordpress-composer,代码行数:18,代码来源:class-wp-upgrader.php

示例3: check_files

 /**
  * Compare the disk file checksums agains the expected checksums.
  *
  * @since 3.7.0
  *
  * @return bool True if the checksums match, otherwise false.
  */
 public function check_files()
 {
     global $wp_version, $wp_local_package;
     $checksums = get_core_checksums($wp_version, isset($wp_local_package) ? $wp_local_package : 'en_US');
     if (!is_array($checksums)) {
         return false;
     }
     foreach ($checksums as $file => $checksum) {
         // Skip files which get updated
         if ('wp-content' == substr($file, 0, 10)) {
             continue;
         }
         if (!file_exists(ABSPATH . $file) || md5_file(ABSPATH . $file) !== $checksum) {
             return false;
         }
     }
     return true;
 }
开发者ID:sunyang3721,项目名称:wp-for-sae,代码行数:25,代码来源:class-wp-upgrader.php

示例4: update_core


//.........这里部分代码省略.........
    if (!$wp_filesystem->copy($from . $distro . 'wp-includes/version.php', $versions_file)) {
        $wp_filesystem->delete($from, true);
        return new WP_Error('copy_failed', __('Could not copy file.'));
    }
    $wp_filesystem->chmod($versions_file, FS_CHMOD_FILE);
    require WP_CONTENT_DIR . '/upgrade/version-current.php';
    $wp_filesystem->delete($versions_file);
    $php_version = phpversion();
    $mysql_version = $wpdb->db_version();
    $old_wp_version = $GLOBALS['wp_version'];
    // The version of WordPress we're updating from
    $development_build = false !== strpos($old_wp_version . $wp_version, '-');
    // a dash in the version indicates a Development release
    $php_compat = version_compare($php_version, $required_php_version, '>=');
    if (file_exists(WP_CONTENT_DIR . '/db.php') && empty($wpdb->is_mysql)) {
        $mysql_compat = true;
    } else {
        $mysql_compat = version_compare($mysql_version, $required_mysql_version, '>=');
    }
    if (!$mysql_compat || !$php_compat) {
        $wp_filesystem->delete($from, true);
    }
    if (!$mysql_compat && !$php_compat) {
        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));
    } elseif (!$php_compat) {
        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));
    } elseif (!$mysql_compat) {
        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));
    }
    apply_filters('update_feedback', __('Preparing to install the latest version…'));
    // Don't copy wp-content, we'll deal with that below
    $skip = array('wp-content');
    // Check to see which files don't really need updating - only available for 3.7 and higher
    if (function_exists('get_core_checksums')) {
        $checksums = get_core_checksums($wp_version);
        if (!empty($checksums[$wp_version]) && is_array($checksums[$wp_version])) {
            foreach ($checksums[$wp_version] as $file => $checksum) {
                if ('wp-content' == substr($file, 0, 10)) {
                    continue;
                }
                if (file_exists(ABSPATH . $file) && md5_file(ABSPATH . $file) === $checksum) {
                    $skip[] = $file;
                }
            }
        }
    }
    apply_filters('update_feedback', __('Enabling Maintenance mode…'));
    // Create maintenance file to signal that we are upgrading
    $maintenance_string = '<?php $upgrading = ' . time() . '; ?>';
    $maintenance_file = $to . '.maintenance';
    $wp_filesystem->delete($maintenance_file);
    $wp_filesystem->put_contents($maintenance_file, $maintenance_string, FS_CHMOD_FILE);
    apply_filters('update_feedback', __('Copying the required files&#8230;'));
    // Copy new versions of WP files into place.
    $result = _copy_dir($from . $distro, $to, $skip);
    // Check to make sure everything copied correctly, ignoring the contents of wp-content
    $skip = array('wp-content');
    $failed = array();
    if (!empty($checksums[$wp_version]) && is_array($checksums[$wp_version])) {
        foreach ($checksums[$wp_version] as $file => $checksum) {
            if (0 === strpos($file, 'wp-content')) {
                continue;
            }
            if (md5_file(ABSPATH . $file) == $checksum) {
                $skip[] = $file;
            } else {
开发者ID:openify,项目名称:wordpress-composer,代码行数:67,代码来源:update-core.php


注:本文中的get_core_checksums函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。