Plugin Directory

Changeset 1989393


Ignore:
Timestamp:
12/08/2018 05:38:30 PM (7 years ago)
Author:
al5dy
Message:

Update plugin

Location:
yamap-block-gutenberg
Files:
12 added
1 edited

Legend:

Unmodified
Added
Removed
  • yamap-block-gutenberg/trunk/yamap-block-gutenberg.php

    r1989369 r1989393  
    8484
    8585        add_action( 'init', array( $this, 'init' ), 0 );
    86         add_action( 'enqueue_block_editor_assets', array( $this, 'editor_assets' ) );
     86        add_action( 'init', array( $this, 'editor_assets' ) );
    8787        add_action( 'wp_enqueue_scripts', array( $this, 'load_assets' ) );
    8888        add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
     
    104104        wp_register_script(
    105105            'guyamap-editor-script',
    106             $this->plugin_url(). '/assets/block-editor.build.js',
     106            $this->plugin_url() . '/assets/block-editor.build.js',
    107107            array( 'wp-i18n', 'wp-blocks', 'wp-element', 'wp-components', 'wp-editor' ),
    108108            filemtime( $this->plugin_path() . '/assets/block-editor.build.js' )
     
    122122            'editor_style'  => 'guyamap-editor-style'
    123123        ) );
    124 
    125 
    126         // Get All Translations @al5dy hack
    127         $locale_data = $this->get_jed_locale_data( 'guyamap' );
    128         wp_add_inline_script(
    129             'wp-i18n',
    130             'wp.i18n.setLocaleData( ' . json_encode( $locale_data ) . ',  \'guyamap\' );'
    131         );
    132 
     124       
     125
     126        if(function_exists('wp_set_script_translations')) {
     127            /*
     128             * Pass already loaded translations to our JavaScript.
     129             *
     130             * This happens _before_ our JavaScript runs, afterwards it's too late.
     131             */
     132            wp_add_inline_script(
     133                'guyamap-editor-script',
     134                sprintf(
     135                    'var guyamap_editor_script = { localeData: %s };',
     136                    json_encode( wp_set_script_translations( 'guyamap-editor-script', 'guyamap', $this->plugin_path() . '/languages' ) )
     137                ),
     138                'before'
     139            );
     140        } else {
     141            // Get All Translations @al5dy hack
     142            $locale_data = $this->get_jed_locale_data( 'guyamap' );
     143            wp_add_inline_script(
     144                'wp-i18n',
     145                'wp.i18n.setLocaleData( ' . json_encode( $locale_data ) . ',  \'guyamap\' );'
     146            );
     147
     148        }
    133149
    134150    }
     
    175191        wp_enqueue_script( 'gutenberg-yamap-api' );
    176192
    177         wp_register_script( 'gutenberg-yamap-front', $this->plugin_url() . '/assets/block-front.build.js' , array( 'gutenberg-yamap-api' ), GUYAMAP_VERSION, true );
     193        wp_register_script( 'gutenberg-yamap-front', $this->plugin_url() . '/assets/block-front.build.js', array( 'gutenberg-yamap-api' ), GUYAMAP_VERSION, true );
    178194        wp_enqueue_script( 'gutenberg-yamap-front' );
    179195    }
Note: See TracChangeset for help on using the changeset viewer.