post_content; if (!empty($post_object->post_excerpt)) { $source_content = $post_object->post_excerpt; } $source_content = strip_shortcodes($source_content); $trimmed_content = wp_trim_words($source_content, $length, '...'); return $trimmed_content; } endif; if (!function_exists('agency_ecommerce_fonts_url')) { /** * Register Google fonts. * * @return string Google fonts URL for the theme. */ function agency_ecommerce_fonts_url() { $fonts_url = ''; $fonts = array(); $subsets = 'latin,latin-ext'; /* translators: If there are characters in your language that are not supported by Open Sans, translate this to 'off'. Do not translate into your own language. */ if ('off' !== _x('on', 'Open Sans font: on or off', 'agency-ecommerce')) { $fonts[] = 'Open Sans:300,300i,400,400i,500,500i,600,600i,700,700i,800,800i'; } /* translators: If there are characters in your language that are not supported by Playfair Display, translate this to 'off'. Do not translate into your own language. */ if ('off' !== _x('on', 'Playfair Display font: on or off', 'agency-ecommerce')) { $fonts[] = 'Playfair Display:400,400i,700,700i,900,900i'; } if ($fonts) { $fonts_url = add_query_arg(array( 'family' => urlencode(implode('|', $fonts)), 'subset' => urlencode($subsets), ), '//fonts.googleapis.com/css'); } return $fonts_url; } } if (!function_exists('agency_ecommerce_get_woocommerce_pages')) : /** * Returns WooCommerce pages. * * @since 1.0.0 * * @return array Pages details. */ function agency_ecommerce_get_woocommerce_pages() { // WC pages to check against. $check_pages = array( esc_html_x('Shop base', 'page setting', 'agency-ecommerce') => array( 'option' => 'woocommerce_shop_page_id', 'shortcode' => '', ), esc_html_x('Cart', 'page setting', 'agency-ecommerce') => array( 'option' => 'woocommerce_cart_page_id', 'shortcode' => '[' . apply_filters('woocommerce_cart_shortcode_tag', 'woocommerce_cart') . ']', ), esc_html_x('Checkout', 'page setting', 'agency-ecommerce') => array( 'option' => 'woocommerce_checkout_page_id', 'shortcode' => '[' . apply_filters('woocommerce_checkout_shortcode_tag', 'woocommerce_checkout') . ']', ), esc_html_x('My account', 'page setting', 'agency-ecommerce') => array( 'option' => 'woocommerce_myaccount_page_id', 'shortcode' => '[' . apply_filters('woocommerce_my_account_shortcode_tag', 'woocommerce_my_account') . ']', ), ); $pages_output = array(); foreach ($check_pages as $page_name => $values) { $page_id = get_option($values['option']); $page_set = $page_exists = $page_visible = false; $shortcode_present = $shortcode_required = false; // Page checks. if ($page_id) { $page_set = true; } if (get_post($page_id)) { $page_exists = true; } if ('publish' === get_post_status($page_id)) { $page_visible = true; } // Shortcode checks. if ($values['shortcode'] && get_post($page_id)) { $shortcode_required = true; $page = get_post($page_id); if (strstr($page->post_content, $values['shortcode'])) { $shortcode_present = true; } } // Wrap up our findings into an output array. $pages_output[] = array( 'page_name' => $page_name, 'page_id' => $page_id, 'page_set' => $page_set, 'page_exists' => $page_exists, 'page_visible' => $page_visible, 'shortcode' => $values['shortcode'], 'shortcode_required' => $shortcode_required, 'shortcode_present' => $shortcode_present, ); } // End foreach(). return $pages_output; } endif; if (!function_exists('agency_ecommerce_woocommerce_pages_status')) : /** * Returns WooCommerce pages status. * * @since 1.0.0 * * @return bool Page status. */ function agency_ecommerce_woocommerce_pages_status() { $output = true; $pages = agency_ecommerce_get_woocommerce_pages(); foreach ($pages as $page) { if (true === $page['page_set']) { if (true === $page['shortcode_required'] && true !== $page['shortcode_present']) { $output = false; break; } } else { $output = false; break; } } return $output; } endif; if (!function_exists('agency_ecommerce_woocommerce_pages_status_message')) : /** * Returns WooCommerce pages status message. * * @since 1.0.0 * * @return string Message. */ function agency_ecommerce_woocommerce_pages_status_message() { $output = ''; $pages = agency_ecommerce_get_woocommerce_pages(); foreach ($pages as $page) { if (true === $page['page_set']) { if (true === $page['shortcode_required'] && true !== $page['shortcode_present']) { /* translators: 1: page name, 2: shortcode */ $output .= '
  • ' . sprintf(esc_html__('%1$s page does not contain %2$s shortcode.', 'agency-ecommerce'), $page['page_name'], $page['shortcode']) . '
  • '; } } else { /* translators: 1: page name */ $output .= '
  • ' . sprintf(esc_html__('%s page is not set.', 'agency-ecommerce'), $page['page_name']) . '
  • '; } } if (!empty($output)) { $output = ''; } return $output; } endif; if (!function_exists('agency_ecommerce_product_searchbox')) { function agency_ecommerce_product_searchbox($search_options = array()) { $options_default = array( 'css' => '', 'class' => '' ); $options = wp_parse_args($search_options, $options_default); ?>
    'shopping-cart' # font awesome cart icon ); $cart_options = wp_parse_args($cart_config, $cart_config_default); ?>
    cart->get_cart_contents_count()); ?>
    'fa-heart' # font awesome wishlist icon ); $wishlist_options = wp_parse_args($wishlist_config, $wishlist_config_default); $wishlist_page_id = yith_wcwl_object_id(get_option('yith_wcwl_wishlist_page_id')); if (absint($wishlist_page_id) > 0) : ?>
    '; if (current_user_can('edit_theme_options')) { ?>

    Get started here.', 'agency-ecommerce'), array( 'a' => array( 'href' => array(), ), ) ), esc_url(admin_url('widgets.php')) ); ?>

    '; } } if (!function_exists('agency_ecommerce_number_of_social_icon')) : function agency_ecommerce_number_of_social_icon() { return apply_filters('agency_ecommerce_number_of_social_icon', 5); } endif;