@@ -731,7 +731,7 @@ |
||
| 731 | 731 | * @param bool $colon Check if add colon between heading and message. |
| 732 | 732 | * @param string $color Heading color. |
| 733 | 733 | * |
| 734 | - * @return mixed |
|
| 734 | + * @return string |
|
| 735 | 735 | */ |
| 736 | 736 | private function color_message( $heading, $message = '', $colon = true, $color = 'g' ) { |
| 737 | 737 | // Add colon. |
@@ -7,12 +7,12 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // Exit if accessed directly. |
| 10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 10 | +if ( ! defined('ABSPATH')) { |
|
| 11 | 11 | exit; |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | // Add give command. |
| 15 | -WP_CLI::add_command( 'give', 'GIVE_CLI_COMMAND' ); |
|
| 15 | +WP_CLI::add_command('give', 'GIVE_CLI_COMMAND'); |
|
| 16 | 16 | |
| 17 | 17 | |
| 18 | 18 | /** |
@@ -68,54 +68,54 @@ discard block |
||
| 68 | 68 | * |
| 69 | 69 | * @subcommand details |
| 70 | 70 | */ |
| 71 | - public function details( $args, $assoc_args ) { |
|
| 71 | + public function details($args, $assoc_args) { |
|
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * Plugin Information |
| 75 | 75 | */ |
| 76 | - WP_CLI::log( $this->color_message( __( 'Give Version: ', 'give' ) ) . GIVE_VERSION ); |
|
| 76 | + WP_CLI::log($this->color_message(__('Give Version: ', 'give')).GIVE_VERSION); |
|
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * General Information. |
| 80 | 80 | */ |
| 81 | - WP_CLI::log( "\n#### " . $this->color_message( __( 'General information', 'give' ) ) . ' ####' ); |
|
| 81 | + WP_CLI::log("\n#### ".$this->color_message(__('General information', 'give')).' ####'); |
|
| 82 | 82 | |
| 83 | - $success_page = give_get_option( 'success_page' ); |
|
| 84 | - $failure_page = give_get_option( 'failure_page' ); |
|
| 85 | - $history_page = give_get_option( 'history_page' ); |
|
| 83 | + $success_page = give_get_option('success_page'); |
|
| 84 | + $failure_page = give_get_option('failure_page'); |
|
| 85 | + $history_page = give_get_option('history_page'); |
|
| 86 | 86 | |
| 87 | - WP_CLI::log( $this->color_message( sprintf( __( 'Success Page: ', 'give' ) ) ) . ( $success_page ? "[{$success_page}] " . get_permalink( $success_page ) : __( 'Not Set', 'give' ) ) ); |
|
| 88 | - WP_CLI::log( $this->color_message( __( 'Failed Donation Page: ', 'give' ) ) . ( $failure_page ? "[{$failure_page}] " . get_permalink( $failure_page ) : __( 'Not Set', 'give' ) ) ); |
|
| 89 | - WP_CLI::log( $this->color_message( __( 'Donation History Page: ', 'give' ) ) . ( $history_page ? "[{$history_page}] " . get_permalink( $history_page ) : __( 'Not Set', 'give' ) ) ); |
|
| 90 | - WP_CLI::log( $this->color_message( __( 'Country: ', 'give' ) ) . give_get_country() ); |
|
| 87 | + WP_CLI::log($this->color_message(sprintf(__('Success Page: ', 'give'))).($success_page ? "[{$success_page}] ".get_permalink($success_page) : __('Not Set', 'give'))); |
|
| 88 | + WP_CLI::log($this->color_message(__('Failed Donation Page: ', 'give')).($failure_page ? "[{$failure_page}] ".get_permalink($failure_page) : __('Not Set', 'give'))); |
|
| 89 | + WP_CLI::log($this->color_message(__('Donation History Page: ', 'give')).($history_page ? "[{$history_page}] ".get_permalink($history_page) : __('Not Set', 'give'))); |
|
| 90 | + WP_CLI::log($this->color_message(__('Country: ', 'give')).give_get_country()); |
|
| 91 | 91 | |
| 92 | 92 | /** |
| 93 | 93 | * Currency Information. |
| 94 | 94 | */ |
| 95 | - $default_gateway = give_get_option( 'default_gateway' ); |
|
| 95 | + $default_gateway = give_get_option('default_gateway'); |
|
| 96 | 96 | |
| 97 | - WP_CLI::log( "\n#### " . $this->color_message( __( 'Currency Information', 'give' ) ) . ' ####' ); |
|
| 97 | + WP_CLI::log("\n#### ".$this->color_message(__('Currency Information', 'give')).' ####'); |
|
| 98 | 98 | |
| 99 | - WP_CLI::log( $this->color_message( __( 'Currency: ', 'give' ), give_get_currency() ) ); |
|
| 100 | - WP_CLI::log( $this->color_message( __( 'Currency Position: ', 'give' ), give_get_currency_position() ) ); |
|
| 101 | - WP_CLI::log( $this->color_message( __( 'Thousand Separator: ', 'give' ), give_get_price_thousand_separator() ) ); |
|
| 102 | - WP_CLI::log( $this->color_message( __( 'Decimal Separator: ', 'give' ), give_get_price_decimal_separator() ) ); |
|
| 103 | - WP_CLI::log( $this->color_message( __( 'Number of Decimals: ', 'give' ), give_get_price_decimals() ) ); |
|
| 104 | - WP_CLI::log( $this->color_message( __( 'Test Mode: ', 'give' ), ( give_get_option( 'test_mode' ) ? __( 'Yes', 'give' ) : __( 'No', 'give' ) ) ) ); |
|
| 105 | - WP_CLI::log( $this->color_message( __( 'Default Gateway: ', 'give' ), ( $default_gateway ? $default_gateway : __( 'Not Set', 'give' ) ) ) ); |
|
| 99 | + WP_CLI::log($this->color_message(__('Currency: ', 'give'), give_get_currency())); |
|
| 100 | + WP_CLI::log($this->color_message(__('Currency Position: ', 'give'), give_get_currency_position())); |
|
| 101 | + WP_CLI::log($this->color_message(__('Thousand Separator: ', 'give'), give_get_price_thousand_separator())); |
|
| 102 | + WP_CLI::log($this->color_message(__('Decimal Separator: ', 'give'), give_get_price_decimal_separator())); |
|
| 103 | + WP_CLI::log($this->color_message(__('Number of Decimals: ', 'give'), give_get_price_decimals())); |
|
| 104 | + WP_CLI::log($this->color_message(__('Test Mode: ', 'give'), (give_get_option('test_mode') ? __('Yes', 'give') : __('No', 'give')))); |
|
| 105 | + WP_CLI::log($this->color_message(__('Default Gateway: ', 'give'), ($default_gateway ? $default_gateway : __('Not Set', 'give')))); |
|
| 106 | 106 | |
| 107 | 107 | // Payment gateways Information. |
| 108 | - $gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() ); |
|
| 109 | - WP_CLI::log( $this->color_message( __( 'Enabled Gateways: ', 'give' ) ) ); |
|
| 108 | + $gateways = give_get_ordered_payment_gateways(give_get_payment_gateways()); |
|
| 109 | + WP_CLI::log($this->color_message(__('Enabled Gateways: ', 'give'))); |
|
| 110 | 110 | |
| 111 | - if ( ! empty( $gateways ) ) { |
|
| 111 | + if ( ! empty($gateways)) { |
|
| 112 | 112 | self::$counter = 1; |
| 113 | - foreach ( $gateways as $gateway ) { |
|
| 114 | - WP_CLI::log( ' ' . $this->color_message( self::$counter, $gateway['admin_label'] ) ); |
|
| 115 | - self::$counter ++; |
|
| 113 | + foreach ($gateways as $gateway) { |
|
| 114 | + WP_CLI::log(' '.$this->color_message(self::$counter, $gateway['admin_label'])); |
|
| 115 | + self::$counter++; |
|
| 116 | 116 | } |
| 117 | 117 | } else { |
| 118 | - WP_CLI::log( __( 'Not any payment gateways found', 'give' ) ); |
|
| 118 | + WP_CLI::log(__('Not any payment gateways found', 'give')); |
|
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | |
@@ -147,15 +147,15 @@ discard block |
||
| 147 | 147 | * |
| 148 | 148 | * @subcommand forms |
| 149 | 149 | */ |
| 150 | - public function forms( $args, $assoc_args ) { |
|
| 150 | + public function forms($args, $assoc_args) { |
|
| 151 | 151 | global $wp_query; |
| 152 | - $form_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false; |
|
| 153 | - $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? absint( $assoc_args['number'] ) : 10; |
|
| 152 | + $form_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false; |
|
| 153 | + $number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? absint($assoc_args['number']) : 10; |
|
| 154 | 154 | $start = time(); |
| 155 | 155 | |
| 156 | 156 | // Cache previous number query var. |
| 157 | 157 | $is_set_number = $cache_per_page = false; |
| 158 | - if ( isset( $wp_query->query_vars['number'] ) ) { |
|
| 158 | + if (isset($wp_query->query_vars['number'])) { |
|
| 159 | 159 | $cache_per_page = $wp_query->query_vars['number']; |
| 160 | 160 | $is_set_number = true; |
| 161 | 161 | } |
@@ -164,22 +164,22 @@ discard block |
||
| 164 | 164 | $wp_query->query_vars['number'] = $number; |
| 165 | 165 | |
| 166 | 166 | // Get forms. |
| 167 | - $forms = $form_id ? $this->api->get_forms( $form_id ) : $this->api->get_forms(); |
|
| 167 | + $forms = $form_id ? $this->api->get_forms($form_id) : $this->api->get_forms(); |
|
| 168 | 168 | |
| 169 | 169 | // Reset number query var. |
| 170 | - if ( $is_set_number ) { |
|
| 170 | + if ($is_set_number) { |
|
| 171 | 171 | $wp_query->query_vars['number'] = $cache_per_page; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | // Bailout. |
| 175 | - if ( array_key_exists( 'error', $forms ) ) { |
|
| 175 | + if (array_key_exists('error', $forms)) { |
|
| 176 | 176 | |
| 177 | - WP_CLI::warning( $forms['error'] ); |
|
| 177 | + WP_CLI::warning($forms['error']); |
|
| 178 | 178 | |
| 179 | 179 | return; |
| 180 | - } elseif ( empty( $forms['forms'] ) ) { |
|
| 180 | + } elseif (empty($forms['forms'])) { |
|
| 181 | 181 | |
| 182 | - WP_CLI::error( __( 'No forms found.', 'give' ) ); |
|
| 182 | + WP_CLI::error(__('No forms found.', 'give')); |
|
| 183 | 183 | |
| 184 | 184 | return; |
| 185 | 185 | } |
@@ -187,25 +187,25 @@ discard block |
||
| 187 | 187 | // Param to check if form typeis already showed or not. |
| 188 | 188 | $is_show_form_type = false; |
| 189 | 189 | |
| 190 | - if ( 1 === count( $forms ) && $form_id ) { |
|
| 190 | + if (1 === count($forms) && $form_id) { |
|
| 191 | 191 | // Show single form. |
| 192 | - foreach ( $forms['forms'][0] as $key => $info ) { |
|
| 193 | - switch ( $key ) { |
|
| 192 | + foreach ($forms['forms'][0] as $key => $info) { |
|
| 193 | + switch ($key) { |
|
| 194 | 194 | case 'stats': |
| 195 | - $this->color_main_heading( ucfirst( $key ) ); |
|
| 195 | + $this->color_main_heading(ucfirst($key)); |
|
| 196 | 196 | |
| 197 | - foreach ( $info as $heading => $data ) { |
|
| 198 | - $this->color_sub_heading( ucfirst( $heading ) ); |
|
| 199 | - switch ( $heading ) { |
|
| 197 | + foreach ($info as $heading => $data) { |
|
| 198 | + $this->color_sub_heading(ucfirst($heading)); |
|
| 199 | + switch ($heading) { |
|
| 200 | 200 | default: |
| 201 | - foreach ( $data as $subheading => $subdata ) { |
|
| 201 | + foreach ($data as $subheading => $subdata) { |
|
| 202 | 202 | |
| 203 | - switch ( $subheading ) { |
|
| 203 | + switch ($subheading) { |
|
| 204 | 204 | case 'earnings': |
| 205 | - WP_CLI::log( $this->color_message( $subheading . ': ', give_currency_filter( $subdata ) ) ); |
|
| 205 | + WP_CLI::log($this->color_message($subheading.': ', give_currency_filter($subdata))); |
|
| 206 | 206 | break; |
| 207 | 207 | default: |
| 208 | - WP_CLI::log( $this->color_message( $subheading . ': ', $subdata ) ); |
|
| 208 | + WP_CLI::log($this->color_message($subheading.': ', $subdata)); |
|
| 209 | 209 | } |
| 210 | 210 | } |
| 211 | 211 | } |
@@ -215,26 +215,26 @@ discard block |
||
| 215 | 215 | case 'pricing': |
| 216 | 216 | case 'info': |
| 217 | 217 | default: |
| 218 | - $this->color_main_heading( ucfirst( $key ) ); |
|
| 218 | + $this->color_main_heading(ucfirst($key)); |
|
| 219 | 219 | |
| 220 | 220 | // Show form type. |
| 221 | - if ( ! $is_show_form_type ) { |
|
| 222 | - $form = new Give_Donate_Form( $form_id ); |
|
| 221 | + if ( ! $is_show_form_type) { |
|
| 222 | + $form = new Give_Donate_Form($form_id); |
|
| 223 | 223 | $is_show_form_type = true; |
| 224 | 224 | |
| 225 | - WP_CLI::log( $this->color_message( __( 'form type', 'give' ), $form->get_type() ) ); |
|
| 225 | + WP_CLI::log($this->color_message(__('form type', 'give'), $form->get_type())); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - foreach ( $info as $heading => $data ) { |
|
| 228 | + foreach ($info as $heading => $data) { |
|
| 229 | 229 | |
| 230 | - switch ( $heading ) { |
|
| 230 | + switch ($heading) { |
|
| 231 | 231 | case 'id': |
| 232 | - WP_CLI::log( $this->color_message( $heading, $data ) ); |
|
| 232 | + WP_CLI::log($this->color_message($heading, $data)); |
|
| 233 | 233 | break; |
| 234 | 234 | |
| 235 | 235 | default: |
| 236 | - $data = empty( $data ) ? __( 'Not set', 'give' ) : $data; |
|
| 237 | - WP_CLI::log( $this->color_message( $heading, $data ) ); |
|
| 236 | + $data = empty($data) ? __('Not set', 'give') : $data; |
|
| 237 | + WP_CLI::log($this->color_message($heading, $data)); |
|
| 238 | 238 | } |
| 239 | 239 | } |
| 240 | 240 | } |
@@ -245,37 +245,37 @@ discard block |
||
| 245 | 245 | $is_table_first_row_set = false; |
| 246 | 246 | $table_column_count = 0; |
| 247 | 247 | |
| 248 | - WP_CLI::line( $this->color_message( sprintf( __( '%d donation forms found', 'give' ), count( $forms['forms'] ) ), '', false ) ); |
|
| 248 | + WP_CLI::line($this->color_message(sprintf(__('%d donation forms found', 'give'), count($forms['forms'])), '', false)); |
|
| 249 | 249 | |
| 250 | - foreach ( $forms['forms'] as $index => $form_data ) { |
|
| 250 | + foreach ($forms['forms'] as $index => $form_data) { |
|
| 251 | 251 | |
| 252 | 252 | // Default table data. |
| 253 | 253 | $table_first_row = array(); |
| 254 | 254 | $table_row = array(); |
| 255 | 255 | |
| 256 | - foreach ( $form_data['info'] as $key => $form ) { |
|
| 256 | + foreach ($form_data['info'] as $key => $form) { |
|
| 257 | 257 | |
| 258 | 258 | // Do not show thumbnail, content and link in table. |
| 259 | - if ( in_array( $key, array( 'content', 'thumbnail', 'link' ), true ) ) { |
|
| 259 | + if (in_array($key, array('content', 'thumbnail', 'link'), true)) { |
|
| 260 | 260 | continue; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - if ( ! $is_table_first_row_set ) { |
|
| 263 | + if ( ! $is_table_first_row_set) { |
|
| 264 | 264 | $table_first_row[] = $key; |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | $table_row[] = $form; |
| 268 | 268 | |
| 269 | - if ( 'status' === $key ) { |
|
| 269 | + if ('status' === $key) { |
|
| 270 | 270 | // First array item will be an form id in our case. |
| 271 | - $form = new Give_Donate_Form( absint( $table_row[0] ) ); |
|
| 271 | + $form = new Give_Donate_Form(absint($table_row[0])); |
|
| 272 | 272 | |
| 273 | 273 | $table_row[] = $form->get_type(); |
| 274 | 274 | } |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | // Set table first row. |
| 278 | - if ( ! $is_table_first_row_set ) { |
|
| 278 | + if ( ! $is_table_first_row_set) { |
|
| 279 | 279 | |
| 280 | 280 | // Add extra column to table. |
| 281 | 281 | $table_first_row[] = 'type'; |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | $table_data[] = $table_row; |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - $this->display_table( $table_data ); |
|
| 291 | + $this->display_table($table_data); |
|
| 292 | 292 | } |
| 293 | 293 | } |
| 294 | 294 | |
@@ -334,30 +334,30 @@ discard block |
||
| 334 | 334 | * |
| 335 | 335 | * @subcommand donors |
| 336 | 336 | */ |
| 337 | - public function donors( $args, $assoc_args ) { |
|
| 337 | + public function donors($args, $assoc_args) { |
|
| 338 | 338 | global $wp_query; |
| 339 | - $donor_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false; |
|
| 340 | - $email = isset( $assoc_args ) && array_key_exists( 'email', $assoc_args ) ? $assoc_args['email'] : false; |
|
| 341 | - $name = isset( $assoc_args ) && array_key_exists( 'name', $assoc_args ) ? $assoc_args['name'] : ''; |
|
| 342 | - $create = isset( $assoc_args ) && array_key_exists( 'create', $assoc_args ) ? $assoc_args['create'] : false; |
|
| 343 | - $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10; |
|
| 344 | - $form_id = isset( $assoc_args ) && array_key_exists( 'form-id', $assoc_args ) ? $assoc_args['form-id'] : 0; |
|
| 339 | + $donor_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false; |
|
| 340 | + $email = isset($assoc_args) && array_key_exists('email', $assoc_args) ? $assoc_args['email'] : false; |
|
| 341 | + $name = isset($assoc_args) && array_key_exists('name', $assoc_args) ? $assoc_args['name'] : ''; |
|
| 342 | + $create = isset($assoc_args) && array_key_exists('create', $assoc_args) ? $assoc_args['create'] : false; |
|
| 343 | + $number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10; |
|
| 344 | + $form_id = isset($assoc_args) && array_key_exists('form-id', $assoc_args) ? $assoc_args['form-id'] : 0; |
|
| 345 | 345 | $start = time(); |
| 346 | 346 | |
| 347 | - if ( $create ) { |
|
| 347 | + if ($create) { |
|
| 348 | 348 | $number = 1; |
| 349 | 349 | |
| 350 | 350 | // Create one or more donors. |
| 351 | - if ( ! $email ) { |
|
| 351 | + if ( ! $email) { |
|
| 352 | 352 | // If no email is specified, look to see if we are generating arbitrary donor accounts. |
| 353 | - $number = is_numeric( $create ) ? absint( $create ) : 1; |
|
| 353 | + $number = is_numeric($create) ? absint($create) : 1; |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - for ( $i = 0; $i < $number; $i ++ ) { |
|
| 357 | - if ( ! $email ) { |
|
| 356 | + for ($i = 0; $i < $number; $i++) { |
|
| 357 | + if ( ! $email) { |
|
| 358 | 358 | |
| 359 | 359 | // Generate fake email. |
| 360 | - $email = 'customer-' . uniqid() . '@test.com'; |
|
| 360 | + $email = 'customer-'.uniqid().'@test.com'; |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | $args = array( |
@@ -365,19 +365,19 @@ discard block |
||
| 365 | 365 | 'name' => $name, |
| 366 | 366 | ); |
| 367 | 367 | |
| 368 | - $customer_id = Give()->customers->add( $args ); |
|
| 368 | + $customer_id = Give()->customers->add($args); |
|
| 369 | 369 | |
| 370 | - if ( $customer_id ) { |
|
| 371 | - WP_CLI::line( $this->color_message( sprintf( __( 'Donor %d created successfully', 'give' ), $customer_id ) ) ); |
|
| 370 | + if ($customer_id) { |
|
| 371 | + WP_CLI::line($this->color_message(sprintf(__('Donor %d created successfully', 'give'), $customer_id))); |
|
| 372 | 372 | } else { |
| 373 | - WP_CLI::error( __( 'Failed to create donor', 'give' ) ); |
|
| 373 | + WP_CLI::error(__('Failed to create donor', 'give')); |
|
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | // Reset email to false so it is generated on the next loop (if creating donors). |
| 377 | 377 | $email = false; |
| 378 | 378 | } |
| 379 | 379 | |
| 380 | - WP_CLI::line( $this->color_message( sprintf( __( '%1$d donors created in %2$d seconds', 'give' ), $number, time() - $start ) ) ); |
|
| 380 | + WP_CLI::line($this->color_message(sprintf(__('%1$d donors created in %2$d seconds', 'give'), $number, time() - $start))); |
|
| 381 | 381 | |
| 382 | 382 | } else { |
| 383 | 383 | // Counter. |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | */ |
| 392 | 392 | // Cache previous number query var. |
| 393 | 393 | $is_set_number = $cache_per_page = false; |
| 394 | - if ( isset( $wp_query->query_vars['number'] ) ) { |
|
| 394 | + if (isset($wp_query->query_vars['number'])) { |
|
| 395 | 395 | $cache_per_page = $wp_query->query_vars['number']; |
| 396 | 396 | $is_set_number = true; |
| 397 | 397 | } |
@@ -400,24 +400,24 @@ discard block |
||
| 400 | 400 | $wp_query->query_vars['number'] = $number; |
| 401 | 401 | |
| 402 | 402 | // Get donors. |
| 403 | - if ( $form_id ) { |
|
| 403 | + if ($form_id) { |
|
| 404 | 404 | // @TODO: Allow user to get a list of donors by donation status. |
| 405 | - $donors = $this->get_donors_by_form_id( $form_id ); |
|
| 405 | + $donors = $this->get_donors_by_form_id($form_id); |
|
| 406 | 406 | } else { |
| 407 | - $donors = $this->api->get_customers( $search ); |
|
| 407 | + $donors = $this->api->get_customers($search); |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | // Reset number query var. |
| 411 | - if ( $is_set_number ) { |
|
| 411 | + if ($is_set_number) { |
|
| 412 | 412 | $wp_query->query_vars['number'] = $cache_per_page; |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | - if ( isset( $donors['error'] ) ) { |
|
| 416 | - WP_CLI::error( $donors['error'] ); |
|
| 415 | + if (isset($donors['error'])) { |
|
| 416 | + WP_CLI::error($donors['error']); |
|
| 417 | 417 | } |
| 418 | 418 | |
| 419 | - if ( empty( $donors ) ) { |
|
| 420 | - WP_CLI::error( __( 'No donors found.', 'give' ) ); |
|
| 419 | + if (empty($donors)) { |
|
| 420 | + WP_CLI::error(__('No donors found.', 'give')); |
|
| 421 | 421 | |
| 422 | 422 | return; |
| 423 | 423 | } |
@@ -425,24 +425,24 @@ discard block |
||
| 425 | 425 | $table_data = array(); |
| 426 | 426 | $is_table_first_row_set = false; |
| 427 | 427 | |
| 428 | - foreach ( $donors['donors'] as $donor_data ) { |
|
| 428 | + foreach ($donors['donors'] as $donor_data) { |
|
| 429 | 429 | // Set default table row data. |
| 430 | - $table_first_row = array( __( 'S. No.', 'give' ) ); |
|
| 431 | - $table_row = array( self::$counter ); |
|
| 430 | + $table_first_row = array(__('S. No.', 'give')); |
|
| 431 | + $table_row = array(self::$counter); |
|
| 432 | 432 | |
| 433 | - foreach ( $donor_data as $key => $donor ) { |
|
| 434 | - switch ( $key ) { |
|
| 433 | + foreach ($donor_data as $key => $donor) { |
|
| 434 | + switch ($key) { |
|
| 435 | 435 | case 'stats': |
| 436 | - foreach ( $donor as $heading => $data ) { |
|
| 436 | + foreach ($donor as $heading => $data) { |
|
| 437 | 437 | |
| 438 | 438 | // Get first row. |
| 439 | - if ( ! $is_table_first_row_set ) { |
|
| 439 | + if ( ! $is_table_first_row_set) { |
|
| 440 | 440 | $table_first_row[] = $heading; |
| 441 | 441 | } |
| 442 | 442 | |
| 443 | - switch ( $heading ) { |
|
| 443 | + switch ($heading) { |
|
| 444 | 444 | case 'total_spent': |
| 445 | - $table_row[] = give_currency_filter( $data ); |
|
| 445 | + $table_row[] = give_currency_filter($data); |
|
| 446 | 446 | break; |
| 447 | 447 | |
| 448 | 448 | default: |
@@ -453,10 +453,10 @@ discard block |
||
| 453 | 453 | |
| 454 | 454 | case 'info': |
| 455 | 455 | default: |
| 456 | - foreach ( $donor as $heading => $data ) { |
|
| 456 | + foreach ($donor as $heading => $data) { |
|
| 457 | 457 | |
| 458 | 458 | // Get first row. |
| 459 | - if ( ! $is_table_first_row_set ) { |
|
| 459 | + if ( ! $is_table_first_row_set) { |
|
| 460 | 460 | $table_first_row[] = $heading; |
| 461 | 461 | } |
| 462 | 462 | |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | // Add first row data to table data. |
| 469 | - if ( ! $is_table_first_row_set ) { |
|
| 469 | + if ( ! $is_table_first_row_set) { |
|
| 470 | 470 | $table_data[] = $table_first_row; |
| 471 | 471 | $is_table_first_row_set = true; |
| 472 | 472 | } |
@@ -475,10 +475,10 @@ discard block |
||
| 475 | 475 | $table_data[] = $table_row; |
| 476 | 476 | |
| 477 | 477 | // Increase counter. |
| 478 | - self::$counter ++; |
|
| 478 | + self::$counter++; |
|
| 479 | 479 | } |
| 480 | 480 | |
| 481 | - $this->display_table( $table_data ); |
|
| 481 | + $this->display_table($table_data); |
|
| 482 | 482 | } |
| 483 | 483 | } |
| 484 | 484 | |
@@ -507,13 +507,13 @@ discard block |
||
| 507 | 507 | * |
| 508 | 508 | * @subcommand donations |
| 509 | 509 | */ |
| 510 | - public function donations( $args, $assoc_args ) { |
|
| 510 | + public function donations($args, $assoc_args) { |
|
| 511 | 511 | global $wp_query; |
| 512 | - $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10; |
|
| 512 | + $number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10; |
|
| 513 | 513 | |
| 514 | 514 | // Cache previous number query var. |
| 515 | 515 | $is_set_number = $cache_per_page = false; |
| 516 | - if ( isset( $wp_query->query_vars['number'] ) ) { |
|
| 516 | + if (isset($wp_query->query_vars['number'])) { |
|
| 517 | 517 | $cache_per_page = $wp_query->query_vars['number']; |
| 518 | 518 | $is_set_number = true; |
| 519 | 519 | } |
@@ -525,46 +525,46 @@ discard block |
||
| 525 | 525 | $donations = $this->api->get_recent_donations(); |
| 526 | 526 | |
| 527 | 527 | // Reset number query var. |
| 528 | - if ( $is_set_number ) { |
|
| 528 | + if ($is_set_number) { |
|
| 529 | 529 | $wp_query->query_vars['number'] = $cache_per_page; |
| 530 | 530 | } |
| 531 | 531 | |
| 532 | - if ( empty( $donations ) ) { |
|
| 533 | - WP_CLI::error( __( 'No donations found.', 'give' ) ); |
|
| 532 | + if (empty($donations)) { |
|
| 533 | + WP_CLI::error(__('No donations found.', 'give')); |
|
| 534 | 534 | |
| 535 | 535 | return; |
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | self::$counter = 1; |
| 539 | 539 | |
| 540 | - foreach ( $donations['donations'] as $key => $donation ) { |
|
| 541 | - $this->color_main_heading( sprintf( __( '%1$s. Donation #%2$s', 'give' ), self::$counter, $donation['ID'] ), 'Y' ); |
|
| 542 | - self::$counter ++; |
|
| 540 | + foreach ($donations['donations'] as $key => $donation) { |
|
| 541 | + $this->color_main_heading(sprintf(__('%1$s. Donation #%2$s', 'give'), self::$counter, $donation['ID']), 'Y'); |
|
| 542 | + self::$counter++; |
|
| 543 | 543 | |
| 544 | - foreach ( $donation as $column => $data ) { |
|
| 544 | + foreach ($donation as $column => $data) { |
|
| 545 | 545 | |
| 546 | - if ( is_array( $data ) ) { |
|
| 547 | - $this->color_sub_heading( $column ); |
|
| 548 | - foreach ( $data as $subcolumn => $subdata ) { |
|
| 546 | + if (is_array($data)) { |
|
| 547 | + $this->color_sub_heading($column); |
|
| 548 | + foreach ($data as $subcolumn => $subdata) { |
|
| 549 | 549 | |
| 550 | 550 | // Decode html codes. |
| 551 | - switch ( $subcolumn ) { |
|
| 551 | + switch ($subcolumn) { |
|
| 552 | 552 | case 'name': |
| 553 | - $subdata = html_entity_decode( $subdata ); |
|
| 553 | + $subdata = html_entity_decode($subdata); |
|
| 554 | 554 | break; |
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | // @TODO Check if multi dimension array information is importent to show or not. For example inside donation array we have array for fees data inside payment meta. |
| 558 | - if ( is_array( $subdata ) ) { |
|
| 558 | + if (is_array($subdata)) { |
|
| 559 | 559 | continue; |
| 560 | 560 | } |
| 561 | 561 | |
| 562 | - WP_CLI::log( $this->color_message( $subcolumn, $subdata ) ); |
|
| 562 | + WP_CLI::log($this->color_message($subcolumn, $subdata)); |
|
| 563 | 563 | } |
| 564 | 564 | continue; |
| 565 | 565 | } |
| 566 | 566 | |
| 567 | - WP_CLI::log( $this->color_message( $column, $data ) ); |
|
| 567 | + WP_CLI::log($this->color_message($column, $data)); |
|
| 568 | 568 | } |
| 569 | 569 | } |
| 570 | 570 | } |
@@ -603,27 +603,27 @@ discard block |
||
| 603 | 603 | * |
| 604 | 604 | * @return void |
| 605 | 605 | */ |
| 606 | - public function report( $args, $assoc_args ) { |
|
| 606 | + public function report($args, $assoc_args) { |
|
| 607 | 607 | $stats = new Give_Payment_Stats(); |
| 608 | - $date = isset( $assoc_args ) && array_key_exists( 'date', $assoc_args ) ? $assoc_args['date'] : false; |
|
| 609 | - $start_date = isset( $assoc_args ) && array_key_exists( 'start-date', $assoc_args ) ? $assoc_args['start-date'] : false; |
|
| 610 | - $end_date = isset( $assoc_args ) && array_key_exists( 'end-date', $assoc_args ) ? $assoc_args['end-date'] : false; |
|
| 611 | - $form_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? $assoc_args['id'] : 0; |
|
| 608 | + $date = isset($assoc_args) && array_key_exists('date', $assoc_args) ? $assoc_args['date'] : false; |
|
| 609 | + $start_date = isset($assoc_args) && array_key_exists('start-date', $assoc_args) ? $assoc_args['start-date'] : false; |
|
| 610 | + $end_date = isset($assoc_args) && array_key_exists('end-date', $assoc_args) ? $assoc_args['end-date'] : false; |
|
| 611 | + $form_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? $assoc_args['id'] : 0; |
|
| 612 | 612 | |
| 613 | - if ( ! empty( $date ) ) { |
|
| 613 | + if ( ! empty($date)) { |
|
| 614 | 614 | $start_date = $date; |
| 615 | 615 | $end_date = false; |
| 616 | - } elseif ( empty( $date ) && empty( $start_date ) ) { |
|
| 616 | + } elseif (empty($date) && empty($start_date)) { |
|
| 617 | 617 | $start_date = 'this_month'; |
| 618 | 618 | $end_date = false; |
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | // Get stats. |
| 622 | - $earnings = $stats->get_earnings( $form_id, $start_date, $end_date ); |
|
| 623 | - $sales = $stats->get_sales( $form_id, $start_date, $end_date ); |
|
| 622 | + $earnings = $stats->get_earnings($form_id, $start_date, $end_date); |
|
| 623 | + $sales = $stats->get_sales($form_id, $start_date, $end_date); |
|
| 624 | 624 | |
| 625 | - WP_CLI::line( $this->color_message( __( 'Earnings', 'give' ), give_currency_filter( $earnings ) ) ); |
|
| 626 | - WP_CLI::line( $this->color_message( __( 'Sales', 'give' ), $sales ) ); |
|
| 625 | + WP_CLI::line($this->color_message(__('Earnings', 'give'), give_currency_filter($earnings))); |
|
| 626 | + WP_CLI::line($this->color_message(__('Sales', 'give'), $sales)); |
|
| 627 | 627 | } |
| 628 | 628 | |
| 629 | 629 | |
@@ -650,27 +650,27 @@ discard block |
||
| 650 | 650 | * |
| 651 | 651 | * @subcommand cache |
| 652 | 652 | */ |
| 653 | - public function cache( $args, $assoc_args ) { |
|
| 654 | - $action = isset( $assoc_args ) && array_key_exists( 'action', $assoc_args ) ? $assoc_args['action'] : false; |
|
| 653 | + public function cache($args, $assoc_args) { |
|
| 654 | + $action = isset($assoc_args) && array_key_exists('action', $assoc_args) ? $assoc_args['action'] : false; |
|
| 655 | 655 | |
| 656 | 656 | // Bailout. |
| 657 | - if ( ! $action || ! in_array( $action, array( 'delete' ), true ) ) { |
|
| 658 | - WP_CLI::warning( __( 'Type wp give cache --action=delete to delete all stat transients', 'give' ) ); |
|
| 657 | + if ( ! $action || ! in_array($action, array('delete'), true)) { |
|
| 658 | + WP_CLI::warning(__('Type wp give cache --action=delete to delete all stat transients', 'give')); |
|
| 659 | 659 | |
| 660 | 660 | return; |
| 661 | 661 | } |
| 662 | 662 | |
| 663 | - switch ( $action ) { |
|
| 663 | + switch ($action) { |
|
| 664 | 664 | case 'delete' : |
| 665 | 665 | // Reset counter. |
| 666 | 666 | self::$counter = 1; |
| 667 | 667 | |
| 668 | - if ( $this->delete_stats_transients() ) { |
|
| 668 | + if ($this->delete_stats_transients()) { |
|
| 669 | 669 | // Report .eading. |
| 670 | - WP_CLI::success( 'All form stat transient cache deleted.' ); |
|
| 670 | + WP_CLI::success('All form stat transient cache deleted.'); |
|
| 671 | 671 | } else { |
| 672 | 672 | // Report .eading. |
| 673 | - WP_CLI::warning( 'We did not find any transient to delete :)' ); |
|
| 673 | + WP_CLI::warning('We did not find any transient to delete :)'); |
|
| 674 | 674 | } |
| 675 | 675 | break; |
| 676 | 676 | } |
@@ -696,23 +696,23 @@ discard block |
||
| 696 | 696 | ARRAY_A |
| 697 | 697 | ); |
| 698 | 698 | |
| 699 | - if ( ! empty( $stat_option_names ) ) { |
|
| 699 | + if ( ! empty($stat_option_names)) { |
|
| 700 | 700 | |
| 701 | 701 | // Convert transient option name to transient name. |
| 702 | 702 | $stat_option_names = array_map( |
| 703 | - function ( $option ) { |
|
| 704 | - return str_replace( '_transient_', '', $option['option_name'] ); |
|
| 703 | + function($option) { |
|
| 704 | + return str_replace('_transient_', '', $option['option_name']); |
|
| 705 | 705 | }, |
| 706 | 706 | $stat_option_names |
| 707 | 707 | ); |
| 708 | 708 | |
| 709 | - foreach ( $stat_option_names as $option_name ) { |
|
| 710 | - if ( delete_transient( $option_name ) ) { |
|
| 709 | + foreach ($stat_option_names as $option_name) { |
|
| 710 | + if (delete_transient($option_name)) { |
|
| 711 | 711 | |
| 712 | - WP_CLI::log( $this->color_message( self::$counter, $option_name ) ); |
|
| 713 | - self::$counter ++; |
|
| 712 | + WP_CLI::log($this->color_message(self::$counter, $option_name)); |
|
| 713 | + self::$counter++; |
|
| 714 | 714 | } else { |
| 715 | - WP_CLI::log( $this->color_message( __( 'Error while deleting this transient', 'give' ), $option_name ) ); |
|
| 715 | + WP_CLI::log($this->color_message(__('Error while deleting this transient', 'give'), $option_name)); |
|
| 716 | 716 | } |
| 717 | 717 | } |
| 718 | 718 | |
@@ -733,13 +733,13 @@ discard block |
||
| 733 | 733 | * |
| 734 | 734 | * @return mixed |
| 735 | 735 | */ |
| 736 | - private function color_message( $heading, $message = '', $colon = true, $color = 'g' ) { |
|
| 736 | + private function color_message($heading, $message = '', $colon = true, $color = 'g') { |
|
| 737 | 737 | // Add colon. |
| 738 | - if ( $colon ) { |
|
| 739 | - $heading = $heading . ': '; |
|
| 738 | + if ($colon) { |
|
| 739 | + $heading = $heading.': '; |
|
| 740 | 740 | } |
| 741 | 741 | |
| 742 | - return WP_CLI::colorize( "%{$color}" . $heading . '%n' ) . $message; |
|
| 742 | + return WP_CLI::colorize("%{$color}".$heading.'%n').$message; |
|
| 743 | 743 | } |
| 744 | 744 | |
| 745 | 745 | |
@@ -754,8 +754,8 @@ discard block |
||
| 754 | 754 | * |
| 755 | 755 | * @return void |
| 756 | 756 | */ |
| 757 | - private function color_main_heading( $heading, $color = 'g' ) { |
|
| 758 | - WP_CLI::log( "\n###### " . $this->color_message( $heading, '', false, $color ) . ' ######' ); |
|
| 757 | + private function color_main_heading($heading, $color = 'g') { |
|
| 758 | + WP_CLI::log("\n###### ".$this->color_message($heading, '', false, $color).' ######'); |
|
| 759 | 759 | } |
| 760 | 760 | |
| 761 | 761 | /** |
@@ -768,8 +768,8 @@ discard block |
||
| 768 | 768 | * |
| 769 | 769 | * @return void |
| 770 | 770 | */ |
| 771 | - private function color_sub_heading( $subheading ) { |
|
| 772 | - WP_CLI::log( "\n--->" . $subheading . '', '', false ); |
|
| 771 | + private function color_sub_heading($subheading) { |
|
| 772 | + WP_CLI::log("\n--->".$subheading.'', '', false); |
|
| 773 | 773 | } |
| 774 | 774 | |
| 775 | 775 | |
@@ -783,17 +783,17 @@ discard block |
||
| 783 | 783 | * |
| 784 | 784 | * @return void |
| 785 | 785 | */ |
| 786 | - private function display_table( $data ) { |
|
| 786 | + private function display_table($data) { |
|
| 787 | 787 | $table = new \cli\Table(); |
| 788 | 788 | |
| 789 | 789 | // Set table header. |
| 790 | - $table->setHeaders( $data[0] ); |
|
| 790 | + $table->setHeaders($data[0]); |
|
| 791 | 791 | |
| 792 | 792 | // Remove table header. |
| 793 | - unset( $data[0] ); |
|
| 793 | + unset($data[0]); |
|
| 794 | 794 | |
| 795 | 795 | // Set table data. |
| 796 | - $table->setRows( $data ); |
|
| 796 | + $table->setRows($data); |
|
| 797 | 797 | |
| 798 | 798 | // Display table. |
| 799 | 799 | $table->display(); |
@@ -809,14 +809,14 @@ discard block |
||
| 809 | 809 | * @return array |
| 810 | 810 | */ |
| 811 | 811 | |
| 812 | - private function get_donors_by_form_id( $form_id ) { |
|
| 812 | + private function get_donors_by_form_id($form_id) { |
|
| 813 | 813 | $donors = array(); |
| 814 | 814 | |
| 815 | 815 | $donations = new Give_Payments_Query( |
| 816 | 816 | array( |
| 817 | - 'give_forms' => array( $form_id ), |
|
| 817 | + 'give_forms' => array($form_id), |
|
| 818 | 818 | 'number' => -1, |
| 819 | - 'status' => array( 'publish' ), |
|
| 819 | + 'status' => array('publish'), |
|
| 820 | 820 | ) |
| 821 | 821 | ); |
| 822 | 822 | |
@@ -824,16 +824,16 @@ discard block |
||
| 824 | 824 | $skip_donors = array(); |
| 825 | 825 | |
| 826 | 826 | /* @var Give_Payment|object $donation Payment object. */ |
| 827 | - foreach ( $donations as $donation ) { |
|
| 827 | + foreach ($donations as $donation) { |
|
| 828 | 828 | |
| 829 | - if ( in_array( $donation->customer_id, $skip_donors ) ) { |
|
| 829 | + if (in_array($donation->customer_id, $skip_donors)) { |
|
| 830 | 830 | continue; |
| 831 | 831 | } |
| 832 | 832 | |
| 833 | - if ( ! empty( $donors ) ) { |
|
| 834 | - $donors['donors'][] = current( $this->api->get_customers( (int) $donation->customer_id ) )[0]; |
|
| 833 | + if ( ! empty($donors)) { |
|
| 834 | + $donors['donors'][] = current($this->api->get_customers((int) $donation->customer_id))[0]; |
|
| 835 | 835 | } else { |
| 836 | - $donors = array_merge( $donors, $this->api->get_customers( (int) $donation->customer_id ) ); |
|
| 836 | + $donors = array_merge($donors, $this->api->get_customers((int) $donation->customer_id)); |
|
| 837 | 837 | } |
| 838 | 838 | |
| 839 | 839 | $skip_donors[] = $donation->customer_id; |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | * |
| 327 | 327 | * @since 1.0 |
| 328 | 328 | * |
| 329 | - * @param int|bool $form_id Form ID (default: false). |
|
| 329 | + * @param boolean $form_id Form ID (default: false). |
|
| 330 | 330 | * @param int $payment_id Payment ID. |
| 331 | 331 | * |
| 332 | 332 | * @return void |
@@ -644,7 +644,7 @@ discard block |
||
| 644 | 644 | * @param int $year Year number. Default is null. |
| 645 | 645 | * @param int $hour Hour number. Default is null. |
| 646 | 646 | * |
| 647 | - * @return int $earnings Earnings |
|
| 647 | + * @return double $earnings Earnings |
|
| 648 | 648 | */ |
| 649 | 649 | function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) { |
| 650 | 650 | |
@@ -959,7 +959,7 @@ discard block |
||
| 959 | 959 | * |
| 960 | 960 | * @param int $payment_id Payment ID. |
| 961 | 961 | * |
| 962 | - * @return int $form_id Form ID. |
|
| 962 | + * @return string $form_id Form ID. |
|
| 963 | 963 | */ |
| 964 | 964 | function give_get_payment_form_id( $payment_id ) { |
| 965 | 965 | $payment = new Give_Payment( $payment_id ); |
@@ -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 | |
@@ -43,15 +43,15 @@ discard block |
||
| 43 | 43 | * |
| 44 | 44 | * @return object $payments Payments retrieved from the database |
| 45 | 45 | */ |
| 46 | -function give_get_payments( $args = array() ) { |
|
| 46 | +function give_get_payments($args = array()) { |
|
| 47 | 47 | |
| 48 | 48 | // Fallback to post objects to ensure backwards compatibility. |
| 49 | - if ( ! isset( $args['output'] ) ) { |
|
| 49 | + if ( ! isset($args['output'])) { |
|
| 50 | 50 | $args['output'] = 'posts'; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - $args = apply_filters( 'give_get_payments_args', $args ); |
|
| 54 | - $payments = new Give_Payments_Query( $args ); |
|
| 53 | + $args = apply_filters('give_get_payments_args', $args); |
|
| 54 | + $payments = new Give_Payments_Query($args); |
|
| 55 | 55 | |
| 56 | 56 | return $payments->get_payments(); |
| 57 | 57 | } |
@@ -66,48 +66,48 @@ discard block |
||
| 66 | 66 | * |
| 67 | 67 | * @return mixed |
| 68 | 68 | */ |
| 69 | -function give_get_payment_by( $field = '', $value = '' ) { |
|
| 69 | +function give_get_payment_by($field = '', $value = '') { |
|
| 70 | 70 | |
| 71 | - if ( empty( $field ) || empty( $value ) ) { |
|
| 71 | + if (empty($field) || empty($value)) { |
|
| 72 | 72 | return false; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - switch ( strtolower( $field ) ) { |
|
| 75 | + switch (strtolower($field)) { |
|
| 76 | 76 | |
| 77 | 77 | case 'id': |
| 78 | - $payment = new Give_Payment( $value ); |
|
| 78 | + $payment = new Give_Payment($value); |
|
| 79 | 79 | $id = $payment->ID; |
| 80 | 80 | |
| 81 | - if ( empty( $id ) ) { |
|
| 81 | + if (empty($id)) { |
|
| 82 | 82 | return false; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | break; |
| 86 | 86 | |
| 87 | 87 | case 'key': |
| 88 | - $payment = give_get_payments( array( |
|
| 88 | + $payment = give_get_payments(array( |
|
| 89 | 89 | 'meta_key' => '_give_payment_purchase_key', |
| 90 | 90 | 'meta_value' => $value, |
| 91 | 91 | 'posts_per_page' => 1, |
| 92 | 92 | 'fields' => 'ids', |
| 93 | - ) ); |
|
| 93 | + )); |
|
| 94 | 94 | |
| 95 | - if ( $payment ) { |
|
| 96 | - $payment = new Give_Payment( $payment[0] ); |
|
| 95 | + if ($payment) { |
|
| 96 | + $payment = new Give_Payment($payment[0]); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | break; |
| 100 | 100 | |
| 101 | 101 | case 'payment_number': |
| 102 | - $payment = give_get_payments( array( |
|
| 102 | + $payment = give_get_payments(array( |
|
| 103 | 103 | 'meta_key' => '_give_payment_number', |
| 104 | 104 | 'meta_value' => $value, |
| 105 | 105 | 'posts_per_page' => 1, |
| 106 | 106 | 'fields' => 'ids', |
| 107 | - ) ); |
|
| 107 | + )); |
|
| 108 | 108 | |
| 109 | - if ( $payment ) { |
|
| 110 | - $payment = new Give_Payment( $payment[0] ); |
|
| 109 | + if ($payment) { |
|
| 110 | + $payment = new Give_Payment($payment[0]); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | break; |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | return false; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - if ( $payment ) { |
|
| 119 | + if ($payment) { |
|
| 120 | 120 | return $payment; |
| 121 | 121 | } |
| 122 | 122 | |
@@ -132,23 +132,23 @@ discard block |
||
| 132 | 132 | * |
| 133 | 133 | * @return int|bool Payment ID if payment is inserted, false otherwise. |
| 134 | 134 | */ |
| 135 | -function give_insert_payment( $payment_data = array() ) { |
|
| 135 | +function give_insert_payment($payment_data = array()) { |
|
| 136 | 136 | |
| 137 | - if ( empty( $payment_data ) ) { |
|
| 137 | + if (empty($payment_data)) { |
|
| 138 | 138 | return false; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | $payment = new Give_Payment(); |
| 142 | - $gateway = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : ''; |
|
| 143 | - $gateway = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway; |
|
| 144 | - $form_id = isset( $payment_data['give_form_id'] ) ? $payment_data['give_form_id'] : 0; |
|
| 145 | - $price_id = isset( $payment_data['give_price_id'] ) ? $payment_data['give_price_id'] : give_get_price_id( $payment_data['give_form_id'], $payment_data['price'] ); |
|
| 146 | - $form_title = isset( $payment_data['give_form_title'] ) ? $payment_data['give_form_title'] : get_the_title( $form_id ); |
|
| 142 | + $gateway = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : ''; |
|
| 143 | + $gateway = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway; |
|
| 144 | + $form_id = isset($payment_data['give_form_id']) ? $payment_data['give_form_id'] : 0; |
|
| 145 | + $price_id = isset($payment_data['give_price_id']) ? $payment_data['give_price_id'] : give_get_price_id($payment_data['give_form_id'], $payment_data['price']); |
|
| 146 | + $form_title = isset($payment_data['give_form_title']) ? $payment_data['give_form_title'] : get_the_title($form_id); |
|
| 147 | 147 | |
| 148 | 148 | // Set properties. |
| 149 | 149 | $payment->total = $payment_data['price']; |
| 150 | - $payment->status = ! empty( $payment_data['status'] ) ? $payment_data['status'] : 'pending'; |
|
| 151 | - $payment->currency = ! empty( $payment_data['currency'] ) ? $payment_data['currency'] : give_get_currency(); |
|
| 150 | + $payment->status = ! empty($payment_data['status']) ? $payment_data['status'] : 'pending'; |
|
| 151 | + $payment->currency = ! empty($payment_data['currency']) ? $payment_data['currency'] : give_get_currency(); |
|
| 152 | 152 | $payment->user_info = $payment_data['user_info']; |
| 153 | 153 | $payment->gateway = $gateway; |
| 154 | 154 | $payment->form_title = $form_title; |
@@ -162,31 +162,31 @@ discard block |
||
| 162 | 162 | $payment->ip = give_get_ip(); |
| 163 | 163 | $payment->key = $payment_data['purchase_key']; |
| 164 | 164 | $payment->mode = give_is_test_mode() ? 'test' : 'live'; |
| 165 | - $payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : ''; |
|
| 165 | + $payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : ''; |
|
| 166 | 166 | |
| 167 | 167 | // Add the donation. |
| 168 | 168 | $args = array( |
| 169 | 169 | 'price' => $payment->total, |
| 170 | 170 | 'price_id' => $payment->price_id, |
| 171 | - 'fees' => isset( $payment_data['fees'] ) ? $payment_data['fees'] : array(), |
|
| 171 | + 'fees' => isset($payment_data['fees']) ? $payment_data['fees'] : array(), |
|
| 172 | 172 | ); |
| 173 | 173 | |
| 174 | - $payment->add_donation( $payment->form_id, $args ); |
|
| 174 | + $payment->add_donation($payment->form_id, $args); |
|
| 175 | 175 | |
| 176 | 176 | // Set date if present. |
| 177 | - if ( isset( $payment_data['post_date'] ) ) { |
|
| 177 | + if (isset($payment_data['post_date'])) { |
|
| 178 | 178 | $payment->date = $payment_data['post_date']; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | // Handle sequential payments. |
| 182 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
| 182 | + if (give_get_option('enable_sequential')) { |
|
| 183 | 183 | $number = give_get_next_payment_number(); |
| 184 | - $payment->number = give_format_payment_number( $number ); |
|
| 185 | - update_option( 'give_last_payment_number', $number ); |
|
| 184 | + $payment->number = give_format_payment_number($number); |
|
| 185 | + update_option('give_last_payment_number', $number); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | // Clear the user's donation cache. |
| 189 | - delete_transient( 'give_user_' . $payment_data['user_info']['id'] . '_purchases' ); |
|
| 189 | + delete_transient('give_user_'.$payment_data['user_info']['id'].'_purchases'); |
|
| 190 | 190 | |
| 191 | 191 | // Save payment. |
| 192 | 192 | $payment->save(); |
@@ -199,10 +199,10 @@ discard block |
||
| 199 | 199 | * @param int $payment_id The payment ID. |
| 200 | 200 | * @param array $payment_data Arguments passed. |
| 201 | 201 | */ |
| 202 | - do_action( 'give_insert_payment', $payment->ID, $payment_data ); |
|
| 202 | + do_action('give_insert_payment', $payment->ID, $payment_data); |
|
| 203 | 203 | |
| 204 | 204 | // Return payment ID upon success. |
| 205 | - if ( ! empty( $payment->ID ) ) { |
|
| 205 | + if ( ! empty($payment->ID)) { |
|
| 206 | 206 | return $payment->ID; |
| 207 | 207 | } |
| 208 | 208 | |
@@ -221,9 +221,9 @@ discard block |
||
| 221 | 221 | * |
| 222 | 222 | * @return bool |
| 223 | 223 | */ |
| 224 | -function give_update_payment_status( $payment_id, $new_status = 'publish' ) { |
|
| 224 | +function give_update_payment_status($payment_id, $new_status = 'publish') { |
|
| 225 | 225 | |
| 226 | - $payment = new Give_Payment( $payment_id ); |
|
| 226 | + $payment = new Give_Payment($payment_id); |
|
| 227 | 227 | $payment->status = $new_status; |
| 228 | 228 | $updated = $payment->save(); |
| 229 | 229 | |
@@ -242,37 +242,37 @@ discard block |
||
| 242 | 242 | * |
| 243 | 243 | * @return void |
| 244 | 244 | */ |
| 245 | -function give_delete_purchase( $payment_id = 0, $update_customer = true ) { |
|
| 245 | +function give_delete_purchase($payment_id = 0, $update_customer = true) { |
|
| 246 | 246 | global $give_logs; |
| 247 | 247 | |
| 248 | - $payment = new Give_Payment( $payment_id ); |
|
| 249 | - $amount = give_get_payment_amount( $payment_id ); |
|
| 248 | + $payment = new Give_Payment($payment_id); |
|
| 249 | + $amount = give_get_payment_amount($payment_id); |
|
| 250 | 250 | $status = $payment->post_status; |
| 251 | - $customer_id = give_get_payment_customer_id( $payment_id ); |
|
| 252 | - $customer = new Give_Customer( $customer_id ); |
|
| 251 | + $customer_id = give_get_payment_customer_id($payment_id); |
|
| 252 | + $customer = new Give_Customer($customer_id); |
|
| 253 | 253 | |
| 254 | 254 | // Only undo donations that aren't these statuses. |
| 255 | - $dont_undo_statuses = apply_filters( 'give_undo_purchase_statuses', array( |
|
| 255 | + $dont_undo_statuses = apply_filters('give_undo_purchase_statuses', array( |
|
| 256 | 256 | 'pending', |
| 257 | 257 | 'cancelled', |
| 258 | - ) ); |
|
| 258 | + )); |
|
| 259 | 259 | |
| 260 | - if ( ! in_array( $status, $dont_undo_statuses ) ) { |
|
| 261 | - give_undo_purchase( false, $payment_id ); |
|
| 260 | + if ( ! in_array($status, $dont_undo_statuses)) { |
|
| 261 | + give_undo_purchase(false, $payment_id); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - if ( $status == 'publish' ) { |
|
| 264 | + if ($status == 'publish') { |
|
| 265 | 265 | |
| 266 | 266 | // Only decrease earnings if they haven't already been decreased (or were never increased for this payment). |
| 267 | - give_decrease_total_earnings( $amount ); |
|
| 267 | + give_decrease_total_earnings($amount); |
|
| 268 | 268 | // Clear the This Month earnings (this_monththis_month is NOT a typo). |
| 269 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
| 269 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
| 270 | 270 | |
| 271 | - if ( $customer->id && $update_customer ) { |
|
| 271 | + if ($customer->id && $update_customer) { |
|
| 272 | 272 | |
| 273 | 273 | // Decrement the stats for the customer. |
| 274 | 274 | $customer->decrease_purchase_count(); |
| 275 | - $customer->decrease_value( $amount ); |
|
| 275 | + $customer->decrease_value($amount); |
|
| 276 | 276 | |
| 277 | 277 | } |
| 278 | 278 | } |
@@ -284,17 +284,17 @@ discard block |
||
| 284 | 284 | * |
| 285 | 285 | * @param int $payment_id Payment ID. |
| 286 | 286 | */ |
| 287 | - do_action( 'give_payment_delete', $payment_id ); |
|
| 287 | + do_action('give_payment_delete', $payment_id); |
|
| 288 | 288 | |
| 289 | - if ( $customer->id && $update_customer ) { |
|
| 289 | + if ($customer->id && $update_customer) { |
|
| 290 | 290 | |
| 291 | 291 | // Remove the payment ID from the customer. |
| 292 | - $customer->remove_payment( $payment_id ); |
|
| 292 | + $customer->remove_payment($payment_id); |
|
| 293 | 293 | |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | // Remove the payment. |
| 297 | - wp_delete_post( $payment_id, true ); |
|
| 297 | + wp_delete_post($payment_id, true); |
|
| 298 | 298 | |
| 299 | 299 | // Remove related sale log entries. |
| 300 | 300 | $give_logs->delete_logs( |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | * |
| 316 | 316 | * @param int $payment_id Payment ID. |
| 317 | 317 | */ |
| 318 | - do_action( 'give_payment_deleted', $payment_id ); |
|
| 318 | + do_action('give_payment_deleted', $payment_id); |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | /** |
@@ -331,25 +331,25 @@ discard block |
||
| 331 | 331 | * |
| 332 | 332 | * @return void |
| 333 | 333 | */ |
| 334 | -function give_undo_purchase( $form_id = false, $payment_id ) { |
|
| 334 | +function give_undo_purchase($form_id = false, $payment_id) { |
|
| 335 | 335 | |
| 336 | - if ( ! empty( $form_id ) ) { |
|
| 336 | + if ( ! empty($form_id)) { |
|
| 337 | 337 | $form_id = false; |
| 338 | - _give_deprected_argument( 'form_id', 'give_undo_purchase', '1.5' ); |
|
| 338 | + _give_deprected_argument('form_id', 'give_undo_purchase', '1.5'); |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | - $payment = new Give_Payment( $payment_id ); |
|
| 341 | + $payment = new Give_Payment($payment_id); |
|
| 342 | 342 | |
| 343 | - $maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id ); |
|
| 344 | - if ( true === $maybe_decrease_earnings ) { |
|
| 343 | + $maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id); |
|
| 344 | + if (true === $maybe_decrease_earnings) { |
|
| 345 | 345 | // Decrease earnings. |
| 346 | - give_decrease_earnings( $payment->form_id, $payment->total ); |
|
| 346 | + give_decrease_earnings($payment->form_id, $payment->total); |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - $maybe_decrease_sales = apply_filters( 'give_decrease_sales_on_undo', true, $payment, $payment->form_id ); |
|
| 350 | - if ( true === $maybe_decrease_sales ) { |
|
| 349 | + $maybe_decrease_sales = apply_filters('give_decrease_sales_on_undo', true, $payment, $payment->form_id); |
|
| 350 | + if (true === $maybe_decrease_sales) { |
|
| 351 | 351 | // Decrease donation count. |
| 352 | - give_decrease_purchase_count( $payment->form_id ); |
|
| 352 | + give_decrease_purchase_count($payment->form_id); |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | } |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | * |
| 367 | 367 | * @return array $count Number of payments sorted by payment status. |
| 368 | 368 | */ |
| 369 | -function give_count_payments( $args = array() ) { |
|
| 369 | +function give_count_payments($args = array()) { |
|
| 370 | 370 | |
| 371 | 371 | global $wpdb; |
| 372 | 372 | |
@@ -378,18 +378,18 @@ discard block |
||
| 378 | 378 | 'form_id' => null, |
| 379 | 379 | ); |
| 380 | 380 | |
| 381 | - $args = wp_parse_args( $args, $defaults ); |
|
| 381 | + $args = wp_parse_args($args, $defaults); |
|
| 382 | 382 | |
| 383 | 383 | $select = 'SELECT p.post_status,count( * ) AS num_posts'; |
| 384 | 384 | $join = ''; |
| 385 | 385 | $where = "WHERE p.post_type = 'give_payment'"; |
| 386 | 386 | |
| 387 | 387 | // Count payments for a specific user. |
| 388 | - if ( ! empty( $args['user'] ) ) { |
|
| 388 | + if ( ! empty($args['user'])) { |
|
| 389 | 389 | |
| 390 | - if ( is_email( $args['user'] ) ) { |
|
| 390 | + if (is_email($args['user'])) { |
|
| 391 | 391 | $field = 'email'; |
| 392 | - } elseif ( is_numeric( $args['user'] ) ) { |
|
| 392 | + } elseif (is_numeric($args['user'])) { |
|
| 393 | 393 | $field = 'id'; |
| 394 | 394 | } else { |
| 395 | 395 | $field = ''; |
@@ -397,105 +397,105 @@ discard block |
||
| 397 | 397 | |
| 398 | 398 | $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
| 399 | 399 | |
| 400 | - if ( ! empty( $field ) ) { |
|
| 400 | + if ( ! empty($field)) { |
|
| 401 | 401 | $where .= " |
| 402 | 402 | AND m.meta_key = '_give_payment_user_{$field}' |
| 403 | 403 | AND m.meta_value = '{$args['user']}'"; |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | // Count payments for a search. |
| 407 | - } elseif ( ! empty( $args['s'] ) ) { |
|
| 407 | + } elseif ( ! empty($args['s'])) { |
|
| 408 | 408 | |
| 409 | - if ( is_email( $args['s'] ) || strlen( $args['s'] ) == 32 ) { |
|
| 409 | + if (is_email($args['s']) || strlen($args['s']) == 32) { |
|
| 410 | 410 | |
| 411 | - if ( is_email( $args['s'] ) ) { |
|
| 411 | + if (is_email($args['s'])) { |
|
| 412 | 412 | $field = '_give_payment_user_email'; |
| 413 | 413 | } else { |
| 414 | 414 | $field = '_give_payment_purchase_key'; |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
| 418 | - $where .= $wpdb->prepare( ' |
|
| 418 | + $where .= $wpdb->prepare(' |
|
| 419 | 419 | AND m.meta_key = %s |
| 420 | 420 | AND m.meta_value = %s', |
| 421 | 421 | $field, |
| 422 | 422 | $args['s'] |
| 423 | 423 | ); |
| 424 | 424 | |
| 425 | - } elseif ( '#' == substr( $args['s'], 0, 1 ) ) { |
|
| 425 | + } elseif ('#' == substr($args['s'], 0, 1)) { |
|
| 426 | 426 | |
| 427 | - $search = str_replace( '#:', '', $args['s'] ); |
|
| 428 | - $search = str_replace( '#', '', $search ); |
|
| 427 | + $search = str_replace('#:', '', $args['s']); |
|
| 428 | + $search = str_replace('#', '', $search); |
|
| 429 | 429 | |
| 430 | 430 | $select = 'SELECT p2.post_status,count( * ) AS num_posts '; |
| 431 | 431 | $join = "LEFT JOIN $wpdb->postmeta m ON m.meta_key = '_give_log_payment_id' AND m.post_id = p.ID "; |
| 432 | 432 | $join .= "INNER JOIN $wpdb->posts p2 ON m.meta_value = p2.ID "; |
| 433 | 433 | $where = "WHERE p.post_type = 'give_log' "; |
| 434 | - $where .= $wpdb->prepare( 'AND p.post_parent = %d} ', $search ); |
|
| 434 | + $where .= $wpdb->prepare('AND p.post_parent = %d} ', $search); |
|
| 435 | 435 | |
| 436 | - } elseif ( is_numeric( $args['s'] ) ) { |
|
| 436 | + } elseif (is_numeric($args['s'])) { |
|
| 437 | 437 | |
| 438 | 438 | $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
| 439 | - $where .= $wpdb->prepare( " |
|
| 439 | + $where .= $wpdb->prepare(" |
|
| 440 | 440 | AND m.meta_key = '_give_payment_user_id' |
| 441 | 441 | AND m.meta_value = %d", |
| 442 | 442 | $args['s'] |
| 443 | 443 | ); |
| 444 | 444 | |
| 445 | 445 | } else { |
| 446 | - $search = $wpdb->esc_like( $args['s'] ); |
|
| 447 | - $search = '%' . $search . '%'; |
|
| 446 | + $search = $wpdb->esc_like($args['s']); |
|
| 447 | + $search = '%'.$search.'%'; |
|
| 448 | 448 | |
| 449 | - $where .= $wpdb->prepare( 'AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search ); |
|
| 449 | + $where .= $wpdb->prepare('AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search); |
|
| 450 | 450 | } |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | - if ( ! empty( $args['form_id'] ) && is_numeric( $args['form_id'] ) ) { |
|
| 453 | + if ( ! empty($args['form_id']) && is_numeric($args['form_id'])) { |
|
| 454 | 454 | |
| 455 | - $where .= $wpdb->prepare( ' AND p.post_parent = %d', $args['form_id'] ); |
|
| 455 | + $where .= $wpdb->prepare(' AND p.post_parent = %d', $args['form_id']); |
|
| 456 | 456 | |
| 457 | 457 | } |
| 458 | 458 | // Limit payments count by date. |
| 459 | - if ( ! empty( $args['start-date'] ) && false !== strpos( $args['start-date'], '/' ) ) { |
|
| 459 | + if ( ! empty($args['start-date']) && false !== strpos($args['start-date'], '/')) { |
|
| 460 | 460 | |
| 461 | - $date_parts = explode( '/', $args['start-date'] ); |
|
| 462 | - $month = ! empty( $date_parts[0] ) && is_numeric( $date_parts[0] ) ? $date_parts[0] : 0; |
|
| 463 | - $day = ! empty( $date_parts[1] ) && is_numeric( $date_parts[1] ) ? $date_parts[1] : 0; |
|
| 464 | - $year = ! empty( $date_parts[2] ) && is_numeric( $date_parts[2] ) ? $date_parts[2] : 0; |
|
| 461 | + $date_parts = explode('/', $args['start-date']); |
|
| 462 | + $month = ! empty($date_parts[0]) && is_numeric($date_parts[0]) ? $date_parts[0] : 0; |
|
| 463 | + $day = ! empty($date_parts[1]) && is_numeric($date_parts[1]) ? $date_parts[1] : 0; |
|
| 464 | + $year = ! empty($date_parts[2]) && is_numeric($date_parts[2]) ? $date_parts[2] : 0; |
|
| 465 | 465 | |
| 466 | - $is_date = checkdate( $month, $day, $year ); |
|
| 467 | - if ( false !== $is_date ) { |
|
| 466 | + $is_date = checkdate($month, $day, $year); |
|
| 467 | + if (false !== $is_date) { |
|
| 468 | 468 | |
| 469 | - $date = new DateTime( $args['start-date'] ); |
|
| 470 | - $where .= $wpdb->prepare( " AND p.post_date >= '%s'", $date->format( 'Y-m-d' ) ); |
|
| 469 | + $date = new DateTime($args['start-date']); |
|
| 470 | + $where .= $wpdb->prepare(" AND p.post_date >= '%s'", $date->format('Y-m-d')); |
|
| 471 | 471 | |
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | // Fixes an issue with the payments list table counts when no end date is specified (partiy with stats class). |
| 475 | - if ( empty( $args['end-date'] ) ) { |
|
| 475 | + if (empty($args['end-date'])) { |
|
| 476 | 476 | $args['end-date'] = $args['start-date']; |
| 477 | 477 | } |
| 478 | 478 | } |
| 479 | 479 | |
| 480 | - if ( ! empty( $args['end-date'] ) && false !== strpos( $args['end-date'], '/' ) ) { |
|
| 480 | + if ( ! empty($args['end-date']) && false !== strpos($args['end-date'], '/')) { |
|
| 481 | 481 | |
| 482 | - $date_parts = explode( '/', $args['end-date'] ); |
|
| 482 | + $date_parts = explode('/', $args['end-date']); |
|
| 483 | 483 | |
| 484 | - $month = ! empty( $date_parts[0] ) ? $date_parts[0] : 0; |
|
| 485 | - $day = ! empty( $date_parts[1] ) ? $date_parts[1] : 0; |
|
| 486 | - $year = ! empty( $date_parts[2] ) ? $date_parts[2] : 0; |
|
| 484 | + $month = ! empty($date_parts[0]) ? $date_parts[0] : 0; |
|
| 485 | + $day = ! empty($date_parts[1]) ? $date_parts[1] : 0; |
|
| 486 | + $year = ! empty($date_parts[2]) ? $date_parts[2] : 0; |
|
| 487 | 487 | |
| 488 | - $is_date = checkdate( $month, $day, $year ); |
|
| 489 | - if ( false !== $is_date ) { |
|
| 488 | + $is_date = checkdate($month, $day, $year); |
|
| 489 | + if (false !== $is_date) { |
|
| 490 | 490 | |
| 491 | - $date = new DateTime( $args['end-date'] ); |
|
| 492 | - $where .= $wpdb->prepare( " AND p.post_date <= '%s'", $date->format( 'Y-m-d' ) ); |
|
| 491 | + $date = new DateTime($args['end-date']); |
|
| 492 | + $where .= $wpdb->prepare(" AND p.post_date <= '%s'", $date->format('Y-m-d')); |
|
| 493 | 493 | |
| 494 | 494 | } |
| 495 | 495 | } |
| 496 | 496 | |
| 497 | - $where = apply_filters( 'give_count_payments_where', $where ); |
|
| 498 | - $join = apply_filters( 'give_count_payments_join', $join ); |
|
| 497 | + $where = apply_filters('give_count_payments_where', $where); |
|
| 498 | + $join = apply_filters('give_count_payments_join', $join); |
|
| 499 | 499 | |
| 500 | 500 | $query = "$select |
| 501 | 501 | FROM $wpdb->posts p |
@@ -504,36 +504,36 @@ discard block |
||
| 504 | 504 | GROUP BY p.post_status |
| 505 | 505 | "; |
| 506 | 506 | |
| 507 | - $cache_key = md5( $query ); |
|
| 507 | + $cache_key = md5($query); |
|
| 508 | 508 | |
| 509 | - $count = wp_cache_get( $cache_key, 'counts' ); |
|
| 510 | - if ( false !== $count ) { |
|
| 509 | + $count = wp_cache_get($cache_key, 'counts'); |
|
| 510 | + if (false !== $count) { |
|
| 511 | 511 | return $count; |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | - $count = $wpdb->get_results( $query, ARRAY_A ); |
|
| 514 | + $count = $wpdb->get_results($query, ARRAY_A); |
|
| 515 | 515 | |
| 516 | 516 | $stats = array(); |
| 517 | 517 | $statuses = get_post_stati(); |
| 518 | - if ( isset( $statuses['private'] ) && empty( $args['s'] ) ) { |
|
| 519 | - unset( $statuses['private'] ); |
|
| 518 | + if (isset($statuses['private']) && empty($args['s'])) { |
|
| 519 | + unset($statuses['private']); |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | - foreach ( $statuses as $state ) { |
|
| 523 | - $stats[ $state ] = 0; |
|
| 522 | + foreach ($statuses as $state) { |
|
| 523 | + $stats[$state] = 0; |
|
| 524 | 524 | } |
| 525 | 525 | |
| 526 | - foreach ( (array) $count as $row ) { |
|
| 526 | + foreach ((array) $count as $row) { |
|
| 527 | 527 | |
| 528 | - if ( 'private' == $row['post_status'] && empty( $args['s'] ) ) { |
|
| 528 | + if ('private' == $row['post_status'] && empty($args['s'])) { |
|
| 529 | 529 | continue; |
| 530 | 530 | } |
| 531 | 531 | |
| 532 | - $stats[ $row['post_status'] ] = $row['num_posts']; |
|
| 532 | + $stats[$row['post_status']] = $row['num_posts']; |
|
| 533 | 533 | } |
| 534 | 534 | |
| 535 | 535 | $stats = (object) $stats; |
| 536 | - wp_cache_set( $cache_key, $stats, 'counts' ); |
|
| 536 | + wp_cache_set($cache_key, $stats, 'counts'); |
|
| 537 | 537 | |
| 538 | 538 | return $stats; |
| 539 | 539 | } |
@@ -548,11 +548,11 @@ discard block |
||
| 548 | 548 | * |
| 549 | 549 | * @return bool $exists True if payment exists, false otherwise. |
| 550 | 550 | */ |
| 551 | -function give_check_for_existing_payment( $payment_id ) { |
|
| 551 | +function give_check_for_existing_payment($payment_id) { |
|
| 552 | 552 | $exists = false; |
| 553 | - $payment = new Give_Payment( $payment_id ); |
|
| 553 | + $payment = new Give_Payment($payment_id); |
|
| 554 | 554 | |
| 555 | - if ( $payment_id === $payment->ID && 'publish' === $payment->status ) { |
|
| 555 | + if ($payment_id === $payment->ID && 'publish' === $payment->status) { |
|
| 556 | 556 | $exists = true; |
| 557 | 557 | } |
| 558 | 558 | |
@@ -569,24 +569,24 @@ discard block |
||
| 569 | 569 | * instead of status value. Default false. |
| 570 | 570 | * @return bool|mixed True if payment status exists, false otherwise. |
| 571 | 571 | */ |
| 572 | -function give_get_payment_status( $payment, $return_label = false ) { |
|
| 572 | +function give_get_payment_status($payment, $return_label = false) { |
|
| 573 | 573 | |
| 574 | - if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) { |
|
| 574 | + if ( ! is_object($payment) || ! isset($payment->post_status)) { |
|
| 575 | 575 | return false; |
| 576 | 576 | } |
| 577 | 577 | |
| 578 | 578 | $statuses = give_get_payment_statuses(); |
| 579 | 579 | |
| 580 | - if ( ! is_array( $statuses ) || empty( $statuses ) ) { |
|
| 580 | + if ( ! is_array($statuses) || empty($statuses)) { |
|
| 581 | 581 | return false; |
| 582 | 582 | } |
| 583 | 583 | |
| 584 | - $payment = new Give_Payment( $payment->ID ); |
|
| 584 | + $payment = new Give_Payment($payment->ID); |
|
| 585 | 585 | |
| 586 | - if ( array_key_exists( $payment->status, $statuses ) ) { |
|
| 587 | - if ( true === $return_label ) { |
|
| 586 | + if (array_key_exists($payment->status, $statuses)) { |
|
| 587 | + if (true === $return_label) { |
|
| 588 | 588 | // Return translated status label. |
| 589 | - return $statuses[ $payment->status ]; |
|
| 589 | + return $statuses[$payment->status]; |
|
| 590 | 590 | } else { |
| 591 | 591 | // Return status value. |
| 592 | 592 | return $payment->status; |
@@ -605,17 +605,17 @@ discard block |
||
| 605 | 605 | */ |
| 606 | 606 | function give_get_payment_statuses() { |
| 607 | 607 | $payment_statuses = array( |
| 608 | - 'pending' => esc_html__( 'Pending', 'give' ), |
|
| 609 | - 'publish' => esc_html__( 'Complete', 'give' ), |
|
| 610 | - 'refunded' => esc_html__( 'Refunded', 'give' ), |
|
| 611 | - 'failed' => esc_html__( 'Failed', 'give' ), |
|
| 612 | - 'cancelled' => esc_html__( 'Cancelled', 'give' ), |
|
| 613 | - 'abandoned' => esc_html__( 'Abandoned', 'give' ), |
|
| 614 | - 'preapproval' => esc_html__( 'Pre-Approved', 'give' ), |
|
| 615 | - 'revoked' => esc_html__( 'Revoked', 'give' ), |
|
| 608 | + 'pending' => esc_html__('Pending', 'give'), |
|
| 609 | + 'publish' => esc_html__('Complete', 'give'), |
|
| 610 | + 'refunded' => esc_html__('Refunded', 'give'), |
|
| 611 | + 'failed' => esc_html__('Failed', 'give'), |
|
| 612 | + 'cancelled' => esc_html__('Cancelled', 'give'), |
|
| 613 | + 'abandoned' => esc_html__('Abandoned', 'give'), |
|
| 614 | + 'preapproval' => esc_html__('Pre-Approved', 'give'), |
|
| 615 | + 'revoked' => esc_html__('Revoked', 'give'), |
|
| 616 | 616 | ); |
| 617 | 617 | |
| 618 | - return apply_filters( 'give_payment_statuses', $payment_statuses ); |
|
| 618 | + return apply_filters('give_payment_statuses', $payment_statuses); |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | /** |
@@ -628,10 +628,10 @@ discard block |
||
| 628 | 628 | * @return array $payment_status All the available payment statuses. |
| 629 | 629 | */ |
| 630 | 630 | function give_get_payment_status_keys() { |
| 631 | - $statuses = array_keys( give_get_payment_statuses() ); |
|
| 632 | - asort( $statuses ); |
|
| 631 | + $statuses = array_keys(give_get_payment_statuses()); |
|
| 632 | + asort($statuses); |
|
| 633 | 633 | |
| 634 | - return array_values( $statuses ); |
|
| 634 | + return array_values($statuses); |
|
| 635 | 635 | } |
| 636 | 636 | |
| 637 | 637 | /** |
@@ -646,7 +646,7 @@ discard block |
||
| 646 | 646 | * |
| 647 | 647 | * @return int $earnings Earnings |
| 648 | 648 | */ |
| 649 | -function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) { |
|
| 649 | +function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) { |
|
| 650 | 650 | |
| 651 | 651 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead. |
| 652 | 652 | global $wpdb; |
@@ -656,41 +656,41 @@ discard block |
||
| 656 | 656 | 'nopaging' => true, |
| 657 | 657 | 'year' => $year, |
| 658 | 658 | 'monthnum' => $month_num, |
| 659 | - 'post_status' => array( 'publish' ), |
|
| 659 | + 'post_status' => array('publish'), |
|
| 660 | 660 | 'fields' => 'ids', |
| 661 | 661 | 'update_post_term_cache' => false, |
| 662 | 662 | ); |
| 663 | - if ( ! empty( $day ) ) { |
|
| 663 | + if ( ! empty($day)) { |
|
| 664 | 664 | $args['day'] = $day; |
| 665 | 665 | } |
| 666 | 666 | |
| 667 | - if ( ! empty( $hour ) ) { |
|
| 667 | + if ( ! empty($hour)) { |
|
| 668 | 668 | $args['hour'] = $hour; |
| 669 | 669 | } |
| 670 | 670 | |
| 671 | - $args = apply_filters( 'give_get_earnings_by_date_args', $args ); |
|
| 672 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
| 671 | + $args = apply_filters('give_get_earnings_by_date_args', $args); |
|
| 672 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
| 673 | 673 | |
| 674 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
| 674 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
| 675 | 675 | $earnings = false; |
| 676 | 676 | } else { |
| 677 | - $earnings = get_transient( $key ); |
|
| 677 | + $earnings = get_transient($key); |
|
| 678 | 678 | } |
| 679 | 679 | |
| 680 | - if ( false === $earnings ) { |
|
| 681 | - $sales = get_posts( $args ); |
|
| 680 | + if (false === $earnings) { |
|
| 681 | + $sales = get_posts($args); |
|
| 682 | 682 | $earnings = 0; |
| 683 | - if ( $sales ) { |
|
| 684 | - $sales = implode( ',', $sales ); |
|
| 683 | + if ($sales) { |
|
| 684 | + $sales = implode(',', $sales); |
|
| 685 | 685 | |
| 686 | - $earnings = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$sales})" ); |
|
| 686 | + $earnings = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$sales})"); |
|
| 687 | 687 | |
| 688 | 688 | } |
| 689 | 689 | // Cache the results for one hour. |
| 690 | - set_transient( $key, $earnings, HOUR_IN_SECONDS ); |
|
| 690 | + set_transient($key, $earnings, HOUR_IN_SECONDS); |
|
| 691 | 691 | } |
| 692 | 692 | |
| 693 | - return round( $earnings, 2 ); |
|
| 693 | + return round($earnings, 2); |
|
| 694 | 694 | } |
| 695 | 695 | |
| 696 | 696 | /** |
@@ -705,7 +705,7 @@ discard block |
||
| 705 | 705 | * |
| 706 | 706 | * @return int $count Sales |
| 707 | 707 | */ |
| 708 | -function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) { |
|
| 708 | +function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) { |
|
| 709 | 709 | |
| 710 | 710 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead. |
| 711 | 711 | $args = array( |
@@ -713,14 +713,14 @@ discard block |
||
| 713 | 713 | 'nopaging' => true, |
| 714 | 714 | 'year' => $year, |
| 715 | 715 | 'fields' => 'ids', |
| 716 | - 'post_status' => array( 'publish' ), |
|
| 716 | + 'post_status' => array('publish'), |
|
| 717 | 717 | 'update_post_meta_cache' => false, |
| 718 | 718 | 'update_post_term_cache' => false, |
| 719 | 719 | ); |
| 720 | 720 | |
| 721 | - $show_free = apply_filters( 'give_sales_by_date_show_free', true, $args ); |
|
| 721 | + $show_free = apply_filters('give_sales_by_date_show_free', true, $args); |
|
| 722 | 722 | |
| 723 | - if ( false === $show_free ) { |
|
| 723 | + if (false === $show_free) { |
|
| 724 | 724 | $args['meta_query'] = array( |
| 725 | 725 | array( |
| 726 | 726 | 'key' => '_give_payment_total', |
@@ -731,33 +731,33 @@ discard block |
||
| 731 | 731 | ); |
| 732 | 732 | } |
| 733 | 733 | |
| 734 | - if ( ! empty( $month_num ) ) { |
|
| 734 | + if ( ! empty($month_num)) { |
|
| 735 | 735 | $args['monthnum'] = $month_num; |
| 736 | 736 | } |
| 737 | 737 | |
| 738 | - if ( ! empty( $day ) ) { |
|
| 738 | + if ( ! empty($day)) { |
|
| 739 | 739 | $args['day'] = $day; |
| 740 | 740 | } |
| 741 | 741 | |
| 742 | - if ( ! empty( $hour ) ) { |
|
| 742 | + if ( ! empty($hour)) { |
|
| 743 | 743 | $args['hour'] = $hour; |
| 744 | 744 | } |
| 745 | 745 | |
| 746 | - $args = apply_filters( 'give_get_sales_by_date_args', $args ); |
|
| 746 | + $args = apply_filters('give_get_sales_by_date_args', $args); |
|
| 747 | 747 | |
| 748 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
| 748 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
| 749 | 749 | |
| 750 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
| 750 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
| 751 | 751 | $count = false; |
| 752 | 752 | } else { |
| 753 | - $count = get_transient( $key ); |
|
| 753 | + $count = get_transient($key); |
|
| 754 | 754 | } |
| 755 | 755 | |
| 756 | - if ( false === $count ) { |
|
| 757 | - $sales = new WP_Query( $args ); |
|
| 756 | + if (false === $count) { |
|
| 757 | + $sales = new WP_Query($args); |
|
| 758 | 758 | $count = (int) $sales->post_count; |
| 759 | 759 | // Cache the results for one hour. |
| 760 | - set_transient( $key, $count, HOUR_IN_SECONDS ); |
|
| 760 | + set_transient($key, $count, HOUR_IN_SECONDS); |
|
| 761 | 761 | } |
| 762 | 762 | |
| 763 | 763 | return $count; |
@@ -772,19 +772,19 @@ discard block |
||
| 772 | 772 | * |
| 773 | 773 | * @return bool $ret True if complete, false otherwise. |
| 774 | 774 | */ |
| 775 | -function give_is_payment_complete( $payment_id ) { |
|
| 776 | - $payment = new Give_Payment( $payment_id ); |
|
| 775 | +function give_is_payment_complete($payment_id) { |
|
| 776 | + $payment = new Give_Payment($payment_id); |
|
| 777 | 777 | |
| 778 | 778 | $ret = false; |
| 779 | 779 | |
| 780 | - if ( $payment->ID > 0 ) { |
|
| 780 | + if ($payment->ID > 0) { |
|
| 781 | 781 | |
| 782 | - if ( (int) $payment_id === (int) $payment->ID && 'publish' == $payment->status ) { |
|
| 782 | + if ((int) $payment_id === (int) $payment->ID && 'publish' == $payment->status) { |
|
| 783 | 783 | $ret = true; |
| 784 | 784 | } |
| 785 | 785 | } |
| 786 | 786 | |
| 787 | - return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status ); |
|
| 787 | + return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status); |
|
| 788 | 788 | } |
| 789 | 789 | |
| 790 | 790 | /** |
@@ -810,28 +810,28 @@ discard block |
||
| 810 | 810 | */ |
| 811 | 811 | function give_get_total_earnings() { |
| 812 | 812 | |
| 813 | - $total = get_option( 'give_earnings_total', false ); |
|
| 813 | + $total = get_option('give_earnings_total', false); |
|
| 814 | 814 | |
| 815 | 815 | // If no total stored in DB, use old method of calculating total earnings. |
| 816 | - if ( false === $total ) { |
|
| 816 | + if (false === $total) { |
|
| 817 | 817 | |
| 818 | 818 | global $wpdb; |
| 819 | 819 | |
| 820 | - $total = get_transient( 'give_earnings_total' ); |
|
| 820 | + $total = get_transient('give_earnings_total'); |
|
| 821 | 821 | |
| 822 | - if ( false === $total ) { |
|
| 822 | + if (false === $total) { |
|
| 823 | 823 | |
| 824 | 824 | $total = (float) 0; |
| 825 | 825 | |
| 826 | - $args = apply_filters( 'give_get_total_earnings_args', array( |
|
| 826 | + $args = apply_filters('give_get_total_earnings_args', array( |
|
| 827 | 827 | 'offset' => 0, |
| 828 | - 'number' => - 1, |
|
| 829 | - 'status' => array( 'publish' ), |
|
| 828 | + 'number' => -1, |
|
| 829 | + 'status' => array('publish'), |
|
| 830 | 830 | 'fields' => 'ids', |
| 831 | - ) ); |
|
| 831 | + )); |
|
| 832 | 832 | |
| 833 | - $payments = give_get_payments( $args ); |
|
| 834 | - if ( $payments ) { |
|
| 833 | + $payments = give_get_payments($args); |
|
| 834 | + if ($payments) { |
|
| 835 | 835 | |
| 836 | 836 | /* |
| 837 | 837 | * If performing a donation, we need to skip the very last payment in the database, |
@@ -839,29 +839,29 @@ discard block |
||
| 839 | 839 | * which results in duplicated earnings for the very first donation. |
| 840 | 840 | */ |
| 841 | 841 | |
| 842 | - if ( did_action( 'give_update_payment_status' ) ) { |
|
| 843 | - array_pop( $payments ); |
|
| 842 | + if (did_action('give_update_payment_status')) { |
|
| 843 | + array_pop($payments); |
|
| 844 | 844 | } |
| 845 | 845 | |
| 846 | - if ( ! empty( $payments ) ) { |
|
| 847 | - $payments = implode( ',', $payments ); |
|
| 848 | - $total += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})" ); |
|
| 846 | + if ( ! empty($payments)) { |
|
| 847 | + $payments = implode(',', $payments); |
|
| 848 | + $total += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})"); |
|
| 849 | 849 | } |
| 850 | 850 | } |
| 851 | 851 | |
| 852 | 852 | // Cache results for 1 day. This cache is cleared automatically when a payment is made. |
| 853 | - set_transient( 'give_earnings_total', $total, 86400 ); |
|
| 853 | + set_transient('give_earnings_total', $total, 86400); |
|
| 854 | 854 | |
| 855 | 855 | // Store the total for the first time. |
| 856 | - update_option( 'give_earnings_total', $total ); |
|
| 856 | + update_option('give_earnings_total', $total); |
|
| 857 | 857 | } |
| 858 | 858 | } |
| 859 | 859 | |
| 860 | - if ( $total < 0 ) { |
|
| 860 | + if ($total < 0) { |
|
| 861 | 861 | $total = 0; // Don't ever show negative earnings. |
| 862 | 862 | } |
| 863 | 863 | |
| 864 | - return apply_filters( 'give_total_earnings', round( $total, give_currency_decimal_filter() ) ); |
|
| 864 | + return apply_filters('give_total_earnings', round($total, give_currency_decimal_filter())); |
|
| 865 | 865 | } |
| 866 | 866 | |
| 867 | 867 | /** |
@@ -874,10 +874,10 @@ discard block |
||
| 874 | 874 | * |
| 875 | 875 | * @return float $total Total earnings. |
| 876 | 876 | */ |
| 877 | -function give_increase_total_earnings( $amount = 0 ) { |
|
| 877 | +function give_increase_total_earnings($amount = 0) { |
|
| 878 | 878 | $total = give_get_total_earnings(); |
| 879 | 879 | $total += $amount; |
| 880 | - update_option( 'give_earnings_total', $total ); |
|
| 880 | + update_option('give_earnings_total', $total); |
|
| 881 | 881 | |
| 882 | 882 | return $total; |
| 883 | 883 | } |
@@ -891,13 +891,13 @@ discard block |
||
| 891 | 891 | * |
| 892 | 892 | * @return float $total Total earnings. |
| 893 | 893 | */ |
| 894 | -function give_decrease_total_earnings( $amount = 0 ) { |
|
| 894 | +function give_decrease_total_earnings($amount = 0) { |
|
| 895 | 895 | $total = give_get_total_earnings(); |
| 896 | 896 | $total -= $amount; |
| 897 | - if ( $total < 0 ) { |
|
| 897 | + if ($total < 0) { |
|
| 898 | 898 | $total = 0; |
| 899 | 899 | } |
| 900 | - update_option( 'give_earnings_total', $total ); |
|
| 900 | + update_option('give_earnings_total', $total); |
|
| 901 | 901 | |
| 902 | 902 | return $total; |
| 903 | 903 | } |
@@ -913,10 +913,10 @@ discard block |
||
| 913 | 913 | * |
| 914 | 914 | * @return mixed $meta Payment Meta. |
| 915 | 915 | */ |
| 916 | -function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) { |
|
| 917 | - $payment = new Give_Payment( $payment_id ); |
|
| 916 | +function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) { |
|
| 917 | + $payment = new Give_Payment($payment_id); |
|
| 918 | 918 | |
| 919 | - return $payment->get_meta( $meta_key, $single ); |
|
| 919 | + return $payment->get_meta($meta_key, $single); |
|
| 920 | 920 | } |
| 921 | 921 | |
| 922 | 922 | /** |
@@ -929,10 +929,10 @@ discard block |
||
| 929 | 929 | * |
| 930 | 930 | * @return mixed Meta ID if successful, false if unsuccessful. |
| 931 | 931 | */ |
| 932 | -function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
| 933 | - $payment = new Give_Payment( $payment_id ); |
|
| 932 | +function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') { |
|
| 933 | + $payment = new Give_Payment($payment_id); |
|
| 934 | 934 | |
| 935 | - return $payment->update_meta( $meta_key, $meta_value, $prev_value ); |
|
| 935 | + return $payment->update_meta($meta_key, $meta_value, $prev_value); |
|
| 936 | 936 | } |
| 937 | 937 | |
| 938 | 938 | /** |
@@ -944,8 +944,8 @@ discard block |
||
| 944 | 944 | * |
| 945 | 945 | * @return string $user_info User Info Meta Values. |
| 946 | 946 | */ |
| 947 | -function give_get_payment_meta_user_info( $payment_id ) { |
|
| 948 | - $payment = new Give_Payment( $payment_id ); |
|
| 947 | +function give_get_payment_meta_user_info($payment_id) { |
|
| 948 | + $payment = new Give_Payment($payment_id); |
|
| 949 | 949 | |
| 950 | 950 | return $payment->user_info; |
| 951 | 951 | } |
@@ -961,8 +961,8 @@ discard block |
||
| 961 | 961 | * |
| 962 | 962 | * @return int $form_id Form ID. |
| 963 | 963 | */ |
| 964 | -function give_get_payment_form_id( $payment_id ) { |
|
| 965 | - $payment = new Give_Payment( $payment_id ); |
|
| 964 | +function give_get_payment_form_id($payment_id) { |
|
| 965 | + $payment = new Give_Payment($payment_id); |
|
| 966 | 966 | |
| 967 | 967 | return $payment->form_id; |
| 968 | 968 | } |
@@ -976,8 +976,8 @@ discard block |
||
| 976 | 976 | * |
| 977 | 977 | * @return string $email User email. |
| 978 | 978 | */ |
| 979 | -function give_get_payment_user_email( $payment_id ) { |
|
| 980 | - $payment = new Give_Payment( $payment_id ); |
|
| 979 | +function give_get_payment_user_email($payment_id) { |
|
| 980 | + $payment = new Give_Payment($payment_id); |
|
| 981 | 981 | |
| 982 | 982 | return $payment->email; |
| 983 | 983 | } |
@@ -991,11 +991,11 @@ discard block |
||
| 991 | 991 | * |
| 992 | 992 | * @return bool $is_guest_payment If the payment is associated with a user (false) or not (true) |
| 993 | 993 | */ |
| 994 | -function give_is_guest_payment( $payment_id ) { |
|
| 995 | - $payment_user_id = give_get_payment_user_id( $payment_id ); |
|
| 996 | - $is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true; |
|
| 994 | +function give_is_guest_payment($payment_id) { |
|
| 995 | + $payment_user_id = give_get_payment_user_id($payment_id); |
|
| 996 | + $is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true; |
|
| 997 | 997 | |
| 998 | - return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id ); |
|
| 998 | + return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id); |
|
| 999 | 999 | } |
| 1000 | 1000 | |
| 1001 | 1001 | /** |
@@ -1007,8 +1007,8 @@ discard block |
||
| 1007 | 1007 | * |
| 1008 | 1008 | * @return int $user_id User ID. |
| 1009 | 1009 | */ |
| 1010 | -function give_get_payment_user_id( $payment_id ) { |
|
| 1011 | - $payment = new Give_Payment( $payment_id ); |
|
| 1010 | +function give_get_payment_user_id($payment_id) { |
|
| 1011 | + $payment = new Give_Payment($payment_id); |
|
| 1012 | 1012 | |
| 1013 | 1013 | return $payment->user_id; |
| 1014 | 1014 | } |
@@ -1022,8 +1022,8 @@ discard block |
||
| 1022 | 1022 | * |
| 1023 | 1023 | * @return int $customer_id Customer ID. |
| 1024 | 1024 | */ |
| 1025 | -function give_get_payment_customer_id( $payment_id ) { |
|
| 1026 | - $payment = new Give_Payment( $payment_id ); |
|
| 1025 | +function give_get_payment_customer_id($payment_id) { |
|
| 1026 | + $payment = new Give_Payment($payment_id); |
|
| 1027 | 1027 | |
| 1028 | 1028 | return $payment->customer_id; |
| 1029 | 1029 | } |
@@ -1037,8 +1037,8 @@ discard block |
||
| 1037 | 1037 | * |
| 1038 | 1038 | * @return string $ip User IP. |
| 1039 | 1039 | */ |
| 1040 | -function give_get_payment_user_ip( $payment_id ) { |
|
| 1041 | - $payment = new Give_Payment( $payment_id ); |
|
| 1040 | +function give_get_payment_user_ip($payment_id) { |
|
| 1041 | + $payment = new Give_Payment($payment_id); |
|
| 1042 | 1042 | |
| 1043 | 1043 | return $payment->ip; |
| 1044 | 1044 | } |
@@ -1052,8 +1052,8 @@ discard block |
||
| 1052 | 1052 | * |
| 1053 | 1053 | * @return string $date The date the payment was completed. |
| 1054 | 1054 | */ |
| 1055 | -function give_get_payment_completed_date( $payment_id = 0 ) { |
|
| 1056 | - $payment = new Give_Payment( $payment_id ); |
|
| 1055 | +function give_get_payment_completed_date($payment_id = 0) { |
|
| 1056 | + $payment = new Give_Payment($payment_id); |
|
| 1057 | 1057 | |
| 1058 | 1058 | return $payment->completed_date; |
| 1059 | 1059 | } |
@@ -1067,8 +1067,8 @@ discard block |
||
| 1067 | 1067 | * |
| 1068 | 1068 | * @return string $gateway Gateway. |
| 1069 | 1069 | */ |
| 1070 | -function give_get_payment_gateway( $payment_id ) { |
|
| 1071 | - $payment = new Give_Payment( $payment_id ); |
|
| 1070 | +function give_get_payment_gateway($payment_id) { |
|
| 1071 | + $payment = new Give_Payment($payment_id); |
|
| 1072 | 1072 | |
| 1073 | 1073 | return $payment->gateway; |
| 1074 | 1074 | } |
@@ -1082,8 +1082,8 @@ discard block |
||
| 1082 | 1082 | * |
| 1083 | 1083 | * @return string $currency The currency code. |
| 1084 | 1084 | */ |
| 1085 | -function give_get_payment_currency_code( $payment_id = 0 ) { |
|
| 1086 | - $payment = new Give_Payment( $payment_id ); |
|
| 1085 | +function give_get_payment_currency_code($payment_id = 0) { |
|
| 1086 | + $payment = new Give_Payment($payment_id); |
|
| 1087 | 1087 | |
| 1088 | 1088 | return $payment->currency; |
| 1089 | 1089 | } |
@@ -1097,10 +1097,10 @@ discard block |
||
| 1097 | 1097 | * |
| 1098 | 1098 | * @return string $currency The currency name. |
| 1099 | 1099 | */ |
| 1100 | -function give_get_payment_currency( $payment_id = 0 ) { |
|
| 1101 | - $currency = give_get_payment_currency_code( $payment_id ); |
|
| 1100 | +function give_get_payment_currency($payment_id = 0) { |
|
| 1101 | + $currency = give_get_payment_currency_code($payment_id); |
|
| 1102 | 1102 | |
| 1103 | - return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id ); |
|
| 1103 | + return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id); |
|
| 1104 | 1104 | } |
| 1105 | 1105 | |
| 1106 | 1106 | /** |
@@ -1112,8 +1112,8 @@ discard block |
||
| 1112 | 1112 | * |
| 1113 | 1113 | * @return string $key Donation key. |
| 1114 | 1114 | */ |
| 1115 | -function give_get_payment_key( $payment_id = 0 ) { |
|
| 1116 | - $payment = new Give_Payment( $payment_id ); |
|
| 1115 | +function give_get_payment_key($payment_id = 0) { |
|
| 1116 | + $payment = new Give_Payment($payment_id); |
|
| 1117 | 1117 | |
| 1118 | 1118 | return $payment->key; |
| 1119 | 1119 | } |
@@ -1129,8 +1129,8 @@ discard block |
||
| 1129 | 1129 | * |
| 1130 | 1130 | * @return string $number Payment order number. |
| 1131 | 1131 | */ |
| 1132 | -function give_get_payment_number( $payment_id = 0 ) { |
|
| 1133 | - $payment = new Give_Payment( $payment_id ); |
|
| 1132 | +function give_get_payment_number($payment_id = 0) { |
|
| 1133 | + $payment = new Give_Payment($payment_id); |
|
| 1134 | 1134 | |
| 1135 | 1135 | return $payment->number; |
| 1136 | 1136 | } |
@@ -1144,23 +1144,23 @@ discard block |
||
| 1144 | 1144 | * |
| 1145 | 1145 | * @return string The formatted payment number. |
| 1146 | 1146 | */ |
| 1147 | -function give_format_payment_number( $number ) { |
|
| 1147 | +function give_format_payment_number($number) { |
|
| 1148 | 1148 | |
| 1149 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
| 1149 | + if ( ! give_get_option('enable_sequential')) { |
|
| 1150 | 1150 | return $number; |
| 1151 | 1151 | } |
| 1152 | 1152 | |
| 1153 | - if ( ! is_numeric( $number ) ) { |
|
| 1153 | + if ( ! is_numeric($number)) { |
|
| 1154 | 1154 | return $number; |
| 1155 | 1155 | } |
| 1156 | 1156 | |
| 1157 | - $prefix = give_get_option( 'sequential_prefix' ); |
|
| 1158 | - $number = absint( $number ); |
|
| 1159 | - $postfix = give_get_option( 'sequential_postfix' ); |
|
| 1157 | + $prefix = give_get_option('sequential_prefix'); |
|
| 1158 | + $number = absint($number); |
|
| 1159 | + $postfix = give_get_option('sequential_postfix'); |
|
| 1160 | 1160 | |
| 1161 | - $formatted_number = $prefix . $number . $postfix; |
|
| 1161 | + $formatted_number = $prefix.$number.$postfix; |
|
| 1162 | 1162 | |
| 1163 | - return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix ); |
|
| 1163 | + return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix); |
|
| 1164 | 1164 | } |
| 1165 | 1165 | |
| 1166 | 1166 | /** |
@@ -1173,17 +1173,17 @@ discard block |
||
| 1173 | 1173 | */ |
| 1174 | 1174 | function give_get_next_payment_number() { |
| 1175 | 1175 | |
| 1176 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
| 1176 | + if ( ! give_get_option('enable_sequential')) { |
|
| 1177 | 1177 | return false; |
| 1178 | 1178 | } |
| 1179 | 1179 | |
| 1180 | - $number = get_option( 'give_last_payment_number' ); |
|
| 1181 | - $start = give_get_option( 'sequential_start', 1 ); |
|
| 1180 | + $number = get_option('give_last_payment_number'); |
|
| 1181 | + $start = give_get_option('sequential_start', 1); |
|
| 1182 | 1182 | $increment_number = true; |
| 1183 | 1183 | |
| 1184 | - if ( false !== $number ) { |
|
| 1184 | + if (false !== $number) { |
|
| 1185 | 1185 | |
| 1186 | - if ( empty( $number ) ) { |
|
| 1186 | + if (empty($number)) { |
|
| 1187 | 1187 | |
| 1188 | 1188 | $number = $start; |
| 1189 | 1189 | $increment_number = false; |
@@ -1192,24 +1192,24 @@ discard block |
||
| 1192 | 1192 | } else { |
| 1193 | 1193 | |
| 1194 | 1194 | // This case handles the first addition of the new option, as well as if it get's deleted for any reason. |
| 1195 | - $payments = new Give_Payments_Query( array( |
|
| 1195 | + $payments = new Give_Payments_Query(array( |
|
| 1196 | 1196 | 'number' => 1, |
| 1197 | 1197 | 'order' => 'DESC', |
| 1198 | 1198 | 'orderby' => 'ID', |
| 1199 | 1199 | 'output' => 'posts', |
| 1200 | 1200 | 'fields' => 'ids', |
| 1201 | - ) ); |
|
| 1201 | + )); |
|
| 1202 | 1202 | $last_payment = $payments->get_payments(); |
| 1203 | 1203 | |
| 1204 | - if ( ! empty( $last_payment ) ) { |
|
| 1204 | + if ( ! empty($last_payment)) { |
|
| 1205 | 1205 | |
| 1206 | - $number = give_get_payment_number( $last_payment[0] ); |
|
| 1206 | + $number = give_get_payment_number($last_payment[0]); |
|
| 1207 | 1207 | |
| 1208 | 1208 | } |
| 1209 | 1209 | |
| 1210 | - if ( ! empty( $number ) && $number !== (int) $last_payment[0] ) { |
|
| 1210 | + if ( ! empty($number) && $number !== (int) $last_payment[0]) { |
|
| 1211 | 1211 | |
| 1212 | - $number = give_remove_payment_prefix_postfix( $number ); |
|
| 1212 | + $number = give_remove_payment_prefix_postfix($number); |
|
| 1213 | 1213 | |
| 1214 | 1214 | } else { |
| 1215 | 1215 | |
@@ -1218,13 +1218,13 @@ discard block |
||
| 1218 | 1218 | } |
| 1219 | 1219 | } |
| 1220 | 1220 | |
| 1221 | - $increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number ); |
|
| 1221 | + $increment_number = apply_filters('give_increment_payment_number', $increment_number, $number); |
|
| 1222 | 1222 | |
| 1223 | - if ( $increment_number ) { |
|
| 1224 | - $number ++; |
|
| 1223 | + if ($increment_number) { |
|
| 1224 | + $number++; |
|
| 1225 | 1225 | } |
| 1226 | 1226 | |
| 1227 | - return apply_filters( 'give_get_next_payment_number', $number ); |
|
| 1227 | + return apply_filters('give_get_next_payment_number', $number); |
|
| 1228 | 1228 | } |
| 1229 | 1229 | |
| 1230 | 1230 | /** |
@@ -1236,25 +1236,25 @@ discard block |
||
| 1236 | 1236 | * |
| 1237 | 1237 | * @return string The new Payment number without prefix and postfix. |
| 1238 | 1238 | */ |
| 1239 | -function give_remove_payment_prefix_postfix( $number ) { |
|
| 1239 | +function give_remove_payment_prefix_postfix($number) { |
|
| 1240 | 1240 | |
| 1241 | - $prefix = give_get_option( 'sequential_prefix' ); |
|
| 1242 | - $postfix = give_get_option( 'sequential_postfix' ); |
|
| 1241 | + $prefix = give_get_option('sequential_prefix'); |
|
| 1242 | + $postfix = give_get_option('sequential_postfix'); |
|
| 1243 | 1243 | |
| 1244 | 1244 | // Remove prefix. |
| 1245 | - $number = preg_replace( '/' . $prefix . '/', '', $number, 1 ); |
|
| 1245 | + $number = preg_replace('/'.$prefix.'/', '', $number, 1); |
|
| 1246 | 1246 | |
| 1247 | 1247 | // Remove the postfix. |
| 1248 | - $length = strlen( $number ); |
|
| 1249 | - $postfix_pos = strrpos( $number, $postfix ); |
|
| 1250 | - if ( false !== $postfix_pos ) { |
|
| 1251 | - $number = substr_replace( $number, '', $postfix_pos, $length ); |
|
| 1248 | + $length = strlen($number); |
|
| 1249 | + $postfix_pos = strrpos($number, $postfix); |
|
| 1250 | + if (false !== $postfix_pos) { |
|
| 1251 | + $number = substr_replace($number, '', $postfix_pos, $length); |
|
| 1252 | 1252 | } |
| 1253 | 1253 | |
| 1254 | 1254 | // Ensure it's a whole number. |
| 1255 | - $number = intval( $number ); |
|
| 1255 | + $number = intval($number); |
|
| 1256 | 1256 | |
| 1257 | - return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix ); |
|
| 1257 | + return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix); |
|
| 1258 | 1258 | |
| 1259 | 1259 | } |
| 1260 | 1260 | |
@@ -1270,10 +1270,10 @@ discard block |
||
| 1270 | 1270 | * |
| 1271 | 1271 | * @return string $amount Fully formatted payment amount. |
| 1272 | 1272 | */ |
| 1273 | -function give_payment_amount( $payment_id = 0 ) { |
|
| 1274 | - $amount = give_get_payment_amount( $payment_id ); |
|
| 1273 | +function give_payment_amount($payment_id = 0) { |
|
| 1274 | + $amount = give_get_payment_amount($payment_id); |
|
| 1275 | 1275 | |
| 1276 | - return give_currency_filter( give_format_amount( $amount ), give_get_payment_currency_code( $payment_id ) ); |
|
| 1276 | + return give_currency_filter(give_format_amount($amount), give_get_payment_currency_code($payment_id)); |
|
| 1277 | 1277 | } |
| 1278 | 1278 | |
| 1279 | 1279 | /** |
@@ -1286,11 +1286,11 @@ discard block |
||
| 1286 | 1286 | * |
| 1287 | 1287 | * @return mixed|void |
| 1288 | 1288 | */ |
| 1289 | -function give_get_payment_amount( $payment_id ) { |
|
| 1289 | +function give_get_payment_amount($payment_id) { |
|
| 1290 | 1290 | |
| 1291 | - $payment = new Give_Payment( $payment_id ); |
|
| 1291 | + $payment = new Give_Payment($payment_id); |
|
| 1292 | 1292 | |
| 1293 | - return apply_filters( 'give_payment_amount', floatval( $payment->total ), $payment_id ); |
|
| 1293 | + return apply_filters('give_payment_amount', floatval($payment->total), $payment_id); |
|
| 1294 | 1294 | } |
| 1295 | 1295 | |
| 1296 | 1296 | /** |
@@ -1306,10 +1306,10 @@ discard block |
||
| 1306 | 1306 | * |
| 1307 | 1307 | * @return array Fully formatted payment subtotal. |
| 1308 | 1308 | */ |
| 1309 | -function give_payment_subtotal( $payment_id = 0 ) { |
|
| 1310 | - $subtotal = give_get_payment_subtotal( $payment_id ); |
|
| 1309 | +function give_payment_subtotal($payment_id = 0) { |
|
| 1310 | + $subtotal = give_get_payment_subtotal($payment_id); |
|
| 1311 | 1311 | |
| 1312 | - return give_currency_filter( give_format_amount( $subtotal ), give_get_payment_currency_code( $payment_id ) ); |
|
| 1312 | + return give_currency_filter(give_format_amount($subtotal), give_get_payment_currency_code($payment_id)); |
|
| 1313 | 1313 | } |
| 1314 | 1314 | |
| 1315 | 1315 | /** |
@@ -1323,8 +1323,8 @@ discard block |
||
| 1323 | 1323 | * |
| 1324 | 1324 | * @return float $subtotal Subtotal for payment (non formatted). |
| 1325 | 1325 | */ |
| 1326 | -function give_get_payment_subtotal( $payment_id = 0 ) { |
|
| 1327 | - $payment = new G_Payment( $payment_id ); |
|
| 1326 | +function give_get_payment_subtotal($payment_id = 0) { |
|
| 1327 | + $payment = new G_Payment($payment_id); |
|
| 1328 | 1328 | |
| 1329 | 1329 | return $payment->subtotal; |
| 1330 | 1330 | } |
@@ -1339,10 +1339,10 @@ discard block |
||
| 1339 | 1339 | * |
| 1340 | 1340 | * @return mixed array if payment fees found, false otherwise. |
| 1341 | 1341 | */ |
| 1342 | -function give_get_payment_fees( $payment_id = 0, $type = 'all' ) { |
|
| 1343 | - $payment = new Give_Payment( $payment_id ); |
|
| 1342 | +function give_get_payment_fees($payment_id = 0, $type = 'all') { |
|
| 1343 | + $payment = new Give_Payment($payment_id); |
|
| 1344 | 1344 | |
| 1345 | - return $payment->get_fees( $type ); |
|
| 1345 | + return $payment->get_fees($type); |
|
| 1346 | 1346 | } |
| 1347 | 1347 | |
| 1348 | 1348 | /** |
@@ -1354,8 +1354,8 @@ discard block |
||
| 1354 | 1354 | * |
| 1355 | 1355 | * @return string The donation ID. |
| 1356 | 1356 | */ |
| 1357 | -function give_get_payment_transaction_id( $payment_id = 0 ) { |
|
| 1358 | - $payment = new Give_Payment( $payment_id ); |
|
| 1357 | +function give_get_payment_transaction_id($payment_id = 0) { |
|
| 1358 | + $payment = new Give_Payment($payment_id); |
|
| 1359 | 1359 | |
| 1360 | 1360 | return $payment->transaction_id; |
| 1361 | 1361 | } |
@@ -1370,15 +1370,15 @@ discard block |
||
| 1370 | 1370 | * |
| 1371 | 1371 | * @return bool|mixed |
| 1372 | 1372 | */ |
| 1373 | -function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) { |
|
| 1373 | +function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') { |
|
| 1374 | 1374 | |
| 1375 | - if ( empty( $payment_id ) || empty( $transaction_id ) ) { |
|
| 1375 | + if (empty($payment_id) || empty($transaction_id)) { |
|
| 1376 | 1376 | return false; |
| 1377 | 1377 | } |
| 1378 | 1378 | |
| 1379 | - $transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
| 1379 | + $transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id); |
|
| 1380 | 1380 | |
| 1381 | - return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id ); |
|
| 1381 | + return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id); |
|
| 1382 | 1382 | } |
| 1383 | 1383 | |
| 1384 | 1384 | /** |
@@ -1391,12 +1391,12 @@ discard block |
||
| 1391 | 1391 | * |
| 1392 | 1392 | * @return int $purchase Donation ID |
| 1393 | 1393 | */ |
| 1394 | -function give_get_purchase_id_by_key( $key ) { |
|
| 1394 | +function give_get_purchase_id_by_key($key) { |
|
| 1395 | 1395 | global $wpdb; |
| 1396 | 1396 | |
| 1397 | - $purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key ) ); |
|
| 1397 | + $purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key)); |
|
| 1398 | 1398 | |
| 1399 | - if ( $purchase != null ) { |
|
| 1399 | + if ($purchase != null) { |
|
| 1400 | 1400 | return $purchase; |
| 1401 | 1401 | } |
| 1402 | 1402 | |
@@ -1414,12 +1414,12 @@ discard block |
||
| 1414 | 1414 | * |
| 1415 | 1415 | * @return int $purchase Donation ID. |
| 1416 | 1416 | */ |
| 1417 | -function give_get_purchase_id_by_transaction_id( $key ) { |
|
| 1417 | +function give_get_purchase_id_by_transaction_id($key) { |
|
| 1418 | 1418 | global $wpdb; |
| 1419 | 1419 | |
| 1420 | - $purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key ) ); |
|
| 1420 | + $purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key)); |
|
| 1421 | 1421 | |
| 1422 | - if ( $purchase != null ) { |
|
| 1422 | + if ($purchase != null) { |
|
| 1423 | 1423 | return $purchase; |
| 1424 | 1424 | } |
| 1425 | 1425 | |
@@ -1436,19 +1436,19 @@ discard block |
||
| 1436 | 1436 | * |
| 1437 | 1437 | * @return array $notes Donation Notes |
| 1438 | 1438 | */ |
| 1439 | -function give_get_payment_notes( $payment_id = 0, $search = '' ) { |
|
| 1439 | +function give_get_payment_notes($payment_id = 0, $search = '') { |
|
| 1440 | 1440 | |
| 1441 | - if ( empty( $payment_id ) && empty( $search ) ) { |
|
| 1441 | + if (empty($payment_id) && empty($search)) { |
|
| 1442 | 1442 | return false; |
| 1443 | 1443 | } |
| 1444 | 1444 | |
| 1445 | - remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
| 1446 | - remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 ); |
|
| 1445 | + remove_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
| 1446 | + remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10); |
|
| 1447 | 1447 | |
| 1448 | - $notes = get_comments( array( 'post_id' => $payment_id, 'order' => 'ASC', 'search' => $search ) ); |
|
| 1448 | + $notes = get_comments(array('post_id' => $payment_id, 'order' => 'ASC', 'search' => $search)); |
|
| 1449 | 1449 | |
| 1450 | - add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
| 1451 | - add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
| 1450 | + add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
| 1451 | + add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
| 1452 | 1452 | |
| 1453 | 1453 | return $notes; |
| 1454 | 1454 | } |
@@ -1464,8 +1464,8 @@ discard block |
||
| 1464 | 1464 | * |
| 1465 | 1465 | * @return int The new note ID |
| 1466 | 1466 | */ |
| 1467 | -function give_insert_payment_note( $payment_id = 0, $note = '' ) { |
|
| 1468 | - if ( empty( $payment_id ) ) { |
|
| 1467 | +function give_insert_payment_note($payment_id = 0, $note = '') { |
|
| 1468 | + if (empty($payment_id)) { |
|
| 1469 | 1469 | return false; |
| 1470 | 1470 | } |
| 1471 | 1471 | |
@@ -1477,14 +1477,14 @@ discard block |
||
| 1477 | 1477 | * @param int $payment_id Payment ID. |
| 1478 | 1478 | * @param string $note The note. |
| 1479 | 1479 | */ |
| 1480 | - do_action( 'give_pre_insert_payment_note', $payment_id, $note ); |
|
| 1480 | + do_action('give_pre_insert_payment_note', $payment_id, $note); |
|
| 1481 | 1481 | |
| 1482 | - $note_id = wp_insert_comment( wp_filter_comment( array( |
|
| 1482 | + $note_id = wp_insert_comment(wp_filter_comment(array( |
|
| 1483 | 1483 | 'comment_post_ID' => $payment_id, |
| 1484 | 1484 | 'comment_content' => $note, |
| 1485 | 1485 | 'user_id' => is_admin() ? get_current_user_id() : 0, |
| 1486 | - 'comment_date' => current_time( 'mysql' ), |
|
| 1487 | - 'comment_date_gmt' => current_time( 'mysql', 1 ), |
|
| 1486 | + 'comment_date' => current_time('mysql'), |
|
| 1487 | + 'comment_date_gmt' => current_time('mysql', 1), |
|
| 1488 | 1488 | 'comment_approved' => 1, |
| 1489 | 1489 | 'comment_parent' => 0, |
| 1490 | 1490 | 'comment_author' => '', |
@@ -1493,7 +1493,7 @@ discard block |
||
| 1493 | 1493 | 'comment_author_email' => '', |
| 1494 | 1494 | 'comment_type' => 'give_payment_note', |
| 1495 | 1495 | |
| 1496 | - ) ) ); |
|
| 1496 | + ))); |
|
| 1497 | 1497 | |
| 1498 | 1498 | /** |
| 1499 | 1499 | * Fires after payment note inserted. |
@@ -1504,7 +1504,7 @@ discard block |
||
| 1504 | 1504 | * @param int $payment_id Payment ID. |
| 1505 | 1505 | * @param string $note The note. |
| 1506 | 1506 | */ |
| 1507 | - do_action( 'give_insert_payment_note', $note_id, $payment_id, $note ); |
|
| 1507 | + do_action('give_insert_payment_note', $note_id, $payment_id, $note); |
|
| 1508 | 1508 | |
| 1509 | 1509 | return $note_id; |
| 1510 | 1510 | } |
@@ -1519,8 +1519,8 @@ discard block |
||
| 1519 | 1519 | * |
| 1520 | 1520 | * @return bool True on success, false otherwise. |
| 1521 | 1521 | */ |
| 1522 | -function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) { |
|
| 1523 | - if ( empty( $comment_id ) ) { |
|
| 1522 | +function give_delete_payment_note($comment_id = 0, $payment_id = 0) { |
|
| 1523 | + if (empty($comment_id)) { |
|
| 1524 | 1524 | return false; |
| 1525 | 1525 | } |
| 1526 | 1526 | |
@@ -1532,9 +1532,9 @@ discard block |
||
| 1532 | 1532 | * @param int $comment_id Note ID. |
| 1533 | 1533 | * @param int $payment_id Payment ID. |
| 1534 | 1534 | */ |
| 1535 | - do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id ); |
|
| 1535 | + do_action('give_pre_delete_payment_note', $comment_id, $payment_id); |
|
| 1536 | 1536 | |
| 1537 | - $ret = wp_delete_comment( $comment_id, true ); |
|
| 1537 | + $ret = wp_delete_comment($comment_id, true); |
|
| 1538 | 1538 | |
| 1539 | 1539 | /** |
| 1540 | 1540 | * Fires after donation note deleted. |
@@ -1544,7 +1544,7 @@ discard block |
||
| 1544 | 1544 | * @param int $comment_id Note ID. |
| 1545 | 1545 | * @param int $payment_id Payment ID. |
| 1546 | 1546 | */ |
| 1547 | - do_action( 'give_post_delete_payment_note', $comment_id, $payment_id ); |
|
| 1547 | + do_action('give_post_delete_payment_note', $comment_id, $payment_id); |
|
| 1548 | 1548 | |
| 1549 | 1549 | return $ret; |
| 1550 | 1550 | } |
@@ -1559,34 +1559,34 @@ discard block |
||
| 1559 | 1559 | * |
| 1560 | 1560 | * @return string |
| 1561 | 1561 | */ |
| 1562 | -function give_get_payment_note_html( $note, $payment_id = 0 ) { |
|
| 1562 | +function give_get_payment_note_html($note, $payment_id = 0) { |
|
| 1563 | 1563 | |
| 1564 | - if ( is_numeric( $note ) ) { |
|
| 1565 | - $note = get_comment( $note ); |
|
| 1564 | + if (is_numeric($note)) { |
|
| 1565 | + $note = get_comment($note); |
|
| 1566 | 1566 | } |
| 1567 | 1567 | |
| 1568 | - if ( ! empty( $note->user_id ) ) { |
|
| 1569 | - $user = get_userdata( $note->user_id ); |
|
| 1568 | + if ( ! empty($note->user_id)) { |
|
| 1569 | + $user = get_userdata($note->user_id); |
|
| 1570 | 1570 | $user = $user->display_name; |
| 1571 | 1571 | } else { |
| 1572 | - $user = esc_html__( 'System', 'give' ); |
|
| 1572 | + $user = esc_html__('System', 'give'); |
|
| 1573 | 1573 | } |
| 1574 | 1574 | |
| 1575 | - $date_format = give_date_format() . ', ' . get_option( 'time_format' ); |
|
| 1575 | + $date_format = give_date_format().', '.get_option('time_format'); |
|
| 1576 | 1576 | |
| 1577 | - $delete_note_url = wp_nonce_url( add_query_arg( array( |
|
| 1577 | + $delete_note_url = wp_nonce_url(add_query_arg(array( |
|
| 1578 | 1578 | 'give-action' => 'delete_payment_note', |
| 1579 | 1579 | 'note_id' => $note->comment_ID, |
| 1580 | 1580 | 'payment_id' => $payment_id, |
| 1581 | - ) ), |
|
| 1582 | - 'give_delete_payment_note_' . $note->comment_ID |
|
| 1581 | + )), |
|
| 1582 | + 'give_delete_payment_note_'.$note->comment_ID |
|
| 1583 | 1583 | ); |
| 1584 | 1584 | |
| 1585 | - $note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">'; |
|
| 1585 | + $note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">'; |
|
| 1586 | 1586 | $note_html .= '<p>'; |
| 1587 | - $note_html .= '<strong>' . $user . '</strong> – <span style="color:#aaa;font-style:italic;">' . date_i18n( $date_format, strtotime( $note->comment_date ) ) . '</span><br/>'; |
|
| 1587 | + $note_html .= '<strong>'.$user.'</strong> – <span style="color:#aaa;font-style:italic;">'.date_i18n($date_format, strtotime($note->comment_date)).'</span><br/>'; |
|
| 1588 | 1588 | $note_html .= $note->comment_content; |
| 1589 | - $note_html .= ' – <a href="' . esc_url( $delete_note_url ) . '" class="give-delete-payment-note" data-note-id="' . absint( $note->comment_ID ) . '" data-payment-id="' . absint( $payment_id ) . '" aria-label="' . esc_attr__( 'Delete this donation note.', 'give' ) . '">' . esc_html__( 'Delete', 'give' ) . '</a>'; |
|
| 1589 | + $note_html .= ' – <a href="'.esc_url($delete_note_url).'" class="give-delete-payment-note" data-note-id="'.absint($note->comment_ID).'" data-payment-id="'.absint($payment_id).'" aria-label="'.esc_attr__('Delete this donation note.', 'give').'">'.esc_html__('Delete', 'give').'</a>'; |
|
| 1590 | 1590 | $note_html .= '</p>'; |
| 1591 | 1591 | $note_html .= '</div>'; |
| 1592 | 1592 | |
@@ -1604,18 +1604,18 @@ discard block |
||
| 1604 | 1604 | * |
| 1605 | 1605 | * @return void |
| 1606 | 1606 | */ |
| 1607 | -function give_hide_payment_notes( $query ) { |
|
| 1608 | - if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) { |
|
| 1609 | - $types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array(); |
|
| 1610 | - if ( ! is_array( $types ) ) { |
|
| 1611 | - $types = array( $types ); |
|
| 1607 | +function give_hide_payment_notes($query) { |
|
| 1608 | + if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) { |
|
| 1609 | + $types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array(); |
|
| 1610 | + if ( ! is_array($types)) { |
|
| 1611 | + $types = array($types); |
|
| 1612 | 1612 | } |
| 1613 | 1613 | $types[] = 'give_payment_note'; |
| 1614 | 1614 | $query->query_vars['type__not_in'] = $types; |
| 1615 | 1615 | } |
| 1616 | 1616 | } |
| 1617 | 1617 | |
| 1618 | -add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
| 1618 | +add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
| 1619 | 1619 | |
| 1620 | 1620 | /** |
| 1621 | 1621 | * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets |
@@ -1627,15 +1627,15 @@ discard block |
||
| 1627 | 1627 | * |
| 1628 | 1628 | * @return array $clauses Updated comment clauses. |
| 1629 | 1629 | */ |
| 1630 | -function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) { |
|
| 1631 | - if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) { |
|
| 1630 | +function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) { |
|
| 1631 | + if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) { |
|
| 1632 | 1632 | $clauses['where'] .= ' AND comment_type != "give_payment_note"'; |
| 1633 | 1633 | } |
| 1634 | 1634 | |
| 1635 | 1635 | return $clauses; |
| 1636 | 1636 | } |
| 1637 | 1637 | |
| 1638 | -add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
| 1638 | +add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
| 1639 | 1639 | |
| 1640 | 1640 | |
| 1641 | 1641 | /** |
@@ -1648,15 +1648,15 @@ discard block |
||
| 1648 | 1648 | * |
| 1649 | 1649 | * @return string $where |
| 1650 | 1650 | */ |
| 1651 | -function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) { |
|
| 1651 | +function give_hide_payment_notes_from_feeds($where, $wp_comment_query) { |
|
| 1652 | 1652 | global $wpdb; |
| 1653 | 1653 | |
| 1654 | - $where .= $wpdb->prepare( ' AND comment_type != %s', 'give_payment_note' ); |
|
| 1654 | + $where .= $wpdb->prepare(' AND comment_type != %s', 'give_payment_note'); |
|
| 1655 | 1655 | |
| 1656 | 1656 | return $where; |
| 1657 | 1657 | } |
| 1658 | 1658 | |
| 1659 | -add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 ); |
|
| 1659 | +add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2); |
|
| 1660 | 1660 | |
| 1661 | 1661 | |
| 1662 | 1662 | /** |
@@ -1670,32 +1670,32 @@ discard block |
||
| 1670 | 1670 | * |
| 1671 | 1671 | * @return array Array of comment counts. |
| 1672 | 1672 | */ |
| 1673 | -function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) { |
|
| 1673 | +function give_remove_payment_notes_in_comment_counts($stats, $post_id) { |
|
| 1674 | 1674 | global $wpdb, $pagenow; |
| 1675 | 1675 | |
| 1676 | - if ( 'index.php' != $pagenow ) { |
|
| 1676 | + if ('index.php' != $pagenow) { |
|
| 1677 | 1677 | return $stats; |
| 1678 | 1678 | } |
| 1679 | 1679 | |
| 1680 | 1680 | $post_id = (int) $post_id; |
| 1681 | 1681 | |
| 1682 | - if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) { |
|
| 1682 | + if (apply_filters('give_count_payment_notes_in_comments', false)) { |
|
| 1683 | 1683 | return $stats; |
| 1684 | 1684 | } |
| 1685 | 1685 | |
| 1686 | - $stats = wp_cache_get( "comments-{$post_id}", 'counts' ); |
|
| 1686 | + $stats = wp_cache_get("comments-{$post_id}", 'counts'); |
|
| 1687 | 1687 | |
| 1688 | - if ( false !== $stats ) { |
|
| 1688 | + if (false !== $stats) { |
|
| 1689 | 1689 | return $stats; |
| 1690 | 1690 | } |
| 1691 | 1691 | |
| 1692 | 1692 | $where = 'WHERE comment_type != "give_payment_note"'; |
| 1693 | 1693 | |
| 1694 | - if ( $post_id > 0 ) { |
|
| 1695 | - $where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id ); |
|
| 1694 | + if ($post_id > 0) { |
|
| 1695 | + $where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id); |
|
| 1696 | 1696 | } |
| 1697 | 1697 | |
| 1698 | - $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); |
|
| 1698 | + $count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A); |
|
| 1699 | 1699 | |
| 1700 | 1700 | $total = 0; |
| 1701 | 1701 | $approved = array( |
@@ -1705,30 +1705,30 @@ discard block |
||
| 1705 | 1705 | 'trash' => 'trash', |
| 1706 | 1706 | 'post-trashed' => 'post-trashed', |
| 1707 | 1707 | ); |
| 1708 | - foreach ( (array) $count as $row ) { |
|
| 1708 | + foreach ((array) $count as $row) { |
|
| 1709 | 1709 | // Don't count post-trashed toward totals. |
| 1710 | - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) { |
|
| 1710 | + if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) { |
|
| 1711 | 1711 | $total += $row['num_comments']; |
| 1712 | 1712 | } |
| 1713 | - if ( isset( $approved[ $row['comment_approved'] ] ) ) { |
|
| 1714 | - $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments']; |
|
| 1713 | + if (isset($approved[$row['comment_approved']])) { |
|
| 1714 | + $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
|
| 1715 | 1715 | } |
| 1716 | 1716 | } |
| 1717 | 1717 | |
| 1718 | 1718 | $stats['total_comments'] = $total; |
| 1719 | - foreach ( $approved as $key ) { |
|
| 1720 | - if ( empty( $stats[ $key ] ) ) { |
|
| 1721 | - $stats[ $key ] = 0; |
|
| 1719 | + foreach ($approved as $key) { |
|
| 1720 | + if (empty($stats[$key])) { |
|
| 1721 | + $stats[$key] = 0; |
|
| 1722 | 1722 | } |
| 1723 | 1723 | } |
| 1724 | 1724 | |
| 1725 | 1725 | $stats = (object) $stats; |
| 1726 | - wp_cache_set( "comments-{$post_id}", $stats, 'counts' ); |
|
| 1726 | + wp_cache_set("comments-{$post_id}", $stats, 'counts'); |
|
| 1727 | 1727 | |
| 1728 | 1728 | return $stats; |
| 1729 | 1729 | } |
| 1730 | 1730 | |
| 1731 | -add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 ); |
|
| 1731 | +add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2); |
|
| 1732 | 1732 | |
| 1733 | 1733 | |
| 1734 | 1734 | /** |
@@ -1741,9 +1741,9 @@ discard block |
||
| 1741 | 1741 | * |
| 1742 | 1742 | * @return string $where Modified where clause. |
| 1743 | 1743 | */ |
| 1744 | -function give_filter_where_older_than_week( $where = '' ) { |
|
| 1744 | +function give_filter_where_older_than_week($where = '') { |
|
| 1745 | 1745 | // Payments older than one week. |
| 1746 | - $start = date( 'Y-m-d', strtotime( '-7 days' ) ); |
|
| 1746 | + $start = date('Y-m-d', strtotime('-7 days')); |
|
| 1747 | 1747 | $where .= " AND post_date <= '{$start}'"; |
| 1748 | 1748 | |
| 1749 | 1749 | return $where; |
@@ -1763,37 +1763,37 @@ discard block |
||
| 1763 | 1763 | * |
| 1764 | 1764 | * @return string $form_title Returns the full title if $level_title false, otherwise returns the levels title. |
| 1765 | 1765 | */ |
| 1766 | -function give_get_payment_form_title( $payment_meta, $level_title = false, $separator = '' ) { |
|
| 1766 | +function give_get_payment_form_title($payment_meta, $level_title = false, $separator = '') { |
|
| 1767 | 1767 | |
| 1768 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0; |
|
| 1769 | - $form_title = isset( $payment_meta['form_title'] ) ? $payment_meta['form_title'] : ''; |
|
| 1770 | - $price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null; |
|
| 1768 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0; |
|
| 1769 | + $form_title = isset($payment_meta['form_title']) ? $payment_meta['form_title'] : ''; |
|
| 1770 | + $price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null; |
|
| 1771 | 1771 | |
| 1772 | - if ( $level_title == true ) { |
|
| 1772 | + if ($level_title == true) { |
|
| 1773 | 1773 | $form_title = ''; |
| 1774 | 1774 | } |
| 1775 | 1775 | |
| 1776 | - if ( give_has_variable_prices( $form_id ) ) { |
|
| 1776 | + if (give_has_variable_prices($form_id)) { |
|
| 1777 | 1777 | |
| 1778 | - if ( ! empty( $separator ) ) { |
|
| 1779 | - $form_title .= ' ' . $separator; |
|
| 1778 | + if ( ! empty($separator)) { |
|
| 1779 | + $form_title .= ' '.$separator; |
|
| 1780 | 1780 | } |
| 1781 | 1781 | $form_title .= ' <span class="donation-level-text-wrap">'; |
| 1782 | 1782 | |
| 1783 | - if ( $price_id == 'custom' ) { |
|
| 1783 | + if ($price_id == 'custom') { |
|
| 1784 | 1784 | |
| 1785 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
| 1786 | - $form_title .= ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html__( 'Custom Amount', 'give' ); |
|
| 1785 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
| 1786 | + $form_title .= ! empty($custom_amount_text) ? $custom_amount_text : esc_html__('Custom Amount', 'give'); |
|
| 1787 | 1787 | |
| 1788 | 1788 | } else { |
| 1789 | - $form_title .= give_get_price_option_name( $form_id, $price_id ); |
|
| 1789 | + $form_title .= give_get_price_option_name($form_id, $price_id); |
|
| 1790 | 1790 | } |
| 1791 | 1791 | |
| 1792 | 1792 | $form_title .= '</span>'; |
| 1793 | 1793 | |
| 1794 | 1794 | } |
| 1795 | 1795 | |
| 1796 | - return apply_filters( 'give_get_payment_form_title', $form_title, $payment_meta ); |
|
| 1796 | + return apply_filters('give_get_payment_form_title', $form_title, $payment_meta); |
|
| 1797 | 1797 | |
| 1798 | 1798 | } |
| 1799 | 1799 | |
@@ -1807,20 +1807,20 @@ discard block |
||
| 1807 | 1807 | * |
| 1808 | 1808 | * @return string $price_id |
| 1809 | 1809 | */ |
| 1810 | -function give_get_price_id( $form_id, $price ) { |
|
| 1810 | +function give_get_price_id($form_id, $price) { |
|
| 1811 | 1811 | |
| 1812 | 1812 | $price_id = 0; |
| 1813 | 1813 | |
| 1814 | - if ( give_has_variable_prices( $form_id ) ) { |
|
| 1814 | + if (give_has_variable_prices($form_id)) { |
|
| 1815 | 1815 | |
| 1816 | - $levels = maybe_unserialize( get_post_meta( $form_id, '_give_donation_levels', true ) ); |
|
| 1816 | + $levels = maybe_unserialize(get_post_meta($form_id, '_give_donation_levels', true)); |
|
| 1817 | 1817 | |
| 1818 | - foreach ( $levels as $level ) { |
|
| 1818 | + foreach ($levels as $level) { |
|
| 1819 | 1819 | |
| 1820 | - $level_amount = (float) give_sanitize_amount( $level['_give_amount'] ); |
|
| 1820 | + $level_amount = (float) give_sanitize_amount($level['_give_amount']); |
|
| 1821 | 1821 | |
| 1822 | 1822 | // Check that this indeed the recurring price. |
| 1823 | - if ( $level_amount == $price ) { |
|
| 1823 | + if ($level_amount == $price) { |
|
| 1824 | 1824 | |
| 1825 | 1825 | $price_id = $level['_give_id']['level_id']; |
| 1826 | 1826 | |
@@ -1845,10 +1845,10 @@ discard block |
||
| 1845 | 1845 | * |
| 1846 | 1846 | * @return string|void |
| 1847 | 1847 | */ |
| 1848 | -function give_get_form_dropdown( $args = array(), $echo = false ) { |
|
| 1849 | - $form_dropdown_html = Give()->html->forms_dropdown( $args ); |
|
| 1848 | +function give_get_form_dropdown($args = array(), $echo = false) { |
|
| 1849 | + $form_dropdown_html = Give()->html->forms_dropdown($args); |
|
| 1850 | 1850 | |
| 1851 | - if ( ! $echo ) { |
|
| 1851 | + if ( ! $echo) { |
|
| 1852 | 1852 | return $form_dropdown_html; |
| 1853 | 1853 | } |
| 1854 | 1854 | |
@@ -1865,38 +1865,38 @@ discard block |
||
| 1865 | 1865 | * |
| 1866 | 1866 | * @return string|void |
| 1867 | 1867 | */ |
| 1868 | -function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) { |
|
| 1868 | +function give_get_form_variable_price_dropdown($args = array(), $echo = false) { |
|
| 1869 | 1869 | |
| 1870 | 1870 | // Check for give form id. |
| 1871 | - if ( empty( $args['id'] ) ) { |
|
| 1871 | + if (empty($args['id'])) { |
|
| 1872 | 1872 | return false; |
| 1873 | 1873 | } |
| 1874 | 1874 | |
| 1875 | 1875 | // Check if form has variable prices or not. |
| 1876 | - if ( ! ( $variable_prices = give_has_variable_prices( $args['id'] ) ) ) { |
|
| 1876 | + if ( ! ($variable_prices = give_has_variable_prices($args['id']))) { |
|
| 1877 | 1877 | return false; |
| 1878 | 1878 | } |
| 1879 | 1879 | |
| 1880 | - $variable_prices = give_get_variable_prices( absint( $args['id'] ) ); |
|
| 1880 | + $variable_prices = give_get_variable_prices(absint($args['id'])); |
|
| 1881 | 1881 | $variable_price_options = array(); |
| 1882 | 1882 | |
| 1883 | 1883 | // Check if multi donation form support custom donation or not. |
| 1884 | - if ( give_is_custom_price_mode( absint( $args['id'] ) ) ) { |
|
| 1885 | - $variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' ); |
|
| 1884 | + if (give_is_custom_price_mode(absint($args['id']))) { |
|
| 1885 | + $variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give'); |
|
| 1886 | 1886 | } |
| 1887 | 1887 | |
| 1888 | 1888 | // Get variable price and ID from variable price array. |
| 1889 | - foreach ( $variable_prices as $variable_price ) { |
|
| 1890 | - $variable_price_options[ $variable_price['_give_id']['level_id'] ] = $variable_price['_give_text']; |
|
| 1889 | + foreach ($variable_prices as $variable_price) { |
|
| 1890 | + $variable_price_options[$variable_price['_give_id']['level_id']] = $variable_price['_give_text']; |
|
| 1891 | 1891 | } |
| 1892 | 1892 | |
| 1893 | 1893 | // Update options. |
| 1894 | - $args = array_merge( $args, array( 'options' => $variable_price_options ) ); |
|
| 1894 | + $args = array_merge($args, array('options' => $variable_price_options)); |
|
| 1895 | 1895 | |
| 1896 | 1896 | // Generate select html. |
| 1897 | - $form_dropdown_html = Give()->html->select( $args ); |
|
| 1897 | + $form_dropdown_html = Give()->html->select($args); |
|
| 1898 | 1898 | |
| 1899 | - if ( ! $echo ) { |
|
| 1899 | + if ( ! $echo) { |
|
| 1900 | 1900 | return $form_dropdown_html; |
| 1901 | 1901 | } |
| 1902 | 1902 | |
@@ -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,37 +23,37 @@ discard block |
||
| 23 | 23 | function give_setup_post_types() { |
| 24 | 24 | |
| 25 | 25 | /** Give Forms Post Type */ |
| 26 | - $give_forms_singular = give_get_option( 'disable_forms_singular' ) !== 'on' ? true : false; |
|
| 26 | + $give_forms_singular = give_get_option('disable_forms_singular') !== 'on' ? true : false; |
|
| 27 | 27 | |
| 28 | - $give_forms_archives = give_get_option( 'disable_forms_archives' ) !== 'on' ? true : false; |
|
| 28 | + $give_forms_archives = give_get_option('disable_forms_archives') !== 'on' ? true : false; |
|
| 29 | 29 | |
| 30 | - $give_forms_slug = defined( 'GIVE_SLUG' ) ? GIVE_SLUG : 'donations'; |
|
| 30 | + $give_forms_slug = defined('GIVE_SLUG') ? GIVE_SLUG : 'donations'; |
|
| 31 | 31 | //support for old 'GIVE_FORMS_SLUG' constant |
| 32 | - if ( defined( 'GIVE_FORMS_SLUG' ) ) { |
|
| 32 | + if (defined('GIVE_FORMS_SLUG')) { |
|
| 33 | 33 | $give_forms_slug = GIVE_FORMS_SLUG; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - $give_forms_rewrite = defined( 'GIVE_DISABLE_FORMS_REWRITE' ) && GIVE_DISABLE_FORMS_REWRITE ? false : array( |
|
| 36 | + $give_forms_rewrite = defined('GIVE_DISABLE_FORMS_REWRITE') && GIVE_DISABLE_FORMS_REWRITE ? false : array( |
|
| 37 | 37 | 'slug' => $give_forms_slug, |
| 38 | 38 | 'with_front' => false |
| 39 | 39 | ); |
| 40 | 40 | |
| 41 | - $give_forms_labels = apply_filters( 'give_forms_labels', array( |
|
| 42 | - 'name' => esc_html__( 'Donation Forms', 'give' ), |
|
| 43 | - 'singular_name' => esc_html__( 'Form', 'give' ), |
|
| 44 | - 'add_new' => esc_html__( 'Add Form', 'give' ), |
|
| 45 | - 'add_new_item' => esc_html__( 'Add New Donation Form', 'give' ), |
|
| 46 | - 'edit_item' => esc_html__( 'Edit Donation Form', 'give' ), |
|
| 47 | - 'new_item' => esc_html__( 'New Form', 'give' ), |
|
| 48 | - 'all_items' => esc_html__( 'All Forms', 'give' ), |
|
| 49 | - 'view_item' => esc_html__( 'View Form', 'give' ), |
|
| 50 | - 'search_items' => esc_html__( 'Search Forms', 'give' ), |
|
| 51 | - 'not_found' => esc_html__( 'No forms found.', 'give' ), |
|
| 52 | - 'not_found_in_trash' => esc_html__( 'No forms found in Trash.', 'give' ), |
|
| 41 | + $give_forms_labels = apply_filters('give_forms_labels', array( |
|
| 42 | + 'name' => esc_html__('Donation Forms', 'give'), |
|
| 43 | + 'singular_name' => esc_html__('Form', 'give'), |
|
| 44 | + 'add_new' => esc_html__('Add Form', 'give'), |
|
| 45 | + 'add_new_item' => esc_html__('Add New Donation Form', 'give'), |
|
| 46 | + 'edit_item' => esc_html__('Edit Donation Form', 'give'), |
|
| 47 | + 'new_item' => esc_html__('New Form', 'give'), |
|
| 48 | + 'all_items' => esc_html__('All Forms', 'give'), |
|
| 49 | + 'view_item' => esc_html__('View Form', 'give'), |
|
| 50 | + 'search_items' => esc_html__('Search Forms', 'give'), |
|
| 51 | + 'not_found' => esc_html__('No forms found.', 'give'), |
|
| 52 | + 'not_found_in_trash' => esc_html__('No forms found in Trash.', 'give'), |
|
| 53 | 53 | 'parent_item_colon' => '', |
| 54 | - 'menu_name' => apply_filters( 'give_menu_name', esc_html__( 'Donations', 'give' ) ), |
|
| 55 | - 'name_admin_bar' => apply_filters( 'give_name_admin_bar_name', esc_html__( 'Donation Form', 'give' ) ) |
|
| 56 | - ) ); |
|
| 54 | + 'menu_name' => apply_filters('give_menu_name', esc_html__('Donations', 'give')), |
|
| 55 | + 'name_admin_bar' => apply_filters('give_name_admin_bar_name', esc_html__('Donation Form', 'give')) |
|
| 56 | + )); |
|
| 57 | 57 | |
| 58 | 58 | //Default give_forms supports |
| 59 | 59 | $give_form_supports = array( |
@@ -65,14 +65,14 @@ discard block |
||
| 65 | 65 | ); |
| 66 | 66 | |
| 67 | 67 | //Has the user disabled the excerpt |
| 68 | - if ( give_get_option( 'disable_forms_excerpt' ) === 'on' ) { |
|
| 69 | - unset( $give_form_supports[2] ); |
|
| 68 | + if (give_get_option('disable_forms_excerpt') === 'on') { |
|
| 69 | + unset($give_form_supports[2]); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | //Has user disabled the featured image? |
| 73 | - if ( give_get_option( 'disable_form_featured_img' ) === 'on' ) { |
|
| 74 | - unset( $give_form_supports[1] ); |
|
| 75 | - remove_action( 'give_before_single_form_summary', 'give_show_form_images' ); |
|
| 73 | + if (give_get_option('disable_form_featured_img') === 'on') { |
|
| 74 | + unset($give_form_supports[1]); |
|
| 75 | + remove_action('give_before_single_form_summary', 'give_show_form_images'); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | $give_forms_args = array( |
@@ -88,42 +88,42 @@ discard block |
||
| 88 | 88 | 'has_archive' => $give_forms_archives, |
| 89 | 89 | 'menu_icon' => 'dashicons-give', |
| 90 | 90 | 'hierarchical' => false, |
| 91 | - 'supports' => apply_filters( 'give_forms_supports', $give_form_supports ), |
|
| 91 | + 'supports' => apply_filters('give_forms_supports', $give_form_supports), |
|
| 92 | 92 | ); |
| 93 | - register_post_type( 'give_forms', apply_filters( 'give_forms_post_type_args', $give_forms_args ) ); |
|
| 93 | + register_post_type('give_forms', apply_filters('give_forms_post_type_args', $give_forms_args)); |
|
| 94 | 94 | |
| 95 | 95 | /** Donation Post Type */ |
| 96 | 96 | $payment_labels = array( |
| 97 | - 'name' => _x( 'Donations', 'post type general name', 'give' ), |
|
| 98 | - 'singular_name' => _x( 'Donation', 'post type singular name', 'give' ), |
|
| 99 | - 'add_new' => esc_html__( 'Add New', 'give' ), |
|
| 100 | - 'add_new_item' => esc_html__( 'Add New Donation', 'give' ), |
|
| 101 | - 'edit_item' => esc_html__( 'Edit Donation', 'give' ), |
|
| 102 | - 'new_item' => esc_html__( 'New Donation', 'give' ), |
|
| 103 | - 'all_items' => esc_html__( 'All Donations', 'give' ), |
|
| 104 | - 'view_item' => esc_html__( 'View Donation', 'give' ), |
|
| 105 | - 'search_items' => esc_html__( 'Search Donations', 'give' ), |
|
| 106 | - 'not_found' => esc_html__( 'No donations found.', 'give' ), |
|
| 107 | - 'not_found_in_trash' => esc_html__( 'No donations found in Trash.', 'give' ), |
|
| 97 | + 'name' => _x('Donations', 'post type general name', 'give'), |
|
| 98 | + 'singular_name' => _x('Donation', 'post type singular name', 'give'), |
|
| 99 | + 'add_new' => esc_html__('Add New', 'give'), |
|
| 100 | + 'add_new_item' => esc_html__('Add New Donation', 'give'), |
|
| 101 | + 'edit_item' => esc_html__('Edit Donation', 'give'), |
|
| 102 | + 'new_item' => esc_html__('New Donation', 'give'), |
|
| 103 | + 'all_items' => esc_html__('All Donations', 'give'), |
|
| 104 | + 'view_item' => esc_html__('View Donation', 'give'), |
|
| 105 | + 'search_items' => esc_html__('Search Donations', 'give'), |
|
| 106 | + 'not_found' => esc_html__('No donations found.', 'give'), |
|
| 107 | + 'not_found_in_trash' => esc_html__('No donations found in Trash.', 'give'), |
|
| 108 | 108 | 'parent_item_colon' => '', |
| 109 | - 'menu_name' => esc_html__( 'Donations', 'give' ) |
|
| 109 | + 'menu_name' => esc_html__('Donations', 'give') |
|
| 110 | 110 | ); |
| 111 | 111 | |
| 112 | 112 | $payment_args = array( |
| 113 | - 'labels' => apply_filters( 'give_payment_labels', $payment_labels ), |
|
| 113 | + 'labels' => apply_filters('give_payment_labels', $payment_labels), |
|
| 114 | 114 | 'public' => false, |
| 115 | 115 | 'query_var' => false, |
| 116 | 116 | 'rewrite' => false, |
| 117 | 117 | 'map_meta_cap' => true, |
| 118 | 118 | 'capability_type' => 'give_payment', |
| 119 | - 'supports' => array( 'title' ), |
|
| 119 | + 'supports' => array('title'), |
|
| 120 | 120 | 'can_export' => true |
| 121 | 121 | ); |
| 122 | - register_post_type( 'give_payment', $payment_args ); |
|
| 122 | + register_post_type('give_payment', $payment_args); |
|
| 123 | 123 | |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | -add_action( 'init', 'give_setup_post_types', 1 ); |
|
| 126 | +add_action('init', 'give_setup_post_types', 1); |
|
| 127 | 127 | |
| 128 | 128 | |
| 129 | 129 | /** |
@@ -136,30 +136,30 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | function give_setup_taxonomies() { |
| 138 | 138 | |
| 139 | - $slug = defined( 'GIVE_FORMS_SLUG' ) ? GIVE_FORMS_SLUG : 'donations'; |
|
| 139 | + $slug = defined('GIVE_FORMS_SLUG') ? GIVE_FORMS_SLUG : 'donations'; |
|
| 140 | 140 | |
| 141 | 141 | /** Categories */ |
| 142 | 142 | $category_labels = array( |
| 143 | - 'name' => _x( 'Form Categories', 'taxonomy general name', 'give' ), |
|
| 144 | - 'singular_name' => _x( 'Category', 'taxonomy singular name', 'give' ), |
|
| 145 | - 'search_items' => esc_html__( 'Search Categories', 'give' ), |
|
| 146 | - 'all_items' => esc_html__( 'All Categories', 'give' ), |
|
| 147 | - 'parent_item' => esc_html__( 'Parent Category', 'give' ), |
|
| 148 | - 'parent_item_colon' => esc_html__( 'Parent Category:', 'give' ), |
|
| 149 | - 'edit_item' => esc_html__( 'Edit Category', 'give' ), |
|
| 150 | - 'update_item' => esc_html__( 'Update Category', 'give' ), |
|
| 151 | - 'add_new_item' => esc_html__( 'Add New Category', 'give' ), |
|
| 152 | - 'new_item_name' => esc_html__( 'New Category Name', 'give' ), |
|
| 153 | - 'menu_name' => esc_html__( 'Categories', 'give' ), |
|
| 143 | + 'name' => _x('Form Categories', 'taxonomy general name', 'give'), |
|
| 144 | + 'singular_name' => _x('Category', 'taxonomy singular name', 'give'), |
|
| 145 | + 'search_items' => esc_html__('Search Categories', 'give'), |
|
| 146 | + 'all_items' => esc_html__('All Categories', 'give'), |
|
| 147 | + 'parent_item' => esc_html__('Parent Category', 'give'), |
|
| 148 | + 'parent_item_colon' => esc_html__('Parent Category:', 'give'), |
|
| 149 | + 'edit_item' => esc_html__('Edit Category', 'give'), |
|
| 150 | + 'update_item' => esc_html__('Update Category', 'give'), |
|
| 151 | + 'add_new_item' => esc_html__('Add New Category', 'give'), |
|
| 152 | + 'new_item_name' => esc_html__('New Category Name', 'give'), |
|
| 153 | + 'menu_name' => esc_html__('Categories', 'give'), |
|
| 154 | 154 | ); |
| 155 | 155 | |
| 156 | - $category_args = apply_filters( 'give_forms_category_args', array( |
|
| 156 | + $category_args = apply_filters('give_forms_category_args', array( |
|
| 157 | 157 | 'hierarchical' => true, |
| 158 | - 'labels' => apply_filters( 'give_forms_category_labels', $category_labels ), |
|
| 158 | + 'labels' => apply_filters('give_forms_category_labels', $category_labels), |
|
| 159 | 159 | 'show_ui' => true, |
| 160 | 160 | 'query_var' => 'give_forms_category', |
| 161 | 161 | 'rewrite' => array( |
| 162 | - 'slug' => $slug . '/category', |
|
| 162 | + 'slug' => $slug.'/category', |
|
| 163 | 163 | 'with_front' => false, |
| 164 | 164 | 'hierarchical' => true |
| 165 | 165 | ), |
@@ -173,34 +173,34 @@ discard block |
||
| 173 | 173 | ); |
| 174 | 174 | |
| 175 | 175 | //Does the user want categories? |
| 176 | - if ( give_get_option( 'enable_categories' ) == 'on' ) { |
|
| 177 | - register_taxonomy( 'give_forms_category', array( 'give_forms' ), $category_args ); |
|
| 178 | - register_taxonomy_for_object_type( 'give_forms_category', 'give_forms' ); |
|
| 176 | + if (give_get_option('enable_categories') == 'on') { |
|
| 177 | + register_taxonomy('give_forms_category', array('give_forms'), $category_args); |
|
| 178 | + register_taxonomy_for_object_type('give_forms_category', 'give_forms'); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | |
| 182 | 182 | /** Tags */ |
| 183 | 183 | $tag_labels = array( |
| 184 | - 'name' => _x( 'Form Tags', 'taxonomy general name', 'give' ), |
|
| 185 | - 'singular_name' => _x( 'Tag', 'taxonomy singular name', 'give' ), |
|
| 186 | - 'search_items' => esc_html__( 'Search Tags', 'give' ), |
|
| 187 | - 'all_items' => esc_html__( 'All Tags', 'give' ), |
|
| 188 | - 'parent_item' => esc_html__( 'Parent Tag', 'give' ), |
|
| 189 | - 'parent_item_colon' => esc_html__( 'Parent Tag:', 'give' ), |
|
| 190 | - 'edit_item' => esc_html__( 'Edit Tag', 'give' ), |
|
| 191 | - 'update_item' => esc_html__( 'Update Tag', 'give' ), |
|
| 192 | - 'add_new_item' => esc_html__( 'Add New Tag', 'give' ), |
|
| 193 | - 'new_item_name' => esc_html__( 'New Tag Name', 'give' ), |
|
| 194 | - 'menu_name' => esc_html__( 'Tags', 'give' ), |
|
| 195 | - 'choose_from_most_used' => esc_html__( 'Choose from most used tags.', 'give' ), |
|
| 184 | + 'name' => _x('Form Tags', 'taxonomy general name', 'give'), |
|
| 185 | + 'singular_name' => _x('Tag', 'taxonomy singular name', 'give'), |
|
| 186 | + 'search_items' => esc_html__('Search Tags', 'give'), |
|
| 187 | + 'all_items' => esc_html__('All Tags', 'give'), |
|
| 188 | + 'parent_item' => esc_html__('Parent Tag', 'give'), |
|
| 189 | + 'parent_item_colon' => esc_html__('Parent Tag:', 'give'), |
|
| 190 | + 'edit_item' => esc_html__('Edit Tag', 'give'), |
|
| 191 | + 'update_item' => esc_html__('Update Tag', 'give'), |
|
| 192 | + 'add_new_item' => esc_html__('Add New Tag', 'give'), |
|
| 193 | + 'new_item_name' => esc_html__('New Tag Name', 'give'), |
|
| 194 | + 'menu_name' => esc_html__('Tags', 'give'), |
|
| 195 | + 'choose_from_most_used' => esc_html__('Choose from most used tags.', 'give'), |
|
| 196 | 196 | ); |
| 197 | 197 | |
| 198 | - $tag_args = apply_filters( 'give_forms_tag_args', array( |
|
| 198 | + $tag_args = apply_filters('give_forms_tag_args', array( |
|
| 199 | 199 | 'hierarchical' => false, |
| 200 | - 'labels' => apply_filters( 'give_forms_tag_labels', $tag_labels ), |
|
| 200 | + 'labels' => apply_filters('give_forms_tag_labels', $tag_labels), |
|
| 201 | 201 | 'show_ui' => true, |
| 202 | 202 | 'query_var' => 'give_forms_tag', |
| 203 | - 'rewrite' => array( 'slug' => $slug . '/tag', 'with_front' => false, 'hierarchical' => true ), |
|
| 203 | + 'rewrite' => array('slug' => $slug.'/tag', 'with_front' => false, 'hierarchical' => true), |
|
| 204 | 204 | 'capabilities' => array( |
| 205 | 205 | 'manage_terms' => 'manage_give_form_terms', |
| 206 | 206 | 'edit_terms' => 'edit_give_form_terms', |
@@ -210,15 +210,15 @@ discard block |
||
| 210 | 210 | ) |
| 211 | 211 | ); |
| 212 | 212 | |
| 213 | - if ( give_get_option( 'enable_tags' ) == 'on' ) { |
|
| 214 | - register_taxonomy( 'give_forms_tag', array( 'give_forms' ), $tag_args ); |
|
| 215 | - register_taxonomy_for_object_type( 'give_forms_tag', 'give_forms' ); |
|
| 213 | + if (give_get_option('enable_tags') == 'on') { |
|
| 214 | + register_taxonomy('give_forms_tag', array('give_forms'), $tag_args); |
|
| 215 | + register_taxonomy_for_object_type('give_forms_tag', 'give_forms'); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | -add_action( 'init', 'give_setup_taxonomies', 0 ); |
|
| 221 | +add_action('init', 'give_setup_taxonomies', 0); |
|
| 222 | 222 | |
| 223 | 223 | |
| 224 | 224 | /** |
@@ -229,11 +229,11 @@ discard block |
||
| 229 | 229 | */ |
| 230 | 230 | function give_get_default_form_labels() { |
| 231 | 231 | $defaults = array( |
| 232 | - 'singular' => esc_html__( 'Form', 'give' ), |
|
| 233 | - 'plural' => esc_html__( 'Forms', 'give' ) |
|
| 232 | + 'singular' => esc_html__('Form', 'give'), |
|
| 233 | + 'plural' => esc_html__('Forms', 'give') |
|
| 234 | 234 | ); |
| 235 | 235 | |
| 236 | - return apply_filters( 'give_default_form_name', $defaults ); |
|
| 236 | + return apply_filters('give_default_form_name', $defaults); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | /** |
@@ -245,10 +245,10 @@ discard block |
||
| 245 | 245 | * |
| 246 | 246 | * @return string $defaults['singular'] Singular label |
| 247 | 247 | */ |
| 248 | -function give_get_forms_label_singular( $lowercase = false ) { |
|
| 248 | +function give_get_forms_label_singular($lowercase = false) { |
|
| 249 | 249 | $defaults = give_get_default_form_labels(); |
| 250 | 250 | |
| 251 | - return ( $lowercase ) ? strtolower( $defaults['singular'] ) : $defaults['singular']; |
|
| 251 | + return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular']; |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | /** |
@@ -257,10 +257,10 @@ discard block |
||
| 257 | 257 | * @since 1.0 |
| 258 | 258 | * @return string $defaults['plural'] Plural label |
| 259 | 259 | */ |
| 260 | -function give_get_forms_label_plural( $lowercase = false ) { |
|
| 260 | +function give_get_forms_label_plural($lowercase = false) { |
|
| 261 | 261 | $defaults = give_get_default_form_labels(); |
| 262 | 262 | |
| 263 | - return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural']; |
|
| 263 | + return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural']; |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | /** |
@@ -272,24 +272,24 @@ discard block |
||
| 272 | 272 | * |
| 273 | 273 | * @return string $title New placeholder text |
| 274 | 274 | */ |
| 275 | -function give_change_default_title( $title ) { |
|
| 275 | +function give_change_default_title($title) { |
|
| 276 | 276 | // If a frontend plugin uses this filter (check extensions before changing this function) |
| 277 | - if ( ! is_admin() ) { |
|
| 278 | - $title = esc_html__( 'Enter form title here', 'give' ); |
|
| 277 | + if ( ! is_admin()) { |
|
| 278 | + $title = esc_html__('Enter form title here', 'give'); |
|
| 279 | 279 | |
| 280 | 280 | return $title; |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | $screen = get_current_screen(); |
| 284 | 284 | |
| 285 | - if ( 'give_forms' == $screen->post_type ) { |
|
| 286 | - $title = esc_html__( 'Enter form title here', 'give' ); |
|
| 285 | + if ('give_forms' == $screen->post_type) { |
|
| 286 | + $title = esc_html__('Enter form title here', 'give'); |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | return $title; |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | -add_filter( 'enter_title_here', 'give_change_default_title' ); |
|
| 292 | +add_filter('enter_title_here', 'give_change_default_title'); |
|
| 293 | 293 | |
| 294 | 294 | /** |
| 295 | 295 | * Registers Custom Post Statuses which are used by the Payments |
@@ -299,50 +299,50 @@ discard block |
||
| 299 | 299 | */ |
| 300 | 300 | function give_register_post_type_statuses() { |
| 301 | 301 | // Payment Statuses |
| 302 | - register_post_status( 'refunded', array( |
|
| 303 | - 'label' => esc_html__( 'Refunded', 'give' ), |
|
| 302 | + register_post_status('refunded', array( |
|
| 303 | + 'label' => esc_html__('Refunded', 'give'), |
|
| 304 | 304 | 'public' => true, |
| 305 | 305 | 'exclude_from_search' => false, |
| 306 | 306 | 'show_in_admin_all_list' => true, |
| 307 | 307 | 'show_in_admin_status_list' => true, |
| 308 | - 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give' ) |
|
| 309 | - ) ); |
|
| 310 | - register_post_status( 'failed', array( |
|
| 311 | - 'label' => esc_html__( 'Failed', 'give' ), |
|
| 308 | + 'label_count' => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give') |
|
| 309 | + )); |
|
| 310 | + register_post_status('failed', array( |
|
| 311 | + 'label' => esc_html__('Failed', 'give'), |
|
| 312 | 312 | 'public' => true, |
| 313 | 313 | 'exclude_from_search' => false, |
| 314 | 314 | 'show_in_admin_all_list' => true, |
| 315 | 315 | 'show_in_admin_status_list' => true, |
| 316 | - 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give' ) |
|
| 317 | - ) ); |
|
| 318 | - register_post_status( 'revoked', array( |
|
| 319 | - 'label' => esc_html__( 'Revoked', 'give' ), |
|
| 316 | + 'label_count' => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give') |
|
| 317 | + )); |
|
| 318 | + register_post_status('revoked', array( |
|
| 319 | + 'label' => esc_html__('Revoked', 'give'), |
|
| 320 | 320 | 'public' => true, |
| 321 | 321 | 'exclude_from_search' => false, |
| 322 | 322 | 'show_in_admin_all_list' => true, |
| 323 | 323 | 'show_in_admin_status_list' => true, |
| 324 | - 'label_count' => _n_noop( 'Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give' ) |
|
| 325 | - ) ); |
|
| 326 | - register_post_status( 'cancelled', array( |
|
| 327 | - 'label' => esc_html__( 'Cancelled', 'give' ), |
|
| 324 | + 'label_count' => _n_noop('Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give') |
|
| 325 | + )); |
|
| 326 | + register_post_status('cancelled', array( |
|
| 327 | + 'label' => esc_html__('Cancelled', 'give'), |
|
| 328 | 328 | 'public' => true, |
| 329 | 329 | 'exclude_from_search' => false, |
| 330 | 330 | 'show_in_admin_all_list' => true, |
| 331 | 331 | 'show_in_admin_status_list' => true, |
| 332 | - 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give' ) |
|
| 333 | - ) ); |
|
| 334 | - register_post_status( 'abandoned', array( |
|
| 335 | - 'label' => esc_html__( 'Abandoned', 'give' ), |
|
| 332 | + 'label_count' => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give') |
|
| 333 | + )); |
|
| 334 | + register_post_status('abandoned', array( |
|
| 335 | + 'label' => esc_html__('Abandoned', 'give'), |
|
| 336 | 336 | 'public' => true, |
| 337 | 337 | 'exclude_from_search' => false, |
| 338 | 338 | 'show_in_admin_all_list' => true, |
| 339 | 339 | 'show_in_admin_status_list' => true, |
| 340 | - 'label_count' => _n_noop( 'Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give' ) |
|
| 341 | - ) ); |
|
| 340 | + 'label_count' => _n_noop('Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give') |
|
| 341 | + )); |
|
| 342 | 342 | |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | -add_action( 'init', 'give_register_post_type_statuses' ); |
|
| 345 | +add_action('init', 'give_register_post_type_statuses'); |
|
| 346 | 346 | |
| 347 | 347 | /** |
| 348 | 348 | * Updated Messages |
@@ -355,27 +355,27 @@ discard block |
||
| 355 | 355 | * |
| 356 | 356 | * @return array $messages New post updated messages |
| 357 | 357 | */ |
| 358 | -function give_updated_messages( $messages ) { |
|
| 358 | +function give_updated_messages($messages) { |
|
| 359 | 359 | global $post, $post_ID; |
| 360 | 360 | |
| 361 | - if ( give_get_option( 'disable_forms_singular' ) === 'on' ) { |
|
| 361 | + if (give_get_option('disable_forms_singular') === 'on') { |
|
| 362 | 362 | |
| 363 | 363 | $messages['give_forms'] = array( |
| 364 | - 1 => esc_html__( 'Form updated.', 'give' ), |
|
| 365 | - 4 => esc_html__( 'Form updated.', 'give' ), |
|
| 366 | - 6 => esc_html__( 'Form published.', 'give' ), |
|
| 367 | - 7 => esc_html__( 'Form saved.', 'give' ), |
|
| 368 | - 8 => esc_html__( 'Form submitted.', 'give' ) |
|
| 364 | + 1 => esc_html__('Form updated.', 'give'), |
|
| 365 | + 4 => esc_html__('Form updated.', 'give'), |
|
| 366 | + 6 => esc_html__('Form published.', 'give'), |
|
| 367 | + 7 => esc_html__('Form saved.', 'give'), |
|
| 368 | + 8 => esc_html__('Form submitted.', 'give') |
|
| 369 | 369 | ); |
| 370 | 370 | |
| 371 | 371 | } else { |
| 372 | 372 | |
| 373 | 373 | $messages['give_forms'] = array( |
| 374 | - 1 => sprintf( '%1$s <a href="%2$s">%3$s</a>', esc_html__( 'Form updated.', 'give' ), get_permalink( $post_ID ), esc_html__( 'View Form', 'give' ) ), |
|
| 375 | - 4 => sprintf( '%1$s <a href="%2$s">%3$s</a>', esc_html__( 'Form updated.', 'give' ), get_permalink( $post_ID ), esc_html__( 'View Form', 'give' ) ), |
|
| 376 | - 6 => sprintf( '%1$s <a href="%2$s">%3$s</a>', esc_html__( 'Form published.', 'give' ), get_permalink( $post_ID ), esc_html__( 'View Form', 'give' ) ), |
|
| 377 | - 7 => sprintf( '%1$s <a href="%2$s">%3$s</a>', esc_html__( 'Form saved.', 'give' ), get_permalink( $post_ID ), esc_html__( 'View Form', 'give' ) ), |
|
| 378 | - 8 => sprintf( '%1$s <a href="%2$s">%3$s</a>', esc_html__( 'Form submitted.', 'give' ), get_permalink( $post_ID ), esc_html__( 'View Form', 'give' ) ) |
|
| 374 | + 1 => sprintf('%1$s <a href="%2$s">%3$s</a>', esc_html__('Form updated.', 'give'), get_permalink($post_ID), esc_html__('View Form', 'give')), |
|
| 375 | + 4 => sprintf('%1$s <a href="%2$s">%3$s</a>', esc_html__('Form updated.', 'give'), get_permalink($post_ID), esc_html__('View Form', 'give')), |
|
| 376 | + 6 => sprintf('%1$s <a href="%2$s">%3$s</a>', esc_html__('Form published.', 'give'), get_permalink($post_ID), esc_html__('View Form', 'give')), |
|
| 377 | + 7 => sprintf('%1$s <a href="%2$s">%3$s</a>', esc_html__('Form saved.', 'give'), get_permalink($post_ID), esc_html__('View Form', 'give')), |
|
| 378 | + 8 => sprintf('%1$s <a href="%2$s">%3$s</a>', esc_html__('Form submitted.', 'give'), get_permalink($post_ID), esc_html__('View Form', 'give')) |
|
| 379 | 379 | ); |
| 380 | 380 | |
| 381 | 381 | } |
@@ -383,25 +383,25 @@ discard block |
||
| 383 | 383 | return $messages; |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | -add_filter( 'post_updated_messages', 'give_updated_messages' ); |
|
| 386 | +add_filter('post_updated_messages', 'give_updated_messages'); |
|
| 387 | 387 | |
| 388 | 388 | |
| 389 | 389 | /** |
| 390 | 390 | * Setup Post Type Images |
| 391 | 391 | */ |
| 392 | -add_action( 'after_setup_theme', 'give_add_thumbnail_support', 10 ); |
|
| 392 | +add_action('after_setup_theme', 'give_add_thumbnail_support', 10); |
|
| 393 | 393 | |
| 394 | 394 | /** |
| 395 | 395 | * Ensure post thumbnail support is turned on |
| 396 | 396 | */ |
| 397 | 397 | function give_add_thumbnail_support() { |
| 398 | - if ( give_get_option( 'disable_form_featured_img' ) === 'on' ) { |
|
| 398 | + if (give_get_option('disable_form_featured_img') === 'on') { |
|
| 399 | 399 | return; |
| 400 | 400 | } |
| 401 | - if ( ! current_theme_supports( 'post-thumbnails' ) ) { |
|
| 402 | - add_theme_support( 'post-thumbnails' ); |
|
| 401 | + if ( ! current_theme_supports('post-thumbnails')) { |
|
| 402 | + add_theme_support('post-thumbnails'); |
|
| 403 | 403 | } |
| 404 | - add_post_type_support( 'give_forms', 'thumbnail' ); |
|
| 404 | + add_post_type_support('give_forms', 'thumbnail'); |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | /** |
@@ -413,19 +413,19 @@ discard block |
||
| 413 | 413 | function give_widgets_init() { |
| 414 | 414 | |
| 415 | 415 | //Single Give Forms (disabled if single turned off in settings) |
| 416 | - if ( give_get_option( 'disable_forms_singular' ) !== 'on' && give_get_option( 'disable_form_sidebar' ) !== 'on' ) { |
|
| 416 | + if (give_get_option('disable_forms_singular') !== 'on' && give_get_option('disable_form_sidebar') !== 'on') { |
|
| 417 | 417 | |
| 418 | - register_sidebar( apply_filters( 'give_forms_single_sidebar', array( |
|
| 419 | - 'name' => esc_html__( 'Give Single Form Sidebar', 'give' ), |
|
| 418 | + register_sidebar(apply_filters('give_forms_single_sidebar', array( |
|
| 419 | + 'name' => esc_html__('Give Single Form Sidebar', 'give'), |
|
| 420 | 420 | 'id' => 'give-forms-sidebar', |
| 421 | - 'description' => esc_html__( 'Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give' ), |
|
| 421 | + 'description' => esc_html__('Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give'), |
|
| 422 | 422 | 'before_widget' => '<div id="%1$s" class="widget %2$s">', |
| 423 | 423 | 'after_widget' => '</div>', |
| 424 | 424 | 'before_title' => '<h3 class="widgettitle widget-title">', |
| 425 | 425 | 'after_title' => '</h3>', |
| 426 | - ) ) ); |
|
| 426 | + ))); |
|
| 427 | 427 | |
| 428 | 428 | } |
| 429 | 429 | } |
| 430 | 430 | |
| 431 | -add_action( 'widgets_init', 'give_widgets_init', 999 ); |
|
| 431 | +add_action('widgets_init', 'give_widgets_init', 999); |
|
@@ -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 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * |
| 20 | 20 | * @since 1.0 |
| 21 | 21 | */ |
| 22 | -class Give_Forms_Widget extends WP_Widget{ |
|
| 22 | +class Give_Forms_Widget extends WP_Widget { |
|
| 23 | 23 | /** |
| 24 | 24 | * The widget class name |
| 25 | 25 | * |
@@ -30,19 +30,19 @@ discard block |
||
| 30 | 30 | /** |
| 31 | 31 | * Instantiate the class |
| 32 | 32 | */ |
| 33 | - public function __construct(){ |
|
| 34 | - $this->self = get_class( $this ); |
|
| 33 | + public function __construct() { |
|
| 34 | + $this->self = get_class($this); |
|
| 35 | 35 | |
| 36 | 36 | parent::__construct( |
| 37 | - strtolower( $this->self ), |
|
| 38 | - esc_html__( 'Give - Donation Form', 'give' ), |
|
| 37 | + strtolower($this->self), |
|
| 38 | + esc_html__('Give - Donation Form', 'give'), |
|
| 39 | 39 | array( |
| 40 | - 'description' => esc_html__( 'Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give' ) |
|
| 40 | + 'description' => esc_html__('Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give') |
|
| 41 | 41 | ) |
| 42 | 42 | ); |
| 43 | 43 | |
| 44 | - add_action( 'widgets_init', array( $this, 'widget_init' ) ); |
|
| 45 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_widget_scripts' ) ); |
|
| 44 | + add_action('widgets_init', array($this, 'widget_init')); |
|
| 45 | + add_action('admin_enqueue_scripts', array($this, 'admin_widget_scripts')); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -52,23 +52,23 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @return void |
| 54 | 54 | */ |
| 55 | - public function admin_widget_scripts( $hook ){ |
|
| 55 | + public function admin_widget_scripts($hook) { |
|
| 56 | 56 | // Directories of assets |
| 57 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
| 58 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
| 59 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
| 57 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
| 58 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
| 59 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
| 60 | 60 | |
| 61 | 61 | // Use minified libraries if SCRIPT_DEBUG is turned off |
| 62 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
| 62 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
| 63 | 63 | |
| 64 | 64 | // Widget Script |
| 65 | - if ( $hook == 'widgets.php' ) { |
|
| 65 | + if ($hook == 'widgets.php') { |
|
| 66 | 66 | |
| 67 | - wp_enqueue_style( 'give-qtip-css', $css_dir . 'jquery.qtip' . $suffix . '.css' ); |
|
| 67 | + wp_enqueue_style('give-qtip-css', $css_dir.'jquery.qtip'.$suffix.'.css'); |
|
| 68 | 68 | |
| 69 | - wp_enqueue_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION ); |
|
| 69 | + wp_enqueue_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION); |
|
| 70 | 70 | |
| 71 | - wp_enqueue_script( 'give-admin-widgets-scripts', $js_dir . 'admin-widgets' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
| 71 | + wp_enqueue_script('give-admin-widgets-scripts', $js_dir.'admin-widgets'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
@@ -79,14 +79,14 @@ discard block |
||
| 79 | 79 | * before_widget, and after_widget. |
| 80 | 80 | * @param array $instance The settings for the particular instance of the widget. |
| 81 | 81 | */ |
| 82 | - public function widget( $args, $instance ){ |
|
| 83 | - $title = !empty( $instance['title'] ) ? $instance['title'] : ''; |
|
| 84 | - $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
|
| 82 | + public function widget($args, $instance) { |
|
| 83 | + $title = ! empty($instance['title']) ? $instance['title'] : ''; |
|
| 84 | + $title = apply_filters('widget_title', $title, $instance, $this->id_base); |
|
| 85 | 85 | |
| 86 | 86 | |
| 87 | 87 | // If user set float labels to global then check global float label setting and update donation form widget accordingly. |
| 88 | - if( ( 'global' === $instance['float_labels'] ) ) { |
|
| 89 | - $instance['float_labels'] = ( 'on' === give_get_option( 'enable_floatlabels', '' ) ) ? 'enabled' : 'disabled'; |
|
| 88 | + if (('global' === $instance['float_labels'])) { |
|
| 89 | + $instance['float_labels'] = ('on' === give_get_option('enable_floatlabels', '')) ? 'enabled' : 'disabled'; |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | echo $args['before_widget']; |
@@ -96,11 +96,11 @@ discard block |
||
| 96 | 96 | * |
| 97 | 97 | * @since 1.0 |
| 98 | 98 | */ |
| 99 | - do_action( 'give_before_forms_widget' ); |
|
| 99 | + do_action('give_before_forms_widget'); |
|
| 100 | 100 | |
| 101 | - echo $title ? $args['before_title'] . $title . $args['after_title'] : ''; |
|
| 101 | + echo $title ? $args['before_title'].$title.$args['after_title'] : ''; |
|
| 102 | 102 | |
| 103 | - give_get_donation_form( $instance ); |
|
| 103 | + give_get_donation_form($instance); |
|
| 104 | 104 | |
| 105 | 105 | echo $args['after_widget']; |
| 106 | 106 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | * |
| 110 | 110 | * @since 1.0 |
| 111 | 111 | */ |
| 112 | - do_action( 'give_after_forms_widget' ); |
|
| 112 | + do_action('give_after_forms_widget'); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | * |
| 120 | 120 | * @return string |
| 121 | 121 | */ |
| 122 | - public function form( $instance ){ |
|
| 122 | + public function form($instance) { |
|
| 123 | 123 | $defaults = array( |
| 124 | 124 | 'title' => '', |
| 125 | 125 | 'id' => '', |
@@ -127,64 +127,64 @@ discard block |
||
| 127 | 127 | 'display_style' => 'modal', |
| 128 | 128 | ); |
| 129 | 129 | |
| 130 | - $instance = wp_parse_args( (array) $instance, $defaults ); |
|
| 130 | + $instance = wp_parse_args((array) $instance, $defaults); |
|
| 131 | 131 | |
| 132 | 132 | // Backward compatibility: Set float labels as default if, it was set as empty previous. |
| 133 | - $instance['float_labels'] = empty( $instance['float_labels'] ) ? 'global' : $instance['float_labels']; |
|
| 133 | + $instance['float_labels'] = empty($instance['float_labels']) ? 'global' : $instance['float_labels']; |
|
| 134 | 134 | |
| 135 | 135 | // Query Give Forms |
| 136 | 136 | $args = array( |
| 137 | 137 | 'post_type' => 'give_forms', |
| 138 | - 'posts_per_page' => - 1, |
|
| 138 | + 'posts_per_page' => -1, |
|
| 139 | 139 | 'post_status' => 'publish', |
| 140 | 140 | ); |
| 141 | 141 | |
| 142 | - $give_forms = get_posts( $args ); |
|
| 142 | + $give_forms = get_posts($args); |
|
| 143 | 143 | |
| 144 | 144 | // Widget: Title |
| 145 | 145 | |
| 146 | 146 | ?><p> |
| 147 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ); ?></label> |
|
| 148 | - <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php esc_attr_e( $instance['title'] ); ?>" /><br> |
|
| 149 | - <small class="give-field-description"><?php esc_html_e( 'Leave blank to hide the widget title.', 'give' ); ?></small> |
|
| 147 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give'); ?></label> |
|
| 148 | + <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php esc_attr_e($instance['title']); ?>" /><br> |
|
| 149 | + <small class="give-field-description"><?php esc_html_e('Leave blank to hide the widget title.', 'give'); ?></small> |
|
| 150 | 150 | </p><?php |
| 151 | 151 | |
| 152 | 152 | // Widget: Give Form |
| 153 | 153 | |
| 154 | 154 | ?><p> |
| 155 | - <label for="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"><?php esc_html_e( 'Give Form:', 'give' ); ?></label> |
|
| 156 | - <select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'id' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"> |
|
| 157 | - <option value="current"><?php esc_html_e( '- Select -', 'give' ); ?></option> |
|
| 158 | - <?php foreach ( $give_forms as $give_form ) { ?> |
|
| 159 | - <option <?php selected( absint( $instance['id'] ), $give_form->ID ); ?> value="<?php echo esc_attr( $give_form->ID ); ?>"><?php echo $give_form->post_title; ?></option> |
|
| 155 | + <label for="<?php echo esc_attr($this->get_field_id('id')); ?>"><?php esc_html_e('Give Form:', 'give'); ?></label> |
|
| 156 | + <select class="widefat" name="<?php echo esc_attr($this->get_field_name('id')); ?>" id="<?php echo esc_attr($this->get_field_id('id')); ?>"> |
|
| 157 | + <option value="current"><?php esc_html_e('- Select -', 'give'); ?></option> |
|
| 158 | + <?php foreach ($give_forms as $give_form) { ?> |
|
| 159 | + <option <?php selected(absint($instance['id']), $give_form->ID); ?> value="<?php echo esc_attr($give_form->ID); ?>"><?php echo $give_form->post_title; ?></option> |
|
| 160 | 160 | <?php } ?> |
| 161 | 161 | </select><br> |
| 162 | - <small class="give-field-description"><?php esc_html_e( 'Select a Give Form to embed in this widget.', 'give' ); ?></small> |
|
| 162 | + <small class="give-field-description"><?php esc_html_e('Select a Give Form to embed in this widget.', 'give'); ?></small> |
|
| 163 | 163 | </p> |
| 164 | 164 | |
| 165 | 165 | <?php // Widget: Display Style ?> |
| 166 | 166 | <p> |
| 167 | - <label for="<?php echo esc_attr( $this->get_field_id( 'display_style' ) ); ?>"><?php esc_html_e( 'Display style:', 'give' ); ?></label><br> |
|
| 168 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-onpage"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-onpage" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="onpage" <?php checked( $instance['display_style'], 'onpage' ); ?>> <?php echo esc_html__( 'All Fields', 'give' ); ?></label> |
|
| 169 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-reveal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-reveal" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="reveal" <?php checked( $instance['display_style'], 'reveal' ); ?>> <?php echo esc_html__( 'Reveal', 'give' ); ?></label> |
|
| 170 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-modal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-modal" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="modal" <?php checked( $instance['display_style'], 'modal' ); ?>> <?php echo esc_html__( 'Modal', 'give' ); ?></label><br> |
|
| 167 | + <label for="<?php echo esc_attr($this->get_field_id('display_style')); ?>"><?php esc_html_e('Display style:', 'give'); ?></label><br> |
|
| 168 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-onpage"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-onpage" name="<?php echo $this->get_field_name('display_style'); ?>" value="onpage" <?php checked($instance['display_style'], 'onpage'); ?>> <?php echo esc_html__('All Fields', 'give'); ?></label> |
|
| 169 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-reveal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-reveal" name="<?php echo $this->get_field_name('display_style'); ?>" value="reveal" <?php checked($instance['display_style'], 'reveal'); ?>> <?php echo esc_html__('Reveal', 'give'); ?></label> |
|
| 170 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-modal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-modal" name="<?php echo $this->get_field_name('display_style'); ?>" value="modal" <?php checked($instance['display_style'], 'modal'); ?>> <?php echo esc_html__('Modal', 'give'); ?></label><br> |
|
| 171 | 171 | <small class="give-field-description"> |
| 172 | - <?php echo esc_html__( 'Select a Give Form style.', 'give' ); ?> |
|
| 172 | + <?php echo esc_html__('Select a Give Form style.', 'give'); ?> |
|
| 173 | 173 | </small> |
| 174 | 174 | </p> |
| 175 | 175 | |
| 176 | 176 | <?php // Widget: Floating Labels ?> |
| 177 | 177 | <p> |
| 178 | - <label for="<?php echo esc_attr( $this->get_field_id( 'float_labels' ) ); ?>"><?php esc_html_e( 'Floating Labels (optional):', 'give' ); ?></label><br> |
|
| 179 | - <label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-global"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-global" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="global" <?php checked( $instance['float_labels'], 'global' ); ?>> <?php echo esc_html__( 'Global Options', 'give' ); ?></label> |
|
| 180 | - <label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-enabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-enabled" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="enabled" <?php checked( $instance['float_labels'], 'enabled' ); ?>> <?php echo esc_html__( 'Yes', 'give' ); ?></label> |
|
| 181 | - <label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-disabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-disabled" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="disabled" <?php checked( $instance['float_labels'], 'disabled' ); ?>> <?php echo esc_html__( 'No', 'give' ); ?></label><br> |
|
| 178 | + <label for="<?php echo esc_attr($this->get_field_id('float_labels')); ?>"><?php esc_html_e('Floating Labels (optional):', 'give'); ?></label><br> |
|
| 179 | + <label for="<?php echo $this->get_field_id('float_labels'); ?>-global"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-global" name="<?php echo $this->get_field_name('float_labels'); ?>" value="global" <?php checked($instance['float_labels'], 'global'); ?>> <?php echo esc_html__('Global Options', 'give'); ?></label> |
|
| 180 | + <label for="<?php echo $this->get_field_id('float_labels'); ?>-enabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-enabled" name="<?php echo $this->get_field_name('float_labels'); ?>" value="enabled" <?php checked($instance['float_labels'], 'enabled'); ?>> <?php echo esc_html__('Yes', 'give'); ?></label> |
|
| 181 | + <label for="<?php echo $this->get_field_id('float_labels'); ?>-disabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-disabled" name="<?php echo $this->get_field_name('float_labels'); ?>" value="disabled" <?php checked($instance['float_labels'], 'disabled'); ?>> <?php echo esc_html__('No', 'give'); ?></label><br> |
|
| 182 | 182 | <small class="give-field-description"> |
| 183 | 183 | <?php |
| 184 | 184 | printf( |
| 185 | 185 | /* translators: %s: https://givewp.com/documentation/core/give-forms/creating-give-forms/#floating-labels */ |
| 186 | - __( 'Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give' ), |
|
| 187 | - esc_url( 'https://givewp.com/documentation/core/give-forms/creating-give-forms/#floating-labels' ) |
|
| 186 | + __('Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give'), |
|
| 187 | + esc_url('https://givewp.com/documentation/core/give-forms/creating-give-forms/#floating-labels') |
|
| 188 | 188 | ); |
| 189 | 189 | ?></small> |
| 190 | 190 | </p><?php |
@@ -195,8 +195,8 @@ discard block |
||
| 195 | 195 | * |
| 196 | 196 | * @return void |
| 197 | 197 | */ |
| 198 | - function widget_init(){ |
|
| 199 | - register_widget( $this->self ); |
|
| 198 | + function widget_init() { |
|
| 199 | + register_widget($this->self); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | /** |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | * |
| 208 | 208 | * @return array |
| 209 | 209 | */ |
| 210 | - public function update( $new_instance, $old_instance ){ |
|
| 210 | + public function update($new_instance, $old_instance) { |
|
| 211 | 211 | $this->flush_widget_cache(); |
| 212 | 212 | |
| 213 | 213 | return $new_instance; |
@@ -218,8 +218,8 @@ discard block |
||
| 218 | 218 | * |
| 219 | 219 | * @return void |
| 220 | 220 | */ |
| 221 | - public function flush_widget_cache(){ |
|
| 222 | - wp_cache_delete( $this->self, 'widget' ); |
|
| 221 | + public function flush_widget_cache() { |
|
| 222 | + wp_cache_delete($this->self, 'widget'); |
|
| 223 | 223 | } |
| 224 | 224 | } |
| 225 | 225 | |
@@ -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,14 +23,14 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | global $typenow; |
| 25 | 25 | |
| 26 | - if ( $typenow != 'give_forms' ) { |
|
| 26 | + if ($typenow != 'give_forms') { |
|
| 27 | 27 | return true; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | return false; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | -add_filter( 'give_shortcode_button_condition', 'give_shortcode_button_condition' ); |
|
| 33 | +add_filter('give_shortcode_button_condition', 'give_shortcode_button_condition'); |
|
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -40,11 +40,11 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @return int|false |
| 42 | 42 | */ |
| 43 | -function get_form_id_from_args( $args ) { |
|
| 43 | +function get_form_id_from_args($args) { |
|
| 44 | 44 | |
| 45 | - if ( isset( $args['form_id'] ) && $args['form_id'] != 0 ) { |
|
| 45 | + if (isset($args['form_id']) && $args['form_id'] != 0) { |
|
| 46 | 46 | |
| 47 | - return intval( $args['form_id'] ); |
|
| 47 | + return intval($args['form_id']); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | return false; |
@@ -59,23 +59,23 @@ discard block |
||
| 59 | 59 | * |
| 60 | 60 | * @return bool |
| 61 | 61 | */ |
| 62 | -function give_is_float_labels_enabled( $args ) { |
|
| 62 | +function give_is_float_labels_enabled($args) { |
|
| 63 | 63 | |
| 64 | 64 | $float_labels = ''; |
| 65 | 65 | |
| 66 | - if ( ! empty( $args['float_labels'] ) ) { |
|
| 66 | + if ( ! empty($args['float_labels'])) { |
|
| 67 | 67 | $float_labels = $args['float_labels']; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - if ( empty( $float_labels ) ) { |
|
| 71 | - $float_labels = get_post_meta( $args['form_id'], '_give_form_floating_labels', true ); |
|
| 70 | + if (empty($float_labels)) { |
|
| 71 | + $float_labels = get_post_meta($args['form_id'], '_give_form_floating_labels', true); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if ( empty( $float_labels ) ) { |
|
| 75 | - $float_labels = give_get_option( 'enable_floatlabels' ) ? 'enabled' : 'disabled'; |
|
| 74 | + if (empty($float_labels)) { |
|
| 75 | + $float_labels = give_get_option('enable_floatlabels') ? 'enabled' : 'disabled'; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - return ( $float_labels == 'enabled' ) ? true : false; |
|
| 78 | + return ($float_labels == 'enabled') ? true : false; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | $can_checkout = true; |
| 93 | 93 | |
| 94 | - return (bool) apply_filters( 'give_can_checkout', $can_checkout ); |
|
| 94 | + return (bool) apply_filters('give_can_checkout', $can_checkout); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -105,9 +105,9 @@ discard block |
||
| 105 | 105 | function give_get_success_page_uri() { |
| 106 | 106 | $give_options = give_get_settings(); |
| 107 | 107 | |
| 108 | - $success_page = isset( $give_options['success_page'] ) ? get_permalink( absint( $give_options['success_page'] ) ) : get_bloginfo( 'url' ); |
|
| 108 | + $success_page = isset($give_options['success_page']) ? get_permalink(absint($give_options['success_page'])) : get_bloginfo('url'); |
|
| 109 | 109 | |
| 110 | - return apply_filters( 'give_get_success_page_uri', $success_page ); |
|
| 110 | + return apply_filters('give_get_success_page_uri', $success_page); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
@@ -119,9 +119,9 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | function give_is_success_page() { |
| 121 | 121 | $give_options = give_get_settings(); |
| 122 | - $is_success_page = isset( $give_options['success_page'] ) ? is_page( $give_options['success_page'] ) : false; |
|
| 122 | + $is_success_page = isset($give_options['success_page']) ? is_page($give_options['success_page']) : false; |
|
| 123 | 123 | |
| 124 | - return apply_filters( 'give_is_success_page', $is_success_page ); |
|
| 124 | + return apply_filters('give_is_success_page', $is_success_page); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -135,17 +135,17 @@ discard block |
||
| 135 | 135 | * @since 1.0 |
| 136 | 136 | * @return void |
| 137 | 137 | */ |
| 138 | -function give_send_to_success_page( $query_string = null ) { |
|
| 138 | +function give_send_to_success_page($query_string = null) { |
|
| 139 | 139 | |
| 140 | 140 | $redirect = give_get_success_page_uri(); |
| 141 | 141 | |
| 142 | - if ( $query_string ) { |
|
| 142 | + if ($query_string) { |
|
| 143 | 143 | $redirect .= $query_string; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - $gateway = isset( $_REQUEST['give-gateway'] ) ? $_REQUEST['give-gateway'] : ''; |
|
| 146 | + $gateway = isset($_REQUEST['give-gateway']) ? $_REQUEST['give-gateway'] : ''; |
|
| 147 | 147 | |
| 148 | - wp_redirect( apply_filters( 'give_success_page_redirect', $redirect, $gateway, $query_string ) ); |
|
| 148 | + wp_redirect(apply_filters('give_success_page_redirect', $redirect, $gateway, $query_string)); |
|
| 149 | 149 | give_die(); |
| 150 | 150 | } |
| 151 | 151 | |
@@ -161,20 +161,20 @@ discard block |
||
| 161 | 161 | * @since 1.0 |
| 162 | 162 | * @return Void |
| 163 | 163 | */ |
| 164 | -function give_send_back_to_checkout( $args = array() ) { |
|
| 164 | +function give_send_back_to_checkout($args = array()) { |
|
| 165 | 165 | |
| 166 | - $url = isset( $_POST['give-current-url'] ) ? sanitize_text_field( $_POST['give-current-url'] ) : ''; |
|
| 166 | + $url = isset($_POST['give-current-url']) ? sanitize_text_field($_POST['give-current-url']) : ''; |
|
| 167 | 167 | |
| 168 | 168 | //Set the form_id. |
| 169 | - if ( isset( $_POST['give-form-id'] ) ) { |
|
| 170 | - $form_id = sanitize_text_field( $_POST['give-form-id'] ); |
|
| 169 | + if (isset($_POST['give-form-id'])) { |
|
| 170 | + $form_id = sanitize_text_field($_POST['give-form-id']); |
|
| 171 | 171 | } else { |
| 172 | 172 | $form_id = 0; |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | //Need a URL to continue. If none, redirect back to single form. |
| 176 | - if ( empty( $url ) ) { |
|
| 177 | - wp_safe_redirect( get_permalink( $form_id ) ); |
|
| 176 | + if (empty($url)) { |
|
| 177 | + wp_safe_redirect(get_permalink($form_id)); |
|
| 178 | 178 | give_die(); |
| 179 | 179 | } |
| 180 | 180 | |
@@ -183,36 +183,36 @@ discard block |
||
| 183 | 183 | ); |
| 184 | 184 | |
| 185 | 185 | // Check for backward compatibility. |
| 186 | - if ( is_string( $args ) ) { |
|
| 187 | - $args = str_replace( '?', '', $args ); |
|
| 186 | + if (is_string($args)) { |
|
| 187 | + $args = str_replace('?', '', $args); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - $args = wp_parse_args( $args, $defaults ); |
|
| 190 | + $args = wp_parse_args($args, $defaults); |
|
| 191 | 191 | |
| 192 | 192 | // Merge URL query with $args to maintain third-party URL parameters after redirect. |
| 193 | - $url_data = wp_parse_url( $url ); |
|
| 193 | + $url_data = wp_parse_url($url); |
|
| 194 | 194 | |
| 195 | 195 | //Check if an array to prevent notices before parsing. |
| 196 | - if ( isset( $url_data['query'] ) && ! empty( $url_data['query'] ) ) { |
|
| 197 | - parse_str( $url_data['query'], $query ); |
|
| 196 | + if (isset($url_data['query']) && ! empty($url_data['query'])) { |
|
| 197 | + parse_str($url_data['query'], $query); |
|
| 198 | 198 | |
| 199 | 199 | //Precaution: don't allow any CC info. |
| 200 | - unset( $query['card_number'] ); |
|
| 201 | - unset( $query['card_cvc'] ); |
|
| 200 | + unset($query['card_number']); |
|
| 201 | + unset($query['card_cvc']); |
|
| 202 | 202 | |
| 203 | 203 | } else { |
| 204 | 204 | //No $url_data so pass empty array. |
| 205 | 205 | $query = array(); |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - $new_query = array_merge( $args, $query ); |
|
| 209 | - $new_query_string = http_build_query( $new_query ); |
|
| 208 | + $new_query = array_merge($args, $query); |
|
| 209 | + $new_query_string = http_build_query($new_query); |
|
| 210 | 210 | |
| 211 | 211 | // Assemble URL parts. |
| 212 | - $redirect = home_url( '/' . $url_data['path'] . '?' . $new_query_string . '#give-form-' . $form_id . '-wrap' ); |
|
| 212 | + $redirect = home_url('/'.$url_data['path'].'?'.$new_query_string.'#give-form-'.$form_id.'-wrap'); |
|
| 213 | 213 | |
| 214 | 214 | //Redirect them. |
| 215 | - wp_safe_redirect( apply_filters( 'give_send_back_to_checkout', $redirect, $args ) ); |
|
| 215 | + wp_safe_redirect(apply_filters('give_send_back_to_checkout', $redirect, $args)); |
|
| 216 | 216 | give_die(); |
| 217 | 217 | |
| 218 | 218 | } |
@@ -228,16 +228,16 @@ discard block |
||
| 228 | 228 | * @since 1.0 |
| 229 | 229 | * @return string |
| 230 | 230 | */ |
| 231 | -function give_get_success_page_url( $query_string = null ) { |
|
| 231 | +function give_get_success_page_url($query_string = null) { |
|
| 232 | 232 | |
| 233 | - $success_page = give_get_option( 'success_page', 0 ); |
|
| 234 | - $success_page = get_permalink( $success_page ); |
|
| 233 | + $success_page = give_get_option('success_page', 0); |
|
| 234 | + $success_page = get_permalink($success_page); |
|
| 235 | 235 | |
| 236 | - if ( $query_string ) { |
|
| 236 | + if ($query_string) { |
|
| 237 | 237 | $success_page .= $query_string; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - return apply_filters( 'give_success_page_url', $success_page ); |
|
| 240 | + return apply_filters('give_success_page_url', $success_page); |
|
| 241 | 241 | |
| 242 | 242 | } |
| 243 | 243 | |
@@ -250,15 +250,15 @@ discard block |
||
| 250 | 250 | * |
| 251 | 251 | * @return mixed|void Full URL to the Failed Donation Page, if present, home page if it doesn't exist |
| 252 | 252 | */ |
| 253 | -function give_get_failed_transaction_uri( $extras = false ) { |
|
| 253 | +function give_get_failed_transaction_uri($extras = false) { |
|
| 254 | 254 | $give_options = give_get_settings(); |
| 255 | 255 | |
| 256 | - $uri = ! empty( $give_options['failure_page'] ) ? trailingslashit( get_permalink( $give_options['failure_page'] ) ) : home_url(); |
|
| 257 | - if ( $extras ) { |
|
| 256 | + $uri = ! empty($give_options['failure_page']) ? trailingslashit(get_permalink($give_options['failure_page'])) : home_url(); |
|
| 257 | + if ($extras) { |
|
| 258 | 258 | $uri .= $extras; |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - return apply_filters( 'give_get_failed_transaction_uri', $uri ); |
|
| 261 | + return apply_filters('give_get_failed_transaction_uri', $uri); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | /** |
@@ -269,9 +269,9 @@ discard block |
||
| 269 | 269 | */ |
| 270 | 270 | function give_is_failed_transaction_page() { |
| 271 | 271 | $give_options = give_get_settings(); |
| 272 | - $ret = isset( $give_options['failure_page'] ) ? is_page( $give_options['failure_page'] ) : false; |
|
| 272 | + $ret = isset($give_options['failure_page']) ? is_page($give_options['failure_page']) : false; |
|
| 273 | 273 | |
| 274 | - return apply_filters( 'give_is_failure_page', $ret ); |
|
| 274 | + return apply_filters('give_is_failure_page', $ret); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |
@@ -283,18 +283,18 @@ discard block |
||
| 283 | 283 | */ |
| 284 | 284 | function give_listen_for_failed_payments() { |
| 285 | 285 | |
| 286 | - $failed_page = give_get_option( 'failure_page', 0 ); |
|
| 286 | + $failed_page = give_get_option('failure_page', 0); |
|
| 287 | 287 | |
| 288 | - if ( ! empty( $failed_page ) && is_page( $failed_page ) && ! empty( $_GET['payment-id'] ) ) { |
|
| 288 | + if ( ! empty($failed_page) && is_page($failed_page) && ! empty($_GET['payment-id'])) { |
|
| 289 | 289 | |
| 290 | - $payment_id = absint( $_GET['payment-id'] ); |
|
| 291 | - give_update_payment_status( $payment_id, 'failed' ); |
|
| 290 | + $payment_id = absint($_GET['payment-id']); |
|
| 291 | + give_update_payment_status($payment_id, 'failed'); |
|
| 292 | 292 | |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | -add_action( 'template_redirect', 'give_listen_for_failed_payments' ); |
|
| 297 | +add_action('template_redirect', 'give_listen_for_failed_payments'); |
|
| 298 | 298 | |
| 299 | 299 | /** |
| 300 | 300 | * Retrieve the Donation History page URI |
@@ -307,9 +307,9 @@ discard block |
||
| 307 | 307 | function give_get_history_page_uri() { |
| 308 | 308 | $give_options = give_get_settings(); |
| 309 | 309 | |
| 310 | - $history_page = isset( $give_options['history_page'] ) ? get_permalink( absint( $give_options['history_page'] ) ) : get_bloginfo( 'url' ); |
|
| 310 | + $history_page = isset($give_options['history_page']) ? get_permalink(absint($give_options['history_page'])) : get_bloginfo('url'); |
|
| 311 | 311 | |
| 312 | - return apply_filters( 'give_get_history_page_uri', $history_page ); |
|
| 312 | + return apply_filters('give_get_history_page_uri', $history_page); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | /** |
@@ -322,11 +322,11 @@ discard block |
||
| 322 | 322 | * @since 1.0 |
| 323 | 323 | * @return bool |
| 324 | 324 | */ |
| 325 | -function give_field_is_required( $field = '', $form_id ) { |
|
| 325 | +function give_field_is_required($field = '', $form_id) { |
|
| 326 | 326 | |
| 327 | - $required_fields = give_purchase_form_required_fields( $form_id ); |
|
| 327 | + $required_fields = give_purchase_form_required_fields($form_id); |
|
| 328 | 328 | |
| 329 | - return array_key_exists( $field, $required_fields ); |
|
| 329 | + return array_key_exists($field, $required_fields); |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | /** |
@@ -344,14 +344,14 @@ discard block |
||
| 344 | 344 | * |
| 345 | 345 | * @return void |
| 346 | 346 | */ |
| 347 | -function give_record_sale_in_log( $give_form_id = 0, $payment_id, $price_id = false, $sale_date = null ) { |
|
| 347 | +function give_record_sale_in_log($give_form_id = 0, $payment_id, $price_id = false, $sale_date = null) { |
|
| 348 | 348 | global $give_logs; |
| 349 | 349 | |
| 350 | 350 | $log_data = array( |
| 351 | 351 | 'post_parent' => $give_form_id, |
| 352 | 352 | 'log_type' => 'sale', |
| 353 | - 'post_date' => isset( $sale_date ) ? $sale_date : null, |
|
| 354 | - 'post_date_gmt' => isset( $sale_date ) ? $sale_date : null |
|
| 353 | + 'post_date' => isset($sale_date) ? $sale_date : null, |
|
| 354 | + 'post_date_gmt' => isset($sale_date) ? $sale_date : null |
|
| 355 | 355 | ); |
| 356 | 356 | |
| 357 | 357 | $log_meta = array( |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | 'price_id' => (int) $price_id |
| 360 | 360 | ); |
| 361 | 361 | |
| 362 | - $give_logs->insert_log( $log_data, $log_meta ); |
|
| 362 | + $give_logs->insert_log($log_data, $log_meta); |
|
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | |
@@ -373,11 +373,11 @@ discard block |
||
| 373 | 373 | * |
| 374 | 374 | * @return bool|int |
| 375 | 375 | */ |
| 376 | -function give_increase_purchase_count( $form_id = 0, $quantity = 1 ) { |
|
| 376 | +function give_increase_purchase_count($form_id = 0, $quantity = 1) { |
|
| 377 | 377 | $quantity = (int) $quantity; |
| 378 | - $form = new Give_Donate_Form( $form_id ); |
|
| 378 | + $form = new Give_Donate_Form($form_id); |
|
| 379 | 379 | |
| 380 | - return $form->increase_sales( $quantity ); |
|
| 380 | + return $form->increase_sales($quantity); |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | /** |
@@ -390,11 +390,11 @@ discard block |
||
| 390 | 390 | * |
| 391 | 391 | * @return bool|int |
| 392 | 392 | */ |
| 393 | -function give_decrease_purchase_count( $form_id = 0, $quantity = 1 ) { |
|
| 393 | +function give_decrease_purchase_count($form_id = 0, $quantity = 1) { |
|
| 394 | 394 | $quantity = (int) $quantity; |
| 395 | - $form = new Give_Donate_Form( $form_id ); |
|
| 395 | + $form = new Give_Donate_Form($form_id); |
|
| 396 | 396 | |
| 397 | - return $form->decrease_sales( $quantity ); |
|
| 397 | + return $form->decrease_sales($quantity); |
|
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | /** |
@@ -407,10 +407,10 @@ discard block |
||
| 407 | 407 | * |
| 408 | 408 | * @return bool|int |
| 409 | 409 | */ |
| 410 | -function give_increase_earnings( $give_form_id = 0, $amount ) { |
|
| 411 | - $form = new Give_Donate_Form( $give_form_id ); |
|
| 410 | +function give_increase_earnings($give_form_id = 0, $amount) { |
|
| 411 | + $form = new Give_Donate_Form($give_form_id); |
|
| 412 | 412 | |
| 413 | - return $form->increase_earnings( $amount ); |
|
| 413 | + return $form->increase_earnings($amount); |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | /** |
@@ -423,10 +423,10 @@ discard block |
||
| 423 | 423 | * |
| 424 | 424 | * @return bool|int |
| 425 | 425 | */ |
| 426 | -function give_decrease_earnings( $form_id = 0, $amount ) { |
|
| 427 | - $form = new Give_Donate_Form( $form_id ); |
|
| 426 | +function give_decrease_earnings($form_id = 0, $amount) { |
|
| 427 | + $form = new Give_Donate_Form($form_id); |
|
| 428 | 428 | |
| 429 | - return $form->decrease_earnings( $amount ); |
|
| 429 | + return $form->decrease_earnings($amount); |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | |
@@ -439,8 +439,8 @@ discard block |
||
| 439 | 439 | * |
| 440 | 440 | * @return int $earnings Earnings for a certain form |
| 441 | 441 | */ |
| 442 | -function give_get_form_earnings_stats( $form_id = 0 ) { |
|
| 443 | - $give_form = new Give_Donate_Form( $form_id ); |
|
| 442 | +function give_get_form_earnings_stats($form_id = 0) { |
|
| 443 | + $give_form = new Give_Donate_Form($form_id); |
|
| 444 | 444 | |
| 445 | 445 | return $give_form->earnings; |
| 446 | 446 | } |
@@ -455,8 +455,8 @@ discard block |
||
| 455 | 455 | * |
| 456 | 456 | * @return int $sales Amount of sales for a certain form |
| 457 | 457 | */ |
| 458 | -function give_get_form_sales_stats( $give_form_id = 0 ) { |
|
| 459 | - $give_form = new Give_Donate_Form( $give_form_id ); |
|
| 458 | +function give_get_form_sales_stats($give_form_id = 0) { |
|
| 459 | + $give_form = new Give_Donate_Form($give_form_id); |
|
| 460 | 460 | |
| 461 | 461 | return $give_form->sales; |
| 462 | 462 | } |
@@ -471,16 +471,16 @@ discard block |
||
| 471 | 471 | * |
| 472 | 472 | * @return float $sales Average monthly sales |
| 473 | 473 | */ |
| 474 | -function give_get_average_monthly_form_sales( $form_id = 0 ) { |
|
| 475 | - $sales = give_get_form_sales_stats( $form_id ); |
|
| 476 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
| 474 | +function give_get_average_monthly_form_sales($form_id = 0) { |
|
| 475 | + $sales = give_get_form_sales_stats($form_id); |
|
| 476 | + $release_date = get_post_field('post_date', $form_id); |
|
| 477 | 477 | |
| 478 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
| 478 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
| 479 | 479 | |
| 480 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
| 480 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
| 481 | 481 | |
| 482 | - if ( $months > 0 ) { |
|
| 483 | - $sales = ( $sales / $months ); |
|
| 482 | + if ($months > 0) { |
|
| 483 | + $sales = ($sales / $months); |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | return $sales; |
@@ -496,16 +496,16 @@ discard block |
||
| 496 | 496 | * |
| 497 | 497 | * @return float $earnings Average monthly earnings |
| 498 | 498 | */ |
| 499 | -function give_get_average_monthly_form_earnings( $form_id = 0 ) { |
|
| 500 | - $earnings = give_get_form_earnings_stats( $form_id ); |
|
| 501 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
| 499 | +function give_get_average_monthly_form_earnings($form_id = 0) { |
|
| 500 | + $earnings = give_get_form_earnings_stats($form_id); |
|
| 501 | + $release_date = get_post_field('post_date', $form_id); |
|
| 502 | 502 | |
| 503 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
| 503 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
| 504 | 504 | |
| 505 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
| 505 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
| 506 | 506 | |
| 507 | - if ( $months > 0 ) { |
|
| 508 | - $earnings = ( $earnings / $months ); |
|
| 507 | + if ($months > 0) { |
|
| 508 | + $earnings = ($earnings / $months); |
|
| 509 | 509 | } |
| 510 | 510 | |
| 511 | 511 | return $earnings < 0 ? 0 : $earnings; |
@@ -525,25 +525,25 @@ discard block |
||
| 525 | 525 | * |
| 526 | 526 | * @return string $price_name Name of the price option |
| 527 | 527 | */ |
| 528 | -function give_get_price_option_name( $form_id = 0, $price_id = 0, $payment_id = 0 ) { |
|
| 528 | +function give_get_price_option_name($form_id = 0, $price_id = 0, $payment_id = 0) { |
|
| 529 | 529 | |
| 530 | - $prices = give_get_variable_prices( $form_id ); |
|
| 530 | + $prices = give_get_variable_prices($form_id); |
|
| 531 | 531 | $price_name = ''; |
| 532 | 532 | |
| 533 | - foreach ( $prices as $price ) { |
|
| 533 | + foreach ($prices as $price) { |
|
| 534 | 534 | |
| 535 | - if ( intval( $price['_give_id']['level_id'] ) == intval( $price_id ) ) { |
|
| 535 | + if (intval($price['_give_id']['level_id']) == intval($price_id)) { |
|
| 536 | 536 | |
| 537 | - $price_text = isset( $price['_give_text'] ) ? $price['_give_text'] : ''; |
|
| 538 | - $price_fallback = give_currency_filter( give_format_amount( $price['_give_amount'] ) ); |
|
| 539 | - $price_name = ! empty( $price_text ) ? $price_text : $price_fallback; |
|
| 537 | + $price_text = isset($price['_give_text']) ? $price['_give_text'] : ''; |
|
| 538 | + $price_fallback = give_currency_filter(give_format_amount($price['_give_amount'])); |
|
| 539 | + $price_name = ! empty($price_text) ? $price_text : $price_fallback; |
|
| 540 | 540 | |
| 541 | 541 | } |
| 542 | 542 | |
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | |
| 546 | - return apply_filters( 'give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id ); |
|
| 546 | + return apply_filters('give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id); |
|
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | |
@@ -556,14 +556,14 @@ discard block |
||
| 556 | 556 | * |
| 557 | 557 | * @return string $range A fully formatted price range |
| 558 | 558 | */ |
| 559 | -function give_price_range( $form_id = 0 ) { |
|
| 560 | - $low = give_get_lowest_price_option( $form_id ); |
|
| 561 | - $high = give_get_highest_price_option( $form_id ); |
|
| 562 | - $range = '<span class="give_price_range_low">' . give_currency_filter( give_format_amount( $low ) ) . '</span>'; |
|
| 559 | +function give_price_range($form_id = 0) { |
|
| 560 | + $low = give_get_lowest_price_option($form_id); |
|
| 561 | + $high = give_get_highest_price_option($form_id); |
|
| 562 | + $range = '<span class="give_price_range_low">'.give_currency_filter(give_format_amount($low)).'</span>'; |
|
| 563 | 563 | $range .= '<span class="give_price_range_sep"> – </span>'; |
| 564 | - $range .= '<span class="give_price_range_high">' . give_currency_filter( give_format_amount( $high ) ) . '</span>'; |
|
| 564 | + $range .= '<span class="give_price_range_high">'.give_currency_filter(give_format_amount($high)).'</span>'; |
|
| 565 | 565 | |
| 566 | - return apply_filters( 'give_price_range', $range, $form_id, $low, $high ); |
|
| 566 | + return apply_filters('give_price_range', $range, $form_id, $low, $high); |
|
| 567 | 567 | } |
| 568 | 568 | |
| 569 | 569 | |
@@ -578,36 +578,36 @@ discard block |
||
| 578 | 578 | * |
| 579 | 579 | * @return int ID of the lowest price |
| 580 | 580 | */ |
| 581 | -function give_get_lowest_price_id( $form_id = 0 ) { |
|
| 581 | +function give_get_lowest_price_id($form_id = 0) { |
|
| 582 | 582 | |
| 583 | - if ( empty( $form_id ) ) { |
|
| 583 | + if (empty($form_id)) { |
|
| 584 | 584 | $form_id = get_the_ID(); |
| 585 | 585 | } |
| 586 | 586 | |
| 587 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
| 588 | - return give_get_form_price( $form_id ); |
|
| 587 | + if ( ! give_has_variable_prices($form_id)) { |
|
| 588 | + return give_get_form_price($form_id); |
|
| 589 | 589 | } |
| 590 | 590 | |
| 591 | - $prices = give_get_variable_prices( $form_id ); |
|
| 591 | + $prices = give_get_variable_prices($form_id); |
|
| 592 | 592 | |
| 593 | 593 | $low = 0.00; |
| 594 | 594 | $min_id = 1; |
| 595 | 595 | |
| 596 | - if ( ! empty( $prices ) ) { |
|
| 596 | + if ( ! empty($prices)) { |
|
| 597 | 597 | |
| 598 | - foreach ( $prices as $key => $price ) { |
|
| 598 | + foreach ($prices as $key => $price) { |
|
| 599 | 599 | |
| 600 | - if ( empty( $price['_give_amount'] ) ) { |
|
| 600 | + if (empty($price['_give_amount'])) { |
|
| 601 | 601 | continue; |
| 602 | 602 | } |
| 603 | 603 | |
| 604 | - if ( ! isset( $min ) ) { |
|
| 604 | + if ( ! isset($min)) { |
|
| 605 | 605 | $min = $price['_give_amount']; |
| 606 | 606 | } else { |
| 607 | - $min = min( $min, $price['_give_amount'] ); |
|
| 607 | + $min = min($min, $price['_give_amount']); |
|
| 608 | 608 | } |
| 609 | 609 | |
| 610 | - if ( $price['_give_amount'] == $min ) { |
|
| 610 | + if ($price['_give_amount'] == $min) { |
|
| 611 | 611 | $min_id = $price['_give_id']['level_id']; |
| 612 | 612 | } |
| 613 | 613 | } |
@@ -625,43 +625,43 @@ discard block |
||
| 625 | 625 | * |
| 626 | 626 | * @return float Amount of the lowest price |
| 627 | 627 | */ |
| 628 | -function give_get_lowest_price_option( $form_id = 0 ) { |
|
| 629 | - if ( empty( $form_id ) ) { |
|
| 628 | +function give_get_lowest_price_option($form_id = 0) { |
|
| 629 | + if (empty($form_id)) { |
|
| 630 | 630 | $form_id = get_the_ID(); |
| 631 | 631 | } |
| 632 | 632 | |
| 633 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
| 634 | - return give_get_form_price( $form_id ); |
|
| 633 | + if ( ! give_has_variable_prices($form_id)) { |
|
| 634 | + return give_get_form_price($form_id); |
|
| 635 | 635 | } |
| 636 | 636 | |
| 637 | - $prices = give_get_variable_prices( $form_id ); |
|
| 637 | + $prices = give_get_variable_prices($form_id); |
|
| 638 | 638 | |
| 639 | 639 | $low = 0.00; |
| 640 | 640 | |
| 641 | - if ( ! empty( $prices ) ) { |
|
| 641 | + if ( ! empty($prices)) { |
|
| 642 | 642 | |
| 643 | - foreach ( $prices as $key => $price ) { |
|
| 643 | + foreach ($prices as $key => $price) { |
|
| 644 | 644 | |
| 645 | - if ( empty( $price['_give_amount'] ) ) { |
|
| 645 | + if (empty($price['_give_amount'])) { |
|
| 646 | 646 | continue; |
| 647 | 647 | } |
| 648 | 648 | |
| 649 | - if ( ! isset( $min ) ) { |
|
| 649 | + if ( ! isset($min)) { |
|
| 650 | 650 | $min = $price['_give_amount']; |
| 651 | 651 | } else { |
| 652 | - $min = min( $min, give_sanitize_amount( $price['_give_amount'] ) ); |
|
| 652 | + $min = min($min, give_sanitize_amount($price['_give_amount'])); |
|
| 653 | 653 | } |
| 654 | 654 | |
| 655 | - if ( $price['_give_amount'] == $min ) { |
|
| 655 | + if ($price['_give_amount'] == $min) { |
|
| 656 | 656 | $min_id = $key; |
| 657 | 657 | } |
| 658 | 658 | } |
| 659 | 659 | |
| 660 | - $low = $prices[ $min_id ]['_give_amount']; |
|
| 660 | + $low = $prices[$min_id]['_give_amount']; |
|
| 661 | 661 | |
| 662 | 662 | } |
| 663 | 663 | |
| 664 | - return give_sanitize_amount( $low ); |
|
| 664 | + return give_sanitize_amount($low); |
|
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | /** |
@@ -673,41 +673,41 @@ discard block |
||
| 673 | 673 | * |
| 674 | 674 | * @return float Amount of the highest price |
| 675 | 675 | */ |
| 676 | -function give_get_highest_price_option( $form_id = 0 ) { |
|
| 676 | +function give_get_highest_price_option($form_id = 0) { |
|
| 677 | 677 | |
| 678 | - if ( empty( $form_id ) ) { |
|
| 678 | + if (empty($form_id)) { |
|
| 679 | 679 | $form_id = get_the_ID(); |
| 680 | 680 | } |
| 681 | 681 | |
| 682 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
| 683 | - return give_get_form_price( $form_id ); |
|
| 682 | + if ( ! give_has_variable_prices($form_id)) { |
|
| 683 | + return give_get_form_price($form_id); |
|
| 684 | 684 | } |
| 685 | 685 | |
| 686 | - $prices = give_get_variable_prices( $form_id ); |
|
| 686 | + $prices = give_get_variable_prices($form_id); |
|
| 687 | 687 | |
| 688 | 688 | $high = 0.00; |
| 689 | 689 | |
| 690 | - if ( ! empty( $prices ) ) { |
|
| 690 | + if ( ! empty($prices)) { |
|
| 691 | 691 | |
| 692 | 692 | $max = 0; |
| 693 | 693 | |
| 694 | - foreach ( $prices as $key => $price ) { |
|
| 695 | - if ( empty( $price['_give_amount'] ) ) { |
|
| 694 | + foreach ($prices as $key => $price) { |
|
| 695 | + if (empty($price['_give_amount'])) { |
|
| 696 | 696 | continue; |
| 697 | 697 | } |
| 698 | - $give_amount = give_sanitize_amount( $price['_give_amount'] ); |
|
| 698 | + $give_amount = give_sanitize_amount($price['_give_amount']); |
|
| 699 | 699 | |
| 700 | - $max = max( $max, $give_amount ); |
|
| 700 | + $max = max($max, $give_amount); |
|
| 701 | 701 | |
| 702 | - if ( $give_amount == $max ) { |
|
| 702 | + if ($give_amount == $max) { |
|
| 703 | 703 | $max_id = $key; |
| 704 | 704 | } |
| 705 | 705 | } |
| 706 | 706 | |
| 707 | - $high = $prices[ $max_id ]['_give_amount']; |
|
| 707 | + $high = $prices[$max_id]['_give_amount']; |
|
| 708 | 708 | } |
| 709 | 709 | |
| 710 | - return give_sanitize_amount( $high ); |
|
| 710 | + return give_sanitize_amount($high); |
|
| 711 | 711 | } |
| 712 | 712 | |
| 713 | 713 | /** |
@@ -719,15 +719,15 @@ discard block |
||
| 719 | 719 | * |
| 720 | 720 | * @return mixed string|int Price of the form |
| 721 | 721 | */ |
| 722 | -function give_get_form_price( $form_id = 0 ) { |
|
| 722 | +function give_get_form_price($form_id = 0) { |
|
| 723 | 723 | |
| 724 | - if ( empty( $form_id ) ) { |
|
| 724 | + if (empty($form_id)) { |
|
| 725 | 725 | return false; |
| 726 | 726 | } |
| 727 | 727 | |
| 728 | - $form = new Give_Donate_Form( $form_id ); |
|
| 728 | + $form = new Give_Donate_Form($form_id); |
|
| 729 | 729 | |
| 730 | - return $form->__get( 'price' ); |
|
| 730 | + return $form->__get('price'); |
|
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | /** |
@@ -739,15 +739,15 @@ discard block |
||
| 739 | 739 | * |
| 740 | 740 | * @return mixed string|int Minimum price of the form |
| 741 | 741 | */ |
| 742 | -function give_get_form_minimum_price( $form_id = 0 ) { |
|
| 742 | +function give_get_form_minimum_price($form_id = 0) { |
|
| 743 | 743 | |
| 744 | - if ( empty( $form_id ) ) { |
|
| 744 | + if (empty($form_id)) { |
|
| 745 | 745 | return false; |
| 746 | 746 | } |
| 747 | 747 | |
| 748 | - $form = new Give_Donate_Form( $form_id ); |
|
| 748 | + $form = new Give_Donate_Form($form_id); |
|
| 749 | 749 | |
| 750 | - return $form->__get( 'minimum_price' ); |
|
| 750 | + return $form->__get('minimum_price'); |
|
| 751 | 751 | |
| 752 | 752 | } |
| 753 | 753 | |
@@ -762,52 +762,52 @@ discard block |
||
| 762 | 762 | * |
| 763 | 763 | * @return int $formatted_price |
| 764 | 764 | */ |
| 765 | -function give_price( $form_id = 0, $echo = true, $price_id = false ) { |
|
| 765 | +function give_price($form_id = 0, $echo = true, $price_id = false) { |
|
| 766 | 766 | |
| 767 | - if ( empty( $form_id ) ) { |
|
| 767 | + if (empty($form_id)) { |
|
| 768 | 768 | $form_id = get_the_ID(); |
| 769 | 769 | } |
| 770 | 770 | |
| 771 | - if ( give_has_variable_prices( $form_id ) ) { |
|
| 771 | + if (give_has_variable_prices($form_id)) { |
|
| 772 | 772 | |
| 773 | - $prices = give_get_variable_prices( $form_id ); |
|
| 773 | + $prices = give_get_variable_prices($form_id); |
|
| 774 | 774 | |
| 775 | - if ( false !== $price_id ) { |
|
| 775 | + if (false !== $price_id) { |
|
| 776 | 776 | |
| 777 | 777 | //loop through multi-prices to see which is default |
| 778 | - foreach ( $prices as $price ) { |
|
| 778 | + foreach ($prices as $price) { |
|
| 779 | 779 | //this is the default price |
| 780 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
| 780 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
| 781 | 781 | $price = (float) $price['_give_amount']; |
| 782 | 782 | }; |
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | } else { |
| 786 | 786 | |
| 787 | - $price = give_get_lowest_price_option( $form_id ); |
|
| 787 | + $price = give_get_lowest_price_option($form_id); |
|
| 788 | 788 | } |
| 789 | 789 | |
| 790 | - $price = give_sanitize_amount( $price ); |
|
| 790 | + $price = give_sanitize_amount($price); |
|
| 791 | 791 | |
| 792 | 792 | } else { |
| 793 | 793 | |
| 794 | - $price = give_get_form_price( $form_id ); |
|
| 794 | + $price = give_get_form_price($form_id); |
|
| 795 | 795 | |
| 796 | 796 | } |
| 797 | 797 | |
| 798 | - $price = apply_filters( 'give_form_price', give_sanitize_amount( $price ), $form_id ); |
|
| 799 | - $formatted_price = '<span class="give_price" id="give_price_' . $form_id . '">' . $price . '</span>'; |
|
| 800 | - $formatted_price = apply_filters( 'give_form_price_after_html', $formatted_price, $form_id, $price ); |
|
| 798 | + $price = apply_filters('give_form_price', give_sanitize_amount($price), $form_id); |
|
| 799 | + $formatted_price = '<span class="give_price" id="give_price_'.$form_id.'">'.$price.'</span>'; |
|
| 800 | + $formatted_price = apply_filters('give_form_price_after_html', $formatted_price, $form_id, $price); |
|
| 801 | 801 | |
| 802 | - if ( $echo ) { |
|
| 802 | + if ($echo) { |
|
| 803 | 803 | echo $formatted_price; |
| 804 | 804 | } else { |
| 805 | 805 | return $formatted_price; |
| 806 | 806 | } |
| 807 | 807 | } |
| 808 | 808 | |
| 809 | -add_filter( 'give_form_price', 'give_format_amount', 10 ); |
|
| 810 | -add_filter( 'give_form_price', 'give_currency_filter', 20 ); |
|
| 809 | +add_filter('give_form_price', 'give_format_amount', 10); |
|
| 810 | +add_filter('give_form_price', 'give_currency_filter', 20); |
|
| 811 | 811 | |
| 812 | 812 | |
| 813 | 813 | /** |
@@ -820,19 +820,19 @@ discard block |
||
| 820 | 820 | * |
| 821 | 821 | * @return float $amount Amount of the price option |
| 822 | 822 | */ |
| 823 | -function give_get_price_option_amount( $form_id = 0, $price_id = 0 ) { |
|
| 824 | - $prices = give_get_variable_prices( $form_id ); |
|
| 823 | +function give_get_price_option_amount($form_id = 0, $price_id = 0) { |
|
| 824 | + $prices = give_get_variable_prices($form_id); |
|
| 825 | 825 | |
| 826 | 826 | $amount = 0.00; |
| 827 | 827 | |
| 828 | - foreach ( $prices as $price ) { |
|
| 829 | - if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) { |
|
| 830 | - $amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00; |
|
| 828 | + foreach ($prices as $price) { |
|
| 829 | + if (isset($price['_give_id']['level_id']) && $price['_give_id']['level_id'] == $price_id) { |
|
| 830 | + $amount = isset($price['_give_amount']) ? $price['_give_amount'] : 0.00; |
|
| 831 | 831 | break; |
| 832 | 832 | }; |
| 833 | 833 | } |
| 834 | 834 | |
| 835 | - return apply_filters( 'give_get_price_option_amount', give_sanitize_amount( $amount ), $form_id, $price_id ); |
|
| 835 | + return apply_filters('give_get_price_option_amount', give_sanitize_amount($amount), $form_id, $price_id); |
|
| 836 | 836 | } |
| 837 | 837 | |
| 838 | 838 | /** |
@@ -844,13 +844,13 @@ discard block |
||
| 844 | 844 | * |
| 845 | 845 | * @return mixed string|int Goal of the form |
| 846 | 846 | */ |
| 847 | -function give_get_form_goal( $form_id = 0 ) { |
|
| 847 | +function give_get_form_goal($form_id = 0) { |
|
| 848 | 848 | |
| 849 | - if ( empty( $form_id ) ) { |
|
| 849 | + if (empty($form_id)) { |
|
| 850 | 850 | return false; |
| 851 | 851 | } |
| 852 | 852 | |
| 853 | - $form = new Give_Donate_Form( $form_id ); |
|
| 853 | + $form = new Give_Donate_Form($form_id); |
|
| 854 | 854 | |
| 855 | 855 | return $form->goal; |
| 856 | 856 | |
@@ -866,27 +866,27 @@ discard block |
||
| 866 | 866 | * |
| 867 | 867 | * @return string $formatted_goal |
| 868 | 868 | */ |
| 869 | -function give_goal( $form_id = 0, $echo = true ) { |
|
| 869 | +function give_goal($form_id = 0, $echo = true) { |
|
| 870 | 870 | |
| 871 | - if ( empty( $form_id ) ) { |
|
| 871 | + if (empty($form_id)) { |
|
| 872 | 872 | $form_id = get_the_ID(); |
| 873 | 873 | } |
| 874 | 874 | |
| 875 | - $goal = give_get_form_goal( $form_id ); |
|
| 875 | + $goal = give_get_form_goal($form_id); |
|
| 876 | 876 | |
| 877 | - $goal = apply_filters( 'give_form_goal', give_sanitize_amount( $goal ), $form_id ); |
|
| 878 | - $formatted_goal = '<span class="give_price" id="give_price_' . $form_id . '">' . $goal . '</span>'; |
|
| 879 | - $formatted_goal = apply_filters( 'give_form_price_after_html', $formatted_goal, $form_id, $goal ); |
|
| 877 | + $goal = apply_filters('give_form_goal', give_sanitize_amount($goal), $form_id); |
|
| 878 | + $formatted_goal = '<span class="give_price" id="give_price_'.$form_id.'">'.$goal.'</span>'; |
|
| 879 | + $formatted_goal = apply_filters('give_form_price_after_html', $formatted_goal, $form_id, $goal); |
|
| 880 | 880 | |
| 881 | - if ( $echo ) { |
|
| 881 | + if ($echo) { |
|
| 882 | 882 | echo $formatted_goal; |
| 883 | 883 | } else { |
| 884 | 884 | return $formatted_goal; |
| 885 | 885 | } |
| 886 | 886 | } |
| 887 | 887 | |
| 888 | -add_filter( 'give_form_goal', 'give_format_amount', 10 ); |
|
| 889 | -add_filter( 'give_form_goal', 'give_currency_filter', 20 ); |
|
| 888 | +add_filter('give_form_goal', 'give_format_amount', 10); |
|
| 889 | +add_filter('give_form_goal', 'give_currency_filter', 20); |
|
| 890 | 890 | |
| 891 | 891 | |
| 892 | 892 | /** |
@@ -898,13 +898,13 @@ discard block |
||
| 898 | 898 | * |
| 899 | 899 | * @return bool $ret Whether or not the logged_in_only setting is set |
| 900 | 900 | */ |
| 901 | -function give_logged_in_only( $form_id ) { |
|
| 901 | +function give_logged_in_only($form_id) { |
|
| 902 | 902 | |
| 903 | - $form_option = get_post_meta( $form_id, '_give_logged_in_only', true ); |
|
| 903 | + $form_option = get_post_meta($form_id, '_give_logged_in_only', true); |
|
| 904 | 904 | |
| 905 | - $ret = ! empty( $form_option ) ? $form_option : false; |
|
| 905 | + $ret = ! empty($form_option) ? $form_option : false; |
|
| 906 | 906 | |
| 907 | - return (bool) apply_filters( 'give_logged_in_only', $ret, $form_id ); |
|
| 907 | + return (bool) apply_filters('give_logged_in_only', $ret, $form_id); |
|
| 908 | 908 | |
| 909 | 909 | } |
| 910 | 910 | |
@@ -918,11 +918,11 @@ discard block |
||
| 918 | 918 | * |
| 919 | 919 | * @return string |
| 920 | 920 | */ |
| 921 | -function give_show_login_register_option( $form_id ) { |
|
| 921 | +function give_show_login_register_option($form_id) { |
|
| 922 | 922 | |
| 923 | - $show_register_form = get_post_meta( $form_id, '_give_show_register_form', true ); |
|
| 923 | + $show_register_form = get_post_meta($form_id, '_give_show_register_form', true); |
|
| 924 | 924 | |
| 925 | - return apply_filters( 'give_show_register_form', $show_register_form, $form_id ); |
|
| 925 | + return apply_filters('give_show_register_form', $show_register_form, $form_id); |
|
| 926 | 926 | |
| 927 | 927 | } |
| 928 | 928 | |
@@ -936,12 +936,12 @@ discard block |
||
| 936 | 936 | * @param int $form_id Form ID. |
| 937 | 937 | * @return array |
| 938 | 938 | */ |
| 939 | -function _give_get_prefill_form_field_values( $form_id ) { |
|
| 939 | +function _give_get_prefill_form_field_values($form_id) { |
|
| 940 | 940 | $logged_in_donor_info = array(); |
| 941 | 941 | |
| 942 | - if ( is_user_logged_in() ) : |
|
| 943 | - $donor_data = get_userdata( get_current_user_id() ); |
|
| 944 | - $donor_address = get_user_meta( get_current_user_id(), '_give_user_address', true ); |
|
| 942 | + if (is_user_logged_in()) : |
|
| 943 | + $donor_data = get_userdata(get_current_user_id()); |
|
| 944 | + $donor_address = get_user_meta(get_current_user_id(), '_give_user_address', true); |
|
| 945 | 945 | |
| 946 | 946 | $logged_in_donor_info = array( |
| 947 | 947 | // First name. |
@@ -954,42 +954,42 @@ discard block |
||
| 954 | 954 | 'give_email' => $donor_data->user_email, |
| 955 | 955 | |
| 956 | 956 | // Street address 1. |
| 957 | - 'card_address' => ( ! empty( $donor_address['line1'] ) ? $donor_address['line1'] : '' ), |
|
| 957 | + 'card_address' => ( ! empty($donor_address['line1']) ? $donor_address['line1'] : ''), |
|
| 958 | 958 | |
| 959 | 959 | // Street address 2. |
| 960 | - 'card_address_2' => ( ! empty( $donor_address['line2'] ) ? $donor_address['line2'] : '' ), |
|
| 960 | + 'card_address_2' => ( ! empty($donor_address['line2']) ? $donor_address['line2'] : ''), |
|
| 961 | 961 | |
| 962 | 962 | // Country. |
| 963 | - 'billing_country' => ( ! empty( $donor_address['country'] ) ? $donor_address['country'] : '' ), |
|
| 963 | + 'billing_country' => ( ! empty($donor_address['country']) ? $donor_address['country'] : ''), |
|
| 964 | 964 | |
| 965 | 965 | // State. |
| 966 | - 'card_state' => ( ! empty( $donor_address['state'] ) ? $donor_address['state'] : '' ), |
|
| 966 | + 'card_state' => ( ! empty($donor_address['state']) ? $donor_address['state'] : ''), |
|
| 967 | 967 | |
| 968 | 968 | // City. |
| 969 | - 'card_city' => ( ! empty( $donor_address['city'] ) ? $donor_address['city'] : '' ), |
|
| 969 | + 'card_city' => ( ! empty($donor_address['city']) ? $donor_address['city'] : ''), |
|
| 970 | 970 | |
| 971 | 971 | // Zipcode |
| 972 | - 'card_zip' => ( ! empty( $donor_address['zip'] ) ? $donor_address['zip'] : '' ) |
|
| 972 | + 'card_zip' => ( ! empty($donor_address['zip']) ? $donor_address['zip'] : '') |
|
| 973 | 973 | ); |
| 974 | 974 | endif; |
| 975 | 975 | |
| 976 | 976 | // Bailout: Auto fill form field values only form form which donor is donating. |
| 977 | - if( |
|
| 978 | - empty( $_GET['form-id'] ) |
|
| 977 | + if ( |
|
| 978 | + empty($_GET['form-id']) |
|
| 979 | 979 | || ! $form_id |
| 980 | - || ( $form_id !== absint( $_GET['form-id'] ) ) |
|
| 980 | + || ($form_id !== absint($_GET['form-id'])) |
|
| 981 | 981 | ) { |
| 982 | 982 | return $logged_in_donor_info; |
| 983 | 983 | } |
| 984 | 984 | |
| 985 | 985 | // Get purchase data. |
| 986 | - $give_purchase_data = Give()->session->get( 'give_purchase' ); |
|
| 986 | + $give_purchase_data = Give()->session->get('give_purchase'); |
|
| 987 | 987 | |
| 988 | 988 | // Get donor info from form data. |
| 989 | - $give_donor_info_in_session = empty( $give_purchase_data['post_data'] ) |
|
| 989 | + $give_donor_info_in_session = empty($give_purchase_data['post_data']) |
|
| 990 | 990 | ? array() |
| 991 | 991 | : $give_purchase_data['post_data']; |
| 992 | 992 | |
| 993 | 993 | // Output. |
| 994 | - return wp_parse_args( $give_donor_info_in_session, $logged_in_donor_info ); |
|
| 994 | + return wp_parse_args($give_donor_info_in_session, $logged_in_donor_info); |
|
| 995 | 995 | } |
| 996 | 996 | \ 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 | |
@@ -25,14 +25,14 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | function give_get_actions() { |
| 27 | 27 | |
| 28 | - $_get_action = ! empty( $_GET['give_action'] ) ? $_GET['give_action'] : null; |
|
| 28 | + $_get_action = ! empty($_GET['give_action']) ? $_GET['give_action'] : null; |
|
| 29 | 29 | |
| 30 | 30 | // Add backward compatibility to give-action param ( $_GET or $_POST ) |
| 31 | - if( doing_action( 'admin_init' ) && empty( $_get_action ) ) { |
|
| 32 | - $_get_action = ! empty( $_GET['give-action'] ) ? $_GET['give-action'] : null; |
|
| 31 | + if (doing_action('admin_init') && empty($_get_action)) { |
|
| 32 | + $_get_action = ! empty($_GET['give-action']) ? $_GET['give-action'] : null; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if ( isset( $_get_action ) ) { |
|
| 35 | + if (isset($_get_action)) { |
|
| 36 | 36 | /** |
| 37 | 37 | * Fires in WordPress init or admin init, when give_action is present in $_GET. |
| 38 | 38 | * |
@@ -40,13 +40,13 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @param array $_GET Array of HTTP GET variables. |
| 42 | 42 | */ |
| 43 | - do_action( "give_{$_get_action}", $_GET ); |
|
| 43 | + do_action("give_{$_get_action}", $_GET); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | -add_action( 'init', 'give_get_actions' ); |
|
| 49 | -add_action( 'admin_init', 'give_get_actions' ); |
|
| 48 | +add_action('init', 'give_get_actions'); |
|
| 49 | +add_action('admin_init', 'give_get_actions'); |
|
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * Hooks Give actions, when present in the $_POST superglobal. Every give_action |
@@ -59,15 +59,15 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | function give_post_actions() { |
| 61 | 61 | |
| 62 | - $_post_action = ! empty( $_POST['give_action'] ) ? $_POST['give_action'] : null; |
|
| 62 | + $_post_action = ! empty($_POST['give_action']) ? $_POST['give_action'] : null; |
|
| 63 | 63 | |
| 64 | 64 | |
| 65 | 65 | // Add backward compatibility to give-action param ( $_GET or $_POST ) |
| 66 | - if( doing_action( 'admin_init' ) && empty( $_post_action ) ) { |
|
| 67 | - $_post_action = ! empty( $_POST['give-action'] ) ? $_POST['give-action'] : null; |
|
| 66 | + if (doing_action('admin_init') && empty($_post_action)) { |
|
| 67 | + $_post_action = ! empty($_POST['give-action']) ? $_POST['give-action'] : null; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - if ( isset( $_post_action ) ) { |
|
| 70 | + if (isset($_post_action)) { |
|
| 71 | 71 | /** |
| 72 | 72 | * Fires in WordPress init or admin init, when give_action is present in $_POST. |
| 73 | 73 | * |
@@ -75,13 +75,13 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * @param array $_POST Array of HTTP POST variables. |
| 77 | 77 | */ |
| 78 | - do_action( "give_{$_post_action}", $_POST ); |
|
| 78 | + do_action("give_{$_post_action}", $_POST); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | -add_action( 'init', 'give_post_actions' ); |
|
| 84 | -add_action( 'admin_init', 'give_post_actions' ); |
|
| 83 | +add_action('init', 'give_post_actions'); |
|
| 84 | +add_action('admin_init', 'give_post_actions'); |
|
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | 87 | * Connect WordPress user with Donor. |
@@ -91,27 +91,27 @@ discard block |
||
| 91 | 91 | * @param array $user_data User Data |
| 92 | 92 | * @return void |
| 93 | 93 | */ |
| 94 | -function give_connect_donor_to_wpuser( $user_id, $user_data ){ |
|
| 95 | - $donor = new Give_Customer( $user_data['user_email'] ); |
|
| 94 | +function give_connect_donor_to_wpuser($user_id, $user_data) { |
|
| 95 | + $donor = new Give_Customer($user_data['user_email']); |
|
| 96 | 96 | |
| 97 | 97 | // Validate donor id and check if do nor is already connect to wp user or not. |
| 98 | - if( $donor->id && ! $donor->user_id ) { |
|
| 98 | + if ($donor->id && ! $donor->user_id) { |
|
| 99 | 99 | |
| 100 | 100 | // Update donor user_id. |
| 101 | - if( $donor->update( array( 'user_id' => $user_id ) ) ) { |
|
| 102 | - $donor_note = sprintf( esc_html__( 'WordPress user #%d is connected to #%d', 'give' ), $user_id, $donor->id ); |
|
| 103 | - $donor->add_note( $donor_note ); |
|
| 101 | + if ($donor->update(array('user_id' => $user_id))) { |
|
| 102 | + $donor_note = sprintf(esc_html__('WordPress user #%d is connected to #%d', 'give'), $user_id, $donor->id); |
|
| 103 | + $donor->add_note($donor_note); |
|
| 104 | 104 | |
| 105 | 105 | // Update user_id meta in payments. |
| 106 | - if( ! empty( $donor->payment_ids ) && ( $donations = explode( ',', $donor->payment_ids ) ) ) { |
|
| 107 | - foreach ( $donations as $donation ) { |
|
| 108 | - update_post_meta( $donation, '_give_payment_user_id', $user_id ); |
|
| 106 | + if ( ! empty($donor->payment_ids) && ($donations = explode(',', $donor->payment_ids))) { |
|
| 107 | + foreach ($donations as $donation) { |
|
| 108 | + update_post_meta($donation, '_give_payment_user_id', $user_id); |
|
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | -add_action( 'give_insert_user', 'give_connect_donor_to_wpuser', 10, 2 ); |
|
| 114 | +add_action('give_insert_user', 'give_connect_donor_to_wpuser', 10, 2); |
|
| 115 | 115 | |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -125,21 +125,21 @@ discard block |
||
| 125 | 125 | function give_validate_license_when_site_migrated() { |
| 126 | 126 | // Store current site address if not already stored. |
| 127 | 127 | $homeurl = home_url(); |
| 128 | - if( ! get_option( 'give_site_address_before_migrate' ) ) { |
|
| 128 | + if ( ! get_option('give_site_address_before_migrate')) { |
|
| 129 | 129 | // Update site address. |
| 130 | - update_option( 'give_site_address_before_migrate', $homeurl ); |
|
| 130 | + update_option('give_site_address_before_migrate', $homeurl); |
|
| 131 | 131 | |
| 132 | 132 | return; |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - if( $homeurl !== get_option( 'give_site_address_before_migrate' ) ) { |
|
| 135 | + if ($homeurl !== get_option('give_site_address_before_migrate')) { |
|
| 136 | 136 | // Immediately run cron. |
| 137 | - wp_schedule_single_event( time() , 'give_validate_license_when_site_migrated' ); |
|
| 137 | + wp_schedule_single_event(time(), 'give_validate_license_when_site_migrated'); |
|
| 138 | 138 | |
| 139 | 139 | // Update site address. |
| 140 | - update_option( 'give_site_address_before_migrate', home_url() ); |
|
| 140 | + update_option('give_site_address_before_migrate', home_url()); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | } |
| 144 | -add_action( 'init', 'give_validate_license_when_site_migrated' ); |
|
| 145 | -add_action( 'admin_init', 'give_validate_license_when_site_migrated' ); |
|
| 144 | +add_action('init', 'give_validate_license_when_site_migrated'); |
|
| 145 | +add_action('admin_init', 'give_validate_license_when_site_migrated'); |
|
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -27,9 +27,9 @@ discard block |
||
| 27 | 27 | * @since 1.0 |
| 28 | 28 | */ |
| 29 | 29 | public function __construct() { |
| 30 | - add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
| 31 | - add_action( 'give_dismiss_notices', array( $this, 'dismiss_notices' ) ); |
|
| 32 | - add_action( 'admin_bar_menu', array( $this, 'give_admin_bar_menu' ), 1000, 1 ); |
|
| 30 | + add_action('admin_notices', array($this, 'show_notices')); |
|
| 31 | + add_action('give_dismiss_notices', array($this, 'dismiss_notices')); |
|
| 32 | + add_action('admin_bar_menu', array($this, 'give_admin_bar_menu'), 1000, 1); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | |
@@ -40,20 +40,20 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @return bool |
| 42 | 42 | */ |
| 43 | - public function give_admin_bar_menu( $wp_admin_bar ) { |
|
| 43 | + public function give_admin_bar_menu($wp_admin_bar) { |
|
| 44 | 44 | |
| 45 | - if ( ! give_is_test_mode() || ! current_user_can( 'view_give_reports' ) ) { |
|
| 45 | + if ( ! give_is_test_mode() || ! current_user_can('view_give_reports')) { |
|
| 46 | 46 | return false; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | // Add the main siteadmin menu item. |
| 50 | - $wp_admin_bar->add_menu( array( |
|
| 50 | + $wp_admin_bar->add_menu(array( |
|
| 51 | 51 | 'id' => 'give-test-notice', |
| 52 | - 'href' => admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=gateways' ), |
|
| 52 | + 'href' => admin_url('edit.php?post_type=give_forms&page=give-settings&tab=gateways'), |
|
| 53 | 53 | 'parent' => 'top-secondary', |
| 54 | - 'title' => esc_html__( 'Give Test Mode Active', 'give' ), |
|
| 55 | - 'meta' => array( 'class' => 'give-test-mode-active' ), |
|
| 56 | - ) ); |
|
| 54 | + 'title' => esc_html__('Give Test Mode Active', 'give'), |
|
| 55 | + 'meta' => array('class' => 'give-test-mode-active'), |
|
| 56 | + )); |
|
| 57 | 57 | |
| 58 | 58 | } |
| 59 | 59 | |
@@ -68,116 +68,116 @@ discard block |
||
| 68 | 68 | 'error' => array(), |
| 69 | 69 | ); |
| 70 | 70 | |
| 71 | - if ( ! give_test_ajax_works() && ! get_user_meta( get_current_user_id(), '_give_admin_ajax_inaccessible_dismissed', true ) && current_user_can( 'manage_give_settings' ) ) { |
|
| 71 | + if ( ! give_test_ajax_works() && ! get_user_meta(get_current_user_id(), '_give_admin_ajax_inaccessible_dismissed', true) && current_user_can('manage_give_settings')) { |
|
| 72 | 72 | echo '<div class="error">'; |
| 73 | - echo '<p>' . esc_html__( 'Your site appears to be blocking the WordPress ajax interface. This may cause issues with Give.', 'give' ) . '</p>'; |
|
| 73 | + echo '<p>'.esc_html__('Your site appears to be blocking the WordPress ajax interface. This may cause issues with Give.', 'give').'</p>'; |
|
| 74 | 74 | /* translators: %s: https://givewp.com/documentation/core/troubleshooting/admin-ajax-blocked/ */ |
| 75 | - echo '<p>' . sprintf( __( 'Please see <a href="%s" target="_blank">this reference</a> for possible solutions.', 'give' ), esc_url( 'https://givewp.com/documentation/core/troubleshooting/admin-ajax-blocked/' ) ) . '</p>'; |
|
| 76 | - echo '<p><a href="' . add_query_arg( array( |
|
| 75 | + echo '<p>'.sprintf(__('Please see <a href="%s" target="_blank">this reference</a> for possible solutions.', 'give'), esc_url('https://givewp.com/documentation/core/troubleshooting/admin-ajax-blocked/')).'</p>'; |
|
| 76 | + echo '<p><a href="'.add_query_arg(array( |
|
| 77 | 77 | 'give_action' => 'dismiss_notices', |
| 78 | 78 | 'give_notice' => 'admin_ajax_inaccessible', |
| 79 | - ) ) . '">' . esc_html__( 'Dismiss Notice', 'give' ) . '</a></p>'; |
|
| 79 | + )).'">'.esc_html__('Dismiss Notice', 'give').'</a></p>'; |
|
| 80 | 80 | echo '</div>'; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if ( isset( $_GET['give-message'] ) ) { |
|
| 83 | + if (isset($_GET['give-message'])) { |
|
| 84 | 84 | |
| 85 | 85 | // Donation reports errors. |
| 86 | - if ( current_user_can( 'view_give_reports' ) ) { |
|
| 87 | - switch ( $_GET['give-message'] ) { |
|
| 86 | + if (current_user_can('view_give_reports')) { |
|
| 87 | + switch ($_GET['give-message']) { |
|
| 88 | 88 | case 'donation_deleted' : |
| 89 | - $notices['updated']['give-donation-deleted'] = esc_attr__( 'The donation has been deleted.', 'give' ); |
|
| 89 | + $notices['updated']['give-donation-deleted'] = esc_attr__('The donation has been deleted.', 'give'); |
|
| 90 | 90 | break; |
| 91 | 91 | case 'email_sent' : |
| 92 | - $notices['updated']['give-payment-sent'] = esc_attr__( 'The donation receipt has been resent.', 'give' ); |
|
| 92 | + $notices['updated']['give-payment-sent'] = esc_attr__('The donation receipt has been resent.', 'give'); |
|
| 93 | 93 | break; |
| 94 | 94 | case 'refreshed-reports' : |
| 95 | - $notices['updated']['give-refreshed-reports'] = esc_attr__( 'The reports cache has been cleared.', 'give' ); |
|
| 95 | + $notices['updated']['give-refreshed-reports'] = esc_attr__('The reports cache has been cleared.', 'give'); |
|
| 96 | 96 | break; |
| 97 | 97 | case 'donation-note-deleted' : |
| 98 | - $notices['updated']['give-donation-note-deleted'] = esc_attr__( 'The donation note has been deleted.', 'give' ); |
|
| 98 | + $notices['updated']['give-donation-note-deleted'] = esc_attr__('The donation note has been deleted.', 'give'); |
|
| 99 | 99 | break; |
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | // Give settings notices and errors. |
| 104 | - if ( current_user_can( 'manage_give_settings' ) ) { |
|
| 105 | - switch ( $_GET['give-message'] ) { |
|
| 104 | + if (current_user_can('manage_give_settings')) { |
|
| 105 | + switch ($_GET['give-message']) { |
|
| 106 | 106 | case 'settings-imported' : |
| 107 | - $notices['updated']['give-settings-imported'] = esc_attr__( 'The settings have been imported.', 'give' ); |
|
| 107 | + $notices['updated']['give-settings-imported'] = esc_attr__('The settings have been imported.', 'give'); |
|
| 108 | 108 | break; |
| 109 | 109 | case 'api-key-generated' : |
| 110 | - $notices['updated']['give-api-key-generated'] = esc_attr__( 'API keys have been generated.', 'give' ); |
|
| 110 | + $notices['updated']['give-api-key-generated'] = esc_attr__('API keys have been generated.', 'give'); |
|
| 111 | 111 | break; |
| 112 | 112 | case 'api-key-exists' : |
| 113 | - $notices['error']['give-api-key-exists'] = esc_attr__( 'The specified user already has API keys.', 'give' ); |
|
| 113 | + $notices['error']['give-api-key-exists'] = esc_attr__('The specified user already has API keys.', 'give'); |
|
| 114 | 114 | break; |
| 115 | 115 | case 'api-key-regenerated' : |
| 116 | - $notices['updated']['give-api-key-regenerated'] = esc_attr__( 'API keys have been regenerated.', 'give' ); |
|
| 116 | + $notices['updated']['give-api-key-regenerated'] = esc_attr__('API keys have been regenerated.', 'give'); |
|
| 117 | 117 | break; |
| 118 | 118 | case 'api-key-revoked' : |
| 119 | - $notices['updated']['give-api-key-revoked'] = esc_attr__( 'API keys have been revoked.', 'give' ); |
|
| 119 | + $notices['updated']['give-api-key-revoked'] = esc_attr__('API keys have been revoked.', 'give'); |
|
| 120 | 120 | break; |
| 121 | 121 | case 'sent-test-email' : |
| 122 | - $notices['updated']['give-sent-test-email'] = esc_attr__( 'The test email has been sent.', 'give' ); |
|
| 122 | + $notices['updated']['give-sent-test-email'] = esc_attr__('The test email has been sent.', 'give'); |
|
| 123 | 123 | break; |
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | // Payments errors. |
| 127 | - if ( current_user_can( 'edit_give_payments' ) ) { |
|
| 128 | - switch ( $_GET['give-message'] ) { |
|
| 127 | + if (current_user_can('edit_give_payments')) { |
|
| 128 | + switch ($_GET['give-message']) { |
|
| 129 | 129 | case 'note-added' : |
| 130 | - $notices['updated']['give-note-added'] = esc_attr__( 'The donation note has been added.', 'give' ); |
|
| 130 | + $notices['updated']['give-note-added'] = esc_attr__('The donation note has been added.', 'give'); |
|
| 131 | 131 | break; |
| 132 | 132 | case 'payment-updated' : |
| 133 | - $notices['updated']['give-payment-updated'] = esc_attr__( 'The donation has been updated.', 'give' ); |
|
| 133 | + $notices['updated']['give-payment-updated'] = esc_attr__('The donation has been updated.', 'give'); |
|
| 134 | 134 | break; |
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | // Customer Notices. |
| 139 | - if ( current_user_can( 'edit_give_payments' ) ) { |
|
| 140 | - switch ( $_GET['give-message'] ) { |
|
| 139 | + if (current_user_can('edit_give_payments')) { |
|
| 140 | + switch ($_GET['give-message']) { |
|
| 141 | 141 | case 'customer-deleted' : |
| 142 | - $notices['updated']['give-customer-deleted'] = esc_attr__( 'The donor has been deleted.', 'give' ); |
|
| 142 | + $notices['updated']['give-customer-deleted'] = esc_attr__('The donor has been deleted.', 'give'); |
|
| 143 | 143 | break; |
| 144 | 144 | |
| 145 | 145 | case 'email-added' : |
| 146 | - $notices['updated']['give-customer-email-added'] = esc_attr__( 'Donor email added', 'give' ); |
|
| 146 | + $notices['updated']['give-customer-email-added'] = esc_attr__('Donor email added', 'give'); |
|
| 147 | 147 | break; |
| 148 | 148 | |
| 149 | 149 | case 'email-removed' : |
| 150 | - $notices['updated']['give-customer-email-removed'] = esc_attr__( 'Donor email removed', 'give' ); |
|
| 150 | + $notices['updated']['give-customer-email-removed'] = esc_attr__('Donor email removed', 'give'); |
|
| 151 | 151 | break; |
| 152 | 152 | |
| 153 | 153 | case 'email-remove-failed' : |
| 154 | - $notices['error']['give-customer-email-remove-failed'] = esc_attr__( 'Failed to remove donor email', 'give' ); |
|
| 154 | + $notices['error']['give-customer-email-remove-failed'] = esc_attr__('Failed to remove donor email', 'give'); |
|
| 155 | 155 | break; |
| 156 | 156 | |
| 157 | 157 | case 'primary-email-updated' : |
| 158 | - $notices['updated']['give-customer-primary-email-updated'] = esc_attr__( 'Primary email updated for donors', 'give' ); |
|
| 158 | + $notices['updated']['give-customer-primary-email-updated'] = esc_attr__('Primary email updated for donors', 'give'); |
|
| 159 | 159 | break; |
| 160 | 160 | |
| 161 | 161 | case 'primary-email-failed' : |
| 162 | - $notices['error']['give-customer-primary-email-failed'] = esc_attr__( 'Failed to set primary email', 'give' ); |
|
| 162 | + $notices['error']['give-customer-primary-email-failed'] = esc_attr__('Failed to set primary email', 'give'); |
|
| 163 | 163 | |
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - if ( count( $notices['updated'] ) > 0 ) { |
|
| 169 | - foreach ( $notices['updated'] as $notice => $message ) { |
|
| 170 | - add_settings_error( 'give-notices', $notice, $message, 'updated' ); |
|
| 168 | + if (count($notices['updated']) > 0) { |
|
| 169 | + foreach ($notices['updated'] as $notice => $message) { |
|
| 170 | + add_settings_error('give-notices', $notice, $message, 'updated'); |
|
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - if ( count( $notices['error'] ) > 0 ) { |
|
| 175 | - foreach ( $notices['error'] as $notice => $message ) { |
|
| 176 | - add_settings_error( 'give-notices', $notice, $message, 'error' ); |
|
| 174 | + if (count($notices['error']) > 0) { |
|
| 175 | + foreach ($notices['error'] as $notice => $message) { |
|
| 176 | + add_settings_error('give-notices', $notice, $message, 'error'); |
|
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - settings_errors( 'give-notices' ); |
|
| 180 | + settings_errors('give-notices'); |
|
| 181 | 181 | |
| 182 | 182 | } |
| 183 | 183 | |
@@ -189,8 +189,8 @@ discard block |
||
| 189 | 189 | * @return void |
| 190 | 190 | */ |
| 191 | 191 | function give_admin_addons_notices() { |
| 192 | - add_settings_error( 'give-notices', 'give-addons-feed-error', esc_attr__( 'There seems to be an issue with the server. Please try again in a few minutes.', 'give' ), 'error' ); |
|
| 193 | - settings_errors( 'give-notices' ); |
|
| 192 | + add_settings_error('give-notices', 'give-addons-feed-error', esc_attr__('There seems to be an issue with the server. Please try again in a few minutes.', 'give'), 'error'); |
|
| 193 | + settings_errors('give-notices'); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | |
@@ -201,9 +201,9 @@ discard block |
||
| 201 | 201 | * @return void |
| 202 | 202 | */ |
| 203 | 203 | function dismiss_notices() { |
| 204 | - if ( isset( $_GET['give_notice'] ) ) { |
|
| 205 | - update_user_meta( get_current_user_id(), '_give_' . $_GET['give_notice'] . '_dismissed', 1 ); |
|
| 206 | - wp_redirect( remove_query_arg( array( 'give_action', 'give_notice' ) ) ); |
|
| 204 | + if (isset($_GET['give_notice'])) { |
|
| 205 | + update_user_meta(get_current_user_id(), '_give_'.$_GET['give_notice'].'_dismissed', 1); |
|
| 206 | + wp_redirect(remove_query_arg(array('give_action', 'give_notice'))); |
|
| 207 | 207 | exit; |
| 208 | 208 | } |
| 209 | 209 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -21,12 +21,12 @@ discard block |
||
| 21 | 21 | * @return void |
| 22 | 22 | */ |
| 23 | 23 | function give_register_dashboard_widgets() { |
| 24 | - if ( current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) { |
|
| 25 | - wp_add_dashboard_widget( 'give_dashboard_sales', esc_html__( 'Give: Donation Statistics', 'give' ), 'give_dashboard_sales_widget' ); |
|
| 24 | + if (current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) { |
|
| 25 | + wp_add_dashboard_widget('give_dashboard_sales', esc_html__('Give: Donation Statistics', 'give'), 'give_dashboard_sales_widget'); |
|
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | -add_action( 'wp_dashboard_setup', 'give_register_dashboard_widgets', 10 ); |
|
| 29 | +add_action('wp_dashboard_setup', 'give_register_dashboard_widgets', 10); |
|
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * Sales Summary Dashboard Widget |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | function give_dashboard_sales_widget() { |
| 40 | 40 | |
| 41 | - if ( ! current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) { |
|
| 41 | + if ( ! current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) { |
|
| 42 | 42 | return; |
| 43 | 43 | } |
| 44 | 44 | $stats = new Give_Payment_Stats; ?> |
@@ -46,27 +46,27 @@ discard block |
||
| 46 | 46 | <div class="give-dashboard-widget"> |
| 47 | 47 | |
| 48 | 48 | <div class="give-dashboard-today give-clearfix"> |
| 49 | - <h3 class="give-dashboard-date-today"><?php echo date( _x( 'F j, Y', 'dashboard widget', 'give' ) ); ?></h3> |
|
| 49 | + <h3 class="give-dashboard-date-today"><?php echo date(_x('F j, Y', 'dashboard widget', 'give')); ?></h3> |
|
| 50 | 50 | |
| 51 | 51 | <p class="give-dashboard-happy-day"><?php |
| 52 | 52 | printf( |
| 53 | 53 | /* translators: %s: day of the week */ |
| 54 | - esc_html__( 'Happy %s!', 'give' ), |
|
| 55 | - date( 'l', current_time( 'timestamp' ) ) |
|
| 54 | + esc_html__('Happy %s!', 'give'), |
|
| 55 | + date('l', current_time('timestamp')) |
|
| 56 | 56 | ); |
| 57 | 57 | ?></p> |
| 58 | 58 | |
| 59 | 59 | <p class="give-dashboard-today-earnings"><?php |
| 60 | - $earnings_today = $stats->get_earnings( 0, 'today', false ); |
|
| 61 | - echo give_currency_filter( give_format_amount( $earnings_today ) ); |
|
| 60 | + $earnings_today = $stats->get_earnings(0, 'today', false); |
|
| 61 | + echo give_currency_filter(give_format_amount($earnings_today)); |
|
| 62 | 62 | ?></p> |
| 63 | 63 | |
| 64 | 64 | <p class="give-orders-today"><?php |
| 65 | - $donations_today = $stats->get_sales( 0, 'today', false ); |
|
| 65 | + $donations_today = $stats->get_sales(0, 'today', false); |
|
| 66 | 66 | printf( |
| 67 | 67 | /* translators: %s: daily donation count */ |
| 68 | - esc_html__( '%s donations today', 'give' ), |
|
| 69 | - give_format_amount( $donations_today, false ) |
|
| 68 | + esc_html__('%s donations today', 'give'), |
|
| 69 | + give_format_amount($donations_today, false) |
|
| 70 | 70 | ); |
| 71 | 71 | ?></p> |
| 72 | 72 | |
@@ -76,34 +76,34 @@ discard block |
||
| 76 | 76 | <table class="give-table-stats"> |
| 77 | 77 | <thead style="display: none;"> |
| 78 | 78 | <tr> |
| 79 | - <th><?php esc_html_e( 'This Week', 'give' ); ?></th> |
|
| 80 | - <th><?php esc_html_e( 'This Month', 'give' ); ?></th> |
|
| 81 | - <th><?php esc_html_e( 'Past 30 Days', 'give' ); ?></th> |
|
| 79 | + <th><?php esc_html_e('This Week', 'give'); ?></th> |
|
| 80 | + <th><?php esc_html_e('This Month', 'give'); ?></th> |
|
| 81 | + <th><?php esc_html_e('Past 30 Days', 'give'); ?></th> |
|
| 82 | 82 | </tr> |
| 83 | 83 | </thead> |
| 84 | 84 | <tbody> |
| 85 | 85 | <tr id="give-table-stats-tr-1"> |
| 86 | 86 | <td> |
| 87 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_week' ) ) ); ?></p> |
|
| 87 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_week'))); ?></p> |
|
| 88 | 88 | |
| 89 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'This Week', 'give' ); ?></p> |
|
| 89 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('This Week', 'give'); ?></p> |
|
| 90 | 90 | </td> |
| 91 | 91 | <td> |
| 92 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_month' ) ) ); ?></p> |
|
| 92 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_month'))); ?></p> |
|
| 93 | 93 | |
| 94 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'This Month', 'give' ); ?></p> |
|
| 94 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('This Month', 'give'); ?></p> |
|
| 95 | 95 | </td> |
| 96 | 96 | </tr> |
| 97 | 97 | <tr id="give-table-stats-tr-2"> |
| 98 | 98 | <td> |
| 99 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'last_month' ) ) ) ?></p> |
|
| 99 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'last_month'))) ?></p> |
|
| 100 | 100 | |
| 101 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'Last Month', 'give' ); ?></p> |
|
| 101 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('Last Month', 'give'); ?></p> |
|
| 102 | 102 | </td> |
| 103 | 103 | <td> |
| 104 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_year', false ) ) ) ?></p> |
|
| 104 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_year', false))) ?></p> |
|
| 105 | 105 | |
| 106 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'This Year', 'give' ); ?></p> |
|
| 106 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('This Year', 'give'); ?></p> |
|
| 107 | 107 | </td> |
| 108 | 108 | </tr> |
| 109 | 109 | </tbody> |
@@ -123,23 +123,23 @@ discard block |
||
| 123 | 123 | * |
| 124 | 124 | * @return array |
| 125 | 125 | */ |
| 126 | -function give_dashboard_at_a_glance_widget( $items ) { |
|
| 127 | - $num_posts = wp_count_posts( 'give_forms' ); |
|
| 126 | +function give_dashboard_at_a_glance_widget($items) { |
|
| 127 | + $num_posts = wp_count_posts('give_forms'); |
|
| 128 | 128 | |
| 129 | - if ( $num_posts && $num_posts->publish ) { |
|
| 129 | + if ($num_posts && $num_posts->publish) { |
|
| 130 | 130 | |
| 131 | 131 | $text = sprintf( |
| 132 | 132 | /* translators: %s: number of posts published */ |
| 133 | - _n( '%s Give Form', '%s Give Forms', $num_posts->publish, 'give' ), |
|
| 133 | + _n('%s Give Form', '%s Give Forms', $num_posts->publish, 'give'), |
|
| 134 | 134 | $num_posts->publish |
| 135 | 135 | ); |
| 136 | 136 | |
| 137 | - $text = sprintf( $text, number_format_i18n( $num_posts->publish ) ); |
|
| 137 | + $text = sprintf($text, number_format_i18n($num_posts->publish)); |
|
| 138 | 138 | |
| 139 | - if ( current_user_can( 'edit_give_forms', get_current_user_id() ) ) { |
|
| 139 | + if (current_user_can('edit_give_forms', get_current_user_id())) { |
|
| 140 | 140 | $text = sprintf( |
| 141 | 141 | '<a class="give-forms-count" href="%1$s">%2$s</a>', |
| 142 | - admin_url( 'edit.php?post_type=give_forms' ), |
|
| 142 | + admin_url('edit.php?post_type=give_forms'), |
|
| 143 | 143 | $text |
| 144 | 144 | ); |
| 145 | 145 | } else { |
@@ -155,4 +155,4 @@ discard block |
||
| 155 | 155 | return $items; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | -add_filter( 'dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1 ); |
|
| 158 | +add_filter('dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1); |
|
@@ -66,23 +66,23 @@ discard block |
||
| 66 | 66 | * @param $args |
| 67 | 67 | * |
| 68 | 68 | */ |
| 69 | - public function __construct( $args ) { |
|
| 69 | + public function __construct($args) { |
|
| 70 | 70 | |
| 71 | 71 | //Only for admins. |
| 72 | - if ( ! is_admin() ) { |
|
| 72 | + if ( ! is_admin()) { |
|
| 73 | 73 | return; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | //This plugin is en_US native. |
| 77 | 77 | $this->locale = get_locale(); |
| 78 | - if ( 'en_US' === $this->locale ) { |
|
| 78 | + if ('en_US' === $this->locale) { |
|
| 79 | 79 | return; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - $this->init( $args ); |
|
| 82 | + $this->init($args); |
|
| 83 | 83 | |
| 84 | - if ( ! $this->hide_promo() ) { |
|
| 85 | - add_action( $this->hook, array( $this, 'promo' ) ); |
|
| 84 | + if ( ! $this->hide_promo()) { |
|
| 85 | + add_action($this->hook, array($this, 'promo')); |
|
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | * |
| 94 | 94 | * @param array $args |
| 95 | 95 | */ |
| 96 | - private function init( $args ) { |
|
| 97 | - foreach ( $args as $key => $arg ) { |
|
| 96 | + private function init($args) { |
|
| 97 | + foreach ($args as $key => $arg) { |
|
| 98 | 98 | $this->$key = $arg; |
| 99 | 99 | } |
| 100 | 100 | |
@@ -108,11 +108,11 @@ discard block |
||
| 108 | 108 | * @return bool |
| 109 | 109 | */ |
| 110 | 110 | private function hide_promo() { |
| 111 | - $hide_promo = get_transient( 'give_i18n_give_promo_hide' ); |
|
| 112 | - if ( ! $hide_promo ) { |
|
| 113 | - if ( filter_input( INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT ) === 1 ) { |
|
| 111 | + $hide_promo = get_transient('give_i18n_give_promo_hide'); |
|
| 112 | + if ( ! $hide_promo) { |
|
| 113 | + if (filter_input(INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT) === 1) { |
|
| 114 | 114 | // No expiration time, so this would normally not expire, but it wouldn't be copied to other sites etc. |
| 115 | - set_transient( 'give_i18n_give_promo_hide', true ); |
|
| 115 | + set_transient('give_i18n_give_promo_hide', true); |
|
| 116 | 116 | $hide_promo = true; |
| 117 | 117 | } |
| 118 | 118 | } |
@@ -131,20 +131,20 @@ discard block |
||
| 131 | 131 | $message = false; |
| 132 | 132 | |
| 133 | 133 | //Using a translation less than 90% complete. |
| 134 | - if ( $this->translation_exists && $this->translation_loaded && $this->percent_translated < 90 ) { |
|
| 135 | - $message = __( 'As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give' ); |
|
| 136 | - } elseif ( ! $this->translation_loaded && $this->translation_exists ) { |
|
| 137 | - $message = __( 'You\'re using WordPress in %1$s. While %2$s has been translated to %1$s for %3$d%%, it\'s not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give' ); |
|
| 138 | - } elseif ( ! $this->translation_exists ) { |
|
| 139 | - $message = __( 'You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give' ); |
|
| 134 | + if ($this->translation_exists && $this->translation_loaded && $this->percent_translated < 90) { |
|
| 135 | + $message = __('As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give'); |
|
| 136 | + } elseif ( ! $this->translation_loaded && $this->translation_exists) { |
|
| 137 | + $message = __('You\'re using WordPress in %1$s. While %2$s has been translated to %1$s for %3$d%%, it\'s not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give'); |
|
| 138 | + } elseif ( ! $this->translation_exists) { |
|
| 139 | + $message = __('You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give'); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | //Links. |
| 143 | - $registration_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__( 'WordPress.org', 'give' ) ); |
|
| 144 | - $translations_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__( 'complete the translation', 'give' ) ); |
|
| 143 | + $registration_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__('WordPress.org', 'give')); |
|
| 144 | + $translations_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__('complete the translation', 'give')); |
|
| 145 | 145 | |
| 146 | 146 | //Message. |
| 147 | - $message = sprintf( $message, esc_html( $this->locale_name ), esc_html( 'Give' ), $this->percent_translated, $registration_link, $translations_link ); |
|
| 147 | + $message = sprintf($message, esc_html($this->locale_name), esc_html('Give'), $this->percent_translated, $registration_link, $translations_link); |
|
| 148 | 148 | |
| 149 | 149 | |
| 150 | 150 | return $message; |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | $this->translation_details(); |
| 160 | 160 | $message = $this->promo_message(); |
| 161 | 161 | |
| 162 | - if ( $message ) { ?> |
|
| 162 | + if ($message) { ?> |
|
| 163 | 163 | |
| 164 | 164 | <style> |
| 165 | 165 | /* Banner specific styles */ |
@@ -212,12 +212,12 @@ discard block |
||
| 212 | 212 | <a href="https://wordpress.org/support/register.php" class="alignleft give-i18n-icon" style="margin:0" target="_blank"><span class="dashicons dashicons-translation" style="font-size: 110px; text-decoration: none;"></span></a> |
| 213 | 213 | |
| 214 | 214 | <div class="give-i18n-notice-content"> |
| 215 | - <a href="<?php echo esc_url( add_query_arg( array( 'remove_i18n_promo' => '1' ) ) ); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a> |
|
| 215 | + <a href="<?php echo esc_url(add_query_arg(array('remove_i18n_promo' => '1'))); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a> |
|
| 216 | 216 | |
| 217 | - <h2 style="margin: 10px 0;"><?php printf( esc_html__( 'Help Translate Give to %s', 'give' ), $this->locale_name ); ?></h2> |
|
| 217 | + <h2 style="margin: 10px 0;"><?php printf(esc_html__('Help Translate Give to %s', 'give'), $this->locale_name); ?></h2> |
|
| 218 | 218 | <p><?php echo $message; ?></p> |
| 219 | 219 | <p> |
| 220 | - <a href="https://wordpress.org/support/register.php" target="_blank"><?php _e( 'Register now »', 'give' ); ?></a> |
|
| 220 | + <a href="https://wordpress.org/support/register.php" target="_blank"><?php _e('Register now »', 'give'); ?></a> |
|
| 221 | 221 | </p> |
| 222 | 222 | </div> |
| 223 | 223 | </div> |
@@ -234,11 +234,11 @@ discard block |
||
| 234 | 234 | */ |
| 235 | 235 | private function find_or_initialize_translation_details() { |
| 236 | 236 | |
| 237 | - $set = get_transient( 'give_i18n_give_' . $this->locale ); |
|
| 237 | + $set = get_transient('give_i18n_give_'.$this->locale); |
|
| 238 | 238 | |
| 239 | - if ( ! $set ) { |
|
| 239 | + if ( ! $set) { |
|
| 240 | 240 | $set = $this->retrieve_translation_details(); |
| 241 | - set_transient( 'give_i18n_give_' . $this->locale, $set, DAY_IN_SECONDS ); |
|
| 241 | + set_transient('give_i18n_give_'.$this->locale, $set, DAY_IN_SECONDS); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | return $set; |
@@ -252,10 +252,10 @@ discard block |
||
| 252 | 252 | private function translation_details() { |
| 253 | 253 | $set = $this->find_or_initialize_translation_details(); |
| 254 | 254 | |
| 255 | - $this->translation_exists = ! is_null( $set ); |
|
| 256 | - $this->translation_loaded = is_textdomain_loaded( 'give' ); |
|
| 255 | + $this->translation_exists = ! is_null($set); |
|
| 256 | + $this->translation_loaded = is_textdomain_loaded('give'); |
|
| 257 | 257 | |
| 258 | - $this->parse_translation_set( $set ); |
|
| 258 | + $this->parse_translation_set($set); |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | /** |
@@ -267,26 +267,26 @@ discard block |
||
| 267 | 267 | */ |
| 268 | 268 | private function retrieve_translation_details() { |
| 269 | 269 | |
| 270 | - $api_url = trailingslashit( $this->glotpress_url ); |
|
| 270 | + $api_url = trailingslashit($this->glotpress_url); |
|
| 271 | 271 | |
| 272 | - $resp = wp_remote_get( $api_url ); |
|
| 272 | + $resp = wp_remote_get($api_url); |
|
| 273 | 273 | |
| 274 | - if ( is_wp_error( $resp ) || wp_remote_retrieve_response_code( $resp ) === '404' ) { |
|
| 274 | + if (is_wp_error($resp) || wp_remote_retrieve_response_code($resp) === '404') { |
|
| 275 | 275 | return null; |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - $body = wp_remote_retrieve_body( $resp ); |
|
| 279 | - unset( $resp ); |
|
| 278 | + $body = wp_remote_retrieve_body($resp); |
|
| 279 | + unset($resp); |
|
| 280 | 280 | |
| 281 | - if ( $body ) { |
|
| 282 | - $body = json_decode( $body ); |
|
| 281 | + if ($body) { |
|
| 282 | + $body = json_decode($body); |
|
| 283 | 283 | |
| 284 | - foreach ( $body->translation_sets as $set ) { |
|
| 285 | - if ( ! property_exists( $set, 'wp_locale' ) ) { |
|
| 284 | + foreach ($body->translation_sets as $set) { |
|
| 285 | + if ( ! property_exists($set, 'wp_locale')) { |
|
| 286 | 286 | continue; |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - if ( $this->locale == $set->wp_locale ) { |
|
| 289 | + if ($this->locale == $set->wp_locale) { |
|
| 290 | 290 | return $set; |
| 291 | 291 | } |
| 292 | 292 | } |
@@ -302,8 +302,8 @@ discard block |
||
| 302 | 302 | * |
| 303 | 303 | * @access private |
| 304 | 304 | */ |
| 305 | - private function parse_translation_set( $set ) { |
|
| 306 | - if ( $this->translation_exists && is_object( $set ) ) { |
|
| 305 | + private function parse_translation_set($set) { |
|
| 306 | + if ($this->translation_exists && is_object($set)) { |
|
| 307 | 307 | $this->locale_name = $set->name; |
| 308 | 308 | $this->percent_translated = $set->percent_translated; |
| 309 | 309 | } else { |