public function widget($args, $instance)
 {
     $this->instance = $instance;
     $order = hocwp_get_value_by_key($instance, 'order', hocwp_get_value_by_key($this->args, 'order'));
     $orders = explode(',', $order);
     $orders = array_map('trim', $orders);
     $orders = hocwp_sanitize_array($orders);
     $option_names = $this->args['option_names'];
     $options = hocwp_get_option('option_social');
     $icons = $this->args['icons'];
     $description = hocwp_get_value_by_key($instance, 'description');
     hocwp_widget_before($args, $instance);
     ob_start();
     if (!empty($description)) {
         echo hocwp_wrap_tag(wpautop($description), 'div', 'description');
     }
     if (hocwp_array_has_value($orders)) {
         foreach ($orders as $social) {
             $option_name = hocwp_get_value_by_key($option_names, $social);
             $item = hocwp_get_value_by_key($options, $option_name);
             if (!empty($item)) {
                 $icon = '<i class="fa ' . $icons[$social] . '"></i>';
                 $a = new HOCWP_HTML('a');
                 $a->set_href($item);
                 $a->set_class('social-item link-' . $social);
                 $a->set_text($icon);
                 $a->output();
             }
         }
     }
     $widget_html = ob_get_clean();
     $widget_html = apply_filters('hocwp_widget_social_html', $widget_html, $args, $instance, $this);
     echo $widget_html;
     hocwp_widget_after($args, $instance);
 }
function hocwp_plugin_load_custom_css()
{
    $option = get_option('hocwp_plugin_custom_css');
    $css = hocwp_get_value_by_key($option, 'code');
    if (!empty($css)) {
        $css = hocwp_minify_css($css);
        $style = new HOCWP_HTML('style');
        $style->set_attribute('type', 'text/css');
        $style->set_text($css);
        $style->output();
    }
}
Beispiel #3
0
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>';
        }
    }
}
Beispiel #4
0
function hocwp_facebook_comment($args = array())
{
    $args = apply_filters('hocwp_facebook_comment_args', $args);
    $colorscheme = isset($args['colorscheme']) ? $args['colorscheme'] : 'light';
    $colorscheme = apply_filters('hocwp_facebook_comment_colorscheme', $colorscheme, $args);
    $href = isset($args['href']) ? $args['href'] : '';
    if (empty($href)) {
        if (is_single() || is_page() || is_singular()) {
            $href = get_the_permalink();
        }
    }
    if (empty($href)) {
        $href = $this->get_current_url();
    }
    $href = apply_filters('hocwp_facebook_comment_href', $href, $args);
    $mobile = isset($args['mobile']) ? $args['mobile'] : '';
    $num_posts = isset($args['num_posts']) ? $args['num_posts'] : 10;
    $num_posts = apply_filters('hocwp_facebook_comment_num_posts', $num_posts, $args);
    $order_by = isset($args['order_by']) ? $args['order_by'] : 'social';
    $width = isset($args['width']) ? $args['width'] : '100%';
    $width = apply_filters('hocwp_facebook_comment_width', $width, $args);
    $loading_text = hocwp_get_value_by_key($args, 'loading_text', __('Loading...', 'hocwp-theme'));
    $div = new HOCWP_HTML('div');
    $div->set_class('fb-comments');
    $atts = array('data-colorscheme' => $colorscheme, 'data-href' => $href, 'data-mobile' => $mobile, 'data-numposts' => $num_posts, 'data-order-by' => $order_by, 'data-width' => $width);
    $atts = apply_filters('hocwp_facebook_comment_attributes', $atts, $args);
    $div->set_attribute_array($atts);
    $div->set_text($loading_text);
    $div->output();
}
 public function section_description($text)
 {
     $p = new HOCWP_HTML('p');
     $p->set_text($text);
     $p->output();
 }
