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_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>'; } } }
function hocwp_post_link_only(WP_Post $post, $list = false) { if (hocwp_is_post($post)) { $a = new HOCWP_HTML('a'); $a->set_href(get_permalink($post)); $a->set_text($post->post_title); $a->add_class('post-link'); $a->add_class('link-only'); if ($list) { $li = new HOCWP_HTML('li'); $li->set_class(get_post_class('', $post->ID)); $li->set_text($a); $li->output(); } else { $a->output(); } } }
function hocwp_loop_pagination_item($args = array()) { $defaults = hocwp_pagination_defaults(); // The number of page links to show before and after the current page. $range = hocwp_get_value_by_key($args, 'range', hocwp_get_value_by_key($defaults, 'range')); // The number of page links to show at beginning and end of pagination. $anchor = hocwp_get_value_by_key($args, 'anchor', hocwp_get_value_by_key($defaults, 'anchor')); // The minimum number of page links before ellipsis shows. $gap = hocwp_get_value_by_key($args, 'gap', hocwp_get_value_by_key($defaults, 'gap')); $hellip = hocwp_get_value_by_key($args, 'hellip', hocwp_get_value_by_key($defaults, 'hellip')); $show_max_page = hocwp_get_value_by_key($args, 'show_max_page', hocwp_get_value_by_key($defaults, 'show_max_page')); $min_page = hocwp_get_value_by_key($args, 'min_page', hocwp_get_value_by_key($defaults, 'min_page')); $current_page = isset($args['current_page']) ? $args['current_page'] : 1; $total_page = isset($args['total_page']) ? $args['total_page'] : 1; $current_item_link = hocwp_get_value_by_key($args, 'current_item_link', hocwp_get_value_by_key($defaults, 'current_item_link')); $request = isset($args['request']) ? $args['request'] : hocwp_get_request(); $hidden_button = '<span class="item hidden-item">…</span>'; if (!(bool) $hellip) { $hidden_button = ''; } $result = ''; $hidden_before = false; $hidden_after = false; $before_current = $current_page - $range; $after_current = $current_page + $range; for ($i = 1; $i <= $total_page; $i++) { if (!(bool) $show_max_page) { if ($i == $total_page && $current_page < $total_page - 2) { continue; } } if ($current_page == $i) { if ($current_item_link) { $link_href = hocwp_get_pagenum_link(array('pagenum' => $i, 'request' => $request)); $result .= '<a class="item link-item current-item" href="' . $link_href . '" data-paged="' . $i . '">' . $i . '</a>'; } else { $ajax = (bool) hocwp_get_value_by_key($args, 'ajax'); $current_item = new HOCWP_HTML('span'); if ($ajax) { $current_item = new HOCWP_HTML('a'); $current_item->add_class('link-item'); $current_item->set_attribute('data-paged', $i); } $current_item->add_class('item current-item'); $current_item->set_text($i); $result .= $current_item->build(); } } else { $count_hidden_button_before = $before_current - ($anchor + 1); $count_hidden_button_after = $total_page - ($after_current + 1); $show_hidden_button_before = $i < $before_current && !$hidden_before && $count_hidden_button_before >= $gap ? true : false; $show_hidden_button_after = $i > $after_current && !$hidden_after && $count_hidden_button_after >= $gap ? true : false; if (1 == $i || $total_page == $i || $i <= $after_current && $i >= $before_current || $i <= $min_page && $current_page < 2) { $link_href = hocwp_get_pagenum_link(array('pagenum' => $i, 'request' => $request)); $result .= '<a class="item link-item" href="' . $link_href . '" data-paged="' . $i . '">' . $i . '</a>'; } else { if ($show_hidden_button_before && $current_page > 1) { $result .= $hidden_button; $hidden_before = true; $i = $before_current - 1; } elseif ($i < $before_current) { $link_href = hocwp_get_pagenum_link(array('pagenum' => $i, 'request' => $request)); $result .= '<a class="item link-item" href="' . $link_href . '" data-paged="' . $i . '">' . $i . '</a>'; } elseif ($show_hidden_button_after) { $result .= $hidden_button; $hidden_after = true; $i = $total_page - 1; } else { $link_href = hocwp_get_pagenum_link(array('pagenum' => $i, 'request' => $request)); $result .= '<a class="item link-item" href="' . $link_href . '" data-paged="' . $i . '">' . $i . '</a>'; } } } } return $result; }
function hocwp_wc_review_order_after_submit() { $url = hocwp_wc_get_cart_url(); $button = new HOCWP_HTML('a'); $button->set_href($url); $button->set_text(__('Back to cart page', 'hocwp-theme')); $button->add_class('btn navigation-link pull-right'); $button->output(); }
function hocwp_post_gallery($args = array()) { $galleries = hocwp_get_value_by_key($args, 'galleries'); $id = hocwp_get_value_by_key($args, 'id'); $class = hocwp_get_value_by_key($args, 'class'); hocwp_add_string_with_space_before($class, 'post-gallery module'); if (!empty($id)) { $id = ' id="' . $id . '"'; } $title = hocwp_get_value_by_key($args, 'title'); if (!hocwp_array_has_value($galleries)) { if (is_string($args)) { $galleries = hocwp_get_all_image_from_string($args); } elseif (is_string($galleries) && !empty($galleries)) { $galleries = hocwp_get_all_image_from_string($galleries); } else { $galleries = $args; } } if (hocwp_array_has_value($galleries)) { ?> <div<?php echo $id; ?> class="<?php echo $class; ?> "> <?php if (!empty($title)) { ?> <div class="module-header"> <h4><?php echo $title; ?> </h4> </div> <?php } ?> <div class="module-body"> <div class="galleries"> <ul class="gallery hocwp-gallery list-unstyled cS-hidden clearfix row"> <?php $column = hocwp_get_value_by_key($args, 'column'); if (!hocwp_is_positive_number($column)) { $column = 2; } $pager = ''; $count = 0; foreach ($galleries as $img) { $src = hocwp_get_first_image_source($img); if (!hocwp_is_image($src)) { continue; } $li = new HOCWP_HTML('li'); $li->set_text($img); $li->set_attribute('data-thumb', $src); $li->add_class('col-xs-' . $column); $li->output(); } ?> </ul> </div> </div> </div> <?php } }