public function __construct()
 {
     parent::__construct();
     $this->optionsArrayName = erpPROShortCodeOpts::$shortCodeProfilesArrayName;
     $profiles = get_option(erpPROShortCodeOpts::$shortCodeProfilesArrayName);
     $this->profiles = is_array($profiles) ? $profiles : array();
     $this->defaults = erpPRODefaults::$shortCodeOpts + erpPRODefaults::$comOpts;
 }
 public function __construct(array $instance = NULL)
 {
     parent::__construct();
     $this->optionsArrayName = 'widget_' . erpPRODefaults::erpPROWidgetOptionsArrayName;
     $this->defaults = erpPRODefaults::$widOpts + erpPRODefaults::$comOpts;
     if ($instance !== NULL && !empty($instance)) {
         $this->options = $instance;
     } else {
         $this->options = $this->defaults;
     }
 }
 /**
  * Deletes a single option from options array in DB
  *
  * @param string $optionName
  *        	Option name
  * @author Panagiotis Vagenas <*****@*****.**>
  * @since 1.0.0
  */
 public function deleteOption($optionName)
 {
     if ($this->optionsArrayName === NULL) {
         return FALSE;
     }
     $value = parent::deleteOption($optionName);
     if ($value !== NULL) {
         if (update_option($this->optionsArrayName, $this->options)) {
             return TRUE;
         }
         $this->options[$optionName] = $value;
     }
     return FALSE;
 }
 /**
  * Set positions based on options (content)
  *
  * @param array $options
  *        	Assoc array
  * @author Panagiotis Vagenas <*****@*****.**>
  * @since 1.0.0
  */
 private function setPositions($options)
 {
     if (!$this->options->getContentPositioning() || !is_array($this->options->getContentPositioning())) {
         $this->positions[0] =& $this->thumbnail;
         $this->positions[1] =& $this->title;
         $this->positions[2] =& $this->excerpt;
     } else {
         foreach ($this->options->getContentPositioning() as $k => $v) {
             if ($v == 'title') {
                 $this->positions[$k] =& $this->title;
             } elseif ($v == 'thumbnail') {
                 $this->positions[$k] =& $this->thumbnail;
             } elseif ($v == 'excerpt') {
                 $this->positions[$k] =& $this->excerpt;
             }
         }
     }
 }
 /**
  * Calculates weights based on options
  *
  * @return array Assoc array (categories,tags,clicks)
  * @author Panagiotis Vagenas <*****@*****.**>
  * @since 1.0.0
  */
 private function calcWeights()
 {
     return isset(erpPRODefaults::$fetchByOptionsWeights[$this->options->getFetchBy()]) ? erpPRODefaults::$fetchByOptionsWeights[$this->options->getFetchBy()] : erpPRODefaults::$fetchByOptionsWeights['categories'];
 }
 public function formPostData(WP_Query $wpq, erpPROOptions $optionsObj, $ratings = array())
 {
     erpPROPaths::requireOnce(erpPROPaths::$erpPROPostData);
     $from = get_the_ID();
     $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 erpPROPostData($wpq->post, $optionsObj, $rating, $from);
         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;
 }