function hocwp_wc_get_product_total_sales($post_id = null)
{
    if (!hocwp_id_number_valid($post_id)) {
        $post_id = get_the_ID();
    }
    return absint(hocwp_get_post_meta('total_sales', $post_id));
}
Beispiel #2
0
function hocwp_get_sidebar_info($post)
{
    $post_id = $post->ID;
    $active = (bool) hocwp_get_post_meta('active', $post_id);
    $sidebar_id = hocwp_get_post_meta('sidebar_id', $post_id);
    $default = (bool) hocwp_get_post_meta('sidebar_default', $post_id);
    if (empty($sidebar_id)) {
        $sidebar_id = $post->post_name;
    }
    $sidebar_name = hocwp_get_value_by_key('sidebar_name', $post_id);
    if (empty($sidebar_name)) {
        $sidebar_name = $post->post_title;
    }
    if (hocwp_qtranslate_x_installed()) {
        $sidebar_name = apply_filters('translate_text', $sidebar_name, $lang = null, $flags = 0);
    }
    $sidebar_description = hocwp_get_post_meta('sidebar_description', $post_id);
    $sidebar_tag = hocwp_get_post_meta('sidebar_tag', $post_id);
    if (empty($sidebar_tag)) {
        $sidebar_tag = 'div';
    }
    $args = array('id' => hocwp_sanitize_id($sidebar_id), 'name' => strip_tags($sidebar_name), 'description' => strip_tags($sidebar_description), 'tag' => strtolower($sidebar_tag), 'active' => $active, 'default' => $default);
    return $args;
}
Beispiel #3
0
function hocwp_slider_html($args = array())
{
    if (!is_array($args)) {
        $position = $args;
    } else {
        $position = hocwp_get_value_by_key($args, 'position');
    }
    $slider = hocwp_get_slider_by_position($position);
    if (hocwp_is_post($slider)) {
        $items = hocwp_get_post_meta('slider_items', $slider->ID);
        $order = hocwp_get_value_by_key($items, 'order');
        if (!empty($order)) {
            $order = explode(',', $order);
            $items = hocwp_get_value_by_key($items, 'items');
            $slider_class = 'hocwp-slider';
            $thumbs = (bool) hocwp_get_value_by_key($args, 'thumbs', false);
            if ($thumbs) {
                hocwp_add_string_with_space_before($slider_class, 'thumbs-paging');
            }
            hocwp_add_string_with_space_before($slider_class, hocwp_sanitize_html_class($position));
            $custom_arrow = hocwp_get_value_by_key($args, 'custom_arrow');
            if ($custom_arrow) {
                $slider_class = hocwp_add_more_class($slider_class, 'custom-arrow');
            }
            $fit_width = hocwp_get_post_meta('fit_width', $slider->ID);
            $fit_width = hocwp_int_to_bool($fit_width);
            $height = hocwp_get_post_meta('height', $slider->ID);
            if (!hocwp_is_positive_number($height)) {
                $height = 350;
            }
            $atts = array('data-height="' . $height . '"');
            if ($fit_width) {
                $atts[] = 'data-fit-width="1"';
            }
            $atts = implode(' ', $atts);
            if (!empty($atts)) {
                $atts = ' ' . $atts;
                $atts = rtrim($atts);
            }
            echo '<div class="' . $slider_class . '">';
            echo '<ul class="list-unstyled list-items slickslide list-inline"' . $atts . '>';
            $list_paging = '';
            $lazyload = hocwp_get_value_by_key($args, 'lazyload');
            foreach ($order as $item_id) {
                $item = hocwp_get_value_by_key($items, $item_id);
                if (hocwp_array_has_value($item)) {
                    $title = hocwp_get_value_by_key($item, 'title');
                    $link = hocwp_get_value_by_key($item, 'link');
                    $description = hocwp_get_value_by_key($item, 'description');
                    $image_url = hocwp_get_value_by_key($item, 'image_url');
                    $image_id = hocwp_get_value_by_key($item, 'image_id');
                    $image_url = hocwp_return_media_url($image_url, $image_id);
                    $img = new HOCWP_HTML('img');
                    $img->set_image_src($image_url);
                    $img->add_class('slider-image');
                    $li = new HOCWP_HTML('li');
                    $li->set_text($img);
                    $li->add_class('slider-item');
                    if ($lazyload) {
                        $li->add_class('lazyload');
                        $img->set_attribute('data-original', $image_url);
                        $img->set_image_src(hocwp_get_image_url('transparent.gif'));
                    }
                    $list_paging .= $li->build();
                    if (!empty($link)) {
                        $a = new HOCWP_HTML('a');
                        $a->set_href($link);
                        $a->set_text($img);
                        $li->set_text($a);
                    } else {
                        $li->set_text($img);
                    }
                    $li->output();
                }
            }
            echo '</ul>';
            if ($thumbs) {
                echo '<div class="thumbs-paging slick-thumbs">';
                echo '<ul class="list-unstyled list-paging">';
                echo $list_paging;
                echo '</ul>';
                echo '</div>';
            }
            echo '</div>';
        }
    }
}
Beispiel #4
0
function hocwp_meta_box_google_maps($args = array())
{
    global $pagenow;
    if ('post-new.php' == $pagenow || 'post.php' == $pagenow) {
        $post_id = hocwp_get_value_by_key($_REQUEST, 'post');
        $id = hocwp_get_value_by_key($args, 'id', 'google_maps_box');
        $title = hocwp_get_value_by_key($args, 'title', __('Maps', 'hocwp-theme'));
        $post_types = hocwp_get_value_by_key($args, 'post_types', array('post'));
        $meta = new HOCWP_Meta('post');
        $meta->set_title($title);
        $meta->set_id($id);
        $meta->set_post_types($post_types);
        $map_args = array('id' => 'maps_content', 'label' => '', 'field_callback' => 'hocwp_field_google_maps', 'names' => array('google_maps'));
        if (hocwp_id_number_valid($post_id)) {
            $google_maps = hocwp_get_post_meta('google_maps', $post_id);
            $google_maps = hocwp_json_string_to_array($google_maps);
            $map_args['lat'] = hocwp_get_value_by_key($google_maps, 'lat');
            $map_args['long'] = hocwp_get_value_by_key($google_maps, 'lng');
        }
        $meta->add_field($map_args);
        //$meta->add_field(array('id' => 'google_maps', 'label' => '', 'field_callback' => 'hocwp_field_input_hidden'));
        $meta->init();
    }
}
Beispiel #5
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;
        }
    }
}
 function hocwp_widget_subscribe_ajax_callback()
 {
     $use_captcha = (bool) hocwp_get_method_value('use_captcha');
     $captcha_code = hocwp_get_method_value('captcha');
     $email = hocwp_get_method_value('email');
     $name = hocwp_get_method_value('name');
     $phone = hocwp_get_method_value('phone');
     $register = (bool) hocwp_get_method_value('register');
     $result = array('success' => false, 'message' => hocwp_build_message(hocwp_text_error_default(), 'danger'));
     $captcha_valid = true;
     if ($use_captcha) {
         $captcha = new HOCWP_Captcha();
         $captcha_valid = $captcha->check($captcha_code);
     }
     $re_verify = false;
     $query = hocwp_get_post_by_meta('subscriber_email', $email, array('post_type' => 'hocwp_subscriber'));
     if ($query->have_posts()) {
         $subscriber = array_shift($query->posts);
         $verified = hocwp_get_post_meta('subscriber_verified', $subscriber->ID);
         if (1 != $verified) {
             $re_verify = true;
         }
     }
     if ($captcha_valid) {
         if (is_email($email)) {
             $active_key = hocwp_generate_reset_key();
             $verify_link = hocwp_generate_verify_link($active_key);
             if ($re_verify) {
                 hocwp_send_mail_verify_email_subscription(hocwp_text_email_subject_verify_subscription(), $email, $verify_link);
                 $result['success'] = true;
                 $result['message'] = hocwp_build_message(hocwp_text_success_register_and_verify_email(), 'success');
             } else {
                 if ($query->have_posts() || $register && email_exists($email)) {
                     $result['message'] = hocwp_build_message(hocwp_text_error_email_exists(), 'danger');
                 } else {
                     $post_title = '';
                     if (!empty($name)) {
                         $post_title .= $name;
                     }
                     if (empty($post_title)) {
                         $post_title = $email;
                     } else {
                         $post_title .= ' - ' . $email;
                     }
                     $post_data = array('post_type' => 'hocwp_subscriber', 'post_title' => $post_title, 'post_status' => 'publish');
                     $post_id = hocwp_insert_post($post_data);
                     if (hocwp_id_number_valid($post_id)) {
                         update_post_meta($post_id, 'subscriber_name', $name);
                         update_post_meta($post_id, 'subscriber_email', $email);
                         update_post_meta($post_id, 'subscriber_phone', $phone);
                         update_post_meta($post_id, 'subscriber_verified', 0);
                         update_post_meta($post_id, 'subscriber_active_key', $active_key);
                         if ($register) {
                             $password = wp_generate_password();
                             $user_data = array('username' => $email, 'email' => $email, 'password' => $password);
                             $user_id = hocwp_add_user($user_data);
                             if (hocwp_id_number_valid($user_id)) {
                                 wp_send_new_user_notifications($user_id);
                                 update_post_meta($post_id, 'subscriber_user', $user_id);
                                 update_user_meta($user_id, 'subscriber_id', $post_id);
                             }
                         }
                         hocwp_send_mail_verify_email_subscription(hocwp_text_email_subject_verify_subscription(), $email, $verify_link);
                         $result['success'] = true;
                         $result['message'] = hocwp_build_message(hocwp_text_success_register_and_verify_email(), 'success');
                     }
                 }
             }
         } else {
             $result['message'] = hocwp_build_message(hocwp_text_error_email_not_valid(), 'danger');
         }
     } else {
         $result['message'] = hocwp_build_message(hocwp_text_error_captcha_not_valid(), 'danger');
     }
     wp_send_json($result);
 }
