__('Home Slider', 'business-store'), 'banner'=>__('Banner', 'business-store'), 'featured-product'=>__('Featured Products', 'business-store'), 'onsale-product'=>__('Onsale Products', 'business-store'), 'shop'=>__('Home Shop', 'business-store'), 'bestselling-product'=>__('Best Selling Products', 'business-store'), 'toprated-product'=>__('Top Rated Products', 'business-store'), 'service'=>__('Service', 'business-store'), 'news'=>__('News~Events', 'business-store'), 'team'=>__('Team', 'business-store'), 'testimonial'=>__('Testimonial', 'business-store'), 'none'=>__('-- Disable --', 'business-store') ); } endif; if ( ! function_exists( 'business_store_color_codes' ) ) : /** * business-store color codes */ function business_store_color_codes(){ return array('#000000','#ffffff','#ED0A70','#e7ad24','#FFD700','#81d742','#0053f9','#8224e3'); } endif; if ( ! function_exists( 'business_store_background_style' ) ) : /** * business-store color codes */ function business_store_background_style(){ return array( 'no-repeat' => __('No Repeat', 'business-store'), 'repeat' => __('Tile', 'business-store'), 'repeat-x' => __('Tile Horizontally', 'business-store'), 'repeat-y' => __('Tile Vertically', 'business-store'), ); } endif; /** * @package twentyseventeen * @sub-package business-store * @since 1.0 */ if ( ! function_exists( 'business_store_posted_on' ) ) : /** * Prints HTML with meta information for the current post-date/time and author. */ function business_store_posted_on() { $byline = sprintf( // Get the author name; wrap it in a link. esc_html_x( 'By %s', 'post author', 'business-store' ), '' ); // Finally, let's write all of this to the page. echo '' . business_store_time_link() . ''; } endif; /** * @package twentyseventeen * @sub-package business-store * @since 1.0 */ if ( ! function_exists( 'business_store_time_link' ) ) : /** * Gets a nicely formatted string for the published date. */ function business_store_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', 'business-store'), esc_html__('Posted on', 'business-store'), '' .wp_kses($time_string, $args). '' ); } endif; /** * @package twentyseventeen * @sub-package business-store * @since 1.0 */ if ( ! function_exists( 'business_store_entry_footer' ) ) : /** * Prints HTML with meta information for the categories, tags and comments. */ function business_store_entry_footer() { /* translators: used between list items, there is a space after the comma */ $categories_list = get_the_category_list( esc_html__( ', ', 'business-store') ); /* translators: used between list items, there is a space after the comma */ $tags_list = get_the_tag_list( '', esc_html__( ', ', 'business-store') ); // We don't want to output .entry-footer if it will be empty, so make sure its not. if ( ( ( business_store_categorized_blog() && $categories_list ) || $tags_list ) || get_edit_post_link() ) { echo ' '; } } endif; /** * @package twentyseventeen * @sub-package business-store * @since 1.0 */ if ( ! function_exists( 'business_store_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 business_store_edit_link() { edit_post_link( sprintf( /* translators: %s: Name of current post */ __( 'Edit "%s"', 'business-store' ), esc_html(get_the_title()) ), ' ', '' ); } endif; /** * @package twentyseventeen * @sub-package business-store * @since 1.0 * Returns true if a blog has more than 1 category. * @return bool */ function business_store_categorized_blog() { $category_count = get_transient( 'business_store_categories' ); if ( false === $category_count ) { // Create an array of all the categories that are attached to posts. $categories = get_categories( array( 'fields' => '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( 'business_store_categories', $category_count ); } // Allow viewing case of 0 or 1 categories in post preview. if ( is_preview() ) { return true; } return $category_count > 1; } /** * @package twentyseventeen * @sub-package business-store * @since 1.0 * Flush out the transients used in business_store_categorized_blog. */ function business_store_category_transient_flusher() { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } // Like, beat it. Dig? delete_transient( 'business_store_categories' ); } add_action( 'edit_category', 'business_store_category_transient_flusher' ); add_action( 'save_post', 'business_store_category_transient_flusher' ); /* * check valid font has been selected */ function business_store_sanitize_font_family( $value ) { if ( array_key_exists($value, business_store_font_family()) ) { return $value; } else { return "Times New Roman, Sans Serif"; } } function business_store_font_family(){ $google_fonts = array( "Times New Roman" => "Times New Roman, Sans Serif", "Open sans" => "Open sans", "Oswald" => "Oswald", "Lora" => "Lora", ); return ($google_fonts); } /*********************** woocommerce functions *****************************/ /** * Woocommerce Custom add to cart button * */ if ( ! function_exists( 'business_store_add_to_cart' ) ) { function business_store_add_to_cart($id = '') { if(!class_exists( 'WooCommerce' )){return;} global $product; if( $id ) { $product = wc_get_product( $id ); } if ( function_exists( 'method_exists' ) && method_exists( $product, 'get_type' ) ) { $prod_type = $product->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 ); wc_get_template( 'woocommerce/add-to-cart.php', $args ); } } } /* when price empty return 0$ */ function business_store_wc_custom_get_price_html( $price, $product ) { if(!class_exists( 'WooCommerce' )){return;} if ( $product->get_price() == 0 ) { if ( $product->is_on_sale() && $product->get_regular_price() ) { $regular_price = wc_get_price_to_display( $product, array( 'qty' => 1, 'price' => $product->get_regular_price() ) ); $price = wc_format_price_range( $regular_price, __( 'Free!', 'business-store' ) ); } else { $price = '' . __( 'Free!', 'business-store' ) . ''; } } return $price; } add_filter( 'woocommerce_get_price_html', 'business_store_wc_custom_get_price_html', 10, 2 ); /** * Add Cart icon and count to header if WC is active */ function business_store_wc_cart_count() { if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { global $woocommerce; if($woocommerce) { ?> cart->cart_contents_count); ?> cart->get_cart_total()); ?>