@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | // Exit if accessed directly. |
| 19 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 19 | +if ( ! defined('ABSPATH')) { |
|
| 20 | 20 | exit; |
| 21 | 21 | } |
| 22 | 22 | |
@@ -29,8 +29,8 @@ discard block |
||
| 29 | 29 | * @return void |
| 30 | 30 | */ |
| 31 | 31 | function give_reports_page() { |
| 32 | - $current_page = admin_url( 'edit.php?post_type=give_forms&page=give-reports' ); |
|
| 33 | - $active_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings'; |
|
| 32 | + $current_page = admin_url('edit.php?post_type=give_forms&page=give-reports'); |
|
| 33 | + $active_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings'; |
|
| 34 | 34 | $views = give_reports_default_views(); |
| 35 | 35 | ?> |
| 36 | 36 | <div class="wrap give-settings-page"> |
@@ -38,17 +38,17 @@ discard block |
||
| 38 | 38 | <h1 class="screen-reader-text"><?php echo get_admin_page_title(); ?></h1> |
| 39 | 39 | |
| 40 | 40 | <h2 class="nav-tab-wrapper"> |
| 41 | - <?php foreach ( $views as $tab => $label ) { ?> |
|
| 42 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
| 41 | + <?php foreach ($views as $tab => $label) { ?> |
|
| 42 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
| 43 | 43 | 'tab' => $tab, |
| 44 | 44 | 'settings-updated' => false, |
| 45 | - ), $current_page ) ); ?>" class="nav-tab <?php echo $tab === $active_tab ? esc_attr( 'nav-tab-active' ) : ''; ?>"><?php echo esc_html( $label ); ?></a> |
|
| 45 | + ), $current_page)); ?>" class="nav-tab <?php echo $tab === $active_tab ? esc_attr('nav-tab-active') : ''; ?>"><?php echo esc_html($label); ?></a> |
|
| 46 | 46 | <?php } ?> |
| 47 | - <?php if ( current_user_can( 'export_give_reports' ) ) { ?> |
|
| 48 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
| 47 | + <?php if (current_user_can('export_give_reports')) { ?> |
|
| 48 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
| 49 | 49 | 'tab' => 'export', |
| 50 | 50 | 'settings-updated' => false, |
| 51 | - ), $current_page ) ); ?>" class="nav-tab <?php echo 'export' === $active_tab ? esc_attr( 'nav-tab-active' ) : ''; ?>"><?php esc_html_e( 'Export', 'give' ); ?></a> |
|
| 51 | + ), $current_page)); ?>" class="nav-tab <?php echo 'export' === $active_tab ? esc_attr('nav-tab-active') : ''; ?>"><?php esc_html_e('Export', 'give'); ?></a> |
|
| 52 | 52 | <?php } |
| 53 | 53 | /** |
| 54 | 54 | * Fires in the report tabs. |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @since 1.0 |
| 59 | 59 | */ |
| 60 | - do_action( 'give_reports_tabs' ); |
|
| 60 | + do_action('give_reports_tabs'); |
|
| 61 | 61 | ?> |
| 62 | 62 | </h2> |
| 63 | 63 | |
@@ -67,10 +67,10 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @since 1.0 |
| 69 | 69 | */ |
| 70 | - do_action( 'give_reports_page_top' ); |
|
| 70 | + do_action('give_reports_page_top'); |
|
| 71 | 71 | |
| 72 | 72 | // Set $active_tab prior to hook firing. |
| 73 | - if ( in_array( $active_tab, array_keys( $views ) ) ) { |
|
| 73 | + if (in_array($active_tab, array_keys($views))) { |
|
| 74 | 74 | $active_tab = 'reports'; |
| 75 | 75 | } |
| 76 | 76 | |
@@ -79,14 +79,14 @@ discard block |
||
| 79 | 79 | * |
| 80 | 80 | * @since 1.0 |
| 81 | 81 | */ |
| 82 | - do_action( "give_reports_tab_{$active_tab}" ); |
|
| 82 | + do_action("give_reports_tab_{$active_tab}"); |
|
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * Fires after the report page. |
| 86 | 86 | * |
| 87 | 87 | * @since 1.0 |
| 88 | 88 | */ |
| 89 | - do_action( 'give_reports_page_bottom' ); |
|
| 89 | + do_action('give_reports_page_bottom'); |
|
| 90 | 90 | ?> |
| 91 | 91 | </div><!-- .wrap --> |
| 92 | 92 | <?php |
@@ -100,13 +100,13 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | function give_reports_default_views() { |
| 102 | 102 | $views = array( |
| 103 | - 'earnings' => esc_html__( 'Income', 'give' ), |
|
| 104 | - 'forms' => esc_html__( 'Forms', 'give' ), |
|
| 105 | - 'donors' => esc_html__( 'Donors', 'give' ), |
|
| 106 | - 'gateways' => esc_html__( 'Donation Methods', 'give' ), |
|
| 103 | + 'earnings' => esc_html__('Income', 'give'), |
|
| 104 | + 'forms' => esc_html__('Forms', 'give'), |
|
| 105 | + 'donors' => esc_html__('Donors', 'give'), |
|
| 106 | + 'gateways' => esc_html__('Donation Methods', 'give'), |
|
| 107 | 107 | ); |
| 108 | 108 | |
| 109 | - $views = apply_filters( 'give_report_views', $views ); |
|
| 109 | + $views = apply_filters('give_report_views', $views); |
|
| 110 | 110 | |
| 111 | 111 | return $views; |
| 112 | 112 | } |
@@ -121,15 +121,15 @@ discard block |
||
| 121 | 121 | * @since 1.0 |
| 122 | 122 | * @return string $view Report View |
| 123 | 123 | */ |
| 124 | -function give_get_reporting_view( $default = 'earnings' ) { |
|
| 124 | +function give_get_reporting_view($default = 'earnings') { |
|
| 125 | 125 | |
| 126 | - if ( ! isset( $_GET['view'] ) || ! in_array( $_GET['view'], array_keys( give_reports_default_views() ) ) ) { |
|
| 126 | + if ( ! isset($_GET['view']) || ! in_array($_GET['view'], array_keys(give_reports_default_views()))) { |
|
| 127 | 127 | $view = $default; |
| 128 | 128 | } else { |
| 129 | 129 | $view = $_GET['view']; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - return apply_filters( 'give_get_reporting_view', $view ); |
|
| 132 | + return apply_filters('give_get_reporting_view', $view); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | $current_view = 'earnings'; |
| 143 | 143 | $views = give_reports_default_views(); |
| 144 | 144 | |
| 145 | - if ( isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $views ) ) { |
|
| 145 | + if (isset($_GET['tab']) && array_key_exists($_GET['tab'], $views)) { |
|
| 146 | 146 | $current_view = $_GET['tab']; |
| 147 | 147 | } |
| 148 | 148 | |
@@ -151,10 +151,10 @@ discard block |
||
| 151 | 151 | * |
| 152 | 152 | * @since 1.0 |
| 153 | 153 | */ |
| 154 | - do_action( "give_reports_view_{$current_view}" ); |
|
| 154 | + do_action("give_reports_view_{$current_view}"); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | -add_action( 'give_reports_tab_reports', 'give_reports_tab_reports' ); |
|
| 157 | +add_action('give_reports_tab_reports', 'give_reports_tab_reports'); |
|
| 158 | 158 | |
| 159 | 159 | /** |
| 160 | 160 | * Renders the Reports Page Views Drop Downs |
@@ -164,19 +164,19 @@ discard block |
||
| 164 | 164 | */ |
| 165 | 165 | function give_report_views() { |
| 166 | 166 | $views = give_reports_default_views(); |
| 167 | - $current_view = isset( $_GET['view'] ) ? $_GET['view'] : 'earnings'; |
|
| 167 | + $current_view = isset($_GET['view']) ? $_GET['view'] : 'earnings'; |
|
| 168 | 168 | /** |
| 169 | 169 | * Fires before the report page actions form. |
| 170 | 170 | * |
| 171 | 171 | * @since 1.0 |
| 172 | 172 | */ |
| 173 | - do_action( 'give_report_view_actions_before' ); |
|
| 173 | + do_action('give_report_view_actions_before'); |
|
| 174 | 174 | ?> |
| 175 | 175 | <form id="give-reports-filter" method="get"> |
| 176 | 176 | <select id="give-reports-view" name="view"> |
| 177 | - <option value="-1"><?php esc_html_e( 'Report Type', 'give' ); ?></option> |
|
| 178 | - <?php foreach ( $views as $view_id => $label ) : ?> |
|
| 179 | - <option value="<?php echo esc_attr( $view_id ); ?>" <?php selected( $view_id, $current_view ); ?>><?php echo $label; ?></option> |
|
| 177 | + <option value="-1"><?php esc_html_e('Report Type', 'give'); ?></option> |
|
| 178 | + <?php foreach ($views as $view_id => $label) : ?> |
|
| 179 | + <option value="<?php echo esc_attr($view_id); ?>" <?php selected($view_id, $current_view); ?>><?php echo $label; ?></option> |
|
| 180 | 180 | <?php endforeach; ?> |
| 181 | 181 | </select> |
| 182 | 182 | |
@@ -188,12 +188,12 @@ discard block |
||
| 188 | 188 | * |
| 189 | 189 | * @since 1.0 |
| 190 | 190 | */ |
| 191 | - do_action( 'give_report_view_actions' ); |
|
| 191 | + do_action('give_report_view_actions'); |
|
| 192 | 192 | ?> |
| 193 | 193 | |
| 194 | 194 | <input type="hidden" name="post_type" value="give_forms"/> |
| 195 | 195 | <input type="hidden" name="page" value="give-reports"/> |
| 196 | - <?php submit_button( esc_html__( 'Show', 'give' ), 'secondary', 'submit', false ); ?> |
|
| 196 | + <?php submit_button(esc_html__('Show', 'give'), 'secondary', 'submit', false); ?> |
|
| 197 | 197 | </form> |
| 198 | 198 | <?php |
| 199 | 199 | /** |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * |
| 202 | 202 | * @since 1.0 |
| 203 | 203 | */ |
| 204 | - do_action( 'give_report_view_actions_after' ); |
|
| 204 | + do_action('give_report_view_actions_after'); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -214,11 +214,11 @@ discard block |
||
| 214 | 214 | */ |
| 215 | 215 | function give_reports_forms_table() { |
| 216 | 216 | |
| 217 | - if ( isset( $_GET['form-id'] ) ) { |
|
| 217 | + if (isset($_GET['form-id'])) { |
|
| 218 | 218 | return; |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - include( dirname( __FILE__ ) . '/class-form-reports-table.php' ); |
|
| 221 | + include(dirname(__FILE__).'/class-form-reports-table.php'); |
|
| 222 | 222 | |
| 223 | 223 | $give_table = new Give_Form_Reports_Table(); |
| 224 | 224 | $give_table->prepare_items(); |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | <?php |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | -add_action( 'give_reports_view_forms', 'give_reports_forms_table' ); |
|
| 233 | +add_action('give_reports_view_forms', 'give_reports_forms_table'); |
|
| 234 | 234 | |
| 235 | 235 | /** |
| 236 | 236 | * Renders the detailed report for a specific give form. |
@@ -239,20 +239,20 @@ discard block |
||
| 239 | 239 | * @return void |
| 240 | 240 | */ |
| 241 | 241 | function give_reports_form_details() { |
| 242 | - if ( ! isset( $_GET['form-id'] ) ) { |
|
| 242 | + if ( ! isset($_GET['form-id'])) { |
|
| 243 | 243 | return; |
| 244 | 244 | } |
| 245 | 245 | ?> |
| 246 | 246 | <div class="tablenav top reports-forms-details-wrap"> |
| 247 | 247 | <div class="actions bulkactions"> |
| 248 | - <button onclick="history.go(-1);" class="button-secondary"><?php esc_html_e( 'Go Back', 'give' ); ?></button> |
|
| 248 | + <button onclick="history.go(-1);" class="button-secondary"><?php esc_html_e('Go Back', 'give'); ?></button> |
|
| 249 | 249 | </div> |
| 250 | 250 | </div> |
| 251 | 251 | <?php |
| 252 | - give_reports_graph_of_form( absint( $_GET['form-id'] ) ); |
|
| 252 | + give_reports_graph_of_form(absint($_GET['form-id'])); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | -add_action( 'give_reports_view_forms', 'give_reports_form_details' ); |
|
| 255 | +add_action('give_reports_view_forms', 'give_reports_form_details'); |
|
| 256 | 256 | |
| 257 | 257 | /** |
| 258 | 258 | * Renders the Reports Donors Table |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | * @return void |
| 264 | 264 | */ |
| 265 | 265 | function give_reports_donors_table() { |
| 266 | - include( dirname( __FILE__ ) . '/class-donor-reports-table.php' ); |
|
| 266 | + include(dirname(__FILE__).'/class-donor-reports-table.php'); |
|
| 267 | 267 | |
| 268 | 268 | $give_table = new Give_Donor_Reports_Table(); |
| 269 | 269 | $give_table->prepare_items(); |
@@ -275,9 +275,9 @@ discard block |
||
| 275 | 275 | * |
| 276 | 276 | * @since 1.0 |
| 277 | 277 | */ |
| 278 | - do_action( 'give_logs_donors_table_top' ); |
|
| 278 | + do_action('give_logs_donors_table_top'); |
|
| 279 | 279 | |
| 280 | - $give_table->search_box( esc_html__( 'Search', 'give' ), 'give-donors' ); |
|
| 280 | + $give_table->search_box(esc_html__('Search', 'give'), 'give-donors'); |
|
| 281 | 281 | $give_table->display(); |
| 282 | 282 | ?> |
| 283 | 283 | <input type="hidden" name="post_type" value="give_forms"/> |
@@ -290,13 +290,13 @@ discard block |
||
| 290 | 290 | * |
| 291 | 291 | * @since 1.0 |
| 292 | 292 | */ |
| 293 | - do_action( 'give_logs_donors_table_bottom' ); |
|
| 293 | + do_action('give_logs_donors_table_bottom'); |
|
| 294 | 294 | ?> |
| 295 | 295 | </div> |
| 296 | 296 | <?php |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | -add_action( 'give_reports_view_donors', 'give_reports_donors_table' ); |
|
| 299 | +add_action('give_reports_view_donors', 'give_reports_donors_table'); |
|
| 300 | 300 | |
| 301 | 301 | /** |
| 302 | 302 | * Renders the Gateways Table |
@@ -307,14 +307,14 @@ discard block |
||
| 307 | 307 | * @return void |
| 308 | 308 | */ |
| 309 | 309 | function give_reports_gateways_table() { |
| 310 | - include( dirname( __FILE__ ) . '/class-gateways-reports-table.php' ); |
|
| 310 | + include(dirname(__FILE__).'/class-gateways-reports-table.php'); |
|
| 311 | 311 | |
| 312 | 312 | $give_table = new Give_Gateway_Reports_Table(); |
| 313 | 313 | $give_table->prepare_items(); |
| 314 | 314 | $give_table->display(); |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | -add_action( 'give_reports_view_gateways', 'give_reports_gateways_table' ); |
|
| 317 | +add_action('give_reports_view_gateways', 'give_reports_gateways_table'); |
|
| 318 | 318 | |
| 319 | 319 | /** |
| 320 | 320 | * Renders the Reports Earnings Graphs |
@@ -325,13 +325,13 @@ discard block |
||
| 325 | 325 | function give_reports_earnings() { |
| 326 | 326 | ?> |
| 327 | 327 | <div class="tablenav top reports-table-nav"> |
| 328 | - <h3 class="alignleft reports-earnings-title"><span><?php esc_html_e( 'Income Report', 'give' ); ?></span></h3> |
|
| 328 | + <h3 class="alignleft reports-earnings-title"><span><?php esc_html_e('Income Report', 'give'); ?></span></h3> |
|
| 329 | 329 | </div> |
| 330 | 330 | <?php |
| 331 | 331 | give_reports_graph(); |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | -add_action( 'give_reports_view_earnings', 'give_reports_earnings' ); |
|
| 334 | +add_action('give_reports_view_earnings', 'give_reports_earnings'); |
|
| 335 | 335 | |
| 336 | 336 | |
| 337 | 337 | /** |
@@ -342,9 +342,9 @@ discard block |
||
| 342 | 342 | */ |
| 343 | 343 | function give_estimated_monthly_stats() { |
| 344 | 344 | |
| 345 | - $estimated = Give_Cache::get( 'give_estimated_monthly_stats', true ); |
|
| 345 | + $estimated = Give_Cache::get('give_estimated_monthly_stats', true); |
|
| 346 | 346 | |
| 347 | - if ( false === $estimated ) { |
|
| 347 | + if (false === $estimated) { |
|
| 348 | 348 | |
| 349 | 349 | $estimated = array( |
| 350 | 350 | 'earnings' => 0, |
@@ -353,22 +353,22 @@ discard block |
||
| 353 | 353 | |
| 354 | 354 | $stats = new Give_Payment_Stats; |
| 355 | 355 | |
| 356 | - $to_date_earnings = $stats->get_earnings( 0, 'this_month' ); |
|
| 357 | - $to_date_sales = $stats->get_sales( 0, 'this_month' ); |
|
| 356 | + $to_date_earnings = $stats->get_earnings(0, 'this_month'); |
|
| 357 | + $to_date_sales = $stats->get_sales(0, 'this_month'); |
|
| 358 | 358 | |
| 359 | - $current_day = date( 'd', current_time( 'timestamp' ) ); |
|
| 360 | - $current_month = date( 'n', current_time( 'timestamp' ) ); |
|
| 361 | - $current_year = date( 'Y', current_time( 'timestamp' ) ); |
|
| 362 | - $days_in_month = cal_days_in_month( CAL_GREGORIAN, $current_month, $current_year ); |
|
| 359 | + $current_day = date('d', current_time('timestamp')); |
|
| 360 | + $current_month = date('n', current_time('timestamp')); |
|
| 361 | + $current_year = date('Y', current_time('timestamp')); |
|
| 362 | + $days_in_month = cal_days_in_month(CAL_GREGORIAN, $current_month, $current_year); |
|
| 363 | 363 | |
| 364 | - $estimated['earnings'] = ( $to_date_earnings / $current_day ) * $days_in_month; |
|
| 365 | - $estimated['sales'] = ( $to_date_sales / $current_day ) * $days_in_month; |
|
| 364 | + $estimated['earnings'] = ($to_date_earnings / $current_day) * $days_in_month; |
|
| 365 | + $estimated['sales'] = ($to_date_sales / $current_day) * $days_in_month; |
|
| 366 | 366 | |
| 367 | 367 | // Cache for one day |
| 368 | - Give_Cache::set( 'give_estimated_monthly_stats', $estimated, DAY_IN_SECONDS, true ); |
|
| 368 | + Give_Cache::set('give_estimated_monthly_stats', $estimated, DAY_IN_SECONDS, true); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | - return maybe_unserialize( $estimated ); |
|
| 371 | + return maybe_unserialize($estimated); |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 374 | /** |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | function give_reports_set_form_method() { |
| 382 | 382 | return 'get'; |
| 383 | 383 | } |
| 384 | -add_filter( 'give-reports_form_method_tab_forms', 'give_reports_set_form_method', 10 ); |
|
| 385 | -add_filter( 'give-reports_form_method_tab_donors', 'give_reports_set_form_method', 10 ); |
|
| 384 | +add_filter('give-reports_form_method_tab_forms', 'give_reports_set_form_method', 10); |
|
| 385 | +add_filter('give-reports_form_method_tab_donors', 'give_reports_set_form_method', 10); |
|
| 386 | 386 | |
| 387 | 387 | // @TODO: After release 1.8 Donations -> Reports generates with new setting api, so we can remove some old code from this 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 | |
@@ -32,17 +32,17 @@ discard block |
||
| 32 | 32 | global $give_settings_page, $give_payments_page, $give_reports_page, $give_add_ons_page, $give_donors_page, $give_tools_page; |
| 33 | 33 | |
| 34 | 34 | //Payments |
| 35 | - $give_payment = get_post_type_object( 'give_payment' ); |
|
| 36 | - $give_payments_page = add_submenu_page( 'edit.php?post_type=give_forms', $give_payment->labels->name, $give_payment->labels->menu_name, 'edit_give_payments', 'give-payment-history', 'give_payment_history_page' ); |
|
| 35 | + $give_payment = get_post_type_object('give_payment'); |
|
| 36 | + $give_payments_page = add_submenu_page('edit.php?post_type=give_forms', $give_payment->labels->name, $give_payment->labels->menu_name, 'edit_give_payments', 'give-payment-history', 'give_payment_history_page'); |
|
| 37 | 37 | |
| 38 | 38 | //Donors |
| 39 | - $give_donors_page = add_submenu_page( 'edit.php?post_type=give_forms', esc_html__( 'Donors', 'give' ), esc_html__( 'Donors', 'give' ), 'view_give_reports', 'give-donors', 'give_donors_page' ); |
|
| 39 | + $give_donors_page = add_submenu_page('edit.php?post_type=give_forms', esc_html__('Donors', 'give'), esc_html__('Donors', 'give'), 'view_give_reports', 'give-donors', 'give_donors_page'); |
|
| 40 | 40 | |
| 41 | 41 | //Reports` |
| 42 | 42 | $give_reports_page = add_submenu_page( |
| 43 | 43 | 'edit.php?post_type=give_forms', |
| 44 | - esc_html__( 'Donation Reports', 'give' ), |
|
| 45 | - esc_html__( 'Reports', 'give' ), |
|
| 44 | + esc_html__('Donation Reports', 'give'), |
|
| 45 | + esc_html__('Reports', 'give'), |
|
| 46 | 46 | 'view_give_reports', |
| 47 | 47 | 'give-reports', |
| 48 | 48 | array( |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | //Settings |
| 55 | 55 | $give_settings_page = add_submenu_page( |
| 56 | 56 | 'edit.php?post_type=give_forms', |
| 57 | - esc_html__( 'Give Settings', 'give' ), |
|
| 58 | - esc_html__( 'Settings', 'give' ), |
|
| 57 | + esc_html__('Give Settings', 'give'), |
|
| 58 | + esc_html__('Settings', 'give'), |
|
| 59 | 59 | 'manage_give_settings', |
| 60 | 60 | 'give-settings', |
| 61 | 61 | array( |
@@ -65,16 +65,16 @@ discard block |
||
| 65 | 65 | ); |
| 66 | 66 | |
| 67 | 67 | //Tools. |
| 68 | - $give_tools_page = add_submenu_page( 'edit.php?post_type=give_forms', esc_html__( 'Give Tools', 'give' ), esc_html__( 'Tools', 'give' ), 'manage_give_settings', 'give-tools', array( |
|
| 68 | + $give_tools_page = add_submenu_page('edit.php?post_type=give_forms', esc_html__('Give Tools', 'give'), esc_html__('Tools', 'give'), 'manage_give_settings', 'give-tools', array( |
|
| 69 | 69 | Give()->give_settings, |
| 70 | 70 | 'output' |
| 71 | - ) ); |
|
| 71 | + )); |
|
| 72 | 72 | |
| 73 | 73 | //Add-ons |
| 74 | - $give_add_ons_page = add_submenu_page( 'edit.php?post_type=give_forms', esc_html__( 'Give Add-ons', 'give' ), esc_html__( 'Add-ons', 'give' ), 'install_plugins', 'give-addons', 'give_add_ons_page' ); |
|
| 74 | + $give_add_ons_page = add_submenu_page('edit.php?post_type=give_forms', esc_html__('Give Add-ons', 'give'), esc_html__('Add-ons', 'give'), 'install_plugins', 'give-addons', 'give_add_ons_page'); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | -add_action( 'admin_menu', 'give_add_options_links', 10 ); |
|
| 77 | +add_action('admin_menu', 'give_add_options_links', 10); |
|
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | 80 | * Determines whether the current admin page is a Give admin page. |
@@ -89,224 +89,224 @@ discard block |
||
| 89 | 89 | * |
| 90 | 90 | * @return bool True if Give admin page. |
| 91 | 91 | */ |
| 92 | -function give_is_admin_page( $passed_page = '', $passed_view = '' ) { |
|
| 92 | +function give_is_admin_page($passed_page = '', $passed_view = '') { |
|
| 93 | 93 | |
| 94 | 94 | global $pagenow, $typenow; |
| 95 | 95 | |
| 96 | 96 | $found = false; |
| 97 | - $post_type = isset( $_GET['post_type'] ) ? strtolower( $_GET['post_type'] ) : false; |
|
| 98 | - $action = isset( $_GET['action'] ) ? strtolower( $_GET['action'] ) : false; |
|
| 99 | - $taxonomy = isset( $_GET['taxonomy'] ) ? strtolower( $_GET['taxonomy'] ) : false; |
|
| 100 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
| 101 | - $view = isset( $_GET['view'] ) ? strtolower( $_GET['view'] ) : false; |
|
| 102 | - $tab = isset( $_GET['tab'] ) ? strtolower( $_GET['tab'] ) : false; |
|
| 103 | - |
|
| 104 | - switch ( $passed_page ) { |
|
| 97 | + $post_type = isset($_GET['post_type']) ? strtolower($_GET['post_type']) : false; |
|
| 98 | + $action = isset($_GET['action']) ? strtolower($_GET['action']) : false; |
|
| 99 | + $taxonomy = isset($_GET['taxonomy']) ? strtolower($_GET['taxonomy']) : false; |
|
| 100 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
| 101 | + $view = isset($_GET['view']) ? strtolower($_GET['view']) : false; |
|
| 102 | + $tab = isset($_GET['tab']) ? strtolower($_GET['tab']) : false; |
|
| 103 | + |
|
| 104 | + switch ($passed_page) { |
|
| 105 | 105 | case 'give_forms': |
| 106 | - switch ( $passed_view ) { |
|
| 106 | + switch ($passed_view) { |
|
| 107 | 107 | case 'list-table': |
| 108 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' ) { |
|
| 108 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php') { |
|
| 109 | 109 | $found = true; |
| 110 | 110 | } |
| 111 | 111 | break; |
| 112 | 112 | case 'edit': |
| 113 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'post.php' ) { |
|
| 113 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'post.php') { |
|
| 114 | 114 | $found = true; |
| 115 | 115 | } |
| 116 | 116 | break; |
| 117 | 117 | case 'new': |
| 118 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'post-new.php' ) { |
|
| 118 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'post-new.php') { |
|
| 119 | 119 | $found = true; |
| 120 | 120 | } |
| 121 | 121 | break; |
| 122 | 122 | default: |
| 123 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) || 'give_forms' === $post_type || ( 'post-new.php' == $pagenow && 'give_forms' === $post_type ) ) { |
|
| 123 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) || 'give_forms' === $post_type || ('post-new.php' == $pagenow && 'give_forms' === $post_type)) { |
|
| 124 | 124 | $found = true; |
| 125 | 125 | } |
| 126 | 126 | break; |
| 127 | 127 | } |
| 128 | 128 | break; |
| 129 | 129 | case 'categories': |
| 130 | - switch ( $passed_view ) { |
|
| 130 | + switch ($passed_view) { |
|
| 131 | 131 | case 'list-table': |
| 132 | 132 | case 'new': |
| 133 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_category' === $taxonomy ) { |
|
| 133 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_category' === $taxonomy) { |
|
| 134 | 134 | $found = true; |
| 135 | 135 | } |
| 136 | 136 | break; |
| 137 | 137 | case 'edit': |
| 138 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_category' === $taxonomy ) { |
|
| 138 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_category' === $taxonomy) { |
|
| 139 | 139 | $found = true; |
| 140 | 140 | } |
| 141 | 141 | break; |
| 142 | 142 | default: |
| 143 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'give_forms_category' === $taxonomy ) { |
|
| 143 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'give_forms_category' === $taxonomy) { |
|
| 144 | 144 | $found = true; |
| 145 | 145 | } |
| 146 | 146 | break; |
| 147 | 147 | } |
| 148 | 148 | break; |
| 149 | 149 | case 'tags': |
| 150 | - switch ( $passed_view ) { |
|
| 150 | + switch ($passed_view) { |
|
| 151 | 151 | case 'list-table': |
| 152 | 152 | case 'new': |
| 153 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_tag' === $taxonomy ) { |
|
| 153 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_tag' === $taxonomy) { |
|
| 154 | 154 | $found = true; |
| 155 | 155 | } |
| 156 | 156 | break; |
| 157 | 157 | case 'edit': |
| 158 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_tag' === $taxonomy ) { |
|
| 158 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_tag' === $taxonomy) { |
|
| 159 | 159 | $found = true; |
| 160 | 160 | } |
| 161 | 161 | break; |
| 162 | 162 | default: |
| 163 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'give_forms_tag' === $taxonomy ) { |
|
| 163 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'give_forms_tag' === $taxonomy) { |
|
| 164 | 164 | $found = true; |
| 165 | 165 | } |
| 166 | 166 | break; |
| 167 | 167 | } |
| 168 | 168 | break; |
| 169 | 169 | case 'payments': |
| 170 | - switch ( $passed_view ) { |
|
| 170 | + switch ($passed_view) { |
|
| 171 | 171 | case 'list-table': |
| 172 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-payment-history' === $page && false === $view ) { |
|
| 172 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-payment-history' === $page && false === $view) { |
|
| 173 | 173 | $found = true; |
| 174 | 174 | } |
| 175 | 175 | break; |
| 176 | 176 | case 'edit': |
| 177 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-payment-history' === $page && 'view-payment-details' === $view ) { |
|
| 177 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-payment-history' === $page && 'view-payment-details' === $view) { |
|
| 178 | 178 | $found = true; |
| 179 | 179 | } |
| 180 | 180 | break; |
| 181 | 181 | default: |
| 182 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-payment-history' === $page ) { |
|
| 182 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-payment-history' === $page) { |
|
| 183 | 183 | $found = true; |
| 184 | 184 | } |
| 185 | 185 | break; |
| 186 | 186 | } |
| 187 | 187 | break; |
| 188 | 188 | case 'reports': |
| 189 | - switch ( $passed_view ) { |
|
| 189 | + switch ($passed_view) { |
|
| 190 | 190 | // If you want to do something like enqueue a script on a particular report's duration, look at $_GET[ 'range' ] |
| 191 | 191 | case 'earnings': |
| 192 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && ( 'earnings' === $view || '-1' === $view || false === $view ) ) { |
|
| 192 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && ('earnings' === $view || '-1' === $view || false === $view)) { |
|
| 193 | 193 | $found = true; |
| 194 | 194 | } |
| 195 | 195 | break; |
| 196 | 196 | case 'donors': |
| 197 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'customers' === $view ) { |
|
| 197 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'customers' === $view) { |
|
| 198 | 198 | $found = true; |
| 199 | 199 | } |
| 200 | 200 | break; |
| 201 | 201 | case 'gateways': |
| 202 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'gateways' === $view ) { |
|
| 202 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'gateways' === $view) { |
|
| 203 | 203 | $found = true; |
| 204 | 204 | } |
| 205 | 205 | break; |
| 206 | 206 | case 'export': |
| 207 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'export' === $view ) { |
|
| 207 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'export' === $view) { |
|
| 208 | 208 | $found = true; |
| 209 | 209 | } |
| 210 | 210 | break; |
| 211 | 211 | case 'logs': |
| 212 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'logs' === $view ) { |
|
| 212 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'logs' === $view) { |
|
| 213 | 213 | $found = true; |
| 214 | 214 | } |
| 215 | 215 | break; |
| 216 | 216 | default: |
| 217 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page ) { |
|
| 217 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page) { |
|
| 218 | 218 | $found = true; |
| 219 | 219 | } |
| 220 | 220 | break; |
| 221 | 221 | } |
| 222 | 222 | break; |
| 223 | 223 | case 'settings': |
| 224 | - switch ( $passed_view ) { |
|
| 224 | + switch ($passed_view) { |
|
| 225 | 225 | case 'general': |
| 226 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && ( 'general' === $tab || false === $tab ) ) { |
|
| 226 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && ('general' === $tab || false === $tab)) { |
|
| 227 | 227 | $found = true; |
| 228 | 228 | } |
| 229 | 229 | break; |
| 230 | 230 | case 'gateways': |
| 231 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'gateways' === $tab ) { |
|
| 231 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'gateways' === $tab) { |
|
| 232 | 232 | $found = true; |
| 233 | 233 | } |
| 234 | 234 | break; |
| 235 | 235 | case 'emails': |
| 236 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'emails' === $tab ) { |
|
| 236 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'emails' === $tab) { |
|
| 237 | 237 | $found = true; |
| 238 | 238 | } |
| 239 | 239 | break; |
| 240 | 240 | case 'display': |
| 241 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'display' === $tab ) { |
|
| 241 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'display' === $tab) { |
|
| 242 | 242 | $found = true; |
| 243 | 243 | } |
| 244 | 244 | break; |
| 245 | 245 | case 'licenses': |
| 246 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'licenses' === $tab ) { |
|
| 246 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'licenses' === $tab) { |
|
| 247 | 247 | $found = true; |
| 248 | 248 | } |
| 249 | 249 | break; |
| 250 | 250 | case 'api': |
| 251 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'api' === $tab ) { |
|
| 251 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'api' === $tab) { |
|
| 252 | 252 | $found = true; |
| 253 | 253 | } |
| 254 | 254 | break; |
| 255 | 255 | case 'advanced': |
| 256 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'advanced' === $tab ) { |
|
| 256 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'advanced' === $tab) { |
|
| 257 | 257 | $found = true; |
| 258 | 258 | } |
| 259 | 259 | break; |
| 260 | 260 | case 'system_info': |
| 261 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'system_info' === $tab ) { |
|
| 261 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'system_info' === $tab) { |
|
| 262 | 262 | $found = true; |
| 263 | 263 | } |
| 264 | 264 | break; |
| 265 | 265 | default: |
| 266 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page ) { |
|
| 266 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page) { |
|
| 267 | 267 | $found = true; |
| 268 | 268 | } |
| 269 | 269 | break; |
| 270 | 270 | } |
| 271 | 271 | break; |
| 272 | 272 | case 'addons': |
| 273 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-addons' === $page ) { |
|
| 273 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-addons' === $page) { |
|
| 274 | 274 | $found = true; |
| 275 | 275 | } |
| 276 | 276 | break; |
| 277 | 277 | case 'donors': |
| 278 | - switch ( $passed_view ) { |
|
| 278 | + switch ($passed_view) { |
|
| 279 | 279 | case 'list-table': |
| 280 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page && false === $view ) { |
|
| 280 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page && false === $view) { |
|
| 281 | 281 | $found = true; |
| 282 | 282 | } |
| 283 | 283 | break; |
| 284 | 284 | case 'overview': |
| 285 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page && 'overview' === $view ) { |
|
| 285 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page && 'overview' === $view) { |
|
| 286 | 286 | $found = true; |
| 287 | 287 | } |
| 288 | 288 | break; |
| 289 | 289 | case 'notes': |
| 290 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page && 'notes' === $view ) { |
|
| 290 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page && 'notes' === $view) { |
|
| 291 | 291 | $found = true; |
| 292 | 292 | } |
| 293 | 293 | break; |
| 294 | 294 | default: |
| 295 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page ) { |
|
| 295 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page) { |
|
| 296 | 296 | $found = true; |
| 297 | 297 | } |
| 298 | 298 | break; |
| 299 | 299 | } |
| 300 | 300 | break; |
| 301 | 301 | case 'reports': |
| 302 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page ) { |
|
| 302 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page) { |
|
| 303 | 303 | $found = true; |
| 304 | 304 | } |
| 305 | 305 | break; |
| 306 | 306 | default: |
| 307 | 307 | global $give_payments_page, $give_settings_page, $give_reports_page, $give_system_info_page, $give_add_ons_page, $give_settings_export, $give_donors_page, $give_tools_page; |
| 308 | 308 | |
| 309 | - $admin_pages = apply_filters( 'give_admin_pages', array( |
|
| 309 | + $admin_pages = apply_filters('give_admin_pages', array( |
|
| 310 | 310 | $give_payments_page, |
| 311 | 311 | $give_settings_page, |
| 312 | 312 | $give_reports_page, |
@@ -316,16 +316,16 @@ discard block |
||
| 316 | 316 | $give_donors_page, |
| 317 | 317 | $give_tools_page, |
| 318 | 318 | 'widgets.php' |
| 319 | - ) ); |
|
| 320 | - if ( 'give_forms' == $typenow || 'index.php' == $pagenow || 'post-new.php' == $pagenow || 'post.php' == $pagenow ) { |
|
| 319 | + )); |
|
| 320 | + if ('give_forms' == $typenow || 'index.php' == $pagenow || 'post-new.php' == $pagenow || 'post.php' == $pagenow) { |
|
| 321 | 321 | $found = true; |
| 322 | - } elseif ( in_array( $pagenow, $admin_pages ) ) { |
|
| 322 | + } elseif (in_array($pagenow, $admin_pages)) { |
|
| 323 | 323 | $found = true; |
| 324 | 324 | } |
| 325 | 325 | break; |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - return (bool) apply_filters( 'give_is_admin_page', $found, $page, $view, $passed_page, $passed_view ); |
|
| 328 | + return (bool) apply_filters('give_is_admin_page', $found, $page, $view, $passed_page, $passed_view); |
|
| 329 | 329 | |
| 330 | 330 | } |
| 331 | 331 | |
@@ -337,37 +337,37 @@ discard block |
||
| 337 | 337 | * @param array $settings |
| 338 | 338 | * @return array |
| 339 | 339 | */ |
| 340 | -function give_settings_page_pages( $settings ) { |
|
| 341 | - include( 'abstract-admin-settings-page.php' ); |
|
| 342 | - include( 'settings/class-settings-cmb2-backward-compatibility.php' ); |
|
| 340 | +function give_settings_page_pages($settings) { |
|
| 341 | + include('abstract-admin-settings-page.php'); |
|
| 342 | + include('settings/class-settings-cmb2-backward-compatibility.php'); |
|
| 343 | 343 | |
| 344 | 344 | $settings = array( |
| 345 | 345 | // General settings. |
| 346 | - include( 'settings/class-settings-general.php' ), |
|
| 346 | + include('settings/class-settings-general.php'), |
|
| 347 | 347 | |
| 348 | 348 | // Payment Gateways Settings. |
| 349 | - include( 'settings/class-settings-gateways.php' ), |
|
| 349 | + include('settings/class-settings-gateways.php'), |
|
| 350 | 350 | |
| 351 | 351 | // Display settings. |
| 352 | - include( 'settings/class-settings-display.php' ), |
|
| 352 | + include('settings/class-settings-display.php'), |
|
| 353 | 353 | |
| 354 | 354 | // Emails settings. |
| 355 | - include( 'settings/class-settings-email.php' ), |
|
| 355 | + include('settings/class-settings-email.php'), |
|
| 356 | 356 | |
| 357 | 357 | // Addons settings. |
| 358 | - include( 'settings/class-settings-addon.php' ), |
|
| 358 | + include('settings/class-settings-addon.php'), |
|
| 359 | 359 | |
| 360 | 360 | // License settings. |
| 361 | - include( 'settings/class-settings-license.php' ), |
|
| 361 | + include('settings/class-settings-license.php'), |
|
| 362 | 362 | |
| 363 | 363 | // Advanced settinns. |
| 364 | - include( 'settings/class-settings-advanced.php' ) |
|
| 364 | + include('settings/class-settings-advanced.php') |
|
| 365 | 365 | ); |
| 366 | 366 | |
| 367 | 367 | // Output. |
| 368 | 368 | return $settings; |
| 369 | 369 | } |
| 370 | -add_filter( 'give-settings_get_settings_pages', 'give_settings_page_pages', 0, 1 ); |
|
| 370 | +add_filter('give-settings_get_settings_pages', 'give_settings_page_pages', 0, 1); |
|
| 371 | 371 | |
| 372 | 372 | |
| 373 | 373 | /** |
@@ -377,28 +377,28 @@ discard block |
||
| 377 | 377 | * @param array $settings |
| 378 | 378 | * @return array |
| 379 | 379 | */ |
| 380 | -function give_reports_page_pages( $settings ) { |
|
| 381 | - include( 'abstract-admin-settings-page.php' ); |
|
| 380 | +function give_reports_page_pages($settings) { |
|
| 381 | + include('abstract-admin-settings-page.php'); |
|
| 382 | 382 | |
| 383 | 383 | $settings = array( |
| 384 | 384 | // Earnings. |
| 385 | - include( 'reports/class-earnings-report.php' ), |
|
| 385 | + include('reports/class-earnings-report.php'), |
|
| 386 | 386 | |
| 387 | 387 | // Forms. |
| 388 | - include( 'reports/class-forms-report.php' ), |
|
| 388 | + include('reports/class-forms-report.php'), |
|
| 389 | 389 | |
| 390 | 390 | // Donors. |
| 391 | - include( 'reports/class-donors-report.php' ), |
|
| 391 | + include('reports/class-donors-report.php'), |
|
| 392 | 392 | |
| 393 | 393 | // Gateways. |
| 394 | - include( 'reports/class-gateways-report.php' ), |
|
| 394 | + include('reports/class-gateways-report.php'), |
|
| 395 | 395 | |
| 396 | 396 | ); |
| 397 | 397 | |
| 398 | 398 | // Output. |
| 399 | 399 | return $settings; |
| 400 | 400 | } |
| 401 | -add_filter( 'give-reports_get_settings_pages', 'give_reports_page_pages', 0, 1 ); |
|
| 401 | +add_filter('give-reports_get_settings_pages', 'give_reports_page_pages', 0, 1); |
|
| 402 | 402 | |
| 403 | 403 | /** |
| 404 | 404 | * Add setting tab to give-settings page |
@@ -407,31 +407,31 @@ discard block |
||
| 407 | 407 | * @param array $settings |
| 408 | 408 | * @return array |
| 409 | 409 | */ |
| 410 | -function give_tools_page_pages( $settings ) { |
|
| 411 | - include( 'abstract-admin-settings-page.php' ); |
|
| 410 | +function give_tools_page_pages($settings) { |
|
| 411 | + include('abstract-admin-settings-page.php'); |
|
| 412 | 412 | |
| 413 | 413 | $settings = array( |
| 414 | 414 | // System Info. |
| 415 | - include( 'tools/class-settings-system-info.php' ), |
|
| 415 | + include('tools/class-settings-system-info.php'), |
|
| 416 | 416 | |
| 417 | 417 | // Logs. |
| 418 | - include( 'tools/class-settings-logs.php' ), |
|
| 418 | + include('tools/class-settings-logs.php'), |
|
| 419 | 419 | |
| 420 | 420 | // API. |
| 421 | - include( 'tools/class-settings-api.php' ), |
|
| 421 | + include('tools/class-settings-api.php'), |
|
| 422 | 422 | |
| 423 | 423 | // Data. |
| 424 | - include( 'tools/class-settings-data.php' ), |
|
| 424 | + include('tools/class-settings-data.php'), |
|
| 425 | 425 | |
| 426 | 426 | // Export. |
| 427 | - include( 'tools/class-settings-export.php' ), |
|
| 427 | + include('tools/class-settings-export.php'), |
|
| 428 | 428 | |
| 429 | 429 | ); |
| 430 | 430 | |
| 431 | 431 | // Output. |
| 432 | 432 | return $settings; |
| 433 | 433 | } |
| 434 | -add_filter( 'give-tools_get_settings_pages', 'give_tools_page_pages', 0, 1 ); |
|
| 434 | +add_filter('give-tools_get_settings_pages', 'give_tools_page_pages', 0, 1); |
|
| 435 | 435 | |
| 436 | 436 | /** |
| 437 | 437 | * Set default tools page tab. |
@@ -440,10 +440,10 @@ discard block |
||
| 440 | 440 | * @param string $default_tab Default tab name. |
| 441 | 441 | * @return string |
| 442 | 442 | */ |
| 443 | -function give_set_default_tab_form_tools_page( $default_tab ) { |
|
| 443 | +function give_set_default_tab_form_tools_page($default_tab) { |
|
| 444 | 444 | return 'system-info'; |
| 445 | 445 | } |
| 446 | -add_filter( 'give_default_setting_tab_give-tools', 'give_set_default_tab_form_tools_page', 10, 1 ); |
|
| 446 | +add_filter('give_default_setting_tab_give-tools', 'give_set_default_tab_form_tools_page', 10, 1); |
|
| 447 | 447 | |
| 448 | 448 | |
| 449 | 449 | /** |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | * @param string $default_tab Default tab name. |
| 454 | 454 | * @return string |
| 455 | 455 | */ |
| 456 | -function give_set_default_tab_form_reports_page( $default_tab ) { |
|
| 456 | +function give_set_default_tab_form_reports_page($default_tab) { |
|
| 457 | 457 | return 'earnings'; |
| 458 | 458 | } |
| 459 | -add_filter( 'give_default_setting_tab_give-reports', 'give_set_default_tab_form_reports_page', 10, 1 ); |
|
| 460 | 459 | \ No newline at end of file |
| 460 | +add_filter('give_default_setting_tab_give-reports', 'give_set_default_tab_form_reports_page', 10, 1); |
|
| 461 | 461 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | function give_get_logs_tab() { |
| 24 | 24 | |
| 25 | - require( GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/logs.php' ); |
|
| 25 | + require(GIVE_PLUGIN_DIR.'includes/admin/tools/logs/logs.php'); |
|
| 26 | 26 | |
| 27 | 27 | // Get current section. |
| 28 | 28 | $current_section = $_GET['section'] = give_get_current_setting_section(); |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @since 1.0 |
| 34 | 34 | */ |
| 35 | - do_action( "give_logs_view_{$current_section}" ); |
|
| 35 | + do_action("give_logs_view_{$current_section}"); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | function give_logs_view_sales() { |
| 48 | 48 | |
| 49 | - include GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/class-sales-logs-list-table.php'; |
|
| 49 | + include GIVE_PLUGIN_DIR.'includes/admin/tools/logs/class-sales-logs-list-table.php'; |
|
| 50 | 50 | |
| 51 | 51 | $logs_table = new Give_Sales_Log_Table(); |
| 52 | 52 | $logs_table->prepare_items(); |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * |
| 60 | 60 | * @since 1.8.12 |
| 61 | 61 | */ |
| 62 | - do_action( 'give_logs_donations_top' ); |
|
| 62 | + do_action('give_logs_donations_top'); |
|
| 63 | 63 | |
| 64 | 64 | $logs_table->display(); ?> |
| 65 | 65 | <input type="hidden" name="post_type" value="give_forms"/> |
@@ -73,14 +73,14 @@ discard block |
||
| 73 | 73 | * |
| 74 | 74 | * @since 1.8.12 |
| 75 | 75 | */ |
| 76 | - do_action( 'give_logs_donations_bottom' ); |
|
| 76 | + do_action('give_logs_donations_bottom'); |
|
| 77 | 77 | ?> |
| 78 | 78 | |
| 79 | 79 | </div> |
| 80 | 80 | <?php |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | -add_action( 'give_logs_view_sales', 'give_logs_view_sales' ); |
|
| 83 | +add_action('give_logs_view_sales', 'give_logs_view_sales'); |
|
| 84 | 84 | |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | * @return void |
| 93 | 93 | */ |
| 94 | 94 | function give_logs_view_gateway_errors() { |
| 95 | - include( GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/class-gateway-error-logs-list-table.php' ); |
|
| 95 | + include(GIVE_PLUGIN_DIR.'includes/admin/tools/logs/class-gateway-error-logs-list-table.php'); |
|
| 96 | 96 | |
| 97 | 97 | $logs_table = new Give_Gateway_Error_Log_Table(); |
| 98 | 98 | $logs_table->prepare_items(); |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | * |
| 106 | 106 | * @since 1.8.12 |
| 107 | 107 | */ |
| 108 | - do_action( 'give_logs_payment_error_top' ); |
|
| 108 | + do_action('give_logs_payment_error_top'); |
|
| 109 | 109 | |
| 110 | 110 | $logs_table->display(); ?> |
| 111 | 111 | <input type="hidden" name="post_type" value="give_forms"/> |
@@ -119,14 +119,14 @@ discard block |
||
| 119 | 119 | * |
| 120 | 120 | * @since 1.8.12 |
| 121 | 121 | */ |
| 122 | - do_action( 'give_logs_payment_error_bottom' ); |
|
| 122 | + do_action('give_logs_payment_error_bottom'); |
|
| 123 | 123 | ?> |
| 124 | 124 | |
| 125 | 125 | </div> |
| 126 | 126 | <?php |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | -add_action( 'give_logs_view_gateway_errors', 'give_logs_view_gateway_errors' ); |
|
| 129 | +add_action('give_logs_view_gateway_errors', 'give_logs_view_gateway_errors'); |
|
| 130 | 130 | |
| 131 | 131 | /** |
| 132 | 132 | * API Request Logs |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | * @return void |
| 139 | 139 | */ |
| 140 | 140 | function give_logs_view_api_requests() { |
| 141 | - include( GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/class-api-requests-logs-list-table.php' ); |
|
| 141 | + include(GIVE_PLUGIN_DIR.'includes/admin/tools/logs/class-api-requests-logs-list-table.php'); |
|
| 142 | 142 | |
| 143 | 143 | $logs_table = new Give_API_Request_Log_Table(); |
| 144 | 144 | $logs_table->prepare_items(); |
@@ -151,9 +151,9 @@ discard block |
||
| 151 | 151 | * |
| 152 | 152 | * @since 1.0 |
| 153 | 153 | */ |
| 154 | - do_action( 'give_logs_api_requests_top' ); |
|
| 154 | + do_action('give_logs_api_requests_top'); |
|
| 155 | 155 | |
| 156 | - $logs_table->search_box( esc_html__( 'Search', 'give' ), 'give-api-requests' ); |
|
| 156 | + $logs_table->search_box(esc_html__('Search', 'give'), 'give-api-requests'); |
|
| 157 | 157 | $logs_table->display(); |
| 158 | 158 | ?> |
| 159 | 159 | <input type="hidden" name="post_type" value="give_forms"/> |
@@ -167,14 +167,14 @@ discard block |
||
| 167 | 167 | * |
| 168 | 168 | * @since 1.0 |
| 169 | 169 | */ |
| 170 | - do_action( 'give_logs_api_requests_bottom' ); |
|
| 170 | + do_action('give_logs_api_requests_bottom'); |
|
| 171 | 171 | ?> |
| 172 | 172 | |
| 173 | 173 | </div> |
| 174 | 174 | <?php |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | -add_action( 'give_logs_view_api_requests', 'give_logs_view_api_requests' ); |
|
| 177 | +add_action('give_logs_view_api_requests', 'give_logs_view_api_requests'); |
|
| 178 | 178 | |
| 179 | 179 | /** |
| 180 | 180 | * Renders the log views drop down. |
@@ -186,11 +186,11 @@ discard block |
||
| 186 | 186 | $current_section = give_get_current_setting_section(); |
| 187 | 187 | |
| 188 | 188 | // If there are not any event attach to action then do not show form. |
| 189 | - if ( ! has_action( 'give_log_view_actions' ) ) { |
|
| 189 | + if ( ! has_action('give_log_view_actions')) { |
|
| 190 | 190 | return; |
| 191 | 191 | } |
| 192 | 192 | ?> |
| 193 | - <form id="give-logs-filter" method="get" action="<?php echo 'edit.php?post_type=give_forms&page=give-tools&tab=logs§ion=' . $current_section; ?>"> |
|
| 193 | + <form id="give-logs-filter" method="get" action="<?php echo 'edit.php?post_type=give_forms&page=give-tools&tab=logs§ion='.$current_section; ?>"> |
|
| 194 | 194 | <?php |
| 195 | 195 | /** |
| 196 | 196 | * Fires after displaying the reports page views drop down. |
@@ -199,14 +199,14 @@ discard block |
||
| 199 | 199 | * |
| 200 | 200 | * @since 1.0 |
| 201 | 201 | */ |
| 202 | - do_action( 'give_log_view_actions' ); |
|
| 202 | + do_action('give_log_view_actions'); |
|
| 203 | 203 | ?> |
| 204 | 204 | |
| 205 | 205 | <input type="hidden" name="post_type" value="give_forms"/> |
| 206 | 206 | <input type="hidden" name="page" value="give-tools"/> |
| 207 | 207 | <input type="hidden" name="tab" value="logs"/> |
| 208 | 208 | |
| 209 | - <?php submit_button( esc_html__( 'Apply', 'give' ), 'secondary', 'submit', false ); ?> |
|
| 209 | + <?php submit_button(esc_html__('Apply', 'give'), 'secondary', 'submit', false); ?> |
|
| 210 | 210 | </form> |
| 211 | 211 | <?php |
| 212 | 212 | } |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | * |
| 219 | 219 | * @return string |
| 220 | 220 | */ |
| 221 | -function give_tools_set_form_method( $method ) { |
|
| 221 | +function give_tools_set_form_method($method) { |
|
| 222 | 222 | return 'get'; |
| 223 | 223 | } |
| 224 | -add_filter( 'give-tools_form_method_tab_logs', 'give_tools_set_form_method', 10 ); |
|
| 224 | +add_filter('give-tools_form_method_tab_logs', 'give_tools_set_form_method', 10); |
|
@@ -9,11 +9,11 @@ discard block |
||
| 9 | 9 | * @since 1.8 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; // Exit if accessed directly |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -if ( ! class_exists( 'Give_Settings_Logs' ) ) : |
|
| 16 | +if ( ! class_exists('Give_Settings_Logs')) : |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Give_Settings_Logs. |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function __construct() { |
| 45 | 45 | $this->id = 'logs'; |
| 46 | - $this->label = __( 'Logs', 'give' ); |
|
| 46 | + $this->label = __('Logs', 'give'); |
|
| 47 | 47 | |
| 48 | 48 | $this->default_tab = 'sales'; |
| 49 | 49 | |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @return array |
| 62 | 62 | */ |
| 63 | - public function add_settings_page( $pages ) { |
|
| 64 | - $pages[ $this->id ] = $this->label; |
|
| 63 | + public function add_settings_page($pages) { |
|
| 64 | + $pages[$this->id] = $this->label; |
|
| 65 | 65 | |
| 66 | 66 | return $pages; |
| 67 | 67 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | $GLOBALS['give_hide_save_button'] = true; |
| 78 | 78 | |
| 79 | 79 | // Get settings. |
| 80 | - $settings = apply_filters( 'give_settings_logs', array( |
|
| 80 | + $settings = apply_filters('give_settings_logs', array( |
|
| 81 | 81 | array( |
| 82 | 82 | 'id' => 'give_tools_logs', |
| 83 | 83 | 'type' => 'title', |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | ), |
| 86 | 86 | array( |
| 87 | 87 | 'id' => 'api', |
| 88 | - 'name' => __( 'Log', 'give' ), |
|
| 88 | + 'name' => __('Log', 'give'), |
|
| 89 | 89 | 'type' => 'logs', |
| 90 | 90 | |
| 91 | 91 | ), |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | 'type' => 'sectionend', |
| 95 | 95 | 'table_html' => false, |
| 96 | 96 | ), |
| 97 | - ) ); |
|
| 97 | + )); |
|
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | 100 | * Filter the settings. |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @param array $settings |
| 105 | 105 | */ |
| 106 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
| 106 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
| 107 | 107 | |
| 108 | 108 | // Output. |
| 109 | 109 | return $settings; |
@@ -117,14 +117,14 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | public function get_sections() { |
| 119 | 119 | $sections = array( |
| 120 | - 'sales' => __( 'Donations', 'give' ), |
|
| 121 | - 'gateway_errors' => __( 'Payment Errors', 'give' ), |
|
| 122 | - 'api_requests' => __( 'API Requests', 'give' ), |
|
| 120 | + 'sales' => __('Donations', 'give'), |
|
| 121 | + 'gateway_errors' => __('Payment Errors', 'give'), |
|
| 122 | + 'api_requests' => __('API Requests', 'give'), |
|
| 123 | 123 | ); |
| 124 | 124 | |
| 125 | - $sections = apply_filters( 'give_log_views', $sections ); |
|
| 125 | + $sections = apply_filters('give_log_views', $sections); |
|
| 126 | 126 | |
| 127 | - return apply_filters( 'give_get_sections_' . $this->id, $sections ); |
|
| 127 | + return apply_filters('give_get_sections_'.$this->id, $sections); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | public function output() { |
| 137 | 137 | $settings = $this->get_settings(); |
| 138 | 138 | |
| 139 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
| 139 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |
@@ -9,11 +9,11 @@ discard block |
||
| 9 | 9 | * @since 1.8 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; // Exit if accessed directly |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -if ( ! class_exists( 'Give_Settings_System_Info' ) ) : |
|
| 16 | +if ( ! class_exists('Give_Settings_System_Info')) : |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Give_Settings_System_Info. |
@@ -43,15 +43,15 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function __construct() { |
| 45 | 45 | $this->id = 'system-info'; |
| 46 | - $this->label = esc_html__( 'System Info', 'give' ); |
|
| 46 | + $this->label = esc_html__('System Info', 'give'); |
|
| 47 | 47 | |
| 48 | - add_filter( 'give-tools_tabs_array', array( $this, 'add_settings_page' ), 20 ); |
|
| 49 | - add_action( "give-tools_settings_{$this->id}_page", array( $this, 'output' ) ); |
|
| 48 | + add_filter('give-tools_tabs_array', array($this, 'add_settings_page'), 20); |
|
| 49 | + add_action("give-tools_settings_{$this->id}_page", array($this, 'output')); |
|
| 50 | 50 | |
| 51 | 51 | // Do not use main form for this tab. |
| 52 | - if ( give_get_current_setting_tab() === $this->id ) { |
|
| 53 | - add_action( "give-tools_open_form", '__return_empty_string' ); |
|
| 54 | - add_action( "give-tools_close_form", '__return_empty_string' ); |
|
| 52 | + if (give_get_current_setting_tab() === $this->id) { |
|
| 53 | + add_action("give-tools_open_form", '__return_empty_string'); |
|
| 54 | + add_action("give-tools_close_form", '__return_empty_string'); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
@@ -64,8 +64,8 @@ discard block |
||
| 64 | 64 | * |
| 65 | 65 | * @return array |
| 66 | 66 | */ |
| 67 | - public function add_settings_page( $pages ) { |
|
| 68 | - $pages[ $this->id ] = $this->label; |
|
| 67 | + public function add_settings_page($pages) { |
|
| 68 | + $pages[$this->id] = $this->label; |
|
| 69 | 69 | |
| 70 | 70 | return $pages; |
| 71 | 71 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public function output() { |
| 80 | 80 | $GLOBALS['give_hide_save_button'] = true; |
| 81 | - include_once( 'views/html-admin-page-system-info.php' ); |
|
| 81 | + include_once('views/html-admin-page-system-info.php'); |
|
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | |
@@ -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 | |
@@ -55,10 +55,10 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @param $args array The array of arguments that can be passed in and used for setting up this payment query. |
| 57 | 57 | */ |
| 58 | - public function __construct( $args = array() ) { |
|
| 58 | + public function __construct($args = array()) { |
|
| 59 | 59 | $defaults = array( |
| 60 | 60 | 'output' => 'payments', |
| 61 | - 'post_type' => array( 'give_payment' ), |
|
| 61 | + 'post_type' => array('give_payment'), |
|
| 62 | 62 | 'start_date' => false, |
| 63 | 63 | 'end_date' => false, |
| 64 | 64 | 'number' => 20, |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | 'give_forms' => null, |
| 80 | 80 | ); |
| 81 | 81 | |
| 82 | - $this->args = wp_parse_args( $args, $defaults ); |
|
| 82 | + $this->args = wp_parse_args($args, $defaults); |
|
| 83 | 83 | |
| 84 | 84 | $this->init(); |
| 85 | 85 | } |
@@ -93,11 +93,11 @@ discard block |
||
| 93 | 93 | * @param $query_var |
| 94 | 94 | * @param $value |
| 95 | 95 | */ |
| 96 | - public function __set( $query_var, $value ) { |
|
| 97 | - if ( in_array( $query_var, array( 'meta_query', 'tax_query' ) ) ) { |
|
| 98 | - $this->args[ $query_var ][] = $value; |
|
| 96 | + public function __set($query_var, $value) { |
|
| 97 | + if (in_array($query_var, array('meta_query', 'tax_query'))) { |
|
| 98 | + $this->args[$query_var][] = $value; |
|
| 99 | 99 | } else { |
| 100 | - $this->args[ $query_var ] = $value; |
|
| 100 | + $this->args[$query_var] = $value; |
|
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
@@ -109,8 +109,8 @@ discard block |
||
| 109 | 109 | * |
| 110 | 110 | * @param $query_var |
| 111 | 111 | */ |
| 112 | - public function __unset( $query_var ) { |
|
| 113 | - unset( $this->args[ $query_var ] ); |
|
| 112 | + public function __unset($query_var) { |
|
| 113 | + unset($this->args[$query_var]); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | $this->children(); |
| 146 | 146 | $this->give_forms(); |
| 147 | 147 | |
| 148 | - add_filter( 'posts_orderby', array( $this, 'custom_orderby' ), 10, 2 ); |
|
| 148 | + add_filter('posts_orderby', array($this, 'custom_orderby'), 10, 2); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | private function unset_filters() { |
| 158 | 158 | $this->date_filter_post(); |
| 159 | - remove_filter( 'posts_orderby', array( $this, 'custom_orderby' ) ); |
|
| 159 | + remove_filter('posts_orderby', array($this, 'custom_orderby')); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | |
@@ -183,27 +183,27 @@ discard block |
||
| 183 | 183 | * |
| 184 | 184 | * @param Give_Payments_Query $this Payments query object. |
| 185 | 185 | */ |
| 186 | - do_action( 'give_pre_get_payments', $this ); |
|
| 186 | + do_action('give_pre_get_payments', $this); |
|
| 187 | 187 | |
| 188 | - $query = new WP_Query( $this->args ); |
|
| 188 | + $query = new WP_Query($this->args); |
|
| 189 | 189 | |
| 190 | 190 | $custom_output = array( |
| 191 | 191 | 'payments', |
| 192 | 192 | 'give_payments', |
| 193 | 193 | ); |
| 194 | 194 | |
| 195 | - if ( ! in_array( $this->args['output'], $custom_output ) ) { |
|
| 195 | + if ( ! in_array($this->args['output'], $custom_output)) { |
|
| 196 | 196 | return $query->posts; |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - if ( $query->have_posts() ) { |
|
| 200 | - while ( $query->have_posts() ) { |
|
| 199 | + if ($query->have_posts()) { |
|
| 200 | + while ($query->have_posts()) { |
|
| 201 | 201 | $query->the_post(); |
| 202 | 202 | |
| 203 | 203 | $payment_id = get_post()->ID; |
| 204 | - $payment = new Give_Payment( $payment_id ); |
|
| 204 | + $payment = new Give_Payment($payment_id); |
|
| 205 | 205 | |
| 206 | - $this->payments[] = apply_filters( 'give_payment', $payment, $payment_id, $this ); |
|
| 206 | + $this->payments[] = apply_filters('give_payment', $payment, $payment_id, $this); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | wp_reset_postdata(); |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | * |
| 221 | 221 | * @param Give_Payments_Query $this Payments query object. |
| 222 | 222 | */ |
| 223 | - do_action( 'give_post_get_payments', $this ); |
|
| 223 | + do_action('give_post_get_payments', $this); |
|
| 224 | 224 | |
| 225 | 225 | return $this->payments; |
| 226 | 226 | } |
@@ -234,13 +234,13 @@ discard block |
||
| 234 | 234 | * @return void |
| 235 | 235 | */ |
| 236 | 236 | public function date_filter_pre() { |
| 237 | - if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) { |
|
| 237 | + if ( ! ($this->args['start_date'] || $this->args['end_date'])) { |
|
| 238 | 238 | return; |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - $this->setup_dates( $this->args['start_date'], $this->args['end_date'] ); |
|
| 241 | + $this->setup_dates($this->args['start_date'], $this->args['end_date']); |
|
| 242 | 242 | |
| 243 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
| 243 | + add_filter('posts_where', array($this, 'payments_where')); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | /** |
@@ -253,11 +253,11 @@ discard block |
||
| 253 | 253 | * @return void |
| 254 | 254 | */ |
| 255 | 255 | public function date_filter_post() { |
| 256 | - if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) { |
|
| 256 | + if ( ! ($this->args['start_date'] || $this->args['end_date'])) { |
|
| 257 | 257 | return; |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
| 260 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /** |
@@ -269,12 +269,12 @@ discard block |
||
| 269 | 269 | * @return void |
| 270 | 270 | */ |
| 271 | 271 | public function status() { |
| 272 | - if ( ! isset ( $this->args['status'] ) ) { |
|
| 272 | + if ( ! isset ($this->args['status'])) { |
|
| 273 | 273 | return; |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | - $this->__set( 'post_status', $this->args['status'] ); |
|
| 277 | - $this->__unset( 'status' ); |
|
| 276 | + $this->__set('post_status', $this->args['status']); |
|
| 277 | + $this->__unset('status'); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | /** |
@@ -286,12 +286,12 @@ discard block |
||
| 286 | 286 | * @return void |
| 287 | 287 | */ |
| 288 | 288 | public function page() { |
| 289 | - if ( ! isset ( $this->args['page'] ) ) { |
|
| 289 | + if ( ! isset ($this->args['page'])) { |
|
| 290 | 290 | return; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - $this->__set( 'paged', $this->args['page'] ); |
|
| 294 | - $this->__unset( 'page' ); |
|
| 293 | + $this->__set('paged', $this->args['page']); |
|
| 294 | + $this->__unset('page'); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | /** |
@@ -304,17 +304,17 @@ discard block |
||
| 304 | 304 | */ |
| 305 | 305 | public function per_page() { |
| 306 | 306 | |
| 307 | - if ( ! isset( $this->args['number'] ) ) { |
|
| 307 | + if ( ! isset($this->args['number'])) { |
|
| 308 | 308 | return; |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | - if ( $this->args['number'] == - 1 ) { |
|
| 312 | - $this->__set( 'nopaging', true ); |
|
| 311 | + if ($this->args['number'] == - 1) { |
|
| 312 | + $this->__set('nopaging', true); |
|
| 313 | 313 | } else { |
| 314 | - $this->__set( 'posts_per_page', $this->args['number'] ); |
|
| 314 | + $this->__set('posts_per_page', $this->args['number']); |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - $this->__unset( 'number' ); |
|
| 317 | + $this->__unset('number'); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | /** |
@@ -326,12 +326,12 @@ discard block |
||
| 326 | 326 | * @return void |
| 327 | 327 | */ |
| 328 | 328 | public function month() { |
| 329 | - if ( ! isset ( $this->args['month'] ) ) { |
|
| 329 | + if ( ! isset ($this->args['month'])) { |
|
| 330 | 330 | return; |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - $this->__set( 'monthnum', $this->args['month'] ); |
|
| 334 | - $this->__unset( 'month' ); |
|
| 333 | + $this->__set('monthnum', $this->args['month']); |
|
| 334 | + $this->__unset('month'); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | /** |
@@ -343,23 +343,23 @@ discard block |
||
| 343 | 343 | * @return void |
| 344 | 344 | */ |
| 345 | 345 | public function orderby() { |
| 346 | - switch ( $this->args['orderby'] ) { |
|
| 346 | + switch ($this->args['orderby']) { |
|
| 347 | 347 | case 'amount' : |
| 348 | - $this->__set( 'orderby', 'meta_value_num' ); |
|
| 349 | - $this->__set( 'meta_key', '_give_payment_total' ); |
|
| 348 | + $this->__set('orderby', 'meta_value_num'); |
|
| 349 | + $this->__set('meta_key', '_give_payment_total'); |
|
| 350 | 350 | break; |
| 351 | 351 | |
| 352 | 352 | case 'status' : |
| 353 | - $this->__set( 'orderby', 'post_status' ); |
|
| 353 | + $this->__set('orderby', 'post_status'); |
|
| 354 | 354 | break; |
| 355 | 355 | |
| 356 | 356 | case 'donation_form' : |
| 357 | - $this->__set( 'orderby', 'meta_value' ); |
|
| 358 | - $this->__set( 'meta_key', '_give_payment_form_title' ); |
|
| 357 | + $this->__set('orderby', 'meta_value'); |
|
| 358 | + $this->__set('meta_key', '_give_payment_form_title'); |
|
| 359 | 359 | break; |
| 360 | 360 | |
| 361 | 361 | default : |
| 362 | - $this->__set( 'orderby', $this->args['orderby'] ); |
|
| 362 | + $this->__set('orderby', $this->args['orderby']); |
|
| 363 | 363 | break; |
| 364 | 364 | } |
| 365 | 365 | } |
@@ -376,17 +376,17 @@ discard block |
||
| 376 | 376 | * |
| 377 | 377 | * @return mixed |
| 378 | 378 | */ |
| 379 | - public function custom_orderby( $order, $query ) { |
|
| 379 | + public function custom_orderby($order, $query) { |
|
| 380 | 380 | global $wpdb; |
| 381 | 381 | |
| 382 | - $post_types = is_array( $query->query['post_type'] ) ? $query->query['post_type'] : array( $query->query['post_type'] ); |
|
| 383 | - if ( ! in_array( 'give_payment', $post_types ) || is_array( $query->query['orderby'] ) ) { |
|
| 382 | + $post_types = is_array($query->query['post_type']) ? $query->query['post_type'] : array($query->query['post_type']); |
|
| 383 | + if ( ! in_array('give_payment', $post_types) || is_array($query->query['orderby'])) { |
|
| 384 | 384 | return $order; |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | - switch ( $query->query['orderby'] ) { |
|
| 387 | + switch ($query->query['orderby']) { |
|
| 388 | 388 | case 'post_status': |
| 389 | - $order = $wpdb->posts .'.post_status ' . strtoupper( $query->query['order'] ); |
|
| 389 | + $order = $wpdb->posts.'.post_status '.strtoupper($query->query['order']); |
|
| 390 | 390 | break; |
| 391 | 391 | } |
| 392 | 392 | |
@@ -402,20 +402,20 @@ discard block |
||
| 402 | 402 | * @return void |
| 403 | 403 | */ |
| 404 | 404 | public function user() { |
| 405 | - if ( is_null( $this->args['user'] ) ) { |
|
| 405 | + if (is_null($this->args['user'])) { |
|
| 406 | 406 | return; |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - if ( is_numeric( $this->args['user'] ) ) { |
|
| 409 | + if (is_numeric($this->args['user'])) { |
|
| 410 | 410 | $user_key = '_give_payment_user_id'; |
| 411 | 411 | } else { |
| 412 | 412 | $user_key = '_give_payment_user_email'; |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | - $this->__set( 'meta_query', array( |
|
| 415 | + $this->__set('meta_query', array( |
|
| 416 | 416 | 'key' => $user_key, |
| 417 | 417 | 'value' => $this->args['user'], |
| 418 | - ) ); |
|
| 418 | + )); |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | /** |
@@ -426,14 +426,14 @@ discard block |
||
| 426 | 426 | * @return void |
| 427 | 427 | */ |
| 428 | 428 | public function donor() { |
| 429 | - if ( is_null( $this->args['donor'] ) || ! is_numeric( $this->args['donor'] ) ) { |
|
| 429 | + if (is_null($this->args['donor']) || ! is_numeric($this->args['donor'])) { |
|
| 430 | 430 | return; |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | - $this->__set( 'meta_query', array( |
|
| 433 | + $this->__set('meta_query', array( |
|
| 434 | 434 | 'key' => '_give_payment_customer_id', |
| 435 | 435 | 'value' => (int) $this->args['donor'], |
| 436 | - ) ); |
|
| 436 | + )); |
|
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | /** |
@@ -446,33 +446,33 @@ discard block |
||
| 446 | 446 | */ |
| 447 | 447 | public function search() { |
| 448 | 448 | |
| 449 | - if ( ! isset( $this->args['s'] ) ) { |
|
| 449 | + if ( ! isset($this->args['s'])) { |
|
| 450 | 450 | return; |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | - $search = trim( $this->args['s'] ); |
|
| 453 | + $search = trim($this->args['s']); |
|
| 454 | 454 | |
| 455 | - if ( empty( $search ) ) { |
|
| 455 | + if (empty($search)) { |
|
| 456 | 456 | return; |
| 457 | 457 | } |
| 458 | 458 | |
| 459 | - $is_email = is_email( $search ) || strpos( $search, '@' ) !== false; |
|
| 460 | - $is_user = strpos( $search, strtolower( 'user:' ) ) !== false; |
|
| 459 | + $is_email = is_email($search) || strpos($search, '@') !== false; |
|
| 460 | + $is_user = strpos($search, strtolower('user:')) !== false; |
|
| 461 | 461 | |
| 462 | - if ( ! empty( $this->args['search_in_notes'] ) ) { |
|
| 462 | + if ( ! empty($this->args['search_in_notes'])) { |
|
| 463 | 463 | |
| 464 | - $notes = give_get_payment_notes( 0, $search ); |
|
| 464 | + $notes = give_get_payment_notes(0, $search); |
|
| 465 | 465 | |
| 466 | - if ( ! empty( $notes ) ) { |
|
| 466 | + if ( ! empty($notes)) { |
|
| 467 | 467 | |
| 468 | - $payment_ids = wp_list_pluck( (array) $notes, 'comment_post_ID' ); |
|
| 468 | + $payment_ids = wp_list_pluck((array) $notes, 'comment_post_ID'); |
|
| 469 | 469 | |
| 470 | - $this->__set( 'post__in', $payment_ids ); |
|
| 470 | + $this->__set('post__in', $payment_ids); |
|
| 471 | 471 | } |
| 472 | 472 | |
| 473 | - $this->__unset( 's' ); |
|
| 473 | + $this->__unset('s'); |
|
| 474 | 474 | |
| 475 | - } elseif ( $is_email || strlen( $search ) == 32 ) { |
|
| 475 | + } elseif ($is_email || strlen($search) == 32) { |
|
| 476 | 476 | |
| 477 | 477 | $key = $is_email ? '_give_payment_user_email' : '_give_payment_purchase_key'; |
| 478 | 478 | $search_meta = array( |
@@ -481,19 +481,19 @@ discard block |
||
| 481 | 481 | 'compare' => 'LIKE', |
| 482 | 482 | ); |
| 483 | 483 | |
| 484 | - $this->__set( 'meta_query', $search_meta ); |
|
| 485 | - $this->__unset( 's' ); |
|
| 484 | + $this->__set('meta_query', $search_meta); |
|
| 485 | + $this->__unset('s'); |
|
| 486 | 486 | |
| 487 | - } elseif ( $is_user ) { |
|
| 487 | + } elseif ($is_user) { |
|
| 488 | 488 | |
| 489 | 489 | $search_meta = array( |
| 490 | 490 | 'key' => '_give_payment_user_id', |
| 491 | - 'value' => trim( str_replace( 'user:', '', strtolower( $search ) ) ), |
|
| 491 | + 'value' => trim(str_replace('user:', '', strtolower($search))), |
|
| 492 | 492 | ); |
| 493 | 493 | |
| 494 | - $this->__set( 'meta_query', $search_meta ); |
|
| 494 | + $this->__set('meta_query', $search_meta); |
|
| 495 | 495 | |
| 496 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
| 496 | + if (give_get_option('enable_sequential')) { |
|
| 497 | 497 | |
| 498 | 498 | $search_meta = array( |
| 499 | 499 | 'key' => '_give_payment_number', |
@@ -501,19 +501,19 @@ discard block |
||
| 501 | 501 | 'compare' => 'LIKE', |
| 502 | 502 | ); |
| 503 | 503 | |
| 504 | - $this->__set( 'meta_query', $search_meta ); |
|
| 504 | + $this->__set('meta_query', $search_meta); |
|
| 505 | 505 | |
| 506 | 506 | $this->args['meta_query']['relation'] = 'OR'; |
| 507 | 507 | |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | - $this->__unset( 's' ); |
|
| 510 | + $this->__unset('s'); |
|
| 511 | 511 | |
| 512 | 512 | } elseif ( |
| 513 | - give_get_option( 'enable_sequential' ) && |
|
| 513 | + give_get_option('enable_sequential') && |
|
| 514 | 514 | ( |
| 515 | - false !== strpos( $search, give_get_option( 'sequential_prefix' ) ) || |
|
| 516 | - false !== strpos( $search, give_get_option( 'sequential_postfix' ) ) |
|
| 515 | + false !== strpos($search, give_get_option('sequential_prefix')) || |
|
| 516 | + false !== strpos($search, give_get_option('sequential_postfix')) |
|
| 517 | 517 | ) |
| 518 | 518 | ) { |
| 519 | 519 | |
@@ -523,29 +523,29 @@ discard block |
||
| 523 | 523 | 'compare' => 'LIKE', |
| 524 | 524 | ); |
| 525 | 525 | |
| 526 | - $this->__set( 'meta_query', $search_meta ); |
|
| 527 | - $this->__unset( 's' ); |
|
| 526 | + $this->__set('meta_query', $search_meta); |
|
| 527 | + $this->__unset('s'); |
|
| 528 | 528 | |
| 529 | - } elseif ( is_numeric( $search ) ) { |
|
| 529 | + } elseif (is_numeric($search)) { |
|
| 530 | 530 | |
| 531 | - $post = get_post( $search ); |
|
| 531 | + $post = get_post($search); |
|
| 532 | 532 | |
| 533 | - if ( is_object( $post ) && $post->post_type == 'give_payment' ) { |
|
| 533 | + if (is_object($post) && $post->post_type == 'give_payment') { |
|
| 534 | 534 | |
| 535 | 535 | $arr = array(); |
| 536 | 536 | $arr[] = $search; |
| 537 | - $this->__set( 'post__in', $arr ); |
|
| 538 | - $this->__unset( 's' ); |
|
| 537 | + $this->__set('post__in', $arr); |
|
| 538 | + $this->__unset('s'); |
|
| 539 | 539 | } |
| 540 | - } elseif ( '#' == substr( $search, 0, 1 ) ) { |
|
| 540 | + } elseif ('#' == substr($search, 0, 1)) { |
|
| 541 | 541 | |
| 542 | - $search = str_replace( '#:', '', $search ); |
|
| 543 | - $search = str_replace( '#', '', $search ); |
|
| 544 | - $this->__set( 'give_forms', $search ); |
|
| 545 | - $this->__unset( 's' ); |
|
| 542 | + $search = str_replace('#:', '', $search); |
|
| 543 | + $search = str_replace('#', '', $search); |
|
| 544 | + $this->__set('give_forms', $search); |
|
| 545 | + $this->__unset('s'); |
|
| 546 | 546 | |
| 547 | 547 | } else { |
| 548 | - $this->__set( 's', $search ); |
|
| 548 | + $this->__set('s', $search); |
|
| 549 | 549 | |
| 550 | 550 | } |
| 551 | 551 | |
@@ -560,16 +560,16 @@ discard block |
||
| 560 | 560 | * @return void |
| 561 | 561 | */ |
| 562 | 562 | public function mode() { |
| 563 | - if ( empty( $this->args['mode'] ) || $this->args['mode'] == 'all' ) { |
|
| 564 | - $this->__unset( 'mode' ); |
|
| 563 | + if (empty($this->args['mode']) || $this->args['mode'] == 'all') { |
|
| 564 | + $this->__unset('mode'); |
|
| 565 | 565 | |
| 566 | 566 | return; |
| 567 | 567 | } |
| 568 | 568 | |
| 569 | - $this->__set( 'meta_query', array( |
|
| 569 | + $this->__set('meta_query', array( |
|
| 570 | 570 | 'key' => '_give_payment_mode', |
| 571 | 571 | 'value' => $this->args['mode'], |
| 572 | - ) ); |
|
| 572 | + )); |
|
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | /** |
@@ -581,10 +581,10 @@ discard block |
||
| 581 | 581 | * @return void |
| 582 | 582 | */ |
| 583 | 583 | public function children() { |
| 584 | - if ( empty( $this->args['children'] ) ) { |
|
| 585 | - $this->__set( 'post_parent', 0 ); |
|
| 584 | + if (empty($this->args['children'])) { |
|
| 585 | + $this->__set('post_parent', 0); |
|
| 586 | 586 | } |
| 587 | - $this->__unset( 'children' ); |
|
| 587 | + $this->__unset('children'); |
|
| 588 | 588 | } |
| 589 | 589 | |
| 590 | 590 | /** |
@@ -597,25 +597,25 @@ discard block |
||
| 597 | 597 | */ |
| 598 | 598 | public function give_forms() { |
| 599 | 599 | |
| 600 | - if ( empty( $this->args['give_forms'] ) ) { |
|
| 600 | + if (empty($this->args['give_forms'])) { |
|
| 601 | 601 | return; |
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | $compare = '='; |
| 605 | 605 | |
| 606 | - if ( is_array( $this->args['give_forms'] ) ) { |
|
| 606 | + if (is_array($this->args['give_forms'])) { |
|
| 607 | 607 | $compare = 'IN'; |
| 608 | 608 | } |
| 609 | 609 | |
| 610 | - $this->__set( 'meta_query', array( |
|
| 610 | + $this->__set('meta_query', array( |
|
| 611 | 611 | array( |
| 612 | 612 | 'key' => '_give_payment_form_id', |
| 613 | 613 | 'value' => $this->args['give_forms'], |
| 614 | 614 | 'compare' => $compare, |
| 615 | 615 | ), |
| 616 | - ) ); |
|
| 616 | + )); |
|
| 617 | 617 | |
| 618 | - $this->__unset( 'give_forms' ); |
|
| 618 | + $this->__unset('give_forms'); |
|
| 619 | 619 | |
| 620 | 620 | } |
| 621 | 621 | |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Exit if accessed directly. |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if ( ! defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -27,15 +27,15 @@ discard block |
||
| 27 | 27 | * |
| 28 | 28 | * @return bool $ret True if guest checkout is enabled, false otherwise |
| 29 | 29 | */ |
| 30 | -function give_no_guest_checkout( $form_id ) { |
|
| 30 | +function give_no_guest_checkout($form_id) { |
|
| 31 | 31 | |
| 32 | 32 | $backtrace = debug_backtrace(); |
| 33 | 33 | |
| 34 | - _give_deprecated_function( __FUNCTION__, '1.4.1', null, $backtrace ); |
|
| 34 | + _give_deprecated_function(__FUNCTION__, '1.4.1', null, $backtrace); |
|
| 35 | 35 | |
| 36 | - $ret = give_get_meta( $form_id, '_give_logged_in_only', true ); |
|
| 36 | + $ret = give_get_meta($form_id, '_give_logged_in_only', true); |
|
| 37 | 37 | |
| 38 | - return (bool) apply_filters( 'give_no_guest_checkout', give_is_setting_enabled( $ret ) ); |
|
| 38 | + return (bool) apply_filters('give_no_guest_checkout', give_is_setting_enabled($ret)); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | |
@@ -50,15 +50,15 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | $backtrace = debug_backtrace(); |
| 52 | 52 | |
| 53 | - _give_deprecated_function( __FUNCTION__, '1.8', null, $backtrace ); |
|
| 53 | + _give_deprecated_function(__FUNCTION__, '1.8', null, $backtrace); |
|
| 54 | 54 | |
| 55 | 55 | $views = array( |
| 56 | - 'sales' => __( 'Donations', 'give' ), |
|
| 57 | - 'gateway_errors' => __( 'Payment Errors', 'give' ), |
|
| 58 | - 'api_requests' => __( 'API Requests', 'give' ), |
|
| 56 | + 'sales' => __('Donations', 'give'), |
|
| 57 | + 'gateway_errors' => __('Payment Errors', 'give'), |
|
| 58 | + 'api_requests' => __('API Requests', 'give'), |
|
| 59 | 59 | ); |
| 60 | 60 | |
| 61 | - $views = apply_filters( 'give_log_views', $views ); |
|
| 61 | + $views = apply_filters('give_log_views', $views); |
|
| 62 | 62 | |
| 63 | 63 | return $views; |
| 64 | 64 | } |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | $backtrace = debug_backtrace(); |
| 75 | 75 | |
| 76 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_agree_to_terms', $backtrace ); |
|
| 76 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_agree_to_terms', $backtrace); |
|
| 77 | 77 | |
| 78 | 78 | // Call new renamed function. |
| 79 | 79 | give_donation_form_validate_agree_to_terms(); |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | $backtrace = debug_backtrace(); |
| 92 | 92 | |
| 93 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_logged_in_user', $backtrace ); |
|
| 93 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_logged_in_user', $backtrace); |
|
| 94 | 94 | |
| 95 | 95 | // Call new renamed function. |
| 96 | 96 | give_donation_form_validate_logged_in_user(); |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | $backtrace = debug_backtrace(); |
| 109 | 109 | |
| 110 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_gateway', $backtrace ); |
|
| 110 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_gateway', $backtrace); |
|
| 111 | 111 | |
| 112 | 112 | // Call new renamed function. |
| 113 | 113 | give_donation_form_validate_gateway(); |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | $backtrace = debug_backtrace(); |
| 126 | 126 | |
| 127 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_fields', $backtrace ); |
|
| 127 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_fields', $backtrace); |
|
| 128 | 128 | |
| 129 | 129 | // Call new renamed function. |
| 130 | 130 | give_donation_form_validate_fields(); |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | $backtrace = debug_backtrace(); |
| 143 | 143 | |
| 144 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_cc', $backtrace ); |
|
| 144 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_cc', $backtrace); |
|
| 145 | 145 | |
| 146 | 146 | // Call new renamed function. |
| 147 | 147 | give_donation_form_validate_cc(); |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | |
| 159 | 159 | $backtrace = debug_backtrace(); |
| 160 | 160 | |
| 161 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_get_donation_cc_info', $backtrace ); |
|
| 161 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_get_donation_cc_info', $backtrace); |
|
| 162 | 162 | |
| 163 | 163 | // Call new renamed function. |
| 164 | 164 | give_get_donation_cc_info(); |
@@ -175,14 +175,14 @@ discard block |
||
| 175 | 175 | * @param int $zip |
| 176 | 176 | * @param string $country_code |
| 177 | 177 | */ |
| 178 | -function give_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
| 178 | +function give_purchase_form_validate_cc_zip($zip = 0, $country_code = '') { |
|
| 179 | 179 | |
| 180 | 180 | $backtrace = debug_backtrace(); |
| 181 | 181 | |
| 182 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_cc_zip', $backtrace ); |
|
| 182 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_cc_zip', $backtrace); |
|
| 183 | 183 | |
| 184 | 184 | // Call new renamed function. |
| 185 | - give_donation_form_validate_cc_zip( $zip, $country_code ); |
|
| 185 | + give_donation_form_validate_cc_zip($zip, $country_code); |
|
| 186 | 186 | |
| 187 | 187 | } |
| 188 | 188 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | |
| 197 | 197 | $backtrace = debug_backtrace(); |
| 198 | 198 | |
| 199 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_user_login', $backtrace ); |
|
| 199 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_user_login', $backtrace); |
|
| 200 | 200 | |
| 201 | 201 | // Call new renamed function. |
| 202 | 202 | give_donation_form_validate_user_login(); |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | |
| 214 | 214 | $backtrace = debug_backtrace(); |
| 215 | 215 | |
| 216 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_guest_user', $backtrace ); |
|
| 216 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_guest_user', $backtrace); |
|
| 217 | 217 | |
| 218 | 218 | // Call new renamed function. |
| 219 | 219 | give_donation_form_validate_guest_user(); |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | |
| 231 | 231 | $backtrace = debug_backtrace(); |
| 232 | 232 | |
| 233 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_new_user', $backtrace ); |
|
| 233 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_new_user', $backtrace); |
|
| 234 | 234 | |
| 235 | 235 | // Call new renamed function. |
| 236 | 236 | give_donation_form_validate_new_user(); |
@@ -246,14 +246,14 @@ discard block |
||
| 246 | 246 | * |
| 247 | 247 | * @param array $valid_data |
| 248 | 248 | */ |
| 249 | -function give_get_purchase_form_user( $valid_data = array() ) { |
|
| 249 | +function give_get_purchase_form_user($valid_data = array()) { |
|
| 250 | 250 | |
| 251 | 251 | $backtrace = debug_backtrace(); |
| 252 | 252 | |
| 253 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_get_donation_form_user', $backtrace ); |
|
| 253 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_get_donation_form_user', $backtrace); |
|
| 254 | 254 | |
| 255 | 255 | // Call new renamed function. |
| 256 | - give_get_donation_form_user( $valid_data ); |
|
| 256 | + give_get_donation_form_user($valid_data); |
|
| 257 | 257 | |
| 258 | 258 | } |
| 259 | 259 | |
@@ -269,12 +269,12 @@ discard block |
||
| 269 | 269 | * |
| 270 | 270 | * @return string |
| 271 | 271 | */ |
| 272 | -function give_checkout_button_purchase( $form_id ) { |
|
| 272 | +function give_checkout_button_purchase($form_id) { |
|
| 273 | 273 | $backtrace = debug_backtrace(); |
| 274 | 274 | |
| 275 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_get_donation_form_submit_button', $backtrace ); |
|
| 275 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_get_donation_form_submit_button', $backtrace); |
|
| 276 | 276 | |
| 277 | - return give_get_donation_form_submit_button( $form_id ); |
|
| 277 | + return give_get_donation_form_submit_button($form_id); |
|
| 278 | 278 | |
| 279 | 279 | } |
| 280 | 280 | |
@@ -287,13 +287,13 @@ discard block |
||
| 287 | 287 | * |
| 288 | 288 | * @return int $customer_id Customer ID. |
| 289 | 289 | */ |
| 290 | -function give_get_payment_customer_id( $payment_id ) { |
|
| 290 | +function give_get_payment_customer_id($payment_id) { |
|
| 291 | 291 | |
| 292 | 292 | $backtrace = debug_backtrace(); |
| 293 | 293 | |
| 294 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_get_payment_donor_id', $backtrace ); |
|
| 294 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_get_payment_donor_id', $backtrace); |
|
| 295 | 295 | |
| 296 | - return give_get_payment_donor_id( $payment_id ); |
|
| 296 | + return give_get_payment_donor_id($payment_id); |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | |
| 309 | 309 | $backtrace = debug_backtrace(); |
| 310 | 310 | |
| 311 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_get_total_donations', $backtrace ); |
|
| 311 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_get_total_donations', $backtrace); |
|
| 312 | 312 | |
| 313 | 313 | return give_get_total_donations(); |
| 314 | 314 | } |
@@ -326,13 +326,13 @@ discard block |
||
| 326 | 326 | * |
| 327 | 327 | * @return int The total number of donations |
| 328 | 328 | */ |
| 329 | -function give_count_purchases_of_customer( $user = null ) { |
|
| 329 | +function give_count_purchases_of_customer($user = null) { |
|
| 330 | 330 | |
| 331 | 331 | $backtrace = debug_backtrace(); |
| 332 | 332 | |
| 333 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_count_donations_of_donor', $backtrace ); |
|
| 333 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_count_donations_of_donor', $backtrace); |
|
| 334 | 334 | |
| 335 | - return give_count_donations_of_donor( $user ); |
|
| 335 | + return give_count_donations_of_donor($user); |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | |
@@ -348,13 +348,13 @@ discard block |
||
| 348 | 348 | * |
| 349 | 349 | * @return array |
| 350 | 350 | */ |
| 351 | -function give_get_purchase_stats_by_user( $user = '' ) { |
|
| 351 | +function give_get_purchase_stats_by_user($user = '') { |
|
| 352 | 352 | |
| 353 | 353 | $backtrace = debug_backtrace(); |
| 354 | 354 | |
| 355 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_get_donation_stats_by_user', $backtrace ); |
|
| 355 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_get_donation_stats_by_user', $backtrace); |
|
| 356 | 356 | |
| 357 | - return give_get_donation_stats_by_user( $user ); |
|
| 357 | + return give_get_donation_stats_by_user($user); |
|
| 358 | 358 | |
| 359 | 359 | } |
| 360 | 360 | |
@@ -372,13 +372,13 @@ discard block |
||
| 372 | 372 | * |
| 373 | 373 | * @return bool|object List of all user donations |
| 374 | 374 | */ |
| 375 | -function give_get_users_purchases( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) { |
|
| 375 | +function give_get_users_purchases($user = 0, $number = 20, $pagination = false, $status = 'complete') { |
|
| 376 | 376 | |
| 377 | 377 | $backtrace = debug_backtrace(); |
| 378 | 378 | |
| 379 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_get_users_donations', $backtrace ); |
|
| 379 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_get_users_donations', $backtrace); |
|
| 380 | 380 | |
| 381 | - return give_get_users_donations( $user, $number, $pagination, $status ); |
|
| 381 | + return give_get_users_donations($user, $number, $pagination, $status); |
|
| 382 | 382 | |
| 383 | 383 | } |
| 384 | 384 | |
@@ -395,13 +395,13 @@ discard block |
||
| 395 | 395 | * |
| 396 | 396 | * @return bool True if has donated, false other wise. |
| 397 | 397 | */ |
| 398 | -function give_has_purchases( $user_id = null ) { |
|
| 398 | +function give_has_purchases($user_id = null) { |
|
| 399 | 399 | |
| 400 | 400 | $backtrace = debug_backtrace(); |
| 401 | 401 | |
| 402 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_has_donations', $backtrace ); |
|
| 402 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_has_donations', $backtrace); |
|
| 403 | 403 | |
| 404 | - return give_has_donations( $user_id ); |
|
| 404 | + return give_has_donations($user_id); |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | /** |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | function give_count_total_customers() { |
| 416 | 416 | $backtrace = debug_backtrace(); |
| 417 | 417 | |
| 418 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_count_total_donors', $backtrace ); |
|
| 418 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_count_total_donors', $backtrace); |
|
| 419 | 419 | |
| 420 | 420 | return give_count_total_donors(); |
| 421 | 421 | } |
@@ -430,13 +430,13 @@ discard block |
||
| 430 | 430 | * |
| 431 | 431 | * @return float The total amount the user has spent |
| 432 | 432 | */ |
| 433 | -function give_purchase_total_of_user( $user = null ) { |
|
| 433 | +function give_purchase_total_of_user($user = null) { |
|
| 434 | 434 | |
| 435 | 435 | $backtrace = debug_backtrace(); |
| 436 | 436 | |
| 437 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_donation_total_of_user', $backtrace ); |
|
| 437 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_donation_total_of_user', $backtrace); |
|
| 438 | 438 | |
| 439 | - return give_donation_total_of_user( $user ); |
|
| 439 | + return give_donation_total_of_user($user); |
|
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | /** |
@@ -450,13 +450,13 @@ discard block |
||
| 450 | 450 | * |
| 451 | 451 | * @return void |
| 452 | 452 | */ |
| 453 | -function give_delete_purchase( $payment_id = 0, $update_customer = true ) { |
|
| 453 | +function give_delete_purchase($payment_id = 0, $update_customer = true) { |
|
| 454 | 454 | |
| 455 | 455 | $backtrace = debug_backtrace(); |
| 456 | 456 | |
| 457 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_delete_donation', $backtrace ); |
|
| 457 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_delete_donation', $backtrace); |
|
| 458 | 458 | |
| 459 | - give_delete_donation( $payment_id, $update_customer ); |
|
| 459 | + give_delete_donation($payment_id, $update_customer); |
|
| 460 | 460 | |
| 461 | 461 | } |
| 462 | 462 | |
@@ -474,13 +474,13 @@ discard block |
||
| 474 | 474 | * |
| 475 | 475 | * @return void |
| 476 | 476 | */ |
| 477 | -function give_undo_purchase( $form_id = false, $payment_id ) { |
|
| 477 | +function give_undo_purchase($form_id = false, $payment_id) { |
|
| 478 | 478 | |
| 479 | 479 | $backtrace = debug_backtrace(); |
| 480 | 480 | |
| 481 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_undo_donation', $backtrace ); |
|
| 481 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_undo_donation', $backtrace); |
|
| 482 | 482 | |
| 483 | - give_undo_donation( $payment_id ); |
|
| 483 | + give_undo_donation($payment_id); |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | |
@@ -493,12 +493,12 @@ discard block |
||
| 493 | 493 | * |
| 494 | 494 | * @return void |
| 495 | 495 | */ |
| 496 | -function give_trigger_purchase_delete( $data ) { |
|
| 496 | +function give_trigger_purchase_delete($data) { |
|
| 497 | 497 | $backtrace = debug_backtrace(); |
| 498 | 498 | |
| 499 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_trigger_donation_delete', $backtrace ); |
|
| 499 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_trigger_donation_delete', $backtrace); |
|
| 500 | 500 | |
| 501 | - give_trigger_donation_delete( $data ); |
|
| 501 | + give_trigger_donation_delete($data); |
|
| 502 | 502 | } |
| 503 | 503 | |
| 504 | 504 | |
@@ -512,12 +512,12 @@ discard block |
||
| 512 | 512 | * |
| 513 | 513 | * @return bool|int |
| 514 | 514 | */ |
| 515 | -function give_increase_purchase_count( $form_id = 0, $quantity = 1 ) { |
|
| 515 | +function give_increase_purchase_count($form_id = 0, $quantity = 1) { |
|
| 516 | 516 | $backtrace = debug_backtrace(); |
| 517 | 517 | |
| 518 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_increase_donation_count', $backtrace ); |
|
| 518 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_increase_donation_count', $backtrace); |
|
| 519 | 519 | |
| 520 | - give_increase_donation_count( $form_id, $quantity ); |
|
| 520 | + give_increase_donation_count($form_id, $quantity); |
|
| 521 | 521 | } |
| 522 | 522 | |
| 523 | 523 | |
@@ -536,12 +536,12 @@ discard block |
||
| 536 | 536 | * |
| 537 | 537 | * @return void |
| 538 | 538 | */ |
| 539 | -function give_record_sale_in_log( $give_form_id = 0, $payment_id, $price_id = false, $sale_date = null ) { |
|
| 539 | +function give_record_sale_in_log($give_form_id = 0, $payment_id, $price_id = false, $sale_date = null) { |
|
| 540 | 540 | $backtrace = debug_backtrace(); |
| 541 | 541 | |
| 542 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_record_donation_in_log', $backtrace ); |
|
| 542 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_record_donation_in_log', $backtrace); |
|
| 543 | 543 | |
| 544 | - give_record_donation_in_log( $give_form_id, $payment_id, $price_id, $sale_date ); |
|
| 544 | + give_record_donation_in_log($give_form_id, $payment_id, $price_id, $sale_date); |
|
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | /** |
@@ -558,12 +558,12 @@ discard block |
||
| 558 | 558 | * |
| 559 | 559 | * @return void |
| 560 | 560 | */ |
| 561 | -function give_print_errors( $form_id ) { |
|
| 561 | +function give_print_errors($form_id) { |
|
| 562 | 562 | $backtrace = debug_backtrace(); |
| 563 | 563 | |
| 564 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'Give_Notice::print_frontend_errors', $backtrace ); |
|
| 564 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'Give_Notice::print_frontend_errors', $backtrace); |
|
| 565 | 565 | |
| 566 | - do_action( 'give_frontend_notices', $form_id ); |
|
| 566 | + do_action('give_frontend_notices', $form_id); |
|
| 567 | 567 | } |
| 568 | 568 | |
| 569 | 569 | /** |
@@ -579,12 +579,12 @@ discard block |
||
| 579 | 579 | * |
| 580 | 580 | * @return string $error |
| 581 | 581 | */ |
| 582 | -function give_output_error( $message, $echo = true, $error_id = 'warning' ) { |
|
| 582 | +function give_output_error($message, $echo = true, $error_id = 'warning') { |
|
| 583 | 583 | $backtrace = debug_backtrace(); |
| 584 | 584 | |
| 585 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'Give_Notice::print_frontend_notice', $backtrace ); |
|
| 585 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'Give_Notice::print_frontend_notice', $backtrace); |
|
| 586 | 586 | |
| 587 | - Give()->notices->print_frontend_notice( $message, $echo, $error_id ); |
|
| 587 | + Give()->notices->print_frontend_notice($message, $echo, $error_id); |
|
| 588 | 588 | } |
| 589 | 589 | |
| 590 | 590 | |
@@ -600,11 +600,11 @@ discard block |
||
| 600 | 600 | * |
| 601 | 601 | * @return string |
| 602 | 602 | */ |
| 603 | -function give_get_purchase_summary( $purchase_data, $email = true ) { |
|
| 603 | +function give_get_purchase_summary($purchase_data, $email = true) { |
|
| 604 | 604 | |
| 605 | 605 | $backtrace = debug_backtrace(); |
| 606 | 606 | |
| 607 | - _give_deprecated_function( __FUNCTION__, '1.8.12', 'give_payment_gateway_donation_summary', $backtrace ); |
|
| 607 | + _give_deprecated_function(__FUNCTION__, '1.8.12', 'give_payment_gateway_donation_summary', $backtrace); |
|
| 608 | 608 | |
| 609 | 609 | give_payment_gateway_donation_summary($purchase_data, $email); |
| 610 | 610 | |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | * Return the calculated completion percentage. |
| 217 | 217 | * |
| 218 | 218 | * @since 1.8.12 |
| 219 | - * @return int |
|
| 219 | + * @return double |
|
| 220 | 220 | */ |
| 221 | 221 | public function get_percentage_complete() { |
| 222 | 222 | return ceil( ( 100 * $this->step_completed ) / $this->total_step ); |
@@ -353,6 +353,9 @@ discard block |
||
| 353 | 353 | return true; |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | + /** |
|
| 357 | + * @param integer $page |
|
| 358 | + */ |
|
| 356 | 359 | public function get_delete_ids( $donation_ids, $page ) { |
| 357 | 360 | $index = $page --; |
| 358 | 361 | $count = count( $donation_ids ); |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly. |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -109,32 +109,32 @@ discard block |
||
| 109 | 109 | $donor_ids = array(); |
| 110 | 110 | |
| 111 | 111 | // Check if the ajax request if running for the first time. |
| 112 | - if ( 1 === (int) $this->step ) { |
|
| 112 | + if (1 === (int) $this->step) { |
|
| 113 | 113 | // Delete all the donation ids. |
| 114 | - $this->delete_option( $this->donation_key ); |
|
| 114 | + $this->delete_option($this->donation_key); |
|
| 115 | 115 | // Delete all the donor ids. |
| 116 | - $this->delete_option( $this->donor_key ); |
|
| 116 | + $this->delete_option($this->donor_key); |
|
| 117 | 117 | |
| 118 | 118 | // Delete all the step and set to 'count' which if the first step in the process of deleting the donors. |
| 119 | - $this->update_option( $this->step_key, 'count' ); |
|
| 119 | + $this->update_option($this->step_key, 'count'); |
|
| 120 | 120 | |
| 121 | 121 | // Delete tha page count of the step. |
| 122 | - $this->update_option( $this->step_on_key, '0' ); |
|
| 122 | + $this->update_option($this->step_on_key, '0'); |
|
| 123 | 123 | } else { |
| 124 | 124 | // Get the old donors list. |
| 125 | - $donor_ids = $this->get_option( $this->donor_key ); |
|
| 125 | + $donor_ids = $this->get_option($this->donor_key); |
|
| 126 | 126 | |
| 127 | 127 | // Get the old donation list. |
| 128 | - $donation_ids = $this->get_option( $this->donation_key ); |
|
| 128 | + $donation_ids = $this->get_option($this->donation_key); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | // Get the step and check for it if it's on the first step( 'count' ) or not. |
| 132 | 132 | $step = (int) $this->get_step(); |
| 133 | - if ( 1 === $step ) { |
|
| 133 | + if (1 === $step) { |
|
| 134 | 134 | /** |
| 135 | 135 | * Will add or update the donation and donor data by running wp query. |
| 136 | 136 | */ |
| 137 | - $this->count( $step, $donation_ids, $donor_ids ); |
|
| 137 | + $this->count($step, $donation_ids, $donor_ids); |
|
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
@@ -145,17 +145,17 @@ discard block |
||
| 145 | 145 | * @param array $donation_ids Contain the list of all the donation id's that has being add before this |
| 146 | 146 | * @param array $donor_ids Contain the list of all the donors id's that has being add before this |
| 147 | 147 | */ |
| 148 | - private function count( $step, $donation_ids = array(), $donor_ids = array() ) { |
|
| 148 | + private function count($step, $donation_ids = array(), $donor_ids = array()) { |
|
| 149 | 149 | |
| 150 | 150 | // Get the Page count by default it's zero. |
| 151 | 151 | $paged = (int) $this->get_step_page(); |
| 152 | 152 | // Incresed the page count by one. |
| 153 | - ++ $paged; |
|
| 153 | + ++$paged; |
|
| 154 | 154 | |
| 155 | 155 | /** |
| 156 | 156 | * Filter add to alter the argument before the wp quest run |
| 157 | 157 | */ |
| 158 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
| 158 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
| 159 | 159 | 'post_type' => 'give_payment', |
| 160 | 160 | 'post_status' => 'any', |
| 161 | 161 | 'posts_per_page' => $this->per_step, |
@@ -163,16 +163,16 @@ discard block |
||
| 163 | 163 | // ONLY TEST MODE TRANSACTIONS!!! |
| 164 | 164 | 'meta_key' => '_give_payment_mode', |
| 165 | 165 | 'meta_value' => 'test' |
| 166 | - ) ); |
|
| 166 | + )); |
|
| 167 | 167 | |
| 168 | 168 | // Reset the post data. |
| 169 | 169 | wp_reset_postdata(); |
| 170 | 170 | // Getting the new donation. |
| 171 | - $donation_posts = new WP_Query( $args ); |
|
| 171 | + $donation_posts = new WP_Query($args); |
|
| 172 | 172 | |
| 173 | 173 | // The Loop. |
| 174 | - if ( $donation_posts->have_posts() ) { |
|
| 175 | - while ( $donation_posts->have_posts() ) { |
|
| 174 | + if ($donation_posts->have_posts()) { |
|
| 175 | + while ($donation_posts->have_posts()) { |
|
| 176 | 176 | $donation_posts->the_post(); |
| 177 | 177 | global $post; |
| 178 | 178 | // Add the donation id in side the array. |
@@ -191,23 +191,23 @@ discard block |
||
| 191 | 191 | $max_num_pages = (int) $donation_posts->max_num_pages; |
| 192 | 192 | |
| 193 | 193 | // Check current page is less then max number of page or not |
| 194 | - if ( $paged < $max_num_pages ) { |
|
| 194 | + if ($paged < $max_num_pages) { |
|
| 195 | 195 | // Update the curretn page virable for the next step |
| 196 | - $this->update_option( $this->step_on_key, $paged ); |
|
| 196 | + $this->update_option($this->step_on_key, $paged); |
|
| 197 | 197 | |
| 198 | 198 | // Calculating percentage. |
| 199 | 199 | $page_remain = $max_num_pages - $paged; |
| 200 | - $this->total_step = (int) $max_num_pages + ( $total_donation / $this->per_step ) + ( ( $page_remain * 2 ) * count( $donor_ids ) ); |
|
| 200 | + $this->total_step = (int) $max_num_pages + ($total_donation / $this->per_step) + (($page_remain * 2) * count($donor_ids)); |
|
| 201 | 201 | $this->step_completed = $paged; |
| 202 | 202 | } else { |
| 203 | - $donation_ids_count = count( $donor_ids ); |
|
| 204 | - $this->update_option( $this->step_key, 'donation' ); |
|
| 205 | - $this->update_option( $this->step_on_key, '0' ); |
|
| 203 | + $donation_ids_count = count($donor_ids); |
|
| 204 | + $this->update_option($this->step_key, 'donation'); |
|
| 205 | + $this->update_option($this->step_on_key, '0'); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - $donor_ids = array_unique( $donor_ids ); |
|
| 209 | - $this->update_option( $this->donor_key, $donor_ids ); |
|
| 210 | - $this->update_option( $this->donation_key, $donation_ids ); |
|
| 208 | + $donor_ids = array_unique($donor_ids); |
|
| 209 | + $this->update_option($this->donor_key, $donor_ids); |
|
| 210 | + $this->update_option($this->donation_key, $donation_ids); |
|
| 211 | 211 | |
| 212 | 212 | wp_reset_postdata(); |
| 213 | 213 | } |
@@ -219,34 +219,34 @@ discard block |
||
| 219 | 219 | * @return int |
| 220 | 220 | */ |
| 221 | 221 | public function get_percentage_complete() { |
| 222 | - return ceil( ( 100 * $this->step_completed ) / $this->total_step ); |
|
| 222 | + return ceil((100 * $this->step_completed) / $this->total_step); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | public function process_step() { |
| 226 | 226 | |
| 227 | - if ( ! $this->can_export() ) { |
|
| 228 | - wp_die( __( 'You do not have permission to delete test transactions.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 227 | + if ( ! $this->can_export()) { |
|
| 228 | + wp_die(__('You do not have permission to delete test transactions.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | $had_data = $this->get_data(); |
| 232 | 232 | |
| 233 | - if ( $had_data ) { |
|
| 233 | + if ($had_data) { |
|
| 234 | 234 | $this->done = false; |
| 235 | 235 | |
| 236 | 236 | return true; |
| 237 | 237 | } else { |
| 238 | - update_option( 'give_earnings_total', give_get_total_earnings( true ) ); |
|
| 239 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
| 238 | + update_option('give_earnings_total', give_get_total_earnings(true)); |
|
| 239 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
| 240 | 240 | |
| 241 | - $this->delete_option( $this->donation_key ); |
|
| 241 | + $this->delete_option($this->donation_key); |
|
| 242 | 242 | |
| 243 | 243 | // Reset the sequential order numbers |
| 244 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
| 245 | - delete_option( 'give_last_payment_number' ); |
|
| 244 | + if (give_get_option('enable_sequential')) { |
|
| 245 | + delete_option('give_last_payment_number'); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | $this->done = true; |
| 249 | - $this->message = __( 'Test donor and transactions successfully deleted.', 'give' ); |
|
| 249 | + $this->message = __('Test donor and transactions successfully deleted.', 'give'); |
|
| 250 | 250 | |
| 251 | 251 | return false; |
| 252 | 252 | } |
@@ -264,12 +264,12 @@ discard block |
||
| 264 | 264 | public function get_data() { |
| 265 | 265 | |
| 266 | 266 | // Get the donation id's. |
| 267 | - $donation_ids = $this->get_option( $this->donation_key ); |
|
| 267 | + $donation_ids = $this->get_option($this->donation_key); |
|
| 268 | 268 | |
| 269 | 269 | /** |
| 270 | 270 | * Return false id not test donation is found. |
| 271 | 271 | */ |
| 272 | - if ( empty( $donation_ids ) ) { |
|
| 272 | + if (empty($donation_ids)) { |
|
| 273 | 273 | $this->is_empty = true; |
| 274 | 274 | $this->total_step = 1; |
| 275 | 275 | |
@@ -280,68 +280,68 @@ discard block |
||
| 280 | 280 | $step = (int) $this->get_step(); |
| 281 | 281 | |
| 282 | 282 | // get teh donor ids. |
| 283 | - $donor_ids = $this->get_option( $this->donor_key ); |
|
| 283 | + $donor_ids = $this->get_option($this->donor_key); |
|
| 284 | 284 | |
| 285 | 285 | // In step to we delete all the donation in loop. |
| 286 | - if ( 2 === $step ) { |
|
| 286 | + if (2 === $step) { |
|
| 287 | 287 | $pass_to_donor = false; |
| 288 | 288 | $page = (int) $this->get_step_page(); |
| 289 | - $page ++; |
|
| 290 | - $count = count( $donation_ids ); |
|
| 289 | + $page++; |
|
| 290 | + $count = count($donation_ids); |
|
| 291 | 291 | |
| 292 | - $this->total_step = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids ); |
|
| 292 | + $this->total_step = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids); |
|
| 293 | 293 | $this->step_completed = $page; |
| 294 | 294 | |
| 295 | 295 | |
| 296 | - if ( $count > $this->per_step ) { |
|
| 296 | + if ($count > $this->per_step) { |
|
| 297 | 297 | |
| 298 | - $this->update_option( $this->step_on_key, $page ); |
|
| 299 | - $donation_ids = $this->get_delete_ids( $donation_ids, $page ); |
|
| 300 | - $current_page = (int) ceil( $count / $this->per_step ); |
|
| 298 | + $this->update_option($this->step_on_key, $page); |
|
| 299 | + $donation_ids = $this->get_delete_ids($donation_ids, $page); |
|
| 300 | + $current_page = (int) ceil($count / $this->per_step); |
|
| 301 | 301 | |
| 302 | - if ( $page === $current_page ) { |
|
| 302 | + if ($page === $current_page) { |
|
| 303 | 303 | $pass_to_donor = true; |
| 304 | 304 | } |
| 305 | 305 | } else { |
| 306 | 306 | $pass_to_donor = true; |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | - if ( true === $pass_to_donor ) { |
|
| 310 | - $this->update_option( $this->step_key, 'donor' ); |
|
| 311 | - $this->update_option( $this->step_on_key, '0' ); |
|
| 309 | + if (true === $pass_to_donor) { |
|
| 310 | + $this->update_option($this->step_key, 'donor'); |
|
| 311 | + $this->update_option($this->step_on_key, '0'); |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - foreach ( $donation_ids as $item ) { |
|
| 315 | - wp_delete_post( $item, true ); |
|
| 314 | + foreach ($donation_ids as $item) { |
|
| 315 | + wp_delete_post($item, true); |
|
| 316 | 316 | } |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | |
| 320 | 320 | // Here we delete all the donor |
| 321 | - if ( 3 === $step ) { |
|
| 321 | + if (3 === $step) { |
|
| 322 | 322 | $page = (int) $this->get_step_page(); |
| 323 | - $count = count( $donor_ids ); |
|
| 323 | + $count = count($donor_ids); |
|
| 324 | 324 | |
| 325 | - $this->total_step = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids ); |
|
| 326 | - $this->step_completed = $page + ( count( $donation_ids ) / $this->per_step ); |
|
| 325 | + $this->total_step = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids); |
|
| 326 | + $this->step_completed = $page + (count($donation_ids) / $this->per_step); |
|
| 327 | 327 | |
| 328 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
| 328 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
| 329 | 329 | 'post_type' => 'give_payment', |
| 330 | 330 | 'post_status' => 'any', |
| 331 | 331 | 'posts_per_page' => 1, |
| 332 | 332 | 'meta_key' => '_give_payment_mode', |
| 333 | 333 | 'meta_value' => 'live', |
| 334 | - 'author' => $donor_ids[ $page ] |
|
| 335 | - ) ); |
|
| 334 | + 'author' => $donor_ids[$page] |
|
| 335 | + )); |
|
| 336 | 336 | |
| 337 | - $donation_posts = get_posts( $args ); |
|
| 338 | - if ( empty( $donation_posts ) ) { |
|
| 339 | - Give()->donors->delete_by_user_id( $donor_ids[ $page ] ); |
|
| 337 | + $donation_posts = get_posts($args); |
|
| 338 | + if (empty($donation_posts)) { |
|
| 339 | + Give()->donors->delete_by_user_id($donor_ids[$page]); |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - $page ++; |
|
| 343 | - $this->update_option( $this->step_on_key, $page ); |
|
| 344 | - if ( $count === $page ) { |
|
| 342 | + $page++; |
|
| 343 | + $this->update_option($this->step_on_key, $page); |
|
| 344 | + if ($count === $page) { |
|
| 345 | 345 | $this->is_empty = false; |
| 346 | 346 | |
| 347 | 347 | return false; |
@@ -353,24 +353,24 @@ discard block |
||
| 353 | 353 | return true; |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - public function get_delete_ids( $donation_ids, $page ) { |
|
| 357 | - $index = $page --; |
|
| 358 | - $count = count( $donation_ids ); |
|
| 356 | + public function get_delete_ids($donation_ids, $page) { |
|
| 357 | + $index = $page--; |
|
| 358 | + $count = count($donation_ids); |
|
| 359 | 359 | $temp = 0; |
| 360 | 360 | $current_page = 0; |
| 361 | 361 | $post_delete = $this->per_step; |
| 362 | 362 | $page_donation_id = array(); |
| 363 | 363 | |
| 364 | - foreach ( $donation_ids as $item ) { |
|
| 365 | - $temp ++; |
|
| 366 | - $page_donation_id[ $current_page ][] = $item; |
|
| 367 | - if ( $temp === $post_delete ) { |
|
| 368 | - $current_page ++; |
|
| 364 | + foreach ($donation_ids as $item) { |
|
| 365 | + $temp++; |
|
| 366 | + $page_donation_id[$current_page][] = $item; |
|
| 367 | + if ($temp === $post_delete) { |
|
| 368 | + $current_page++; |
|
| 369 | 369 | $temp = 0; |
| 370 | 370 | } |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - return $page_donation_id[ $page ]; |
|
| 373 | + return $page_donation_id[$page]; |
|
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | /** |
@@ -382,8 +382,8 @@ discard block |
||
| 382 | 382 | * |
| 383 | 383 | * @return mixed Returns the data from the database |
| 384 | 384 | */ |
| 385 | - public function get_option( $key, $defalut_value = false ) { |
|
| 386 | - return get_option( $key, $defalut_value ); |
|
| 385 | + public function get_option($key, $defalut_value = false) { |
|
| 386 | + return get_option($key, $defalut_value); |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | /** |
@@ -396,8 +396,8 @@ discard block |
||
| 396 | 396 | * |
| 397 | 397 | * @return void |
| 398 | 398 | */ |
| 399 | - public function update_option( $key, $value ) { |
|
| 400 | - update_option( $key, $value, false ); |
|
| 399 | + public function update_option($key, $value) { |
|
| 400 | + update_option($key, $value, false); |
|
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | /** |
@@ -409,8 +409,8 @@ discard block |
||
| 409 | 409 | * |
| 410 | 410 | * @return void |
| 411 | 411 | */ |
| 412 | - public function delete_option( $key ) { |
|
| 413 | - delete_option( $key ); |
|
| 412 | + public function delete_option($key) { |
|
| 413 | + delete_option($key); |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | /** |
@@ -421,12 +421,12 @@ discard block |
||
| 421 | 421 | * @return int|string |
| 422 | 422 | */ |
| 423 | 423 | private function get_step() { |
| 424 | - $step_key = (string) $this->get_option( $this->step_key, false ); |
|
| 425 | - if ( 'count' === $step_key ) { |
|
| 424 | + $step_key = (string) $this->get_option($this->step_key, false); |
|
| 425 | + if ('count' === $step_key) { |
|
| 426 | 426 | return 1; |
| 427 | - } elseif ( 'donation' === $step_key ) { |
|
| 427 | + } elseif ('donation' === $step_key) { |
|
| 428 | 428 | return 2; |
| 429 | - } elseif ( 'donor' === $step_key ) { |
|
| 429 | + } elseif ('donor' === $step_key) { |
|
| 430 | 430 | return 3; |
| 431 | 431 | } else { |
| 432 | 432 | return $step_key; |
@@ -437,6 +437,6 @@ discard block |
||
| 437 | 437 | * Get the current $page value in the ajax. |
| 438 | 438 | */ |
| 439 | 439 | private function get_step_page() { |
| 440 | - return $this->get_option( $this->step_on_key, false ); |
|
| 440 | + return $this->get_option($this->step_on_key, false); |
|
| 441 | 441 | } |
| 442 | 442 | } |
@@ -340,7 +340,7 @@ |
||
| 340 | 340 | * @since 1.0 |
| 341 | 341 | * |
| 342 | 342 | * @param int|float|string $amount Formatted or sanitized price |
| 343 | - * @param int|bool $dp number of decimals |
|
| 343 | + * @param boolean $dp number of decimals |
|
| 344 | 344 | * @param bool $sanitize Whether or not sanitize number |
| 345 | 345 | * |
| 346 | 346 | * @return string $amount Newly formatted amount or Price Not Available |
@@ -96,7 +96,7 @@ |
||
| 96 | 96 | // Bailout. |
| 97 | 97 | if( empty( $number ) || ( ! is_numeric( $number ) && ! is_string( $number ) ) ) { |
| 98 | 98 | return $number; |
| 99 | - }elseif ( |
|
| 99 | + } elseif ( |
|
| 100 | 100 | ( false == strpos( $number, $thousand_separator ) ) && |
| 101 | 101 | ( false === strpos( $number, $decimal_separator ) ) |
| 102 | 102 | ) { |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * @return mixed |
| 24 | 24 | */ |
| 25 | 25 | function give_get_price_decimals() { |
| 26 | - return apply_filters( 'give_sanitize_amount_decimals', give_get_option( 'number_decimals', 0 ) ); |
|
| 26 | + return apply_filters('give_sanitize_amount_decimals', give_get_option('number_decimals', 0)); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -35,8 +35,8 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | function give_get_price_thousand_separator() { |
| 37 | 37 | $give_options = give_get_settings(); |
| 38 | - $thousand_separator = isset( $give_options['thousands_separator'] ) ? $give_options['thousands_separator'] : ','; |
|
| 39 | - $thousand_separator = empty( $thousand_separator ) ? ' ' : $thousand_separator; |
|
| 38 | + $thousand_separator = isset($give_options['thousands_separator']) ? $give_options['thousands_separator'] : ','; |
|
| 39 | + $thousand_separator = empty($thousand_separator) ? ' ' : $thousand_separator; |
|
| 40 | 40 | |
| 41 | 41 | return $thousand_separator; |
| 42 | 42 | } |
@@ -55,11 +55,10 @@ discard block |
||
| 55 | 55 | ); |
| 56 | 56 | |
| 57 | 57 | $thousand_separator = give_get_price_thousand_separator(); |
| 58 | - $default_decimal_separator = in_array( $thousand_separator, $default_decimal_separators ) ? |
|
| 59 | - $default_decimal_separators[$thousand_separator] : |
|
| 60 | - '.'; |
|
| 58 | + $default_decimal_separator = in_array($thousand_separator, $default_decimal_separators) ? |
|
| 59 | + $default_decimal_separators[$thousand_separator] : '.'; |
|
| 61 | 60 | |
| 62 | - $decimal_separator = give_get_option( 'decimal_separator', $default_decimal_separator ); |
|
| 61 | + $decimal_separator = give_get_option('decimal_separator', $default_decimal_separator); |
|
| 63 | 62 | |
| 64 | 63 | return $decimal_separator; |
| 65 | 64 | } |
@@ -74,8 +73,8 @@ discard block |
||
| 74 | 73 | * |
| 75 | 74 | * @return string $amount Newly sanitized amount |
| 76 | 75 | */ |
| 77 | -function give_sanitize_amount_for_db( $number ) { |
|
| 78 | - return give_sanitize_amount( $number, 6 ); |
|
| 76 | +function give_sanitize_amount_for_db($number) { |
|
| 77 | + return give_sanitize_amount($number, 6); |
|
| 79 | 78 | } |
| 80 | 79 | |
| 81 | 80 | /** |
@@ -89,40 +88,40 @@ discard block |
||
| 89 | 88 | * |
| 90 | 89 | * @return string $amount Newly sanitized amount |
| 91 | 90 | */ |
| 92 | -function give_maybe_sanitize_amount( $number, $dp = false, $trim_zeros = false ) { |
|
| 91 | +function give_maybe_sanitize_amount($number, $dp = false, $trim_zeros = false) { |
|
| 93 | 92 | $thousand_separator = give_get_price_thousand_separator(); |
| 94 | 93 | $decimal_separator = give_get_price_decimal_separator(); |
| 95 | 94 | |
| 96 | 95 | // Bailout. |
| 97 | - if( empty( $number ) || ( ! is_numeric( $number ) && ! is_string( $number ) ) ) { |
|
| 96 | + if (empty($number) || ( ! is_numeric($number) && ! is_string($number))) { |
|
| 98 | 97 | return $number; |
| 99 | 98 | }elseif ( |
| 100 | - ( false == strpos( $number, $thousand_separator ) ) && |
|
| 101 | - ( false === strpos( $number, $decimal_separator ) ) |
|
| 99 | + (false == strpos($number, $thousand_separator)) && |
|
| 100 | + (false === strpos($number, $decimal_separator)) |
|
| 102 | 101 | ) { |
| 103 | - return number_format( $number, ( is_bool( $dp ) ? give_get_price_decimals() : $dp ), '.', '' ); |
|
| 102 | + return number_format($number, (is_bool($dp) ? give_get_price_decimals() : $dp), '.', ''); |
|
| 104 | 103 | } |
| 105 | 104 | |
| 106 | 105 | // Handle thousand separator as '.' |
| 107 | 106 | // Handle sanitize database values. |
| 108 | - $number_parts = explode( '.', $number ); |
|
| 109 | - $is_db_sanitize_val = ( 2 === count( $number_parts ) && ( 6 === strlen( $number_parts[1] ) ) ); |
|
| 107 | + $number_parts = explode('.', $number); |
|
| 108 | + $is_db_sanitize_val = (2 === count($number_parts) && (6 === strlen($number_parts[1]))); |
|
| 110 | 109 | |
| 111 | - if( $is_db_sanitize_val ) { |
|
| 110 | + if ($is_db_sanitize_val) { |
|
| 112 | 111 | // Sanitize database value. |
| 113 | - return number_format( $number, ( is_bool( $dp ) ? give_get_price_decimals() : $dp ), '.', '' ); |
|
| 112 | + return number_format($number, (is_bool($dp) ? give_get_price_decimals() : $dp), '.', ''); |
|
| 114 | 113 | |
| 115 | 114 | } elseif ( |
| 116 | 115 | '.' === $thousand_separator && |
| 117 | - false !== strpos( $number, $thousand_separator ) |
|
| 118 | - ){ |
|
| 116 | + false !== strpos($number, $thousand_separator) |
|
| 117 | + ) { |
|
| 119 | 118 | // Fix point thousand separator value. |
| 120 | - if( ! $is_db_sanitize_val ) { |
|
| 121 | - $number = str_replace( '.', '', $number ); |
|
| 119 | + if ( ! $is_db_sanitize_val) { |
|
| 120 | + $number = str_replace('.', '', $number); |
|
| 122 | 121 | } |
| 123 | 122 | } |
| 124 | 123 | |
| 125 | - return give_sanitize_amount( $number, $dp, $trim_zeros ); |
|
| 124 | + return give_sanitize_amount($number, $dp, $trim_zeros); |
|
| 126 | 125 | } |
| 127 | 126 | |
| 128 | 127 | /** |
@@ -138,67 +137,67 @@ discard block |
||
| 138 | 137 | * |
| 139 | 138 | * @return string $amount Newly sanitized amount |
| 140 | 139 | */ |
| 141 | -function give_sanitize_amount( $number, $dp = false, $trim_zeros = false ) { |
|
| 140 | +function give_sanitize_amount($number, $dp = false, $trim_zeros = false) { |
|
| 142 | 141 | |
| 143 | 142 | // Bailout. |
| 144 | - if ( empty( $number ) || ( ! is_numeric( $number ) && ! is_string( $number ) ) ) { |
|
| 143 | + if (empty($number) || ( ! is_numeric($number) && ! is_string($number))) { |
|
| 145 | 144 | return $number; |
| 146 | 145 | } |
| 147 | 146 | |
| 148 | 147 | // Remove slash from amount. |
| 149 | 148 | // If thousand or decimal separator is set to ' then in $_POST or $_GET param we will get an escaped number. |
| 150 | 149 | // To prevent notices and warning remove slash from amount/number. |
| 151 | - $number = wp_unslash( $number ); |
|
| 150 | + $number = wp_unslash($number); |
|
| 152 | 151 | |
| 153 | 152 | $thousand_separator = give_get_price_thousand_separator(); |
| 154 | 153 | |
| 155 | 154 | $locale = localeconv(); |
| 156 | - $decimals = array( give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point'] ); |
|
| 155 | + $decimals = array(give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point']); |
|
| 157 | 156 | |
| 158 | 157 | // Remove locale from string |
| 159 | - if ( ! is_float( $number ) ) { |
|
| 160 | - $number = str_replace( $decimals, '.', $number ); |
|
| 158 | + if ( ! is_float($number)) { |
|
| 159 | + $number = str_replace($decimals, '.', $number); |
|
| 161 | 160 | } |
| 162 | 161 | |
| 163 | 162 | // Remove thousand amount formatting if amount has. |
| 164 | 163 | // This condition use to add backward compatibility to version before 1.6, because before version 1.6 we were saving formatted amount to db. |
| 165 | 164 | // Do not replace thousand separator from price if it is same as decimal separator, because it will be already replace by above code. |
| 166 | - if ( ! in_array( $thousand_separator, $decimals ) && ( false !== strpos( $number, $thousand_separator ) ) ) { |
|
| 167 | - $number = str_replace( $thousand_separator, '', $number ); |
|
| 168 | - } elseif ( in_array( $thousand_separator, $decimals ) ) { |
|
| 169 | - $number = preg_replace( '/\.(?=.*\.)/', '', $number ); |
|
| 165 | + if ( ! in_array($thousand_separator, $decimals) && (false !== strpos($number, $thousand_separator))) { |
|
| 166 | + $number = str_replace($thousand_separator, '', $number); |
|
| 167 | + } elseif (in_array($thousand_separator, $decimals)) { |
|
| 168 | + $number = preg_replace('/\.(?=.*\.)/', '', $number); |
|
| 170 | 169 | } |
| 171 | 170 | |
| 172 | 171 | // Remove non numeric entity before decimal separator. |
| 173 | - $number = preg_replace( '/[^0-9\.]/', '', $number ); |
|
| 172 | + $number = preg_replace('/[^0-9\.]/', '', $number); |
|
| 174 | 173 | $default_dp = give_get_price_decimals(); |
| 175 | 174 | |
| 176 | 175 | // Reset negative amount to zero. |
| 177 | - if ( 0 > $number ) { |
|
| 178 | - $number = number_format( 0, $default_dp, '.' ); |
|
| 176 | + if (0 > $number) { |
|
| 177 | + $number = number_format(0, $default_dp, '.'); |
|
| 179 | 178 | } |
| 180 | 179 | |
| 181 | 180 | // If number does not have decimal then add number of decimals to it. |
| 182 | 181 | if ( |
| 183 | - false === strpos( $number, '.' ) |
|
| 184 | - || ( $default_dp > strlen( substr( $number, strpos( $number, '.' ) + 1 ) ) ) |
|
| 182 | + false === strpos($number, '.') |
|
| 183 | + || ($default_dp > strlen(substr($number, strpos($number, '.') + 1))) |
|
| 185 | 184 | ) { |
| 186 | - $number = number_format( $number, $default_dp, '.', '' ); |
|
| 185 | + $number = number_format($number, $default_dp, '.', ''); |
|
| 187 | 186 | } |
| 188 | 187 | |
| 189 | 188 | // Format number by custom number of decimals. |
| 190 | - if ( false !== $dp ) { |
|
| 191 | - $dp = intval( is_bool( $dp ) ? $default_dp : $dp ); |
|
| 192 | - $dp = apply_filters( 'give_sanitize_amount_decimals', $dp, $number ); |
|
| 193 | - $number = number_format( floatval( $number ), $dp, '.', '' ); |
|
| 189 | + if (false !== $dp) { |
|
| 190 | + $dp = intval(is_bool($dp) ? $default_dp : $dp); |
|
| 191 | + $dp = apply_filters('give_sanitize_amount_decimals', $dp, $number); |
|
| 192 | + $number = number_format(floatval($number), $dp, '.', ''); |
|
| 194 | 193 | } |
| 195 | 194 | |
| 196 | 195 | // Trim zeros. |
| 197 | - if ( $trim_zeros && strstr( $number, '.' ) ) { |
|
| 198 | - $number = rtrim( rtrim( $number, '0' ), '.' ); |
|
| 196 | + if ($trim_zeros && strstr($number, '.')) { |
|
| 197 | + $number = rtrim(rtrim($number, '0'), '.'); |
|
| 199 | 198 | } |
| 200 | 199 | |
| 201 | - return apply_filters( 'give_sanitize_amount', $number ); |
|
| 200 | + return apply_filters('give_sanitize_amount', $number); |
|
| 202 | 201 | } |
| 203 | 202 | |
| 204 | 203 | /** |
@@ -211,10 +210,10 @@ discard block |
||
| 211 | 210 | * |
| 212 | 211 | * @return string $amount Newly formatted amount or Price Not Available |
| 213 | 212 | */ |
| 214 | -function give_format_amount( $amount, $args = array() ) { |
|
| 213 | +function give_format_amount($amount, $args = array()) { |
|
| 215 | 214 | // Backward compatibility. |
| 216 | - if( is_bool( $args ) ) { |
|
| 217 | - $args = array( 'decimal' => $args ); |
|
| 215 | + if (is_bool($args)) { |
|
| 216 | + $args = array('decimal' => $args); |
|
| 218 | 217 | } |
| 219 | 218 | |
| 220 | 219 | $default_args = array( |
@@ -223,60 +222,59 @@ discard block |
||
| 223 | 222 | 'currency' => give_get_currency(), |
| 224 | 223 | ); |
| 225 | 224 | |
| 226 | - $args = wp_parse_args( $args, $default_args ); |
|
| 225 | + $args = wp_parse_args($args, $default_args); |
|
| 227 | 226 | |
| 228 | 227 | $formatted = 0; |
| 229 | 228 | $thousands_sep = give_get_price_thousand_separator(); |
| 230 | 229 | $decimal_sep = give_get_price_decimal_separator(); |
| 231 | - $decimals = ! empty( $args['decimal'] ) ? give_get_price_decimals() : 0; |
|
| 230 | + $decimals = ! empty($args['decimal']) ? give_get_price_decimals() : 0; |
|
| 232 | 231 | $currency = $args['currency']; |
| 233 | 232 | |
| 234 | - if ( ! empty( $amount ) ) { |
|
| 233 | + if ( ! empty($amount)) { |
|
| 235 | 234 | // Sanitize amount before formatting. |
| 236 | - $amount = ! empty( $args['sanitize'] ) ? |
|
| 237 | - give_maybe_sanitize_amount( $amount, $decimals ) : |
|
| 238 | - number_format( $amount, $decimals, '.', '' ); |
|
| 235 | + $amount = ! empty($args['sanitize']) ? |
|
| 236 | + give_maybe_sanitize_amount($amount, $decimals) : number_format($amount, $decimals, '.', ''); |
|
| 239 | 237 | |
| 240 | - switch ( $currency ) { |
|
| 238 | + switch ($currency) { |
|
| 241 | 239 | case 'INR': |
| 242 | 240 | $decimal_amount = ''; |
| 243 | 241 | |
| 244 | 242 | // Extract decimals from amount |
| 245 | - if ( ( $pos = strpos( $amount, '.' ) ) !== false ) { |
|
| 246 | - if ( ! empty( $decimals ) ) { |
|
| 247 | - $decimal_amount = substr( round( substr( $amount, $pos ), $decimals ), 1 ); |
|
| 248 | - $amount = substr( $amount, 0, $pos ); |
|
| 249 | - |
|
| 250 | - if ( ! $decimal_amount ) { |
|
| 251 | - $decimal_amount = substr( '.0000000000', 0, ( $decimals + 1 ) ); |
|
| 252 | - } elseif ( ( $decimals + 1 ) > strlen( $decimal_amount ) ) { |
|
| 253 | - $decimal_amount = substr( "{$decimal_amount}000000000", 0, ( $decimals + 1 ) ); |
|
| 243 | + if (($pos = strpos($amount, '.')) !== false) { |
|
| 244 | + if ( ! empty($decimals)) { |
|
| 245 | + $decimal_amount = substr(round(substr($amount, $pos), $decimals), 1); |
|
| 246 | + $amount = substr($amount, 0, $pos); |
|
| 247 | + |
|
| 248 | + if ( ! $decimal_amount) { |
|
| 249 | + $decimal_amount = substr('.0000000000', 0, ($decimals + 1)); |
|
| 250 | + } elseif (($decimals + 1) > strlen($decimal_amount)) { |
|
| 251 | + $decimal_amount = substr("{$decimal_amount}000000000", 0, ($decimals + 1)); |
|
| 254 | 252 | } |
| 255 | 253 | |
| 256 | 254 | } else { |
| 257 | - $amount = number_format( $amount, $decimals, $decimal_sep, '' ); |
|
| 255 | + $amount = number_format($amount, $decimals, $decimal_sep, ''); |
|
| 258 | 256 | } |
| 259 | 257 | } |
| 260 | 258 | |
| 261 | 259 | // Extract last 3 from amount |
| 262 | - $result = substr( $amount, - 3 ); |
|
| 263 | - $amount = substr( $amount, 0, - 3 ); |
|
| 260 | + $result = substr($amount, - 3); |
|
| 261 | + $amount = substr($amount, 0, - 3); |
|
| 264 | 262 | |
| 265 | 263 | // Apply digits 2 by 2 |
| 266 | - while ( strlen( $amount ) > 0 ) { |
|
| 267 | - $result = substr( $amount, - 2 ) . $thousands_sep . $result; |
|
| 268 | - $amount = substr( $amount, 0, - 2 ); |
|
| 264 | + while (strlen($amount) > 0) { |
|
| 265 | + $result = substr($amount, - 2).$thousands_sep.$result; |
|
| 266 | + $amount = substr($amount, 0, - 2); |
|
| 269 | 267 | } |
| 270 | 268 | |
| 271 | - $formatted = $result . $decimal_amount; |
|
| 269 | + $formatted = $result.$decimal_amount; |
|
| 272 | 270 | break; |
| 273 | 271 | |
| 274 | 272 | default: |
| 275 | - $formatted = number_format( $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
| 273 | + $formatted = number_format($amount, $decimals, $decimal_sep, $thousands_sep); |
|
| 276 | 274 | } |
| 277 | 275 | } |
| 278 | 276 | |
| 279 | - return apply_filters( 'give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $currency, $args ); |
|
| 277 | + return apply_filters('give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $currency, $args); |
|
| 280 | 278 | } |
| 281 | 279 | |
| 282 | 280 | |
@@ -294,51 +292,51 @@ discard block |
||
| 294 | 292 | * |
| 295 | 293 | * @return float|string formatted amount number with large number names. |
| 296 | 294 | */ |
| 297 | -function give_human_format_large_amount( $amount, $args = array() ) { |
|
| 295 | +function give_human_format_large_amount($amount, $args = array()) { |
|
| 298 | 296 | $default_args = array( |
| 299 | 297 | 'currency' => give_get_currency(), |
| 300 | 298 | ); |
| 301 | 299 | |
| 302 | - $args = wp_parse_args( $args, $default_args ); |
|
| 300 | + $args = wp_parse_args($args, $default_args); |
|
| 303 | 301 | |
| 304 | 302 | // Get thousand separator. |
| 305 | 303 | $thousands_sep = give_get_price_thousand_separator(); |
| 306 | 304 | |
| 307 | 305 | // Sanitize amount. |
| 308 | - $sanitize_amount = give_maybe_sanitize_amount( $amount ); |
|
| 306 | + $sanitize_amount = give_maybe_sanitize_amount($amount); |
|
| 309 | 307 | |
| 310 | 308 | // Explode amount to calculate name of large numbers. |
| 311 | - $amount_array = explode( $thousands_sep, $amount ); |
|
| 309 | + $amount_array = explode($thousands_sep, $amount); |
|
| 312 | 310 | |
| 313 | 311 | // Calculate amount parts count. |
| 314 | - $amount_count_parts = count( $amount_array ); |
|
| 312 | + $amount_count_parts = count($amount_array); |
|
| 315 | 313 | |
| 316 | 314 | // Human format amount (default). |
| 317 | 315 | $human_format_amount = $amount; |
| 318 | 316 | |
| 319 | - switch ( $args['currency'] ) { |
|
| 317 | + switch ($args['currency']) { |
|
| 320 | 318 | case 'INR': |
| 321 | 319 | // Calculate large number formatted amount. |
| 322 | - if ( 4 < $amount_count_parts ) { |
|
| 323 | - $human_format_amount = sprintf( esc_html__( '%s arab', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) ); |
|
| 324 | - } elseif ( 3 < $amount_count_parts ) { |
|
| 325 | - $human_format_amount = sprintf( esc_html__( '%s crore', 'give' ), round( ( $sanitize_amount / 10000000 ), 2 ) ); |
|
| 326 | - } elseif ( 2 < $amount_count_parts ) { |
|
| 327 | - $human_format_amount = sprintf( esc_html__( '%s lakh', 'give' ), round( ( $sanitize_amount / 100000 ), 2 ) ); |
|
| 320 | + if (4 < $amount_count_parts) { |
|
| 321 | + $human_format_amount = sprintf(esc_html__('%s arab', 'give'), round(($sanitize_amount / 1000000000), 2)); |
|
| 322 | + } elseif (3 < $amount_count_parts) { |
|
| 323 | + $human_format_amount = sprintf(esc_html__('%s crore', 'give'), round(($sanitize_amount / 10000000), 2)); |
|
| 324 | + } elseif (2 < $amount_count_parts) { |
|
| 325 | + $human_format_amount = sprintf(esc_html__('%s lakh', 'give'), round(($sanitize_amount / 100000), 2)); |
|
| 328 | 326 | } |
| 329 | 327 | break; |
| 330 | 328 | default: |
| 331 | 329 | // Calculate large number formatted amount. |
| 332 | - if ( 4 < $amount_count_parts ) { |
|
| 333 | - $human_format_amount = sprintf( esc_html__( '%s trillion', 'give' ), round( ( $sanitize_amount / 1000000000000 ), 2 ) ); |
|
| 334 | - } elseif ( 3 < $amount_count_parts ) { |
|
| 335 | - $human_format_amount = sprintf( esc_html__( '%s billion', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) ); |
|
| 336 | - } elseif ( 2 < $amount_count_parts ) { |
|
| 337 | - $human_format_amount = sprintf( esc_html__( '%s million', 'give' ), round( ( $sanitize_amount / 1000000 ), 2 ) ); |
|
| 330 | + if (4 < $amount_count_parts) { |
|
| 331 | + $human_format_amount = sprintf(esc_html__('%s trillion', 'give'), round(($sanitize_amount / 1000000000000), 2)); |
|
| 332 | + } elseif (3 < $amount_count_parts) { |
|
| 333 | + $human_format_amount = sprintf(esc_html__('%s billion', 'give'), round(($sanitize_amount / 1000000000), 2)); |
|
| 334 | + } elseif (2 < $amount_count_parts) { |
|
| 335 | + $human_format_amount = sprintf(esc_html__('%s million', 'give'), round(($sanitize_amount / 1000000), 2)); |
|
| 338 | 336 | } |
| 339 | 337 | } |
| 340 | 338 | |
| 341 | - return apply_filters( 'give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount ); |
|
| 339 | + return apply_filters('give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount); |
|
| 342 | 340 | } |
| 343 | 341 | |
| 344 | 342 | /** |
@@ -352,17 +350,16 @@ discard block |
||
| 352 | 350 | * |
| 353 | 351 | * @return string $amount Newly formatted amount or Price Not Available |
| 354 | 352 | */ |
| 355 | -function give_format_decimal( $amount, $dp = false, $sanitize = true ) { |
|
| 353 | +function give_format_decimal($amount, $dp = false, $sanitize = true) { |
|
| 356 | 354 | $decimal_separator = give_get_price_decimal_separator(); |
| 357 | 355 | $formatted_amount = $sanitize ? |
| 358 | - give_maybe_sanitize_amount( $amount, $dp ) : |
|
| 359 | - number_format( $amount, ( is_bool( $dp ) ? give_get_price_decimals() : $dp ), '.', '' ); |
|
| 356 | + give_maybe_sanitize_amount($amount, $dp) : number_format($amount, (is_bool($dp) ? give_get_price_decimals() : $dp), '.', ''); |
|
| 360 | 357 | |
| 361 | - if ( false !== strpos( $formatted_amount, '.' ) ) { |
|
| 362 | - $formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount ); |
|
| 358 | + if (false !== strpos($formatted_amount, '.')) { |
|
| 359 | + $formatted_amount = str_replace('.', $decimal_separator, $formatted_amount); |
|
| 363 | 360 | } |
| 364 | 361 | |
| 365 | - return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator ); |
|
| 362 | + return apply_filters('give_format_decimal', $formatted_amount, $amount, $decimal_separator); |
|
| 366 | 363 | } |
| 367 | 364 | |
| 368 | 365 | /** |
@@ -376,24 +373,24 @@ discard block |
||
| 376 | 373 | * |
| 377 | 374 | * @return mixed|string |
| 378 | 375 | */ |
| 379 | -function give_currency_filter( $price = '', $currency = '', $decode_currency = false ) { |
|
| 376 | +function give_currency_filter($price = '', $currency = '', $decode_currency = false) { |
|
| 380 | 377 | |
| 381 | - if ( empty( $currency ) || ! array_key_exists( (string) $currency, give_get_currencies() ) ) { |
|
| 378 | + if (empty($currency) || ! array_key_exists((string) $currency, give_get_currencies())) { |
|
| 382 | 379 | $currency = give_get_currency(); |
| 383 | 380 | } |
| 384 | 381 | |
| 385 | - $position = give_get_option( 'currency_position', 'before' ); |
|
| 382 | + $position = give_get_option('currency_position', 'before'); |
|
| 386 | 383 | |
| 387 | 384 | $negative = $price < 0; |
| 388 | 385 | |
| 389 | - if ( $negative ) { |
|
| 386 | + if ($negative) { |
|
| 390 | 387 | // Remove proceeding "-". |
| 391 | - $price = substr( $price, 1 ); |
|
| 388 | + $price = substr($price, 1); |
|
| 392 | 389 | } |
| 393 | 390 | |
| 394 | - $symbol = give_currency_symbol( $currency, $decode_currency ); |
|
| 391 | + $symbol = give_currency_symbol($currency, $decode_currency); |
|
| 395 | 392 | |
| 396 | - switch ( $currency ) : |
|
| 393 | + switch ($currency) : |
|
| 397 | 394 | case 'GBP' : |
| 398 | 395 | case 'BRL' : |
| 399 | 396 | case 'EUR' : |
@@ -422,13 +419,13 @@ discard block |
||
| 422 | 419 | case 'MAD' : |
| 423 | 420 | case 'KRW' : |
| 424 | 421 | case 'ZAR' : |
| 425 | - $formatted = ( 'before' === $position ? $symbol . $price : $price . $symbol ); |
|
| 422 | + $formatted = ('before' === $position ? $symbol.$price : $price.$symbol); |
|
| 426 | 423 | break; |
| 427 | 424 | case 'NOK' : |
| 428 | - $formatted = ( 'before' === $position ? $symbol . ' ' . $price : $price . ' ' . $symbol ); |
|
| 425 | + $formatted = ('before' === $position ? $symbol.' '.$price : $price.' '.$symbol); |
|
| 429 | 426 | break; |
| 430 | 427 | default : |
| 431 | - $formatted = ( 'before' === $position ? $currency . ' ' . $price : $price . ' ' . $currency ); |
|
| 428 | + $formatted = ('before' === $position ? $currency.' '.$price : $price.' '.$currency); |
|
| 432 | 429 | break; |
| 433 | 430 | endswitch; |
| 434 | 431 | |
@@ -443,11 +440,11 @@ discard block |
||
| 443 | 440 | * and if currency is USD and currency position is after then |
| 444 | 441 | * filter name will be give_usd_currency_filter_after |
| 445 | 442 | */ |
| 446 | - $formatted = apply_filters( 'give_' . strtolower( $currency ) . "_currency_filter_{$position}", $formatted, $currency, $price ); |
|
| 443 | + $formatted = apply_filters('give_'.strtolower($currency)."_currency_filter_{$position}", $formatted, $currency, $price); |
|
| 447 | 444 | |
| 448 | - if ( $negative ) { |
|
| 445 | + if ($negative) { |
|
| 449 | 446 | // Prepend the minus sign before the currency sign. |
| 450 | - $formatted = '-' . $formatted; |
|
| 447 | + $formatted = '-'.$formatted; |
|
| 451 | 448 | } |
| 452 | 449 | |
| 453 | 450 | return $formatted; |
@@ -463,21 +460,21 @@ discard block |
||
| 463 | 460 | */ |
| 464 | 461 | function give_currency_decimal_filter() { |
| 465 | 462 | |
| 466 | - remove_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
| 463 | + remove_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
| 467 | 464 | |
| 468 | 465 | // Set default number of decimals. |
| 469 | 466 | $decimals = give_get_price_decimals(); |
| 470 | 467 | |
| 471 | - add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
| 468 | + add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
| 472 | 469 | |
| 473 | 470 | // Get number of decimals with backward compatibility ( version < 1.6 ) |
| 474 | - if ( 1 <= func_num_args() ) { |
|
| 475 | - $decimals = ( false === func_get_arg( 0 ) ? $decimals : absint( func_get_arg( 0 ) ) ); |
|
| 471 | + if (1 <= func_num_args()) { |
|
| 472 | + $decimals = (false === func_get_arg(0) ? $decimals : absint(func_get_arg(0))); |
|
| 476 | 473 | } |
| 477 | 474 | |
| 478 | 475 | $currency = give_get_currency(); |
| 479 | 476 | |
| 480 | - switch ( $currency ) { |
|
| 477 | + switch ($currency) { |
|
| 481 | 478 | case 'RIAL' : |
| 482 | 479 | case 'JPY' : |
| 483 | 480 | case 'TWD' : |
@@ -487,11 +484,11 @@ discard block |
||
| 487 | 484 | break; |
| 488 | 485 | } |
| 489 | 486 | |
| 490 | - return apply_filters( 'give_currency_decimal_count', $decimals, $currency ); |
|
| 487 | + return apply_filters('give_currency_decimal_count', $decimals, $currency); |
|
| 491 | 488 | } |
| 492 | 489 | |
| 493 | -add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
| 494 | -add_filter( 'give_format_amount_decimals', 'give_currency_decimal_filter' ); |
|
| 490 | +add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
| 491 | +add_filter('give_format_amount_decimals', 'give_currency_decimal_filter'); |
|
| 495 | 492 | |
| 496 | 493 | |
| 497 | 494 | /** |
@@ -503,7 +500,7 @@ discard block |
||
| 503 | 500 | * |
| 504 | 501 | * @return string Date format string |
| 505 | 502 | */ |
| 506 | -function give_date_format( $date_context = '' ) { |
|
| 503 | +function give_date_format($date_context = '') { |
|
| 507 | 504 | /** |
| 508 | 505 | * Filter the date context |
| 509 | 506 | * |
@@ -524,19 +521,19 @@ discard block |
||
| 524 | 521 | * |
| 525 | 522 | * } |
| 526 | 523 | */ |
| 527 | - $date_format_contexts = apply_filters( 'give_date_format_contexts', array() ); |
|
| 524 | + $date_format_contexts = apply_filters('give_date_format_contexts', array()); |
|
| 528 | 525 | |
| 529 | 526 | // Set date format to default date format. |
| 530 | - $date_format = get_option( 'date_format' ); |
|
| 527 | + $date_format = get_option('date_format'); |
|
| 531 | 528 | |
| 532 | 529 | // Update date format if we have non empty date format context array and non empty date format string for that context. |
| 533 | - if ( $date_context && ! empty( $date_format_contexts ) && array_key_exists( $date_context, $date_format_contexts ) ) { |
|
| 534 | - $date_format = ! empty( $date_format_contexts[ $date_context ] ) |
|
| 535 | - ? $date_format_contexts[ $date_context ] |
|
| 530 | + if ($date_context && ! empty($date_format_contexts) && array_key_exists($date_context, $date_format_contexts)) { |
|
| 531 | + $date_format = ! empty($date_format_contexts[$date_context]) |
|
| 532 | + ? $date_format_contexts[$date_context] |
|
| 536 | 533 | : $date_format; |
| 537 | 534 | } |
| 538 | 535 | |
| 539 | - return apply_filters( 'give_date_format', $date_format ); |
|
| 536 | + return apply_filters('give_date_format', $date_format); |
|
| 540 | 537 | } |
| 541 | 538 | |
| 542 | 539 | /** |
@@ -550,8 +547,8 @@ discard block |
||
| 550 | 547 | * |
| 551 | 548 | * @return string |
| 552 | 549 | */ |
| 553 | -function give_get_cache_key( $action, $query_args ) { |
|
| 554 | - return Give_Cache::get_key( $action, $query_args ); |
|
| 550 | +function give_get_cache_key($action, $query_args) { |
|
| 551 | + return Give_Cache::get_key($action, $query_args); |
|
| 555 | 552 | } |
| 556 | 553 | |
| 557 | 554 | /** |
@@ -564,11 +561,11 @@ discard block |
||
| 564 | 561 | * |
| 565 | 562 | * @return string|array |
| 566 | 563 | */ |
| 567 | -function give_clean( $var ) { |
|
| 568 | - if ( is_array( $var ) ) { |
|
| 569 | - return array_map( 'give_clean', $var ); |
|
| 564 | +function give_clean($var) { |
|
| 565 | + if (is_array($var)) { |
|
| 566 | + return array_map('give_clean', $var); |
|
| 570 | 567 | } else { |
| 571 | - return is_scalar( $var ) ? sanitize_text_field( $var ) : $var; |
|
| 568 | + return is_scalar($var) ? sanitize_text_field($var) : $var; |
|
| 572 | 569 | } |
| 573 | 570 | } |
| 574 | 571 | |
@@ -581,10 +578,10 @@ discard block |
||
| 581 | 578 | * |
| 582 | 579 | * @return int |
| 583 | 580 | */ |
| 584 | -function give_let_to_num( $size ) { |
|
| 585 | - $l = substr( $size, - 1 ); |
|
| 586 | - $ret = substr( $size, 0, - 1 ); |
|
| 587 | - switch ( strtoupper( $l ) ) { |
|
| 581 | +function give_let_to_num($size) { |
|
| 582 | + $l = substr($size, - 1); |
|
| 583 | + $ret = substr($size, 0, - 1); |
|
| 584 | + switch (strtoupper($l)) { |
|
| 588 | 585 | case 'P': |
| 589 | 586 | $ret *= 1024; |
| 590 | 587 | case 'T': |
@@ -609,19 +606,19 @@ discard block |
||
| 609 | 606 | * @param int $action |
| 610 | 607 | * @param array $wp_die_args |
| 611 | 608 | */ |
| 612 | -function give_validate_nonce( $nonce, $action = - 1, $wp_die_args = array() ) { |
|
| 609 | +function give_validate_nonce($nonce, $action = - 1, $wp_die_args = array()) { |
|
| 613 | 610 | |
| 614 | 611 | $default_wp_die_args = array( |
| 615 | - 'message' => esc_html__( 'Nonce verification has failed.', 'give' ), |
|
| 616 | - 'title' => esc_html__( 'Error', 'give' ), |
|
| 612 | + 'message' => esc_html__('Nonce verification has failed.', 'give'), |
|
| 613 | + 'title' => esc_html__('Error', 'give'), |
|
| 617 | 614 | 'args' => array( |
| 618 | 615 | 'response' => 403, |
| 619 | 616 | ), |
| 620 | 617 | ); |
| 621 | 618 | |
| 622 | - $wp_die_args = wp_parse_args( $wp_die_args, $default_wp_die_args ); |
|
| 619 | + $wp_die_args = wp_parse_args($wp_die_args, $default_wp_die_args); |
|
| 623 | 620 | |
| 624 | - if ( ! wp_verify_nonce( $nonce, $action ) ) { |
|
| 621 | + if ( ! wp_verify_nonce($nonce, $action)) { |
|
| 625 | 622 | wp_die( |
| 626 | 623 | $wp_die_args['message'], |
| 627 | 624 | $wp_die_args['title'], |
@@ -643,23 +640,23 @@ discard block |
||
| 643 | 640 | * |
| 644 | 641 | * @return mixed |
| 645 | 642 | */ |
| 646 | -function give_check_variable( $variable, $conditional = '', $default = false ) { |
|
| 643 | +function give_check_variable($variable, $conditional = '', $default = false) { |
|
| 647 | 644 | |
| 648 | - switch ( $conditional ) { |
|
| 645 | + switch ($conditional) { |
|
| 649 | 646 | case 'isset_empty': |
| 650 | - $variable = ( isset( $variable ) && ! empty( $variable ) ) ? $variable : $default; |
|
| 647 | + $variable = (isset($variable) && ! empty($variable)) ? $variable : $default; |
|
| 651 | 648 | break; |
| 652 | 649 | |
| 653 | 650 | case 'empty': |
| 654 | - $variable = ! empty( $variable ) ? $variable : $default; |
|
| 651 | + $variable = ! empty($variable) ? $variable : $default; |
|
| 655 | 652 | break; |
| 656 | 653 | |
| 657 | 654 | case 'null': |
| 658 | - $variable = ! is_null( $variable ) ? $variable : $default; |
|
| 655 | + $variable = ! is_null($variable) ? $variable : $default; |
|
| 659 | 656 | break; |
| 660 | 657 | |
| 661 | 658 | default: |
| 662 | - $variable = isset( $variable ) ? $variable : $default; |
|
| 659 | + $variable = isset($variable) ? $variable : $default; |
|
| 663 | 660 | |
| 664 | 661 | } |
| 665 | 662 | |