Example #1
0
function hocwp_is_table_exists($table_name)
{
    global $wpdb;
    if (!hocwp_string_contain($table_name, $wpdb->prefix)) {
        $table_name = $wpdb->prefix . $table_name;
    }
    $result = $wpdb->get_var("SHOW TABLES LIKE '{$table_name}'");
    if (empty($result)) {
        return false;
    }
    return true;
}
    public function default_setting_page_callback()
    {
        $parent_slug = $this->get_parent_slug();
        if (empty($parent_slug)) {
            return;
        }
        $disable_sidebar = (bool) $this->disable_sidebar;
        $title = $this->get_heading_text();
        if ($this->is_option_page() && !hocwp_string_contain(strtolower($title), 'settings') && !hocwp_string_contain(strtolower($title), 'options')) {
            hocwp_add_string_with_space_before($title, 'Settings');
        }
        $wrap_class = $this->get_option_name_no_prefix();
        $wrap_class = hocwp_sanitize($wrap_class, 'html_class');
        hocwp_add_string_with_space_before($wrap_class, 'wrap hocwp option-page');
        if (!$disable_sidebar) {
            hocwp_add_string_with_space_before($wrap_class, 'has-sidebar');
        }
        ?>
		<div class="<?php 
        echo $wrap_class;
        ?>
">
			<h1 class="page-title"><?php 
        echo esc_html($title) . $this->get_page_title_action();
        ?>
</h1>
			<?php 
        $header_callback = $this->get_page_header_callback();
        if (hocwp_callback_exists($header_callback)) {
            call_user_func($header_callback);
        }
        $page_content_class = 'page-content';
        if ($disable_sidebar) {
            hocwp_add_string_with_space_before($page_content_class, 'no-sidebar');
        }
        ?>
			<div class="<?php 
        echo $page_content_class;
        ?>
">
				<?php 
        if ((bool) $this->disable_sidebar) {
            if ($this->is_option_page()) {
                if ($this->is_this_page() && (isset($_REQUEST['submit']) || isset($_REQUEST['settings-updated']))) {
                    do_action('hocwp_option_saved');
                    if ('options-general.php' != $this->get_parent_slug() && !$this->get_exists()) {
                        hocwp_admin_notice_setting_saved();
                    }
                    do_action($this->get_menu_slug() . '_option_saved', $this);
                }
                $this->form();
            }
            do_action('hocwp_option_page_content');
            do_action('hocwp_option_page_' . $this->get_option_name_no_prefix() . '_content');
        } else {
            ?>
					<div class="sidebar">
						<?php 
            $sidebar_callback = $this->get_page_sidebar_callback();
            if (hocwp_callback_exists($sidebar_callback)) {
                call_user_func($sidebar_callback);
            }
            ?>
					</div>
					<div class="main main-content">
						<?php 
            if ($this->is_option_page()) {
                if ($this->is_this_page() && (isset($_REQUEST['submit']) || isset($_REQUEST['settings-updated']))) {
                    do_action('hocwp_option_saved');
                    if ('options-general.php' != $this->get_parent_slug() && !$this->get_exists()) {
                        hocwp_admin_notice_setting_saved();
                    }
                    do_action($this->get_menu_slug() . '_option_saved', $this);
                }
                $this->form();
            }
            do_action('hocwp_option_page_content');
            do_action('hocwp_option_page_' . $this->get_option_name_no_prefix() . '_content');
            ?>
					</div>
					<?php 
        }
        ?>
			</div>
			<?php 
        $footer_callback = $this->get_page_footer_callback();
        if (hocwp_callback_exists($footer_callback)) {
            call_user_func($footer_callback);
        }
        ?>
		</div>
		<?php 
    }
