PluginProbe
bbPress / 2.6.6
bbPress v2.6.6
trunk 2.0 2.0-beta-1 2.0-beta-2b 2.0-beta-3 2.0-beta-3b 2.0-rc-2 2.0-rc-3 2.0-rc-4 2.0-rc-5 2.0.1 2.0.2 2.0.3 2.1 2.1-beta-1 2.1-rc1 2.1-rc2 2.1-rc3 2.1-rc4 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.2.2 All 71 releases
← All changes | includes/common/engagements.php +197 -211 trunk2.6.6 View file →
@@ -1,8 +1,8 @@
1 1 <?php
2 2
3 3 /**
4 - * bbPress Common Engagements.
4 + * bbPress Common Engagements
5 5 *
6 6 * This file contains the common classes and functions for interacting with the
7 7 * bbPress engagements API. See `includes/users/engagements.php` for more.
8 8 *
@@ -13,14 +13,14 @@
13 13 // Exit if accessed directly
14 14 defined( 'ABSPATH' ) || exit;
15 15
16 16 /**
17 - * Return the strategy used for storing user engagements.
17 + * Return the strategy used for storing user engagements
18 18 *
19 19 * @since 2.6.0 bbPress (r6722)
20 20 *
21 - * @param string $rel_key The key used to index this relationship.
22 - * @param string $rel_type The type of meta to look in.
21 + * @param string $rel_key The key used to index this relationship
22 + * @param string $rel_type The type of meta to look in
23 23 *
24 24 * @return string
25 25 */
26 26 function bbp_user_engagements_interface( $rel_key = '', $rel_type = 'post' ) {
@@ -44,98 +44,98 @@
44 44 */
45 45 public $type = '';
46 46
47 47 /**
48 - * Add a user id to an object.
48 + * Add a user id to an object
49 49 *
50 50 * @since 2.6.0 bbPress (r6722)
51 51 *
52 - * @param int $object_id The object id.
53 - * @param int $user_id The user id.
54 - * @param string $meta_key The relationship key.
55 - * @param string $meta_type The relationship type (usually 'post').
56 - * @param bool $unique Whether meta key should be unique to the object.
52 + * @param int $object_id The object id
53 + * @param int $user_id The user id
54 + * @param string $meta_key The relationship key
55 + * @param string $meta_type The relationship type (usually 'post')
56 + * @param bool $unique Whether meta key should be unique to the object
57 57 *
58 - * @return bool Returns true on success, false on failure.
58 + * @return bool Returns true on success, false on failure
59 59 */
60 60 public function add_user_to_object( $object_id = 0, $user_id = 0, $meta_key = '', $meta_type = 'post', $unique = false ) {
61 - // Intentionally empty
61 +
62 62 }
63 63
64 64 /**
65 - * Remove a user id from an object.
65 + * Remove a user id from an object
66 66 *
67 67 * @since 2.6.0 bbPress (r6722)
68 68 *
69 - * @param int $object_id The object id.
70 - * @param int $user_id The user id.
71 - * @param string $meta_key The relationship key.
72 - * @param string $meta_type The relationship type (usually 'post').
69 + * @param int $object_id The object id
70 + * @param int $user_id The user id
71 + * @param string $meta_key The relationship key
72 + * @param string $meta_type The relationship type (usually 'post')
73 73 *
74 - * @return bool Returns true on success, false on failure.
74 + * @return bool Returns true on success, false on failure
75 75 */
76 76 public function remove_user_from_object( $object_id = 0, $user_id = 0, $meta_key = '', $meta_type = 'post' ) {
77 - // Intentionally empty
77 +
78 78 }
79 79
80 80 /**
81 - * Remove a user id from all objects.
81 + * Remove a user id from all objects
82 82 *
83 83 * @since 2.6.0 bbPress (r6722)
84 84 *
85 - * @param int $user_id The user id.
86 - * @param string $meta_key The relationship key.
87 - * @param string $meta_type The relationship type (usually 'post').
85 + * @param int $user_id The user id
86 + * @param string $meta_key The relationship key
87 + * @param string $meta_type The relationship type (usually 'post')
88 88 *
89 - * @return bool Returns true on success, false on failure.
89 + * @return bool Returns true on success, false on failure
90 90 */
91 91 public function remove_user_from_all_objects( $user_id = 0, $meta_key = '', $meta_type = 'post' ) {
92 - // Intentionally empty
92 +
93 93 }
94 94
95 95 /**
96 - * Remove an object from all users.
96 + * Remove an object from all users
97 97 *
98 98 * @since 2.6.0 bbPress (r6722)
99 99 *
100 - * @param int $object_id The object id.
101 - * @param int $user_id The user id.
102 - * @param string $meta_key The relationship key.
103 - * @param string $meta_type The relationship type (usually 'post').
100 + * @param int $object_id The object id
101 + * @param int $user_id The user id
102 + * @param string $meta_key The relationship key
103 + * @param string $meta_type The relationship type (usually 'post')
104 104 *
105 - * @return bool Returns true on success, false on failure.
105 + * @return bool Returns true on success, false on failure
106 106 */
107 107 public function remove_object_from_all_users( $object_id = 0, $meta_key = '', $meta_type = 'post' ) {
108 - // Intentionally empty
108 +
109 109 }
110 110
111 111 /**
112 - * Remove all users from all objects.
112 + * Remove all users from all objects
113 113 *
114 114 * @since 2.6.0 bbPress (r6722)
115 115 *
116 - * @param string $meta_key The relationship key.
117 - * @param string $meta_type The relationship type (usually 'post').
116 + * @param string $meta_key The relationship key
117 + * @param string $meta_type The relationship type (usually 'post')
118 118 *
119 - * @return bool Returns true on success, false on failure.
119 + * @return bool Returns true on success, false on failure
120 120 */
121 121 public function remove_all_users_from_all_objects( $meta_key = '', $meta_type = 'post' ) {
122 - // Intentionally empty
122 +
123 123 }
124 124
125 125 /**
126 - * Get users of an object.
126 + * Get users of an object
127 127 *
128 128 * @since 2.6.0 bbPress (r6722)
129 129 *
130 - * @param int $object_id The object id.
131 - * @param string $meta_key The key used to index this relationship.
132 - * @param string $meta_type The type of meta to look in.
130 + * @param int $object_id The object id
131 + * @param string $meta_key The key used to index this relationship
132 + * @param string $meta_type The type of meta to look in
133 133 *
134 - * @return array Returns ids of users.
134 + * @return array Returns ids of users
135 135 */
136 136 public function get_users_for_object( $object_id = 0, $meta_key = '', $meta_type = 'post' ) {
137 - // Intentionally empty
137 +
138 138 }
139 139
140 140 /**
141 141 * Get the part of the query responsible for JOINing objects to relationships.
@@ -148,14 +148,14 @@
148 148 *
149 149 * @return array
150 150 */
151 151 public function get_query( $args = array(), $context_key = '', $meta_key = '', $meta_type = 'post' ) {
152 - // Intentionally empty
152 +
153 153 }
154 154 }
155 155
156 156 /**
157 - * Meta strategy for interfacing with User Engagements.
157 + * Meta strategy for interfacing with User Engagements
158 158 *
159 159 * @since 2.6.0 bbPress (r6722)
160 160 */
161 161 class BBP_User_Engagements_Meta extends BBP_User_Engagements_Base {
@@ -169,19 +169,19 @@
169 169 */
170 170 public $type = 'meta';
171 171
172 172 /**
173 - * Add a user id to an object.
173 + * Add a user id to an object
174 174 *
175 175 * @since 2.6.0 bbPress (r6722)
176 176 *
177 - * @param int $object_id The object id.
178 - * @param int $user_id The user id.
179 - * @param string $meta_key The relationship key.
180 - * @param string $meta_type The relationship type (usually 'post').
181 - * @param bool $unique Whether meta key should be unique to the object.
177 + * @param int $object_id The object id
178 + * @param int $user_id The user id
179 + * @param string $meta_key The relationship key
180 + * @param string $meta_type The relationship type (usually 'post')
181 + * @param bool $unique Whether meta key should be unique to the object
182 182 *
183 - * @return bool Returns true on success, false on failure.
183 + * @return bool Returns true on success, false on failure
184 184 */
185 185 public function add_user_to_object( $object_id = 0, $user_id = 0, $meta_key = '', $meta_type = 'post', $unique = false ) {
186 186 return add_metadata( $meta_type, $object_id, $meta_key, $user_id, $unique );
187 187 }
@@ -186,16 +186,16 @@
186 186 return add_metadata( $meta_type, $object_id, $meta_key, $user_id, $unique );
187 187 }
188 188
189 189 /**
190 - * Remove a user id from an object.
190 + * Remove a user id from an object
191 191 *
192 192 * @since 2.6.0 bbPress (r6722)
193 193 *
194 - * @param int $object_id The object id.
195 - * @param int $user_id The user id.
196 - * @param string $meta_key The relationship key.
197 - * @param string $meta_type The relationship type (usually 'post').
194 + * @param int $object_id The object id
195 + * @param int $user_id The user id
196 + * @param string $meta_key The relationship key
197 + * @param string $meta_type The relationship type (usually 'post')
198 198 *
199 199 * @return bool Returns true on success, false on failure
200 200 */
201 201 public function remove_user_from_object( $object_id = 0, $user_id = 0, $meta_key = '', $meta_type = 'post' ) {
@@ -202,17 +202,17 @@
202 202 return delete_metadata( $meta_type, $object_id, $meta_key, $user_id, false );
203 203 }
204 204
205 205 /**
206 - * Remove a user id from all objects.
206 + * Remove a user id from all objects
207 207 *
208 208 * @since 2.6.0 bbPress (r6722)
209 209 *
210 - * @param int $user_id The user id.
211 - * @param string $meta_key The relationship key.
212 - * @param string $meta_type The relationship type (usually 'post').
210 + * @param int $user_id The user id
211 + * @param string $meta_key The relationship key
212 + * @param string $meta_type The relationship type (usually 'post')
213 213 *
214 - * @return bool Returns true on success, false on failure.
214 + * @return bool Returns true on success, false on failure
215 215 */
216 216 public function remove_user_from_all_objects( $user_id = 0, $meta_key = '', $meta_type = 'post' ) {
217 217 return delete_metadata( $meta_type, null, $meta_key, $user_id, true );
218 218 }
@@ -217,18 +217,18 @@
217 217 return delete_metadata( $meta_type, null, $meta_key, $user_id, true );
218 218 }
219 219
220 220 /**
221 - * Remove an object from all users.
221 + * Remove an object from all users
222 222 *
223 223 * @since 2.6.0 bbPress (r6722)
224 224 *
225 - * @param int $object_id The object id.
226 - * @param int $user_id The user id.
227 - * @param string $meta_key The relationship key.
228 - * @param string $meta_type The relationship type (usually 'post').
225 + * @param int $object_id The object id
226 + * @param int $user_id The user id
227 + * @param string $meta_key The relationship key
228 + * @param string $meta_type The relationship type (usually 'post')
229 229 *
230 - * @return bool Returns true on success, false on failure.
230 + * @return bool Returns true on success, false on failure
231 231 */
232 232 public function remove_object_from_all_users( $object_id = 0, $meta_key = '', $meta_type = 'post' ) {
233 233 return delete_metadata( $meta_type, $object_id, $meta_key, null, false );
234 234 }
@@ -233,16 +233,16 @@
233 233 return delete_metadata( $meta_type, $object_id, $meta_key, null, false );
234 234 }
235 235
236 236 /**
237 - * Remove all users from all objects.
237 + * Remove all users from all objects
238 238 *
239 239 * @since 2.6.0 bbPress (r6722)
240 240 *
241 - * @param string $meta_key The relationship key.
242 - * @param string $meta_type The relationship type (usually 'post').
241 + * @param string $meta_key The relationship key
242 + * @param string $meta_type The relationship type (usually 'post')
243 243 *
244 - * @return bool Returns true on success, false on failure.
244 + * @return bool Returns true on success, false on failure
245 245 */
246 246 public function remove_all_users_from_all_objects( $meta_key = '', $meta_type = 'post' ) {
247 247 return delete_metadata( $meta_type, null, $meta_key, null, true );
248 248 }
@@ -247,17 +247,17 @@
247 247 return delete_metadata( $meta_type, null, $meta_key, null, true );
248 248 }
249 249
250 250 /**
251 - * Get users of an object.
251 + * Get users of an object
252 252 *
253 253 * @since 2.6.0 bbPress (r6722)
254 254 *
255 - * @param int $object_id The object id.
256 - * @param string $meta_key The key used to index this relationship.
257 - * @param string $meta_type The type of meta to look in.
255 + * @param int $object_id The object id
256 + * @param string $meta_key The key used to index this relationship
257 + * @param string $meta_type The type of meta to look in
258 258 *
259 - * @return array Returns ids of users.
259 + * @return array Returns ids of users
260 260 */
261 261 public function get_users_for_object( $object_id = 0, $meta_key = '', $meta_type = 'post' ) {
262 262 return wp_parse_id_list( get_metadata( $meta_type, $object_id, $meta_key, false ) );
263 263 }
@@ -277,27 +277,23 @@
277 277
278 278 // Backwards compat for pre-2.6.0
279 279 if ( is_numeric( $args ) ) {
280 280 $args = array(
281 - 'meta_query' => array(
282 - array(
283 - 'key' => $meta_key,
284 - 'value' => bbp_get_user_id( $args, false, false ),
285 - 'compare' => 'NUMERIC'
286 - )
287 - )
281 + 'meta_query' => array( array(
282 + 'key' => $meta_key,
283 + 'value' => bbp_get_user_id( $args, false, false ),
284 + 'compare' => 'NUMERIC'
285 + ) )
288 286 );
289 287 }
290 288
291 289 // Default arguments
292 290 $defaults = array(
293 - 'meta_query' => array(
294 - array(
295 - 'key' => $meta_key,
296 - 'value' => bbp_get_displayed_user_id(),
297 - 'compare' => 'NUMERIC'
298 - )
299 - )
291 + 'meta_query' => array( array(
292 + 'key' => $meta_key,
293 + 'value' => bbp_get_displayed_user_id(),
294 + 'compare' => 'NUMERIC'
295 + ) )
300 296 );
301 297
302 298 // Parse arguments
303 299 return bbp_parse_args( $args, $defaults, $context_key );
@@ -304,9 +300,9 @@
304 300 }
305 301 }
306 302
307 303 /**
308 - * Term strategy for interfacing with User Engagements.
304 + * Term strategy for interfacing with User Engagements
309 305 *
310 306 * @since 2.6.0 bbPress (r6737)
311 307 */
312 308 class BBP_User_Engagements_Term extends BBP_User_Engagements_Base {
@@ -320,9 +316,9 @@
320 316 */
321 317 public $type = 'term';
322 318
323 319 /**
324 - * Register an engagement taxonomy just-in-time for immediate use.
320 + * Register an engagement taxonomy just-in-time for immediate use
325 321 *
326 322 * @since 2.6.0 bbPress (r6737)
327 323 *
328 324 * @param string $tax_key
@@ -335,48 +331,44 @@
335 331 return;
336 332 }
337 333
338 334 // Register the taxonomy
339 - register_taxonomy(
340 - $tax_key,
341 - 'bbp_' . $object_type,
342 - array(
343 - 'labels' => array(),
344 - 'description' => '',
345 - 'public' => false,
346 - 'publicly_queryable' => false,
347 - 'hierarchical' => false,
348 - 'show_ui' => false,
349 - 'show_in_menu' => false,
350 - 'show_in_nav_menus' => false,
351 - 'show_tagcloud' => false,
352 - 'show_in_quick_edit' => false,
353 - 'show_admin_column' => false,
354 - 'meta_box_cb' => false,
355 - 'capabilities' => array(),
356 - 'rewrite' => false,
357 - 'query_var' => '',
358 - 'update_count_callback' => '',
359 - 'show_in_rest' => false,
360 - 'rest_base' => false,
361 - 'rest_controller_class' => false,
362 - '_builtin' => false
363 - )
364 - );
335 + register_taxonomy( $tax_key, 'bbp_' . $object_type, array(
336 + 'labels' => array(),
337 + 'description' => '',
338 + 'public' => false,
339 + 'publicly_queryable' => false,
340 + 'hierarchical' => false,
341 + 'show_ui' => false,
342 + 'show_in_menu' => false,
343 + 'show_in_nav_menus' => false,
344 + 'show_tagcloud' => false,
345 + 'show_in_quick_edit' => false,
346 + 'show_admin_column' => false,
347 + 'meta_box_cb' => false,
348 + 'capabilities' => array(),
349 + 'rewrite' => false,
350 + 'query_var' => '',
351 + 'update_count_callback' => '',
352 + 'show_in_rest' => false,
353 + 'rest_base' => false,
354 + 'rest_controller_class' => false,
355 + '_builtin' => false
356 + ) );
365 357 }
366 358
367 359 /**
368 - * Add a user id to an object.
360 + * Add a user id to an object
369 361 *
370 362 * @since 2.6.0 bbPress (r6737)
371 363 *
372 - * @param int $object_id The object id.
373 - * @param int $user_id The user id.
374 - * @param string $meta_key The relationship key.
375 - * @param string $meta_type The relationship type (usually 'post').
376 - * @param bool $unique Whether meta key should be unique to the object.
364 + * @param int $object_id The object id
365 + * @param int $user_id The user id
366 + * @param string $meta_key The relationship key
367 + * @param string $meta_type The relationship type (usually 'post')
368 + * @param bool $unique Whether meta key should be unique to the object
377 369 *
378 - * @return bool Returns true on success, false on failure.
370 + * @return bool Returns true on success, false on failure
379 371 */
380 372 public function add_user_to_object( $object_id = 0, $user_id = 0, $meta_key = '', $meta_type = 'post', $unique = false ) {
381 373 $user_key = "{$meta_key}_user_id_{$user_id}";
382 374 $tax_key = "{$meta_key}_{$meta_type}";
@@ -385,18 +377,18 @@
385 377 return wp_add_object_terms( $object_id, $user_key, $tax_key );
386 378 }
387 379
388 380 /**
389 - * Remove a user id from an object.
381 + * Remove a user id from an object
390 382 *
391 383 * @since 2.6.0 bbPress (r6737)
392 384 *
393 - * @param int $object_id The object id.
394 - * @param int $user_id The user id.
395 - * @param string $meta_key The relationship key.
396 - * @param string $meta_type The relationship type (usually 'post').
385 + * @param int $object_id The object id
386 + * @param int $user_id The user id
387 + * @param string $meta_key The relationship key
388 + * @param string $meta_type The relationship type (usually 'post')
397 389 *
398 - * @return bool Returns true on success, false on failure.
390 + * @return bool Returns true on success, false on failure
399 391 */
400 392 public function remove_user_from_object( $object_id = 0, $user_id = 0, $meta_key = '', $meta_type = 'post' ) {
401 393 $user_key = "{$meta_key}_user_id_{$user_id}";
402 394 $tax_key = "{$meta_key}_{$meta_type}";
@@ -405,17 +397,17 @@
405 397 return wp_remove_object_terms( $object_id, $user_key, $tax_key );
406 398 }
407 399
408 400 /**
409 - * Remove a user id from all objects.
401 + * Remove a user id from all objects
410 402 *
411 403 * @since 2.6.0 bbPress (r6737)
412 404 *
413 - * @param int $user_id The user id.
414 - * @param string $meta_key The relationship key.
415 - * @param string $meta_type The relationship type (usually 'post').
405 + * @param int $user_id The user id
406 + * @param string $meta_key The relationship key
407 + * @param string $meta_type The relationship type (usually 'post')
416 408 *
417 - * @return bool Returns true on success, false on failure.
409 + * @return bool Returns true on success, false on failure
418 410 */
419 411 public function remove_user_from_all_objects( $user_id = 0, $meta_key = '', $meta_type = 'post' ) {
420 412 $user_key = "{$meta_key}_user_id_{$user_id}";
421 413 $tax_key = "{$meta_key}_{$meta_type}";
@@ -425,18 +417,18 @@
425 417 return wp_delete_term( $term->term_id, $tax_key );
426 418 }
427 419
428 420 /**
429 - * Remove an object from all users.
421 + * Remove an object from all users
430 422 *
431 423 * @since 2.6.0 bbPress (r6737)
432 424 *
433 - * @param int $object_id The object id.
434 - * @param int $user_id The user id.
435 - * @param string $meta_key The relationship key.
436 - * @param string $meta_type The relationship type (usually 'post').
425 + * @param int $object_id The object id
426 + * @param int $user_id The user id
427 + * @param string $meta_key The relationship key
428 + * @param string $meta_type The relationship type (usually 'post')
437 429 *
438 - * @return bool Returns true on success, false on failure.
430 + * @return bool Returns true on success, false on failure
439 431 */
440 432 public function remove_object_from_all_users( $object_id = 0, $meta_key = '', $meta_type = 'post' ) {
441 433 return wp_delete_object_term_relationships( $object_id, get_object_taxonomies( 'bbp_user' ) );
442 434 }
@@ -441,16 +433,16 @@
441 433 return wp_delete_object_term_relationships( $object_id, get_object_taxonomies( 'bbp_user' ) );
442 434 }
443 435
444 436 /**
445 - * Remove all users from all objects.
437 + * Remove all users from all objects
446 438 *
447 439 * @since 2.6.0 bbPress (r6737)
448 440 *
449 - * @param string $meta_key The relationship key.
450 - * @param string $meta_type The relationship type (usually 'post').
441 + * @param string $meta_key The relationship key
442 + * @param string $meta_type The relationship type (usually 'post')
451 443 *
452 - * @return bool Returns true on success, false on failure.
444 + * @return bool Returns true on success, false on failure
453 445 */
454 446 public function remove_all_users_from_all_objects( $meta_key = '', $meta_type = 'post' ) {
455 447 // TODO
456 448 }
@@ -455,17 +447,17 @@
455 447 // TODO
456 448 }
457 449
458 450 /**
459 - * Get users of an object.
451 + * Get users of an object
460 452 *
461 453 * @since 2.6.0 bbPress (r6737)
462 454 *
463 - * @param int $object_id The object id.
464 - * @param string $meta_key The key used to index this relationship.
465 - * @param string $meta_type The type of meta to look in.
455 + * @param int $object_id The object id
456 + * @param string $meta_key The key used to index this relationship
457 + * @param string $meta_type The type of meta to look in
466 458 *
467 - * @return array Returns ids of users.
459 + * @return array Returns ids of users
468 460 */
469 461 public function get_users_for_object( $object_id = 0, $meta_key = '', $meta_type = 'post' ) {
470 462 $user_key = "{$meta_key}_user_id_";
471 463 $tax_key = "{$meta_key}_{$meta_type}";
@@ -471,14 +463,12 @@
471 463 $tax_key = "{$meta_key}_{$meta_type}";
472 464 $this->jit_taxonomy( $tax_key );
473 465
474 466 // Get terms
475 - $terms = get_terms(
476 - array(
477 - 'object_ids' => $object_id,
478 - 'taxonomy' => $tax_key
479 - )
480 - );
467 + $terms = get_terms( array(
468 + 'object_ids' => $object_id,
469 + 'taxonomy' => $tax_key
470 + ) );
481 471
482 472 // Slug part to replace
483 473 $user_ids = array();
484 474
@@ -511,27 +501,23 @@
511 501
512 502 // Backwards compat for pre-2.6.0
513 503 if ( is_numeric( $args ) ) {
514 504 $args = array(
515 - 'tax_query' => array(
516 - array(
517 - 'taxonomy' => $tax_key,
518 - 'terms' => $user_key . bbp_get_user_id( $args, false, false ),
519 - 'field' => 'slug'
520 - )
521 - )
505 + 'tax_query' => array( array(
506 + 'taxonomy' => $tax_key,
507 + 'terms' => $user_key . bbp_get_user_id( $args, false, false ),
508 + 'field' => 'slug'
509 + ) )
522 510 );
523 511 }
524 512
525 513 // Default arguments
526 514 $defaults = array(
527 - 'tax_query' => array(
528 - array(
529 - 'taxonomy' => $tax_key,
530 - 'terms' => $user_key . bbp_get_displayed_user_id(),
531 - 'field' => 'slug'
532 - )
533 - )
515 + 'tax_query' => array( array(
516 + 'taxonomy' => $tax_key,
517 + 'terms' => $user_key . bbp_get_displayed_user_id(),
518 + 'field' => 'slug'
519 + ) )
534 520 );
535 521
536 522 // Parse arguments
537 523 return bbp_parse_args( $args, $defaults, $context_key );
@@ -538,9 +524,9 @@
538 524 }
539 525 }
540 526
541 527 /**
542 - * User strategy for interfacing with User Engagements.
528 + * User strategy for interfacing with User Engagements
543 529 *
544 530 * This strategy largely exists for backwards compatibility with bbPress 2.5,
545 531 * or installations that have not upgraded their databases to 2.6 or above.
546 532 *
@@ -671,9 +657,9 @@
671 657 *
672 658 * @param string $meta_key
673 659 * @param int $object_id
674 660 *
675 - * @return mixed Results from cache get.
661 + * @return mixed Results from cache get
676 662 */
677 663 private function cache_get( $meta_key = '', $object_id = 0 ) {
678 664 $cache_key = $this->get_cache_key( $meta_key, $object_id );
679 665
@@ -690,9 +676,9 @@
690 676 *
691 677 * @param string $meta_key
692 678 * @param int $object_id
693 679 *
694 - * @return mixed Results from cache set.
680 + * @return mixed Results from cache set
695 681 */
696 682 private function cache_set( $meta_key = '', $object_id = 0, $user_ids = array() ) {
697 683 $cache_key = $this->get_cache_key( $meta_key, $object_id );
698 684 $user_ids = $this->parse_comma_list( $user_ids );
@@ -710,9 +696,9 @@
710 696 *
711 697 * @param string $meta_key
712 698 * @param int $object_id
713 699 *
714 - * @return mixed Results from cache delete.
700 + * @return mixed Results from cache delete
715 701 */
716 702 private function cache_delete( $meta_key = '', $object_id = 0 ) {
717 703 $cache_key = $this->get_cache_key( $meta_key, $object_id );
718 704
@@ -731,25 +717,25 @@
731 717 return array_filter( wp_parse_id_list( $results ) );
732 718 }
733 719
734 720 /**
735 - * Add a user id to an object.
721 + * Add a user id to an object
736 722 *
737 723 * @since 2.6.0 bbPress (r6844)
738 724 *
739 - * @param int $object_id The object id.
740 - * @param int $user_id The user id.
741 - * @param string $meta_key The relationship key.
742 - * @param string $meta_type The relationship type (usually 'post').
743 - * @param bool $unique Whether meta key should be unique to the object.
725 + * @param int $object_id The object id
726 + * @param int $user_id The user id
727 + * @param string $meta_key The relationship key
728 + * @param string $meta_type The relationship type (usually 'post')
729 + * @param bool $unique Whether meta key should be unique to the object
744 730 *
745 - * @return bool Returns true on success, false on failure.
731 + * @return bool Returns true on success, false on failure
746 732 */
747 733 public function add_user_to_object( $object_id = 0, $user_id = 0, $meta_key = '', $meta_type = 'post', $unique = false ) {
748 734 $retval = false;
749 735 $option_key = $this->get_user_option_key( $meta_key, $object_id );
750 736 $object_ids = $this->parse_comma_list( get_user_option( $option_key, $user_id ) );
751 - $exists = array_search( $object_id, $object_ids, true );
737 + $exists = array_search( $object_id, $object_ids );
752 738
753 739 // Not already added, so add it
754 740 if ( false === $exists ) {
755 741 $object_ids[] = $object_id;
@@ -766,24 +752,24 @@
766 752 return $retval;
767 753 }
768 754
769 755 /**
770 - * Remove a user id from an object.
756 + * Remove a user id from an object
771 757 *
772 758 * @since 2.6.0 bbPress (r6844)
773 759 *
774 - * @param int $object_id The object id.
775 - * @param int $user_id The user id.
776 - * @param string $meta_key The relationship key.
777 - * @param string $meta_type The relationship type (usually 'post').
760 + * @param int $object_id The object id
761 + * @param int $user_id The user id
762 + * @param string $meta_key The relationship key
763 + * @param string $meta_type The relationship type (usually 'post')
778 764 *
779 - * @return bool Returns true on success, false on failure.
765 + * @return bool Returns true on success, false on failure
780 766 */
781 767 public function remove_user_from_object( $object_id = 0, $user_id = 0, $meta_key = '', $meta_type = 'post' ) {
782 768 $retval = false;
783 769 $option_key = $this->get_user_option_key( $meta_key, $object_id );
784 770 $object_ids = $this->parse_comma_list( get_user_option( $option_key, $user_id ) );
785 - $exists = array_search( $object_id, $object_ids, true );
771 + $exists = array_search( $object_id, $object_ids );
786 772
787 773 // Exists, so remove it
788 774 if ( false !== $exists ) {
789 775 unset( $object_ids[ $exists ] );
@@ -803,17 +789,17 @@
803 789 return $retval;
804 790 }
805 791
806 792 /**
807 - * Remove a user id from all objects.
793 + * Remove a user id from all objects
808 794 *
809 795 * @since 2.6.0 bbPress (r6844)
810 796 *
811 - * @param int $user_id The user id.
812 - * @param string $meta_key The relationship key.
813 - * @param string $meta_type The relationship type (usually 'post').
797 + * @param int $user_id The user id
798 + * @param string $meta_key The relationship key
799 + * @param string $meta_type The relationship type (usually 'post')
814 800 *
815 - * @return bool Returns true on success, false on failure.
801 + * @return bool Returns true on success, false on failure
816 802 */
817 803 public function remove_user_from_all_objects( $user_id = 0, $meta_key = '', $meta_type = 'post' ) {
818 804
819 805 // Get the key
@@ -836,18 +822,18 @@
836 822 return $retval;
837 823 }
838 824
839 825 /**
840 - * Remove an object from all users.
826 + * Remove an object from all users
841 827 *
842 828 * @since 2.6.0 bbPress (r6844)
843 829 *
844 - * @param int $object_id The object id.
845 - * @param int $user_id The user id.
846 - * @param string $meta_key The relationship key.
847 - * @param string $meta_type The relationship type (usually 'post').
830 + * @param int $object_id The object id
831 + * @param int $user_id The user id
832 + * @param string $meta_key The relationship key
833 + * @param string $meta_type The relationship type (usually 'post')
848 834 *
849 - * @return bool Returns true on success, false on failure.
835 + * @return bool Returns true on success, false on failure
850 836 */
851 837 public function remove_object_from_all_users( $object_id = 0, $meta_key = '', $meta_type = 'post' ) {
852 838
853 839 // Query for users
@@ -874,16 +860,16 @@
874 860 return ( $r_count === $u_count );
875 861 }
876 862
877 863 /**
878 - * Remove all users from all objects.
864 + * Remove all users from all objects
879 865 *
880 866 * @since 2.6.0 bbPress (r6844)
881 867 *
882 - * @param string $meta_key The relationship key.
883 - * @param string $meta_type The relationship type (usually 'post').
868 + * @param string $meta_key The relationship key
869 + * @param string $meta_type The relationship type (usually 'post')
884 870 *
885 - * @return bool Returns true on success, false on failure.
871 + * @return bool Returns true on success, false on failure
886 872 */
887 873 public function remove_all_users_from_all_objects( $meta_key = '', $meta_type = 'post' ) {
888 874
889 875 // Query for users
@@ -912,9 +898,9 @@
912 898 return ( $r_count === $u_count );
913 899 }
914 900
915 901 /**
916 - * Get users of an object.
902 + * Get users of an object
917 903 *
918 904 * The database queries in this function were cached in bbPress versions
919 905 * older than 2.6, but no longer are to avoid cache pollution.
920 906 *
@@ -919,13 +905,13 @@
919 905 * older than 2.6, but no longer are to avoid cache pollution.
920 906 *
921 907 * @since 2.6.0 bbPress (r6844)
922 908 *
923 - * @param int $object_id The object id.
924 - * @param string $meta_key The key used to index this relationship.
925 - * @param string $meta_type The type of meta to look in.
909 + * @param int $object_id The object id
910 + * @param string $meta_key The key used to index this relationship
911 + * @param string $meta_type The type of meta to look in
926 912 *
927 - * @return array Returns ids of users.
913 + * @return array Returns ids of users
928 914 */
929 915 public function get_users_for_object( $object_id = 0, $meta_key = '', $meta_type = 'post' ) {
930 916
931 917 // Try to get user IDs from cache