Beispiel #7
0
function hocwp_product_price($post_id = null, $no_price = '', $args = array())
{
    $post_id = hocwp_return_post($post_id, 'id');
    $regular_price = hocwp_get_post_meta('regular_price', $post_id);
    $sale_price = hocwp_get_post_meta('sale_price', $post_id);
    $prices = hocwp_sanitize_product_price($regular_price, $sale_price, $post_id);
    $price = $prices['price'];
    $no_price_html = '<span class="no-price">' . __('Price', 'hocwp-theme') . ': <span class="amount">';
    $no_price_html .= __('Please call', 'hocwp-theme') . '</span></span>';
    $defaults = array('currency' => '$', 'currency_position' => 'left', 'decimals' => 2, 'dec_point' => '.', 'thousands_sep' => ',', 'no_price_html' => $no_price_html);
    $defaults = apply_filters('hocwp_product_price_defaults', $defaults);
    $args = wp_parse_args($args, $defaults);
    $no_price_html = $args['no_price_html'];
    if (empty($no_price)) {
        $no_price = $no_price_html;
    }
    if (!hocwp_is_positive_number($price)) {
        $price = $no_price;
    } else {
        $sale_price = $prices['sale_price'];
        $regular_price = $prices['regular_price'];
        $currency = hocwp_get_value_by_key($args, 'currency');
        $currency = apply_filters('hocwp_product_price_currency', $currency);
        $currency_position = hocwp_get_value_by_key($args, 'currency_position', 'left');
        $currency_position = apply_filters('hocwp_product_price_currency_position', $currency_position);
        $decimals = hocwp_get_value_by_key($args, 'decimals');
        $dec_point = hocwp_get_value_by_key($args, 'dec_point');
        $thousands_sep = hocwp_get_value_by_key($args, 'thousands_sep');
        $number_format = '%NUMBER%';
        if ('left' == $currency_position) {
            $number_format = '%CURRENCY%' . $number_format;
        } else {
            $number_format .= '%CURRENCY%';
        }
        $number_format = str_replace('%CURRENCY%', $currency, $number_format);
        $price = number_format($regular_price, $decimals, $dec_point, $thousands_sep);
        $price = str_replace('%NUMBER%', $price, $number_format);
        $price = hocwp_wrap_tag($price, 'span', 'amount');
        if (hocwp_is_positive_number($sale_price)) {
            $sale_price = number_format($sale_price, $decimals, $dec_point, $thousands_sep);
            $sale_price = str_replace('%NUMBER%', $sale_price, $number_format);
            $sale_price = hocwp_wrap_tag($sale_price, 'span', 'amount');
            $sale_price = hocwp_wrap_tag($sale_price, 'ins');
            $price = hocwp_wrap_tag($price, 'del');
            $price .= $sale_price;
        }
    }
    if (!empty($price)) {
        $price = hocwp_wrap_tag($price, 'p', 'price');
        echo $price;
    }
}
Beispiel #8
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;
}
Beispiel #9
0
function hocwp_get_post_temperature($post_id = null)
{
    $post_id = hocwp_return_post($post_id, 'id');
    $result = hocwp_get_post_meta('temperature', $post_id);
    $result = absint($result);
    return $result;
}
    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 
    }
    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;
    }
