/**
  * since yarpp v4.2.5
  * @param $posts: related posts result
  * @param array $args: keys 'function','args','related_ID'
  */
 public function _yarpp_results($posts, $args)
 {
     global $wp_query;
     $wp_query->posts = $posts;
     /*$cat_posts = $wp_query;
       $arrExlpodeFields = array('title');*/
     /*if(isset($args['args']['compatible_vars']) && is_array($args['args']['compatible_vars'])){
           $this->compatible_vars = array_merge($this->compatible_vars, $args['args']['compatible_vars']);
       }
       $this->compatible_vars = array_merge($this->compatible_vars, $args['args']['skin']->instance->get_migrate());
       foreach($this->compatible_vars as $var => $val){
           $$var = is_string($val) && isset($$val)? $$val : $val;
       }
       */
     //default sidebar params
     $sidebar_params = array('before_widget' => '<div id="%1$s" class="hw-widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>');
     //valid posts
     if (!isset($args['args']['skin'])) {
         return $posts;
     }
     $hwrp = $skin = $args['args']['skin'];
     if (isset($args['args']['hwrp_current'])) {
         $hwrp = (object) $args['args']['hwrp_current'];
         //get current post type related data
     }
     //migrate vars
     $migrate_data = $skin->instance->get_migrate();
     extract($migrate_data);
     //get sidebar wrapper
     if (isset($skin->box_skin)) {
         global $wp_registered_sidebars;
         $sidebar = $args['args']['skin']->box_skin;
         $sidebar_widget_skin = $args['args']['skin']->box_widget_skin;
         //override sidebar skin box with other
         $sidebar_params = array();
         //extract($sidebar_params);   //extract sidebar param
         if ($sidebar_widget_skin) {
             //get change default sidebar skin, here we create 4 holder: sidebar_default, skin1,skin2,skin3
             $skin_data = HW_AWC_Sidebar_Settings::get_sidebar_setting($sidebar_widget_skin, $sidebar);
             HW_SKIN::apply_skin_data($skin_data, array($this, '_hw_skin_resume_skin_data'), array('sidebar' => $sidebar, 'sidebar_widget_skin' => $sidebar_widget_skin, 'sidebar_params' => &$sidebar_params));
             $sidebar_params = HW_AWC::format_widget_sidebar_params(null, $sidebar, array('classname' => 'hw-related-posts hw-awc-override', 'sidebar_params' => $sidebar_params));
         }
     }
     //check related content from widget config
     if (!empty($skin->widget_config)) {
         $widget_instance = AWC_WidgetFeature_saveconfig::get_widget_setting_instance($skin->widget_config, array('widget' => 'hw_taxonomy_post_list_widget', 'group' => 'main_loop'));
         //valid data
         if (!isset($widget_instance['query_data'])) {
             $widget_instance['query_data'] = 'current_context';
         }
         //get global $wp_query
         //override sidebar params from awc feature assign to widget
         if (isset($sidebar_params) && isset($sidebar)) {
             $sidebar_params = HW_AWC::format_sidebar_params($sidebar, $sidebar_params, $widget_instance);
         }
     }
     /**
      * display related content
      */
     if (!isset($widget_instance)) {
         extract($sidebar_params);
     }
     //extract sidebar param if not use HWTPL config
     if (isset($before_widget)) {
         echo $before_widget;
     }
     //widget title
     if (isset($before_title)) {
         echo $before_title;
     }
     echo apply_filters('hw_related_posts_title', $hwrp->title);
     if (isset($after_title)) {
         echo $after_title;
     }
     //do action before
     do_action('hoangweb_before_loop');
     do_action('hw_yarpp_results_before', $hwrp);
     if (isset($widget_instance)) {
         /**
          * output widget, when using the_widget to show widget content,
          * note that you set up & enable sidebar skin at /admin.php?page=hw_sidebar_widgets_settings this mean sidebar apply to yarpp it work for that skin
          * And no related to active sidebar that using on website, which call by function 'dynamic_sidebar' /hw_dynamic_sidebar
          */
         the_widget('HW_Taxonomy_Post_List_widget', $widget_instance, $sidebar_params);
     } else {
         if (isset($args['args']['template'])) {
             include $args['args']['template'];
         }
     }
     //do action after
     do_action('hw_yarpp_results_after', $hwrp);
     do_action('hoangweb_after_loop');
     if (isset($after_widget)) {
         echo $after_widget;
     }
     return false;
     //disable behavior as default $yarpp->display_related do
 }
