Completed
Branch dev (aae49a)
by
unknown
19:32
created

_printClassSpecificScripts()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 25
Code Lines 16

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 25
rs 8.8571
cc 2
eloc 16
nc 2
nop 1
1
<?php 
2
/**
3
 * Admin Page Framework
4
 * 
5
 * http://en.michaeluno.jp/admin-page-framework/
6
 * Copyright (c) 2013-2015 Michael Uno; Licensed MIT
7
 * 
8
 */
9
10
/**
11
 * Provides methods to enqueue or insert resource elements.
12
 *  
13
 * The class handles `<link>`, `<style>` and `<script>` tags to be inserted conditionally into the head tag or the footer of the page.
14
 * 
15
 * @abstract
16
 * @since       2.1.5
17
 * @since       3.3.0       Changed the name from `AdminPageFramework_HeadTag_Base`.
18
 * @since       3.6.3       Changed it to extend `AdminPageFramework_WPUtility`.
19
 * @use         AdminPageFramework_Utility
20
 * @package     AdminPageFramework
21
 * @subpackage  Resource
22
 * @internal
23
 */
24
abstract class AdminPageFramework_Resource_Base extends AdminPageFramework_WPUtility {
2 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
Coding Style introduced by
As per PSR2, the opening brace for this class should be on a new line.
Loading history...
25
    
26
    /**
27
     * Represents the structure of the array for enqueuing scripts and styles.
28
     * 
29
     * @since       2.1.2
30
     * @since       2.1.5       Moved to the base class.
31
     * @since       3.0.0       Moved from the property class.
32
     * @since       3.3.0       Changed the name to `$_aStructure_EnqueuingResources` from `$_aStructure_EnqueuingScriptsAndStyles`.
33
     * @internal
34
     */
35
    protected static $_aStructure_EnqueuingResources = array(
1 ignored issue
show
Coding Style introduced by
Please declare explicit visibility instead of using a prefixed underscore.
Loading history...
36
    
37
        /* The system internal keys. */
38
        'sSRC'          => null,
39
        'aPostTypes'    => array(),     // for meta box class
40
        'sPageSlug'     => null,    
41
        'sTabSlug'      => null,
42
        'sType'         => null,        // script or style
43
        
44
        /* The below keys are for users. */
45
        'handle_id'     => null,
46
        'dependencies'  => array(),
47
        'version'       => false,       // although the type should be string, the wp_enqueue_...() functions want false as the default value.
48
        'translation'   => array(),     // only for scripts
49
        'in_footer'     => false,       // only for scripts
50
        'media'         => 'all',       // only for styles     
51
        'attributes'    => array(),     // 3.3.0+ - the attribute array
52
        
53
    );    
54
      
55
    /**
56
     * Stores the class selector used for the class-specific style.
57
     * 
58
     * @since       3.2.0
59
     * @remark      This value should be overridden in an extended class.
60
     * @internal
61
     */
62
    protected $_sClassSelector_Style    = 'admin-page-framework-style';
1 ignored issue
show
Coding Style introduced by
Please declare explicit visibility instead of using a prefixed underscore.
Loading history...
63
    
64
    /**
65
     * Stores the class selector used to the class-specific script.
66
     * 
67
     * @since       3.2.0
68
     * @remark      This value should be overridden in an extended class.
69
     * @internal
70
     */    
71
    protected $_sClassSelector_Script   = 'admin-page-framework-script';
1 ignored issue
show
Coding Style introduced by
Please declare explicit visibility instead of using a prefixed underscore.
Loading history...
72
      
73
    /**
74
     * Stores hand IDs by resource url to look up handle id and add custom arguments.
75
     * @since       3.3.0
76
     * @internal
77
     */ 
78
    protected $_aHandleIDs = array();
1 ignored issue
show
Coding Style introduced by
Please declare explicit visibility instead of using a prefixed underscore.
Loading history...
79
      
80
    /**
81
     * A property object.
82
     * 
83
     * @remark      Set in the constructor.
84
     */ 
85
    public $oProp;
86
    
87
    /**
88
     * A utility object.
89
     * 
90
     * @remark      Set in the constructor.
91
     * @deprecated  3.6.3
92
     * @remark      kept for backward compatibility.
93
     */
94
    public $oUtil;
95
    
96
    /**
97
     * Sets up properties and hooks.
98
     * @internal
99
     */
100
    function __construct( $oProp ) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
101
        
102
        $this->oProp = $oProp;
103
        
104
        // for backward compatibility
105
        $this->oUtil = new AdminPageFramework_WPUtility;
0 ignored issues
show
Deprecated Code introduced by
The property AdminPageFramework_Resource_Base::$oUtil has been deprecated with message: 3.6.3

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
106
        
107
        if ( $this->isDoingAjax() ) {
108
            return;
109
        }        
110
        
111
        // Hook the admin header to insert custom admin stylesheets and scripts.
112
        add_action( 'admin_enqueue_scripts', array( $this, '_replyToEnqueueScripts' ) );
113
        add_action( 'admin_enqueue_scripts', array( $this, '_replyToEnqueueStyles' ) );
114
        
115
        /// A low priority is required to let dependencies loaded fast especially in customizer.php.
116
        add_action( did_action( 'admin_print_styles' ) ? 'admin_print_footer_scripts' : 'admin_print_styles', array( $this, '_replyToAddStyle' ), 999 );
117
        add_action( did_action( 'admin_print_scripts' ) ? 'admin_print_footer_scripts' : 'admin_print_scripts', array( $this, '_replyToAddScript' ), 999 );     
118
    
119
        // Take care of items that could not be added in the head tag.
120
        
121
        /// For wp-admin/customizer.php 
122
        add_action( 'customize_controls_print_footer_scripts', array( $this, '_replyToEnqueueScripts' ) );
123
        add_action( 'customize_controls_print_footer_scripts', array( $this, '_replyToEnqueueStyles' ) );
124
125
        /// For admin pages other than wp-admin/customizer.php 
126
        add_action( 'admin_footer', array( $this, '_replyToEnqueueScripts' ) ); 
127
        add_action( 'admin_footer', array( $this, '_replyToEnqueueStyles' ) );        
128
        
129
        /// For all admin pages.
130
        add_action( 'admin_print_footer_scripts', array( $this, '_replyToAddStyle' ), 999 );
131
        add_action( 'admin_print_footer_scripts', array( $this, '_replyToAddScript' ), 999 );  
132
        
133
        
134
        // To add the custom attributes to the enqueued style and script tags.
135
        add_filter( 'script_loader_src', array( $this, '_replyToSetupArgumentCallback' ), 1, 2 );
136
        add_filter( 'style_loader_src', array( $this, '_replyToSetupArgumentCallback' ), 1, 2 );
137
138
    }    
