@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Exit if accessed directly |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if ( ! defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -25,27 +25,27 @@ discard block |
||
| 25 | 25 | function give_test_ajax_works() { |
| 26 | 26 | |
| 27 | 27 | // Check if the Airplane Mode plugin is installed |
| 28 | - if ( class_exists( 'Airplane_Mode_Core' ) ) { |
|
| 28 | + if (class_exists('Airplane_Mode_Core')) { |
|
| 29 | 29 | |
| 30 | 30 | $airplane = Airplane_Mode_Core::getInstance(); |
| 31 | 31 | |
| 32 | - if ( method_exists( $airplane, 'enabled' ) ) { |
|
| 32 | + if (method_exists($airplane, 'enabled')) { |
|
| 33 | 33 | |
| 34 | - if ( $airplane->enabled() ) { |
|
| 34 | + if ($airplane->enabled()) { |
|
| 35 | 35 | return true; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | } else { |
| 39 | 39 | |
| 40 | - if ( $airplane->check_status() == 'on' ) { |
|
| 40 | + if ($airplane->check_status() == 'on') { |
|
| 41 | 41 | return true; |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - add_filter( 'block_local_requests', '__return_false' ); |
|
| 46 | + add_filter('block_local_requests', '__return_false'); |
|
| 47 | 47 | |
| 48 | - if ( get_transient( '_give_ajax_works' ) ) { |
|
| 48 | + if (get_transient('_give_ajax_works')) { |
|
| 49 | 49 | return true; |
| 50 | 50 | } |
| 51 | 51 | |
@@ -57,35 +57,35 @@ discard block |
||
| 57 | 57 | ) |
| 58 | 58 | ); |
| 59 | 59 | |
| 60 | - $ajax = wp_remote_post( give_get_ajax_url(), $params ); |
|
| 60 | + $ajax = wp_remote_post(give_get_ajax_url(), $params); |
|
| 61 | 61 | $works = true; |
| 62 | 62 | |
| 63 | - if ( is_wp_error( $ajax ) ) { |
|
| 63 | + if (is_wp_error($ajax)) { |
|
| 64 | 64 | |
| 65 | 65 | $works = false; |
| 66 | 66 | |
| 67 | 67 | } else { |
| 68 | 68 | |
| 69 | - if ( empty( $ajax['response'] ) ) { |
|
| 69 | + if (empty($ajax['response'])) { |
|
| 70 | 70 | $works = false; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - if ( empty( $ajax['response']['code'] ) || 200 !== (int) $ajax['response']['code'] ) { |
|
| 73 | + if (empty($ajax['response']['code']) || 200 !== (int) $ajax['response']['code']) { |
|
| 74 | 74 | $works = false; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - if ( empty( $ajax['response']['message'] ) || 'OK' !== $ajax['response']['message'] ) { |
|
| 77 | + if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) { |
|
| 78 | 78 | $works = false; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if ( ! isset( $ajax['body'] ) || 0 !== (int) $ajax['body'] ) { |
|
| 81 | + if ( ! isset($ajax['body']) || 0 !== (int) $ajax['body']) { |
|
| 82 | 82 | $works = false; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - if ( $works ) { |
|
| 88 | - set_transient( '_give_ajax_works', '1', DAY_IN_SECONDS ); |
|
| 87 | + if ($works) { |
|
| 88 | + set_transient('_give_ajax_works', '1', DAY_IN_SECONDS); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | return $works; |
@@ -99,16 +99,16 @@ discard block |
||
| 99 | 99 | * @return string |
| 100 | 100 | */ |
| 101 | 101 | function give_get_ajax_url() { |
| 102 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
| 102 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
| 103 | 103 | |
| 104 | 104 | $current_url = give_get_current_page_url(); |
| 105 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
| 105 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
| 106 | 106 | |
| 107 | - if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) { |
|
| 108 | - $ajax_url = preg_replace( '/^http/', 'https', $ajax_url ); |
|
| 107 | + if (preg_match('/^https/', $current_url) && ! preg_match('/^https/', $ajax_url)) { |
|
| 108 | + $ajax_url = preg_replace('/^http/', 'https', $ajax_url); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - return apply_filters( 'give_ajax_url', $ajax_url ); |
|
| 111 | + return apply_filters('give_ajax_url', $ajax_url); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -118,11 +118,11 @@ discard block |
||
| 118 | 118 | * @return void |
| 119 | 119 | */ |
| 120 | 120 | function give_load_checkout_login_fields() { |
| 121 | - do_action( 'give_purchase_form_login_fields' ); |
|
| 121 | + do_action('give_purchase_form_login_fields'); |
|
| 122 | 122 | give_die(); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | -add_action( 'wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields' ); |
|
| 125 | +add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields'); |
|
| 126 | 126 | |
| 127 | 127 | /** |
| 128 | 128 | * Load Checkout Fields |
@@ -131,22 +131,22 @@ discard block |
||
| 131 | 131 | * @return void |
| 132 | 132 | */ |
| 133 | 133 | function give_load_checkout_fields() { |
| 134 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : ''; |
|
| 134 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : ''; |
|
| 135 | 135 | |
| 136 | 136 | ob_start(); |
| 137 | 137 | |
| 138 | - do_action( 'give_purchase_form_register_login_fields', $form_id ); |
|
| 138 | + do_action('give_purchase_form_register_login_fields', $form_id); |
|
| 139 | 139 | |
| 140 | 140 | $fields = ob_get_clean(); |
| 141 | 141 | |
| 142 | - wp_send_json( array( |
|
| 143 | - 'fields' => wp_json_encode( $fields ), |
|
| 144 | - 'submit' => wp_json_encode( give_checkout_button_purchase( $form_id ) ), |
|
| 145 | - ) ); |
|
| 142 | + wp_send_json(array( |
|
| 143 | + 'fields' => wp_json_encode($fields), |
|
| 144 | + 'submit' => wp_json_encode(give_checkout_button_purchase($form_id)), |
|
| 145 | + )); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | -add_action( 'wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields' ); |
|
| 149 | -add_action( 'wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields' ); |
|
| 148 | +add_action('wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields'); |
|
| 149 | +add_action('wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields'); |
|
| 150 | 150 | |
| 151 | 151 | /** |
| 152 | 152 | * Get Form Title via AJAX (used only in WordPress Admin) |
@@ -155,9 +155,9 @@ discard block |
||
| 155 | 155 | * @return void |
| 156 | 156 | */ |
| 157 | 157 | function give_ajax_get_form_title() { |
| 158 | - if ( isset( $_POST['form_id'] ) ) { |
|
| 159 | - $title = get_the_title( $_POST['form_id'] ); |
|
| 160 | - if ( $title ) { |
|
| 158 | + if (isset($_POST['form_id'])) { |
|
| 159 | + $title = get_the_title($_POST['form_id']); |
|
| 160 | + if ($title) { |
|
| 161 | 161 | echo $title; |
| 162 | 162 | } else { |
| 163 | 163 | echo 'fail'; |
@@ -166,8 +166,8 @@ discard block |
||
| 166 | 166 | give_die(); |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | -add_action( 'wp_ajax_give_get_form_title', 'give_ajax_get_form_title' ); |
|
| 170 | -add_action( 'wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title' ); |
|
| 169 | +add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title'); |
|
| 170 | +add_action('wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title'); |
|
| 171 | 171 | |
| 172 | 172 | /** |
| 173 | 173 | * Retrieve a states drop down |
@@ -177,23 +177,23 @@ discard block |
||
| 177 | 177 | */ |
| 178 | 178 | function give_ajax_get_states_field() { |
| 179 | 179 | |
| 180 | - if ( empty( $_POST['country'] ) ) { |
|
| 180 | + if (empty($_POST['country'])) { |
|
| 181 | 181 | $_POST['country'] = give_get_country(); |
| 182 | 182 | } |
| 183 | - $states = give_get_states( $_POST['country'] ); |
|
| 183 | + $states = give_get_states($_POST['country']); |
|
| 184 | 184 | |
| 185 | - if ( ! empty( $states ) ) { |
|
| 185 | + if ( ! empty($states)) { |
|
| 186 | 186 | |
| 187 | 187 | $args = array( |
| 188 | 188 | 'name' => $_POST['field_name'], |
| 189 | 189 | 'id' => $_POST['field_name'], |
| 190 | - 'class' => $_POST['field_name'] . ' give-select', |
|
| 191 | - 'options' => give_get_states( $_POST['country'] ), |
|
| 190 | + 'class' => $_POST['field_name'].' give-select', |
|
| 191 | + 'options' => give_get_states($_POST['country']), |
|
| 192 | 192 | 'show_option_all' => false, |
| 193 | 193 | 'show_option_none' => false |
| 194 | 194 | ); |
| 195 | 195 | |
| 196 | - $response = Give()->html->select( $args ); |
|
| 196 | + $response = Give()->html->select($args); |
|
| 197 | 197 | |
| 198 | 198 | } else { |
| 199 | 199 | |
@@ -205,8 +205,8 @@ discard block |
||
| 205 | 205 | give_die(); |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | -add_action( 'wp_ajax_give_get_states', 'give_ajax_get_states_field' ); |
|
| 209 | -add_action( 'wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field' ); |
|
| 208 | +add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field'); |
|
| 209 | +add_action('wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field'); |
|
| 210 | 210 | |
| 211 | 211 | /** |
| 212 | 212 | * Retrieve a states drop down |
@@ -217,17 +217,17 @@ discard block |
||
| 217 | 217 | function give_ajax_form_search() { |
| 218 | 218 | global $wpdb; |
| 219 | 219 | |
| 220 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
| 220 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
| 221 | 221 | $results = array(); |
| 222 | - if ( current_user_can( 'edit_give_forms' ) ) { |
|
| 223 | - $items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50" ); |
|
| 222 | + if (current_user_can('edit_give_forms')) { |
|
| 223 | + $items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50"); |
|
| 224 | 224 | } else { |
| 225 | - $items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50" ); |
|
| 225 | + $items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50"); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - if ( $items ) { |
|
| 228 | + if ($items) { |
|
| 229 | 229 | |
| 230 | - foreach ( $items as $item ) { |
|
| 230 | + foreach ($items as $item) { |
|
| 231 | 231 | |
| 232 | 232 | $results[] = array( |
| 233 | 233 | 'id' => $item->ID, |
@@ -239,18 +239,18 @@ discard block |
||
| 239 | 239 | |
| 240 | 240 | $items[] = array( |
| 241 | 241 | 'id' => 0, |
| 242 | - 'name' => __( 'No results found', 'give' ) |
|
| 242 | + 'name' => __('No results found', 'give') |
|
| 243 | 243 | ); |
| 244 | 244 | |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - echo json_encode( $results ); |
|
| 247 | + echo json_encode($results); |
|
| 248 | 248 | |
| 249 | 249 | give_die(); |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | -add_action( 'wp_ajax_give_form_search', 'give_ajax_form_search' ); |
|
| 253 | -add_action( 'wp_ajax_nopriv_give_form_search', 'give_ajax_form_search' ); |
|
| 252 | +add_action('wp_ajax_give_form_search', 'give_ajax_form_search'); |
|
| 253 | +add_action('wp_ajax_nopriv_give_form_search', 'give_ajax_form_search'); |
|
| 254 | 254 | |
| 255 | 255 | /** |
| 256 | 256 | * Search the donors database via Ajax |
@@ -261,21 +261,21 @@ discard block |
||
| 261 | 261 | function give_ajax_donor_search() { |
| 262 | 262 | global $wpdb; |
| 263 | 263 | |
| 264 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
| 264 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
| 265 | 265 | $results = array(); |
| 266 | - if ( ! current_user_can( 'view_give_reports' ) ) { |
|
| 266 | + if ( ! current_user_can('view_give_reports')) { |
|
| 267 | 267 | $donors = array(); |
| 268 | 268 | } else { |
| 269 | - $donors = $wpdb->get_results( "SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50" ); |
|
| 269 | + $donors = $wpdb->get_results("SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50"); |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - if ( $donors ) { |
|
| 272 | + if ($donors) { |
|
| 273 | 273 | |
| 274 | - foreach ( $donors as $donor ) { |
|
| 274 | + foreach ($donors as $donor) { |
|
| 275 | 275 | |
| 276 | 276 | $results[] = array( |
| 277 | 277 | 'id' => $donor->id, |
| 278 | - 'name' => $donor->name . '(' . $donor->email . ')' |
|
| 278 | + 'name' => $donor->name.'('.$donor->email.')' |
|
| 279 | 279 | ); |
| 280 | 280 | } |
| 281 | 281 | |
@@ -283,17 +283,17 @@ discard block |
||
| 283 | 283 | |
| 284 | 284 | $donors[] = array( |
| 285 | 285 | 'id' => 0, |
| 286 | - 'name' => __( 'No results found', 'give' ) |
|
| 286 | + 'name' => __('No results found', 'give') |
|
| 287 | 287 | ); |
| 288 | 288 | |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - echo json_encode( $results ); |
|
| 291 | + echo json_encode($results); |
|
| 292 | 292 | |
| 293 | 293 | give_die(); |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | -add_action( 'wp_ajax_give_donor_search', 'give_ajax_donor_search' ); |
|
| 296 | +add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search'); |
|
| 297 | 297 | |
| 298 | 298 | |
| 299 | 299 | /** |
@@ -304,30 +304,30 @@ discard block |
||
| 304 | 304 | */ |
| 305 | 305 | function give_ajax_search_users() { |
| 306 | 306 | |
| 307 | - if ( current_user_can( 'manage_give_settings' ) ) { |
|
| 307 | + if (current_user_can('manage_give_settings')) { |
|
| 308 | 308 | |
| 309 | - $search_query = trim( $_POST['user_name'] ); |
|
| 309 | + $search_query = trim($_POST['user_name']); |
|
| 310 | 310 | |
| 311 | - $found_users = get_users( array( |
|
| 311 | + $found_users = get_users(array( |
|
| 312 | 312 | 'number' => 9999, |
| 313 | - 'search' => $search_query . '*' |
|
| 313 | + 'search' => $search_query.'*' |
|
| 314 | 314 | ) |
| 315 | 315 | ); |
| 316 | 316 | |
| 317 | 317 | $user_list = '<ul>'; |
| 318 | - if ( $found_users ) { |
|
| 319 | - foreach ( $found_users as $user ) { |
|
| 320 | - $user_list .= '<li><a href="#" data-login="' . esc_attr( $user->user_login ) . '">' . esc_html( $user->user_login ) . '</a></li>'; |
|
| 318 | + if ($found_users) { |
|
| 319 | + foreach ($found_users as $user) { |
|
| 320 | + $user_list .= '<li><a href="#" data-login="'.esc_attr($user->user_login).'">'.esc_html($user->user_login).'</a></li>'; |
|
| 321 | 321 | } |
| 322 | 322 | } else { |
| 323 | - $user_list .= '<li>' . __( 'No users found', 'give' ) . '</li>'; |
|
| 323 | + $user_list .= '<li>'.__('No users found', 'give').'</li>'; |
|
| 324 | 324 | } |
| 325 | 325 | $user_list .= '</ul>'; |
| 326 | 326 | |
| 327 | - echo json_encode( array( 'results' => $user_list ) ); |
|
| 327 | + echo json_encode(array('results' => $user_list)); |
|
| 328 | 328 | |
| 329 | 329 | } |
| 330 | 330 | die(); |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | -add_action( 'wp_ajax_give_search_users', 'give_ajax_search_users' ); |
|
| 334 | 333 | \ No newline at end of file |
| 334 | +add_action('wp_ajax_give_search_users', 'give_ajax_search_users'); |
|
| 335 | 335 | \ No newline at end of file |
@@ -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 | |
@@ -32,25 +32,25 @@ discard block |
||
| 32 | 32 | give_setup_post_types(); |
| 33 | 33 | |
| 34 | 34 | // Clear the permalinks |
| 35 | - flush_rewrite_rules( false ); |
|
| 35 | + flush_rewrite_rules(false); |
|
| 36 | 36 | |
| 37 | 37 | // Add Upgraded From Option |
| 38 | - $current_version = get_option( 'give_version' ); |
|
| 39 | - if ( $current_version ) { |
|
| 40 | - update_option( 'give_version_upgraded_from', $current_version ); |
|
| 38 | + $current_version = get_option('give_version'); |
|
| 39 | + if ($current_version) { |
|
| 40 | + update_option('give_version_upgraded_from', $current_version); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | // Setup some default options |
| 44 | 44 | $options = array(); |
| 45 | 45 | |
| 46 | 46 | // Checks if the Success Page option exists AND that the page exists |
| 47 | - if ( ! get_post( give_get_option( 'success_page' ) ) ) { |
|
| 47 | + if ( ! get_post(give_get_option('success_page'))) { |
|
| 48 | 48 | |
| 49 | 49 | // Purchase Confirmation (Success) Page |
| 50 | 50 | $success = wp_insert_post( |
| 51 | 51 | array( |
| 52 | - 'post_title' => __( 'Donation Confirmation', 'give' ), |
|
| 53 | - 'post_content' => __( '[give_receipt]', 'give' ), |
|
| 52 | + 'post_title' => __('Donation Confirmation', 'give'), |
|
| 53 | + 'post_content' => __('[give_receipt]', 'give'), |
|
| 54 | 54 | 'post_status' => 'publish', |
| 55 | 55 | 'post_author' => 1, |
| 56 | 56 | 'post_type' => 'page', |
@@ -63,13 +63,13 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | // Checks if the Failure Page option exists AND that the page exists |
| 66 | - if ( ! get_post( give_get_option( 'failure_page' ) ) ) { |
|
| 66 | + if ( ! get_post(give_get_option('failure_page'))) { |
|
| 67 | 67 | |
| 68 | 68 | // Failed Purchase Page |
| 69 | 69 | $failed = wp_insert_post( |
| 70 | 70 | array( |
| 71 | - 'post_title' => __( 'Transaction Failed', 'give' ), |
|
| 72 | - 'post_content' => __( 'We\'re sorry, your transaction failed to process. Please try again or contact site support.', 'give' ), |
|
| 71 | + 'post_title' => __('Transaction Failed', 'give'), |
|
| 72 | + 'post_content' => __('We\'re sorry, your transaction failed to process. Please try again or contact site support.', 'give'), |
|
| 73 | 73 | 'post_status' => 'publish', |
| 74 | 74 | 'post_author' => 1, |
| 75 | 75 | 'post_type' => 'page', |
@@ -81,11 +81,11 @@ discard block |
||
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | // Checks if the History Page option exists AND that the page exists |
| 84 | - if ( ! get_post( give_get_option( 'history_page' ) ) ) { |
|
| 84 | + if ( ! get_post(give_get_option('history_page'))) { |
|
| 85 | 85 | // Purchase History (History) Page |
| 86 | 86 | $history = wp_insert_post( |
| 87 | 87 | array( |
| 88 | - 'post_title' => __( 'Donation History', 'give' ), |
|
| 88 | + 'post_title' => __('Donation History', 'give'), |
|
| 89 | 89 | 'post_content' => '[donation_history]', |
| 90 | 90 | 'post_status' => 'publish', |
| 91 | 91 | 'post_author' => 1, |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | //Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency |
| 101 | - if ( empty( $current_version ) ) { |
|
| 101 | + if (empty($current_version)) { |
|
| 102 | 102 | $options['base_country'] = 'US'; |
| 103 | 103 | $options['test_mode'] = 1; |
| 104 | 104 | $options['currency'] = 'USD'; |
@@ -115,12 +115,12 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | // Populate some default values |
| 118 | - update_option( 'give_settings', array_merge( $give_options, $options ) ); |
|
| 119 | - update_option( 'give_version', GIVE_VERSION ); |
|
| 118 | + update_option('give_settings', array_merge($give_options, $options)); |
|
| 119 | + update_option('give_version', GIVE_VERSION); |
|
| 120 | 120 | |
| 121 | 121 | //Update Version Number |
| 122 | - if ( $current_version ) { |
|
| 123 | - update_option( 'give_version_upgraded_from', $current_version ); |
|
| 122 | + if ($current_version) { |
|
| 123 | + update_option('give_version_upgraded_from', $current_version); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | // Create Give roles |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | $roles->add_caps(); |
| 130 | 130 | |
| 131 | 131 | $api = new Give_API(); |
| 132 | - update_option( 'give_default_api_version', 'v' . $api->get_version() ); |
|
| 132 | + update_option('give_default_api_version', 'v'.$api->get_version()); |
|
| 133 | 133 | |
| 134 | 134 | // Create the customers database |
| 135 | 135 | @Give()->customers->create_table(); |
@@ -138,11 +138,11 @@ discard block |
||
| 138 | 138 | Give()->session->use_php_sessions(); |
| 139 | 139 | |
| 140 | 140 | // Add a temporary option to note that Give pages have been created |
| 141 | - set_transient( '_give_installed', $options, 30 ); |
|
| 141 | + set_transient('_give_installed', $options, 30); |
|
| 142 | 142 | |
| 143 | 143 | |
| 144 | - if ( ! $current_version ) { |
|
| 145 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
| 144 | + if ( ! $current_version) { |
|
| 145 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
| 146 | 146 | |
| 147 | 147 | // When new upgrade routines are added, mark them as complete on fresh install |
| 148 | 148 | $upgrade_routines = array( |
@@ -150,20 +150,20 @@ discard block |
||
| 150 | 150 | 'upgrade_give_offline_status' |
| 151 | 151 | ); |
| 152 | 152 | |
| 153 | - foreach ( $upgrade_routines as $upgrade ) { |
|
| 154 | - give_set_upgrade_complete( $upgrade ); |
|
| 153 | + foreach ($upgrade_routines as $upgrade) { |
|
| 154 | + give_set_upgrade_complete($upgrade); |
|
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | // Bail if activating from network, or bulk |
| 158 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
| 158 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
| 159 | 159 | return; |
| 160 | 160 | } |
| 161 | 161 | // Add the transient to redirect |
| 162 | - set_transient( '_give_activation_redirect', true, 30 ); |
|
| 162 | + set_transient('_give_activation_redirect', true, 30); |
|
| 163 | 163 | |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | -register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' ); |
|
| 166 | +register_activation_hook(GIVE_PLUGIN_FILE, 'give_install'); |
|
| 167 | 167 | |
| 168 | 168 | /** |
| 169 | 169 | * Post-installation |
@@ -175,14 +175,14 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | function give_after_install() { |
| 177 | 177 | |
| 178 | - if ( ! is_admin() ) { |
|
| 178 | + if ( ! is_admin()) { |
|
| 179 | 179 | return; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - $give_options = get_transient( '_give_installed' ); |
|
| 182 | + $give_options = get_transient('_give_installed'); |
|
| 183 | 183 | |
| 184 | 184 | // Exit if not in admin or the transient doesn't exist |
| 185 | - if ( false === $give_options ) { |
|
| 185 | + if (false === $give_options) { |
|
| 186 | 186 | return; |
| 187 | 187 | } |
| 188 | 188 | |
@@ -190,13 +190,13 @@ discard block |
||
| 190 | 190 | @Give()->customers->create_table(); |
| 191 | 191 | |
| 192 | 192 | // Delete the transient |
| 193 | - delete_transient( '_give_installed' ); |
|
| 193 | + delete_transient('_give_installed'); |
|
| 194 | 194 | |
| 195 | - do_action( 'give_after_install', $give_options ); |
|
| 195 | + do_action('give_after_install', $give_options); |
|
| 196 | 196 | |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | -add_action( 'admin_init', 'give_after_install' ); |
|
| 199 | +add_action('admin_init', 'give_after_install'); |
|
| 200 | 200 | |
| 201 | 201 | |
| 202 | 202 | /** |
@@ -211,11 +211,11 @@ discard block |
||
| 211 | 211 | |
| 212 | 212 | global $wp_roles; |
| 213 | 213 | |
| 214 | - if ( ! is_object( $wp_roles ) ) { |
|
| 214 | + if ( ! is_object($wp_roles)) { |
|
| 215 | 215 | return; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) { |
|
| 218 | + if ( ! array_key_exists('give_manager', $wp_roles->roles)) { |
|
| 219 | 219 | |
| 220 | 220 | // Create Give shop roles |
| 221 | 221 | $roles = new Give_Roles; |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | -add_action( 'admin_init', 'give_install_roles_on_network' ); |
|
| 229 | +add_action('admin_init', 'give_install_roles_on_network'); |
|
| 230 | 230 | |
| 231 | 231 | /** |
| 232 | 232 | * Network Activated New Site Setup |
@@ -242,12 +242,12 @@ discard block |
||
| 242 | 242 | * @param $site_id |
| 243 | 243 | * @param $meta |
| 244 | 244 | */ |
| 245 | -function on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { |
|
| 246 | - if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) { |
|
| 247 | - switch_to_blog( $blog_id ); |
|
| 245 | +function on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) { |
|
| 246 | + if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) { |
|
| 247 | + switch_to_blog($blog_id); |
|
| 248 | 248 | give_install(); |
| 249 | 249 | restore_current_blog(); |
| 250 | 250 | } |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | -add_action( 'wpmu_new_blog', 'on_create_blog', 10, 6 ); |
|
| 254 | 253 | \ No newline at end of file |
| 254 | +add_action('wpmu_new_blog', 'on_create_blog', 10, 6); |
|
| 255 | 255 | \ No newline at end of file |