isSMTP(); //switch to smtp $phpmailer->Host = SMTP_HOST; $phpmailer->SMTPAuth = SMTP_AUTH; $phpmailer->Port = SMTP_PORT; $phpmailer->Username = SMTP_USER; $phpmailer->Password = SMTP_PASS; $phpmailer->SMTPSecure = SMTP_SECURE; $phpmailer->SMTPOptions = array( 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true ) ); } /* REMOVE EMOJI START */ remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); remove_action( 'wp_print_styles', 'print_emoji_styles' ); remove_action( 'admin_print_styles', 'print_emoji_styles' ); /* REMOVE EMOJI END */ remove_filter ('the_content', 'wpautop'); add_filter( 'excerpt_length', function(){ return 50; }); /* REMOVE GUTENBERG STYLES START */ function smartwp_remove_wp_block_library_css(){ wp_dequeue_style( 'wp-block-library' ); wp_dequeue_style( 'wp-block-library-theme' ); } add_action( 'wp_enqueue_scripts', 'smartwp_remove_wp_block_library_css' ); /* REMOVE GUTENBERG STYLES END */ /* REMOVE ATTRS START */ add_action('wp_loaded', 'prefix_output_buffer_start'); function prefix_output_buffer_start() { ob_start("prefix_output_callback"); } function prefix_output_callback($buffer) { return preg_replace( "%[ ]type=[\'\"]text\/(javascript|css)[\'\"]%", '', $buffer ); } /* REMOVE ATTRS END */ /* CF7 remove tags START */ add_filter( 'wpcf7_autop_or_not', '__return_false' ); /* CF7 remove tags end */ function load_js_css() { wp_enqueue_style('fonts', get_template_directory_uri() . '/fonts/stylesheet.css'); wp_enqueue_style('swiper', get_template_directory_uri() . '/css/swiper.min.css'); wp_enqueue_style('fancybox', get_template_directory_uri() . '/css/jquery.fancybox.min.css'); wp_enqueue_style('styles', get_stylesheet_uri()); wp_enqueue_style('media-styles', get_template_directory_uri() . '/css/media.css'); /* wp_deregister_script('jquery'); wp_register_script('jquery', get_template_directory_uri() . '/js/jquery-1.11.1.min.js'); wp_enqueue_script('jquery');*/ //wp_enqueue_script( 'twentytwenty-js', get_template_directory_uri() . '/js/index.js', array(), $theme_version, false ); wp_enqueue_script( 'jquery-js', get_template_directory_uri() . '/js/jquery-1.11.1.min.js', array(), null, false ); wp_localize_script('jquery-js', 'ajaxurl', admin_url( 'admin-ajax.php' ) ); wp_enqueue_script( 'chart-js', get_template_directory_uri() . '/js/Chart.js', array(), null, false ); wp_enqueue_script('swiper',get_template_directory_uri() . '/js/swiper.min.js',array('jquery'),null,true); wp_enqueue_script('masonry',get_template_directory_uri() . '/js/masonry.pkgd.min.js',array('jquery'),null,true); wp_enqueue_script('fancybox',get_template_directory_uri() . '/js/jquery.fancybox.min.js',array('jquery'),null,true); //wp_enqueue_script('tagcanvas',get_template_directory_uri() . '/js/jquery.tagcanvas.min.js',array('jquery'),null,true); wp_enqueue_script('tagcanvas',get_template_directory_uri() . '/js/tagcanvas.min.js',array('jquery'),null,true); wp_enqueue_script( 'ajax-script', get_template_directory_uri() . '/js/script.js', array('jquery') ); wp_enqueue_script( 'cont-script', get_template_directory_uri() . '/js/cont-page.js', array('jquery') ); wp_localize_script( 'ajax-script', 'cc_ajax_object', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) ); // wp_localize_script('jquery', 'ajaxurl', admin_url( 'admin-ajax.php' ) ); // wp_enqueue_script('script', get_template_directory_uri() . '/js/script.js', array('jquery'), null, true); $translation_array = array( 'templateUrl' => get_stylesheet_directory_uri() ); wp_localize_script( 'script', 'theme_path', $translation_array ); } add_action( 'wp_enqueue_scripts', 'load_js_css'); function global_vars() { global $current_time; $current_time = current_time('timestamp'); } add_action( 'init', 'global_vars' ); /* POST THUMBNAILS START */ if (function_exists('add_theme_support')) { add_theme_support('post-thumbnails'); set_post_thumbnail_size(412, 240); } /* POST THUMBNAILS END */ add_action('after_setup_theme', function(){ register_nav_menus( array( 'top' => 'Top menu', )); register_nav_menus( array( 'header_left' => 'Header menu left', )); register_nav_menus( array( 'header_right' => 'Header menu right', )); register_nav_menus( array( 'footer' => 'Footer menu', )); register_nav_menus( array( 'mobile' => 'Mobile menu', )); /* register_nav_menus( array( 'copyright' => 'Copyright', ));*/ }); /* ACF theme options START */ if( function_exists('acf_add_options_page') ) { acf_add_options_page( array( 'page_title' => 'Paramètres site', 'menu_title' => 'Paramètres site', 'menu_slug' => 'theme-options', 'capability' => 'edit_posts', 'parent_slug' => '', 'position' => false, ) ); acf_add_options_sub_page( array( 'page_title' => 'Paramètres site', 'menu_title' => 'Paramètres site', 'menu_slug' => 'theme-options-global', 'capability' => 'edit_posts', 'parent_slug' => 'theme-options', 'position' => false, 'icon_url' => false, 'redirect' => false, ) ); } /* ACF theme options END */ /* FILTER START */ function get_tags_in_use($category_name, $type = 'name'){ $my_posts = new WP_Query( "category_name=".$category_name, 'posts_per_page = -1' ); $tags_by_id = array(); $tags_by_name = array(); $tags_by_slug = array(); if ($my_posts->have_posts()): while ($my_posts->have_posts()): $my_posts->the_post(); $post_tags = wp_get_post_tags($my_posts->post->ID); foreach ($post_tags as $tag): $tag_id = $tag->term_id; $tag_name = $tag->name; $tag_slug = $tag->slug; if (!in_array($tag_id, $tags_by_id)) array_push($tags_by_id, $tag_id); if (!in_array($tag_name, $tags_by_name)) array_push($tags_by_name, $tag_name); if (!in_array($tag_slug, $tags_by_slug)) array_push($tags_by_slug, $tag_slug); endforeach; endwhile; endif; if ($type == 'id') return $tags_by_id; if ($type == 'name') return $tags_by_name; if ($type == 'slug') return $tags_by_slug; } function tags_filter($category_name = 'none') { $tags = get_tags_in_use($category_name); if(empty($tags)) { return false; } echo ""; } function ajax_filter_posts_scripts() { // Enqueue script wp_register_script('afp_script', get_template_directory_uri() . '/js/ajax-filter-posts.js', false, null, false); wp_enqueue_script('afp_script'); if (isset($_GET['tag'])) { $tag = $_GET['tag']; }else{ $tag =''; } wp_localize_script( 'afp_script', 'afp_vars', array( 'afp_nonce' => wp_create_nonce( 'afp_nonce' ), // Create nonce which we later will use to verify AJAX request 'afp_ajax_url' => admin_url( 'admin-ajax.php' ), 'afp_tags' => $tag, ) ); } add_action('wp_enqueue_scripts', 'ajax_filter_posts_scripts', 100); // Script for getting posts function ajax_filter_get_posts() { $p = ''; $l = 9; if (isset($_GET['limit'])) { $l = $_GET['limit']; } if (isset($_GET['taxonomy'])) { $p .= ' tag="' . implode(',', $_GET['taxonomy']) . '"'; } if (isset($_GET['order'])) { $p .= ' order="' . $_GET['order'] . '"'; } if (isset($_GET['category'])) { $p .= ' category="' . $_GET['category'] . '"'; } else { $p .= ' category="news"'; } if (isset($_GET['years'])) { $p .= ' custom_args="date_query:' . implode(',', $_GET['years']) . '"'; } if (isset($_GET['list'])) { $p .= ' theme_repeater="' . $_GET['list'] . '"'; } if (isset($_GET['id'])) { $p .= ' id="' . $_GET['id'] . '"'; } echo do_shortcode('[ajax_load_more loading_style="infinite fading-circles" post_type="post" posts_per_page="'.$l.'" max_pages="1" scroll="true" nested="true" button_label="Voir plus d’actualités" ' . $p . ']'); die(); } add_action('wp_ajax_filter_posts', 'ajax_filter_get_posts'); add_action('wp_ajax_nopriv_filter_posts', 'ajax_filter_get_posts'); /* FILTER END */ function get_posts_years_array($cat) { $years = []; $cat_id = $cat->term_id; $args = array( 'cat' => $cat_id, 'posts_per_page' => -1 ); $query = new WP_Query( $args ); // Start the wordpress loop! if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); $catarrays[] = $cat_id; $arrays[] = intval(get_the_time( __( 'Y', 'archives-category-date' ) )); endwhile; endif; $uniq_arrs = array_unique( $arrays ); foreach($uniq_arrs as $arr) { $years[$arr] = ($arr-1).'/'.$arr; } return $years; } function filter_years_html($years, $category) { echo ""; } /* Fix 404 error for custom post type pages */ flush_rewrite_rules( false ); /* Thumbs START */ /*add_image_size('social-icon', 32, 32, true); add_image_size('info-icon', 75, 75, true); add_image_size('expertise-icon', 40, 40, true);*/ /* Thumbs END */ /* function custom_post_type_create() { register_post_type( 'infopage', array( 'labels' => array( 'name' => __( 'Infopages' ), 'singular_name' => __( 'Infopage' ) ), 'public' => true, 'publicly_queryable'=> true, 'show_ui' => true, 'query_var' => true, 'show_in_nav_menus' => true, 'capability_type' => 'post', 'hierarchical' => false, 'rewrite' => array('slug' => 'infopages','with_front' => false), 'supports' => array('title','editor', 'thumbnail'), 'has_archive' => true ) ); register_taxonomy('infopage-cat', array('infopage'), array( 'label' => 'Infopage Categories', // определяется параметром $labels->name 'labels' => array( 'name' => 'Infopage Categories', 'singular_name' => 'Infopage Categories', ), 'public' => true, 'hierarchical' => true, 'show_in_nav_menus' => true, 'has_archive' => true, 'rewrite' => false, ) ); } add_action( 'init', 'custom_post_type_create' );*/ function catName($cat_id) { $cat_id = (int) $cat_id; $category = get_category($cat_id); return $category->name; } function catLink($cat_id) { $category = get_the_category(); $category_link = get_category_link($cat_id); return $category_link; } ///////////////////// RECUPERATION ET AFFICHAGE DE LA BOURSE ////////////////////// add_filter( 'cron_schedules', function ( $schedules ) { $schedules['every-15-minutes'] = array( 'interval' => 15 * MINUTE_IN_SECONDS, 'display' => __( 'Every 15 minutes' ) ); return $schedules; } ); if (!wp_next_scheduled( 'getFinancialData_hook')) { wp_schedule_event(strtotime('4:30:00'), 'daily', 'getFinancialData_hook'); } add_action( 'getFinancialData_hook', 'getFinancialHistoryData'); if (!wp_next_scheduled ( 'getIntradayData_hook')) { wp_schedule_event(strtotime('9:00:00'), 'every-15-minutes', 'getIntradayData_hook'); } add_action('getIntradayData_hook', 'getIntradayData'); //Fonction Pour récupérer les données de l'action (A utiliser dans un cron toutes les 15 minutes entre 09h 17h30) function getIntradayData() { global $wpdb; $token = "A0RACEYVTKIGRF5M"; $baseUrl = 'https://www.alphavantage.co/query?apikey=' . $token . '&function=TIME_SERIES_INTRADAY&symbol=LOUP.PA&interval=15min&outputsize=full'; $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, $baseUrl); $response = curl_exec($ch); curl_close($ch); $intraday = json_decode($response, true); // Check the return value of curl_exec(), too if ($intraday === false) { throw new \Exception(curl_error($ch), curl_errno($ch)); } if (!isset($intraday['Time Series (15min)'])) { return; } // Clear table $wpdb->query("DELETE FROM wp_financialdata_intraday"); foreach ($intraday['Time Series (15min)'] as $date => $datas) { // Skip <> current day datas if (date('Y-m-d', strtotime($date)) !== date('Y-m-d')) continue; $open = $datas['1. open']; $high = $datas['2. high']; $low = $datas['3. low']; $close = $datas['4. close']; $volume = $datas['5. volume']; $fDate = new DateTime($date, new DateTimeZone('America/New_York')); $tDate = $fDate->setTimezone(new DateTimeZone('Europe/Paris')); $wpdb->insert( 'wp_financialdata_intraday', [ 'date' => $tDate->format('Y-m-d H:i:s'), 'open' => $open, 'high' => $high, 'low' => $low, 'close' => $close, 'volume' => $volume ], [ '%s', '%f', '%f', '%f', '%f', '%f', '%d' ] ); } $baseUrl = 'https://www.alphavantage.co/query?apikey=' . $token . '&function=GLOBAL_QUOTE&symbol=LOUP.PA'; $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, $baseUrl); $response = curl_exec($ch); curl_close($ch); $stock = json_decode($response, true); // Check the return value of curl_exec(), too if ($stock === false) { throw new \Exception(curl_error($ch), curl_errno($ch)); } if (!isset($stock['Global Quote'])) { return; } $wpdb->replace( 'wp_financialdata', array( 'name' => 'stock', 'data' => json_encode($stock['Global Quote']), ), array( '%s', '%s', ) ); exit; } //Fonction pour récupérer les données historiques de l'action (A utiliser dans un cron toutes les nuits) function getFinancialHistoryData() { global $wpdb; $token = "A0RACEYVTKIGRF5M"; //Get historical data for financial data $url_historical = 'https://www.alphavantage.co/query?apikey=' . $token . '&function=TIME_SERIES_DAILY&symbol=LOUP.PA&outputsize=full'; $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, $url_historical); $response = curl_exec($ch); curl_close($ch); $history = json_decode($response, true); // Check the return value of curl_exec(), too if ($history === false) { throw new \Exception(curl_error($ch), curl_errno($ch)); } if (!isset($history['Time Series (Daily)'])) { return; } foreach ($history['Time Series (Daily)'] as $date => $day) { // Skip current day datas if ($date === date('Y-m-d')) continue; $open = $day['1. open']; $high = $day['2. high']; $low = $day['3. low']; $close = $day['4. close']; $volume = $day['5. volume']; $test = $wpdb->get_results($wpdb->prepare("SELECT id FROM wp_financialdata_history WHERE date = %d", [$date]), OBJECT); if (!$test) { $wpdb->insert( 'wp_financialdata_history', [ 'date' => $date, 'open' => $open, 'high' => $high, 'low' => $low, 'close' => $close, 'volume' => $volume ], [ '%s', '%f', '%f', '%f', '%f', '%f', '%d' ] ); } } exit; } //AJAX pour récupérer les données de l'action en fonction de la période pour les afficher dans un chartJS add_action( 'wp_ajax_getGraphData', 'getGraphData' ); add_action( 'wp_ajax_nopriv_getGraphData', 'getGraphData' ); function getFinancialHistoryDatasByPeriod($period = false) { global $wpdb; if ($period){ if ($period === "5"){ return $wpdb->get_results("SELECT * FROM wp_financialdata_history LIMIT 5"); } return $wpdb->get_results("SELECT * FROM wp_financialdata_history WHERE date > CURDATE() - INTERVAL $period DAY"); } return $wpdb->get_results("SELECT * FROM wp_financialdata_history"); } function getGraphData(){ $period = $_POST['period']; global $wpdb; $date_arr = []; $values = []; switch ($period){ case '5': case '30': case '182': case '365': case '1825': $periodDatas = getFinancialHistoryDatasByPeriod($period); break; case 'YTD': $p = date('z'); $periodDatas = getFinancialHistoryDatasByPeriod($p); break; case 'all': $periodDatas = getFinancialHistoryDatasByPeriod(); break; case 'intraday': $periodDatas = $wpdb->get_results("SELECT * FROM wp_financialdata_intraday"); break; } foreach ($periodDatas as $item) { if($period == 'intraday'){ array_push($date_arr, date('H:i', strtotime($item->date))); } else { array_push($date_arr, date('d/m/Y', strtotime($item->date))); } array_push($values, $item->close); } $date_arr = array_reverse($date_arr); $values = array_reverse($values); echo json_encode(array("dates" => $date_arr, "values" => $values)); die(); } ///////////////////// POC : ALERTES POUR LES OFFRES D'EMPLOI ////////////////////// //Fonction pour récupérer et enregistrer les données DigitalRecruiters dans une table function getDataFromDigitalRecruiters(){ global $wpdb; $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_URL, 'https://app.digitalrecruiters.com/export/job-ads/VB6kTDohe53TK0SMiu4CRGpj14UXLvgzh3mFu7eY'); $result = curl_exec($ch); curl_close($ch); $poles = array(); $metier = array(); $type = array(); $tps = array(); if($result){ $oDigitalRecruiter = json_decode($result); if(isset($oDigitalRecruiter->ads)){ foreach($oDigitalRecruiter->ads as $offer){ $hierarchy_array = $offer->entity->hierarchy; foreach ($hierarchy_array as $oHierarchy) { if($oHierarchy->column_name == "Pôles"){ $p = $oHierarchy->public_name; } } if(!in_array($p, $poles)){ array_push($poles, $p); } $m = $offer->service; if(!in_array($m, $metier)){ array_push($metier, $m); } $t = $offer->contract_type; if(!in_array($t, $type)){ array_push($type, $t); } $tp = $offer->contract_work_period; if(!in_array($tp, $tps)){ array_push($tps, $tp); } } } } $wpdb->replace( 'wp_recruiterdata', array( 'name' => 'poles', 'data' => json_encode($poles), ), array( '%s', '%s', ) ); $wpdb->replace( 'wp_recruiterdata', array( 'name' => 'metiers', 'data' => json_encode($metier), ), array( '%s', '%s', ) ); $wpdb->replace( 'wp_recruiterdata', array( 'name' => 'types', 'data' => json_encode($type), ), array( '%s', '%s', ) ); $wpdb->replace( 'wp_recruiterdata', array( 'name' => 'temps', 'data' => json_encode($tps), ), array( '%s', '%s', ) ); $wpdb->replace( 'wp_recruiterdata', array( 'name' => 'data', 'data' => json_encode($oDigitalRecruiter->ads), ), array( '%s', '%s', ) ); die(); } // Ajax pour enregistrer les utilisateurs a l'alerte job avec leur paramètres add_action( 'wp_ajax_registerMailJobAlert', 'registerMailJobAlert' ); add_action( 'wp_ajax_nopriv_registerMailJobAlert', 'registerMailJobAlert' ); function registerMailJobAlert(){ global $wpdb; $poles = sanitize_text_field($_POST['poles']); $metiers = sanitize_text_field($_POST['metiers']); $types = sanitize_text_field($_POST['types']); $temps = sanitize_text_field($_POST['temps']); $email = sanitize_email($_POST['email']); $token = $_POST['token']; $secret = "6LePZvAUAAAAAHW0Upj3jRH9wTzGrMO1aWpg9ICn"; if(isset($_SERVER["HTTP_X_FORWARDED_FOR"]) && $_SERVER["HTTP_X_FORWARDED_FOR"] != ""){ if (strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ',')) { $explode = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); $remoteip = trim($explode[0]); }else{ $remoteip = $_SERVER['HTTP_X_FORWARDED_FOR']; } }else{ $remoteip = $_SERVER["REMOTE_ADDR"]; } $api_url = "https://www.google.com/recaptcha/api/siteverify?secret=". $secret. "&response=" . $token. "&remoteip=" . $remoteip ; $decode = json_decode(file_get_contents($api_url), true); if ($decode['success'] == true){ $data = array( 'poles' => $poles, 'metiers' => $metiers, 'types' => $types, 'temps' => $temps ); $wpdb->delete( 'wp_jobalert', array( 'email' => $email ) ); $wpdb->replace( 'wp_jobalert', array( 'email' => $email, 'data' => json_encode($data), ), array( '%s', '%s', ) ); echo(json_encode('ok')); }else{ echo(json_encode('Une erreur est survenue. Veuillez recharger la page.')); } die(); } //Fonctions qui cherchent les annonces correspondantes et les envoient par mail (A mettre dans un cron toutes les nuits) //Attention, Il faut mettre la configuration SMTP pour l'envoi de mail / Faire un template de mail function checkMailToAlert() { global $wpdb; //Récupère les informations des personnes enregistrés pour l'alerte $alertData = $wpdb->get_results( " SELECT email, data FROM wp_jobalert ", ARRAY_A ); //Récupère les informations de digitalrecruiter (les différents poles, types, metiers, temps et la liste des annonces) $jobData = $wpdb->get_results( " SELECT name, data FROM wp_recruiterdata ", ARRAY_A ); //Créé les tableaux des infos digitalrecruiters foreach ($jobData as $dataValues) { switch ($dataValues['name']) { case 'poles': $poles = json_decode($dataValues['data']); break; case 'metiers': $metiers = json_decode($dataValues['data']); break; case 'types': $types = json_decode($dataValues['data']); break; case 'temps': $temps = json_decode($dataValues['data']); break; case 'data': $jobads = json_decode($dataValues['data']); break; } } //Pour chaque personne ayant demandés une alerte foreach ($alertData as $userData) { $userEmail = $userData['email']; $userPoleFilter = ""; $userMetierFilter = ""; $userTypeFilter = ""; $userTempsFilter = ""; $userJobAds = $jobads; //Correspondance entre ID des filtres utilisateurs avec les tableaux des infos digitalrecruiters (Récupère la valeur de recherche) $oFilters = json_decode($userData['data']); if($oFilters->poles != 'all'){ $userPoleFilter = $poles[$oFilters->poles]; } if($oFilters->metiers != 'all'){ $userMetierFilter = $metiers[$oFilters->metiers]; } if($oFilters->types != 'all'){ $userTypeFilter = $types[$oFilters->types]; } if($oFilters->temps != 'all'){ $userTempsFilter = $temps[$oFilters->temps]; } $keysToDelete = array(); //Pour chaque Annonces, on va checker chaque filtres et récupérer les ids a supprimer du tableaux foreach ($userJobAds as $key => $oJob) { $remove = false; if($userMetierFilter != "" && $oJob->service != $userMetierFilter){ $remove = true; } if($userTypeFilter != "" && $oJob->contract_type != $userTypeFilter){ $remove = true; } if($userTempsFilter != "" && $oJob->contract_work_period != $userTempsFilter){ $remove = true; } foreach ($oJob->entity->hierarchy as $hierarchy) { if($hierarchy->column_name == "Pôles"){ if($userPoleFilter != "" && $hierarchy->public_name != $userPoleFilter){ $remove = true; } } } if($remove){ array_push($keysToDelete, $key); } } //Effacement des annonces qui ne correspondent pas au filtres. foreach ($keysToDelete as $key) { unset($userJobAds[$key]); } //Envoi du mail s'il y a des annonces correspondantes if(count($userJobAds) > 0){ $body = ""; $body .= ""; $body .= ""; $body .= "

