@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | * @return void |
16 | 16 | */ |
17 | 17 | public function register() { |
18 | - add_filter( 'bp_activity_notification_callback', function ( $callback ) { |
|
19 | - return [ $this, 'callback' ]; |
|
18 | + add_filter('bp_activity_notification_callback', function($callback) { |
|
19 | + return [$this, 'callback']; |
|
20 | 20 | } ); |
21 | 21 | } |
22 | 22 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @return mixed |
27 | 27 | */ |
28 | - public function callback( $action, $activity_id, $user_id, $total, $format = 'string', $id ) { |
|
28 | + public function callback($action, $activity_id, $user_id, $total, $format = 'string', $id) { |
|
29 | 29 | $data = [ |
30 | 30 | 'id' => $id, |
31 | 31 | 'action' => $action, |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | |
38 | 38 | $messages = $this->getMessages(); |
39 | 39 | |
40 | - $message = $this->instantiateMessage( $data, $messages ); |
|
40 | + $message = $this->instantiateMessage($data, $messages); |
|
41 | 41 | |
42 | - if ( $format === 'string' ) { |
|
42 | + if ($format === 'string') { |
|
43 | 43 | return $message->toHtml(); |
44 | 44 | } |
45 | 45 | |
@@ -55,23 +55,23 @@ discard block |
||
55 | 55 | * @return Messages\Message |
56 | 56 | * @throws InvalidArgumentException |
57 | 57 | */ |
58 | - protected function instantiateMessage( array $data, array $messages ) { |
|
58 | + protected function instantiateMessage(array $data, array $messages) { |
|
59 | 59 | $action = $data['action']; |
60 | 60 | |
61 | - if ( ! array_key_exists( $action, $messages ) ) { |
|
62 | - throw new InvalidArgumentException( sprintf( |
|
61 | + if ( ! array_key_exists($action, $messages)) { |
|
62 | + throw new InvalidArgumentException(sprintf( |
|
63 | 63 | 'Message class for %s action does not exist', |
64 | 64 | $action |
65 | - ) ); |
|
65 | + )); |
|
66 | 66 | } |
67 | 67 | |
68 | - $message = new $messages[ $action ]( $data ); |
|
68 | + $message = new $messages[$action]($data); |
|
69 | 69 | |
70 | - if ( ! $message instanceof Messages\Message ) { |
|
71 | - throw new InvalidArgumentException( sprintf( |
|
70 | + if ( ! $message instanceof Messages\Message) { |
|
71 | + throw new InvalidArgumentException(sprintf( |
|
72 | 72 | 'The message "%s" is not recognized and cannot be rendered', |
73 | - is_object( $message ) ? get_class( $message ) : (string) $message |
|
74 | - ) ); |
|
73 | + is_object($message) ? get_class($message) : (string) $message |
|
74 | + )); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | return $message; |
@@ -15,7 +15,7 @@ |
||
15 | 15 | public static function create() { |
16 | 16 | static $plugin = null; |
17 | 17 | |
18 | - if ( null === $plugin ) { |
|
18 | + if (null === $plugin) { |
|
19 | 19 | $plugin = new Plugin(); |
20 | 20 | } |
21 | 21 |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @return void |
19 | 19 | */ |
20 | 20 | public function register() { |
21 | - add_action( 'bp_loaded', [ $this, 'registerServices' ] ); |
|
21 | + add_action('bp_loaded', [$this, 'registerServices']); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function registerServices() { |
30 | 30 | $services = $this->getServices(); |
31 | - $services = array_map( [ $this, 'instantiateServices' ], $services ); |
|
31 | + $services = array_map([$this, 'instantiateServices'], $services); |
|
32 | 32 | |
33 | - array_walk( $services, function ( Service $service ) { |
|
33 | + array_walk($services, function(Service $service) { |
|
34 | 34 | $service->register(); |
35 | 35 | } ); |
36 | 36 | } |
@@ -43,21 +43,21 @@ discard block |
||
43 | 43 | * @return Service |
44 | 44 | * @throws InvalidArgumentException |
45 | 45 | */ |
46 | - protected function instantiateServices( $class ) { |
|
47 | - if ( ! class_exists( $class ) ) { |
|
48 | - throw new InvalidArgumentException( sprintf( |
|
46 | + protected function instantiateServices($class) { |
|
47 | + if ( ! class_exists($class)) { |
|
48 | + throw new InvalidArgumentException(sprintf( |
|
49 | 49 | 'The service "%s" is not recognized and cannot be registered.', |
50 | - is_object( $class ) ? get_class( $class ) : (string) $class |
|
51 | - ) ); |
|
50 | + is_object($class) ? get_class($class) : (string) $class |
|
51 | + )); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | $service = new $class(); |
55 | 55 | |
56 | - if ( ! $service instanceof Service ) { |
|
57 | - throw new InvalidArgumentException( sprintf( |
|
56 | + if ( ! $service instanceof Service) { |
|
57 | + throw new InvalidArgumentException(sprintf( |
|
58 | 58 | 'The service "%s" is not recognized and cannot be registered.', |
59 | - is_object( $service ) ? get_class( $service ) : (string) $service |
|
60 | - ) ); |
|
59 | + is_object($service) ? get_class($service) : (string) $service |
|
60 | + )); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | return $service; |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | * @param array $data |
18 | 18 | * @return void |
19 | 19 | */ |
20 | - public function __construct( array $data = [] ) { |
|
20 | + public function __construct(array $data = []) { |
|
21 | 21 | $this->data = $data; |
22 | 22 | } |
23 | 23 | |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | * @return string |
28 | 28 | */ |
29 | 29 | public function message() { |
30 | - if ( $this->data['total'] > 1 ) { |
|
31 | - return sprintf( 'You have %1$d new mentions', (int) $this->data['total'] ); |
|
30 | + if ($this->data['total'] > 1) { |
|
31 | + return sprintf('You have %1$d new mentions', (int) $this->data['total']); |
|
32 | 32 | } |
33 | 33 | |
34 | - return sprintf( '%1$s mentioned you', bp_core_get_user_displayname( $this->data['user_id' ] ) ); |
|
34 | + return sprintf('%1$s mentioned you', bp_core_get_user_displayname($this->data['user_id'])); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | public function toHtml() { |
64 | 64 | return sprintf( |
65 | 65 | '<a href="%1$s">%2$s</a>', |
66 | - esc_url( $this->url() ), |
|
67 | - esc_html( $this->message() ) |
|
66 | + esc_url($this->url()), |
|
67 | + esc_html($this->message()) |
|
68 | 68 | ); |
69 | 69 | } |
70 | 70 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | * @param array $data |
18 | 18 | * @return void |
19 | 19 | */ |
20 | - public function __construct( array $data = [] ) { |
|
20 | + public function __construct(array $data = []) { |
|
21 | 21 | $this->data = $data; |
22 | 22 | } |
23 | 23 | |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | * @return string |
28 | 28 | */ |
29 | 29 | public function message() { |
30 | - if ( $this->data['total'] > 1 ) { |
|
31 | - return sprintf( 'You have %d new replies', (int) $this->data['total'] ); |
|
30 | + if ($this->data['total'] > 1) { |
|
31 | + return sprintf('You have %d new replies', (int) $this->data['total']); |
|
32 | 32 | } |
33 | 33 | |
34 | - return sprintf( '%s commented on one of your updates', bp_core_get_user_displayname( $this->data['user_id' ] ) ); |
|
34 | + return sprintf('%s commented on one of your updates', bp_core_get_user_displayname($this->data['user_id'])); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -40,17 +40,17 @@ discard block |
||
40 | 40 | * @return string |
41 | 41 | */ |
42 | 42 | public function url() { |
43 | - if ( $this->data['total'] > 1 ) { |
|
43 | + if ($this->data['total'] > 1) { |
|
44 | 44 | return add_query_arg( |
45 | 45 | 'type', |
46 | 46 | $this->data['action'], |
47 | - bp_get_notifications_permalink( $this->data['user_id'] ) ); |
|
47 | + bp_get_notifications_permalink($this->data['user_id']) ); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | return add_query_arg( |
51 | 51 | 'nid', |
52 | 52 | $this->data['id'], |
53 | - bp_activity_get_permalink( $this->data['activity_id'] ) |
|
53 | + bp_activity_get_permalink($this->data['activity_id']) |
|
54 | 54 | ); |
55 | 55 | } |
56 | 56 | |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | public function toHtml() { |
75 | 75 | return sprintf( |
76 | 76 | '<a href="%1$s">%2$s</a>', |
77 | - esc_url( $this->url() ), |
|
78 | - esc_html( $this->message() ) |
|
77 | + esc_url($this->url()), |
|
78 | + esc_html($this->message()) |
|
79 | 79 | ); |
80 | 80 | } |
81 | 81 | } |
@@ -10,8 +10,8 @@ discard block |
||
10 | 10 | * @param array $data |
11 | 11 | * @return void |
12 | 12 | */ |
13 | - public function __construct( array $data = [] ) { |
|
14 | - parent::__construct( $data ); |
|
13 | + public function __construct(array $data = []) { |
|
14 | + parent::__construct($data); |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | /** |
@@ -20,10 +20,10 @@ discard block |
||
20 | 20 | * @return string |
21 | 21 | */ |
22 | 22 | public function message() { |
23 | - if ( $this->data['total'] > 1 ) { |
|
24 | - return sprintf( 'You have %1$d new comment replies', (int) $this->data['total'] ); |
|
23 | + if ($this->data['total'] > 1) { |
|
24 | + return sprintf('You have %1$d new comment replies', (int) $this->data['total']); |
|
25 | 25 | } |
26 | 26 | |
27 | - return sprintf( '%1$s replied to one your activity comments', bp_core_get_user_displayname( $this->data['user_id' ] ) ); |
|
27 | + return sprintf('%1$s replied to one your activity comments', bp_core_get_user_displayname($this->data['user_id'])); |
|
28 | 28 | } |
29 | 29 | } |