139
                
140
    /*
141
     * Methods that should be overridden in extended classes.
142
     * @internal
143
     */
144
    
145
    public function _forceToEnqueueStyle( $sSRC, $aCustomArgs=array() ) {}
1 ignored issue
show
Coding Style introduced by
Method name "_forceToEnqueueStyle" should not be prefixed with an underscore to indicate visibility
Loading history...
146
    public function _forceToEnqueueScript( $sSRC, $aCustomArgs=array() ) {}
1 ignored issue
show
Coding Style introduced by
Method name "_forceToEnqueueScript" should not be prefixed with an underscore to indicate visibility
Loading history...
147
    
148
    /**
149
     * A helper function for the _replyToEnqueueScripts() and the `_replyToEnqueueStyle()` methods.
150
     * 
151
     * @since       2.1.5
152
     * @since       DEVVER      Fixed a typo in the method name.
153
     * @internal
154
     * @remark      The widget fields type does not have conditions unlike the meta-box type that requires to check currently loaded post type.
155
     * @remark      This method should be redefined in the extended class.
156
     */
157
    protected function _enqueueSRCByCondition( $aEnqueueItem ) {
1 ignored issue
show
Coding Style introduced by
Method name "_enqueueSRCByCondition" should not be prefixed with an underscore to indicate visibility
Loading history...
158
        return $this->_enqueueSRC( $aEnqueueItem );            
159
    }
