@@ -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 | |
@@ -53,21 +53,21 @@ discard block |
||
| 53 | 53 | * @since 1.8.9 |
| 54 | 54 | */ |
| 55 | 55 | public function __construct() { |
| 56 | - add_action( 'admin_notices', array( $this, 'render_admin_notices' ), 999 ); |
|
| 57 | - add_action( 'give_dismiss_notices', array( $this, 'dismiss_notices' ) ); |
|
| 56 | + add_action('admin_notices', array($this, 'render_admin_notices'), 999); |
|
| 57 | + add_action('give_dismiss_notices', array($this, 'dismiss_notices')); |
|
| 58 | 58 | |
| 59 | - add_action( 'give_frontend_notices', array( $this, 'render_frontend_notices' ), 999 ); |
|
| 60 | - add_action( 'give_pre_form_output', array( $this, 'render_frontend_form_notices' ), 10, 1 ); |
|
| 61 | - add_action( 'give_ajax_donation_errors', array( $this, 'render_frontend_notices' ) ); |
|
| 59 | + add_action('give_frontend_notices', array($this, 'render_frontend_notices'), 999); |
|
| 60 | + add_action('give_pre_form_output', array($this, 'render_frontend_form_notices'), 10, 1); |
|
| 61 | + add_action('give_ajax_donation_errors', array($this, 'render_frontend_notices')); |
|
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | 64 | * Backward compatibility for deprecated params. |
| 65 | 65 | * |
| 66 | 66 | * @since 1.8.14 |
| 67 | 67 | */ |
| 68 | - add_filter( 'give_register_notice_args', array( $this, 'bc_deprecated_params' ) ); |
|
| 69 | - add_filter( 'give_frontend_errors_args', array( $this, 'bc_deprecated_params' ) ); |
|
| 70 | - add_filter( 'give_frontend_notice_args', array( $this, 'bc_deprecated_params' ) ); |
|
| 68 | + add_filter('give_register_notice_args', array($this, 'bc_deprecated_params')); |
|
| 69 | + add_filter('give_frontend_errors_args', array($this, 'bc_deprecated_params')); |
|
| 70 | + add_filter('give_frontend_notice_args', array($this, 'bc_deprecated_params')); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -80,19 +80,19 @@ discard block |
||
| 80 | 80 | * |
| 81 | 81 | * @return array |
| 82 | 82 | */ |
| 83 | - public function bc_deprecated_params( $args ) { |
|
| 83 | + public function bc_deprecated_params($args) { |
|
| 84 | 84 | /** |
| 85 | 85 | * Param: auto_dismissible |
| 86 | 86 | * deprecated in 1.8.14 |
| 87 | 87 | * |
| 88 | 88 | * Check if auto_dismissible is set and it true then unset and change dismissible parameter value to auto |
| 89 | 89 | */ |
| 90 | - if ( isset( $args['auto_dismissible'] ) ) { |
|
| 91 | - if ( ! empty( $args['auto_dismissible'] ) ) { |
|
| 90 | + if (isset($args['auto_dismissible'])) { |
|
| 91 | + if ( ! empty($args['auto_dismissible'])) { |
|
| 92 | 92 | $args['dismissible'] = 'auto'; |
| 93 | 93 | } |
| 94 | 94 | // unset auto_dismissible as it has been deprecated. |
| 95 | - unset( $args['auto_dismissible'] ); |
|
| 95 | + unset($args['auto_dismissible']); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | return $args; |
@@ -108,9 +108,9 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @return bool |
| 110 | 110 | */ |
| 111 | - public function register_notice( $notice_args ) { |
|
| 111 | + public function register_notice($notice_args) { |
|
| 112 | 112 | // Bailout. |
| 113 | - if ( empty( $notice_args['id'] ) || array_key_exists( $notice_args['id'], self::$notices ) ) { |
|
| 113 | + if (empty($notice_args['id']) || array_key_exists($notice_args['id'], self::$notices)) { |
|
| 114 | 114 | return false; |
| 115 | 115 | } |
| 116 | 116 | |
@@ -159,39 +159,39 @@ discard block |
||
| 159 | 159 | * |
| 160 | 160 | * @since 1.8.14 |
| 161 | 161 | */ |
| 162 | - $notice_args = apply_filters( 'give_register_notice_args', $notice_args ); |
|
| 162 | + $notice_args = apply_filters('give_register_notice_args', $notice_args); |
|
| 163 | 163 | |
| 164 | 164 | // Set extra dismiss links if any. |
| 165 | - if ( false !== strpos( $notice_args['description'], 'data-dismiss-interval' ) ) { |
|
| 165 | + if (false !== strpos($notice_args['description'], 'data-dismiss-interval')) { |
|
| 166 | 166 | |
| 167 | - preg_match_all( "/data-([^\"]*)=\"([^\"]*)\"/", $notice_args['description'], $extra_notice_dismiss_link ); |
|
| 167 | + preg_match_all("/data-([^\"]*)=\"([^\"]*)\"/", $notice_args['description'], $extra_notice_dismiss_link); |
|
| 168 | 168 | |
| 169 | - if ( ! empty( $extra_notice_dismiss_link ) ) { |
|
| 170 | - $extra_notice_dismiss_links = array_chunk( current( $extra_notice_dismiss_link ), 3 ); |
|
| 171 | - foreach ( $extra_notice_dismiss_links as $extra_notice_dismiss_link ) { |
|
| 169 | + if ( ! empty($extra_notice_dismiss_link)) { |
|
| 170 | + $extra_notice_dismiss_links = array_chunk(current($extra_notice_dismiss_link), 3); |
|
| 171 | + foreach ($extra_notice_dismiss_links as $extra_notice_dismiss_link) { |
|
| 172 | 172 | // Create array og key ==> value by parsing query string created after renaming data attributes. |
| 173 | - $data_attribute_query_str = str_replace( array( 'data-', '-', '"' ), array( |
|
| 173 | + $data_attribute_query_str = str_replace(array('data-', '-', '"'), array( |
|
| 174 | 174 | '', |
| 175 | 175 | '_', |
| 176 | 176 | '', |
| 177 | - ), implode( '&', $extra_notice_dismiss_link ) ); |
|
| 177 | + ), implode('&', $extra_notice_dismiss_link)); |
|
| 178 | 178 | |
| 179 | - $notice_args['extra_links'][] = wp_parse_args( $data_attribute_query_str ); |
|
| 179 | + $notice_args['extra_links'][] = wp_parse_args($data_attribute_query_str); |
|
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | |
| 185 | - self::$notices[ $notice_args['id'] ] = $notice_args; |
|
| 185 | + self::$notices[$notice_args['id']] = $notice_args; |
|
| 186 | 186 | |
| 187 | 187 | // Auto set show param if not already set. |
| 188 | - if ( ! isset( self::$notices[ $notice_args['id'] ]['show'] ) ) { |
|
| 189 | - self::$notices[ $notice_args['id'] ]['show'] = $this->is_notice_dismissed( $notice_args ) ? false : true; |
|
| 188 | + if ( ! isset(self::$notices[$notice_args['id']]['show'])) { |
|
| 189 | + self::$notices[$notice_args['id']]['show'] = $this->is_notice_dismissed($notice_args) ? false : true; |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | // Auto set time interval for shortly. |
| 193 | - if ( 'shortly' === self::$notices[ $notice_args['id'] ]['dismiss_interval'] ) { |
|
| 194 | - self::$notices[ $notice_args['id'] ]['dismiss_interval_time'] = DAY_IN_SECONDS; |
|
| 193 | + if ('shortly' === self::$notices[$notice_args['id']]['dismiss_interval']) { |
|
| 194 | + self::$notices[$notice_args['id']]['dismiss_interval_time'] = DAY_IN_SECONDS; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | return true; |
@@ -205,51 +205,51 @@ discard block |
||
| 205 | 205 | */ |
| 206 | 206 | public function render_admin_notices() { |
| 207 | 207 | // Bailout. |
| 208 | - if ( empty( self::$notices ) ) { |
|
| 208 | + if (empty(self::$notices)) { |
|
| 209 | 209 | return; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | $output = ''; |
| 213 | 213 | |
| 214 | - foreach ( self::$notices as $notice_id => $notice ) { |
|
| 214 | + foreach (self::$notices as $notice_id => $notice) { |
|
| 215 | 215 | // Check flag set to true to show notice. |
| 216 | - if ( ! $notice['show'] ) { |
|
| 216 | + if ( ! $notice['show']) { |
|
| 217 | 217 | continue; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | |
| 221 | 221 | // Render custom html. |
| 222 | - if( ! empty( $notice['description_html'] ) ) { |
|
| 222 | + if ( ! empty($notice['description_html'])) { |
|
| 223 | 223 | $output .= "{$notice['description_html']} \n"; |
| 224 | 224 | continue; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | // Check if notice dismissible or not. |
| 228 | - if ( ! self::$has_auto_dismissible_notice ) { |
|
| 229 | - self::$has_auto_dismissible_notice = ( 'auto' === $notice['dismissible'] ); |
|
| 228 | + if ( ! self::$has_auto_dismissible_notice) { |
|
| 229 | + self::$has_auto_dismissible_notice = ('auto' === $notice['dismissible']); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | // Check if notice dismissible or not. |
| 233 | - if ( ! self::$has_dismiss_interval_notice ) { |
|
| 233 | + if ( ! self::$has_dismiss_interval_notice) { |
|
| 234 | 234 | self::$has_dismiss_interval_notice = $notice['dismiss_interval']; |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - $css_id = ( false === strpos( $notice['id'], 'give' ) ? "give-{$notice['id']}" : $notice['id'] ); |
|
| 237 | + $css_id = (false === strpos($notice['id'], 'give') ? "give-{$notice['id']}" : $notice['id']); |
|
| 238 | 238 | |
| 239 | - $css_class = 'give-notice notice ' . ( empty( $notice['dismissible'] ) ? 'non' : 'is' ) . "-dismissible {$notice['type']} notice-{$notice['type']}"; |
|
| 240 | - $output .= sprintf( |
|
| 241 | - '<div id="%1$s" class="%2$s" data-dismissible="%3$s" data-dismissible-type="%4$s" data-dismiss-interval="%5$s" data-notice-id="%6$s" data-security="%7$s" data-dismiss-interval-time="%8$s" style="display: none">' . " \n", |
|
| 239 | + $css_class = 'give-notice notice '.(empty($notice['dismissible']) ? 'non' : 'is')."-dismissible {$notice['type']} notice-{$notice['type']}"; |
|
| 240 | + $output .= sprintf( |
|
| 241 | + '<div id="%1$s" class="%2$s" data-dismissible="%3$s" data-dismissible-type="%4$s" data-dismiss-interval="%5$s" data-notice-id="%6$s" data-security="%7$s" data-dismiss-interval-time="%8$s" style="display: none">'." \n", |
|
| 242 | 242 | $css_id, |
| 243 | 243 | $css_class, |
| 244 | - give_clean( $notice['dismissible'] ), |
|
| 244 | + give_clean($notice['dismissible']), |
|
| 245 | 245 | $notice['dismissible_type'], |
| 246 | 246 | $notice['dismiss_interval'], |
| 247 | 247 | $notice['id'], |
| 248 | - empty( $notice['dismissible_type'] ) ? '' : wp_create_nonce( "give_edit_{$notice_id}_notice" ), |
|
| 248 | + empty($notice['dismissible_type']) ? '' : wp_create_nonce("give_edit_{$notice_id}_notice"), |
|
| 249 | 249 | $notice['dismiss_interval_time'] |
| 250 | 250 | ); |
| 251 | 251 | |
| 252 | - $output .= ( 0 === strpos( $notice['description'], '<div' ) || 0 === strpos( $notice['description'], '<p' ) ? $notice['description'] : "<p>{$notice['description']}</p>" ); |
|
| 252 | + $output .= (0 === strpos($notice['description'], '<div') || 0 === strpos($notice['description'], '<p') ? $notice['description'] : "<p>{$notice['description']}</p>"); |
|
| 253 | 253 | $output .= "</div> \n"; |
| 254 | 254 | } |
| 255 | 255 | |
@@ -267,18 +267,18 @@ discard block |
||
| 267 | 267 | * |
| 268 | 268 | * @param int $form_id |
| 269 | 269 | */ |
| 270 | - public function render_frontend_notices( $form_id = 0 ) { |
|
| 270 | + public function render_frontend_notices($form_id = 0) { |
|
| 271 | 271 | $errors = give_get_errors(); |
| 272 | 272 | |
| 273 | - $request_form_id = isset( $_REQUEST['form-id'] ) ? absint( $_REQUEST['form-id'] ) : 0; |
|
| 273 | + $request_form_id = isset($_REQUEST['form-id']) ? absint($_REQUEST['form-id']) : 0; |
|
| 274 | 274 | |
| 275 | 275 | // Sanity checks first: Ensure that gateway returned errors display on the appropriate form. |
| 276 | - if ( ! isset( $_POST['give_ajax'] ) && $request_form_id !== $form_id ) { |
|
| 276 | + if ( ! isset($_POST['give_ajax']) && $request_form_id !== $form_id) { |
|
| 277 | 277 | return; |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | - if ( $errors ) { |
|
| 281 | - self::print_frontend_errors( $errors ); |
|
| 280 | + if ($errors) { |
|
| 281 | + self::print_frontend_errors($errors); |
|
| 282 | 282 | |
| 283 | 283 | give_clear_errors(); |
| 284 | 284 | } |
@@ -295,13 +295,13 @@ discard block |
||
| 295 | 295 | * |
| 296 | 296 | * @return void |
| 297 | 297 | */ |
| 298 | - public function render_frontend_form_notices( $form_id ) { |
|
| 299 | - $display_option = give_get_meta( $form_id, '_give_payment_display', true ); |
|
| 298 | + public function render_frontend_form_notices($form_id) { |
|
| 299 | + $display_option = give_get_meta($form_id, '_give_payment_display', true); |
|
| 300 | 300 | |
| 301 | - if ( 'modal' === $display_option ) { |
|
| 302 | - add_action( 'give_payment_mode_top', array( $this, 'render_frontend_notices' ) ); |
|
| 301 | + if ('modal' === $display_option) { |
|
| 302 | + add_action('give_payment_mode_top', array($this, 'render_frontend_notices')); |
|
| 303 | 303 | } else { |
| 304 | - add_action( 'give_pre_form', array( $this, 'render_frontend_notices' ), 11 ); |
|
| 304 | + add_action('give_pre_form', array($this, 'render_frontend_notices'), 11); |
|
| 305 | 305 | } |
| 306 | 306 | } |
| 307 | 307 | |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | * @access private |
| 313 | 313 | */ |
| 314 | 314 | private function print_js() { |
| 315 | - if ( self::$has_auto_dismissible_notice ) : |
|
| 315 | + if (self::$has_auto_dismissible_notice) : |
|
| 316 | 316 | ?> |
| 317 | 317 | <script> |
| 318 | 318 | jQuery(document).ready(function () { |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | <?php |
| 329 | 329 | endif; |
| 330 | 330 | |
| 331 | - if ( self::$has_dismiss_interval_notice ) : |
|
| 331 | + if (self::$has_dismiss_interval_notice) : |
|
| 332 | 332 | ?> |
| 333 | 333 | <script> |
| 334 | 334 | jQuery(document).ready(function () { |
@@ -407,36 +407,36 @@ discard block |
||
| 407 | 407 | * @access public |
| 408 | 408 | */ |
| 409 | 409 | public function dismiss_notices() { |
| 410 | - $_post = give_clean( $_POST ); |
|
| 411 | - $notice_id = esc_attr( $_post['notice_id'] ); |
|
| 410 | + $_post = give_clean($_POST); |
|
| 411 | + $notice_id = esc_attr($_post['notice_id']); |
|
| 412 | 412 | |
| 413 | 413 | // Bailout. |
| 414 | 414 | if ( |
| 415 | - empty( $notice_id ) || |
|
| 416 | - empty( $_post['dismissible_type'] ) || |
|
| 417 | - empty( $_post['dismiss_interval'] ) || |
|
| 418 | - ! check_ajax_referer( "give_edit_{$notice_id}_notice", '_wpnonce' ) |
|
| 415 | + empty($notice_id) || |
|
| 416 | + empty($_post['dismissible_type']) || |
|
| 417 | + empty($_post['dismiss_interval']) || |
|
| 418 | + ! check_ajax_referer("give_edit_{$notice_id}_notice", '_wpnonce') |
|
| 419 | 419 | ) { |
| 420 | 420 | wp_send_json_error(); |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | - $notice_key = Give()->notices->get_notice_key( $notice_id, $_post['dismiss_interval'] ); |
|
| 424 | - if ( 'user' === $_post['dismissible_type'] ) { |
|
| 423 | + $notice_key = Give()->notices->get_notice_key($notice_id, $_post['dismiss_interval']); |
|
| 424 | + if ('user' === $_post['dismissible_type']) { |
|
| 425 | 425 | $current_user = wp_get_current_user(); |
| 426 | - $notice_key = Give()->notices->get_notice_key( $notice_id, $_post['dismiss_interval'], $current_user->ID ); |
|
| 426 | + $notice_key = Give()->notices->get_notice_key($notice_id, $_post['dismiss_interval'], $current_user->ID); |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | - $notice_dismiss_time = ! empty( $_post['dismiss_interval_time'] ) ? $_post['dismiss_interval_time'] : null; |
|
| 429 | + $notice_dismiss_time = ! empty($_post['dismiss_interval_time']) ? $_post['dismiss_interval_time'] : null; |
|
| 430 | 430 | |
| 431 | 431 | // Save option to hide notice. |
| 432 | - Give_Cache::set( $notice_key, true, $notice_dismiss_time, true ); |
|
| 432 | + Give_Cache::set($notice_key, true, $notice_dismiss_time, true); |
|
| 433 | 433 | |
| 434 | 434 | /** |
| 435 | 435 | * Fire the action when notice dismissed |
| 436 | 436 | * |
| 437 | 437 | * @since 2.2.0 |
| 438 | 438 | */ |
| 439 | - do_action( 'give_notice_dismissed', $_post ); |
|
| 439 | + do_action('give_notice_dismissed', $_post); |
|
| 440 | 440 | |
| 441 | 441 | wp_send_json_success(); |
| 442 | 442 | } |
@@ -454,18 +454,18 @@ discard block |
||
| 454 | 454 | * |
| 455 | 455 | * @return string |
| 456 | 456 | */ |
| 457 | - public function get_notice_key( $notice_id, $dismiss_interval = null, $user_id = 0 ) { |
|
| 457 | + public function get_notice_key($notice_id, $dismiss_interval = null, $user_id = 0) { |
|
| 458 | 458 | $notice_key = "_give_notice_{$notice_id}"; |
| 459 | 459 | |
| 460 | - if ( ! empty( $dismiss_interval ) ) { |
|
| 460 | + if ( ! empty($dismiss_interval)) { |
|
| 461 | 461 | $notice_key .= "_{$dismiss_interval}"; |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | - if ( $user_id ) { |
|
| 464 | + if ($user_id) { |
|
| 465 | 465 | $notice_key .= "_{$user_id}"; |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - $notice_key = sanitize_key( $notice_key ); |
|
| 468 | + $notice_key = sanitize_key($notice_key); |
|
| 469 | 469 | |
| 470 | 470 | return $notice_key; |
| 471 | 471 | } |
@@ -478,11 +478,11 @@ discard block |
||
| 478 | 478 | * |
| 479 | 479 | * @return string |
| 480 | 480 | */ |
| 481 | - public function get_dismiss_link( $notice_args ) { |
|
| 481 | + public function get_dismiss_link($notice_args) { |
|
| 482 | 482 | $notice_args = wp_parse_args( |
| 483 | 483 | $notice_args, |
| 484 | 484 | array( |
| 485 | - 'title' => __( 'Click here', 'give' ), |
|
| 485 | + 'title' => __('Click here', 'give'), |
|
| 486 | 486 | 'dismissible_type' => '', |
| 487 | 487 | 'dismiss_interval' => '', |
| 488 | 488 | 'dismiss_interval_time' => null, |
@@ -509,31 +509,31 @@ discard block |
||
| 509 | 509 | * |
| 510 | 510 | * @return bool|null |
| 511 | 511 | */ |
| 512 | - public function is_notice_dismissed( $notice ) { |
|
| 513 | - $notice_key = $this->get_notice_key( $notice['id'], $notice['dismiss_interval'] ); |
|
| 512 | + public function is_notice_dismissed($notice) { |
|
| 513 | + $notice_key = $this->get_notice_key($notice['id'], $notice['dismiss_interval']); |
|
| 514 | 514 | $is_notice_dismissed = false; |
| 515 | 515 | |
| 516 | - if ( 'user' === $notice['dismissible_type'] ) { |
|
| 516 | + if ('user' === $notice['dismissible_type']) { |
|
| 517 | 517 | $current_user = wp_get_current_user(); |
| 518 | - $notice_key = Give()->notices->get_notice_key( $notice['id'], $notice['dismiss_interval'], $current_user->ID ); |
|
| 518 | + $notice_key = Give()->notices->get_notice_key($notice['id'], $notice['dismiss_interval'], $current_user->ID); |
|
| 519 | 519 | } |
| 520 | 520 | |
| 521 | - $notice_data = Give_Cache::get( $notice_key, true ); |
|
| 521 | + $notice_data = Give_Cache::get($notice_key, true); |
|
| 522 | 522 | |
| 523 | 523 | // Find notice dismiss link status if notice has extra dismissible links. |
| 524 | - if ( ( empty( $notice_data ) || is_wp_error( $notice_data ) ) && ! empty( $notice['extra_links'] ) ) { |
|
| 524 | + if ((empty($notice_data) || is_wp_error($notice_data)) && ! empty($notice['extra_links'])) { |
|
| 525 | 525 | |
| 526 | - foreach ( $notice['extra_links'] as $extra_link ) { |
|
| 527 | - $new_notice_data = wp_parse_args( $extra_link, $notice ); |
|
| 528 | - unset( $new_notice_data['extra_links'] ); |
|
| 526 | + foreach ($notice['extra_links'] as $extra_link) { |
|
| 527 | + $new_notice_data = wp_parse_args($extra_link, $notice); |
|
| 528 | + unset($new_notice_data['extra_links']); |
|
| 529 | 529 | |
| 530 | - if ( $is_notice_dismissed = $this->is_notice_dismissed( $new_notice_data ) ) { |
|
| 530 | + if ($is_notice_dismissed = $this->is_notice_dismissed($new_notice_data)) { |
|
| 531 | 531 | return $is_notice_dismissed; |
| 532 | 532 | } |
| 533 | 533 | } |
| 534 | 534 | } |
| 535 | 535 | |
| 536 | - $is_notice_dismissed = ! empty( $notice_data ) && ! is_wp_error( $notice_data ); |
|
| 536 | + $is_notice_dismissed = ! empty($notice_data) && ! is_wp_error($notice_data); |
|
| 537 | 537 | |
| 538 | 538 | return $is_notice_dismissed; |
| 539 | 539 | } |
@@ -547,9 +547,9 @@ discard block |
||
| 547 | 547 | * |
| 548 | 548 | * @param array $errors |
| 549 | 549 | */ |
| 550 | - public static function print_frontend_errors( $errors ) { |
|
| 550 | + public static function print_frontend_errors($errors) { |
|
| 551 | 551 | // Bailout. |
| 552 | - if ( ! $errors ) { |
|
| 552 | + if ( ! $errors) { |
|
| 553 | 553 | return; |
| 554 | 554 | } |
| 555 | 555 | |
@@ -564,37 +564,37 @@ discard block |
||
| 564 | 564 | ); |
| 565 | 565 | |
| 566 | 566 | // Note: we will remove give_errors class in future. |
| 567 | - $classes = apply_filters( 'give_error_class', array( 'give_notices', 'give_errors' ) ); |
|
| 567 | + $classes = apply_filters('give_error_class', array('give_notices', 'give_errors')); |
|
| 568 | 568 | |
| 569 | - echo sprintf( '<div class="%s">', implode( ' ', $classes ) ); |
|
| 569 | + echo sprintf('<div class="%s">', implode(' ', $classes)); |
|
| 570 | 570 | |
| 571 | 571 | // Loop error codes and display errors. |
| 572 | - foreach ( $errors as $error_id => $error ) { |
|
| 572 | + foreach ($errors as $error_id => $error) { |
|
| 573 | 573 | // Backward compatibility v<1.8.11 |
| 574 | - if ( is_string( $error ) ) { |
|
| 574 | + if (is_string($error)) { |
|
| 575 | 575 | $error = array( |
| 576 | 576 | 'message' => $error, |
| 577 | 577 | 'notice_args' => array(), |
| 578 | 578 | ); |
| 579 | 579 | } |
| 580 | 580 | |
| 581 | - $notice_args = wp_parse_args( $error['notice_args'], $default_notice_args ); |
|
| 581 | + $notice_args = wp_parse_args($error['notice_args'], $default_notice_args); |
|
| 582 | 582 | |
| 583 | 583 | /** |
| 584 | 584 | * Filter to modify Frontend Errors args before errors is display. |
| 585 | 585 | * |
| 586 | 586 | * @since 1.8.14 |
| 587 | 587 | */ |
| 588 | - $notice_args = apply_filters( 'give_frontend_errors_args', $notice_args ); |
|
| 588 | + $notice_args = apply_filters('give_frontend_errors_args', $notice_args); |
|
| 589 | 589 | |
| 590 | 590 | echo sprintf( |
| 591 | 591 | '<div class="give_error give_notice" id="give_error_%1$s" data-dismissible="%2$s" data-dismiss-interval="%3$d"> |
| 592 | 592 | <p><strong>%4$s</strong>: %5$s</p> |
| 593 | 593 | </div>', |
| 594 | 594 | $error_id, |
| 595 | - give_clean( $notice_args['dismissible'] ), |
|
| 596 | - absint( $notice_args['dismiss_interval'] ), |
|
| 597 | - esc_html__( 'Error', 'give' ), |
|
| 595 | + give_clean($notice_args['dismissible']), |
|
| 596 | + absint($notice_args['dismiss_interval']), |
|
| 597 | + esc_html__('Error', 'give'), |
|
| 598 | 598 | $error['message'] |
| 599 | 599 | ); |
| 600 | 600 | } |
@@ -616,8 +616,8 @@ discard block |
||
| 616 | 616 | * |
| 617 | 617 | * @return string |
| 618 | 618 | */ |
| 619 | - public static function print_frontend_notice( $message, $echo = true, $notice_type = 'warning', $notice_args = array() ) { |
|
| 620 | - if ( empty( $message ) ) { |
|
| 619 | + public static function print_frontend_notice($message, $echo = true, $notice_type = 'warning', $notice_args = array()) { |
|
| 620 | + if (empty($message)) { |
|
| 621 | 621 | return ''; |
| 622 | 622 | } |
| 623 | 623 | |
@@ -632,7 +632,7 @@ discard block |
||
| 632 | 632 | 'dismiss_interval' => 5000, |
| 633 | 633 | ); |
| 634 | 634 | |
| 635 | - $notice_args = wp_parse_args( $notice_args, $default_notice_args ); |
|
| 635 | + $notice_args = wp_parse_args($notice_args, $default_notice_args); |
|
| 636 | 636 | |
| 637 | 637 | // Notice dismissible must be true for dismiss type. |
| 638 | 638 | $notice_args['dismiss_type'] = ! $notice_args['dismissible'] ? '' : $notice_args['dismiss_type']; |
@@ -642,15 +642,14 @@ discard block |
||
| 642 | 642 | * |
| 643 | 643 | * @since 1.8.14 |
| 644 | 644 | */ |
| 645 | - $notice_args = apply_filters( 'give_frontend_notice_args', $notice_args ); |
|
| 645 | + $notice_args = apply_filters('give_frontend_notice_args', $notice_args); |
|
| 646 | 646 | |
| 647 | 647 | $close_icon = 'manual' === $notice_args['dismiss_type'] ? |
| 648 | 648 | sprintf( |
| 649 | 649 | '<img class="notice-dismiss give-notice-close" src="%s" />', |
| 650 | - esc_url( GIVE_PLUGIN_URL . 'assets/dist/images/close.svg' ) |
|
| 650 | + esc_url(GIVE_PLUGIN_URL.'assets/dist/images/close.svg') |
|
| 651 | 651 | |
| 652 | - ) : |
|
| 653 | - ''; |
|
| 652 | + ) : ''; |
|
| 654 | 653 | |
| 655 | 654 | // Note: we will remove give_errors class in future. |
| 656 | 655 | $error = sprintf( |
@@ -661,15 +660,15 @@ discard block |
||
| 661 | 660 | %6$s |
| 662 | 661 | </div>', |
| 663 | 662 | $notice_type, |
| 664 | - give_clean( $notice_args['dismissible'] ), |
|
| 665 | - absint( $notice_args['dismiss_interval'] ), |
|
| 666 | - give_clean( $notice_args['dismiss_type'] ), |
|
| 663 | + give_clean($notice_args['dismissible']), |
|
| 664 | + absint($notice_args['dismiss_interval']), |
|
| 665 | + give_clean($notice_args['dismiss_type']), |
|
| 667 | 666 | $message, |
| 668 | 667 | $close_icon |
| 669 | 668 | |
| 670 | 669 | ); |
| 671 | 670 | |
| 672 | - if ( ! $echo ) { |
|
| 671 | + if ( ! $echo) { |
|
| 673 | 672 | return $error; |
| 674 | 673 | } |
| 675 | 674 | |
@@ -689,24 +688,24 @@ discard block |
||
| 689 | 688 | * |
| 690 | 689 | * @return string |
| 691 | 690 | */ |
| 692 | - public function print_admin_notices( $notice_args = array() ) { |
|
| 691 | + public function print_admin_notices($notice_args = array()) { |
|
| 693 | 692 | // Bailout. |
| 694 | - if ( empty( $notice_args['description'] ) ) { |
|
| 693 | + if (empty($notice_args['description'])) { |
|
| 695 | 694 | return ''; |
| 696 | 695 | } |
| 697 | 696 | |
| 698 | - $defaults = array( |
|
| 697 | + $defaults = array( |
|
| 699 | 698 | 'id' => '', |
| 700 | 699 | 'echo' => true, |
| 701 | 700 | 'notice_type' => 'warning', |
| 702 | 701 | 'dismissible' => true, |
| 703 | 702 | ); |
| 704 | - $notice_args = wp_parse_args( $notice_args, $defaults ); |
|
| 703 | + $notice_args = wp_parse_args($notice_args, $defaults); |
|
| 705 | 704 | |
| 706 | 705 | $output = ''; |
| 707 | - $css_id = ! empty( $notice_args['id'] ) ? $notice_args['id'] : uniqid( 'give-inline-notice-' ); |
|
| 706 | + $css_id = ! empty($notice_args['id']) ? $notice_args['id'] : uniqid('give-inline-notice-'); |
|
| 708 | 707 | $css_class = "notice-{$notice_args['notice_type']} give-notice notice inline"; |
| 709 | - $css_class .= ( $notice_args['dismissible'] ) ? ' is-dismissible' : ''; |
|
| 708 | + $css_class .= ($notice_args['dismissible']) ? ' is-dismissible' : ''; |
|
| 710 | 709 | $output .= sprintf( |
| 711 | 710 | '<div id="%1$s" class="%2$s"><p>%3$s</p></div>', |
| 712 | 711 | $css_id, |
@@ -714,7 +713,7 @@ discard block |
||
| 714 | 713 | $notice_args['description'] |
| 715 | 714 | ); |
| 716 | 715 | |
| 717 | - if ( ! $notice_args['echo'] ) { |
|
| 716 | + if ( ! $notice_args['echo']) { |
|
| 718 | 717 | return $output; |
| 719 | 718 | } |
| 720 | 719 | |