public function end_el(&$output, $item, $depth = 0, $args = array())
 {
     $html = apply_filters('hocwp_menu_end_el_html', '', $item, $depth, $args);
     hocwp_add_string_with_space_before($html, "</li>\n");
     //$html = apply_filters( 'hocwp_menu_end_el_html_after', $html, $item, $depth, $args );
     $output .= $html;
 }
Ejemplo n.º 2
0
function hocwp_comment_form_default_fields($fields)
{
    $commenter = wp_get_current_commenter();
    $user = wp_get_current_user();
    $user_identity = $user->exists() ? $user->display_name : '';
    $format = current_theme_supports('html5', 'comment-form') ? 'html5' : 'xhtml';
    $format = apply_filters('hocwp_comment_form_format', $format);
    $req = get_option('require_name_email');
    $aria_req = $req ? "aria-required='true'" : '';
    $html_req = $req ? "required='required'" : '';
    $required_html = '';
    hocwp_add_string_with_space_before($required_html, $aria_req);
    hocwp_add_string_with_space_before($required_html, $html_req);
    $html5 = 'html5' === $format;
    $fields = array('author' => '<p class="comment-form-author">' . '<label for="author">' . __('Name', 'hocwp-theme') . ($req ? ' <span class="required">*</span>' : '') . '</label> ' . '<input id="author" name="author" type="text" value="' . esc_attr($commenter['comment_author']) . '" size="30" ' . $required_html . ' /></p>', 'email' => '<p class="comment-form-email"><label for="email">' . __('Email', 'hocwp-theme') . ($req ? ' <span class="required">*</span>' : '') . '</label> ' . '<input id="email" name="email" ' . ($html5 ? 'type="email"' : 'type="text"') . ' value="' . esc_attr($commenter['comment_author_email']) . '" size="30" aria-describedby="email-notes" ' . $required_html . ' /></p>', 'url' => '<p class="comment-form-url"><label for="url">' . __('Website', 'hocwp-theme') . '</label> ' . '<input id="url" name="url" ' . ($html5 ? 'type="url"' : 'type="text"') . ' value="' . esc_attr($commenter['comment_author_url']) . '" size="30" /></p>');
    return $fields;
}
Ejemplo n.º 3
0
function hocwp_setup_admin_body_class($class)
{
    if (HOCWP_DEVELOPING && hocwp_is_localhost()) {
        hocwp_add_string_with_space_before($class, 'hocwp-developing');
    }
    return $class;
}
Ejemplo n.º 4
0
 public function add_class($class)
 {
     $old_class = $this->get_attribute('class');
     hocwp_add_string_with_space_before($old_class, $class);
     $this->set_class($old_class);
 }