160
    
161
    /*
162
     * Shared methods
163
     */
164
        /**
165
         * Checks the src url of the enqueued script/style to determine whether or not to set up a attribute modification callback.
166
         * 
167
         * If it is one of the framework added item, the method sets up a hook to modify the url to add custom attributes.
168
         * 
169
         * @since       3.3.0
170
         * @internal
171
         * @callback    action      script_loader_src
172
         * @callback    action      style_loader_src
173
         */
174
        public function _replyToSetupArgumentCallback( $sSRC, $sHandleID ) {
1 ignored issue
show
Coding Style introduced by
Method name "_replyToSetupArgumentCallback" should not be prefixed with an underscore to indicate visibility
Loading history...
175
176
            if ( isset( $this->oProp->aResourceAttributes[ $sHandleID ] ) ) {
177
                $this->_aHandleIDs[ $sSRC ] = $sHandleID;
178
                add_filter( 'clean_url', array( $this, '_replyToModifyEnqueuedAttrbutes' ), 1, 3 );
179
                remove_filter( current_filter(), array( $this, '_replyToSetupArgumentCallback' ), 1, 2 );
180
            }
181
            return $sSRC;
182
            
183
        }    
184
            /**
185
             * Modifies the attributes of the enqueued script tag.
186
             * 
187
             * @since   3.3.0
188
             * @internal
189
             */
190
            public function _replyToModifyEnqueuedAttrbutes( $sSanitizedURL, $sOriginalURL, $sContext ) {
1 ignored issue
show
Coding Style introduced by
Method name "_replyToModifyEnqueuedAttrbutes" should not be prefixed with an underscore to indicate visibility
Loading history...
191
                
192
                if ( 'display' !== $sContext ) {
193
                    return $sSanitizedURL;
194
                }
195
            
196
                // Returns the modified url which attributes are embedded at the end.
197
                if ( isset( $this->_aHandleIDs[ $sOriginalURL ] ) ) {
198
                    
199
                    $_sHandleID     = $this->_aHandleIDs[ $sOriginalURL ];
200
                    $_aAttributes   = $this->oProp->aResourceAttributes[ $_sHandleID ];
201
                    
202
                    if ( empty( $_aAttributes ) ) {
203
                        return $sSanitizedURL;
204
                    }
205
                    
206
                    $_sAttributes   = $this->getAttributes( $_aAttributes );
207
                    $_sModifiedURL  = $sSanitizedURL . "' " . rtrim( $_sAttributes, "'\"" );    // '"
208
209
                    return $_sModifiedURL;                    
210
                    
211
                }
212
213
                return $sSanitizedURL;
214
             
215
            }
216
     
217
     
218
    /**
219
     * Flags whether the common styles are loaded or not.
220
     * 
221
     * @since       3.2.0
222
     * @internal
223
     */
224
    static private $_bCommonStyleLoaded = false;
1 ignored issue
show
Coding Style introduced by
Please declare explicit visibility instead of using a prefixed underscore.
Loading history...
225
    
226
    /**
227
     * Prints the inline stylesheet of the meta-box common CSS rules with the style tag.
228
     * 
229
     * @internal
230
     * @since       3.0.0
231
     * @since       3.2.0       Moved to the base class from the meta box class.
232
     * @remark      The meta box class may be instantiated multiple times so prevent echoing the same styles multiple times.
233
     * @parameter   string      $sIDPrefix   The id selector embedded in the script tag.
234
     * @parameter   string      $sClassName  The class name that identify the call group. This is important for the meta-box class because it can be instantiated multiple times in one particular page.
235
     */
