/**
  * render current pagenavi skin
  * @param $html
  */
 public static function render_pagination_skin($html = '')
 {
     //get hoangweb scb options
     $options = HWPageNavi_Core::getOptions()->get();
     //$options = PageNavi_Core::$options->get();    //other way
     if (isset($options['hw_skin']['hwskin_config']) && isset($options['hw_skin']['hash_skin'])) {
         #$skin = HW_SKIN::resume_skin($options['hw_skin']['hwskin_config']);
         $skin = HW_SKIN::resume_hwskin_instance($options['hw_skin']);
         if (!empty($skin)) {
             $file = $skin->instance->get_skin_file($options['hw_skin']['hash_skin']);
             if (file_exists($file)) {
                 $theme_setting = $skin->instance->get_file_skin_setting();
                 //extract theme setting from skin
                 //load theme setting
                 if (file_exists($theme_setting)) {
                     include $theme_setting;
                 }
                 //custom wp_pagenavi output by skin
                 $html = hw_paginav_output($file, $html);
                 //valid theme setting
                 /*if(!isset($theme['styles']) || !is_array($theme['styles'])) $theme['styles'] = array();
                                     if(!isset($theme['scripts']) || !is_array($theme['scripts'])) $theme['scripts'] = array();
                 
                                     if(count($theme['styles']) || count($theme['scripts'])) {
                                         //put css within head tag
                                         $skin->instance->enqueue_files_from_skin($theme['styles'], $theme['scripts']);
                                     }*/
                 $skin_assets = array('skin_file' => $file);
                 if (isset($theme)) {
                     $skin_assets['theme_settings'] = $theme;
                 }
                 HW_SKIN::enqueue_skin_assets(array_merge($skin_assets, (array) $skin));
                 return isset($theme) && is_array($theme) ? $theme : array();
             }
         }
     }
 }
 /**
  * load widget template
  * @param array $instance: widget instance (optional)	 
  * @param array $data: array of data need to be extract to current context
  */
 private function load_widget_template(&$instance = array(), $data = array())
 {
     //extract data
     if (isset($this->shared) && is_array($this->shared)) {
         extract($this->shared);
     } else {
         if (is_array($data)) {
             extract($data);
         }
     }
     //extract variables from array $args that get from 'widget' method
     if (isset($args)) {
         extract($args);
     }
     if (!is_array($instance) || !count($instance)) {
         $instance = $this->hw_parse_data();
         $instance = $instance['instance'];
     } else {
         $this->get_widget_instance($instance);
     }
     //by hoangweb.com
     if ($this->skin) {
         //load skin
         $file = $this->skin->get_skin_file(empty($instance['skin']) ? 'default' : $instance['skin']);
         if (file_exists($file)) {
             /**
              * pagination skin
              */
             $paginav = $this->skin->get_skin_instance('pagination')->get_skin_file(empty($instance['pagination_skin']) ? 'default' : $instance['pagination_skin']);
             //skin settings
             /*
             $paginav_skin_setting = isset($instance['skin_setting'])? $instance['skin_setting'] : '';
             
             $skin_setting_file = $this->skin->get_file_skin_setting(); //current skin setting
             $skin_options = $this->skin->get_file_skin_options();      //current skin options
             
             if(file_exists($skin_setting_file)) include ($skin_setting_file);
             if(file_exists($skin_options)) include ($skin_options);
             
             if(isset($theme) && isset($theme['options'])) $default_options = $theme['options'];
             if(isset($default_options) && isset($theme_options)) {
                 $paginav_skin_setting = HW_SKIN::merge_skin_options_values($paginav_skin_setting, $default_options, $theme_options);
             }
             */
             /**
              * scrollbar skin
              */
             $scrollbar = $this->skin->get_skin_instance('scrollbar')->get_skin_file(empty($instance['scrollbar_skin']) ? 'default' : $instance['scrollbar_skin']);
             //widget feature: grid_posts
             $grid_posts = HW_AWC::get_widget_feature($this, 'grid_posts');
             $awc_enable_grid_posts = false;
             //disable by default
             if ($grid_posts && HW_AWC::check_widget_feature($this, 'grid_posts')) {
                 $awc_enable_grid_posts = $grid_posts->is_active($instance);
                 if ($awc_enable_grid_posts) {
                     $awc_grid_posts_cols = $grid_posts->get_field_value('awc_grid_posts_cols');
                 }
             }
             /**
              * init some variables
              */
             $theme = array();
             //declare stylesheets file
             //content wrapper ID
             $hwtpl_wrapper_id = $this->get_holder_id($instance['widget_id']);
             $hwtpl_scrollbar_wrapper_class = '';
             //scrollbar content wrapper css class
             $hwtpl_pagination_class = '';
             //for pagination
             /**
              * load pagination component
              */
             if (file_exists($paginav)) {
                 include $paginav;
                 //valid
                 if (!isset($theme['scripts'])) {
                     $theme['scripts'] = array();
                 }
                 if (!isset($theme['styles'])) {
                     $theme['styles'] = array();
                 }
                 //migrate skin from pagination module
                 if ($instance['use_default_pagenav_skin'] && hw_is_active_module('pagination')) {
                     $theme = HWPageNavi_Core::render_pagination_skin();
                 } elseif (count($theme['styles']) || count($theme['scripts'])) {
                     $this->skin->get_skin_instance('pagination')->enqueue_files_from_skin($theme['styles'], $theme['scripts']);
                     //enqueue stuff from skin
                     /*HW_SKIN::enqueue_skin_assets(array(
                           'instance' => $this->skin,
                           'hash_skin' => $instance['skin'],
                           'skin_file' => $file,
                           'skin_settings' => $theme,
                           'skin_options' => $skin_setting
                       ));*/
                 }
                 //parse template tags
                 $hwtpl_pagination_class = isset($theme['pagination_class']) ? $theme['pagination_class'] : '';
                 $this->share_data('pagination', $theme);
             }
             //_print($this->skin->get_active_skin()); //enqueue stuff from skin
             /**
              * load scrollbar component
              */
             if (isset($instance['enable_scrollbar']) && $instance['enable_scrollbar'] && file_exists($scrollbar)) {
                 //load skin resource
                 $scrollbar_options_config = $this->skin->get_skin_instance('scrollbar')->get_file_skin_options(empty($instance['scrollbar_skin']) ? 'default' : $instance['scrollbar_skin']);
                 //theme options configuration
                 $scrollbar_theme_setting = $this->skin->get_skin_instance('scrollbar')->get_file_skin_setting();
                 //load theme-setting.php
                 //theme options
                 $scrollbar_theme_options = isset($instance['scrollbar_skin_setting']) ? $instance['scrollbar_skin_setting'] : array();
                 //scrollbar skin options
                 //reset
                 $theme['styles'] = array();
                 //declare stylesheets file
                 $theme['scripts'] = array();
                 //declare js files
                 $theme['options'] = array();
                 if (!empty($scrollbar_options_config) && file_exists($scrollbar_options_config)) {
                     include $scrollbar_options_config;
                     //include define scrollbar theme options
                 }
                 if (!empty($scrollbar_theme_setting) && file_exists($scrollbar_theme_setting)) {
                     include $scrollbar_theme_setting;
                     //scrollbar theme setting
                 }
                 if (isset($theme_options) && isset($theme)) {
                     $default = isset($theme['options']) ? $theme['options'] : array();
                     $result = HW_SKIN::get_skin_options($scrollbar_theme_options, $default, $theme_options);
                     $scrollbar_theme_options = array_merge($scrollbar_theme_options, $result);
                 }
                 /*
                 //best way but use old way as above do
                 $scrollbar_skin_setting = isset($instance['scrollbar_skin_setting'])? $instance['scrollbar_skin_setting'] : '';
                 
                                    $scrollbarskin_setting_file = $this->skin->get_skin_instance('scrollbar')->get_file_skin_setting(); //current skin setting
                                    $scrollbar_skin_options = $this->skin->get_skin_instance('scrollbar')->get_file_skin_options();      //current skin options
                 
                                    if(file_exists($scrollbarskin_setting_file)) include ($scrollbarskin_setting_file);
                                    if(file_exists($scrollbar_skin_options)) include ($scrollbar_skin_options);
                 
                                    if(isset($theme) && isset($theme['options'])) $scrollbar_default_options = $theme['options'];
                                    if(isset($scrollbar_default_options) && isset($theme_options)) {
                 $scrollbar_skin_setting = HW_SKIN::merge_skin_options_values($scrollbar_skin_setting, $scrollbar_default_options, $theme_options);
                                    }
                 */
                 //parse template tags
                 $hwtpl_scrollbar_wrapper_class = isset($theme['scrollbar_css']) ? $theme['scrollbar_css'] : '';
                 include $scrollbar;
                 //valid
                 /*if(!isset($theme['scripts'])) $theme['scripts'] = array();
                                        if(!isset($theme['styles'])) $theme['styles'] = array();
                 
                                        if(count($theme['styles']) || count($theme['scripts'])) {
                                            $this->skin->get_skin_instance('scrollbar')->enqueue_files_from_skin($theme['styles'], $theme['scripts']);
                                        }*/
                 //enqueue stuff from skin
                 HW_SKIN::enqueue_skin_assets(array('instance' => $this->skin->get_skin_instance('scrollbar'), 'hash_skin' => $instance['scrollbar_skin'], 'skin_file' => $scrollbar, 'skin_settings' => $theme, 'skin_options' => $scrollbar_theme_options));
                 $this->init_scrollbar_options($scrollbar_theme_options, $theme);
             }
             /**
              * load main skin
              */
             $options_config = $this->skin->get_file_skin_options();
             $skin_setting = $this->skin->get_file_skin_setting();
             if (file_exists($skin_setting)) {
                 include $skin_setting;
             }
             //theme options
             $skin_options = isset($instance['skin_setting']) ? $instance['skin_setting'] : array();
             $skin_options = HW_SKIN::merge_skin_options_values($skin_options, $skin_setting, $options_config);
             //params
             if (empty($instance['intermediate_image_sizes']) && !empty($instance['thumb_w']) && !empty($instance['thumb_h'])) {
                 $image_size = array($instance['thumb_w'], $instance['thumb_h']);
             } elseif (!empty($instance['intermediate_image_sizes'])) {
                 $image_size = $instance['intermediate_image_sizes'];
             } else {
                 $image_size = 'thumbnail';
             }
             //reset
             $theme['styles'] = array();
             //declare stylesheets file
             $theme['scripts'] = array();
             //declare js files
             $theme['options'] = array();
             //refresh theme options
             //widget features
             $wfeatures = $this->init_widget_features(array('theme' => $theme, 'skin_options' => $skin_options, 'instance' => $instance));
             //render skin template power by twig
             $data = array('hwtpl_scrollbar_wrapper_class', 'cat_posts', 'full_image_src', 'fancy_group', 'fancybox_g1', 'arrExlpodeFields', 'image_size', 'wfeatures', 'hwtpl_wrapper_id', 'args', 'instance', 'open_title_link', 'close_title_link');
             $data = compact($data);
             $data['context'] = $this;
             //reference to this object
             $content = $this->skin->render_skin_template($data, false);
             if ($content !== false) {
                 echo $content;
             }
             include $file;
             //valid
             /*if(!isset($theme['scripts'])) $theme['scripts'] = array();
                                if(!isset($theme['styles'])) $theme['styles'] = array();
             
                                if(count($theme['styles']) || count($theme['scripts'])) {
                                    $this->skin->enqueue_files_from_skin($theme['styles'], $theme['scripts']); //enqueue stuff from skin
                                }*/
             //enqueue stuff from skin
             HW_SKIN::enqueue_skin_assets(array('instance' => $this->skin, 'hash_skin' => $instance['skin'], 'skin_file' => $file, 'skin_settings' => $theme, 'skin_options' => $skin_options));
             //init scrolling
             //add_action('wp_footer',array(&$this, 'init_content_options'),1000);	//don't use wp hook to setup scroll
             $this->init_content_options(array('theme' => $theme, 'skin_options' => $skin_options, 'instance' => $instance));
         }
     } else {
         echo __('not found class HW_SKIN.');
     }
 }
