Test Failed
Push — master ( f49c98...c5285d )
by Devin
01:02
created
includes/forms/widget.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  *
20 20
  * @since 1.0
21 21
  */
22
-class Give_Forms_Widget extends WP_Widget{
22
+class Give_Forms_Widget extends WP_Widget {
23 23
 	/**
24 24
 	 * The widget class name
25 25
 	 *
@@ -30,19 +30,19 @@  discard block
 block discarded – undo
30 30
 	/**
31 31
 	 * Instantiate the class
32 32
 	 */
33
-	public function __construct(){
34
-		$this->self = get_class( $this );
33
+	public function __construct() {
34
+		$this->self = get_class($this);
35 35
 
36 36
 		parent::__construct(
37
-			strtolower( $this->self ),
38
-			esc_html__( 'Give - Donation Form', 'give' ),
37
+			strtolower($this->self),
38
+			esc_html__('Give - Donation Form', 'give'),
39 39
 			array(
40
-				'description' => esc_html__( 'Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give' )
40
+				'description' => esc_html__('Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give')
41 41
 			)
42 42
 		);
43 43
 
44
-		add_action( 'widgets_init',          array( $this, 'widget_init' ) );
45
-		add_action( 'admin_enqueue_scripts', array( $this, 'admin_widget_scripts' ) );
44
+		add_action('widgets_init', array($this, 'widget_init'));
45
+		add_action('admin_enqueue_scripts', array($this, 'admin_widget_scripts'));
46 46
 	}
47 47
 
48 48
 	/**
@@ -52,19 +52,19 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @return void
54 54
 	 */
55
-	public function admin_widget_scripts( $hook ){
55
+	public function admin_widget_scripts($hook) {
56 56
 		// Directories of assets
57
-		$js_dir     = GIVE_PLUGIN_URL . 'assets/js/admin/';
58
-		$js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/';
59
-		$css_dir    = GIVE_PLUGIN_URL . 'assets/css/';
57
+		$js_dir     = GIVE_PLUGIN_URL.'assets/js/admin/';
58
+		$js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/';
59
+		$css_dir    = GIVE_PLUGIN_URL.'assets/css/';
60 60
 
61 61
 		// Use minified libraries if SCRIPT_DEBUG is turned off
62
-		$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
62
+		$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
63 63
 
64 64
 		// Widget Script
65
-		if ( $hook == 'widgets.php' ) {
65
+		if ($hook == 'widgets.php') {
66 66
 
67
-			wp_enqueue_script( 'give-admin-widgets-scripts', $js_dir . 'admin-widgets' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
67
+			wp_enqueue_script('give-admin-widgets-scripts', $js_dir.'admin-widgets'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
68 68
 		}
69 69
 	}
70 70
 
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
 	 *                        before_widget, and after_widget.
76 76
 	 * @param array $instance The settings for the particular instance of the widget.
77 77
 	 */
78
-	public function widget( $args, $instance ){
79
-		$title = !empty( $instance['title'] ) ? $instance['title'] : '';
80
-		$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
78
+	public function widget($args, $instance) {
79
+		$title = ! empty($instance['title']) ? $instance['title'] : '';
80
+		$title = apply_filters('widget_title', $title, $instance, $this->id_base);
81 81
 
82 82
 		echo $args['before_widget'];
83 83
 
@@ -86,11 +86,11 @@  discard block
 block discarded – undo
86 86
 		 *
87 87
 		 * @since 1.0
88 88
 		 */
89
-		do_action( 'give_before_forms_widget' );
89
+		do_action('give_before_forms_widget');
90 90
 
91
-		echo $title ? $args['before_title'] . $title . $args['after_title'] : '';
91
+		echo $title ? $args['before_title'].$title.$args['after_title'] : '';
92 92
 
93
-		give_get_donation_form( $instance );
93
+		give_get_donation_form($instance);
94 94
 
95 95
 		echo $args['after_widget'];
96 96
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 		 *
100 100
 		 * @since 1.0
101 101
 		 */
102
-		do_action( 'give_after_forms_widget' );
102
+		do_action('give_after_forms_widget');
103 103
 	}
104 104
 
105 105
 	/**
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 *
110 110
 	 * @return string
111 111
 	 */
112
-	public function form( $instance ){
112
+	public function form($instance) {
113 113
 		$defaults = array(
114 114
 			'title'         => '',
115 115
 			'id'            => '',
@@ -119,84 +119,84 @@  discard block
 block discarded – undo
119 119
 			'continue_button_title' => '',
120 120
 		);
121 121
 
122
-		$instance = wp_parse_args( (array) $instance, $defaults );
122
+		$instance = wp_parse_args((array) $instance, $defaults);
123 123
 
124 124
 		// Backward compatibility: Set float labels as default if, it was set as empty previous.
125
-		$instance['float_labels'] = empty( $instance['float_labels'] ) ? 'global' : $instance['float_labels'];
125
+		$instance['float_labels'] = empty($instance['float_labels']) ? 'global' : $instance['float_labels'];
126 126
 
127 127
 		// Query Give Forms
128 128
 		$args = array(
129 129
 			'post_type'      => 'give_forms',
130
-			'posts_per_page' => - 1,
130
+			'posts_per_page' => -1,
131 131
 			'post_status'    => 'publish',
132 132
 		);
133 133
 
134
-		$give_forms = get_posts( $args );
134
+		$give_forms = get_posts($args);
135 135
 		?>
136 136
 		<div class="give_forms_widget_container">
137 137
 
138 138
 			<?php // Widget: widget Title. ?>
139 139
 			<p>
140
-				<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ); ?></label>
141
-				<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php esc_attr_e( $instance['title'] ); ?>" /><br>
142
-				<small class="give-field-description"><?php esc_html_e( 'Leave blank to hide the widget title.', 'give' ); ?></small>
140
+				<label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give'); ?></label>
141
+				<input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php esc_attr_e($instance['title']); ?>" /><br>
142
+				<small class="give-field-description"><?php esc_html_e('Leave blank to hide the widget title.', 'give'); ?></small>
143 143
 			</p>
144 144
 
145 145
 			<?php // Widget: Give Form?>
146 146
 			<p>
147
-				<label for="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"><?php esc_html_e( 'Give Form:', 'give' ); ?></label>
148
-				<select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'id' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>">
149
-					<option value="current"><?php esc_html_e( '- Select -', 'give' ); ?></option>
150
-					<?php foreach ( $give_forms as $give_form ) { ?>
151
-						<?php $form_title = empty( $give_form->post_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $give_form->ID ) : $give_form->post_title; ?>
152
-						<option <?php selected( absint( $instance['id'] ), $give_form->ID ); ?> value="<?php echo esc_attr( $give_form->ID ); ?>"><?php echo $form_title; ?></option>
147
+				<label for="<?php echo esc_attr($this->get_field_id('id')); ?>"><?php esc_html_e('Give Form:', 'give'); ?></label>
148
+				<select class="widefat" name="<?php echo esc_attr($this->get_field_name('id')); ?>" id="<?php echo esc_attr($this->get_field_id('id')); ?>">
149
+					<option value="current"><?php esc_html_e('- Select -', 'give'); ?></option>
150
+					<?php foreach ($give_forms as $give_form) { ?>
151
+						<?php $form_title = empty($give_form->post_title) ? sprintf(__('Untitled (#%s)', 'give'), $give_form->ID) : $give_form->post_title; ?>
152
+						<option <?php selected(absint($instance['id']), $give_form->ID); ?> value="<?php echo esc_attr($give_form->ID); ?>"><?php echo $form_title; ?></option>
153 153
 					<?php } ?>
154 154
 				</select><br>
155
-				<small class="give-field-description"><?php esc_html_e( 'Select a Give Form to embed in this widget.', 'give' ); ?></small>
155
+				<small class="give-field-description"><?php esc_html_e('Select a Give Form to embed in this widget.', 'give'); ?></small>
156 156
 			</p>
157 157
 
158 158
 			<?php // Widget: Display Style ?>
159 159
 			<p class="give_forms_display_style_setting_row">
160
-				<label for="<?php echo esc_attr( $this->get_field_id( 'display_style' ) ); ?>"><?php esc_html_e( 'Display Style:', 'give' ); ?></label><br>
161
-				<label for="<?php echo $this->get_field_id( 'display_style' ); ?>-onpage"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-onpage" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="onpage" <?php checked( $instance['display_style'], 'onpage' ); ?>> <?php echo esc_html__( 'All Fields', 'give' ); ?></label>
162
-				&nbsp;&nbsp;<label for="<?php echo $this->get_field_id( 'display_style' ); ?>-reveal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-reveal" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="reveal" <?php checked( $instance['display_style'], 'reveal' ); ?>> <?php echo esc_html__( 'Reveal', 'give' ); ?></label>
163
-				&nbsp;&nbsp;<label for="<?php echo $this->get_field_id( 'display_style' ); ?>-modal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-modal" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="modal" <?php checked( $instance['display_style'], 'modal' ); ?>> <?php echo esc_html__( 'Modal', 'give' ); ?></label>
164
-				&nbsp;&nbsp;<label for="<?php echo $this->get_field_id( 'display_style' ); ?>-button"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-button" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="button" <?php checked( $instance['display_style'], 'button' ); ?>> <?php echo esc_html__( 'Button', 'give' ); ?></label><br>
160
+				<label for="<?php echo esc_attr($this->get_field_id('display_style')); ?>"><?php esc_html_e('Display Style:', 'give'); ?></label><br>
161
+				<label for="<?php echo $this->get_field_id('display_style'); ?>-onpage"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-onpage" name="<?php echo $this->get_field_name('display_style'); ?>" value="onpage" <?php checked($instance['display_style'], 'onpage'); ?>> <?php echo esc_html__('All Fields', 'give'); ?></label>
162
+				&nbsp;&nbsp;<label for="<?php echo $this->get_field_id('display_style'); ?>-reveal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-reveal" name="<?php echo $this->get_field_name('display_style'); ?>" value="reveal" <?php checked($instance['display_style'], 'reveal'); ?>> <?php echo esc_html__('Reveal', 'give'); ?></label>
163
+				&nbsp;&nbsp;<label for="<?php echo $this->get_field_id('display_style'); ?>-modal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-modal" name="<?php echo $this->get_field_name('display_style'); ?>" value="modal" <?php checked($instance['display_style'], 'modal'); ?>> <?php echo esc_html__('Modal', 'give'); ?></label>
164
+				&nbsp;&nbsp;<label for="<?php echo $this->get_field_id('display_style'); ?>-button"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-button" name="<?php echo $this->get_field_name('display_style'); ?>" value="button" <?php checked($instance['display_style'], 'button'); ?>> <?php echo esc_html__('Button', 'give'); ?></label><br>
165 165
 				<small class="give-field-description">
166
-					<?php echo esc_html__( 'Select a Give Form style.', 'give' ); ?>
166
+					<?php echo esc_html__('Select a Give Form style.', 'give'); ?>
167 167
 				</small>
168 168
 			</p>
169 169
 
170 170
 			<?php // Widget: Continue Button Title. ?>
171 171
 			<p class="give_forms_continue_button_title_setting_row">
172
-				<label for="<?php echo $this->get_field_id( 'continue_button_title' ); ?>"><?php esc_html_e( 'Button Text:', 'give' ); ?></label>
173
-				<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'continue_button_title' ); ?>" name="<?php echo $this->get_field_name( 'continue_button_title' ); ?>" value="<?php esc_attr_e( $instance['continue_button_title'] ); ?>" /><br>
174
-				<small class="give-field-description"><?php esc_html_e( 'The button label for displaying the additional payment fields.', 'give' ); ?></small>
172
+				<label for="<?php echo $this->get_field_id('continue_button_title'); ?>"><?php esc_html_e('Button Text:', 'give'); ?></label>
173
+				<input type="text" class="widefat" id="<?php echo $this->get_field_id('continue_button_title'); ?>" name="<?php echo $this->get_field_name('continue_button_title'); ?>" value="<?php esc_attr_e($instance['continue_button_title']); ?>" /><br>
174
+				<small class="give-field-description"><?php esc_html_e('The button label for displaying the additional payment fields.', 'give'); ?></small>
175 175
 			</p>
176 176
 
177 177
 			<?php // Widget: Floating Labels ?>
178 178
 			<p>
179
-				<label for="<?php echo esc_attr( $this->get_field_id( 'float_labels' ) ); ?>"><?php esc_html_e( 'Floating Labels (optional):', 'give' ); ?></label><br>
180
-				<label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-global"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-global" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="global" <?php checked( $instance['float_labels'], 'global' ); ?>> <?php echo esc_html__( 'Global Option', 'give' ); ?></label>
181
-				&nbsp;&nbsp;<label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-enabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-enabled" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="enabled" <?php checked( $instance['float_labels'], 'enabled' ); ?>> <?php echo esc_html__( 'Yes', 'give' ); ?></label>
182
-				&nbsp;&nbsp;<label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-disabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-disabled" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="disabled" <?php checked( $instance['float_labels'], 'disabled' ); ?>> <?php echo esc_html__( 'No', 'give' ); ?></label><br>
179
+				<label for="<?php echo esc_attr($this->get_field_id('float_labels')); ?>"><?php esc_html_e('Floating Labels (optional):', 'give'); ?></label><br>
180
+				<label for="<?php echo $this->get_field_id('float_labels'); ?>-global"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-global" name="<?php echo $this->get_field_name('float_labels'); ?>" value="global" <?php checked($instance['float_labels'], 'global'); ?>> <?php echo esc_html__('Global Option', 'give'); ?></label>
181
+				&nbsp;&nbsp;<label for="<?php echo $this->get_field_id('float_labels'); ?>-enabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-enabled" name="<?php echo $this->get_field_name('float_labels'); ?>" value="enabled" <?php checked($instance['float_labels'], 'enabled'); ?>> <?php echo esc_html__('Yes', 'give'); ?></label>
182
+				&nbsp;&nbsp;<label for="<?php echo $this->get_field_id('float_labels'); ?>-disabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-disabled" name="<?php echo $this->get_field_name('float_labels'); ?>" value="disabled" <?php checked($instance['float_labels'], 'disabled'); ?>> <?php echo esc_html__('No', 'give'); ?></label><br>
183 183
 				<small class="give-field-description">
184 184
 					<?php
185 185
 					printf(
186 186
 					/* translators: %s: http://docs.givewp.com/form-floating-labels */
187
-						__( 'Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give' ),
188
-						esc_url( 'http://docs.givewp.com/form-floating-labels' )
187
+						__('Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give'),
188
+						esc_url('http://docs.givewp.com/form-floating-labels')
189 189
 					);
190 190
 					?></small>
191 191
 			</p>
192 192
 
193 193
 			<?php // Widget: Display Content ?>
194 194
 			<p>
195
-				<label for="<?php echo esc_attr( $this->get_field_id( 'show_content' ) ); ?>"><?php esc_html_e( 'Display Content (optional):', 'give' ); ?></label><br>
196
-				<label for="<?php echo $this->get_field_id( 'show_content' ); ?>-none"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'show_content' ); ?>-none" name="<?php echo $this->get_field_name( 'show_content' ); ?>" value="none" <?php checked( $instance['show_content'], 'none' ); ?>> <?php echo esc_html__( 'None', 'give' ); ?></label>
197
-				&nbsp;&nbsp;<label for="<?php echo $this->get_field_id( 'show_content' ); ?>-above"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'show_content' ); ?>-above" name="<?php echo $this->get_field_name( 'show_content' ); ?>" value="above" <?php checked( $instance['show_content'], 'above' ); ?>> <?php echo esc_html__( 'Above', 'give' ); ?></label>
198
-				&nbsp;&nbsp;<label for="<?php echo $this->get_field_id( 'show_content' ); ?>-below"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'show_content' ); ?>-below" name="<?php echo $this->get_field_name( 'show_content' ); ?>" value="below" <?php checked( $instance['show_content'], 'below' ); ?>> <?php echo esc_html__( 'Below', 'give' ); ?></label><br>
199
-				<small class="give-field-description"><?php esc_html_e( 'Override the display content setting for this Give form.', 'give' ); ?></small>
195
+				<label for="<?php echo esc_attr($this->get_field_id('show_content')); ?>"><?php esc_html_e('Display Content (optional):', 'give'); ?></label><br>
196
+				<label for="<?php echo $this->get_field_id('show_content'); ?>-none"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('show_content'); ?>-none" name="<?php echo $this->get_field_name('show_content'); ?>" value="none" <?php checked($instance['show_content'], 'none'); ?>> <?php echo esc_html__('None', 'give'); ?></label>
197
+				&nbsp;&nbsp;<label for="<?php echo $this->get_field_id('show_content'); ?>-above"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('show_content'); ?>-above" name="<?php echo $this->get_field_name('show_content'); ?>" value="above" <?php checked($instance['show_content'], 'above'); ?>> <?php echo esc_html__('Above', 'give'); ?></label>
198
+				&nbsp;&nbsp;<label for="<?php echo $this->get_field_id('show_content'); ?>-below"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('show_content'); ?>-below" name="<?php echo $this->get_field_name('show_content'); ?>" value="below" <?php checked($instance['show_content'], 'below'); ?>> <?php echo esc_html__('Below', 'give'); ?></label><br>
199
+				<small class="give-field-description"><?php esc_html_e('Override the display content setting for this Give form.', 'give'); ?></small>
200 200
 		</div>
201 201
 		<?php
202 202
 	}
@@ -206,8 +206,8 @@  discard block
 block discarded – undo
206 206
 	 *
207 207
 	 * @return void
208 208
 	 */
209
-	function widget_init(){
210
-		register_widget( $this->self );
209
+	function widget_init() {
210
+		register_widget($this->self);
211 211
 	}
212 212
 
213 213
 	/**
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 	 *
219 219
 	 * @return array
220 220
 	 */
221
-	public function update( $new_instance, $old_instance ){
221
+	public function update($new_instance, $old_instance) {
222 222
 		$this->flush_widget_cache();
223 223
 
224 224
 		return $new_instance;
@@ -229,8 +229,8 @@  discard block
 block discarded – undo
229 229
 	 *
230 230
 	 * @return void
231 231
 	 */
232
-	public function flush_widget_cache(){
233
-		wp_cache_delete( $this->self, 'widget' );
232
+	public function flush_widget_cache() {
233
+		wp_cache_delete($this->self, 'widget');
234 234
 	}
235 235
 }
236 236
 
Please login to merge, or discard this patch.
includes/actions.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -25,14 +25,14 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function give_get_actions() {
27 27
 
28
-	$_get_action = ! empty( $_GET['give_action'] ) ? $_GET['give_action'] : null;
28
+	$_get_action = ! empty($_GET['give_action']) ? $_GET['give_action'] : null;
29 29
 
30 30
 	// Add backward compatibility to give-action param ( $_GET )
31
-	if ( empty( $_get_action ) ) {
32
-		$_get_action = ! empty( $_GET['give-action'] ) ? $_GET['give-action'] : null;
31
+	if (empty($_get_action)) {
32
+		$_get_action = ! empty($_GET['give-action']) ? $_GET['give-action'] : null;
33 33
 	}
34 34
 
35
-	if ( isset( $_get_action ) ) {
35
+	if (isset($_get_action)) {
36 36
 		/**
37 37
 		 * Fires in WordPress init or admin init, when give_action is present in $_GET.
38 38
 		 *
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
 		 *
41 41
 		 * @param array $_GET Array of HTTP GET variables.
42 42
 		 */
43
-		do_action( "give_{$_get_action}", $_GET );
43
+		do_action("give_{$_get_action}", $_GET);
44 44
 	}
45 45
 
46 46
 }
47 47
 
48
-add_action( 'init', 'give_get_actions' );
48
+add_action('init', 'give_get_actions');
49 49
 
50 50
 /**
51 51
  * Hooks Give actions, when present in the $_POST super global. Every give_action
@@ -58,14 +58,14 @@  discard block
 block discarded – undo
58 58
  */
59 59
 function give_post_actions() {
60 60
 
61
-	$_post_action = ! empty( $_POST['give_action'] ) ? $_POST['give_action'] : null;
61
+	$_post_action = ! empty($_POST['give_action']) ? $_POST['give_action'] : null;
62 62
 
63 63
 	// Add backward compatibility to give-action param ( $_POST ).
64
-	if ( empty( $_post_action ) ) {
65
-		$_post_action = ! empty( $_POST['give-action'] ) ? $_POST['give-action'] : null;
64
+	if (empty($_post_action)) {
65
+		$_post_action = ! empty($_POST['give-action']) ? $_POST['give-action'] : null;
66 66
 	}
67 67
 
68
-	if ( isset( $_post_action ) ) {
68
+	if (isset($_post_action)) {
69 69
 		/**
70 70
 		 * Fires in WordPress init or admin init, when give_action is present in $_POST.
71 71
 		 *
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
 		 *
74 74
 		 * @param array $_POST Array of HTTP POST variables.
75 75
 		 */
76
-		do_action( "give_{$_post_action}", $_POST );
76
+		do_action("give_{$_post_action}", $_POST);
77 77
 	}
78 78
 
79 79
 }
80 80
 
81
-add_action( 'init', 'give_post_actions' );
81
+add_action('init', 'give_post_actions');
82 82
 
83 83
 /**
84 84
  * Connect WordPress user with Donor.
@@ -90,17 +90,17 @@  discard block
 block discarded – undo
90 90
  *
91 91
  * @return void
92 92
  */
93
-function give_connect_donor_to_wpuser( $user_id, $user_data ) {
93
+function give_connect_donor_to_wpuser($user_id, $user_data) {
94 94
 	/* @var Give_Donor $donor */
95
-	$donor = new Give_Donor( $user_data['user_email'] );
95
+	$donor = new Give_Donor($user_data['user_email']);
96 96
 
97 97
 	// Validate donor id and check if do nor is already connect to wp user or not.
98
-	if ( $donor->id && ! $donor->user_id ) {
98
+	if ($donor->id && ! $donor->user_id) {
99 99
 
100 100
 		// Update donor user_id.
101
-		if ( $donor->update( array( 'user_id' => $user_id ) ) ) {
102
-			$donor_note = sprintf( esc_html__( 'WordPress user #%d is connected to #%d', 'give' ), $user_id, $donor->id );
103
-			$donor->add_note( $donor_note );
101
+		if ($donor->update(array('user_id' => $user_id))) {
102
+			$donor_note = sprintf(esc_html__('WordPress user #%d is connected to #%d', 'give'), $user_id, $donor->id);
103
+			$donor->add_note($donor_note);
104 104
 
105 105
 			// Update user_id meta in payments.
106 106
 			// if( ! empty( $donor->payment_ids ) && ( $donations = explode( ',', $donor->payment_ids ) ) ) {
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	}
114 114
 }
115 115
 
116
-add_action( 'give_insert_user', 'give_connect_donor_to_wpuser', 10, 2 );
116
+add_action('give_insert_user', 'give_connect_donor_to_wpuser', 10, 2);
117 117
 
118 118
 
119 119
 /**
@@ -127,45 +127,45 @@  discard block
 block discarded – undo
127 127
  */
128 128
 function give_validate_license_when_site_migrated() {
129 129
 	// Store current site address if not already stored.
130
-	$home_url_parts              = parse_url( home_url() );
131
-	$home_url                    = isset( $home_url_parts['host'] ) ? $home_url_parts['host'] : false;
132
-	$home_url                    .= isset( $home_url_parts['path'] ) ? $home_url_parts['path'] : '';
133
-	$site_address_before_migrate = get_option( 'give_site_address_before_migrate' );
130
+	$home_url_parts              = parse_url(home_url());
131
+	$home_url                    = isset($home_url_parts['host']) ? $home_url_parts['host'] : false;
132
+	$home_url .= isset($home_url_parts['path']) ? $home_url_parts['path'] : '';
133
+	$site_address_before_migrate = get_option('give_site_address_before_migrate');
134 134
 
135 135
 	// Need $home_url to proceed.
136
-	if ( ! $home_url ) {
136
+	if ( ! $home_url) {
137 137
 		return;
138 138
 	}
139 139
 
140 140
 	// Save site address.
141
-	if ( ! $site_address_before_migrate ) {
141
+	if ( ! $site_address_before_migrate) {
142 142
 		// Update site address.
143
-		update_option( 'give_site_address_before_migrate', $home_url );
143
+		update_option('give_site_address_before_migrate', $home_url);
144 144
 
145 145
 		return;
146 146
 	}
147 147
 
148 148
 	// Backwards compat. for before when we were storing URL scheme.
149
-	if ( strpos( $site_address_before_migrate, 'http' ) ) {
150
-		$site_address_before_migrate = parse_url( $site_address_before_migrate );
151
-		$site_address_before_migrate = isset( $site_address_before_migrate['host'] ) ? $site_address_before_migrate['host'] : false;
149
+	if (strpos($site_address_before_migrate, 'http')) {
150
+		$site_address_before_migrate = parse_url($site_address_before_migrate);
151
+		$site_address_before_migrate = isset($site_address_before_migrate['host']) ? $site_address_before_migrate['host'] : false;
152 152
 
153 153
 		// Add path for multisite installs.
154
-		$site_address_before_migrate .= isset( $site_address_before_migrate['path'] ) ? $site_address_before_migrate['path'] : '';
154
+		$site_address_before_migrate .= isset($site_address_before_migrate['path']) ? $site_address_before_migrate['path'] : '';
155 155
 	}
156 156
 
157 157
 	// If the two URLs don't match run CRON.
158
-	if ( $home_url !== $site_address_before_migrate ) {
158
+	if ($home_url !== $site_address_before_migrate) {
159 159
 		// Immediately run cron.
160
-		wp_schedule_single_event( time(), 'give_validate_license_when_site_migrated' );
160
+		wp_schedule_single_event(time(), 'give_validate_license_when_site_migrated');
161 161
 
162 162
 		// Update site address.
163
-		update_option( 'give_site_address_before_migrate', $home_url );
163
+		update_option('give_site_address_before_migrate', $home_url);
164 164
 	}
165 165
 
166 166
 }
167 167
 
168
-add_action( 'admin_init', 'give_validate_license_when_site_migrated' );
168
+add_action('admin_init', 'give_validate_license_when_site_migrated');
169 169
 
170 170
 
171 171
 /**
@@ -175,19 +175,19 @@  discard block
 block discarded – undo
175 175
  *
176 176
  * @param $data
177 177
  */
178
-function give_donor_batch_export_complete( $data ) {
178
+function give_donor_batch_export_complete($data) {
179 179
 	// Remove donor ids cache.
180 180
 	if (
181
-		isset( $data['class'] )
181
+		isset($data['class'])
182 182
 		&& 'Give_Batch_Donors_Export' === $data['class']
183
-		&& ! empty( $data['forms'] )
184
-		&& isset( $data['give_export_option']['query_id'] )
183
+		&& ! empty($data['forms'])
184
+		&& isset($data['give_export_option']['query_id'])
185 185
 	) {
186
-		Give_Cache::delete( Give_Cache::get_key( $data['give_export_option']['query_id'] ) );
186
+		Give_Cache::delete(Give_Cache::get_key($data['give_export_option']['query_id']));
187 187
 	}
188 188
 }
189 189
 
190
-add_action( 'give_file_export_complete', 'give_donor_batch_export_complete' );
190
+add_action('give_file_export_complete', 'give_donor_batch_export_complete');
191 191
 
192 192
 /**
193 193
  * Print css for wordpress setting pages.
@@ -198,12 +198,12 @@  discard block
 block discarded – undo
198 198
 	/* @var WP_Screen $screen */
199 199
 	$screen = get_current_screen();
200 200
 
201
-	if ( ! ( $screen instanceof WP_Screen ) ) {
201
+	if ( ! ($screen instanceof WP_Screen)) {
202 202
 		return false;
203 203
 	}
204 204
 
205
-	switch ( true ) {
206
-		case ( 'plugins' === $screen->base || 'plugins-network' === $screen->base ):
205
+	switch (true) {
206
+		case ('plugins' === $screen->base || 'plugins-network' === $screen->base):
207 207
 			?>
208 208
 			<style>
209 209
 				tr.active.update + tr.give-addon-notice-tr td {
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 	}
241 241
 }
242 242
 
243
-add_action( 'admin_head', 'give_admin_quick_css' );
243
+add_action('admin_head', 'give_admin_quick_css');
244 244
 
245 245
 
246 246
 /**
@@ -252,31 +252,31 @@  discard block
 block discarded – undo
252 252
  *
253 253
  * @return void
254 254
  */
255
-function give_set_donation_levels_max_min_amount( $form_id ) {
255
+function give_set_donation_levels_max_min_amount($form_id) {
256 256
 	if (
257
-		( 'set' === $_POST['_give_price_option'] ) ||
258
-		( in_array( '_give_donation_levels', $_POST ) && count( $_POST['_give_donation_levels'] ) <= 0 ) ||
259
-		! ( $donation_levels_amounts = wp_list_pluck( $_POST['_give_donation_levels'], '_give_amount' ) )
257
+		('set' === $_POST['_give_price_option']) ||
258
+		(in_array('_give_donation_levels', $_POST) && count($_POST['_give_donation_levels']) <= 0) ||
259
+		! ($donation_levels_amounts = wp_list_pluck($_POST['_give_donation_levels'], '_give_amount'))
260 260
 	) {
261 261
 		// Delete old meta.
262
-		give_delete_meta( $form_id, '_give_levels_minimum_amount' );
263
-		give_delete_meta( $form_id, '_give_levels_maximum_amount' );
262
+		give_delete_meta($form_id, '_give_levels_minimum_amount');
263
+		give_delete_meta($form_id, '_give_levels_maximum_amount');
264 264
 
265 265
 		return;
266 266
 	}
267 267
 
268 268
 	// Sanitize donation level amounts.
269
-	$donation_levels_amounts = array_map( 'give_maybe_sanitize_amount', $donation_levels_amounts );
269
+	$donation_levels_amounts = array_map('give_maybe_sanitize_amount', $donation_levels_amounts);
270 270
 
271
-	$min_amount = min( $donation_levels_amounts );
272
-	$max_amount = max( $donation_levels_amounts );
271
+	$min_amount = min($donation_levels_amounts);
272
+	$max_amount = max($donation_levels_amounts);
273 273
 
274 274
 	// Set Minimum and Maximum amount for Multi Level Donation Forms.
275
-	give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount_for_db( $min_amount ) : 0 );
276
-	give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount_for_db( $max_amount ) : 0 );
275
+	give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount_for_db($min_amount) : 0);
276
+	give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount_for_db($max_amount) : 0);
277 277
 }
278 278
 
279
-add_action( 'give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30 );
279
+add_action('give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30);
280 280
 
281 281
 
282 282
 /**
@@ -286,24 +286,24 @@  discard block
 block discarded – undo
286 286
  *
287 287
  * @param int $payment_id
288 288
  */
289
-function _give_save_donor_billing_address( $payment_id ) {
289
+function _give_save_donor_billing_address($payment_id) {
290 290
 	/* @var Give_Payment $donation */
291
-	$donation = new Give_Payment( $payment_id );
291
+	$donation = new Give_Payment($payment_id);
292 292
 
293 293
 	// Bailout
294
-	if ( ! $donation->customer_id ) {
294
+	if ( ! $donation->customer_id) {
295 295
 		return;
296 296
 	}
297 297
 
298 298
 
299 299
 	/* @var Give_Donor $donor */
300
-	$donor = new Give_Donor( $donation->customer_id );
300
+	$donor = new Give_Donor($donation->customer_id);
301 301
 
302 302
 	// Save address.
303
-	$donor->add_address( 'billing[]', $donation->address );
303
+	$donor->add_address('billing[]', $donation->address);
304 304
 }
305 305
 
306
-add_action( 'give_complete_donation', '_give_save_donor_billing_address', 9999 );
306
+add_action('give_complete_donation', '_give_save_donor_billing_address', 9999);
307 307
 
308 308
 
309 309
 /**
@@ -313,25 +313,25 @@  discard block
 block discarded – undo
313 313
  *
314 314
  * @param array $args
315 315
  */
316
-function give_update_log_form_id( $args ) {
317
-	$new_form_id = absint( $args[0] );
318
-	$payment_id  = absint( $args[1] );
319
-	$logs        = Give()->logs->get_logs( $payment_id );
316
+function give_update_log_form_id($args) {
317
+	$new_form_id = absint($args[0]);
318
+	$payment_id  = absint($args[1]);
319
+	$logs        = Give()->logs->get_logs($payment_id);
320 320
 
321 321
 	// Bailout.
322
-	if ( empty( $logs ) ) {
322
+	if (empty($logs)) {
323 323
 		return;
324 324
 	}
325 325
 
326 326
 	/* @var object $log */
327
-	foreach ( $logs as $log ) {
328
-		Give()->logs->logmeta_db->update_meta( $log->ID, '_give_log_form_id', $new_form_id );
327
+	foreach ($logs as $log) {
328
+		Give()->logs->logmeta_db->update_meta($log->ID, '_give_log_form_id', $new_form_id);
329 329
 	}
330 330
 
331 331
 	// Delete cache.
332 332
 	Give()->logs->delete_cache();
333 333
 }
334 334
 
335
-add_action( 'give_update_log_form_id', 'give_update_log_form_id' );
335
+add_action('give_update_log_form_id', 'give_update_log_form_id');
336 336
 
337 337
 
Please login to merge, or discard this patch.
includes/class-give-db-logs-meta.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
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
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		/* @var WPDB $wpdb */
51 51
 		global $wpdb;
52 52
 
53
-		$wpdb->logmeta     = $this->table_name = $wpdb->prefix . 'give_logmeta';
53
+		$wpdb->logmeta     = $this->table_name = $wpdb->prefix.'give_logmeta';
54 54
 		$this->primary_key = 'meta_id';
55 55
 		$this->version     = '1.0';
56 56
 
@@ -86,18 +86,18 @@  discard block
 block discarded – undo
86 86
 	 *
87 87
 	 * @return bool
88 88
 	 */
89
-	public function delete_row( $log_id = 0 ) {
89
+	public function delete_row($log_id = 0) {
90 90
 		/* @var WPDB $wpdb */
91 91
 		global $wpdb;
92 92
 
93 93
 		// Row ID must be positive integer
94
-		$log_id = absint( $log_id );
94
+		$log_id = absint($log_id);
95 95
 
96
-		if ( empty( $log_id ) ) {
96
+		if (empty($log_id)) {
97 97
 			return false;
98 98
 		}
99 99
 
100
-		if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE log_id = %d", $log_id ) ) ) {
100
+		if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE log_id = %d", $log_id))) {
101 101
 			return false;
102 102
 		}
103 103
 
@@ -126,10 +126,10 @@  discard block
 block discarded – undo
126 126
 			KEY meta_key (meta_key)
127 127
 			) {$charset_collate};";
128 128
 
129
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
130
-		dbDelta( $sql );
129
+		require_once(ABSPATH.'wp-admin/includes/upgrade.php');
130
+		dbDelta($sql);
131 131
 
132
-		update_option( $this->table_name . '_db_version', $this->version );
132
+		update_option($this->table_name.'_db_version', $this->version);
133 133
 	}
134 134
 
135 135
 	/**
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 *
143 143
 	 * @return bool
144 144
 	 */
145
-	protected function is_valid_post_type( $ID ) {
145
+	protected function is_valid_post_type($ID) {
146 146
 		return $ID && true;
147 147
 	}
148 148
 }
Please login to merge, or discard this patch.
includes/class-give-tooltips.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 *
21 21
 	 * @return array
22 22
 	 */
23
-	private function set_toottip_args( $args ) {
23
+	private function set_toottip_args($args) {
24 24
 		$args = wp_parse_args(
25 25
 			$args,
26 26
 			array(
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
 
63 63
 		// Auto set width of tooltip.
64 64
 		if (
65
-			! empty( $args['auto_width'] ) &&
66
-			! empty( $args['label'] ) &&
67
-			empty( $args['size'] )
65
+			! empty($args['auto_width']) &&
66
+			! empty($args['label']) &&
67
+			empty($args['size'])
68 68
 		) {
69
-			if ( 15 < str_word_count( $args['label'] ) ) {
69
+			if (15 < str_word_count($args['label'])) {
70 70
 				$args['size'] = 'large';
71
-			} elseif ( 7 < str_word_count( $args['label'] ) ) {
71
+			} elseif (7 < str_word_count($args['label'])) {
72 72
 				$args['size'] = 'medium';
73 73
 			}
74 74
 		}
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 	 *
88 88
 	 * @return string
89 89
 	 */
90
-	public function render( $args ) {
91
-		$args = $this->set_toottip_args( $args );
90
+	public function render($args) {
91
+		$args = $this->set_toottip_args($args);
92 92
 
93 93
 		$tooltip_pos = array(
94 94
 			'top'          => 'hint--top',
@@ -118,21 +118,21 @@  discard block
 block discarded – undo
118 118
 		$args['attributes']['aria-label'] = $args['label'];
119 119
 
120 120
 		// Set classes.
121
-		$args['attributes']['class'] = ! empty( $args['attributes']['class'] ) ? $args['attributes']['class'] : '';
122
-		$args['attributes']['class'] .= " {$tooltip_pos[ $args['position'] ]}";
123
-		$args['attributes']['class'] .= ! empty( $args['status'] ) ? " {$tooltip_status[ $args['status'] ]}" : '';
124
-		$args['attributes']['class'] .= ! empty( $args['size'] ) ? " {$tooltip_size[ $args['size'] ]}" : '';
121
+		$args['attributes']['class'] = ! empty($args['attributes']['class']) ? $args['attributes']['class'] : '';
122
+		$args['attributes']['class'] .= " {$tooltip_pos[$args['position']]}";
123
+		$args['attributes']['class'] .= ! empty($args['status']) ? " {$tooltip_status[$args['status']]}" : '';
124
+		$args['attributes']['class'] .= ! empty($args['size']) ? " {$tooltip_size[$args['size']]}" : '';
125 125
 		$args['attributes']['class'] .= $args['show_always'] ? ' hint--always' : '';
126 126
 		$args['attributes']['class'] .= $args['round_edges'] ? ' hint--rounded' : '';
127 127
 		$args['attributes']['class'] .= $args['animate'] ? ' hint--bounce' : ' hint--no-animate';
128
-		$args['attributes']['class'] = trim( $args['attributes']['class'] );
128
+		$args['attributes']['class'] = trim($args['attributes']['class']);
129 129
 
130 130
 		// Set link attribute in tooltip has anchor tag.
131
-		if ( 'a' === $args['tag'] && ! empty( $args['link'] ) ) {
132
-			$args['attributes']['href'] = esc_url( $args['link'] );
131
+		if ('a' === $args['tag'] && ! empty($args['link'])) {
132
+			$args['attributes']['href'] = esc_url($args['link']);
133 133
 		}
134 134
 
135
-		return sprintf( '<%1$s %2$s rel="tooltip">%3$s</%1$s>', $args['tag'], give_get_attribute_str( $args['attributes'] ), $args['tag_content'] );
135
+		return sprintf('<%1$s %2$s rel="tooltip">%3$s</%1$s>', $args['tag'], give_get_attribute_str($args['attributes']), $args['tag_content']);
136 136
 	}
137 137
 
138 138
 
@@ -146,9 +146,9 @@  discard block
 block discarded – undo
146 146
 	 *
147 147
 	 * @return string
148 148
 	 */
149
-	function render_link( $args ) {
149
+	function render_link($args) {
150 150
 		$args['tag']    = 'a';
151
-		$tooltip_markup = $this->render( $args );
151
+		$tooltip_markup = $this->render($args);
152 152
 
153 153
 		return $tooltip_markup;
154 154
 	}
@@ -163,14 +163,14 @@  discard block
 block discarded – undo
163 163
 	 *
164 164
 	 * @return string
165 165
 	 */
166
-	function render_span( $args ) {
166
+	function render_span($args) {
167 167
 		// Set tooltip args from string.
168
-		if ( is_string( $args ) ) {
169
-			$args = array( 'label' => $args );
168
+		if (is_string($args)) {
169
+			$args = array('label' => $args);
170 170
 		}
171 171
 
172 172
 		$args['tag']    = 'span';
173
-		$tooltip_markup = $this->render( $args );
173
+		$tooltip_markup = $this->render($args);
174 174
 
175 175
 		return $tooltip_markup;
176 176
 	}
@@ -185,15 +185,15 @@  discard block
 block discarded – undo
185 185
 	 *
186 186
 	 * @return string
187 187
 	 */
188
-	function render_help( $args ) {
188
+	function render_help($args) {
189 189
 		// Set tooltip args from string.
190
-		if ( is_string( $args ) ) {
191
-			$args = array( 'label' => $args );
190
+		if (is_string($args)) {
191
+			$args = array('label' => $args);
192 192
 		}
193 193
 
194 194
 		$args['tag_content']         = '<i class="give-icon give-icon-question"></i>';
195 195
 		$args['attributes']['class'] = 'give-tooltip';
196
-		$tooltip_markup              = $this->render_span( $args );
196
+		$tooltip_markup              = $this->render_span($args);
197 197
 
198 198
 		return $tooltip_markup;
199 199
 	}
Please login to merge, or discard this patch.
includes/error-tracking.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  * @return array|bool array if errors are present, false if none found
26 26
  */
27 27
 function give_get_errors() {
28
-	return Give()->session->get( 'give_errors' );
28
+	return Give()->session->get('give_errors');
29 29
 }
30 30
 
31 31
 /**
@@ -42,23 +42,23 @@  discard block
 block discarded – undo
42 42
  *
43 43
  * @return void
44 44
  */
45
-function give_set_error( $error_id, $error_message, $notice_args = array() ) {
45
+function give_set_error($error_id, $error_message, $notice_args = array()) {
46 46
 	$errors = give_get_errors();
47
-	if ( ! $errors ) {
47
+	if ( ! $errors) {
48 48
 		$errors = array();
49 49
 	}
50 50
 
51
-	if( is_array( $notice_args ) && ! empty( $notice_args ) ) {
52
-		$errors[ $error_id ] = array(
51
+	if (is_array($notice_args) && ! empty($notice_args)) {
52
+		$errors[$error_id] = array(
53 53
 			'message'     => $error_message,
54 54
 			'notice_args' => $notice_args,
55 55
 		);
56 56
 	} else {
57 57
 		// Backward compatibility v<1.8.11.
58
-		$errors[ $error_id ] = $error_message;
58
+		$errors[$error_id] = $error_message;
59 59
 	}
60 60
 
61
-	Give()->session->set( 'give_errors', $errors );
61
+	Give()->session->set('give_errors', $errors);
62 62
 }
63 63
 
64 64
 /**
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
  * @return void
70 70
  */
71 71
 function give_clear_errors() {
72
-	Give()->session->set( 'give_errors', null );
72
+	Give()->session->set('give_errors', null);
73 73
 }
74 74
 
75 75
 /**
@@ -82,19 +82,19 @@  discard block
 block discarded – undo
82 82
  *
83 83
  * @return void
84 84
  */
85
-function give_unset_error( $error_id ) {
85
+function give_unset_error($error_id) {
86 86
 	$errors = give_get_errors();
87
-	if ( $errors ) {
87
+	if ($errors) {
88 88
 		/**
89 89
 		 * Check If $error_id exists in the array.
90 90
 		 * If exists then unset it.
91 91
 		 *
92 92
 		 * @since 1.8.13
93 93
 		 */
94
-		if ( isset( $errors[ $error_id ] ) ) {
95
-			unset( $errors[ $error_id ] );
94
+		if (isset($errors[$error_id])) {
95
+			unset($errors[$error_id]);
96 96
 		}
97
-		Give()->session->set( 'give_errors', $errors );
97
+		Give()->session->set('give_errors', $errors);
98 98
 	}
99 99
 }
100 100
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
  * @return string
106 106
  */
107 107
 function _give_die_handler() {
108
-	if ( defined( 'GIVE_UNIT_TESTS' ) ) {
108
+	if (defined('GIVE_UNIT_TESTS')) {
109 109
 		return '_give_die_handler';
110 110
 	} else {
111 111
 		die();
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
  *
126 126
  * @return void
127 127
  */
128
-function give_die( $message = '', $title = '', $status = 400 ) {
129
-	add_filter( 'wp_die_ajax_handler', '_give_die_handler', 10, 3 );
130
-	add_filter( 'wp_die_handler', '_give_die_handler', 10, 3 );
131
-	wp_die( $message, $title, array( 'response' => $status ) );
128
+function give_die($message = '', $title = '', $status = 400) {
129
+	add_filter('wp_die_ajax_handler', '_give_die_handler', 10, 3);
130
+	add_filter('wp_die_handler', '_give_die_handler', 10, 3);
131
+	wp_die($message, $title, array('response' => $status));
132 132
 }
Please login to merge, or discard this patch.
includes/payments/actions.php 1 patch
Spacing   +106 added lines, -110 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -28,21 +28,21 @@  discard block
 block discarded – undo
28 28
  *
29 29
  * @return void
30 30
  */
31
-function give_complete_purchase( $payment_id, $new_status, $old_status ) {
31
+function give_complete_purchase($payment_id, $new_status, $old_status) {
32 32
 
33 33
 	// Make sure that payments are only completed once.
34
-	if ( $old_status == 'publish' || $old_status == 'complete' ) {
34
+	if ($old_status == 'publish' || $old_status == 'complete') {
35 35
 		return;
36 36
 	}
37 37
 
38 38
 	// Make sure the payment completion is only processed when new status is complete.
39
-	if ( $new_status != 'publish' && $new_status != 'complete' ) {
39
+	if ($new_status != 'publish' && $new_status != 'complete') {
40 40
 		return;
41 41
 	}
42 42
 
43
-	$payment = new Give_Payment( $payment_id );
43
+	$payment = new Give_Payment($payment_id);
44 44
 
45
-	$creation_date  = get_post_field( 'post_date', $payment_id, 'raw' );
45
+	$creation_date  = get_post_field('post_date', $payment_id, 'raw');
46 46
 	$payment_meta   = $payment->payment_meta;
47 47
 	$completed_date = $payment->completed_date;
48 48
 	$user_info      = $payment->user_info;
@@ -58,12 +58,12 @@  discard block
 block discarded – undo
58 58
 	 *
59 59
 	 * @param int $payment_id The ID of the payment.
60 60
 	 */
61
-	do_action( 'give_pre_complete_donation', $payment_id );
61
+	do_action('give_pre_complete_donation', $payment_id);
62 62
 
63 63
 	// Ensure these actions only run once, ever.
64
-	if ( empty( $completed_date ) ) {
64
+	if (empty($completed_date)) {
65 65
 
66
-		give_record_donation_in_log( $form_id, $payment_id, $price_id, $creation_date );
66
+		give_record_donation_in_log($form_id, $payment_id, $price_id, $creation_date);
67 67
 
68 68
 		/**
69 69
 		 * Fires after logging donation record.
@@ -74,29 +74,29 @@  discard block
 block discarded – undo
74 74
 		 * @param int   $payment_id   The ID number of the payment.
75 75
 		 * @param array $payment_meta The payment meta.
76 76
 		 */
77
-		do_action( 'give_complete_form_donation', $form_id, $payment_id, $payment_meta );
77
+		do_action('give_complete_form_donation', $form_id, $payment_id, $payment_meta);
78 78
 
79 79
 	}
80 80
 
81 81
 	// Increase the earnings for this form ID.
82
-	give_increase_earnings( $form_id, $amount );
83
-	give_increase_donation_count( $form_id );
82
+	give_increase_earnings($form_id, $amount);
83
+	give_increase_donation_count($form_id);
84 84
 
85 85
 	// @todo: Refresh only range related stat cache
86 86
 	give_delete_donation_stats();
87 87
 
88 88
 	// Increase the donor's donation stats.
89
-	$donor = new Give_Donor( $donor_id );
89
+	$donor = new Give_Donor($donor_id);
90 90
 	$donor->increase_purchase_count();
91
-	$donor->increase_value( $amount );
91
+	$donor->increase_value($amount);
92 92
 
93
-	give_increase_total_earnings( $amount );
93
+	give_increase_total_earnings($amount);
94 94
 
95 95
 	// Ensure this action only runs once ever.
96
-	if ( empty( $completed_date ) ) {
96
+	if (empty($completed_date)) {
97 97
 
98 98
 		// Save the completed date.
99
-		$payment->completed_date = current_time( 'mysql' );
99
+		$payment->completed_date = current_time('mysql');
100 100
 		$payment->save();
101 101
 
102 102
 		/**
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
 		 *
107 107
 		 * @param int $payment_id The ID of the payment.
108 108
 		 */
109
-		do_action( 'give_complete_donation', $payment_id );
109
+		do_action('give_complete_donation', $payment_id);
110 110
 	}
111 111
 
112 112
 }
113 113
 
114
-add_action( 'give_update_payment_status', 'give_complete_purchase', 100, 3 );
114
+add_action('give_update_payment_status', 'give_complete_purchase', 100, 3);
115 115
 
116 116
 
117 117
 /**
@@ -125,20 +125,20 @@  discard block
 block discarded – undo
125 125
  *
126 126
  * @return void
127 127
  */
128
-function give_record_status_change( $payment_id, $new_status, $old_status ) {
128
+function give_record_status_change($payment_id, $new_status, $old_status) {
129 129
 
130 130
 	// Get the list of statuses so that status in the payment note can be translated.
131 131
 	$stati      = give_get_payment_statuses();
132
-	$old_status = isset( $stati[ $old_status ] ) ? $stati[ $old_status ] : $old_status;
133
-	$new_status = isset( $stati[ $new_status ] ) ? $stati[ $new_status ] : $new_status;
132
+	$old_status = isset($stati[$old_status]) ? $stati[$old_status] : $old_status;
133
+	$new_status = isset($stati[$new_status]) ? $stati[$new_status] : $new_status;
134 134
 
135 135
 	// translators: 1: old status 2: new status.
136
-	$status_change = sprintf( esc_html__( 'Status changed from %1$s to %2$s.', 'give' ), $old_status, $new_status );
136
+	$status_change = sprintf(esc_html__('Status changed from %1$s to %2$s.', 'give'), $old_status, $new_status);
137 137
 
138
-	give_insert_payment_note( $payment_id, $status_change );
138
+	give_insert_payment_note($payment_id, $status_change);
139 139
 }
140 140
 
141
-add_action( 'give_update_payment_status', 'give_record_status_change', 100, 3 );
141
+add_action('give_update_payment_status', 'give_record_status_change', 100, 3);
142 142
 
143 143
 
144 144
 /**
@@ -154,25 +154,25 @@  discard block
 block discarded – undo
154 154
  *
155 155
  * @return void
156 156
  */
157
-function give_update_old_payments_with_totals( $data ) {
158
-	if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_upgrade_payments_nonce' ) ) {
157
+function give_update_old_payments_with_totals($data) {
158
+	if ( ! wp_verify_nonce($data['_wpnonce'], 'give_upgrade_payments_nonce')) {
159 159
 		return;
160 160
 	}
161 161
 
162
-	if ( get_option( 'give_payment_totals_upgraded' ) ) {
162
+	if (get_option('give_payment_totals_upgraded')) {
163 163
 		return;
164 164
 	}
165 165
 
166
-	$payments = give_get_payments( array(
166
+	$payments = give_get_payments(array(
167 167
 		'offset' => 0,
168
-		'number' => - 1,
168
+		'number' => -1,
169 169
 		'mode'   => 'all',
170
-	) );
170
+	));
171 171
 
172
-	if ( $payments ) {
173
-		foreach ( $payments as $payment ) {
172
+	if ($payments) {
173
+		foreach ($payments as $payment) {
174 174
 
175
-			$payment = new Give_Payment( $payment->ID );
175
+			$payment = new Give_Payment($payment->ID);
176 176
 			$meta    = $payment->get_meta();
177 177
 
178 178
 			$payment->total = $meta['amount'];
@@ -181,10 +181,10 @@  discard block
 block discarded – undo
181 181
 		}
182 182
 	}
183 183
 
184
-	add_option( 'give_payment_totals_upgraded', 1 );
184
+	add_option('give_payment_totals_upgraded', 1);
185 185
 }
186 186
 
187
-add_action( 'give_upgrade_payments', 'give_update_old_payments_with_totals' );
187
+add_action('give_upgrade_payments', 'give_update_old_payments_with_totals');
188 188
 
189 189
 /**
190 190
  * Mark Abandoned Donations
@@ -198,17 +198,17 @@  discard block
 block discarded – undo
198 198
 function give_mark_abandoned_donations() {
199 199
 	$args = array(
200 200
 		'status' => 'pending',
201
-		'number' => - 1,
201
+		'number' => -1,
202 202
 		'output' => 'give_payments',
203 203
 	);
204 204
 
205
-	add_filter( 'posts_where', 'give_filter_where_older_than_week' );
205
+	add_filter('posts_where', 'give_filter_where_older_than_week');
206 206
 
207
-	$payments = give_get_payments( $args );
207
+	$payments = give_get_payments($args);
208 208
 
209
-	remove_filter( 'posts_where', 'give_filter_where_older_than_week' );
209
+	remove_filter('posts_where', 'give_filter_where_older_than_week');
210 210
 
211
-	if ( $payments ) {
211
+	if ($payments) {
212 212
 		/**
213 213
 		 * Filter payment gateways:  Used to set payment gateways which can be skip while transferring pending payment to abandon.
214 214
 		 *
@@ -216,13 +216,13 @@  discard block
 block discarded – undo
216 216
 		 *
217 217
 		 * @param array $skip_payment_gateways Array of payment gateways
218 218
 		 */
219
-		$skip_payment_gateways = apply_filters( 'give_mark_abandoned_donation_gateways', array( 'offline' ) );
219
+		$skip_payment_gateways = apply_filters('give_mark_abandoned_donation_gateways', array('offline'));
220 220
 
221
-		foreach ( $payments as $payment ) {
222
-			$gateway = give_get_payment_gateway( $payment );
221
+		foreach ($payments as $payment) {
222
+			$gateway = give_get_payment_gateway($payment);
223 223
 
224 224
 			// Skip payment gateways.
225
-			if ( in_array( $gateway, $skip_payment_gateways ) ) {
225
+			if (in_array($gateway, $skip_payment_gateways)) {
226 226
 				continue;
227 227
 			}
228 228
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	}
233 233
 }
234 234
 
235
-Give_Cron::add_weekly_event( 'give_mark_abandoned_donations' );
235
+Give_Cron::add_weekly_event('give_mark_abandoned_donations');
236 236
 
237 237
 
238 238
 /**
@@ -244,15 +244,15 @@  discard block
 block discarded – undo
244 244
  *
245 245
  * @return void
246 246
  */
247
-function give_refresh_thismonth_stat_transients( $payment_ID ) {
247
+function give_refresh_thismonth_stat_transients($payment_ID) {
248 248
 	// Monthly stats.
249
-	Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
249
+	Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
250 250
 
251 251
 	// @todo: Refresh only range related stat cache
252 252
 	give_delete_donation_stats();
253 253
 }
254 254
 
255
-add_action( 'save_post_give_payment', 'give_refresh_thismonth_stat_transients' );
255
+add_action('save_post_give_payment', 'give_refresh_thismonth_stat_transients');
256 256
 
257 257
 
258 258
 /**
@@ -268,12 +268,12 @@  discard block
 block discarded – undo
268 268
  *
269 269
  * @return array
270 270
  */
271
-function give_bc_v20_get_payment_meta( $check, $object_id, $meta_key, $single ) {
271
+function give_bc_v20_get_payment_meta($check, $object_id, $meta_key, $single) {
272 272
 	// Bailout.
273 273
 	if (
274
-		'give_payment' !== get_post_type( $object_id ) ||
274
+		'give_payment' !== get_post_type($object_id) ||
275 275
 		'_give_payment_meta' !== $meta_key ||
276
-		! give_has_upgrade_completed( 'v20_upgrades_payment_metadata' )
276
+		! give_has_upgrade_completed('v20_upgrades_payment_metadata')
277 277
 	) {
278 278
 		return $check;
279 279
 	}
@@ -281,73 +281,69 @@  discard block
 block discarded – undo
281 281
 	$cache_key = "_give_payment_meta_{$object_id}";
282 282
 
283 283
 	// Get already calculate payment meta from cache.
284
-	$payment_meta = Give_Cache::get_db_query( $cache_key );
284
+	$payment_meta = Give_Cache::get_db_query($cache_key);
285 285
 
286
-	if ( is_null( $payment_meta ) ) {
286
+	if (is_null($payment_meta)) {
287 287
 		// Remove filter.
288
-		remove_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999 );
288
+		remove_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999);
289 289
 
290
-		$donation = new Give_Payment( $object_id );
290
+		$donation = new Give_Payment($object_id);
291 291
 
292 292
 		// Get all payment meta.
293
-		$payment_meta = give_get_meta( $object_id );
293
+		$payment_meta = give_get_meta($object_id);
294 294
 
295 295
 		// Set default value to array.
296
-		if ( empty( $payment_meta ) ) {
296
+		if (empty($payment_meta)) {
297 297
 			return $check;
298 298
 		}
299 299
 
300 300
 		// Convert all meta key value to string instead of array
301
-		array_walk( $payment_meta, function ( &$meta, $key ) {
302
-			$meta = current( $meta );
301
+		array_walk($payment_meta, function(&$meta, $key) {
302
+			$meta = current($meta);
303 303
 		} );
304 304
 
305 305
 		/**
306 306
 		 * Add backward compatibility to old meta keys.
307 307
 		 */
308 308
 		// Donation key.
309
-		$payment_meta['key'] = ! empty( $payment_meta['_give_payment_purchase_key'] ) ? $payment_meta['_give_payment_purchase_key'] : '';
309
+		$payment_meta['key'] = ! empty($payment_meta['_give_payment_purchase_key']) ? $payment_meta['_give_payment_purchase_key'] : '';
310 310
 
311 311
 		// Donation form.
312
-		$payment_meta['form_title'] = ! empty( $payment_meta['_give_payment_form_title'] ) ? $payment_meta['_give_payment_form_title'] : '';
312
+		$payment_meta['form_title'] = ! empty($payment_meta['_give_payment_form_title']) ? $payment_meta['_give_payment_form_title'] : '';
313 313
 
314 314
 		// Donor email.
315
-		$payment_meta['email'] = ! empty( $payment_meta['_give_payment_donor_email'] ) ? $payment_meta['_give_payment_donor_email'] : '';
316
-		$payment_meta['email'] = ! empty( $payment_meta['email'] ) ?
317
-			$payment_meta['email'] :
318
-			Give()->donors->get_column( 'email', $donation->donor_id );
315
+		$payment_meta['email'] = ! empty($payment_meta['_give_payment_donor_email']) ? $payment_meta['_give_payment_donor_email'] : '';
316
+		$payment_meta['email'] = ! empty($payment_meta['email']) ?
317
+			$payment_meta['email'] : Give()->donors->get_column('email', $donation->donor_id);
319 318
 
320 319
 		// Form id.
321
-		$payment_meta['form_id'] = ! empty( $payment_meta['_give_payment_form_id'] ) ? $payment_meta['_give_payment_form_id'] : '';
320
+		$payment_meta['form_id'] = ! empty($payment_meta['_give_payment_form_id']) ? $payment_meta['_give_payment_form_id'] : '';
322 321
 
323 322
 		// Price id.
324
-		$payment_meta['price_id'] = ! empty( $payment_meta['_give_payment_price_id'] ) ? $payment_meta['_give_payment_price_id'] : '';
323
+		$payment_meta['price_id'] = ! empty($payment_meta['_give_payment_price_id']) ? $payment_meta['_give_payment_price_id'] : '';
325 324
 
326 325
 		// Date.
327
-		$payment_meta['date'] = ! empty( $payment_meta['_give_payment_date'] ) ? $payment_meta['_give_payment_date'] : '';
328
-		$payment_meta['date'] = ! empty( $payment_meta['date'] ) ?
329
-			$payment_meta['date'] :
330
-			get_post_field( 'post_date', $object_id );
326
+		$payment_meta['date'] = ! empty($payment_meta['_give_payment_date']) ? $payment_meta['_give_payment_date'] : '';
327
+		$payment_meta['date'] = ! empty($payment_meta['date']) ?
328
+			$payment_meta['date'] : get_post_field('post_date', $object_id);
331 329
 
332 330
 
333 331
 		// Currency.
334
-		$payment_meta['currency'] = ! empty( $payment_meta['_give_payment_currency'] ) ? $payment_meta['_give_payment_currency'] : '';
332
+		$payment_meta['currency'] = ! empty($payment_meta['_give_payment_currency']) ? $payment_meta['_give_payment_currency'] : '';
335 333
 
336 334
 		// Decode donor data.
337
-		$donor_id = ! empty( $payment_meta['_give_payment_donor_id'] ) ? $payment_meta['_give_payment_donor_id'] : 0;
338
-		$donor    = new Give_Donor( $donor_id );
335
+		$donor_id = ! empty($payment_meta['_give_payment_donor_id']) ? $payment_meta['_give_payment_donor_id'] : 0;
336
+		$donor    = new Give_Donor($donor_id);
339 337
 
340 338
 		// Donor first name.
341
-		$donor_data['first_name'] = ! empty( $payment_meta['_give_donor_billing_first_name'] ) ? $payment_meta['_give_donor_billing_first_name'] : '';
342
-		$donor_data['first_name'] = ! empty( $donor_data['first_name'] ) ?
343
-			$donor_data['first_name'] :
344
-			$donor->get_first_name();
339
+		$donor_data['first_name'] = ! empty($payment_meta['_give_donor_billing_first_name']) ? $payment_meta['_give_donor_billing_first_name'] : '';
340
+		$donor_data['first_name'] = ! empty($donor_data['first_name']) ?
341
+			$donor_data['first_name'] : $donor->get_first_name();
345 342
 
346 343
 		// Donor last name.
347
-		$donor_data['last_name'] = ! empty( $payment_meta['_give_donor_billing_last_name'] ) ? $payment_meta['_give_donor_billing_last_name'] : '';
348
-		$donor_data['last_name'] = ! empty( $donor_data['last_name'] ) ?
349
-			$donor_data['last_name'] :
350
-			$donor->get_last_name();
344
+		$donor_data['last_name'] = ! empty($payment_meta['_give_donor_billing_last_name']) ? $payment_meta['_give_donor_billing_last_name'] : '';
345
+		$donor_data['last_name'] = ! empty($donor_data['last_name']) ?
346
+			$donor_data['last_name'] : $donor->get_last_name();
351 347
 
352 348
 		// Donor email.
353 349
 		$donor_data['email'] = $payment_meta['email'];
@@ -358,63 +354,63 @@  discard block
 block discarded – undo
358 354
 		$donor_data['address'] = false;
359 355
 
360 356
 		// Address1.
361
-		$address1 = ! empty( $payment_meta['_give_payment_billing_address1'] ) ? $payment_meta['_give_payment_billing_address1'] : '';
362
-		if ( $address1 ) {
357
+		$address1 = ! empty($payment_meta['_give_payment_billing_address1']) ? $payment_meta['_give_payment_billing_address1'] : '';
358
+		if ($address1) {
363 359
 			$donor_data['address']['line1'] = $address1;
364 360
 		}
365 361
 
366 362
 		// Address2.
367
-		$address2 = ! empty( $payment_meta['_give_payment_billing_address2'] ) ? $payment_meta['_give_payment_billing_address2'] : '';
368
-		if ( $address2 ) {
363
+		$address2 = ! empty($payment_meta['_give_payment_billing_address2']) ? $payment_meta['_give_payment_billing_address2'] : '';
364
+		if ($address2) {
369 365
 			$donor_data['address']['line2'] = $address2;
370 366
 		}
371 367
 
372 368
 		// City.
373
-		$city = ! empty( $payment_meta['_give_payment_billing_city'] ) ? $payment_meta['_give_payment_billing_city'] : '';
374
-		if ( $city ) {
369
+		$city = ! empty($payment_meta['_give_payment_billing_city']) ? $payment_meta['_give_payment_billing_city'] : '';
370
+		if ($city) {
375 371
 			$donor_data['address']['city'] = $city;
376 372
 		}
377 373
 
378 374
 		// Zip.
379
-		$zip = ! empty( $payment_meta['_give_payment_billing_zip'] ) ? $payment_meta['_give_payment_billing_zip'] : '';
380
-		if ( $zip ) {
375
+		$zip = ! empty($payment_meta['_give_payment_billing_zip']) ? $payment_meta['_give_payment_billing_zip'] : '';
376
+		if ($zip) {
381 377
 			$donor_data['address']['zip'] = $zip;
382 378
 		}
383 379
 
384 380
 		// State.
385
-		$state = ! empty( $payment_meta['_give_payment_billing_state'] ) ? $payment_meta['_give_payment_billing_state'] : '';
386
-		if ( $state ) {
381
+		$state = ! empty($payment_meta['_give_payment_billing_state']) ? $payment_meta['_give_payment_billing_state'] : '';
382
+		if ($state) {
387 383
 			$donor_data['address']['state'] = $state;
388 384
 		}
389 385
 
390 386
 		// Country.
391
-		$country = ! empty( $payment_meta['_give_payment_billing_country'] ) ? $payment_meta['_give_payment_billing_country'] : '';
392
-		if ( $country ) {
387
+		$country = ! empty($payment_meta['_give_payment_billing_country']) ? $payment_meta['_give_payment_billing_country'] : '';
388
+		if ($country) {
393 389
 			$donor_data['address']['country'] = $country;
394 390
 		}
395 391
 
396 392
 		$payment_meta['user_info'] = $donor_data;
397 393
 
398 394
 		// Add filter
399
-		add_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4 );
395
+		add_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4);
400 396
 
401 397
 		// Set custom meta key into payment meta.
402
-		if ( ! empty( $payment_meta['_give_payment_meta'] ) ) {
403
-			$payment_meta = array_merge( maybe_unserialize( $payment_meta['_give_payment_meta'] ), $payment_meta );
398
+		if ( ! empty($payment_meta['_give_payment_meta'])) {
399
+			$payment_meta = array_merge(maybe_unserialize($payment_meta['_give_payment_meta']), $payment_meta);
404 400
 		}
405 401
 
406 402
 		// Set cache.
407
-		Give_Cache::set_db_query( $cache_key, $payment_meta );
403
+		Give_Cache::set_db_query($cache_key, $payment_meta);
408 404
 	}
409 405
 
410
-	if ( $single ) {
406
+	if ($single) {
411 407
 		/**
412 408
 		 * Filter the payment meta
413 409
 		 * Add custom meta key to payment meta
414 410
 		 *
415 411
 		 * @since 2.0
416 412
 		 */
417
-		$new_payment_meta[0] = apply_filters( 'give_get_payment_meta', $payment_meta, $object_id, $meta_key );
413
+		$new_payment_meta[0] = apply_filters('give_get_payment_meta', $payment_meta, $object_id, $meta_key);
418 414
 
419 415
 		$payment_meta = $new_payment_meta;
420 416
 	}
@@ -422,7 +418,7 @@  discard block
 block discarded – undo
422 418
 	return $payment_meta;
423 419
 }
424 420
 
425
-add_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4 );
421
+add_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4);
426 422
 
427 423
 /**
428 424
  * Add meta in payment that store page id and page url.
@@ -434,19 +430,19 @@  discard block
 block discarded – undo
434 430
  *
435 431
  * @param int $payment_id Payment id for which the meta value should be updated.
436 432
  */
437
-function give_payment_save_page_data( $payment_id ) {
438
-	$page_url = ( ! empty( $_REQUEST['give-current-url'] ) ? esc_url( $_REQUEST['give-current-url'] ) : false );
433
+function give_payment_save_page_data($payment_id) {
434
+	$page_url = ( ! empty($_REQUEST['give-current-url']) ? esc_url($_REQUEST['give-current-url']) : false);
439 435
 
440 436
 	// Check $page_url is not empty.
441
-	if ( $page_url ) {
442
-		update_post_meta( $payment_id, '_give_current_url', $page_url );
443
-		$page_id = url_to_postid( $page_url );
437
+	if ($page_url) {
438
+		update_post_meta($payment_id, '_give_current_url', $page_url);
439
+		$page_id = url_to_postid($page_url);
444 440
 		// Check $page_id is not empty.
445
-		if ( $page_id ) {
446
-			update_post_meta( $payment_id, '_give_current_page_id', $page_id );
441
+		if ($page_id) {
442
+			update_post_meta($payment_id, '_give_current_page_id', $page_id);
447 443
 		}
448 444
 	}
449 445
 }
450 446
 
451 447
 // Fire when payment is save.
452
-add_action( 'give_insert_payment', 'give_payment_save_page_data' );
453 448
\ No newline at end of file
449
+add_action('give_insert_payment', 'give_payment_save_page_data');
454 450
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-give-async-process.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @category Class
12 12
  * @author   WordImpress
13 13
  */
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -52,16 +52,16 @@  discard block
 block discarded – undo
52 52
 		 * )
53 53
 		 */
54 54
 
55
-		$_post = give_clean( $_POST );
55
+		$_post = give_clean($_POST);
56 56
 
57
-		if ( empty( $_post ) || empty( $_post['data'] ) || empty( $_post['hook'] ) ) {
57
+		if (empty($_post) || empty($_post['data']) || empty($_post['hook'])) {
58 58
 			exit();
59 59
 		}
60 60
 
61 61
 		/**
62 62
 		 * Fire the hook.
63 63
 		 */
64
-		do_action( $_post['hook'], $_post['data'] );
64
+		do_action($_post['hook'], $_post['data']);
65 65
 
66 66
 		exit();
67 67
 	}
Please login to merge, or discard this patch.
includes/shortcodes.php 1 patch
Spacing   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,41 +23,41 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return string|bool
25 25
  */
26
-function give_donation_history( $atts ) {
26
+function give_donation_history($atts) {
27 27
 
28
-	$donation_history_args = shortcode_atts( array(
28
+	$donation_history_args = shortcode_atts(array(
29 29
 		'id'             => true,
30 30
 		'date'           => true,
31 31
 		'donor'          => false,
32 32
 		'amount'         => true,
33 33
 		'status'         => false,
34 34
 		'payment_method' => false,
35
-	), $atts, 'donation_history' );
35
+	), $atts, 'donation_history');
36 36
 
37 37
 	// Always show receipt link.
38 38
 	$donation_history_args['details'] = true;
39 39
 
40 40
 	// Set Donation History Shortcode Arguments in session variable.
41
-	Give()->session->set( 'give_donation_history_args', $donation_history_args );
41
+	Give()->session->set('give_donation_history_args', $donation_history_args);
42 42
 
43 43
 	// If payment_key query arg exists, return receipt instead of donation history.
44
-	if ( isset( $_GET['payment_key'] ) ) {
44
+	if (isset($_GET['payment_key'])) {
45 45
 		ob_start();
46 46
 
47
-		echo give_receipt_shortcode( array() );
47
+		echo give_receipt_shortcode(array());
48 48
 
49 49
 		// Display donation history link only if Receipt Access Session is available.
50
-		if ( give_get_receipt_session() ) {
50
+		if (give_get_receipt_session()) {
51 51
 			echo sprintf(
52 52
 				'<a href="%s">%s</a>',
53
-				esc_url( give_get_history_page_uri() ),
54
-				__( '&laquo; Return to All Donations', 'give' )
53
+				esc_url(give_get_history_page_uri()),
54
+				__('&laquo; Return to All Donations', 'give')
55 55
 			);
56 56
 		}
57 57
 		return ob_get_clean();
58 58
 	}
59 59
 
60
-	$email_access = give_get_option( 'email_access' );
60
+	$email_access = give_get_option('email_access');
61 61
 
62 62
 	/**
63 63
 	 * Determine access
@@ -68,31 +68,31 @@  discard block
 block discarded – undo
68 68
 	if (
69 69
 		is_user_logged_in() ||
70 70
 		false !== Give()->session->get_session_expiration() ||
71
-		( give_is_setting_enabled( $email_access ) && Give()->email_access->token_exists ) ||
71
+		(give_is_setting_enabled($email_access) && Give()->email_access->token_exists) ||
72 72
 		true === give_get_history_session()
73 73
 	) {
74 74
 		ob_start();
75
-		give_get_template_part( 'history', 'donations' );
75
+		give_get_template_part('history', 'donations');
76 76
 
77 77
 		return ob_get_clean();
78 78
 
79
-	} elseif ( give_is_setting_enabled( $email_access ) ) {
79
+	} elseif (give_is_setting_enabled($email_access)) {
80 80
 		// Is Email-based access enabled?
81 81
 		ob_start();
82
-		give_get_template_part( 'email', 'login-form' );
82
+		give_get_template_part('email', 'login-form');
83 83
 
84 84
 		return ob_get_clean();
85 85
 
86 86
 	} else {
87 87
 
88
-		$output = apply_filters( 'give_donation_history_nonuser_message', Give()->notices->print_frontend_notice( __( 'You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give' ), false ) );
89
-		$output .= do_shortcode( '[give_login]' );
88
+		$output = apply_filters('give_donation_history_nonuser_message', Give()->notices->print_frontend_notice(__('You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give'), false));
89
+		$output .= do_shortcode('[give_login]');
90 90
 
91 91
 		return $output;
92 92
 	}
93 93
 }
94 94
 
95
-add_shortcode( 'donation_history', 'give_donation_history' );
95
+add_shortcode('donation_history', 'give_donation_history');
96 96
 
97 97
 /**
98 98
  * Donation Form Shortcode
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
  *
106 106
  * @return string
107 107
  */
108
-function give_form_shortcode( $atts ) {
109
-	$atts = shortcode_atts( array(
108
+function give_form_shortcode($atts) {
109
+	$atts = shortcode_atts(array(
110 110
 		'id'                    => '',
111 111
 		'show_title'            => true,
112 112
 		'show_goal'             => true,
@@ -114,21 +114,21 @@  discard block
 block discarded – undo
114 114
 		'float_labels'          => '',
115 115
 		'display_style'         => '',
116 116
 		'continue_button_title' => '',
117
-	), $atts, 'give_form' );
117
+	), $atts, 'give_form');
118 118
 
119 119
 	// Convert string to bool.
120
-	$atts['show_title'] = filter_var( $atts['show_title'], FILTER_VALIDATE_BOOLEAN );
121
-	$atts['show_goal']  = filter_var( $atts['show_goal'], FILTER_VALIDATE_BOOLEAN );
120
+	$atts['show_title'] = filter_var($atts['show_title'], FILTER_VALIDATE_BOOLEAN);
121
+	$atts['show_goal']  = filter_var($atts['show_goal'], FILTER_VALIDATE_BOOLEAN);
122 122
 
123 123
 	// get the Give Form
124 124
 	ob_start();
125
-	give_get_donation_form( $atts );
125
+	give_get_donation_form($atts);
126 126
 	$final_output = ob_get_clean();
127 127
 
128
-	return apply_filters( 'give_donate_form', $final_output, $atts );
128
+	return apply_filters('give_donate_form', $final_output, $atts);
129 129
 }
130 130
 
131
-add_shortcode( 'give_form', 'give_form_shortcode' );
131
+add_shortcode('give_form', 'give_form_shortcode');
132 132
 
133 133
 /**
134 134
  * Donation Form Goal Shortcode.
@@ -141,36 +141,36 @@  discard block
 block discarded – undo
141 141
  *
142 142
  * @return string
143 143
  */
144
-function give_goal_shortcode( $atts ) {
145
-	$atts = shortcode_atts( array(
144
+function give_goal_shortcode($atts) {
145
+	$atts = shortcode_atts(array(
146 146
 		'id'        => '',
147 147
 		'show_text' => true,
148 148
 		'show_bar'  => true,
149
-	), $atts, 'give_goal' );
149
+	), $atts, 'give_goal');
150 150
 
151 151
 	// get the Give Form.
152 152
 	ob_start();
153 153
 
154 154
 	// Sanity check 1: ensure there is an ID Provided.
155
-	if ( empty( $atts['id'] ) ) {
156
-		Give()->notices->print_frontend_notice( __( 'The shortcode is missing Donation Form ID attribute.', 'give' ), true );
155
+	if (empty($atts['id'])) {
156
+		Give()->notices->print_frontend_notice(__('The shortcode is missing Donation Form ID attribute.', 'give'), true);
157 157
 	}
158 158
 
159 159
 	// Sanity check 2: Check the form even has Goals enabled.
160
-	if ( ! give_is_setting_enabled( give_get_meta( $atts['id'], '_give_goal_option', true ) ) ) {
160
+	if ( ! give_is_setting_enabled(give_get_meta($atts['id'], '_give_goal_option', true))) {
161 161
 
162
-		Give()->notices->print_frontend_notice( __( 'The form does not have Goals enabled.', 'give' ), true );
162
+		Give()->notices->print_frontend_notice(__('The form does not have Goals enabled.', 'give'), true);
163 163
 	} else {
164 164
 		// Passed all sanity checks: output Goal.
165
-		give_show_goal_progress( $atts['id'], $atts );
165
+		give_show_goal_progress($atts['id'], $atts);
166 166
 	}
167 167
 
168 168
 	$final_output = ob_get_clean();
169 169
 
170
-	return apply_filters( 'give_goal_shortcode_output', $final_output, $atts );
170
+	return apply_filters('give_goal_shortcode_output', $final_output, $atts);
171 171
 }
172 172
 
173
-add_shortcode( 'give_goal', 'give_goal_shortcode' );
173
+add_shortcode('give_goal', 'give_goal_shortcode');
174 174
 
175 175
 
176 176
 /**
@@ -187,22 +187,22 @@  discard block
 block discarded – undo
187 187
  *
188 188
  * @return string
189 189
  */
190
-function give_login_form_shortcode( $atts ) {
190
+function give_login_form_shortcode($atts) {
191 191
 
192
-	$atts = shortcode_atts( array(
192
+	$atts = shortcode_atts(array(
193 193
 		// Add backward compatibility for redirect attribute.
194 194
 		'redirect' => '',
195 195
 		'login-redirect'  => '',
196 196
 		'logout-redirect' => '',
197
-	), $atts, 'give_login' );
197
+	), $atts, 'give_login');
198 198
 
199 199
 	// Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute.
200
-	$atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect'] ) ? $atts['redirect'] : '' );
200
+	$atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : '');
201 201
 
202
-	return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] );
202
+	return give_login_form($atts['login-redirect'], $atts['logout-redirect']);
203 203
 }
204 204
 
205
-add_shortcode( 'give_login', 'give_login_form_shortcode' );
205
+add_shortcode('give_login', 'give_login_form_shortcode');
206 206
 
207 207
 /**
208 208
  * Register Shortcode.
@@ -217,15 +217,15 @@  discard block
 block discarded – undo
217 217
  *
218 218
  * @return string
219 219
  */
220
-function give_register_form_shortcode( $atts ) {
221
-	$atts = shortcode_atts( array(
220
+function give_register_form_shortcode($atts) {
221
+	$atts = shortcode_atts(array(
222 222
 		'redirect' => '',
223
-	), $atts, 'give_register' );
223
+	), $atts, 'give_register');
224 224
 
225
-	return give_register_form( $atts['redirect'] );
225
+	return give_register_form($atts['redirect']);
226 226
 }
227 227
 
228
-add_shortcode( 'give_register', 'give_register_form_shortcode' );
228
+add_shortcode('give_register', 'give_register_form_shortcode');
229 229
 
230 230
 /**
231 231
  * Receipt Shortcode.
@@ -238,12 +238,12 @@  discard block
 block discarded – undo
238 238
  *
239 239
  * @return string
240 240
  */
241
-function give_receipt_shortcode( $atts ) {
241
+function give_receipt_shortcode($atts) {
242 242
 
243 243
 	global $give_receipt_args;
244 244
 
245
-	$give_receipt_args = shortcode_atts( array(
246
-		'error'          => __( 'You are missing the payment key to view this donation receipt.', 'give' ),
245
+	$give_receipt_args = shortcode_atts(array(
246
+		'error'          => __('You are missing the payment key to view this donation receipt.', 'give'),
247 247
 		'price'          => true,
248 248
 		'donor'          => true,
249 249
 		'date'           => true,
@@ -252,49 +252,49 @@  discard block
 block discarded – undo
252 252
 		'payment_id'     => true,
253 253
 		'payment_status' => false,
254 254
 		'status_notice'  => true,
255
-	), $atts, 'give_receipt' );
255
+	), $atts, 'give_receipt');
256 256
 
257 257
 	// set $session var
258 258
 	$session = give_get_purchase_session();
259 259
 
260 260
 	// set payment key var
261
-	if ( isset( $_GET['payment_key'] ) ) {
262
-		$payment_key = urldecode( $_GET['payment_key'] );
263
-	} elseif ( $session ) {
261
+	if (isset($_GET['payment_key'])) {
262
+		$payment_key = urldecode($_GET['payment_key']);
263
+	} elseif ($session) {
264 264
 		$payment_key = $session['purchase_key'];
265
-	} elseif ( $give_receipt_args['payment_key'] ) {
265
+	} elseif ($give_receipt_args['payment_key']) {
266 266
 		$payment_key = $give_receipt_args['payment_key'];
267 267
 	}
268 268
 
269
-	$email_access = give_get_option( 'email_access' );
269
+	$email_access = give_get_option('email_access');
270 270
 
271 271
 	// No payment_key found & Email Access is Turned on.
272
-	if ( ! isset( $payment_key ) && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) {
272
+	if ( ! isset($payment_key) && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) {
273 273
 
274 274
 		ob_start();
275 275
 
276
-		give_get_template_part( 'email-login-form' );
276
+		give_get_template_part('email-login-form');
277 277
 
278 278
 		return ob_get_clean();
279 279
 
280
-	} elseif ( ! isset( $payment_key ) ) {
280
+	} elseif ( ! isset($payment_key)) {
281 281
 
282
-		return Give()->notices->print_frontend_notice( $give_receipt_args['error'], false, 'error' );
282
+		return Give()->notices->print_frontend_notice($give_receipt_args['error'], false, 'error');
283 283
 
284 284
 	}
285 285
 
286
-	$user_can_view = give_can_view_receipt( $payment_key );
286
+	$user_can_view = give_can_view_receipt($payment_key);
287 287
 
288 288
 	// Key was provided, but user is logged out. Offer them the ability to login and view the receipt.
289
-	if ( ! $user_can_view && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) {
289
+	if ( ! $user_can_view && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) {
290 290
 
291 291
 		ob_start();
292 292
 
293
-		give_get_template_part( 'email-login-form' );
293
+		give_get_template_part('email-login-form');
294 294
 
295 295
 		return ob_get_clean();
296 296
 
297
-	} elseif ( ! $user_can_view ) {
297
+	} elseif ( ! $user_can_view) {
298 298
 
299 299
 		global $give_login_redirect;
300 300
 
@@ -302,9 +302,9 @@  discard block
 block discarded – undo
302 302
 
303 303
 		ob_start();
304 304
 
305
-		Give()->notices->print_frontend_notice( apply_filters( 'give_must_be_logged_in_error_message', __( 'You must be logged in to view this donation receipt.', 'give' ) ) );
305
+		Give()->notices->print_frontend_notice(apply_filters('give_must_be_logged_in_error_message', __('You must be logged in to view this donation receipt.', 'give')));
306 306
 
307
-		give_get_template_part( 'shortcode', 'login' );
307
+		give_get_template_part('shortcode', 'login');
308 308
 
309 309
 		$login_form = ob_get_clean();
310 310
 
@@ -318,20 +318,20 @@  discard block
 block discarded – undo
318 318
 	 * or if user is logged out and donation was made as a guest, the donation session is checked for
319 319
 	 * or if user is logged in and the user can view sensitive shop data.
320 320
 	 */
321
-	if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) {
322
-		return Give()->notices->print_frontend_notice( $give_receipt_args['error'], false, 'error' );
321
+	if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) {
322
+		return Give()->notices->print_frontend_notice($give_receipt_args['error'], false, 'error');
323 323
 	}
324 324
 
325 325
 	ob_start();
326 326
 
327
-	give_get_template_part( 'shortcode', 'receipt' );
327
+	give_get_template_part('shortcode', 'receipt');
328 328
 
329 329
 	$display = ob_get_clean();
330 330
 
331 331
 	return $display;
332 332
 }
333 333
 
334
-add_shortcode( 'give_receipt', 'give_receipt_shortcode' );
334
+add_shortcode('give_receipt', 'give_receipt_shortcode');
335 335
 
336 336
 /**
337 337
  * Profile Editor Shortcode.
@@ -350,25 +350,25 @@  discard block
 block discarded – undo
350 350
  *
351 351
  * @return string Output generated from the profile editor
352 352
  */
353
-function give_profile_editor_shortcode( $atts ) {
353
+function give_profile_editor_shortcode($atts) {
354 354
 
355 355
 	ob_start();
356 356
 
357 357
 	// Restrict access to donor profile, if donor and user are disconnected.
358
-	$is_donor_disconnected = get_user_meta( get_current_user_id(), '_give_is_donor_disconnected', true );
359
-	if ( is_user_logged_in() && $is_donor_disconnected ) {
360
-		Give()->notices->print_frontend_notice( __( 'Your Donor and User profile are no longer connected. Please contact the site administrator.', 'give' ), true, 'error' );
358
+	$is_donor_disconnected = get_user_meta(get_current_user_id(), '_give_is_donor_disconnected', true);
359
+	if (is_user_logged_in() && $is_donor_disconnected) {
360
+		Give()->notices->print_frontend_notice(__('Your Donor and User profile are no longer connected. Please contact the site administrator.', 'give'), true, 'error');
361 361
 		return false;
362 362
 	}
363 363
 
364
-	give_get_template_part( 'shortcode', 'profile-editor' );
364
+	give_get_template_part('shortcode', 'profile-editor');
365 365
 
366 366
 	$display = ob_get_clean();
367 367
 
368 368
 	return $display;
369 369
 }
370 370
 
371
-add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' );
371
+add_shortcode('give_profile_editor', 'give_profile_editor_shortcode');
372 372
 
373 373
 /**
374 374
  * Process Profile Updater Form.
@@ -381,29 +381,29 @@  discard block
 block discarded – undo
381 381
  *
382 382
  * @return bool
383 383
  */
384
-function give_process_profile_editor_updates( $data ) {
384
+function give_process_profile_editor_updates($data) {
385 385
 	// Profile field change request.
386
-	if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) {
386
+	if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) {
387 387
 		return false;
388 388
 	}
389 389
 
390 390
 	// Nonce security.
391
-	if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) {
391
+	if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) {
392 392
 		return false;
393 393
 	}
394 394
 
395 395
 	$user_id       = get_current_user_id();
396
-	$old_user_data = get_userdata( $user_id );
396
+	$old_user_data = get_userdata($user_id);
397 397
 
398 398
 	/* @var Give_Donor $donor */
399
-	$donor = new Give_Donor( $user_id, true );
399
+	$donor = new Give_Donor($user_id, true);
400 400
 
401
-	$display_name     = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name;
402
-	$first_name       = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name;
403
-	$last_name        = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name;
404
-	$email            = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email;
405
-	$password         = ! empty( $data['give_new_user_pass1'] ) ? $data['give_new_user_pass1'] : '';
406
-	$confirm_password = ! empty( $data['give_new_user_pass2'] ) ? $data['give_new_user_pass2'] : '';
401
+	$display_name     = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name;
402
+	$first_name       = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name;
403
+	$last_name        = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name;
404
+	$email            = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email;
405
+	$password         = ! empty($data['give_new_user_pass1']) ? $data['give_new_user_pass1'] : '';
406
+	$confirm_password = ! empty($data['give_new_user_pass2']) ? $data['give_new_user_pass2'] : '';
407 407
 
408 408
 	$userdata = array(
409 409
 		'ID'           => $user_id,
@@ -422,55 +422,55 @@  discard block
 block discarded – undo
422 422
 	 * @param int $user_id The ID of the user.
423 423
 	 * @param array $userdata User info, including ID, first name, last name, display name and email.
424 424
 	 */
425
-	do_action( 'give_pre_update_user_profile', $user_id, $userdata );
425
+	do_action('give_pre_update_user_profile', $user_id, $userdata);
426 426
 
427 427
 	// Make sure to validate first name of existing donors.
428
-	if ( empty( $first_name ) ) {
428
+	if (empty($first_name)) {
429 429
 		// Empty First Name.
430
-		give_set_error( 'empty_first_name', __( 'Please enter your first name.', 'give' ) );
430
+		give_set_error('empty_first_name', __('Please enter your first name.', 'give'));
431 431
 	}
432 432
 
433 433
 	// Make sure to validate passwords for existing Donors.
434
-	give_validate_user_password( $password, $confirm_password );
434
+	give_validate_user_password($password, $confirm_password);
435 435
 
436
-	if ( empty( $email ) ) {
436
+	if (empty($email)) {
437 437
 		// Make sure email should not be empty.
438
-		give_set_error( 'email_empty', __( 'The email you entered is empty.', 'give' ) );
438
+		give_set_error('email_empty', __('The email you entered is empty.', 'give'));
439 439
 
440
-	} elseif ( ! is_email( $email ) ) {
440
+	} elseif ( ! is_email($email)) {
441 441
 		// Make sure email should be valid.
442
-		give_set_error( 'email_not_valid', __( 'The email you entered is not valid. Please use another', 'give' ) );
442
+		give_set_error('email_not_valid', __('The email you entered is not valid. Please use another', 'give'));
443 443
 
444
-	} elseif ( $email != $old_user_data->user_email ) {
444
+	} elseif ($email != $old_user_data->user_email) {
445 445
 		// Make sure the new email doesn't belong to another user
446
-		if ( email_exists( $email ) ) {
447
-			give_set_error( 'user_email_exists', __( 'The email you entered belongs to another user. Please use another.', 'give' ) );
448
-		} elseif ( Give()->donors->get_donor_by( 'email', $email ) ) {
446
+		if (email_exists($email)) {
447
+			give_set_error('user_email_exists', __('The email you entered belongs to another user. Please use another.', 'give'));
448
+		} elseif (Give()->donors->get_donor_by('email', $email)) {
449 449
 			// Make sure the new email doesn't belong to another user
450
-			give_set_error( 'donor_email_exists', __( 'The email you entered belongs to another donor. Please use another.', 'give' ) );
450
+			give_set_error('donor_email_exists', __('The email you entered belongs to another donor. Please use another.', 'give'));
451 451
 		}
452 452
 	}
453 453
 
454 454
 	// Check for errors.
455 455
 	$errors = give_get_errors();
456 456
 
457
-	if ( $errors ) {
457
+	if ($errors) {
458 458
 		// Send back to the profile editor if there are errors.
459
-		wp_redirect( $data['give_redirect'] );
459
+		wp_redirect($data['give_redirect']);
460 460
 		give_die();
461 461
 	}
462 462
 
463 463
 	// Update Donor First Name and Last Name.
464
-	Give()->donors->update( $donor->id, array(
465
-		'name' => trim( "{$first_name} {$last_name}" ),
466
-	) );
467
-	Give()->donor_meta->update_meta( $donor->id, '_give_donor_first_name', $first_name );
468
-	Give()->donor_meta->update_meta( $donor->id, '_give_donor_last_name', $last_name );
464
+	Give()->donors->update($donor->id, array(
465
+		'name' => trim("{$first_name} {$last_name}"),
466
+	));
467
+	Give()->donor_meta->update_meta($donor->id, '_give_donor_first_name', $first_name);
468
+	Give()->donor_meta->update_meta($donor->id, '_give_donor_last_name', $last_name);
469 469
 
470 470
 	// Update the user.
471
-	$updated = wp_update_user( $userdata );
471
+	$updated = wp_update_user($userdata);
472 472
 
473
-	if ( $updated ) {
473
+	if ($updated) {
474 474
 
475 475
 		/**
476 476
 		 * Fires after updating user profile.
@@ -480,12 +480,12 @@  discard block
 block discarded – undo
480 480
 		 * @param int $user_id The ID of the user.
481 481
 		 * @param array $userdata User info, including ID, first name, last name, display name and email.
482 482
 		 */
483
-		do_action( 'give_user_profile_updated', $user_id, $userdata );
484
-		wp_redirect( add_query_arg( 'updated', 'true', $data['give_redirect'] ) );
483
+		do_action('give_user_profile_updated', $user_id, $userdata);
484
+		wp_redirect(add_query_arg('updated', 'true', $data['give_redirect']));
485 485
 		give_die();
486 486
 	}
487 487
 
488 488
 	return false;
489 489
 }
490 490
 
491
-add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' );
491
+add_action('give_edit_user_profile', 'give_process_profile_editor_updates');
Please login to merge, or discard this patch.
includes/class-notices.php 1 patch
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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_donation_form_before_personal_info', array( $this, 'render_frontend_notices' ) );
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_donation_form_before_personal_info', array($this, 'render_frontend_notices'));
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 		}
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 	 * @access private
292 292
 	 */
293 293
 	private function print_js() {
294
-		if ( self::$has_auto_dismissible_notice ) :
294
+		if (self::$has_auto_dismissible_notice) :
295 295
 			?>
296 296
 			<script>
297 297
 				jQuery(document).ready(function () {
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 			<?php
308 308
 		endif;
309 309
 
310
-		if ( self::$has_dismiss_interval_notice ) :
310
+		if (self::$has_dismiss_interval_notice) :
311 311
 			?>
312 312
 			<script>
313 313
 				jQuery(document).ready(function () {
@@ -386,36 +386,36 @@  discard block
 block discarded – undo
386 386
 	 * @access public
387 387
 	 */
388 388
 	public function dismiss_notices() {
389
-		$_post     = give_clean( $_POST );
390
-		$notice_id = esc_attr( $_post['notice_id'] );
389
+		$_post     = give_clean($_POST);
390
+		$notice_id = esc_attr($_post['notice_id']);
391 391
 
392 392
 		// Bailout.
393 393
 		if (
394
-			empty( $notice_id ) ||
395
-			empty( $_post['dismissible_type'] ) ||
396
-			empty( $_post['dismiss_interval'] ) ||
397
-			! check_ajax_referer( "give_edit_{$notice_id}_notice", '_wpnonce' )
394
+			empty($notice_id) ||
395
+			empty($_post['dismissible_type']) ||
396
+			empty($_post['dismiss_interval']) ||
397
+			! check_ajax_referer("give_edit_{$notice_id}_notice", '_wpnonce')
398 398
 		) {
399 399
 			wp_send_json_error();
400 400
 		}
401 401
 
402
-		$notice_key = Give()->notices->get_notice_key( $notice_id, $_post['dismiss_interval'] );
403
-		if ( 'user' === $_post['dismissible_type'] ) {
402
+		$notice_key = Give()->notices->get_notice_key($notice_id, $_post['dismiss_interval']);
403
+		if ('user' === $_post['dismissible_type']) {
404 404
 			$current_user = wp_get_current_user();
405
-			$notice_key   = Give()->notices->get_notice_key( $notice_id, $_post['dismiss_interval'], $current_user->ID );
405
+			$notice_key   = Give()->notices->get_notice_key($notice_id, $_post['dismiss_interval'], $current_user->ID);
406 406
 		}
407 407
 
408
-		$notice_dismiss_time = ! empty( $_post['dismiss_interval_time'] ) ? $_post['dismiss_interval_time'] : null;
408
+		$notice_dismiss_time = ! empty($_post['dismiss_interval_time']) ? $_post['dismiss_interval_time'] : null;
409 409
 
410 410
 		// Save option to hide notice.
411
-		Give_Cache::set( $notice_key, true, $notice_dismiss_time, true );
411
+		Give_Cache::set($notice_key, true, $notice_dismiss_time, true);
412 412
 
413 413
 		/**
414 414
 		 * Fire the action when notice dismissed
415 415
 		 *
416 416
 		 * @since 2.0
417 417
 		 */
418
-		do_action( 'give_dismiss_notices', $_post );
418
+		do_action('give_dismiss_notices', $_post);
419 419
 
420 420
 		wp_send_json_success();
421 421
 	}
@@ -433,18 +433,18 @@  discard block
 block discarded – undo
433 433
 	 *
434 434
 	 * @return string
435 435
 	 */
436
-	public function get_notice_key( $notice_id, $dismiss_interval = null, $user_id = 0 ) {
436
+	public function get_notice_key($notice_id, $dismiss_interval = null, $user_id = 0) {
437 437
 		$notice_key = "_give_notice_{$notice_id}";
438 438
 
439
-		if ( ! empty( $dismiss_interval ) ) {
439
+		if ( ! empty($dismiss_interval)) {
440 440
 			$notice_key .= "_{$dismiss_interval}";
441 441
 		}
442 442
 
443
-		if ( $user_id ) {
443
+		if ($user_id) {
444 444
 			$notice_key .= "_{$user_id}";
445 445
 		}
446 446
 
447
-		$notice_key = sanitize_key( $notice_key );
447
+		$notice_key = sanitize_key($notice_key);
448 448
 
449 449
 		return $notice_key;
450 450
 	}
@@ -457,11 +457,11 @@  discard block
 block discarded – undo
457 457
 	 *
458 458
 	 * @return string
459 459
 	 */
460
-	public function get_dismiss_link( $notice_args ) {
460
+	public function get_dismiss_link($notice_args) {
461 461
 		$notice_args = wp_parse_args(
462 462
 			$notice_args,
463 463
 			array(
464
-				'title'                 => __( 'Click here', 'give' ),
464
+				'title'                 => __('Click here', 'give'),
465 465
 				'dismissible_type'      => '',
466 466
 				'dismiss_interval'      => '',
467 467
 				'dismiss_interval_time' => null,
@@ -488,31 +488,31 @@  discard block
 block discarded – undo
488 488
 	 *
489 489
 	 * @return bool|null
490 490
 	 */
491
-	public function is_notice_dismissed( $notice ) {
492
-		$notice_key          = $this->get_notice_key( $notice['id'], $notice['dismiss_interval'] );
491
+	public function is_notice_dismissed($notice) {
492
+		$notice_key          = $this->get_notice_key($notice['id'], $notice['dismiss_interval']);
493 493
 		$is_notice_dismissed = false;
494 494
 
495
-		if ( 'user' === $notice['dismissible_type'] ) {
495
+		if ('user' === $notice['dismissible_type']) {
496 496
 			$current_user = wp_get_current_user();
497
-			$notice_key   = Give()->notices->get_notice_key( $notice['id'], $notice['dismiss_interval'], $current_user->ID );
497
+			$notice_key   = Give()->notices->get_notice_key($notice['id'], $notice['dismiss_interval'], $current_user->ID);
498 498
 		}
499 499
 
500
-		$notice_data = Give_Cache::get( $notice_key, true );
500
+		$notice_data = Give_Cache::get($notice_key, true);
501 501
 
502 502
 		// Find notice dismiss link status if notice has extra dismissible links.
503
-		if ( ( empty( $notice_data ) || is_wp_error( $notice_data ) ) && ! empty( $notice['extra_links'] ) ) {
503
+		if ((empty($notice_data) || is_wp_error($notice_data)) && ! empty($notice['extra_links'])) {
504 504
 
505
-			foreach ( $notice['extra_links'] as $extra_link ) {
506
-				$new_notice_data = wp_parse_args( $extra_link, $notice );
507
-				unset( $new_notice_data['extra_links'] );
505
+			foreach ($notice['extra_links'] as $extra_link) {
506
+				$new_notice_data = wp_parse_args($extra_link, $notice);
507
+				unset($new_notice_data['extra_links']);
508 508
 
509
-				if ( $is_notice_dismissed = $this->is_notice_dismissed( $new_notice_data ) ) {
509
+				if ($is_notice_dismissed = $this->is_notice_dismissed($new_notice_data)) {
510 510
 					return $is_notice_dismissed;
511 511
 				}
512 512
 			}
513 513
 		}
514 514
 
515
-		$is_notice_dismissed = ! empty( $notice_data ) && ! is_wp_error( $notice_data );
515
+		$is_notice_dismissed = ! empty($notice_data) && ! is_wp_error($notice_data);
516 516
 
517 517
 		return $is_notice_dismissed;
518 518
 	}
@@ -526,9 +526,9 @@  discard block
 block discarded – undo
526 526
 	 *
527 527
 	 * @param array $errors
528 528
 	 */
529
-	public static function print_frontend_errors( $errors ) {
529
+	public static function print_frontend_errors($errors) {
530 530
 		// Bailout.
531
-		if ( ! $errors ) {
531
+		if ( ! $errors) {
532 532
 			return;
533 533
 		}
534 534
 
@@ -543,37 +543,37 @@  discard block
 block discarded – undo
543 543
 		);
544 544
 
545 545
 		// Note: we will remove give_errors class in future.
546
-		$classes = apply_filters( 'give_error_class', array( 'give_notices', 'give_errors' ) );
546
+		$classes = apply_filters('give_error_class', array('give_notices', 'give_errors'));
547 547
 
548
-		echo sprintf( '<div class="%s">', implode( ' ', $classes ) );
548
+		echo sprintf('<div class="%s">', implode(' ', $classes));
549 549
 
550 550
 		// Loop error codes and display errors.
551
-		foreach ( $errors as $error_id => $error ) {
551
+		foreach ($errors as $error_id => $error) {
552 552
 			// Backward compatibility v<1.8.11
553
-			if ( is_string( $error ) ) {
553
+			if (is_string($error)) {
554 554
 				$error = array(
555 555
 					'message'     => $error,
556 556
 					'notice_args' => array(),
557 557
 				);
558 558
 			}
559 559
 
560
-			$notice_args = wp_parse_args( $error['notice_args'], $default_notice_args );
560
+			$notice_args = wp_parse_args($error['notice_args'], $default_notice_args);
561 561
 
562 562
 			/**
563 563
 			 * Filter to modify Frontend Errors args before errors is display.
564 564
 			 *
565 565
 			 * @since 1.8.14
566 566
 			 */
567
-			$notice_args = apply_filters( 'give_frontend_errors_args', $notice_args );
567
+			$notice_args = apply_filters('give_frontend_errors_args', $notice_args);
568 568
 
569 569
 			echo sprintf(
570 570
 				'<div class="give_error give_notice" id="give_error_%1$s" data-dismissible="%2$s" data-dismiss-interval="%3$d">
571 571
 						<p><strong>%4$s</strong>: %5$s</p>
572 572
 					</div>',
573 573
 				$error_id,
574
-				give_clean( $notice_args['dismissible'] ),
575
-				absint( $notice_args['dismiss_interval'] ),
576
-				esc_html__( 'Error', 'give' ),
574
+				give_clean($notice_args['dismissible']),
575
+				absint($notice_args['dismiss_interval']),
576
+				esc_html__('Error', 'give'),
577 577
 				$error['message']
578 578
 			);
579 579
 		}
@@ -595,8 +595,8 @@  discard block
 block discarded – undo
595 595
 	 *
596 596
 	 * @return  string
597 597
 	 */
598
-	public static function print_frontend_notice( $message, $echo = true, $notice_type = 'warning', $notice_args = array() ) {
599
-		if ( empty( $message ) ) {
598
+	public static function print_frontend_notice($message, $echo = true, $notice_type = 'warning', $notice_args = array()) {
599
+		if (empty($message)) {
600 600
 			return '';
601 601
 		}
602 602
 
@@ -610,14 +610,14 @@  discard block
 block discarded – undo
610 610
 			'dismiss_interval' => 5000,
611 611
 		);
612 612
 
613
-		$notice_args = wp_parse_args( $notice_args, $default_notice_args );
613
+		$notice_args = wp_parse_args($notice_args, $default_notice_args);
614 614
 
615 615
 		/**
616 616
 		 * Filter to modify Frontend notice args before notices is display.
617 617
 		 *
618 618
 		 * @since 1.8.14
619 619
 		 */
620
-		$notice_args = apply_filters( 'give_frontend_notice_args', $notice_args );
620
+		$notice_args = apply_filters('give_frontend_notice_args', $notice_args);
621 621
 
622 622
 		// Note: we will remove give_errors class in future.
623 623
 		$error = sprintf(
@@ -627,12 +627,12 @@  discard block
 block discarded – undo
627 627
 				</p>
628 628
 			</div>',
629 629
 			$notice_type,
630
-			give_clean( $notice_args['dismissible'] ),
631
-			absint( $notice_args['dismiss_interval'] ),
630
+			give_clean($notice_args['dismissible']),
631
+			absint($notice_args['dismiss_interval']),
632 632
 			$message
633 633
 		);
634 634
 
635
-		if ( ! $echo ) {
635
+		if ( ! $echo) {
636 636
 			return $error;
637 637
 		}
638 638
 
@@ -652,24 +652,24 @@  discard block
 block discarded – undo
652 652
 	 *
653 653
 	 * @return string
654 654
 	 */
655
-	public function print_admin_notices( $notice_args = array() ) {
655
+	public function print_admin_notices($notice_args = array()) {
656 656
 		// Bailout.
657
-		if ( empty( $notice_args['description'] ) ) {
657
+		if (empty($notice_args['description'])) {
658 658
 			return '';
659 659
 		}
660 660
 
661
-		$defaults    = array(
661
+		$defaults = array(
662 662
 			'id'          => '',
663 663
 			'echo'        => true,
664 664
 			'notice_type' => 'warning',
665 665
 			'dismissible' => true,
666 666
 		);
667
-		$notice_args = wp_parse_args( $notice_args, $defaults );
667
+		$notice_args = wp_parse_args($notice_args, $defaults);
668 668
 
669 669
 		$output    = '';
670
-		$css_id    = ! empty( $notice_args['id'] ) ? $notice_args['id'] : uniqid( 'give-inline-notice-' );
670
+		$css_id    = ! empty($notice_args['id']) ? $notice_args['id'] : uniqid('give-inline-notice-');
671 671
 		$css_class = "notice-{$notice_args['notice_type']} give-notice notice inline";
672
-		$css_class .= ( $notice_args['dismissible'] ) ? ' is-dismissible' : '';
672
+		$css_class .= ($notice_args['dismissible']) ? ' is-dismissible' : '';
673 673
 		$output    .= sprintf(
674 674
 			'<div id="%1$s" class="%2$s"><p>%3$s</p></div>',
675 675
 			$css_id,
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
 			$notice_args['description']
678 678
 		);
679 679
 
680
-		if ( ! $notice_args['echo'] ) {
680
+		if ( ! $notice_args['echo']) {
681 681
 			return $output;
682 682
 		}
683 683
 
Please login to merge, or discard this patch.