From a1a258303942f20c3585959f67216dc11f7c92bf Mon Sep 17 00:00:00 2001 From: Antoine M Date: Tue, 10 Jun 2025 15:01:47 +0200 Subject: [PATCH] FEATURE introducing the file --- includes/api.php | 88 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 includes/api.php diff --git a/includes/api.php b/includes/api.php new file mode 100644 index 0000000..16fcb79 --- /dev/null +++ b/includes/api.php @@ -0,0 +1,88 @@ + 'GET', + 'callback' => 'build_revue_authors', + 'permission_callback' => '__return_true', + )); +}); + + +// ################ NEWS ################ + +function build_revue_authors($request) +{ + + write_log($request); + + // $previousActivePage = esc_html($request->get_param('active-page')) ?? 1; + // $activeTermID = esc_html($request->get_param('active-term-id')); + // $postsPerPage = esc_html($request->get_param('posts-per-page')) ?? 12; + + // $activePage = is_numeric($previousActivePage) ? $previousActivePage + 1 : 1; + + // $taxQuery = $activeTermID && is_numeric($activeTermID) ? array( + // array( + // 'taxonomy' => 'news_type', + // 'field' => 'term_id', + // 'terms' => $activeTermID + // ) + // ) : null; + + + // do_action('wpml_switch_language', $currentLanguage); + + // $args = array( + // "status" => "publish", + // "post_type" => "post", + // "posts_per_page" => $postsPerPage, + // "paged" => $activePage, + // "tax_query" => $taxQuery + // ); + // $newsPostsDatas = new WP_Query($args); + + // ob_start(); + // foreach ($newsPostsDatas->posts as $key => $post) { + // $post_thumbnail = get_the_post_thumbnail($post->ID, 'full', array('class' => 'card-news__thumbnail card-post__thumbnail')) ?? null; + // $news_type = get_the_terms($post->ID, "news_type") ?? null; + // $post_date = get_the_date('j.m.Y', $post->ID) ?? null; + + // get_template_part( + // 'template-components/cards/card-news', + // null, + // array( + // 'card_variant' => 'activite', + // 'post_ID' => $post->ID, + // 'post_title' => get_the_title($post->ID), + // 'post_thumbnail' => $post_thumbnail, + // 'news_type' => $news_type, + // 'post_date' => $post_date, + // ) + // ); + // } + + // $html_template = ob_get_clean(); + + // $response_data = array( + // 'html_template' => $html_template, + // 'total_posts_found' => $newsPostsDatas->found_posts, + // 'active_page' => $activePage, + // 'max_num_pages' => $newsPostsDatas->max_num_pages, + // ); + + + $response = new WP_REST_Response($response_data); + + $response->set_status(200); + + return $response; +}