Skip to content

Commit 8fc4425

Browse files
Merge branch 'release/8.0.13'
2 parents c7065b7 + 27bb47f commit 8fc4425

File tree

5 files changed

+50
-21
lines changed

5 files changed

+50
-21
lines changed

notification.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Description: Customisable email and webhook notifications with powerful developer friendly API for custom triggers and notifications. Send alerts easily.
55
* Author: BracketSpace
66
* Author URI: https://bracketspace.com
7-
* Version: 8.0.12
7+
* Version: 8.0.13
88
* License: GPL3
99
* Text Domain: notification
1010
* Domain Path: /languages

readme.txt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: notification, bracketspace, Kubitomakita, tomaszadamowicz, insejn,
33
Tags: notification, notify, alert, email, mail, webhook, API, developer, framework
44
Requires at least: 4.9
55
Tested up to: 5.8
6-
Stable tag: 8.0.12
6+
Stable tag: 8.0.13
77
Requires PHP: 7.0
88
License: GPLv3
99
License URI: http://www.gnu.org/licenses/gpl-3.0.html
@@ -302,13 +302,19 @@ Yes! We're offering a [custom plugin development](https://bracketspace.com/custo
302302

303303
== Changelog ==
304304

305+
= 8.0.13 =
306+
307+
* [Fixed] Regression with REST API check.
308+
* [Changed] `repeater_api` internal runtime component to `api`.
309+
* [Added] `get_endpoint` method to the API class.
310+
305311
= 8.0.12 =
306312

307-
* [Changed] Logic of assigning property name is moved to Abstract Merge Tag Class
308-
* [Added] Property names to Term Merge Tags
309-
* [Added] 6h cache expire to the user queries
310-
* [Added] Email / Merge tag recipient now can also be separated with semicolon
311-
* [Added] Endpoint to check whether the REST api is enabled
313+
* [Changed] Logic of assigning property name is moved to Abstract Merge Tag Class.
314+
* [Added] Property names to Term Merge Tags.
315+
* [Added] 6h cache expire to the user queries.
316+
* [Added] Email / Merge tag recipient now can also be separated with semicolon.
317+
* [Added] Endpoint to check whether the REST api is enabled.
312318

313319
= 8.0.11 =
314320

src/Admin/CheckRestApi.php

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,31 @@ class CheckRestApi {
2222
* @return void
2323
*/
2424
public function test_rest_api() {
25-
$response = wp_remote_get( get_rest_url( null, 'notification/v1/check/' ) );
26-
$message = json_decode( wp_remote_retrieve_body( $response ), true );
27-
28-
$is_available = false;
29-
$is_edit = false;
30-
31-
if ( array_key_exists( 'data', $message ) ) {
32-
$is_available = 'RestApi' === $message['data'];
33-
}
34-
25+
$is_edit = false;
3526
$current_screen = get_current_screen();
3627

3728
if ( $current_screen instanceof \WP_Screen ) {
3829
$is_edit = 'post' === $current_screen->base && 'notification' === $current_screen->post_type;
3930
}
4031

41-
if ( ! $is_available && $is_edit ) {
42-
$class = 'notice notice-error';
43-
printf( '<div class="%1$s"><p>%2$s</p></div>', esc_attr( $class ), 'The Notification plugin requires enabled REST API endpoint: notification/v1/. Please ensure your WP REST API works correctly.' );
32+
if ( ! $is_edit ) {
33+
return;
34+
}
35+
36+
$response = wp_remote_get( get_rest_url(
37+
null,
38+
\Notification::component( 'api' )->get_endpoint( 'check' )
39+
) );
40+
41+
$message = json_decode( wp_remote_retrieve_body( $response ), true );
42+
43+
$is_available = false;
44+
45+
if ( ! is_array( $message ) || ! array_key_exists( 'data', $message ) || 'RestApi' !== $message['data'] ) {
46+
printf(
47+
'<div class="notice notice-error"><p>%1$s</p></div>',
48+
'The Notification plugin requires enabled REST API endpoint: notification/v1/. Please ensure your WP REST API works correctly.'
49+
);
4450
}
4551
}
4652

src/Api/Api.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,21 @@ public function rest_api_init() {
9090
}
9191

9292
}
93+
94+
/**
95+
* Gets API endpoint
96+
*
97+
* @since 8.0.13
98+
* @param string $endpoint Endopint name.
99+
* @return string
100+
*/
101+
public function get_endpoint( $endpoint ) {
102+
103+
return sprintf(
104+
'%s/%s/',
105+
$this->namespace,
106+
untrailingslashit( $endpoint )
107+
);
108+
109+
}
93110
}

src/Runtime.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public function singletons() {
225225
$this->add_component( 'integration_wp_emails', new Integration\WordPressEmails() );
226226
$this->add_component( 'integration_2fa', new Integration\TwoFactor() );
227227

228-
$this->add_component( 'repeater_api', new Api\Api() );
228+
$this->add_component( 'api', new Api\Api() );
229229
}
230230

231231
/**

0 commit comments

Comments
 (0)