예제 #1
0
if ($dropdown) {
    echo '<form action="' . get_bloginfo('url') . '" method="get">';
    wp_dropdown_categories($args);
    echo '<input type="submit" value="go &raquo;" />';
    echo '</form>';
} else {
    echo '<div id="lct-widget-' . $tax . '" class="hwlct-container hwlct-travel-box">';
    //wp_list_categories($args);
    HW_POST::reset_item_counter();
    //$data = get_categories($args);
    foreach ($terms_data as $i => $term) {
        $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);
        }
        $classes_attribute = HW_POST::item_class($classes);
        $term_link = get_term_link($term);
        //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');
        }
        $quick_edit_link = esc_url(get_edit_term_link($term, $term->taxonomy));
        $skin->render_skin_template(array('classes_attribute' => $classes_attribute, 'term_link' => $term_link, 'image' => $image, 'quick_edit_link' => $quick_edit_link, 'term' => $term), true, false, 'loop.tpl');
        /*
        ?>
        <div  <?php echo $classes_attribute?> id="<?php echo $term->term_id?>">
 /**
  * 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
 }
예제 #3
0
    echo '<form action="' . get_bloginfo('url') . '" method="get">';
    wp_dropdown_categories($args);
    echo '<input type="submit" value="go &raquo;" /></form>';
} else {
    echo '<div id="lct-widget-' . $tax . '" class="hwlct-container hwlct-box1">';
    //wp_list_categories($args);
    HW_POST::reset_item_counter();
    $data = get_categories($args);
    foreach ($data as $term) {
        $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);
        }
        ?>
        <div <?php 
        HW_POST::item_class($classes);
        ?>
 id="<?php 
        echo $term->term_id;
        ?>
">
            <div class="sub-category-item">
                <div class="picture">
                    <a href="<?php 
        echo get_term_link($term);
        ?>
" title="<?php 
        echo $term->name;
        ?>
">
                        <?php