@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly. |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | /** |
| 47 | 47 | * Constructor. |
| 48 | 48 | */ |
| 49 | - public function __construct( $_step = 1 ) { |
|
| 50 | - parent::__construct( $_step ); |
|
| 49 | + public function __construct($_step = 1) { |
|
| 50 | + parent::__construct($_step); |
|
| 51 | 51 | |
| 52 | 52 | $this->is_writable = true; |
| 53 | 53 | } |
@@ -61,49 +61,49 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | public function get_data() { |
| 63 | 63 | |
| 64 | - if ( $this->step == 1 ) { |
|
| 65 | - $this->delete_data( 'give_temp_recount_earnings' ); |
|
| 64 | + if ($this->step == 1) { |
|
| 65 | + $this->delete_data('give_temp_recount_earnings'); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - $total = get_option( 'give_temp_recount_earnings', false ); |
|
| 68 | + $total = get_option('give_temp_recount_earnings', false); |
|
| 69 | 69 | |
| 70 | - if ( false === $total ) { |
|
| 70 | + if (false === $total) { |
|
| 71 | 71 | $total = (float) 0; |
| 72 | - $this->store_data( 'give_temp_recount_earnings', $total ); |
|
| 72 | + $this->store_data('give_temp_recount_earnings', $total); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
| 75 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
| 76 | 76 | |
| 77 | - $args = apply_filters( 'give_recount_earnings_args', array( |
|
| 77 | + $args = apply_filters('give_recount_earnings_args', array( |
|
| 78 | 78 | 'number' => $this->per_step, |
| 79 | 79 | 'page' => $this->step, |
| 80 | 80 | 'status' => $accepted_statuses, |
| 81 | 81 | 'fields' => 'ids' |
| 82 | - ) ); |
|
| 82 | + )); |
|
| 83 | 83 | |
| 84 | - $payments = give_get_payments( $args ); |
|
| 84 | + $payments = give_get_payments($args); |
|
| 85 | 85 | |
| 86 | - if ( ! empty( $payments ) ) { |
|
| 86 | + if ( ! empty($payments)) { |
|
| 87 | 87 | |
| 88 | - foreach ( $payments as $payment ) { |
|
| 88 | + foreach ($payments as $payment) { |
|
| 89 | 89 | |
| 90 | - $total += (float) give_donation_amount( $payment, array( 'type' => 'stats' ) ); |
|
| 90 | + $total += (float) give_donation_amount($payment, array('type' => 'stats')); |
|
| 91 | 91 | |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - if ( $total < 0 ) { |
|
| 94 | + if ($total < 0) { |
|
| 95 | 95 | $totals = 0; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - $total = round( $total, give_get_price_decimals() ); |
|
| 98 | + $total = round($total, give_get_price_decimals()); |
|
| 99 | 99 | |
| 100 | - $this->store_data( 'give_temp_recount_earnings', $total ); |
|
| 100 | + $this->store_data('give_temp_recount_earnings', $total); |
|
| 101 | 101 | |
| 102 | 102 | return true; |
| 103 | 103 | |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - update_option( 'give_earnings_total', $total ); |
|
| 106 | + update_option('give_earnings_total', $total); |
|
| 107 | 107 | |
| 108 | 108 | return false; |
| 109 | 109 | |
@@ -117,25 +117,25 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | public function get_percentage_complete() { |
| 119 | 119 | |
| 120 | - $total = $this->get_stored_data( 'give_recount_earnings_total' ); |
|
| 120 | + $total = $this->get_stored_data('give_recount_earnings_total'); |
|
| 121 | 121 | |
| 122 | - if ( false === $total ) { |
|
| 123 | - $args = apply_filters( 'give_recount_earnings_total_args', array() ); |
|
| 122 | + if (false === $total) { |
|
| 123 | + $args = apply_filters('give_recount_earnings_total_args', array()); |
|
| 124 | 124 | |
| 125 | - $counts = give_count_payments( $args ); |
|
| 126 | - $total = absint( $counts->publish ); |
|
| 127 | - $total = apply_filters( 'give_recount_store_earnings_total', $total ); |
|
| 125 | + $counts = give_count_payments($args); |
|
| 126 | + $total = absint($counts->publish); |
|
| 127 | + $total = apply_filters('give_recount_store_earnings_total', $total); |
|
| 128 | 128 | |
| 129 | - $this->store_data( 'give_recount_earnings_total', $total ); |
|
| 129 | + $this->store_data('give_recount_earnings_total', $total); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | $percentage = 100; |
| 133 | 133 | |
| 134 | - if ( $total > 0 ) { |
|
| 135 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 134 | + if ($total > 0) { |
|
| 135 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - if ( $percentage > 100 ) { |
|
| 138 | + if ($percentage > 100) { |
|
| 139 | 139 | $percentage = 100; |
| 140 | 140 | } |
| 141 | 141 | |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | * |
| 150 | 150 | * @param array $request The Form Data passed into the batch processing |
| 151 | 151 | */ |
| 152 | - public function set_properties( $request ) { |
|
| 152 | + public function set_properties($request) { |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -160,21 +160,21 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | public function process_step() { |
| 162 | 162 | |
| 163 | - if ( ! $this->can_export() ) { |
|
| 164 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 163 | + if ( ! $this->can_export()) { |
|
| 164 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | $had_data = $this->get_data(); |
| 168 | 168 | |
| 169 | - if ( $had_data ) { |
|
| 169 | + if ($had_data) { |
|
| 170 | 170 | $this->done = false; |
| 171 | 171 | |
| 172 | 172 | return true; |
| 173 | 173 | } else { |
| 174 | - $this->delete_data( 'give_recount_earnings_total' ); |
|
| 175 | - $this->delete_data( 'give_temp_recount_earnings' ); |
|
| 174 | + $this->delete_data('give_recount_earnings_total'); |
|
| 175 | + $this->delete_data('give_temp_recount_earnings'); |
|
| 176 | 176 | $this->done = true; |
| 177 | - $this->message = esc_html__( 'Income stats have been successfully recounted.', 'give' ); |
|
| 177 | + $this->message = esc_html__('Income stats have been successfully recounted.', 'give'); |
|
| 178 | 178 | |
| 179 | 179 | return false; |
| 180 | 180 | } |
@@ -211,17 +211,17 @@ discard block |
||
| 211 | 211 | * |
| 212 | 212 | * @return mixed Returns the data from the database |
| 213 | 213 | */ |
| 214 | - private function get_stored_data( $key ) { |
|
| 214 | + private function get_stored_data($key) { |
|
| 215 | 215 | global $wpdb; |
| 216 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 216 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 217 | 217 | |
| 218 | - if ( empty( $value ) ) { |
|
| 218 | + if (empty($value)) { |
|
| 219 | 219 | return false; |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - $maybe_json = json_decode( $value ); |
|
| 223 | - if ( ! is_null( $maybe_json ) ) { |
|
| 224 | - $value = json_decode( $value, true ); |
|
| 222 | + $maybe_json = json_decode($value); |
|
| 223 | + if ( ! is_null($maybe_json)) { |
|
| 224 | + $value = json_decode($value, true); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | return $value; |
@@ -237,10 +237,10 @@ discard block |
||
| 237 | 237 | * |
| 238 | 238 | * @return void |
| 239 | 239 | */ |
| 240 | - private function store_data( $key, $value ) { |
|
| 240 | + private function store_data($key, $value) { |
|
| 241 | 241 | global $wpdb; |
| 242 | 242 | |
| 243 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
| 243 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
| 244 | 244 | |
| 245 | 245 | $data = array( |
| 246 | 246 | 'option_name' => $key, |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | '%s', |
| 255 | 255 | ); |
| 256 | 256 | |
| 257 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 257 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | /** |
@@ -266,9 +266,9 @@ discard block |
||
| 266 | 266 | * |
| 267 | 267 | * @return void |
| 268 | 268 | */ |
| 269 | - private function delete_data( $key ) { |
|
| 269 | + private function delete_data($key) { |
|
| 270 | 270 | global $wpdb; |
| 271 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 271 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly. |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | /** |
| 47 | 47 | * Constructor. |
| 48 | 48 | */ |
| 49 | - public function __construct( $_step = 1 ) { |
|
| 50 | - parent::__construct( $_step ); |
|
| 49 | + public function __construct($_step = 1) { |
|
| 50 | + parent::__construct($_step); |
|
| 51 | 51 | |
| 52 | 52 | $this->is_writable = true; |
| 53 | 53 | } |
@@ -62,20 +62,20 @@ discard block |
||
| 62 | 62 | * @return array|bool $data The data for the CSV file |
| 63 | 63 | */ |
| 64 | 64 | public function get_data() { |
| 65 | - $items = $this->get_stored_data( 'give_temp_delete_test_ids' ); |
|
| 65 | + $items = $this->get_stored_data('give_temp_delete_test_ids'); |
|
| 66 | 66 | |
| 67 | - if ( ! is_array( $items ) ) { |
|
| 67 | + if ( ! is_array($items)) { |
|
| 68 | 68 | return false; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
| 72 | - $step_items = array_slice( $items, $offset, $this->per_step ); |
|
| 73 | - $meta_table = __give_v20_bc_table_details( 'payment' ); |
|
| 71 | + $offset = ($this->step - 1) * $this->per_step; |
|
| 72 | + $step_items = array_slice($items, $offset, $this->per_step); |
|
| 73 | + $meta_table = __give_v20_bc_table_details('payment'); |
|
| 74 | 74 | |
| 75 | - if ( $step_items ) { |
|
| 76 | - foreach ( $step_items as $item ) { |
|
| 75 | + if ($step_items) { |
|
| 76 | + foreach ($step_items as $item) { |
|
| 77 | 77 | // Delete the main payment. |
| 78 | - give_delete_donation( absint( $item['id'] ) ); |
|
| 78 | + give_delete_donation(absint($item['id'])); |
|
| 79 | 79 | } |
| 80 | 80 | return true; |
| 81 | 81 | } |
@@ -91,16 +91,16 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | public function get_percentage_complete() { |
| 93 | 93 | |
| 94 | - $items = $this->get_stored_data( 'give_temp_delete_test_ids', false ); |
|
| 95 | - $total = count( $items ); |
|
| 94 | + $items = $this->get_stored_data('give_temp_delete_test_ids', false); |
|
| 95 | + $total = count($items); |
|
| 96 | 96 | |
| 97 | 97 | $percentage = 100; |
| 98 | 98 | |
| 99 | - if ( $total > 0 ) { |
|
| 100 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 99 | + if ($total > 0) { |
|
| 100 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - if ( $percentage > 100 ) { |
|
| 103 | + if ($percentage > 100) { |
|
| 104 | 104 | $percentage = 100; |
| 105 | 105 | } |
| 106 | 106 | |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | * @param array $request The Form Data passed into the batch processing |
| 116 | 116 | */ |
| 117 | - public function set_properties( $request ) { |
|
| 117 | + public function set_properties($request) { |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
@@ -125,29 +125,29 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | public function process_step() { |
| 127 | 127 | |
| 128 | - if ( ! $this->can_export() ) { |
|
| 129 | - wp_die( __( 'You do not have permission to delete test transactions.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 128 | + if ( ! $this->can_export()) { |
|
| 129 | + wp_die(__('You do not have permission to delete test transactions.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | $had_data = $this->get_data(); |
| 133 | 133 | |
| 134 | - if ( $had_data ) { |
|
| 134 | + if ($had_data) { |
|
| 135 | 135 | $this->done = false; |
| 136 | 136 | |
| 137 | 137 | return true; |
| 138 | 138 | } else { |
| 139 | - update_option( 'give_earnings_total', give_get_total_earnings( true ) ); |
|
| 140 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
| 139 | + update_option('give_earnings_total', give_get_total_earnings(true)); |
|
| 140 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
| 141 | 141 | |
| 142 | - $this->delete_data( 'give_temp_delete_test_ids' ); |
|
| 142 | + $this->delete_data('give_temp_delete_test_ids'); |
|
| 143 | 143 | |
| 144 | 144 | // Reset the sequential order numbers |
| 145 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
| 146 | - delete_option( 'give_last_payment_number' ); |
|
| 145 | + if (give_get_option('enable_sequential')) { |
|
| 146 | + delete_option('give_last_payment_number'); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | $this->done = true; |
| 150 | - $this->message = __( 'Test transactions successfully deleted.', 'give' ); |
|
| 150 | + $this->message = __('Test transactions successfully deleted.', 'give'); |
|
| 151 | 151 | |
| 152 | 152 | return false; |
| 153 | 153 | } |
@@ -180,27 +180,27 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | public function pre_fetch() { |
| 182 | 182 | |
| 183 | - if ( $this->step == 1 ) { |
|
| 184 | - $this->delete_data( 'give_temp_delete_test_ids' ); |
|
| 183 | + if ($this->step == 1) { |
|
| 184 | + $this->delete_data('give_temp_delete_test_ids'); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - $items = get_option( 'give_temp_delete_test_ids', false ); |
|
| 187 | + $items = get_option('give_temp_delete_test_ids', false); |
|
| 188 | 188 | |
| 189 | - if ( false === $items ) { |
|
| 189 | + if (false === $items) { |
|
| 190 | 190 | $items = array(); |
| 191 | 191 | |
| 192 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
| 192 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
| 193 | 193 | 'post_status' => 'any', |
| 194 | - 'number' => - 1, |
|
| 194 | + 'number' => -1, |
|
| 195 | 195 | 'meta_key' => '_give_payment_mode', |
| 196 | 196 | 'meta_value' => 'test' |
| 197 | - ) ); |
|
| 197 | + )); |
|
| 198 | 198 | |
| 199 | - $posts = new Give_Payments_Query( $args ); |
|
| 199 | + $posts = new Give_Payments_Query($args); |
|
| 200 | 200 | $payments = $posts->get_payments(); |
| 201 | 201 | |
| 202 | 202 | /* @var Give_Payment $payment */ |
| 203 | - foreach ( $payments as $payment ) { |
|
| 203 | + foreach ($payments as $payment) { |
|
| 204 | 204 | $items[] = array( |
| 205 | 205 | 'id' => (int) $payment->ID, |
| 206 | 206 | 'type' => 'give_payment', |
@@ -209,9 +209,9 @@ discard block |
||
| 209 | 209 | |
| 210 | 210 | // Allow filtering of items to remove with an unassociative array for each item. |
| 211 | 211 | // The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method. |
| 212 | - $items = apply_filters( 'give_delete_test_items', $items ); |
|
| 212 | + $items = apply_filters('give_delete_test_items', $items); |
|
| 213 | 213 | |
| 214 | - $this->store_data( 'give_temp_delete_test_ids', $items ); |
|
| 214 | + $this->store_data('give_temp_delete_test_ids', $items); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | } |
@@ -225,17 +225,17 @@ discard block |
||
| 225 | 225 | * |
| 226 | 226 | * @return mixed Returns the data from the database |
| 227 | 227 | */ |
| 228 | - private function get_stored_data( $key ) { |
|
| 228 | + private function get_stored_data($key) { |
|
| 229 | 229 | global $wpdb; |
| 230 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 230 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 231 | 231 | |
| 232 | - if ( empty( $value ) ) { |
|
| 232 | + if (empty($value)) { |
|
| 233 | 233 | return false; |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - $maybe_json = json_decode( $value ); |
|
| 237 | - if ( ! is_null( $maybe_json ) ) { |
|
| 238 | - $value = json_decode( $value, true ); |
|
| 236 | + $maybe_json = json_decode($value); |
|
| 237 | + if ( ! is_null($maybe_json)) { |
|
| 238 | + $value = json_decode($value, true); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | return $value; |
@@ -251,10 +251,10 @@ discard block |
||
| 251 | 251 | * |
| 252 | 252 | * @return void |
| 253 | 253 | */ |
| 254 | - private function store_data( $key, $value ) { |
|
| 254 | + private function store_data($key, $value) { |
|
| 255 | 255 | global $wpdb; |
| 256 | 256 | |
| 257 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
| 257 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
| 258 | 258 | |
| 259 | 259 | $data = array( |
| 260 | 260 | 'option_name' => $key, |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | '%s', |
| 269 | 269 | ); |
| 270 | 270 | |
| 271 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 271 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | /** |
@@ -280,9 +280,9 @@ discard block |
||
| 280 | 280 | * |
| 281 | 281 | * @return void |
| 282 | 282 | */ |
| 283 | - private function delete_data( $key ) { |
|
| 283 | + private function delete_data($key) { |
|
| 284 | 284 | global $wpdb; |
| 285 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 285 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly. |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -73,8 +73,8 @@ discard block |
||
| 73 | 73 | /** |
| 74 | 74 | * Constructor. |
| 75 | 75 | */ |
| 76 | - public function __construct( $_step = 1 ) { |
|
| 77 | - parent::__construct( $_step ); |
|
| 76 | + public function __construct($_step = 1) { |
|
| 77 | + parent::__construct($_step); |
|
| 78 | 78 | |
| 79 | 79 | $this->is_writable = true; |
| 80 | 80 | } |
@@ -89,108 +89,106 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | public function get_data() { |
| 91 | 91 | |
| 92 | - $totals = $this->get_stored_data( 'give_temp_recount_all_stats' ); |
|
| 93 | - $payment_items = $this->get_stored_data( 'give_temp_payment_items' ); |
|
| 94 | - $processed_payments = $this->get_stored_data( 'give_temp_processed_payments' ); |
|
| 95 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
| 92 | + $totals = $this->get_stored_data('give_temp_recount_all_stats'); |
|
| 93 | + $payment_items = $this->get_stored_data('give_temp_payment_items'); |
|
| 94 | + $processed_payments = $this->get_stored_data('give_temp_processed_payments'); |
|
| 95 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
| 96 | 96 | |
| 97 | - if ( false === $totals ) { |
|
| 97 | + if (false === $totals) { |
|
| 98 | 98 | $totals = array(); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - if ( false === $payment_items ) { |
|
| 101 | + if (false === $payment_items) { |
|
| 102 | 102 | $payment_items = array(); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - if ( false === $processed_payments ) { |
|
| 105 | + if (false === $processed_payments) { |
|
| 106 | 106 | $processed_payments = array(); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - $all_forms = $this->get_stored_data( 'give_temp_form_ids' ); |
|
| 109 | + $all_forms = $this->get_stored_data('give_temp_form_ids'); |
|
| 110 | 110 | |
| 111 | - $payments = $this->get_stored_data( 'give_temp_all_payments_data' ); |
|
| 111 | + $payments = $this->get_stored_data('give_temp_all_payments_data'); |
|
| 112 | 112 | |
| 113 | - if ( empty( $payments ) ) { |
|
| 114 | - $args = apply_filters( 'give_recount_form_stats_args', array( |
|
| 113 | + if (empty($payments)) { |
|
| 114 | + $args = apply_filters('give_recount_form_stats_args', array( |
|
| 115 | 115 | 'give_forms' => $all_forms, |
| 116 | 116 | 'number' => $this->per_step, |
| 117 | 117 | 'status' => $accepted_statuses, |
| 118 | 118 | 'paged' => $this->step, |
| 119 | 119 | 'output' => 'give_payments', |
| 120 | - ) ); |
|
| 120 | + )); |
|
| 121 | 121 | |
| 122 | - $payments_query = new Give_Payments_Query( $args ); |
|
| 122 | + $payments_query = new Give_Payments_Query($args); |
|
| 123 | 123 | $payments = $payments_query->get_payments(); |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - if ( ! empty( $payments ) ) { |
|
| 126 | + if ( ! empty($payments)) { |
|
| 127 | 127 | |
| 128 | 128 | //Loop through payments |
| 129 | - foreach ( $payments as $payment ) { |
|
| 129 | + foreach ($payments as $payment) { |
|
| 130 | 130 | |
| 131 | - $payment_id = ( ! empty( $payment['ID'] ) ? absint( $payment['ID'] ) : ( ! empty( $payment->ID ) ? absint( $payment->ID ) : false ) ); |
|
| 132 | - $payment = new Give_Payment( $payment_id ); |
|
| 131 | + $payment_id = ( ! empty($payment['ID']) ? absint($payment['ID']) : ( ! empty($payment->ID) ? absint($payment->ID) : false)); |
|
| 132 | + $payment = new Give_Payment($payment_id); |
|
| 133 | 133 | |
| 134 | 134 | // Prevent payments that have all ready been retrieved from a previous sales log from counting again. |
| 135 | - if ( in_array( $payment->ID, $processed_payments ) ) { |
|
| 135 | + if (in_array($payment->ID, $processed_payments)) { |
|
| 136 | 136 | continue; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | // Verify accepted status. |
| 140 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
| 140 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
| 141 | 141 | $processed_payments[] = $payment->ID; |
| 142 | 142 | continue; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - $payment_item = $payment_items[ $payment->ID ]; |
|
| 145 | + $payment_item = $payment_items[$payment->ID]; |
|
| 146 | 146 | |
| 147 | - $form_id = isset( $payment_item['id'] ) ? $payment_item['id'] : ''; |
|
| 147 | + $form_id = isset($payment_item['id']) ? $payment_item['id'] : ''; |
|
| 148 | 148 | |
| 149 | 149 | // Must have a form ID. |
| 150 | - if ( empty( $form_id ) ) { |
|
| 150 | + if (empty($form_id)) { |
|
| 151 | 151 | continue; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | // Form ID must be within $all_forms array to be validated. |
| 155 | - if ( ! in_array( $form_id, $all_forms ) ) { |
|
| 155 | + if ( ! in_array($form_id, $all_forms)) { |
|
| 156 | 156 | continue; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | // Set Sales count |
| 160 | - $totals[ $form_id ]['sales'] = isset( $totals[ $form_id ]['sales'] ) ? |
|
| 161 | - ++ $totals[ $form_id ]['sales'] : |
|
| 162 | - 1; |
|
| 160 | + $totals[$form_id]['sales'] = isset($totals[$form_id]['sales']) ? |
|
| 161 | + ++$totals[$form_id]['sales'] : 1; |
|
| 163 | 162 | |
| 164 | 163 | // Set Total Earnings |
| 165 | - $totals[ $form_id ]['earnings'] = isset( $totals[ $form_id ]['earnings'] ) ? |
|
| 166 | - ( $totals[ $form_id ]['earnings'] + $payment_item['price'] ) : |
|
| 167 | - $payment_item['price']; |
|
| 164 | + $totals[$form_id]['earnings'] = isset($totals[$form_id]['earnings']) ? |
|
| 165 | + ($totals[$form_id]['earnings'] + $payment_item['price']) : $payment_item['price']; |
|
| 168 | 166 | |
| 169 | 167 | $processed_payments[] = $payment->ID; |
| 170 | 168 | } |
| 171 | 169 | |
| 172 | 170 | // Get the list of form ids which does not contain any payment record. |
| 173 | - $remaining_form_ids = array_diff( $all_forms, array_keys( $totals ) ); |
|
| 174 | - foreach ( $remaining_form_ids as $form_id ) { |
|
| 171 | + $remaining_form_ids = array_diff($all_forms, array_keys($totals)); |
|
| 172 | + foreach ($remaining_form_ids as $form_id) { |
|
| 175 | 173 | //If array key doesn't exist, create it |
| 176 | - if ( ! array_key_exists( $form_id, $totals ) ) { |
|
| 177 | - $totals[ $form_id ] = array( |
|
| 174 | + if ( ! array_key_exists($form_id, $totals)) { |
|
| 175 | + $totals[$form_id] = array( |
|
| 178 | 176 | 'sales' => (int) 0, |
| 179 | 177 | 'earnings' => (float) 0, |
| 180 | 178 | ); |
| 181 | 179 | } |
| 182 | 180 | } |
| 183 | 181 | |
| 184 | - $this->store_data( 'give_temp_processed_payments', $processed_payments ); |
|
| 185 | - $this->store_data( 'give_temp_recount_all_stats', $totals ); |
|
| 182 | + $this->store_data('give_temp_processed_payments', $processed_payments); |
|
| 183 | + $this->store_data('give_temp_recount_all_stats', $totals); |
|
| 186 | 184 | |
| 187 | 185 | return true; |
| 188 | 186 | } |
| 189 | 187 | |
| 190 | 188 | |
| 191 | - foreach ( $totals as $key => $stats ) { |
|
| 192 | - give_update_meta( $key, '_give_form_sales', $stats['sales'] ); |
|
| 193 | - give_update_meta( $key, '_give_form_earnings', give_sanitize_amount_for_db( $stats['earnings'] ) ); |
|
| 189 | + foreach ($totals as $key => $stats) { |
|
| 190 | + give_update_meta($key, '_give_form_sales', $stats['sales']); |
|
| 191 | + give_update_meta($key, '_give_form_earnings', give_sanitize_amount_for_db($stats['earnings'])); |
|
| 194 | 192 | } |
| 195 | 193 | |
| 196 | 194 | return false; |
@@ -205,20 +203,20 @@ discard block |
||
| 205 | 203 | */ |
| 206 | 204 | public function get_percentage_complete() { |
| 207 | 205 | |
| 208 | - $total = $this->get_stored_data( 'give_recount_all_total' ); |
|
| 206 | + $total = $this->get_stored_data('give_recount_all_total'); |
|
| 209 | 207 | |
| 210 | - if ( false === $total ) { |
|
| 208 | + if (false === $total) { |
|
| 211 | 209 | $this->pre_fetch(); |
| 212 | - $total = $this->get_stored_data( 'give_recount_all_total' ); |
|
| 210 | + $total = $this->get_stored_data('give_recount_all_total'); |
|
| 213 | 211 | } |
| 214 | 212 | |
| 215 | 213 | $percentage = 100; |
| 216 | 214 | |
| 217 | - if ( $total > 0 ) { |
|
| 218 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 215 | + if ($total > 0) { |
|
| 216 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 219 | 217 | } |
| 220 | 218 | |
| 221 | - if ( $percentage > 100 ) { |
|
| 219 | + if ($percentage > 100) { |
|
| 222 | 220 | $percentage = 100; |
| 223 | 221 | } |
| 224 | 222 | |
@@ -232,8 +230,8 @@ discard block |
||
| 232 | 230 | * |
| 233 | 231 | * @param array $request The Form Data passed into the batch processing |
| 234 | 232 | */ |
| 235 | - public function set_properties( $request ) { |
|
| 236 | - $this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false; |
|
| 233 | + public function set_properties($request) { |
|
| 234 | + $this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false; |
|
| 237 | 235 | } |
| 238 | 236 | |
| 239 | 237 | /** |
@@ -244,25 +242,25 @@ discard block |
||
| 244 | 242 | */ |
| 245 | 243 | public function process_step() { |
| 246 | 244 | |
| 247 | - if ( ! $this->can_export() ) { |
|
| 248 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 245 | + if ( ! $this->can_export()) { |
|
| 246 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 249 | 247 | } |
| 250 | 248 | |
| 251 | 249 | $had_data = $this->get_data(); |
| 252 | 250 | |
| 253 | - if ( $had_data ) { |
|
| 251 | + if ($had_data) { |
|
| 254 | 252 | $this->done = false; |
| 255 | 253 | |
| 256 | 254 | return true; |
| 257 | 255 | } else { |
| 258 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
| 259 | - $this->delete_data( 'give_recount_all_total' ); |
|
| 260 | - $this->delete_data( 'give_temp_recount_all_stats' ); |
|
| 261 | - $this->delete_data( 'give_temp_payment_items' ); |
|
| 262 | - $this->delete_data( 'give_temp_form_ids' ); |
|
| 263 | - $this->delete_data( 'give_temp_processed_payments' ); |
|
| 256 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
| 257 | + $this->delete_data('give_recount_all_total'); |
|
| 258 | + $this->delete_data('give_temp_recount_all_stats'); |
|
| 259 | + $this->delete_data('give_temp_payment_items'); |
|
| 260 | + $this->delete_data('give_temp_form_ids'); |
|
| 261 | + $this->delete_data('give_temp_processed_payments'); |
|
| 264 | 262 | $this->done = true; |
| 265 | - $this->message = esc_html__( 'Donation form income amounts and donation counts stats successfully recounted.', 'give' ); |
|
| 263 | + $this->message = esc_html__('Donation form income amounts and donation counts stats successfully recounted.', 'give'); |
|
| 266 | 264 | |
| 267 | 265 | return false; |
| 268 | 266 | } |
@@ -298,70 +296,70 @@ discard block |
||
| 298 | 296 | */ |
| 299 | 297 | public function pre_fetch() { |
| 300 | 298 | |
| 301 | - if ( 1 == $this->step ) { |
|
| 302 | - $this->delete_data( 'give_temp_recount_all_total' ); |
|
| 303 | - $this->delete_data( 'give_temp_recount_all_stats' ); |
|
| 304 | - $this->delete_data( 'give_temp_payment_items' ); |
|
| 305 | - $this->delete_data( 'give_temp_processed_payments' ); |
|
| 306 | - $this->delete_data( 'give_temp_all_payments_data' ); |
|
| 299 | + if (1 == $this->step) { |
|
| 300 | + $this->delete_data('give_temp_recount_all_total'); |
|
| 301 | + $this->delete_data('give_temp_recount_all_stats'); |
|
| 302 | + $this->delete_data('give_temp_payment_items'); |
|
| 303 | + $this->delete_data('give_temp_processed_payments'); |
|
| 304 | + $this->delete_data('give_temp_all_payments_data'); |
|
| 307 | 305 | } |
| 308 | 306 | |
| 309 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
| 310 | - $total = $this->get_stored_data( 'give_temp_recount_all_total' ); |
|
| 307 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
| 308 | + $total = $this->get_stored_data('give_temp_recount_all_total'); |
|
| 311 | 309 | |
| 312 | - if ( false === $total ) { |
|
| 310 | + if (false === $total) { |
|
| 313 | 311 | |
| 314 | - $payment_items = $this->get_stored_data( 'give_temp_payment_items' ); |
|
| 312 | + $payment_items = $this->get_stored_data('give_temp_payment_items'); |
|
| 315 | 313 | |
| 316 | - if ( false === $payment_items ) { |
|
| 314 | + if (false === $payment_items) { |
|
| 317 | 315 | $payment_items = array(); |
| 318 | - $this->store_data( 'give_temp_payment_items', $payment_items ); |
|
| 316 | + $this->store_data('give_temp_payment_items', $payment_items); |
|
| 319 | 317 | } |
| 320 | 318 | |
| 321 | 319 | $args = array( |
| 322 | 320 | 'post_status' => 'publish', |
| 323 | 321 | 'post_type' => 'give_forms', |
| 324 | - 'posts_per_page' => - 1, |
|
| 322 | + 'posts_per_page' => -1, |
|
| 325 | 323 | 'fields' => 'ids', |
| 326 | 324 | ); |
| 327 | 325 | |
| 328 | - $all_forms = get_posts( $args ); |
|
| 326 | + $all_forms = get_posts($args); |
|
| 329 | 327 | |
| 330 | - $this->store_data( 'give_temp_form_ids', $all_forms ); |
|
| 328 | + $this->store_data('give_temp_form_ids', $all_forms); |
|
| 331 | 329 | |
| 332 | - $args = apply_filters( 'give_recount_form_stats_total_args', array( |
|
| 330 | + $args = apply_filters('give_recount_form_stats_total_args', array( |
|
| 333 | 331 | 'give_forms' => $all_forms, |
| 334 | 332 | 'number' => $this->per_step, |
| 335 | 333 | 'status' => $accepted_statuses, |
| 336 | 334 | 'page' => $this->step, |
| 337 | 335 | 'output' => 'payments', |
| 338 | - ) ); |
|
| 336 | + )); |
|
| 339 | 337 | |
| 340 | - $payments_query = new Give_Payments_Query( $args ); |
|
| 338 | + $payments_query = new Give_Payments_Query($args); |
|
| 341 | 339 | $payments = $payments_query->get_payments(); |
| 342 | 340 | |
| 343 | - $total = wp_count_posts( 'give_payment' )->publish; |
|
| 341 | + $total = wp_count_posts('give_payment')->publish; |
|
| 344 | 342 | |
| 345 | - $this->store_data( 'give_temp_all_payments_data', $payments ); |
|
| 343 | + $this->store_data('give_temp_all_payments_data', $payments); |
|
| 346 | 344 | |
| 347 | - if ( $payments ) { |
|
| 345 | + if ($payments) { |
|
| 348 | 346 | |
| 349 | - foreach ( $payments as $payment ) { |
|
| 347 | + foreach ($payments as $payment) { |
|
| 350 | 348 | |
| 351 | 349 | $form_id = $payment->form_id; |
| 352 | 350 | |
| 353 | 351 | //If for some reason somehow the form_ID isn't set check payment meta |
| 354 | - if ( empty( $payment->form_id ) ) { |
|
| 352 | + if (empty($payment->form_id)) { |
|
| 355 | 353 | $payment_meta = $payment->get_meta(); |
| 356 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0; |
|
| 354 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0; |
|
| 357 | 355 | } |
| 358 | 356 | |
| 359 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
| 357 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
| 360 | 358 | continue; |
| 361 | 359 | } |
| 362 | 360 | |
| 363 | - if ( ! array_key_exists( $payment->ID, $payment_items ) ) { |
|
| 364 | - $payment_items[ $payment->ID ] = array( |
|
| 361 | + if ( ! array_key_exists($payment->ID, $payment_items)) { |
|
| 362 | + $payment_items[$payment->ID] = array( |
|
| 365 | 363 | 'id' => $form_id, |
| 366 | 364 | 'payment_id' => $payment->ID, |
| 367 | 365 | 'price' => $payment->total, |
@@ -369,8 +367,8 @@ discard block |
||
| 369 | 367 | } |
| 370 | 368 | } |
| 371 | 369 | } |
| 372 | - $this->store_data( 'give_temp_payment_items', $payment_items ); |
|
| 373 | - $this->store_data( 'give_recount_all_total', $total ); |
|
| 370 | + $this->store_data('give_temp_payment_items', $payment_items); |
|
| 371 | + $this->store_data('give_recount_all_total', $total); |
|
| 374 | 372 | } |
| 375 | 373 | |
| 376 | 374 | } |
@@ -384,17 +382,17 @@ discard block |
||
| 384 | 382 | * |
| 385 | 383 | * @return mixed Returns the data from the database |
| 386 | 384 | */ |
| 387 | - private function get_stored_data( $key ) { |
|
| 385 | + private function get_stored_data($key) { |
|
| 388 | 386 | global $wpdb; |
| 389 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 390 | - if ( empty( $value ) ) { |
|
| 387 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 388 | + if (empty($value)) { |
|
| 391 | 389 | return false; |
| 392 | 390 | } |
| 393 | 391 | |
| 394 | - $maybe_json = json_decode( $value ); |
|
| 392 | + $maybe_json = json_decode($value); |
|
| 395 | 393 | |
| 396 | - if ( ! is_null( $maybe_json ) ) { |
|
| 397 | - $value = json_decode( $value, true ); |
|
| 394 | + if ( ! is_null($maybe_json)) { |
|
| 395 | + $value = json_decode($value, true); |
|
| 398 | 396 | } |
| 399 | 397 | |
| 400 | 398 | return $value; |
@@ -410,10 +408,10 @@ discard block |
||
| 410 | 408 | * |
| 411 | 409 | * @return void |
| 412 | 410 | */ |
| 413 | - private function store_data( $key, $value ) { |
|
| 411 | + private function store_data($key, $value) { |
|
| 414 | 412 | global $wpdb; |
| 415 | 413 | |
| 416 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
| 414 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
| 417 | 415 | |
| 418 | 416 | $data = array( |
| 419 | 417 | 'option_name' => $key, |
@@ -427,7 +425,7 @@ discard block |
||
| 427 | 425 | '%s', |
| 428 | 426 | ); |
| 429 | 427 | |
| 430 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 428 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 431 | 429 | } |
| 432 | 430 | |
| 433 | 431 | /** |
@@ -439,9 +437,9 @@ discard block |
||
| 439 | 437 | * |
| 440 | 438 | * @return void |
| 441 | 439 | */ |
| 442 | - private function delete_data( $key ) { |
|
| 440 | + private function delete_data($key) { |
|
| 443 | 441 | global $wpdb; |
| 444 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 442 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 445 | 443 | } |
| 446 | 444 | |
| 447 | 445 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly. |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | /** |
| 47 | 47 | * Constructor. |
| 48 | 48 | */ |
| 49 | - public function __construct( $_step = 1 ) { |
|
| 50 | - parent::__construct( $_step ); |
|
| 49 | + public function __construct($_step = 1) { |
|
| 50 | + parent::__construct($_step); |
|
| 51 | 51 | |
| 52 | 52 | $this->is_writable = true; |
| 53 | 53 | } |
@@ -62,40 +62,40 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function get_data() { |
| 64 | 64 | |
| 65 | - $donor = new Give_Donor( $this->customer_id ); |
|
| 66 | - $payments = $this->get_stored_data( 'give_recount_donor_payments_' . $donor->id ); |
|
| 65 | + $donor = new Give_Donor($this->customer_id); |
|
| 66 | + $payments = $this->get_stored_data('give_recount_donor_payments_'.$donor->id); |
|
| 67 | 67 | |
| 68 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
| 69 | - $step_items = array_slice( $payments, $offset, $this->per_step ); |
|
| 68 | + $offset = ($this->step - 1) * $this->per_step; |
|
| 69 | + $step_items = array_slice($payments, $offset, $this->per_step); |
|
| 70 | 70 | |
| 71 | - if ( count( $step_items ) > 0 ) { |
|
| 72 | - $pending_total = (float) $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id ); |
|
| 71 | + if (count($step_items) > 0) { |
|
| 72 | + $pending_total = (float) $this->get_stored_data('give_stats_donor_pending_total'.$donor->id); |
|
| 73 | 73 | $step_total = 0; |
| 74 | 74 | |
| 75 | - $found_payment_ids = $this->get_stored_data( 'give_stats_found_payments_' . $donor->id ); |
|
| 75 | + $found_payment_ids = $this->get_stored_data('give_stats_found_payments_'.$donor->id); |
|
| 76 | 76 | |
| 77 | - foreach ( $step_items as $payment ) { |
|
| 78 | - $payment = get_post( $payment->ID ); |
|
| 77 | + foreach ($step_items as $payment) { |
|
| 78 | + $payment = get_post($payment->ID); |
|
| 79 | 79 | |
| 80 | - if ( is_null( $payment ) || is_wp_error( $payment ) || 'give_payment' !== $payment->post_type ) { |
|
| 80 | + if (is_null($payment) || is_wp_error($payment) || 'give_payment' !== $payment->post_type) { |
|
| 81 | 81 | |
| 82 | - $missing_payments = $this->get_stored_data( 'give_stats_missing_payments' . $donor->id ); |
|
| 82 | + $missing_payments = $this->get_stored_data('give_stats_missing_payments'.$donor->id); |
|
| 83 | 83 | $missing_payments[] = $payment->ID; |
| 84 | - $this->store_data( 'give_stats_missing_payments' . $donor->id, $missing_payments ); |
|
| 84 | + $this->store_data('give_stats_missing_payments'.$donor->id, $missing_payments); |
|
| 85 | 85 | |
| 86 | 86 | continue; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | $should_process_payment = 'publish' == $payment->post_status ? true : false; |
| 90 | - $should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment ); |
|
| 90 | + $should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment); |
|
| 91 | 91 | |
| 92 | - if ( true === $should_process_payment ) { |
|
| 92 | + if (true === $should_process_payment) { |
|
| 93 | 93 | |
| 94 | 94 | $found_payment_ids[] = $payment->ID; |
| 95 | 95 | |
| 96 | - if ( apply_filters( 'give_donor_recount_should_increase_value', true, $payment ) ) { |
|
| 97 | - $payment_amount = (float) give_donation_amount( $payment->ID, array( 'type' => 'stats' ) ); |
|
| 98 | - $step_total += $payment_amount; |
|
| 96 | + if (apply_filters('give_donor_recount_should_increase_value', true, $payment)) { |
|
| 97 | + $payment_amount = (float) give_donation_amount($payment->ID, array('type' => 'stats')); |
|
| 98 | + $step_total += $payment_amount; |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | } |
@@ -103,8 +103,8 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | $updated_total = $pending_total + $step_total; |
| 106 | - $this->store_data( 'give_stats_donor_pending_total' . $donor->id, $updated_total ); |
|
| 107 | - $this->store_data( 'give_stats_found_payments_' . $donor->id, $found_payment_ids ); |
|
| 106 | + $this->store_data('give_stats_donor_pending_total'.$donor->id, $updated_total); |
|
| 107 | + $this->store_data('give_stats_found_payments_'.$donor->id, $found_payment_ids); |
|
| 108 | 108 | |
| 109 | 109 | return true; |
| 110 | 110 | } |
@@ -121,16 +121,16 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function get_percentage_complete() { |
| 123 | 123 | |
| 124 | - $payments = $this->get_stored_data( 'give_recount_donor_payments_' . $this->customer_id ); |
|
| 125 | - $total = count( $payments ); |
|
| 124 | + $payments = $this->get_stored_data('give_recount_donor_payments_'.$this->customer_id); |
|
| 125 | + $total = count($payments); |
|
| 126 | 126 | |
| 127 | 127 | $percentage = 100; |
| 128 | 128 | |
| 129 | - if ( $total > 0 ) { |
|
| 130 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 129 | + if ($total > 0) { |
|
| 130 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - if ( $percentage > 100 ) { |
|
| 133 | + if ($percentage > 100) { |
|
| 134 | 134 | $percentage = 100; |
| 135 | 135 | } |
| 136 | 136 | |
@@ -144,8 +144,8 @@ discard block |
||
| 144 | 144 | * |
| 145 | 145 | * @param array $request The Form Data passed into the batch processing |
| 146 | 146 | */ |
| 147 | - public function set_properties( $request ) { |
|
| 148 | - $this->customer_id = isset( $request['customer_id'] ) ? sanitize_text_field( $request['customer_id'] ) : false; |
|
| 147 | + public function set_properties($request) { |
|
| 148 | + $this->customer_id = isset($request['customer_id']) ? sanitize_text_field($request['customer_id']) : false; |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
@@ -156,53 +156,53 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | public function process_step() { |
| 158 | 158 | |
| 159 | - if ( ! $this->can_export() ) { |
|
| 160 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 159 | + if ( ! $this->can_export()) { |
|
| 160 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | $had_data = $this->get_data(); |
| 164 | 164 | |
| 165 | - if ( $had_data ) { |
|
| 165 | + if ($had_data) { |
|
| 166 | 166 | $this->done = false; |
| 167 | 167 | |
| 168 | 168 | return true; |
| 169 | 169 | } else { |
| 170 | - $donor = new Give_Donor( $this->customer_id ); |
|
| 171 | - $payment_ids = get_option( 'give_stats_found_payments_' . $donor->id, array() ); |
|
| 172 | - $this->delete_data( 'give_stats_found_payments_' . $donor->id ); |
|
| 170 | + $donor = new Give_Donor($this->customer_id); |
|
| 171 | + $payment_ids = get_option('give_stats_found_payments_'.$donor->id, array()); |
|
| 172 | + $this->delete_data('give_stats_found_payments_'.$donor->id); |
|
| 173 | 173 | |
| 174 | - $removed_payments = array_unique( get_option( 'give_stats_missing_payments' . $donor->id, array() ) ); |
|
| 174 | + $removed_payments = array_unique(get_option('give_stats_missing_payments'.$donor->id, array())); |
|
| 175 | 175 | |
| 176 | 176 | // Find non-existing payments (deleted) and total up the donation count |
| 177 | 177 | $purchase_count = 0; |
| 178 | - foreach ( $payment_ids as $key => $payment_id ) { |
|
| 179 | - if ( in_array( $payment_id, $removed_payments ) ) { |
|
| 180 | - unset( $payment_ids[ $key ] ); |
|
| 178 | + foreach ($payment_ids as $key => $payment_id) { |
|
| 179 | + if (in_array($payment_id, $removed_payments)) { |
|
| 180 | + unset($payment_ids[$key]); |
|
| 181 | 181 | continue; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - $payment = get_post( $payment_id ); |
|
| 185 | - if ( apply_filters( 'give_donor_recount_should_increase_count', true, $payment ) ) { |
|
| 186 | - $purchase_count ++; |
|
| 184 | + $payment = get_post($payment_id); |
|
| 185 | + if (apply_filters('give_donor_recount_should_increase_count', true, $payment)) { |
|
| 186 | + $purchase_count++; |
|
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - $this->delete_data( 'give_stats_missing_payments' . $donor->id ); |
|
| 190 | + $this->delete_data('give_stats_missing_payments'.$donor->id); |
|
| 191 | 191 | |
| 192 | - $pending_total = $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id ); |
|
| 193 | - $this->delete_data( 'give_stats_donor_pending_total' . $donor->id ); |
|
| 194 | - $this->delete_data( 'give_recount_donor_stats_' . $donor->id ); |
|
| 195 | - $this->delete_data( 'give_recount_donor_payments_' . $this->customer_id ); |
|
| 192 | + $pending_total = $this->get_stored_data('give_stats_donor_pending_total'.$donor->id); |
|
| 193 | + $this->delete_data('give_stats_donor_pending_total'.$donor->id); |
|
| 194 | + $this->delete_data('give_recount_donor_stats_'.$donor->id); |
|
| 195 | + $this->delete_data('give_recount_donor_payments_'.$this->customer_id); |
|
| 196 | 196 | |
| 197 | - $payment_ids = implode( ',', $payment_ids ); |
|
| 198 | - $donor->update( array( |
|
| 197 | + $payment_ids = implode(',', $payment_ids); |
|
| 198 | + $donor->update(array( |
|
| 199 | 199 | 'payment_ids' => $payment_ids, |
| 200 | 200 | 'purchase_count' => $purchase_count, |
| 201 | 201 | 'purchase_value' => $pending_total, |
| 202 | - ) ); |
|
| 202 | + )); |
|
| 203 | 203 | |
| 204 | 204 | $this->done = true; |
| 205 | - $this->message = esc_html__( 'Donor stats have been successfully recounted.', 'give' ); |
|
| 205 | + $this->message = esc_html__('Donor stats have been successfully recounted.', 'give'); |
|
| 206 | 206 | |
| 207 | 207 | return false; |
| 208 | 208 | } |
@@ -235,26 +235,26 @@ discard block |
||
| 235 | 235 | * @return void |
| 236 | 236 | */ |
| 237 | 237 | public function pre_fetch() { |
| 238 | - if ( $this->step === 1 ) { |
|
| 239 | - $allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() ); |
|
| 238 | + if ($this->step === 1) { |
|
| 239 | + $allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys()); |
|
| 240 | 240 | |
| 241 | 241 | // Before we start, let's zero out the customer's data |
| 242 | - $donor = new Give_Donor( $this->customer_id ); |
|
| 243 | - $donor->update( array( 'purchase_value' => give_format_amount( 0, array( 'sanitize' => false ) ), 'purchase_count' => 0 ) ); |
|
| 242 | + $donor = new Give_Donor($this->customer_id); |
|
| 243 | + $donor->update(array('purchase_value' => give_format_amount(0, array('sanitize' => false)), 'purchase_count' => 0)); |
|
| 244 | 244 | |
| 245 | - $attached_payment_ids = explode( ',', $donor->payment_ids ); |
|
| 245 | + $attached_payment_ids = explode(',', $donor->payment_ids); |
|
| 246 | 246 | |
| 247 | 247 | $attached_args = array( |
| 248 | 248 | 'post__in' => $attached_payment_ids, |
| 249 | - 'number' => - 1, |
|
| 249 | + 'number' => -1, |
|
| 250 | 250 | 'status' => $allowed_payment_status, |
| 251 | 251 | ); |
| 252 | 252 | |
| 253 | - $attached_payments = give_get_payments( $attached_args ); |
|
| 253 | + $attached_payments = give_get_payments($attached_args); |
|
| 254 | 254 | |
| 255 | 255 | $unattached_args = array( |
| 256 | 256 | 'post__not_in' => $attached_payment_ids, |
| 257 | - 'number' => - 1, |
|
| 257 | + 'number' => -1, |
|
| 258 | 258 | 'status' => $allowed_payment_status, |
| 259 | 259 | 'meta_query' => array( |
| 260 | 260 | array( |
@@ -264,11 +264,11 @@ discard block |
||
| 264 | 264 | ), |
| 265 | 265 | ); |
| 266 | 266 | |
| 267 | - $unattached_payments = give_get_payments( $unattached_args ); |
|
| 267 | + $unattached_payments = give_get_payments($unattached_args); |
|
| 268 | 268 | |
| 269 | - $payments = array_merge( $attached_payments, $unattached_payments ); |
|
| 269 | + $payments = array_merge($attached_payments, $unattached_payments); |
|
| 270 | 270 | |
| 271 | - $this->store_data( 'give_recount_donor_payments_' . $donor->id, $payments ); |
|
| 271 | + $this->store_data('give_recount_donor_payments_'.$donor->id, $payments); |
|
| 272 | 272 | } |
| 273 | 273 | } |
| 274 | 274 | |
@@ -281,17 +281,17 @@ discard block |
||
| 281 | 281 | * |
| 282 | 282 | * @return mixed Returns the data from the database |
| 283 | 283 | */ |
| 284 | - private function get_stored_data( $key ) { |
|
| 284 | + private function get_stored_data($key) { |
|
| 285 | 285 | global $wpdb; |
| 286 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 286 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 287 | 287 | |
| 288 | - if ( empty( $value ) ) { |
|
| 288 | + if (empty($value)) { |
|
| 289 | 289 | return false; |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - $maybe_json = json_decode( $value ); |
|
| 293 | - if ( ! is_null( $maybe_json ) ) { |
|
| 294 | - $value = json_decode( $value, true ); |
|
| 292 | + $maybe_json = json_decode($value); |
|
| 293 | + if ( ! is_null($maybe_json)) { |
|
| 294 | + $value = json_decode($value, true); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | return $value; |
@@ -307,10 +307,10 @@ discard block |
||
| 307 | 307 | * |
| 308 | 308 | * @return void |
| 309 | 309 | */ |
| 310 | - private function store_data( $key, $value ) { |
|
| 310 | + private function store_data($key, $value) { |
|
| 311 | 311 | global $wpdb; |
| 312 | 312 | |
| 313 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
| 313 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
| 314 | 314 | |
| 315 | 315 | $data = array( |
| 316 | 316 | 'option_name' => $key, |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | '%s', |
| 325 | 325 | ); |
| 326 | 326 | |
| 327 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 327 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | /** |
@@ -336,9 +336,9 @@ discard block |
||
| 336 | 336 | * |
| 337 | 337 | * @return void |
| 338 | 338 | */ |
| 339 | - private function delete_data( $key ) { |
|
| 339 | + private function delete_data($key) { |
|
| 340 | 340 | global $wpdb; |
| 341 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 341 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly. |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | /** |
| 50 | 50 | * Constructor. |
| 51 | 51 | */ |
| 52 | - public function __construct( $_step = 1 ) { |
|
| 53 | - parent::__construct( $_step ); |
|
| 52 | + public function __construct($_step = 1) { |
|
| 53 | + parent::__construct($_step); |
|
| 54 | 54 | |
| 55 | 55 | $this->is_writable = true; |
| 56 | 56 | } |
@@ -67,16 +67,16 @@ discard block |
||
| 67 | 67 | public function get_data() { |
| 68 | 68 | global $wpdb; |
| 69 | 69 | |
| 70 | - $items = $this->get_stored_data( 'give_temp_reset_ids' ); |
|
| 70 | + $items = $this->get_stored_data('give_temp_reset_ids'); |
|
| 71 | 71 | |
| 72 | - if ( ! is_array( $items ) ) { |
|
| 72 | + if ( ! is_array($items)) { |
|
| 73 | 73 | return false; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
| 77 | - $step_items = array_slice( $items, $offset, $this->per_step ); |
|
| 76 | + $offset = ($this->step - 1) * $this->per_step; |
|
| 77 | + $step_items = array_slice($items, $offset, $this->per_step); |
|
| 78 | 78 | |
| 79 | - if ( $step_items ) { |
|
| 79 | + if ($step_items) { |
|
| 80 | 80 | |
| 81 | 81 | $step_ids = array( |
| 82 | 82 | 'customers' => array(), |
@@ -84,9 +84,9 @@ discard block |
||
| 84 | 84 | 'other' => array(), |
| 85 | 85 | ); |
| 86 | 86 | |
| 87 | - foreach ( $step_items as $item ) { |
|
| 87 | + foreach ($step_items as $item) { |
|
| 88 | 88 | |
| 89 | - switch ( $item['type'] ) { |
|
| 89 | + switch ($item['type']) { |
|
| 90 | 90 | case 'customer': |
| 91 | 91 | $step_ids['customers'][] = $item['id']; |
| 92 | 92 | break; |
@@ -94,24 +94,24 @@ discard block |
||
| 94 | 94 | $step_ids['give_forms'][] = $item['id']; |
| 95 | 95 | break; |
| 96 | 96 | default: |
| 97 | - $item_type = apply_filters( 'give_reset_item_type', 'other', $item ); |
|
| 98 | - $step_ids[ $item_type ][] = $item['id']; |
|
| 97 | + $item_type = apply_filters('give_reset_item_type', 'other', $item); |
|
| 98 | + $step_ids[$item_type][] = $item['id']; |
|
| 99 | 99 | break; |
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | $sql = array(); |
| 104 | - $meta_table = __give_v20_bc_table_details('form' ); |
|
| 104 | + $meta_table = __give_v20_bc_table_details('form'); |
|
| 105 | 105 | |
| 106 | - foreach ( $step_ids as $type => $ids ) { |
|
| 106 | + foreach ($step_ids as $type => $ids) { |
|
| 107 | 107 | |
| 108 | - if ( empty( $ids ) ) { |
|
| 108 | + if (empty($ids)) { |
|
| 109 | 109 | continue; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - $ids = implode( ',', $ids ); |
|
| 112 | + $ids = implode(',', $ids); |
|
| 113 | 113 | |
| 114 | - switch ( $type ) { |
|
| 114 | + switch ($type) { |
|
| 115 | 115 | case 'customers': |
| 116 | 116 | $sql[] = "DELETE FROM $wpdb->donors WHERE id IN ($ids)"; |
| 117 | 117 | $table_name = $wpdb->donors; |
@@ -131,16 +131,16 @@ discard block |
||
| 131 | 131 | break; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - if ( ! in_array( $type, array( 'customers', 'forms', 'other' ) ) ) { |
|
| 134 | + if ( ! in_array($type, array('customers', 'forms', 'other'))) { |
|
| 135 | 135 | // Allows other types of custom post types to filter on their own post_type |
| 136 | 136 | // and add items to the query list, for the IDs found in their post type. |
| 137 | - $sql = apply_filters( "give_reset_add_queries_{$type}", $sql, $ids ); |
|
| 137 | + $sql = apply_filters("give_reset_add_queries_{$type}", $sql, $ids); |
|
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - if ( ! empty( $sql ) ) { |
|
| 142 | - foreach ( $sql as $query ) { |
|
| 143 | - $wpdb->query( $query ); |
|
| 141 | + if ( ! empty($sql)) { |
|
| 142 | + foreach ($sql as $query) { |
|
| 143 | + $wpdb->query($query); |
|
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | |
@@ -160,16 +160,16 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | public function get_percentage_complete() { |
| 162 | 162 | |
| 163 | - $items = $this->get_stored_data( 'give_temp_reset_ids' ); |
|
| 164 | - $total = count( $items ); |
|
| 163 | + $items = $this->get_stored_data('give_temp_reset_ids'); |
|
| 164 | + $total = count($items); |
|
| 165 | 165 | |
| 166 | 166 | $percentage = 100; |
| 167 | 167 | |
| 168 | - if ( $total > 0 ) { |
|
| 169 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 168 | + if ($total > 0) { |
|
| 169 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - if ( $percentage > 100 ) { |
|
| 172 | + if ($percentage > 100) { |
|
| 173 | 173 | $percentage = 100; |
| 174 | 174 | } |
| 175 | 175 | |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | * |
| 184 | 184 | * @param array $request The Form Data passed into the batch processing. |
| 185 | 185 | */ |
| 186 | - public function set_properties( $request ) { |
|
| 186 | + public function set_properties($request) { |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | /** |
@@ -194,31 +194,31 @@ discard block |
||
| 194 | 194 | */ |
| 195 | 195 | public function process_step() { |
| 196 | 196 | |
| 197 | - if ( ! $this->can_export() ) { |
|
| 198 | - wp_die( esc_html__( 'You do not have permission to reset data.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
| 197 | + if ( ! $this->can_export()) { |
|
| 198 | + wp_die(esc_html__('You do not have permission to reset data.', 'give'), esc_html__('Error', 'give'), array( |
|
| 199 | 199 | 'response' => 403, |
| 200 | - ) ); |
|
| 200 | + )); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | $had_data = $this->get_data(); |
| 204 | 204 | |
| 205 | - if ( $had_data ) { |
|
| 205 | + if ($had_data) { |
|
| 206 | 206 | $this->done = false; |
| 207 | 207 | |
| 208 | 208 | return true; |
| 209 | 209 | } else { |
| 210 | - update_option( 'give_earnings_total', 0 ); |
|
| 211 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
| 210 | + update_option('give_earnings_total', 0); |
|
| 211 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
| 212 | 212 | |
| 213 | - $this->delete_data( 'give_temp_reset_ids' ); |
|
| 213 | + $this->delete_data('give_temp_reset_ids'); |
|
| 214 | 214 | |
| 215 | 215 | // Reset the sequential order numbers |
| 216 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
| 217 | - delete_option( 'give_last_payment_number' ); |
|
| 216 | + if (give_get_option('enable_sequential')) { |
|
| 217 | + delete_option('give_last_payment_number'); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | $this->done = true; |
| 221 | - $this->message = esc_html__( 'Donation forms, income, donations counts, and logs successfully reset.', 'give' ); |
|
| 221 | + $this->message = esc_html__('Donation forms, income, donations counts, and logs successfully reset.', 'give'); |
|
| 222 | 222 | |
| 223 | 223 | return false; |
| 224 | 224 | } |
@@ -251,26 +251,26 @@ discard block |
||
| 251 | 251 | */ |
| 252 | 252 | public function pre_fetch() { |
| 253 | 253 | |
| 254 | - if ( $this->step == 1 ) { |
|
| 255 | - $this->delete_data( 'give_temp_reset_ids' ); |
|
| 254 | + if ($this->step == 1) { |
|
| 255 | + $this->delete_data('give_temp_reset_ids'); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - $items = get_option( 'give_temp_reset_ids', false ); |
|
| 258 | + $items = get_option('give_temp_reset_ids', false); |
|
| 259 | 259 | |
| 260 | - if ( false === $items ) { |
|
| 260 | + if (false === $items) { |
|
| 261 | 261 | $items = array(); |
| 262 | 262 | |
| 263 | - $give_types_for_reset = array( 'give_forms', 'give_payment' ); |
|
| 264 | - $give_types_for_reset = apply_filters( 'give_reset_store_post_types', $give_types_for_reset ); |
|
| 263 | + $give_types_for_reset = array('give_forms', 'give_payment'); |
|
| 264 | + $give_types_for_reset = apply_filters('give_reset_store_post_types', $give_types_for_reset); |
|
| 265 | 265 | |
| 266 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
| 266 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
| 267 | 267 | 'post_type' => $give_types_for_reset, |
| 268 | 268 | 'post_status' => 'any', |
| 269 | - 'posts_per_page' => - 1, |
|
| 270 | - ) ); |
|
| 269 | + 'posts_per_page' => -1, |
|
| 270 | + )); |
|
| 271 | 271 | |
| 272 | - $posts = get_posts( $args ); |
|
| 273 | - foreach ( $posts as $post ) { |
|
| 272 | + $posts = get_posts($args); |
|
| 273 | + foreach ($posts as $post) { |
|
| 274 | 274 | $items[] = array( |
| 275 | 275 | 'id' => (int) $post->ID, |
| 276 | 276 | 'type' => $post->post_type, |
@@ -278,10 +278,10 @@ discard block |
||
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | $donor_args = array( |
| 281 | - 'number' => - 1, |
|
| 281 | + 'number' => -1, |
|
| 282 | 282 | ); |
| 283 | - $donors = Give()->donors->get_donors( $donor_args ); |
|
| 284 | - foreach ( $donors as $donor ) { |
|
| 283 | + $donors = Give()->donors->get_donors($donor_args); |
|
| 284 | + foreach ($donors as $donor) { |
|
| 285 | 285 | $items[] = array( |
| 286 | 286 | 'id' => (int) $donor->id, |
| 287 | 287 | 'type' => 'customer', |
@@ -290,9 +290,9 @@ discard block |
||
| 290 | 290 | |
| 291 | 291 | // Allow filtering of items to remove with an unassociative array for each item |
| 292 | 292 | // The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method |
| 293 | - $items = apply_filters( 'give_reset_items', $items ); |
|
| 293 | + $items = apply_filters('give_reset_items', $items); |
|
| 294 | 294 | |
| 295 | - $this->store_data( 'give_temp_reset_ids', $items ); |
|
| 295 | + $this->store_data('give_temp_reset_ids', $items); |
|
| 296 | 296 | }// End if(). |
| 297 | 297 | |
| 298 | 298 | } |
@@ -306,17 +306,17 @@ discard block |
||
| 306 | 306 | * |
| 307 | 307 | * @return mixed Returns the data from the database. |
| 308 | 308 | */ |
| 309 | - private function get_stored_data( $key ) { |
|
| 309 | + private function get_stored_data($key) { |
|
| 310 | 310 | global $wpdb; |
| 311 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 311 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 312 | 312 | |
| 313 | - if ( empty( $value ) ) { |
|
| 313 | + if (empty($value)) { |
|
| 314 | 314 | return false; |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - $maybe_json = json_decode( $value ); |
|
| 318 | - if ( ! is_null( $maybe_json ) ) { |
|
| 319 | - $value = json_decode( $value, true ); |
|
| 317 | + $maybe_json = json_decode($value); |
|
| 318 | + if ( ! is_null($maybe_json)) { |
|
| 319 | + $value = json_decode($value, true); |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | return $value; |
@@ -332,10 +332,10 @@ discard block |
||
| 332 | 332 | * |
| 333 | 333 | * @return void |
| 334 | 334 | */ |
| 335 | - private function store_data( $key, $value ) { |
|
| 335 | + private function store_data($key, $value) { |
|
| 336 | 336 | global $wpdb; |
| 337 | 337 | |
| 338 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
| 338 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
| 339 | 339 | |
| 340 | 340 | $data = array( |
| 341 | 341 | 'option_name' => $key, |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | '%s', |
| 350 | 350 | ); |
| 351 | 351 | |
| 352 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 352 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | /** |
@@ -361,11 +361,11 @@ discard block |
||
| 361 | 361 | * |
| 362 | 362 | * @return void |
| 363 | 363 | */ |
| 364 | - private function delete_data( $key ) { |
|
| 364 | + private function delete_data($key) { |
|
| 365 | 365 | global $wpdb; |
| 366 | - $wpdb->delete( $wpdb->options, array( |
|
| 366 | + $wpdb->delete($wpdb->options, array( |
|
| 367 | 367 | 'option_name' => $key, |
| 368 | - ) ); |
|
| 368 | + )); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | } |
| 372 | 372 | \ 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 | |
@@ -24,10 +24,10 @@ discard block |
||
| 24 | 24 | * @return void |
| 25 | 25 | */ |
| 26 | 26 | function give_payment_history_page() { |
| 27 | - if ( isset( $_GET['view'] ) && 'view-payment-details' == $_GET['view'] ) { |
|
| 28 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/view-payment-details.php'; |
|
| 27 | + if (isset($_GET['view']) && 'view-payment-details' == $_GET['view']) { |
|
| 28 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/view-payment-details.php'; |
|
| 29 | 29 | } else { |
| 30 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/class-payments-table.php'; |
|
| 30 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/class-payments-table.php'; |
|
| 31 | 31 | $payments_table = new Give_Payment_History_Table(); |
| 32 | 32 | $payments_table->prepare_items(); |
| 33 | 33 | ?> |
@@ -41,23 +41,23 @@ discard block |
||
| 41 | 41 | * |
| 42 | 42 | * @since 1.7 |
| 43 | 43 | */ |
| 44 | - do_action( 'give_payments_page_top' ); |
|
| 44 | + do_action('give_payments_page_top'); |
|
| 45 | 45 | ?> |
| 46 | 46 | <hr class="wp-header-end"> |
| 47 | 47 | |
| 48 | - <form id="give-payments-advanced-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>"> |
|
| 48 | + <form id="give-payments-advanced-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>"> |
|
| 49 | 49 | <input type="hidden" name="post_type" value="give_forms" /> |
| 50 | 50 | <input type="hidden" name="page" value="give-payment-history" /> |
| 51 | 51 | <?php $payments_table->views() ?> |
| 52 | 52 | <?php $payments_table->advanced_filters(); ?> |
| 53 | 53 | </form> |
| 54 | 54 | |
| 55 | - <form id="give-payments-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>"> |
|
| 55 | + <form id="give-payments-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>"> |
|
| 56 | 56 | <input type="hidden" name="post_type" value="give_forms" /> |
| 57 | 57 | <input type="hidden" name="page" value="give-payment-history" /> |
| 58 | 58 | <?php |
| 59 | - if ( ! empty( $_GET['donor'] ) ) { |
|
| 60 | - echo sprintf( '<input type="hidden" name="donor" value="%s"/>', absint( $_GET['donor'] ) ); |
|
| 59 | + if ( ! empty($_GET['donor'])) { |
|
| 60 | + echo sprintf('<input type="hidden" name="donor" value="%s"/>', absint($_GET['donor'])); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | $payments_table->display(); |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | * |
| 71 | 71 | * @since 1.7 |
| 72 | 72 | */ |
| 73 | - do_action( 'give_payments_page_bottom' ); |
|
| 73 | + do_action('give_payments_page_bottom'); |
|
| 74 | 74 | ?> |
| 75 | 75 | |
| 76 | 76 | </div> |
@@ -87,29 +87,29 @@ discard block |
||
| 87 | 87 | * @param $title |
| 88 | 88 | * @return string |
| 89 | 89 | */ |
| 90 | -function give_view_order_details_title( $admin_title, $title ) { |
|
| 90 | +function give_view_order_details_title($admin_title, $title) { |
|
| 91 | 91 | |
| 92 | - if ( 'give_forms_page_give-payment-history' != get_current_screen()->base ) { |
|
| 92 | + if ('give_forms_page_give-payment-history' != get_current_screen()->base) { |
|
| 93 | 93 | return $admin_title; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - if( ! isset( $_GET['give-action'] ) ) { |
|
| 96 | + if ( ! isset($_GET['give-action'])) { |
|
| 97 | 97 | return $admin_title; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - switch( $_GET['give-action'] ) : |
|
| 100 | + switch ($_GET['give-action']) : |
|
| 101 | 101 | |
| 102 | 102 | case 'view-payment-details' : |
| 103 | 103 | $title = sprintf( |
| 104 | 104 | /* translators: %s: admin title */ |
| 105 | - esc_html__( 'View Donation Details - %s', 'give' ), |
|
| 105 | + esc_html__('View Donation Details - %s', 'give'), |
|
| 106 | 106 | $admin_title |
| 107 | 107 | ); |
| 108 | 108 | break; |
| 109 | 109 | case 'edit-payment' : |
| 110 | 110 | $title = sprintf( |
| 111 | 111 | /* translators: %s: admin title */ |
| 112 | - esc_html__( 'Edit Donation - %s', 'give' ), |
|
| 112 | + esc_html__('Edit Donation - %s', 'give'), |
|
| 113 | 113 | $admin_title |
| 114 | 114 | ); |
| 115 | 115 | break; |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | return $title; |
| 122 | 122 | } |
| 123 | -add_filter( 'admin_title', 'give_view_order_details_title', 10, 2 ); |
|
| 123 | +add_filter('admin_title', 'give_view_order_details_title', 10, 2); |
|
| 124 | 124 | |
| 125 | 125 | /** |
| 126 | 126 | * Intercept default Edit post links for Give payments and rewrite them to the View Order Details screen. |
@@ -132,20 +132,20 @@ discard block |
||
| 132 | 132 | * @param $context |
| 133 | 133 | * @return string |
| 134 | 134 | */ |
| 135 | -function give_override_edit_post_for_payment_link( $url, $post_id = 0, $context ) { |
|
| 135 | +function give_override_edit_post_for_payment_link($url, $post_id = 0, $context) { |
|
| 136 | 136 | |
| 137 | - $post = get_post( $post_id ); |
|
| 137 | + $post = get_post($post_id); |
|
| 138 | 138 | |
| 139 | - if( ! $post ) { |
|
| 139 | + if ( ! $post) { |
|
| 140 | 140 | return $url; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - if( 'give_payment' != $post->post_type ) { |
|
| 143 | + if ('give_payment' != $post->post_type) { |
|
| 144 | 144 | return $url; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - $url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $post_id ); |
|
| 147 | + $url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$post_id); |
|
| 148 | 148 | |
| 149 | 149 | return $url; |
| 150 | 150 | } |
| 151 | -add_filter( 'get_edit_post_link', 'give_override_edit_post_for_payment_link', 10, 3 ); |
|
| 151 | +add_filter('get_edit_post_link', 'give_override_edit_post_for_payment_link', 10, 3); |
|
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @return string |
| 22 | 22 | */ |
| 23 | 23 | function give_get_templates_dir() { |
| 24 | - return GIVE_PLUGIN_DIR . 'templates'; |
|
| 24 | + return GIVE_PLUGIN_DIR.'templates'; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * @return string |
| 32 | 32 | */ |
| 33 | 33 | function give_get_templates_url() { |
| 34 | - return GIVE_PLUGIN_URL . 'templates'; |
|
| 34 | + return GIVE_PLUGIN_URL.'templates'; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -44,24 +44,24 @@ discard block |
||
| 44 | 44 | * @param string $template_path Template file path. Default is empty. |
| 45 | 45 | * @param string $default_path Default path. Default is empty. |
| 46 | 46 | */ |
| 47 | -function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 48 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
| 49 | - extract( $args ); |
|
| 47 | +function give_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
| 48 | + if ( ! empty($args) && is_array($args)) { |
|
| 49 | + extract($args); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | $template_names = "{$template_name}.php"; |
| 53 | 53 | |
| 54 | - $located = give_get_locate_template( $template_names, $template_path, $default_path ); |
|
| 54 | + $located = give_get_locate_template($template_names, $template_path, $default_path); |
|
| 55 | 55 | |
| 56 | - if ( ! file_exists( $located ) ) { |
|
| 56 | + if ( ! file_exists($located)) { |
|
| 57 | 57 | /* translators: %s: the template */ |
| 58 | - Give()->notices->print_frontend_notice( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true ); |
|
| 58 | + Give()->notices->print_frontend_notice(sprintf(__('The %s template was not found.', 'give'), $located), true); |
|
| 59 | 59 | |
| 60 | 60 | return; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // Allow 3rd party plugin filter template file from their plugin. |
| 64 | - $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
| 64 | + $located = apply_filters('give_get_template', $located, $template_name, $args, $template_path, $default_path); |
|
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | 67 | * Fires in give template, before the file is included. |
@@ -75,9 +75,9 @@ discard block |
||
| 75 | 75 | * @param string $located Template file filter by 3rd party plugin. |
| 76 | 76 | * @param array $args Passed arguments. |
| 77 | 77 | */ |
| 78 | - do_action( 'give_before_template_part', $template_name, $template_path, $located, $args ); |
|
| 78 | + do_action('give_before_template_part', $template_name, $template_path, $located, $args); |
|
| 79 | 79 | |
| 80 | - include( $located ); |
|
| 80 | + include($located); |
|
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | 83 | * Fires in give template, after the file is included. |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * @param string $located Template file filter by 3rd party plugin. |
| 92 | 92 | * @param array $args Passed arguments. |
| 93 | 93 | */ |
| 94 | - do_action( 'give_after_template_part', $template_name, $template_path, $located, $args ); |
|
| 94 | + do_action('give_after_template_part', $template_name, $template_path, $located, $args); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * |
| 108 | 108 | * @return string |
| 109 | 109 | */ |
| 110 | -function give_get_template_part( $slug, $name = null, $load = true ) { |
|
| 110 | +function give_get_template_part($slug, $name = null, $load = true) { |
|
| 111 | 111 | |
| 112 | 112 | /** |
| 113 | 113 | * Fires in give template part, before the template part is retrieved. |
@@ -119,20 +119,20 @@ discard block |
||
| 119 | 119 | * @param string $slug Template part file slug {slug}.php. |
| 120 | 120 | * @param string $name Template part file name {slug}-{name}.php. |
| 121 | 121 | */ |
| 122 | - do_action( "get_template_part_{$slug}", $slug, $name ); |
|
| 122 | + do_action("get_template_part_{$slug}", $slug, $name); |
|
| 123 | 123 | |
| 124 | 124 | // Setup possible parts |
| 125 | 125 | $templates = array(); |
| 126 | - if ( isset( $name ) ) { |
|
| 127 | - $templates[] = $slug . '-' . $name . '.php'; |
|
| 126 | + if (isset($name)) { |
|
| 127 | + $templates[] = $slug.'-'.$name.'.php'; |
|
| 128 | 128 | } |
| 129 | - $templates[] = $slug . '.php'; |
|
| 129 | + $templates[] = $slug.'.php'; |
|
| 130 | 130 | |
| 131 | 131 | // Allow template parts to be filtered |
| 132 | - $templates = apply_filters( 'give_get_template_part', $templates, $slug, $name ); |
|
| 132 | + $templates = apply_filters('give_get_template_part', $templates, $slug, $name); |
|
| 133 | 133 | |
| 134 | 134 | // Return the part that is found |
| 135 | - return give_locate_template( $templates, $load, false ); |
|
| 135 | + return give_locate_template($templates, $load, false); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
@@ -153,37 +153,37 @@ discard block |
||
| 153 | 153 | * |
| 154 | 154 | * @return string The template filename if one is located. |
| 155 | 155 | */ |
| 156 | -function give_locate_template( $template_names, $load = false, $require_once = true ) { |
|
| 156 | +function give_locate_template($template_names, $load = false, $require_once = true) { |
|
| 157 | 157 | // No file found yet |
| 158 | 158 | $located = false; |
| 159 | 159 | |
| 160 | 160 | // Try to find a template file |
| 161 | - foreach ( (array) $template_names as $template_name ) { |
|
| 161 | + foreach ((array) $template_names as $template_name) { |
|
| 162 | 162 | |
| 163 | 163 | // Continue if template is empty |
| 164 | - if ( empty( $template_name ) ) { |
|
| 164 | + if (empty($template_name)) { |
|
| 165 | 165 | continue; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | // Trim off any slashes from the template name |
| 169 | - $template_name = ltrim( $template_name, '/' ); |
|
| 169 | + $template_name = ltrim($template_name, '/'); |
|
| 170 | 170 | |
| 171 | 171 | // try locating this template file by looping through the template paths |
| 172 | - foreach ( give_get_theme_template_paths() as $template_path ) { |
|
| 172 | + foreach (give_get_theme_template_paths() as $template_path) { |
|
| 173 | 173 | |
| 174 | - if ( file_exists( $template_path . $template_name ) ) { |
|
| 175 | - $located = $template_path . $template_name; |
|
| 174 | + if (file_exists($template_path.$template_name)) { |
|
| 175 | + $located = $template_path.$template_name; |
|
| 176 | 176 | break; |
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - if ( $located ) { |
|
| 180 | + if ($located) { |
|
| 181 | 181 | break; |
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - if ( ( true == $load ) && ! empty( $located ) ) { |
|
| 186 | - load_template( $located, $require_once ); |
|
| 185 | + if ((true == $load) && ! empty($located)) { |
|
| 186 | + load_template($located, $require_once); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | return $located; |
@@ -207,26 +207,26 @@ discard block |
||
| 207 | 207 | * |
| 208 | 208 | * @return string |
| 209 | 209 | */ |
| 210 | -function give_get_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
| 211 | - if ( ! $template_path ) { |
|
| 212 | - $template_path = give_get_theme_template_dir_name() . '/'; |
|
| 210 | +function give_get_locate_template($template_name, $template_path = '', $default_path = '') { |
|
| 211 | + if ( ! $template_path) { |
|
| 212 | + $template_path = give_get_theme_template_dir_name().'/'; |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - if ( ! $default_path ) { |
|
| 216 | - $default_path = GIVE_PLUGIN_DIR . 'templates/'; |
|
| 215 | + if ( ! $default_path) { |
|
| 216 | + $default_path = GIVE_PLUGIN_DIR.'templates/'; |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | // Look within passed path within the theme - this is priority. |
| 220 | 220 | $template = locate_template( |
| 221 | 221 | array( |
| 222 | - trailingslashit( $template_path ) . $template_name, |
|
| 222 | + trailingslashit($template_path).$template_name, |
|
| 223 | 223 | $template_name, |
| 224 | 224 | ) |
| 225 | 225 | ); |
| 226 | 226 | |
| 227 | 227 | // Get default template/ |
| 228 | - if ( ! $template ) { |
|
| 229 | - $template = $default_path . $template_name; |
|
| 228 | + if ( ! $template) { |
|
| 229 | + $template = $default_path.$template_name; |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | * |
| 235 | 235 | * @since 2.0.3 |
| 236 | 236 | */ |
| 237 | - return apply_filters( 'give_get_locate_template', $template, $template_name, $template_path ); |
|
| 237 | + return apply_filters('give_get_locate_template', $template, $template_name, $template_path); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | /** |
@@ -248,17 +248,17 @@ discard block |
||
| 248 | 248 | $template_dir = give_get_theme_template_dir_name(); |
| 249 | 249 | |
| 250 | 250 | $file_paths = array( |
| 251 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 252 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 251 | + 1 => trailingslashit(get_stylesheet_directory()).$template_dir, |
|
| 252 | + 10 => trailingslashit(get_template_directory()).$template_dir, |
|
| 253 | 253 | 100 => give_get_templates_dir(), |
| 254 | 254 | ); |
| 255 | 255 | |
| 256 | - $file_paths = apply_filters( 'give_template_paths', $file_paths ); |
|
| 256 | + $file_paths = apply_filters('give_template_paths', $file_paths); |
|
| 257 | 257 | |
| 258 | 258 | // sort the file paths based on priority |
| 259 | - ksort( $file_paths, SORT_NUMERIC ); |
|
| 259 | + ksort($file_paths, SORT_NUMERIC); |
|
| 260 | 260 | |
| 261 | - return array_map( 'trailingslashit', $file_paths ); |
|
| 261 | + return array_map('trailingslashit', $file_paths); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | /** |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | * @return string |
| 271 | 271 | */ |
| 272 | 272 | function give_get_theme_template_dir_name() { |
| 273 | - return trailingslashit( apply_filters( 'give_templates_dir', 'give' ) ); |
|
| 273 | + return trailingslashit(apply_filters('give_templates_dir', 'give')); |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | /** |
@@ -280,10 +280,10 @@ discard block |
||
| 280 | 280 | * @return void |
| 281 | 281 | */ |
| 282 | 282 | function give_version_in_header() { |
| 283 | - echo '<meta name="generator" content="Give v' . GIVE_VERSION . '" />' . "\n"; |
|
| 283 | + echo '<meta name="generator" content="Give v'.GIVE_VERSION.'" />'."\n"; |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | -add_action( 'wp_head', 'give_version_in_header' ); |
|
| 286 | +add_action('wp_head', 'give_version_in_header'); |
|
| 287 | 287 | |
| 288 | 288 | /** |
| 289 | 289 | * Determines if we're currently on the Donations History page. |
@@ -293,9 +293,9 @@ discard block |
||
| 293 | 293 | */ |
| 294 | 294 | function give_is_donation_history_page() { |
| 295 | 295 | |
| 296 | - $ret = is_page( give_get_option( 'history_page' ) ); |
|
| 296 | + $ret = is_page(give_get_option('history_page')); |
|
| 297 | 297 | |
| 298 | - return apply_filters( 'give_is_donation_history_page', $ret ); |
|
| 298 | + return apply_filters('give_is_donation_history_page', $ret); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | /** |
@@ -307,25 +307,25 @@ discard block |
||
| 307 | 307 | * |
| 308 | 308 | * @return array Modified array of classes |
| 309 | 309 | */ |
| 310 | -function give_add_body_classes( $class ) { |
|
| 310 | +function give_add_body_classes($class) { |
|
| 311 | 311 | $classes = (array) $class; |
| 312 | 312 | |
| 313 | - if ( give_is_success_page() ) { |
|
| 313 | + if (give_is_success_page()) { |
|
| 314 | 314 | $classes[] = 'give-success'; |
| 315 | 315 | $classes[] = 'give-page'; |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - if ( give_is_failed_transaction_page() ) { |
|
| 318 | + if (give_is_failed_transaction_page()) { |
|
| 319 | 319 | $classes[] = 'give-failed-transaction'; |
| 320 | 320 | $classes[] = 'give-page'; |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | - if ( give_is_donation_history_page() ) { |
|
| 323 | + if (give_is_donation_history_page()) { |
|
| 324 | 324 | $classes[] = 'give-donation-history'; |
| 325 | 325 | $classes[] = 'give-page'; |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - if ( give_is_test_mode() ) { |
|
| 328 | + if (give_is_test_mode()) { |
|
| 329 | 329 | $classes[] = 'give-test-mode'; |
| 330 | 330 | $classes[] = 'give-page'; |
| 331 | 331 | } |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | /* @var WP_Theme $current_theme */ |
| 335 | 335 | $current_theme = wp_get_theme(); |
| 336 | 336 | |
| 337 | - switch ( $current_theme->get_template() ) { |
|
| 337 | + switch ($current_theme->get_template()) { |
|
| 338 | 338 | |
| 339 | 339 | case 'Divi': |
| 340 | 340 | $classes[] = 'give-divi'; |
@@ -351,10 +351,10 @@ discard block |
||
| 351 | 351 | |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - return array_unique( $classes ); |
|
| 354 | + return array_unique($classes); |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | -add_filter( 'body_class', 'give_add_body_classes' ); |
|
| 357 | +add_filter('body_class', 'give_add_body_classes'); |
|
| 358 | 358 | |
| 359 | 359 | |
| 360 | 360 | /** |
@@ -370,22 +370,22 @@ discard block |
||
| 370 | 370 | * |
| 371 | 371 | * @return array |
| 372 | 372 | */ |
| 373 | -function give_add_post_class( $classes, $class = '', $post_id = '' ) { |
|
| 374 | - if ( ! $post_id || 'give_forms' !== get_post_type( $post_id ) ) { |
|
| 373 | +function give_add_post_class($classes, $class = '', $post_id = '') { |
|
| 374 | + if ( ! $post_id || 'give_forms' !== get_post_type($post_id)) { |
|
| 375 | 375 | return $classes; |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | //@TODO: Add classes for custom taxonomy and form configurations (multi vs single donations, etc). |
| 379 | 379 | |
| 380 | - if ( false !== ( $key = array_search( 'hentry', $classes ) ) ) { |
|
| 381 | - unset( $classes[ $key ] ); |
|
| 380 | + if (false !== ($key = array_search('hentry', $classes))) { |
|
| 381 | + unset($classes[$key]); |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | return $classes; |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | |
| 388 | -add_filter( 'post_class', 'give_add_post_class', 20, 3 ); |
|
| 388 | +add_filter('post_class', 'give_add_post_class', 20, 3); |
|
| 389 | 389 | |
| 390 | 390 | /** |
| 391 | 391 | * Get the placeholder image URL for forms etc |
@@ -395,74 +395,74 @@ discard block |
||
| 395 | 395 | */ |
| 396 | 396 | function give_get_placeholder_img_src() { |
| 397 | 397 | |
| 398 | - $placeholder_url = '//placehold.it/600x600&text=' . urlencode( esc_attr__( 'Give Placeholder Image', 'give' ) ); |
|
| 398 | + $placeholder_url = '//placehold.it/600x600&text='.urlencode(esc_attr__('Give Placeholder Image', 'give')); |
|
| 399 | 399 | |
| 400 | - return apply_filters( 'give_placeholder_img_src', $placeholder_url ); |
|
| 400 | + return apply_filters('give_placeholder_img_src', $placeholder_url); |
|
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | |
| 404 | 404 | /** |
| 405 | 405 | * Global |
| 406 | 406 | */ |
| 407 | -if ( ! function_exists( 'give_output_content_wrapper' ) ) { |
|
| 407 | +if ( ! function_exists('give_output_content_wrapper')) { |
|
| 408 | 408 | |
| 409 | 409 | /** |
| 410 | 410 | * Output the start of the page wrapper. |
| 411 | 411 | */ |
| 412 | 412 | function give_output_content_wrapper() { |
| 413 | - give_get_template_part( 'global/wrapper-start' ); |
|
| 413 | + give_get_template_part('global/wrapper-start'); |
|
| 414 | 414 | } |
| 415 | 415 | } |
| 416 | -if ( ! function_exists( 'give_output_content_wrapper_end' ) ) { |
|
| 416 | +if ( ! function_exists('give_output_content_wrapper_end')) { |
|
| 417 | 417 | |
| 418 | 418 | /** |
| 419 | 419 | * Output the end of the page wrapper. |
| 420 | 420 | */ |
| 421 | 421 | function give_output_content_wrapper_end() { |
| 422 | - give_get_template_part( 'global/wrapper-end' ); |
|
| 422 | + give_get_template_part('global/wrapper-end'); |
|
| 423 | 423 | } |
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | /** |
| 427 | 427 | * Single Give Form |
| 428 | 428 | */ |
| 429 | -if ( ! function_exists( 'give_left_sidebar_pre_wrap' ) ) { |
|
| 429 | +if ( ! function_exists('give_left_sidebar_pre_wrap')) { |
|
| 430 | 430 | function give_left_sidebar_pre_wrap() { |
| 431 | - echo apply_filters( 'give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">' ); |
|
| 431 | + echo apply_filters('give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">'); |
|
| 432 | 432 | } |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | -if ( ! function_exists( 'give_left_sidebar_post_wrap' ) ) { |
|
| 435 | +if ( ! function_exists('give_left_sidebar_post_wrap')) { |
|
| 436 | 436 | function give_left_sidebar_post_wrap() { |
| 437 | - echo apply_filters( 'give_left_sidebar_post_wrap', '</div>' ); |
|
| 437 | + echo apply_filters('give_left_sidebar_post_wrap', '</div>'); |
|
| 438 | 438 | } |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | -if ( ! function_exists( 'give_get_forms_sidebar' ) ) { |
|
| 441 | +if ( ! function_exists('give_get_forms_sidebar')) { |
|
| 442 | 442 | function give_get_forms_sidebar() { |
| 443 | - give_get_template_part( 'single-give-form/sidebar' ); |
|
| 443 | + give_get_template_part('single-give-form/sidebar'); |
|
| 444 | 444 | } |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | -if ( ! function_exists( 'give_show_form_images' ) ) { |
|
| 447 | +if ( ! function_exists('give_show_form_images')) { |
|
| 448 | 448 | |
| 449 | 449 | /** |
| 450 | 450 | * Output the donation form featured image. |
| 451 | 451 | */ |
| 452 | 452 | function give_show_form_images() { |
| 453 | - if ( give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) { |
|
| 454 | - give_get_template_part( 'single-give-form/featured-image' ); |
|
| 453 | + if (give_is_setting_enabled(give_get_option('form_featured_img'))) { |
|
| 454 | + give_get_template_part('single-give-form/featured-image'); |
|
| 455 | 455 | } |
| 456 | 456 | } |
| 457 | 457 | } |
| 458 | 458 | |
| 459 | -if ( ! function_exists( 'give_template_single_title' ) ) { |
|
| 459 | +if ( ! function_exists('give_template_single_title')) { |
|
| 460 | 460 | |
| 461 | 461 | /** |
| 462 | 462 | * Output the form title. |
| 463 | 463 | */ |
| 464 | 464 | function give_template_single_title() { |
| 465 | - give_get_template_part( 'single-give-form/title' ); |
|
| 465 | + give_get_template_part('single-give-form/title'); |
|
| 466 | 466 | } |
| 467 | 467 | } |
| 468 | 468 | |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | * Conditional Functions |
| 471 | 471 | */ |
| 472 | 472 | |
| 473 | -if ( ! function_exists( 'is_give_form' ) ) { |
|
| 473 | +if ( ! function_exists('is_give_form')) { |
|
| 474 | 474 | |
| 475 | 475 | /** |
| 476 | 476 | * is_give_form |
@@ -482,11 +482,11 @@ discard block |
||
| 482 | 482 | * @return bool |
| 483 | 483 | */ |
| 484 | 484 | function is_give_form() { |
| 485 | - return is_singular( array( 'give_form' ) ); |
|
| 485 | + return is_singular(array('give_form')); |
|
| 486 | 486 | } |
| 487 | 487 | } |
| 488 | 488 | |
| 489 | -if ( ! function_exists( 'is_give_category' ) ) { |
|
| 489 | +if ( ! function_exists('is_give_category')) { |
|
| 490 | 490 | |
| 491 | 491 | /** |
| 492 | 492 | * is_give_category |
@@ -501,12 +501,12 @@ discard block |
||
| 501 | 501 | * |
| 502 | 502 | * @return bool |
| 503 | 503 | */ |
| 504 | - function is_give_category( $term = '' ) { |
|
| 505 | - return is_tax( 'give_forms_category', $term ); |
|
| 504 | + function is_give_category($term = '') { |
|
| 505 | + return is_tax('give_forms_category', $term); |
|
| 506 | 506 | } |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | -if ( ! function_exists( 'is_give_tag' ) ) { |
|
| 509 | +if ( ! function_exists('is_give_tag')) { |
|
| 510 | 510 | |
| 511 | 511 | /** |
| 512 | 512 | * is_give_tag |
@@ -521,12 +521,12 @@ discard block |
||
| 521 | 521 | * |
| 522 | 522 | * @return bool |
| 523 | 523 | */ |
| 524 | - function is_give_tag( $term = '' ) { |
|
| 525 | - return is_tax( 'give_forms_tag', $term ); |
|
| 524 | + function is_give_tag($term = '') { |
|
| 525 | + return is_tax('give_forms_tag', $term); |
|
| 526 | 526 | } |
| 527 | 527 | } |
| 528 | 528 | |
| 529 | -if ( ! function_exists( 'is_give_taxonomy' ) ) { |
|
| 529 | +if ( ! function_exists('is_give_taxonomy')) { |
|
| 530 | 530 | |
| 531 | 531 | /** |
| 532 | 532 | * is_give_taxonomy |
@@ -538,6 +538,6 @@ discard block |
||
| 538 | 538 | * @return bool |
| 539 | 539 | */ |
| 540 | 540 | function is_give_taxonomy() { |
| 541 | - return is_tax( get_object_taxonomies( 'give_form' ) ); |
|
| 541 | + return is_tax(get_object_taxonomies('give_form')); |
|
| 542 | 542 | } |
| 543 | 543 | } |
@@ -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,41 +23,41 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return string|bool |
| 25 | 25 | */ |
| 26 | -function give_donation_history( $atts ) { |
|
| 26 | +function give_donation_history($atts) { |
|
| 27 | 27 | |
| 28 | - $donation_history_args = shortcode_atts( array( |
|
| 28 | + $donation_history_args = shortcode_atts(array( |
|
| 29 | 29 | 'id' => true, |
| 30 | 30 | 'date' => true, |
| 31 | 31 | 'donor' => false, |
| 32 | 32 | 'amount' => true, |
| 33 | 33 | 'status' => false, |
| 34 | 34 | 'payment_method' => false, |
| 35 | - ), $atts, 'donation_history' ); |
|
| 35 | + ), $atts, 'donation_history'); |
|
| 36 | 36 | |
| 37 | 37 | // Always show receipt link. |
| 38 | 38 | $donation_history_args['details'] = true; |
| 39 | 39 | |
| 40 | 40 | // Set Donation History Shortcode Arguments in session variable. |
| 41 | - Give()->session->set( 'give_donation_history_args', $donation_history_args ); |
|
| 41 | + Give()->session->set('give_donation_history_args', $donation_history_args); |
|
| 42 | 42 | |
| 43 | 43 | // If payment_key query arg exists, return receipt instead of donation history. |
| 44 | - if ( isset( $_GET['payment_key'] ) ) { |
|
| 44 | + if (isset($_GET['payment_key'])) { |
|
| 45 | 45 | ob_start(); |
| 46 | 46 | |
| 47 | - echo give_receipt_shortcode( array() ); |
|
| 47 | + echo give_receipt_shortcode(array()); |
|
| 48 | 48 | |
| 49 | 49 | // Display donation history link only if Receipt Access Session is available. |
| 50 | - if ( give_get_receipt_session() ) { |
|
| 50 | + if (give_get_receipt_session()) { |
|
| 51 | 51 | echo sprintf( |
| 52 | 52 | '<a href="%s">%s</a>', |
| 53 | - esc_url( give_get_history_page_uri() ), |
|
| 54 | - __( '« Return to All Donations', 'give' ) |
|
| 53 | + esc_url(give_get_history_page_uri()), |
|
| 54 | + __('« Return to All Donations', 'give') |
|
| 55 | 55 | ); |
| 56 | 56 | } |
| 57 | 57 | return ob_get_clean(); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - $email_access = give_get_option( 'email_access' ); |
|
| 60 | + $email_access = give_get_option('email_access'); |
|
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * Determine access |
@@ -68,31 +68,31 @@ discard block |
||
| 68 | 68 | if ( |
| 69 | 69 | is_user_logged_in() || |
| 70 | 70 | false !== Give()->session->get_session_expiration() || |
| 71 | - ( give_is_setting_enabled( $email_access ) && Give()->email_access->token_exists ) || |
|
| 71 | + (give_is_setting_enabled($email_access) && Give()->email_access->token_exists) || |
|
| 72 | 72 | true === give_get_history_session() |
| 73 | 73 | ) { |
| 74 | 74 | ob_start(); |
| 75 | - give_get_template_part( 'history', 'donations' ); |
|
| 75 | + give_get_template_part('history', 'donations'); |
|
| 76 | 76 | |
| 77 | 77 | return ob_get_clean(); |
| 78 | 78 | |
| 79 | - } elseif ( give_is_setting_enabled( $email_access ) ) { |
|
| 79 | + } elseif (give_is_setting_enabled($email_access)) { |
|
| 80 | 80 | // Is Email-based access enabled? |
| 81 | 81 | ob_start(); |
| 82 | - give_get_template_part( 'email', 'login-form' ); |
|
| 82 | + give_get_template_part('email', 'login-form'); |
|
| 83 | 83 | |
| 84 | 84 | return ob_get_clean(); |
| 85 | 85 | |
| 86 | 86 | } else { |
| 87 | 87 | |
| 88 | - $output = apply_filters( 'give_donation_history_nonuser_message', Give()->notices->print_frontend_notice( __( 'You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give' ), false ) ); |
|
| 89 | - $output .= do_shortcode( '[give_login]' ); |
|
| 88 | + $output = apply_filters('give_donation_history_nonuser_message', Give()->notices->print_frontend_notice(__('You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give'), false)); |
|
| 89 | + $output .= do_shortcode('[give_login]'); |
|
| 90 | 90 | |
| 91 | 91 | return $output; |
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | -add_shortcode( 'donation_history', 'give_donation_history' ); |
|
| 95 | +add_shortcode('donation_history', 'give_donation_history'); |
|
| 96 | 96 | |
| 97 | 97 | /** |
| 98 | 98 | * Donation Form Shortcode |
@@ -105,8 +105,8 @@ discard block |
||
| 105 | 105 | * |
| 106 | 106 | * @return string |
| 107 | 107 | */ |
| 108 | -function give_form_shortcode( $atts ) { |
|
| 109 | - $atts = shortcode_atts( array( |
|
| 108 | +function give_form_shortcode($atts) { |
|
| 109 | + $atts = shortcode_atts(array( |
|
| 110 | 110 | 'id' => '', |
| 111 | 111 | 'show_title' => true, |
| 112 | 112 | 'show_goal' => true, |
@@ -114,21 +114,21 @@ discard block |
||
| 114 | 114 | 'float_labels' => '', |
| 115 | 115 | 'display_style' => '', |
| 116 | 116 | 'continue_button_title' => '', |
| 117 | - ), $atts, 'give_form' ); |
|
| 117 | + ), $atts, 'give_form'); |
|
| 118 | 118 | |
| 119 | 119 | // Convert string to bool. |
| 120 | - $atts['show_title'] = filter_var( $atts['show_title'], FILTER_VALIDATE_BOOLEAN ); |
|
| 121 | - $atts['show_goal'] = filter_var( $atts['show_goal'], FILTER_VALIDATE_BOOLEAN ); |
|
| 120 | + $atts['show_title'] = filter_var($atts['show_title'], FILTER_VALIDATE_BOOLEAN); |
|
| 121 | + $atts['show_goal'] = filter_var($atts['show_goal'], FILTER_VALIDATE_BOOLEAN); |
|
| 122 | 122 | |
| 123 | 123 | // get the Give Form |
| 124 | 124 | ob_start(); |
| 125 | - give_get_donation_form( $atts ); |
|
| 125 | + give_get_donation_form($atts); |
|
| 126 | 126 | $final_output = ob_get_clean(); |
| 127 | 127 | |
| 128 | - return apply_filters( 'give_donate_form', $final_output, $atts ); |
|
| 128 | + return apply_filters('give_donate_form', $final_output, $atts); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | -add_shortcode( 'give_form', 'give_form_shortcode' ); |
|
| 131 | +add_shortcode('give_form', 'give_form_shortcode'); |
|
| 132 | 132 | |
| 133 | 133 | /** |
| 134 | 134 | * Donation Form Goal Shortcode. |
@@ -141,36 +141,36 @@ discard block |
||
| 141 | 141 | * |
| 142 | 142 | * @return string |
| 143 | 143 | */ |
| 144 | -function give_goal_shortcode( $atts ) { |
|
| 145 | - $atts = shortcode_atts( array( |
|
| 144 | +function give_goal_shortcode($atts) { |
|
| 145 | + $atts = shortcode_atts(array( |
|
| 146 | 146 | 'id' => '', |
| 147 | 147 | 'show_text' => true, |
| 148 | 148 | 'show_bar' => true, |
| 149 | - ), $atts, 'give_goal' ); |
|
| 149 | + ), $atts, 'give_goal'); |
|
| 150 | 150 | |
| 151 | 151 | // get the Give Form. |
| 152 | 152 | ob_start(); |
| 153 | 153 | |
| 154 | 154 | // Sanity check 1: ensure there is an ID Provided. |
| 155 | - if ( empty( $atts['id'] ) ) { |
|
| 156 | - Give()->notices->print_frontend_notice( __( 'The shortcode is missing Donation Form ID attribute.', 'give' ), true ); |
|
| 155 | + if (empty($atts['id'])) { |
|
| 156 | + Give()->notices->print_frontend_notice(__('The shortcode is missing Donation Form ID attribute.', 'give'), true); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | // Sanity check 2: Check the form even has Goals enabled. |
| 160 | - if ( ! give_is_setting_enabled( give_get_meta( $atts['id'], '_give_goal_option', true ) ) ) { |
|
| 160 | + if ( ! give_is_setting_enabled(give_get_meta($atts['id'], '_give_goal_option', true))) { |
|
| 161 | 161 | |
| 162 | - Give()->notices->print_frontend_notice( __( 'The form does not have Goals enabled.', 'give' ), true ); |
|
| 162 | + Give()->notices->print_frontend_notice(__('The form does not have Goals enabled.', 'give'), true); |
|
| 163 | 163 | } else { |
| 164 | 164 | // Passed all sanity checks: output Goal. |
| 165 | - give_show_goal_progress( $atts['id'], $atts ); |
|
| 165 | + give_show_goal_progress($atts['id'], $atts); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | $final_output = ob_get_clean(); |
| 169 | 169 | |
| 170 | - return apply_filters( 'give_goal_shortcode_output', $final_output, $atts ); |
|
| 170 | + return apply_filters('give_goal_shortcode_output', $final_output, $atts); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | -add_shortcode( 'give_goal', 'give_goal_shortcode' ); |
|
| 173 | +add_shortcode('give_goal', 'give_goal_shortcode'); |
|
| 174 | 174 | |
| 175 | 175 | |
| 176 | 176 | /** |
@@ -187,22 +187,22 @@ discard block |
||
| 187 | 187 | * |
| 188 | 188 | * @return string |
| 189 | 189 | */ |
| 190 | -function give_login_form_shortcode( $atts ) { |
|
| 190 | +function give_login_form_shortcode($atts) { |
|
| 191 | 191 | |
| 192 | - $atts = shortcode_atts( array( |
|
| 192 | + $atts = shortcode_atts(array( |
|
| 193 | 193 | // Add backward compatibility for redirect attribute. |
| 194 | 194 | 'redirect' => '', |
| 195 | 195 | 'login-redirect' => '', |
| 196 | 196 | 'logout-redirect' => '', |
| 197 | - ), $atts, 'give_login' ); |
|
| 197 | + ), $atts, 'give_login'); |
|
| 198 | 198 | |
| 199 | 199 | // 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. |
| 200 | - $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect'] ) ? $atts['redirect'] : '' ); |
|
| 200 | + $atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : ''); |
|
| 201 | 201 | |
| 202 | - return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] ); |
|
| 202 | + return give_login_form($atts['login-redirect'], $atts['logout-redirect']); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | -add_shortcode( 'give_login', 'give_login_form_shortcode' ); |
|
| 205 | +add_shortcode('give_login', 'give_login_form_shortcode'); |
|
| 206 | 206 | |
| 207 | 207 | /** |
| 208 | 208 | * Register Shortcode. |
@@ -217,15 +217,15 @@ discard block |
||
| 217 | 217 | * |
| 218 | 218 | * @return string |
| 219 | 219 | */ |
| 220 | -function give_register_form_shortcode( $atts ) { |
|
| 221 | - $atts = shortcode_atts( array( |
|
| 220 | +function give_register_form_shortcode($atts) { |
|
| 221 | + $atts = shortcode_atts(array( |
|
| 222 | 222 | 'redirect' => '', |
| 223 | - ), $atts, 'give_register' ); |
|
| 223 | + ), $atts, 'give_register'); |
|
| 224 | 224 | |
| 225 | - return give_register_form( $atts['redirect'] ); |
|
| 225 | + return give_register_form($atts['redirect']); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | -add_shortcode( 'give_register', 'give_register_form_shortcode' ); |
|
| 228 | +add_shortcode('give_register', 'give_register_form_shortcode'); |
|
| 229 | 229 | |
| 230 | 230 | /** |
| 231 | 231 | * Receipt Shortcode. |
@@ -238,12 +238,12 @@ discard block |
||
| 238 | 238 | * |
| 239 | 239 | * @return string |
| 240 | 240 | */ |
| 241 | -function give_receipt_shortcode( $atts ) { |
|
| 241 | +function give_receipt_shortcode($atts) { |
|
| 242 | 242 | |
| 243 | 243 | global $give_receipt_args; |
| 244 | 244 | |
| 245 | - $give_receipt_args = shortcode_atts( array( |
|
| 246 | - 'error' => __( 'You are missing the payment key to view this donation receipt.', 'give' ), |
|
| 245 | + $give_receipt_args = shortcode_atts(array( |
|
| 246 | + 'error' => __('You are missing the payment key to view this donation receipt.', 'give'), |
|
| 247 | 247 | 'price' => true, |
| 248 | 248 | 'donor' => true, |
| 249 | 249 | 'date' => true, |
@@ -252,49 +252,49 @@ discard block |
||
| 252 | 252 | 'payment_id' => true, |
| 253 | 253 | 'payment_status' => false, |
| 254 | 254 | 'status_notice' => true, |
| 255 | - ), $atts, 'give_receipt' ); |
|
| 255 | + ), $atts, 'give_receipt'); |
|
| 256 | 256 | |
| 257 | 257 | // set $session var |
| 258 | 258 | $session = give_get_purchase_session(); |
| 259 | 259 | |
| 260 | 260 | // set payment key var |
| 261 | - if ( isset( $_GET['payment_key'] ) ) { |
|
| 262 | - $payment_key = urldecode( $_GET['payment_key'] ); |
|
| 263 | - } elseif ( $session ) { |
|
| 261 | + if (isset($_GET['payment_key'])) { |
|
| 262 | + $payment_key = urldecode($_GET['payment_key']); |
|
| 263 | + } elseif ($session) { |
|
| 264 | 264 | $payment_key = $session['purchase_key']; |
| 265 | - } elseif ( $give_receipt_args['payment_key'] ) { |
|
| 265 | + } elseif ($give_receipt_args['payment_key']) { |
|
| 266 | 266 | $payment_key = $give_receipt_args['payment_key']; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - $email_access = give_get_option( 'email_access' ); |
|
| 269 | + $email_access = give_get_option('email_access'); |
|
| 270 | 270 | |
| 271 | 271 | // No payment_key found & Email Access is Turned on. |
| 272 | - if ( ! isset( $payment_key ) && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) { |
|
| 272 | + if ( ! isset($payment_key) && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) { |
|
| 273 | 273 | |
| 274 | 274 | ob_start(); |
| 275 | 275 | |
| 276 | - give_get_template_part( 'email-login-form' ); |
|
| 276 | + give_get_template_part('email-login-form'); |
|
| 277 | 277 | |
| 278 | 278 | return ob_get_clean(); |
| 279 | 279 | |
| 280 | - } elseif ( ! isset( $payment_key ) ) { |
|
| 280 | + } elseif ( ! isset($payment_key)) { |
|
| 281 | 281 | |
| 282 | - return Give()->notices->print_frontend_notice( $give_receipt_args['error'], false, 'error' ); |
|
| 282 | + return Give()->notices->print_frontend_notice($give_receipt_args['error'], false, 'error'); |
|
| 283 | 283 | |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - $user_can_view = give_can_view_receipt( $payment_key ); |
|
| 286 | + $user_can_view = give_can_view_receipt($payment_key); |
|
| 287 | 287 | |
| 288 | 288 | // Key was provided, but user is logged out. Offer them the ability to login and view the receipt. |
| 289 | - if ( ! $user_can_view && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) { |
|
| 289 | + if ( ! $user_can_view && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) { |
|
| 290 | 290 | |
| 291 | 291 | ob_start(); |
| 292 | 292 | |
| 293 | - give_get_template_part( 'email-login-form' ); |
|
| 293 | + give_get_template_part('email-login-form'); |
|
| 294 | 294 | |
| 295 | 295 | return ob_get_clean(); |
| 296 | 296 | |
| 297 | - } elseif ( ! $user_can_view ) { |
|
| 297 | + } elseif ( ! $user_can_view) { |
|
| 298 | 298 | |
| 299 | 299 | global $give_login_redirect; |
| 300 | 300 | |
@@ -302,9 +302,9 @@ discard block |
||
| 302 | 302 | |
| 303 | 303 | ob_start(); |
| 304 | 304 | |
| 305 | - Give()->notices->print_frontend_notice( apply_filters( 'give_must_be_logged_in_error_message', __( 'You must be logged in to view this donation receipt.', 'give' ) ) ); |
|
| 305 | + Give()->notices->print_frontend_notice(apply_filters('give_must_be_logged_in_error_message', __('You must be logged in to view this donation receipt.', 'give'))); |
|
| 306 | 306 | |
| 307 | - give_get_template_part( 'shortcode', 'login' ); |
|
| 307 | + give_get_template_part('shortcode', 'login'); |
|
| 308 | 308 | |
| 309 | 309 | $login_form = ob_get_clean(); |
| 310 | 310 | |
@@ -318,20 +318,20 @@ discard block |
||
| 318 | 318 | * or if user is logged out and donation was made as a guest, the donation session is checked for |
| 319 | 319 | * or if user is logged in and the user can view sensitive shop data. |
| 320 | 320 | */ |
| 321 | - if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) { |
|
| 322 | - return Give()->notices->print_frontend_notice( $give_receipt_args['error'], false, 'error' ); |
|
| 321 | + if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) { |
|
| 322 | + return Give()->notices->print_frontend_notice($give_receipt_args['error'], false, 'error'); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | ob_start(); |
| 326 | 326 | |
| 327 | - give_get_template_part( 'shortcode', 'receipt' ); |
|
| 327 | + give_get_template_part('shortcode', 'receipt'); |
|
| 328 | 328 | |
| 329 | 329 | $display = ob_get_clean(); |
| 330 | 330 | |
| 331 | 331 | return $display; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | -add_shortcode( 'give_receipt', 'give_receipt_shortcode' ); |
|
| 334 | +add_shortcode('give_receipt', 'give_receipt_shortcode'); |
|
| 335 | 335 | |
| 336 | 336 | /** |
| 337 | 337 | * Profile Editor Shortcode. |
@@ -350,25 +350,25 @@ discard block |
||
| 350 | 350 | * |
| 351 | 351 | * @return string Output generated from the profile editor |
| 352 | 352 | */ |
| 353 | -function give_profile_editor_shortcode( $atts ) { |
|
| 353 | +function give_profile_editor_shortcode($atts) { |
|
| 354 | 354 | |
| 355 | 355 | ob_start(); |
| 356 | 356 | |
| 357 | 357 | // Restrict access to donor profile, if donor and user are disconnected. |
| 358 | - $is_donor_disconnected = get_user_meta( get_current_user_id(), '_give_is_donor_disconnected', true ); |
|
| 359 | - if ( is_user_logged_in() && $is_donor_disconnected ) { |
|
| 360 | - Give()->notices->print_frontend_notice( __( 'Your Donor and User profile are no longer connected. Please contact the site administrator.', 'give' ), true, 'error' ); |
|
| 358 | + $is_donor_disconnected = get_user_meta(get_current_user_id(), '_give_is_donor_disconnected', true); |
|
| 359 | + if (is_user_logged_in() && $is_donor_disconnected) { |
|
| 360 | + Give()->notices->print_frontend_notice(__('Your Donor and User profile are no longer connected. Please contact the site administrator.', 'give'), true, 'error'); |
|
| 361 | 361 | return false; |
| 362 | 362 | } |
| 363 | 363 | |
| 364 | - give_get_template_part( 'shortcode', 'profile-editor' ); |
|
| 364 | + give_get_template_part('shortcode', 'profile-editor'); |
|
| 365 | 365 | |
| 366 | 366 | $display = ob_get_clean(); |
| 367 | 367 | |
| 368 | 368 | return $display; |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | -add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' ); |
|
| 371 | +add_shortcode('give_profile_editor', 'give_profile_editor_shortcode'); |
|
| 372 | 372 | |
| 373 | 373 | /** |
| 374 | 374 | * Process Profile Updater Form. |
@@ -381,29 +381,29 @@ discard block |
||
| 381 | 381 | * |
| 382 | 382 | * @return bool |
| 383 | 383 | */ |
| 384 | -function give_process_profile_editor_updates( $data ) { |
|
| 384 | +function give_process_profile_editor_updates($data) { |
|
| 385 | 385 | // Profile field change request. |
| 386 | - if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) { |
|
| 386 | + if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) { |
|
| 387 | 387 | return false; |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | // Nonce security. |
| 391 | - if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) { |
|
| 391 | + if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) { |
|
| 392 | 392 | return false; |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | $user_id = get_current_user_id(); |
| 396 | - $old_user_data = get_userdata( $user_id ); |
|
| 396 | + $old_user_data = get_userdata($user_id); |
|
| 397 | 397 | |
| 398 | 398 | /* @var Give_Donor $donor */ |
| 399 | - $donor = new Give_Donor( $user_id, true ); |
|
| 399 | + $donor = new Give_Donor($user_id, true); |
|
| 400 | 400 | |
| 401 | - $display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name; |
|
| 402 | - $first_name = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name; |
|
| 403 | - $last_name = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name; |
|
| 404 | - $email = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email; |
|
| 405 | - $password = ! empty( $data['give_new_user_pass1'] ) ? $data['give_new_user_pass1'] : ''; |
|
| 406 | - $confirm_password = ! empty( $data['give_new_user_pass2'] ) ? $data['give_new_user_pass2'] : ''; |
|
| 401 | + $display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name; |
|
| 402 | + $first_name = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name; |
|
| 403 | + $last_name = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name; |
|
| 404 | + $email = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email; |
|
| 405 | + $password = ! empty($data['give_new_user_pass1']) ? $data['give_new_user_pass1'] : ''; |
|
| 406 | + $confirm_password = ! empty($data['give_new_user_pass2']) ? $data['give_new_user_pass2'] : ''; |
|
| 407 | 407 | |
| 408 | 408 | $userdata = array( |
| 409 | 409 | 'ID' => $user_id, |
@@ -422,58 +422,58 @@ discard block |
||
| 422 | 422 | * @param int $user_id The ID of the user. |
| 423 | 423 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
| 424 | 424 | */ |
| 425 | - do_action( 'give_pre_update_user_profile', $user_id, $userdata ); |
|
| 425 | + do_action('give_pre_update_user_profile', $user_id, $userdata); |
|
| 426 | 426 | |
| 427 | 427 | // Make sure to validate first name of existing donors. |
| 428 | - if ( empty( $first_name ) ) { |
|
| 428 | + if (empty($first_name)) { |
|
| 429 | 429 | // Empty First Name. |
| 430 | - give_set_error( 'empty_first_name', __( 'Please enter your first name.', 'give' ) ); |
|
| 430 | + give_set_error('empty_first_name', __('Please enter your first name.', 'give')); |
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | // Make sure to validate passwords for existing Donors. |
| 434 | - give_validate_user_password( $password, $confirm_password ); |
|
| 434 | + give_validate_user_password($password, $confirm_password); |
|
| 435 | 435 | |
| 436 | - if ( empty( $email ) ) { |
|
| 436 | + if (empty($email)) { |
|
| 437 | 437 | // Make sure email should not be empty. |
| 438 | - give_set_error( 'email_empty', __( 'The email you entered is empty.', 'give' ) ); |
|
| 438 | + give_set_error('email_empty', __('The email you entered is empty.', 'give')); |
|
| 439 | 439 | |
| 440 | - } elseif ( ! is_email( $email ) ) { |
|
| 440 | + } elseif ( ! is_email($email)) { |
|
| 441 | 441 | // Make sure email should be valid. |
| 442 | - give_set_error( 'email_not_valid', __( 'The email you entered is not valid. Please use another', 'give' ) ); |
|
| 442 | + give_set_error('email_not_valid', __('The email you entered is not valid. Please use another', 'give')); |
|
| 443 | 443 | |
| 444 | - } elseif ( $email != $old_user_data->user_email ) { |
|
| 444 | + } elseif ($email != $old_user_data->user_email) { |
|
| 445 | 445 | // Make sure the new email doesn't belong to another user. |
| 446 | - if ( email_exists( $email ) ) { |
|
| 447 | - give_set_error( 'user_email_exists', __( 'The email you entered belongs to another user. Please use another.', 'give' ) ); |
|
| 448 | - } elseif ( Give()->donors->get_donor_by( 'email', $email ) ) { |
|
| 446 | + if (email_exists($email)) { |
|
| 447 | + give_set_error('user_email_exists', __('The email you entered belongs to another user. Please use another.', 'give')); |
|
| 448 | + } elseif (Give()->donors->get_donor_by('email', $email)) { |
|
| 449 | 449 | // Make sure the new email doesn't belong to another user. |
| 450 | - give_set_error( 'donor_email_exists', __( 'The email you entered belongs to another donor. Please use another.', 'give' ) ); |
|
| 450 | + give_set_error('donor_email_exists', __('The email you entered belongs to another donor. Please use another.', 'give')); |
|
| 451 | 451 | } |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | // Check for errors. |
| 455 | 455 | $errors = give_get_errors(); |
| 456 | 456 | |
| 457 | - if ( $errors ) { |
|
| 457 | + if ($errors) { |
|
| 458 | 458 | // Send back to the profile editor if there are errors. |
| 459 | - wp_redirect( $data['give_redirect'] ); |
|
| 459 | + wp_redirect($data['give_redirect']); |
|
| 460 | 460 | give_die(); |
| 461 | 461 | } |
| 462 | 462 | |
| 463 | 463 | // Update Donor First Name and Last Name. |
| 464 | - Give()->donors->update( $donor->id, array( |
|
| 465 | - 'name' => trim( "{$first_name} {$last_name}" ), |
|
| 466 | - ) ); |
|
| 467 | - Give()->donor_meta->update_meta( $donor->id, '_give_donor_first_name', $first_name ); |
|
| 468 | - Give()->donor_meta->update_meta( $donor->id, '_give_donor_last_name', $last_name ); |
|
| 464 | + Give()->donors->update($donor->id, array( |
|
| 465 | + 'name' => trim("{$first_name} {$last_name}"), |
|
| 466 | + )); |
|
| 467 | + Give()->donor_meta->update_meta($donor->id, '_give_donor_first_name', $first_name); |
|
| 468 | + Give()->donor_meta->update_meta($donor->id, '_give_donor_last_name', $last_name); |
|
| 469 | 469 | |
| 470 | 470 | $current_user = wp_get_current_user(); |
| 471 | 471 | |
| 472 | 472 | // Compares new values with old values to detect change in values. |
| 473 | - $email_update = ( $email !== $current_user->user_email ) ? true : false; |
|
| 474 | - $display_name_update = ( $display_name !== $current_user->display_name ) ? true : false; |
|
| 475 | - $first_name_update = ( $first_name !== $current_user->first_name ) ? true : false; |
|
| 476 | - $last_name_update = ( $last_name !== $current_user->last_name ) ? true : false; |
|
| 473 | + $email_update = ($email !== $current_user->user_email) ? true : false; |
|
| 474 | + $display_name_update = ($display_name !== $current_user->display_name) ? true : false; |
|
| 475 | + $first_name_update = ($first_name !== $current_user->first_name) ? true : false; |
|
| 476 | + $last_name_update = ($last_name !== $current_user->last_name) ? true : false; |
|
| 477 | 477 | $update_code = 0; |
| 478 | 478 | |
| 479 | 479 | /** |
@@ -481,35 +481,35 @@ discard block |
||
| 481 | 481 | * |
| 482 | 482 | * @var boolean |
| 483 | 483 | */ |
| 484 | - $profile_update = ( $email_update || $display_name_update || $first_name_update || $last_name_update ); |
|
| 484 | + $profile_update = ($email_update || $display_name_update || $first_name_update || $last_name_update); |
|
| 485 | 485 | |
| 486 | 486 | /** |
| 487 | 487 | * True if password fields are filled. |
| 488 | 488 | * |
| 489 | 489 | * @var boolean |
| 490 | 490 | */ |
| 491 | - $password_update = ( ! empty( $password ) && ! empty( $confirm_password ) ); |
|
| 491 | + $password_update = ( ! empty($password) && ! empty($confirm_password)); |
|
| 492 | 492 | |
| 493 | - if ( $profile_update ) { |
|
| 493 | + if ($profile_update) { |
|
| 494 | 494 | |
| 495 | 495 | // If only profile fields are updated. |
| 496 | 496 | $update_code = '1'; |
| 497 | 497 | |
| 498 | - if ( $password_update ) { |
|
| 498 | + if ($password_update) { |
|
| 499 | 499 | |
| 500 | 500 | // If profile fields AND password both are updated. |
| 501 | 501 | $update_code = '2'; |
| 502 | 502 | } |
| 503 | - } elseif ( $password_update ) { |
|
| 503 | + } elseif ($password_update) { |
|
| 504 | 504 | |
| 505 | 505 | // If only password is updated. |
| 506 | 506 | $update_code = '3'; |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | // Update the user. |
| 510 | - $updated = wp_update_user( $userdata ); |
|
| 510 | + $updated = wp_update_user($userdata); |
|
| 511 | 511 | |
| 512 | - if ( $updated ) { |
|
| 512 | + if ($updated) { |
|
| 513 | 513 | |
| 514 | 514 | /** |
| 515 | 515 | * Fires after updating user profile. |
@@ -519,7 +519,7 @@ discard block |
||
| 519 | 519 | * @param int $user_id The ID of the user. |
| 520 | 520 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
| 521 | 521 | */ |
| 522 | - do_action( 'give_user_profile_updated', $user_id, $userdata ); |
|
| 522 | + do_action('give_user_profile_updated', $user_id, $userdata); |
|
| 523 | 523 | |
| 524 | 524 | $profile_edit_redirect_args = array( |
| 525 | 525 | 'updated' => 'true', |
@@ -530,10 +530,10 @@ discard block |
||
| 530 | 530 | * Update codes '2' and '3' indicate a password change. |
| 531 | 531 | * If the password is changed, then logout and redirect to the same page. |
| 532 | 532 | */ |
| 533 | - if ( '2' === $update_code || '3' === $update_code ) { |
|
| 534 | - wp_logout( wp_redirect( add_query_arg( $profile_edit_redirect_args, $data['give_redirect'] ) ) ); |
|
| 533 | + if ('2' === $update_code || '3' === $update_code) { |
|
| 534 | + wp_logout(wp_redirect(add_query_arg($profile_edit_redirect_args, $data['give_redirect']))); |
|
| 535 | 535 | } else { |
| 536 | - wp_redirect( add_query_arg( $profile_edit_redirect_args, $data['give_redirect'] ) ); |
|
| 536 | + wp_redirect(add_query_arg($profile_edit_redirect_args, $data['give_redirect'])); |
|
| 537 | 537 | } |
| 538 | 538 | |
| 539 | 539 | give_die(); |
@@ -542,4 +542,4 @@ discard block |
||
| 542 | 542 | return false; |
| 543 | 543 | } |
| 544 | 544 | |
| 545 | -add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' ); |
|
| 545 | +add_action('give_edit_user_profile', 'give_process_profile_editor_updates'); |
|
@@ -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 | |
@@ -28,21 +28,21 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @return void |
| 30 | 30 | */ |
| 31 | -function give_complete_purchase( $payment_id, $new_status, $old_status ) { |
|
| 31 | +function give_complete_purchase($payment_id, $new_status, $old_status) { |
|
| 32 | 32 | |
| 33 | 33 | // Make sure that payments are only completed once. |
| 34 | - if ( $old_status == 'publish' || $old_status == 'complete' ) { |
|
| 34 | + if ($old_status == 'publish' || $old_status == 'complete') { |
|
| 35 | 35 | return; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | // Make sure the payment completion is only processed when new status is complete. |
| 39 | - if ( $new_status != 'publish' && $new_status != 'complete' ) { |
|
| 39 | + if ($new_status != 'publish' && $new_status != 'complete') { |
|
| 40 | 40 | return; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - $payment = new Give_Payment( $payment_id ); |
|
| 43 | + $payment = new Give_Payment($payment_id); |
|
| 44 | 44 | |
| 45 | - $creation_date = get_post_field( 'post_date', $payment_id, 'raw' ); |
|
| 45 | + $creation_date = get_post_field('post_date', $payment_id, 'raw'); |
|
| 46 | 46 | $payment_meta = $payment->payment_meta; |
| 47 | 47 | $completed_date = $payment->completed_date; |
| 48 | 48 | $user_info = $payment->user_info; |
@@ -58,12 +58,12 @@ discard block |
||
| 58 | 58 | * |
| 59 | 59 | * @param int $payment_id The ID of the payment. |
| 60 | 60 | */ |
| 61 | - do_action( 'give_pre_complete_donation', $payment_id ); |
|
| 61 | + do_action('give_pre_complete_donation', $payment_id); |
|
| 62 | 62 | |
| 63 | 63 | // Ensure these actions only run once, ever. |
| 64 | - if ( empty( $completed_date ) ) { |
|
| 64 | + if (empty($completed_date)) { |
|
| 65 | 65 | |
| 66 | - give_record_donation_in_log( $form_id, $payment_id, $price_id, $creation_date ); |
|
| 66 | + give_record_donation_in_log($form_id, $payment_id, $price_id, $creation_date); |
|
| 67 | 67 | |
| 68 | 68 | /** |
| 69 | 69 | * Fires after logging donation record. |
@@ -74,29 +74,29 @@ discard block |
||
| 74 | 74 | * @param int $payment_id The ID number of the payment. |
| 75 | 75 | * @param array $payment_meta The payment meta. |
| 76 | 76 | */ |
| 77 | - do_action( 'give_complete_form_donation', $form_id, $payment_id, $payment_meta ); |
|
| 77 | + do_action('give_complete_form_donation', $form_id, $payment_id, $payment_meta); |
|
| 78 | 78 | |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | // Increase the earnings for this form ID. |
| 82 | - give_increase_earnings( $form_id, $amount ); |
|
| 83 | - give_increase_donation_count( $form_id ); |
|
| 82 | + give_increase_earnings($form_id, $amount); |
|
| 83 | + give_increase_donation_count($form_id); |
|
| 84 | 84 | |
| 85 | 85 | // @todo: Refresh only range related stat cache |
| 86 | 86 | give_delete_donation_stats(); |
| 87 | 87 | |
| 88 | 88 | // Increase the donor's donation stats. |
| 89 | - $donor = new Give_Donor( $donor_id ); |
|
| 89 | + $donor = new Give_Donor($donor_id); |
|
| 90 | 90 | $donor->increase_purchase_count(); |
| 91 | - $donor->increase_value( $amount ); |
|
| 91 | + $donor->increase_value($amount); |
|
| 92 | 92 | |
| 93 | - give_increase_total_earnings( $amount ); |
|
| 93 | + give_increase_total_earnings($amount); |
|
| 94 | 94 | |
| 95 | 95 | // Ensure this action only runs once ever. |
| 96 | - if ( empty( $completed_date ) ) { |
|
| 96 | + if (empty($completed_date)) { |
|
| 97 | 97 | |
| 98 | 98 | // Save the completed date. |
| 99 | - $payment->completed_date = current_time( 'mysql' ); |
|
| 99 | + $payment->completed_date = current_time('mysql'); |
|
| 100 | 100 | $payment->save(); |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -106,12 +106,12 @@ discard block |
||
| 106 | 106 | * |
| 107 | 107 | * @param int $payment_id The ID of the payment. |
| 108 | 108 | */ |
| 109 | - do_action( 'give_complete_donation', $payment_id ); |
|
| 109 | + do_action('give_complete_donation', $payment_id); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | -add_action( 'give_update_payment_status', 'give_complete_purchase', 100, 3 ); |
|
| 114 | +add_action('give_update_payment_status', 'give_complete_purchase', 100, 3); |
|
| 115 | 115 | |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -125,20 +125,20 @@ discard block |
||
| 125 | 125 | * |
| 126 | 126 | * @return void |
| 127 | 127 | */ |
| 128 | -function give_record_status_change( $payment_id, $new_status, $old_status ) { |
|
| 128 | +function give_record_status_change($payment_id, $new_status, $old_status) { |
|
| 129 | 129 | |
| 130 | 130 | // Get the list of statuses so that status in the payment note can be translated. |
| 131 | 131 | $stati = give_get_payment_statuses(); |
| 132 | - $old_status = isset( $stati[ $old_status ] ) ? $stati[ $old_status ] : $old_status; |
|
| 133 | - $new_status = isset( $stati[ $new_status ] ) ? $stati[ $new_status ] : $new_status; |
|
| 132 | + $old_status = isset($stati[$old_status]) ? $stati[$old_status] : $old_status; |
|
| 133 | + $new_status = isset($stati[$new_status]) ? $stati[$new_status] : $new_status; |
|
| 134 | 134 | |
| 135 | 135 | // translators: 1: old status 2: new status. |
| 136 | - $status_change = sprintf( esc_html__( 'Status changed from %1$s to %2$s.', 'give' ), $old_status, $new_status ); |
|
| 136 | + $status_change = sprintf(esc_html__('Status changed from %1$s to %2$s.', 'give'), $old_status, $new_status); |
|
| 137 | 137 | |
| 138 | - give_insert_payment_note( $payment_id, $status_change ); |
|
| 138 | + give_insert_payment_note($payment_id, $status_change); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | -add_action( 'give_update_payment_status', 'give_record_status_change', 100, 3 ); |
|
| 141 | +add_action('give_update_payment_status', 'give_record_status_change', 100, 3); |
|
| 142 | 142 | |
| 143 | 143 | |
| 144 | 144 | /** |
@@ -154,25 +154,25 @@ discard block |
||
| 154 | 154 | * |
| 155 | 155 | * @return void |
| 156 | 156 | */ |
| 157 | -function give_update_old_payments_with_totals( $data ) { |
|
| 158 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_upgrade_payments_nonce' ) ) { |
|
| 157 | +function give_update_old_payments_with_totals($data) { |
|
| 158 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give_upgrade_payments_nonce')) { |
|
| 159 | 159 | return; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - if ( get_option( 'give_payment_totals_upgraded' ) ) { |
|
| 162 | + if (get_option('give_payment_totals_upgraded')) { |
|
| 163 | 163 | return; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - $payments = give_get_payments( array( |
|
| 166 | + $payments = give_get_payments(array( |
|
| 167 | 167 | 'offset' => 0, |
| 168 | - 'number' => - 1, |
|
| 168 | + 'number' => -1, |
|
| 169 | 169 | 'mode' => 'all', |
| 170 | - ) ); |
|
| 170 | + )); |
|
| 171 | 171 | |
| 172 | - if ( $payments ) { |
|
| 173 | - foreach ( $payments as $payment ) { |
|
| 172 | + if ($payments) { |
|
| 173 | + foreach ($payments as $payment) { |
|
| 174 | 174 | |
| 175 | - $payment = new Give_Payment( $payment->ID ); |
|
| 175 | + $payment = new Give_Payment($payment->ID); |
|
| 176 | 176 | $meta = $payment->get_meta(); |
| 177 | 177 | |
| 178 | 178 | $payment->total = $meta['amount']; |
@@ -181,10 +181,10 @@ discard block |
||
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - add_option( 'give_payment_totals_upgraded', 1 ); |
|
| 184 | + add_option('give_payment_totals_upgraded', 1); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | -add_action( 'give_upgrade_payments', 'give_update_old_payments_with_totals' ); |
|
| 187 | +add_action('give_upgrade_payments', 'give_update_old_payments_with_totals'); |
|
| 188 | 188 | |
| 189 | 189 | /** |
| 190 | 190 | * Mark Abandoned Donations |
@@ -198,17 +198,17 @@ discard block |
||
| 198 | 198 | function give_mark_abandoned_donations() { |
| 199 | 199 | $args = array( |
| 200 | 200 | 'status' => 'pending', |
| 201 | - 'number' => - 1, |
|
| 201 | + 'number' => -1, |
|
| 202 | 202 | 'output' => 'give_payments', |
| 203 | 203 | ); |
| 204 | 204 | |
| 205 | - add_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
| 205 | + add_filter('posts_where', 'give_filter_where_older_than_week'); |
|
| 206 | 206 | |
| 207 | - $payments = give_get_payments( $args ); |
|
| 207 | + $payments = give_get_payments($args); |
|
| 208 | 208 | |
| 209 | - remove_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
| 209 | + remove_filter('posts_where', 'give_filter_where_older_than_week'); |
|
| 210 | 210 | |
| 211 | - if ( $payments ) { |
|
| 211 | + if ($payments) { |
|
| 212 | 212 | /** |
| 213 | 213 | * Filter payment gateways: Used to set payment gateways which can be skip while transferring pending payment to abandon. |
| 214 | 214 | * |
@@ -216,14 +216,14 @@ discard block |
||
| 216 | 216 | * |
| 217 | 217 | * @param array $skip_payment_gateways Array of payment gateways |
| 218 | 218 | */ |
| 219 | - $skip_payment_gateways = apply_filters( 'give_mark_abandoned_donation_gateways', array( 'offline' ) ); |
|
| 219 | + $skip_payment_gateways = apply_filters('give_mark_abandoned_donation_gateways', array('offline')); |
|
| 220 | 220 | |
| 221 | 221 | /* @var Give_Payment $payment */ |
| 222 | - foreach ( $payments as $payment ) { |
|
| 223 | - $gateway = give_get_payment_gateway( $payment->ID ); |
|
| 222 | + foreach ($payments as $payment) { |
|
| 223 | + $gateway = give_get_payment_gateway($payment->ID); |
|
| 224 | 224 | |
| 225 | 225 | // Skip payment gateways. |
| 226 | - if ( in_array( $gateway, $skip_payment_gateways ) ) { |
|
| 226 | + if (in_array($gateway, $skip_payment_gateways)) { |
|
| 227 | 227 | continue; |
| 228 | 228 | } |
| 229 | 229 | |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | -Give_Cron::add_weekly_event( 'give_mark_abandoned_donations' ); |
|
| 236 | +Give_Cron::add_weekly_event('give_mark_abandoned_donations'); |
|
| 237 | 237 | |
| 238 | 238 | |
| 239 | 239 | /** |
@@ -245,15 +245,15 @@ discard block |
||
| 245 | 245 | * |
| 246 | 246 | * @return void |
| 247 | 247 | */ |
| 248 | -function give_refresh_thismonth_stat_transients( $payment_ID ) { |
|
| 248 | +function give_refresh_thismonth_stat_transients($payment_ID) { |
|
| 249 | 249 | // Monthly stats. |
| 250 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
| 250 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
| 251 | 251 | |
| 252 | 252 | // @todo: Refresh only range related stat cache |
| 253 | 253 | give_delete_donation_stats(); |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | -add_action( 'save_post_give_payment', 'give_refresh_thismonth_stat_transients' ); |
|
| 256 | +add_action('save_post_give_payment', 'give_refresh_thismonth_stat_transients'); |
|
| 257 | 257 | |
| 258 | 258 | |
| 259 | 259 | /** |
@@ -269,12 +269,12 @@ discard block |
||
| 269 | 269 | * |
| 270 | 270 | * @return array |
| 271 | 271 | */ |
| 272 | -function give_bc_v20_get_payment_meta( $check, $object_id, $meta_key, $single ) { |
|
| 272 | +function give_bc_v20_get_payment_meta($check, $object_id, $meta_key, $single) { |
|
| 273 | 273 | // Bailout. |
| 274 | 274 | if ( |
| 275 | - 'give_payment' !== get_post_type( $object_id ) || |
|
| 275 | + 'give_payment' !== get_post_type($object_id) || |
|
| 276 | 276 | '_give_payment_meta' !== $meta_key || |
| 277 | - ! give_has_upgrade_completed( 'v20_upgrades_payment_metadata' ) |
|
| 277 | + ! give_has_upgrade_completed('v20_upgrades_payment_metadata') |
|
| 278 | 278 | ) { |
| 279 | 279 | return $check; |
| 280 | 280 | } |
@@ -282,73 +282,69 @@ discard block |
||
| 282 | 282 | $cache_key = "_give_payment_meta_{$object_id}"; |
| 283 | 283 | |
| 284 | 284 | // Get already calculate payment meta from cache. |
| 285 | - $payment_meta = Give_Cache::get_db_query( $cache_key ); |
|
| 285 | + $payment_meta = Give_Cache::get_db_query($cache_key); |
|
| 286 | 286 | |
| 287 | - if ( is_null( $payment_meta ) ) { |
|
| 287 | + if (is_null($payment_meta)) { |
|
| 288 | 288 | // Remove filter. |
| 289 | - remove_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999 ); |
|
| 289 | + remove_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999); |
|
| 290 | 290 | |
| 291 | - $donation = new Give_Payment( $object_id ); |
|
| 291 | + $donation = new Give_Payment($object_id); |
|
| 292 | 292 | |
| 293 | 293 | // Get all payment meta. |
| 294 | - $payment_meta = give_get_meta( $object_id ); |
|
| 294 | + $payment_meta = give_get_meta($object_id); |
|
| 295 | 295 | |
| 296 | 296 | // Set default value to array. |
| 297 | - if ( empty( $payment_meta ) ) { |
|
| 297 | + if (empty($payment_meta)) { |
|
| 298 | 298 | return $check; |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | // Convert all meta key value to string instead of array |
| 302 | - array_walk( $payment_meta, function ( &$meta, $key ) { |
|
| 303 | - $meta = current( $meta ); |
|
| 302 | + array_walk($payment_meta, function(&$meta, $key) { |
|
| 303 | + $meta = current($meta); |
|
| 304 | 304 | } ); |
| 305 | 305 | |
| 306 | 306 | /** |
| 307 | 307 | * Add backward compatibility to old meta keys. |
| 308 | 308 | */ |
| 309 | 309 | // Donation key. |
| 310 | - $payment_meta['key'] = ! empty( $payment_meta['_give_payment_purchase_key'] ) ? $payment_meta['_give_payment_purchase_key'] : ''; |
|
| 310 | + $payment_meta['key'] = ! empty($payment_meta['_give_payment_purchase_key']) ? $payment_meta['_give_payment_purchase_key'] : ''; |
|
| 311 | 311 | |
| 312 | 312 | // Donation form. |
| 313 | - $payment_meta['form_title'] = ! empty( $payment_meta['_give_payment_form_title'] ) ? $payment_meta['_give_payment_form_title'] : ''; |
|
| 313 | + $payment_meta['form_title'] = ! empty($payment_meta['_give_payment_form_title']) ? $payment_meta['_give_payment_form_title'] : ''; |
|
| 314 | 314 | |
| 315 | 315 | // Donor email. |
| 316 | - $payment_meta['email'] = ! empty( $payment_meta['_give_payment_donor_email'] ) ? $payment_meta['_give_payment_donor_email'] : ''; |
|
| 317 | - $payment_meta['email'] = ! empty( $payment_meta['email'] ) ? |
|
| 318 | - $payment_meta['email'] : |
|
| 319 | - Give()->donors->get_column( 'email', $donation->donor_id ); |
|
| 316 | + $payment_meta['email'] = ! empty($payment_meta['_give_payment_donor_email']) ? $payment_meta['_give_payment_donor_email'] : ''; |
|
| 317 | + $payment_meta['email'] = ! empty($payment_meta['email']) ? |
|
| 318 | + $payment_meta['email'] : Give()->donors->get_column('email', $donation->donor_id); |
|
| 320 | 319 | |
| 321 | 320 | // Form id. |
| 322 | - $payment_meta['form_id'] = ! empty( $payment_meta['_give_payment_form_id'] ) ? $payment_meta['_give_payment_form_id'] : ''; |
|
| 321 | + $payment_meta['form_id'] = ! empty($payment_meta['_give_payment_form_id']) ? $payment_meta['_give_payment_form_id'] : ''; |
|
| 323 | 322 | |
| 324 | 323 | // Price id. |
| 325 | - $payment_meta['price_id'] = ! empty( $payment_meta['_give_payment_price_id'] ) ? $payment_meta['_give_payment_price_id'] : ''; |
|
| 324 | + $payment_meta['price_id'] = ! empty($payment_meta['_give_payment_price_id']) ? $payment_meta['_give_payment_price_id'] : ''; |
|
| 326 | 325 | |
| 327 | 326 | // Date. |
| 328 | - $payment_meta['date'] = ! empty( $payment_meta['_give_payment_date'] ) ? $payment_meta['_give_payment_date'] : ''; |
|
| 329 | - $payment_meta['date'] = ! empty( $payment_meta['date'] ) ? |
|
| 330 | - $payment_meta['date'] : |
|
| 331 | - get_post_field( 'post_date', $object_id ); |
|
| 327 | + $payment_meta['date'] = ! empty($payment_meta['_give_payment_date']) ? $payment_meta['_give_payment_date'] : ''; |
|
| 328 | + $payment_meta['date'] = ! empty($payment_meta['date']) ? |
|
| 329 | + $payment_meta['date'] : get_post_field('post_date', $object_id); |
|
| 332 | 330 | |
| 333 | 331 | |
| 334 | 332 | // Currency. |
| 335 | - $payment_meta['currency'] = ! empty( $payment_meta['_give_payment_currency'] ) ? $payment_meta['_give_payment_currency'] : ''; |
|
| 333 | + $payment_meta['currency'] = ! empty($payment_meta['_give_payment_currency']) ? $payment_meta['_give_payment_currency'] : ''; |
|
| 336 | 334 | |
| 337 | 335 | // Decode donor data. |
| 338 | - $donor_id = ! empty( $payment_meta['_give_payment_donor_id'] ) ? $payment_meta['_give_payment_donor_id'] : 0; |
|
| 339 | - $donor = new Give_Donor( $donor_id ); |
|
| 336 | + $donor_id = ! empty($payment_meta['_give_payment_donor_id']) ? $payment_meta['_give_payment_donor_id'] : 0; |
|
| 337 | + $donor = new Give_Donor($donor_id); |
|
| 340 | 338 | |
| 341 | 339 | // Donor first name. |
| 342 | - $donor_data['first_name'] = ! empty( $payment_meta['_give_donor_billing_first_name'] ) ? $payment_meta['_give_donor_billing_first_name'] : ''; |
|
| 343 | - $donor_data['first_name'] = ! empty( $donor_data['first_name'] ) ? |
|
| 344 | - $donor_data['first_name'] : |
|
| 345 | - $donor->get_first_name(); |
|
| 340 | + $donor_data['first_name'] = ! empty($payment_meta['_give_donor_billing_first_name']) ? $payment_meta['_give_donor_billing_first_name'] : ''; |
|
| 341 | + $donor_data['first_name'] = ! empty($donor_data['first_name']) ? |
|
| 342 | + $donor_data['first_name'] : $donor->get_first_name(); |
|
| 346 | 343 | |
| 347 | 344 | // Donor last name. |
| 348 | - $donor_data['last_name'] = ! empty( $payment_meta['_give_donor_billing_last_name'] ) ? $payment_meta['_give_donor_billing_last_name'] : ''; |
|
| 349 | - $donor_data['last_name'] = ! empty( $donor_data['last_name'] ) ? |
|
| 350 | - $donor_data['last_name'] : |
|
| 351 | - $donor->get_last_name(); |
|
| 345 | + $donor_data['last_name'] = ! empty($payment_meta['_give_donor_billing_last_name']) ? $payment_meta['_give_donor_billing_last_name'] : ''; |
|
| 346 | + $donor_data['last_name'] = ! empty($donor_data['last_name']) ? |
|
| 347 | + $donor_data['last_name'] : $donor->get_last_name(); |
|
| 352 | 348 | |
| 353 | 349 | // Donor email. |
| 354 | 350 | $donor_data['email'] = $payment_meta['email']; |
@@ -359,63 +355,63 @@ discard block |
||
| 359 | 355 | $donor_data['address'] = false; |
| 360 | 356 | |
| 361 | 357 | // Address1. |
| 362 | - $address1 = ! empty( $payment_meta['_give_donor_billing_address1'] ) ? $payment_meta['_give_donor_billing_address1'] : ''; |
|
| 363 | - if ( $address1 ) { |
|
| 358 | + $address1 = ! empty($payment_meta['_give_donor_billing_address1']) ? $payment_meta['_give_donor_billing_address1'] : ''; |
|
| 359 | + if ($address1) { |
|
| 364 | 360 | $donor_data['address']['line1'] = $address1; |
| 365 | 361 | } |
| 366 | 362 | |
| 367 | 363 | // Address2. |
| 368 | - $address2 = ! empty( $payment_meta['_give_donor_billing_address2'] ) ? $payment_meta['_give_donor_billing_address2'] : ''; |
|
| 369 | - if ( $address2 ) { |
|
| 364 | + $address2 = ! empty($payment_meta['_give_donor_billing_address2']) ? $payment_meta['_give_donor_billing_address2'] : ''; |
|
| 365 | + if ($address2) { |
|
| 370 | 366 | $donor_data['address']['line2'] = $address2; |
| 371 | 367 | } |
| 372 | 368 | |
| 373 | 369 | // City. |
| 374 | - $city = ! empty( $payment_meta['_give_donor_billing_city'] ) ? $payment_meta['_give_donor_billing_city'] : ''; |
|
| 375 | - if ( $city ) { |
|
| 370 | + $city = ! empty($payment_meta['_give_donor_billing_city']) ? $payment_meta['_give_donor_billing_city'] : ''; |
|
| 371 | + if ($city) { |
|
| 376 | 372 | $donor_data['address']['city'] = $city; |
| 377 | 373 | } |
| 378 | 374 | |
| 379 | 375 | // Zip. |
| 380 | - $zip = ! empty( $payment_meta['_give_donor_billing_zip'] ) ? $payment_meta['_give_donor_billing_zip'] : ''; |
|
| 381 | - if ( $zip ) { |
|
| 376 | + $zip = ! empty($payment_meta['_give_donor_billing_zip']) ? $payment_meta['_give_donor_billing_zip'] : ''; |
|
| 377 | + if ($zip) { |
|
| 382 | 378 | $donor_data['address']['zip'] = $zip; |
| 383 | 379 | } |
| 384 | 380 | |
| 385 | 381 | // State. |
| 386 | - $state = ! empty( $payment_meta['_give_donor_billing_state'] ) ? $payment_meta['_give_donor_billing_state'] : ''; |
|
| 387 | - if ( $state ) { |
|
| 382 | + $state = ! empty($payment_meta['_give_donor_billing_state']) ? $payment_meta['_give_donor_billing_state'] : ''; |
|
| 383 | + if ($state) { |
|
| 388 | 384 | $donor_data['address']['state'] = $state; |
| 389 | 385 | } |
| 390 | 386 | |
| 391 | 387 | // Country. |
| 392 | - $country = ! empty( $payment_meta['_give_donor_billing_country'] ) ? $payment_meta['_give_donor_billing_country'] : ''; |
|
| 393 | - if ( $country ) { |
|
| 388 | + $country = ! empty($payment_meta['_give_donor_billing_country']) ? $payment_meta['_give_donor_billing_country'] : ''; |
|
| 389 | + if ($country) { |
|
| 394 | 390 | $donor_data['address']['country'] = $country; |
| 395 | 391 | } |
| 396 | 392 | |
| 397 | 393 | $payment_meta['user_info'] = $donor_data; |
| 398 | 394 | |
| 399 | 395 | // Add filter |
| 400 | - add_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4 ); |
|
| 396 | + add_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4); |
|
| 401 | 397 | |
| 402 | 398 | // Set custom meta key into payment meta. |
| 403 | - if ( ! empty( $payment_meta['_give_payment_meta'] ) ) { |
|
| 404 | - $payment_meta = array_merge( maybe_unserialize( $payment_meta['_give_payment_meta'] ), $payment_meta ); |
|
| 399 | + if ( ! empty($payment_meta['_give_payment_meta'])) { |
|
| 400 | + $payment_meta = array_merge(maybe_unserialize($payment_meta['_give_payment_meta']), $payment_meta); |
|
| 405 | 401 | } |
| 406 | 402 | |
| 407 | 403 | // Set cache. |
| 408 | - Give_Cache::set_db_query( $cache_key, $payment_meta ); |
|
| 404 | + Give_Cache::set_db_query($cache_key, $payment_meta); |
|
| 409 | 405 | } |
| 410 | 406 | |
| 411 | - if ( $single ) { |
|
| 407 | + if ($single) { |
|
| 412 | 408 | /** |
| 413 | 409 | * Filter the payment meta |
| 414 | 410 | * Add custom meta key to payment meta |
| 415 | 411 | * |
| 416 | 412 | * @since 2.0 |
| 417 | 413 | */ |
| 418 | - $new_payment_meta[0] = apply_filters( 'give_get_payment_meta', $payment_meta, $object_id, $meta_key ); |
|
| 414 | + $new_payment_meta[0] = apply_filters('give_get_payment_meta', $payment_meta, $object_id, $meta_key); |
|
| 419 | 415 | |
| 420 | 416 | $payment_meta = $new_payment_meta; |
| 421 | 417 | } |
@@ -423,7 +419,7 @@ discard block |
||
| 423 | 419 | return $payment_meta; |
| 424 | 420 | } |
| 425 | 421 | |
| 426 | -add_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4 ); |
|
| 422 | +add_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4); |
|
| 427 | 423 | |
| 428 | 424 | /** |
| 429 | 425 | * Add meta in payment that store page id and page url. |
@@ -435,19 +431,19 @@ discard block |
||
| 435 | 431 | * |
| 436 | 432 | * @param int $payment_id Payment id for which the meta value should be updated. |
| 437 | 433 | */ |
| 438 | -function give_payment_save_page_data( $payment_id ) { |
|
| 439 | - $page_url = ( ! empty( $_REQUEST['give-current-url'] ) ? esc_url( $_REQUEST['give-current-url'] ) : false ); |
|
| 434 | +function give_payment_save_page_data($payment_id) { |
|
| 435 | + $page_url = ( ! empty($_REQUEST['give-current-url']) ? esc_url($_REQUEST['give-current-url']) : false); |
|
| 440 | 436 | |
| 441 | 437 | // Check $page_url is not empty. |
| 442 | - if ( $page_url ) { |
|
| 443 | - update_post_meta( $payment_id, '_give_current_url', $page_url ); |
|
| 444 | - $page_id = url_to_postid( $page_url ); |
|
| 438 | + if ($page_url) { |
|
| 439 | + update_post_meta($payment_id, '_give_current_url', $page_url); |
|
| 440 | + $page_id = url_to_postid($page_url); |
|
| 445 | 441 | // Check $page_id is not empty. |
| 446 | - if ( $page_id ) { |
|
| 447 | - update_post_meta( $payment_id, '_give_current_page_id', $page_id ); |
|
| 442 | + if ($page_id) { |
|
| 443 | + update_post_meta($payment_id, '_give_current_page_id', $page_id); |
|
| 448 | 444 | } |
| 449 | 445 | } |
| 450 | 446 | } |
| 451 | 447 | |
| 452 | 448 | // Fire when payment is save. |
| 453 | -add_action( 'give_insert_payment', 'give_payment_save_page_data' ); |
|
| 454 | 449 | \ No newline at end of file |
| 450 | +add_action('give_insert_payment', 'give_payment_save_page_data'); |
|
| 455 | 451 | \ No newline at end of file |