Ejemplo n.º 5
0
function hocwp_post_title_single($args = array())
{
    $class = hocwp_get_value_by_key($args, 'class');
    hocwp_add_string_with_space_before($class, 'entry-title post-title');
    $tag = hocwp_get_value_by_key($args, 'tag', 'h1');
    the_title('<' . $tag . ' class="' . $class . '" itemprop="headline">', '</' . $tag . '>');
}
Ejemplo n.º 6
0
function hocwp_facebook_like_button($args = array())
{
    $post_id = isset($args['post_id']) ? $args['post_id'] : get_the_ID();
    $permalink = hocwp_get_value_by_key($args, 'permalink', get_permalink($post_id));
    if (empty($permalink)) {
        $permalink = home_url('/');
    }
    $class = isset($args['class']) ? $args['class'] : '';
    hocwp_add_string_with_space_before($class, 'fb-like');
    $layout = isset($args['layout']) ? $args['layout'] : 'button_count';
    $action = isset($args['action']) ? $args['action'] : 'like';
    $show_faces = isset($args['show_faces']) ? $args['show_faces'] : false;
    $show_faces = hocwp_bool_to_string($show_faces);
    $share = isset($args['share']) ? $args['share'] : true;
    $share = hocwp_bool_to_string($share);
    ?>
	<div class="<?php 
    echo $class;
    ?>
" data-href="<?php 
    echo esc_url($permalink);
    ?>
"
	     data-layout="<?php 
    echo $layout;
    ?>
"
	     data-action="<?php 
    echo $action;
    ?>
" data-show-faces="<?php 
    echo $show_faces;
    ?>
"
	     data-share="<?php 
    echo $share;
    ?>
"></div>
	<?php 
}
Ejemplo n.º 7
0
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_option_page_recommended_plugin_content()
{
    $base_url = 'admin.php?page=hocwp_recommended_plugin';
    $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : 'installed';
    $tabs = array('installed' => __('Installed', 'hocwp-theme'), 'activated' => __('Activated', 'hocwp-theme'), 'required' => __('Required', 'hocwp-theme'), 'recommended' => __('Recommended', 'hocwp-theme'));
    $plugins = array();
    switch ($current_tab) {
        case 'required':
            $defaults = hocwp_recommended_plugins();
            $lists = hocwp_get_value_by_key($defaults, 'required');
            foreach ($lists as $key => $data) {
                $slug = hocwp_get_plugin_slug_from_file_path($data);
                $plugins[$slug] = $data;
            }
            break;
        case 'installed':
            $lists = hocwp_get_installed_plugins();
            foreach ($lists as $key => $data) {
                $slug = hocwp_get_plugin_slug_from_file_path($key);
                $plugins[$slug] = $key;
            }
            break;
        case 'activated':
            $lists = get_option('active_plugins');
            foreach ($lists as $key => $data) {
                $slug = hocwp_get_plugin_slug_from_file_path($data);
                $plugins[$slug] = $data;
            }
            break;
        case 'recommended':
            $defaults = hocwp_recommended_plugins();
            $lists = hocwp_get_value_by_key($defaults, 'recommended');
            foreach ($lists as $key => $data) {
                $slug = hocwp_get_plugin_slug_from_file_path($data);
                $plugins[$slug] = $data;
            }
            break;
    }
    ?>
	<div class="wp-filter">
		<ul class="filter-links">
			<?php 
    foreach ($tabs as $id => $text) {
        ?>
				<?php 
        $url = add_query_arg(array('tab' => $id), $base_url);
        $link_class = '';
        if ($id == $current_tab) {
            hocwp_add_string_with_space_before($link_class, 'current');
        }
        ?>
				<li class="plugin-install-<?php 
        echo $id;
        ?>
">
					<a class="<?php 
        echo $link_class;
        ?>
" data-tab="<?php 
        echo $id;
        ?>
"
					   href="<?php 
        echo $url;
        ?>
"><?php 
        echo $text;
        ?>
</a>
				</li>
			<?php 
    }
    ?>
		</ul>
	</div>
	<br class="clear">
	<p>Plugins extend and expand the functionality of WordPress. You may automatically install plugins from the <a
			href="https://wordpress.org/plugins/">WordPress Plugin Directory</a> or upload a plugin in .zip format via
		<a href="<?php 
    echo admin_url('plugin-install.php?tab=upload');
    ?>
">this page</a>.</p>
	<div id="the-list" class="widefat">
		<?php 
    $plugin_items = array();
    foreach ($plugins as $key => $data) {
        $plugin_information = hocwp_plugins_api_get_information(array('slug' => $key));
        $plugin_items[$data] = $plugin_information;
    }
    $plugins_allowedtags = array('a' => array('href' => array(), 'title' => array(), 'target' => array()), 'abbr' => array('title' => array()), 'acronym' => array('title' => array()), 'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(), 'ul' => array(), 'ol' => array(), 'li' => array(), 'p' => array(), 'br' => array());
    ?>
		<?php 
    foreach ($plugin_items as $key => $plugin) {
        hocwp_loop_plugin_card($plugin, $plugins_allowedtags, $key);
    }
    ?>
	</div>
	<?php 
}
Ejemplo n.º 9
0
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 
}
Ejemplo n.º 10
0
function hocwp_classifieds_admin_body_class($classes)
{
    global $pagenow;
    hocwp_add_string_with_space_before($classes, 'classifieds');
    if ('post-new.php' == $pagenow || 'post.php' == $pagenow) {
        hocwp_add_string_with_space_before($classes, 'hocwp-google-maps');
    }
    return $classes;
}
Ejemplo n.º 11
0
<?php

