/** * @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; }
/** * Applies filters to the replacement string * * @param string $replacement * @param array $options * @return string */ protected function _applyFilters($replacement, $options) { if (!empty($options['filters'])) { $replacement = IfwPsn_Wp_Tpl::applyFilters($replacement, $options['filters'], $this->_logger); } return $replacement; }
/** * Retrieves the file loader instance * * @param IfwPsn_Wp_Plugin_Manager $pm * @param array $twigOptions * @return IfwPsn_Wp_WunderScript_Parser */ public static function getFileInstance(IfwPsn_Wp_Plugin_Manager $pm, $twigOptions = array()) { if (self::$_instanceFile === null) { require_once dirname(__FILE__) . '/../Tpl.php'; $env = IfwPsn_Wp_Tpl::getFilesytemInstance($pm, $twigOptions); self::$_instanceFile = new self($env); } return self::$_instanceFile; }
/** * @return IfwPsn_Wp_Ajax_Response_Abstract */ public function getResponse() { try { $rssItems = $this->_getFeedItems($this->_feedItems); $tpl = IfwPsn_Wp_Tpl::getFilesytemInstance($this->_pm); $success = true; $html = $tpl->render($this->_feedItemsTpl, array('items' => $this->_prepareItems($rssItems))); } catch (Exception $e) { $success = false; $html = sprintf(__('Error while loading newsfeed: %s', 'ifw'), $this->_feedUrl); } return new IfwPsn_Wp_Ajax_Response_Json($success, array('html' => $html)); }
/** * @return IfwPsn_Wp_Ajax_Response_Abstract */ public function getResponse() { if ($this->_pm->hasPremium() && $this->_pm->isPremium()) { $this->_addPremiumBlock(); } $this->_addConnectBlock(); $this->_addHelpBlock(); $tpl = IfwPsn_Wp_Tpl::getInstance($this->_pm); $html = ''; foreach ($this->_infoBlocks as $block) { $params = array('label' => $block['label'], 'content' => $block['content'], 'iconClass' => $block['iconClass']); $html .= $tpl->render('metabox_plugininfo_block.html.twig', $params); } $html .= '<p class="ifw-made-with-heart">This plugin was made with <img src="' . $this->_pm->getEnv()->getSkinUrl() . 'icons/heart.png" /> by <a href="http://www.ifeelweb.de/" target="_blank">ifeelweb.de</a></p>'; $success = true; $response = new IfwPsn_Wp_Ajax_Response_Json($success); $response->addData('html', $html); return $response; }
/** * @param IfwPsn_Wp_Plugin_Manager $pm * @param $identifier * @param array $options * @return string */ public static function getForm(IfwPsn_Wp_Plugin_Manager $pm, $identifier, $options = array()) { $context = array('identifier' => $identifier, 'headline' => $options['headline'], 'help_text' => $options['help_text'], 'action_url' => $options['action_url'], 'import_file_label' => $options['import_file_label'], 'import_file_description' => $options['import_file_description'], 'import_prefix_label' => $options['import_prefix_label'], 'import_prefix_description' => $options['import_prefix_description'], 'wait_text_headline' => $options['wait_text_headline'], 'wait_text_description' => $options['wait_text_description'], 'nonce' => wp_create_nonce(IfwPsn_Zend_Controller_ModelBinding::getImportNonceAction($identifier))); return IfwPsn_Wp_Tpl::getFilesytemInstance($pm)->render('import_form.html.twig', $context); }
/** * @param IfwPsn_Wp_Plugin_Manager $pm * @return string */ public static function getServerEnvironment(IfwPsn_Wp_Plugin_Manager $pm) { $tpl = IfwPsn_Wp_Tpl::getFilesytemInstance($pm); $count_users = count_users(); $mysql_server_info = @mysql_get_server_info(); $mysql_client_info = @mysql_get_client_info(); $phpAutoloadFunctions = array(); foreach (IfwPsn_Wp_Autoloader::getAllRegisteredAutoloadFunctions() as $function) { try { if (is_string($function)) { array_push($phpAutoloadFunctions, $function); } elseif (is_array($function) && count($function) == 2) { $autoloadObject = $function[0]; if (is_object($autoloadObject)) { $autoloadObject = get_class($autoloadObject); } $autoloadMethod = $function[1]; if (!is_scalar($autoloadMethod)) { $autoloadMethod = var_export($autoloadMethod, true); } array_push($phpAutoloadFunctions, $autoloadObject . '::' . $autoloadMethod); } elseif (is_object($function)) { array_push($phpAutoloadFunctions, get_class($function)); } } catch (Exception $e) { // no action } } $context = array('plugin_name' => $pm->getEnv()->getName(), 'plugin_version' => $pm->getEnv()->getVersion(), 'plugin_build_number' => $pm->getEnv()->getBuildNumber(), 'plugin_modules' => $pm->getBootstrap()->getModuleManager()->getModules(), 'plugin_modules_initialized' => $pm->getBootstrap()->getModuleManager()->getInitializedModules(), 'plugin_modules_custom_dir' => $pm->getBootstrap()->getModuleManager()->getCustomModulesLocation(), 'OS' => PHP_OS, 'uname' => php_uname(), 'wp_version' => IfwPsn_Wp_Proxy_Blog::getVersion(), 'wp_charset' => IfwPsn_Wp_Proxy_Blog::getCharset(), 'wp_count_users' => $count_users['total_users'], 'wp_debug' => WP_DEBUG == true ? 'true' : 'false', 'wp_debug_log' => WP_DEBUG_LOG == true ? 'true' : 'false', 'wp_debug_display' => WP_DEBUG_DISPLAY == true ? 'true' : 'false', 'plugins' => IfwPsn_Wp_Proxy_Blog::getPlugins(), 'theme_name' => IfwPsn_Wp_Proxy_Blog::getThemeName(), 'theme_version' => IfwPsn_Wp_Proxy_Blog::getThemeVersion(), 'theme_author' => IfwPsn_Wp_Proxy_Blog::getThemeAuthor(), 'theme_uri' => IfwPsn_Wp_Proxy_Blog::getThemeURI(), 'php_version' => phpversion(), 'php_memory_limit' => ini_get('memory_limit'), 'php_extensions' => IfwPsn_Wp_Server_Php::getExtensions(), 'php_include_path' => get_include_path(), 'php_open_basedir' => ini_get('open_basedir'), 'php_autoload_functions' => $phpAutoloadFunctions, 'mysql_version' => !empty($mysql_server_info) ? $mysql_server_info : '', 'mysql_client' => !empty($mysql_client_info) ? $mysql_client_info : '', 'server_software' => $_SERVER['SERVER_SOFTWARE']); if (function_exists('apache_get_version')) { $context['apache_version'] = apache_get_version(); } if (function_exists('apache_get_modules')) { $context['apache_modules'] = apache_get_modules(); } return $tpl->render('server_env.html.twig', $context); }
/** * Inits the template engine */ protected function _initTemplateEngine() { $this->_tpl = IfwPsn_Wp_Tpl::getFilesytemInstance($this->_pm); }
/** * @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; }
/** * 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); }
/** * @see IfwPsn_Wp_Plugin_Admin_Menu_Metabox_Abstract::render() */ public function render() { $tpl = IfwPsn_Wp_Tpl::getInstance($this->_pm); $tpl->display('premium_ad.html.twig', array('plugin_homepage' => $this->_pm->getEnv()->getHomepage(), 'premium_url' => $this->_pm->getConfig()->plugin->premiumUrl)); }
/** * register the module's tpl dir to loader path */ public function initTpl() { if ($this->_pathinfo->hasRootTpl()) { IfwPsn_Wp_Tpl::getFilesytemInstance($this->_pm)->getLoader()->addPath($this->_pathinfo->getRootTpl()); } }
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); }