wp_update_https_migration_required

函数
wp_update_https_migration_required ( $old_url, $new_url )
Access
Private
参数
  • (mixed) $old_url Previous value of the URL option.
    Required:
  • (mixed) $new_url New value of the URL option.
    Required:
定义位置
相关方法
wp_update_https_detection_errorswp_get_update_https_urlwp_update_php_annotationwp_update_sitewp_get_direct_update_https_url
引入
5.7.0
弃用
-

wp_update_https_migration_required是一个函数,用于更新WordPress网站的HTTPS迁移所需状态: 该函数通过添加或更新WordPress数据库中的https_migration_required选项来更新HTTPS迁移所需状态。这个选项用来存储一个网站是否需要迁移到HTTPS以实现完全安全的信息。

如果需要,当给定的URL从HTTP更新到HTTPS时,更新’https_migration_required’选项。
如果这是一个新的网站,将不需要迁移,所以该选项将被设置为`false`。

这是与{@see ‘update_option_home’}动作挂钩的。

function wp_update_https_migration_required( $old_url, $new_url ) {
	// Do nothing if WordPress is being installed.
	if ( wp_installing() ) {
		return;
	}

	// Delete/reset the option if the new URL is not the HTTPS version of the old URL.
	if ( untrailingslashit( (string) $old_url ) !== str_replace( 'https://', 'http://', untrailingslashit( (string) $new_url ) ) ) {
		delete_option( 'https_migration_required' );
		return;
	}

	// If this is a fresh site, there is no content to migrate, so do not require migration.
	$https_migration_required = get_option( 'fresh_site' ) ? false : true;

	update_option( 'https_migration_required', $https_migration_required );
}

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2025-12-05 19:32:59

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: