Пример #1
0
 /**
  * @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;
 }
Пример #2
0
 /**
  * @param $placeholders
  * @return array
  */
 public function filterPlaceholders(array $placeholders)
 {
     $filters = $this->_pm->getBootstrap()->getOptionsManager()->getOption('placeholders_filters');
     if (!empty($filters)) {
         $counter = 0;
         foreach (preg_split("/((\r?\n)|(\r\n?))/", $filters) as $filter) {
             if (!$this->_pm->isPremium() && $counter >= 1) {
                 break;
             }
             preg_match_all('/\\[([A-Za-z0-9_-]+?)\\]/', $filter, $match);
             if (isset($match[0][0]) && isset($match[1][0])) {
                 $placeholder_tag = $match[0][0];
                 $placeholder_name = $match[1][0];
                 if (isset($placeholders[$placeholder_name])) {
                     $filter_string = str_replace($placeholder_tag, '"' . $placeholders[$placeholder_name] . '"', $filter);
                     if (!empty($filter_string)) {
                         if ($filter_string[0] != '{') {
                             $filter_string = '{{ ' . $filter_string . ' }}';
                         }
                         $placeholders[$placeholder_name] = IfwPsn_Wp_Tpl::renderString($filter_string);
                     }
                 }
             }
             $counter++;
         }
     }
     return $placeholders;
 }
Пример #3
0
 /**
  * @return bool
  */
 protected function _skipAutorun()
 {
     if ($this->_pm->getBootstrap()->getUpdateManager()->getPatcher()->isPatchesAvailable()) {
         return true;
     }
     return false;
 }
Пример #4
0
 protected function _addOptions()
 {
     $this->_pm->getOptionsManager()->addGeneralOption(new IfwPsn_Wp_Options_Field_Checkbox('psn_ignore_status_inherit', __('Ignore post status "inherit"', 'psn'), __('Status "inherit" is used when post revisions get created by WordPress automatically', 'psn')));
     $this->_pm->getOptionsManager()->addGeneralOption(new IfwPsn_Wp_Options_Field_Checkbox('psn_hide_nonpublic_posttypes', __('Hide non-public post types', 'psn'), __('When selected, non-public post types will be excluded from rule settings form', 'psn')));
     if (!$this->_pm->isPremium()) {
         $smtpOptions = new IfwPsn_Wp_Options_Section('smtp', __('SMTP', 'psn_smtp'));
         $smtpOptions->addField(new IfwPsn_Wp_Options_Field_Checkbox('smtp_teaser', __('Activate SMTP', 'psn'), __('SMTP is a premium feature. You will get all configuration options to connect to your SMTP server.', 'psn')));
         $this->_pm->getBootstrap()->getOptions()->addSection($smtpOptions, 12);
     }
     $placeholderFilterOptions = new IfwPsn_Wp_Options_Section('placeholders', __('Placeholders', 'psn'));
     $placeholderFilterOptions->addField(new IfwPsn_Wp_Options_Field_Textarea('placeholders_filters', __('Placeholders filters', 'psn'), sprintf(__('Here you can define filters which will apply to the placeholders contents (One filter per line). You can use the <a href="%s" target="_blank">Twig filters</a>. Refer to the <a href="%s" target="_blank">documentation</a> for details.<br>Example: [post_date]|date("m/d/Y")', 'psn_smtp'), 'http://twig.sensiolabs.org/doc/filters/index.html', 'http://docs.ifeelweb.de/post-status-notifier/options.html#placeholders')));
     $this->_pm->getBootstrap()->getOptions()->addSection($placeholderFilterOptions, 300);
     // Advanced
     $advancedOptions = new IfwPsn_Wp_Options_Section('advanced', __('Advanced', 'psn'));
     do_action('psn_options_advanced', $advancedOptions);
     if (function_exists('apc_clear_cache')) {
         // APC 502 bad gateway workaround
         $advancedOptions->addField(new IfwPsn_Wp_Options_Field_Checkbox('apc_clear_cache', __('APC clear cache', 'psn'), __('In case you are facing issues when updating rules or email templates (blank page, 502 Bad Gateway on nginx), please activate this option and try again. Or ask your webhost to deactivate APC. This option will deactivate the APC cache on PSN admin pages.', 'psn')));
     }
     $this->_pm->getBootstrap()->getOptions()->addSection($advancedOptions, 400);
 }
