| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * Admin Page Framework - Loader | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * Loads Admin Page Framework. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * http://admin-page-framework.michaeluno.jp/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * Copyright (c) 2013-2022, Michael Uno | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | class AdminPageFrameworkLoader_AdminPageMetaBox_Notification extends AdminPageFramework_PageMetaBox { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |      * ( optional ) Use the setUp() method to define settings of this meta box. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     public function setUp() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |         $this->oUtil->registerAction( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |             'current_screen', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |             array( $this, 'replyToDecideToLoad' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |             1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     public $_sDevelopmentVersion; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |      * @param       $oScreen | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |      * @callback    action      current_screen | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 33 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |     public function replyToDecideToLoad( /* $oScreen */ ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |         if ( ! $this->_isInThePage() ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |             return; | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |         // For debugging, uncomment the below line to remove the transient. | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  | //         $this->oUtil->deleteTransient( | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  | //             AdminPageFrameworkLoader_Registry::TRANSIENT_PREFIX . 'devver' | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  | //         ); | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |         // Retrieve the development version. | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |         $this->_sDevelopmentVersion = $this->oUtil->getTransient( | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |             AdminPageFrameworkLoader_Registry::TRANSIENT_PREFIX . 'devver' | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |         ); | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |         // Disable the meta box if the development version is not above the running one. | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |         if ( version_compare( AdminPageFramework_Registry::VERSION, $this->_sDevelopmentVersion, '>=' ) ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |             $this->oProp->aPageSlugs = array(); | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  |         // If the value is not set, schedule retrieving the version. | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |         if ( empty( $this->_sDevelopmentVersion ) ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |             $this->_scheduleEvent(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |          * @since       3.6.2 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |          */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         private function _scheduleEvent() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |             $_sActionName = AdminPageFrameworkLoader_Registry::HOOK_SLUG . '_action_get_development_version'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |             $_aArguments  = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |             if ( wp_next_scheduled( $_sActionName, $_aArguments ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |                 return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |             wp_schedule_single_event( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |                 time(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |                 $_sActionName, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |                 $_aArguments | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |      * The content filter callback method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |      * Alternatively use the `content_{instantiated class name}` method instead. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     public function content( $sContent ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |         $_sInsert = '' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |             . "<h4>" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |                 . "<span class='header-icon dashicons dashicons-warning'></span>" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |                 . __( 'Test Development Version', 'admin-page-framework-loader' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |             . "</h4>" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |             . "<p class='new-version-notification'>" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |                 . sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |                     __( 'A new development version <code>%1$s</code> is available!', 'admin-page-framework-loader' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |                     . ' ' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |                     . __( 'Please test it before it gets released.', 'admin-page-framework-loader' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |                     $this->_sDevelopmentVersion, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |                     esc_url( 'https://github.com/michaeluno/admin-page-framework/archive/dev.zip' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |             . "</p>" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |             . "<div style='width:100%; display:inline-block;'>" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |                 . '<a href="' . esc_url( 'https://github.com/michaeluno/admin-page-framework/archive/dev.zip' ). '">' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |                     . "<div class='button button-primary float-right'>" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |                         . __( 'Download', 'admin-page-framework-loader' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |                     . "</div>" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |                 . "</a>" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |             . "</div>" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |             ; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |         return $_sInsert . $sContent; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 112 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 113 |  |  |  |