/** * Alias for get_current_screen() * @return WP_Screen */ public static function getCurrent() { if (IfwPsn_Wp_Proxy_Blog::isMinimumVersion('3.1') && function_exists('get_current_screen')) { return get_current_screen(); } return null; }
/** * @param IfwPsn_Wp_Plugin_Manager $pm */ public function __construct(IfwPsn_Wp_Plugin_Manager $pm) { $this->_pm = $pm; if (IfwPsn_Wp_Proxy_Blog::isMinimumVersion('3.1')) { // screen functionality supported since WP 3.1 $this->_init(); } }
/** * Loads the appropriate action for adding contextual help */ public function load() { if (IfwPsn_Wp_Proxy_Blog::isMinimumVersion('3.3')) { // since 3.3 use the add_help_method on the screen object IfwPsn_Wp_Proxy_Action::addAdminHead(array($this, 'addHelpTab')); } else { // before 3.3 use the contextual_help action IfwPsn_Wp_Proxy_Action::add('contextual_help', array($this, 'getContextualHelp'), 10, 3); } }
/** * Initializes the controller * Will be called on bootstrap before admin-menu/admin-init/load-[page] * Use onAdminMenu/onAdminInit etc otherwise */ public function init() { // set config $this->_config = $this->getInvokeArg('bootstrap')->getOptions(); $this->_pm = $this->_config['pluginmanager']; $this->view->pm = $this->_pm; $this->_pm->getLogger()->logPrefixed('Init default controller.'); $this->_adminNotices = new IfwPsn_Wp_Admin_Notices($this->_pm->getAbbrLower()); // $this->_adminNotices->setAutoShow(true); $this->view->adminNotices = $this->_adminNotices; $this->_redirector = $this->_helper->getHelper('Redirector'); $this->_request = $this->getRequest(); $this->_helper->layout()->setLayout('layout'); $this->_pageHook = 'page-' . $this->_pm->getPathinfo()->getDirname() . '-' . $this->getRequest()->getControllerName() . '-' . $this->getRequest()->getActionName(); $this->view->pageHook = $this->_pageHook; $this->initNavigation(); $this->view->isSupportedWpVersion = IfwPsn_Wp_Proxy_Blog::isMinimumVersion($this->_pm->getConfig()->plugin->wpMinVersion); $this->view->notSupportedWpVersionMessage = sprintf(__('This plugin requires WordPress version %s for full functionality. Your version is %s. <a href="%s">Please upgrade</a>.', 'ifw'), $this->_pm->getConfig()->plugin->wpMinVersion, IfwPsn_Wp_Proxy_Blog::getVersion(), 'http://wordpress.org/download/'); // Do action on controller init IfwPsn_Wp_Proxy_Action::doAction(get_class($this) . '_init', $this); }
/** * Runs the test * @param IfwPsn_Wp_Plugin_Manager $pm * @return mixed */ public function execute(IfwPsn_Wp_Plugin_Manager $pm) { $this->_pm = $pm; $this->_result = IfwPsn_Wp_Proxy_Blog::isMinimumVersion($pm->getConfig()->plugin->wpMinVersion); }
/** * @return WP_Post|object */ protected function _getPostMockup() { $this->_isMockUpPost = true; if (IfwPsn_Wp_Proxy_Blog::isMinimumVersion('3.5')) { // WP_Post since 3.5 return new WP_Post(new stdClass()); } else { // before 3.5 global $wpdb; return $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->posts} LIMIT 1")); } }