maj general/ACF
This commit is contained in:
parent
e734ca68fc
commit
a7c84fe336
@ -2,7 +2,7 @@ import React, { useState, useEffect } from "react";
|
||||
import Hero from "../Hero";
|
||||
import SEO from "../SEO";
|
||||
import api from "../../api";
|
||||
import ModernSpinner from "../ModernSpinner";
|
||||
import ModernSpinner from "../SpinnerModerne";
|
||||
import Expertises from "../Expertises";
|
||||
import {
|
||||
Box,
|
||||
|
||||
103
server/wp-config.php
Normal file
103
server/wp-config.php
Normal file
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/**
|
||||
* The base configuration for WordPress
|
||||
*
|
||||
* The wp-config.php creation script uses this file during the installation.
|
||||
* You don't have to use the website, you can copy this file to "wp-config.php"
|
||||
* and fill in the values.
|
||||
*
|
||||
* This file contains the following configurations:
|
||||
*
|
||||
* * Database settings
|
||||
* * Secret keys
|
||||
* * Database table prefix
|
||||
* * ABSPATH
|
||||
*
|
||||
* @link https://developer.wordpress.org/advanced-administration/wordpress/wp-config/
|
||||
*
|
||||
* @package WordPress
|
||||
*/
|
||||
|
||||
// ** Database settings - You can get this info from your web host ** //
|
||||
define( 'FS_METHOD', 'direct' );
|
||||
/** The name of the database for WordPress */
|
||||
define( 'DB_NAME', 'vese7572_api-octopus-serveur' );
|
||||
|
||||
/** Database username */
|
||||
define( 'DB_USER', 'vese7572_api-octopus-serveur' );
|
||||
|
||||
/** Database password */
|
||||
define( 'DB_PASSWORD', 'I5HZzt}fQQit' );
|
||||
|
||||
/** Database hostname */
|
||||
define( 'DB_HOST', 'localhost' );
|
||||
|
||||
/** Database charset to use in creating database tables. */
|
||||
define( 'DB_CHARSET', 'utf8mb4' );
|
||||
|
||||
/** The database collate type. Don't change this if in doubt. */
|
||||
define( 'DB_COLLATE', '' );
|
||||
|
||||
/**#@+
|
||||
* Authentication unique keys and salts.
|
||||
*
|
||||
* Change these to different unique phrases! You can generate these using
|
||||
* the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}.
|
||||
*
|
||||
* You can change these at any point in time to invalidate all existing cookies.
|
||||
* This will force all users to have to log in again.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*/
|
||||
define( 'AUTH_KEY', '(P31hms,z~_HjW;`kPeb C)L8PRmEfg r=O}0q,_f&]t>:x0TCB(R9.4MVmg$pPT' );
|
||||
define( 'SECURE_AUTH_KEY', 'g[7wJf03>Gc{nN!3*=MEL+{ ,)#01e^H]]H2`kQ-uFY*;ic!tFnfEf{aa{$9]sor' );
|
||||
define( 'LOGGED_IN_KEY', '2TyP;/Gj,$$/Ra)U(/*_7ywF!Ow4 ^~g ,b%gu-c_3PD[`G+U92m?YW2{&g3?xNy' );
|
||||
define( 'NONCE_KEY', 'fU*W91F?9s4ou,Xfq)!PPSP0};4Ls?ht9rbW-S:+pc@6fb}-yGU~D^f8Iwj5`M$k' );
|
||||
define( 'AUTH_SALT', 'lny^;$KU&|V3YB^L@K)WFk{<rsE?)~>/&yVfjz,R9LozDGrB?~_jI}>s!I89n}9>' );
|
||||
define( 'SECURE_AUTH_SALT', '8mSK N+5VQ%DS| /@Sh[w}FFioXAe|Vt Q:|O5?P#,V3i@p!`b]D=D!MWu-QKiI4' );
|
||||
define( 'LOGGED_IN_SALT', '?m-qZC0Ked Y]jK^*9U_2#u)|EXgo6cE](`LrM;]EfGP.#Sc!qCjl=rA)bT0twZa' );
|
||||
define( 'NONCE_SALT', '/~PuQ}s}gZd:D[Z.Z|9{^Dy(:[r:1Q4xramAUon%eLY9t^P>f4B#$?[c2,{)%yp8' );
|
||||
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* WordPress database table prefix.
|
||||
*
|
||||
* You can have multiple installations in one database if you give each
|
||||
* a unique prefix. Only numbers, letters, and underscores please!
|
||||
*
|
||||
* At the installation time, database tables are created with the specified prefix.
|
||||
* Changing this value after WordPress is installed will make your site think
|
||||
* it has not been installed.
|
||||
*
|
||||
* @link https://developer.wordpress.org/advanced-administration/wordpress/wp-config/#table-prefix
|
||||
*/
|
||||
$table_prefix = 'oce_';
|
||||
|
||||
/**
|
||||
* For developers: WordPress debugging mode.
|
||||
*
|
||||
* Change this to true to enable the display of notices during development.
|
||||
* It is strongly recommended that plugin and theme developers use WP_DEBUG
|
||||
* in their development environments.
|
||||
*
|
||||
* For information on other constants that can be used for debugging,
|
||||
* visit the documentation.
|
||||
*
|
||||
* @link https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/
|
||||
*/
|
||||
define( 'WP_DEBUG', false );
|
||||
|
||||
/* Add any custom values between this line and the "stop editing" line. */
|
||||
|
||||
|
||||
|
||||
/* That's all, stop editing! Happy publishing. */
|
||||
|
||||
/** Absolute path to the WordPress directory. */
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
define( 'ABSPATH', __DIR__ . '/' );
|
||||
}
|
||||
|
||||
/** Sets up WordPress vars and included files. */
|
||||
require_once ABSPATH . 'wp-settings.php';
|
||||
177
server/wp-content/themes/hello-elementor-child/functions.php
Normal file
177
server/wp-content/themes/hello-elementor-child/functions.php
Normal file
@ -0,0 +1,177 @@
|
||||
<?php
|
||||
|
||||
// Exit if accessed directly
|
||||
if (!defined('ABSPATH')) exit;
|
||||
|
||||
// Charger les styles du parent et de l'enfant
|
||||
if (!function_exists('child_theme_styles')) {
|
||||
function child_theme_styles() {
|
||||
// Style du parent
|
||||
wp_enqueue_style('parent-style', get_template_directory_uri() . '/style.css');
|
||||
// Style de l'enfant
|
||||
wp_enqueue_style('child-style', get_stylesheet_directory_uri() . '/style.css', ['parent-style']);
|
||||
}
|
||||
}
|
||||
add_action('wp_enqueue_scripts', 'child_theme_styles');
|
||||
|
||||
// Ajouter les champs ACF à l'API REST pour les pages
|
||||
add_action('rest_api_init', function () {
|
||||
register_rest_field(
|
||||
'page',
|
||||
'acf',
|
||||
[
|
||||
'get_callback' => function ($object) {
|
||||
return get_fields($object['id']);
|
||||
},
|
||||
'schema' => null,
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
// API RANK SEO
|
||||
add_filter('rest_prepare_page', function ($response, $post) {
|
||||
$seo_data = [
|
||||
'rank_math_title' => get_post_meta($post->ID, 'rank_math_title', true),
|
||||
'rank_math_description' => get_post_meta($post->ID, 'rank_math_description', true),
|
||||
];
|
||||
|
||||
$response->data = array_merge($response->data, $seo_data);
|
||||
|
||||
return $response;
|
||||
}, 10, 2);
|
||||
|
||||
add_action('rest_api_init', function () {
|
||||
register_rest_route('custom/v1', '/contact', array(
|
||||
'methods' => 'POST',
|
||||
'callback' => 'handle_contact_form',
|
||||
'permission_callback' => '__return_true', // Permet l'accès public
|
||||
));
|
||||
});
|
||||
|
||||
// Formulaire
|
||||
function register_contact_endpoint() {
|
||||
register_rest_route('custom/v1', '/contact', [
|
||||
'methods' => 'POST',
|
||||
'callback' => 'handle_contact_form',
|
||||
'permission_callback' => '__return_true',
|
||||
]);
|
||||
}
|
||||
add_action('rest_api_init', 'register_contact_endpoint');
|
||||
|
||||
function handle_contact_form($request) {
|
||||
$params = $request->get_json_params();
|
||||
|
||||
$name = sanitize_text_field($params['name'] ?? '');
|
||||
$email = sanitize_email($params['email'] ?? '');
|
||||
$subject = sanitize_text_field($params['subject'] ?? '');
|
||||
$message = sanitize_textarea_field($params['message'] ?? '');
|
||||
|
||||
if (empty($name) || empty($email) || empty($subject) || empty($message)) {
|
||||
return new WP_Error(
|
||||
'incomplete_fields',
|
||||
'Tous les champs doivent être remplis.',
|
||||
['status' => 400]
|
||||
);
|
||||
}
|
||||
|
||||
// Logique pour envoyer l'e-mail ou enregistrer les données
|
||||
$to = get_option('admin_email'); // Adresse e-mail de l'administrateur WordPress
|
||||
$headers = ['Content-Type: text/html; charset=UTF-8', 'From: ' . $name . ' <' . $email . '>'];
|
||||
|
||||
$mail_sent = wp_mail($to, $subject, nl2br($message), $headers);
|
||||
|
||||
if (!$mail_sent) {
|
||||
return new WP_Error('email_not_sent', 'Le message n’a pas pu être envoyé.', ['status' => 500]);
|
||||
}
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'message' => 'Message envoyé avec succès.',
|
||||
];
|
||||
}
|
||||
|
||||
// Gestion des menus ACF
|
||||
function register_multiple_acf_dashboard_menus() {
|
||||
// Menu principal
|
||||
add_menu_page(
|
||||
'Gestion des Champs ACF', // Titre de la page principale
|
||||
'ACF Manager', // Texte du menu
|
||||
'manage_options', // Capacité requise
|
||||
'acf-manager', // Slug du menu principal
|
||||
'acf_manager_main_page', // Fonction de rappel pour la page principale
|
||||
'dashicons-admin-generic', // Icône du menu
|
||||
2 // Position dans le menu
|
||||
);
|
||||
|
||||
// Sous-menu pour le Groupe 1
|
||||
add_submenu_page(
|
||||
'acf-manager', // Slug du menu parent
|
||||
'Groupe 1 ACF', // Titre de la page
|
||||
'Page d\'accueil', // Texte du sous-menu
|
||||
'manage_options', // Capacité requise
|
||||
'acf-manager-group-1', // Slug du sous-menu
|
||||
'acf_manager_group_1' // Fonction de rappel pour afficher le contenu
|
||||
);
|
||||
|
||||
// Sous-menu pour le Groupe 2
|
||||
add_submenu_page(
|
||||
'acf-manager',
|
||||
'Groupe 2 ACF',
|
||||
'section expertise',
|
||||
'manage_options',
|
||||
'acf-manager-group-2',
|
||||
'acf_manager_group_2'
|
||||
);
|
||||
}
|
||||
add_action('admin_menu', 'register_multiple_acf_dashboard_menus');
|
||||
|
||||
// Page principale (facultatif)
|
||||
function acf_manager_main_page() {
|
||||
echo '<div class="wrap"><h1>Bienvenue dans le Gestionnaire ACF</h1><p>Choisissez un groupe dans le menu pour gérer ses champs.</p></div>';
|
||||
}
|
||||
|
||||
// Groupe 1 - Champs ACF
|
||||
function acf_manager_group_1() {
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h1>Groupe 1 - Champs ACF</h1>
|
||||
<?php
|
||||
if (function_exists('acf_form')) {
|
||||
acf_form_head();
|
||||
acf_form(array(
|
||||
'post_id' => '13', // Remplacez par un ID de page si nécessaire
|
||||
'field_groups' => array('group_6774f26930ebd'),
|
||||
'form' => true,
|
||||
'return' => add_query_arg('updated', 'true', wp_get_referer()),
|
||||
'submit_value' => __('Enregistrer les modifications', 'acf'),
|
||||
));
|
||||
} else {
|
||||
echo '<p>Le plugin ACF n\'est pas activé ou disponible.</p>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
// Groupe 2 - Champs ACF
|
||||
function acf_manager_group_2() {
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h1>Groupe 2 - Champs ACF</h1>
|
||||
<?php
|
||||
if (function_exists('acf_form')) {
|
||||
acf_form_head();
|
||||
acf_form(array(
|
||||
'post_id' => '13', // Remplacez par un ID de page si nécessaire
|
||||
'field_groups' => array('group_6779c41fcdc6d'),
|
||||
'form' => true,
|
||||
'return' => add_query_arg('updated', 'true', wp_get_referer()),
|
||||
'submit_value' => __('Enregistrer les modifications', 'acf'),
|
||||
));
|
||||
} else {
|
||||
echo '<p>Le plugin ACF n\'est pas activé ou disponible.</p>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
@ -263,78 +263,3 @@ if ( ! function_exists( 'hello_elementor_body_open' ) ) {
|
||||
}
|
||||
}
|
||||
|
||||
// Ajouter les champs ACF à l'API REST pour les pages
|
||||
add_action('rest_api_init', function () {
|
||||
register_rest_field(
|
||||
'page',
|
||||
'acf',
|
||||
[
|
||||
'get_callback' => function ($object) {
|
||||
return get_fields($object['id']);
|
||||
},
|
||||
'schema' => null,
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
// API RANK SEO
|
||||
add_filter('rest_prepare_page', function ($response, $post) {
|
||||
$seo_data = [
|
||||
'rank_math_title' => get_post_meta($post->ID, 'rank_math_title', true),
|
||||
'rank_math_description' => get_post_meta($post->ID, 'rank_math_description', true),
|
||||
];
|
||||
|
||||
$response->data = array_merge($response->data, $seo_data);
|
||||
|
||||
return $response;
|
||||
}, 10, 2);
|
||||
|
||||
add_action('rest_api_init', function () {
|
||||
register_rest_route('custom/v1', '/contact', array(
|
||||
'methods' => 'POST',
|
||||
'callback' => 'handle_contact_form',
|
||||
'permission_callback' => '__return_true', // Permet l'accès public
|
||||
));
|
||||
});
|
||||
|
||||
// Formulaire
|
||||
function register_contact_endpoint() {
|
||||
register_rest_route('custom/v1', '/contact', [
|
||||
'methods' => 'POST',
|
||||
'callback' => 'handle_contact_form',
|
||||
'permission_callback' => '__return_true',
|
||||
]);
|
||||
}
|
||||
add_action('rest_api_init', 'register_contact_endpoint');
|
||||
|
||||
function handle_contact_form($request) {
|
||||
$params = $request->get_json_params();
|
||||
|
||||
$name = sanitize_text_field($params['name'] ?? '');
|
||||
$email = sanitize_email($params['email'] ?? '');
|
||||
$subject = sanitize_text_field($params['subject'] ?? '');
|
||||
$message = sanitize_textarea_field($params['message'] ?? '');
|
||||
|
||||
if (empty($name) || empty($email) || empty($subject) || empty($message)) {
|
||||
return new WP_Error(
|
||||
'incomplete_fields',
|
||||
'Tous les champs doivent être remplis.',
|
||||
['status' => 400]
|
||||
);
|
||||
}
|
||||
|
||||
// Logique pour envoyer l'e-mail ou enregistrer les données
|
||||
$to = get_option('admin_email'); // Adresse e-mail de l'administrateur WordPress
|
||||
$headers = ['Content-Type: text/html; charset=UTF-8', 'From: ' . $name . ' <' . $email . '>'];
|
||||
|
||||
$mail_sent = wp_mail($to, $subject, nl2br($message), $headers);
|
||||
|
||||
if (!$mail_sent) {
|
||||
return new WP_Error('email_not_sent', 'Le message n’a pas pu être envoyé.', ['status' => 500]);
|
||||
}
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'message' => 'Message envoyé avec succès.',
|
||||
];
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user