if (!function_exists('add_filter')) {
    exit;
}
$sidebar = '404';
if (is_active_sidebar($sidebar)) {
    do_action('hocwp_before_sidebar');
    do_action('hocwp_before_404_sidebar');
    $class = apply_filters('hocwp_sidebar_class', '', '404');
    hocwp_add_string_with_space_before($class, 'sidebar widget-area not-found');
    ?>
	<div id="secondary" class="<?php 
    echo $class;
    ?>
" role="complementary">
		<?php 
    do_action('hocwp_before_sidebar_widget');
    do_action('hocwp_before_404_sidebar_widget');
    dynamic_sidebar($sidebar);
    do_action('hocwp_after_404_sidebar_widget');
    do_action('hocwp_after_sidebar_widget');
    ?>
	</div><!-- .sidebar .widget-area -->
	<?php 
    do_action('hocwp_after_404_sidebar');
    do_action('hocwp_after_sidebar');
} else {
    get_sidebar('page');
}
Ejemplo n.º 12
0
function hocwp_get_archive_title($prefix = '')
{
    $title = '';
    if (is_archive()) {
        if (is_tax()) {
            $title = single_term_title('', false);
        } elseif (is_category()) {
            $title = single_cat_title('', false);
        } elseif (is_tag()) {
            $title = single_tag_title('', false);
        } elseif (is_post_type_archive()) {
            $title = post_type_archive_title('', false);
        } elseif (is_author()) {
            $title = get_the_author();
        } elseif (is_year()) {
            $title = get_the_date('Y');
        } elseif (is_month()) {
            if ('vi' == hocwp_get_language()) {
                $month = get_the_date('F');
                $title = hocwp_convert_month_name_to_vietnamese($month);
                hocwp_add_string_with_space_before($title, get_the_date('Y'));
            } else {
                $title = get_the_date('F Y');
            }
        } elseif (is_day()) {
            if ('vi' == hocwp_get_language()) {
                $month = get_the_date('F');
                $title = hocwp_convert_month_name_to_vietnamese($month);
                hocwp_add_string_with_space_before($title, get_the_date('Y'));
                $title = get_the_date('j') . ' ' . strtolower($title);
            } else {
                $title = get_the_date('F j, Y');
            }
        } else {
            if (is_search()) {
                $title = get_search_query();
                if (empty($title)) {
                    $title = __('Search results', 'hocwp-theme');
                }
            } else {
                $title = __('Archive', 'hocwp-theme');
            }
        }
        if (!empty($prefix)) {
            $title = $prefix . $title;
        }
    }
    return apply_filters('hocwp_get_archive_title', $title, $prefix);
}
Ejemplo n.º 13
0
function hocwp_search_form($args = array())
{
    $echo = isset($args['echo']) ? (bool) $args['echo'] : true;
    $class = isset($args['class']) ? $args['class'] : '';
    hocwp_add_string_with_space_before($class, 'search-form');
    $placeholder = isset($args['placeholder']) ? $args['placeholder'] : _x('Search &hellip;', 'placeholder', 'hocwp-theme');
    $search_icon = isset($args['search_icon']) ? $args['search_icon'] : false;
    $submit_text = _x('Search', 'submit button');
    if ($search_icon) {
        hocwp_add_string_with_space_before($class, 'use-icon-search');
        $submit_text = '&#xf002;';
    }
    $icon_in = hocwp_get_value_by_key($args, 'icon_in');
    if ((bool) $icon_in) {
        hocwp_add_string_with_space_before($class, 'icon-in');
    }
    $action = hocwp_get_value_by_key($args, 'action', home_url('/'));
    $action = trailingslashit($action);
    $name = hocwp_get_value_by_key($args, 'name', 's');
    $before_search_field = apply_filters('hocwp_search_form_before_search_field', '', $args);
    $form = '<form method="get" class="' . $class . '" action="' . esc_url($action) . '">
				<label>
					<span class="screen-reader-text">' . _x('Search for:', 'label', 'hocwp-theme') . '</span>';
    $form .= $before_search_field;
    $form .= '<input type="search" class="search-field" placeholder="' . esc_attr($placeholder) . '" value="' . get_search_query() . '" name="' . $name . '" title="' . esc_attr_x('Search for:', 'label') . '" />
				</label>
				<input type="submit" class="search-submit" value="' . esc_attr($submit_text) . '" />';
    $post_types = hocwp_get_value_by_key($args, 'post_type');
    if (!empty($post_types) && !is_array($post_types)) {
        $post_types = array($post_types);
    }
    if (hocwp_array_has_value($post_types)) {
        foreach ($post_types as $post_type) {
            $form .= '<input type="hidden" name="post_type[]" value="' . $post_type . '" />';
        }
    }
    $form .= '</form>';
    if ($echo) {
        echo $form;
    }
    return $form;
}
Ejemplo n.º 14
0
<?php