236
    protected function _printCommonStyles( $sIDPrefix, $sClassName ) {
1 ignored issue
show
Unused Code introduced by
The parameter $sClassName is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Coding Style introduced by
Method name "_printCommonStyles" should not be prefixed with an underscore to indicate visibility
Loading history...
237
238
        if ( self::$_bCommonStyleLoaded ) { 
239
            return; 
240
        }
241
        self::$_bCommonStyleLoaded = true;
242
        
243
        $_oCaller = $this->oProp->_getCallerObject();     
244
        echo $this->_getStyleTag( $_oCaller, $sIDPrefix );
245
        echo $this->_getIEStyleTag( $_oCaller, $sIDPrefix );
246
            
247
    }   
248
        /**
249
         * @internal
250
         * @since       3.5.7
251
         * @return      string
252
         */
253
        private function _getStyleTag( $oCaller, $sIDPrefix ) {
1 ignored issue
show
Coding Style introduced by
Method name "_getStyleTag" should not be prefixed with an underscore to indicate visibility
Loading history...
254
            
255
            $_sStyle     = $this->addAndApplyFilters( 
256
                $oCaller, 
257
                array(
258
                    "style_common_admin_page_framework",            // 3.2.1+
259
                    "style_common_{$this->oProp->sClassName}",
260
                ), 
261
                AdminPageFramework_CSS::getDefaultCSS() 
262
            );
263
            $_sStyle     = $this->isDebugMode()
264
                ? trim( $_sStyle )
265
                : $this->minifyCSS( $_sStyle );
266
            if ( $_sStyle ) {
267
                echo "<style type='text/css' id='" . esc_attr( $sIDPrefix ) . "'>"
268
                        . $_sStyle
269
                    . "</style>";
270
            }
271
         
272
            
273
        }    
274
        /**
275
         * @internal
276
         * @since       3.5.7
277
         * @return      string
278
         */        
279
        private function _getIEStyleTag( $oCaller, $sIDPrefix ) {
1 ignored issue
show
Coding Style introduced by
Method name "_getIEStyleTag" should not be prefixed with an underscore to indicate visibility
Loading history...
280
                
281
            $_sStyleIE   = $this->addAndApplyFilters( 
282
                $oCaller, 
283
                array(
284
                    "style_ie_common_admin_page_framework",         // 3.2.1+
285
                    "style_ie_common_{$this->oProp->sClassName}", 
286
                ),
287
                AdminPageFramework_CSS::getDefaultCSSIE() 
288
            );
289
            
290
            $_sStyleIE   = $this->isDebugMode()
291
                ? trim( $_sStyleIE )
292
                : $this->minifyCSS( $_sStyleIE );
293
            return $_sStyleIE
294
                ? "<!--[if IE]><style type='text/css' id='" . esc_attr( $sIDPrefix . "-ie" ) . "'>"
295
                        . $_sStyleIE
296
                    . "</style><![endif]-->"
297
                : '';
298
    
299
        }
300
    
301
    /**
302
     * Flags whether the common styles are loaded or not.
303
     * 
304
     * @since       3.2.0
305
     * @internal
306
     */
307
    static private $_bCommonScriptLoaded = false;
1 ignored issue
show
Coding Style introduced by
Please declare explicit visibility instead of using a prefixed underscore.
Loading history...
308
    
309
    /**
310
     * Prints the inline scripts of the meta-box common scripts.
311
     * 
312
     * @internal
313
     * @since       3.0.0
314
     * @since       3.2.0       Moved to the base class from the meta box class.       
315
     * @remark      The meta box class may be instantiated multiple times so prevent echoing the same styles multiple times.
316
     * @parametr    string      $sIDPrefix      The id selector embedded in the script tag.
317
     * @parametr    string      $sClassName     The class name that identify the call group. This is important for the meta-box class because it can be instantiated multiple times in one particular page.
318
     */