Exemplo n.º 3
0
 /**
  * if this callback of the hook that mean you not link specific menu to wp_nav_menu
  * @hook filter 'wp_nav_menu_args'
  * @param $args
  */
 public function _modify_nav_menu_args($args)
 {
     //get current menu name
     $menu = self::get_menu_name($args);
     /**
      * get menu skin
      * first entry for through out menu filters
      */
     $skin = HW_NavMenu_Metabox_settings::get_menu_setting('skin', $menu);
     $enable_skin = HW_NavMenu_Metabox_settings::get_menu_setting('enable_skin', $menu);
     $enable_filter_menu = HW_NavMenu_Metabox_settings::get_menu_setting('enable_filter_menu', $menu);
     //add other menu setting to menu args
     $addition_menu_args = array('show_searchbox', 'remove_ul_wrap', 'only_anchor_tag_nav_menu', 'show_home_menu', 'allow_tags_nav_menu', 'show_icon');
     foreach ($addition_menu_args as $option) {
         $args[$option] = HW_NavMenu_Metabox_settings::get_menu_setting($option, $menu);
     }
     if ($enable_filter_menu && $enable_skin && $skin) {
         //parse SKIN object
         $this->skin = APF_hw_skin_Selector_hwskin::resume_hwskin_instance($skin);
         //parse into HW_SKIN object & saved as property
         $this->skin->file = $this->skin->instance->get_skin_file($this->skin->hash_skin);
         $options_config = $this->skin->instance->get_file_skin_options($this->skin->hash_skin);
         //theme options configuration
         $theme_setting = $this->skin->instance->get_file_skin_setting();
         //theme setting file
         //register twig loader
         if (class_exists('HW_Twig_Template')) {
             //Twig_Autoloader::register();
             //$loader = new Twig_Loader_Filesystem($this->skin->instance->get_file_skin_resource('tpl'));
             $this->twig = HW_Twig_Template::create($this->skin->instance->get_file_skin_resource('tpl'));
             #$this->twig = new Twig_Environment($loader);
             $args['twig'] = $this->twig->get();
             //reference twig object
         }
         if (file_exists($this->skin->file)) {
             $theme = array();
             $theme['styles'] = array();
             //init
             $theme['scripts'] = array();
             $theme['filters'] = array();
             //allow filters
             //keep this info (ex: menu) with filter that bind to callback to compare from current filter args
             $theme['menu'] = $menu;
             $user_options = array();
             //skin options
             if (file_exists($theme_setting)) {
                 include $theme_setting;
             }
             //theme setting
             if (file_exists($options_config)) {
                 include $options_config;
             }
             //options file
             if (isset($theme_options)) {
                 //$theme_options variable already exists in skin options
                 //$skin_options_config = hwskin_parse_theme_options($theme_options);
                 //get addition skin options value
                 $skin_options = isset($skin['skin_options']) ? $skin['skin_options'] : array();
                 if (empty($skin_options)) {
                     $skin_options = array();
                 }
                 //please go menu setting page & press on save button
                 $exclude_options = array('menu');
                 foreach ($exclude_options as $opt) {
                     if (isset($skin_options[$opt])) {
                         unset($skin_options[$opt]);
                     }
                 }
                 $user_options = HW_SKIN::get_skin_options($skin_options, $theme['args'], $theme_options);
                 $args = array_merge($args, $user_options);
                 //sync skin options with $args
                 //hope $args share to all remain menu filters in order to render final output menu to user
                 /*foreach($skin_options as $arg => $value){
                       $field_setting = $skin_options_config[$arg];
                       if(!isset($args[$arg])) $args[$arg] = '';   //set menu args from skin
                       //append if exists setting
                       if(isset($field_setting['method']) && $field_setting['method'] == 'append' && !empty($value)){
                           if(!in_array($value, preg_split('#[\s]+#',$args[$arg]))){
                               $args[$arg] .= (!empty($args[$arg])? ' ':'').trim($value);
                           }
                       }
                       //override setting if not exists
                       if(isset($field_setting['method']) && $field_setting['method'] == 'override' && !empty($value)){
                           $args[$arg] = $value;
                       }
                   }*/
             }
             //make sure have no ouput at here
             HW_SKIN::include_skin_file($this->skin->file);
             //extract wp_nav_menu_args from skin file
             /*if(isset($theme['args']) && is_array($theme['args'])){
                   //$args = array_merge($args, $theme['args']);
                   foreach($theme['args'] as $arg => $val){
                       if(isset($args[$arg])) $args[$arg] .= (!empty($args[$arg])? ' ':'').$val;     //append
                       else $args[$arg] = $val;    //create if not exists
                   }
               }*/
             $this->skin->instance->do_filters($theme['filters'], array($theme, $user_options));
             //do filters & actions that defined in skin
             //$this->skin->instance->enqueue_files_from_skin(null/*$theme['styles']*/, $theme['scripts']);    //put stuff from skin (note: css enqueue before)
             //new way for enqueue stuff from skin
             HW_SKIN::enqueue_skin_assets(array('instance' => $this->skin->instance, 'hash_skin' => $this->skin->hash_skin, 'skin_file' => $this->skin->file, 'theme_settings' => $theme, 'theme_options' => $args));
             //languages selector on the website
             $show_langs_switcher = HW_NavMenu_Metabox_settings::get_menu_setting('show_langs_switcher', $menu);
             //show search form in nav menu
             if ($show_langs_switcher) {
                 //get langs switcher output
                 $args['langs_switcher'] = hw_get_qtrans_switcher();
             }
             #$args = array_merge($args, $skin_options); //filtered values in above
             //if(isset($args['show_items_separator'])) ;
         }
         $args['walker'] = new HW_Nav_Menu_Walker();
     }
     $this->menu_args = (object) $args;
     //save current menu args
     /*if( 'primary' == $args['theme_location'] )
             {
                 $args['depth'] = -1;
                 $args['container_id'] = 'my_primary_menu';
             }
             if('menu1' == $args['menu']){    #maybe old wp version
                 $args['walker'] = new custom_walker();
             }
             //for custom menu widget
             if(isset($args['menu']) && isset($args['menu']->name) && $args['menu']->name == 'menu-header')
             {
     
             }*/
     return $args;
 }
 /**
  * This is the Widget
  * @param $args
  * @param $instance
  */
 public function widget($args, $instance)
 {
     global $post;
     extract($args);
     // Widget options
     $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
     // Title
     $this_taxonomy = $instance['taxonomy'];
     // Taxonomy to show
     $hierarchical = !empty($instance['hierarchical']) ? '1' : '0';
     $showcount = !empty($instance['count']) ? '1' : '0';
     $hide_empty = !empty($instance['hide_empty']) ? '1' : '0';
     $depth = !empty($instance['depth']) ? $instance['depth'] : 0;
     //skin
     $use_skin = !empty($instance['use_skin']) ? 1 : 0;
     $use_skin_options = !empty($instance['extend_skin_options']) ? 1 : 0;
     $skin = isset($instance['skin']) ? $instance['skin'] : '';
     //saved active hash skin
     //skin settings
     $skin_setting = isset($instance['skin_settings']) ? $instance['skin_settings'] : '';
     if ($skin) {
         $skin_setting_file = $this->skin->get_file_skin_setting($skin);
         //current skin setting
         $skin_options = $this->skin->get_file_skin_options();
         //current skin options
         if (file_exists($skin_setting_file)) {
             include $skin_setting_file;
         }
         if (file_exists($skin_options)) {
             include $skin_options;
         }
         if (isset($theme) && isset($theme['options'])) {
             $default_options = $theme['options'];
         }
         if (isset($default_options) && isset($theme_options)) {
             $skin_setting = HW_SKIN::merge_skin_options_values($skin_setting, $default_options, $theme_options);
         }
     }
     //widget feature field: grid_posts
     $grid_posts = HW_AWC::get_widget_feature($this, 'grid_posts');
     $awc_enable_grid_posts = false;
     //disable by default
     if ($grid_posts && HW_AWC::check_widget_feature($this, 'grid_posts')) {
         $awc_enable_grid_posts = $grid_posts->is_active($instance);
         if ($awc_enable_grid_posts) {
             $awc_grid_posts_cols = $grid_posts->get_field_value('awc_grid_posts_cols');
         }
     }
     $show_option_none = !empty($instance['show_option_none']) ? $instance['show_option_none'] : '';
     if (array_key_exists('orderby', $instance)) {
         $orderby = $instance['orderby'];
     } else {
         $orderby = 'count';
     }
     if (array_key_exists('ascdsc', $instance)) {
         $ascdsc = $instance['ascdsc'];
     } else {
         $ascdsc = 'desc';
     }
     if (array_key_exists('exclude', $instance)) {
         $exclude = join(',', (array) $instance['exclude']);
     } else {
         $exclude = '';
     }
     if (array_key_exists('dropdown', $instance)) {
         $dropdown = $instance['dropdown'];
     } else {
         $dropdown = false;
     }
     #child of arg
     if (array_key_exists('childof', $instance)) {
         $childof = $instance['childof'];
     } else {
         $childof = '';
     }
     //get current category/taxonomy
     if (isset($instance['childof_current_term']) && $instance['childof_current_term'] && (is_category() || is_tax())) {
         $obj = get_queried_object();
         //get current page data
         $childof = $obj->term_id;
         //get current term in template
     }
     $show_subcat_by_parent = isset($instance['show_subcat_by_parent']) ? (bool) $instance['show_subcat_by_parent'] : false;
     $categories_by_current_post = isset($instance['categories_by_current_post']) ? (bool) $instance['categories_by_current_post'] : false;
     $args['skin'] = $skin;
     $args['skin_setting'] = $skin_setting;
     $data = array('show_subcat_by_parent' => $show_subcat_by_parent, 'categories_by_current_post' => $categories_by_current_post, 'skin' => $skin, 'skin_setting' => $skin_setting);
     // Output
     $tax = $this_taxonomy;
     if ($dropdown) {
         $taxonomy_object = get_taxonomy($tax);
         $args = array('show_option_all' => false, 'show_option_none' => '', 'orderby' => $orderby, 'order' => $ascdsc, 'show_count' => $showcount, 'hide_empty' => $hide_empty, 'child_of' => $childof, 'exclude' => $exclude, 'echo' => 0, 'hierarchical' => $hierarchical, 'name' => $taxonomy_object->query_var, 'id' => 'hwlct-widget-' . $tax, 'depth' => $depth, 'taxonomy' => $tax, 'hide_if_empty' => (bool) $hide_empty, 'walker' => new hwlctwidget_Taxonomy_Dropdown_Walker(), 'mydata' => $data);
     } else {
         $args = array('show_option_all' => false, 'orderby' => $orderby, 'order' => $ascdsc, 'style' => 'list', 'show_count' => $showcount, 'hide_empty' => $hide_empty, 'use_desc_for_title' => 1, 'child_of' => $childof, 'exclude' => $exclude, 'hierarchical' => $hierarchical, 'title_li' => '', 'show_option_none' => apply_filters('hwlct_show_option_none', $show_option_none), 'number' => null, 'echo' => 0, 'depth' => $depth, 'taxonomy' => $tax, 'mydata' => $data);
         $args['walker'] = new hwlctwidget_Taxonomy_Walker($args);
     }
     $args = apply_filters('hwlct_wp_list_categories_args', $args, $instance);
     //filter args
     if ($use_skin && $this->skin) {
         //load skin
         $skin = $this->skin;
         //$file = $this->skin->get_skin_instance('x')->get_skin_link(empty($instance['skin1'])? 'default':$instance['skin1']);
         $file = $this->skin->get_skin_file(empty($instance['skin']) ? 'default' : $instance['skin']);
         if (file_exists($file)) {
             HW_POST::reset_item_counter();
             $terms_data = get_categories($args);
             //get terms data
             foreach ($terms_data as $id => &$term) {
                 //wrap with timber
                 $term = new HW_TimberTerm($term->term_id, $term->taxonomy);
                 //class
                 $classes = array('item-box');
                 if ($awc_enable_grid_posts && isset($awc_grid_posts_cols) && class_exists('HW_POST')) {
                     $classes = HW_POST::get_item_class($awc_grid_posts_cols, $classes);
                 }
                 if (class_exists('HW_POST')) {
                     $term->add_class(HW_POST::item_class($classes, false));
                 }
                 //term image custom field
                 /*if(function_exists('get_field')) $image = get_field('image',$term);
                   else $image = '';
                   if(!$image) $image = HW_SKIN::current()->get_skin_url('images/placeholder.png');*/
             }
             //skin template
             $content = $this->skin->render_skin_template(compact('terms_data', 'tax'), false);
             if ($content !== false) {
                 echo $content;
             }
             //init theme setting
             $theme['styles'] = array();
             //declare stylesheets file
             $theme['scripts'] = array();
             //declare js files
             if ($this->skin->allow_skin_file()) {
                 include $file;
             }
             //enqueue stuff from skin
             HW_SKIN::enqueue_skin_assets(array('instance' => $this->skin, 'hash_skin' => $instance['skin'], 'skin_file' => $file, 'skin_settings' => $theme, 'skin_options' => $skin_setting));
         }
     } else {
         echo $before_widget;
         if ($title) {
             echo $before_title . $title . $after_title;
         }
         if ($dropdown) {
             echo '<form action="' . get_bloginfo('url') . '" method="get">';
             echo apply_filters('hwlct_wp_dropdown_categories', wp_dropdown_categories($args), $args, $instance);
             echo '<input type="submit" value="go &raquo;" /></form>';
         } else {
             echo apply_filters('hwlct_wp_list_categories', wp_list_categories($args), $args, $instance);
         }
         echo $after_widget;
     }
     if ($use_skin && !class_exists('HW_SKIN')) {
         echo 'HW_SKIN class không tìm thấy.';
     }
     //notice
 }
 /**
  * display widget content on website
  * @param $args
  * @param $instance
  */
 public function widget($args, $instance)
 {
     extract($args);
     //filter widget title
     $instance['title'] = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
     // Title
     $hash_skin = empty($instance['skin']) ? 'default' : $instance['skin'];
     //valid instance
     if (!isset($instance['phone_icon'])) {
         $instance['phone_icon'] = '';
     }
     if (!isset($instance['mail_icon'])) {
         $instance['mail_icon'] = '';
     }
     //by hoangweb.com
     if ($this->skin) {
         $nums = $this->_number;
         //load skin
         $file = $this->skin->get_skin_file($hash_skin);
         if (file_exists($file)) {
             $skin_setting = $this->skin->get_file_skin_setting($hash_skin, false);
             $skin_options = $this->skin->get_file_skin_options($hash_skin, false);
             if (file_exists($skin_setting)) {
                 //get setting file
                 include $skin_setting;
             }
             //init theme setting
             if (empty($theme)) {
                 $theme = array();
             }
             $theme['styles'] = array();
             $theme['scripts'] = array();
             //parse widget data
             $data = HW_Yahoo_Skype_status::parse_onlinesupport_data($instance);
             if (!is_array($data)) {
                 $data = array();
             }
             include $file;
             $this->skin->render_skin_template(array('current_skin' => HW_SKIN::current(), 'before_widget' => $before_widget, 'before_title' => $before_title, 'after_title' => $after_title, 'after_widget' => $after_widget, 'instance' => $instance, 'data' => $data, 'yk' => $this), true, $hash_skin);
             //$this->skin->enqueue_files_from_skin($theme['styles'], $theme['scripts']); //enqueue stuff from skin
             //enqueue stuff from skin
             HW_SKIN::enqueue_skin_assets(array('instance' => $this->skin, 'hash_skin' => $instance['skin'], 'skin_file' => $file, 'theme_settings' => $theme));
         }
     } else {
         echo 'not found class HW_SKIN.';
     }
 }
 /**
  * form HTML to output on website, but we will include selected skin for this form
  */
 public function _hw_wpcf7_form_elements($html)
 {
     $skin = $this->current->prop('hw_wpcf7_skin');
     //get current contact form skin
     $custom_css = $this->current->prop('hw_custom_css');
     //get custom css for this form
     $enable_skin = $this->current->prop('hw_wpcf7_use_skin');
     //check whether this skin is active for the contact form
     if ($enable_skin !== 'on') {
         return $html;
     }
     //don't use private skin for this form
     //get skin file
     $file = $this->setting->skin->get_skin_file($skin);
     if (file_exists($file)) {
         $theme[] = array();
         ob_start();
         include_once $file;
         if (!isset($theme['styles'])) {
             $theme['styles'] = array();
         }
         if (!isset($theme['scripts'])) {
             $theme['scripts'] = array();
         }
         /*if(count($theme['styles']) || count($theme['scripts'])){    //enqueue stuff from skin
               $this->setting->skin->enqueue_files_from_skin($theme['styles'], $theme['scripts']);
           }*/
         //enqueue stuff from skin
         HW_SKIN::enqueue_skin_assets(array('instance' => $this->setting->skin, 'hash_skin' => $skin, 'skin_file' => $file, 'theme_settings' => $theme));
         //addition css
         echo '<style>';
         echo $this->format_custom_css($custom_css);
         echo '</style>';
         do_action('hw_wpcf7_contact_form_css', $this->current);
         $content = ob_get_contents();
         ob_clean();
         $html .= $content;
     }
     return $html;
 }
 /**
  * output breadcrumb navxt
  */
 public function display()
 {
     //get bcn settings
     $setting = $this->get_settings();
     $display = 'normal';
     $linked = isset($setting['hw_allow_trail_link']) && $setting['hw_allow_trail_link'] ? true : false;
     $reverse = isset($setting['hw_bcn_reverse']) && $setting['hw_bcn_reverse'] ? true : false;
     if (isset($setting['hw_active_skin']) && $setting['hw_active_skin'] && class_exists('HW_SKIN') && isset($setting['hw_skin']) && isset($setting['hw_skin']['hwskin_config'])) {
         #$skin = HW_SKIN::resume_skin($setting['hw_skin']['hwskin_config']);
         $skin = HW_SKIN::resume_hwskin_instance($setting['hw_skin']);
         if (!empty($skin)) {
             $file = $skin->instance->get_skin_file($setting['hw_skin']['hash_skin']);
             $content = $skin->instance->render_skin_template(0, false);
             if ($content !== false) {
                 echo $content;
             }
             //if(file_exists($file)) {
             //get theme setting from setting file or skin file
             $setting = $skin->instance->get_file_skin_setting();
             if (file_exists($setting)) {
                 include $setting;
             } else {
                 include $file;
             }
             if (isset($theme['display']) && $theme['display'] == 'list') {
                 $display = 'list';
             }
             //how to output breadcrumb
             $opt = array('hseparator' => '>>');
             breadcrumb_navxt::setup_options($opt);
             //valid setting
             if (empty($theme['styles'])) {
                 $theme['styles'] = array();
             }
             if (empty($theme['scripts'])) {
                 $theme['scripts'] = array();
             }
             if (!empty($theme['filters'])) {
                 //do filters & actions that defined in skin
                 $skin->instance->do_filters($theme['filters'], $theme);
             }
             /*if(count($theme['styles']) || count($theme['scripts'])) {   //enqueue stuff from theme
                   $skin->enqueue_files_from_skin($theme['styles'], $theme['scripts']);
               }*/
             //enqueue stuff from skin using new way
             HW_SKIN::enqueue_skin_assets(array_merge(array('skin_file' => $file, 'theme_settings' => $theme), (array) $skin));
             //}
         }
     }
     //how to ouput breadcrumb function
     if ($display == 'list') {
         $output = bcn_display_list(true, $linked, $reverse);
     } else {
         $output = bcn_display(true, $linked, $reverse);
     }
     echo '<div class="hw-breadcrumb">';
     echo apply_filters('hw_breadcrumb_output', $output, $this);
     echo '</div>';
 }