function hocwp_theme_post_column_content_subscriber($column, $post_id)
{
    global $post_type;
    $post = get_post($post_id);
    if ('hocwp_subscriber' == $post_type) {
        if ('subscriber_date' == $column) {
            echo date(hocwp_get_date_format(), strtotime($post->post_date));
        } else {
            if ('active' != $column) {
                echo hocwp_get_post_meta($column, $post_id);
            }
        }
    }
}
function hocwp_classifieds_pre_post_thumbnail($url, $post_id)
{
    if (empty($url)) {
        $gallery = hocwp_get_post_meta('gallery', $post_id);
        $url = hocwp_get_first_image_source($gallery);
    }
    return $url;
}
function hocwp_setup_theme_woocommerce_product_tabs_callback($key, $tab)
{
    $content = hocwp_get_post_meta($key, get_the_ID());
    $content = trim($content);
    $title = hocwp_get_value_by_key($tab, 'title');
    if (empty($content)) {
        $slug = hocwp_sanitize_html_class($key);
        $hocwp_product_tab = hocwp_get_post_by_slug($slug, 'hocwp_product_tab');
        if (!hocwp_is_post($hocwp_product_tab)) {
            $hocwp_product_tab = hocwp_get_post_by_column('post_title', $title);
        }
        if (hocwp_is_post($hocwp_product_tab)) {
            $content = $hocwp_product_tab->post_content;
            $content = trim($content);
        }
    }
    if (!empty($content)) {
        if (!empty($title)) {
            echo hocwp_wrap_tag($title, 'h2', 'tab-title');
        }
        echo '<div class="hocwp-product-info">';
        $embed = new WP_Embed();
        $content = $embed->run_shortcode($content);
        $content = $embed->autoembed($content);
        hocwp_the_custom_content($content);
        echo '</div>';
    }
}
<?php