319
    protected function _printCommonScripts( $sIDPrefix, $sClassName ) {
1 ignored issue
show
Unused Code introduced by
The parameter $sClassName is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Coding Style introduced by
Method name "_printCommonScripts" should not be prefixed with an underscore to indicate visibility
Loading history...
320
        
321
        if ( self::$_bCommonScriptLoaded ) { return; }
322
        self::$_bCommonScriptLoaded = true;
323
        
324
        $_sScript = $this->addAndApplyFilters( 
325
            $this->oProp->_getCallerObject(), 
326
            array(
327
                "script_common_admin_page_framework",       // 3.2.1+
328
                "script_common_{$this->oProp->sClassName}", 
329
            ),
330
            AdminPageFramework_Property_Base::$_sDefaultScript 
331
        );
332
        $_sScript = trim( $_sScript );
333
        if ( $_sScript ) {
334
            echo "<script type='text/javascript' id='" . esc_attr( $sIDPrefix ) . "'>"
335
                    . '/* <![CDATA[ */'
336
                    . $_sScript
337
                    . '/* ]]> */'
338
                . "</script>";
339
        }
340
    
341
    }    
342
     
343
    /**
344
     * Prints the inline stylesheet of this class stored in this class property.
345
     * 
346
     * @since       3.0.0
347
     * @since       3.2.0       Made the properties storing styles empty. Moved to the base class.
348
     * @internal
349
     * @return      void
350
     */
351
    protected function _printClassSpecificStyles( $sIDPrefix ) {
1 ignored issue
show
Coding Style introduced by
Method name "_printClassSpecificStyles" should not be prefixed with an underscore to indicate visibility
Loading history...
352
           
353
        $_oCaller   = $this->oProp->_getCallerObject();     
354
        echo $this->_getClassSpecificStyleTag( $_oCaller, $sIDPrefix );
355
        echo $this->_getClassSpecificIEStyleTag( $_oCaller, $sIDPrefix );
356
        
357
        // As of 3.2.0, this method also gets called in the footer to ensure there is not any left styles.
358
        // This happens when a head tag item is added after the head tag is already rendered such as for widget forms.
359
        $this->oProp->sStyle    = '';          
360
        $this->oProp->sStyleIE  = '';
361
    
362
    }
363
        /**
364
         * 
365
         * @internal
366
         * @since       3.5.7
367
         * @return      string
368
         */
369
        private function _getClassSpecificStyleTag( $_oCaller, $sIDPrefix ) {
1 ignored issue
show
Coding Style introduced by
Method name "_getClassSpecificStyleTag" should not be prefixed with an underscore to indicate visibility
Loading history...
370
            
371
            static $_iCallCount = 1;    
372
            $_sStyle = $this->addAndApplyFilters( 
373
                $_oCaller, 
374
                "style_{$this->oProp->sClassName}", 
375
                $this->oProp->sStyle 
376
            );
377
            $_sStyle = $this->isDebugMode()
378
                ? trim( $_sStyle )
379
                : $this->minifyCSS( $_sStyle );
380
            if ( $_sStyle ) {
381
                return "<style type='text/css' id='" . esc_attr( "{$sIDPrefix}-{$this->oProp->sClassName}_{$_iCallCount}" ) . "'>"
382
                        . $_sStyle
383
                    . "</style>";
384
                $_iCallCount++;
0 ignored issues
show
Unused Code introduced by
$_iCallCount++; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
385
            }         
386
            return '';
387
            
388
        }
389
        /**
390
         * 
391
         * @internal
392
         * @since       3.5.7
393
         * @return      string
394
         */        
395
        private function _getClassSpecificIEStyleTag( $_oCaller, $sIDPrefix ) {
1 ignored issue
show
Coding Style introduced by
Method name "_getClassSpecificIEStyleTag" should not be prefixed with an underscore to indicate visibility
Loading history...
396
            
397
            static $_iCallCountIE = 1;  
398
            $_sStyleIE = $this->addAndApplyFilters( 
399
                $_oCaller,
400
                "style_ie_{$this->oProp->sClassName}",
401
                $this->oProp->sStyleIE 
402
            );
403
            $_sStyleIE = $this->isDebugMode()
404
                ? trim( $_sStyleIE )
405
                : $this->minifyCSS( $_sStyleIE );
406
            if ( $_sStyleIE ) {
407
                return "<!--[if IE]><style type='text/css' id='" . esc_attr( "{$sIDPrefix}-ie-{$this->oProp->sClassName}_{$_iCallCountIE}" ) . "'>" 
408
                        . $_sStyleIE
409
                    . "</style><![endif]-->";
410
                $_iCallCountIE++;
0 ignored issues
show
Unused Code introduced by
$_iCallCountIE++; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
411
            }            
412
            return '';
413
            
414
        }
