public function update($new_instance, $old_instance)
 {
     $instance = $old_instance;
     $instance['title'] = strip_tags(hocwp_get_value_by_key($new_instance, 'title'));
     $instance['category'] = hocwp_get_value_by_key($new_instance, 'category', json_encode($this->args['category']));
     return $instance;
 }
function hocwp_force_admin_english()
{
    $args = hocwp_option_utilities();
    $force_admin_english = (bool) hocwp_get_value_by_key($args, 'force_admin_english');
    $force_admin_english = apply_filters('hocwp_force_admin_english', $force_admin_english);
    return $force_admin_english;
}
 public function update($new_instance, $old_instance)
 {
     $instance = $old_instance;
     $instance['title'] = strip_tags(hocwp_get_value_by_key($new_instance, 'title'));
     $instance['order'] = hocwp_get_value_by_key($new_instance, 'order', hocwp_get_value_by_key($this->args, 'order'));
     $instance['description'] = hocwp_get_value_by_key($new_instance, 'description');
     return $instance;
 }
function hocwp_option_theme_setting_defaults()
{
    $alls = hocwp_option_defaults();
    $defaults = hocwp_get_value_by_key($alls, 'theme_setting');
    if (!hocwp_array_has_value($defaults)) {
        $defaults = array('language' => 'vi');
    }
    return apply_filters('hocwp_option_theme_setting_defaults', $defaults);
}
function hocwp_option_theme_custom_defaults()
{
    $alls = hocwp_option_defaults();
    $defaults = hocwp_get_value_by_key($alls, 'theme_custom');
    if (!hocwp_array_has_value($defaults)) {
        $defaults = array('background_lazyload' => 0);
    }
    return apply_filters('hocwp_option_theme_custom_defaults', $defaults);
}
 public function update($new_instance, $old_instance)
 {
     $instance = $old_instance;
     $instance['title'] = strip_tags(hocwp_get_value_by_key($new_instance, 'title'));
     $instance['banner_image'] = hocwp_get_value_by_key($new_instance, 'banner_image');
     $instance['banner_url'] = hocwp_get_value_by_key($new_instance, 'banner_url');
     $instance['nofollow'] = hocwp_checkbox_post_data_value($new_instance, 'nofollow');
     return $instance;
 }
function hocwp_option_optimize_defaults()
{
    $alls = hocwp_option_defaults();
    $defaults = hocwp_get_value_by_key($alls, 'optimize');
    if (!hocwp_array_has_value($defaults)) {
        $defaults = array('use_jquery_cdn' => 1, 'use_bootstrap_cdn' => 1, 'use_fontawesome_cdn' => 1, 'use_superfish_cdn' => 1);
    }
    return apply_filters('hocwp_option_optimize_defaults', $defaults);
}
function hocwp_option_home_setting_defaults()
{
    $alls = hocwp_option_defaults();
    $defaults = hocwp_get_value_by_key($alls, 'home_setting');
    if (!hocwp_array_has_value($defaults)) {
        $defaults = array('recent_posts' => 1, 'posts_per_page' => hocwp_get_posts_per_page(), 'pagination' => 1);
    }
    return apply_filters('hocwp_option_home_setting_defaults', $defaults);
}
Пример #9
0
function hocwp_setup_enable_session()
{
    $options = get_option('hocwp_user_login');
    $use_captcha = hocwp_get_value_by_key($options, 'use_captcha');
    $options = get_option('hocwp_discussion');
    $comment_captcha = hocwp_get_value_by_key($options, 'captcha');
    if ((bool) $use_captcha || (bool) $comment_captcha) {
        add_filter('hocwp_use_session', '__return_true');
    }
}
 public function get_taxonomy_base($taxonomy = null)
 {
     if (empty($taxonomy)) {
         $taxonomy = $this->taxonomy;
     }
     $base_slug = '';
     if (taxonomy_exists($taxonomy)) {
         $taxonomy = get_taxonomy($taxonomy);
         $base_slug = hocwp_get_value_by_key($taxonomy->rewrite, 'slug');
     }
     return $base_slug;
 }
