@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -24,15 +24,15 @@ discard block |
||
24 | 24 | * @global $wp_version |
25 | 25 | * @return void |
26 | 26 | */ |
27 | -function give_install( $network_wide = false ) { |
|
27 | +function give_install($network_wide = false) { |
|
28 | 28 | |
29 | 29 | global $wpdb; |
30 | 30 | |
31 | - if ( is_multisite() && $network_wide ) { |
|
31 | + if (is_multisite() && $network_wide) { |
|
32 | 32 | |
33 | - foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) { |
|
33 | + foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) { |
|
34 | 34 | |
35 | - switch_to_blog( $blog_id ); |
|
35 | + switch_to_blog($blog_id); |
|
36 | 36 | give_run_install(); |
37 | 37 | restore_current_blog(); |
38 | 38 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | |
47 | 47 | } |
48 | 48 | |
49 | -register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' ); |
|
49 | +register_activation_hook(GIVE_PLUGIN_FILE, 'give_install'); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Run the Give Install process. |
@@ -62,24 +62,24 @@ discard block |
||
62 | 62 | give_setup_post_types(); |
63 | 63 | |
64 | 64 | // Clear the permalinks. |
65 | - flush_rewrite_rules( false ); |
|
65 | + flush_rewrite_rules(false); |
|
66 | 66 | |
67 | 67 | // Add Upgraded From Option. |
68 | - $current_version = get_option( 'give_version' ); |
|
69 | - if ( $current_version ) { |
|
70 | - update_option( 'give_version_upgraded_from', $current_version ); |
|
68 | + $current_version = get_option('give_version'); |
|
69 | + if ($current_version) { |
|
70 | + update_option('give_version_upgraded_from', $current_version); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | // Setup some default options. |
74 | 74 | $options = array(); |
75 | 75 | |
76 | 76 | // Checks if the Success Page option exists AND that the page exists. |
77 | - if ( ! get_post( give_get_option( 'success_page' ) ) ) { |
|
77 | + if ( ! get_post(give_get_option('success_page'))) { |
|
78 | 78 | |
79 | 79 | // Donations Confirmation (Success) Page. |
80 | 80 | $success = wp_insert_post( |
81 | 81 | array( |
82 | - 'post_title' => esc_html__( 'Donation Confirmation', 'give' ), |
|
82 | + 'post_title' => esc_html__('Donation Confirmation', 'give'), |
|
83 | 83 | 'post_content' => '[give_receipt]', |
84 | 84 | 'post_status' => 'publish', |
85 | 85 | 'post_author' => 1, |
@@ -93,13 +93,13 @@ discard block |
||
93 | 93 | } |
94 | 94 | |
95 | 95 | // Checks if the Failure Page option exists AND that the page exists. |
96 | - if ( ! get_post( give_get_option( 'failure_page' ) ) ) { |
|
96 | + if ( ! get_post(give_get_option('failure_page'))) { |
|
97 | 97 | |
98 | 98 | // Failed Donation Page. |
99 | 99 | $failed = wp_insert_post( |
100 | 100 | array( |
101 | - 'post_title' => esc_html__( 'Transaction Failed', 'give' ), |
|
102 | - 'post_content' => esc_html__( 'We\'re sorry, your transaction failed to process. Please try again or contact site support.', 'give' ), |
|
101 | + 'post_title' => esc_html__('Transaction Failed', 'give'), |
|
102 | + 'post_content' => esc_html__('We\'re sorry, your transaction failed to process. Please try again or contact site support.', 'give'), |
|
103 | 103 | 'post_status' => 'publish', |
104 | 104 | 'post_author' => 1, |
105 | 105 | 'post_type' => 'page', |
@@ -111,11 +111,11 @@ discard block |
||
111 | 111 | } |
112 | 112 | |
113 | 113 | // Checks if the History Page option exists AND that the page exists. |
114 | - if ( ! get_post( give_get_option( 'history_page' ) ) ) { |
|
114 | + if ( ! get_post(give_get_option('history_page'))) { |
|
115 | 115 | // Purchase History (History) Page. |
116 | 116 | $history = wp_insert_post( |
117 | 117 | array( |
118 | - 'post_title' => esc_html__( 'Donation History', 'give' ), |
|
118 | + 'post_title' => esc_html__('Donation History', 'give'), |
|
119 | 119 | 'post_content' => '[donation_history]', |
120 | 120 | 'post_status' => 'publish', |
121 | 121 | 'post_author' => 1, |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | //Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency. |
131 | - if ( empty( $current_version ) ) { |
|
131 | + if (empty($current_version)) { |
|
132 | 132 | $options['base_country'] = 'US'; |
133 | 133 | $options['test_mode'] = 1; |
134 | 134 | $options['currency'] = 'USD'; |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | } |
153 | 153 | |
154 | 154 | // Populate the default values. |
155 | - update_option( 'give_settings', array_merge( $give_options, $options ) ); |
|
156 | - update_option( 'give_version', GIVE_VERSION ); |
|
155 | + update_option('give_settings', array_merge($give_options, $options)); |
|
156 | + update_option('give_version', GIVE_VERSION); |
|
157 | 157 | |
158 | 158 | // Create Give roles. |
159 | 159 | $roles = new Give_Roles(); |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | $roles->add_caps(); |
162 | 162 | |
163 | 163 | $api = new Give_API(); |
164 | - update_option( 'give_default_api_version', 'v' . $api->get_version() ); |
|
164 | + update_option('give_default_api_version', 'v'.$api->get_version()); |
|
165 | 165 | |
166 | 166 | // Create the customers databases. |
167 | 167 | @Give()->customers->create_table(); |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | Give()->session->use_php_sessions(); |
172 | 172 | |
173 | 173 | // Add a temporary option to note that Give pages have been created. |
174 | - set_transient( '_give_installed', $options, 30 ); |
|
174 | + set_transient('_give_installed', $options, 30); |
|
175 | 175 | |
176 | - if ( ! $current_version ) { |
|
176 | + if ( ! $current_version) { |
|
177 | 177 | |
178 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
178 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
179 | 179 | |
180 | 180 | // When new upgrade routines are added, mark them as complete on fresh install. |
181 | 181 | $upgrade_routines = array( |
@@ -184,22 +184,22 @@ discard block |
||
184 | 184 | 'upgrade_give_offline_status' |
185 | 185 | ); |
186 | 186 | |
187 | - foreach ( $upgrade_routines as $upgrade ) { |
|
188 | - give_set_upgrade_complete( $upgrade ); |
|
187 | + foreach ($upgrade_routines as $upgrade) { |
|
188 | + give_set_upgrade_complete($upgrade); |
|
189 | 189 | } |
190 | 190 | } |
191 | 191 | |
192 | 192 | // Bail if activating from network, or bulk. |
193 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
193 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
194 | 194 | return; |
195 | 195 | } |
196 | 196 | |
197 | 197 | // Add the transient to redirect. |
198 | - set_transient( '_give_activation_redirect', true, 30 ); |
|
198 | + set_transient('_give_activation_redirect', true, 30); |
|
199 | 199 | |
200 | 200 | } |
201 | 201 | |
202 | -register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' ); |
|
202 | +register_activation_hook(GIVE_PLUGIN_FILE, 'give_install'); |
|
203 | 203 | |
204 | 204 | /** |
205 | 205 | * Network Activated New Site Setup. |
@@ -215,11 +215,11 @@ discard block |
||
215 | 215 | * @param int $site_id The Site ID. |
216 | 216 | * @param array $meta Blog Meta. |
217 | 217 | */ |
218 | -function on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { |
|
218 | +function on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) { |
|
219 | 219 | |
220 | - if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) { |
|
220 | + if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) { |
|
221 | 221 | |
222 | - switch_to_blog( $blog_id ); |
|
222 | + switch_to_blog($blog_id); |
|
223 | 223 | give_install(); |
224 | 224 | restore_current_blog(); |
225 | 225 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | |
228 | 228 | } |
229 | 229 | |
230 | -add_action( 'wpmu_new_blog', 'on_create_blog', 10, 6 ); |
|
230 | +add_action('wpmu_new_blog', 'on_create_blog', 10, 6); |
|
231 | 231 | |
232 | 232 | |
233 | 233 | /** |
@@ -240,13 +240,13 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return array The tables to drop. |
242 | 242 | */ |
243 | -function give_wpmu_drop_tables( $tables, $blog_id ) { |
|
243 | +function give_wpmu_drop_tables($tables, $blog_id) { |
|
244 | 244 | |
245 | - switch_to_blog( $blog_id ); |
|
245 | + switch_to_blog($blog_id); |
|
246 | 246 | $customers_db = new Give_DB_Customers(); |
247 | 247 | $customer_meta_db = new Give_DB_Customer_Meta(); |
248 | 248 | |
249 | - if ( $customers_db->installed() ) { |
|
249 | + if ($customers_db->installed()) { |
|
250 | 250 | $tables[] = $customers_db->table_name; |
251 | 251 | $tables[] = $customer_meta_db->table_name; |
252 | 252 | } |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | |
257 | 257 | } |
258 | 258 | |
259 | -add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 ); |
|
259 | +add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2); |
|
260 | 260 | |
261 | 261 | /** |
262 | 262 | * Post-installation |
@@ -268,16 +268,16 @@ discard block |
||
268 | 268 | */ |
269 | 269 | function give_after_install() { |
270 | 270 | |
271 | - if ( ! is_admin() ) { |
|
271 | + if ( ! is_admin()) { |
|
272 | 272 | return; |
273 | 273 | } |
274 | 274 | |
275 | - $give_options = get_transient( '_give_installed' ); |
|
276 | - $give_table_check = get_option( '_give_table_check', false ); |
|
275 | + $give_options = get_transient('_give_installed'); |
|
276 | + $give_table_check = get_option('_give_table_check', false); |
|
277 | 277 | |
278 | - if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) { |
|
278 | + if (false === $give_table_check || current_time('timestamp') > $give_table_check) { |
|
279 | 279 | |
280 | - if ( ! @Give()->customer_meta->installed() ) { |
|
280 | + if ( ! @Give()->customer_meta->installed()) { |
|
281 | 281 | |
282 | 282 | // Create the customer meta database |
283 | 283 | // (this ensures it creates it on multisite instances where it is network activated). |
@@ -285,27 +285,27 @@ discard block |
||
285 | 285 | |
286 | 286 | } |
287 | 287 | |
288 | - if ( ! @Give()->customers->installed() ) { |
|
288 | + if ( ! @Give()->customers->installed()) { |
|
289 | 289 | // Create the customers database |
290 | 290 | // (this ensures it creates it on multisite instances where it is network activated). |
291 | 291 | @Give()->customers->create_table(); |
292 | 292 | |
293 | - do_action( 'give_after_install', $give_options ); |
|
293 | + do_action('give_after_install', $give_options); |
|
294 | 294 | } |
295 | 295 | |
296 | - update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) ); |
|
296 | + update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS)); |
|
297 | 297 | |
298 | 298 | } |
299 | 299 | |
300 | 300 | // Delete the transient |
301 | - if ( false !== $give_options ) { |
|
302 | - delete_transient( '_give_installed' ); |
|
301 | + if (false !== $give_options) { |
|
302 | + delete_transient('_give_installed'); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | |
306 | 306 | } |
307 | 307 | |
308 | -add_action( 'admin_init', 'give_after_install' ); |
|
308 | +add_action('admin_init', 'give_after_install'); |
|
309 | 309 | |
310 | 310 | |
311 | 311 | /** |
@@ -320,11 +320,11 @@ discard block |
||
320 | 320 | |
321 | 321 | global $wp_roles; |
322 | 322 | |
323 | - if ( ! is_object( $wp_roles ) ) { |
|
323 | + if ( ! is_object($wp_roles)) { |
|
324 | 324 | return; |
325 | 325 | } |
326 | 326 | |
327 | - if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) { |
|
327 | + if ( ! array_key_exists('give_manager', $wp_roles->roles)) { |
|
328 | 328 | |
329 | 329 | // Create Give plugin roles |
330 | 330 | $roles = new Give_Roles(); |
@@ -335,4 +335,4 @@ discard block |
||
335 | 335 | |
336 | 336 | } |
337 | 337 | |
338 | -add_action( 'admin_init', 'give_install_roles_on_network' ); |
|
339 | 338 | \ No newline at end of file |
339 | +add_action('admin_init', 'give_install_roles_on_network'); |
|
340 | 340 | \ No newline at end of file |