Making WordPress.org


Ignore:
Timestamp:
04/01/2022 02:58:12 PM (5 years ago)
Author:
ocean90
Message:

Translate: Add suffix to GlotPress' default assets for extra cache busting.

See #6246.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/inc/class-plugin.php

    r11494 r11736  
    4343                add_action( 'gp_project_saved', array( $this, 'update_projects_last_updated' ) );
    4444                add_filter( 'pre_handle_404', array( $this, 'short_circuit_handle_404' ) );
    45                 add_action( 'wp_default_scripts', array( $this, 'bump_script_versions' ) );
     45                add_action( 'init', array( $this, 'bump_assets_versions' ), 20 );
    4646                add_action( 'after_setup_theme', array( $this, 'after_setup_theme' ) );
    4747                add_filter( 'body_class', array( $this, 'wporg_add_make_site_body_class' ) );
    … …  
    452452
    453453        /**
    454          * Changes the versions of some default scripts for cache bust.
    455          *
    456          * @see https://wordpress.slack.com/archives/meta-i18n/p1460626195000251
    457          *
    458          * @param WP_Scripts &$scripts WP_Scripts instance, passed by reference.
    459          */
    460         public function bump_script_versions( &$scripts ) {
    461                 foreach ( [ 'gp-editor', 'gp-glossary' ] as $handle ) {
    462                         if ( isset( $scripts->registered[ $handle ] ) && '20160329' === $scripts->registered[ $handle ]->ver ) {
    463                                 $scripts->registered[ $handle ]->ver = '20160329a';
     454         * Changes the versions of GlotPress default assets for extra cache busting.
     455         */
     456        public function bump_assets_versions() {
     457                $scripts = wp_scripts();
     458                foreach ( [ 'gp-common', 'gp-editor', 'gp-glossary', 'gp-translations-page', 'gp-mass-create-sets-page' ] as $handle ) {
     459                        if ( isset( $scripts->registered[ $handle ] ) ) {
     460                                $scripts->registered[ $handle ]->ver = $scripts->registered[ $handle ]->ver . '-1';
     461                        }
     462                }
     463
     464                $styles = wp_styles();
     465                foreach ( [ 'gp-base' ] as $handle ) {
     466                        if ( isset( $styles->registered[ $handle ] ) ) {
     467                                $styles->registered[ $handle ]->ver = $styles->registered[ $handle ]->ver . '-1';
    464468                        }
    465469                }
Note: See TracChangeset for help on using the changeset viewer.