if (!function_exists('add_filter')) {
    exit;
}
if (is_active_sidebar('primary')) {
    do_action('hocwp_before_sidebar');
    do_action('hocwp_before_primary_sidebar');
    $class = apply_filters('hocwp_sidebar_class', '', 'primary');
    hocwp_add_string_with_space_before($class, 'sidebar widget-area primary');
    ?>
	<div id="secondary" class="<?php 
    echo $class;
    ?>
" role="complementary">
		<?php 
    do_action('hocwp_before_sidebar_widget');
    do_action('hocwp_before_primary_sidebar_widget');
    dynamic_sidebar('primary');
    do_action('hocwp_after_primary_sidebar_widget');
    do_action('hocwp_after_sidebar_widget');
    ?>
	</div><!-- .sidebar .widget-area -->
	<?php 
    do_action('hocwp_after_primary_sidebar');
    do_action('hocwp_after_sidebar');
}
Ejemplo n.º 15
0
    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;
    }
Ejemplo n.º 16
0
function hocwp_theme_site_main_before($class = '', $outer_class = '')
{
    $outer_class = apply_filters('hocwp_content_area_class', $outer_class);
    hocwp_add_string_with_space_before($class, 'site-main');
    hocwp_add_string_with_space_before($outer_class, 'content-area');
    ?>
	<div id="primary" class="<?php 
    echo $outer_class;
    ?>
">
	<main id="main" class="<?php 
    echo $class;
    ?>
"<?php 
    hocwp_html_tag_attributes('main', 'site_main');
    ?>
>
	<?php 
}
 public function field_init()
 {
     foreach ($this->get_fields() as $args) {
         $id = isset($args['id']) ? $args['id'] : '';
         $title = isset($args['title']) ? $args['title'] : '';
         $callback = isset($args['callback']) ? $args['callback'] : '';
         $section = isset($args['section']) ? $args['section'] : $this->get_section_id();
         if (!hocwp_callback_exists($callback)) {
             $callback = array($this, 'default_field_callback');
         }
         if ($this->get_exists()) {
             $class = isset($args['class']) ? $args['class'] : '';
             hocwp_add_string_with_space_before($class, 'hocwp-theme');
             $args['class'] = $class;
         }
         $this->add_settings_field($id, $title, $callback, $section, $args);
     }
 }