Beispiel #6
0
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_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 
    }
}
function hocwp_icon_circle_ajax($post_id, $meta_key)
{
    $div = new HOCWP_HTML('div');
    $div->set_attribute('style', 'text-align: center');
    $div->set_class('hocwp-switcher-ajax');
    $span = new HOCWP_HTML('span');
    $circle_class = 'icon-circle';
    $result = get_post_meta($post_id, $meta_key, true);
    if (1 == $result) {
        $circle_class .= ' icon-circle-success';
    }
    $span->set_attribute('data-id', $post_id);
    $span->set_attribute('data-value', $result);
    $span->set_attribute('data-key', $meta_key);
    $span->set_class($circle_class);
    $div->set_text($span->build());
    $div->output();
}
function hocwp_theme_post_column_content_partner($column, $post_id)
{
    $post = get_post($post_id);
    if ('partner' == $post->post_type) {
        if ('url' == $column) {
            echo hocwp_get_post_meta($column, $post_id);
        } elseif ('thumbnail' == $column) {
            $thumbnail = hocwp_get_post_meta($column, $post_id);
            $thumbnail = hocwp_sanitize_media_value($thumbnail);
            $thumbnail = $thumbnail['url'];
            if (!empty($thumbnail)) {
                $img = new HOCWP_HTML('img');
                $img->set_image_src($thumbnail);
                $img->output();
            }
        }
    }
}
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_setup_theme_more_user_profile($user)
{
    $user_id = $user->ID;
    ?>
	<h3><?php 
    _e('Social Accounts', 'hocwp-theme');
    ?>
</h3>
	<table class="form-table">
		<tr>
			<th><label for="facebook">Facebook</label></th>
			<td>
				<?php 
    $facebook = get_the_author_meta('facebook', $user_id);
    $input = new HOCWP_HTML('input');
    $input->set_attribute('name', 'facebook');
    if (empty($facebook)) {
        $input->set_attribute('type', 'button');
        $input->set_text(__('Connect with Facebook account', 'hocwp-theme'));
        $input->set_class('button button-secondary hide-if-no-js hocwp-connect-facebook facebook');
        $input->set_attribute('onclick', 'hocwp_facebook_login();');
    } else {
        $facebook_data = get_the_author_meta('facebook_data', $user_id);
        $avatar = hocwp_get_value_by_key($facebook_data, array('picture', 'data', 'url'));
        $email = hocwp_get_value_by_key($facebook_data, 'email');
        if (!empty($avatar)) {
            $img = new HOCWP_HTML('img');
            $img->set_image_alt('');
            $img->set_image_src($avatar);
        }
        $input->set_attribute('type', 'text');
        $input->set_attribute('readonly', 'readonly');
        $input->set_attribute('value', $facebook . ' - ' . $email);
        $input->set_class('regular-text hocwp-disconnect-social facebook');
        $input->set_attribute('data-user-id', $user_id);
        $input->set_attribute('data-social', 'facebook');
    }
    if (empty($facebook) && 'profile.php' == $GLOBALS['pagenow']) {
        $input->output();
        if (empty($facebook)) {
            hocwp_facebook_login_script(array('connect' => true));
        }
    } else {
        if (!empty($facebook)) {
            $input->output();
        } else {
            _e('You can only connect to social account on profile page.', 'hocwp-theme');
        }
    }
    ?>
			</td>
		</tr>
		<tr>
			<th><label for="google">Google</label></th>
			<td>
				<?php 
    $social = 'google';
    $social_id = get_the_author_meta($social, $user_id);
    $input = new HOCWP_HTML('input');
    $input->set_attribute('name', $social);
    if (empty($social_id)) {
        $input->set_attribute('type', 'button');
        $input->set_text(__('Connect with Google account', 'hocwp-theme'));
        $input->set_class('button button-secondary hide-if-no-js hocwp-connect-' . $social . ' ' . $social);
        $input->set_attribute('onclick', 'hocwp_google_login();');
    } else {
        $facebook_data = get_the_author_meta($social . '_data', $user_id);
        $avatar = hocwp_get_value_by_key($facebook_data, array('picture', 'data', 'url'));
        $email = hocwp_get_value_by_key($facebook_data, array('emails', 0, 'value'));
        if (!empty($avatar)) {
            $img = new HOCWP_HTML('img');
            $img->set_image_alt('');
            $img->set_image_src($avatar);
        }
        $input->set_attribute('type', 'text');
        $input->set_attribute('readonly', 'readonly');
        $input->set_attribute('value', $social_id . ' - ' . $email);
        $input->set_class('regular-text hocwp-disconnect-social ' . $social);
        $input->set_attribute('data-user-id', $user_id);
        $input->set_attribute('data-social', $social);
    }
    if (empty($social_id) && 'profile.php' == $GLOBALS['pagenow']) {
        $input->output();
        if (empty($social_id)) {
            hocwp_google_login_script(array('connect' => true));
        }
    } else {
        if (!empty($social_id)) {
            $input->output();
        } else {
            _e('You can only connect to social account on profile page.', 'hocwp-theme');
        }
    }
    ?>
			</td>
		</tr>
	</table>
	<?php 
}
Beispiel #12
0
function hocwp_inline_script($code)
{
    $script = new HOCWP_HTML('script');
    $script->set_attribute('type', 'text/javascript');
    $script->set_text($code);
    $script->output();
}
function hocwp_field_select($args = array())
{
    $args = hocwp_field_sanitize_args($args);
    $id = isset($args['id']) ? $args['id'] : '';
    $name = isset($args['name']) ? $args['name'] : '';
    $list_options = isset($args['list_options']) ? $args['list_options'] : array();
    $options = isset($args['options']) ? $args['options'] : array();
    if (!hocwp_array_has_value($options)) {
        $options = hocwp_get_value_by_key($args, array('field_args', 'options'));
    }
    $load_item = isset($args['load_item']) ? $args['load_item'] : true;
    $value = isset($args['value']) ? $args['value'] : '';
    $field_class = isset($args['field_class']) ? $args['field_class'] : 'widefat';
    if (!is_array($options) || count($options) < 1) {
        $options = $list_options;
    }
    $all_option = isset($args['all_option']) ? $args['all_option'] : '';
    $autocomplete = isset($args['autocomplete']) ? $args['autocomplete'] : false;
    if (!$autocomplete) {
        $autocomplete = 'off';
    }
    $select_option = isset($args['default_option']) ? $args['default_option'] : '';
    if ($load_item && empty($all_option)) {
        foreach ($options as $key => $text) {
            $select_option .= hocwp_field_get_option(array('value' => $key, 'text' => $text, 'selected' => $value));
        }
    } else {
        $select_option .= $all_option;
    }
    if (!$load_item) {
        $custom_options = isset($args['custom_options']) ? $args['custom_options'] : '';
        $select_option .= $custom_options;
    }
    hocwp_field_before($args);
    $html = new HOCWP_HTML('select');
    $attributes = isset($args['attributes']) ? hocwp_sanitize_array($args['attributes']) : array();
    $atts = array('id' => hocwp_sanitize_id($id), 'name' => $name, 'class' => $field_class, 'autocomplete' => $autocomplete, 'text' => $select_option);
    $html->set_attribute_array($atts);
    foreach ($attributes as $key => $value) {
        $html->set_attribute($key, $value);
    }
    $html->output();
    hocwp_field_after($args);
}
Beispiel #14
0
function hocwp_lostpassword_form($args = array())
{
    $defaults = hocwp_account_form_default_args();
    $args = wp_parse_args($args, $defaults);
    $data = hocwp_execute_lostpassword();
    $user_login = $data['user_login'];
    $error = $data['error'];
    $message = $data['message'];
    $redirect_to = hocwp_get_value_by_key($args, 'redirect_to', hocwp_get_method_value('redirect_to', 'get'));
    $logo = hocwp_get_value_by_key($args, 'logo', hocwp_get_login_logo_url());
    ?>
	<div class="hocwp-login-box module">
		<div class="module-header text-center">
			<?php 
    if (!empty($logo)) {
        $a = new HOCWP_HTML('a');
        $a->set_href(home_url('/'));
        $a->set_class('logo');
        $img = new HOCWP_HTML('img');
        $img->set_image_alt('');
        $img->set_image_src($logo);
        $a->set_text($img->build());
        $a->output();
    }
    $slogan = new HOCWP_HTML('p');
    $slogan->set_class('slogan');
    $slogan->set_text(sprintf($args['slogan'], hocwp_get_root_domain_name(home_url('/'))));
    $slogan->output();
    if (isset($_POST['submit']) || isset($_POST['wp-submit'])) {
        if (isset($_REQUEST['error']) || $error) {
            $message = hocwp_build_message($message, 'danger');
            echo $message;
        } else {
            if (!empty($message) && !$error || isset($_POST['submit']) && !empty($message)) {
                $message = hocwp_build_message($message, 'success');
                echo $message;
            }
        }
    }
    ?>
		</div>
		<div class="module-body">
			<h4 class="form-title"><?php 
    _e('Reset password', 'hocwp-theme');
    ?>
</h4>

			<form name="lostpasswordform" id="lostpasswordform" action="<?php 
    echo esc_url(wp_lostpassword_url());
    ?>
"
			      method="post">
				<p>
					<label><?php 
    echo hocwp_get_value_by_key($args, 'label_username', __('Username or Email', 'hocwp-theme'));
    ?>
						<br>
						<input type="text" size="20" value="<?php 
    echo esc_attr($user_login);
    ?>
" class="input"
						       id="user_login" name="user_login"></label>
				</p>
				<input type="hidden" name="action" value="lostpassword">
				<input type="hidden" name="redirect_to" value="<?php 
    echo $redirect_to;
    ?>
">

				<p class="submit">
					<input type="submit" name="wp-submit" id="wp-submit" class="button-primary"
					       value="Get New Password" tabindex="100"></p>
			</form>
		</div>
		<div class="module-footer">
			<div class="text-center">
				<p class="form-nav">
					<a href="<?php 
    echo esc_url(wp_login_url());
    ?>
"><?php 
    echo hocwp_get_value_by_key($args, 'label_log_in', __('Login', 'hocwp-theme'));
    ?>
</a>
					<span class="sep">|</span>
					<a href="<?php 
    echo esc_url(wp_lostpassword_url());
    ?>
"
					   title="<?php 
    echo $args['title_lostpassword_link'];
    ?>
"><?php 
    echo $args['text_lostpassword_link'];
    ?>
</a>
				</p>
			</div>
		</div>
	</div>
	<?php 
}
Beispiel #15
0
function hocwp_the_social_list($args = array())
{
    $option_socials = hocwp_option_defaults();
    $option_socials = $option_socials['social'];
    $order = hocwp_get_value_by_key($args, 'order', hocwp_get_value_by_key($option_socials, 'order'));
    $orders = explode(',', $order);
    $orders = array_map('trim', $orders);
    $orders = hocwp_sanitize_array($orders);
    $option_names = $option_socials['option_names'];
    $options = hocwp_get_option('option_social');
    $icons = $option_socials['icons'];
    $list = (bool) hocwp_get_value_by_key($args, 'list');
    if (hocwp_array_has_value($orders)) {
        if ($list) {
            echo '<ul class="list-socials list-unstyled list-inline">';
            foreach ($orders as $social) {
                $option_name = hocwp_get_value_by_key($option_names, $social);
                $item = hocwp_get_value_by_key($options, $option_name);
                if (!empty($item)) {
                    $icon = '<i class="fa ' . $icons[$social] . '"></i>';
                    $a = new HOCWP_HTML('a');
                    $a->set_href($item);
                    $a->set_class('social-item link-' . $social);
                    $a->set_text($icon);
                    $li = new HOCWP_HTML('li');
                    $li->set_text($a);
                    $li->output();
                }
            }
            echo '</ul>';
        } else {
            foreach ($orders as $social) {
                $option_name = hocwp_get_value_by_key($option_names, $social);
                $item = hocwp_get_value_by_key($options, $option_name);
                if (!empty($item)) {
                    $icon = '<i class="fa ' . $icons[$social] . '"></i>';
                    $a = new HOCWP_HTML('a');
                    $a->set_href($item);
                    $a->set_class('social-item link-' . $social);
                    $a->set_text($icon);
                    $a->output();
                }
            }
        }
    }
}
function hocwp_theme_translation_comments_list_callback($comment, $args, $depth)
{
    $GLOBALS['comment'] = $comment;
    $comment_id = $comment->comment_ID;
    $style = isset($args['style']) ? $args['style'] : 'ol';
    $avatar_size = isset($args['avatar_size']) ? absint($args['avatar_size']) : 64;
    $avatar_size = apply_filters('hocwp_comment_avatar_size', $avatar_size);
    $max_depth = isset($args['max_depth']) ? absint($args['max_depth']) : '';
    $comment_permalink = get_comment_link($comment);
    if ('div' == $style) {
        $tag = 'div';
        $add_below = 'comment';
    } else {
        $tag = 'li';
        $add_below = 'div-comment';
    }
    $comment_date = get_comment_date('Y-m-d H:i:s', $comment_id);
    $comment_author = '<div class="comment-author vcard">' . get_avatar($comment, $avatar_size) . '<b class="fn">' . get_comment_author_link() . '</b> <span class="says">nói:</span></div>';
    $comment_metadata = '<div class="comment-metadata"><a href="' . $comment_permalink . '"><time datetime="' . get_comment_time('c') . '">' . hocwp_human_time_diff_to_now($comment_date) . ' ' . 'trước' . '</time></a> <a class="comment-edit-link" href="' . get_edit_comment_link($comment_id) . '">(' . 'Sửa' . ')</a></div>';
    if ($comment->comment_approved == '0') {
        $comment_metadata .= '<p class="comment-awaiting-moderation">' . 'Bình luận của bạn đang được chờ để xét duyệt.' . '</p>';
    }
    $footer = new HOCWP_HTML('footer');
    $footer->set_class('comment-meta');
    $footer->set_text($comment_author . $comment_metadata);
    $comment_text = get_comment_text($comment_id);
    $comment_text = apply_filters('comment_text', $comment_text, $comment);
    $comment_content = '<div class="comment-content">' . $comment_text . '</div>';
    $reply = '<div class="reply comment-tools">';
    $reply .= get_comment_reply_link(array_merge($args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $max_depth)));
    $comment_tools_enabled = apply_filters('hocwp_comment_tools_enabled', true);
    if ($comment_tools_enabled) {
        $class = 'comment-like comment-likes';
        $session_comment_liked_key = 'comment_' . $comment_id . '_likes';
        $liked = intval(isset($_SESSION[$session_comment_liked_key]) ? $_SESSION[$session_comment_liked_key] : '');
        if ($liked == 1) {
            hocwp_add_string_with_space_before($class, 'disabled');
        }
        $a = new HOCWP_HTML('a');
        $a->set_class($class);
        $a->set_attribute('href', 'javascript:;');
        $a->set_attribute('data-session-likes-key', $session_comment_liked_key);
        $likes = hocwp_get_comment_likes($comment_id);
        $a->set_attribute('data-likes', $likes);
        $a->set_text('<span class="text">' . 'Thích' . '</span> <i class="fa fa-thumbs-o-up"></i><span class="sep-dot">.</span> <span class="count">' . $likes . '</span>');
        $reply .= $a->build();
        $a->set_class('comment-report');
        $a->remove_attribute('data-session-liked-key');
        $a->set_text('Báo cáo vi phạm' . '<i class="fa fa-flag"></i>');
        $reply .= $a->build();
        $a->set_class('comment-share');
        $share_text = '<span class="text">' . 'Chia sẻ' . '<i class="fa fa-angle-down"></i></span>';
        $share_text .= '<span class="list-share">';
        $share_text .= '<i class="fa fa-facebook facebook" data-url="' . hocwp_get_social_share_url(array('social_name' => 'facebook', 'permalink' => $comment_permalink)) . '"></i>';
        $share_text .= '<i class="fa fa-google-plus google" data-url="' . hocwp_get_social_share_url(array('social_name' => 'googleplus', 'permalink' => $comment_permalink)) . '"></i>';
        $share_text .= '<i class="fa fa-twitter twitter" data-url="' . hocwp_get_social_share_url(array('social_name' => 'twitter', 'permalink' => $comment_permalink)) . '"></i>';
        $share_text .= '</span>';
        $a->set_text($share_text);
        $reply .= $a->build();
    }
    $reply .= '</div>';
    $article = new HOCWP_HTML('article');
    $article->set_attribute('id', 'div-comment-' . $comment_id);
    $article->set_class('comment-body');
    $article_text = $footer->build();
    $article_text .= $comment_content;
    $article_text .= $reply;
    $article->set_text($article_text);
    $html = new HOCWP_HTML($tag);
    $comment_class = get_comment_class(empty($args['has_children']) ? '' : 'parent');
    $comment_class = implode(' ', $comment_class);
    $html_atts = array('class' => $comment_class, 'id' => 'comment-' . $comment_id, 'data-comment-id' => $comment_id);
    $html->set_attribute_array($html_atts);
    $html->set_text($article->build());
    $html->set_close(false);
    $html->output();
}
    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);
    }
Beispiel #18
0
function hocwp_term_icon_html($term_id, $default = '')
{
    $icon = hocwp_get_term_icon($term_id);
    $icon = hocwp_sanitize_media_value($icon);
    $icon = $icon['url'];
    if (empty($icon)) {
        $icon = $default;
    }
    if (hocwp_string_contain($icon, 'fa') || hocwp_string_contain($icon, '</i>')) {
        echo $icon;
    } else {
        if (!empty($icon)) {
            $img = new HOCWP_HTML('img');
            $img->set_image_src($icon);
            $img->output();
        }
    }
}