@@ -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 |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @param WordPoints_Entity $entity An entity. |
35 | 35 | */ |
36 | - public function add_entity( WordPoints_Entity $entity ); |
|
36 | + public function add_entity(WordPoints_Entity $entity); |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Remove an entity from the top of the hierarchy. |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @param string $slug The slug of the entity to remove. |
44 | 44 | */ |
45 | - public function remove_entity( $slug ); |
|
45 | + public function remove_entity($slug); |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * Descend to a child of the current entity/entity child. |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @return bool Whether the descent was successful. |
55 | 55 | */ |
56 | - public function descend( $child_slug ); |
|
56 | + public function descend($child_slug); |
|
57 | 57 | |
58 | 58 | /** |
59 | 59 | * Ascend to the parent of the current entity/entity child. |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @return WordPoints_EntityishI|null The entity/child, or null if not found. |
84 | 84 | */ |
85 | - public function get_from_hierarchy( array $hierarchy ); |
|
85 | + public function get_from_hierarchy(array $hierarchy); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | // EOF |
@@ -32,6 +32,7 @@ discard block |
||
32 | 32 | * @since 2.1.0 |
33 | 33 | * |
34 | 34 | * @param WordPoints_Entity $entity An entity. |
35 | + * @return void |
|
35 | 36 | */ |
36 | 37 | public function add_entity( WordPoints_Entity $entity ); |
37 | 38 | |
@@ -41,6 +42,7 @@ discard block |
||
41 | 42 | * @since 2.1.0 |
42 | 43 | * |
43 | 44 | * @param string $slug The slug of the entity to remove. |
45 | + * @return void |
|
44 | 46 | */ |
45 | 47 | public function remove_entity( $slug ); |
46 | 48 |
@@ -17,20 +17,20 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * @since 2.1.0 |
19 | 19 | */ |
20 | - public function __construct( $slug ) { |
|
20 | + public function __construct($slug) { |
|
21 | 21 | |
22 | - parent::__construct( $slug ); |
|
22 | + parent::__construct($slug); |
|
23 | 23 | |
24 | - $parts = wordpoints_parse_dynamic_slug( $this->slug ); |
|
24 | + $parts = wordpoints_parse_dynamic_slug($this->slug); |
|
25 | 25 | |
26 | - if ( $parts['dynamic'] ) { |
|
26 | + if ($parts['dynamic']) { |
|
27 | 27 | |
28 | - $parsed = $this->parse_slug( $this->related_entity_slug ); |
|
28 | + $parsed = $this->parse_slug($this->related_entity_slug); |
|
29 | 29 | |
30 | 30 | $this->primary_entity_slug = "{$this->primary_entity_slug}\\{$parts['dynamic']}"; |
31 | 31 | $this->related_entity_slug = "{$parsed['slug']}\\{$parts['dynamic']}"; |
32 | 32 | |
33 | - if ( $parsed['is_array'] ) { |
|
33 | + if ($parsed['is_array']) { |
|
34 | 34 | $this->related_entity_slug .= '{}'; |
35 | 35 | } |
36 | 36 | } |
@@ -41,11 +41,11 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function get_title() { |
43 | 43 | |
44 | - $parsed = $this->parse_slug( $this->related_entity_slug ); |
|
44 | + $parsed = $this->parse_slug($this->related_entity_slug); |
|
45 | 45 | |
46 | - $entity = wordpoints_entities()->get( $parsed['slug'] ); |
|
46 | + $entity = wordpoints_entities()->get($parsed['slug']); |
|
47 | 47 | |
48 | - if ( $entity instanceof WordPoints_Entity ) { |
|
48 | + if ($entity instanceof WordPoints_Entity) { |
|
49 | 49 | return $entity->get_title(); |
50 | 50 | } else { |
51 | 51 | return $this->related_entity_slug; |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @return mixed The attribute value. |
41 | 41 | */ |
42 | - abstract protected function get_attr_value_from_entity( WordPoints_Entity $entity ); |
|
42 | + abstract protected function get_attr_value_from_entity(WordPoints_Entity $entity); |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * Get the data type of this attribute's values. |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return bool Whether the value was set correctly. |
68 | 68 | */ |
69 | - public function set_the_value_from_entity( WordPoints_Entity $entity ) { |
|
69 | + public function set_the_value_from_entity(WordPoints_Entity $entity) { |
|
70 | 70 | |
71 | - $this->the_value = $this->get_attr_value_from_entity( $entity ); |
|
71 | + $this->the_value = $this->get_attr_value_from_entity($entity); |
|
72 | 72 | |
73 | 73 | return true; |
74 | 74 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | * |
24 | 24 | * @return bool Whether the value was set successfully. |
25 | 25 | */ |
26 | - public function set_the_value_from_entity( WordPoints_Entity $entity ); |
|
26 | + public function set_the_value_from_entity(WordPoints_Entity $entity); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | // EOF |