Ejemplo n.º 18
0
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;
        }
    }
}
Ejemplo n.º 19
0
function hocwp_setup_theme_after_go_to_top_button()
{
    $button = (bool) hocwp_option_get_value('reading', 'go_to_top');
    $button = apply_filters('hocwp_theme_go_to_top_button', $button);
    if ($button) {
        $icon = hocwp_option_get_value('reading', 'scroll_top_icon');
        $icon = hocwp_sanitize_media_value($icon);
        $icon = $icon['url'];
        $class = 'hocwp-go-top';
        if (empty($icon)) {
            $icon = '<i class="fa fa-chevron-up"></i>';
            hocwp_add_string_with_space_before($class, 'icon-default');
        }
        $icon = apply_filters('hocwp_theme_go_to_top_button_icon', $icon);
        if (hocwp_url_valid($icon)) {
            $icon = '<img src="' . $icon . '">';
            hocwp_add_string_with_space_before($class, 'icon-image');
        }
        $on_left = hocwp_option_get_value('reading', 'go_to_top_on_left');
        if ($on_left) {
            hocwp_add_string_with_space_before($class, 'position-left');
        }
        $a = new HOCWP_HTML('a');
        $a->set_attribute('id', 'hocwp_go_top');
        $a->set_text($icon);
        $a->set_attribute('href', '#');
        $a->set_attribute('class', $class);
        do_action('hocwp_back_to_top_before');
        $a->output();
        do_action('hocwp_back_to_top_after');
    }
}
Ejemplo n.º 20
0
function hocwp_widget_field($callback, $args)
{
    if (hocwp_callback_exists($callback)) {
        $hidden = isset($args['hidden']) ? $args['hidden'] : false;
        $container_class = '';
        if ($hidden) {
            hocwp_add_string_with_space_before($container_class, 'hidden');
        }
        hocwp_field_widget_before($container_class, true);
        $args = hocwp_field_sanitize_widget_args($args);
        if ('hocwp_field_select_chosen' == $callback) {
            $args['before'] = '<div class="hocwp-widget-field">';
            $args['after'] = '</div>';
        }
        call_user_func($callback, $args);
        hocwp_field_widget_after();
    }
}
Ejemplo n.º 21
0
function hocwp_term_pagination($args = array())
{
    $query_vars = hocwp_get_value_by_key($args, 'query_vars', array());
    $posts_per_page = hocwp_get_value_by_key($query_vars, 'number', hocwp_get_posts_per_page());
    $offset = absint(hocwp_get_value_by_key($query_vars, 'offset'));
    $paged = hocwp_get_paged();
    $taxonomy = hocwp_get_value_by_key($args, 'taxonomy', 'category');
    if ($paged > 1) {
        $offset = ($paged - 1) * $posts_per_page;
    }
    $term_args = array('number' => 0, 'hide_empty' => false);
    $terms = hocwp_get_terms($taxonomy, $term_args);
    $total_page = 1;
    if (0 < $posts_per_page) {
        $total_page = ceil(count($terms) / $posts_per_page);
    }
    $args['current_page'] = $paged;
    $args['total_page'] = $total_page;
    $class = hocwp_get_value_by_key($args, 'class');
    hocwp_add_string_with_space_before($class, 'term-pagination');
    $args['class'] = $class;
    $result = hocwp_build_pagination($args);
    hocwp_pagination_before($args);
    echo $result;
    hocwp_pagination_after();
}
Ejemplo n.º 22
0
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();
}
Ejemplo n.º 23
0
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 
    }
}
    public function list_post_html($args, $instance, WP_Query $query)
    {
        $post_type = $this->get_post_type_from_instance($instance);
        $post_types = array();
        foreach ($post_type as $fvdata) {
            $ptvalue = isset($fvdata['value']) ? $fvdata['value'] : '';
            if (!empty($ptvalue)) {
                $post_types[] = $ptvalue;
            }
        }
        $full_width_post = hocwp_get_value_by_key($instance, 'full_width_post', $this->args['full_width_post']);
        $hide_thumbnail = hocwp_get_value_by_key($instance, 'hide_thumbnail', hocwp_get_value_by_key($this->args, 'hide_thumbnail'));
        $thumbnail_size = isset($instance['thumbnail_size']) ? $instance['thumbnail_size'] : $this->args['thumbnail_size'];
        $thumbnail_size = hocwp_sanitize_size($thumbnail_size);
        $excerpt_length = isset($instance['excerpt_length']) ? $instance['excerpt_length'] : $this->args['excerpt_length'];
        $title_length = hocwp_get_value_by_key($instance, 'title_length', hocwp_get_value_by_key($this->args, 'title_length'));
        $list_class = 'list-unstyled';
        foreach ($post_types as $ptvalue) {
            hocwp_add_string_with_space_before($list_class, 'list-' . $ptvalue . 's');
        }
        $list_class = apply_filters('hocwp_widget_post_list_class', $list_class, $args, $instance, $this);
        $widget_html = '<ul class="' . $list_class . '">';
        $loop_html = apply_filters('hocwp_widget_post_loop_html', '', $args, $instance, $this);
        if (empty($loop_html)) {
            $count = 0;
            ob_start();
            while ($query->have_posts()) {
                $query->the_post();
                $post_id = get_the_ID();
                $post = get_post($post_id);
                $class = 'a-widget-post';
                $full_width = false;
                if ('all' == $full_width_post) {
                    $full_width = true;
                } elseif ('first' == $full_width_post && 0 == $count) {
                    $full_width = true;
                } elseif ('last' == $full_width_post && $count == $query->post_count) {
                    $full_width = true;
                } elseif ('first_last' == $full_width_post && (0 == $count || $count == $query->post_count)) {
                    $full_width = true;
                } elseif ('odd' == $full_width_post && $count % 2 != 0) {
                    $full_width = true;
                } elseif ('even' == $full_width_post && $count % 2 == 0) {
                    $full_width = true;
                }
                if ($full_width) {
                    hocwp_add_string_with_space_before($class, 'full-width');
                }
                if ($hide_thumbnail) {
                    hocwp_add_string_with_space_before($class, 'hide-thumbnail');
                }
                if (hocwp_is_positive_number($excerpt_length)) {
                    hocwp_add_string_with_space_before($class, 'show-excerpt');
                } else {
                    hocwp_add_string_with_space_before($class, 'hide-excerpt');
                }
                ?>
				<li <?php 
                post_class($class);
                ?>
>
					<?php 
                do_action('hocwp_widget_post_before_post', $args, $instance, $this);
                if (!(bool) $hide_thumbnail) {
                    if ('coupon' == $post->post_type) {
                        echo '<div class="text-center code-data">';
                        $percent = hocwp_get_coupon_percent_label($post_id);
                        $text = hocwp_get_coupon_text_label($post_id);
                        $type_text = 'Website Coupons';
                        $type_term = hocwp_get_coupon_type_term($post_id);
                        if (is_a($type_term, 'WP_Term')) {
                            $type_text = $type_term->name;
                        }
                        $tmp = hocwp_get_coupon_type($post_id);
                        if (is_array($tmp)) {
                            $tmp = array_shift($tmp);
                            if (!empty($tmp)) {
                                $type_text = $tmp;
                            }
                        }
                        $price = hocwp_get_post_meta('price', $post_id);
                        $sale_price = hocwp_get_post_meta('sale_price', $post_id);
                        if (!empty($price) && !empty($sale_price) || empty($percent)) {
                            $percentage = hocwp_percentage($price, $sale_price);
                            $percent = $percentage . '%';
                            $text = 'OFF';
                        }
                        ?>
							<div class="txt"><?php 
                        echo $percent . ' ' . $text;
                        ?>
</div>
							<div class="type"><?php 
                        echo $type_text;
                        ?>
</div>
							<?php 
                        echo '</div>';
                    } else {
                        $thumbnail_args = array('width' => $thumbnail_size[0], 'height' => $thumbnail_size[1]);
                        if ($full_width) {
                            unset($thumbnail_args['width']);
                            unset($thumbnail_args['height']);
                        }
                        hocwp_post_thumbnail($thumbnail_args);
                    }
                }
                do_action('hocwp_widget_post_before_post_title', $args, $instance, $this);
                hocwp_post_title_link(array('title' => hocwp_substr(get_the_title(), $title_length)));
                do_action('hocwp_widget_post_after_post_title', $args, $instance, $this);
                if (0 < $excerpt_length) {
                    $post_type = get_post_type($post_id);
                    if ('product' == $post_type && hocwp_wc_installed()) {
                        hocwp_wc_product_price(null, true);
                    } else {
                        hocwp_entry_summary($excerpt_length);
                    }
                }
                do_action('hocwp_widget_post_after_post', $args, $instance, $this);
                ?>
				</li>
				<?php 
                $count++;
            }
            wp_reset_postdata();
            $loop_html .= ob_get_clean();
        }
        $widget_html .= $loop_html;
        $widget_html .= '</ul>';
        return $widget_html;
    }
