Skip to content

Commit

Permalink
fix: JS translations being loaded from the plugins directory
Browse files Browse the repository at this point in the history
  • Loading branch information
abaicus committed Jul 26, 2024
1 parent 519535f commit 8869518
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions inc/core/core_loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ function () {
add_action( 'wp_enqueue_scripts', array( $front_end, 'enqueue_scripts' ) );
add_action( 'after_setup_theme', array( $front_end, 'setup_theme' ) );
add_action( 'widgets_init', array( $front_end, 'register_sidebars' ) );
add_filter( 'load_script_translation_file', array( $front_end, 'fix_script_translation_files' ), 10, 3 );
}

/**
Expand Down
21 changes: 21 additions & 0 deletions inc/core/front_end.php
Original file line number Diff line number Diff line change
Expand Up @@ -573,4 +573,25 @@ public function css_global_custom_colors( $current_styles, $context ) {

return $current_styles;
}

/**
* Fix script translations language directory.
*
* @param string | false $file File path.
* @param string $handle Script handle.
* @param string $domain Script text domain.
*
* @return string | false
*/
public function fix_script_translation_files( $file, $handle, $domain ) {
if ( ! $file || $domain !== 'neve' ) {
return $file;
}

if ( strpos( $file, WP_LANG_DIR . '/plugins' ) !== false ) {
$file = str_replace( WP_LANG_DIR . '/plugins', WP_LANG_DIR . '/themes', $file );
}

return $file;
}
}
1 change: 1 addition & 0 deletions tests/php/static-analysis-stubs/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@

define( 'WP_DEFAULT_THEME', 'neve' );
define( 'WP_PLUGIN_DIR', '/plugins' );
define( 'WP_LANG_DIR', '/languages' );

0 comments on commit 8869518

Please sign in to comment.