From 8c49254e5251a900c7a5244fd0ffc67b80ad37f8 Mon Sep 17 00:00:00 2001 From: Eric Stout Date: Mon, 4 Jun 2018 13:38:34 -0700 Subject: [PATCH 1/4] Add permalinks to responses from issue #17 --- includes/create_cpt_endpoints.php | 4 +++- includes/get_cpt_by_id.php | 4 +++- includes/get_cpt_by_slug.php | 4 +++- includes/get_page_by_id.php | 4 +++- includes/get_pages.php | 4 +++- includes/get_post_by_id.php | 4 +++- includes/get_post_by_slug.php | 4 +++- includes/get_posts.php | 4 +++- includes/get_posts_tax.php | 4 +++- includes/get_search.php | 4 +++- 10 files changed, 30 insertions(+), 10 deletions(-) diff --git a/includes/create_cpt_endpoints.php b/includes/create_cpt_endpoints.php index cc18040..329e89c 100644 --- a/includes/create_cpt_endpoints.php +++ b/includes/create_cpt_endpoints.php @@ -67,9 +67,11 @@ function bre_build_cpt_endpoints() { $bre_post = new stdClass(); // get post data + $permalink = get_permalink(); $bre_post->id = get_the_ID(); $bre_post->title = get_the_title(); - $bre_post->slug = basename(get_permalink()); + $bre_post->slug = basename($permalink); + $bre_post->permalink = $permalink; $bre_post->date = get_the_date('c'); $bre_post->excerpt = get_the_excerpt(); diff --git a/includes/get_cpt_by_id.php b/includes/get_cpt_by_id.php index 657419a..788ce7a 100644 --- a/includes/get_cpt_by_id.php +++ b/includes/get_cpt_by_id.php @@ -46,9 +46,11 @@ function bre_build_single_cpt_endpoints() { // get post data + $permalink = get_permalink(); $bre_cpt_post->id = get_the_ID(); $bre_cpt_post->title = get_the_title(); - $bre_cpt_post->slug = basename(get_permalink()); + $bre_post->slug = basename($permalink); + $bre_post->permalink = $permalink; $bre_cpt_post->date = get_the_date('c'); $bre_cpt_post->excerpt = get_the_excerpt(); $bre_cpt_post->content = apply_filters('the_content', get_the_content()); diff --git a/includes/get_cpt_by_slug.php b/includes/get_cpt_by_slug.php index e938241..26a8e2c 100644 --- a/includes/get_cpt_by_slug.php +++ b/includes/get_cpt_by_slug.php @@ -46,9 +46,11 @@ function bre_build_single_cpt_endpoints_slug() { // get post data + $permalink = get_permalink(); $bre_cpt_post->id = get_the_ID(); $bre_cpt_post->title = get_the_title(); - $bre_cpt_post->slug = basename(get_permalink()); + $bre_cpt_post->slug = basename($permalink); + $bre_cpt_post->permalink = $permalink; $bre_cpt_post->date = get_the_date('c'); $bre_cpt_post->excerpt = get_the_excerpt(); $bre_cpt_post->content = apply_filters('the_content', get_the_content()); diff --git a/includes/get_page_by_id.php b/includes/get_page_by_id.php index 1124d23..3942673 100644 --- a/includes/get_page_by_id.php +++ b/includes/get_page_by_id.php @@ -26,9 +26,11 @@ function get_page_by_id( WP_REST_Request $request ){ // better wordpress endpoint post object $bre_page = new stdClass(); + $permalink = get_permalink(); $bre_page->id = get_the_ID(); $bre_page->title = get_the_title(); - $bre_page->slug = basename(get_permalink()); + $bre_page->slug = basename($permalink); + $bre_page->permalink = $permalink; /* * diff --git a/includes/get_pages.php b/includes/get_pages.php index 579a791..7852bf0 100644 --- a/includes/get_pages.php +++ b/includes/get_pages.php @@ -59,9 +59,11 @@ function bre_get_pages( WP_REST_Request $request ) { * get page data * */ + $permalink = get_permalink(); $bre_page->id = get_the_ID(); $bre_page->title = get_the_title(); - $bre_page->slug = basename(get_permalink()); + $bre_page->slug = basename($permalink); + $bre_page->permalink = $permalink; /* * diff --git a/includes/get_post_by_id.php b/includes/get_post_by_id.php index 2d42d59..127fd19 100644 --- a/includes/get_post_by_id.php +++ b/includes/get_post_by_id.php @@ -24,9 +24,11 @@ function get_post_by_id( $data ) { // better wordpress endpoint post object $bre_post = new stdClass(); + $permalink = get_permalink(); $bre_post->id = get_the_ID(); $bre_post->title = get_the_title(); - $bre_post->slug = basename(get_permalink()); + $bre_post->slug = basename($permalink); + $bre_post->permalink = $permalink; $bre_post->date = get_the_date('c'); $bre_post->excerpt = get_the_excerpt(); $bre_post->content = apply_filters('the_content', get_the_content()); diff --git a/includes/get_post_by_slug.php b/includes/get_post_by_slug.php index 9e913f8..7c2b5f0 100644 --- a/includes/get_post_by_slug.php +++ b/includes/get_post_by_slug.php @@ -26,9 +26,11 @@ function get_post_by_slug( WP_REST_Request $request ) { // better wordpress endpoint post object $bre_post = new stdClass(); + $permalink = get_permalink(); $bre_post->id = get_the_ID(); $bre_post->title = get_the_title(); - $bre_post->slug = basename(get_permalink()); + $bre_post->slug = basename($permalink); + $bre_post->permalink = $permalink; $bre_post->date = get_the_date('c'); $bre_post->excerpt = get_the_excerpt(); $bre_post->content = apply_filters('the_content', get_the_content()); diff --git a/includes/get_posts.php b/includes/get_posts.php index 8fd7769..ee08f5f 100644 --- a/includes/get_posts.php +++ b/includes/get_posts.php @@ -59,9 +59,11 @@ function bre_get_posts( WP_REST_Request $request ) { $bre_post = new stdClass(); // get post data + $permalink = get_permalink(); $bre_post->id = get_the_ID(); $bre_post->title = get_the_title(); - $bre_post->slug = basename(get_permalink()); + $bre_post->slug = basename($permalink); + $bre_post->permalink = $permalink; $bre_post->date = get_the_date('c'); $bre_post->excerpt = get_the_excerpt(); diff --git a/includes/get_posts_tax.php b/includes/get_posts_tax.php index ab67c85..835fd45 100644 --- a/includes/get_posts_tax.php +++ b/includes/get_posts_tax.php @@ -78,9 +78,11 @@ function bre_build_custom_tax_endpoint() { $bre_tax_post = new stdClass(); // get post data + $permalink = get_permalink(); $bre_tax_post->id = get_the_ID(); $bre_tax_post->title = get_the_title(); - $bre_tax_post->slug = basename(get_permalink()); + $bre_tax_post->slug = basename($permalink); + $bre_tax_post->permalink = $permalink; $bre_tax_post->date = get_the_date('c'); $bre_tax_post->excerpt = get_the_excerpt(); diff --git a/includes/get_search.php b/includes/get_search.php index 38d8506..252c1c8 100644 --- a/includes/get_search.php +++ b/includes/get_search.php @@ -51,9 +51,11 @@ function bre_get_search( WP_REST_Request $request ) { $bre_post = new stdClass(); // get post data + $permalink = get_permalink(); $bre_post->id = get_the_ID(); $bre_post->title = get_the_title(); - $bre_post->slug = basename(get_permalink()); + $bre_post->slug = basename($permalink); + $bre_post->permalink = $permalink; $bre_post->date = get_the_date('c'); $bre_post->excerpt = get_the_excerpt(); From 19537fa1684eb27943b5c1286825a86eabc0de5a Mon Sep 17 00:00:00 2001 From: Eric Stout Date: Mon, 4 Jun 2018 13:41:10 -0700 Subject: [PATCH 2/4] Rename main plugin file --- better-wp-endpoints.php => better-rest-endpoints.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename better-wp-endpoints.php => better-rest-endpoints.php (100%) diff --git a/better-wp-endpoints.php b/better-rest-endpoints.php similarity index 100% rename from better-wp-endpoints.php rename to better-rest-endpoints.php From 9305c1d82b9742944cf8518e6939538119dd8785 Mon Sep 17 00:00:00 2001 From: Eric Stout Date: Mon, 4 Jun 2018 13:43:58 -0700 Subject: [PATCH 3/4] Update changelogs --- CHANGELOG.md | 4 ++++ better-rest-endpoints.php | 2 +- readme.txt | 5 ++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a114db0..7ade3f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] n/a +## [1.2.1] - 2018-06-04 +### Added +- Permalinks to all page/post endpoints + ## [1.2.0] - 2018-02-07 ### Added - ACF query in endpoint url to hide acf values from the response where applicable (all collections) diff --git a/better-rest-endpoints.php b/better-rest-endpoints.php index a409806..16bc1b5 100644 --- a/better-rest-endpoints.php +++ b/better-rest-endpoints.php @@ -3,7 +3,7 @@ Plugin Name: Better Rest Endpoints Plugin URI: https://github.com/factor1/better-rest-endpoints/ Description: Serves up slimmer WordPress Rest API endpoints, with some great enhancements. -Version: 1.2.0 +Version: 1.2.1 Author: Eric Stout, Factor1 Studios Author URI: https://factor1studios.com/ License: GPL3 diff --git a/readme.txt b/readme.txt index a64ef03..57434e6 100644 --- a/readme.txt +++ b/readme.txt @@ -6,7 +6,7 @@ Contributors: factor1, erwstout Tags: rest, api, endpoints, acf, json Requires at least: 4.7.1 Tested up to: 4.9.4 -Stable Tag: 1.2.0 +Stable Tag: 1.2.1 License: GNU Version 3 or Any Later Version A WordPress plugin that serves up slimmer WP Rest API endpoints. @@ -42,6 +42,9 @@ apps endpoints to use Better Rest Endpoints. == Changelog == += 1.2.1, June 4, 2018 = +* Add: Permalinks to all post/page endpoints + = 1.2.0, Febuary 7, 2018 = * Add: ACF query in endpoint url to hide acf values from the response where applicable (all collections) * Add: Media query in endpoint url to hide featured media from the response where applicable (all collections) From 34c87ca5a8ab8f58ba9227f4c6186eaf8994b3b1 Mon Sep 17 00:00:00 2001 From: Eric Stout Date: Mon, 4 Jun 2018 13:50:03 -0700 Subject: [PATCH 4/4] Fix object name --- includes/get_cpt_by_id.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/get_cpt_by_id.php b/includes/get_cpt_by_id.php index 788ce7a..939395b 100644 --- a/includes/get_cpt_by_id.php +++ b/includes/get_cpt_by_id.php @@ -49,8 +49,8 @@ function bre_build_single_cpt_endpoints() { $permalink = get_permalink(); $bre_cpt_post->id = get_the_ID(); $bre_cpt_post->title = get_the_title(); - $bre_post->slug = basename($permalink); - $bre_post->permalink = $permalink; + $bre_cpt_post->slug = basename($permalink); + $bre_cpt_post->permalink = $permalink; $bre_cpt_post->date = get_the_date('c'); $bre_cpt_post->excerpt = get_the_excerpt(); $bre_cpt_post->content = apply_filters('the_content', get_the_content());