@@ -66,7 +66,6 @@ public function setup(): void {
6666 /**
6767 * Registers the settings page for the view logs.
6868 *
69- * @psalm-suppress HookNotFound
7069 */
7170 public function register_settings_page (): void {
7271
@@ -93,9 +92,7 @@ public function register_settings_page(): void {
9392 add_action ( 'load- ' . $ this ->page_hook , [ $ this , 'process_page_actions_before_rendering ' ], 10 , 0 );
9493
9594 // Enqueue scripts for the admin page.
96- add_action ( 'admin_enqueue_scripts ' , [ $ this , 'enqueue_admin_scripts ' ], 9 , 1 ); // Need to load before adding SRI attributes.
97- add_action ( 'script_loader_tag ' , [ $ this , 'add_sri_to_scripts ' ], 10 , 2 );
98- add_action ( 'style_loader_tag ' , [ $ this , 'add_sri_to_styles ' ], 10 , 2 );
95+ add_action ( 'admin_enqueue_scripts ' , [ $ this , 'enqueue_admin_scripts ' ]);
9996 }
10097
10198 /**
@@ -115,7 +112,7 @@ public function enqueue_admin_scripts( string $hook_suffix ): void {
115112 'jquery-ui-timepicker-addon ' ,
116113 'https://cdnjs.cloudflare.com/ajax/libs/jquery-ui-timepicker-addon/1.6.3/jquery-ui-timepicker-addon.min.js ' ,
117114 [ 'jquery-ui-datepicker ' , 'jquery-ui-slider ' ],
118- '1.6.3 ' ,
115+ '1.6.3 ' , // Hash needs to be updated once a version is changed with the new version.
119116 true ,
120117 );
121118
@@ -151,103 +148,6 @@ public function enqueue_admin_scripts( string $hook_suffix ): void {
151148 do_action ( 'wpgraphql_logging_view_logs_admin_enqueue_scripts ' , $ hook_suffix );
152149 }
153150
154- /**
155- * Adds integrity and crossorigin attributes to scripts.
156- *
157- * @param string $tag The script tag.
158- * @param string $handle The script handle.
159- *
160- * @link https://www.srihash.org/ to generate the integrity and crossorigin attributes.
161- */
162- public function add_sri_to_scripts ($ tag , $ handle ): void {
163-
164- $ scripts = [
165- 'jquery-ui-timepicker-addon ' => [
166- 'integrity ' => 'sha512-s5u/JBtkPg+Ff2WEr49/cJsod95UgLHbC000N/GglqdQuLnYhALncz8ZHiW/LxDRGduijLKzeYb7Aal9h3codZA== ' ,
167- 'crossorigin ' => 'anonymous ' ,
168- ],
169- ];
170-
171- $ scripts = apply_filters ( 'wpgraphql_logging_view_logs_add_sri_to_scripts ' , $ scripts );
172-
173- if ( ! isset ( $ scripts [ $ handle ] ) ) {
174- return ;
175- }
176-
177- $ integrity = $ scripts [ $ handle ]['integrity ' ];
178- $ crossorigin = $ scripts [ $ handle ]['crossorigin ' ];
179-
180- $ tag = str_replace (
181- ' src= ' ,
182- ' integrity=" ' . esc_attr ( $ integrity ) . '" crossorigin=" ' . esc_attr ( $ crossorigin ) . '" src= ' ,
183- $ tag
184- );
185-
186- echo wp_kses ( $ tag , [
187- 'script ' => [
188- 'src ' => [],
189- 'integrity ' => [],
190- 'crossorigin ' => [],
191- 'type ' => [],
192- 'id ' => [],
193- ],
194- 'link ' => [
195- 'href ' => [],
196- 'integrity ' => [],
197- 'crossorigin ' => [],
198- 'rel ' => [],
199- 'type ' => [],
200- 'id ' => [],
201- ],
202- ] );
203- }
204-
205- /**
206- * Adds integrity and crossorigin attributes to styles.
207- *
208- * @param string $tag The script tag.
209- * @param string $handle The script handle.
210- *
211- * @link https://www.srihash.org/ to generate the integrity and crossorigin attributes.
212- */
213- public function add_sri_to_styles ($ tag , $ handle ): void {
214-
215- $ styles = [
216- 'jquery-ui-timepicker-addon-style ' => [
217- 'integrity ' => 'sha512-LT9fy1J8pE4Cy6ijbg96UkExgOjCqcxAC7xsnv+mLJxSvftGVmmc236jlPTZXPcBRQcVOWoK1IJhb1dAjtb4lQ== ' ,
218- 'crossorigin ' => 'anonymous ' ,
219- ],
220- 'jquery-ui-style ' => [
221- 'integrity ' => 'sha512-sOC1C3U/7L42Ao1++jwVCpnllhbxnfD525JBZE2h1+cYnLg3aIE3G1RBWKSr/9cF5LxB1CxPckAvHqzz7O4apQ== ' ,
222- 'crossorigin ' => 'anonymous ' ,
223- ],
224- ];
225- $ styles = apply_filters ( 'wpgraphql_logging_view_logs_add_sri_to_styles ' , $ styles );
226-
227- if ( ! isset ( $ styles [ $ handle ] ) ) {
228- return ;
229- }
230-
231- $ integrity = $ styles [ $ handle ]['integrity ' ];
232- $ crossorigin = $ styles [ $ handle ]['crossorigin ' ];
233-
234- $ tag = str_replace (
235- ' href= ' ,
236- ' integrity=" ' . esc_attr ( $ integrity ) . '" crossorigin=" ' . esc_attr ( $ crossorigin ) . '" href= ' ,
237- $ tag
238- );
239-
240- echo wp_kses ( $ tag , [
241- 'link ' => [
242- 'src ' => [],
243- 'integrity ' => [],
244- 'crossorigin ' => [],
245- 'type ' => [],
246- 'id ' => [],
247- ],
248- ] );
249- }
250-
251151 /**
252152 * Renders the admin page for the logs.
253153 */
0 commit comments