Plugin Directory

Changeset 2009195


Ignore:
Timestamp:
01/09/2019 03:21:04 PM (7 years ago)
Author:
vlad.olaru
Message:

Fixed Gutenberg Editor fonts

Location:
customify/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • customify/trunk/class-pixcustomify.php

    r1990988 r2009195  
    938938            ob_start();
    939939            ?>
    940               if (typeof WebFont !== 'undefined') {<?php // if there is a WebFont object, use it ?>
    941                 WebFont.load({
    942                   google: {families: [<?php echo( rtrim( $families, ',' ) ); ?>]},
    943                   classes: false,
    944                   events: false
    945                 });
    946               } else {<?php // basically when we don't have the WebFont object we create the google script dynamically  ?>
    947 
    948                 var tk = document.createElement('script');
    949                 tk.src = '//ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
    950                 tk.type = 'text/javascript';
    951 
    952                 tk.onload = tk.onreadystatechange = function () {
    953                   WebFont.load({
    954                     google: {families: [<?php echo( rtrim( $families, ',' ) ); ?>]},
    955                     classes: false,
    956                     events: false
    957                   });
    958                 };
    959 
    960                 var s = document.getElementsByTagName('script')[0];
    961                 s.parentNode.insertBefore(tk, s);
    962               }
    963         <?php
     940if (typeof WebFont !== 'undefined') {<?php // if there is a WebFont object, use it ?>
     941    WebFont.load({
     942        google: {families: [<?php echo( rtrim( $families, ',' ) ); ?>]},
     943        classes: false,
     944        events: false
     945    });
     946} else {<?php // basically when we don't have the WebFont object we create the google script dynamically  ?>
     947
     948    var tk = document.createElement('script');
     949    tk.src = '//ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
     950    tk.type = 'text/javascript';
     951
     952    tk.onload = tk.onreadystatechange = function () {
     953        WebFont.load({
     954            google: {families: [<?php echo( rtrim( $families, ',' ) ); ?>]},
     955            classes: false,
     956            events: false
     957        });
     958    };
     959
     960    var s = document.getElementsByTagName('script')[0];
     961    s.parentNode.insertBefore(tk, s);
     962}<?php
    964963            $output = ob_get_clean();
    965964        }
  • customify/trunk/customify.php

    r1990988 r2009195  
    44Plugin URI:  https://wordpress.org/plugins/customify/
    55Description: A Theme Customizer Booster
    6 Version: 2.3.2
     6Version: 2.3.3
    77Author: Pixelgrade
    88Author URI: https://pixelgrade.com
     
    1212License URI: http://www.gnu.org/licenses/gpl-2.0.txt
    1313Domain Path: /languages/
     14Requires at least: 4.9
     15Tested up to: 5.0.2
    1416*/
    1517
     
    6264    require_once plugin_dir_path( __FILE__ ) . 'class-pixcustomify.php';
    6365
    64     $instance = PixCustomifyPlugin::instance( __FILE__, '2.3.2' );
     66    $instance = PixCustomifyPlugin::instance( __FILE__, '2.3.3' );
    6567
    6668    return $instance;
  • customify/trunk/features/class-Font_Selector.php

    r1987686 r2009195  
    110110            if ( ! empty( $font ) ) {
    111111                //display the select option's HTML
    112                 Pix_Customize_Font_Control::output_font_option( $font['family'], $active_font_family, $font, 'theme_font' );
     112                Pix_Customize_Font_Control::output_font_option( $font, $active_font_family, 'theme_font' );
    113113            }
    114114        }
     
    177177                }
    178178
    179                 if ( isset( $value['font_family'] ) && isset( $value['type'] ) && $value['type'] === 'google' ) {
     179                if ( isset( $this->theme_fonts[ $value['font_family'] ] ) ) {
     180
     181//                  $value['type']     = 'theme_font';
     182//                  $args['local_srcs'] .= $this->theme_fonts[ $value['font_family'] ]['src'] . ',';
     183//                  $value['variants'] = $this->theme_fonts[ $value['font_family'] ]['variants'];
     184
     185                    if ( false === array_search( $value['font_family'], $args['local_families'] ) ) {
     186                        $args['local_families'][] = "'" . $value['font_family'] . "'";
     187                    }
     188
     189                    if ( false === array_search( $this->theme_fonts[ $value['font_family'] ]['src'], $args['local_srcs'] ) ) {
     190                        $args['local_srcs'][] = "'" . $this->theme_fonts[ $value['font_family'] ]['src'] . "'";
     191                    }
     192                } elseif ( isset( $value['font_family'] ) && isset( $value['type'] ) && $value['type'] === 'google' ) {
    180193                    $family = "'" . $value['font_family'];
    181194
     
    213226
    214227                    $args['google_families'][] = $family;
    215                 } elseif ( isset( $this->theme_fonts[ $value['font_family'] ] ) ) {
    216 
    217 //                  $value['type']     = 'theme_font';
    218 //                  $args['local_srcs'] .= $this->theme_fonts[ $value['font_family'] ]['src'] . ',';
    219 //                  $value['variants'] = $this->theme_fonts[ $value['font_family'] ]['variants'];
    220 
    221                     if ( false === array_search( $value['font_family'], $args['local_families'] ) ) {
    222                         $args['local_families'][] = "'" . $value['font_family'] . "'";
    223                     }
    224 
    225                     if ( false === array_search( $this->theme_fonts[ $value['font_family'] ]['src'], $args['local_srcs'] ) ) {
    226                         $args['local_srcs'][] = "'" . $this->theme_fonts[ $value['font_family'] ]['src'] . "'";
    227                     }
    228228                }
    229229            }
     
    515515        }
    516516
    517         ob_start();
    518         ?>
    519         var customify_font_loader = function () {
    520         var webfontargs = {
    521         classes: false,
    522         events: false
    523         };
    524         <?php if ( ! empty( $args['google_families'] ) ) { ?>
    525             webfontargs.google = {families: [<?php echo join( ',', $args['google_families'] ); ?>]};
    526         <?php }
    527         if ( ! empty( $args['local_families'] ) && ! empty( $args['local_srcs'] ) ) { ?>
    528             webfontargs.custom = {
    529             families: [<?php echo join( ',', $args['local_families'] ); ?>],
    530             urls: [<?php echo join( ',', $args['local_srcs'] ) ?>]
    531             };
    532         <?php } ?>
    533         WebFont.load(webfontargs);
    534         };
    535 
    536         if (typeof WebFont !== 'undefined') { <?php // if there is a WebFont object, use it ?>
    537         customify_font_loader();
    538         } else { <?php // basically when we don't have the WebFont object we create the google script dynamically  ?>
    539         var tk = document.createElement('script');
    540         tk.src = '//ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
    541         tk.type = 'text/javascript';
    542 
    543         tk.onload = tk.onreadystatechange = function () {
    544         customify_font_loader();
    545         };
    546         var s = document.getElementsByTagName('script')[0];
    547         s.parentNode.insertBefore(tk, s);
    548         }
     517        ob_start(); ?>
     518function customify_font_loader() {
     519    var webfontargs = {
     520        classes: false,
     521        events: false
     522    };
     523        <?php if ( ! empty( $args['google_families'] ) ) { ?>
     524    webfontargs.google = {
     525            families: [<?php echo join( ',', $args['google_families'] ); ?>]
     526        };
     527        <?php }
     528        if ( ! empty( $args['local_families'] ) && ! empty( $args['local_srcs'] ) ) { ?>
     529    webfontargs.custom = {
     530            families: [<?php echo join( ',', $args['local_families'] ); ?>],
     531            urls: [<?php echo join( ',', $args['local_srcs'] ) ?>]
     532        };
     533        <?php } ?>
     534    WebFont.load(webfontargs);
     535};
     536
     537if (typeof WebFont !== 'undefined') {
     538    customify_font_loader();
     539} else {
     540    var tk = document.createElement('script');
     541    tk.src = '//ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
     542    tk.type = 'text/javascript';
     543
     544    tk.onload = tk.onreadystatechange = function () {
     545        customify_font_loader();
     546    };
     547
     548    var s = document.getElementsByTagName('script')[0];
     549    s.parentNode.insertBefore(tk, s);
     550}
    549551        <?php
    550552        $output = ob_get_clean();
  • customify/trunk/includes/class-customify-gutenberg.php

    r1985364 r2009195  
    218218        if ( PixCustomifyPlugin()->get_plugin_setting( 'enable_editor_style', true ) ) {
    219219            add_filter( 'customify_typography_css_selector', array( $this, 'gutenbergify_font_css_selectors' ), 10, 2 );
    220             wp_add_inline_script( $enqueue_parent_handle, PixCustomifyPlugin()->get_typography_dynamic_script() );
     220            wp_add_inline_script( 'wp-editor', PixCustomifyPlugin()->get_typography_dynamic_script() );
    221221            wp_add_inline_style( $enqueue_parent_handle, PixCustomifyPlugin()->get_typography_dynamic_style() );
    222222            remove_filter( 'customify_typography_css_selector', array( $this, 'gutenbergify_font_css_selectors' ), 10 );
    223223
    224224            add_filter( 'customify_font_css_selector', array( $this, 'gutenbergify_font_css_selectors' ), 10, 2 );
    225             wp_add_inline_script( $enqueue_parent_handle, Customify_Font_Selector::instance()->get_fonts_dynamic_script() );
     225            wp_add_inline_script( 'wp-editor', Customify_Font_Selector::instance()->get_fonts_dynamic_script() );
    226226            wp_add_inline_style( $enqueue_parent_handle, Customify_Font_Selector::instance()->get_fonts_dynamic_style() );
    227227            remove_filter( 'customify_font_css_selector', array( $this, 'gutenbergify_font_css_selectors' ), 10 );
Note: See TracChangeset for help on using the changeset viewer.