'; return $form; } endif; add_filter( 'get_search_form', 'best_commerce_customize_search_form', 15 ); if ( ! function_exists( 'best_commerce_add_primary_navigation' ) ) : /** * Add primary navigation. * * @since 1.0.0 */ function best_commerce_add_primary_navigation() { ?> 0 ) { $length = absint( $excerpt_length ); } return $length; } endif; add_filter( 'excerpt_length', 'best_commerce_implement_excerpt_length', 999 ); if ( ! function_exists( 'best_commerce_implement_read_more' ) ) : /** * Implement read more in excerpt. * * @since 1.0.0 * * @param string $more The string shown within the more link. * @return string The excerpt. */ function best_commerce_implement_read_more( $more ) { if ( is_admin() ) { return $more; } $read_more_text = best_commerce_get_option( 'read_more_text' ); $more_link = '… ' . esc_html( $read_more_text ) . ''; return $more_link; } endif; add_filter( 'excerpt_more', 'best_commerce_implement_read_more' ); if ( ! function_exists( 'best_commerce_content_more_link' ) ) : /** * Implement read more in content. * * @since 1.0.0 * * @param string $more_link Read More link element. * @param string $more_link_text Read More text. * @return string Link. */ function best_commerce_content_more_link( $more_link, $more_link_text ) { $read_more_text = best_commerce_get_option( 'read_more_text' ); if ( ! empty( $read_more_text ) ) { $more_link = str_replace( $more_link_text, esc_html( $read_more_text ), $more_link ); } return $more_link; } endif; add_filter( 'the_content_more_link', 'best_commerce_content_more_link', 10, 2 ); if ( ! function_exists( 'best_commerce_custom_body_class' ) ) : /** * Custom body class. * * @since 1.0.0 * * @param string|array $input One or more classes to add to the class list. * @return array Array of classes. */ function best_commerce_custom_body_class( $input ) { // Adds a class of group-blog to blogs with more than 1 published author. if ( is_multi_author() ) { $input[] = 'group-blog'; } // Site layout. $input[] = 'site-layout-boxed'; // Global layout. global $post; $global_layout = best_commerce_get_option( 'global_layout' ); $global_layout = apply_filters( 'best_commerce_filter_theme_global_layout', $global_layout ); // Check if single template. if ( $post && is_singular() ) { $post_options = get_post_meta( $post->ID, 'best_commerce_settings', true ); if ( isset( $post_options['post_layout'] ) && ! empty( $post_options['post_layout'] ) ) { $global_layout = $post_options['post_layout']; } } $input[] = 'global-layout-' . esc_attr( $global_layout ); // Common class for three columns. switch ( $global_layout ) { case 'three-columns': $input[] = 'three-columns-enabled'; break; default: break; } return $input; } endif; add_filter( 'body_class', 'best_commerce_custom_body_class' ); if ( ! function_exists( 'best_commerce_custom_content_width' ) ) : /** * Custom content width. * * @since 1.0.0 */ function best_commerce_custom_content_width() { global $post, $wp_query, $content_width; $global_layout = best_commerce_get_option( 'global_layout' ); $global_layout = apply_filters( 'best_commerce_filter_theme_global_layout', $global_layout ); // Check if single template. if ( $post && is_singular() ) { $post_options = get_post_meta( $post->ID, 'best_commerce_settings', true ); if ( isset( $post_options['post_layout'] ) && ! empty( $post_options['post_layout'] ) ) { $global_layout = $post_options['post_layout']; } } switch ( $global_layout ) { case 'no-sidebar': $content_width = 1220; break; case 'three-columns': $content_width = 570; break; case 'left-sidebar': case 'right-sidebar': $content_width = 895; break; default: break; } } endif; add_filter( 'template_redirect', 'best_commerce_custom_content_width' ); if ( ! function_exists( 'best_commerce_custom_links_in_primary_navigation' ) ) : /** * Add custom links in primary navigation. * * @since 1.0.0 * * @param string $items The HTML list content for the menu items. * @param object $args An object containing wp_nav_menu() arguments. * @return string Modified HTML list content for the menu items. */ function best_commerce_custom_links_in_primary_navigation( $items, $args ) { if ( 'primary' === $args->theme_location ) { $classes = ''; if ( is_front_page() ) { $classes .= ' current-menu-item'; } $items = '
  • ' . esc_html__( 'Home', 'best-commerce' ) . '
  • ' . $items; } return $items; } endif; add_filter( 'wp_nav_menu_items', 'best_commerce_custom_links_in_primary_navigation', 10, 2 );