@@ -9,13 +9,13 @@ 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 | |
| 16 | 16 | // Load WP_List_Table if not loaded |
| 17 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
| 18 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
| 17 | +if ( ! class_exists('WP_List_Table')) { |
|
| 18 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -44,13 +44,13 @@ discard block |
||
| 44 | 44 | global $status, $page; |
| 45 | 45 | |
| 46 | 46 | // Set parent defaults |
| 47 | - parent::__construct( array( |
|
| 48 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
| 49 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
| 47 | + parent::__construct(array( |
|
| 48 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
| 49 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
| 50 | 50 | 'ajax' => false // Does this table support ajax? |
| 51 | - ) ); |
|
| 51 | + )); |
|
| 52 | 52 | |
| 53 | - add_action( 'give_log_view_actions', array( $this, 'give_forms_filter' ) ); |
|
| 53 | + add_action('give_log_view_actions', array($this, 'give_forms_filter')); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
@@ -64,37 +64,37 @@ discard block |
||
| 64 | 64 | * |
| 65 | 65 | * @return string Column Name |
| 66 | 66 | */ |
| 67 | - public function column_default( $item, $column_name ) { |
|
| 67 | + public function column_default($item, $column_name) { |
|
| 68 | 68 | |
| 69 | - $payment = give_get_payment_by( 'id', $item['payment_id'] ); |
|
| 69 | + $payment = give_get_payment_by('id', $item['payment_id']); |
|
| 70 | 70 | |
| 71 | - switch ( $column_name ) { |
|
| 71 | + switch ($column_name) { |
|
| 72 | 72 | case 'form' : |
| 73 | - return '<a href="' . esc_url( add_query_arg( 'form', $item[ $column_name ] ) ) . '" >' . get_the_title( $item[ $column_name ] ) . '</a>'; |
|
| 73 | + return '<a href="'.esc_url(add_query_arg('form', $item[$column_name])).'" >'.get_the_title($item[$column_name]).'</a>'; |
|
| 74 | 74 | |
| 75 | 75 | case 'user_id' : |
| 76 | - return '<a href="' . |
|
| 77 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . ( ! empty( $item['user_id'] ) ? urlencode( $item['user_id'] ) : give_get_payment_user_email( $item['payment_id'] ) ) ) . |
|
| 78 | - '">' . $item['user_name'] . '</a>'; |
|
| 76 | + return '<a href="'. |
|
| 77 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='.( ! empty($item['user_id']) ? urlencode($item['user_id']) : give_get_payment_user_email($item['payment_id']))). |
|
| 78 | + '">'.$item['user_name'].'</a>'; |
|
| 79 | 79 | |
| 80 | 80 | case 'amount' : |
| 81 | - return give_currency_filter( give_format_amount( $item['amount'] ) ); |
|
| 81 | + return give_currency_filter(give_format_amount($item['amount'])); |
|
| 82 | 82 | |
| 83 | 83 | case 'status' : |
| 84 | 84 | |
| 85 | - $value = '<div class="give-donation-status status-' . sanitize_title( give_get_payment_status( $payment, true ) ) . '"><span class="give-donation-status-icon"></span> ' . give_get_payment_status( $payment, true ) . '</div>'; |
|
| 85 | + $value = '<div class="give-donation-status status-'.sanitize_title(give_get_payment_status($payment, true)).'"><span class="give-donation-status-icon"></span> '.give_get_payment_status($payment, true).'</div>'; |
|
| 86 | 86 | |
| 87 | - if ( $payment->mode == 'test' ) { |
|
| 88 | - $value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="' . esc_attr__( 'This donation was made in test mode.', 'give' ) . '">' . esc_html__( 'Test', 'give' ) . '</span>'; |
|
| 87 | + if ($payment->mode == 'test') { |
|
| 88 | + $value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="'.esc_attr__('This donation was made in test mode.', 'give').'">'.esc_html__('Test', 'give').'</span>'; |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | return $value; |
| 92 | 92 | |
| 93 | 93 | case 'payment_id' : |
| 94 | - return '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $item['payment_id'] ) . '">' . give_get_payment_number( $item['payment_id'] ) . '</a>'; |
|
| 94 | + return '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$item['payment_id']).'">'.give_get_payment_number($item['payment_id']).'</a>'; |
|
| 95 | 95 | |
| 96 | 96 | default: |
| 97 | - return $item[ $column_name ]; |
|
| 97 | + return $item[$column_name]; |
|
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | |
@@ -107,13 +107,13 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | public function get_columns() { |
| 109 | 109 | $columns = array( |
| 110 | - 'ID' => esc_html__( 'Log ID', 'give' ), |
|
| 111 | - 'user_id' => esc_html__( 'Donor', 'give' ), |
|
| 110 | + 'ID' => esc_html__('Log ID', 'give'), |
|
| 111 | + 'user_id' => esc_html__('Donor', 'give'), |
|
| 112 | 112 | 'form' => give_get_forms_label_singular(), |
| 113 | - 'amount' => esc_html__( 'Donation Amount', 'give' ), |
|
| 114 | - 'status' => esc_html__( 'Status', 'give' ), |
|
| 115 | - 'payment_id' => esc_html__( 'Transaction ID', 'give' ), |
|
| 116 | - 'date' => esc_html__( 'Date', 'give' ) |
|
| 113 | + 'amount' => esc_html__('Donation Amount', 'give'), |
|
| 114 | + 'status' => esc_html__('Status', 'give'), |
|
| 115 | + 'payment_id' => esc_html__('Transaction ID', 'give'), |
|
| 116 | + 'date' => esc_html__('Date', 'give') |
|
| 117 | 117 | ); |
| 118 | 118 | |
| 119 | 119 | return $columns; |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * @return int Current page number |
| 128 | 128 | */ |
| 129 | 129 | public function get_paged() { |
| 130 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
| 130 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | * @return mixed int If User ID, string If Email/Login |
| 139 | 139 | */ |
| 140 | 140 | public function get_filtered_user() { |
| 141 | - return isset( $_GET['user'] ) ? absint( $_GET['user'] ) : false; |
|
| 141 | + return isset($_GET['user']) ? absint($_GET['user']) : false; |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | * @return int Download ID |
| 150 | 150 | */ |
| 151 | 151 | public function get_filtered_give_form() { |
| 152 | - return ! empty( $_GET['form'] ) ? absint( $_GET['form'] ) : false; |
|
| 152 | + return ! empty($_GET['form']) ? absint($_GET['form']) : false; |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | * @return mixed string If search is present, false otherwise |
| 161 | 161 | */ |
| 162 | 162 | public function get_search() { |
| 163 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
| 163 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | |
@@ -176,20 +176,20 @@ discard block |
||
| 176 | 176 | * |
| 177 | 177 | * @param string $which |
| 178 | 178 | */ |
| 179 | - protected function display_tablenav( $which ) { |
|
| 179 | + protected function display_tablenav($which) { |
|
| 180 | 180 | |
| 181 | - if ( 'top' === $which ) { |
|
| 182 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
| 181 | + if ('top' === $which) { |
|
| 182 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
| 183 | 183 | } |
| 184 | 184 | ?> |
| 185 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
| 185 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
| 186 | 186 | |
| 187 | 187 | <div class="alignleft actions bulkactions"> |
| 188 | - <?php $this->bulk_actions( $which ); ?> |
|
| 188 | + <?php $this->bulk_actions($which); ?> |
|
| 189 | 189 | </div> |
| 190 | 190 | <?php |
| 191 | - $this->extra_tablenav( $which ); |
|
| 192 | - $this->pagination( $which ); |
|
| 191 | + $this->extra_tablenav($which); |
|
| 192 | + $this->pagination($which); |
|
| 193 | 193 | ?> |
| 194 | 194 | |
| 195 | 195 | <br class="clear"/> |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | |
| 213 | 213 | $meta_query = array(); |
| 214 | 214 | |
| 215 | - if ( $user ) { |
|
| 215 | + if ($user) { |
|
| 216 | 216 | // Show only logs from a specific user |
| 217 | 217 | $meta_query[] = array( |
| 218 | 218 | 'key' => '_give_log_user_id', |
@@ -221,8 +221,8 @@ discard block |
||
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | $search = $this->get_search(); |
| 224 | - if ( $search ) { |
|
| 225 | - if ( is_email( $search ) ) { |
|
| 224 | + if ($search) { |
|
| 225 | + if (is_email($search)) { |
|
| 226 | 226 | // This is an email search. We use this to ensure it works for guest users and logged-in users |
| 227 | 227 | $key = '_give_log_user_info'; |
| 228 | 228 | $compare = 'LIKE'; |
@@ -231,32 +231,32 @@ discard block |
||
| 231 | 231 | $key = '_give_log_user_id'; |
| 232 | 232 | $compare = 'LIKE'; |
| 233 | 233 | |
| 234 | - if ( ! is_numeric( $search ) ) { |
|
| 234 | + if ( ! is_numeric($search)) { |
|
| 235 | 235 | // Searching for user by username |
| 236 | - $user = get_user_by( 'login', $search ); |
|
| 236 | + $user = get_user_by('login', $search); |
|
| 237 | 237 | |
| 238 | - if ( $user ) { |
|
| 238 | + if ($user) { |
|
| 239 | 239 | // Found one, set meta value to user's ID |
| 240 | 240 | $search = $user->ID; |
| 241 | 241 | } else { |
| 242 | 242 | // No user found so let's do a real search query |
| 243 | - $users = new WP_User_Query( array( |
|
| 243 | + $users = new WP_User_Query(array( |
|
| 244 | 244 | 'search' => $search, |
| 245 | - 'search_columns' => array( 'user_url', 'user_nicename' ), |
|
| 245 | + 'search_columns' => array('user_url', 'user_nicename'), |
|
| 246 | 246 | 'number' => 1, |
| 247 | 247 | 'fields' => 'ids' |
| 248 | - ) ); |
|
| 248 | + )); |
|
| 249 | 249 | |
| 250 | 250 | $found_user = $users->get_results(); |
| 251 | 251 | |
| 252 | - if ( $found_user ) { |
|
| 252 | + if ($found_user) { |
|
| 253 | 253 | $search = $found_user[0]; |
| 254 | 254 | } |
| 255 | 255 | } |
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - if ( ! $this->file_search ) { |
|
| 259 | + if ( ! $this->file_search) { |
|
| 260 | 260 | // Meta query only works for non file name searche |
| 261 | 261 | $meta_query[] = array( |
| 262 | 262 | 'key' => $key, |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | * @since 1.0 |
| 278 | 278 | * @return void |
| 279 | 279 | */ |
| 280 | - function bulk_actions( $which = '' ) { |
|
| 280 | + function bulk_actions($which = '') { |
|
| 281 | 281 | give_log_views(); |
| 282 | 282 | } |
| 283 | 283 | |
@@ -289,22 +289,22 @@ discard block |
||
| 289 | 289 | * @return void |
| 290 | 290 | */ |
| 291 | 291 | public function give_forms_filter() { |
| 292 | - $give_forms = get_posts( array( |
|
| 292 | + $give_forms = get_posts(array( |
|
| 293 | 293 | 'post_type' => 'give_forms', |
| 294 | 294 | 'post_status' => 'any', |
| 295 | - 'posts_per_page' => - 1, |
|
| 295 | + 'posts_per_page' => -1, |
|
| 296 | 296 | 'orderby' => 'title', |
| 297 | 297 | 'order' => 'ASC', |
| 298 | 298 | 'fields' => 'ids', |
| 299 | 299 | 'update_post_meta_cache' => false, |
| 300 | 300 | 'update_post_term_cache' => false |
| 301 | - ) ); |
|
| 301 | + )); |
|
| 302 | 302 | |
| 303 | - if ( $give_forms ) { |
|
| 303 | + if ($give_forms) { |
|
| 304 | 304 | echo '<select name="form" id="give-log-form-filter">'; |
| 305 | - echo '<option value="0">' . esc_html__( 'All', 'give' ) . '</option>'; |
|
| 306 | - foreach ( $give_forms as $form ) { |
|
| 307 | - echo '<option value="' . $form . '"' . selected( $form, $this->get_filtered_give_form() ) . '>' . esc_html( get_the_title( $form ) ) . '</option>'; |
|
| 305 | + echo '<option value="0">'.esc_html__('All', 'give').'</option>'; |
|
| 306 | + foreach ($give_forms as $form) { |
|
| 307 | + echo '<option value="'.$form.'"'.selected($form, $this->get_filtered_give_form()).'>'.esc_html(get_the_title($form)).'</option>'; |
|
| 308 | 308 | } |
| 309 | 309 | echo '</select>'; |
| 310 | 310 | } |
@@ -322,11 +322,11 @@ discard block |
||
| 322 | 322 | global $give_logs; |
| 323 | 323 | |
| 324 | 324 | // Prevent the queries from getting cached. Without this there are occasional memory issues for some installs |
| 325 | - wp_suspend_cache_addition( true ); |
|
| 325 | + wp_suspend_cache_addition(true); |
|
| 326 | 326 | |
| 327 | 327 | $logs_data = array(); |
| 328 | 328 | $paged = $this->get_paged(); |
| 329 | - $give_form = empty( $_GET['s'] ) ? $this->get_filtered_give_form() : null; |
|
| 329 | + $give_form = empty($_GET['s']) ? $this->get_filtered_give_form() : null; |
|
| 330 | 330 | $user = $this->get_filtered_user(); |
| 331 | 331 | |
| 332 | 332 | $log_query = array( |
@@ -336,26 +336,26 @@ discard block |
||
| 336 | 336 | 'meta_query' => $this->get_meta_query() |
| 337 | 337 | ); |
| 338 | 338 | |
| 339 | - $logs = $give_logs->get_connected_logs( $log_query ); |
|
| 339 | + $logs = $give_logs->get_connected_logs($log_query); |
|
| 340 | 340 | |
| 341 | - if ( $logs ) { |
|
| 342 | - foreach ( $logs as $log ) { |
|
| 343 | - $payment_id = get_post_meta( $log->ID, '_give_log_payment_id', true ); |
|
| 341 | + if ($logs) { |
|
| 342 | + foreach ($logs as $log) { |
|
| 343 | + $payment_id = get_post_meta($log->ID, '_give_log_payment_id', true); |
|
| 344 | 344 | |
| 345 | 345 | // Make sure this payment hasn't been deleted |
| 346 | - if ( get_post( $payment_id ) ) : |
|
| 347 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
| 348 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
| 349 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
| 346 | + if (get_post($payment_id)) : |
|
| 347 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
| 348 | + $payment_meta = give_get_payment_meta($payment_id); |
|
| 349 | + $payment_amount = give_get_payment_amount($payment_id); |
|
| 350 | 350 | |
| 351 | 351 | $logs_data[] = array( |
| 352 | - 'ID' => '<span class="give-item-label give-item-label-gray">' . $log->ID . '</span>', |
|
| 352 | + 'ID' => '<span class="give-item-label give-item-label-gray">'.$log->ID.'</span>', |
|
| 353 | 353 | 'payment_id' => $payment_id, |
| 354 | 354 | 'form' => $log->post_parent, |
| 355 | 355 | 'amount' => $payment_amount, |
| 356 | 356 | 'user_id' => $user_info['id'], |
| 357 | - 'user_name' => $user_info['first_name'] . ' ' . $user_info['last_name'], |
|
| 358 | - 'date' => get_post_field( 'post_date', $payment_id ) |
|
| 357 | + 'user_name' => $user_info['first_name'].' '.$user_info['last_name'], |
|
| 358 | + 'date' => get_post_field('post_date', $payment_id) |
|
| 359 | 359 | ); |
| 360 | 360 | |
| 361 | 361 | endif; |
@@ -384,15 +384,15 @@ discard block |
||
| 384 | 384 | $columns = $this->get_columns(); |
| 385 | 385 | $hidden = array(); |
| 386 | 386 | $sortable = $this->get_sortable_columns(); |
| 387 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
| 387 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
| 388 | 388 | $current_page = $this->get_pagenum(); |
| 389 | 389 | $this->items = $this->get_logs(); |
| 390 | - $total_items = $give_logs->get_log_count( $this->get_filtered_give_form(), 'sale', $this->get_meta_query() ); |
|
| 390 | + $total_items = $give_logs->get_log_count($this->get_filtered_give_form(), 'sale', $this->get_meta_query()); |
|
| 391 | 391 | |
| 392 | - $this->set_pagination_args( array( |
|
| 392 | + $this->set_pagination_args(array( |
|
| 393 | 393 | 'total_items' => $total_items, |
| 394 | 394 | 'per_page' => $this->per_page, |
| 395 | - 'total_pages' => ceil( $total_items / $this->per_page ) |
|
| 395 | + 'total_pages' => ceil($total_items / $this->per_page) |
|
| 396 | 396 | ) |
| 397 | 397 | ); |
| 398 | 398 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * @return void |
| 24 | 24 | */ |
| 25 | 25 | function give_logs_view_sales() { |
| 26 | - include( dirname( __FILE__ ) . '/class-sales-logs-list-table.php' ); |
|
| 26 | + include(dirname(__FILE__).'/class-sales-logs-list-table.php'); |
|
| 27 | 27 | |
| 28 | 28 | $logs_table = new Give_Sales_Log_Table(); |
| 29 | 29 | $logs_table->prepare_items(); |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | -add_action( 'give_logs_view_sales', 'give_logs_view_sales' ); |
|
| 34 | +add_action('give_logs_view_sales', 'give_logs_view_sales'); |
|
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -43,14 +43,14 @@ discard block |
||
| 43 | 43 | * @return void |
| 44 | 44 | */ |
| 45 | 45 | function give_logs_view_gateway_errors() { |
| 46 | - include( dirname( __FILE__ ) . '/class-gateway-error-logs-list-table.php' ); |
|
| 46 | + include(dirname(__FILE__).'/class-gateway-error-logs-list-table.php'); |
|
| 47 | 47 | |
| 48 | 48 | $logs_table = new Give_Gateway_Error_Log_Table(); |
| 49 | 49 | $logs_table->prepare_items(); |
| 50 | 50 | $logs_table->display(); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | -add_action( 'give_logs_view_gateway_errors', 'give_logs_view_gateway_errors' ); |
|
| 53 | +add_action('give_logs_view_gateway_errors', 'give_logs_view_gateway_errors'); |
|
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | 56 | * API Request Logs |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | * @return void |
| 63 | 63 | */ |
| 64 | 64 | function give_logs_view_api_requests() { |
| 65 | - include( dirname( __FILE__ ) . '/class-api-requests-logs-list-table.php' ); |
|
| 65 | + include(dirname(__FILE__).'/class-api-requests-logs-list-table.php'); |
|
| 66 | 66 | |
| 67 | 67 | $logs_table = new Give_API_Request_Log_Table(); |
| 68 | 68 | $logs_table->prepare_items(); |
@@ -75,12 +75,12 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * @since 1.0 |
| 77 | 77 | */ |
| 78 | - do_action( 'give_logs_api_requests_top' ); |
|
| 78 | + do_action('give_logs_api_requests_top'); |
|
| 79 | 79 | ?> |
| 80 | 80 | |
| 81 | - <form id="give-logs-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=logs' ); ?>"> |
|
| 81 | + <form id="give-logs-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-reports&tab=logs'); ?>"> |
|
| 82 | 82 | <?php |
| 83 | - $logs_table->search_box( esc_html__( 'Search', 'give' ), 'give-api-requests' ); |
|
| 83 | + $logs_table->search_box(esc_html__('Search', 'give'), 'give-api-requests'); |
|
| 84 | 84 | $logs_table->display(); |
| 85 | 85 | ?> |
| 86 | 86 | <input type="hidden" name="post_type" value="give_forms"/> |
@@ -93,14 +93,14 @@ discard block |
||
| 93 | 93 | * |
| 94 | 94 | * @since 1.0 |
| 95 | 95 | */ |
| 96 | - do_action( 'give_logs_api_requests_bottom' ); |
|
| 96 | + do_action('give_logs_api_requests_bottom'); |
|
| 97 | 97 | ?> |
| 98 | 98 | |
| 99 | 99 | </div> |
| 100 | 100 | <?php |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | -add_action( 'give_logs_view_api_requests', 'give_logs_view_api_requests' ); |
|
| 103 | +add_action('give_logs_view_api_requests', 'give_logs_view_api_requests'); |
|
| 104 | 104 | |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -111,12 +111,12 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | function give_log_default_views() { |
| 113 | 113 | $views = array( |
| 114 | - 'sales' => esc_html__( 'Donations', 'give' ), |
|
| 115 | - 'gateway_errors' => esc_html__( 'Payment Errors', 'give' ), |
|
| 116 | - 'api_requests' => esc_html__( 'API Requests', 'give' ) |
|
| 114 | + 'sales' => esc_html__('Donations', 'give'), |
|
| 115 | + 'gateway_errors' => esc_html__('Payment Errors', 'give'), |
|
| 116 | + 'api_requests' => esc_html__('API Requests', 'give') |
|
| 117 | 117 | ); |
| 118 | 118 | |
| 119 | - $views = apply_filters( 'give_log_views', $views ); |
|
| 119 | + $views = apply_filters('give_log_views', $views); |
|
| 120 | 120 | |
| 121 | 121 | return $views; |
| 122 | 122 | } |
@@ -129,13 +129,13 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | function give_log_views() { |
| 131 | 131 | $views = give_log_default_views(); |
| 132 | - $current_view = isset( $_GET['view'] ) && array_key_exists( $_GET['view'], give_log_default_views() ) ? sanitize_text_field( $_GET['view'] ) : 'sales'; |
|
| 132 | + $current_view = isset($_GET['view']) && array_key_exists($_GET['view'], give_log_default_views()) ? sanitize_text_field($_GET['view']) : 'sales'; |
|
| 133 | 133 | ?> |
| 134 | 134 | <form id="give-logs-filter" method="get" action="edit.php"> |
| 135 | 135 | <select id="give-logs-view" name="view"> |
| 136 | 136 | <optgroup label="Log Type:"> |
| 137 | - <?php foreach ( $views as $view_id => $label ): ?> |
|
| 138 | - <option value="<?php echo esc_attr( $view_id ); ?>" <?php selected( $view_id, $current_view ); ?>><?php echo $label; ?></option> |
|
| 137 | + <?php foreach ($views as $view_id => $label): ?> |
|
| 138 | + <option value="<?php echo esc_attr($view_id); ?>" <?php selected($view_id, $current_view); ?>><?php echo $label; ?></option> |
|
| 139 | 139 | <?php endforeach; ?> |
| 140 | 140 | </optgroup> |
| 141 | 141 | </select> |
@@ -148,14 +148,14 @@ discard block |
||
| 148 | 148 | * |
| 149 | 149 | * @since 1.0 |
| 150 | 150 | */ |
| 151 | - do_action( 'give_log_view_actions' ); |
|
| 151 | + do_action('give_log_view_actions'); |
|
| 152 | 152 | ?> |
| 153 | 153 | |
| 154 | 154 | <input type="hidden" name="post_type" value="give_forms"/> |
| 155 | 155 | <input type="hidden" name="page" value="give-reports"/> |
| 156 | 156 | <input type="hidden" name="tab" value="logs"/> |
| 157 | 157 | |
| 158 | - <?php submit_button( esc_html__( 'Apply', 'give' ), 'secondary', 'submit', false ); ?> |
|
| 158 | + <?php submit_button(esc_html__('Apply', 'give'), 'secondary', 'submit', false); ?> |
|
| 159 | 159 | </form> |
| 160 | 160 | <?php |
| 161 | 161 | } |
| 162 | 162 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -22,11 +22,11 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | function give_process_batch_export_form() { |
| 24 | 24 | |
| 25 | - if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'give-batch-export' ) ) { |
|
| 26 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 25 | + if ( ! wp_verify_nonce($_REQUEST['nonce'], 'give-batch-export')) { |
|
| 26 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export.php'; |
|
| 29 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export.php'; |
|
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * Fires before batch export. |
@@ -35,14 +35,14 @@ discard block |
||
| 35 | 35 | * |
| 36 | 36 | * @param atring $class Export class. |
| 37 | 37 | */ |
| 38 | - do_action( 'give_batch_export_class_include', $_REQUEST['class'] ); |
|
| 38 | + do_action('give_batch_export_class_include', $_REQUEST['class']); |
|
| 39 | 39 | |
| 40 | 40 | $export = new $_REQUEST['class']; |
| 41 | 41 | $export->export(); |
| 42 | 42 | |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | -add_action( 'give_form_batch_export', 'give_process_batch_export_form' ); |
|
| 45 | +add_action('give_form_batch_export', 'give_process_batch_export_form'); |
|
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * Exports earnings for a specified time period |
@@ -53,14 +53,14 @@ discard block |
||
| 53 | 53 | * @return void |
| 54 | 54 | */ |
| 55 | 55 | function give_export_earnings() { |
| 56 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export-earnings.php'; |
|
| 56 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export-earnings.php'; |
|
| 57 | 57 | |
| 58 | 58 | $earnings_export = new Give_Earnings_Export(); |
| 59 | 59 | |
| 60 | 60 | $earnings_export->export(); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | -add_action( 'give_earnings_export', 'give_export_earnings' ); |
|
| 63 | +add_action('give_earnings_export', 'give_export_earnings'); |
|
| 64 | 64 | |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -73,14 +73,14 @@ discard block |
||
| 73 | 73 | * @return void |
| 74 | 74 | */ |
| 75 | 75 | function give_export_all_customers() { |
| 76 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export-customers.php'; |
|
| 76 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export-customers.php'; |
|
| 77 | 77 | |
| 78 | 78 | $customer_export = new Give_Donors_Export(); |
| 79 | 79 | |
| 80 | 80 | $customer_export->export(); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | -add_action( 'give_email_export', 'give_export_all_customers' ); |
|
| 83 | +add_action('give_email_export', 'give_export_all_customers'); |
|
| 84 | 84 | |
| 85 | 85 | /** |
| 86 | 86 | * Add a hook allowing extensions to register a hook on the batch export process |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * @return void |
| 90 | 90 | */ |
| 91 | 91 | function give_register_batch_exporters() { |
| 92 | - if ( is_admin() ) { |
|
| 92 | + if (is_admin()) { |
|
| 93 | 93 | /** |
| 94 | 94 | * Fires in the admin, while plugins loaded. |
| 95 | 95 | * |
@@ -99,21 +99,21 @@ discard block |
||
| 99 | 99 | * |
| 100 | 100 | * @param string $class Export class. |
| 101 | 101 | */ |
| 102 | - do_action( 'give_register_batch_exporter' ); |
|
| 102 | + do_action('give_register_batch_exporter'); |
|
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | -add_action( 'plugins_loaded', 'give_register_batch_exporters' ); |
|
| 106 | +add_action('plugins_loaded', 'give_register_batch_exporters'); |
|
| 107 | 107 | |
| 108 | 108 | /** |
| 109 | 109 | * Register the payments batch exporter |
| 110 | 110 | * @since 1.5 |
| 111 | 111 | */ |
| 112 | 112 | function give_register_payments_batch_export() { |
| 113 | - add_action( 'give_batch_export_class_include', 'give_include_payments_batch_processor', 10, 1 ); |
|
| 113 | + add_action('give_batch_export_class_include', 'give_include_payments_batch_processor', 10, 1); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | -add_action( 'give_register_batch_exporter', 'give_register_payments_batch_export', 10 ); |
|
| 116 | +add_action('give_register_batch_exporter', 'give_register_payments_batch_export', 10); |
|
| 117 | 117 | |
| 118 | 118 | /** |
| 119 | 119 | * Loads the payments batch process if needed |
@@ -124,10 +124,10 @@ discard block |
||
| 124 | 124 | * |
| 125 | 125 | * @return void |
| 126 | 126 | */ |
| 127 | -function give_include_payments_batch_processor( $class ) { |
|
| 127 | +function give_include_payments_batch_processor($class) { |
|
| 128 | 128 | |
| 129 | - if ( 'Give_Batch_Payments_Export' === $class ) { |
|
| 130 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-payments.php'; |
|
| 129 | + if ('Give_Batch_Payments_Export' === $class) { |
|
| 130 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-payments.php'; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | } |
@@ -137,10 +137,10 @@ discard block |
||
| 137 | 137 | * @since 1.5.2 |
| 138 | 138 | */ |
| 139 | 139 | function give_register_customers_batch_export() { |
| 140 | - add_action( 'give_batch_export_class_include', 'give_include_customers_batch_processor', 10, 1 ); |
|
| 140 | + add_action('give_batch_export_class_include', 'give_include_customers_batch_processor', 10, 1); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | -add_action( 'give_register_batch_exporter', 'give_register_customers_batch_export', 10 ); |
|
| 143 | +add_action('give_register_batch_exporter', 'give_register_customers_batch_export', 10); |
|
| 144 | 144 | |
| 145 | 145 | /** |
| 146 | 146 | * Loads the customers batch process if needed |
@@ -151,10 +151,10 @@ discard block |
||
| 151 | 151 | * |
| 152 | 152 | * @return void |
| 153 | 153 | */ |
| 154 | -function give_include_customers_batch_processor( $class ) { |
|
| 154 | +function give_include_customers_batch_processor($class) { |
|
| 155 | 155 | |
| 156 | - if ( 'Give_Batch_Customers_Export' === $class ) { |
|
| 157 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-customers.php'; |
|
| 156 | + if ('Give_Batch_Customers_Export' === $class) { |
|
| 157 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-customers.php'; |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | } |
@@ -165,10 +165,10 @@ discard block |
||
| 165 | 165 | * @since 1.5 |
| 166 | 166 | */ |
| 167 | 167 | function give_register_forms_batch_export() { |
| 168 | - add_action( 'give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1 ); |
|
| 168 | + add_action('give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | -add_action( 'give_register_batch_exporter', 'give_register_forms_batch_export', 10 ); |
|
| 171 | +add_action('give_register_batch_exporter', 'give_register_forms_batch_export', 10); |
|
| 172 | 172 | |
| 173 | 173 | /** |
| 174 | 174 | * Loads the file downloads batch process if needed |
@@ -179,10 +179,10 @@ discard block |
||
| 179 | 179 | * |
| 180 | 180 | * @return void |
| 181 | 181 | */ |
| 182 | -function give_include_forms_batch_processor( $class ) { |
|
| 182 | +function give_include_forms_batch_processor($class) { |
|
| 183 | 183 | |
| 184 | - if ( 'Give_Batch_Forms_Export' === $class ) { |
|
| 185 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-forms.php'; |
|
| 184 | + if ('Give_Batch_Forms_Export' === $class) { |
|
| 185 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-forms.php'; |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | } |
| 189 | 189 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | function give_tools_recount_stats_display() { |
| 24 | 24 | |
| 25 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
| 25 | + if ( ! current_user_can('manage_give_settings')) { |
|
| 26 | 26 | return; |
| 27 | 27 | } |
| 28 | 28 | |
@@ -31,27 +31,27 @@ discard block |
||
| 31 | 31 | * |
| 32 | 32 | * @since 1.5 |
| 33 | 33 | */ |
| 34 | - do_action( 'give_tools_recount_stats_before' ); |
|
| 34 | + do_action('give_tools_recount_stats_before'); |
|
| 35 | 35 | ?> |
| 36 | 36 | <div id="poststuff"> |
| 37 | 37 | <div class="postbox"> |
| 38 | 38 | |
| 39 | - <h2 class="hndle ui-sortable-handle"><span><?php esc_html_e( 'Recount Stats', 'give' ); ?></span></h2> |
|
| 39 | + <h2 class="hndle ui-sortable-handle"><span><?php esc_html_e('Recount Stats', 'give'); ?></span></h2> |
|
| 40 | 40 | |
| 41 | 41 | <div class="inside recount-stats-controls"> |
| 42 | - <p><?php esc_html_e( 'Use these tools to recount stats, delete test transactions, or reset stats.', 'give' ); ?></p> |
|
| 42 | + <p><?php esc_html_e('Use these tools to recount stats, delete test transactions, or reset stats.', 'give'); ?></p> |
|
| 43 | 43 | <form method="post" id="give-tools-recount-form" class="give-export-form"> |
| 44 | 44 | |
| 45 | - <?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?> |
|
| 45 | + <?php wp_nonce_field('give_ajax_export', 'give_ajax_export'); ?> |
|
| 46 | 46 | |
| 47 | 47 | <select name="give-export-class" id="recount-stats-type"> |
| 48 | - <option value="0" selected="selected" disabled="disabled"><?php esc_html_e( 'Please select an option', 'give' ); ?></option> |
|
| 49 | - <option data-type="recount-stats" value="Give_Tools_Recount_Income"><?php esc_html_e( 'Recalculate Total Donation Income Amount', 'give' ); ?></option> |
|
| 50 | - <option data-type="recount-form" value="Give_Tools_Recount_Form_Stats"><?php esc_html_e( 'Recalculate Income Amount and Donation Counts for a Form', 'give' ); ?></option> |
|
| 51 | - <option data-type="recount-all" value="Give_Tools_Recount_All_Stats"><?php esc_html_e( 'Recalculate Income Amount and Donation Counts for All Forms', 'give' ); ?></option> |
|
| 52 | - <option data-type="recount-customer-stats" value="Give_Tools_Recount_Customer_Stats"><?php esc_html_e( 'Recalculate Donor Statistics', 'give' ); ?></option> |
|
| 53 | - <option data-type="delete-test-transactions" value="Give_Tools_Delete_Test_Transactions"><?php esc_html_e( 'Delete Test Transactions', 'give' ); ?></option> |
|
| 54 | - <option data-type="reset-stats" value="Give_Tools_Reset_Stats"><?php esc_html_e( 'Delete All Data', 'give' ); ?></option> |
|
| 48 | + <option value="0" selected="selected" disabled="disabled"><?php esc_html_e('Please select an option', 'give'); ?></option> |
|
| 49 | + <option data-type="recount-stats" value="Give_Tools_Recount_Income"><?php esc_html_e('Recalculate Total Donation Income Amount', 'give'); ?></option> |
|
| 50 | + <option data-type="recount-form" value="Give_Tools_Recount_Form_Stats"><?php esc_html_e('Recalculate Income Amount and Donation Counts for a Form', 'give'); ?></option> |
|
| 51 | + <option data-type="recount-all" value="Give_Tools_Recount_All_Stats"><?php esc_html_e('Recalculate Income Amount and Donation Counts for All Forms', 'give'); ?></option> |
|
| 52 | + <option data-type="recount-customer-stats" value="Give_Tools_Recount_Customer_Stats"><?php esc_html_e('Recalculate Donor Statistics', 'give'); ?></option> |
|
| 53 | + <option data-type="delete-test-transactions" value="Give_Tools_Delete_Test_Transactions"><?php esc_html_e('Delete Test Transactions', 'give'); ?></option> |
|
| 54 | + <option data-type="reset-stats" value="Give_Tools_Reset_Stats"><?php esc_html_e('Delete All Data', 'give'); ?></option> |
|
| 55 | 55 | <?php |
| 56 | 56 | /** |
| 57 | 57 | * Fires in the recount stats selectbox. |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @since 1.5 |
| 62 | 62 | */ |
| 63 | - do_action( 'give_recount_tool_options' ); |
|
| 63 | + do_action('give_recount_tool_options'); |
|
| 64 | 64 | ?> |
| 65 | 65 | </select> |
| 66 | 66 | |
@@ -68,34 +68,34 @@ discard block |
||
| 68 | 68 | <?php |
| 69 | 69 | $args = array( |
| 70 | 70 | 'name' => 'form_id', |
| 71 | - 'number' => - 1, |
|
| 71 | + 'number' => -1, |
|
| 72 | 72 | 'chosen' => true, |
| 73 | 73 | ); |
| 74 | - echo Give()->html->forms_dropdown( $args ); |
|
| 74 | + echo Give()->html->forms_dropdown($args); |
|
| 75 | 75 | ?> |
| 76 | 76 | </span> |
| 77 | 77 | |
| 78 | - <input type="submit" id="recount-stats-submit" value="<?php esc_attr_e( 'Submit', 'give' ); ?>" class="button-secondary"/> |
|
| 78 | + <input type="submit" id="recount-stats-submit" value="<?php esc_attr_e('Submit', 'give'); ?>" class="button-secondary"/> |
|
| 79 | 79 | |
| 80 | 80 | <br/> |
| 81 | 81 | |
| 82 | 82 | <span class="give-recount-stats-descriptions"> |
| 83 | - <span id="recount-stats"><?php esc_html_e( 'Recalculates the overall donation income amount.', 'give' ); ?></span> |
|
| 83 | + <span id="recount-stats"><?php esc_html_e('Recalculates the overall donation income amount.', 'give'); ?></span> |
|
| 84 | 84 | <span id="recount-form"><?php |
| 85 | 85 | printf( |
| 86 | 86 | /* translators: %s: form singular label */ |
| 87 | - esc_html__( 'Recalculates the donation and income stats for a specific %s.', 'give' ), |
|
| 88 | - give_get_forms_label_singular( true ) |
|
| 87 | + esc_html__('Recalculates the donation and income stats for a specific %s.', 'give'), |
|
| 88 | + give_get_forms_label_singular(true) |
|
| 89 | 89 | ); |
| 90 | 90 | ?></span> |
| 91 | 91 | <span id="recount-all"><?php |
| 92 | 92 | printf( |
| 93 | 93 | /* translators: %s: form plural label */ |
| 94 | - esc_html__( 'Recalculates the earnings and sales stats for all %s.', 'give' ), |
|
| 95 | - give_get_forms_label_plural( true ) |
|
| 94 | + esc_html__('Recalculates the earnings and sales stats for all %s.', 'give'), |
|
| 95 | + give_get_forms_label_plural(true) |
|
| 96 | 96 | ); |
| 97 | 97 | ?></span> |
| 98 | - <span id="recount-customer-stats"><?php esc_html_e( 'Recalculates the lifetime value and donation counts for all donors.', 'give' ); ?></span> |
|
| 98 | + <span id="recount-customer-stats"><?php esc_html_e('Recalculates the lifetime value and donation counts for all donors.', 'give'); ?></span> |
|
| 99 | 99 | <?php |
| 100 | 100 | /** |
| 101 | 101 | * Fires in the recount stats description area. |
@@ -104,10 +104,10 @@ discard block |
||
| 104 | 104 | * |
| 105 | 105 | * @since 1.5 |
| 106 | 106 | */ |
| 107 | - do_action( 'give_recount_tool_descriptions' ); |
|
| 107 | + do_action('give_recount_tool_descriptions'); |
|
| 108 | 108 | ?> |
| 109 | - <span id="delete-test-transactions"><?php _e( '<strong>Deletes</strong> all TEST donations, donors, and related log entries.', 'give' ); ?></span> |
|
| 110 | - <span id="reset-stats"><?php _e( '<strong>Deletes</strong> ALL donations, donors, and related log entries regardless of test or live mode.', 'give' ); ?></span> |
|
| 109 | + <span id="delete-test-transactions"><?php _e('<strong>Deletes</strong> all TEST donations, donors, and related log entries.', 'give'); ?></span> |
|
| 110 | + <span id="reset-stats"><?php _e('<strong>Deletes</strong> ALL donations, donors, and related log entries regardless of test or live mode.', 'give'); ?></span> |
|
| 111 | 111 | </span> |
| 112 | 112 | |
| 113 | 113 | <span class="spinner"></span> |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * |
| 122 | 122 | * @since 1.5 |
| 123 | 123 | */ |
| 124 | - do_action( 'give_tools_recount_forms' ); |
|
| 124 | + do_action('give_tools_recount_forms'); |
|
| 125 | 125 | ?> |
| 126 | 126 | </div><!-- .inside --> |
| 127 | 127 | </div><!-- .postbox --> |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | * |
| 133 | 133 | * @since 1.5 |
| 134 | 134 | */ |
| 135 | - do_action( 'give_tools_recount_stats_after' ); |
|
| 135 | + do_action('give_tools_recount_stats_after'); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | -add_action( 'give_reports_tab_tools', 'give_tools_recount_stats_display' ); |
|
| 138 | +add_action('give_reports_tab_tools', 'give_tools_recount_stats_display'); |
|
@@ -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,9 +27,9 @@ discard block |
||
| 27 | 27 | * @since 1.0 |
| 28 | 28 | */ |
| 29 | 29 | public function __construct() { |
| 30 | - add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
| 31 | - add_action( 'give_dismiss_notices', array( $this, 'dismiss_notices' ) ); |
|
| 32 | - add_action( 'admin_bar_menu', array( $this, 'give_admin_bar_menu' ), 1000 ); |
|
| 30 | + add_action('admin_notices', array($this, 'show_notices')); |
|
| 31 | + add_action('give_dismiss_notices', array($this, 'dismiss_notices')); |
|
| 32 | + add_action('admin_bar_menu', array($this, 'give_admin_bar_menu'), 1000); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | |
@@ -41,18 +41,18 @@ discard block |
||
| 41 | 41 | public function give_admin_bar_menu() { |
| 42 | 42 | global $wp_admin_bar; |
| 43 | 43 | |
| 44 | - if ( ! give_is_test_mode() || ! current_user_can( 'view_give_reports' ) ) { |
|
| 44 | + if ( ! give_is_test_mode() || ! current_user_can('view_give_reports')) { |
|
| 45 | 45 | return false; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | //Add the main siteadmin menu item. |
| 49 | - $wp_admin_bar->add_menu( array( |
|
| 49 | + $wp_admin_bar->add_menu(array( |
|
| 50 | 50 | 'id' => 'give-test-notice', |
| 51 | - 'href' => admin_url() . 'edit.php?post_type=give_forms&page=give-settings&tab=gateways', |
|
| 51 | + 'href' => admin_url().'edit.php?post_type=give_forms&page=give-settings&tab=gateways', |
|
| 52 | 52 | 'parent' => 'top-secondary', |
| 53 | - 'title' => esc_html__( 'Give Test Mode Active', 'give' ), |
|
| 54 | - 'meta' => array( 'class' => 'give-test-mode-active' ), |
|
| 55 | - ) ); |
|
| 53 | + 'title' => esc_html__('Give Test Mode Active', 'give'), |
|
| 54 | + 'meta' => array('class' => 'give-test-mode-active'), |
|
| 55 | + )); |
|
| 56 | 56 | |
| 57 | 57 | } |
| 58 | 58 | |
@@ -67,98 +67,98 @@ discard block |
||
| 67 | 67 | 'error' => array() |
| 68 | 68 | ); |
| 69 | 69 | |
| 70 | - if ( ! give_test_ajax_works() && ! get_user_meta( get_current_user_id(), '_give_admin_ajax_inaccessible_dismissed', true ) && current_user_can( 'manage_give_settings' ) ) { |
|
| 70 | + if ( ! give_test_ajax_works() && ! get_user_meta(get_current_user_id(), '_give_admin_ajax_inaccessible_dismissed', true) && current_user_can('manage_give_settings')) { |
|
| 71 | 71 | echo '<div class="error">'; |
| 72 | - echo '<p>' . esc_html__( 'Your site appears to be blocking the WordPress ajax interface. This may cause issues with Give.', 'give' ) . '</p>'; |
|
| 72 | + echo '<p>'.esc_html__('Your site appears to be blocking the WordPress ajax interface. This may cause issues with Give.', 'give').'</p>'; |
|
| 73 | 73 | /* translators: %s: https://givewp.com/documentation/core/troubleshooting/admin-ajax-blocked/ */ |
| 74 | - echo '<p>' . sprintf( __( 'Please see <a href="%s" target="_blank">this reference</a> for possible solutions.', 'give' ), esc_url( 'https://givewp.com/documentation/core/troubleshooting/admin-ajax-blocked/' ) ) . '</p>'; |
|
| 75 | - echo '<p><a href="' . add_query_arg( array( |
|
| 74 | + echo '<p>'.sprintf(__('Please see <a href="%s" target="_blank">this reference</a> for possible solutions.', 'give'), esc_url('https://givewp.com/documentation/core/troubleshooting/admin-ajax-blocked/')).'</p>'; |
|
| 75 | + echo '<p><a href="'.add_query_arg(array( |
|
| 76 | 76 | 'give_action' => 'dismiss_notices', |
| 77 | 77 | 'give_notice' => 'admin_ajax_inaccessible' |
| 78 | - ) ) . '">' . esc_attr__( 'Dismiss Notice', 'give' ) . '</a></p>'; |
|
| 78 | + )).'">'.esc_attr__('Dismiss Notice', 'give').'</a></p>'; |
|
| 79 | 79 | echo '</div>'; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | |
| 83 | - if ( isset( $_GET['give-message'] ) ) { |
|
| 83 | + if (isset($_GET['give-message'])) { |
|
| 84 | 84 | |
| 85 | 85 | // Donation reports errors. |
| 86 | - if ( current_user_can( 'view_give_reports' ) ) { |
|
| 87 | - switch ( $_GET['give-message'] ) { |
|
| 86 | + if (current_user_can('view_give_reports')) { |
|
| 87 | + switch ($_GET['give-message']) { |
|
| 88 | 88 | case 'payment_deleted' : |
| 89 | - $notices['updated']['give-payment-deleted'] = esc_attr__( 'The donation has been deleted.', 'give' ); |
|
| 89 | + $notices['updated']['give-payment-deleted'] = esc_attr__('The donation has been deleted.', 'give'); |
|
| 90 | 90 | break; |
| 91 | 91 | case 'email_sent' : |
| 92 | - $notices['updated']['give-payment-sent'] = esc_attr__( 'The donation receipt has been resent.', 'give' ); |
|
| 92 | + $notices['updated']['give-payment-sent'] = esc_attr__('The donation receipt has been resent.', 'give'); |
|
| 93 | 93 | break; |
| 94 | 94 | case 'refreshed-reports' : |
| 95 | - $notices['updated']['give-refreshed-reports'] = esc_attr__( 'The reports cache has been cleared.', 'give' ); |
|
| 95 | + $notices['updated']['give-refreshed-reports'] = esc_attr__('The reports cache has been cleared.', 'give'); |
|
| 96 | 96 | break; |
| 97 | 97 | case 'payment-note-deleted' : |
| 98 | - $notices['updated']['give-payment-note-deleted'] = esc_attr__( 'The donation note has been deleted.', 'give' ); |
|
| 98 | + $notices['updated']['give-payment-note-deleted'] = esc_attr__('The donation note has been deleted.', 'give'); |
|
| 99 | 99 | break; |
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | // Give settings notices and errors. |
| 104 | - if ( current_user_can( 'manage_give_settings' ) ) { |
|
| 105 | - switch ( $_GET['give-message'] ) { |
|
| 104 | + if (current_user_can('manage_give_settings')) { |
|
| 105 | + switch ($_GET['give-message']) { |
|
| 106 | 106 | case 'settings-imported' : |
| 107 | - $notices['updated']['give-settings-imported'] = esc_attr__( 'The settings have been imported.', 'give' ); |
|
| 107 | + $notices['updated']['give-settings-imported'] = esc_attr__('The settings have been imported.', 'give'); |
|
| 108 | 108 | break; |
| 109 | 109 | case 'api-key-generated' : |
| 110 | - $notices['updated']['give-api-key-generated'] = esc_attr__( 'API keys have been generated.', 'give' ); |
|
| 110 | + $notices['updated']['give-api-key-generated'] = esc_attr__('API keys have been generated.', 'give'); |
|
| 111 | 111 | break; |
| 112 | 112 | case 'api-key-exists' : |
| 113 | - $notices['error']['give-api-key-exists'] = esc_attr__( 'The specified user already has API keys.', 'give' ); |
|
| 113 | + $notices['error']['give-api-key-exists'] = esc_attr__('The specified user already has API keys.', 'give'); |
|
| 114 | 114 | break; |
| 115 | 115 | case 'api-key-regenerated' : |
| 116 | - $notices['updated']['give-api-key-regenerated'] = esc_attr__( 'API keys have been regenerated.', 'give' ); |
|
| 116 | + $notices['updated']['give-api-key-regenerated'] = esc_attr__('API keys have been regenerated.', 'give'); |
|
| 117 | 117 | break; |
| 118 | 118 | case 'api-key-revoked' : |
| 119 | - $notices['updated']['give-api-key-revoked'] = esc_attr__( 'API keys have been revoked.', 'give' ); |
|
| 119 | + $notices['updated']['give-api-key-revoked'] = esc_attr__('API keys have been revoked.', 'give'); |
|
| 120 | 120 | break; |
| 121 | 121 | case 'sent-test-email' : |
| 122 | - $notices['updated']['give-sent-test-email'] = esc_attr__( 'The test email has been sent.', 'give' ); |
|
| 122 | + $notices['updated']['give-sent-test-email'] = esc_attr__('The test email has been sent.', 'give'); |
|
| 123 | 123 | break; |
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | // Payments errors. |
| 127 | - if ( current_user_can( 'edit_give_payments' ) ) { |
|
| 128 | - switch ( $_GET['give-message'] ) { |
|
| 127 | + if (current_user_can('edit_give_payments')) { |
|
| 128 | + switch ($_GET['give-message']) { |
|
| 129 | 129 | case 'note-added' : |
| 130 | - $notices['updated']['give-note-added'] = esc_attr__( 'The donation note has been added.', 'give' ); |
|
| 130 | + $notices['updated']['give-note-added'] = esc_attr__('The donation note has been added.', 'give'); |
|
| 131 | 131 | break; |
| 132 | 132 | case 'payment-updated' : |
| 133 | - $notices['updated']['give-payment-updated'] = esc_attr__( 'The donation has been updated.', 'give' ); |
|
| 133 | + $notices['updated']['give-payment-updated'] = esc_attr__('The donation has been updated.', 'give'); |
|
| 134 | 134 | break; |
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | // Customer Notices. |
| 139 | - if ( current_user_can( 'edit_give_payments' ) ) { |
|
| 140 | - switch ( $_GET['give-message'] ) { |
|
| 139 | + if (current_user_can('edit_give_payments')) { |
|
| 140 | + switch ($_GET['give-message']) { |
|
| 141 | 141 | case 'customer-deleted' : |
| 142 | - $notices['updated']['give-customer-deleted'] = esc_attr__( 'The donor has been deleted.', 'give' ); |
|
| 142 | + $notices['updated']['give-customer-deleted'] = esc_attr__('The donor has been deleted.', 'give'); |
|
| 143 | 143 | break; |
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - if ( count( $notices['updated'] ) > 0 ) { |
|
| 150 | - foreach ( $notices['updated'] as $notice => $message ) { |
|
| 151 | - add_settings_error( 'give-notices', $notice, $message, 'updated' ); |
|
| 149 | + if (count($notices['updated']) > 0) { |
|
| 150 | + foreach ($notices['updated'] as $notice => $message) { |
|
| 151 | + add_settings_error('give-notices', $notice, $message, 'updated'); |
|
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - if ( count( $notices['error'] ) > 0 ) { |
|
| 156 | - foreach ( $notices['error'] as $notice => $message ) { |
|
| 157 | - add_settings_error( 'give-notices', $notice, $message, 'error' ); |
|
| 155 | + if (count($notices['error']) > 0) { |
|
| 156 | + foreach ($notices['error'] as $notice => $message) { |
|
| 157 | + add_settings_error('give-notices', $notice, $message, 'error'); |
|
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - settings_errors( 'give-notices' ); |
|
| 161 | + settings_errors('give-notices'); |
|
| 162 | 162 | |
| 163 | 163 | } |
| 164 | 164 | |
@@ -170,8 +170,8 @@ discard block |
||
| 170 | 170 | * @return void |
| 171 | 171 | */ |
| 172 | 172 | function give_admin_addons_notices() { |
| 173 | - add_settings_error( 'give-notices', 'give-addons-feed-error', esc_attr__( 'There seems to be an issue with the server. Please try again in a few minutes.', 'give' ), 'error' ); |
|
| 174 | - settings_errors( 'give-notices' ); |
|
| 173 | + add_settings_error('give-notices', 'give-addons-feed-error', esc_attr__('There seems to be an issue with the server. Please try again in a few minutes.', 'give'), 'error'); |
|
| 174 | + settings_errors('give-notices'); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | |
@@ -182,9 +182,9 @@ discard block |
||
| 182 | 182 | * @return void |
| 183 | 183 | */ |
| 184 | 184 | function dismiss_notices() { |
| 185 | - if ( isset( $_GET['give_notice'] ) ) { |
|
| 186 | - update_user_meta( get_current_user_id(), '_give_' . $_GET['give_notice'] . '_dismissed', 1 ); |
|
| 187 | - wp_redirect( remove_query_arg( array( 'give_action', 'give_notice' ) ) ); |
|
| 185 | + if (isset($_GET['give_notice'])) { |
|
| 186 | + update_user_meta(get_current_user_id(), '_give_'.$_GET['give_notice'].'_dismissed', 1); |
|
| 187 | + wp_redirect(remove_query_arg(array('give_action', 'give_notice'))); |
|
| 188 | 188 | exit; |
| 189 | 189 | } |
| 190 | 190 | } |
@@ -10,11 +10,11 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -if ( ! defined( 'ABSPATH' ) ) {
|
|
| 13 | +if ( ! defined('ABSPATH')) {
|
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | -add_filter( 'cmb2_meta_boxes', 'give_single_forms_cmb2_metaboxes' ); |
|
| 17 | +add_filter('cmb2_meta_boxes', 'give_single_forms_cmb2_metaboxes');
|
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * Define the metabox and field configurations. |
@@ -23,23 +23,23 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return array |
| 25 | 25 | */ |
| 26 | -function give_single_forms_cmb2_metaboxes( array $meta_boxes ) {
|
|
| 26 | +function give_single_forms_cmb2_metaboxes(array $meta_boxes) {
|
|
| 27 | 27 | |
| 28 | 28 | $post_id = give_get_admin_post_id(); |
| 29 | - $price = give_get_form_price( $post_id ); |
|
| 30 | - $custom_amount_minimum = give_get_form_minimum_price( $post_id ); |
|
| 31 | - $goal = give_get_form_goal( $post_id ); |
|
| 32 | - $variable_pricing = give_has_variable_prices( $post_id ); |
|
| 33 | - $prices = give_get_variable_prices( $post_id ); |
|
| 29 | + $price = give_get_form_price($post_id); |
|
| 30 | + $custom_amount_minimum = give_get_form_minimum_price($post_id); |
|
| 31 | + $goal = give_get_form_goal($post_id); |
|
| 32 | + $variable_pricing = give_has_variable_prices($post_id); |
|
| 33 | + $prices = give_get_variable_prices($post_id); |
|
| 34 | 34 | |
| 35 | 35 | //No empty prices - min. 1.00 for new forms |
| 36 | - if ( empty( $price ) && is_null( $post_id ) ) {
|
|
| 37 | - $price = esc_attr( give_format_amount( '1.00' ) ); |
|
| 36 | + if (empty($price) && is_null($post_id)) {
|
|
| 37 | + $price = esc_attr(give_format_amount('1.00'));
|
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | //Min. $1.00 for new forms |
| 41 | - if ( empty( $custom_amount_minimum ) ) {
|
|
| 42 | - $custom_amount_minimum = esc_attr( give_format_amount( '1.00' ) ); |
|
| 41 | + if (empty($custom_amount_minimum)) {
|
|
| 42 | + $custom_amount_minimum = esc_attr(give_format_amount('1.00'));
|
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | // Start with an underscore to hide fields from custom fields list |
@@ -48,327 +48,327 @@ discard block |
||
| 48 | 48 | /** |
| 49 | 49 | * Repeatable Field Groups |
| 50 | 50 | */ |
| 51 | - $meta_boxes['form_field_options'] = apply_filters( 'give_forms_field_options', array( |
|
| 51 | + $meta_boxes['form_field_options'] = apply_filters('give_forms_field_options', array(
|
|
| 52 | 52 | 'id' => 'form_field_options', |
| 53 | - 'title' => esc_html__( 'Donation Options', 'give' ), |
|
| 54 | - 'object_types' => array( 'give_forms' ), |
|
| 53 | + 'title' => esc_html__('Donation Options', 'give'),
|
|
| 54 | + 'object_types' => array('give_forms'),
|
|
| 55 | 55 | 'context' => 'normal', |
| 56 | 56 | 'priority' => 'high', //Show above Content WYSIWYG |
| 57 | - 'fields' => apply_filters( 'give_forms_donation_form_metabox_fields', array( |
|
| 57 | + 'fields' => apply_filters('give_forms_donation_form_metabox_fields', array(
|
|
| 58 | 58 | //Donation Option |
| 59 | 59 | array( |
| 60 | - 'name' => esc_html__( 'Donation Option', 'give' ), |
|
| 61 | - 'description' => esc_html__( 'Would you like this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give' ), |
|
| 62 | - 'id' => $prefix . 'price_option', |
|
| 60 | + 'name' => esc_html__('Donation Option', 'give'),
|
|
| 61 | + 'description' => esc_html__('Would you like this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give'),
|
|
| 62 | + 'id' => $prefix.'price_option', |
|
| 63 | 63 | 'type' => 'radio_inline', |
| 64 | 64 | 'default' => 'set', |
| 65 | - 'options' => apply_filters( 'give_forms_price_options', array( |
|
| 66 | - 'set' => esc_html__( 'Set Donation', 'give' ), |
|
| 67 | - 'multi' => esc_html__( 'Multi-level Donation', 'give' ), |
|
| 68 | - ) ), |
|
| 65 | + 'options' => apply_filters('give_forms_price_options', array(
|
|
| 66 | + 'set' => esc_html__('Set Donation', 'give'),
|
|
| 67 | + 'multi' => esc_html__('Multi-level Donation', 'give'),
|
|
| 68 | + )), |
|
| 69 | 69 | ), |
| 70 | 70 | array( |
| 71 | - 'name' => esc_html__( 'Set Donation', 'give' ), |
|
| 72 | - 'description' => esc_html__( 'This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give' ), |
|
| 73 | - 'id' => $prefix . 'set_price', |
|
| 71 | + 'name' => esc_html__('Set Donation', 'give'),
|
|
| 72 | + 'description' => esc_html__('This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give'),
|
|
| 73 | + 'id' => $prefix.'set_price', |
|
| 74 | 74 | 'type' => 'text_small', |
| 75 | 75 | 'row_classes' => 'give-subfield', |
| 76 | 76 | 'render_row_cb' => 'give_cmb_amount_field_render_row_cb', |
| 77 | 77 | 'sanitization_cb' => 'give_sanitize_price_field_value', |
| 78 | 78 | 'attributes' => array( |
| 79 | - 'placeholder' => give_format_decimal( '1.00' ), |
|
| 80 | - 'value' => give_format_decimal( $price ), |
|
| 79 | + 'placeholder' => give_format_decimal('1.00'),
|
|
| 80 | + 'value' => give_format_decimal($price), |
|
| 81 | 81 | 'class' => 'cmb-type-text-small give-money-field', |
| 82 | 82 | ), |
| 83 | 83 | ), |
| 84 | 84 | //Donation levels: Header |
| 85 | 85 | array( |
| 86 | - 'id' => $prefix . 'levels_header', |
|
| 86 | + 'id' => $prefix.'levels_header', |
|
| 87 | 87 | 'type' => 'levels_repeater_header', |
| 88 | 88 | ), |
| 89 | 89 | //Donation Levels: Repeatable CMB2 Group |
| 90 | 90 | array( |
| 91 | - 'id' => $prefix . 'donation_levels', |
|
| 91 | + 'id' => $prefix.'donation_levels', |
|
| 92 | 92 | 'type' => 'group', |
| 93 | 93 | 'row_classes' => 'give-subfield', |
| 94 | 94 | 'options' => array( |
| 95 | - 'add_button' => esc_html__( 'Add Level', 'give' ), |
|
| 95 | + 'add_button' => esc_html__('Add Level', 'give'),
|
|
| 96 | 96 | 'remove_button' => '<span class="dashicons dashicons-no"></span>', |
| 97 | 97 | 'sortable' => true, // beta |
| 98 | 98 | ), |
| 99 | 99 | // Fields array works the same, except id's only need to be unique for this group. Prefix is not needed. |
| 100 | - 'fields' => apply_filters( 'give_donation_levels_table_row', array( |
|
| 100 | + 'fields' => apply_filters('give_donation_levels_table_row', array(
|
|
| 101 | 101 | array( |
| 102 | - 'name' => esc_html__( 'ID', 'give' ), |
|
| 103 | - 'id' => $prefix . 'id', |
|
| 102 | + 'name' => esc_html__('ID', 'give'),
|
|
| 103 | + 'id' => $prefix.'id', |
|
| 104 | 104 | 'type' => 'levels_id', |
| 105 | 105 | ), |
| 106 | 106 | array( |
| 107 | - 'name' => esc_html__( 'Amount', 'give' ), |
|
| 108 | - 'id' => $prefix . 'amount', |
|
| 107 | + 'name' => esc_html__('Amount', 'give'),
|
|
| 108 | + 'id' => $prefix.'amount', |
|
| 109 | 109 | 'type' => 'text_small', |
| 110 | - 'before_field' => give_get_option( 'currency_position' ) == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '', |
|
| 111 | - 'after_field' => give_get_option( 'currency_position' ) == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '', |
|
| 110 | + 'before_field' => give_get_option('currency_position') == 'before' ? '<span class="give-money-symbol give-money-symbol-before">'.give_currency_symbol().'</span>' : '',
|
|
| 111 | + 'after_field' => give_get_option('currency_position') == 'after' ? '<span class="give-money-symbol give-money-symbol-after">'.give_currency_symbol().'</span>' : '',
|
|
| 112 | 112 | 'sanitization_cb' => 'give_sanitize_price_field_value', |
| 113 | 113 | 'attributes' => array( |
| 114 | - 'placeholder' => give_format_decimal( '1.00' ), |
|
| 114 | + 'placeholder' => give_format_decimal('1.00'),
|
|
| 115 | 115 | 'class' => 'cmb-type-text-small give-money-field', |
| 116 | 116 | ), |
| 117 | 117 | 'before' => 'give_format_admin_multilevel_amount', |
| 118 | 118 | ), |
| 119 | 119 | array( |
| 120 | - 'name' => esc_html__( 'Text', 'give' ), |
|
| 121 | - 'id' => $prefix . 'text', |
|
| 120 | + 'name' => esc_html__('Text', 'give'),
|
|
| 121 | + 'id' => $prefix.'text', |
|
| 122 | 122 | 'type' => 'text', |
| 123 | 123 | 'attributes' => array( |
| 124 | - 'placeholder' => esc_html__( 'Donation Level', 'give' ), |
|
| 124 | + 'placeholder' => esc_html__('Donation Level', 'give'),
|
|
| 125 | 125 | 'class' => 'give-multilevel-text-field', |
| 126 | 126 | ), |
| 127 | 127 | ), |
| 128 | 128 | array( |
| 129 | - 'name' => esc_html__( 'Default', 'give' ), |
|
| 130 | - 'id' => $prefix . 'default', |
|
| 129 | + 'name' => esc_html__('Default', 'give'),
|
|
| 130 | + 'id' => $prefix.'default', |
|
| 131 | 131 | 'type' => 'give_default_radio_inline' |
| 132 | 132 | ), |
| 133 | - ) ), |
|
| 133 | + )), |
|
| 134 | 134 | ), |
| 135 | 135 | //Display Style |
| 136 | 136 | array( |
| 137 | - 'name' => esc_html__( 'Display Style', 'give' ), |
|
| 138 | - 'description' => esc_html__( 'Set how the donations levels will display on the form.', 'give' ), |
|
| 139 | - 'id' => $prefix . 'display_style', |
|
| 137 | + 'name' => esc_html__('Display Style', 'give'),
|
|
| 138 | + 'description' => esc_html__('Set how the donations levels will display on the form.', 'give'),
|
|
| 139 | + 'id' => $prefix.'display_style', |
|
| 140 | 140 | 'type' => 'radio_inline', |
| 141 | 141 | 'default' => 'buttons', |
| 142 | 142 | 'options' => array( |
| 143 | - 'buttons' => esc_html__( 'Buttons', 'give' ), |
|
| 144 | - 'radios' => esc_html__( 'Radios', 'give' ), |
|
| 145 | - 'dropdown' => esc_html__( 'Dropdown', 'give' ), |
|
| 143 | + 'buttons' => esc_html__('Buttons', 'give'),
|
|
| 144 | + 'radios' => esc_html__('Radios', 'give'),
|
|
| 145 | + 'dropdown' => esc_html__('Dropdown', 'give'),
|
|
| 146 | 146 | ), |
| 147 | 147 | ), |
| 148 | 148 | //Custom Amount |
| 149 | 149 | array( |
| 150 | - 'name' => esc_html__( 'Custom Amount', 'give' ), |
|
| 151 | - 'description' => esc_html__( 'Do you want the user to be able to input their own donation amount?', 'give' ), |
|
| 152 | - 'id' => $prefix . 'custom_amount', |
|
| 150 | + 'name' => esc_html__('Custom Amount', 'give'),
|
|
| 151 | + 'description' => esc_html__('Do you want the user to be able to input their own donation amount?', 'give'),
|
|
| 152 | + 'id' => $prefix.'custom_amount', |
|
| 153 | 153 | 'type' => 'radio_inline', |
| 154 | 154 | 'default' => 'no', |
| 155 | 155 | 'options' => array( |
| 156 | - 'yes' => esc_html__( 'Yes', 'give' ), |
|
| 157 | - 'no' => esc_html__( 'No', 'give' ), |
|
| 156 | + 'yes' => esc_html__('Yes', 'give'),
|
|
| 157 | + 'no' => esc_html__('No', 'give'),
|
|
| 158 | 158 | ), |
| 159 | 159 | ), |
| 160 | 160 | array( |
| 161 | - 'name' => esc_html__( 'Custom Amount Minimum', 'give' ), |
|
| 162 | - 'description' => esc_html__( 'If you would like to set a minimum custom donation amount please enter it here.', 'give' ), |
|
| 163 | - 'id' => $prefix . 'custom_amount_minimum', |
|
| 161 | + 'name' => esc_html__('Custom Amount Minimum', 'give'),
|
|
| 162 | + 'description' => esc_html__('If you would like to set a minimum custom donation amount please enter it here.', 'give'),
|
|
| 163 | + 'id' => $prefix.'custom_amount_minimum', |
|
| 164 | 164 | 'type' => 'text_small', |
| 165 | 165 | 'row_classes' => 'give-subfield', |
| 166 | 166 | 'render_row_cb' => 'give_cmb_amount_field_render_row_cb', |
| 167 | 167 | 'sanitization_cb' => 'give_sanitize_price_field_value', |
| 168 | 168 | 'attributes' => array( |
| 169 | 169 | 'placeholder' => give_format_decimal('1.00'),
|
| 170 | - 'value' => give_format_decimal( $custom_amount_minimum ), |
|
| 170 | + 'value' => give_format_decimal($custom_amount_minimum), |
|
| 171 | 171 | 'class' => 'cmb-type-text-small give-money-field', |
| 172 | 172 | ) |
| 173 | 173 | ), |
| 174 | 174 | array( |
| 175 | - 'name' => esc_html__( 'Custom Amount Text', 'give' ), |
|
| 176 | - 'description' => esc_html__( 'This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option).', 'give' ), |
|
| 177 | - 'id' => $prefix . 'custom_amount_text', |
|
| 175 | + 'name' => esc_html__('Custom Amount Text', 'give'),
|
|
| 176 | + 'description' => esc_html__('This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option).', 'give'),
|
|
| 177 | + 'id' => $prefix.'custom_amount_text', |
|
| 178 | 178 | 'type' => 'text', |
| 179 | 179 | 'row_classes' => 'give-subfield', |
| 180 | 180 | 'attributes' => array( |
| 181 | 181 | 'rows' => 3, |
| 182 | - 'placeholder' => esc_attr__( 'Give a Custom Amount', 'give' ), |
|
| 182 | + 'placeholder' => esc_attr__('Give a Custom Amount', 'give'),
|
|
| 183 | 183 | ), |
| 184 | 184 | ), |
| 185 | 185 | //Goals |
| 186 | 186 | array( |
| 187 | - 'name' => esc_html__( 'Goal', 'give' ), |
|
| 188 | - 'description' => esc_html__( 'Do you want to set a donation goal for this form?', 'give' ), |
|
| 189 | - 'id' => $prefix . 'goal_option', |
|
| 187 | + 'name' => esc_html__('Goal', 'give'),
|
|
| 188 | + 'description' => esc_html__('Do you want to set a donation goal for this form?', 'give'),
|
|
| 189 | + 'id' => $prefix.'goal_option', |
|
| 190 | 190 | 'type' => 'radio_inline', |
| 191 | 191 | 'default' => 'no', |
| 192 | 192 | 'options' => array( |
| 193 | - 'yes' => esc_html__( 'Yes', 'give' ), |
|
| 194 | - 'no' => esc_html__( 'No', 'give' ), |
|
| 193 | + 'yes' => esc_html__('Yes', 'give'),
|
|
| 194 | + 'no' => esc_html__('No', 'give'),
|
|
| 195 | 195 | ), |
| 196 | 196 | ), |
| 197 | 197 | array( |
| 198 | - 'name' => esc_html__( 'Goal Amount', 'give' ), |
|
| 199 | - 'description' => esc_html__( 'This is the monetary goal amount you want to reach for this donation form.', 'give' ), |
|
| 200 | - 'id' => $prefix . 'set_goal', |
|
| 198 | + 'name' => esc_html__('Goal Amount', 'give'),
|
|
| 199 | + 'description' => esc_html__('This is the monetary goal amount you want to reach for this donation form.', 'give'),
|
|
| 200 | + 'id' => $prefix.'set_goal', |
|
| 201 | 201 | 'type' => 'text_small', |
| 202 | 202 | 'row_classes' => 'give-subfield', |
| 203 | 203 | 'render_row_cb' => 'give_cmb_amount_field_render_row_cb', |
| 204 | 204 | 'sanitization_cb' => 'give_sanitize_price_field_value', |
| 205 | 205 | 'attributes' => array( |
| 206 | - 'placeholder' => give_format_decimal( '0.00' ), |
|
| 207 | - 'value' => give_format_decimal( $goal ), |
|
| 206 | + 'placeholder' => give_format_decimal('0.00'),
|
|
| 207 | + 'value' => give_format_decimal($goal), |
|
| 208 | 208 | 'class' => 'cmb-type-text-small give-money-field', |
| 209 | 209 | ), |
| 210 | 210 | ), |
| 211 | 211 | |
| 212 | 212 | array( |
| 213 | - 'name' => esc_html__( 'Goal Format', 'give' ), |
|
| 214 | - 'description' => esc_html__( 'Would you like to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded".', 'give' ), |
|
| 215 | - 'id' => $prefix . 'goal_format', |
|
| 213 | + 'name' => esc_html__('Goal Format', 'give'),
|
|
| 214 | + 'description' => esc_html__('Would you like to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded".', 'give'),
|
|
| 215 | + 'id' => $prefix.'goal_format', |
|
| 216 | 216 | 'type' => 'radio_inline', |
| 217 | 217 | 'default' => 'amount', |
| 218 | 218 | 'row_classes' => 'give-subfield', |
| 219 | 219 | 'options' => array( |
| 220 | - 'amount' => esc_html__( 'Amount', 'give' ), |
|
| 221 | - 'percentage' => esc_html__( 'Percentage', 'give' ), |
|
| 220 | + 'amount' => esc_html__('Amount', 'give'),
|
|
| 221 | + 'percentage' => esc_html__('Percentage', 'give'),
|
|
| 222 | 222 | ), |
| 223 | 223 | ), |
| 224 | 224 | array( |
| 225 | - 'name' => esc_html__( 'Goal Progress Bar Color', 'give' ), |
|
| 226 | - 'id' => $prefix . 'goal_color', |
|
| 225 | + 'name' => esc_html__('Goal Progress Bar Color', 'give'),
|
|
| 226 | + 'id' => $prefix.'goal_color', |
|
| 227 | 227 | 'type' => 'colorpicker', |
| 228 | 228 | 'row_classes' => 'give-subfield', |
| 229 | 229 | 'default' => '#2bc253', |
| 230 | 230 | ), |
| 231 | 231 | |
| 232 | 232 | array( |
| 233 | - 'name' => esc_html__( 'Close Form when Goal Achieved', 'give' ), |
|
| 234 | - 'desc' => esc_html__( 'Would you like to close the donation forms and stop accepting donations once this goal has been met?', 'give' ), |
|
| 235 | - 'id' => $prefix . 'close_form_when_goal_achieved', |
|
| 233 | + 'name' => esc_html__('Close Form when Goal Achieved', 'give'),
|
|
| 234 | + 'desc' => esc_html__('Would you like to close the donation forms and stop accepting donations once this goal has been met?', 'give'),
|
|
| 235 | + 'id' => $prefix.'close_form_when_goal_achieved', |
|
| 236 | 236 | 'type' => 'radio_inline', |
| 237 | 237 | 'row_classes' => 'give-subfield', |
| 238 | 238 | 'options' => array( |
| 239 | - 'yes' => esc_html__( 'Yes', 'give' ), |
|
| 240 | - 'no' => esc_html__( 'No', 'give' ), |
|
| 239 | + 'yes' => esc_html__('Yes', 'give'),
|
|
| 240 | + 'no' => esc_html__('No', 'give'),
|
|
| 241 | 241 | ), |
| 242 | 242 | 'default' => 'no', |
| 243 | 243 | ), |
| 244 | 244 | array( |
| 245 | - 'name' => esc_html__( 'Goal Achieved Message', 'give' ), |
|
| 246 | - 'desc' => esc_html__( 'Would you like to display a custom message when the goal is closed? If none is provided the default message will be displayed', 'give' ), |
|
| 247 | - 'id' => $prefix . 'form_goal_achieved_message', |
|
| 245 | + 'name' => esc_html__('Goal Achieved Message', 'give'),
|
|
| 246 | + 'desc' => esc_html__('Would you like to display a custom message when the goal is closed? If none is provided the default message will be displayed', 'give'),
|
|
| 247 | + 'id' => $prefix.'form_goal_achieved_message', |
|
| 248 | 248 | 'type' => 'textarea', |
| 249 | 249 | 'row_classes' => 'give-subfield', |
| 250 | 250 | 'attributes' => array( |
| 251 | - 'placeholder' => esc_attr__( 'Thank you to all our donors, we have met our fundraising goal.', 'give' ), |
|
| 251 | + 'placeholder' => esc_attr__('Thank you to all our donors, we have met our fundraising goal.', 'give'),
|
|
| 252 | 252 | ), |
| 253 | 253 | ) |
| 254 | 254 | ) |
| 255 | 255 | ) |
| 256 | - ) ); |
|
| 256 | + )); |
|
| 257 | 257 | |
| 258 | 258 | |
| 259 | 259 | /** |
| 260 | 260 | * Content Field |
| 261 | 261 | */ |
| 262 | - $meta_boxes['form_content_options'] = apply_filters( 'give_forms_content_options', array( |
|
| 262 | + $meta_boxes['form_content_options'] = apply_filters('give_forms_content_options', array(
|
|
| 263 | 263 | 'id' => 'form_content_options', |
| 264 | - 'title' => esc_html__( 'Form Content', 'give' ), |
|
| 265 | - 'object_types' => array( 'give_forms' ), |
|
| 264 | + 'title' => esc_html__('Form Content', 'give'),
|
|
| 265 | + 'object_types' => array('give_forms'),
|
|
| 266 | 266 | 'context' => 'normal', |
| 267 | 267 | 'priority' => 'high', //Show above Content WYSIWYG |
| 268 | - 'fields' => apply_filters( 'give_forms_content_options_metabox_fields', array( |
|
| 268 | + 'fields' => apply_filters('give_forms_content_options_metabox_fields', array(
|
|
| 269 | 269 | //Donation Option |
| 270 | 270 | array( |
| 271 | - 'name' => esc_html__( 'Display Content', 'give' ), |
|
| 272 | - 'description' => esc_html__( 'Do you want to display content? If you choose to display content, a WYSIWYG editor will appear which you will be able to enter content.', 'give' ), |
|
| 273 | - 'id' => $prefix . 'content_option', |
|
| 271 | + 'name' => esc_html__('Display Content', 'give'),
|
|
| 272 | + 'description' => esc_html__('Do you want to display content? If you choose to display content, a WYSIWYG editor will appear which you will be able to enter content.', 'give'),
|
|
| 273 | + 'id' => $prefix.'content_option', |
|
| 274 | 274 | 'type' => 'select', |
| 275 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
| 276 | - 'none' => esc_html__( 'No Content', 'give' ), |
|
| 277 | - 'give_pre_form' => esc_html__( 'Display content ABOVE the fields', 'give' ), |
|
| 278 | - 'give_post_form' => esc_html__( 'Display content BELOW the fields', 'give' ), |
|
| 275 | + 'options' => apply_filters('give_forms_content_options_select', array(
|
|
| 276 | + 'none' => esc_html__('No Content', 'give'),
|
|
| 277 | + 'give_pre_form' => esc_html__('Display content ABOVE the fields', 'give'),
|
|
| 278 | + 'give_post_form' => esc_html__('Display content BELOW the fields', 'give'),
|
|
| 279 | 279 | ) |
| 280 | 280 | ), |
| 281 | 281 | 'default' => 'none', |
| 282 | 282 | ), |
| 283 | 283 | array( |
| 284 | - 'name' => esc_html__( 'Content', 'give' ), |
|
| 285 | - 'description' => esc_html__( 'This content will display on the single give form page.', 'give' ), |
|
| 286 | - 'id' => $prefix . 'form_content', |
|
| 284 | + 'name' => esc_html__('Content', 'give'),
|
|
| 285 | + 'description' => esc_html__('This content will display on the single give form page.', 'give'),
|
|
| 286 | + 'id' => $prefix.'form_content', |
|
| 287 | 287 | 'row_classes' => 'give-subfield', |
| 288 | 288 | 'type' => 'wysiwyg' |
| 289 | 289 | ), |
| 290 | 290 | ) |
| 291 | 291 | ) |
| 292 | - ) ); |
|
| 292 | + )); |
|
| 293 | 293 | |
| 294 | 294 | |
| 295 | 295 | /** |
| 296 | 296 | * Display Options |
| 297 | 297 | */ |
| 298 | - $meta_boxes['form_display_options'] = apply_filters( 'give_form_display_options', array( |
|
| 298 | + $meta_boxes['form_display_options'] = apply_filters('give_form_display_options', array(
|
|
| 299 | 299 | 'id' => 'form_display_options', |
| 300 | - 'title' => esc_html__( 'Form Display Options', 'give' ), |
|
| 301 | - 'object_types' => array( 'give_forms' ), |
|
| 300 | + 'title' => esc_html__('Form Display Options', 'give'),
|
|
| 301 | + 'object_types' => array('give_forms'),
|
|
| 302 | 302 | 'context' => 'normal', // 'normal', 'advanced', or 'side' |
| 303 | 303 | 'priority' => 'high', //Show above Content WYSIWYG |
| 304 | 304 | 'show_names' => true, // Show field names on the left |
| 305 | - 'fields' => apply_filters( 'give_forms_display_options_metabox_fields', array( |
|
| 305 | + 'fields' => apply_filters('give_forms_display_options_metabox_fields', array(
|
|
| 306 | 306 | array( |
| 307 | - 'name' => esc_html__( 'Payment Fields', 'give' ), |
|
| 308 | - 'desc' => esc_html__( 'How would you like to display donation information for this form? The "Show on Page" option will display the entire form when the page loads. "Reveal Upon Click" places a button below the donation fields and upon click slides into view the rest of the fields. "Modal Window Upon Click" is a similar option, rather than sliding into view the fields they will open in a shadow box or "modal" window.', 'give' ), |
|
| 309 | - 'id' => $prefix . 'payment_display', |
|
| 307 | + 'name' => esc_html__('Payment Fields', 'give'),
|
|
| 308 | + 'desc' => esc_html__('How would you like to display donation information for this form? The "Show on Page" option will display the entire form when the page loads. "Reveal Upon Click" places a button below the donation fields and upon click slides into view the rest of the fields. "Modal Window Upon Click" is a similar option, rather than sliding into view the fields they will open in a shadow box or "modal" window.', 'give'),
|
|
| 309 | + 'id' => $prefix.'payment_display', |
|
| 310 | 310 | 'type' => 'select', |
| 311 | 311 | 'options' => array( |
| 312 | - 'onpage' => esc_html__( 'Show on Page', 'give' ), |
|
| 313 | - 'reveal' => esc_html__( 'Reveal Upon Click', 'give' ), |
|
| 314 | - 'modal' => esc_html__( 'Modal Window Upon Click', 'give' ), |
|
| 312 | + 'onpage' => esc_html__('Show on Page', 'give'),
|
|
| 313 | + 'reveal' => esc_html__('Reveal Upon Click', 'give'),
|
|
| 314 | + 'modal' => esc_html__('Modal Window Upon Click', 'give'),
|
|
| 315 | 315 | ), |
| 316 | 316 | 'default' => 'onpage', |
| 317 | 317 | ), |
| 318 | 318 | array( |
| 319 | - 'id' => $prefix . 'reveal_label', |
|
| 320 | - 'name' => esc_html__( 'Reveal / Modal Open Text', 'give' ), |
|
| 321 | - 'desc' => esc_html__( 'The button label for completing the donation.', 'give' ), |
|
| 319 | + 'id' => $prefix.'reveal_label', |
|
| 320 | + 'name' => esc_html__('Reveal / Modal Open Text', 'give'),
|
|
| 321 | + 'desc' => esc_html__('The button label for completing the donation.', 'give'),
|
|
| 322 | 322 | 'type' => 'text_small', |
| 323 | 323 | 'row_classes' => 'give-subfield', |
| 324 | 324 | 'attributes' => array( |
| 325 | - 'placeholder' => esc_attr__( 'Donate Now', 'give' ), |
|
| 325 | + 'placeholder' => esc_attr__('Donate Now', 'give'),
|
|
| 326 | 326 | ), |
| 327 | 327 | ), |
| 328 | 328 | array( |
| 329 | - 'id' => $prefix . 'checkout_label', |
|
| 330 | - 'name' => esc_html__( 'Complete Donation Text', 'give' ), |
|
| 331 | - 'desc' => esc_html__( 'The button label for completing a donation.', 'give' ), |
|
| 329 | + 'id' => $prefix.'checkout_label', |
|
| 330 | + 'name' => esc_html__('Complete Donation Text', 'give'),
|
|
| 331 | + 'desc' => esc_html__('The button label for completing a donation.', 'give'),
|
|
| 332 | 332 | 'type' => 'text_small', |
| 333 | 333 | 'attributes' => array( |
| 334 | - 'placeholder' => esc_html__( 'Donate Now', 'give' ), |
|
| 334 | + 'placeholder' => esc_html__('Donate Now', 'give'),
|
|
| 335 | 335 | ), |
| 336 | 336 | ), |
| 337 | 337 | array( |
| 338 | - 'name' => esc_html__( 'Default Gateway', 'give' ), |
|
| 339 | - 'desc' => esc_html__( 'By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give' ), |
|
| 340 | - 'id' => $prefix . 'default_gateway', |
|
| 338 | + 'name' => esc_html__('Default Gateway', 'give'),
|
|
| 339 | + 'desc' => esc_html__('By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give'),
|
|
| 340 | + 'id' => $prefix.'default_gateway', |
|
| 341 | 341 | 'type' => 'default_gateway' |
| 342 | 342 | ), |
| 343 | 343 | array( |
| 344 | - 'name' => esc_html__( 'Disable Guest Donations', 'give' ), |
|
| 345 | - 'desc' => esc_html__( 'Do you want to require users be logged-in to make donations?', 'give' ), |
|
| 346 | - 'id' => $prefix . 'logged_in_only', |
|
| 344 | + 'name' => esc_html__('Disable Guest Donations', 'give'),
|
|
| 345 | + 'desc' => esc_html__('Do you want to require users be logged-in to make donations?', 'give'),
|
|
| 346 | + 'id' => $prefix.'logged_in_only', |
|
| 347 | 347 | 'type' => 'checkbox' |
| 348 | 348 | ), |
| 349 | 349 | array( |
| 350 | - 'name' => esc_html__( 'Register / Login Form', 'give' ), |
|
| 351 | - 'desc' => esc_html__( 'Display the registration and login forms in the payment section for non-logged-in users.', 'give' ), |
|
| 352 | - 'id' => $prefix . 'show_register_form', |
|
| 350 | + 'name' => esc_html__('Register / Login Form', 'give'),
|
|
| 351 | + 'desc' => esc_html__('Display the registration and login forms in the payment section for non-logged-in users.', 'give'),
|
|
| 352 | + 'id' => $prefix.'show_register_form', |
|
| 353 | 353 | 'type' => 'select', |
| 354 | 354 | 'options' => array( |
| 355 | - 'both' => esc_html__( 'Registration and Login Forms', 'give' ), |
|
| 356 | - 'registration' => esc_html__( 'Registration Form Only', 'give' ), |
|
| 357 | - 'login' => esc_html__( 'Login Form Only', 'give' ), |
|
| 358 | - 'none' => esc_html__( 'None', 'give' ), |
|
| 355 | + 'both' => esc_html__('Registration and Login Forms', 'give'),
|
|
| 356 | + 'registration' => esc_html__('Registration Form Only', 'give'),
|
|
| 357 | + 'login' => esc_html__('Login Form Only', 'give'),
|
|
| 358 | + 'none' => esc_html__('None', 'give'),
|
|
| 359 | 359 | ), |
| 360 | 360 | 'default' => 'none', |
| 361 | 361 | ), |
| 362 | 362 | array( |
| 363 | - 'name' => esc_html__( 'Floating Labels', 'give' ), |
|
| 363 | + 'name' => esc_html__('Floating Labels', 'give'),
|
|
| 364 | 364 | /* translators: %s: forms https://givewp.com/documentation/core/give-forms/creating-give-forms/#floating-labels */ |
| 365 | - 'desc' => sprintf( __( 'Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form.<br>Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give' ), esc_url( 'https://givewp.com/documentation/core/give-forms/creating-give-forms/#floating-labels' ) ), |
|
| 366 | - 'id' => $prefix . 'form_floating_labels', |
|
| 365 | + 'desc' => sprintf(__('Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form.<br>Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give'), esc_url('https://givewp.com/documentation/core/give-forms/creating-give-forms/#floating-labels')),
|
|
| 366 | + 'id' => $prefix.'form_floating_labels', |
|
| 367 | 367 | 'type' => 'select', |
| 368 | 368 | 'options' => array( |
| 369 | - '' => esc_html__( 'Use the global setting', 'give' ), |
|
| 370 | - 'enabled' => esc_html__( 'Enabled', 'give' ), |
|
| 371 | - 'disabled' => esc_html__( 'Disabled', 'give' ), |
|
| 369 | + '' => esc_html__('Use the global setting', 'give'),
|
|
| 370 | + 'enabled' => esc_html__('Enabled', 'give'),
|
|
| 371 | + 'disabled' => esc_html__('Disabled', 'give'),
|
|
| 372 | 372 | ), |
| 373 | 373 | 'default' => 'none', |
| 374 | 374 | ) |
@@ -380,47 +380,47 @@ discard block |
||
| 380 | 380 | /** |
| 381 | 381 | * Terms & Conditions |
| 382 | 382 | */ |
| 383 | - $meta_boxes['form_terms_options'] = apply_filters( 'give_forms_terms_options', array( |
|
| 383 | + $meta_boxes['form_terms_options'] = apply_filters('give_forms_terms_options', array(
|
|
| 384 | 384 | 'id' => 'form_terms_options', |
| 385 | - 'title' => esc_html__( 'Terms and Conditions', 'give' ), |
|
| 386 | - 'object_types' => array( 'give_forms' ), |
|
| 385 | + 'title' => esc_html__('Terms and Conditions', 'give'),
|
|
| 386 | + 'object_types' => array('give_forms'),
|
|
| 387 | 387 | 'context' => 'normal', |
| 388 | 388 | 'priority' => 'high', //Show above Content WYSIWYG |
| 389 | - 'fields' => apply_filters( 'give_forms_terms_options_metabox_fields', array( |
|
| 389 | + 'fields' => apply_filters('give_forms_terms_options_metabox_fields', array(
|
|
| 390 | 390 | //Donation Option |
| 391 | 391 | array( |
| 392 | - 'name' => esc_html__( 'Terms and Conditions', 'give' ), |
|
| 393 | - 'description' => esc_html__( 'Do you want to require the user to agree to terms and conditions prior to being able to complete their donation?', 'give' ), |
|
| 394 | - 'id' => $prefix . 'terms_option', |
|
| 392 | + 'name' => esc_html__('Terms and Conditions', 'give'),
|
|
| 393 | + 'description' => esc_html__('Do you want to require the user to agree to terms and conditions prior to being able to complete their donation?', 'give'),
|
|
| 394 | + 'id' => $prefix.'terms_option', |
|
| 395 | 395 | 'type' => 'select', |
| 396 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
| 397 | - 'none' => esc_html__( 'No', 'give' ), |
|
| 398 | - 'yes' => esc_html__( 'Yes', 'give' ), |
|
| 396 | + 'options' => apply_filters('give_forms_content_options_select', array(
|
|
| 397 | + 'none' => esc_html__('No', 'give'),
|
|
| 398 | + 'yes' => esc_html__('Yes', 'give'),
|
|
| 399 | 399 | ) |
| 400 | 400 | ), |
| 401 | 401 | 'default' => 'none', |
| 402 | 402 | ), |
| 403 | 403 | array( |
| 404 | - 'id' => $prefix . 'agree_label', |
|
| 405 | - 'name' => esc_html__( 'Agree to Terms Label', 'give' ), |
|
| 406 | - 'desc' => esc_html__( 'The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give' ), |
|
| 404 | + 'id' => $prefix.'agree_label', |
|
| 405 | + 'name' => esc_html__('Agree to Terms Label', 'give'),
|
|
| 406 | + 'desc' => esc_html__('The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give'),
|
|
| 407 | 407 | 'type' => 'text', |
| 408 | 408 | 'row_classes' => 'give-subfield', |
| 409 | 409 | 'size' => 'regular', |
| 410 | 410 | 'attributes' => array( |
| 411 | - 'placeholder' => esc_attr__( 'Agree to Terms?', 'give' ), |
|
| 411 | + 'placeholder' => esc_attr__('Agree to Terms?', 'give'),
|
|
| 412 | 412 | ), |
| 413 | 413 | ), |
| 414 | 414 | array( |
| 415 | - 'id' => $prefix . 'agree_text', |
|
| 415 | + 'id' => $prefix.'agree_text', |
|
| 416 | 416 | 'row_classes' => 'give-subfield', |
| 417 | - 'name' => esc_html__( 'Agreement Text', 'give' ), |
|
| 418 | - 'desc' => esc_html__( 'This is the actual text which the user will have to agree to in order to make a donation.', 'give' ), |
|
| 417 | + 'name' => esc_html__('Agreement Text', 'give'),
|
|
| 418 | + 'desc' => esc_html__('This is the actual text which the user will have to agree to in order to make a donation.', 'give'),
|
|
| 419 | 419 | 'type' => 'wysiwyg' |
| 420 | 420 | ), |
| 421 | 421 | ) |
| 422 | 422 | ) |
| 423 | - ) ); |
|
| 423 | + )); |
|
| 424 | 424 | |
| 425 | 425 | return $meta_boxes; |
| 426 | 426 | |
@@ -434,9 +434,9 @@ discard block |
||
| 434 | 434 | |
| 435 | 435 | <div class="table-container"> |
| 436 | 436 | <div class="table-row"> |
| 437 | - <div class="table-cell col-amount"><?php esc_html_e( 'Amount', 'give' ); ?></div> |
|
| 438 | - <div class="table-cell col-text"><?php esc_html_e( 'Text', 'give' ); ?></div> |
|
| 439 | - <div class="table-cell col-default"><?php esc_html_e( 'Default', 'give' ); ?></div> |
|
| 437 | + <div class="table-cell col-amount"><?php esc_html_e('Amount', 'give'); ?></div>
|
|
| 438 | + <div class="table-cell col-text"><?php esc_html_e('Text', 'give'); ?></div>
|
|
| 439 | + <div class="table-cell col-default"><?php esc_html_e('Default', 'give'); ?></div>
|
|
| 440 | 440 | <?php |
| 441 | 441 | /** |
| 442 | 442 | * Fires in repeatable donation levels table head. |
@@ -448,9 +448,9 @@ discard block |
||
| 448 | 448 | * |
| 449 | 449 | * @since 1.0 |
| 450 | 450 | */ |
| 451 | - do_action( 'give_donation_levels_table_head' ); |
|
| 451 | + do_action('give_donation_levels_table_head');
|
|
| 452 | 452 | ?> |
| 453 | - <div class="table-cell col-sort"><?php esc_html_e( 'Sort', 'give' ); ?></div> |
|
| 453 | + <div class="table-cell col-sort"><?php esc_html_e('Sort', 'give'); ?></div>
|
|
| 454 | 454 | |
| 455 | 455 | </div> |
| 456 | 456 | </div> |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | <?php |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | -add_action( 'cmb2_render_levels_repeater_header', 'give_cmb_render_levels_repeater_header', 10 ); |
|
| 461 | +add_action('cmb2_render_levels_repeater_header', 'give_cmb_render_levels_repeater_header', 10);
|
|
| 462 | 462 | |
| 463 | 463 | |
| 464 | 464 | /** |
@@ -475,25 +475,25 @@ discard block |
||
| 475 | 475 | * @param $object_type |
| 476 | 476 | * @param $field_type_object |
| 477 | 477 | */ |
| 478 | -function give_cmb_render_levels_id( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) {
|
|
| 478 | +function give_cmb_render_levels_id($field_object, $escaped_value, $object_id, $object_type, $field_type_object) {
|
|
| 479 | 479 | |
| 480 | - $escaped_value = ( isset( $escaped_value['level_id'] ) ? $escaped_value['level_id'] : '' ); |
|
| 480 | + $escaped_value = (isset($escaped_value['level_id']) ? $escaped_value['level_id'] : ''); |
|
| 481 | 481 | |
| 482 | 482 | $field_options_array = array( |
| 483 | 483 | 'class' => 'give-hidden give-level-id-input', |
| 484 | - 'name' => $field_type_object->_name( '[level_id]' ), |
|
| 485 | - 'id' => $field_type_object->_id( '_level_id' ), |
|
| 484 | + 'name' => $field_type_object->_name('[level_id]'),
|
|
| 485 | + 'id' => $field_type_object->_id('_level_id'),
|
|
| 486 | 486 | 'value' => $escaped_value, |
| 487 | 487 | 'type' => 'number', |
| 488 | 488 | 'desc' => '', |
| 489 | 489 | ); |
| 490 | 490 | |
| 491 | - echo '<p class="give-level-id">' . $escaped_value . '</p>'; |
|
| 492 | - echo $field_type_object->input( $field_options_array ); |
|
| 491 | + echo '<p class="give-level-id">'.$escaped_value.'</p>'; |
|
| 492 | + echo $field_type_object->input($field_options_array); |
|
| 493 | 493 | |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | -add_action( 'cmb2_render_levels_id', 'give_cmb_render_levels_id', 10, 5 ); |
|
| 496 | +add_action('cmb2_render_levels_id', 'give_cmb_render_levels_id', 10, 5);
|
|
| 497 | 497 | |
| 498 | 498 | |
| 499 | 499 | /** |
@@ -505,13 +505,13 @@ discard block |
||
| 505 | 505 | * @param $object_type |
| 506 | 506 | * @param $field_type_object |
| 507 | 507 | */ |
| 508 | -function give_cmb_give_default_radio_inline( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) {
|
|
| 509 | - echo '<input type="radio" class="cmb2-option donation-level-radio" name="' . $field_object->args['_name'] . '" id="' . $field_object->args['id'] . '" value="default" ' . checked( 'default', $escaped_value, false ) . '>'; |
|
| 510 | - echo '<label for="' . $field_object->args['id'] . '">' . esc_html__( 'Default', 'give' ) . '</label>'; |
|
| 508 | +function give_cmb_give_default_radio_inline($field_object, $escaped_value, $object_id, $object_type, $field_type_object) {
|
|
| 509 | + echo '<input type="radio" class="cmb2-option donation-level-radio" name="'.$field_object->args['_name'].'" id="'.$field_object->args['id'].'" value="default" '.checked('default', $escaped_value, false).'>';
|
|
| 510 | + echo '<label for="'.$field_object->args['id'].'">'.esc_html__('Default', 'give').'</label>';
|
|
| 511 | 511 | |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | -add_action( 'cmb2_render_give_default_radio_inline', 'give_cmb_give_default_radio_inline', 10, 5 ); |
|
| 514 | +add_action('cmb2_render_give_default_radio_inline', 'give_cmb_give_default_radio_inline', 10, 5);
|
|
| 515 | 515 | |
| 516 | 516 | |
| 517 | 517 | /** |
@@ -521,20 +521,20 @@ discard block |
||
| 521 | 521 | */ |
| 522 | 522 | function give_add_shortcode_to_publish_metabox() {
|
| 523 | 523 | |
| 524 | - if ( 'give_forms' !== get_post_type() ) {
|
|
| 524 | + if ('give_forms' !== get_post_type()) {
|
|
| 525 | 525 | return false; |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | global $post; |
| 529 | 529 | |
| 530 | 530 | //Only enqueue scripts for CPT on post type screen |
| 531 | - if ( 'give_forms' === $post->post_type ) {
|
|
| 531 | + if ('give_forms' === $post->post_type) {
|
|
| 532 | 532 | //Shortcode column with select all input |
| 533 | - $shortcode = htmlentities( '[give_form id="' . $post->ID . '"]' ); |
|
| 534 | - echo '<div class="shortcode-wrap box-sizing"><label for="shortcode-input">' . esc_html__( 'Give Form Shortcode:', 'give' ) . '</label><input onClick="this.setSelectionRange(0, this.value.length)" type="text" name="shortcode-input" id="shortcode-input" class="shortcode-input" readonly value="' . $shortcode . '"></div>'; |
|
| 533 | + $shortcode = htmlentities('[give_form id="'.$post->ID.'"]');
|
|
| 534 | + echo '<div class="shortcode-wrap box-sizing"><label for="shortcode-input">'.esc_html__('Give Form Shortcode:', 'give').'</label><input onClick="this.setSelectionRange(0, this.value.length)" type="text" name="shortcode-input" id="shortcode-input" class="shortcode-input" readonly value="'.$shortcode.'"></div>';
|
|
| 535 | 535 | |
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | -add_action( 'post_submitbox_misc_actions', 'give_add_shortcode_to_publish_metabox' ); |
|
| 540 | +add_action('post_submitbox_misc_actions', 'give_add_shortcode_to_publish_metabox');
|
|
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * @since 1.3.0 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -defined( 'ABSPATH' ) or exit; |
|
| 12 | +defined('ABSPATH') or exit; |
|
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | 15 | * Class Give_Shortcode_Donation_Form |
@@ -21,10 +21,10 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public function __construct() { |
| 23 | 23 | |
| 24 | - $this->shortcode['title'] = esc_html__( 'Donation Form', 'give' ); |
|
| 25 | - $this->shortcode['label'] = esc_html__( 'Donation Form', 'give' ); |
|
| 24 | + $this->shortcode['title'] = esc_html__('Donation Form', 'give'); |
|
| 25 | + $this->shortcode['label'] = esc_html__('Donation Form', 'give'); |
|
| 26 | 26 | |
| 27 | - parent::__construct( 'give_form' ); |
|
| 27 | + parent::__construct('give_form'); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -36,8 +36,8 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | $create_form_link = sprintf( |
| 38 | 38 | /* translators: %s: create new form URL */ |
| 39 | - __( '<a href="%s">Create</a> a new Donation Form.', 'give' ), |
|
| 40 | - admin_url( 'post-new.php?post_type=give_forms' ) |
|
| 39 | + __('<a href="%s">Create</a> a new Donation Form.', 'give'), |
|
| 40 | + admin_url('post-new.php?post_type=give_forms') |
|
| 41 | 41 | ); |
| 42 | 42 | |
| 43 | 43 | return array( |
@@ -47,68 +47,68 @@ discard block |
||
| 47 | 47 | 'post_type' => 'give_forms', |
| 48 | 48 | ), |
| 49 | 49 | 'name' => 'id', |
| 50 | - 'tooltip' => esc_attr__( 'Select a Donation Form', 'give' ), |
|
| 51 | - 'placeholder' => esc_attr__( '- Select a Form -', 'give' ), |
|
| 50 | + 'tooltip' => esc_attr__('Select a Donation Form', 'give'), |
|
| 51 | + 'placeholder' => esc_attr__('- Select a Form -', 'give'), |
|
| 52 | 52 | 'required' => array( |
| 53 | - 'alert' => esc_html__( 'You must first select a Form!', 'give' ), |
|
| 54 | - 'error' => sprintf( '<p class="strong">%s</p><p class="no-margin">%s</p>', esc_html__( 'No donation forms found.', 'give' ), $create_form_link ), |
|
| 53 | + 'alert' => esc_html__('You must first select a Form!', 'give'), |
|
| 54 | + 'error' => sprintf('<p class="strong">%s</p><p class="no-margin">%s</p>', esc_html__('No donation forms found.', 'give'), $create_form_link), |
|
| 55 | 55 | ), |
| 56 | 56 | ), |
| 57 | 57 | array( |
| 58 | 58 | 'type' => 'container', |
| 59 | - 'html' => sprintf( '<p class="strong margin-top">%s</p>', esc_html__( 'Optional settings', 'give' ) ), |
|
| 59 | + 'html' => sprintf('<p class="strong margin-top">%s</p>', esc_html__('Optional settings', 'give')), |
|
| 60 | 60 | ), |
| 61 | 61 | array( |
| 62 | 62 | 'type' => 'listbox', |
| 63 | 63 | 'name' => 'show_title', |
| 64 | - 'label' => esc_attr__( 'Show Title:', 'give' ), |
|
| 65 | - 'tooltip' => esc_attr__( 'Do you want to display the form title?', 'give' ), |
|
| 64 | + 'label' => esc_attr__('Show Title:', 'give'), |
|
| 65 | + 'tooltip' => esc_attr__('Do you want to display the form title?', 'give'), |
|
| 66 | 66 | 'options' => array( |
| 67 | - 'true' => esc_html__( 'Show', 'give' ), |
|
| 68 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
| 67 | + 'true' => esc_html__('Show', 'give'), |
|
| 68 | + 'false' => esc_html__('Hide', 'give'), |
|
| 69 | 69 | ), |
| 70 | 70 | ), |
| 71 | 71 | array( |
| 72 | 72 | 'type' => 'listbox', |
| 73 | 73 | 'name' => 'show_goal', |
| 74 | - 'label' => esc_attr__( 'Show Goal:', 'give' ), |
|
| 75 | - 'tooltip' => esc_attr__( 'Do you want to display the donation goal?', 'give' ), |
|
| 74 | + 'label' => esc_attr__('Show Goal:', 'give'), |
|
| 75 | + 'tooltip' => esc_attr__('Do you want to display the donation goal?', 'give'), |
|
| 76 | 76 | 'options' => array( |
| 77 | - 'true' => esc_html__( 'Show', 'give' ), |
|
| 78 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
| 77 | + 'true' => esc_html__('Show', 'give'), |
|
| 78 | + 'false' => esc_html__('Hide', 'give'), |
|
| 79 | 79 | ), |
| 80 | 80 | ), |
| 81 | 81 | array( |
| 82 | 82 | 'type' => 'listbox', |
| 83 | 83 | 'name' => 'show_content', |
| 84 | 84 | 'minWidth' => 240, |
| 85 | - 'label' => esc_attr__( 'Display Content:', 'give' ), |
|
| 86 | - 'tooltip' => esc_attr__( 'Do you want to display the form content?', 'give' ), |
|
| 85 | + 'label' => esc_attr__('Display Content:', 'give'), |
|
| 86 | + 'tooltip' => esc_attr__('Do you want to display the form content?', 'give'), |
|
| 87 | 87 | 'options' => array( |
| 88 | - 'none' => esc_html__( 'No Content', 'give' ), |
|
| 89 | - 'above' => esc_html__( 'Display content ABOVE the fields', 'give' ), |
|
| 90 | - 'below' => esc_html__( 'Display content BELOW the fields', 'give' ), |
|
| 88 | + 'none' => esc_html__('No Content', 'give'), |
|
| 89 | + 'above' => esc_html__('Display content ABOVE the fields', 'give'), |
|
| 90 | + 'below' => esc_html__('Display content BELOW the fields', 'give'), |
|
| 91 | 91 | ), |
| 92 | 92 | ), |
| 93 | 93 | array( |
| 94 | 94 | 'type' => 'listbox', |
| 95 | 95 | 'name' => 'display_style', |
| 96 | - 'label' => esc_attr__( 'Donation Fields:', 'give' ), |
|
| 97 | - 'tooltip' => esc_attr__( 'How would you like to display donation information?', 'give' ), |
|
| 96 | + 'label' => esc_attr__('Donation Fields:', 'give'), |
|
| 97 | + 'tooltip' => esc_attr__('How would you like to display donation information?', 'give'), |
|
| 98 | 98 | 'options' => array( |
| 99 | - 'onpage' => esc_html__( 'Show on Page', 'give' ), |
|
| 100 | - 'reveal' => esc_html__( 'Reveal Upon Click', 'give' ), |
|
| 101 | - 'modal' => esc_html__( 'Modal Window Upon Click', 'give' ), |
|
| 99 | + 'onpage' => esc_html__('Show on Page', 'give'), |
|
| 100 | + 'reveal' => esc_html__('Reveal Upon Click', 'give'), |
|
| 101 | + 'modal' => esc_html__('Modal Window Upon Click', 'give'), |
|
| 102 | 102 | ), |
| 103 | 103 | ), |
| 104 | 104 | array( |
| 105 | 105 | 'type' => 'listbox', |
| 106 | 106 | 'name' => 'float_labels', |
| 107 | - 'label' => esc_attr__( 'Floating Labels:', 'give' ), |
|
| 108 | - 'tooltip' => esc_attr__( 'Override the default floating labels setting for this form.', 'give' ), |
|
| 107 | + 'label' => esc_attr__('Floating Labels:', 'give'), |
|
| 108 | + 'tooltip' => esc_attr__('Override the default floating labels setting for this form.', 'give'), |
|
| 109 | 109 | 'options' => array( |
| 110 | - 'enabled' => esc_html__( 'Enabled', 'give' ), |
|
| 111 | - 'disabled' => esc_html__( 'Disabled', 'give' ), |
|
| 110 | + 'enabled' => esc_html__('Enabled', 'give'), |
|
| 111 | + 'disabled' => esc_html__('Disabled', 'give'), |
|
| 112 | 112 | ), |
| 113 | 113 | ), |
| 114 | 114 | ); |
@@ -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 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @access private |
| 22 | 22 | * @since 1.0 |
| 23 | 23 | */ |
| 24 | -add_action( 'give_paypal_cc_form', '__return_false' ); |
|
| 24 | +add_action('give_paypal_cc_form', '__return_false'); |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * Process PayPal Purchase |
@@ -32,13 +32,13 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @return void |
| 34 | 34 | */ |
| 35 | -function give_process_paypal_purchase( $purchase_data ) { |
|
| 35 | +function give_process_paypal_purchase($purchase_data) { |
|
| 36 | 36 | |
| 37 | - if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'give-gateway' ) ) { |
|
| 38 | - wp_die( esc_html__( 'Nonce verification has failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 37 | + if ( ! wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) { |
|
| 38 | + wp_die(esc_html__('Nonce verification has failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - $form_id = intval( $purchase_data['post_data']['give-form-id'] ); |
|
| 41 | + $form_id = intval($purchase_data['post_data']['give-form-id']); |
|
| 42 | 42 | $price_id = isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : ''; |
| 43 | 43 | |
| 44 | 44 | // Collect payment data |
@@ -57,67 +57,67 @@ discard block |
||
| 57 | 57 | ); |
| 58 | 58 | |
| 59 | 59 | // Record the pending payment |
| 60 | - $payment = give_insert_payment( $payment_data ); |
|
| 60 | + $payment = give_insert_payment($payment_data); |
|
| 61 | 61 | |
| 62 | 62 | // Check payment |
| 63 | - if ( ! $payment ) { |
|
| 63 | + if ( ! $payment) { |
|
| 64 | 64 | // Record the error |
| 65 | 65 | give_record_gateway_error( |
| 66 | - esc_html__( 'Payment Error', 'give' ), |
|
| 66 | + esc_html__('Payment Error', 'give'), |
|
| 67 | 67 | sprintf( |
| 68 | 68 | /* translators: %s: payment data */ |
| 69 | - esc_html__( 'Payment creation failed before sending buyer to PayPal. Payment data: %s', 'give' ), |
|
| 70 | - json_encode( $payment_data ) |
|
| 69 | + esc_html__('Payment creation failed before sending buyer to PayPal. Payment data: %s', 'give'), |
|
| 70 | + json_encode($payment_data) |
|
| 71 | 71 | ), |
| 72 | 72 | $payment |
| 73 | 73 | ); |
| 74 | 74 | // Problems? send back |
| 75 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
| 75 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
| 76 | 76 | } else { |
| 77 | 77 | // Only send to PayPal if the pending payment is created successfully |
| 78 | - $listener_url = add_query_arg( 'give-listener', 'IPN', home_url( 'index.php' ) ); |
|
| 78 | + $listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php')); |
|
| 79 | 79 | |
| 80 | 80 | // Get the success url |
| 81 | - $return_url = add_query_arg( array( |
|
| 81 | + $return_url = add_query_arg(array( |
|
| 82 | 82 | 'payment-confirmation' => 'paypal', |
| 83 | 83 | 'payment-id' => $payment |
| 84 | 84 | |
| 85 | - ), get_permalink( give_get_option( 'success_page' ) ) ); |
|
| 85 | + ), get_permalink(give_get_option('success_page'))); |
|
| 86 | 86 | |
| 87 | 87 | // Get the PayPal redirect uri |
| 88 | - $paypal_redirect = trailingslashit( give_get_paypal_redirect() ) . '?'; |
|
| 88 | + $paypal_redirect = trailingslashit(give_get_paypal_redirect()).'?'; |
|
| 89 | 89 | |
| 90 | 90 | //Item name - pass level name if variable priced |
| 91 | 91 | $item_name = $purchase_data['post_data']['give-form-title']; |
| 92 | 92 | |
| 93 | 93 | //Verify has variable prices |
| 94 | - if ( give_has_variable_prices( $form_id ) && isset( $purchase_data['post_data']['give-price-id'] ) ) { |
|
| 94 | + if (give_has_variable_prices($form_id) && isset($purchase_data['post_data']['give-price-id'])) { |
|
| 95 | 95 | |
| 96 | - $item_price_level_text = give_get_price_option_name( $form_id, $purchase_data['post_data']['give-price-id'] ); |
|
| 96 | + $item_price_level_text = give_get_price_option_name($form_id, $purchase_data['post_data']['give-price-id']); |
|
| 97 | 97 | |
| 98 | - $price_level_amount = give_get_price_option_amount( $form_id, $purchase_data['post_data']['give-price-id'] ); |
|
| 98 | + $price_level_amount = give_get_price_option_amount($form_id, $purchase_data['post_data']['give-price-id']); |
|
| 99 | 99 | |
| 100 | 100 | //Donation given doesn't match selected level (must be a custom amount) |
| 101 | - if ( $price_level_amount != give_sanitize_amount( $purchase_data['price'] ) ) { |
|
| 102 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
| 101 | + if ($price_level_amount != give_sanitize_amount($purchase_data['price'])) { |
|
| 102 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
| 103 | 103 | //user custom amount text if any, fallback to default if not |
| 104 | - $item_name .= ' - ' . ( ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html__( 'Custom Amount', 'give' ) ); |
|
| 104 | + $item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : esc_html__('Custom Amount', 'give')); |
|
| 105 | 105 | |
| 106 | 106 | } //Is there any donation level text? |
| 107 | - elseif ( ! empty( $item_price_level_text ) ) { |
|
| 108 | - $item_name .= ' - ' . $item_price_level_text; |
|
| 107 | + elseif ( ! empty($item_price_level_text)) { |
|
| 108 | + $item_name .= ' - '.$item_price_level_text; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | } //Single donation: Custom Amount |
| 112 | - elseif ( give_get_form_price( $form_id ) !== give_sanitize_amount( $purchase_data['price'] ) ) { |
|
| 113 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
| 112 | + elseif (give_get_form_price($form_id) !== give_sanitize_amount($purchase_data['price'])) { |
|
| 113 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
| 114 | 114 | //user custom amount text if any, fallback to default if not |
| 115 | - $item_name .= ' - ' . ( ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html__( 'Custom Amount', 'give' ) ); |
|
| 115 | + $item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : esc_html__('Custom Amount', 'give')); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | // Setup PayPal arguments |
| 119 | 119 | $paypal_args = array( |
| 120 | - 'business' => give_get_option( 'paypal_email', false ), |
|
| 120 | + 'business' => give_get_option('paypal_email', false), |
|
| 121 | 121 | 'email' => $purchase_data['user_email'], |
| 122 | 122 | 'invoice' => $purchase_data['purchase_key'], |
| 123 | 123 | 'amount' => $purchase_data['price'], |
@@ -128,25 +128,25 @@ discard block |
||
| 128 | 128 | 'shipping' => '0', |
| 129 | 129 | 'no_note' => '1', |
| 130 | 130 | 'currency_code' => give_get_currency(), |
| 131 | - 'charset' => get_bloginfo( 'charset' ), |
|
| 131 | + 'charset' => get_bloginfo('charset'), |
|
| 132 | 132 | 'custom' => $payment, |
| 133 | 133 | 'rm' => '2', |
| 134 | 134 | 'return' => $return_url, |
| 135 | - 'cancel_return' => give_get_failed_transaction_uri( '?payment-id=' . $payment ), |
|
| 135 | + 'cancel_return' => give_get_failed_transaction_uri('?payment-id='.$payment), |
|
| 136 | 136 | 'notify_url' => $listener_url, |
| 137 | 137 | 'page_style' => give_get_paypal_page_style(), |
| 138 | - 'cbt' => get_bloginfo( 'name' ), |
|
| 138 | + 'cbt' => get_bloginfo('name'), |
|
| 139 | 139 | 'bn' => 'givewp_SP' |
| 140 | 140 | ); |
| 141 | 141 | |
| 142 | - if ( ! empty( $purchase_data['user_info']['address'] ) ) { |
|
| 142 | + if ( ! empty($purchase_data['user_info']['address'])) { |
|
| 143 | 143 | $paypal_args['address1'] = $purchase_data['user_info']['address']['line1']; |
| 144 | 144 | $paypal_args['address2'] = $purchase_data['user_info']['address']['line2']; |
| 145 | 145 | $paypal_args['city'] = $purchase_data['user_info']['address']['city']; |
| 146 | 146 | $paypal_args['country'] = $purchase_data['user_info']['address']['country']; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - if ( give_get_option( 'paypal_button_type' ) === 'standard' ) { |
|
| 149 | + if (give_get_option('paypal_button_type') === 'standard') { |
|
| 150 | 150 | $paypal_extra_args = array( |
| 151 | 151 | 'cmd' => '_xclick', |
| 152 | 152 | ); |
@@ -156,23 +156,23 @@ discard block |
||
| 156 | 156 | ); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - $paypal_args = array_merge( $paypal_extra_args, $paypal_args ); |
|
| 160 | - $paypal_args = apply_filters( 'give_paypal_redirect_args', $paypal_args, $purchase_data ); |
|
| 159 | + $paypal_args = array_merge($paypal_extra_args, $paypal_args); |
|
| 160 | + $paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $purchase_data); |
|
| 161 | 161 | |
| 162 | 162 | // Build query |
| 163 | - $paypal_redirect .= http_build_query( $paypal_args ); |
|
| 163 | + $paypal_redirect .= http_build_query($paypal_args); |
|
| 164 | 164 | |
| 165 | 165 | // Fix for some sites that encode the entities |
| 166 | - $paypal_redirect = str_replace( '&', '&', $paypal_redirect ); |
|
| 166 | + $paypal_redirect = str_replace('&', '&', $paypal_redirect); |
|
| 167 | 167 | |
| 168 | 168 | // Redirect to PayPal |
| 169 | - wp_redirect( $paypal_redirect ); |
|
| 169 | + wp_redirect($paypal_redirect); |
|
| 170 | 170 | exit; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | -add_action( 'give_gateway_paypal', 'give_process_paypal_purchase' ); |
|
| 175 | +add_action('give_gateway_paypal', 'give_process_paypal_purchase'); |
|
| 176 | 176 | |
| 177 | 177 | /** |
| 178 | 178 | * Listens for a PayPal IPN requests and then sends to the processing function |
@@ -182,17 +182,17 @@ discard block |
||
| 182 | 182 | */ |
| 183 | 183 | function give_listen_for_paypal_ipn() { |
| 184 | 184 | // Regular PayPal IPN |
| 185 | - if ( isset( $_GET['give-listener'] ) && $_GET['give-listener'] == 'IPN' ) { |
|
| 185 | + if (isset($_GET['give-listener']) && $_GET['give-listener'] == 'IPN') { |
|
| 186 | 186 | /** |
| 187 | 187 | * Fires while verifying PayPal IPN |
| 188 | 188 | * |
| 189 | 189 | * @since 1.0 |
| 190 | 190 | */ |
| 191 | - do_action( 'give_verify_paypal_ipn' ); |
|
| 191 | + do_action('give_verify_paypal_ipn'); |
|
| 192 | 192 | } |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | -add_action( 'init', 'give_listen_for_paypal_ipn' ); |
|
| 195 | +add_action('init', 'give_listen_for_paypal_ipn'); |
|
| 196 | 196 | |
| 197 | 197 | /** |
| 198 | 198 | * Process PayPal IPN |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | function give_process_paypal_ipn() { |
| 204 | 204 | |
| 205 | 205 | // Check the request method is POST |
| 206 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) { |
|
| 206 | + if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') { |
|
| 207 | 207 | return; |
| 208 | 208 | } |
| 209 | 209 | |
@@ -211,11 +211,11 @@ discard block |
||
| 211 | 211 | $post_data = ''; |
| 212 | 212 | |
| 213 | 213 | // Fallback just in case post_max_size is lower than needed |
| 214 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
| 215 | - $post_data = file_get_contents( 'php://input' ); |
|
| 214 | + if (ini_get('allow_url_fopen')) { |
|
| 215 | + $post_data = file_get_contents('php://input'); |
|
| 216 | 216 | } else { |
| 217 | 217 | // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough |
| 218 | - ini_set( 'post_max_size', '12M' ); |
|
| 218 | + ini_set('post_max_size', '12M'); |
|
| 219 | 219 | } |
| 220 | 220 | // Start the encoded data collection with notification command |
| 221 | 221 | $encoded_data = 'cmd=_notify-validate'; |
@@ -224,40 +224,40 @@ discard block |
||
| 224 | 224 | $arg_separator = give_get_php_arg_separator_output(); |
| 225 | 225 | |
| 226 | 226 | // Verify there is a post_data |
| 227 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
| 227 | + if ($post_data || strlen($post_data) > 0) { |
|
| 228 | 228 | // Append the data |
| 229 | - $encoded_data .= $arg_separator . $post_data; |
|
| 229 | + $encoded_data .= $arg_separator.$post_data; |
|
| 230 | 230 | } else { |
| 231 | 231 | // Check if POST is empty |
| 232 | - if ( empty( $_POST ) ) { |
|
| 232 | + if (empty($_POST)) { |
|
| 233 | 233 | // Nothing to do |
| 234 | 234 | return; |
| 235 | 235 | } else { |
| 236 | 236 | // Loop through each POST |
| 237 | - foreach ( $_POST as $key => $value ) { |
|
| 237 | + foreach ($_POST as $key => $value) { |
|
| 238 | 238 | // Encode the value and append the data |
| 239 | - $encoded_data .= $arg_separator . "$key=" . urlencode( $value ); |
|
| 239 | + $encoded_data .= $arg_separator."$key=".urlencode($value); |
|
| 240 | 240 | } |
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | // Convert collected post data to an array |
| 245 | - parse_str( $encoded_data, $encoded_data_array ); |
|
| 245 | + parse_str($encoded_data, $encoded_data_array); |
|
| 246 | 246 | |
| 247 | - foreach ( $encoded_data_array as $key => $value ) { |
|
| 247 | + foreach ($encoded_data_array as $key => $value) { |
|
| 248 | 248 | |
| 249 | - if ( false !== strpos( $key, 'amp;' ) ) { |
|
| 250 | - $new_key = str_replace( '&', '&', $key ); |
|
| 251 | - $new_key = str_replace( 'amp;', '&' , $new_key ); |
|
| 249 | + if (false !== strpos($key, 'amp;')) { |
|
| 250 | + $new_key = str_replace('&', '&', $key); |
|
| 251 | + $new_key = str_replace('amp;', '&', $new_key); |
|
| 252 | 252 | |
| 253 | - unset( $encoded_data_array[ $key ] ); |
|
| 254 | - $encoded_data_array[ $new_key ] = $value; |
|
| 253 | + unset($encoded_data_array[$key]); |
|
| 254 | + $encoded_data_array[$new_key] = $value; |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | //Validate IPN request w/ PayPal if user hasn't disabled this security measure |
| 260 | - if ( ! give_get_option( 'disable_paypal_verification' ) ) { |
|
| 260 | + if ( ! give_get_option('disable_paypal_verification')) { |
|
| 261 | 261 | |
| 262 | 262 | $remote_post_vars = array( |
| 263 | 263 | 'method' => 'POST', |
@@ -277,27 +277,27 @@ discard block |
||
| 277 | 277 | ); |
| 278 | 278 | |
| 279 | 279 | // Validate the IPN |
| 280 | - $api_response = wp_remote_post( give_get_paypal_redirect(), $remote_post_vars ); |
|
| 280 | + $api_response = wp_remote_post(give_get_paypal_redirect(), $remote_post_vars); |
|
| 281 | 281 | |
| 282 | - if ( is_wp_error( $api_response ) ) { |
|
| 282 | + if (is_wp_error($api_response)) { |
|
| 283 | 283 | give_record_gateway_error( |
| 284 | - esc_html__( 'IPN Error', 'give' ), |
|
| 284 | + esc_html__('IPN Error', 'give'), |
|
| 285 | 285 | sprintf( |
| 286 | 286 | /* translators: %s: Paypal IPN response */ |
| 287 | - esc_html__( 'Invalid IPN verification response. IPN data: %s', 'give' ), |
|
| 288 | - json_encode( $api_response ) |
|
| 287 | + esc_html__('Invalid IPN verification response. IPN data: %s', 'give'), |
|
| 288 | + json_encode($api_response) |
|
| 289 | 289 | ) |
| 290 | 290 | ); |
| 291 | 291 | return; // Something went wrong |
| 292 | 292 | } |
| 293 | 293 | |
| 294 | - if ( $api_response['body'] !== 'VERIFIED' && give_get_option( 'disable_paypal_verification', false ) ) { |
|
| 294 | + if ($api_response['body'] !== 'VERIFIED' && give_get_option('disable_paypal_verification', false)) { |
|
| 295 | 295 | give_record_gateway_error( |
| 296 | - esc_html__( 'IPN Error', 'give' ), |
|
| 296 | + esc_html__('IPN Error', 'give'), |
|
| 297 | 297 | sprintf( |
| 298 | 298 | /* translators: %s: Paypal IPN response */ |
| 299 | - esc_html__( 'Invalid IPN verification response. IPN data: %s', 'give' ), |
|
| 300 | - json_encode( $api_response ) |
|
| 299 | + esc_html__('Invalid IPN verification response. IPN data: %s', 'give'), |
|
| 300 | + json_encode($api_response) |
|
| 301 | 301 | ) |
| 302 | 302 | ); |
| 303 | 303 | return; // Response not okay |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | // Check if $post_data_array has been populated |
| 309 | - if ( ! is_array( $encoded_data_array ) && ! empty( $encoded_data_array ) ) { |
|
| 309 | + if ( ! is_array($encoded_data_array) && ! empty($encoded_data_array)) { |
|
| 310 | 310 | return; |
| 311 | 311 | } |
| 312 | 312 | |
@@ -315,12 +315,12 @@ discard block |
||
| 315 | 315 | 'payment_status' => '' |
| 316 | 316 | ); |
| 317 | 317 | |
| 318 | - $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
| 318 | + $encoded_data_array = wp_parse_args($encoded_data_array, $defaults); |
|
| 319 | 319 | |
| 320 | - $payment_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
| 320 | + $payment_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0; |
|
| 321 | 321 | $txn_type = $encoded_data_array['txn_type']; |
| 322 | 322 | |
| 323 | - if ( has_action( 'give_paypal_' . $txn_type ) ) { |
|
| 323 | + if (has_action('give_paypal_'.$txn_type)) { |
|
| 324 | 324 | /** |
| 325 | 325 | * Fires while processing PayPal IPN $txn_type. |
| 326 | 326 | * |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | * @param array $encoded_data_array Encoded data. |
| 332 | 332 | * @param int $payment_id Payment id. |
| 333 | 333 | */ |
| 334 | - do_action( "give_paypal_{$txn_type}", $encoded_data_array, $payment_id ); |
|
| 334 | + do_action("give_paypal_{$txn_type}", $encoded_data_array, $payment_id); |
|
| 335 | 335 | } else { |
| 336 | 336 | /** |
| 337 | 337 | * Fires while process PayPal IPN. |
@@ -343,12 +343,12 @@ discard block |
||
| 343 | 343 | * @param array $encoded_data_array Encoded data. |
| 344 | 344 | * @param int $payment_id Payment id. |
| 345 | 345 | */ |
| 346 | - do_action( 'give_paypal_web_accept', $encoded_data_array, $payment_id ); |
|
| 346 | + do_action('give_paypal_web_accept', $encoded_data_array, $payment_id); |
|
| 347 | 347 | } |
| 348 | 348 | exit; |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | -add_action( 'give_verify_paypal_ipn', 'give_process_paypal_ipn' ); |
|
| 351 | +add_action('give_verify_paypal_ipn', 'give_process_paypal_ipn'); |
|
| 352 | 352 | |
| 353 | 353 | /** |
| 354 | 354 | * Process web accept (one time) payment IPNs |
@@ -359,224 +359,224 @@ discard block |
||
| 359 | 359 | * |
| 360 | 360 | * @return void |
| 361 | 361 | */ |
| 362 | -function give_process_paypal_web_accept_and_cart( $data, $payment_id ) { |
|
| 362 | +function give_process_paypal_web_accept_and_cart($data, $payment_id) { |
|
| 363 | 363 | |
| 364 | - if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded' ) { |
|
| 364 | + if ($data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded') { |
|
| 365 | 365 | return; |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | - if ( empty( $payment_id ) ) { |
|
| 368 | + if (empty($payment_id)) { |
|
| 369 | 369 | return; |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | // Collect payment details |
| 373 | - $purchase_key = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number']; |
|
| 373 | + $purchase_key = isset($data['invoice']) ? $data['invoice'] : $data['item_number']; |
|
| 374 | 374 | $paypal_amount = $data['mc_gross']; |
| 375 | - $payment_status = strtolower( $data['payment_status'] ); |
|
| 376 | - $currency_code = strtolower( $data['mc_currency'] ); |
|
| 377 | - $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] ); |
|
| 378 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
| 375 | + $payment_status = strtolower($data['payment_status']); |
|
| 376 | + $currency_code = strtolower($data['mc_currency']); |
|
| 377 | + $business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']); |
|
| 378 | + $payment_meta = give_get_payment_meta($payment_id); |
|
| 379 | 379 | |
| 380 | 380 | |
| 381 | - if ( give_get_payment_gateway( $payment_id ) != 'paypal' ) { |
|
| 381 | + if (give_get_payment_gateway($payment_id) != 'paypal') { |
|
| 382 | 382 | return; // this isn't a PayPal standard IPN |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | // Verify payment recipient |
| 386 | - if ( strcasecmp( $business_email, trim( give_get_option( 'paypal_email' ) ) ) != 0 ) { |
|
| 386 | + if (strcasecmp($business_email, trim(give_get_option('paypal_email'))) != 0) { |
|
| 387 | 387 | |
| 388 | 388 | give_record_gateway_error( |
| 389 | - esc_html__( 'IPN Error', 'give' ), |
|
| 389 | + esc_html__('IPN Error', 'give'), |
|
| 390 | 390 | sprintf( |
| 391 | 391 | /* translators: %s: Paypal IPN response */ |
| 392 | - esc_html__( 'Invalid business email in IPN response. IPN data: %s', 'give' ), |
|
| 393 | - json_encode( $data ) |
|
| 392 | + esc_html__('Invalid business email in IPN response. IPN data: %s', 'give'), |
|
| 393 | + json_encode($data) |
|
| 394 | 394 | ), |
| 395 | 395 | $payment_id |
| 396 | 396 | ); |
| 397 | - give_update_payment_status( $payment_id, 'failed' ); |
|
| 398 | - give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid PayPal business email.', 'give' ) ); |
|
| 397 | + give_update_payment_status($payment_id, 'failed'); |
|
| 398 | + give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid PayPal business email.', 'give')); |
|
| 399 | 399 | |
| 400 | 400 | return; |
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | // Verify payment currency |
| 404 | - if ( $currency_code != strtolower( $payment_meta['currency'] ) ) { |
|
| 404 | + if ($currency_code != strtolower($payment_meta['currency'])) { |
|
| 405 | 405 | |
| 406 | 406 | give_record_gateway_error( |
| 407 | - esc_html__( 'IPN Error', 'give' ), |
|
| 407 | + esc_html__('IPN Error', 'give'), |
|
| 408 | 408 | sprintf( |
| 409 | 409 | /* translators: %s: Paypal IPN response */ |
| 410 | - esc_html__( 'Invalid currency in IPN response. IPN data: %s', 'give' ), |
|
| 411 | - json_encode( $data ) |
|
| 410 | + esc_html__('Invalid currency in IPN response. IPN data: %s', 'give'), |
|
| 411 | + json_encode($data) |
|
| 412 | 412 | ), |
| 413 | 413 | $payment_id |
| 414 | 414 | ); |
| 415 | - give_update_payment_status( $payment_id, 'failed' ); |
|
| 416 | - give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid currency in PayPal IPN.', 'give' ) ); |
|
| 415 | + give_update_payment_status($payment_id, 'failed'); |
|
| 416 | + give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid currency in PayPal IPN.', 'give')); |
|
| 417 | 417 | |
| 418 | 418 | return; |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | - if ( ! give_get_payment_user_email( $payment_id ) ) { |
|
| 421 | + if ( ! give_get_payment_user_email($payment_id)) { |
|
| 422 | 422 | |
| 423 | 423 | // No email associated with the donation, so store from PayPal |
| 424 | - give_update_payment_meta( $payment_id, '_give_payment_user_email', $data['payer_email'] ); |
|
| 424 | + give_update_payment_meta($payment_id, '_give_payment_user_email', $data['payer_email']); |
|
| 425 | 425 | |
| 426 | 426 | // Setup and store the donors's details |
| 427 | 427 | $address = array(); |
| 428 | - $address['line1'] = ! empty( $data['address_street'] ) ? sanitize_text_field( $data['address_street'] ) : false; |
|
| 429 | - $address['city'] = ! empty( $data['address_city'] ) ? sanitize_text_field( $data['address_city'] ) : false; |
|
| 430 | - $address['state'] = ! empty( $data['address_state'] ) ? sanitize_text_field( $data['address_state'] ) : false; |
|
| 431 | - $address['country'] = ! empty( $data['address_country_code'] ) ? sanitize_text_field( $data['address_country_code'] ) : false; |
|
| 432 | - $address['zip'] = ! empty( $data['address_zip'] ) ? sanitize_text_field( $data['address_zip'] ) : false; |
|
| 428 | + $address['line1'] = ! empty($data['address_street']) ? sanitize_text_field($data['address_street']) : false; |
|
| 429 | + $address['city'] = ! empty($data['address_city']) ? sanitize_text_field($data['address_city']) : false; |
|
| 430 | + $address['state'] = ! empty($data['address_state']) ? sanitize_text_field($data['address_state']) : false; |
|
| 431 | + $address['country'] = ! empty($data['address_country_code']) ? sanitize_text_field($data['address_country_code']) : false; |
|
| 432 | + $address['zip'] = ! empty($data['address_zip']) ? sanitize_text_field($data['address_zip']) : false; |
|
| 433 | 433 | |
| 434 | 434 | $user_info = array( |
| 435 | 435 | 'id' => '-1', |
| 436 | - 'email' => sanitize_text_field( $data['payer_email'] ), |
|
| 437 | - 'first_name' => sanitize_text_field( $data['first_name'] ), |
|
| 438 | - 'last_name' => sanitize_text_field( $data['last_name'] ), |
|
| 436 | + 'email' => sanitize_text_field($data['payer_email']), |
|
| 437 | + 'first_name' => sanitize_text_field($data['first_name']), |
|
| 438 | + 'last_name' => sanitize_text_field($data['last_name']), |
|
| 439 | 439 | 'discount' => '', |
| 440 | 440 | 'address' => $address |
| 441 | 441 | ); |
| 442 | 442 | |
| 443 | 443 | $payment_meta['user_info'] = $user_info; |
| 444 | - give_update_payment_meta( $payment_id, '_give_payment_meta', $payment_meta ); |
|
| 444 | + give_update_payment_meta($payment_id, '_give_payment_meta', $payment_meta); |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | - if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) { |
|
| 447 | + if ($payment_status == 'refunded' || $payment_status == 'reversed') { |
|
| 448 | 448 | |
| 449 | 449 | // Process a refund |
| 450 | - give_process_paypal_refund( $data, $payment_id ); |
|
| 450 | + give_process_paypal_refund($data, $payment_id); |
|
| 451 | 451 | |
| 452 | 452 | } else { |
| 453 | 453 | |
| 454 | - if ( get_post_status( $payment_id ) == 'publish' ) { |
|
| 454 | + if (get_post_status($payment_id) == 'publish') { |
|
| 455 | 455 | return; // Only complete payments once |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | // Retrieve the total donation amount (before PayPal) |
| 459 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
| 459 | + $payment_amount = give_get_payment_amount($payment_id); |
|
| 460 | 460 | |
| 461 | - if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
| 461 | + if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
| 462 | 462 | // The prices don't match |
| 463 | 463 | give_record_gateway_error( |
| 464 | - esc_html__( 'IPN Error', 'give' ), |
|
| 464 | + esc_html__('IPN Error', 'give'), |
|
| 465 | 465 | sprintf( |
| 466 | 466 | /* translators: %s: Paypal IPN response */ |
| 467 | - esc_html__( 'Invalid payment amount in IPN response. IPN data: %s', 'give' ), |
|
| 468 | - json_encode( $data ) |
|
| 467 | + esc_html__('Invalid payment amount in IPN response. IPN data: %s', 'give'), |
|
| 468 | + json_encode($data) |
|
| 469 | 469 | ), |
| 470 | 470 | $payment_id |
| 471 | 471 | ); |
| 472 | - give_update_payment_status( $payment_id, 'failed' ); |
|
| 473 | - give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid amount in PayPal IPN.', 'give' ) ); |
|
| 472 | + give_update_payment_status($payment_id, 'failed'); |
|
| 473 | + give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid amount in PayPal IPN.', 'give')); |
|
| 474 | 474 | |
| 475 | 475 | return; |
| 476 | 476 | } |
| 477 | - if ( $purchase_key != give_get_payment_key( $payment_id ) ) { |
|
| 477 | + if ($purchase_key != give_get_payment_key($payment_id)) { |
|
| 478 | 478 | // Keys don't match |
| 479 | 479 | give_record_gateway_error( |
| 480 | - esc_html__( 'IPN Error', 'give' ), |
|
| 480 | + esc_html__('IPN Error', 'give'), |
|
| 481 | 481 | sprintf( |
| 482 | 482 | /* translators: %s: Paypal IPN response */ |
| 483 | - esc_html__( 'Invalid key in IPN response. IPN data: %s', 'give' ), |
|
| 484 | - json_encode( $data ) |
|
| 483 | + esc_html__('Invalid key in IPN response. IPN data: %s', 'give'), |
|
| 484 | + json_encode($data) |
|
| 485 | 485 | ), |
| 486 | 486 | $payment_id |
| 487 | 487 | ); |
| 488 | - give_update_payment_status( $payment_id, 'failed' ); |
|
| 489 | - give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid key in PayPal IPN.', 'give' ) ); |
|
| 488 | + give_update_payment_status($payment_id, 'failed'); |
|
| 489 | + give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid key in PayPal IPN.', 'give')); |
|
| 490 | 490 | |
| 491 | 491 | return; |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | - if ( $payment_status == 'completed' || give_is_test_mode() ) { |
|
| 494 | + if ($payment_status == 'completed' || give_is_test_mode()) { |
|
| 495 | 495 | give_insert_payment_note( |
| 496 | 496 | $payment_id, |
| 497 | 497 | sprintf( |
| 498 | 498 | /* translators: %s: Paypal transaction ID */ |
| 499 | - esc_html__( 'PayPal Transaction ID: %s', 'give' ), |
|
| 499 | + esc_html__('PayPal Transaction ID: %s', 'give'), |
|
| 500 | 500 | $data['txn_id'] |
| 501 | 501 | ) |
| 502 | 502 | ); |
| 503 | - give_set_payment_transaction_id( $payment_id, $data['txn_id'] ); |
|
| 504 | - give_update_payment_status( $payment_id, 'publish' ); |
|
| 505 | - } else if ( 'pending' == $payment_status && isset( $data['pending_reason'] ) ) { |
|
| 503 | + give_set_payment_transaction_id($payment_id, $data['txn_id']); |
|
| 504 | + give_update_payment_status($payment_id, 'publish'); |
|
| 505 | + } else if ('pending' == $payment_status && isset($data['pending_reason'])) { |
|
| 506 | 506 | |
| 507 | 507 | // Look for possible pending reasons, such as an echeck |
| 508 | 508 | |
| 509 | 509 | $note = ''; |
| 510 | 510 | |
| 511 | - switch ( strtolower( $data['pending_reason'] ) ) { |
|
| 511 | + switch (strtolower($data['pending_reason'])) { |
|
| 512 | 512 | |
| 513 | 513 | case 'echeck' : |
| 514 | 514 | |
| 515 | - $note = esc_html__( 'Payment made via eCheck and will clear automatically in 5-8 days.', 'give' ); |
|
| 515 | + $note = esc_html__('Payment made via eCheck and will clear automatically in 5-8 days.', 'give'); |
|
| 516 | 516 | |
| 517 | 517 | break; |
| 518 | 518 | |
| 519 | 519 | case 'address' : |
| 520 | 520 | |
| 521 | - $note = esc_html__( 'Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give' ); |
|
| 521 | + $note = esc_html__('Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give'); |
|
| 522 | 522 | |
| 523 | 523 | break; |
| 524 | 524 | |
| 525 | 525 | case 'intl' : |
| 526 | 526 | |
| 527 | - $note = esc_html__( 'Payment must be accepted manually through PayPal due to international account regulations.', 'give' ); |
|
| 527 | + $note = esc_html__('Payment must be accepted manually through PayPal due to international account regulations.', 'give'); |
|
| 528 | 528 | |
| 529 | 529 | break; |
| 530 | 530 | |
| 531 | 531 | case 'multi-currency' : |
| 532 | 532 | |
| 533 | - $note = esc_html__( 'Payment received in non-shop currency and must be accepted manually through PayPal.', 'give' ); |
|
| 533 | + $note = esc_html__('Payment received in non-shop currency and must be accepted manually through PayPal.', 'give'); |
|
| 534 | 534 | |
| 535 | 535 | break; |
| 536 | 536 | |
| 537 | 537 | case 'paymentreview' : |
| 538 | 538 | case 'regulatory_review' : |
| 539 | 539 | |
| 540 | - $note = esc_html__( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give' ); |
|
| 540 | + $note = esc_html__('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give'); |
|
| 541 | 541 | |
| 542 | 542 | break; |
| 543 | 543 | |
| 544 | 544 | case 'unilateral' : |
| 545 | 545 | |
| 546 | - $note = esc_html__( 'Payment was sent to non-confirmed or non-registered email address.', 'give' ); |
|
| 546 | + $note = esc_html__('Payment was sent to non-confirmed or non-registered email address.', 'give'); |
|
| 547 | 547 | |
| 548 | 548 | break; |
| 549 | 549 | |
| 550 | 550 | case 'upgrade' : |
| 551 | 551 | |
| 552 | - $note = esc_html__( 'PayPal account must be upgraded before this payment can be accepted.', 'give' ); |
|
| 552 | + $note = esc_html__('PayPal account must be upgraded before this payment can be accepted.', 'give'); |
|
| 553 | 553 | |
| 554 | 554 | break; |
| 555 | 555 | |
| 556 | 556 | case 'verify' : |
| 557 | 557 | |
| 558 | - $note = esc_html__( 'PayPal account is not verified. Verify account in order to accept this payment.', 'give' ); |
|
| 558 | + $note = esc_html__('PayPal account is not verified. Verify account in order to accept this payment.', 'give'); |
|
| 559 | 559 | |
| 560 | 560 | break; |
| 561 | 561 | |
| 562 | 562 | case 'other' : |
| 563 | 563 | |
| 564 | - $note = esc_html__( 'Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give' ); |
|
| 564 | + $note = esc_html__('Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give'); |
|
| 565 | 565 | |
| 566 | 566 | break; |
| 567 | 567 | |
| 568 | 568 | } |
| 569 | 569 | |
| 570 | - if ( ! empty( $note ) ) { |
|
| 570 | + if ( ! empty($note)) { |
|
| 571 | 571 | |
| 572 | - give_insert_payment_note( $payment_id, $note ); |
|
| 572 | + give_insert_payment_note($payment_id, $note); |
|
| 573 | 573 | |
| 574 | 574 | } |
| 575 | 575 | } |
| 576 | 576 | } |
| 577 | 577 | } |
| 578 | 578 | |
| 579 | -add_action( 'give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2 ); |
|
| 579 | +add_action('give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2); |
|
| 580 | 580 | |
| 581 | 581 | /** |
| 582 | 582 | * Process PayPal IPN Refunds |
@@ -587,28 +587,28 @@ discard block |
||
| 587 | 587 | * |
| 588 | 588 | * @return void |
| 589 | 589 | */ |
| 590 | -function give_process_paypal_refund( $data, $payment_id = 0 ) { |
|
| 590 | +function give_process_paypal_refund($data, $payment_id = 0) { |
|
| 591 | 591 | |
| 592 | 592 | // Collect payment details |
| 593 | 593 | |
| 594 | - if ( empty( $payment_id ) ) { |
|
| 594 | + if (empty($payment_id)) { |
|
| 595 | 595 | return; |
| 596 | 596 | } |
| 597 | 597 | |
| 598 | - if ( get_post_status( $payment_id ) == 'refunded' ) { |
|
| 598 | + if (get_post_status($payment_id) == 'refunded') { |
|
| 599 | 599 | return; // Only refund payments once |
| 600 | 600 | } |
| 601 | 601 | |
| 602 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
| 602 | + $payment_amount = give_get_payment_amount($payment_id); |
|
| 603 | 603 | $refund_amount = $data['payment_gross'] * - 1; |
| 604 | 604 | |
| 605 | - if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
| 605 | + if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
| 606 | 606 | |
| 607 | 607 | give_insert_payment_note( |
| 608 | 608 | $payment_id, |
| 609 | 609 | sprintf( |
| 610 | 610 | /* translators: %s: Paypal parent transaction ID */ |
| 611 | - esc_html__( 'Partial PayPal refund processed: %s', 'give' ), |
|
| 611 | + esc_html__('Partial PayPal refund processed: %s', 'give'), |
|
| 612 | 612 | $data['parent_txn_id'] |
| 613 | 613 | ) |
| 614 | 614 | ); |
@@ -621,7 +621,7 @@ discard block |
||
| 621 | 621 | $payment_id, |
| 622 | 622 | sprintf( |
| 623 | 623 | /* translators: 1: Paypal parent transaction ID 2. Paypal reason code */ |
| 624 | - esc_html__( 'PayPal Payment #%1$s Refunded for reason: %2$s', 'give' ), |
|
| 624 | + esc_html__('PayPal Payment #%1$s Refunded for reason: %2$s', 'give'), |
|
| 625 | 625 | $data['parent_txn_id'], |
| 626 | 626 | $data['reason_code'] |
| 627 | 627 | ) |
@@ -630,11 +630,11 @@ discard block |
||
| 630 | 630 | $payment_id, |
| 631 | 631 | sprintf( |
| 632 | 632 | /* translators: %s: Paypal transaction ID */ |
| 633 | - esc_html__( 'PayPal Refund Transaction ID: %s', 'give' ), |
|
| 633 | + esc_html__('PayPal Refund Transaction ID: %s', 'give'), |
|
| 634 | 634 | $data['txn_id'] |
| 635 | 635 | ) |
| 636 | 636 | ); |
| 637 | - give_update_payment_status( $payment_id, 'refunded' ); |
|
| 637 | + give_update_payment_status($payment_id, 'refunded'); |
|
| 638 | 638 | } |
| 639 | 639 | |
| 640 | 640 | /** |
@@ -646,24 +646,24 @@ discard block |
||
| 646 | 646 | * |
| 647 | 647 | * @return string |
| 648 | 648 | */ |
| 649 | -function give_get_paypal_redirect( $ssl_check = false ) { |
|
| 649 | +function give_get_paypal_redirect($ssl_check = false) { |
|
| 650 | 650 | |
| 651 | - if ( is_ssl() || ! $ssl_check ) { |
|
| 651 | + if (is_ssl() || ! $ssl_check) { |
|
| 652 | 652 | $protocal = 'https://'; |
| 653 | 653 | } else { |
| 654 | 654 | $protocal = 'http://'; |
| 655 | 655 | } |
| 656 | 656 | |
| 657 | 657 | // Check the current payment mode |
| 658 | - if ( give_is_test_mode() ) { |
|
| 658 | + if (give_is_test_mode()) { |
|
| 659 | 659 | // Test mode |
| 660 | - $paypal_uri = $protocal . 'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
| 660 | + $paypal_uri = $protocal.'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
| 661 | 661 | } else { |
| 662 | 662 | // Live mode |
| 663 | - $paypal_uri = $protocal . 'www.paypal.com/cgi-bin/webscr'; |
|
| 663 | + $paypal_uri = $protocal.'www.paypal.com/cgi-bin/webscr'; |
|
| 664 | 664 | } |
| 665 | 665 | |
| 666 | - return apply_filters( 'give_paypal_uri', $paypal_uri ); |
|
| 666 | + return apply_filters('give_paypal_uri', $paypal_uri); |
|
| 667 | 667 | } |
| 668 | 668 | |
| 669 | 669 | /** |
@@ -673,8 +673,8 @@ discard block |
||
| 673 | 673 | * @return string |
| 674 | 674 | */ |
| 675 | 675 | function give_get_paypal_page_style() { |
| 676 | - $page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) ); |
|
| 677 | - return apply_filters( 'give_paypal_page_style', $page_style ); |
|
| 676 | + $page_style = trim(give_get_option('paypal_page_style', 'PayPal')); |
|
| 677 | + return apply_filters('give_paypal_page_style', $page_style); |
|
| 678 | 678 | } |
| 679 | 679 | |
| 680 | 680 | /** |
@@ -689,27 +689,27 @@ discard block |
||
| 689 | 689 | * @return string |
| 690 | 690 | * |
| 691 | 691 | */ |
| 692 | -function give_paypal_success_page_content( $content ) { |
|
| 692 | +function give_paypal_success_page_content($content) { |
|
| 693 | 693 | |
| 694 | - if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) { |
|
| 694 | + if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) { |
|
| 695 | 695 | return $content; |
| 696 | 696 | } |
| 697 | 697 | |
| 698 | - $payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false; |
|
| 698 | + $payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false; |
|
| 699 | 699 | |
| 700 | - if ( ! $payment_id ) { |
|
| 700 | + if ( ! $payment_id) { |
|
| 701 | 701 | $session = give_get_purchase_session(); |
| 702 | - $payment_id = give_get_purchase_id_by_key( $session['purchase_key'] ); |
|
| 702 | + $payment_id = give_get_purchase_id_by_key($session['purchase_key']); |
|
| 703 | 703 | } |
| 704 | 704 | |
| 705 | - $payment = get_post( $payment_id ); |
|
| 705 | + $payment = get_post($payment_id); |
|
| 706 | 706 | |
| 707 | - if ( $payment && 'pending' == $payment->post_status ) { |
|
| 707 | + if ($payment && 'pending' == $payment->post_status) { |
|
| 708 | 708 | |
| 709 | 709 | // Payment is still pending so show processing indicator to fix the Race Condition |
| 710 | 710 | ob_start(); |
| 711 | 711 | |
| 712 | - give_get_template_part( 'payment', 'processing' ); |
|
| 712 | + give_get_template_part('payment', 'processing'); |
|
| 713 | 713 | |
| 714 | 714 | $content = ob_get_clean(); |
| 715 | 715 | |
@@ -719,7 +719,7 @@ discard block |
||
| 719 | 719 | |
| 720 | 720 | } |
| 721 | 721 | |
| 722 | -add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' ); |
|
| 722 | +add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content'); |
|
| 723 | 723 | |
| 724 | 724 | /** |
| 725 | 725 | * Given a Payment ID, extract the transaction ID |
@@ -730,22 +730,22 @@ discard block |
||
| 730 | 730 | * |
| 731 | 731 | * @return string Transaction ID |
| 732 | 732 | */ |
| 733 | -function give_paypal_get_payment_transaction_id( $payment_id ) { |
|
| 733 | +function give_paypal_get_payment_transaction_id($payment_id) { |
|
| 734 | 734 | |
| 735 | 735 | $transaction_id = ''; |
| 736 | - $notes = give_get_payment_notes( $payment_id ); |
|
| 736 | + $notes = give_get_payment_notes($payment_id); |
|
| 737 | 737 | |
| 738 | - foreach ( $notes as $note ) { |
|
| 739 | - if ( preg_match( '/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match ) ) { |
|
| 738 | + foreach ($notes as $note) { |
|
| 739 | + if (preg_match('/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match)) { |
|
| 740 | 740 | $transaction_id = $match[1]; |
| 741 | 741 | continue; |
| 742 | 742 | } |
| 743 | 743 | } |
| 744 | 744 | |
| 745 | - return apply_filters( 'give_paypal_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
| 745 | + return apply_filters('give_paypal_set_payment_transaction_id', $transaction_id, $payment_id); |
|
| 746 | 746 | } |
| 747 | 747 | |
| 748 | -add_filter( 'give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1 ); |
|
| 748 | +add_filter('give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1); |
|
| 749 | 749 | |
| 750 | 750 | /** |
| 751 | 751 | * Given a transaction ID, generate a link to the PayPal transaction ID details |
@@ -757,13 +757,13 @@ discard block |
||
| 757 | 757 | * |
| 758 | 758 | * @return string A link to the PayPal transaction details |
| 759 | 759 | */ |
| 760 | -function give_paypal_link_transaction_id( $transaction_id, $payment_id ) { |
|
| 760 | +function give_paypal_link_transaction_id($transaction_id, $payment_id) { |
|
| 761 | 761 | |
| 762 | 762 | $paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id='; |
| 763 | - $transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>'; |
|
| 763 | + $transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>'; |
|
| 764 | 764 | |
| 765 | - return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url ); |
|
| 765 | + return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url); |
|
| 766 | 766 | |
| 767 | 767 | } |
| 768 | 768 | |
| 769 | -add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 ); |
|
| 769 | +add_filter('give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2); |
|
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Exit if accessed directly |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if ( ! defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -140,27 +140,27 @@ discard block |
||
| 140 | 140 | 'v1' => 'GIVE_API_V1', |
| 141 | 141 | ); |
| 142 | 142 | |
| 143 | - foreach ( $this->get_versions() as $version => $class ) { |
|
| 144 | - require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api-' . $version . '.php'; |
|
| 143 | + foreach ($this->get_versions() as $version => $class) { |
|
| 144 | + require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api-'.$version.'.php'; |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - add_action( 'init', array( $this, 'add_endpoint' ) ); |
|
| 148 | - add_action( 'wp', array( $this, 'process_query' ), - 1 ); |
|
| 149 | - add_filter( 'query_vars', array( $this, 'query_vars' ) ); |
|
| 150 | - add_action( 'show_user_profile', array( $this, 'user_key_field' ) ); |
|
| 151 | - add_action( 'edit_user_profile', array( $this, 'user_key_field' ) ); |
|
| 152 | - add_action( 'personal_options_update', array( $this, 'update_key' ) ); |
|
| 153 | - add_action( 'edit_user_profile_update', array( $this, 'update_key' ) ); |
|
| 154 | - add_action( 'give_process_api_key', array( $this, 'process_api_key' ) ); |
|
| 147 | + add_action('init', array($this, 'add_endpoint')); |
|
| 148 | + add_action('wp', array($this, 'process_query'), - 1); |
|
| 149 | + add_filter('query_vars', array($this, 'query_vars')); |
|
| 150 | + add_action('show_user_profile', array($this, 'user_key_field')); |
|
| 151 | + add_action('edit_user_profile', array($this, 'user_key_field')); |
|
| 152 | + add_action('personal_options_update', array($this, 'update_key')); |
|
| 153 | + add_action('edit_user_profile_update', array($this, 'update_key')); |
|
| 154 | + add_action('give_process_api_key', array($this, 'process_api_key')); |
|
| 155 | 155 | |
| 156 | 156 | // Setup a backwards compatibility check for user API Keys |
| 157 | - add_filter( 'get_user_metadata', array( $this, 'api_key_backwards_compat' ), 10, 4 ); |
|
| 157 | + add_filter('get_user_metadata', array($this, 'api_key_backwards_compat'), 10, 4); |
|
| 158 | 158 | |
| 159 | 159 | // Determine if JSON_PRETTY_PRINT is available |
| 160 | - $this->pretty_print = defined( 'JSON_PRETTY_PRINT' ) ? JSON_PRETTY_PRINT : null; |
|
| 160 | + $this->pretty_print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : null; |
|
| 161 | 161 | |
| 162 | 162 | // Allow API request logging to be turned off |
| 163 | - $this->log_requests = apply_filters( 'give_api_log_requests', $this->log_requests ); |
|
| 163 | + $this->log_requests = apply_filters('give_api_log_requests', $this->log_requests); |
|
| 164 | 164 | |
| 165 | 165 | // Setup Give_Payment_Stats instance |
| 166 | 166 | $this->stats = new Give_Payment_Stats; |
@@ -176,8 +176,8 @@ discard block |
||
| 176 | 176 | * |
| 177 | 177 | * @since 1.1 |
| 178 | 178 | */ |
| 179 | - public function add_endpoint( $rewrite_rules ) { |
|
| 180 | - add_rewrite_endpoint( 'give-api', EP_ALL ); |
|
| 179 | + public function add_endpoint($rewrite_rules) { |
|
| 180 | + add_rewrite_endpoint('give-api', EP_ALL); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | /** |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | * |
| 191 | 191 | * @return string[] $vars New query vars |
| 192 | 192 | */ |
| 193 | - public function query_vars( $vars ) { |
|
| 193 | + public function query_vars($vars) { |
|
| 194 | 194 | |
| 195 | 195 | $vars[] = 'token'; |
| 196 | 196 | $vars[] = 'key'; |
@@ -241,11 +241,11 @@ discard block |
||
| 241 | 241 | */ |
| 242 | 242 | public function get_default_version() { |
| 243 | 243 | |
| 244 | - $version = get_option( 'give_default_api_version' ); |
|
| 244 | + $version = get_option('give_default_api_version'); |
|
| 245 | 245 | |
| 246 | - if ( defined( 'GIVE_API_VERSION' ) ) { |
|
| 246 | + if (defined('GIVE_API_VERSION')) { |
|
| 247 | 247 | $version = GIVE_API_VERSION; |
| 248 | - } elseif ( ! $version ) { |
|
| 248 | + } elseif ( ! $version) { |
|
| 249 | 249 | $version = 'v1'; |
| 250 | 250 | } |
| 251 | 251 | |
@@ -266,14 +266,14 @@ discard block |
||
| 266 | 266 | |
| 267 | 267 | $version = $wp_query->query_vars['give-api']; |
| 268 | 268 | |
| 269 | - if ( strpos( $version, '/' ) ) { |
|
| 269 | + if (strpos($version, '/')) { |
|
| 270 | 270 | |
| 271 | - $version = explode( '/', $version ); |
|
| 272 | - $version = strtolower( $version[0] ); |
|
| 271 | + $version = explode('/', $version); |
|
| 272 | + $version = strtolower($version[0]); |
|
| 273 | 273 | |
| 274 | - $wp_query->query_vars['give-api'] = str_replace( $version . '/', '', $wp_query->query_vars['give-api'] ); |
|
| 274 | + $wp_query->query_vars['give-api'] = str_replace($version.'/', '', $wp_query->query_vars['give-api']); |
|
| 275 | 275 | |
| 276 | - if ( array_key_exists( $version, $this->versions ) ) { |
|
| 276 | + if (array_key_exists($version, $this->versions)) { |
|
| 277 | 277 | |
| 278 | 278 | $this->queried_version = $version; |
| 279 | 279 | |
@@ -310,32 +310,32 @@ discard block |
||
| 310 | 310 | $this->override = false; |
| 311 | 311 | |
| 312 | 312 | // Make sure we have both user and api key |
| 313 | - if ( ! empty( $wp_query->query_vars['give-api'] ) && ( $wp_query->query_vars['give-api'] != 'forms' || ! empty( $wp_query->query_vars['token'] ) ) ) { |
|
| 313 | + if ( ! empty($wp_query->query_vars['give-api']) && ($wp_query->query_vars['give-api'] != 'forms' || ! empty($wp_query->query_vars['token']))) { |
|
| 314 | 314 | |
| 315 | - if ( empty( $wp_query->query_vars['token'] ) || empty( $wp_query->query_vars['key'] ) ) { |
|
| 315 | + if (empty($wp_query->query_vars['token']) || empty($wp_query->query_vars['key'])) { |
|
| 316 | 316 | $this->missing_auth(); |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | // Retrieve the user by public API key and ensure they exist |
| 320 | - if ( ! ( $user = $this->get_user( $wp_query->query_vars['key'] ) ) ) { |
|
| 320 | + if ( ! ($user = $this->get_user($wp_query->query_vars['key']))) { |
|
| 321 | 321 | |
| 322 | 322 | $this->invalid_key(); |
| 323 | 323 | |
| 324 | 324 | } else { |
| 325 | 325 | |
| 326 | - $token = urldecode( $wp_query->query_vars['token'] ); |
|
| 327 | - $secret = $this->get_user_secret_key( $user ); |
|
| 328 | - $public = urldecode( $wp_query->query_vars['key'] ); |
|
| 326 | + $token = urldecode($wp_query->query_vars['token']); |
|
| 327 | + $secret = $this->get_user_secret_key($user); |
|
| 328 | + $public = urldecode($wp_query->query_vars['key']); |
|
| 329 | 329 | |
| 330 | - if ( hash_equals( md5( $secret . $public ), $token ) ) { |
|
| 330 | + if (hash_equals(md5($secret.$public), $token)) { |
|
| 331 | 331 | $this->is_valid_request = true; |
| 332 | 332 | } else { |
| 333 | 333 | $this->invalid_auth(); |
| 334 | 334 | } |
| 335 | 335 | } |
| 336 | - } elseif ( ! empty( $wp_query->query_vars['give-api'] ) && $wp_query->query_vars['give-api'] == 'forms' ) { |
|
| 336 | + } elseif ( ! empty($wp_query->query_vars['give-api']) && $wp_query->query_vars['give-api'] == 'forms') { |
|
| 337 | 337 | $this->is_valid_request = true; |
| 338 | - $wp_query->set( 'key', 'public' ); |
|
| 338 | + $wp_query->set('key', 'public'); |
|
| 339 | 339 | } |
| 340 | 340 | } |
| 341 | 341 | |
@@ -351,25 +351,25 @@ discard block |
||
| 351 | 351 | * |
| 352 | 352 | * @return bool if user ID is found, false otherwise |
| 353 | 353 | */ |
| 354 | - public function get_user( $key = '' ) { |
|
| 354 | + public function get_user($key = '') { |
|
| 355 | 355 | global $wpdb, $wp_query; |
| 356 | 356 | |
| 357 | - if ( empty( $key ) ) { |
|
| 358 | - $key = urldecode( $wp_query->query_vars['key'] ); |
|
| 357 | + if (empty($key)) { |
|
| 358 | + $key = urldecode($wp_query->query_vars['key']); |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | - if ( empty( $key ) ) { |
|
| 361 | + if (empty($key)) { |
|
| 362 | 362 | return false; |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | - $user = get_transient( md5( 'give_api_user_' . $key ) ); |
|
| 365 | + $user = get_transient(md5('give_api_user_'.$key)); |
|
| 366 | 366 | |
| 367 | - if ( false === $user ) { |
|
| 368 | - $user = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key ) ); |
|
| 369 | - set_transient( md5( 'give_api_user_' . $key ), $user, DAY_IN_SECONDS ); |
|
| 367 | + if (false === $user) { |
|
| 368 | + $user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key)); |
|
| 369 | + set_transient(md5('give_api_user_'.$key), $user, DAY_IN_SECONDS); |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - if ( $user != null ) { |
|
| 372 | + if ($user != null) { |
|
| 373 | 373 | $this->user_id = $user; |
| 374 | 374 | |
| 375 | 375 | return $user; |
@@ -378,37 +378,37 @@ discard block |
||
| 378 | 378 | return false; |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - public function get_user_public_key( $user_id = 0 ) { |
|
| 381 | + public function get_user_public_key($user_id = 0) { |
|
| 382 | 382 | global $wpdb; |
| 383 | 383 | |
| 384 | - if ( empty( $user_id ) ) { |
|
| 384 | + if (empty($user_id)) { |
|
| 385 | 385 | return ''; |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | - $cache_key = md5( 'give_api_user_public_key' . $user_id ); |
|
| 389 | - $user_public_key = get_transient( $cache_key ); |
|
| 388 | + $cache_key = md5('give_api_user_public_key'.$user_id); |
|
| 389 | + $user_public_key = get_transient($cache_key); |
|
| 390 | 390 | |
| 391 | - if ( empty( $user_public_key ) ) { |
|
| 392 | - $user_public_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id ) ); |
|
| 393 | - set_transient( $cache_key, $user_public_key, HOUR_IN_SECONDS ); |
|
| 391 | + if (empty($user_public_key)) { |
|
| 392 | + $user_public_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id)); |
|
| 393 | + set_transient($cache_key, $user_public_key, HOUR_IN_SECONDS); |
|
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | return $user_public_key; |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | - public function get_user_secret_key( $user_id = 0 ) { |
|
| 399 | + public function get_user_secret_key($user_id = 0) { |
|
| 400 | 400 | global $wpdb; |
| 401 | 401 | |
| 402 | - if ( empty( $user_id ) ) { |
|
| 402 | + if (empty($user_id)) { |
|
| 403 | 403 | return ''; |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | - $cache_key = md5( 'give_api_user_secret_key' . $user_id ); |
|
| 407 | - $user_secret_key = get_transient( $cache_key ); |
|
| 406 | + $cache_key = md5('give_api_user_secret_key'.$user_id); |
|
| 407 | + $user_secret_key = get_transient($cache_key); |
|
| 408 | 408 | |
| 409 | - if ( empty( $user_secret_key ) ) { |
|
| 410 | - $user_secret_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id ) ); |
|
| 411 | - set_transient( $cache_key, $user_secret_key, HOUR_IN_SECONDS ); |
|
| 409 | + if (empty($user_secret_key)) { |
|
| 410 | + $user_secret_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id)); |
|
| 411 | + set_transient($cache_key, $user_secret_key, HOUR_IN_SECONDS); |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | return $user_secret_key; |
@@ -424,10 +424,10 @@ discard block |
||
| 424 | 424 | */ |
| 425 | 425 | private function missing_auth() { |
| 426 | 426 | $error = array(); |
| 427 | - $error['error'] = esc_html__( 'You must specify both a token and API key.', 'give' ); |
|
| 427 | + $error['error'] = esc_html__('You must specify both a token and API key.', 'give'); |
|
| 428 | 428 | |
| 429 | 429 | $this->data = $error; |
| 430 | - $this->output( 401 ); |
|
| 430 | + $this->output(401); |
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | /** |
@@ -441,10 +441,10 @@ discard block |
||
| 441 | 441 | */ |
| 442 | 442 | private function invalid_auth() { |
| 443 | 443 | $error = array(); |
| 444 | - $error['error'] = esc_html__( 'Your request could not be authenticated.', 'give' ); |
|
| 444 | + $error['error'] = esc_html__('Your request could not be authenticated.', 'give'); |
|
| 445 | 445 | |
| 446 | 446 | $this->data = $error; |
| 447 | - $this->output( 403 ); |
|
| 447 | + $this->output(403); |
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | /** |
@@ -458,10 +458,10 @@ discard block |
||
| 458 | 458 | */ |
| 459 | 459 | private function invalid_key() { |
| 460 | 460 | $error = array(); |
| 461 | - $error['error'] = esc_html__( 'Invalid API key.', 'give' ); |
|
| 461 | + $error['error'] = esc_html__('Invalid API key.', 'give'); |
|
| 462 | 462 | |
| 463 | 463 | $this->data = $error; |
| 464 | - $this->output( 403 ); |
|
| 464 | + $this->output(403); |
|
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | /** |
@@ -474,10 +474,10 @@ discard block |
||
| 474 | 474 | */ |
| 475 | 475 | private function invalid_version() { |
| 476 | 476 | $error = array(); |
| 477 | - $error['error'] = esc_html__( 'Invalid API version.', 'give' ); |
|
| 477 | + $error['error'] = esc_html__('Invalid API version.', 'give'); |
|
| 478 | 478 | |
| 479 | 479 | $this->data = $error; |
| 480 | - $this->output( 404 ); |
|
| 480 | + $this->output(404); |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | /** |
@@ -493,10 +493,10 @@ discard block |
||
| 493 | 493 | global $wp_query; |
| 494 | 494 | |
| 495 | 495 | // Start logging how long the request takes for logging |
| 496 | - $before = microtime( true ); |
|
| 496 | + $before = microtime(true); |
|
| 497 | 497 | |
| 498 | 498 | // Check for give-api var. Get out if not present |
| 499 | - if ( empty( $wp_query->query_vars['give-api'] ) ) { |
|
| 499 | + if (empty($wp_query->query_vars['give-api'])) { |
|
| 500 | 500 | return; |
| 501 | 501 | } |
| 502 | 502 | |
@@ -510,45 +510,45 @@ discard block |
||
| 510 | 510 | $this->validate_request(); |
| 511 | 511 | |
| 512 | 512 | // Only proceed if no errors have been noted |
| 513 | - if ( ! $this->is_valid_request ) { |
|
| 513 | + if ( ! $this->is_valid_request) { |
|
| 514 | 514 | return; |
| 515 | 515 | } |
| 516 | 516 | |
| 517 | - if ( ! defined( 'GIVE_DOING_API' ) ) { |
|
| 518 | - define( 'GIVE_DOING_API', true ); |
|
| 517 | + if ( ! defined('GIVE_DOING_API')) { |
|
| 518 | + define('GIVE_DOING_API', true); |
|
| 519 | 519 | } |
| 520 | 520 | |
| 521 | 521 | $data = array(); |
| 522 | 522 | $this->routes = new $this->versions[$this->get_queried_version()]; |
| 523 | 523 | $this->routes->validate_request(); |
| 524 | 524 | |
| 525 | - switch ( $this->endpoint ) : |
|
| 525 | + switch ($this->endpoint) : |
|
| 526 | 526 | |
| 527 | 527 | case 'stats' : |
| 528 | 528 | |
| 529 | - $data = $this->routes->get_stats( array( |
|
| 530 | - 'type' => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null, |
|
| 531 | - 'form' => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null, |
|
| 532 | - 'date' => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null, |
|
| 533 | - 'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null, |
|
| 534 | - 'enddate' => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null |
|
| 535 | - ) ); |
|
| 529 | + $data = $this->routes->get_stats(array( |
|
| 530 | + 'type' => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null, |
|
| 531 | + 'form' => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null, |
|
| 532 | + 'date' => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null, |
|
| 533 | + 'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null, |
|
| 534 | + 'enddate' => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null |
|
| 535 | + )); |
|
| 536 | 536 | |
| 537 | 537 | break; |
| 538 | 538 | |
| 539 | 539 | case 'forms' : |
| 540 | 540 | |
| 541 | - $form = isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null; |
|
| 541 | + $form = isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null; |
|
| 542 | 542 | |
| 543 | - $data = $this->routes->get_forms( $form ); |
|
| 543 | + $data = $this->routes->get_forms($form); |
|
| 544 | 544 | |
| 545 | 545 | break; |
| 546 | 546 | |
| 547 | 547 | case 'donors' : |
| 548 | 548 | |
| 549 | - $customer = isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null; |
|
| 549 | + $customer = isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null; |
|
| 550 | 550 | |
| 551 | - $data = $this->routes->get_customers( $customer ); |
|
| 551 | + $data = $this->routes->get_customers($customer); |
|
| 552 | 552 | |
| 553 | 553 | break; |
| 554 | 554 | |
@@ -561,14 +561,14 @@ discard block |
||
| 561 | 561 | endswitch; |
| 562 | 562 | |
| 563 | 563 | // Allow extensions to setup their own return data |
| 564 | - $this->data = apply_filters( 'give_api_output_data', $data, $this->endpoint, $this ); |
|
| 564 | + $this->data = apply_filters('give_api_output_data', $data, $this->endpoint, $this); |
|
| 565 | 565 | |
| 566 | - $after = microtime( true ); |
|
| 567 | - $request_time = ( $after - $before ); |
|
| 566 | + $after = microtime(true); |
|
| 567 | + $request_time = ($after - $before); |
|
| 568 | 568 | $this->data['request_speed'] = $request_time; |
| 569 | 569 | |
| 570 | 570 | // Log this API request, if enabled. We log it here because we have access to errors. |
| 571 | - $this->log_request( $this->data ); |
|
| 571 | + $this->log_request($this->data); |
|
| 572 | 572 | |
| 573 | 573 | // Send out data to the output function |
| 574 | 574 | $this->output(); |
@@ -598,25 +598,25 @@ discard block |
||
| 598 | 598 | global $wp_query; |
| 599 | 599 | |
| 600 | 600 | // Whitelist our query options |
| 601 | - $accepted = apply_filters( 'give_api_valid_query_modes', array( |
|
| 601 | + $accepted = apply_filters('give_api_valid_query_modes', array( |
|
| 602 | 602 | 'stats', |
| 603 | 603 | 'forms', |
| 604 | 604 | 'donors', |
| 605 | 605 | 'donations' |
| 606 | - ) ); |
|
| 606 | + )); |
|
| 607 | 607 | |
| 608 | - $query = isset( $wp_query->query_vars['give-api'] ) ? $wp_query->query_vars['give-api'] : null; |
|
| 609 | - $query = str_replace( $this->queried_version . '/', '', $query ); |
|
| 608 | + $query = isset($wp_query->query_vars['give-api']) ? $wp_query->query_vars['give-api'] : null; |
|
| 609 | + $query = str_replace($this->queried_version.'/', '', $query); |
|
| 610 | 610 | |
| 611 | 611 | $error = array(); |
| 612 | 612 | |
| 613 | 613 | // Make sure our query is valid |
| 614 | - if ( ! in_array( $query, $accepted ) ) { |
|
| 615 | - $error['error'] = esc_html__( 'Invalid query.', 'give' ); |
|
| 614 | + if ( ! in_array($query, $accepted)) { |
|
| 615 | + $error['error'] = esc_html__('Invalid query.', 'give'); |
|
| 616 | 616 | |
| 617 | 617 | $this->data = $error; |
| 618 | 618 | // 400 is Bad Request |
| 619 | - $this->output( 400 ); |
|
| 619 | + $this->output(400); |
|
| 620 | 620 | } |
| 621 | 621 | |
| 622 | 622 | $this->endpoint = $query; |
@@ -633,7 +633,7 @@ discard block |
||
| 633 | 633 | public function get_paged() { |
| 634 | 634 | global $wp_query; |
| 635 | 635 | |
| 636 | - return isset( $wp_query->query_vars['page'] ) ? $wp_query->query_vars['page'] : 1; |
|
| 636 | + return isset($wp_query->query_vars['page']) ? $wp_query->query_vars['page'] : 1; |
|
| 637 | 637 | } |
| 638 | 638 | |
| 639 | 639 | |
@@ -648,13 +648,13 @@ discard block |
||
| 648 | 648 | public function per_page() { |
| 649 | 649 | global $wp_query; |
| 650 | 650 | |
| 651 | - $per_page = isset( $wp_query->query_vars['number'] ) ? $wp_query->query_vars['number'] : 10; |
|
| 651 | + $per_page = isset($wp_query->query_vars['number']) ? $wp_query->query_vars['number'] : 10; |
|
| 652 | 652 | |
| 653 | - if ( $per_page < 0 && $this->get_query_mode() == 'donors' ) { |
|
| 653 | + if ($per_page < 0 && $this->get_query_mode() == 'donors') { |
|
| 654 | 654 | $per_page = 99999999; |
| 655 | 655 | } // Customers query doesn't support -1 |
| 656 | 656 | |
| 657 | - return apply_filters( 'give_api_results_per_page', $per_page ); |
|
| 657 | + return apply_filters('give_api_results_per_page', $per_page); |
|
| 658 | 658 | } |
| 659 | 659 | |
| 660 | 660 | /** |
@@ -667,7 +667,7 @@ discard block |
||
| 667 | 667 | * |
| 668 | 668 | * @return array $dates |
| 669 | 669 | */ |
| 670 | - public function get_dates( $args = array() ) { |
|
| 670 | + public function get_dates($args = array()) { |
|
| 671 | 671 | $dates = array(); |
| 672 | 672 | |
| 673 | 673 | $defaults = array( |
@@ -678,60 +678,60 @@ discard block |
||
| 678 | 678 | 'enddate' => null |
| 679 | 679 | ); |
| 680 | 680 | |
| 681 | - $args = wp_parse_args( $args, $defaults ); |
|
| 681 | + $args = wp_parse_args($args, $defaults); |
|
| 682 | 682 | |
| 683 | - $current_time = current_time( 'timestamp' ); |
|
| 683 | + $current_time = current_time('timestamp'); |
|
| 684 | 684 | |
| 685 | - if ( 'range' === $args['date'] ) { |
|
| 686 | - $startdate = strtotime( $args['startdate'] ); |
|
| 687 | - $enddate = strtotime( $args['enddate'] ); |
|
| 688 | - $dates['day_start'] = date( 'd', $startdate ); |
|
| 689 | - $dates['day_end'] = date( 'd', $enddate ); |
|
| 690 | - $dates['m_start'] = date( 'n', $startdate ); |
|
| 691 | - $dates['m_end'] = date( 'n', $enddate ); |
|
| 692 | - $dates['year'] = date( 'Y', $startdate ); |
|
| 693 | - $dates['year_end'] = date( 'Y', $enddate ); |
|
| 685 | + if ('range' === $args['date']) { |
|
| 686 | + $startdate = strtotime($args['startdate']); |
|
| 687 | + $enddate = strtotime($args['enddate']); |
|
| 688 | + $dates['day_start'] = date('d', $startdate); |
|
| 689 | + $dates['day_end'] = date('d', $enddate); |
|
| 690 | + $dates['m_start'] = date('n', $startdate); |
|
| 691 | + $dates['m_end'] = date('n', $enddate); |
|
| 692 | + $dates['year'] = date('Y', $startdate); |
|
| 693 | + $dates['year_end'] = date('Y', $enddate); |
|
| 694 | 694 | } else { |
| 695 | 695 | // Modify dates based on predefined ranges |
| 696 | - switch ( $args['date'] ) : |
|
| 696 | + switch ($args['date']) : |
|
| 697 | 697 | |
| 698 | 698 | case 'this_month' : |
| 699 | 699 | $dates['day'] = null; |
| 700 | - $dates['m_start'] = date( 'n', $current_time ); |
|
| 701 | - $dates['m_end'] = date( 'n', $current_time ); |
|
| 702 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 700 | + $dates['m_start'] = date('n', $current_time); |
|
| 701 | + $dates['m_end'] = date('n', $current_time); |
|
| 702 | + $dates['year'] = date('Y', $current_time); |
|
| 703 | 703 | break; |
| 704 | 704 | |
| 705 | 705 | case 'last_month' : |
| 706 | 706 | $dates['day'] = null; |
| 707 | - $dates['m_start'] = date( 'n', $current_time ) == 1 ? 12 : date( 'n', $current_time ) - 1; |
|
| 707 | + $dates['m_start'] = date('n', $current_time) == 1 ? 12 : date('n', $current_time) - 1; |
|
| 708 | 708 | $dates['m_end'] = $dates['m_start']; |
| 709 | - $dates['year'] = date( 'n', $current_time ) == 1 ? date( 'Y', $current_time ) - 1 : date( 'Y', $current_time ); |
|
| 709 | + $dates['year'] = date('n', $current_time) == 1 ? date('Y', $current_time) - 1 : date('Y', $current_time); |
|
| 710 | 710 | break; |
| 711 | 711 | |
| 712 | 712 | case 'today' : |
| 713 | - $dates['day'] = date( 'd', $current_time ); |
|
| 714 | - $dates['m_start'] = date( 'n', $current_time ); |
|
| 715 | - $dates['m_end'] = date( 'n', $current_time ); |
|
| 716 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 713 | + $dates['day'] = date('d', $current_time); |
|
| 714 | + $dates['m_start'] = date('n', $current_time); |
|
| 715 | + $dates['m_end'] = date('n', $current_time); |
|
| 716 | + $dates['year'] = date('Y', $current_time); |
|
| 717 | 717 | break; |
| 718 | 718 | |
| 719 | 719 | case 'yesterday' : |
| 720 | 720 | |
| 721 | - $year = date( 'Y', $current_time ); |
|
| 722 | - $month = date( 'n', $current_time ); |
|
| 723 | - $day = date( 'd', $current_time ); |
|
| 721 | + $year = date('Y', $current_time); |
|
| 722 | + $month = date('n', $current_time); |
|
| 723 | + $day = date('d', $current_time); |
|
| 724 | 724 | |
| 725 | - if ( $month == 1 && $day == 1 ) { |
|
| 725 | + if ($month == 1 && $day == 1) { |
|
| 726 | 726 | |
| 727 | 727 | $year -= 1; |
| 728 | 728 | $month = 12; |
| 729 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 729 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 730 | 730 | |
| 731 | - } elseif ( $month > 1 && $day == 1 ) { |
|
| 731 | + } elseif ($month > 1 && $day == 1) { |
|
| 732 | 732 | |
| 733 | 733 | $month -= 1; |
| 734 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 734 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 735 | 735 | |
| 736 | 736 | } else { |
| 737 | 737 | |
@@ -747,65 +747,65 @@ discard block |
||
| 747 | 747 | break; |
| 748 | 748 | |
| 749 | 749 | case 'this_quarter' : |
| 750 | - $month_now = date( 'n', $current_time ); |
|
| 750 | + $month_now = date('n', $current_time); |
|
| 751 | 751 | |
| 752 | 752 | $dates['day'] = null; |
| 753 | 753 | |
| 754 | - if ( $month_now <= 3 ) { |
|
| 754 | + if ($month_now <= 3) { |
|
| 755 | 755 | |
| 756 | 756 | $dates['m_start'] = 1; |
| 757 | 757 | $dates['m_end'] = 3; |
| 758 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 758 | + $dates['year'] = date('Y', $current_time); |
|
| 759 | 759 | |
| 760 | - } else if ( $month_now <= 6 ) { |
|
| 760 | + } else if ($month_now <= 6) { |
|
| 761 | 761 | |
| 762 | 762 | $dates['m_start'] = 4; |
| 763 | 763 | $dates['m_end'] = 6; |
| 764 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 764 | + $dates['year'] = date('Y', $current_time); |
|
| 765 | 765 | |
| 766 | - } else if ( $month_now <= 9 ) { |
|
| 766 | + } else if ($month_now <= 9) { |
|
| 767 | 767 | |
| 768 | 768 | $dates['m_start'] = 7; |
| 769 | 769 | $dates['m_end'] = 9; |
| 770 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 770 | + $dates['year'] = date('Y', $current_time); |
|
| 771 | 771 | |
| 772 | 772 | } else { |
| 773 | 773 | |
| 774 | 774 | $dates['m_start'] = 10; |
| 775 | 775 | $dates['m_end'] = 12; |
| 776 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 776 | + $dates['year'] = date('Y', $current_time); |
|
| 777 | 777 | |
| 778 | 778 | } |
| 779 | 779 | break; |
| 780 | 780 | |
| 781 | 781 | case 'last_quarter' : |
| 782 | - $month_now = date( 'n', $current_time ); |
|
| 782 | + $month_now = date('n', $current_time); |
|
| 783 | 783 | |
| 784 | 784 | $dates['day'] = null; |
| 785 | 785 | |
| 786 | - if ( $month_now <= 3 ) { |
|
| 786 | + if ($month_now <= 3) { |
|
| 787 | 787 | |
| 788 | 788 | $dates['m_start'] = 10; |
| 789 | 789 | $dates['m_end'] = 12; |
| 790 | - $dates['year'] = date( 'Y', $current_time ) - 1; // Previous year |
|
| 790 | + $dates['year'] = date('Y', $current_time) - 1; // Previous year |
|
| 791 | 791 | |
| 792 | - } else if ( $month_now <= 6 ) { |
|
| 792 | + } else if ($month_now <= 6) { |
|
| 793 | 793 | |
| 794 | 794 | $dates['m_start'] = 1; |
| 795 | 795 | $dates['m_end'] = 3; |
| 796 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 796 | + $dates['year'] = date('Y', $current_time); |
|
| 797 | 797 | |
| 798 | - } else if ( $month_now <= 9 ) { |
|
| 798 | + } else if ($month_now <= 9) { |
|
| 799 | 799 | |
| 800 | 800 | $dates['m_start'] = 4; |
| 801 | 801 | $dates['m_end'] = 6; |
| 802 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 802 | + $dates['year'] = date('Y', $current_time); |
|
| 803 | 803 | |
| 804 | 804 | } else { |
| 805 | 805 | |
| 806 | 806 | $dates['m_start'] = 7; |
| 807 | 807 | $dates['m_end'] = 9; |
| 808 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 808 | + $dates['year'] = date('Y', $current_time); |
|
| 809 | 809 | |
| 810 | 810 | } |
| 811 | 811 | break; |
@@ -814,14 +814,14 @@ discard block |
||
| 814 | 814 | $dates['day'] = null; |
| 815 | 815 | $dates['m_start'] = null; |
| 816 | 816 | $dates['m_end'] = null; |
| 817 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 817 | + $dates['year'] = date('Y', $current_time); |
|
| 818 | 818 | break; |
| 819 | 819 | |
| 820 | 820 | case 'last_year' : |
| 821 | 821 | $dates['day'] = null; |
| 822 | 822 | $dates['m_start'] = null; |
| 823 | 823 | $dates['m_end'] = null; |
| 824 | - $dates['year'] = date( 'Y', $current_time ) - 1; |
|
| 824 | + $dates['year'] = date('Y', $current_time) - 1; |
|
| 825 | 825 | break; |
| 826 | 826 | |
| 827 | 827 | endswitch; |
@@ -835,7 +835,7 @@ discard block |
||
| 835 | 835 | * @param object $dates The dates used for retrieving earnings/donations |
| 836 | 836 | */ |
| 837 | 837 | |
| 838 | - return apply_filters( 'give_api_stat_dates', $dates ); |
|
| 838 | + return apply_filters('give_api_stat_dates', $dates); |
|
| 839 | 839 | } |
| 840 | 840 | |
| 841 | 841 | /** |
@@ -850,11 +850,11 @@ discard block |
||
| 850 | 850 | * |
| 851 | 851 | * @return array $customers Multidimensional array of the customers |
| 852 | 852 | */ |
| 853 | - public function get_customers( $customer = null ) { |
|
| 853 | + public function get_customers($customer = null) { |
|
| 854 | 854 | |
| 855 | 855 | $customers = array(); |
| 856 | 856 | $error = array(); |
| 857 | - if ( ! user_can( $this->user_id, 'view_give_sensitive_data' ) && ! $this->override ) { |
|
| 857 | + if ( ! user_can($this->user_id, 'view_give_sensitive_data') && ! $this->override) { |
|
| 858 | 858 | return $customers; |
| 859 | 859 | } |
| 860 | 860 | |
@@ -862,64 +862,64 @@ discard block |
||
| 862 | 862 | |
| 863 | 863 | $paged = $this->get_paged(); |
| 864 | 864 | $per_page = $this->per_page(); |
| 865 | - $offset = $per_page * ( $paged - 1 ); |
|
| 865 | + $offset = $per_page * ($paged - 1); |
|
| 866 | 866 | |
| 867 | - if ( is_numeric( $customer ) ) { |
|
| 867 | + if (is_numeric($customer)) { |
|
| 868 | 868 | $field = 'id'; |
| 869 | 869 | } else { |
| 870 | 870 | $field = 'email'; |
| 871 | 871 | } |
| 872 | 872 | |
| 873 | - $customer_query = Give()->customers->get_customers( array( |
|
| 873 | + $customer_query = Give()->customers->get_customers(array( |
|
| 874 | 874 | 'number' => $per_page, |
| 875 | 875 | 'offset' => $offset, |
| 876 | 876 | $field => $customer |
| 877 | - ) ); |
|
| 877 | + )); |
|
| 878 | 878 | $customer_count = 0; |
| 879 | 879 | |
| 880 | - if ( $customer_query ) { |
|
| 880 | + if ($customer_query) { |
|
| 881 | 881 | |
| 882 | - foreach ( $customer_query as $customer_obj ) { |
|
| 882 | + foreach ($customer_query as $customer_obj) { |
|
| 883 | 883 | |
| 884 | - $names = explode( ' ', $customer_obj->name ); |
|
| 885 | - $first_name = ! empty( $names[0] ) ? $names[0] : ''; |
|
| 884 | + $names = explode(' ', $customer_obj->name); |
|
| 885 | + $first_name = ! empty($names[0]) ? $names[0] : ''; |
|
| 886 | 886 | $last_name = ''; |
| 887 | - if ( ! empty( $names[1] ) ) { |
|
| 888 | - unset( $names[0] ); |
|
| 889 | - $last_name = implode( ' ', $names ); |
|
| 887 | + if ( ! empty($names[1])) { |
|
| 888 | + unset($names[0]); |
|
| 889 | + $last_name = implode(' ', $names); |
|
| 890 | 890 | } |
| 891 | 891 | |
| 892 | - $customers['donors'][ $customer_count ]['info']['user_id'] = ''; |
|
| 893 | - $customers['donors'][ $customer_count ]['info']['username'] = ''; |
|
| 894 | - $customers['donors'][ $customer_count ]['info']['display_name'] = ''; |
|
| 895 | - $customers['donors'][ $customer_count ]['info']['customer_id'] = $customer_obj->id; |
|
| 896 | - $customers['donors'][ $customer_count ]['info']['first_name'] = $first_name; |
|
| 897 | - $customers['donors'][ $customer_count ]['info']['last_name'] = $last_name; |
|
| 898 | - $customers['donors'][ $customer_count ]['info']['email'] = $customer_obj->email; |
|
| 892 | + $customers['donors'][$customer_count]['info']['user_id'] = ''; |
|
| 893 | + $customers['donors'][$customer_count]['info']['username'] = ''; |
|
| 894 | + $customers['donors'][$customer_count]['info']['display_name'] = ''; |
|
| 895 | + $customers['donors'][$customer_count]['info']['customer_id'] = $customer_obj->id; |
|
| 896 | + $customers['donors'][$customer_count]['info']['first_name'] = $first_name; |
|
| 897 | + $customers['donors'][$customer_count]['info']['last_name'] = $last_name; |
|
| 898 | + $customers['donors'][$customer_count]['info']['email'] = $customer_obj->email; |
|
| 899 | 899 | |
| 900 | - if ( ! empty( $customer_obj->user_id ) ) { |
|
| 900 | + if ( ! empty($customer_obj->user_id)) { |
|
| 901 | 901 | |
| 902 | - $user_data = get_userdata( $customer_obj->user_id ); |
|
| 902 | + $user_data = get_userdata($customer_obj->user_id); |
|
| 903 | 903 | |
| 904 | 904 | // Customer with registered account |
| 905 | - $customers['donors'][ $customer_count ]['info']['user_id'] = $customer_obj->user_id; |
|
| 906 | - $customers['donors'][ $customer_count ]['info']['username'] = $user_data->user_login; |
|
| 907 | - $customers['donors'][ $customer_count ]['info']['display_name'] = $user_data->display_name; |
|
| 905 | + $customers['donors'][$customer_count]['info']['user_id'] = $customer_obj->user_id; |
|
| 906 | + $customers['donors'][$customer_count]['info']['username'] = $user_data->user_login; |
|
| 907 | + $customers['donors'][$customer_count]['info']['display_name'] = $user_data->display_name; |
|
| 908 | 908 | |
| 909 | 909 | } |
| 910 | 910 | |
| 911 | - $customers['donors'][ $customer_count ]['stats']['total_donations'] = $customer_obj->purchase_count; |
|
| 912 | - $customers['donors'][ $customer_count ]['stats']['total_spent'] = $customer_obj->purchase_value; |
|
| 911 | + $customers['donors'][$customer_count]['stats']['total_donations'] = $customer_obj->purchase_count; |
|
| 912 | + $customers['donors'][$customer_count]['stats']['total_spent'] = $customer_obj->purchase_value; |
|
| 913 | 913 | |
| 914 | - $customer_count ++; |
|
| 914 | + $customer_count++; |
|
| 915 | 915 | |
| 916 | 916 | } |
| 917 | 917 | |
| 918 | - } elseif ( $customer ) { |
|
| 918 | + } elseif ($customer) { |
|
| 919 | 919 | |
| 920 | 920 | $error['error'] = sprintf( |
| 921 | 921 | /* translators: %s: customer */ |
| 922 | - esc_html__( 'Donor %s not found.', 'give' ), |
|
| 922 | + esc_html__('Donor %s not found.', 'give'), |
|
| 923 | 923 | $customer |
| 924 | 924 | ); |
| 925 | 925 | |
@@ -927,7 +927,7 @@ discard block |
||
| 927 | 927 | |
| 928 | 928 | } else { |
| 929 | 929 | |
| 930 | - $error['error'] = esc_html__( 'No donors found.', 'give' ); |
|
| 930 | + $error['error'] = esc_html__('No donors found.', 'give'); |
|
| 931 | 931 | |
| 932 | 932 | return $error; |
| 933 | 933 | |
@@ -946,38 +946,38 @@ discard block |
||
| 946 | 946 | * |
| 947 | 947 | * @return array $customers Multidimensional array of the forms |
| 948 | 948 | */ |
| 949 | - public function get_forms( $form = null ) { |
|
| 949 | + public function get_forms($form = null) { |
|
| 950 | 950 | |
| 951 | 951 | $forms = array(); |
| 952 | 952 | $error = array(); |
| 953 | 953 | |
| 954 | - if ( $form == null ) { |
|
| 954 | + if ($form == null) { |
|
| 955 | 955 | $forms['forms'] = array(); |
| 956 | 956 | |
| 957 | - $form_list = get_posts( array( |
|
| 957 | + $form_list = get_posts(array( |
|
| 958 | 958 | 'post_type' => 'give_forms', |
| 959 | 959 | 'posts_per_page' => $this->per_page(), |
| 960 | 960 | 'suppress_filters' => true, |
| 961 | 961 | 'paged' => $this->get_paged() |
| 962 | - ) ); |
|
| 962 | + )); |
|
| 963 | 963 | |
| 964 | - if ( $form_list ) { |
|
| 964 | + if ($form_list) { |
|
| 965 | 965 | $i = 0; |
| 966 | - foreach ( $form_list as $form_info ) { |
|
| 967 | - $forms['forms'][ $i ] = $this->get_form_data( $form_info ); |
|
| 968 | - $i ++; |
|
| 966 | + foreach ($form_list as $form_info) { |
|
| 967 | + $forms['forms'][$i] = $this->get_form_data($form_info); |
|
| 968 | + $i++; |
|
| 969 | 969 | } |
| 970 | 970 | } |
| 971 | 971 | } else { |
| 972 | - if ( get_post_type( $form ) == 'give_forms' ) { |
|
| 973 | - $form_info = get_post( $form ); |
|
| 972 | + if (get_post_type($form) == 'give_forms') { |
|
| 973 | + $form_info = get_post($form); |
|
| 974 | 974 | |
| 975 | - $forms['forms'][0] = $this->get_form_data( $form_info ); |
|
| 975 | + $forms['forms'][0] = $this->get_form_data($form_info); |
|
| 976 | 976 | |
| 977 | 977 | } else { |
| 978 | 978 | $error['error'] = sprintf( |
| 979 | 979 | /* translators: %s: form */ |
| 980 | - esc_html__( 'Form %s not found.', 'give' ), |
|
| 980 | + esc_html__('Form %s not found.', 'give'), |
|
| 981 | 981 | $form |
| 982 | 982 | ); |
| 983 | 983 | |
@@ -997,7 +997,7 @@ discard block |
||
| 997 | 997 | * |
| 998 | 998 | * @return array Array of post data to return back in the API |
| 999 | 999 | */ |
| 1000 | - private function get_form_data( $form_info ) { |
|
| 1000 | + private function get_form_data($form_info) { |
|
| 1001 | 1001 | |
| 1002 | 1002 | $form = array(); |
| 1003 | 1003 | |
@@ -1007,50 +1007,50 @@ discard block |
||
| 1007 | 1007 | $form['info']['create_date'] = $form_info->post_date; |
| 1008 | 1008 | $form['info']['modified_date'] = $form_info->post_modified; |
| 1009 | 1009 | $form['info']['status'] = $form_info->post_status; |
| 1010 | - $form['info']['link'] = html_entity_decode( $form_info->guid ); |
|
| 1011 | - $form['info']['content'] = get_post_meta( $form_info->ID, '_give_form_content', true ); |
|
| 1012 | - $form['info']['thumbnail'] = wp_get_attachment_url( get_post_thumbnail_id( $form_info->ID ) ); |
|
| 1010 | + $form['info']['link'] = html_entity_decode($form_info->guid); |
|
| 1011 | + $form['info']['content'] = get_post_meta($form_info->ID, '_give_form_content', true); |
|
| 1012 | + $form['info']['thumbnail'] = wp_get_attachment_url(get_post_thumbnail_id($form_info->ID)); |
|
| 1013 | 1013 | |
| 1014 | - if ( give_get_option( 'enable_categories' ) == 'on' ) { |
|
| 1015 | - $form['info']['category'] = get_the_terms( $form_info, 'give_forms_category' ); |
|
| 1016 | - $form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' ); |
|
| 1014 | + if (give_get_option('enable_categories') == 'on') { |
|
| 1015 | + $form['info']['category'] = get_the_terms($form_info, 'give_forms_category'); |
|
| 1016 | + $form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag'); |
|
| 1017 | 1017 | } |
| 1018 | - if ( give_get_option( 'enable_tags' ) == 'on' ) { |
|
| 1019 | - $form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' ); |
|
| 1018 | + if (give_get_option('enable_tags') == 'on') { |
|
| 1019 | + $form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag'); |
|
| 1020 | 1020 | } |
| 1021 | 1021 | |
| 1022 | - if ( user_can( $this->user_id, 'view_give_reports' ) || $this->override ) { |
|
| 1023 | - $form['stats']['total']['donations'] = give_get_form_sales_stats( $form_info->ID ); |
|
| 1024 | - $form['stats']['total']['earnings'] = give_get_form_earnings_stats( $form_info->ID ); |
|
| 1025 | - $form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales( $form_info->ID ); |
|
| 1026 | - $form['stats']['monthly_average']['earnings'] = give_get_average_monthly_form_earnings( $form_info->ID ); |
|
| 1022 | + if (user_can($this->user_id, 'view_give_reports') || $this->override) { |
|
| 1023 | + $form['stats']['total']['donations'] = give_get_form_sales_stats($form_info->ID); |
|
| 1024 | + $form['stats']['total']['earnings'] = give_get_form_earnings_stats($form_info->ID); |
|
| 1025 | + $form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales($form_info->ID); |
|
| 1026 | + $form['stats']['monthly_average']['earnings'] = give_get_average_monthly_form_earnings($form_info->ID); |
|
| 1027 | 1027 | } |
| 1028 | 1028 | |
| 1029 | 1029 | $counter = 0; |
| 1030 | - if ( give_has_variable_prices( $form_info->ID ) ) { |
|
| 1031 | - foreach ( give_get_variable_prices( $form_info->ID ) as $price ) { |
|
| 1032 | - $counter ++; |
|
| 1030 | + if (give_has_variable_prices($form_info->ID)) { |
|
| 1031 | + foreach (give_get_variable_prices($form_info->ID) as $price) { |
|
| 1032 | + $counter++; |
|
| 1033 | 1033 | //muli-level item |
| 1034 | - $level = isset( $price['_give_text'] ) ? $price['_give_text'] : 'level-' . $counter; |
|
| 1035 | - $form['pricing'][ sanitize_key( $level ) ] = $price['_give_amount']; |
|
| 1034 | + $level = isset($price['_give_text']) ? $price['_give_text'] : 'level-'.$counter; |
|
| 1035 | + $form['pricing'][sanitize_key($level)] = $price['_give_amount']; |
|
| 1036 | 1036 | |
| 1037 | 1037 | } |
| 1038 | 1038 | } else { |
| 1039 | - $form['pricing']['amount'] = give_get_form_price( $form_info->ID ); |
|
| 1039 | + $form['pricing']['amount'] = give_get_form_price($form_info->ID); |
|
| 1040 | 1040 | } |
| 1041 | 1041 | |
| 1042 | - if ( user_can( $this->user_id, 'view_give_sensitive_data' ) || $this->override ) { |
|
| 1042 | + if (user_can($this->user_id, 'view_give_sensitive_data') || $this->override) { |
|
| 1043 | 1043 | |
| 1044 | 1044 | /** |
| 1045 | 1045 | * Fires when generating API sensitive data. |
| 1046 | 1046 | * |
| 1047 | 1047 | * @since 1.1 |
| 1048 | 1048 | */ |
| 1049 | - do_action( 'give_api_sensitive_data' ); |
|
| 1049 | + do_action('give_api_sensitive_data'); |
|
| 1050 | 1050 | |
| 1051 | 1051 | } |
| 1052 | 1052 | |
| 1053 | - return apply_filters( 'give_api_forms_form', $form ); |
|
| 1053 | + return apply_filters('give_api_forms_form', $form); |
|
| 1054 | 1054 | |
| 1055 | 1055 | } |
| 1056 | 1056 | |
@@ -1065,7 +1065,7 @@ discard block |
||
| 1065 | 1065 | * |
| 1066 | 1066 | * @return array |
| 1067 | 1067 | */ |
| 1068 | - public function get_stats( $args = array() ) { |
|
| 1068 | + public function get_stats($args = array()) { |
|
| 1069 | 1069 | $defaults = array( |
| 1070 | 1070 | 'type' => null, |
| 1071 | 1071 | 'form' => null, |
@@ -1074,9 +1074,9 @@ discard block |
||
| 1074 | 1074 | 'enddate' => null |
| 1075 | 1075 | ); |
| 1076 | 1076 | |
| 1077 | - $args = wp_parse_args( $args, $defaults ); |
|
| 1077 | + $args = wp_parse_args($args, $defaults); |
|
| 1078 | 1078 | |
| 1079 | - $dates = $this->get_dates( $args ); |
|
| 1079 | + $dates = $this->get_dates($args); |
|
| 1080 | 1080 | |
| 1081 | 1081 | $stats = array(); |
| 1082 | 1082 | $earnings = array( |
@@ -1087,41 +1087,41 @@ discard block |
||
| 1087 | 1087 | ); |
| 1088 | 1088 | $error = array(); |
| 1089 | 1089 | |
| 1090 | - if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) { |
|
| 1090 | + if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) { |
|
| 1091 | 1091 | return $stats; |
| 1092 | 1092 | } |
| 1093 | 1093 | |
| 1094 | - if ( $args['type'] == 'donations' ) { |
|
| 1094 | + if ($args['type'] == 'donations') { |
|
| 1095 | 1095 | |
| 1096 | - if ( $args['form'] == null ) { |
|
| 1097 | - if ( $args['date'] == null ) { |
|
| 1096 | + if ($args['form'] == null) { |
|
| 1097 | + if ($args['date'] == null) { |
|
| 1098 | 1098 | $sales = $this->get_default_sales_stats(); |
| 1099 | - } elseif ( $args['date'] === 'range' ) { |
|
| 1099 | + } elseif ($args['date'] === 'range') { |
|
| 1100 | 1100 | // Return sales for a date range |
| 1101 | 1101 | |
| 1102 | 1102 | // Ensure the end date is later than the start date |
| 1103 | - if ( $args['enddate'] < $args['startdate'] ) { |
|
| 1104 | - $error['error'] = esc_html__( 'The end date must be later than the start date.', 'give' ); |
|
| 1103 | + if ($args['enddate'] < $args['startdate']) { |
|
| 1104 | + $error['error'] = esc_html__('The end date must be later than the start date.', 'give'); |
|
| 1105 | 1105 | } |
| 1106 | 1106 | |
| 1107 | 1107 | // Ensure both the start and end date are specified |
| 1108 | - if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) { |
|
| 1109 | - $error['error'] = esc_html__( 'Invalid or no date range specified.', 'give' ); |
|
| 1108 | + if (empty($args['startdate']) || empty($args['enddate'])) { |
|
| 1109 | + $error['error'] = esc_html__('Invalid or no date range specified.', 'give'); |
|
| 1110 | 1110 | } |
| 1111 | 1111 | |
| 1112 | 1112 | $total = 0; |
| 1113 | 1113 | |
| 1114 | 1114 | // Loop through the years |
| 1115 | 1115 | $y = $dates['year']; |
| 1116 | - while ( $y <= $dates['year_end'] ) : |
|
| 1116 | + while ($y <= $dates['year_end']) : |
|
| 1117 | 1117 | |
| 1118 | - if ( $dates['year'] == $dates['year_end'] ) { |
|
| 1118 | + if ($dates['year'] == $dates['year_end']) { |
|
| 1119 | 1119 | $month_start = $dates['m_start']; |
| 1120 | 1120 | $month_end = $dates['m_end']; |
| 1121 | - } elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) { |
|
| 1121 | + } elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) { |
|
| 1122 | 1122 | $month_start = $dates['m_start']; |
| 1123 | 1123 | $month_end = 12; |
| 1124 | - } elseif ( $y == $dates['year_end'] ) { |
|
| 1124 | + } elseif ($y == $dates['year_end']) { |
|
| 1125 | 1125 | $month_start = 1; |
| 1126 | 1126 | $month_end = $dates['m_end']; |
| 1127 | 1127 | } else { |
@@ -1130,113 +1130,113 @@ discard block |
||
| 1130 | 1130 | } |
| 1131 | 1131 | |
| 1132 | 1132 | $i = $month_start; |
| 1133 | - while ( $i <= $month_end ) : |
|
| 1133 | + while ($i <= $month_end) : |
|
| 1134 | 1134 | |
| 1135 | - if ( $i == $dates['m_start'] ) { |
|
| 1135 | + if ($i == $dates['m_start']) { |
|
| 1136 | 1136 | $d = $dates['day_start']; |
| 1137 | 1137 | } else { |
| 1138 | 1138 | $d = 1; |
| 1139 | 1139 | } |
| 1140 | 1140 | |
| 1141 | - if ( $i == $dates['m_end'] ) { |
|
| 1141 | + if ($i == $dates['m_end']) { |
|
| 1142 | 1142 | $num_of_days = $dates['day_end']; |
| 1143 | 1143 | } else { |
| 1144 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
| 1144 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
| 1145 | 1145 | } |
| 1146 | 1146 | |
| 1147 | - while ( $d <= $num_of_days ) : |
|
| 1148 | - $sale_count = give_get_sales_by_date( $d, $i, $y ); |
|
| 1149 | - $date_key = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) ); |
|
| 1150 | - if ( ! isset( $sales['sales'][ $date_key ] ) ) { |
|
| 1151 | - $sales['sales'][ $date_key ] = 0; |
|
| 1147 | + while ($d <= $num_of_days) : |
|
| 1148 | + $sale_count = give_get_sales_by_date($d, $i, $y); |
|
| 1149 | + $date_key = date('Ymd', strtotime($y.'/'.$i.'/'.$d)); |
|
| 1150 | + if ( ! isset($sales['sales'][$date_key])) { |
|
| 1151 | + $sales['sales'][$date_key] = 0; |
|
| 1152 | 1152 | } |
| 1153 | - $sales['sales'][ $date_key ] += $sale_count; |
|
| 1153 | + $sales['sales'][$date_key] += $sale_count; |
|
| 1154 | 1154 | $total += $sale_count; |
| 1155 | - $d ++; |
|
| 1155 | + $d++; |
|
| 1156 | 1156 | endwhile; |
| 1157 | - $i ++; |
|
| 1157 | + $i++; |
|
| 1158 | 1158 | endwhile; |
| 1159 | 1159 | |
| 1160 | - $y ++; |
|
| 1160 | + $y++; |
|
| 1161 | 1161 | endwhile; |
| 1162 | 1162 | |
| 1163 | 1163 | $sales['totals'] = $total; |
| 1164 | 1164 | } else { |
| 1165 | - if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) { |
|
| 1165 | + if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') { |
|
| 1166 | 1166 | $sales_count = 0; |
| 1167 | 1167 | |
| 1168 | 1168 | // Loop through the months |
| 1169 | 1169 | $month = $dates['m_start']; |
| 1170 | 1170 | |
| 1171 | - while ( $month <= $dates['m_end'] ) : |
|
| 1172 | - $sales_count += give_get_sales_by_date( null, $month, $dates['year'] ); |
|
| 1173 | - $month ++; |
|
| 1171 | + while ($month <= $dates['m_end']) : |
|
| 1172 | + $sales_count += give_get_sales_by_date(null, $month, $dates['year']); |
|
| 1173 | + $month++; |
|
| 1174 | 1174 | endwhile; |
| 1175 | 1175 | |
| 1176 | - $sales['donations'][ $args['date'] ] = $sales_count; |
|
| 1176 | + $sales['donations'][$args['date']] = $sales_count; |
|
| 1177 | 1177 | } else { |
| 1178 | - $sales['donations'][ $args['date'] ] = give_get_sales_by_date( $dates['day'], $dates['m_start'], $dates['year'] ); |
|
| 1178 | + $sales['donations'][$args['date']] = give_get_sales_by_date($dates['day'], $dates['m_start'], $dates['year']); |
|
| 1179 | 1179 | } |
| 1180 | 1180 | } |
| 1181 | - } elseif ( $args['form'] == 'all' ) { |
|
| 1182 | - $forms = get_posts( array( 'post_type' => 'give_forms', 'nopaging' => true ) ); |
|
| 1181 | + } elseif ($args['form'] == 'all') { |
|
| 1182 | + $forms = get_posts(array('post_type' => 'give_forms', 'nopaging' => true)); |
|
| 1183 | 1183 | $i = 0; |
| 1184 | - foreach ( $forms as $form_info ) { |
|
| 1185 | - $sales['donations'][ $i ] = array( $form_info->post_name => give_get_form_sales_stats( $form_info->ID ) ); |
|
| 1186 | - $i ++; |
|
| 1184 | + foreach ($forms as $form_info) { |
|
| 1185 | + $sales['donations'][$i] = array($form_info->post_name => give_get_form_sales_stats($form_info->ID)); |
|
| 1186 | + $i++; |
|
| 1187 | 1187 | } |
| 1188 | 1188 | } else { |
| 1189 | - if ( get_post_type( $args['form'] ) == 'give_forms' ) { |
|
| 1190 | - $form_info = get_post( $args['form'] ); |
|
| 1191 | - $sales['donations'][0] = array( $form_info->post_name => give_get_form_sales_stats( $args['form'] ) ); |
|
| 1189 | + if (get_post_type($args['form']) == 'give_forms') { |
|
| 1190 | + $form_info = get_post($args['form']); |
|
| 1191 | + $sales['donations'][0] = array($form_info->post_name => give_get_form_sales_stats($args['form'])); |
|
| 1192 | 1192 | } else { |
| 1193 | 1193 | $error['error'] = sprintf( |
| 1194 | 1194 | /* translators: %s: form */ |
| 1195 | - esc_html__( 'Product %s not found.', 'give' ), |
|
| 1195 | + esc_html__('Product %s not found.', 'give'), |
|
| 1196 | 1196 | $args['form'] |
| 1197 | 1197 | ); |
| 1198 | 1198 | } |
| 1199 | 1199 | } |
| 1200 | 1200 | |
| 1201 | - if ( ! empty( $error ) ) { |
|
| 1201 | + if ( ! empty($error)) { |
|
| 1202 | 1202 | return $error; |
| 1203 | 1203 | } |
| 1204 | 1204 | |
| 1205 | 1205 | return $sales; |
| 1206 | 1206 | |
| 1207 | - } elseif ( $args['type'] == 'earnings' ) { |
|
| 1208 | - if ( $args['form'] == null ) { |
|
| 1209 | - if ( $args['date'] == null ) { |
|
| 1207 | + } elseif ($args['type'] == 'earnings') { |
|
| 1208 | + if ($args['form'] == null) { |
|
| 1209 | + if ($args['date'] == null) { |
|
| 1210 | 1210 | $earnings = $this->get_default_earnings_stats(); |
| 1211 | - } elseif ( $args['date'] === 'range' ) { |
|
| 1211 | + } elseif ($args['date'] === 'range') { |
|
| 1212 | 1212 | // Return sales for a date range |
| 1213 | 1213 | |
| 1214 | 1214 | // Ensure the end date is later than the start date |
| 1215 | - if ( $args['enddate'] < $args['startdate'] ) { |
|
| 1216 | - $error['error'] = esc_html__( 'The end date must be later than the start date.', 'give' ); |
|
| 1215 | + if ($args['enddate'] < $args['startdate']) { |
|
| 1216 | + $error['error'] = esc_html__('The end date must be later than the start date.', 'give'); |
|
| 1217 | 1217 | } |
| 1218 | 1218 | |
| 1219 | 1219 | // Ensure both the start and end date are specified |
| 1220 | - if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) { |
|
| 1221 | - $error['error'] = esc_html__( 'Invalid or no date range specified.', 'give' ); |
|
| 1220 | + if (empty($args['startdate']) || empty($args['enddate'])) { |
|
| 1221 | + $error['error'] = esc_html__('Invalid or no date range specified.', 'give'); |
|
| 1222 | 1222 | } |
| 1223 | 1223 | |
| 1224 | 1224 | $total = (float) 0.00; |
| 1225 | 1225 | |
| 1226 | 1226 | // Loop through the years |
| 1227 | 1227 | $y = $dates['year']; |
| 1228 | - if ( ! isset( $earnings['earnings'] ) ) { |
|
| 1228 | + if ( ! isset($earnings['earnings'])) { |
|
| 1229 | 1229 | $earnings['earnings'] = array(); |
| 1230 | 1230 | } |
| 1231 | - while ( $y <= $dates['year_end'] ) : |
|
| 1231 | + while ($y <= $dates['year_end']) : |
|
| 1232 | 1232 | |
| 1233 | - if ( $dates['year'] == $dates['year_end'] ) { |
|
| 1233 | + if ($dates['year'] == $dates['year_end']) { |
|
| 1234 | 1234 | $month_start = $dates['m_start']; |
| 1235 | 1235 | $month_end = $dates['m_end']; |
| 1236 | - } elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) { |
|
| 1236 | + } elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) { |
|
| 1237 | 1237 | $month_start = $dates['m_start']; |
| 1238 | 1238 | $month_end = 12; |
| 1239 | - } elseif ( $y == $dates['year_end'] ) { |
|
| 1239 | + } elseif ($y == $dates['year_end']) { |
|
| 1240 | 1240 | $month_start = 1; |
| 1241 | 1241 | $month_end = $dates['m_end']; |
| 1242 | 1242 | } else { |
@@ -1245,92 +1245,92 @@ discard block |
||
| 1245 | 1245 | } |
| 1246 | 1246 | |
| 1247 | 1247 | $i = $month_start; |
| 1248 | - while ( $i <= $month_end ) : |
|
| 1248 | + while ($i <= $month_end) : |
|
| 1249 | 1249 | |
| 1250 | - if ( $i == $dates['m_start'] ) { |
|
| 1250 | + if ($i == $dates['m_start']) { |
|
| 1251 | 1251 | $d = $dates['day_start']; |
| 1252 | 1252 | } else { |
| 1253 | 1253 | $d = 1; |
| 1254 | 1254 | } |
| 1255 | 1255 | |
| 1256 | - if ( $i == $dates['m_end'] ) { |
|
| 1256 | + if ($i == $dates['m_end']) { |
|
| 1257 | 1257 | $num_of_days = $dates['day_end']; |
| 1258 | 1258 | } else { |
| 1259 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
| 1259 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
| 1260 | 1260 | } |
| 1261 | 1261 | |
| 1262 | - while ( $d <= $num_of_days ) : |
|
| 1263 | - $earnings_stat = give_get_earnings_by_date( $d, $i, $y ); |
|
| 1264 | - $date_key = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) ); |
|
| 1265 | - if ( ! isset( $earnings['earnings'][ $date_key ] ) ) { |
|
| 1266 | - $earnings['earnings'][ $date_key ] = 0; |
|
| 1262 | + while ($d <= $num_of_days) : |
|
| 1263 | + $earnings_stat = give_get_earnings_by_date($d, $i, $y); |
|
| 1264 | + $date_key = date('Ymd', strtotime($y.'/'.$i.'/'.$d)); |
|
| 1265 | + if ( ! isset($earnings['earnings'][$date_key])) { |
|
| 1266 | + $earnings['earnings'][$date_key] = 0; |
|
| 1267 | 1267 | } |
| 1268 | - $earnings['earnings'][ $date_key ] += $earnings_stat; |
|
| 1268 | + $earnings['earnings'][$date_key] += $earnings_stat; |
|
| 1269 | 1269 | $total += $earnings_stat; |
| 1270 | - $d ++; |
|
| 1270 | + $d++; |
|
| 1271 | 1271 | endwhile; |
| 1272 | 1272 | |
| 1273 | - $i ++; |
|
| 1273 | + $i++; |
|
| 1274 | 1274 | endwhile; |
| 1275 | 1275 | |
| 1276 | - $y ++; |
|
| 1276 | + $y++; |
|
| 1277 | 1277 | endwhile; |
| 1278 | 1278 | |
| 1279 | 1279 | $earnings['totals'] = $total; |
| 1280 | 1280 | } else { |
| 1281 | - if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) { |
|
| 1281 | + if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') { |
|
| 1282 | 1282 | $earnings_count = (float) 0.00; |
| 1283 | 1283 | |
| 1284 | 1284 | // Loop through the months |
| 1285 | 1285 | $month = $dates['m_start']; |
| 1286 | 1286 | |
| 1287 | - while ( $month <= $dates['m_end'] ) : |
|
| 1288 | - $earnings_count += give_get_earnings_by_date( null, $month, $dates['year'] ); |
|
| 1289 | - $month ++; |
|
| 1287 | + while ($month <= $dates['m_end']) : |
|
| 1288 | + $earnings_count += give_get_earnings_by_date(null, $month, $dates['year']); |
|
| 1289 | + $month++; |
|
| 1290 | 1290 | endwhile; |
| 1291 | 1291 | |
| 1292 | - $earnings['earnings'][ $args['date'] ] = $earnings_count; |
|
| 1292 | + $earnings['earnings'][$args['date']] = $earnings_count; |
|
| 1293 | 1293 | } else { |
| 1294 | - $earnings['earnings'][ $args['date'] ] = give_get_earnings_by_date( $dates['day'], $dates['m_start'], $dates['year'] ); |
|
| 1294 | + $earnings['earnings'][$args['date']] = give_get_earnings_by_date($dates['day'], $dates['m_start'], $dates['year']); |
|
| 1295 | 1295 | } |
| 1296 | 1296 | } |
| 1297 | - } elseif ( $args['form'] == 'all' ) { |
|
| 1298 | - $forms = get_posts( array( 'post_type' => 'give_forms', 'nopaging' => true ) ); |
|
| 1297 | + } elseif ($args['form'] == 'all') { |
|
| 1298 | + $forms = get_posts(array('post_type' => 'give_forms', 'nopaging' => true)); |
|
| 1299 | 1299 | |
| 1300 | 1300 | $i = 0; |
| 1301 | - foreach ( $forms as $form_info ) { |
|
| 1302 | - $earnings['earnings'][ $i ] = array( $form_info->post_name => give_get_form_earnings_stats( $form_info->ID ) ); |
|
| 1303 | - $i ++; |
|
| 1301 | + foreach ($forms as $form_info) { |
|
| 1302 | + $earnings['earnings'][$i] = array($form_info->post_name => give_get_form_earnings_stats($form_info->ID)); |
|
| 1303 | + $i++; |
|
| 1304 | 1304 | } |
| 1305 | 1305 | } else { |
| 1306 | - if ( get_post_type( $args['form'] ) == 'give_forms' ) { |
|
| 1307 | - $form_info = get_post( $args['form'] ); |
|
| 1308 | - $earnings['earnings'][0] = array( $form_info->post_name => give_get_form_earnings_stats( $args['form'] ) ); |
|
| 1306 | + if (get_post_type($args['form']) == 'give_forms') { |
|
| 1307 | + $form_info = get_post($args['form']); |
|
| 1308 | + $earnings['earnings'][0] = array($form_info->post_name => give_get_form_earnings_stats($args['form'])); |
|
| 1309 | 1309 | } else { |
| 1310 | 1310 | $error['error'] = sprintf( |
| 1311 | 1311 | /* translators: %s: form */ |
| 1312 | - esc_html__( 'Form %s not found.', 'give' ), |
|
| 1312 | + esc_html__('Form %s not found.', 'give'), |
|
| 1313 | 1313 | $args['form'] |
| 1314 | 1314 | ); |
| 1315 | 1315 | } |
| 1316 | 1316 | } |
| 1317 | 1317 | |
| 1318 | - if ( ! empty( $error ) ) { |
|
| 1318 | + if ( ! empty($error)) { |
|
| 1319 | 1319 | return $error; |
| 1320 | 1320 | } |
| 1321 | 1321 | |
| 1322 | 1322 | return $earnings; |
| 1323 | - } elseif ( $args['type'] == 'donors' ) { |
|
| 1323 | + } elseif ($args['type'] == 'donors') { |
|
| 1324 | 1324 | $customers = new Give_DB_Customers(); |
| 1325 | 1325 | $stats['donations']['total_donors'] = $customers->count(); |
| 1326 | 1326 | |
| 1327 | 1327 | return $stats; |
| 1328 | 1328 | |
| 1329 | - } elseif ( empty( $args['type'] ) ) { |
|
| 1330 | - $stats = array_merge( $stats, $this->get_default_sales_stats() ); |
|
| 1331 | - $stats = array_merge( $stats, $this->get_default_earnings_stats() ); |
|
| 1329 | + } elseif (empty($args['type'])) { |
|
| 1330 | + $stats = array_merge($stats, $this->get_default_sales_stats()); |
|
| 1331 | + $stats = array_merge($stats, $this->get_default_earnings_stats()); |
|
| 1332 | 1332 | |
| 1333 | - return array( 'stats' => $stats ); |
|
| 1333 | + return array('stats' => $stats); |
|
| 1334 | 1334 | } |
| 1335 | 1335 | } |
| 1336 | 1336 | |
@@ -1346,18 +1346,18 @@ discard block |
||
| 1346 | 1346 | |
| 1347 | 1347 | $sales = array(); |
| 1348 | 1348 | |
| 1349 | - if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) { |
|
| 1349 | + if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) { |
|
| 1350 | 1350 | return $sales; |
| 1351 | 1351 | } |
| 1352 | 1352 | |
| 1353 | - if ( isset( $wp_query->query_vars['id'] ) ) { |
|
| 1353 | + if (isset($wp_query->query_vars['id'])) { |
|
| 1354 | 1354 | $query = array(); |
| 1355 | - $query[] = new Give_Payment( $wp_query->query_vars['id'] ); |
|
| 1356 | - } elseif ( isset( $wp_query->query_vars['purchasekey'] ) ) { |
|
| 1355 | + $query[] = new Give_Payment($wp_query->query_vars['id']); |
|
| 1356 | + } elseif (isset($wp_query->query_vars['purchasekey'])) { |
|
| 1357 | 1357 | $query = array(); |
| 1358 | - $query[] = give_get_payment_by( 'key', $wp_query->query_vars['purchasekey'] ); |
|
| 1359 | - } elseif ( isset( $wp_query->query_vars['email'] ) ) { |
|
| 1360 | - $args = array( |
|
| 1358 | + $query[] = give_get_payment_by('key', $wp_query->query_vars['purchasekey']); |
|
| 1359 | + } elseif (isset($wp_query->query_vars['email'])) { |
|
| 1360 | + $args = array( |
|
| 1361 | 1361 | 'fields' => 'ids', |
| 1362 | 1362 | 'meta_key' => '_give_payment_user_email', |
| 1363 | 1363 | 'meta_value' => $wp_query->query_vars['email'], |
@@ -1365,7 +1365,7 @@ discard block |
||
| 1365 | 1365 | 'page' => $this->get_paged(), |
| 1366 | 1366 | 'status' => 'publish' |
| 1367 | 1367 | ); |
| 1368 | - $query = give_get_payments( $args ); |
|
| 1368 | + $query = give_get_payments($args); |
|
| 1369 | 1369 | } else { |
| 1370 | 1370 | $args = array( |
| 1371 | 1371 | 'fields' => 'ids', |
@@ -1373,14 +1373,14 @@ discard block |
||
| 1373 | 1373 | 'page' => $this->get_paged(), |
| 1374 | 1374 | 'status' => 'publish' |
| 1375 | 1375 | ); |
| 1376 | - $query = give_get_payments( $args ); |
|
| 1376 | + $query = give_get_payments($args); |
|
| 1377 | 1377 | } |
| 1378 | - if ( $query ) { |
|
| 1378 | + if ($query) { |
|
| 1379 | 1379 | $i = 0; |
| 1380 | - foreach ( $query as $payment ) { |
|
| 1380 | + foreach ($query as $payment) { |
|
| 1381 | 1381 | |
| 1382 | - if ( is_numeric( $payment ) ) { |
|
| 1383 | - $payment = new Give_Payment( $payment ); |
|
| 1382 | + if (is_numeric($payment)) { |
|
| 1383 | + $payment = new Give_Payment($payment); |
|
| 1384 | 1384 | $payment_meta = $payment->get_meta(); |
| 1385 | 1385 | $user_info = $payment->user_info; |
| 1386 | 1386 | } else { |
@@ -1390,40 +1390,40 @@ discard block |
||
| 1390 | 1390 | $payment_meta = $payment->get_meta(); |
| 1391 | 1391 | $user_info = $payment->user_info; |
| 1392 | 1392 | |
| 1393 | - $first_name = isset( $user_info['first_name'] ) ? $user_info['first_name'] : ''; |
|
| 1394 | - $last_name = isset( $user_info['last_name'] ) ? $user_info['last_name'] : ''; |
|
| 1395 | - |
|
| 1396 | - $sales['donations'][ $i ]['ID'] = $payment->number; |
|
| 1397 | - $sales['donations'][ $i ]['transaction_id'] = $payment->transaction_id; |
|
| 1398 | - $sales['donations'][ $i ]['key'] = $payment->key; |
|
| 1399 | - $sales['donations'][ $i ]['total'] = $payment->total; |
|
| 1400 | - $sales['donations'][ $i ]['gateway'] = $payment->gateway; |
|
| 1401 | - $sales['donations'][ $i ]['name'] = $first_name . ' ' . $last_name; |
|
| 1402 | - $sales['donations'][ $i ]['fname'] = $first_name; |
|
| 1403 | - $sales['donations'][ $i ]['lname'] = $last_name; |
|
| 1404 | - $sales['donations'][ $i ]['email'] = $payment->email; |
|
| 1405 | - $sales['donations'][ $i ]['date'] = $payment->date; |
|
| 1406 | - |
|
| 1407 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : $payment_meta; |
|
| 1408 | - $price = isset( $payment_meta['form_id'] ) ? give_get_form_price( $payment_meta['form_id'] ) : false; |
|
| 1409 | - $price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null; |
|
| 1410 | - |
|
| 1411 | - $sales['donations'][ $i ]['form']['id'] = $form_id; |
|
| 1412 | - $sales['donations'][ $i ]['form']['name'] = get_the_title( $payment_meta['form_id'] ); |
|
| 1413 | - $sales['donations'][ $i ]['form']['price'] = $price; |
|
| 1414 | - |
|
| 1415 | - if ( give_has_variable_prices( $form_id ) ) { |
|
| 1416 | - if ( isset( $payment_meta['price_id'] ) ) { |
|
| 1417 | - $price_name = give_get_price_option_name( $form_id, $payment_meta['price_id'], $payment->ID ); |
|
| 1418 | - $sales['donations'][ $i ]['form']['price_name'] = $price_name; |
|
| 1419 | - $sales['donations'][ $i ]['form']['price_id'] = $price_id; |
|
| 1420 | - $sales['donations'][ $i ]['form']['price'] = give_get_price_option_amount( $form_id, $price_id ); |
|
| 1393 | + $first_name = isset($user_info['first_name']) ? $user_info['first_name'] : ''; |
|
| 1394 | + $last_name = isset($user_info['last_name']) ? $user_info['last_name'] : ''; |
|
| 1395 | + |
|
| 1396 | + $sales['donations'][$i]['ID'] = $payment->number; |
|
| 1397 | + $sales['donations'][$i]['transaction_id'] = $payment->transaction_id; |
|
| 1398 | + $sales['donations'][$i]['key'] = $payment->key; |
|
| 1399 | + $sales['donations'][$i]['total'] = $payment->total; |
|
| 1400 | + $sales['donations'][$i]['gateway'] = $payment->gateway; |
|
| 1401 | + $sales['donations'][$i]['name'] = $first_name.' '.$last_name; |
|
| 1402 | + $sales['donations'][$i]['fname'] = $first_name; |
|
| 1403 | + $sales['donations'][$i]['lname'] = $last_name; |
|
| 1404 | + $sales['donations'][$i]['email'] = $payment->email; |
|
| 1405 | + $sales['donations'][$i]['date'] = $payment->date; |
|
| 1406 | + |
|
| 1407 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : $payment_meta; |
|
| 1408 | + $price = isset($payment_meta['form_id']) ? give_get_form_price($payment_meta['form_id']) : false; |
|
| 1409 | + $price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null; |
|
| 1410 | + |
|
| 1411 | + $sales['donations'][$i]['form']['id'] = $form_id; |
|
| 1412 | + $sales['donations'][$i]['form']['name'] = get_the_title($payment_meta['form_id']); |
|
| 1413 | + $sales['donations'][$i]['form']['price'] = $price; |
|
| 1414 | + |
|
| 1415 | + if (give_has_variable_prices($form_id)) { |
|
| 1416 | + if (isset($payment_meta['price_id'])) { |
|
| 1417 | + $price_name = give_get_price_option_name($form_id, $payment_meta['price_id'], $payment->ID); |
|
| 1418 | + $sales['donations'][$i]['form']['price_name'] = $price_name; |
|
| 1419 | + $sales['donations'][$i]['form']['price_id'] = $price_id; |
|
| 1420 | + $sales['donations'][$i]['form']['price'] = give_get_price_option_amount($form_id, $price_id); |
|
| 1421 | 1421 | |
| 1422 | 1422 | } |
| 1423 | 1423 | } |
| 1424 | 1424 | |
| 1425 | 1425 | //Add custom meta to API |
| 1426 | - foreach ( $payment_meta as $meta_key => $meta_value ) { |
|
| 1426 | + foreach ($payment_meta as $meta_key => $meta_value) { |
|
| 1427 | 1427 | |
| 1428 | 1428 | $exceptions = array( |
| 1429 | 1429 | 'form_title', |
@@ -1436,19 +1436,19 @@ discard block |
||
| 1436 | 1436 | ); |
| 1437 | 1437 | |
| 1438 | 1438 | //Don't clutter up results with dupes |
| 1439 | - if ( in_array( $meta_key, $exceptions ) ) { |
|
| 1439 | + if (in_array($meta_key, $exceptions)) { |
|
| 1440 | 1440 | continue; |
| 1441 | 1441 | } |
| 1442 | 1442 | |
| 1443 | - $sales['donations'][ $i ]['payment_meta'][ $meta_key ] = $meta_value; |
|
| 1443 | + $sales['donations'][$i]['payment_meta'][$meta_key] = $meta_value; |
|
| 1444 | 1444 | |
| 1445 | 1445 | } |
| 1446 | 1446 | |
| 1447 | - $i ++; |
|
| 1447 | + $i++; |
|
| 1448 | 1448 | } |
| 1449 | 1449 | } |
| 1450 | 1450 | |
| 1451 | - return apply_filters( 'give_api_donations_endpoint', $sales ); |
|
| 1451 | + return apply_filters('give_api_donations_endpoint', $sales); |
|
| 1452 | 1452 | } |
| 1453 | 1453 | |
| 1454 | 1454 | /** |
@@ -1464,9 +1464,9 @@ discard block |
||
| 1464 | 1464 | public function get_output_format() { |
| 1465 | 1465 | global $wp_query; |
| 1466 | 1466 | |
| 1467 | - $format = isset( $wp_query->query_vars['format'] ) ? $wp_query->query_vars['format'] : 'json'; |
|
| 1467 | + $format = isset($wp_query->query_vars['format']) ? $wp_query->query_vars['format'] : 'json'; |
|
| 1468 | 1468 | |
| 1469 | - return apply_filters( 'give_api_output_format', $format ); |
|
| 1469 | + return apply_filters('give_api_output_format', $format); |
|
| 1470 | 1470 | } |
| 1471 | 1471 | |
| 1472 | 1472 | |
@@ -1483,8 +1483,8 @@ discard block |
||
| 1483 | 1483 | * |
| 1484 | 1484 | * @return void |
| 1485 | 1485 | */ |
| 1486 | - private function log_request( $data = array() ) { |
|
| 1487 | - if ( ! $this->log_requests ) { |
|
| 1486 | + private function log_request($data = array()) { |
|
| 1487 | + if ( ! $this->log_requests) { |
|
| 1488 | 1488 | return; |
| 1489 | 1489 | } |
| 1490 | 1490 | |
@@ -1500,36 +1500,36 @@ discard block |
||
| 1500 | 1500 | |
| 1501 | 1501 | $query = array( |
| 1502 | 1502 | 'give-api' => $wp_query->query_vars['give-api'], |
| 1503 | - 'key' => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null, |
|
| 1504 | - 'token' => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null, |
|
| 1505 | - 'query' => isset( $wp_query->query_vars['query'] ) ? $wp_query->query_vars['query'] : null, |
|
| 1506 | - 'type' => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null, |
|
| 1507 | - 'form' => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null, |
|
| 1508 | - 'customer' => isset( $wp_query->query_vars['customer'] ) ? $wp_query->query_vars['customer'] : null, |
|
| 1509 | - 'date' => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null, |
|
| 1510 | - 'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null, |
|
| 1511 | - 'enddate' => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null, |
|
| 1512 | - 'id' => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null, |
|
| 1513 | - 'purchasekey' => isset( $wp_query->query_vars['purchasekey'] ) ? $wp_query->query_vars['purchasekey'] : null, |
|
| 1514 | - 'email' => isset( $wp_query->query_vars['email'] ) ? $wp_query->query_vars['email'] : null, |
|
| 1503 | + 'key' => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null, |
|
| 1504 | + 'token' => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null, |
|
| 1505 | + 'query' => isset($wp_query->query_vars['query']) ? $wp_query->query_vars['query'] : null, |
|
| 1506 | + 'type' => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null, |
|
| 1507 | + 'form' => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null, |
|
| 1508 | + 'customer' => isset($wp_query->query_vars['customer']) ? $wp_query->query_vars['customer'] : null, |
|
| 1509 | + 'date' => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null, |
|
| 1510 | + 'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null, |
|
| 1511 | + 'enddate' => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null, |
|
| 1512 | + 'id' => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null, |
|
| 1513 | + 'purchasekey' => isset($wp_query->query_vars['purchasekey']) ? $wp_query->query_vars['purchasekey'] : null, |
|
| 1514 | + 'email' => isset($wp_query->query_vars['email']) ? $wp_query->query_vars['email'] : null, |
|
| 1515 | 1515 | ); |
| 1516 | 1516 | |
| 1517 | 1517 | $log_data = array( |
| 1518 | 1518 | 'log_type' => 'api_request', |
| 1519 | - 'post_excerpt' => http_build_query( $query ), |
|
| 1520 | - 'post_content' => ! empty( $data['error'] ) ? $data['error'] : '', |
|
| 1519 | + 'post_excerpt' => http_build_query($query), |
|
| 1520 | + 'post_content' => ! empty($data['error']) ? $data['error'] : '', |
|
| 1521 | 1521 | ); |
| 1522 | 1522 | |
| 1523 | 1523 | $log_meta = array( |
| 1524 | 1524 | 'request_ip' => give_get_ip(), |
| 1525 | 1525 | 'user' => $this->user_id, |
| 1526 | - 'key' => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null, |
|
| 1527 | - 'token' => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null, |
|
| 1526 | + 'key' => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null, |
|
| 1527 | + 'token' => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null, |
|
| 1528 | 1528 | 'time' => $data['request_speed'], |
| 1529 | 1529 | 'version' => $this->get_queried_version() |
| 1530 | 1530 | ); |
| 1531 | 1531 | |
| 1532 | - $give_logs->insert_log( $log_data, $log_meta ); |
|
| 1532 | + $give_logs->insert_log($log_data, $log_meta); |
|
| 1533 | 1533 | } |
| 1534 | 1534 | |
| 1535 | 1535 | |
@@ -1553,7 +1553,7 @@ discard block |
||
| 1553 | 1553 | * |
| 1554 | 1554 | * @param int $status_code |
| 1555 | 1555 | */ |
| 1556 | - public function output( $status_code = 200 ) { |
|
| 1556 | + public function output($status_code = 200) { |
|
| 1557 | 1557 | /** |
| 1558 | 1558 | * @var WP_Query $wp_query |
| 1559 | 1559 | */ |
@@ -1561,7 +1561,7 @@ discard block |
||
| 1561 | 1561 | |
| 1562 | 1562 | $format = $this->get_output_format(); |
| 1563 | 1563 | |
| 1564 | - status_header( $status_code ); |
|
| 1564 | + status_header($status_code); |
|
| 1565 | 1565 | |
| 1566 | 1566 | /** |
| 1567 | 1567 | * Fires before outputing the API. |
@@ -1572,25 +1572,25 @@ discard block |
||
| 1572 | 1572 | * @param Give_API $this The Give_API object. |
| 1573 | 1573 | * @param string $format Output format, XML or JSON. Default is JSON. |
| 1574 | 1574 | */ |
| 1575 | - do_action( 'give_api_output_before', $this->data, $this, $format ); |
|
| 1575 | + do_action('give_api_output_before', $this->data, $this, $format); |
|
| 1576 | 1576 | |
| 1577 | - switch ( $format ) : |
|
| 1577 | + switch ($format) : |
|
| 1578 | 1578 | |
| 1579 | 1579 | case 'xml' : |
| 1580 | 1580 | |
| 1581 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/array2xml.php'; |
|
| 1582 | - $xml = Array2XML::createXML( 'give', $this->data ); |
|
| 1581 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/array2xml.php'; |
|
| 1582 | + $xml = Array2XML::createXML('give', $this->data); |
|
| 1583 | 1583 | echo $xml->saveXML(); |
| 1584 | 1584 | |
| 1585 | 1585 | break; |
| 1586 | 1586 | |
| 1587 | 1587 | case 'json' : |
| 1588 | 1588 | |
| 1589 | - header( 'Content-Type: application/json' ); |
|
| 1590 | - if ( ! empty( $this->pretty_print ) ) { |
|
| 1591 | - echo json_encode( $this->data, $this->pretty_print ); |
|
| 1589 | + header('Content-Type: application/json'); |
|
| 1590 | + if ( ! empty($this->pretty_print)) { |
|
| 1591 | + echo json_encode($this->data, $this->pretty_print); |
|
| 1592 | 1592 | } else { |
| 1593 | - echo json_encode( $this->data ); |
|
| 1593 | + echo json_encode($this->data); |
|
| 1594 | 1594 | } |
| 1595 | 1595 | |
| 1596 | 1596 | break; |
@@ -1606,7 +1606,7 @@ discard block |
||
| 1606 | 1606 | * @param array $data Response data to return. |
| 1607 | 1607 | * @param Give_API $this The Give_API object. |
| 1608 | 1608 | */ |
| 1609 | - do_action( "give_api_output_{$format}", $this->data, $this ); |
|
| 1609 | + do_action("give_api_output_{$format}", $this->data, $this); |
|
| 1610 | 1610 | |
| 1611 | 1611 | break; |
| 1612 | 1612 | |
@@ -1621,7 +1621,7 @@ discard block |
||
| 1621 | 1621 | * @param Give_API $this The Give_API object. |
| 1622 | 1622 | * @param string $format Output format, XML or JSON. Default is JSON. |
| 1623 | 1623 | */ |
| 1624 | - do_action( 'give_api_output_after', $this->data, $this, $format ); |
|
| 1624 | + do_action('give_api_output_after', $this->data, $this, $format); |
|
| 1625 | 1625 | |
| 1626 | 1626 | give_die(); |
| 1627 | 1627 | } |
@@ -1638,37 +1638,37 @@ discard block |
||
| 1638 | 1638 | * |
| 1639 | 1639 | * @return void |
| 1640 | 1640 | */ |
| 1641 | - function user_key_field( $user ) { |
|
| 1641 | + function user_key_field($user) { |
|
| 1642 | 1642 | |
| 1643 | - if ( ( give_get_option( 'api_allow_user_keys', false ) || current_user_can( 'manage_give_settings' ) ) && current_user_can( 'edit_user', $user->ID ) ) { |
|
| 1644 | - $user = get_userdata( $user->ID ); |
|
| 1643 | + if ((give_get_option('api_allow_user_keys', false) || current_user_can('manage_give_settings')) && current_user_can('edit_user', $user->ID)) { |
|
| 1644 | + $user = get_userdata($user->ID); |
|
| 1645 | 1645 | ?> |
| 1646 | 1646 | <table class="form-table"> |
| 1647 | 1647 | <tbody> |
| 1648 | 1648 | <tr> |
| 1649 | 1649 | <th> |
| 1650 | - <?php esc_html_e( 'Give API Keys', 'give' ); ?> |
|
| 1650 | + <?php esc_html_e('Give API Keys', 'give'); ?> |
|
| 1651 | 1651 | </th> |
| 1652 | 1652 | <td> |
| 1653 | 1653 | <?php |
| 1654 | - $public_key = $this->get_user_public_key( $user->ID ); |
|
| 1655 | - $secret_key = $this->get_user_secret_key( $user->ID ); |
|
| 1654 | + $public_key = $this->get_user_public_key($user->ID); |
|
| 1655 | + $secret_key = $this->get_user_secret_key($user->ID); |
|
| 1656 | 1656 | ?> |
| 1657 | - <?php if ( empty( $user->give_user_public_key ) ) { ?> |
|
| 1657 | + <?php if (empty($user->give_user_public_key)) { ?> |
|
| 1658 | 1658 | <input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/> |
| 1659 | - <span class="description"><?php esc_html_e( 'Generate API Key', 'give' ); ?></span> |
|
| 1659 | + <span class="description"><?php esc_html_e('Generate API Key', 'give'); ?></span> |
|
| 1660 | 1660 | <?php } else { ?> |
| 1661 | - <strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Public key:', 'give' ); ?> </strong> |
|
| 1662 | - <input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr( $public_key ); ?>"/> |
|
| 1661 | + <strong style="display:inline-block; width: 125px;"><?php esc_html_e('Public key:', 'give'); ?> </strong> |
|
| 1662 | + <input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr($public_key); ?>"/> |
|
| 1663 | 1663 | <br/> |
| 1664 | - <strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Secret key:', 'give' ); ?> </strong> |
|
| 1665 | - <input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr( $secret_key ); ?>"/> |
|
| 1664 | + <strong style="display:inline-block; width: 125px;"><?php esc_html_e('Secret key:', 'give'); ?> </strong> |
|
| 1665 | + <input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr($secret_key); ?>"/> |
|
| 1666 | 1666 | <br/> |
| 1667 | - <strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Token:', 'give' ); ?> </strong> |
|
| 1668 | - <input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr( $this->get_token( $user->ID ) ); ?>"/> |
|
| 1667 | + <strong style="display:inline-block; width: 125px;"><?php esc_html_e('Token:', 'give'); ?> </strong> |
|
| 1668 | + <input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr($this->get_token($user->ID)); ?>"/> |
|
| 1669 | 1669 | <br/> |
| 1670 | 1670 | <input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/> |
| 1671 | - <span class="description"><label for="give_set_api_key"><?php esc_html_e( 'Revoke API Keys', 'give' ); ?></label></span> |
|
| 1671 | + <span class="description"><label for="give_set_api_key"><?php esc_html_e('Revoke API Keys', 'give'); ?></label></span> |
|
| 1672 | 1672 | <?php } ?> |
| 1673 | 1673 | </td> |
| 1674 | 1674 | </tr> |
@@ -1687,69 +1687,69 @@ discard block |
||
| 1687 | 1687 | * |
| 1688 | 1688 | * @return void |
| 1689 | 1689 | */ |
| 1690 | - public function process_api_key( $args ) { |
|
| 1690 | + public function process_api_key($args) { |
|
| 1691 | 1691 | |
| 1692 | - if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'give-api-nonce' ) ) { |
|
| 1692 | + if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'give-api-nonce')) { |
|
| 1693 | 1693 | |
| 1694 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 1694 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 1695 | 1695 | |
| 1696 | 1696 | } |
| 1697 | 1697 | |
| 1698 | - if ( empty( $args['user_id'] ) ) { |
|
| 1699 | - wp_die( esc_html__( 'User ID Required.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 401 ) ); |
|
| 1698 | + if (empty($args['user_id'])) { |
|
| 1699 | + wp_die(esc_html__('User ID Required.', 'give'), esc_html__('Error', 'give'), array('response' => 401)); |
|
| 1700 | 1700 | } |
| 1701 | 1701 | |
| 1702 | - if ( is_numeric( $args['user_id'] ) ) { |
|
| 1703 | - $user_id = isset( $args['user_id'] ) ? absint( $args['user_id'] ) : get_current_user_id(); |
|
| 1702 | + if (is_numeric($args['user_id'])) { |
|
| 1703 | + $user_id = isset($args['user_id']) ? absint($args['user_id']) : get_current_user_id(); |
|
| 1704 | 1704 | } else { |
| 1705 | - $userdata = get_user_by( 'login', $args['user_id'] ); |
|
| 1705 | + $userdata = get_user_by('login', $args['user_id']); |
|
| 1706 | 1706 | $user_id = $userdata->ID; |
| 1707 | 1707 | } |
| 1708 | - $process = isset( $args['give_api_process'] ) ? strtolower( $args['give_api_process'] ) : false; |
|
| 1708 | + $process = isset($args['give_api_process']) ? strtolower($args['give_api_process']) : false; |
|
| 1709 | 1709 | |
| 1710 | - if ( $user_id == get_current_user_id() && ! give_get_option( 'allow_user_api_keys' ) && ! current_user_can( 'manage_give_settings' ) ) { |
|
| 1710 | + if ($user_id == get_current_user_id() && ! give_get_option('allow_user_api_keys') && ! current_user_can('manage_give_settings')) { |
|
| 1711 | 1711 | wp_die( |
| 1712 | 1712 | sprintf( |
| 1713 | 1713 | /* translators: %s: process */ |
| 1714 | - esc_html__( 'You do not have permission to %s API keys for this user.', 'give' ), |
|
| 1714 | + esc_html__('You do not have permission to %s API keys for this user.', 'give'), |
|
| 1715 | 1715 | $process |
| 1716 | 1716 | ), |
| 1717 | - esc_html__( 'Error', 'give' ), |
|
| 1718 | - array( 'response' => 403 ) |
|
| 1717 | + esc_html__('Error', 'give'), |
|
| 1718 | + array('response' => 403) |
|
| 1719 | 1719 | ); |
| 1720 | - } elseif ( ! current_user_can( 'manage_give_settings' ) ) { |
|
| 1720 | + } elseif ( ! current_user_can('manage_give_settings')) { |
|
| 1721 | 1721 | wp_die( |
| 1722 | 1722 | sprintf( |
| 1723 | 1723 | /* translators: %s: process */ |
| 1724 | - esc_html__( 'You do not have permission to %s API keys for this user.', 'give' ), |
|
| 1724 | + esc_html__('You do not have permission to %s API keys for this user.', 'give'), |
|
| 1725 | 1725 | $process |
| 1726 | 1726 | ), |
| 1727 | - esc_html__( 'Error', 'give' ), |
|
| 1728 | - array( 'response' => 403 ) |
|
| 1727 | + esc_html__('Error', 'give'), |
|
| 1728 | + array('response' => 403) |
|
| 1729 | 1729 | ); |
| 1730 | 1730 | } |
| 1731 | 1731 | |
| 1732 | - switch ( $process ) { |
|
| 1732 | + switch ($process) { |
|
| 1733 | 1733 | case 'generate': |
| 1734 | - if ( $this->generate_api_key( $user_id ) ) { |
|
| 1735 | - delete_transient( 'give_total_api_keys' ); |
|
| 1736 | - wp_redirect( add_query_arg( 'give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) ); |
|
| 1734 | + if ($this->generate_api_key($user_id)) { |
|
| 1735 | + delete_transient('give_total_api_keys'); |
|
| 1736 | + wp_redirect(add_query_arg('give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-settings&tab=api')); |
|
| 1737 | 1737 | exit(); |
| 1738 | 1738 | } else { |
| 1739 | - wp_redirect( add_query_arg( 'give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) ); |
|
| 1739 | + wp_redirect(add_query_arg('give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-settings&tab=api')); |
|
| 1740 | 1740 | exit(); |
| 1741 | 1741 | } |
| 1742 | 1742 | break; |
| 1743 | 1743 | case 'regenerate': |
| 1744 | - $this->generate_api_key( $user_id, true ); |
|
| 1745 | - delete_transient( 'give_total_api_keys' ); |
|
| 1746 | - wp_redirect( add_query_arg( 'give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) ); |
|
| 1744 | + $this->generate_api_key($user_id, true); |
|
| 1745 | + delete_transient('give_total_api_keys'); |
|
| 1746 | + wp_redirect(add_query_arg('give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-settings&tab=api')); |
|
| 1747 | 1747 | exit(); |
| 1748 | 1748 | break; |
| 1749 | 1749 | case 'revoke': |
| 1750 | - $this->revoke_api_key( $user_id ); |
|
| 1751 | - delete_transient( 'give_total_api_keys' ); |
|
| 1752 | - wp_redirect( add_query_arg( 'give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) ); |
|
| 1750 | + $this->revoke_api_key($user_id); |
|
| 1751 | + delete_transient('give_total_api_keys'); |
|
| 1752 | + wp_redirect(add_query_arg('give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-settings&tab=api')); |
|
| 1753 | 1753 | exit(); |
| 1754 | 1754 | break; |
| 1755 | 1755 | default; |
@@ -1768,34 +1768,34 @@ discard block |
||
| 1768 | 1768 | * |
| 1769 | 1769 | * @return boolean True if (re)generated succesfully, false otherwise. |
| 1770 | 1770 | */ |
| 1771 | - public function generate_api_key( $user_id = 0, $regenerate = false ) { |
|
| 1771 | + public function generate_api_key($user_id = 0, $regenerate = false) { |
|
| 1772 | 1772 | |
| 1773 | - if ( empty( $user_id ) ) { |
|
| 1773 | + if (empty($user_id)) { |
|
| 1774 | 1774 | return false; |
| 1775 | 1775 | } |
| 1776 | 1776 | |
| 1777 | - $user = get_userdata( $user_id ); |
|
| 1777 | + $user = get_userdata($user_id); |
|
| 1778 | 1778 | |
| 1779 | - if ( ! $user ) { |
|
| 1779 | + if ( ! $user) { |
|
| 1780 | 1780 | return false; |
| 1781 | 1781 | } |
| 1782 | 1782 | |
| 1783 | - $public_key = $this->get_user_public_key( $user_id ); |
|
| 1784 | - $secret_key = $this->get_user_secret_key( $user_id ); |
|
| 1783 | + $public_key = $this->get_user_public_key($user_id); |
|
| 1784 | + $secret_key = $this->get_user_secret_key($user_id); |
|
| 1785 | 1785 | |
| 1786 | - if ( empty( $public_key ) || $regenerate == true ) { |
|
| 1787 | - $new_public_key = $this->generate_public_key( $user->user_email ); |
|
| 1788 | - $new_secret_key = $this->generate_private_key( $user->ID ); |
|
| 1786 | + if (empty($public_key) || $regenerate == true) { |
|
| 1787 | + $new_public_key = $this->generate_public_key($user->user_email); |
|
| 1788 | + $new_secret_key = $this->generate_private_key($user->ID); |
|
| 1789 | 1789 | } else { |
| 1790 | 1790 | return false; |
| 1791 | 1791 | } |
| 1792 | 1792 | |
| 1793 | - if ( $regenerate == true ) { |
|
| 1794 | - $this->revoke_api_key( $user->ID ); |
|
| 1793 | + if ($regenerate == true) { |
|
| 1794 | + $this->revoke_api_key($user->ID); |
|
| 1795 | 1795 | } |
| 1796 | 1796 | |
| 1797 | - update_user_meta( $user_id, $new_public_key, 'give_user_public_key' ); |
|
| 1798 | - update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' ); |
|
| 1797 | + update_user_meta($user_id, $new_public_key, 'give_user_public_key'); |
|
| 1798 | + update_user_meta($user_id, $new_secret_key, 'give_user_secret_key'); |
|
| 1799 | 1799 | |
| 1800 | 1800 | return true; |
| 1801 | 1801 | } |
@@ -1810,26 +1810,26 @@ discard block |
||
| 1810 | 1810 | * |
| 1811 | 1811 | * @return string |
| 1812 | 1812 | */ |
| 1813 | - public function revoke_api_key( $user_id = 0 ) { |
|
| 1813 | + public function revoke_api_key($user_id = 0) { |
|
| 1814 | 1814 | |
| 1815 | - if ( empty( $user_id ) ) { |
|
| 1815 | + if (empty($user_id)) { |
|
| 1816 | 1816 | return false; |
| 1817 | 1817 | } |
| 1818 | 1818 | |
| 1819 | - $user = get_userdata( $user_id ); |
|
| 1819 | + $user = get_userdata($user_id); |
|
| 1820 | 1820 | |
| 1821 | - if ( ! $user ) { |
|
| 1821 | + if ( ! $user) { |
|
| 1822 | 1822 | return false; |
| 1823 | 1823 | } |
| 1824 | 1824 | |
| 1825 | - $public_key = $this->get_user_public_key( $user_id ); |
|
| 1826 | - $secret_key = $this->get_user_secret_key( $user_id ); |
|
| 1827 | - if ( ! empty( $public_key ) ) { |
|
| 1828 | - delete_transient( md5( 'give_api_user_' . $public_key ) ); |
|
| 1829 | - delete_transient( md5( 'give_api_user_public_key' . $user_id ) ); |
|
| 1830 | - delete_transient( md5( 'give_api_user_secret_key' . $user_id ) ); |
|
| 1831 | - delete_user_meta( $user_id, $public_key ); |
|
| 1832 | - delete_user_meta( $user_id, $secret_key ); |
|
| 1825 | + $public_key = $this->get_user_public_key($user_id); |
|
| 1826 | + $secret_key = $this->get_user_secret_key($user_id); |
|
| 1827 | + if ( ! empty($public_key)) { |
|
| 1828 | + delete_transient(md5('give_api_user_'.$public_key)); |
|
| 1829 | + delete_transient(md5('give_api_user_public_key'.$user_id)); |
|
| 1830 | + delete_transient(md5('give_api_user_secret_key'.$user_id)); |
|
| 1831 | + delete_user_meta($user_id, $public_key); |
|
| 1832 | + delete_user_meta($user_id, $secret_key); |
|
| 1833 | 1833 | } else { |
| 1834 | 1834 | return false; |
| 1835 | 1835 | } |
@@ -1854,22 +1854,22 @@ discard block |
||
| 1854 | 1854 | * |
| 1855 | 1855 | * @return void |
| 1856 | 1856 | */ |
| 1857 | - public function update_key( $user_id ) { |
|
| 1858 | - if ( current_user_can( 'edit_user', $user_id ) && isset( $_POST['give_set_api_key'] ) ) { |
|
| 1857 | + public function update_key($user_id) { |
|
| 1858 | + if (current_user_can('edit_user', $user_id) && isset($_POST['give_set_api_key'])) { |
|
| 1859 | 1859 | |
| 1860 | - $user = get_userdata( $user_id ); |
|
| 1860 | + $user = get_userdata($user_id); |
|
| 1861 | 1861 | |
| 1862 | - $public_key = $this->get_user_public_key( $user_id ); |
|
| 1863 | - $secret_key = $this->get_user_secret_key( $user_id ); |
|
| 1862 | + $public_key = $this->get_user_public_key($user_id); |
|
| 1863 | + $secret_key = $this->get_user_secret_key($user_id); |
|
| 1864 | 1864 | |
| 1865 | - if ( empty( $public_key ) ) { |
|
| 1866 | - $new_public_key = $this->generate_public_key( $user->user_email ); |
|
| 1867 | - $new_secret_key = $this->generate_private_key( $user->ID ); |
|
| 1865 | + if (empty($public_key)) { |
|
| 1866 | + $new_public_key = $this->generate_public_key($user->user_email); |
|
| 1867 | + $new_secret_key = $this->generate_private_key($user->ID); |
|
| 1868 | 1868 | |
| 1869 | - update_user_meta( $user_id, $new_public_key, 'give_user_public_key' ); |
|
| 1870 | - update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' ); |
|
| 1869 | + update_user_meta($user_id, $new_public_key, 'give_user_public_key'); |
|
| 1870 | + update_user_meta($user_id, $new_secret_key, 'give_user_secret_key'); |
|
| 1871 | 1871 | } else { |
| 1872 | - $this->revoke_api_key( $user_id ); |
|
| 1872 | + $this->revoke_api_key($user_id); |
|
| 1873 | 1873 | } |
| 1874 | 1874 | } |
| 1875 | 1875 | } |
@@ -1884,9 +1884,9 @@ discard block |
||
| 1884 | 1884 | * |
| 1885 | 1885 | * @return string |
| 1886 | 1886 | */ |
| 1887 | - private function generate_public_key( $user_email = '' ) { |
|
| 1888 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 1889 | - $public = hash( 'md5', $user_email . $auth_key . date( 'U' ) ); |
|
| 1887 | + private function generate_public_key($user_email = '') { |
|
| 1888 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
| 1889 | + $public = hash('md5', $user_email.$auth_key.date('U')); |
|
| 1890 | 1890 | |
| 1891 | 1891 | return $public; |
| 1892 | 1892 | } |
@@ -1901,9 +1901,9 @@ discard block |
||
| 1901 | 1901 | * |
| 1902 | 1902 | * @return string |
| 1903 | 1903 | */ |
| 1904 | - private function generate_private_key( $user_id = 0 ) { |
|
| 1905 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 1906 | - $secret = hash( 'md5', $user_id . $auth_key . date( 'U' ) ); |
|
| 1904 | + private function generate_private_key($user_id = 0) { |
|
| 1905 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
| 1906 | + $secret = hash('md5', $user_id.$auth_key.date('U')); |
|
| 1907 | 1907 | |
| 1908 | 1908 | return $secret; |
| 1909 | 1909 | } |
@@ -1918,8 +1918,8 @@ discard block |
||
| 1918 | 1918 | * |
| 1919 | 1919 | * @return string |
| 1920 | 1920 | */ |
| 1921 | - public function get_token( $user_id = 0 ) { |
|
| 1922 | - return hash( 'md5', $this->get_user_secret_key( $user_id ) . $this->get_user_public_key( $user_id ) ); |
|
| 1921 | + public function get_token($user_id = 0) { |
|
| 1922 | + return hash('md5', $this->get_user_secret_key($user_id).$this->get_user_public_key($user_id)); |
|
| 1923 | 1923 | } |
| 1924 | 1924 | |
| 1925 | 1925 | /** |
@@ -1933,9 +1933,9 @@ discard block |
||
| 1933 | 1933 | |
| 1934 | 1934 | // Default sales return |
| 1935 | 1935 | $sales = array(); |
| 1936 | - $sales['donations']['today'] = $this->stats->get_sales( 0, 'today' ); |
|
| 1937 | - $sales['donations']['current_month'] = $this->stats->get_sales( 0, 'this_month' ); |
|
| 1938 | - $sales['donations']['last_month'] = $this->stats->get_sales( 0, 'last_month' ); |
|
| 1936 | + $sales['donations']['today'] = $this->stats->get_sales(0, 'today'); |
|
| 1937 | + $sales['donations']['current_month'] = $this->stats->get_sales(0, 'this_month'); |
|
| 1938 | + $sales['donations']['last_month'] = $this->stats->get_sales(0, 'last_month'); |
|
| 1939 | 1939 | $sales['donations']['totals'] = give_get_total_sales(); |
| 1940 | 1940 | |
| 1941 | 1941 | return $sales; |
@@ -1952,9 +1952,9 @@ discard block |
||
| 1952 | 1952 | |
| 1953 | 1953 | // Default earnings return |
| 1954 | 1954 | $earnings = array(); |
| 1955 | - $earnings['earnings']['today'] = $this->stats->get_earnings( 0, 'today' ); |
|
| 1956 | - $earnings['earnings']['current_month'] = $this->stats->get_earnings( 0, 'this_month' ); |
|
| 1957 | - $earnings['earnings']['last_month'] = $this->stats->get_earnings( 0, 'last_month' ); |
|
| 1955 | + $earnings['earnings']['today'] = $this->stats->get_earnings(0, 'today'); |
|
| 1956 | + $earnings['earnings']['current_month'] = $this->stats->get_earnings(0, 'this_month'); |
|
| 1957 | + $earnings['earnings']['last_month'] = $this->stats->get_earnings(0, 'last_month'); |
|
| 1958 | 1958 | $earnings['earnings']['totals'] = give_get_total_earnings(); |
| 1959 | 1959 | |
| 1960 | 1960 | return $earnings; |
@@ -1974,25 +1974,25 @@ discard block |
||
| 1974 | 1974 | * |
| 1975 | 1975 | * @return string The API key/secret for the user supplied |
| 1976 | 1976 | */ |
| 1977 | - public function api_key_backwards_compat( $check, $object_id, $meta_key, $single ) { |
|
| 1977 | + public function api_key_backwards_compat($check, $object_id, $meta_key, $single) { |
|
| 1978 | 1978 | |
| 1979 | - if ( $meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key' ) { |
|
| 1979 | + if ($meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key') { |
|
| 1980 | 1980 | return $check; |
| 1981 | 1981 | } |
| 1982 | 1982 | |
| 1983 | 1983 | $return = $check; |
| 1984 | 1984 | |
| 1985 | - switch ( $meta_key ) { |
|
| 1985 | + switch ($meta_key) { |
|
| 1986 | 1986 | case 'give_user_public_key': |
| 1987 | - $return = Give()->api->get_user_public_key( $object_id ); |
|
| 1987 | + $return = Give()->api->get_user_public_key($object_id); |
|
| 1988 | 1988 | break; |
| 1989 | 1989 | case 'give_user_secret_key': |
| 1990 | - $return = Give()->api->get_user_secret_key( $object_id ); |
|
| 1990 | + $return = Give()->api->get_user_secret_key($object_id); |
|
| 1991 | 1991 | break; |
| 1992 | 1992 | } |
| 1993 | 1993 | |
| 1994 | - if ( ! $single ) { |
|
| 1995 | - $return = array( $return ); |
|
| 1994 | + if ( ! $single) { |
|
| 1995 | + $return = array($return); |
|
| 1996 | 1996 | } |
| 1997 | 1997 | |
| 1998 | 1998 | return $return; |