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();
    }
}
 public function widget($args, $instance)
 {
     $this->instance = $instance;
     $title_text = isset($instance['title']) ? $instance['title'] : '';
     $first_char = hocwp_get_first_char($title_text);
     if ('!' === $first_char) {
         $title_text = ltrim($title_text, '!');
     }
     $banner_image = isset($instance['banner_image']) ? $instance['banner_image'] : '';
     $banner_url = isset($instance['banner_url']) ? $instance['banner_url'] : '';
     $banner_image = hocwp_sanitize_media_value($banner_image);
     $banner_image = $banner_image['url'];
     if (!empty($banner_image)) {
         hocwp_widget_before($args, $instance);
         $img = new HOCWP_HTML('img');
         $img->set_image_src($banner_image);
         $img->set_image_alt($title_text);
         $img->set_class('hocwp-banner-image');
         $html = $img->build();
         if (!empty($banner_url)) {
             $a = new HOCWP_HTML('a');
             $a->set_class('hocwp-banner-link');
             $a->set_attribute('title', $title_text);
             $a->set_href($banner_url);
             $a->set_text($html);
             $nofollow = hocwp_get_value_by_key($instance, 'nofollow', hocwp_get_value_by_key($this->args, 'nofollow'));
             if ((bool) $nofollow) {
                 $a->set_attribute('rel', 'nofollow');
             }
             $html = $a->build();
         }
         $widget_html = apply_filters('hocwp_widget_banner_html', $html, $args, $instance, $this);
         echo $widget_html;
         hocwp_widget_after($args, $instance);
     }
 }
Beispiel #3
0
function hocwp_loading_image($args = array())
{
    $name = hocwp_get_value_by_key($args, 'name', 'icon-loading-circle-16.gif');
    $class = hocwp_get_value_by_key($args, 'class');
    hocwp_add_string_with_space_before($class, 'img-loading');
    $alt = hocwp_get_value_by_key($args, 'alt');
    $display = hocwp_get_value_by_key($args, 'display', 'none');
    $style = 'display: ' . $display;
    $img = new HOCWP_HTML('img');
    $image_url = hocwp_get_image_url($name);
    $img->set_image_alt($alt);
    $img->set_class($class);
    $img->set_attribute('style', $style);
    $img->set_image_src($image_url);
    $img->output();
}
Beispiel #4
0
function hocwp_notification_posts_ajax_callback()
{
    $lists = get_option('hocwp_notification_posts');
    $lists = hocwp_to_array($lists);
    if (hocwp_array_has_value($lists)) {
        $query = hocwp_get_post_by_meta('subscriber_verified', 1, array('post_type' => 'hocwp_subscriber'));
        if ($query->have_posts()) {
            $subscribers = $query->posts;
            $date = hocwp_get_current_date();
            $transient_name = hocwp_build_transient_name('hocwp_notification_posts_table_%s', $date);
            if (false === ($table_content = get_transient($transient_name))) {
                $table = new HOCWP_HTML('table');
                $table->set_attribute('align', 'center');
                $table->set_attribute('width', '100%');
                $table->set_attribute('cellspacing', 0);
                $table->set_attribute('border', 0);
                $table->set_attribute('cellpadding', 0);
                $table->set_attribute('bgcolor', '#ffffff');
                $table_content = '';
                foreach ($lists as $post_id) {
                    $obj = get_post($post_id);
                    $post_type = get_post_type_object($obj->post_type);
                    if (!is_object($post_type) || !$post_type->public) {
                        continue;
                    }
                    $notified = (bool) hocwp_get_post_meta('hocwp_notification_posts_sent', $post_id);
                    if ($notified) {
                        continue;
                    }
                    $inner_table = $table;
                    $tbody = new HOCWP_HTML('tbody');
                    $tr = new HOCWP_HTML('tr');
                    $td = new HOCWP_HTML('td');
                    $td->set_attribute('style', 'font-size:1px;line-height:1px');
                    $tr->set_text($td);
                    $tr2 = new HOCWP_HTML('tr');
                    $td2 = new HOCWP_HTML('td');
                    $td2->set_attribute('style', 'border-bottom:2px dotted #808285;padding-bottom:12px');
                    $a = new HOCWP_HTML('a');
                    $a->set_attribute('target', '_blank');
                    $a->set_href(get_permalink($obj));
                    $a->set_attribute('style', 'font-family: Helvetica,arial,sans-serif; font-size: 20px; color: rgb(22, 63, 144); text-align: left; font-weight: 500; text-decoration: none; line-height: 27px;');
                    $a->set_text(get_the_title($obj));
                    $p = new HOCWP_HTML('p');
                    $excerpt = get_the_excerpt($obj);
                    if (empty($excerpt)) {
                        $excerpt = $obj->post_content;
                        $excerpt = strip_tags($excerpt);
                        $excerpt = apply_filters('excerpt_length', $excerpt, 150);
                    }
                    $p->set_text($excerpt);
                    $td2->set_text($a->build() . $p->build());
                    $tr2->set_text($td2);
                    $tbody->set_text($tr->build() . $tr2->build());
                    $inner_table->set_text($tbody);
                    $table_content .= $inner_table->build();
                    update_post_meta($post_id, 'hocwp_notification_posts_sent', 1);
                }
                if (!empty($table_content)) {
                    $tbody = new HOCWP_HTML('tbody');
                    $tr = new HOCWP_HTML('tr');
                    $td = new HOCWP_HTML('td');
                    $td->set_text($table_content);
                    $tr->set_text($td);
                    $tbody->set_text($tr);
                    $table->set_text($tbody);
                    $table_content = $table->build();
                }
            }
            if (!empty($table_content)) {
                foreach ($subscribers as $subscriber) {
                    $email = hocwp_get_post_meta('subscriber_email', $subscriber->ID);
                    if (is_email($email)) {
                        $transient_name = 'hocwp_notification_posts_to_user_' . md5($email);
                        $transient_name = hocwp_build_transient_name($transient_name . '_%s', $table_content);
                        if (false === get_transient($transient_name)) {
                            $subject = '[' . get_bloginfo('name') . '] New content updated on ' . hocwp_get_current_date(hocwp_get_date_format());
                            $message = $table_content;
                            $message = hocwp_mail_unsubscribe_link_footer($message, $email);
                            $sent = hocwp_send_html_mail($email, $subject, $message);
                            if ($sent) {
                                set_transient($transient_name, 1, DAY_IN_SECONDS);
                            }
                        }
                    }
                }
            }
        }
    }
    exit;
}
 public function set_page_title_action($action, $url, $text)
 {
     $action = hocwp_sanitize($action, 'html_class');
     hocwp_add_string_with_space_before($action, 'page-title-action');
     $link = new HOCWP_HTML('a');
     $link->set_class($action);
     $link->set_attribute('href', $url);
     $link->set_text($text);
     $this->page_title_action = $link->build();
 }
