-
Notifications
You must be signed in to change notification settings - Fork 0
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
11 changed files
with
1,553 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
indent_style = tab | ||
|
||
[{*.txt,wp-config-sample.php}] | ||
end_of_line = crlf |
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 @@ | ||
* text=auto |
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,53 @@ | ||
<?php | ||
/** | ||
* Trigger class | ||
* This class registers all the triggers automatically | ||
*/ | ||
|
||
namespace Notification\bbPress; | ||
|
||
abstract class Trigger { | ||
|
||
public function __construct() { | ||
|
||
// register triggers from child class | ||
$this->register_triggers(); | ||
|
||
// add notification actions | ||
$this->notifications(); | ||
|
||
} | ||
|
||
/** | ||
* Used to register a notification action | ||
* Must be defined in a child class | ||
*/ | ||
abstract protected function notifications(); | ||
|
||
/** | ||
* Register triggers | ||
* Each method which starts with trigger_ is automatically called | ||
* @return void | ||
*/ | ||
public function register_triggers() { | ||
|
||
$methods = get_class_methods( $this ); | ||
|
||
foreach ( $methods as $method ) { | ||
|
||
// not a method we are looking for | ||
if ( strpos( $method, 'trigger_' ) === false ) { | ||
continue; | ||
} | ||
|
||
$trigger = str_replace( 'trigger_', '', $method ); | ||
|
||
if ( apply_filters( 'notification/triggers/bbpress/' . $trigger, true ) ) { | ||
call_user_func( array( $this, $method ) ); | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
} |
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,53 @@ | ||
<?php | ||
/** | ||
* Triggers class | ||
*/ | ||
|
||
namespace Notification\bbPress; | ||
|
||
use Notification\Singleton; | ||
use Notification\bbPress\Triggers; | ||
|
||
class Triggers extends Singleton { | ||
|
||
public function __construct() { | ||
|
||
$this->load_triggers(); | ||
|
||
add_filter( 'notification/disable/post_types_allowed', array( $this, 'disable_metabox_post_types' ), 10, 1 ); | ||
|
||
} | ||
|
||
/** | ||
* Load triggers from their directories | ||
* @return void | ||
*/ | ||
public function load_triggers() { | ||
|
||
// Forums | ||
new Triggers\Forums(); | ||
|
||
// Topics | ||
new Triggers\Topics(); | ||
|
||
// Replies | ||
new Triggers\Replies(); | ||
|
||
} | ||
|
||
/** | ||
* Allow bbPress post types to disable certain triggers | ||
* @param array $post_types default post types | ||
* @return array post types with bbPress types | ||
*/ | ||
public function disable_metabox_post_types( $post_types ) { | ||
|
||
$post_types[] = bbp_get_forum_post_type(); | ||
$post_types[] = bbp_get_topic_post_type(); | ||
$post_types[] = bbp_get_reply_post_type(); | ||
|
||
return $post_types; | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.