C:\xampp\htdocs\landing\wp-content\plugins\wp-asset-clean-up\classes\HardcodedAssets.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
<?php
namespace WpAssetCleanUp;

use 
WpAssetCleanUp\OptimiseAssets\OptimizeCommon;
use 
WpAssetCleanUp\OptimiseAssets\OptimizeJs;

/**
 * Class HardcodedAssets
 * @package WpAssetCleanUp
 */
class HardcodedAssets
{
    
/**
     *
     */
    
public static function init()
    {
        
add_action'init', static function() {
            if (
Main::instance()->isGetAssetsCall) {
                
// Case 1: An AJAX call is made from the Dashboard
                
self::initBufferingForAjaxCallFromTheDashboard();
            } elseif (
self::useBufferingForEditFrontEndView()) {
                
// Case 2: The logged-in admin manages the assets from the front-end view
                
self::initBufferingForFrontendManagement();
            }
        });
    }

    
/**
     *
     */
    
public static function initBufferingForAjaxCallFromTheDashboard()
    {
        
ob_start();

        
add_action('shutdown', static function() {
            
$htmlSource '';

            
// We'll need to get the number of ob levels we're in, so that we can iterate over each, collecting
            // that buffer's output into the final output.
            
$htmlSourceLevel ob_get_level();

            for (
$wpacuI 0$wpacuI $htmlSourceLevel$wpacuI++) {
                
$htmlSource .= ob_get_clean();
            }

            
$anyHardCodedAssets HardcodedAssets::getAll($htmlSource); // Fetch all for this type of request

            
$htmlSource str_replace('{wpacu_hardcoded_assets}'$anyHardCodedAssets$htmlSource);

            echo 
$htmlSource;
        }, 
0);
    }

    
/**
     *
     */
    
public static function initBufferingForFrontendManagement()
    {
        
// Used to print the hardcoded CSS/JS
        
ob_start();

        
add_action('shutdown', static function() {
            if (! 
defined('NEXTEND_SMARTSLIDER_3_URL_PATH')) {
                
ob_flush();
            }

            
$htmlSource '';

            
// We'll need to get the number of ob levels we're in, so that we can iterate over each, collecting
            // that buffer's output into the final output.
            
$htmlSourceLevel ob_get_level();

            for (
$wpacuI 0$wpacuI $htmlSourceLevel$wpacuI++) {
                
$htmlSource .= ob_get_clean();
            }

            echo 
OptimizeCommon::alterHtmlSource($htmlSource);

            }, 
0);
    }

    
/**
     * @return bool
     */
    
public static function useBufferingForEditFrontEndView()
    {
        
// The logged-in admin needs to be outside the Dashboard (in the front-end view)
        // "Manage in the Front-end" is enabled in "Settings" -> "Plugin Usage Preferences"
        
return (Main::instance()->frontendShow() && ! is_admin() && Menu::userCanManageAssets() && ! Main::instance()->isGetAssetsCall);
    }

    
/**
     * @param $htmlSource
     * @param bool $encodeIt - if set to "false", it's mostly for testing purposes
     *
     * @return string|array
     */
    
public static function getAll($htmlSource$encodeIt true)
    {
        
$htmlSourceAlt CleanUp::removeHtmlComments($htmlSourcetrue);

        
$collectLinkStyles true// default
        
$collectScripts    true// default

        
$hardCodedAssets = array(
            
'link_and_style_tags'        => array(), // LINK (rel="stylesheet") & STYLE (inline)
            
'script_src_and_inline_tags' => array(), // SCRIPT (with "src" attribute) & SCRIPT (inline)
        
);

        if (
$collectLinkStyles) {
            
/*
            * [START] Collect Hardcoded LINK (stylesheet) & STYLE tags
            */
            
preg_match_all'#(?=(?P<link_tag><link[^>]*stylesheet[^>]*(>)))|(?=(?P<style_tag><style[^>]*?>.*</style>))#Umsi',
                
$htmlSourceAlt$matchesSourcesFromTagsPREG_SET_ORDER );

            if ( ! empty( 
$matchesSourcesFromTags ) ) {
                
// Only the hashes are set
                // For instance, 'd1eae32c4e99d24573042dfbb71f5258a86e2a8e' is the hash for the following script:
                /*
                * <style media="print">#wpadminbar { display:none; }</style>
                 */
                
$stripsSpecificStylesHashes = array(
                    
'5ead5f033961f3b8db362d2ede500051f659dd6d',
                    
'25bd090513716c34b48b0495c834d2070088ad24'
                
);

                
// Sometimes, the hash checking might failed (if there's a small change to the JS content)
                // Consider using a fallback verification by checking the actual content
                
$stripsSpecificStylesContaining = array(
                    
'<style media="print">#wpadminbar { display:none; }</style>'
                
);

                foreach ( 
$matchesSourcesFromTags as $matchedTagIndex => $matchedTag ) {
                    
// LINK "stylesheet" tags (if any)
                    
if ( isset( $matchedTag['link_tag'] ) && trim$matchedTag['link_tag'] ) !== '' && ( trimstrip_tags$matchedTag['link_tag'] ) ) === '' ) ) {
                        
$matchedTagOutput trim$matchedTag['link_tag'] );

                        if ( 
strpos$matchedTagOutput'data-wpacu-style-handle=' ) !== false ) {
                            
// Skip the LINK with src that was enqueued properly and keep the hardcoded ones
                            
continue;
                        }

                        
$hardCodedAssets['link_and_style_tags'][] = $matchedTagOutput;
                    }

                    
// STYLE inline tags (if any)
                    
if ( isset( $matchedTag['style_tag'] ) && trim$matchedTag['style_tag'] ) !== '' ) {
                        
$matchedTagOutput trim$matchedTag['style_tag'] );

                        
/*
                         * Strip certain STYLE tags irrelevant for the list (e.g. related to the WordPress Admin Bar, etc.)
                        */
                        
if ( in_arraysha1$matchedTagOutput ), $stripsSpecificStylesHashes ) ) {
                            continue;
                        }

                        foreach ( 
$stripsSpecificStylesContaining as $cssContentTargeted ) {
                            if ( 
strpos$matchedTagOutput$cssContentTargeted ) !== false ) {
                                continue;
                            }
                        }

                        
// Do not add to the list elements such as Emojis (not relevant for hard-coded tags)
                        
if ( strpos$matchedTagOutput'img.wp-smiley' )  !== false
                             
&& strpos$matchedTagOutput'img.emoji' )   !== false
                             
&& strpos$matchedTagOutput'!important;' ) !== false ) {
                            continue;
                        }

                        if ( (
strpos$matchedTagOutput'data-wpacu-own-inline-style=' ) !== false) ||
                             (
strpos$matchedTagOutput'data-wpacu-inline-css-file=')   !== false) ) {
                            
// remove plugin's own STYLE tags as they are not relevant in this context
                            
continue;
                        }

                        foreach ( 
wp_styles()->done as $cssHandle ) {
                            if ( 
strpos$matchedTagOutput,
                                    
'<style id=\'' trim$cssHandle ) . '-inline-css\'' ) !== false ) {
                                
// Do not consider the STYLE added via WordPress with wp_add_inline_style() as it's not hardcoded
                                
continue 2;
                            }
                        }

                        
$hardCodedAssets['link_and_style_tags'][] = $matchedTagOutput;
                    }
                }
            }
            
/*
            * [END] Collect Hardcoded LINK (stylesheet) & STYLE tags
            */
        
}

        if (
$collectScripts) {
            
/*
            * [START] Collect Hardcoded SCRIPT (src/inline)
            */
            
preg_match_all'@<script[^>]*?>.*?</script>@si'$htmlSourceAlt$matchesScriptTagsPREG_SET_ORDER );

            if ( isset( 
wp_scripts()->done ) && ! empty( wp_scripts()->done ) ) {
                
$allInlineAssocWithJsHandle = array();

                foreach ( 
wp_scripts()->done as $assetHandle ) {
                    
// Now, go through the list of inline SCRIPTs associated with an enqueued SCRIPT (with "src" attribute)
                    // And make sure they do not show to the hardcoded list, since they are related to the handle and they are stripped when the handle is dequeued
                    
$anyInlineAssocWithJsHandle OptimizeJs::getInlineAssociatedWithScriptHandle$assetHandlewp_scripts()->registered'handle' );
                    if ( ! empty( 
$anyInlineAssocWithJsHandle ) ) {
                        foreach ( 
$anyInlineAssocWithJsHandle as $jsInlineTagContent ) {
                            if ( 
trim$jsInlineTagContent ) === '' ) {
                                continue;
                            }

                            
$allInlineAssocWithJsHandle[] = trim($jsInlineTagContent);
                        }
                    }
                }

                
$allInlineAssocWithJsHandle array_unique($allInlineAssocWithJsHandle);
                }

            
