PluginProbe
WP Coder – Insert & Manage Code Snippets / 4.1
WP Coder – Insert & Manage Code Snippets v4.1
4.5.1 1.1 2.3.1 2.3.2 2.4.1 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.1 3.1.1 3.2 3.2.1 3.3 3.4 3.5 3.5.1 All 39 releases
← All changes | classes/Publisher/EnqueueScript.php +24 -13 3.0.24.1 View file →
@@ -6,9 +6,9 @@
6 6
7 7 use WPCoder\Dashboard\DBManager;
8 8 use WPCoder\Dashboard\FolderManager;
9 9 use WPCoder\Optimization\Obfuscator;
10 -use WPCoder\WOW_Plugin;
10 +use WPCoder\WPCoder;
11 11
12 12 class EnqueueScript {
13 13
14 14 public static function init( $result ): void {
@@ -16,12 +16,8 @@
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
@@ -38,13 +34,26 @@
38 34
39 35 return $tag;
40 36 }
41 37
42 - private static function print_style( $js, $param, $result ): void {
38 + public static function inline( $result ): void {
39 +
43 40 if ( is_admin() ) {
44 41 return;
45 42 }
46 43
44 + $param = maybe_unserialize( $result->param );
45 + $js = wp_specialchars_decode( $result->js_code, ENT_QUOTES );
46 +
47 + if ( empty( $param['inline_js'] ) ) {
48 + return;
49 + }
50 +
51 + if ( empty( $js ) ) {
52 + return;
53 + }
54 +
55 +
47 56 $minified = ! empty( $param['minified_js'] ) ? $param['minified_js'] : 'obfuscate';
48 57
49 58 if ( $minified === 'obfuscate' ) {
50 59 $packer = new Obfuscator( $js, 'Normal', true, false );
@@ -54,10 +63,12 @@
54 63 $packer = new Obfuscator( $js, 'None', true, false );
55 64 $js = $packer->pack();
56 65 }
57 66
58 - $slug = WOW_Plugin::SLUG . '-js-' . $result->id . '-inline';
67 + $slug = WPCoder::SLUG . '-js-' . $result->id . '-inline';
68 + // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
59 69 echo '<script id="' . esc_attr( $slug ) . '">' . $js . '</script>';
70 + // phpcs:enable
60 71 }
61 72
62 73 private static function include_script( $result, $param ): void {
63 74 $url = FolderManager::get_js_url( $result );
@@ -62,10 +73,10 @@
62 73 private static function include_script( $result, $param ): void {
63 74 $url = FolderManager::get_js_url( $result );
64 75 $time = ! empty( $param['time'] ) ? $param['time'] : time();
65 76 $dependency = ! empty( $param['jquery_dependency'] ) ? [] : [ 'jquery' ];
66 - wp_enqueue_script( WOW_Plugin::SLUG . '-script-' . $result->id, $url, $dependency,
67 - WOW_Plugin::VERSION . '_' . $time, true );
77 + wp_enqueue_script( WPCoder::SLUG . '-script-' . $result->id, $url, $dependency,
78 + WPCoder::info( 'version' ) . '_' . $time, true );
68 79 }
69 80
70 81 private static function include_scripts( $result ): void {
71 82 $scripts = self::get_scripts( $result );
@@ -93,10 +104,10 @@
93 104 for ( $i = 0; $i < $count; $i ++ ) {
94 105 if ( $param['include'][ $i ] === 'js' && ! empty( $param['include_file'][ $i ] ) ) {
95 106 $scripts[] = [
96 107 'url' => $param['include_file'][ $i ],
97 - 'slug' => WOW_Plugin::SLUG . '-' . $result->id . '-js-' . $i,
98 - 'ver' => WOW_Plugin::VERSION . '_' . $time,
108 + 'slug' => WPCoder::SLUG . '-' . $result->id . '-js-' . $i,
109 + 'ver' => WPCoder::info( 'version' ) . '_' . $time,
99 110 ];
100 111 }
101 112 }
102 113
@@ -116,9 +127,9 @@
116 127 $id = $result->id;
117 128 $param = maybe_unserialize( $result->param );
118 129
119 130 if ( ! empty( $param['js_attributes'] ) && ! empty( $result->js_code ) ) {
120 - $scripts[ WOW_Plugin::SLUG . '-script-' . $id ] = $param['js_attributes'];
131 + $scripts[ WPCoder::SLUG . '-script-' . $id ] = $param['js_attributes'];
121 132 }
122 133
123 134
124 135 $count = ! empty( $param['include'] ) ? count( $param['include'] ) : 0;
@@ -130,9 +141,9 @@
130 141 for ( $i = 0; $i < $count; $i ++ ) {
131 142 if ( $param['include'][ $i ] === 'js' && ! empty( $param['include_file'][ $i ] ) ) {
132 143 $attr = ! empty( $param['file_js_att'][ $i ] ) ? $param['file_js_att'][ $i ] : '';
133 144
134 - $scripts[ WOW_Plugin::SLUG . '-' . $id . '-js-' . $i ] = $attr;
145 + $scripts[ WPCoder::SLUG . '-' . $id . '-js-' . $i ] = $attr;
135 146 }
136 147 }
137 148 }
138 149