__('No Repeat','ecommerce-star'), 'repeat' => __('Tile','ecommerce-star'), 'repeat-x' => __('Tile Horizontally','ecommerce-star'), 'repeat-y' => __('Tile Vertically','ecommerce-star'), ); } endif; if ( ! function_exists( 'ecommerce_star_get_index_page_id' ) ) : /** * Get front index page ID. * @param string $type Type. * @return int Corresponding Page ID. */ function ecommerce_star_get_index_page_id( $type = 'front' ) { $page = ''; switch ( $type ) { case 'front': $page = get_option( 'page_on_front' ); break; case 'blog': $page = get_option( 'page_for_posts' ); break; default: break; } $page = absint( $page ); return $page; } endif; if ( ! function_exists( 'ecommerce_star_customize_page_title' ) ) : /** * Add title in Custom Header. * @since 1.0 * * @param string $title Title. * @return string Modified title. */ function ecommerce_star_customize_page_title( $title = '' ) { if ( is_home() && ( $blog_page_id = ecommerce_star_get_index_page_id( 'blog' ) ) > 0 ) { $title = get_the_title( $blog_page_id ); } elseif ( is_singular() ) { $title = get_the_title(); } elseif ( is_archive() ) { $title = strip_tags( get_the_archive_title() ); } elseif ( is_search() ) { /* translators: %s: search query input */ $title = sprintf( __( 'Search Results for: %s', 'ecommerce-star' ), get_search_query() ); } elseif ( is_404() ) { $title = __( '404!', 'ecommerce-star' ); } return $title; } endif; if ( ! function_exists( 'ecommerce_star_custom_fonts_css' ) ) : /** * ecommerce-star google font css */ function ecommerce_star_custom_fonts_css() { global $ecommerce_star_option; if ( class_exists( 'WP_Customize_Control' ) ) { $ecommerce_star_option = wp_parse_args( get_option( 'ecommerce_star_option', array() ) , ecommerce_star_settings()); } $css =' h1 , h2 , h3 , h4 , h5 , h6 , .entry-title , .page-title , .entry-meta , .callout-title , .entry-meta a { font-family:'.$ecommerce_star_option['header_fontfamily'].',sans serif; } html { font-family:'.$ecommerce_star_option['body_fontfamily'].',sans serif; } .main-navigation { font-family:'.$ecommerce_star_option['header_fontfamily'].',sans serif; } .site-title a, .testimonial-title { font-family:'.$ecommerce_star_option['header_fontfamily'].',sans serif; } #main_Carousel .slider-title { font-family:'.$ecommerce_star_option['header_fontfamily'].',sans serif; } '; return $css; } endif; if ( ! function_exists( 'ecommerce_star_posted_on' ) ) : /** * Prints HTML with meta information for the current post-date/time and author. */ function ecommerce_star_posted_on() { $byline = sprintf( // Get the author name; wrap it in a link. esc_html_x( 'By %s', 'post author', 'ecommerce-star' ), '' . esc_html( get_the_author() ) . '' ); // Finally, let's write all of this to the page. echo '' . ecommerce_star_time_link() . ' ' . $byline . ''; } endif; if ( ! function_exists( 'ecommerce_star_time_link' ) ) : /** * Gets a nicely formatted string for the published date. */ function ecommerce_star_time_link() { $time_string = ''; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { $time_string = ''; } $time_string = sprintf( $time_string, get_the_date( DATE_W3C ), get_the_date(), get_the_modified_date( DATE_W3C ), get_the_modified_date() ); $args = array( 'time'=> array('class'=> array(),'datetime'=>array())); // Wrap the time string in a link, and preface it with 'Posted on'. return sprintf( /* translators: %s: post date */ __( '%1$s %2$s', 'ecommerce-star' ), esc_html__('Posted on', 'ecommerce-star'), '' . wp_kses($time_string, $args) . '' ); } endif; if ( ! function_exists( 'ecommerce_star_entry_footer' ) ) : /** * Prints HTML with meta information for the categories, tags and comments. */ function ecommerce_star_entry_footer() { /* translators: used between list items, there is a space after the comma */ $separate_meta = __( ', ', 'ecommerce-star' ); // Get Categories for posts. $categories_list = get_the_category_list( $separate_meta ); // Get Tags for posts. $tags_list = get_the_tag_list( '', $separate_meta ); // We don't want to output .entry-footer if it will be empty, so make sure its not. if ( ( ( ecommerce_star_categorized_blog() && $categories_list ) || $tags_list ) || get_edit_post_link() ) { echo ' '; } } endif; if ( ! function_exists( 'ecommerce_star_edit_link' ) ) : /** * Returns an accessibility-friendly link to edit a post or page. * Helpful when/if the single-page * layout with multiple posts/pages shown gets confusing. */ function ecommerce_star_edit_link() { edit_post_link( sprintf( /* translators: %s: Name of current post */ __( 'Edit "%s"', 'ecommerce-star' ), esc_html(get_the_title()) ), ' ', '' ); } endif; /** * Change View cart text */ function ecommerce_star_view_cart_strings( $translated_text, $text, $domain ) { switch ( $translated_text ) { case 'View cart' : $translated_text = __( 'View', 'ecommerce-star' ); break; } return $translated_text; } add_filter( 'gettext', 'ecommerce_star_view_cart_strings', 20, 3 ); /** * Woocommerce Custom add to wishlist button * */ if ( ! function_exists( 'ecommerce_star_wishlist' ) ) { function ecommerce_star_wishlist() { if(!class_exists( 'WooCommerce' )){return;} global $product; if( function_exists( 'YITH_WCWL' ) ){ $wishlist_url = add_query_arg( 'add_to_wishlist', $product->get_id() ); ?> get_type(); } else { $prod_type = $product->product_type; } if ( function_exists( 'method_exists' ) && method_exists( $product, 'get_stock_status' ) ) { $prod_in_stock = $product->get_stock_status(); } else { $prod_in_stock = $product->is_in_stock(); } if ( $product ) { $args = array(); $defaults = array( 'quantity' => 1, 'class' => implode( ' ', array_filter( array('button', 'product_type_' . $prod_type, $product->is_purchasable() && $prod_in_stock ? 'add_to_cart_button' : '', $product->supports( 'ajax_add_to_cart' ) ? 'ajax_add_to_cart' : '',) ) ), ); $args = apply_filters( 'woocommerce_loop_add_to_cart_args', wp_parse_args( $args, $defaults ), $product ); if(locate_template('woocommerce/add-to-cart.php')){ wc_get_template( 'woocommerce/add-to-cart.php', $args ); } } } } /** * Add Cart icon and count to header if WC is active */ function ecommerce_star_wc_cart_count() { if (!class_exists('WooCommerce')) return; global $woocommerce; ?> cart->cart_contents_count); ?> cart->get_cart_total()); ?> cart->cart_contents_count); ?> cart->get_cart_total()); ?>  
'ids', 'hide_empty' => 1, // We only need to know if there is more than one category. 'number' => 2, ) ); // Count the number of categories that are attached to the posts. $category_count = count( $categories ); set_transient( 'ecommerce_star_categories', $category_count ); } // Allow viewing case of 0 or 1 categories in post preview. if ( is_preview() ) { return true; } return $category_count > 1; } /** * Flush out the transients used in ecommerce_star_categorized_blog. */ function ecommerce_star_category_transient_flusher() { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } delete_transient( 'ecommerce_star_categories' ); } add_action( 'edit_category', 'ecommerce_star_category_transient_flusher' ); add_action( 'save_post', 'ecommerce_star_category_transient_flusher' ); /** * Replaces "[...]" (appended to automatically generated excerpts) with ... and * a 'Continue reading' link. * * @since ecommerce-star 1.0 * * @param string $link Link to single post/page. * @return string 'Continue reading' link prepended with an ellipsis. */ function ecommerce_star_excerpt_more( $link ) { if ( is_admin() ) { return $link; } $link = sprintf( '', esc_url( get_permalink( get_the_ID() ) ), /* translators: %s: Name of current post */ sprintf( __( 'Continue reading "%s"', 'ecommerce-star' ), esc_html(get_the_title( get_the_ID() )) ) ); return ' … ' . $link; } add_filter( 'excerpt_more', 'ecommerce_star_excerpt_more' ); /** * Handles JavaScript detection. * * Adds a `js` class to the root `` element when JavaScript is detected. * * @since ecommerce-star 1.0 */ function ecommerce_star_javascript_detection() { echo "\n"; } add_action( 'wp_head', 'ecommerce_star_javascript_detection', 0 ); /** * Add a pingback url auto-discovery header for singularly identifiable articles. */ function ecommerce_star_pingback_header() { if ( is_singular() && pings_open() ) { printf( '' . "\n", esc_url(get_bloginfo( 'pingback_url' )) ); } } add_action( 'wp_head', 'ecommerce_star_pingback_header' ); /** * Add custom image sizes attribute to enhance responsive image functionality * for content images. * * @since ecommerce-star 1.0 * * @param string $sizes A source size value for use in a 'sizes' attribute. * @param array $size Image size. Accepts an array of width and height values in pixels (in that order). * @return string A source size value for use in a content image 'sizes' attribute. */ function ecommerce_star_content_image_sizes_attr( $sizes, $size ) { $width = $size[0]; if ( 740 <= $width ) { $sizes = '(max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px'; } if ( is_active_sidebar( 'sidebar-1' ) || is_archive() || is_search() || is_home() || is_page() ) { global $ecommerce_star_option; if ( ! ( is_page() && 1 != $ecommerce_star_option['layout_section_post_one_column'] ) && 767 <= $width ) { $sizes = '(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px'; } } return $sizes; } add_filter( 'wp_calculate_image_sizes', 'ecommerce_star_content_image_sizes_attr', 10, 2 ); /** * Filter the `sizes` value in the header image markup. * * @since ecommerce-star 1.0 * * @param string $html The HTML image tag markup being filtered. * @param object $header The custom header object returned by 'get_custom_header()'. * @param array $attr Array of the attributes for the image tag. * @return string The filtered header image HTML. */ function ecommerce_star_header_image_tag( $html, $header, $attr ) { if ( isset( $attr['sizes'] ) ) { $html = str_replace( $attr['sizes'], '100vw', $html ); } return $html; } add_filter( 'get_header_image_tag', 'ecommerce_star_header_image_tag', 10, 3 ); /** * Add custom image sizes attribute to enhance responsive image functionality * for post thumbnails. * * @since ecommerce-star 1.0 * * @param array $attr Attributes for the image markup. * @param int $attachment Image attachment ID. * @param array $size Registered image size or flat array of height and width dimensions. * @return array The filtered attributes for the image markup. */ function ecommerce_star_post_thumbnail_sizes_attr( $attr, $attachment, $size ) { if ( is_archive() || is_search() || is_home() ) { $attr['sizes'] = '(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px'; } else { $attr['sizes'] = '100vw'; } return $attr; } add_filter( 'wp_get_attachment_image_attributes', 'ecommerce_star_post_thumbnail_sizes_attr', 10, 3 ); /** * Return rgb value of a $hex - hexadecimal color value with given $a - alpha value * Ex:- ecommerce_star_rgba('#11ffee',15) // return rgba(17,255,238,15) **/ function ecommerce_star_rgba($hex,$a){ $r = hexdec(substr($hex,1,2)); $g = hexdec(substr($hex,3,2)); $b = hexdec(substr($hex,5,2)); $result = 'rgba('.$r.','.$g.','.$b.','.$a.')'; return $result; } /* sanotize option group */ function ecommerce_star_sanitize_header_options($input){ $choices = array("box_shadow", "border", "transparent", "woocommerce", "none"); return ( in_array( $input, $choices ) ? $input : 'box_shadow' ); } /** * Modifies tag cloud widget arguments to display all tags in the same font size * and use list format for better accessibility. * * @since ecommerce-star 1.0 * * @param array $args Arguments for tag cloud widget. * @return array The filtered arguments for tag cloud widget. */ function ecommerce_star_widget_tag_cloud_args( $args ) { $args['largest'] = 1; $args['smallest'] = 1; $args['unit'] = 'em'; $args['format'] = 'list'; return $args; } add_filter( 'widget_tag_cloud_args', 'ecommerce_star_widget_tag_cloud_args' ); /* * WooCommerce Header */ function ecommerce_star_woocommerce_header(){ global $ecommerce_star_option; ?>