/** * @param IfwPsn_Wp_Plugin_Manager $pm */ public static function load(IfwPsn_Wp_Plugin_Manager $pm) { if (!$pm->getEnv()->isCli()) { // die if not command line accessed die('Invalid access'); } $args = $_SERVER['argv']; $command = $args[1]; $args = array_slice($args, 2); $executable = 'script'; if ($pm->getEnv()->isWindows()) { $executable .= '.bat'; } else { $executable .= '.sh'; } try { // try to execute a command $cliCommand = IfwPsn_Wp_Plugin_Cli_Factory::getCommand($command, $args, $pm); $cliCommand->setExecutable($executable); $cliCommand->execute(); } catch (IfwPsn_Wp_Plugin_Cli_Factory_Exception $e) { echo 'Initialization error: ' . $e->getMessage(); } catch (IfwPsn_Wp_Plugin_Cli_Command_Exception_MissingOperand $e) { // fetch MissingOperand exception echo $executable . ' ' . $command . ': missing operand'; echo PHP_EOL; echo $e->getMessage(); } catch (IfwPsn_Wp_Plugin_Cli_Exception $e) { // fetch generell cli exception echo $e->getMessage(); } }
/** * @return IfwPsn_Wp_Ajax_Response_Abstract */ public function getResponse() { $tpl = IfwPsn_Wp_Tpl::getInstance($this->_pm); if ($this->_iframeSrc !== null) { $iframeSrc = $this->_iframeSrc; } elseif (strpos($this->_pm->getConfig()->plugin->optionsPage, 'options-general.php') !== false) { $iframeSrc = IfwPsn_Wp_Proxy_Admin::getUrl() . IfwPsn_Wp_Proxy_Admin::getMenuUrl($this->_pm, 'selftest'); $iframeSrc = str_replace('wp-admin//', 'wp-admin/', $iframeSrc); } else { $iframeSrc = IfwPsn_Wp_Proxy_Admin::getAdminPageUrl($this->_pm, $this->_pm->getAbbrLower() . '_selftest', $this->_pm->getAbbrLower() . '_selftest'); } $context = array('ajax' => $this, 'iframe_src' => $iframeSrc, 'img_path' => $this->_pm->getEnv()->getUrlAdminImg()); $timestamp = $this->_pm->getBootstrap()->getSelftester()->getTimestamp(); if (!empty($timestamp)) { require_once $this->_pm->getPathinfo()->getRootLib() . 'IfwPsn/Wp/Date.php'; $timestamp = IfwPsn_Wp_Date::format($timestamp); } $context['timestamp'] = $timestamp; $status = $this->_pm->getBootstrap()->getSelftester()->getStatus(); if ($status === true || $status === 'true' || $status == '1') { $context['status'] = 'true'; } elseif ($status === false || $status === 'false' || $status == '0') { $context['status'] = 'false'; } else { $context['status'] = 'null'; } $html = $tpl->render('metabox_pluginstatus.html.twig', $context); $success = true; $response = new IfwPsn_Wp_Ajax_Response_Json($success); $response->addData('html', $html); return $response; }
/** * @param IfwPsn_Wp_Plugin_Manager $pm */ protected static function _loadCliCommand($command, IfwPsn_Wp_Plugin_Manager $pm) { $headline = '### %s %s CLI ###' . PHP_EOL . PHP_EOL; printf($headline, $pm->getEnv()->getName(), $pm->getEnv()->getVersion()); $args = $_SERVER['argv']; $args = array_slice($args, 2); $executable = 'script'; if ($pm->getEnv()->isWindows()) { $executable .= '.bat'; } else { $executable .= '.sh'; } try { // try to execute a command $cliCommand = IfwPsn_Wp_Plugin_Cli_Factory::getCommand($command, $args, $pm); $cliCommand->setExecutable($executable); // load the cli command after WP is completely loaded add_action('wp_loaded', array($cliCommand, 'execute')); } catch (IfwPsn_Wp_Plugin_Cli_Factory_Exception $e) { echo 'Initialization error: ' . $e->getMessage(); } catch (IfwPsn_Wp_Plugin_Cli_Command_Exception_MissingOperand $e) { // fetch MissingOperand exception echo $executable . ' ' . $command . ': missing operand'; echo PHP_EOL; echo $e->getMessage(); } catch (IfwPsn_Wp_Plugin_Cli_Exception $e) { // fetch generell cli exception echo $e->getMessage(); } }
/** * @return bool */ public function isPatchesAvailable() { if ($this->_presentVersion->isLessThan($this->_pm->getEnv()->getVersion()) && $this->hasPatches()) { return true; } return false; }
/** * Retrieves the application options * @return array */ protected function _getApplicationOptions() { $options = (include $this->_pm->getPathinfo()->getRootAdminMenu() . 'configs/application.php'); if ($this->_pm->getEnv()->getEnvironmet() == 'development') { $options['resources']['FrontController']['params']['displayExceptions'] = 1; $options['phpSettings']['error_reporting'] = 6143; // E_ALL & ~E_STRICT $options['phpSettings']['display_errors'] = 1; $options['phpSettings']['display_startup_errors'] = 1; } return $options; }
protected function _addConnectBlock() { $homepage = $this->_pm->getEnv()->getHomepage(); $premiumUrl = $this->_pm->getConfig()->plugin->premiumUrl; $content = ''; $content .= sprintf(__('Visit the <a href="%s" target="_blank">plugin homepage</a>', 'ifw'), $homepage); if (!empty($premiumUrl) && $premiumUrl != $homepage) { $content .= '<br>' . sprintf(__('Visit the <a href="%s" target="_blank">premium homepage</a> for the latest news.', 'ifw'), $premiumUrl); } $content .= '<br><a href="https://twitter.com/ifeelwebde" target="_blank">@ifeelweb ' . __('on Twitter', 'ifw') . '</a>'; $this->addBlock('connect', __('Connect', 'ifw'), '<br>' . $content, 'connect'); }
/** * @param $body * @param Psn_Notification_Service_Email $email * @return string */ public function filterEmailBody($body, Psn_Notification_Service_Email $email) { $body = $this->_handleSpecialChars($body); if (!$this->_pm->isPremium()) { // please respect my work and buy the premium version if you want this plugin to stay alive! $body .= PHP_EOL . PHP_EOL . sprintf(__('This email was sent by WordPress plugin "%s". Visit the plugin homepage: %s'), $this->_pm->getEnv()->getName(), $this->_pm->getEnv()->getHomepage()); } return $body; }
/** * @param string $docUrl * @return string */ protected function _getHelpSidebar($docUrl = '') { $sidebar = '<p><b>' . __('For more information:', 'ifw') . '</b></p>'; $sidebar .= sprintf('<p><a href="%s" target="_blank">' . __('Plugin homepage', 'ifw') . '</a></p>', $this->_pm->getEnv()->getHomepage()); if (!empty($this->_pm->getConfig()->plugin->docUrl)) { $sidebar .= sprintf('<p><a href="%s" target="_blank">' . __('Documentation', 'ifw') . '</a></p>', $this->_pm->getConfig()->plugin->docUrl . $docUrl); } return $sidebar; }
public function init() { IfwPsn_Wp_Proxy_Script::loadAdminMinimized($this->_pm, 'opt-render-tabs', $this->_pm->getEnv()->getUrl() . 'lib/IfwPsn/Wp/Options/Renderer/sources/tabs/tabs.js', array('jquery')); IfwPsn_Wp_Proxy_Style::loadAdminMinimized($this->_pm, 'opt-render-tabs', $this->_pm->getEnv()->getUrl() . 'lib/IfwPsn/Wp/Options/Renderer/sources/tabs/tabs.css'); }
/** * Updates the plugin's option "present_version" to current plugin version */ public function refreshPresentVersion() { $this->_pm->getBootstrap()->getOptionsManager()->updateOption('present_version', $this->_pm->getEnv()->getVersion()); }
/** * Resets the error reporting to default in dev mode */ public function disableErrorReporting() { if ($this->_pm->getEnv()->getEnvironmet() == 'development' || $this->_pm->getConfig()->debug->show_errors == '1') { error_reporting($this->_errorReportingLevel); } }
public static function loadSkin(IfwPsn_Wp_Plugin_Manager $pm) { if ($pm->getEnv()->hasSkin()) { IfwPsn_Wp_Proxy_Style::loadAdmin('admin-style', $pm->getEnv()->getSkinUrl() . 'style.css'); } }
/** * Retrieves the URL of a UI theme css file * * @param $theme_name * @param IfwPsn_Wp_Plugin_Manager $pm * @return string */ public static function getUiThemeUrl($theme_name, IfwPsn_Wp_Plugin_Manager $pm) { return $pm->getEnv()->getUrlCss() . 'jqueryui/themes/' . $theme_name . '/' . self::getUiThemeFile($theme_name, $pm); }