Changeset 3234465
- Timestamp:
- 02/04/2025 07:28:54 AM (13 months ago)
- Location:
- pageapp
- Files:
-
- 18 added
- 2 edited
-
tags/1.4.4 (added)
-
tags/1.4.4/css (added)
-
tags/1.4.4/css/admin.css (added)
-
tags/1.4.4/images (added)
-
tags/1.4.4/images/pageapp20.png (added)
-
tags/1.4.4/inc (added)
-
tags/1.4.4/inc/cachelib.php (added)
-
tags/1.4.4/inc/httplib.php (added)
-
tags/1.4.4/inc/jsonlib.php (added)
-
tags/1.4.4/inc/pluginlib.php (added)
-
tags/1.4.4/inc/restlib.php (added)
-
tags/1.4.4/inc/settingslib.php (added)
-
tags/1.4.4/inc/utilslib.php (added)
-
tags/1.4.4/js (added)
-
tags/1.4.4/js/admin.js (added)
-
tags/1.4.4/pageapp-json.php (added)
-
tags/1.4.4/pageapp.php (added)
-
tags/1.4.4/readme.txt (added)
-
trunk/pageapp.php (modified) (7 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pageapp/trunk/pageapp.php
r3168966 r3234465 4 4 Plugin URI: https://wordpress.org/plugins/pageapp/ 5 5 Description: Extensions to Wordpress wp-json for the PageApp API and mobile framework 6 Version: 1.4. 36 Version: 1.4.4 7 7 Author: PageApp 8 8 Author URI: https://www.pageapp.com … … 41 41 public static function plugin() { 42 42 return plugins_url(null,__FILE__); 43 } 44 public static function is_rest() { 45 return defined('REST_REQUEST') && REST_REQUEST; 43 46 } 44 47 … … 60 63 add_filter('lostpassword_redirect', array(static::class, 'lostpassword_redirect')); 61 64 add_filter('rest_pre_dispatch', array(static::class, 'rest_pre_dispatch'), 10, 3); 65 66 if (get_option('pageapp_metaquery') == '1') { 67 add_filter('rest_post_query', array(static::class, 'filter_rest_meta_query'), 10, 2); 68 add_filter('rest_page_query', array(static::class, 'filter_rest_meta_query'), 10, 2); 69 add_filter('rest_attachment_query', array(static::class, 'filter_rest_meta_query'), 10, 2); 70 add_filter('rest_post_tag_query', array(static::class, 'filter_rest_meta_query'), 10, 2); 71 add_filter('rest_cateegory_query', array(static::class, 'filter_rest_meta_query'), 10, 2); 72 add_filter('rest_user_query', array(static::class, 'filter_rest_meta_query'), 10, 2); 73 } 74 if (get_option('pageapp_addimages') == '1') { 75 add_filter('rest_prepare_post_tag', array(static::class, 'rest_prepre_term'), 10, 3); 76 add_filter('rest_prepare_category', array(static::class, 'rest_prepre_term'), 10, 3); 77 } 78 } 79 public static function rest_prepre_term($response, $item, $request) { 80 $attachment_id = get_term_meta($item->term_id, 'attachment_id', true); 81 if ($attachment_id) { 82 $response->data['featured_image_urls'] = self::get_attahment_urls(get_term_meta($item->term_id, 'attachment_id', true)); 83 } 84 return $response; 62 85 } 63 86 public static function init() { … … 70 93 array('id'=>'pageapp_relevanssi', 'type'=>'boolean', 'title'=>'Enable Relevanssi'), 71 94 array('id'=>'pageapp_whitelist', 'type'=>'boolean', 'title'=>'Whitelist Post Meta'), 72 array('id'=>'pageapp_addimages', 'type'=>'boolean', 'title'=>'Add Images to Posts '),95 array('id'=>'pageapp_addimages', 'type'=>'boolean', 'title'=>'Add Images to Posts/Pages/Terms'), 73 96 array('id'=>'pageapp_categories', 'type'=>'boolean', 'title'=>'Include Category Details'), 74 97 array('id'=>'pageapp_customposts', 'type'=>'boolean', 'title'=>'Include Custom Post Types'), 98 array('id'=>'pageapp_metaquery', 'type'=>'boolean', 'title'=>'Enable Querying by Meta'), 75 99 array('id'=>'pageapp_apisettings', 'type'=>'title', 'title'=>'API Settings'), 76 100 array('id'=>'pageapp_restkey', 'type'=>'boolean', 'title'=>'WP JSON Key', 'description'=>'Require apikey on WP JSON API'), … … 291 315 ) 292 316 ); 317 //TODO: This doesn't seem to work 293 318 $taxonomies = get_object_taxonomies($post_type, 'objects'); 294 319 foreach ($taxonomies as $name => $tax) { … … 370 395 } 371 396 public static function image_sizes($post_id, $post_type = null) { 372 $featured_id = get_post_thumbnail_id($post_id); 397 return self::get_attahment_urls(get_post_thumbnail_id($post_id)); 398 } 399 public static function get_attahment_urls($featured_id) { 373 400 $sizes = wp_get_attachment_metadata($featured_id); 374 401 $size_data = array(); 375 402 if (!empty($sizes['sizes'])) { 403 $sizes['sizes']['full'] = []; 376 404 foreach ($sizes['sizes'] as $key => $size) { 377 405 $image_src = wp_get_attachment_image_src($featured_id, $key); … … 442 470 } 443 471 return $result; 472 } 473 public static function filter_rest_meta_query($args, $request = null) { 474 $request = $_REQUEST; 475 if (!empty($request['meta_key']) && !empty($request['meta_compare'])) { 476 $meta_query = [ 477 [ 478 'key' => sanitize_text_field($request['meta_key']), 479 'compare' => sanitize_text_field($request['meta_compare']), 480 ], 481 ]; 482 483 if (!empty($request['meta_value'])) { 484 $meta_query[0]['value'] = sanitize_text_field($request['meta_value']); 485 } 486 487 $args['meta_query'] = $meta_query; 488 } 489 return $args; 444 490 } 445 491 -
pageapp/trunk/readme.txt
r3168966 r3234465 4 4 Requires at least: 3.0 5 5 Tested up to: 6.5.4 6 Stable tag: 1.4. 36 Stable tag: 1.4.4 7 7 License: © 2024 Thireen32 Pty Ltd 8 8 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=K6VKWB3HZB2T2&item_name=Donation%20to%20jameslow%2ecom¤cy_code=USD&bn=PP%2dDonationsBF&charset=UTF%2d8 … … 28 28 29 29 == Changelog == 30 31 = 1.4.4 = 32 * Add option to query by meta 30 33 31 34 = 1.4.3 =
Note: See TracChangeset
for help on using the changeset viewer.