Пример #5
0
 public function render()
 {
     require_once $this->_pm->getPathinfo()->getRootLib() . '/IfwPsn/Wp/Upload.php';
     $uploader = new IfwPsn_Wp_Upload($this->_id);
     $uploader->setMimeTypes(array('zip' => 'application/zip', 'zip' => 'application/octet-stream'));
     echo '<div id="module_upload">';
     if ($this->_extendingDocUrl != '') {
         echo '<div class="extending_doc_link"><a href="' . $this->_extendingDocUrl . '" target="_blank">' . sprintf(__('Learn how to extend %s', 'ifw'), $this->_pm->getAbbrUpper()) . '</a></div>';
     }
     echo '<h3>' . __('Upload module', 'ifw') . '</h3>';
     $uploader->displayForm($this->_optionsUrl);
     if ($uploader->isUploaded()) {
         if ($uploader->isSuccess()) {
             try {
                 // handle the module archive
                 $archive = new IfwPsn_Wp_Module_Archive($uploader->getFileInfo(), $this->_pm);
                 if ($archive->isValid()) {
                     $archive->extractTo($this->_pm->getBootstrap()->getModuleManager()->getCustomModulesLocation());
                     $archive->close();
                 }
                 $this->_pm->getController()->getMessenger()->addMessage(__('Module installed.', 'ifw'));
             } catch (Exception $e) {
                 $this->_pm->getController()->getMessenger()->addMessage($e->getMessage(), 'error');
             }
             $uploader->remove();
         } else {
             $this->_pm->getController()->getMessenger()->addMessage(__('Error', 'ifw') . ': ' . $uploader->getError(), 'error');
         }
         $this->_pm->getController()->gotoRoute($this->getController(), $this->getAppaction(), $this->getPage());
     }
     echo '</div>';
     $tpl = IfwPsn_Wp_Tpl::getFilesytemInstance($this->_pm);
     $moduleManager = $this->_pm->getBootstrap()->getModuleManager();
     $context = array('custom_modules' => $moduleManager->getCustomModules(), 'activate_url' => wp_nonce_url(admin_url($this->_optionsUrl), $this->_activateNonceName, $this->_activateActionName), 'deactivate_url' => wp_nonce_url(admin_url($this->_optionsUrl), $this->_deactivateNonceName, $this->_deactivateActionName), 'delete_url' => wp_nonce_url(admin_url($this->_optionsUrl), $this->_deleteNonceName, $this->_deleteActionName));
     echo $tpl->render('module_frontend.html.twig', $context);
 }
Пример #6
0
 /**
  * Resets the storage / deactivates all custom modules
  */
 public function reset()
 {
     $this->_pm->getBootstrap()->getOptionsManager()->updateOption($this->_optionName, array());
 }
Пример #7
0
 protected function _isPatchesRedirect(IfwPsn_Vendor_Zend_Controller_Request_Abstract $request)
 {
     return $this->_pm->getBootstrap()->getUpdateManager()->getPatcher()->isPatchesAvailable() && $request->getControllerName() != 'patches' && $request->getActionName() != 'execute';
 }
Пример #8
0
 /**
  * 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());
 }
Пример #9
0
 /**
  * @param IfwPsn_Wp_Plugin_Manager $pm
  */
 protected function _refreshPresentVersion(IfwPsn_Wp_Plugin_Manager $pm)
 {
     $pm->getBootstrap()->getUpdateManager()->refreshPresentVersion();
 }