@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return bool Whether the event was updated successfully. |
66 | 66 | */ |
67 | - public function update_event_slug( $event_slug ); |
|
67 | + public function update_event_slug($event_slug); |
|
68 | 68 | |
69 | 69 | /** |
70 | 70 | * Get the slug of the reactor this reaction is for. |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @return mixed|false The meta value, or false if not found. |
108 | 108 | */ |
109 | - public function get_meta( $key ); |
|
109 | + public function get_meta($key); |
|
110 | 110 | |
111 | 111 | /** |
112 | 112 | * Add a piece of metadata for this reaction. |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @return bool Whether the metadata was added successfully. |
122 | 122 | */ |
123 | - public function add_meta( $key, $value ); |
|
123 | + public function add_meta($key, $value); |
|
124 | 124 | |
125 | 125 | /** |
126 | 126 | * Update a piece of metadata for this reaction. |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @return bool Whether the metadata was updated successfully. |
134 | 134 | */ |
135 | - public function update_meta( $key, $value ); |
|
135 | + public function update_meta($key, $value); |
|
136 | 136 | |
137 | 137 | /** |
138 | 138 | * Delete a piece of metadata for this reaction. |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @return bool Whether the metadata was deleted successfully. |
145 | 145 | */ |
146 | - public function delete_meta( $key ); |
|
146 | + public function delete_meta($key); |
|
147 | 147 | |
148 | 148 | /** |
149 | 149 | * Get all of the metadata for this reaction. |
@@ -28,7 +28,7 @@ |
||
28 | 28 | * |
29 | 29 | * @param string $slug The event slug. |
30 | 30 | */ |
31 | - public function __construct( $slug ) { |
|
31 | + public function __construct($slug) { |
|
32 | 32 | |
33 | 33 | $this->slug = $slug; |
34 | 34 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @param string $slug The slug of the entity/entity-child. |
41 | 41 | */ |
42 | - public function __construct( $slug ) { |
|
42 | + public function __construct($slug) { |
|
43 | 43 | $this->slug = $slug; |
44 | 44 | } |
45 | 45 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | /** |
61 | 61 | * @since 2.1.0 |
62 | 62 | */ |
63 | - public function set_the_value( $value ) { |
|
63 | + public function set_the_value($value) { |
|
64 | 64 | |
65 | 65 | $this->the_value = $value; |
66 | 66 |
@@ -26,10 +26,10 @@ discard block |
||
26 | 26 | /** |
27 | 27 | * @since 2.2.0 |
28 | 28 | */ |
29 | - public function switch_to( $id ) { |
|
29 | + public function switch_to($id) { |
|
30 | 30 | |
31 | - if ( function_exists( 'switch_to_network' ) ) { |
|
32 | - return switch_to_network( $id ); |
|
31 | + if (function_exists('switch_to_network')) { |
|
32 | + return switch_to_network($id); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | return false; |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function switch_back() { |
42 | 42 | |
43 | - if ( function_exists( 'restore_current_network' ) ) { |
|
43 | + if (function_exists('restore_current_network')) { |
|
44 | 44 | return restore_current_network(); |
45 | 45 | } |
46 | 46 |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function get_current_id() { |
28 | 28 | |
29 | - if ( ! is_multisite() ) { |
|
29 | + if ( ! is_multisite()) { |
|
30 | 30 | return 1; |
31 | 31 | } |
32 | 32 | |
33 | - if ( wordpoints_is_network_context() ) { |
|
33 | + if (wordpoints_is_network_context()) { |
|
34 | 34 | return false; |
35 | 35 | } |
36 | 36 | |
@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | /** |
41 | 41 | * @since 2.2.0 |
42 | 42 | */ |
43 | - public function switch_to( $id ) { |
|
43 | + public function switch_to($id) { |
|
44 | 44 | |
45 | - if ( ! is_multisite() ) { |
|
45 | + if ( ! is_multisite()) { |
|
46 | 46 | return false; |
47 | 47 | } |
48 | 48 | |
49 | - return switch_to_blog( $id ); |
|
49 | + return switch_to_blog($id); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function switch_back() { |
56 | 56 | |
57 | - if ( ! is_multisite() ) { |
|
57 | + if ( ! is_multisite()) { |
|
58 | 58 | return false; |
59 | 59 | } |
60 | 60 |
@@ -37,8 +37,8 @@ |
||
37 | 37 | /** |
38 | 38 | * @since 2.1.0 |
39 | 39 | */ |
40 | - protected function get_attr_value_from_entity( WordPoints_Entity $entity ) { |
|
41 | - return $entity->get_the_attr_value( $this->field ); |
|
40 | + protected function get_attr_value_from_entity(WordPoints_Entity $entity) { |
|
41 | + return $entity->get_the_attr_value($this->field); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -72,16 +72,16 @@ discard block |
||
72 | 72 | * @return array The parsed slug in the 'slug' key and whether it is an array in |
73 | 73 | * the 'is_array' key. |
74 | 74 | */ |
75 | - protected function parse_slug( $slug ) { |
|
75 | + protected function parse_slug($slug) { |
|
76 | 76 | |
77 | 77 | $is_array = false; |
78 | 78 | |
79 | - if ( '{}' === substr( $slug, -2 ) ) { |
|
79 | + if ('{}' === substr($slug, -2)) { |
|
80 | 80 | $is_array = true; |
81 | - $slug = substr( $slug, 0, -2 ); |
|
81 | + $slug = substr($slug, 0, -2); |
|
82 | 82 | } |
83 | 83 | |
84 | - return array( 'slug' => $slug, 'is_array' => $is_array ); |
|
84 | + return array('slug' => $slug, 'is_array' => $is_array); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @return mixed The ID (array of or IDs) of the related entity (or entities). |
95 | 95 | */ |
96 | - protected function get_related_entity_ids( WordPoints_Entity $entity ) { |
|
97 | - return $entity->get_the_attr_value( $this->related_ids_field ); |
|
96 | + protected function get_related_entity_ids(WordPoints_Entity $entity) { |
|
97 | + return $entity->get_the_attr_value($this->related_ids_field); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | // |
@@ -133,22 +133,22 @@ discard block |
||
133 | 133 | * @return WordPoints_Entity_Array|WordPoints_Entity|false An entity or array of |
134 | 134 | * entities, or false. |
135 | 135 | */ |
136 | - public function get_child( $child_slug ) { |
|
136 | + public function get_child($child_slug) { |
|
137 | 137 | |
138 | - if ( $child_slug !== $this->get_related_entity_slug() ) { |
|
138 | + if ($child_slug !== $this->get_related_entity_slug()) { |
|
139 | 139 | return false; |
140 | 140 | } |
141 | 141 | |
142 | - $parsed_slug = $this->parse_slug( $child_slug ); |
|
142 | + $parsed_slug = $this->parse_slug($child_slug); |
|
143 | 143 | |
144 | - if ( $parsed_slug['is_array'] ) { |
|
145 | - $child = new WordPoints_Entity_Array( $parsed_slug['slug'] ); |
|
144 | + if ($parsed_slug['is_array']) { |
|
145 | + $child = new WordPoints_Entity_Array($parsed_slug['slug']); |
|
146 | 146 | } else { |
147 | - $child = wordpoints_entities()->get( $parsed_slug['slug'] ); |
|
147 | + $child = wordpoints_entities()->get($parsed_slug['slug']); |
|
148 | 148 | } |
149 | 149 | |
150 | - if ( isset( $this->the_value ) ) { |
|
151 | - $child->set_the_value( $this->the_value ); |
|
150 | + if (isset($this->the_value)) { |
|
151 | + $child->set_the_value($this->the_value); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | return $child; |
@@ -157,13 +157,13 @@ discard block |
||
157 | 157 | /** |
158 | 158 | * @since 2.1.0 |
159 | 159 | */ |
160 | - public function set_the_value_from_entity( WordPoints_Entity $entity ) { |
|
160 | + public function set_the_value_from_entity(WordPoints_Entity $entity) { |
|
161 | 161 | |
162 | 162 | $this->the_value = null; |
163 | 163 | |
164 | - $related_ids = $this->get_related_entity_ids( $entity ); |
|
164 | + $related_ids = $this->get_related_entity_ids($entity); |
|
165 | 165 | |
166 | - if ( ! $related_ids ) { |
|
166 | + if ( ! $related_ids) { |
|
167 | 167 | return false; |
168 | 168 | } |
169 | 169 |
@@ -45,23 +45,23 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @return bool Whether the context was switched to successfully. |
47 | 47 | */ |
48 | - public function switch_to( $context_guid ) { |
|
48 | + public function switch_to($context_guid) { |
|
49 | 49 | |
50 | 50 | /** @var WordPoints_Entity_Context[] $to_switch */ |
51 | 51 | $to_switch = array(); |
52 | 52 | |
53 | 53 | // Loop through the contexts from highest to lowest. |
54 | - $context_guid = array_reverse( $context_guid ); |
|
54 | + $context_guid = array_reverse($context_guid); |
|
55 | 55 | |
56 | - foreach ( $context_guid as $slug => $id ) { |
|
56 | + foreach ($context_guid as $slug => $id) { |
|
57 | 57 | |
58 | - $context = $this->get( $slug ); |
|
58 | + $context = $this->get($slug); |
|
59 | 59 | |
60 | - if ( ! $context instanceof WordPoints_Entity_Context ) { |
|
60 | + if ( ! $context instanceof WordPoints_Entity_Context) { |
|
61 | 61 | return false; |
62 | 62 | } |
63 | 63 | |
64 | - $to_switch[ $slug ] = $context; |
|
64 | + $to_switch[$slug] = $context; |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | $switched = array(); |
@@ -69,22 +69,22 @@ discard block |
||
69 | 69 | // We use two separate loops so as to not begin switching contexts until we |
70 | 70 | // are sure that we can complete the operation, thus consolidating the back- |
71 | 71 | // switching code that runs in the case of a failure. |
72 | - foreach ( $to_switch as $slug => $context ) { |
|
72 | + foreach ($to_switch as $slug => $context) { |
|
73 | 73 | |
74 | - if ( $context_guid[ $slug ] === $context->get_current_id() ) { |
|
74 | + if ($context_guid[$slug] === $context->get_current_id()) { |
|
75 | 75 | |
76 | - $switched[ $slug ] = false; |
|
76 | + $switched[$slug] = false; |
|
77 | 77 | |
78 | - } elseif ( $context->switch_to( $context_guid[ $slug ] ) ) { |
|
78 | + } elseif ($context->switch_to($context_guid[$slug])) { |
|
79 | 79 | |
80 | - $switched[ $slug ] = true; |
|
80 | + $switched[$slug] = true; |
|
81 | 81 | |
82 | 82 | } else { |
83 | 83 | |
84 | 84 | // Failed to switch, reset everything back the way it was. |
85 | - foreach ( $switched as $switched_slug => $is_switched ) { |
|
86 | - if ( $is_switched ) { |
|
87 | - $to_switch[ $switched_slug ]->switch_back(); |
|
85 | + foreach ($switched as $switched_slug => $is_switched) { |
|
86 | + if ($is_switched) { |
|
87 | + $to_switch[$switched_slug]->switch_back(); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
@@ -110,15 +110,15 @@ discard block |
||
110 | 110 | */ |
111 | 111 | public function switch_back() { |
112 | 112 | |
113 | - $switched = array_pop( $this->switched ); |
|
113 | + $switched = array_pop($this->switched); |
|
114 | 114 | |
115 | - if ( ! $switched ) { |
|
115 | + if ( ! $switched) { |
|
116 | 116 | return false; |
117 | 117 | } |
118 | 118 | |
119 | - foreach ( $switched as $slug => $is_switched ) { |
|
120 | - if ( $is_switched ) { |
|
121 | - if ( ! $this->get( $slug )->switch_back() ) { |
|
119 | + foreach ($switched as $slug => $is_switched) { |
|
120 | + if ($is_switched) { |
|
121 | + if ( ! $this->get($slug)->switch_back()) { |
|
122 | 122 | return false; |
123 | 123 | } |
124 | 124 | } |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function get_title() { |
43 | 43 | |
44 | - $post_type = get_post_type_object( substr( $this->slug, 5 /* post\ */ ) ); |
|
44 | + $post_type = get_post_type_object(substr($this->slug, 5 /* post\ */)); |
|
45 | 45 | |
46 | - if ( $post_type ) { |
|
46 | + if ($post_type) { |
|
47 | 47 | return $post_type->labels->singular_name; |
48 | 48 | } else { |
49 | 49 | return $this->slug; |
@@ -54,15 +54,15 @@ discard block |
||
54 | 54 | * @since 2.1.0 |
55 | 55 | * @deprecated 2.2.0 Use entity restrictions API instead. |
56 | 56 | */ |
57 | - public function user_can_view( $user_id, $id ) { |
|
57 | + public function user_can_view($user_id, $id) { |
|
58 | 58 | |
59 | - _deprecated_function( __METHOD__, '2.2.0' ); |
|
59 | + _deprecated_function(__METHOD__, '2.2.0'); |
|
60 | 60 | |
61 | 61 | /** @var WordPoints_Entity_Restrictions $restrictions */ |
62 | - $restrictions = wordpoints_entities()->get_sub_app( 'restrictions' ); |
|
63 | - $restriction = $restrictions->get( $id, $this->get_slug(), 'view' ); |
|
62 | + $restrictions = wordpoints_entities()->get_sub_app('restrictions'); |
|
63 | + $restriction = $restrictions->get($id, $this->get_slug(), 'view'); |
|
64 | 64 | |
65 | - return $restriction->user_can( $user_id ); |
|
65 | + return $restriction->user_can($user_id); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 |