Kadence Blocks – Gutenberg Page Builder Toolkit - Version 1.9.7

Version Description

  • Fix: Possible update issue.
Download this release

Release Info

Developer britner
Plugin Icon 128x128 Kadence Blocks – Gutenberg Page Builder Toolkit
Version 1.9.7
Comparing to
See all releases

Code changes from version 1.9.6 to 1.9.7

dist/class-mailerlite-form-rest-api.php ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * REST API Mailchimp controller customized for Kadence Form
4
+ */
5
+
6
+ if ( ! defined( 'ABSPATH' ) ) {
7
+ exit;
8
+ }
9
+ /**
10
+ * REST API Products controller class.
11
+ *
12
+ * @package WooCommerce/API
13
+ */
14
+ class Kadence_MailerLite_REST_Controller extends WP_REST_Controller {
15
+
16
+ /**
17
+ * api key property name.
18
+ */
19
+ const PROP_API_KEY = 'apikey';
20
+
21
+ /**
22
+ * Include property name.
23
+ */
24
+ const PROP_END_POINT = 'endpoint';
25
+
26
+ /**
27
+ * Per page property name.
28
+ */
29
+ const PROP_QUERY_ARGS = 'queryargs';
30
+
31
+
32
+ /**
33
+ * Constructor.
34
+ */
35
+ public function __construct() {
36
+ $this->namespace = 'kb-mailerlite/v1';
37
+ $this->rest_base = 'get';
38
+ }
39
+
40
+ /**
41
+ * Registers the routes for the objects of the controller.
42
+ *
43
+ * @see register_rest_route()
44
+ */
45
+ public function register_routes() {
46
+ register_rest_route(
47
+ $this->namespace,
48
+ '/' . $this->rest_base,
49
+ array(
50
+ array(
51
+ 'methods' => WP_REST_Server::READABLE,
52
+ 'callback' => array( $this, 'get_items' ),
53
+ 'permission_callback' => array( $this, 'get_items_permission_check' ),
54
+ 'args' => $this->get_collection_params(),
55
+ ),
56
+ )
57
+ );
58
+ }
59
+ /**
60
+ * Checks if a given request has access to search content.
61
+ *
62
+ *
63
+ * @param WP_REST_Request $request Full details about the request.
64
+ * @return true|WP_Error True if the request has search access, WP_Error object otherwise.
65
+ */
66
+ public function get_items_permission_check( $request ) {
67
+ return current_user_can( 'edit_posts' );
68
+ }
69
+
70
+ /**
71
+ * Retrieves a collection of objects.
72
+ *
73
+ * @param WP_REST_Request $request Full details about the request.
74
+ * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
75
+ */
76
+ public function get_items( $request ) {
77
+ $api_key = $request->get_param( self::PROP_API_KEY );
78
+ $end_point = $request->get_param( self::PROP_END_POINT );
79
+ $query_args = $request->get_param( self::PROP_QUERY_ARGS );
80
+
81
+ if ( empty( $api_key ) ) {
82
+ return array();
83
+ }
84
+ $base_url = 'https://api.mailerlite.com/api/v2/';
85
+ $request_args = array(
86
+ 'headers' => array(
87
+ 'X-MailerLite-ApiKey' => $api_key,
88
+ ),
89
+ );
90
+ if ( $query_args && is_array( $query_args ) ) {
91
+ $args = array();
92
+ foreach ( $query_args as $key => $value ) {
93
+ $value_parts = explode( '=', $value );
94
+ $args[$value_parts[0]] = $value_parts[1];
95
+ }
96
+ $url = add_query_arg( $args, $base_url . $end_point );
97
+ } else {
98
+ $url = $base_url . $end_point;
99
+ }
100
+ $response = wp_remote_get( $url, $request_args );
101
+
102
+ if ( is_wp_error( $response ) || 200 != (int) wp_remote_retrieve_response_code( $response ) ) {
103
+ //error_log( 'response failed' );
104
+ return array();
105
+ }
106
+
107
+ $body = json_decode( wp_remote_retrieve_body( $response ), true );
108
+
109
+ if ( ! is_array( $body ) ) {
110
+ //error_log( 'no content' );
111
+ return array();
112
+ }
113
+ // $groups = array();
114
+ // if ( 'groups' === $end_point ) {
115
+ // foreach ( $body as $group ) {
116
+ // $groups[] = array( 'id' => $group['id'], 'title' => $group['name'] );
117
+ // }
118
+ // return $groups;
119
+ // }
120
+
121
+ return $body;
122
+
123
+ }
124
+ /**
125
+ * Retrieves the query params for the search results collection.
126
+ *
127
+ * @return array Collection parameters.
128
+ */
129
+ public function get_collection_params() {
130
+ $query_params = parent::get_collection_params();
131
+
132
+ $query_params[ self::PROP_API_KEY ] = array(
133
+ 'description' => __( 'The API Key for mailchimp account.', 'kadence-blocks-pro' ),
134
+ 'type' => 'string',
135
+ );
136
+
137
+ $query_params[ self::PROP_END_POINT ] = array(
138
+ 'description' => __( 'Actionable endpoint for api call.', 'kadence-blocks-pro' ),
139
+ 'type' => 'string',
140
+ );
141
+
142
+ $query_params[ self::PROP_QUERY_ARGS ] = array(
143
+ 'description' => __( 'Query Args for url.', 'kadence-blocks-pro' ),
144
+ 'type' => 'array',
145
+ );
146
+
147
+ return $query_params;
148
+ }
149
+ }
kadence-blocks.php CHANGED
@@ -5,7 +5,7 @@
5
  * Description: Advanced Page Building Blocks for Gutenberg. Create custom column layouts, backgrounds, dual buttons, icons etc.
