Skip to content

Commit

Permalink
Merge branch 'release/8.0.12'
Browse files Browse the repository at this point in the history
  • Loading branch information
BracketSpaceWorker committed Oct 24, 2022
2 parents 89c9cd3 + ddb946f commit ee7c7f6
Show file tree
Hide file tree
Showing 71 changed files with 419 additions and 815 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ jobs:
path: ${{ steps.vars.outputs.composer-cache-path }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Set Composer version
run: composer self-update --2.2
- name: Install Composer dependencies
run: composer install --no-progress
- name: Install Composer build dependencies
Expand Down
43 changes: 43 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# How to Contribute

Thank you for taking the time to contribute to our project. We're thrilled to share our work with you and hope you'll enjoy sharing your work with us! Here's a bunch of useful information for you to start.

## Gitflow

We use [Gitflow](https://danielkummer.github.io/git-flow-cheatsheet/) on each of our projects. According to the basic assumptions of this workflow, here are the steps that you need to take when developing a new feature:

1. Create a new branch from `develop`
2. Work on this branch until your feature is finished
3. Rebase your branch onto current `develop`
4. Create a Pull Request and wait for the Code Review
5. Iterate with all needed changes and fixes
6. Enjoy your branch being merged once accepted

### Branch names

Typically, branches are named after the developed feature, i.e. `feature/Name-of-the-Feature` and so we do.

## Conventional Commits

We're following the rule of [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).

A well-formed git commit description line should always be able to complete the following sentence:
> When applied, this commit should *\<your description line here\>*
## Pull Requests

When you're done with developing your feature, you should create a [Pull Request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests) and wait for your code to be reviewed. Once all the changes and fixes will be applied, the PR will be merged into the develop branch.

### PR size

Create PRs as small as they can possibly be. Create as much of them as you need. This makes them easier to review and less likely to cause serious merge conflicts.

## Changelog

We appreciate it if you keep the changelog for every change.

Changelog usually lives in `readme.txt` files when it comes to a plugin, or it is in `CHANGELOG.md`. New sections (unreleased changes) can be marked as `8.0.12`. It will be changed to the next version number when a new version is released.

***

And that's it for the basic information you need. Thanks!
1 change: 1 addition & 0 deletions compat/register-hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
add_action( 'notification/trigger/registered', [ $this->component( 'core_binder' ), 'bind' ], 100, 1 );
add_action( 'shutdown', [ $this->component( 'core_processor' ), 'process_queue' ], 10, 0 );
add_action( 'notification_background_processing', [ $this->component( 'core_processor' ), 'handle_cron' ], 10, 2 );
add_action( 'admin_notices', [ $this->component( 'test_rest_api' ), 'test_rest_api' ], 10, 0 );
add_action( 'admin_post_notification_export', [ $this->component( 'admin_impexp' ), 'export_request' ], 10, 0 );
add_action( 'wp_ajax_notification_import_json', [ $this->component( 'admin_impexp' ), 'import_request' ], 10, 0 );
add_filter( 'notification/settings/triggers/valid_post_types', [ $this->component( 'admin_settings' ), 'filter_post_types' ], 10, 1 );
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"require": {
"php": "^7.0",
"composer-runtime-api": "^2.0",
"enshrined/svg-sanitize": "^0.14.1",
"enshrined/svg-sanitize": "^0.15.0",
"micropackage/ajax": "^1.0",
"micropackage/cache": "^1.0",
"micropackage/dochooks": "1.0.2",
Expand Down
16 changes: 8 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Description: Customisable email and webhook notifications with powerful developer friendly API for custom triggers and notifications. Send alerts easily.
* Author: BracketSpace
* Author URI: https://bracketspace.com
* Version: 8.0.11
* Version: 8.0.12
* License: GPL3
* Text Domain: notification
* Domain Path: /languages
Expand Down
100 changes: 5 additions & 95 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@ parameters:
count: 1
path: compat/register-hooks.php

-
message: "#^Parameter \\#2 \\$callback of function add_action expects callable\\(\\)\\: mixed, array\\(mixed, 'test_rest_api'\\) given\\.$#"
count: 1
path: compat/register-hooks.php

-
message: "#^Parameter \\#2 \\$callback of function add_action expects callable\\(\\)\\: mixed, array\\(mixed, 'triggers_settings…'\\) given\\.$#"
count: 1
Expand Down Expand Up @@ -1525,16 +1530,6 @@ parameters:
count: 1
path: src/Defaults/MergeTag/Post/ThumbnailUrl.php

-
message: "#^Method BracketSpace\\\\Notification\\\\Defaults\\\\MergeTag\\\\Taxonomy\\\\TaxonomyName\\:\\:__construct\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#"
count: 1
path: src/Defaults/MergeTag/Taxonomy/TaxonomyName.php

-
message: "#^Method BracketSpace\\\\Notification\\\\Defaults\\\\MergeTag\\\\Taxonomy\\\\TaxonomySlug\\:\\:__construct\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#"
count: 1
path: src/Defaults/MergeTag/Taxonomy/TaxonomySlug.php

-
message: "#^Method BracketSpace\\\\Notification\\\\Defaults\\\\MergeTag\\\\User\\\\Avatar\\:\\:__construct\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -1610,11 +1605,6 @@ parameters:
count: 1
path: src/Defaults/Recipient/Email.php

-
message: "#^Parameter \\#1 \\$str of function trim expects string, string\\|null given\\.$#"
count: 1
path: src/Defaults/Recipient/Email.php

-
message: "#^Method BracketSpace\\\\Notification\\\\Defaults\\\\Recipient\\\\Role\\:\\:parse_value\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -2140,86 +2130,6 @@ parameters:
count: 1
path: src/Defaults/Trigger/Privacy/DataExported.php

-
message: "#^Cannot access property \\$taxonomy on array\\|WP_Error\\|WP_Term\\|null\\.$#"
count: 2
path: src/Defaults/Trigger/Taxonomy/TermAdded.php

-
message: "#^Parameter \\#1 \\$term of function get_term_link expects int\\|string\\|WP_Term, array\\|WP_Error\\|WP_Term\\|null given\\.$#"
count: 1
path: src/Defaults/Trigger/Taxonomy/TermAdded.php

-
message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Taxonomy\\\\TermAdded\\:\\:\\$term_creation_datetime \\(string\\) does not accept int\\.$#"
count: 1
path: src/Defaults/Trigger/Taxonomy/TermAdded.php

-
message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Taxonomy\\\\TermTrigger\\:\\:\\$term \\(WP_Term\\) does not accept array\\|WP_Error\\|WP_Term\\|null\\.$#"
count: 1
path: src/Defaults/Trigger/Taxonomy/TermAdded.php

-
message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Taxonomy\\\\TermTrigger\\:\\:\\$term_permalink \\(string\\) does not accept string\\|WP_Error\\.$#"
count: 1
path: src/Defaults/Trigger/Taxonomy/TermAdded.php

-
message: "#^Cannot access property \\$taxonomy on array\\|WP_Error\\|WP_Term\\|null\\.$#"
count: 2
path: src/Defaults/Trigger/Taxonomy/TermDeleted.php

-
message: "#^Parameter \\#1 \\$term of function get_term_link expects int\\|string\\|WP_Term, array\\|WP_Error\\|WP_Term\\|null given\\.$#"
count: 1
path: src/Defaults/Trigger/Taxonomy/TermDeleted.php

-
message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Taxonomy\\\\TermDeleted\\:\\:\\$term_deletion_datetime \\(string\\) does not accept int\\.$#"
count: 1
path: src/Defaults/Trigger/Taxonomy/TermDeleted.php

-
message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Taxonomy\\\\TermTrigger\\:\\:\\$term \\(WP_Term\\) does not accept array\\|WP_Error\\|WP_Term\\|null\\.$#"
count: 1
path: src/Defaults/Trigger/Taxonomy/TermDeleted.php

-
message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Taxonomy\\\\TermTrigger\\:\\:\\$term_permalink \\(string\\) does not accept string\\|WP_Error\\.$#"
count: 1
path: src/Defaults/Trigger/Taxonomy/TermDeleted.php

-
message: "#^Method BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Taxonomy\\\\TermTrigger\\:\\:__construct\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#"
count: 1
path: src/Defaults/Trigger/Taxonomy/TermTrigger.php

-
message: "#^Cannot access property \\$taxonomy on array\\|WP_Error\\|WP_Term\\|null\\.$#"
count: 2
path: src/Defaults/Trigger/Taxonomy/TermUpdated.php

-
message: "#^Parameter \\#1 \\$term of function get_term_link expects int\\|string\\|WP_Term, array\\|WP_Error\\|WP_Term\\|null given\\.$#"
count: 1
path: src/Defaults/Trigger/Taxonomy/TermUpdated.php

-
message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Taxonomy\\\\TermTrigger\\:\\:\\$term \\(WP_Term\\) does not accept array\\|WP_Error\\|WP_Term\\|null\\.$#"
count: 1
path: src/Defaults/Trigger/Taxonomy/TermUpdated.php

-
message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Taxonomy\\\\TermTrigger\\:\\:\\$term_permalink \\(string\\) does not accept string\\|WP_Error\\.$#"
count: 1
path: src/Defaults/Trigger/Taxonomy/TermUpdated.php

-
message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Taxonomy\\\\TermUpdated\\:\\:\\$term_modification_datetime \\(string\\) does not accept int\\.$#"
count: 1
path: src/Defaults/Trigger/Taxonomy/TermUpdated.php

-
message: "#^Method BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Theme\\\\Installed\\:\\:context\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
count: 1
Expand Down
10 changes: 9 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: notification, bracketspace, Kubitomakita, tomaszadamowicz, insejn,
Tags: notification, notify, alert, email, mail, webhook, API, developer, framework
Requires at least: 4.9
Tested up to: 5.8
Stable tag: 8.0.11
Stable tag: 8.0.12
Requires PHP: 7.0
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html
Expand Down Expand Up @@ -302,6 +302,14 @@ Yes! We're offering a [custom plugin development](https://bracketspace.com/custo

== Changelog ==

= 8.0.12 =

* [Changed] Logic of assigning property name is moved to Abstract Merge Tag Class
* [Added] Property names to Term Merge Tags
* [Added] 6h cache expire to the user queries
* [Added] Email / Merge tag recipient now can also be separated with semicolon
* [Added] Endpoint to check whether the REST api is enabled

= 8.0.11 =

* [Changed] Add php_xml to required php extensions.
Expand Down
31 changes: 31 additions & 0 deletions src/Abstracts/MergeTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ abstract class MergeTag implements Interfaces\Taggable {
*/
protected $hidden = false;

/**
* Trigger property name to get the comment data from
*
* @var string
*/
private $trigger_property_name;

/**
* Merge tag constructor
*
Expand Down Expand Up @@ -212,6 +219,30 @@ public function set_resolver( $resolver ) {

}

/**
* Sets resolver function
*
* @since 8.0.12
*
* @param string $trigger_property_name merge tag trigger property name.
*
* @return void
*/
public function set_trigger_prop( string $trigger_property_name ) {
$this->trigger_property_name = $trigger_property_name;
}

/**
* Get trigger property
*
* @since 8.0.12
*
* @return string
*/
public function get_trigger_prop(): string {
return $this->trigger_property_name;
}

/**
* Gets trigger object
*
Expand Down
47 changes: 47 additions & 0 deletions src/Admin/CheckRestApi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* CheckRestApi class
*
* @package notification
*/

namespace BracketSpace\Notification\Admin;

use BracketSpace\Notification\Dependencies\Micropackage\DocHooks\HookTrait;

/**
* CheckRestApi class
*/
class CheckRestApi {

/**
* Method sends request to API, based on response checks whether REST API works correctly
*
* @since 8.0.12
* @action admin_notices
* @return void
*/
public function test_rest_api() {
$response = wp_remote_get( get_rest_url( null, 'notification/v1/check/' ) );
$message = json_decode( wp_remote_retrieve_body( $response ), true );

$is_available = false;
$is_edit = false;

if ( array_key_exists( 'data', $message ) ) {
$is_available = 'RestApi' === $message['data'];
}

$current_screen = get_current_screen();

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

if ( ! $is_available && $is_edit ) {
$class = 'notice notice-error';
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.' );
}
}

}
9 changes: 9 additions & 0 deletions src/Api/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ public function __construct() {
},
],
];

$this->routes[] = [
'path' => 'check',
'args' => [
'methods' => 'GET',
'callback' => [ new Controller\CheckRestApiController(), 'send_response' ],
'permission_callback' => '__return_true',
],
];
}

/**
Expand Down
Loading

0 comments on commit ee7c7f6

Please sign in to comment.