/**
  *
  * @param array $options
  * @author Panagiotis Vagenas <*****@*****.**>
  * @since 2.0.0
  */
 protected function __construct($options)
 {
     if (!class_exists('erpQueryFormater')) {
         erpPaths::requireOnce(erpPaths::$erpQueryFormater);
     }
     if (!class_exists('erpRatingSystem')) {
         erpPaths::requireOnce(erpPaths::$erpRatingSystem);
     }
     if (!class_exists('erpRelData')) {
         erpPaths::requireOnce(erpPaths::$erpRelData);
     }
     $this->options = $options;
 }
" 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 delWidOptions()
 {
     erpPaths::requireOnce(erpPaths::$erpWidOpts);
     $wOpts = new erpWidOpts();
     delete_option($wOpts->getOptionsArrayName());
 }
 /**
  * Get default thumb url
  * @return string|NULL
  * @author Panagiotis Vagenas <*****@*****.**>
  * @since 2.0.0
  */
 public function getDefaultThumbnail()
 {
     if ($this instanceof erpMainOpts) {
         $t = $this->getValue('defaultThumbnail');
     } else {
         erpPaths::requireOnce(erpPaths::$erpMainOpts);
         $mOpts = new erpMainOpts();
         $t = $mOpts->getDefaultThumbnail();
     }
     return !empty($t) ? $t : erpDefaults::$comOpts['defaultThumbnail'];
 }
 /**
  * Uses bfi resizer to resize image and returns url to new image
  * @param string $url
  * @param int $width
  * @param int $height
  * @param bool $crop
  * @return string
  * @author Panagiotis Vagenas <*****@*****.**>
  * @since 2.0.0
  */
 private function resize($url, $width = NULL, $height = NULL, $crop = true)
 {
     erpPaths::requireOnce(erpPaths::$bfiResizer);
     return bfi_thumb($url, array('width' => $width, 'height' => $height, 'crop' => $crop));
 }
}
/* ----------------------------------------------------------------------------*
 * Public-Facing Functionality
 * ---------------------------------------------------------------------------- */
erpPaths::requireOnce(erpPaths::$erpWidget);
erpPaths::requireOnce(erpPaths::$easyRelatedPosts);
/*
 * Register hooks that are fired when the plugin is activated or deactivated.
 * When the plugin is deleted, the uninstall.php file is loaded.
 */
register_activation_hook(__FILE__, array('easyRelatedPosts', 'activate'));
register_deactivation_hook(__FILE__, array('easyRelatedPosts', 'deactivate'));
/**
 * Register plugin and widget
 */
add_action('plugins_loaded', array('easyRelatedPosts', 'get_instance'));
function regERPWidget()
{
    register_widget("ERP_Widget");
}
add_action('widgets_init', 'regERPWidget');
/* ----------------------------------------------------------------------------*
 * Dashboard and Administrative Functionality
 * ---------------------------------------------------------------------------- */
/**
 */
if (is_admin()) {
    erpPaths::requireOnce(erpPaths::$easyRelatedPostsAdmin);
    erpPaths::requireOnce(erpPaths::$WP_Admin_Notices);
    add_action('plugins_loaded', array('easyRelatedPostsAdmin', 'get_instance'));
}
 /**
  * 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;
 }
Example #8
0
 />
                            </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;
 }
<?php

/**
 * Easy related posts .
 *
 * @package   Easy_Related_Posts_Options
 * @author    Panagiotis Vagenas <*****@*****.**>
 * @link      http://erp.xdark.eu
 * @copyright 2014 Panagiotis Vagenas <*****@*****.**>
 */
erpPaths::requireOnce(erpPaths::$erpOptions);
/**
 * Widget options class.
 *
 * @package Easy_Related_Posts_Options
 * @author    Panagiotis Vagenas <*****@*****.**>
 */
class erpWidOpts extends erpOptions
{
    public function __construct(array $instance = NULL)
    {
        parent::__construct();
        $this->optionsArrayName = 'widget_' . erpDefaults::erpWidgetOptionsArrayName;
        $this->defaults = erpDefaults::$widOpts + erpDefaults::$comOpts;
        if ($instance !== NULL && !empty($instance)) {
            $this->options = $instance;
        } else {
            $this->options = $this->defaults;
        }
    }
    /**
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
/**
 * @copyright 2014 Panagiotis Vagenas <*****@*****.**>
 */
erpPaths::requireOnce(erpPaths::$erpTheme);
/**
 * Description of erpTheme
 * 
 * @author Panagiotis Vagenas <*****@*****.**>
 */
class erpBasicListWidTheme extends erpTheme
{
    /**
     * The name of the theme
     * @var string 
     */
    protected $name = 'Basic list';
    /**
     * A description for theme
     * @var string
 /**
  * Fired for each blog when the plugin is activated.
  *
  * @since 2.0.0
  */
 private static function single_activate()
 {
     erpPaths::requireOnce(erpPaths::$erpActivator);
     $compareVersions = erpDefaults::compareVersion(get_option(erpDefaults::versionNumOptName));
     if ($compareVersions < 0) {
         // New install
         /**
          * If an old version is present translate options
          */
         if (get_option('erpVersion')) {
             $mainOpts = self::migrateMainOptions();
             $notice = new WP_Updated_Notice('<strong>Easy Related Posts updated from V1 to V2.</strong>' . 'You should review the main plugin and widget settings.<br>' . 'There are some major changes in this version and this affects options as well. ' . 'We are  sorry for the inconvenience but this was necessary to move this plugin forward');
             WP_Admin_Notices::getInstance()->addNotice($notice);
             // Delete old options
             delete_option('erpVersion');
             delete_option('erpSubVersion');
             delete_option('erpOpts');
         } else {
             $mainOpts = erpDefaults::$comOpts + erpDefaults::$mainOpts;
         }
         erpActivator::addNonExistingMainOptions($mainOpts, EPR_MAIN_OPTIONS_ARRAY_NAME);
         erpActivator::addNonExistingWidgetOptions(erpDefaults::$comOpts + erpDefaults::$mainOpts, 'widget_' . erpDefaults::erpWidgetOptionsArrayName);
         erpDefaults::updateVersionNumbers();
     } elseif ($compareVersions === 0) {
         // Major update
         erpDefaults::updateVersionNumbers();
     } elseif ($compareVersions === 1) {
         // Release update
         erpDefaults::updateVersionNumbers();
     } elseif ($compareVersions === 2) {
         // Minor update
         erpDefaults::updateVersionNumbers();
     }
 }
 public function formPostData(WP_Query $wpq, erpOptions $optionsObj, $ratings = array())
 {
     erpPaths::requireOnce(erpPaths::$erpPostData);
     $data = array('title' => $optionsObj->getValue('title'), 'options' => $this->options, 'uniqueID' => $this->uniqueID, 'optionsObj' => $optionsObj, 'posts' => array());
     while ($wpq->have_posts()) {
         $wpq->the_post();
         $rating = isset($ratings[get_the_ID()]) ? $ratings[get_the_ID()] : null;
         $postData = new erpPostData($wpq->post, $optionsObj, $rating);
         if ($optionsObj->haveToShowExcerpt()) {
             $postData->setExcerpt($optionsObj->getValue('excLength'), $optionsObj->getValue('moreTxt'));
         }
         if ($optionsObj->haveToShowThumbnail()) {
             $postData->setThumbnail($optionsObj->getDefaultThumbnail());
         }
         array_push($data['posts'], $postData);
     }
     wp_reset_postdata();
     $this->setAdditionalViewData(array_merge($data, $this->options));
     return $this;
 }