| @@ -16,17 +16,12 @@ | ||
| 16 | 16 | $js = wp_specialchars_decode( $result->js_code, ENT_QUOTES ); |
| 17 | 17 | |
| 18 | 18 | self::include_scripts( $result ); |
| 19 | 19 | |
| 20 | - if ( ! empty( $js ) && ! empty( $param['inline_js'] ) ) { | |
| 21 | - self::print_style( $js, $param, $result ); | |
| 22 | - } | |
| 23 | - | |
| 24 | 20 | if ( ! empty( $js ) && empty( $param['inline_js'] ) ) { |
| 25 | 21 | self::include_script( $result, $param ); |
| 26 | 22 | } |
| 27 | 23 | |
| 28 | - | |
| 29 | 24 | add_filter( 'script_loader_tag', [ __CLASS__, 'add_attribute' ], 20, 2 ); |
| 30 | 25 | } |
| 31 | 26 | |
| 32 | 27 | public static function add_attribute( $tag, $handle ) { |
| @@ -38,12 +33,25 @@ | ||
| 38 | 33 | |
| 39 | 34 | return $tag; |
| 40 | 35 | } |
| 41 | 36 | |
| 42 | - private static function print_style( $js, $param, $result ): void { | |
| 37 | + public static function inline( $result ): void { | |
| 38 | + | |
| 43 | 39 | if ( is_admin() ) { |
| 44 | 40 | return; |
| 45 | 41 | } |
| 42 | + | |
| 43 | + $param = maybe_unserialize( $result->param ); | |
| 44 | + $js = wp_specialchars_decode( $result->js_code, ENT_QUOTES ); | |
| 45 | + | |
| 46 | + if ( empty( $param['inline_js'] ) ) { | |
| 47 | + return; | |
| 48 | + } | |
| 49 | + | |
| 50 | + if ( empty( $js ) ) { | |
| 51 | + return; | |
| 52 | + } | |
| 53 | + | |
| 46 | 54 | |
| 47 | 55 | $minified = ! empty( $param['minified_js'] ) ? $param['minified_js'] : 'obfuscate'; |
| 48 | 56 | |
| 49 | 57 | if ( $minified === 'obfuscate' ) { |