Exemplo n.º 8
0
 /**
  * get footer, instead of calling get_footer()
  * @param $slug from get_footer() param
  */
 public static function get_footer($slug = '')
 {
     $footer_skin = hw_option('footer_skin');
     //get footer skin
     //skin options
     if (!empty($footer_skin) && !empty($footer_skin['skin_options'])) {
         $skin_options = $footer_skin['skin_options'];
         extract($skin_options);
     }
     if (isset($footer_skin['hash_skin']) && isset($footer_skin['hwskin_config'])) {
         $skin = APF_hw_skin_Selector_hwskin::resume_hwskin_instance($footer_skin);
         $file = $skin->instance->get_skin_file($skin->hash_skin);
         //get theme setting file
         $setting = $skin->instance->get_file_skin_setting();
         //(new HW_SKIN);
         if (file_exists($setting)) {
             include $setting;
         }
         $skin->instance->render_skin_template(compact('col', 'col_1', 'col_2', 'col_3'), true);
         //render skin twig template
         //load footer template
         if ($skin->instance->allow_skin_file() && file_exists($file)) {
             include_once $file;
         }
         //valid
         if (!isset($theme['styles'])) {
             $theme['styles'] = array();
         }
         if (!isset($theme['scripts'])) {
             $theme['scripts'] = array();
         }
         //put stuff from skin
         /*if(count($theme['styles']) || count($theme['scripts'])) {
               $skin->instance->enqueue_files_from_skin($theme['styles'], $theme['scripts']);
           }
           */
         if (isset($theme['filters'])) {
             $skin->instance->do_filters($theme['filters'], $theme);
         }
         //do skin filter/action
         //enqueue stuff from skin using new way
         HW_SKIN::enqueue_skin_assets(array_merge(array('skin_file' => $file, 'theme_settings' => $theme), (array) $skin));
     } else {
         get_footer($slug);
         //include default footer-$slug.php
     }
     do_action('hw_get_footer');
     //modify footer output, you can add close html tag for example to make fit your wp theme
 }
 /**
  * render metaslider slideshow, i will put skin content after this
  * @param $slideshow: slider output
  * @param int $id: slider id
  * @param array $settings: current slider settings data
  */
 function _hw_metaslider_slideshow_output($slideshow, $id, $settings)
 {
     if (isset($this->skin)) {
         //load actived skin
         $file = $this->skin->get_skin_file($settings['theme']);
         if (file_exists($file)) {
             ob_start();
             include $file;
             //valid
             if (!isset($theme['styles'])) {
                 $theme['styles'] = array();
             }
             if (!isset($theme['scripts'])) {
                 $theme['scripts'] = array();
             }
             /*
                                 //enqueue stuff from skin
                                 if(count($theme['styles']) || count($theme['scripts'])) {
                                     $this->skin->enqueue_files_from_skin($theme['styles'], $theme['scripts']);
                                 }*/
             //enqueue stuff from skin
             HW_SKIN::enqueue_skin_assets(array('instance' => $this->skin, 'hash_skin' => $settings['theme'], 'skin_file' => $file, 'skin_settings' => $theme));
             $content = ob_get_contents();
             ob_clean();
             $slideshow .= $content;
         }
     }
     return $slideshow;
 }