Ejemplo n.º 25
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>';
        }
    }
}
 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 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);
    }
Ejemplo n.º 28
0
    public function post_meta_box_callback()
    {
        $class = 'hocwp-meta-box';
        hocwp_add_string_with_space_before($class, $this->get_context());
        hocwp_add_string_with_space_before($class, $this->get_priority());
        foreach ($this->get_post_types() as $post_type) {
            hocwp_add_string_with_space_before($class, 'post-type-' . $post_type);
        }
        ?>
		<div class="<?php 
        echo $class;
        ?>
">
			<?php 
        if (hocwp_callback_exists($this->get_callback())) {
            call_user_func($this->get_callback());
        } else {
            global $post;
            $post_id = $post->ID;
            foreach ($this->get_fields() as $field) {
                $field_args = isset($field['field_args']) ? $field['field_args'] : array();
                $callback = isset($field['field_callback']) ? $field['field_callback'] : 'hocwp_field_input';
                if (!isset($field_args['value'])) {
                    $name = $field_args['name'];
                    $value = hocwp_get_post_meta($name, $post_id);
                    $field_args['value'] = $value;
                }
                if (hocwp_callback_exists($callback)) {
                    call_user_func($callback, $field_args);
                } else {
                    echo '<p>' . sprintf(__('The callback function %s does not exists!', 'hocwp-theme'), '<strong>' . $callback . '</strong>') . '</p>';
                }
            }
        }
        do_action('hocwp_post_meta_box_field', $this);
        $current_post_type = hocwp_get_current_post_type();
        if (!empty($current_post_type)) {
            do_action('hocwp_' . $current_post_type . '_meta_box_field');
        }
        do_action('hocwp_meta_box_' . $this->get_id() . '_field');
        ?>
		</div>
		<?php 
    }
Ejemplo n.º 29
0
function hocwp_addthis_toolbox($args = array())
{
    $post_id = isset($args['post_id']) ? $args['post_id'] : get_the_ID();
    $class = isset($args['class']) ? $args['class'] : 'addthis_native_toolbox';
    $class = apply_filters('hocwp_addthis_toolbox_class', $class);
    hocwp_add_string_with_space_before($class, 'addthis-tools');
    $url = isset($args['url']) ? $args['url'] : get_the_permalink();
    $title = isset($args['title']) ? $args['title'] : get_the_title();
    ?>
	<!-- Go to www.addthis.com/dashboard to customize your tools -->
	<div class="<?php 
    echo $class;
    ?>
" data-url="<?php 
    echo $url;
    ?>
"
	     data-title="<?php 
    echo hocwp_wpseo_get_post_title($post_id);
    ?>
"></div>
	<?php 
}
Ejemplo n.º 30
0
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>';
}