ACF to REST API - Version 3.2.0

Version Description

moving class-acf-to-rest-api-settings.php to shared/include/admin/classes adding donation notice update tested up

Download this release

Release Info

Developer airesvsg
Plugin Icon 128x128 ACF to REST API
Version 3.2.0
Comparing to
See all releases

Code changes from version 3.1.0 to 3.2.0

class-acf-to-rest-api.php CHANGED
@@ -4,7 +4,7 @@
4
  * Description: Exposes Advanced Custom Fields Endpoints in the WordPress REST API
5
  * Author: Aires Gonçalves
6
  * Author URI: http://github.com/airesvsg
7
- * Version: 3.1.0
8
  * Plugin URI: http://github.com/airesvsg/acf-to-rest-api
9
  */
10
 
@@ -16,7 +16,7 @@ if ( ! class_exists( 'ACF_To_REST_API' ) ) {
16
 
17
  class ACF_To_REST_API {
18
 
19
- const VERSION = '3.1.0';
20
 
21
  private static $old_request_version = 2;
22
  private static $default_request_version = 3;
@@ -48,7 +48,8 @@ if ( ! class_exists( 'ACF_To_REST_API' ) ) {
48
 
49
  if ( self::is_plugin_active( 'all' ) ) {
50
  if ( is_admin() ) {
51
- require_once dirname( __FILE__ ) . '/shared/lib/class-acf-to-rest-api-settings.php';
 
52
  }
53
  self::instance()->includes();
54
  }
@@ -76,7 +77,6 @@ if ( ! class_exists( 'ACF_To_REST_API' ) ) {
76
  } else {
77
  add_action( 'admin_notices', array( __CLASS__, 'missing_notice' ) );
78
  }
79
-
80
  }
81
 
82
  public static function load_plugin_textdomain() {
4
  * Description: Exposes Advanced Custom Fields Endpoints in the WordPress REST API
5
  * Author: Aires Gonçalves
6
  * Author URI: http://github.com/airesvsg
7
+ * Version: 3.2.0
8
  * Plugin URI: http://github.com/airesvsg/acf-to-rest-api
9
  */
10
 
16
 
17
  class ACF_To_REST_API {
18
 
19
+ const VERSION = '3.2.0';
20
 
21
  private static $old_request_version = 2;
22
  private static $default_request_version = 3;
48
 
49
  if ( self::is_plugin_active( 'all' ) ) {
50
  if ( is_admin() ) {
51
+ require_once dirname( __FILE__ ) . '/shared/includes/admin/classes/class-acf-to-rest-api-settings.php';
52
+ require_once dirname( __FILE__ ) . '/shared/includes/admin/classes/class-acf-to-rest-api-donation.php';
53
  }
54
  self::instance()->includes();
55
  }
77
  } else {
78
  add_action( 'admin_notices', array( __CLASS__, 'missing_notice' ) );
79
  }
 
80
  }
81
 
82
  public static function load_plugin_textdomain() {
composer.json CHANGED
@@ -2,10 +2,10 @@
2
  "name": "airesvsg/acf-to-rest-api",
3
  "description": "Exposes Advanced Custom Fields Endpoints in the WordPress REST API",
4
  "type": "wordpress-plugin",
5
- "version": "3.1.0",
6
  "keywords": ["wordpress", "wp", "rest-api", "acf", "wp-api", "json", "wordpres-plugin", "fields"],
7
  "homepage": "https://github.com/airesvsg/acf-to-rest-api",
8
- "license": "GPLv2.0+",
9
  "authors": [
10
  {
11
  "name": "Aires Gonçalves",
2
  "name": "airesvsg/acf-to-rest-api",
3
  "description": "Exposes Advanced Custom Fields Endpoints in the WordPress REST API",
4
  "type": "wordpress-plugin",
5
+ "version": "3.2.0",
6
  "keywords": ["wordpress", "wp", "rest-api", "acf", "wp-api", "json", "wordpres-plugin", "fields"],
7
  "homepage": "https://github.com/airesvsg/acf-to-rest-api",
8
+ "license": "GPL-2.0-only",
9
  "authors": [
10
  {
11
  "name": "Aires Gonçalves",
readme.md CHANGED
@@ -12,6 +12,7 @@ https://wordpress.org/plugins/acf-to-rest-api/
12
  - [Field Settings ![new](http://airesgoncalves.com.br/screenshot/acf-to-rest-api/readme/new-v3.1.png)](#field-settings)
13
  - [Editing the Fields](#editing-the-fields)
14
  - [Examples](#examples)
 
15
  - [Cache](#cache)
16
 
17
  Installation
@@ -176,8 +177,23 @@ To-do list ![new](http://airesgoncalves.com.br/screenshot/acf-to-rest-api/readme
176
 
177
  https://github.com/airesvsg/to-do-list-acf-to-rest-api
178
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  Cache
180
  ====
181
  Enable caching for WordPress REST API and increase speed of your application.
182
 
183
- https://github.com/airesvsg/wp-rest-api-cache
12
  - [Field Settings ![new](http://airesgoncalves.com.br/screenshot/acf-to-rest-api/readme/new-v3.1.png)](#field-settings)
13
  - [Editing the Fields](#editing-the-fields)
14
  - [Examples](#examples)
15
+ - [Get ACF Fields Recursively ![new](http://airesgoncalves.com.br/screenshot/acf-to-rest-api/readme/new-v3.1.png)](#get-acf-fields-recursively)
16
  - [Cache](#cache)
17
 
18
  Installation
177
 
178
  https://github.com/airesvsg/to-do-list-acf-to-rest-api
179
 
180
+
181
+ Get ACF Fields Recursively![new](http://airesgoncalves.com.br/screenshot/acf-to-rest-api/readme/new-v3.1.png)
182
+ ====
183
+ https://github.com/airesvsg/acf-to-rest-api-recursive
184
+
185
+ More details:
186
+
187
+ - Issues
188
+ - https://github.com/airesvsg/acf-to-rest-api/issues/109
189
+ - https://github.com/airesvsg/acf-to-rest-api/issues/223
190
+ - https://github.com/airesvsg/acf-to-rest-api/issues/9
191
+
192
+ - Pull Request
193
+ - https://github.com/airesvsg/acf-to-rest-api/pull/95
194
+
195
  Cache
196
  ====
197
  Enable caching for WordPress REST API and increase speed of your application.
198
 
199
+ https://github.com/airesvsg/wp-rest-api-cache
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === ACF to REST API ===
2
  Contributors: airesvsg
3
- Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=airesvsg%40gmail%2ecom&lc=BR&item_name=Aires%20Goncalves&no_note=0&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest
4
  Tags: acf, api, rest, wp-api, wp-rest-api, json, wp, wordpress, wp-rest-api, wordpress-rest-api
5
  Requires at least: 4.6
6
- Tested up to: 4.9.1
7
- Stable tag: 3.1.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -13,7 +13,7 @@ Exposes Advanced Custom Fields Endpoints in the WordPress REST API
13
  == Description ==
14
  Exposes [Advanced Custom Fields](https://wordpress.org/plugins/advanced-custom-fields/) Endpoints in the [WordPress REST API](https://developer.wordpress.org/rest-api/)
15
 
16
- **See details on GitHub:** http://github.com/airesvsg/acf-to-rest-api
17
 
18
  == Installation ==
19
  1. Copy the `acf-to-rest-api` folder into your `wp-content/plugins` folder
@@ -21,6 +21,11 @@ Exposes [Advanced Custom Fields](https://wordpress.org/plugins/advanced-custom-f
21
 
22
  == Changelog ==
23
 
 
 
 
 
 
24
  = 3.1.0 =
25
  fix indentation
26
  removing unnecessary code
1
  === ACF to REST API ===
2
  Contributors: airesvsg
3
+ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=E5M7HDWNPFVF4&lc=BR&item_name=Aires%20Goncalves&no_note=0&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest
4
  Tags: acf, api, rest, wp-api, wp-rest-api, json, wp, wordpress, wp-rest-api, wordpress-rest-api
5
  Requires at least: 4.6
6
+ Tested up to: 5.3.2
7
+ Stable tag: 3.2.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
13
  == Description ==
14
  Exposes [Advanced Custom Fields](https://wordpress.org/plugins/advanced-custom-fields/) Endpoints in the [WordPress REST API](https://developer.wordpress.org/rest-api/)
15
 
16
+ **See details on GitHub:** [https://github.com/airesvsg/acf-to-rest-api/](https://github.com/airesvsg/acf-to-rest-api/)
17
 
18
  == Installation ==
19
  1. Copy the `acf-to-rest-api` folder into your `wp-content/plugins` folder
21
 
22
  == Changelog ==
23
 
24
+ = 3.2.0 =
25
+ moving class-acf-to-rest-api-settings.php to shared/include/admin/classes
26
+ adding donation notice
27
+ update tested up
28
+
29
  = 3.1.0 =
30
  fix indentation
31
  removing unnecessary code
shared/assets/css/acf-to-rest-api-donation.css ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .acf-to-rest-api-donation-notice {
2
+ background: #fff;
3
+ border: 0;
4
+ border-radius: 4px;
5
+ color: #cd331f;
6
+ padding: 1px 5px;
7
+ position: relative;
8
+ }
9
+
10
+ .acf-to-rest-api-donation-button-notice-dismiss:focus {
11
+ box-shadow: none;
12
+ }
13
+
14
+ .acf-to-rest-api-donation-button-notice-dismiss:hover {
15
+ opacity: .5;
16
+ }
17
+
18
+ .acf-to-rest-api-donation-button-notice-dismiss:before {
19
+ color: #FF8676;
20
+ }
21
+
22
+ .acf-to-rest-api-donation-plugin-name,
23
+ .acf-to-rest-api-donation-button {
24
+ background: #fff;
25
+ border: 1px solid #cd331f;
26
+ border-radius: 4px;
27
+ color: #cd331f;
28
+ margin-right: 5px;
29
+ padding: 2px 15px;
30
+ text-decoration: none;
31
+ }
32
+
33
+ .acf-to-rest-api-donation-plugin-name,
34
+ .acf-to-rest-api-donation-button:hover {
35
+ background: #cd331f;
36
+ color: #fff;
37
+ }
38
+
39
+ .acf-to-rest-api-donation-plugin-name {
40
+ font-weight: bold;
41
+ }
42
+
43
+ .acf-to-rest-api-donation-button:hover .dashicons-heart {
44
+ animation: .8s infinite heart_beat;
45
+ }
46
+
47
+ .acf-to-rest-api-donation-button:focus {
48
+ box-shadow: none;
49
+ }
50
+
51
+ @keyframes heart_beat {
52
+ 0% {
53
+ transform: scale(1);
54
+ }
55
+ 25% {
56
+ transform: scale(1.1);
57
+ }
58
+ 40% {
59
+ transform: scale(1);
60
+ }
61
+ 60% {
62
+ transform: scale(1.1);
63
+ }
64
+ 100% {
65
+ transform: scale(1);
66
+ }
67
+ }
shared/assets/js/acf-to-rest-api-donation.js ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ ( function( $ ) {
2
+ $( '.acf-to-rest-api-donation-button-notice-dismiss' ).click( function( e ) {
3
+ e.preventDefault();
4
+ $( this ).closest('.acf-to-rest-api-donation-notice').slideUp();
5
+ $.post( acf_to_rest_api_donation.ajax_url, {
6
+ action: 'acf_to_rest_api_dismiss_notice',
7
+ nonce: acf_to_rest_api_donation.nonce
8
+ } );
9
+ } );
10
+ } )( jQuery );
shared/includes/admin/classes/class-acf-to-rest-api-donation.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ if ( ! class_exists( 'ACF_To_REST_API_Donation' ) ) {
8
+
9
+ class ACF_To_REST_API_Donation {
10
+
11
+ const DONATION_URL = 'https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=E5M7HDWNPFVF4&lc=BR&item_name=Aires%20Goncalves&no_note=0&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest';
12
+
13
+ private static $version_meta = 'acf_to_rest_api_donation_version';
14
+
15
+ private static $action_nonce = 'acf-to-rest-api-ajax-nonce';
16
+
17
+ public static function init() {
18
+ self::hooks();
19
+ }
20
+
21
+ private static function hooks() {
22
+ if ( self::show() ) {
23
+ add_action( 'admin_notices', array( __CLASS__, 'donation_notice' ) );
24
+ add_action( 'admin_enqueue_scripts', array( __CLASS__, 'admin_enqueue_scripts' ) );
25
+ add_action( 'wp_ajax_acf_to_rest_api_dismiss_notice', array( __CLASS__, 'dismiss_notice' ) );
26
+ }
27
+ add_action( 'admin_enqueue_scripts', array( __CLASS__, 'admin_enqueue_styles' ) );
28
+ }
29
+
30
+ public static function admin_enqueue_styles() {
31
+ wp_enqueue_style( 'acf_to_rest_api_donation', plugins_url( 'assets/css/acf-to-rest-api-donation.css', dirname( __FILE__ ) . '/../../../../' ), array(), ACF_To_REST_API::VERSION );
32
+ }
33
+
34
+ public static function admin_enqueue_scripts() {
35
+ wp_enqueue_script( 'acf_to_rest_api_donation', plugins_url( 'assets/js/acf-to-rest-api-donation.js', dirname( __FILE__ ) . '/../../../../' ), array( 'jquery' ), ACF_To_REST_API::VERSION, true );
36
+ wp_localize_script( 'acf_to_rest_api_donation', 'acf_to_rest_api_donation', array(
37
+ 'ajax_url' => admin_url( 'admin-ajax.php' ),
38
+ 'nonce' => wp_create_nonce( self::$action_nonce ),
39
+ ) );
40
+ }
41
+
42
+ public static function donation_notice() {
43
+ include dirname( __FILE__ ) . '/../views/html-notice-donation.php';
44
+ }
45
+
46
+ public static function dismiss_notice() {
47
+ if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], self::$action_nonce ) ) {
48
+ wp_die();
49
+ }
50
+
51
+ $user_id = get_current_user_id();
52
+ if ( $user_id ) {
53
+ update_user_meta( $user_id, self::$version_meta, ACF_To_REST_API::VERSION );
54
+ }
55
+
56
+ exit;
57
+ }
58
+
59
+ private static function show() {
60
+ $version = null;
61
+ $user_id = get_current_user_id();
62
+
63
+ if ( $user_id ) {
64
+ $version = get_user_meta( $user_id, self::$version_meta, true );
65
+ }
66
+
67
+ return is_admin() && $version !== ACF_To_REST_API::VERSION;
68
+ }
69
+
70
+ }
71
+
72
+ add_action( 'admin_init', array( 'ACF_To_REST_API_Donation', 'init' ) );
73
+
74
+ }
shared/{lib → includes/admin/classes}/class-acf-to-rest-api-settings.php RENAMED
@@ -8,7 +8,6 @@ if ( ! class_exists( 'ACF_To_REST_API_Settings' ) ) {
8
 
9
  class ACF_To_REST_API_Settings {
10
 
11
- private static $donation_url = 'https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=airesvsg%40gmail%2ecom&lc=BR&item_name=Aires%20Goncalves&no_note=0&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest';
12
  private static $github_url = 'http://github.com/airesvsg/acf-to-rest-api';
13
 
14
  public static function init() {
@@ -28,13 +27,13 @@ if ( ! class_exists( 'ACF_To_REST_API_Settings' ) ) {
28
  }
29
 
30
  public static function add_settings_section() {
31
- include_once dirname( __FILE__ ) . '/../includes/admin/views/html-settings-section.php';
32
  }
33
 
34
  public static function add_settings_field( $args ) {
35
  $request_version = ACF_To_REST_API::handle_request_version();
36
 
37
- include_once dirname( __FILE__ ) . '/../includes/admin/views/html-settings-field.php';
38
  }
39
 
40
  public static function plugin_action_links( $actions ) {
@@ -54,7 +53,7 @@ if ( ! class_exists( 'ACF_To_REST_API_Settings' ) ) {
54
  public static function plugin_row_meta( $plugin_meta, $plugin_file, $plugin_data ) {
55
  if ( isset( $plugin_data['slug'] ) && 'acf-to-rest-api' == $plugin_data['slug'] ) {
56
  $plugin_meta['acf-to-rest-api-github'] = sprintf( '<a href="%s" target="_blank">%s</a>', self::$github_url, esc_html__( 'Fork me on GitHub' ) );
57
- $plugin_meta['acf_to_rest_api_donation'] = sprintf( '<a href="%s" target="_blank">%s</a>', self::$donation_url, esc_html__( 'Make a donation', 'acf-to-rest-api' ) );
58
  }
59
 
60
  return $plugin_meta;
8
 
9
  class ACF_To_REST_API_Settings {
10
 
 
11
  private static $github_url = 'http://github.com/airesvsg/acf-to-rest-api';
12
 
13
  public static function init() {
27
  }
28
 
29
  public static function add_settings_section() {
30
+ include_once dirname( __FILE__ ) . '/../views/html-settings-section.php';
31
  }
32
 
33
  public static function add_settings_field( $args ) {
34
  $request_version = ACF_To_REST_API::handle_request_version();
35
 
36
+ include_once dirname( __FILE__ ) . '/../views/html-settings-field.php';
37
  }
38
 
39
  public static function plugin_action_links( $actions ) {
53
  public static function plugin_row_meta( $plugin_meta, $plugin_file, $plugin_data ) {
54
  if ( isset( $plugin_data['slug'] ) && 'acf-to-rest-api' == $plugin_data['slug'] ) {
55
  $plugin_meta['acf-to-rest-api-github'] = sprintf( '<a href="%s" target="_blank">%s</a>', self::$github_url, esc_html__( 'Fork me on GitHub' ) );
56
+ $plugin_meta['acf_to_rest_api_donation'] = sprintf( '<a href="%s" target="_blank" class="acf-to-rest-api-donation-button"><span class="dashicons dashicons-heart"></span> %s</a>', ACF_To_REST_API_Donation::DONATION_URL, esc_html__( 'Make a donation', 'acf-to-rest-api' ) );
57
  }
58
 
59
  return $plugin_meta;
shared/includes/admin/views/html-notice-donation.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ ?>
8
+
9
+ <div class="notice acf-to-rest-api-donation-notice">
10
+ <p><span class="acf-to-rest-api-donation-plugin-name">{ <?php esc_html_e( 'ACF to REST-API', 'act-to-rest-api' ); ?> }</span> <a href="<?php echo esc_url( self::DONATION_URL ); ?>" target="_blank" class="acf-to-rest-api-donation-button"> <span class="dashicons dashicons-heart"></span> <?php echo esc_html_e( 'Make a donation', 'acf-to-rest-api' ); ?></a></p>
11
+ <button type="button" class="notice-dismiss acf-to-rest-api-donation-button-notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button>
12
+ </div>
shared/includes/admin/views/html-settings-field.php CHANGED
@@ -7,10 +7,10 @@ if ( ! defined( 'ABSPATH' ) ) {
7
  ?>
8
 
9
  <div id="acf-to-rest-api-settings">
10
- <code><?php echo esc_url( site_url( 'wp-json/acf/' ) ); ?></code>
11
  <select name="acf_to_rest_api_settings[request_version]">
12
  <option value="2"<?php selected( 2, $request_version ); ?>>v2</option>
13
  <option value="3"<?php selected( 3, $request_version ); ?>>v3</option>
14
  </select>
15
- <p><a href="<?php echo esc_url( self::$donation_url ); ?>" target="_blank"><?php esc_html_e( 'Click here', 'acf-to-rest-api' ); ?></a> <?php esc_html_e( 'to make a donation and help to improve the plugin.', 'acf-to-rest-api' ); ?></p>
16
  </div>
7
  ?>
8
 
9
  <div id="acf-to-rest-api-settings">
10
+ <code><?php echo esc_url( home_url( 'wp-json/acf/' ) ); ?></code>
11
  <select name="acf_to_rest_api_settings[request_version]">
12
  <option value="2"<?php selected( 2, $request_version ); ?>>v2</option>
13
  <option value="3"<?php selected( 3, $request_version ); ?>>v3</option>
14
  </select>
15
+ <p><a href="<?php echo esc_url( ACF_To_REST_API_Donation::DONATION_URL ); ?>" target="_blank" class="acf-to-rest-api-donation-button"><span class="dashicons dashicons-heart"></span> <?php esc_html_e( 'Make a donation', 'acf-to-rest-api' ); ?></a> <?php esc_html_e( 'and help to improve the ACF to REST-API plugin.', 'acf-to-rest-api' ); ?></p>
16
  </div>