PluginProbe
WP Coder – Insert & Manage Code Snippets / 4.3
WP Coder – Insert & Manage Code Snippets v4.3
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 +11 -8 3.0.34.3 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 {
@@ -20,8 +20,9 @@
20 20 if ( ! empty( $js ) && empty( $param['inline_js'] ) ) {
21 21 self::include_script( $result, $param );
22 22 }
23 23
24 +
24 25 add_filter( 'script_loader_tag', [ __CLASS__, 'add_attribute' ], 20, 2 );
25 26 }
26 27
27 28 public static function add_attribute( $tag, $handle ) {
@@ -62,10 +63,12 @@
62 63 $packer = new Obfuscator( $js, 'None', true, false );
63 64 $js = $packer->pack();
64 65 }
65 66
66 - $slug = WOW_Plugin::SLUG . '-js-' . $result->id . '-inline';
67 + $slug = WPCoder::SLUG . '-js-' . $result->id . '-inline';
68 + // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
67 69 echo '<script id="' . esc_attr( $slug ) . '">' . $js . '</script>';
70 + // phpcs:enable
68 71 }
69 72
70 73 private static function include_script( $result, $param ): void {
71 74 $url = FolderManager::get_js_url( $result );
@@ -70,10 +73,10 @@
70 73 private static function include_script( $result, $param ): void {
71 74 $url = FolderManager::get_js_url( $result );
72 75 $time = ! empty( $param['time'] ) ? $param['time'] : time();
73 76 $dependency = ! empty( $param['jquery_dependency'] ) ? [] : [ 'jquery' ];
74 - wp_enqueue_script( WOW_Plugin::SLUG . '-script-' . $result->id, $url, $dependency,
75 - WOW_Plugin::VERSION . '_' . $time, true );
77 + wp_enqueue_script( WPCoder::SLUG . '-script-' . $result->id, $url, $dependency,
78 + WPCoder::info( 'version' ) . '_' . $time, true );
76 79 }
77 80
78 81 private static function include_scripts( $result ): void {
79 82 $scripts = self::get_scripts( $result );
@@ -101,10 +104,10 @@
101 104 for ( $i = 0; $i < $count; $i ++ ) {
102 105 if ( $param['include'][ $i ] === 'js' && ! empty( $param['include_file'][ $i ] ) ) {
103 106 $scripts[] = [
104 107 'url' => $param['include_file'][ $i ],
105 - 'slug' => WOW_Plugin::SLUG . '-' . $result->id . '-js-' . $i,
106 - 'ver' => WOW_Plugin::VERSION . '_' . $time,
108 + 'slug' => WPCoder::SLUG . '-' . $result->id . '-js-' . $i,
109 + 'ver' => WPCoder::info( 'version' ) . '_' . $time,
107 110 ];
108 111 }
109 112 }
110 113
@@ -124,9 +127,9 @@
124 127 $id = $result->id;
125 128 $param = maybe_unserialize( $result->param );
126 129
127 130 if ( ! empty( $param['js_attributes'] ) && ! empty( $result->js_code ) ) {
128 - $scripts[ WOW_Plugin::SLUG . '-script-' . $id ] = $param['js_attributes'];
131 + $scripts[ WPCoder::SLUG . '-script-' . $id ] = $param['js_attributes'];
129 132 }
130 133
131 134
132 135 $count = ! empty( $param['include'] ) ? count( $param['include'] ) : 0;
@@ -138,9 +141,9 @@
138 141 for ( $i = 0; $i < $count; $i ++ ) {
139 142 if ( $param['include'][ $i ] === 'js' && ! empty( $param['include_file'][ $i ] ) ) {
140 143 $attr = ! empty( $param['file_js_att'][ $i ] ) ? $param['file_js_att'][ $i ] : '';
141 144
142 - $scripts[ WOW_Plugin::SLUG . '-' . $id . '-js-' . $i ] = $attr;
145 + $scripts[ WPCoder::SLUG . '-' . $id . '-js-' . $i ] = $attr;
143 146 }
144 147 }
145 148 }
146 149