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’}動作掛鉤的。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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 );
}
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 ); }
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
檢視更多 >