Beispiel #6
0
function hocwp_post_thumbnail($args = array())
{
    $post_id = isset($args['post_id']) ? $args['post_id'] : '';
    if (empty($post_id)) {
        $post_id = get_the_ID();
    }
    if (post_password_required($post_id) || is_attachment()) {
        return;
    }
    $args['post_id'] = $post_id;
    $transient_name = hocwp_build_transient_name('hocwp_cache_post_thumbnail_%s', $args);
    if (false === ($html = get_transient($transient_name))) {
        $cache = hocwp_get_value_by_key($args, 'cache', HOUR_IN_SECONDS);
        $thumbnail_url = hocwp_get_value_by_key($args, 'thumbnail_url');
        if (empty($thumbnail_url)) {
            $large_size = hocwp_get_value_by_key($args, 'large_size');
            if ($large_size) {
                $thumbnail_url = get_post_meta($post_id, 'large_thumbnail', true);
                $thumbnail_url = hocwp_sanitize_media_value($thumbnail_url);
                $thumbnail_url = $thumbnail_url['url'];
                if (empty($thumbnail_url)) {
                    $thumbnail_url = hocwp_get_post_thumbnail_url($post_id);
                }
            } else {
                $thumbnail_url = hocwp_get_post_thumbnail_url($post_id);
            }
        }
        if (empty($thumbnail_url)) {
            return;
        }
        $bfi_thumb = isset($args['bfi_thumb']) ? $args['bfi_thumb'] : true;
        $bfi_thumb = apply_filters('hocwp_use_bfi_thumb', $bfi_thumb, $post_id);
        $size = hocwp_sanitize_size($args);
        $width = $size[0];
        $height = $size[1];
        $enlarge = apply_filters('hocwp_enlarge_post_thumbnail_on_mobile', false);
        if ($enlarge && wp_is_mobile()) {
            $ratio = 600 / $width;
            $ratio = round($ratio);
            if ($ratio > 1) {
                $width *= $ratio;
                $height *= $ratio;
            }
        }
        $original = $thumbnail_url;
        if ($bfi_thumb) {
            $params = isset($args['params']) ? $args['params'] : array();
            if (is_numeric($width) && $width > 0) {
                $params['width'] = $width;
            }
            if (is_numeric($height) && $height > 0) {
                $params['height'] = $height;
            }
            $bfi_url = apply_filters('hocwp_pre_bfi_thumb', '', $thumbnail_url, $params);
            if (empty($bfi_url)) {
                if ($width > 0 || $height > 0) {
                    $bfi_url = bfi_thumb($thumbnail_url, $params);
                }
            }
            if (!empty($bfi_url)) {
                $thumbnail_url = $bfi_url;
            }
        }
        $img = new HOCWP_HTML('img');
        if (is_numeric($width) && $width > 0) {
            $img->set_attribute('width', $size[0]);
        }
        if (is_numeric($height) && $height > 0) {
            $img->set_attribute('height', $size[1]);
        }
        $img->set_attribute('data-original', $original);
        $lazyload = hocwp_get_value_by_key($args, 'lazyload', false);
        $img->set_attribute('alt', get_the_title($post_id));
        $img->set_class('attachment-post-thumbnail wp-post-image img-responsive');
        $img->set_attribute('src', $thumbnail_url);
        $centered = (bool) hocwp_get_value_by_key($args, 'centered', false);
        if ($centered) {
            $img->add_class('centered');
        }
        $bk_img = '';
        if ((bool) $lazyload) {
            $img->set_wrap_tag('noscript');
            $bk_img = $img->build();
            $img->set_wrap_tag('');
            $loading_icon = hocwp_get_value_by_key($args, 'loading_icon');
            if (!hocwp_is_image($loading_icon)) {
                $loading_icon = hocwp_get_image_url('transparent.gif');
            }
            $img->set_image_src($loading_icon);
            $img->set_attribute('data-original', $thumbnail_url);
            $img->add_class('lazyload');
        }
        $only_image = hocwp_get_value_by_key($args, 'only_image');
        if ((bool) $only_image) {
            $html = $img->build();
            if ((bool) $lazyload) {
                $html = $bk_img;
            }
        } else {
            $before = hocwp_get_value_by_key($args, 'before');
            $after = hocwp_get_value_by_key($args, 'after');
            $permalink = hocwp_get_value_by_key($args, 'permalink', get_permalink($post_id));
            $loop = isset($args['loop']) ? $args['loop'] : true;
            $custom_html = isset($args['custom_html']) ? $args['custom_html'] : '';
            $icon_video = hocwp_get_value_by_key($args, 'icon_video');
            if (true === $icon_video) {
                $icon_video = '<i class="fa fa-play-circle-o" aria-hidden="true"></i>';
            }
            $fancybox = (bool) hocwp_get_value_by_key($args, 'fancybox');
            $a = new HOCWP_HTML('a');
            $a->set_href($permalink);
            if (!empty($icon_video) && is_string($icon_video) && empty($custom_html)) {
                $a->set_text($icon_video);
                $custom_html = $a->build();
            }
            $icon_image = hocwp_get_value_by_key($args, 'icon_image');
            if (true === $icon_image) {
                $icon_image = '<i class="fa fa-camera" aria-hidden="true"></i>';
            }
            if (!empty($icon_image) && is_string($icon_image) && empty($custom_html)) {
                $a->set_text($icon_image);
                $custom_html = $a->build();
            }
            $cover = hocwp_get_value_by_key($args, 'cover');
            $schema = '';
            if (current_theme_supports('hocwp-schema')) {
                ob_start();
                ?>
				<meta itemprop="url" content="<?php 
                echo $thumbnail_url;
                ?>
">
				<meta itemprop="width" content="<?php 
                echo $width;
                ?>
">
				<meta itemprop="height" content="<?php 
                echo $height;
                ?>
">
				<?php 
                $schema = ob_get_clean();
            }
            $html = $before;
            if (is_singular() && !$loop) {
                ob_start();
                ?>
				<div class="post-thumbnail entry-thumb"<?php 
                hocwp_html_tag_attributes('div', 'entry_thumb');
                ?>
>
					<?php 
                $img->output();
                if ((bool) $lazyload) {
                    echo $bk_img;
                }
                echo $custom_html;
                echo $schema;
                ?>
				</div>
				<?php 
                $html = ob_get_clean();
            } else {
                if (!empty($custom_html)) {
                    $html .= '<div class="thumbnail-wrap">';
                }
                $class = 'post-thumbnail-loop entry-thumb post-thumbnail';
                $atts = '';
                if ($fancybox) {
                    hocwp_add_string_with_space_before($class, 'fancybox');
                    $atts = ' data-fancybox-group="gallery"';
                    $atts .= ' rel="gallery"';
                    $permalink = $original;
                }
                ob_start();
                ?>
				<a class="<?php 
                echo $class;
                ?>
"<?php 
                echo $atts;
                ?>
 href="<?php 
                echo $permalink;
                ?>
"
				   aria-hidden="true"<?php 
                hocwp_html_tag_attributes('a', 'entry_thumb');
                ?>
>
					<?php 
                $img->output();
                if ((bool) $lazyload) {
                    echo $bk_img;
                }
                if ($cover) {
                    echo '<span class="cover"></span>';
                }
                echo $schema;
                ?>
				</a>
				<?php 
                $html .= ob_get_clean();
                $html .= $custom_html;
                if (!empty($custom_html)) {
                    $html .= '</div>';
                }
            }
            $html .= $after;
        }
        if (!empty($html)) {
            set_transient($transient_name, $html, $cache);
        }
    }
    echo $html;
}
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();
}
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">&hellip;</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_setup_theme_custom_head()
{
    $options = get_option('hocwp_theme_custom');
    $background_image = hocwp_get_value_by_key($options, 'background_image');
    $background_image = hocwp_get_media_option_url($background_image);
    if (hocwp_url_valid($background_image)) {
        $style = new HOCWP_HTML('style');
        $style->set_attribute('type', 'text/css');
        $elements = array('body.hocwp');
        $properties = array('background-image' => 'url("' . $background_image . '")', 'background-repeat' => 'no-repeat', 'background-color' => 'rgba(0,0,0,0)');
        $lazyload = hocwp_get_value_by_key($options, 'background_lazyload');
        if ((bool) $lazyload) {
            unset($properties['background-image']);
        }
        $background_repeat = hocwp_get_value_by_key($options, 'background_repeat');
        if ((bool) $background_repeat) {
            $properties['background-repeat'] = 'repeat';
        }
        $background_color = hocwp_get_value_by_key($options, 'background_color');
        if (hocwp_color_valid($background_color)) {
            $properties['background-color'] = $background_color;
        }
        $background_size = hocwp_get_value_by_key($options, 'background_size');
        if (!empty($background_size)) {
            $properties['background-size'] = $background_size;
        }
        $background_position = hocwp_get_value_by_key($options, 'background_position');
        if (!empty($background_position)) {
            $properties['background-position'] = $background_position;
        }
        $background_attachment = hocwp_get_value_by_key($options, 'background_attachment');
        if (!empty($background_attachment)) {
            $properties['background-attachment'] = $background_attachment;
        }
        $css = hocwp_build_css_rule($elements, $properties);
        $css = hocwp_minify_css($css);
        $style->set_text($css);
        if (!empty($css)) {
            $style->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 #11
0
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 woocommerce_quantity_input($args = array(), $product = null, $echo = true)
    {
        global $product;
        $defaults = array('input_name' => 'quantity', 'input_value' => '1', 'max_value' => apply_filters('woocommerce_quantity_input_max', '', $product), 'min_value' => apply_filters('woocommerce_quantity_input_min', '', $product), 'step' => apply_filters('woocommerce_quantity_input_step', 1, $product), 'style' => apply_filters('woocommerce_quantity_style', 'float:left; margin-right:10px;', $product), 'size' => apply_filters('woocommerce_quantity_input_size', 4, $product), 'label' => apply_filters('woocommerce_quantity_input_label', '', $product));
        $args = apply_filters('woocommerce_quantity_input_args', $args, $product);
        $args = apply_filters('hocwp_wc_quantity_input_args', $args, $product);
        $args = wp_parse_args($args, $defaults);
        $quantity_input = apply_filters('hocwp_wc_quantity_input_pre', '', $product, $args);
        if (empty($quantity_input)) {
            $input_name = $args['input_name'];
            $input_value = $args['input_value'];
            $label = $args['label'];
            $min = hocwp_get_value_by_key($args, 'min', 1);
            $max = hocwp_get_value_by_key($args, 'max', 20);
            $step = hocwp_get_value_by_key($args, 'step', 1);
            $size = hocwp_get_value_by_key($args, 'size', 4);
            $input = new HOCWP_HTML('input');
            $input->set_attribute('type', 'number');
            $input->set_attribute('size', $size);
            $input->set_class('input-text qty text input-number');
            $input->set_attribute('title', __('Qty', 'hocwp-theme'));
            $input->set_attribute('value', $input_value);
            $input->set_attribute('name', $input_name);
            $input->set_attribute('max', $max);
            $input->set_attribute('min', $min);
            $input->set_attribute('step', $step);
            $container_class = 'quantity hocwp-custom-quantity';
            if (!empty($label)) {
                hocwp_add_string_with_space_before($container_class, 'with-label has-label');
            }
            ob_start();
            ?>
			<div class="<?php 
            echo $container_class;
            ?>
">
				<?php 
            if (!empty($label)) {
                $lb = new HOCWP_HTML('label');
                $lb->set_text($label);
                $lb->output();
            }
            ?>
				<input type="button" class="minus qty-control btn-down number-down" value="-">
				<?php 
            $input->output();
            ?>
				<input type="button" class="plus qty-control btn-up number-up" value="+">
			</div>
			<?php 
            $quantity_input = ob_get_clean();
        }
        $quantity_input = apply_filters('hocwp_wc_quantity_input', $quantity_input, $product, $args);
        if ($echo) {
            echo $quantity_input;
        }
        return $quantity_input;
    }
Beispiel #13
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 #15
0
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 
    }
}
Beispiel #16
0
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);
}