Skip to content

Commit

Permalink
fix: unify attribute name used by resolvers to "property_name" in all…
Browse files Browse the repository at this point in the history
… Merge Tags
  • Loading branch information
Dartui committed Sep 25, 2024
1 parent ed4a90f commit 2227669
Show file tree
Hide file tree
Showing 16 changed files with 43 additions and 41 deletions.
2 changes: 2 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ Yes! We're offering a [custom plugin development](https://bracketspace.com/custo
- Class methods and properties has been changed from snake_case to camelCase.
- In Post Triggers, dynamic property `$trigger->{$post_type}` has been replaced with static prop `$trigger->post`.
- The same as above applies to Post Trigger datetime tags, namely: postCreationDatetime, postPublicationDatetime, and postModificationDatetime.
- Post Merge Tags will now use `property_name` attribute rather than `post_type` to set trigger property used by resolvers.
- Hook `notification/data/save` and `notification/data/save/after` now pass Core\Notification instance in the first param instead of the WordPress adapter instance.
- Runtime components are now referenced by FQCN (Fully Qualified Class Name), instead of the name.

Expand Down Expand Up @@ -379,6 +380,7 @@ Removed deprecated hooks:
* [Changed] Runtime components are now referenced by FQCN (Fully Qualified Class Name), instead of the name.
* [Changed] Abstract classes are now renamed BaseSomething convention and placed in Repository dir.
* [Changed] Date-related merge tags (`Date`, `DateTime` and `Time`) now requires `timestamp` argument to be callable.
* [Changed] Unify attribute name used by resolvers to `property_name` in all Merge Tags.
* [Fixed] Shortcodes being uncorrectly stripped leaving closing "]" behind.
* [Fixed] PHP 8.2 deprecations.
* [Fixed] Stripping shortcodes in carrier fields.
Expand Down
6 changes: 3 additions & 3 deletions src/Repository/MergeTag/Post/FeaturedImageId.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ class FeaturedImageId extends IntegerTag
*/
public function __construct($params = [])
{
$this->setTriggerProp($params['post_type'] ?? 'post');
$this->setTriggerProp($params['property_name'] ?? 'post');

$postTypeName = WpObjectHelper::getPostTypeName($this->getTriggerProp());
$postTypeName = WpObjectHelper::getPostTypeName($params['post_type'] ?? 'post');

$args = wp_parse_args(
$params,
[
'slug' => sprintf('%s_featured_image_id', $this->getTriggerProp()),
'slug' => sprintf('%s_featured_image_id', $params['post_type'] ?? 'post'),
// translators: singular post name.
'name' => sprintf(__('%s featured image id', 'notification'), $postTypeName),
'description' => __('123', 'notification'),
Expand Down
6 changes: 3 additions & 3 deletions src/Repository/MergeTag/Post/FeaturedImageUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ class FeaturedImageUrl extends UrlTag
*/
public function __construct($params = [])
{
$this->setTriggerProp($params['post_type'] ?? 'post');
$this->setTriggerProp($params['property_name'] ?? 'post');

$postTypeName = WpObjectHelper::getPostTypeName($this->getTriggerProp());
$postTypeName = WpObjectHelper::getPostTypeName($params['post_type'] ?? 'post');

$args = wp_parse_args(
$params,
[
'slug' => sprintf('%s_featured_image_url', $this->getTriggerProp()),
'slug' => sprintf('%s_featured_image_url', $params['post_type'] ?? 'post'),
// translators: singular post name.
'name' => sprintf(__('%s featured image url', 'notification'), $postTypeName),
'description' => __('https://example.com/wp-content/2019/01/image.jpg', 'notification'),
Expand Down
6 changes: 3 additions & 3 deletions src/Repository/MergeTag/Post/PostContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ class PostContent extends StringTag
*/
public function __construct($params = [])
{
$this->setTriggerProp($params['post_type'] ?? 'post');
$this->setTriggerProp($params['property_name'] ?? 'post');

$postTypeName = WpObjectHelper::getPostTypeName($this->getTriggerProp());
$postTypeName = WpObjectHelper::getPostTypeName($params['post_type'] ?? 'post');

$args = wp_parse_args(
$params,
[
'slug' => sprintf('%s_content', $this->getTriggerProp()),
'slug' => sprintf('%s_content', $params['post_type'] ?? 'post'),
// translators: singular post name.
'name' => sprintf(__('%s content', 'notification'), $postTypeName),
'description' => __(
Expand Down
6 changes: 3 additions & 3 deletions src/Repository/MergeTag/Post/PostContentHtml.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ class PostContentHtml extends HtmlTag
*/
public function __construct($params = [])
{
$this->setTriggerProp($params['post_type'] ?? 'post');
$this->setTriggerProp($params['property_name'] ?? 'post');

$postTypeName = WpObjectHelper::getPostTypeName($this->getTriggerProp());
$postTypeName = WpObjectHelper::getPostTypeName($params['post_type'] ?? 'post');

$args = wp_parse_args(
$params,
[
'slug' => sprintf('%s_content_html', $this->getTriggerProp()),
'slug' => sprintf('%s_content_html', $params['post_type'] ?? 'post'),
// translators: singular post name.
'name' => sprintf(__('%s content HTML', 'notification'), $postTypeName),
'description' => __(
Expand Down
6 changes: 3 additions & 3 deletions src/Repository/MergeTag/Post/PostExcerpt.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ class PostExcerpt extends StringTag
*/
public function __construct($params = [])
{
$this->setTriggerProp($params['post_type'] ?? 'post');
$this->setTriggerProp($params['property_name'] ?? 'post');

$postTypeName = WpObjectHelper::getPostTypeName($this->getTriggerProp());
$postTypeName = WpObjectHelper::getPostTypeName($params['post_type'] ?? 'post');

$args = wp_parse_args(
$params,
[
'slug' => sprintf('%s_excerpt', $this->getTriggerProp()),
'slug' => sprintf('%s_excerpt', $params['post_type'] ?? 'post'),
// translators: singular post name.
'name' => sprintf(__('%s excerpt', 'notification'), $postTypeName),
'description' => __('Welcome to WordPress...', 'notification'),
Expand Down
6 changes: 3 additions & 3 deletions src/Repository/MergeTag/Post/PostID.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ class PostID extends IntegerTag
*/
public function __construct($params = [])
{
$this->setTriggerProp($params['post_type'] ?? 'post');
$this->setTriggerProp($params['property_name'] ?? 'post');

$postTypeName = WpObjectHelper::getPostTypeName($this->getTriggerProp());
$postTypeName = WpObjectHelper::getPostTypeName($params['post_type'] ?? 'post');

$args = wp_parse_args(
$params,
[
'slug' => sprintf('%s_ID', $this->getTriggerProp()),
'slug' => sprintf('%s_ID', $params['post_type'] ?? 'post'),
// translators: singular post name.
'name' => sprintf(__('%s ID', 'notification'), $postTypeName),
'description' => '35',
Expand Down
6 changes: 3 additions & 3 deletions src/Repository/MergeTag/Post/PostPermalink.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ class PostPermalink extends UrlTag
*/
public function __construct($params = [])
{
$this->setTriggerProp($params['post_type'] ?? 'post');
$this->setTriggerProp($params['property_name'] ?? 'post');

$postTypeName = WpObjectHelper::getPostTypeName($this->getTriggerProp());
$postTypeName = WpObjectHelper::getPostTypeName($params['post_type'] ?? 'post');

$args = wp_parse_args(
$params,
[
'slug' => sprintf('%s_permalink', $this->getTriggerProp()),
'slug' => sprintf('%s_permalink', $params['post_type'] ?? 'post'),
// translators: singular post name.
'name' => sprintf(__('%s permalink', 'notification'), $postTypeName),
'description' => __('https://example.com/hello-world/', 'notification'),
Expand Down
6 changes: 3 additions & 3 deletions src/Repository/MergeTag/Post/PostSlug.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ class PostSlug extends StringTag
*/
public function __construct($params = [])
{
$this->setTriggerProp($params['post_type'] ?? 'post');
$this->setTriggerProp($params['property_name'] ?? 'post');

$postTypeName = WpObjectHelper::getPostTypeName($this->getTriggerProp());
$postTypeName = WpObjectHelper::getPostTypeName($params['post_type'] ?? 'post');

$args = wp_parse_args(
$params,
[
'slug' => sprintf('%s_slug', $this->getTriggerProp()),
'slug' => sprintf('%s_slug', $params['post_type'] ?? 'post'),
// translators: singular post name.
'name' => sprintf(__('%s slug', 'notification'), $postTypeName),
'description' => __('hello-world', 'notification'),
Expand Down
6 changes: 3 additions & 3 deletions src/Repository/MergeTag/Post/PostStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ class PostStatus extends StringTag
*/
public function __construct($params = [])
{
$this->setTriggerProp($params['post_type'] ?? 'post');
$this->setTriggerProp($params['property_name'] ?? 'post');

$postTypeName = WpObjectHelper::getPostTypeName($this->getTriggerProp());
$postTypeName = WpObjectHelper::getPostTypeName($params['post_type'] ?? 'post');

$args = wp_parse_args(
$params,
[
'slug' => sprintf('%s_status', $this->getTriggerProp()),
'slug' => sprintf('%s_status', $params['post_type'] ?? 'post'),
// translators: singular post name.
'name' => sprintf(__('%s status', 'notification'), $postTypeName),
'description' => 'publish',
Expand Down
6 changes: 3 additions & 3 deletions src/Repository/MergeTag/Post/PostTerms.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@ class PostTerms extends StringTag
*/
public function __construct($params = [])
{
$this->setTriggerProp($params['post_type'] ?? 'post');
$this->setTriggerProp($params['property_name'] ?? 'post');

if (isset($params['taxonomy'])) {
$this->taxonomy = is_string($params['taxonomy'])
? get_taxonomy($params['taxonomy'])
: $params['taxonomy'];
}

$postTypeName = WpObjectHelper::getPostTypeName($this->getTriggerProp());
$postTypeName = WpObjectHelper::getPostTypeName($params['post_type'] ?? 'post');

$args = wp_parse_args(
$params,
[
'slug' => sprintf('%s_%s', $this->getTriggerProp(), $this->taxonomy->name),
'slug' => sprintf('%s_%s', $params['post_type'] ?? 'post', $this->taxonomy->name),
// translators: 1. Post Type 2. Taxonomy name.
'name' => sprintf(__('%1$s %2$s', 'notification'), $postTypeName, $this->taxonomy->label),
'description' => __('General, Tech, Lifestyle', 'notification'),
Expand Down
6 changes: 3 additions & 3 deletions src/Repository/MergeTag/Post/PostTitle.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ class PostTitle extends StringTag
*/
public function __construct($params = [])
{
$this->setTriggerProp($params['post_type'] ?? 'post');
$this->setTriggerProp($params['property_name'] ?? 'post');

$postTypeName = WpObjectHelper::getPostTypeName($this->getTriggerProp());
$postTypeName = WpObjectHelper::getPostTypeName($params['post_type'] ?? 'post');

$args = wp_parse_args(
$params,
[
'slug' => sprintf('%s_title', $this->getTriggerProp()),
'slug' => sprintf('%s_title', $params['post_type'] ?? 'post'),
// translators: singular post name.
'name' => sprintf(__('%s title', 'notification'), $postTypeName),
'description' => __('Hello World', 'notification'),
Expand Down
2 changes: 1 addition & 1 deletion src/Repository/MergeTag/Post/PostType.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PostType extends StringTag
*/
public function __construct($params = [])
{
$this->setTriggerProp($params['post_type'] ?? 'post');
$this->setTriggerProp($params['property_name'] ?? 'post');

$args = wp_parse_args(
$params,
Expand Down
6 changes: 3 additions & 3 deletions src/Repository/MergeTag/Post/RevisionLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ class RevisionLink extends UrlTag
*/
public function __construct($params = [])
{
$this->setTriggerProp($params['post_type'] ?? 'post');
$this->setTriggerProp($params['property_name'] ?? 'post');

$postTypeName = WpObjectHelper::getPostTypeName($this->getTriggerProp());
$postTypeName = WpObjectHelper::getPostTypeName($params['post_type'] ?? 'post');

$args = wp_parse_args(
$params,
[
'slug' => sprintf('%s_revision_link', $this->getTriggerProp()),
'slug' => sprintf('%s_revision_link', $params['post_type'] ?? 'post'),
// translators: singular post name.
'name' => sprintf(__('%s revision link', 'notification'), $postTypeName),
'description' => __('https://example.com/wp-admin/revision.php?revision=id', 'notification'),
Expand Down
6 changes: 3 additions & 3 deletions src/Repository/MergeTag/Post/ThumbnailUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ class ThumbnailUrl extends UrlTag
*/
public function __construct($params = [])
{
$this->setTriggerProp($params['post_type'] ?? 'post');
$this->setTriggerProp($params['property_name'] ?? 'post');

$postTypeName = WpObjectHelper::getPostTypeName($this->getTriggerProp());
$postTypeName = WpObjectHelper::getPostTypeName($params['post_type'] ?? 'post');

$args = wp_parse_args(
$params,
[
'slug' => sprintf('%s_thumbnail_url', $this->getTriggerProp()),
'slug' => sprintf('%s_thumbnail_url', $params['post_type'] ?? 'post'),
// translators: singular post name.
'name' => sprintf(__('%s thumbnail url', 'notification'), $postTypeName),
'description' => __('https://example.com/wp-content/2019/01/image.jpg', 'notification'),
Expand Down
2 changes: 1 addition & 1 deletion src/Repository/MergeTag/User/UserPasswordResetLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct($params = [])
$this->keyPropertyName = $params['key_property_name'];
}

$this->setTriggerProp($params['user_property_name'] ?? 'user_object');
$this->setTriggerProp($params['property_name'] ?? 'user_object');

$args = wp_parse_args(
[
Expand Down

0 comments on commit 2227669

Please sign in to comment.