Changeset 3289940
- Timestamp:
- 05/08/2025 02:28:28 PM (11 months ago)
- Location:
- sapientseo
- Files:
-
- 6 edited
- 1 copied
-
tags/1.0.6 (copied) (copied from sapientseo/trunk)
-
tags/1.0.6/inc/api/posts.php (modified) (2 diffs)
-
tags/1.0.6/readme.txt (modified) (1 diff)
-
tags/1.0.6/sapientseo.php (modified) (1 diff)
-
trunk/inc/api/posts.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/sapientseo.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
sapientseo/tags/1.0.6/inc/api/posts.php
r3289920 r3289940 78 78 'methods' => 'GET', 79 79 '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', 80 88 'permission_callback' => function ($request) { 81 89 return sapient_seo_api_key_permission($request); … … 200 208 ]); 201 209 } 210 211 // Get Post Details 212 function 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 4 4 Tested up to: 6.8 5 5 Requires PHP: 7.4 6 Stable tag: 1.0. 56 Stable tag: 1.0.6 7 7 License: GPLv2 or later 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html -
sapientseo/tags/1.0.6/sapientseo.php
r3289920 r3289940 3 3 * Plugin Name: SapientSEO 4 4 * Description: Connect your WordPress site to SapientSEO using secure custom REST API endpoints. 5 * Version: 1.0. 55 * Version: 1.0.6 6 6 * Author: SapientSEO 7 7 * Plugin URI: https://sapientseo.ai -
sapientseo/trunk/inc/api/posts.php
r3289920 r3289940 78 78 'methods' => 'GET', 79 79 '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', 80 88 'permission_callback' => function ($request) { 81 89 return sapient_seo_api_key_permission($request); … … 200 208 ]); 201 209 } 210 211 // Get Post Details 212 function 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 4 4 Tested up to: 6.8 5 5 Requires PHP: 7.4 6 Stable tag: 1.0. 56 Stable tag: 1.0.6 7 7 License: GPLv2 or later 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html -
sapientseo/trunk/sapientseo.php
r3289920 r3289940 3 3 * Plugin Name: SapientSEO 4 4 * Description: Connect your WordPress site to SapientSEO using secure custom REST API endpoints. 5 * Version: 1.0. 55 * Version: 1.0.6 6 6 * Author: SapientSEO 7 7 * Plugin URI: https://sapientseo.ai
Note: See TracChangeset
for help on using the changeset viewer.