| @@ -16,10 +16,10 @@ | ||
| 16 | 16 | * Constructor |
| 17 | 17 | * return void |
| 18 | 18 | */ |
| 19 | 19 | public function __construct() { |
| 20 | - add_action( 'wp_enqueue_scripts', [ $this, 'fonts_loader' ] ); | |
| 21 | - add_action( 'admin_enqueue_scripts', [ $this, 'fonts_loader' ] ); | |
| 20 | + add_action( 'wp_enqueue_scripts', [ $this, 'fonts_loader' ], 10); | |
| 21 | + add_action( 'admin_enqueue_scripts', [ $this, 'fonts_loader' ], 10 ); | |
| 22 | 22 | add_action('gutsliders_render_block', [ $this, 'font_generator' ]); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
| @@ -34,8 +34,10 @@ | ||
| 34 | 34 | if ( ! empty( $value ) && strpos( $key, 'gutsliders_' ) === 0 && strpos( $key, 'FontFamily' ) !== false ) { |
| 35 | 35 | self::$all_fonts[] = $value; |
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | + | |
| 39 | + $this->fonts_loader(); | |
| 38 | 40 | } |
| 39 | 41 | } |
| 40 | 42 | |
| 41 | 43 | /** |
| @@ -67,22 +69,30 @@ | ||
| 67 | 69 | $gfonts .= str_replace( ' ', '+', trim( $font ) ) . $gfonts_attr . '|'; |
| 68 | 70 | } |
| 69 | 71 | } |
| 70 | 72 | |
| 71 | - if ( ! empty( $gfonts ) ) { | |
| 73 | + if (!empty($gfonts)) { | |
| 74 | + $font_array = explode('|', $gfonts); | |
| 75 | + | |
| 76 | + foreach ($font_array as $font) { | |
| 77 | + if (empty($font)) { | |
| 78 | + continue; | |
| 79 | + } | |
| 72 | 80 | |
| 73 | - $query_args = [ 'family' => $gfonts ]; | |
| 74 | - | |
| 75 | - wp_register_style( | |
| 76 | - 'gutsliders-fonts', | |
| 77 | - add_query_arg( $query_args, '//fonts.googleapis.com/css' ), | |
| 78 | - [], | |
| 79 | - GUTSLIDER_VERSION, | |
| 80 | - 'all' | |
| 81 | - ); | |
| 82 | - | |
| 83 | - wp_enqueue_style( 'gutsliders-fonts', false, [], GUTSLIDER_VERSION, 'all' ); | |
| 84 | - } | |
| 81 | + $query_args = ['family' => $font]; | |
| 82 | + $font_handle = 'gutsliders-font-' . sanitize_title($font); | |
| 83 | + | |
| 84 | + wp_register_style( | |
| 85 | + $font_handle, | |
| 86 | + add_query_arg($query_args, '//fonts.googleapis.com/css'), | |
| 87 | + [], | |
| 88 | + GUTSLIDER_VERSION, | |
| 89 | + 'all' | |
| 90 | + ); | |
| 91 | + | |
| 92 | + wp_enqueue_style($font_handle); | |
| 93 | + } | |
| 94 | + } | |
| 85 | 95 | |
| 86 | 96 | // Reset. |
| 87 | 97 | $gfonts = ''; |
| 88 | 98 | } |