tag in the document head, and expect WordPress to * provide it for us. */ add_theme_support('title-tag'); /* * Enable support for Post Thumbnails on posts and pages. * * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/ */ add_theme_support('post-thumbnails'); add_image_size('grand_popo-featured-image', 640, 9999); //This theme uses wp_nav_menu() in one location. register_nav_menus(array( 'top-header-menu-left' => esc_html__('Top header left', 'grand-popo'), 'top-header-menu-right' => esc_html__('Top header right', 'grand-popo'), 'main-menu' => esc_html__('Main', 'grand-popo'), )); /** * Add support for core custom logo. */ add_theme_support('custom-logo', array( 'height' => 200, 'width' => 200, 'flex-width' => true, 'flex-height' => true, )); /* * Switch default core markup for comment form, and comments * to output valid HTML5. */ add_theme_support('html5', array( 'comment-form', 'comment-list', 'gallery', 'caption', )); /* * Enable support for Post Formats. * See http://codex.wordpress.org/Post_Formats */ add_theme_support('post-formats', array( 'image', 'video', 'quote', 'gallery', 'audio', 'link' )); // Set up the WordPress core custom background feature. add_theme_support('custom-background', apply_filters('grand_popo_custom_background_args', array( 'default-color' => 'ffffff', 'default-image' => '', ))); define('ORION_CURRENT_THEME_OPTIONS_NAME', 'grand_popo_options'); } endif; add_action('after_setup_theme', 'grand_popo_setup'); //load redux framework to allow custom options for the theme require_once (get_template_directory() . '/inc/redux/grand_popo-config.php'); //Add theme support woocommerce function grand_popo_woocommerce_support() { add_theme_support('woocommerce'); } add_action('after_setup_theme', 'grand_popo_woocommerce_support'); /** * Set the content width in pixels, based on the theme's design and stylesheet. * * Priority 0 to make it available to lower priority callbacks. * * @global int $content_width */ function grand_popo_content_width() { $GLOBALS['content_width'] = apply_filters('grand_popo_content_width', 640); } add_action('after_setup_theme', 'grand_popo_content_width', 0); /** * Register widget area. * * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar */ function grand_popo_widgets_init() { //Default sidebar (blog sidebar) register_sidebar(array( 'name' => esc_html__('Sidebar', 'grand-popo'), 'id' => 'sidebar-1', 'description' => esc_html__('Blog sidebar', 'grand-popo'), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); //Display widget on the top of product archive page register_sidebar(array( 'name' => esc_html__('Product Archive Top Sidebar', 'grand-popo'), 'id' => 'top-shop-sidebar', 'description' => esc_html__('Product Archive Top Sidebar', 'grand-popo'), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); //Display widget on the single product page register_sidebar(array( 'name' => esc_html__('Product Advantage', 'grand-popo'), 'id' => 'product-avantage-sidebar', 'description' => esc_html__('Product Avantage Sidebar', 'grand-popo'), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); //Display widget on the shop sidebar register_sidebar(array( 'name' => esc_html__('Shop sidebar', 'grand-popo'), 'id' => 'shop-sidebar', 'description' => esc_html__('Shop sidebar', 'grand-popo'), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); } add_action('widgets_init', 'grand_popo_widgets_init'); /** * Enqueue google fonts url. * returns an aarray of font */ function grand_popo_google_fonts_url() { $fonts_url = ''; $grand_popo_montserrat = _x('on', 'Montserrat font: on or off', 'grand-popo'); $grand_popo_open_sans = _x('on', 'Open Sans font: on or off', 'grand-popo'); $grand_popo_playfair = _x('on', 'Playfair Dispaly font: on or off', 'grand-popo'); if ('off' !== $grand_popo_montserrat || 'off' !== $grand_popo_open_sans || 'off' !== $grand_popo_playfair ) { $font_families = array(); if ('off' !== $grand_popo_montserrat) { $font_families[] = 'Montserrat:400,700'; } if ('off' !== $grand_popo_open_sans) { $font_families[] = 'Open Sans:300i,400,400i,700,800'; } if ('off' !== $grand_popo_playfair) { $font_families[] = 'Playfair Display:400,400italic'; } $query_args = array( 'family' => urlencode(implode('|', $font_families)), 'subset' => urlencode('latin,latin-ext'), ); $fonts_url = add_query_arg($query_args, 'https://fonts.googleapis.com/css'); } return esc_url_raw($fonts_url); } /** * Enqueue scripts and styles. */ function grand_popo_scripts() { wp_enqueue_style('grand_popo-google-font', grand_popo_google_fonts_url(), array()); wp_enqueue_style('fontawesome', get_template_directory_uri() . '/assets/font-awesome/css/font-awesome.min.css', array(), time(), 'all'); wp_enqueue_style('themify', get_template_directory_uri() . '/assets/themify-icons/themify-icons.css'); wp_enqueue_style('flexiblegs', get_template_directory_uri() . '/assets/stylesheets/flexiblegs.css'); wp_enqueue_style('mCustomScrollbar-css', get_template_directory_uri() . '/assets/stylesheets/jquery.mCustomScrollbar.min.css'); wp_enqueue_style('owl-carousel-css', get_template_directory_uri() . '/assets/stylesheets/owl.carousel.css'); wp_enqueue_style('owl-carousel-theme-css', get_template_directory_uri() . '/assets/stylesheets/owl.theme.css'); wp_enqueue_style('grand_popo-select2-css', get_template_directory_uri() . '/assets/stylesheets/select2.css'); wp_enqueue_style('tooltip-css', get_template_directory_uri() . '/assets/stylesheets/tooltip.css'); wp_enqueue_style('grand_popo-style', get_stylesheet_uri(), array()); wp_enqueue_script('grand_popo-navigation', get_template_directory_uri() . '/assets/js/navigation.js', array(), '20151215', true); wp_enqueue_script('grand_popo-skip-link-focus-fix', get_template_directory_uri() . '/assets/js/skip-link-focus-fix.js', array(), '20151215', true); wp_enqueue_script('unveil-js', get_template_directory_uri() . '/assets/js/jquery.unveil.min.js', array('jquery'), null, true); wp_enqueue_script('mCustomScrollbar-js', get_template_directory_uri() . '/assets/js/jquery.mCustomScrollbar.concat.min.js', array('jquery'), false, true); wp_enqueue_script('owl-carousel-js', get_template_directory_uri() . '/assets/js/owl.carousel.min.js', array(), null, true); wp_enqueue_script('tooltip-js', get_template_directory_uri() . '/assets/js/tooltip.min.js', array(), null, true); wp_enqueue_script('bx-slider-js', get_template_directory_uri() . '/assets/js/jquery.bxslider.min.js', array(), null, true); wp_enqueue_script('grand_popo-select2-js', get_template_directory_uri() . '/assets/js/select2.min.js', array(), null, true); wp_enqueue_script('grand_popo-scripts-js', get_template_directory_uri() . '/assets/js/scripts.js', array('jquery','grand_popo-select2-js'), null, true); if (is_singular() && comments_open() && get_option('thread_comments')) { wp_enqueue_script('comment-reply'); } global $grand_popo_options; if (isset($grand_popo_options['opt_css_editor'])) $css = grand_popo_get_proper_value($grand_popo_options, 'opt_css_editor'); if (!empty($css)) { wp_add_inline_style('grand_popo-style', $css); } } add_action('wp_enqueue_scripts', 'grand_popo_scripts'); /** * Add fontawesome to redux panel * Allow to use fontawesome in redux panel */ function grand_popo_add_font_awesome_to_redux_panel() { wp_enqueue_style('redux-font-awesome', get_template_directory_uri() . '/assets/font-awesome/css/font-awesome.min.css', array(), time(), 'all'); } add_action('redux/page/grand_popo_options/enqueue', 'grand_popo_add_font_awesome_to_redux_panel'); /** * Registers an editor stylesheet for the theme. */ function wpdocs_theme_add_editor_styles() { add_editor_style(get_template_directory_uri() . '/assets/stylesheets/editor-style.css'); } add_action('admin_init', 'wpdocs_theme_add_editor_styles'); /** * Enqueue admin scripts and admin styles. */ function grand_popo_admin_scripts() { wp_enqueue_style('grand_popo-admin-css', get_template_directory_uri() . '/assets/admin/admin.css'); wp_enqueue_script('grand_popo-admin-js', get_template_directory_uri() . '/assets/admin/admin.js', array('jquery')); } add_action('admin_enqueue_scripts', 'grand_popo_admin_scripts'); /** * Custom template tags for this theme. */ require get_template_directory() . '/inc/template-tags.php'; /** * Custom functions that act independently of the theme templates. */ require get_template_directory() . '/inc/extras.php'; /** * Customizer additions. */ require get_template_directory() . '/inc/customizer.php'; /** * Load Jetpack compatibility file. */ require get_template_directory() . '/inc/jetpack.php'; /** * Get a value by key in an array if defined * @param array $values Array to search into * @param string $search_key Searched key * @param mixed $default_value Value if the key does not exist in the array * @return mixed */ function grand_popo_get_proper_value($values, $search_key, $default_value = "") { if (isset($values[$search_key])) $default_value = $values[$search_key]; return $default_value; } /** * Get a mini cart * @param string $mode (mobile or "") * returns mini cart */ function grand_popo_get_mini_cart($mode="") { global $grand_popo_options; if (function_exists('woocommerce_mini_cart') && grand_popo_get_proper_value($grand_popo_options, 'opt-enable-mini-cart', '1') == '1') { if($mode=="mobile"){ ?>
'sectionbegin', 'id' => 'grand_popo_header_section', 'title' => esc_html__('Header Settings', 'grand-popo') ); $page_title = array( 'title' => esc_html__('Display Page Title', 'grand-popo'), 'desc' => esc_html__('Hide or show title', 'grand-popo'), 'name' => 'grand_popo_page_options[page-title]', 'type' => 'select', 'default' => 'yes', 'options' => array( 'yes' => esc_html__('Yes', 'grand-popo'), 'no' => esc_html__('No', 'grand-popo'), 'all'=> esc_html__('Hide All', 'grand-popo') ) ); $sidebar_position = array( 'title' => esc_html__('Sidebar Position', 'grand-popo'), 'desc' => esc_html__('Choose the sidebar position', 'grand-popo'), 'name' => 'grand_popo_page_options[sidebar-position]', 'type' => 'select', 'default' => 'no-sidebar', 'options' => array( 'left' => esc_html__('Left Sidebar', 'grand-popo'), 'right' => esc_html__('Right Sidebar', 'grand-popo'), 'no-sidebar' => esc_html__('No Sidebar', 'grand-popo') ) ); $page_layout = array( 'title' => esc_html__('Page Layout', 'grand-popo'), 'desc' => esc_html__('Choose the page layout', 'grand-popo'), 'name' => 'grand_popo_page_options[page-layout]', 'type' => 'select', 'default' => 'boxed', 'options' => array( 'boxed' => esc_html__('Boxed', 'grand-popo'), 'full-width' => esc_html__('Full Width', 'grand-popo'), ) ); $header_settings_end = array('type' => 'sectionend'); array_push($options, $header_settings_begin); array_push($options, $page_title); array_push($options, $page_layout); array_push($options, $sidebar_position); array_push($options, $header_settings_end); echo Orion_Library::o_admin_fields($options); ?> $value ) { $newArr[ $key ]=(is_array($value) ? vpc_array_sanitize($value) : sanitize_text_field(esc_html($value))) ; } return $newArr; } /** * Save meta box content. * * @param int $post_id Post ID */ function grand_popo_save_meta_box($grand_popo_post_id) { // Save logic goes here. Don't forget to include nonce checks! if ( isset($_REQUEST['grand_popo_page_options_nonce'] ) && wp_verify_nonce($_REQUEST['grand_popo_page_options_nonce'], 'grand_popo_page_options_nonce' ) ) { $_POST= filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING); if(isset($_POST['grand_popo_page_options']) && !empty($_POST['grand_popo_page_options']) && current_user_can('edit_post',$grand_popo_post_id)) { $options=grand_popo_array_sanitize($_POST['grand_popo_page_options']); if(is_array($options)){ $esc_gp_page_options=array(); $gp_page_options=$options; foreach($gp_page_options as $key=>$gp_page_option){ $esc_gp_page_options[$key]=sanitize_text_field(esc_html($gp_page_option)); update_post_meta($grand_popo_post_id, 'grand_popo_page_options', $esc_gp_page_options); } } } } } add_action('save_post', 'grand_popo_save_meta_box'); /** * Get page title * return page title */ function grand_popo_get_page_title() { global $post, $grand_popo_options; $show_page_header = grand_popo_get_proper_value($grand_popo_options, 'opt-display-page-header', '1'); $page_id= get_the_ID(); if (function_exists('is_shop') && is_shop()) $page_id=get_option( 'woocommerce_shop_page_id' ); if (function_exists('is_shop') && (is_page() || is_shop() )){ // $grand_popo_meta_boxes = get_post_meta($post->ID, 'grand_popo_page_options', true); $page_metas = get_post_meta($page_id, 'grand_popo_page_options', true); $page_metas_title=grand_popo_get_proper_value($page_metas, 'page-title', 'yes'); if ($page_metas_title != "all") { $page_header_class = "grand_popo-page-title"; } else { $page_header_class = "grand_popo-page-title no-header"; } }else{ if ($show_page_header==1) { $page_header_class = "grand_popo-page-title"; } else { $page_header_class = "grand_popo-page-title no-header "; } } if (is_front_page()) { } else { ?>
ID, 'grand_popo_page_options', true); $show_title = grand_popo_get_proper_value($show_title, 'page-title', 'yes'); $page_title = ""; if ($show_title == "yes") { $page_title.= "

"; $page_title.= get_the_title(); $page_title.="

"; } ?>
', '
'); ?>
'; $breadcrums_id = 'breadcrumbs'; $breadcrums_class = 'breadcrumbs'; $home_title = esc_html__('Home','grand-popo'); $custom_taxonomy = 'product_cat'; // Get the query & post information global $post, $wp_query; // Do not display on the homepage if (!is_front_page()) { // Build the breadcrums echo ''; } } } /** * remove woocommerce breadcrumb to woocommerce_before_main_content * replace with custom breadcrumb */ remove_action('woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0); /** * Get custom sale price * @param objet $product * @param string $price * return sale price html */ function grand_popo_get_custom_sales_price($price, $product) { $regular_price = wc_price($product->get_regular_price()); $sale_price = wc_price($product->get_sale_price()); $get_price_html = sprintf("") . $regular_price . sprintf("") . $sale_price . sprintf(""); return $get_price_html; } add_filter('woocommerce_sale_price_html', 'grand_popo_get_custom_sales_price', 10, 2); /** * Get custom variable sale price * @param objet $product * @param string $price * return variable price html */ function grand_popo_custom_variable_price($price, $product) { // Main Price $prices = array($product->get_variation_price('min', true), $product->get_variation_price('max', true)); $price = $prices[0] !== $prices[1] ? sprintf('%1$s', wc_price($prices[0])) : wc_price($prices[0]); // Sale Price $prices = array($product->get_variation_regular_price('min', true), $product->get_variation_regular_price('max', true)); sort($prices); $saleprice = $prices[0] !== $prices[1] ? sprintf('%1$s', wc_price($prices[0])) : wc_price($prices[0]); if ($price !== $saleprice) { $price = '' . $saleprice . '' . $price . ''; } return $price; } add_filter('woocommerce_variable_sale_price_html', 'grand_popo_custom_variable_price', 10, 2); add_filter('woocommerce_variable_price_html', 'grand_popo_custom_variable_price', 10, 2); /** * Get social network * return liste of network set */ function grand_popo_get_social_link() { global $grand_popo_options; $enable_social = grand_popo_get_proper_value($grand_popo_options, 'opt-social-enable'); if ($enable_social == "1") { ?> esc_html__('Redux Framework', 'grand-popo'), // The plugin name. 'slug' => 'redux-framework', // The plugin slug (typically the folder name). 'required' => false, // If false, the plugin is only 'recommended' instead of required. ), array( 'name' => esc_html__('Grand-Popo Core', 'grand-popo'), // The plugin name. 'slug' => 'grand-popo-core', // The plugin slug (typically the folder name). 'required' => true, // If false, the plugin is only 'recommended' instead of required. ), array( 'name' => esc_html__('WooCommerce', 'grand-popo'), // The plugin name. 'slug' => 'woocommerce', // The plugin slug (typically the folder name). 'required' => false, // If false, the plugin is only 'recommended' instead of required. ), ); $config = array( 'id' => 'grand-popo', // Unique ID for hashing notices for multiple instances of TGMPA. 'default_path' => '', // Default absolute path to bundled plugins. 'menu' => 'tgmpa-install-plugins', // Menu slug. 'has_notices' => true, // Show admin notices or not. 'dismissable' => true, // If false, a user cannot dismiss the nag message. 'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag. 'is_automatic' => false, // Automatically activate plugins after installation or not. 'message' => '', // Message to output right before the plugins table. ); tgmpa($plugins, $config); } add_action('tgmpa_register', 'grand_popo_register_required_plugins'); /** * Force Visual Composer to initialize as "built into the theme". This will hide certain tabs under the Settings->Visual Composer page */ function grand_popo_vcSetAsTheme() { vc_set_as_theme(); } add_action( 'vc_before_init', 'grand_popo_vcSetAsTheme' ); //REMOVE SUBCATEGORIES COUNT function grand_popo_remove_category_products_count() { return; } add_filter('woocommerce_subcategory_count_html', 'grand_popo_remove_category_products_count'); /** * Get Footer sidebar * Display widget set in footer-sidebar on footer */ function grand_popo_custom_widgets_init() { global $grand_popo_options; $number = grand_popo_get_proper_value($grand_popo_options, 'footer-sidebar-column', 4); $search_number = grand_popo_get_proper_value($grand_popo_options, 'search-sidebar-column', 4); if ($number == 1) { $args = array( 'name' => esc_html__('footer column 1', 'grand-popo'), 'id' => 'footer-sidebar', 'description' => 'One of the footer sidebar column', 'class' => '', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

'); } else { $args = array( 'name' => esc_html__('footer column %d', 'grand-popo'), 'id' => 'footer-sidebar', 'description' => 'One of the footer sidebar column', 'class' => '', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

'); } register_sidebars($number, $args); } add_action('widgets_init', 'grand_popo_custom_widgets_init'); /** * WOOCOMERCE LOOP WRAPPER * Wrapper start *Wrapper close */ function woocommerce_product_loop_start() { echo"
"; } function woocommerce_product_loop_end() { echo "
"; } //CUSTOM WOOCOMMERCE BREADCRUMBS function grand_popo_get_grand_popo_breadcrumbss() { return array( 'delimiter' => '  >  ', 'wrap_before' => '', 'before' => '', 'after' => '', 'home' => _x('Home', 'breadcrumb', 'grand-popo'), ); } add_filter('grand_popo_breadcrumbs_defaults', 'grand_popo_get_grand_popo_breadcrumbss'); /** * replace the default add_to_cart_link * @global type $product * @param type $add_to_cart_link * @return type */ function grand_popo_add_to_cart_link($add_to_cart_link) { global $product, $product_id, $product_type, $link_classes; $product_type = $product->product_type; $product_id = $product->id; $product_link = get_the_permalink($product_id); ob_start(); ?>
" rel="nofollow" data-product-id="" data-product-type="" class="add_to_wishlist yith-wcwl-add-to-wishlist add-to-wishlist-" > " class="compare button" data-product_id="id); ?>" rel="nofollow"> " > " >

' . get_the_title() . '

'; } add_action('woocommerce_shop_loop_item_title', 'grand_popo_woocommerce_template_loop_product_title', 10); //Remove woocommerce template loop product title remove_action('woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10); //CUSTOM FILTER PRICE WIDGET function grand_popo_custom_woocommerce_filter_widgets() { // Ensure our parent class exists to avoid fatal error (thanks Wilgert!) if (class_exists('WC_Widget_Price_Filter')) { unregister_widget('WC_Widget_Price_Filter'); require_once( get_template_directory() . '/woocommerce/widgets/grand_popo-widget-price-filter.php'); register_widget('Grand_Popo_Widget_Price_Filter'); } } add_action('widgets_init', 'grand_popo_custom_woocommerce_filter_widgets'); /** *Get custom chekout field * @param type $field * @return type $field */ function grand_popo_override_checkout_fields($fields) { $fields['billing']['billing_company']['placeholder'] = esc_html__('Company','grand-popo'); $fields['billing']['billing_first_name']['placeholder'] = esc_html__('First name','grand-popo'); $fields['billing']['billing_last_name']['placeholder'] = esc_html__('Last name','grand-popo'); $fields['billing']['billing_email']['placeholder'] = esc_html__('Email','grand-popo'); $fields['billing']['billing_phone']['placeholder'] = esc_html__('Phone','grand-popo'); $fields['billing']['billing_address_1']['placeholder'] = esc_html__('Address','grand-popo'); $fields['billing']['billing_city']['placeholder'] = esc_html__('City / Town','grand-popo'); $fields['billing']['billing_state']['placeholder'] = esc_html__('State / Country','grand-popo'); $fields['billing']['billing_postcode']['placeholder'] = esc_html__('Post Code','grand-popo'); $fields['order']['order_comments']['placeholder'] = esc_html__('Your comment','grand-popo'); unset($fields['billing']['billing_company']['label']); unset($fields['billing']['billing_first_name']['label']); unset($fields['billing']['billing_last_name']['label']); unset($fields['billing']['billing_email']['label']); unset($fields['billing']['billing_phone']['label']); unset($fields['billing']['billing_country']['label']); unset($fields['billing']['billing_address_1']['label']); unset($fields['billing']['billing_city']['label']); unset($fields['billing']['billing_state']['label']); unset($fields['billing']['billing_postcode']['label']); unset($fields['order']['order_comments']['label']); return $fields; } add_filter('woocommerce_checkout_fields', 'grand_popo_override_checkout_fields'); //REMOVE SALE ON SINGLE PRODUCT BEFORE remove_action('woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10); /** *Get custom chekout field * @param array $matches * @return raw url */ function grand_popo_get_post_format_raw_url() { if (!preg_match("/(?:http|https)?(?:\:\/\/)?(?:www.)?(([A-Za-z0-9-]+\.)*[A-Za-z0-9-]+\.[A-Za-z]+)(?:\/.*)?/im", get_the_content(), $matches)) { return false; } return esc_url_raw($matches[0]); } /** * Get poste thumbnail * @return type $post_thumbnail */ function grand_popo_get_post_thumb() { $post_id = get_the_ID(); $post_format = get_post_format(); $meta = get_post_meta($post_id, "grand-popo", true); $post_thumb = ""; switch ($post_format) { case 'quote': global $post; $regexp = "
(.*)<\/blockquote>"; $input = get_the_content(); if (preg_match_all("/$regexp/siU", $input, $matches)) { $post_thumb = $matches[0][0]; } break; case 'link': global $post; $regexp = "]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>"; $input = get_the_content(); if (preg_match_all("/$regexp/siU", $input, $matches)) { $post_thumb = "
" . $matches[0][0] . "
"; } break; case 'video': case 'audio': global $post; global $wp_embed; $pattern = get_shortcode_regex(array("embed", "audio", "wpvideo")); $matches = array(); preg_match("/$pattern/s", get_the_content(), $matches); if (!empty($matches)) { $post_thumb = do_shortcode($matches[0]); } else { $post_thumb_url = grand_popo_get_post_format_raw_url(); if ($post_thumb_url) { $post_thumb = wp_oembed_get($post_thumb_url); } } break; case 'image': $url = grand_popo_grab_first_image(); if ($url) $post_thumb = '' . esc_attr__('Post thumbnail', 'grand-popo') . ''; case 'gallery': global $post; $pattern = get_shortcode_regex(array("gallery")); $matches = array(); preg_match("/$pattern/s", get_the_content(), $matches); if (!empty($matches)) { $post_thumb = do_shortcode($matches[0]); } else { } break; default: global $post; $url = wp_get_attachment_url(get_post_thumbnail_id($post->ID)); if ($url) $post_thumb = '' . esc_attr__('Post thumbnail', 'grand-popo') . ''; break; } return $post_thumb; } /** * Get first attached image * @global $post * @return type $first_img */ function grand_popo_grab_first_image() { global $post; $output = preg_match_all('//i', $post->post_content, $matches); $first_img = $matches [1] [0]; if (empty($first_img)) { //return false $first_img = false; } return $first_img; } /** * Get custom post excerpt more * @param $more * @return custom $more */ function grand_popo_sbt_auto_excerpt_more($more) { return '.'; } add_filter('excerpt_more', 'grand_popo_sbt_auto_excerpt_more', 20); // Grand-Popo get single post navigation function grand_popo_get_single_post_nav() { if (is_singular()) { ?>
'; ?>
>
' ); */ ?> %1$s', get_comment_author_link()) ?> $depth, 'max_depth' => $args['max_depth']))) ?>
comment_approved == '0') : ?>