// Go through the hardcoded SCRIPT tags
            
if ( isset( $matchesScriptTags ) && ! empty( $matchesScriptTags ) ) {
                
// Only the hashes are set
                // For instance, 'd1eae32c4e99d24573042dfbb71f5258a86e2a8e' is the hash for the following script:
                /*
                 * <script>
                (function() {
                    var request, b = document.body, c = 'className', cs = 'customize-support', rcs = new RegExp('(^|\\s+)(no-)?'+cs+'(\\s+|$)');
                        request = true;
                    b[c] = b[c].replace( rcs, ' ' );
                    // The customizer requires postMessage and CORS (if the site is cross domain)
                    b[c] += ( window.postMessage && request ? ' ' : ' no-' ) + cs;
                }());
                </script>
                 */
                
$stripsSpecificScriptsHashes = array(
                    
'd1eae32c4e99d24573042dfbb71f5258a86e2a8e',
                    
'1a8f46f9f33e5d95919620df54781acbfa9efff7'
                
);

                
// Sometimes, the hash checking might failed (if there's a small change to the JS content)
                // Consider using a fallback verification by checking the actual content
                
$stripsSpecificScriptsContaining = array(
                    
'// The customizer requires postMessage and CORS (if the site is cross domain)',
                    
'b[c] += ( window.postMessage && request ? \' \' : \' no-\' ) + cs;',
                    
"(function(){var request,b=document.body,c='className',cs='customize-support',rcs=new RegExp('(^|\\s+)(no-)?'+cs+'(\\s+|$)');request=!0;b[c]=b[c].replace(rcs,' ');b[c]+=(window.postMessage&&request?' ':' no-')+cs}())",
                    
'document.body.className = document.body.className.replace( /(^|\s)(no-)?customize-support(?=\s|$)/, \'\' ) + \' no-customize-support\''
                
);

                foreach ( 
$matchesScriptTags as $matchedTag ) {
                    if ( isset( 
$matchedTag[0] ) && $matchedTag[0] && strpos$matchedTag[0], '<script' ) === ) {
                        
$matchedTagOutput trim$matchedTag[0] );

                        
/*
                         * Strip certain SCRIPT tags irrelevant for the list (e.g. related to WordPress Customiser, Admin Bar, etc.)
                        */
                        
if ( in_arraysha1$matchedTagOutput ), $stripsSpecificScriptsHashes ) ) {
                            continue;
                        }

                        foreach ( 
$stripsSpecificScriptsContaining as $jsContentTargeted ) {
                            if ( 
strpos$matchedTagOutput$jsContentTargeted ) !== false ) {
                                continue;
                            }
                        }

                        if ( 
strpos$matchedTagOutput'window._wpemojiSettings' ) !== false
                             
&& strpos$matchedTagOutput'twemoji' ) !== false ) {
                            continue;
                        }

                        
// Check the type and only allow SCRIPT tags with type='text/javascript' or no type at all (it default to 'text/javascript')
                        
$matchedTagInner    strip_tags$matchedTagOutput );
                        
$matchedTagOnlyTags str_replace$matchedTagInner''$matchedTagOutput );
                        
preg_match_all'#type=(["\'])' '(.*)' '(["\'])#Usmi'$matchedTagOnlyTags,
                            
$outputMatches );
                        
$scriptType = isset( $outputMatches[2][0] ) ? trim$outputMatches[2][0],
                            
'"\'' ) : 'text/javascript';

                        if ( 
strpos$scriptType'text/javascript' ) === false ) {
                            continue;
                        }

                        if ( 
strpos$matchedTagOutput'data-wpacu-script-handle=' ) !== false ) {
                            
// skip the SCRIPT with src that was enqueued properly and keep the hardcoded ones
                            
continue;
                        }

                        if ( (
strpos$matchedTagOutput'data-wpacu-own-inline-script=' ) !== false) ||
                             (
strpos$matchedTagOutput'data-wpacu-inline-js-file=' )    !== false) ) {
                            
// skip plugin's own SCRIPT tags as they are not relevant in this context
                            
continue;
                        }

                        if ( 
strpos$matchedTagOutput'wpacu-preload-async-css-fallback' ) !== false ) {
                            
// skip plugin's own SCRIPT tags as they are not relevant in this context
                            
continue;
                        }

                        
