REFACTOR Revue current id with a dedicated route containing the id
This commit is contained in:
parent
ed74a03c22
commit
c176afd05e
|
|
@ -21,6 +21,13 @@ add_action('rest_api_init', function () {
|
||||||
'permission_callback' => '__return_true',
|
'permission_callback' => '__return_true',
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// ################ RÉCUPÉRATION DES ARTICLES D'UNE REVUE ################
|
||||||
|
register_rest_route('dynamiques-datas/v1/build', '/revues/(?P<revue_id>\d+)/articles', array(
|
||||||
|
'methods' => 'GET',
|
||||||
|
'callback' => 'build_revue_articles',
|
||||||
|
'permission_callback' => '__return_true',
|
||||||
|
));
|
||||||
|
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
INTERACTIONS ROUTES
|
INTERACTIONS ROUTES
|
||||||
|
|
@ -36,11 +43,11 @@ add_action('rest_api_init', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ################ FILTER ARTICLES ################
|
// ################ FILTER ARTICLES ################
|
||||||
|
|
||||||
function build_articles($request)
|
function build_articles($request)
|
||||||
{
|
{
|
||||||
|
|
||||||
$etiquette = esc_html($request->get_param('etiquette'));
|
$etiquette = esc_html($request->get_param('etiquette'));
|
||||||
$auteur = esc_html($request->get_param('auteur'));
|
$auteur = esc_html($request->get_param('auteur'));
|
||||||
$sort_by = esc_html($request->get_param('sort_by'));
|
$sort_by = esc_html($request->get_param('sort_by'));
|
||||||
|
|
@ -133,10 +140,12 @@ function build_articles($request)
|
||||||
|
|
||||||
// ################ FILTER REVUES ################
|
// ################ FILTER REVUES ################
|
||||||
|
|
||||||
function build_revues($request)
|
function build_revue_articles($request)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
$search = esc_html($request->get_param('search'));
|
$search = esc_html($request->get_param('search'));
|
||||||
$current_revue_id = intval($request->get_param('current_revue_id'));
|
$current_revue_id = intval($request->get_param('revue_id'));
|
||||||
|
|
||||||
// Récupérer les articles liés à la revue courante
|
// Récupérer les articles liés à la revue courante
|
||||||
$issue_related_articles = get_field('articles', $current_revue_id);
|
$issue_related_articles = get_field('articles', $current_revue_id);
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,9 @@ export default function handleSearchRevue() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`/wp-json/dynamiques-datas/v1/build/revues?search=${encodeURIComponent(
|
`/wp-json/dynamiques-datas/v1/build/revues/${currentRevueId}/articles?search=${encodeURIComponent(
|
||||||
searchValue
|
searchValue
|
||||||
)}¤t_revue_id=${currentRevueId}`
|
)}`
|
||||||
);
|
);
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user