Skip to content

Commit 9c42847

Browse files
authored
Merge pull request #444 from BeAPI/feat/register_script_strategy
Modification du paramètre `(bool) $in_footer` => `(array) $strategy` pour `wp_register_script`
2 parents 2da0c7c + 0eb752a commit 9c42847

File tree

6 files changed

+5
-81
lines changed

6 files changed

+5
-81
lines changed

inc/Framework.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@
55
use BEA\Theme\Framework\Services\Acf;
66
use BEA\Theme\Framework\Services\Assets;
77
use BEA\Theme\Framework\Services\Performance;
8-
use BEA\Theme\Framework\Services\Assets_JS_Async;
98
use BEA\Theme\Framework\Services\Editor;
109
use BEA\Theme\Framework\Services\Editor_Patterns;
1110
use BEA\Theme\Framework\Services\Gravity_Forms;
1211
use BEA\Theme\Framework\Services\Menu;
13-
use BEA\Theme\Framework\Services\Sidebar;
1412
use BEA\Theme\Framework\Services\Svg;
1513
use BEA\Theme\Framework\Services\Theme;
1614
use BEA\Theme\Framework\Tools\Body_Class;
@@ -35,7 +33,6 @@ class Framework {
3533
Theme::class,
3634
Assets::class,
3735
Performance::class,
38-
Assets_JS_Async::class,
3936
Editor::class,
4037
Editor_Patterns::class,
4138
Gravity_Forms::class,

inc/Services/Assets.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function register_assets(): void {
6868
'dist/' . $file,
6969
array_merge( [ 'jquery' ], $asset_data['dependencies'] ), // ensure jQuery dependency is set even if not declared explicitly in the JS
7070
$asset_data['version'],
71-
true
71+
[ 'strategy' => 'defer' ]
7272
);
7373

7474
wp_add_inline_script(

inc/Services/Assets_JS_Async.php

Lines changed: 0 additions & 73 deletions
This file was deleted.

inc/Services/Theme.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ private function add_theme_supports(): void {
5555
add_theme_support( 'post-thumbnails' );
5656
add_theme_support( 'html5', [ 'comment-list', 'comment-form', 'search-form', 'gallery', 'caption', 'script', 'style' ] );
5757
add_theme_support( 'title-tag' );
58-
add_theme_support( 'async-js' );
5958
add_theme_support( 'yoast-seo-breadcrumbs' );
6059
}
6160

inc/Tools/Assets.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ class Assets {
1717
* @param $src : Have to be a relative filename
1818
* @param array $deps
1919
* @param mixed $ver
20-
* @param bool $in_footer
20+
* @param array $strategy
2121
*
2222
* @return bool
2323
*/
24-
public function register_script( string $handle, string $src, array $deps = [], $ver = false, bool $in_footer = false ): bool {
25-
return \wp_register_script( $handle, \get_theme_file_uri( $src ), $deps, $ver, $in_footer );
24+
public function register_script( string $handle, string $src, array $deps = [], $ver = false, array $strategy = [] ): bool {
25+
return \wp_register_script( $handle, \get_theme_file_uri( $src ), $deps, $ver, $strategy );
2626
}
2727

2828
/**

style.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ Version: 1.0.0
66
Author: BeAPI
77
Author URI: http://www.beapi.fr
88
Text Domain: beapi-frontend-framework
9+
Requires at least: 6.3
910
*/

0 commit comments

Comments
 (0)