Пример #11
0
function hocwp_plugin_load_custom_css()
{
    $option = get_option('hocwp_plugin_custom_css');
    $css = hocwp_get_value_by_key($option, 'code');
    if (!empty($css)) {
        $css = hocwp_minify_css($css);
        $style = new HOCWP_HTML('style');
        $style->set_attribute('type', 'text/css');
        $style->set_text($css);
        $style->output();
    }
}
Пример #12
0
function hocwp_plugin_upgrader_process_complete($upgrader, $options)
{
    $plugins = hocwp_get_value_by_key($options, 'plugins');
    if (!hocwp_array_has_value($plugins)) {
        return;
    }
    foreach ($plugins as $plugin) {
        $slug = hocwp_get_plugin_slug_from_file_path($plugin);
        $transient_name = 'hocwp_plugins_api_' . $slug . '_plugin_information';
        $transient_name = hocwp_sanitize_id($transient_name);
        delete_transient($transient_name);
    }
}
Пример #13
0
function hocwp_theme_meta_box_sidebar_information($post_type, $post)
{
    if (!hocwp_is_post($post)) {
        return;
    }
    global $pagenow;
    if ('hocwp_sidebar' == $post_type) {
        $readonly = false;
        $post_id = 0;
        if ('post.php' == $pagenow) {
            $post_id = hocwp_get_value_by_key($_REQUEST, 'post');
            $default = (bool) get_post_meta($post_id, 'sidebar_default');
            if ($default) {
                $readonly = true;
            }
        }
        $post_id = $post->ID;
        $meta = new HOCWP_Meta('post');
        $meta->set_id('hocwp_sidebar_information');
        $meta->set_title(__('Sidebar Information', 'hocwp-theme'));
        $meta->add_post_type('hocwp_sidebar');
        $field_args = array('id' => 'sidebar_id', 'label' => __('Sidebar ID:', 'hocwp-theme'));
        if ($readonly) {
            $field_args['readonly'] = true;
        }
        $meta->add_field($field_args);
        $field_args = array('id' => 'sidebar_name', 'label' => __('Sidebar name:', 'hocwp-theme'));
        if ($readonly) {
            $field_args['readonly'] = true;
        }
        $meta->add_field($field_args);
        $field_args = array('id' => 'sidebar_description', 'label' => __('Sidebar description:', 'hocwp-theme'));
        if ($readonly) {
            $field_args['readonly'] = true;
        }
        $meta->add_field($field_args);
        $field_args = array('id' => 'sidebar_tag', 'label' => __('Sidebar tag:', 'hocwp-theme'));
        if ($readonly) {
            $field_args['readonly'] = true;
        }
        $meta->add_field($field_args);
        $meta->init();
    }
}
Пример #14
0
function hocwp_register_string_language($args = array())
{
    if (!did_action('init')) {
        _doing_it_wrong(__FUNCTION__, __('Please call this function in <strong>hocwp_register_string_translation</strong> hook.', 'hocwp-theme'), HOCWP_VERSION);
        return;
    }
    if (!is_array($args)) {
        $args = array('string' => $args);
    }
    $name = hocwp_get_value_by_key($args, 'name');
    $string = hocwp_get_value_by_key($args, 'string');
    $context = hocwp_get_value_by_key($args, 'context', 'HocWP');
    $multiline = hocwp_get_value_by_key($args, 'multiline');
    $key = md5($string);
    $active_strings = hocwp_get_active_registered_string_language();
    $active_strings[$key]['name'] = $name;
    $active_strings[$key]['string'] = $string;
    $active_strings[$key]['context'] = $context;
    $active_strings[$key]['multiline'] = $multiline;
    global $hocwp_active_registered_string_translations;
    $hocwp_active_registered_string_translations = $active_strings;
    $transient_name = hocwp_build_transient_name('hocwp_string_translation_registered_%s', $args);
    if (false === get_transient($transient_name)) {
        $strings = hocwp_get_registered_string_language();
        $strings[$key]['name'] = $name;
        $strings[$key]['string'] = $string;
        $strings[$key]['context'] = $context;
        $strings[$key]['multiline'] = $multiline;
        update_option('hocwp_string_translations', $strings);
        $mo = new HOCWP_MO();
        $translation = '';
        $object = $mo->get_object($string);
        if (is_a($object, 'WP_Post')) {
            $translation = $object->post_content;
        }
        $post_id = $mo->export_to_db($string, $translation);
        if (hocwp_id_number_valid($post_id)) {
            set_transient($transient_name, $post_id, WEEK_IN_SECONDS);
        }
    }
}
Пример #15
0
function hocwp_get_mailer()
{
    $data = hocwp_get_smtp_mail_data();
    $mailer = hocwp_get_value_by_key($data, 'mailer');
    return apply_filters('hocwp_mailer', $mailer);
}
 public function update($new_instance, $old_instance)
 {
     $instance = $old_instance;
     $instance['title'] = strip_tags(hocwp_get_value_by_key($new_instance, 'title'));
     $instance['page_name'] = hocwp_get_value_by_key($new_instance, 'page_name');
     $instance['href'] = hocwp_get_value_by_key($new_instance, 'href');
     $instance['width'] = hocwp_get_value_by_key($new_instance, 'width', $this->args['width']);
     $instance['height'] = hocwp_get_value_by_key($new_instance, 'height', $this->args['height']);
     $instance['button_text'] = hocwp_get_value_by_key($new_instance, 'button_text', $this->args['button_text']);
     $instance['position'] = hocwp_get_value_by_key($new_instance, 'position', $this->args['position']);
     $instance['hide_cover'] = hocwp_checkbox_post_data_value($new_instance, 'hide_cover');
     $instance['show_facepile'] = hocwp_checkbox_post_data_value($new_instance, 'show_facepile');
     $instance['hide_cta'] = hocwp_checkbox_post_data_value($new_instance, 'hide_cta');
     $instance['small_header'] = hocwp_checkbox_post_data_value($new_instance, 'small_header');
     $instance['adapt_container_width'] = hocwp_checkbox_post_data_value($new_instance, 'adapt_container_width');
     $instance['fixed'] = hocwp_checkbox_post_data_value($new_instance, 'fixed');
     $instance['only_link'] = hocwp_checkbox_post_data_value($new_instance, 'only_link');
     return $instance;
 }
