function hocwp_shortcode_post_callback($atts = array(), $content = null) { $defaults = array('order' => 'desc', 'orderby' => 'date', 'by' => 'related', 'post_type' => 'post', 'title' => __('Related posts', 'hocwp-theme'), 'offset' => 0, 'column' => 4, 'number' => hocwp_get_posts_per_page(), 'border_color' => '', 'exclude_current' => true, 'display' => 'left', 'excerpt_length' => 0, 'style' => '', 'post' => '', 'posts' => '', 'thumbnail_size' => '180,110', 'interval' => ''); $attributes = shortcode_atts($defaults, $atts); $transient_name = 'hocwp_shortcode_post_%s'; $transient_name = hocwp_build_transient_name($transient_name, $attributes); if (false === ($html = get_transient($transient_name))) { $order = $attributes['order']; $orderby = $attributes['orderby']; $by = $attributes['by']; $post_type = hocwp_string_to_array(',', $attributes['post_type']); $post_type = array_map('trim', $post_type); $offset = $attributes['offset']; $column = $attributes['column']; if (!hocwp_is_positive_number($column)) { $column = 1; } $number = $attributes['number']; $posts_per_page = hocwp_get_first_divisible_of_divisor($number, $column); $exclude_current = (bool) $attributes['exclude_current']; $display = $attributes['display']; $display = trim($display); $excerpt_length = $attributes['excerpt_length']; $post = $attributes['post']; $post = hocwp_find_post($post); $posts = $attributes['posts']; $posts = hocwp_string_to_array(',', $posts); $thumbnail_size = $attributes['thumbnail_size']; $thumbnail_size = hocwp_sanitize_size($thumbnail_size); $interval = $attributes['interval']; if (hocwp_is_post($post)) { $display = 'full'; } $class = 'hocwp-shortcode-post'; hocwp_add_string_with_space_before($class, $order); hocwp_add_string_with_space_before($class, $by); hocwp_add_string_with_space_before($class, hocwp_sanitize_html_class($display)); if ('100%' == $display) { $class = hocwp_add_more_class($class, 'full-width'); } hocwp_add_string_with_space_before($class, implode(' ', $post_type)); $query = null; if (!hocwp_is_post($post)) { $args = array('post_type' => $post_type, 'posts_per_page' => $posts_per_page, 'offset' => $offset, 'order' => $order, 'orderby' => $orderby); if (!empty($interval)) { hocwp_query_sanitize_date_query_args($interval, $args); } if ($exclude_current && is_singular()) { $post_id = get_the_ID(); $args['post__not_in'] = array($post_id); } if (hocwp_array_has_value($posts)) { $args['post__in'] = $posts; } $query = hocwp_query_by($by, $args); } else { if (!hocwp_is_positive_number($excerpt_length)) { $excerpt_length = 200; } } if (hocwp_is_post($post) || hocwp_object_valid($query) && $query->have_posts()) { $html = hocwp_shortcode_before($class, $attributes); $width = $thumbnail_size[0]; if (hocwp_is_post($post)) { global $post; setup_postdata($post); ob_start(); ?> <div class="one-post"> <div <?php post_class('', $post); ?> > <?php if ($width > 0) { hocwp_post_thumbnail(array('width' => $thumbnail_size[0], 'height' => $thumbnail_size[1], 'post_id' => $post->ID)); } hocwp_post_title_link(array('title' => $post->post_title, 'permalink' => get_permalink($post))); if (hocwp_is_positive_number($excerpt_length)) { hocwp_entry_summary($excerpt_length); } ?> </div> </div> <?php $html .= ob_get_clean(); wp_reset_postdata(); } else { $html .= '<div class="in-loop row-small">'; $loop = apply_filters('hocwp_shortcode_post_pre_loop', '', $query, $attributes); if (empty($loop)) { $count = 1; $style = ''; if ('left' != $display && 'right' != $display) { $style = 'width:' . hocwp_column_width_percentage($column); } while ($query->have_posts()) { $query->the_post(); $html_loop = apply_filters('hocwp_shortcode_post_loop', '', $attributes); if (empty($html_loop)) { $item_class = 'item'; if (hocwp_is_last_item($count, $column)) { hocwp_add_string_with_space_before($item_class, 'last-item'); } elseif (hocwp_is_first_item($count, $column)) { hocwp_add_string_with_space_before($item_class, 'first-item'); } ob_start(); ?> <div class="<?php echo $item_class; ?> " style="<?php echo $style; ?> "> <div <?php post_class(); ?> > <?php if ($width > 0) { hocwp_post_thumbnail(array('width' => $thumbnail_size[0], 'height' => $thumbnail_size[1])); } hocwp_post_title_link(); if (hocwp_is_positive_number($excerpt_length)) { hocwp_entry_summary($excerpt_length); } ?> </div> </div> <?php $html_loop = ob_get_clean(); } $loop .= $html_loop; $count++; } wp_reset_postdata(); } $html .= $loop; $html .= '</div>'; } $html .= hocwp_shortcode_after(); } else { $html = ''; } if (!empty($html)) { set_transient($transient_name, $html, WEEK_IN_SECONDS); } } return apply_filters('hocwp_shortcode_post', $html, $attributes, $content); }
function hocwp_slider_html($args = array()) { if (!is_array($args)) { $position = $args; } else { $position = hocwp_get_value_by_key($args, 'position'); } $slider = hocwp_get_slider_by_position($position); if (hocwp_is_post($slider)) { $items = hocwp_get_post_meta('slider_items', $slider->ID); $order = hocwp_get_value_by_key($items, 'order'); if (!empty($order)) { $order = explode(',', $order); $items = hocwp_get_value_by_key($items, 'items'); $slider_class = 'hocwp-slider'; $thumbs = (bool) hocwp_get_value_by_key($args, 'thumbs', false); if ($thumbs) { hocwp_add_string_with_space_before($slider_class, 'thumbs-paging'); } hocwp_add_string_with_space_before($slider_class, hocwp_sanitize_html_class($position)); $custom_arrow = hocwp_get_value_by_key($args, 'custom_arrow'); if ($custom_arrow) { $slider_class = hocwp_add_more_class($slider_class, 'custom-arrow'); } $fit_width = hocwp_get_post_meta('fit_width', $slider->ID); $fit_width = hocwp_int_to_bool($fit_width); $height = hocwp_get_post_meta('height', $slider->ID); if (!hocwp_is_positive_number($height)) { $height = 350; } $atts = array('data-height="' . $height . '"'); if ($fit_width) { $atts[] = 'data-fit-width="1"'; } $atts = implode(' ', $atts); if (!empty($atts)) { $atts = ' ' . $atts; $atts = rtrim($atts); } echo '<div class="' . $slider_class . '">'; echo '<ul class="list-unstyled list-items slickslide list-inline"' . $atts . '>'; $list_paging = ''; $lazyload = hocwp_get_value_by_key($args, 'lazyload'); foreach ($order as $item_id) { $item = hocwp_get_value_by_key($items, $item_id); if (hocwp_array_has_value($item)) { $title = hocwp_get_value_by_key($item, 'title'); $link = hocwp_get_value_by_key($item, 'link'); $description = hocwp_get_value_by_key($item, 'description'); $image_url = hocwp_get_value_by_key($item, 'image_url'); $image_id = hocwp_get_value_by_key($item, 'image_id'); $image_url = hocwp_return_media_url($image_url, $image_id); $img = new HOCWP_HTML('img'); $img->set_image_src($image_url); $img->add_class('slider-image'); $li = new HOCWP_HTML('li'); $li->set_text($img); $li->add_class('slider-item'); if ($lazyload) { $li->add_class('lazyload'); $img->set_attribute('data-original', $image_url); $img->set_image_src(hocwp_get_image_url('transparent.gif')); } $list_paging .= $li->build(); if (!empty($link)) { $a = new HOCWP_HTML('a'); $a->set_href($link); $a->set_text($img); $li->set_text($a); } else { $li->set_text($img); } $li->output(); } } echo '</ul>'; if ($thumbs) { echo '<div class="thumbs-paging slick-thumbs">'; echo '<ul class="list-unstyled list-paging">'; echo $list_paging; echo '</ul>'; echo '</div>'; } echo '</div>'; } } }
public function widget($args, $instance) { $this->instance = $instance; $page_name = isset($instance['page_name']) ? $instance['page_name'] : ''; $href = isset($instance['href']) ? $instance['href'] : ''; $width = isset($instance['width']) ? $instance['width'] : $this->args['width']; $height = isset($instance['height']) ? $instance['height'] : $this->args['height']; $hide_cover = (bool) (isset($instance['hide_cover']) ? $instance['hide_cover'] : $this->args['hide_cover']); $show_facepile = (bool) (isset($instance['show_facepile']) ? $instance['show_facepile'] : $this->args['show_facepile']); $hide_cta = (bool) (isset($instance['hide_cta']) ? $instance['hide_cta'] : $this->args['hide_cta']); $small_header = (bool) (isset($instance['small_header']) ? $instance['small_header'] : $this->args['small_header']); $adapt_container_width = (bool) (isset($instance['adapt_container_width']) ? $instance['adapt_container_width'] : $this->args['adapt_container_width']); $fixed = hocwp_get_value_by_key($instance, 'fixed', $this->args['fixed']); $only_link = hocwp_get_value_by_key($instance, 'only_link', $this->args['only_link']); $button_text = hocwp_get_value_by_key($instance, 'button_text', $this->args['button_text']); $before_widget = hocwp_get_value_by_key($args, 'before_widget'); $widget_class = ''; if ($fixed) { hocwp_add_string_with_space_before($widget_class, 'fixed'); $position = hocwp_get_value_by_key($instance, 'position', $this->args['position']); hocwp_add_string_with_space_before($widget_class, hocwp_sanitize_html_class($position)); } $before_widget = hocwp_add_class_to_string('', $before_widget, $widget_class); $args['before_widget'] = $before_widget; $img = new HOCWP_HTML('img'); $img->set_image_src(hocwp_get_image_url('icon-facebook-messenger-white-64.png')); $img->set_class('icon-messenger'); hocwp_widget_before($args, $instance); if ($only_link) { if (!hocwp_is_url($href)) { $href = 'https://m.me/' . $href; } $span = new HOCWP_HTML('span'); $span->set_text($button_text); $link_text = $img->build(); $link_text .= $span->build(); $a = new HOCWP_HTML('a'); $a->add_class('button btn btn-facebook-messenger'); $a->set_text($link_text); $a->set_href($href); $widget_html = $a->build(); } else { $app_id = hocwp_get_wpseo_social_facebook_app_id(); if (empty($app_id)) { hocwp_debug_log(__('Please set your Facebook APP ID first.', 'hocwp-theme')); return; } add_filter('hocwp_use_facebook_javascript_sdk', '__return_true'); ?> <script type="text/javascript"> window.fbAsyncInit = function () { FB.init({ appId: '<?php echo $app_id; ?> ', cookie: true, xfbml: true, version: 'v<?php echo HOCWP_FACEBOOK_JAVASCRIPT_SDK_VERSION; ?> ' }); }; </script> <?php $fanpage_args = array('page_name' => $page_name, 'href' => $href, 'width' => $width, 'height' => $height, 'tabs' => 'messages', 'hide_cover' => $hide_cover, 'show_facepile' => $show_facepile, 'hide_cta' => $hide_cta, 'small_header' => $small_header, 'adapt_container_width' => $adapt_container_width); ob_start(); if ($fixed) { $fanpage_args['width'] = 300; ?> <div class="messenger-box module"> <div class="module-header heading btn-facebook-messenger" title="<?php echo $button_text; ?> "> <?php $img->output(); ?> <label><?php echo $button_text; ?> </label> <?php if ('left' == $position || 'right' == $position) { echo '<i class="fa fa-times" aria-hidden="true"></i>'; $span = new HOCWP_HTML('span'); $span->add_class('facebook-messenger-box-control'); $span->set_text($img); $span->output(); } else { echo '<i class="fa fa-angle-up" aria-hidden="true"></i>'; } ?> </div> <div class="module-body"> <?php hocwp_facebook_page_plugin($fanpage_args); ?> </div> </div> <?php } else { hocwp_facebook_page_plugin($fanpage_args); } $widget_html = ob_get_clean(); } $widget_html = apply_filters('hocwp_widget_facebook_messenger_html', $widget_html, $args, $instance, $this); echo $widget_html; hocwp_widget_after($args, $instance); }
function hocwp_theme_option_sidebar_tab() { global $hocwp_tos_tabs; if (hocwp_array_has_value($hocwp_tos_tabs)) { $current_page = hocwp_get_current_admin_page(); ?> <ul class="list-tabs"> <?php foreach ($hocwp_tos_tabs as $key => $value) { ?> <?php $admin_url = admin_url('admin.php'); $admin_url = add_query_arg(array('page' => $key), $admin_url); $item_class = hocwp_sanitize_html_class($key); if ($key == $current_page) { hocwp_add_string_with_space_before($item_class, 'active'); $admin_url = 'javascript:;'; } $text = hocwp_get_value_by_key($value, 'text'); if (empty($text)) { continue; } ?> <li class="<?php echo $item_class; ?> "><a href="<?php echo $admin_url; ?> "><span><?php echo $text; ?> </span></a></li> <?php } ?> </ul> <?php } }
function hocwp_term_meta_add_field($args = array()) { $callback = hocwp_get_value_by_key($args, 'callback'); if (!hocwp_callback_exists($callback)) { $callback = hocwp_get_value_by_key($args, 'field_callback'); } $field_args = hocwp_get_value_by_key($args, 'field_args'); $field_args = wp_parse_args($field_args, $args); $class = hocwp_get_value_by_key($args, 'class'); $name = hocwp_get_value_by_key($args, 'name'); $id = hocwp_get_value_by_key($args, 'id'); hocwp_transmit_id_and_name($id, $name); $tmp = hocwp_sanitize_html_class($name); hocwp_add_string_with_space_before($class, 'form-field term-' . $name . '-wrap hocwp'); ?> <div class="<?php echo $class; ?> "> <?php if (hocwp_callback_exists($callback)) { call_user_func($callback, $field_args); } else { _e('Please set a valid callback for this field', 'hocwp-theme'); } ?> </div> <?php }
public function widget($args, $instance) { $this->instance = $instance; $register = hocwp_get_value_by_key($instance, 'register', hocwp_get_value_by_key($this->args, 'register')); $button_text = hocwp_get_value_by_key($instance, 'button_text', hocwp_get_value_by_key($this->args, 'button_text')); $captcha = (bool) hocwp_get_value_by_key($instance, 'captcha', hocwp_get_value_by_key($this->args, 'captcha')); if ($captcha) { add_filter('hocwp_use_session', '__return_true'); } $description = hocwp_get_value_by_key($instance, 'description', hocwp_get_value_by_key($this->args, 'description')); $desc_position = hocwp_get_value_by_key($instance, 'desc_position', hocwp_get_value_by_key($this->args, 'desc_position')); $fields = $this->get_value_fields($instance); $all_fields = explode(',', $fields); hocwp_widget_before($args, $instance); ob_start(); ?> <form class="subscribe-form hocwp-subscribe-form" method="post" data-captcha="<?php echo hocwp_bool_to_int($captcha); ?> " data-register="<?php echo hocwp_bool_to_int($register); ?> "> <?php echo '<div class="messages"></div>'; if (!empty($description) && 'before' == $desc_position) { echo '<p class="description">' . $description . '</p>'; } foreach ($all_fields as $field_name) { $field = hocwp_get_value_by_key($this->args['fields'], $field_name); if (hocwp_array_has_value($field)) { $label = $this->get_value_field($instance, $field_name, 'label'); $placeholder = $this->get_value_field($instance, $field_name, 'placeholder'); $required = $this->get_value_field($instance, $field_name, 'required'); $class = hocwp_sanitize_html_class($field_name); $field_args = array('id' => $this->get_field_id('subscribe_' . $field_name), 'name' => $this->get_field_name('subscribe_' . $field_name), 'value' => '', 'label' => $label, 'placeholder' => $placeholder, 'required' => $required, 'class' => 'form-control input-' . $class, 'before' => '<div class="form-group field-' . $class . '">', 'after' => '</div>'); hocwp_field_input($field_args); } } if (!empty($description) && 'after' == $desc_position) { echo '<p class="description">' . $description . '</p>'; } if ($captcha) { $captcha_label = hocwp_get_value_by_key($instance, 'captcha_label', hocwp_get_value_by_key($this->args, 'captcha_label')); $captcha_placeholder = hocwp_get_value_by_key($instance, 'captcha_placeholder', hocwp_get_value_by_key($this->args, 'captcha_placeholder')); $field_args = array('id' => $this->get_field_id('captcha'), 'name' => $this->get_field_name('captcha'), 'input_width' => '100%', 'class' => 'form-control', 'label' => $captcha_label, 'placeholder' => $captcha_placeholder, 'before' => '<div class="form-group field-captcha">', 'after' => '</div>'); hocwp_field_captcha($field_args); } $field_args = array('type' => 'submit', 'name' => 'submit', 'value' => $button_text, 'class' => 'form-control', 'before' => '<div class="form-group field-submit">', 'after' => '</div>'); hocwp_field_input($field_args); hocwp_loading_image(array('name' => 'icon-loading-long.gif')); ?> </form> <?php $widget_html = ob_get_clean(); $widget_html = apply_filters('hocwp_widget_subscribe_html', $widget_html, $args, $instance, $this); echo $widget_html; hocwp_widget_after($args, $instance); }
function hocwp_show_ads($args = array()) { $ads = $args; $position = ''; if (!is_object($args)) { if (!is_array($args)) { $args = array('position' => $args); } $position = hocwp_get_value_by_key($args, 'position'); if (!empty($position)) { $random = (bool) hocwp_get_value_by_key($args, 'random'); $current_datetime = date(hocwp_get_date_format()); $current_datetime = strtotime($current_datetime); $query_args = array('post_type' => 'hocwp_ads', 'posts_per_page' => 1, 'meta_query' => array('relation' => 'AND', array('relation' => 'OR', array('key' => 'expire', 'compare' => 'NOT EXISTS'), array('key' => 'expire', 'value' => '', 'compare' => '='), array('key' => 'expire', 'value' => 0, 'type' => 'numeric'), array('key' => 'expire', 'value' => $current_datetime, 'type' => 'numeric', 'compare' => '>=')), array('key' => 'active', 'value' => 1, 'type' => 'numeric'))); if ($random) { $query_args['orderby'] = 'rand'; } $ads = hocwp_get_post_by_meta('position', $position, $query_args); if ($ads->have_posts()) { $posts = $ads->posts; $ads = array_shift($posts); } } } if (hocwp_is_post($ads) && 'hocwp_ads' == $ads->post_type) { $code = hocwp_get_post_meta('code', $ads->ID); if (empty($code)) { $image = hocwp_get_post_meta('image', $ads->ID); $image = hocwp_sanitize_media_value($image); $image = $image['url']; if (!empty($image)) { $img = new HOCWP_HTML('img'); $img->set_image_src($image); $url = hocwp_get_post_meta('url', $ads->ID); if (!empty($url)) { $a = new HOCWP_HTML('a'); $a->set_href($url); $a->set_text($img); $code = $a->build(); } else { $code = $img->build(); } } } if (!empty($code)) { $class = hocwp_get_value_by_key($args, 'class'); hocwp_add_string_with_space_before($class, 'hocwp-ads text-center ads'); if (!empty($position)) { hocwp_add_string_with_space_before($class, 'position-' . $position); $position = hocwp_sanitize_html_class($position); $class = hocwp_add_more_class($class, $position); } hocwp_add_string_with_space_before($class, $ads->post_name); $div = new HOCWP_HTML('div'); $div->set_class($class); $div->set_text($code); $html = $div->build(); $html = apply_filters('hocwp_ads_html', $html, $ads_or_args = $args); echo $html; } } }
public function widget($args, $instance) { $this->instance = $instance; $before_widget = hocwp_get_value_by_key($args, 'before_widget'); $taxonomy = $this->get_taxonomy_from_instance($instance); $taxonomies = array(); $widget_class = ''; foreach ($taxonomy as $tax) { $tax = hocwp_get_value_by_key($tax, 'value'); if (!empty($tax)) { $taxonomies[] = $tax; hocwp_add_string_with_space_before($widget_class, hocwp_sanitize_html_class($tax)); } } $before_widget = hocwp_add_class_to_string('', $before_widget, $widget_class); $args['before_widget'] = $before_widget; $in_current_post = (bool) hocwp_get_value_by_key($instance, 'in_current_post', hocwp_get_value_by_key($this->args, 'in_current_post')); if ($in_current_post && (!is_singular() || is_page())) { return; } if ($in_current_post) { $post_id = get_the_ID(); $current_post = get_post($post_id); $obj_taxs = get_object_taxonomies($current_post->post_type); $has_tax = false; foreach ($taxonomies as $tax) { foreach ($obj_taxs as $tax_name) { if ($tax == $tax_name) { $has_tax = true; break; } } } if (!$has_tax) { return; } $before_widget = hocwp_add_class_to_string('', $before_widget, 'in-current-post'); $args['before_widget'] = $before_widget; } $number = hocwp_get_value_by_key($instance, 'number', hocwp_get_value_by_key($this->args, 'number')); if (0 > $number) { $number = 0; } $thumbnail_size = hocwp_get_value_by_key($instance, 'thumbnail_size', hocwp_get_value_by_key($this->args, 'thumbnail_size')); $thumbnail_size = hocwp_sanitize_size($thumbnail_size); $full_width_item = hocwp_get_value_by_key($instance, 'full_width_item', hocwp_get_value_by_key($this->args, 'full_width_item')); $show_count = hocwp_get_value_by_key($instance, 'show_count', hocwp_get_value_by_key($this->args, 'show_count')); $hide_thumbnail = hocwp_get_value_by_key($instance, 'hide_thumbnail', hocwp_get_value_by_key($this->args, 'hide_thumbnail')); $only_thumbnail = hocwp_get_value_by_key($instance, 'only_thumbnail', hocwp_get_value_by_key($this->args, 'only_thumbnail')); $order = hocwp_get_value_by_key($instance, 'order', hocwp_get_value_by_key($this->args, 'order')); $orderby = hocwp_get_value_by_key($instance, 'orderby', hocwp_get_value_by_key($this->args, 'orderby')); $count_format = hocwp_get_value_by_key($instance, 'count_format', hocwp_get_value_by_key($this->args, 'count_format')); $different_name = (bool) hocwp_get_value_by_key($instance, 'different_name', hocwp_get_value_by_key($this->args, 'different_name')); $hide_empty = hocwp_get_value_by_key($instance, 'hide_empty', hocwp_get_value_by_key($this->args, 'hide_empty')); $only_parent = hocwp_get_value_by_key($instance, 'only_parent', hocwp_get_value_by_key($this->args, 'only_parent')); $child_of_current = hocwp_get_value_by_key($instance, 'child_of_current', hocwp_get_value_by_key($this->args, 'child_of_current')); $child_of_parent = hocwp_get_value_by_key($instance, 'child_of_parent', hocwp_get_value_by_key($this->args, 'child_of_parent')); $parent_as_title = hocwp_get_value_by_key($instance, 'parent_as_title', hocwp_get_value_by_key($this->args, 'parent_as_title')); if ($hide_thumbnail) { $only_thumbnail = false; } $defaults = array('order' => $order, 'orderby' => $orderby, 'number' => absint($number)); if (0 == $hide_empty || !(bool) $hide_empty) { $defaults['hide_empty'] = 0; } else { $defaults['hide_empty'] = 1; } if ($only_parent) { $defaults['parent'] = 0; } if ($in_current_post && is_singular()) { $terms = wp_get_post_terms(get_the_ID(), $taxonomies); } elseif (($child_of_current || $child_of_parent) && is_tax()) { $current_term = hocwp_term_get_current(); $tax_args = array('child_of' => $current_term->term_id); $tax_args = wp_parse_args($tax_args, $defaults); unset($tax_args['parent']); $terms = hocwp_get_terms($current_term->taxonomy, $tax_args); if ($child_of_parent) { if (!hocwp_array_has_value($terms) && hocwp_id_number_valid($current_term->parent)) { $parent = hocwp_term_get_top_most_parent($current_term); $tax_args['child_of'] = $parent->term_id; $terms = hocwp_get_terms($parent->taxonomy, $tax_args); } } } else { $terms = hocwp_get_terms($taxonomies, $defaults); } if (($in_current_post || $child_of_current) && !hocwp_array_has_value($terms)) { return; } if ($parent_as_title && is_tax()) { $current_term = hocwp_term_get_current(); if (hocwp_id_number_valid($current_term->parent)) { $parent = hocwp_term_get_top_most_parent($current_term); $instance['title'] = $parent->name; } elseif ($child_of_current) { $instance['title'] = $current_term->name; } } hocwp_widget_before($args, $instance); ob_start(); if (hocwp_array_has_value($terms)) { $count_terms = count($terms); $html = '<ul class="list-unstyled list-terms">'; $count = 0; foreach ($terms as $term) { $item_class = 'term-item'; hocwp_add_string_with_space_before($item_class, hocwp_sanitize_html_class('tax-' . $term->taxonomy)); if (!(bool) $hide_thumbnail) { hocwp_add_string_with_space_before($item_class, 'show-thumbnail'); } if ((bool) $only_thumbnail) { hocwp_add_string_with_space_before($item_class, 'only-thumbnail'); } $full_width = hocwp_widget_item_full_width_result($full_width_item, $count_terms, $count); if ($full_width) { hocwp_add_string_with_space_before($item_class, 'full-width'); } if ((bool) $show_count) { hocwp_add_string_with_space_before($item_class, 'show-count'); } else { hocwp_add_string_with_space_before($item_class, 'no-count'); } $html .= '<li class="' . $item_class . '">'; if (!(bool) $hide_thumbnail) { $html .= hocwp_term_get_thumbnail_html(array('term' => $term, 'width' => $thumbnail_size[0], $thumbnail_size[1], 'bfi_thumb' => false)); } if (!(bool) $only_thumbnail) { $term_name = $term->name; if ($different_name) { $term_name = hocwp_term_get_name($term); } $html .= '<a class="term-name" href="' . get_term_link($term) . '">' . $term_name . '</a>'; if ((bool) $show_count && !empty($count_format)) { $html .= ' <span class="count">' . str_replace('%TERM_COUNT%', $term->count, $count_format) . '</span>'; } } $html .= '</li>'; $count++; } $html .= '</ul>'; echo $html; } else { _e('Sorry, nothing found.', 'hocwp-theme'); } $widget_html = ob_get_clean(); $widget_html = apply_filters('hocwp_widget_term_html', $widget_html, $args, $instance, $this); echo $widget_html; hocwp_widget_after($args, $instance); }
public function sanitize_field_args(&$args) { $id = isset($args['id']) ? $args['id'] : ''; $name = isset($args['name']) ? $args['name'] : ''; hocwp_transmit_id_and_name($id, $name); $args['id'] = $id; $args['name'] = $name; if ($this->is_term_meta()) { } elseif ($this->is_menu_item_meta()) { $args['before'] = '<div class="field-' . hocwp_sanitize_html_class($name) . ' description description-wide">'; $args['after'] = '</div>'; } else { $args['before'] = '<div class="meta-row">'; $args['after'] = '</div>'; } return $args; }
function hocwp_setup_theme_widget_title($title, $instance = array(), $id_base = null) { if ('rss' != $id_base) { $title = hocwp_wrap_tag($title, 'span', hocwp_sanitize_html_class($title)); } return $title; }
function hocwp_setup_theme_woocommerce_product_tabs_callback($key, $tab) { $content = hocwp_get_post_meta($key, get_the_ID()); $content = trim($content); $title = hocwp_get_value_by_key($tab, 'title'); if (empty($content)) { $slug = hocwp_sanitize_html_class($key); $hocwp_product_tab = hocwp_get_post_by_slug($slug, 'hocwp_product_tab'); if (!hocwp_is_post($hocwp_product_tab)) { $hocwp_product_tab = hocwp_get_post_by_column('post_title', $title); } if (hocwp_is_post($hocwp_product_tab)) { $content = $hocwp_product_tab->post_content; $content = trim($content); } } if (!empty($content)) { if (!empty($title)) { echo hocwp_wrap_tag($title, 'h2', 'tab-title'); } echo '<div class="hocwp-product-info">'; $embed = new WP_Embed(); $content = $embed->run_shortcode($content); $content = $embed->autoembed($content); hocwp_the_custom_content($content); echo '</div>'; } }
function hocwp_theme_the_menu($args = array()) { if (!is_array($args)) { $args = array('theme_location' => $args); } $items_wrap = '<ul id="%1$s" class="%2$s">%3$s</ul>'; $theme_location = isset($args['theme_location']) ? $args['theme_location'] : 'primary'; $menu_id = isset($args['menu_id']) ? $args['menu_id'] : $theme_location . '_menu'; $menu_id = hocwp_sanitize_id($menu_id); $menu_class = isset($args['menu_class']) ? $args['menu_class'] : ''; hocwp_add_string_with_space_before($menu_class, 'hocwp-menu'); hocwp_add_string_with_space_before($menu_class, $theme_location); $nav_class = hocwp_get_value_by_key($args, 'nav_class'); hocwp_add_string_with_space_before($nav_class, 'navigation'); if ('primary' == $theme_location) { hocwp_add_string_with_space_before($nav_class, 'main-navigation'); } hocwp_add_string_with_space_before($nav_class, hocwp_sanitize_html_class($theme_location . '-navigation')); $superfish = isset($args['superfish']) ? $args['superfish'] : true; if ($superfish) { hocwp_add_string_with_space_before($menu_class, 'hocwp-superfish-menu'); $items_wrap = '<ul id="%1$s" class="sf-menu %2$s">%3$s</ul>'; } $button_text = isset($args['button_text']) ? $args['button_text'] : __('Menu', 'hocwp-theme'); hocwp_add_string_with_space_before($nav_class, 'clearfix'); ?> <nav id="<?php echo hocwp_sanitize_id($theme_location . '_navigation'); ?> " class="<?php echo $nav_class; ?> " data-button-text="<?php echo $button_text; ?> "<?php hocwp_html_tag_attributes('nav', 'site_navigation'); ?> > <?php $menu_args = array('theme_location' => $theme_location, 'menu_class' => $menu_class, 'menu_id' => $menu_id, 'items_wrap' => $items_wrap); $menu_args = wp_parse_args($args, $menu_args); wp_nav_menu($menu_args); ?> </nav><!-- #site-navigation --> <?php }
function hocwp_entry_summary($length = null, $class = '') { if (is_numeric($length) && 1 > $length) { return; } $class = hocwp_sanitize_html_class($class); hocwp_add_string_with_space_before($class, 'entry-summary'); $class = esc_attr($class); echo '<div class="' . $class . '" itemprop="text">'; if (is_numeric($length)) { echo wpautop(hocwp_substr(get_the_excerpt(), $length)); } else { the_excerpt(); } echo '</div>'; }
function hocwp_term_get_thumbnail_html($args = array()) { $thumb_url = hocwp_term_get_thumbnail_url($args); $result = ''; $term = hocwp_get_value_by_key($args, 'term'); if (!empty($thumb_url)) { $taxonomy = hocwp_get_value_by_key($args, 'taxonomy'); if (!is_a($term, 'WP_Term')) { $term_id = hocwp_get_value_by_key($args, 'term_id'); if (hocwp_id_number_valid($term_id) && !empty($taxonomy)) { $term = get_term($term_id, $taxonomy); } } if (is_a($term, 'WP_Term')) { $taxonomy = $term->taxonomy; $size = hocwp_sanitize_size($args); $link = hocwp_get_value_by_key($args, 'link', true); $show_name = hocwp_get_value_by_key($args, 'show_name'); $img = new HOCWP_HTML('img'); $img->set_image_src($thumb_url); if ($size[0] > 0) { $img->set_attribute('width', $size[0]); } if ($size[1] > 0) { $img->set_attribute('height', $size[1]); } $class = 'img-responsive wp-term-image'; $slug = $term->taxonomy; hocwp_add_string_with_space_before($class, hocwp_sanitize_html_class($slug) . '-thumb'); $img->set_class($class); $link_text = $img->build(); if ((bool) $show_name) { $link_text .= '<span class="term-name">' . $term->name . '</span>'; } $a = new HOCWP_HTML('a'); $a->set_class('term-link ' . hocwp_sanitize_html_class($taxonomy)); $a->set_text($link_text); $a->set_attribute('title', $term->name); $a->set_href(get_term_link($term)); if (!(bool) $link) { $result = $img->build(); } else { $result = $a->build(); } } } return apply_filters('hocwp_term_thumbnail_html', $result, $term); }