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 search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support('html5', array(
'search-form',
'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
require_once (get_template_directory() . '/inc/redux/grand_popo-config.php');
add_action('after_setup_theme', 'grand_popo_woocommerce_support');
function grand_popo_woocommerce_support() {
add_theme_support('woocommerce');
}
/**
* 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);
/**
* Return early if Custom Logos are not available.
*
* @todo Remove after WP 4.7
*/
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function grand_popo_widgets_init() {
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' => '',
));
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' => '',
));
register_sidebar(array(
'name' => esc_html__('Product Advantage', 'grand-popo'),
'id' => 'product-avantage-sidebar',
'description' => esc_html__('Product Avantage Sidebar', 'grand-popo'),
'before_widget' => '',
'before_title' => '',
));
register_sidebar(array(
'name' => esc_html__('Shop sidebar', 'grand-popo'),
'id' => 'shop-sidebar',
'description' => esc_html__('Shop sidebar', 'grand-popo'),
'before_widget' => '',
'before_title' => '',
));
}
add_action('widgets_init', 'grand_popo_widgets_init');
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.min.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.min.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.js', array('jquery'), null, true);
wp_enqueue_script('imageloaded-js', get_template_directory_uri() . '/assets/js/imageloaded.min.js', array('jquery'), null, true);
wp_enqueue_script('masonry-js', get_template_directory_uri() . '/assets/js/mansory.min.js', array(), 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);
if(function_exists('is_shop')){
wp_enqueue_script('grand_popo-scripts-js', get_template_directory_uri() . '/assets/js/scripts.js', array('jquery', 'select2'), null, true);
}else{
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');
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');
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;
}
// custom search form
function grand_popo_custom_search_form($form) {
$form = "";
return $form;
}
add_filter('get_search_form', 'grand_popo_custom_search_form');
// 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 o_admin_fields($options);
}
/**
* 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($_POST['grand_popo_page_options'])) {
$grand_popo_meta_boxes = $_POST['grand_popo_page_options'];
update_post_meta($grand_popo_post_id, 'grand_popo_page_options', $grand_popo_meta_boxes);
}
}
add_action('save_post', 'grand_popo_save_meta_box');
//get 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 {
?>
';
$breadcrums_id = 'breadcrumbs';
$breadcrums_class = 'breadcrumbs';
$home_title = 'Home';
$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 '';
// Home page
echo '' . esc_html($home_title) . ' ';
echo ' ' . $separator . ' ';
if (is_archive() && !is_tax() && !is_category() && !is_tag()) {
echo '' . post_type_archive_title('', false) . ' ';
} else if (is_archive() && is_tax() && !is_category() && !is_tag()) {
// If post is a custom post type
$post_type = get_post_type();
// If it is a custom post type display name and link
if ($post_type != 'post') {
$post_type_object = get_post_type_object($post_type);
$post_type_archive = get_post_type_archive_link($post_type);
$no_found = esc_html__('No Post Found', 'grand-popo');
echo '' . (isset($post_type_object) ? $post_type_object->labels->name : $no_found) . ' ';
echo ' ' . $separator . ' ';
}
$custom_tax_name = get_queried_object()->name;
echo '' . (($custom_tax_name))? $custom_tax_name : "" . ' ';
} else if (is_single()) {
// If post is a custom post type
$post_type = get_post_type();
// If it is a custom post type display name and link
if ($post_type != 'post') {
$post_type_object = get_post_type_object($post_type);
$post_type_archive = get_post_type_archive_link($post_type);
echo '' . $post_type_object->labels->name . ' ';
echo ' ' . $separator . ' ';
}
// Get post category info
$category = get_the_category();
if (!empty($category)) {
// Get last category post is in
$category_values = array_values($category);
$last_category = end($category_values);
// Get parent any categories and create array
$get_cat_parents = rtrim(get_category_parents($last_category->term_id, true, ','), ',');
$cat_parents = explode(',', $get_cat_parents);
// Loop through parent categories and store in variable $cat_display
$cat_display = '';
foreach ($cat_parents as $parents) {
$cat_display .= '' . $parents . ' ';
$cat_display .= ' ' . $separator . ' ';
}
}
// If it's a custom post type within a custom taxonomy
$taxonomy_exists = taxonomy_exists($custom_taxonomy);
if (empty($last_category) && !empty($custom_taxonomy) && $taxonomy_exists) {
$taxonomy_terms = get_the_terms($post->ID, $custom_taxonomy);
if (isset($taxonomy_terms[0]) && property_exists($taxonomy_terms[0], 'term_id')) {
$cat_id = $taxonomy_terms[0]->term_id;
$cat_nicename = $taxonomy_terms[0]->slug;
$cat_link = get_term_link($taxonomy_terms[0]->term_id, $custom_taxonomy);
$cat_name = $taxonomy_terms[0]->name;
}
}
// Check if the post is in a category
if (!empty($last_category)) {
echo wp_kses_post($cat_display);
echo '' . get_the_title() . ' ';
// Else if post is in a custom taxonomy
} else if (!empty($cat_id)) {
echo '' . $cat_name . ' ';
echo ' ' . $separator . ' ';
echo '' . get_the_title() . ' ';
} else {
echo '' . get_the_title() . ' ';
}
} else if (is_category()) {
// Category page
echo '' . single_cat_title('', false) . ' ';
} else if (is_page()) {
// Standard page
if ($post->post_parent) {
// If child page, get parents
$anc = get_post_ancestors($post->ID);
// Get parents in the right order
$anc = array_reverse($anc);
// Parent page loop
$parents = "";
foreach ($anc as $ancestor) {
$parents .= '' . get_the_title($ancestor) . ' ';
$parents .= ' ' . $separator . ' ';
}
// Display parent pages
echo $parents;
// Current page
echo ' ' . get_the_title() . ' ';
} else {
// Just display current page if not parents
echo ' ' . get_the_title() . ' ';
}
} else if (is_tag()) {
// Tag page
// Get tag information
$term_id = get_query_var('tag_id');
$taxonomy = 'post_tag';
$args = 'include=' . $term_id;
$terms = get_terms($taxonomy, $args);
$get_term_id = $terms[0]->term_id;
$get_term_slug = $terms[0]->slug;
$get_term_name = $terms[0]->name;
// Display the tag name
echo '' . $get_term_name . ' ';
} elseif (is_day()) {
// Day archive
// Year link
echo '' . get_the_time('Y') . ' Archives ';
echo ' ' . $separator . ' ';
// Month link
echo '' . get_the_time('M') . ' Archives ';
echo ' ' . $separator . ' ';
// Day display
echo ' ' . get_the_time('jS') . ' ' . get_the_time('M') . ' Archives ';
} else if (is_month()) {
// Month Archive
// Year link
echo '' . get_the_time('Y') . ' Archives ';
echo ' ' . $separator . ' ';
// Month display
echo '' . get_the_time('M') . ' Archives ';
} else if (is_year()) {
// Display year archive
echo '' . get_the_time('Y') . ' Archives ';
} else if (is_author()) {
// Auhor archive
// Get the author information
global $author;
$userdata = get_userdata($author);
// Display author name
echo '' . 'Author: ' . $userdata->display_name . ' ';
} else if (get_query_var('paged')) {
// Paginated archives
echo '' . esc_html__('Page', 'grand-popo') . ' ' . get_query_var('paged') . ' ';
} else if (is_search()) {
// Search results page
echo 'Search results for: ' . get_search_query() . ' ';
} elseif (is_404()) {
// 404 page
echo '' . 'Error 404' . ' ';
}
echo ' ';
}
}
}
//remove woocommerce breadcrumb to woocommerce_before_main_content
remove_action('woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0);
// custom sale price
add_filter('woocommerce_sale_price_html', 'grand_popo_get_custom_sales_price', 10, 2);
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;
}
// Custom variable sale price
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', 'grand-popo'), 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', 'grand-popo'), 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
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") {
?>
' : '';
echo (grand_popo_get_proper_value($grand_popo_options, 'opt-social-twitter') != '') ? ' ' : '';
echo (grand_popo_get_proper_value($grand_popo_options, 'opt-social-pinterest') != '') ? ' ' : '';
echo (grand_popo_get_proper_value($grand_popo_options, 'opt-social-instagram') != '') ? ' ' : '';
echo (grand_popo_get_proper_value($grand_popo_options, 'opt-social-google-plus') != '') ? ' ' : '';
echo (grand_popo_get_proper_value($grand_popo_options, 'opt-social-behance') != '') ? ' ' : '';
echo (grand_popo_get_proper_value($grand_popo_options, 'opt-social-dribbble') != '') ? ' ' : '';
echo (grand_popo_get_proper_value($grand_popo_options, 'opt-social-vimeo') != '') ? ' ' : '';
echo (grand_popo_get_proper_value($grand_popo_options, 'opt-social-tumblr') != '') ? ' ' : '';
echo (grand_popo_get_proper_value($grand_popo_options, 'opt-social-linkedIn') != '') ? ' ' : '';
echo (grand_popo_get_proper_value($grand_popo_options, 'opt-social-flickr') != '') ? ' ' : '';
echo (grand_popo_get_proper_value($grand_popo_options, 'opt-social-youtube') != '') ? ' ' : '';
echo (grand_popo_get_proper_value($grand_popo_options, 'opt-social-foursquare') != '') ? ' ' : '';
echo (grand_popo_get_proper_value($grand_popo_options, 'opt-social-github') != '') ? ' ' : '';
?>
esc_html__('Redux Framework', 'grand-popo'), // The plugin name.
'slug' => 'redux-framework', // The plugin slug (typically the folder name).
'required' => true, // If false, the plugin is only 'recommended' instead of required.
),
array(
'name' => esc_html__('grand-popo', 'grand-popo'), // The plugin name.
'slug' => 'grand-popo', // The plugin slug (typically the folder name).
'source' => esc_url('http://static.orionorigin.com/themes/plugins/grand-popo-free-plugin.zip'), // The plugin source.
'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);
}
/**
* Force Visual Composer to initialize as "built into the theme". This will hide certain tabs under the Settings->Visual Composer page
*/
add_action( 'vc_before_init', 'grand_popo_vcSetAsTheme' );
function grand_popo_vcSetAsTheme() {
vc_set_as_theme();
}
//REMOVE SUBCATEGORIES COUNT
add_filter('woocommerce_subcategory_count_html', 'grand_popo_remove_category_products_count');
function grand_popo_remove_category_products_count() {
return;
}
// get footer widget
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' => '');
} 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' => '');
}
register_sidebars($number, $args);
}
add_action('widgets_init', 'grand_popo_custom_widgets_init');
// WOOCOMERCE LOOP WRAPPER
function woocommerce_product_loop_start() {
echo"";
}
function woocommerce_product_loop_end() {
echo "
";
}
//CUSTOM WOOCOMMERCE BREADCRUMBS
add_filter('grand_popo_breadcrumbs_defaults', 'grand_popo_get_grand_popo_breadcrumbss');
function grand_popo_get_grand_popo_breadcrumbss() {
return array(
'delimiter' => ' > ',
'wrap_before' => '',
'wrap_after' => ' ',
'before' => '',
'after' => '',
'home' => _x('Home', 'breadcrumb', 'grand-popo'),
);
}
/**
* 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();
?>
' . get_the_title() . ' ';
}
remove_action('woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10);
add_action('woocommerce_shop_loop_item_title', 'grand_popo_woocommerce_template_loop_product_title', 10);
//CUSTOM FILTER PRICE WIDGET
add_action('widgets_init', 'grand_popo_custom_woocommerce_filter_widgets');
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');
}
}
// Hook in
add_filter('woocommerce_checkout_fields', 'grand_popo_override_checkout_fields');
// Our hooked in function – $fields is passed via the filter!
function grand_popo_override_checkout_fields($fields) {
$fields['billing']['billing_company']['placeholder'] = 'Company';
$fields['billing']['billing_first_name']['placeholder'] = 'First name';
$fields['billing']['billing_last_name']['placeholder'] = 'Last name';
$fields['billing']['billing_email']['placeholder'] = 'Email';
$fields['billing']['billing_phone']['placeholder'] = 'Phone';
$fields['billing']['billing_address_1']['placeholder'] = 'Address';
$fields['billing']['billing_city']['placeholder'] = 'City / Town';
$fields['billing']['billing_state']['placeholder'] = 'State / Country';
$fields['billing']['billing_postcode']['placeholder'] = 'Post Code';
$fields['order']['order_comments']['placeholder'] = 'Your comment';
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;
}
//REMOVE SALE ON SINGLE PRODUCT BEFORE
remove_action('woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10);
//POST FUNCTIONS
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]);
}
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 = ' ';
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 = ' ';
break;
}
return $post_thumb;
}
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;
}
// POST VIEWS
function grand_popo_get_post_views($postID) {
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if ($count == '') {
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, 0);
return "0 View";
}
return $count . ' Views';
}
//count view
function grand_popo_set_post_views($postID) {
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if ($count == '') {
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, 0);
} else {
$count++;
update_post_meta($postID, $count_key, $count);
}
}
function grand_popo_sbt_auto_excerpt_more($more) {
return '.';
}
add_filter('excerpt_more', 'grand_popo_sbt_auto_excerpt_more', 20);
function grand_popo_get_post_share_html() {
global $grand_popo_post_id;
$grand_popo_post_share_html = "
";
echo wp_kses_post($grand_popo_post_share_html);
}
function grand_popo_get_facebook_share_url($grand_popo_post_id) {
$url = get_permalink($grand_popo_post_id);
return "https://www.facebook.com/sharer/sharer.php?u=$url";
}
function grand_popo_get_twitter_share_url($grand_popo_post_id) {
$url = get_permalink($grand_popo_post_id);
$title = get_the_title($grand_popo_post_id);
return "https://twitter.com/home?status=Check%20out%20this%20article:%20" . urlencode($title) . "%20-%20$url";
}
function grand_popo_get_pinterest_share_url($grand_popo_post_id) {
$url = get_permalink($grand_popo_post_id);
$img_id = get_post_thumbnail_id($grand_popo_post_id);
$featured_img = wp_get_attachment_image_src($img_id, "full");
$title = get_the_title($grand_popo_post_id);
return "https://pinterest.com/pin/create/button/?url=$url&media=$featured_img[0]&description=" . urlencode($title);
}
function grand_popo_get_google_share_url($grand_popo_post_id) {
$url = get_permalink($grand_popo_post_id);
return "https://plus.google.com/share?url=$url";
}
// grand_popo get single product navigation
function grand_popo_get_single_product_nav() {
if (is_singular()) {
?>
PREV', FALSE); ?>
', FALSE); ?>
'
. $author_name . ' ' . $author_description . ' ';
?>
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 <= $per_page || -1 === $per_page) { printf(_n('Showing the single result', 'all %d results', $total, 'grand-popo'), $total); } else { printf(_nx('Showing the single result', ' %1$d–%2$d of %3$d results', $total, '%1$d = first, %2$d = last, %3$d = total', '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 ); } } } } } 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; } ?>Grand-Popo Premium
Click here to unlock'.$random_message_key.': '.$messages[$random_message_key] .'