theme_location ) {
if ( in_array( 'menu-item-has-children', $item->classes, true ) ) {
$args->after = ' ';
} else {
$args->after = '';
}
}
return $args;
}
}
add_filter( 'nav_menu_item_args', 'cordero_primary_menu_sub_trigger', 10, 2 );
if ( !function_exists( 'cordero_primary_menu_fallback' ) ) {
function cordero_primary_menu_fallback() {
echo '
';
}
}
if ( !function_exists( 'cordero_footer_menu_fallback' ) ) {
function cordero_footer_menu_fallback() {
if ( function_exists( 'the_privacy_policy_link' ) ) {
echo '';
the_privacy_policy_link( '', '' );
echo '
';
}
}
}
if ( !function_exists( 'cordero_custom_excerpt_length' ) ) {
function cordero_custom_excerpt_length( $length ) {
if ( is_admin() ) {
return $length;
} else {
return get_theme_mod( 'excerpt_length', '20' );
}
}
}
add_filter( 'excerpt_length', 'cordero_custom_excerpt_length', 999 );
if ( !function_exists( 'cordero_excerpt_more' ) ) {
function cordero_excerpt_more( $more ) {
if ( is_admin() ) {
return $more;
} else {
return '…';
}
}
}
add_filter( 'excerpt_more', 'cordero_excerpt_more' );
if ( !function_exists( 'cordero_archive_title_prefix' ) ) {
function cordero_archive_title_prefix( $title ) {
if ( is_category() ) {
$title = single_cat_title( '', false );
} elseif ( is_tag() ) {
$title = single_tag_title( '', false );
} elseif ( is_author() ) {
$title = '' . get_avatar( get_the_author_meta( 'ID' ), '90' ) . esc_html( get_the_author() ) . ' ';
}
return $title;
}
}
add_filter( 'get_the_archive_title', 'cordero_archive_title_prefix' );
if ( !function_exists( 'cordero_header_menu' ) ) {
function cordero_header_menu() {
$header_layout = get_theme_mod( 'header_layout', '' );
?>
>
'primary',
'menu_id' => 'primary-menu',
'fallback_cb' => 'cordero_primary_menu_fallback',
)
); ?>
>>
>
>>
>
'custom-logo',
);
if ( is_front_page() ) {
/*
* If on the home page, set the logo alt attribute to an empty string,
* as the image is decorative and doesn't need its purpose to be described.
*/
$custom_logo_attr['alt'] = '';
} else {
/*
* If the logo alt attribute is empty, get the site title and explicitly pass it
* to the attributes used by wp_get_attachment_image().
*/
$image_alt = get_post_meta( $custom_logo_id, '_wp_attachment_image_alt', true );
if ( empty( $image_alt ) ) {
$custom_logo_attr['alt'] = get_bloginfo( 'name', 'display' );
}
}
/*
* If the alt attribute is not empty, there's no need to explicitly pass it
* because wp_get_attachment_image() already adds the alt attribute.
*/
$image = wp_get_attachment_image( $custom_logo_id, 'full', false, $custom_logo_attr );
if ( is_front_page() ) {
// If on the home page, don't link the logo to home.
$html = sprintf(
'%1$s ',
$image
);
} else {
$html = sprintf(
'%2$s ',
esc_url( home_url( '/' ) ),
$image
);
}
} elseif ( is_customize_preview() ) {
// If no logo is set but we're in the Customizer, leave a placeholder (needed for the live preview).
$html = sprintf(
' ',
esc_url( home_url( '/' ) )
);
}
echo $html;
}
}
if ( !function_exists( 'cordero_header_content_customizer' ) ) {
function cordero_header_content_customizer() {
cordero_site_branding_start();
?>
>>
>
>>
>
>
yith_wcwl_count_all_products()
) );
}
}
}
add_action( 'wp_ajax_yith_wcwl_update_wishlist_count', 'cordero_update_wishlist_count' );
add_action( 'wp_ajax_nopriv_yith_wcwl_update_wishlist_count', 'cordero_update_wishlist_count' );
if ( !function_exists( 'cordero_header_cart' ) ) {
function cordero_header_cart() {
if ( class_exists( 'WooCommerce' ) ) {
$cart_items = WC()->cart->get_cart_contents_count();
if ( $cart_items > 0 ) {
$cart_class = ' items';
} else {
$cart_class = '';
} ?>
cart->get_cart_contents_count();
if ( $cart_items > 0 ) {
$cart_class = ' items';
} else {
$cart_class = '';
}
ob_start();
?>
';
}
}
if ( !function_exists( 'cordero_before_shop_loop_item_title' ) ) {
function cordero_before_shop_loop_item_title() {
global $product;
$attachment_ids = $product->get_gallery_image_ids();
if ( $attachment_ids && $product->get_image_id() ) {
echo '';
}
echo '';
}
}
if ( !function_exists( 'cordero_before_shop_loop_cat_title' ) ) {
function cordero_before_shop_loop_cat_title() {
echo '
';
}
}
if ( !function_exists( 'cordero_after_shop_loop_item_title' ) ) {
function cordero_after_shop_loop_item_title() {
echo '
';
}
}
if ( !function_exists( 'cordero_before_shop_loop_addtocart' ) ) {
function cordero_before_shop_loop_addtocart() {
echo '
';
}
}
if ( !function_exists( 'cordero_after_shop_loop_addtocart' ) ) {
function cordero_after_shop_loop_addtocart() {
echo '
';
}
}
if ( !function_exists( 'cordero_after_subcategory' ) ) {
function cordero_after_subcategory() {
echo '';
}
}
if ( !function_exists( 'cordero_shop_filter_section' ) ) {
function cordero_shop_filter_section() {
if ( !is_product() ) {
get_sidebar( 'shop-filters' );
}
}
}
if ( !function_exists( 'cordero_theme_wrapper_start' ) ) {
function cordero_theme_wrapper_start() {
if ( !is_active_sidebar( 'cordero-sidebar-shop' ) || is_product() || get_theme_mod( 'sidebar_position' ) === 'below' ) {
$page_full_width = ' full-width';
} else {
$page_full_width = '';
}
cordero_before_primary_content();
echo '
';
}
}
if ( !function_exists( 'cordero_theme_wrapper_end' ) ) {
function cordero_theme_wrapper_end() {
echo '
';
cordero_after_primary_content();
if ( !is_product() ) {
get_sidebar( 'shop' );
}
}
}
if ( !function_exists( 'cordero_change_prev_next' ) ) {
function cordero_change_prev_next( $args ) {
$args['prev_text'] = ' ';
$args['next_text'] = ' ';
return $args;
}
}
add_filter( 'woocommerce_pagination_args', 'cordero_change_prev_next' );
if ( !function_exists( 'cordero_woocommerce_placeholder_img_src' ) ) {
function cordero_woocommerce_placeholder_img_src() {
return esc_url( get_template_directory_uri() ) . '/images/woocommerce-placeholder.png';
}
}
if ( !get_option( 'woocommerce_placeholder_image', 0 ) ) {
add_filter('woocommerce_placeholder_img_src', 'cordero_woocommerce_placeholder_img_src');
}
if ( !function_exists( 'cordero_upsell_products_args' ) ) {
function cordero_upsell_products_args( $args ) {
$col_per_page = esc_attr( get_option( 'woocommerce_catalog_columns', 5 ) );
$args['posts_per_page'] = $col_per_page;
$args['columns'] = $col_per_page;
return $args;
}
}
add_filter( 'woocommerce_upsell_display_args', 'cordero_upsell_products_args' );
if ( !function_exists( 'cordero_related_products_args' ) ) {
function cordero_related_products_args( $args ) {
$col_per_page = esc_attr( get_option( 'woocommerce_catalog_columns', 5 ) );
$args['posts_per_page'] = $col_per_page;
$args['columns'] = $col_per_page;
return $args;
}
}
add_filter( 'woocommerce_output_related_products_args', 'cordero_related_products_args' );
if ( !function_exists( 'cordero_woocommerce_gallery_thumbnail_size' ) ) {
function cordero_woocommerce_gallery_thumbnail_size( $size ) {
return 'woocommerce_thumbnail';
}
}
add_filter( 'woocommerce_gallery_thumbnail_size', 'cordero_woocommerce_gallery_thumbnail_size' );
/*
* see: woocommerce/packages/woocommerce-blocks/src/BlockTypes/AbstractProductGrid.php
*/
if ( !function_exists( 'cordero_wc_product_block' ) ) {
function cordero_wc_product_block( $html, $data, $product ) {
$html = '
' . $data->image . '
' . cordero_wc_block_extra_img( $product ) . '
' . $data->title . '
' . $data->badge . '
' . $data->price . '
' . $data->rating . '
' . $data->button . '
';
return $html;
}
}
add_filter( 'woocommerce_blocks_product_grid_item_html', 'cordero_wc_product_block', 10, 3);
if ( !function_exists( 'cordero_wc_block_extra_img' ) ) {
function cordero_wc_block_extra_img( $product ) {
$attachment_ids = $product->get_gallery_image_ids();
if ( $attachment_ids && $product->get_image_id() ) {
return '';
}
}
}
/**
* Exclude custom logo image from Jetpack lazy load
*/
if(!function_exists( 'cordero_exclude_class_from_lazy_load' )){
function cordero_exclude_class_from_lazy_load( $classes ) {
$classes[] = 'custom-logo';
return $classes;
}
}
add_filter( 'jetpack_lazy_images_blocked_classes', 'cordero_exclude_class_from_lazy_load', 999, 1 );
/**
* Disable image scaling
* since WP 5.3 any uploaded image larger than 2560px (height or width) is scaled to max 2560px
*/
add_filter( 'big_image_size_threshold', '__return_false' );