PluginProbe
bbPress / 2.0-rc-3
bbPress v2.0-rc-3
2.6.17 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 All 72 releases
bbpress / bbp-includes / bbp-core-update.php

bbp-core-update.php in bbPress 2.0-rc-3, at bbp-includes/bbp-core-update.php

143 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * bbPress Updater
5 *
6 * @package bbPress
7 * @subpackage Updater
8 */
9
10 // Exit if accessed directly
11 if ( !defined( 'ABSPATH' ) ) exit;
12
13 /**
14 * Compare the bbPress version to the DB version to determine if updating
15 *
16 * @since bbPress (r3421)
17 * @global bbPress $bbp
18 * @uses get_option()
19 * @return bool True if update, False if not
20 */
21 function bbp_is_update() {
22 global $bbp;
23
24 // Current DB version of this site (per site in a multisite network)
25 $current_db = get_option( '_bbp_db_version' );
26
27 // Compare versions (cast as int and bool to be safe)
28 $is_update = (bool) ( (int) $current_db < (int) $bbp->db_version );
29
30 // Return the product of version comparison
31 return $is_update;
32 }
33
34 /**
35 * Determine if bbPress is being activated
36 *
37 * @since bbPress (r3421)
38 * @global bbPress $bbp
39 * @return bool True if activating bbPress, false if not
40 */
41 function bbp_is_activation( $basename = '' ) {
42 global $bbp;
43
44 // Baif if action or plugin are empty
45 if ( empty( $_GET['action'] ) || empty( $_GET['plugin'] ) )
46 return false;
47
48 // Bail if not activating
49 if ( 'activate' !== $_GET['action'] )
50 return false;
51
52 // The plugin being activated
53 $plugin = isset( $_GET['plugin'] ) ? $_GET['plugin'] : '';
54
55 // Set basename if empty
56 if ( empty( $basename ) && !empty( $bbp->basename ) )
57 $basename = $bbp->basename;
58
59 // Bail if no basename
60 if ( empty( $basename ) )
61 return false;
62
63 // Bail if plugin is not bbPress
64 if ( $basename !== $_GET['plugin'] )
65 return false;
66
67 return true;
68 }
69
70 /**
71 * Determine if bbPress is being deactivated
72 *
73 * @since bbPress (r3421)
74 * @global bbPress $bbp
75 * @return bool True if deactivating bbPress, false if not
76 */
77 function bbp_is_deactivation( $basename = '' ) {
78 global $bbp;
79
80 // Baif if action or plugin are empty
81 if ( empty( $_GET['action'] ) || empty( $_GET['plugin'] ) )
82 return false;
83
84 // Bail if not deactivating
85 if ( 'deactivate' !== $_GET['action'] )
86 return false;
87
88 // The plugin being deactivated
89 $plugin = isset( $_GET['plugin'] ) ? $_GET['plugin'] : '';
90
91 // Set basename if empty
92 if ( empty( $basename ) && !empty( $bbp->basename ) )
93 $basename = $bbp->basename;
94
95 // Bail if no basename
96 if ( empty( $basename ) )
97 return false;
98
99 // Bail if plugin is not bbPress
100 if ( $basename !== $plugin )
101 return false;
102
103 return true;
104 }
105
106 /**
107 * Update the DB to the latest version
108 *
109 * @since bbPress (r3421)
110 * @uses update_option()
111 */
112 function bbp_version_bump() {
113 global $bbp;
114
115 update_option( '_bbp_db_version', $bbp->db_version );
116 }
117
118 /**
119 * Setup the bbPress updater
120 *
121 * @since bbPress (r3419)
122 *
123 * @global bbPress $bbp
124 * @uses BBP_Updater
125 */
126 function bbp_setup_updater() {
127
128 // Are we running an outdated version of bbPress?
129 if ( bbp_is_update() ) {
130
131 // Bump the version
132 bbp_version_bump();
133
134 // Run the deactivation function to wipe roles, caps, and rewrite rules
135 bbp_deactivation();
136
137 // Run the activation function to reset roles, caps, and rewrite rules
138 bbp_activation();
139 }
140 }
141
142 ?>
143