@@ -17,14 +17,14 @@ |
||
17 | 17 | /** |
18 | 18 | * @since 1.0.0 |
19 | 19 | */ |
20 | - public function validate_value( $value ) { |
|
20 | + public function validate_value($value) { |
|
21 | 21 | |
22 | - wordpoints_int( $value ); |
|
22 | + wordpoints_int($value); |
|
23 | 23 | |
24 | - if ( false === $value ) { |
|
24 | + if (false === $value) { |
|
25 | 25 | return new WP_Error( |
26 | 26 | 'not_integer' |
27 | - , __( '%s must be an integer.', 'wordpoints' ) |
|
27 | + , __('%s must be an integer.', 'wordpoints') |
|
28 | 28 | ); |
29 | 29 | } |
30 | 30 |
@@ -20,12 +20,12 @@ |
||
20 | 20 | /** |
21 | 21 | * @since 1.0.0 |
22 | 22 | */ |
23 | - public function validate_value( $value ) { |
|
23 | + public function validate_value($value) { |
|
24 | 24 | |
25 | - if ( ! is_string( $value ) ) { |
|
25 | + if ( ! is_string($value)) { |
|
26 | 26 | return new WP_Error( |
27 | 27 | 'not_string' |
28 | - , __( '%s must be a text value.', 'wordpoints' ) |
|
28 | + , __('%s must be a text value.', 'wordpoints') |
|
29 | 29 | ); |
30 | 30 | } |
31 | 31 |
@@ -42,7 +42,7 @@ |
||
42 | 42 | * |
43 | 43 | * @return mixed|WP_Error The validated value or a WP_Error on failure. |
44 | 44 | */ |
45 | - public function validate_value( $value ); |
|
45 | + public function validate_value($value); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | // EOF |
@@ -52,12 +52,12 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @param string $entity_slug The slug of the entity type. |
54 | 54 | */ |
55 | - public function __construct( $entity_slug ) { |
|
55 | + public function __construct($entity_slug) { |
|
56 | 56 | |
57 | 57 | $this->entity_slug = $entity_slug; |
58 | - $this->entity_object = wordpoints_entities()->get( $this->entity_slug ); |
|
58 | + $this->entity_object = wordpoints_entities()->get($this->entity_slug); |
|
59 | 59 | |
60 | - parent::__construct( $this->entity_slug . '{}' ); |
|
60 | + parent::__construct($this->entity_slug.'{}'); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -80,19 +80,19 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return bool Whether the value was set successfully. |
82 | 82 | */ |
83 | - public function set_the_value( $values ) { |
|
83 | + public function set_the_value($values) { |
|
84 | 84 | |
85 | 85 | $this->the_entities = $this->the_value = array(); |
86 | 86 | |
87 | - if ( ! ( $this->entity_object instanceof WordPoints_Entity ) ) { |
|
87 | + if ( ! ($this->entity_object instanceof WordPoints_Entity)) { |
|
88 | 88 | return false; |
89 | 89 | } |
90 | 90 | |
91 | - foreach ( $values as $value ) { |
|
91 | + foreach ($values as $value) { |
|
92 | 92 | |
93 | 93 | $entity = clone $this->entity_object; |
94 | 94 | |
95 | - if ( $entity->set_the_value( $value ) ) { |
|
95 | + if ($entity->set_the_value($value)) { |
|
96 | 96 | $this->the_entities[] = $entity; |
97 | 97 | $this->the_value[] = $entity->get_the_id(); |
98 | 98 | } |
@@ -117,16 +117,16 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function get_title() { |
119 | 119 | |
120 | - if ( $this->entity_object ) { |
|
120 | + if ($this->entity_object) { |
|
121 | 121 | |
122 | 122 | return sprintf( |
123 | 123 | // translators: the singular name of an item |
124 | - __( '%s Collection', 'wordpoints' ) |
|
124 | + __('%s Collection', 'wordpoints') |
|
125 | 125 | , $this->entity_object->get_title() |
126 | 126 | ); |
127 | 127 | |
128 | 128 | } else { |
129 | - return __( 'Item Collection', 'wordpoints' ); |
|
129 | + return __('Item Collection', 'wordpoints'); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | } |
@@ -78,9 +78,9 @@ |
||
78 | 78 | * |
79 | 79 | * @return bool Whether the value was set correctly. |
80 | 80 | */ |
81 | - public function set_the_value_from_entity( WordPoints_Entity $entity ) { |
|
81 | + public function set_the_value_from_entity(WordPoints_Entity $entity) { |
|
82 | 82 | |
83 | - $this->the_value = $entity->get_the_attr_value( $this->get_field() ); |
|
83 | + $this->the_value = $entity->get_the_attr_value($this->get_field()); |
|
84 | 84 | |
85 | 85 | return true; |
86 | 86 | } |
@@ -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 |
@@ -24,12 +24,12 @@ discard block |
||
24 | 24 | /** |
25 | 25 | * @since 1.0.0 |
26 | 26 | */ |
27 | - protected function get_entity( $id ) { |
|
27 | + protected function get_entity($id) { |
|
28 | 28 | |
29 | 29 | // We must do this because the $id parameter is expected by reference. |
30 | - $comment = get_comment( $id ); |
|
30 | + $comment = get_comment($id); |
|
31 | 31 | |
32 | - if ( ! $comment ) { |
|
32 | + if ( ! $comment) { |
|
33 | 33 | return false; |
34 | 34 | } |
35 | 35 | |
@@ -39,28 +39,28 @@ discard block |
||
39 | 39 | /** |
40 | 40 | * @since 1.0.0 |
41 | 41 | */ |
42 | - protected function get_entity_human_id( $entity ) { |
|
42 | + protected function get_entity_human_id($entity) { |
|
43 | 43 | // An extra space is added to the end in WP <4.4 if the comment is short. |
44 | 44 | // See https://core.trac.wordpress.org/ticket/27526#comment:5 |
45 | - return rtrim( get_comment_excerpt( $entity->comment_ID ) ); |
|
45 | + return rtrim(get_comment_excerpt($entity->comment_ID)); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
49 | 49 | * @since 1.0.0 |
50 | 50 | */ |
51 | 51 | public function get_title() { |
52 | - return __( 'Comment', 'wordpoints' ); |
|
52 | + return __('Comment', 'wordpoints'); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
56 | 56 | * @since 1.0.0 |
57 | 57 | */ |
58 | - public function user_can_view( $user_id, $id ) { |
|
58 | + public function user_can_view($user_id, $id) { |
|
59 | 59 | |
60 | - $comment = get_comment( $id ); |
|
60 | + $comment = get_comment($id); |
|
61 | 61 | |
62 | - if ( $comment ) { |
|
63 | - return user_can( $user_id, 'read_post', $comment->comment_post_ID ); |
|
62 | + if ($comment) { |
|
63 | + return user_can($user_id, 'read_post', $comment->comment_post_ID); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | return false; |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @param WordPoints_Entity|null $entity An entity. |
50 | 50 | */ |
51 | - public function __construct( WordPoints_Entity $entity = null ) { |
|
52 | - if ( isset( $entity ) ) { |
|
53 | - $this->add_entity( $entity ); |
|
51 | + public function __construct(WordPoints_Entity $entity = null) { |
|
52 | + if (isset($entity)) { |
|
53 | + $this->add_entity($entity); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
@@ -64,20 +64,20 @@ discard block |
||
64 | 64 | /** |
65 | 65 | * @since 1.0.0 |
66 | 66 | */ |
67 | - public function add_entity( WordPoints_Entity $entity ) { |
|
67 | + public function add_entity(WordPoints_Entity $entity) { |
|
68 | 68 | |
69 | - $this->entities[ $entity->get_slug() ] = $entity; |
|
69 | + $this->entities[$entity->get_slug()] = $entity; |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
73 | 73 | * @since 1.0.0 |
74 | 74 | */ |
75 | - public function remove_entity( $slug ) { |
|
75 | + public function remove_entity($slug) { |
|
76 | 76 | |
77 | - unset( $this->entities[ $slug ] ); |
|
77 | + unset($this->entities[$slug]); |
|
78 | 78 | |
79 | 79 | if ( |
80 | - isset( $this->hierarchy[0] ) |
|
80 | + isset($this->hierarchy[0]) |
|
81 | 81 | && $this->hierarchy[0]->get_slug() === $slug |
82 | 82 | ) { |
83 | 83 | $this->current = null; |
@@ -88,30 +88,30 @@ discard block |
||
88 | 88 | /** |
89 | 89 | * @since 1.0.0 |
90 | 90 | */ |
91 | - public function descend( $child_slug ) { |
|
91 | + public function descend($child_slug) { |
|
92 | 92 | |
93 | - if ( ! $this->current ) { |
|
93 | + if ( ! $this->current) { |
|
94 | 94 | |
95 | - if ( ! isset( $this->entities[ $child_slug ] ) ) { |
|
95 | + if ( ! isset($this->entities[$child_slug])) { |
|
96 | 96 | return false; |
97 | 97 | } |
98 | 98 | |
99 | - $child = $this->entities[ $child_slug ]; |
|
99 | + $child = $this->entities[$child_slug]; |
|
100 | 100 | |
101 | 101 | } else { |
102 | 102 | |
103 | - if ( ! ( $this->current instanceof WordPoints_Entity_ParentI ) ) { |
|
103 | + if ( ! ($this->current instanceof WordPoints_Entity_ParentI)) { |
|
104 | 104 | return false; |
105 | 105 | } |
106 | 106 | |
107 | - $child = $this->current->get_child( $child_slug ); |
|
107 | + $child = $this->current->get_child($child_slug); |
|
108 | 108 | |
109 | - if ( ! $child ) { |
|
109 | + if ( ! $child) { |
|
110 | 110 | return false; |
111 | 111 | } |
112 | 112 | } |
113 | 113 | |
114 | - if ( $this->current ) { |
|
114 | + if ($this->current) { |
|
115 | 115 | $this->hierarchy[] = $this->current; |
116 | 116 | } |
117 | 117 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function ascend() { |
127 | 127 | |
128 | - if ( empty( $this->current ) ) { |
|
128 | + if (empty($this->current)) { |
|
129 | 129 | |
130 | 130 | // We're already at the top, some logic is probably wrong. |
131 | 131 | _doing_it_wrong( |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | return false; |
138 | 138 | } |
139 | 139 | |
140 | - $this->current = array_pop( $this->hierarchy ); |
|
140 | + $this->current = array_pop($this->hierarchy); |
|
141 | 141 | |
142 | 142 | return true; |
143 | 143 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | /** |
153 | 153 | * @since 1.0.0 |
154 | 154 | */ |
155 | - public function get_from_hierarchy( array $hierarchy ) { |
|
155 | + public function get_from_hierarchy(array $hierarchy) { |
|
156 | 156 | |
157 | 157 | $backup = $this->hierarchy; |
158 | 158 | $current = $this->current; |
@@ -160,16 +160,16 @@ discard block |
||
160 | 160 | $this->hierarchy = array(); |
161 | 161 | $this->current = null; |
162 | 162 | |
163 | - $slug = reset( $hierarchy ); |
|
163 | + $slug = reset($hierarchy); |
|
164 | 164 | |
165 | - while ( $slug ) { |
|
165 | + while ($slug) { |
|
166 | 166 | |
167 | - if ( ! $this->descend( $slug ) ) { |
|
167 | + if ( ! $this->descend($slug)) { |
|
168 | 168 | $this->current = null; |
169 | 169 | break; |
170 | 170 | } |
171 | 171 | |
172 | - $slug = next( $hierarchy ); |
|
172 | + $slug = next($hierarchy); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | $entityish = $this->current; |
@@ -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 |