';
}
}, 11 );
// Set the number or products per page
if ( ! function_exists( 'panoramic_loop_shop_per_page' ) ) {
function panoramic_loop_shop_per_page( $cols ) {
// $cols contains the current number of products per page based on the value stored on Options -> Reading
// Return the number of products you wanna show per page.
$cols = get_theme_mod( 'panoramic-woocommerce-products-per-page' );
return $cols;
}
}
add_filter( 'loop_shop_per_page', 'panoramic_loop_shop_per_page', 20 );
if ( ! function_exists( 'panoramic_woocommerce_product_thumbnails_columns' ) ) {
function panoramic_woocommerce_product_thumbnails_columns() {
return 3;
}
}
add_filter ( 'woocommerce_product_thumbnails_columns', 'panoramic_woocommerce_product_thumbnails_columns' );
/**
* Replace Read more buttons for out of stock items
*/
// Display an Out of Stock label on out of stock products
add_action( 'woocommerce_after_shop_loop_item_title', 'panoramic_out_of_stock_notice', 10 );
if ( ! function_exists( 'panoramic_out_of_stock_notice' ) ) {
function panoramic_out_of_stock_notice() {
global $product;
if ( !$product->is_in_stock() ) {
echo '
';
echo __( 'Out of Stock', 'panoramic' );
echo '
';
}
}
}
function panoramic_excerpt_length( $length ) {
if ( is_admin() || ( !is_home() && !is_category() && !is_tag() && !is_search() ) ) {
return $length;
} else {
return intval( get_theme_mod( 'panoramic-blog-excerpt-length', customizer_library_get_default( 'panoramic-blog-excerpt-length' ) ) );
}
}
add_filter( 'excerpt_length', 'panoramic_excerpt_length', 999 );
if ( ! function_exists( 'panoramic_excerpt_more' ) ) {
function panoramic_excerpt_more( $more ) {
if ( is_admin() ) {
return $more;
} else {
return ' ' . wp_kses_post( pll__( get_theme_mod( 'panoramic-blog-read-more-text', customizer_library_get_default( 'panoramic-blog-read-more-text' ) ) ) ) . '';
}
}
}
add_filter( 'excerpt_more', 'panoramic_excerpt_more' );
/**
* Adjust is_home query if panoramic-slider-categories is set
*/
function panoramic_set_blog_queries( $query ) {
$slider_categories = get_theme_mod( 'panoramic-slider-categories', '' );
$slider_type = get_theme_mod( 'panoramic-slider-type', customizer_library_get_default( 'panoramic-slider-type' ) );
if ( $slider_categories != '' && $slider_type == 'panoramic-slider-default' ) {
$is_front_page = ( $query->get('page_id') == get_option('page_on_front') || is_front_page() );
if ( count($slider_categories) > 0) {
// do not alter the query on wp-admin pages and only alter it if it's the main query
if ( !is_admin() && !$is_front_page || !is_admin() && $is_front_page && $query->get('id') != 'slider' ){
$query->set( 'category__not_in', $slider_categories );
}
}
}
}
add_action( 'pre_get_posts', 'panoramic_set_blog_queries' );
function panoramic_filter_recent_posts_widget_parameters( $params ) {
$slider_categories = get_theme_mod( 'panoramic-slider-categories', '' );
$slider_type = get_theme_mod( 'panoramic-slider-type', customizer_library_get_default( 'panoramic-slider-type' ) );
if ( $slider_categories != '' && $slider_type == 'panoramic-slider-default' ) {
if ( count($slider_categories) > 0) {
// do not alter the query on wp-admin pages and only alter it if it's the main query
$params['category__not_in'] = $slider_categories;
}
}
return $params;
}
add_filter('widget_posts_args','panoramic_filter_recent_posts_widget_parameters');
/**
* Adjust the widget categories query if panoramic-slider-categories is set
*/
function panoramic_set_widget_categories_args($args){
$slider_categories = get_theme_mod( 'panoramic-slider-categories', '' );
$slider_type = get_theme_mod( 'panoramic-slider-type', customizer_library_get_default( 'panoramic-slider-type' ) );
if ( $slider_categories != '' && $slider_type == 'panoramic-slider-default' ) {
if ( count($slider_categories) > 0) {
$exclude = implode(',', $slider_categories);
$args['exclude'] = $exclude;
}
}
return $args;
}
add_filter('widget_categories_args', 'panoramic_set_widget_categories_args');
function panoramic_set_widget_categories_dropdown_arg($args){
$slider_categories = get_theme_mod( 'panoramic-slider-categories', '' );
$slider_type = get_theme_mod( 'panoramic-slider-type', customizer_library_get_default( 'panoramic-slider-type' ) );
if ( $slider_categories != '' && $slider_type == 'panoramic-slider-default' ) {
if ( count($slider_categories) > 0) {
$exclude = implode(',', $slider_categories);
$args['exclude'] = $exclude;
}
}
return $args;
}
add_filter('widget_categories_dropdown_args', 'panoramic_set_widget_categories_dropdown_arg');
function panoramic_allowed_tags() {
global $allowedtags;
$allowedtags["h1"] = array();
$allowedtags["h2"] = array();
$allowedtags["h3"] = array();
$allowedtags["h4"] = array();
$allowedtags["h5"] = array();
$allowedtags["h6"] = array();
$allowedtags["p"] = array();
$allowedtags["br"] = array();
$allowedtags["a"] = array(
'href' => true,
'class' => true,
);
$allowedtags["i"] = array(
'class' => true,
);
}
add_action('init', 'panoramic_allowed_tags', 10);
function panoramic_register_required_plugins() {
$plugins = array(
array(
'name' => __( 'Elementor', 'panoramic' ),
'slug' => 'elementor',
'required' => false
),
array(
'name' => __( 'SiteOrigin Widgets Bundle', 'panoramic' ),
'slug' => 'so-widgets-bundle',
'required' => false
),
array(
'name' => __( 'Recent Posts Widget Extended', 'panoramic' ),
'slug' => 'recent-posts-widget-extended',
'required' => false
),
array(
'name' => __( 'Beam me up Scotty', 'panoramic' ),
'slug' => 'beam-me-up-scotty',
'required' => false
),
array(
'name' => __( 'WPForms', 'panoramic' ),
'slug' => 'wpforms-lite',
'required' => false
),
array(
'name' => __( 'Breadcrumb NavXT', 'panoramic' ),
'slug' => 'breadcrumb-navxt',
'required' => false
),
array(
'name' => __( 'WooCommerce', 'panoramic' ),
'slug' => 'woocommerce',
'required' => false
)
);
$config = array(
'id' => 'panoramic', // Unique ID for hashing notices for multiple instances of TGMPA.
'default_path' => get_stylesheet_directory() .'/library/plugins/', // 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', 'panoramic_register_required_plugins' );
/**
* Determine if Custom Post Type
* usage: if ( is_this_a_custom_post_type() )
*
* References/Modified from:
* @link https://codex.wordpress.org/Function_Reference/get_post_types
* @link http://wordpress.stackexchange.com/users/73/toscho <== love this person!
* @link http://wordpress.stackexchange.com/a/95906/64742
*/
function panoramic_is_this_a_custom_post_type( $post = NULL ) {
$all_custom_post_types = get_post_types( array ( '_builtin' => false ) );
//* there are no custom post types
if ( empty ( $all_custom_post_types ) ) return false;
$custom_types = array_keys( $all_custom_post_types );
$current_post_type = get_post_type( $post );
//* could not detect current type
if ( ! $current_post_type )
return false;
return in_array( $current_post_type, $custom_types );
}
/**
* Remove blog menu link class 'current_page_parent' when on an unrelated CPT
* or search results page
* or 404 page
* dep: is_this_a_custom_post_type() function
* modified from: https://gist.github.com/ajithrn/1f059b2201d66f647b69
*/
function panoramic_if_cpt_or_search_or_404_remove_current_page_parent_on_blog_page_link( $classes, $item, $args ) {
if ( panoramic_is_this_a_custom_post_type() || is_search() || is_404() ) {
$blog_page_id = intval( get_option('page_for_posts') );
if ( $blog_page_id != 0 && $item->object_id == $blog_page_id ) {
unset( $classes[array_search( 'current_page_parent', $classes )] );
}
}
return $classes;
}
add_filter( 'nav_menu_css_class', 'panoramic_if_cpt_or_search_or_404_remove_current_page_parent_on_blog_page_link', 10, 3 );
if ( function_exists( 'pll_register_string' ) ) {
/**
* Register some string from the customizer to be translated with Polylang
*/
function panoramic_pll_register_string() {
// Header
pll_register_string( 'panoramic-header-info-text-one', get_theme_mod( 'panoramic-header-info-text-one', customizer_library_get_default( 'panoramic-header-info-text-one' ) ), 'panoramic', false );
// Search
pll_register_string( 'panoramic-search-placeholder-text', get_theme_mod( 'panoramic-search-placeholder-text', customizer_library_get_default( 'panoramic-search-placeholder-text' ) ), 'panoramic', false );
pll_register_string( 'panoramic-website-text-no-search-results-heading', get_theme_mod( 'panoramic-website-text-no-search-results-heading', customizer_library_get_default( 'panoramic-website-text-no-search-results-heading' ) ), 'panoramic', false );
pll_register_string( 'panoramic-website-text-no-search-results-text', get_theme_mod( 'panoramic-website-text-no-search-results-text', customizer_library_get_default( 'panoramic-website-text-no-search-results-text' ) ), 'panoramic', true );
// Header media
pll_register_string( 'panoramic-header-image-text', get_theme_mod( 'panoramic-header-image-text', customizer_library_get_default( 'panoramic-header-image-text' ) ), 'panoramic', true );
// Blog read more
pll_register_string( 'panoramic-blog-read-more-text', get_theme_mod( 'panoramic-blog-read-more-text', customizer_library_get_default( 'panoramic-blog-read-more-text' ) ), 'panoramic', true );
// 404
pll_register_string( 'panoramic-website-text-404-page-heading', get_theme_mod( 'panoramic-website-text-404-page-heading', customizer_library_get_default( 'panoramic-website-text-404-page-heading' ) ), 'panoramic', true );
pll_register_string( 'panoramic-website-text-404-page-text', get_theme_mod( 'panoramic-website-text-404-page-text', customizer_library_get_default( 'panoramic-website-text-404-page-text' ) ), 'panoramic', true );
}
add_action( 'admin_init', 'panoramic_pll_register_string' );
}
/**
* A fallback function that outputs a non-translated string if Polylang is not active
*
* @param $string
*
* @return void
*/
if ( !function_exists( 'pll_e' ) ) {
function pll_e( $str ) {
echo $str;
}
}
/**
* A fallback function that returns a non-translated string if Polylang is not active
*
* @param $string
*
* @return string
*/
if ( !function_exists( 'pll__' ) ) {
function pll__( $str ) {
return $str;
}
}
function panoramic_singular_or_plural( $singular, $plural, $value ) {
$locale = get_locale();
$plural_exceptions = array(
'fr_CA',
'fr_FR',
'fr_BE',
'pt_BR'
);
if ( ( $value == 0 && !in_array( $locale, $plural_exceptions ) ) || $value > 1 ) {
return $plural;
} else {
return $singular;
}
}
Skip to content