get( 'Version' ); wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( 'oceanwp-style' ), $version );}add_action( 'wp_enqueue_scripts', 'oceanwp_child_enqueue_parent_style', 30 );// Changer "Read more" en françaisadd_filter('ocean_post_button_text', function() { return 'Lire la suite';});// WIDGET PAGE ACCUEIL ACCESSIBLES DANS PERSONNALISER// Désactiver l'éditeur de blocs pour les widgetsadd_filter( 'use_widgets_block_editor', '__return_false' );// Ajouter des widgets en page d'accueiladd_action('widgets_init', function () { register_sidebar(array( 'name' => 'Accueil 1 - Principal', 'id' => 'accueil-one-main', 'description' => 'Widget principal avec encadré pour la colonne 1', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); register_sidebar(array( 'name' => 'Accueil 2 - Principal', 'id' => 'accueil-two-main', 'description' => 'Widget principal avec encadré pour la colonne 2', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); register_sidebar(array( 'name' => 'Accueil 3 - Principal', 'id' => 'accueil-three-main', 'description' => 'Widget principal avec encadré pour la colonne 3', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ));});// Shortcode pour afficher email visible mais protégé des botsfunction site_email_shortcode() { $email = 'coordo-luttes-pv@protonmail.com'; $encoded_email = ''; for ($i = 0; $i < strlen($email); $i++) { $encoded_email .= '&#' . ord($email[$i]) . ';'; } $display_email = esc_html($email); return '' . $display_email . '';}add_shortcode('email_site', 'site_email_shortcode');/** * Initialize tarteaucitron */function tarteaucitron_init() { ?> 'Index', 'colonnes' => '2' ), $atts); $colonnes = intval($atts['colonnes']); $col_class = 'index-colonnes-' . $colonnes; $clean_content = trim( shortcode_unautop( $content ) ); $items = do_shortcode( $clean_content ); $nb_elements = preg_match_all('/\[lien\s/', $content); $nb_lignes = ceil($nb_elements / $colonnes); $output = '
'; $output .= '

' . esc_html($atts['titre']) . '