$hasSrc false;

                        if (
strpos($matchedTagOnlyTags' src=') !== false) {
                            
$hasSrc true;
                        }

                        if ( ! 
$hasSrc && ! empty( $allInlineAssocWithJsHandle ) ) {
                            
preg_match_all("'<script[^>]*?>(.*?)</script>'si"$matchedTagOutput$matchesFromTagOutput);
                            
$matchedTagOutputInner = isset($matchesFromTagOutput[1][0]) && trim($matchesFromTagOutput[1][0])
                                ? 
trim($matchesFromTagOutput[1][0]) : false;

                            
$matchedTagOutputInnerCleaner $matchedTagOutputInner;

                            
$stripStrStart '/* <![CDATA[ */';
                            
$stripStrEnd   '/* ]]> */';

                            if (
strpos($matchedTagOutputInnerCleaner$stripStrStart) === 0
                                
&& Misc::endsWith($matchedTagOutputInnerCleaner'/* ]]> */')) {
                                
$matchedTagOutputInnerCleaner substr($matchedTagOutputInnerCleanerstrlen($stripStrStart));
                                
$matchedTagOutputInnerCleaner substr($matchedTagOutputInnerCleaner0, -strlen($stripStrEnd));
                                
$matchedTagOutputInnerCleaner trim($matchedTagOutputInnerCleaner);
                            }

                            if (
in_array($matchedTagOutputInnerCleaner$allInlineAssocWithJsHandle)) {
                                continue;
                            }

                            }

                        
$hardCodedAssets['script_src_and_inline_tags'][] = trim$matchedTag[0] );
                    }
                }
            }
            
/*
            * [END] Collect Hardcoded SCRIPT (src/inline)
            */
        
}

        
$tagsWithinConditionalComments self::extractHtmlFromConditionalComments$htmlSourceAlt );

        if (
Main::instance()->isGetAssetsCall) {
            
// AJAX call within the Dashboard
            
$hardCodedAssets['within_conditional_comments'] = $tagsWithinConditionalComments;
        }

        if (
$encodeIt) {
            return 
base64_encodejson_encode$hardCodedAssets ) );
        }

        return 
$hardCodedAssets;
    }

    
/**
     * @param $htmlSource
     *
     * @return mixed
     */
    /*
    public static function removeHtmlCommentsExceptMSIE($htmlSource)
    {
        // No comments? Do not continue
        if (strpos($htmlSource, '<!--') === false) {
            return $htmlSource;
        }

        if (! (function_exists('libxml_use_internal_errors') && function_exists('libxml_clear_errors') && class_exists('\DOMDocument'))) {
            return $htmlSource;
        }

        // First, collect all MSIE comments
        preg_match_all('#<!--\[if(.*?)]>(<!-->|-->|\s|)(.*?)(<!--<!|<!)\[endif]-->#si', $htmlSource, $matchedMSIEComments);

        $allMSIEComments = array();

        if (isset($matchedMSIEComments[0]) && ! empty($matchedMSIEComments[0])) {
            foreach ($matchedMSIEComments[0] as $matchedMSIEComment) {
                $allMSIEComments[] = $matchedMSIEComment;
            }
        }

        if (! ($domTag = ObjectCache::wpacu_cache_get('wpacu_html_dom_tag'))) {
            $domTag = new \DOMDocument();
            libxml_use_internal_errors( true );
            $domTag->loadHTML( $htmlSource );
        }

        $xpathComments = new \DOMXPath($domTag);
        $comments = $xpathComments->query('//comment()');

        libxml_clear_errors();

        if ($comments === null) {
            return $htmlSource;
        }

        preg_match_all('#<!--(.*?)-->#s', $htmlSource, $matchesRegExpComments);

        // "comments" within tag attributes or script tags?
        // e.g. <script>var type='<!-- A comment here -->';</script>
        // e.g. <div data-info="This is just a <!-- comment --> text">Content here</div>
        $commentsWithinQuotes = array();

        if (isset($matchesRegExpComments[1]) && count($matchesRegExpComments[1]) !== count($comments)) {
            preg_match_all('#=(|\s+)([\'"])(|\s+)<!--(.*?)-->(|\s+)([\'"])#s', $htmlSource, $matchesCommentsWithinQuotes);

            if (isset($matchesCommentsWithinQuotes[0]) && ! empty($matchesCommentsWithinQuotes[0])) {
                foreach ($matchesCommentsWithinQuotes[0] as $matchedDataOriginal) {
                    $matchedDataUpdated = str_replace(
                        array('', '<!--', '-->'),
                        array('--wpacu-space-del--', '--wpacu-start-comm--', '--wpacu-end-comm--'),
                        $matchedDataOriginal
                    );

                    $htmlSource = str_replace($matchedDataOriginal, $matchedDataUpdated, $htmlSource);

                    $commentsWithinQuotes[] = array(
                        'original' => $matchedDataOriginal,
                        'updated'  => $matchedDataUpdated
                    );
                }
            }
        }

        foreach ($comments as $comment) {
            $entireComment = CleanUp::getOuterHTML($comment);

            $htmlSource = str_replace(
                array(
                    $entireComment,
                    '<!--' . $comment->nodeValue . '-->'
                ),
                '',
                $htmlSource
            );
        }

        if (! empty($commentsWithinQuotes)) {
            foreach ($commentsWithinQuotes as $commentQuote) {
                $htmlSource = str_replace($commentQuote['updated'], $commentQuote['original'], $htmlSource);
            }
        }

        return $htmlSource;
    }
    */
    //endRemoveIf(development)

    /**
     * @param $htmlSource
     *
     * @return array
     */
    
