@@ -521,7 +521,7 @@ |
||
| 521 | 521 | * |
| 522 | 522 | * @since 1.8.17 |
| 523 | 523 | * |
| 524 | - * @return bool |
|
| 524 | + * @return false|null |
|
| 525 | 525 | */ |
| 526 | 526 | function give_confirm_email_for_donation_access() { |
| 527 | 527 | |
@@ -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 | |
@@ -26,31 +26,31 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | function give_test_ajax_works() { |
| 28 | 28 | // Handle ajax. |
| 29 | - if ( doing_action( 'wp_ajax_nopriv_give_test_ajax' ) ) { |
|
| 30 | - wp_die( 0, 200 ); |
|
| 29 | + if (doing_action('wp_ajax_nopriv_give_test_ajax')) { |
|
| 30 | + wp_die(0, 200); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | // Check if the Airplane Mode plugin is installed. |
| 34 | - if ( class_exists( 'Airplane_Mode_Core' ) ) { |
|
| 34 | + if (class_exists('Airplane_Mode_Core')) { |
|
| 35 | 35 | |
| 36 | 36 | $airplane = Airplane_Mode_Core::getInstance(); |
| 37 | 37 | |
| 38 | - if ( method_exists( $airplane, 'enabled' ) ) { |
|
| 38 | + if (method_exists($airplane, 'enabled')) { |
|
| 39 | 39 | |
| 40 | - if ( $airplane->enabled() ) { |
|
| 40 | + if ($airplane->enabled()) { |
|
| 41 | 41 | return true; |
| 42 | 42 | } |
| 43 | 43 | } else { |
| 44 | 44 | |
| 45 | - if ( 'on' === $airplane->check_status() ) { |
|
| 45 | + if ('on' === $airplane->check_status()) { |
|
| 46 | 46 | return true; |
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - add_filter( 'block_local_requests', '__return_false' ); |
|
| 51 | + add_filter('block_local_requests', '__return_false'); |
|
| 52 | 52 | |
| 53 | - if ( Give_Cache::get( '_give_ajax_works', true ) ) { |
|
| 53 | + if (Give_Cache::get('_give_ajax_works', true)) { |
|
| 54 | 54 | return true; |
| 55 | 55 | } |
| 56 | 56 | |
@@ -62,41 +62,41 @@ discard block |
||
| 62 | 62 | ), |
| 63 | 63 | ); |
| 64 | 64 | |
| 65 | - $ajax = wp_remote_post( give_get_ajax_url(), $params ); |
|
| 65 | + $ajax = wp_remote_post(give_get_ajax_url(), $params); |
|
| 66 | 66 | |
| 67 | 67 | $works = true; |
| 68 | 68 | |
| 69 | - if ( is_wp_error( $ajax ) ) { |
|
| 69 | + if (is_wp_error($ajax)) { |
|
| 70 | 70 | |
| 71 | 71 | $works = false; |
| 72 | 72 | |
| 73 | 73 | } else { |
| 74 | 74 | |
| 75 | - if ( empty( $ajax['response'] ) ) { |
|
| 75 | + if (empty($ajax['response'])) { |
|
| 76 | 76 | $works = false; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - if ( empty( $ajax['response']['code'] ) || 200 !== (int) $ajax['response']['code'] ) { |
|
| 79 | + if (empty($ajax['response']['code']) || 200 !== (int) $ajax['response']['code']) { |
|
| 80 | 80 | $works = false; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if ( empty( $ajax['response']['message'] ) || 'OK' !== $ajax['response']['message'] ) { |
|
| 83 | + if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) { |
|
| 84 | 84 | $works = false; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - if ( ! isset( $ajax['body'] ) || 0 !== (int) $ajax['body'] ) { |
|
| 87 | + if ( ! isset($ajax['body']) || 0 !== (int) $ajax['body']) { |
|
| 88 | 88 | $works = false; |
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - if ( $works ) { |
|
| 93 | - Give_Cache::set( '_give_ajax_works', '1', DAY_IN_SECONDS, true ); |
|
| 92 | + if ($works) { |
|
| 93 | + Give_Cache::set('_give_ajax_works', '1', DAY_IN_SECONDS, true); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - return apply_filters( 'give_test_ajax_works', $works ); |
|
| 96 | + return apply_filters('give_test_ajax_works', $works); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | -add_action( 'wp_ajax_nopriv_give_test_ajax', 'give_test_ajax_works' ); |
|
| 99 | +add_action('wp_ajax_nopriv_give_test_ajax', 'give_test_ajax_works'); |
|
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | 102 | * Get AJAX URL |
@@ -107,21 +107,21 @@ discard block |
||
| 107 | 107 | * |
| 108 | 108 | * @return string |
| 109 | 109 | */ |
| 110 | -function give_get_ajax_url( $query = array() ) { |
|
| 111 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
| 110 | +function give_get_ajax_url($query = array()) { |
|
| 111 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
| 112 | 112 | |
| 113 | 113 | $current_url = give_get_current_page_url(); |
| 114 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
| 114 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
| 115 | 115 | |
| 116 | - if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) { |
|
| 117 | - $ajax_url = preg_replace( '/^http/', 'https', $ajax_url ); |
|
| 116 | + if (preg_match('/^https/', $current_url) && ! preg_match('/^https/', $ajax_url)) { |
|
| 117 | + $ajax_url = preg_replace('/^http/', 'https', $ajax_url); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - if ( ! empty( $query ) ) { |
|
| 121 | - $ajax_url = add_query_arg( $query, $ajax_url ); |
|
| 120 | + if ( ! empty($query)) { |
|
| 121 | + $ajax_url = add_query_arg($query, $ajax_url); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - return apply_filters( 'give_ajax_url', $ajax_url ); |
|
| 124 | + return apply_filters('give_ajax_url', $ajax_url); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -137,12 +137,12 @@ discard block |
||
| 137 | 137 | * |
| 138 | 138 | * @since 1.7 |
| 139 | 139 | */ |
| 140 | - do_action( 'give_donation_form_login_fields' ); |
|
| 140 | + do_action('give_donation_form_login_fields'); |
|
| 141 | 141 | |
| 142 | 142 | give_die(); |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | -add_action( 'wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields' ); |
|
| 145 | +add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields'); |
|
| 146 | 146 | |
| 147 | 147 | /** |
| 148 | 148 | * Load Checkout Fields |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * @return void |
| 153 | 153 | */ |
| 154 | 154 | function give_load_checkout_fields() { |
| 155 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : ''; |
|
| 155 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : ''; |
|
| 156 | 156 | |
| 157 | 157 | ob_start(); |
| 158 | 158 | |
@@ -161,18 +161,18 @@ discard block |
||
| 161 | 161 | * |
| 162 | 162 | * @since 1.7 |
| 163 | 163 | */ |
| 164 | - do_action( 'give_donation_form_register_login_fields', $form_id ); |
|
| 164 | + do_action('give_donation_form_register_login_fields', $form_id); |
|
| 165 | 165 | |
| 166 | 166 | $fields = ob_get_clean(); |
| 167 | 167 | |
| 168 | - wp_send_json( array( |
|
| 169 | - 'fields' => wp_json_encode( $fields ), |
|
| 170 | - 'submit' => wp_json_encode( give_get_donation_form_submit_button( $form_id ) ), |
|
| 171 | - ) ); |
|
| 168 | + wp_send_json(array( |
|
| 169 | + 'fields' => wp_json_encode($fields), |
|
| 170 | + 'submit' => wp_json_encode(give_get_donation_form_submit_button($form_id)), |
|
| 171 | + )); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | -add_action( 'wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields' ); |
|
| 175 | -add_action( 'wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields' ); |
|
| 174 | +add_action('wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields'); |
|
| 175 | +add_action('wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields'); |
|
| 176 | 176 | |
| 177 | 177 | /** |
| 178 | 178 | * Get Form Title via AJAX (used only in WordPress Admin) |
@@ -182,9 +182,9 @@ discard block |
||
| 182 | 182 | * @return void |
| 183 | 183 | */ |
| 184 | 184 | function give_ajax_get_form_title() { |
| 185 | - if ( isset( $_POST['form_id'] ) ) { |
|
| 186 | - $title = get_the_title( $_POST['form_id'] ); |
|
| 187 | - if ( $title ) { |
|
| 185 | + if (isset($_POST['form_id'])) { |
|
| 186 | + $title = get_the_title($_POST['form_id']); |
|
| 187 | + if ($title) { |
|
| 188 | 188 | echo $title; |
| 189 | 189 | } else { |
| 190 | 190 | echo 'fail'; |
@@ -193,8 +193,8 @@ discard block |
||
| 193 | 193 | give_die(); |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | -add_action( 'wp_ajax_give_get_form_title', 'give_ajax_get_form_title' ); |
|
| 197 | -add_action( 'wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title' ); |
|
| 196 | +add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title'); |
|
| 197 | +add_action('wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title'); |
|
| 198 | 198 | |
| 199 | 199 | /** |
| 200 | 200 | * Retrieve a states drop down |
@@ -208,41 +208,41 @@ discard block |
||
| 208 | 208 | $show_field = true; |
| 209 | 209 | $states_require = true; |
| 210 | 210 | // Get the Country code from the $_POST. |
| 211 | - $country = sanitize_text_field( $_POST['country'] ); |
|
| 211 | + $country = sanitize_text_field($_POST['country']); |
|
| 212 | 212 | |
| 213 | 213 | // Get the field name from the $_POST. |
| 214 | - $field_name = sanitize_text_field( $_POST['field_name'] ); |
|
| 214 | + $field_name = sanitize_text_field($_POST['field_name']); |
|
| 215 | 215 | |
| 216 | - $label = __( 'State', 'give' ); |
|
| 216 | + $label = __('State', 'give'); |
|
| 217 | 217 | $states_label = give_get_states_label(); |
| 218 | 218 | |
| 219 | 219 | $default_state = ''; |
| 220 | - if ( $country === give_get_country() ) { |
|
| 220 | + if ($country === give_get_country()) { |
|
| 221 | 221 | $default_state = give_get_state(); |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | // Check if $country code exists in the array key for states label. |
| 225 | - if ( array_key_exists( $country, $states_label ) ) { |
|
| 226 | - $label = $states_label[ $country ]; |
|
| 225 | + if (array_key_exists($country, $states_label)) { |
|
| 226 | + $label = $states_label[$country]; |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - if ( empty( $country ) ) { |
|
| 229 | + if (empty($country)) { |
|
| 230 | 230 | $country = give_get_country(); |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - $states = give_get_states( $country ); |
|
| 234 | - if ( ! empty( $states ) ) { |
|
| 235 | - $args = array( |
|
| 233 | + $states = give_get_states($country); |
|
| 234 | + if ( ! empty($states)) { |
|
| 235 | + $args = array( |
|
| 236 | 236 | 'name' => $field_name, |
| 237 | 237 | 'id' => $field_name, |
| 238 | - 'class' => $field_name . ' give-select', |
|
| 238 | + 'class' => $field_name.' give-select', |
|
| 239 | 239 | 'options' => $states, |
| 240 | 240 | 'show_option_all' => false, |
| 241 | 241 | 'show_option_none' => false, |
| 242 | 242 | 'placeholder' => $label, |
| 243 | 243 | 'selected' => $default_state, |
| 244 | 244 | ); |
| 245 | - $data = Give()->html->select( $args ); |
|
| 245 | + $data = Give()->html->select($args); |
|
| 246 | 246 | $states_found = true; |
| 247 | 247 | } else { |
| 248 | 248 | $data = 'nostates'; |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | $no_states_country = give_no_states_country_list(); |
| 252 | 252 | |
| 253 | 253 | // Check if $country code exists in the array key. |
| 254 | - if ( array_key_exists( $country, $no_states_country ) ) { |
|
| 254 | + if (array_key_exists($country, $no_states_country)) { |
|
| 255 | 255 | $show_field = false; |
| 256 | 256 | } |
| 257 | 257 | |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | $states_not_required_country_list = give_states_not_required_country_list(); |
| 260 | 260 | |
| 261 | 261 | // Check if $country code exists in the array key. |
| 262 | - if ( array_key_exists( $country, $states_not_required_country_list ) ) { |
|
| 262 | + if (array_key_exists($country, $states_not_required_country_list)) { |
|
| 263 | 263 | $states_require = false; |
| 264 | 264 | } |
| 265 | 265 | } |
@@ -272,11 +272,11 @@ discard block |
||
| 272 | 272 | 'data' => $data, |
| 273 | 273 | 'default_state' => $default_state, |
| 274 | 274 | ); |
| 275 | - wp_send_json( $response ); |
|
| 275 | + wp_send_json($response); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | -add_action( 'wp_ajax_give_get_states', 'give_ajax_get_states_field' ); |
|
| 279 | -add_action( 'wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field' ); |
|
| 278 | +add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field'); |
|
| 279 | +add_action('wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field'); |
|
| 280 | 280 | |
| 281 | 281 | /** |
| 282 | 282 | * Retrieve donation forms via AJAX for chosen dropdown search field. |
@@ -288,19 +288,19 @@ discard block |
||
| 288 | 288 | function give_ajax_form_search() { |
| 289 | 289 | global $wpdb; |
| 290 | 290 | |
| 291 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
| 292 | - $excludes = ( isset( $_GET['current_id'] ) ? (array) $_GET['current_id'] : array() ); |
|
| 291 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
| 292 | + $excludes = (isset($_GET['current_id']) ? (array) $_GET['current_id'] : array()); |
|
| 293 | 293 | |
| 294 | 294 | $results = array(); |
| 295 | - if ( current_user_can( 'edit_give_forms' ) ) { |
|
| 296 | - $items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50" ); |
|
| 295 | + if (current_user_can('edit_give_forms')) { |
|
| 296 | + $items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50"); |
|
| 297 | 297 | } else { |
| 298 | - $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" ); |
|
| 298 | + $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"); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - if ( $items ) { |
|
| 301 | + if ($items) { |
|
| 302 | 302 | |
| 303 | - foreach ( $items as $item ) { |
|
| 303 | + foreach ($items as $item) { |
|
| 304 | 304 | |
| 305 | 305 | $results[] = array( |
| 306 | 306 | 'id' => $item->ID, |
@@ -311,18 +311,18 @@ discard block |
||
| 311 | 311 | |
| 312 | 312 | $items[] = array( |
| 313 | 313 | 'id' => 0, |
| 314 | - 'name' => __( 'No forms found.', 'give' ), |
|
| 314 | + 'name' => __('No forms found.', 'give'), |
|
| 315 | 315 | ); |
| 316 | 316 | |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - echo json_encode( $results ); |
|
| 319 | + echo json_encode($results); |
|
| 320 | 320 | |
| 321 | 321 | give_die(); |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | -add_action( 'wp_ajax_give_form_search', 'give_ajax_form_search' ); |
|
| 325 | -add_action( 'wp_ajax_nopriv_give_form_search', 'give_ajax_form_search' ); |
|
| 324 | +add_action('wp_ajax_give_form_search', 'give_ajax_form_search'); |
|
| 325 | +add_action('wp_ajax_nopriv_give_form_search', 'give_ajax_form_search'); |
|
| 326 | 326 | |
| 327 | 327 | /** |
| 328 | 328 | * Search the donors database via Ajax |
@@ -334,38 +334,38 @@ discard block |
||
| 334 | 334 | function give_ajax_donor_search() { |
| 335 | 335 | global $wpdb; |
| 336 | 336 | |
| 337 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
| 337 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
| 338 | 338 | $results = array(); |
| 339 | - if ( ! current_user_can( 'view_give_reports' ) ) { |
|
| 339 | + if ( ! current_user_can('view_give_reports')) { |
|
| 340 | 340 | $donors = array(); |
| 341 | 341 | } else { |
| 342 | - $donors = $wpdb->get_results( "SELECT id,name,email FROM $wpdb->donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50" ); |
|
| 342 | + $donors = $wpdb->get_results("SELECT id,name,email FROM $wpdb->donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50"); |
|
| 343 | 343 | } |
| 344 | 344 | |
| 345 | - if ( $donors ) { |
|
| 345 | + if ($donors) { |
|
| 346 | 346 | |
| 347 | - foreach ( $donors as $donor ) { |
|
| 347 | + foreach ($donors as $donor) { |
|
| 348 | 348 | |
| 349 | 349 | $results[] = array( |
| 350 | 350 | 'id' => $donor->id, |
| 351 | - 'name' => $donor->name . ' (' . $donor->email . ')', |
|
| 351 | + 'name' => $donor->name.' ('.$donor->email.')', |
|
| 352 | 352 | ); |
| 353 | 353 | } |
| 354 | 354 | } else { |
| 355 | 355 | |
| 356 | 356 | $donors[] = array( |
| 357 | 357 | 'id' => 0, |
| 358 | - 'name' => __( 'No donors found.', 'give' ), |
|
| 358 | + 'name' => __('No donors found.', 'give'), |
|
| 359 | 359 | ); |
| 360 | 360 | |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | - echo json_encode( $results ); |
|
| 363 | + echo json_encode($results); |
|
| 364 | 364 | |
| 365 | 365 | give_die(); |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | -add_action( 'wp_ajax_give_donor_search', 'give_ajax_donor_search' ); |
|
| 368 | +add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search'); |
|
| 369 | 369 | |
| 370 | 370 | |
| 371 | 371 | /** |
@@ -377,39 +377,39 @@ discard block |
||
| 377 | 377 | */ |
| 378 | 378 | function give_ajax_search_users() { |
| 379 | 379 | |
| 380 | - if ( current_user_can( 'manage_give_settings' ) ) { |
|
| 380 | + if (current_user_can('manage_give_settings')) { |
|
| 381 | 381 | |
| 382 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
| 382 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
| 383 | 383 | |
| 384 | 384 | $get_users_args = array( |
| 385 | 385 | 'number' => 9999, |
| 386 | - 'search' => $search . '*', |
|
| 386 | + 'search' => $search.'*', |
|
| 387 | 387 | ); |
| 388 | 388 | |
| 389 | - $get_users_args = apply_filters( 'give_search_users_args', $get_users_args ); |
|
| 389 | + $get_users_args = apply_filters('give_search_users_args', $get_users_args); |
|
| 390 | 390 | |
| 391 | - $found_users = apply_filters( 'give_ajax_found_users', get_users( $get_users_args ), $search ); |
|
| 391 | + $found_users = apply_filters('give_ajax_found_users', get_users($get_users_args), $search); |
|
| 392 | 392 | $results = array(); |
| 393 | 393 | |
| 394 | - if ( $found_users ) { |
|
| 394 | + if ($found_users) { |
|
| 395 | 395 | |
| 396 | - foreach ( $found_users as $user ) { |
|
| 396 | + foreach ($found_users as $user) { |
|
| 397 | 397 | |
| 398 | 398 | $results[] = array( |
| 399 | 399 | 'id' => $user->ID, |
| 400 | - 'name' => esc_html( $user->user_login . ' (' . $user->user_email . ')' ), |
|
| 400 | + 'name' => esc_html($user->user_login.' ('.$user->user_email.')'), |
|
| 401 | 401 | ); |
| 402 | 402 | } |
| 403 | 403 | } else { |
| 404 | 404 | |
| 405 | 405 | $results[] = array( |
| 406 | 406 | 'id' => 0, |
| 407 | - 'name' => __( 'No users found.', 'give' ), |
|
| 407 | + 'name' => __('No users found.', 'give'), |
|
| 408 | 408 | ); |
| 409 | 409 | |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | - echo json_encode( $results ); |
|
| 412 | + echo json_encode($results); |
|
| 413 | 413 | |
| 414 | 414 | }// End if(). |
| 415 | 415 | |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | |
| 418 | 418 | } |
| 419 | 419 | |
| 420 | -add_action( 'wp_ajax_give_user_search', 'give_ajax_search_users' ); |
|
| 420 | +add_action('wp_ajax_give_user_search', 'give_ajax_search_users'); |
|
| 421 | 421 | |
| 422 | 422 | |
| 423 | 423 | /** |
@@ -429,32 +429,32 @@ discard block |
||
| 429 | 429 | */ |
| 430 | 430 | function give_check_for_form_price_variations() { |
| 431 | 431 | |
| 432 | - if ( ! current_user_can( 'edit_give_forms', get_current_user_id() ) ) { |
|
| 433 | - die( '-1' ); |
|
| 432 | + if ( ! current_user_can('edit_give_forms', get_current_user_id())) { |
|
| 433 | + die('-1'); |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - $form_id = intval( $_POST['form_id'] ); |
|
| 437 | - $form = get_post( $form_id ); |
|
| 436 | + $form_id = intval($_POST['form_id']); |
|
| 437 | + $form = get_post($form_id); |
|
| 438 | 438 | |
| 439 | - if ( 'give_forms' !== $form->post_type ) { |
|
| 440 | - die( '-2' ); |
|
| 439 | + if ('give_forms' !== $form->post_type) { |
|
| 440 | + die('-2'); |
|
| 441 | 441 | } |
| 442 | 442 | |
| 443 | - if ( give_has_variable_prices( $form_id ) ) { |
|
| 444 | - $variable_prices = give_get_variable_prices( $form_id ); |
|
| 443 | + if (give_has_variable_prices($form_id)) { |
|
| 444 | + $variable_prices = give_get_variable_prices($form_id); |
|
| 445 | 445 | |
| 446 | - if ( $variable_prices ) { |
|
| 446 | + if ($variable_prices) { |
|
| 447 | 447 | $ajax_response = '<select class="give_price_options_select give-select give-select" name="give_price_option">'; |
| 448 | 448 | |
| 449 | - if ( isset( $_POST['all_prices'] ) ) { |
|
| 450 | - $ajax_response .= '<option value="all">' . esc_html__( 'All Levels', 'give' ) . '</option>'; |
|
| 449 | + if (isset($_POST['all_prices'])) { |
|
| 450 | + $ajax_response .= '<option value="all">'.esc_html__('All Levels', 'give').'</option>'; |
|
| 451 | 451 | } |
| 452 | 452 | |
| 453 | - foreach ( $variable_prices as $key => $price ) { |
|
| 453 | + foreach ($variable_prices as $key => $price) { |
|
| 454 | 454 | |
| 455 | - $level_text = ! empty( $price['_give_text'] ) ? esc_html( $price['_give_text'] ) : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ); |
|
| 455 | + $level_text = ! empty($price['_give_text']) ? esc_html($price['_give_text']) : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false))); |
|
| 456 | 456 | |
| 457 | - $ajax_response .= '<option value="' . esc_attr( $price['_give_id']['level_id'] ) . '">' . $level_text . '</option>'; |
|
| 457 | + $ajax_response .= '<option value="'.esc_attr($price['_give_id']['level_id']).'">'.$level_text.'</option>'; |
|
| 458 | 458 | } |
| 459 | 459 | $ajax_response .= '</select>'; |
| 460 | 460 | echo $ajax_response; |
@@ -464,7 +464,7 @@ discard block |
||
| 464 | 464 | give_die(); |
| 465 | 465 | } |
| 466 | 466 | |
| 467 | -add_action( 'wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations' ); |
|
| 467 | +add_action('wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations'); |
|
| 468 | 468 | |
| 469 | 469 | |
| 470 | 470 | /** |
@@ -475,28 +475,28 @@ discard block |
||
| 475 | 475 | * @return void |
| 476 | 476 | */ |
| 477 | 477 | function give_check_for_form_price_variations_html() { |
| 478 | - if ( ! current_user_can( 'edit_give_payments', get_current_user_id() ) ) { |
|
| 478 | + if ( ! current_user_can('edit_give_payments', get_current_user_id())) { |
|
| 479 | 479 | wp_die(); |
| 480 | 480 | } |
| 481 | 481 | |
| 482 | - $form_id = ! empty( $_POST['form_id'] ) ? intval( $_POST['form_id'] ) : false; |
|
| 483 | - $payment_id = ! empty( $_POST['payment_id'] ) ? intval( $_POST['payment_id'] ) : false; |
|
| 484 | - if ( empty( $form_id ) || empty( $payment_id ) ) { |
|
| 482 | + $form_id = ! empty($_POST['form_id']) ? intval($_POST['form_id']) : false; |
|
| 483 | + $payment_id = ! empty($_POST['payment_id']) ? intval($_POST['payment_id']) : false; |
|
| 484 | + if (empty($form_id) || empty($payment_id)) { |
|
| 485 | 485 | wp_die(); |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | - $form = get_post( $form_id ); |
|
| 489 | - if ( ! empty( $form->post_type ) && 'give_forms' !== $form->post_type ) { |
|
| 488 | + $form = get_post($form_id); |
|
| 489 | + if ( ! empty($form->post_type) && 'give_forms' !== $form->post_type) { |
|
| 490 | 490 | wp_die(); |
| 491 | 491 | } |
| 492 | 492 | |
| 493 | - if ( ! give_has_variable_prices( $form_id ) || ! $form_id ) { |
|
| 494 | - esc_html_e( 'n/a', 'give' ); |
|
| 493 | + if ( ! give_has_variable_prices($form_id) || ! $form_id) { |
|
| 494 | + esc_html_e('n/a', 'give'); |
|
| 495 | 495 | } else { |
| 496 | 496 | $prices_atts = array(); |
| 497 | - if ( $variable_prices = give_get_variable_prices( $form_id ) ) { |
|
| 498 | - foreach ( $variable_prices as $variable_price ) { |
|
| 499 | - $prices_atts[ $variable_price['_give_id']['level_id'] ] = give_format_amount( $variable_price['_give_amount'], array( 'sanitize' => false ) ); |
|
| 497 | + if ($variable_prices = give_get_variable_prices($form_id)) { |
|
| 498 | + foreach ($variable_prices as $variable_price) { |
|
| 499 | + $prices_atts[$variable_price['_give_id']['level_id']] = give_format_amount($variable_price['_give_amount'], array('sanitize' => false)); |
|
| 500 | 500 | } |
| 501 | 501 | } |
| 502 | 502 | |
@@ -507,12 +507,12 @@ discard block |
||
| 507 | 507 | 'chosen' => true, |
| 508 | 508 | 'show_option_all' => '', |
| 509 | 509 | 'show_option_none' => '', |
| 510 | - 'select_atts' => 'data-prices=' . esc_attr( json_encode( $prices_atts ) ), |
|
| 510 | + 'select_atts' => 'data-prices='.esc_attr(json_encode($prices_atts)), |
|
| 511 | 511 | ); |
| 512 | 512 | |
| 513 | - if ( $payment_id ) { |
|
| 513 | + if ($payment_id) { |
|
| 514 | 514 | // Payment object. |
| 515 | - $payment = new Give_Payment( $payment_id ); |
|
| 515 | + $payment = new Give_Payment($payment_id); |
|
| 516 | 516 | |
| 517 | 517 | // Payment meta. |
| 518 | 518 | $payment_meta = $payment->get_meta(); |
@@ -520,13 +520,13 @@ discard block |
||
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | // Render variable prices select tag html. |
| 523 | - give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true ); |
|
| 523 | + give_get_form_variable_price_dropdown($variable_price_dropdown_option, true); |
|
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 526 | give_die(); |
| 527 | 527 | } |
| 528 | 528 | |
| 529 | -add_action( 'wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html' ); |
|
| 529 | +add_action('wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html'); |
|
| 530 | 530 | |
| 531 | 531 | /** |
| 532 | 532 | * Send Confirmation Email For Complete Donation History Access. |
@@ -538,24 +538,24 @@ discard block |
||
| 538 | 538 | function give_confirm_email_for_donation_access() { |
| 539 | 539 | |
| 540 | 540 | // Verify Security using Nonce. |
| 541 | - if ( ! check_ajax_referer( 'give_ajax_nonce', 'nonce' ) ) { |
|
| 541 | + if ( ! check_ajax_referer('give_ajax_nonce', 'nonce')) { |
|
| 542 | 542 | return false; |
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | // Bail Out, if email is empty. |
| 546 | - if ( empty( $_POST['email'] ) ) { |
|
| 546 | + if (empty($_POST['email'])) { |
|
| 547 | 547 | return false; |
| 548 | 548 | } |
| 549 | 549 | |
| 550 | - $donor = Give()->donors->get_donor_by( 'email', give_clean( $_POST['email'] ) ); |
|
| 551 | - if ( Give()->email_access->can_send_email( $donor->id ) ) { |
|
| 550 | + $donor = Give()->donors->get_donor_by('email', give_clean($_POST['email'])); |
|
| 551 | + if (Give()->email_access->can_send_email($donor->id)) { |
|
| 552 | 552 | $return = array(); |
| 553 | - $email_sent = Give()->email_access->send_email( $donor->id, $donor->email ); |
|
| 553 | + $email_sent = Give()->email_access->send_email($donor->id, $donor->email); |
|
| 554 | 554 | |
| 555 | - if ( ! $email_sent ) { |
|
| 555 | + if ( ! $email_sent) { |
|
| 556 | 556 | $return['status'] = 'error'; |
| 557 | 557 | $return['message'] = Give()->notices->print_frontend_notice( |
| 558 | - __( 'Unable to send email. Please try again.', 'give' ), |
|
| 558 | + __('Unable to send email. Please try again.', 'give'), |
|
| 559 | 559 | false, |
| 560 | 560 | 'error' |
| 561 | 561 | ); |
@@ -563,7 +563,7 @@ discard block |
||
| 563 | 563 | |
| 564 | 564 | $return['status'] = 'success'; |
| 565 | 565 | $return['message'] = Give()->notices->print_frontend_notice( |
| 566 | - __( 'Please check your email and click on the link to access your complete donation history.', 'give' ), |
|
| 566 | + __('Please check your email and click on the link to access your complete donation history.', 'give'), |
|
| 567 | 567 | false, |
| 568 | 568 | 'success' |
| 569 | 569 | ); |
@@ -574,16 +574,16 @@ discard block |
||
| 574 | 574 | $return['status'] = 'error'; |
| 575 | 575 | $return['message'] = Give()->notices->print_frontend_notice( |
| 576 | 576 | sprintf( |
| 577 | - __( 'Too many access email requests detected. Please wait %s before requesting a new donation history access link.', 'give' ), |
|
| 578 | - sprintf( _n( '%s minute', '%s minutes', $value, 'give' ), $value ) |
|
| 577 | + __('Too many access email requests detected. Please wait %s before requesting a new donation history access link.', 'give'), |
|
| 578 | + sprintf(_n('%s minute', '%s minutes', $value, 'give'), $value) |
|
| 579 | 579 | ), |
| 580 | 580 | false, |
| 581 | 581 | 'error' |
| 582 | 582 | ); |
| 583 | 583 | } |
| 584 | 584 | |
| 585 | - echo json_encode( $return ); |
|
| 585 | + echo json_encode($return); |
|
| 586 | 586 | give_die(); |
| 587 | 587 | } |
| 588 | 588 | |
| 589 | -add_action( 'wp_ajax_nopriv_give_confirm_email_for_donations_access', 'give_confirm_email_for_donation_access' ); |
|
| 590 | 589 | \ No newline at end of file |
| 590 | +add_action('wp_ajax_nopriv_give_confirm_email_for_donations_access', 'give_confirm_email_for_donation_access'); |
|
| 591 | 591 | \ No newline at end of file |
@@ -242,7 +242,7 @@ |
||
| 242 | 242 | * @since 1.0 |
| 243 | 243 | * @access public |
| 244 | 244 | * |
| 245 | - * @return bool |
|
| 245 | + * @return boolean|null |
|
| 246 | 246 | */ |
| 247 | 247 | public function check_for_token() { |
| 248 | 248 | |
@@ -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 | |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | public function __construct() { |
| 107 | 107 | |
| 108 | 108 | // get it started |
| 109 | - add_action( 'init', array( $this, 'init' ) ); |
|
| 109 | + add_action('init', array($this, 'init')); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
@@ -122,28 +122,28 @@ discard block |
||
| 122 | 122 | public function init() { |
| 123 | 123 | |
| 124 | 124 | // Bail Out, if user is logged in. |
| 125 | - if ( is_user_logged_in() ) { |
|
| 125 | + if (is_user_logged_in()) { |
|
| 126 | 126 | return; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | // Are db columns setup? |
| 130 | - $column_exists = Give()->donors->does_column_exist( 'token' ); |
|
| 131 | - if ( ! $column_exists ) { |
|
| 130 | + $column_exists = Give()->donors->does_column_exist('token'); |
|
| 131 | + if ( ! $column_exists) { |
|
| 132 | 132 | $this->create_columns(); |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | // Timeouts. |
| 136 | - $this->verify_throttle = apply_filters( 'give_nl_verify_throttle', 300 ); |
|
| 137 | - $this->limit_throttle = apply_filters( 'give_nl_limit_throttle', 3 ); |
|
| 138 | - $this->token_expiration = apply_filters( 'give_nl_token_expiration', 7200 ); |
|
| 136 | + $this->verify_throttle = apply_filters('give_nl_verify_throttle', 300); |
|
| 137 | + $this->limit_throttle = apply_filters('give_nl_limit_throttle', 3); |
|
| 138 | + $this->token_expiration = apply_filters('give_nl_token_expiration', 7200); |
|
| 139 | 139 | |
| 140 | 140 | // Setup login. |
| 141 | 141 | $this->check_for_token(); |
| 142 | 142 | |
| 143 | - if ( $this->token_exists ) { |
|
| 144 | - add_filter( 'give_can_view_receipt', '__return_true' ); |
|
| 145 | - add_filter( 'give_user_pending_verification', '__return_false' ); |
|
| 146 | - add_filter( 'give_get_users_donations_args', array( $this, 'users_donations_args' ) ); |
|
| 143 | + if ($this->token_exists) { |
|
| 144 | + add_filter('give_can_view_receipt', '__return_true'); |
|
| 145 | + add_filter('give_user_pending_verification', '__return_false'); |
|
| 146 | + add_filter('give_get_users_donations_args', array($this, 'users_donations_args')); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | } |
@@ -158,23 +158,23 @@ discard block |
||
| 158 | 158 | * |
| 159 | 159 | * @return bool |
| 160 | 160 | */ |
| 161 | - public function can_send_email( $donor_id ) { |
|
| 161 | + public function can_send_email($donor_id) { |
|
| 162 | 162 | |
| 163 | - $donor = Give()->donors->get_donor_by( 'id', $donor_id ); |
|
| 163 | + $donor = Give()->donors->get_donor_by('id', $donor_id); |
|
| 164 | 164 | |
| 165 | - if ( is_object( $donor ) && count( $donor ) > 0 ) { |
|
| 165 | + if (is_object($donor) && count($donor) > 0) { |
|
| 166 | 166 | |
| 167 | - $email_throttle_count = (int) give_get_meta( $donor_id, '_give_email_throttle_count', true ); |
|
| 167 | + $email_throttle_count = (int) give_get_meta($donor_id, '_give_email_throttle_count', true); |
|
| 168 | 168 | |
| 169 | 169 | $cache_key = "give_cache_email_throttle_limit_exhausted_{$donor_id}"; |
| 170 | 170 | if ( |
| 171 | 171 | $email_throttle_count < $this->limit_throttle && |
| 172 | - true !== Give_Cache::get( $cache_key ) |
|
| 172 | + true !== Give_Cache::get($cache_key) |
|
| 173 | 173 | ) { |
| 174 | - give_update_meta( $donor_id, '_give_email_throttle_count', $email_throttle_count + 1 ); |
|
| 174 | + give_update_meta($donor_id, '_give_email_throttle_count', $email_throttle_count + 1); |
|
| 175 | 175 | } else { |
| 176 | - give_update_meta( $donor_id, '_give_email_throttle_count', 0 ); |
|
| 177 | - Give_Cache::set( $cache_key, true, $this->verify_throttle ); |
|
| 176 | + give_update_meta($donor_id, '_give_email_throttle_count', 0); |
|
| 177 | + Give_Cache::set($cache_key, true, $this->verify_throttle); |
|
| 178 | 178 | return false; |
| 179 | 179 | } |
| 180 | 180 | |
@@ -194,8 +194,8 @@ discard block |
||
| 194 | 194 | * |
| 195 | 195 | * @return bool |
| 196 | 196 | */ |
| 197 | - public function send_email( $donor_id, $email ) { |
|
| 198 | - return apply_filters( 'give_email-access_email_notification', $donor_id, $email ); |
|
| 197 | + public function send_email($donor_id, $email) { |
|
| 198 | + return apply_filters('give_email-access_email_notification', $donor_id, $email); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
@@ -208,28 +208,28 @@ discard block |
||
| 208 | 208 | */ |
| 209 | 209 | public function check_for_token() { |
| 210 | 210 | |
| 211 | - $token = isset( $_GET['give_nl'] ) ? $_GET['give_nl'] : ''; |
|
| 211 | + $token = isset($_GET['give_nl']) ? $_GET['give_nl'] : ''; |
|
| 212 | 212 | |
| 213 | 213 | // Check for cookie. |
| 214 | - if ( empty( $token ) ) { |
|
| 215 | - $token = isset( $_COOKIE['give_nl'] ) ? $_COOKIE['give_nl'] : ''; |
|
| 214 | + if (empty($token)) { |
|
| 215 | + $token = isset($_COOKIE['give_nl']) ? $_COOKIE['give_nl'] : ''; |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | // Must have a token. |
| 219 | - if ( ! empty( $token ) ) { |
|
| 219 | + if ( ! empty($token)) { |
|
| 220 | 220 | |
| 221 | - if ( ! $this->is_valid_token( $token ) ) { |
|
| 222 | - if ( ! $this->is_valid_verify_key( $token ) ) { |
|
| 221 | + if ( ! $this->is_valid_token($token)) { |
|
| 222 | + if ( ! $this->is_valid_verify_key($token)) { |
|
| 223 | 223 | return false; |
| 224 | 224 | } |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | // Set Receipt Access Session. |
| 228 | - Give()->session->set( 'receipt_access', true ); |
|
| 228 | + Give()->session->set('receipt_access', true); |
|
| 229 | 229 | $this->token_exists = true; |
| 230 | 230 | // Set cookie. |
| 231 | - $lifetime = current_time( 'timestamp' ) + Give()->session->set_expiration_time(); |
|
| 232 | - @setcookie( 'give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
| 231 | + $lifetime = current_time('timestamp') + Give()->session->set_expiration_time(); |
|
| 232 | + @setcookie('give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
| 233 | 233 | |
| 234 | 234 | return true; |
| 235 | 235 | } |
@@ -245,26 +245,26 @@ discard block |
||
| 245 | 245 | * |
| 246 | 246 | * @return bool |
| 247 | 247 | */ |
| 248 | - public function is_valid_token( $token ) { |
|
| 248 | + public function is_valid_token($token) { |
|
| 249 | 249 | |
| 250 | 250 | global $wpdb; |
| 251 | 251 | |
| 252 | 252 | // Make sure token isn't expired. |
| 253 | - $expires = date( 'Y-m-d H:i:s', time() - $this->token_expiration ); |
|
| 253 | + $expires = date('Y-m-d H:i:s', time() - $this->token_expiration); |
|
| 254 | 254 | |
| 255 | 255 | $email = $wpdb->get_var( |
| 256 | - $wpdb->prepare( "SELECT email FROM {$wpdb->donors} WHERE verify_key = %s AND verify_throttle >= %s LIMIT 1", $token, $expires ) |
|
| 256 | + $wpdb->prepare("SELECT email FROM {$wpdb->donors} WHERE verify_key = %s AND verify_throttle >= %s LIMIT 1", $token, $expires) |
|
| 257 | 257 | ); |
| 258 | 258 | |
| 259 | - if ( ! empty( $email ) ) { |
|
| 259 | + if ( ! empty($email)) { |
|
| 260 | 260 | $this->token_email = $email; |
| 261 | 261 | $this->token = $token; |
| 262 | 262 | return true; |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | // Set error only if email access form isn't being submitted. |
| 266 | - if ( ! isset( $_POST['give_email'] ) && ! isset( $_POST['_wpnonce'] ) ) { |
|
| 267 | - give_set_error( 'give_email_token_expired', apply_filters( 'give_email_token_expired_message', __( 'Your access token has expired. Please request a new one below:', 'give' ) ) ); |
|
| 266 | + if ( ! isset($_POST['give_email']) && ! isset($_POST['_wpnonce'])) { |
|
| 267 | + give_set_error('give_email_token_expired', apply_filters('give_email_token_expired_message', __('Your access token has expired. Please request a new one below:', 'give'))); |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | return false; |
@@ -283,25 +283,25 @@ discard block |
||
| 283 | 283 | * |
| 284 | 284 | * @return void |
| 285 | 285 | */ |
| 286 | - public function set_verify_key( $donor_id, $email, $verify_key ) { |
|
| 286 | + public function set_verify_key($donor_id, $email, $verify_key) { |
|
| 287 | 287 | global $wpdb; |
| 288 | 288 | |
| 289 | - $now = date( 'Y-m-d H:i:s' ); |
|
| 289 | + $now = date('Y-m-d H:i:s'); |
|
| 290 | 290 | |
| 291 | 291 | // Insert or update? |
| 292 | 292 | $row_id = (int) $wpdb->get_var( |
| 293 | - $wpdb->prepare( "SELECT id FROM {$wpdb->donors} WHERE id = %d LIMIT 1", $donor_id ) |
|
| 293 | + $wpdb->prepare("SELECT id FROM {$wpdb->donors} WHERE id = %d LIMIT 1", $donor_id) |
|
| 294 | 294 | ); |
| 295 | 295 | |
| 296 | 296 | // Update. |
| 297 | - if ( ! empty( $row_id ) ) { |
|
| 297 | + if ( ! empty($row_id)) { |
|
| 298 | 298 | $wpdb->query( |
| 299 | - $wpdb->prepare( "UPDATE {$wpdb->donors} SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id ) |
|
| 299 | + $wpdb->prepare("UPDATE {$wpdb->donors} SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id) |
|
| 300 | 300 | ); |
| 301 | 301 | } // Insert. |
| 302 | 302 | else { |
| 303 | 303 | $wpdb->query( |
| 304 | - $wpdb->prepare( "INSERT INTO {$wpdb->donors} ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now ) |
|
| 304 | + $wpdb->prepare("INSERT INTO {$wpdb->donors} ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now) |
|
| 305 | 305 | ); |
| 306 | 306 | } |
| 307 | 307 | } |
@@ -316,21 +316,21 @@ discard block |
||
| 316 | 316 | * |
| 317 | 317 | * @return bool |
| 318 | 318 | */ |
| 319 | - public function is_valid_verify_key( $token ) { |
|
| 319 | + public function is_valid_verify_key($token) { |
|
| 320 | 320 | /* @var WPDB $wpdb */ |
| 321 | 321 | global $wpdb; |
| 322 | 322 | |
| 323 | 323 | // See if the verify_key exists. |
| 324 | 324 | $row = $wpdb->get_row( |
| 325 | - $wpdb->prepare( "SELECT id, email FROM {$wpdb->donors} WHERE verify_key = %s LIMIT 1", $token ) |
|
| 325 | + $wpdb->prepare("SELECT id, email FROM {$wpdb->donors} WHERE verify_key = %s LIMIT 1", $token) |
|
| 326 | 326 | ); |
| 327 | 327 | |
| 328 | - $now = date( 'Y-m-d H:i:s' ); |
|
| 328 | + $now = date('Y-m-d H:i:s'); |
|
| 329 | 329 | |
| 330 | 330 | // Set token and remove verify key. |
| 331 | - if ( ! empty( $row ) ) { |
|
| 331 | + if ( ! empty($row)) { |
|
| 332 | 332 | $wpdb->query( |
| 333 | - $wpdb->prepare( "UPDATE {$wpdb->donors} SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id ) |
|
| 333 | + $wpdb->prepare("UPDATE {$wpdb->donors} SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id) |
|
| 334 | 334 | ); |
| 335 | 335 | |
| 336 | 336 | $this->token_email = $row->email; |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | * |
| 355 | 355 | * @return mixed |
| 356 | 356 | */ |
| 357 | - public function users_donations_args( $args ) { |
|
| 357 | + public function users_donations_args($args) { |
|
| 358 | 358 | $args['user'] = $this->token_email; |
| 359 | 359 | |
| 360 | 360 | return $args; |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | global $wpdb; |
| 376 | 376 | |
| 377 | 377 | // Create columns in donors table. |
| 378 | - $wpdb->query( "ALTER TABLE {$wpdb->donors} ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`" ); |
|
| 378 | + $wpdb->query("ALTER TABLE {$wpdb->donors} ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`"); |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | } |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | * @param string $user_login Username |
| 181 | 181 | * @param string $user_pass Password |
| 182 | 182 | * |
| 183 | - * @return bool |
|
| 183 | + * @return false|null |
|
| 184 | 184 | */ |
| 185 | 185 | function give_log_user_in( $user_id, $user_login, $user_pass ) { |
| 186 | 186 | |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | * |
| 222 | 222 | * @param array $data Data sent from the register form |
| 223 | 223 | * |
| 224 | - * @return bool |
|
| 224 | + * @return false|null |
|
| 225 | 225 | */ |
| 226 | 226 | function give_process_register_form( $data ) { |
| 227 | 227 | |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | * |
| 308 | 308 | * @since 1.8.17 |
| 309 | 309 | * |
| 310 | - * @return bool |
|
| 310 | + * @return boolean|null |
|
| 311 | 311 | */ |
| 312 | 312 | function give_email_access_login() { |
| 313 | 313 | |
@@ -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 | |
@@ -26,24 +26,24 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @return string Login form |
| 28 | 28 | */ |
| 29 | -function give_login_form( $login_redirect = '', $logout_redirect = '' ) { |
|
| 29 | +function give_login_form($login_redirect = '', $logout_redirect = '') { |
|
| 30 | 30 | |
| 31 | - if ( empty( $login_redirect ) ) { |
|
| 32 | - $login_redirect = add_query_arg( 'give-login-success', 'true', give_get_history_page_uri() ); |
|
| 31 | + if (empty($login_redirect)) { |
|
| 32 | + $login_redirect = add_query_arg('give-login-success', 'true', give_get_history_page_uri()); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if ( empty( $logout_redirect ) ) { |
|
| 36 | - $logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() ); |
|
| 35 | + if (empty($logout_redirect)) { |
|
| 36 | + $logout_redirect = add_query_arg('give-logout-success', 'true', give_get_current_page_url()); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | // Add user_logout action to logout url. |
| 40 | 40 | $logout_redirect = add_query_arg( |
| 41 | 41 | array( |
| 42 | 42 | 'give_action' => 'user_logout', |
| 43 | - 'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ), |
|
| 44 | - 'give_logout_redirect' => urlencode( $logout_redirect ), |
|
| 43 | + 'give_logout_nonce' => wp_create_nonce('give-logout-nonce'), |
|
| 44 | + 'give_logout_redirect' => urlencode($logout_redirect), |
|
| 45 | 45 | ), |
| 46 | - home_url( '/' ) |
|
| 46 | + home_url('/') |
|
| 47 | 47 | ); |
| 48 | 48 | |
| 49 | 49 | ob_start(); |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | ) |
| 57 | 57 | ); |
| 58 | 58 | |
| 59 | - return apply_filters( 'give_login_form', ob_get_clean() ); |
|
| 59 | + return apply_filters('give_login_form', ob_get_clean()); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -69,14 +69,14 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @return string Register form |
| 71 | 71 | */ |
| 72 | -function give_register_form( $redirect = '' ) { |
|
| 73 | - if ( empty( $redirect ) ) { |
|
| 72 | +function give_register_form($redirect = '') { |
|
| 73 | + if (empty($redirect)) { |
|
| 74 | 74 | $redirect = give_get_current_page_url(); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | ob_start(); |
| 78 | 78 | |
| 79 | - if ( ! is_user_logged_in() ) { |
|
| 79 | + if ( ! is_user_logged_in()) { |
|
| 80 | 80 | give_get_template( |
| 81 | 81 | 'shortcode-register', |
| 82 | 82 | array( |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | ); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - return apply_filters( 'give_register_form', ob_get_clean() ); |
|
| 88 | + return apply_filters('give_register_form', ob_get_clean()); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -97,40 +97,40 @@ discard block |
||
| 97 | 97 | * |
| 98 | 98 | * @return void |
| 99 | 99 | */ |
| 100 | -function give_process_login_form( $data ) { |
|
| 101 | - if ( wp_verify_nonce( $data['give_login_nonce'], 'give-login-nonce' ) ) { |
|
| 100 | +function give_process_login_form($data) { |
|
| 101 | + if (wp_verify_nonce($data['give_login_nonce'], 'give-login-nonce')) { |
|
| 102 | 102 | |
| 103 | 103 | // Set Receipt Access Session. |
| 104 | - if ( ! empty( $_GET['payment_key'] ) ) { |
|
| 105 | - Give()->session->set( 'receipt_access', true ); |
|
| 104 | + if ( ! empty($_GET['payment_key'])) { |
|
| 105 | + Give()->session->set('receipt_access', true); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - $user_data = get_user_by( 'login', $data['give_user_login'] ); |
|
| 109 | - if ( ! $user_data ) { |
|
| 110 | - $user_data = get_user_by( 'email', $data['give_user_login'] ); |
|
| 108 | + $user_data = get_user_by('login', $data['give_user_login']); |
|
| 109 | + if ( ! $user_data) { |
|
| 110 | + $user_data = get_user_by('email', $data['give_user_login']); |
|
| 111 | 111 | } |
| 112 | - if ( $user_data ) { |
|
| 112 | + if ($user_data) { |
|
| 113 | 113 | $user_ID = $user_data->ID; |
| 114 | 114 | $user_email = $user_data->user_email; |
| 115 | - if ( wp_check_password( $data['give_user_pass'], $user_data->user_pass, $user_ID ) ) { |
|
| 116 | - give_log_user_in( $user_data->ID, $data['give_user_login'], $data['give_user_pass'] ); |
|
| 115 | + if (wp_check_password($data['give_user_pass'], $user_data->user_pass, $user_ID)) { |
|
| 116 | + give_log_user_in($user_data->ID, $data['give_user_login'], $data['give_user_pass']); |
|
| 117 | 117 | } else { |
| 118 | - give_set_error( 'password_incorrect', __( 'The password you entered is incorrect.', 'give' ) ); |
|
| 118 | + give_set_error('password_incorrect', __('The password you entered is incorrect.', 'give')); |
|
| 119 | 119 | } |
| 120 | 120 | } else { |
| 121 | - give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) ); |
|
| 121 | + give_set_error('username_incorrect', __('The username you entered does not exist.', 'give')); |
|
| 122 | 122 | } |
| 123 | 123 | // Check for errors and redirect if none present |
| 124 | 124 | $errors = give_get_errors(); |
| 125 | - if ( ! $errors ) { |
|
| 126 | - $redirect = apply_filters( 'give_login_redirect', $data['give_login_redirect'], $user_ID ); |
|
| 127 | - wp_redirect( $redirect ); |
|
| 125 | + if ( ! $errors) { |
|
| 126 | + $redirect = apply_filters('give_login_redirect', $data['give_login_redirect'], $user_ID); |
|
| 127 | + wp_redirect($redirect); |
|
| 128 | 128 | give_die(); |
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | -add_action( 'give_user_login', 'give_process_login_form' ); |
|
| 133 | +add_action('give_user_login', 'give_process_login_form'); |
|
| 134 | 134 | |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -142,18 +142,18 @@ discard block |
||
| 142 | 142 | * |
| 143 | 143 | * @return void |
| 144 | 144 | */ |
| 145 | -function give_process_user_logout( $data ) { |
|
| 146 | - if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) { |
|
| 145 | +function give_process_user_logout($data) { |
|
| 146 | + if (wp_verify_nonce($data['give_logout_nonce'], 'give-logout-nonce') && is_user_logged_in()) { |
|
| 147 | 147 | |
| 148 | 148 | // Prevent occurring of any custom action on wp_logout. |
| 149 | - remove_all_actions( 'wp_logout' ); |
|
| 149 | + remove_all_actions('wp_logout'); |
|
| 150 | 150 | |
| 151 | 151 | /** |
| 152 | 152 | * Fires before processing user logout. |
| 153 | 153 | * |
| 154 | 154 | * @since 1.0 |
| 155 | 155 | */ |
| 156 | - do_action( 'give_before_user_logout' ); |
|
| 156 | + do_action('give_before_user_logout'); |
|
| 157 | 157 | |
| 158 | 158 | // Logout user. |
| 159 | 159 | wp_logout(); |
@@ -163,14 +163,14 @@ discard block |
||
| 163 | 163 | * |
| 164 | 164 | * @since 1.0 |
| 165 | 165 | */ |
| 166 | - do_action( 'give_after_user_logout' ); |
|
| 166 | + do_action('give_after_user_logout'); |
|
| 167 | 167 | |
| 168 | - wp_redirect( $data['give_logout_redirect'] ); |
|
| 168 | + wp_redirect($data['give_logout_redirect']); |
|
| 169 | 169 | give_die(); |
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | -add_action( 'give_user_logout', 'give_process_user_logout' ); |
|
| 173 | +add_action('give_user_logout', 'give_process_user_logout'); |
|
| 174 | 174 | |
| 175 | 175 | /** |
| 176 | 176 | * Log User In |
@@ -183,14 +183,14 @@ discard block |
||
| 183 | 183 | * |
| 184 | 184 | * @return bool |
| 185 | 185 | */ |
| 186 | -function give_log_user_in( $user_id, $user_login, $user_pass ) { |
|
| 186 | +function give_log_user_in($user_id, $user_login, $user_pass) { |
|
| 187 | 187 | |
| 188 | - if ( $user_id < 1 ) { |
|
| 188 | + if ($user_id < 1) { |
|
| 189 | 189 | return false; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - wp_set_auth_cookie( $user_id ); |
|
| 193 | - wp_set_current_user( $user_id, $user_login ); |
|
| 192 | + wp_set_auth_cookie($user_id); |
|
| 193 | + wp_set_current_user($user_id, $user_login); |
|
| 194 | 194 | |
| 195 | 195 | /** |
| 196 | 196 | * Fires after the user has successfully logged in. |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | * @param string $user_login Username. |
| 201 | 201 | * @param WP_User $$user WP_User object of the logged-in user. |
| 202 | 202 | */ |
| 203 | - do_action( 'wp_login', $user_login, get_userdata( $user_id ) ); |
|
| 203 | + do_action('wp_login', $user_login, get_userdata($user_id)); |
|
| 204 | 204 | |
| 205 | 205 | /** |
| 206 | 206 | * Fires after give user has successfully logged in. |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | * @param string $user_login Username. |
| 212 | 212 | * @param string $user_pass User password. |
| 213 | 213 | */ |
| 214 | - do_action( 'give_log_user_in', $user_id, $user_login, $user_pass ); |
|
| 214 | + do_action('give_log_user_in', $user_id, $user_login, $user_pass); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | |
@@ -224,13 +224,13 @@ discard block |
||
| 224 | 224 | * |
| 225 | 225 | * @return bool |
| 226 | 226 | */ |
| 227 | -function give_process_register_form( $data ) { |
|
| 227 | +function give_process_register_form($data) { |
|
| 228 | 228 | |
| 229 | - if ( is_user_logged_in() ) { |
|
| 229 | + if (is_user_logged_in()) { |
|
| 230 | 230 | return false; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - if ( empty( $_POST['give_register_submit'] ) ) { |
|
| 233 | + if (empty($_POST['give_register_submit'])) { |
|
| 234 | 234 | return false; |
| 235 | 235 | } |
| 236 | 236 | |
@@ -239,38 +239,38 @@ discard block |
||
| 239 | 239 | * |
| 240 | 240 | * @since 1.0 |
| 241 | 241 | */ |
| 242 | - do_action( 'give_pre_process_register_form' ); |
|
| 242 | + do_action('give_pre_process_register_form'); |
|
| 243 | 243 | |
| 244 | - if ( empty( $data['give_user_login'] ) ) { |
|
| 245 | - give_set_error( 'empty_username', esc_html__( 'Invalid username.', 'give' ) ); |
|
| 244 | + if (empty($data['give_user_login'])) { |
|
| 245 | + give_set_error('empty_username', esc_html__('Invalid username.', 'give')); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - if ( username_exists( $data['give_user_login'] ) ) { |
|
| 249 | - give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) ); |
|
| 248 | + if (username_exists($data['give_user_login'])) { |
|
| 249 | + give_set_error('username_unavailable', esc_html__('Username already taken.', 'give')); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - if ( ! validate_username( $data['give_user_login'] ) ) { |
|
| 253 | - give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) ); |
|
| 252 | + if ( ! validate_username($data['give_user_login'])) { |
|
| 253 | + give_set_error('username_invalid', esc_html__('Invalid username.', 'give')); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - if ( email_exists( $data['give_user_email'] ) ) { |
|
| 257 | - give_set_error( 'email_unavailable', esc_html__( 'Email address already taken.', 'give' ) ); |
|
| 256 | + if (email_exists($data['give_user_email'])) { |
|
| 257 | + give_set_error('email_unavailable', esc_html__('Email address already taken.', 'give')); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | - if ( empty( $data['give_user_email'] ) || ! is_email( $data['give_user_email'] ) ) { |
|
| 261 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
| 260 | + if (empty($data['give_user_email']) || ! is_email($data['give_user_email'])) { |
|
| 261 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - if ( ! empty( $data['give_payment_email'] ) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email( $data['give_payment_email'] ) ) { |
|
| 265 | - give_set_error( 'payment_email_invalid', esc_html__( 'Invalid payment email.', 'give' ) ); |
|
| 264 | + if ( ! empty($data['give_payment_email']) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email($data['give_payment_email'])) { |
|
| 265 | + give_set_error('payment_email_invalid', esc_html__('Invalid payment email.', 'give')); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - if ( empty( $_POST['give_user_pass'] ) ) { |
|
| 269 | - give_set_error( 'empty_password', esc_html__( 'Please enter a password.', 'give' ) ); |
|
| 268 | + if (empty($_POST['give_user_pass'])) { |
|
| 269 | + give_set_error('empty_password', esc_html__('Please enter a password.', 'give')); |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - if ( ( ! empty( $_POST['give_user_pass'] ) && empty( $_POST['give_user_pass2'] ) ) || ( $_POST['give_user_pass'] !== $_POST['give_user_pass2'] ) ) { |
|
| 273 | - give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) ); |
|
| 272 | + if (( ! empty($_POST['give_user_pass']) && empty($_POST['give_user_pass2'])) || ($_POST['give_user_pass'] !== $_POST['give_user_pass2'])) { |
|
| 273 | + give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give')); |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | /** |
@@ -278,29 +278,29 @@ discard block |
||
| 278 | 278 | * |
| 279 | 279 | * @since 1.0 |
| 280 | 280 | */ |
| 281 | - do_action( 'give_process_register_form' ); |
|
| 281 | + do_action('give_process_register_form'); |
|
| 282 | 282 | |
| 283 | 283 | // Check for errors and redirect if none present |
| 284 | 284 | $errors = give_get_errors(); |
| 285 | 285 | |
| 286 | - if ( empty( $errors ) ) { |
|
| 286 | + if (empty($errors)) { |
|
| 287 | 287 | |
| 288 | - $redirect = apply_filters( 'give_register_redirect', $data['give_redirect'] ); |
|
| 288 | + $redirect = apply_filters('give_register_redirect', $data['give_redirect']); |
|
| 289 | 289 | |
| 290 | - give_register_and_login_new_user( array( |
|
| 290 | + give_register_and_login_new_user(array( |
|
| 291 | 291 | 'user_login' => $data['give_user_login'], |
| 292 | 292 | 'user_pass' => $data['give_user_pass'], |
| 293 | 293 | 'user_email' => $data['give_user_email'], |
| 294 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
| 295 | - 'role' => get_option( 'default_role' ), |
|
| 296 | - ) ); |
|
| 294 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
| 295 | + 'role' => get_option('default_role'), |
|
| 296 | + )); |
|
| 297 | 297 | |
| 298 | - wp_redirect( $redirect ); |
|
| 298 | + wp_redirect($redirect); |
|
| 299 | 299 | give_die(); |
| 300 | 300 | } |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | -add_action( 'give_user_register', 'give_process_register_form' ); |
|
| 303 | +add_action('give_user_register', 'give_process_register_form'); |
|
| 304 | 304 | |
| 305 | 305 | |
| 306 | 306 | /** |
@@ -313,24 +313,24 @@ discard block |
||
| 313 | 313 | function give_email_access_login() { |
| 314 | 314 | |
| 315 | 315 | // Verify nonce. |
| 316 | - if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], 'give' ) ) { |
|
| 316 | + if ( ! isset($_POST['_wpnonce']) || ! wp_verify_nonce($_POST['_wpnonce'], 'give')) { |
|
| 317 | 317 | return false; |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | // Need email to proceed. |
| 321 | - $email = isset( $_POST['give_email'] ) ? give_clean( $_POST['give_email'] ) : ''; |
|
| 322 | - if ( empty( $email ) ) { |
|
| 323 | - give_set_error( 'give_empty_email', __( 'Please enter the email address you used for your donation.', 'give' ) ); |
|
| 321 | + $email = isset($_POST['give_email']) ? give_clean($_POST['give_email']) : ''; |
|
| 322 | + if (empty($email)) { |
|
| 323 | + give_set_error('give_empty_email', __('Please enter the email address you used for your donation.', 'give')); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - $recaptcha_key = give_get_option( 'recaptcha_key' ); |
|
| 327 | - $recaptcha_secret = give_get_option( 'recaptcha_secret' ); |
|
| 326 | + $recaptcha_key = give_get_option('recaptcha_key'); |
|
| 327 | + $recaptcha_secret = give_get_option('recaptcha_secret'); |
|
| 328 | 328 | |
| 329 | - $enable_recaptcha = ( give_is_setting_enabled( give_get_option( 'enable_recaptcha' ) ) ) && ! empty( $recaptcha_key ) && ! empty( $recaptcha_secret ) ? true : false; |
|
| 330 | - $access_token = ! empty( $_GET['payment_key'] ) ? $_GET['payment_key'] : ''; |
|
| 329 | + $enable_recaptcha = (give_is_setting_enabled(give_get_option('enable_recaptcha'))) && ! empty($recaptcha_key) && ! empty($recaptcha_secret) ? true : false; |
|
| 330 | + $access_token = ! empty($_GET['payment_key']) ? $_GET['payment_key'] : ''; |
|
| 331 | 331 | |
| 332 | 332 | // Use reCAPTCHA. |
| 333 | - if ( $enable_recaptcha ) { |
|
| 333 | + if ($enable_recaptcha) { |
|
| 334 | 334 | |
| 335 | 335 | $args = array( |
| 336 | 336 | 'secret' => $recaptcha_secret, |
@@ -338,43 +338,43 @@ discard block |
||
| 338 | 338 | 'remoteip' => $_POST['give_ip'], |
| 339 | 339 | ); |
| 340 | 340 | |
| 341 | - if ( ! empty( $args['response'] ) ) { |
|
| 342 | - $request = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', array( |
|
| 341 | + if ( ! empty($args['response'])) { |
|
| 342 | + $request = wp_remote_post('https://www.google.com/recaptcha/api/siteverify', array( |
|
| 343 | 343 | 'body' => $args, |
| 344 | - ) ); |
|
| 345 | - if ( ! is_wp_error( $request ) || 200 == wp_remote_retrieve_response_code( $request ) ) { |
|
| 344 | + )); |
|
| 345 | + if ( ! is_wp_error($request) || 200 == wp_remote_retrieve_response_code($request)) { |
|
| 346 | 346 | |
| 347 | - $response = json_decode( $request['body'], true ); |
|
| 347 | + $response = json_decode($request['body'], true); |
|
| 348 | 348 | |
| 349 | 349 | // reCAPTCHA fail. |
| 350 | - if ( ! $response['success'] ) { |
|
| 351 | - give_set_error( 'give_recaptcha_test_failed', apply_filters( 'give_recaptcha_test_failed_message', __( 'reCAPTCHA test failed.', 'give' ) ) ); |
|
| 350 | + if ( ! $response['success']) { |
|
| 351 | + give_set_error('give_recaptcha_test_failed', apply_filters('give_recaptcha_test_failed_message', __('reCAPTCHA test failed.', 'give'))); |
|
| 352 | 352 | } |
| 353 | 353 | } else { |
| 354 | 354 | |
| 355 | 355 | // Connection issue. |
| 356 | - give_set_error( 'give_recaptcha_connection_issue', apply_filters( 'give_recaptcha_connection_issue_message', __( 'Unable to connect to reCAPTCHA server.', 'give' ) ) ); |
|
| 356 | + give_set_error('give_recaptcha_connection_issue', apply_filters('give_recaptcha_connection_issue_message', __('Unable to connect to reCAPTCHA server.', 'give'))); |
|
| 357 | 357 | |
| 358 | 358 | } // End if(). |
| 359 | 359 | } else { |
| 360 | 360 | |
| 361 | - give_set_error( 'give_recaptcha_failed', apply_filters( 'give_recaptcha_failed_message', __( 'It looks like the reCAPTCHA test has failed.', 'give' ) ) ); |
|
| 361 | + give_set_error('give_recaptcha_failed', apply_filters('give_recaptcha_failed_message', __('It looks like the reCAPTCHA test has failed.', 'give'))); |
|
| 362 | 362 | |
| 363 | 363 | } // End if(). |
| 364 | 364 | } // End if(). |
| 365 | 365 | |
| 366 | 366 | // If no errors or only expired token key error - then send email. |
| 367 | - if ( ! give_get_errors() ) { |
|
| 367 | + if ( ! give_get_errors()) { |
|
| 368 | 368 | |
| 369 | - $donor = Give()->donors->get_donor_by( 'email', $email ); |
|
| 369 | + $donor = Give()->donors->get_donor_by('email', $email); |
|
| 370 | 370 | |
| 371 | 371 | Give()->email_access->init(); |
| 372 | 372 | |
| 373 | 373 | // Verify that donor object is present and donor is connected with its user profile or not. |
| 374 | - if ( is_object( $donor ) ) { |
|
| 374 | + if (is_object($donor)) { |
|
| 375 | 375 | |
| 376 | 376 | // Verify that email can be sent. |
| 377 | - if ( ! Give()->email_access->can_send_email( $donor->id ) ) { |
|
| 377 | + if ( ! Give()->email_access->can_send_email($donor->id)) { |
|
| 378 | 378 | |
| 379 | 379 | $_POST['email-access-exhausted'] = true; |
| 380 | 380 | |
@@ -382,10 +382,10 @@ discard block |
||
| 382 | 382 | |
| 383 | 383 | } else { |
| 384 | 384 | // Send the email. Requests not |
| 385 | - $email_sent = Give()->email_access->send_email( $donor->id, $donor->email ); |
|
| 385 | + $email_sent = Give()->email_access->send_email($donor->id, $donor->email); |
|
| 386 | 386 | |
| 387 | - if ( ! $email_sent ) { |
|
| 388 | - give_set_error( 'give_email_access_send_issue', __( 'Unable to send email. Please try again.', 'give' ) ); |
|
| 387 | + if ( ! $email_sent) { |
|
| 388 | + give_set_error('give_email_access_send_issue', __('Unable to send email. Please try again.', 'give')); |
|
| 389 | 389 | return false; |
| 390 | 390 | } |
| 391 | 391 | |
@@ -395,11 +395,11 @@ discard block |
||
| 395 | 395 | } |
| 396 | 396 | } else { |
| 397 | 397 | |
| 398 | - give_set_error( 'give-no-donations', __( 'We were unable to find any donations associated with the email address provided. Please try again using another email.', 'give' ) ); |
|
| 398 | + give_set_error('give-no-donations', __('We were unable to find any donations associated with the email address provided. Please try again using another email.', 'give')); |
|
| 399 | 399 | |
| 400 | 400 | } |
| 401 | 401 | } // End if(). |
| 402 | 402 | |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | -add_action( 'give_email_access_form_login', 'give_email_access_login' ); |
|
| 405 | +add_action('give_email_access_form_login', 'give_email_access_login'); |
|
@@ -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 | |
@@ -23,49 +23,49 @@ discard block |
||
| 23 | 23 | function give_setup_post_types() { |
| 24 | 24 | |
| 25 | 25 | // Give Forms single post and archive options. |
| 26 | - $give_forms_singular = give_is_setting_enabled( give_get_option( 'forms_singular' ) ); |
|
| 27 | - $give_forms_archives = give_is_setting_enabled( give_get_option( 'forms_archives' ) ); |
|
| 26 | + $give_forms_singular = give_is_setting_enabled(give_get_option('forms_singular')); |
|
| 27 | + $give_forms_archives = give_is_setting_enabled(give_get_option('forms_archives')); |
|
| 28 | 28 | |
| 29 | 29 | // Enable/Disable give_forms links if form is saving. |
| 30 | - if ( Give_Admin_Settings::is_saving_settings() ) { |
|
| 31 | - if ( isset( $_POST['forms_singular'] ) ) { |
|
| 32 | - $give_forms_singular = give_is_setting_enabled( give_clean( $_POST['forms_singular'] ) ); |
|
| 30 | + if (Give_Admin_Settings::is_saving_settings()) { |
|
| 31 | + if (isset($_POST['forms_singular'])) { |
|
| 32 | + $give_forms_singular = give_is_setting_enabled(give_clean($_POST['forms_singular'])); |
|
| 33 | 33 | flush_rewrite_rules(); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - if ( isset( $_POST['forms_archives'] ) ) { |
|
| 37 | - $give_forms_archives = give_is_setting_enabled( give_clean( $_POST['forms_archives'] ) ); |
|
| 36 | + if (isset($_POST['forms_archives'])) { |
|
| 37 | + $give_forms_archives = give_is_setting_enabled(give_clean($_POST['forms_archives'])); |
|
| 38 | 38 | flush_rewrite_rules(); |
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - $give_forms_slug = defined( 'GIVE_SLUG' ) ? GIVE_SLUG : 'donations'; |
|
| 42 | + $give_forms_slug = defined('GIVE_SLUG') ? GIVE_SLUG : 'donations'; |
|
| 43 | 43 | // Support for old 'GIVE_FORMS_SLUG' constant |
| 44 | - if ( defined( 'GIVE_FORMS_SLUG' ) ) { |
|
| 44 | + if (defined('GIVE_FORMS_SLUG')) { |
|
| 45 | 45 | $give_forms_slug = GIVE_FORMS_SLUG; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - $give_forms_rewrite = defined( 'GIVE_DISABLE_FORMS_REWRITE' ) && GIVE_DISABLE_FORMS_REWRITE ? false : array( |
|
| 48 | + $give_forms_rewrite = defined('GIVE_DISABLE_FORMS_REWRITE') && GIVE_DISABLE_FORMS_REWRITE ? false : array( |
|
| 49 | 49 | 'slug' => $give_forms_slug, |
| 50 | 50 | 'with_front' => false, |
| 51 | 51 | ); |
| 52 | 52 | |
| 53 | - $give_forms_labels = apply_filters( 'give_forms_labels', array( |
|
| 54 | - 'name' => __( 'Donation Forms', 'give' ), |
|
| 55 | - 'singular_name' => __( 'Form', 'give' ), |
|
| 56 | - 'add_new' => __( 'Add Form', 'give' ), |
|
| 57 | - 'add_new_item' => __( 'Add New Donation Form', 'give' ), |
|
| 58 | - 'edit_item' => __( 'Edit Donation Form', 'give' ), |
|
| 59 | - 'new_item' => __( 'New Form', 'give' ), |
|
| 60 | - 'all_items' => __( 'All Forms', 'give' ), |
|
| 61 | - 'view_item' => __( 'View Form', 'give' ), |
|
| 62 | - 'search_items' => __( 'Search Forms', 'give' ), |
|
| 63 | - 'not_found' => __( 'No forms found.', 'give' ), |
|
| 64 | - 'not_found_in_trash' => __( 'No forms found in Trash.', 'give' ), |
|
| 53 | + $give_forms_labels = apply_filters('give_forms_labels', array( |
|
| 54 | + 'name' => __('Donation Forms', 'give'), |
|
| 55 | + 'singular_name' => __('Form', 'give'), |
|
| 56 | + 'add_new' => __('Add Form', 'give'), |
|
| 57 | + 'add_new_item' => __('Add New Donation Form', 'give'), |
|
| 58 | + 'edit_item' => __('Edit Donation Form', 'give'), |
|
| 59 | + 'new_item' => __('New Form', 'give'), |
|
| 60 | + 'all_items' => __('All Forms', 'give'), |
|
| 61 | + 'view_item' => __('View Form', 'give'), |
|
| 62 | + 'search_items' => __('Search Forms', 'give'), |
|
| 63 | + 'not_found' => __('No forms found.', 'give'), |
|
| 64 | + 'not_found_in_trash' => __('No forms found in Trash.', 'give'), |
|
| 65 | 65 | 'parent_item_colon' => '', |
| 66 | - 'menu_name' => apply_filters( 'give_menu_name', __( 'Donations', 'give' ) ), |
|
| 67 | - 'name_admin_bar' => apply_filters( 'give_name_admin_bar_name', __( 'Donation Form', 'give' ) ), |
|
| 68 | - ) ); |
|
| 66 | + 'menu_name' => apply_filters('give_menu_name', __('Donations', 'give')), |
|
| 67 | + 'name_admin_bar' => apply_filters('give_name_admin_bar_name', __('Donation Form', 'give')), |
|
| 68 | + )); |
|
| 69 | 69 | |
| 70 | 70 | // Default give_forms supports. |
| 71 | 71 | $give_form_supports = array( |
@@ -77,14 +77,14 @@ discard block |
||
| 77 | 77 | ); |
| 78 | 78 | |
| 79 | 79 | // Has the user disabled the excerpt? |
| 80 | - if ( ! give_is_setting_enabled( give_get_option( 'forms_excerpt' ) ) ) { |
|
| 81 | - unset( $give_form_supports[2] ); |
|
| 80 | + if ( ! give_is_setting_enabled(give_get_option('forms_excerpt'))) { |
|
| 81 | + unset($give_form_supports[2]); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | // Has user disabled the featured image? |
| 85 | - if ( ! give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) { |
|
| 86 | - unset( $give_form_supports[1] ); |
|
| 87 | - remove_action( 'give_before_single_form_summary', 'give_show_form_images' ); |
|
| 85 | + if ( ! give_is_setting_enabled(give_get_option('form_featured_img'))) { |
|
| 86 | + unset($give_form_supports[1]); |
|
| 87 | + remove_action('give_before_single_form_summary', 'give_show_form_images'); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | $give_forms_args = array( |
@@ -99,42 +99,42 @@ discard block |
||
| 99 | 99 | 'has_archive' => $give_forms_archives, |
| 100 | 100 | 'menu_icon' => 'dashicons-give', |
| 101 | 101 | 'hierarchical' => false, |
| 102 | - 'supports' => apply_filters( 'give_forms_supports', $give_form_supports ), |
|
| 102 | + 'supports' => apply_filters('give_forms_supports', $give_form_supports), |
|
| 103 | 103 | ); |
| 104 | - register_post_type( 'give_forms', apply_filters( 'give_forms_post_type_args', $give_forms_args ) ); |
|
| 104 | + register_post_type('give_forms', apply_filters('give_forms_post_type_args', $give_forms_args)); |
|
| 105 | 105 | |
| 106 | 106 | /** Donation Post Type */ |
| 107 | 107 | $payment_labels = array( |
| 108 | - 'name' => _x( 'Donations', 'post type general name', 'give' ), |
|
| 109 | - 'singular_name' => _x( 'Donation', 'post type singular name', 'give' ), |
|
| 110 | - 'add_new' => __( 'Add New', 'give' ), |
|
| 111 | - 'add_new_item' => __( 'Add New Donation', 'give' ), |
|
| 112 | - 'edit_item' => __( 'Edit Donation', 'give' ), |
|
| 113 | - 'new_item' => __( 'New Donation', 'give' ), |
|
| 114 | - 'all_items' => __( 'All Donations', 'give' ), |
|
| 115 | - 'view_item' => __( 'View Donation', 'give' ), |
|
| 116 | - 'search_items' => __( 'Search Donations', 'give' ), |
|
| 117 | - 'not_found' => __( 'No donations found.', 'give' ), |
|
| 118 | - 'not_found_in_trash' => __( 'No donations found in Trash.', 'give' ), |
|
| 108 | + 'name' => _x('Donations', 'post type general name', 'give'), |
|
| 109 | + 'singular_name' => _x('Donation', 'post type singular name', 'give'), |
|
| 110 | + 'add_new' => __('Add New', 'give'), |
|
| 111 | + 'add_new_item' => __('Add New Donation', 'give'), |
|
| 112 | + 'edit_item' => __('Edit Donation', 'give'), |
|
| 113 | + 'new_item' => __('New Donation', 'give'), |
|
| 114 | + 'all_items' => __('All Donations', 'give'), |
|
| 115 | + 'view_item' => __('View Donation', 'give'), |
|
| 116 | + 'search_items' => __('Search Donations', 'give'), |
|
| 117 | + 'not_found' => __('No donations found.', 'give'), |
|
| 118 | + 'not_found_in_trash' => __('No donations found in Trash.', 'give'), |
|
| 119 | 119 | 'parent_item_colon' => '', |
| 120 | - 'menu_name' => __( 'Donations', 'give' ), |
|
| 120 | + 'menu_name' => __('Donations', 'give'), |
|
| 121 | 121 | ); |
| 122 | 122 | |
| 123 | 123 | $payment_args = array( |
| 124 | - 'labels' => apply_filters( 'give_payment_labels', $payment_labels ), |
|
| 124 | + 'labels' => apply_filters('give_payment_labels', $payment_labels), |
|
| 125 | 125 | 'public' => false, |
| 126 | 126 | 'query_var' => false, |
| 127 | 127 | 'rewrite' => false, |
| 128 | 128 | 'map_meta_cap' => true, |
| 129 | 129 | 'capability_type' => 'give_payment', |
| 130 | - 'supports' => array( 'title' ), |
|
| 130 | + 'supports' => array('title'), |
|
| 131 | 131 | 'can_export' => true, |
| 132 | 132 | ); |
| 133 | - register_post_type( 'give_payment', $payment_args ); |
|
| 133 | + register_post_type('give_payment', $payment_args); |
|
| 134 | 134 | |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | -add_action( 'init', 'give_setup_post_types', 1 ); |
|
| 137 | +add_action('init', 'give_setup_post_types', 1); |
|
| 138 | 138 | |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -147,30 +147,30 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | function give_setup_taxonomies() { |
| 149 | 149 | |
| 150 | - $slug = defined( 'GIVE_FORMS_SLUG' ) ? GIVE_FORMS_SLUG : 'donations'; |
|
| 150 | + $slug = defined('GIVE_FORMS_SLUG') ? GIVE_FORMS_SLUG : 'donations'; |
|
| 151 | 151 | |
| 152 | 152 | /** Categories */ |
| 153 | 153 | $category_labels = array( |
| 154 | - 'name' => _x( 'Form Categories', 'taxonomy general name', 'give' ), |
|
| 155 | - 'singular_name' => _x( 'Category', 'taxonomy singular name', 'give' ), |
|
| 156 | - 'search_items' => __( 'Search Categories', 'give' ), |
|
| 157 | - 'all_items' => __( 'All Categories', 'give' ), |
|
| 158 | - 'parent_item' => __( 'Parent Category', 'give' ), |
|
| 159 | - 'parent_item_colon' => __( 'Parent Category:', 'give' ), |
|
| 160 | - 'edit_item' => __( 'Edit Category', 'give' ), |
|
| 161 | - 'update_item' => __( 'Update Category', 'give' ), |
|
| 162 | - 'add_new_item' => __( 'Add New Category', 'give' ), |
|
| 163 | - 'new_item_name' => __( 'New Category Name', 'give' ), |
|
| 164 | - 'menu_name' => __( 'Categories', 'give' ), |
|
| 154 | + 'name' => _x('Form Categories', 'taxonomy general name', 'give'), |
|
| 155 | + 'singular_name' => _x('Category', 'taxonomy singular name', 'give'), |
|
| 156 | + 'search_items' => __('Search Categories', 'give'), |
|
| 157 | + 'all_items' => __('All Categories', 'give'), |
|
| 158 | + 'parent_item' => __('Parent Category', 'give'), |
|
| 159 | + 'parent_item_colon' => __('Parent Category:', 'give'), |
|
| 160 | + 'edit_item' => __('Edit Category', 'give'), |
|
| 161 | + 'update_item' => __('Update Category', 'give'), |
|
| 162 | + 'add_new_item' => __('Add New Category', 'give'), |
|
| 163 | + 'new_item_name' => __('New Category Name', 'give'), |
|
| 164 | + 'menu_name' => __('Categories', 'give'), |
|
| 165 | 165 | ); |
| 166 | 166 | |
| 167 | - $category_args = apply_filters( 'give_forms_category_args', array( |
|
| 167 | + $category_args = apply_filters('give_forms_category_args', array( |
|
| 168 | 168 | 'hierarchical' => true, |
| 169 | - 'labels' => apply_filters( 'give_forms_category_labels', $category_labels ), |
|
| 169 | + 'labels' => apply_filters('give_forms_category_labels', $category_labels), |
|
| 170 | 170 | 'show_ui' => true, |
| 171 | 171 | 'query_var' => 'give_forms_category', |
| 172 | 172 | 'rewrite' => array( |
| 173 | - 'slug' => $slug . '/category', |
|
| 173 | + 'slug' => $slug.'/category', |
|
| 174 | 174 | 'with_front' => false, |
| 175 | 175 | 'hierarchical' => true, |
| 176 | 176 | ), |
@@ -185,26 +185,26 @@ discard block |
||
| 185 | 185 | |
| 186 | 186 | /** Tags */ |
| 187 | 187 | $tag_labels = array( |
| 188 | - 'name' => _x( 'Form Tags', 'taxonomy general name', 'give' ), |
|
| 189 | - 'singular_name' => _x( 'Tag', 'taxonomy singular name', 'give' ), |
|
| 190 | - 'search_items' => __( 'Search Tags', 'give' ), |
|
| 191 | - 'all_items' => __( 'All Tags', 'give' ), |
|
| 192 | - 'parent_item' => __( 'Parent Tag', 'give' ), |
|
| 193 | - 'parent_item_colon' => __( 'Parent Tag:', 'give' ), |
|
| 194 | - 'edit_item' => __( 'Edit Tag', 'give' ), |
|
| 195 | - 'update_item' => __( 'Update Tag', 'give' ), |
|
| 196 | - 'add_new_item' => __( 'Add New Tag', 'give' ), |
|
| 197 | - 'new_item_name' => __( 'New Tag Name', 'give' ), |
|
| 198 | - 'menu_name' => __( 'Tags', 'give' ), |
|
| 199 | - 'choose_from_most_used' => __( 'Choose from most used tags.', 'give' ), |
|
| 188 | + 'name' => _x('Form Tags', 'taxonomy general name', 'give'), |
|
| 189 | + 'singular_name' => _x('Tag', 'taxonomy singular name', 'give'), |
|
| 190 | + 'search_items' => __('Search Tags', 'give'), |
|
| 191 | + 'all_items' => __('All Tags', 'give'), |
|
| 192 | + 'parent_item' => __('Parent Tag', 'give'), |
|
| 193 | + 'parent_item_colon' => __('Parent Tag:', 'give'), |
|
| 194 | + 'edit_item' => __('Edit Tag', 'give'), |
|
| 195 | + 'update_item' => __('Update Tag', 'give'), |
|
| 196 | + 'add_new_item' => __('Add New Tag', 'give'), |
|
| 197 | + 'new_item_name' => __('New Tag Name', 'give'), |
|
| 198 | + 'menu_name' => __('Tags', 'give'), |
|
| 199 | + 'choose_from_most_used' => __('Choose from most used tags.', 'give'), |
|
| 200 | 200 | ); |
| 201 | 201 | |
| 202 | - $tag_args = apply_filters( 'give_forms_tag_args', array( |
|
| 202 | + $tag_args = apply_filters('give_forms_tag_args', array( |
|
| 203 | 203 | 'hierarchical' => false, |
| 204 | - 'labels' => apply_filters( 'give_forms_tag_labels', $tag_labels ), |
|
| 204 | + 'labels' => apply_filters('give_forms_tag_labels', $tag_labels), |
|
| 205 | 205 | 'show_ui' => true, |
| 206 | 206 | 'query_var' => 'give_forms_tag', |
| 207 | - 'rewrite' => array( 'slug' => $slug . '/tag', 'with_front' => false, 'hierarchical' => true ), |
|
| 207 | + 'rewrite' => array('slug' => $slug.'/tag', 'with_front' => false, 'hierarchical' => true), |
|
| 208 | 208 | 'capabilities' => array( |
| 209 | 209 | 'manage_terms' => 'manage_give_form_terms', |
| 210 | 210 | 'edit_terms' => 'edit_give_form_terms', |
@@ -215,36 +215,36 @@ discard block |
||
| 215 | 215 | ); |
| 216 | 216 | |
| 217 | 217 | // Does the user want category? |
| 218 | - $enable_category = give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ); |
|
| 218 | + $enable_category = give_is_setting_enabled(give_get_option('categories', 'disabled')); |
|
| 219 | 219 | |
| 220 | 220 | // Does the user want tag? |
| 221 | - $enable_tag = give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ); |
|
| 221 | + $enable_tag = give_is_setting_enabled(give_get_option('tags', 'disabled')); |
|
| 222 | 222 | |
| 223 | 223 | // Enable/Disable category and tag if form is saving. |
| 224 | - if ( Give_Admin_Settings::is_saving_settings() ) { |
|
| 225 | - if ( isset( $_POST['categories'] ) ) { |
|
| 226 | - $enable_category = give_is_setting_enabled( give_clean( $_POST['categories'] ) ); |
|
| 224 | + if (Give_Admin_Settings::is_saving_settings()) { |
|
| 225 | + if (isset($_POST['categories'])) { |
|
| 226 | + $enable_category = give_is_setting_enabled(give_clean($_POST['categories'])); |
|
| 227 | 227 | flush_rewrite_rules(); |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - if ( isset( $_POST['tags'] ) ) { |
|
| 231 | - $enable_tag = give_is_setting_enabled( give_clean( $_POST['tags'] ) ); |
|
| 230 | + if (isset($_POST['tags'])) { |
|
| 231 | + $enable_tag = give_is_setting_enabled(give_clean($_POST['tags'])); |
|
| 232 | 232 | flush_rewrite_rules(); |
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - if ( $enable_category ) { |
|
| 237 | - register_taxonomy( 'give_forms_category', array( 'give_forms' ), $category_args ); |
|
| 238 | - register_taxonomy_for_object_type( 'give_forms_category', 'give_forms' ); |
|
| 236 | + if ($enable_category) { |
|
| 237 | + register_taxonomy('give_forms_category', array('give_forms'), $category_args); |
|
| 238 | + register_taxonomy_for_object_type('give_forms_category', 'give_forms'); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - if ( $enable_tag ) { |
|
| 242 | - register_taxonomy( 'give_forms_tag', array( 'give_forms' ), $tag_args ); |
|
| 243 | - register_taxonomy_for_object_type( 'give_forms_tag', 'give_forms' ); |
|
| 241 | + if ($enable_tag) { |
|
| 242 | + register_taxonomy('give_forms_tag', array('give_forms'), $tag_args); |
|
| 243 | + register_taxonomy_for_object_type('give_forms_tag', 'give_forms'); |
|
| 244 | 244 | } |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | -add_action( 'init', 'give_setup_taxonomies', 0 ); |
|
| 247 | +add_action('init', 'give_setup_taxonomies', 0); |
|
| 248 | 248 | |
| 249 | 249 | |
| 250 | 250 | /** |
@@ -255,11 +255,11 @@ discard block |
||
| 255 | 255 | */ |
| 256 | 256 | function give_get_default_form_labels() { |
| 257 | 257 | $defaults = array( |
| 258 | - 'singular' => __( 'Form', 'give' ), |
|
| 259 | - 'plural' => __( 'Forms', 'give' ), |
|
| 258 | + 'singular' => __('Form', 'give'), |
|
| 259 | + 'plural' => __('Forms', 'give'), |
|
| 260 | 260 | ); |
| 261 | 261 | |
| 262 | - return apply_filters( 'give_default_form_name', $defaults ); |
|
| 262 | + return apply_filters('give_default_form_name', $defaults); |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | /** |
@@ -271,10 +271,10 @@ discard block |
||
| 271 | 271 | * |
| 272 | 272 | * @return string $defaults['singular'] Singular label |
| 273 | 273 | */ |
| 274 | -function give_get_forms_label_singular( $lowercase = false ) { |
|
| 274 | +function give_get_forms_label_singular($lowercase = false) { |
|
| 275 | 275 | $defaults = give_get_default_form_labels(); |
| 276 | 276 | |
| 277 | - return ( $lowercase ) ? strtolower( $defaults['singular'] ) : $defaults['singular']; |
|
| 277 | + return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular']; |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | /** |
@@ -283,10 +283,10 @@ discard block |
||
| 283 | 283 | * @since 1.0 |
| 284 | 284 | * @return string $defaults['plural'] Plural label |
| 285 | 285 | */ |
| 286 | -function give_get_forms_label_plural( $lowercase = false ) { |
|
| 286 | +function give_get_forms_label_plural($lowercase = false) { |
|
| 287 | 287 | $defaults = give_get_default_form_labels(); |
| 288 | 288 | |
| 289 | - return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural']; |
|
| 289 | + return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural']; |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | /** |
@@ -298,24 +298,24 @@ discard block |
||
| 298 | 298 | * |
| 299 | 299 | * @return string $title New placeholder text |
| 300 | 300 | */ |
| 301 | -function give_change_default_title( $title ) { |
|
| 301 | +function give_change_default_title($title) { |
|
| 302 | 302 | // If a frontend plugin uses this filter (check extensions before changing this function) |
| 303 | - if ( ! is_admin() ) { |
|
| 304 | - $title = __( 'Enter form title here', 'give' ); |
|
| 303 | + if ( ! is_admin()) { |
|
| 304 | + $title = __('Enter form title here', 'give'); |
|
| 305 | 305 | |
| 306 | 306 | return $title; |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | $screen = get_current_screen(); |
| 310 | 310 | |
| 311 | - if ( 'give_forms' == $screen->post_type ) { |
|
| 312 | - $title = __( 'Enter form title here', 'give' ); |
|
| 311 | + if ('give_forms' == $screen->post_type) { |
|
| 312 | + $title = __('Enter form title here', 'give'); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | return $title; |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | -add_filter( 'enter_title_here', 'give_change_default_title' ); |
|
| 318 | +add_filter('enter_title_here', 'give_change_default_title'); |
|
| 319 | 319 | |
| 320 | 320 | /** |
| 321 | 321 | * Registers Custom Post Statuses which are used by the Payments |
@@ -325,67 +325,67 @@ discard block |
||
| 325 | 325 | */ |
| 326 | 326 | function give_register_post_type_statuses() { |
| 327 | 327 | // Payment Statuses |
| 328 | - register_post_status( 'refunded', array( |
|
| 329 | - 'label' => __( 'Refunded', 'give' ), |
|
| 328 | + register_post_status('refunded', array( |
|
| 329 | + 'label' => __('Refunded', 'give'), |
|
| 330 | 330 | 'public' => true, |
| 331 | 331 | 'exclude_from_search' => false, |
| 332 | 332 | 'show_in_admin_all_list' => true, |
| 333 | 333 | 'show_in_admin_status_list' => true, |
| 334 | - 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give' ), |
|
| 335 | - ) ); |
|
| 336 | - register_post_status( 'failed', array( |
|
| 337 | - 'label' => __( 'Failed', 'give' ), |
|
| 334 | + 'label_count' => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give'), |
|
| 335 | + )); |
|
| 336 | + register_post_status('failed', array( |
|
| 337 | + 'label' => __('Failed', 'give'), |
|
| 338 | 338 | 'public' => true, |
| 339 | 339 | 'exclude_from_search' => false, |
| 340 | 340 | 'show_in_admin_all_list' => true, |
| 341 | 341 | 'show_in_admin_status_list' => true, |
| 342 | - 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give' ), |
|
| 343 | - ) ); |
|
| 344 | - register_post_status( 'revoked', array( |
|
| 345 | - 'label' => __( 'Revoked', 'give' ), |
|
| 342 | + 'label_count' => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give'), |
|
| 343 | + )); |
|
| 344 | + register_post_status('revoked', array( |
|
| 345 | + 'label' => __('Revoked', 'give'), |
|
| 346 | 346 | 'public' => true, |
| 347 | 347 | 'exclude_from_search' => false, |
| 348 | 348 | 'show_in_admin_all_list' => true, |
| 349 | 349 | 'show_in_admin_status_list' => true, |
| 350 | - 'label_count' => _n_noop( 'Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give' ), |
|
| 351 | - ) ); |
|
| 352 | - register_post_status( 'cancelled', array( |
|
| 353 | - 'label' => __( 'Cancelled', 'give' ), |
|
| 350 | + 'label_count' => _n_noop('Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give'), |
|
| 351 | + )); |
|
| 352 | + register_post_status('cancelled', array( |
|
| 353 | + 'label' => __('Cancelled', 'give'), |
|
| 354 | 354 | 'public' => true, |
| 355 | 355 | 'exclude_from_search' => false, |
| 356 | 356 | 'show_in_admin_all_list' => true, |
| 357 | 357 | 'show_in_admin_status_list' => true, |
| 358 | - 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give' ), |
|
| 359 | - ) ); |
|
| 360 | - register_post_status( 'abandoned', array( |
|
| 361 | - 'label' => __( 'Abandoned', 'give' ), |
|
| 358 | + 'label_count' => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give'), |
|
| 359 | + )); |
|
| 360 | + register_post_status('abandoned', array( |
|
| 361 | + 'label' => __('Abandoned', 'give'), |
|
| 362 | 362 | 'public' => true, |
| 363 | 363 | 'exclude_from_search' => false, |
| 364 | 364 | 'show_in_admin_all_list' => true, |
| 365 | 365 | 'show_in_admin_status_list' => true, |
| 366 | - 'label_count' => _n_noop( 'Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give' ), |
|
| 367 | - ) ); |
|
| 368 | - register_post_status( 'processing', array( |
|
| 369 | - 'label' => _x( 'Processing', 'Processing payment status', 'give' ), |
|
| 366 | + 'label_count' => _n_noop('Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give'), |
|
| 367 | + )); |
|
| 368 | + register_post_status('processing', array( |
|
| 369 | + 'label' => _x('Processing', 'Processing payment status', 'give'), |
|
| 370 | 370 | 'public' => true, |
| 371 | 371 | 'exclude_from_search' => false, |
| 372 | 372 | 'show_in_admin_all_list' => true, |
| 373 | 373 | 'show_in_admin_status_list' => true, |
| 374 | - 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'give' ) |
|
| 375 | - ) ); |
|
| 374 | + 'label_count' => _n_noop('Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'give') |
|
| 375 | + )); |
|
| 376 | 376 | |
| 377 | - register_post_status( 'preapproval', array( |
|
| 378 | - 'label' => _x( 'Preapproval', 'Preapproval payment status', 'give' ), |
|
| 377 | + register_post_status('preapproval', array( |
|
| 378 | + 'label' => _x('Preapproval', 'Preapproval payment status', 'give'), |
|
| 379 | 379 | 'public' => true, |
| 380 | 380 | 'exclude_from_search' => false, |
| 381 | 381 | 'show_in_admin_all_list' => true, |
| 382 | 382 | 'show_in_admin_status_list' => true, |
| 383 | - 'label_count' => _n_noop( 'Preapproval <span class="count">(%s)</span>', 'Preapproval <span class="count">(%s)</span>', 'give' ), |
|
| 384 | - ) ); |
|
| 383 | + 'label_count' => _n_noop('Preapproval <span class="count">(%s)</span>', 'Preapproval <span class="count">(%s)</span>', 'give'), |
|
| 384 | + )); |
|
| 385 | 385 | |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | -add_action( 'init', 'give_register_post_type_statuses' ); |
|
| 388 | +add_action('init', 'give_register_post_type_statuses'); |
|
| 389 | 389 | |
| 390 | 390 | /** |
| 391 | 391 | * Updated Messages |
@@ -398,27 +398,27 @@ discard block |
||
| 398 | 398 | * |
| 399 | 399 | * @return array $messages New post updated messages |
| 400 | 400 | */ |
| 401 | -function give_updated_messages( $messages ) { |
|
| 401 | +function give_updated_messages($messages) { |
|
| 402 | 402 | global $post, $post_ID; |
| 403 | 403 | |
| 404 | - if ( ! give_is_setting_enabled( give_get_option( 'forms_singular' ) ) ) { |
|
| 404 | + if ( ! give_is_setting_enabled(give_get_option('forms_singular'))) { |
|
| 405 | 405 | |
| 406 | 406 | $messages['give_forms'] = array( |
| 407 | - 1 => __( 'Form updated.', 'give' ), |
|
| 408 | - 4 => __( 'Form updated.', 'give' ), |
|
| 409 | - 6 => __( 'Form published.', 'give' ), |
|
| 410 | - 7 => __( 'Form saved.', 'give' ), |
|
| 411 | - 8 => __( 'Form submitted.', 'give' ), |
|
| 407 | + 1 => __('Form updated.', 'give'), |
|
| 408 | + 4 => __('Form updated.', 'give'), |
|
| 409 | + 6 => __('Form published.', 'give'), |
|
| 410 | + 7 => __('Form saved.', 'give'), |
|
| 411 | + 8 => __('Form submitted.', 'give'), |
|
| 412 | 412 | ); |
| 413 | 413 | |
| 414 | 414 | } else { |
| 415 | 415 | |
| 416 | 416 | $messages['give_forms'] = array( |
| 417 | - 1 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form updated.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ), |
|
| 418 | - 4 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form updated.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ), |
|
| 419 | - 6 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form published.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ), |
|
| 420 | - 7 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form saved.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ), |
|
| 421 | - 8 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form submitted.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ), |
|
| 417 | + 1 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form updated.', 'give'), get_permalink($post_ID), __('View Form', 'give')), |
|
| 418 | + 4 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form updated.', 'give'), get_permalink($post_ID), __('View Form', 'give')), |
|
| 419 | + 6 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form published.', 'give'), get_permalink($post_ID), __('View Form', 'give')), |
|
| 420 | + 7 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form saved.', 'give'), get_permalink($post_ID), __('View Form', 'give')), |
|
| 421 | + 8 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form submitted.', 'give'), get_permalink($post_ID), __('View Form', 'give')), |
|
| 422 | 422 | ); |
| 423 | 423 | |
| 424 | 424 | } |
@@ -426,24 +426,24 @@ discard block |
||
| 426 | 426 | return $messages; |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | -add_filter( 'post_updated_messages', 'give_updated_messages' ); |
|
| 429 | +add_filter('post_updated_messages', 'give_updated_messages'); |
|
| 430 | 430 | |
| 431 | 431 | /** |
| 432 | 432 | * Ensure post thumbnail support is turned on |
| 433 | 433 | */ |
| 434 | 434 | function give_add_thumbnail_support() { |
| 435 | - if ( ! give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) { |
|
| 435 | + if ( ! give_is_setting_enabled(give_get_option('form_featured_img'))) { |
|
| 436 | 436 | return; |
| 437 | 437 | } |
| 438 | 438 | |
| 439 | - if ( ! current_theme_supports( 'post-thumbnails' ) ) { |
|
| 440 | - add_theme_support( 'post-thumbnails' ); |
|
| 439 | + if ( ! current_theme_supports('post-thumbnails')) { |
|
| 440 | + add_theme_support('post-thumbnails'); |
|
| 441 | 441 | } |
| 442 | 442 | |
| 443 | - add_post_type_support( 'give_forms', 'thumbnail' ); |
|
| 443 | + add_post_type_support('give_forms', 'thumbnail'); |
|
| 444 | 444 | } |
| 445 | 445 | |
| 446 | -add_action( 'after_setup_theme', 'give_add_thumbnail_support', 10 ); |
|
| 446 | +add_action('after_setup_theme', 'give_add_thumbnail_support', 10); |
|
| 447 | 447 | |
| 448 | 448 | /** |
| 449 | 449 | * Give Sidebars |
@@ -454,21 +454,21 @@ discard block |
||
| 454 | 454 | |
| 455 | 455 | // Single Give Forms (disabled if single turned off in settings) |
| 456 | 456 | if ( |
| 457 | - give_is_setting_enabled( give_get_option( 'forms_singular' ) ) |
|
| 458 | - && give_is_setting_enabled( give_get_option( 'form_sidebar' ) ) |
|
| 457 | + give_is_setting_enabled(give_get_option('forms_singular')) |
|
| 458 | + && give_is_setting_enabled(give_get_option('form_sidebar')) |
|
| 459 | 459 | ) { |
| 460 | 460 | |
| 461 | - register_sidebar( apply_filters( 'give_forms_single_sidebar', array( |
|
| 462 | - 'name' => __( 'Give Single Form Sidebar', 'give' ), |
|
| 461 | + register_sidebar(apply_filters('give_forms_single_sidebar', array( |
|
| 462 | + 'name' => __('Give Single Form Sidebar', 'give'), |
|
| 463 | 463 | 'id' => 'give-forms-sidebar', |
| 464 | - 'description' => __( 'Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give' ), |
|
| 464 | + 'description' => __('Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give'), |
|
| 465 | 465 | 'before_widget' => '<div id="%1$s" class="widget %2$s">', |
| 466 | 466 | 'after_widget' => '</div>', |
| 467 | 467 | 'before_title' => '<h3 class="widgettitle widget-title">', |
| 468 | 468 | 'after_title' => '</h3>', |
| 469 | - ) ) ); |
|
| 469 | + ))); |
|
| 470 | 470 | |
| 471 | 471 | } |
| 472 | 472 | } |
| 473 | 473 | |
| 474 | -add_action( 'widgets_init', 'give_widgets_init', 999 ); |
|
| 474 | +add_action('widgets_init', 'give_widgets_init', 999); |
|
@@ -7,12 +7,12 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // Exit if accessed directly. |
| 10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 10 | +if ( ! defined('ABSPATH')) { |
|
| 11 | 11 | exit; |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | // Add give command. |
| 15 | -WP_CLI::add_command( 'give', 'GIVE_CLI_COMMAND' ); |
|
| 15 | +WP_CLI::add_command('give', 'GIVE_CLI_COMMAND'); |
|
| 16 | 16 | |
| 17 | 17 | |
| 18 | 18 | /** |
@@ -76,8 +76,8 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | * @subcommand logo |
| 78 | 78 | */ |
| 79 | - public function ascii( $args, $assoc_args ) { |
|
| 80 | - WP_CLI::log( file_get_contents( GIVE_PLUGIN_DIR . 'assets/images/give-ascii-logo.txt' ) ); |
|
| 79 | + public function ascii($args, $assoc_args) { |
|
| 80 | + WP_CLI::log(file_get_contents(GIVE_PLUGIN_DIR.'assets/images/give-ascii-logo.txt')); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | |
@@ -102,54 +102,54 @@ discard block |
||
| 102 | 102 | * |
| 103 | 103 | * @subcommand details |
| 104 | 104 | */ |
| 105 | - public function details( $args, $assoc_args ) { |
|
| 105 | + public function details($args, $assoc_args) { |
|
| 106 | 106 | |
| 107 | 107 | /** |
| 108 | 108 | * Plugin Information |
| 109 | 109 | */ |
| 110 | - WP_CLI::log( $this->color_message( __( 'Give Version: ', 'give' ) ) . GIVE_VERSION ); |
|
| 110 | + WP_CLI::log($this->color_message(__('Give Version: ', 'give')).GIVE_VERSION); |
|
| 111 | 111 | |
| 112 | 112 | /** |
| 113 | 113 | * General Information. |
| 114 | 114 | */ |
| 115 | - WP_CLI::log( "\n#### " . $this->color_message( __( 'General information', 'give' ) ) . ' ####' ); |
|
| 115 | + WP_CLI::log("\n#### ".$this->color_message(__('General information', 'give')).' ####'); |
|
| 116 | 116 | |
| 117 | - $success_page = give_get_option( 'success_page' ); |
|
| 118 | - $failure_page = give_get_option( 'failure_page' ); |
|
| 119 | - $history_page = give_get_option( 'history_page' ); |
|
| 117 | + $success_page = give_get_option('success_page'); |
|
| 118 | + $failure_page = give_get_option('failure_page'); |
|
| 119 | + $history_page = give_get_option('history_page'); |
|
| 120 | 120 | |
| 121 | - WP_CLI::log( $this->color_message( sprintf( __( 'Success Page: ', 'give' ) ) ) . ( $success_page ? "[{$success_page}] " . get_permalink( $success_page ) : __( 'Not Set', 'give' ) ) ); |
|
| 122 | - WP_CLI::log( $this->color_message( __( 'Failed Donation Page: ', 'give' ) ) . ( $failure_page ? "[{$failure_page}] " . get_permalink( $failure_page ) : __( 'Not Set', 'give' ) ) ); |
|
| 123 | - WP_CLI::log( $this->color_message( __( 'Donation History Page: ', 'give' ) ) . ( $history_page ? "[{$history_page}] " . get_permalink( $history_page ) : __( 'Not Set', 'give' ) ) ); |
|
| 124 | - WP_CLI::log( $this->color_message( __( 'Country: ', 'give' ) ) . give_get_country() ); |
|
| 121 | + WP_CLI::log($this->color_message(sprintf(__('Success Page: ', 'give'))).($success_page ? "[{$success_page}] ".get_permalink($success_page) : __('Not Set', 'give'))); |
|
| 122 | + WP_CLI::log($this->color_message(__('Failed Donation Page: ', 'give')).($failure_page ? "[{$failure_page}] ".get_permalink($failure_page) : __('Not Set', 'give'))); |
|
| 123 | + WP_CLI::log($this->color_message(__('Donation History Page: ', 'give')).($history_page ? "[{$history_page}] ".get_permalink($history_page) : __('Not Set', 'give'))); |
|
| 124 | + WP_CLI::log($this->color_message(__('Country: ', 'give')).give_get_country()); |
|
| 125 | 125 | |
| 126 | 126 | /** |
| 127 | 127 | * Currency Information. |
| 128 | 128 | */ |
| 129 | - $default_gateway = give_get_option( 'default_gateway' ); |
|
| 129 | + $default_gateway = give_get_option('default_gateway'); |
|
| 130 | 130 | |
| 131 | - WP_CLI::log( "\n#### " . $this->color_message( __( 'Currency Information', 'give' ) ) . ' ####' ); |
|
| 131 | + WP_CLI::log("\n#### ".$this->color_message(__('Currency Information', 'give')).' ####'); |
|
| 132 | 132 | |
| 133 | - WP_CLI::log( $this->color_message( __( 'Currency: ', 'give' ), give_get_currency() ) ); |
|
| 134 | - WP_CLI::log( $this->color_message( __( 'Currency Position: ', 'give' ), give_get_currency_position() ) ); |
|
| 135 | - WP_CLI::log( $this->color_message( __( 'Thousand Separator: ', 'give' ), give_get_price_thousand_separator() ) ); |
|
| 136 | - WP_CLI::log( $this->color_message( __( 'Decimal Separator: ', 'give' ), give_get_price_decimal_separator() ) ); |
|
| 137 | - WP_CLI::log( $this->color_message( __( 'Number of Decimals: ', 'give' ), give_get_price_decimals() ) ); |
|
| 138 | - WP_CLI::log( $this->color_message( __( 'Test Mode: ', 'give' ), ( give_get_option( 'test_mode' ) ? __( 'Yes', 'give' ) : __( 'No', 'give' ) ) ) ); |
|
| 139 | - WP_CLI::log( $this->color_message( __( 'Default Gateway: ', 'give' ), ( $default_gateway ? $default_gateway : __( 'Not Set', 'give' ) ) ) ); |
|
| 133 | + WP_CLI::log($this->color_message(__('Currency: ', 'give'), give_get_currency())); |
|
| 134 | + WP_CLI::log($this->color_message(__('Currency Position: ', 'give'), give_get_currency_position())); |
|
| 135 | + WP_CLI::log($this->color_message(__('Thousand Separator: ', 'give'), give_get_price_thousand_separator())); |
|
| 136 | + WP_CLI::log($this->color_message(__('Decimal Separator: ', 'give'), give_get_price_decimal_separator())); |
|
| 137 | + WP_CLI::log($this->color_message(__('Number of Decimals: ', 'give'), give_get_price_decimals())); |
|
| 138 | + WP_CLI::log($this->color_message(__('Test Mode: ', 'give'), (give_get_option('test_mode') ? __('Yes', 'give') : __('No', 'give')))); |
|
| 139 | + WP_CLI::log($this->color_message(__('Default Gateway: ', 'give'), ($default_gateway ? $default_gateway : __('Not Set', 'give')))); |
|
| 140 | 140 | |
| 141 | 141 | // Payment gateways Information. |
| 142 | - $gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() ); |
|
| 143 | - WP_CLI::log( $this->color_message( __( 'Enabled Gateways: ', 'give' ) ) ); |
|
| 142 | + $gateways = give_get_ordered_payment_gateways(give_get_payment_gateways()); |
|
| 143 | + WP_CLI::log($this->color_message(__('Enabled Gateways: ', 'give'))); |
|
| 144 | 144 | |
| 145 | - if ( ! empty( $gateways ) ) { |
|
| 145 | + if ( ! empty($gateways)) { |
|
| 146 | 146 | self::$counter = 1; |
| 147 | - foreach ( $gateways as $gateway ) { |
|
| 148 | - WP_CLI::log( ' ' . $this->color_message( self::$counter, $gateway['admin_label'] ) ); |
|
| 149 | - self::$counter ++; |
|
| 147 | + foreach ($gateways as $gateway) { |
|
| 148 | + WP_CLI::log(' '.$this->color_message(self::$counter, $gateway['admin_label'])); |
|
| 149 | + self::$counter++; |
|
| 150 | 150 | } |
| 151 | 151 | } else { |
| 152 | - WP_CLI::log( __( 'Not any payment gateways found', 'give' ) ); |
|
| 152 | + WP_CLI::log(__('Not any payment gateways found', 'give')); |
|
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | |
@@ -181,15 +181,15 @@ discard block |
||
| 181 | 181 | * |
| 182 | 182 | * @subcommand forms |
| 183 | 183 | */ |
| 184 | - public function forms( $args, $assoc_args ) { |
|
| 184 | + public function forms($args, $assoc_args) { |
|
| 185 | 185 | global $wp_query; |
| 186 | - $form_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false; |
|
| 187 | - $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? absint( $assoc_args['number'] ) : 10; |
|
| 186 | + $form_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false; |
|
| 187 | + $number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? absint($assoc_args['number']) : 10; |
|
| 188 | 188 | $start = time(); |
| 189 | 189 | |
| 190 | 190 | // Cache previous number query var. |
| 191 | 191 | $is_set_number = $cache_per_page = false; |
| 192 | - if ( isset( $wp_query->query_vars['number'] ) ) { |
|
| 192 | + if (isset($wp_query->query_vars['number'])) { |
|
| 193 | 193 | $cache_per_page = $wp_query->query_vars['number']; |
| 194 | 194 | $is_set_number = true; |
| 195 | 195 | } |
@@ -198,22 +198,22 @@ discard block |
||
| 198 | 198 | $wp_query->query_vars['number'] = $number; |
| 199 | 199 | |
| 200 | 200 | // Get forms. |
| 201 | - $forms = $form_id ? $this->api->get_forms( $form_id ) : $this->api->get_forms(); |
|
| 201 | + $forms = $form_id ? $this->api->get_forms($form_id) : $this->api->get_forms(); |
|
| 202 | 202 | |
| 203 | 203 | // Reset number query var. |
| 204 | - if ( $is_set_number ) { |
|
| 204 | + if ($is_set_number) { |
|
| 205 | 205 | $wp_query->query_vars['number'] = $cache_per_page; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | // Bailout. |
| 209 | - if ( array_key_exists( 'error', $forms ) ) { |
|
| 209 | + if (array_key_exists('error', $forms)) { |
|
| 210 | 210 | |
| 211 | - WP_CLI::warning( $forms['error'] ); |
|
| 211 | + WP_CLI::warning($forms['error']); |
|
| 212 | 212 | |
| 213 | 213 | return; |
| 214 | - } elseif ( empty( $forms['forms'] ) ) { |
|
| 214 | + } elseif (empty($forms['forms'])) { |
|
| 215 | 215 | |
| 216 | - WP_CLI::error( __( 'No forms found.', 'give' ) ); |
|
| 216 | + WP_CLI::error(__('No forms found.', 'give')); |
|
| 217 | 217 | |
| 218 | 218 | return; |
| 219 | 219 | } |
@@ -221,25 +221,25 @@ discard block |
||
| 221 | 221 | // Param to check if form typeis already showed or not. |
| 222 | 222 | $is_show_form_type = false; |
| 223 | 223 | |
| 224 | - if ( 1 === count( $forms ) && $form_id ) { |
|
| 224 | + if (1 === count($forms) && $form_id) { |
|
| 225 | 225 | // Show single form. |
| 226 | - foreach ( $forms['forms'][0] as $key => $info ) { |
|
| 227 | - switch ( $key ) { |
|
| 226 | + foreach ($forms['forms'][0] as $key => $info) { |
|
| 227 | + switch ($key) { |
|
| 228 | 228 | case 'stats': |
| 229 | - $this->color_main_heading( ucfirst( $key ) ); |
|
| 229 | + $this->color_main_heading(ucfirst($key)); |
|
| 230 | 230 | |
| 231 | - foreach ( $info as $heading => $data ) { |
|
| 232 | - $this->color_sub_heading( ucfirst( $heading ) ); |
|
| 233 | - switch ( $heading ) { |
|
| 231 | + foreach ($info as $heading => $data) { |
|
| 232 | + $this->color_sub_heading(ucfirst($heading)); |
|
| 233 | + switch ($heading) { |
|
| 234 | 234 | default: |
| 235 | - foreach ( $data as $subheading => $subdata ) { |
|
| 235 | + foreach ($data as $subheading => $subdata) { |
|
| 236 | 236 | |
| 237 | - switch ( $subheading ) { |
|
| 237 | + switch ($subheading) { |
|
| 238 | 238 | case 'earnings': |
| 239 | - WP_CLI::log( $this->color_message( $subheading . ': ', give_currency_filter( $subdata ) ) ); |
|
| 239 | + WP_CLI::log($this->color_message($subheading.': ', give_currency_filter($subdata))); |
|
| 240 | 240 | break; |
| 241 | 241 | default: |
| 242 | - WP_CLI::log( $this->color_message( $subheading . ': ', $subdata ) ); |
|
| 242 | + WP_CLI::log($this->color_message($subheading.': ', $subdata)); |
|
| 243 | 243 | } |
| 244 | 244 | } |
| 245 | 245 | } |
@@ -249,26 +249,26 @@ discard block |
||
| 249 | 249 | case 'pricing': |
| 250 | 250 | case 'info': |
| 251 | 251 | default: |
| 252 | - $this->color_main_heading( ucfirst( $key ) ); |
|
| 252 | + $this->color_main_heading(ucfirst($key)); |
|
| 253 | 253 | |
| 254 | 254 | // Show form type. |
| 255 | - if ( ! $is_show_form_type ) { |
|
| 256 | - $form = new Give_Donate_Form( $form_id ); |
|
| 255 | + if ( ! $is_show_form_type) { |
|
| 256 | + $form = new Give_Donate_Form($form_id); |
|
| 257 | 257 | $is_show_form_type = true; |
| 258 | 258 | |
| 259 | - WP_CLI::log( $this->color_message( __( 'form type', 'give' ), $form->get_type() ) ); |
|
| 259 | + WP_CLI::log($this->color_message(__('form type', 'give'), $form->get_type())); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - foreach ( $info as $heading => $data ) { |
|
| 262 | + foreach ($info as $heading => $data) { |
|
| 263 | 263 | |
| 264 | - switch ( $heading ) { |
|
| 264 | + switch ($heading) { |
|
| 265 | 265 | case 'id': |
| 266 | - WP_CLI::log( $this->color_message( $heading, $data ) ); |
|
| 266 | + WP_CLI::log($this->color_message($heading, $data)); |
|
| 267 | 267 | break; |
| 268 | 268 | |
| 269 | 269 | default: |
| 270 | - $data = empty( $data ) ? __( 'Not set', 'give' ) : $data; |
|
| 271 | - WP_CLI::log( $this->color_message( $heading, $data ) ); |
|
| 270 | + $data = empty($data) ? __('Not set', 'give') : $data; |
|
| 271 | + WP_CLI::log($this->color_message($heading, $data)); |
|
| 272 | 272 | } |
| 273 | 273 | } |
| 274 | 274 | }// End switch(). |
@@ -279,37 +279,37 @@ discard block |
||
| 279 | 279 | $is_table_first_row_set = false; |
| 280 | 280 | $table_column_count = 0; |
| 281 | 281 | |
| 282 | - WP_CLI::line( $this->color_message( sprintf( __( '%d donation forms found', 'give' ), count( $forms['forms'] ) ), '', false ) ); |
|
| 282 | + WP_CLI::line($this->color_message(sprintf(__('%d donation forms found', 'give'), count($forms['forms'])), '', false)); |
|
| 283 | 283 | |
| 284 | - foreach ( $forms['forms'] as $index => $form_data ) { |
|
| 284 | + foreach ($forms['forms'] as $index => $form_data) { |
|
| 285 | 285 | |
| 286 | 286 | // Default table data. |
| 287 | 287 | $table_first_row = array(); |
| 288 | 288 | $table_row = array(); |
| 289 | 289 | |
| 290 | - foreach ( $form_data['info'] as $key => $form ) { |
|
| 290 | + foreach ($form_data['info'] as $key => $form) { |
|
| 291 | 291 | |
| 292 | 292 | // Do not show thumbnail, content and link in table. |
| 293 | - if ( in_array( $key, array( 'content', 'thumbnail', 'link' ), true ) ) { |
|
| 293 | + if (in_array($key, array('content', 'thumbnail', 'link'), true)) { |
|
| 294 | 294 | continue; |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | - if ( ! $is_table_first_row_set ) { |
|
| 297 | + if ( ! $is_table_first_row_set) { |
|
| 298 | 298 | $table_first_row[] = $key; |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | $table_row[] = $form; |
| 302 | 302 | |
| 303 | - if ( 'status' === $key ) { |
|
| 303 | + if ('status' === $key) { |
|
| 304 | 304 | // First array item will be an form id in our case. |
| 305 | - $form = new Give_Donate_Form( absint( $table_row[0] ) ); |
|
| 305 | + $form = new Give_Donate_Form(absint($table_row[0])); |
|
| 306 | 306 | |
| 307 | 307 | $table_row[] = $form->get_type(); |
| 308 | 308 | } |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | // Set table first row. |
| 312 | - if ( ! $is_table_first_row_set ) { |
|
| 312 | + if ( ! $is_table_first_row_set) { |
|
| 313 | 313 | |
| 314 | 314 | // Add extra column to table. |
| 315 | 315 | $table_first_row[] = 'type'; |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | $table_data[] = $table_row; |
| 323 | 323 | }// End foreach(). |
| 324 | 324 | |
| 325 | - $this->display_table( $table_data ); |
|
| 325 | + $this->display_table($table_data); |
|
| 326 | 326 | }// End if(). |
| 327 | 327 | } |
| 328 | 328 | |
@@ -375,59 +375,59 @@ discard block |
||
| 375 | 375 | * |
| 376 | 376 | * @subcommand donors |
| 377 | 377 | */ |
| 378 | - public function donors( $args, $assoc_args ) { |
|
| 378 | + public function donors($args, $assoc_args) { |
|
| 379 | 379 | global $wp_query; |
| 380 | - $donor_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false; |
|
| 381 | - $email = isset( $assoc_args ) && array_key_exists( 'email', $assoc_args ) ? $assoc_args['email'] : false; |
|
| 382 | - $name = isset( $assoc_args ) && array_key_exists( 'name', $assoc_args ) ? $assoc_args['name'] : ''; |
|
| 383 | - $create = isset( $assoc_args ) && array_key_exists( 'create', $assoc_args ) ? $assoc_args['create'] : false; |
|
| 384 | - $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10; |
|
| 385 | - $form_id = isset( $assoc_args ) && array_key_exists( 'form-id', $assoc_args ) ? $assoc_args['form-id'] : 0; |
|
| 386 | - $format = isset( $assoc_args ) && array_key_exists( 'format', $assoc_args ) ? $assoc_args['format'] : 'table'; |
|
| 380 | + $donor_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false; |
|
| 381 | + $email = isset($assoc_args) && array_key_exists('email', $assoc_args) ? $assoc_args['email'] : false; |
|
| 382 | + $name = isset($assoc_args) && array_key_exists('name', $assoc_args) ? $assoc_args['name'] : ''; |
|
| 383 | + $create = isset($assoc_args) && array_key_exists('create', $assoc_args) ? $assoc_args['create'] : false; |
|
| 384 | + $number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10; |
|
| 385 | + $form_id = isset($assoc_args) && array_key_exists('form-id', $assoc_args) ? $assoc_args['form-id'] : 0; |
|
| 386 | + $format = isset($assoc_args) && array_key_exists('format', $assoc_args) ? $assoc_args['format'] : 'table'; |
|
| 387 | 387 | $start = time(); |
| 388 | 388 | |
| 389 | - if ( $create ) { |
|
| 390 | - if ( 80 < $create ) { |
|
| 391 | - WP_CLI::warning( 'Currently we can only generate maximum 80 donors.', 'give' ); |
|
| 389 | + if ($create) { |
|
| 390 | + if (80 < $create) { |
|
| 391 | + WP_CLI::warning('Currently we can only generate maximum 80 donors.', 'give'); |
|
| 392 | 392 | $create = 80; |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | $number = 1; |
| 396 | 396 | |
| 397 | - if ( isset( $assoc_args['email'] ) && ! is_email( $email ) ) { |
|
| 398 | - WP_CLI::warning( 'Wrong email address provided.', 'give' ); |
|
| 397 | + if (isset($assoc_args['email']) && ! is_email($email)) { |
|
| 398 | + WP_CLI::warning('Wrong email address provided.', 'give'); |
|
| 399 | 399 | |
| 400 | 400 | return; |
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | // Create one or more donors. |
| 404 | - if ( ! $email ) { |
|
| 404 | + if ( ! $email) { |
|
| 405 | 405 | // If no email is specified, look to see if we are generating arbitrary donor accounts. |
| 406 | - $number = is_numeric( $create ) ? absint( $create ) : 1; |
|
| 406 | + $number = is_numeric($create) ? absint($create) : 1; |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - for ( $i = 0; $i < $number; $i ++ ) { |
|
| 409 | + for ($i = 0; $i < $number; $i++) { |
|
| 410 | 410 | $name = $name ? $name : $this->get_random_name(); |
| 411 | - $email = $email ? $email : $this->get_random_email( $name ); |
|
| 411 | + $email = $email ? $email : $this->get_random_email($name); |
|
| 412 | 412 | |
| 413 | 413 | $args = array( |
| 414 | 414 | 'email' => $email, |
| 415 | 415 | 'name' => $name, |
| 416 | 416 | ); |
| 417 | 417 | |
| 418 | - $donor_id = Give()->donors->add( $args ); |
|
| 418 | + $donor_id = Give()->donors->add($args); |
|
| 419 | 419 | |
| 420 | - if ( $donor_id ) { |
|
| 421 | - WP_CLI::line( $this->color_message( sprintf( __( 'Donor #%d created successfully', 'give' ), $donor_id ) ) ); |
|
| 420 | + if ($donor_id) { |
|
| 421 | + WP_CLI::line($this->color_message(sprintf(__('Donor #%d created successfully', 'give'), $donor_id))); |
|
| 422 | 422 | } else { |
| 423 | - WP_CLI::error( __( 'Failed to create donor', 'give' ) ); |
|
| 423 | + WP_CLI::error(__('Failed to create donor', 'give')); |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | // Reset email and name to false so it is generated on the next loop (if creating donors). |
| 427 | 427 | $email = $name = false; |
| 428 | 428 | } |
| 429 | 429 | |
| 430 | - WP_CLI::line( $this->color_message( sprintf( __( '%1$d donors created in %2$d seconds', 'give' ), $number, time() - $start ) ) ); |
|
| 430 | + WP_CLI::line($this->color_message(sprintf(__('%1$d donors created in %2$d seconds', 'give'), $number, time() - $start))); |
|
| 431 | 431 | |
| 432 | 432 | } else { |
| 433 | 433 | // Counter. |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | */ |
| 442 | 442 | // Cache previous number query var. |
| 443 | 443 | $is_set_number = $cache_per_page = false; |
| 444 | - if ( isset( $wp_query->query_vars['number'] ) ) { |
|
| 444 | + if (isset($wp_query->query_vars['number'])) { |
|
| 445 | 445 | $cache_per_page = $wp_query->query_vars['number']; |
| 446 | 446 | $is_set_number = true; |
| 447 | 447 | } |
@@ -450,24 +450,24 @@ discard block |
||
| 450 | 450 | $wp_query->query_vars['number'] = $number; |
| 451 | 451 | |
| 452 | 452 | // Get donors. |
| 453 | - if ( $form_id ) { |
|
| 453 | + if ($form_id) { |
|
| 454 | 454 | // @TODO: Allow user to get a list of donors by donation status. |
| 455 | - $donors = $this->get_donors_by_form_id( $form_id ); |
|
| 455 | + $donors = $this->get_donors_by_form_id($form_id); |
|
| 456 | 456 | } else { |
| 457 | - $donors = $this->api->get_donors( $search ); |
|
| 457 | + $donors = $this->api->get_donors($search); |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | // Reset number query var. |
| 461 | - if ( $is_set_number ) { |
|
| 461 | + if ($is_set_number) { |
|
| 462 | 462 | $wp_query->query_vars['number'] = $cache_per_page; |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | - if ( isset( $donors['error'] ) ) { |
|
| 466 | - WP_CLI::error( $donors['error'] ); |
|
| 465 | + if (isset($donors['error'])) { |
|
| 466 | + WP_CLI::error($donors['error']); |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | - if ( empty( $donors ) ) { |
|
| 470 | - WP_CLI::error( __( 'No donors found.', 'give' ) ); |
|
| 469 | + if (empty($donors)) { |
|
| 470 | + WP_CLI::error(__('No donors found.', 'give')); |
|
| 471 | 471 | |
| 472 | 472 | return; |
| 473 | 473 | } |
@@ -475,24 +475,24 @@ discard block |
||
| 475 | 475 | $table_data = array(); |
| 476 | 476 | $is_table_first_row_set = false; |
| 477 | 477 | |
| 478 | - foreach ( $donors['donors'] as $donor_data ) { |
|
| 478 | + foreach ($donors['donors'] as $donor_data) { |
|
| 479 | 479 | // Set default table row data. |
| 480 | - $table_first_row = array( __( 's_no', 'give' ) ); |
|
| 481 | - $table_row = array( self::$counter ); |
|
| 480 | + $table_first_row = array(__('s_no', 'give')); |
|
| 481 | + $table_row = array(self::$counter); |
|
| 482 | 482 | |
| 483 | - foreach ( $donor_data as $key => $donor ) { |
|
| 484 | - switch ( $key ) { |
|
| 483 | + foreach ($donor_data as $key => $donor) { |
|
| 484 | + switch ($key) { |
|
| 485 | 485 | case 'stats': |
| 486 | - foreach ( $donor as $heading => $data ) { |
|
| 486 | + foreach ($donor as $heading => $data) { |
|
| 487 | 487 | |
| 488 | 488 | // Get first row. |
| 489 | - if ( ! $is_table_first_row_set ) { |
|
| 489 | + if ( ! $is_table_first_row_set) { |
|
| 490 | 490 | $table_first_row[] = $heading; |
| 491 | 491 | } |
| 492 | 492 | |
| 493 | - switch ( $heading ) { |
|
| 493 | + switch ($heading) { |
|
| 494 | 494 | case 'total_spent': |
| 495 | - $table_row[] = give_currency_filter( $data ); |
|
| 495 | + $table_row[] = give_currency_filter($data); |
|
| 496 | 496 | break; |
| 497 | 497 | |
| 498 | 498 | default: |
@@ -503,10 +503,10 @@ discard block |
||
| 503 | 503 | |
| 504 | 504 | case 'info': |
| 505 | 505 | default: |
| 506 | - foreach ( $donor as $heading => $data ) { |
|
| 506 | + foreach ($donor as $heading => $data) { |
|
| 507 | 507 | |
| 508 | 508 | // Get first row. |
| 509 | - if ( ! $is_table_first_row_set ) { |
|
| 509 | + if ( ! $is_table_first_row_set) { |
|
| 510 | 510 | $table_first_row[] = $heading; |
| 511 | 511 | } |
| 512 | 512 | |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | // Add first row data to table data. |
| 519 | - if ( ! $is_table_first_row_set ) { |
|
| 519 | + if ( ! $is_table_first_row_set) { |
|
| 520 | 520 | $table_data[] = $table_first_row; |
| 521 | 521 | $is_table_first_row_set = true; |
| 522 | 522 | } |
@@ -525,44 +525,44 @@ discard block |
||
| 525 | 525 | $table_data[] = $table_row; |
| 526 | 526 | |
| 527 | 527 | // Increase counter. |
| 528 | - self::$counter ++; |
|
| 528 | + self::$counter++; |
|
| 529 | 529 | }// End foreach(). |
| 530 | 530 | |
| 531 | - switch ( $format ) { |
|
| 531 | + switch ($format) { |
|
| 532 | 532 | case 'json': |
| 533 | 533 | $table_column_name = $table_data[0]; |
| 534 | - unset( $table_data[0] ); |
|
| 534 | + unset($table_data[0]); |
|
| 535 | 535 | |
| 536 | 536 | $new_table_data = array(); |
| 537 | - foreach ( $table_data as $index => $data ) { |
|
| 538 | - foreach ( $data as $key => $value ) { |
|
| 539 | - $new_table_data[ $index ][ $table_column_name[ $key ] ] = $value; |
|
| 537 | + foreach ($table_data as $index => $data) { |
|
| 538 | + foreach ($data as $key => $value) { |
|
| 539 | + $new_table_data[$index][$table_column_name[$key]] = $value; |
|
| 540 | 540 | } |
| 541 | 541 | } |
| 542 | 542 | |
| 543 | - WP_CLI::log( json_encode( $new_table_data ) ); |
|
| 543 | + WP_CLI::log(json_encode($new_table_data)); |
|
| 544 | 544 | break; |
| 545 | 545 | |
| 546 | 546 | case 'csv': |
| 547 | - $file_path = trailingslashit( WP_CONTENT_DIR ) . 'uploads/give_donors_' . date( 'Y_m_d_s', current_time( 'timestamp' ) ) . '.csv'; |
|
| 548 | - $fp = fopen( $file_path, 'w' ); |
|
| 547 | + $file_path = trailingslashit(WP_CONTENT_DIR).'uploads/give_donors_'.date('Y_m_d_s', current_time('timestamp')).'.csv'; |
|
| 548 | + $fp = fopen($file_path, 'w'); |
|
| 549 | 549 | |
| 550 | - if ( is_writable( $file_path ) ) { |
|
| 551 | - foreach ( $table_data as $fields ) { |
|
| 552 | - fputcsv( $fp, $fields ); |
|
| 550 | + if (is_writable($file_path)) { |
|
| 551 | + foreach ($table_data as $fields) { |
|
| 552 | + fputcsv($fp, $fields); |
|
| 553 | 553 | } |
| 554 | 554 | |
| 555 | - fclose( $fp ); |
|
| 555 | + fclose($fp); |
|
| 556 | 556 | |
| 557 | - WP_CLI::success( "Donors list csv created successfully: {$file_path}" ); |
|
| 557 | + WP_CLI::success("Donors list csv created successfully: {$file_path}"); |
|
| 558 | 558 | } else { |
| 559 | - WP_CLI::warning( "Unable to create donors list csv file: {$file_path} (May folder do not have write permission)" ); |
|
| 559 | + WP_CLI::warning("Unable to create donors list csv file: {$file_path} (May folder do not have write permission)"); |
|
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | break; |
| 563 | 563 | |
| 564 | 564 | default: |
| 565 | - $this->display_table( $table_data ); |
|
| 565 | + $this->display_table($table_data); |
|
| 566 | 566 | }// End switch(). |
| 567 | 567 | }// End if(). |
| 568 | 568 | } |
@@ -592,13 +592,13 @@ discard block |
||
| 592 | 592 | * |
| 593 | 593 | * @subcommand donations |
| 594 | 594 | */ |
| 595 | - public function donations( $args, $assoc_args ) { |
|
| 595 | + public function donations($args, $assoc_args) { |
|
| 596 | 596 | global $wp_query; |
| 597 | - $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10; |
|
| 597 | + $number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10; |
|
| 598 | 598 | |
| 599 | 599 | // Cache previous number query var. |
| 600 | 600 | $is_set_number = $cache_per_page = false; |
| 601 | - if ( isset( $wp_query->query_vars['number'] ) ) { |
|
| 601 | + if (isset($wp_query->query_vars['number'])) { |
|
| 602 | 602 | $cache_per_page = $wp_query->query_vars['number']; |
| 603 | 603 | $is_set_number = true; |
| 604 | 604 | } |
@@ -610,46 +610,46 @@ discard block |
||
| 610 | 610 | $donations = $this->api->get_recent_donations(); |
| 611 | 611 | |
| 612 | 612 | // Reset number query var. |
| 613 | - if ( $is_set_number ) { |
|
| 613 | + if ($is_set_number) { |
|
| 614 | 614 | $wp_query->query_vars['number'] = $cache_per_page; |
| 615 | 615 | } |
| 616 | 616 | |
| 617 | - if ( empty( $donations ) ) { |
|
| 618 | - WP_CLI::error( __( 'No donations found.', 'give' ) ); |
|
| 617 | + if (empty($donations)) { |
|
| 618 | + WP_CLI::error(__('No donations found.', 'give')); |
|
| 619 | 619 | |
| 620 | 620 | return; |
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | self::$counter = 1; |
| 624 | 624 | |
| 625 | - foreach ( $donations['donations'] as $key => $donation ) { |
|
| 626 | - $this->color_main_heading( sprintf( __( '%1$s. Donation #%2$s', 'give' ), self::$counter, $donation['ID'] ), 'Y' ); |
|
| 627 | - self::$counter ++; |
|
| 625 | + foreach ($donations['donations'] as $key => $donation) { |
|
| 626 | + $this->color_main_heading(sprintf(__('%1$s. Donation #%2$s', 'give'), self::$counter, $donation['ID']), 'Y'); |
|
| 627 | + self::$counter++; |
|
| 628 | 628 | |
| 629 | - foreach ( $donation as $column => $data ) { |
|
| 629 | + foreach ($donation as $column => $data) { |
|
| 630 | 630 | |
| 631 | - if ( is_array( $data ) ) { |
|
| 632 | - $this->color_sub_heading( $column ); |
|
| 633 | - foreach ( $data as $subcolumn => $subdata ) { |
|
| 631 | + if (is_array($data)) { |
|
| 632 | + $this->color_sub_heading($column); |
|
| 633 | + foreach ($data as $subcolumn => $subdata) { |
|
| 634 | 634 | |
| 635 | 635 | // Decode html codes. |
| 636 | - switch ( $subcolumn ) { |
|
| 636 | + switch ($subcolumn) { |
|
| 637 | 637 | case 'name': |
| 638 | - $subdata = html_entity_decode( $subdata ); |
|
| 638 | + $subdata = html_entity_decode($subdata); |
|
| 639 | 639 | break; |
| 640 | 640 | } |
| 641 | 641 | |
| 642 | 642 | // @TODO Check if multi dimension array information is importent to show or not. For example inside donation array we have array for fees data inside payment meta. |
| 643 | - if ( is_array( $subdata ) ) { |
|
| 643 | + if (is_array($subdata)) { |
|
| 644 | 644 | continue; |
| 645 | 645 | } |
| 646 | 646 | |
| 647 | - WP_CLI::log( $this->color_message( $subcolumn, $subdata ) ); |
|
| 647 | + WP_CLI::log($this->color_message($subcolumn, $subdata)); |
|
| 648 | 648 | } |
| 649 | 649 | continue; |
| 650 | 650 | } |
| 651 | 651 | |
| 652 | - WP_CLI::log( $this->color_message( $column, $data ) ); |
|
| 652 | + WP_CLI::log($this->color_message($column, $data)); |
|
| 653 | 653 | } |
| 654 | 654 | } |
| 655 | 655 | } |
@@ -689,27 +689,27 @@ discard block |
||
| 689 | 689 | * |
| 690 | 690 | * @return void |
| 691 | 691 | */ |
| 692 | - public function report( $args, $assoc_args ) { |
|
| 692 | + public function report($args, $assoc_args) { |
|
| 693 | 693 | $stats = new Give_Payment_Stats(); |
| 694 | - $date = isset( $assoc_args ) && array_key_exists( 'date', $assoc_args ) ? $assoc_args['date'] : false; |
|
| 695 | - $start_date = isset( $assoc_args ) && array_key_exists( 'start-date', $assoc_args ) ? $assoc_args['start-date'] : false; |
|
| 696 | - $end_date = isset( $assoc_args ) && array_key_exists( 'end-date', $assoc_args ) ? $assoc_args['end-date'] : false; |
|
| 697 | - $form_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? $assoc_args['id'] : 0; |
|
| 694 | + $date = isset($assoc_args) && array_key_exists('date', $assoc_args) ? $assoc_args['date'] : false; |
|
| 695 | + $start_date = isset($assoc_args) && array_key_exists('start-date', $assoc_args) ? $assoc_args['start-date'] : false; |
|
| 696 | + $end_date = isset($assoc_args) && array_key_exists('end-date', $assoc_args) ? $assoc_args['end-date'] : false; |
|
| 697 | + $form_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? $assoc_args['id'] : 0; |
|
| 698 | 698 | |
| 699 | - if ( ! empty( $date ) ) { |
|
| 699 | + if ( ! empty($date)) { |
|
| 700 | 700 | $start_date = $date; |
| 701 | 701 | $end_date = false; |
| 702 | - } elseif ( empty( $date ) && empty( $start_date ) ) { |
|
| 702 | + } elseif (empty($date) && empty($start_date)) { |
|
| 703 | 703 | $start_date = 'this_month'; |
| 704 | 704 | $end_date = false; |
| 705 | 705 | } |
| 706 | 706 | |
| 707 | 707 | // Get stats. |
| 708 | - $earnings = $stats->get_earnings( $form_id, $start_date, $end_date ); |
|
| 709 | - $sales = $stats->get_sales( $form_id, $start_date, $end_date ); |
|
| 708 | + $earnings = $stats->get_earnings($form_id, $start_date, $end_date); |
|
| 709 | + $sales = $stats->get_sales($form_id, $start_date, $end_date); |
|
| 710 | 710 | |
| 711 | - WP_CLI::line( $this->color_message( __( 'Earnings', 'give' ), give_currency_filter( $earnings ) ) ); |
|
| 712 | - WP_CLI::line( $this->color_message( __( 'Sales', 'give' ), $sales ) ); |
|
| 711 | + WP_CLI::line($this->color_message(__('Earnings', 'give'), give_currency_filter($earnings))); |
|
| 712 | + WP_CLI::line($this->color_message(__('Sales', 'give'), $sales)); |
|
| 713 | 713 | } |
| 714 | 714 | |
| 715 | 715 | |
@@ -736,27 +736,27 @@ discard block |
||
| 736 | 736 | * |
| 737 | 737 | * @subcommand cache |
| 738 | 738 | */ |
| 739 | - public function cache( $args, $assoc_args ) { |
|
| 740 | - $action = isset( $assoc_args ) && array_key_exists( 'action', $assoc_args ) ? $assoc_args['action'] : false; |
|
| 739 | + public function cache($args, $assoc_args) { |
|
| 740 | + $action = isset($assoc_args) && array_key_exists('action', $assoc_args) ? $assoc_args['action'] : false; |
|
| 741 | 741 | |
| 742 | 742 | // Bailout. |
| 743 | - if ( ! $action || ! in_array( $action, array( 'delete' ), true ) ) { |
|
| 744 | - WP_CLI::warning( __( 'Type wp give cache --action=delete to delete all stat transients', 'give' ) ); |
|
| 743 | + if ( ! $action || ! in_array($action, array('delete'), true)) { |
|
| 744 | + WP_CLI::warning(__('Type wp give cache --action=delete to delete all stat transients', 'give')); |
|
| 745 | 745 | |
| 746 | 746 | return; |
| 747 | 747 | } |
| 748 | 748 | |
| 749 | - switch ( $action ) { |
|
| 749 | + switch ($action) { |
|
| 750 | 750 | case 'delete': |
| 751 | 751 | // Reset counter. |
| 752 | 752 | self::$counter = 1; |
| 753 | 753 | |
| 754 | - if ( $this->delete_stats_transients() ) { |
|
| 754 | + if ($this->delete_stats_transients()) { |
|
| 755 | 755 | // Report .eading. |
| 756 | - WP_CLI::success( 'Give cache deleted.' ); |
|
| 756 | + WP_CLI::success('Give cache deleted.'); |
|
| 757 | 757 | } else { |
| 758 | 758 | // Report .eading. |
| 759 | - WP_CLI::warning( 'We did not find any Give plugin cache to delete :)' ); |
|
| 759 | + WP_CLI::warning('We did not find any Give plugin cache to delete :)'); |
|
| 760 | 760 | } |
| 761 | 761 | break; |
| 762 | 762 | } |
@@ -785,27 +785,27 @@ discard block |
||
| 785 | 785 | ARRAY_A |
| 786 | 786 | ); |
| 787 | 787 | |
| 788 | - if ( ! empty( $stat_option_names ) ) { |
|
| 788 | + if ( ! empty($stat_option_names)) { |
|
| 789 | 789 | |
| 790 | - foreach ( $stat_option_names as $option_name ) { |
|
| 790 | + foreach ($stat_option_names as $option_name) { |
|
| 791 | 791 | $error = false; |
| 792 | 792 | $option_name = $option_name['option_name']; |
| 793 | 793 | |
| 794 | - switch ( true ) { |
|
| 795 | - case ( false !== strpos( $option_name, 'transient' ) ): |
|
| 796 | - $option_name = str_replace( '_transient_', '', $option_name ); |
|
| 797 | - $error = delete_transient( $option_name ); |
|
| 794 | + switch (true) { |
|
| 795 | + case (false !== strpos($option_name, 'transient')): |
|
| 796 | + $option_name = str_replace('_transient_', '', $option_name); |
|
| 797 | + $error = delete_transient($option_name); |
|
| 798 | 798 | break; |
| 799 | 799 | |
| 800 | 800 | default: |
| 801 | - $error = delete_option( $option_name ); |
|
| 801 | + $error = delete_option($option_name); |
|
| 802 | 802 | } |
| 803 | 803 | |
| 804 | - if ( $error ) { |
|
| 805 | - WP_CLI::log( $this->color_message( self::$counter, $option_name ) ); |
|
| 806 | - self::$counter ++; |
|
| 804 | + if ($error) { |
|
| 805 | + WP_CLI::log($this->color_message(self::$counter, $option_name)); |
|
| 806 | + self::$counter++; |
|
| 807 | 807 | } else { |
| 808 | - WP_CLI::log( $this->color_message( __( 'Error while deleting this transient', 'give' ), $option_name ) ); |
|
| 808 | + WP_CLI::log($this->color_message(__('Error while deleting this transient', 'give'), $option_name)); |
|
| 809 | 809 | } |
| 810 | 810 | } |
| 811 | 811 | |
@@ -826,13 +826,13 @@ discard block |
||
| 826 | 826 | * |
| 827 | 827 | * @return string |
| 828 | 828 | */ |
| 829 | - private function color_message( $heading, $message = '', $colon = true, $color = 'g' ) { |
|
| 829 | + private function color_message($heading, $message = '', $colon = true, $color = 'g') { |
|
| 830 | 830 | // Add colon. |
| 831 | - if ( $colon ) { |
|
| 832 | - $heading = $heading . ': '; |
|
| 831 | + if ($colon) { |
|
| 832 | + $heading = $heading.': '; |
|
| 833 | 833 | } |
| 834 | 834 | |
| 835 | - return WP_CLI::colorize( "%{$color}" . $heading . '%n' ) . $message; |
|
| 835 | + return WP_CLI::colorize("%{$color}".$heading.'%n').$message; |
|
| 836 | 836 | } |
| 837 | 837 | |
| 838 | 838 | |
@@ -847,8 +847,8 @@ discard block |
||
| 847 | 847 | * |
| 848 | 848 | * @return void |
| 849 | 849 | */ |
| 850 | - private function color_main_heading( $heading, $color = 'g' ) { |
|
| 851 | - WP_CLI::log( "\n###### " . $this->color_message( $heading, '', false, $color ) . ' ######' ); |
|
| 850 | + private function color_main_heading($heading, $color = 'g') { |
|
| 851 | + WP_CLI::log("\n###### ".$this->color_message($heading, '', false, $color).' ######'); |
|
| 852 | 852 | } |
| 853 | 853 | |
| 854 | 854 | /** |
@@ -861,8 +861,8 @@ discard block |
||
| 861 | 861 | * |
| 862 | 862 | * @return void |
| 863 | 863 | */ |
| 864 | - private function color_sub_heading( $subheading ) { |
|
| 865 | - WP_CLI::log( "\n--->" . $subheading . '', '', false ); |
|
| 864 | + private function color_sub_heading($subheading) { |
|
| 865 | + WP_CLI::log("\n--->".$subheading.'', '', false); |
|
| 866 | 866 | } |
| 867 | 867 | |
| 868 | 868 | |
@@ -876,17 +876,17 @@ discard block |
||
| 876 | 876 | * |
| 877 | 877 | * @return void |
| 878 | 878 | */ |
| 879 | - private function display_table( $data ) { |
|
| 879 | + private function display_table($data) { |
|
| 880 | 880 | $table = new \cli\Table(); |
| 881 | 881 | |
| 882 | 882 | // Set table header. |
| 883 | - $table->setHeaders( $data[0] ); |
|
| 883 | + $table->setHeaders($data[0]); |
|
| 884 | 884 | |
| 885 | 885 | // Remove table header. |
| 886 | - unset( $data[0] ); |
|
| 886 | + unset($data[0]); |
|
| 887 | 887 | |
| 888 | 888 | // Set table data. |
| 889 | - $table->setRows( $data ); |
|
| 889 | + $table->setRows($data); |
|
| 890 | 890 | |
| 891 | 891 | // Display table. |
| 892 | 892 | $table->display(); |
@@ -903,14 +903,14 @@ discard block |
||
| 903 | 903 | * @return array |
| 904 | 904 | */ |
| 905 | 905 | |
| 906 | - private function get_donors_by_form_id( $form_id ) { |
|
| 906 | + private function get_donors_by_form_id($form_id) { |
|
| 907 | 907 | $donors = array(); |
| 908 | 908 | |
| 909 | 909 | $donations = new Give_Payments_Query( |
| 910 | 910 | array( |
| 911 | - 'give_forms' => array( $form_id ), |
|
| 912 | - 'number' => - 1, |
|
| 913 | - 'status' => array( 'publish' ), |
|
| 911 | + 'give_forms' => array($form_id), |
|
| 912 | + 'number' => -1, |
|
| 913 | + 'status' => array('publish'), |
|
| 914 | 914 | ) |
| 915 | 915 | ); |
| 916 | 916 | |
@@ -918,16 +918,16 @@ discard block |
||
| 918 | 918 | $skip_donors = array(); |
| 919 | 919 | |
| 920 | 920 | /* @var Give_Payment|object $donation Payment object. */ |
| 921 | - foreach ( $donations as $donation ) { |
|
| 921 | + foreach ($donations as $donation) { |
|
| 922 | 922 | |
| 923 | - if ( in_array( $donation->customer_id, $skip_donors, true ) ) { |
|
| 923 | + if (in_array($donation->customer_id, $skip_donors, true)) { |
|
| 924 | 924 | continue; |
| 925 | 925 | } |
| 926 | 926 | |
| 927 | - if ( ! empty( $donors ) ) { |
|
| 928 | - $donors['donors'][] = current( current( $this->api->get_donors( (int) $donation->customer_id ) ) ); |
|
| 927 | + if ( ! empty($donors)) { |
|
| 928 | + $donors['donors'][] = current(current($this->api->get_donors((int) $donation->customer_id))); |
|
| 929 | 929 | } else { |
| 930 | - $donors = array_merge( $donors, $this->api->get_donors( (int) $donation->customer_id ) ); |
|
| 930 | + $donors = array_merge($donors, $this->api->get_donors((int) $donation->customer_id)); |
|
| 931 | 931 | } |
| 932 | 932 | |
| 933 | 933 | $skip_donors[] = $donation->customer_id; |
@@ -972,15 +972,15 @@ discard block |
||
| 972 | 972 | ); |
| 973 | 973 | |
| 974 | 974 | // Generate a random forename. |
| 975 | - $random_name = $names[ mt_rand( 0, sizeof( $names ) - 1 ) ]; |
|
| 975 | + $random_name = $names[mt_rand(0, sizeof($names) - 1)]; |
|
| 976 | 976 | |
| 977 | 977 | // Generate a random surname. |
| 978 | - $random_surname = $surnames[ mt_rand( 0, sizeof( $surnames ) - 1 ) ]; |
|
| 978 | + $random_surname = $surnames[mt_rand(0, sizeof($surnames) - 1)]; |
|
| 979 | 979 | |
| 980 | 980 | // Generate name. |
| 981 | 981 | $name = "{$random_name} {$random_surname}"; |
| 982 | 982 | |
| 983 | - if ( in_array( $name, $this->new_donor_names ) ) { |
|
| 983 | + if (in_array($name, $this->new_donor_names)) { |
|
| 984 | 984 | $name = $this->get_random_name(); |
| 985 | 985 | } |
| 986 | 986 | |
@@ -999,7 +999,7 @@ discard block |
||
| 999 | 999 | * |
| 1000 | 1000 | * @return string |
| 1001 | 1001 | */ |
| 1002 | - private function get_random_email( $name ) { |
|
| 1003 | - return implode( '.', explode( ' ', strtolower( $name ) ) ) . '@test.com'; |
|
| 1002 | + private function get_random_email($name) { |
|
| 1003 | + return implode('.', explode(' ', strtolower($name))).'@test.com'; |
|
| 1004 | 1004 | } |
| 1005 | 1005 | } |
@@ -9,11 +9,11 @@ discard block |
||
| 9 | 9 | * @since 1.8 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; // Exit if accessed directly |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -if ( ! class_exists( 'Give_Earnings_Report' ) ) : |
|
| 16 | +if ( ! class_exists('Give_Earnings_Report')) : |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Give_Earnings_Report. |
@@ -35,16 +35,16 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | public function __construct() { |
| 37 | 37 | $this->id = 'earnings'; |
| 38 | - $this->label = esc_html__( 'Income', 'give' ); |
|
| 38 | + $this->label = esc_html__('Income', 'give'); |
|
| 39 | 39 | |
| 40 | 40 | parent::__construct(); |
| 41 | 41 | |
| 42 | - add_action( 'give_admin_field_report_earnings', array( $this, 'render_report_earnings_field' ), 10, 2 ); |
|
| 42 | + add_action('give_admin_field_report_earnings', array($this, 'render_report_earnings_field'), 10, 2); |
|
| 43 | 43 | |
| 44 | 44 | // Do not use main form for this tab. |
| 45 | - if ( give_get_current_setting_tab() === $this->id ) { |
|
| 46 | - add_action( 'give-reports_open_form', '__return_empty_string' ); |
|
| 47 | - add_action( 'give-reports_close_form', '__return_empty_string' ); |
|
| 45 | + if (give_get_current_setting_tab() === $this->id) { |
|
| 46 | + add_action('give-reports_open_form', '__return_empty_string'); |
|
| 47 | + add_action('give-reports_close_form', '__return_empty_string'); |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * @param array $settings |
| 65 | 65 | */ |
| 66 | 66 | $settings = apply_filters( |
| 67 | - 'give_get_settings_' . $this->id, |
|
| 67 | + 'give_get_settings_'.$this->id, |
|
| 68 | 68 | array( |
| 69 | 69 | array( |
| 70 | 70 | 'id' => 'give_tools_earnings', |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | ), |
| 74 | 74 | array( |
| 75 | 75 | 'id' => 'earnings', |
| 76 | - 'name' => esc_html__( 'Income', 'give' ), |
|
| 76 | + 'name' => esc_html__('Income', 'give'), |
|
| 77 | 77 | 'type' => 'report_earnings', |
| 78 | 78 | ), |
| 79 | 79 | array( |
@@ -97,8 +97,8 @@ discard block |
||
| 97 | 97 | * @param $field |
| 98 | 98 | * @param $option_value |
| 99 | 99 | */ |
| 100 | - public function render_report_earnings_field( $field, $option_value ) { |
|
| 101 | - do_action( 'give_reports_view_earnings' ); |
|
| 100 | + public function render_report_earnings_field($field, $option_value) { |
|
| 101 | + do_action('give_reports_view_earnings'); |
|
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | |
@@ -9,11 +9,11 @@ discard block |
||
| 9 | 9 | * @since 1.8 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; // Exit if accessed directly |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -if ( ! class_exists( 'Give_Forms_Report' ) ) : |
|
| 16 | +if ( ! class_exists('Give_Forms_Report')) : |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Give_Forms_Report. |
@@ -34,16 +34,16 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | public function __construct() { |
| 36 | 36 | $this->id = 'forms'; |
| 37 | - $this->label = esc_html__( 'Forms', 'give' ); |
|
| 37 | + $this->label = esc_html__('Forms', 'give'); |
|
| 38 | 38 | |
| 39 | 39 | parent::__construct(); |
| 40 | 40 | |
| 41 | - add_action( 'give_admin_field_report_forms', array( $this, 'render_report_forms_field' ), 10, 2 ); |
|
| 41 | + add_action('give_admin_field_report_forms', array($this, 'render_report_forms_field'), 10, 2); |
|
| 42 | 42 | |
| 43 | 43 | // Do not use main form for this tab. |
| 44 | - if ( give_get_current_setting_tab() === $this->id ) { |
|
| 45 | - add_action( 'give-reports_open_form', '__return_empty_string' ); |
|
| 46 | - add_action( 'give-reports_close_form', '__return_empty_string' ); |
|
| 44 | + if (give_get_current_setting_tab() === $this->id) { |
|
| 45 | + add_action('give-reports_open_form', '__return_empty_string'); |
|
| 46 | + add_action('give-reports_close_form', '__return_empty_string'); |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * @param array $settings |
| 64 | 64 | */ |
| 65 | 65 | $settings = apply_filters( |
| 66 | - 'give_get_settings_' . $this->id, |
|
| 66 | + 'give_get_settings_'.$this->id, |
|
| 67 | 67 | array( |
| 68 | 68 | array( |
| 69 | 69 | 'id' => 'give_reports_forms', |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | ), |
| 73 | 73 | array( |
| 74 | 74 | 'id' => 'forms', |
| 75 | - 'name' => esc_html__( 'Forms', 'give' ), |
|
| 75 | + 'name' => esc_html__('Forms', 'give'), |
|
| 76 | 76 | 'type' => 'report_forms', |
| 77 | 77 | ), |
| 78 | 78 | array( |
@@ -96,8 +96,8 @@ discard block |
||
| 96 | 96 | * @param $field |
| 97 | 97 | * @param $option_value |
| 98 | 98 | */ |
| 99 | - public function render_report_forms_field( $field, $option_value ) { |
|
| 100 | - do_action( 'give_reports_view_forms' ); |
|
| 99 | + public function render_report_forms_field($field, $option_value) { |
|
| 100 | + do_action('give_reports_view_forms'); |
|
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
@@ -9,11 +9,11 @@ discard block |
||
| 9 | 9 | * @since 1.8 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; // Exit if accessed directly |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -if ( ! class_exists( 'Give_Gateways_Report' ) ) : |
|
| 16 | +if ( ! class_exists('Give_Gateways_Report')) : |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Give_Gateways_Report. |
@@ -34,16 +34,16 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | public function __construct() { |
| 36 | 36 | $this->id = 'gateways'; |
| 37 | - $this->label = esc_html__( 'Donation Methods', 'give' ); |
|
| 37 | + $this->label = esc_html__('Donation Methods', 'give'); |
|
| 38 | 38 | |
| 39 | 39 | parent::__construct(); |
| 40 | 40 | |
| 41 | - add_action( 'give_admin_field_report_gateways', array( $this, 'render_report_gateways_field' ), 10, 2 ); |
|
| 41 | + add_action('give_admin_field_report_gateways', array($this, 'render_report_gateways_field'), 10, 2); |
|
| 42 | 42 | |
| 43 | 43 | // Do not use main form for this tab. |
| 44 | - if ( give_get_current_setting_tab() === $this->id ) { |
|
| 45 | - add_action( 'give-reports_open_form', '__return_empty_string' ); |
|
| 46 | - add_action( 'give-reports_close_form', '__return_empty_string' ); |
|
| 44 | + if (give_get_current_setting_tab() === $this->id) { |
|
| 45 | + add_action('give-reports_open_form', '__return_empty_string'); |
|
| 46 | + add_action('give-reports_close_form', '__return_empty_string'); |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * @param array $settings |
| 76 | 76 | */ |
| 77 | 77 | $settings = apply_filters( |
| 78 | - 'give_get_settings_' . $this->id, |
|
| 78 | + 'give_get_settings_'.$this->id, |
|
| 79 | 79 | array( |
| 80 | 80 | array( |
| 81 | 81 | 'id' => 'give_reports_gateways', |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | ), |
| 85 | 85 | array( |
| 86 | 86 | 'id' => 'gateways', |
| 87 | - 'name' => esc_html__( 'Gateways', 'give' ), |
|
| 87 | + 'name' => esc_html__('Gateways', 'give'), |
|
| 88 | 88 | 'type' => 'report_gateways', |
| 89 | 89 | ), |
| 90 | 90 | array( |
@@ -108,8 +108,8 @@ discard block |
||
| 108 | 108 | * @param $field |
| 109 | 109 | * @param $option_value |
| 110 | 110 | */ |
| 111 | - public function render_report_gateways_field( $field, $option_value ) { |
|
| 112 | - do_action( 'give_reports_view_gateways' ); |
|
| 111 | + public function render_report_gateways_field($field, $option_value) { |
|
| 112 | + do_action('give_reports_view_gateways'); |
|
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | |
@@ -10,13 +10,13 @@ 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 | |
| 17 | 17 | // Load WP_List_Table if not loaded |
| 18 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
| 19 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
| 18 | +if ( ! class_exists('WP_List_Table')) { |
|
| 19 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -56,13 +56,13 @@ discard block |
||
| 56 | 56 | global $status, $page; |
| 57 | 57 | |
| 58 | 58 | // Set parent defaults |
| 59 | - parent::__construct( array( |
|
| 60 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records. |
|
| 61 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records. |
|
| 59 | + parent::__construct(array( |
|
| 60 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records. |
|
| 61 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records. |
|
| 62 | 62 | 'ajax' => false // Does this table support ajax? |
| 63 | - ) ); |
|
| 63 | + )); |
|
| 64 | 64 | |
| 65 | - add_action( 'give_report_view_actions', array( $this, 'category_filter' ) ); |
|
| 65 | + add_action('give_report_view_actions', array($this, 'category_filter')); |
|
| 66 | 66 | $this->query(); |
| 67 | 67 | |
| 68 | 68 | } |
@@ -78,32 +78,32 @@ discard block |
||
| 78 | 78 | * |
| 79 | 79 | * @return string Column Name |
| 80 | 80 | */ |
| 81 | - public function column_default( $item, $column_name ) { |
|
| 82 | - switch ( $column_name ) { |
|
| 81 | + public function column_default($item, $column_name) { |
|
| 82 | + switch ($column_name) { |
|
| 83 | 83 | case 'title': |
| 84 | - $title = empty( $item['title'] ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $item['ID'] ) : $item['title']; |
|
| 84 | + $title = empty($item['title']) ? sprintf(__('Untitled (#%s)', 'give'), $item['ID']) : $item['title']; |
|
| 85 | 85 | |
| 86 | 86 | return sprintf( |
| 87 | 87 | '<a href="%s">%s</a>', |
| 88 | - get_edit_post_link( $item['ID'] ), |
|
| 88 | + get_edit_post_link($item['ID']), |
|
| 89 | 89 | $title |
| 90 | 90 | ); |
| 91 | 91 | case 'sales': |
| 92 | 92 | return sprintf( |
| 93 | 93 | '<a href="%s">%s</a>', |
| 94 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&form_id=' . urlencode( $item['ID'] ) ), |
|
| 94 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&form_id='.urlencode($item['ID'])), |
|
| 95 | 95 | $item['sales'] |
| 96 | 96 | ); |
| 97 | 97 | case 'earnings' : |
| 98 | - return give_currency_filter( give_format_amount( $item[ $column_name ], array( 'sanitize' => false ) ) ); |
|
| 98 | + return give_currency_filter(give_format_amount($item[$column_name], array('sanitize' => false))); |
|
| 99 | 99 | case 'average_sales' : |
| 100 | - return round( $item[ $column_name ] ); |
|
| 100 | + return round($item[$column_name]); |
|
| 101 | 101 | case 'average_earnings' : |
| 102 | - return give_currency_filter( give_format_amount( $item[ $column_name ], array( 'sanitize' => false ) ) ); |
|
| 102 | + return give_currency_filter(give_format_amount($item[$column_name], array('sanitize' => false))); |
|
| 103 | 103 | case 'details' : |
| 104 | - return '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=forms&form-id=' . $item['ID'] ) . '">' . esc_html__( 'View Detailed Report', 'give' ) . '</a>'; |
|
| 104 | + return '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-reports&tab=forms&form-id='.$item['ID']).'">'.esc_html__('View Detailed Report', 'give').'</a>'; |
|
| 105 | 105 | default: |
| 106 | - return $item[ $column_name ]; |
|
| 106 | + return $item[$column_name]; |
|
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | 109 | |
@@ -117,12 +117,12 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | public function get_columns() { |
| 119 | 119 | $columns = array( |
| 120 | - 'title' => esc_html__( 'Form', 'give' ), |
|
| 121 | - 'sales' => esc_html__( 'Donations', 'give' ), |
|
| 122 | - 'earnings' => esc_html__( 'Income', 'give' ), |
|
| 123 | - 'average_sales' => esc_html__( 'Monthly Average Donations', 'give' ), |
|
| 124 | - 'average_earnings' => esc_html__( 'Monthly Average Income', 'give' ), |
|
| 125 | - 'details' => esc_html__( 'Detailed Report', 'give' ) |
|
| 120 | + 'title' => esc_html__('Form', 'give'), |
|
| 121 | + 'sales' => esc_html__('Donations', 'give'), |
|
| 122 | + 'earnings' => esc_html__('Income', 'give'), |
|
| 123 | + 'average_sales' => esc_html__('Monthly Average Donations', 'give'), |
|
| 124 | + 'average_earnings' => esc_html__('Monthly Average Income', 'give'), |
|
| 125 | + 'details' => esc_html__('Detailed Report', 'give') |
|
| 126 | 126 | ); |
| 127 | 127 | |
| 128 | 128 | return $columns; |
@@ -138,9 +138,9 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | public function get_sortable_columns() { |
| 140 | 140 | return array( |
| 141 | - 'title' => array( 'title', true ), |
|
| 142 | - 'sales' => array( 'sales', false ), |
|
| 143 | - 'earnings' => array( 'earnings', false ), |
|
| 141 | + 'title' => array('title', true), |
|
| 142 | + 'sales' => array('sales', false), |
|
| 143 | + 'earnings' => array('earnings', false), |
|
| 144 | 144 | ); |
| 145 | 145 | } |
| 146 | 146 | |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | * @return int Current page number |
| 154 | 154 | */ |
| 155 | 155 | public function get_paged() { |
| 156 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
| 156 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | * @return int Category ID |
| 166 | 166 | */ |
| 167 | 167 | public function get_category() { |
| 168 | - return isset( $_GET['category'] ) ? absint( $_GET['category'] ) : 0; |
|
| 168 | + return isset($_GET['category']) ? absint($_GET['category']) : 0; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | /** |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | * |
| 177 | 177 | * @return void |
| 178 | 178 | */ |
| 179 | - public function bulk_actions( $which = '' ) { |
|
| 179 | + public function bulk_actions($which = '') { |
|
| 180 | 180 | |
| 181 | 181 | } |
| 182 | 182 | |
@@ -188,27 +188,27 @@ discard block |
||
| 188 | 188 | * |
| 189 | 189 | * @param string $which |
| 190 | 190 | */ |
| 191 | - protected function display_tablenav( $which ) { |
|
| 191 | + protected function display_tablenav($which) { |
|
| 192 | 192 | |
| 193 | - if ( 'top' === $which ) { |
|
| 194 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
| 193 | + if ('top' === $which) { |
|
| 194 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
| 195 | 195 | } |
| 196 | 196 | ?> |
| 197 | - <div class="tablenav give-clearfix <?php echo esc_attr( $which ); ?>"> |
|
| 197 | + <div class="tablenav give-clearfix <?php echo esc_attr($which); ?>"> |
|
| 198 | 198 | |
| 199 | - <?php if ( 'top' === $which ) { ?> |
|
| 199 | + <?php if ('top' === $which) { ?> |
|
| 200 | 200 | <h2 class="alignleft reports-earnings-title screen-reader-text"> |
| 201 | - <?php _e( 'Donation Forms Report', 'give' ); ?> |
|
| 201 | + <?php _e('Donation Forms Report', 'give'); ?> |
|
| 202 | 202 | </h2> |
| 203 | 203 | <?php } ?> |
| 204 | 204 | |
| 205 | 205 | <div class="alignright tablenav-right"> |
| 206 | 206 | <div class="actions bulkactions"> |
| 207 | - <?php $this->bulk_actions( $which ); ?> |
|
| 207 | + <?php $this->bulk_actions($which); ?> |
|
| 208 | 208 | </div> |
| 209 | 209 | <?php |
| 210 | - $this->extra_tablenav( $which ); |
|
| 211 | - $this->pagination( $which ); |
|
| 210 | + $this->extra_tablenav($which); |
|
| 211 | + $this->pagination($which); |
|
| 212 | 212 | ?> |
| 213 | 213 | </div> |
| 214 | 214 | |
@@ -228,9 +228,9 @@ discard block |
||
| 228 | 228 | */ |
| 229 | 229 | public function category_filter() { |
| 230 | 230 | |
| 231 | - $categories = get_terms( 'form_category' ); |
|
| 232 | - if ( $categories && ! is_wp_error( $categories ) ) { |
|
| 233 | - echo Give()->html->category_dropdown( 'category', $this->get_category() ); |
|
| 231 | + $categories = get_terms('form_category'); |
|
| 232 | + if ($categories && ! is_wp_error($categories)) { |
|
| 233 | + echo Give()->html->category_dropdown('category', $this->get_category()); |
|
| 234 | 234 | } |
| 235 | 235 | } |
| 236 | 236 | |
@@ -244,8 +244,8 @@ discard block |
||
| 244 | 244 | */ |
| 245 | 245 | public function query() { |
| 246 | 246 | |
| 247 | - $orderby = isset( $_GET['orderby'] ) ? $_GET['orderby'] : 'title'; |
|
| 248 | - $order = isset( $_GET['order'] ) ? $_GET['order'] : 'DESC'; |
|
| 247 | + $orderby = isset($_GET['orderby']) ? $_GET['orderby'] : 'title'; |
|
| 248 | + $order = isset($_GET['order']) ? $_GET['order'] : 'DESC'; |
|
| 249 | 249 | $category = $this->get_category(); |
| 250 | 250 | |
| 251 | 251 | $args = array( |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | 'suppress_filters' => true |
| 259 | 259 | ); |
| 260 | 260 | |
| 261 | - if ( ! empty( $category ) ) { |
|
| 261 | + if ( ! empty($category)) { |
|
| 262 | 262 | $args['tax_query'] = array( |
| 263 | 263 | array( |
| 264 | 264 | 'taxonomy' => 'form_category', |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | ); |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - switch ( $orderby ) : |
|
| 270 | + switch ($orderby) : |
|
| 271 | 271 | case 'title' : |
| 272 | 272 | $args['orderby'] = 'title'; |
| 273 | 273 | break; |
@@ -283,9 +283,9 @@ discard block |
||
| 283 | 283 | break; |
| 284 | 284 | endswitch; |
| 285 | 285 | |
| 286 | - $args = apply_filters( 'give_form_reports_prepare_items_args', $args, $this ); |
|
| 286 | + $args = apply_filters('give_form_reports_prepare_items_args', $args, $this); |
|
| 287 | 287 | |
| 288 | - $this->donation_forms = new WP_Query( $args ); |
|
| 288 | + $this->donation_forms = new WP_Query($args); |
|
| 289 | 289 | |
| 290 | 290 | // Store total number of donation forms count. |
| 291 | 291 | $this->count = $this->donation_forms->found_posts; |
@@ -305,15 +305,15 @@ discard block |
||
| 305 | 305 | |
| 306 | 306 | $give_forms = $this->donation_forms->posts; |
| 307 | 307 | |
| 308 | - if ( $give_forms ) { |
|
| 309 | - foreach ( $give_forms as $form ) { |
|
| 308 | + if ($give_forms) { |
|
| 309 | + foreach ($give_forms as $form) { |
|
| 310 | 310 | $reports_data[] = array( |
| 311 | 311 | 'ID' => $form, |
| 312 | - 'title' => get_the_title( $form ), |
|
| 313 | - 'sales' => give_get_form_sales_stats( $form ), |
|
| 314 | - 'earnings' => give_get_form_earnings_stats( $form ), |
|
| 315 | - 'average_sales' => give_get_average_monthly_form_sales( $form ), |
|
| 316 | - 'average_earnings' => give_get_average_monthly_form_earnings( $form ) |
|
| 312 | + 'title' => get_the_title($form), |
|
| 313 | + 'sales' => give_get_form_sales_stats($form), |
|
| 314 | + 'earnings' => give_get_form_earnings_stats($form), |
|
| 315 | + 'average_sales' => give_get_average_monthly_form_sales($form), |
|
| 316 | + 'average_earnings' => give_get_average_monthly_form_earnings($form) |
|
| 317 | 317 | ); |
| 318 | 318 | } |
| 319 | 319 | } |
@@ -338,14 +338,14 @@ discard block |
||
| 338 | 338 | $columns = $this->get_columns(); |
| 339 | 339 | $hidden = array(); // No hidden columns |
| 340 | 340 | $sortable = $this->get_sortable_columns(); |
| 341 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
| 341 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
| 342 | 342 | $this->items = $this->reports_data(); |
| 343 | 343 | $total_items = $this->count; |
| 344 | 344 | |
| 345 | - $this->set_pagination_args( array( |
|
| 345 | + $this->set_pagination_args(array( |
|
| 346 | 346 | 'total_items' => $total_items, |
| 347 | 347 | 'per_page' => $this->per_page, |
| 348 | - 'total_pages' => ceil( $total_items / $this->per_page ) |
|
| 348 | + 'total_pages' => ceil($total_items / $this->per_page) |
|
| 349 | 349 | ) |
| 350 | 350 | ); |
| 351 | 351 | } |