示例#1
0
function hocwp_get_option_post($option_name, $slug, $option_base = 'hocwp_theme_setting')
{
    $options = get_option($option_base);
    $post_id = hocwp_get_value_by_key($options, $option_name);
    if (hocwp_id_number_valid($post_id)) {
        $result = get_post($post_id);
    } else {
        $result = hocwp_get_post_by_slug($slug);
    }
    if (!is_a($result, 'WP_Post')) {
        $result = new WP_Error();
    }
    return apply_filters('hocwp_get_option_post', $result, $option_name, $slug, $option_base);
}
示例#2
0
function hocwp_get_page_by_slug($slug)
{
    return hocwp_get_post_by_slug($slug, 'page');
}
示例#3
0
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>';
    }
}