public static function extractHtmlFromConditionalComments($htmlSource)
    {
        
preg_match_all('#<!--\[if(.*?)]>(<!-->|-->|\s|)(.*?)(<!--<!|<!)\[endif]-->#si'$htmlSource$matchedContent);

        if (isset(
$matchedContent[1], $matchedContent[3]) && ! empty($matchedContent[1]) && ! empty($matchedContent[3])) {
            
$conditions array_map('trim'$matchedContent[1]);
            
$tags       array_map('trim'$matchedContent[3]);

            return array(
                
'conditions' => $conditions,
                
'tags'       => $tags,
            );
        }

        return array();
    }

    
/**
     * @param $targetedTag
     * @param $contentWithinConditionalComments
     *
     * @return bool
     */
    
public static function isWithinConditionalComment($targetedTag$contentWithinConditionalComments)
    {
        if (empty(
$contentWithinConditionalComments)) {
            return 
false;
        }

        
$targetedTag trim($targetedTag);

        foreach (
$contentWithinConditionalComments['tags'] as $tagIndex => $tagFromList) {
            
$tagFromList trim($tagFromList);

            if (
$targetedTag === $tagFromList || strpos($targetedTag$tagFromList) !== false) {
                return 
$contentWithinConditionalComments['conditions'][$tagIndex]; // Stops here and returns the condition
                
break;
            }
        }

        return 
false// Not within a conditional comment (most cases)
    
}

    
/**
     * @param $htmlTag
     *
     * @return bool|string
     */
    
public static function belongsTo($htmlTag)
    {
        
$belongList = array(
            
'wpcf7recaptcha.' => '"Contact Form 7" plugin',
            
'c = c.replace(/woocommerce-no-js/, \'woocommerce-js\');' => '"WooCommerce" plugin',
            
'.woocommerce-product-gallery{ opacity: 1 !important; }'  => '"WooCommerce" plugin',
            
'-ss-slider-3' => '"Smart Slider 3" plugin',
            
'N2R(["nextend-frontend","smartslider-frontend","smartslider-simple-type-frontend"]' => '"Smart Slider 3" plugin',
            
'function setREVStartSize' => '"Slider Revolution" plugin',
            
'jQuery(\'.rev_slider_wrapper\')' => '"Slider Revolution" plugin',
            
'jQuery(\'#wp-admin-bar-revslider-default' => '"Slider Revolution" plugin'
        
);

        foreach (
$belongList as $ifContains => $isFromSource) {
            if ( 
strpos$htmlTag$ifContains) !== false ) {
                return 
$isFromSource;
            }
        }

        return 
false;
    }

    
/**
     * @param $data
     *
     * @return string
     */
    