6
  * Author: Kadence WP
7
  * Author URI: https://www.kadencewp.com
8
- * Version: 1.9.6
9
  * Text Domain: kadence-blocks
10
  * License: GPL2+
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
@@ -20,7 +20,7 @@ if ( ! defined( 'ABSPATH' ) ) {
20
 
21
  define( 'KADENCE_BLOCKS_PATH', realpath( plugin_dir_path( __FILE__ ) ) . DIRECTORY_SEPARATOR );
22
  define( 'KADENCE_BLOCKS_URL', plugin_dir_url( __FILE__ ) );
23
- define( 'KADENCE_BLOCKS_VERSION', '1.9.6' );
24
 
25
  /**
26
  * Add a check before redirecting
5
  * Description: Advanced Page Building Blocks for Gutenberg. Create custom column layouts, backgrounds, dual buttons, icons etc.
6
  * Author: Kadence WP
7
  * Author URI: https://www.kadencewp.com
8
+ * Version: 1.9.7
9
  * Text Domain: kadence-blocks
10
  * License: GPL2+
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
20
 
21
  define( 'KADENCE_BLOCKS_PATH', realpath( plugin_dir_path( __FILE__ ) ) . DIRECTORY_SEPARATOR );
22
  define( 'KADENCE_BLOCKS_URL', plugin_dir_url( __FILE__ ) );
23
+ define( 'KADENCE_BLOCKS_VERSION', '1.9.7' );
24
 
25
  /**
26
  * Add a check before redirecting
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: gutenberg, blocks, page builder, google fonts, dual buttons, svg icons, ed
4
  Donate link: https://www.kadencewp.com/about-us/
5
  Requires at least: 5.2
6
  Tested up to: 5.5.3
7
- Stable tag: 1.9.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -87,6 +87,9 @@ Install the plugin into the `/wp-content/plugins/` folder, and activate it.
87
 
88
  == Changelog ==
89
 
 
 
 
90
  = 1.9.6 =
91
  * Add: MailerLite option to Kadence Blocks.
92
  * Update: Initial Update to Blocks settings page.
4
  Donate link: https://www.kadencewp.com/about-us/
5
  Requires at least: 5.2
6
  Tested up to: 5.5.3
7
+ Stable tag: 1.9.7
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
87
 
88
  == Changelog ==
89
 
90
+ = 1.9.7 =
91
+ * Fix: Possible update issue.
92
+
93
  = 1.9.6 =
94
  * Add: MailerLite option to Kadence Blocks.
95
  * Update: Initial Update to Blocks settings page.