Bonjour,

"; $body .= "

Vous vous êtes inscrits pour recevoir des alertes aux annonces LDC correspondantes a votre profil.

"; $body .= "

De nouveaux résultats sont disponibles :

"; $body .= ""; $body .= "

Merci

"; $body .= ""; } var_dump($body); echo '















'; } die(); } //////////////////////////////// POC : GMAP Societe ////////////////////////////////////////////// //--- Intégration de la classe CSociete pour faciliter la manipulation des objets ? require_once( get_template_directory() . '/societe.class.php' ); // ---- CPT Societe function wp_cpt_societes() { $labels = array( 'name' => _x( 'Société', 'Post Type General Name'), 'singular_name' => _x( 'Société', 'Post Type Singular Name'), 'menu_name' => __( 'Sociétés'), 'all_items' => __( 'Tous les Sociétés'), 'view_item' => __( 'Voir les Sociétés'), 'add_new_item' => __( 'Ajouter une Société'), 'add_new' => __( 'Ajouter'), 'edit_item' => __( 'Editer la Société'), 'update_item' => __( 'Modifier la Société'), 'search_items' => __( 'Rechercher une Société'), 'not_found' => __( 'Non trouvée'), 'not_found_in_trash' => __( 'Non trouvée dans la corbeille'), ); $args = array( 'label' => __( 'Société'), 'labels' => $labels, 'supports' => array( 'title', 'editor', 'thumbnail'), 'hierarchical' => true, 'public' => true, 'has_archive' => true, 'taxonomies' => array('type'), 'rewrite' => array( 'slug' => 'type'), 'map_meta_cap' => true, 'menu_icon' => 'dashicons-admin-site-alt2' ); register_post_type( 'societe', $args ); } add_action( 'init', 'wp_cpt_societes', 0 ); // ---- Taxo : Type d'activité des societes function taxo_type_societe() { $args = array( 'label' => __( 'Type d\'Activité' ), 'hierarchical' => true, 'rewrite' => array( 'slug' => 'type-activite', 'with_front' => false ), 'show_ui' => true, 'show_in_quick_edit' => false, 'show_in_rest' => false, 'show_admin_column' => true, ); register_taxonomy( 'type-activite', 'societe', $args ); } add_action( 'init', 'taxo_type_societe'); // ---- Taxo : Filières des societes function taxo_filieres_societe() { $args = array( 'label' => __( 'Filières' ), 'hierarchical' => true, 'rewrite' => array( 'slug' => 'filieres', 'with_front' => false ), 'show_ui' => true, 'show_in_quick_edit' => false, 'show_admin_column' => true, ); register_taxonomy( 'filieres', 'societe', $args ); } add_action( 'init', 'taxo_filieres_societe'); // Fonction utilitaires pour réintégrer les sociétés en fonction d'un json et d'un dossier de logos function importSociete(){ include_once( ABSPATH . 'wp-admin/includes/image.php' ); $dir = wp_upload_dir(); $file = $dir['basedir']."/import/export_societe.json"; $data = file_get_contents($file); foreach (json_decode($data) as $oSociete) { //Insertion du post $postarr = array( 'post_title' => $oSociete->titre, 'post_status' => 'publish', 'post_type' => 'societe', ); $societeId = wp_insert_post($postarr); $term = get_term_by('name', $oSociete->filiere, 'filieres'); $termId = $term->term_id; update_field('field_5e5f6c2f2c95a', $termId, $societeId); $termType = get_term_by('slug', $oSociete->type_activite, 'type-activite'); $termTypeId = $termType->term_id; update_field('field_5e5f6c002c959', $termTypeId, $societeId); //Ajout du logo $fullpath_img = $dir['basedir']."/import/".$oSociete->logo; $full_path = $dir['path']."/". $oSociete->logo; copy($fullpath_img, $full_path); // Check the type of file. We'll use this as the 'post_mime_type'. $filetype = wp_check_filetype(basename($full_path), null); // Prepare an array of post data for the attachment. $attachment = array( 'guid' => $dir['url'] . '/' . basename($full_path), 'post_mime_type' => $filetype['type'], 'post_title' => preg_replace( '/\.[^.]+$/', '', basename($full_path) ), 'post_content' => '', 'post_status' => 'inherit' ); // Insert the attachment. $attach_id = wp_insert_attachment( $attachment, $full_path, $societeId ); $attach_data = wp_generate_attachment_metadata( $attach_id, $full_path ); wp_update_attachment_metadata( $attach_id, $attach_data ); // Saving image update_field('field_5e5f6e8adcab0', $attach_id, $societeId); //Ajout des champs de base avec ACF update_field('field_5e5f6ea3dcab1', $oSociete->adresse , $societeId); update_field('field_5e5f6eb7dcab2', $oSociete->responsable , $societeId); update_field('field_5e5f6ec6dcab3', $oSociete->departement , $societeId); update_field('field_5e5f6ed7dcab4', $oSociete->activite , $societeId); update_field('field_5e5f6ee2dcab5', $oSociete->effectif , $societeId); update_field('field_5e5f6ef7dcab6', $oSociete->contact , $societeId); update_field('field_5e5f6f09dcab7', $oSociete->url , $societeId); update_field('field_5e5f6f1bdcab8', $oSociete->infos_sup , $societeId); update_field('field_5e5f6f4fdcaba', $oSociete->responsable_pole , $societeId); update_field('field_5e5f6fb4dcabb', $oSociete->latitude , $societeId); update_field('field_5e5f6fbcdcabc', $oSociete->longitude , $societeId); } } add_theme_support( 'title-tag' ); add_filter( 'document_title_parts', function( $title ) { if ( is_search() ) $title['title'] = sprintf( esc_html__( '“%s” result213123 page', 'ldc' ), get_search_query() ); return $title; } ); add_filter('relevanssi_index_custom_fields', 'rlv_skip_custom_fields'); function rlv_skip_custom_fields($custom_fields) { $unwanted_fields = array('text_block'); $custom_fields = array_diff($custom_fields, $unwanted_fields); return $custom_fields; } add_action( 'alm_get_theme_repeater', 'alm_get_theme_repeater'); function alm_get_theme_repeater($theme_repeater){ get_template_part('partials/'.$theme_repeater); } add_filter('alm_modify_query_args', 'alm_modify_query_args_parida'); function alm_modify_query_args_parida($args) { if(isset($args["date_query"])){ if(!is_array($args["date_query"])) $args["date_query"] = array($args["date_query"]); $s = array(); foreach ($args["date_query"] as $year) $s[]['year'] = $year; $args["date_query"] = array('relation' => 'OR', $s); } return $args; } function language_selector_flags(){ $languages = icl_get_languages('skip_missing=0&orderby=code'); $lc = 1; if(!empty($languages)){ foreach($languages as $l){ if(!$l['active']) { echo ''; } else { echo ''; } echo strtoupper($l['code']); echo ''; if($lc < count($languages)) { echo ' / '; } $lc++; } } } /* class CustomWalker extends Walker_Nav_Menu { var $current_menu = null; var $break_point = null; function start_el(&$output, $item, $depth, $args) { global $wp_query; // Get the locations of nav menus $theme_locations = get_nav_menu_locations(); // Get the menu object of the current nav menu based on the returned theme location $menu_obj = get_term( $theme_locations[$args->theme_location], 'nav_menu' ); if( !isset( $this->current_menu ) ) { $this->current_menu = wp_get_nav_menu_object( $menu_obj->term_id ); } if( !isset( $this->break_point ) ) { $this->break_point = ceil( $this->current_menu->count / 2 ) + 1; } $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; $class_names = $value = ''; $classes = empty( $item->classes ) ? array() : (array) $item->classes; $classes[] = 'menu-item-' . $item->ID; $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) ); $class_names = ' class="' . esc_attr( $class_names ) . '"'; $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args ); $id = strlen( $id ) ? ' id="' . esc_attr( $id ) . '"' : ''; if( $this->break_point == $item->menu_order ) { $output .= $indent . '