Changeset 2123 for sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-js-warnings/wporg-gp-js-warnings.php
- Timestamp:
- 11/23/2015 10:45:21 PM (9 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-js-warnings
- Files:
-
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-js-warnings/wporg-gp-js-warnings.php
r2115 r2123 1 1 <?php 2 /** 3 * Plugin name: GlotPress: Client-side JS translation validation 4 * Plugin author: dd32 5 */ 6 2 7 /** 3 8 * Adds client-side JS translation validation warning warnings. … … 12 17 * @author dd32 13 18 */ 14 class WPORG_JS_Translation_Warnings { 19 class WPorg_GP_JS_Translation_Warnings { 20 15 21 function __construct() { 16 22 add_action( 'wp_print_scripts', array( $this, 'replace_editor_with_our_own' ), 100 ); 17 23 } 18 24 19 // Replace the GlotPress editor script with our own (which depends on the editor-core GlotPress variant) this allows us to be output whenever `editor` is. 20 function replace_editor_with_our_own( $scripts ) { 21 global $wp_scripts; 22 23 $query = $wp_scripts->query( 'editor', 'registered' ); 25 /** 26 * Replace the GlotPress editor script with our own which depends on the wporg-gp-editor GlotPress variant. 27 * 28 * This allows us to be output whenever `gp-editor` is. 29 */ 30 function replace_editor_with_our_own() { 31 $query = wp_scripts()->query( 'gp-editor', 'registered' ); 24 32 if ( ! $query ) { 25 33 return; 26 34 } 27 35 28 wp_register_script( ' editor-core', $query->src, $query->deps, $query->ver );36 wp_register_script( 'wporg-gp-editor', $query->src, $query->deps, $query->ver ); 29 37 if ( isset( $query->extra['l10n'] ) ) { 30 wp_localize_script( ' editor-core', $query->extra['l10n'][0], $query->extra['l10n'][1] );38 wp_localize_script( 'wporg-gp-editor', $query->extra['l10n'][0], $query->extra['l10n'][1] ); 31 39 } 32 40 33 wp_deregister_script( 'editor' ); 34 wp_register_script( 'editor', gp_url_public_root() . 'gp-plugins/wporg-js-warnings/wporg-js-warnings.js', array( 'editor-core', 'jquery' ), '2015-11-14' ); 35 41 wp_deregister_script( 'gp-editor' ); 42 wp_register_script( 'gp-editor', plugins_url( '/wporg-gp-js-warnings.js', __FILE__ ), array( 'wporg-gp-editor', 'jquery' ), '2015-11-14' ); 36 43 } 37 44 38 45 } 39 new WPORG_JS_Translation_Warnings();40 46 47 function wporg_gp_js_translation_warnings() { 48 global $wporg_gp_js_translation_warnings; 49 50 if ( ! isset( $wporg_gp_js_translation_warnings ) ) { 51 $wporg_gp_js_translation_warnings = new WPorg_GP_JS_Translation_Warnings(); 52 } 53 54 return $wporg_gp_js_translation_warnings; 55 } 56 add_action( 'plugins_loaded', 'wporg_gp_js_translation_warnings' );
Note: See TracChangeset
for help on using the changeset viewer.