'; $output .= ''; $output .= '
'; return $output;}add_shortcode('index', 'creer_index_generique');function creer_lien_index($atts) { $atts = shortcode_atts(array( 'ancre' => '', 'texte' => '' ), $atts); $ancre = esc_attr($atts['ancre']); $texte = esc_html($atts['texte']); return '
  • ' . $texte . '
  • ';}add_shortcode('lien', 'creer_lien_index');/** * CSS inline injecté après OceanWP pour garantir la priorité * Centralise tout le CSS qui doit écraser les styles du thème parent */function custom_inline_css() { $css = ' /* Footer widgets */ #footer-widgets { background-color: #222; padding: 0; margin: 0; } #footer-widgets .container { display: flex; align-items: center; justify-content: center; } #footer-widgets .footer-box { display: flex; flex-direction: column; justify-content: center; } #footer-widgets .widget_text { text-align: center; } #footer-widgets .footer-box .widget_media_image { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; } /* Widgets accueil : passage en 1 colonne sur mobile et tablette */ @media (max-width: 768px) { #home-widgets.oceanwp-row .home-box.span_1_of_3 { width: 100%; float: none; margin-right: 0; } } /* Index / sommaire */ .index-generique { background-color: #f5f5f5; padding: 20px; margin: 20px 0; border-radius: 10px; } .index-generique h2 { text-align: center; color: #2c5530; margin: 0 0 20px 0; } .index-liste { list-style: none !important; margin: 0 !important; padding: 0 !important; padding-left: 0 !important; margin-left: 0 !important; } .index-liste p { margin: 0; padding: 0; } .index-liste br { display: none; } .index-colonnes-1 > li { margin: 0 !important; padding: 0 !important; line-height: 1.5; list-style: none !important; text-indent: 0 !important; } .index-colonnes-1 > li a { display: inline-block; vertical-align: top; text-decoration: none; color: inherit; margin: 0; padding: 0; } .index-colonnes-2 { display: grid; grid-template-columns: 1fr 1fr; grid-auto-flow: column; column-gap: 30px; row-gap: 10px; } .index-colonnes-2 > li { margin: 0 !important; padding: 0 !important; line-height: 1.5; list-style: none; } .index-colonnes-2 > li a { display: block; text-decoration: none; color: inherit; } .index-colonnes-2 > li, .index-colonnes-1 > li { vertical-align: top; } '; wp_add_inline_style('oceanwp-style', $css);}add_action('wp_enqueue_scripts', 'custom_inline_css', 30);// Désactiver les pages auteuradd_action('template_redirect', 'disable_author_pages');function disable_author_pages() { if (is_author()) { global $wp_query; $wp_query->set_404(); status_header(404); nocache_headers(); }}/** * ============================================================ * FORMULAIRE DE NOTIFICATION - traitement sécurisé via admin-ajax * ============================================================ * Remplace l'ancien notify.php (à supprimer du serveur). * Le widget ne contient plus que du HTML/JS, tout le PHP est ici. */// 1. Fournit le nonce et l'URL ajax au JavaScript du widgetadd_action('wp_enqueue_scripts', 'cnprv_notify_localize_data');function cnprv_notify_localize_data() { wp_register_script('cnprv-notify-inline', false, [], null, true); wp_enqueue_script('cnprv-notify-inline'); wp_localize_script('cnprv-notify-inline', 'notifyFormData', [ 'ajaxUrl' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('notify_form_nonce'), ]);}// 2. Traitement de la soumission (visiteurs connectés ou non)add_action('wp_ajax_cnprv_notify_subscribe', 'cnprv_notify_handle_subscribe');add_action('wp_ajax_nopriv_cnprv_notify_subscribe', 'cnprv_notify_handle_subscribe');function cnprv_notify_handle_subscribe() { // Vérification du nonce (empêche les POST directs sans passer par le site) if (empty($_POST['form_token']) || !wp_verify_nonce($_POST['form_token'], 'notify_form_nonce')) { wp_send_json(['success' => true]); // échec silencieux pour ne pas aider les bots } // Honeypot if (!empty($_POST['website']) || !empty($_POST['phone'])) { wp_send_json(['success' => true]); } // Time-trap : au moins 3 secondes entre le chargement de la page et l'envoi $form_ts = isset($_POST['form_ts']) ? (int) $_POST['form_ts'] : 0; $elapsed = time() - $form_ts; if ($form_ts === 0 || $elapsed < 3 || $elapsed > 3600) { wp_send_json(['success' => true]); } // Rate limiting par IP (transient WordPress) $ip = sanitize_text_field($_SERVER['REMOTE_ADDR'] ?? 'unknown'); $rateKey = 'cnprv_notify_rl_' . md5($ip); if (get_transient($rateKey)) { wp_send_json(['success' => true]); } set_transient($rateKey, 1, 60); // 1 soumission max par minute et par IP // Validation email $email = isset($_POST['email']) ? sanitize_email(wp_unslash($_POST['email'])) : ''; if (!is_email($email)) { wp_send_json(['success' => false]); } // Validation nom : longueur, pas d'URL ni de HTML $nom = isset($_POST['nom']) ? sanitize_text_field(wp_unslash($_POST['nom'])) : ''; $nom = trim($nom); if ($nom === '' || mb_strlen($nom) > 100) { wp_send_json(['success' => false]); } if (preg_match('/https?:\/\/|www\.|<[a-z]+.*>/i', $nom)) { wp_send_json(['success' => true]); // signe de spam -> échec silencieux } // Envoi de l'email interne uniquement (pas d'email automatique à l'adresse // fournie par le visiteur : c'était le vecteur d'abus identifié précédemment) $sujet = "Nouvelle demande d'ajout aux diffusions d'actualités"; $message = "Nouvelle demande d'une personne souhaitant recevoir les actualités de la CNPRV :\n\n"; $message .= "Email : " . $email . "\n"; $message .= "Nom : " . $nom . "\n"; $message .= "IP : " . $ip . "\n"; $message .= "Date : " . date_i18n('d/m/Y H:i') . "\n"; $headers = ['Reply-To: coordo-luttes-pv@protonmail.com']; $sent = wp_mail('coordo-luttes-pv@protonmail.com', $sujet, $message, $headers); wp_send_json(['success' => (bool) $sent]);} https://coordo-nationale-photorevoltee.org/post-sitemap.xml 2026-09-22T21:15:56+00:00 https://coordo-nationale-photorevoltee.org/page-sitemap.xml 2026-09-13T18:09:50+00:00 https://coordo-nationale-photorevoltee.org/category-sitemap.xml 2026-09-22T21:15:56+00:00 https://coordo-nationale-photorevoltee.org/author-sitemap.xml 2025-10-06T08:59:28+00:00