Пример #17
0
function hocwp_shortcode_support_form_callback($atts = array(), $content = null)
{
    $defaults = array('style' => '', 'name' => 'full_name,email,phone,message', 'label' => array(__('Full name', 'hocwp-theme'), __('Email', 'hocwp-theme'), __('Phone', 'hocwp-theme'), __('Message', 'hocwp-theme')), 'type' => 'text,email,text,textarea', 'placehoder' => '', 'captcha' => false, 'admin_email' => hocwp_get_admin_email());
    $attributes = shortcode_atts($defaults, $atts);
    $name = hocwp_get_value_by_key($attributes, 'name');
    $names = explode(',', $name);
    if (hocwp_array_has_value($names)) {
        $show_form = true;
        $label = hocwp_get_value_by_key($attributes, 'label');
        if (!is_array($label)) {
            $label = explode(',', $label);
            $label = array_map('trim', $label);
        }
        $type = hocwp_get_value_by_key($attributes, 'type');
        $type = explode(',', $type);
        $type = array_map('trim', $type);
        $placeholder = hocwp_get_value_by_key($attributes, 'placeholder');
        if (!empty($placeholder)) {
            $placeholder = explode(',', $placeholder);
            $placeholder = array_map('trim', $placeholder);
        }
        $captcha = hocwp_get_value_by_key($attributes, 'captcha');
        $names = array_map('trim', $names);
        $html = hocwp_shortcode_before('support-form', $attributes);
        if (isset($_POST['submit'])) {
            if (hocwp_check_nonce('hocwp_support_form')) {
                if (hocwp_check_captcha()) {
                    $body = '';
                    foreach ($names as $index => $name) {
                        if (empty($name)) {
                            continue;
                        }
                        if ('name' == $name) {
                            $name = 'full_name';
                        }
                        $field_type = isset($type[$index]) ? $type[$index] : 'text';
                        $field_label = isset($label[$index]) ? $label[$index] : '';
                        $field_placeholder = isset($placeholder[$index]) ? $placeholder[$index] : '';
                        $row = isset($_POST[$name]) ? $_POST[$name] : '';
                        if (!empty($field_label)) {
                            $last_char = hocwp_get_last_char($field_label);
                            if (':' != $last_char) {
                                $field_label .= ':';
                            }
                            $row = $field_label . ' ' . $row;
                        }
                        if (!empty($row)) {
                            $body .= wpautop($row);
                        }
                    }
                    if (empty($body)) {
                        $html .= hocwp_build_message(__('You must fill all required fields.', 'hocwp-theme'), 'danger');
                    } else {
                        $full_name = __('Guest', 'hocwp-theme');
                        if (isset($_POST['full_name'])) {
                            $full_name = $_POST['full_name'];
                        }
                        $subject = sprintf(__('[%1$s] Contact message from %2$s', 'hocwp-theme'), get_bloginfo('name'), $full_name);
                        $admin_email = hocwp_get_value_by_key($attributes, 'admin_email');
                        if (!is_email($admin_email)) {
                            $admin_email = hocwp_get_admin_email();
                        }
                        $sent = hocwp_send_html_mail($admin_email, $subject, $body);
                        if ($sent) {
                            $show_form = false;
                            $html .= hocwp_build_message(__('Your message has been sent, we will reply to you as soon as possible.', 'hocwp-theme'), 'success');
                        } else {
                            $html .= hocwp_build_message(__('There was an error occurred, please try again or contact administrators.', 'hocwp-theme'), 'danger');
                        }
                    }
                } else {
                    $html .= hocwp_build_message(__('Captcha code is not valid.', 'hocwp-theme'), 'danger');
                }
            }
        }
        if ($show_form) {
            ob_start();
            ?>
			<form class="hocwp-support-form" action="" method="post">
				<?php 
            foreach ($names as $index => $name) {
                if (empty($name)) {
                    continue;
                }
                if ('name' == $name) {
                    $name = 'full_name';
                }
                $field_type = isset($type[$index]) ? $type[$index] : 'text';
                $field_label = isset($label[$index]) ? $label[$index] : '';
                $field_placeholder = isset($placeholder[$index]) ? $placeholder[$index] : '';
                ?>
					<div class="form-group form-row">
						<div class="row">
							<div class="col-sm-2">
								<label for="<?php 
                echo esc_attr($name);
                ?>
"><?php 
                echo $field_label;
                ?>
</label>
							</div>
							<div class="col-sm-10">
								<?php 
                $value = isset($_POST[$name]) ? $_POST[$name] : '';
                switch ($field_type) {
                    case 'longtext':
                    case 'textarea':
                        ?>
										<textarea id="<?php 
                        echo esc_attr($name);
                        ?>
"
										          name="<?php 
                        echo esc_attr($name);
                        ?>
"
										          class="form-control"
										          placeholder="<?php 
                        echo esc_attr($field_placeholder);
                        ?>
"><?php 
                        echo $value;
                        ?>
</textarea>
										<?php 
                        break;
                    default:
                        $input_type = 'text';
                        if ('email' == $field_type) {
                            $input_type = 'email';
                        }
                        ?>
										<input id="<?php 
                        echo esc_attr($name);
                        ?>
"
										       placeholder="<?php 
                        echo esc_attr($field_placeholder);
                        ?>
"
										       value="<?php 
                        echo esc_attr($value);
                        ?>
"
										       name="<?php 
                        echo esc_attr($name);
                        ?>
"
										       type="<?php 
                        echo esc_attr($input_type);
                        ?>
">
										<?php 
                }
                ?>
							</div>
						</div>
					</div>
					<?php 
            }
            if ($captcha) {
                echo '<div class="form-group form-row"><div class="row"><div class="col-sm-2"></div><div class="col-sm-10">';
                hocwp_field_captcha(array('input_width' => 180));
                echo '</div></div></div>';
            }
            ?>
				<div class="form-hidden-fields">
					<?php 
            hocwp_nonce('hocwp_support_form');
            ?>
				</div>
				<div class="form-group form-row">
					<div class="row">
						<div class="col-sm-2"></div>
						<div class="col-sm-10">
							<input type="submit" name="submit" class="btn btn-warning"
							       value="<?php 
            _e('Send', 'hocwp-theme');
            ?>
">
						</div>
					</div>
				</div>
			</form>
			<?php 
            $html .= ob_get_clean();
        }
        $html .= hocwp_shortcode_after();
    }
    return apply_filters('hocwp_shortcode_support_form', $html, $attributes, $content);
}
Пример #18
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>';
        }
    }
}
Пример #19
0
function hocwp_twitter_follow_button($args = array())
{
    $username = hocwp_get_value_by_key($args, 'username');
    if (empty($username)) {
        $username = hocwp_get_value_by_key($args, 'account');
    }
    $permalink = hocwp_get_value_by_key($args, 'permalink');
    if (empty($permalink)) {
        $permalink = $username;
    }
    if (!empty($permalink) && !hocwp_is_url($permalink)) {
        $permalink = 'https://twitter.com/' . $permalink;
    }
    if (empty($permalink)) {
        $permalink = hocwp_get_option_by_name('hocwp_option_social', 'twitter_site');
    }
    if (empty($permalink)) {
        return;
    }
    $show_screen_name = hocwp_get_value_by_key($args, 'show_screen_name');
    $show_count = hocwp_get_value_by_key($args, 'show_count');
    $show_count = hocwp_bool_to_string($show_count);
    if (empty($username)) {
        $username = hocwp_get_last_part_in_url($permalink);
    }
    if (!empty($username)) {
        $first_char = hocwp_get_first_char($username);
        if ('@' != $first_char) {
            $username = '******' . $username;
        }
    }
    $text = __('Follow', 'hocwp-theme');
    if ($show_screen_name) {
        $username = $text . ' ' . $username;
    } else {
        $username = $text;
    }
    $username = trim($username);
    $size = hocwp_get_value_by_key($args, 'size');
    $show_screen_name = hocwp_bool_to_string($show_screen_name);
    ?>
	<a data-show-screen-name="<?php 
    echo $show_screen_name;
    ?>
" data-size="<?php 
    echo $size;
    ?>
"
	   href="<?php 
    echo esc_url($permalink);
    ?>
" class="twitter-follow-button"
	   data-show-count="<?php 
    echo $show_count;
    ?>
"><?php 
    echo $username;
    ?>
</a>
	<script type="text/javascript">
		window.twttr = (function (d, s, id) {
			var js, fjs = d.getElementsByTagName(s)[0],
				t = window.twttr || {};
			if (d.getElementById(id)) return t;
			js = d.createElement(s);
			js.id = id;
			js.src = "https://platform.twitter.com/widgets.js";
			fjs.parentNode.insertBefore(js, fjs);

			t._e = [];
			t.ready = function (f) {
				t._e.push(f);
			};

			return t;
		}(document, "script", "twitter-wjs"));
	</script>
	<?php 
}
Пример #20
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 
    }
}
Пример #21
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 
}
 public function update($new_instance, $old_instance)
 {
     $instance = $old_instance;
     $instance['title'] = strip_tags(hocwp_get_value_by_key($new_instance, 'title'));
     $instance['fields'] = $this->get_value_fields($new_instance);
     $all_fields = explode(',', $instance['fields']);
     foreach ($all_fields as $field_name) {
         $field = hocwp_get_value_by_key($this->args['fields'], $field_name);
         if (hocwp_array_has_value($field)) {
             foreach ($field as $key => $data) {
                 $real_name = 'subscribe_' . $field_name . '_' . $key;
                 $instance[$real_name] = $this->get_value_field($new_instance, $field_name, $key);
             }
         }
     }
     $instance['button_text'] = hocwp_get_value_by_key($new_instance, 'button_text', hocwp_get_value_by_key($this->args, 'button_text'));
     $instance['description'] = hocwp_get_value_by_key($new_instance, 'description', hocwp_get_value_by_key($this->args, 'description'));
     $instance['desc_position'] = hocwp_get_value_by_key($new_instance, 'desc_position', $this->args['desc_position']);
     $instance['captcha'] = hocwp_checkbox_post_data_value($new_instance, 'captcha');
     $instance['captcha_label'] = hocwp_get_value_by_key($new_instance, 'captcha_label', hocwp_get_value_by_key($this->args, 'captcha_label'));
     $instance['captcha_placeholder'] = hocwp_get_value_by_key($new_instance, 'captcha_placeholder', hocwp_get_value_by_key($this->args, 'captcha_placeholder'));
     $instance['register'] = hocwp_checkbox_post_data_value($new_instance, 'register');
     return $instance;
 }
