瀏覽代碼

Ensure that the action only runs once

Jeremy Yip 3 年之前
父節點
當前提交
f4428e110a
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      blockbase/inc/customizer/wp-customize-fonts.php

+ 5 - 1
blockbase/inc/customizer/wp-customize-fonts.php

@@ -4,7 +4,11 @@ require_once( __DIR__ . '/wp-customize-global-styles-setting.php' );
 require_once( __DIR__ . '/wp-customize-utils.php' );
 
 add_action( 'init', function() {
-	// TODO: Ensure this is only run once
+	if ( get_option( 'blockbase_custom_fonts_data_migrated' ) ) {
+		return;
+	}
+	add_option( 'blockbase_custom_fonts_data_migrated', 1 );
+	
 	$font_settings = wp_get_global_settings( array( 'typography', 'fontFamilies' ) );
 
 	if ( ! isset( $font_settings['custom'] ) || ! is_array( $font_settings['custom'] ) ) {