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/core/update.php +63 -85 trunk2.6.6 View file →
@@ -1,8 +1,8 @@
1 1 <?php
2 2
3 3 /**
4 - * bbPress Updater.
4 + * bbPress Updater
5 5 *
6 6 * @package bbPress
7 7 * @subpackage Core
8 8 */
@@ -10,13 +10,13 @@
10 10 // Exit if accessed directly
11 11 defined( 'ABSPATH' ) || exit;
12 12
13 13 /**
14 - * If there is no raw DB version, this is the first installation.
14 + * If there is no raw DB version, this is the first installation
15 15 *
16 16 * @since 2.1.0 bbPress (r3764)
17 17 *
18 - * @return bool True if update, False if not.
18 + * @return bool True if update, False if not
19 19 */
20 20 function bbp_is_install() {
21 21 return ! bbp_get_db_version_raw();
22 22 }
@@ -21,13 +21,13 @@
21 21 return ! bbp_get_db_version_raw();
22 22 }
23 23
24 24 /**
25 - * Compare the bbPress version to the DB version to determine if updating.
25 + * Compare the bbPress version to the DB version to determine if updating
26 26 *
27 27 * @since 2.0.0 bbPress (r3421)
28 28 *
29 - * @return bool True if update, False if not.
29 + * @return bool True if update, False if not
30 30 */
31 31 function bbp_is_update() {
32 32 $raw = (int) bbp_get_db_version_raw();
33 33 $cur = (int) bbp_get_db_version();
@@ -35,9 +35,9 @@
35 35 return $retval;
36 36 }
37 37
38 38 /**
39 - * Determine if bbPress is being activated.
39 + * Determine if bbPress is being activated
40 40 *
41 41 * Note that this function currently is not used in bbPress core and is here
42 42 * for third party plugins to use to check for bbPress activation.
43 43 *
@@ -42,13 +42,9 @@
42 42 * for third party plugins to use to check for bbPress activation.
43 43 *
44 44 * @since 2.0.0 bbPress (r3421)
45 45 *
46 - * @global string $pagenow The filename of the current screen.
47 - *
48 - * @param string $basename Plugin base name.
49 - *
50 - * @return bool True if activating bbPress, false if not.
46 + * @return bool True if activating bbPress, false if not
51 47 */
52 48 function bbp_is_activation( $basename = '' ) {
53 49 global $pagenow;
54 50
@@ -66,14 +62,14 @@
66 62 $action = $_REQUEST['action2'];
67 63 }
68 64
69 65 // Bail if not activating
70 - if ( empty( $action ) || ! in_array( $action, array( 'activate', 'activate-selected' ), true ) ) {
66 + if ( empty( $action ) || ! in_array( $action, array( 'activate', 'activate-selected', true ) ) ) {
71 67 return false;
72 68 }
73 69
74 70 // The plugin(s) being activated
75 - if ( 'activate' === $action ) {
71 + if ( $action === 'activate' ) {
76 72 $plugins = isset( $_GET['plugin'] ) ? array( $_GET['plugin'] ) : array();
77 73 } else {
78 74 $plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
79 75 }
@@ -92,17 +88,13 @@
92 88 return in_array( $basename, $plugins, true );
93 89 }
94 90
95 91 /**
96 - * Determine if bbPress is being deactivated.
92 + * Determine if bbPress is being deactivated
97 93 *
98 94 * @since 2.0.0 bbPress (r3421)
99 95 *
100 - * @global string $pagenow The filename of the current screen.
101 - *
102 - * @param string $basename Plugin base name.
103 - *
104 - * @return bool True if deactivating bbPress, false if not.
96 + * @return bool True if deactivating bbPress, false if not
105 97 */
106 98 function bbp_is_deactivation( $basename = '' ) {
107 99 global $pagenow;
108 100
@@ -125,9 +117,9 @@
125 117 return false;
126 118 }
127 119
128 120 // The plugin(s) being deactivated
129 - if ( 'deactivate' === $action ) {
121 + if ( $action === 'deactivate' ) {
130 122 $plugins = isset( $_GET['plugin'] ) ? array( $_GET['plugin'] ) : array();
131 123 } else {
132 124 $plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
133 125 }
@@ -146,9 +138,9 @@
146 138 return in_array( $basename, $plugins, true );
147 139 }
148 140
149 141 /**
150 - * Update the DB to the latest version.
142 + * Update the DB to the latest version
151 143 *
152 144 * @since 2.0.0 bbPress (r3421)
153 145 */
154 146 function bbp_version_bump() {
@@ -155,9 +147,9 @@
155 147 update_option( '_bbp_db_version', bbp_get_db_version() );
156 148 }
157 149
158 150 /**
159 - * Setup the bbPress updater.
151 + * Setup the bbPress updater
160 152 *
161 153 * @since 2.0.0 bbPress (r3419)
162 154 */
163 155 function bbp_setup_updater() {
@@ -172,13 +164,11 @@
172 164 }
173 165
174 166 /**
175 167 * Runs when a new site is created in a multisite network, and bbPress is active
176 - * on that site (hooked to `bbp_new_site`).
168 + * on that site (hooked to `bbp_new_site`)
177 169 *
178 170 * @since 2.6.0 bbPress (r6779)
179 - *
180 - * @param int $site_id Side id.
181 171 */
182 172 function bbp_setup_new_site( $site_id = 0 ) {
183 173
184 174 // Look for initial content
@@ -197,13 +187,13 @@
197 187 }
198 188 }
199 189
200 190 /**
201 - * Create a default forum, topic, and reply.
191 + * Create a default forum, topic, and reply
202 192 *
203 193 * @since 2.1.0 bbPress (r3767)
204 194 *
205 - * @param array $args Array of arguments to override default values.
195 + * @param array $args Array of arguments to override default values
206 196 */
207 197 function bbp_create_initial_content( $args = array() ) {
208 198
209 199 // Cannot use bbp_get_current_user_id() during activation process
@@ -209,46 +199,38 @@
209 199 // Cannot use bbp_get_current_user_id() during activation process
210 200 $user_id = get_current_user_id();
211 201
212 202 // Parse arguments against default values
213 - $r = bbp_parse_args(
214 - $args,
215 - array(
216 - 'forum_author' => $user_id,
217 - 'forum_parent' => 0,
218 - 'forum_status' => 'publish',
219 - 'forum_title' => esc_html__( 'General', 'bbpress' ),
220 - 'forum_content' => esc_html__( 'General Discussion', 'bbpress' ),
203 + $r = bbp_parse_args( $args, array(
204 + 'forum_author' => $user_id,
205 + 'forum_parent' => 0,
206 + 'forum_status' => 'publish',
207 + 'forum_title' => esc_html__( 'General', 'bbpress' ),
208 + 'forum_content' => esc_html__( 'General Discussion', 'bbpress' ),
221 209
222 - 'topic_author' => $user_id,
223 - 'topic_title' => esc_html__( 'Hello World!', 'bbpress' ),
224 - 'topic_content' => esc_html__( 'This is the very first topic in these forums.', 'bbpress' ),
210 + 'topic_author' => $user_id,
211 + 'topic_title' => esc_html__( 'Hello World!', 'bbpress' ),
212 + 'topic_content' => esc_html__( 'This is the very first topic in these forums.', 'bbpress' ),
225 213
226 - 'reply_author' => $user_id,
227 - 'reply_content' => esc_html__( 'And this is the very first reply.', 'bbpress' ),
228 - ),
229 - 'create_initial_content'
230 - );
214 + 'reply_author' => $user_id,
215 + 'reply_content' => esc_html__( 'And this is the very first reply.', 'bbpress' ),
216 + ), 'create_initial_content' );
231 217
232 218 // Use the same time for each post
233 - // phpcs:disable WordPress.DateTime.RestrictedFunctions.date_date
234 219 $current_time = time();
235 220 $forum_time = date( 'Y-m-d H:i:s', $current_time - 60 * 60 * 80 );
236 221 $topic_time = date( 'Y-m-d H:i:s', $current_time - 60 * 60 * 60 );
237 222 $reply_time = date( 'Y-m-d H:i:s', $current_time - 60 * 60 * 40 );
238 - // phpcs:enable
239 223
240 224 // Create the initial forum
241 - $forum_id = bbp_insert_forum(
242 - array(
243 - 'post_author' => $r['forum_author'],
244 - 'post_parent' => $r['forum_parent'],
245 - 'post_status' => $r['forum_status'],
246 - 'post_title' => $r['forum_title'],
247 - 'post_content' => $r['forum_content'],
248 - 'post_date' => $forum_time
249 - )
250 - );
225 + $forum_id = bbp_insert_forum( array(
226 + 'post_author' => $r['forum_author'],
227 + 'post_parent' => $r['forum_parent'],
228 + 'post_status' => $r['forum_status'],
229 + 'post_title' => $r['forum_title'],
230 + 'post_content' => $r['forum_content'],
231 + 'post_date' => $forum_time
232 + ) );
251 233
252 234 // Create the initial topic
253 235 $topic_id = bbp_insert_topic(
254 236 array(
@@ -258,9 +240,9 @@
258 240 'post_content' => $r['topic_content'],
259 241 'post_date' => $topic_time,
260 242 ),
261 243 array(
262 - 'forum_id' => $forum_id
244 + 'forum_id' => $forum_id
263 245 )
264 246 );
265 247
266 248 // Create the initial reply
@@ -271,10 +253,10 @@
271 253 'post_content' => $r['reply_content'],
272 254 'post_date' => $reply_time
273 255 ),
274 256 array(
275 - 'forum_id' => $forum_id,
276 - 'topic_id' => $topic_id
257 + 'forum_id' => $forum_id,
258 + 'topic_id' => $topic_id
277 259 )
278 260 );
279 261
280 262 return array(
@@ -303,9 +285,8 @@
303 285
304 286 /** 2.0 Branch ********************************************************/
305 287
306 288 // 2.0, 2.0.1, 2.0.2, 2.0.3
307 - // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedIf
308 289 if ( $raw_db_version < 200 ) {
309 290 // No changes
310 291 }
311 292
@@ -336,9 +317,8 @@
336 317
337 318 /** 2.3 Branch ********************************************************/
338 319
339 320 // 2.3.x
340 - // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedIf
341 321 if ( $raw_db_version < 230 ) {
342 322 // No changes
343 323 }
344 324
@@ -344,9 +324,8 @@
344 324
345 325 /** 2.4 Branch ********************************************************/
346 326
347 327 // 2.4.x
348 - // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedIf
349 328 if ( $raw_db_version < 240 ) {
350 329 // No changes
351 330 }
352 331
@@ -352,9 +331,8 @@
352 331
353 332 /** 2.5 Branch ********************************************************/
354 333
355 334 // 2.5.x
356 - // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedIf
357 335 if ( $raw_db_version < 250 ) {
358 336 // No changes
359 337 }
360 338
@@ -429,15 +407,15 @@
429 407 bbp_delete_rewrite_rules();
430 408 }
431 409
432 410 /**
433 - * Redirect user to the "What's New" page on activation.
411 + * Redirect user to the "What's New" page on activation
434 412 *
435 413 * @since 2.2.0 bbPress (r4389)
436 414 *
437 - * @internal Used internally to redirect bbPress to the about page on activation.
415 + * @internal Used internally to redirect bbPress to the about page on activation
438 416 *
439 - * @return If network admin or bulk activation.
417 + * @return If network admin or bulk activation
440 418 */
441 419 function bbp_add_activation_redirect() {
442 420
443 421 // Bail if activating from network, or bulk
@@ -449,15 +427,15 @@
449 427 update_user_option( get_current_user_id(), '_bbp_activation_redirect', true );
450 428 }
451 429
452 430 /**
453 - * Redirect user to "What's New" page on activation.
431 + * Redirect user to "What's New" page on activation
454 432 *
455 433 * @since 2.2.0 bbPress (r4389)
456 434 *
457 - * @internal Used internally to redirect bbPress to the about page on activation.
435 + * @internal Used internally to redirect bbPress to the about page on activation
458 436 *
459 - * @return If no transient, or in network admin, or is bulk activation.
437 + * @return If no transient, or in network admin, or is bulk activation
460 438 */
461 439 function bbp_do_activation_redirect() {
462 440
463 441 // Bail if no redirect trigger
@@ -483,16 +461,16 @@
483 461 }
484 462
485 463 /**
486 464 * Hooked to the 'bbp_activate' action, this helper function automatically makes
487 - * the current user a Keymaster in the forums if they just activated bbPress,
465 + * the current user a Key Master in the forums if they just activated bbPress,
488 466 * regardless of the bbp_allow_global_access() setting.
489 467 *
490 468 * @since 2.4.0 bbPress (r4910)
491 469 *
492 - * @internal Used to internally make the current user a keymaster on activation.
470 + * @internal Used to internally make the current user a keymaster on activation
493 471 *
494 - * @return If user can't activate plugins or is already a keymaster.
472 + * @return If user can't activate plugins or is already a keymaster
495 473 */
496 474 function bbp_make_current_user_keymaster() {
497 475
498 476 // Catch all, to prevent premature user initialization
@@ -536,13 +514,13 @@
536 514
537 515 /** Pending Upgrades **********************************************************/
538 516
539 517 /**
540 - * Return the number of pending upgrades.
518 + * Return the number of pending upgrades
541 519 *
542 520 * @since 2.6.0 bbPress (r6895)
543 521 *
544 - * @param string $type Type of pending upgrades (upgrade|repair|empty).
522 + * @param string $type Type of pending upgrades (upgrade|repair|empty)
545 523 *
546 524 * @return int
547 525 */
548 526 function bbp_get_pending_upgrade_count( $type = '' ) {
@@ -549,13 +527,13 @@
549 527 return count( (array) bbp_get_pending_upgrades( $type ) );
550 528 }
551 529
552 530 /**
553 - * Return an array of pending upgrades.
531 + * Return an array of pending upgrades
554 532 *
555 533 * @since 2.6.0 bbPress (r6895)
556 534 *
557 - * @param string $type Type of pending upgrades (upgrade|repair|empty).
535 + * @param string $type Type of pending upgrades (upgrade|repair|empty)
558 536 *
559 537 * @return array
560 538 */
561 539 function bbp_get_pending_upgrades( $type = '' ) {
@@ -573,9 +551,9 @@
573 551 return (array) $retval;
574 552 }
575 553
576 554 /**
577 - * Add an upgrade ID to pending upgrades array.
555 + * Add an upgrade ID to pending upgrades array
578 556 *
579 557 * @since 2.6.0 bbPress (r6895)
580 558 *
581 559 * @param string $upgrade_id
@@ -594,9 +572,9 @@
594 572 return update_option( '_bbp_db_pending_upgrades', $pending );
595 573 }
596 574
597 575 /**
598 - * Add an upgrade ID to pending upgrades array.
576 + * Add an upgrade ID to pending upgrades array
599 577 *
600 578 * @since 2.6.0 bbPress (r6895)
601 579 *
602 580 * @param string $upgrade_id
@@ -618,9 +596,9 @@
618 596 return update_option( '_bbp_db_pending_upgrades', $pending );
619 597 }
620 598
621 599 /**
622 - * Delete all pending upgrades.
600 + * Delete all pending upgrades
623 601 *
624 602 * @since 2.6.0 bbPress (r6895)
625 603 */
626 604 function bbp_clear_pending_upgrades() {
@@ -627,18 +605,18 @@
627 605 return delete_option( '_bbp_db_pending_upgrades' );
628 606 }
629 607
630 608 /**
631 - * Maybe append an upgrade count to a string.
609 + * Maybe append an upgrade count to a string
632 610 *
633 611 * @since 2.6.0 bbPress (r6896)
634 612 *
635 - * @param string $text Text to append count to.
636 - * @param string $type Type of pending upgrades (upgrade|repair|empty).
613 + * @param string $string Text to append count to
614 + * @param string $type Type of pending upgrades (upgrade|repair|empty)
637 615 *
638 616 * @return string
639 617 */
640 -function bbp_maybe_append_pending_upgrade_count( $text = '', $type = '' ) {
618 +function bbp_maybe_append_pending_upgrade_count( $string = '', $type = '' ) {
641 619
642 620 // Look for an upgrade count
643 621 $count = bbp_get_pending_upgrade_count( $type );
644 622
@@ -644,10 +622,10 @@
644 622
645 623 // Append the count to the string
646 624 if ( ! empty( $count ) ) {
647 625 $suffix = ' <span class="awaiting-mod count-' . absint( $count ) . '"><span class="pending-count">' . bbp_number_format( $count ) . '</span></span>';
648 - $text = "{$text}{$suffix}";
626 + $string = "{$string}{$suffix}";
649 627 }
650 628
651 - // Return the text, maybe with a count
652 - return $text;
629 + // Return the string, maybe with a count
630 + return $string;
653 631 }