-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
1,289 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
/** | ||
* Taxonomy name merge tag | ||
* | ||
* Requirements: | ||
* - Trigger property of the WP_Taxonomy term object | ||
* | ||
* @package notification | ||
*/ | ||
|
||
namespace BracketSpace\Notification\Defaults\MergeTag\Taxonomy; | ||
|
||
use BracketSpace\Notification\Defaults\MergeTag\StringTag; | ||
|
||
|
||
/** | ||
* Taxonomy name merge tag class | ||
*/ | ||
class TaxonomyName extends StringTag { | ||
|
||
/** | ||
* Taxonomy slug | ||
* | ||
* @var string | ||
*/ | ||
protected $taxonomy; | ||
|
||
/** | ||
* Merge tag constructor | ||
* | ||
* @since [Next] | ||
* @param array $params merge tag configuration params. | ||
*/ | ||
public function __construct( $params = array() ) { | ||
|
||
if ( isset( $params['taxonomy'] ) ) { | ||
$this->taxonomy = $params['taxonomy']; | ||
} else { | ||
$this->taxonomy = 'category'; | ||
} | ||
|
||
$args = wp_parse_args( $params, array( | ||
'slug' => $this->taxonomy . '_name', | ||
'name' => __( 'Taxonomy name', 'notification' ), | ||
'description' => __( 'Hello World', 'notification' ), | ||
'example' => true, | ||
'resolver' => function( $trigger ) { | ||
return $this->get_nicename(); | ||
}, | ||
) ); | ||
|
||
parent::__construct( $args ); | ||
|
||
} | ||
|
||
/** | ||
* Function for checking requirements | ||
* | ||
* @return boolean | ||
*/ | ||
public function check_requirements() { | ||
return isset( $this->trigger->taxonomy ); | ||
} | ||
|
||
/** | ||
* Gets nice, translated taxonomy name | ||
* | ||
* @since [Next] | ||
* @return string taxonomy nicename | ||
*/ | ||
public function get_nicename() { | ||
$taxonomy = get_taxonomy( $this->trigger->taxonomy ); | ||
if ( empty( $taxonomy ) ) { | ||
return ''; | ||
} | ||
return $taxonomy->labels->singular_name; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
/** | ||
* Taxonomy slug merge tag | ||
* | ||
* Requirements: | ||
* - Trigger property of the WP_Taxonomy term object | ||
* | ||
* @package notification | ||
*/ | ||
|
||
namespace BracketSpace\Notification\Defaults\MergeTag\Taxonomy; | ||
|
||
use BracketSpace\Notification\Defaults\MergeTag\StringTag; | ||
|
||
|
||
/** | ||
* Taxonomy slug merge tag class | ||
*/ | ||
class TaxonomySlug extends StringTag { | ||
|
||
/** | ||
* Taxonomy slug | ||
* | ||
* @var string | ||
*/ | ||
protected $taxonomy; | ||
|
||
/** | ||
* Merge tag constructor | ||
* | ||
* @since [Next] | ||
* @param array $params merge tag configuration params. | ||
*/ | ||
public function __construct( $params = array() ) { | ||
|
||
if ( isset( $params['taxonomy'] ) ) { | ||
$this->taxonomy = $params['taxonomy']; | ||
} else { | ||
$this->taxonomy = 'category'; | ||
} | ||
|
||
$args = wp_parse_args( $params, array( | ||
'slug' => $this->taxonomy . '_slug', | ||
'name' => __( 'Taxonomy slug', 'notification' ), | ||
'description' => __( 'hello-world', 'notification' ), | ||
'example' => true, | ||
'resolver' => function( $trigger ) { | ||
return $trigger->taxonomy; | ||
}, | ||
) ); | ||
|
||
parent::__construct( $args ); | ||
|
||
} | ||
|
||
/** | ||
* Function for checking requirements | ||
* | ||
* @return boolean | ||
*/ | ||
public function check_requirements() { | ||
return isset( $this->trigger->taxonomy ); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
/** | ||
* Taxonomy term description merge tag | ||
* | ||
* Requirements: | ||
* - Trigger property of the WP_Taxonomy term object | ||
* | ||
* @package notification | ||
*/ | ||
|
||
namespace BracketSpace\Notification\Defaults\MergeTag\Taxonomy; | ||
|
||
use BracketSpace\Notification\Defaults\MergeTag\StringTag; | ||
|
||
|
||
/** | ||
* Taxonomy term description merge tag class | ||
*/ | ||
class TermDescription extends StringTag { | ||
|
||
/** | ||
* Merge tag constructor | ||
* | ||
* @since [Next] | ||
*/ | ||
public function __construct() { | ||
|
||
$args = wp_parse_args( array( | ||
'slug' => 'term_description', | ||
'name' => __( 'Term description', 'notification' ), | ||
'description' => 'Lorem ipsum sit dolor amet', | ||
'example' => true, | ||
'resolver' => function( $trigger ) { | ||
return $trigger->term->description; | ||
}, | ||
) ); | ||
|
||
parent::__construct( $args ); | ||
|
||
} | ||
|
||
/** | ||
* Function for checking requirements | ||
* | ||
* @return boolean | ||
*/ | ||
public function check_requirements() { | ||
return isset( $this->trigger->term->description ); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
/** | ||
* Taxonomy term ID merge tag | ||
* | ||
* Requirements: | ||
* - Trigger property of the WP_Taxonomy term object | ||
* | ||
* @package notification | ||
*/ | ||
|
||
namespace BracketSpace\Notification\Defaults\MergeTag\Taxonomy; | ||
|
||
use BracketSpace\Notification\Defaults\MergeTag\IntegerTag; | ||
|
||
|
||
/** | ||
* Taxonomy term ID merge tag class | ||
*/ | ||
class TermID extends IntegerTag { | ||
|
||
/** | ||
* Merge tag constructor | ||
* | ||
* @since [Next] | ||
*/ | ||
public function __construct() { | ||
|
||
$args = wp_parse_args( array( | ||
'slug' => 'term_ID', | ||
'name' => __( 'Term ID', 'notification' ), | ||
'description' => '35', | ||
'example' => true, | ||
'resolver' => function( $trigger ) { | ||
return $trigger->term->term_id; | ||
}, | ||
) ); | ||
|
||
parent::__construct( $args ); | ||
|
||
} | ||
|
||
/** | ||
* Function for checking requirements | ||
* | ||
* @return boolean | ||
*/ | ||
public function check_requirements() { | ||
return isset( $this->trigger->term->term_id ); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
/** | ||
* Taxonomy term name merge tag | ||
* | ||
* Requirements: | ||
* - Trigger property of the WP_Taxonomy term object | ||
* | ||
* @package notification | ||
*/ | ||
|
||
namespace BracketSpace\Notification\Defaults\MergeTag\Taxonomy; | ||
|
||
use BracketSpace\Notification\Defaults\MergeTag\StringTag; | ||
|
||
|
||
/** | ||
* Taxonomy term name merge tag class | ||
*/ | ||
class TermName extends StringTag { | ||
|
||
/** | ||
* Merge tag constructor | ||
* | ||
* @since [Next] | ||
*/ | ||
public function __construct() { | ||
|
||
$args = wp_parse_args( array( | ||
'slug' => 'term_name', | ||
'name' => __( 'Term name', 'notification' ), | ||
'description' => 'Nature', | ||
'example' => true, | ||
'resolver' => function( $trigger ) { | ||
return $trigger->term->name; | ||
|
||
} ) ); | ||
|
||
parent::__construct( $args ); | ||
|
||
} | ||
|
||
/** | ||
* Function for checking requirements | ||
* | ||
* @return boolean | ||
*/ | ||
public function check_requirements() { | ||
return isset( $this->trigger->term->name ); | ||
} | ||
|
||
} |
Oops, something went wrong.