if (!function_exists('add_filter')) {
    exit;
}
$sidebar = hocwp_get_post_meta('sidebar');
if (!is_active_sidebar($sidebar)) {
    $sidebar = 'page';
}
if (is_active_sidebar($sidebar)) {
    do_action('hocwp_before_sidebar');
    do_action('hocwp_before_page_sidebar');
    $class = apply_filters('hocwp_sidebar_class', '', 'page');
    hocwp_add_string_with_space_before($class, 'sidebar widget-area page');
    ?>
	<div id="secondary" class="<?php 
    echo $class;
    ?>
" role="complementary">
		<?php 
    do_action('hocwp_before_sidebar_widget');
    do_action('hocwp_before_page_sidebar_widget');
    dynamic_sidebar($sidebar);
    do_action('hocwp_after_page_sidebar_widget');
    do_action('hocwp_after_sidebar_widget');
    ?>
	</div><!-- .sidebar .widget-area -->
	<?php 
    do_action('hocwp_after_page_sidebar');
    do_action('hocwp_after_sidebar');
} else {
Beispiel #16
0
function hocwp_button_vote_group()
{
    $post_id = get_the_ID();
    $vote_up = absint(get_post_meta($post_id, 'likes', true));
    $vote_down = absint(hocwp_get_post_meta('dislikes', $post_id));
    ?>
	<div class="text-center vote-buttons">
		<p class="vote btn-group" data-post-id="<?php 
    the_ID();
    ?>
">
			<a class="btn btn-default vote-up vote-post" data-vote-type="up" data-vote="<?php 
    echo $vote_up;
    ?>
">
				<i class="fa fa-thumbs-o-up"></i>
			</a>
			<a class="btn btn-default vote-down vote-post" data-vote-type="down" data-vote="<?php 
    echo $vote_down;
    ?>
">
				<i class="fa fa-thumbs-o-down"></i>
			</a>
		</p>
	</div>
	<?php 
}