Exemplo n.º 10
0
 /**
  *
  */
 public function _hw_wp_footer()
 {
     if (hw_livechat_option('enable_livechat')) {
         //load mobile detector library
         if (function_exists('hwlib_load_library')) {
             $mobile_detect = hwlib_load_library('HW_Mobile_Detect');
             if ($mobile_detect->object->isMobile() && !hw_livechat_option('active_on_mobile')) {
                 return;
                 //do not show chatbox on mobile device
             }
         }
         /*if(class_exists('HW_Mobile_Detect')) {
               HW_PHP_Libraries::get('HW_Mobile_Detect');
           }*/
         //get embed live chat code
         $embed = hw_livechat_option('chat_embed_code');
         if ($embed) {
             echo $embed;
         }
         /**
          * apply skin
          */
         $skin_data = hw_livechat_option('chat_skin');
         $skin = APF_hw_skin_Selector_hwskin::resume_hwskin_instance($skin_data);
         if ($skin && !empty($skin->instance)) {
             $file = $skin->instance->get_skin_file($skin->hash_skin);
             if (file_exists($file)) {
                 $theme = array();
                 //valid
                 include $file;
                 //depricated
                 /*if(!isset($theme['styles'])) $theme['styles'] = array();
                                     if(!isset($theme['scripts'])) $theme['scripts'] = array();
                 
                                     if(count($theme['styles']) || count($theme['scripts'])) {
                                         $skin->instance->enqueue_files_from_skin(null//$theme['styles']//, $theme['scripts']);  //enqueued css before
                                     }*/
                 HW_SKIN::enqueue_skin_assets(array_merge(array('skin_file' => $file), (array) $skin));
             }
         }
     }
 }
 /**
  * add shortcode to display slider on website
  * @param array $attsa
  */
 public function _hwml_shortcode_slider($atts = array())
 {
     $default = array('id' => false, 'restrict_to' => false);
     extract(shortcode_atts($default, $atts, 'hwml_slider'));
     if (!$id) {
         return false;
     }
     // handle [hwml_slider id=123 restrict_to=home]
     if ($restrict_to && $restrict_to == 'home' && !is_front_page()) {
         //front page
         return;
     }
     if ($restrict_to && $restrict_to != 'home' && !is_page($restrict_to)) {
         //for page
         return;
     }
     $id = trim($id, '&quot;');
     $post = get_post($id);
     //_print(get_post_custom($id));
     $slider_id = get_post_meta($id, 'pick_slider', true);
     //meta slider id
     $slider_theme = get_post_meta($id, 'slider_theme', true);
     //slider theme
     $source = get_post_meta($id, 'slideshow_source', true);
     //choose slideshow source
     if (!$slider_id && !$slider_theme) {
         throw new Exception('Lỗi custom field (hwml-shortcode)?');
         return;
     }
     //instance HW_SKIN
     $skin = APF_hw_skin_Selector_hwskin::resume_hwskin_instance($slider_theme);
     //current skin file
     $file = $skin->instance->get_skin_file($skin->hash_skin);
     $skin_config = $skin->instance->get_config(false);
     $skin_info = $skin->instance->get_active_skin_info();
     $options_config = $skin->instance->get_file_skin_options($skin->hash_skin);
     //theme options configuration
     $theme_setting = $skin->instance->get_file_skin_setting();
     //(new HW_SKIN)->get_file_skin_setting()
     //theme options
     $user_theme_options = isset($slider_theme['skin_options']) && is_array($slider_theme['skin_options']) ? $slider_theme['skin_options'] : array();
     /*
     //load skin resource
     if(file_exists($options_config)) include($options_config);   //include define theme options
     if(file_exists($theme_setting)) include($theme_setting);        //theme setting
     
     if( isset($theme_options) && isset($theme)){
         $default = isset($theme['options']) ? $theme['options'] : array();
     
         $result = HW_SKIN::get_skin_options($user_theme_options, $default,$theme_options);
         $user_theme_options = array_merge($user_theme_options, $result);
     }
     */
     //new way
     $user_theme_options = HW_SKIN::merge_skin_options_values($user_theme_options, $theme_setting, $options_config);
     //get default template for this skin base slideshow source
     $default_template = $skin_info[0] . '/' . $skin_info[1] . trim($skin_config['skin_name'], '.php') . '_template_' . $source . '.php';
     //default template
     if (file_exists($default_template) && isset($user_theme_options['template_file']) && $user_theme_options['template_file'] == APF_hw_skin_Selector_hwskin::DEFAULT_TEMPLATE) {
         $file = $default_template;
         //change template file
     } elseif (isset($user_theme_options['template_file']) && $user_theme_options['template_file'] != APF_hw_skin_Selector_hwskin::DEFAULT_TEMPLATE) {
         $file = base64_decode($user_theme_options['template_file']);
     }
     if (file_exists($file)) {
         //get data
         $show_title = get_post_meta($id, 'show_title', true);
         $data = array();
         //valid data
         if (isset($user_theme_options['template_file'])) {
             unset($user_theme_options['template_file']);
         }
         //get sides from metaslider
         if ($source == 'metaslider') {
             $query = $this->get_mlslider_metaslides($slider_id);
             $data['posts'] = Timber::get_posts($query->query_vars);
         }
         //get sides from posts
         if ($source == 'posttype') {
             //get query post types
             $posttype = get_post_meta($id, 'source_posttype', true);
             //get active post types
             $current_post = get_post_meta($id, 'current_post', true);
             //get active post types
             $only_attachment = get_post_meta($id, 'only_attachments', true);
             //get only attachments
             $args = array('order' => 'ASC', 'posts_per_page' => -1);
             $query = null;
             $images = array();
             if ($current_post) {
                 global $post;
                 if (is_single()) {
                     $images = get_children(array('post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image'));
                 }
             } else {
                 //get all selected terms assign to post type
                 $pt_terms = get_post_meta($id, 'post_type_terms', true);
                 $tax_query_relation = get_post_meta($id, 'tax_query_relation', true);
                 $terms_tax = array();
                 //prepare tax query
                 $tax_query = array();
                 //tax_query param
                 if ($tax_query_relation) {
                     $tax_query['relation'] = $tax_query_relation;
                 }
                 if (is_array($pt_terms)) {
                     foreach ($pt_terms as $t => $enable) {
                         if ($enable) {
                             $tax = base64_decode($t);
                             $tax = explode('|', $tax);
                             if (!isset($terms_tax[$tax[1]])) {
                                 $terms_tax[$tax[1]] = array();
                             }
                             $terms_tax[$tax[1]][] = $tax[0];
                         }
                     }
                 }
                 //build tax_query param
                 foreach ($terms_tax as $tax => $terms) {
                     $tax_query[] = array('taxonomy' => $tax, 'field' => 'slug', 'terms' => $terms, 'operator' => 'IN');
                 }
                 //$terms = wp_get_post_terms($id,'category',array("fields" => "ids"));
                 $args['post_type'] = $posttype;
                 $args['tax_query'] = $tax_query;
                 $query = new WP_Query($args);
                 $data['posts'] = Timber::get_posts($args);
                 //get only attachments image
                 if ($only_attachment) {
                     //refercence http://wordpress.stackexchange.com/questions/52315/get-attachments-for-all-posts-of-particular-post-type
                     if ($query->have_posts()) {
                         while ($query->have_posts()) {
                             $query->the_post();
                             // arguments for get_posts
                             $attachment_args = array('post_type' => 'attachment', 'post_mime_type' => 'image', 'post_status' => null, 'post_parent' => get_the_ID());
                             // get the posts
                             $this_posts_attachments = get_posts($attachment_args);
                             // append those posts onto the array
                             $images[get_the_ID()] = $this_posts_attachments;
                             // make an array with the post_id as the key, just in case that's useful
                         }
                     }
                 }
             }
         }
         //skin data
         $options = APF_hw_skin_Selector_hwskin::build_json_options($user_theme_options, 'template_file');
         $slider_theme = !empty($user_theme_options['theme']) ? $user_theme_options['theme'] : 'default';
         $data = compact('slider_id', 'options', 'slider_theme', 'show_title');
         $data['context'] = $this;
         /**
          * parse theme
          */
         $content = $skin->instance->render_skin_template($data, false);
         //implement skin template
         if ($content !== false) {
             echo $content;
         }
         $theme = array();
         //valid
         if ($skin->instance->allow_skin_file()) {
             include_once $file;
         }
         /*if(!isset($theme['styles'])) $theme['styles'] = array();
                     if(!isset($theme['scripts'])) $theme['scripts'] = array();
         
                     if(count($theme['styles']) || count($theme['scripts'])) {
                         $skin->instance->enqueue_files_from_skin($theme['styles'], $theme['scripts']);
                     }*/
         //enqueue stuff from skin
         HW_SKIN::enqueue_skin_assets(array('instance' => $skin->instance, 'hash_skin' => $skin->hash_skin, 'skin_file' => $file, 'theme_settings' => $theme, 'theme_options' => $user_theme_options));
     }
 }