Skip to content

Commit 118446d

Browse files
committed
Merge branch 'hotfix/is-plugin-active'
2 parents 5a1bec9 + bba9369 commit 118446d

20 files changed

+62
-46
lines changed

CHANGELOG.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77
## [Unreleased]
88
n/a
99

10+
## [1.0.2] - 2018-01-19
11+
### Fixed
12+
- Fixed static instance warning
13+
- Fixed failure of ACF function by including admin plugin.php
14+
15+
### Updates
16+
- Updates all functions named bwe_ to bre_
17+
1018
## [1.0.1] - 2018-01-19
1119
### Added
1220
- Changelog
13-
- readme.txt for WP repo
21+
- readme.txt for WP repo

better-wp-endpoints.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: Better Rest Endpoints
44
Plugin URI: https://github.com/factor1/better-rest-endpoints/
55
Description: Serves up slimmer WordPress Rest API endpoints, with some great enhancements.
6-
Version: 1.0.1
6+
Version: 1.0.2
77
Author: Eric Stout, Factor1 Studios
88
Author URI: https://factor1studios.com/
99
License: GPL3
@@ -54,7 +54,7 @@ private function __construct() {}
5454
*
5555
* @return F1_Better_Rest_Endpoints
5656
*/
57-
public function instance() {
57+
public static function instance() {
5858
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof F1_Better_Rest_Endpoints ) ) {
5959
self::$instance = new F1_Better_Rest_Endpoints;
6060

copy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const fs = require('fs-extra'),
2-
target = '/Users/ericstout/Documents/projects/better-rest-endpoints-wp/app/public/wp-content/plugins/better-rest-endpoints',
2+
target = '/Users/ericstout/Documents/projects/better-wp-endpoints-wp/app/public/wp-content/plugins/better-wp-endpoints',
33
files = './';
44

55
fs.copy(files, target)

includes/create_cpt_endpoints.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
* @since 0.0.1
66
*/
77

8-
function bwe_build_cpt_endpoints() {
9-
if( bwe_get_cpts() ){
8+
function bre_build_cpt_endpoints() {
9+
if( bre_get_cpts() ){
1010

1111
// store what custom post types we have
12-
$cpt_collection = bwe_get_cpts();
12+
$cpt_collection = bre_get_cpts();
1313

1414
foreach ($cpt_collection as $key => $cpt) {
1515

@@ -97,7 +97,7 @@ function bwe_build_cpt_endpoints() {
9797
* return acf fields if they exist
9898
*
9999
*/
100-
$bre_post->acf = bwe_get_acf();
100+
$bre_post->acf = bre_get_acf();
101101

102102
/*
103103
*
@@ -209,4 +209,4 @@ function bwe_build_cpt_endpoints() {
209209
* Add action for cpt endpoint building
210210
*
211211
*/
212-
add_action( 'rest_api_init', 'bwe_build_cpt_endpoints' );
212+
add_action( 'rest_api_init', 'bre_build_cpt_endpoints' );

includes/get_acf.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
* @since 0.0.1
88
*/
99

10-
function bwe_get_acf() {
10+
function bre_get_acf() {
11+
12+
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
13+
1114
// check if acf is active before doing anything
1215
if( is_plugin_active('advanced-custom-fields-pro/acf.php') || is_plugin_active('advanced-custom-fields/acf.php') ) {
1316

includes/get_cpt_by_id.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
* @since 0.0.1
88
*/
99

10-
function bwe_build_single_cpt_endpoints() {
11-
if( bwe_get_cpts() ) {
10+
function bre_build_single_cpt_endpoints() {
11+
if( bre_get_cpts() ) {
1212

1313
// store what custom post types we have
14-
$cpt_collection = bwe_get_cpts();
14+
$cpt_collection = bre_get_cpts();
1515

1616
foreach ($cpt_collection as $key => $cpt) {
1717

@@ -76,7 +76,7 @@ function bwe_build_single_cpt_endpoints() {
7676
* return acf fields if they exist
7777
*
7878
*/
79-
$bre_cpt_post->acf = bwe_get_acf();
79+
$bre_cpt_post->acf = bre_get_acf();
8080

8181
/*
8282
*
@@ -122,4 +122,4 @@ function bwe_build_single_cpt_endpoints() {
122122
* Add action for cpt endpoint building
123123
*
124124
*/
125-
add_action( 'rest_api_init', 'bwe_build_single_cpt_endpoints' );
125+
add_action( 'rest_api_init', 'bre_build_single_cpt_endpoints' );

includes/get_cpt_by_slug.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
* @since 0.0.1
88
*/
99

10-
function bwe_build_single_cpt_endpoints_slug() {
11-
if( bwe_get_cpts() ) {
10+
function bre_build_single_cpt_endpoints_slug() {
11+
if( bre_get_cpts() ) {
1212

1313
// store what custom post types we have
14-
$cpt_collection = bwe_get_cpts();
14+
$cpt_collection = bre_get_cpts();
1515

1616
foreach ($cpt_collection as $key => $cpt) {
1717

@@ -76,7 +76,7 @@ function bwe_build_single_cpt_endpoints_slug() {
7676
* return acf fields if they exist
7777
*
7878
*/
79-
$bre_cpt_post->acf = bwe_get_acf();
79+
$bre_cpt_post->acf = bre_get_acf();
8080

8181
/*
8282
*
@@ -122,4 +122,4 @@ function bwe_build_single_cpt_endpoints_slug() {
122122
* Add action for cpt endpoint building
123123
*
124124
*/
125-
add_action( 'rest_api_init', 'bwe_build_single_cpt_endpoints_slug' );
125+
add_action( 'rest_api_init', 'bre_build_single_cpt_endpoints_slug' );

includes/get_cpts.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* bwe_get_cpts()
3+
* bre_get_cpts()
44
* Get Post Types, but filter out core WP and ACF post types
55
*
66
* TODO: Simplify the allowed post types, example: https://github.com/postpromoterpro/post-promoter-pro/blob/master/includes/general-functions.php#L89
@@ -10,7 +10,7 @@
1010
* @since 0.0.1
1111
*/
1212

13-
function bwe_get_cpts() {
13+
function bre_get_cpts() {
1414

1515
$bre_cpts = array();
1616

includes/get_page_by_id.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function get_page_by_id( WP_REST_Request $request ){
6464
* return acf fields if they exist
6565
*
6666
*/
67-
$bre_page->acf = bwe_get_acf();
67+
$bre_page->acf = bre_get_acf();
6868

6969
/*
7070
*

includes/get_pages.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
// get a collection of pages with parameters
11-
function bwe_get_pages( WP_REST_Request $request ) {
11+
function bre_get_pages( WP_REST_Request $request ) {
1212

1313
// check for params
1414
$posts_per_page = $request['per_page']?: '10';
@@ -97,7 +97,7 @@ function bwe_get_pages( WP_REST_Request $request ) {
9797
* return acf fields if they exist
9898
*
9999
*/
100-
$bre_page->acf = bwe_get_acf();
100+
$bre_page->acf = bre_get_acf();
101101

102102
/*
103103
*
@@ -146,7 +146,7 @@ function bwe_get_pages( WP_REST_Request $request ) {
146146
add_action( 'rest_api_init', function () {
147147
register_rest_route( 'better-rest-endpoints/v1', '/pages/', array(
148148
'methods' => 'GET',
149-
'callback' => 'bwe_get_pages',
149+
'callback' => 'bre_get_pages',
150150
'args' => array(
151151
'per_page' => array(
152152
'description' => 'Maxiumum number of items to show per page.',

includes/get_post_by_id.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function get_post_by_id( $data ) {
7979
* return acf fields if they exist
8080
*
8181
*/
82-
$bre_post->acf = bwe_get_acf();
82+
$bre_post->acf = bre_get_acf();
8383

8484
/*
8585
*

includes/get_posts.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @since 0.0.1
88
*/
99

10-
function bwe_get_posts( WP_REST_Request $request ) {
10+
function bre_get_posts( WP_REST_Request $request ) {
1111

1212
// check for params
1313
$posts_per_page = $request['per_page']?: '10';
@@ -116,7 +116,7 @@ function bwe_get_posts( WP_REST_Request $request ) {
116116
* return acf fields if they exist
117117
*
118118
*/
119-
$bre_post->acf = bwe_get_acf();
119+
$bre_post->acf = bre_get_acf();
120120

121121
/*
122122
*
@@ -163,7 +163,7 @@ function bwe_get_posts( WP_REST_Request $request ) {
163163
add_action( 'rest_api_init', function () {
164164
register_rest_route( 'better-rest-endpoints/v1', '/posts/', array(
165165
'methods' => 'GET',
166-
'callback' => 'bwe_get_posts',
166+
'callback' => 'bre_get_posts',
167167
'args' => array(
168168
'per_page' => array(
169169
'description' => 'Maxiumum number of items to show per page.',

includes/get_posts_tax.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
* @since 0.1.8
88
*/
99

10-
function bwe_build_custom_tax_endpoint() {
11-
if( bwe_get_custom_tax() ){
10+
function bre_build_custom_tax_endpoint() {
11+
if( bre_get_custom_tax() ){
1212

1313
// store the custom tax collections we have
14-
$custom_tax_collection = bwe_get_custom_tax();
14+
$custom_tax_collection = bre_get_custom_tax();
1515

1616
foreach ($custom_tax_collection as $key => $tax) {
1717

@@ -107,7 +107,7 @@ function bwe_build_custom_tax_endpoint() {
107107
* return acf fields if they exist
108108
*
109109
*/
110-
$bre_tax_post->acf = bwe_get_acf();
110+
$bre_tax_post->acf = bre_get_acf();
111111

112112
/*
113113
*
@@ -217,4 +217,4 @@ function bwe_build_custom_tax_endpoint() {
217217
* Add action for custom tax endpoint building
218218
*
219219
*/
220-
add_action( 'rest_api_init', 'bwe_build_custom_tax_endpoint' );
220+
add_action( 'rest_api_init', 'bre_build_custom_tax_endpoint' );

includes/get_search.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @since 0.0.1
88
*/
99

10-
function bwe_get_search( WP_REST_Request $request ) {
10+
function bre_get_search( WP_REST_Request $request ) {
1111

1212
// check for params
1313
$posts_per_page = $request['per_page']?: '10';
@@ -108,7 +108,7 @@ function bwe_get_search( WP_REST_Request $request ) {
108108
* return acf fields if they exist
109109
*
110110
*/
111-
$bre_post->acf = bwe_get_acf();
111+
$bre_post->acf = bre_get_acf();
112112

113113
/*
114114
*
@@ -155,7 +155,7 @@ function bwe_get_search( WP_REST_Request $request ) {
155155
add_action( 'rest_api_init', function () {
156156
register_rest_route( 'better-rest-endpoints/v1', '/search/', array(
157157
'methods' => 'GET',
158-
'callback' => 'bwe_get_search',
158+
'callback' => 'bre_get_search',
159159
'args' => array(
160160
'per_page' => array(
161161
'description' => 'Maxiumum number of items to show per page.',

includes/get_tax.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @since 0.1.8
88
*/
99

10-
function bwe_get_custom_tax() {
10+
function bre_get_custom_tax() {
1111
$bre_custom_tax = array();
1212

1313
foreach ( get_taxonomies() as $custom_tax ){

includes/get_taxonomies.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @since 0.2.0
88
*/
99

10-
function bwe_get_taxonomies() {
10+
function bre_get_taxonomies() {
1111

1212
// set an empty array
1313
$bre_taxonomies = array();
@@ -47,4 +47,4 @@ function bwe_get_taxonomies() {
4747
* Add action for taxonomies
4848
*
4949
*/
50-
add_action( 'rest_api_init', 'bwe_get_taxonomies' );
50+
add_action( 'rest_api_init', 'bre_get_taxonomies' );

includes/wp_nav_menus.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @since 0.1.1
88
*/
99

10-
function bwe_get_menus() {
10+
function bre_get_menus() {
1111

1212
// get registered menus
1313
$menus = get_terms('nav_menu');
@@ -62,4 +62,4 @@ function bwe_get_menus() {
6262
* Add action for cpt endpoint building
6363
*
6464
*/
65-
add_action( 'rest_api_init', 'bwe_get_menus' );
65+
add_action( 'rest_api_init', 'bre_get_menus' );

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "better-rest-endpoints",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "Serves up slimmer WordPress Rest API endpoints.",
55
"main": "index.js",
66
"scripts": {

readme.txt

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Contributors: factor1, erwstout
66
Tags: rest, api, endpoints, acf, json
77
Requires at least: 4.7.1
88
Tested up to: 4.9.2
9-
Stable Tag: 2.8.17
9+
Stable Tag: 1.0.2
1010
License: GNU Version 3 or Any Later Version
1111

1212
A WordPress plugin that serves up slimmer WP Rest API endpoints.
@@ -42,5 +42,10 @@ apps endpoints to use Better Rest Endpoints.
4242

4343
== Changelog ==
4444

45+
= 1.0.2, January 1, 2018 =
46+
* Fix: static instance warning
47+
* Fix: failure of ACF function by including admin plugin.php
48+
* Update: all functions named bwe_ to bre_
49+
4550
= 1.0.1, January 1, 2018 =
4651
* Prep: Update files for release on WP Repo.

0 commit comments

Comments
 (0)