/** * (non-PHPdoc) * @see IfwPsn_Wp_Plugin_Bootstrap_Abstract::bootstrap() */ public function bootstrap() { $featureLoader = new Psn_Feature_Loader($this->_pm); $featureLoader->load(); if ($this->_pm->getAccess()->isAdmin()) { // on admin access // add plugin menu links IfwPsn_Wp_Proxy_Filter::addPluginActionLinks($this->_pm, array($this, 'addPluginActionLinks')); // set installer / uninstaller require_once $this->_pm->getPathinfo()->getRootLib() . 'Psn/Installer/Activation.php'; require_once $this->_pm->getPathinfo()->getRootLib() . 'Psn/Installer/Uninstall.php'; $this->getInstaller()->addActivation(new Psn_Installer_Activation()); $this->getInstaller()->addUninstall(new Psn_Installer_Uninstall()); // load options handler require_once $this->_pm->getPathinfo()->getRootLib() . 'Psn/Admin/Options/Handler.php'; $optionsHandler = new Psn_Admin_Options_Handler($this->_pm); $optionsHandler->load(); } if ($this->_pm->getAccess()->isPlugin()) { // register patches require_once $this->_pm->getPathinfo()->getRootLib() . 'Psn/Patch/Database.php'; $this->getUpdateManager()->getPatcher()->addPatch(new Psn_Patch_Database()); // register selftests IfwPsn_Wp_Proxy_Action::addPlugin($this->_pm, 'selftester_activate', array($this, 'addSelftests')); } require_once $this->_pm->getPathinfo()->getRootLib() . '/Psn/Notification/Manager.php'; $this->_notificationManager = new Psn_Notification_Manager($this->_pm); $this->_notificationManager->setDeferredExecution(); //IfwPsn_Wp_Proxy_Action::addInit(array($this, 'test')); }
/** * */ public function indexAction() { add_thickbox(); $this->_pm->getLogger()->logPrefixed('Executing ' . get_class($this) . ':indexAction()'); $this->_pm->getBootstrap()->getSelftester()->performTests(); require_once $this->_pm->getPathinfo()->getRootLib() . 'IfwPsn/Wp/Plugin/Menu/Help.php'; require_once $this->_pm->getPathinfo()->getRootLib() . 'IfwPsn/Wp/Plugin/Metabox/Container.php'; require_once $this->_pm->getPathinfo()->getRootLib() . 'IfwPsn/Wp/Plugin/Metabox/PremiumAd.php'; require_once $this->_pm->getPathinfo()->getRootLib() . 'IfwPsn/Wp/Plugin/Metabox/PluginInfo.php'; require_once $this->_pm->getPathinfo()->getRootLib() . 'IfwPsn/Wp/Plugin/Metabox/PluginStatus.php'; require_once $this->_pm->getPathinfo()->getRootLib() . 'IfwPsn/Wp/Plugin/Metabox/IfwFeed.php'; require_once $this->_pm->getPathinfo()->getRootLib() . 'Psn/Admin/Metabox/Rules.php'; // set up contextual help $help = new IfwPsn_Wp_Plugin_Menu_Help($this->_pm); $help->setTitle(__('Overview', 'psn'))->setHelp($this->_getHelpText())->setSidebar($this->_getHelpSidebar())->load(); // set up metaboxes $metaBoxContainerLeft = new IfwPsn_Wp_Plugin_Metabox_Container('column1', $this->_pageHook, 'left'); IfwPsn_Wp_Proxy_Action::doAction('psn_admin_overview_before_metabox_left', $metaBoxContainerLeft); $metaBoxContainerLeft->addMetabox(new Psn_Admin_Metabox_Rules($this->_pm)); IfwPsn_Wp_Proxy_Action::doAction('psn_admin_overview_after_metabox_left', $metaBoxContainerLeft); $metaBoxContainerRight = new IfwPsn_Wp_Plugin_Metabox_Container('column2', $this->_pageHook, 'right'); IfwPsn_Wp_Proxy_Action::doAction('psn_admin_overview_before_metabox_right', $metaBoxContainerRight); if ($this->_pm->hasPremium() && $this->_pm->isPremium() == false) { $metaBoxContainerRight->addMetabox(new IfwPsn_Wp_Plugin_Metabox_PremiumAd($this->_pm)); } $metaBoxContainerRight->addMetabox(new IfwPsn_Wp_Plugin_Metabox_PluginInfo($this->_pm)); $metaBoxContainerRight->addMetabox(new IfwPsn_Wp_Plugin_Metabox_PluginStatus($this->_pm)); $metaBoxContainerRight->addMetabox(new IfwPsn_Wp_Plugin_Metabox_IfwFeed($this->_pm)); IfwPsn_Wp_Proxy_Action::doAction('psn_admin_overview_after_metabox_right', $metaBoxContainerRight); $this->view->metaBoxContainerLeft = $metaBoxContainerLeft; $this->view->metaBoxContainerRight = $metaBoxContainerRight; }
/** * @param $navigation */ public function addMailTplNav(IfwPsn_Vendor_Zend_Navigation $navigation) { $page = new IfwPsn_Zend_Navigation_Page_WpMvc(array('label' => __('Mail templates', 'psn'), 'controller' => 'index', 'action' => 'adMailTpl', 'page' => $this->_pm->getPathinfo()->getDirname(), 'route' => 'requestVars')); $page->set('exactActiveMatch', true); $navigation->addPage($page); IfwPsn_Wp_Proxy_Action::doPlugin($this->_pm, 'after_admin_navigation_htmlmails', $navigation); }
/** * Loads the application */ public function load() { IfwPsn_Wp_Proxy_Action::doAction($this->_pm->getAbbrLower() . '_before_application_load', $this); $this->_pm->getLogger()->logPrefixed('Trying to load application...'); $this->_adapter->load(); IfwPsn_Wp_Proxy_Action::doAction($this->_pm->getAbbrLower() . '_after_application_load', $this); }
public function onLoad() { $application = $this->_pm->getBootstrap()->getApplication(); if ($application->getAdapter() instanceof IfwPsn_Wp_Plugin_Application_Adapter_ZendFw) { IfwPsn_Wp_Proxy_Action::addAdminInit(array($application->getAdapter(), 'init')); IfwPsn_Wp_Proxy_Action::add('load-' . $this->getPageHook(), array($application, 'render')); } }
/** * Registeres the callback method to the WP ajax action * * @param IfwPsn_Wp_Ajax_Request_Abstract $request */ public function addRequest(IfwPsn_Wp_Ajax_Request_Abstract $request) { $this->_callback = $request->getCallback(); IfwPsn_Wp_Proxy_Action::add($request->getAction(), array($this, 'execute')); if ($request instanceof IfwPsn_Wp_Ajax_Request_Public) { IfwPsn_Wp_Proxy_Action::add('wp_ajax_' . $request->getId(), array($this, 'execute')); } }
protected function _init() { if (IfwPsn_Wp_Proxy_Screen::isLoadedCurrentScreen()) { $this->_pm->getLogger()->error('Screen option must be initialized before page load.'); } $this->_type = $this->getType(); IfwPsn_Wp_Proxy_Filter::addSetScreenOption(array($this, 'setScreenOptionCallback'), 10, 3); IfwPsn_Wp_Proxy_Action::addCurrentScreen(array($this, 'registerOption')); }
/** * 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); } }
/** * Decides which function to call */ public function _callback() { if ($this->getCallback() instanceof IfwPsn_Wp_Plugin_Application_PageMapperInterface) { $this->getCallback()->handlePage($this); } elseif (is_callable($this->getCallback())) { call_user_func($this->getCallback()); } else { IfwPsn_Wp_Proxy_Action::doPlugin($this->_pm, 'submenu_page_callback', $this); } }
/** * Fetch a post on save / update and store it for later processing * * @param $post_ID * @param $post * @param $update */ public function fetchPostOnInsert($post_ID, $post, $update = null) { // fetch post $this->_post = $post; if (IfwPsn_Wp_Plugin_Manager::getInstance('Psn')->hasOption('psn_late_execution')) { // register container execution for shutdown action IfwPsn_Wp_Proxy_Action::add('shutdown', array($this, 'execute')); } else { $this->execute(); } }
/** * */ protected function _initAutorun() { $interval = $this->_pm->getConfig()->plugin->selftestInterval; if (!empty($interval)) { require_once $this->_pm->getPathinfo()->getRootLib() . 'IfwPsn/Wp/Date.php'; if ($this->getTimestamp() == null || IfwPsn_Wp_Date::isOlderThanSeconds($this->getTimestamp(), $interval)) { // perform a selftest if no one was run before or the selftest interval is exceeded IfwPsn_Wp_Proxy_Action::addPluginsLoaded(array($this, 'performTests')); } } }
protected function _init() { $this->_initAction(); $this->_initNonce(); if (method_exists($this, 'getResponse')) { IfwPsn_Wp_Proxy_Action::add($this->getAction(), array($this, '_render')); if ($this instanceof IfwPsn_Wp_Ajax_Request_Public) { IfwPsn_Wp_Proxy_Action::add('wp_ajax_' . $this->getId(), array($this, '_render')); } } }
/** * @param $target */ public function renderTo($target) { $this->_target = $target; if ($this->_isValid()) { // enqueue scripts and styles IfwPsn_Wp_Proxy_Script::loadAdmin('wp-pointer', false, array('jquery')); IfwPsn_Wp_Proxy_Style::loadAdmin('wp-pointer'); IfwPsn_Wp_Proxy_Action::addAdminFooterCurrentScreen(array($this, 'renderScript')); IfwPsn_Wp_Proxy_Action::add('admin_footer-post-new.php', array($this, 'renderScript')); IfwPsn_Wp_Proxy_Action::add('admin_footer-edit.php', array($this, 'renderScript')); } }
/** * @param IfwPsn_Vendor_Zend_Form_Element|string $element * @param null $name * @param null $options * @return IfwPsn_Vendor_Zend_Form * @throws IfwPsn_Vendor_Zend_Form_Exception */ public function addElement($element, $name = null, $options = null) { if ($element instanceof IfwPsn_Vendor_Zend_Form_Element) { $name = $element->getName(); } IfwPsn_Wp_Proxy_Action::doAction($this->getName() . '_before_' . $name, $this); $result = parent::addElement($element, $name, $options); $decoratorHtml = $result->getElement($name)->getDecorator('HtmlTag'); if ($decoratorHtml) { $decoratorHtml->setOption('id', 'form_element_' . $name); } IfwPsn_Wp_Proxy_Action::doAction($this->getName() . '_after_' . $name, $this); return $result; }
public function init() { if ($this->_pm->getConfig()->plugin->autoupdate == 1) { $updateApi = IfwPsn_Wp_Plugin_Update_Api_Factory::get($this->_pm); // check for custom update message IfwPsn_Wp_Proxy_Action::add('in_plugin_update_message-' . $this->_pm->getPathinfo()->getFilenamePath(), array($updateApi, 'getUpdateInlineMessage'), 10, 3); IfwPsn_Wp_Proxy_Filter::add('pre_set_site_transient_update_plugins', array($updateApi, 'getUpdateData')); if ($this->_pm->isPremium()) { // check for premium get update info IfwPsn_Wp_Proxy_Filter::add('plugins_api', array($updateApi, 'getPluginInformation'), 10, 3); } } $this->_pm->getBootstrap()->getOptionsManager()->registerExternalOption('present_version'); }
/** * @param WP_Post $post */ public function __construct($post = null) { if ($post === null) { $this->_post = $this->_getPostMockup(); } else { // real post object with data $this->_post = $post; } $options = array('auto_delimiters' => true, 'lazy_filter_prefix' => 'psn_load_placeholder_value_'); parent::__construct($this->_getNotificationPlaceholders(), $options); $this->_addDynamicPlaceholders(); $this->_addArrayData(); IfwPsn_Wp_Proxy_Action::doAction('psn_notification_placeholders_loaded', $this); if (!$this->isMockUpPost()) { $this->prepareTwigContext(); } }
/** * @see IfwPsn_Wp_Plugin_Admin_Menu_Metabox_Abstract::render() */ public function render() { require_once IFW_PSN_LIB_ROOT . '/IfwPsn/Vendor/Zend/View.php'; $testMailForm = new Psn_Admin_Form_TestMail(array('action' => IfwPsn_Wp_Proxy_Admin::getUrl() . IfwPsn_Wp_Proxy_Admin::getMenuUrl($this->_pm, 'service', 'send-test-mail'))); IfwPsn_Wp_Proxy_Action::doPlugin($this->_pm, 'testmail_form', $testMailForm); $testMailForm->setView(new IfwPsn_Vendor_Zend_View()); ?> <p><?php _e('Send a test email to check the general email functionality of your WordPress installation. Settings in the options section will be considered (e.g. SMTP).', 'psn'); ?> </p> <?php echo $testMailForm; ?> <?php }
/** * */ public function sendTestMailAction() { if (!$this->_verifyNonce('psn-form-test-mail')) { $this->getAdminNotices()->persistError(__('Invalid access.', 'psn')); $this->_gotoIndex(); } $this->_email = new IfwPsn_Wp_Email(); $subject = sprintf(__('Test Email from %s', 'psn'), $this->_pm->getEnv()->getName()); $body = IfwPsn_Wp_Proxy_Filter::apply('psn_send_test_mail_body', sprintf(__('This is a test email generated by %s on %s (%s)', 'psn'), $this->_pm->getEnv()->getName(), IfwPsn_Wp_Proxy_Blog::getName(), IfwPsn_Wp_Proxy_Blog::getUrl()), $this->_email); switch (trim($this->_request->get('recipient'))) { case 'custom': $recipient = esc_attr($_POST['custom_recipient']); break; case 'admin': default: $recipient = IfwPsn_Wp_Proxy_Blog::getAdminEmail(); break; } $recipient = IfwPsn_Wp_Proxy_Filter::apply('psn_send_test_mail_recipient', $recipient); if (empty($recipient)) { $resultMsg = __('Invalid recipient.', 'psn') . ' ' . __('Test email could not be sent.', 'psn'); $this->getAdminNotices()->persistError($resultMsg); } else { $this->_email->setTo($recipient)->setSubject($subject)->setMessage($body); IfwPsn_Wp_Proxy_Action::doAction('psn_send_test_mail', $this->_email); if ($this->_email->send()) { // mail sent successfully $resultMsg = __('Test email has been sent successfully.', 'psn'); $this->getAdminNotices()->persistUpdated($resultMsg); IfwPsn_Wp_Proxy_Action::doAction('psn_send_test_mail_success', $this); } else { // email could not be sent $resultMsg = __('Test email could not be sent.', 'psn'); $this->getAdminNotices()->persistError($resultMsg); IfwPsn_Wp_Proxy_Action::doAction('psn_send_test_mail_failure', $this); } IfwPsn_Wp_Proxy_Action::doAction('psn_after_test_email_send', $this->_email); } $this->_gotoIndex(); }
/** * (non-PHPdoc) * @see IfwPsn_Vendor_Zend_Controller_Action::preDispatch() */ public function preDispatch() { if ($this->_request->getActionName() == 'index') { $this->_listTable = $this->getListTable(); if ($this->_listTable->hasValidBulkRequest()) { $action = $this->_listTable->getBulkAction(); if ($action == 'bulk_delete' && is_array($this->_request->getPost($this->getSingular()))) { // bulk action delete $this->_bulkDelete($this->_request->getPost($this->getSingular())); } elseif ($action == 'bulk_export' && is_array($this->_request->getPost($this->getSingular())) && method_exists($this, '_bulkExport')) { // bulk action export $this->_bulkExport($this->_request->getPost($this->getSingular())); } else { if (method_exists($this, 'handleBulkAction')) { $this->handleBulkAction($action); } $actionFormat = '%s_%s_action-%s'; IfwPsn_Wp_Proxy_Action::doAction(sprintf($actionFormat, $this->getPluginAbbr(), $this->getPlural(), $action), $this); } } } }
/** (non-PHPdoc) * @see IfwPsn_Wp_Plugin_Installer_UninstallInterface::execute() */ public static function execute($pm, $networkwide = false) { // handle the DB if (IfwPsn_Wp_Proxy_Blog::isMultisite() && $networkwide == true) { // multisite installation $currentBlogId = IfwPsn_Wp_Proxy_Blog::getBlogId(); foreach (IfwPsn_Wp_Proxy_Blog::getMultisiteBlogIds() as $blogId) { IfwPsn_Wp_Proxy_Blog::switchToBlog($blogId); self::_dropTable($pm); } IfwPsn_Wp_Proxy_Blog::switchToBlog($currentBlogId); } else { // single blog installation self::_dropTable($pm); } // remove update action if ($pm->getConfig()->plugin->autoupdate == 1) { IfwPsn_Wp_Proxy_Action::remove('in_plugin_update_message-' . $pm->getPathinfo()->getFilenamePath(), array($pm->getBootstrap()->getUpdateManager(), 'onPluginUpdateMessage'), 10, 3); IfwPsn_Wp_Proxy_Filter::remove('pre_set_site_transient_update_plugins', array($pm->getBootstrap()->getUpdateManager(), 'checkForPremiumUpdate')); if ($pm->isPremium()) { IfwPsn_Wp_Proxy_Filter::remove('plugins_api', array($pm->getBootstrap()->getUpdateManager(), 'getPluginInfo'), 10, 3); } } }
/** * @return bool */ public static function isLoadedCurrentScreen() { return function_exists('get_current_screen') && self::getCurrentId() != null && IfwPsn_Wp_Proxy_Action::did('load-' . self::getCurrentId()); }
public function _load() { if ($this->_pm->getAccess()->isPlugin() || isset($_POST['option_page']) && $_POST['option_page'] == $this->_pageId) { // init the option objects only if it is a exact plugin admin page access or save request $generalOptions = new IfwPsn_Wp_Options_Section('general', __('General', 'ifw')); IfwPsn_Wp_Proxy_Action::doAction($this->_pm->getAbbrLower() . '_general_options_init', $generalOptions); $this->addSection($generalOptions); $externalOptions = new IfwPsn_Wp_Options_Section('external', ''); IfwPsn_Wp_Proxy_Action::doAction($this->_pm->getAbbrLower() . '_external_options_init', $externalOptions); $this->addSection($externalOptions); do_action($this->_pm->getAbbrLower() . '_on_options_load'); } }
public function load() { IfwPsn_Wp_Proxy_Action::addWidgetsInit(array($this, 'register')); }
/** * @param IfwPsn_Vendor_Zend_Controller_Request_Abstract $request * @param IfwPsn_Vendor_Zend_Controller_Response_Abstract $response * @throws IfwPsn_Vendor_Zend_Controller_Dispatcher_Exception */ public function initController(IfwPsn_Vendor_Zend_Controller_Request_Abstract $request, IfwPsn_Vendor_Zend_Controller_Response_Abstract $response) { $this->setResponse($response); /** * Get controller class */ if (!$this->isDispatchable($request)) { $controller = $request->getControllerName(); if (!$this->getParam('useDefaultControllerAlways') && !empty($controller)) { //require_once 'IfwZend/Controller/Dispatcher/Exception.php'; throw new IfwPsn_Vendor_Zend_Controller_Dispatcher_Exception('Invalid controller specified (' . $request->getControllerName() . ')'); } $className = $this->getDefaultControllerClass($request); } else { $className = $this->getControllerClass($request); if (!$className) { $className = $this->getDefaultControllerClass($request); } } /** * Load the controller class file */ $className = $this->loadClass($className); /** * Instantiate controller with request, response, and invocation * arguments; throw exception if it's not an action controller */ $controller = new $className($request, $this->getResponse(), $this->getParams()); if (!$controller instanceof IfwPsn_Vendor_Zend_Controller_Action_Interface && !$controller instanceof IfwPsn_Vendor_Zend_Controller_Action) { //require_once 'IfwZend/Controller/Dispatcher/Exception.php'; throw new IfwPsn_Vendor_Zend_Controller_Dispatcher_Exception('Controller "' . $className . '" is not an instance of IfwPsn_Vendor_Zend_Controller_Action_Interface'); } if (method_exists($controller, 'onBootstrap')) { $controller->onBootstrap(); } // add WP actions hooks IfwPsn_Wp_Proxy_Action::addAdminMenu(array($controller, 'onAdminMenu')); IfwPsn_Wp_Proxy_Action::addAdminInit(array($controller, 'onAdminInit')); IfwPsn_Wp_Proxy_Action::addCurrentScreen(array($controller, 'onCurrentScreen')); $this->_controller = $controller; }
/** * @param IfwPsn_Vendor_Zend_Controller_Request_Abstract $request * @param IfwPsn_Vendor_Zend_Controller_Response_Abstract $response * @throws Exception */ public function initController(IfwPsn_Wp_Plugin_Manager $pm, IfwPsn_Vendor_Zend_Controller_Request_Abstract $request = null, IfwPsn_Vendor_Zend_Controller_Response_Abstract $response = null) { if (!$this->getParam('noErrorHandler') && !$this->_plugins->hasPlugin('IfwPsn_Vendor_Zend_Controller_Plugin_ErrorHandler')) { // Register with stack index of 100 //require_once 'IfwZend/Controller/Plugin/ErrorHandler.php'; $this->_plugins->registerPlugin(new IfwPsn_Vendor_Zend_Controller_Plugin_ErrorHandler(), 100); } if (!$this->getParam('noViewRenderer') && !IfwPsn_Vendor_Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer')) { //require_once 'IfwZend/Controller/Action/Helper/ViewRenderer.php'; IfwPsn_Vendor_Zend_Controller_Action_HelperBroker::getStack()->offsetSet(-80, new IfwPsn_Vendor_Zend_Controller_Action_Helper_ViewRenderer()); } /** * Instantiate default request object (HTTP version) if none provided */ if (null !== $request) { $this->setRequest($request); } elseif (null === $request && null === ($request = $this->getRequest())) { //require_once 'IfwZend/Controller/Request/Http.php'; $request = new IfwPsn_Vendor_Zend_Controller_Request_Http(); $this->setRequest($request); } $request->setActionKey($pm->getConfig()->getActionKey()); /** * Set base URL of request object, if available */ if (is_callable(array($this->_request, 'setBaseUrl'))) { if (null !== $this->_baseUrl) { $this->_request->setBaseUrl($this->_baseUrl); } } /** * Instantiate default response object (HTTP version) if none provided */ if (null !== $response) { $this->setResponse($response); } elseif (null === $this->_response && null === ($this->_response = $this->getResponse())) { //require_once 'IfwZend/Controller/Response/Http.php'; $response = new IfwPsn_Vendor_Zend_Controller_Response_Http(); $this->setResponse($response); } //IfwPsn_Wp_Proxy_Action::doPlugin($pm, 'before_controller_init', $this); /** * Register request and response objects with plugin broker */ $this->_plugins->setRequest($this->_request)->setResponse($this->_response); IfwPsn_Wp_Proxy_Action::doPlugin($pm, 'before_controller_init', $this); /** * Initialize router */ $router = $this->getRouter(); $router->setParams($this->getParams()); /** * Initialize dispatcher */ $dispatcher = $this->getDispatcher(); $dispatcher->setParams($this->getParams())->setResponse($this->_response); // Begin dispatch try { /** * Route request to controller/action, if a router is provided */ /** * Notify plugins of router startup */ $this->_plugins->routeStartup($this->_request); try { $router->route($this->_request); } catch (Exception $e) { throw $e; } /** * Needed for custom route RequestVars */ $this->_plugins->routeShutdown($this->_request); /** * skip plugins dispatchLoopStartup on initController */ //$this->_plugins->dispatchLoopStartup($this->_request); /** * Attempt to dispatch the controller/action. If the $this->_request * indicates that it needs to be dispatched, move to the next * action in the request. */ do { $this->_request->setDispatched(true); /** * skip plugins preDispatch on initController */ $this->_plugins->preDispatch($this->_request); /** * Skip requested action if preDispatch() has reset it */ //if (!$this->_request->isDispatched()) { // continue; //} /** * init controller */ try { // this will add custom WP action to the controller object $dispatcher->initController($this->_request, $this->_response); } catch (Exception $e) { throw $e; } /** * skip plugins postDispatch on initController */ //$this->_plugins->postDispatch($this->_request); } while (!$this->_request->isDispatched()); } catch (Exception $e) { throw $e; } }
/** * @param $handle * @param bool $src * @param array $deps * @param bool|string $ver * @param bool $in_footer * @param array $localize * @return void */ public static function loadAdmin($handle, $src = false, $deps = array(), $ver = false, $in_footer = false, $localize = array()) { if (!isset(self::$_scriptsAdmin[$handle])) { self::$_scriptsAdmin[$handle] = array('src' => $src, 'deps' => $deps, 'ver' => $ver, 'in_footer' => $in_footer); } if (is_array($localize) && !empty($localize)) { self::localize($handle, key($localize), $localize[key($localize)]); } if (self::$_enqueueAdminSet == false) { IfwPsn_Wp_Proxy_Action::addAdminEnqueueScripts(array('IfwPsn_Wp_Proxy_Script', '_enqueueAdminScripts')); self::$_enqueueAdminSet = true; } }
/** * load default services */ protected function _loadServices() { require_once $this->_pm->getPathinfo()->getRootLib() . 'Psn/Notification/Service/Email.php'; $this->addService(new Psn_Notification_Service_Email()); IfwPsn_Wp_Proxy_Action::doAction('psn_after_load_services', $this); }
/** * Initializes commonly used properties */ protected function _initFormView() { require_once $this->_pm->getPathinfo()->getRootLib() . 'Psn/Patch/Database.php'; require_once $this->_pm->getPathinfo()->getRootLib() . 'Psn/Admin/Form/NotificationRule.php'; require_once $this->_pm->getPathinfo()->getRootLib() . 'Psn/Notification/Placeholders.php'; require_once $this->_pm->getPathinfo()->getRootLib() . 'IfwPsn/Wp/Plugin/Menu/Help.php'; $dbPatcher = new Psn_Patch_Database(); $this->view->dbPatcher = $dbPatcher; if (!$this->_pm->isPremium()) { IfwPsn_Wp_Proxy_Filter::add('psn_rule_form_description_cc', create_function('$var', 'return $var . " " . __("Limited to 1. Get the Premium version for unlimited Cc emails.", "psn");')); IfwPsn_Wp_Proxy_Filter::add('psn_rule_form_description_bcc', create_function('$var', 'return $var . " " . __("(Premium feature)", "psn");')); } $formOptions = array(); if ($this->_pm->getOptionsManager()->getOption('psn_hide_nonpublic_posttypes') != null) { $formOptions['hide_nonpublic_posttypes'] = true; } $this->_form = new Psn_Admin_Form_NotificationRule($formOptions); if (!$this->_pm->isPremium()) { $this->_form->getElement('recipient')->setDescription(__('Get additional recipients like user roles (including custom roles) or all users with the Premium version.', 'psn')); } $this->_helper->viewRenderer('form'); $placeholders = new Psn_Notification_Placeholders(); $help = new IfwPsn_Wp_Plugin_Menu_Help($this->_pm); $help->setTitle(__('Placeholders', 'psn'))->setId('placeholders')->setHelp($placeholders->getOnScreenHelp())->setSidebar($this->_getHelpSidebar())->load(); $help = new IfwPsn_Wp_Plugin_Menu_Help($this->_pm); $help->setTitle(__('Conditions', 'psn'))->setId('conditions')->setHelp(IfwPsn_Wp_Tpl::getFilesytemInstance($this->_pm)->render('admin_help_conditions.html.twig', array('pm' => $this->_pm)))->setSidebar($this->_getHelpSidebar())->load(); $this->view->langListOfPlaceholdersLabel = __('Show list of placeholders available for subject and text', 'psn'); $this->view->langListOfPlaceholdersLink = __('List of placeholders', 'psn'); $this->view->langHelp = __('Help', 'ifw'); if (Psn_Model_Rule::hasMax() && Psn_Model_Rule::reachedMax() && $this->getRequest()->getActionName() == 'create') { $this->view->maxReached = __(sprintf('You reached the maximum number of rules (%s) for the free version. Get the <a href="%s" target="_blank">Premium Version</a> for unlimmited rules and more features.', Psn_Model_Rule::getMax(), $this->_pm->getConfig()->plugin->premiumUrl), 'psn'); } if ($this->_request->getActionName() == 'create') { $this->view->langHeadline = __('Create new rule', 'psn'); IfwPsn_Wp_Proxy_Script::loadAdmin('psn_rule_examples', $this->_pm->getEnv()->getUrlAdminJs() . 'rule_examples.js', array(), $this->_pm->getEnv()->getVersion()); IfwPsn_Wp_Proxy_Script::localize('psn_rule_examples', 'PsnExampleRule', array('ThePendingPost' => __('The pending post', 'psn'), 'ThePendingPostSubject' => __('[blog_name]: New post is waiting for review', 'psn'), 'ThePendingPostBody' => str_replace('<br>', "\n", __('Howdy admin,<br>there is a new post by [author_display_name] waiting for review:<br>"[post_title]".<br><br>Here is the permalink: [post_permalink]<br><br>Here is the backend edit link: [post_editlink]<br><br>The author\'s email address is [author_email]<br><br>[blog_wpurl]', 'psn')), 'TheHappyAuthor' => __('The happy author', 'psn'), 'TheHappyAuthorSubject' => __('Your post on [blog_name] got published!', 'psn'), 'TheHappyAuthorBody' => str_replace('<br>', "\n", __('Howdy [author_display_name],<br>we are happy to tell you that your post "[post_title]" got published.<br><br>Here is the permalink: [post_permalink]<br><br>Thanks for your good work,<br>your [blog_name]-Team<br><br>[blog_wpurl]', 'psn')), 'ThePedanticAdmin' => __('The pedantic admin', 'psn'), 'ThePedanticAdminSubject' => __('[blog_name]: Post status transition from [post_status_before] to [post_status_after]', 'psn'), 'ThePedanticAdminBody' => str_replace('<br>', "\n", __('Howdy admin,<br>a post status transition was a detected on "[post_title]".<br><br>Status before: [post_status_before]<br>Status after: [post_status_after]<br><br>Post permalink: [post_permalink]', 'psn')))); IfwPsn_Wp_Proxy_Style::loadAdmin('psn_rule_examples', $this->_pm->getEnv()->getUrlAdminCss() . 'rule_examples.css'); $this->view->langExamples = __('Examples', 'psn'); $this->view->langExamplesDesc = __('Click the buttons below to get an idea of how you can set up notification rules.', 'psn'); $this->view->langExamplesRuleThePendingPost = __('The pending post', 'psn'); $this->view->langExamplesRuleThePendingPostDesc = __('This rule sends a notification when a new post got submitted for review.', 'psn'); $this->view->langExamplesRuleTheHappyAuthor = __('The happy author', 'psn'); $this->view->langExamplesRuleTheHappyAuthorDesc = __('This rule sends an email to the author of a post when it got published.', 'psn'); $this->view->langExamplesRuleThePedanticAdmin = __('The pedantic admin', 'psn'); $this->view->langExamplesRuleThePedanticAdminDesc = __('This rule is for blog admins who want to be informed about every single post status change.', 'psn'); $this->view->langExamplesRuleDebug = __('Debug rule', 'psn'); $this->view->langExamplesRuleDebugDesc = __('This rule is just for creating log entries to monitor all available values when the rule matched. Remember to activate option Logger / Log rule matches.', 'psn') . ' ' . sprintf('<a href="%s" target="_blank">' . __('More details', 'psn') . '</a>', $this->_pm->getConfig()->plugin->docUrl . 'rules.html#debug-rule'); } else { $this->view->langHeadline = __('Edit notification rule', 'psn'); $this->_form->getElement('submit')->setLabel(__('Update', 'psn')); $this->_form->getElement('submit_and_stay')->setLabel(__('Update and stay on page', 'psn')); } $this->view->actionName = $this->_request->getActionName(); IfwPsn_Wp_Proxy_Script::loadAdmin('psn_rule_form', $this->_pm->getEnv()->getUrlAdminJs() . 'rule_form.js', array(), $this->_pm->getEnv()->getVersion()); IfwPsn_Wp_Proxy_Script::localize('psn_rule_form', 'psn', array('is_premium' => $this->_pm->isPremium())); IfwPsn_Wp_Proxy_Script::localize('psn_rule_form', 'psn_taxonomies', array_merge(IfwPsn_Wp_Proxy_Post::getAllTypesCategories(), array('lang_Categories' => __('Categories', 'psn'), 'lang_categories_help' => sprintf(__('To select multiple categories hold down the control button (ctrl) on Windows or command button (cmd) on Mac.<br>If nothing is selected, all categories get included.<br>Exclude is dominant. See the <a href="%s" target="_blank">docs</a> for more details.', 'psn'), 'http://docs.ifeelweb.de/post-status-notifier/rules.html#category-filter'), 'lang_include_categories' => __('Include only these categories', 'psn'), 'lang_exclude_categories' => __('Exclude categories', 'psn'), 'lang_select_all' => __('select all', 'psn'), 'lang_remove_all' => __('remove all', 'psn'), 'lang_no_categories' => __('Post type "%s" has no categories.', 'psn'), 'lang_premium_feature' => sprintf(__('This is a <a href="%s" target="_blank">Premium</a> feature.', 'psn'), $this->_pm->getConfig()->plugin->premiumUrl)))); IfwPsn_Wp_Proxy_Action::doAction('psn_rule_form', $this->_form); }
/** * @return array */ public static function getPlugins() { $result = array(); if (IfwPsn_Wp_Proxy_Action::didPluginsLoaded()) { $result = get_plugins(); } return $result; }
protected function _init() { IfwPsn_Wp_Proxy_Action::add($this->_pm->getAbbrLower() . '_general_options_init', array($this, 'registerOptionsCallback')); IfwPsn_Wp_Proxy_Action::add($this->_pm->getAbbrLower() . '_external_options_init', array($this, 'registerOptionsCallback')); }