Пример #23
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;
        }
    }
}
 public function add_field($args = array())
 {
     $data_type = hocwp_get_value_by_key($args, 'data_type', 'default');
     $callback = hocwp_get_value_by_key($args, 'field_callback');
     if (hocwp_callback_exists($callback)) {
         if ('hocwp_field_input_checkbox' == $callback) {
             $data_type = 'checkbox';
         } elseif ('hocwp_field_color_picker' == $callback) {
             $this->set_use_color_picker(true);
         }
     }
     $args['data_type'] = $data_type;
     $id = isset($args['id']) ? $args['id'] : '';
     $name = isset($args['name']) ? $args['name'] : '';
     $class = isset($args['class']) ? $args['class'] : '';
     if (!isset($args['field_class'])) {
         $args['field_class'] = $class;
     }
     hocwp_transmit_id_and_name($id, $name);
     $args['id'] = $id;
     $args['name'] = $name;
     if (isset($args['default'])) {
         $args['field_args']['default'] = $args['default'];
     }
     $this->fields[] = $args;
 }
 public function update($new_instance, $old_instance)
 {
     hocwp_delete_transient('hocwp_top_commenters');
     $instance = $old_instance;
     $instance['title'] = strip_tags(hocwp_get_value_by_key($new_instance, 'title'));
     $instance['number'] = hocwp_get_value_by_key($new_instance, 'number', hocwp_get_value_by_key($this->args, 'number'));
     $instance['time'] = hocwp_get_value_by_key($new_instance, 'time', hocwp_get_value_by_key($this->args, 'time'));
     $instance['exclude_users'] = hocwp_get_value_by_key($new_instance, 'exclude_users');
     $instance['show_count'] = hocwp_checkbox_post_data_value($new_instance, 'show_count');
     $instance['link_author_name'] = hocwp_checkbox_post_data_value($new_instance, 'link_author_name');
     $instance['none_text'] = hocwp_get_value_by_key($new_instance, 'none_text', hocwp_get_value_by_key($this->args, 'none_text'));
     return $instance;
 }
