Test Failed
Pull Request — master (#3152)
by Devin
07:21
created
includes/admin/shortcodes/shortcode-give-totals.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 // Exit if accessed directly.
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
 	 */
24 24
 	public function __construct() {
25 25
 
26
-		$this->shortcode['title'] = __( 'Give Totals', 'give' );
27
-		$this->shortcode['label'] = __( 'Give Totals', 'give' );
26
+		$this->shortcode['title'] = __('Give Totals', 'give');
27
+		$this->shortcode['label'] = __('Give Totals', 'give');
28 28
 
29
-		parent::__construct( 'give_totals' );
29
+		parent::__construct('give_totals');
30 30
 	}
31 31
 
32 32
 	/**
@@ -39,66 +39,66 @@  discard block
 block discarded – undo
39 39
 
40 40
 		$category_options = array();
41 41
 		$category_lists   = array();
42
-		$categories       = get_terms( 'give_forms_category', apply_filters( 'give_forms_category_dropdown', array() ) );
43
-		if ( give_is_setting_enabled( give_get_option( 'categories' ) ) && ! is_wp_error( $categories ) ) {
44
-			foreach ( $categories as $category ) {
45
-				$category_options[ absint( $category->term_id ) ] = esc_html( $category->name );
42
+		$categories       = get_terms('give_forms_category', apply_filters('give_forms_category_dropdown', array()));
43
+		if (give_is_setting_enabled(give_get_option('categories')) && ! is_wp_error($categories)) {
44
+			foreach ($categories as $category) {
45
+				$category_options[absint($category->term_id)] = esc_html($category->name);
46 46
 			}
47 47
 
48 48
 			$category_lists['type']    = 'listbox';
49 49
 			$category_lists['name']    = 'cats';
50
-			$category_lists['label']   = __( 'Select a Donation Form Category:', 'give' );
51
-			$category_lists['tooltip'] = __( 'Select a Donation Form Category', 'give' );
50
+			$category_lists['label']   = __('Select a Donation Form Category:', 'give');
51
+			$category_lists['tooltip'] = __('Select a Donation Form Category', 'give');
52 52
 			$category_lists['options'] = $category_options;
53 53
 		}
54 54
 
55 55
 		$tag_options = array();
56 56
 		$tag_lists   = array();
57
-		$tags        = get_terms( 'give_forms_tag', apply_filters( 'give_forms_tag_dropdown', array() ) );
58
-		if ( give_is_setting_enabled( give_get_option( 'tags' ) ) && ! is_wp_error( $tags ) ) {
59
-			$tags = get_terms( 'give_forms_tag', apply_filters( 'give_forms_tag_dropdown', array() ) );
60
-			foreach ( $tags as $tag ) {
61
-				$tag_options[ absint( $tag->term_id ) ] = esc_html( $tag->name );
57
+		$tags        = get_terms('give_forms_tag', apply_filters('give_forms_tag_dropdown', array()));
58
+		if (give_is_setting_enabled(give_get_option('tags')) && ! is_wp_error($tags)) {
59
+			$tags = get_terms('give_forms_tag', apply_filters('give_forms_tag_dropdown', array()));
60
+			foreach ($tags as $tag) {
61
+				$tag_options[absint($tag->term_id)] = esc_html($tag->name);
62 62
 			}
63 63
 
64 64
 			$tag_lists['type']    = 'listbox';
65 65
 			$tag_lists['name']    = 'tags';
66
-			$tag_lists['label']   = __( 'Select a Donation Form Tag:', 'give' );
67
-			$tag_lists['tooltip'] = __( 'Select a Donation Form Tag', 'give' );
66
+			$tag_lists['label']   = __('Select a Donation Form Tag:', 'give');
67
+			$tag_lists['tooltip'] = __('Select a Donation Form Tag', 'give');
68 68
 			$tag_lists['options'] = $tag_options;
69 69
 		}
70 70
 
71 71
 		return array(
72 72
 			array(
73 73
 				'type' => 'container',
74
-				'html' => sprintf( '<p class="give-totals-shortcode-container-message">%s</p>',
75
-					 __( 'This shortcode shows the total amount raised towards a custom goal for one or several forms regardless of whether they have goals enabled or not.', 'give' )
74
+				'html' => sprintf('<p class="give-totals-shortcode-container-message">%s</p>',
75
+					 __('This shortcode shows the total amount raised towards a custom goal for one or several forms regardless of whether they have goals enabled or not.', 'give')
76 76
 				),
77 77
 			),
78 78
 			array(
79 79
 				'type' => 'container',
80
-				'html' => sprintf( '<p class="strong margin-top">%s</p>', __( 'Shortcode Configuration', 'give' ) ),
80
+				'html' => sprintf('<p class="strong margin-top">%s</p>', __('Shortcode Configuration', 'give')),
81 81
 			),
82 82
 			array(
83 83
 				'type'        => 'textbox',
84 84
 				'name'        => 'ids',
85
-				'label'       => __( 'Donation Form IDs:', 'give' ),
86
-				'tooltip'     => __( 'Enter the IDs separated by commas for the donation forms you would like to combine within the totals.', 'give' ),
85
+				'label'       => __('Donation Form IDs:', 'give'),
86
+				'tooltip'     => __('Enter the IDs separated by commas for the donation forms you would like to combine within the totals.', 'give'),
87 87
 			),
88 88
 			$category_lists,
89 89
 			$tag_lists,
90 90
 			array(
91 91
 				'type'    => 'textbox',
92 92
 				'name'    => 'total_goal',
93
-				'label'   => __( 'Total Goal:', 'give' ),
94
-				'tooltip' => __( 'Enter the total goal amount that you would like to display.', 'give' ),
93
+				'label'   => __('Total Goal:', 'give'),
94
+				'tooltip' => __('Enter the total goal amount that you would like to display.', 'give'),
95 95
 			),
96 96
 			array(
97 97
 				'type'      => 'textbox',
98 98
 				'name'      => 'message',
99
-				'label'     => __( 'Message:', 'give' ),
100
-				'tooltip'   => __( 'Enter a message to display encouraging donors to support the goal.', 'give' ),
101
-				'value'     => apply_filters( 'give_totals_message', __( 'Hey! We\'ve raised {total} of the {total_goal} we are trying to raise for this campaign!', 'give' ) ),
99
+				'label'     => __('Message:', 'give'),
100
+				'tooltip'   => __('Enter a message to display encouraging donors to support the goal.', 'give'),
101
+				'value'     => apply_filters('give_totals_message', __('Hey! We\'ve raised {total} of the {total_goal} we are trying to raise for this campaign!', 'give')),
102 102
 				'multiline' => true,
103 103
 				'minWidth'  => 300,
104 104
 				'minHeight' => 60,
@@ -106,24 +106,24 @@  discard block
 block discarded – undo
106 106
 			array(
107 107
 				'type'    => 'textbox',
108 108
 				'name'    => 'link',
109
-				'label'   => __( 'Link:', 'give' ),
110
-				'tooltip' => __( 'Enter a link to the main campaign donation form.', 'give' ),
109
+				'label'   => __('Link:', 'give'),
110
+				'tooltip' => __('Enter a link to the main campaign donation form.', 'give'),
111 111
 			),
112 112
 			array(
113 113
 				'type'    => 'textbox',
114 114
 				'name'    => 'link_text',
115
-				'label'   => __( 'Link Text:', 'give' ),
116
-				'tooltip' => __( 'Enter hyperlink text for the link to the main campaign donation form.', 'give' ),
117
-				'value'   => __( 'Donate!', 'give' ),
115
+				'label'   => __('Link Text:', 'give'),
116
+				'tooltip' => __('Enter hyperlink text for the link to the main campaign donation form.', 'give'),
117
+				'value'   => __('Donate!', 'give'),
118 118
 			),
119 119
 			array(
120 120
 				'type'    => 'listbox',
121 121
 				'name'    => 'progress_bar',
122
-				'label'   => __( 'Show Progress Bar:', 'give' ),
123
-				'tooltip' => __( 'Select whether you would like to show a goal progress bar.', 'give' ),
122
+				'label'   => __('Show Progress Bar:', 'give'),
123
+				'tooltip' => __('Select whether you would like to show a goal progress bar.', 'give'),
124 124
 				'options' => array(
125
-					'true'  => __( 'Show', 'give' ),
126
-					'false' => __( 'Hide', 'give' ),
125
+					'true'  => __('Show', 'give'),
126
+					'false' => __('Hide', 'give'),
127 127
 				),
128 128
 				'value'   => 'true',
129 129
 			),
Please login to merge, or discard this patch.
includes/admin/shortcodes/class-shortcode-button.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 * Class constructor
33 33
 	 */
34 34
 	public function __construct() {
35
-		add_action( 'admin_init', array( $this, 'init'), 999 );
35
+		add_action('admin_init', array($this, 'init'), 999);
36 36
 	}
37 37
 
38 38
 	/**
@@ -41,17 +41,17 @@  discard block
 block discarded – undo
41 41
 	 * @since 2.1.0
42 42
 	 * @access public
43 43
 	 */
44
-	public function init(){
45
-		if ( $this->is_add_button() ) {
46
-			add_filter( 'mce_external_plugins', array( $this, 'mce_external_plugins' ), 15 );
44
+	public function init() {
45
+		if ($this->is_add_button()) {
46
+			add_filter('mce_external_plugins', array($this, 'mce_external_plugins'), 15);
47 47
 
48
-			add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_assets' ) );
49
-			add_action( 'admin_enqueue_scripts', array( $this, 'admin_localize_scripts' ), 13 );
50
-			add_action( 'media_buttons', array( $this, 'shortcode_button' ) );
48
+			add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_assets'));
49
+			add_action('admin_enqueue_scripts', array($this, 'admin_localize_scripts'), 13);
50
+			add_action('media_buttons', array($this, 'shortcode_button'));
51 51
 		}
52 52
 
53
-		add_action( "wp_ajax_give_shortcode", array( $this, 'shortcode_ajax' ) );
54
-		add_action( "wp_ajax_nopriv_give_shortcode", array( $this, 'shortcode_ajax' ) );
53
+		add_action("wp_ajax_give_shortcode", array($this, 'shortcode_ajax'));
54
+		add_action("wp_ajax_nopriv_give_shortcode", array($this, 'shortcode_ajax'));
55 55
 	}
56 56
 
57 57
 	/**
@@ -63,13 +63,13 @@  discard block
 block discarded – undo
63 63
 	 *
64 64
 	 * @since 1.0
65 65
 	 */
66
-	public function mce_external_plugins( $plugin_array ) {
66
+	public function mce_external_plugins($plugin_array) {
67 67
 
68
-		if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ) {
68
+		if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages')) {
69 69
 			return false;
70 70
 		}
71 71
 
72
-		$plugin_array['give_shortcode'] = GIVE_PLUGIN_URL . 'includes/admin/shortcodes/mce-plugin.js';
72
+		$plugin_array['give_shortcode'] = GIVE_PLUGIN_URL.'includes/admin/shortcodes/mce-plugin.js';
73 73
 
74 74
 		return $plugin_array;
75 75
 	}
@@ -82,19 +82,19 @@  discard block
 block discarded – undo
82 82
 	 * @since 1.0
83 83
 	 */
84 84
 	public function admin_enqueue_assets() {
85
-		$direction = ( is_rtl() || isset( $_GET['d'] ) && 'rtl' === $_GET['d'] ) ? '.rtl' : '';
85
+		$direction = (is_rtl() || isset($_GET['d']) && 'rtl' === $_GET['d']) ? '.rtl' : '';
86 86
 
87 87
 		wp_enqueue_script(
88 88
 			'give_shortcode',
89
-			GIVE_PLUGIN_URL . 'includes/admin/shortcodes/admin-shortcodes.js',
90
-			array( 'jquery' ),
89
+			GIVE_PLUGIN_URL.'includes/admin/shortcodes/admin-shortcodes.js',
90
+			array('jquery'),
91 91
 			GIVE_VERSION,
92 92
 			true
93 93
 		);
94 94
 
95 95
 		wp_enqueue_style(
96 96
 			'give-admin-shortcode-button-style',
97
-			GIVE_PLUGIN_URL . 'assets/dist/css/admin-shortcode-button' . $direction . '.css',
97
+			GIVE_PLUGIN_URL.'assets/dist/css/admin-shortcode-button'.$direction.'.css',
98 98
 			array(),
99 99
 			GIVE_VERSION
100 100
 		);
@@ -109,17 +109,17 @@  discard block
 block discarded – undo
109 109
 	 */
110 110
 	public function admin_localize_scripts() {
111 111
 
112
-		if ( ! empty( self::$shortcodes ) ) {
112
+		if ( ! empty(self::$shortcodes)) {
113 113
 
114 114
 			$variables = array();
115 115
 
116
-			foreach ( self::$shortcodes as $shortcode => $values ) {
117
-				if ( ! empty( $values['required'] ) ) {
118
-					$variables[ $shortcode ] = $values['required'];
116
+			foreach (self::$shortcodes as $shortcode => $values) {
117
+				if ( ! empty($values['required'])) {
118
+					$variables[$shortcode] = $values['required'];
119 119
 				}
120 120
 			}
121 121
 
122
-			wp_localize_script( 'give_shortcode', 'scShortcodes', $variables );
122
+			wp_localize_script('give_shortcode', 'scShortcodes', $variables);
123 123
 		}
124 124
 	}
125 125
 
@@ -134,16 +134,16 @@  discard block
 block discarded – undo
134 134
 
135 135
 		$shortcodes = array();
136 136
 
137
-		foreach ( self::$shortcodes as $shortcode => $values ) {
137
+		foreach (self::$shortcodes as $shortcode => $values) {
138 138
 
139 139
 			/**
140 140
 			 * Filters the condition for including the current shortcode
141 141
 			 *
142 142
 			 * @since 1.0
143 143
 			 */
144
-			if ( apply_filters( sanitize_title( $shortcode ) . '_condition', true ) ) {
144
+			if (apply_filters(sanitize_title($shortcode).'_condition', true)) {
145 145
 
146
-				$shortcodes[ $shortcode ] = sprintf(
146
+				$shortcodes[$shortcode] = sprintf(
147 147
 					'<div class="sc-shortcode mce-menu-item give-shortcode-item-%1$s" data-shortcode="%2$s">%3$s</div>',
148 148
 					$shortcode,
149 149
 					$shortcode,
@@ -152,37 +152,37 @@  discard block
 block discarded – undo
152 152
 			}
153 153
 		}
154 154
 
155
-		if ( ! empty( $shortcodes ) ) {
155
+		if ( ! empty($shortcodes)) {
156 156
 
157 157
 			// check current WP version
158
-			$img = ( version_compare( get_bloginfo( 'version' ), '3.5', '<' ) )
159
-				? '<img src="' . GIVE_PLUGIN_URL . 'assets/dist/images/give-media.png" />'
160
-				: '<span class="wp-media-buttons-icon" id="give-media-button" style="background-image: url(' . give_svg_icons( 'give_grey' ) . ');"></span>';
158
+			$img = (version_compare(get_bloginfo('version'), '3.5', '<'))
159
+				? '<img src="'.GIVE_PLUGIN_URL.'assets/dist/images/give-media.png" />'
160
+				: '<span class="wp-media-buttons-icon" id="give-media-button" style="background-image: url('.give_svg_icons('give_grey').');"></span>';
161 161
 
162
-			reset( $shortcodes );
162
+			reset($shortcodes);
163 163
 
164
-			if ( 1 === count( $shortcodes ) ) {
164
+			if (1 === count($shortcodes)) {
165 165
 
166
-				$shortcode = key( $shortcodes );
166
+				$shortcode = key($shortcodes);
167 167
 
168 168
 				printf(
169 169
 					'<button type="button" class="button sc-shortcode" data-shortcode="%s">%s</button>',
170 170
 					$shortcode,
171
-					sprintf( '%s %s %s',
171
+					sprintf('%s %s %s',
172 172
 						$img,
173
-						__( 'Insert', 'give' ),
174
-						self::$shortcodes[ $shortcode ]['label']
173
+						__('Insert', 'give'),
174
+						self::$shortcodes[$shortcode]['label']
175 175
 					)
176 176
 				);
177 177
 			} else {
178 178
 				printf(
179
-					'<div class="sc-wrap">' .
180
-					'<button class="button sc-button" type="button">%s %s</button>' .
181
-					'<div class="sc-menu mce-menu">%s</div>' .
179
+					'<div class="sc-wrap">'.
180
+					'<button class="button sc-button" type="button">%s %s</button>'.
181
+					'<div class="sc-menu mce-menu">%s</div>'.
182 182
 					'</div>',
183 183
 					$img,
184
-					__( 'Give Shortcodes', 'give' ),
185
-					implode( '', array_values( $shortcodes ) )
184
+					__('Give Shortcodes', 'give'),
185
+					implode('', array_values($shortcodes))
186 186
 				);
187 187
 			}
188 188
 		}
@@ -197,15 +197,15 @@  discard block
 block discarded – undo
197 197
 	 */
198 198
 	public function shortcode_ajax() {
199 199
 
200
-		$shortcode = isset( $_POST['shortcode'] ) ? $_POST['shortcode'] : false;
200
+		$shortcode = isset($_POST['shortcode']) ? $_POST['shortcode'] : false;
201 201
 		$response  = false;
202 202
 
203
-		if ( $shortcode && array_key_exists( $shortcode, self::$shortcodes ) ) {
203
+		if ($shortcode && array_key_exists($shortcode, self::$shortcodes)) {
204 204
 
205
-			$data = self::$shortcodes[ $shortcode ];
205
+			$data = self::$shortcodes[$shortcode];
206 206
 
207
-			if ( ! empty( $data['errors'] ) ) {
208
-				$data['btn_okay'] = array( esc_html__( 'Okay', 'give' ) );
207
+			if ( ! empty($data['errors'])) {
208
+				$data['btn_okay'] = array(esc_html__('Okay', 'give'));
209 209
 			}
210 210
 
211 211
 			$response = array(
@@ -217,10 +217,10 @@  discard block
 block discarded – undo
217 217
 			);
218 218
 		} else {
219 219
 			// todo: handle error
220
-			error_log( print_r( 'AJAX error!', 1 ) );
220
+			error_log(print_r('AJAX error!', 1));
221 221
 		}
222 222
 
223
-		wp_send_json( $response );
223
+		wp_send_json($response);
224 224
 	}
225 225
 
226 226
 
@@ -234,21 +234,21 @@  discard block
 block discarded – undo
234 234
 	private function is_add_button() {
235 235
 		global $pagenow;
236 236
 
237
-		$shortcode_button_pages = apply_filters( 'give_shortcode_button_pages', array(
237
+		$shortcode_button_pages = apply_filters('give_shortcode_button_pages', array(
238 238
 			'post.php',
239 239
 			'page.php',
240 240
 			'post-new.php',
241 241
 			'post-edit.php',
242 242
 			'edit.php',
243 243
 			'edit.php?post_type=page',
244
-		) );
244
+		));
245 245
 
246 246
 		// Only run in admin post/page creation and edit screens
247 247
 		if (
248 248
 			! is_admin()
249
-			|| ! in_array( $pagenow, $shortcode_button_pages )
250
-			|| ! apply_filters( 'give_shortcode_button_condition', true )
251
-			|| empty( self::$shortcodes )
249
+			|| ! in_array($pagenow, $shortcode_button_pages)
250
+			|| ! apply_filters('give_shortcode_button_condition', true)
251
+			|| empty(self::$shortcodes)
252 252
 		) {
253 253
 			return false;
254 254
 		}
Please login to merge, or discard this patch.
includes/admin/abstract-admin-settings-page.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  discard block
 block discarded – undo
9 9
  * @since       1.8
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit; // Exit if accessed directly
14 14
 }
15 15
 
16
-if ( ! class_exists( 'Give_Settings_Page' ) ) :
16
+if ( ! class_exists('Give_Settings_Page')) :
17 17
 
18 18
 	/**
19 19
 	 * Give_Settings_Page.
@@ -70,25 +70,25 @@  discard block
 block discarded – undo
70 70
 			// Get current setting page.
71 71
 			$this->current_setting_page = give_get_current_setting_page();
72 72
 
73
-			add_filter( "give_default_setting_tab_section_{$this->id}", array( $this, 'set_default_setting_tab' ), 10 );
74
-			add_filter( "{$this->current_setting_page}_tabs_array", array( $this, 'add_settings_page' ), 20 );
75
-			add_action( "{$this->current_setting_page}_settings_{$this->id}_page", array( $this, 'output' ) );
73
+			add_filter("give_default_setting_tab_section_{$this->id}", array($this, 'set_default_setting_tab'), 10);
74
+			add_filter("{$this->current_setting_page}_tabs_array", array($this, 'add_settings_page'), 20);
75
+			add_action("{$this->current_setting_page}_settings_{$this->id}_page", array($this, 'output'));
76 76
 
77 77
 			// Output section only if exist.
78 78
 			$sections = $this->get_sections();
79
-			if ( ! empty( $sections ) ) {
80
-				add_action( "{$this->current_setting_page}_sections_{$this->id}_page", array(
79
+			if ( ! empty($sections)) {
80
+				add_action("{$this->current_setting_page}_sections_{$this->id}_page", array(
81 81
 					$this,
82 82
 					'output_sections',
83
-				) );
83
+				));
84 84
 			}
85 85
 
86 86
 			// Save hide button by default.
87 87
 			$GLOBALS['give_hide_save_button'] = true;
88 88
 
89 89
 			// Enable saving feature.
90
-			if ( $this->enable_save ) {
91
-				add_action( "{$this->current_setting_page}_save_{$this->id}", array( $this, 'save' ) );
90
+			if ($this->enable_save) {
91
+				add_action("{$this->current_setting_page}_save_{$this->id}", array($this, 'save'));
92 92
 			}
93 93
 		}
94 94
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 		 *
114 114
 		 * @return string
115 115
 		 */
116
-		function set_default_setting_tab( $setting_tab ) {
116
+		function set_default_setting_tab($setting_tab) {
117 117
 			return $this->default_tab;
118 118
 		}
119 119
 
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 		 *
127 127
 		 * @return array
128 128
 		 */
129
-		public function add_settings_page( $pages ) {
130
-			$pages[ $this->id ] = $this->label;
129
+		public function add_settings_page($pages) {
130
+			$pages[$this->id] = $this->label;
131 131
 
132 132
 			return $pages;
133 133
 		}
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 			 *
147 147
 			 * @param  array $settings
148 148
 			 */
149
-			$settings = apply_filters( 'give_get_settings_' . $this->id, array() );
149
+			$settings = apply_filters('give_get_settings_'.$this->id, array());
150 150
 
151 151
 			// Output.
152 152
 			return $settings;
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		 * @return array
160 160
 		 */
161 161
 		public function get_sections() {
162
-			return apply_filters( 'give_get_sections_' . $this->id, array() );
162
+			return apply_filters('give_get_sections_'.$this->id, array());
163 163
 		}
164 164
 
165 165
 		/**
@@ -176,40 +176,40 @@  discard block
 block discarded – undo
176 176
 			$sections = $this->get_sections();
177 177
 
178 178
 			// Bailout.
179
-			if ( empty( $sections ) ) {
179
+			if (empty($sections)) {
180 180
 				return;
181 181
 			}
182 182
 
183 183
 			// Show section settings only if setting section exist.
184
-			if ( $current_section && ! in_array( $current_section, array_keys( $sections ), true ) ) {
185
-				echo wp_kses_post( '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>' );
184
+			if ($current_section && ! in_array($current_section, array_keys($sections), true)) {
185
+				echo wp_kses_post('<div class="error"><p>'.__('Oops, this settings page does not exist.', 'give').'</p></div>');
186 186
 				$GLOBALS['give_hide_save_button'] = true;
187 187
 
188 188
 				return;
189 189
 			}
190 190
 
191
-			if ( is_null( $this->current_setting_page ) ) {
191
+			if (is_null($this->current_setting_page)) {
192 192
 				$this->current_setting_page = give_get_current_setting_page();
193 193
 			}
194 194
 
195 195
 			$section_list = array();
196
-			foreach ( $sections as $id => $label ) {
196
+			foreach ($sections as $id => $label) {
197 197
 				/**
198 198
 				 * Fire the filter to hide particular section on tab.
199 199
 				 *
200 200
 				 * @since 2.0
201 201
 				 */
202
-				if ( apply_filters( "give_hide_section_{$id}_on_{$this->id}_page", false, $sections, $this->id ) ) {
202
+				if (apply_filters("give_hide_section_{$id}_on_{$this->id}_page", false, $sections, $this->id)) {
203 203
 					continue;
204 204
 				}
205 205
 
206
-				$section_list[] = '<li><a href="' . admin_url( 'edit.php?post_type=give_forms&page=' . $this->current_setting_page . '&tab=' . $this->id . '&section=' . sanitize_title( $id ) ) . '" class="' . ( $current_section === $id ? 'current' : '' ) . '">' . $label . '</a>';
206
+				$section_list[] = '<li><a href="'.admin_url('edit.php?post_type=give_forms&page='.$this->current_setting_page.'&tab='.$this->id.'&section='.sanitize_title($id)).'" class="'.($current_section === $id ? 'current' : '').'">'.$label.'</a>';
207 207
 			}
208 208
 
209
-			echo wp_kses_post( sprintf(
209
+			echo wp_kses_post(sprintf(
210 210
 				'<ul class="subsubsub">%s</ul><br class="clear" /><hr>',
211
-				implode( ' | </li>', $section_list )
212
-			) );
211
+				implode(' | </li>', $section_list)
212
+			));
213 213
 		}
214 214
 
215 215
 		/**
@@ -221,13 +221,13 @@  discard block
 block discarded – undo
221 221
 		 * @return void
222 222
 		 */
223 223
 		public function output() {
224
-			if ( $this->enable_save ) {
224
+			if ($this->enable_save) {
225 225
 				$GLOBALS['give_hide_save_button'] = false;
226 226
 			}
227 227
 
228 228
 			$settings = $this->get_settings();
229 229
 
230
-			Give_Admin_Settings::output_fields( $settings, 'give_settings' );
230
+			Give_Admin_Settings::output_fields($settings, 'give_settings');
231 231
 		}
232 232
 
233 233
 		/**
@@ -245,8 +245,8 @@  discard block
 block discarded – undo
245 245
 			 *
246 246
 			 * @since 2.1
247 247
 			 */
248
-			if ( apply_filters( "give_save_options_{$this->id}_{$current_section}", true ) ) {
249
-				Give_Admin_Settings::save_fields( $settings, 'give_settings' );
248
+			if (apply_filters("give_save_options_{$this->id}_{$current_section}", true)) {
249
+				Give_Admin_Settings::save_fields($settings, 'give_settings');
250 250
 			}
251 251
 
252 252
 			/**
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 			 *
255 255
 			 * @since 1.8
256 256
 			 */
257
-			do_action( 'give_update_options_' . $this->id . '_' . $current_section );
257
+			do_action('give_update_options_'.$this->id.'_'.$current_section);
258 258
 		}
259 259
 
260 260
 		/**
@@ -271,11 +271,11 @@  discard block
 block discarded – undo
271 271
 			$section         = $this->get_sections();
272 272
 			$current_section = give_get_current_setting_section();
273 273
 
274
-			if ( array_key_exists( $current_section, $section ) ) {
275
-				$heading[] = $section[ $current_section ];
274
+			if (array_key_exists($current_section, $section)) {
275
+				$heading[] = $section[$current_section];
276 276
 			}
277 277
 
278
-			return array_unique( $heading );
278
+			return array_unique($heading);
279 279
 		}
280 280
 
281 281
 		/**
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 		public function get_heading_html() {
290 290
 			return sprintf(
291 291
 				'<h1 class="wp-heading-inline">%s</h1><hr class="wp-header-end">',
292
-				implode( ' <span class="give-settings-heading-sep dashicons dashicons-arrow-right-alt2"></span> ', $this->get_heading() )
292
+				implode(' <span class="give-settings-heading-sep dashicons dashicons-arrow-right-alt2"></span> ', $this->get_heading())
293 293
 			);
294 294
 		}
295 295
 	}
Please login to merge, or discard this patch.
includes/admin/emails/class-email-notification-table.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
 	 * @access public
37 37
 	 */
38 38
 	public function __construct() {
39
-		parent::__construct( array(
40
-			'singular' => __( 'Give Email Notification', 'give' ),
41
-			'plural'   => __( 'Give Email Notifications', 'give' ),
42
-		) );
39
+		parent::__construct(array(
40
+			'singular' => __('Give Email Notification', 'give'),
41
+			'plural'   => __('Give Email Notifications', 'give'),
42
+		));
43 43
 
44 44
 		$this->email_notifications = Give_Email_Notifications::get_instance();
45 45
 	}
@@ -59,13 +59,13 @@  discard block
 block discarded – undo
59 59
 		 *
60 60
 		 * @since 2.0
61 61
 		 */
62
-		return apply_filters( 'give_email_notification_setting_columns', array(
63
-			'cb'         => __( 'Email Status', 'give' ),
64
-			'name'       => __( 'Email', 'give' ),
65
-			'email_type' => __( 'Content Type', 'give' ),
66
-			'recipient'  => __( 'Recipient(s)', 'give' ),
67
-			'setting'    => __( 'Edit Email', 'give' ),
68
-		) );
62
+		return apply_filters('give_email_notification_setting_columns', array(
63
+			'cb'         => __('Email Status', 'give'),
64
+			'name'       => __('Email', 'give'),
65
+			'email_type' => __('Content Type', 'give'),
66
+			'recipient'  => __('Recipient(s)', 'give'),
67
+			'setting'    => __('Edit Email', 'give'),
68
+		));
69 69
 	}
70 70
 
71 71
 	/**
@@ -78,19 +78,19 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @return  string
80 80
 	 */
81
-	public function column_name( $email ) {
82
-		$edit_url = esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=emails&section=' . $email->config['id'] ) );
83
-		$actions  = $this->get_row_actions( $email );
81
+	public function column_name($email) {
82
+		$edit_url = esc_url(admin_url('edit.php?post_type=give_forms&page=give-settings&tab=emails&section='.$email->config['id']));
83
+		$actions  = $this->get_row_actions($email);
84 84
 
85 85
 		ob_start();
86 86
 		?>
87 87
 		<a class="row-title" href="<?php echo $edit_url; ?>"><?php echo $email->config['label']; ?></a>
88 88
 
89
-		<?php if ( $desc = $email->config['description'] ) : ?>
90
-			<?php echo Give()->tooltips->render_help( esc_attr( $desc ) ); ?>
89
+		<?php if ($desc = $email->config['description']) : ?>
90
+			<?php echo Give()->tooltips->render_help(esc_attr($desc)); ?>
91 91
 		<?php endif; ?>
92 92
 
93
-		<?php echo $this->row_actions( $actions ); ?>
93
+		<?php echo $this->row_actions($actions); ?>
94 94
 		<?php
95 95
 		return ob_get_clean();
96 96
 	}
@@ -105,18 +105,18 @@  discard block
 block discarded – undo
105 105
 	 *
106 106
 	 * @return string
107 107
 	 */
108
-	public function column_recipient( $email ) {
108
+	public function column_recipient($email) {
109 109
 		ob_start();
110 110
 
111
-		if( Give_Email_Notification_Util::has_recipient_field( $email ) ) {
111
+		if (Give_Email_Notification_Util::has_recipient_field($email)) {
112 112
 			$recipients = $email->get_recipient();
113
-			if ( is_array( $recipients ) ) {
114
-				$recipients = implode( '<br>', $recipients );
113
+			if (is_array($recipients)) {
114
+				$recipients = implode('<br>', $recipients);
115 115
 			}
116 116
 
117 117
 			echo $recipients;
118 118
 
119
-		} elseif ( ! empty( $email->config['recipient_group_name'] ) ) {
119
+		} elseif ( ! empty($email->config['recipient_group_name'])) {
120 120
 			echo $email->config['recipient_group_name'];
121 121
 		}
122 122
 
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
 	 *
134 134
 	 * @return string
135 135
 	 */
136
-	public function column_cb( $email ) {
136
+	public function column_cb($email) {
137 137
 		$notification_status  = $email->get_notification_status();
138
-		$user_can_edit_status = (int) Give_Email_Notification_Util::is_notification_status_editable( $email );
139
-		$icon_classes         = Give_Email_Notification_Util::is_email_notification_active( $email )
138
+		$user_can_edit_status = (int) Give_Email_Notification_Util::is_notification_status_editable($email);
139
+		$icon_classes         = Give_Email_Notification_Util::is_email_notification_active($email)
140 140
 			? 'dashicons dashicons-yes'
141 141
 			: 'dashicons dashicons-no-alt';
142 142
 		$attributes           = array(
@@ -146,15 +146,15 @@  discard block
 block discarded – undo
146 146
 			'data-edit'   => $user_can_edit_status,
147 147
 		);
148 148
 
149
-		if ( ! $user_can_edit_status ) {
150
-			$icon_classes         = 'dashicons dashicons-lock';
149
+		if ( ! $user_can_edit_status) {
150
+			$icon_classes = 'dashicons dashicons-lock';
151 151
 
152
-			$attributes['data-notice'] = esc_attr( $email->config['notices']['non-notification-status-editable'] );
152
+			$attributes['data-notice'] = esc_attr($email->config['notices']['non-notification-status-editable']);
153 153
 		}
154 154
 
155 155
 		$html = sprintf(
156 156
 			'<span %1$s><i class="%2$s"></i></span></span><span class="spinner"></span>',
157
-			give_get_attribute_str( $attributes ),
157
+			give_get_attribute_str($attributes),
158 158
 			$icon_classes
159 159
 		);
160 160
 
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
 	 *
173 173
 	 * @return string
174 174
 	 */
175
-	public function column_email_type( Give_Email_Notification $email ) {
176
-		return Give_Email_Notification_Util::get_formatted_email_type( $email->config['content_type'] );
175
+	public function column_email_type(Give_Email_Notification $email) {
176
+		return Give_Email_Notification_Util::get_formatted_email_type($email->config['content_type']);
177 177
 	}
178 178
 
179 179
 	/**
@@ -186,15 +186,15 @@  discard block
 block discarded – undo
186 186
 	 *
187 187
 	 * @return string
188 188
 	 */
189
-	public function column_setting( Give_Email_Notification $email ) {
190
-		return Give()->tooltips->render_link( array(
191
-			'label'       => __( 'Edit', 'give' ) . " {$email->config['label']}",
189
+	public function column_setting(Give_Email_Notification $email) {
190
+		return Give()->tooltips->render_link(array(
191
+			'label'       => __('Edit', 'give')." {$email->config['label']}",
192 192
 			'tag_content' => '<span class="dashicons dashicons-admin-generic"></span>',
193
-			'link'        => esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=emails&section=' . $email->config['id'] ) ),
193
+			'link'        => esc_url(admin_url('edit.php?post_type=give_forms&page=give-settings&tab=emails&section='.$email->config['id'])),
194 194
 			'attributes'  => array(
195 195
 				'class' => 'button button-small',
196 196
 			),
197
-		) );
197
+		));
198 198
 	}
199 199
 
200 200
 
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
 	 *
209 209
 	 * @return array
210 210
 	 */
211
-	private function get_row_actions( $email ) {
212
-		$edit_url = esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=emails&section=' . $email->config['id'] ) );
211
+	private function get_row_actions($email) {
212
+		$edit_url = esc_url(admin_url('edit.php?post_type=give_forms&page=give-settings&tab=emails&section='.$email->config['id']));
213 213
 
214 214
 		/**
215 215
 		 * Filter the row actions
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 		$row_actions = apply_filters(
222 222
 			'give_email_notification_row_actions',
223 223
 			array(
224
-				'edit' => "<a href=\"{$edit_url}\">" . __( 'Edit', 'give' ) . '</a>',
224
+				'edit' => "<a href=\"{$edit_url}\">".__('Edit', 'give').'</a>',
225 225
 			),
226 226
 			$email
227 227
 		);
@@ -242,22 +242,22 @@  discard block
 block discarded – undo
242 242
 		$hidden                = array();
243 243
 		$email_notifications   = array();
244 244
 		$sortable              = $this->get_sortable_columns();
245
-		$this->_column_headers = array( $columns, $hidden, $sortable, $this->get_primary_column_name() );
245
+		$this->_column_headers = array($columns, $hidden, $sortable, $this->get_primary_column_name());
246 246
 
247 247
 		// Set email notifications.
248 248
 		/* @var Give_Email_Notification $email_notification */
249
-		foreach ( $this->email_notifications->get_email_notifications() as $email_notification ) {
250
-			if ( Give_Email_Notification_Util::is_show_on_emails_setting_page( $email_notification ) ) {
249
+		foreach ($this->email_notifications->get_email_notifications() as $email_notification) {
250
+			if (Give_Email_Notification_Util::is_show_on_emails_setting_page($email_notification)) {
251 251
 				$email_notifications[] = $email_notification;
252 252
 			}
253 253
 		}
254 254
 
255
-		$totalItems  = count( $email_notifications );
255
+		$totalItems  = count($email_notifications);
256 256
 		$this->items = $email_notifications;
257
-		$this->set_pagination_args( array(
257
+		$this->set_pagination_args(array(
258 258
 			'total_items' => $totalItems,
259 259
 			'per_page'    => $this->per_page,
260
-		) );
260
+		));
261 261
 	}
262 262
 
263 263
 	/**
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 	 * @access public
268 268
 	 */
269 269
 	public function no_items() {
270
-		_e( 'No give email notification found.', 'give' );
270
+		_e('No give email notification found.', 'give');
271 271
 	}
272 272
 
273 273
 	/**
Please login to merge, or discard this patch.
includes/admin/emails/class-email-setting-field.php 1 patch
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -21,30 +21,30 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @return array
23 23
 	 */
24
-	public static function get_setting_fields( Give_Email_Notification $email, $form_id = null ) {
25
-		$setting_fields = self::get_default_setting_fields( $email, $form_id );
24
+	public static function get_setting_fields(Give_Email_Notification $email, $form_id = null) {
25
+		$setting_fields = self::get_default_setting_fields($email, $form_id);
26 26
 
27 27
 		// Recipient field.
28
-		$setting_fields[] = self::get_recipient_setting_field( $email, $form_id, Give_Email_Notification_Util::has_recipient_field( $email ) );
28
+		$setting_fields[] = self::get_recipient_setting_field($email, $form_id, Give_Email_Notification_Util::has_recipient_field($email));
29 29
 
30 30
 		// Add extra setting field.
31
-		if ( $extra_setting_field = $email->get_extra_setting_fields( $form_id ) ) {
32
-			$setting_fields = array_merge( $setting_fields, $extra_setting_field );
31
+		if ($extra_setting_field = $email->get_extra_setting_fields($form_id)) {
32
+			$setting_fields = array_merge($setting_fields, $extra_setting_field);
33 33
 		}
34 34
 
35 35
 		// Preview field.
36
-		if ( Give_Email_Notification_Util::has_preview( $email ) ) {
37
-			$setting_fields[] = self::get_preview_setting_field( $email, $form_id );
36
+		if (Give_Email_Notification_Util::has_preview($email)) {
37
+			$setting_fields[] = self::get_preview_setting_field($email, $form_id);
38 38
 		}
39 39
 
40
-		$setting_fields = self::add_section_end( $email, $setting_fields );
40
+		$setting_fields = self::add_section_end($email, $setting_fields);
41 41
 
42 42
 		/**
43 43
 		 * Filter the email notification settings.
44 44
 		 *
45 45
 		 * @since 2.0
46 46
 		 */
47
-		return apply_filters( 'give_email_notification_setting_fields', $setting_fields, $email, $form_id );
47
+		return apply_filters('give_email_notification_setting_fields', $setting_fields, $email, $form_id);
48 48
 	}
49 49
 
50 50
 
@@ -58,11 +58,11 @@  discard block
 block discarded – undo
58 58
 	 *
59 59
 	 * @return bool
60 60
 	 */
61
-	public static function has_section_end( $setting ) {
62
-		$last_field      = end( $setting );
61
+	public static function has_section_end($setting) {
62
+		$last_field      = end($setting);
63 63
 		$has_section_end = false;
64 64
 
65
-		if ( 'sectionend' === $last_field['type'] ) {
65
+		if ('sectionend' === $last_field['type']) {
66 66
 			$has_section_end = true;
67 67
 		}
68 68
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @return array
82 82
 	 */
83
-	public static function get_section_start( Give_Email_Notification $email, $form_id = null ) {
83
+	public static function get_section_start(Give_Email_Notification $email, $form_id = null) {
84 84
 		// Add section end field.
85 85
 		$setting = array(
86 86
 			'id'    => "give_title_email_settings_{$email->config['id']}",
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 	 *
103 103
 	 * @return array
104 104
 	 */
105
-	public static function add_section_end( Give_Email_Notification $email, $setting ) {
106
-		if ( ! self::has_section_end( $setting ) ) {
105
+	public static function add_section_end(Give_Email_Notification $email, $setting) {
106
+		if ( ! self::has_section_end($setting)) {
107 107
 			// Add section end field.
108 108
 			$setting[] = array(
109 109
 				'id'   => "give_title_email_settings_{$email->config['id']}",
@@ -125,25 +125,25 @@  discard block
 block discarded – undo
125 125
 	 *
126 126
 	 * @return array
127 127
 	 */
128
-	public static function get_default_setting_fields( Give_Email_Notification $email, $form_id = null ) {
129
-		$settings[] = self::get_section_start( $email, $form_id );
130
-		$settings[] = self::get_notification_status_field( $email, $form_id );
128
+	public static function get_default_setting_fields(Give_Email_Notification $email, $form_id = null) {
129
+		$settings[] = self::get_section_start($email, $form_id);
130
+		$settings[] = self::get_notification_status_field($email, $form_id);
131 131
 
132
-		if ( ! Give_Email_Notification_Util::is_notification_status_editable( $email ) ) {
133
-			if ( $form_id || give_is_add_new_form_page() ) {
132
+		if ( ! Give_Email_Notification_Util::is_notification_status_editable($email)) {
133
+			if ($form_id || give_is_add_new_form_page()) {
134 134
 				// Do not allow admin to disable notification on perform basis.
135
-				unset( $settings[1]['options']['disabled'] );
135
+				unset($settings[1]['options']['disabled']);
136 136
 			} else {
137 137
 				// Do not allow admin to edit notification status globally.
138
-				unset( $settings[1] );
138
+				unset($settings[1]);
139 139
 			}
140 140
 		}
141 141
 
142
-		$settings[] = self::get_email_subject_field( $email, $form_id );
143
-		$settings[] = self::get_email_message_field( $email, $form_id );
142
+		$settings[] = self::get_email_subject_field($email, $form_id);
143
+		$settings[] = self::get_email_message_field($email, $form_id);
144 144
 
145
-		if ( Give_Email_Notification_Util::is_content_type_editable( $email ) ) {
146
-			$settings[] = self::get_email_content_type_field( $email, $form_id );
145
+		if (Give_Email_Notification_Util::is_content_type_editable($email)) {
146
+			$settings[] = self::get_email_content_type_field($email, $form_id);
147 147
 		}
148 148
 
149 149
 		return $settings;
@@ -160,31 +160,31 @@  discard block
 block discarded – undo
160 160
 	 *
161 161
 	 * @return array
162 162
 	 */
163
-	public static function get_notification_status_field( Give_Email_Notification $email, $form_id = null ) {
163
+	public static function get_notification_status_field(Give_Email_Notification $email, $form_id = null) {
164 164
 		$option = array(
165
-			'enabled'  => __( 'Enabled', 'give' ),
166
-			'disabled' => __( 'Disabled', 'give' ),
165
+			'enabled'  => __('Enabled', 'give'),
166
+			'disabled' => __('Disabled', 'give'),
167 167
 		);
168 168
 
169 169
 		$default_value = $email->get_notification_status();
170 170
 
171 171
 		// Add global options.
172
-		if ( $form_id || give_is_add_new_form_page() ) {
172
+		if ($form_id || give_is_add_new_form_page()) {
173 173
 			$option = array(
174
-				'global'   => __( 'Global Options' ),
175
-				'enabled'  => __( 'Customize', 'give' ),
176
-				'disabled' => __( 'Disabled', 'give' ),
174
+				'global'   => __('Global Options'),
175
+				'enabled'  => __('Customize', 'give'),
176
+				'disabled' => __('Disabled', 'give'),
177 177
 			);
178 178
 
179 179
 			$default_value = 'global';
180 180
 		}
181 181
 
182
-		$description = isset( $_GET['page'] ) && 'give-settings' === $_GET['page'] ? __( 'Choose whether you want this email enabled or not.', 'give' ) : sprintf( __( 'Global Options are set <a href="%s">in Give settings</a>. You may override them for this form here.', 'give' ), admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=emails' ) );
182
+		$description = isset($_GET['page']) && 'give-settings' === $_GET['page'] ? __('Choose whether you want this email enabled or not.', 'give') : sprintf(__('Global Options are set <a href="%s">in Give settings</a>. You may override them for this form here.', 'give'), admin_url('edit.php?post_type=give_forms&page=give-settings&tab=emails'));
183 183
 
184 184
 		return array(
185
-			'name'          => esc_html__( 'Notification', 'give' ),
185
+			'name'          => esc_html__('Notification', 'give'),
186 186
 			'desc'          => $description,
187
-			'id'            => self::get_prefix( $email, $form_id ) . 'notification',
187
+			'id'            => self::get_prefix($email, $form_id).'notification',
188 188
 			'type'          => 'radio_inline',
189 189
 			'default'       => $default_value,
190 190
 			'options'       => $option,
@@ -203,11 +203,11 @@  discard block
 block discarded – undo
203 203
 	 *
204 204
 	 * @return array
205 205
 	 */
206
-	public static function get_email_subject_field( Give_Email_Notification $email, $form_id = null ) {
206
+	public static function get_email_subject_field(Give_Email_Notification $email, $form_id = null) {
207 207
 		return array(
208
-			'id'      => self::get_prefix( $email, $form_id ) . 'email_subject',
209
-			'name'    => esc_html__( 'Email Subject', 'give' ),
210
-			'desc'    => esc_html__( 'Enter the email subject line.', 'give' ),
208
+			'id'      => self::get_prefix($email, $form_id).'email_subject',
209
+			'name'    => esc_html__('Email Subject', 'give'),
210
+			'desc'    => esc_html__('Enter the email subject line.', 'give'),
211 211
 			'default' => $email->config['default_email_subject'],
212 212
 			'type'    => 'text',
213 213
 		);
@@ -224,28 +224,28 @@  discard block
 block discarded – undo
224 224
 	 *
225 225
 	 * @return array
226 226
 	 */
227
-	public static function get_email_message_field( Give_Email_Notification $email, $form_id = null ) {
228
-		$desc = esc_html__( 'Enter the email message.', 'give' );
227
+	public static function get_email_message_field(Give_Email_Notification $email, $form_id = null) {
228
+		$desc = esc_html__('Enter the email message.', 'give');
229 229
 
230
-		if ( $email_tag_list = $email->get_allowed_email_tags( true ) ) {
230
+		if ($email_tag_list = $email->get_allowed_email_tags(true)) {
231 231
 			$desc = sprintf(
232 232
 				'%1$s <br> %2$s: %3$s %4$s',
233
-				__( 'The email that is sent to users after completing a successful donation. HTML is accepted.', 'give' ),
234
-				__( 'Available template tags', 'give' ),
233
+				__('The email that is sent to users after completing a successful donation. HTML is accepted.', 'give'),
234
+				__('Available template tags', 'give'),
235 235
 				$email_tag_list,
236 236
 				sprintf(
237 237
 					'<br><a href="%1$s" target="_blank">%2$s</a> %3$s',
238
-					esc_url( 'http://docs.givewp.com/meta-email-tags' ),
239
-					__( 'See our documentation', 'give' ),
240
-					__( 'for examples of how to use custom meta email tags to output additional donor or donation information in your Give emails.', 'give' )
238
+					esc_url('http://docs.givewp.com/meta-email-tags'),
239
+					__('See our documentation', 'give'),
240
+					__('for examples of how to use custom meta email tags to output additional donor or donation information in your Give emails.', 'give')
241 241
 				)
242 242
 			);
243 243
 
244 244
 		}
245 245
 
246 246
 		return array(
247
-			'id'      => self::get_prefix( $email, $form_id ) . 'email_message',
248
-			'name'    => esc_html__( 'Email message', 'give' ),
247
+			'id'      => self::get_prefix($email, $form_id).'email_message',
248
+			'name'    => esc_html__('Email message', 'give'),
249 249
 			'desc'    => $desc,
250 250
 			'type'    => 'wysiwyg',
251 251
 			'default' => $email->config['default_email_message'],
@@ -263,15 +263,15 @@  discard block
 block discarded – undo
263 263
 	 *
264 264
 	 * @return array
265 265
 	 */
266
-	public static function get_email_content_type_field( Give_Email_Notification $email, $form_id = null ) {
266
+	public static function get_email_content_type_field(Give_Email_Notification $email, $form_id = null) {
267 267
 		return array(
268
-			'id'      => self::get_prefix( $email, $form_id ) . 'email_content_type',
269
-			'name'    => esc_html__( 'Email Content Type', 'give' ),
270
-			'desc'    => __( 'Choose email type.', 'give' ),
268
+			'id'      => self::get_prefix($email, $form_id).'email_content_type',
269
+			'name'    => esc_html__('Email Content Type', 'give'),
270
+			'desc'    => __('Choose email type.', 'give'),
271 271
 			'type'    => 'select',
272 272
 			'options' => array(
273
-				'text/html'  => Give_Email_Notification_Util::get_formatted_email_type( 'text/html' ),
274
-				'text/plain' => Give_Email_Notification_Util::get_formatted_email_type( 'text/plain' ),
273
+				'text/html'  => Give_Email_Notification_Util::get_formatted_email_type('text/html'),
274
+				'text/plain' => Give_Email_Notification_Util::get_formatted_email_type('text/plain'),
275 275
 			),
276 276
 			'default' => $email->config['content_type'],
277 277
 		);
@@ -291,29 +291,29 @@  discard block
 block discarded – undo
291 291
 	 *
292 292
 	 * @return array
293 293
 	 */
294
-	public static function get_recipient_setting_field( Give_Email_Notification $email, $form_id = null, $edit_recipient = true ) {
294
+	public static function get_recipient_setting_field(Give_Email_Notification $email, $form_id = null, $edit_recipient = true) {
295 295
 		$recipient = array(
296
-			'id'               => self::get_prefix( $email, $form_id ) . 'recipient',
297
-			'name'             => esc_html__( 'Email Recipients', 'give' ),
298
-			'desc'             => __( 'Enter the email address(es) that should receive a notification.', 'give' ),
296
+			'id'               => self::get_prefix($email, $form_id).'recipient',
297
+			'name'             => esc_html__('Email Recipients', 'give'),
298
+			'desc'             => __('Enter the email address(es) that should receive a notification.', 'give'),
299 299
 			'type'             => 'email',
300
-			'default'          => get_bloginfo( 'admin_email' ),
300
+			'default'          => get_bloginfo('admin_email'),
301 301
 			'repeat'           => true,
302
-			'repeat_btn_title' => esc_html__( 'Add Recipient', 'give' ),
302
+			'repeat_btn_title' => esc_html__('Add Recipient', 'give'),
303 303
 		);
304 304
 
305
-		if ( $form_id || give_is_add_new_form_page() ) {
306
-			$recipient['name']    = __( 'Email', 'give' );
305
+		if ($form_id || give_is_add_new_form_page()) {
306
+			$recipient['name']    = __('Email', 'give');
307 307
 			$recipient['default'] = '';
308 308
 			$recipient['id']      = 'email';
309
-			$recipient['desc']    = __( 'Enter the email address that should receive a notification.', 'give' );
309
+			$recipient['desc']    = __('Enter the email address that should receive a notification.', 'give');
310 310
 
311 311
 			$recipient = array(
312
-				'id'      => self::get_prefix( $email, $form_id ) . 'recipient',
312
+				'id'      => self::get_prefix($email, $form_id).'recipient',
313 313
 				'type'    => 'group',
314 314
 				'options' => array(
315
-					'add_button'    => __( 'Add Email', 'give' ),
316
-					'header_title'  => __( 'Email Recipient', 'give' ),
315
+					'add_button'    => __('Add Email', 'give'),
316
+					'header_title'  => __('Email Recipient', 'give'),
317 317
 					'remove_button' => '<span class="dashicons dashicons-no"></span>',
318 318
 				),
319 319
 				'fields'  => array(
@@ -324,16 +324,16 @@  discard block
 block discarded – undo
324 324
 
325 325
 		// Disable field if email donor has recipient field.
326 326
 		// @see https://github.com/WordImpress/Give/issues/2657
327
-		if ( ! $edit_recipient ) {
328
-			if ( 'group' == $recipient['type'] ) {
329
-				$recipient         = current( $recipient['fields'] );
327
+		if ( ! $edit_recipient) {
328
+			if ('group' == $recipient['type']) {
329
+				$recipient         = current($recipient['fields']);
330 330
 				$recipient['type'] = 'text';
331 331
 			}
332 332
 
333 333
 			$recipient['attributes']['disabled'] = 'disabled';
334 334
 			$recipient['value']                  = $recipient['default'] = '{donor_email}';
335 335
 			$recipient['repeat']                 = false;
336
-			$recipient['desc']                   = __( 'This email is automatically sent to the donor and the recipient cannot be customized.', 'give' );
336
+			$recipient['desc']                   = __('This email is automatically sent to the donor and the recipient cannot be customized.', 'give');
337 337
 		}
338 338
 
339 339
 		return $recipient;
@@ -350,12 +350,12 @@  discard block
 block discarded – undo
350 350
 	 *
351 351
 	 * @return array
352 352
 	 */
353
-	public static function get_preview_setting_field( Give_Email_Notification $email, $form_id = null ) {
353
+	public static function get_preview_setting_field(Give_Email_Notification $email, $form_id = null) {
354 354
 		return array(
355
-			'name' => __( 'Preview Email', 'give' ),
356
-			'desc' => __( 'Click the "Preview Email" button to preview the email in your browser. Click the "Send Test Email" button to send a test email directly to your inbox.',
357
-				'give' ),
358
-			'id'   => self::get_prefix( $email, $form_id ) . 'preview_buttons',
355
+			'name' => __('Preview Email', 'give'),
356
+			'desc' => __('Click the "Preview Email" button to preview the email in your browser. Click the "Send Test Email" button to send a test email directly to your inbox.',
357
+				'give'),
358
+			'id'   => self::get_prefix($email, $form_id).'preview_buttons',
359 359
 			'type' => 'email_preview_buttons',
360 360
 		);
361 361
 	}
@@ -372,10 +372,10 @@  discard block
 block discarded – undo
372 372
 	 *
373 373
 	 * @return string
374 374
 	 */
375
-	public static function get_prefix( Give_Email_Notification $email, $form_id = null ) {
375
+	public static function get_prefix(Give_Email_Notification $email, $form_id = null) {
376 376
 		$meta_key = "{$email->config['id']}_";
377 377
 
378
-		if ( $form_id || give_is_add_new_form_page() ) {
378
+		if ($form_id || give_is_add_new_form_page()) {
379 379
 			$meta_key = "_give_{$email->config['id']}_";
380 380
 		}
381 381
 
Please login to merge, or discard this patch.
includes/admin/plugins.php 1 patch
Spacing   +75 added lines, -76 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,19 +23,19 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return array An array of updated action links.
25 25
  */
26
-function give_plugin_action_links( $actions ) {
26
+function give_plugin_action_links($actions) {
27 27
 	$new_actions = array(
28 28
 		'settings' => sprintf(
29 29
 			'<a href="%1$s">%2$s</a>',
30
-			admin_url( 'edit.php?post_type=give_forms&page=give-settings' ),
31
-			__( 'Settings', 'give' )
30
+			admin_url('edit.php?post_type=give_forms&page=give-settings'),
31
+			__('Settings', 'give')
32 32
 		),
33 33
 	);
34 34
 
35
-	return array_merge( $new_actions, $actions );
35
+	return array_merge($new_actions, $actions);
36 36
 }
37 37
 
38
-add_filter( 'plugin_action_links_' . GIVE_PLUGIN_BASENAME, 'give_plugin_action_links' );
38
+add_filter('plugin_action_links_'.GIVE_PLUGIN_BASENAME, 'give_plugin_action_links');
39 39
 
40 40
 
41 41
 /**
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
  *
49 49
  * @return array
50 50
  */
51
-function give_plugin_row_meta( $plugin_meta, $plugin_file ) {
52
-	if ( GIVE_PLUGIN_BASENAME !== $plugin_file ) {
51
+function give_plugin_row_meta($plugin_meta, $plugin_file) {
52
+	if (GIVE_PLUGIN_BASENAME !== $plugin_file) {
53 53
 		return $plugin_meta;
54 54
 	}
55 55
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 					), 'https://givewp.com/documentation/'
66 66
 				)
67 67
 			),
68
-			__( 'Documentation', 'give' )
68
+			__('Documentation', 'give')
69 69
 		),
70 70
 		sprintf(
71 71
 			'<a href="%1$s" target="_blank">%2$s</a>',
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
 					), 'https://givewp.com/addons/'
79 79
 				)
80 80
 			),
81
-			__( 'Add-ons', 'give' )
81
+			__('Add-ons', 'give')
82 82
 		),
83 83
 	);
84 84
 
85
-	return array_merge( $plugin_meta, $new_meta_links );
85
+	return array_merge($plugin_meta, $new_meta_links);
86 86
 }
87 87
 
88
-add_filter( 'plugin_row_meta', 'give_plugin_row_meta', 10, 2 );
88
+add_filter('plugin_row_meta', 'give_plugin_row_meta', 10, 2);
89 89
 
90 90
 
91 91
 /**
@@ -103,19 +103,18 @@  discard block
 block discarded – undo
103 103
 	$title = '';
104 104
 	global $submenu, $plugin_page;
105 105
 
106
-	foreach ( array_keys( $submenu ) as $parent ) {
107
-		if ( 'edit.php?post_type=give_forms' !== $parent ) {
106
+	foreach (array_keys($submenu) as $parent) {
107
+		if ('edit.php?post_type=give_forms' !== $parent) {
108 108
 			continue;
109 109
 		}
110 110
 
111
-		foreach ( $submenu[ $parent ] as $submenu_array ) {
112
-			if ( $plugin_page !== $submenu_array[2] ) {
111
+		foreach ($submenu[$parent] as $submenu_array) {
112
+			if ($plugin_page !== $submenu_array[2]) {
113 113
 				continue;
114 114
 			}
115 115
 
116
-			$title = isset( $submenu_array[0] ) ?
117
-				$submenu_array[0] :
118
-				$submenu_array[3];
116
+			$title = isset($submenu_array[0]) ?
117
+				$submenu_array[0] : $submenu_array[3];
119 118
 		}
120 119
 	}
121 120
 
@@ -129,11 +128,11 @@  discard block
 block discarded – undo
129 128
  */
130 129
 function give_recently_activated_addons() {
131 130
 	// Check if action is set.
132
-	if ( isset( $_REQUEST['action'] ) ) {
133
-		$plugin_action = ( '-1' !== $_REQUEST['action'] ) ? $_REQUEST['action'] : ( isset( $_REQUEST['action2'] ) ? $_REQUEST['action2'] : '' );
131
+	if (isset($_REQUEST['action'])) {
132
+		$plugin_action = ('-1' !== $_REQUEST['action']) ? $_REQUEST['action'] : (isset($_REQUEST['action2']) ? $_REQUEST['action2'] : '');
134 133
 		$plugins       = array();
135 134
 
136
-		switch ( $plugin_action ) {
135
+		switch ($plugin_action) {
137 136
 			case 'activate': // Single add-on activation.
138 137
 				$plugins[] = $_REQUEST['plugin'];
139 138
 				break;
@@ -142,25 +141,25 @@  discard block
 block discarded – undo
142 141
 				break;
143 142
 		}
144 143
 
145
-		if ( ! empty( $plugins ) ) {
144
+		if ( ! empty($plugins)) {
146 145
 			$give_addons = array();
147
-			foreach ( $plugins as $plugin ) {
146
+			foreach ($plugins as $plugin) {
148 147
 				// Get plugins which has 'Give-' as prefix.
149
-				if ( stripos( $plugin, 'Give-' ) !== false ) {
148
+				if (stripos($plugin, 'Give-') !== false) {
150 149
 					$give_addons[] = $plugin;
151 150
 				}
152 151
 			}
153 152
 
154
-			if ( ! empty( $give_addons ) ) {
153
+			if ( ! empty($give_addons)) {
155 154
 				// Update the Give's activated add-ons.
156
-				update_option( 'give_recently_activated_addons', $give_addons );
155
+				update_option('give_recently_activated_addons', $give_addons);
157 156
 			}
158 157
 		}
159 158
 	}
160 159
 }
161 160
 
162 161
 // Add add-on plugins to wp option table.
163
-add_action( 'activated_plugin', 'give_recently_activated_addons', 10 );
162
+add_action('activated_plugin', 'give_recently_activated_addons', 10);
164 163
 
165 164
 /**
166 165
  * Create new menu in plugin section that include all the add-on
@@ -171,19 +170,19 @@  discard block
 block discarded – undo
171 170
  *
172 171
  * @return mixed
173 172
  */
174
-function give_filter_addons_do_filter_addons( $plugin_menu ) {
173
+function give_filter_addons_do_filter_addons($plugin_menu) {
175 174
 	global $plugins;
176 175
 
177
-	foreach ( $plugins['all'] as $plugin_slug => $plugin_data ) {
176
+	foreach ($plugins['all'] as $plugin_slug => $plugin_data) {
178 177
 
179
-		if ( false !== strpos( $plugin_data['Name'], 'Give' ) && false !== strpos( $plugin_data['AuthorName'], 'WordImpress' ) ) {
180
-			$plugins['give'][ $plugin_slug ]           = $plugins['all'][ $plugin_slug ];
181
-			$plugins['give'][ $plugin_slug ]['plugin'] = $plugin_slug;
178
+		if (false !== strpos($plugin_data['Name'], 'Give') && false !== strpos($plugin_data['AuthorName'], 'WordImpress')) {
179
+			$plugins['give'][$plugin_slug]           = $plugins['all'][$plugin_slug];
180
+			$plugins['give'][$plugin_slug]['plugin'] = $plugin_slug;
182 181
 			// replicate the next step.
183
-			if ( current_user_can( 'update_plugins' ) ) {
184
-				$current = get_site_transient( 'update_plugins' );
185
-				if ( isset( $current->response[ $plugin_slug ] ) ) {
186
-					$plugins['give'][ $plugin_slug ]['update'] = true;
182
+			if (current_user_can('update_plugins')) {
183
+				$current = get_site_transient('update_plugins');
184
+				if (isset($current->response[$plugin_slug])) {
185
+					$plugins['give'][$plugin_slug]['update'] = true;
187 186
 				}
188 187
 			}
189 188
 		}
@@ -193,7 +192,7 @@  discard block
 block discarded – undo
193 192
 
194 193
 }
195 194
 
196
-add_filter( 'show_advanced_plugins', 'give_filter_addons_do_filter_addons' );
195
+add_filter('show_advanced_plugins', 'give_filter_addons_do_filter_addons');
197 196
 
198 197
 /**
199 198
  * Make the Give Menu as an default menu and update the Menu Name
@@ -204,29 +203,29 @@  discard block
 block discarded – undo
204 203
  *
205 204
  * @return mixed
206 205
  */
207
-function give_filter_addons_filter_addons( $views ) {
206
+function give_filter_addons_filter_addons($views) {
208 207
 
209 208
 	global $status, $plugins;
210 209
 
211
-	if ( ! empty( $plugins['give'] ) ) {
210
+	if ( ! empty($plugins['give'])) {
212 211
 		$class = '';
213 212
 
214
-		if ( 'give' === $status ) {
213
+		if ('give' === $status) {
215 214
 			$class = 'current';
216 215
 		}
217 216
 
218 217
 		$views['give'] = sprintf(
219 218
 			'<a class="%s" href="plugins.php?plugin_status=give"> %s <span class="count">(%s) </span></a>',
220 219
 			$class,
221
-			__( 'Give', 'give' ),
222
-			count( $plugins['give'] )
220
+			__('Give', 'give'),
221
+			count($plugins['give'])
223 222
 		);
224 223
 	}
225 224
 
226 225
 	return $views;
227 226
 }
228 227
 
229
-add_filter( 'views_plugins', 'give_filter_addons_filter_addons' );
228
+add_filter('views_plugins', 'give_filter_addons_filter_addons');
230 229
 
231 230
 /**
232 231
  * Set the Give as the Main menu when admin click on the Give Menu in Plugin section.
@@ -237,17 +236,17 @@  discard block
 block discarded – undo
237 236
  *
238 237
  * @return mixed
239 238
  */
240
-function give_prepare_filter_addons( $plugins ) {
239
+function give_prepare_filter_addons($plugins) {
241 240
 	global $status;
242 241
 
243
-	if ( isset( $_REQUEST['plugin_status'] ) && 'give' === $_REQUEST['plugin_status'] ) {
242
+	if (isset($_REQUEST['plugin_status']) && 'give' === $_REQUEST['plugin_status']) {
244 243
 		$status = 'give';
245 244
 	}
246 245
 
247 246
 	return $plugins;
248 247
 }
249 248
 
250
-add_filter( 'all_plugins', 'give_prepare_filter_addons' );
249
+add_filter('all_plugins', 'give_prepare_filter_addons');
251 250
 
252 251
 
253 252
 /**
@@ -258,26 +257,26 @@  discard block
 block discarded – undo
258 257
  *
259 258
  * @since 2.1
260 259
  */
261
-function give_in_plugin_update_message( $data, $response ) {
260
+function give_in_plugin_update_message($data, $response) {
262 261
 	$new_version           = $data['new_version'];
263
-	$current_version_parts = explode( '.', GIVE_VERSION );
264
-	$new_version_parts     = explode( '.', $new_version );
262
+	$current_version_parts = explode('.', GIVE_VERSION);
263
+	$new_version_parts     = explode('.', $new_version);
265 264
 
266 265
 	// If it is a minor upgrade then return.
267
-	if ( version_compare( $current_version_parts[0] . '.' . $current_version_parts[1], $new_version_parts[0] . '.' . $new_version_parts[1], '=' ) ) {
266
+	if (version_compare($current_version_parts[0].'.'.$current_version_parts[1], $new_version_parts[0].'.'.$new_version_parts[1], '=')) {
268 267
 
269 268
 		return;
270 269
 	}
271 270
 
272 271
 	// Get the upgrade notice from the trunk.
273
-	$upgrade_notice = give_get_plugin_upgrade_notice( $new_version );
272
+	$upgrade_notice = give_get_plugin_upgrade_notice($new_version);
274 273
 
275 274
 	// Display upgrade notice.
276
-	echo apply_filters( 'give_in_plugin_update_message', $upgrade_notice ? '</p>' . wp_kses_post( $upgrade_notice ) . '<p class="dummy">' : '' );
275
+	echo apply_filters('give_in_plugin_update_message', $upgrade_notice ? '</p>'.wp_kses_post($upgrade_notice).'<p class="dummy">' : '');
277 276
 }
278 277
 
279 278
 // Display upgrade notice.
280
-add_action( 'in_plugin_update_message-Give/give.php', 'give_in_plugin_update_message', 10, 2 );
279
+add_action('in_plugin_update_message-Give/give.php', 'give_in_plugin_update_message', 10, 2);
281 280
 
282 281
 
283 282
 /**
@@ -291,18 +290,18 @@  discard block
 block discarded – undo
291 290
  *
292 291
  * @return string
293 292
  */
294
-function give_get_plugin_upgrade_notice( $new_version ) {
293
+function give_get_plugin_upgrade_notice($new_version) {
295 294
 
296 295
 	// Cache the upgrade notice.
297 296
 	$transient_name = "give_upgrade_notice_{$new_version}";
298
-	$upgrade_notice = get_transient( $transient_name );
297
+	$upgrade_notice = get_transient($transient_name);
299 298
 
300
-	if ( false === $upgrade_notice ) {
301
-		$response = wp_safe_remote_get( 'https://plugins.svn.wordpress.org/give/trunk/readme.txt' );
299
+	if (false === $upgrade_notice) {
300
+		$response = wp_safe_remote_get('https://plugins.svn.wordpress.org/give/trunk/readme.txt');
302 301
 
303
-		if ( ! is_wp_error( $response ) && ! empty( $response['body'] ) ) {
304
-			$upgrade_notice = give_parse_plugin_update_notice( $response['body'], $new_version );
305
-			set_transient( $transient_name, $upgrade_notice, DAY_IN_SECONDS );
302
+		if ( ! is_wp_error($response) && ! empty($response['body'])) {
303
+			$upgrade_notice = give_parse_plugin_update_notice($response['body'], $new_version);
304
+			set_transient($transient_name, $upgrade_notice, DAY_IN_SECONDS);
306 305
 		}
307 306
 	}
308 307
 
@@ -322,34 +321,34 @@  discard block
 block discarded – undo
322 321
  *
323 322
  * @return string
324 323
  */
325
-function give_parse_plugin_update_notice( $content, $new_version ) {
326
-	$version_parts     = explode( '.', $new_version );
324
+function give_parse_plugin_update_notice($content, $new_version) {
325
+	$version_parts     = explode('.', $new_version);
327 326
 	$check_for_notices = array(
328
-		$version_parts[0] . '.0',
329
-		$version_parts[0] . '.0.0',
330
-		$version_parts[0] . '.' . $version_parts[1],
327
+		$version_parts[0].'.0',
328
+		$version_parts[0].'.0.0',
329
+		$version_parts[0].'.'.$version_parts[1],
331 330
 	);
332 331
 
333 332
 	// Regex to extract Upgrade notice from the readme.txt file.
334
-	$notice_regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( $new_version ) . '\s*=|$)~Uis';
333
+	$notice_regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*'.preg_quote($new_version).'\s*=|$)~Uis';
335 334
 
336 335
 	$upgrade_notice = '';
337 336
 
338
-	foreach ( $check_for_notices as $check_version ) {
339
-		if ( version_compare( GIVE_VERSION, $check_version, '>' ) ) {
337
+	foreach ($check_for_notices as $check_version) {
338
+		if (version_compare(GIVE_VERSION, $check_version, '>')) {
340 339
 			continue;
341 340
 		}
342 341
 
343 342
 		$matches = null;
344 343
 
345
-		if ( preg_match( $notice_regexp, $content, $matches ) ) {
346
-			$notices = (array) preg_split( '~[\r\n]+~', trim( $matches[2] ) );
344
+		if (preg_match($notice_regexp, $content, $matches)) {
345
+			$notices = (array) preg_split('~[\r\n]+~', trim($matches[2]));
347 346
 
348
-			if ( version_compare( trim( $matches[1] ), $check_version, '=' ) ) {
347
+			if (version_compare(trim($matches[1]), $check_version, '=')) {
349 348
 				$upgrade_notice .= '<p class="give-plugin-upgrade-notice">';
350 349
 
351
-				foreach ( $notices as $index => $line ) {
352
-					$upgrade_notice .= preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line );
350
+				foreach ($notices as $index => $line) {
351
+					$upgrade_notice .= preg_replace('~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line);
353 352
 				}
354 353
 
355 354
 				$upgrade_notice .= '</p>';
@@ -359,7 +358,7 @@  discard block
 block discarded – undo
359 358
 		}
360 359
 	}
361 360
 
362
-	return wp_kses_post( $upgrade_notice );
361
+	return wp_kses_post($upgrade_notice);
363 362
 }
364 363
 
365 364
 
@@ -396,4 +395,4 @@  discard block
 block discarded – undo
396 395
 <?php
397 396
 }
398 397
 
399
-add_action( 'admin_head', 'give_plugin_notice_css' );
398
+add_action('admin_head', 'give_plugin_notice_css');
Please login to merge, or discard this patch.
includes/admin/upgrades/class-give-updates.php 2 patches
Spacing   +248 added lines, -255 removed lines patch added patch discarded remove patch
@@ -80,34 +80,34 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @param array $args
82 82
 	 */
83
-	public function register( $args ) {
83
+	public function register($args) {
84 84
 		$args_default = array(
85 85
 			'id'       => '',
86 86
 			'version'  => '',
87 87
 			'callback' => '',
88 88
 		);
89 89
 
90
-		$args = wp_parse_args( $args, $args_default );
90
+		$args = wp_parse_args($args, $args_default);
91 91
 
92 92
 		// You can only register database upgrade.
93 93
 		$args['type'] = 'database';
94 94
 
95 95
 		// Bailout.
96 96
 		if (
97
-			empty( $args['id'] ) ||
98
-			empty( $args['version'] ) ||
99
-			empty( $args['callback'] ) ||
100
-			! is_callable( $args['callback'] )
97
+			empty($args['id']) ||
98
+			empty($args['version']) ||
99
+			empty($args['callback']) ||
100
+			! is_callable($args['callback'])
101 101
 		) {
102 102
 			return;
103 103
 		}
104 104
 
105 105
 		// Change depend param to array.
106
-		if ( isset( $args['depend'] ) && is_string( $args['depend'] ) ) {
107
-			$args['depend'] = array( $args['depend'] );
106
+		if (isset($args['depend']) && is_string($args['depend'])) {
107
+			$args['depend'] = array($args['depend']);
108 108
 		}
109 109
 
110
-		$this->updates[ $args['type'] ][] = $args;
110
+		$this->updates[$args['type']][] = $args;
111 111
 	}
112 112
 
113 113
 	/**
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 * @return static
119 119
 	 */
120 120
 	static function get_instance() {
121
-		if ( is_null( self::$instance ) ) {
121
+		if (is_null(self::$instance)) {
122 122
 			self::$instance = new self();
123 123
 		}
124 124
 
@@ -136,27 +136,27 @@  discard block
 block discarded – undo
136 136
 		/**
137 137
 		 * Load file
138 138
 		 */
139
-		require_once GIVE_PLUGIN_DIR . 'includes/class-give-background-updater.php';
140
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';
139
+		require_once GIVE_PLUGIN_DIR.'includes/class-give-background-updater.php';
140
+		require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php';
141 141
 
142 142
 		self::$background_updater = new Give_Background_Updater();
143 143
 
144 144
 		/**
145 145
 		 * Setup hooks.
146 146
 		 */
147
-		add_action( 'init', array( $this, '__register_upgrade' ), 9999 );
148
-		add_action( 'give_set_upgrade_completed', array( $this, '__flush_resume_updates' ), 9999 );
149
-		add_action( 'wp_ajax_give_db_updates_info', array( $this, '__give_db_updates_info' ) );
150
-		add_action( 'wp_ajax_give_run_db_updates', array( $this, '__give_start_updating' ) );
151
-		add_action( 'admin_init', array( $this, '__redirect_admin' ) );
152
-		add_action( 'admin_init', array( $this, '__pause_db_update' ), - 1 );
153
-		add_action( 'admin_init', array( $this, '__restart_db_update' ), - 1 );
154
-		add_action( 'admin_notices', array( $this, '__show_notice' ) );
155
-		add_action( 'give_restart_db_upgrade', array( $this, '__health_background_update' ) );
156
-
157
-		if ( is_admin() ) {
158
-			add_action( 'admin_init', array( $this, '__change_donations_label' ), 9999 );
159
-			add_action( 'admin_menu', array( $this, '__register_menu' ), 9999 );
147
+		add_action('init', array($this, '__register_upgrade'), 9999);
148
+		add_action('give_set_upgrade_completed', array($this, '__flush_resume_updates'), 9999);
149
+		add_action('wp_ajax_give_db_updates_info', array($this, '__give_db_updates_info'));
150
+		add_action('wp_ajax_give_run_db_updates', array($this, '__give_start_updating'));
151
+		add_action('admin_init', array($this, '__redirect_admin'));
152
+		add_action('admin_init', array($this, '__pause_db_update'), - 1);
153
+		add_action('admin_init', array($this, '__restart_db_update'), - 1);
154
+		add_action('admin_notices', array($this, '__show_notice'));
155
+		add_action('give_restart_db_upgrade', array($this, '__health_background_update'));
156
+
157
+		if (is_admin()) {
158
+			add_action('admin_init', array($this, '__change_donations_label'), 9999);
159
+			add_action('admin_menu', array($this, '__register_menu'), 9999);
160 160
 		}
161 161
 	}
162 162
 
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
 		$addons         = give_get_plugins();
171 171
 		$plugin_updates = get_plugin_updates();
172 172
 
173
-		foreach ( $addons as $key => $info ) {
174
-			if ( 'active' != $info['Status'] || 'add-on' != $info['Type'] || empty( $plugin_updates[ $key ] ) ) {
173
+		foreach ($addons as $key => $info) {
174
+			if ('active' != $info['Status'] || 'add-on' != $info['Type'] || empty($plugin_updates[$key])) {
175 175
 				continue;
176 176
 			}
177 177
 
178
-			$this->updates['plugin'][] = array_merge( $info, (array) $plugin_updates[ $key ] );
178
+			$this->updates['plugin'][] = array_merge($info, (array) $plugin_updates[$key]);
179 179
 		}
180 180
 	}
181 181
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 	 * @access public
188 188
 	 */
189 189
 	public function __register_upgrade() {
190
-		if ( ! is_admin() ) {
190
+		if ( ! is_admin()) {
191 191
 			return;
192 192
 		}
193 193
 
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 		 *
197 197
 		 * @since 1.8.12
198 198
 		 */
199
-		do_action( 'give_register_updates', $this );
199
+		do_action('give_register_updates', $this);
200 200
 	}
201 201
 
202 202
 	/**
@@ -209,23 +209,22 @@  discard block
 block discarded – undo
209 209
 		global $menu;
210 210
 
211 211
 		// Bailout.
212
-		if ( empty( $menu ) || ! $this->get_total_update_count() ) {
212
+		if (empty($menu) || ! $this->get_total_update_count()) {
213 213
 			return;
214 214
 		}
215 215
 
216
-		$is_update = ( $this->is_doing_updates() && ! self::$background_updater->is_paused_process() );
216
+		$is_update = ($this->is_doing_updates() && ! self::$background_updater->is_paused_process());
217 217
 
218
-		foreach ( $menu as $index => $menu_item ) {
219
-			if ( 'edit.php?post_type=give_forms' !== $menu_item[2] ) {
218
+		foreach ($menu as $index => $menu_item) {
219
+			if ('edit.php?post_type=give_forms' !== $menu_item[2]) {
220 220
 				continue;
221 221
 			}
222 222
 
223
-			$menu[ $index ][0] = sprintf(
223
+			$menu[$index][0] = sprintf(
224 224
 				'%1$s <span class="update-plugins"><span class="plugin-count give-update-progress-count">%2$s%3$s</span></span>',
225
-				__( 'Donations', 'give' ),
225
+				__('Donations', 'give'),
226 226
 				$is_update ?
227
-					$this->get_db_update_processing_percentage() :
228
-					$this->get_total_update_count(),
227
+					$this->get_db_update_processing_percentage() : $this->get_total_update_count(),
229 228
 				$is_update ? '%' : ''
230 229
 			);
231 230
 
@@ -244,46 +243,45 @@  discard block
 block discarded – undo
244 243
 		$this->__register_plugin_addon_updates();
245 244
 
246 245
 		// Bailout.
247
-		if ( ! $this->get_total_update_count() ) {
246
+		if ( ! $this->get_total_update_count()) {
248 247
 			return;
249 248
 		}
250 249
 
251 250
 		// Bailout.
252
-		if ( ! $this->get_total_update_count() ) {
251
+		if ( ! $this->get_total_update_count()) {
253 252
 			// Show complete update message if still on update setting page.
254
-			if ( isset( $_GET['page'] ) && 'give-updates' === $_GET['page'] ) {
253
+			if (isset($_GET['page']) && 'give-updates' === $_GET['page']) {
255 254
 				// Upgrades
256 255
 				add_submenu_page(
257 256
 					'edit.php?post_type=give_forms',
258
-					esc_html__( 'Give Updates Complete', 'give' ),
259
-					__( 'Updates', 'give' ),
257
+					esc_html__('Give Updates Complete', 'give'),
258
+					__('Updates', 'give'),
260 259
 					'manage_give_settings',
261 260
 					'give-updates',
262
-					array( $this, 'render_complete_page' )
261
+					array($this, 'render_complete_page')
263 262
 				);
264 263
 			}
265 264
 
266 265
 			return;
267 266
 		}
268 267
 
269
-		$is_update = ( $this->is_doing_updates() && ! self::$background_updater->is_paused_process() );
268
+		$is_update = ($this->is_doing_updates() && ! self::$background_updater->is_paused_process());
270 269
 
271 270
 		// Upgrades
272 271
 		add_submenu_page(
273 272
 			'edit.php?post_type=give_forms',
274
-			esc_html__( 'Give Updates', 'give' ),
273
+			esc_html__('Give Updates', 'give'),
275 274
 			sprintf(
276 275
 				'%1$s <span class="update-plugins"%2$s><span class="plugin-count give-update-progress-count">%3$s%4$s</span></span>',
277
-				__( 'Updates', 'give' ),
278
-				isset( $_GET['give-pause-db-upgrades'] ) ? ' style="display:none;"' : '',
276
+				__('Updates', 'give'),
277
+				isset($_GET['give-pause-db-upgrades']) ? ' style="display:none;"' : '',
279 278
 				$is_update ?
280
-					$this->get_db_update_processing_percentage() :
281
-					$this->get_total_update_count(),
279
+					$this->get_db_update_processing_percentage() : $this->get_total_update_count(),
282 280
 				$is_update ? '%' : ''
283 281
 			),
284 282
 			'manage_give_settings',
285 283
 			'give-updates',
286
-			array( $this, 'render_page' )
284
+			array($this, 'render_page')
287 285
 		);
288 286
 	}
289 287
 
@@ -298,13 +296,13 @@  discard block
 block discarded – undo
298 296
 		// Show db upgrade completed notice.
299 297
 		if (
300 298
 			! wp_doing_ajax() &&
301
-			current_user_can( 'manage_give_settings' ) &&
302
-			get_option( 'give_show_db_upgrade_complete_notice' ) &&
303
-			! isset( $_GET['give-db-update-completed'] )
299
+			current_user_can('manage_give_settings') &&
300
+			get_option('give_show_db_upgrade_complete_notice') &&
301
+			! isset($_GET['give-db-update-completed'])
304 302
 		) {
305
-			delete_option( 'give_show_db_upgrade_complete_notice' );
303
+			delete_option('give_show_db_upgrade_complete_notice');
306 304
 
307
-			wp_redirect( add_query_arg( array( 'give-db-update-completed' => 'give_db_upgrade_completed' ) ) );
305
+			wp_redirect(add_query_arg(array('give-db-update-completed' => 'give_db_upgrade_completed')));
308 306
 			exit();
309 307
 		}
310 308
 	}
@@ -320,15 +318,15 @@  discard block
 block discarded – undo
320 318
 	 *
321 319
 	 * @return bool
322 320
 	 */
323
-	public function __pause_db_update( $force = false ) {
321
+	public function __pause_db_update($force = false) {
324 322
 		// Bailout.
325 323
 		if (
326 324
 			! $force &&
327 325
 			(
328 326
 				wp_doing_ajax() ||
329
-				! isset( $_GET['page'] ) ||
327
+				! isset($_GET['page']) ||
330 328
 				'give-updates' !== $_GET['page'] ||
331
-				! isset( $_GET['give-pause-db-upgrades'] ) ||
329
+				! isset($_GET['give-pause-db-upgrades']) ||
332 330
 				self::$background_updater->is_paused_process()
333 331
 			)
334 332
 
@@ -336,13 +334,13 @@  discard block
 block discarded – undo
336 334
 			return false;
337 335
 		}
338 336
 
339
-		delete_option( 'give_upgrade_error' );
337
+		delete_option('give_upgrade_error');
340 338
 
341
-		$this->__health_background_update( $this );
339
+		$this->__health_background_update($this);
342 340
 		$batch = self::$background_updater->get_all_batch();
343 341
 
344 342
 		// Bailout: if batch is empty
345
-		if ( empty( $batch->data ) ) {
343
+		if (empty($batch->data)) {
346 344
 			return false;
347 345
 		}
348 346
 
@@ -351,25 +349,25 @@  discard block
 block discarded – undo
351 349
 
352 350
 		// Do not stop background process immediately if task running.
353 351
 		// @see Give_Background_Updater::lock_process
354
-		if ( ! $force && self::$background_updater->is_process_running() ) {
355
-			update_option( 'give_pause_upgrade', 1 );
352
+		if ( ! $force && self::$background_updater->is_process_running()) {
353
+			update_option('give_pause_upgrade', 1);
356 354
 
357 355
 			return true;
358 356
 		}
359 357
 
360
-		update_option( 'give_paused_batches', $batch, 'no' );
361
-		delete_option( $batch->key );
362
-		delete_site_transient( self::$background_updater->get_identifier() . '_process_lock' );
363
-		wp_clear_scheduled_hook( self::$background_updater->get_cron_identifier() );
358
+		update_option('give_paused_batches', $batch, 'no');
359
+		delete_option($batch->key);
360
+		delete_site_transient(self::$background_updater->get_identifier().'_process_lock');
361
+		wp_clear_scheduled_hook(self::$background_updater->get_cron_identifier());
364 362
 
365
-		Give()->logs->add( 'Update Pause', print_r( $batch, true ), 0, 'update' );
363
+		Give()->logs->add('Update Pause', print_r($batch, true), 0, 'update');
366 364
 
367 365
 		/**
368 366
 		 * Fire action when pause db updates
369 367
 		 *
370 368
 		 * @since 2.0.1
371 369
 		 */
372
-		do_action( 'give_pause_db_upgrade', $this );
370
+		do_action('give_pause_db_upgrade', $this);
373 371
 
374 372
 		return true;
375 373
 	}
@@ -386,31 +384,31 @@  discard block
 block discarded – undo
386 384
 		// Bailout.
387 385
 		if (
388 386
 			wp_doing_ajax() ||
389
-			! isset( $_GET['page'] ) ||
387
+			! isset($_GET['page']) ||
390 388
 			'give-updates' !== $_GET['page'] ||
391
-			! isset( $_GET['give-restart-db-upgrades'] ) ||
389
+			! isset($_GET['give-restart-db-upgrades']) ||
392 390
 			! self::$background_updater->is_paused_process()
393 391
 		) {
394 392
 			return false;
395 393
 		}
396 394
 
397 395
 		Give_Background_Updater::flush_cache();
398
-		$batch = get_option( 'give_paused_batches' );
396
+		$batch = get_option('give_paused_batches');
399 397
 
400
-		if ( ! empty( $batch ) ) {
401
-			wp_cache_delete( $batch->key, 'options' );
402
-			update_option( $batch->key, $batch->data );
398
+		if ( ! empty($batch)) {
399
+			wp_cache_delete($batch->key, 'options');
400
+			update_option($batch->key, $batch->data);
403 401
 
404
-			delete_option( 'give_paused_batches' );
402
+			delete_option('give_paused_batches');
405 403
 
406
-			Give()->logs->add( 'Update Restart', print_r( $batch, true ), 0, 'update' );
404
+			Give()->logs->add('Update Restart', print_r($batch, true), 0, 'update');
407 405
 
408 406
 
409 407
 			/** Fire action when restart db updates
410 408
 			 *
411 409
 			 * @since 2.0.1
412 410
 			 */
413
-			do_action( 'give_restart_db_upgrade', $this );
411
+			do_action('give_restart_db_upgrade', $this);
414 412
 
415 413
 			self::$background_updater->dispatch();
416 414
 		}
@@ -426,53 +424,53 @@  discard block
 block discarded – undo
426 424
 	 *
427 425
 	 * @param Give_Updates $give_updates
428 426
 	 */
429
-	public function __health_background_update( $give_updates ) {
430
-		if ( ! $this->is_doing_updates() ) {
427
+	public function __health_background_update($give_updates) {
428
+		if ( ! $this->is_doing_updates()) {
431 429
 			return;
432 430
 		}
433 431
 
434 432
 		Give_Background_Updater::flush_cache();
435 433
 
436 434
 		$batch                = Give_Updates::$background_updater->get_all_batch();
437
-		$batch_data_count     = count( $batch->data );
438
-		$all_updates          = $give_updates->get_updates( 'database', 'all' );
439
-		$all_update_ids       = wp_list_pluck( $all_updates, 'id' );
440
-		$all_batch_update_ids = ! empty( $batch->data ) ? wp_list_pluck( $batch->data, 'id' ) : array();
435
+		$batch_data_count     = count($batch->data);
436
+		$all_updates          = $give_updates->get_updates('database', 'all');
437
+		$all_update_ids       = wp_list_pluck($all_updates, 'id');
438
+		$all_batch_update_ids = ! empty($batch->data) ? wp_list_pluck($batch->data, 'id') : array();
441 439
 		$log_data             = '';
442
-		$doing_upgrade_args   = get_option( 'give_doing_upgrade' );
440
+		$doing_upgrade_args   = get_option('give_doing_upgrade');
443 441
 
444
-		if ( ! empty( $doing_upgrade_args ) ) {
445
-			$log_data .= 'Doing update:' . "\n";
446
-			$log_data .= print_r( $doing_upgrade_args, true ) . "\n";
442
+		if ( ! empty($doing_upgrade_args)) {
443
+			$log_data .= 'Doing update:'."\n";
444
+			$log_data .= print_r($doing_upgrade_args, true)."\n";
447 445
 		}
448 446
 
449 447
 		/**
450 448
 		 * Add remove upgrade from batch
451 449
 		 */
452
-		if ( ! empty( $batch->data ) ) {
450
+		if ( ! empty($batch->data)) {
453 451
 
454
-			foreach ( $batch->data as $index => $update ) {
455
-				$log_data = print_r( $update, true ) . "\n";
452
+			foreach ($batch->data as $index => $update) {
453
+				$log_data = print_r($update, true)."\n";
456 454
 
457
-				if ( ! is_callable( $update['callback'] ) ) {
458
-					$log_data .= 'Removing missing callback update: ' . "{$update['id']}\n";
459
-					unset( $batch->data[ $index ] );
460
-				} elseif ( give_has_upgrade_completed( $update['id'] ) ) {
461
-					$log_data .= 'Removing already completed update: ' . "{$update['id']}\n";
462
-					unset( $batch->data[ $index ] );
455
+				if ( ! is_callable($update['callback'])) {
456
+					$log_data .= 'Removing missing callback update: '."{$update['id']}\n";
457
+					unset($batch->data[$index]);
458
+				} elseif (give_has_upgrade_completed($update['id'])) {
459
+					$log_data .= 'Removing already completed update: '."{$update['id']}\n";
460
+					unset($batch->data[$index]);
463 461
 				}
464 462
 
465
-				if ( ! empty( $update['depend'] ) ) {
463
+				if ( ! empty($update['depend'])) {
466 464
 
467
-					foreach ( $update['depend'] as $depend ) {
468
-						if ( give_has_upgrade_completed( $depend ) ) {
469
-							$log_data .= 'Completed update: ' . "{$depend}\n";
465
+					foreach ($update['depend'] as $depend) {
466
+						if (give_has_upgrade_completed($depend)) {
467
+							$log_data .= 'Completed update: '."{$depend}\n";
470 468
 							continue;
471 469
 						}
472 470
 
473
-						if ( in_array( $depend, $all_update_ids ) && ! in_array( $depend, $all_batch_update_ids ) ) {
474
-							$log_data .= 'Adding missing update: ' . "{$depend}\n";
475
-							array_unshift( $batch->data, $all_updates[ array_search( $depend, $all_update_ids ) ] );
471
+						if (in_array($depend, $all_update_ids) && ! in_array($depend, $all_batch_update_ids)) {
472
+							$log_data .= 'Adding missing update: '."{$depend}\n";
473
+							array_unshift($batch->data, $all_updates[array_search($depend, $all_update_ids)]);
476 474
 						}
477 475
 					}
478 476
 				}
@@ -482,52 +480,52 @@  discard block
 block discarded – undo
482 480
 		/**
483 481
 		 * Add new upgrade to batch
484 482
 		 */
485
-		if ( $new_updates = $this->get_updates( 'database', 'new' ) ) {
486
-			$all_batch_update_ids = ! empty( $batch->data ) ? wp_list_pluck( $batch->data, 'id' ) : array();
483
+		if ($new_updates = $this->get_updates('database', 'new')) {
484
+			$all_batch_update_ids = ! empty($batch->data) ? wp_list_pluck($batch->data, 'id') : array();
487 485
 
488
-			foreach ( $new_updates as $index => $new_update ) {
489
-				if ( give_has_upgrade_completed( $new_update['id'] ) || in_array( $new_update['id'], $all_batch_update_ids ) ) {
490
-					unset( $new_updates[ $index ] );
486
+			foreach ($new_updates as $index => $new_update) {
487
+				if (give_has_upgrade_completed($new_update['id']) || in_array($new_update['id'], $all_batch_update_ids)) {
488
+					unset($new_updates[$index]);
491 489
 				}
492 490
 			}
493 491
 
494
-			if ( ! empty( $new_updates ) ) {
495
-				$log_data .= 'Adding new update: ' . "\n";
496
-				$log_data .= print_r( $new_updates, true ) . "\n";
492
+			if ( ! empty($new_updates)) {
493
+				$log_data .= 'Adding new update: '."\n";
494
+				$log_data .= print_r($new_updates, true)."\n";
497 495
 
498
-				$batch->data = array_merge( (array) $batch->data, $new_updates );
499
-				update_option( 'give_db_update_count', ( absint( get_option( 'give_db_update_count' ) ) + count( $new_updates ) ) );
496
+				$batch->data = array_merge((array) $batch->data, $new_updates);
497
+				update_option('give_db_update_count', (absint(get_option('give_db_update_count')) + count($new_updates)));
500 498
 			}
501 499
 		}
502 500
 
503 501
 		/**
504 502
 		 * Fix batch
505 503
 		 */
506
-		if ( empty( $batch->data ) ) {
504
+		if (empty($batch->data)) {
507 505
 			// Complete batch if do not have any data to process.
508
-			self::$background_updater->delete( $batch->key );
506
+			self::$background_updater->delete($batch->key);
509 507
 
510
-			if ( self::$background_updater->has_queue() ) {
511
-				$this->__health_background_update( $this );
508
+			if (self::$background_updater->has_queue()) {
509
+				$this->__health_background_update($this);
512 510
 			} else {
513
-				delete_site_transient( self::$background_updater->get_identifier() . '_process_lock' );
514
-				wp_clear_scheduled_hook( self::$background_updater->get_cron_identifier() );
511
+				delete_site_transient(self::$background_updater->get_identifier().'_process_lock');
512
+				wp_clear_scheduled_hook(self::$background_updater->get_cron_identifier());
515 513
 
516 514
 				self::$background_updater->complete();
517 515
 			}
518 516
 
519
-		} elseif ( $batch_data_count !== count( $batch->data ) ) {
517
+		} elseif ($batch_data_count !== count($batch->data)) {
520 518
 
521
-			$log_data .= 'Updating batch' . "\n";
522
-			$log_data .= print_r( $batch, true );
519
+			$log_data .= 'Updating batch'."\n";
520
+			$log_data .= print_r($batch, true);
523 521
 
524
-			if ( ! empty( $batch->key ) ) {
525
-				wp_cache_delete( $batch->key, 'options' );
526
-				update_option( $batch->key, $batch->data );
522
+			if ( ! empty($batch->key)) {
523
+				wp_cache_delete($batch->key, 'options');
524
+				update_option($batch->key, $batch->data);
527 525
 			} else {
528 526
 
529
-				foreach ( $batch->data as $data ) {
530
-					Give_Updates::$background_updater->push_to_queue( $data );
527
+				foreach ($batch->data as $data) {
528
+					Give_Updates::$background_updater->push_to_queue($data);
531 529
 				}
532 530
 
533 531
 				Give_Updates::$background_updater->save();
@@ -538,31 +536,31 @@  discard block
 block discarded – undo
538 536
 		/**
539 537
 		 * Fix give_doing_upgrade option
540 538
 		 */
541
-		if( $fresh_new_db_count = $this->get_total_new_db_update_count( true ) ) {
542
-			update_option( 'give_db_update_count', $fresh_new_db_count );
539
+		if ($fresh_new_db_count = $this->get_total_new_db_update_count(true)) {
540
+			update_option('give_db_update_count', $fresh_new_db_count);
543 541
 		}
544 542
 
545 543
 		$doing_upgrade_args['update']           = 1;
546
-		$doing_upgrade_args['heading']          = sprintf( 'Update %s of %s', 1, $fresh_new_db_count );
547
-		$doing_upgrade_args['total_percentage'] = $this->get_db_update_processing_percentage( true );
544
+		$doing_upgrade_args['heading']          = sprintf('Update %s of %s', 1, $fresh_new_db_count);
545
+		$doing_upgrade_args['total_percentage'] = $this->get_db_update_processing_percentage(true);
548 546
 
549 547
 		// Remove already completed update from info.
550 548
 		if (
551
-			empty( $doing_upgrade_args['update_info'] )
552
-			|| give_has_upgrade_completed( $doing_upgrade_args['update_info']['id'] )
549
+			empty($doing_upgrade_args['update_info'])
550
+			|| give_has_upgrade_completed($doing_upgrade_args['update_info']['id'])
553 551
 		) {
554
-			$doing_upgrade_args['update_info'] = current( array_values( $batch->data ) );
552
+			$doing_upgrade_args['update_info'] = current(array_values($batch->data));
555 553
 			$doing_upgrade_args['step']        = 1;
556 554
 		}
557 555
 
558 556
 		// Check if dependency completed or not.
559
-		if ( isset( $doing_upgrade_args['update_info']['depend'] ) ) {
560
-			foreach ( $doing_upgrade_args['update_info']['depend'] as $depend ) {
561
-				if ( give_has_upgrade_completed( $depend ) ) {
557
+		if (isset($doing_upgrade_args['update_info']['depend'])) {
558
+			foreach ($doing_upgrade_args['update_info']['depend'] as $depend) {
559
+				if (give_has_upgrade_completed($depend)) {
562 560
 					continue;
563 561
 				}
564 562
 
565
-				$doing_upgrade_args['update_info']      = $all_updates[ array_search( $depend, $all_update_ids ) ];
563
+				$doing_upgrade_args['update_info']      = $all_updates[array_search($depend, $all_update_ids)];
566 564
 				$doing_upgrade_args['step']             = 1;
567 565
 				$doing_upgrade_args['percentage']       = 0;
568 566
 				$doing_upgrade_args['total_percentage'] = 0;
@@ -571,14 +569,14 @@  discard block
 block discarded – undo
571 569
 			}
572 570
 		}
573 571
 
574
-		if( ! empty( $doing_upgrade_args['update_info'] ) ) {
575
-			update_option( 'give_doing_upgrade', $doing_upgrade_args );
572
+		if ( ! empty($doing_upgrade_args['update_info'])) {
573
+			update_option('give_doing_upgrade', $doing_upgrade_args);
576 574
 
577
-			$log_data .= 'Updated doing update:' . "\n";
578
-			$log_data .= print_r( $doing_upgrade_args, true ) . "\n";
575
+			$log_data .= 'Updated doing update:'."\n";
576
+			$log_data .= print_r($doing_upgrade_args, true)."\n";
579 577
 		}
580 578
 
581
-		Give()->logs->add( 'Update Health Check', $log_data, 0, 'update' );
579
+		Give()->logs->add('Update Health Check', $log_data, 0, 'update');
582 580
 	}
583 581
 
584 582
 
@@ -590,61 +588,61 @@  discard block
 block discarded – undo
590 588
 	 */
591 589
 	public function __show_notice() {
592 590
 		// Bailout.
593
-		if ( ! current_user_can( 'manage_give_settings' ) ) {
591
+		if ( ! current_user_can('manage_give_settings')) {
594 592
 			return;
595 593
 		}
596 594
 
597 595
 		// Run DB updates.
598
-		if ( ! empty( $_GET['give-run-db-update'] ) ) {
596
+		if ( ! empty($_GET['give-run-db-update'])) {
599 597
 			$this->run_db_update();
600 598
 		}
601 599
 
602 600
 
603 601
 		// Bailout.
604
-		if ( isset( $_GET['page'] ) && 'give-updates' === $_GET['page'] ) {
602
+		if (isset($_GET['page']) && 'give-updates' === $_GET['page']) {
605 603
 			return;
606 604
 		}
607 605
 
608 606
 		// Show notice if upgrade paused.
609
-		if ( self::$background_updater->is_paused_process() ) {
607
+		if (self::$background_updater->is_paused_process()) {
610 608
 			ob_start();
611 609
 
612
-			$upgrade_error = get_option( 'give_upgrade_error' );
613
-			if ( ! $upgrade_error ) : ?>
614
-				<strong><?php _e( 'Database Update', 'give' ); ?></strong>
615
-				&nbsp;&#8211;&nbsp;<?php _e( 'GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a backup before proceeding.', 'give' ); ?>
610
+			$upgrade_error = get_option('give_upgrade_error');
611
+			if ( ! $upgrade_error) : ?>
612
+				<strong><?php _e('Database Update', 'give'); ?></strong>
613
+				&nbsp;&#8211;&nbsp;<?php _e('GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a backup before proceeding.', 'give'); ?>
616 614
 				<br>
617 615
 				<br>
618
-				<a href="<?php echo esc_url( add_query_arg( array( 'give-restart-db-upgrades' => 1 ), admin_url( 'edit.php?post_type=give_forms&page=give-updates' ) ) ); ?>" class="button button-primary give-restart-updater-btn">
619
-					<?php _e( 'Restart the updater', 'give' ); ?>
616
+				<a href="<?php echo esc_url(add_query_arg(array('give-restart-db-upgrades' => 1), admin_url('edit.php?post_type=give_forms&page=give-updates'))); ?>" class="button button-primary give-restart-updater-btn">
617
+					<?php _e('Restart the updater', 'give'); ?>
620 618
 				</a>
621 619
 			<?php else: ?>
622
-				<strong><?php _e( 'Database Update', 'give' ); ?></strong>
623
-				&nbsp;&#8211;&nbsp;<?php _e( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); ?>
620
+				<strong><?php _e('Database Update', 'give'); ?></strong>
621
+				&nbsp;&#8211;&nbsp;<?php _e('An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give'); ?>
624 622
 			<?php
625 623
 			endif;
626 624
 			$desc_html = ob_get_clean();
627 625
 
628
-			Give()->notices->register_notice( array(
626
+			Give()->notices->register_notice(array(
629 627
 				'id'          => 'give_upgrade_db',
630 628
 				'type'        => 'error',
631 629
 				'dismissible' => false,
632 630
 				'description' => $desc_html,
633
-			) );
631
+			));
634 632
 		}
635 633
 
636 634
 		// Bailout if doing upgrades.
637
-		if ( $this->is_doing_updates() ) {
635
+		if ($this->is_doing_updates()) {
638 636
 			return;
639 637
 		}
640 638
 
641 639
 		// Show notice if ajax is not working.
642
-		if ( ! give_test_ajax_works() ) {
640
+		if ( ! give_test_ajax_works()) {
643 641
 			Give()->notices->register_notice(
644 642
 				array(
645 643
 					'id'          => 'give_db_upgrade_ajax_inaccessible',
646 644
 					'type'        => 'error',
647
-					'description' => sprintf( '%1$s <a href="%2$s" target="_blank">%3$s</a>', __( 'Give needs to upgrade the database but cannot because AJAX does not appear accessible. This could be because your website is password protected, in maintenance mode, or has a specific hosting configuration or plugin active that is preventing access.', 'give' ), 'http://docs.givewp.com/admin-ajax-error', __( 'Read More', 'give' ) . ' &raquo;' ),
645
+					'description' => sprintf('%1$s <a href="%2$s" target="_blank">%3$s</a>', __('Give needs to upgrade the database but cannot because AJAX does not appear accessible. This could be because your website is password protected, in maintenance mode, or has a specific hosting configuration or plugin active that is preventing access.', 'give'), 'http://docs.givewp.com/admin-ajax-error', __('Read More', 'give').' &raquo;'),
648 646
 					'show'        => true,
649 647
 				)
650 648
 			);
@@ -653,40 +651,40 @@  discard block
 block discarded – undo
653 651
 		}
654 652
 
655 653
 		// Show db upgrade completed notice.
656
-		if ( ! empty( $_GET['give-db-update-completed'] ) ) {
657
-			Give()->notices->register_notice( array(
654
+		if ( ! empty($_GET['give-db-update-completed'])) {
655
+			Give()->notices->register_notice(array(
658 656
 				'id'          => 'give_db_upgrade_completed',
659 657
 				'type'        => 'updated',
660
-				'description' => __( 'Give database updates completed successfully. Thank you for updating to the latest version!', 'give' ),
658
+				'description' => __('Give database updates completed successfully. Thank you for updating to the latest version!', 'give'),
661 659
 				'show'        => true,
662
-			) );
660
+			));
663 661
 
664 662
 			// Start update.
665
-		} elseif ( ! empty( $_GET['give-run-db-update'] ) ) {
663
+		} elseif ( ! empty($_GET['give-run-db-update'])) {
666 664
 			$this->run_db_update();
667 665
 
668 666
 			// Show run the update notice.
669
-		} elseif ( $this->get_total_new_db_update_count() ) {
667
+		} elseif ($this->get_total_new_db_update_count()) {
670 668
 			ob_start();
671 669
 			?>
672 670
 			<p>
673
-				<strong><?php _e( 'Database Update', 'give' ); ?></strong>
674
-				&nbsp;&#8211;&nbsp;<?php _e( 'GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a complete backup before proceeding.', 'give' ); ?>
671
+				<strong><?php _e('Database Update', 'give'); ?></strong>
672
+				&nbsp;&#8211;&nbsp;<?php _e('GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a complete backup before proceeding.', 'give'); ?>
675 673
 			</p>
676 674
 			<p class="submit">
677
-				<a href="<?php echo esc_url( add_query_arg( array( 'give-run-db-update' => 1 ), admin_url( 'edit.php?post_type=give_forms&page=give-updates' ) ) ); ?>" class="button button-primary give-run-update-now">
678
-					<?php _e( 'Run the updater', 'give' ); ?>
675
+				<a href="<?php echo esc_url(add_query_arg(array('give-run-db-update' => 1), admin_url('edit.php?post_type=give_forms&page=give-updates'))); ?>" class="button button-primary give-run-update-now">
676
+					<?php _e('Run the updater', 'give'); ?>
679 677
 				</a>
680 678
 			</p>
681 679
 			<?php
682 680
 			$desc_html = ob_get_clean();
683 681
 
684
-			Give()->notices->register_notice( array(
682
+			Give()->notices->register_notice(array(
685 683
 				'id'          => 'give_upgrade_db',
686 684
 				'type'        => 'updated',
687 685
 				'dismissible' => false,
688 686
 				'description' => $desc_html,
689
-			) );
687
+			));
690 688
 		}
691 689
 	}
692 690
 
@@ -697,7 +695,7 @@  discard block
 block discarded – undo
697 695
 	 * @access public
698 696
 	 */
699 697
 	public function render_complete_page() {
700
-		include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades-complete.php';
698
+		include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades-complete.php';
701 699
 	}
702 700
 
703 701
 	/**
@@ -707,7 +705,7 @@  discard block
 block discarded – undo
707 705
 	 * @access public
708 706
 	 */
709 707
 	public function render_page() {
710
-		include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades.php';
708
+		include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades.php';
711 709
 	}
712 710
 
713 711
 	/**
@@ -718,26 +716,26 @@  discard block
 block discarded – undo
718 716
 	 */
719 717
 	private function run_db_update() {
720 718
 		// Bailout.
721
-		if ( $this->is_doing_updates() || ! $this->get_total_new_db_update_count() ) {
719
+		if ($this->is_doing_updates() || ! $this->get_total_new_db_update_count()) {
722 720
 			return;
723 721
 		}
724 722
 
725
-		$updates = $this->get_updates( 'database', 'new' );
723
+		$updates = $this->get_updates('database', 'new');
726 724
 
727
-		foreach ( $updates as $update ) {
728
-			self::$background_updater->push_to_queue( $update );
725
+		foreach ($updates as $update) {
726
+			self::$background_updater->push_to_queue($update);
729 727
 		}
730 728
 
731
-		add_option( 'give_db_update_count', count( $updates ), '', 'no' );
729
+		add_option('give_db_update_count', count($updates), '', 'no');
732 730
 
733
-		add_option( 'give_doing_upgrade', array(
731
+		add_option('give_doing_upgrade', array(
734 732
 			'update_info'      => $updates[0],
735 733
 			'step'             => 1,
736 734
 			'update'           => 1,
737
-			'heading'          => sprintf( 'Update %s of %s', 1, count( $updates ) ),
735
+			'heading'          => sprintf('Update %s of %s', 1, count($updates)),
738 736
 			'percentage'       => 0,
739 737
 			'total_percentage' => 0,
740
-		), '', 'no' );
738
+		), '', 'no');
741 739
 
742 740
 		self::$background_updater->save()->dispatch();
743 741
 	}
@@ -751,14 +749,13 @@  discard block
 block discarded – undo
751 749
 	 */
752 750
 	public function __flush_resume_updates() {
753 751
 		//delete_option( 'give_doing_upgrade' );
754
-		update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
752
+		update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
755 753
 
756 754
 		// Reset counter.
757 755
 		$this->step = $this->percentage = 0;
758 756
 
759
-		$this->update = ( $this->get_total_db_update_count() > $this->update ) ?
760
-			( $this->update + 1 ) :
761
-			$this->update;
757
+		$this->update = ($this->get_total_db_update_count() > $this->update) ?
758
+			($this->update + 1) : $this->update;
762 759
 	}
763 760
 
764 761
 
@@ -773,7 +770,7 @@  discard block
 block discarded – undo
773 770
 	public function __give_start_updating() {
774 771
 		// Check permission.
775 772
 		if (
776
-			! current_user_can( 'manage_give_settings' ) ||
773
+			! current_user_can('manage_give_settings') ||
777 774
 			$this->is_doing_updates()
778 775
 		) {
779 776
 			wp_send_json_error();
@@ -781,7 +778,7 @@  discard block
 block discarded – undo
781 778
 
782 779
 		// @todo: validate nonce
783 780
 		// @todo: set http method to post
784
-		if ( empty( $_POST['run_db_update'] ) ) {
781
+		if (empty($_POST['run_db_update'])) {
785 782
 			wp_send_json_error();
786 783
 		}
787 784
 
@@ -800,34 +797,34 @@  discard block
 block discarded – undo
800 797
 	 * @return string
801 798
 	 */
802 799
 	public function __give_db_updates_info() {
803
-		$update_info   = get_option( 'give_doing_upgrade' );
800
+		$update_info   = get_option('give_doing_upgrade');
804 801
 		$response_type = '';
805 802
 
806
-		if ( self::$background_updater->is_paused_process() ) {
803
+		if (self::$background_updater->is_paused_process()) {
807 804
 			$update_info = array(
808
-				'message'    => __( 'The updates have been paused.', 'give' ),
805
+				'message'    => __('The updates have been paused.', 'give'),
809 806
 				'heading'    => '',
810 807
 				'percentage' => 0,
811 808
 			);
812 809
 
813
-			if ( get_option( 'give_upgrade_error' ) ) {
814
-				$update_info['message'] = __( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' );
810
+			if (get_option('give_upgrade_error')) {
811
+				$update_info['message'] = __('An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give');
815 812
 			}
816 813
 
817 814
 			$response_type = 'error';
818 815
 
819
-		} elseif ( empty( $update_info ) || ! $this->get_total_new_db_update_count( true ) ) {
816
+		} elseif (empty($update_info) || ! $this->get_total_new_db_update_count(true)) {
820 817
 			$update_info   = array(
821
-				'message'    => __( 'Give database updates completed successfully. Thank you for updating to the latest version!', 'give' ),
822
-				'heading'    => __( 'Updates Completed.', 'give' ),
818
+				'message'    => __('Give database updates completed successfully. Thank you for updating to the latest version!', 'give'),
819
+				'heading'    => __('Updates Completed.', 'give'),
823 820
 				'percentage' => 0,
824 821
 			);
825 822
 			$response_type = 'success';
826 823
 
827
-			delete_option( 'give_show_db_upgrade_complete_notice' );
824
+			delete_option('give_show_db_upgrade_complete_notice');
828 825
 		}
829 826
 
830
-		$this->send_ajax_response( $update_info, $response_type );
827
+		$this->send_ajax_response($update_info, $response_type);
831 828
 	}
832 829
 
833 830
 	/**
@@ -839,7 +836,7 @@  discard block
 block discarded – undo
839 836
 	 * @param        $data
840 837
 	 * @param string $type
841 838
 	 */
842
-	public function send_ajax_response( $data, $type = '' ) {
839
+	public function send_ajax_response($data, $type = '') {
843 840
 		$default = array(
844 841
 			'message'    => '',
845 842
 			'heading'    => '',
@@ -849,24 +846,24 @@  discard block
 block discarded – undo
849 846
 		);
850 847
 
851 848
 		// Set data.
852
-		$data = wp_parse_args( $data, $default );
849
+		$data = wp_parse_args($data, $default);
853 850
 
854 851
 		// Enable cache.
855 852
 		Give_Cache::enable();
856 853
 
857
-		switch ( $type ) {
854
+		switch ($type) {
858 855
 			case 'success':
859
-				wp_send_json_success( $data );
856
+				wp_send_json_success($data);
860 857
 				break;
861 858
 
862 859
 			case 'error':
863
-				wp_send_json_error( $data );
860
+				wp_send_json_error($data);
864 861
 				break;
865 862
 
866 863
 			default:
867
-				wp_send_json( array(
864
+				wp_send_json(array(
868 865
 					'data' => $data,
869
-				) );
866
+				));
870 867
 				break;
871 868
 		}
872 869
 	}
@@ -880,12 +877,12 @@  discard block
 block discarded – undo
880 877
 	 * @param $total
881 878
 	 * @param $current_total
882 879
 	 */
883
-	public function set_percentage( $total, $current_total ) {
880
+	public function set_percentage($total, $current_total) {
884 881
 		// Set percentage.
885
-		$this->percentage = $total ? ( ( $current_total ) / $total ) * 100 : 0;
882
+		$this->percentage = $total ? (($current_total) / $total) * 100 : 0;
886 883
 
887 884
 		// Verify percentage.
888
-		$this->percentage = ( 100 < $this->percentage ) ? 100 : $this->percentage;
885
+		$this->percentage = (100 < $this->percentage) ? 100 : $this->percentage;
889 886
 	}
890 887
 
891 888
 	/**
@@ -898,22 +895,22 @@  discard block
 block discarded – undo
898 895
 	 *
899 896
 	 * @return bool|null
900 897
 	 */
901
-	public function is_parent_updates_completed( $update ) {
898
+	public function is_parent_updates_completed($update) {
902 899
 		// Bailout.
903
-		if ( empty( $update['depend'] ) ) {
900
+		if (empty($update['depend'])) {
904 901
 			return true;
905 902
 		}
906 903
 
907 904
 		// Check if dependency is valid or not.
908
-		if ( ! $this->has_valid_dependency( $update ) ) {
905
+		if ( ! $this->has_valid_dependency($update)) {
909 906
 			return null;
910 907
 		}
911 908
 
912 909
 		$is_dependency_completed = true;
913 910
 
914
-		foreach ( $update['depend'] as $depend ) {
911
+		foreach ($update['depend'] as $depend) {
915 912
 
916
-			if ( ! give_has_upgrade_completed( $depend ) ) {
913
+			if ( ! give_has_upgrade_completed($depend)) {
917 914
 				$is_dependency_completed = false;
918 915
 				break;
919 916
 			}
@@ -930,7 +927,7 @@  discard block
 block discarded – undo
930 927
 	 * @return bool
931 928
 	 */
932 929
 	public function is_doing_updates() {
933
-		return (bool) get_option( 'give_doing_upgrade' );
930
+		return (bool) get_option('give_doing_upgrade');
934 931
 	}
935 932
 
936 933
 
@@ -944,7 +941,7 @@  discard block
 block discarded – undo
944 941
 	 *
945 942
 	 * @return bool
946 943
 	 */
947
-	public function has_valid_dependency( $update ) {
944
+	public function has_valid_dependency($update) {
948 945
 		$is_valid_dependency = true;
949 946
 		// $update_ids          = wp_list_pluck( $this->get_updates( 'database', 'all' ), 'id' );
950 947
 		//
@@ -970,33 +967,33 @@  discard block
 block discarded – undo
970 967
 	 *
971 968
 	 * @return array
972 969
 	 */
973
-	public function get_updates( $update_type = '', $status = 'all' ) {
970
+	public function get_updates($update_type = '', $status = 'all') {
974 971
 		// return all updates.
975
-		if ( empty( $update_type ) ) {
972
+		if (empty($update_type)) {
976 973
 			return $this->updates;
977 974
 		}
978 975
 
979 976
 		// Get specific update.
980
-		$updates = ! empty( $this->updates[ $update_type ] ) ? $this->updates[ $update_type ] : array();
977
+		$updates = ! empty($this->updates[$update_type]) ? $this->updates[$update_type] : array();
981 978
 
982 979
 		// Bailout.
983
-		if ( empty( $updates ) ) {
980
+		if (empty($updates)) {
984 981
 			return $updates;
985 982
 		}
986 983
 
987
-		switch ( $status ) {
984
+		switch ($status) {
988 985
 			case 'new':
989 986
 				// Remove already completed updates.
990
-				wp_cache_delete( 'give_completed_upgrades', 'options' );
987
+				wp_cache_delete('give_completed_upgrades', 'options');
991 988
 				$completed_updates = give_get_completed_upgrades();
992 989
 
993
-				if ( ! empty( $completed_updates ) ) {
994
-					foreach ( $updates as $index => $update ) {
995
-						if ( in_array( $update['id'], $completed_updates ) ) {
996
-							unset( $updates[ $index ] );
990
+				if ( ! empty($completed_updates)) {
991
+					foreach ($updates as $index => $update) {
992
+						if (in_array($update['id'], $completed_updates)) {
993
+							unset($updates[$index]);
997 994
 						}
998 995
 					}
999
-					$updates = array_values( $updates );
996
+					$updates = array_values($updates);
1000 997
 				}
1001 998
 
1002 999
 				break;
@@ -1013,7 +1010,7 @@  discard block
 block discarded – undo
1013 1010
 	 * @return int
1014 1011
 	 */
1015 1012
 	public function get_total_plugin_update_count() {
1016
-		return count( $this->get_updates( 'plugin' ) );
1013
+		return count($this->get_updates('plugin'));
1017 1014
 	}
1018 1015
 
1019 1016
 	/**
@@ -1028,7 +1025,7 @@  discard block
 block discarded – undo
1028 1025
 		$db_update_count     = $this->get_pending_db_update_count();
1029 1026
 		$plugin_update_count = $this->get_total_plugin_update_count();
1030 1027
 
1031
-		return ( $db_update_count + $plugin_update_count );
1028
+		return ($db_update_count + $plugin_update_count);
1032 1029
 	}
1033 1030
 
1034 1031
 	/**
@@ -1040,7 +1037,7 @@  discard block
 block discarded – undo
1040 1037
 	 * @return int
1041 1038
 	 */
1042 1039
 	public function get_pending_db_update_count() {
1043
-		return count( $this->get_updates( 'database', 'new' ) );
1040
+		return count($this->get_updates('database', 'new'));
1044 1041
 	}
1045 1042
 
1046 1043
 	/**
@@ -1052,7 +1049,7 @@  discard block
 block discarded – undo
1052 1049
 	 * @return int
1053 1050
 	 */
1054 1051
 	public function get_total_db_update_count() {
1055
-		return count( $this->get_updates( 'database', 'all' ) );
1052
+		return count($this->get_updates('database', 'all'));
1056 1053
 	}
1057 1054
 
1058 1055
 	/**
@@ -1065,10 +1062,9 @@  discard block
 block discarded – undo
1065 1062
 	 *
1066 1063
 	 * @return int
1067 1064
 	 */
1068
-	public function get_total_new_db_update_count( $refresh = false ) {
1065
+	public function get_total_new_db_update_count($refresh = false) {
1069 1066
 		$update_count = $this->is_doing_updates() && ! $refresh ?
1070
-			get_option( 'give_db_update_count' ) :
1071
-			$this->get_pending_db_update_count();
1067
+			get_option('give_db_update_count') : $this->get_pending_db_update_count();
1072 1068
 
1073 1069
 		return $update_count;
1074 1070
 	}
@@ -1083,11 +1079,11 @@  discard block
 block discarded – undo
1083 1079
 	 *
1084 1080
 	 * @return int
1085 1081
 	 */
1086
-	public function get_running_db_update( $refresh = false ) {
1082
+	public function get_running_db_update($refresh = false) {
1087 1083
 		$current_update = 1;
1088 1084
 
1089
-		if ( $this->is_doing_updates() && ! $refresh ) {
1090
-			$current_update = get_option( 'give_doing_upgrade' );
1085
+		if ($this->is_doing_updates() && ! $refresh) {
1086
+			$current_update = get_option('give_doing_upgrade');
1091 1087
 			$current_update = $current_update['update'];
1092 1088
 		}
1093 1089
 
@@ -1104,25 +1100,23 @@  discard block
 block discarded – undo
1104 1100
 	 *
1105 1101
 	 * @return float|int
1106 1102
 	 */
1107
-	public function get_db_update_processing_percentage( $refresh = false ) {
1103
+	public function get_db_update_processing_percentage($refresh = false) {
1108 1104
 		// Bailout.
1109
-		if ( ! $this->get_total_new_db_update_count( $refresh ) ) {
1105
+		if ( ! $this->get_total_new_db_update_count($refresh)) {
1110 1106
 			return 0;
1111 1107
 		}
1112 1108
 
1113
-		$resume_update            = get_option( 'give_doing_upgrade' );
1114
-		$update_count_percentages = ( ( $this->get_running_db_update( $refresh ) - 1 ) / $this->get_total_new_db_update_count( $refresh ) ) * 100;
1115
-		$update_percentage_share  = ( 1 / $this->get_total_new_db_update_count() ) * 100;
1116
-		$upgrade_percentage       = ( ( $resume_update['percentage'] * $update_percentage_share ) / 100 );
1109
+		$resume_update            = get_option('give_doing_upgrade');
1110
+		$update_count_percentages = (($this->get_running_db_update($refresh) - 1) / $this->get_total_new_db_update_count($refresh)) * 100;
1111
+		$update_percentage_share  = (1 / $this->get_total_new_db_update_count()) * 100;
1112
+		$upgrade_percentage       = (($resume_update['percentage'] * $update_percentage_share) / 100);
1117 1113
 
1118 1114
 		$final_percentage = $update_count_percentages + $upgrade_percentage;
1119 1115
 
1120 1116
 		return $this->is_doing_updates() ?
1121
-			( absint( $final_percentage ) ?
1122
-				absint( $final_percentage ) :
1123
-				round( $final_percentage, 2 )
1124
-			) :
1125
-			0;
1117
+			(absint($final_percentage) ?
1118
+				absint($final_percentage) : round($final_percentage, 2)
1119
+			) : 0;
1126 1120
 	}
1127 1121
 
1128 1122
 
@@ -1134,8 +1128,8 @@  discard block
 block discarded – undo
1134 1128
 	 * @return array
1135 1129
 	 */
1136 1130
 	public function get_update_ids() {
1137
-		$all_updates    = $this->get_updates( 'database', 'all' );
1138
-		$all_update_ids = wp_list_pluck( $all_updates, 'id' );
1131
+		$all_updates    = $this->get_updates('database', 'all');
1132
+		$all_update_ids = wp_list_pluck($all_updates, 'id');
1139 1133
 
1140 1134
 		return $all_update_ids;
1141 1135
 	}
@@ -1150,10 +1144,9 @@  discard block
 block discarded – undo
1150 1144
 	 *
1151 1145
 	 * @return float|int
1152 1146
 	 */
1153
-	public function get_offset( $process_item_count ) {
1154
-		return ( 1 === $this->step ) ?
1155
-			0 :
1156
-			( $this->step - 1 ) * $process_item_count;
1147
+	public function get_offset($process_item_count) {
1148
+		return (1 === $this->step) ?
1149
+			0 : ($this->step - 1) * $process_item_count;
1157 1150
 	}
1158 1151
 }
1159 1152
 
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -618,8 +618,11 @@
 block discarded – undo
618 618
 				<a href="<?php echo esc_url( add_query_arg( array( 'give-restart-db-upgrades' => 1 ), admin_url( 'edit.php?post_type=give_forms&page=give-updates' ) ) ); ?>" class="button button-primary give-restart-updater-btn">
619 619
 					<?php _e( 'Restart the updater', 'give' ); ?>
620 620
 				</a>
621
-			<?php else: ?>
622
-				<strong><?php _e( 'Database Update', 'give' ); ?></strong>
621
+			<?php else {
622
+	: ?>
623
+				<strong><?php _e( 'Database Update', 'give' );
624
+}
625
+?></strong>
623 626
 				&nbsp;&#8211;&nbsp;<?php _e( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); ?>
624 627
 			<?php
625 628
 			endif;
Please login to merge, or discard this patch.
includes/admin/upgrades/upgrade-functions.php 1 patch
Spacing   +480 added lines, -480 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  */
14 14
 
15 15
 // Exit if accessed directly.
16
-if ( ! defined( 'ABSPATH' ) ) {
16
+if ( ! defined('ABSPATH')) {
17 17
 	exit;
18 18
 }
19 19
 
@@ -25,70 +25,70 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function give_do_automatic_upgrades() {
27 27
 	$did_upgrade  = false;
28
-	$give_version = preg_replace( '/[^0-9.].*/', '', get_option( 'give_version' ) );
28
+	$give_version = preg_replace('/[^0-9.].*/', '', get_option('give_version'));
29 29
 
30
-	if ( ! $give_version ) {
30
+	if ( ! $give_version) {
31 31
 		// 1.0 is the first version to use this option so we must add it.
32 32
 		$give_version = '1.0';
33 33
 	}
34 34
 
35
-	switch ( true ) {
35
+	switch (true) {
36 36
 
37
-		case version_compare( $give_version, '1.6', '<' ) :
37
+		case version_compare($give_version, '1.6', '<') :
38 38
 			give_v16_upgrades();
39 39
 			$did_upgrade = true;
40 40
 
41
-		case version_compare( $give_version, '1.7', '<' ) :
41
+		case version_compare($give_version, '1.7', '<') :
42 42
 			give_v17_upgrades();
43 43
 			$did_upgrade = true;
44 44
 
45
-		case version_compare( $give_version, '1.8', '<' ) :
45
+		case version_compare($give_version, '1.8', '<') :
46 46
 			give_v18_upgrades();
47 47
 			$did_upgrade = true;
48 48
 
49
-		case version_compare( $give_version, '1.8.7', '<' ) :
49
+		case version_compare($give_version, '1.8.7', '<') :
50 50
 			give_v187_upgrades();
51 51
 			$did_upgrade = true;
52 52
 
53
-		case version_compare( $give_version, '1.8.8', '<' ) :
53
+		case version_compare($give_version, '1.8.8', '<') :
54 54
 			give_v188_upgrades();
55 55
 			$did_upgrade = true;
56 56
 
57
-		case version_compare( $give_version, '1.8.9', '<' ) :
57
+		case version_compare($give_version, '1.8.9', '<') :
58 58
 			give_v189_upgrades();
59 59
 			$did_upgrade = true;
60 60
 
61
-		case version_compare( $give_version, '1.8.12', '<' ) :
61
+		case version_compare($give_version, '1.8.12', '<') :
62 62
 			give_v1812_upgrades();
63 63
 			$did_upgrade = true;
64 64
 
65
-		case version_compare( $give_version, '1.8.13', '<' ) :
65
+		case version_compare($give_version, '1.8.13', '<') :
66 66
 			give_v1813_upgrades();
67 67
 			$did_upgrade = true;
68 68
 
69
-		case version_compare( $give_version, '1.8.17', '<' ) :
69
+		case version_compare($give_version, '1.8.17', '<') :
70 70
 			give_v1817_upgrades();
71 71
 			$did_upgrade = true;
72 72
 
73
-		case version_compare( $give_version, '1.8.18', '<' ) :
73
+		case version_compare($give_version, '1.8.18', '<') :
74 74
 			give_v1818_upgrades();
75 75
 			$did_upgrade = true;
76 76
 
77
-		case version_compare( $give_version, '2.0', '<' ) :
77
+		case version_compare($give_version, '2.0', '<') :
78 78
 			give_v20_upgrades();
79 79
 			$did_upgrade = true;
80 80
 
81
-		case version_compare( $give_version, '2.0.1', '<' ) :
81
+		case version_compare($give_version, '2.0.1', '<') :
82 82
 			// Do nothing on fresh install.
83
-			if ( ! doing_action( 'give_upgrades' ) ) {
83
+			if ( ! doing_action('give_upgrades')) {
84 84
 				give_v201_create_tables();
85
-				Give_Updates::get_instance()->__health_background_update( Give_Updates::get_instance() );
85
+				Give_Updates::get_instance()->__health_background_update(Give_Updates::get_instance());
86 86
 				Give_Updates::$background_updater->dispatch();
87 87
 			}
88 88
 
89 89
 			$did_upgrade = true;
90 90
 
91
-		case version_compare( $give_version, '2.0.2', '<' ) :
91
+		case version_compare($give_version, '2.0.2', '<') :
92 92
 			// Remove 2.0.1 update to rerun on 2.0.2
93 93
 			$completed_upgrades = give_get_completed_upgrades();
94 94
 			$v201_updates       = array(
@@ -98,35 +98,35 @@  discard block
 block discarded – undo
98 98
 				'v201_logs_upgrades',
99 99
 			);
100 100
 
101
-			foreach ( $v201_updates as $v201_update ) {
102
-				if ( in_array( $v201_update, $completed_upgrades ) ) {
103
-					unset( $completed_upgrades[ array_search( $v201_update, $completed_upgrades ) ] );
101
+			foreach ($v201_updates as $v201_update) {
102
+				if (in_array($v201_update, $completed_upgrades)) {
103
+					unset($completed_upgrades[array_search($v201_update, $completed_upgrades)]);
104 104
 				}
105 105
 			}
106 106
 
107
-			update_option( 'give_completed_upgrades', $completed_upgrades );
107
+			update_option('give_completed_upgrades', $completed_upgrades);
108 108
 
109 109
 			// Do nothing on fresh install.
110
-			if ( ! doing_action( 'give_upgrades' ) ) {
110
+			if ( ! doing_action('give_upgrades')) {
111 111
 				give_v201_create_tables();
112
-				Give_Updates::get_instance()->__health_background_update( Give_Updates::get_instance() );
112
+				Give_Updates::get_instance()->__health_background_update(Give_Updates::get_instance());
113 113
 				Give_Updates::$background_updater->dispatch();
114 114
 			}
115 115
 
116 116
 			$did_upgrade = true;
117 117
 
118
-		case version_compare( $give_version, '2.0.3', '<' ) :
118
+		case version_compare($give_version, '2.0.3', '<') :
119 119
 			give_v203_upgrades();
120 120
 			$did_upgrade = true;
121 121
 	}
122 122
 
123
-	if ( $did_upgrade ) {
124
-		update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
123
+	if ($did_upgrade) {
124
+		update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
125 125
 	}
126 126
 }
127 127
 
128
-add_action( 'admin_init', 'give_do_automatic_upgrades' );
129
-add_action( 'give_upgrades', 'give_do_automatic_upgrades' );
128
+add_action('admin_init', 'give_do_automatic_upgrades');
129
+add_action('give_upgrades', 'give_do_automatic_upgrades');
130 130
 
131 131
 /**
132 132
  * Display Upgrade Notices.
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
  *
141 141
  * @return void
142 142
  */
143
-function give_show_upgrade_notices( $give_updates ) {
143
+function give_show_upgrade_notices($give_updates) {
144 144
 	// v1.3.2 Upgrades
145 145
 	$give_updates->register(
146 146
 		array(
@@ -206,32 +206,32 @@  discard block
 block discarded – undo
206 206
 	);
207 207
 
208 208
 	// v1.8.17 Upgrades for donations.
209
-	$give_updates->register( array(
209
+	$give_updates->register(array(
210 210
 		'id'       => 'v1817_update_donation_iranian_currency_code',
211 211
 		'version'  => '1.8.17',
212 212
 		'callback' => 'give_v1817_update_donation_iranian_currency_code',
213
-	) );
213
+	));
214 214
 
215 215
 	// v1.8.17 Upgrades for cleanup of user roles.
216
-	$give_updates->register( array(
216
+	$give_updates->register(array(
217 217
 		'id'       => 'v1817_cleanup_user_roles',
218 218
 		'version'  => '1.8.17',
219 219
 		'callback' => 'give_v1817_cleanup_user_roles',
220
-	) );
220
+	));
221 221
 
222 222
 	// v1.8.18 Upgrades for assigning custom amount to existing set donations.
223
-	$give_updates->register( array(
223
+	$give_updates->register(array(
224 224
 		'id'       => 'v1818_assign_custom_amount_set_donation',
225 225
 		'version'  => '1.8.18',
226 226
 		'callback' => 'give_v1818_assign_custom_amount_set_donation',
227
-	) );
227
+	));
228 228
 
229 229
 	// v1.8.18 Cleanup the Give Worker Role Caps.
230
-	$give_updates->register( array(
230
+	$give_updates->register(array(
231 231
 		'id'       => 'v1818_give_worker_role_cleanup',
232 232
 		'version'  => '1.8.18',
233 233
 		'callback' => 'give_v1818_give_worker_role_cleanup',
234
-	) );
234
+	));
235 235
 
236 236
 	// v2.0.0 Upgrades
237 237
 	$give_updates->register(
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 			'id'       => 'v20_move_metadata_into_new_table',
286 286
 			'version'  => '2.0.0',
287 287
 			'callback' => 'give_v20_move_metadata_into_new_table_callback',
288
-			'depend'   => array( 'v20_upgrades_payment_metadata', 'v20_upgrades_form_metadata' ),
288
+			'depend'   => array('v20_upgrades_payment_metadata', 'v20_upgrades_form_metadata'),
289 289
 		)
290 290
 	);
291 291
 
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 			'id'       => 'v201_move_metadata_into_new_table',
332 332
 			'version'  => '2.0.1',
333 333
 			'callback' => 'give_v201_move_metadata_into_new_table_callback',
334
-			'depend'   => array( 'v201_upgrades_payment_metadata', 'v201_add_missing_donors' ),
334
+			'depend'   => array('v201_upgrades_payment_metadata', 'v201_add_missing_donors'),
335 335
 		)
336 336
 	);
337 337
 
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 
356 356
 }
357 357
 
358
-add_action( 'give_register_updates', 'give_show_upgrade_notices' );
358
+add_action('give_register_updates', 'give_show_upgrade_notices');
359 359
 
360 360
 /**
361 361
  * Triggers all upgrade functions
@@ -367,29 +367,29 @@  discard block
 block discarded – undo
367 367
  */
368 368
 function give_trigger_upgrades() {
369 369
 
370
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
371
-		wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array(
370
+	if ( ! current_user_can('manage_give_settings')) {
371
+		wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array(
372 372
 			'response' => 403,
373
-		) );
373
+		));
374 374
 	}
375 375
 
376
-	$give_version = get_option( 'give_version' );
376
+	$give_version = get_option('give_version');
377 377
 
378
-	if ( ! $give_version ) {
378
+	if ( ! $give_version) {
379 379
 		// 1.0 is the first version to use this option so we must add it.
380 380
 		$give_version = '1.0';
381
-		add_option( 'give_version', $give_version );
381
+		add_option('give_version', $give_version);
382 382
 	}
383 383
 
384
-	update_option( 'give_version', GIVE_VERSION );
385
-	delete_option( 'give_doing_upgrade' );
384
+	update_option('give_version', GIVE_VERSION);
385
+	delete_option('give_doing_upgrade');
386 386
 
387
-	if ( DOING_AJAX ) {
388
-		die( 'complete' );
387
+	if (DOING_AJAX) {
388
+		die('complete');
389 389
 	} // End if().
390 390
 }
391 391
 
392
-add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' );
392
+add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades');
393 393
 
394 394
 
395 395
 /**
@@ -407,10 +407,10 @@  discard block
 block discarded – undo
407 407
 
408 408
 	// UPDATE DB METAKEYS.
409 409
 	$sql   = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'";
410
-	$query = $wpdb->query( $sql );
410
+	$query = $wpdb->query($sql);
411 411
 
412 412
 	$give_updates->percentage = 100;
413
-	give_set_upgrade_complete( 'upgrade_give_payment_customer_id' );
413
+	give_set_upgrade_complete('upgrade_give_payment_customer_id');
414 414
 }
415 415
 
416 416
 
@@ -434,24 +434,24 @@  discard block
 block discarded – undo
434 434
 	$where  .= "AND ( p.post_status = 'abandoned' )";
435 435
 	$where  .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )";
436 436
 
437
-	$sql            = $select . $join . $where;
438
-	$found_payments = $wpdb->get_col( $sql );
437
+	$sql            = $select.$join.$where;
438
+	$found_payments = $wpdb->get_col($sql);
439 439
 
440
-	foreach ( $found_payments as $payment ) {
440
+	foreach ($found_payments as $payment) {
441 441
 
442 442
 		// Only change ones marked abandoned since our release last week because the admin may have marked some abandoned themselves.
443
-		$modified_time = get_post_modified_time( 'U', false, $payment );
443
+		$modified_time = get_post_modified_time('U', false, $payment);
444 444
 
445 445
 		// 1450124863 =  12/10/2015 20:42:25.
446
-		if ( $modified_time >= 1450124863 ) {
446
+		if ($modified_time >= 1450124863) {
447 447
 
448
-			give_update_payment_status( $payment, 'pending' );
448
+			give_update_payment_status($payment, 'pending');
449 449
 
450 450
 		}
451 451
 	}
452 452
 
453 453
 	$give_updates->percentage = 100;
454
-	give_set_upgrade_complete( 'upgrade_give_offline_status' );
454
+	give_set_upgrade_complete('upgrade_give_offline_status');
455 455
 }
456 456
 
457 457
 
@@ -464,17 +464,17 @@  discard block
 block discarded – undo
464 464
  */
465 465
 function give_v152_cleanup_users() {
466 466
 
467
-	$give_version = get_option( 'give_version' );
467
+	$give_version = get_option('give_version');
468 468
 
469
-	if ( ! $give_version ) {
469
+	if ( ! $give_version) {
470 470
 		// 1.0 is the first version to use this option so we must add it.
471 471
 		$give_version = '1.0';
472 472
 	}
473 473
 
474
-	$give_version = preg_replace( '/[^0-9.].*/', '', $give_version );
474
+	$give_version = preg_replace('/[^0-9.].*/', '', $give_version);
475 475
 
476 476
 	// v1.5.2 Upgrades
477
-	if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) {
477
+	if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) {
478 478
 
479 479
 		// Delete all caps with "ss".
480 480
 		// Also delete all unused "campaign" roles.
@@ -521,9 +521,9 @@  discard block
 block discarded – undo
521 521
 		);
522 522
 
523 523
 		global $wp_roles;
524
-		foreach ( $delete_caps as $cap ) {
525
-			foreach ( array_keys( $wp_roles->roles ) as $role ) {
526
-				$wp_roles->remove_cap( $role, $cap );
524
+		foreach ($delete_caps as $cap) {
525
+			foreach (array_keys($wp_roles->roles) as $role) {
526
+				$wp_roles->remove_cap($role, $cap);
527 527
 			}
528 528
 		}
529 529
 
@@ -533,15 +533,15 @@  discard block
 block discarded – undo
533 533
 		$roles->add_caps();
534 534
 
535 535
 		// The Update Ran.
536
-		update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
537
-		give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' );
538
-		delete_option( 'give_doing_upgrade' );
536
+		update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
537
+		give_set_upgrade_complete('upgrade_give_user_caps_cleanup');
538
+		delete_option('give_doing_upgrade');
539 539
 
540 540
 	}// End if().
541 541
 
542 542
 }
543 543
 
544
-add_action( 'admin_init', 'give_v152_cleanup_users' );
544
+add_action('admin_init', 'give_v152_cleanup_users');
545 545
 
546 546
 /**
547 547
  * 1.6 Upgrade routine to create the customer meta table.
@@ -584,53 +584,53 @@  discard block
 block discarded – undo
584 584
 
585 585
 	// Get addons license key.
586 586
 	$addons = array();
587
-	foreach ( $give_options as $key => $value ) {
588
-		if ( false !== strpos( $key, '_license_key' ) ) {
589
-			$addons[ $key ] = $value;
587
+	foreach ($give_options as $key => $value) {
588
+		if (false !== strpos($key, '_license_key')) {
589
+			$addons[$key] = $value;
590 590
 		}
591 591
 	}
592 592
 
593 593
 	// Bailout: We do not have any addon license data to upgrade.
594
-	if ( empty( $addons ) ) {
594
+	if (empty($addons)) {
595 595
 		return false;
596 596
 	}
597 597
 
598
-	foreach ( $addons as $key => $addon_license ) {
598
+	foreach ($addons as $key => $addon_license) {
599 599
 
600 600
 		// Get addon shortname.
601
-		$shortname = str_replace( '_license_key', '', $key );
601
+		$shortname = str_replace('_license_key', '', $key);
602 602
 
603 603
 		// Addon license option name.
604
-		$addon_license_option_name = $shortname . '_license_active';
604
+		$addon_license_option_name = $shortname.'_license_active';
605 605
 
606 606
 		// bailout if license is empty.
607
-		if ( empty( $addon_license ) ) {
608
-			delete_option( $addon_license_option_name );
607
+		if (empty($addon_license)) {
608
+			delete_option($addon_license_option_name);
609 609
 			continue;
610 610
 		}
611 611
 
612 612
 		// Get addon name.
613 613
 		$addon_name       = array();
614
-		$addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) );
615
-		foreach ( $addon_name_parts as $name_part ) {
614
+		$addon_name_parts = explode('_', str_replace('give_', '', $shortname));
615
+		foreach ($addon_name_parts as $name_part) {
616 616
 
617 617
 			// Fix addon name
618
-			switch ( $name_part ) {
618
+			switch ($name_part) {
619 619
 				case 'authorizenet' :
620 620
 					$name_part = 'authorize.net';
621 621
 					break;
622 622
 			}
623 623
 
624
-			$addon_name[] = ucfirst( $name_part );
624
+			$addon_name[] = ucfirst($name_part);
625 625
 		}
626 626
 
627
-		$addon_name = implode( ' ', $addon_name );
627
+		$addon_name = implode(' ', $addon_name);
628 628
 
629 629
 		// Data to send to the API.
630 630
 		$api_params = array(
631 631
 			'edd_action' => 'activate_license', // never change from "edd_" to "give_"!
632 632
 			'license'    => $addon_license,
633
-			'item_name'  => urlencode( $addon_name ),
633
+			'item_name'  => urlencode($addon_name),
634 634
 			'url'        => home_url(),
635 635
 		);
636 636
 
@@ -645,17 +645,17 @@  discard block
 block discarded – undo
645 645
 		);
646 646
 
647 647
 		// Make sure there are no errors.
648
-		if ( is_wp_error( $response ) ) {
649
-			delete_option( $addon_license_option_name );
648
+		if (is_wp_error($response)) {
649
+			delete_option($addon_license_option_name);
650 650
 			continue;
651 651
 		}
652 652
 
653 653
 		// Tell WordPress to look for updates.
654
-		set_site_transient( 'update_plugins', null );
654
+		set_site_transient('update_plugins', null);
655 655
 
656 656
 		// Decode license data.
657
-		$license_data = json_decode( wp_remote_retrieve_body( $response ) );
658
-		update_option( $addon_license_option_name, $license_data );
657
+		$license_data = json_decode(wp_remote_retrieve_body($response));
658
+		update_option($addon_license_option_name, $license_data);
659 659
 	}// End foreach().
660 660
 }
661 661
 
@@ -685,9 +685,9 @@  discard block
 block discarded – undo
685 685
 	);
686 686
 
687 687
 	global $wp_roles;
688
-	foreach ( $delete_caps as $cap ) {
689
-		foreach ( array_keys( $wp_roles->roles ) as $role ) {
690
-			$wp_roles->remove_cap( $role, $cap );
688
+	foreach ($delete_caps as $cap) {
689
+		foreach (array_keys($wp_roles->roles) as $role) {
690
+			$wp_roles->remove_cap($role, $cap);
691 691
 		}
692 692
 	}
693 693
 
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
 function give_v18_upgrades_core_setting() {
722 722
 	// Core settings which changes from checkbox to radio.
723 723
 	$core_setting_names = array_merge(
724
-		array_keys( give_v18_renamed_core_settings() ),
724
+		array_keys(give_v18_renamed_core_settings()),
725 725
 		array(
726 726
 			'uninstall_on_delete',
727 727
 			'scripts_footer',
@@ -733,48 +733,48 @@  discard block
 block discarded – undo
733 733
 	);
734 734
 
735 735
 	// Bailout: If not any setting define.
736
-	if ( $give_settings = get_option( 'give_settings' ) ) {
736
+	if ($give_settings = get_option('give_settings')) {
737 737
 
738 738
 		$setting_changed = false;
739 739
 
740 740
 		// Loop: check each setting field.
741
-		foreach ( $core_setting_names as $setting_name ) {
741
+		foreach ($core_setting_names as $setting_name) {
742 742
 			// New setting name.
743
-			$new_setting_name = preg_replace( '/^(enable_|disable_)/', '', $setting_name );
743
+			$new_setting_name = preg_replace('/^(enable_|disable_)/', '', $setting_name);
744 744
 
745 745
 			// Continue: If setting already set.
746 746
 			if (
747
-				array_key_exists( $new_setting_name, $give_settings )
748
-				&& in_array( $give_settings[ $new_setting_name ], array( 'enabled', 'disabled' ) )
747
+				array_key_exists($new_setting_name, $give_settings)
748
+				&& in_array($give_settings[$new_setting_name], array('enabled', 'disabled'))
749 749
 			) {
750 750
 				continue;
751 751
 			}
752 752
 
753 753
 			// Set checkbox value to radio value.
754
-			$give_settings[ $setting_name ] = ( ! empty( $give_settings[ $setting_name ] ) && 'on' === $give_settings[ $setting_name ] ? 'enabled' : 'disabled' );
754
+			$give_settings[$setting_name] = ( ! empty($give_settings[$setting_name]) && 'on' === $give_settings[$setting_name] ? 'enabled' : 'disabled');
755 755
 
756 756
 			// @see https://github.com/WordImpress/Give/issues/1063.
757
-			if ( false !== strpos( $setting_name, 'disable_' ) ) {
757
+			if (false !== strpos($setting_name, 'disable_')) {
758 758
 
759
-				$give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'disabled' : 'enabled' );
760
-			} elseif ( false !== strpos( $setting_name, 'enable_' ) ) {
759
+				$give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'disabled' : 'enabled');
760
+			} elseif (false !== strpos($setting_name, 'enable_')) {
761 761
 
762
-				$give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'enabled' : 'disabled' );
762
+				$give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'enabled' : 'disabled');
763 763
 			}
764 764
 
765 765
 			// Tell bot to update core setting to db.
766
-			if ( ! $setting_changed ) {
766
+			if ( ! $setting_changed) {
767 767
 				$setting_changed = true;
768 768
 			}
769 769
 		}
770 770
 
771 771
 		// Update setting only if they changed.
772
-		if ( $setting_changed ) {
773
-			update_option( 'give_settings', $give_settings );
772
+		if ($setting_changed) {
773
+			update_option('give_settings', $give_settings);
774 774
 		}
775 775
 	}// End if().
776 776
 
777
-	give_set_upgrade_complete( 'v18_upgrades_core_setting' );
777
+	give_set_upgrade_complete('v18_upgrades_core_setting');
778 778
 }
779 779
 
780 780
 /**
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
 	$give_updates = Give_Updates::get_instance();
789 789
 
790 790
 	// form query
791
-	$forms = new WP_Query( array(
791
+	$forms = new WP_Query(array(
792 792
 			'paged'          => $give_updates->step,
793 793
 			'status'         => 'any',
794 794
 			'order'          => 'ASC',
@@ -797,41 +797,41 @@  discard block
 block discarded – undo
797 797
 		)
798 798
 	);
799 799
 
800
-	if ( $forms->have_posts() ) {
801
-		$give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 20 ) );
800
+	if ($forms->have_posts()) {
801
+		$give_updates->set_percentage($forms->found_posts, ($give_updates->step * 20));
802 802
 
803
-		while ( $forms->have_posts() ) {
803
+		while ($forms->have_posts()) {
804 804
 			$forms->the_post();
805 805
 
806 806
 			// Form content.
807 807
 			// Note in version 1.8 display content setting split into display content and content placement setting.
808 808
 			// You can delete _give_content_option in future.
809
-			$show_content = give_get_meta( get_the_ID(), '_give_content_option', true );
810
-			if ( $show_content && ! give_get_meta( get_the_ID(), '_give_display_content', true ) ) {
811
-				$field_value = ( 'none' !== $show_content ? 'enabled' : 'disabled' );
812
-				give_update_meta( get_the_ID(), '_give_display_content', $field_value );
809
+			$show_content = give_get_meta(get_the_ID(), '_give_content_option', true);
810
+			if ($show_content && ! give_get_meta(get_the_ID(), '_give_display_content', true)) {
811
+				$field_value = ('none' !== $show_content ? 'enabled' : 'disabled');
812
+				give_update_meta(get_the_ID(), '_give_display_content', $field_value);
813 813
 
814
-				$field_value = ( 'none' !== $show_content ? $show_content : 'give_pre_form' );
815
-				give_update_meta( get_the_ID(), '_give_content_placement', $field_value );
814
+				$field_value = ('none' !== $show_content ? $show_content : 'give_pre_form');
815
+				give_update_meta(get_the_ID(), '_give_content_placement', $field_value);
816 816
 			}
817 817
 
818 818
 			// "Disable" Guest Donation. Checkbox.
819 819
 			// See: https://github.com/WordImpress/Give/issues/1470.
820
-			$guest_donation        = give_get_meta( get_the_ID(), '_give_logged_in_only', true );
821
-			$guest_donation_newval = ( in_array( $guest_donation, array( 'yes', 'on' ) ) ? 'disabled' : 'enabled' );
822
-			give_update_meta( get_the_ID(), '_give_logged_in_only', $guest_donation_newval );
820
+			$guest_donation        = give_get_meta(get_the_ID(), '_give_logged_in_only', true);
821
+			$guest_donation_newval = (in_array($guest_donation, array('yes', 'on')) ? 'disabled' : 'enabled');
822
+			give_update_meta(get_the_ID(), '_give_logged_in_only', $guest_donation_newval);
823 823
 
824 824
 			// Offline Donations.
825 825
 			// See: https://github.com/WordImpress/Give/issues/1579.
826
-			$offline_donation = give_get_meta( get_the_ID(), '_give_customize_offline_donations', true );
827
-			if ( 'no' === $offline_donation ) {
826
+			$offline_donation = give_get_meta(get_the_ID(), '_give_customize_offline_donations', true);
827
+			if ('no' === $offline_donation) {
828 828
 				$offline_donation_newval = 'global';
829
-			} elseif ( 'yes' === $offline_donation ) {
829
+			} elseif ('yes' === $offline_donation) {
830 830
 				$offline_donation_newval = 'enabled';
831 831
 			} else {
832 832
 				$offline_donation_newval = 'disabled';
833 833
 			}
834
-			give_update_meta( get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval );
834
+			give_update_meta(get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval);
835 835
 
836 836
 			// Convert yes/no setting field to enabled/disabled.
837 837
 			$form_radio_settings = array(
@@ -851,15 +851,15 @@  discard block
 block discarded – undo
851 851
 				'_give_offline_donation_enable_billing_fields_single',
852 852
 			);
853 853
 
854
-			foreach ( $form_radio_settings as $meta_key ) {
854
+			foreach ($form_radio_settings as $meta_key) {
855 855
 				// Get value.
856
-				$field_value = give_get_meta( get_the_ID(), $meta_key, true );
856
+				$field_value = give_get_meta(get_the_ID(), $meta_key, true);
857 857
 
858 858
 				// Convert meta value only if it is in yes/no/none.
859
-				if ( in_array( $field_value, array( 'yes', 'on', 'no', 'none' ) ) ) {
859
+				if (in_array($field_value, array('yes', 'on', 'no', 'none'))) {
860 860
 
861
-					$field_value = ( in_array( $field_value, array( 'yes', 'on' ) ) ? 'enabled' : 'disabled' );
862
-					give_update_meta( get_the_ID(), $meta_key, $field_value );
861
+					$field_value = (in_array($field_value, array('yes', 'on')) ? 'enabled' : 'disabled');
862
+					give_update_meta(get_the_ID(), $meta_key, $field_value);
863 863
 				}
864 864
 			}
865 865
 		}// End while().
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
 
869 869
 	} else {
870 870
 		// No more forms found, finish up.
871
-		give_set_upgrade_complete( 'v18_upgrades_form_metadata' );
871
+		give_set_upgrade_complete('v18_upgrades_form_metadata');
872 872
 	}
873 873
 }
874 874
 
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
 				'%_transient_give_stats_%',
936 936
 				'give_cache%',
937 937
 				'%_transient_give_add_ons_feed%',
938
-				'%_transient__give_ajax_works' .
938
+				'%_transient__give_ajax_works'.
939 939
 				'%_transient_give_total_api_keys%',
940 940
 				'%_transient_give_i18n_give_promo_hide%',
941 941
 				'%_transient_give_contributors%',
@@ -962,24 +962,24 @@  discard block
 block discarded – undo
962 962
 		ARRAY_A
963 963
 	);
964 964
 
965
-	if ( ! empty( $user_apikey_options ) ) {
966
-		foreach ( $user_apikey_options as $user ) {
967
-			$cached_options[] = '_transient_' . md5( 'give_api_user_' . $user['meta_key'] );
968
-			$cached_options[] = '_transient_' . md5( 'give_api_user_public_key' . $user['user_id'] );
969
-			$cached_options[] = '_transient_' . md5( 'give_api_user_secret_key' . $user['user_id'] );
965
+	if ( ! empty($user_apikey_options)) {
966
+		foreach ($user_apikey_options as $user) {
967
+			$cached_options[] = '_transient_'.md5('give_api_user_'.$user['meta_key']);
968
+			$cached_options[] = '_transient_'.md5('give_api_user_public_key'.$user['user_id']);
969
+			$cached_options[] = '_transient_'.md5('give_api_user_secret_key'.$user['user_id']);
970 970
 		}
971 971
 	}
972 972
 
973
-	if ( ! empty( $cached_options ) ) {
974
-		foreach ( $cached_options as $option ) {
975
-			switch ( true ) {
976
-				case ( false !== strpos( $option, 'transient' ) ):
977
-					$option = str_replace( '_transient_', '', $option );
978
-					delete_transient( $option );
973
+	if ( ! empty($cached_options)) {
974
+		foreach ($cached_options as $option) {
975
+			switch (true) {
976
+				case (false !== strpos($option, 'transient')):
977
+					$option = str_replace('_transient_', '', $option);
978
+					delete_transient($option);
979 979
 					break;
980 980
 
981 981
 				default:
982
-					delete_option( $option );
982
+					delete_option($option);
983 983
 			}
984 984
 		}
985 985
 	}
@@ -997,7 +997,7 @@  discard block
 block discarded – undo
997 997
 	global $wp_roles;
998 998
 
999 999
 	// Get the role object.
1000
-	$give_worker = get_role( 'give_worker' );
1000
+	$give_worker = get_role('give_worker');
1001 1001
 
1002 1002
 	// A list of capabilities to add for give workers.
1003 1003
 	$caps_to_add = array(
@@ -1005,9 +1005,9 @@  discard block
 block discarded – undo
1005 1005
 		'edit_pages',
1006 1006
 	);
1007 1007
 
1008
-	foreach ( $caps_to_add as $cap ) {
1008
+	foreach ($caps_to_add as $cap) {
1009 1009
 		// Add the capability.
1010
-		$give_worker->add_cap( $cap );
1010
+		$give_worker->add_cap($cap);
1011 1011
 	}
1012 1012
 
1013 1013
 }
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
 	$give_updates = Give_Updates::get_instance();
1025 1025
 
1026 1026
 	// form query.
1027
-	$donation_forms = new WP_Query( array(
1027
+	$donation_forms = new WP_Query(array(
1028 1028
 			'paged'          => $give_updates->step,
1029 1029
 			'status'         => 'any',
1030 1030
 			'order'          => 'ASC',
@@ -1033,10 +1033,10 @@  discard block
 block discarded – undo
1033 1033
 		)
1034 1034
 	);
1035 1035
 
1036
-	if ( $donation_forms->have_posts() ) {
1037
-		$give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) );
1036
+	if ($donation_forms->have_posts()) {
1037
+		$give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20));
1038 1038
 
1039
-		while ( $donation_forms->have_posts() ) {
1039
+		while ($donation_forms->have_posts()) {
1040 1040
 			$donation_forms->the_post();
1041 1041
 			$form_id = get_the_ID();
1042 1042
 
@@ -1044,41 +1044,41 @@  discard block
 block discarded – undo
1044 1044
 			update_post_meta(
1045 1045
 				$form_id,
1046 1046
 				'_give_set_price',
1047
-				give_sanitize_amount( get_post_meta( $form_id, '_give_set_price', true ) )
1047
+				give_sanitize_amount(get_post_meta($form_id, '_give_set_price', true))
1048 1048
 			);
1049 1049
 
1050 1050
 			// Remove formatting from _give_custom_amount_minimum.
1051 1051
 			update_post_meta(
1052 1052
 				$form_id,
1053 1053
 				'_give_custom_amount_minimum',
1054
-				give_sanitize_amount( get_post_meta( $form_id, '_give_custom_amount_minimum', true ) )
1054
+				give_sanitize_amount(get_post_meta($form_id, '_give_custom_amount_minimum', true))
1055 1055
 			);
1056 1056
 
1057 1057
 			// Bailout.
1058
-			if ( 'set' === get_post_meta( $form_id, '_give_price_option', true ) ) {
1058
+			if ('set' === get_post_meta($form_id, '_give_price_option', true)) {
1059 1059
 				continue;
1060 1060
 			}
1061 1061
 
1062
-			$donation_levels = get_post_meta( $form_id, '_give_donation_levels', true );
1062
+			$donation_levels = get_post_meta($form_id, '_give_donation_levels', true);
1063 1063
 
1064
-			if ( ! empty( $donation_levels ) ) {
1064
+			if ( ! empty($donation_levels)) {
1065 1065
 
1066
-				foreach ( $donation_levels as $index => $donation_level ) {
1067
-					if ( isset( $donation_level['_give_amount'] ) ) {
1068
-						$donation_levels[ $index ]['_give_amount'] = give_sanitize_amount( $donation_level['_give_amount'] );
1066
+				foreach ($donation_levels as $index => $donation_level) {
1067
+					if (isset($donation_level['_give_amount'])) {
1068
+						$donation_levels[$index]['_give_amount'] = give_sanitize_amount($donation_level['_give_amount']);
1069 1069
 					}
1070 1070
 				}
1071 1071
 
1072
-				update_post_meta( $form_id, '_give_donation_levels', $donation_levels );
1072
+				update_post_meta($form_id, '_give_donation_levels', $donation_levels);
1073 1073
 
1074
-				$donation_levels_amounts = wp_list_pluck( $donation_levels, '_give_amount' );
1074
+				$donation_levels_amounts = wp_list_pluck($donation_levels, '_give_amount');
1075 1075
 
1076
-				$min_amount = min( $donation_levels_amounts );
1077
-				$max_amount = max( $donation_levels_amounts );
1076
+				$min_amount = min($donation_levels_amounts);
1077
+				$max_amount = max($donation_levels_amounts);
1078 1078
 
1079 1079
 				// Set Minimum and Maximum amount for Multi Level Donation Forms
1080
-				give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount( $min_amount ) : 0 );
1081
-				give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount( $max_amount ) : 0 );
1080
+				give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount($min_amount) : 0);
1081
+				give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount($max_amount) : 0);
1082 1082
 			}
1083 1083
 
1084 1084
 		}
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
 		wp_reset_postdata();
1088 1088
 	} else {
1089 1089
 		// The Update Ran.
1090
-		give_set_upgrade_complete( 'v189_upgrades_levels_post_meta' );
1090
+		give_set_upgrade_complete('v189_upgrades_levels_post_meta');
1091 1091
 	}
1092 1092
 
1093 1093
 }
@@ -1137,7 +1137,7 @@  discard block
 block discarded – undo
1137 1137
  */
1138 1138
 function give_v20_upgrades() {
1139 1139
 	// Update cache setting.
1140
-	give_update_option( 'cache', 'enabled' );
1140
+	give_update_option('cache', 'enabled');
1141 1141
 
1142 1142
 	// Upgrade email settings.
1143 1143
 	give_v20_upgrades_email_setting();
@@ -1156,7 +1156,7 @@  discard block
 block discarded – undo
1156 1156
 	$all_setting = give_get_settings();
1157 1157
 
1158 1158
 	// Bailout on fresh install.
1159
-	if ( empty( $all_setting ) ) {
1159
+	if (empty($all_setting)) {
1160 1160
 		return;
1161 1161
 	}
1162 1162
 
@@ -1175,19 +1175,19 @@  discard block
 block discarded – undo
1175 1175
 		'admin_notices'                 => 'new-donation_notification',
1176 1176
 	);
1177 1177
 
1178
-	foreach ( $settings as $old_setting => $new_setting ) {
1178
+	foreach ($settings as $old_setting => $new_setting) {
1179 1179
 		// Do not update already modified
1180
-		if ( ! is_array( $new_setting ) ) {
1181
-			if ( array_key_exists( $new_setting, $all_setting ) || ! array_key_exists( $old_setting, $all_setting ) ) {
1180
+		if ( ! is_array($new_setting)) {
1181
+			if (array_key_exists($new_setting, $all_setting) || ! array_key_exists($old_setting, $all_setting)) {
1182 1182
 				continue;
1183 1183
 			}
1184 1184
 		}
1185 1185
 
1186
-		switch ( $old_setting ) {
1186
+		switch ($old_setting) {
1187 1187
 			case 'admin_notices':
1188
-				$notification_status = give_get_option( $old_setting, 'enabled' );
1188
+				$notification_status = give_get_option($old_setting, 'enabled');
1189 1189
 
1190
-				give_update_option( $new_setting, $notification_status );
1190
+				give_update_option($new_setting, $notification_status);
1191 1191
 
1192 1192
 				// @todo: Delete this option later ( version > 2.0 ), We need this for per form email addon.
1193 1193
 				// give_delete_option( $old_setting );
@@ -1198,19 +1198,19 @@  discard block
 block discarded – undo
1198 1198
 			case 'admin_notice_emails':
1199 1199
 				$recipients = give_get_admin_notice_emails();
1200 1200
 
1201
-				foreach ( $new_setting as $setting ) {
1201
+				foreach ($new_setting as $setting) {
1202 1202
 					// bailout if setting already exist.
1203
-					if ( array_key_exists( $setting, $all_setting ) ) {
1203
+					if (array_key_exists($setting, $all_setting)) {
1204 1204
 						continue;
1205 1205
 					}
1206 1206
 
1207
-					give_update_option( $setting, $recipients );
1207
+					give_update_option($setting, $recipients);
1208 1208
 				}
1209 1209
 				break;
1210 1210
 
1211 1211
 			default:
1212
-				give_update_option( $new_setting, give_get_option( $old_setting ) );
1213
-				give_delete_option( $old_setting );
1212
+				give_update_option($new_setting, give_get_option($old_setting));
1213
+				give_delete_option($old_setting);
1214 1214
 		}
1215 1215
 	}
1216 1216
 }
@@ -1227,22 +1227,22 @@  discard block
 block discarded – undo
1227 1227
 	$give_settings        = give_get_settings();
1228 1228
 	$give_setting_updated = false;
1229 1229
 
1230
-	if ( $give_settings['thousands_separator'] === $give_settings['decimal_separator'] ) {
1230
+	if ($give_settings['thousands_separator'] === $give_settings['decimal_separator']) {
1231 1231
 		$give_settings['number_decimals']   = 0;
1232 1232
 		$give_settings['decimal_separator'] = '';
1233 1233
 		$give_setting_updated               = true;
1234 1234
 
1235
-	} elseif ( empty( $give_settings['decimal_separator'] ) ) {
1235
+	} elseif (empty($give_settings['decimal_separator'])) {
1236 1236
 		$give_settings['number_decimals'] = 0;
1237 1237
 		$give_setting_updated             = true;
1238 1238
 
1239
-	} elseif ( 6 < absint( $give_settings['number_decimals'] ) ) {
1239
+	} elseif (6 < absint($give_settings['number_decimals'])) {
1240 1240
 		$give_settings['number_decimals'] = 5;
1241 1241
 		$give_setting_updated             = true;
1242 1242
 	}
1243 1243
 
1244
-	if ( $give_setting_updated ) {
1245
-		update_option( 'give_settings', $give_settings );
1244
+	if ($give_setting_updated) {
1245
+		update_option('give_settings', $give_settings);
1246 1246
 	}
1247 1247
 }
1248 1248
 
@@ -1261,69 +1261,69 @@  discard block
 block discarded – undo
1261 1261
 	$give_updates = Give_Updates::get_instance();
1262 1262
 
1263 1263
 	// form query.
1264
-	$donation_forms = new WP_Query( array(
1264
+	$donation_forms = new WP_Query(array(
1265 1265
 			'paged'          => $give_updates->step,
1266 1266
 			'status'         => 'any',
1267 1267
 			'order'          => 'ASC',
1268
-			'post_type'      => array( 'give_forms', 'give_payment' ),
1268
+			'post_type'      => array('give_forms', 'give_payment'),
1269 1269
 			'posts_per_page' => 20,
1270 1270
 		)
1271 1271
 	);
1272
-	if ( $donation_forms->have_posts() ) {
1273
-		$give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) );
1272
+	if ($donation_forms->have_posts()) {
1273
+		$give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20));
1274 1274
 
1275
-		while ( $donation_forms->have_posts() ) {
1275
+		while ($donation_forms->have_posts()) {
1276 1276
 			$donation_forms->the_post();
1277 1277
 			global $post;
1278 1278
 
1279
-			$meta = get_post_meta( $post->ID );
1279
+			$meta = get_post_meta($post->ID);
1280 1280
 
1281
-			switch ( $post->post_type ) {
1281
+			switch ($post->post_type) {
1282 1282
 				case 'give_forms':
1283 1283
 					// _give_set_price.
1284
-					if ( ! empty( $meta['_give_set_price'][0] ) ) {
1285
-						update_post_meta( $post->ID, '_give_set_price', give_sanitize_amount_for_db( $meta['_give_set_price'][0] ) );
1284
+					if ( ! empty($meta['_give_set_price'][0])) {
1285
+						update_post_meta($post->ID, '_give_set_price', give_sanitize_amount_for_db($meta['_give_set_price'][0]));
1286 1286
 					}
1287 1287
 
1288 1288
 					// _give_custom_amount_minimum.
1289
-					if ( ! empty( $meta['_give_custom_amount_minimum'][0] ) ) {
1290
-						update_post_meta( $post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db( $meta['_give_custom_amount_minimum'][0] ) );
1289
+					if ( ! empty($meta['_give_custom_amount_minimum'][0])) {
1290
+						update_post_meta($post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db($meta['_give_custom_amount_minimum'][0]));
1291 1291
 					}
1292 1292
 
1293 1293
 					// _give_levels_minimum_amount.
1294
-					if ( ! empty( $meta['_give_levels_minimum_amount'][0] ) ) {
1295
-						update_post_meta( $post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db( $meta['_give_levels_minimum_amount'][0] ) );
1294
+					if ( ! empty($meta['_give_levels_minimum_amount'][0])) {
1295
+						update_post_meta($post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db($meta['_give_levels_minimum_amount'][0]));
1296 1296
 					}
1297 1297
 
1298 1298
 					// _give_levels_maximum_amount.
1299
-					if ( ! empty( $meta['_give_levels_maximum_amount'][0] ) ) {
1300
-						update_post_meta( $post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db( $meta['_give_levels_maximum_amount'][0] ) );
1299
+					if ( ! empty($meta['_give_levels_maximum_amount'][0])) {
1300
+						update_post_meta($post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db($meta['_give_levels_maximum_amount'][0]));
1301 1301
 					}
1302 1302
 
1303 1303
 					// _give_set_goal.
1304
-					if ( ! empty( $meta['_give_set_goal'][0] ) ) {
1305
-						update_post_meta( $post->ID, '_give_set_goal', give_sanitize_amount_for_db( $meta['_give_set_goal'][0] ) );
1304
+					if ( ! empty($meta['_give_set_goal'][0])) {
1305
+						update_post_meta($post->ID, '_give_set_goal', give_sanitize_amount_for_db($meta['_give_set_goal'][0]));
1306 1306
 					}
1307 1307
 
1308 1308
 					// _give_form_earnings.
1309
-					if ( ! empty( $meta['_give_form_earnings'][0] ) ) {
1310
-						update_post_meta( $post->ID, '_give_form_earnings', give_sanitize_amount_for_db( $meta['_give_form_earnings'][0] ) );
1309
+					if ( ! empty($meta['_give_form_earnings'][0])) {
1310
+						update_post_meta($post->ID, '_give_form_earnings', give_sanitize_amount_for_db($meta['_give_form_earnings'][0]));
1311 1311
 					}
1312 1312
 
1313 1313
 					// _give_custom_amount_minimum.
1314
-					if ( ! empty( $meta['_give_donation_levels'][0] ) ) {
1315
-						$donation_levels = unserialize( $meta['_give_donation_levels'][0] );
1314
+					if ( ! empty($meta['_give_donation_levels'][0])) {
1315
+						$donation_levels = unserialize($meta['_give_donation_levels'][0]);
1316 1316
 
1317
-						foreach ( $donation_levels as $index => $level ) {
1318
-							if ( empty( $level['_give_amount'] ) ) {
1317
+						foreach ($donation_levels as $index => $level) {
1318
+							if (empty($level['_give_amount'])) {
1319 1319
 								continue;
1320 1320
 							}
1321 1321
 
1322
-							$donation_levels[ $index ]['_give_amount'] = give_sanitize_amount_for_db( $level['_give_amount'] );
1322
+							$donation_levels[$index]['_give_amount'] = give_sanitize_amount_for_db($level['_give_amount']);
1323 1323
 						}
1324 1324
 
1325 1325
 						$meta['_give_donation_levels'] = $donation_levels;
1326
-						update_post_meta( $post->ID, '_give_donation_levels', $meta['_give_donation_levels'] );
1326
+						update_post_meta($post->ID, '_give_donation_levels', $meta['_give_donation_levels']);
1327 1327
 					}
1328 1328
 
1329 1329
 
@@ -1331,8 +1331,8 @@  discard block
 block discarded – undo
1331 1331
 
1332 1332
 				case 'give_payment':
1333 1333
 					// _give_payment_total.
1334
-					if ( ! empty( $meta['_give_payment_total'][0] ) ) {
1335
-						update_post_meta( $post->ID, '_give_payment_total', give_sanitize_amount_for_db( $meta['_give_payment_total'][0] ) );
1334
+					if ( ! empty($meta['_give_payment_total'][0])) {
1335
+						update_post_meta($post->ID, '_give_payment_total', give_sanitize_amount_for_db($meta['_give_payment_total'][0]));
1336 1336
 					}
1337 1337
 
1338 1338
 					break;
@@ -1343,7 +1343,7 @@  discard block
 block discarded – undo
1343 1343
 		wp_reset_postdata();
1344 1344
 	} else {
1345 1345
 		// The Update Ran.
1346
-		give_set_upgrade_complete( 'v1812_update_amount_values' );
1346
+		give_set_upgrade_complete('v1812_update_amount_values');
1347 1347
 	}
1348 1348
 }
1349 1349
 
@@ -1362,22 +1362,22 @@  discard block
 block discarded – undo
1362 1362
 	$give_updates = Give_Updates::get_instance();
1363 1363
 
1364 1364
 	// form query.
1365
-	$donors = Give()->donors->get_donors( array(
1365
+	$donors = Give()->donors->get_donors(array(
1366 1366
 			'number' => 20,
1367
-			'offset' => $give_updates->get_offset( 20 ),
1367
+			'offset' => $give_updates->get_offset(20),
1368 1368
 		)
1369 1369
 	);
1370 1370
 
1371
-	if ( ! empty( $donors ) ) {
1372
-		$give_updates->set_percentage( Give()->donors->count(), $give_updates->get_offset( 20 ) );
1371
+	if ( ! empty($donors)) {
1372
+		$give_updates->set_percentage(Give()->donors->count(), $give_updates->get_offset(20));
1373 1373
 
1374 1374
 		/* @var Object $donor */
1375
-		foreach ( $donors as $donor ) {
1376
-			Give()->donors->update( $donor->id, array( 'purchase_value' => give_sanitize_amount_for_db( $donor->purchase_value ) ) );
1375
+		foreach ($donors as $donor) {
1376
+			Give()->donors->update($donor->id, array('purchase_value' => give_sanitize_amount_for_db($donor->purchase_value)));
1377 1377
 		}
1378 1378
 	} else {
1379 1379
 		// The Update Ran.
1380
-		give_set_upgrade_complete( 'v1812_update_donor_purchase_values' );
1380
+		give_set_upgrade_complete('v1812_update_donor_purchase_values');
1381 1381
 	}
1382 1382
 }
1383 1383
 
@@ -1391,25 +1391,25 @@  discard block
 block discarded – undo
1391 1391
 	$give_updates = Give_Updates::get_instance();
1392 1392
 
1393 1393
 	// Fetch all the existing donors.
1394
-	$donors = Give()->donors->get_donors( array(
1394
+	$donors = Give()->donors->get_donors(array(
1395 1395
 			'number' => 20,
1396
-			'offset' => $give_updates->get_offset( 20 ),
1396
+			'offset' => $give_updates->get_offset(20),
1397 1397
 		)
1398 1398
 	);
1399 1399
 
1400
-	if ( ! empty( $donors ) ) {
1401
-		$give_updates->set_percentage( Give()->donors->count(), $give_updates->get_offset( 20 ) );
1400
+	if ( ! empty($donors)) {
1401
+		$give_updates->set_percentage(Give()->donors->count(), $give_updates->get_offset(20));
1402 1402
 
1403 1403
 		/* @var Object $donor */
1404
-		foreach ( $donors as $donor ) {
1404
+		foreach ($donors as $donor) {
1405 1405
 			$user_id = $donor->user_id;
1406 1406
 
1407 1407
 			// Proceed, if donor is attached with user.
1408
-			if ( $user_id ) {
1409
-				$user = get_userdata( $user_id );
1408
+			if ($user_id) {
1409
+				$user = get_userdata($user_id);
1410 1410
 
1411 1411
 				// Update user role, if user has subscriber role.
1412
-				if ( is_array( $user->roles ) && in_array( 'subscriber', $user->roles ) ) {
1412
+				if (is_array($user->roles) && in_array('subscriber', $user->roles)) {
1413 1413
 					wp_update_user(
1414 1414
 						array(
1415 1415
 							'ID'   => $user_id,
@@ -1421,7 +1421,7 @@  discard block
 block discarded – undo
1421 1421
 		}
1422 1422
 	} else {
1423 1423
 		// The Update Ran.
1424
-		give_set_upgrade_complete( 'v1813_update_donor_user_roles' );
1424
+		give_set_upgrade_complete('v1813_update_donor_user_roles');
1425 1425
 	}
1426 1426
 }
1427 1427
 
@@ -1433,7 +1433,7 @@  discard block
 block discarded – undo
1433 1433
  */
1434 1434
 function give_v1813_upgrades() {
1435 1435
 	// Update admin setting.
1436
-	give_update_option( 'donor_default_user_role', 'give_donor' );
1436
+	give_update_option('donor_default_user_role', 'give_donor');
1437 1437
 
1438 1438
 	// Update Give roles.
1439 1439
 	$roles = new Give_Roles();
@@ -1451,33 +1451,33 @@  discard block
 block discarded – undo
1451 1451
 	$give_updates = Give_Updates::get_instance();
1452 1452
 
1453 1453
 	// form query.
1454
-	$payments = new WP_Query( array(
1454
+	$payments = new WP_Query(array(
1455 1455
 			'paged'          => $give_updates->step,
1456 1456
 			'status'         => 'any',
1457 1457
 			'order'          => 'ASC',
1458
-			'post_type'      => array( 'give_payment' ),
1458
+			'post_type'      => array('give_payment'),
1459 1459
 			'posts_per_page' => 100,
1460 1460
 		)
1461 1461
 	);
1462 1462
 
1463
-	if ( $payments->have_posts() ) {
1464
-		$give_updates->set_percentage( $payments->found_posts, ( $give_updates->step * 100 ) );
1463
+	if ($payments->have_posts()) {
1464
+		$give_updates->set_percentage($payments->found_posts, ($give_updates->step * 100));
1465 1465
 
1466
-		while ( $payments->have_posts() ) {
1466
+		while ($payments->have_posts()) {
1467 1467
 			$payments->the_post();
1468 1468
 
1469
-			$payment_meta = give_get_payment_meta( get_the_ID() );
1469
+			$payment_meta = give_get_payment_meta(get_the_ID());
1470 1470
 
1471
-			if ( 'RIAL' === $payment_meta['currency'] ) {
1471
+			if ('RIAL' === $payment_meta['currency']) {
1472 1472
 				$payment_meta['currency'] = 'IRR';
1473
-				give_update_meta( get_the_ID(), '_give_payment_meta', $payment_meta );
1473
+				give_update_meta(get_the_ID(), '_give_payment_meta', $payment_meta);
1474 1474
 			}
1475 1475
 
1476 1476
 		}
1477 1477
 
1478 1478
 	} else {
1479 1479
 		// The Update Ran.
1480
-		give_set_upgrade_complete( 'v1817_update_donation_iranian_currency_code' );
1480
+		give_set_upgrade_complete('v1817_update_donation_iranian_currency_code');
1481 1481
 	}
1482 1482
 }
1483 1483
 
@@ -1490,9 +1490,9 @@  discard block
 block discarded – undo
1490 1490
 function give_v1817_upgrades() {
1491 1491
 	$give_settings = give_get_settings();
1492 1492
 
1493
-	if ( 'RIAL' === $give_settings['currency'] ) {
1493
+	if ('RIAL' === $give_settings['currency']) {
1494 1494
 		$give_settings['currency'] = 'IRR';
1495
-		update_option( 'give_settings', $give_settings );
1495
+		update_option('give_settings', $give_settings);
1496 1496
 	}
1497 1497
 }
1498 1498
 
@@ -1505,7 +1505,7 @@  discard block
 block discarded – undo
1505 1505
 
1506 1506
 	global $wp_roles;
1507 1507
 
1508
-	if ( ! ( $wp_roles instanceof WP_Roles ) ) {
1508
+	if ( ! ($wp_roles instanceof WP_Roles)) {
1509 1509
 		return;
1510 1510
 	}
1511 1511
 
@@ -1529,15 +1529,15 @@  discard block
 block discarded – undo
1529 1529
 		),
1530 1530
 	);
1531 1531
 
1532
-	foreach ( $add_caps as $role => $caps ) {
1533
-		foreach ( $caps as $cap ) {
1534
-			$wp_roles->add_cap( $role, $cap );
1532
+	foreach ($add_caps as $role => $caps) {
1533
+		foreach ($caps as $cap) {
1534
+			$wp_roles->add_cap($role, $cap);
1535 1535
 		}
1536 1536
 	}
1537 1537
 
1538
-	foreach ( $remove_caps as $role => $caps ) {
1539
-		foreach ( $caps as $cap ) {
1540
-			$wp_roles->remove_cap( $role, $cap );
1538
+	foreach ($remove_caps as $role => $caps) {
1539
+		foreach ($caps as $cap) {
1540
+			$wp_roles->remove_cap($role, $cap);
1541 1541
 		}
1542 1542
 	}
1543 1543
 
@@ -1561,7 +1561,7 @@  discard block
 block discarded – undo
1561 1561
 	$roles->add_roles();
1562 1562
 	$roles->add_caps();
1563 1563
 
1564
-	give_set_upgrade_complete( 'v1817_cleanup_user_roles' );
1564
+	give_set_upgrade_complete('v1817_cleanup_user_roles');
1565 1565
 }
1566 1566
 
1567 1567
 /**
@@ -1572,7 +1572,7 @@  discard block
 block discarded – undo
1572 1572
 function give_v1818_upgrades() {
1573 1573
 
1574 1574
 	// Remove email_access_installed from give_settings.
1575
-	give_delete_option( 'email_access_installed' );
1575
+	give_delete_option('email_access_installed');
1576 1576
 }
1577 1577
 
1578 1578
 /**
@@ -1585,23 +1585,23 @@  discard block
 block discarded – undo
1585 1585
 	/* @var Give_Updates $give_updates */
1586 1586
 	$give_updates = Give_Updates::get_instance();
1587 1587
 
1588
-	$donations = new WP_Query( array(
1588
+	$donations = new WP_Query(array(
1589 1589
 			'paged'          => $give_updates->step,
1590 1590
 			'status'         => 'any',
1591 1591
 			'order'          => 'ASC',
1592
-			'post_type'      => array( 'give_payment' ),
1592
+			'post_type'      => array('give_payment'),
1593 1593
 			'posts_per_page' => 100,
1594 1594
 		)
1595 1595
 	);
1596 1596
 
1597
-	if ( $donations->have_posts() ) {
1598
-		$give_updates->set_percentage( $donations->found_posts, $give_updates->step * 100 );
1597
+	if ($donations->have_posts()) {
1598
+		$give_updates->set_percentage($donations->found_posts, $give_updates->step * 100);
1599 1599
 
1600
-		while ( $donations->have_posts() ) {
1600
+		while ($donations->have_posts()) {
1601 1601
 			$donations->the_post();
1602 1602
 
1603
-			$form          = new Give_Donate_Form( give_get_meta( get_the_ID(), '_give_payment_form_id', true ) );
1604
-			$donation_meta = give_get_payment_meta( get_the_ID() );
1603
+			$form          = new Give_Donate_Form(give_get_meta(get_the_ID(), '_give_payment_form_id', true));
1604
+			$donation_meta = give_get_payment_meta(get_the_ID());
1605 1605
 
1606 1606
 			// Update Donation meta with price_id set as custom, only if it is:
1607 1607
 			// 1. Donation Type = Set Donation.
@@ -1610,19 +1610,19 @@  discard block
 block discarded – undo
1610 1610
 			if (
1611 1611
 				$form->ID &&
1612 1612
 				$form->is_set_type_donation_form() &&
1613
-				( 'custom' !== $donation_meta['price_id'] ) &&
1614
-				$form->is_custom_price( give_get_meta( get_the_ID(), '_give_payment_total', true ) )
1613
+				('custom' !== $donation_meta['price_id']) &&
1614
+				$form->is_custom_price(give_get_meta(get_the_ID(), '_give_payment_total', true))
1615 1615
 			) {
1616 1616
 				$donation_meta['price_id'] = 'custom';
1617
-				give_update_meta( get_the_ID(), '_give_payment_meta', $donation_meta );
1618
-				give_update_meta( get_the_ID(), '_give_payment_price_id', 'custom' );
1617
+				give_update_meta(get_the_ID(), '_give_payment_meta', $donation_meta);
1618
+				give_update_meta(get_the_ID(), '_give_payment_price_id', 'custom');
1619 1619
 			}
1620 1620
 		}
1621 1621
 
1622 1622
 		wp_reset_postdata();
1623 1623
 	} else {
1624 1624
 		// Update Ran Successfully.
1625
-		give_set_upgrade_complete( 'v1818_assign_custom_amount_set_donation' );
1625
+		give_set_upgrade_complete('v1818_assign_custom_amount_set_donation');
1626 1626
 	}
1627 1627
 }
1628 1628
 
@@ -1640,7 +1640,7 @@  discard block
 block discarded – undo
1640 1640
 
1641 1641
 	global $wp_roles;
1642 1642
 
1643
-	if ( ! ( $wp_roles instanceof WP_Roles ) ) {
1643
+	if ( ! ($wp_roles instanceof WP_Roles)) {
1644 1644
 		return;
1645 1645
 	}
1646 1646
 
@@ -1658,9 +1658,9 @@  discard block
 block discarded – undo
1658 1658
 		),
1659 1659
 	);
1660 1660
 
1661
-	foreach ( $remove_caps as $role => $caps ) {
1662
-		foreach ( $caps as $cap ) {
1663
-			$wp_roles->remove_cap( $role, $cap );
1661
+	foreach ($remove_caps as $role => $caps) {
1662
+		foreach ($caps as $cap) {
1663
+			$wp_roles->remove_cap($role, $cap);
1664 1664
 		}
1665 1665
 	}
1666 1666
 
@@ -1671,7 +1671,7 @@  discard block
 block discarded – undo
1671 1671
 	$roles->add_roles();
1672 1672
 	$roles->add_caps();
1673 1673
 
1674
-	give_set_upgrade_complete( 'v1818_give_worker_role_cleanup' );
1674
+	give_set_upgrade_complete('v1818_give_worker_role_cleanup');
1675 1675
 }
1676 1676
 
1677 1677
 /**
@@ -1685,7 +1685,7 @@  discard block
 block discarded – undo
1685 1685
 	$give_updates = Give_Updates::get_instance();
1686 1686
 
1687 1687
 	// form query
1688
-	$forms = new WP_Query( array(
1688
+	$forms = new WP_Query(array(
1689 1689
 			'paged'          => $give_updates->step,
1690 1690
 			'status'         => 'any',
1691 1691
 			'order'          => 'ASC',
@@ -1694,22 +1694,22 @@  discard block
 block discarded – undo
1694 1694
 		)
1695 1695
 	);
1696 1696
 
1697
-	if ( $forms->have_posts() ) {
1698
-		$give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 100 ) );
1697
+	if ($forms->have_posts()) {
1698
+		$give_updates->set_percentage($forms->found_posts, ($give_updates->step * 100));
1699 1699
 
1700
-		while ( $forms->have_posts() ) {
1700
+		while ($forms->have_posts()) {
1701 1701
 			$forms->the_post();
1702 1702
 			global $post;
1703 1703
 
1704 1704
 			// Update offline instruction email notification status.
1705
-			$offline_instruction_notification_status = get_post_meta( get_the_ID(), '_give_customize_offline_donations', true );
1706
-			$offline_instruction_notification_status = give_is_setting_enabled( $offline_instruction_notification_status, array(
1705
+			$offline_instruction_notification_status = get_post_meta(get_the_ID(), '_give_customize_offline_donations', true);
1706
+			$offline_instruction_notification_status = give_is_setting_enabled($offline_instruction_notification_status, array(
1707 1707
 				'enabled',
1708 1708
 				'global',
1709
-			) )
1709
+			))
1710 1710
 				? $offline_instruction_notification_status
1711 1711
 				: 'global';
1712
-			update_post_meta( get_the_ID(), '_give_offline-donation-instruction_notification', $offline_instruction_notification_status );
1712
+			update_post_meta(get_the_ID(), '_give_offline-donation-instruction_notification', $offline_instruction_notification_status);
1713 1713
 
1714 1714
 			// Update offline instruction email message.
1715 1715
 			update_post_meta(
@@ -1741,7 +1741,7 @@  discard block
 block discarded – undo
1741 1741
 		wp_reset_postdata();
1742 1742
 	} else {
1743 1743
 		// No more forms found, finish up.
1744
-		give_set_upgrade_complete( 'v20_upgrades_form_metadata' );
1744
+		give_set_upgrade_complete('v20_upgrades_form_metadata');
1745 1745
 	}
1746 1746
 }
1747 1747
 
@@ -1758,7 +1758,7 @@  discard block
 block discarded – undo
1758 1758
 	$give_updates = Give_Updates::get_instance();
1759 1759
 
1760 1760
 	// form query
1761
-	$forms = new WP_Query( array(
1761
+	$forms = new WP_Query(array(
1762 1762
 			'paged'          => $give_updates->step,
1763 1763
 			'status'         => 'any',
1764 1764
 			'order'          => 'ASC',
@@ -1767,19 +1767,19 @@  discard block
 block discarded – undo
1767 1767
 		)
1768 1768
 	);
1769 1769
 
1770
-	if ( $forms->have_posts() ) {
1771
-		$give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 100 ) );
1770
+	if ($forms->have_posts()) {
1771
+		$give_updates->set_percentage($forms->found_posts, ($give_updates->step * 100));
1772 1772
 
1773
-		while ( $forms->have_posts() ) {
1773
+		while ($forms->have_posts()) {
1774 1774
 			$forms->the_post();
1775 1775
 			global $post;
1776 1776
 
1777 1777
 			// Split _give_payment_meta meta.
1778 1778
 			// @todo Remove _give_payment_meta after releases 2.0
1779
-			$payment_meta = give_get_meta( $post->ID, '_give_payment_meta', true );
1779
+			$payment_meta = give_get_meta($post->ID, '_give_payment_meta', true);
1780 1780
 
1781
-			if ( ! empty( $payment_meta ) ) {
1782
-				_give_20_bc_split_and_save_give_payment_meta( $post->ID, $payment_meta );
1781
+			if ( ! empty($payment_meta)) {
1782
+				_give_20_bc_split_and_save_give_payment_meta($post->ID, $payment_meta);
1783 1783
 			}
1784 1784
 
1785 1785
 			$deprecated_meta_keys = array(
@@ -1788,9 +1788,9 @@  discard block
 block discarded – undo
1788 1788
 				'_give_payment_user_ip'     => '_give_payment_donor_ip',
1789 1789
 			);
1790 1790
 
1791
-			foreach ( $deprecated_meta_keys as $old_meta_key => $new_meta_key ) {
1791
+			foreach ($deprecated_meta_keys as $old_meta_key => $new_meta_key) {
1792 1792
 				// Do not add new meta key if already exist.
1793
-				if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key ) ) ) {
1793
+				if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key))) {
1794 1794
 					continue;
1795 1795
 				}
1796 1796
 
@@ -1799,25 +1799,25 @@  discard block
 block discarded – undo
1799 1799
 					array(
1800 1800
 						'post_id'    => $post->ID,
1801 1801
 						'meta_key'   => $new_meta_key,
1802
-						'meta_value' => give_get_meta( $post->ID, $old_meta_key, true ),
1802
+						'meta_value' => give_get_meta($post->ID, $old_meta_key, true),
1803 1803
 					)
1804 1804
 				);
1805 1805
 			}
1806 1806
 
1807 1807
 			// Bailout
1808
-			if ( $donor_id = give_get_meta( $post->ID, '_give_payment_donor_id', true ) ) {
1808
+			if ($donor_id = give_get_meta($post->ID, '_give_payment_donor_id', true)) {
1809 1809
 				/* @var Give_Donor $donor */
1810
-				$donor = new Give_Donor( $donor_id );
1810
+				$donor = new Give_Donor($donor_id);
1811 1811
 
1812
-				$address['line1']   = give_get_meta( $post->ID, '_give_donor_billing_address1', true, '' );
1813
-				$address['line2']   = give_get_meta( $post->ID, '_give_donor_billing_address2', true, '' );
1814
-				$address['city']    = give_get_meta( $post->ID, '_give_donor_billing_city', true, '' );
1815
-				$address['state']   = give_get_meta( $post->ID, '_give_donor_billing_state', true, '' );
1816
-				$address['zip']     = give_get_meta( $post->ID, '_give_donor_billing_zip', true, '' );
1817
-				$address['country'] = give_get_meta( $post->ID, '_give_donor_billing_country', true, '' );
1812
+				$address['line1']   = give_get_meta($post->ID, '_give_donor_billing_address1', true, '');
1813
+				$address['line2']   = give_get_meta($post->ID, '_give_donor_billing_address2', true, '');
1814
+				$address['city']    = give_get_meta($post->ID, '_give_donor_billing_city', true, '');
1815
+				$address['state']   = give_get_meta($post->ID, '_give_donor_billing_state', true, '');
1816
+				$address['zip']     = give_get_meta($post->ID, '_give_donor_billing_zip', true, '');
1817
+				$address['country'] = give_get_meta($post->ID, '_give_donor_billing_country', true, '');
1818 1818
 
1819 1819
 				// Save address.
1820
-				$donor->add_address( 'billing[]', $address );
1820
+				$donor->add_address('billing[]', $address);
1821 1821
 			}
1822 1822
 
1823 1823
 		}// End while().
@@ -1828,7 +1828,7 @@  discard block
 block discarded – undo
1828 1828
 		// $wpdb->get_var( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key=%s", '_give_payment_user_id' ) );
1829 1829
 
1830 1830
 		// No more forms found, finish up.
1831
-		give_set_upgrade_complete( 'v20_upgrades_payment_metadata' );
1831
+		give_set_upgrade_complete('v20_upgrades_payment_metadata');
1832 1832
 	}
1833 1833
 }
1834 1834
 
@@ -1844,7 +1844,7 @@  discard block
 block discarded – undo
1844 1844
 	$give_updates = Give_Updates::get_instance();
1845 1845
 
1846 1846
 	// form query
1847
-	$forms = new WP_Query( array(
1847
+	$forms = new WP_Query(array(
1848 1848
 			'paged'          => $give_updates->step,
1849 1849
 			'order'          => 'DESC',
1850 1850
 			'post_type'      => 'give_log',
@@ -1853,20 +1853,20 @@  discard block
 block discarded – undo
1853 1853
 		)
1854 1854
 	);
1855 1855
 
1856
-	if ( $forms->have_posts() ) {
1857
-		$give_updates->set_percentage( $forms->found_posts, $give_updates->step * 100 );
1856
+	if ($forms->have_posts()) {
1857
+		$give_updates->set_percentage($forms->found_posts, $give_updates->step * 100);
1858 1858
 
1859
-		while ( $forms->have_posts() ) {
1859
+		while ($forms->have_posts()) {
1860 1860
 			$forms->the_post();
1861 1861
 			global $post;
1862 1862
 
1863
-			if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID ) ) ) {
1863
+			if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID))) {
1864 1864
 				continue;
1865 1865
 			}
1866 1866
 
1867
-			$term      = get_the_terms( $post->ID, 'give_log_type' );
1868
-			$term      = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array();
1869
-			$term_name = ! empty( $term ) ? $term->slug : '';
1867
+			$term      = get_the_terms($post->ID, 'give_log_type');
1868
+			$term      = ! is_wp_error($term) && ! empty($term) ? $term[0] : array();
1869
+			$term_name = ! empty($term) ? $term->slug : '';
1870 1870
 
1871 1871
 			$log_data = array(
1872 1872
 				'ID'           => $post->ID,
@@ -1879,29 +1879,29 @@  discard block
 block discarded – undo
1879 1879
 			);
1880 1880
 			$log_meta = array();
1881 1881
 
1882
-			if ( $old_log_meta = get_post_meta( $post->ID ) ) {
1883
-				foreach ( $old_log_meta as $meta_key => $meta_value ) {
1884
-					switch ( $meta_key ) {
1882
+			if ($old_log_meta = get_post_meta($post->ID)) {
1883
+				foreach ($old_log_meta as $meta_key => $meta_value) {
1884
+					switch ($meta_key) {
1885 1885
 						case '_give_log_payment_id':
1886
-							$log_data['log_parent']        = current( $meta_value );
1886
+							$log_data['log_parent']        = current($meta_value);
1887 1887
 							$log_meta['_give_log_form_id'] = $post->post_parent;
1888 1888
 							break;
1889 1889
 
1890 1890
 						default:
1891
-							$log_meta[ $meta_key ] = current( $meta_value );
1891
+							$log_meta[$meta_key] = current($meta_value);
1892 1892
 					}
1893 1893
 				}
1894 1894
 			}
1895 1895
 
1896
-			if ( 'api_request' === $term_name ) {
1896
+			if ('api_request' === $term_name) {
1897 1897
 				$log_meta['_give_log_api_query'] = $post->post_excerpt;
1898 1898
 			}
1899 1899
 
1900
-			$wpdb->insert( "{$wpdb->prefix}give_logs", $log_data );
1900
+			$wpdb->insert("{$wpdb->prefix}give_logs", $log_data);
1901 1901
 
1902
-			if ( ! empty( $log_meta ) ) {
1903
-				foreach ( $log_meta as $meta_key => $meta_value ) {
1904
-					Give()->logs->logmeta_db->update_meta( $post->ID, $meta_key, $meta_value );
1902
+			if ( ! empty($log_meta)) {
1903
+				foreach ($log_meta as $meta_key => $meta_value) {
1904
+					Give()->logs->logmeta_db->update_meta($post->ID, $meta_key, $meta_value);
1905 1905
 				}
1906 1906
 			}
1907 1907
 
@@ -1943,7 +1943,7 @@  discard block
 block discarded – undo
1943 1943
 		Give()->logs->delete_cache();
1944 1944
 
1945 1945
 		// No more forms found, finish up.
1946
-		give_set_upgrade_complete( 'v20_logs_upgrades' );
1946
+		give_set_upgrade_complete('v20_logs_upgrades');
1947 1947
 	}
1948 1948
 }
1949 1949
 
@@ -1959,19 +1959,19 @@  discard block
 block discarded – undo
1959 1959
 	$give_updates = Give_Updates::get_instance();
1960 1960
 
1961 1961
 	// form query
1962
-	$payments = new WP_Query( array(
1962
+	$payments = new WP_Query(array(
1963 1963
 			'paged'          => $give_updates->step,
1964 1964
 			'status'         => 'any',
1965 1965
 			'order'          => 'ASC',
1966
-			'post_type'      => array( 'give_forms', 'give_payment' ),
1966
+			'post_type'      => array('give_forms', 'give_payment'),
1967 1967
 			'posts_per_page' => 100,
1968 1968
 		)
1969 1969
 	);
1970 1970
 
1971
-	if ( $payments->have_posts() ) {
1972
-		$give_updates->set_percentage( $payments->found_posts, $give_updates->step * 100 );
1971
+	if ($payments->have_posts()) {
1972
+		$give_updates->set_percentage($payments->found_posts, $give_updates->step * 100);
1973 1973
 
1974
-		while ( $payments->have_posts() ) {
1974
+		while ($payments->have_posts()) {
1975 1975
 			$payments->the_post();
1976 1976
 			global $post;
1977 1977
 
@@ -1983,19 +1983,19 @@  discard block
 block discarded – undo
1983 1983
 				ARRAY_A
1984 1984
 			);
1985 1985
 
1986
-			if ( ! empty( $meta_data ) ) {
1987
-				foreach ( $meta_data as $index => $data ) {
1986
+			if ( ! empty($meta_data)) {
1987
+				foreach ($meta_data as $index => $data) {
1988 1988
 					// Check for duplicate meta values.
1989
-					if ( $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . ( 'give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta ) . " WHERE meta_id=%d", $data['meta_id'] ), ARRAY_A ) ) {
1989
+					if ($result = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".('give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta)." WHERE meta_id=%d", $data['meta_id']), ARRAY_A)) {
1990 1990
 						continue;
1991 1991
 					}
1992 1992
 
1993
-					switch ( $post->post_type ) {
1993
+					switch ($post->post_type) {
1994 1994
 						case 'give_forms':
1995 1995
 							$data['form_id'] = $data['post_id'];
1996
-							unset( $data['post_id'] );
1996
+							unset($data['post_id']);
1997 1997
 
1998
-							Give()->form_meta->insert( $data );
1998
+							Give()->form_meta->insert($data);
1999 1999
 							// @todo: delete form meta from post meta table after releases 2.0.
2000 2000
 							/*delete_post_meta( get_the_ID(), $data['meta_key'] );*/
2001 2001
 
@@ -2003,9 +2003,9 @@  discard block
 block discarded – undo
2003 2003
 
2004 2004
 						case 'give_payment':
2005 2005
 							$data['payment_id'] = $data['post_id'];
2006
-							unset( $data['post_id'] );
2006
+							unset($data['post_id']);
2007 2007
 
2008
-							Give()->payment_meta->insert( $data );
2008
+							Give()->payment_meta->insert($data);
2009 2009
 
2010 2010
 							// @todo: delete donation meta from post meta table after releases 2.0.
2011 2011
 							/*delete_post_meta( get_the_ID(), $data['meta_key'] );*/
@@ -2020,7 +2020,7 @@  discard block
 block discarded – undo
2020 2020
 		wp_reset_postdata();
2021 2021
 	} else {
2022 2022
 		// No more forms found, finish up.
2023
-		give_set_upgrade_complete( 'v20_move_metadata_into_new_table' );
2023
+		give_set_upgrade_complete('v20_move_metadata_into_new_table');
2024 2024
 	}
2025 2025
 
2026 2026
 }
@@ -2036,44 +2036,44 @@  discard block
 block discarded – undo
2036 2036
 	/* @var Give_Updates $give_updates */
2037 2037
 	$give_updates = Give_Updates::get_instance();
2038 2038
 
2039
-	$donors = Give()->donors->get_donors( array(
2039
+	$donors = Give()->donors->get_donors(array(
2040 2040
 		'paged'  => $give_updates->step,
2041 2041
 		'number' => 100,
2042
-	) );
2042
+	));
2043 2043
 
2044
-	if ( $donors ) {
2045
-		$give_updates->set_percentage( count( $donors ), $give_updates->step * 100 );
2044
+	if ($donors) {
2045
+		$give_updates->set_percentage(count($donors), $give_updates->step * 100);
2046 2046
 		// Loop through Donors
2047
-		foreach ( $donors as $donor ) {
2047
+		foreach ($donors as $donor) {
2048 2048
 
2049
-			$donor_name       = explode( ' ', $donor->name, 2 );
2050
-			$donor_first_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_first_name' );
2051
-			$donor_last_name  = Give()->donor_meta->get_meta( $donor->id, '_give_donor_last_name' );
2049
+			$donor_name       = explode(' ', $donor->name, 2);
2050
+			$donor_first_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_first_name');
2051
+			$donor_last_name  = Give()->donor_meta->get_meta($donor->id, '_give_donor_last_name');
2052 2052
 
2053 2053
 			// If first name meta of donor is not created, then create it.
2054
-			if ( ! $donor_first_name && isset( $donor_name[0] ) ) {
2055
-				Give()->donor_meta->add_meta( $donor->id, '_give_donor_first_name', $donor_name[0] );
2054
+			if ( ! $donor_first_name && isset($donor_name[0])) {
2055
+				Give()->donor_meta->add_meta($donor->id, '_give_donor_first_name', $donor_name[0]);
2056 2056
 			}
2057 2057
 
2058 2058
 			// If last name meta of donor is not created, then create it.
2059
-			if ( ! $donor_last_name && isset( $donor_name[1] ) ) {
2060
-				Give()->donor_meta->add_meta( $donor->id, '_give_donor_last_name', $donor_name[1] );
2059
+			if ( ! $donor_last_name && isset($donor_name[1])) {
2060
+				Give()->donor_meta->add_meta($donor->id, '_give_donor_last_name', $donor_name[1]);
2061 2061
 			}
2062 2062
 
2063 2063
 			// If Donor is connected with WP User then update user meta.
2064
-			if ( $donor->user_id ) {
2065
-				if ( isset( $donor_name[0] ) ) {
2066
-					update_user_meta( $donor->user_id, 'first_name', $donor_name[0] );
2064
+			if ($donor->user_id) {
2065
+				if (isset($donor_name[0])) {
2066
+					update_user_meta($donor->user_id, 'first_name', $donor_name[0]);
2067 2067
 				}
2068
-				if ( isset( $donor_name[1] ) ) {
2069
-					update_user_meta( $donor->user_id, 'last_name', $donor_name[1] );
2068
+				if (isset($donor_name[1])) {
2069
+					update_user_meta($donor->user_id, 'last_name', $donor_name[1]);
2070 2070
 				}
2071 2071
 			}
2072 2072
 		}
2073 2073
 
2074 2074
 	} else {
2075 2075
 		// The Update Ran.
2076
-		give_set_upgrade_complete( 'v20_upgrades_donor_name' );
2076
+		give_set_upgrade_complete('v20_upgrades_donor_name');
2077 2077
 	}
2078 2078
 
2079 2079
 }
@@ -2102,15 +2102,15 @@  discard block
 block discarded – undo
2102 2102
 
2103 2103
 	$users = $user_query->get_results();
2104 2104
 
2105
-	if ( $users ) {
2106
-		$give_updates->set_percentage( $user_query->get_total(), $give_updates->step * 100 );
2105
+	if ($users) {
2106
+		$give_updates->set_percentage($user_query->get_total(), $give_updates->step * 100);
2107 2107
 
2108 2108
 		// Loop through Donors
2109
-		foreach ( $users as $user ) {
2109
+		foreach ($users as $user) {
2110 2110
 			/* @var Give_Donor $donor */
2111
-			$donor = new Give_Donor( $user->ID, true );
2111
+			$donor = new Give_Donor($user->ID, true);
2112 2112
 
2113
-			if ( ! $donor->id ) {
2113
+			if ( ! $donor->id) {
2114 2114
 				continue;
2115 2115
 			}
2116 2116
 
@@ -2126,10 +2126,10 @@  discard block
 block discarded – undo
2126 2126
 				)
2127 2127
 			);
2128 2128
 
2129
-			if ( ! empty( $address ) ) {
2130
-				$address = maybe_unserialize( $address );
2131
-				$donor->add_address( 'personal', $address );
2132
-				$donor->add_address( 'billing[]', $address );
2129
+			if ( ! empty($address)) {
2130
+				$address = maybe_unserialize($address);
2131
+				$donor->add_address('personal', $address);
2132
+				$donor->add_address('billing[]', $address);
2133 2133
 
2134 2134
 
2135 2135
 				// @todo: delete _give_user_address from user meta after releases 2.0.
@@ -2139,7 +2139,7 @@  discard block
 block discarded – undo
2139 2139
 
2140 2140
 	} else {
2141 2141
 		// The Update Ran.
2142
-		give_set_upgrade_complete( 'v20_upgrades_user_address' );
2142
+		give_set_upgrade_complete('v20_upgrades_user_address');
2143 2143
 	}
2144 2144
 
2145 2145
 }
@@ -2163,15 +2163,15 @@  discard block
 block discarded – undo
2163 2163
 	);
2164 2164
 
2165 2165
 	// Alter customer table
2166
-	foreach ( $tables as $old_table => $new_table ) {
2166
+	foreach ($tables as $old_table => $new_table) {
2167 2167
 		if (
2168
-			$wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", $old_table ) ) &&
2169
-			! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", $new_table ) )
2168
+			$wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", $old_table)) &&
2169
+			! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", $new_table))
2170 2170
 		) {
2171
-			$wpdb->query( "ALTER TABLE {$old_table} RENAME TO {$new_table}" );
2171
+			$wpdb->query("ALTER TABLE {$old_table} RENAME TO {$new_table}");
2172 2172
 
2173
-			if ( "{$wpdb->prefix}give_donormeta" === $new_table ) {
2174
-				$wpdb->query( "ALTER TABLE {$new_table} CHANGE COLUMN customer_id donor_id bigint(20)" );
2173
+			if ("{$wpdb->prefix}give_donormeta" === $new_table) {
2174
+				$wpdb->query("ALTER TABLE {$new_table} CHANGE COLUMN customer_id donor_id bigint(20)");
2175 2175
 			}
2176 2176
 		}
2177 2177
 	}
@@ -2179,7 +2179,7 @@  discard block
 block discarded – undo
2179 2179
 	$give_updates->percentage = 100;
2180 2180
 
2181 2181
 	// No more forms found, finish up.
2182
-	give_set_upgrade_complete( 'v20_rename_donor_tables' );
2182
+	give_set_upgrade_complete('v20_rename_donor_tables');
2183 2183
 
2184 2184
 	// Re initiate donor classes.
2185 2185
 	Give()->donors     = new Give_DB_Donors();
@@ -2197,19 +2197,19 @@  discard block
 block discarded – undo
2197 2197
 function give_v201_create_tables() {
2198 2198
 	global $wpdb;
2199 2199
 
2200
-	if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_paymentmeta" ) ) ) {
2200
+	if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_paymentmeta"))) {
2201 2201
 		Give()->payment_meta->create_table();
2202 2202
 	}
2203 2203
 
2204
-	if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_formmeta" ) ) ) {
2204
+	if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_formmeta"))) {
2205 2205
 		Give()->form_meta->create_table();
2206 2206
 	}
2207 2207
 
2208
-	if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logs" ) ) ) {
2208
+	if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logs"))) {
2209 2209
 		Give()->logs->log_db->create_table();
2210 2210
 	}
2211 2211
 
2212
-	if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logmeta" ) ) ) {
2212
+	if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logmeta"))) {
2213 2213
 		Give()->logs->logmeta_db->create_table();
2214 2214
 	}
2215 2215
 }
@@ -2234,31 +2234,31 @@  discard block
 block discarded – undo
2234 2234
   				$wpdb->posts.post_date >= '2018-01-08 00:00:00'
2235 2235
 			)
2236 2236
 			AND $wpdb->posts.post_type = 'give_payment'
2237
-			AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "')
2237
+			AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."')
2238 2238
 			ORDER BY $wpdb->posts.post_date ASC 
2239 2239
 			LIMIT 100
2240
-			OFFSET " . $give_updates->get_offset( 100 )
2240
+			OFFSET ".$give_updates->get_offset(100)
2241 2241
 	);
2242 2242
 
2243
-	if ( ! empty( $payments ) ) {
2244
-		$give_updates->set_percentage( give_get_total_post_type_count( 'give_payment' ), ( $give_updates->step * 100 ) );
2243
+	if ( ! empty($payments)) {
2244
+		$give_updates->set_percentage(give_get_total_post_type_count('give_payment'), ($give_updates->step * 100));
2245 2245
 
2246
-		foreach ( $payments as $payment_id ) {
2247
-			$post = get_post( $payment_id );
2248
-			setup_postdata( $post );
2246
+		foreach ($payments as $payment_id) {
2247
+			$post = get_post($payment_id);
2248
+			setup_postdata($post);
2249 2249
 
2250 2250
 			// Do not add new meta keys if already refactored.
2251
-			if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, '_give_payment_donor_id' ) ) ) {
2251
+			if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, '_give_payment_donor_id'))) {
2252 2252
 				continue;
2253 2253
 			}
2254 2254
 
2255 2255
 
2256 2256
 			// Split _give_payment_meta meta.
2257 2257
 			// @todo Remove _give_payment_meta after releases 2.0
2258
-			$payment_meta = give_get_meta( $post->ID, '_give_payment_meta', true );
2258
+			$payment_meta = give_get_meta($post->ID, '_give_payment_meta', true);
2259 2259
 
2260
-			if ( ! empty( $payment_meta ) ) {
2261
-				_give_20_bc_split_and_save_give_payment_meta( $post->ID, $payment_meta );
2260
+			if ( ! empty($payment_meta)) {
2261
+				_give_20_bc_split_and_save_give_payment_meta($post->ID, $payment_meta);
2262 2262
 			}
2263 2263
 
2264 2264
 			$deprecated_meta_keys = array(
@@ -2267,9 +2267,9 @@  discard block
 block discarded – undo
2267 2267
 				'_give_payment_user_ip'     => '_give_payment_donor_ip',
2268 2268
 			);
2269 2269
 
2270
-			foreach ( $deprecated_meta_keys as $old_meta_key => $new_meta_key ) {
2270
+			foreach ($deprecated_meta_keys as $old_meta_key => $new_meta_key) {
2271 2271
 				// Do not add new meta key if already exist.
2272
-				if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key ) ) ) {
2272
+				if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key))) {
2273 2273
 					continue;
2274 2274
 				}
2275 2275
 
@@ -2278,25 +2278,25 @@  discard block
 block discarded – undo
2278 2278
 					array(
2279 2279
 						'post_id'    => $post->ID,
2280 2280
 						'meta_key'   => $new_meta_key,
2281
-						'meta_value' => give_get_meta( $post->ID, $old_meta_key, true ),
2281
+						'meta_value' => give_get_meta($post->ID, $old_meta_key, true),
2282 2282
 					)
2283 2283
 				);
2284 2284
 			}
2285 2285
 
2286 2286
 			// Bailout
2287
-			if ( $donor_id = give_get_meta( $post->ID, '_give_payment_donor_id', true ) ) {
2287
+			if ($donor_id = give_get_meta($post->ID, '_give_payment_donor_id', true)) {
2288 2288
 				/* @var Give_Donor $donor */
2289
-				$donor = new Give_Donor( $donor_id );
2289
+				$donor = new Give_Donor($donor_id);
2290 2290
 
2291
-				$address['line1']   = give_get_meta( $post->ID, '_give_donor_billing_address1', true, '' );
2292
-				$address['line2']   = give_get_meta( $post->ID, '_give_donor_billing_address2', true, '' );
2293
-				$address['city']    = give_get_meta( $post->ID, '_give_donor_billing_city', true, '' );
2294
-				$address['state']   = give_get_meta( $post->ID, '_give_donor_billing_state', true, '' );
2295
-				$address['zip']     = give_get_meta( $post->ID, '_give_donor_billing_zip', true, '' );
2296
-				$address['country'] = give_get_meta( $post->ID, '_give_donor_billing_country', true, '' );
2291
+				$address['line1']   = give_get_meta($post->ID, '_give_donor_billing_address1', true, '');
2292
+				$address['line2']   = give_get_meta($post->ID, '_give_donor_billing_address2', true, '');
2293
+				$address['city']    = give_get_meta($post->ID, '_give_donor_billing_city', true, '');
2294
+				$address['state']   = give_get_meta($post->ID, '_give_donor_billing_state', true, '');
2295
+				$address['zip']     = give_get_meta($post->ID, '_give_donor_billing_zip', true, '');
2296
+				$address['country'] = give_get_meta($post->ID, '_give_donor_billing_country', true, '');
2297 2297
 
2298 2298
 				// Save address.
2299
-				$donor->add_address( 'billing[]', $address );
2299
+				$donor->add_address('billing[]', $address);
2300 2300
 			}
2301 2301
 
2302 2302
 		}// End while().
@@ -2307,7 +2307,7 @@  discard block
 block discarded – undo
2307 2307
 		// $wpdb->get_var( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key=%s", '_give_payment_user_id' ) );
2308 2308
 
2309 2309
 		// No more forms found, finish up.
2310
-		give_set_upgrade_complete( 'v201_upgrades_payment_metadata' );
2310
+		give_set_upgrade_complete('v201_upgrades_payment_metadata');
2311 2311
 	}
2312 2312
 }
2313 2313
 
@@ -2327,21 +2327,21 @@  discard block
 block discarded – undo
2327 2327
 			SELECT ID FROM $wpdb->posts 
2328 2328
 			WHERE 1=1
2329 2329
 			AND ( $wpdb->posts.post_type = 'give_payment' OR $wpdb->posts.post_type = 'give_forms' )
2330
-			AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "')
2330
+			AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."')
2331 2331
 			ORDER BY $wpdb->posts.post_date ASC 
2332 2332
 			LIMIT 100
2333
-			OFFSET " . $give_updates->get_offset( 100 )
2333
+			OFFSET ".$give_updates->get_offset(100)
2334 2334
 	);
2335 2335
 
2336
-	if ( ! empty( $payments ) ) {
2337
-		$give_updates->set_percentage( give_get_total_post_type_count( array(
2336
+	if ( ! empty($payments)) {
2337
+		$give_updates->set_percentage(give_get_total_post_type_count(array(
2338 2338
 			'give_forms',
2339 2339
 			'give_payment',
2340
-		) ), $give_updates->step * 100 );
2340
+		)), $give_updates->step * 100);
2341 2341
 
2342
-		foreach ( $payments as $payment_id ) {
2343
-			$post = get_post( $payment_id );
2344
-			setup_postdata( $post );
2342
+		foreach ($payments as $payment_id) {
2343
+			$post = get_post($payment_id);
2344
+			setup_postdata($post);
2345 2345
 
2346 2346
 			$meta_data = $wpdb->get_results(
2347 2347
 				$wpdb->prepare(
@@ -2351,19 +2351,19 @@  discard block
 block discarded – undo
2351 2351
 				ARRAY_A
2352 2352
 			);
2353 2353
 
2354
-			if ( ! empty( $meta_data ) ) {
2355
-				foreach ( $meta_data as $index => $data ) {
2354
+			if ( ! empty($meta_data)) {
2355
+				foreach ($meta_data as $index => $data) {
2356 2356
 					// Check for duplicate meta values.
2357
-					if ( $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . ( 'give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta ) . " WHERE meta_id=%d", $data['meta_id'] ), ARRAY_A ) ) {
2357
+					if ($result = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".('give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta)." WHERE meta_id=%d", $data['meta_id']), ARRAY_A)) {
2358 2358
 						continue;
2359 2359
 					}
2360 2360
 
2361
-					switch ( $post->post_type ) {
2361
+					switch ($post->post_type) {
2362 2362
 						case 'give_forms':
2363 2363
 							$data['form_id'] = $data['post_id'];
2364
-							unset( $data['post_id'] );
2364
+							unset($data['post_id']);
2365 2365
 
2366
-							Give()->form_meta->insert( $data );
2366
+							Give()->form_meta->insert($data);
2367 2367
 							// @todo: delete form meta from post meta table after releases 2.0.
2368 2368
 							/*delete_post_meta( get_the_ID(), $data['meta_key'] );*/
2369 2369
 
@@ -2371,9 +2371,9 @@  discard block
 block discarded – undo
2371 2371
 
2372 2372
 						case 'give_payment':
2373 2373
 							$data['payment_id'] = $data['post_id'];
2374
-							unset( $data['post_id'] );
2374
+							unset($data['post_id']);
2375 2375
 
2376
-							Give()->payment_meta->insert( $data );
2376
+							Give()->payment_meta->insert($data);
2377 2377
 
2378 2378
 							// @todo: delete donation meta from post meta table after releases 2.0.
2379 2379
 							/*delete_post_meta( get_the_ID(), $data['meta_key'] );*/
@@ -2388,7 +2388,7 @@  discard block
 block discarded – undo
2388 2388
 		wp_reset_postdata();
2389 2389
 	} else {
2390 2390
 		// No more forms found, finish up.
2391
-		give_set_upgrade_complete( 'v201_move_metadata_into_new_table' );
2391
+		give_set_upgrade_complete('v201_move_metadata_into_new_table');
2392 2392
 	}
2393 2393
 
2394 2394
 }
@@ -2409,26 +2409,26 @@  discard block
 block discarded – undo
2409 2409
 			SELECT ID FROM $wpdb->posts 
2410 2410
 			WHERE 1=1
2411 2411
 			AND $wpdb->posts.post_type = 'give_log'
2412
-			AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "')
2412
+			AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."')
2413 2413
 			ORDER BY $wpdb->posts.post_date ASC 
2414 2414
 			LIMIT 100
2415
-			OFFSET " . $give_updates->get_offset( 100 )
2415
+			OFFSET ".$give_updates->get_offset(100)
2416 2416
 	);
2417 2417
 
2418
-	if ( ! empty( $logs ) ) {
2419
-		$give_updates->set_percentage( give_get_total_post_type_count( 'give_log' ), $give_updates->step * 100 );
2418
+	if ( ! empty($logs)) {
2419
+		$give_updates->set_percentage(give_get_total_post_type_count('give_log'), $give_updates->step * 100);
2420 2420
 
2421
-		foreach ( $logs as $log_id ) {
2422
-			$post = get_post( $log_id );
2423
-			setup_postdata( $post );
2421
+		foreach ($logs as $log_id) {
2422
+			$post = get_post($log_id);
2423
+			setup_postdata($post);
2424 2424
 
2425
-			if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID ) ) ) {
2425
+			if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID))) {
2426 2426
 				continue;
2427 2427
 			}
2428 2428
 
2429
-			$term      = get_the_terms( $post->ID, 'give_log_type' );
2430
-			$term      = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array();
2431
-			$term_name = ! empty( $term ) ? $term->slug : '';
2429
+			$term      = get_the_terms($post->ID, 'give_log_type');
2430
+			$term      = ! is_wp_error($term) && ! empty($term) ? $term[0] : array();
2431
+			$term_name = ! empty($term) ? $term->slug : '';
2432 2432
 
2433 2433
 			$log_data = array(
2434 2434
 				'ID'           => $post->ID,
@@ -2441,29 +2441,29 @@  discard block
 block discarded – undo
2441 2441
 			);
2442 2442
 			$log_meta = array();
2443 2443
 
2444
-			if ( $old_log_meta = get_post_meta( $post->ID ) ) {
2445
-				foreach ( $old_log_meta as $meta_key => $meta_value ) {
2446
-					switch ( $meta_key ) {
2444
+			if ($old_log_meta = get_post_meta($post->ID)) {
2445
+				foreach ($old_log_meta as $meta_key => $meta_value) {
2446
+					switch ($meta_key) {
2447 2447
 						case '_give_log_payment_id':
2448
-							$log_data['log_parent']        = current( $meta_value );
2448
+							$log_data['log_parent']        = current($meta_value);
2449 2449
 							$log_meta['_give_log_form_id'] = $post->post_parent;
2450 2450
 							break;
2451 2451
 
2452 2452
 						default:
2453
-							$log_meta[ $meta_key ] = current( $meta_value );
2453
+							$log_meta[$meta_key] = current($meta_value);
2454 2454
 					}
2455 2455
 				}
2456 2456
 			}
2457 2457
 
2458
-			if ( 'api_request' === $term_name ) {
2458
+			if ('api_request' === $term_name) {
2459 2459
 				$log_meta['_give_log_api_query'] = $post->post_excerpt;
2460 2460
 			}
2461 2461
 
2462
-			$wpdb->insert( "{$wpdb->prefix}give_logs", $log_data );
2462
+			$wpdb->insert("{$wpdb->prefix}give_logs", $log_data);
2463 2463
 
2464
-			if ( ! empty( $log_meta ) ) {
2465
-				foreach ( $log_meta as $meta_key => $meta_value ) {
2466
-					Give()->logs->logmeta_db->update_meta( $post->ID, $meta_key, $meta_value );
2464
+			if ( ! empty($log_meta)) {
2465
+				foreach ($log_meta as $meta_key => $meta_value) {
2466
+					Give()->logs->logmeta_db->update_meta($post->ID, $meta_key, $meta_value);
2467 2467
 				}
2468 2468
 			}
2469 2469
 
@@ -2476,7 +2476,7 @@  discard block
 block discarded – undo
2476 2476
 		Give()->logs->delete_cache();
2477 2477
 
2478 2478
 		// No more forms found, finish up.
2479
-		give_set_upgrade_complete( 'v201_logs_upgrades' );
2479
+		give_set_upgrade_complete('v201_logs_upgrades');
2480 2480
 	}
2481 2481
 }
2482 2482
 
@@ -2491,51 +2491,51 @@  discard block
 block discarded – undo
2491 2491
 	global $wpdb;
2492 2492
 	give_v201_create_tables();
2493 2493
 
2494
-	if ( $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers" ) ) ) {
2495
-		$customers  = wp_list_pluck( $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}give_customers" ), 'id' );
2496
-		$donors     = wp_list_pluck( $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}give_donors" ), 'id' );
2494
+	if ($wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers"))) {
2495
+		$customers  = wp_list_pluck($wpdb->get_results("SELECT id FROM {$wpdb->prefix}give_customers"), 'id');
2496
+		$donors     = wp_list_pluck($wpdb->get_results("SELECT id FROM {$wpdb->prefix}give_donors"), 'id');
2497 2497
 		$donor_data = array();
2498 2498
 
2499
-		if ( $missing_donors = array_diff( $customers, $donors ) ) {
2500
-			foreach ( $missing_donors as $donor_id ) {
2499
+		if ($missing_donors = array_diff($customers, $donors)) {
2500
+			foreach ($missing_donors as $donor_id) {
2501 2501
 				$donor_data[] = array(
2502
-					'info' => $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_customers WHERE id=%d", $donor_id ) ),
2503
-					'meta' => $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_customermeta WHERE customer_id=%d", $donor_id ) ),
2502
+					'info' => $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_customers WHERE id=%d", $donor_id)),
2503
+					'meta' => $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_customermeta WHERE customer_id=%d", $donor_id)),
2504 2504
 
2505 2505
 				);
2506 2506
 			}
2507 2507
 		}
2508 2508
 
2509
-		if ( ! empty( $donor_data ) ) {
2509
+		if ( ! empty($donor_data)) {
2510 2510
 			$donor_table_name      = Give()->donors->table_name;
2511 2511
 			$donor_meta_table_name = Give()->donor_meta->table_name;
2512 2512
 
2513 2513
 			Give()->donors->table_name     = "{$wpdb->prefix}give_donors";
2514 2514
 			Give()->donor_meta->table_name = "{$wpdb->prefix}give_donormeta";
2515 2515
 
2516
-			foreach ( $donor_data as $donor ) {
2516
+			foreach ($donor_data as $donor) {
2517 2517
 				$donor['info'][0] = (array) $donor['info'][0];
2518 2518
 
2519 2519
 				// Prevent duplicate meta id issue.
2520
-				if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_donors WHERE id=%d", $donor['info'][0]['id'] ) ) ) {
2520
+				if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_donors WHERE id=%d", $donor['info'][0]['id']))) {
2521 2521
 					continue;
2522 2522
 				}
2523 2523
 
2524
-				$donor_id = Give()->donors->add( $donor['info'][0] );
2524
+				$donor_id = Give()->donors->add($donor['info'][0]);
2525 2525
 
2526
-				if ( ! empty( $donor['meta'] ) ) {
2527
-					foreach ( $donor['meta'] as $donor_meta ) {
2526
+				if ( ! empty($donor['meta'])) {
2527
+					foreach ($donor['meta'] as $donor_meta) {
2528 2528
 						$donor_meta = (array) $donor_meta;
2529 2529
 
2530 2530
 						// Prevent duplicate meta id issue.
2531
-						if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_donormeta WHERE meta_id=%d", $donor_meta['meta_id'] ) ) ) {
2532
-							unset( $donor_meta['meta_id'] );
2531
+						if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_donormeta WHERE meta_id=%d", $donor_meta['meta_id']))) {
2532
+							unset($donor_meta['meta_id']);
2533 2533
 						}
2534 2534
 
2535 2535
 						$donor_meta['donor_id'] = $donor_meta['customer_id'];
2536
-						unset( $donor_meta['customer_id'] );
2536
+						unset($donor_meta['customer_id']);
2537 2537
 
2538
-						Give()->donor_meta->insert( $donor_meta );
2538
+						Give()->donor_meta->insert($donor_meta);
2539 2539
 					}
2540 2540
 				}
2541 2541
 
@@ -2554,35 +2554,35 @@  discard block
 block discarded – undo
2554 2554
 					)
2555 2555
 				);
2556 2556
 
2557
-				$donor = new Give_Donor( $donor_id );
2557
+				$donor = new Give_Donor($donor_id);
2558 2558
 
2559
-				if ( ! empty( $address ) ) {
2560
-					$address = maybe_unserialize( $address );
2561
-					$donor->add_address( 'personal', $address );
2562
-					$donor->add_address( 'billing[]', $address );
2559
+				if ( ! empty($address)) {
2560
+					$address = maybe_unserialize($address);
2561
+					$donor->add_address('personal', $address);
2562
+					$donor->add_address('billing[]', $address);
2563 2563
 				}
2564 2564
 
2565
-				$donor_name       = explode( ' ', $donor->name, 2 );
2566
-				$donor_first_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_first_name' );
2567
-				$donor_last_name  = Give()->donor_meta->get_meta( $donor->id, '_give_donor_last_name' );
2565
+				$donor_name       = explode(' ', $donor->name, 2);
2566
+				$donor_first_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_first_name');
2567
+				$donor_last_name  = Give()->donor_meta->get_meta($donor->id, '_give_donor_last_name');
2568 2568
 
2569 2569
 				// If first name meta of donor is not created, then create it.
2570
-				if ( ! $donor_first_name && isset( $donor_name[0] ) ) {
2571
-					Give()->donor_meta->add_meta( $donor->id, '_give_donor_first_name', $donor_name[0] );
2570
+				if ( ! $donor_first_name && isset($donor_name[0])) {
2571
+					Give()->donor_meta->add_meta($donor->id, '_give_donor_first_name', $donor_name[0]);
2572 2572
 				}
2573 2573
 
2574 2574
 				// If last name meta of donor is not created, then create it.
2575
-				if ( ! $donor_last_name && isset( $donor_name[1] ) ) {
2576
-					Give()->donor_meta->add_meta( $donor->id, '_give_donor_last_name', $donor_name[1] );
2575
+				if ( ! $donor_last_name && isset($donor_name[1])) {
2576
+					Give()->donor_meta->add_meta($donor->id, '_give_donor_last_name', $donor_name[1]);
2577 2577
 				}
2578 2578
 
2579 2579
 				// If Donor is connected with WP User then update user meta.
2580
-				if ( $donor->user_id ) {
2581
-					if ( isset( $donor_name[0] ) ) {
2582
-						update_user_meta( $donor->user_id, 'first_name', $donor_name[0] );
2580
+				if ($donor->user_id) {
2581
+					if (isset($donor_name[0])) {
2582
+						update_user_meta($donor->user_id, 'first_name', $donor_name[0]);
2583 2583
 					}
2584
-					if ( isset( $donor_name[1] ) ) {
2585
-						update_user_meta( $donor->user_id, 'last_name', $donor_name[1] );
2584
+					if (isset($donor_name[1])) {
2585
+						update_user_meta($donor->user_id, 'last_name', $donor_name[1]);
2586 2586
 					}
2587 2587
 				}
2588 2588
 			}
@@ -2593,7 +2593,7 @@  discard block
 block discarded – undo
2593 2593
 	}
2594 2594
 
2595 2595
 	Give_Updates::get_instance()->percentage = 100;
2596
-	give_set_upgrade_complete( 'v201_add_missing_donors' );
2596
+	give_set_upgrade_complete('v201_add_missing_donors');
2597 2597
 }
2598 2598
 
2599 2599
 
@@ -2606,14 +2606,14 @@  discard block
 block discarded – undo
2606 2606
 	global $wpdb;
2607 2607
 
2608 2608
 	// Do not auto load option.
2609
-	$wpdb->update( $wpdb->options, array( 'autoload' => 'no' ), array( 'option_name' => 'give_completed_upgrades' ) );
2609
+	$wpdb->update($wpdb->options, array('autoload' => 'no'), array('option_name' => 'give_completed_upgrades'));
2610 2610
 
2611 2611
 	// Remove from cache.
2612 2612
 	$all_options = wp_load_alloptions();
2613 2613
 
2614
-	if ( isset( $all_options['give_completed_upgrades'] ) ) {
2615
-		unset( $all_options['give_completed_upgrades'] );
2616
-		wp_cache_set( 'alloptions', $all_options, 'options' );
2614
+	if (isset($all_options['give_completed_upgrades'])) {
2615
+		unset($all_options['give_completed_upgrades']);
2616
+		wp_cache_set('alloptions', $all_options, 'options');
2617 2617
 	}
2618 2618
 
2619 2619
 }
@@ -2628,7 +2628,7 @@  discard block
 block discarded – undo
2628 2628
 	$give_updates = Give_Updates::get_instance();
2629 2629
 
2630 2630
 	// form query.
2631
-	$donation_forms = new WP_Query( array(
2631
+	$donation_forms = new WP_Query(array(
2632 2632
 			'paged'          => $give_updates->step,
2633 2633
 			'status'         => 'any',
2634 2634
 			'order'          => 'ASC',
@@ -2637,16 +2637,16 @@  discard block
 block discarded – undo
2637 2637
 		)
2638 2638
 	);
2639 2639
 
2640
-	if ( $donation_forms->have_posts() ) {
2641
-		$give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) );
2640
+	if ($donation_forms->have_posts()) {
2641
+		$give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20));
2642 2642
 
2643
-		while ( $donation_forms->have_posts() ) {
2643
+		while ($donation_forms->have_posts()) {
2644 2644
 			$donation_forms->the_post();
2645 2645
 			$form_id = get_the_ID();
2646 2646
 
2647
-			$form_closed_status = give_get_meta( $form_id, '_give_form_status', true );
2648
-			if ( empty( $form_closed_status ) ) {
2649
-				give_set_form_closed_status( $form_id );
2647
+			$form_closed_status = give_get_meta($form_id, '_give_form_status', true);
2648
+			if (empty($form_closed_status)) {
2649
+				give_set_form_closed_status($form_id);
2650 2650
 			}
2651 2651
 		}
2652 2652
 
@@ -2656,7 +2656,7 @@  discard block
 block discarded – undo
2656 2656
 	} else {
2657 2657
 
2658 2658
 		// The Update Ran.
2659
-		give_set_upgrade_complete( 'v210_verify_form_status_upgrades' );
2659
+		give_set_upgrade_complete('v210_verify_form_status_upgrades');
2660 2660
 	}
2661 2661
 
2662 2662
 }
2663 2663
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/admin-footer.php 1 patch
Spacing   +6 added lines, -6 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
 
@@ -24,14 +24,14 @@  discard block
 block discarded – undo
24 24
  *
25 25
  * @return      string
26 26
  */
27
-function give_admin_rate_us( $footer_text ) {
27
+function give_admin_rate_us($footer_text) {
28 28
 	global $typenow;
29 29
 
30
-	if ( 'give_forms' === $typenow ) {
30
+	if ('give_forms' === $typenow) {
31 31
 		$rate_text = sprintf(
32 32
 			/* translators: %s: Link to 5 star rating */
33
-			__( 'If you like <strong>Give</strong> please leave us a %s rating. It takes a minute and helps a lot. Thanks in advance!', 'give' ),
34
-			'<a href="https://wordpress.org/support/view/plugin-reviews/give?filter=5#postform" target="_blank" class="give-rating-link" style="text-decoration:none;" data-rated="' . esc_attr__( 'Thanks :)', 'give' ) . '">&#9733;&#9733;&#9733;&#9733;&#9733;</a>'
33
+			__('If you like <strong>Give</strong> please leave us a %s rating. It takes a minute and helps a lot. Thanks in advance!', 'give'),
34
+			'<a href="https://wordpress.org/support/view/plugin-reviews/give?filter=5#postform" target="_blank" class="give-rating-link" style="text-decoration:none;" data-rated="'.esc_attr__('Thanks :)', 'give').'">&#9733;&#9733;&#9733;&#9733;&#9733;</a>'
35 35
 		);
36 36
 
37 37
 		return $rate_text;
@@ -40,4 +40,4 @@  discard block
 block discarded – undo
40 40
 	}
41 41
 }
42 42
 
43
-add_filter( 'admin_footer_text', 'give_admin_rate_us' );
43
+add_filter('admin_footer_text', 'give_admin_rate_us');
Please login to merge, or discard this patch.