' . $attr['name'] . '';}add_shortcode('thau_document', 'thau_agglo_document');/** * Shortcode Lien interne */function thau_agglo_link($attr){ return '' . $attr['name'] . ' ';}add_shortcode('thau_link', 'thau_agglo_link');/** * Shortcode Lien interne par post id */function thau_agglo_link_by_id($attr){ return '' . $attr['name'] . ' ';}add_shortcode('thau_link_by_id', 'thau_agglo_link_by_id');/** * Excerpt custom functions */function thau_agglo_excerpt_length($length){ return 50;}add_filter('excerpt_length', 'thau_agglo_excerpt_length', 999);function thau_agglo_excerpt_more($more){ return ' (...)';}add_filter('excerpt_more', 'thau_agglo_excerpt_more');/** * Mise en forme de l'affichage des domments PDF liés à un article * @param string nom du document | NULL */function thau_agglo_list_pdf(){ global $post; global $wpdb; $docs = get_post_meta($post->ID, 'wpcf-document-pdf', false); if (!empty($docs)) { echo ''; }}function thau_agglo_get_media_info($media){ global $wpdb; $meta_data = $wpdb->get_results('SELECT * FROM wp_posts WHERE guid ="' . $media . '"', OBJECT); return $meta_data[0];}/** * Mise en forme de l'affichage des images supplémentaires liées à un article * @param string nom du document | NULL */function thau_agglo_list_illustration($illustrations, $post_id){ global $wpdb; if (!empty($illustrations)) { foreach ($illustrations as $illustration) { echo '
'; $meta_data = $wpdb->get_results('SELECT * FROM wp_posts WHERE guid ="' . $illustration . '"', OBJECT); $legend = $wpdb->get_results('SELECT meta_value FROM wp_postmeta WHERE meta_key = "_wp_attachment_image_alt" AND post_id ="' . $post_id . '"', OBJECT); $illustration_title = $meta_data[0]->post_title; echo ' ' . $legend[0] . ''; if ($meta_data[0]->post_excerpt != '') echo ' ' . $meta_data[0]->post_excerpt . ''; echo '
'; } }}/** * Fonction de conversion première page PDF en image * @param string $image_url chemin vers le fichier PDF * @return string chemin vers l'image */function thau_agglo_pdf2img($image_url = NULL){ $jpg = str_replace('.pdf', '.jpg', $image_url); if (!is_null($image_url) && !sys_file_exists($jpg)) { $uri_absolute = '/home/agglopolebassead/websites/agglopole.fr/public_html/wp-content/'; $pdf_uri = str_replace('https://www.agglopole.fr/', '/home/agglopolebassead/websites/agglopole.fr/public_html/', $image_url); $pdf_name = basename($image_url); $img_file = str_replace('pdf', 'jpg', $pdf_uri); if (!sys_file_exists($img_file)) { $im = new Imagick($pdf_uri); $im->setIteratorIndex(0); $im->setCompression(Imagick::COMPRESSION_JPEG); $im->setCompressionQuality(90); $im->writeImage($img_file); } return str_replace('/home/agglopolebassead/websites/agglopole.fr/public_html/', 'https://www.agglopole.fr/', $img_file); } //return $image_url; return str_replace('.pdf', '.jpg', $image_url); // Correction SM 4/6/2015}/** * Fonction de conversion première page PDF en image * @param string $image_url chemin vers le fichier PDF * @return string chemin vers l'image */function thau_agglo_img_grayscale($image_url = NULL){ if (!is_null($image_url) && !sys_file_exists($image_url)) { $image_uri = str_replace('https://www.agglopole.fr/', '/home/agglopolebassead/websites/agglopole.fr/public_html/', $image_url); $image_name = basename($image_url); $image_new = str_replace($image_name, 'gs-' . $image_name, $image_uri); $img = imagecreatefromjpeg($image_uri); if ($img && imagefilter($img, IMG_FILTER_COLORIZE, 80, 80, 80) && imagefilter($img, IMG_FILTER_CONTRAST, 20) && imagefilter($img, IMG_FILTER_BRIGHTNESS, 40)) { imagejpeg($img, $image_new); imagedestroy($img); return str_replace('/home/agglopolebassead/websites/agglopole.fr/public_html/', 'https://www.agglopole.fr/', $image_new); } } return $image_url;}/** * Fonction de récupération de logotype en fonction d'un nom de commune * @param string $city nom de la commune * @return components markup html pour l'image */function thau_agglo_get_logo_city($city_name){ global $wpdb; $city = $wpdb->get_row('SELECT P.post_name, M.meta_value FROM wp_postmeta M LEFT JOIN wp_posts P ON P.ID = M.post_id WHERE P.post_type LIKE ("commune") AND P.post_status LIKE ("publish") AND P.post_title LIKE("' . $city_name . '") AND M.meta_key LIKE("wpcf-logotype") LIMIT 1', OBJECT); $markup = 'Logotype - ' . $city_name . ''; return $markup;}/** * Fonction de récupération d'une fiche contact * si le second paramètre n'est pas renseigné : aucune encapsulation. Utilisation dans la colonne info sppl. des pages * si le second paramètre est égal à "row" : le contact est présenté avec la description à droite * si le second paramètre est égal à "columns" : le contact est affiché de façon simple, sans description avec une largeur de 1/3 * @param string $name slug du contact * @param string or null template à utiliser pour la présentation * @return components markup html du contact */function thau_agglo_contact($name, $template = null){ global $wpdb; $contact = $wpdb->get_results('SELECT P.ID, M.meta_value,M.meta_key FROM wp_postmeta M LEFT JOIN wp_posts P ON P.ID = M.post_id WHERE P.post_type LIKE ("contacts") AND P.post_status LIKE ("publish") AND P.post_name LIKE("' . $name . '")', OBJECT); $markup = ''; $markup .= ''; $contact_post = get_post($contact[0]->ID); if (!is_null($template) && $template == 'row') { $markup_embeded .= '
'; $markup_embeded .= '
' . $markup . '
'; $markup_embeded .= '
' . $contact_post->post_content . '
'; $markup_embeded .= '
'; wp_reset_postdata(); return $markup_embeded; } elseif (!is_null($template) && $template == 'column') { $markup_embeded .= '
' . $markup . '
'; wp_reset_postdata(); return $markup_embeded; } return $markup;}/** * Fonction de test d'existence de fichier * @param string chemin absolu ver le fichier * @return boolean */function sys_file_exists($f = NULL){ $h = array(); $ret = FALSE; if (!is_null($f)): if (preg_match('/^http|https|ftp/', $f)) : $h = @get_headers($f); if (array_key_exists(0, $h)) : $ret = (bool) preg_match('/200|301/', $h[0]); endif; else : $ret = ( file_exists($f) && is_readable($f) ); endif; endif; return ( ( $ret === TRUE ) ? TRUE : FALSE );}/** * Fonction de génération du big menu * @return component markup du menu */function thau_agglo_primary_menu_pages(){ global $wpdb; $top_menu_pages = $wpdb->get_results('SELECT ID, post_name, post_title, post_parent, menu_order FROM wp_posts WHERE post_type LIKE ("page") AND post_status LIKE ("publish") AND post_parent=0 AND menu_order!=999 ORDER BY post_parent, menu_order', OBJECT); $markup = ''; foreach ($top_menu_pages as $parent) : $markup .= '
  • '; $markup .= ' ' . $parent->post_title . ''; $markup .= ' '; $markup .= '
  • '; $markup .= '
  • '; $markup .= ' ' . $parent->post_title . ''; $markup .= '
    '; $markup .= '
    '; $markup .= '
    '; foreach ($child_menu_pages as $child) : $content_post = get_post($child->ID); $content = $content_post->post_content; /* * Modification : Amlan * Ref : MTA-MenuTarget * Date : 10/03/16 * Raison : Permettre le choix du target du menu */ $surcharge_postlink = ''; $surcharge_postlink_target = ''; $surcharge_postlink = get_post_meta($child->ID, "wpcf-menu_surcharge", true); if ($surcharge_postlink != '') { $surcharge_postlink_target = get_post_meta($child->ID, "wpcf-menu_surcharge_tgt", true); $post_link = '' . $child->post_title . ''; } else { $post_link = '' . $child->post_title . ''; $post_link = $child->post_title; } /* * Modification : Amlan * Ref : MTA-BGmenus * Date : 26/10/15 * Raison : Permettre le choix de la couleur de fond de puis le BO */ $surcharge_background = ''; $surcharge_couleur = get_post_meta($child->ID, "wpcf-surcharge-couleur-de-fond", true); if ($surcharge_couleur != '') { $surcharge_background = 'style="background-color:' . $surcharge_couleur . '!important"'; } /* * MTA-BGmenus * Nature : Remplacement de ligne * Backup : $markup .= '
    ' . $post_link . '
    '; */ $markup .= '
    ' . $post_link . '
    '; $child_submenu_pages = $wpdb->get_results('SELECT ID, post_name, post_title, post_parent, menu_order FROM wp_posts WHERE post_type LIKE ("page") AND post_status LIKE ("publish") AND post_parent = ' . $child->ID . ' ORDER BY menu_order', OBJECT); if (count($child_submenu_pages) > 0) : $markup .= '
      '; foreach ($child_submenu_pages as $child_sub) : /* * Modification : Amlan * Ref : MTA-MenuTarget * Date : 10/03/16 * Raison : Permettre le choix du target du menu */ $surcharge_child_postlink = ''; $surcharge_child_postlink_target = ''; $surcharge_child_postlink = get_post_meta($child_sub->ID, "wpcf-menu_surcharge", true); $hide_page_in_menu = get_post_meta($child_sub->ID, 'wpcf-hide_page_in_menu', true); if ('1' === $hide_page_in_menu) { continue; } if ($surcharge_child_postlink != '') { $surcharge_child_postlink_target = get_post_meta($child_sub->ID, "wpcf-menu_surcharge_tgt", true); $markup .= ' '; } else { $markup .= ' '; } endforeach; $markup .= '
    '; endif; $cpt--; $loop_cpt++; if ($loop_cpt == $items) { $loop_cpt = 0; /* if ($cpt % $items == 0) { */ $markup .= '
    '; } //$markup .= ( $cpt % $items == 0 ) ? '
    ' : ''; endforeach; $markup .= '
    '; $markup .= '
    '; $markup .= '
    '; $markup .= '
  • '; endforeach; return $markup;}/** * Fonction de génération du menu de navigation * @return component markup du menu */function thau_agglo_navigation_menu(){ global $wpdb; $top_menu_pages = $wpdb->get_results('SELECT ID, post_name, post_title, post_parent, menu_order FROM wp_posts WHERE post_type LIKE ("page") AND post_status LIKE ("publish") AND post_parent=0 AND menu_order!=999 ORDER BY post_parent, menu_order', OBJECT); $markup = ''; return $markup;}/** * Fonction de nettoyage des anciennes URLs pour mise en production sur nouveau domaine * décommenté la ligne de header.php * Utiliser : do_shortcode('[thau_prod last="site" new="www" ]'); * @param string terme à remplacer * @param string terme de remplacement */function thau_agglo_production($last, $new){ global $wpdb; $sql = "SELECT * FROM wp_posts WHERE guid LIKE ('%http://$last.thau-agglo.fr%')"; $posts = $wpdb->get_results($sql, OBJECT); $rewrite = []; $rewrite['success'] = 0; $rewrite['error'] = 0; foreach ($posts as $key => $post) { $post->guid = str_replace("http://" . $last . ".thau-agglo.fr", "http://" . $new . ".thau-agglo.fr", $post->guid); $result = $wpdb->update('wp_posts', ['guid' => $post->guid], ['ID' => $post->ID]); if ($result) { $rewrite['success']++; } else { $rewrite['error']++; $rewrite['post' . $key] = $post->guid; } } echo '
    ';    print_r($rewrite);    echo '
    '; die('

    Report

    ');}/** * Shortcode Production * @see thau_agglo_production($arg,$arg) */function thau_agglo_prod($attr){ return thau_agglo_production($attr['last'], $attr['new']);}add_shortcode('thau_prod', 'thau_agglo_prod');/** * Fonction permettant de retourner l'ensemble des images du slider + titres */function thau_agglo_get_header_slides(){ global $wpdb; $args = array( 'post_type' => 'slider-image', 'orderby' => 'menu_order', 'post_status' => 'publish', 'posts_per_page' => 30, 'order' => 'ASC' ); $my_query = new WP_Query($args); $toReturn = array(); while ($my_query->have_posts()) { $my_query->the_post(); $meta_data = get_post_meta(get_the_ID(), 'wpcf-header-slider-image', OBJECT); $toReturn[] = array('title' => get_the_title(), 'image' => $meta_data); } return $toReturn;}remove_action('wp_head', 'print_emoji_detection_script', 7);remove_action('wp_print_styles', 'print_emoji_styles');//Register hook to load scriptsadd_action('wp_enqueue_scripts', 'search_engine_load_scripts');//Load scripts (and/or styles)function search_engine_load_scripts(){ if (is_page()) { //Check if we are viewing a page global $wp_query; //Check which template is assigned to current page we are looking at $template_name = get_post_meta($wp_query->post->ID, '_wp_page_template', true); if ($template_name == 'page-search-engine.php') { //wp_enqueue_script('datatables', "//cdn.datatables.net/1.10.16/js/jquery.dataTables.js"); wp_register_style('datatables-css', "https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css"); wp_enqueue_script('datatables', "https://cdn.datatables.net/v/dt/jqc-1.12.3/dt-1.10.16/r-2.2.1/datatables.min.js"); // wp_register_style('datatables-css', "https://cdn.datatables.net/v/dt/jqc-1.12.3/dt-1.10.16/r-2.2.1/datatables.min.css"); wp_enqueue_style('datatables-css'); wp_enqueue_script('search-moment', "https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.4/moment.min.js"); wp_enqueue_script('datetime', "https://cdn.datatables.net/plug-ins/1.10.16/sorting/datetime-moment.js"); // wp_enqueue_script('search-engine', "//www.amlan.fr/testagglopole/search_engine.min.js"); wp_enqueue_script('search-engine', "https://js.elit-sa.com/agglopole_1408/search_engine.min.js"); //wp_enqueue_script('search-engine', get_template_directory_uri() . '/js/search_engine.min.js'); } }}$youtube_channel = 'https://www.youtube.com/channel/UC346duLfI7cy7VYuCbxc-iw';add_filter('tiny_mce_before_init', 'fb_change_mce_options');function fb_change_mce_options($tags){ // Comma separated string od extendes tags // Command separated string of extended elements $ext = 'iframe[align|longdesc|name|width|height|frameborder|scrolling|marginheight|marginwidth|src|id|class|title|style|allow|allowfullscreen]'; if (isset($tags['extended_valid_elements'])) $tags['extended_valid_elements'] .= ',' . $ext; else $tags['extended_valid_elements'] = $ext; return $tags;}add_action('wp_head', 'archipel_css');function archipel_css(){ global $post; if (!isset($post) || !is_object($post)) { return; } if ($post->ID != 16752) { return; } ?> rest_authorization_required_code() ] ); } return $access;});add_action('admin_footer', function(){ ?> '', 'width' => '100%', 'height' => '500px', 'frameborder' => '0', 'allowfullscreen' => 'allowfullscreen', ], $atts ); if ( empty( $atts['src'] ) ) { return ''; } return sprintf( '', esc_attr( $atts['width'] ), esc_attr( $atts['height'] ), esc_attr( $atts['frameborder'] ), esc_url( $atts['src'] ), esc_attr( $atts['allowfullscreen'] ) );} ); Sète agglopôle méditerranée » Communauté d'agglomération du bassin de Thau