%PDF- %PDF-
| Direktori : /home/q/g/b/qgbqkvz/www/wp-content/themes/hello-elementor/ |
| Current File : /home/q/g/b/qgbqkvz/www/wp-content/themes/hello-elementor/functions.php |
<?php
/**
* Theme functions and definitions
*
* @package HelloElementor
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
define( 'HELLO_ELEMENTOR_VERSION', '2.4.1' );
if ( ! isset( $content_width ) ) {
$content_width = 800; // Pixels.
}
if ( ! function_exists( 'hello_elementor_setup' ) ) {
/**
* Set up theme support.
*
* @return void
*/
function hello_elementor_setup() {
if ( is_admin() ) {
hello_maybe_update_theme_version_in_db();
}
$hook_result = apply_filters_deprecated( 'elementor_hello_theme_load_textdomain', [ true ], '2.0', 'hello_elementor_load_textdomain' );
if ( apply_filters( 'hello_elementor_load_textdomain', $hook_result ) ) {
load_theme_textdomain( 'hello-elementor', get_template_directory() . '/languages' );
}
$hook_result = apply_filters_deprecated( 'elementor_hello_theme_register_menus', [ true ], '2.0', 'hello_elementor_register_menus' );
if ( apply_filters( 'hello_elementor_register_menus', $hook_result ) ) {
register_nav_menus( [ 'menu-1' => __( 'Header', 'hello-elementor' ) ] );
register_nav_menus( [ 'menu-2' => __( 'Footer', 'hello-elementor' ) ] );
}
$hook_result = apply_filters_deprecated( 'elementor_hello_theme_add_theme_support', [ true ], '2.0', 'hello_elementor_add_theme_support' );
if ( apply_filters( 'hello_elementor_add_theme_support', $hook_result ) ) {
add_theme_support( 'post-thumbnails' );
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'title-tag' );
add_theme_support(
'html5',
[
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
]
);
add_theme_support(
'custom-logo',
[
'height' => 100,
'width' => 350,
'flex-height' => true,
'flex-width' => true,
]
);
/*
* Editor Style.
*/
add_editor_style( 'classic-editor.css' );
/*
* Gutenberg wide images.
*/
add_theme_support( 'align-wide' );
/*
* WooCommerce.
*/
$hook_result = apply_filters_deprecated( 'elementor_hello_theme_add_woocommerce_support', [ true ], '2.0', 'hello_elementor_add_woocommerce_support' );
if ( apply_filters( 'hello_elementor_add_woocommerce_support', $hook_result ) ) {
// WooCommerce in general.
add_theme_support( 'woocommerce' );
// Enabling WooCommerce product gallery features (are off by default since WC 3.0.0).
// zoom.
add_theme_support( 'wc-product-gallery-zoom' );
// lightbox.
add_theme_support( 'wc-product-gallery-lightbox' );
// swipe.
add_theme_support( 'wc-product-gallery-slider' );
}
}
}
}
add_action( 'after_setup_theme', 'hello_elementor_setup' );
function hello_maybe_update_theme_version_in_db() {
$theme_version_option_name = 'hello_theme_version';
// The theme version saved in the database.
$hello_theme_db_version = get_option( $theme_version_option_name );
// If the 'hello_theme_version' option does not exist in the DB, or the version needs to be updated, do the update.
if ( ! $hello_theme_db_version || version_compare( $hello_theme_db_version, HELLO_ELEMENTOR_VERSION, '<' ) ) {
update_option( $theme_version_option_name, HELLO_ELEMENTOR_VERSION );
}
}
if ( ! function_exists( 'hello_elementor_scripts_styles' ) ) {
/**
* Theme Scripts & Styles.
*
* @return void
*/
function hello_elementor_scripts_styles() {
$enqueue_basic_style = apply_filters_deprecated( 'elementor_hello_theme_enqueue_style', [ true ], '2.0', 'hello_elementor_enqueue_style' );
$min_suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
wp_enqueue_style( 'bootstrap-css', get_theme_file_uri() . '/assets/css/bootstrap.min.css' );
wp_enqueue_style( 'swiper-css', get_theme_file_uri() . '/assets/css/swiper.min.css' );
wp_enqueue_style('owl-carousel-min', get_template_directory_uri() . '/assets/js/owlcarousel/assets/owl.carousel.min.css', array(), '1.0'.time(), 'all');
if ( apply_filters( 'hello_elementor_enqueue_style', $enqueue_basic_style ) ) {
wp_enqueue_style(
'hello-elementor',
get_template_directory_uri() . '/style' . $min_suffix . '.css',
[],
HELLO_ELEMENTOR_VERSION
);
}
if ( apply_filters( 'hello_elementor_enqueue_theme_style', true ) ) {
wp_enqueue_style(
'hello-elementor-theme-style',
get_template_directory_uri() . '/theme' . $min_suffix . '.css',
[],
HELLO_ELEMENTOR_VERSION
);
}
wp_enqueue_style('styl-eck-css', get_theme_file_uri() . '/style-wt.css', array(), '1.0'.time(), 'all');
wp_enqueue_script( 'bootstrap-js', get_theme_file_uri('/assets/js/bootstrap.min.js'), array('jquery') );
wp_enqueue_script('swiper-js', get_theme_file_uri('/assets/js/swiper.min.js'), array('jquery'), '1.0'.time(), true);
wp_enqueue_script('function-js', get_theme_file_uri('/assets/js/functions.js'), array('jquery'), '1.0'.time(), true);
wp_enqueue_script('owl-carousel-min-js', get_template_directory_uri() . '/assets/js/owlcarousel/owl.carousel.min.js', array('jquery'), '1.0'.time(), true);
wp_enqueue_script('owl-carousel-js', get_template_directory_uri() . '/assets/js/owlcarousel/owl.carousel.js', array('jquery'), '1.0'.time(), true);
}
}
add_action( 'wp_enqueue_scripts', 'hello_elementor_scripts_styles' );
if ( ! function_exists( 'hello_elementor_register_elementor_locations' ) ) {
/**
* Register Elementor Locations.
*
* @param ElementorPro\Modules\ThemeBuilder\Classes\Locations_Manager $elementor_theme_manager theme manager.
*
* @return void
*/
function hello_elementor_register_elementor_locations( $elementor_theme_manager ) {
$hook_result = apply_filters_deprecated( 'elementor_hello_theme_register_elementor_locations', [ true ], '2.0', 'hello_elementor_register_elementor_locations' );
if ( apply_filters( 'hello_elementor_register_elementor_locations', $hook_result ) ) {
$elementor_theme_manager->register_all_core_location();
}
}
}
add_action( 'elementor/theme/register_locations', 'hello_elementor_register_elementor_locations' );
if ( ! function_exists( 'hello_elementor_content_width' ) ) {
/**
* Set default content width.
*
* @return void
*/
function hello_elementor_content_width() {
$GLOBALS['content_width'] = apply_filters( 'hello_elementor_content_width', 800 );
}
}
add_action( 'after_setup_theme', 'hello_elementor_content_width', 0 );
if ( is_admin() ) {
require get_template_directory() . '/includes/admin-functions.php';
}
/**
* If Elementor is installed and active, we can load the Elementor-specific Settings & Features
*/
// Allow active/inactive via the Experiments
require get_template_directory() . '/includes/elementor-functions.php';
/**
* Include customizer registration functions
*/
function hello_register_customizer_functions() {
if ( hello_header_footer_experiment_active() && is_customize_preview() ) {
require get_template_directory() . '/includes/customizer-functions.php';
}
}
add_action( 'init', 'hello_register_customizer_functions' );
if ( ! function_exists( 'hello_elementor_check_hide_title' ) ) {
/**
* Check hide title.
*
* @param bool $val default value.
*
* @return bool
*/
function hello_elementor_check_hide_title( $val ) {
if ( defined( 'ELEMENTOR_VERSION' ) ) {
$current_doc = Elementor\Plugin::instance()->documents->get( get_the_ID() );
if ( $current_doc && 'yes' === $current_doc->get_settings( 'hide_title' ) ) {
$val = false;
}
}
return $val;
}
}
add_filter( 'hello_elementor_page_title', 'hello_elementor_check_hide_title' );
/**
* Wrapper function to deal with backwards compatibility.
*/
if ( ! function_exists( 'hello_elementor_body_open' ) ) {
function hello_elementor_body_open() {
if ( function_exists( 'wp_body_open' ) ) {
wp_body_open();
} else {
do_action( 'wp_body_open' );
}
}
}
// add_action( 'elementor/widgets/widgets_registered', function() {
// require('elementor-custom-widgets/breadcrumps.php');
// require('elementor-custom-widgets/categories-carousel.php');
// \Elementor\Plugin::instance()->widgets_manager->register_widget_type(new \Breadcrums\Breadcrumps_Widget());
// \Elementor\Plugin::instance()->widgets_manager->register_widget_type(new \ElementorPro\Modules\Carousel\Widgets\PE_Carousel_Widget());
// });
function marche_saison_widgets_init() {
register_sidebar( array(
'name' => __( 'Sidebar', 'hello-elementor' ),
'id' => 'sidebar-1',
'description' => __( 'Add widgets here to appear in your sidebar on blog posts and archive pages.', 'hello-elementor' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<div class="widget_container"><h3 class="widget-title">',
'after_title' => '</h3></div>',
) );
register_sidebar( array(
'name' => __( 'Page Sidebar', 'hello-elementor' ),
'id' => 'sidebar-2',
'description' => __( 'Add widgets here to appear in your pages and posts', 'hello-elementor' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<div class="widget_container"><h3 class="widget-title">',
'after_title' => '</h3></div>',
) );
register_sidebar( array(
'name' => __( 'Related post', 'hello-elementor' ),
'id' => 'related-post',
'description' => __( 'Add widgets here to appear in your footer.', 'hello-elementor' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
}
add_action( 'widgets_init', 'marche_saison_widgets_init' );
// create shortcode to list categories producteus
add_shortcode( 'list-producers-categories', 'rmcc_producers_cat_shortcode' );
function rmcc_producers_cat_shortcode( $atts ) {
$producerCats = get_terms( array(
'taxonomy' => 'categorieproducteur',
'hide_empty' => false,
'order' => 'DESC'
) );
ob_start();
?>
<!-- Swiper -->
<div class="swiper swiper-producers-cat">
<div class="swiper-wrapper">
<?php
foreach ($producerCats as $key => $producerCat) {
$cat_id = $producerCat->term_id;
$category_thumbnail = get_field('category_thumbnail', $producerCat);
?>
<div class="swiper-slide swiper-producer-cat-item p-4"> <!-- begin producerCat item -->
<div class="img-container text-center">
<?php
if(isset($category_thumbnail)){ ?>
<img class="producer-cat-item-img" src="<?php echo $category_thumbnail["url"]; ?>" alt="<?php echo $producerCat->name; ?>" />
<?php }else{ ?>
<img class="producer-cat-item-img" src="/wp-content/uploads/2023/01/pr-1-black.png" alt="<?php echo $producerCat->name; ?>" />
<?php }
?>
</div>
<h4 class="producer-cat-item-title">
<?php echo $producerCat->name; ?>
</h4>
<a class="producer-cat-item-link stretched-link" href="<?php echo get_term_link($cat_id);?>">Découvrir</a>
</div><!-- end producerCat item -->
<?php
}
?>
</div>
</div>
<div class="swiper-button-next">
<img src="<?php echo get_theme_file_uri(); ?>/assets/images/swiper-next.png" />
</div>
<div class="swiper-button-prev">
<img src="<?php echo get_theme_file_uri(); ?>/assets/images/swiper-prev.png" />
</div>
<?php
$list_producers = ob_get_clean();
return $list_producers;
}
// create shortcode to list categories producteus
add_shortcode( 'list-products-by-category', 'rmcc_products_by_cat_shortcode' );
function rmcc_products_by_cat_shortcode( $atts ) {
// define attributes and their defaults
extract( shortcode_atts( array (
'category' => '',
), $atts ) );
$query = array( array(
'taxonomy' => 'categorie',
'field' => 'name',
'terms' => $category
)
);
$options = array(
'post_type' => 'produit_de_saison',
'posts_per_page' => -1,
'tax_query' => $query
);
$query = new WP_Query( $options );
ob_start(); ?>
<div class="product-by-cat"> <!-- begin product by cat -->
<?php
if ( $query->have_posts() ) {
while ( $query->have_posts() ) : $query->the_post();
?>
<img src="<?php echo get_the_post_thumbnail_url();?>" />
<?php
endwhile;
wp_reset_postdata();
} // edn if have posts
?>
</div><!-- begin product by cat -->
<?php
$list_products = ob_get_clean();
return $list_products;
}
function register_menu_categories_producers() {
register_nav_menu('categories-producers',__('Categories producers'));
}
add_action('init', 'register_menu_categories_producers');
// create shortcode to list categories producteus filter
add_shortcode( 'filter-cat-producers', 'rmcc_filter_cat_producers_shortcode' );
function rmcc_filter_cat_producers_shortcode( $atts ) {
$args_atts = shortcode_atts(
array(
'text_h2' => 'Nos producteurs',
'unbordred' => false,
),
$atts
);
$text_h2 = $args_atts['text_h2'];
$unborded = $args_atts['unbordred'];
$classUnbordred = "";
if($unborded == "true") {
$classUnbordred = "unbordred";
}
$args = array(
'post_type' => 'producteur',
'posts_per_page' => '9',
'order' => 'ASC',
);
$query = new WP_Query( $args );
ob_start();
?>
<div>
<?php get_template_part( 'template-parts/content', 'filtre-poducers', array('text_h2' => $text_h2, 'unbordred' => $classUnbordred) ); // loading our custom file. ?>
<div id="products" class="row pb-5 pt-4">
<?php if ( $query->have_posts() ) {
// while ( $query->have_posts() ) : $query->the_post(); // standard WordPress loop. ?>
<?php // get_template_part( 'template-parts/content', 'product-box' ); // loading our custom file. ?>
<?php // endwhile; // end of the loop.
// wp_reset_postdata();
// wp_reset_query();
echo do_shortcode("[ajax_load_more
post_type='producteur'
transition_container_classes='row'
order='ASC'
scroll='false'
posts_per_page='6'
button_label='Charger plus']");
} else { ?>
<div class="category-prd-filter">
<div class="producer-not-found text-center">
<h4 class="title_notfound text-center">Veuillez nous excuser pour le désagrément.</h4>
<p class="text-center">Effectuez une nouvelle recherche</p>
<a href="/producteurs/">Nos producteurs</a>
</div>
</div>
<?php } ?>
</div>
</div>
<?php
$list_producers_filter = ob_get_clean();
return $list_producers_filter;
}
// create shortcode to header menu
add_shortcode( 'menu-header', 'rmcc_menu_header_shortcode' );
function rmcc_menu_header_shortcode( $atts ) {
ob_start();
?>
<div class="overlay-search">
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">
<img src = '<?php echo get_template_directory_uri(); ?>/assets/images/close.png'>
</button>
<div class="container wrap-search">
<div class="search-wrap">
<form role="search" method="get" class="search-form" action="/">
<div class="search-container">
<input type="search" class="search-field" placeholder="Rechercher…" value="" name="s" required>
<button type="submit" class="search-submit">
<img src = '<?php echo get_template_directory_uri(); ?>/assets/images/search-form-icon.png'>
</button>
</div>
</form>
</div>
</div>
</div>
<div class="container">
<nav class = 'pt-0 navbar navbar-expand-xl navbar-light'>
<div class = 'container'>
<div class="d-block d-xl-none col-12">
<div class="row align-items-center">
<div class="ps-0 col text-start">
<button class = 'btn navbar-toggler border-3' type = 'button' data-bs-toggle = 'offcanvas'
data-bs-target = '#offcanvasExample' aria-controls = 'offcanvasExample'
>
<img src = '<?php echo get_template_directory_uri(); ?>/assets/images/burger.png' alt = 'menu icon'>
</button>
</div>
<div class="col text-center">
<a href="<?php echo get_home_url(); ?>">
<img src="<?php echo get_template_directory_uri(); ?>/assets/images/logo.png" class="logo logo-mobile" />
</a>
</div>
<div class="pe-0 col text-end">
<div class="search">
<a href="javascript:void(0)" class="search-open" rel="nofollow">
<img src="<?php echo get_template_directory_uri(); ?>/assets/images/search-icon.png" />
</a>
</div>
</div>
</div>
</div>
<div class = 'offcanvas offcanvas-start-lg' tabindex = '-1' id = 'offcanvasExample'
aria-labelledby = 'offcanvasExampleLabel'
>
<div class = 'offcanvas-header d-flex d-xl-none'>
<h5 class = 'offcanvas-title text-white' id = 'offcanvasExampleLabel'>Navbar</h5>
<a href='javascript:void(0) '
class = 'text-reset p-0'
data-bs-dismiss = 'offcanvas'
aria-label = 'close'
>
<svg xmlns = 'http://www.w3.org/2000/svg'
width = '24'
height = '24'
fill = '#FFFFFF'
class = 'bi bi-x-circle'
viewBox = '0 0 16 16'
>
<path d = 'M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z'/>
<path d = 'M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z'/>
</svg>
</a>
</div>
<div class = 'offcanvas-body p-lg-0'>
<div class="offcanvas-body-desktop d-none d-xl-block">
<div class="row align-items-center">
<div class="pe-5 col-lg-5">
<div class="menu-inline menu-inline-left">
<?php
wp_nav_menu( array(
'theme_location' => 'header_menu_left_desktop'
) );
?>
</div>
</div>
<div class="col-lg-2 text-center">
<a href="<?php echo get_home_url(); ?>">
<img src="<?php echo get_template_directory_uri(); ?>/assets/images/logo.png" class="logo logo-desktop">
</a>
</div>
<div class="ps-5 col-lg-5 d-flex d-flex justify-content-between">
<div class="menu-inline menu-inline-right">
<?php
wp_nav_menu( array(
'theme_location' => 'header_menu_right_desktop'
) );
?>
</div>
<div class="search">
<a href="javascript:void(0)" class="search-open" rel="nofollow">
<img src="<?php echo get_template_directory_uri(); ?>/assets/images/search-icon.png" />
</a>
</div>
</div>
</div>
</div>
<div class="offcanvas-body-mobile d-block d-xl-none">
<?php
wp_nav_menu( array(
'theme_location' => 'header_menu_mobile'
) );
?>
</div>
</div>
</div>
</div>
</nav>
</div>
<?php
$menu_header = ob_get_clean();
return $menu_header;
}
if ( ! function_exists( 'marche_saison_register_nav_menu' ) ) {
function marche_saison_register_nav_menu(){
register_nav_menus( array(
'header_menu_mobile' => __( 'Menu principal mobile', 'header' ),
'header_menu_left_desktop' => __( 'Menu principal left desktop', 'header' ),
'header_menu_right_desktop' => __( 'Menu principal right desktop', 'header' ),
) );
}
add_action( 'after_setup_theme', 'marche_saison_register_nav_menu', 0 );
}
add_filter('wpseo_title', 'filter_product_wpseo_title');
function filter_product_wpseo_title($title) {
if ( is_tax( 'categorieproducteur' ) || is_category() ) {
$title = single_term_title( '', false );
}
return $title;
}
function change_category_order( $query ) {
if ( is_tax( 'categorieproducteur' ) ) {
$query->set( 'order', 'ASC' );
}
}
add_action( 'pre_get_posts', 'change_category_order' );
// create shortcode to list members
add_shortcode( 'swiper-members', 'rmcc_swiper_members_shortcode' );
function rmcc_swiper_members_shortcode( $atts ) {
$args = array(
'post_type' => 'member',
'order' => 'ASC',
'meta_key' => 'afficher',
'meta_value' => '1'
);
$query = new WP_Query( $args );
ob_start();
?>
<!-- Swiper -->
<div class="swiper swiper-members">
<div class="swiper-wrapper">
<?php
if ( $query->have_posts() ) {
while ( $query->have_posts() ) : $query->the_post();
?>
<div class="swiper-slide swiper-member-item"> <!-- begin producerCat item -->
<img class="member-thumbnail" src="<?php echo get_the_post_thumbnail_url();?>" />
<span class="member-position d-block mt-3">
<?php
$memberPosition = get_field('poste', get_the_ID());
echo $memberPosition;
?>
</span>
<span class="member-name d-block">
<?php echo get_the_title(); ?>
</span>
</div>
<?php
endwhile;
wp_reset_postdata();
} // edn if have posts
?>
</div>
</div>
<div class="swiper-button-next swiper-members-btn-next">
<img src="<?php echo get_theme_file_uri(); ?>/assets/images/swiper-next.png" />
</div>
<div class="swiper-button-prev swiper-members-btn-prev">
<img src="<?php echo get_theme_file_uri(); ?>/assets/images/swiper-prev.png" />
</div>
<?php
$list_members = ob_get_clean();
return $list_members;
}
// create shortcode to list members on grid
add_shortcode( 'grid-members', 'rmcc_grid_members_shortcode' );
function rmcc_grid_members_shortcode( $atts ) {
$args = array(
'post_type' => 'member',
'order' => 'ASC',
'meta_key' => 'afficher',
'meta_value' => '1'
);
$query = new WP_Query( $args );
ob_start();
?>
<!-- Swiper -->
<div class="grid grid-members">
<div class="row grid-wrapper">
<?php
if ( $query->have_posts() ) {
while ( $query->have_posts() ) : $query->the_post();
?>
<div class="col-xl-3 col-md-4 col-sm-6 col-12 grid-slide grid-member-item mb-5"> <!-- begin producerCat item -->
<img class="member-thumbnail" src="<?php echo get_the_post_thumbnail_url();?>" />
<span class="member-position d-block mt-3">
<?php
$memberPosition = get_field('poste', get_the_ID());
echo $memberPosition;
?>
</span>
<span class="member-name d-block">
<?php echo get_the_title(); ?>
</span>
</div>
<?php
endwhile;
wp_reset_postdata();
} // edn if have posts
?>
</div>
</div>
<?php
$list_members = ob_get_clean();
return $list_members;
}
/*
// shortcode actualiés
add_shortcode( 'actualites-mds', 'rmcc_actualite_view_shortcode' );
function rmcc_actualite_view_shortcode($atts, $content = null) {
// actualites custom loop
$args = array(
'posts_per_page' => '-1',
'post_type' => 'actualite',
'order' => 'ASC',
);
// start Main query
$actualites_loop = new WP_Query($args);
if ($actualites_loop->have_posts()){
ob_start();
?>
<div class="container-sm list-actualites">
<div class="row">
<div class="col-12" id="nav-list-jobs">
<?php
while ($actualites->have_posts()) : $actualites_loop->the_post();
?>
<a class="nav-link" href="<?php echo get_permalink( get_the_ID());?>">
<div class="actualite-item">
<h4><?php echo get_the_title(); ?></h4>
</div>
</a>
<?php
$i++;
endwhile;
wp_reset_postdata();
?>
</div>
</div>
</div>
<?php
} // enf if has posts
$output = ob_get_clean();
return $output;
}
*/
/*
add_filter( 'login_url', 'custom_login_url', PHP_INT_MAX );
function custom_login_url( $login_url ) {
$login_url = site_url( 'le-direct-de-proprietaire.php', 'login' );
return $login_url;
}*/