Пример #26
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;
    }
}
Пример #27
0
function hocwp_wpseo_internallink_value($key)
{
    $wpseo_internallinks = hocwp_wpseo_internallinks();
    return hocwp_get_value_by_key($wpseo_internallinks, $key);
}
Пример #28
0
function hocwp_facebook_comment($args = array())
{
    $args = apply_filters('hocwp_facebook_comment_args', $args);
    $colorscheme = isset($args['colorscheme']) ? $args['colorscheme'] : 'light';
    $colorscheme = apply_filters('hocwp_facebook_comment_colorscheme', $colorscheme, $args);
    $href = isset($args['href']) ? $args['href'] : '';
    if (empty($href)) {
        if (is_single() || is_page() || is_singular()) {
            $href = get_the_permalink();
        }
    }
    if (empty($href)) {
        $href = $this->get_current_url();
    }
    $href = apply_filters('hocwp_facebook_comment_href', $href, $args);
    $mobile = isset($args['mobile']) ? $args['mobile'] : '';
    $num_posts = isset($args['num_posts']) ? $args['num_posts'] : 10;
    $num_posts = apply_filters('hocwp_facebook_comment_num_posts', $num_posts, $args);
    $order_by = isset($args['order_by']) ? $args['order_by'] : 'social';
    $width = isset($args['width']) ? $args['width'] : '100%';
    $width = apply_filters('hocwp_facebook_comment_width', $width, $args);
    $loading_text = hocwp_get_value_by_key($args, 'loading_text', __('Loading...', 'hocwp-theme'));
    $div = new HOCWP_HTML('div');
    $div->set_class('fb-comments');
    $atts = array('data-colorscheme' => $colorscheme, 'data-href' => $href, 'data-mobile' => $mobile, 'data-numposts' => $num_posts, 'data-order-by' => $order_by, 'data-width' => $width);
    $atts = apply_filters('hocwp_facebook_comment_attributes', $atts, $args);
    $div->set_attribute_array($atts);
    $div->set_text($loading_text);
    $div->output();
}
Пример #29
0
function hocwp_social_login_google_ajax_callback()
{
    $result = array('redirect_to' => '', 'logged_in' => false);
    $data = hocwp_get_method_value('data');
    $data = hocwp_json_string_to_array($data);
    $connect = hocwp_get_method_value('connect');
    if (hocwp_array_has_value($data)) {
        $verified = (bool) hocwp_get_value_by_key($data, 'verified');
        $allow_not_verified = apply_filters('hocwp_allow_social_user_signup_not_verified', true);
        if ($verified || $allow_not_verified) {
            $id = hocwp_get_value_by_key($data, 'id');
            $requested_redirect_to = hocwp_get_method_value('redirect_to');
            $redirect_to = home_url('/');
            $transient_name = hocwp_build_transient_name('hocwp_social_login_google_%s', $id);
            $user_id = get_transient($transient_name);
            $user = get_user_by('id', $user_id);
            if ($connect && is_user_logged_in()) {
                $user = wp_get_current_user();
                $user_id = $user->ID;
            }
            $find_users = get_users(array('meta_key' => 'google', 'meta_value' => $id));
            if (hocwp_array_has_value($find_users)) {
                $user = $find_users[0];
                $user_id = $user->ID;
            }
            if (false === $user_id || !hocwp_id_number_valid($user_id) || !is_a($user, 'WP_User') || $connect) {
                $avatar = hocwp_get_value_by_key($data, array('image', 'url'));
                if ($connect) {
                    update_user_meta($user_id, 'google', $id);
                    update_user_meta($user_id, 'avatar', $avatar);
                    update_user_meta($user_id, 'google_data', $data);
                    $result['redirect_to'] = get_edit_profile_url($user_id);
                    $result['logged_in'] = true;
                } else {
                    $email = hocwp_get_value_by_key($data, array('emails', 0, 'value'));
                    if (is_email($email)) {
                        $name = hocwp_get_value_by_key($data, 'displayName');
                        $first_name = hocwp_get_value_by_key($data, array('name', 'givenName'));
                        $last_name = hocwp_get_value_by_key($data, array('name', 'familyName'));
                        $password = wp_generate_password();
                        $user_id = null;
                        if (username_exists($email)) {
                            $user = get_user_by('login', $email);
                            $user_id = $user->ID;
                        } elseif (email_exists($email)) {
                            $user = get_user_by('email', $email);
                            $user_id = $user->ID;
                        }
                        $old_user = true;
                        if (!hocwp_id_number_valid($user_id)) {
                            $user_data = array('username' => $email, 'email' => $email, 'password' => $password);
                            $user_id = hocwp_add_user($user_data);
                            if (hocwp_id_number_valid($user_id)) {
                                $old_user = false;
                            }
                        }
                        if (hocwp_id_number_valid($user_id)) {
                            $user = get_user_by('id', $user_id);
                            $redirect_to = apply_filters('login_redirect', $redirect_to, $requested_redirect_to, $user);
                            if (!$old_user) {
                                update_user_meta($user_id, 'google', $id);
                                $user_data = array('ID' => $user_id, 'display_name' => $name, 'first_name' => $first_name, 'last_name' => $last_name);
                                wp_update_user($user_data);
                                update_user_meta($user_id, 'avatar', $avatar);
                                update_user_meta($user_id, 'google_data', $data);
                            }
                            hocwp_user_force_login($user_id);
                            $result['redirect_to'] = $redirect_to;
                            $result['logged_in'] = true;
                            set_transient($transient_name, $user_id, DAY_IN_SECONDS);
                        }
                    }
                }
            } else {
                update_user_meta($user_id, 'google_data', $data);
                $user = get_user_by('id', $user_id);
                $redirect_to = apply_filters('login_redirect', $redirect_to, $requested_redirect_to, $user);
                hocwp_user_force_login($user_id);
                $result['redirect_to'] = $redirect_to;
                $result['logged_in'] = true;
            }
        }
    }
    wp_send_json($result);
}
 public function update($new_instance, $old_instance)
 {
     $instance = $old_instance;
     $instance['title'] = strip_tags(hocwp_get_value_by_key($new_instance, 'title'));
     $instance['feedburner_name'] = hocwp_get_value_by_key($new_instance, 'feedburner_name');
     $instance['button_text'] = hocwp_get_value_by_key($new_instance, 'button_text', hocwp_get_value_by_key($this->args, 'button_text'));
     $instance['placeholder'] = hocwp_get_value_by_key($new_instance, 'placeholder', hocwp_get_value_by_key($this->args, 'placeholder'));
     $instance['description'] = hocwp_get_value_by_key($new_instance, 'description', hocwp_get_value_by_key($this->args, 'description'));
     $instance['desc_position'] = hocwp_get_value_by_key($new_instance, 'desc_position', $this->args['desc_position']);
     return $instance;
 }