@@ -33,20 +33,20 @@ discard block |
||
| 33 | 33 | $login_redirect = add_query_arg('give-login-success', 'true', give_get_current_page_url()); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - if ( empty( $logout_redirect ) ) { |
|
| 37 | - $logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() ); |
|
| 38 | - } |
|
| 36 | + if ( empty( $logout_redirect ) ) { |
|
| 37 | + $logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() ); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | 40 | |
| 41 | - // Add user_logout action to logout url. |
|
| 42 | - $logout_redirect = add_query_arg( |
|
| 43 | - array( |
|
| 44 | - 'give_action' => 'user_logout', |
|
| 45 | - 'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ), |
|
| 46 | - 'give_logout_redirect' => urlencode( $logout_redirect ) |
|
| 47 | - ), |
|
| 48 | - home_url('/') |
|
| 49 | - ); |
|
| 41 | + // Add user_logout action to logout url. |
|
| 42 | + $logout_redirect = add_query_arg( |
|
| 43 | + array( |
|
| 44 | + 'give_action' => 'user_logout', |
|
| 45 | + 'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ), |
|
| 46 | + 'give_logout_redirect' => urlencode( $logout_redirect ) |
|
| 47 | + ), |
|
| 48 | + home_url('/') |
|
| 49 | + ); |
|
| 50 | 50 | |
| 51 | 51 | $give_login_redirect = $login_redirect; |
| 52 | 52 | $give_logout_redirect = $logout_redirect; |
@@ -136,23 +136,23 @@ discard block |
||
| 136 | 136 | * @return void |
| 137 | 137 | */ |
| 138 | 138 | function give_process_user_logout( $data ) { |
| 139 | - if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) { |
|
| 139 | + if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) { |
|
| 140 | 140 | |
| 141 | - // Prevent occurring of any custom action on wp_logout. |
|
| 142 | - remove_all_actions( 'wp_logout' ); |
|
| 141 | + // Prevent occurring of any custom action on wp_logout. |
|
| 142 | + remove_all_actions( 'wp_logout' ); |
|
| 143 | 143 | |
| 144 | - // Before logout give action. |
|
| 145 | - do_action( 'give_before_user_logout' ); |
|
| 144 | + // Before logout give action. |
|
| 145 | + do_action( 'give_before_user_logout' ); |
|
| 146 | 146 | |
| 147 | - // Logout user. |
|
| 148 | - wp_logout(); |
|
| 147 | + // Logout user. |
|
| 148 | + wp_logout(); |
|
| 149 | 149 | |
| 150 | - // After logout give action. |
|
| 151 | - do_action( 'give_after_user_logout' ); |
|
| 150 | + // After logout give action. |
|
| 151 | + do_action( 'give_after_user_logout' ); |
|
| 152 | 152 | |
| 153 | - wp_redirect( $data['give_logout_redirect'] ); |
|
| 154 | - give_die(); |
|
| 155 | - } |
|
| 153 | + wp_redirect( $data['give_logout_redirect'] ); |
|
| 154 | + give_die(); |
|
| 155 | + } |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | add_action( 'give_user_logout', 'give_process_user_logout' ); |
@@ -1437,7 +1437,7 @@ discard block |
||
| 1437 | 1437 | * Determines whether results should be displayed in XML or JSON |
| 1438 | 1438 | * |
| 1439 | 1439 | * @since 1.1 |
| 1440 | - * @access public |
|
| 1440 | + * @access public |
|
| 1441 | 1441 | * |
| 1442 | 1442 | * @return mixed|void |
| 1443 | 1443 | */ |
@@ -1455,7 +1455,7 @@ discard block |
||
| 1455 | 1455 | * |
| 1456 | 1456 | * @access private |
| 1457 | 1457 | * @since 1.1 |
| 1458 | - * |
|
| 1458 | + * |
|
| 1459 | 1459 | * @global Give_Logging $give_logs |
| 1460 | 1460 | * @global WP_Query $wp_query |
| 1461 | 1461 | * |
@@ -1468,15 +1468,15 @@ discard block |
||
| 1468 | 1468 | return; |
| 1469 | 1469 | } |
| 1470 | 1470 | |
| 1471 | - /** |
|
| 1472 | - * @var Give_Logging $give_logs |
|
| 1473 | - */ |
|
| 1471 | + /** |
|
| 1472 | + * @var Give_Logging $give_logs |
|
| 1473 | + */ |
|
| 1474 | 1474 | global $give_logs; |
| 1475 | 1475 | |
| 1476 | - /** |
|
| 1477 | - * @var WP_Query $wp_query |
|
| 1478 | - */ |
|
| 1479 | - global $wp_query; |
|
| 1476 | + /** |
|
| 1477 | + * @var WP_Query $wp_query |
|
| 1478 | + */ |
|
| 1479 | + global $wp_query; |
|
| 1480 | 1480 | |
| 1481 | 1481 | $query = array( |
| 1482 | 1482 | 'give-api' => $wp_query->query_vars['give-api'], |
@@ -1534,9 +1534,9 @@ discard block |
||
| 1534 | 1534 | * @param int $status_code |
| 1535 | 1535 | */ |
| 1536 | 1536 | public function output( $status_code = 200 ) { |
| 1537 | - /** |
|
| 1538 | - * @var WP_Query $wp_query |
|
| 1539 | - */ |
|
| 1537 | + /** |
|
| 1538 | + * @var WP_Query $wp_query |
|
| 1539 | + */ |
|
| 1540 | 1540 | global $wp_query; |
| 1541 | 1541 | |
| 1542 | 1542 | $format = $this->get_output_format(); |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | //validate display_style and float_labels value |
| 93 | 93 | if ( ( $key == 'display_style' && ! in_array( $value, array( 'onpage', 'reveal', 'modal' ) ) ) |
| 94 | - || ( $key == 'float_labels' && ! in_array( $value, array( 'enabled', 'disabled' ) ) ) |
|
| 94 | + || ( $key == 'float_labels' && ! in_array( $value, array( 'enabled', 'disabled' ) ) ) |
|
| 95 | 95 | ) { |
| 96 | 96 | |
| 97 | 97 | $atts[ $key ] = ''; |
@@ -169,15 +169,15 @@ discard block |
||
| 169 | 169 | */ |
| 170 | 170 | function give_login_form_shortcode( $atts, $content = null ) { |
| 171 | 171 | $atts = shortcode_atts( array( |
| 172 | - // Add backward compatibility for redirect attribute. |
|
| 173 | - 'redirect' => '', |
|
| 172 | + // Add backward compatibility for redirect attribute. |
|
| 173 | + 'redirect' => '', |
|
| 174 | 174 | |
| 175 | 175 | 'login-redirect' => '', |
| 176 | 176 | 'logout-redirect' => '', |
| 177 | 177 | ), $atts, 'give_login' ); |
| 178 | 178 | |
| 179 | - // Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute. |
|
| 180 | - $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect' ] ) ? $atts['redirect'] : '' ); |
|
| 179 | + // Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute. |
|
| 180 | + $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect' ] ) ? $atts['redirect'] : '' ); |
|
| 181 | 181 | |
| 182 | 182 | return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] ); |
| 183 | 183 | } |
@@ -95,17 +95,17 @@ discard block |
||
| 95 | 95 | * Retrieve a row by a specific column / value |
| 96 | 96 | * |
| 97 | 97 | * @access public |
| 98 | - * |
|
| 98 | + * |
|
| 99 | 99 | * @since 1.0 |
| 100 | 100 | * |
| 101 | - * @param int $column Column ID |
|
| 102 | - * @param int $row_id Row ID |
|
| 103 | - * |
|
| 104 | - * @return object |
|
| 101 | + * @param int $column Column ID |
|
| 102 | + * @param int $row_id Row ID |
|
| 103 | + * |
|
| 104 | + * @return object |
|
| 105 | 105 | */ |
| 106 | 106 | public function get_by( $column, $row_id ) { |
| 107 | - /* @var WPDB $wpdb */ |
|
| 108 | - global $wpdb; |
|
| 107 | + /* @var WPDB $wpdb */ |
|
| 108 | + global $wpdb; |
|
| 109 | 109 | |
| 110 | 110 | $column = esc_sql( $column ); |
| 111 | 111 | return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) ); |
@@ -115,17 +115,17 @@ discard block |
||
| 115 | 115 | * Retrieve a specific column's value by the primary key |
| 116 | 116 | * |
| 117 | 117 | * @access public |
| 118 | - * |
|
| 118 | + * |
|
| 119 | 119 | * @since 1.0 |
| 120 | - * |
|
| 121 | - * @param int $column Column ID |
|
| 122 | - * @param int $row_id Row ID |
|
| 123 | - * |
|
| 120 | + * |
|
| 121 | + * @param int $column Column ID |
|
| 122 | + * @param int $row_id Row ID |
|
| 123 | + * |
|
| 124 | 124 | * @return string |
| 125 | 125 | */ |
| 126 | 126 | public function get_column( $column, $row_id ) { |
| 127 | - /* @var WPDB $wpdb */ |
|
| 128 | - global $wpdb; |
|
| 127 | + /* @var WPDB $wpdb */ |
|
| 128 | + global $wpdb; |
|
| 129 | 129 | |
| 130 | 130 | $column = esc_sql( $column ); |
| 131 | 131 | return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
@@ -135,18 +135,18 @@ discard block |
||
| 135 | 135 | * Retrieve a specific column's value by the the specified column / value |
| 136 | 136 | * |
| 137 | 137 | * @access public |
| 138 | - * |
|
| 138 | + * |
|
| 139 | 139 | * @since 1.0 |
| 140 | - * |
|
| 141 | - * @param int $column Column ID |
|
| 142 | - * @param string $column_where Column name |
|
| 143 | - * @param string $column_value Column value |
|
| 144 | - * |
|
| 140 | + * |
|
| 141 | + * @param int $column Column ID |
|
| 142 | + * @param string $column_where Column name |
|
| 143 | + * @param string $column_value Column value |
|
| 144 | + * |
|
| 145 | 145 | * @return string |
| 146 | 146 | */ |
| 147 | 147 | public function get_column_by( $column, $column_where, $column_value ) { |
| 148 | - /* @var WPDB $wpdb */ |
|
| 149 | - global $wpdb; |
|
| 148 | + /* @var WPDB $wpdb */ |
|
| 149 | + global $wpdb; |
|
| 150 | 150 | |
| 151 | 151 | $column_where = esc_sql( $column_where ); |
| 152 | 152 | $column = esc_sql( $column ); |
@@ -157,17 +157,17 @@ discard block |
||
| 157 | 157 | * Insert a new row |
| 158 | 158 | * |
| 159 | 159 | * @access public |
| 160 | - * |
|
| 160 | + * |
|
| 161 | 161 | * @since 1.0 |
| 162 | - * |
|
| 163 | - * @param array $data |
|
| 164 | - * @param string $type |
|
| 165 | - * |
|
| 162 | + * |
|
| 163 | + * @param array $data |
|
| 164 | + * @param string $type |
|
| 165 | + * |
|
| 166 | 166 | * @return int |
| 167 | 167 | */ |
| 168 | 168 | public function insert( $data, $type = '' ) { |
| 169 | - /* @var WPDB $wpdb */ |
|
| 170 | - global $wpdb; |
|
| 169 | + /* @var WPDB $wpdb */ |
|
| 170 | + global $wpdb; |
|
| 171 | 171 | |
| 172 | 172 | // Set default values |
| 173 | 173 | $data = wp_parse_args( $data, $this->get_column_defaults() ); |
@@ -198,18 +198,18 @@ discard block |
||
| 198 | 198 | * Update a row |
| 199 | 199 | * |
| 200 | 200 | * @access public |
| 201 | - * |
|
| 201 | + * |
|
| 202 | 202 | * @since 1.0 |
| 203 | - * |
|
| 204 | - * @param int $row_id Column ID |
|
| 205 | - * @param array $data |
|
| 206 | - * @param string $where Column value |
|
| 207 | - * |
|
| 203 | + * |
|
| 204 | + * @param int $row_id Column ID |
|
| 205 | + * @param array $data |
|
| 206 | + * @param string $where Column value |
|
| 207 | + * |
|
| 208 | 208 | * @return bool |
| 209 | 209 | */ |
| 210 | 210 | public function update( $row_id, $data = array(), $where = '' ) { |
| 211 | - /* @var WPDB $wpdb */ |
|
| 212 | - global $wpdb; |
|
| 211 | + /* @var WPDB $wpdb */ |
|
| 212 | + global $wpdb; |
|
| 213 | 213 | |
| 214 | 214 | // Row ID must be positive integer |
| 215 | 215 | $row_id = absint( $row_id ); |
@@ -246,16 +246,16 @@ discard block |
||
| 246 | 246 | * Delete a row identified by the primary key |
| 247 | 247 | * |
| 248 | 248 | * @access public |
| 249 | - * |
|
| 249 | + * |
|
| 250 | 250 | * @since 1.0 |
| 251 | - * |
|
| 252 | - * @param int $row_id Column ID |
|
| 253 | - * |
|
| 251 | + * |
|
| 252 | + * @param int $row_id Column ID |
|
| 253 | + * |
|
| 254 | 254 | * @return bool |
| 255 | 255 | */ |
| 256 | 256 | public function delete( $row_id = 0 ) { |
| 257 | - /* @var WPDB $wpdb */ |
|
| 258 | - global $wpdb; |
|
| 257 | + /* @var WPDB $wpdb */ |
|
| 258 | + global $wpdb; |
|
| 259 | 259 | |
| 260 | 260 | // Row ID must be positive integer |
| 261 | 261 | $row_id = absint( $row_id ); |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | * @return bool If the table name exists |
| 280 | 280 | */ |
| 281 | 281 | public function table_exists( $table ) { |
| 282 | - /* @var WPDB $wpdb */ |
|
| 282 | + /* @var WPDB $wpdb */ |
|
| 283 | 283 | global $wpdb; |
| 284 | 284 | |
| 285 | 285 | $table = sanitize_text_field( $table ); |
@@ -457,22 +457,22 @@ discard block |
||
| 457 | 457 | return true; |
| 458 | 458 | } |
| 459 | 459 | |
| 460 | - /** |
|
| 461 | - * Payment class object is storing various meta value in object parameter. |
|
| 462 | - * So if user is updating payment meta but not updating payment object, then payment meta values will not reflect/changes on payment meta automatically |
|
| 463 | - * and you can still access payment meta old value in any old payment object ( previously created ) which can cause to show or save wrong payment data. |
|
| 464 | - * To prevent that user can use this function after updating any payment meta value ( in bulk or single update ). |
|
| 465 | - * |
|
| 466 | - * @since 1.6 |
|
| 467 | - * @access public |
|
| 468 | - * |
|
| 469 | - * @param int $payment_id Payment ID. |
|
| 470 | - * |
|
| 471 | - * @return void |
|
| 472 | - */ |
|
| 473 | - public function update_payment_setup( $payment_id ){ |
|
| 474 | - $this->setup_payment( $payment_id ); |
|
| 475 | - } |
|
| 460 | + /** |
|
| 461 | + * Payment class object is storing various meta value in object parameter. |
|
| 462 | + * So if user is updating payment meta but not updating payment object, then payment meta values will not reflect/changes on payment meta automatically |
|
| 463 | + * and you can still access payment meta old value in any old payment object ( previously created ) which can cause to show or save wrong payment data. |
|
| 464 | + * To prevent that user can use this function after updating any payment meta value ( in bulk or single update ). |
|
| 465 | + * |
|
| 466 | + * @since 1.6 |
|
| 467 | + * @access public |
|
| 468 | + * |
|
| 469 | + * @param int $payment_id Payment ID. |
|
| 470 | + * |
|
| 471 | + * @return void |
|
| 472 | + */ |
|
| 473 | + public function update_payment_setup( $payment_id ){ |
|
| 474 | + $this->setup_payment( $payment_id ); |
|
| 475 | + } |
|
| 476 | 476 | |
| 477 | 477 | /** |
| 478 | 478 | * Create the base of a payment. |
@@ -916,7 +916,7 @@ discard block |
||
| 916 | 916 | //Find a match between price_id and level_id |
| 917 | 917 | //First verify array keys exists THEN make the match |
| 918 | 918 | if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) ) |
| 919 | - && $args['price_id'] == $price['_give_id']['level_id'] |
|
| 919 | + && $args['price_id'] == $price['_give_id']['level_id'] |
|
| 920 | 920 | ) { |
| 921 | 921 | $item_price = $price['_give_amount']; |
| 922 | 922 | } |
@@ -1312,9 +1312,9 @@ discard block |
||
| 1312 | 1312 | case 'pending': |
| 1313 | 1313 | $this->process_pending(); |
| 1314 | 1314 | break; |
| 1315 | - case 'cancelled': |
|
| 1316 | - $this->process_cancelled(); |
|
| 1317 | - break; |
|
| 1315 | + case 'cancelled': |
|
| 1316 | + $this->process_cancelled(); |
|
| 1317 | + break; |
|
| 1318 | 1318 | } |
| 1319 | 1319 | |
| 1320 | 1320 | do_action( 'give_update_payment_status', $this->ID, $status, $old_status ); |
@@ -1502,40 +1502,40 @@ discard block |
||
| 1502 | 1502 | delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
| 1503 | 1503 | } |
| 1504 | 1504 | |
| 1505 | - /** |
|
| 1506 | - * Process when a payment moves to cancelled |
|
| 1507 | - * |
|
| 1508 | - * @since 1.5 |
|
| 1509 | - * @return void |
|
| 1510 | - */ |
|
| 1511 | - private function process_cancelled() { |
|
| 1512 | - $process_cancelled = true; |
|
| 1505 | + /** |
|
| 1506 | + * Process when a payment moves to cancelled |
|
| 1507 | + * |
|
| 1508 | + * @since 1.5 |
|
| 1509 | + * @return void |
|
| 1510 | + */ |
|
| 1511 | + private function process_cancelled() { |
|
| 1512 | + $process_cancelled = true; |
|
| 1513 | 1513 | |
| 1514 | - // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented |
|
| 1515 | - if ( ( 'publish' != $this->old_status && 'revoked' != $this->old_status ) || 'cancelled' != $this->status ) { |
|
| 1516 | - $process_cancelled = false; |
|
| 1517 | - } |
|
| 1514 | + // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented |
|
| 1515 | + if ( ( 'publish' != $this->old_status && 'revoked' != $this->old_status ) || 'cancelled' != $this->status ) { |
|
| 1516 | + $process_cancelled = false; |
|
| 1517 | + } |
|
| 1518 | 1518 | |
| 1519 | - // Allow extensions to filter for their own payment types, Example: Recurring Payments |
|
| 1520 | - $process_cancelled = apply_filters( 'give_should_process_cancelled', $process_cancelled, $this ); |
|
| 1519 | + // Allow extensions to filter for their own payment types, Example: Recurring Payments |
|
| 1520 | + $process_cancelled = apply_filters( 'give_should_process_cancelled', $process_cancelled, $this ); |
|
| 1521 | 1521 | |
| 1522 | - if ( false === $process_cancelled ) { |
|
| 1523 | - return; |
|
| 1524 | - } |
|
| 1522 | + if ( false === $process_cancelled ) { |
|
| 1523 | + return; |
|
| 1524 | + } |
|
| 1525 | 1525 | |
| 1526 | - $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_cancelled', true, $this ); |
|
| 1527 | - $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_cancelled', true, $this ); |
|
| 1528 | - $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_cancelled', true, $this ); |
|
| 1526 | + $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_cancelled', true, $this ); |
|
| 1527 | + $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_cancelled', true, $this ); |
|
| 1528 | + $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_cancelled', true, $this ); |
|
| 1529 | 1529 | |
| 1530 | - $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
| 1531 | - $this->delete_sales_logs(); |
|
| 1530 | + $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
| 1531 | + $this->delete_sales_logs(); |
|
| 1532 | 1532 | |
| 1533 | - $this->completed_date = false; |
|
| 1534 | - $this->update_meta( '_give_completed_date', '' ); |
|
| 1533 | + $this->completed_date = false; |
|
| 1534 | + $this->update_meta( '_give_completed_date', '' ); |
|
| 1535 | 1535 | |
| 1536 | - // Clear the This Month earnings (this_monththis_month is NOT a typo) |
|
| 1537 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
| 1538 | - } |
|
| 1536 | + // Clear the This Month earnings (this_monththis_month is NOT a typo) |
|
| 1537 | + delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
| 1538 | + } |
|
| 1539 | 1539 | |
| 1540 | 1540 | /** |
| 1541 | 1541 | * Used during the process of moving to refunded or pending, to decrement stats |
@@ -1788,13 +1788,13 @@ discard block |
||
| 1788 | 1788 | * @return string/void |
| 1789 | 1789 | */ |
| 1790 | 1790 | function give_get_form_dropdown( $args = array(), $echo = false ){ |
| 1791 | - $form_dropdown_html = Give()->html->forms_dropdown( $args ); |
|
| 1791 | + $form_dropdown_html = Give()->html->forms_dropdown( $args ); |
|
| 1792 | 1792 | |
| 1793 | - if( ! $echo ) { |
|
| 1794 | - return $form_dropdown_html; |
|
| 1795 | - } |
|
| 1793 | + if( ! $echo ) { |
|
| 1794 | + return $form_dropdown_html; |
|
| 1795 | + } |
|
| 1796 | 1796 | |
| 1797 | - echo $form_dropdown_html; |
|
| 1797 | + echo $form_dropdown_html; |
|
| 1798 | 1798 | } |
| 1799 | 1799 | |
| 1800 | 1800 | /** |
@@ -1809,39 +1809,39 @@ discard block |
||
| 1809 | 1809 | */ |
| 1810 | 1810 | function give_get_form_variable_price_dropdown( $args = array(), $echo = false ){ |
| 1811 | 1811 | |
| 1812 | - // Check for give form id. |
|
| 1813 | - if( empty( $args['id'] ) ) { |
|
| 1814 | - return false; |
|
| 1815 | - } |
|
| 1816 | - |
|
| 1817 | - // Check if form has variable prices or not. |
|
| 1818 | - if( ! ( $variable_prices = give_has_variable_prices( $args['id'] ) ) ) { |
|
| 1819 | - return false; |
|
| 1820 | - } |
|
| 1812 | + // Check for give form id. |
|
| 1813 | + if( empty( $args['id'] ) ) { |
|
| 1814 | + return false; |
|
| 1815 | + } |
|
| 1816 | + |
|
| 1817 | + // Check if form has variable prices or not. |
|
| 1818 | + if( ! ( $variable_prices = give_has_variable_prices( $args['id'] ) ) ) { |
|
| 1819 | + return false; |
|
| 1820 | + } |
|
| 1821 | 1821 | |
| 1822 | - $variable_prices = give_get_variable_prices( absint( $args['id'] ) ); |
|
| 1823 | - $variable_price_options = array(); |
|
| 1822 | + $variable_prices = give_get_variable_prices( absint( $args['id'] ) ); |
|
| 1823 | + $variable_price_options = array(); |
|
| 1824 | 1824 | |
| 1825 | - // Check if multi donation form support custom donation or not. |
|
| 1826 | - if( give_is_custom_price_mode( absint( $args['id'] ) ) ) { |
|
| 1827 | - $variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' ); |
|
| 1828 | - } |
|
| 1825 | + // Check if multi donation form support custom donation or not. |
|
| 1826 | + if( give_is_custom_price_mode( absint( $args['id'] ) ) ) { |
|
| 1827 | + $variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' ); |
|
| 1828 | + } |
|
| 1829 | 1829 | |
| 1830 | - // Get variable price and ID from variable price array. |
|
| 1831 | - foreach ( $variable_prices as $variable_price ) { |
|
| 1832 | - $variable_price_options[ $variable_price['_give_id']['level_id'] ] = $variable_price['_give_text']; |
|
| 1833 | - } |
|
| 1830 | + // Get variable price and ID from variable price array. |
|
| 1831 | + foreach ( $variable_prices as $variable_price ) { |
|
| 1832 | + $variable_price_options[ $variable_price['_give_id']['level_id'] ] = $variable_price['_give_text']; |
|
| 1833 | + } |
|
| 1834 | 1834 | |
| 1835 | 1835 | |
| 1836 | - // Update options. |
|
| 1837 | - $args = array_merge( $args, array( 'options' => $variable_price_options ) ); |
|
| 1836 | + // Update options. |
|
| 1837 | + $args = array_merge( $args, array( 'options' => $variable_price_options ) ); |
|
| 1838 | 1838 | |
| 1839 | - // Generate select html. |
|
| 1840 | - $form_dropdown_html = Give()->html->select( $args ); |
|
| 1839 | + // Generate select html. |
|
| 1840 | + $form_dropdown_html = Give()->html->select( $args ); |
|
| 1841 | 1841 | |
| 1842 | - if( ! $echo ) { |
|
| 1843 | - return $form_dropdown_html; |
|
| 1844 | - } |
|
| 1842 | + if( ! $echo ) { |
|
| 1843 | + return $form_dropdown_html; |
|
| 1844 | + } |
|
| 1845 | 1845 | |
| 1846 | - echo $form_dropdown_html; |
|
| 1846 | + echo $form_dropdown_html; |
|
| 1847 | 1847 | } |
| 1848 | 1848 | \ No newline at end of file |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | // Retrieve the payment ID |
| 38 | 38 | $payment_id = absint( $data['give_payment_id'] ); |
| 39 | 39 | |
| 40 | - /* @var Give_Payment $payment */ |
|
| 40 | + /* @var Give_Payment $payment */ |
|
| 41 | 41 | $payment = new Give_Payment( $payment_id ); |
| 42 | 42 | |
| 43 | 43 | // Retrieve existing payment meta |
@@ -151,9 +151,9 @@ discard block |
||
| 151 | 151 | $previous_customer->remove_payment( $payment_id, false ); |
| 152 | 152 | $customer->attach_payment( $payment_id, false ); |
| 153 | 153 | |
| 154 | - // Reduce previous user donation count and amoount. |
|
| 155 | - $previous_customer->decrease_purchase_count(); |
|
| 156 | - $previous_customer->decrease_value( $curr_total ); |
|
| 154 | + // Reduce previous user donation count and amoount. |
|
| 155 | + $previous_customer->decrease_purchase_count(); |
|
| 156 | + $previous_customer->decrease_value( $curr_total ); |
|
| 157 | 157 | |
| 158 | 158 | // If purchase was completed and not ever refunded, adjust stats of new customers. |
| 159 | 159 | if ( 'revoked' == $status || 'publish' == $status ) { |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | } else{ |
| 166 | 166 | // Update user donation stat. |
| 167 | 167 | $customer->update_donation_value( $curr_total, $new_total ); |
| 168 | - } |
|
| 168 | + } |
|
| 169 | 169 | |
| 170 | 170 | // Set new meta values |
| 171 | 171 | $payment->user_id = $customer->user_id; |
@@ -206,76 +206,76 @@ discard block |
||
| 206 | 206 | |
| 207 | 207 | $payment->save(); |
| 208 | 208 | |
| 209 | - // Get new give form ID. |
|
| 210 | - $new_form_id = absint( $data['forms'] ); |
|
| 211 | - $current_form_id = absint( $payment->get_meta( '_give_payment_form_id' ) ); |
|
| 209 | + // Get new give form ID. |
|
| 210 | + $new_form_id = absint( $data['forms'] ); |
|
| 211 | + $current_form_id = absint( $payment->get_meta( '_give_payment_form_id' ) ); |
|
| 212 | 212 | |
| 213 | - // We are adding payment transfer code in last to remove any conflict with above functionality. |
|
| 214 | - // For example: above code will automatically handle form stat (increase/decrease) when payment status changes. |
|
| 215 | - /* Check if user want to transfer current payment to new give form id. */ |
|
| 216 | - if( $new_form_id != $current_form_id ) { |
|
| 213 | + // We are adding payment transfer code in last to remove any conflict with above functionality. |
|
| 214 | + // For example: above code will automatically handle form stat (increase/decrease) when payment status changes. |
|
| 215 | + /* Check if user want to transfer current payment to new give form id. */ |
|
| 216 | + if( $new_form_id != $current_form_id ) { |
|
| 217 | 217 | |
| 218 | - // Get new give form title. |
|
| 219 | - $new_form_title = get_the_title( $new_form_id ); |
|
| 218 | + // Get new give form title. |
|
| 219 | + $new_form_title = get_the_title( $new_form_id ); |
|
| 220 | 220 | |
| 221 | - // Update new give form data in payment data. |
|
| 222 | - $payment_meta = $payment->get_meta(); |
|
| 223 | - $payment_meta['form_title'] = $new_form_title; |
|
| 224 | - $payment_meta['form_id'] = $new_form_id; |
|
| 221 | + // Update new give form data in payment data. |
|
| 222 | + $payment_meta = $payment->get_meta(); |
|
| 223 | + $payment_meta['form_title'] = $new_form_title; |
|
| 224 | + $payment_meta['form_id'] = $new_form_id; |
|
| 225 | 225 | |
| 226 | - // Update price id post meta data for set donation form. |
|
| 227 | - if( ! give_has_variable_prices( $new_form_id ) ) { |
|
| 228 | - $payment_meta['price_id'] = ''; |
|
| 229 | - } |
|
| 226 | + // Update price id post meta data for set donation form. |
|
| 227 | + if( ! give_has_variable_prices( $new_form_id ) ) { |
|
| 228 | + $payment_meta['price_id'] = ''; |
|
| 229 | + } |
|
| 230 | 230 | |
| 231 | - // Update payment give form meta data. |
|
| 232 | - $payment->update_meta( '_give_payment_form_id', $new_form_id ); |
|
| 233 | - $payment->update_meta( '_give_payment_form_title', $new_form_title ); |
|
| 234 | - $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
| 231 | + // Update payment give form meta data. |
|
| 232 | + $payment->update_meta( '_give_payment_form_id', $new_form_id ); |
|
| 233 | + $payment->update_meta( '_give_payment_form_title', $new_form_title ); |
|
| 234 | + $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
| 235 | 235 | |
| 236 | - // Update price id payment metadata. |
|
| 237 | - if( ! give_has_variable_prices( $new_form_id ) ) { |
|
| 238 | - $payment->update_meta( '_give_payment_price_id', '' ); |
|
| 239 | - } |
|
| 236 | + // Update price id payment metadata. |
|
| 237 | + if( ! give_has_variable_prices( $new_form_id ) ) { |
|
| 238 | + $payment->update_meta( '_give_payment_price_id', '' ); |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | 241 | |
| 242 | - // If purchase was completed and not ever refunded, adjust stats of forms |
|
| 243 | - if ( 'revoked' == $status || 'publish' == $status ) { |
|
| 242 | + // If purchase was completed and not ever refunded, adjust stats of forms |
|
| 243 | + if ( 'revoked' == $status || 'publish' == $status ) { |
|
| 244 | 244 | |
| 245 | - // Decrease sale of old give form. For other payment status |
|
| 246 | - $current_form = new Give_Donate_Form( $current_form_id ); |
|
| 247 | - $current_form->decrease_sales(); |
|
| 248 | - $current_form->decrease_earnings( $curr_total ); |
|
| 245 | + // Decrease sale of old give form. For other payment status |
|
| 246 | + $current_form = new Give_Donate_Form( $current_form_id ); |
|
| 247 | + $current_form->decrease_sales(); |
|
| 248 | + $current_form->decrease_earnings( $curr_total ); |
|
| 249 | 249 | |
| 250 | - // Increase sale of new give form. |
|
| 251 | - $new_form = new Give_Donate_Form($new_form_id); |
|
| 252 | - $new_form->increase_sales(); |
|
| 253 | - $new_form->increase_earnings($new_total); |
|
| 254 | - } |
|
| 250 | + // Increase sale of new give form. |
|
| 251 | + $new_form = new Give_Donate_Form($new_form_id); |
|
| 252 | + $new_form->increase_sales(); |
|
| 253 | + $new_form->increase_earnings($new_total); |
|
| 254 | + } |
|
| 255 | 255 | |
| 256 | - // Re setup payment to update new meta value in object. |
|
| 257 | - $payment->update_payment_setup( $payment->ID ); |
|
| 258 | - } |
|
| 256 | + // Re setup payment to update new meta value in object. |
|
| 257 | + $payment->update_payment_setup( $payment->ID ); |
|
| 258 | + } |
|
| 259 | 259 | |
| 260 | - // Update price id if current form is variable form. |
|
| 261 | - if( ! empty( $data['give-variable-price'] ) && give_has_variable_prices( $payment->form_id ) ) { |
|
| 260 | + // Update price id if current form is variable form. |
|
| 261 | + if( ! empty( $data['give-variable-price'] ) && give_has_variable_prices( $payment->form_id ) ) { |
|
| 262 | 262 | |
| 263 | - // Get payment meta data. |
|
| 264 | - $payment_meta = $payment->get_meta(); |
|
| 263 | + // Get payment meta data. |
|
| 264 | + $payment_meta = $payment->get_meta(); |
|
| 265 | 265 | |
| 266 | - // Set payment id to empty string if variable price id is negative ( i.e. custom amount feature enabled ). |
|
| 267 | - $data['give-variable-price'] = ( 'custom' === $data['give-variable-price'] ) ? 'custom' : ( 0 < $data['give-variable-price'] ) ? $data['give-variable-price'] : ''; |
|
| 266 | + // Set payment id to empty string if variable price id is negative ( i.e. custom amount feature enabled ). |
|
| 267 | + $data['give-variable-price'] = ( 'custom' === $data['give-variable-price'] ) ? 'custom' : ( 0 < $data['give-variable-price'] ) ? $data['give-variable-price'] : ''; |
|
| 268 | 268 | |
| 269 | - // Update payment meta data. |
|
| 270 | - $payment_meta['price_id'] = $data['give-variable-price']; |
|
| 269 | + // Update payment meta data. |
|
| 270 | + $payment_meta['price_id'] = $data['give-variable-price']; |
|
| 271 | 271 | |
| 272 | - // Update payment give form meta data. |
|
| 273 | - $payment->update_meta( '_give_payment_price_id', $data['give-variable-price'] ); |
|
| 274 | - $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
| 272 | + // Update payment give form meta data. |
|
| 273 | + $payment->update_meta( '_give_payment_price_id', $data['give-variable-price'] ); |
|
| 274 | + $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
| 275 | 275 | |
| 276 | - // Re setup payment to update new meta value in object. |
|
| 277 | - $payment->update_payment_setup( $payment->ID ); |
|
| 278 | - } |
|
| 276 | + // Re setup payment to update new meta value in object. |
|
| 277 | + $payment->update_payment_setup( $payment->ID ); |
|
| 278 | + } |
|
| 279 | 279 | |
| 280 | 280 | do_action( 'give_updated_edited_purchase', $payment_id ); |
| 281 | 281 | |
@@ -75,8 +75,8 @@ discard block |
||
| 75 | 75 | 'row_classes' => 'give-subfield', |
| 76 | 76 | 'before_field' => give_get_option( 'currency_position' ) == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '', |
| 77 | 77 | 'after_field' => give_get_option( 'currency_position' ) == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '', |
| 78 | - 'sanitization_cb' => 'give_sanitize_amount', |
|
| 79 | - 'attributes' => array( |
|
| 78 | + 'sanitization_cb' => 'give_sanitize_amount', |
|
| 79 | + 'attributes' => array( |
|
| 80 | 80 | 'placeholder' => give_format_decimal( '1.00' ), |
| 81 | 81 | 'value' => give_format_decimal( $price ), |
| 82 | 82 | 'class' => 'cmb-type-text-small give-money-field', |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | 'before_field' => give_get_option( 'currency_position' ) == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '', |
| 112 | 112 | 'after_field' => give_get_option( 'currency_position' ) == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '', |
| 113 | 113 | 'sanitization_cb' => 'give_sanitize_amount', |
| 114 | - 'attributes' => array( |
|
| 114 | + 'attributes' => array( |
|
| 115 | 115 | 'placeholder' => '1.00', |
| 116 | 116 | 'class' => 'cmb-type-text-small give-money-field', |
| 117 | 117 | ), |
@@ -166,8 +166,8 @@ discard block |
||
| 166 | 166 | 'row_classes' => 'give-subfield', |
| 167 | 167 | 'before_field' => give_get_option( 'currency_position' ) == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '', |
| 168 | 168 | 'after_field' => give_get_option( 'currency_position' ) == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '', |
| 169 | - 'sanitization_cb' => 'give_sanitize_amount', |
|
| 170 | - 'attributes' => array( |
|
| 169 | + 'sanitization_cb' => 'give_sanitize_amount', |
|
| 170 | + 'attributes' => array( |
|
| 171 | 171 | 'placeholder' => give_format_decimal('1.00'),
|
| 172 | 172 | 'value' => give_format_decimal( $custom_amount_minimum ), |
| 173 | 173 | 'class' => 'cmb-type-text-small give-money-field', |
@@ -781,7 +781,7 @@ |
||
| 781 | 781 | foreach ( $prices as $price ) { |
| 782 | 782 | if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) { |
| 783 | 783 | $amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00; |
| 784 | - break; |
|
| 784 | + break; |
|
| 785 | 785 | }; |
| 786 | 786 | } |
| 787 | 787 | |