Skip to content

Commit

Permalink
Merge branch 'release/1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubmikita committed Feb 19, 2017
2 parents cc82a88 + 9860a76 commit 01640d6
Show file tree
Hide file tree
Showing 11 changed files with 1,553 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
53 changes: 53 additions & 0 deletions inc/trigger.php
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 ) );
}

}

}

}
53 changes: 53 additions & 0 deletions inc/triggers.php
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;

}

}
Loading

0 comments on commit 01640d6

Please sign in to comment.