Plugin Directory

Changeset 3289940


Ignore:
Timestamp:
05/08/2025 02:28:28 PM (11 months ago)
Author:
galbc
Message:

Release version 1.0.6

Location:
sapientseo
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • sapientseo/tags/1.0.6/inc/api/posts.php

    r3289920 r3289940  
    7878        'methods'  => 'GET',
    7979        'callback' => 'sapient_seo_get_all_posts',
     80        'permission_callback' => function ($request) {
     81            return sapient_seo_api_key_permission($request);
     82        }
     83    ]);
     84
     85    register_rest_route('sapientseo/v1', '/posts/(?P<id>\d+)', [
     86        'methods'  => 'GET',
     87        'callback' => 'sapient_seo_get_post_details',
    8088        'permission_callback' => function ($request) {
    8189            return sapient_seo_api_key_permission($request);
     
    200208    ]);
    201209}
     210
     211// Get Post Details
     212function sapient_seo_get_post_details(WP_REST_Request $request) {
     213    $post_id = intval($request->get_param('id'));
     214    $post    = get_post($post_id);
     215
     216    if (!$post || $post->post_type !== 'post') {
     217        return new WP_Error('invalid_post', 'Post not found.', ['status' => 404]);
     218    }
     219
     220    $acf = function_exists('get_fields') ? get_fields($post_id) : [];
     221    $seo = [
     222        'meta_title'       => get_post_meta($post_id, 'meta_title', true),
     223        'meta_description' => get_post_meta($post_id, 'meta_description', true),
     224        // Add more keys if needed
     225    ];
     226
     227    $categories = wp_get_post_categories($post_id, ['fields' => 'names']);
     228    $tags       = wp_get_post_tags($post_id, ['fields' => 'names']);
     229
     230    return rest_ensure_response([
     231        'id'           => $post_id,
     232        'title'        => get_the_title($post),
     233        'slug'         => $post->post_name,
     234        'status'       => $post->post_status,
     235        'excerpt'      => get_the_excerpt($post),
     236        'content'      => apply_filters('the_content', $post->post_content),
     237        'created_at'   => get_the_date('c', $post),
     238        'modified_at'  => get_post_modified_time('c', true, $post),
     239        'acf'          => $acf,
     240        'seo'          => $seo,
     241        'categories'   => $categories,
     242        'tags'         => $tags,
     243    ]);
     244}
  • sapientseo/tags/1.0.6/readme.txt

    r3289920 r3289940  
    44Tested up to: 6.8
    55Requires PHP: 7.4
    6 Stable tag: 1.0.5
     6Stable tag: 1.0.6
    77License: GPLv2 or later
    88License URI: https://www.gnu.org/licenses/gpl-2.0.html
  • sapientseo/tags/1.0.6/sapientseo.php

    r3289920 r3289940  
    33 * Plugin Name: SapientSEO
    44 * Description: Connect your WordPress site to SapientSEO using secure custom REST API endpoints.
    5  * Version: 1.0.5
     5 * Version: 1.0.6
    66 * Author: SapientSEO
    77 * Plugin URI: https://sapientseo.ai
  • sapientseo/trunk/inc/api/posts.php

    r3289920 r3289940  
    7878        'methods'  => 'GET',
    7979        'callback' => 'sapient_seo_get_all_posts',
     80        'permission_callback' => function ($request) {
     81            return sapient_seo_api_key_permission($request);
     82        }
     83    ]);
     84
     85    register_rest_route('sapientseo/v1', '/posts/(?P<id>\d+)', [
     86        'methods'  => 'GET',
     87        'callback' => 'sapient_seo_get_post_details',
    8088        'permission_callback' => function ($request) {
    8189            return sapient_seo_api_key_permission($request);
     
    200208    ]);
    201209}
     210
     211// Get Post Details
     212function sapient_seo_get_post_details(WP_REST_Request $request) {
     213    $post_id = intval($request->get_param('id'));
     214    $post    = get_post($post_id);
     215
     216    if (!$post || $post->post_type !== 'post') {
     217        return new WP_Error('invalid_post', 'Post not found.', ['status' => 404]);
     218    }
     219
     220    $acf = function_exists('get_fields') ? get_fields($post_id) : [];
     221    $seo = [
     222        'meta_title'       => get_post_meta($post_id, 'meta_title', true),
     223        'meta_description' => get_post_meta($post_id, 'meta_description', true),
     224        // Add more keys if needed
     225    ];
     226
     227    $categories = wp_get_post_categories($post_id, ['fields' => 'names']);
     228    $tags       = wp_get_post_tags($post_id, ['fields' => 'names']);
     229
     230    return rest_ensure_response([
     231        'id'           => $post_id,
     232        'title'        => get_the_title($post),
     233        'slug'         => $post->post_name,
     234        'status'       => $post->post_status,
     235        'excerpt'      => get_the_excerpt($post),
     236        'content'      => apply_filters('the_content', $post->post_content),
     237        'created_at'   => get_the_date('c', $post),
     238        'modified_at'  => get_post_modified_time('c', true, $post),
     239        'acf'          => $acf,
     240        'seo'          => $seo,
     241        'categories'   => $categories,
     242        'tags'         => $tags,
     243    ]);
     244}
  • sapientseo/trunk/readme.txt

    r3289920 r3289940  
    44Tested up to: 6.8
    55Requires PHP: 7.4
    6 Stable tag: 1.0.5
     6Stable tag: 1.0.6
    77License: GPLv2 or later
    88License URI: https://www.gnu.org/licenses/gpl-2.0.html
  • sapientseo/trunk/sapientseo.php

    r3289920 r3289940  
    33 * Plugin Name: SapientSEO
    44 * Description: Connect your WordPress site to SapientSEO using secure custom REST API endpoints.
    5  * Version: 1.0.5
     5 * Version: 1.0.6
    66 * Author: SapientSEO
    77 * Plugin URI: https://sapientseo.ai
Note: See TracChangeset for help on using the changeset viewer.