Exemplo n.º 2
0
 /**
  * main loop
  */
 public static function hw_theme_get_main()
 {
     //init
     //hw_taxonomy_post_list_widget widget setting
     $setting = array();
     //default sidebar params
     $sidebar_params = array('before_widget' => '<div id="%1$s" class="hw-widget %2$s *1" >', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget-title %1$s {css_title}">', 'after_title' => '</h3>');
     //override loop template base context
     $loop_temp = HW__Template::get_current_context_loop_template();
     global $wp_registered_sidebars;
     global $wp_registered_widgets;
     if (!empty($loop_temp)) {
         //$widg = AWC_WidgetFeature_saveconfig::get_widget_setting($loop_temp['widget_config']);
         $setting = AWC_WidgetFeature_saveconfig::get_widget_setting_instance($loop_temp['widget_config'], array('widget' => 'hw_taxonomy_post_list_widget', 'group' => 'main_loop'));
         //valid data
         if (!isset($setting['query_data'])) {
             $setting['query_data'] = 'current_context';
         }
         //get global $wp_query
         //$setting['widget_title'] = 'sdfgdg';  //set widget title by skin
         //get sidebar box
         if ($loop_temp['sidebar'] && isset($wp_registered_sidebars[$loop_temp['sidebar']])) {
             $sidebar = $loop_temp['sidebar'];
             //sidebar id
             $sidebar_params = $wp_registered_sidebars[$sidebar];
             if (isset($loop_temp['sidebar_widget_skin'])) {
                 $sidebar_widget_skin = $loop_temp['sidebar_widget_skin'];
                 //get change default sidebar skin, here we create 4 holder: sidebar_default, skin1,skin2,skin3
                 $skin_data = HW_AWC_Sidebar_Settings::get_sidebar_setting($sidebar_widget_skin, $sidebar);
                 HW_SKIN::apply_skin_data($skin_data, 'HW__Template::_hw_skin_resume_skin_data', array('sidebar' => $sidebar, 'sidebar_widget_skin' => $sidebar_widget_skin, 'sidebar_params' => &$sidebar_params));
             }
         }
         list($widget_id, $t) = each($wp_registered_widgets);
         //get first widget as demo
         $sidebar_params = HW_AWC::format_widget_sidebar_params($widget_id, $sidebar_params, array('classname' => 'main-content hw-awc-override', 'widget_id' => 'hw-main-loop-content'));
         //override sidebar params from awc feature assign to widget
         if (isset($sidebar_params) && isset($sidebar)) {
             $sidebar_params = HW_AWC::format_sidebar_params($sidebar, $sidebar_params, $setting);
         }
         //important: since any sidebar skin use wrapper class 'hw-awc-override'
         //$sidebar_params['before_widget'] = sprintf($sidebar_params['before_widget'], /*$widget_id, $classname*/'hw-main-loop-content','main-content hw-awc-override');
         do_action('hw_before_loop');
         /**
          * output widget, when using the_widget to show widget content,
          *
          * note that you set up & enable sidebar skin at /admin.php?page=hw_sidebar_widgets_settings this mean sidebar apply to yarpp it work for that skin
          * And no related to active sidebar that using on website, which call by function 'dynamic_sidebar' /hw_dynamic_sidebar
          */
         if (class_exists('HW_Taxonomy_Post_List_widget')) {
             the_widget('HW_Taxonomy_Post_List_widget', $setting, $sidebar_params);
         }
         do_action('hw_after_loop');
     } elseif (APF_Page_Templates::get_instance()->hw_loop_template()) {
         //do nothing
     } else {
         $context = HW__Template::get_current_template_file();
         //determine current template
         $current = self::get_current_template();
         if ($current && method_exists($current, 'Main')) {
             $current->Main();
             //display main content of current template
         }
         //filter default template
         do_action('hw_theme_get_main_default', $context);
     }
 }
 public function widget($args, $instance)
 {
     $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
     //$content = isset($instance['content'])? $instance['content'] : '';  //marquee content
     $source = isset($instance['source']) ? $instance['source'] : 'content';
     //data source
     $data = isset($instance['data']) ? $instance['data'] : array();
     if (isset($data[$source])) {
         //get data content
         $content = $data = $data[$source];
     }
     //parse source for slides
     if ($source == 'slides' && is_numeric($data)) {
         $data = hwmq_get_mlslider_data($data);
     }
     //skin
     $hash_skin = isset($instance['skin']) ? $instance['skin'] : 'default';
     // before and after widget arguments are defined by themes
     echo $args['before_widget'];
     if (!empty($title)) {
         echo $args['before_title'] . $title . $args['after_title'];
     }
     // This is where you run the code and display the output
     if ($this->skin) {
         $skin_options = isset($instance['skin_settings']) ? $instance['skin_settings'] : array();
         HW_SKIN::apply_skin_data(array('instance' => $this->skin, 'hash_skin' => $hash_skin, 'skin_options' => $skin_options), array('callback_before' => array($this, '_hw_skin_apply_skin_data_callback_before'), 'callback_after' => array($this, '_hw_skin_apply_skin_data_callback_after')), array('instance' => $instance, 'data' => $data));
     }
     echo $args['after_widget'];
 }
 /**
  * apply sidebar skin for dynamic
  * @param $sidebar sidebar id
  * @param $skin sidebar skin style
  * @param $override_params arguments
  * @param $widget_id specific  widget id
  */
 public static function apply_sidebar_skin($sidebar, $skin, $override_params = array(), $widget_id = null)
 {
     global $wp_registered_sidebars;
     global $wp_registered_widgets;
     //valid
     if (!isset($wp_registered_sidebars[$sidebar])) {
         return;
     }
     $sidebar_params = $wp_registered_sidebars[$sidebar];
     //sidebar params
     //get change default sidebar skin, here we create 4 holder: sidebar_default, skin1,skin2,skin3
     $skin_data = HW_AWC_Sidebar_Settings::get_sidebar_setting($skin, $sidebar);
     //valid widget id
     if (empty($widget_id) && !isset($wp_registered_widgets[$widget_id])) {
         list($widget_id, $t) = each($wp_registered_widgets);
         //get first widget as demo
     }
     //change sidebar params from skin
     HW_SKIN::apply_skin_data($skin_data, array(__CLASS__, '_hw_skin_resume_skin_data'), array('sidebar' => $sidebar, 'sidebar_widget_skin' => $skin, 'sidebar_params' => &$sidebar_params));
     $params = array('classname' => $widget_id . ' hw-awc-override', 'widget_id' => $widget_id);
     $params = array_merge($params, $override_params);
     //format sidebar variables
     $sidebar_params = HW_AWC::format_widget_sidebar_params($widget_id, $sidebar_params, $params);
     return $sidebar_params;
 }
Exemplo n.º 5
0
 /**
  * @param $atts
  */
 public function _gallery_shortcode($atts)
 {
     global $post;
     // If no attributes have been passed, the gallery should be pulled from the current post.
     $gallery_id = false;
     if (empty($atts)) {
         $gallery_id = $post->ID;
         $data = is_preview() ? $this->gallery->_get_gallery($gallery_id) : $this->gallery->get_gallery($gallery_id);
     } else {
         if (isset($atts['id'])) {
             $gallery_id = (int) $atts['id'];
             $data = is_preview() ? $this->gallery->_get_gallery($gallery_id) : $this->gallery->get_gallery($gallery_id);
         } else {
             if (isset($atts['slug'])) {
                 $gallery_id = $atts['slug'];
                 $data = is_preview() ? $this->gallery->_get_gallery_by_slug($gallery_id) : $this->gallery->get_gallery_by_slug($gallery_id);
             } else {
                 // A custom attribute must have been passed. Allow it to be filtered to grab data from a custom source.
                 $data = apply_filters('hw_envira_gallery_custom_gallery_data', false, $atts, $post);
             }
         }
     }
     // If there is no data to output or the gallery is inactive, do nothing.
     if (!$data || empty($data['gallery']) || isset($data['status']) && 'inactive' == $data['status'] && !is_preview()) {
         return;
     }
     // Get rid of any external plugins trying to jack up our stuff where a gallery is present.
     $this->plugin_humility();
     // If this is a feed view, customize the output and return early.
     if (is_feed()) {
         return $this->do_feed_output($data);
     }
     $i = 1;
     $args = array();
     $args['wrapper_id'] = sanitize_html_class($data['id']);
     $args['wrapper_class'] = $this->get_gallery_classes($data);
     $args['columns_class'] = $this->get_config('columns', $data);
     $galleries = array();
     foreach ($data['gallery'] as $id => $item) {
         // Skip over images that are pending (ignore if in Preview mode).
         if (isset($item['status']) && 'pending' == $item['status'] && !is_preview()) {
             continue;
         }
         $gallery = array();
         $image = $this->get_image_src($id, $item, $data);
         $gallery = array_merge($item);
         $gallery['index'] = $i;
         $gallery['id'] = $id;
         $gallery['item_classes'] = $this->get_gallery_item_classes($item, $i, $data);
         $gallery['margin_bottom'] = HW_Validation::format_unit($this->get_config('margin', $data));
         $gallery['img_src'] = esc_url($image[0]);
         $gallery['img_width'] = esc_url($image[1]);
         $gallery['img_height'] = esc_url($image[2]);
         $thumb = wp_get_attachment_image_src($id, 'thumbnail');
         $gallery['thumb_src'] = $thumb[0];
         $gallery['thumb_width'] = $thumb[1];
         $gallery['thumb_height'] = $thumb[2];
         $gallery['placeholder'] = esc_url(plugins_url('assets/css/images/holder.gif', dirname(dirname(__FILE__))));
         $galleries[$id] = $gallery;
         // Increment the iterator.
         $i++;
     }
     /*---start skin---*/
     //$skin = $this->get_config( 'hw_skin', $data );
     $skin = !empty($data['config']['hw_skin']) ? $data['config']['hw_skin'] : $this->get_config('hw_skin', array());
     if (empty($skin['hash_skin'])) {
         return;
     }
     //get skin options
     $data['options'] = isset($skin['skin_options']) ? $skin['skin_options'] : array();
     $data['json_options'] = HW_SKIN_Option::build_json_options($data['options']);
     //$this->skin->get_current();
     //change sidebar params from skin
     return HW_SKIN::apply_skin_data($skin, array('callback_before' => array(__CLASS__, '_hw_skin_before_include_skin_file')), array('galleries' => $galleries, 'args' => $args, 'data' => $data), false);
 }
Exemplo n.º 6
0
 /**
  * Display download attachments for a given post
  * from: wp-content/plugins/download-attachments/includes/functions.php
  *
  * @param 	int $post_id
  * @param	array $args
  * @return 	mixed
  */
 public function hw_da_display_download_attachments($post_id = 0, $args = array())
 {
     $post_id = (int) (empty($post_id) ? get_the_ID() : $post_id);
     $options = get_option('download_attachments_general');
     $setting = HW_Module_downloadattachment::get()->get_values();
     $defaults = array('container' => 'div', 'container_class' => 'download-attachments', 'container_id' => '', 'style' => isset($options['display_style']) ? esc_attr($options['display_style']) : 'list', 'link_before' => '', 'link_after' => '', 'content_before' => isset($setting['content_before']) ? $setting['content_before'] : '', 'content_after' => isset($setting['content_after']) ? $setting['content_after'] : '', 'display_index' => isset($options['frontend_columns']['index']) ? (int) $options['frontend_columns']['index'] : false, 'display_user' => (int) $options['frontend_columns']['author'], 'display_icon' => (int) $options['frontend_columns']['icon'], 'display_count' => (int) $options['frontend_columns']['downloads'], 'display_size' => (int) $options['frontend_columns']['size'], 'display_date' => (int) $options['frontend_columns']['date'], 'display_caption' => (int) $options['frontend_content']['caption'], 'display_description' => (int) $options['frontend_content']['description'], 'display_empty' => 0, 'display_option_none' => __('No attachments to download', 'download-attachments'), 'use_desc_for_title' => 0, 'exclude' => '', 'include' => '', 'title' => __('Download Attachments', 'download-attachments'), 'title_container' => 'p', 'title_class' => 'download-title', 'orderby' => 'menu_order', 'order' => 'asc', 'echo' => 1);
     $args = apply_filters('da_display_attachments_defaults', array_merge($defaults, $args), $post_id);
     $args['display_index'] = apply_filters('da_display_attachments_index', (int) $args['display_index']);
     $args['display_user'] = apply_filters('da_display_attachments_user', (int) $args['display_user']);
     $args['display_icon'] = apply_filters('da_display_attachments_icon', (int) $args['display_icon']);
     $args['display_count'] = apply_filters('da_display_attachments_count', (int) $args['display_count']);
     $args['display_size'] = apply_filters('da_display_attachments_size', (int) $args['display_size']);
     $args['display_date'] = apply_filters('da_display_attachments_date', (int) $args['display_date']);
     $args['display_caption'] = apply_filters('da_display_attachments_caption', (int) $args['display_caption']);
     $args['display_description'] = apply_filters('da_display_attachments_description', (int) $args['display_description']);
     $args['display_empty'] = apply_filters('da_display_attachments_empty', (int) $args['display_empty']);
     $args['use_desc_for_title'] = (int) $args['use_desc_for_title'];
     $args['echo'] = (int) $args['echo'];
     $args['style'] = in_array($args['style'], array('list', 'table', 'none', ''), true) ? $args['style'] : $defaults['style'];
     $args['orderby'] = in_array($args['orderby'], array('menu_order', 'attachment_id', 'attachment_date', 'attachment_title', 'attachment_size', 'attachment_downloads'), true) ? $args['orderby'] : $defaults['orderby'];
     $args['order'] = in_array($args['order'], array('asc', 'desc'), true) ? $args['order'] : $defaults['order'];
     $args['link_before'] = trim($args['link_before']);
     $args['link_after'] = trim($args['link_after']);
     $args['display_option_none'] = ($info = trim($args['display_option_none'])) !== '' ? $info : $defaults['display_option_none'];
     $args['title'] = apply_filters('da_display_attachments_title', trim($args['title']));
     $attachments = da_get_download_attachments($post_id, apply_filters('da_display_attachments_args', array('include' => $args['include'], 'exclude' => $args['exclude'], 'orderby' => $args['orderby'], 'order' => $args['order'])));
     $count = count($attachments);
     //load active skin
     $current_skin = HW_Module_downloadattachment::get()->get_field_value('skin');
     $headers = array('index' => '', 'file' => __('Tệp'));
     $data = array();
     if ($count > 0) {
         $i = 1;
         //caption
         if ($args['display_caption'] === 1 || $args['display_description'] === 1 && $args['use_desc_for_title'] === 0) {
             $headers['caption'] = __('Mô tả');
         }
         //date
         if ($args['display_date'] === 1) {
             $headers['attachment-date'] = __('Date added', 'download-attachments');
         }
         //user
         if ($args['display_user'] === 1) {
             $headers['attachment-user'] = __('Added by', 'download-attachments');
         }
         //size
         if ($args['display_size'] === 1) {
             $headers['attachment-size'] = __('File size', 'download-attachments');
         }
         //display download count
         if ($args['display_count'] === 1) {
             $headers['attachment-downloads'] = __('Downloads', 'download-attachments');
         }
         foreach ($attachments as $attachment) {
             if ($attachment['attachment_exclude']) {
                 continue;
             }
             $row = array();
             if ($args['use_desc_for_title'] === 1 && $attachment['attachment_description'] !== '') {
                 $title = apply_filters('da_display_attachment_title', $attachment['attachment_description']);
             } else {
                 $title = apply_filters('da_display_attachment_title', $attachment['attachment_title']);
             }
             //attachment type
             $row['class'] = $attachment['attachment_type'];
             #if ( $args['display_index'] === 1 )
             $row['index'] = $i;
             //index count
             // title
             // type
             if ($args['display_icon'] === 1) {
                 $row['icon'] = '<img class="attachment-icon" src="' . $attachment['attachment_icon_url'] . '" alt="' . $attachment['attachment_type'] . '" /> ';
             } else {
                 $row['icon'] = '';
             }
             // link before
             if ($args['link_before'] !== '') {
                 $row['link_before'] = $args['link_before'];
             } else {
                 $row['link_before'] = '';
             }
             $row['url'] = $options['pretty_urls'] === true ? home_url('/' . $options['download_link'] . '/' . $attachment['attachment_id'] . '/') : hw_modules_url('download-attachments/includes/download.php?id=' . $attachment['attachment_id']);
             $row['title'] = $title;
             $row['link'] = '<a href="' . ($options['pretty_urls'] === true ? home_url('/' . $options['download_link'] . '/' . $attachment['attachment_id'] . '/') : hw_modules_url('download-attachments/includes/download.php?id=' . $attachment['attachment_id'])) . '" class="attachment-link" title="' . $title . '">' . $title . '</a>';
             $row['link_after'] = $args['link_after'];
             //link after
             // caption
             if ($args['display_caption'] === 1) {
                 $row['caption'] = $attachment['attachment_caption'];
             }
             // description
             if ($args['display_description'] === 1 && $args['use_desc_for_title'] === 0) {
                 $row['description'] = $attachment['attachment_description'];
             }
             // date
             if ($args['display_date'] === 1) {
                 $row['date'] = $attachment['attachment_date'];
             }
             // user
             if ($args['display_user'] === 1) {
                 $row['user'] = $attachment['attachment_user_name'];
             }
             // size
             if ($args['display_size'] === 1) {
                 $row['size'] = $attachment['attachment_size'];
             }
             // downloads
             if ($args['display_count'] === 1) {
                 $row['count'] = $attachment['attachment_downloads'];
             }
             $data[] = $row;
             $i++;
         }
     }
     //change sidebar params from skin
     return HW_SKIN::apply_skin_data($current_skin, array('callback_before' => array(__CLASS__, '_hw_skin_before_include_skin_file')), array('attachments' => $data, 'headers' => $headers, 'args' => $args), false);
 }