/** * render facebook comment box * @param $atts attributes */ function _hw_fb_comment_display($atts) { HW_HOANGWEB::load_class('HW_UI_Component'); $inst = HW_Module_Comments::get(); $options = $inst->get_tab('facebook')->get_values(); $atts = array(); $appId = isset($options['appId']) ? $options['appId'] : ''; $width = !empty($options['width']) ? HW_Validation::format_unit($options['width']) : '100%'; $num_posts = !empty($options['num_posts']) ? $options['num_posts'] : '5'; $colorscheme = !empty($options['colorscheme']) ? $options['colorscheme'] : 'light'; $order_by = !empty($options['order_by']) ? $options['order_by'] : 'social'; //order_by $show_count = !empty($options['show_count']) ? $options['show_count'] : 0; $comment_text = !empty($options['comment_text']) ? $options['comment_text'] : __('Bình luận'); echo '<div id="fb-root"></div>'; #echo '<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>'; echo "\r\n<script>(function(d, s, id) {\r\n var js, fjs = d.getElementsByTagName(s)[0];\r\n if (d.getElementById(id)) return;\r\n js = d.createElement(s); js.id = id;\r\n js.src = '//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5&appId={$appId}';\r\n fjs.parentNode.insertBefore(js, fjs);\r\n}(document, 'script', 'facebook-jssdk'));</script>"; //show count if ($show_count) { echo '<span class="fb-comments-count" data-href="' . get_permalink() . '"></span> ' . $comment_text; } if (isset($options['html5'])) { $atts['data-href'] = get_permalink(); $atts['data-width'] = $width; $atts['data-numposts'] = $num_posts; $atts['data-order-by'] = $order_by; $atts['data-colorscheme'] = $colorscheme; echo '<div class="fb-comments" ' . HW_UI_Component::generateAttributes($atts) . '></div>'; } else { $atts['href'] = get_permalink(); $atts['width'] = $width; $atts['num_posts'] = $num_posts; $atts['order_by'] = $order_by; $atts['width'] = $width; echo '<fb:comments ' . HW_UI_Component::generateAttributes($atts) . '></fb:comments>'; } }
/** * extend from wordpress core * @param string $output * @param object $category * @param int $depth * @param array $args * @param int $id */ public function start_el(&$output, $category, $depth = 0, $args = array(), $id = 0) { if (!empty($args['mydata']['skin_setting'])) { $skin_setting = $args['mydata']['skin_setting']; } $this->current_cat = new HW_TimberTerm($category); /** This filter is documented in wp-includes/category-template.php */ $cat_name = apply_filters('list_cats', esc_attr($category->name), $category); //valid $options = (object) $args['options']; if (!isset($options->before)) { $options->before = ''; } if (!isset($options->submenu_before)) { $options->submenu_before = ''; } if (!isset($options->after)) { $options->after = ''; } if (!isset($options->submenu_after)) { $options->submenu_after = ''; } if (!isset($options->link_before)) { $options->link_before = ''; } if (!isset($options->submenu_link_before)) { $options->submenu_link_before = ''; } if (!isset($options->link_after)) { $options->link_after = ''; } if (!isset($options->submenu_link_after)) { $options->submenu_link_after = ''; } //whether current menu item has sub menu $item_has_sub = $this->item_has_sub($category); //separator if (!empty($options->ex_separator) && isset($options->show_items_separator)) { $output .= $options->ex_separator; } $data['args'] = hwArray::cloneArray($options); $data['indent'] = $indent = $depth ? str_repeat("\t", $depth) : ''; $data['item_has_sub'] = $item_has_sub; $id = apply_filters('hw_cat_item_id', 'cat-item-' . $category->term_id, $category, $args, $depth); $data['id'] = ' id="cat-' . esc_attr($category->term_id) . '"'; if ($item_has_sub && !empty($options->remove_link_parent)) { $data['remove_link_parent'] = true; } else { $data['remove_link_parent'] = false; } //item class //category item class $classes[] = 'cat-item cat-item-' . $category->term_id; if (!empty($args['current_category'])) { $_current_category = get_term($args['current_category'], $category->taxonomy); if ($category->term_id == $args['current_category']) { $classes[] = 'current-cat'; if (isset($skin_setting['current_item_class'])) { $classes[] = ' ' . $skin_setting['current_item_class']; } } elseif ($category->term_id == $_current_category->parent) { $classes[] = 'current-cat-parent'; } } if ($item_has_sub && !empty($options->menu_item_class_has_submenu)) { //cat item class has submenu $classes[] = $options->menu_item_class_has_submenu; } if ($depth > 0 && !empty($options->menu_item_class_submenu)) { //cat item class in submenu $classes[] = $options->menu_item_class_submenu; } $data['classes'] = $class_names = join(' ', apply_filters('cat_item_css_class', HW_Validation::valid_classes_attr(array_filter($classes)), $category, $args, $depth)); //custom fields $custom_item = get_post_custom($category->term_id); $data['field-01'] = isset($custom_item['menu-item-field-01'][0]) ? $custom_item['menu-item-field-01'][0] : ''; $data['field-02'] = isset($custom_item['menu-item-field-02'][0]) ? $custom_item['menu-item-field-02'][0] : ''; //cat item image if (isset($options->show_icon) && $options->show_icon) { $image_url = HW_ACF_Taxonomy::get_field_image($category); if ($image_url) { $image_img = '<img src="' . $image_url . '" class="hw-cat-item-icon"/>'; } else { $image_img = ''; } } $data['image_url'] = isset($image_url) ? $image_url : ''; $data['image_img'] = isset($image_img) ? $image_img : ''; /** * anchor attributes */ $atts = array(); $atts['href'] = esc_url(get_term_link($category)); $atts['class'] = array(); //anchor classes if ($item_has_sub && isset($options->anchor_class_has_submenu)) { //anchor class has submenu $atts['class'][] = $options->anchor_class_has_submenu; } if ($depth > 0 && !empty($options->anchor_class_submenu)) { //anchor class in submenu $atts['class'][] = $options->anchor_class_submenu; } $atts = apply_filters('hw_cat_link_attributes', $atts, $category, $args, $depth, $this); //validation $atts['class'] = HW_Validation::valid_classes_attr(array_filter($atts['class'])); $atts['class'] = join(' ', $atts['class']); if ($args['use_desc_for_title'] && !empty($category->description)) { $atts['title'] = esc_attr(strip_tags(apply_filters('category_description', $category->description, $category))); } $attributes = HW_UI_Component::generateAttributes($atts); //addition attribute build for item link if ($depth == 0 && !empty($options->anchor_attrs)) { $attributes .= " {$options->anchor_attrs}"; } elseif ($depth != 0 && !empty($options->anchor_attrs_submenu)) { $attributes .= " {$options->anchor_attrs_submenu}"; } //attributes item link for submenu if ($item_has_sub && !empty($options->anchor_attrs_has_submenu)) { $attributes .= " {$options->anchor_attrs_has_submenu}"; } $data['attributes'] = $attributes; $data['title'] = apply_filters('the_title', $category->name, $category->term_id); $link = $options->before; $link .= '<a ' . $attributes . ' >'; $link .= $options->link_before . $cat_name . $options->link_after; $link .= '</a>'; $link .= $options->after; //feed image if (!empty($args['feed_image']) || !empty($args['feed'])) { $link .= ' '; if (empty($args['feed_image'])) { $link .= '('; } $link .= '<a href="' . esc_url(get_term_feed_link($category->term_id, $category->taxonomy, $args['feed_type'])) . '"'; if (empty($args['feed'])) { $alt = ' alt="' . sprintf(__('Feed for all posts filed under %s'), $cat_name) . '"'; } else { $alt = ' alt="' . $args['feed'] . '"'; $name = $args['feed']; $link .= empty($args['title']) ? '' : $args['title']; } $link .= '>'; if (empty($args['feed_image'])) { $link .= $name; } else { $link .= "<img src='" . $args['feed_image'] . "'{$alt}" . ' />'; } $link .= '</a>'; if (empty($args['feed_image'])) { $link .= ')'; } } if (!empty($args['show_count'])) { $link .= ' (' . number_format_i18n($category->count) . ')'; } //render cat item if (isset($args['twig']) && HW_NAVMENU::twig_asset_exists('start_el.twig', $args['twig'])) { $tpl = $args['twig']->loadTemplate('start_el.twig'); $data['term'] = $this->current_cat; $output .= $tpl->render($data); } else { if ('list' == $args['style']) { $output .= $indent . "\t<li"; //class attr $output .= ' class="' . $class_names . '"'; $output .= ">{$link}\n"; } else { $output .= "\t{$link}<br />\n"; } } }
/** * return HTML for select tag of terms list from taxonomy * @param $tax * @param $focus * @param array $atts * @param array $args * @return string|void */ function hw_get_terms_list($tax, $focus, $atts = array(), $args = array()) { if (!$tax) { return; } HW_HOANGWEB::load_class('HW_UI_Component'); if (is_array($args)) { $args = array(); } $args['order'] = 'ASC'; $args['fields'] = 'all'; $args['hide_empty'] = 0; //build atts $attrs = HW_UI_Component::generateAttributes($atts); /*foreach($atts as $att => $v){ $a.=$att.'="'.$v.'" '; }*/ $out = __('Rỗng'); $terms_data = get_terms($tax, $args); if (is_wp_error($terms_data)) { return ''; } if (count($terms_data)) { $out = '<select ' . trim($attrs) . '>'; $out .= '<option value="">----All----</option>'; foreach ($terms_data as $item) { if (!isset($item->slug)) { continue; } if ($item->slug == $focus) { } $out .= '<option ' . selected($item->slug, $focus, false) . ' value="' . $item->slug . '">' . $item->name . '</option>'; } $out .= '</select>'; } return $out; }