ID, 'storecommerce-meta-content-alignment', true);
if (!empty($post_options)) {
$page_layout = $post_options;
} else {
$page_layout = $global_alignment;
}
}
if ( function_exists('is_woocommerce') && is_woocommerce() ) {
$store_alignment = storecommerce_get_option('store_global_alignment');
if (!empty($store_alignment)) {
$page_layout = $store_alignment;
} else {
$page_layout = $global_alignment;
}
}
if ($page_layout == 'align-content-right') {
if ( is_front_page() ) {
if (is_page_template('tmpl-front-page.php')) {
$classes[] = 'full-width-content';
} else {
if (function_exists('is_woocommerce') && is_woocommerce()){
if (is_active_sidebar('shop-sidebar-widgets')) {
$classes[] = 'align-content-right';
} else {
$classes[] = 'full-width-content';
}
} else {
if (is_active_sidebar('sidebar-1')) {
$classes[] = 'align-content-right';
} else {
$classes[] = 'full-width-content';
}
}
}
} else {
if (function_exists('is_woocommerce') && is_woocommerce()){
if (is_active_sidebar('shop-sidebar-widgets')) {
$classes[] = 'align-content-right';
} else {
$classes[] = 'full-width-content';
}
} else {
if (is_active_sidebar('sidebar-1')) {
$classes[] = 'align-content-right';
} else {
$classes[] = 'full-width-content';
}
}
}
} elseif ($page_layout == 'full-width-content') {
$classes[] = 'full-width-content';
} else {
if ( is_front_page() ) {
if (is_page_template('tmpl-front-page.php')) {
$classes[] = 'full-width-content';
} else {
if (function_exists('is_woocommerce') && is_woocommerce()){
if (is_active_sidebar('shop-sidebar-widgets')) {
$classes[] = 'align-content-left';
} else {
$classes[] = 'full-width-content';
}
} else {
if (is_active_sidebar('sidebar-1')) {
$classes[] = 'align-content-left';
} else {
$classes[] = 'full-width-content';
}
}
}
} else {
if (function_exists('is_woocommerce') && is_woocommerce()){
if (is_active_sidebar('shop-sidebar-widgets')) {
$classes[] = 'align-content-left';
} else {
$classes[] = 'full-width-content';
}
} else {
if (is_active_sidebar('sidebar-1')) {
$classes[] = 'align-content-left';
} else {
$classes[] = 'full-width-content';
}
}
}
}
return $classes;
}
add_filter('body_class', 'storecommerce_body_classes');
/**
* Add a pingback url auto-discovery header for single posts, pages, or attachments.
*/
function storecommerce_pingback_header()
{
if (is_singular() && pings_open()) {
echo '';
}
}
add_action('wp_head', 'storecommerce_pingback_header');
if (!function_exists('storecommerce_post_categories')) :
function storecommerce_post_categories($separator = ' ', $taxonomy = 'product_cat')
{
// Hide category and tag text for pages.
//if ('post' === get_post_type()) {
global $post;
//print_pre($post);
$post_categories = get_the_terms($post->ID, $taxonomy);
if ($post_categories) {
$output = '
';
foreach ($post_categories as $post_category) {
$t_id = $post_category->term_id;
$color_id = "category_color_" . $t_id;
// retrieve the existing value(s) for this meta field. This returns an array
$term_meta = get_option($color_id);
$color_class = ($term_meta) ? $term_meta['color_class_term_meta'] : 'category-color-1';
$output .= '-
' . esc_html($post_category->name) . '
';
}
$output .= '
';
echo $output;
}
// }
}
endif;
if (!function_exists('storecommerce_get_block')) :
/**
*
* @since StoreCommerce 1.0.0
*
* @param null
* @return null
*
*/
function storecommerce_get_block($block = '')
{
if (!empty($block)) {
get_template_part('inc/blocks/block', $block);
}
}
endif;
if (!function_exists('storecommerce_archive_title')) :
/**
*
* @since Magazine 7 1.0.0
*
* @param null
* @return null
*
*/
function storecommerce_archive_title($title)
{
if (is_category()) {
$title = single_cat_title('', false);
} elseif (is_tag()) {
$title = single_tag_title('', false);
} elseif (is_author()) {
$title = '' . get_the_author() . '';
} elseif (is_post_type_archive()) {
$title = post_type_archive_title('', false);
} elseif (is_tax()) {
$title = single_term_title('', false);
}
return $title;
}
endif;
add_filter('get_the_archive_title', 'storecommerce_archive_title');
if (!function_exists('storecommerce_get_category_color_class')) :
function storecommerce_get_category_color_class($term_id)
{
$color_id = "category_color_" . $term_id;
// retrieve the existing value(s) for this meta field. This returns an array
$term_meta = get_option($color_id);
$color_class = ($term_meta) ? $term_meta['color_class_term_meta'] : '';
return $color_class;
}
endif;
/**
* Descriptions on Header Menu
* @author AF themes
* @param string $item_output , HTML outputp for the menu item
* @param object $item , menu item object
* @param int $depth , depth in menu structure
* @param object $args , arguments passed to wp_nav_menu()
* @return string $item_output
*/
function storecommerce_header_menu_desc($item_output, $item, $depth, $args)
{
if ('aft-primary-nav' == $args->theme_location && $item->description)
$item_output = str_replace('', '', $item_output);
return $item_output;
}
add_filter('walker_nav_menu_start_el', 'storecommerce_header_menu_desc', 10, 4);
if (!function_exists('storecommerce_post_item_meta')) :
function storecommerce_post_item_meta()
{
global $post;
$author_id = $post->post_author;
$display_setting = storecommerce_get_option('global_post_date_author_setting');
?>
' . esc_html('Tags: %1$s') . '', $tags_list); // WPCS: XSS OK.
}
}
if (is_single()) {
edit_post_link(
sprintf(
wp_kses(
/* translators: %s: Name of current post. Only visible to screen readers */
__('Edit %s', 'storecommerce'),
array(
'span' => array(
'class' => array(),
),
)
),
get_the_title()
),
'',
''
);
}
}
endif;
if (!function_exists('storecommerce_get_products')) :
/**
* @param $number_of_products
* @param $category
* @param $show
* @param $orderby
* @param $order
* @return WP_Query
*/
function storecommerce_get_products($number_of_products = '4', $category = 0, $show = '', $orderby = 'date', $order = 'DESC')
{
$product_visibility_term_ids = wc_get_product_visibility_term_ids();
$query_args = array(
'posts_per_page' => $number_of_products,
'post_status' => 'publish',
'post_type' => 'product',
'no_found_rows' => 1,
'order' => $order,
'meta_query' => array(),
'tax_query' => array(
'relation' => 'AND',
),
);
if (absint($category) > 0) {
$query_args['tax_query'][] = array(
'taxonomy' => 'product_cat',
'field' => 'term_id',
'terms' => $category
);
}
switch ($show) {
case 'featured' :
$query_args['tax_query'][] = array(
'taxonomy' => 'product_visibility',
'field' => 'term_id',
'terms' => $product_visibility_term_ids['featured'],
);
break;
case 'onsale' :
$product_ids_on_sale = wc_get_product_ids_on_sale();
$product_ids_on_sale[] = 0;
$query_args['post__in'] = $product_ids_on_sale;
break;
}
switch ($orderby) {
case 'price' :
$query_args['meta_key'] = '_price';
$query_args['orderby'] = 'meta_value_num';
break;
case 'rand' :
$query_args['orderby'] = 'rand';
break;
case 'sales' :
$query_args['meta_key'] = 'total_sales';
$query_args['orderby'] = 'meta_value_num';
break;
default :
$query_args['orderby'] = 'date';
}
return new WP_Query(apply_filters('storecommerce_widget_query_args', $query_args));
}
endif;
if (!function_exists('storecommerce_get_featured_image')):
function storecommerce_get_featured_image($post_id, $size = 'storecommerce-featured')
{
if (has_post_thumbnail()) {
$thumb = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), $size);
$url = $thumb['0'];
} else {
$url = '';
}
return $url;
}
endif;
if (!function_exists('storecommerce_product_loop')):
function storecommerce_product_loop($all_posts)
{ ?>
have_posts()): $all_posts->the_post();
$url = storecommerce_get_featured_image(get_the_ID());
?>
-
name;
$term_link = get_term_link($term);
$products_count = storecommerce_product_count($term->term_id);
$products_count = ($product_count == 'true') ? $products_count : 0;
$meta = get_term_meta($category);
if (isset($meta['thumbnail_id'])) {
$thumb_id = $meta['thumbnail_id'][0];
$thumb_url = wp_get_attachment_image_src($thumb_id, 'storecommerce-medium-center');
$url = $thumb_url[0];
} else {
$url = '';
}
?>
0): ?>
%sitem', '%sitems', $products_count, 'storecommerce'), number_format_i18n($products_count)); ?>