@@ -38,7 +38,7 @@ |
||
38 | 38 | * @since 2.1.0 |
39 | 39 | */ |
40 | 40 | public function get_title() { |
41 | - return __( 'Author', 'wordpoints' ); |
|
41 | + return __('Author', 'wordpoints'); |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 |
@@ -45,18 +45,18 @@ discard block |
||
45 | 45 | /** |
46 | 46 | * @since 2.2.0 |
47 | 47 | */ |
48 | - public function __construct( $entity_id, array $hierarchy ) { |
|
48 | + public function __construct($entity_id, array $hierarchy) { |
|
49 | 49 | |
50 | 50 | $this->entity_id = $entity_id; |
51 | 51 | $this->post_id = $this->get_post_id(); |
52 | 52 | |
53 | - if ( $this->post_id ) { |
|
53 | + if ($this->post_id) { |
|
54 | 54 | |
55 | 55 | $post_status = get_post_status_object( |
56 | - get_post_status( $this->post_id ) |
|
56 | + get_post_status($this->post_id) |
|
57 | 57 | ); |
58 | 58 | |
59 | - if ( $post_status && $post_status->public ) { |
|
59 | + if ($post_status && $post_status->public) { |
|
60 | 60 | $this->is_public = true; |
61 | 61 | } |
62 | 62 | } |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | /** |
66 | 66 | * @since 2.2.0 |
67 | 67 | */ |
68 | - public function user_can( $user_id ) { |
|
68 | + public function user_can($user_id) { |
|
69 | 69 | |
70 | - if ( $this->is_public ) { |
|
70 | + if ($this->is_public) { |
|
71 | 71 | return true; |
72 | 72 | } |
73 | 73 | |
74 | 74 | // If the post doesn't have a public status, fall back to the caps API. |
75 | - return user_can( $user_id, 'read_post', $this->post_id ); |
|
75 | + return user_can($user_id, 'read_post', $this->post_id); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | $this->entity_id = $entity_id; |
63 | 63 | $this->context = $context; |
64 | 64 | |
65 | - foreach ( $restrictions as $restriction ) { |
|
66 | - if ( $restriction->applies() ) { |
|
65 | + foreach ($restrictions as $restriction) { |
|
66 | + if ($restriction->applies()) { |
|
67 | 67 | $this->restrictions[] = $restriction; |
68 | 68 | } |
69 | 69 | } |
@@ -80,28 +80,28 @@ discard block |
||
80 | 80 | /** |
81 | 81 | * @since 2.2.0 |
82 | 82 | */ |
83 | - public function user_can( $user_id ) { |
|
83 | + public function user_can($user_id) { |
|
84 | 84 | |
85 | - if ( empty( $this->restrictions ) ) { |
|
85 | + if (empty($this->restrictions)) { |
|
86 | 86 | return true; |
87 | 87 | } |
88 | 88 | |
89 | - if ( $this->context ) { |
|
89 | + if ($this->context) { |
|
90 | 90 | /** @var WordPoints_Entity_Contexts $contexts */ |
91 | - $contexts = wordpoints_entities()->get_sub_app( 'contexts' ); |
|
92 | - $contexts->switch_to( $this->context ); |
|
91 | + $contexts = wordpoints_entities()->get_sub_app('contexts'); |
|
92 | + $contexts->switch_to($this->context); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | $can = true; |
96 | 96 | |
97 | - foreach ( $this->restrictions as $restriction ) { |
|
98 | - if ( ! $restriction->user_can( $user_id ) ) { |
|
97 | + foreach ($this->restrictions as $restriction) { |
|
98 | + if ( ! $restriction->user_can($user_id)) { |
|
99 | 99 | $can = false; |
100 | 100 | break; |
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | - if ( isset( $contexts ) ) { |
|
104 | + if (isset($contexts)) { |
|
105 | 105 | $contexts->switch_back(); |
106 | 106 | } |
107 | 107 |
@@ -65,9 +65,9 @@ |
||
65 | 65 | __METHOD__ |
66 | 66 | , '2.2.0' |
67 | 67 | , esc_html( get_class( $this->entity ) ) |
68 | - . ' implements the WordPoints_Entity_Restricted_VisibilityI' |
|
69 | - . ' interface, which has been deprecated. Use the entity' |
|
70 | - . ' restrictions API instead.' |
|
68 | + . ' implements the WordPoints_Entity_Restricted_VisibilityI' |
|
69 | + . ' interface, which has been deprecated. Use the entity' |
|
70 | + . ' restrictions API instead.' |
|
71 | 71 | ); |
72 | 72 | |
73 | 73 | $this->restricted_entity = $this->entity; |
@@ -47,24 +47,24 @@ discard block |
||
47 | 47 | /** |
48 | 48 | * @since 2.2.0 |
49 | 49 | */ |
50 | - public function __construct( $entity_id, array $hierarchy ) { |
|
50 | + public function __construct($entity_id, array $hierarchy) { |
|
51 | 51 | |
52 | 52 | $this->entity_id = $entity_id; |
53 | 53 | |
54 | - $entity = wordpoints_entities()->get( $hierarchy[0] ); |
|
54 | + $entity = wordpoints_entities()->get($hierarchy[0]); |
|
55 | 55 | |
56 | - if ( ! $entity instanceof WordPoints_Entity ) { |
|
56 | + if ( ! $entity instanceof WordPoints_Entity) { |
|
57 | 57 | return; |
58 | 58 | } |
59 | 59 | |
60 | 60 | $this->entity = $entity; |
61 | 61 | |
62 | - if ( $this->entity instanceof WordPoints_Entity_Restricted_VisibilityI ) { |
|
62 | + if ($this->entity instanceof WordPoints_Entity_Restricted_VisibilityI) { |
|
63 | 63 | |
64 | 64 | _deprecated_argument( |
65 | 65 | __METHOD__ |
66 | 66 | , '2.2.0' |
67 | - , esc_html( get_class( $this->entity ) ) |
|
67 | + , esc_html(get_class($this->entity)) |
|
68 | 68 | . ' implements the WordPoints_Entity_Restricted_VisibilityI' |
69 | 69 | . ' interface, which has been deprecated. Use the entity' |
70 | 70 | . ' restrictions API instead.' |
@@ -77,18 +77,18 @@ discard block |
||
77 | 77 | /** |
78 | 78 | * @since 2.2.0 |
79 | 79 | */ |
80 | - public function user_can( $user_id ) { |
|
80 | + public function user_can($user_id) { |
|
81 | 81 | |
82 | 82 | $can_view = true; |
83 | 83 | |
84 | - if ( $this->restricted_entity ) { |
|
84 | + if ($this->restricted_entity) { |
|
85 | 85 | $can_view = $this->restricted_entity->user_can_view( |
86 | 86 | $user_id |
87 | 87 | , $this->entity_id |
88 | 88 | ); |
89 | 89 | } |
90 | 90 | |
91 | - if ( $this->entity ) { |
|
91 | + if ($this->entity) { |
|
92 | 92 | |
93 | 93 | /** |
94 | 94 | * Filter whether a user can view an entity. |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | $can_view = apply_filters_deprecated( |
105 | 105 | 'wordpoints_entity_user_can_view' |
106 | - , array( $can_view, $user_id, $this->entity_id, $this->entity ) |
|
106 | + , array($can_view, $user_id, $this->entity_id, $this->entity) |
|
107 | 107 | , '2.2.0' |
108 | 108 | , false |
109 | 109 | , 'Use the entity restrictions API instead.' |
@@ -27,13 +27,13 @@ discard block |
||
27 | 27 | /** |
28 | 28 | * @since 2.2.0 |
29 | 29 | */ |
30 | - public function __construct( $entity_id, array $hierarchy ) { |
|
30 | + public function __construct($entity_id, array $hierarchy) { |
|
31 | 31 | |
32 | - if ( $entity_id ) { |
|
32 | + if ($entity_id) { |
|
33 | 33 | |
34 | - $post = get_post( $entity_id ); |
|
34 | + $post = get_post($entity_id); |
|
35 | 35 | |
36 | - if ( $post && $post->post_password ) { |
|
36 | + if ($post && $post->post_password) { |
|
37 | 37 | $this->has_password = true; |
38 | 38 | } |
39 | 39 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | /** |
43 | 43 | * @since 2.2.0 |
44 | 44 | */ |
45 | - public function user_can( $user_id ) { |
|
45 | + public function user_can($user_id) { |
|
46 | 46 | return ! $this->has_password; |
47 | 47 | } |
48 | 48 |
@@ -20,9 +20,9 @@ |
||
20 | 20 | */ |
21 | 21 | protected function get_post_id() { |
22 | 22 | |
23 | - $comment = get_comment( $this->entity_id ); |
|
23 | + $comment = get_comment($this->entity_id); |
|
24 | 24 | |
25 | - if ( $comment ) { |
|
25 | + if ($comment) { |
|
26 | 26 | return $comment->comment_post_ID; |
27 | 27 | } |
28 | 28 |
@@ -30,14 +30,14 @@ |
||
30 | 30 | /** |
31 | 31 | * @since 2.2.0 |
32 | 32 | */ |
33 | - public function __construct( $entity_id, array $hierarchy ) { |
|
34 | - $this->is_registered = wordpoints_entities()->is_registered( $hierarchy[0] ); |
|
33 | + public function __construct($entity_id, array $hierarchy) { |
|
34 | + $this->is_registered = wordpoints_entities()->is_registered($hierarchy[0]); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | 38 | * @since 2.2.0 |
39 | 39 | */ |
40 | - public function user_can( $user_id ) { |
|
40 | + public function user_can($user_id) { |
|
41 | 41 | return $this->is_registered; |
42 | 42 | } |
43 | 43 |
@@ -29,12 +29,12 @@ discard block |
||
29 | 29 | /** |
30 | 30 | * @since 2.1.0 |
31 | 31 | */ |
32 | - protected function get_entity( $id ) { |
|
32 | + protected function get_entity($id) { |
|
33 | 33 | |
34 | 34 | // We must do this because the $id parameter is expected by reference. |
35 | - $comment = get_comment( $id ); |
|
35 | + $comment = get_comment($id); |
|
36 | 36 | |
37 | - if ( ! $comment ) { |
|
37 | + if ( ! $comment) { |
|
38 | 38 | return false; |
39 | 39 | } |
40 | 40 | |
@@ -44,30 +44,30 @@ discard block |
||
44 | 44 | /** |
45 | 45 | * @since 2.1.0 |
46 | 46 | */ |
47 | - protected function get_entity_human_id( $entity ) { |
|
48 | - return get_comment_excerpt( $entity->comment_ID ); |
|
47 | + protected function get_entity_human_id($entity) { |
|
48 | + return get_comment_excerpt($entity->comment_ID); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
52 | 52 | * @since 2.1.0 |
53 | 53 | */ |
54 | 54 | public function get_title() { |
55 | - return __( 'Comment', 'wordpoints' ); |
|
55 | + return __('Comment', 'wordpoints'); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
59 | 59 | * @since 2.1.0 |
60 | 60 | * @deprecated 2.2.0 Use entity restrictions API instead. |
61 | 61 | */ |
62 | - public function user_can_view( $user_id, $id ) { |
|
62 | + public function user_can_view($user_id, $id) { |
|
63 | 63 | |
64 | - _deprecated_function( __METHOD__, '2.2.0' ); |
|
64 | + _deprecated_function(__METHOD__, '2.2.0'); |
|
65 | 65 | |
66 | 66 | /** @var WordPoints_Entity_Restrictions $restrictions */ |
67 | - $restrictions = wordpoints_entities()->get_sub_app( 'restrictions' ); |
|
68 | - $restriction = $restrictions->get( $id, $this->get_slug(), 'view' ); |
|
67 | + $restrictions = wordpoints_entities()->get_sub_app('restrictions'); |
|
68 | + $restriction = $restrictions->get($id, $this->get_slug(), 'view'); |
|
69 | 69 | |
70 | - return $restriction->user_can( $user_id ); |
|
70 | + return $restriction->user_can($user_id); |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 |
@@ -29,7 +29,7 @@ |
||
29 | 29 | * |
30 | 30 | * @return bool Whether the user can view the entity. |
31 | 31 | */ |
32 | - public function user_can_view( $user_id, $id ); |
|
32 | + public function user_can_view($user_id, $id); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | // EOF |