Completed
Branch dev (ee71a7)
by
unknown
03:39
created
admin_page/_model/delegate/AdminPageFramework_Model_Menu__RegisterMenu.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
      * 
28 28
      * @internal
29 29
      */
30
-    public function __construct( $oFactory, $sActionHook='admin_menu' ) {
30
+    public function __construct( $oFactory, $sActionHook = 'admin_menu' ) {
31 31
         
32 32
         $this->oFactory = $oFactory;
33 33
         
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     public function _replyToRegisterRootMenu() {
76 76
         
77 77
         // If the root menu label is not set but the slug is set, 
78
-        if ( ! $this->oFactory->oProp->aRootMenu[ 'fCreateRoot' ] ) {
78
+        if ( !$this->oFactory->oProp->aRootMenu[ 'fCreateRoot' ] ) {
79 79
             return;
80 80
         }
81 81
         $this->_registerRootMenuPage();
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
             }
98 98
 
99 99
             $this->oFactory->oProp->aRootMenu[ '_page_hook' ] = add_menu_page(  
100
-                $this->oFactory->oProp->sClassName,                 // Page title - will be invisible anyway
101
-                $this->oFactory->oProp->aRootMenu[ 'sTitle' ],      // Menu title - should be the root page title.
102
-                $this->oFactory->oProp->sCapability,                // Capability - access right
103
-                $this->oFactory->oProp->aRootMenu[ 'sPageSlug' ],   // Menu ID 
104
-                '',                                       // Callback function for the page content output - the root page will be removed so no need to register a function.
105
-                $this->oFactory->oProp->aRootMenu[ 'sIcon16x16' ],  // icon path
100
+                $this->oFactory->oProp->sClassName, // Page title - will be invisible anyway
101
+                $this->oFactory->oProp->aRootMenu[ 'sTitle' ], // Menu title - should be the root page title.
102
+                $this->oFactory->oProp->sCapability, // Capability - access right
103
+                $this->oFactory->oProp->aRootMenu[ 'sPageSlug' ], // Menu ID 
104
+                '', // Callback function for the page content output - the root page will be removed so no need to register a function.
105
+                $this->oFactory->oProp->aRootMenu[ 'sIcon16x16' ], // icon path
106 106
                 $this->getElement( 
107 107
                     $this->oFactory->oProp->aRootMenu, 
108 108
                     'iPosition', 
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
 
125 125
         // Let external scripts add sub-menu pages.
126 126
         $_aPages = $this->addAndApplyFilter( 
127
-            $this->oFactory,    // caller object
128
-            "pages_{$this->oFactory->oProp->sClassName}",   // filter
127
+            $this->oFactory, // caller object
128
+            "pages_{$this->oFactory->oProp->sClassName}", // filter
129 129
             $this->oFactory->oProp->aPages  // arguments
130 130
         );
131 131
         
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
         // Format the `$aPages` property and register the pages.
136 136
         $_iParsedIndex    = 0;
137 137
         $_aFormattedPages = array();
138
-        foreach( $_aPages as $_aSubMenuItem ) {
138
+        foreach ( $_aPages as $_aSubMenuItem ) {
139 139
             
140 140
             // needs to be sanitized because there are hook filters applied to this array.
141 141
             $_oFormatter = new AdminPageFramework_Format_SubMenuItem( 
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
          */
171 171
         private function _getDefaultPageSlug( array $aPages ) {
172 172
 
173
-            foreach( $aPages as $_aPage ) {
174
-                if ( ! isset( $_aPage[ 'page_slug' ] ) ) { 
173
+            foreach ( $aPages as $_aPage ) {
174
+                if ( !isset( $_aPage[ 'page_slug' ] ) ) { 
175 175
                     continue; 
176 176
                 }
177 177
                 return $_aPage[ 'page_slug' ];                
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
          */ 
194 194
         private function _registerSubMenuItem( array $aArgs ) {
195 195
 
196
-            if ( ! current_user_can( $aArgs[ 'capability' ] ) ) {
196
+            if ( !current_user_can( $aArgs[ 'capability' ] ) ) {
197 197
                 return '';
198 198
             }
199 199
                                     
@@ -257,14 +257,14 @@  discard block
 block discarded – undo
257 257
              */
258 258
             private function _addPageSubmenuItem( $sRootPageSlug, $sMenuSlug, $sPageSlug, $sPageTitle, $sMenuTitle, $sCapability, $bShowInMenu, $nOrder ) {
259 259
                 
260
-                if ( ! $sPageSlug ) {
260
+                if ( !$sPageSlug ) {
261 261
                     return '';
262 262
                 }
263 263
                 $_sPageHook = $this->___addSubMenuPage(
264
-                    $sRootPageSlug,         // the root (parent) page slug
265
-                    $sPageTitle,            // page title
266
-                    $sMenuTitle,            // menu title
267
-                    $sCapability,           // capability
264
+                    $sRootPageSlug, // the root (parent) page slug
265
+                    $sPageTitle, // page title
266
+                    $sMenuTitle, // menu title
267
+                    $sCapability, // capability
268 268
                     $sPageSlug              // menu slug
269 269
                 );
270 270
 
@@ -293,14 +293,14 @@  discard block
 block discarded – undo
293 293
                 $_aRemovedMenuItem = $this->_removePageSubmenuItem( $_nSubMenuPageIndex, $sMenuSlug, $sPageSlug, $sMenuTitle );
294 294
                 
295 295
                 // If the visibility option is `false`, remove the one just added from the sub-menu global array
296
-                if ( ! $bShowInMenu && ! $this->_isCurrentPage( $sPageSlug ) ) {
296
+                if ( !$bShowInMenu && !$this->_isCurrentPage( $sPageSlug ) ) {
297 297
                     return $_sPageHook;
298 298
                 }                
299 299
                 
300 300
                 // Set the order index in the element of the `submenu` global array.
301 301
                 $this->_setSubMenuPageByIndex( 
302
-                    $nOrder,                // user-set order
303
-                    $_aRemovedMenuItem,     // will be reassign with a new index
302
+                    $nOrder, // user-set order
303
+                    $_aRemovedMenuItem, // will be reassign with a new index
304 304
                     $sMenuSlug
305 305
                 );
306 306
 
@@ -321,21 +321,21 @@  discard block
 block discarded – undo
321 321
                  * @uses        add_submenu_page
322 322
                  */
323 323
                 private function ___addSubMenuPage(
324
-                    $sRootPageSlug,         // the root (parent) page slug
325
-                    $sPageTitle,            // page title
326
-                    $sMenuTitle,            // menu title
327
-                    $sCapability,           // capability
324
+                    $sRootPageSlug, // the root (parent) page slug
325
+                    $sPageTitle, // page title
326
+                    $sMenuTitle, // menu title
327
+                    $sCapability, // capability
328 328
                     $sPageSlug              // menu slug
329 329
                 ) {
330 330
                     if ( $this->oFactory->oProp->bIsAdminAjax ) {
331 331
                         return $sPageSlug;
332 332
                     }
333 333
                     return add_submenu_page(
334
-                        $sRootPageSlug,         // the root (parent) page slug
335
-                        $sPageTitle,            // page title
336
-                        $sMenuTitle,            // menu title
337
-                        $sCapability,           // capability
338
-                        $sPageSlug,             // menu slug
334
+                        $sRootPageSlug, // the root (parent) page slug
335
+                        $sPageTitle, // page title
336
+                        $sMenuTitle, // menu title
337
+                        $sCapability, // capability
338
+                        $sPageSlug, // menu slug
339 339
                         array( $this->oFactory, '_replyToRenderPage' )  // callback 3.7.10+
340 340
                     );
341 341
                 }
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
                      */
370 370
                     add_action( 
371 371
                         'current_screen', 
372
-                        array( $this->oFactory, "load_pre_" . $sPageSlug ), 
372
+                        array( $this->oFactory, "load_pre_".$sPageSlug ), 
373 373
                         20 
374 374
                     );
375 375
                     /**
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
                      */
379 379
                     add_action(
380 380
                         'pseudo_current_screen',
381
-                        array( $this->oFactory, "load_pre_" . $sPageSlug ),
381
+                        array( $this->oFactory, "load_pre_".$sPageSlug ),
382 382
                         20
383 383
                     );
384 384
                     
@@ -387,15 +387,15 @@  discard block
 block discarded – undo
387 387
                      * Set a low priority because the user may add in-page tabs in their callback method of this action hook.
388 388
                      * @since       3.6.3
389 389
                      */
390
-                    add_action( "load_" . $sPageSlug, array( $this->oFactory, '_replyToFinalizeInPageTabs' ), 9999 );
390
+                    add_action( "load_".$sPageSlug, array( $this->oFactory, '_replyToFinalizeInPageTabs' ), 9999 );
391 391
                     
392 392
                     // 3.6.3+
393
-                    add_action( "load_after_" . $sPageSlug, array( $this->oFactory, '_replyToEnqueuePageAssets' ) );
394
-                    add_action( "load_after_" . $sPageSlug, array( $this->oFactory, '_replyToEnablePageMetaBoxes' ) );  // 3.7.10+
393
+                    add_action( "load_after_".$sPageSlug, array( $this->oFactory, '_replyToEnqueuePageAssets' ) );
394
+                    add_action( "load_after_".$sPageSlug, array( $this->oFactory, '_replyToEnablePageMetaBoxes' ) ); // 3.7.10+
395 395
                           
396 396
                     $this->oFactory->oProp->aPageHooks[ $sPageSlug ] = $this->getAOrB(
397 397
                         is_network_admin(),
398
-                        $sPageHook . '-network',
398
+                        $sPageHook.'-network',
399 399
                         $sPageHook
400 400
                     );                          
401 401
 
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 
413 413
                     $_nNewIndex = $this->getUnusedNumericIndex( 
414 414
                         $this->getElementAsArray( $GLOBALS, array( 'submenu', $sMenuSlug ) ), // subject array to parser
415
-                        $nOrder,    // a desired menu position
415
+                        $nOrder, // a desired menu position
416 416
                         5           // offset 
417 417
                     );
418 418
 
@@ -426,9 +426,9 @@  discard block
 block discarded – undo
426 426
                  */
427 427
                 private function _getSubMenuPageIndex( $sMenuSlug, $sMenuTitle, $sPageTitle, $sPageSlug ) {
428 428
                     
429
-                    foreach( $this->getElementAsArray( $GLOBALS, array( 'submenu', $sMenuSlug ) ) as $_iIndex => $_aSubMenu ) {
429
+                    foreach ( $this->getElementAsArray( $GLOBALS, array( 'submenu', $sMenuSlug ) ) as $_iIndex => $_aSubMenu ) {
430 430
                       
431
-                        if ( ! isset( $_aSubMenu[ 3 ] ) ) { 
431
+                        if ( !isset( $_aSubMenu[ 3 ] ) ) { 
432 432
                             continue; 
433 433
                         }
434 434
                                                
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
                  * @since       3.1.1       Moved from `AdminPageFramework_Menu`. Chagned the return type.
461 461
                  * @return      array       removed menu item.
462 462
                  */
463
-                private function _removePageSubmenuItem( $nSubMenuPageIndex, $sMenuSlug, $sPageSlug, $sMenuTitle ){
463
+                private function _removePageSubmenuItem( $nSubMenuPageIndex, $sMenuSlug, $sPageSlug, $sMenuTitle ) {
464 464
  
465 465
                     $_aRemovedMenuItem = $this->_removePageSubMenuItemByIndex( 
466 466
                         $nSubMenuPageIndex,
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
              */
534 534
             private function _addLinkSubmenuItem( $sMenuSlug, $sTitle, $sCapability, $sHref, $bShowInMenu, $nOrder ) {
535 535
                 
536
-                if ( ! $bShowInMenu ) {
536
+                if ( !$bShowInMenu ) {
537 537
                     return;
538 538
                 }
539 539
     
@@ -548,9 +548,9 @@  discard block
 block discarded – undo
548 548
                     5   // offset
549 549
                 );
550 550
                 $_aSubMenuItems[ $_nIndex ] = array(
551
-                    $sTitle,        // 0
552
-                    $sCapability,   // 1
553
-                    $sHref,         // 2   
551
+                    $sTitle, // 0
552
+                    $sCapability, // 1
553
+                    $sHref, // 2   
554 554
                 );
555 555
                 $GLOBALS[ 'submenu' ][ $sMenuSlug ] = $_aSubMenuItems;                
556 556
                 
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
     public function _replyToRemoveRootMenuPage() {      
570 570
         
571 571
         // After adding the sub menus, if the root menu is created, remove the page that is automatically created when registering the root menu.
572
-        if ( ! $this->oFactory->oProp->aRootMenu[ 'fCreateRoot' ] ) {
572
+        if ( !$this->oFactory->oProp->aRootMenu[ 'fCreateRoot' ] ) {
573 573
             return;
574 574
         }
575 575
         if ( $this->oFactory->oProp->bIsAdminAjax ) {
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
          * Namespace slugs have backslashes but the registered slugs backslashes are all converted to forward-slashes.
581 581
          * @since       3.5.16
582 582
          */
583
-        $_sMenuSlug =             str_replace(
583
+        $_sMenuSlug = str_replace(
584 584
             '\\',
585 585
             '/',
586 586
             $this->oFactory->oProp->aRootMenu[ 'sPageSlug' ]
Please login to merge, or discard this patch.
admin-page-framework-loader.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@  discard block
 block discarded – undo
16 16
  */
17 17
 class AdminPageFrameworkLoader_Registry_Base {
18 18
 
19
-    const VERSION        = '3.8.16b01';    // <--- DON'T FORGET TO CHANGE THIS AS WELL!!
19
+    const VERSION        = '3.8.16b01'; // <--- DON'T FORGET TO CHANGE THIS AS WELL!!
20 20
     const NAME           = 'Admin Page Framework - Loader'; // the name is not 'Admin Page Framework' because warning messages gets confusing.
21
-    const SHORTNAME      = 'Admin Page Framework';  // used for a menu title etc.
21
+    const SHORTNAME      = 'Admin Page Framework'; // used for a menu title etc.
22 22
     const DESCRIPTION    = 'Loads Admin Page Framework which facilitates WordPress plugin and theme development.';
23 23
     const URI            = 'http://admin-page-framework.michaeluno.jp/';
24 24
     const AUTHOR         = 'miunosoft (Michael Uno)';
@@ -55,14 +55,14 @@  discard block
 block discarded – undo
55 55
      * @remark      This is also accessed from `uninstall.php` so do not remove.
56 56
      * @remark      Do not exceed 8 characters as a transient name allows 45 characters or less ( 40 for site transients ) so that md5 (32 characters) can be added.
57 57
      */
58
-    const TRANSIENT_PREFIX         = 'APFL_';
58
+    const TRANSIENT_PREFIX = 'APFL_';
59 59
 
60 60
     /**
61 61
      * The hook slug used for the prefix of action and filter hook names.
62 62
      * 
63 63
      * @remark      The ending underscore is not necessary.
64 64
      */
65
-    const HOOK_SLUG                = 'admin_page_framework_loader';
65
+    const HOOK_SLUG = 'admin_page_framework_loader';
66 66
 
67 67
     /**
68 68
      * The text domain slug and its path.
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
      */
117 117
     static public $aAdminPages = array(
118 118
         // key => 'page slug'
119
-        'about'     => 'apfl_about',        // the welcome page
119
+        'about'     => 'apfl_about', // the welcome page
120 120
         'addon'     => 'apfl_addons',
121 121
         'tool'      => 'apfl_tools',
122 122
         'help'      => 'apfl_contact',
@@ -154,12 +154,12 @@  discard block
 block discarded – undo
154 154
      * @since       3.5.0
155 155
      * @return      string
156 156
      */
157
-    public static function getPluginURL( $sRelativePath='' ) {
157
+    public static function getPluginURL( $sRelativePath = '' ) {
158 158
         if ( isset( self::$_sPluginURLCache ) ) {
159
-            return self::$_sPluginURLCache . $sRelativePath;
159
+            return self::$_sPluginURLCache.$sRelativePath;
160 160
         }
161 161
         self::$_sPluginURLCache = trailingslashit( plugins_url( '', self::$sFilePath ) );
162
-        return self::$_sPluginURLCache . $sRelativePath;
162
+        return self::$_sPluginURLCache.$sRelativePath;
163 163
     }
164 164
         /**
165 165
          * @since       3.7.9
@@ -189,13 +189,13 @@  discard block
 block discarded – undo
189 189
      * @since       3.5.0
190 190
      * @return      void
191 191
      */ 
192
-    static public function setAdminNotice( $sMessage, $sClassAttribute='error' ) {
193
-        if ( ! is_admin() ) {  
192
+    static public function setAdminNotice( $sMessage, $sClassAttribute = 'error' ) {
193
+        if ( !is_admin() ) {  
194 194
             return; 
195 195
         }
196
-        self::$_aAdminNotices[] = array(
196
+        self::$_aAdminNotices[ ] = array(
197 197
             'message'           => $sMessage,
198
-            'class_attribute'   => trim( $sClassAttribute ) . ' notice is-dismissible',
198
+            'class_attribute'   => trim( $sClassAttribute ).' notice is-dismissible',
199 199
         );
200 200
         add_action( 'admin_notices', array( __CLASS__, '_replyToSetAdminNotice' ) );
201 201
     }
@@ -205,12 +205,12 @@  discard block
 block discarded – undo
205 205
          * @return      void
206 206
          */
207 207
         static public function _replyToSetAdminNotice() {
208
-            foreach( self::$_aAdminNotices as $_aAdminNotice ) {
209
-                echo "<div class='" . esc_attr( $_aAdminNotice['class_attribute'] ) . " notice is-dismissible'>"
208
+            foreach ( self::$_aAdminNotices as $_aAdminNotice ) {
209
+                echo "<div class='".esc_attr( $_aAdminNotice[ 'class_attribute' ] )." notice is-dismissible'>"
210 210
                         ."<p>"
211 211
                             . sprintf(
212
-                                '<strong>%1$s</strong>: ' . $_aAdminNotice['message'],
213
-                                self::NAME . ' ' . self::VERSION
212
+                                '<strong>%1$s</strong>: '.$_aAdminNotice[ 'message' ],
213
+                                self::NAME.' '.self::VERSION
214 214
                             )
215 215
                         . "</p>"
216 216
                     . "</div>";
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 AdminPageFrameworkLoader_Registry::setUp( __FILE__ );
223 223
 
224 224
 // Initial checks. - Do no load if accessed directly, not exiting because the 'uninstall.php' and inclusion list generator will load this file.
225
-if ( ! defined( 'ABSPATH' ) ) {
225
+if ( !defined( 'ABSPATH' ) ) {
226 226
     return;
227 227
 }
228 228
 if ( defined( 'DOING_UNINSTALL' ) && DOING_UNINSTALL ) {
@@ -234,8 +234,8 @@  discard block
 block discarded – undo
234 234
 
235 235
     $_bFrameworkLoaded = class_exists( 'AdminPageFramework_Registry', false );
236 236
     if (
237
-        ! $_bFrameworkLoaded
238
-        || ! defined( 'AdminPageFramework_Registry::VERSION' ) // backward compatibility
237
+        !$_bFrameworkLoaded
238
+        || !defined( 'AdminPageFramework_Registry::VERSION' ) // backward compatibility
239 239
         || version_compare( AdminPageFramework_Registry::VERSION, AdminPageFrameworkLoader_Registry::VERSION, '<' )
240 240
     ) {
241 241
         AdminPageFrameworkLoader_Registry::setAdminNotice(
@@ -253,18 +253,18 @@  discard block
 block discarded – undo
253 253
 add_action( 'admin_init', 'AdminPageFrameworkLoader_Warning' );
254 254
 
255 255
 // Include the library file - the development version will be available if you cloned the GitHub repository.
256
-$_sDevelopmentVersionPath = AdminPageFrameworkLoader_Registry::$sDirPath . '/development/admin-page-framework.php';
256
+$_sDevelopmentVersionPath = AdminPageFrameworkLoader_Registry::$sDirPath.'/development/admin-page-framework.php';
257 257
 $_bDebugMode              = defined( 'WP_DEBUG' ) && WP_DEBUG;
258 258
 $_bLoadDevelopmentVersion = $_bDebugMode && file_exists( $_sDevelopmentVersionPath );
259 259
 include(
260 260
     $_bLoadDevelopmentVersion
261 261
         ? $_sDevelopmentVersionPath
262
-        : AdminPageFrameworkLoader_Registry::$sDirPath . '/library/apf/admin-page-framework.php'
262
+        : AdminPageFrameworkLoader_Registry::$sDirPath.'/library/apf/admin-page-framework.php'
263 263
 );
264 264
 
265 265
 // Include the framework loader plugin components.
266 266
 include( AdminPageFramework_Registry::$aClassFiles[ 'AdminPageFramework_PluginBootstrap' ] );
267
-include( AdminPageFrameworkLoader_Registry::$sDirPath . '/include/class/AdminPageFrameworkLoader_Bootstrap.php' );
267
+include( AdminPageFrameworkLoader_Registry::$sDirPath.'/include/class/AdminPageFrameworkLoader_Bootstrap.php' );
268 268
 new AdminPageFrameworkLoader_Bootstrap(
269 269
     AdminPageFrameworkLoader_Registry::$sFilePath,
270 270
     AdminPageFrameworkLoader_Registry::HOOK_SLUG    // hook prefix
Please login to merge, or discard this patch.