public static function getHardCodedManageAreaForFrontEndView($data)
    {
        
$dataSettingsFrontEnd ObjectCache::wpacu_cache_get('wpacu_settings_frontend_data') ?: array();
        
$dataSettingsFrontEnd['page_unload_text'] = $data['page_unload_text'];
        
// The following string will be replaced by the values got the from the AJAX call to /?wpassetcleanup_load=1&wpacu_just_hardcoded
        
$dataWpacuSettingsFrontend base64_encode(json_encode($dataSettingsFrontEnd));
        
$imgLoadingSpinnerUrl admin_url('images/spinner.gif');

        
$currentHardcodedAssetRules '';

        
// When the form is submitted it will clear some values if they are not sent anymore which can happen with a failed AJAX call to retrieve the list of hardcoded assets
        // Place the current values to the area in case the AJAX call fails and it won't print the list
        // If the user presses "Update", it won't clear any existing rules
        // If the list is printed, obviously it will be with all the fields in place as they should be
        
foreach (array('current''load_exceptions''handle_unload_regex''handle_load_regex''handle_load_logged_in') as $ruleKey) {
            foreach ( array( 
'styles''scripts' ) as $assetType ) {
                if ( isset( 
$dataSettingsFrontEnd[$ruleKey][ $assetType ] ) && ! empty( $dataSettingsFrontEnd[$ruleKey][$assetType] ) ) {
                    
// Go through the values, depending on how the array is structured
                    // handle_unload_regex, handle_load_regex
                    
if (in_array($ruleKey, array('handle_unload_regex''handle_load_regex'))) {
                        foreach ( 
$dataSettingsFrontEnd$ruleKey ][ $assetType ] as $assetHandle => $assetValues ) {
                            if ( 
strpos$assetHandle'wpacu_hardcoded_' ) !== false ) {
                                if (
$ruleKey === 'handle_unload_regex') {
                                    
$enableValue                = isset( $assetValues['enable'] ) ? $assetValues['enable'] : '';
                                    
$regExValue                 = isset( $assetValues['value'] ) ? $assetValues['value']   : '';
                                    
$currentHardcodedAssetRules .= '<input type="hidden" name="wpacu_handle_unload_regex[' $assetType '][' $assetHandle '][enable]" value="' $enableValue '" />';
                                    
$currentHardcodedAssetRules .= '<input type="hidden" name="wpacu_handle_unload_regex[' $assetType '][' $assetHandle '][value]"  value="' esc_attr$regExValue ) . '" />';
                                } elseif (
$ruleKey === 'handle_load_regex') {
                                    
$enableValue                = isset( $assetValues['enable'] ) ? $assetValues['enable'] : '';
                                    
$regExValue                 = isset( $assetValues['value'] ) ? $assetValues['value']   : '';
                                    
$currentHardcodedAssetRules .= '<input type="hidden" name="wpacu_handle_load_regex[' $assetType '][' $assetHandle '][enable]" value="' $enableValue '" />';
                                    
$currentHardcodedAssetRules .= '<input type="hidden" name="wpacu_handle_load_regex[' $assetType '][' $assetHandle '][value]"  value="' esc_attr$regExValue ) . '" />';
                                }
                            }
                        }
                    } else {
                        
// current, load_exceptions, handle_load_logged_in
                        
foreach ( $dataSettingsFrontEnd$ruleKey ][ $assetType ] as $assetHandle ) {
                            if ( 
strpos$assetHandle'wpacu_hardcoded_' ) !== false ) {
                                if ( 
$ruleKey === 'current' ) {
                                    
$currentHardcodedAssetRules .= '<input type="hidden" name="wpassetcleanup[' $assetType '][]" value="' $assetHandle '" />';
                                } elseif ( 
$ruleKey === 'load_exceptions' ) {
                                    
$currentHardcodedAssetRules .= '<input type="hidden" name="wpacu_styles_load_it[]" value="' $assetHandle '" />';
                                } elseif (
$ruleKey === 'handle_load_logged_in') {
                                    
$currentHardcodedAssetRules .= '<input type="hidden" name="wpacu_load_it_logged_in['.$assetType.']['.$assetHandle.']" value="1" />';
                                }
                            }
                        }
                    }
                }
            }
        }

        
$hardcodedManageAreaHtml = <<<HTML
<div class="wpacu-assets-collapsible-wrap wpacu-wrap-area wpacu-hardcoded" id="wpacu-assets-collapsible-wrap-hardcoded-list" data-wpacu-settings-frontend="{$dataWpacuSettingsFrontend}">
    <a class="wpacu-assets-collapsible wpacu-assets-collapsible-active" href="#" style="padding: 15px 15px 15px 44px;"><span class="dashicons dashicons-code-standards"></span> Hardcoded (non-enqueued) Styles &amp; Scripts</a>
    <div class="wpacu-assets-collapsible-content" style="max-height: inherit;">
        <div style="padding: 20px 0; margin: 0;"><img src="
{$imgLoadingSpinnerUrl}" align="top" width="20" height="20" alt="" /> The list of hardcoded assets is fetched... Please wait...</div>
        
{$currentHardcodedAssetRules}
    </div>
</div>
HTML;

        return 
$hardcodedManageAreaHtml;
    }
}
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586