@@ -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 | |
@@ -27,34 +27,34 @@ discard block |
||
| 27 | 27 | * @return array $form_columns Updated array of forms columns |
| 28 | 28 | * Post Type List Table |
| 29 | 29 | */ |
| 30 | -function give_form_columns( $give_form_columns ) { |
|
| 30 | +function give_form_columns($give_form_columns) { |
|
| 31 | 31 | |
| 32 | 32 | // Standard columns |
| 33 | 33 | $give_form_columns = array( |
| 34 | 34 | 'cb' => '<input type="checkbox"/>', |
| 35 | - 'title' => __( 'Name', 'give' ), |
|
| 36 | - 'form_category' => __( 'Categories', 'give' ), |
|
| 37 | - 'form_tag' => __( 'Tags', 'give' ), |
|
| 38 | - 'price' => __( 'Amount', 'give' ), |
|
| 39 | - 'goal' => __( 'Goal', 'give' ), |
|
| 40 | - 'donations' => __( 'Donations', 'give' ), |
|
| 41 | - 'earnings' => __( 'Income', 'give' ), |
|
| 42 | - 'shortcode' => __( 'Shortcode', 'give' ), |
|
| 43 | - 'date' => __( 'Date', 'give' ), |
|
| 35 | + 'title' => __('Name', 'give'), |
|
| 36 | + 'form_category' => __('Categories', 'give'), |
|
| 37 | + 'form_tag' => __('Tags', 'give'), |
|
| 38 | + 'price' => __('Amount', 'give'), |
|
| 39 | + 'goal' => __('Goal', 'give'), |
|
| 40 | + 'donations' => __('Donations', 'give'), |
|
| 41 | + 'earnings' => __('Income', 'give'), |
|
| 42 | + 'shortcode' => __('Shortcode', 'give'), |
|
| 43 | + 'date' => __('Date', 'give'), |
|
| 44 | 44 | ); |
| 45 | 45 | |
| 46 | 46 | // Does the user want categories / tags? |
| 47 | - if ( ! give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ) ) { |
|
| 48 | - unset( $give_form_columns['form_category'] ); |
|
| 47 | + if ( ! give_is_setting_enabled(give_get_option('categories', 'disabled'))) { |
|
| 48 | + unset($give_form_columns['form_category']); |
|
| 49 | 49 | } |
| 50 | - if ( ! give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ) ) { |
|
| 51 | - unset( $give_form_columns['form_tag'] ); |
|
| 50 | + if ( ! give_is_setting_enabled(give_get_option('tags', 'disabled'))) { |
|
| 51 | + unset($give_form_columns['form_tag']); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - return apply_filters( 'give_forms_columns', $give_form_columns ); |
|
| 54 | + return apply_filters('give_forms_columns', $give_form_columns); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | -add_filter( 'manage_edit-give_forms_columns', 'give_form_columns' ); |
|
| 57 | +add_filter('manage_edit-give_forms_columns', 'give_form_columns'); |
|
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | 60 | * Render Give Form Columns |
@@ -66,59 +66,59 @@ discard block |
||
| 66 | 66 | * |
| 67 | 67 | * @return void |
| 68 | 68 | */ |
| 69 | -function give_render_form_columns( $column_name, $post_id ) { |
|
| 70 | - if ( get_post_type( $post_id ) == 'give_forms' ) { |
|
| 69 | +function give_render_form_columns($column_name, $post_id) { |
|
| 70 | + if (get_post_type($post_id) == 'give_forms') { |
|
| 71 | 71 | |
| 72 | - switch ( $column_name ) { |
|
| 72 | + switch ($column_name) { |
|
| 73 | 73 | case 'form_category': |
| 74 | - echo get_the_term_list( $post_id, 'give_forms_category', '', ', ', '' ); |
|
| 74 | + echo get_the_term_list($post_id, 'give_forms_category', '', ', ', ''); |
|
| 75 | 75 | break; |
| 76 | 76 | case 'form_tag': |
| 77 | - echo get_the_term_list( $post_id, 'give_forms_tag', '', ', ', '' ); |
|
| 77 | + echo get_the_term_list($post_id, 'give_forms_tag', '', ', ', ''); |
|
| 78 | 78 | break; |
| 79 | 79 | case 'price': |
| 80 | - if ( give_has_variable_prices( $post_id ) ) { |
|
| 81 | - echo give_price_range( $post_id ); |
|
| 80 | + if (give_has_variable_prices($post_id)) { |
|
| 81 | + echo give_price_range($post_id); |
|
| 82 | 82 | } else { |
| 83 | - echo give_price( $post_id, false ); |
|
| 84 | - echo '<input type="hidden" class="formprice-' . $post_id . '" value="' . give_get_form_price( $post_id ) . '" />'; |
|
| 83 | + echo give_price($post_id, false); |
|
| 84 | + echo '<input type="hidden" class="formprice-'.$post_id.'" value="'.give_get_form_price($post_id).'" />'; |
|
| 85 | 85 | } |
| 86 | 86 | break; |
| 87 | 87 | case 'goal': |
| 88 | - if ( give_is_setting_enabled( give_get_meta( $post_id, '_give_goal_option', true ) ) ) { |
|
| 89 | - echo give_goal( $post_id, false ); |
|
| 88 | + if (give_is_setting_enabled(give_get_meta($post_id, '_give_goal_option', true))) { |
|
| 89 | + echo give_goal($post_id, false); |
|
| 90 | 90 | } else { |
| 91 | - esc_html_e( 'No Goal Set', 'give' ); |
|
| 91 | + esc_html_e('No Goal Set', 'give'); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - echo '<input type="hidden" class="formgoal-' . $post_id . '" value="' . give_get_form_goal( $post_id ) . '" />'; |
|
| 94 | + echo '<input type="hidden" class="formgoal-'.$post_id.'" value="'.give_get_form_goal($post_id).'" />'; |
|
| 95 | 95 | break; |
| 96 | 96 | case 'donations': |
| 97 | - if ( current_user_can( 'view_give_form_stats', $post_id ) ) { |
|
| 98 | - echo '<a href="' . esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&form_id=' . $post_id ) ) . '">'; |
|
| 99 | - echo give_get_form_sales_stats( $post_id ); |
|
| 97 | + if (current_user_can('view_give_form_stats', $post_id)) { |
|
| 98 | + echo '<a href="'.esc_url(admin_url('edit.php?post_type=give_forms&page=give-payment-history&form_id='.$post_id)).'">'; |
|
| 99 | + echo give_get_form_sales_stats($post_id); |
|
| 100 | 100 | echo '</a>'; |
| 101 | 101 | } else { |
| 102 | 102 | echo '-'; |
| 103 | 103 | } |
| 104 | 104 | break; |
| 105 | 105 | case 'earnings': |
| 106 | - if ( current_user_can( 'view_give_form_stats', $post_id ) ) { |
|
| 107 | - echo '<a href="' . esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=forms&form-id=' . $post_id ) ) . '">'; |
|
| 108 | - echo give_currency_filter( give_format_amount( give_get_form_earnings_stats( $post_id ), array( 'sanitize' => false ) ) ); |
|
| 106 | + if (current_user_can('view_give_form_stats', $post_id)) { |
|
| 107 | + echo '<a href="'.esc_url(admin_url('edit.php?post_type=give_forms&page=give-reports&tab=forms&form-id='.$post_id)).'">'; |
|
| 108 | + echo give_currency_filter(give_format_amount(give_get_form_earnings_stats($post_id), array('sanitize' => false))); |
|
| 109 | 109 | echo '</a>'; |
| 110 | 110 | } else { |
| 111 | 111 | echo '-'; |
| 112 | 112 | } |
| 113 | 113 | break; |
| 114 | 114 | case 'shortcode': |
| 115 | - echo '<input onclick="this.setSelectionRange(0, this.value.length)" type="text" class="shortcode-input" readonly="" value="[give_form id="' . absint( $post_id ) . '"]">'; |
|
| 115 | + echo '<input onclick="this.setSelectionRange(0, this.value.length)" type="text" class="shortcode-input" readonly="" value="[give_form id="'.absint($post_id).'"]">'; |
|
| 116 | 116 | break; |
| 117 | 117 | }// End switch(). |
| 118 | 118 | }// End if(). |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | -add_action( 'manage_posts_custom_column', 'give_render_form_columns', 10, 2 ); |
|
| 121 | +add_action('manage_posts_custom_column', 'give_render_form_columns', 10, 2); |
|
| 122 | 122 | |
| 123 | 123 | /** |
| 124 | 124 | * Registers the sortable columns in the list table |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | * |
| 130 | 130 | * @return array $columns Array of sortable columns |
| 131 | 131 | */ |
| 132 | -function give_sortable_form_columns( $columns ) { |
|
| 132 | +function give_sortable_form_columns($columns) { |
|
| 133 | 133 | $columns['price'] = 'amount'; |
| 134 | 134 | $columns['sales'] = 'sales'; |
| 135 | 135 | $columns['earnings'] = 'earnings'; |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | return $columns; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | -add_filter( 'manage_edit-give_forms_sortable_columns', 'give_sortable_form_columns' ); |
|
| 142 | +add_filter('manage_edit-give_forms_sortable_columns', 'give_sortable_form_columns'); |
|
| 143 | 143 | |
| 144 | 144 | /** |
| 145 | 145 | * Sorts Columns in the Forms List Table |
@@ -150,13 +150,13 @@ discard block |
||
| 150 | 150 | * |
| 151 | 151 | * @return array $vars Array of all the sort variables. |
| 152 | 152 | */ |
| 153 | -function give_sort_forms( $vars ) { |
|
| 153 | +function give_sort_forms($vars) { |
|
| 154 | 154 | // Check if we're viewing the "give_forms" post type. |
| 155 | - if ( ! isset( $vars['post_type'] ) || ! isset( $vars['orderby'] ) || 'give_forms' !== $vars['post_type'] ) { |
|
| 155 | + if ( ! isset($vars['post_type']) || ! isset($vars['orderby']) || 'give_forms' !== $vars['post_type']) { |
|
| 156 | 156 | return $vars; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - switch ( $vars['orderby'] ) { |
|
| 159 | + switch ($vars['orderby']) { |
|
| 160 | 160 | // Check if 'orderby' is set to "sales". |
| 161 | 161 | case 'sales': |
| 162 | 162 | $vars = array_merge( |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | |
| 182 | 182 | // Check if "orderby" is set to "price/amount". |
| 183 | 183 | case 'amount': |
| 184 | - $multi_level_meta_key = ( 'asc' === $vars['order'] ) ? '_give_levels_minimum_amount' : '_give_levels_maximum_amount'; |
|
| 184 | + $multi_level_meta_key = ('asc' === $vars['order']) ? '_give_levels_minimum_amount' : '_give_levels_maximum_amount'; |
|
| 185 | 185 | |
| 186 | 186 | $vars['orderby'] = 'meta_value_num'; |
| 187 | 187 | $vars['meta_query'] = array( |
@@ -233,17 +233,17 @@ discard block |
||
| 233 | 233 | * |
| 234 | 234 | * @return array Array of all sort variables. |
| 235 | 235 | */ |
| 236 | -function give_filter_forms( $vars ) { |
|
| 237 | - if ( isset( $vars['post_type'] ) && 'give_forms' == $vars['post_type'] ) { |
|
| 236 | +function give_filter_forms($vars) { |
|
| 237 | + if (isset($vars['post_type']) && 'give_forms' == $vars['post_type']) { |
|
| 238 | 238 | |
| 239 | 239 | // If an author ID was passed, use it |
| 240 | - if ( isset( $_REQUEST['author'] ) && ! current_user_can( 'view_give_reports' ) ) { |
|
| 240 | + if (isset($_REQUEST['author']) && ! current_user_can('view_give_reports')) { |
|
| 241 | 241 | |
| 242 | 242 | $author_id = $_REQUEST['author']; |
| 243 | - if ( (int) $author_id !== get_current_user_id() ) { |
|
| 244 | - wp_die( esc_html__( 'You do not have permission to view this data.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
| 243 | + if ((int) $author_id !== get_current_user_id()) { |
|
| 244 | + wp_die(esc_html__('You do not have permission to view this data.', 'give'), esc_html__('Error', 'give'), array( |
|
| 245 | 245 | 'response' => 403, |
| 246 | - ) ); |
|
| 246 | + )); |
|
| 247 | 247 | } |
| 248 | 248 | $vars = array_merge( |
| 249 | 249 | $vars, |
@@ -267,11 +267,11 @@ discard block |
||
| 267 | 267 | * @return void |
| 268 | 268 | */ |
| 269 | 269 | function give_forms_load() { |
| 270 | - add_filter( 'request', 'give_sort_forms' ); |
|
| 271 | - add_filter( 'request', 'give_filter_forms' ); |
|
| 270 | + add_filter('request', 'give_sort_forms'); |
|
| 271 | + add_filter('request', 'give_filter_forms'); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | -add_action( 'load-edit.php', 'give_forms_load', 9999 ); |
|
| 274 | +add_action('load-edit.php', 'give_forms_load', 9999); |
|
| 275 | 275 | |
| 276 | 276 | /** |
| 277 | 277 | * Remove Forms Month Filter |
@@ -285,17 +285,17 @@ discard block |
||
| 285 | 285 | * @global $typenow The post type we are viewing. |
| 286 | 286 | * @return array Empty array disables the dropdown. |
| 287 | 287 | */ |
| 288 | -function give_remove_month_filter( $dates ) { |
|
| 288 | +function give_remove_month_filter($dates) { |
|
| 289 | 289 | global $typenow; |
| 290 | 290 | |
| 291 | - if ( $typenow == 'give_forms' ) { |
|
| 291 | + if ($typenow == 'give_forms') { |
|
| 292 | 292 | $dates = array(); |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | return $dates; |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | -add_filter( 'months_dropdown_results', 'give_remove_month_filter', 99 ); |
|
| 298 | +add_filter('months_dropdown_results', 'give_remove_month_filter', 99); |
|
| 299 | 299 | |
| 300 | 300 | /** |
| 301 | 301 | * Updates price when saving post |
@@ -306,23 +306,23 @@ discard block |
||
| 306 | 306 | * |
| 307 | 307 | * @return int|null |
| 308 | 308 | */ |
| 309 | -function give_price_save_quick_edit( $post_id ) { |
|
| 310 | - if ( ! isset( $_POST['post_type'] ) || 'give_forms' !== $_POST['post_type'] ) { |
|
| 309 | +function give_price_save_quick_edit($post_id) { |
|
| 310 | + if ( ! isset($_POST['post_type']) || 'give_forms' !== $_POST['post_type']) { |
|
| 311 | 311 | return; |
| 312 | 312 | } |
| 313 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
| 313 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
| 314 | 314 | return $post_id; |
| 315 | 315 | } |
| 316 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
| 316 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { |
|
| 317 | 317 | return $post_id; |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - if ( isset( $_REQUEST['_give_regprice'] ) ) { |
|
| 321 | - give_update_meta( $post_id, '_give_set_price', give_sanitize_amount_for_db( strip_tags( stripslashes( $_REQUEST['_give_regprice'] ) ) ) ); |
|
| 320 | + if (isset($_REQUEST['_give_regprice'])) { |
|
| 321 | + give_update_meta($post_id, '_give_set_price', give_sanitize_amount_for_db(strip_tags(stripslashes($_REQUEST['_give_regprice'])))); |
|
| 322 | 322 | } |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | -add_action( 'save_post', 'give_price_save_quick_edit' ); |
|
| 325 | +add_action('save_post', 'give_price_save_quick_edit'); |
|
| 326 | 326 | |
| 327 | 327 | /** |
| 328 | 328 | * Process bulk edit actions via AJAX |
@@ -332,18 +332,18 @@ discard block |
||
| 332 | 332 | */ |
| 333 | 333 | function give_save_bulk_edit() { |
| 334 | 334 | |
| 335 | - $post_ids = ( isset( $_POST['post_ids'] ) && ! empty( $_POST['post_ids'] ) ) ? $_POST['post_ids'] : array(); |
|
| 335 | + $post_ids = (isset($_POST['post_ids']) && ! empty($_POST['post_ids'])) ? $_POST['post_ids'] : array(); |
|
| 336 | 336 | |
| 337 | - if ( ! empty( $post_ids ) && is_array( $post_ids ) ) { |
|
| 338 | - $price = isset( $_POST['price'] ) ? strip_tags( stripslashes( $_POST['price'] ) ) : 0; |
|
| 339 | - foreach ( $post_ids as $post_id ) { |
|
| 337 | + if ( ! empty($post_ids) && is_array($post_ids)) { |
|
| 338 | + $price = isset($_POST['price']) ? strip_tags(stripslashes($_POST['price'])) : 0; |
|
| 339 | + foreach ($post_ids as $post_id) { |
|
| 340 | 340 | |
| 341 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
| 341 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
| 342 | 342 | continue; |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | - if ( ! empty( $price ) ) { |
|
| 346 | - give_update_meta( $post_id, '_give_set_price', give_sanitize_amount_for_db( $price ) ); |
|
| 345 | + if ( ! empty($price)) { |
|
| 346 | + give_update_meta($post_id, '_give_set_price', give_sanitize_amount_for_db($price)); |
|
| 347 | 347 | } |
| 348 | 348 | } |
| 349 | 349 | } |
@@ -351,4 +351,4 @@ discard block |
||
| 351 | 351 | die(); |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | -add_action( 'wp_ajax_give_save_bulk_edit', 'give_save_bulk_edit' ); |
|
| 354 | +add_action('wp_ajax_give_save_bulk_edit', 'give_save_bulk_edit'); |
|
@@ -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 | |
@@ -21,12 +21,12 @@ discard block |
||
| 21 | 21 | * @return void |
| 22 | 22 | */ |
| 23 | 23 | function give_register_dashboard_widgets() { |
| 24 | - if ( current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) { |
|
| 25 | - wp_add_dashboard_widget( 'give_dashboard_sales', esc_html__( 'Give: Donation Statistics', 'give' ), 'give_dashboard_sales_widget' ); |
|
| 24 | + if (current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) { |
|
| 25 | + wp_add_dashboard_widget('give_dashboard_sales', esc_html__('Give: Donation Statistics', 'give'), 'give_dashboard_sales_widget'); |
|
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | -add_action( 'wp_dashboard_setup', 'give_register_dashboard_widgets', 10 ); |
|
| 29 | +add_action('wp_dashboard_setup', 'give_register_dashboard_widgets', 10); |
|
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * Sales Summary Dashboard Widget |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | function give_dashboard_sales_widget() { |
| 40 | 40 | |
| 41 | - if ( ! current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) { |
|
| 41 | + if ( ! current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) { |
|
| 42 | 42 | return; |
| 43 | 43 | } |
| 44 | 44 | $stats = new Give_Payment_Stats; ?> |
@@ -46,27 +46,27 @@ discard block |
||
| 46 | 46 | <div class="give-dashboard-widget"> |
| 47 | 47 | |
| 48 | 48 | <div class="give-dashboard-today give-clearfix"> |
| 49 | - <h3 class="give-dashboard-date-today"><?php echo date( _x( 'F j, Y', 'dashboard widget', 'give' ) ); ?></h3> |
|
| 49 | + <h3 class="give-dashboard-date-today"><?php echo date(_x('F j, Y', 'dashboard widget', 'give')); ?></h3> |
|
| 50 | 50 | |
| 51 | 51 | <p class="give-dashboard-happy-day"><?php |
| 52 | 52 | printf( |
| 53 | 53 | /* translators: %s: day of the week */ |
| 54 | - esc_html__( 'Happy %s!', 'give' ), |
|
| 55 | - date( 'l', current_time( 'timestamp' ) ) |
|
| 54 | + esc_html__('Happy %s!', 'give'), |
|
| 55 | + date('l', current_time('timestamp')) |
|
| 56 | 56 | ); |
| 57 | 57 | ?></p> |
| 58 | 58 | |
| 59 | 59 | <p class="give-dashboard-today-earnings"><?php |
| 60 | - $earnings_today = $stats->get_earnings( 0, 'today', false ); |
|
| 61 | - echo give_currency_filter( give_format_amount( $earnings_today, array( 'sanitize' => false ) ) ); |
|
| 60 | + $earnings_today = $stats->get_earnings(0, 'today', false); |
|
| 61 | + echo give_currency_filter(give_format_amount($earnings_today, array('sanitize' => false))); |
|
| 62 | 62 | ?></p> |
| 63 | 63 | |
| 64 | 64 | <p class="give-orders-today"><?php |
| 65 | - $donations_today = $stats->get_sales( 0, 'today', false ); |
|
| 65 | + $donations_today = $stats->get_sales(0, 'today', false); |
|
| 66 | 66 | printf( |
| 67 | 67 | /* translators: %s: daily donation count */ |
| 68 | - esc_html__( '%s donations today', 'give' ), |
|
| 69 | - give_format_amount( $donations_today, array( 'decimal' => false, 'sanitize' => false ) ) |
|
| 68 | + esc_html__('%s donations today', 'give'), |
|
| 69 | + give_format_amount($donations_today, array('decimal' => false, 'sanitize' => false)) |
|
| 70 | 70 | ); |
| 71 | 71 | ?></p> |
| 72 | 72 | |
@@ -76,34 +76,34 @@ discard block |
||
| 76 | 76 | <table class="give-table-stats"> |
| 77 | 77 | <thead style="display: none;"> |
| 78 | 78 | <tr> |
| 79 | - <th><?php esc_html_e( 'This Week', 'give' ); ?></th> |
|
| 80 | - <th><?php esc_html_e( 'This Month', 'give' ); ?></th> |
|
| 81 | - <th><?php esc_html_e( 'Past 30 Days', 'give' ); ?></th> |
|
| 79 | + <th><?php esc_html_e('This Week', 'give'); ?></th> |
|
| 80 | + <th><?php esc_html_e('This Month', 'give'); ?></th> |
|
| 81 | + <th><?php esc_html_e('Past 30 Days', 'give'); ?></th> |
|
| 82 | 82 | </tr> |
| 83 | 83 | </thead> |
| 84 | 84 | <tbody> |
| 85 | 85 | <tr id="give-table-stats-tr-1"> |
| 86 | 86 | <td> |
| 87 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_week' ), array( 'sanitize' => false ) ) ); ?></p> |
|
| 87 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_week'), array('sanitize' => false))); ?></p> |
|
| 88 | 88 | |
| 89 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'This Week', 'give' ); ?></p> |
|
| 89 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('This Week', 'give'); ?></p> |
|
| 90 | 90 | </td> |
| 91 | 91 | <td> |
| 92 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_month' ), array( 'sanitize' => false ) ) ); ?></p> |
|
| 92 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_month'), array('sanitize' => false))); ?></p> |
|
| 93 | 93 | |
| 94 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'This Month', 'give' ); ?></p> |
|
| 94 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('This Month', 'give'); ?></p> |
|
| 95 | 95 | </td> |
| 96 | 96 | </tr> |
| 97 | 97 | <tr id="give-table-stats-tr-2"> |
| 98 | 98 | <td> |
| 99 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'last_month' ), array( 'sanitize' => false ) ) ) ?></p> |
|
| 99 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'last_month'), array('sanitize' => false))) ?></p> |
|
| 100 | 100 | |
| 101 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'Last Month', 'give' ); ?></p> |
|
| 101 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('Last Month', 'give'); ?></p> |
|
| 102 | 102 | </td> |
| 103 | 103 | <td> |
| 104 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_year', false ), array( 'decimal' => false, 'sanitize' => false ) ) ) ?></p> |
|
| 104 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_year', false), array('decimal' => false, 'sanitize' => false))) ?></p> |
|
| 105 | 105 | |
| 106 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'This Year', 'give' ); ?></p> |
|
| 106 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('This Year', 'give'); ?></p> |
|
| 107 | 107 | </td> |
| 108 | 108 | </tr> |
| 109 | 109 | </tbody> |
@@ -123,23 +123,23 @@ discard block |
||
| 123 | 123 | * |
| 124 | 124 | * @return array |
| 125 | 125 | */ |
| 126 | -function give_dashboard_at_a_glance_widget( $items ) { |
|
| 127 | - $num_posts = wp_count_posts( 'give_forms' ); |
|
| 126 | +function give_dashboard_at_a_glance_widget($items) { |
|
| 127 | + $num_posts = wp_count_posts('give_forms'); |
|
| 128 | 128 | |
| 129 | - if ( $num_posts && $num_posts->publish ) { |
|
| 129 | + if ($num_posts && $num_posts->publish) { |
|
| 130 | 130 | |
| 131 | 131 | $text = sprintf( |
| 132 | 132 | /* translators: %s: number of posts published */ |
| 133 | - _n( '%s Give Form', '%s Give Forms', $num_posts->publish, 'give' ), |
|
| 133 | + _n('%s Give Form', '%s Give Forms', $num_posts->publish, 'give'), |
|
| 134 | 134 | $num_posts->publish |
| 135 | 135 | ); |
| 136 | 136 | |
| 137 | - $text = sprintf( $text, number_format_i18n( $num_posts->publish ) ); |
|
| 137 | + $text = sprintf($text, number_format_i18n($num_posts->publish)); |
|
| 138 | 138 | |
| 139 | - if ( current_user_can( 'edit_give_forms', get_current_user_id() ) ) { |
|
| 139 | + if (current_user_can('edit_give_forms', get_current_user_id())) { |
|
| 140 | 140 | $text = sprintf( |
| 141 | 141 | '<a class="give-forms-count" href="%1$s">%2$s</a>', |
| 142 | - admin_url( 'edit.php?post_type=give_forms' ), |
|
| 142 | + admin_url('edit.php?post_type=give_forms'), |
|
| 143 | 143 | $text |
| 144 | 144 | ); |
| 145 | 145 | } else { |
@@ -155,4 +155,4 @@ discard block |
||
| 155 | 155 | return $items; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | -add_filter( 'dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1 ); |
|
| 158 | +add_filter('dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1); |
|
@@ -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 | |
@@ -27,30 +27,30 @@ discard block |
||
| 27 | 27 | * |
| 28 | 28 | * @return mixed |
| 29 | 29 | */ |
| 30 | -function __give_sanitize_number_decimals_setting_field( $value ) { |
|
| 30 | +function __give_sanitize_number_decimals_setting_field($value) { |
|
| 31 | 31 | $value_changed = false; |
| 32 | 32 | $old_value = $value; |
| 33 | 33 | |
| 34 | - if ( isset( $_POST['decimal_separator'] ) ) { |
|
| 35 | - $value = ! empty( $_POST['decimal_separator'] ) ? $value : 0; |
|
| 34 | + if (isset($_POST['decimal_separator'])) { |
|
| 35 | + $value = ! empty($_POST['decimal_separator']) ? $value : 0; |
|
| 36 | 36 | $value_changed = true; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - if ( $value_changed && ( $old_value != $value ) ) { |
|
| 40 | - Give_Admin_Settings::add_error( 'give-number-decimal', __( 'The \'Number of Decimals\' option has been automatically set to zero because the \'Decimal Separator\' is not set.', 'give' ) ); |
|
| 39 | + if ($value_changed && ($old_value != $value)) { |
|
| 40 | + Give_Admin_Settings::add_error('give-number-decimal', __('The \'Number of Decimals\' option has been automatically set to zero because the \'Decimal Separator\' is not set.', 'give')); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - $value = absint( $value ); |
|
| 43 | + $value = absint($value); |
|
| 44 | 44 | |
| 45 | - if( 6 <= $value ) { |
|
| 45 | + if (6 <= $value) { |
|
| 46 | 46 | $value = 5; |
| 47 | - Give_Admin_Settings::add_error( 'give-number-decimal', __( 'The \'Number of Decimals\' option has been automatically set to 5 because you entered a number higher than the maximum allowed.', 'give' ) ); |
|
| 47 | + Give_Admin_Settings::add_error('give-number-decimal', __('The \'Number of Decimals\' option has been automatically set to 5 because you entered a number higher than the maximum allowed.', 'give')); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - return absint( $value ); |
|
| 50 | + return absint($value); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | -add_filter( 'give_admin_settings_sanitize_option_number_decimals', '__give_sanitize_number_decimals_setting_field', 10 ); |
|
| 53 | +add_filter('give_admin_settings_sanitize_option_number_decimals', '__give_sanitize_number_decimals_setting_field', 10); |
|
| 54 | 54 | |
| 55 | 55 | |
| 56 | 56 | /** |
@@ -66,17 +66,17 @@ discard block |
||
| 66 | 66 | * |
| 67 | 67 | * @return mixed |
| 68 | 68 | */ |
| 69 | -function __give_validate_decimal_separator_setting_field( $value ) { |
|
| 70 | - $thousand_separator = give_clean( $_POST['thousands_separator'] ); |
|
| 71 | - $decimal_separator = give_clean( $_POST['decimal_separator'] ); |
|
| 69 | +function __give_validate_decimal_separator_setting_field($value) { |
|
| 70 | + $thousand_separator = give_clean($_POST['thousands_separator']); |
|
| 71 | + $decimal_separator = give_clean($_POST['decimal_separator']); |
|
| 72 | 72 | |
| 73 | - if ( $decimal_separator === $thousand_separator ) { |
|
| 73 | + if ($decimal_separator === $thousand_separator) { |
|
| 74 | 74 | $value = ''; |
| 75 | 75 | $_POST['number_decimals'] = 0; |
| 76 | - Give_Admin_Settings::add_error( 'give-decimal-separator', __( 'The \'Decimal Separator\' option has automatically been set to empty because it can not be equal to the \'Thousand Separator\'', 'give' ) ); |
|
| 76 | + Give_Admin_Settings::add_error('give-decimal-separator', __('The \'Decimal Separator\' option has automatically been set to empty because it can not be equal to the \'Thousand Separator\'', 'give')); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | return $value; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | -add_filter( 'give_admin_settings_sanitize_option_decimal_separator', '__give_validate_decimal_separator_setting_field', 10 ); |
|
| 83 | 82 | \ No newline at end of file |
| 83 | +add_filter('give_admin_settings_sanitize_option_decimal_separator', '__give_validate_decimal_separator_setting_field', 10); |
|
| 84 | 84 | \ No newline at end of file |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | // Exit if accessed directly. |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; |
| 14 | 14 | } |
| 15 | 15 | |
@@ -23,10 +23,10 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | public function __construct() { |
| 25 | 25 | |
| 26 | - $this->shortcode['title'] = esc_html__( 'Donation Form Goal', 'give' ); |
|
| 27 | - $this->shortcode['label'] = esc_html__( 'Donation Form Goal', 'give' ); |
|
| 26 | + $this->shortcode['title'] = esc_html__('Donation Form Goal', 'give'); |
|
| 27 | + $this->shortcode['label'] = esc_html__('Donation Form Goal', 'give'); |
|
| 28 | 28 | |
| 29 | - parent::__construct( 'give_goal' ); |
|
| 29 | + parent::__construct('give_goal'); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -38,8 +38,8 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | $create_form_link = sprintf( |
| 40 | 40 | /* translators: %s: create new form URL */ |
| 41 | - __( '<a href="%s">Create</a> a new Donation Form.', 'give' ), |
|
| 42 | - admin_url( 'post-new.php?post_type=give_forms' ) |
|
| 41 | + __('<a href="%s">Create</a> a new Donation Form.', 'give'), |
|
| 42 | + admin_url('post-new.php?post_type=give_forms') |
|
| 43 | 43 | ); |
| 44 | 44 | |
| 45 | 45 | return array( |
@@ -51,35 +51,35 @@ discard block |
||
| 51 | 51 | 'meta_value' => 'enabled', |
| 52 | 52 | ), |
| 53 | 53 | 'name' => 'id', |
| 54 | - 'tooltip' => esc_attr__( 'Select a Donation Form', 'give' ), |
|
| 55 | - 'placeholder' => '- ' . esc_attr__( 'Select a Donation Form', 'give' ) . ' -', |
|
| 54 | + 'tooltip' => esc_attr__('Select a Donation Form', 'give'), |
|
| 55 | + 'placeholder' => '- '.esc_attr__('Select a Donation Form', 'give').' -', |
|
| 56 | 56 | 'required' => array( |
| 57 | - 'alert' => esc_html__( 'You must first select a Form!', 'give' ), |
|
| 58 | - 'error' => sprintf( '<p class="strong">%s</p><p class="no-margin">%s</p>', esc_html__( 'No forms found.', 'give' ), $create_form_link ), |
|
| 57 | + 'alert' => esc_html__('You must first select a Form!', 'give'), |
|
| 58 | + 'error' => sprintf('<p class="strong">%s</p><p class="no-margin">%s</p>', esc_html__('No forms found.', 'give'), $create_form_link), |
|
| 59 | 59 | ), |
| 60 | 60 | ), |
| 61 | 61 | array( |
| 62 | 62 | 'type' => 'container', |
| 63 | - 'html' => sprintf( '<p class="strong margin-top">%s</p>', esc_html__( 'Optional settings', 'give' ) ), |
|
| 63 | + 'html' => sprintf('<p class="strong margin-top">%s</p>', esc_html__('Optional settings', 'give')), |
|
| 64 | 64 | ), |
| 65 | 65 | array( |
| 66 | 66 | 'type' => 'listbox', |
| 67 | 67 | 'name' => 'show_text', |
| 68 | - 'label' => esc_attr__( 'Show Text:', 'give' ), |
|
| 69 | - 'tooltip' => esc_attr__( 'This text displays the amount of income raised compared to the goal.', 'give' ), |
|
| 68 | + 'label' => esc_attr__('Show Text:', 'give'), |
|
| 69 | + 'tooltip' => esc_attr__('This text displays the amount of income raised compared to the goal.', 'give'), |
|
| 70 | 70 | 'options' => array( |
| 71 | - 'true' => esc_html__( 'Show', 'give' ), |
|
| 72 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
| 71 | + 'true' => esc_html__('Show', 'give'), |
|
| 72 | + 'false' => esc_html__('Hide', 'give'), |
|
| 73 | 73 | ), |
| 74 | 74 | ), |
| 75 | 75 | array( |
| 76 | 76 | 'type' => 'listbox', |
| 77 | 77 | 'name' => 'show_bar', |
| 78 | - 'label' => esc_attr__( 'Show Progress Bar:', 'give' ), |
|
| 79 | - 'tooltip' => esc_attr__( 'Do you want to display the goal\'s progress bar?', 'give' ), |
|
| 78 | + 'label' => esc_attr__('Show Progress Bar:', 'give'), |
|
| 79 | + 'tooltip' => esc_attr__('Do you want to display the goal\'s progress bar?', 'give'), |
|
| 80 | 80 | 'options' => array( |
| 81 | - 'true' => esc_html__( 'Show', 'give' ), |
|
| 82 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
| 81 | + 'true' => esc_html__('Show', 'give'), |
|
| 82 | + 'false' => esc_html__('Hide', 'give'), |
|
| 83 | 83 | ), |
| 84 | 84 | ), |
| 85 | 85 | ); |
@@ -18,17 +18,17 @@ discard block |
||
| 18 | 18 | * |
| 19 | 19 | * @return array |
| 20 | 20 | */ |
| 21 | -function give_offline_register_gateway( $gateways ) { |
|
| 21 | +function give_offline_register_gateway($gateways) { |
|
| 22 | 22 | // Format: ID => Name |
| 23 | 23 | $gateways['offline'] = array( |
| 24 | - 'admin_label' => esc_attr__( 'Offline Donation', 'give' ), |
|
| 25 | - 'checkout_label' => esc_attr__( 'Offline Donation', 'give' ) |
|
| 24 | + 'admin_label' => esc_attr__('Offline Donation', 'give'), |
|
| 25 | + 'checkout_label' => esc_attr__('Offline Donation', 'give') |
|
| 26 | 26 | ); |
| 27 | 27 | |
| 28 | 28 | return $gateways; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | -add_filter( 'give_payment_gateways', 'give_offline_register_gateway', 1 ); |
|
| 31 | +add_filter('give_payment_gateways', 'give_offline_register_gateway', 1); |
|
| 32 | 32 | |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @return void |
| 42 | 42 | */ |
| 43 | -function give_offline_payment_cc_form( $form_id ) { |
|
| 43 | +function give_offline_payment_cc_form($form_id) { |
|
| 44 | 44 | // Get offline payment instruction. |
| 45 | - $offline_instructions = give_get_offline_payment_instruction( $form_id, true ); |
|
| 45 | + $offline_instructions = give_get_offline_payment_instruction($form_id, true); |
|
| 46 | 46 | |
| 47 | 47 | ob_start(); |
| 48 | 48 | |
@@ -53,10 +53,10 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @param int $form_id Give form id. |
| 55 | 55 | */ |
| 56 | - do_action( 'give_before_offline_info_fields', $form_id ); |
|
| 56 | + do_action('give_before_offline_info_fields', $form_id); |
|
| 57 | 57 | ?> |
| 58 | 58 | <fieldset id="give_offline_payment_info"> |
| 59 | - <?php echo stripslashes( $offline_instructions ); ?> |
|
| 59 | + <?php echo stripslashes($offline_instructions); ?> |
|
| 60 | 60 | </fieldset> |
| 61 | 61 | <?php |
| 62 | 62 | /** |
@@ -66,35 +66,35 @@ discard block |
||
| 66 | 66 | * |
| 67 | 67 | * @param int $form_id Give form id. |
| 68 | 68 | */ |
| 69 | - do_action( 'give_after_offline_info_fields', $form_id ); |
|
| 69 | + do_action('give_after_offline_info_fields', $form_id); |
|
| 70 | 70 | |
| 71 | 71 | echo ob_get_clean(); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | -add_action( 'give_offline_cc_form', 'give_offline_payment_cc_form' ); |
|
| 74 | +add_action('give_offline_cc_form', 'give_offline_payment_cc_form'); |
|
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | 77 | * Give Offline Billing Field |
| 78 | 78 | * |
| 79 | 79 | * @param $form_id |
| 80 | 80 | */ |
| 81 | -function give_offline_billing_fields( $form_id ) { |
|
| 81 | +function give_offline_billing_fields($form_id) { |
|
| 82 | 82 | //Enable Default CC fields (billing info) |
| 83 | - $post_offline_cc_fields = give_get_meta( $form_id, '_give_offline_donation_enable_billing_fields_single', true ); |
|
| 84 | - $post_offline_customize_option = give_get_meta( $form_id, '_give_customize_offline_donations', true ); |
|
| 83 | + $post_offline_cc_fields = give_get_meta($form_id, '_give_offline_donation_enable_billing_fields_single', true); |
|
| 84 | + $post_offline_customize_option = give_get_meta($form_id, '_give_customize_offline_donations', true); |
|
| 85 | 85 | |
| 86 | - $global_offline_cc_fields = give_get_option( 'give_offline_donation_enable_billing_fields' ); |
|
| 86 | + $global_offline_cc_fields = give_get_option('give_offline_donation_enable_billing_fields'); |
|
| 87 | 87 | |
| 88 | 88 | //Output CC Address fields if global option is on and user hasn't elected to customize this form's offline donation options |
| 89 | 89 | if ( |
| 90 | - ( give_is_setting_enabled( $post_offline_customize_option, 'global' ) && give_is_setting_enabled( $global_offline_cc_fields ) ) |
|
| 91 | - || ( give_is_setting_enabled( $post_offline_customize_option, 'enabled' ) && give_is_setting_enabled( $post_offline_cc_fields ) ) |
|
| 90 | + (give_is_setting_enabled($post_offline_customize_option, 'global') && give_is_setting_enabled($global_offline_cc_fields)) |
|
| 91 | + || (give_is_setting_enabled($post_offline_customize_option, 'enabled') && give_is_setting_enabled($post_offline_cc_fields)) |
|
| 92 | 92 | ) { |
| 93 | - give_default_cc_address_fields( $form_id ); |
|
| 93 | + give_default_cc_address_fields($form_id); |
|
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | -add_action( 'give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1 ); |
|
| 97 | +add_action('give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1); |
|
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | 100 | * Process the payment |
@@ -105,14 +105,14 @@ discard block |
||
| 105 | 105 | * |
| 106 | 106 | * @return void |
| 107 | 107 | */ |
| 108 | -function give_offline_process_payment( $purchase_data ) { |
|
| 108 | +function give_offline_process_payment($purchase_data) { |
|
| 109 | 109 | |
| 110 | 110 | // Setup the payment details. |
| 111 | 111 | $payment_data = array( |
| 112 | 112 | 'price' => $purchase_data['price'], |
| 113 | 113 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
| 114 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
| 115 | - 'give_price_id' => isset( $purchase_data['post_data']['give-price-id'] ) ? $purchase_data['post_data']['give-price-id'] : '', |
|
| 114 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
| 115 | + 'give_price_id' => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '', |
|
| 116 | 116 | 'date' => $purchase_data['date'], |
| 117 | 117 | 'user_email' => $purchase_data['user_email'], |
| 118 | 118 | 'purchase_key' => $purchase_data['purchase_key'], |
@@ -124,20 +124,20 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | |
| 126 | 126 | // record the pending payment |
| 127 | - $payment = give_insert_payment( $payment_data ); |
|
| 127 | + $payment = give_insert_payment($payment_data); |
|
| 128 | 128 | |
| 129 | - if ( $payment ) { |
|
| 130 | - give_offline_send_admin_notice( $payment ); |
|
| 131 | - give_offline_send_donor_instructions( $payment ); |
|
| 129 | + if ($payment) { |
|
| 130 | + give_offline_send_admin_notice($payment); |
|
| 131 | + give_offline_send_donor_instructions($payment); |
|
| 132 | 132 | give_send_to_success_page(); |
| 133 | 133 | } else { |
| 134 | 134 | // if errors are present, send the user back to the donation form so they can be corrected |
| 135 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
| 135 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | -add_action( 'give_gateway_offline', 'give_offline_process_payment' ); |
|
| 140 | +add_action('give_gateway_offline', 'give_offline_process_payment'); |
|
| 141 | 141 | |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -150,59 +150,59 @@ discard block |
||
| 150 | 150 | * @since 1.0 |
| 151 | 151 | * @return void |
| 152 | 152 | */ |
| 153 | -function give_offline_send_donor_instructions( $payment_id = 0 ) { |
|
| 153 | +function give_offline_send_donor_instructions($payment_id = 0) { |
|
| 154 | 154 | |
| 155 | - $payment_data = give_get_payment_meta( $payment_id ); |
|
| 156 | - $post_offline_customization_option = give_get_meta( $payment_data['form_id'], '_give_customize_offline_donations', true ); |
|
| 155 | + $payment_data = give_get_payment_meta($payment_id); |
|
| 156 | + $post_offline_customization_option = give_get_meta($payment_data['form_id'], '_give_customize_offline_donations', true); |
|
| 157 | 157 | |
| 158 | 158 | //Customize email content depending on whether the single form has been customized |
| 159 | - $email_content = give_get_option( 'global_offline_donation_email' ); |
|
| 159 | + $email_content = give_get_option('global_offline_donation_email'); |
|
| 160 | 160 | |
| 161 | - if ( give_is_setting_enabled( $post_offline_customization_option, 'enabled' ) ) { |
|
| 162 | - $email_content = give_get_meta( $payment_data['form_id'], '_give_offline_donation_email', true ); |
|
| 161 | + if (give_is_setting_enabled($post_offline_customization_option, 'enabled')) { |
|
| 162 | + $email_content = give_get_meta($payment_data['form_id'], '_give_offline_donation_email', true); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
| 165 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
| 166 | 166 | |
| 167 | 167 | /** |
| 168 | 168 | * Filters the from name. |
| 169 | 169 | * |
| 170 | 170 | * @since 1.7 |
| 171 | 171 | */ |
| 172 | - $from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data ); |
|
| 172 | + $from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data); |
|
| 173 | 173 | |
| 174 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
| 174 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
| 175 | 175 | |
| 176 | 176 | /** |
| 177 | 177 | * Filters the from email. |
| 178 | 178 | * |
| 179 | 179 | * @since 1.7 |
| 180 | 180 | */ |
| 181 | - $from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data ); |
|
| 181 | + $from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data); |
|
| 182 | 182 | |
| 183 | - $to_email = give_get_payment_user_email( $payment_id ); |
|
| 183 | + $to_email = give_get_payment_user_email($payment_id); |
|
| 184 | 184 | |
| 185 | - $subject = give_get_option( 'offline_donation_subject', __( 'Offline Donation Instructions', 'give' ) ); |
|
| 186 | - if ( give_is_setting_enabled( $post_offline_customization_option, 'enabled' ) ) { |
|
| 187 | - $subject = give_get_meta( $payment_data['form_id'], '_give_offline_donation_subject', true ); |
|
| 185 | + $subject = give_get_option('offline_donation_subject', __('Offline Donation Instructions', 'give')); |
|
| 186 | + if (give_is_setting_enabled($post_offline_customization_option, 'enabled')) { |
|
| 187 | + $subject = give_get_meta($payment_data['form_id'], '_give_offline_donation_subject', true); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - $subject = apply_filters( 'give_offline_donation_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
| 191 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
| 190 | + $subject = apply_filters('give_offline_donation_subject', wp_strip_all_tags($subject), $payment_id); |
|
| 191 | + $subject = give_do_email_tags($subject, $payment_id); |
|
| 192 | 192 | |
| 193 | - $attachments = apply_filters( 'give_offline_donation_attachments', array(), $payment_id, $payment_data ); |
|
| 194 | - $message = give_do_email_tags( $email_content, $payment_id ); |
|
| 193 | + $attachments = apply_filters('give_offline_donation_attachments', array(), $payment_id, $payment_data); |
|
| 194 | + $message = give_do_email_tags($email_content, $payment_id); |
|
| 195 | 195 | |
| 196 | 196 | $emails = Give()->emails; |
| 197 | 197 | |
| 198 | - $emails->__set( 'from_name', $from_name ); |
|
| 199 | - $emails->__set( 'from_email', $from_email ); |
|
| 200 | - $emails->__set( 'heading', __( 'Offline Donation Instructions', 'give' ) ); |
|
| 198 | + $emails->__set('from_name', $from_name); |
|
| 199 | + $emails->__set('from_email', $from_email); |
|
| 200 | + $emails->__set('heading', __('Offline Donation Instructions', 'give')); |
|
| 201 | 201 | |
| 202 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data ); |
|
| 203 | - $emails->__set( 'headers', $headers ); |
|
| 202 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data); |
|
| 203 | + $emails->__set('headers', $headers); |
|
| 204 | 204 | |
| 205 | - $emails->send( $to_email, $subject, $message, $attachments ); |
|
| 205 | + $emails->send($to_email, $subject, $message, $attachments); |
|
| 206 | 206 | |
| 207 | 207 | } |
| 208 | 208 | |
@@ -219,54 +219,54 @@ discard block |
||
| 219 | 219 | * @return void |
| 220 | 220 | * |
| 221 | 221 | */ |
| 222 | -function give_offline_send_admin_notice( $payment_id = 0 ) { |
|
| 222 | +function give_offline_send_admin_notice($payment_id = 0) { |
|
| 223 | 223 | |
| 224 | 224 | /* Send an email notification to the admin */ |
| 225 | 225 | $admin_email = give_get_admin_notice_emails(); |
| 226 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
| 226 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
| 227 | 227 | |
| 228 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) { |
|
| 229 | - $user_data = get_userdata( $user_info['id'] ); |
|
| 228 | + if (isset($user_info['id']) && $user_info['id'] > 0) { |
|
| 229 | + $user_data = get_userdata($user_info['id']); |
|
| 230 | 230 | $name = $user_data->display_name; |
| 231 | - } elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) { |
|
| 232 | - $name = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
| 231 | + } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { |
|
| 232 | + $name = $user_info['first_name'].' '.$user_info['last_name']; |
|
| 233 | 233 | } else { |
| 234 | 234 | $name = $user_info['email']; |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - $amount = give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ), array( 'sanitize' => false ) ) ); |
|
| 237 | + $amount = give_currency_filter(give_format_amount(give_get_payment_amount($payment_id), array('sanitize' => false))); |
|
| 238 | 238 | |
| 239 | - $admin_subject = apply_filters( 'give_offline_admin_donation_notification_subject', __( 'New Pending Donation', 'give' ), $payment_id ); |
|
| 239 | + $admin_subject = apply_filters('give_offline_admin_donation_notification_subject', __('New Pending Donation', 'give'), $payment_id); |
|
| 240 | 240 | |
| 241 | - $admin_message = __( 'Dear Admin,', 'give' ) . "\n\n"; |
|
| 242 | - $admin_message .= sprintf(__( 'A new offline donation has been made on your website for %s.', 'give' ), $amount) . "\n\n"; |
|
| 243 | - $admin_message .= __( 'The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give' ) . "\n\n"; |
|
| 241 | + $admin_message = __('Dear Admin,', 'give')."\n\n"; |
|
| 242 | + $admin_message .= sprintf(__('A new offline donation has been made on your website for %s.', 'give'), $amount)."\n\n"; |
|
| 243 | + $admin_message .= __('The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give')."\n\n"; |
|
| 244 | 244 | |
| 245 | 245 | |
| 246 | - $admin_message .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n"; |
|
| 247 | - $admin_message .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n\n"; |
|
| 246 | + $admin_message .= '<strong>'.__('Donor:', 'give').'</strong> {fullname}'."\n"; |
|
| 247 | + $admin_message .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n\n"; |
|
| 248 | 248 | |
| 249 | 249 | $admin_message .= sprintf( |
| 250 | 250 | '<a href="%1$s">%2$s</a>', |
| 251 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment_id ), |
|
| 252 | - __( 'View Donation Details »', 'give' ) |
|
| 253 | - ) . "\n\n"; |
|
| 251 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$payment_id), |
|
| 252 | + __('View Donation Details »', 'give') |
|
| 253 | + )."\n\n"; |
|
| 254 | 254 | |
| 255 | - $admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id ); |
|
| 256 | - $admin_message = give_do_email_tags( $admin_message, $payment_id ); |
|
| 255 | + $admin_message = apply_filters('give_offline_admin_donation_notification', $admin_message, $payment_id); |
|
| 256 | + $admin_message = give_do_email_tags($admin_message, $payment_id); |
|
| 257 | 257 | |
| 258 | - $attachments = apply_filters( 'give_offline_admin_donation_notification_attachments', array(), $payment_id ); |
|
| 259 | - $admin_headers = apply_filters( 'give_offline_admin_donation_notification_headers', array(), $payment_id ); |
|
| 258 | + $attachments = apply_filters('give_offline_admin_donation_notification_attachments', array(), $payment_id); |
|
| 259 | + $admin_headers = apply_filters('give_offline_admin_donation_notification_headers', array(), $payment_id); |
|
| 260 | 260 | |
| 261 | 261 | //Send Email |
| 262 | 262 | $emails = Give()->emails; |
| 263 | - $emails->__set( 'heading', __( 'New Offline Donation', 'give' ) ); |
|
| 263 | + $emails->__set('heading', __('New Offline Donation', 'give')); |
|
| 264 | 264 | |
| 265 | - if ( ! empty( $admin_headers ) ) { |
|
| 266 | - $emails->__set( 'headers', $admin_headers ); |
|
| 265 | + if ( ! empty($admin_headers)) { |
|
| 266 | + $emails->__set('headers', $admin_headers); |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - $emails->send( $admin_email, $admin_subject, $admin_message, $attachments ); |
|
| 269 | + $emails->send($admin_email, $admin_subject, $admin_message, $attachments); |
|
| 270 | 270 | |
| 271 | 271 | } |
| 272 | 272 | |
@@ -278,20 +278,20 @@ discard block |
||
| 278 | 278 | * |
| 279 | 279 | * @return array |
| 280 | 280 | */ |
| 281 | -function give_offline_add_settings( $settings ) { |
|
| 281 | +function give_offline_add_settings($settings) { |
|
| 282 | 282 | |
| 283 | 283 | // Bailout: Do not show offline gateways setting in to metabox if its disabled globally. |
| 284 | - if ( in_array( 'offline', give_get_option( 'gateways' ) ) ) { |
|
| 284 | + if (in_array('offline', give_get_option('gateways'))) { |
|
| 285 | 285 | return $settings; |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | //Vars |
| 289 | 289 | $prefix = '_give_'; |
| 290 | 290 | |
| 291 | - $is_gateway_active = give_is_gateway_active( 'offline' ); |
|
| 291 | + $is_gateway_active = give_is_gateway_active('offline'); |
|
| 292 | 292 | |
| 293 | 293 | //this gateway isn't active |
| 294 | - if ( ! $is_gateway_active ) { |
|
| 294 | + if ( ! $is_gateway_active) { |
|
| 295 | 295 | //return settings and bounce |
| 296 | 296 | return $settings; |
| 297 | 297 | } |
@@ -300,34 +300,34 @@ discard block |
||
| 300 | 300 | $check_settings = array( |
| 301 | 301 | |
| 302 | 302 | array( |
| 303 | - 'name' => __( 'Offline Donations', 'give' ), |
|
| 304 | - 'desc' => __( 'Do you want to customize the donation instructions for this form?', 'give' ), |
|
| 305 | - 'id' => $prefix . 'customize_offline_donations', |
|
| 303 | + 'name' => __('Offline Donations', 'give'), |
|
| 304 | + 'desc' => __('Do you want to customize the donation instructions for this form?', 'give'), |
|
| 305 | + 'id' => $prefix.'customize_offline_donations', |
|
| 306 | 306 | 'type' => 'radio_inline', |
| 307 | 307 | 'default' => 'global', |
| 308 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
| 309 | - 'global' => __( 'Global Option', 'give' ), |
|
| 310 | - 'enabled' => __( 'Customize', 'give' ), |
|
| 311 | - 'disabled' => __( 'Disable', 'give' ), |
|
| 308 | + 'options' => apply_filters('give_forms_content_options_select', array( |
|
| 309 | + 'global' => __('Global Option', 'give'), |
|
| 310 | + 'enabled' => __('Customize', 'give'), |
|
| 311 | + 'disabled' => __('Disable', 'give'), |
|
| 312 | 312 | ) |
| 313 | 313 | ), |
| 314 | 314 | ), |
| 315 | 315 | array( |
| 316 | - 'name' => __( 'Billing Fields', 'give' ), |
|
| 317 | - 'desc' => __( 'This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give' ), |
|
| 318 | - 'id' => $prefix . 'offline_donation_enable_billing_fields_single', |
|
| 316 | + 'name' => __('Billing Fields', 'give'), |
|
| 317 | + 'desc' => __('This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give'), |
|
| 318 | + 'id' => $prefix.'offline_donation_enable_billing_fields_single', |
|
| 319 | 319 | 'row_classes' => 'give-subfield', |
| 320 | 320 | 'type' => 'radio_inline', |
| 321 | 321 | 'default' => 'disabled', |
| 322 | 322 | 'options' => array( |
| 323 | - 'enabled' => __( 'Enabled', 'give' ), |
|
| 324 | - 'disabled' => __( 'Disabled', 'give' ), |
|
| 323 | + 'enabled' => __('Enabled', 'give'), |
|
| 324 | + 'disabled' => __('Disabled', 'give'), |
|
| 325 | 325 | ), |
| 326 | 326 | ), |
| 327 | 327 | array( |
| 328 | - 'id' => $prefix . 'offline_checkout_notes', |
|
| 329 | - 'name' => __( 'Donation Instructions', 'give' ), |
|
| 330 | - 'desc' => __( 'Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
| 328 | + 'id' => $prefix.'offline_checkout_notes', |
|
| 329 | + 'name' => __('Donation Instructions', 'give'), |
|
| 330 | + 'desc' => __('Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
| 331 | 331 | 'default' => give_get_default_offline_donation_content(), |
| 332 | 332 | 'type' => 'wysiwyg', |
| 333 | 333 | 'row_classes' => 'give-subfield', |
@@ -336,17 +336,17 @@ discard block |
||
| 336 | 336 | ) |
| 337 | 337 | ), |
| 338 | 338 | array( |
| 339 | - 'id' => $prefix . 'offline_donation_subject', |
|
| 340 | - 'name' => __( 'Email Subject', 'give' ), |
|
| 341 | - 'desc' => __( 'Enter the subject line for the donation receipt email.', 'give' ), |
|
| 342 | - 'default' => __( '{form_title} - Offline Donation Instructions', 'give' ), |
|
| 339 | + 'id' => $prefix.'offline_donation_subject', |
|
| 340 | + 'name' => __('Email Subject', 'give'), |
|
| 341 | + 'desc' => __('Enter the subject line for the donation receipt email.', 'give'), |
|
| 342 | + 'default' => __('{form_title} - Offline Donation Instructions', 'give'), |
|
| 343 | 343 | 'row_classes' => 'give-subfield', |
| 344 | 344 | 'type' => 'text' |
| 345 | 345 | ), |
| 346 | 346 | array( |
| 347 | - 'id' => $prefix . 'offline_donation_email', |
|
| 348 | - 'name' => __( 'Email Instructions', 'give' ), |
|
| 349 | - 'desc' => __( 'Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ) . ' ' . __( 'Available template tags:', 'give' ) . give_get_emails_tags_list(), |
|
| 347 | + 'id' => $prefix.'offline_donation_email', |
|
| 348 | + 'name' => __('Email Instructions', 'give'), |
|
| 349 | + 'desc' => __('Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give').' '.__('Available template tags:', 'give').give_get_emails_tags_list(), |
|
| 350 | 350 | 'default' => give_get_default_offline_donation_email_content(), |
| 351 | 351 | 'type' => 'wysiwyg', |
| 352 | 352 | 'row_classes' => 'give-subfield', |
@@ -358,14 +358,14 @@ discard block |
||
| 358 | 358 | 'name' => 'offline_docs', |
| 359 | 359 | 'type' => 'docs_link', |
| 360 | 360 | 'url' => 'http://docs.givewp.com/settings-gateway-offline-donations', |
| 361 | - 'title' => __( 'Offline Donations', 'give' ), |
|
| 361 | + 'title' => __('Offline Donations', 'give'), |
|
| 362 | 362 | ), |
| 363 | 363 | ); |
| 364 | 364 | |
| 365 | - return array_merge( $settings, $check_settings ); |
|
| 365 | + return array_merge($settings, $check_settings); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | -add_filter( 'give_forms_offline_donations_metabox_fields', 'give_offline_add_settings' ); |
|
| 368 | +add_filter('give_forms_offline_donations_metabox_fields', 'give_offline_add_settings'); |
|
| 369 | 369 | |
| 370 | 370 | |
| 371 | 371 | /** |
@@ -377,32 +377,32 @@ discard block |
||
| 377 | 377 | */ |
| 378 | 378 | function give_get_default_offline_donation_content() { |
| 379 | 379 | |
| 380 | - $sitename = get_bloginfo( 'sitename' ); |
|
| 380 | + $sitename = get_bloginfo('sitename'); |
|
| 381 | 381 | |
| 382 | - $default_text = '<p>' . __( 'In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>'; |
|
| 382 | + $default_text = '<p>'.__('In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>'; |
|
| 383 | 383 | $default_text .= '<ol>'; |
| 384 | 384 | $default_text .= '<li>'; |
| 385 | 385 | $default_text .= sprintf( |
| 386 | 386 | /* translators: %s: site name */ |
| 387 | - __( 'Make a check payable to "%s"', 'give' ), |
|
| 387 | + __('Make a check payable to "%s"', 'give'), |
|
| 388 | 388 | $sitename |
| 389 | 389 | ); |
| 390 | 390 | $default_text .= '</li>'; |
| 391 | 391 | $default_text .= '<li>'; |
| 392 | 392 | $default_text .= sprintf( |
| 393 | 393 | /* translators: %s: site name */ |
| 394 | - __( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
| 394 | + __('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
| 395 | 395 | $sitename |
| 396 | 396 | ); |
| 397 | 397 | $default_text .= '</li>'; |
| 398 | - $default_text .= '<li>' . __( 'Please mail your check to:', 'give' ) . '</li>'; |
|
| 398 | + $default_text .= '<li>'.__('Please mail your check to:', 'give').'</li>'; |
|
| 399 | 399 | $default_text .= '</ol>'; |
| 400 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
| 400 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
| 401 | 401 | $default_text .= ' <em>111 Not A Real St.</em><br>'; |
| 402 | 402 | $default_text .= ' <em>Anytown, CA 12345 </em><br>'; |
| 403 | - $default_text .= '<p>' . __( 'All contributions will be gratefully acknowledged and are tax deductible.', 'give' ) . '</p>'; |
|
| 403 | + $default_text .= '<p>'.__('All contributions will be gratefully acknowledged and are tax deductible.', 'give').'</p>'; |
|
| 404 | 404 | |
| 405 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
| 405 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
| 406 | 406 | |
| 407 | 407 | } |
| 408 | 408 | |
@@ -415,34 +415,34 @@ discard block |
||
| 415 | 415 | */ |
| 416 | 416 | function give_get_default_offline_donation_email_content() { |
| 417 | 417 | |
| 418 | - $sitename = get_bloginfo( 'sitename' ); |
|
| 419 | - $default_text = '<p>' . __( 'Dear {name},', 'give' ) . '</p>'; |
|
| 420 | - $default_text .= '<p>' . __( 'Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give' ) . '</p>'; |
|
| 418 | + $sitename = get_bloginfo('sitename'); |
|
| 419 | + $default_text = '<p>'.__('Dear {name},', 'give').'</p>'; |
|
| 420 | + $default_text .= '<p>'.__('Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give').'</p>'; |
|
| 421 | 421 | $default_text .= '<ol>'; |
| 422 | 422 | $default_text .= '<li>'; |
| 423 | 423 | $default_text .= sprintf( |
| 424 | 424 | /* translators: %s: site name */ |
| 425 | - __( 'Make a check payable to "%s"', 'give' ), |
|
| 425 | + __('Make a check payable to "%s"', 'give'), |
|
| 426 | 426 | $sitename |
| 427 | 427 | ); |
| 428 | 428 | $default_text .= '</li>'; |
| 429 | 429 | $default_text .= '<li>'; |
| 430 | 430 | $default_text .= sprintf( |
| 431 | 431 | /* translators: %s: site name */ |
| 432 | - __( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
| 432 | + __('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
| 433 | 433 | $sitename |
| 434 | 434 | ); |
| 435 | 435 | $default_text .= '</li>'; |
| 436 | - $default_text .= '<li>' . __( 'Please mail your check to:', 'give' ) . '</li>'; |
|
| 436 | + $default_text .= '<li>'.__('Please mail your check to:', 'give').'</li>'; |
|
| 437 | 437 | $default_text .= '</ol>'; |
| 438 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
| 438 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
| 439 | 439 | $default_text .= ' <em>111 Not A Real St.</em><br>'; |
| 440 | 440 | $default_text .= ' <em>Anytown, CA 12345 </em><br>'; |
| 441 | - $default_text .= '<p>' . __( 'Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give' ) . '</p>'; |
|
| 442 | - $default_text .= '<p>' . __( 'Sincerely,', 'give' ) . '</p>'; |
|
| 443 | - $default_text .= '<p>' . $sitename . '</p>'; |
|
| 441 | + $default_text .= '<p>'.__('Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give').'</p>'; |
|
| 442 | + $default_text .= '<p>'.__('Sincerely,', 'give').'</p>'; |
|
| 443 | + $default_text .= '<p>'.$sitename.'</p>'; |
|
| 444 | 444 | |
| 445 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
| 445 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
| 446 | 446 | |
| 447 | 447 | } |
| 448 | 448 | |
@@ -456,17 +456,17 @@ discard block |
||
| 456 | 456 | * |
| 457 | 457 | * @return string |
| 458 | 458 | */ |
| 459 | -function give_offline_donation_receipt_status_notice( $notice, $id ) { |
|
| 460 | - $payment = new Give_Payment( $id ); |
|
| 459 | +function give_offline_donation_receipt_status_notice($notice, $id) { |
|
| 460 | + $payment = new Give_Payment($id); |
|
| 461 | 461 | |
| 462 | - if ( 'offline' !== $payment->gateway || $payment->is_completed() ) { |
|
| 462 | + if ('offline' !== $payment->gateway || $payment->is_completed()) { |
|
| 463 | 463 | return $notice; |
| 464 | 464 | } |
| 465 | 465 | |
| 466 | - return Give()->notices->print_frontend_notice( __( 'Payment Pending: Please follow the instructions below to complete your donation.', 'give' ), false, 'warning' ); |
|
| 466 | + return Give()->notices->print_frontend_notice(__('Payment Pending: Please follow the instructions below to complete your donation.', 'give'), false, 'warning'); |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | -add_filter( 'give_receipt_status_notice', 'give_offline_donation_receipt_status_notice', 10, 2 ); |
|
| 469 | +add_filter('give_receipt_status_notice', 'give_offline_donation_receipt_status_notice', 10, 2); |
|
| 470 | 470 | |
| 471 | 471 | /** |
| 472 | 472 | * Add offline payment instruction on payment receipt. |
@@ -477,26 +477,26 @@ discard block |
||
| 477 | 477 | * |
| 478 | 478 | * @return mixed |
| 479 | 479 | */ |
| 480 | -function give_offline_payment_receipt_after( $payment ) { |
|
| 480 | +function give_offline_payment_receipt_after($payment) { |
|
| 481 | 481 | // Get payment object. |
| 482 | - $payment = new Give_Payment( $payment->ID ); |
|
| 482 | + $payment = new Give_Payment($payment->ID); |
|
| 483 | 483 | |
| 484 | 484 | // Bailout. |
| 485 | - if ( 'offline' !== $payment->gateway ) { |
|
| 485 | + if ('offline' !== $payment->gateway) { |
|
| 486 | 486 | return false; |
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | ?> |
| 490 | 490 | <tr> |
| 491 | - <td scope="row"><strong><?php esc_html_e( 'Offline Donations Instructions', 'give' ); ?></strong></td> |
|
| 491 | + <td scope="row"><strong><?php esc_html_e('Offline Donations Instructions', 'give'); ?></strong></td> |
|
| 492 | 492 | <td> |
| 493 | - <?php echo give_get_offline_payment_instruction( $payment->form_id, true ); ?> |
|
| 493 | + <?php echo give_get_offline_payment_instruction($payment->form_id, true); ?> |
|
| 494 | 494 | </td> |
| 495 | 495 | </tr> |
| 496 | 496 | <?php |
| 497 | 497 | } |
| 498 | 498 | |
| 499 | -add_filter( 'give_payment_receipt_after', 'give_offline_payment_receipt_after' ); |
|
| 499 | +add_filter('give_payment_receipt_after', 'give_offline_payment_receipt_after'); |
|
| 500 | 500 | |
| 501 | 501 | /** |
| 502 | 502 | * Get offline payment instructions. |
@@ -508,27 +508,27 @@ discard block |
||
| 508 | 508 | * |
| 509 | 509 | * @return string |
| 510 | 510 | */ |
| 511 | -function give_get_offline_payment_instruction( $form_id, $wpautop = false ) { |
|
| 511 | +function give_get_offline_payment_instruction($form_id, $wpautop = false) { |
|
| 512 | 512 | // Bailout. |
| 513 | - if ( ! $form_id ) { |
|
| 513 | + if ( ! $form_id) { |
|
| 514 | 514 | return ''; |
| 515 | 515 | } |
| 516 | 516 | |
| 517 | - $post_offline_customization_option = give_get_meta( $form_id, '_give_customize_offline_donations', true ); |
|
| 518 | - $post_offline_instructions = give_get_meta( $form_id, '_give_offline_checkout_notes', true ); |
|
| 519 | - $global_offline_instruction = give_get_option( 'global_offline_donation_content' ); |
|
| 517 | + $post_offline_customization_option = give_get_meta($form_id, '_give_customize_offline_donations', true); |
|
| 518 | + $post_offline_instructions = give_get_meta($form_id, '_give_offline_checkout_notes', true); |
|
| 519 | + $global_offline_instruction = give_get_option('global_offline_donation_content'); |
|
| 520 | 520 | $offline_instructions = $global_offline_instruction; |
| 521 | 521 | |
| 522 | - if ( give_is_setting_enabled( $post_offline_customization_option ) ) { |
|
| 522 | + if (give_is_setting_enabled($post_offline_customization_option)) { |
|
| 523 | 523 | $offline_instructions = $post_offline_instructions; |
| 524 | 524 | } |
| 525 | 525 | |
| 526 | - $settings_url = admin_url( 'post.php?post=' . $form_id . '&action=edit&message=1' ); |
|
| 526 | + $settings_url = admin_url('post.php?post='.$form_id.'&action=edit&message=1'); |
|
| 527 | 527 | |
| 528 | 528 | /* translators: %s: form settings url */ |
| 529 | - $offline_instructions = ! empty( $offline_instructions ) ? $offline_instructions : sprintf( __( 'Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give' ), $settings_url ); |
|
| 529 | + $offline_instructions = ! empty($offline_instructions) ? $offline_instructions : sprintf(__('Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give'), $settings_url); |
|
| 530 | 530 | |
| 531 | - return ( $wpautop ? wpautop( $offline_instructions ) : $offline_instructions ); |
|
| 531 | + return ($wpautop ? wpautop($offline_instructions) : $offline_instructions); |
|
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | |
@@ -542,24 +542,24 @@ discard block |
||
| 542 | 542 | * |
| 543 | 543 | * @return array |
| 544 | 544 | */ |
| 545 | -function give_filter_offline_gateway( $gateway_list, $form_id ) { |
|
| 545 | +function give_filter_offline_gateway($gateway_list, $form_id) { |
|
| 546 | 546 | if ( |
| 547 | 547 | // Show offline payment gateway if enable for new donation form. |
| 548 | - ( false === strpos( $_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms' ) ) |
|
| 548 | + (false === strpos($_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms')) |
|
| 549 | 549 | && $form_id |
| 550 | - && ! give_is_setting_enabled( give_get_meta( $form_id, '_give_customize_offline_donations', true ), array( |
|
| 550 | + && ! give_is_setting_enabled(give_get_meta($form_id, '_give_customize_offline_donations', true), array( |
|
| 551 | 551 | 'enabled', |
| 552 | 552 | 'global', |
| 553 | - ) ) |
|
| 553 | + )) |
|
| 554 | 554 | ) { |
| 555 | - unset( $gateway_list['offline'] ); |
|
| 555 | + unset($gateway_list['offline']); |
|
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | // Output. |
| 559 | 559 | return $gateway_list; |
| 560 | 560 | } |
| 561 | 561 | |
| 562 | -add_filter( 'give_enabled_payment_gateways', 'give_filter_offline_gateway', 10, 2 ); |
|
| 562 | +add_filter('give_enabled_payment_gateways', 'give_filter_offline_gateway', 10, 2); |
|
| 563 | 563 | |
| 564 | 564 | /** |
| 565 | 565 | * Set default gateway to global default payment gateway |
@@ -573,10 +573,10 @@ discard block |
||
| 573 | 573 | * |
| 574 | 574 | * @return void |
| 575 | 575 | */ |
| 576 | -function _give_customize_offline_donations_on_save_callback( $meta_key, $meta_value, $postid ) { |
|
| 577 | - if ( ! give_is_setting_enabled( $meta_value ) && ( 'offline' === give_get_meta( $postid, '_give_default_gateway', true ) ) ) { |
|
| 578 | - give_update_meta( $postid, '_give_default_gateway', 'global' ); |
|
| 576 | +function _give_customize_offline_donations_on_save_callback($meta_key, $meta_value, $postid) { |
|
| 577 | + if ( ! give_is_setting_enabled($meta_value) && ('offline' === give_get_meta($postid, '_give_default_gateway', true))) { |
|
| 578 | + give_update_meta($postid, '_give_default_gateway', 'global'); |
|
| 579 | 579 | } |
| 580 | 580 | } |
| 581 | 581 | |
| 582 | -add_filter( 'give_save__give_customize_offline_donations', '_give_customize_offline_donations_on_save_callback', 10, 3 ); |
|
| 582 | +add_filter('give_save__give_customize_offline_donations', '_give_customize_offline_donations_on_save_callback', 10, 3); |
|
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * @since 1.0 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; |
| 14 | 14 | } |
| 15 | 15 | |
@@ -22,10 +22,10 @@ discard block |
||
| 22 | 22 | * |
| 23 | 23 | * @return bool |
| 24 | 24 | */ |
| 25 | -function give_paypal_standard_billing_fields( $form_id ) { |
|
| 25 | +function give_paypal_standard_billing_fields($form_id) { |
|
| 26 | 26 | |
| 27 | - if ( give_is_setting_enabled( give_get_option( 'paypal_standard_billing_details' ) ) ) { |
|
| 28 | - give_default_cc_address_fields( $form_id ); |
|
| 27 | + if (give_is_setting_enabled(give_get_option('paypal_standard_billing_details'))) { |
|
| 28 | + give_default_cc_address_fields($form_id); |
|
| 29 | 29 | |
| 30 | 30 | return true; |
| 31 | 31 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | -add_action( 'give_paypal_cc_form', 'give_paypal_standard_billing_fields' ); |
|
| 37 | +add_action('give_paypal_cc_form', 'give_paypal_standard_billing_fields'); |
|
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | 40 | * Process PayPal Payment. |
@@ -45,27 +45,27 @@ discard block |
||
| 45 | 45 | * |
| 46 | 46 | * @return void |
| 47 | 47 | */ |
| 48 | -function give_process_paypal_payment( $payment_data ) { |
|
| 48 | +function give_process_paypal_payment($payment_data) { |
|
| 49 | 49 | |
| 50 | 50 | // Validate nonce. |
| 51 | - give_validate_nonce( $payment_data['gateway_nonce'], 'give-gateway' ); |
|
| 52 | - $payment_id = give_create_payment( $payment_data ); |
|
| 51 | + give_validate_nonce($payment_data['gateway_nonce'], 'give-gateway'); |
|
| 52 | + $payment_id = give_create_payment($payment_data); |
|
| 53 | 53 | |
| 54 | 54 | // Check payment. |
| 55 | - if ( empty( $payment_id ) ) { |
|
| 55 | + if (empty($payment_id)) { |
|
| 56 | 56 | // Record the error. |
| 57 | - give_record_gateway_error( __( 'Payment Error', 'give' ), sprintf( /* translators: %s: payment data */ |
|
| 58 | - __( 'Payment creation failed before sending donor to PayPal. Payment data: %s', 'give' ), json_encode( $payment_data ) ), $payment_id ); |
|
| 57 | + give_record_gateway_error(__('Payment Error', 'give'), sprintf( /* translators: %s: payment data */ |
|
| 58 | + __('Payment creation failed before sending donor to PayPal. Payment data: %s', 'give'), json_encode($payment_data) ), $payment_id); |
|
| 59 | 59 | // Problems? Send back. |
| 60 | - give_send_back_to_checkout( '?payment-mode=' . $payment_data['post_data']['give-gateway'] ); |
|
| 60 | + give_send_back_to_checkout('?payment-mode='.$payment_data['post_data']['give-gateway']); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // Redirect to PayPal. |
| 64 | - wp_redirect( give_build_paypal_url( $payment_id, $payment_data ) ); |
|
| 64 | + wp_redirect(give_build_paypal_url($payment_id, $payment_data)); |
|
| 65 | 65 | exit; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | -add_action( 'give_gateway_paypal', 'give_process_paypal_payment' ); |
|
| 68 | +add_action('give_gateway_paypal', 'give_process_paypal_payment'); |
|
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | 71 | * Listens for a PayPal IPN requests and then sends to the processing function. |
@@ -75,17 +75,17 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | function give_listen_for_paypal_ipn() { |
| 77 | 77 | // Regular PayPal IPN |
| 78 | - if ( isset( $_GET['give-listener'] ) && $_GET['give-listener'] == 'IPN' ) { |
|
| 78 | + if (isset($_GET['give-listener']) && $_GET['give-listener'] == 'IPN') { |
|
| 79 | 79 | /** |
| 80 | 80 | * Fires while verifying PayPal IPN |
| 81 | 81 | * |
| 82 | 82 | * @since 1.0 |
| 83 | 83 | */ |
| 84 | - do_action( 'give_verify_paypal_ipn' ); |
|
| 84 | + do_action('give_verify_paypal_ipn'); |
|
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | -add_action( 'init', 'give_listen_for_paypal_ipn' ); |
|
| 88 | +add_action('init', 'give_listen_for_paypal_ipn'); |
|
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | 91 | * Process PayPal IPN |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | function give_process_paypal_ipn() { |
| 97 | 97 | |
| 98 | 98 | // Check the request method is POST. |
| 99 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && 'POST' !== $_SERVER['REQUEST_METHOD'] ) { |
|
| 99 | + if (isset($_SERVER['REQUEST_METHOD']) && 'POST' !== $_SERVER['REQUEST_METHOD']) { |
|
| 100 | 100 | return; |
| 101 | 101 | } |
| 102 | 102 | |
@@ -104,11 +104,11 @@ discard block |
||
| 104 | 104 | $post_data = ''; |
| 105 | 105 | |
| 106 | 106 | // Fallback just in case post_max_size is lower than needed. |
| 107 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
| 108 | - $post_data = file_get_contents( 'php://input' ); |
|
| 107 | + if (ini_get('allow_url_fopen')) { |
|
| 108 | + $post_data = file_get_contents('php://input'); |
|
| 109 | 109 | } else { |
| 110 | 110 | // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough. |
| 111 | - ini_set( 'post_max_size', '12M' ); |
|
| 111 | + ini_set('post_max_size', '12M'); |
|
| 112 | 112 | } |
| 113 | 113 | // Start the encoded data collection with notification command. |
| 114 | 114 | $encoded_data = 'cmd=_notify-validate'; |
@@ -117,39 +117,39 @@ discard block |
||
| 117 | 117 | $arg_separator = give_get_php_arg_separator_output(); |
| 118 | 118 | |
| 119 | 119 | // Verify there is a post_data. |
| 120 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
| 120 | + if ($post_data || strlen($post_data) > 0) { |
|
| 121 | 121 | // Append the data. |
| 122 | - $encoded_data .= $arg_separator . $post_data; |
|
| 122 | + $encoded_data .= $arg_separator.$post_data; |
|
| 123 | 123 | } else { |
| 124 | 124 | // Check if POST is empty. |
| 125 | - if ( empty( $_POST ) ) { |
|
| 125 | + if (empty($_POST)) { |
|
| 126 | 126 | // Nothing to do. |
| 127 | 127 | return; |
| 128 | 128 | } else { |
| 129 | 129 | // Loop through each POST. |
| 130 | - foreach ( $_POST as $key => $value ) { |
|
| 130 | + foreach ($_POST as $key => $value) { |
|
| 131 | 131 | // Encode the value and append the data. |
| 132 | - $encoded_data .= $arg_separator . "$key=" . urlencode( $value ); |
|
| 132 | + $encoded_data .= $arg_separator."$key=".urlencode($value); |
|
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | // Convert collected post data to an array. |
| 138 | - parse_str( $encoded_data, $encoded_data_array ); |
|
| 138 | + parse_str($encoded_data, $encoded_data_array); |
|
| 139 | 139 | |
| 140 | - foreach ( $encoded_data_array as $key => $value ) { |
|
| 140 | + foreach ($encoded_data_array as $key => $value) { |
|
| 141 | 141 | |
| 142 | - if ( false !== strpos( $key, 'amp;' ) ) { |
|
| 143 | - $new_key = str_replace( '&', '&', $key ); |
|
| 144 | - $new_key = str_replace( 'amp;', '&', $new_key ); |
|
| 142 | + if (false !== strpos($key, 'amp;')) { |
|
| 143 | + $new_key = str_replace('&', '&', $key); |
|
| 144 | + $new_key = str_replace('amp;', '&', $new_key); |
|
| 145 | 145 | |
| 146 | - unset( $encoded_data_array[ $key ] ); |
|
| 147 | - $encoded_data_array[ $new_key ] = $value; |
|
| 146 | + unset($encoded_data_array[$key]); |
|
| 147 | + $encoded_data_array[$new_key] = $value; |
|
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | // Validate IPN request w/ PayPal if user hasn't disabled this security measure. |
| 152 | - if ( give_is_setting_enabled( give_get_option( 'paypal_verification' ) ) ) { |
|
| 152 | + if (give_is_setting_enabled(give_get_option('paypal_verification'))) { |
|
| 153 | 153 | |
| 154 | 154 | $remote_post_vars = array( |
| 155 | 155 | 'method' => 'POST', |
@@ -169,25 +169,25 @@ discard block |
||
| 169 | 169 | ); |
| 170 | 170 | |
| 171 | 171 | // Validate the IPN. |
| 172 | - $api_response = wp_remote_post( give_get_paypal_redirect(), $remote_post_vars ); |
|
| 172 | + $api_response = wp_remote_post(give_get_paypal_redirect(), $remote_post_vars); |
|
| 173 | 173 | |
| 174 | - if ( is_wp_error( $api_response ) ) { |
|
| 175 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
| 176 | - __( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) ); |
|
| 174 | + if (is_wp_error($api_response)) { |
|
| 175 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
| 176 | + __('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response) )); |
|
| 177 | 177 | |
| 178 | 178 | return; // Something went wrong |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - if ( 'VERIFIED' !== $api_response['body'] ) { |
|
| 182 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
| 183 | - __( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) ); |
|
| 181 | + if ('VERIFIED' !== $api_response['body']) { |
|
| 182 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
| 183 | + __('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response) )); |
|
| 184 | 184 | |
| 185 | 185 | return; // Response not okay. |
| 186 | 186 | } |
| 187 | 187 | }// End if(). |
| 188 | 188 | |
| 189 | 189 | // Check if $post_data_array has been populated. |
| 190 | - if ( ! is_array( $encoded_data_array ) && ! empty( $encoded_data_array ) ) { |
|
| 190 | + if ( ! is_array($encoded_data_array) && ! empty($encoded_data_array)) { |
|
| 191 | 191 | return; |
| 192 | 192 | } |
| 193 | 193 | |
@@ -196,28 +196,28 @@ discard block |
||
| 196 | 196 | 'payment_status' => '', |
| 197 | 197 | ); |
| 198 | 198 | |
| 199 | - $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
| 199 | + $encoded_data_array = wp_parse_args($encoded_data_array, $defaults); |
|
| 200 | 200 | |
| 201 | - $payment_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
| 201 | + $payment_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0; |
|
| 202 | 202 | $txn_type = $encoded_data_array['txn_type']; |
| 203 | 203 | |
| 204 | 204 | // Check for PayPal IPN Notifications and update data based on it. |
| 205 | - $current_timestamp = current_time( 'timestamp' ); |
|
| 205 | + $current_timestamp = current_time('timestamp'); |
|
| 206 | 206 | $paypal_ipn_vars = array( |
| 207 | - 'auth_status' => ( $api_response['body'] ) ? $api_response['body'] : 'N/A', |
|
| 207 | + 'auth_status' => ($api_response['body']) ? $api_response['body'] : 'N/A', |
|
| 208 | 208 | 'transaction_id' => $encoded_data_array['txn_id'], |
| 209 | 209 | 'payment_id' => $payment_id, |
| 210 | 210 | ); |
| 211 | - update_option( 'give_last_paypal_ipn_received', $paypal_ipn_vars ); |
|
| 212 | - give_insert_payment_note( $payment_id, sprintf( |
|
| 213 | - __( 'Last IPN received on %s at %s', 'give' ), |
|
| 214 | - date_i18n( 'm/d/Y', $current_timestamp ), |
|
| 215 | - date_i18n( 'H:i', $current_timestamp ) |
|
| 211 | + update_option('give_last_paypal_ipn_received', $paypal_ipn_vars); |
|
| 212 | + give_insert_payment_note($payment_id, sprintf( |
|
| 213 | + __('Last IPN received on %s at %s', 'give'), |
|
| 214 | + date_i18n('m/d/Y', $current_timestamp), |
|
| 215 | + date_i18n('H:i', $current_timestamp) |
|
| 216 | 216 | ) |
| 217 | 217 | ); |
| 218 | - give_update_meta( $payment_id, 'give_last_paypal_ipn_received', $current_timestamp ); |
|
| 218 | + give_update_meta($payment_id, 'give_last_paypal_ipn_received', $current_timestamp); |
|
| 219 | 219 | |
| 220 | - if ( has_action( 'give_paypal_' . $txn_type ) ) { |
|
| 220 | + if (has_action('give_paypal_'.$txn_type)) { |
|
| 221 | 221 | /** |
| 222 | 222 | * Fires while processing PayPal IPN $txn_type. |
| 223 | 223 | * |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | * @param array $encoded_data_array Encoded data. |
| 229 | 229 | * @param int $payment_id Payment id. |
| 230 | 230 | */ |
| 231 | - do_action( "give_paypal_{$txn_type}", $encoded_data_array, $payment_id ); |
|
| 231 | + do_action("give_paypal_{$txn_type}", $encoded_data_array, $payment_id); |
|
| 232 | 232 | } else { |
| 233 | 233 | /** |
| 234 | 234 | * Fires while process PayPal IPN. |
@@ -240,12 +240,12 @@ discard block |
||
| 240 | 240 | * @param array $encoded_data_array Encoded data. |
| 241 | 241 | * @param int $payment_id Payment id. |
| 242 | 242 | */ |
| 243 | - do_action( 'give_paypal_web_accept', $encoded_data_array, $payment_id ); |
|
| 243 | + do_action('give_paypal_web_accept', $encoded_data_array, $payment_id); |
|
| 244 | 244 | } |
| 245 | 245 | exit; |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | -add_action( 'give_verify_paypal_ipn', 'give_process_paypal_ipn' ); |
|
| 248 | +add_action('give_verify_paypal_ipn', 'give_process_paypal_ipn'); |
|
| 249 | 249 | |
| 250 | 250 | /** |
| 251 | 251 | * Process web accept (one time) payment IPNs. |
@@ -257,99 +257,99 @@ discard block |
||
| 257 | 257 | * |
| 258 | 258 | * @return void |
| 259 | 259 | */ |
| 260 | -function give_process_paypal_web_accept( $data, $payment_id ) { |
|
| 260 | +function give_process_paypal_web_accept($data, $payment_id) { |
|
| 261 | 261 | |
| 262 | 262 | // Only allow through these transaction types. |
| 263 | - if ( 'web_accept' !== $data['txn_type'] && 'cart' !== $data['txn_type'] && 'refunded' !== strtolower( $data['payment_status'] ) ) { |
|
| 263 | + if ('web_accept' !== $data['txn_type'] && 'cart' !== $data['txn_type'] && 'refunded' !== strtolower($data['payment_status'])) { |
|
| 264 | 264 | return; |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | // Need $payment_id to continue. |
| 268 | - if ( empty( $payment_id ) ) { |
|
| 268 | + if (empty($payment_id)) { |
|
| 269 | 269 | return; |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | // Collect donation payment details. |
| 273 | 273 | $paypal_amount = $data['mc_gross']; |
| 274 | - $payment_status = strtolower( $data['payment_status'] ); |
|
| 275 | - $currency_code = strtolower( $data['mc_currency'] ); |
|
| 276 | - $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] ); |
|
| 277 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
| 274 | + $payment_status = strtolower($data['payment_status']); |
|
| 275 | + $currency_code = strtolower($data['mc_currency']); |
|
| 276 | + $business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']); |
|
| 277 | + $payment_meta = give_get_payment_meta($payment_id); |
|
| 278 | 278 | |
| 279 | 279 | // Must be a PayPal standard IPN. |
| 280 | - if ( 'paypal' !== give_get_payment_gateway( $payment_id ) ) { |
|
| 280 | + if ('paypal' !== give_get_payment_gateway($payment_id)) { |
|
| 281 | 281 | return; |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | // Verify payment recipient |
| 285 | - if ( strcasecmp( $business_email, trim( give_get_option( 'paypal_email' ) ) ) !== 0 ) { |
|
| 285 | + if (strcasecmp($business_email, trim(give_get_option('paypal_email'))) !== 0) { |
|
| 286 | 286 | |
| 287 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
| 288 | - __( 'Invalid business email in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
| 289 | - give_update_payment_status( $payment_id, 'failed' ); |
|
| 290 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid PayPal business email.', 'give' ) ); |
|
| 287 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
| 288 | + __('Invalid business email in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
| 289 | + give_update_payment_status($payment_id, 'failed'); |
|
| 290 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid PayPal business email.', 'give')); |
|
| 291 | 291 | |
| 292 | 292 | return; |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | // Verify payment currency. |
| 296 | - if ( $currency_code !== strtolower( $payment_meta['currency'] ) ) { |
|
| 296 | + if ($currency_code !== strtolower($payment_meta['currency'])) { |
|
| 297 | 297 | |
| 298 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
| 299 | - __( 'Invalid currency in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
| 300 | - give_update_payment_status( $payment_id, 'failed' ); |
|
| 301 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'give' ) ); |
|
| 298 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
| 299 | + __('Invalid currency in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
| 300 | + give_update_payment_status($payment_id, 'failed'); |
|
| 301 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid currency in PayPal IPN.', 'give')); |
|
| 302 | 302 | |
| 303 | 303 | return; |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | // Process refunds & reversed. |
| 307 | - if ( 'refunded' === $payment_status || 'reversed' === $payment_status ) { |
|
| 308 | - give_process_paypal_refund( $data, $payment_id ); |
|
| 307 | + if ('refunded' === $payment_status || 'reversed' === $payment_status) { |
|
| 308 | + give_process_paypal_refund($data, $payment_id); |
|
| 309 | 309 | |
| 310 | 310 | return; |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | // Only complete payments once. |
| 314 | - if ( 'publish' === get_post_status( $payment_id ) ) { |
|
| 314 | + if ('publish' === get_post_status($payment_id)) { |
|
| 315 | 315 | return; |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | // Retrieve the total donation amount (before PayPal). |
| 319 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
| 319 | + $payment_amount = give_get_payment_amount($payment_id); |
|
| 320 | 320 | |
| 321 | 321 | // Check that the donation PP and local db amounts match. |
| 322 | - if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
| 322 | + if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
| 323 | 323 | // The prices don't match |
| 324 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
| 325 | - __( 'Invalid payment amount in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
| 326 | - give_update_payment_status( $payment_id, 'failed' ); |
|
| 327 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'give' ) ); |
|
| 324 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
| 325 | + __('Invalid payment amount in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
| 326 | + give_update_payment_status($payment_id, 'failed'); |
|
| 327 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid amount in PayPal IPN.', 'give')); |
|
| 328 | 328 | |
| 329 | 329 | return; |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | // Process completed donations. |
| 333 | - if ( 'completed' === $payment_status || give_is_test_mode() ) { |
|
| 333 | + if ('completed' === $payment_status || give_is_test_mode()) { |
|
| 334 | 334 | |
| 335 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
| 336 | - __( 'PayPal Transaction ID: %s', 'give' ), $data['txn_id'] ) ); |
|
| 337 | - give_set_payment_transaction_id( $payment_id, $data['txn_id'] ); |
|
| 338 | - give_update_payment_status( $payment_id, 'publish' ); |
|
| 335 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
| 336 | + __('PayPal Transaction ID: %s', 'give'), $data['txn_id'] )); |
|
| 337 | + give_set_payment_transaction_id($payment_id, $data['txn_id']); |
|
| 338 | + give_update_payment_status($payment_id, 'publish'); |
|
| 339 | 339 | |
| 340 | - } elseif ( 'pending' === $payment_status && isset( $data['pending_reason'] ) ) { |
|
| 340 | + } elseif ('pending' === $payment_status && isset($data['pending_reason'])) { |
|
| 341 | 341 | |
| 342 | 342 | // Look for possible pending reasons, such as an echeck. |
| 343 | - $note = give_paypal_get_pending_donation_note( strtolower( $data['pending_reason'] ) ); |
|
| 343 | + $note = give_paypal_get_pending_donation_note(strtolower($data['pending_reason'])); |
|
| 344 | 344 | |
| 345 | - if ( ! empty( $note ) ) { |
|
| 346 | - give_insert_payment_note( $payment_id, $note ); |
|
| 345 | + if ( ! empty($note)) { |
|
| 346 | + give_insert_payment_note($payment_id, $note); |
|
| 347 | 347 | } |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | -add_action( 'give_paypal_web_accept', 'give_process_paypal_web_accept', 10, 2 ); |
|
| 352 | +add_action('give_paypal_web_accept', 'give_process_paypal_web_accept', 10, 2); |
|
| 353 | 353 | |
| 354 | 354 | /** |
| 355 | 355 | * Process PayPal IPN Refunds |
@@ -361,35 +361,35 @@ discard block |
||
| 361 | 361 | * |
| 362 | 362 | * @return void |
| 363 | 363 | */ |
| 364 | -function give_process_paypal_refund( $data, $payment_id = 0 ) { |
|
| 364 | +function give_process_paypal_refund($data, $payment_id = 0) { |
|
| 365 | 365 | |
| 366 | 366 | // Collect payment details. |
| 367 | - if ( empty( $payment_id ) ) { |
|
| 367 | + if (empty($payment_id)) { |
|
| 368 | 368 | return; |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | // Only refund payments once. |
| 372 | - if ( 'refunded' === get_post_status( $payment_id ) ) { |
|
| 372 | + if ('refunded' === get_post_status($payment_id)) { |
|
| 373 | 373 | return; |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
| 376 | + $payment_amount = give_get_payment_amount($payment_id); |
|
| 377 | 377 | $refund_amount = $data['payment_gross'] * - 1; |
| 378 | 378 | |
| 379 | - if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
| 379 | + if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
| 380 | 380 | |
| 381 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal parent transaction ID */ |
|
| 382 | - __( 'Partial PayPal refund processed: %s', 'give' ), $data['parent_txn_id'] ) ); |
|
| 381 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal parent transaction ID */ |
|
| 382 | + __('Partial PayPal refund processed: %s', 'give'), $data['parent_txn_id'] )); |
|
| 383 | 383 | |
| 384 | 384 | return; // This is a partial refund |
| 385 | 385 | |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | - give_insert_payment_note( $payment_id, sprintf( /* translators: 1: Paypal parent transaction ID 2. Paypal reason code */ |
|
| 389 | - __( 'PayPal Payment #%1$s Refunded for reason: %2$s', 'give' ), $data['parent_txn_id'], $data['reason_code'] ) ); |
|
| 390 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
| 391 | - __( 'PayPal Refund Transaction ID: %s', 'give' ), $data['txn_id'] ) ); |
|
| 392 | - give_update_payment_status( $payment_id, 'refunded' ); |
|
| 388 | + give_insert_payment_note($payment_id, sprintf( /* translators: 1: Paypal parent transaction ID 2. Paypal reason code */ |
|
| 389 | + __('PayPal Payment #%1$s Refunded for reason: %2$s', 'give'), $data['parent_txn_id'], $data['reason_code'] )); |
|
| 390 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
| 391 | + __('PayPal Refund Transaction ID: %s', 'give'), $data['txn_id'] )); |
|
| 392 | + give_update_payment_status($payment_id, 'refunded'); |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | /** |
@@ -401,24 +401,24 @@ discard block |
||
| 401 | 401 | * |
| 402 | 402 | * @return string |
| 403 | 403 | */ |
| 404 | -function give_get_paypal_redirect( $ssl_check = false ) { |
|
| 404 | +function give_get_paypal_redirect($ssl_check = false) { |
|
| 405 | 405 | |
| 406 | - if ( is_ssl() || ! $ssl_check ) { |
|
| 406 | + if (is_ssl() || ! $ssl_check) { |
|
| 407 | 407 | $protocol = 'https://'; |
| 408 | 408 | } else { |
| 409 | 409 | $protocol = 'http://'; |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | // Check the current payment mode |
| 413 | - if ( give_is_test_mode() ) { |
|
| 413 | + if (give_is_test_mode()) { |
|
| 414 | 414 | // Test mode |
| 415 | - $paypal_uri = $protocol . 'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
| 415 | + $paypal_uri = $protocol.'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
| 416 | 416 | } else { |
| 417 | 417 | // Live mode |
| 418 | - $paypal_uri = $protocol . 'www.paypal.com/cgi-bin/webscr'; |
|
| 418 | + $paypal_uri = $protocol.'www.paypal.com/cgi-bin/webscr'; |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | - return apply_filters( 'give_paypal_uri', $paypal_uri ); |
|
| 421 | + return apply_filters('give_paypal_uri', $paypal_uri); |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | /** |
@@ -428,9 +428,9 @@ discard block |
||
| 428 | 428 | * @return string |
| 429 | 429 | */ |
| 430 | 430 | function give_get_paypal_page_style() { |
| 431 | - $page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) ); |
|
| 431 | + $page_style = trim(give_get_option('paypal_page_style', 'PayPal')); |
|
| 432 | 432 | |
| 433 | - return apply_filters( 'give_paypal_page_style', $page_style ); |
|
| 433 | + return apply_filters('give_paypal_page_style', $page_style); |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | /** |
@@ -444,26 +444,26 @@ discard block |
||
| 444 | 444 | * |
| 445 | 445 | * @return string |
| 446 | 446 | */ |
| 447 | -function give_paypal_success_page_content( $content ) { |
|
| 447 | +function give_paypal_success_page_content($content) { |
|
| 448 | 448 | |
| 449 | - if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) { |
|
| 449 | + if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) { |
|
| 450 | 450 | return $content; |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | - $payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false; |
|
| 453 | + $payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false; |
|
| 454 | 454 | |
| 455 | - if ( ! $payment_id ) { |
|
| 455 | + if ( ! $payment_id) { |
|
| 456 | 456 | $session = give_get_purchase_session(); |
| 457 | - $payment_id = give_get_purchase_id_by_key( $session['purchase_key'] ); |
|
| 457 | + $payment_id = give_get_purchase_id_by_key($session['purchase_key']); |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | - $payment = get_post( $payment_id ); |
|
| 461 | - if ( $payment && 'pending' === $payment->post_status ) { |
|
| 460 | + $payment = get_post($payment_id); |
|
| 461 | + if ($payment && 'pending' === $payment->post_status) { |
|
| 462 | 462 | |
| 463 | 463 | // Payment is still pending so show processing indicator to fix the race condition. |
| 464 | 464 | ob_start(); |
| 465 | 465 | |
| 466 | - give_get_template_part( 'payment', 'processing' ); |
|
| 466 | + give_get_template_part('payment', 'processing'); |
|
| 467 | 467 | |
| 468 | 468 | $content = ob_get_clean(); |
| 469 | 469 | |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | -add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' ); |
|
| 476 | +add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content'); |
|
| 477 | 477 | |
| 478 | 478 | /** |
| 479 | 479 | * Given a Payment ID, extract the transaction ID |
@@ -484,22 +484,22 @@ discard block |
||
| 484 | 484 | * |
| 485 | 485 | * @return string Transaction ID |
| 486 | 486 | */ |
| 487 | -function give_paypal_get_payment_transaction_id( $payment_id ) { |
|
| 487 | +function give_paypal_get_payment_transaction_id($payment_id) { |
|
| 488 | 488 | |
| 489 | 489 | $transaction_id = ''; |
| 490 | - $notes = give_get_payment_notes( $payment_id ); |
|
| 490 | + $notes = give_get_payment_notes($payment_id); |
|
| 491 | 491 | |
| 492 | - foreach ( $notes as $note ) { |
|
| 493 | - if ( preg_match( '/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match ) ) { |
|
| 492 | + foreach ($notes as $note) { |
|
| 493 | + if (preg_match('/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match)) { |
|
| 494 | 494 | $transaction_id = $match[1]; |
| 495 | 495 | continue; |
| 496 | 496 | } |
| 497 | 497 | } |
| 498 | 498 | |
| 499 | - return apply_filters( 'give_paypal_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
| 499 | + return apply_filters('give_paypal_set_payment_transaction_id', $transaction_id, $payment_id); |
|
| 500 | 500 | } |
| 501 | 501 | |
| 502 | -add_filter( 'give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1 ); |
|
| 502 | +add_filter('give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1); |
|
| 503 | 503 | |
| 504 | 504 | /** |
| 505 | 505 | * Given a transaction ID, generate a link to the PayPal transaction ID details |
@@ -511,16 +511,16 @@ discard block |
||
| 511 | 511 | * |
| 512 | 512 | * @return string A link to the PayPal transaction details |
| 513 | 513 | */ |
| 514 | -function give_paypal_link_transaction_id( $transaction_id, $payment_id ) { |
|
| 514 | +function give_paypal_link_transaction_id($transaction_id, $payment_id) { |
|
| 515 | 515 | |
| 516 | 516 | $paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id='; |
| 517 | - $transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>'; |
|
| 517 | + $transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>'; |
|
| 518 | 518 | |
| 519 | - return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url ); |
|
| 519 | + return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url); |
|
| 520 | 520 | |
| 521 | 521 | } |
| 522 | 522 | |
| 523 | -add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 ); |
|
| 523 | +add_filter('give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2); |
|
| 524 | 524 | |
| 525 | 525 | |
| 526 | 526 | /** |
@@ -532,64 +532,64 @@ discard block |
||
| 532 | 532 | * |
| 533 | 533 | * @return string |
| 534 | 534 | */ |
| 535 | -function give_paypal_get_pending_donation_note( $pending_reason ) { |
|
| 535 | +function give_paypal_get_pending_donation_note($pending_reason) { |
|
| 536 | 536 | |
| 537 | 537 | $note = ''; |
| 538 | 538 | |
| 539 | - switch ( $pending_reason ) { |
|
| 539 | + switch ($pending_reason) { |
|
| 540 | 540 | |
| 541 | 541 | case 'echeck' : |
| 542 | 542 | |
| 543 | - $note = __( 'Payment made via eCheck and will clear automatically in 5-8 days.', 'give' ); |
|
| 543 | + $note = __('Payment made via eCheck and will clear automatically in 5-8 days.', 'give'); |
|
| 544 | 544 | |
| 545 | 545 | break; |
| 546 | 546 | |
| 547 | 547 | case 'address' : |
| 548 | 548 | |
| 549 | - $note = __( 'Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give' ); |
|
| 549 | + $note = __('Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give'); |
|
| 550 | 550 | |
| 551 | 551 | break; |
| 552 | 552 | |
| 553 | 553 | case 'intl' : |
| 554 | 554 | |
| 555 | - $note = __( 'Payment must be accepted manually through PayPal due to international account regulations.', 'give' ); |
|
| 555 | + $note = __('Payment must be accepted manually through PayPal due to international account regulations.', 'give'); |
|
| 556 | 556 | |
| 557 | 557 | break; |
| 558 | 558 | |
| 559 | 559 | case 'multi-currency' : |
| 560 | 560 | |
| 561 | - $note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal.', 'give' ); |
|
| 561 | + $note = __('Payment received in non-shop currency and must be accepted manually through PayPal.', 'give'); |
|
| 562 | 562 | |
| 563 | 563 | break; |
| 564 | 564 | |
| 565 | 565 | case 'paymentreview' : |
| 566 | 566 | case 'regulatory_review' : |
| 567 | 567 | |
| 568 | - $note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give' ); |
|
| 568 | + $note = __('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give'); |
|
| 569 | 569 | |
| 570 | 570 | break; |
| 571 | 571 | |
| 572 | 572 | case 'unilateral' : |
| 573 | 573 | |
| 574 | - $note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'give' ); |
|
| 574 | + $note = __('Payment was sent to non-confirmed or non-registered email address.', 'give'); |
|
| 575 | 575 | |
| 576 | 576 | break; |
| 577 | 577 | |
| 578 | 578 | case 'upgrade' : |
| 579 | 579 | |
| 580 | - $note = __( 'PayPal account must be upgraded before this payment can be accepted.', 'give' ); |
|
| 580 | + $note = __('PayPal account must be upgraded before this payment can be accepted.', 'give'); |
|
| 581 | 581 | |
| 582 | 582 | break; |
| 583 | 583 | |
| 584 | 584 | case 'verify' : |
| 585 | 585 | |
| 586 | - $note = __( 'PayPal account is not verified. Verify account in order to accept this donation.', 'give' ); |
|
| 586 | + $note = __('PayPal account is not verified. Verify account in order to accept this donation.', 'give'); |
|
| 587 | 587 | |
| 588 | 588 | break; |
| 589 | 589 | |
| 590 | 590 | case 'other' : |
| 591 | 591 | |
| 592 | - $note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give' ); |
|
| 592 | + $note = __('Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give'); |
|
| 593 | 593 | |
| 594 | 594 | break; |
| 595 | 595 | |
@@ -607,49 +607,49 @@ discard block |
||
| 607 | 607 | * |
| 608 | 608 | * @return mixed|string |
| 609 | 609 | */ |
| 610 | -function give_build_paypal_url( $payment_id, $payment_data ) { |
|
| 610 | +function give_build_paypal_url($payment_id, $payment_data) { |
|
| 611 | 611 | // Only send to PayPal if the pending payment is created successfully. |
| 612 | - $listener_url = add_query_arg( 'give-listener', 'IPN', home_url( 'index.php' ) ); |
|
| 612 | + $listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php')); |
|
| 613 | 613 | |
| 614 | 614 | // Get the success url. |
| 615 | - $return_url = add_query_arg( array( |
|
| 615 | + $return_url = add_query_arg(array( |
|
| 616 | 616 | 'payment-confirmation' => 'paypal', |
| 617 | 617 | 'payment-id' => $payment_id, |
| 618 | 618 | |
| 619 | - ), get_permalink( give_get_option( 'success_page' ) ) ); |
|
| 619 | + ), get_permalink(give_get_option('success_page'))); |
|
| 620 | 620 | |
| 621 | 621 | // Get the PayPal redirect uri. |
| 622 | - $paypal_redirect = trailingslashit( give_get_paypal_redirect() ) . '?'; |
|
| 622 | + $paypal_redirect = trailingslashit(give_get_paypal_redirect()).'?'; |
|
| 623 | 623 | |
| 624 | 624 | // Item name. |
| 625 | - $item_name = give_build_paypal_item_title( $payment_data ); |
|
| 625 | + $item_name = give_build_paypal_item_title($payment_data); |
|
| 626 | 626 | |
| 627 | 627 | // Setup PayPal API params. |
| 628 | 628 | $paypal_args = array( |
| 629 | - 'business' => give_get_option( 'paypal_email', false ), |
|
| 629 | + 'business' => give_get_option('paypal_email', false), |
|
| 630 | 630 | 'first_name' => $payment_data['user_info']['first_name'], |
| 631 | 631 | 'last_name' => $payment_data['user_info']['last_name'], |
| 632 | 632 | 'email' => $payment_data['user_email'], |
| 633 | 633 | 'invoice' => $payment_data['purchase_key'], |
| 634 | 634 | 'amount' => $payment_data['price'], |
| 635 | - 'item_name' => stripslashes( $item_name ), |
|
| 635 | + 'item_name' => stripslashes($item_name), |
|
| 636 | 636 | 'no_shipping' => '1', |
| 637 | 637 | 'shipping' => '0', |
| 638 | 638 | 'no_note' => '1', |
| 639 | 639 | 'currency_code' => give_get_currency(), |
| 640 | - 'charset' => get_bloginfo( 'charset' ), |
|
| 640 | + 'charset' => get_bloginfo('charset'), |
|
| 641 | 641 | 'custom' => $payment_id, |
| 642 | 642 | 'rm' => '2', |
| 643 | 643 | 'return' => $return_url, |
| 644 | - 'cancel_return' => give_get_failed_transaction_uri( '?payment-id=' . $payment_id ), |
|
| 644 | + 'cancel_return' => give_get_failed_transaction_uri('?payment-id='.$payment_id), |
|
| 645 | 645 | 'notify_url' => $listener_url, |
| 646 | 646 | 'page_style' => give_get_paypal_page_style(), |
| 647 | - 'cbt' => get_bloginfo( 'name' ), |
|
| 647 | + 'cbt' => get_bloginfo('name'), |
|
| 648 | 648 | 'bn' => 'givewp_SP', |
| 649 | 649 | ); |
| 650 | 650 | |
| 651 | 651 | // Add user address if present. |
| 652 | - if ( ! empty( $payment_data['user_info']['address'] ) ) { |
|
| 652 | + if ( ! empty($payment_data['user_info']['address'])) { |
|
| 653 | 653 | $default_address = array( |
| 654 | 654 | 'line1' => '', |
| 655 | 655 | 'line2' => '', |
@@ -659,7 +659,7 @@ discard block |
||
| 659 | 659 | 'country' => '', |
| 660 | 660 | ); |
| 661 | 661 | |
| 662 | - $address = wp_parse_args( $payment_data['user_info']['address'], $default_address ); |
|
| 662 | + $address = wp_parse_args($payment_data['user_info']['address'], $default_address); |
|
| 663 | 663 | |
| 664 | 664 | $paypal_args['address1'] = $address['line1']; |
| 665 | 665 | $paypal_args['address2'] = $address['line2']; |
@@ -680,13 +680,13 @@ discard block |
||
| 680 | 680 | * @param array $paypal_args |
| 681 | 681 | * @param array $payment_data |
| 682 | 682 | */ |
| 683 | - $paypal_args = apply_filters( 'give_paypal_redirect_args', $paypal_args, $payment_data ); |
|
| 683 | + $paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $payment_data); |
|
| 684 | 684 | |
| 685 | 685 | // Build query. |
| 686 | - $paypal_redirect .= http_build_query( $paypal_args ); |
|
| 686 | + $paypal_redirect .= http_build_query($paypal_args); |
|
| 687 | 687 | |
| 688 | 688 | // Fix for some sites that encode the entities. |
| 689 | - $paypal_redirect = str_replace( '&', '&', $paypal_redirect ); |
|
| 689 | + $paypal_redirect = str_replace('&', '&', $paypal_redirect); |
|
| 690 | 690 | |
| 691 | 691 | return $paypal_redirect; |
| 692 | 692 | } |
@@ -701,7 +701,7 @@ discard block |
||
| 701 | 701 | function give_get_paypal_button_type() { |
| 702 | 702 | // paypal_button_type can be donation or standard. |
| 703 | 703 | $paypal_button_type = '_donations'; |
| 704 | - if ( 'standard' === give_get_option( 'paypal_button_type' ) ) { |
|
| 704 | + if ('standard' === give_get_option('paypal_button_type')) { |
|
| 705 | 705 | $paypal_button_type = '_xclick'; |
| 706 | 706 | } |
| 707 | 707 | |
@@ -718,30 +718,30 @@ discard block |
||
| 718 | 718 | * |
| 719 | 719 | * @return string |
| 720 | 720 | */ |
| 721 | -function give_build_paypal_item_title( $payment_data ) { |
|
| 722 | - $form_id = intval( $payment_data['post_data']['give-form-id'] ); |
|
| 721 | +function give_build_paypal_item_title($payment_data) { |
|
| 722 | + $form_id = intval($payment_data['post_data']['give-form-id']); |
|
| 723 | 723 | $item_name = $payment_data['post_data']['give-form-title']; |
| 724 | 724 | |
| 725 | 725 | // Verify has variable prices. |
| 726 | - if ( give_has_variable_prices( $form_id ) && isset( $payment_data['post_data']['give-price-id'] ) ) { |
|
| 726 | + if (give_has_variable_prices($form_id) && isset($payment_data['post_data']['give-price-id'])) { |
|
| 727 | 727 | |
| 728 | - $item_price_level_text = give_get_price_option_name( $form_id, $payment_data['post_data']['give-price-id'] ); |
|
| 729 | - $price_level_amount = give_get_price_option_amount( $form_id, $payment_data['post_data']['give-price-id'] ); |
|
| 728 | + $item_price_level_text = give_get_price_option_name($form_id, $payment_data['post_data']['give-price-id']); |
|
| 729 | + $price_level_amount = give_get_price_option_amount($form_id, $payment_data['post_data']['give-price-id']); |
|
| 730 | 730 | |
| 731 | 731 | // Donation given doesn't match selected level (must be a custom amount). |
| 732 | - if ( $price_level_amount != give_maybe_sanitize_amount( $payment_data['price'] ) ) { |
|
| 733 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
| 732 | + if ($price_level_amount != give_maybe_sanitize_amount($payment_data['price'])) { |
|
| 733 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
| 734 | 734 | // user custom amount text if any, fallback to default if not. |
| 735 | - $item_name .= ' - ' . give_check_variable( $custom_amount_text, 'empty', __( 'Custom Amount', 'give' ) ); |
|
| 735 | + $item_name .= ' - '.give_check_variable($custom_amount_text, 'empty', __('Custom Amount', 'give')); |
|
| 736 | 736 | |
| 737 | - } elseif ( ! empty( $item_price_level_text ) ) { |
|
| 738 | - $item_name .= ' - ' . $item_price_level_text; |
|
| 737 | + } elseif ( ! empty($item_price_level_text)) { |
|
| 738 | + $item_name .= ' - '.$item_price_level_text; |
|
| 739 | 739 | } |
| 740 | 740 | } // End if(). |
| 741 | - elseif ( give_get_form_price( $form_id ) !== give_maybe_sanitize_amount( $payment_data['price'] ) ) { |
|
| 742 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
| 741 | + elseif (give_get_form_price($form_id) !== give_maybe_sanitize_amount($payment_data['price'])) { |
|
| 742 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
| 743 | 743 | // user custom amount text if any, fallback to default if not. |
| 744 | - $item_name .= ' - ' . give_check_variable( $custom_amount_text, 'empty', __( 'Custom Amount', 'give' ) ); |
|
| 744 | + $item_name .= ' - '.give_check_variable($custom_amount_text, 'empty', __('Custom Amount', 'give')); |
|
| 745 | 745 | } |
| 746 | 746 | |
| 747 | 747 | return $item_name; |
@@ -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 | |
@@ -35,14 +35,14 @@ discard block |
||
| 35 | 35 | /* @var WPDB $wpdb */ |
| 36 | 36 | global $wpdb; |
| 37 | 37 | |
| 38 | - $this->table_name = $wpdb->prefix . 'give_customers'; |
|
| 38 | + $this->table_name = $wpdb->prefix.'give_customers'; |
|
| 39 | 39 | $this->primary_key = 'id'; |
| 40 | 40 | $this->version = '1.0'; |
| 41 | 41 | |
| 42 | 42 | // Set hooks and register table only if instance loading first time. |
| 43 | - if( ! ( Give()->donors instanceof Give_DB_Donors ) ) { |
|
| 43 | + if ( ! (Give()->donors instanceof Give_DB_Donors)) { |
|
| 44 | 44 | // Setup hook. |
| 45 | - add_action( 'profile_update', array( $this, 'update_donor_email_on_user_update' ), 10, 2 ); |
|
| 45 | + add_action('profile_update', array($this, 'update_donor_email_on_user_update'), 10, 2); |
|
| 46 | 46 | |
| 47 | 47 | // Install table. |
| 48 | 48 | $this->register_table(); |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | 'purchase_value' => 0.00, |
| 90 | 90 | 'purchase_count' => 0, |
| 91 | 91 | 'notes' => '', |
| 92 | - 'date_created' => date( 'Y-m-d H:i:s' ), |
|
| 92 | + 'date_created' => date('Y-m-d H:i:s'), |
|
| 93 | 93 | ); |
| 94 | 94 | } |
| 95 | 95 | |
@@ -103,40 +103,40 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @return int|bool |
| 105 | 105 | */ |
| 106 | - public function add( $data = array() ) { |
|
| 106 | + public function add($data = array()) { |
|
| 107 | 107 | |
| 108 | 108 | $defaults = array( |
| 109 | 109 | 'payment_ids' => '' |
| 110 | 110 | ); |
| 111 | 111 | |
| 112 | - $args = wp_parse_args( $data, $defaults ); |
|
| 112 | + $args = wp_parse_args($data, $defaults); |
|
| 113 | 113 | |
| 114 | - if ( empty( $args['email'] ) ) { |
|
| 114 | + if (empty($args['email'])) { |
|
| 115 | 115 | return false; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
| 119 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
| 118 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
| 119 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - $donor = $this->get_donor_by( 'email', $args['email'] ); |
|
| 122 | + $donor = $this->get_donor_by('email', $args['email']); |
|
| 123 | 123 | |
| 124 | 124 | // update an existing donor. |
| 125 | - if ( $donor ) { |
|
| 125 | + if ($donor) { |
|
| 126 | 126 | |
| 127 | 127 | // Update the payment IDs attached to the donor |
| 128 | - if ( ! empty( $args['payment_ids'] ) ) { |
|
| 128 | + if ( ! empty($args['payment_ids'])) { |
|
| 129 | 129 | |
| 130 | - if ( empty( $donor->payment_ids ) ) { |
|
| 130 | + if (empty($donor->payment_ids)) { |
|
| 131 | 131 | |
| 132 | 132 | $donor->payment_ids = $args['payment_ids']; |
| 133 | 133 | |
| 134 | 134 | } else { |
| 135 | 135 | |
| 136 | - $existing_ids = array_map( 'absint', explode( ',', $donor->payment_ids ) ); |
|
| 137 | - $payment_ids = array_map( 'absint', explode( ',', $args['payment_ids'] ) ); |
|
| 138 | - $payment_ids = array_merge( $payment_ids, $existing_ids ); |
|
| 139 | - $donor->payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
| 136 | + $existing_ids = array_map('absint', explode(',', $donor->payment_ids)); |
|
| 137 | + $payment_ids = array_map('absint', explode(',', $args['payment_ids'])); |
|
| 138 | + $payment_ids = array_merge($payment_ids, $existing_ids); |
|
| 139 | + $donor->payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
| 140 | 140 | |
| 141 | 141 | } |
| 142 | 142 | |
@@ -144,13 +144,13 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - $this->update( $donor->id, $args ); |
|
| 147 | + $this->update($donor->id, $args); |
|
| 148 | 148 | |
| 149 | 149 | return $donor->id; |
| 150 | 150 | |
| 151 | 151 | } else { |
| 152 | 152 | |
| 153 | - return $this->insert( $args, 'donor' ); |
|
| 153 | + return $this->insert($args, 'donor'); |
|
| 154 | 154 | |
| 155 | 155 | } |
| 156 | 156 | |
@@ -169,20 +169,20 @@ discard block |
||
| 169 | 169 | * |
| 170 | 170 | * @return bool|int |
| 171 | 171 | */ |
| 172 | - public function delete( $_id_or_email = false ) { |
|
| 172 | + public function delete($_id_or_email = false) { |
|
| 173 | 173 | |
| 174 | - if ( empty( $_id_or_email ) ) { |
|
| 174 | + if (empty($_id_or_email)) { |
|
| 175 | 175 | return false; |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - $column = is_email( $_id_or_email ) ? 'email' : 'id'; |
|
| 179 | - $donor = $this->get_donor_by( $column, $_id_or_email ); |
|
| 178 | + $column = is_email($_id_or_email) ? 'email' : 'id'; |
|
| 179 | + $donor = $this->get_donor_by($column, $_id_or_email); |
|
| 180 | 180 | |
| 181 | - if ( $donor->id > 0 ) { |
|
| 181 | + if ($donor->id > 0) { |
|
| 182 | 182 | |
| 183 | 183 | global $wpdb; |
| 184 | 184 | |
| 185 | - return $wpdb->delete( $this->table_name, array( 'id' => $donor->id ), array( '%d' ) ); |
|
| 185 | + return $wpdb->delete($this->table_name, array('id' => $donor->id), array('%d')); |
|
| 186 | 186 | |
| 187 | 187 | } else { |
| 188 | 188 | return false; |
@@ -203,14 +203,14 @@ discard block |
||
| 203 | 203 | * |
| 204 | 204 | * @return bool|int |
| 205 | 205 | */ |
| 206 | - public function delete_by_user_id( $user_id = false ) { |
|
| 206 | + public function delete_by_user_id($user_id = false) { |
|
| 207 | 207 | |
| 208 | - if ( empty( $user_id ) ) { |
|
| 208 | + if (empty($user_id)) { |
|
| 209 | 209 | return false; |
| 210 | 210 | } |
| 211 | 211 | global $wpdb; |
| 212 | 212 | |
| 213 | - return $wpdb->delete( $this->table_name, array( 'user_id' => $user_id ), array( '%d' ) ); |
|
| 213 | + return $wpdb->delete($this->table_name, array('user_id' => $user_id), array('%d')); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | /** |
@@ -224,14 +224,14 @@ discard block |
||
| 224 | 224 | * |
| 225 | 225 | * @return bool True is exists, false otherwise. |
| 226 | 226 | */ |
| 227 | - public function exists( $value = '', $field = 'email' ) { |
|
| 227 | + public function exists($value = '', $field = 'email') { |
|
| 228 | 228 | |
| 229 | 229 | $columns = $this->get_columns(); |
| 230 | - if ( ! array_key_exists( $field, $columns ) ) { |
|
| 230 | + if ( ! array_key_exists($field, $columns)) { |
|
| 231 | 231 | return false; |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - return (bool) $this->get_column_by( 'id', $field, $value ); |
|
| 234 | + return (bool) $this->get_column_by('id', $field, $value); |
|
| 235 | 235 | |
| 236 | 236 | } |
| 237 | 237 | |
@@ -246,16 +246,16 @@ discard block |
||
| 246 | 246 | * |
| 247 | 247 | * @return bool |
| 248 | 248 | */ |
| 249 | - public function attach_payment( $donor_id = 0, $payment_id = 0 ) { |
|
| 249 | + public function attach_payment($donor_id = 0, $payment_id = 0) { |
|
| 250 | 250 | |
| 251 | - $donor = new Give_Donor( $donor_id ); |
|
| 251 | + $donor = new Give_Donor($donor_id); |
|
| 252 | 252 | |
| 253 | - if ( empty( $donor->id ) ) { |
|
| 253 | + if (empty($donor->id)) { |
|
| 254 | 254 | return false; |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | // Attach the payment, but don't increment stats, as this function previously did not |
| 258 | - return $donor->attach_payment( $payment_id, false ); |
|
| 258 | + return $donor->attach_payment($payment_id, false); |
|
| 259 | 259 | |
| 260 | 260 | } |
| 261 | 261 | |
@@ -270,16 +270,16 @@ discard block |
||
| 270 | 270 | * |
| 271 | 271 | * @return bool |
| 272 | 272 | */ |
| 273 | - public function remove_payment( $donor_id = 0, $payment_id = 0 ) { |
|
| 273 | + public function remove_payment($donor_id = 0, $payment_id = 0) { |
|
| 274 | 274 | |
| 275 | - $donor = new Give_Donor( $donor_id ); |
|
| 275 | + $donor = new Give_Donor($donor_id); |
|
| 276 | 276 | |
| 277 | - if ( ! $donor ) { |
|
| 277 | + if ( ! $donor) { |
|
| 278 | 278 | return false; |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | // Remove the payment, but don't decrease stats, as this function previously did not |
| 282 | - return $donor->remove_payment( $payment_id, false ); |
|
| 282 | + return $donor->remove_payment($payment_id, false); |
|
| 283 | 283 | |
| 284 | 284 | } |
| 285 | 285 | |
@@ -293,18 +293,18 @@ discard block |
||
| 293 | 293 | * |
| 294 | 294 | * @return bool |
| 295 | 295 | */ |
| 296 | - public function increment_stats( $donor_id = 0, $amount = 0.00 ) { |
|
| 296 | + public function increment_stats($donor_id = 0, $amount = 0.00) { |
|
| 297 | 297 | |
| 298 | - $donor = new Give_Donor( $donor_id ); |
|
| 298 | + $donor = new Give_Donor($donor_id); |
|
| 299 | 299 | |
| 300 | - if ( empty( $donor->id ) ) { |
|
| 300 | + if (empty($donor->id)) { |
|
| 301 | 301 | return false; |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | $increased_count = $donor->increase_purchase_count(); |
| 305 | - $increased_value = $donor->increase_value( $amount ); |
|
| 305 | + $increased_value = $donor->increase_value($amount); |
|
| 306 | 306 | |
| 307 | - return ( $increased_count && $increased_value ) ? true : false; |
|
| 307 | + return ($increased_count && $increased_value) ? true : false; |
|
| 308 | 308 | |
| 309 | 309 | } |
| 310 | 310 | |
@@ -319,18 +319,18 @@ discard block |
||
| 319 | 319 | * |
| 320 | 320 | * @return bool |
| 321 | 321 | */ |
| 322 | - public function decrement_stats( $donor_id = 0, $amount = 0.00 ) { |
|
| 322 | + public function decrement_stats($donor_id = 0, $amount = 0.00) { |
|
| 323 | 323 | |
| 324 | - $donor = new Give_Donor( $donor_id ); |
|
| 324 | + $donor = new Give_Donor($donor_id); |
|
| 325 | 325 | |
| 326 | - if ( ! $donor ) { |
|
| 326 | + if ( ! $donor) { |
|
| 327 | 327 | return false; |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | $decreased_count = $donor->decrease_donation_count(); |
| 331 | - $decreased_value = $donor->decrease_value( $amount ); |
|
| 331 | + $decreased_value = $donor->decrease_value($amount); |
|
| 332 | 332 | |
| 333 | - return ( $decreased_count && $decreased_value ) ? true : false; |
|
| 333 | + return ($decreased_count && $decreased_value) ? true : false; |
|
| 334 | 334 | |
| 335 | 335 | } |
| 336 | 336 | |
@@ -345,31 +345,31 @@ discard block |
||
| 345 | 345 | * |
| 346 | 346 | * @return bool |
| 347 | 347 | */ |
| 348 | - public function update_donor_email_on_user_update( $user_id = 0, $old_user_data = false ) { |
|
| 348 | + public function update_donor_email_on_user_update($user_id = 0, $old_user_data = false) { |
|
| 349 | 349 | |
| 350 | - $donor = new Give_Donor( $user_id, true ); |
|
| 350 | + $donor = new Give_Donor($user_id, true); |
|
| 351 | 351 | |
| 352 | - if( ! $donor ) { |
|
| 352 | + if ( ! $donor) { |
|
| 353 | 353 | return false; |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - $user = get_userdata( $user_id ); |
|
| 356 | + $user = get_userdata($user_id); |
|
| 357 | 357 | |
| 358 | - if( ! empty( $user ) && $user->user_email !== $donor->email ) { |
|
| 358 | + if ( ! empty($user) && $user->user_email !== $donor->email) { |
|
| 359 | 359 | |
| 360 | - if( ! $this->get_donor_by( 'email', $user->user_email ) ) { |
|
| 360 | + if ( ! $this->get_donor_by('email', $user->user_email)) { |
|
| 361 | 361 | |
| 362 | - $success = $this->update( $donor->id, array( 'email' => $user->user_email ) ); |
|
| 362 | + $success = $this->update($donor->id, array('email' => $user->user_email)); |
|
| 363 | 363 | |
| 364 | - if( $success ) { |
|
| 364 | + if ($success) { |
|
| 365 | 365 | // Update some payment meta if we need to |
| 366 | - $payments_array = explode( ',', $donor->payment_ids ); |
|
| 366 | + $payments_array = explode(',', $donor->payment_ids); |
|
| 367 | 367 | |
| 368 | - if( ! empty( $payments_array ) ) { |
|
| 368 | + if ( ! empty($payments_array)) { |
|
| 369 | 369 | |
| 370 | - foreach ( $payments_array as $payment_id ) { |
|
| 370 | + foreach ($payments_array as $payment_id) { |
|
| 371 | 371 | |
| 372 | - give_update_payment_meta( $payment_id, 'email', $user->user_email ); |
|
| 372 | + give_update_payment_meta($payment_id, 'email', $user->user_email); |
|
| 373 | 373 | |
| 374 | 374 | } |
| 375 | 375 | |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | * @param WP_User $user WordPress User object. |
| 384 | 384 | * @param Give_Donor $donor Give donor object. |
| 385 | 385 | */ |
| 386 | - do_action( 'give_update_donor_email_on_user_update', $user, $donor ); |
|
| 386 | + do_action('give_update_donor_email_on_user_update', $user, $donor); |
|
| 387 | 387 | |
| 388 | 388 | } |
| 389 | 389 | |
@@ -404,46 +404,46 @@ discard block |
||
| 404 | 404 | * |
| 405 | 405 | * @return mixed Upon success, an object of the donor. Upon failure, NULL |
| 406 | 406 | */ |
| 407 | - public function get_donor_by( $field = 'id', $value = 0 ) { |
|
| 407 | + public function get_donor_by($field = 'id', $value = 0) { |
|
| 408 | 408 | /* @var WPDB $wpdb */ |
| 409 | 409 | global $wpdb; |
| 410 | 410 | |
| 411 | - if ( empty( $field ) || empty( $value ) ) { |
|
| 411 | + if (empty($field) || empty($value)) { |
|
| 412 | 412 | return null; |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | - if ( 'id' == $field || 'user_id' == $field ) { |
|
| 415 | + if ('id' == $field || 'user_id' == $field) { |
|
| 416 | 416 | // Make sure the value is numeric to avoid casting objects, for example, |
| 417 | 417 | // to int 1. |
| 418 | - if ( ! is_numeric( $value ) ) { |
|
| 418 | + if ( ! is_numeric($value)) { |
|
| 419 | 419 | return false; |
| 420 | 420 | } |
| 421 | 421 | |
| 422 | - $value = intval( $value ); |
|
| 422 | + $value = intval($value); |
|
| 423 | 423 | |
| 424 | - if ( $value < 1 ) { |
|
| 424 | + if ($value < 1) { |
|
| 425 | 425 | return false; |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | - } elseif ( 'email' === $field ) { |
|
| 428 | + } elseif ('email' === $field) { |
|
| 429 | 429 | |
| 430 | - if ( ! is_email( $value ) ) { |
|
| 430 | + if ( ! is_email($value)) { |
|
| 431 | 431 | return false; |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | - $value = trim( $value ); |
|
| 434 | + $value = trim($value); |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | - if ( ! $value ) { |
|
| 437 | + if ( ! $value) { |
|
| 438 | 438 | return false; |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | - switch ( $field ) { |
|
| 441 | + switch ($field) { |
|
| 442 | 442 | case 'id': |
| 443 | 443 | $db_field = 'id'; |
| 444 | 444 | break; |
| 445 | 445 | case 'email': |
| 446 | - $value = sanitize_text_field( $value ); |
|
| 446 | + $value = sanitize_text_field($value); |
|
| 447 | 447 | $db_field = 'email'; |
| 448 | 448 | break; |
| 449 | 449 | case 'user_id': |
@@ -453,15 +453,15 @@ discard block |
||
| 453 | 453 | return false; |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | - if ( ! $donor = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $db_field = %s LIMIT 1", $value ) ) ) { |
|
| 456 | + if ( ! $donor = $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $db_field = %s LIMIT 1", $value))) { |
|
| 457 | 457 | |
| 458 | 458 | // Look for donor from an additional email. |
| 459 | - if( 'email' === $field ) { |
|
| 460 | - $meta_table = Give()->donor_meta->table_name; |
|
| 461 | - $donor_id = $wpdb->get_var( $wpdb->prepare( "SELECT customer_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $value ) ); |
|
| 459 | + if ('email' === $field) { |
|
| 460 | + $meta_table = Give()->donor_meta->table_name; |
|
| 461 | + $donor_id = $wpdb->get_var($wpdb->prepare("SELECT customer_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $value)); |
|
| 462 | 462 | |
| 463 | - if( ! empty( $donor_id ) ) { |
|
| 464 | - return $this->get( $donor_id ); |
|
| 463 | + if ( ! empty($donor_id)) { |
|
| 464 | + return $this->get($donor_id); |
|
| 465 | 465 | } |
| 466 | 466 | } |
| 467 | 467 | |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | * |
| 482 | 482 | * @return array|object|null Customers array or object. Null if not found. |
| 483 | 483 | */ |
| 484 | - public function get_donors( $args = array() ) { |
|
| 484 | + public function get_donors($args = array()) { |
|
| 485 | 485 | /* @var WPDB $wpdb */ |
| 486 | 486 | global $wpdb; |
| 487 | 487 | |
@@ -493,21 +493,21 @@ discard block |
||
| 493 | 493 | 'order' => 'DESC' |
| 494 | 494 | ); |
| 495 | 495 | |
| 496 | - $args = wp_parse_args( $args, $defaults ); |
|
| 496 | + $args = wp_parse_args($args, $defaults); |
|
| 497 | 497 | |
| 498 | - if ( $args['number'] < 1 ) { |
|
| 498 | + if ($args['number'] < 1) { |
|
| 499 | 499 | $args['number'] = 999999999999; |
| 500 | 500 | } |
| 501 | 501 | |
| 502 | 502 | $where = ' WHERE 1=1 '; |
| 503 | 503 | |
| 504 | 504 | // specific donors. |
| 505 | - if ( ! empty( $args['id'] ) ) { |
|
| 505 | + if ( ! empty($args['id'])) { |
|
| 506 | 506 | |
| 507 | - if ( is_array( $args['id'] ) ) { |
|
| 508 | - $ids = implode( ',', array_map( 'intval', $args['id'] ) ); |
|
| 507 | + if (is_array($args['id'])) { |
|
| 508 | + $ids = implode(',', array_map('intval', $args['id'])); |
|
| 509 | 509 | } else { |
| 510 | - $ids = intval( $args['id'] ); |
|
| 510 | + $ids = intval($args['id']); |
|
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | $where .= " AND `id` IN( {$ids} ) "; |
@@ -515,12 +515,12 @@ discard block |
||
| 515 | 515 | } |
| 516 | 516 | |
| 517 | 517 | // donors for specific user accounts |
| 518 | - if ( ! empty( $args['user_id'] ) ) { |
|
| 518 | + if ( ! empty($args['user_id'])) { |
|
| 519 | 519 | |
| 520 | - if ( is_array( $args['user_id'] ) ) { |
|
| 521 | - $user_ids = implode( ',', array_map( 'intval', $args['user_id'] ) ); |
|
| 520 | + if (is_array($args['user_id'])) { |
|
| 521 | + $user_ids = implode(',', array_map('intval', $args['user_id'])); |
|
| 522 | 522 | } else { |
| 523 | - $user_ids = intval( $args['user_id'] ); |
|
| 523 | + $user_ids = intval($args['user_id']); |
|
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 526 | $where .= " AND `user_id` IN( {$user_ids} ) "; |
@@ -528,41 +528,41 @@ discard block |
||
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | //specific donors by email |
| 531 | - if( ! empty( $args['email'] ) ) { |
|
| 531 | + if ( ! empty($args['email'])) { |
|
| 532 | 532 | |
| 533 | - if( is_array( $args['email'] ) ) { |
|
| 533 | + if (is_array($args['email'])) { |
|
| 534 | 534 | |
| 535 | - $emails_count = count( $args['email'] ); |
|
| 536 | - $emails_placeholder = array_fill( 0, $emails_count, '%s' ); |
|
| 537 | - $emails = implode( ', ', $emails_placeholder ); |
|
| 535 | + $emails_count = count($args['email']); |
|
| 536 | + $emails_placeholder = array_fill(0, $emails_count, '%s'); |
|
| 537 | + $emails = implode(', ', $emails_placeholder); |
|
| 538 | 538 | |
| 539 | - $where .= $wpdb->prepare( " AND `email` IN( $emails ) ", $args['email'] ); |
|
| 539 | + $where .= $wpdb->prepare(" AND `email` IN( $emails ) ", $args['email']); |
|
| 540 | 540 | } else { |
| 541 | - $where .= $wpdb->prepare( " AND `email` = %s ", $args['email'] ); |
|
| 541 | + $where .= $wpdb->prepare(" AND `email` = %s ", $args['email']); |
|
| 542 | 542 | } |
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | // specific donors by name |
| 546 | - if( ! empty( $args['name'] ) ) { |
|
| 547 | - $where .= $wpdb->prepare( " AND `name` LIKE '%%%%" . '%s' . "%%%%' ", $args['name'] ); |
|
| 546 | + if ( ! empty($args['name'])) { |
|
| 547 | + $where .= $wpdb->prepare(" AND `name` LIKE '%%%%".'%s'."%%%%' ", $args['name']); |
|
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | // Donors created for a specific date or in a date range |
| 551 | - if ( ! empty( $args['date'] ) ) { |
|
| 551 | + if ( ! empty($args['date'])) { |
|
| 552 | 552 | |
| 553 | - if ( is_array( $args['date'] ) ) { |
|
| 553 | + if (is_array($args['date'])) { |
|
| 554 | 554 | |
| 555 | - if ( ! empty( $args['date']['start'] ) ) { |
|
| 555 | + if ( ! empty($args['date']['start'])) { |
|
| 556 | 556 | |
| 557 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) ); |
|
| 557 | + $start = date('Y-m-d H:i:s', strtotime($args['date']['start'])); |
|
| 558 | 558 | |
| 559 | 559 | $where .= " AND `date_created` >= '{$start}'"; |
| 560 | 560 | |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | - if ( ! empty( $args['date']['end'] ) ) { |
|
| 563 | + if ( ! empty($args['date']['end'])) { |
|
| 564 | 564 | |
| 565 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) ); |
|
| 565 | + $end = date('Y-m-d H:i:s', strtotime($args['date']['end'])); |
|
| 566 | 566 | |
| 567 | 567 | $where .= " AND `date_created` <= '{$end}'"; |
| 568 | 568 | |
@@ -570,31 +570,31 @@ discard block |
||
| 570 | 570 | |
| 571 | 571 | } else { |
| 572 | 572 | |
| 573 | - $year = date( 'Y', strtotime( $args['date'] ) ); |
|
| 574 | - $month = date( 'm', strtotime( $args['date'] ) ); |
|
| 575 | - $day = date( 'd', strtotime( $args['date'] ) ); |
|
| 573 | + $year = date('Y', strtotime($args['date'])); |
|
| 574 | + $month = date('m', strtotime($args['date'])); |
|
| 575 | + $day = date('d', strtotime($args['date'])); |
|
| 576 | 576 | |
| 577 | 577 | $where .= " AND $year = YEAR ( date_created ) AND $month = MONTH ( date_created ) AND $day = DAY ( date_created )"; |
| 578 | 578 | } |
| 579 | 579 | |
| 580 | 580 | } |
| 581 | 581 | |
| 582 | - $args['orderby'] = ! array_key_exists( $args['orderby'], $this->get_columns() ) ? 'id' : $args['orderby']; |
|
| 582 | + $args['orderby'] = ! array_key_exists($args['orderby'], $this->get_columns()) ? 'id' : $args['orderby']; |
|
| 583 | 583 | |
| 584 | - if ( 'purchase_value' == $args['orderby'] ) { |
|
| 584 | + if ('purchase_value' == $args['orderby']) { |
|
| 585 | 585 | $args['orderby'] = 'purchase_value+0'; |
| 586 | 586 | } |
| 587 | 587 | |
| 588 | - $cache_key = md5( 'give_donors_' . serialize( $args ) ); |
|
| 588 | + $cache_key = md5('give_donors_'.serialize($args)); |
|
| 589 | 589 | |
| 590 | - $donors = wp_cache_get( $cache_key, 'donors' ); |
|
| 590 | + $donors = wp_cache_get($cache_key, 'donors'); |
|
| 591 | 591 | |
| 592 | - $args['orderby'] = esc_sql( $args['orderby'] ); |
|
| 593 | - $args['order'] = esc_sql( $args['order'] ); |
|
| 592 | + $args['orderby'] = esc_sql($args['orderby']); |
|
| 593 | + $args['order'] = esc_sql($args['order']); |
|
| 594 | 594 | |
| 595 | - if ( $donors === false ) { |
|
| 596 | - $donors = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint( $args['offset'] ), absint( $args['number'] ) ) ); |
|
| 597 | - wp_cache_set( $cache_key, $donors, 'donors', 3600 ); |
|
| 595 | + if ($donors === false) { |
|
| 596 | + $donors = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint($args['offset']), absint($args['number']))); |
|
| 597 | + wp_cache_set($cache_key, $donors, 'donors', 3600); |
|
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | return $donors; |
@@ -612,26 +612,26 @@ discard block |
||
| 612 | 612 | * |
| 613 | 613 | * @return int Total number of donors. |
| 614 | 614 | */ |
| 615 | - public function count( $args = array() ) { |
|
| 615 | + public function count($args = array()) { |
|
| 616 | 616 | /* @var WPDB $wpdb */ |
| 617 | 617 | global $wpdb; |
| 618 | 618 | |
| 619 | 619 | $where = ' WHERE 1=1 '; |
| 620 | 620 | |
| 621 | - if ( ! empty( $args['date'] ) ) { |
|
| 621 | + if ( ! empty($args['date'])) { |
|
| 622 | 622 | |
| 623 | - if ( is_array( $args['date'] ) ) { |
|
| 623 | + if (is_array($args['date'])) { |
|
| 624 | 624 | |
| 625 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) ); |
|
| 626 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) ); |
|
| 625 | + $start = date('Y-m-d H:i:s', strtotime($args['date']['start'])); |
|
| 626 | + $end = date('Y-m-d H:i:s', strtotime($args['date']['end'])); |
|
| 627 | 627 | |
| 628 | 628 | $where .= " AND `date_created` >= '{$start}' AND `date_created` <= '{$end}'"; |
| 629 | 629 | |
| 630 | 630 | } else { |
| 631 | 631 | |
| 632 | - $year = date( 'Y', strtotime( $args['date'] ) ); |
|
| 633 | - $month = date( 'm', strtotime( $args['date'] ) ); |
|
| 634 | - $day = date( 'd', strtotime( $args['date'] ) ); |
|
| 632 | + $year = date('Y', strtotime($args['date'])); |
|
| 633 | + $month = date('m', strtotime($args['date'])); |
|
| 634 | + $day = date('d', strtotime($args['date'])); |
|
| 635 | 635 | |
| 636 | 636 | $where .= " AND $year = YEAR ( date_created ) AND $month = MONTH ( date_created ) AND $day = DAY ( date_created )"; |
| 637 | 637 | } |
@@ -639,16 +639,16 @@ discard block |
||
| 639 | 639 | } |
| 640 | 640 | |
| 641 | 641 | |
| 642 | - $cache_key = md5( 'give_donors_count' . serialize( $args ) ); |
|
| 642 | + $cache_key = md5('give_donors_count'.serialize($args)); |
|
| 643 | 643 | |
| 644 | - $count = wp_cache_get( $cache_key, 'donors' ); |
|
| 644 | + $count = wp_cache_get($cache_key, 'donors'); |
|
| 645 | 645 | |
| 646 | - if ( $count === false ) { |
|
| 647 | - $count = $wpdb->get_var( "SELECT COUNT($this->primary_key) FROM " . $this->table_name . "{$where};" ); |
|
| 648 | - wp_cache_set( $cache_key, $count, 'donors', 3600 ); |
|
| 646 | + if ($count === false) { |
|
| 647 | + $count = $wpdb->get_var("SELECT COUNT($this->primary_key) FROM ".$this->table_name."{$where};"); |
|
| 648 | + wp_cache_set($cache_key, $count, 'donors', 3600); |
|
| 649 | 649 | } |
| 650 | 650 | |
| 651 | - return absint( $count ); |
|
| 651 | + return absint($count); |
|
| 652 | 652 | |
| 653 | 653 | } |
| 654 | 654 | |
@@ -662,9 +662,9 @@ discard block |
||
| 662 | 662 | */ |
| 663 | 663 | public function create_table() { |
| 664 | 664 | |
| 665 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 665 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
| 666 | 666 | |
| 667 | - $sql = "CREATE TABLE " . $this->table_name . " ( |
|
| 667 | + $sql = "CREATE TABLE ".$this->table_name." ( |
|
| 668 | 668 | id bigint(20) NOT NULL AUTO_INCREMENT, |
| 669 | 669 | user_id bigint(20) NOT NULL, |
| 670 | 670 | email varchar(50) NOT NULL, |
@@ -679,9 +679,9 @@ discard block |
||
| 679 | 679 | KEY user (user_id) |
| 680 | 680 | ) CHARACTER SET utf8 COLLATE utf8_general_ci;"; |
| 681 | 681 | |
| 682 | - dbDelta( $sql ); |
|
| 682 | + dbDelta($sql); |
|
| 683 | 683 | |
| 684 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
| 684 | + update_option($this->table_name.'_db_version', $this->version); |
|
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | /** |
@@ -693,7 +693,7 @@ discard block |
||
| 693 | 693 | * @return bool Returns if the donors table was installed and upgrade routine run. |
| 694 | 694 | */ |
| 695 | 695 | public function installed() { |
| 696 | - return $this->table_exists( $this->table_name ); |
|
| 696 | + return $this->table_exists($this->table_name); |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | } |
@@ -3,24 +3,24 @@ discard block |
||
| 3 | 3 | * This template is used to display the goal with [give_goal] |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | -$form = new Give_Donate_Form( $form_id ); |
|
| 7 | -$goal_option = give_get_meta( $form->ID, '_give_goal_option', true ); |
|
| 6 | +$form = new Give_Donate_Form($form_id); |
|
| 7 | +$goal_option = give_get_meta($form->ID, '_give_goal_option', true); |
|
| 8 | 8 | |
| 9 | 9 | //Sanity check - ensure form has pass all condition to show goal. |
| 10 | 10 | if ( |
| 11 | - ( isset( $args['show_goal'] ) && ! filter_var( $args['show_goal'], FILTER_VALIDATE_BOOLEAN ) ) |
|
| 12 | - || empty( $form->ID ) |
|
| 13 | - || ( is_singular( 'give_forms' ) && ! give_is_setting_enabled( $goal_option ) ) |
|
| 14 | - || ! give_is_setting_enabled( $goal_option ) |
|
| 11 | + (isset($args['show_goal']) && ! filter_var($args['show_goal'], FILTER_VALIDATE_BOOLEAN)) |
|
| 12 | + || empty($form->ID) |
|
| 13 | + || (is_singular('give_forms') && ! give_is_setting_enabled($goal_option)) |
|
| 14 | + || ! give_is_setting_enabled($goal_option) |
|
| 15 | 15 | || 0 === $form->goal |
| 16 | 16 | ) { |
| 17 | 17 | return false; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | -$goal_format = give_get_meta( $form_id, '_give_goal_format', true ); |
|
| 21 | -$color = give_get_meta( $form_id, '_give_goal_color', true ); |
|
| 22 | -$show_text = isset( $args['show_text'] ) ? filter_var( $args['show_text'], FILTER_VALIDATE_BOOLEAN ) : true; |
|
| 23 | -$show_bar = isset( $args['show_bar'] ) ? filter_var( $args['show_bar'], FILTER_VALIDATE_BOOLEAN ) : true; |
|
| 20 | +$goal_format = give_get_meta($form_id, '_give_goal_format', true); |
|
| 21 | +$color = give_get_meta($form_id, '_give_goal_color', true); |
|
| 22 | +$show_text = isset($args['show_text']) ? filter_var($args['show_text'], FILTER_VALIDATE_BOOLEAN) : true; |
|
| 23 | +$show_bar = isset($args['show_bar']) ? filter_var($args['show_bar'], FILTER_VALIDATE_BOOLEAN) : true; |
|
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -28,14 +28,14 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @since 1.8.8 |
| 30 | 30 | */ |
| 31 | -$income = apply_filters( 'give_goal_amount_raised_output', $form->get_earnings(), $form_id, $form ); |
|
| 31 | +$income = apply_filters('give_goal_amount_raised_output', $form->get_earnings(), $form_id, $form); |
|
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | 34 | * Filter the form |
| 35 | 35 | * |
| 36 | 36 | * @since 1.8.8 |
| 37 | 37 | */ |
| 38 | -$goal = apply_filters( 'give_goal_amount_target_output', $form->goal, $form_id, $form ); |
|
| 38 | +$goal = apply_filters('give_goal_amount_target_output', $form->goal, $form_id, $form); |
|
| 39 | 39 | |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -43,39 +43,39 @@ discard block |
||
| 43 | 43 | * |
| 44 | 44 | * @since 1.8.8 |
| 45 | 45 | */ |
| 46 | -$progress = apply_filters( 'give_goal_amount_funded_percentage_output', round( ( $income / $goal ) * 100, 2 ), $form_id, $form ); |
|
| 46 | +$progress = apply_filters('give_goal_amount_funded_percentage_output', round(($income / $goal) * 100, 2), $form_id, $form); |
|
| 47 | 47 | |
| 48 | 48 | |
| 49 | 49 | // Set progress to 100 percentage if income > goal. |
| 50 | -if ( $income >= $goal ) { |
|
| 50 | +if ($income >= $goal) { |
|
| 51 | 51 | $progress = 100; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | ?> |
| 55 | 55 | <div class="give-goal-progress"> |
| 56 | - <?php if ( ! empty( $show_text ) ) : ?> |
|
| 56 | + <?php if ( ! empty($show_text)) : ?> |
|
| 57 | 57 | <div class="raised"> |
| 58 | 58 | <?php |
| 59 | - if ( $goal_format !== 'percentage' ) : |
|
| 59 | + if ($goal_format !== 'percentage') : |
|
| 60 | 60 | |
| 61 | 61 | // Get formatted amount. |
| 62 | - $income = give_human_format_large_amount( give_format_amount( $income, array( 'sanitize' => false ) ) ); |
|
| 63 | - $goal = give_human_format_large_amount( give_format_amount( $goal, array( 'sanitize' => false ) ) ); |
|
| 62 | + $income = give_human_format_large_amount(give_format_amount($income, array('sanitize' => false))); |
|
| 63 | + $goal = give_human_format_large_amount(give_format_amount($goal, array('sanitize' => false))); |
|
| 64 | 64 | |
| 65 | 65 | echo sprintf( |
| 66 | 66 | /* translators: 1: amount of income raised 2: goal target ammount */ |
| 67 | - __( '%1$s of %2$s raised', 'give' ), |
|
| 68 | - '<span class="income">' . give_currency_filter( $income ) . '</span>', |
|
| 69 | - '<span class="goal-text">' . give_currency_filter( $goal ) . '</span>' |
|
| 67 | + __('%1$s of %2$s raised', 'give'), |
|
| 68 | + '<span class="income">'.give_currency_filter($income).'</span>', |
|
| 69 | + '<span class="goal-text">'.give_currency_filter($goal).'</span>' |
|
| 70 | 70 | ); |
| 71 | 71 | |
| 72 | 72 | |
| 73 | - elseif ( $goal_format == 'percentage' ) : |
|
| 73 | + elseif ($goal_format == 'percentage') : |
|
| 74 | 74 | |
| 75 | 75 | echo sprintf( |
| 76 | 76 | /* translators: %s: percentage of the amount raised compared to the goal target */ |
| 77 | - __( '%s%% funded', 'give' ), |
|
| 78 | - '<span class="give-percentage">' . round( $progress ) . '</span>' |
|
| 77 | + __('%s%% funded', 'give'), |
|
| 78 | + '<span class="give-percentage">'.round($progress).'</span>' |
|
| 79 | 79 | ); |
| 80 | 80 | |
| 81 | 81 | endif; |
@@ -84,10 +84,10 @@ discard block |
||
| 84 | 84 | <?php endif; ?> |
| 85 | 85 | |
| 86 | 86 | |
| 87 | - <?php if ( ! empty( $show_bar ) ) : ?> |
|
| 88 | - <div class="give-progress-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="<?php echo esc_attr( $progress ); ?>"> |
|
| 89 | - <span style="width: <?php echo esc_attr( $progress ); ?>%;<?php if ( ! empty( $color ) ) { |
|
| 90 | - echo 'background-color:' . $color; |
|
| 87 | + <?php if ( ! empty($show_bar)) : ?> |
|
| 88 | + <div class="give-progress-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="<?php echo esc_attr($progress); ?>"> |
|
| 89 | + <span style="width: <?php echo esc_attr($progress); ?>%;<?php if ( ! empty($color)) { |
|
| 90 | + echo 'background-color:'.$color; |
|
| 91 | 91 | } ?>"></span> |
| 92 | 92 | </div><!-- /.give-progress-bar --> |
| 93 | 93 | <?php endif; ?> |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | <?php |
| 72 | 72 | // Display View Receipt or |
| 73 | 73 | if ( 'publish' !== $post->post_status |
| 74 | - && 'subscription' !== $post->post_status |
|
| 74 | + && 'subscription' !== $post->post_status |
|
| 75 | 75 | ) : ?> |
| 76 | 76 | <a href="<?php echo esc_url( add_query_arg( 'payment_key', give_get_payment_key( $post->ID ), give_get_history_page_uri() ) ); ?>"><span |
| 77 | 77 | class="give-donation-status <?php echo $post->post_status; ?>"><?php echo esc_html__( 'View', 'give' ) . ' ' . give_get_payment_status( $post, true ) . ' »'; ?></span></a> |
@@ -4,18 +4,18 @@ discard block |
||
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | 6 | // User's Donations |
| 7 | -if ( is_user_logged_in() ) { |
|
| 8 | - $donations = give_get_users_donations( get_current_user_id(), 20, true, 'any' ); |
|
| 9 | -} elseif ( Give()->email_access->token_exists ) { |
|
| 7 | +if (is_user_logged_in()) { |
|
| 8 | + $donations = give_get_users_donations(get_current_user_id(), 20, true, 'any'); |
|
| 9 | +} elseif (Give()->email_access->token_exists) { |
|
| 10 | 10 | // Email Access Token? |
| 11 | - $donations = give_get_users_donations( 0, 20, true, 'any' ); |
|
| 12 | -} elseif ( Give()->session->get_session_expiration() !== false ) { |
|
| 11 | + $donations = give_get_users_donations(0, 20, true, 'any'); |
|
| 12 | +} elseif (Give()->session->get_session_expiration() !== false) { |
|
| 13 | 13 | // Session active? |
| 14 | - $email = Give()->session->get( 'give_email' ); |
|
| 15 | - $donations = give_get_users_donations( $email, 20, true, 'any' ); |
|
| 14 | + $email = Give()->session->get('give_email'); |
|
| 15 | + $donations = give_get_users_donations($email, 20, true, 'any'); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | -if ( $donations ) : ?> |
|
| 18 | +if ($donations) : ?> |
|
| 19 | 19 | <table id="give_user_history" class="give-table"> |
| 20 | 20 | <thead> |
| 21 | 21 | <tr class="give-donation-row"> |
@@ -27,12 +27,12 @@ discard block |
||
| 27 | 27 | * |
| 28 | 28 | * @since 1.7 |
| 29 | 29 | */ |
| 30 | - do_action( 'give_donation_history_header_before' ); |
|
| 30 | + do_action('give_donation_history_header_before'); |
|
| 31 | 31 | ?> |
| 32 | - <th scope="col" class="give-donation-id"><?php esc_html_e( 'ID', 'give' ); ?></th> |
|
| 33 | - <th scope="col" class="give-donation-date"><?php esc_html_e( 'Date', 'give' ); ?></th> |
|
| 34 | - <th scope="col" class="give-donation-amount"><?php esc_html_e( 'Amount', 'give' ); ?></th> |
|
| 35 | - <th scope="col" class="give-donation-details"><?php esc_html_e( 'Details', 'give' ); ?></th> |
|
| 32 | + <th scope="col" class="give-donation-id"><?php esc_html_e('ID', 'give'); ?></th> |
|
| 33 | + <th scope="col" class="give-donation-date"><?php esc_html_e('Date', 'give'); ?></th> |
|
| 34 | + <th scope="col" class="give-donation-amount"><?php esc_html_e('Amount', 'give'); ?></th> |
|
| 35 | + <th scope="col" class="give-donation-details"><?php esc_html_e('Details', 'give'); ?></th> |
|
| 36 | 36 | <?php |
| 37 | 37 | /** |
| 38 | 38 | * Fires in current user donation history table, after the header row ends. |
@@ -41,13 +41,13 @@ discard block |
||
| 41 | 41 | * |
| 42 | 42 | * @since 1.7 |
| 43 | 43 | */ |
| 44 | - do_action( 'give_donation_history_header_after' ); |
|
| 44 | + do_action('give_donation_history_header_after'); |
|
| 45 | 45 | ?> |
| 46 | 46 | </tr> |
| 47 | 47 | </thead> |
| 48 | - <?php foreach ( $donations as $post ) : |
|
| 49 | - setup_postdata( $post ); |
|
| 50 | - $donation_data = give_get_payment_meta( $post->ID ); ?> |
|
| 48 | + <?php foreach ($donations as $post) : |
|
| 49 | + setup_postdata($post); |
|
| 50 | + $donation_data = give_get_payment_meta($post->ID); ?> |
|
| 51 | 51 | <tr class="give-donation-row"> |
| 52 | 52 | <?php |
| 53 | 53 | /** |
@@ -60,23 +60,23 @@ discard block |
||
| 60 | 60 | * @param int $post_id The ID of the post. |
| 61 | 61 | * @param mixed $donation_data Payment meta data. |
| 62 | 62 | */ |
| 63 | - do_action( 'give_donation_history_row_start', $post->ID, $donation_data ); |
|
| 63 | + do_action('give_donation_history_row_start', $post->ID, $donation_data); |
|
| 64 | 64 | ?> |
| 65 | - <td class="give-donation-id">#<?php echo give_get_payment_number( $post->ID ); ?></td> |
|
| 66 | - <td class="give-donation-date"><?php echo date_i18n( give_date_format(), strtotime( get_post_field( 'post_date', $post->ID ) ) ); ?></td> |
|
| 65 | + <td class="give-donation-id">#<?php echo give_get_payment_number($post->ID); ?></td> |
|
| 66 | + <td class="give-donation-date"><?php echo date_i18n(give_date_format(), strtotime(get_post_field('post_date', $post->ID))); ?></td> |
|
| 67 | 67 | <td class="give-donation-amount"> |
| 68 | - <span class="give-donation-amount"><?php echo give_currency_filter( give_format_amount( give_get_payment_amount( $post->ID ), array( 'sanitize' => false ) ) ); ?></span> |
|
| 68 | + <span class="give-donation-amount"><?php echo give_currency_filter(give_format_amount(give_get_payment_amount($post->ID), array('sanitize' => false))); ?></span> |
|
| 69 | 69 | </td> |
| 70 | 70 | <td class="give-donation-details"> |
| 71 | 71 | <?php |
| 72 | 72 | // Display View Receipt or |
| 73 | - if ( 'publish' !== $post->post_status |
|
| 73 | + if ('publish' !== $post->post_status |
|
| 74 | 74 | && 'subscription' !== $post->post_status |
| 75 | 75 | ) : ?> |
| 76 | - <a href="<?php echo esc_url( add_query_arg( 'payment_key', give_get_payment_key( $post->ID ), give_get_history_page_uri() ) ); ?>"><span |
|
| 77 | - class="give-donation-status <?php echo $post->post_status; ?>"><?php echo esc_html__( 'View', 'give' ) . ' ' . give_get_payment_status( $post, true ) . ' »'; ?></span></a> |
|
| 76 | + <a href="<?php echo esc_url(add_query_arg('payment_key', give_get_payment_key($post->ID), give_get_history_page_uri())); ?>"><span |
|
| 77 | + class="give-donation-status <?php echo $post->post_status; ?>"><?php echo esc_html__('View', 'give').' '.give_get_payment_status($post, true).' »'; ?></span></a> |
|
| 78 | 78 | <?php else : ?> |
| 79 | - <a href="<?php echo esc_url( add_query_arg( 'payment_key', give_get_payment_key( $post->ID ), give_get_history_page_uri() ) ); ?>"><?php esc_html_e( 'View Receipt »', 'give' ); ?></a> |
|
| 79 | + <a href="<?php echo esc_url(add_query_arg('payment_key', give_get_payment_key($post->ID), give_get_history_page_uri())); ?>"><?php esc_html_e('View Receipt »', 'give'); ?></a> |
|
| 80 | 80 | <?php endif; ?> |
| 81 | 81 | </td> |
| 82 | 82 | <?php |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @param int $post_id The ID of the post. |
| 91 | 91 | * @param mixed $donation_data Payment meta data. |
| 92 | 92 | */ |
| 93 | - do_action( 'give_donation_history_row_end', $post->ID, $donation_data ); |
|
| 93 | + do_action('give_donation_history_row_end', $post->ID, $donation_data); |
|
| 94 | 94 | ?> |
| 95 | 95 | </tr> |
| 96 | 96 | <?php endforeach; ?> |
@@ -98,15 +98,15 @@ discard block |
||
| 98 | 98 | <div id="give-donation-history-pagination" class="give_pagination navigation"> |
| 99 | 99 | <?php |
| 100 | 100 | $big = 999999; |
| 101 | - echo paginate_links( array( |
|
| 102 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
| 101 | + echo paginate_links(array( |
|
| 102 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
| 103 | 103 | 'format' => '?paged=%#%', |
| 104 | - 'current' => max( 1, get_query_var( 'paged' ) ), |
|
| 105 | - 'total' => ceil( give_count_donations_of_donor() / 20 ) // 20 items per page |
|
| 106 | - ) ); |
|
| 104 | + 'current' => max(1, get_query_var('paged')), |
|
| 105 | + 'total' => ceil(give_count_donations_of_donor() / 20) // 20 items per page |
|
| 106 | + )); |
|
| 107 | 107 | ?> |
| 108 | 108 | </div> |
| 109 | 109 | <?php wp_reset_postdata(); ?> |
| 110 | 110 | <?php else : ?> |
| 111 | - <?php Give()->notices->print_frontend_notice( esc_html__( 'It looks like you haven\'t made any donations.', 'give' ), true, 'success' ); ?> |
|
| 111 | + <?php Give()->notices->print_frontend_notice(esc_html__('It looks like you haven\'t made any donations.', 'give'), true, 'success'); ?> |
|
| 112 | 112 | <?php endif; |
@@ -75,8 +75,11 @@ discard block |
||
| 75 | 75 | ) : ?> |
| 76 | 76 | <a href="<?php echo esc_url( add_query_arg( 'payment_key', give_get_payment_key( $post->ID ), give_get_history_page_uri() ) ); ?>"><span |
| 77 | 77 | class="give-donation-status <?php echo $post->post_status; ?>"><?php echo esc_html__( 'View', 'give' ) . ' ' . give_get_payment_status( $post, true ) . ' »'; ?></span></a> |
| 78 | - <?php else : ?> |
|
| 79 | - <a href="<?php echo esc_url( add_query_arg( 'payment_key', give_get_payment_key( $post->ID ), give_get_history_page_uri() ) ); ?>"><?php esc_html_e( 'View Receipt »', 'give' ); ?></a> |
|
| 78 | + <?php else { |
|
| 79 | + : ?> |
|
| 80 | + <a href="<?php echo esc_url( add_query_arg( 'payment_key', give_get_payment_key( $post->ID ), give_get_history_page_uri() ) ); |
|
| 81 | +} |
|
| 82 | +?>"><?php esc_html_e( 'View Receipt »', 'give' ); ?></a> |
|
| 80 | 83 | <?php endif; ?> |
| 81 | 84 | </td> |
| 82 | 85 | <?php |
@@ -107,6 +110,9 @@ discard block |
||
| 107 | 110 | ?> |
| 108 | 111 | </div> |
| 109 | 112 | <?php wp_reset_postdata(); ?> |
| 110 | -<?php else : ?> |
|
| 111 | - <?php Give()->notices->print_frontend_notice( esc_html__( 'It looks like you haven\'t made any donations.', 'give' ), true, 'success' ); ?> |
|
| 113 | +<?php else { |
|
| 114 | + : ?> |
|
| 115 | + <?php Give()->notices->print_frontend_notice( esc_html__( 'It looks like you haven\'t made any donations.', 'give' ), true, 'success' ); |
|
| 116 | +} |
|
| 117 | +?> |
|
| 112 | 118 | <?php endif; |