415
        
416
    /**
417
     * Prints the inline scripts of this class stored in this class property.
418
     * 
419
     * @since       3.0.0
420
     * @since       3.2.0       Made the property empty that stores scripts. Moved to the base class.
421
     * @internal
422
     */
423
    protected function _printClassSpecificScripts( $sIDPrefix ) {
1 ignored issue
show
Coding Style introduced by
Method name "_printClassSpecificScripts" should not be prefixed with an underscore to indicate visibility
Loading history...
424
        
425
        static $_iCallCount = 1;
426
        $_sScript = $this->addAndApplyFilters( 
427
            $this->oProp->_getCallerObject(),
428
            array(
429
                "script_{$this->oProp->sClassName}", 
430
            ),
431
            $this->oProp->sScript 
432
        );
433
        $_sScript = trim( $_sScript );
434
        if ( $_sScript ) {
435
            echo "<script type='text/javascript' id='" . esc_attr( "{$sIDPrefix}-{$this->oProp->sClassName}_{$_iCallCount}" ) . "'>" 
436
                    . '/* <![CDATA[ */'
437
                    . $_sScript
438
                    . '/* ]]> */'
439
                . "</script>"; 
440
            $_iCallCount++;
441
        }
442
        
443
        // As of 3.2.0, this method also gets called in the footer to ensure there is not any left scripts.
444
        // This happens when a head tag item is added after the head tag is already rendered such as for widget forms.
445
        $this->oProp->sScript = '';
446
        
447
    }     
448
449
    
450
    /**
451
     * Appends the CSS rules of the framework in the head tag. 
452
     * 
453
     * @since       2.0.0
454
     * @since       2.1.5       Moved from `AdminPageFramework_MetaBox`. Changed the name from `addAtyle()` to `replyToAddStyle()`.
455
     * @callback    action      admin_head
456
     * @internal
457
     */     
458
    public function _replyToAddStyle() {
1 ignored issue
show
Coding Style introduced by
Method name "_replyToAddStyle" should not be prefixed with an underscore to indicate visibility
Loading history...
459
    
460
        $_oCaller = $this->oProp->_getCallerObject();     
461
        if ( ! $_oCaller->_isInThePage() ) {
462
            return; 
463
        }
464
        
465
        $this->_printCommonStyles( 'admin-page-framework-style-common', get_class() );
466
        $this->_printClassSpecificStyles( $this->_sClassSelector_Style . '-' . $this->oProp->sStructureType );
467
 
468
    }
469
    /**
470
     * Appends the JavaScript script of the framework in the head tag. 
471
     * 
472
     * @callback    action      admin_head
473
     * @since       2.0.0
474
     * @since       2.1.5       Moved from AdminPageFramework_MetaBox. Changed the name from `addScript()` to `replyToAddScript()`.
475
     * @since       3.2.0       Moved from AdminPageFramework_Resource_MetaBox. 
476
     * @internal
477
     */ 
478
    public function _replyToAddScript() {
1 ignored issue
show
Coding Style introduced by
Method name "_replyToAddScript" should not be prefixed with an underscore to indicate visibility
Loading history...
479
480
        $_oCaller = $this->oProp->_getCallerObject();     
481
        if ( ! $_oCaller->_isInThePage() ) { 
482
            return; 
483
        }
484
        
485
        $this->_printCommonScripts( 'admin-page-framework-script-common', get_class() );
486
        $this->_printClassSpecificScripts( $this->_sClassSelector_Script . '-' . $this->oProp->sStructureType );
487
        
488
    }        
489
    
490
     