post_content; preg_match('/\[gallery.*ids=.(.*).\]/', $post_content, $ids); if(!empty($ids)) $images_id = explode(",", $ids[1]); else $images_id =""; return $images_id; } //Custom grand-popo product on sale badge html function grand_popo_sale_html() { ?> max_num_pages <= 1) return; echo ''; } add_filter('wp_nav_menu_items', 'grand_popo_add_logout_link', 10, 2); /** * Add a logout link * @param type $items * @param type $args * @return $item */ function grand_popo_add_logout_link($items, $args) { if ($args->theme_location == 'top-header-menu-right') { if (is_user_logged_in()) { $items .= '
  • ' . esc_html__("Log Out", "grand-popo") . '
  • '; } else { $items .= '
  • ' . esc_html__("Log In", "grand-popo") . '
  • '; } } return $items; } /** * Get header on sticky mode * @global $grand_popo_options * @return $sticky_class */ function grand_popo_header_sticky() { global $grand_popo_options; $sticky = grand_popo_get_proper_value($grand_popo_options, 'opt-enable-header-sticky', '1'); if ($sticky == "1") $sticky_class = "sticky"; else $sticky_class = ""; echo $sticky_class; } /** * Get scroll to top button * @global $grand_popo_options * @return $scroll_to_top_class */ function grand_popo_get_scroll_to_top() { global $grand_popo_options; $scroll_to_top = grand_popo_get_proper_value($grand_popo_options, 'opt-scroll-top', '0'); if ($scroll_to_top == "1") $scroll_to_top_class = "grand_popo-scroll-to-top"; else $scroll_to_top_class = ""; echo $scroll_to_top_class; } //Add custom css with theme option function grand_popo_add_editor_styles() { add_editor_style(get_template_directory_uri() . '/assets/stylesheets/editor-style.css'); } add_action('admin_init', 'grand_popo_add_editor_styles'); //Removes redux notices function grand_popo_remove_redux_notices() { if (class_exists('ReduxFrameworkPlugin')) { remove_filter('plugin_row_meta', array(ReduxFrameworkPlugin::get_instance(), 'plugin_metalinks'), null, 2); } if (class_exists('ReduxFrameworkPlugin')) { remove_action('admin_notices', array(ReduxFrameworkPlugin::get_instance(), 'admin_notices')); } } add_action('init', 'grand_popo_remove_redux_notices'); //Get shop tools, display on top of product archive pages to filter product function grand_popo_get_shop_tools($shop_layout) { ?>

    get( 'paged' ) ); $per_page = $wp_query->get( 'posts_per_page' ); $total = $wp_query->found_posts; $first = ( $per_page * $paged ) - $per_page + 1; $last = min( $total, $wp_query->get( 'posts_per_page' ) * $paged ); if($total==1){ printf( _x('Showing the single result', $total, 'grand-popo'), $total); } elseif ($total <= $per_page || -1 === $per_page) { /* translators: %d: total results */ printf( _n( 'Showing the single result', 'All %d results', $total, 'grand-popo' ), $total ); } else { /* translators: 1: first result 2: last result 3: total results */ printf( _nx( 'Showing the single result', ' %1$d–%2$d of %3$d results', $total, 'with first and last result', 'grand-popo' ), $first, $last, $total ); } ?>

    $filter) { foreach ($filter as $identifier => $function) { if (is_array($function) and is_a($function['function'][0], $class) and $method === $function['function'][1]) { remove_filter( $tag, array($function['function'][0], $method), $priority ); } } } } } /** * Get product cat icon field * @param $term * @return $icon field */ function grand_popo_get_icon_fields($term = false) { $icon_url = ""; $img_placeholder = get_template_directory_uri() . '/assets/images/placeholder.png'; $img_src = $img_placeholder; if ($term) { $icon_url = get_term_meta($term->term_id, "prod_cat_icon", true); $img_src = $icon_url; if (empty($icon_url)) $img_src = $img_placeholder; } ?>
    " />
    cart->get_cart_contents_count(); ?>
    is_in_stock() ) { echo '
    ' . $product->get_stock_quantity() . esc_html__('in stock', 'grand-popo' ) . '
    '; } else { echo '
    ' . esc_html__('out of stock', 'grand-popo' ) . '
    '; } ?>
    ". esc_html__('Detailed specifications','grand-popo') . "" ; } add_filter('woocommerce_product_additional_information_heading', 'grand_popo_change_all_specifications_heading'); /* * Get compare button * @global $product * @return $compare_link */ function grand_popo_get_compare_btn(){ global $product; if(class_exists( 'YITH_Woocompare' ) ) { ?> " class="compare button grand_popo-compare" data-product_id="id); ?>" rel="nofollow"> product_type == "variation") $product_parent_id=wp_get_post_parent_id( $product_id); else $product_parent_id=$product_id; $products_metas =get_post_meta($product_parent_id,'shipping-date-start',true); if(isset($products_metas[$product_id]) && !empty($products_metas[$product_id]) && $products_metas[$product_id]>date('Y-m-d')){ echo esc_html__( 'Pre order', 'grand-popo' ); } elseif($product->product_type == "external"){ }else{ echo esc_html__( 'Add to cart', 'grand-popo' ); } } add_filter( 'woocommerce_product_single_add_to_cart_text', 'grand_popo_single_add_to_cart_text' ); //remove woocommerce template loop product link close remove_action('woocommerce_after_shop_loop_item','woocommerce_template_loop_product_link_close',5); /* * Get texte of external product button * @param type $product * @param string $button_text * @return $button_text */ function grand_popo_wc_external_product_button( $button_text, $product ) { if ( 'external' === $product->get_type() ) { // enter the default text for external products return $product->button_text ? $product->button_text : esc_html__('Buy at Amazon','grand-popo'); } return $button_text; } add_filter( 'woocommerce_product_single_add_to_cart_text', 'grand_popo_wc_external_product_button', 10, 2 ); // Get Grand-popo Pro features messages function grand_popo_get_pro_features_messages() { $messages=array( "Improved Speed"=> esc_html__('Do you feel the theme is a bit slow? Upgrade to make it faster.','grand-popo'), "Pre-Orders"=> esc_html__('Sell new products, not on the market yet in exclusivity and enable your customers to be the first to receive the product as soon as it drops.','grand-popo'), "Products Pack Recommendation"=> esc_html__('Recommend accessories and packs related to a product directly on its page.','grand-popo'), "Product Comparison"=> esc_html__('Do you feel the theme is a bit slow? Upgrade to make it faster.','grand-popo'), "Grouped Attributes"=> esc_html__('Create and assign a set of product attributes to any product, no more wasting of time to write them one by one.','grand-popo'), "Brands Module"=> esc_html__('Allows you to manage multiple brands in your shop and help your customers browse your platform by brands.','grand-popo'), "+600 Google fonts"=> esc_html__('Grand-Popo is offering you a large variety of typefaces, to enable you create the typography that best suits your online shop.','grand-popo'), "Highly customizable"=> esc_html__('Personalize the look and feel of your website with colors, icons, font and logo.','grand-popo'), "Flexible shop layout"=> esc_html__('The theme offers an unlimited option such as customizable sidebars, pagination options, filter options, shop layout styles and more.','grand-popo'), "Authentic customer support"=> esc_html__('No matter the technical problems you face, our developers are ever-ready to give you a helping hand.','grand-popo'), "Simple Installation & Setup"=> esc_html__('Includes a user manual that would help you build pages easily and without stress.','grand-popo'), "Onclick demo"=> esc_html__('Includes a many demo of home page that would help you build pages easily and without stress.','grand-popo'), ); return $messages; }