" style="border: 1px solid lightblue;padding: 10px;border-radius: 5px;"> <span style="position: relative; top: -21px; float: left; background-color: white;"> Theme options </span><br> <?php foreach ($templates as $key => $value) { $temp = VPluginThemeFactory::getThemeByName($value); echo '<span class="templateSettings" data-template="' . $value . '" hidden="hidden">'; $temp->setOptions($options); echo $temp->renderSettings($widgetInstance); echo '</span>'; } ?> </p> <script type="text/javascript"> var templateRoot = "<?php echo erpPaths::getAbsPath(erpPaths::$widgetThemesFolder); ?> "; jQuery(document).ready(function($) { jQuery('#<?php echo $widgetInstance->get_field_id("postTitleColor"); ?> ').wpColorPicker(); jQuery('#<?php echo $widgetInstance->get_field_id("excColor"); ?> ').wpColorPicker(); }); </script>
private static function delTemplateOptions() { erpPaths::requireOnce(erpPaths::$VPluginThemeFactory); VPluginThemeFactory::registerThemeInPathRecursive(erpPaths::getAbsPath(erpPaths::$mainThemesFolder)); $themes = VPluginThemeFactory::getRegisteredThemes(); foreach ((array) $themes as $key => $value) { delete_option($value->getOptionsArrayName()); } }
/** * This is called through ajax hook and returns the plugin options as defined in template settings file * * @author Panagiotis Vagenas <*****@*****.**> * @since 2.0.0 */ public function loadTemplateOptions() { if (!isset($_POST['template']) || !isset($_POST['templateRoot'])) { echo json_encode(false); die; } erpPaths::requireOnce(erpPaths::$VPluginThemeFactory); VPluginThemeFactory::registerThemeInPathRecursive(erpPaths::getAbsPath(erpPaths::$mainThemesFolder), $_POST['template']); $theme = VPluginThemeFactory::getThemeByName($_POST['template']); $data = array(); if ($theme) { $data = array('content' => $theme->renderSettings('', false), 'optionValues' => $theme->getOptions()); } echo json_encode($data); die; }
/> </td> </tr> <?php } ?> </table> </div> </div> <?php echo get_submit_button('Update options', 'primary large', 'Save'); ?> <input id="tab-spec" type="hidden" name="tab-spec" value="0"> <script type="text/javascript"> var templateRoot = "<?php echo erpPaths::getAbsPath(erpPaths::$mainThemesFolder); ?> "; var options = {}; <?php $tabSpec = filter_input(INPUT_GET, 'tab-spec'); if ($tabSpec !== null && $tabSpec !== false) { echo 'options.active= ' . (int) $tabSpec . ';'; } ?> </script> </form> <div style="margin: auto; display: table;"> <div class="get-pro" style=""> <a href="http://erp.xdark.eu/downloads/easy-related-posts-pro/" target="blank"> <img src="<?php
/** * Sanitize widget form values as they are saved. * * @see WP_Widget::update() * * @param array $new_instance * Values just sent to be saved. * @param array $old_instance * Previously saved values from database. * @return array Updated safe values to be saved. * @since 2.0.0 * @author Panagiotis Vagenas <*****@*****.**> */ public function update($new_instance, $old_instance) { /* #? Verify nonce */ if (!isset($_POST['erp_meta_box_nonce']) || !wp_verify_nonce($_POST['erp_meta_box_nonce'], 'erp_meta_box_nonce')) { return; } erpPaths::requireOnce(erpPaths::$erpWidOpts); // get an instance to validate options $widOpts = new erpWidOpts($old_instance); // validate wid options $widOptsValidated = $widOpts->saveOptions($new_instance, $old_instance); // validate template options if (isset($new_instance['dsplLayout'])) { erpPaths::requireOnce(erpPaths::$VPluginThemeFactory); VPluginThemeFactory::registerThemeInPathRecursive(erpPaths::getAbsPath(erpPaths::$widgetThemesFolder), $new_instance['dsplLayout']); $theme = VPluginThemeFactory::getThemeByName($new_instance['dsplLayout']); if ($theme) { $themeValidated = $theme->saveSettings($new_instance); foreach ($theme->getDefOptions() as $key => $value) { unset($new_instance[$key]); } } else { $message = new WP_Error_Notice('Theme ' . $new_instance['dsplLayout'] . ' not found. Theme options discarded'); WP_Admin_Notices::getInstance()->addNotice($message); } } // save updated options return $widOptsValidated + $themeValidated; }
/** * Decides if content should be modified, if yes calls content modifier * * @param string $content * @return string * @author Panagiotis Vagenas <*****@*****.**> * @since 2.0.0 */ public function contentFilter($content) { global $post; /** * Check if is time to take action */ if ($this->isShowTime($post) && !$this->isInExcludedPostTypes($post) && !$this->isInExcludedTaxonomies($post) && (bool) $this->mainOpts->getValue('activate')) { erpPaths::requireOnce(erpPaths::$erpRelated); erpPaths::requireOnce(erpPaths::$VPluginThemeFactory); $relatedObj = erpRelated::get_instance($this->mainOpts); $result = $relatedObj->getRelated($post->ID); $ratings = $relatedObj->getRatingsFromRelDataObj(); if (empty($result) || empty($result->posts)) { return $content; } VPluginThemeFactory::registerThemeInPathRecursive(erpPaths::getAbsPath(erpPaths::$mainThemesFolder), $this->mainOpts->getDsplLayout()); $theme = VPluginThemeFactory::getThemeByName($this->mainOpts->getDsplLayout()); if (!$theme) { return $content; } $theme->formPostData($result, $this->mainOpts, $ratings); $relContent = $theme->render(); return $content . $relContent; } return $content; }