491
    /**
492
     * Performs actual enqueuing items. 
493
     * 
494
     * @since       2.1.2
495
     * @since       2.1.5       Moved from the main class.
496
     * @internal
497
     */
498
    protected function _enqueueSRC( $aEnqueueItem ) {
1 ignored issue
show
Coding Style introduced by
Method name "_enqueueSRC" should not be prefixed with an underscore to indicate visibility
Loading history...
499
        
500
        // For styles
501
        if ( 'style' === $aEnqueueItem['sType'] ) {
502
            wp_enqueue_style( 
503
                $aEnqueueItem['handle_id'], 
504
                $aEnqueueItem['sSRC'], 
505
                $aEnqueueItem['dependencies'], 
506
                $aEnqueueItem['version'], 
507
                $aEnqueueItem['media']
508
            );
509
            return;
510
        }
511
512
        // For scripts
513
        wp_enqueue_script( 
514
            $aEnqueueItem['handle_id'], 
515
            $aEnqueueItem['sSRC'], 
516
            $aEnqueueItem['dependencies'], 
517
            $aEnqueueItem['version'], 
518
            did_action( 'admin_body_class' ) ? true : $aEnqueueItem['in_footer'] 
519
        );
520
    
521
        if ( $aEnqueueItem['translation'] ) {
522
            wp_localize_script( $aEnqueueItem['handle_id'], $aEnqueueItem['handle_id'], $aEnqueueItem['translation'] );
523
        }
524
        
525
    }
526
    
527
    /**
528
     * Takes care of added enqueuing scripts by checking the currently loading page.
529
     * 
530
     * @remark      A callback for the admin_enqueue_scripts hook.
531
     * @since       2.1.2
532
     * @since       2.1.5   Moved from the main class. Changed the name from `enqueueStylesCalback` to `replyToEnqueueStyles()`.
533
     * @since       3.0.0   Changed the name to `_replyToEnqueueStyles()`.
534
     * @since       3.2.0   Changed it unset the enqueued item so that the method can be called multiple times.
535
     * @internal
536
     */    
537
    public function _replyToEnqueueStyles() {        
1 ignored issue
show
Coding Style introduced by
Method name "_replyToEnqueueStyles" should not be prefixed with an underscore to indicate visibility
Loading history...
538
        foreach( $this->oProp->aEnqueuingStyles as $_sKey => $_aEnqueuingStyle ) {
539
            $this->_enqueueSRCByCondition( $_aEnqueuingStyle );
540
            unset( $this->oProp->aEnqueuingStyles[ $_sKey ] );
541
        }
542
    }
543
    
544
    /**
545
     * Takes care of added enqueuing scripts by page slug and tab slug.
546
     * 
547
     * @remark      A callback for the admin_enqueue_scripts hook.
548
     * @since       2.1.2
549
     * @since       2.1.5   Moved from the main class. Changed the name from `enqueueScriptsCallback` to `callbackEnqueueScripts()`.
550
     * @since       3.0.0   Changed the name to `_replyToEnqueueScripts()`.
551
     * @since       3.2.0   Changed it unset the enqueued item so that the method can be called multiple times.
552
     * @internal
553
     */
554
    public function _replyToEnqueueScripts() {     
1 ignored issue
show
Coding Style introduced by
Method name "_replyToEnqueueScripts" should not be prefixed with an underscore to indicate visibility
Loading history...
555
        foreach( $this->oProp->aEnqueuingScripts as $_sKey => $_aEnqueuingScript ) {
556
            $this->_enqueueSRCByCondition( $_aEnqueuingScript );     
557
            unset( $this->oProp->aEnqueuingScripts[ $_sKey ] );
558
        }
559
    }
560
    
561
}
1 ignored issue
show
Coding Style introduced by
According to PSR2, the closing brace of classes should be placed on the next line directly after the body.

Below you find some examples:

// Incorrect placement according to PSR2
class MyClass
{
    public function foo()
    {

    }
    // This blank line is not allowed.

}

// Correct
class MyClass
{
    public function foo()
    {

    } // No blank lines after this line.
}
Loading history...