Example #3
0
function hocwp_video_play($args = array())
{
    $post_id = isset($args['post_id']) ? $args['post_id'] : get_the_ID();
    $video_url = get_post_meta($post_id, 'video_url', true);
    $video_code = get_post_meta($post_id, 'video_code', true);
    if (empty($video_url) && empty($video_code)) {
        if (hocwp_automatic_video_posts_installed()) {
            $video_url = get_post_meta($post_id, '_ayvpp_video_url', true);
        }
    }
    $autoplay = isset($args['autoplay']) ? $args['autoplay'] : false;
    $width = isset($args['width']) ? $args['width'] : '';
    $height = isset($args['height']) ? $args['height'] : '';
    $rel = isset($args['rel']) ? $args['rel'] : false;
    $cc = isset($args['cc_load_policy']) ? $args['cc_load_policy'] : false;
    $iv = isset($args['iv_load_policy']) ? $args['iv_load_policy'] : false;
    $showinfo = isset($args['showinfo']) ? $args['showinfo'] : false;
    $player_id = hocwp_get_value_by_key($args, 'player_id', 'hocwp_player');
    if (empty($player_id)) {
        $player_id = 'hocwp_player';
    }
    if (!empty($video_code)) {
        if ($height > 0) {
            $video_code = preg_replace('/height="(.*?)"/i', 'height="' . $height . '"', $video_code);
        }
        if ($width > 0) {
            $video_code = preg_replace('/width="(.*?)"/i', 'width="' . $width . '"', $video_code);
        }
        $video_code = preg_replace('/id="(.*?)"/i', 'id="' . $player_id . '"', $video_code);
        if (!hocwp_string_contain($video_code, 'id="')) {
            $video_code = str_replace('<iframe', '<iframe id="' . $player_id . '"', $video_code);
        }
        $video_code = apply_filters('hocwp_video_code_result', $video_code, $args);
        echo $video_code;
    } else {
        if (!empty($video_url)) {
            $video_args = array('rel' => 0, 'showinfo' => 0, 'cc_load_policy' => 0, 'iv_load_policy' => 3, 'start' => 1);
            if ($showinfo) {
                $video_args['showinfo'] = 1;
            }
            if ($cc) {
                $video_args['cc_load_policy'] = 1;
            }
            if ($iv) {
                $video_args['iv_load_policy'] = 1;
            }
            if ((bool) $autoplay) {
                $video_args['autoplay'] = 1;
            }
            if ($rel) {
                $video_args['rel'] = 1;
            }
            $video_args = apply_filters('hocwp_embed_video_args', $video_args);
            $html = wp_oembed_get($video_url, $video_args);
            if ($height > 0) {
                $html = preg_replace('/height="(.*?)"/i', 'height="' . $height . '"', $html);
            }
            if ($width > 0) {
                $html = preg_replace('/width="(.*?)"/i', 'width="' . $width . '"', $html);
            }
            $html = preg_replace('/id="(.*?)"/i', 'id="' . $player_id . '"', $html);
            if (!hocwp_string_contain($html, 'id="')) {
                $html = str_replace('<iframe', '<iframe id="' . $player_id . '"', $html);
            }
            $html = apply_filters('hocwp_embed_video_result', $html, $video_args);
            echo $html;
        }
    }
    $video_id = get_post_meta($post_id, 'video_id', true);
    if (!empty($video_id)) {
        $video_server = get_post_meta($post_id, 'video_server', true);
        if ('youtube' == $video_server) {
        }
    }
}
Example #4
0
function hocwp_query_post_by_format($format, $args = array())
{
    if (is_string($format) && !hocwp_string_contain($format, 'post-format-')) {
        $format = 'post-format-' . $format;
    }
    if (!is_array($format)) {
        $format = array($format);
    }
    $item = array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => $format);
    hocwp_query_sanitize_tax_query($item, $args);
    return hocwp_query($args);
}
function hocwp_setup_theme_kk_star_rating_legend($legend, $post_id)
{
    $edit = false;
    if (hocwp_string_contain($legend, '[total]')) {
        $edit = true;
    } elseif (hocwp_string_contain($legend, '[avg]')) {
        $edit = true;
    } elseif (hocwp_string_contain($legend, '[per]')) {
        $edit = true;
    } elseif (hocwp_string_contain($legend, '[s]')) {
        $edit = true;
    }
    if ($edit) {
        $id = $post_id;
        $title = get_the_title($id);
        $best = get_option('kksr_stars');
        $score = get_post_meta($id, '_kksr_ratings', true);
        if (!hocwp_is_positive_number($score)) {
            $score = 0;
        }
        if ($score) {
            $votes = get_post_meta($id, '_kksr_casts', true);
            if (!hocwp_is_positive_number($votes)) {
                $votes = 0;
            }
            $avg = $score ? round((double) ($score / $votes * ($best / 5)), 2) : 0;
            $per = $score ? round((double) ($score / $votes / 5 * 100), 2) : 0;
            $leg = str_replace('[total]', '<span property="ratingCount">' . $votes . '</span>', $legend);
            $leg = str_replace('[avg]', '<span property="ratingValue">' . $avg . '</span>', $leg);
            $leg = str_replace('[per]', $per . '%', $leg);
            $leg = str_replace('[s]', $votes == 1 ? '' : 's', $leg);
            $kksr_grs = get_option('kksr_grs');
            if ((bool) $kksr_grs) {
                $snippet = '<div vocab="http://schema.org/" typeof="Blog">';
                $snippet .= '<div property="name" class="kksr-title">' . $title . '</div>';
                $snippet .= '<div property="aggregateRating" typeof="AggregateRating">';
                $snippet .= $leg;
                $snippet .= '<meta property="bestRating" content="' . $best . '"/>';
                $snippet .= '<meta property="worstRating" content="1"/>';
                $snippet .= '</div>';
                $snippet .= '</div>';
                $leg = $snippet;
            }
            $legend = $leg;
        }
    }
    return $legend;
}
Example #6
0
function hocwp_sidebar_has_widget($sidebar, $widget)
{
    $sidebar_name = $sidebar;
    $sidebars = hocwp_get_sidebars();
    $sidebar = isset($sidebars[$sidebar]) ? $sidebars[$sidebar] : '';
    if (!empty($sidebar)) {
        $widgets = hocwp_get_sidebar_widgets($sidebar_name);
        foreach ($widgets as $widget_name) {
            if (hocwp_string_contain($widget_name, $widget)) {
                return true;
            }
        }
    }
    return false;
}
function hocwp_setup_theme_update_footer($text)
{
    $tmp = strtolower($text);
    if (hocwp_string_contain($tmp, 'version')) {
        $text = sprintf(__('Theme core version %s', 'hocwp-theme'), HOCWP_THEME_CORE_VERSION);
    }
    return $text;
}
function hocwp_add_unique_string(&$string, $add, $tail = true)
{
    if (empty($string)) {
        $string = $add;
    } elseif (!hocwp_string_contain($string, $add)) {
        if ($tail) {
            $string .= $add;
        } else {
            $string = $add . $string;
        }
    }
    $string = trim($string);
    return $string;
}
 private function make_outlink_nofollow()
 {
     if ('a' == strtolower($this->get_name())) {
         $href = $this->get_attribute('href');
         if (!empty($href)) {
             if (!hocwp_is_site_domain($href) && !hocwp_string_contain($href, 'javascript')) {
                 $this->set_attribute('rel', 'external nofollow');
                 $this->set_attribute('target', '_blank');
             }
         }
     }
 }
Example #10
0
function hocwp_term_icon_html($term_id, $default = '')
{
    $icon = hocwp_get_term_icon($term_id);
    $icon = hocwp_sanitize_media_value($icon);
    $icon = $icon['url'];
    if (empty($icon)) {
        $icon = $default;
    }
    if (hocwp_string_contain($icon, 'fa') || hocwp_string_contain($icon, '</i>')) {
        echo $icon;
    } else {
        if (!empty($icon)) {
            $img = new HOCWP_HTML('img');
            $img->set_image_src($icon);
            $img->output();
        }
    }
}