Changeset 3255397
- Timestamp:
- 03/13/2025 01:32:51 PM (19 months ago)
- Location:
- hipa-ai
- Files:
-
- 12 added
- 2 edited
-
tags/1.7 (added)
-
tags/1.7/README.txt (added)
-
tags/1.7/assets (added)
-
tags/1.7/assets/icon-128x128.png (added)
-
tags/1.7/assets/screenshot-1.png (added)
-
tags/1.7/assets/screenshot-2.png (added)
-
tags/1.7/assets/screenshot-3.png (added)
-
tags/1.7/assets/screenshot-4.png (added)
-
tags/1.7/assets/screenshot-5.png (added)
-
tags/1.7/assets/screenshot-6.png (added)
-
tags/1.7/hipa-ai.php (added)
-
tags/1.7/logo.png (added)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/hipa-ai.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
hipa-ai/trunk/README.txt
r3255301 r3255397 6 6 Tested up to: 6.7 7 7 Requires PHP: 7.0 8 Stable tag: 1. 68 Stable tag: 1.7 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 91 91 * Added functionality of fetching single post 92 92 93 = 1.7 = 94 * Single post now can be fetched by id and after date period 95 93 96 == Upgrade Notice == 94 97 -
hipa-ai/trunk/hipa-ai.php
r3255301 r3255397 4 4 Plugin URI: https://hipa.ai 5 5 Description: Refresh your blog posts on autopilot with intelligent, in-depth updates. 6 Version: 1. 66 Version: 1.7 7 7 Author: Hipa.ai 8 8 Author URI: https://hipa.ai/suggestions/new … … 333 333 // Validate URL parameter 334 334 $url = $request->get_param('url'); 335 if (empty($url)) { 336 return new WP_REST_Response(array('message' => 'URL parameter is required'), 400); 337 } 338 339 // Sanitize and validate URL 335 $id = $request->get_param('id'); 336 $after = $request->get_param('after'); 337 $context = $request->get_param('context'); 338 339 if ($context && !in_array($context, ['raw', 'rendered'])) { 340 return new WP_REST_Response(array('message' => 'Invalid context value'), 400); 341 } 342 343 // Ensure that at least one identifier (URL or ID) is provided 344 if (!$url && !$id) { 345 return new WP_REST_Response(array('message' => 'Either URL or post ID parameter is required'), 400); 346 } 347 348 if ($id) { 349 $post_id = (int) $id; 350 } else { 340 351 $clean_url = esc_url_raw($url); 341 352 $site_url = get_site_url(); 342 353 343 // Verify URL belongs to this site344 354 if (strpos($clean_url, $site_url) !== 0) { 345 355 return new WP_REST_Response(array('message' => 'Invalid URL for this site'), 400); 346 356 } 347 357 348 // Get post ID from URL349 358 $post_id = url_to_postid($clean_url); 359 } 360 350 361 if (!$post_id) { 351 362 return new WP_REST_Response(array('message' => 'Post not found for the given URL'), 404); 352 363 } 353 364 354 // Get post data355 365 $post = get_post($post_id); 356 366 if (!$post || $post->post_status !== 'publish') { … … 358 368 } 359 369 360 // Handle context parameter 361 $context = $request->get_param('context'); 362 if ($context && !in_array($context, ['raw', 'rendered'])) { 363 return new WP_REST_Response(array('message' => 'Invalid context value'), 400); 364 } 365 366 // Format content based on context 370 if ($after) { 371 if (strtotime($post->post_modified) < strtotime($after)) { 372 return new WP_REST_Response(array('message' => 'Post not found for the given date filter'), 404); 373 } 374 } 375 367 376 if ($context === 'raw') { 368 377 $raw_content = get_post_field('post_content', $post_id); … … 371 380 $content = apply_filters('the_content', $post->post_content); 372 381 } 382 373 383 374 384 // Build response
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)