Skip to content

Commit

Permalink
Merge branch 'hotfix/empty-taxonimies'
Browse files Browse the repository at this point in the history
  • Loading branch information
erwstout committed Oct 9, 2017
2 parents a0e8f4a + ac6149c commit 759607c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion better-wp-endpoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Better WordPress Endpoints
Plugin URI: https://github.com/factor1/better-wp-endpoints/
Description: Serves up slimmer WordPress Rest API endpoints, with some great enhancements.
Version: 0.1.5
Version: 0.1.6
Author: Eric Stout, Factor1 Studios
Author URI: https://factor1studios.com/
License: GPL3
Expand Down
16 changes: 10 additions & 6 deletions includes/get_post_by_id.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ function get_post_by_id( $data ) {
$bwe_categories = [];
$bwe_category_ids = [];

foreach ($categories as $key => $category) {
array_push($bwe_category_ids, $category->term_id);
array_push($bwe_categories, $category->cat_name);
if( !empty($categories) ){
foreach ($categories as $key => $category) {
array_push($bwe_category_ids, $category->term_id);
array_push($bwe_categories, $category->cat_name);
}
}

$bwe_post->category_ids = $bwe_category_ids;
Expand All @@ -61,9 +63,11 @@ function get_post_by_id( $data ) {
$bwe_tags = [];
$bwe_tag_ids = [];

foreach ($tags as $key => $tag) {
array_push($bwe_tag_ids, $tag->term_id);
array_push($bwe_tags, $tag->name);
if( !empty($tags) ){
foreach ($tags as $key => $tag) {
array_push($bwe_tag_ids, $tag->term_id);
array_push($bwe_tags, $tag->name);
}
}

$bwe_post->tag_ids = $bwe_tag_ids;
Expand Down
17 changes: 11 additions & 6 deletions includes/get_posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ function bwe_get_posts( WP_REST_Request $request ) {
$bwe_categories = [];
$bwe_category_ids = [];

foreach ($categories as $key => $category) {
array_push($bwe_category_ids, $category->term_id);
array_push($bwe_categories, $category->cat_name);
if( !empty($categories) ){
foreach ($categories as $key => $category) {
array_push($bwe_category_ids, $category->term_id);
array_push($bwe_categories, $category->cat_name);
}
}

$bwe_post->category_ids = $bwe_category_ids;
Expand All @@ -82,11 +84,14 @@ function bwe_get_posts( WP_REST_Request $request ) {
$bwe_tags = [];
$bwe_tag_ids = [];

foreach ($tags as $key => $tag) {
array_push($bwe_tag_ids, $tag->term_id);
array_push($bwe_tags, $tag->name);
if( !empty($tags) ){
foreach ($tags as $key => $tag) {
array_push($bwe_tag_ids, $tag->term_id);
array_push($bwe_tags, $tag->name);
}
}


$bwe_post->tag_ids = $bwe_tag_ids;
$bwe_post->tag_names = $bwe_tags;

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "better-wp-endpoints",
"version": "0.1.5",
"version": "0.1.6",
"description": "Serves up slimmer WordPress Rest API endpoints.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 759607c

Please sign in to comment.