-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
429b489
commit 76d64aa
Showing
13 changed files
with
109 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* Description: Puts all ACF fields from posts, pages, custom post types, attachments and taxonomy terms, into the WP-API output under the 'acf' key | ||
* Author: Chris Hutchinson | ||
* Author URI: http://www.chrishutchinson.me | ||
* Version: 1.3.3 | ||
* Version: 1.4.0 | ||
* Plugin URI: https://wordpress.org/plugins/acf-to-wp-api/ | ||
*/ | ||
|
||
|
@@ -25,6 +25,7 @@ class ACFtoWPAPI { | |
* | ||
* @author Chris Hutchinson <[email protected]> | ||
* | ||
* @since 1.4.0 Improved API version checking | ||
* @since 1.3.3 Compatibility fix for V2.0Beta9 | ||
* @since 1.3.0 Updated to support version 2 of the WP-API | ||
* @since 1.0.0 | ||
|
@@ -34,9 +35,9 @@ function __construct() { | |
$this->plugin = new StdClass; | ||
$this->plugin->title = 'ACF to WP API'; | ||
$this->plugin->name = 'acf-to-wp-api'; | ||
$this->plugin->folder = WP_PLUGIN_DIR . '/' . $this->plugin->name; | ||
$this->plugin->url = WP_PLUGIN_URL . '/' . str_replace(basename( __FILE__), "", plugin_basename(__FILE__)); | ||
$this->plugin->version = '1.3.3'; | ||
$this->plugin->folder = WP_PLUGIN_DIR . '/' . $this->plugin->name; | ||
$this->plugin->url = WP_PLUGIN_URL . '/' . str_replace(basename( __FILE__), "", plugin_basename(__FILE__)); | ||
$this->plugin->version = '1.4.0'; | ||
|
||
$this->apiVersion = $this->_getAPIVersion(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* Description: Puts all ACF fields from posts, pages, custom post types, attachments and taxonomy terms, into the WP-API output under the 'acf' key | ||
* Author: Chris Hutchinson | ||
* Author URI: http://www.chrishutchinson.me | ||
* Version: 1.3.2 | ||
* Version: 1.4.0 | ||
* Plugin URI: https://wordpress.org/plugins/acf-to-wp-api/ | ||
*/ | ||
|
||
|
@@ -25,6 +25,8 @@ class ACFtoWPAPI { | |
* | ||
* @author Chris Hutchinson <[email protected]> | ||
* | ||
* @since 1.4.0 Improved API version checking | ||
* @since 1.3.3 Compatibility fix for V2.0Beta9 | ||
* @since 1.3.0 Updated to support version 2 of the WP-API | ||
* @since 1.0.0 | ||
*/ | ||
|
@@ -33,11 +35,11 @@ class ACFtoWPAPI { | |
$this->plugin = new StdClass; | ||
$this->plugin->title = 'ACF to WP API'; | ||
$this->plugin->name = 'acf-to-wp-api'; | ||
$this->plugin->folder = WP_PLUGIN_DIR . '/' . $this->plugin->name; | ||
$this->plugin->url = WP_PLUGIN_URL . '/' . str_replace(basename( __FILE__), "", plugin_basename(__FILE__)); | ||
$this->plugin->version = '1.3.2'; | ||
$this->plugin->folder = WP_PLUGIN_DIR . '/' . $this->plugin->name; | ||
$this->plugin->url = WP_PLUGIN_URL . '/' . str_replace(basename( __FILE__), "", plugin_basename(__FILE__)); | ||
$this->plugin->version = '1.4.0'; | ||
|
||
$this->apiVersion = get_option( 'rest_api_plugin_version', get_option( 'json_api_plugin_version', null ) ); | ||
$this->apiVersion = $this->_getAPIVersion(); | ||
|
||
// Version One | ||
if($this->_isAPIVersionOne()) { | ||
|
@@ -106,6 +108,26 @@ class ACFtoWPAPI { | |
add_action( 'rest_api_init', array( $this, 'addACFOptionRouteV2') ); | ||
} | ||
|
||
/** | ||
* Returns the WP REST API version, assumes version 2 | ||
* if can't find any other version | ||
* | ||
* @return string The version number, set by WP REST API | ||
* | ||
* @since 1.3.2 | ||
*/ | ||
private function _getAPIVersion() { | ||
$version = 2; | ||
|
||
if ( defined('REST_API_VERSION') ) { | ||
$version = REST_API_VERSION; | ||
} else { | ||
$version = get_option( 'rest_api_plugin_version', get_option( 'json_api_plugin_version', null ) ); | ||
} | ||
|
||
return $version; | ||
} | ||
|
||
/** | ||
* Gets the version number of the WP REST API | ||
* | ||
|
@@ -122,14 +144,10 @@ class ACFtoWPAPI { | |
return false; | ||
} | ||
|
||
$baseNumber = substr( $version, 0, 1 ); | ||
$baseNumber = (int) substr( $version, 0, 1 ); | ||
|
||
if( $baseNumber === '1' ) { | ||
return 1; | ||
} | ||
|
||
if( $baseNumber === '2' ) { | ||
return 2; | ||
if( $baseNumber > 0 ) { | ||
return $baseNumber; | ||
} | ||
|
||
return false; | ||
|
@@ -540,3 +558,4 @@ class ACFtoWPAPI { | |
} | ||
|
||
$ACFtoWPAPI = new ACFtoWPAPI(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+2.56 KB
(100%)
docs/phpdoc-cache-6a/phpdoc-cache-file_ed4324bfbbef445f3dccc426ada722ee.dat
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters