Passed
Push — master ( 330418...c4952f )
by Brian
05:45 queued 27s
created
ayecode/wp-ayecode-ui/includes/components/class-aui-component-input.php 3 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -209,7 +209,7 @@
 block discarded – undo
209 209
 						$help_text = '';
210 210
 						//$label_args['class'] .= ' d-inline ';
211 211
 						$args['wrap_class'] .= ' align-items-center ';
212
-					}else{
212
+					} else{
213 213
 
214 214
 					}
215 215
 
Please login to merge, or discard this patch.
Indentation   +1186 added lines, -1186 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit; // Exit if accessed directly
4
+    exit; // Exit if accessed directly
5 5
 }
6 6
 
7 7
 /**
@@ -11,1210 +11,1210 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class AUI_Component_Input {
13 13
 
14
-	/**
15
-	 * Build the component.
16
-	 *
17
-	 * @param array $args
18
-	 *
19
-	 * @return string The rendered component.
20
-	 */
21
-	public static function input( $args = array() ) {
22
-		$defaults = array(
23
-			'type'                     => 'text',
24
-			'name'                     => '',
25
-			'class'                    => '',
26
-			'wrap_class'               => '',
27
-			'id'                       => '',
28
-			'placeholder'              => '',
29
-			'title'                    => '',
30
-			'value'                    => '',
31
-			'required'                 => false,
32
-			'label'                    => '',
33
-			'label_after'              => false,
34
-			'label_class'              => '',
35
-			'label_col'                => '2',
36
-			'label_type'               => '',
37
-			'label_force_left'         => false, // used to force checkbox label left when using horizontal
38
-			// sets the label type, default: hidden. Options: hidden, top, horizontal, floating
39
-			'help_text'                => '',
40
-			'validation_text'          => '',
41
-			'validation_pattern'       => '',
42
-			'no_wrap'                  => false,
43
-			'input_group_right'        => '',
44
-			'input_group_left'         => '',
45
-			'input_group_right_inside' => false,
46
-			// forces the input group inside the input
47
-			'input_group_left_inside'  => false,
48
-			// forces the input group inside the input
49
-			'step'                     => '',
50
-			'switch'                   => false,
51
-			// to show checkbox as a switch
52
-			'checked'                  => false,
53
-			// set a checkbox or radio as selected
54
-			'password_toggle'          => true,
55
-			// toggle view/hide password
56
-			'element_require'          => '',
57
-			// [%element_id%] == "1"
58
-			'extra_attributes'         => array(),
59
-			// an array of extra attributes
60
-			'wrap_attributes'          => array()
61
-		);
62
-
63
-		/**
64
-		 * Parse incoming $args into an array and merge it with $defaults
65
-		 */
66
-		$args   = wp_parse_args( $args, $defaults );
67
-		$output = '';
68
-		if ( ! empty( $args['type'] ) ) {
69
-			// hidden label option needs to be empty
70
-			$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
71
-
72
-			$type = sanitize_html_class( $args['type'] );
73
-
74
-			$help_text   = '';
75
-			$label       = '';
76
-			$label_after = $args['label_after'];
77
-			$label_args  = array(
78
-				'title'      => $args['label'],
79
-				'for'        => $args['id'],
80
-				'class'      => $args['label_class'] . " ",
81
-				'label_type' => $args['label_type'],
82
-				'label_col'  => $args['label_col']
83
-			);
84
-
85
-			// floating labels need label after
86
-			if ( $args['label_type'] == 'floating' && $type != 'checkbox' ) {
87
-				$label_after         = true;
88
-				$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
89
-			}
90
-
91
-			// Some special sauce for files
92
-			if ( $type == 'file' ) {
93
-				$label_after = true; // if type file we need the label after
94
-				$args['class'] .= ' custom-file-input ';
95
-			} elseif ( $type == 'checkbox' ) {
96
-				$label_after = true; // if type file we need the label after
97
-				$args['class'] .= ' custom-control-input ';
98
-			} elseif ( $type == 'datepicker' || $type == 'timepicker' ) {
99
-				$type = 'text';
100
-				//$args['class'] .= ' aui-flatpickr bg-initial ';
101
-				$args['class'] .= ' bg-initial ';
102
-
103
-				$args['extra_attributes']['data-aui-init'] = 'flatpickr';
104
-				// enqueue the script
105
-				$aui_settings = AyeCode_UI_Settings::instance();
106
-				$aui_settings->enqueue_flatpickr();
107
-			} elseif ( $type == 'iconpicker' ) {
108
-				$type = 'text';
109
-				//$args['class'] .= ' aui-flatpickr bg-initial ';
14
+    /**
15
+     * Build the component.
16
+     *
17
+     * @param array $args
18
+     *
19
+     * @return string The rendered component.
20
+     */
21
+    public static function input( $args = array() ) {
22
+        $defaults = array(
23
+            'type'                     => 'text',
24
+            'name'                     => '',
25
+            'class'                    => '',
26
+            'wrap_class'               => '',
27
+            'id'                       => '',
28
+            'placeholder'              => '',
29
+            'title'                    => '',
30
+            'value'                    => '',
31
+            'required'                 => false,
32
+            'label'                    => '',
33
+            'label_after'              => false,
34
+            'label_class'              => '',
35
+            'label_col'                => '2',
36
+            'label_type'               => '',
37
+            'label_force_left'         => false, // used to force checkbox label left when using horizontal
38
+            // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
39
+            'help_text'                => '',
40
+            'validation_text'          => '',
41
+            'validation_pattern'       => '',
42
+            'no_wrap'                  => false,
43
+            'input_group_right'        => '',
44
+            'input_group_left'         => '',
45
+            'input_group_right_inside' => false,
46
+            // forces the input group inside the input
47
+            'input_group_left_inside'  => false,
48
+            // forces the input group inside the input
49
+            'step'                     => '',
50
+            'switch'                   => false,
51
+            // to show checkbox as a switch
52
+            'checked'                  => false,
53
+            // set a checkbox or radio as selected
54
+            'password_toggle'          => true,
55
+            // toggle view/hide password
56
+            'element_require'          => '',
57
+            // [%element_id%] == "1"
58
+            'extra_attributes'         => array(),
59
+            // an array of extra attributes
60
+            'wrap_attributes'          => array()
61
+        );
62
+
63
+        /**
64
+         * Parse incoming $args into an array and merge it with $defaults
65
+         */
66
+        $args   = wp_parse_args( $args, $defaults );
67
+        $output = '';
68
+        if ( ! empty( $args['type'] ) ) {
69
+            // hidden label option needs to be empty
70
+            $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
71
+
72
+            $type = sanitize_html_class( $args['type'] );
73
+
74
+            $help_text   = '';
75
+            $label       = '';
76
+            $label_after = $args['label_after'];
77
+            $label_args  = array(
78
+                'title'      => $args['label'],
79
+                'for'        => $args['id'],
80
+                'class'      => $args['label_class'] . " ",
81
+                'label_type' => $args['label_type'],
82
+                'label_col'  => $args['label_col']
83
+            );
84
+
85
+            // floating labels need label after
86
+            if ( $args['label_type'] == 'floating' && $type != 'checkbox' ) {
87
+                $label_after         = true;
88
+                $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
89
+            }
90
+
91
+            // Some special sauce for files
92
+            if ( $type == 'file' ) {
93
+                $label_after = true; // if type file we need the label after
94
+                $args['class'] .= ' custom-file-input ';
95
+            } elseif ( $type == 'checkbox' ) {
96
+                $label_after = true; // if type file we need the label after
97
+                $args['class'] .= ' custom-control-input ';
98
+            } elseif ( $type == 'datepicker' || $type == 'timepicker' ) {
99
+                $type = 'text';
100
+                //$args['class'] .= ' aui-flatpickr bg-initial ';
101
+                $args['class'] .= ' bg-initial ';
102
+
103
+                $args['extra_attributes']['data-aui-init'] = 'flatpickr';
104
+                // enqueue the script
105
+                $aui_settings = AyeCode_UI_Settings::instance();
106
+                $aui_settings->enqueue_flatpickr();
107
+            } elseif ( $type == 'iconpicker' ) {
108
+                $type = 'text';
109
+                //$args['class'] .= ' aui-flatpickr bg-initial ';
110 110
 //				$args['class'] .= ' bg-initial ';
111 111
 
112
-				$args['extra_attributes']['data-aui-init'] = 'iconpicker';
113
-				$args['extra_attributes']['data-placement'] = 'bottomRight';
112
+                $args['extra_attributes']['data-aui-init'] = 'iconpicker';
113
+                $args['extra_attributes']['data-placement'] = 'bottomRight';
114 114
 
115
-				$args['input_group_right'] = '<span class="input-group-addon input-group-text c-pointer"></span>';
115
+                $args['input_group_right'] = '<span class="input-group-addon input-group-text c-pointer"></span>';
116 116
 //				$args['input_group_right_inside'] = true;
117
-				// enqueue the script
118
-				$aui_settings = AyeCode_UI_Settings::instance();
119
-				$aui_settings->enqueue_iconpicker();
120
-			}
121
-
122
-			if ( $type == 'checkbox' && !empty($args['name'] ) && strpos($args['name'], '[') === false ) {
123
-				$output .= '<input type="hidden" name="' . esc_attr( $args['name'] ) . '" value="0" />';
124
-			}
125
-
126
-
127
-			// open/type
128
-			$output .= '<input type="' . $type . '" ';
129
-
130
-			// name
131
-			if ( ! empty( $args['name'] ) ) {
132
-				$output .= ' name="' . esc_attr( $args['name'] ) . '" ';
133
-			}
134
-
135
-			// id
136
-			if ( ! empty( $args['id'] ) ) {
137
-				$output .= ' id="' . sanitize_html_class( $args['id'] ) . '" ';
138
-			}
139
-
140
-			// placeholder
141
-			if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) {
142
-				$output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" ';
143
-			}
144
-
145
-			// title
146
-			if ( ! empty( $args['title'] ) ) {
147
-				$output .= ' title="' . esc_attr( $args['title'] ) . '" ';
148
-			}
149
-
150
-			// value
151
-			if ( ! empty( $args['value'] ) ) {
152
-				$output .= AUI_Component_Helper::value( $args['value'] );
153
-			}
154
-
155
-			// checked, for radio and checkboxes
156
-			if ( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ) {
157
-				$output .= ' checked ';
158
-			}
159
-
160
-			// validation text
161
-			if ( ! empty( $args['validation_text'] ) ) {
162
-				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" ';
163
-				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
164
-			}
165
-
166
-			// validation_pattern
167
-			if ( ! empty( $args['validation_pattern'] ) ) {
168
-				$output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
169
-			}
170
-
171
-			// step (for numbers)
172
-			if ( ! empty( $args['step'] ) ) {
173
-				$output .= ' step="' . $args['step'] . '" ';
174
-			}
175
-
176
-			// required
177
-			if ( ! empty( $args['required'] ) ) {
178
-				$output .= ' required ';
179
-			}
180
-
181
-			// class
182
-			$class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
183
-			$output .= ' class="form-control ' . $class . '" ';
184
-
185
-			// data-attributes
186
-			$output .= AUI_Component_Helper::data_attributes( $args );
187
-
188
-			// extra attributes
189
-			if ( ! empty( $args['extra_attributes'] ) ) {
190
-				$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
191
-			}
192
-
193
-			// close
194
-			$output .= ' >';
195
-
196
-			// help text
197
-			if ( ! empty( $args['help_text'] ) ) {
198
-				$help_text = AUI_Component_Helper::help_text( $args['help_text'] );
199
-			}
200
-
201
-			// label
202
-			if ( ! empty( $args['label'] ) ) {
203
-				$label_base_class = '';
204
-				if ( $type == 'file' ) {
205
-					$label_base_class = ' custom-file-label';
206
-				} elseif ( $type == 'checkbox' ) {
207
-					if ( ! empty( $args['label_force_left'] ) ) {
208
-						$label_args['title'] = wp_kses_post( $args['help_text'] );
209
-						$help_text = '';
210
-						//$label_args['class'] .= ' d-inline ';
211
-						$args['wrap_class'] .= ' align-items-center ';
212
-					}else{
213
-
214
-					}
215
-
216
-					$label_base_class = ' custom-control-label';
217
-				}
218
-				$label_args['class'] .= $label_base_class;
219
-				$temp_label_args = $label_args;
220
-				if(! empty( $args['label_force_left'] )){$temp_label_args['class'] = $label_base_class." text-muted";}
221
-				$label = self::label( $temp_label_args, $type );
222
-			}
223
-
224
-
225
-
226
-
227
-			// set help text in the correct position
228
-			if ( $label_after ) {
229
-				$output .= $label . $help_text;
230
-			}
231
-
232
-			// some input types need a separate wrap
233
-			if ( $type == 'file' ) {
234
-				$output = self::wrap( array(
235
-					'content' => $output,
236
-					'class'   => 'form-group custom-file'
237
-				) );
238
-			} elseif ( $type == 'checkbox' ) {
239
-
240
-				$label_args['title'] = $args['label'];
241
-				$label_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'label' );
242
-				$label = !empty( $args['label_force_left'] ) ? self::label( $label_args, 'cb' ) : '<div class="' . $label_col . ' col-form-label"></div>';
243
-				$switch_size_class = $args['switch'] && !is_bool( $args['switch'] ) ? ' custom-switch-'.esc_attr( $args['switch'] ) : '';
244
-				$wrap_class = $args['switch'] ? 'custom-switch'.$switch_size_class : 'custom-checkbox';
245
-				if ( ! empty( $args['label_force_left'] ) ) {
246
-					$wrap_class .= ' d-flex align-content-center';
247
-					$label = str_replace("custom-control-label","", self::label( $label_args, 'cb' ) );
248
-				}
249
-				$output     = self::wrap( array(
250
-					'content' => $output,
251
-					'class'   => 'custom-control ' . $wrap_class
252
-				) );
253
-
254
-				if ( $args['label_type'] == 'horizontal' ) {
255
-					$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
256
-					$output    = $label . '<div class="' . $input_col . '">' . $output . '</div>';
257
-				}
258
-			} elseif ( $type == 'password' && $args['password_toggle'] && ! $args['input_group_right'] ) {
259
-
260
-
261
-				// allow password field to toggle view
262
-				$args['input_group_right'] = '<span class="input-group-text c-pointer px-3" 
117
+                // enqueue the script
118
+                $aui_settings = AyeCode_UI_Settings::instance();
119
+                $aui_settings->enqueue_iconpicker();
120
+            }
121
+
122
+            if ( $type == 'checkbox' && !empty($args['name'] ) && strpos($args['name'], '[') === false ) {
123
+                $output .= '<input type="hidden" name="' . esc_attr( $args['name'] ) . '" value="0" />';
124
+            }
125
+
126
+
127
+            // open/type
128
+            $output .= '<input type="' . $type . '" ';
129
+
130
+            // name
131
+            if ( ! empty( $args['name'] ) ) {
132
+                $output .= ' name="' . esc_attr( $args['name'] ) . '" ';
133
+            }
134
+
135
+            // id
136
+            if ( ! empty( $args['id'] ) ) {
137
+                $output .= ' id="' . sanitize_html_class( $args['id'] ) . '" ';
138
+            }
139
+
140
+            // placeholder
141
+            if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) {
142
+                $output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" ';
143
+            }
144
+
145
+            // title
146
+            if ( ! empty( $args['title'] ) ) {
147
+                $output .= ' title="' . esc_attr( $args['title'] ) . '" ';
148
+            }
149
+
150
+            // value
151
+            if ( ! empty( $args['value'] ) ) {
152
+                $output .= AUI_Component_Helper::value( $args['value'] );
153
+            }
154
+
155
+            // checked, for radio and checkboxes
156
+            if ( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ) {
157
+                $output .= ' checked ';
158
+            }
159
+
160
+            // validation text
161
+            if ( ! empty( $args['validation_text'] ) ) {
162
+                $output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" ';
163
+                $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
164
+            }
165
+
166
+            // validation_pattern
167
+            if ( ! empty( $args['validation_pattern'] ) ) {
168
+                $output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
169
+            }
170
+
171
+            // step (for numbers)
172
+            if ( ! empty( $args['step'] ) ) {
173
+                $output .= ' step="' . $args['step'] . '" ';
174
+            }
175
+
176
+            // required
177
+            if ( ! empty( $args['required'] ) ) {
178
+                $output .= ' required ';
179
+            }
180
+
181
+            // class
182
+            $class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
183
+            $output .= ' class="form-control ' . $class . '" ';
184
+
185
+            // data-attributes
186
+            $output .= AUI_Component_Helper::data_attributes( $args );
187
+
188
+            // extra attributes
189
+            if ( ! empty( $args['extra_attributes'] ) ) {
190
+                $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
191
+            }
192
+
193
+            // close
194
+            $output .= ' >';
195
+
196
+            // help text
197
+            if ( ! empty( $args['help_text'] ) ) {
198
+                $help_text = AUI_Component_Helper::help_text( $args['help_text'] );
199
+            }
200
+
201
+            // label
202
+            if ( ! empty( $args['label'] ) ) {
203
+                $label_base_class = '';
204
+                if ( $type == 'file' ) {
205
+                    $label_base_class = ' custom-file-label';
206
+                } elseif ( $type == 'checkbox' ) {
207
+                    if ( ! empty( $args['label_force_left'] ) ) {
208
+                        $label_args['title'] = wp_kses_post( $args['help_text'] );
209
+                        $help_text = '';
210
+                        //$label_args['class'] .= ' d-inline ';
211
+                        $args['wrap_class'] .= ' align-items-center ';
212
+                    }else{
213
+
214
+                    }
215
+
216
+                    $label_base_class = ' custom-control-label';
217
+                }
218
+                $label_args['class'] .= $label_base_class;
219
+                $temp_label_args = $label_args;
220
+                if(! empty( $args['label_force_left'] )){$temp_label_args['class'] = $label_base_class." text-muted";}
221
+                $label = self::label( $temp_label_args, $type );
222
+            }
223
+
224
+
225
+
226
+
227
+            // set help text in the correct position
228
+            if ( $label_after ) {
229
+                $output .= $label . $help_text;
230
+            }
231
+
232
+            // some input types need a separate wrap
233
+            if ( $type == 'file' ) {
234
+                $output = self::wrap( array(
235
+                    'content' => $output,
236
+                    'class'   => 'form-group custom-file'
237
+                ) );
238
+            } elseif ( $type == 'checkbox' ) {
239
+
240
+                $label_args['title'] = $args['label'];
241
+                $label_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'label' );
242
+                $label = !empty( $args['label_force_left'] ) ? self::label( $label_args, 'cb' ) : '<div class="' . $label_col . ' col-form-label"></div>';
243
+                $switch_size_class = $args['switch'] && !is_bool( $args['switch'] ) ? ' custom-switch-'.esc_attr( $args['switch'] ) : '';
244
+                $wrap_class = $args['switch'] ? 'custom-switch'.$switch_size_class : 'custom-checkbox';
245
+                if ( ! empty( $args['label_force_left'] ) ) {
246
+                    $wrap_class .= ' d-flex align-content-center';
247
+                    $label = str_replace("custom-control-label","", self::label( $label_args, 'cb' ) );
248
+                }
249
+                $output     = self::wrap( array(
250
+                    'content' => $output,
251
+                    'class'   => 'custom-control ' . $wrap_class
252
+                ) );
253
+
254
+                if ( $args['label_type'] == 'horizontal' ) {
255
+                    $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
256
+                    $output    = $label . '<div class="' . $input_col . '">' . $output . '</div>';
257
+                }
258
+            } elseif ( $type == 'password' && $args['password_toggle'] && ! $args['input_group_right'] ) {
259
+
260
+
261
+                // allow password field to toggle view
262
+                $args['input_group_right'] = '<span class="input-group-text c-pointer px-3" 
263 263
 onclick="var $el = jQuery(this).find(\'i\');$el.toggleClass(\'fa-eye fa-eye-slash\');
264 264
 var $eli = jQuery(this).parent().parent().find(\'input\');
265 265
 if($el.hasClass(\'fa-eye\'))
266 266
 {$eli.attr(\'type\',\'text\');}
267 267
 else{$eli.attr(\'type\',\'password\');}"
268 268
 ><i class="far fa-fw fa-eye-slash"></i></span>';
269
-			}
270
-
271
-			// input group wraps
272
-			if ( $args['input_group_left'] || $args['input_group_right'] ) {
273
-				$w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
274
-				if ( $args['input_group_left'] ) {
275
-					$output = self::wrap( array(
276
-						'content'                 => $output,
277
-						'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
278
-						'input_group_left'        => $args['input_group_left'],
279
-						'input_group_left_inside' => $args['input_group_left_inside']
280
-					) );
281
-				}
282
-				if ( $args['input_group_right'] ) {
283
-					$output = self::wrap( array(
284
-						'content'                  => $output,
285
-						'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
286
-						'input_group_right'        => $args['input_group_right'],
287
-						'input_group_right_inside' => $args['input_group_right_inside']
288
-					) );
289
-				}
290
-
291
-			}
292
-
293
-			if ( ! $label_after ) {
294
-				$output .= $help_text;
295
-			}
296
-
297
-
298
-			if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) {
299
-				$output = self::wrap( array(
300
-					'content' => $output,
301
-					'class'   => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' )
302
-				) );
303
-			}
304
-
305
-			if ( ! $label_after ) {
306
-				$output = $label . $output;
307
-			}
308
-
309
-			// wrap
310
-			if ( ! $args['no_wrap'] ) {
311
-				$form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
312
-				$wrap_class       = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
313
-				$wrap_class       = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
314
-				$output           = self::wrap( array(
315
-					'content'         => $output,
316
-					'class'           => $wrap_class,
317
-					'element_require' => $args['element_require'],
318
-					'argument_id'     => $args['id'],
319
-					'wrap_attributes' => $args['wrap_attributes'],
320
-				) );
321
-			}
322
-		}
323
-
324
-		return $output;
325
-	}
326
-
327
-	public static function label( $args = array(), $type = '' ) {
328
-		//<label for="exampleInputEmail1">Email address</label>
329
-		$defaults = array(
330
-			'title'      => 'div',
331
-			'for'        => '',
332
-			'class'      => '',
333
-			'label_type' => '', // empty = hidden, top, horizontal
334
-			'label_col'  => '',
335
-		);
336
-
337
-		/**
338
-		 * Parse incoming $args into an array and merge it with $defaults
339
-		 */
340
-		$args   = wp_parse_args( $args, $defaults );
341
-		$output = '';
342
-
343
-		if ( $args['title'] ) {
344
-
345
-			// maybe hide labels //@todo set a global option for visibility class
346
-			if ( $type == 'file' || $type == 'checkbox' || $type == 'radio' || ! empty( $args['label_type'] ) ) {
347
-				$class = $args['class'];
348
-			} else {
349
-				$class = 'sr-only ' . $args['class'];
350
-			}
351
-
352
-			// maybe horizontal
353
-			if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) {
354
-				$class .= ' ' . AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ) . ' col-form-label';
355
-			}
356
-
357
-			// open
358
-			$output .= '<label ';
359
-
360
-			// for
361
-			if ( ! empty( $args['for'] ) ) {
362
-				$output .= ' for="' . esc_attr( $args['for'] ) . '" ';
363
-			}
364
-
365
-			// class
366
-			$class = $class ? AUI_Component_Helper::esc_classes( $class ) : '';
367
-			$output .= ' class="' . $class . '" ';
368
-
369
-			// close
370
-			$output .= '>';
371
-
372
-
373
-			// title, don't escape fully as can contain html
374
-			if ( ! empty( $args['title'] ) ) {
375
-				$output .= wp_kses_post( $args['title'] );
376
-			}
377
-
378
-			// close wrap
379
-			$output .= '</label>';
380
-
381
-
382
-		}
383
-
384
-
385
-		return $output;
386
-	}
387
-
388
-	/**
389
-	 * Wrap some content in a HTML wrapper.
390
-	 *
391
-	 * @param array $args
392
-	 *
393
-	 * @return string
394
-	 */
395
-	public static function wrap( $args = array() ) {
396
-		$defaults = array(
397
-			'type'                     => 'div',
398
-			'class'                    => 'form-group',
399
-			'content'                  => '',
400
-			'input_group_left'         => '',
401
-			'input_group_right'        => '',
402
-			'input_group_left_inside'  => false,
403
-			'input_group_right_inside' => false,
404
-			'element_require'          => '',
405
-			'argument_id'              => '',
406
-			'wrap_attributes'          => array()
407
-		);
408
-
409
-		/**
410
-		 * Parse incoming $args into an array and merge it with $defaults
411
-		 */
412
-		$args   = wp_parse_args( $args, $defaults );
413
-		$output = '';
414
-		if ( $args['type'] ) {
415
-
416
-			// open
417
-			$output .= '<' . sanitize_html_class( $args['type'] );
418
-
419
-			// element require
420
-			if ( ! empty( $args['element_require'] ) ) {
421
-				$output .= AUI_Component_Helper::element_require( $args['element_require'] );
422
-				$args['class'] .= " aui-conditional-field";
423
-			}
424
-
425
-			// argument_id
426
-			if ( ! empty( $args['argument_id'] ) ) {
427
-				$output .= ' data-argument="' . esc_attr( $args['argument_id'] ) . '"';
428
-			}
429
-
430
-			// class
431
-			$class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
432
-			$output .= ' class="' . $class . '" ';
433
-
434
-			// Attributes
435
-			if ( ! empty( $args['wrap_attributes'] ) ) {
436
-				$output .= AUI_Component_Helper::extra_attributes( $args['wrap_attributes'] );
437
-			}
438
-
439
-			// close wrap
440
-			$output .= ' >';
441
-
442
-
443
-			// Input group left
444
-			if ( ! empty( $args['input_group_left'] ) ) {
445
-				$position_class   = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : '';
446
-				$input_group_left = strpos( $args['input_group_left'], '<' ) !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>';
447
-				$output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>';
448
-			}
449
-
450
-			// content
451
-			$output .= $args['content'];
452
-
453
-			// Input group right
454
-			if ( ! empty( $args['input_group_right'] ) ) {
455
-				$position_class    = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : '';
456
-				$input_group_right = strpos( $args['input_group_right'], '<' ) !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>';
457
-				$output .= '<div class="input-group-append ' . $position_class . '">' . $input_group_right . '</div>';
458
-			}
459
-
460
-
461
-			// close wrap
462
-			$output .= '</' . sanitize_html_class( $args['type'] ) . '>';
463
-
464
-
465
-		} else {
466
-			$output = $args['content'];
467
-		}
468
-
469
-		return $output;
470
-	}
471
-
472
-	/**
473
-	 * Build the component.
474
-	 *
475
-	 * @param array $args
476
-	 *
477
-	 * @return string The rendered component.
478
-	 */
479
-	public static function textarea( $args = array() ) {
480
-		$defaults = array(
481
-			'name'               => '',
482
-			'class'              => '',
483
-			'wrap_class'         => '',
484
-			'id'                 => '',
485
-			'placeholder'        => '',
486
-			'title'              => '',
487
-			'value'              => '',
488
-			'required'           => false,
489
-			'label'              => '',
490
-			'label_after'        => false,
491
-			'label_class'        => '',
492
-			'label_type'         => '',
493
-			'label_col'          => '',
494
-			// sets the label type, default: hidden. Options: hidden, top, horizontal, floating
495
-			'input_group_right'        => '',
496
-			'input_group_left'         => '',
497
-			'input_group_right_inside' => false,
498
-			'help_text'          => '',
499
-			'validation_text'    => '',
500
-			'validation_pattern' => '',
501
-			'no_wrap'            => false,
502
-			'rows'               => '',
503
-			'wysiwyg'            => false,
504
-			'allow_tags'         => false,
505
-			// Allow HTML tags
506
-			'element_require'    => '',
507
-			// [%element_id%] == "1"
508
-			'extra_attributes'   => array(),
509
-			// an array of extra attributes
510
-			'wrap_attributes'    => array(),
511
-		);
512
-
513
-		/**
514
-		 * Parse incoming $args into an array and merge it with $defaults
515
-		 */
516
-		$args   = wp_parse_args( $args, $defaults );
517
-		$output = '';
518
-
519
-		// hidden label option needs to be empty
520
-		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
521
-
522
-		// floating labels don't work with wysiwyg so set it as top
523
-		if ( $args['label_type'] == 'floating' && ! empty( $args['wysiwyg'] ) ) {
524
-			$args['label_type'] = 'top';
525
-		}
526
-
527
-		$label_after = $args['label_after'];
528
-
529
-		// floating labels need label after
530
-		if ( $args['label_type'] == 'floating' && empty( $args['wysiwyg'] ) ) {
531
-			$label_after         = true;
532
-			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
533
-		}
534
-
535
-		// label
536
-		if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
537
-		} elseif ( ! empty( $args['label'] ) && ! $label_after ) {
538
-			$label_args = array(
539
-				'title'      => $args['label'],
540
-				'for'        => $args['id'],
541
-				'class'      => $args['label_class'] . " ",
542
-				'label_type' => $args['label_type'],
543
-				'label_col'  => $args['label_col']
544
-			);
545
-			$output .= self::label( $label_args );
546
-		}
547
-
548
-		// maybe horizontal label
549
-		if ( $args['label_type'] == 'horizontal' ) {
550
-			$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
551
-			$output .= '<div class="' . $input_col . '">';
552
-		}
553
-
554
-		if ( ! empty( $args['wysiwyg'] ) ) {
555
-			ob_start();
556
-			$content   = $args['value'];
557
-			$editor_id = ! empty( $args['id'] ) ? sanitize_html_class( $args['id'] ) : 'wp_editor';
558
-			$settings  = array(
559
-				'textarea_rows' => ! empty( absint( $args['rows'] ) ) ? absint( $args['rows'] ) : 4,
560
-				'quicktags'     => false,
561
-				'media_buttons' => false,
562
-				'editor_class'  => 'form-control',
563
-				'textarea_name' => ! empty( $args['name'] ) ? sanitize_html_class( $args['name'] ) : sanitize_html_class( $args['id'] ),
564
-				'teeny'         => true,
565
-			);
566
-
567
-			// maybe set settings if array
568
-			if ( is_array( $args['wysiwyg'] ) ) {
569
-				$settings = wp_parse_args( $args['wysiwyg'], $settings );
570
-			}
571
-
572
-			wp_editor( $content, $editor_id, $settings );
573
-			$output .= ob_get_clean();
574
-		} else {
575
-
576
-			// open
577
-			$output .= '<textarea ';
578
-
579
-			// name
580
-			if ( ! empty( $args['name'] ) ) {
581
-				$output .= ' name="' . esc_attr( $args['name'] ) . '" ';
582
-			}
583
-
584
-			// id
585
-			if ( ! empty( $args['id'] ) ) {
586
-				$output .= ' id="' . sanitize_html_class( $args['id'] ) . '" ';
587
-			}
588
-
589
-			// placeholder
590
-			if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) {
591
-				$output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" ';
592
-			}
593
-
594
-			// title
595
-			if ( ! empty( $args['title'] ) ) {
596
-				$output .= ' title="' . esc_attr( $args['title'] ) . '" ';
597
-			}
598
-
599
-			// validation text
600
-			if ( ! empty( $args['validation_text'] ) ) {
601
-				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" ';
602
-				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
603
-			}
604
-
605
-			// validation_pattern
606
-			if ( ! empty( $args['validation_pattern'] ) ) {
607
-				$output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
608
-			}
609
-
610
-			// required
611
-			if ( ! empty( $args['required'] ) ) {
612
-				$output .= ' required ';
613
-			}
614
-
615
-			// rows
616
-			if ( ! empty( $args['rows'] ) ) {
617
-				$output .= ' rows="' . absint( $args['rows'] ) . '" ';
618
-			}
619
-
620
-
621
-			// class
622
-			$class = ! empty( $args['class'] ) ? $args['class'] : '';
623
-			$output .= ' class="form-control ' . $class . '" ';
624
-
625
-			// extra attributes
626
-			if ( ! empty( $args['extra_attributes'] ) ) {
627
-				$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
628
-			}
629
-
630
-			// close tag
631
-			$output .= ' >';
632
-
633
-			// value
634
-			if ( ! empty( $args['value'] ) ) {
635
-				if ( ! empty( $args['allow_tags'] ) ) {
636
-					$output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML.
637
-				} else {
638
-					$output .= AUI_Component_Helper::sanitize_textarea_field( $args['value'] );
639
-				}
640
-			}
641
-
642
-			// closing tag
643
-			$output .= '</textarea>';
644
-
645
-
646
-			// input group wraps
647
-			if ( $args['input_group_left'] || $args['input_group_right'] ) {
648
-				$w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
649
-				if ( $args['input_group_left'] ) {
650
-					$output = self::wrap( array(
651
-						'content'                 => $output,
652
-						'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
653
-						'input_group_left'        => $args['input_group_left'],
654
-						'input_group_left_inside' => $args['input_group_left_inside']
655
-					) );
656
-				}
657
-				if ( $args['input_group_right'] ) {
658
-					$output = self::wrap( array(
659
-						'content'                  => $output,
660
-						'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
661
-						'input_group_right'        => $args['input_group_right'],
662
-						'input_group_right_inside' => $args['input_group_right_inside']
663
-					) );
664
-				}
665
-
666
-			}
667
-
668
-
669
-		}
670
-
671
-		if ( ! empty( $args['label'] ) && $label_after ) {
672
-			$label_args = array(
673
-				'title'      => $args['label'],
674
-				'for'        => $args['id'],
675
-				'class'      => $args['label_class'] . " ",
676
-				'label_type' => $args['label_type'],
677
-				'label_col'  => $args['label_col']
678
-			);
679
-			$output .= self::label( $label_args );
680
-		}
681
-
682
-		// help text
683
-		if ( ! empty( $args['help_text'] ) ) {
684
-			$output .= AUI_Component_Helper::help_text( $args['help_text'] );
685
-		}
686
-
687
-		// maybe horizontal label
688
-		if ( $args['label_type'] == 'horizontal' ) {
689
-			$output .= '</div>';
690
-		}
691
-
692
-
693
-		// wrap
694
-		if ( ! $args['no_wrap'] ) {
695
-			$form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : 'form-group';
696
-			$wrap_class       = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
697
-			$wrap_class       = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
698
-			$output           = self::wrap( array(
699
-				'content'         => $output,
700
-				'class'           => $wrap_class,
701
-				'element_require' => $args['element_require'],
702
-				'argument_id'     => $args['id'],
703
-				'wrap_attributes' => $args['wrap_attributes'],
704
-			) );
705
-		}
706
-
707
-
708
-		return $output;
709
-	}
710
-
711
-	/**
712
-	 * Build the component.
713
-	 *
714
-	 * @param array $args
715
-	 *
716
-	 * @return string The rendered component.
717
-	 */
718
-	public static function select( $args = array() ) {
719
-		$defaults = array(
720
-			'class'            => '',
721
-			'wrap_class'       => '',
722
-			'id'               => '',
723
-			'title'            => '',
724
-			'value'            => '',
725
-			// can be an array or a string
726
-			'required'         => false,
727
-			'label'            => '',
728
-			'label_after'      => false,
729
-			'label_type'       => '',
730
-			'label_col'        => '',
731
-			// sets the label type, default: hidden. Options: hidden, top, horizontal, floating
732
-			'label_class'      => '',
733
-			'help_text'        => '',
734
-			'placeholder'      => '',
735
-			'options'          => array(),
736
-			// array or string
737
-			'icon'             => '',
738
-			'multiple'         => false,
739
-			'select2'          => false,
740
-			'no_wrap'          => false,
741
-			'input_group_right' => '',
742
-			'input_group_left' => '',
743
-			'input_group_right_inside' => false, // forces the input group inside the input
744
-			'input_group_left_inside' => false, // forces the input group inside the input
745
-			'element_require'  => '',
746
-			// [%element_id%] == "1"
747
-			'extra_attributes' => array(),
748
-			// an array of extra attributes
749
-			'wrap_attributes'  => array(),
750
-		);
751
-
752
-		/**
753
-		 * Parse incoming $args into an array and merge it with $defaults
754
-		 */
755
-		$args   = wp_parse_args( $args, $defaults );
756
-		$output = '';
757
-
758
-		// for now lets hide floating labels
759
-		if ( $args['label_type'] == 'floating' ) {
760
-			$args['label_type'] = 'hidden';
761
-		}
762
-
763
-		// hidden label option needs to be empty
764
-		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
765
-
766
-
767
-		$label_after = $args['label_after'];
768
-
769
-		// floating labels need label after
770
-		if ( $args['label_type'] == 'floating' ) {
771
-			$label_after         = true;
772
-			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
773
-		}
774
-
775
-		// Maybe setup select2
776
-		$is_select2 = false;
777
-		if ( ! empty( $args['select2'] ) ) {
778
-			$args['class'] .= ' aui-select2';
779
-			$is_select2 = true;
780
-		} elseif ( strpos( $args['class'], 'aui-select2' ) !== false ) {
781
-			$is_select2 = true;
782
-		}
783
-
784
-		// select2 tags
785
-		if ( ! empty( $args['select2'] ) && $args['select2'] === 'tags' ) { // triple equals needed here for some reason
786
-			$args['data-tags']             = 'true';
787
-			$args['data-token-separators'] = "[',']";
788
-			$args['multiple']              = true;
789
-		}
790
-
791
-		// select2 placeholder
792
-		if ( $is_select2 && isset( $args['placeholder'] ) && '' != $args['placeholder'] && empty( $args['data-placeholder'] ) ) {
793
-			$args['data-placeholder'] = esc_attr( $args['placeholder'] );
794
-			$args['data-allow-clear'] = isset( $args['data-allow-clear'] ) ? (bool) $args['data-allow-clear'] : true;
795
-		}
796
-
797
-
798
-
799
-		// maybe horizontal label
269
+            }
270
+
271
+            // input group wraps
272
+            if ( $args['input_group_left'] || $args['input_group_right'] ) {
273
+                $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
274
+                if ( $args['input_group_left'] ) {
275
+                    $output = self::wrap( array(
276
+                        'content'                 => $output,
277
+                        'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
278
+                        'input_group_left'        => $args['input_group_left'],
279
+                        'input_group_left_inside' => $args['input_group_left_inside']
280
+                    ) );
281
+                }
282
+                if ( $args['input_group_right'] ) {
283
+                    $output = self::wrap( array(
284
+                        'content'                  => $output,
285
+                        'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
286
+                        'input_group_right'        => $args['input_group_right'],
287
+                        'input_group_right_inside' => $args['input_group_right_inside']
288
+                    ) );
289
+                }
290
+
291
+            }
292
+
293
+            if ( ! $label_after ) {
294
+                $output .= $help_text;
295
+            }
296
+
297
+
298
+            if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) {
299
+                $output = self::wrap( array(
300
+                    'content' => $output,
301
+                    'class'   => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' )
302
+                ) );
303
+            }
304
+
305
+            if ( ! $label_after ) {
306
+                $output = $label . $output;
307
+            }
308
+
309
+            // wrap
310
+            if ( ! $args['no_wrap'] ) {
311
+                $form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
312
+                $wrap_class       = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
313
+                $wrap_class       = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
314
+                $output           = self::wrap( array(
315
+                    'content'         => $output,
316
+                    'class'           => $wrap_class,
317
+                    'element_require' => $args['element_require'],
318
+                    'argument_id'     => $args['id'],
319
+                    'wrap_attributes' => $args['wrap_attributes'],
320
+                ) );
321
+            }
322
+        }
323
+
324
+        return $output;
325
+    }
326
+
327
+    public static function label( $args = array(), $type = '' ) {
328
+        //<label for="exampleInputEmail1">Email address</label>
329
+        $defaults = array(
330
+            'title'      => 'div',
331
+            'for'        => '',
332
+            'class'      => '',
333
+            'label_type' => '', // empty = hidden, top, horizontal
334
+            'label_col'  => '',
335
+        );
336
+
337
+        /**
338
+         * Parse incoming $args into an array and merge it with $defaults
339
+         */
340
+        $args   = wp_parse_args( $args, $defaults );
341
+        $output = '';
342
+
343
+        if ( $args['title'] ) {
344
+
345
+            // maybe hide labels //@todo set a global option for visibility class
346
+            if ( $type == 'file' || $type == 'checkbox' || $type == 'radio' || ! empty( $args['label_type'] ) ) {
347
+                $class = $args['class'];
348
+            } else {
349
+                $class = 'sr-only ' . $args['class'];
350
+            }
351
+
352
+            // maybe horizontal
353
+            if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) {
354
+                $class .= ' ' . AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ) . ' col-form-label';
355
+            }
356
+
357
+            // open
358
+            $output .= '<label ';
359
+
360
+            // for
361
+            if ( ! empty( $args['for'] ) ) {
362
+                $output .= ' for="' . esc_attr( $args['for'] ) . '" ';
363
+            }
364
+
365
+            // class
366
+            $class = $class ? AUI_Component_Helper::esc_classes( $class ) : '';
367
+            $output .= ' class="' . $class . '" ';
368
+
369
+            // close
370
+            $output .= '>';
371
+
372
+
373
+            // title, don't escape fully as can contain html
374
+            if ( ! empty( $args['title'] ) ) {
375
+                $output .= wp_kses_post( $args['title'] );
376
+            }
377
+
378
+            // close wrap
379
+            $output .= '</label>';
380
+
381
+
382
+        }
383
+
384
+
385
+        return $output;
386
+    }
387
+
388
+    /**
389
+     * Wrap some content in a HTML wrapper.
390
+     *
391
+     * @param array $args
392
+     *
393
+     * @return string
394
+     */
395
+    public static function wrap( $args = array() ) {
396
+        $defaults = array(
397
+            'type'                     => 'div',
398
+            'class'                    => 'form-group',
399
+            'content'                  => '',
400
+            'input_group_left'         => '',
401
+            'input_group_right'        => '',
402
+            'input_group_left_inside'  => false,
403
+            'input_group_right_inside' => false,
404
+            'element_require'          => '',
405
+            'argument_id'              => '',
406
+            'wrap_attributes'          => array()
407
+        );
408
+
409
+        /**
410
+         * Parse incoming $args into an array and merge it with $defaults
411
+         */
412
+        $args   = wp_parse_args( $args, $defaults );
413
+        $output = '';
414
+        if ( $args['type'] ) {
415
+
416
+            // open
417
+            $output .= '<' . sanitize_html_class( $args['type'] );
418
+
419
+            // element require
420
+            if ( ! empty( $args['element_require'] ) ) {
421
+                $output .= AUI_Component_Helper::element_require( $args['element_require'] );
422
+                $args['class'] .= " aui-conditional-field";
423
+            }
424
+
425
+            // argument_id
426
+            if ( ! empty( $args['argument_id'] ) ) {
427
+                $output .= ' data-argument="' . esc_attr( $args['argument_id'] ) . '"';
428
+            }
429
+
430
+            // class
431
+            $class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
432
+            $output .= ' class="' . $class . '" ';
433
+
434
+            // Attributes
435
+            if ( ! empty( $args['wrap_attributes'] ) ) {
436
+                $output .= AUI_Component_Helper::extra_attributes( $args['wrap_attributes'] );
437
+            }
438
+
439
+            // close wrap
440
+            $output .= ' >';
441
+
442
+
443
+            // Input group left
444
+            if ( ! empty( $args['input_group_left'] ) ) {
445
+                $position_class   = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : '';
446
+                $input_group_left = strpos( $args['input_group_left'], '<' ) !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>';
447
+                $output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>';
448
+            }
449
+
450
+            // content
451
+            $output .= $args['content'];
452
+
453
+            // Input group right
454
+            if ( ! empty( $args['input_group_right'] ) ) {
455
+                $position_class    = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : '';
456
+                $input_group_right = strpos( $args['input_group_right'], '<' ) !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>';
457
+                $output .= '<div class="input-group-append ' . $position_class . '">' . $input_group_right . '</div>';
458
+            }
459
+
460
+
461
+            // close wrap
462
+            $output .= '</' . sanitize_html_class( $args['type'] ) . '>';
463
+
464
+
465
+        } else {
466
+            $output = $args['content'];
467
+        }
468
+
469
+        return $output;
470
+    }
471
+
472
+    /**
473
+     * Build the component.
474
+     *
475
+     * @param array $args
476
+     *
477
+     * @return string The rendered component.
478
+     */
479
+    public static function textarea( $args = array() ) {
480
+        $defaults = array(
481
+            'name'               => '',
482
+            'class'              => '',
483
+            'wrap_class'         => '',
484
+            'id'                 => '',
485
+            'placeholder'        => '',
486
+            'title'              => '',
487
+            'value'              => '',
488
+            'required'           => false,
489
+            'label'              => '',
490
+            'label_after'        => false,
491
+            'label_class'        => '',
492
+            'label_type'         => '',
493
+            'label_col'          => '',
494
+            // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
495
+            'input_group_right'        => '',
496
+            'input_group_left'         => '',
497
+            'input_group_right_inside' => false,
498
+            'help_text'          => '',
499
+            'validation_text'    => '',
500
+            'validation_pattern' => '',
501
+            'no_wrap'            => false,
502
+            'rows'               => '',
503
+            'wysiwyg'            => false,
504
+            'allow_tags'         => false,
505
+            // Allow HTML tags
506
+            'element_require'    => '',
507
+            // [%element_id%] == "1"
508
+            'extra_attributes'   => array(),
509
+            // an array of extra attributes
510
+            'wrap_attributes'    => array(),
511
+        );
512
+
513
+        /**
514
+         * Parse incoming $args into an array and merge it with $defaults
515
+         */
516
+        $args   = wp_parse_args( $args, $defaults );
517
+        $output = '';
518
+
519
+        // hidden label option needs to be empty
520
+        $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
521
+
522
+        // floating labels don't work with wysiwyg so set it as top
523
+        if ( $args['label_type'] == 'floating' && ! empty( $args['wysiwyg'] ) ) {
524
+            $args['label_type'] = 'top';
525
+        }
526
+
527
+        $label_after = $args['label_after'];
528
+
529
+        // floating labels need label after
530
+        if ( $args['label_type'] == 'floating' && empty( $args['wysiwyg'] ) ) {
531
+            $label_after         = true;
532
+            $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
533
+        }
534
+
535
+        // label
536
+        if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
537
+        } elseif ( ! empty( $args['label'] ) && ! $label_after ) {
538
+            $label_args = array(
539
+                'title'      => $args['label'],
540
+                'for'        => $args['id'],
541
+                'class'      => $args['label_class'] . " ",
542
+                'label_type' => $args['label_type'],
543
+                'label_col'  => $args['label_col']
544
+            );
545
+            $output .= self::label( $label_args );
546
+        }
547
+
548
+        // maybe horizontal label
549
+        if ( $args['label_type'] == 'horizontal' ) {
550
+            $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
551
+            $output .= '<div class="' . $input_col . '">';
552
+        }
553
+
554
+        if ( ! empty( $args['wysiwyg'] ) ) {
555
+            ob_start();
556
+            $content   = $args['value'];
557
+            $editor_id = ! empty( $args['id'] ) ? sanitize_html_class( $args['id'] ) : 'wp_editor';
558
+            $settings  = array(
559
+                'textarea_rows' => ! empty( absint( $args['rows'] ) ) ? absint( $args['rows'] ) : 4,
560
+                'quicktags'     => false,
561
+                'media_buttons' => false,
562
+                'editor_class'  => 'form-control',
563
+                'textarea_name' => ! empty( $args['name'] ) ? sanitize_html_class( $args['name'] ) : sanitize_html_class( $args['id'] ),
564
+                'teeny'         => true,
565
+            );
566
+
567
+            // maybe set settings if array
568
+            if ( is_array( $args['wysiwyg'] ) ) {
569
+                $settings = wp_parse_args( $args['wysiwyg'], $settings );
570
+            }
571
+
572
+            wp_editor( $content, $editor_id, $settings );
573
+            $output .= ob_get_clean();
574
+        } else {
575
+
576
+            // open
577
+            $output .= '<textarea ';
578
+
579
+            // name
580
+            if ( ! empty( $args['name'] ) ) {
581
+                $output .= ' name="' . esc_attr( $args['name'] ) . '" ';
582
+            }
583
+
584
+            // id
585
+            if ( ! empty( $args['id'] ) ) {
586
+                $output .= ' id="' . sanitize_html_class( $args['id'] ) . '" ';
587
+            }
588
+
589
+            // placeholder
590
+            if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) {
591
+                $output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" ';
592
+            }
593
+
594
+            // title
595
+            if ( ! empty( $args['title'] ) ) {
596
+                $output .= ' title="' . esc_attr( $args['title'] ) . '" ';
597
+            }
598
+
599
+            // validation text
600
+            if ( ! empty( $args['validation_text'] ) ) {
601
+                $output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" ';
602
+                $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
603
+            }
604
+
605
+            // validation_pattern
606
+            if ( ! empty( $args['validation_pattern'] ) ) {
607
+                $output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
608
+            }
609
+
610
+            // required
611
+            if ( ! empty( $args['required'] ) ) {
612
+                $output .= ' required ';
613
+            }
614
+
615
+            // rows
616
+            if ( ! empty( $args['rows'] ) ) {
617
+                $output .= ' rows="' . absint( $args['rows'] ) . '" ';
618
+            }
619
+
620
+
621
+            // class
622
+            $class = ! empty( $args['class'] ) ? $args['class'] : '';
623
+            $output .= ' class="form-control ' . $class . '" ';
624
+
625
+            // extra attributes
626
+            if ( ! empty( $args['extra_attributes'] ) ) {
627
+                $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
628
+            }
629
+
630
+            // close tag
631
+            $output .= ' >';
632
+
633
+            // value
634
+            if ( ! empty( $args['value'] ) ) {
635
+                if ( ! empty( $args['allow_tags'] ) ) {
636
+                    $output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML.
637
+                } else {
638
+                    $output .= AUI_Component_Helper::sanitize_textarea_field( $args['value'] );
639
+                }
640
+            }
641
+
642
+            // closing tag
643
+            $output .= '</textarea>';
644
+
645
+
646
+            // input group wraps
647
+            if ( $args['input_group_left'] || $args['input_group_right'] ) {
648
+                $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
649
+                if ( $args['input_group_left'] ) {
650
+                    $output = self::wrap( array(
651
+                        'content'                 => $output,
652
+                        'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
653
+                        'input_group_left'        => $args['input_group_left'],
654
+                        'input_group_left_inside' => $args['input_group_left_inside']
655
+                    ) );
656
+                }
657
+                if ( $args['input_group_right'] ) {
658
+                    $output = self::wrap( array(
659
+                        'content'                  => $output,
660
+                        'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
661
+                        'input_group_right'        => $args['input_group_right'],
662
+                        'input_group_right_inside' => $args['input_group_right_inside']
663
+                    ) );
664
+                }
665
+
666
+            }
667
+
668
+
669
+        }
670
+
671
+        if ( ! empty( $args['label'] ) && $label_after ) {
672
+            $label_args = array(
673
+                'title'      => $args['label'],
674
+                'for'        => $args['id'],
675
+                'class'      => $args['label_class'] . " ",
676
+                'label_type' => $args['label_type'],
677
+                'label_col'  => $args['label_col']
678
+            );
679
+            $output .= self::label( $label_args );
680
+        }
681
+
682
+        // help text
683
+        if ( ! empty( $args['help_text'] ) ) {
684
+            $output .= AUI_Component_Helper::help_text( $args['help_text'] );
685
+        }
686
+
687
+        // maybe horizontal label
688
+        if ( $args['label_type'] == 'horizontal' ) {
689
+            $output .= '</div>';
690
+        }
691
+
692
+
693
+        // wrap
694
+        if ( ! $args['no_wrap'] ) {
695
+            $form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : 'form-group';
696
+            $wrap_class       = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
697
+            $wrap_class       = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
698
+            $output           = self::wrap( array(
699
+                'content'         => $output,
700
+                'class'           => $wrap_class,
701
+                'element_require' => $args['element_require'],
702
+                'argument_id'     => $args['id'],
703
+                'wrap_attributes' => $args['wrap_attributes'],
704
+            ) );
705
+        }
706
+
707
+
708
+        return $output;
709
+    }
710
+
711
+    /**
712
+     * Build the component.
713
+     *
714
+     * @param array $args
715
+     *
716
+     * @return string The rendered component.
717
+     */
718
+    public static function select( $args = array() ) {
719
+        $defaults = array(
720
+            'class'            => '',
721
+            'wrap_class'       => '',
722
+            'id'               => '',
723
+            'title'            => '',
724
+            'value'            => '',
725
+            // can be an array or a string
726
+            'required'         => false,
727
+            'label'            => '',
728
+            'label_after'      => false,
729
+            'label_type'       => '',
730
+            'label_col'        => '',
731
+            // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
732
+            'label_class'      => '',
733
+            'help_text'        => '',
734
+            'placeholder'      => '',
735
+            'options'          => array(),
736
+            // array or string
737
+            'icon'             => '',
738
+            'multiple'         => false,
739
+            'select2'          => false,
740
+            'no_wrap'          => false,
741
+            'input_group_right' => '',
742
+            'input_group_left' => '',
743
+            'input_group_right_inside' => false, // forces the input group inside the input
744
+            'input_group_left_inside' => false, // forces the input group inside the input
745
+            'element_require'  => '',
746
+            // [%element_id%] == "1"
747
+            'extra_attributes' => array(),
748
+            // an array of extra attributes
749
+            'wrap_attributes'  => array(),
750
+        );
751
+
752
+        /**
753
+         * Parse incoming $args into an array and merge it with $defaults
754
+         */
755
+        $args   = wp_parse_args( $args, $defaults );
756
+        $output = '';
757
+
758
+        // for now lets hide floating labels
759
+        if ( $args['label_type'] == 'floating' ) {
760
+            $args['label_type'] = 'hidden';
761
+        }
762
+
763
+        // hidden label option needs to be empty
764
+        $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
765
+
766
+
767
+        $label_after = $args['label_after'];
768
+
769
+        // floating labels need label after
770
+        if ( $args['label_type'] == 'floating' ) {
771
+            $label_after         = true;
772
+            $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
773
+        }
774
+
775
+        // Maybe setup select2
776
+        $is_select2 = false;
777
+        if ( ! empty( $args['select2'] ) ) {
778
+            $args['class'] .= ' aui-select2';
779
+            $is_select2 = true;
780
+        } elseif ( strpos( $args['class'], 'aui-select2' ) !== false ) {
781
+            $is_select2 = true;
782
+        }
783
+
784
+        // select2 tags
785
+        if ( ! empty( $args['select2'] ) && $args['select2'] === 'tags' ) { // triple equals needed here for some reason
786
+            $args['data-tags']             = 'true';
787
+            $args['data-token-separators'] = "[',']";
788
+            $args['multiple']              = true;
789
+        }
790
+
791
+        // select2 placeholder
792
+        if ( $is_select2 && isset( $args['placeholder'] ) && '' != $args['placeholder'] && empty( $args['data-placeholder'] ) ) {
793
+            $args['data-placeholder'] = esc_attr( $args['placeholder'] );
794
+            $args['data-allow-clear'] = isset( $args['data-allow-clear'] ) ? (bool) $args['data-allow-clear'] : true;
795
+        }
796
+
797
+
798
+
799
+        // maybe horizontal label
800 800
 //		if ( $args['label_type'] == 'horizontal' ) {
801 801
 //			$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
802 802
 //			$output .= '<div class="' . $input_col . '">';
803 803
 //		}
804 804
 
805
-		// Set hidden input to save empty value for multiselect.
806
-		if ( ! empty( $args['multiple'] ) && ! empty( $args['name'] ) ) {
807
-			$output .= '<input type="hidden" ' . AUI_Component_Helper::name( $args['name'] ) . ' value=""/>';
808
-		}
809
-
810
-		// open/type
811
-		$output .= '<select ';
812
-
813
-		// style
814
-		if ( $is_select2 && !($args['input_group_left'] || $args['input_group_right'])) {
815
-			$output .= " style='width:100%;' ";
816
-		}
817
-
818
-		// element require
819
-		if ( ! empty( $args['element_require'] ) ) {
820
-			$output .= AUI_Component_Helper::element_require( $args['element_require'] );
821
-			$args['class'] .= " aui-conditional-field";
822
-		}
823
-
824
-		// class
825
-		$class = ! empty( $args['class'] ) ? $args['class'] : '';
826
-		$output .= AUI_Component_Helper::class_attr( 'custom-select ' . $class );
827
-
828
-		// name
829
-		if ( ! empty( $args['name'] ) ) {
830
-			$output .= AUI_Component_Helper::name( $args['name'], $args['multiple'] );
831
-		}
832
-
833
-		// id
834
-		if ( ! empty( $args['id'] ) ) {
835
-			$output .= AUI_Component_Helper::id( $args['id'] );
836
-		}
837
-
838
-		// title
839
-		if ( ! empty( $args['title'] ) ) {
840
-			$output .= AUI_Component_Helper::title( $args['title'] );
841
-		}
842
-
843
-		// data-attributes
844
-		$output .= AUI_Component_Helper::data_attributes( $args );
845
-
846
-		// aria-attributes
847
-		$output .= AUI_Component_Helper::aria_attributes( $args );
848
-
849
-		// extra attributes
850
-		if ( ! empty( $args['extra_attributes'] ) ) {
851
-			$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
852
-		}
853
-
854
-		// required
855
-		if ( ! empty( $args['required'] ) ) {
856
-			$output .= ' required ';
857
-		}
858
-
859
-		// multiple
860
-		if ( ! empty( $args['multiple'] ) ) {
861
-			$output .= ' multiple ';
862
-		}
863
-
864
-		// close opening tag
865
-		$output .= ' >';
866
-
867
-		// placeholder
868
-		if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] && ! $is_select2 ) {
869
-			$output .= '<option value="" disabled selected hidden>' . esc_attr( $args['placeholder'] ) . '</option>';
870
-		} elseif ( $is_select2 && ! empty( $args['placeholder'] ) ) {
871
-			$output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
872
-		}
873
-
874
-		// Options
875
-		if ( ! empty( $args['options'] ) ) {
876
-
877
-			if ( ! is_array( $args['options'] ) ) {
878
-				$output .= $args['options']; // not the preferred way but an option
879
-			} else {
880
-				foreach ( $args['options'] as $val => $name ) {
881
-					$selected = '';
882
-					if ( is_array( $name ) ) {
883
-						if ( isset( $name['optgroup'] ) && ( $name['optgroup'] == 'start' || $name['optgroup'] == 'end' ) ) {
884
-							$option_label = isset( $name['label'] ) ? $name['label'] : '';
885
-
886
-							$output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr( $option_label ) . '">' : '</optgroup>';
887
-						} else {
888
-							$option_label = isset( $name['label'] ) ? $name['label'] : '';
889
-							$option_value = isset( $name['value'] ) ? $name['value'] : '';
890
-							$extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes( $name['extra_attributes'] ) : '';
891
-							if ( ! empty( $args['multiple'] ) && ! empty( $args['value'] ) && is_array( $args['value'] ) ) {
892
-								$selected = in_array( $option_value, stripslashes_deep( $args['value'] ) ) ? "selected" : "";
893
-							} elseif ( ! empty( $args['value'] ) ) {
894
-								$selected = selected( $option_value, stripslashes_deep( $args['value'] ), false );
895
-							} elseif ( empty( $args['value'] ) && $args['value'] === $option_value ) {
896
-								$selected = selected( $option_value, $args['value'], false );
897
-							}
898
-
899
-							$output .= '<option value="' . esc_attr( $option_value ) . '" ' . $selected . ' '.$extra_attributes .'>' . $option_label . '</option>';
900
-						}
901
-					} else {
902
-						if ( ! empty( $args['value'] ) ) {
903
-							if ( is_array( $args['value'] ) ) {
904
-								$selected = in_array( $val, $args['value'] ) ? 'selected="selected"' : '';
905
-							} elseif ( ! empty( $args['value'] ) ) {
906
-								$selected = selected( $args['value'], $val, false );
907
-							}
908
-						} elseif ( $args['value'] === $val ) {
909
-							$selected = selected( $args['value'], $val, false );
910
-						}
911
-						$output .= '<option value="' . esc_attr( $val ) . '" ' . $selected . '>' . esc_attr( $name ) . '</option>';
912
-					}
913
-				}
914
-			}
915
-
916
-		}
917
-
918
-		// closing tag
919
-		$output .= '</select>';
920
-
921
-		$label = '';
922
-		$help_text = '';
923
-		// label
924
-		if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
925
-		} elseif ( ! empty( $args['label'] ) && ! $label_after ) {
926
-			$label_args = array(
927
-				'title'      => $args['label'],
928
-				'for'        => $args['id'],
929
-				'class'      => $args['label_class'] . " ",
930
-				'label_type' => $args['label_type'],
931
-				'label_col'  => $args['label_col']
932
-			);
933
-			$label = self::label( $label_args );
934
-		}
935
-
936
-		// help text
937
-		if ( ! empty( $args['help_text'] ) ) {
938
-			$help_text = AUI_Component_Helper::help_text( $args['help_text'] );
939
-		}
940
-
941
-		// input group wraps
942
-		if ( $args['input_group_left'] || $args['input_group_right'] ) {
943
-			$w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
944
-			if ( $args['input_group_left'] ) {
945
-				$output = self::wrap( array(
946
-					'content'                 => $output,
947
-					'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
948
-					'input_group_left'        => $args['input_group_left'],
949
-					'input_group_left_inside' => $args['input_group_left_inside']
950
-				) );
951
-			}
952
-			if ( $args['input_group_right'] ) {
953
-				$output = self::wrap( array(
954
-					'content'                  => $output,
955
-					'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
956
-					'input_group_right'        => $args['input_group_right'],
957
-					'input_group_right_inside' => $args['input_group_right_inside']
958
-				) );
959
-			}
960
-
961
-		}
962
-
963
-		if ( ! $label_after ) {
964
-			$output .= $help_text;
965
-		}
966
-
967
-
968
-		if ( $args['label_type'] == 'horizontal' ) {
969
-			$output = self::wrap( array(
970
-				'content' => $output,
971
-				'class'   => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' )
972
-			) );
973
-		}
974
-
975
-		if ( ! $label_after ) {
976
-			$output = $label . $output;
977
-		}
978
-
979
-		// maybe horizontal label
805
+        // Set hidden input to save empty value for multiselect.
806
+        if ( ! empty( $args['multiple'] ) && ! empty( $args['name'] ) ) {
807
+            $output .= '<input type="hidden" ' . AUI_Component_Helper::name( $args['name'] ) . ' value=""/>';
808
+        }
809
+
810
+        // open/type
811
+        $output .= '<select ';
812
+
813
+        // style
814
+        if ( $is_select2 && !($args['input_group_left'] || $args['input_group_right'])) {
815
+            $output .= " style='width:100%;' ";
816
+        }
817
+
818
+        // element require
819
+        if ( ! empty( $args['element_require'] ) ) {
820
+            $output .= AUI_Component_Helper::element_require( $args['element_require'] );
821
+            $args['class'] .= " aui-conditional-field";
822
+        }
823
+
824
+        // class
825
+        $class = ! empty( $args['class'] ) ? $args['class'] : '';
826
+        $output .= AUI_Component_Helper::class_attr( 'custom-select ' . $class );
827
+
828
+        // name
829
+        if ( ! empty( $args['name'] ) ) {
830
+            $output .= AUI_Component_Helper::name( $args['name'], $args['multiple'] );
831
+        }
832
+
833
+        // id
834
+        if ( ! empty( $args['id'] ) ) {
835
+            $output .= AUI_Component_Helper::id( $args['id'] );
836
+        }
837
+
838
+        // title
839
+        if ( ! empty( $args['title'] ) ) {
840
+            $output .= AUI_Component_Helper::title( $args['title'] );
841
+        }
842
+
843
+        // data-attributes
844
+        $output .= AUI_Component_Helper::data_attributes( $args );
845
+
846
+        // aria-attributes
847
+        $output .= AUI_Component_Helper::aria_attributes( $args );
848
+
849
+        // extra attributes
850
+        if ( ! empty( $args['extra_attributes'] ) ) {
851
+            $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
852
+        }
853
+
854
+        // required
855
+        if ( ! empty( $args['required'] ) ) {
856
+            $output .= ' required ';
857
+        }
858
+
859
+        // multiple
860
+        if ( ! empty( $args['multiple'] ) ) {
861
+            $output .= ' multiple ';
862
+        }
863
+
864
+        // close opening tag
865
+        $output .= ' >';
866
+
867
+        // placeholder
868
+        if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] && ! $is_select2 ) {
869
+            $output .= '<option value="" disabled selected hidden>' . esc_attr( $args['placeholder'] ) . '</option>';
870
+        } elseif ( $is_select2 && ! empty( $args['placeholder'] ) ) {
871
+            $output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
872
+        }
873
+
874
+        // Options
875
+        if ( ! empty( $args['options'] ) ) {
876
+
877
+            if ( ! is_array( $args['options'] ) ) {
878
+                $output .= $args['options']; // not the preferred way but an option
879
+            } else {
880
+                foreach ( $args['options'] as $val => $name ) {
881
+                    $selected = '';
882
+                    if ( is_array( $name ) ) {
883
+                        if ( isset( $name['optgroup'] ) && ( $name['optgroup'] == 'start' || $name['optgroup'] == 'end' ) ) {
884
+                            $option_label = isset( $name['label'] ) ? $name['label'] : '';
885
+
886
+                            $output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr( $option_label ) . '">' : '</optgroup>';
887
+                        } else {
888
+                            $option_label = isset( $name['label'] ) ? $name['label'] : '';
889
+                            $option_value = isset( $name['value'] ) ? $name['value'] : '';
890
+                            $extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes( $name['extra_attributes'] ) : '';
891
+                            if ( ! empty( $args['multiple'] ) && ! empty( $args['value'] ) && is_array( $args['value'] ) ) {
892
+                                $selected = in_array( $option_value, stripslashes_deep( $args['value'] ) ) ? "selected" : "";
893
+                            } elseif ( ! empty( $args['value'] ) ) {
894
+                                $selected = selected( $option_value, stripslashes_deep( $args['value'] ), false );
895
+                            } elseif ( empty( $args['value'] ) && $args['value'] === $option_value ) {
896
+                                $selected = selected( $option_value, $args['value'], false );
897
+                            }
898
+
899
+                            $output .= '<option value="' . esc_attr( $option_value ) . '" ' . $selected . ' '.$extra_attributes .'>' . $option_label . '</option>';
900
+                        }
901
+                    } else {
902
+                        if ( ! empty( $args['value'] ) ) {
903
+                            if ( is_array( $args['value'] ) ) {
904
+                                $selected = in_array( $val, $args['value'] ) ? 'selected="selected"' : '';
905
+                            } elseif ( ! empty( $args['value'] ) ) {
906
+                                $selected = selected( $args['value'], $val, false );
907
+                            }
908
+                        } elseif ( $args['value'] === $val ) {
909
+                            $selected = selected( $args['value'], $val, false );
910
+                        }
911
+                        $output .= '<option value="' . esc_attr( $val ) . '" ' . $selected . '>' . esc_attr( $name ) . '</option>';
912
+                    }
913
+                }
914
+            }
915
+
916
+        }
917
+
918
+        // closing tag
919
+        $output .= '</select>';
920
+
921
+        $label = '';
922
+        $help_text = '';
923
+        // label
924
+        if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
925
+        } elseif ( ! empty( $args['label'] ) && ! $label_after ) {
926
+            $label_args = array(
927
+                'title'      => $args['label'],
928
+                'for'        => $args['id'],
929
+                'class'      => $args['label_class'] . " ",
930
+                'label_type' => $args['label_type'],
931
+                'label_col'  => $args['label_col']
932
+            );
933
+            $label = self::label( $label_args );
934
+        }
935
+
936
+        // help text
937
+        if ( ! empty( $args['help_text'] ) ) {
938
+            $help_text = AUI_Component_Helper::help_text( $args['help_text'] );
939
+        }
940
+
941
+        // input group wraps
942
+        if ( $args['input_group_left'] || $args['input_group_right'] ) {
943
+            $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
944
+            if ( $args['input_group_left'] ) {
945
+                $output = self::wrap( array(
946
+                    'content'                 => $output,
947
+                    'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
948
+                    'input_group_left'        => $args['input_group_left'],
949
+                    'input_group_left_inside' => $args['input_group_left_inside']
950
+                ) );
951
+            }
952
+            if ( $args['input_group_right'] ) {
953
+                $output = self::wrap( array(
954
+                    'content'                  => $output,
955
+                    'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
956
+                    'input_group_right'        => $args['input_group_right'],
957
+                    'input_group_right_inside' => $args['input_group_right_inside']
958
+                ) );
959
+            }
960
+
961
+        }
962
+
963
+        if ( ! $label_after ) {
964
+            $output .= $help_text;
965
+        }
966
+
967
+
968
+        if ( $args['label_type'] == 'horizontal' ) {
969
+            $output = self::wrap( array(
970
+                'content' => $output,
971
+                'class'   => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' )
972
+            ) );
973
+        }
974
+
975
+        if ( ! $label_after ) {
976
+            $output = $label . $output;
977
+        }
978
+
979
+        // maybe horizontal label
980 980
 //		if ( $args['label_type'] == 'horizontal' ) {
981 981
 //			$output .= '</div>';
982 982
 //		}
983 983
 
984 984
 
985
-		// wrap
986
-		if ( ! $args['no_wrap'] ) {
987
-			$wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
988
-			$wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
989
-			$output     = self::wrap( array(
990
-				'content'         => $output,
991
-				'class'           => $wrap_class,
992
-				'element_require' => $args['element_require'],
993
-				'argument_id'     => $args['id'],
994
-				'wrap_attributes' => $args['wrap_attributes'],
995
-			) );
996
-		}
997
-
998
-
999
-		return $output;
1000
-	}
1001
-
1002
-	/**
1003
-	 * Build the component.
1004
-	 *
1005
-	 * @param array $args
1006
-	 *
1007
-	 * @return string The rendered component.
1008
-	 */
1009
-	public static function radio( $args = array() ) {
1010
-		$defaults = array(
1011
-			'class'            => '',
1012
-			'wrap_class'       => '',
1013
-			'id'               => '',
1014
-			'title'            => '',
1015
-			'horizontal'       => false,
1016
-			// sets the lable horizontal
1017
-			'value'            => '',
1018
-			'label'            => '',
1019
-			'label_class'      => '',
1020
-			'label_type'       => '',
1021
-			'label_col'        => '',
1022
-			// sets the label type, default: hidden. Options: hidden, top, horizontal, floating
1023
-			'help_text'        => '',
1024
-			'inline'           => true,
1025
-			'required'         => false,
1026
-			'options'          => array(),
1027
-			'icon'             => '',
1028
-			'no_wrap'          => false,
1029
-			'element_require'  => '',
1030
-			// [%element_id%] == "1"
1031
-			'extra_attributes' => array(),
1032
-			// an array of extra attributes
1033
-			'wrap_attributes'  => array()
1034
-		);
1035
-
1036
-		/**
1037
-		 * Parse incoming $args into an array and merge it with $defaults
1038
-		 */
1039
-		$args = wp_parse_args( $args, $defaults );
1040
-
1041
-		// for now lets use horizontal for floating
1042
-		if ( $args['label_type'] == 'floating' ) {
1043
-			$args['label_type'] = 'horizontal';
1044
-		}
1045
-
1046
-		$label_args = array(
1047
-			'title'      => $args['label'],
1048
-			'class'      => $args['label_class'] . " pt-0 ",
1049
-			'label_type' => $args['label_type'],
1050
-			'label_col'  => $args['label_col']
1051
-		);
1052
-
1053
-		$output = '';
1054
-
1055
-
1056
-		// label before
1057
-		if ( ! empty( $args['label'] ) ) {
1058
-			$output .= self::label( $label_args, 'radio' );
1059
-		}
1060
-
1061
-		// maybe horizontal label
1062
-		if ( $args['label_type'] == 'horizontal' ) {
1063
-			$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
1064
-			$output .= '<div class="' . $input_col . '">';
1065
-		}
1066
-
1067
-		if ( ! empty( $args['options'] ) ) {
1068
-			$count = 0;
1069
-			foreach ( $args['options'] as $value => $label ) {
1070
-				$option_args            = $args;
1071
-				$option_args['value']   = $value;
1072
-				$option_args['label']   = $label;
1073
-				$option_args['checked'] = $value == $args['value'] ? true : false;
1074
-				$output .= self::radio_option( $option_args, $count );
1075
-				$count ++;
1076
-			}
1077
-		}
1078
-
1079
-		// help text
1080
-		$help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : '';
1081
-		$output .= $help_text;
1082
-
1083
-		// maybe horizontal label
1084
-		if ( $args['label_type'] == 'horizontal' ) {
1085
-			$output .= '</div>';
1086
-		}
1087
-
1088
-		// wrap
1089
-		$wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
1090
-		$wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
1091
-		$output     = self::wrap( array(
1092
-			'content'         => $output,
1093
-			'class'           => $wrap_class,
1094
-			'element_require' => $args['element_require'],
1095
-			'argument_id'     => $args['id'],
1096
-			'wrap_attributes' => $args['wrap_attributes'],
1097
-		) );
1098
-
1099
-
1100
-		return $output;
1101
-	}
1102
-
1103
-	/**
1104
-	 * Build the component.
1105
-	 *
1106
-	 * @param array $args
1107
-	 *
1108
-	 * @return string The rendered component.
1109
-	 */
1110
-	public static function radio_option( $args = array(), $count = '' ) {
1111
-		$defaults = array(
1112
-			'class'            => '',
1113
-			'id'               => '',
1114
-			'title'            => '',
1115
-			'value'            => '',
1116
-			'required'         => false,
1117
-			'inline'           => true,
1118
-			'label'            => '',
1119
-			'options'          => array(),
1120
-			'icon'             => '',
1121
-			'no_wrap'          => false,
1122
-			'extra_attributes' => array() // an array of extra attributes
1123
-		);
1124
-
1125
-		/**
1126
-		 * Parse incoming $args into an array and merge it with $defaults
1127
-		 */
1128
-		$args = wp_parse_args( $args, $defaults );
1129
-
1130
-		$output = '';
1131
-
1132
-		// open/type
1133
-		$output .= '<input type="radio"';
1134
-
1135
-		// class
1136
-		$output .= ' class="form-check-input" ';
1137
-
1138
-		// name
1139
-		if ( ! empty( $args['name'] ) ) {
1140
-			$output .= AUI_Component_Helper::name( $args['name'] );
1141
-		}
1142
-
1143
-		// id
1144
-		if ( ! empty( $args['id'] ) ) {
1145
-			$output .= AUI_Component_Helper::id( $args['id'] . $count );
1146
-		}
1147
-
1148
-		// title
1149
-		if ( ! empty( $args['title'] ) ) {
1150
-			$output .= AUI_Component_Helper::title( $args['title'] );
1151
-		}
1152
-
1153
-		// value
1154
-		if ( isset( $args['value'] ) ) {
1155
-			$output .= AUI_Component_Helper::value( $args['value'] );
1156
-		}
1157
-
1158
-		// checked, for radio and checkboxes
1159
-		if ( $args['checked'] ) {
1160
-			$output .= ' checked ';
1161
-		}
1162
-
1163
-		// data-attributes
1164
-		$output .= AUI_Component_Helper::data_attributes( $args );
1165
-
1166
-		// aria-attributes
1167
-		$output .= AUI_Component_Helper::aria_attributes( $args );
1168
-
1169
-		// extra attributes
1170
-		if ( ! empty( $args['extra_attributes'] ) ) {
1171
-			$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
1172
-		}
1173
-
1174
-		// required
1175
-		if ( ! empty( $args['required'] ) ) {
1176
-			$output .= ' required ';
1177
-		}
1178
-
1179
-		// close opening tag
1180
-		$output .= ' >';
1181
-
1182
-		// label
1183
-		if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
1184
-		} elseif ( ! empty( $args['label'] ) ) {
1185
-			$output .= self::label( array(
1186
-				'title' => $args['label'],
1187
-				'for'   => $args['id'] . $count,
1188
-				'class' => 'form-check-label'
1189
-			), 'radio' );
1190
-		}
1191
-
1192
-		// wrap
1193
-		if ( ! $args['no_wrap'] ) {
1194
-			$wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
1195
-
1196
-			// Unique wrap class
1197
-			$uniq_class = 'fwrap';
1198
-			if ( ! empty( $args['name'] ) ) {
1199
-				$uniq_class .= '-' . $args['name'];
1200
-			} else if ( ! empty( $args['id'] ) ) {
1201
-				$uniq_class .= '-' . $args['id'];
1202
-			}
1203
-
1204
-			if ( isset( $args['value'] ) || $args['value'] !== "" ) {
1205
-				$uniq_class .= '-' . $args['value'];
1206
-			} else {
1207
-				$uniq_class .= '-' . $count;
1208
-			}
1209
-			$wrap_class .= ' ' . sanitize_html_class( $uniq_class );
1210
-
1211
-			$output = self::wrap( array(
1212
-				'content' => $output,
1213
-				'class'   => $wrap_class
1214
-			) );
1215
-		}
1216
-
1217
-		return $output;
1218
-	}
985
+        // wrap
986
+        if ( ! $args['no_wrap'] ) {
987
+            $wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
988
+            $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
989
+            $output     = self::wrap( array(
990
+                'content'         => $output,
991
+                'class'           => $wrap_class,
992
+                'element_require' => $args['element_require'],
993
+                'argument_id'     => $args['id'],
994
+                'wrap_attributes' => $args['wrap_attributes'],
995
+            ) );
996
+        }
997
+
998
+
999
+        return $output;
1000
+    }
1001
+
1002
+    /**
1003
+     * Build the component.
1004
+     *
1005
+     * @param array $args
1006
+     *
1007
+     * @return string The rendered component.
1008
+     */
1009
+    public static function radio( $args = array() ) {
1010
+        $defaults = array(
1011
+            'class'            => '',
1012
+            'wrap_class'       => '',
1013
+            'id'               => '',
1014
+            'title'            => '',
1015
+            'horizontal'       => false,
1016
+            // sets the lable horizontal
1017
+            'value'            => '',
1018
+            'label'            => '',
1019
+            'label_class'      => '',
1020
+            'label_type'       => '',
1021
+            'label_col'        => '',
1022
+            // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
1023
+            'help_text'        => '',
1024
+            'inline'           => true,
1025
+            'required'         => false,
1026
+            'options'          => array(),
1027
+            'icon'             => '',
1028
+            'no_wrap'          => false,
1029
+            'element_require'  => '',
1030
+            // [%element_id%] == "1"
1031
+            'extra_attributes' => array(),
1032
+            // an array of extra attributes
1033
+            'wrap_attributes'  => array()
1034
+        );
1035
+
1036
+        /**
1037
+         * Parse incoming $args into an array and merge it with $defaults
1038
+         */
1039
+        $args = wp_parse_args( $args, $defaults );
1040
+
1041
+        // for now lets use horizontal for floating
1042
+        if ( $args['label_type'] == 'floating' ) {
1043
+            $args['label_type'] = 'horizontal';
1044
+        }
1045
+
1046
+        $label_args = array(
1047
+            'title'      => $args['label'],
1048
+            'class'      => $args['label_class'] . " pt-0 ",
1049
+            'label_type' => $args['label_type'],
1050
+            'label_col'  => $args['label_col']
1051
+        );
1052
+
1053
+        $output = '';
1054
+
1055
+
1056
+        // label before
1057
+        if ( ! empty( $args['label'] ) ) {
1058
+            $output .= self::label( $label_args, 'radio' );
1059
+        }
1060
+
1061
+        // maybe horizontal label
1062
+        if ( $args['label_type'] == 'horizontal' ) {
1063
+            $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
1064
+            $output .= '<div class="' . $input_col . '">';
1065
+        }
1066
+
1067
+        if ( ! empty( $args['options'] ) ) {
1068
+            $count = 0;
1069
+            foreach ( $args['options'] as $value => $label ) {
1070
+                $option_args            = $args;
1071
+                $option_args['value']   = $value;
1072
+                $option_args['label']   = $label;
1073
+                $option_args['checked'] = $value == $args['value'] ? true : false;
1074
+                $output .= self::radio_option( $option_args, $count );
1075
+                $count ++;
1076
+            }
1077
+        }
1078
+
1079
+        // help text
1080
+        $help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : '';
1081
+        $output .= $help_text;
1082
+
1083
+        // maybe horizontal label
1084
+        if ( $args['label_type'] == 'horizontal' ) {
1085
+            $output .= '</div>';
1086
+        }
1087
+
1088
+        // wrap
1089
+        $wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
1090
+        $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
1091
+        $output     = self::wrap( array(
1092
+            'content'         => $output,
1093
+            'class'           => $wrap_class,
1094
+            'element_require' => $args['element_require'],
1095
+            'argument_id'     => $args['id'],
1096
+            'wrap_attributes' => $args['wrap_attributes'],
1097
+        ) );
1098
+
1099
+
1100
+        return $output;
1101
+    }
1102
+
1103
+    /**
1104
+     * Build the component.
1105
+     *
1106
+     * @param array $args
1107
+     *
1108
+     * @return string The rendered component.
1109
+     */
1110
+    public static function radio_option( $args = array(), $count = '' ) {
1111
+        $defaults = array(
1112
+            'class'            => '',
1113
+            'id'               => '',
1114
+            'title'            => '',
1115
+            'value'            => '',
1116
+            'required'         => false,
1117
+            'inline'           => true,
1118
+            'label'            => '',
1119
+            'options'          => array(),
1120
+            'icon'             => '',
1121
+            'no_wrap'          => false,
1122
+            'extra_attributes' => array() // an array of extra attributes
1123
+        );
1124
+
1125
+        /**
1126
+         * Parse incoming $args into an array and merge it with $defaults
1127
+         */
1128
+        $args = wp_parse_args( $args, $defaults );
1129
+
1130
+        $output = '';
1131
+
1132
+        // open/type
1133
+        $output .= '<input type="radio"';
1134
+
1135
+        // class
1136
+        $output .= ' class="form-check-input" ';
1137
+
1138
+        // name
1139
+        if ( ! empty( $args['name'] ) ) {
1140
+            $output .= AUI_Component_Helper::name( $args['name'] );
1141
+        }
1142
+
1143
+        // id
1144
+        if ( ! empty( $args['id'] ) ) {
1145
+            $output .= AUI_Component_Helper::id( $args['id'] . $count );
1146
+        }
1147
+
1148
+        // title
1149
+        if ( ! empty( $args['title'] ) ) {
1150
+            $output .= AUI_Component_Helper::title( $args['title'] );
1151
+        }
1152
+
1153
+        // value
1154
+        if ( isset( $args['value'] ) ) {
1155
+            $output .= AUI_Component_Helper::value( $args['value'] );
1156
+        }
1157
+
1158
+        // checked, for radio and checkboxes
1159
+        if ( $args['checked'] ) {
1160
+            $output .= ' checked ';
1161
+        }
1162
+
1163
+        // data-attributes
1164
+        $output .= AUI_Component_Helper::data_attributes( $args );
1165
+
1166
+        // aria-attributes
1167
+        $output .= AUI_Component_Helper::aria_attributes( $args );
1168
+
1169
+        // extra attributes
1170
+        if ( ! empty( $args['extra_attributes'] ) ) {
1171
+            $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
1172
+        }
1173
+
1174
+        // required
1175
+        if ( ! empty( $args['required'] ) ) {
1176
+            $output .= ' required ';
1177
+        }
1178
+
1179
+        // close opening tag
1180
+        $output .= ' >';
1181
+
1182
+        // label
1183
+        if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
1184
+        } elseif ( ! empty( $args['label'] ) ) {
1185
+            $output .= self::label( array(
1186
+                'title' => $args['label'],
1187
+                'for'   => $args['id'] . $count,
1188
+                'class' => 'form-check-label'
1189
+            ), 'radio' );
1190
+        }
1191
+
1192
+        // wrap
1193
+        if ( ! $args['no_wrap'] ) {
1194
+            $wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
1195
+
1196
+            // Unique wrap class
1197
+            $uniq_class = 'fwrap';
1198
+            if ( ! empty( $args['name'] ) ) {
1199
+                $uniq_class .= '-' . $args['name'];
1200
+            } else if ( ! empty( $args['id'] ) ) {
1201
+                $uniq_class .= '-' . $args['id'];
1202
+            }
1203
+
1204
+            if ( isset( $args['value'] ) || $args['value'] !== "" ) {
1205
+                $uniq_class .= '-' . $args['value'];
1206
+            } else {
1207
+                $uniq_class .= '-' . $count;
1208
+            }
1209
+            $wrap_class .= ' ' . sanitize_html_class( $uniq_class );
1210
+
1211
+            $output = self::wrap( array(
1212
+                'content' => $output,
1213
+                'class'   => $wrap_class
1214
+            ) );
1215
+        }
1216
+
1217
+        return $output;
1218
+    }
1219 1219
 
1220 1220
 }
1221 1221
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +284 added lines, -284 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
 	exit; // Exit if accessed directly
5 5
 }
6 6
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 *
19 19
 	 * @return string The rendered component.
20 20
 	 */
21
-	public static function input( $args = array() ) {
21
+	public static function input($args = array()) {
22 22
 		$defaults = array(
23 23
 			'type'                     => 'text',
24 24
 			'name'                     => '',
@@ -63,13 +63,13 @@  discard block
 block discarded – undo
63 63
 		/**
64 64
 		 * Parse incoming $args into an array and merge it with $defaults
65 65
 		 */
66
-		$args   = wp_parse_args( $args, $defaults );
66
+		$args   = wp_parse_args($args, $defaults);
67 67
 		$output = '';
68
-		if ( ! empty( $args['type'] ) ) {
68
+		if (!empty($args['type'])) {
69 69
 			// hidden label option needs to be empty
70 70
 			$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
71 71
 
72
-			$type = sanitize_html_class( $args['type'] );
72
+			$type = sanitize_html_class($args['type']);
73 73
 
74 74
 			$help_text   = '';
75 75
 			$label       = '';
@@ -83,19 +83,19 @@  discard block
 block discarded – undo
83 83
 			);
84 84
 
85 85
 			// floating labels need label after
86
-			if ( $args['label_type'] == 'floating' && $type != 'checkbox' ) {
86
+			if ($args['label_type'] == 'floating' && $type != 'checkbox') {
87 87
 				$label_after         = true;
88 88
 				$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
89 89
 			}
90 90
 
91 91
 			// Some special sauce for files
92
-			if ( $type == 'file' ) {
92
+			if ($type == 'file') {
93 93
 				$label_after = true; // if type file we need the label after
94 94
 				$args['class'] .= ' custom-file-input ';
95
-			} elseif ( $type == 'checkbox' ) {
95
+			} elseif ($type == 'checkbox') {
96 96
 				$label_after = true; // if type file we need the label after
97 97
 				$args['class'] .= ' custom-control-input ';
98
-			} elseif ( $type == 'datepicker' || $type == 'timepicker' ) {
98
+			} elseif ($type == 'datepicker' || $type == 'timepicker') {
99 99
 				$type = 'text';
100 100
 				//$args['class'] .= ' aui-flatpickr bg-initial ';
101 101
 				$args['class'] .= ' bg-initial ';
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 				// enqueue the script
105 105
 				$aui_settings = AyeCode_UI_Settings::instance();
106 106
 				$aui_settings->enqueue_flatpickr();
107
-			} elseif ( $type == 'iconpicker' ) {
107
+			} elseif ($type == 'iconpicker') {
108 108
 				$type = 'text';
109 109
 				//$args['class'] .= ' aui-flatpickr bg-initial ';
110 110
 //				$args['class'] .= ' bg-initial ';
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
 				$aui_settings->enqueue_iconpicker();
120 120
 			}
121 121
 
122
-			if ( $type == 'checkbox' && !empty($args['name'] ) && strpos($args['name'], '[') === false ) {
123
-				$output .= '<input type="hidden" name="' . esc_attr( $args['name'] ) . '" value="0" />';
122
+			if ($type == 'checkbox' && !empty($args['name']) && strpos($args['name'], '[') === false) {
123
+				$output .= '<input type="hidden" name="' . esc_attr($args['name']) . '" value="0" />';
124 124
 			}
125 125
 
126 126
 
@@ -128,88 +128,88 @@  discard block
 block discarded – undo
128 128
 			$output .= '<input type="' . $type . '" ';
129 129
 
130 130
 			// name
131
-			if ( ! empty( $args['name'] ) ) {
132
-				$output .= ' name="' . esc_attr( $args['name'] ) . '" ';
131
+			if (!empty($args['name'])) {
132
+				$output .= ' name="' . esc_attr($args['name']) . '" ';
133 133
 			}
134 134
 
135 135
 			// id
136
-			if ( ! empty( $args['id'] ) ) {
137
-				$output .= ' id="' . sanitize_html_class( $args['id'] ) . '" ';
136
+			if (!empty($args['id'])) {
137
+				$output .= ' id="' . sanitize_html_class($args['id']) . '" ';
138 138
 			}
139 139
 
140 140
 			// placeholder
141
-			if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) {
142
-				$output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" ';
141
+			if (isset($args['placeholder']) && '' != $args['placeholder']) {
142
+				$output .= ' placeholder="' . esc_attr($args['placeholder']) . '" ';
143 143
 			}
144 144
 
145 145
 			// title
146
-			if ( ! empty( $args['title'] ) ) {
147
-				$output .= ' title="' . esc_attr( $args['title'] ) . '" ';
146
+			if (!empty($args['title'])) {
147
+				$output .= ' title="' . esc_attr($args['title']) . '" ';
148 148
 			}
149 149
 
150 150
 			// value
151
-			if ( ! empty( $args['value'] ) ) {
152
-				$output .= AUI_Component_Helper::value( $args['value'] );
151
+			if (!empty($args['value'])) {
152
+				$output .= AUI_Component_Helper::value($args['value']);
153 153
 			}
154 154
 
155 155
 			// checked, for radio and checkboxes
156
-			if ( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ) {
156
+			if (($type == 'checkbox' || $type == 'radio') && $args['checked']) {
157 157
 				$output .= ' checked ';
158 158
 			}
159 159
 
160 160
 			// validation text
161
-			if ( ! empty( $args['validation_text'] ) ) {
162
-				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" ';
161
+			if (!empty($args['validation_text'])) {
162
+				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" ';
163 163
 				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
164 164
 			}
165 165
 
166 166
 			// validation_pattern
167
-			if ( ! empty( $args['validation_pattern'] ) ) {
168
-				$output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
167
+			if (!empty($args['validation_pattern'])) {
168
+				$output .= ' pattern="' . esc_attr($args['validation_pattern']) . '" ';
169 169
 			}
170 170
 
171 171
 			// step (for numbers)
172
-			if ( ! empty( $args['step'] ) ) {
172
+			if (!empty($args['step'])) {
173 173
 				$output .= ' step="' . $args['step'] . '" ';
174 174
 			}
175 175
 
176 176
 			// required
177
-			if ( ! empty( $args['required'] ) ) {
177
+			if (!empty($args['required'])) {
178 178
 				$output .= ' required ';
179 179
 			}
180 180
 
181 181
 			// class
182
-			$class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
182
+			$class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : '';
183 183
 			$output .= ' class="form-control ' . $class . '" ';
184 184
 
185 185
 			// data-attributes
186
-			$output .= AUI_Component_Helper::data_attributes( $args );
186
+			$output .= AUI_Component_Helper::data_attributes($args);
187 187
 
188 188
 			// extra attributes
189
-			if ( ! empty( $args['extra_attributes'] ) ) {
190
-				$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
189
+			if (!empty($args['extra_attributes'])) {
190
+				$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
191 191
 			}
192 192
 
193 193
 			// close
194 194
 			$output .= ' >';
195 195
 
196 196
 			// help text
197
-			if ( ! empty( $args['help_text'] ) ) {
198
-				$help_text = AUI_Component_Helper::help_text( $args['help_text'] );
197
+			if (!empty($args['help_text'])) {
198
+				$help_text = AUI_Component_Helper::help_text($args['help_text']);
199 199
 			}
200 200
 
201 201
 			// label
202
-			if ( ! empty( $args['label'] ) ) {
202
+			if (!empty($args['label'])) {
203 203
 				$label_base_class = '';
204
-				if ( $type == 'file' ) {
204
+				if ($type == 'file') {
205 205
 					$label_base_class = ' custom-file-label';
206
-				} elseif ( $type == 'checkbox' ) {
207
-					if ( ! empty( $args['label_force_left'] ) ) {
208
-						$label_args['title'] = wp_kses_post( $args['help_text'] );
206
+				} elseif ($type == 'checkbox') {
207
+					if (!empty($args['label_force_left'])) {
208
+						$label_args['title'] = wp_kses_post($args['help_text']);
209 209
 						$help_text = '';
210 210
 						//$label_args['class'] .= ' d-inline ';
211 211
 						$args['wrap_class'] .= ' align-items-center ';
212
-					}else{
212
+					} else {
213 213
 
214 214
 					}
215 215
 
@@ -217,45 +217,45 @@  discard block
 block discarded – undo
217 217
 				}
218 218
 				$label_args['class'] .= $label_base_class;
219 219
 				$temp_label_args = $label_args;
220
-				if(! empty( $args['label_force_left'] )){$temp_label_args['class'] = $label_base_class." text-muted";}
221
-				$label = self::label( $temp_label_args, $type );
220
+				if (!empty($args['label_force_left'])) {$temp_label_args['class'] = $label_base_class . " text-muted"; }
221
+				$label = self::label($temp_label_args, $type);
222 222
 			}
223 223
 
224 224
 
225 225
 
226 226
 
227 227
 			// set help text in the correct position
228
-			if ( $label_after ) {
228
+			if ($label_after) {
229 229
 				$output .= $label . $help_text;
230 230
 			}
231 231
 
232 232
 			// some input types need a separate wrap
233
-			if ( $type == 'file' ) {
234
-				$output = self::wrap( array(
233
+			if ($type == 'file') {
234
+				$output = self::wrap(array(
235 235
 					'content' => $output,
236 236
 					'class'   => 'form-group custom-file'
237
-				) );
238
-			} elseif ( $type == 'checkbox' ) {
237
+				));
238
+			} elseif ($type == 'checkbox') {
239 239
 
240 240
 				$label_args['title'] = $args['label'];
241
-				$label_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'label' );
242
-				$label = !empty( $args['label_force_left'] ) ? self::label( $label_args, 'cb' ) : '<div class="' . $label_col . ' col-form-label"></div>';
243
-				$switch_size_class = $args['switch'] && !is_bool( $args['switch'] ) ? ' custom-switch-'.esc_attr( $args['switch'] ) : '';
244
-				$wrap_class = $args['switch'] ? 'custom-switch'.$switch_size_class : 'custom-checkbox';
245
-				if ( ! empty( $args['label_force_left'] ) ) {
241
+				$label_col = AUI_Component_Helper::get_column_class($args['label_col'], 'label');
242
+				$label = !empty($args['label_force_left']) ? self::label($label_args, 'cb') : '<div class="' . $label_col . ' col-form-label"></div>';
243
+				$switch_size_class = $args['switch'] && !is_bool($args['switch']) ? ' custom-switch-' . esc_attr($args['switch']) : '';
244
+				$wrap_class = $args['switch'] ? 'custom-switch' . $switch_size_class : 'custom-checkbox';
245
+				if (!empty($args['label_force_left'])) {
246 246
 					$wrap_class .= ' d-flex align-content-center';
247
-					$label = str_replace("custom-control-label","", self::label( $label_args, 'cb' ) );
247
+					$label = str_replace("custom-control-label", "", self::label($label_args, 'cb'));
248 248
 				}
249
-				$output     = self::wrap( array(
249
+				$output = self::wrap(array(
250 250
 					'content' => $output,
251 251
 					'class'   => 'custom-control ' . $wrap_class
252
-				) );
252
+				));
253 253
 
254
-				if ( $args['label_type'] == 'horizontal' ) {
255
-					$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
254
+				if ($args['label_type'] == 'horizontal') {
255
+					$input_col = AUI_Component_Helper::get_column_class($args['label_col'], 'input');
256 256
 					$output    = $label . '<div class="' . $input_col . '">' . $output . '</div>';
257 257
 				}
258
-			} elseif ( $type == 'password' && $args['password_toggle'] && ! $args['input_group_right'] ) {
258
+			} elseif ($type == 'password' && $args['password_toggle'] && !$args['input_group_right']) {
259 259
 
260 260
 
261 261
 				// allow password field to toggle view
@@ -269,62 +269,62 @@  discard block
 block discarded – undo
269 269
 			}
270 270
 
271 271
 			// input group wraps
272
-			if ( $args['input_group_left'] || $args['input_group_right'] ) {
273
-				$w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
274
-				if ( $args['input_group_left'] ) {
275
-					$output = self::wrap( array(
272
+			if ($args['input_group_left'] || $args['input_group_right']) {
273
+				$w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
274
+				if ($args['input_group_left']) {
275
+					$output = self::wrap(array(
276 276
 						'content'                 => $output,
277 277
 						'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
278 278
 						'input_group_left'        => $args['input_group_left'],
279 279
 						'input_group_left_inside' => $args['input_group_left_inside']
280
-					) );
280
+					));
281 281
 				}
282
-				if ( $args['input_group_right'] ) {
283
-					$output = self::wrap( array(
282
+				if ($args['input_group_right']) {
283
+					$output = self::wrap(array(
284 284
 						'content'                  => $output,
285 285
 						'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
286 286
 						'input_group_right'        => $args['input_group_right'],
287 287
 						'input_group_right_inside' => $args['input_group_right_inside']
288
-					) );
288
+					));
289 289
 				}
290 290
 
291 291
 			}
292 292
 
293
-			if ( ! $label_after ) {
293
+			if (!$label_after) {
294 294
 				$output .= $help_text;
295 295
 			}
296 296
 
297 297
 
298
-			if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) {
299
-				$output = self::wrap( array(
298
+			if ($args['label_type'] == 'horizontal' && $type != 'checkbox') {
299
+				$output = self::wrap(array(
300 300
 					'content' => $output,
301
-					'class'   => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' )
302
-				) );
301
+					'class'   => AUI_Component_Helper::get_column_class($args['label_col'], 'input')
302
+				));
303 303
 			}
304 304
 
305
-			if ( ! $label_after ) {
305
+			if (!$label_after) {
306 306
 				$output = $label . $output;
307 307
 			}
308 308
 
309 309
 			// wrap
310
-			if ( ! $args['no_wrap'] ) {
310
+			if (!$args['no_wrap']) {
311 311
 				$form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
312 312
 				$wrap_class       = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
313
-				$wrap_class       = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
314
-				$output           = self::wrap( array(
313
+				$wrap_class       = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
314
+				$output           = self::wrap(array(
315 315
 					'content'         => $output,
316 316
 					'class'           => $wrap_class,
317 317
 					'element_require' => $args['element_require'],
318 318
 					'argument_id'     => $args['id'],
319 319
 					'wrap_attributes' => $args['wrap_attributes'],
320
-				) );
320
+				));
321 321
 			}
322 322
 		}
323 323
 
324 324
 		return $output;
325 325
 	}
326 326
 
327
-	public static function label( $args = array(), $type = '' ) {
327
+	public static function label($args = array(), $type = '') {
328 328
 		//<label for="exampleInputEmail1">Email address</label>
329 329
 		$defaults = array(
330 330
 			'title'      => 'div',
@@ -337,33 +337,33 @@  discard block
 block discarded – undo
337 337
 		/**
338 338
 		 * Parse incoming $args into an array and merge it with $defaults
339 339
 		 */
340
-		$args   = wp_parse_args( $args, $defaults );
340
+		$args   = wp_parse_args($args, $defaults);
341 341
 		$output = '';
342 342
 
343
-		if ( $args['title'] ) {
343
+		if ($args['title']) {
344 344
 
345 345
 			// maybe hide labels //@todo set a global option for visibility class
346
-			if ( $type == 'file' || $type == 'checkbox' || $type == 'radio' || ! empty( $args['label_type'] ) ) {
346
+			if ($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type'])) {
347 347
 				$class = $args['class'];
348 348
 			} else {
349 349
 				$class = 'sr-only ' . $args['class'];
350 350
 			}
351 351
 
352 352
 			// maybe horizontal
353
-			if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) {
354
-				$class .= ' ' . AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ) . ' col-form-label';
353
+			if ($args['label_type'] == 'horizontal' && $type != 'checkbox') {
354
+				$class .= ' ' . AUI_Component_Helper::get_column_class($args['label_col'], 'label') . ' col-form-label';
355 355
 			}
356 356
 
357 357
 			// open
358 358
 			$output .= '<label ';
359 359
 
360 360
 			// for
361
-			if ( ! empty( $args['for'] ) ) {
362
-				$output .= ' for="' . esc_attr( $args['for'] ) . '" ';
361
+			if (!empty($args['for'])) {
362
+				$output .= ' for="' . esc_attr($args['for']) . '" ';
363 363
 			}
364 364
 
365 365
 			// class
366
-			$class = $class ? AUI_Component_Helper::esc_classes( $class ) : '';
366
+			$class = $class ? AUI_Component_Helper::esc_classes($class) : '';
367 367
 			$output .= ' class="' . $class . '" ';
368 368
 
369 369
 			// close
@@ -371,8 +371,8 @@  discard block
 block discarded – undo
371 371
 
372 372
 
373 373
 			// title, don't escape fully as can contain html
374
-			if ( ! empty( $args['title'] ) ) {
375
-				$output .= wp_kses_post( $args['title'] );
374
+			if (!empty($args['title'])) {
375
+				$output .= wp_kses_post($args['title']);
376 376
 			}
377 377
 
378 378
 			// close wrap
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 	 *
393 393
 	 * @return string
394 394
 	 */
395
-	public static function wrap( $args = array() ) {
395
+	public static function wrap($args = array()) {
396 396
 		$defaults = array(
397 397
 			'type'                     => 'div',
398 398
 			'class'                    => 'form-group',
@@ -409,31 +409,31 @@  discard block
 block discarded – undo
409 409
 		/**
410 410
 		 * Parse incoming $args into an array and merge it with $defaults
411 411
 		 */
412
-		$args   = wp_parse_args( $args, $defaults );
412
+		$args   = wp_parse_args($args, $defaults);
413 413
 		$output = '';
414
-		if ( $args['type'] ) {
414
+		if ($args['type']) {
415 415
 
416 416
 			// open
417
-			$output .= '<' . sanitize_html_class( $args['type'] );
417
+			$output .= '<' . sanitize_html_class($args['type']);
418 418
 
419 419
 			// element require
420
-			if ( ! empty( $args['element_require'] ) ) {
421
-				$output .= AUI_Component_Helper::element_require( $args['element_require'] );
420
+			if (!empty($args['element_require'])) {
421
+				$output .= AUI_Component_Helper::element_require($args['element_require']);
422 422
 				$args['class'] .= " aui-conditional-field";
423 423
 			}
424 424
 
425 425
 			// argument_id
426
-			if ( ! empty( $args['argument_id'] ) ) {
427
-				$output .= ' data-argument="' . esc_attr( $args['argument_id'] ) . '"';
426
+			if (!empty($args['argument_id'])) {
427
+				$output .= ' data-argument="' . esc_attr($args['argument_id']) . '"';
428 428
 			}
429 429
 
430 430
 			// class
431
-			$class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
431
+			$class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : '';
432 432
 			$output .= ' class="' . $class . '" ';
433 433
 
434 434
 			// Attributes
435
-			if ( ! empty( $args['wrap_attributes'] ) ) {
436
-				$output .= AUI_Component_Helper::extra_attributes( $args['wrap_attributes'] );
435
+			if (!empty($args['wrap_attributes'])) {
436
+				$output .= AUI_Component_Helper::extra_attributes($args['wrap_attributes']);
437 437
 			}
438 438
 
439 439
 			// close wrap
@@ -441,9 +441,9 @@  discard block
 block discarded – undo
441 441
 
442 442
 
443 443
 			// Input group left
444
-			if ( ! empty( $args['input_group_left'] ) ) {
445
-				$position_class   = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : '';
446
-				$input_group_left = strpos( $args['input_group_left'], '<' ) !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>';
444
+			if (!empty($args['input_group_left'])) {
445
+				$position_class   = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
446
+				$input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>';
447 447
 				$output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>';
448 448
 			}
449 449
 
@@ -451,15 +451,15 @@  discard block
 block discarded – undo
451 451
 			$output .= $args['content'];
452 452
 
453 453
 			// Input group right
454
-			if ( ! empty( $args['input_group_right'] ) ) {
455
-				$position_class    = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : '';
456
-				$input_group_right = strpos( $args['input_group_right'], '<' ) !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>';
454
+			if (!empty($args['input_group_right'])) {
455
+				$position_class    = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
456
+				$input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>';
457 457
 				$output .= '<div class="input-group-append ' . $position_class . '">' . $input_group_right . '</div>';
458 458
 			}
459 459
 
460 460
 
461 461
 			// close wrap
462
-			$output .= '</' . sanitize_html_class( $args['type'] ) . '>';
462
+			$output .= '</' . sanitize_html_class($args['type']) . '>';
463 463
 
464 464
 
465 465
 		} else {
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 	 *
477 477
 	 * @return string The rendered component.
478 478
 	 */
479
-	public static function textarea( $args = array() ) {
479
+	public static function textarea($args = array()) {
480 480
 		$defaults = array(
481 481
 			'name'               => '',
482 482
 			'class'              => '',
@@ -513,28 +513,28 @@  discard block
 block discarded – undo
513 513
 		/**
514 514
 		 * Parse incoming $args into an array and merge it with $defaults
515 515
 		 */
516
-		$args   = wp_parse_args( $args, $defaults );
516
+		$args   = wp_parse_args($args, $defaults);
517 517
 		$output = '';
518 518
 
519 519
 		// hidden label option needs to be empty
520 520
 		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
521 521
 
522 522
 		// floating labels don't work with wysiwyg so set it as top
523
-		if ( $args['label_type'] == 'floating' && ! empty( $args['wysiwyg'] ) ) {
523
+		if ($args['label_type'] == 'floating' && !empty($args['wysiwyg'])) {
524 524
 			$args['label_type'] = 'top';
525 525
 		}
526 526
 
527 527
 		$label_after = $args['label_after'];
528 528
 
529 529
 		// floating labels need label after
530
-		if ( $args['label_type'] == 'floating' && empty( $args['wysiwyg'] ) ) {
530
+		if ($args['label_type'] == 'floating' && empty($args['wysiwyg'])) {
531 531
 			$label_after         = true;
532 532
 			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
533 533
 		}
534 534
 
535 535
 		// label
536
-		if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
537
-		} elseif ( ! empty( $args['label'] ) && ! $label_after ) {
536
+		if (!empty($args['label']) && is_array($args['label'])) {
537
+		} elseif (!empty($args['label']) && !$label_after) {
538 538
 			$label_args = array(
539 539
 				'title'      => $args['label'],
540 540
 				'for'        => $args['id'],
@@ -542,34 +542,34 @@  discard block
 block discarded – undo
542 542
 				'label_type' => $args['label_type'],
543 543
 				'label_col'  => $args['label_col']
544 544
 			);
545
-			$output .= self::label( $label_args );
545
+			$output .= self::label($label_args);
546 546
 		}
547 547
 
548 548
 		// maybe horizontal label
549
-		if ( $args['label_type'] == 'horizontal' ) {
550
-			$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
549
+		if ($args['label_type'] == 'horizontal') {
550
+			$input_col = AUI_Component_Helper::get_column_class($args['label_col'], 'input');
551 551
 			$output .= '<div class="' . $input_col . '">';
552 552
 		}
553 553
 
554
-		if ( ! empty( $args['wysiwyg'] ) ) {
554
+		if (!empty($args['wysiwyg'])) {
555 555
 			ob_start();
556 556
 			$content   = $args['value'];
557
-			$editor_id = ! empty( $args['id'] ) ? sanitize_html_class( $args['id'] ) : 'wp_editor';
557
+			$editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor';
558 558
 			$settings  = array(
559
-				'textarea_rows' => ! empty( absint( $args['rows'] ) ) ? absint( $args['rows'] ) : 4,
559
+				'textarea_rows' => !empty(absint($args['rows'])) ? absint($args['rows']) : 4,
560 560
 				'quicktags'     => false,
561 561
 				'media_buttons' => false,
562 562
 				'editor_class'  => 'form-control',
563
-				'textarea_name' => ! empty( $args['name'] ) ? sanitize_html_class( $args['name'] ) : sanitize_html_class( $args['id'] ),
563
+				'textarea_name' => !empty($args['name']) ? sanitize_html_class($args['name']) : sanitize_html_class($args['id']),
564 564
 				'teeny'         => true,
565 565
 			);
566 566
 
567 567
 			// maybe set settings if array
568
-			if ( is_array( $args['wysiwyg'] ) ) {
569
-				$settings = wp_parse_args( $args['wysiwyg'], $settings );
568
+			if (is_array($args['wysiwyg'])) {
569
+				$settings = wp_parse_args($args['wysiwyg'], $settings);
570 570
 			}
571 571
 
572
-			wp_editor( $content, $editor_id, $settings );
572
+			wp_editor($content, $editor_id, $settings);
573 573
 			$output .= ob_get_clean();
574 574
 		} else {
575 575
 
@@ -577,65 +577,65 @@  discard block
 block discarded – undo
577 577
 			$output .= '<textarea ';
578 578
 
579 579
 			// name
580
-			if ( ! empty( $args['name'] ) ) {
581
-				$output .= ' name="' . esc_attr( $args['name'] ) . '" ';
580
+			if (!empty($args['name'])) {
581
+				$output .= ' name="' . esc_attr($args['name']) . '" ';
582 582
 			}
583 583
 
584 584
 			// id
585
-			if ( ! empty( $args['id'] ) ) {
586
-				$output .= ' id="' . sanitize_html_class( $args['id'] ) . '" ';
585
+			if (!empty($args['id'])) {
586
+				$output .= ' id="' . sanitize_html_class($args['id']) . '" ';
587 587
 			}
588 588
 
589 589
 			// placeholder
590
-			if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) {
591
-				$output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" ';
590
+			if (isset($args['placeholder']) && '' != $args['placeholder']) {
591
+				$output .= ' placeholder="' . esc_attr($args['placeholder']) . '" ';
592 592
 			}
593 593
 
594 594
 			// title
595
-			if ( ! empty( $args['title'] ) ) {
596
-				$output .= ' title="' . esc_attr( $args['title'] ) . '" ';
595
+			if (!empty($args['title'])) {
596
+				$output .= ' title="' . esc_attr($args['title']) . '" ';
597 597
 			}
598 598
 
599 599
 			// validation text
600
-			if ( ! empty( $args['validation_text'] ) ) {
601
-				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" ';
600
+			if (!empty($args['validation_text'])) {
601
+				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" ';
602 602
 				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
603 603
 			}
604 604
 
605 605
 			// validation_pattern
606
-			if ( ! empty( $args['validation_pattern'] ) ) {
607
-				$output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
606
+			if (!empty($args['validation_pattern'])) {
607
+				$output .= ' pattern="' . esc_attr($args['validation_pattern']) . '" ';
608 608
 			}
609 609
 
610 610
 			// required
611
-			if ( ! empty( $args['required'] ) ) {
611
+			if (!empty($args['required'])) {
612 612
 				$output .= ' required ';
613 613
 			}
614 614
 
615 615
 			// rows
616
-			if ( ! empty( $args['rows'] ) ) {
617
-				$output .= ' rows="' . absint( $args['rows'] ) . '" ';
616
+			if (!empty($args['rows'])) {
617
+				$output .= ' rows="' . absint($args['rows']) . '" ';
618 618
 			}
619 619
 
620 620
 
621 621
 			// class
622
-			$class = ! empty( $args['class'] ) ? $args['class'] : '';
622
+			$class = !empty($args['class']) ? $args['class'] : '';
623 623
 			$output .= ' class="form-control ' . $class . '" ';
624 624
 
625 625
 			// extra attributes
626
-			if ( ! empty( $args['extra_attributes'] ) ) {
627
-				$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
626
+			if (!empty($args['extra_attributes'])) {
627
+				$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
628 628
 			}
629 629
 
630 630
 			// close tag
631 631
 			$output .= ' >';
632 632
 
633 633
 			// value
634
-			if ( ! empty( $args['value'] ) ) {
635
-				if ( ! empty( $args['allow_tags'] ) ) {
636
-					$output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML.
634
+			if (!empty($args['value'])) {
635
+				if (!empty($args['allow_tags'])) {
636
+					$output .= AUI_Component_Helper::sanitize_html_field($args['value'], $args); // Sanitize HTML.
637 637
 				} else {
638
-					$output .= AUI_Component_Helper::sanitize_textarea_field( $args['value'] );
638
+					$output .= AUI_Component_Helper::sanitize_textarea_field($args['value']);
639 639
 				}
640 640
 			}
641 641
 
@@ -644,23 +644,23 @@  discard block
 block discarded – undo
644 644
 
645 645
 
646 646
 			// input group wraps
647
-			if ( $args['input_group_left'] || $args['input_group_right'] ) {
648
-				$w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
649
-				if ( $args['input_group_left'] ) {
650
-					$output = self::wrap( array(
647
+			if ($args['input_group_left'] || $args['input_group_right']) {
648
+				$w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
649
+				if ($args['input_group_left']) {
650
+					$output = self::wrap(array(
651 651
 						'content'                 => $output,
652 652
 						'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
653 653
 						'input_group_left'        => $args['input_group_left'],
654 654
 						'input_group_left_inside' => $args['input_group_left_inside']
655
-					) );
655
+					));
656 656
 				}
657
-				if ( $args['input_group_right'] ) {
658
-					$output = self::wrap( array(
657
+				if ($args['input_group_right']) {
658
+					$output = self::wrap(array(
659 659
 						'content'                  => $output,
660 660
 						'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
661 661
 						'input_group_right'        => $args['input_group_right'],
662 662
 						'input_group_right_inside' => $args['input_group_right_inside']
663
-					) );
663
+					));
664 664
 				}
665 665
 
666 666
 			}
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
 
669 669
 		}
670 670
 
671
-		if ( ! empty( $args['label'] ) && $label_after ) {
671
+		if (!empty($args['label']) && $label_after) {
672 672
 			$label_args = array(
673 673
 				'title'      => $args['label'],
674 674
 				'for'        => $args['id'],
@@ -676,32 +676,32 @@  discard block
 block discarded – undo
676 676
 				'label_type' => $args['label_type'],
677 677
 				'label_col'  => $args['label_col']
678 678
 			);
679
-			$output .= self::label( $label_args );
679
+			$output .= self::label($label_args);
680 680
 		}
681 681
 
682 682
 		// help text
683
-		if ( ! empty( $args['help_text'] ) ) {
684
-			$output .= AUI_Component_Helper::help_text( $args['help_text'] );
683
+		if (!empty($args['help_text'])) {
684
+			$output .= AUI_Component_Helper::help_text($args['help_text']);
685 685
 		}
686 686
 
687 687
 		// maybe horizontal label
688
-		if ( $args['label_type'] == 'horizontal' ) {
688
+		if ($args['label_type'] == 'horizontal') {
689 689
 			$output .= '</div>';
690 690
 		}
691 691
 
692 692
 
693 693
 		// wrap
694
-		if ( ! $args['no_wrap'] ) {
694
+		if (!$args['no_wrap']) {
695 695
 			$form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : 'form-group';
696 696
 			$wrap_class       = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
697
-			$wrap_class       = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
698
-			$output           = self::wrap( array(
697
+			$wrap_class       = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
698
+			$output           = self::wrap(array(
699 699
 				'content'         => $output,
700 700
 				'class'           => $wrap_class,
701 701
 				'element_require' => $args['element_require'],
702 702
 				'argument_id'     => $args['id'],
703 703
 				'wrap_attributes' => $args['wrap_attributes'],
704
-			) );
704
+			));
705 705
 		}
706 706
 
707 707
 
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
 	 *
716 716
 	 * @return string The rendered component.
717 717
 	 */
718
-	public static function select( $args = array() ) {
718
+	public static function select($args = array()) {
719 719
 		$defaults = array(
720 720
 			'class'            => '',
721 721
 			'wrap_class'       => '',
@@ -752,11 +752,11 @@  discard block
 block discarded – undo
752 752
 		/**
753 753
 		 * Parse incoming $args into an array and merge it with $defaults
754 754
 		 */
755
-		$args   = wp_parse_args( $args, $defaults );
755
+		$args   = wp_parse_args($args, $defaults);
756 756
 		$output = '';
757 757
 
758 758
 		// for now lets hide floating labels
759
-		if ( $args['label_type'] == 'floating' ) {
759
+		if ($args['label_type'] == 'floating') {
760 760
 			$args['label_type'] = 'hidden';
761 761
 		}
762 762
 
@@ -767,31 +767,31 @@  discard block
 block discarded – undo
767 767
 		$label_after = $args['label_after'];
768 768
 
769 769
 		// floating labels need label after
770
-		if ( $args['label_type'] == 'floating' ) {
770
+		if ($args['label_type'] == 'floating') {
771 771
 			$label_after         = true;
772 772
 			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
773 773
 		}
774 774
 
775 775
 		// Maybe setup select2
776 776
 		$is_select2 = false;
777
-		if ( ! empty( $args['select2'] ) ) {
777
+		if (!empty($args['select2'])) {
778 778
 			$args['class'] .= ' aui-select2';
779 779
 			$is_select2 = true;
780
-		} elseif ( strpos( $args['class'], 'aui-select2' ) !== false ) {
780
+		} elseif (strpos($args['class'], 'aui-select2') !== false) {
781 781
 			$is_select2 = true;
782 782
 		}
783 783
 
784 784
 		// select2 tags
785
-		if ( ! empty( $args['select2'] ) && $args['select2'] === 'tags' ) { // triple equals needed here for some reason
785
+		if (!empty($args['select2']) && $args['select2'] === 'tags') { // triple equals needed here for some reason
786 786
 			$args['data-tags']             = 'true';
787 787
 			$args['data-token-separators'] = "[',']";
788 788
 			$args['multiple']              = true;
789 789
 		}
790 790
 
791 791
 		// select2 placeholder
792
-		if ( $is_select2 && isset( $args['placeholder'] ) && '' != $args['placeholder'] && empty( $args['data-placeholder'] ) ) {
793
-			$args['data-placeholder'] = esc_attr( $args['placeholder'] );
794
-			$args['data-allow-clear'] = isset( $args['data-allow-clear'] ) ? (bool) $args['data-allow-clear'] : true;
792
+		if ($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])) {
793
+			$args['data-placeholder'] = esc_attr($args['placeholder']);
794
+			$args['data-allow-clear'] = isset($args['data-allow-clear']) ? (bool) $args['data-allow-clear'] : true;
795 795
 		}
796 796
 
797 797
 
@@ -803,61 +803,61 @@  discard block
 block discarded – undo
803 803
 //		}
804 804
 
805 805
 		// Set hidden input to save empty value for multiselect.
806
-		if ( ! empty( $args['multiple'] ) && ! empty( $args['name'] ) ) {
807
-			$output .= '<input type="hidden" ' . AUI_Component_Helper::name( $args['name'] ) . ' value=""/>';
806
+		if (!empty($args['multiple']) && !empty($args['name'])) {
807
+			$output .= '<input type="hidden" ' . AUI_Component_Helper::name($args['name']) . ' value=""/>';
808 808
 		}
809 809
 
810 810
 		// open/type
811 811
 		$output .= '<select ';
812 812
 
813 813
 		// style
814
-		if ( $is_select2 && !($args['input_group_left'] || $args['input_group_right'])) {
814
+		if ($is_select2 && !($args['input_group_left'] || $args['input_group_right'])) {
815 815
 			$output .= " style='width:100%;' ";
816 816
 		}
817 817
 
818 818
 		// element require
819
-		if ( ! empty( $args['element_require'] ) ) {
820
-			$output .= AUI_Component_Helper::element_require( $args['element_require'] );
819
+		if (!empty($args['element_require'])) {
820
+			$output .= AUI_Component_Helper::element_require($args['element_require']);
821 821
 			$args['class'] .= " aui-conditional-field";
822 822
 		}
823 823
 
824 824
 		// class
825
-		$class = ! empty( $args['class'] ) ? $args['class'] : '';
826
-		$output .= AUI_Component_Helper::class_attr( 'custom-select ' . $class );
825
+		$class = !empty($args['class']) ? $args['class'] : '';
826
+		$output .= AUI_Component_Helper::class_attr('custom-select ' . $class);
827 827
 
828 828
 		// name
829
-		if ( ! empty( $args['name'] ) ) {
830
-			$output .= AUI_Component_Helper::name( $args['name'], $args['multiple'] );
829
+		if (!empty($args['name'])) {
830
+			$output .= AUI_Component_Helper::name($args['name'], $args['multiple']);
831 831
 		}
832 832
 
833 833
 		// id
834
-		if ( ! empty( $args['id'] ) ) {
835
-			$output .= AUI_Component_Helper::id( $args['id'] );
834
+		if (!empty($args['id'])) {
835
+			$output .= AUI_Component_Helper::id($args['id']);
836 836
 		}
837 837
 
838 838
 		// title
839
-		if ( ! empty( $args['title'] ) ) {
840
-			$output .= AUI_Component_Helper::title( $args['title'] );
839
+		if (!empty($args['title'])) {
840
+			$output .= AUI_Component_Helper::title($args['title']);
841 841
 		}
842 842
 
843 843
 		// data-attributes
844
-		$output .= AUI_Component_Helper::data_attributes( $args );
844
+		$output .= AUI_Component_Helper::data_attributes($args);
845 845
 
846 846
 		// aria-attributes
847
-		$output .= AUI_Component_Helper::aria_attributes( $args );
847
+		$output .= AUI_Component_Helper::aria_attributes($args);
848 848
 
849 849
 		// extra attributes
850
-		if ( ! empty( $args['extra_attributes'] ) ) {
851
-			$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
850
+		if (!empty($args['extra_attributes'])) {
851
+			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
852 852
 		}
853 853
 
854 854
 		// required
855
-		if ( ! empty( $args['required'] ) ) {
855
+		if (!empty($args['required'])) {
856 856
 			$output .= ' required ';
857 857
 		}
858 858
 
859 859
 		// multiple
860
-		if ( ! empty( $args['multiple'] ) ) {
860
+		if (!empty($args['multiple'])) {
861 861
 			$output .= ' multiple ';
862 862
 		}
863 863
 
@@ -865,50 +865,50 @@  discard block
 block discarded – undo
865 865
 		$output .= ' >';
866 866
 
867 867
 		// placeholder
868
-		if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] && ! $is_select2 ) {
869
-			$output .= '<option value="" disabled selected hidden>' . esc_attr( $args['placeholder'] ) . '</option>';
870
-		} elseif ( $is_select2 && ! empty( $args['placeholder'] ) ) {
868
+		if (isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2) {
869
+			$output .= '<option value="" disabled selected hidden>' . esc_attr($args['placeholder']) . '</option>';
870
+		} elseif ($is_select2 && !empty($args['placeholder'])) {
871 871
 			$output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
872 872
 		}
873 873
 
874 874
 		// Options
875
-		if ( ! empty( $args['options'] ) ) {
875
+		if (!empty($args['options'])) {
876 876
 
877
-			if ( ! is_array( $args['options'] ) ) {
877
+			if (!is_array($args['options'])) {
878 878
 				$output .= $args['options']; // not the preferred way but an option
879 879
 			} else {
880
-				foreach ( $args['options'] as $val => $name ) {
880
+				foreach ($args['options'] as $val => $name) {
881 881
 					$selected = '';
882
-					if ( is_array( $name ) ) {
883
-						if ( isset( $name['optgroup'] ) && ( $name['optgroup'] == 'start' || $name['optgroup'] == 'end' ) ) {
884
-							$option_label = isset( $name['label'] ) ? $name['label'] : '';
882
+					if (is_array($name)) {
883
+						if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) {
884
+							$option_label = isset($name['label']) ? $name['label'] : '';
885 885
 
886
-							$output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr( $option_label ) . '">' : '</optgroup>';
886
+							$output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>';
887 887
 						} else {
888
-							$option_label = isset( $name['label'] ) ? $name['label'] : '';
889
-							$option_value = isset( $name['value'] ) ? $name['value'] : '';
890
-							$extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes( $name['extra_attributes'] ) : '';
891
-							if ( ! empty( $args['multiple'] ) && ! empty( $args['value'] ) && is_array( $args['value'] ) ) {
892
-								$selected = in_array( $option_value, stripslashes_deep( $args['value'] ) ) ? "selected" : "";
893
-							} elseif ( ! empty( $args['value'] ) ) {
894
-								$selected = selected( $option_value, stripslashes_deep( $args['value'] ), false );
895
-							} elseif ( empty( $args['value'] ) && $args['value'] === $option_value ) {
896
-								$selected = selected( $option_value, $args['value'], false );
888
+							$option_label = isset($name['label']) ? $name['label'] : '';
889
+							$option_value = isset($name['value']) ? $name['value'] : '';
890
+							$extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes($name['extra_attributes']) : '';
891
+							if (!empty($args['multiple']) && !empty($args['value']) && is_array($args['value'])) {
892
+								$selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : "";
893
+							} elseif (!empty($args['value'])) {
894
+								$selected = selected($option_value, stripslashes_deep($args['value']), false);
895
+							} elseif (empty($args['value']) && $args['value'] === $option_value) {
896
+								$selected = selected($option_value, $args['value'], false);
897 897
 							}
898 898
 
899
-							$output .= '<option value="' . esc_attr( $option_value ) . '" ' . $selected . ' '.$extra_attributes .'>' . $option_label . '</option>';
899
+							$output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . ' ' . $extra_attributes . '>' . $option_label . '</option>';
900 900
 						}
901 901
 					} else {
902
-						if ( ! empty( $args['value'] ) ) {
903
-							if ( is_array( $args['value'] ) ) {
904
-								$selected = in_array( $val, $args['value'] ) ? 'selected="selected"' : '';
905
-							} elseif ( ! empty( $args['value'] ) ) {
906
-								$selected = selected( $args['value'], $val, false );
902
+						if (!empty($args['value'])) {
903
+							if (is_array($args['value'])) {
904
+								$selected = in_array($val, $args['value']) ? 'selected="selected"' : '';
905
+							} elseif (!empty($args['value'])) {
906
+								$selected = selected($args['value'], $val, false);
907 907
 							}
908
-						} elseif ( $args['value'] === $val ) {
909
-							$selected = selected( $args['value'], $val, false );
908
+						} elseif ($args['value'] === $val) {
909
+							$selected = selected($args['value'], $val, false);
910 910
 						}
911
-						$output .= '<option value="' . esc_attr( $val ) . '" ' . $selected . '>' . esc_attr( $name ) . '</option>';
911
+						$output .= '<option value="' . esc_attr($val) . '" ' . $selected . '>' . esc_attr($name) . '</option>';
912 912
 					}
913 913
 				}
914 914
 			}
@@ -921,8 +921,8 @@  discard block
 block discarded – undo
921 921
 		$label = '';
922 922
 		$help_text = '';
923 923
 		// label
924
-		if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
925
-		} elseif ( ! empty( $args['label'] ) && ! $label_after ) {
924
+		if (!empty($args['label']) && is_array($args['label'])) {
925
+		} elseif (!empty($args['label']) && !$label_after) {
926 926
 			$label_args = array(
927 927
 				'title'      => $args['label'],
928 928
 				'for'        => $args['id'],
@@ -930,49 +930,49 @@  discard block
 block discarded – undo
930 930
 				'label_type' => $args['label_type'],
931 931
 				'label_col'  => $args['label_col']
932 932
 			);
933
-			$label = self::label( $label_args );
933
+			$label = self::label($label_args);
934 934
 		}
935 935
 
936 936
 		// help text
937
-		if ( ! empty( $args['help_text'] ) ) {
938
-			$help_text = AUI_Component_Helper::help_text( $args['help_text'] );
937
+		if (!empty($args['help_text'])) {
938
+			$help_text = AUI_Component_Helper::help_text($args['help_text']);
939 939
 		}
940 940
 
941 941
 		// input group wraps
942
-		if ( $args['input_group_left'] || $args['input_group_right'] ) {
943
-			$w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
944
-			if ( $args['input_group_left'] ) {
945
-				$output = self::wrap( array(
942
+		if ($args['input_group_left'] || $args['input_group_right']) {
943
+			$w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
944
+			if ($args['input_group_left']) {
945
+				$output = self::wrap(array(
946 946
 					'content'                 => $output,
947 947
 					'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
948 948
 					'input_group_left'        => $args['input_group_left'],
949 949
 					'input_group_left_inside' => $args['input_group_left_inside']
950
-				) );
950
+				));
951 951
 			}
952
-			if ( $args['input_group_right'] ) {
953
-				$output = self::wrap( array(
952
+			if ($args['input_group_right']) {
953
+				$output = self::wrap(array(
954 954
 					'content'                  => $output,
955 955
 					'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
956 956
 					'input_group_right'        => $args['input_group_right'],
957 957
 					'input_group_right_inside' => $args['input_group_right_inside']
958
-				) );
958
+				));
959 959
 			}
960 960
 
961 961
 		}
962 962
 
963
-		if ( ! $label_after ) {
963
+		if (!$label_after) {
964 964
 			$output .= $help_text;
965 965
 		}
966 966
 
967 967
 
968
-		if ( $args['label_type'] == 'horizontal' ) {
969
-			$output = self::wrap( array(
968
+		if ($args['label_type'] == 'horizontal') {
969
+			$output = self::wrap(array(
970 970
 				'content' => $output,
971
-				'class'   => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' )
972
-			) );
971
+				'class'   => AUI_Component_Helper::get_column_class($args['label_col'], 'input')
972
+			));
973 973
 		}
974 974
 
975
-		if ( ! $label_after ) {
975
+		if (!$label_after) {
976 976
 			$output = $label . $output;
977 977
 		}
978 978
 
@@ -983,16 +983,16 @@  discard block
 block discarded – undo
983 983
 
984 984
 
985 985
 		// wrap
986
-		if ( ! $args['no_wrap'] ) {
986
+		if (!$args['no_wrap']) {
987 987
 			$wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
988
-			$wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
989
-			$output     = self::wrap( array(
988
+			$wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
989
+			$output     = self::wrap(array(
990 990
 				'content'         => $output,
991 991
 				'class'           => $wrap_class,
992 992
 				'element_require' => $args['element_require'],
993 993
 				'argument_id'     => $args['id'],
994 994
 				'wrap_attributes' => $args['wrap_attributes'],
995
-			) );
995
+			));
996 996
 		}
997 997
 
998 998
 
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
 	 *
1007 1007
 	 * @return string The rendered component.
1008 1008
 	 */
1009
-	public static function radio( $args = array() ) {
1009
+	public static function radio($args = array()) {
1010 1010
 		$defaults = array(
1011 1011
 			'class'            => '',
1012 1012
 			'wrap_class'       => '',
@@ -1036,10 +1036,10 @@  discard block
 block discarded – undo
1036 1036
 		/**
1037 1037
 		 * Parse incoming $args into an array and merge it with $defaults
1038 1038
 		 */
1039
-		$args = wp_parse_args( $args, $defaults );
1039
+		$args = wp_parse_args($args, $defaults);
1040 1040
 
1041 1041
 		// for now lets use horizontal for floating
1042
-		if ( $args['label_type'] == 'floating' ) {
1042
+		if ($args['label_type'] == 'floating') {
1043 1043
 			$args['label_type'] = 'horizontal';
1044 1044
 		}
1045 1045
 
@@ -1054,47 +1054,47 @@  discard block
 block discarded – undo
1054 1054
 
1055 1055
 
1056 1056
 		// label before
1057
-		if ( ! empty( $args['label'] ) ) {
1058
-			$output .= self::label( $label_args, 'radio' );
1057
+		if (!empty($args['label'])) {
1058
+			$output .= self::label($label_args, 'radio');
1059 1059
 		}
1060 1060
 
1061 1061
 		// maybe horizontal label
1062
-		if ( $args['label_type'] == 'horizontal' ) {
1063
-			$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
1062
+		if ($args['label_type'] == 'horizontal') {
1063
+			$input_col = AUI_Component_Helper::get_column_class($args['label_col'], 'input');
1064 1064
 			$output .= '<div class="' . $input_col . '">';
1065 1065
 		}
1066 1066
 
1067
-		if ( ! empty( $args['options'] ) ) {
1067
+		if (!empty($args['options'])) {
1068 1068
 			$count = 0;
1069
-			foreach ( $args['options'] as $value => $label ) {
1069
+			foreach ($args['options'] as $value => $label) {
1070 1070
 				$option_args            = $args;
1071 1071
 				$option_args['value']   = $value;
1072 1072
 				$option_args['label']   = $label;
1073 1073
 				$option_args['checked'] = $value == $args['value'] ? true : false;
1074
-				$output .= self::radio_option( $option_args, $count );
1075
-				$count ++;
1074
+				$output .= self::radio_option($option_args, $count);
1075
+				$count++;
1076 1076
 			}
1077 1077
 		}
1078 1078
 
1079 1079
 		// help text
1080
-		$help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : '';
1080
+		$help_text = !empty($args['help_text']) ? AUI_Component_Helper::help_text($args['help_text']) : '';
1081 1081
 		$output .= $help_text;
1082 1082
 
1083 1083
 		// maybe horizontal label
1084
-		if ( $args['label_type'] == 'horizontal' ) {
1084
+		if ($args['label_type'] == 'horizontal') {
1085 1085
 			$output .= '</div>';
1086 1086
 		}
1087 1087
 
1088 1088
 		// wrap
1089 1089
 		$wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
1090
-		$wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
1091
-		$output     = self::wrap( array(
1090
+		$wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
1091
+		$output     = self::wrap(array(
1092 1092
 			'content'         => $output,
1093 1093
 			'class'           => $wrap_class,
1094 1094
 			'element_require' => $args['element_require'],
1095 1095
 			'argument_id'     => $args['id'],
1096 1096
 			'wrap_attributes' => $args['wrap_attributes'],
1097
-		) );
1097
+		));
1098 1098
 
1099 1099
 
1100 1100
 		return $output;
@@ -1107,7 +1107,7 @@  discard block
 block discarded – undo
1107 1107
 	 *
1108 1108
 	 * @return string The rendered component.
1109 1109
 	 */
1110
-	public static function radio_option( $args = array(), $count = '' ) {
1110
+	public static function radio_option($args = array(), $count = '') {
1111 1111
 		$defaults = array(
1112 1112
 			'class'            => '',
1113 1113
 			'id'               => '',
@@ -1125,7 +1125,7 @@  discard block
 block discarded – undo
1125 1125
 		/**
1126 1126
 		 * Parse incoming $args into an array and merge it with $defaults
1127 1127
 		 */
1128
-		$args = wp_parse_args( $args, $defaults );
1128
+		$args = wp_parse_args($args, $defaults);
1129 1129
 
1130 1130
 		$output = '';
1131 1131
 
@@ -1136,43 +1136,43 @@  discard block
 block discarded – undo
1136 1136
 		$output .= ' class="form-check-input" ';
1137 1137
 
1138 1138
 		// name
1139
-		if ( ! empty( $args['name'] ) ) {
1140
-			$output .= AUI_Component_Helper::name( $args['name'] );
1139
+		if (!empty($args['name'])) {
1140
+			$output .= AUI_Component_Helper::name($args['name']);
1141 1141
 		}
1142 1142
 
1143 1143
 		// id
1144
-		if ( ! empty( $args['id'] ) ) {
1145
-			$output .= AUI_Component_Helper::id( $args['id'] . $count );
1144
+		if (!empty($args['id'])) {
1145
+			$output .= AUI_Component_Helper::id($args['id'] . $count);
1146 1146
 		}
1147 1147
 
1148 1148
 		// title
1149
-		if ( ! empty( $args['title'] ) ) {
1150
-			$output .= AUI_Component_Helper::title( $args['title'] );
1149
+		if (!empty($args['title'])) {
1150
+			$output .= AUI_Component_Helper::title($args['title']);
1151 1151
 		}
1152 1152
 
1153 1153
 		// value
1154
-		if ( isset( $args['value'] ) ) {
1155
-			$output .= AUI_Component_Helper::value( $args['value'] );
1154
+		if (isset($args['value'])) {
1155
+			$output .= AUI_Component_Helper::value($args['value']);
1156 1156
 		}
1157 1157
 
1158 1158
 		// checked, for radio and checkboxes
1159
-		if ( $args['checked'] ) {
1159
+		if ($args['checked']) {
1160 1160
 			$output .= ' checked ';
1161 1161
 		}
1162 1162
 
1163 1163
 		// data-attributes
1164
-		$output .= AUI_Component_Helper::data_attributes( $args );
1164
+		$output .= AUI_Component_Helper::data_attributes($args);
1165 1165
 
1166 1166
 		// aria-attributes
1167
-		$output .= AUI_Component_Helper::aria_attributes( $args );
1167
+		$output .= AUI_Component_Helper::aria_attributes($args);
1168 1168
 
1169 1169
 		// extra attributes
1170
-		if ( ! empty( $args['extra_attributes'] ) ) {
1171
-			$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
1170
+		if (!empty($args['extra_attributes'])) {
1171
+			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
1172 1172
 		}
1173 1173
 
1174 1174
 		// required
1175
-		if ( ! empty( $args['required'] ) ) {
1175
+		if (!empty($args['required'])) {
1176 1176
 			$output .= ' required ';
1177 1177
 		}
1178 1178
 
@@ -1180,38 +1180,38 @@  discard block
 block discarded – undo
1180 1180
 		$output .= ' >';
1181 1181
 
1182 1182
 		// label
1183
-		if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
1184
-		} elseif ( ! empty( $args['label'] ) ) {
1185
-			$output .= self::label( array(
1183
+		if (!empty($args['label']) && is_array($args['label'])) {
1184
+		} elseif (!empty($args['label'])) {
1185
+			$output .= self::label(array(
1186 1186
 				'title' => $args['label'],
1187 1187
 				'for'   => $args['id'] . $count,
1188 1188
 				'class' => 'form-check-label'
1189
-			), 'radio' );
1189
+			), 'radio');
1190 1190
 		}
1191 1191
 
1192 1192
 		// wrap
1193
-		if ( ! $args['no_wrap'] ) {
1193
+		if (!$args['no_wrap']) {
1194 1194
 			$wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
1195 1195
 
1196 1196
 			// Unique wrap class
1197 1197
 			$uniq_class = 'fwrap';
1198
-			if ( ! empty( $args['name'] ) ) {
1198
+			if (!empty($args['name'])) {
1199 1199
 				$uniq_class .= '-' . $args['name'];
1200
-			} else if ( ! empty( $args['id'] ) ) {
1200
+			} else if (!empty($args['id'])) {
1201 1201
 				$uniq_class .= '-' . $args['id'];
1202 1202
 			}
1203 1203
 
1204
-			if ( isset( $args['value'] ) || $args['value'] !== "" ) {
1204
+			if (isset($args['value']) || $args['value'] !== "") {
1205 1205
 				$uniq_class .= '-' . $args['value'];
1206 1206
 			} else {
1207 1207
 				$uniq_class .= '-' . $count;
1208 1208
 			}
1209
-			$wrap_class .= ' ' . sanitize_html_class( $uniq_class );
1209
+			$wrap_class .= ' ' . sanitize_html_class($uniq_class);
1210 1210
 
1211
-			$output = self::wrap( array(
1211
+			$output = self::wrap(array(
1212 1212
 				'content' => $output,
1213 1213
 				'class'   => $wrap_class
1214
-			) );
1214
+			));
1215 1215
 		}
1216 1216
 
1217 1217
 		return $output;
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-item-details.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Item_Details {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25 25
 
26 26
         // Prepare the item.
@@ -270,35 +270,35 @@  discard block
 block discarded – undo
270 270
     }
271 271
 
272 272
     /**
273
-	 * Save meta box data.
274
-	 *
275
-	 * @param int $post_id
276
-	 */
277
-	public static function save( $post_id ) {
273
+     * Save meta box data.
274
+     *
275
+     * @param int $post_id
276
+     */
277
+    public static function save( $post_id ) {
278 278
 
279 279
         // Prepare the item.
280 280
         $item = new WPInv_Item( $post_id );
281 281
 
282 282
         // Load new data.
283 283
         $item->set_props(
284
-			array(
285
-				'price'                => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null,
286
-				'vat_rule'             => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null,
287
-				'vat_class'            => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null,
288
-				'type'                 => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null,
289
-				'is_dynamic_pricing'   => ! empty( $_POST['wpinv_name_your_price'] ),
284
+            array(
285
+                'price'                => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null,
286
+                'vat_rule'             => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null,
287
+                'vat_class'            => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null,
288
+                'type'                 => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null,
289
+                'is_dynamic_pricing'   => ! empty( $_POST['wpinv_name_your_price'] ),
290 290
                 'minimum_price'        => isset( $_POST['wpinv_minimum_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_minimum_price'] ) : null,
291
-				'is_recurring'         => ! empty( $_POST['wpinv_is_recurring'] ),
292
-				'recurring_period'     => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null,
293
-				'recurring_interval'   => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1,
294
-				'recurring_limit'      => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null,
295
-				'is_free_trial'        => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null,
296
-				'trial_period'         => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null,
297
-				'trial_interval'       => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null,
298
-			)
291
+                'is_recurring'         => ! empty( $_POST['wpinv_is_recurring'] ),
292
+                'recurring_period'     => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null,
293
+                'recurring_interval'   => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1,
294
+                'recurring_limit'      => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null,
295
+                'is_free_trial'        => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null,
296
+                'trial_period'         => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null,
297
+                'trial_interval'       => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null,
298
+            )
299 299
         );
300 300
 
301
-		$item->save();
302
-		do_action( 'getpaid_item_metabox_save', $post_id, $item );
303
-	}
301
+        $item->save();
302
+        do_action( 'getpaid_item_metabox_save', $post_id, $item );
303
+    }
304 304
 }
Please login to merge, or discard this patch.
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,27 +21,27 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the item.
27
-        $item = new WPInv_Item( $post );
27
+        $item = new WPInv_Item($post);
28 28
 
29 29
         // Nonce field.
30
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
30
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
31 31
 
32 32
         // Set the currency position.
33 33
         $position = wpinv_currency_position();
34 34
 
35
-        if ( $position == 'left_space' ) {
35
+        if ($position == 'left_space') {
36 36
             $position = 'left';
37 37
         }
38 38
 
39
-        if ( $position == 'right_space' ) {
39
+        if ($position == 'right_space') {
40 40
             $position = 'right';
41 41
         }
42 42
 
43 43
         ?>
44
-        <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr( $item->get_type( 'edit' ) ); ?>" />
44
+        <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr($item->get_type('edit')); ?>" />
45 45
         <style>
46 46
             #poststuff .input-group-text,
47 47
             #poststuff .form-control {
@@ -55,21 +55,21 @@  discard block
 block discarded – undo
55 55
         </style>
56 56
         <div class='bsui' style='max-width: 600px;padding-top: 10px;'>
57 57
 
58
-            <?php do_action( 'wpinv_item_details_metabox_before_price', $item ); ?>
58
+            <?php do_action('wpinv_item_details_metabox_before_price', $item); ?>
59 59
             <div class="form-group row">
60
-                <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e( 'Item Price', 'invoicing' )?></span></label>
60
+                <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e('Item Price', 'invoicing')?></span></label>
61 61
                 <div class="col-sm-8">
62 62
                     <div class="row">
63 63
                         <div class="col-sm-4 getpaid-price-input">
64 64
                             <div class="input-group input-group-sm">
65
-                                <?php if( 'left' == $position ) : ?>
65
+                                <?php if ('left' == $position) : ?>
66 66
                                 <div class="input-group-prepend">
67 67
                                     <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
68 68
                                 </div>
69 69
                                 <?php endif; ?>
70
-                                <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr( getpaid_unstandardize_amount( $item->get_price( 'edit' ) ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control">
70
+                                <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr(getpaid_unstandardize_amount($item->get_price('edit'))); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control">
71 71
 
72
-                                <?php if( 'left' != $position ) : ?>
72
+                                <?php if ('left' != $position) : ?>
73 73
                                 <div class="input-group-append">
74 74
                                     <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
75 75
                                 </div>
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
                         </div>
80 80
                         <div class="col-sm-4 wpinv_show_if_recurring">
81 81
                             <?php
82
-                                _e( 'every' );
82
+                                _e('every');
83 83
                                 echo "&nbsp;";
84 84
                             ?>
85
-                            <input type="number" style="max-width: 60px;" value="<?php echo esc_attr( $item->get_recurring_interval( 'edit' ) ); ?>" placeholder="1" name="wpinv_recurring_interval" id="wpinv_recurring_interval" />
85
+                            <input type="number" style="max-width: 60px;" value="<?php echo esc_attr($item->get_recurring_interval('edit')); ?>" placeholder="1" name="wpinv_recurring_interval" id="wpinv_recurring_interval" />
86 86
                         </div>
87 87
                         <div class="col-sm-4 wpinv_show_if_recurring">
88 88
                             <?php
@@ -90,16 +90,16 @@  discard block
 block discarded – undo
90 90
                                     array(
91 91
                                         'id'               => 'wpinv_recurring_period',
92 92
                                         'name'             => 'wpinv_recurring_period',
93
-                                        'label'            => __( 'Period', 'invoicing' ),
94
-                                        'placeholder'      => __( 'Select Period', 'invoicing' ),
95
-                                        'value'            => $item->get_recurring_period( 'edit' ),
93
+                                        'label'            => __('Period', 'invoicing'),
94
+                                        'placeholder'      => __('Select Period', 'invoicing'),
95
+                                        'value'            => $item->get_recurring_period('edit'),
96 96
                                         'select2'          => true,
97 97
                                         'data-allow-clear' => 'false',
98 98
                                         'options'     => array(
99
-                                            'D'  => __( 'day(s)', 'invoicing' ),
100
-                                            'W'  => __( 'week(s)', 'invoicing' ),
101
-                                            'M'  => __( 'month(s)', 'invoicing' ),
102
-                                            'Y'  => __( 'year(s)', 'invoicing' ),
99
+                                            'D'  => __('day(s)', 'invoicing'),
100
+                                            'W'  => __('week(s)', 'invoicing'),
101
+                                            'M'  => __('month(s)', 'invoicing'),
102
+                                            'Y'  => __('year(s)', 'invoicing'),
103 103
                                         )
104 104
                                     )
105 105
                                 );
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
                             <?php
112 112
 
113 113
                                 // Dynamic pricing.
114
-                                if( $item->supports_dynamic_pricing() ) {
114
+                                if ($item->supports_dynamic_pricing()) {
115 115
 
116
-                                    do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item );
116
+                                    do_action('wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item);
117 117
 
118 118
                                     // NYP toggle.
119 119
                                     echo aui()->input(
@@ -121,31 +121,31 @@  discard block
 block discarded – undo
121 121
                                             'id'          => 'wpinv_name_your_price',
122 122
                                             'name'        => 'wpinv_name_your_price',
123 123
                                             'type'        => 'checkbox',
124
-                                            'label'       => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ),
124
+                                            'label'       => apply_filters('wpinv_name_your_price_toggle_text', __('Let customers name their price', 'invoicing')),
125 125
                                             'value'       => '1',
126 126
                                             'checked'     => $item->user_can_set_their_price(),
127 127
                                             'no_wrap'     => true,
128 128
                                         )
129 129
                                     );
130 130
 
131
-                                    do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item );
131
+                                    do_action('wpinv_item_details_metabox_dynamic_pricing_checkbox', $item);
132 132
 
133 133
                                 }
134 134
 
135 135
                                 // Subscriptions.
136
-                                do_action( 'wpinv_item_details_metabox_before_subscription_checkbox', $item );
136
+                                do_action('wpinv_item_details_metabox_before_subscription_checkbox', $item);
137 137
                                 echo aui()->input(
138 138
                                     array(
139 139
                                         'id'          => 'wpinv_is_recurring',
140 140
                                         'name'        => 'wpinv_is_recurring',
141 141
                                         'type'        => 'checkbox',
142
-                                        'label'       => apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Charge customers a recurring amount for this item', 'invoicing' ) ),
142
+                                        'label'       => apply_filters('wpinv_is_recurring_toggle_text', __('Charge customers a recurring amount for this item', 'invoicing')),
143 143
                                         'value'       => '1',
144 144
                                         'checked'     => $item->is_recurring(),
145 145
                                         'no_wrap'     => true,
146 146
                                     )
147 147
                                 );
148
-                                do_action( 'wpinv_item_details_metabox_subscription_checkbox', $item );
148
+                                do_action('wpinv_item_details_metabox_subscription_checkbox', $item);
149 149
 
150 150
                             ?>
151 151
                             <div class="wpinv_show_if_recurring">
@@ -155,30 +155,30 @@  discard block
 block discarded – undo
155 155
                     </div>
156 156
                 </div>
157 157
                 <div class="col-sm-1 pt-2 pl-0">
158
-                    <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e( 'Set the subscription price, billing interval and period.', 'invoicing' ); ?>"></span>
158
+                    <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e('Set the subscription price, billing interval and period.', 'invoicing'); ?>"></span>
159 159
                 </div>
160 160
             </div>
161
-            <?php do_action( 'wpinv_item_details_metabox_after_price', $item ); ?>
161
+            <?php do_action('wpinv_item_details_metabox_after_price', $item); ?>
162 162
 
163
-            <?php if( $item->supports_dynamic_pricing() ) : ?>
164
-                <?php do_action( 'wpinv_item_details_metabox_before_minimum_price', $item ); ?>
163
+            <?php if ($item->supports_dynamic_pricing()) : ?>
164
+                <?php do_action('wpinv_item_details_metabox_before_minimum_price', $item); ?>
165 165
                 <div class="wpinv_show_if_dynamic wpinv_minimum_price">
166 166
 
167 167
                     <div class="form-group row">
168 168
                         <label for="wpinv_minimum_price" class="col-sm-3 col-form-label">
169
-                            <?php _e( 'Minimum Price', 'invoicing' );?>
169
+                            <?php _e('Minimum Price', 'invoicing'); ?>
170 170
                         </label>
171 171
                         <div class="col-sm-8">
172 172
                             <div class="input-group input-group-sm">
173
-                                <?php if( 'left' == $position ) : ?>
173
+                                <?php if ('left' == $position) : ?>
174 174
                                     <div class="input-group-prepend">
175 175
                                         <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
176 176
                                     </div>
177 177
                                 <?php endif; ?>
178 178
 
179
-                                <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr( getpaid_unstandardize_amount( $item->get_minimum_price( 'edit' ) ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control">
179
+                                <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr(getpaid_unstandardize_amount($item->get_minimum_price('edit'))); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control">
180 180
 
181
-                                <?php if( 'left' != $position ) : ?>
181
+                                <?php if ('left' != $position) : ?>
182 182
                                     <div class="input-group-append">
183 183
                                         <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
184 184
                                     </div>
@@ -187,45 +187,45 @@  discard block
 block discarded – undo
187 187
                         </div>
188 188
 
189 189
                         <div class="col-sm-1 pt-2 pl-0">
190
-                            <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the minimum amount that users are allowed to set', 'invoicing' ); ?>"></span>
190
+                            <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the minimum amount that users are allowed to set', 'invoicing'); ?>"></span>
191 191
                         </div>
192 192
                     </div>
193 193
 
194 194
                 </div>
195
-                <?php do_action( 'wpinv_item_details_metabox_minimum_price', $item ); ?>
195
+                <?php do_action('wpinv_item_details_metabox_minimum_price', $item); ?>
196 196
             <?php endif; ?>
197 197
 
198
-            <?php do_action( 'wpinv_item_details_metabox_before_maximum_renewals', $item ); ?>
198
+            <?php do_action('wpinv_item_details_metabox_before_maximum_renewals', $item); ?>
199 199
             <div class="wpinv_show_if_recurring wpinv_maximum_renewals">
200 200
 
201 201
                 <div class="form-group row">
202 202
                     <label for="wpinv_recurring_limit" class="col-sm-3 col-form-label">
203
-                        <?php _e( 'Maximum Renewals', 'invoicing' );?>
203
+                        <?php _e('Maximum Renewals', 'invoicing'); ?>
204 204
                     </label>
205 205
                     <div class="col-sm-8">
206
-                        <input type="number" value="<?php echo esc_attr( $item->get_recurring_limit( 'edit' ) ); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" />
206
+                        <input type="number" value="<?php echo esc_attr($item->get_recurring_limit('edit')); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" />
207 207
                     </div>
208 208
                     <div class="col-sm-1 pt-2 pl-0">
209
-                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing' ); ?>"></span>
209
+                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing'); ?>"></span>
210 210
                     </div>
211 211
                 </div>
212 212
 
213 213
             </div>
214
-            <?php do_action( 'wpinv_item_details_metabox_maximum_renewals', $item ); ?>
214
+            <?php do_action('wpinv_item_details_metabox_maximum_renewals', $item); ?>
215 215
 
216
-            <?php do_action( 'wpinv_item_details_metabox_before_free_trial', $item ); ?>
216
+            <?php do_action('wpinv_item_details_metabox_before_free_trial', $item); ?>
217 217
             <div class="wpinv_show_if_recurring wpinv_free_trial">
218 218
 
219 219
                 <div class="form-group row">
220
-                    <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php defined( 'GETPAID_PAID_TRIALS_VERSION' ) ? _e( 'Free/Paid Trial', 'invoicing' ) : _e( 'Free Trial', 'invoicing' )?></label>
220
+                    <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php defined('GETPAID_PAID_TRIALS_VERSION') ? _e('Free/Paid Trial', 'invoicing') : _e('Free Trial', 'invoicing')?></label>
221 221
 
222 222
                     <div class="col-sm-8">
223 223
                         <div class="row">
224 224
                             <div class="col-sm-6">
225
-                                <?php $value = $item->has_free_trial() ? $item->get_trial_interval( 'edit' ) : 0;?>
225
+                                <?php $value = $item->has_free_trial() ? $item->get_trial_interval('edit') : 0; ?>
226 226
 
227 227
                                 <div>
228
-                                    <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr( $value ); ?>" >
228
+                                    <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr($value); ?>" >
229 229
                                 </div>
230 230
                             </div>
231 231
                             <div class="col-sm-6">
@@ -234,17 +234,17 @@  discard block
 block discarded – undo
234 234
                                         array(
235 235
                                             'id'               => 'wpinv_trial_period',
236 236
                                             'name'             => 'wpinv_trial_period',
237
-                                            'label'            => __( 'Trial Period', 'invoicing' ),
238
-                                            'placeholder'      => __( 'Trial Period', 'invoicing' ),
239
-                                            'value'            => $item->get_trial_period( 'edit' ),
237
+                                            'label'            => __('Trial Period', 'invoicing'),
238
+                                            'placeholder'      => __('Trial Period', 'invoicing'),
239
+                                            'value'            => $item->get_trial_period('edit'),
240 240
                                             'select2'          => true,
241 241
                                             'data-allow-clear' => 'false',
242 242
                                             'no_wrap'          => true,
243 243
                                             'options'          => array(
244
-                                                'D'  => __( 'day(s)', 'invoicing' ),
245
-                                                'W'  => __( 'week(s)', 'invoicing' ),
246
-                                                'M'  => __( 'month(s)', 'invoicing' ),
247
-                                                'Y'  => __( 'year(s)', 'invoicing' ),
244
+                                                'D'  => __('day(s)', 'invoicing'),
245
+                                                'W'  => __('week(s)', 'invoicing'),
246
+                                                'M'  => __('month(s)', 'invoicing'),
247
+                                                'Y'  => __('year(s)', 'invoicing'),
248 248
                                             )
249 249
                                         )
250 250
                                     );
@@ -255,15 +255,15 @@  discard block
 block discarded – undo
255 255
                     </div>
256 256
 
257 257
                     <div class="col-sm-1 pt-2 pl-0">
258
-                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'An optional period of time to wait before charging the first recurring payment.', 'invoicing' ); ?>"></span>
258
+                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('An optional period of time to wait before charging the first recurring payment.', 'invoicing'); ?>"></span>
259 259
                     </div>
260 260
 
261 261
                 </div>
262 262
 
263 263
             </div>
264
-            <?php do_action( 'wpinv_item_details_metabox__free_trial', $item ); ?>
264
+            <?php do_action('wpinv_item_details_metabox__free_trial', $item); ?>
265 265
 
266
-            <?php do_action( 'wpinv_item_details_metabox_item_details', $item ); ?>
266
+            <?php do_action('wpinv_item_details_metabox_item_details', $item); ?>
267 267
         </div>
268 268
         <?php
269 269
 
@@ -274,31 +274,31 @@  discard block
 block discarded – undo
274 274
 	 *
275 275
 	 * @param int $post_id
276 276
 	 */
277
-	public static function save( $post_id ) {
277
+	public static function save($post_id) {
278 278
 
279 279
         // Prepare the item.
280
-        $item = new WPInv_Item( $post_id );
280
+        $item = new WPInv_Item($post_id);
281 281
 
282 282
         // Load new data.
283 283
         $item->set_props(
284 284
 			array(
285
-				'price'                => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null,
286
-				'vat_rule'             => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null,
287
-				'vat_class'            => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null,
288
-				'type'                 => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null,
289
-				'is_dynamic_pricing'   => ! empty( $_POST['wpinv_name_your_price'] ),
290
-                'minimum_price'        => isset( $_POST['wpinv_minimum_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_minimum_price'] ) : null,
291
-				'is_recurring'         => ! empty( $_POST['wpinv_is_recurring'] ),
292
-				'recurring_period'     => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null,
293
-				'recurring_interval'   => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1,
294
-				'recurring_limit'      => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null,
295
-				'is_free_trial'        => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null,
296
-				'trial_period'         => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null,
297
-				'trial_interval'       => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null,
285
+				'price'                => isset($_POST['wpinv_item_price']) ? getpaid_standardize_amount($_POST['wpinv_item_price']) : null,
286
+				'vat_rule'             => isset($_POST['wpinv_vat_rules']) ? wpinv_clean($_POST['wpinv_vat_rules']) : null,
287
+				'vat_class'            => isset($_POST['wpinv_vat_class']) ? wpinv_clean($_POST['wpinv_vat_class']) : null,
288
+				'type'                 => isset($_POST['wpinv_item_type']) ? wpinv_clean($_POST['wpinv_item_type']) : null,
289
+				'is_dynamic_pricing'   => !empty($_POST['wpinv_name_your_price']),
290
+                'minimum_price'        => isset($_POST['wpinv_minimum_price']) ? getpaid_standardize_amount($_POST['wpinv_minimum_price']) : null,
291
+				'is_recurring'         => !empty($_POST['wpinv_is_recurring']),
292
+				'recurring_period'     => isset($_POST['wpinv_recurring_period']) ? wpinv_clean($_POST['wpinv_recurring_period']) : null,
293
+				'recurring_interval'   => isset($_POST['wpinv_recurring_interval']) ? (int) $_POST['wpinv_recurring_interval'] : 1,
294
+				'recurring_limit'      => isset($_POST['wpinv_recurring_limit']) ? (int) $_POST['wpinv_recurring_limit'] : null,
295
+				'is_free_trial'        => isset($_POST['wpinv_trial_interval']) ? (0 != (int) $_POST['wpinv_trial_interval']) : null,
296
+				'trial_period'         => isset($_POST['wpinv_trial_period']) ? wpinv_clean($_POST['wpinv_trial_period']) : null,
297
+				'trial_interval'       => isset($_POST['wpinv_trial_interval']) ? (int) $_POST['wpinv_trial_interval'] : null,
298 298
 			)
299 299
         );
300 300
 
301 301
 		$item->save();
302
-		do_action( 'getpaid_item_metabox_save', $post_id, $item );
302
+		do_action('getpaid_item_metabox_save', $post_id, $item);
303 303
 	}
304 304
 }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-discount-details.php 2 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Discount_Details {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25 25
 
26 26
         // Prepare the discount.
@@ -396,35 +396,35 @@  discard block
 block discarded – undo
396 396
     }
397 397
 
398 398
     /**
399
-	 * Save meta box data.
400
-	 *
401
-	 * @param int $post_id
402
-	 */
403
-	public static function save( $post_id ) {
399
+     * Save meta box data.
400
+     *
401
+     * @param int $post_id
402
+     */
403
+    public static function save( $post_id ) {
404 404
 
405 405
         // Prepare the discount.
406 406
         $discount = new WPInv_Discount( $post_id );
407 407
 
408 408
         // Load new data.
409 409
         $discount->set_props(
410
-			array(
411
-				'code'                 => isset( $_POST['wpinv_discount_code'] ) ? wpinv_clean( $_POST['wpinv_discount_code'] ) : null,
412
-				'amount'               => isset( $_POST['wpinv_discount_amount'] ) ? floatval( $_POST['wpinv_discount_amount'] ) : null,
413
-				'start'                => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null,
414
-				'expiration'           => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null,
415
-				'is_single_use'        => ! empty( $_POST['wpinv_discount_single_use'] ),
410
+            array(
411
+                'code'                 => isset( $_POST['wpinv_discount_code'] ) ? wpinv_clean( $_POST['wpinv_discount_code'] ) : null,
412
+                'amount'               => isset( $_POST['wpinv_discount_amount'] ) ? floatval( $_POST['wpinv_discount_amount'] ) : null,
413
+                'start'                => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null,
414
+                'expiration'           => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null,
415
+                'is_single_use'        => ! empty( $_POST['wpinv_discount_single_use'] ),
416 416
                 'type'                 => isset( $_POST['wpinv_discount_type'] ) ? wpinv_clean( $_POST['wpinv_discount_type'] ) : null,
417
-				'is_recurring'         => ! empty( $_POST['wpinv_discount_recurring'] ),
418
-				'items'                => isset( $_POST['wpinv_discount_items'] ) ? wpinv_clean( $_POST['wpinv_discount_items'] ) : array(),
419
-				'excluded_items'       => isset( $_POST['wpinv_discount_excluded_items'] ) ? wpinv_clean( $_POST['wpinv_discount_excluded_items'] ) : array(),
417
+                'is_recurring'         => ! empty( $_POST['wpinv_discount_recurring'] ),
418
+                'items'                => isset( $_POST['wpinv_discount_items'] ) ? wpinv_clean( $_POST['wpinv_discount_items'] ) : array(),
419
+                'excluded_items'       => isset( $_POST['wpinv_discount_excluded_items'] ) ? wpinv_clean( $_POST['wpinv_discount_excluded_items'] ) : array(),
420 420
                 'required_items'       => isset( $_POST['wpinv_discount_required_items'] ) ? wpinv_clean( $_POST['wpinv_discount_required_items'] ) : array(),
421
-				'max_uses'             => isset( $_POST['wpinv_discount_max_uses'] ) ? intval( $_POST['wpinv_discount_max_uses'] ) : null,
422
-				'min_total'            => isset( $_POST['wpinv_discount_min_total'] ) ? floatval( $_POST['wpinv_discount_min_total'] ) : null,
423
-				'max_total'            => isset( $_POST['wpinv_discount_max_total'] ) ? floatval( $_POST['wpinv_discount_max_total'] ) : null,
424
-			)
421
+                'max_uses'             => isset( $_POST['wpinv_discount_max_uses'] ) ? intval( $_POST['wpinv_discount_max_uses'] ) : null,
422
+                'min_total'            => isset( $_POST['wpinv_discount_min_total'] ) ? floatval( $_POST['wpinv_discount_min_total'] ) : null,
423
+                'max_total'            => isset( $_POST['wpinv_discount_max_total'] ) ? floatval( $_POST['wpinv_discount_max_total'] ) : null,
424
+            )
425 425
         );
426 426
 
427
-		$discount->save();
428
-		do_action( 'getpaid_discount_metabox_save', $post_id, $discount );
429
-	}
427
+        $discount->save();
428
+        do_action( 'getpaid_discount_metabox_save', $post_id, $discount );
429
+    }
430 430
 }
Please login to merge, or discard this patch.
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,24 +21,24 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the discount.
27
-        $discount = new WPInv_Discount( $post );
27
+        $discount = new WPInv_Discount($post);
28 28
 
29 29
         // Nonce field.
30
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
30
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
31 31
 
32
-        do_action( 'wpinv_discount_form_top', $discount );
32
+        do_action('wpinv_discount_form_top', $discount);
33 33
 
34 34
         // Set the currency position.
35 35
         $position = wpinv_currency_position();
36 36
 
37
-        if ( $position == 'left_space' ) {
37
+        if ($position == 'left_space') {
38 38
             $position = 'left';
39 39
         }
40 40
 
41
-        if ( $position == 'right_space' ) {
41
+        if ($position == 'right_space') {
42 42
             $position = 'right';
43 43
         }
44 44
 
@@ -52,66 +52,66 @@  discard block
 block discarded – undo
52 52
         </style>
53 53
         <div class='bsui' style='max-width: 600px;padding-top: 10px;'>
54 54
 
55
-            <?php do_action( 'wpinv_discount_form_first', $discount ); ?>
55
+            <?php do_action('wpinv_discount_form_first', $discount); ?>
56 56
 
57
-            <?php do_action( 'wpinv_discount_form_before_code', $discount ); ?>
57
+            <?php do_action('wpinv_discount_form_before_code', $discount); ?>
58 58
             <div class="form-group row">
59 59
                 <label for="wpinv_discount_code" class="col-sm-3 col-form-label">
60
-                    <?php _e( 'Discount Code', 'invoicing' );?>
60
+                    <?php _e('Discount Code', 'invoicing'); ?>
61 61
                 </label>
62 62
                 <div class="col-sm-8">
63 63
                     <div class="row">
64 64
                         <div class="col-sm-12 form-group">
65
-                            <input type="text" value="<?php echo esc_attr( $discount->get_code( 'edit' ) ); ?>" placeholder="SUMMER_SALE" name="wpinv_discount_code" id="wpinv_discount_code" style="width: 100%;" />
65
+                            <input type="text" value="<?php echo esc_attr($discount->get_code('edit')); ?>" placeholder="SUMMER_SALE" name="wpinv_discount_code" id="wpinv_discount_code" style="width: 100%;" />
66 66
                         </div>
67 67
                         <div class="col-sm-12">
68 68
                             <?php
69
-                                do_action( 'wpinv_discount_form_before_single_use', $discount );
69
+                                do_action('wpinv_discount_form_before_single_use', $discount);
70 70
 
71 71
                                 echo aui()->input(
72 72
                                     array(
73 73
                                         'id'          => 'wpinv_discount_single_use',
74 74
                                         'name'        => 'wpinv_discount_single_use',
75 75
                                         'type'        => 'checkbox',
76
-                                        'label'       => __( 'Each customer can only use this discount once', 'invoicing' ),
76
+                                        'label'       => __('Each customer can only use this discount once', 'invoicing'),
77 77
                                         'value'       => '1',
78 78
                                         'checked'     => $discount->is_single_use(),
79 79
                                     )
80 80
                                 );
81 81
 
82
-                                do_action( 'wpinv_discount_form_single_use', $discount );
82
+                                do_action('wpinv_discount_form_single_use', $discount);
83 83
                             ?>
84 84
                         </div>
85 85
                         <div class="col-sm-12">
86 86
                             <?php
87
-                                do_action( 'wpinv_discount_form_before_recurring', $discount );
87
+                                do_action('wpinv_discount_form_before_recurring', $discount);
88 88
 
89 89
                                 echo aui()->input(
90 90
                                     array(
91 91
                                         'id'          => 'wpinv_discount_recurring',
92 92
                                         'name'        => 'wpinv_discount_recurring',
93 93
                                         'type'        => 'checkbox',
94
-                                        'label'       => __( 'Apply this discount to all recurring payments for subscriptions', 'invoicing' ),
94
+                                        'label'       => __('Apply this discount to all recurring payments for subscriptions', 'invoicing'),
95 95
                                         'value'       => '1',
96 96
                                         'checked'     => $discount->is_recurring(),
97 97
                                     )
98 98
                                 );
99 99
 
100
-                                do_action( 'wpinv_discount_form_recurring', $discount );
100
+                                do_action('wpinv_discount_form_recurring', $discount);
101 101
                             ?>
102 102
                         </div>
103 103
                     </div>
104 104
                 </div>
105 105
                 <div class="col-sm-1 pt-2 pl-0">
106
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter a discount code such as 10OFF.', 'invoicing' ); ?>"></span>
106
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter a discount code such as 10OFF.', 'invoicing'); ?>"></span>
107 107
                 </div>
108 108
             </div>
109
-            <?php do_action( 'wpinv_discount_form_code', $discount ); ?>
109
+            <?php do_action('wpinv_discount_form_code', $discount); ?>
110 110
 
111
-            <?php do_action( 'wpinv_discount_form_before_type', $discount ); ?>
111
+            <?php do_action('wpinv_discount_form_before_type', $discount); ?>
112 112
             <div class="form-group row">
113 113
                 <label for="wpinv_discount_type" class="col-sm-3 col-form-label">
114
-                    <?php _e( 'Discount Type', 'invoicing' );?>
114
+                    <?php _e('Discount Type', 'invoicing'); ?>
115 115
                 </label>
116 116
                 <div class="col-sm-8">
117 117
                     <?php
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
                             array(
120 120
                                 'id'               => 'wpinv_discount_type',
121 121
                                 'name'             => 'wpinv_discount_type',
122
-                                'label'            => __( 'Discount Type', 'invoicing' ),
123
-                                'placeholder'      => __( 'Select Discount Type', 'invoicing' ),
124
-                                'value'            => $discount->get_type( 'edit' ),
122
+                                'label'            => __('Discount Type', 'invoicing'),
123
+                                'placeholder'      => __('Select Discount Type', 'invoicing'),
124
+                                'value'            => $discount->get_type('edit'),
125 125
                                 'select2'          => true,
126 126
                                 'data-allow-clear' => 'false',
127 127
                                 'options'          => wpinv_get_discount_types()
@@ -130,19 +130,19 @@  discard block
 block discarded – undo
130 130
                     ?>
131 131
                 </div>
132 132
                 <div class="col-sm-1 pt-2 pl-0">
133
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Discount type.', 'invoicing' ); ?>"></span>
133
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Discount type.', 'invoicing'); ?>"></span>
134 134
                 </div>
135 135
             </div>
136
-            <?php do_action( 'wpinv_discount_form_type', $discount ); ?>
136
+            <?php do_action('wpinv_discount_form_type', $discount); ?>
137 137
 
138
-            <?php do_action( 'wpinv_discount_form_before_amount', $discount ); ?>
139
-            <div class="form-group row <?php echo esc_attr( $discount->get_type( 'edit' ) ); ?>" id="wpinv_discount_amount_wrap">
138
+            <?php do_action('wpinv_discount_form_before_amount', $discount); ?>
139
+            <div class="form-group row <?php echo esc_attr($discount->get_type('edit')); ?>" id="wpinv_discount_amount_wrap">
140 140
                 <label for="wpinv_discount_amount" class="col-sm-3 col-form-label">
141
-                    <?php _e( 'Discount Amount', 'invoicing' );?>
141
+                    <?php _e('Discount Amount', 'invoicing'); ?>
142 142
                 </label>
143 143
                 <div class="col-sm-8">
144 144
                     <div class="input-group input-group-sm">
145
-                        <?php if( 'left' == $position ) : ?>
145
+                        <?php if ('left' == $position) : ?>
146 146
                             <div class="input-group-prepend left wpinv-if-flat">
147 147
                                 <span class="input-group-text">
148 148
                                     <?php echo wpinv_currency_symbol(); ?>
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
                             </div>
151 151
                         <?php endif; ?>
152 152
 
153
-                        <input type="text" name="wpinv_discount_amount" id="wpinv_discount_amount" value="<?php echo esc_attr( $discount->get_amount( 'edit' ) ); ?>" placeholder="0" class="form-control">
153
+                        <input type="text" name="wpinv_discount_amount" id="wpinv_discount_amount" value="<?php echo esc_attr($discount->get_amount('edit')); ?>" placeholder="0" class="form-control">
154 154
 
155
-                        <?php if( 'right' == $position ) : ?>
155
+                        <?php if ('right' == $position) : ?>
156 156
                             <div class="input-group-prepend left wpinv-if-flat">
157 157
                                 <span class="input-group-text">
158 158
                                     <?php echo wpinv_currency_symbol(); ?>
@@ -165,15 +165,15 @@  discard block
 block discarded – undo
165 165
                     </div>
166 166
                 </div>
167 167
                 <div class="col-sm-1 pt-2 pl-0">
168
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?>"></span>
168
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the discount value. Ex: 10', 'invoicing'); ?>"></span>
169 169
                 </div>
170 170
             </div>
171
-            <?php do_action( 'wpinv_discount_form_amount', $discount ); ?>
171
+            <?php do_action('wpinv_discount_form_amount', $discount); ?>
172 172
 
173
-            <?php do_action( 'wpinv_discount_form_before_items', $discount ); ?>
173
+            <?php do_action('wpinv_discount_form_before_items', $discount); ?>
174 174
             <div class="form-group row">
175 175
                 <label for="wpinv_discount_items" class="col-sm-3 col-form-label">
176
-                    <?php _e( 'Items', 'invoicing' );?>
176
+                    <?php _e('Items', 'invoicing'); ?>
177 177
                 </label>
178 178
                 <div class="col-sm-8">
179 179
                     <?php
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
                             array(
182 182
                                 'id'               => 'wpinv_discount_items',
183 183
                                 'name'             => 'wpinv_discount_items[]',
184
-                                'label'            => __( 'Items', 'invoicing' ),
185
-                                'placeholder'      => __( 'Select Items', 'invoicing' ),
186
-                                'value'            => $discount->get_items( 'edit' ),
184
+                                'label'            => __('Items', 'invoicing'),
185
+                                'placeholder'      => __('Select Items', 'invoicing'),
186
+                                'value'            => $discount->get_items('edit'),
187 187
                                 'select2'          => true,
188 188
                                 'multiple'         => true,
189 189
                                 'data-allow-clear' => 'false',
@@ -193,15 +193,15 @@  discard block
 block discarded – undo
193 193
                     ?>
194 194
                 </div>
195 195
                 <div class="col-sm-1 pt-2 pl-0">
196
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select the items that are allowed to use this discount or leave blank to use this discount all items.', 'invoicing' ); ?>"></span>
196
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select the items that are allowed to use this discount or leave blank to use this discount all items.', 'invoicing'); ?>"></span>
197 197
                 </div>
198 198
             </div>
199
-            <?php do_action( 'wpinv_discount_form_items', $discount ); ?>
199
+            <?php do_action('wpinv_discount_form_items', $discount); ?>
200 200
 
201
-            <?php do_action( 'wpinv_discount_form_before_excluded_items', $discount ); ?>
201
+            <?php do_action('wpinv_discount_form_before_excluded_items', $discount); ?>
202 202
             <div class="form-group row">
203 203
                 <label for="wpinv_discount_excluded_items" class="col-sm-3 col-form-label">
204
-                    <?php _e( 'Excluded Items', 'invoicing' );?>
204
+                    <?php _e('Excluded Items', 'invoicing'); ?>
205 205
                 </label>
206 206
                 <div class="col-sm-8">
207 207
                     <?php
@@ -209,9 +209,9 @@  discard block
 block discarded – undo
209 209
                             array(
210 210
                                 'id'               => 'wpinv_discount_excluded_items',
211 211
                                 'name'             => 'wpinv_discount_excluded_items[]',
212
-                                'label'            => __( 'Excluded Items', 'invoicing' ),
213
-                                'placeholder'      => __( 'Select Items', 'invoicing' ),
214
-                                'value'            => $discount->get_excluded_items( 'edit' ),
212
+                                'label'            => __('Excluded Items', 'invoicing'),
213
+                                'placeholder'      => __('Select Items', 'invoicing'),
214
+                                'value'            => $discount->get_excluded_items('edit'),
215 215
                                 'select2'          => true,
216 216
                                 'multiple'         => true,
217 217
                                 'data-allow-clear' => 'false',
@@ -221,15 +221,15 @@  discard block
 block discarded – undo
221 221
                     ?>
222 222
                 </div>
223 223
                 <div class="col-sm-1 pt-2 pl-0">
224
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select all the items that are not allowed to use this discount.', 'invoicing' ); ?>"></span>
224
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select all the items that are not allowed to use this discount.', 'invoicing'); ?>"></span>
225 225
                 </div>
226 226
             </div>
227
-            <?php do_action( 'wpinv_discount_form_excluded_items', $discount ); ?>
227
+            <?php do_action('wpinv_discount_form_excluded_items', $discount); ?>
228 228
 
229
-            <?php do_action( 'wpinv_discount_form_before_required_items', $discount ); ?>
229
+            <?php do_action('wpinv_discount_form_before_required_items', $discount); ?>
230 230
             <div class="form-group row">
231 231
                 <label for="wpinv_discount_required_items" class="col-sm-3 col-form-label">
232
-                    <?php _e( 'Required Items', 'invoicing' );?>
232
+                    <?php _e('Required Items', 'invoicing'); ?>
233 233
                 </label>
234 234
                 <div class="col-sm-8">
235 235
                     <?php
@@ -237,9 +237,9 @@  discard block
 block discarded – undo
237 237
                             array(
238 238
                                 'id'               => 'wpinv_discount_required_items',
239 239
                                 'name'             => 'wpinv_discount_required_items[]',
240
-                                'label'            => __( 'Required Items', 'invoicing' ),
241
-                                'placeholder'      => __( 'Select Items', 'invoicing' ),
242
-                                'value'            => $discount->get_required_items( 'edit' ),
240
+                                'label'            => __('Required Items', 'invoicing'),
241
+                                'placeholder'      => __('Select Items', 'invoicing'),
242
+                                'value'            => $discount->get_required_items('edit'),
243 243
                                 'select2'          => true,
244 244
                                 'multiple'         => true,
245 245
                                 'data-allow-clear' => 'false',
@@ -249,15 +249,15 @@  discard block
 block discarded – undo
249 249
                     ?>
250 250
                 </div>
251 251
                 <div class="col-sm-1 pt-2 pl-0">
252
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select all the items that are required to be in the cart before using this discount.', 'invoicing' ); ?>"></span>
252
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select all the items that are required to be in the cart before using this discount.', 'invoicing'); ?>"></span>
253 253
                 </div>
254 254
             </div>
255
-            <?php do_action( 'wpinv_discount_form_required_items', $discount ); ?>
255
+            <?php do_action('wpinv_discount_form_required_items', $discount); ?>
256 256
 
257
-            <?php do_action( 'wpinv_discount_form_before_start', $discount ); ?>
257
+            <?php do_action('wpinv_discount_form_before_start', $discount); ?>
258 258
             <div class="form-group row">
259 259
                 <label for="wpinv_discount_start" class="col-sm-3 col-form-label">
260
-                    <?php _e( 'Start Date', 'invoicing' );?>
260
+                    <?php _e('Start Date', 'invoicing'); ?>
261 261
                 </label>
262 262
                 <div class="col-sm-8">
263 263
                     <?php
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
                                 'type'        => 'datepicker',
267 267
                                 'id'          => 'wpinv_discount_start',
268 268
                                 'name'        => 'wpinv_discount_start',
269
-                                'label'       => __( 'Start Date', 'invoicing' ),
269
+                                'label'       => __('Start Date', 'invoicing'),
270 270
                                 'placeholder' => 'YYYY-MM-DD 00:00',
271 271
                                 'class'       => 'form-control-sm',
272
-                                'value'       => $discount->get_start_date( 'edit' ),
272
+                                'value'       => $discount->get_start_date('edit'),
273 273
                                 'extra_attributes' => array(
274 274
                                     'data-enable-time' => 'true',
275 275
                                     'data-time_24hr'   => 'true',
@@ -280,15 +280,15 @@  discard block
 block discarded – undo
280 280
                     ?>
281 281
                 </div>
282 282
                 <div class="col-sm-1 pt-2 pl-0">
283
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?>"></span>
283
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?>"></span>
284 284
                 </div>
285 285
             </div>
286
-            <?php do_action( 'wpinv_discount_form_start', $discount ); ?>
286
+            <?php do_action('wpinv_discount_form_start', $discount); ?>
287 287
 
288
-            <?php do_action( 'wpinv_discount_form_before_expiration', $discount ); ?>
288
+            <?php do_action('wpinv_discount_form_before_expiration', $discount); ?>
289 289
             <div class="form-group row">
290 290
                 <label for="wpinv_discount_expiration" class="col-sm-3 col-form-label">
291
-                    <?php _e( 'Expiration Date', 'invoicing' );?>
291
+                    <?php _e('Expiration Date', 'invoicing'); ?>
292 292
                 </label>
293 293
                 <div class="col-sm-8">
294 294
                     <?php
@@ -297,10 +297,10 @@  discard block
 block discarded – undo
297 297
                                 'type'        => 'datepicker',
298 298
                                 'id'          => 'wpinv_discount_expiration',
299 299
                                 'name'        => 'wpinv_discount_expiration',
300
-                                'label'       => __( 'Expiration Date', 'invoicing' ),
300
+                                'label'       => __('Expiration Date', 'invoicing'),
301 301
                                 'placeholder' => 'YYYY-MM-DD 00:00',
302 302
                                 'class'       => 'form-control-sm',
303
-                                'value'       => $discount->get_end_date( 'edit' ),
303
+                                'value'       => $discount->get_end_date('edit'),
304 304
                                 'extra_attributes' => array(
305 305
                                     'data-enable-time' => 'true',
306 306
                                     'data-time_24hr'   => 'true',
@@ -313,27 +313,27 @@  discard block
 block discarded – undo
313 313
                     ?>
314 314
                 </div>
315 315
                 <div class="col-sm-1 pt-2 pl-0">
316
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the date after which the discount will expire.', 'invoicing' ); ?>"></span>
316
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the date after which the discount will expire.', 'invoicing'); ?>"></span>
317 317
                 </div>
318 318
             </div>
319
-            <?php do_action( 'wpinv_discount_form_expiration', $discount ); ?>
319
+            <?php do_action('wpinv_discount_form_expiration', $discount); ?>
320 320
 
321
-            <?php do_action( 'wpinv_discount_form_before_min_total', $discount ); ?>
321
+            <?php do_action('wpinv_discount_form_before_min_total', $discount); ?>
322 322
             <div class="form-group row">
323 323
                 <label for="wpinv_discount_min_total" class="col-sm-3 col-form-label">
324
-                    <?php _e( 'Minimum Amount', 'invoicing' );?>
324
+                    <?php _e('Minimum Amount', 'invoicing'); ?>
325 325
                 </label>
326 326
                 <div class="col-sm-8">
327 327
                     <div class="input-group input-group-sm">
328
-                        <?php if( 'left' == $position ) : ?>
328
+                        <?php if ('left' == $position) : ?>
329 329
                             <div class="input-group-prepend">
330 330
                                 <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span>
331 331
                             </div>
332 332
                         <?php endif; ?>
333 333
 
334
-                        <input type="text" name="wpinv_discount_min_total" id="wpinv_discount_min_total" value="<?php echo esc_attr( $discount->get_minimum_total( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'No minimum', 'invoicing' ); ?>" class="form-control">
334
+                        <input type="text" name="wpinv_discount_min_total" id="wpinv_discount_min_total" value="<?php echo esc_attr($discount->get_minimum_total('edit')); ?>" placeholder="<?php esc_attr_e('No minimum', 'invoicing'); ?>" class="form-control">
335 335
 
336
-                        <?php if( 'left' != $position ) : ?>
336
+                        <?php if ('left' != $position) : ?>
337 337
                             <div class="input-group-append">
338 338
                                 <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span>
339 339
                             </div>
@@ -341,27 +341,27 @@  discard block
 block discarded – undo
341 341
                     </div>
342 342
                 </div>
343 343
                 <div class="col-sm-1 pt-2 pl-0">
344
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the minimum amount (including taxes) required to use this discount.', 'invoicing' ); ?>"></span>
344
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the minimum amount (including taxes) required to use this discount.', 'invoicing'); ?>"></span>
345 345
                 </div>
346 346
             </div>
347
-            <?php do_action( 'wpinv_discount_form_min_total', $discount ); ?>
347
+            <?php do_action('wpinv_discount_form_min_total', $discount); ?>
348 348
 
349
-            <?php do_action( 'wpinv_discount_form_before_max_total', $discount ); ?>
349
+            <?php do_action('wpinv_discount_form_before_max_total', $discount); ?>
350 350
             <div class="form-group row">
351 351
                 <label for="wpinv_discount_max_total" class="col-sm-3 col-form-label">
352
-                    <?php _e( 'Maximum Amount', 'invoicing' );?>
352
+                    <?php _e('Maximum Amount', 'invoicing'); ?>
353 353
                 </label>
354 354
                 <div class="col-sm-8">
355 355
                     <div class="input-group input-group-sm">
356
-                        <?php if( 'left' == $position ) : ?>
356
+                        <?php if ('left' == $position) : ?>
357 357
                             <div class="input-group-prepend">
358 358
                                 <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span>
359 359
                             </div>
360 360
                         <?php endif; ?>
361 361
 
362
-                        <input type="text" name="wpinv_discount_max_total" id="wpinv_discount_max_total" value="<?php echo esc_attr( $discount->get_maximum_total( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'No maximum', 'invoicing' ); ?>" class="form-control">
362
+                        <input type="text" name="wpinv_discount_max_total" id="wpinv_discount_max_total" value="<?php echo esc_attr($discount->get_maximum_total('edit')); ?>" placeholder="<?php esc_attr_e('No maximum', 'invoicing'); ?>" class="form-control">
363 363
 
364
-                        <?php if( 'left' != $position ) : ?>
364
+                        <?php if ('left' != $position) : ?>
365 365
                             <div class="input-group-append">
366 366
                                 <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span>
367 367
                             </div>
@@ -369,30 +369,30 @@  discard block
 block discarded – undo
369 369
                     </div>
370 370
                 </div>
371 371
                 <div class="col-sm-1 pt-2 pl-0">
372
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the maximum amount (including taxes) allowed when using this discount.', 'invoicing' ); ?>"></span>
372
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the maximum amount (including taxes) allowed when using this discount.', 'invoicing'); ?>"></span>
373 373
                 </div>
374 374
             </div>
375
-            <?php do_action( 'wpinv_discount_form_before_max_total', $discount ); ?>
375
+            <?php do_action('wpinv_discount_form_before_max_total', $discount); ?>
376 376
 
377
-            <?php do_action( 'wpinv_discount_form_before_max_uses', $discount ); ?>
377
+            <?php do_action('wpinv_discount_form_before_max_uses', $discount); ?>
378 378
             <div class="form-group row">
379 379
                 <label for="wpinv_discount_max_uses" class="col-sm-3 col-form-label">
380
-                    <?php _e( 'Maximum Uses', 'invoicing' );?>
380
+                    <?php _e('Maximum Uses', 'invoicing'); ?>
381 381
                 </label>
382 382
                 <div class="col-sm-8">
383
-                    <input type="text" value="<?php echo esc_attr( $discount->get_max_uses( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'Unlimited', 'invoicing' ); ?>" name="wpinv_discount_max_uses" id="wpinv_discount_max_uses" style="width: 100%;" />
383
+                    <input type="text" value="<?php echo esc_attr($discount->get_max_uses('edit')); ?>" placeholder="<?php esc_attr_e('Unlimited', 'invoicing'); ?>" name="wpinv_discount_max_uses" id="wpinv_discount_max_uses" style="width: 100%;" />
384 384
                 </div>
385 385
                 <div class="col-sm-1 pt-2 pl-0">
386
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the maximum number of times that this discount code can be used.', 'invoicing' ); ?>"></span>
386
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the maximum number of times that this discount code can be used.', 'invoicing'); ?>"></span>
387 387
                 </div>
388 388
             </div>
389
-            <?php do_action( 'wpinv_discount_form_max_uses', $discount ); ?>
389
+            <?php do_action('wpinv_discount_form_max_uses', $discount); ?>
390 390
 
391
-            <?php do_action( 'wpinv_discount_form_last', $discount ); ?>
391
+            <?php do_action('wpinv_discount_form_last', $discount); ?>
392 392
 
393 393
         </div>
394 394
         <?php
395
-        do_action( 'wpinv_discount_form_bottom', $post );
395
+        do_action('wpinv_discount_form_bottom', $post);
396 396
     }
397 397
 
398 398
     /**
@@ -400,31 +400,31 @@  discard block
 block discarded – undo
400 400
 	 *
401 401
 	 * @param int $post_id
402 402
 	 */
403
-	public static function save( $post_id ) {
403
+	public static function save($post_id) {
404 404
 
405 405
         // Prepare the discount.
406
-        $discount = new WPInv_Discount( $post_id );
406
+        $discount = new WPInv_Discount($post_id);
407 407
 
408 408
         // Load new data.
409 409
         $discount->set_props(
410 410
 			array(
411
-				'code'                 => isset( $_POST['wpinv_discount_code'] ) ? wpinv_clean( $_POST['wpinv_discount_code'] ) : null,
412
-				'amount'               => isset( $_POST['wpinv_discount_amount'] ) ? floatval( $_POST['wpinv_discount_amount'] ) : null,
413
-				'start'                => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null,
414
-				'expiration'           => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null,
415
-				'is_single_use'        => ! empty( $_POST['wpinv_discount_single_use'] ),
416
-                'type'                 => isset( $_POST['wpinv_discount_type'] ) ? wpinv_clean( $_POST['wpinv_discount_type'] ) : null,
417
-				'is_recurring'         => ! empty( $_POST['wpinv_discount_recurring'] ),
418
-				'items'                => isset( $_POST['wpinv_discount_items'] ) ? wpinv_clean( $_POST['wpinv_discount_items'] ) : array(),
419
-				'excluded_items'       => isset( $_POST['wpinv_discount_excluded_items'] ) ? wpinv_clean( $_POST['wpinv_discount_excluded_items'] ) : array(),
420
-                'required_items'       => isset( $_POST['wpinv_discount_required_items'] ) ? wpinv_clean( $_POST['wpinv_discount_required_items'] ) : array(),
421
-				'max_uses'             => isset( $_POST['wpinv_discount_max_uses'] ) ? intval( $_POST['wpinv_discount_max_uses'] ) : null,
422
-				'min_total'            => isset( $_POST['wpinv_discount_min_total'] ) ? floatval( $_POST['wpinv_discount_min_total'] ) : null,
423
-				'max_total'            => isset( $_POST['wpinv_discount_max_total'] ) ? floatval( $_POST['wpinv_discount_max_total'] ) : null,
411
+				'code'                 => isset($_POST['wpinv_discount_code']) ? wpinv_clean($_POST['wpinv_discount_code']) : null,
412
+				'amount'               => isset($_POST['wpinv_discount_amount']) ? floatval($_POST['wpinv_discount_amount']) : null,
413
+				'start'                => isset($_POST['wpinv_discount_start']) ? wpinv_clean($_POST['wpinv_discount_start']) : null,
414
+				'expiration'           => isset($_POST['wpinv_discount_expiration']) ? wpinv_clean($_POST['wpinv_discount_expiration']) : null,
415
+				'is_single_use'        => !empty($_POST['wpinv_discount_single_use']),
416
+                'type'                 => isset($_POST['wpinv_discount_type']) ? wpinv_clean($_POST['wpinv_discount_type']) : null,
417
+				'is_recurring'         => !empty($_POST['wpinv_discount_recurring']),
418
+				'items'                => isset($_POST['wpinv_discount_items']) ? wpinv_clean($_POST['wpinv_discount_items']) : array(),
419
+				'excluded_items'       => isset($_POST['wpinv_discount_excluded_items']) ? wpinv_clean($_POST['wpinv_discount_excluded_items']) : array(),
420
+                'required_items'       => isset($_POST['wpinv_discount_required_items']) ? wpinv_clean($_POST['wpinv_discount_required_items']) : array(),
421
+				'max_uses'             => isset($_POST['wpinv_discount_max_uses']) ? intval($_POST['wpinv_discount_max_uses']) : null,
422
+				'min_total'            => isset($_POST['wpinv_discount_min_total']) ? floatval($_POST['wpinv_discount_min_total']) : null,
423
+				'max_total'            => isset($_POST['wpinv_discount_max_total']) ? floatval($_POST['wpinv_discount_max_total']) : null,
424 424
 			)
425 425
         );
426 426
 
427 427
 		$discount->save();
428
-		do_action( 'getpaid_discount_metabox_save', $post_id, $discount );
428
+		do_action('getpaid_discount_metabox_save', $post_id, $discount);
429 429
 	}
430 430
 }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-address.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Invoice_Address {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25 25
 
26 26
         // Prepare the invoice.
@@ -366,18 +366,18 @@  discard block
 block discarded – undo
366 366
     }
367 367
 
368 368
     /**
369
-	 * Save meta box data.
370
-	 *
371
-	 * @param int $post_id
372
-	 */
373
-	public static function save( $post_id ) {
369
+     * Save meta box data.
370
+     *
371
+     * @param int $post_id
372
+     */
373
+    public static function save( $post_id ) {
374 374
 
375 375
         // Prepare the invoice.
376 376
         $invoice = new WPInv_Invoice( $post_id );
377 377
 
378 378
         // Load new data.
379 379
         $invoice->set_props(
380
-			array(
380
+            array(
381 381
                 'template'             => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null,
382 382
                 'email_cc'             => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null,
383 383
                 'disable_taxes'        => ! empty( $_POST['disable_taxes'] ),
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
                 'due_date'             => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null,
401 401
                 'number'               => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null,
402 402
                 'status'               => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null,
403
-			)
403
+            )
404 404
         );
405 405
 
406 406
         // Discount code.
@@ -465,6 +465,6 @@  discard block
 block discarded – undo
465 465
         }
466 466
 
467 467
         // Fires after an invoice is saved.
468
-		do_action( 'wpinv_invoice_metabox_saved', $invoice );
469
-	}
468
+        do_action( 'wpinv_invoice_metabox_saved', $invoice );
469
+    }
470 470
 }
Please login to merge, or discard this patch.
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the invoice.
27
-        $invoice  = new WPInv_Invoice( $post );
28
-        $customer = $invoice->exists() ? $invoice->get_user_id( 'edit' ) : get_current_user_id();
29
-        $customer = new WP_User( $customer );
30
-        $display  = sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email );
31
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
27
+        $invoice  = new WPInv_Invoice($post);
28
+        $customer = $invoice->exists() ? $invoice->get_user_id('edit') : get_current_user_id();
29
+        $customer = new WP_User($customer);
30
+        $display  = sprintf(_x('%1$s (%2$s)', 'user dropdown', 'invoicing'), $customer->display_name, $customer->user_email);
31
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
32 32
 
33 33
         ?>
34 34
 
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
                         <div class="col-12 col-sm-6">
44 44
                             <div id="getpaid-invoice-user-id-wrapper" class="form-group">
45 45
                                 <div>
46
-                                    <label for="post_author_override"><?php _e( 'Customer', 'invoicing' );?></label>
46
+                                    <label for="post_author_override"><?php _e('Customer', 'invoicing'); ?></label>
47 47
                                 </div>
48 48
                                 <div>
49
-                                    <select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e( 'Search for a customer by email or name', 'invoicing' ); ?>">
50
-                                        <option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo esc_html( $display ); ?> </option>)
49
+                                    <select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e('Search for a customer by email or name', 'invoicing'); ?>">
50
+                                        <option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo esc_html($display); ?> </option>)
51 51
                                     </select>
52 52
                                 </div>
53 53
                             </div>
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
                                             'type'        => 'text',
61 61
                                             'id'          => 'getpaid-invoice-new-user-email',
62 62
                                             'name'        => 'wpinv_email',
63
-                                            'label'       => __( 'Email', 'invoicing' ) . '<span class="required">*</span>',
63
+                                            'label'       => __('Email', 'invoicing') . '<span class="required">*</span>',
64 64
                                             'label_type'  => 'vertical',
65 65
                                             'placeholder' => '[email protected]',
66 66
                                             'class'       => 'form-control-sm',
@@ -70,18 +70,18 @@  discard block
 block discarded – undo
70 70
                             </div>
71 71
                         </div>
72 72
                         <div class="col-12 col-sm-6 form-group mt-sm-4">
73
-                            <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?>
73
+                            <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?>
74 74
                                 <a id="getpaid-invoice-fill-user-details" class="button button-small button-secondary" href="javascript:void(0)">
75 75
                                     <i aria-hidden="true" class="fa fa-refresh"></i>
76
-                                    <?php _e( 'Fill User Details', 'invoicing' );?>
76
+                                    <?php _e('Fill User Details', 'invoicing'); ?>
77 77
                                 </a>
78 78
                                 <a id="getpaid-invoice-create-new-user-button" class="button button-small button-secondary" href="javascript:void(0)">
79 79
                                     <i aria-hidden="true" class="fa fa-plus"></i>
80
-                                    <?php _e( 'Add New User', 'invoicing' );?>
80
+                                    <?php _e('Add New User', 'invoicing'); ?>
81 81
                                 </a>
82 82
                                 <a id="getpaid-invoice-cancel-create-new-user" class="button button-small button-secondary d-none" href="javascript:void(0)">
83 83
                                     <i aria-hidden="true" class="fa fa-close"></i>
84
-                                    <?php _e( 'Cancel', 'invoicing' );?>
84
+                                    <?php _e('Cancel', 'invoicing'); ?>
85 85
                                 </a>
86 86
                             <?php endif; ?>
87 87
                         </div>
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
                                         'type'        => 'text',
95 95
                                         'id'          => 'wpinv_first_name',
96 96
                                         'name'        => 'wpinv_first_name',
97
-                                        'label'       => __( 'First Name', 'invoicing' ),
97
+                                        'label'       => __('First Name', 'invoicing'),
98 98
                                         'label_type'  => 'vertical',
99 99
                                         'placeholder' => '',
100 100
                                         'class'       => 'form-control-sm',
101
-                                        'value'       => $invoice->get_first_name( 'edit' ),
101
+                                        'value'       => $invoice->get_first_name('edit'),
102 102
                                     )
103 103
                                 );
104 104
                             ?>
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
                                         'type'        => 'text',
111 111
                                         'id'          => 'wpinv_last_name',
112 112
                                         'name'        => 'wpinv_last_name',
113
-                                        'label'       => __( 'Last Name', 'invoicing' ),
113
+                                        'label'       => __('Last Name', 'invoicing'),
114 114
                                         'label_type'  => 'vertical',
115 115
                                         'placeholder' => '',
116 116
                                         'class'       => 'form-control-sm',
117
-                                        'value'       => $invoice->get_last_name( 'edit' ),
117
+                                        'value'       => $invoice->get_last_name('edit'),
118 118
                                     )
119 119
                                 );
120 120
                             ?>
@@ -129,11 +129,11 @@  discard block
 block discarded – undo
129 129
                                         'type'        => 'text',
130 130
                                         'id'          => 'wpinv_company',
131 131
                                         'name'        => 'wpinv_company',
132
-                                        'label'       => __( 'Company', 'invoicing' ),
132
+                                        'label'       => __('Company', 'invoicing'),
133 133
                                         'label_type'  => 'vertical',
134 134
                                         'placeholder' => '',
135 135
                                         'class'       => 'form-control-sm',
136
-                                        'value'       => $invoice->get_company( 'edit' ),
136
+                                        'value'       => $invoice->get_company('edit'),
137 137
                                     )
138 138
                                 );
139 139
                             ?>
@@ -145,11 +145,11 @@  discard block
 block discarded – undo
145 145
                                         'type'        => 'text',
146 146
                                         'id'          => 'wpinv_vat_number',
147 147
                                         'name'        => 'wpinv_vat_number',
148
-                                        'label'       => __( 'Vat Number', 'invoicing' ),
148
+                                        'label'       => __('Vat Number', 'invoicing'),
149 149
                                         'label_type'  => 'vertical',
150 150
                                         'placeholder' => '',
151 151
                                         'class'       => 'form-control-sm getpaid-recalculate-prices-on-change',
152
-                                        'value'       => $invoice->get_vat_number( 'edit' ),
152
+                                        'value'       => $invoice->get_vat_number('edit'),
153 153
                                     )
154 154
                                 );
155 155
                             ?>
@@ -164,11 +164,11 @@  discard block
 block discarded – undo
164 164
                                         'type'        => 'text',
165 165
                                         'id'          => 'wpinv_address',
166 166
                                         'name'        => 'wpinv_address',
167
-                                        'label'       => __( 'Address', 'invoicing' ),
167
+                                        'label'       => __('Address', 'invoicing'),
168 168
                                         'label_type'  => 'vertical',
169 169
                                         'placeholder' => '',
170 170
                                         'class'       => 'form-control-sm',
171
-                                        'value'       => $invoice->get_address( 'edit' ),
171
+                                        'value'       => $invoice->get_address('edit'),
172 172
                                     )
173 173
                                 );
174 174
                             ?>
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
                                         'type'        => 'text',
181 181
                                         'id'          => 'wpinv_city',
182 182
                                         'name'        => 'wpinv_city',
183
-                                        'label'       => __( 'City', 'invoicing' ),
183
+                                        'label'       => __('City', 'invoicing'),
184 184
                                         'label_type'  => 'vertical',
185 185
                                         'placeholder' => '',
186 186
                                         'class'       => 'form-control-sm',
187
-                                        'value'       => $invoice->get_city( 'edit' ),
187
+                                        'value'       => $invoice->get_city('edit'),
188 188
                                     )
189 189
                                 );
190 190
                             ?>
@@ -198,11 +198,11 @@  discard block
 block discarded – undo
198 198
                                     array(
199 199
                                         'id'          => 'wpinv_country',
200 200
                                         'name'        => 'wpinv_country',
201
-                                        'label'       => __( 'Country', 'invoicing' ),
201
+                                        'label'       => __('Country', 'invoicing'),
202 202
                                         'label_type'  => 'vertical',
203
-                                        'placeholder' => __( 'Choose a country', 'invoicing' ),
203
+                                        'placeholder' => __('Choose a country', 'invoicing'),
204 204
                                         'class'       => 'form-control-sm getpaid-recalculate-prices-on-change',
205
-                                        'value'       => $invoice->get_country( 'edit' ),
205
+                                        'value'       => $invoice->get_country('edit'),
206 206
                                         'options'     => wpinv_get_country_list(),
207 207
                                         'data-allow-clear' => 'false',
208 208
                                         'select2'          => true,
@@ -213,20 +213,20 @@  discard block
 block discarded – undo
213 213
                         <div class="col-12 col-sm-6">
214 214
                             <?php
215 215
 
216
-                                $states = wpinv_get_country_states( $invoice->get_country( 'edit' ) );
216
+                                $states = wpinv_get_country_states($invoice->get_country('edit'));
217 217
 
218
-                                if ( empty( $states ) ) {
218
+                                if (empty($states)) {
219 219
 
220 220
                                     echo aui()->input(
221 221
                                         array(
222 222
                                             'type'        => 'text',
223 223
                                             'id'          => 'wpinv_state',
224 224
                                             'name'        => 'wpinv_state',
225
-                                            'label'       => __( 'State', 'invoicing' ),
225
+                                            'label'       => __('State', 'invoicing'),
226 226
                                             'label_type'  => 'vertical',
227 227
                                             'placeholder' => '',
228 228
                                             'class'       => 'form-control-sm',
229
-                                            'value'       => $invoice->get_state( 'edit' ),
229
+                                            'value'       => $invoice->get_state('edit'),
230 230
                                         )
231 231
                                     );
232 232
 
@@ -236,11 +236,11 @@  discard block
 block discarded – undo
236 236
                                         array(
237 237
                                             'id'          => 'wpinv_state',
238 238
                                             'name'        => 'wpinv_state',
239
-                                            'label'       => __( 'State', 'invoicing' ),
239
+                                            'label'       => __('State', 'invoicing'),
240 240
                                             'label_type'  => 'vertical',
241
-                                            'placeholder' => __( 'Select a state', 'invoicing' ),
241
+                                            'placeholder' => __('Select a state', 'invoicing'),
242 242
                                             'class'       => 'form-control-sm',
243
-                                            'value'       => $invoice->get_state( 'edit' ),
243
+                                            'value'       => $invoice->get_state('edit'),
244 244
                                             'options'     => $states,
245 245
                                             'data-allow-clear' => 'false',
246 246
                                             'select2'          => true,
@@ -261,11 +261,11 @@  discard block
 block discarded – undo
261 261
                                         'type'        => 'text',
262 262
                                         'id'          => 'wpinv_zip',
263 263
                                         'name'        => 'wpinv_zip',
264
-                                        'label'       => __( 'Zip / Postal Code', 'invoicing' ),
264
+                                        'label'       => __('Zip / Postal Code', 'invoicing'),
265 265
                                         'label_type'  => 'vertical',
266 266
                                         'placeholder' => '',
267 267
                                         'class'       => 'form-control-sm',
268
-                                        'value'       => $invoice->get_zip( 'edit' ),
268
+                                        'value'       => $invoice->get_zip('edit'),
269 269
                                     )
270 270
                                 );
271 271
                             ?>
@@ -277,19 +277,19 @@  discard block
 block discarded – undo
277 277
                                         'type'        => 'text',
278 278
                                         'id'          => 'wpinv_phone',
279 279
                                         'name'        => 'wpinv_phone',
280
-                                        'label'       => __( 'Phone', 'invoicing' ),
280
+                                        'label'       => __('Phone', 'invoicing'),
281 281
                                         'label_type'  => 'vertical',
282 282
                                         'placeholder' => '',
283 283
                                         'class'       => 'form-control-sm',
284
-                                        'value'       => $invoice->get_phone( 'edit' ),
284
+                                        'value'       => $invoice->get_phone('edit'),
285 285
                                     )
286 286
                                 );
287 287
                             ?>
288 288
                         </div>
289 289
                     </div>
290 290
 
291
-                    <?php if ( ! apply_filters( 'getpaid_use_new_invoice_items_metabox', false ) ) : ?>
292
-                        <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?>
291
+                    <?php if (!apply_filters('getpaid_use_new_invoice_items_metabox', false)) : ?>
292
+                        <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?>
293 293
 
294 294
                         <div class="row">
295 295
                             <div class="col-12 col-sm-6">
@@ -298,14 +298,14 @@  discard block
 block discarded – undo
298 298
                                         array(
299 299
                                             'id'          => 'wpinv_template',
300 300
                                             'name'        => 'wpinv_template',
301
-                                            'label'       => __( 'Template', 'invoicing' ),
301
+                                            'label'       => __('Template', 'invoicing'),
302 302
                                             'label_type'  => 'vertical',
303
-                                            'placeholder' => __( 'Choose a template', 'invoicing' ),
303
+                                            'placeholder' => __('Choose a template', 'invoicing'),
304 304
                                             'class'       => 'form-control-sm',
305
-                                            'value'       => $invoice->get_template( 'edit' ),
305
+                                            'value'       => $invoice->get_template('edit'),
306 306
                                             'options'     => array(
307
-                                                'quantity' => __( 'Quantity', 'invoicing' ),
308
-                                                'hours'    => __( 'Hours', 'invoicing' ),
307
+                                                'quantity' => __('Quantity', 'invoicing'),
308
+                                                'hours'    => __('Hours', 'invoicing'),
309 309
                                                 //'amount'   => __( 'Amount Only', 'invoicing' ),
310 310
                                             ),
311 311
                                             'data-allow-clear' => 'false',
@@ -322,11 +322,11 @@  discard block
 block discarded – undo
322 322
                                         array(
323 323
                                             'id'          => 'wpinv_currency',
324 324
                                             'name'        => 'wpinv_currency',
325
-                                            'label'       => __( 'Currency', 'invoicing' ),
325
+                                            'label'       => __('Currency', 'invoicing'),
326 326
                                             'label_type'  => 'vertical',
327
-                                            'placeholder' => __( 'Select Invoice Currency', 'invoicing' ),
327
+                                            'placeholder' => __('Select Invoice Currency', 'invoicing'),
328 328
                                             'class'       => 'form-control-sm getpaid-recalculate-prices-on-change',
329
-                                            'value'       => $invoice->get_currency( 'edit' ),
329
+                                            'value'       => $invoice->get_currency('edit'),
330 330
                                             'required'    => false,
331 331
                                             'data-allow-clear' => 'false',
332 332
                                             'select2'          => true,
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
                             </div>
339 339
                         </div>
340 340
 
341
-                        <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?>
341
+                        <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?>
342 342
                     <?php endif; ?>
343 343
 
344 344
                     <div class="row">
@@ -349,18 +349,18 @@  discard block
 block discarded – undo
349 349
                                         'type'        => 'text',
350 350
                                         'id'          => 'wpinv_company_id',
351 351
                                         'name'        => 'wpinv_company_id',
352
-                                        'label'       => __( 'Company ID', 'invoicing' ),
352
+                                        'label'       => __('Company ID', 'invoicing'),
353 353
                                         'label_type'  => 'vertical',
354 354
                                         'placeholder' => '',
355 355
                                         'class'       => 'form-control-sm',
356
-                                        'value'       => $invoice->get_company_id( 'edit' ),
356
+                                        'value'       => $invoice->get_company_id('edit'),
357 357
                                     )
358 358
                                 );
359 359
                             ?>
360 360
                         </div>
361 361
                     </div>
362 362
 
363
-                    <?php do_action( 'getpaid_after_metabox_invoice_address', $invoice ); ?>
363
+                    <?php do_action('getpaid_after_metabox_invoice_address', $invoice); ?>
364 364
             </div>
365 365
         <?php
366 366
     }
@@ -370,51 +370,51 @@  discard block
 block discarded – undo
370 370
 	 *
371 371
 	 * @param int $post_id
372 372
 	 */
373
-	public static function save( $post_id ) {
373
+	public static function save($post_id) {
374 374
 
375 375
         // Prepare the invoice.
376
-        $invoice = new WPInv_Invoice( $post_id );
376
+        $invoice = new WPInv_Invoice($post_id);
377 377
 
378 378
         // Load new data.
379 379
         $invoice->set_props(
380 380
 			array(
381
-                'template'             => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null,
382
-                'email_cc'             => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null,
383
-                'disable_taxes'        => ! empty( $_POST['disable_taxes'] ),
384
-                'currency'             => isset( $_POST['wpinv_currency'] ) ? wpinv_clean( $_POST['wpinv_currency'] ) : null,
385
-                'gateway'              => ( $invoice->needs_payment() && isset( $_POST['wpinv_gateway'] ) ) ? wpinv_clean( $_POST['wpinv_gateway'] ) : null,
386
-                'address'              => isset( $_POST['wpinv_address'] ) ? wpinv_clean( $_POST['wpinv_address'] ) : null,
387
-                'vat_number'           => isset( $_POST['wpinv_vat_number'] ) ? wpinv_clean( $_POST['wpinv_vat_number'] ) : null,
388
-                'company'              => isset( $_POST['wpinv_company'] ) ? wpinv_clean( $_POST['wpinv_company'] ) : null,
389
-                'company_id'           => isset( $_POST['wpinv_company_id'] ) ? wpinv_clean( $_POST['wpinv_company_id'] ) : null,
390
-                'zip'                  => isset( $_POST['wpinv_zip'] ) ? wpinv_clean( $_POST['wpinv_zip'] ) : null,
391
-                'state'                => isset( $_POST['wpinv_state'] ) ? wpinv_clean( $_POST['wpinv_state'] ) : null,
392
-                'city'                 => isset( $_POST['wpinv_city'] ) ? wpinv_clean( $_POST['wpinv_city'] ) : null,
393
-                'country'              => isset( $_POST['wpinv_country'] ) ? wpinv_clean( $_POST['wpinv_country'] ) : null,
394
-                'phone'                => isset( $_POST['wpinv_phone'] ) ? wpinv_clean( $_POST['wpinv_phone'] ) : null,
395
-                'first_name'           => isset( $_POST['wpinv_first_name'] ) ? wpinv_clean( $_POST['wpinv_first_name'] ) : null,
396
-                'last_name'            => isset( $_POST['wpinv_last_name'] ) ? wpinv_clean( $_POST['wpinv_last_name'] ) : null,
397
-                'author'               => isset( $_POST['post_author_override'] ) ? wpinv_clean( $_POST['post_author_override'] ) : null,
398
-                'date_created'         => isset( $_POST['date_created'] ) ? wpinv_clean( $_POST['date_created'] ) : null,
399
-                'date_completed'       => isset( $_POST['wpinv_date_completed'] ) ? wpinv_clean( $_POST['wpinv_date_completed'] ) : null,
400
-                'due_date'             => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null,
401
-                'number'               => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null,
402
-                'status'               => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null,
381
+                'template'             => isset($_POST['wpinv_template']) ? wpinv_clean($_POST['wpinv_template']) : null,
382
+                'email_cc'             => isset($_POST['wpinv_cc']) ? wpinv_clean($_POST['wpinv_cc']) : null,
383
+                'disable_taxes'        => !empty($_POST['disable_taxes']),
384
+                'currency'             => isset($_POST['wpinv_currency']) ? wpinv_clean($_POST['wpinv_currency']) : null,
385
+                'gateway'              => ($invoice->needs_payment() && isset($_POST['wpinv_gateway'])) ? wpinv_clean($_POST['wpinv_gateway']) : null,
386
+                'address'              => isset($_POST['wpinv_address']) ? wpinv_clean($_POST['wpinv_address']) : null,
387
+                'vat_number'           => isset($_POST['wpinv_vat_number']) ? wpinv_clean($_POST['wpinv_vat_number']) : null,
388
+                'company'              => isset($_POST['wpinv_company']) ? wpinv_clean($_POST['wpinv_company']) : null,
389
+                'company_id'           => isset($_POST['wpinv_company_id']) ? wpinv_clean($_POST['wpinv_company_id']) : null,
390
+                'zip'                  => isset($_POST['wpinv_zip']) ? wpinv_clean($_POST['wpinv_zip']) : null,
391
+                'state'                => isset($_POST['wpinv_state']) ? wpinv_clean($_POST['wpinv_state']) : null,
392
+                'city'                 => isset($_POST['wpinv_city']) ? wpinv_clean($_POST['wpinv_city']) : null,
393
+                'country'              => isset($_POST['wpinv_country']) ? wpinv_clean($_POST['wpinv_country']) : null,
394
+                'phone'                => isset($_POST['wpinv_phone']) ? wpinv_clean($_POST['wpinv_phone']) : null,
395
+                'first_name'           => isset($_POST['wpinv_first_name']) ? wpinv_clean($_POST['wpinv_first_name']) : null,
396
+                'last_name'            => isset($_POST['wpinv_last_name']) ? wpinv_clean($_POST['wpinv_last_name']) : null,
397
+                'author'               => isset($_POST['post_author_override']) ? wpinv_clean($_POST['post_author_override']) : null,
398
+                'date_created'         => isset($_POST['date_created']) ? wpinv_clean($_POST['date_created']) : null,
399
+                'date_completed'       => isset($_POST['wpinv_date_completed']) ? wpinv_clean($_POST['wpinv_date_completed']) : null,
400
+                'due_date'             => isset($_POST['wpinv_due_date']) ? wpinv_clean($_POST['wpinv_due_date']) : null,
401
+                'number'               => isset($_POST['wpinv_number']) ? wpinv_clean($_POST['wpinv_number']) : null,
402
+                'status'               => isset($_POST['wpinv_status']) ? wpinv_clean($_POST['wpinv_status']) : null,
403 403
 			)
404 404
         );
405 405
 
406 406
         // Discount code.
407
-        if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
407
+        if (!$invoice->is_paid() && !$invoice->is_refunded()) {
408 408
 
409
-            if ( isset( $_POST['wpinv_discount_code'] ) ) {
410
-                $invoice->set_discount_code( wpinv_clean( $_POST['wpinv_discount_code'] ) );
409
+            if (isset($_POST['wpinv_discount_code'])) {
410
+                $invoice->set_discount_code(wpinv_clean($_POST['wpinv_discount_code']));
411 411
             }
412 412
 
413
-            $discount = new WPInv_Discount( $invoice->get_discount_code() );
414
-            if ( $discount->exists() ) {
415
-                $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
413
+            $discount = new WPInv_Discount($invoice->get_discount_code());
414
+            if ($discount->exists()) {
415
+                $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
416 416
             } else {
417
-                $invoice->remove_discount( 'discount_code' );
417
+                $invoice->remove_discount('discount_code');
418 418
             }
419 419
 
420 420
             // Recalculate totals.
@@ -423,17 +423,17 @@  discard block
 block discarded – undo
423 423
         }
424 424
 
425 425
         // If we're creating a new user...
426
-        if ( ! empty( $_POST['wpinv_new_user'] ) && is_email( stripslashes( $_POST['wpinv_email'] ) ) ) {
426
+        if (!empty($_POST['wpinv_new_user']) && is_email(stripslashes($_POST['wpinv_email']))) {
427 427
 
428 428
             // Attempt to create the user.
429
-            $user = wpinv_create_user( sanitize_email( stripslashes( $_POST['wpinv_email'] ) ) );
429
+            $user = wpinv_create_user(sanitize_email(stripslashes($_POST['wpinv_email'])));
430 430
 
431 431
 
432 432
             // If successful, update the invoice author.
433
-            if ( is_numeric( $user ) ) {
434
-                $invoice->set_author( $user );
433
+            if (is_numeric($user)) {
434
+                $invoice->set_author($user);
435 435
             } else {
436
-                wpinv_error_log( $user->get_error_message(), __( 'Invoice add new user', 'invoicing' ), __FILE__, __LINE__ );
436
+                wpinv_error_log($user->get_error_message(), __('Invoice add new user', 'invoicing'), __FILE__, __LINE__);
437 437
             }
438 438
         }
439 439
 
@@ -447,16 +447,16 @@  discard block
 block discarded – undo
447 447
         $GLOBALS['wpinv_skip_invoice_notification'] = false;
448 448
 
449 449
         // (Maybe) send new user notification.
450
-        $should_send_notification = wpinv_get_option( 'disable_new_user_emails' );
451
-        if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ) ) ) {
452
-            wp_send_new_user_notifications( $user, 'user' );
450
+        $should_send_notification = wpinv_get_option('disable_new_user_emails');
451
+        if (!empty($user) && is_numeric($user) && apply_filters('getpaid_send_new_user_notification', empty($should_send_notification))) {
452
+            wp_send_new_user_notifications($user, 'user');
453 453
         }
454 454
 
455
-        if ( ! empty( $_POST['send_to_customer'] ) && ! $invoice->is_draft() ) {
456
-            getpaid()->get( 'invoice_emails' )->user_invoice( $invoice, true );
455
+        if (!empty($_POST['send_to_customer']) && !$invoice->is_draft()) {
456
+            getpaid()->get('invoice_emails')->user_invoice($invoice, true);
457 457
         }
458 458
 
459 459
         // Fires after an invoice is saved.
460
-		do_action( 'wpinv_invoice_metabox_saved', $invoice );
460
+		do_action('wpinv_invoice_metabox_saved', $invoice);
461 461
 	}
462 462
 }
Please login to merge, or discard this patch.
templates/payment-forms/cart.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -7,34 +7,34 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 // Cart table columns.
13 13
 $columns = array(
14
-    'name'     => __( 'Item', 'invoicing' ),
15
-    'price'    => __( 'Price', 'invoicing' ),
16
-    'quantity' => __( 'Qty', 'invoicing' ),
17
-    'subtotal' => __( 'Subtotal', 'invoicing' ),
14
+    'name'     => __('Item', 'invoicing'),
15
+    'price'    => __('Price', 'invoicing'),
16
+    'quantity' => __('Qty', 'invoicing'),
17
+    'subtotal' => __('Subtotal', 'invoicing'),
18 18
 );
19 19
 
20
-if ( ! empty( $form->invoice ) ) {
21
-    $columns = getpaid_invoice_item_columns( $form->invoice );
20
+if (!empty($form->invoice)) {
21
+    $columns = getpaid_invoice_item_columns($form->invoice);
22 22
 }
23 23
 
24
-if ( isset( $columns['tax_rate'] ) ) {
25
-    unset( $columns['tax_rate'] );
24
+if (isset($columns['tax_rate'])) {
25
+    unset($columns['tax_rate']);
26 26
 }
27 27
 
28
-$columns = apply_filters( 'getpaid_payment_form_cart_table_columns', $columns, $form );
28
+$columns = apply_filters('getpaid_payment_form_cart_table_columns', $columns, $form);
29 29
 
30 30
 ?>
31 31
     <div class="getpaid-payment-form-items-cart border form-group">
32 32
 
33 33
         <div class="getpaid-payment-form-items-cart-header font-weight-bold bg-light border-bottom py-2 px-3">
34 34
             <div class="form-row">
35
-                <?php foreach ( $columns as $key => $label ) : ?>
36
-                    <div class="<?php echo 'name' == $key ? 'col-6' : 'col' ?> <?php echo ( in_array( $key, array( 'subtotal', 'quantity', 'tax_rate' ) ) ) ? 'd-none d-sm-block' : '' ?> getpaid-form-cart-item-<?php echo sanitize_html_class( $key ); ?>">
37
-                        <span><?php echo esc_html( $label ); ?></span>
35
+                <?php foreach ($columns as $key => $label) : ?>
36
+                    <div class="<?php echo 'name' == $key ? 'col-6' : 'col' ?> <?php echo (in_array($key, array('subtotal', 'quantity', 'tax_rate'))) ? 'd-none d-sm-block' : '' ?> getpaid-form-cart-item-<?php echo sanitize_html_class($key); ?>">
37
+                        <span><?php echo esc_html($label); ?></span>
38 38
                     </div>
39 39
                 <?php endforeach; ?>
40 40
             </div>
@@ -43,16 +43,16 @@  discard block
 block discarded – undo
43 43
         <?php
44 44
 
45 45
             // Display the item totals.
46
-            foreach ( $form->get_items() as $item ) {
47
-                wpinv_get_template( 'payment-forms/cart-item.php', compact( 'form', 'item', 'columns' ) );
46
+            foreach ($form->get_items() as $item) {
47
+                wpinv_get_template('payment-forms/cart-item.php', compact('form', 'item', 'columns'));
48 48
             }
49 49
 
50 50
             // Display the cart totals.
51
-            wpinv_get_template( 'payment-forms/cart-totals.php', compact( 'form' ) );
51
+            wpinv_get_template('payment-forms/cart-totals.php', compact('form'));
52 52
 
53 53
         ?>
54 54
     </div>
55 55
 
56 56
 <?php 
57 57
 
58
-do_action( 'getpaid_after_payment_form_cart', $form );
58
+do_action('getpaid_after_payment_form_cart', $form);
Please login to merge, or discard this patch.
templates/payment-forms/elements/items.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -7,44 +7,44 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-if ( empty( $form->get_items() ) ) {
12
+if (empty($form->get_items())) {
13 13
     return;
14 14
 }
15 15
 
16
-if ( ! empty( $GLOBALS['getpaid_force_checkbox'] ) ) {
16
+if (!empty($GLOBALS['getpaid_force_checkbox'])) {
17 17
     $items_type = 'checkbox';
18 18
 }
19 19
 
20
-if ( empty( $items_type ) ) {
20
+if (empty($items_type)) {
21 21
     $items_type = 'total';
22 22
 }
23 23
 
24
-do_action( 'getpaid_before_payment_form_items', $form );
24
+do_action('getpaid_before_payment_form_items', $form);
25 25
 
26
-switch( $items_type ) {
26
+switch ($items_type) {
27 27
     case 'radio':
28
-        wpinv_get_template( 'payment-forms/variations/radio.php', compact( 'form', 'items_type' ) );
28
+        wpinv_get_template('payment-forms/variations/radio.php', compact('form', 'items_type'));
29 29
         break;
30 30
     case 'checkbox':
31
-        wpinv_get_template( 'payment-forms/variations/checkbox.php', compact( 'form', 'items_type' ) );
31
+        wpinv_get_template('payment-forms/variations/checkbox.php', compact('form', 'items_type'));
32 32
         break;
33 33
     case 'select':
34
-        wpinv_get_template( 'payment-forms/variations/select.php', compact( 'form', 'items_type' ) );
34
+        wpinv_get_template('payment-forms/variations/select.php', compact('form', 'items_type'));
35 35
         break;
36 36
 }
37 37
 
38
-do_action( 'getpaid_before_payment_form_cart', $form );
38
+do_action('getpaid_before_payment_form_cart', $form);
39 39
 
40 40
 // Display the cart totals.
41
-if ( ! empty( $hide_cart ) ) {
41
+if (!empty($hide_cart)) {
42 42
     echo '<div class="d-none">';
43 43
 }
44 44
 
45 45
 // Display the cart totals.
46
-wpinv_get_template( 'payment-forms/cart.php', compact( 'form', 'items_type' ) );
46
+wpinv_get_template('payment-forms/cart.php', compact('form', 'items_type'));
47 47
 
48
-if ( ! empty( $hide_cart ) ) {
48
+if (!empty($hide_cart)) {
49 49
     echo '</div>';
50 50
 }
Please login to merge, or discard this patch.
includes/class-getpaid-subscription-notification-emails.php 2 patches
Indentation   +257 added lines, -257 removed lines patch added patch discarded remove patch
@@ -13,300 +13,300 @@
 block discarded – undo
13 13
 class GetPaid_Subscription_Notification_Emails {
14 14
 
15 15
     /**
16
-	 * The array of subscription email actions.
17
-	 *
18
-	 * @param array
19
-	 */
20
-	public $subscription_actions;
16
+     * The array of subscription email actions.
17
+     *
18
+     * @param array
19
+     */
20
+    public $subscription_actions;
21 21
 
22 22
     /**
23
-	 * Class constructor
23
+     * Class constructor
24 24
      *
25
-	 */
26
-	public function __construct() {
27
-
28
-		$this->subscription_actions = apply_filters(
29
-			'getpaid_notification_email_subscription_triggers',
30
-			array(
31
-				'getpaid_subscription_trialling' => 'subscription_trial',
32
-				'getpaid_subscription_cancelled' => 'subscription_cancelled',
33
-				'getpaid_subscription_expired'   => 'subscription_expired',
34
-				'getpaid_subscription_completed' => 'subscription_complete',
35
-				'getpaid_daily_maintenance'      => 'renewal_reminder',
36
-			)
37
-		);
38
-
39
-		$this->init_hooks();
25
+     */
26
+    public function __construct() {
27
+
28
+        $this->subscription_actions = apply_filters(
29
+            'getpaid_notification_email_subscription_triggers',
30
+            array(
31
+                'getpaid_subscription_trialling' => 'subscription_trial',
32
+                'getpaid_subscription_cancelled' => 'subscription_cancelled',
33
+                'getpaid_subscription_expired'   => 'subscription_expired',
34
+                'getpaid_subscription_completed' => 'subscription_complete',
35
+                'getpaid_daily_maintenance'      => 'renewal_reminder',
36
+            )
37
+        );
38
+
39
+        $this->init_hooks();
40 40
 
41 41
     }
42 42
 
43 43
     /**
44
-	 * Registers email hooks.
45
-	 */
46
-	public function init_hooks() {
47
-
48
-		add_filter( 'getpaid_get_email_merge_tags', array( $this, 'subscription_merge_tags' ), 10, 2 );
49
-		foreach ( $this->subscription_actions as $hook => $email_type ) {
50
-
51
-			$email = new GetPaid_Notification_Email( $email_type );
52
-
53
-			if ( ! $email->is_active() ) {
54
-				continue;
55
-			}
56
-
57
-			if ( method_exists( $this, $email_type ) ) {
58
-				add_action( $hook, array( $this, $email_type ), 100, 2 );
59
-				continue;
60
-			}
61
-
62
-			do_action( 'getpaid_subscription_notification_email_register_hook', $email_type, $hook );
63
-
64
-		}
65
-
66
-	}
67
-
68
-	/**
69
-	 * Filters subscription merge tags.
70
-	 *
71
-	 * @param array $merge_tags
72
-	 * @param mixed|WPInv_Invoice|WPInv_Subscription $object
73
-	 */
74
-	public function subscription_merge_tags( $merge_tags, $object ) {
75
-
76
-		if ( is_a( $object, 'WPInv_Subscription' ) ) {
77
-			$merge_tags = array_merge(
78
-				$merge_tags,
79
-				$this->get_subscription_merge_tags( $object )
80
-			);
81
-		}
82
-
83
-		return $merge_tags;
84
-
85
-	}
86
-
87
-	/**
88
-	 * Generates subscription merge tags.
89
-	 *
90
-	 * @param WPInv_Subscription $subscription
91
-	 * @return array
92
-	 */
93
-	public function get_subscription_merge_tags( $subscription ) {
94
-
95
-		// Abort if it does not exist.
96
-		if ( ! $subscription->get_id() ) {
97
-			return array();
98
-		}
99
-
100
-		$invoice    = $subscription->get_parent_invoice();
101
-		return array(
102
-			'{subscription_renewal_date}'     => getpaid_format_date_value( $subscription->get_next_renewal_date(), __( 'Never', 'invoicing' ) ),
103
-			'{subscription_created}'          => getpaid_format_date_value( $subscription->get_date_created() ),
104
-			'{subscription_status}'           => sanitize_text_field( $subscription->get_status_label() ),
105
-			'{subscription_profile_id}'       => sanitize_text_field( $subscription->get_profile_id() ),
106
-			'{subscription_id}'               => absint( $subscription->get_id() ),
107
-			'{subscription_recurring_amount}' => sanitize_text_field( wpinv_price( $subscription->get_recurring_amount(), $invoice->get_currency() ) ),
108
-			'{subscription_initial_amount}'   => sanitize_text_field( wpinv_price( $subscription->get_initial_amount(), $invoice->get_currency() ) ),
109
-			'{subscription_recurring_period}' => getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ),
110
-			'{subscription_bill_times}'       => $subscription->get_bill_times(),
111
-			'{subscription_url}'              => esc_url( $subscription->get_view_url() ),
112
-		);
113
-
114
-	}
115
-
116
-	/**
117
-	 * Checks if we should send a notification for a subscription.
118
-	 *
119
-	 * @param WPInv_Invoice $invoice
120
-	 * @return bool
121
-	 */
122
-	public function should_send_notification( $invoice ) {
123
-		return 0 != $invoice->get_id();
124
-	}
125
-
126
-	/**
127
-	 * Returns notification recipients.
128
-	 *
129
-	 * @param WPInv_Invoice $invoice
130
-	 * @return array
131
-	 */
132
-	public function get_recipients( $invoice ) {
133
-		$recipients = array( $invoice->get_email() );
134
-
135
-		$cc = $invoice->get_email_cc();
136
-
137
-		if ( ! empty( $cc ) ) {
138
-			$cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) );
139
-			$recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) );
140
-		}
141
-
142
-		return $recipients;
143
-	}
144
-
145
-	/**
146
-	 * Helper function to send an email.
147
-	 *
148
-	 * @param WPInv_Subscription $subscription
149
-	 * @param GetPaid_Notification_Email $email
150
-	 * @param string $type
151
-	 * @param array $extra_args Extra template args.
152
-	 */
153
-	public function send_email( $subscription, $email, $type, $extra_args = array() ) {
154
-
155
-		// Abort in case the parent invoice does not exist.
156
-		$invoice = $subscription->get_parent_invoice();
157
-		if ( ! $this->should_send_notification( $invoice ) ) {
158
-			return;
159
-		}
160
-
161
-		if ( apply_filters( 'getpaid_skip_subscription_email', false, $type, $subscription ) ) {
162
-			return;
163
-		}
164
-
165
-		do_action( 'getpaid_before_send_subscription_notification', $type, $subscription, $email );
166
-
167
-		$recipients  = $this->get_recipients( $invoice );
168
-		$mailer      = new GetPaid_Notification_Email_Sender();
169
-		$merge_tags  = $email->get_merge_tags();
170
-		$content     = $email->get_content( $merge_tags, $extra_args );
171
-		$subject     = $email->add_merge_tags( $email->get_subject(), $merge_tags );
172
-		$attachments = $email->get_attachments();
173
-
174
-		$result = $mailer->send(
175
-			apply_filters( 'getpaid_subscription_email_recipients', wpinv_parse_list( $recipients ), $email ),
176
-			$subject,
177
-			$content,
178
-			$attachments
179
-		);
180
-
181
-		// Maybe send a copy to the admin.
182
-		if ( $email->include_admin_bcc() ) {
183
-			$mailer->send(
184
-				wpinv_get_admin_email(),
185
-				$subject . __( ' - ADMIN BCC COPY', 'invoicing' ),
186
-				$content,
187
-				$attachments
188
-			);
189
-		}
190
-
191
-		if ( $result ) {
192
-			$invoice->add_system_note(
193
-				sprintf(
194
-					__( 'Successfully sent %s notification email to %s.', 'invoicing' ),
195
-					sanitize_key( $type ),
196
-					$email->is_admin_email() ? __( 'admin' ) : __( 'the customer' )
197
-				)
198
-			);
199
-		} else {
200
-			$invoice->add_system_note(
201
-				sprintf(
202
-					__( 'Failed sending %s notification email to %s.', 'invoicing' ),
203
-					sanitize_key( $type ),
204
-					$email->is_admin_email() ? __( 'admin' ) : __( 'the customer' )
205
-				)
206
-			);	
207
-		}
208
-
209
-		do_action( 'getpaid_after_send_subscription_notification', $type, $subscription, $email );
210
-
211
-	}
44
+     * Registers email hooks.
45
+     */
46
+    public function init_hooks() {
47
+
48
+        add_filter( 'getpaid_get_email_merge_tags', array( $this, 'subscription_merge_tags' ), 10, 2 );
49
+        foreach ( $this->subscription_actions as $hook => $email_type ) {
50
+
51
+            $email = new GetPaid_Notification_Email( $email_type );
52
+
53
+            if ( ! $email->is_active() ) {
54
+                continue;
55
+            }
56
+
57
+            if ( method_exists( $this, $email_type ) ) {
58
+                add_action( $hook, array( $this, $email_type ), 100, 2 );
59
+                continue;
60
+            }
61
+
62
+            do_action( 'getpaid_subscription_notification_email_register_hook', $email_type, $hook );
63
+
64
+        }
65
+
66
+    }
212 67
 
213 68
     /**
214
-	 * Sends a new trial notification.
215
-	 *
216
-	 * @param WPInv_Subscription $subscription
217
-	 */
218
-	public function subscription_trial( $subscription ) {
69
+     * Filters subscription merge tags.
70
+     *
71
+     * @param array $merge_tags
72
+     * @param mixed|WPInv_Invoice|WPInv_Subscription $object
73
+     */
74
+    public function subscription_merge_tags( $merge_tags, $object ) {
219 75
 
220
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
221
-		$this->send_email( $subscription, $email, __FUNCTION__ );
76
+        if ( is_a( $object, 'WPInv_Subscription' ) ) {
77
+            $merge_tags = array_merge(
78
+                $merge_tags,
79
+                $this->get_subscription_merge_tags( $object )
80
+            );
81
+        }
222 82
 
223
-	}
83
+        return $merge_tags;
224 84
 
225
-	/**
226
-	 * Sends a cancelled subscription notification.
227
-	 *
228
-	 * @param WPInv_Subscription $subscription
229
-	 */
230
-	public function subscription_cancelled( $subscription ) {
85
+    }
231 86
 
232
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
233
-		$this->send_email( $subscription, $email, __FUNCTION__ );
87
+    /**
88
+     * Generates subscription merge tags.
89
+     *
90
+     * @param WPInv_Subscription $subscription
91
+     * @return array
92
+     */
93
+    public function get_subscription_merge_tags( $subscription ) {
94
+
95
+        // Abort if it does not exist.
96
+        if ( ! $subscription->get_id() ) {
97
+            return array();
98
+        }
99
+
100
+        $invoice    = $subscription->get_parent_invoice();
101
+        return array(
102
+            '{subscription_renewal_date}'     => getpaid_format_date_value( $subscription->get_next_renewal_date(), __( 'Never', 'invoicing' ) ),
103
+            '{subscription_created}'          => getpaid_format_date_value( $subscription->get_date_created() ),
104
+            '{subscription_status}'           => sanitize_text_field( $subscription->get_status_label() ),
105
+            '{subscription_profile_id}'       => sanitize_text_field( $subscription->get_profile_id() ),
106
+            '{subscription_id}'               => absint( $subscription->get_id() ),
107
+            '{subscription_recurring_amount}' => sanitize_text_field( wpinv_price( $subscription->get_recurring_amount(), $invoice->get_currency() ) ),
108
+            '{subscription_initial_amount}'   => sanitize_text_field( wpinv_price( $subscription->get_initial_amount(), $invoice->get_currency() ) ),
109
+            '{subscription_recurring_period}' => getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ),
110
+            '{subscription_bill_times}'       => $subscription->get_bill_times(),
111
+            '{subscription_url}'              => esc_url( $subscription->get_view_url() ),
112
+        );
234 113
 
235
-	}
114
+    }
236 115
 
237
-	/**
238
-	 * Sends a subscription expired notification.
239
-	 *
240
-	 * @param WPInv_Subscription $subscription
241
-	 */
242
-	public function subscription_expired( $subscription ) {
116
+    /**
117
+     * Checks if we should send a notification for a subscription.
118
+     *
119
+     * @param WPInv_Invoice $invoice
120
+     * @return bool
121
+     */
122
+    public function should_send_notification( $invoice ) {
123
+        return 0 != $invoice->get_id();
124
+    }
243 125
 
244
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
245
-		$this->send_email( $subscription, $email, __FUNCTION__ );
126
+    /**
127
+     * Returns notification recipients.
128
+     *
129
+     * @param WPInv_Invoice $invoice
130
+     * @return array
131
+     */
132
+    public function get_recipients( $invoice ) {
133
+        $recipients = array( $invoice->get_email() );
246 134
 
247
-	}
135
+        $cc = $invoice->get_email_cc();
248 136
 
249
-	/**
250
-	 * Sends a completed subscription notification.
251
-	 *
252
-	 * @param WPInv_Subscription $subscription
253
-	 */
254
-	public function subscription_complete( $subscription ) {
137
+        if ( ! empty( $cc ) ) {
138
+            $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) );
139
+            $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) );
140
+        }
255 141
 
256
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
257
-		$this->send_email( $subscription, $email, __FUNCTION__ );
142
+        return $recipients;
143
+    }
258 144
 
259
-	}
145
+    /**
146
+     * Helper function to send an email.
147
+     *
148
+     * @param WPInv_Subscription $subscription
149
+     * @param GetPaid_Notification_Email $email
150
+     * @param string $type
151
+     * @param array $extra_args Extra template args.
152
+     */
153
+    public function send_email( $subscription, $email, $type, $extra_args = array() ) {
154
+
155
+        // Abort in case the parent invoice does not exist.
156
+        $invoice = $subscription->get_parent_invoice();
157
+        if ( ! $this->should_send_notification( $invoice ) ) {
158
+            return;
159
+        }
160
+
161
+        if ( apply_filters( 'getpaid_skip_subscription_email', false, $type, $subscription ) ) {
162
+            return;
163
+        }
164
+
165
+        do_action( 'getpaid_before_send_subscription_notification', $type, $subscription, $email );
166
+
167
+        $recipients  = $this->get_recipients( $invoice );
168
+        $mailer      = new GetPaid_Notification_Email_Sender();
169
+        $merge_tags  = $email->get_merge_tags();
170
+        $content     = $email->get_content( $merge_tags, $extra_args );
171
+        $subject     = $email->add_merge_tags( $email->get_subject(), $merge_tags );
172
+        $attachments = $email->get_attachments();
173
+
174
+        $result = $mailer->send(
175
+            apply_filters( 'getpaid_subscription_email_recipients', wpinv_parse_list( $recipients ), $email ),
176
+            $subject,
177
+            $content,
178
+            $attachments
179
+        );
180
+
181
+        // Maybe send a copy to the admin.
182
+        if ( $email->include_admin_bcc() ) {
183
+            $mailer->send(
184
+                wpinv_get_admin_email(),
185
+                $subject . __( ' - ADMIN BCC COPY', 'invoicing' ),
186
+                $content,
187
+                $attachments
188
+            );
189
+        }
190
+
191
+        if ( $result ) {
192
+            $invoice->add_system_note(
193
+                sprintf(
194
+                    __( 'Successfully sent %s notification email to %s.', 'invoicing' ),
195
+                    sanitize_key( $type ),
196
+                    $email->is_admin_email() ? __( 'admin' ) : __( 'the customer' )
197
+                )
198
+            );
199
+        } else {
200
+            $invoice->add_system_note(
201
+                sprintf(
202
+                    __( 'Failed sending %s notification email to %s.', 'invoicing' ),
203
+                    sanitize_key( $type ),
204
+                    $email->is_admin_email() ? __( 'admin' ) : __( 'the customer' )
205
+                )
206
+            );	
207
+        }
208
+
209
+        do_action( 'getpaid_after_send_subscription_notification', $type, $subscription, $email );
260 210
 
261
-	/**
262
-	 * Sends a subscription renewal reminder notification.
263
-	 *
264
-	 */
265
-	public function renewal_reminder() {
211
+    }
266 212
 
267
-		$email = new GetPaid_Notification_Email( __FUNCTION__ );
213
+    /**
214
+     * Sends a new trial notification.
215
+     *
216
+     * @param WPInv_Subscription $subscription
217
+     */
218
+    public function subscription_trial( $subscription ) {
268 219
 
269
-		// Fetch reminder days.
270
-		$reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) );
220
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
221
+        $this->send_email( $subscription, $email, __FUNCTION__ );
271 222
 
272
-		// Abort if non is set.
273
-		if ( empty( $reminder_days ) ) {
274
-			return;
275
-		}
223
+    }
276 224
 
277
-		// Fetch matching subscriptions.
225
+    /**
226
+     * Sends a cancelled subscription notification.
227
+     *
228
+     * @param WPInv_Subscription $subscription
229
+     */
230
+    public function subscription_cancelled( $subscription ) {
231
+
232
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
233
+        $this->send_email( $subscription, $email, __FUNCTION__ );
234
+
235
+    }
236
+
237
+    /**
238
+     * Sends a subscription expired notification.
239
+     *
240
+     * @param WPInv_Subscription $subscription
241
+     */
242
+    public function subscription_expired( $subscription ) {
243
+
244
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
245
+        $this->send_email( $subscription, $email, __FUNCTION__ );
246
+
247
+    }
248
+
249
+    /**
250
+     * Sends a completed subscription notification.
251
+     *
252
+     * @param WPInv_Subscription $subscription
253
+     */
254
+    public function subscription_complete( $subscription ) {
255
+
256
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
257
+        $this->send_email( $subscription, $email, __FUNCTION__ );
258
+
259
+    }
260
+
261
+    /**
262
+     * Sends a subscription renewal reminder notification.
263
+     *
264
+     */
265
+    public function renewal_reminder() {
266
+
267
+        $email = new GetPaid_Notification_Email( __FUNCTION__ );
268
+
269
+        // Fetch reminder days.
270
+        $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) );
271
+
272
+        // Abort if non is set.
273
+        if ( empty( $reminder_days ) ) {
274
+            return;
275
+        }
276
+
277
+        // Fetch matching subscriptions.
278 278
         $args  = array(
279 279
             'number'             => -1,
280
-			'count_total'        => false,
281
-			'status'             => 'trialling active',
280
+            'count_total'        => false,
281
+            'status'             => 'trialling active',
282 282
             'date_expires_query' => array(
283
-				'relation'  => 'OR'
283
+                'relation'  => 'OR'
284 284
             ),
285
-		);
285
+        );
286 286
 
287
-		foreach ( $reminder_days as $days ) {
288
-			$date = date_parse( date( 'Y-m-d', strtotime( "+$days days", current_time( 'timestamp' ) ) ) );
287
+        foreach ( $reminder_days as $days ) {
288
+            $date = date_parse( date( 'Y-m-d', strtotime( "+$days days", current_time( 'timestamp' ) ) ) );
289 289
 
290
-			$args['date_expires_query'][] = array(
291
-				'year'  => $date['year'],
292
-				'month' => $date['month'],
293
-				'day'   => $date['day'],
294
-			);
290
+            $args['date_expires_query'][] = array(
291
+                'year'  => $date['year'],
292
+                'month' => $date['month'],
293
+                'day'   => $date['day'],
294
+            );
295 295
 
296
-		}
296
+        }
297 297
 
298
-		$subscriptions = new GetPaid_Subscriptions_Query( $args );
298
+        $subscriptions = new GetPaid_Subscriptions_Query( $args );
299 299
 
300 300
         foreach ( $subscriptions as $subscription ) {
301 301
 
302
-			// Skip packages.
303
-			if ( apply_filters( 'getpaid_send_subscription_renewal_reminder_email', true ) ) {
304
-				$email->object = $subscription;
305
-            	$this->send_email( $subscription, $email, __FUNCTION__ );
306
-			}
302
+            // Skip packages.
303
+            if ( apply_filters( 'getpaid_send_subscription_renewal_reminder_email', true ) ) {
304
+                $email->object = $subscription;
305
+                $this->send_email( $subscription, $email, __FUNCTION__ );
306
+            }
307 307
 
308
-		}
308
+        }
309 309
 
310
-	}
310
+    }
311 311
 
312 312
 }
Please login to merge, or discard this patch.
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * This class handles subscription notificaiton emails.
@@ -45,21 +45,21 @@  discard block
 block discarded – undo
45 45
 	 */
46 46
 	public function init_hooks() {
47 47
 
48
-		add_filter( 'getpaid_get_email_merge_tags', array( $this, 'subscription_merge_tags' ), 10, 2 );
49
-		foreach ( $this->subscription_actions as $hook => $email_type ) {
48
+		add_filter('getpaid_get_email_merge_tags', array($this, 'subscription_merge_tags'), 10, 2);
49
+		foreach ($this->subscription_actions as $hook => $email_type) {
50 50
 
51
-			$email = new GetPaid_Notification_Email( $email_type );
51
+			$email = new GetPaid_Notification_Email($email_type);
52 52
 
53
-			if ( ! $email->is_active() ) {
53
+			if (!$email->is_active()) {
54 54
 				continue;
55 55
 			}
56 56
 
57
-			if ( method_exists( $this, $email_type ) ) {
58
-				add_action( $hook, array( $this, $email_type ), 100, 2 );
57
+			if (method_exists($this, $email_type)) {
58
+				add_action($hook, array($this, $email_type), 100, 2);
59 59
 				continue;
60 60
 			}
61 61
 
62
-			do_action( 'getpaid_subscription_notification_email_register_hook', $email_type, $hook );
62
+			do_action('getpaid_subscription_notification_email_register_hook', $email_type, $hook);
63 63
 
64 64
 		}
65 65
 
@@ -71,12 +71,12 @@  discard block
 block discarded – undo
71 71
 	 * @param array $merge_tags
72 72
 	 * @param mixed|WPInv_Invoice|WPInv_Subscription $object
73 73
 	 */
74
-	public function subscription_merge_tags( $merge_tags, $object ) {
74
+	public function subscription_merge_tags($merge_tags, $object) {
75 75
 
76
-		if ( is_a( $object, 'WPInv_Subscription' ) ) {
76
+		if (is_a($object, 'WPInv_Subscription')) {
77 77
 			$merge_tags = array_merge(
78 78
 				$merge_tags,
79
-				$this->get_subscription_merge_tags( $object )
79
+				$this->get_subscription_merge_tags($object)
80 80
 			);
81 81
 		}
82 82
 
@@ -90,25 +90,25 @@  discard block
 block discarded – undo
90 90
 	 * @param WPInv_Subscription $subscription
91 91
 	 * @return array
92 92
 	 */
93
-	public function get_subscription_merge_tags( $subscription ) {
93
+	public function get_subscription_merge_tags($subscription) {
94 94
 
95 95
 		// Abort if it does not exist.
96
-		if ( ! $subscription->get_id() ) {
96
+		if (!$subscription->get_id()) {
97 97
 			return array();
98 98
 		}
99 99
 
100
-		$invoice    = $subscription->get_parent_invoice();
100
+		$invoice = $subscription->get_parent_invoice();
101 101
 		return array(
102
-			'{subscription_renewal_date}'     => getpaid_format_date_value( $subscription->get_next_renewal_date(), __( 'Never', 'invoicing' ) ),
103
-			'{subscription_created}'          => getpaid_format_date_value( $subscription->get_date_created() ),
104
-			'{subscription_status}'           => sanitize_text_field( $subscription->get_status_label() ),
105
-			'{subscription_profile_id}'       => sanitize_text_field( $subscription->get_profile_id() ),
106
-			'{subscription_id}'               => absint( $subscription->get_id() ),
107
-			'{subscription_recurring_amount}' => sanitize_text_field( wpinv_price( $subscription->get_recurring_amount(), $invoice->get_currency() ) ),
108
-			'{subscription_initial_amount}'   => sanitize_text_field( wpinv_price( $subscription->get_initial_amount(), $invoice->get_currency() ) ),
109
-			'{subscription_recurring_period}' => getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ),
102
+			'{subscription_renewal_date}'     => getpaid_format_date_value($subscription->get_next_renewal_date(), __('Never', 'invoicing')),
103
+			'{subscription_created}'          => getpaid_format_date_value($subscription->get_date_created()),
104
+			'{subscription_status}'           => sanitize_text_field($subscription->get_status_label()),
105
+			'{subscription_profile_id}'       => sanitize_text_field($subscription->get_profile_id()),
106
+			'{subscription_id}'               => absint($subscription->get_id()),
107
+			'{subscription_recurring_amount}' => sanitize_text_field(wpinv_price($subscription->get_recurring_amount(), $invoice->get_currency())),
108
+			'{subscription_initial_amount}'   => sanitize_text_field(wpinv_price($subscription->get_initial_amount(), $invoice->get_currency())),
109
+			'{subscription_recurring_period}' => getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency(), ''),
110 110
 			'{subscription_bill_times}'       => $subscription->get_bill_times(),
111
-			'{subscription_url}'              => esc_url( $subscription->get_view_url() ),
111
+			'{subscription_url}'              => esc_url($subscription->get_view_url()),
112 112
 		);
113 113
 
114 114
 	}
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	 * @param WPInv_Invoice $invoice
120 120
 	 * @return bool
121 121
 	 */
122
-	public function should_send_notification( $invoice ) {
122
+	public function should_send_notification($invoice) {
123 123
 		return 0 != $invoice->get_id();
124 124
 	}
125 125
 
@@ -129,14 +129,14 @@  discard block
 block discarded – undo
129 129
 	 * @param WPInv_Invoice $invoice
130 130
 	 * @return array
131 131
 	 */
132
-	public function get_recipients( $invoice ) {
133
-		$recipients = array( $invoice->get_email() );
132
+	public function get_recipients($invoice) {
133
+		$recipients = array($invoice->get_email());
134 134
 
135 135
 		$cc = $invoice->get_email_cc();
136 136
 
137
-		if ( ! empty( $cc ) ) {
138
-			$cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) );
139
-			$recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) );
137
+		if (!empty($cc)) {
138
+			$cc = array_map('sanitize_email', wpinv_parse_list($cc));
139
+			$recipients = array_filter(array_unique(array_merge($recipients, $cc)));
140 140
 		}
141 141
 
142 142
 		return $recipients;
@@ -150,63 +150,63 @@  discard block
 block discarded – undo
150 150
 	 * @param string $type
151 151
 	 * @param array $extra_args Extra template args.
152 152
 	 */
153
-	public function send_email( $subscription, $email, $type, $extra_args = array() ) {
153
+	public function send_email($subscription, $email, $type, $extra_args = array()) {
154 154
 
155 155
 		// Abort in case the parent invoice does not exist.
156 156
 		$invoice = $subscription->get_parent_invoice();
157
-		if ( ! $this->should_send_notification( $invoice ) ) {
157
+		if (!$this->should_send_notification($invoice)) {
158 158
 			return;
159 159
 		}
160 160
 
161
-		if ( apply_filters( 'getpaid_skip_subscription_email', false, $type, $subscription ) ) {
161
+		if (apply_filters('getpaid_skip_subscription_email', false, $type, $subscription)) {
162 162
 			return;
163 163
 		}
164 164
 
165
-		do_action( 'getpaid_before_send_subscription_notification', $type, $subscription, $email );
165
+		do_action('getpaid_before_send_subscription_notification', $type, $subscription, $email);
166 166
 
167
-		$recipients  = $this->get_recipients( $invoice );
167
+		$recipients  = $this->get_recipients($invoice);
168 168
 		$mailer      = new GetPaid_Notification_Email_Sender();
169 169
 		$merge_tags  = $email->get_merge_tags();
170
-		$content     = $email->get_content( $merge_tags, $extra_args );
171
-		$subject     = $email->add_merge_tags( $email->get_subject(), $merge_tags );
170
+		$content     = $email->get_content($merge_tags, $extra_args);
171
+		$subject     = $email->add_merge_tags($email->get_subject(), $merge_tags);
172 172
 		$attachments = $email->get_attachments();
173 173
 
174 174
 		$result = $mailer->send(
175
-			apply_filters( 'getpaid_subscription_email_recipients', wpinv_parse_list( $recipients ), $email ),
175
+			apply_filters('getpaid_subscription_email_recipients', wpinv_parse_list($recipients), $email),
176 176
 			$subject,
177 177
 			$content,
178 178
 			$attachments
179 179
 		);
180 180
 
181 181
 		// Maybe send a copy to the admin.
182
-		if ( $email->include_admin_bcc() ) {
182
+		if ($email->include_admin_bcc()) {
183 183
 			$mailer->send(
184 184
 				wpinv_get_admin_email(),
185
-				$subject . __( ' - ADMIN BCC COPY', 'invoicing' ),
185
+				$subject . __(' - ADMIN BCC COPY', 'invoicing'),
186 186
 				$content,
187 187
 				$attachments
188 188
 			);
189 189
 		}
190 190
 
191
-		if ( $result ) {
191
+		if ($result) {
192 192
 			$invoice->add_system_note(
193 193
 				sprintf(
194
-					__( 'Successfully sent %s notification email to %s.', 'invoicing' ),
195
-					sanitize_key( $type ),
196
-					$email->is_admin_email() ? __( 'admin' ) : __( 'the customer' )
194
+					__('Successfully sent %s notification email to %s.', 'invoicing'),
195
+					sanitize_key($type),
196
+					$email->is_admin_email() ? __('admin') : __('the customer')
197 197
 				)
198 198
 			);
199 199
 		} else {
200 200
 			$invoice->add_system_note(
201 201
 				sprintf(
202
-					__( 'Failed sending %s notification email to %s.', 'invoicing' ),
203
-					sanitize_key( $type ),
204
-					$email->is_admin_email() ? __( 'admin' ) : __( 'the customer' )
202
+					__('Failed sending %s notification email to %s.', 'invoicing'),
203
+					sanitize_key($type),
204
+					$email->is_admin_email() ? __('admin') : __('the customer')
205 205
 				)
206 206
 			);	
207 207
 		}
208 208
 
209
-		do_action( 'getpaid_after_send_subscription_notification', $type, $subscription, $email );
209
+		do_action('getpaid_after_send_subscription_notification', $type, $subscription, $email);
210 210
 
211 211
 	}
212 212
 
@@ -215,10 +215,10 @@  discard block
 block discarded – undo
215 215
 	 *
216 216
 	 * @param WPInv_Subscription $subscription
217 217
 	 */
218
-	public function subscription_trial( $subscription ) {
218
+	public function subscription_trial($subscription) {
219 219
 
220
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
221
-		$this->send_email( $subscription, $email, __FUNCTION__ );
220
+		$email = new GetPaid_Notification_Email(__FUNCTION__, $subscription);
221
+		$this->send_email($subscription, $email, __FUNCTION__);
222 222
 
223 223
 	}
224 224
 
@@ -227,10 +227,10 @@  discard block
 block discarded – undo
227 227
 	 *
228 228
 	 * @param WPInv_Subscription $subscription
229 229
 	 */
230
-	public function subscription_cancelled( $subscription ) {
230
+	public function subscription_cancelled($subscription) {
231 231
 
232
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
233
-		$this->send_email( $subscription, $email, __FUNCTION__ );
232
+		$email = new GetPaid_Notification_Email(__FUNCTION__, $subscription);
233
+		$this->send_email($subscription, $email, __FUNCTION__);
234 234
 
235 235
 	}
236 236
 
@@ -239,10 +239,10 @@  discard block
 block discarded – undo
239 239
 	 *
240 240
 	 * @param WPInv_Subscription $subscription
241 241
 	 */
242
-	public function subscription_expired( $subscription ) {
242
+	public function subscription_expired($subscription) {
243 243
 
244
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
245
-		$this->send_email( $subscription, $email, __FUNCTION__ );
244
+		$email = new GetPaid_Notification_Email(__FUNCTION__, $subscription);
245
+		$this->send_email($subscription, $email, __FUNCTION__);
246 246
 
247 247
 	}
248 248
 
@@ -251,10 +251,10 @@  discard block
 block discarded – undo
251 251
 	 *
252 252
 	 * @param WPInv_Subscription $subscription
253 253
 	 */
254
-	public function subscription_complete( $subscription ) {
254
+	public function subscription_complete($subscription) {
255 255
 
256
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
257
-		$this->send_email( $subscription, $email, __FUNCTION__ );
256
+		$email = new GetPaid_Notification_Email(__FUNCTION__, $subscription);
257
+		$this->send_email($subscription, $email, __FUNCTION__);
258 258
 
259 259
 	}
260 260
 
@@ -264,18 +264,18 @@  discard block
 block discarded – undo
264 264
 	 */
265 265
 	public function renewal_reminder() {
266 266
 
267
-		$email = new GetPaid_Notification_Email( __FUNCTION__ );
267
+		$email = new GetPaid_Notification_Email(__FUNCTION__);
268 268
 
269 269
 		// Fetch reminder days.
270
-		$reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) );
270
+		$reminder_days = array_unique(wp_parse_id_list($email->get_option('days')));
271 271
 
272 272
 		// Abort if non is set.
273
-		if ( empty( $reminder_days ) ) {
273
+		if (empty($reminder_days)) {
274 274
 			return;
275 275
 		}
276 276
 
277 277
 		// Fetch matching subscriptions.
278
-        $args  = array(
278
+        $args = array(
279 279
             'number'             => -1,
280 280
 			'count_total'        => false,
281 281
 			'status'             => 'trialling active',
@@ -284,8 +284,8 @@  discard block
 block discarded – undo
284 284
             ),
285 285
 		);
286 286
 
287
-		foreach ( $reminder_days as $days ) {
288
-			$date = date_parse( date( 'Y-m-d', strtotime( "+$days days", current_time( 'timestamp' ) ) ) );
287
+		foreach ($reminder_days as $days) {
288
+			$date = date_parse(date('Y-m-d', strtotime("+$days days", current_time('timestamp'))));
289 289
 
290 290
 			$args['date_expires_query'][] = array(
291 291
 				'year'  => $date['year'],
@@ -295,14 +295,14 @@  discard block
 block discarded – undo
295 295
 
296 296
 		}
297 297
 
298
-		$subscriptions = new GetPaid_Subscriptions_Query( $args );
298
+		$subscriptions = new GetPaid_Subscriptions_Query($args);
299 299
 
300
-        foreach ( $subscriptions as $subscription ) {
300
+        foreach ($subscriptions as $subscription) {
301 301
 
302 302
 			// Skip packages.
303
-			if ( apply_filters( 'getpaid_send_subscription_renewal_reminder_email', true ) ) {
303
+			if (apply_filters('getpaid_send_subscription_renewal_reminder_email', true)) {
304 304
 				$email->object = $subscription;
305
-            	$this->send_email( $subscription, $email, __FUNCTION__ );
305
+            	$this->send_email($subscription, $email, __FUNCTION__);
306 306
 			}
307 307
 
308 308
 		}
Please login to merge, or discard this patch.
includes/data/email-settings.php 1 patch
Spacing   +228 added lines, -228 removed lines patch added patch discarded remove patch
@@ -8,24 +8,24 @@  discard block
 block discarded – undo
8 8
  * @version 1.0.19
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 // Prepare the due date reminder options.
14 14
 $overdue_days_options       = array();
15
-$overdue_days_options['0']  = __( 'On the Due Date', 'invoicing' );
16
-$overdue_days_options['1']  = __( '1 day after Due Date', 'invoicing' );
15
+$overdue_days_options['0']  = __('On the Due Date', 'invoicing');
16
+$overdue_days_options['1']  = __('1 day after Due Date', 'invoicing');
17 17
 
18
-for ( $i = 2; $i <= 10; $i++ ) {
19
-    $overdue_days_options["$i"] = wp_sprintf( __( '%d days after Due Date', 'invoicing' ), $i );
18
+for ($i = 2; $i <= 10; $i++) {
19
+    $overdue_days_options["$i"] = wp_sprintf(__('%d days after Due Date', 'invoicing'), $i);
20 20
 }
21 21
 
22 22
 // Prepare up coming renewal reminder options.
23 23
 $renewal_days_options       = array();
24
-$renewal_days_options['0']  = __( 'On the renewal date', 'invoicing' );
25
-$renewal_days_options['1']  = __( '1 day before the renewal date', 'invoicing' );
24
+$renewal_days_options['0']  = __('On the renewal date', 'invoicing');
25
+$renewal_days_options['1']  = __('1 day before the renewal date', 'invoicing');
26 26
 
27
-for ( $i = 2; $i <= 10; $i++ ) {
28
-    $renewal_days_options["$i"]   = wp_sprintf( __( '%d days before the renewal date', 'invoicing' ), $i );
27
+for ($i = 2; $i <= 10; $i++) {
28
+    $renewal_days_options["$i"] = wp_sprintf(__('%d days before the renewal date', 'invoicing'), $i);
29 29
 }
30 30
 
31 31
 // Default, built-in gateways
@@ -34,45 +34,45 @@  discard block
 block discarded – undo
34 34
 
35 35
         'email_new_invoice_header' => array(
36 36
             'id'       => 'email_new_invoice_header',
37
-            'name'     => '<h3>' . __( 'New Invoice', 'invoicing' ) . '</h3>',
38
-            'desc'     => __( 'These emails are sent to the site admin whenever there is a new invoice.', 'invoicing' ),
37
+            'name'     => '<h3>' . __('New Invoice', 'invoicing') . '</h3>',
38
+            'desc'     => __('These emails are sent to the site admin whenever there is a new invoice.', 'invoicing'),
39 39
             'type'     => 'header',
40 40
         ),
41 41
 
42 42
         'email_new_invoice_active' => array(
43 43
             'id'       => 'email_new_invoice_active',
44
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
45
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
44
+            'name'     => __('Enable/Disable', 'invoicing'),
45
+            'desc'     => __('Enable this email notification', 'invoicing'),
46 46
             'type'     => 'checkbox',
47 47
             'std'      => 1
48 48
         ),
49 49
 
50 50
         'email_new_invoice_subject' => array(
51 51
             'id'       => 'email_new_invoice_subject',
52
-            'name'     => __( 'Subject', 'invoicing' ),
53
-            'desc'     => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
52
+            'name'     => __('Subject', 'invoicing'),
53
+            'desc'     => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
54 54
             'help-tip' => true,
55 55
             'type'     => 'text',
56
-            'std'      => __( '[{site_title}] New invoice ({invoice_number}) for {invoice_total} {invoice_currency}', 'invoicing' ),
56
+            'std'      => __('[{site_title}] New invoice ({invoice_number}) for {invoice_total} {invoice_currency}', 'invoicing'),
57 57
             'size'     => 'large'
58 58
         ),
59 59
 
60 60
         'email_new_invoice_heading' => array(
61 61
             'id'       => 'email_new_invoice_heading',
62
-            'name'     => __( 'Email Heading', 'invoicing' ),
63
-            'desc'     => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
62
+            'name'     => __('Email Heading', 'invoicing'),
63
+            'desc'     => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
64 64
             'help-tip' => true,
65 65
             'type'     => 'text',
66
-            'std'      => __( 'New invoice', 'invoicing' ),
66
+            'std'      => __('New invoice', 'invoicing'),
67 67
             'size'     => 'large'
68 68
         ),
69 69
 
70 70
         'email_new_invoice_body' => array(
71 71
             'id'       => 'email_new_invoice_body',
72
-            'name'     => __( 'Email Content', 'invoicing' ),
72
+            'name'     => __('Email Content', 'invoicing'),
73 73
             'desc'     => wpinv_get_merge_tags_help_text(),
74 74
             'type'     => 'rich_editor',
75
-            'std'      => __( '<p>A new invoice <a href="{invoice_link}">({invoice_number})</a> to {name} for {invoice_total} {invoice_currency} has been created on your site. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing' ),
75
+            'std'      => __('<p>A new invoice <a href="{invoice_link}">({invoice_number})</a> to {name} for {invoice_total} {invoice_currency} has been created on your site. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing'),
76 76
             'class'    => 'large',
77 77
             'size'     => '10'
78 78
         ),
@@ -82,53 +82,53 @@  discard block
 block discarded – undo
82 82
 
83 83
         'email_cancelled_invoice_header' => array(
84 84
             'id'       => 'email_cancelled_invoice_header',
85
-            'name'     => '<h3>' . __( 'Cancelled Invoice', 'invoicing' ) . '</h3>',
86
-            'desc'     => __( 'These emails are sent to customers whenever invoices are cancelled.', 'invoicing' ),
85
+            'name'     => '<h3>' . __('Cancelled Invoice', 'invoicing') . '</h3>',
86
+            'desc'     => __('These emails are sent to customers whenever invoices are cancelled.', 'invoicing'),
87 87
             'type'     => 'header',
88 88
         ),
89 89
 
90 90
         'email_cancelled_invoice_active' => array(
91 91
             'id'       => 'email_cancelled_invoice_active',
92
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
93
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
92
+            'name'     => __('Enable/Disable', 'invoicing'),
93
+            'desc'     => __('Enable this email notification', 'invoicing'),
94 94
             'type'     => 'checkbox',
95 95
             'std'      => 1
96 96
         ),
97 97
 
98 98
         'email_cancelled_invoice_admin_bcc' => array(
99 99
             'id'       => 'email_cancelled_invoice_admin_bcc',
100
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
101
-            'desc'     => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
100
+            'name'     => __('Enable Admin BCC', 'invoicing'),
101
+            'desc'     => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
102 102
             'type'     => 'checkbox',
103 103
             'std'      => 1
104 104
         ),
105 105
 
106 106
         'email_cancelled_invoice_subject' => array(
107 107
             'id'       => 'email_cancelled_invoice_subject',
108
-            'name'     => __( 'Subject', 'invoicing' ),
109
-            'desc'     => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
108
+            'name'     => __('Subject', 'invoicing'),
109
+            'desc'     => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
110 110
             'help-tip' => true,
111 111
             'type'     => 'text',
112
-            'std'      => __( '[{site_title}] Invoice ({invoice_number}) Cancelled', 'invoicing' ),
112
+            'std'      => __('[{site_title}] Invoice ({invoice_number}) Cancelled', 'invoicing'),
113 113
             'size'     => 'large'
114 114
         ),
115 115
 
116 116
         'email_cancelled_invoice_heading' => array(
117 117
             'id'       => 'email_cancelled_invoice_heading',
118
-            'name'     => __( 'Email Heading', 'invoicing' ),
119
-            'desc'     => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
118
+            'name'     => __('Email Heading', 'invoicing'),
119
+            'desc'     => __('Enter the main heading contained within the email notification.', 'invoicing'),
120 120
             'help-tip' => true,
121 121
             'type'     => 'text',
122
-            'std'      => __( 'Invoice Cancelled', 'invoicing' ),
122
+            'std'      => __('Invoice Cancelled', 'invoicing'),
123 123
             'size'     => 'large'
124 124
         ),
125 125
 
126 126
         'email_cancelled_invoice_body' => array(
127 127
             'id'       => 'email_cancelled_invoice_body',
128
-            'name'     => __( 'Email Content', 'invoicing' ),
128
+            'name'     => __('Email Content', 'invoicing'),
129 129
             'desc'     => wpinv_get_merge_tags_help_text(),
130 130
             'type'     => 'rich_editor',
131
-            'std'      => __( '<p>The invoice <a href="{invoice_link}">#{invoice_number}</a> created for {name} on {site_title} has been cancelled. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing' ),
131
+            'std'      => __('<p>The invoice <a href="{invoice_link}">#{invoice_number}</a> created for {name} on {site_title} has been cancelled. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing'),
132 132
             'class'    => 'large',
133 133
             'size'     => '10'
134 134
         ),
@@ -139,45 +139,45 @@  discard block
 block discarded – undo
139 139
 
140 140
         'email_failed_invoice_header' => array(
141 141
             'id'       => 'email_failed_invoice_header',
142
-            'name'     => '<h3>' . __( 'Failed Invoice', 'invoicing' ) . '</h3>',
143
-            'desc'     => __( 'Failed invoice emails are sent to the site admin when invoice payments fail.', 'invoicing' ),
142
+            'name'     => '<h3>' . __('Failed Invoice', 'invoicing') . '</h3>',
143
+            'desc'     => __('Failed invoice emails are sent to the site admin when invoice payments fail.', 'invoicing'),
144 144
             'type'     => 'header',
145 145
         ),
146 146
 
147 147
         'email_failed_invoice_active' => array(
148 148
             'id'       => 'email_failed_invoice_active',
149
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
150
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
149
+            'name'     => __('Enable/Disable', 'invoicing'),
150
+            'desc'     => __('Enable this email notification', 'invoicing'),
151 151
             'type'     => 'checkbox',
152 152
             'std'      => 1
153 153
         ),
154 154
 
155 155
         'email_failed_invoice_subject' => array(
156 156
             'id'       => 'email_failed_invoice_subject',
157
-            'name'     => __( 'Subject', 'invoicing' ),
158
-            'desc'     => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
157
+            'name'     => __('Subject', 'invoicing'),
158
+            'desc'     => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
159 159
             'help-tip' => true,
160 160
             'type'     => 'text',
161
-            'std'      => __( '[{site_title}] Invoice ({invoice_number}) Payment Failed', 'invoicing' ),
161
+            'std'      => __('[{site_title}] Invoice ({invoice_number}) Payment Failed', 'invoicing'),
162 162
             'size'     => 'large'
163 163
         ),
164 164
 
165 165
         'email_failed_invoice_heading' => array(
166 166
             'id'       => 'email_failed_invoice_heading',
167
-            'name'     => __( 'Email Heading', 'invoicing' ),
168
-            'desc'     => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
167
+            'name'     => __('Email Heading', 'invoicing'),
168
+            'desc'     => __('Enter the main heading contained within the email notification.', 'invoicing'),
169 169
             'help-tip' => true,
170 170
             'type'     => 'text',
171
-            'std'      => __( 'Invoice Payment Failed', 'invoicing' ),
171
+            'std'      => __('Invoice Payment Failed', 'invoicing'),
172 172
             'size'     => 'large'
173 173
         ),
174 174
 
175 175
         'email_failed_invoice_body' => array(
176 176
             'id'       => 'email_failed_invoice_body',
177
-            'name'     => __( 'Email Content', 'invoicing' ),
177
+            'name'     => __('Email Content', 'invoicing'),
178 178
             'desc'     => wpinv_get_merge_tags_help_text(),
179 179
             'type'     => 'rich_editor',
180
-            'std'      => __( '<p>Payment for the invoice <a href="{invoice_link}">#{invoice_number}</a> on {site_title} has failed to go through. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing' ),
180
+            'std'      => __('<p>Payment for the invoice <a href="{invoice_link}">#{invoice_number}</a> on {site_title} has failed to go through. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing'),
181 181
             'class'    => 'large',
182 182
             'size'     => '10'
183 183
         ),
@@ -187,53 +187,53 @@  discard block
 block discarded – undo
187 187
 
188 188
         'email_onhold_invoice_header' => array(
189 189
             'id'       => 'email_onhold_invoice_header',
190
-            'name'     => '<h3>' . __( 'On Hold Invoice', 'invoicing' ) . '</h3>',
191
-            'desc'     => __( 'These emails are sent to customers whenever their invoices are held.', 'invoicing' ),
190
+            'name'     => '<h3>' . __('On Hold Invoice', 'invoicing') . '</h3>',
191
+            'desc'     => __('These emails are sent to customers whenever their invoices are held.', 'invoicing'),
192 192
             'type'     => 'header',
193 193
         ),
194 194
 
195 195
         'email_onhold_invoice_active' => array(
196 196
             'id'       => 'email_onhold_invoice_active',
197
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
198
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
197
+            'name'     => __('Enable/Disable', 'invoicing'),
198
+            'desc'     => __('Enable this email notification', 'invoicing'),
199 199
             'type'     => 'checkbox',
200 200
             'std'      => 1
201 201
         ),
202 202
 
203 203
         'email_onhold_invoice_admin_bcc' => array(
204 204
             'id'       => 'email_onhold_invoice_admin_bcc',
205
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
206
-            'desc'     => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
205
+            'name'     => __('Enable Admin BCC', 'invoicing'),
206
+            'desc'     => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
207 207
             'type'     => 'checkbox',
208 208
             'std'      => 1
209 209
         ),
210 210
 
211 211
         'email_onhold_invoice_subject' => array(
212 212
             'id'       => 'email_onhold_invoice_subject',
213
-            'name'     => __( 'Subject', 'invoicing' ),
214
-            'desc'     => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
213
+            'name'     => __('Subject', 'invoicing'),
214
+            'desc'     => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
215 215
             'help-tip' => true,
216 216
             'type'     => 'text',
217
-            'std'      => __( '[{site_title}] Your invoice is on hold', 'invoicing' ),
217
+            'std'      => __('[{site_title}] Your invoice is on hold', 'invoicing'),
218 218
             'size'     => 'large'
219 219
         ),
220 220
 
221 221
         'email_onhold_invoice_heading' => array(
222 222
             'id'       => 'email_onhold_invoice_heading',
223
-            'name'     => __( 'Email Heading', 'invoicing' ),
224
-            'desc'     => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
223
+            'name'     => __('Email Heading', 'invoicing'),
224
+            'desc'     => __('Enter the main heading contained within the email notification.', 'invoicing'),
225 225
             'help-tip' => true,
226 226
             'type'     => 'text',
227
-            'std'      => __( 'Your invoice is on hold', 'invoicing' ),
227
+            'std'      => __('Your invoice is on hold', 'invoicing'),
228 228
             'size'     => 'large'
229 229
         ),
230 230
 
231 231
         'email_onhold_invoice_body' => array(
232 232
             'id'       => 'email_onhold_invoice_body',
233
-            'name'     => __( 'Email Content', 'invoicing' ),
233
+            'name'     => __('Email Content', 'invoicing'),
234 234
             'desc'     => wpinv_get_merge_tags_help_text(),
235 235
             'type'     => 'rich_editor',
236
-            'std'      => __( '<p>Hi {name},</p><p>Your invoice is on-hold and will be processed when we receive your payment. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing' ),
236
+            'std'      => __('<p>Hi {name},</p><p>Your invoice is on-hold and will be processed when we receive your payment. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing'),
237 237
             'class'    => 'large',
238 238
             'size'     => '10'
239 239
         ),
@@ -244,53 +244,53 @@  discard block
 block discarded – undo
244 244
 
245 245
         'email_processing_invoice_header' => array(
246 246
             'id'       => 'email_processing_invoice_header',
247
-            'name'     => '<h3>' . __( 'Processing Invoice', 'invoicing' ) . '</h3>',
248
-            'desc'     => __( 'These emails are sent to users whenever payments for their invoices are processing.', 'invoicing' ),
247
+            'name'     => '<h3>' . __('Processing Invoice', 'invoicing') . '</h3>',
248
+            'desc'     => __('These emails are sent to users whenever payments for their invoices are processing.', 'invoicing'),
249 249
             'type'     => 'header',
250 250
         ),
251 251
 
252 252
         'email_processing_invoice_active' => array(
253 253
             'id'       => 'email_processing_invoice_active',
254
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
255
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
254
+            'name'     => __('Enable/Disable', 'invoicing'),
255
+            'desc'     => __('Enable this email notification', 'invoicing'),
256 256
             'type'     => 'checkbox',
257 257
             'std'      => 1
258 258
         ),
259 259
 
260 260
         'email_processing_invoice_admin_bcc' => array(
261 261
             'id'       => 'email_processing_invoice_admin_bcc',
262
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
263
-            'desc'     => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ),
262
+            'name'     => __('Enable Admin BCC', 'invoicing'),
263
+            'desc'     => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'),
264 264
             'type'     => 'checkbox',
265 265
             'std'      => 1
266 266
         ),
267 267
 
268 268
         'email_processing_invoice_subject' => array(
269 269
             'id'       => 'email_processing_invoice_subject',
270
-            'name'     => __( 'Subject', 'invoicing' ),
271
-            'desc'     => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
270
+            'name'     => __('Subject', 'invoicing'),
271
+            'desc'     => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
272 272
             'help-tip' => true,
273 273
             'type'     => 'text',
274
-            'std'      => __( '[{site_title}] Your payment is being processed', 'invoicing' ),
274
+            'std'      => __('[{site_title}] Your payment is being processed', 'invoicing'),
275 275
             'size'     => 'large'
276 276
         ),
277 277
 
278 278
         'email_processing_invoice_heading' => array(
279 279
             'id'       => 'email_processing_invoice_heading',
280
-            'name'     => __( 'Email Heading', 'invoicing' ),
281
-            'desc'     => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
280
+            'name'     => __('Email Heading', 'invoicing'),
281
+            'desc'     => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
282 282
             'help-tip' => true,
283 283
             'type'     => 'text',
284
-            'std'      => __( 'Your payment is being processed', 'invoicing' ),
284
+            'std'      => __('Your payment is being processed', 'invoicing'),
285 285
             'size'     => 'large'
286 286
         ),
287 287
 
288 288
         'email_processing_invoice_body' => array(
289 289
             'id'       => 'email_processing_invoice_body',
290
-            'name'     => __( 'Email Content', 'invoicing' ),
290
+            'name'     => __('Email Content', 'invoicing'),
291 291
             'desc'     => wpinv_get_merge_tags_help_text(),
292 292
             'type'     => 'rich_editor',
293
-            'std'      => __( '<p>Hi {name},</p><p>I would like to let you know that we have received and are currently processing your payment for the invoice <a href="{invoice_link}">#{invoice_number}</a> on {site_title}. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing' ),
293
+            'std'      => __('<p>Hi {name},</p><p>I would like to let you know that we have received and are currently processing your payment for the invoice <a href="{invoice_link}">#{invoice_number}</a> on {site_title}. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing'),
294 294
             'class'    => 'large',
295 295
             'size'     => '10'
296 296
         ),
@@ -301,61 +301,61 @@  discard block
 block discarded – undo
301 301
 
302 302
         'email_completed_invoice_header' => array(
303 303
             'id'       => 'email_completed_invoice_header',
304
-            'name'     => '<h3>' . __( 'Paid Invoice', 'invoicing' ) . '</h3>',
305
-            'desc'     => __( 'These emails are sent to customers when their invoices are marked as paid.', 'invoicing' ),
304
+            'name'     => '<h3>' . __('Paid Invoice', 'invoicing') . '</h3>',
305
+            'desc'     => __('These emails are sent to customers when their invoices are marked as paid.', 'invoicing'),
306 306
             'type'     => 'header',
307 307
         ),
308 308
 
309 309
         'email_completed_invoice_active' => array(
310 310
             'id'       => 'email_completed_invoice_active',
311
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
312
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
311
+            'name'     => __('Enable/Disable', 'invoicing'),
312
+            'desc'     => __('Enable this email notification', 'invoicing'),
313 313
             'type'     => 'checkbox',
314 314
             'std'      => 1
315 315
         ),
316 316
 
317 317
         'email_completed_invoice_renewal_active' => array(
318 318
             'id'       => 'email_completed_invoice_renewal_active',
319
-            'name'     => __( 'Enable renewal notification', 'invoicing' ),
320
-            'desc'     => __( 'Should this email be sent for renewals too?', 'invoicing' ),
319
+            'name'     => __('Enable renewal notification', 'invoicing'),
320
+            'desc'     => __('Should this email be sent for renewals too?', 'invoicing'),
321 321
             'type'     => 'checkbox',
322 322
             'std'      => 1
323 323
         ),
324 324
 
325 325
         'email_completed_invoice_admin_bcc' => array(
326 326
             'id'       => 'email_completed_invoice_admin_bcc',
327
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
328
-            'desc'     => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ),
327
+            'name'     => __('Enable Admin BCC', 'invoicing'),
328
+            'desc'     => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'),
329 329
             'type'     => 'checkbox',
330 330
             'std'      => 1,
331 331
         ),
332 332
 
333 333
         'email_completed_invoice_subject' => array(
334 334
             'id'       => 'email_completed_invoice_subject',
335
-            'name'     => __( 'Subject', 'invoicing' ),
336
-            'desc'     => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
335
+            'name'     => __('Subject', 'invoicing'),
336
+            'desc'     => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
337 337
             'help-tip' => true,
338 338
             'type'     => 'text',
339
-            'std'      => __( '[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing' ),
339
+            'std'      => __('[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing'),
340 340
             'size'     => 'large'
341 341
         ),
342 342
 
343 343
         'email_completed_invoice_heading' => array(
344 344
             'id'       => 'email_completed_invoice_heading',
345
-            'name'     => __( 'Email Heading', 'invoicing' ),
346
-            'desc'     => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
345
+            'name'     => __('Email Heading', 'invoicing'),
346
+            'desc'     => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
347 347
             'help-tip' => true,
348 348
             'type'     => 'text',
349
-            'std'      => __( 'Your invoice has been paid', 'invoicing' ),
349
+            'std'      => __('Your invoice has been paid', 'invoicing'),
350 350
             'size'     => 'large'
351 351
         ),
352 352
 
353 353
         'email_completed_invoice_body' => array(
354 354
             'id'       => 'email_completed_invoice_body',
355
-            'name'     => __( 'Email Content', 'invoicing' ),
355
+            'name'     => __('Email Content', 'invoicing'),
356 356
             'desc'     => wpinv_get_merge_tags_help_text(),
357 357
             'type'     => 'rich_editor',
358
-            'std'      => __( '<p>Hi {name},</p><p>Your recent invoice on {site_title} has been paid. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing' ),
358
+            'std'      => __('<p>Hi {name},</p><p>Your recent invoice on {site_title} has been paid. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing'),
359 359
             'class'    => 'large',
360 360
             'size'     => '10'
361 361
         ),
@@ -366,53 +366,53 @@  discard block
 block discarded – undo
366 366
 
367 367
         'email_refunded_invoice_header' => array(
368 368
             'id'       => 'email_refunded_invoice_header',
369
-            'name'     => '<h3>' . __( 'Refunded Invoice', 'invoicing' ) . '</h3>',
370
-            'desc'     => __( 'These emails are sent to users when their invoices are marked as refunded.', 'invoicing' ),
369
+            'name'     => '<h3>' . __('Refunded Invoice', 'invoicing') . '</h3>',
370
+            'desc'     => __('These emails are sent to users when their invoices are marked as refunded.', 'invoicing'),
371 371
             'type'     => 'header',
372 372
         ),
373 373
 
374 374
         'email_refunded_invoice_active' => array(
375 375
             'id'       => 'email_refunded_invoice_active',
376
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
377
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
376
+            'name'     => __('Enable/Disable', 'invoicing'),
377
+            'desc'     => __('Enable this email notification', 'invoicing'),
378 378
             'type'     => 'checkbox',
379 379
             'std'      => 1
380 380
         ),
381 381
 
382 382
         'email_refunded_invoice_admin_bcc' => array(
383 383
             'id'       => 'email_refunded_invoice_admin_bcc',
384
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
385
-            'desc'     => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ),
384
+            'name'     => __('Enable Admin BCC', 'invoicing'),
385
+            'desc'     => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'),
386 386
             'type'     => 'checkbox',
387 387
             'std'      => 1
388 388
         ),
389 389
 
390 390
         'email_refunded_invoice_subject' => array(
391 391
             'id'       => 'email_refunded_invoice_subject',
392
-            'name'     => __( 'Subject', 'invoicing' ),
393
-            'desc'     => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
392
+            'name'     => __('Subject', 'invoicing'),
393
+            'desc'     => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
394 394
             'help-tip' => true,
395 395
             'type'     => 'text',
396
-            'std'      => __( '[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing' ),
396
+            'std'      => __('[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing'),
397 397
             'size'     => 'large'
398 398
         ),
399 399
 
400 400
         'email_refunded_invoice_heading' => array(
401 401
             'id'       => 'email_refunded_invoice_heading',
402
-            'name'     => __( 'Email Heading', 'invoicing' ),
403
-            'desc'     => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
402
+            'name'     => __('Email Heading', 'invoicing'),
403
+            'desc'     => __('Enter the main heading contained within the email notification.', 'invoicing'),
404 404
             'help-tip' => true,
405 405
             'type'     => 'text',
406
-            'std'      => __( 'Your invoice has been refunded', 'invoicing' ),
406
+            'std'      => __('Your invoice has been refunded', 'invoicing'),
407 407
             'size'     => 'large'
408 408
         ),
409 409
 
410 410
         'email_refunded_invoice_body' => array(
411 411
             'id'       => 'email_refunded_invoice_body',
412
-            'name'     => __( 'Email Content', 'invoicing' ),
412
+            'name'     => __('Email Content', 'invoicing'),
413 413
             'desc'     => wpinv_get_merge_tags_help_text(),
414 414
             'type'     => 'rich_editor',
415
-            'std'      => __( '<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing' ),
415
+            'std'      => __('<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing'),
416 416
             'class'    => 'large',
417 417
             'size'     => '10'
418 418
         ),
@@ -423,53 +423,53 @@  discard block
 block discarded – undo
423 423
 
424 424
         'email_user_invoice_header' => array(
425 425
             'id'       => 'email_user_invoice_header',
426
-            'name'     => '<h3>' . __( 'Customer Invoice', 'invoicing' ) . '</h3>',
427
-            'desc'     => __( 'These emails are sent to customers containing their invoice information and payment links.', 'invoicing' ),
426
+            'name'     => '<h3>' . __('Customer Invoice', 'invoicing') . '</h3>',
427
+            'desc'     => __('These emails are sent to customers containing their invoice information and payment links.', 'invoicing'),
428 428
             'type'     => 'header',
429 429
         ),
430 430
 
431 431
         'email_user_invoice_active' => array(
432 432
             'id'       => 'email_user_invoice_active',
433
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
434
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
433
+            'name'     => __('Enable/Disable', 'invoicing'),
434
+            'desc'     => __('Enable this email notification', 'invoicing'),
435 435
             'type'     => 'checkbox',
436 436
             'std'      => 1
437 437
         ),
438 438
 
439 439
         'email_user_invoice_admin_bcc' => array(
440 440
             'id'       => 'email_user_invoice_admin_bcc',
441
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
442
-            'desc'     => __( 'Check if you want to send a copy of this notification email to to the site admin.', 'invoicing' ),
441
+            'name'     => __('Enable Admin BCC', 'invoicing'),
442
+            'desc'     => __('Check if you want to send a copy of this notification email to to the site admin.', 'invoicing'),
443 443
             'type'     => 'checkbox',
444 444
             'std'      => 0
445 445
         ),
446 446
 
447 447
         'email_user_invoice_subject' => array(
448 448
             'id'       => 'email_user_invoice_subject',
449
-            'name'     => __( 'Subject', 'invoicing' ),
450
-            'desc'     => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
449
+            'name'     => __('Subject', 'invoicing'),
450
+            'desc'     => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
451 451
             'help-tip' => true,
452 452
             'type'     => 'text',
453
-            'std'      => __( '[{site_title}] Your invoice from {invoice_date}', 'invoicing' ),
453
+            'std'      => __('[{site_title}] Your invoice from {invoice_date}', 'invoicing'),
454 454
             'size'     => 'large'
455 455
         ),
456 456
 
457 457
         'email_user_invoice_heading' => array(
458 458
             'id'       => 'email_user_invoice_heading',
459
-            'name'     => __( 'Email Heading', 'invoicing' ),
460
-            'desc'     => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
459
+            'name'     => __('Email Heading', 'invoicing'),
460
+            'desc'     => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
461 461
             'help-tip' => true,
462 462
             'type'     => 'text',
463
-            'std'      => __( 'Your invoice {invoice_number} details', 'invoicing' ),
463
+            'std'      => __('Your invoice {invoice_number} details', 'invoicing'),
464 464
             'size'     => 'large'
465 465
         ),
466 466
 
467 467
         'email_user_invoice_body' => array(
468 468
             'id'       => 'email_user_invoice_body',
469
-            'name'     => __( 'Email Content', 'invoicing' ),
469
+            'name'     => __('Email Content', 'invoicing'),
470 470
             'desc'     => wpinv_get_merge_tags_help_text(),
471 471
             'type'     => 'rich_editor',
472
-            'std'      => __( '<p>Hi {name},</p><p>An invoice of {invoice_total} has been created for you on {site_title}. You can <a href="{invoice_link}">view</a> or <a href="{invoice_pay_link}">pay</a> the invoice. Please reply to this email if you have any questions about the invoice.', 'invoicing' ),
472
+            'std'      => __('<p>Hi {name},</p><p>An invoice of {invoice_total} has been created for you on {site_title}. You can <a href="{invoice_link}">view</a> or <a href="{invoice_pay_link}">pay</a> the invoice. Please reply to this email if you have any questions about the invoice.', 'invoicing'),
473 473
             'class'    => 'large',
474 474
             'size'     => '10'
475 475
         ),
@@ -479,53 +479,53 @@  discard block
 block discarded – undo
479 479
 
480 480
         'email_user_note_header' => array(
481 481
             'id'       => 'email_user_note_header',
482
-            'name'     => '<h3>' . __( 'Customer Note', 'invoicing' ) . '</h3>',
483
-            'desc'     => __( 'These emails are sent when you add a customer note to an invoice/quote.', 'invoicing' ),
482
+            'name'     => '<h3>' . __('Customer Note', 'invoicing') . '</h3>',
483
+            'desc'     => __('These emails are sent when you add a customer note to an invoice/quote.', 'invoicing'),
484 484
             'type'     => 'header',
485 485
         ),
486 486
 
487 487
         'email_user_note_active' => array(
488 488
             'id'       => 'email_user_note_active',
489
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
490
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
489
+            'name'     => __('Enable/Disable', 'invoicing'),
490
+            'desc'     => __('Enable this email notification', 'invoicing'),
491 491
             'type'     => 'checkbox',
492 492
             'std'      => 1
493 493
         ),
494 494
 
495 495
         'email_user_note_admin_bcc' => array(
496 496
             'id'       => 'email_user_note_admin_bcc',
497
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
498
-            'desc'     => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ),
497
+            'name'     => __('Enable Admin BCC', 'invoicing'),
498
+            'desc'     => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'),
499 499
             'type'     => 'checkbox',
500 500
             'std'      => 0
501 501
         ),
502 502
 
503 503
         'email_user_note_subject' => array(
504 504
             'id'       => 'email_user_note_subject',
505
-            'name'     => __( 'Subject', 'invoicing' ),
506
-            'desc'     => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
505
+            'name'     => __('Subject', 'invoicing'),
506
+            'desc'     => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
507 507
             'help-tip' => true,
508 508
             'type'     => 'text',
509
-            'std'      => __( '[{site_title}] Note added to your {invoice_label} #{invoice_number} from {invoice_date}', 'invoicing' ),
509
+            'std'      => __('[{site_title}] Note added to your {invoice_label} #{invoice_number} from {invoice_date}', 'invoicing'),
510 510
             'size'     => 'large'
511 511
         ),
512 512
 
513 513
         'email_user_note_heading' => array(
514 514
             'id'       => 'email_user_note_heading',
515
-            'name'     => __( 'Email Heading', 'invoicing' ),
516
-            'desc'     => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
515
+            'name'     => __('Email Heading', 'invoicing'),
516
+            'desc'     => __('Enter the main heading contained within the email notification.', 'invoicing'),
517 517
             'help-tip' => true,
518 518
             'type'     => 'text',
519
-            'std'      => __( 'A note has been added to your {invoice_label}', 'invoicing' ),
519
+            'std'      => __('A note has been added to your {invoice_label}', 'invoicing'),
520 520
             'size'     => 'large'
521 521
         ),
522 522
 
523 523
         'email_user_note_body' => array(
524 524
             'id'       => 'email_user_note_body',
525
-            'name'     => __( 'Email Content', 'invoicing' ),
525
+            'name'     => __('Email Content', 'invoicing'),
526 526
             'desc'     => wpinv_get_merge_tags_help_text(),
527 527
             'type'     => 'rich_editor',
528
-            'std'      => __( '<p>Hi {name},</p><p>The following note has been added to your {invoice_label} <a href="{invoice_link}">#{invoice_number}</a>:</p><blockquote class="wpinv-note">{customer_note}</blockquote><a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a>', 'invoicing' ),
528
+            'std'      => __('<p>Hi {name},</p><p>The following note has been added to your {invoice_label} <a href="{invoice_link}">#{invoice_number}</a>:</p><blockquote class="wpinv-note">{customer_note}</blockquote><a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a>', 'invoicing'),
529 529
             'class'    => 'large',
530 530
             'size'     => '10'
531 531
         ),
@@ -535,63 +535,63 @@  discard block
 block discarded – undo
535 535
 
536 536
         'email_overdue_header' => array(
537 537
             'id'       => 'email_overdue_header',
538
-            'name'     => '<h3>' . __( 'Payment Reminder', 'invoicing' ) . '</h3>',
539
-            'desc'     => __( 'Payment reminder emails are sent to customers whenever their invoices are due.', 'invoicing' ),
538
+            'name'     => '<h3>' . __('Payment Reminder', 'invoicing') . '</h3>',
539
+            'desc'     => __('Payment reminder emails are sent to customers whenever their invoices are due.', 'invoicing'),
540 540
             'type'     => 'header',
541 541
         ),
542 542
 
543 543
         'email_overdue_active' => array(
544 544
             'id'       => 'email_overdue_active',
545
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
546
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
545
+            'name'     => __('Enable/Disable', 'invoicing'),
546
+            'desc'     => __('Enable this email notification', 'invoicing'),
547 547
             'type'     => 'checkbox',
548 548
             'std'      => 1
549 549
         ),
550 550
 
551 551
         'email_overdue_admin_bcc' => array(
552 552
             'id'       => 'email_overdue_admin_bcc',
553
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
554
-            'desc'     => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ),
553
+            'name'     => __('Enable Admin BCC', 'invoicing'),
554
+            'desc'     => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'),
555 555
             'type'     => 'checkbox',
556 556
             'std'      => 0
557 557
         ),
558 558
 
559 559
         'email_overdue_days' => array(
560 560
             'id'       => 'email_overdue_days',
561
-            'name'     => __( 'When to Send', 'invoicing' ),
562
-            'desc'     => __( 'Check when you would like payment reminders sent out.', 'invoicing' ),
561
+            'name'     => __('When to Send', 'invoicing'),
562
+            'desc'     => __('Check when you would like payment reminders sent out.', 'invoicing'),
563 563
             'help-tip' => true,
564
-            'std'      => array( '1' ),
564
+            'std'      => array('1'),
565 565
             'type'     => 'multicheck',
566 566
             'options'  => $overdue_days_options,
567 567
         ),
568 568
 
569 569
         'email_overdue_subject' => array(
570 570
             'id'       => 'email_overdue_subject',
571
-            'name'     => __( 'Subject', 'invoicing' ),
572
-            'desc'     => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
571
+            'name'     => __('Subject', 'invoicing'),
572
+            'desc'     => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
573 573
             'help-tip' => true,
574 574
             'type'     => 'text',
575
-            'std'      => __( '[{site_title}] Payment Reminder', 'invoicing' ),
575
+            'std'      => __('[{site_title}] Payment Reminder', 'invoicing'),
576 576
             'size'     => 'large'
577 577
         ),
578 578
 
579 579
         'email_overdue_heading' => array(
580 580
             'id'       => 'email_overdue_heading',
581
-            'name'     => __( 'Email Heading', 'invoicing' ),
582
-            'desc'     => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
581
+            'name'     => __('Email Heading', 'invoicing'),
582
+            'desc'     => __('Enter the main heading contained within the email notification.', 'invoicing'),
583 583
             'help-tip' => true,
584 584
             'type'     => 'text',
585
-            'std'      => __( 'Payment reminder for your invoice', 'invoicing' ),
585
+            'std'      => __('Payment reminder for your invoice', 'invoicing'),
586 586
             'size'     => 'large'
587 587
         ),
588 588
 
589 589
         'email_overdue_body' => array(
590 590
             'id'       => 'email_overdue_body',
591
-            'name'     => __( 'Email Content', 'invoicing' ),
591
+            'name'     => __('Email Content', 'invoicing'),
592 592
             'desc'     => wpinv_get_merge_tags_help_text(),
593 593
             'type'     => 'rich_editor',
594
-            'std'      => __( '<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ),
594
+            'std'      => __('<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'),
595 595
             'class'    => 'large',
596 596
             'size'     => 10,
597 597
         ),
@@ -602,63 +602,63 @@  discard block
 block discarded – undo
602 602
 
603 603
         'email_renewal_reminder_header' => array(
604 604
             'id'       => 'email_renewal_reminder_header',
605
-            'name'     => '<h3>' . __( 'Renewal Reminder', 'invoicing' ) . '</h3>',
606
-            'desc'     => __( 'These emails are sent to customers whenever their subscription is about to renew.', 'invoicing' ),
605
+            'name'     => '<h3>' . __('Renewal Reminder', 'invoicing') . '</h3>',
606
+            'desc'     => __('These emails are sent to customers whenever their subscription is about to renew.', 'invoicing'),
607 607
             'type'     => 'header',
608 608
         ),
609 609
 
610 610
         'email_renewal_reminder_active' => array(
611 611
             'id'       => 'email_renewal_reminder_active',
612
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
613
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
612
+            'name'     => __('Enable/Disable', 'invoicing'),
613
+            'desc'     => __('Enable this email notification', 'invoicing'),
614 614
             'type'     => 'checkbox',
615 615
             'std'      => 0
616 616
         ),
617 617
 
618 618
         'email_renewal_reminder_admin_bcc' => array(
619 619
             'id'       => 'email_renewal_reminder_admin_bcc',
620
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
621
-            'desc'     => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ),
620
+            'name'     => __('Enable Admin BCC', 'invoicing'),
621
+            'desc'     => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'),
622 622
             'type'     => 'checkbox',
623 623
             'std'      => 0
624 624
         ),
625 625
 
626 626
         'email_renewal_reminder_days' => array(
627 627
             'id'       => 'email_renewal_reminder_days',
628
-            'name'     => __( 'When to Send', 'invoicing' ),
629
-            'desc'     => __( 'Check when you would like renewal reminders sent out.', 'invoicing' ),
628
+            'name'     => __('When to Send', 'invoicing'),
629
+            'desc'     => __('Check when you would like renewal reminders sent out.', 'invoicing'),
630 630
             'help-tip' => true,
631
-            'std'      => array( '1', '5', '10' ),
631
+            'std'      => array('1', '5', '10'),
632 632
             'type'     => 'multicheck',
633 633
             'options'  => $renewal_days_options,
634 634
         ),
635 635
 
636 636
         'email_renewal_reminder_subject' => array(
637 637
             'id'       => 'email_renewal_reminder_subject',
638
-            'name'     => __( 'Subject', 'invoicing' ),
639
-            'desc'     => __( 'Enter the subject line for the email.', 'invoicing' ),
638
+            'name'     => __('Subject', 'invoicing'),
639
+            'desc'     => __('Enter the subject line for the email.', 'invoicing'),
640 640
             'help-tip' => true,
641 641
             'type'     => 'text',
642
-            'std'      => __( '[{site_title}] Renewal Reminder', 'invoicing' ),
642
+            'std'      => __('[{site_title}] Renewal Reminder', 'invoicing'),
643 643
             'size'     => 'large'
644 644
         ),
645 645
 
646 646
         'email_renewal_reminder_heading' => array(
647 647
             'id'       => 'email_renewal_reminder_heading',
648
-            'name'     => __( 'Email Heading', 'invoicing' ),
649
-            'desc'     => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
648
+            'name'     => __('Email Heading', 'invoicing'),
649
+            'desc'     => __('Enter the main heading contained within the email notification.', 'invoicing'),
650 650
             'help-tip' => true,
651 651
             'type'     => 'text',
652
-            'std'      => __( 'Upcoming renewal reminder', 'invoicing' ),
652
+            'std'      => __('Upcoming renewal reminder', 'invoicing'),
653 653
             'size'     => 'large'
654 654
         ),
655 655
 
656 656
         'email_renewal_reminder_body' => array(
657 657
             'id'       => 'email_renewal_reminder_body',
658
-            'name'     => __( 'Email Content', 'invoicing' ),
659
-            'desc'     => wpinv_get_merge_tags_help_text( true ),
658
+            'name'     => __('Email Content', 'invoicing'),
659
+            'desc'     => wpinv_get_merge_tags_help_text(true),
660 660
             'type'     => 'rich_editor',
661
-            'std'      => __( '<p>Hi {full_name},</p><p>This is just a friendly reminder that your subscription for invoice <a href="{invoice_link}">#{invoice_number}</a> will renew on {subscription_renewal_date}.</p>', 'invoicing' ),
661
+            'std'      => __('<p>Hi {full_name},</p><p>This is just a friendly reminder that your subscription for invoice <a href="{invoice_link}">#{invoice_number}</a> will renew on {subscription_renewal_date}.</p>', 'invoicing'),
662 662
             'class'    => 'large',
663 663
             'size'     => 10,
664 664
         ),
@@ -669,53 +669,53 @@  discard block
 block discarded – undo
669 669
 
670 670
         'email_subscription_trial_header' => array(
671 671
             'id'       => 'email_subscription_trial_header',
672
-            'name'     => '<h3>' . __( 'Trial Started', 'invoicing' ) . '</h3>',
673
-            'desc'     => __( 'These emails are sent when a customer starts a subscription trial.', 'invoicing' ),
672
+            'name'     => '<h3>' . __('Trial Started', 'invoicing') . '</h3>',
673
+            'desc'     => __('These emails are sent when a customer starts a subscription trial.', 'invoicing'),
674 674
             'type'     => 'header',
675 675
         ),
676 676
 
677 677
         'email_subscription_trial_active' => array(
678 678
             'id'       => 'email_subscription_trial_active',
679
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
680
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
679
+            'name'     => __('Enable/Disable', 'invoicing'),
680
+            'desc'     => __('Enable this email notification', 'invoicing'),
681 681
             'type'     => 'checkbox',
682 682
             'std'      => 0
683 683
         ),
684 684
 
685 685
         'email_subscription_trial_admin_bcc' => array(
686 686
             'id'       => 'email_subscription_trial_admin_bcc',
687
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
688
-            'desc'     => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ),
687
+            'name'     => __('Enable Admin BCC', 'invoicing'),
688
+            'desc'     => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'),
689 689
             'type'     => 'checkbox',
690 690
             'std'      => 0
691 691
         ),
692 692
 
693 693
         'email_subscription_trial_subject' => array(
694 694
             'id'       => 'email_subscription_trial_subject',
695
-            'name'     => __( 'Subject', 'invoicing' ),
696
-            'desc'     => __( 'Enter the subject line for the subscription trial email.', 'invoicing' ),
695
+            'name'     => __('Subject', 'invoicing'),
696
+            'desc'     => __('Enter the subject line for the subscription trial email.', 'invoicing'),
697 697
             'help-tip' => true,
698 698
             'type'     => 'text',
699
-            'std'      => __( '[{site_title}] Trial Started', 'invoicing' ),
699
+            'std'      => __('[{site_title}] Trial Started', 'invoicing'),
700 700
             'size'     => 'large'
701 701
         ),
702 702
 
703 703
         'email_subscription_trial_heading' => array(
704 704
             'id'       => 'email_subscription_trial_heading',
705
-            'name'     => __( 'Email Heading', 'invoicing' ),
706
-            'desc'     => __( 'Enter the main heading of this email.', 'invoicing' ),
705
+            'name'     => __('Email Heading', 'invoicing'),
706
+            'desc'     => __('Enter the main heading of this email.', 'invoicing'),
707 707
             'help-tip' => true,
708 708
             'type'     => 'text',
709
-            'std'      => __( 'Trial Started', 'invoicing' ),
709
+            'std'      => __('Trial Started', 'invoicing'),
710 710
             'size'     => 'large'
711 711
         ),
712 712
 
713 713
         'email_subscription_trial_body' => array(
714 714
             'id'       => 'email_subscription_trial_body',
715
-            'name'     => __( 'Email Content', 'invoicing' ),
716
-            'desc'     => wpinv_get_merge_tags_help_text( true ),
715
+            'name'     => __('Email Content', 'invoicing'),
716
+            'desc'     => wpinv_get_merge_tags_help_text(true),
717 717
             'type'     => 'rich_editor',
718
-            'std'      => __( '<p>Hi {first_name},</p><p>Your trial for {subscription_name} is now active and will renew on {subscription_renewal_date}.</p>', 'invoicing' ),
718
+            'std'      => __('<p>Hi {first_name},</p><p>Your trial for {subscription_name} is now active and will renew on {subscription_renewal_date}.</p>', 'invoicing'),
719 719
             'class'    => 'large',
720 720
             'size'     => 10,
721 721
         ),
@@ -725,53 +725,53 @@  discard block
 block discarded – undo
725 725
 
726 726
         'email_subscription_cancelled_header' => array(
727 727
             'id'       => 'email_subscription_cancelled_header',
728
-            'name'     => '<h3>' . __( 'Subscription Cancelled', 'invoicing' ) . '</h3>',
729
-            'desc'     => __( 'These emails are sent when a customer cancels their subscription.', 'invoicing' ),
728
+            'name'     => '<h3>' . __('Subscription Cancelled', 'invoicing') . '</h3>',
729
+            'desc'     => __('These emails are sent when a customer cancels their subscription.', 'invoicing'),
730 730
             'type'     => 'header',
731 731
         ),
732 732
 
733 733
         'email_subscription_cancelled_active' => array(
734 734
             'id'       => 'email_subscription_cancelled_active',
735
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
736
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
735
+            'name'     => __('Enable/Disable', 'invoicing'),
736
+            'desc'     => __('Enable this email notification', 'invoicing'),
737 737
             'type'     => 'checkbox',
738 738
             'std'      => 1
739 739
         ),
740 740
 
741 741
         'email_subscription_cancelled_admin_bcc' => array(
742 742
             'id'       => 'email_subscription_cancelled_admin_bcc',
743
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
744
-            'desc'     => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ),
743
+            'name'     => __('Enable Admin BCC', 'invoicing'),
744
+            'desc'     => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'),
745 745
             'type'     => 'checkbox',
746 746
             'std'      => 1
747 747
         ),
748 748
 
749 749
         'email_subscription_cancelled_subject' => array(
750 750
             'id'       => 'email_subscription_cancelled_subject',
751
-            'name'     => __( 'Subject', 'invoicing' ),
752
-            'desc'     => __( 'Enter the subject line for the subscription cancelled email.', 'invoicing' ),
751
+            'name'     => __('Subject', 'invoicing'),
752
+            'desc'     => __('Enter the subject line for the subscription cancelled email.', 'invoicing'),
753 753
             'help-tip' => true,
754 754
             'type'     => 'text',
755
-            'std'      => __( '[{site_title}] Subscription Cancelled', 'invoicing' ),
755
+            'std'      => __('[{site_title}] Subscription Cancelled', 'invoicing'),
756 756
             'size'     => 'large'
757 757
         ),
758 758
 
759 759
         'email_subscription_cancelled_heading' => array(
760 760
             'id'       => 'email_subscription_cancelled_heading',
761
-            'name'     => __( 'Email Heading', 'invoicing' ),
762
-            'desc'     => __( 'Enter the main heading of this email.', 'invoicing' ),
761
+            'name'     => __('Email Heading', 'invoicing'),
762
+            'desc'     => __('Enter the main heading of this email.', 'invoicing'),
763 763
             'help-tip' => true,
764 764
             'type'     => 'text',
765
-            'std'      => __( 'Subscription Cancelled', 'invoicing' ),
765
+            'std'      => __('Subscription Cancelled', 'invoicing'),
766 766
             'size'     => 'large'
767 767
         ),
768 768
 
769 769
         'email_subscription_cancelled_body' => array(
770 770
             'id'       => 'email_subscription_cancelled_body',
771
-            'name'     => __( 'Email Content', 'invoicing' ),
772
-            'desc'     => wpinv_get_merge_tags_help_text( true ),
771
+            'name'     => __('Email Content', 'invoicing'),
772
+            'desc'     => wpinv_get_merge_tags_help_text(true),
773 773
             'type'     => 'rich_editor',
774
-            'std'      => __( '<p>Hi {first_name},</p><p>Your subscription for {subscription_name} has been cancelled and will no longer renew.</p>', 'invoicing' ),
774
+            'std'      => __('<p>Hi {first_name},</p><p>Your subscription for {subscription_name} has been cancelled and will no longer renew.</p>', 'invoicing'),
775 775
             'class'    => 'large',
776 776
             'size'     => 10,
777 777
         ),
@@ -781,53 +781,53 @@  discard block
 block discarded – undo
781 781
 
782 782
         'email_subscription_expired_header' => array(
783 783
             'id'       => 'email_subscription_expired_header',
784
-            'name'     => '<h3>' . __( 'Subscription Expired', 'invoicing' ) . '</h3>',
785
-            'desc'     => __( "These emails are sent when a customer's subscription expires and automatic renewal fails.", 'invoicing' ),
784
+            'name'     => '<h3>' . __('Subscription Expired', 'invoicing') . '</h3>',
785
+            'desc'     => __("These emails are sent when a customer's subscription expires and automatic renewal fails.", 'invoicing'),
786 786
             'type'     => 'header',
787 787
         ),
788 788
 
789 789
         'email_subscription_expired_active' => array(
790 790
             'id'       => 'email_subscription_expired_active',
791
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
792
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
791
+            'name'     => __('Enable/Disable', 'invoicing'),
792
+            'desc'     => __('Enable this email notification', 'invoicing'),
793 793
             'type'     => 'checkbox',
794 794
             'std'      => 1
795 795
         ),
796 796
 
797 797
         'email_subscription_expired_admin_bcc' => array(
798 798
             'id'       => 'email_subscription_expired_admin_bcc',
799
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
800
-            'desc'     => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ),
799
+            'name'     => __('Enable Admin BCC', 'invoicing'),
800
+            'desc'     => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'),
801 801
             'type'     => 'checkbox',
802 802
             'std'      => 1
803 803
         ),
804 804
 
805 805
         'email_subscription_expired_subject' => array(
806 806
             'id'       => 'email_subscription_expired_subject',
807
-            'name'     => __( 'Subject', 'invoicing' ),
808
-            'desc'     => __( 'Enter the subject line for the subscription expired email.', 'invoicing' ),
807
+            'name'     => __('Subject', 'invoicing'),
808
+            'desc'     => __('Enter the subject line for the subscription expired email.', 'invoicing'),
809 809
             'help-tip' => true,
810 810
             'type'     => 'text',
811
-            'std'      => __( '[{site_title}] Subscription Expired', 'invoicing' ),
811
+            'std'      => __('[{site_title}] Subscription Expired', 'invoicing'),
812 812
             'size'     => 'large'
813 813
         ),
814 814
 
815 815
         'email_subscription_expired_heading' => array(
816 816
             'id'       => 'email_subscription_expired_heading',
817
-            'name'     => __( 'Email Heading', 'invoicing' ),
818
-            'desc'     => __( 'Enter the main heading of this email.', 'invoicing' ),
817
+            'name'     => __('Email Heading', 'invoicing'),
818
+            'desc'     => __('Enter the main heading of this email.', 'invoicing'),
819 819
             'type'     => 'text',
820
-            'std'      => __( 'Subscription Expired', 'invoicing' ),
820
+            'std'      => __('Subscription Expired', 'invoicing'),
821 821
             'help-tip' => true,
822 822
             'size'     => 'large'
823 823
         ),
824 824
 
825 825
         'email_subscription_expired_body' => array(
826 826
             'id'       => 'email_subscription_expired_body',
827
-            'name'     => __( 'Email Content', 'invoicing' ),
828
-            'desc'     => wpinv_get_merge_tags_help_text( true ),
827
+            'name'     => __('Email Content', 'invoicing'),
828
+            'desc'     => wpinv_get_merge_tags_help_text(true),
829 829
             'type'     => 'rich_editor',
830
-            'std'      => __( '<p>Hi {first_name},</p><p>Your subscription for {subscription_name} has expired.</p>', 'invoicing' ),
830
+            'std'      => __('<p>Hi {first_name},</p><p>Your subscription for {subscription_name} has expired.</p>', 'invoicing'),
831 831
             'class'    => 'large',
832 832
             'size'     => 10,
833 833
         ),
@@ -837,53 +837,53 @@  discard block
 block discarded – undo
837 837
 
838 838
         'email_subscription_complete_header' => array(
839 839
             'id'     => 'email_subscription_complete_header',
840
-            'name'   => '<h3>' . __( 'Subscription Complete', 'invoicing' ) . '</h3>',
841
-            'desc'   => __( 'These emails are sent when a customer completes their subscription.', 'invoicing' ),
840
+            'name'   => '<h3>' . __('Subscription Complete', 'invoicing') . '</h3>',
841
+            'desc'   => __('These emails are sent when a customer completes their subscription.', 'invoicing'),
842 842
             'type'   => 'header',
843 843
         ),
844 844
 
845 845
         'email_subscription_complete_active' => array(
846 846
             'id'      => 'email_subscription_complete_active',
847
-            'name'    => __( 'Enable/Disable', 'invoicing' ),
848
-            'desc'    => __( 'Enable this email notification', 'invoicing' ),
847
+            'name'    => __('Enable/Disable', 'invoicing'),
848
+            'desc'    => __('Enable this email notification', 'invoicing'),
849 849
             'type'    => 'checkbox',
850 850
             'std'     => 1
851 851
         ),
852 852
 
853 853
         'email_subscription_complete_admin_bcc' => array(
854 854
             'id'      => 'email_subscription_complete_admin_bcc',
855
-            'name'    => __( 'Enable Admin BCC', 'invoicing' ),
856
-            'desc'    => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ),
855
+            'name'    => __('Enable Admin BCC', 'invoicing'),
856
+            'desc'    => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'),
857 857
             'type'    => 'checkbox',
858 858
             'std'     => 1
859 859
         ),
860 860
 
861 861
         'email_subscription_complete_subject' => array(
862 862
             'id'       => 'email_subscription_complete_subject',
863
-            'name'     => __( 'Subject', 'invoicing' ),
864
-            'desc'     => __( 'Enter the subject line for the subscription complete email.', 'invoicing' ),
863
+            'name'     => __('Subject', 'invoicing'),
864
+            'desc'     => __('Enter the subject line for the subscription complete email.', 'invoicing'),
865 865
             'help-tip' => true,
866 866
             'type'     => 'text',
867
-            'std'      => __( '[{site_title}] Subscription Complete', 'invoicing' ),
867
+            'std'      => __('[{site_title}] Subscription Complete', 'invoicing'),
868 868
             'size'     => 'large'
869 869
         ),
870 870
 
871 871
         'email_subscription_complete_heading' => array(
872 872
             'id'       => 'email_subscription_complete_heading',
873
-            'name'     => __( 'Email Heading', 'invoicing' ),
874
-            'desc'     => __( 'Enter the main heading of this email.', 'invoicing' ),
873
+            'name'     => __('Email Heading', 'invoicing'),
874
+            'desc'     => __('Enter the main heading of this email.', 'invoicing'),
875 875
             'help-tip' => true,
876 876
             'type'     => 'text',
877
-            'std'      => __( 'Subscription Complete', 'invoicing' ),
877
+            'std'      => __('Subscription Complete', 'invoicing'),
878 878
             'size'     => 'large'
879 879
         ),
880 880
 
881 881
         'email_subscription_complete_body' => array(
882 882
             'id'       => 'email_subscription_complete_body',
883
-            'name'     => __( 'Email Content', 'invoicing' ),
884
-            'desc'     => wpinv_get_merge_tags_help_text( true ),
883
+            'name'     => __('Email Content', 'invoicing'),
884
+            'desc'     => wpinv_get_merge_tags_help_text(true),
885 885
             'type'     => 'rich_editor',
886
-            'std'      => __( '<p>Hi {first_name},</p><p>Your subscription for {subscription_name} is now complete.</p>', 'invoicing' ),
886
+            'std'      => __('<p>Hi {first_name},</p><p>Your subscription for {subscription_name} is now complete.</p>', 'invoicing'),
887 887
             'class'    => 'large',
888 888
             'size'     => 10,
889 889
         ),
Please login to merge, or discard this patch.
includes/class-getpaid-notification-email.php 2 patches
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -13,36 +13,36 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Notification_Email {
14 14
 
15 15
     /**
16
-	 * Contains the type of this notification email.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Contains the type of this notification email.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id;
21 21
 
22 22
     /**
23
-	 * Contains any object to use in filters.
24
-	 *
25
-	 * @var false|WPInv_Invoice|WPInv_Item|WPInv_Subscription
26
-	 */
23
+     * Contains any object to use in filters.
24
+     *
25
+     * @var false|WPInv_Invoice|WPInv_Item|WPInv_Subscription
26
+     */
27 27
     public $object;
28 28
 
29 29
     /**
30
-	 * Class constructor.
31
-	 *
30
+     * Class constructor.
31
+     *
32 32
      * @param string $id Email Type.
33 33
      * @param mixed $object Optional. Associated object.
34
-	 */
35
-	public function __construct( $id, $object = false ) {
34
+     */
35
+    public function __construct( $id, $object = false ) {
36 36
         $this->id     = $id;
37 37
         $this->object = $object;
38 38
     }
39 39
 
40 40
     /**
41
-	 * Retrieves an option
42
-	 *
41
+     * Retrieves an option
42
+     *
43 43
      * @return mixed
44
-	 */
45
-	public function get_option( $key ) {
44
+     */
45
+    public function get_option( $key ) {
46 46
 
47 47
         $key   = "email_{$this->id}_$key";
48 48
         $value = wpinv_get_option( $key, null );
@@ -60,80 +60,80 @@  discard block
 block discarded – undo
60 60
     }
61 61
 
62 62
     /**
63
-	 * Retrieves the email body.
64
-	 *
63
+     * Retrieves the email body.
64
+     *
65 65
      * @return string
66
-	 */
67
-	public function get_body() {
66
+     */
67
+    public function get_body() {
68 68
         $body = $this->get_option( 'body' );
69 69
         return apply_filters( 'getpaid_get_email_body', $body, $this->id, $this->object );
70 70
     }
71 71
 
72 72
     /**
73
-	 * Retrieves the email subject.
74
-	 *
73
+     * Retrieves the email subject.
74
+     *
75 75
      * @return string
76
-	 */
77
-	public function get_subject() {
76
+     */
77
+    public function get_subject() {
78 78
         $subject = $this->get_option( 'subject' );
79 79
         return apply_filters( 'getpaid_get_email_subject', $subject, $this->id, $this->object );
80 80
     }
81 81
 
82 82
     /**
83
-	 * Retrieves the email heading.
84
-	 *
83
+     * Retrieves the email heading.
84
+     *
85 85
      * @return string
86
-	 */
87
-	public function get_heading() {
86
+     */
87
+    public function get_heading() {
88 88
         $heading = $this->get_option( 'heading' );
89 89
         return apply_filters( 'getpaid_get_email_heading', $heading, $this->id, $this->object );
90 90
     }
91 91
 
92 92
     /**
93
-	 * Checks if an email is active.
94
-	 *
93
+     * Checks if an email is active.
94
+     *
95 95
      * @return bool
96
-	 */
97
-	public function is_active() {
96
+     */
97
+    public function is_active() {
98 98
         $is_active = ! empty( $this->get_option( 'active' ) );
99 99
         return apply_filters( 'getpaid_email_type_is_active', $is_active, $this->id, $this->object );
100 100
     }
101 101
 
102 102
     /**
103
-	 * Checks if the site's admin should receive email notifications.
104
-	 *
103
+     * Checks if the site's admin should receive email notifications.
104
+     *
105 105
      * @return bool
106
-	 */
107
-	public function include_admin_bcc() {
106
+     */
107
+    public function include_admin_bcc() {
108 108
         $include_admin_bcc = ! empty( $this->get_option( 'admin_bcc' ) );
109 109
         return apply_filters( 'getpaid_email_type_include_admin_bcc', $include_admin_bcc, $this->id, $this->object );
110 110
     }
111 111
 
112 112
     /**
113
-	 * Checks whether this email should be sent to the customer or admin.
114
-	 *
113
+     * Checks whether this email should be sent to the customer or admin.
114
+     *
115 115
      * @return bool
116
-	 */
117
-	public function is_admin_email() {
116
+     */
117
+    public function is_admin_email() {
118 118
         $is_admin_email = in_array( $this->id, array( 'new_invoice', 'failed_invoice' ) );
119 119
         return apply_filters( 'getpaid_email_type_is_admin_email', $is_admin_email, $this->id, $this->object );
120 120
     }
121 121
 
122 122
     /**
123
-	 * Returns email attachments.
124
-	 *
123
+     * Returns email attachments.
124
+     *
125 125
      * @return array
126
-	 */
127
-	public function get_attachments() {
126
+     */
127
+    public function get_attachments() {
128 128
         return apply_filters( 'getpaid_get_email_attachments', array(), $this->id, $this->object );
129 129
     }
130 130
 
131 131
     /**
132
-	 * Returns an array of merge tags.
133
-	 *
132
+     * Returns an array of merge tags.
133
+     *
134 134
      * @return array
135
-	 */
136
-	public function get_merge_tags() {
135
+     */
136
+    public function get_merge_tags() {
137 137
 
138 138
         $merge_tags = array(
139 139
             '{site_title}' => wpinv_get_blogname(),
@@ -144,13 +144,13 @@  discard block
 block discarded – undo
144 144
     }
145 145
 
146 146
     /**
147
-	 * Adds merge tags to a text.
148
-	 *
147
+     * Adds merge tags to a text.
148
+     *
149 149
      * @param string string $text
150 150
      * @param array $merge_tags
151 151
      * @return string
152
-	 */
153
-	public function add_merge_tags( $text, $merge_tags = array() ) {
152
+     */
153
+    public function add_merge_tags( $text, $merge_tags = array() ) {
154 154
 
155 155
         foreach ( $merge_tags as $key => $value ) {
156 156
             $text = str_replace( $key, $value, $text );
@@ -160,13 +160,13 @@  discard block
 block discarded – undo
160 160
     }
161 161
 
162 162
     /**
163
-	 * Returns the email content
164
-	 *
163
+     * Returns the email content
164
+     *
165 165
      * @param array $merge_tags
166 166
      * @param array $extra_args Extra template args
167 167
      * @return string
168
-	 */
169
-	public function get_content( $merge_tags = array(), $extra_args = array() ) {
168
+     */
169
+    public function get_content( $merge_tags = array(), $extra_args = array() ) {
170 170
 
171 171
         $content = wpinv_get_template_html(
172 172
             "emails/wpinv-email-{$this->id}.php",
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Represents a single email type.
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
      * @param string $id Email Type.
33 33
      * @param mixed $object Optional. Associated object.
34 34
 	 */
35
-	public function __construct( $id, $object = false ) {
35
+	public function __construct($id, $object = false) {
36 36
         $this->id     = $id;
37 37
         $this->object = $object;
38 38
     }
@@ -42,18 +42,18 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
      * @return mixed
44 44
 	 */
45
-	public function get_option( $key ) {
45
+	public function get_option($key) {
46 46
 
47 47
         $key   = "email_{$this->id}_$key";
48
-        $value = wpinv_get_option( $key, null );
49
-        if ( is_null( $value ) ) {
48
+        $value = wpinv_get_option($key, null);
49
+        if (is_null($value)) {
50 50
             $options = wpinv_get_emails();
51 51
 
52
-            if ( ! isset( $options[ $this->id ] ) || ! isset( $options[ $this->id ][ $key ] ) ) {
52
+            if (!isset($options[$this->id]) || !isset($options[$this->id][$key])) {
53 53
                 return '';
54 54
             }
55 55
 
56
-            $value = isset( $options[ $this->id ][ $key ]['std'] ) ? $options[ $this->id ][ $key ]['std'] : '';
56
+            $value = isset($options[$this->id][$key]['std']) ? $options[$this->id][$key]['std'] : '';
57 57
         }
58 58
 
59 59
         return $value;
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
      * @return string
66 66
 	 */
67 67
 	public function get_body() {
68
-        $body = $this->get_option( 'body' );
69
-        return apply_filters( 'getpaid_get_email_body', $body, $this->id, $this->object );
68
+        $body = $this->get_option('body');
69
+        return apply_filters('getpaid_get_email_body', $body, $this->id, $this->object);
70 70
     }
71 71
 
72 72
     /**
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
      * @return string
76 76
 	 */
77 77
 	public function get_subject() {
78
-        $subject = $this->get_option( 'subject' );
79
-        return apply_filters( 'getpaid_get_email_subject', $subject, $this->id, $this->object );
78
+        $subject = $this->get_option('subject');
79
+        return apply_filters('getpaid_get_email_subject', $subject, $this->id, $this->object);
80 80
     }
81 81
 
82 82
     /**
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
      * @return string
86 86
 	 */
87 87
 	public function get_heading() {
88
-        $heading = $this->get_option( 'heading' );
89
-        return apply_filters( 'getpaid_get_email_heading', $heading, $this->id, $this->object );
88
+        $heading = $this->get_option('heading');
89
+        return apply_filters('getpaid_get_email_heading', $heading, $this->id, $this->object);
90 90
     }
91 91
 
92 92
     /**
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
      * @return bool
96 96
 	 */
97 97
 	public function is_active() {
98
-        $is_active = ! empty( $this->get_option( 'active' ) );
99
-        return apply_filters( 'getpaid_email_type_is_active', $is_active, $this->id, $this->object );
98
+        $is_active = !empty($this->get_option('active'));
99
+        return apply_filters('getpaid_email_type_is_active', $is_active, $this->id, $this->object);
100 100
     }
101 101
 
102 102
     /**
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
      * @return bool
106 106
 	 */
107 107
 	public function include_admin_bcc() {
108
-        $include_admin_bcc = ! empty( $this->get_option( 'admin_bcc' ) );
109
-        return apply_filters( 'getpaid_email_type_include_admin_bcc', $include_admin_bcc, $this->id, $this->object );
108
+        $include_admin_bcc = !empty($this->get_option('admin_bcc'));
109
+        return apply_filters('getpaid_email_type_include_admin_bcc', $include_admin_bcc, $this->id, $this->object);
110 110
     }
111 111
 
112 112
     /**
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
      * @return bool
116 116
 	 */
117 117
 	public function is_admin_email() {
118
-        $is_admin_email = in_array( $this->id, array( 'new_invoice', 'failed_invoice' ) );
119
-        return apply_filters( 'getpaid_email_type_is_admin_email', $is_admin_email, $this->id, $this->object );
118
+        $is_admin_email = in_array($this->id, array('new_invoice', 'failed_invoice'));
119
+        return apply_filters('getpaid_email_type_is_admin_email', $is_admin_email, $this->id, $this->object);
120 120
     }
121 121
 
122 122
     /**
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
      * @return array
126 126
 	 */
127 127
 	public function get_attachments() {
128
-        return apply_filters( 'getpaid_get_email_attachments', array(), $this->id, $this->object );
128
+        return apply_filters('getpaid_get_email_attachments', array(), $this->id, $this->object);
129 129
     }
130 130
 
131 131
     /**
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
 
138 138
         $merge_tags = array(
139 139
             '{site_title}' => wpinv_get_blogname(),
140
-            '{date}'       => getpaid_format_date_value( current_time( 'mysql' ) ),
140
+            '{date}'       => getpaid_format_date_value(current_time('mysql')),
141 141
         );
142 142
 
143
-        return apply_filters( 'getpaid_get_email_merge_tags', $merge_tags, $this->object, $this->id );
143
+        return apply_filters('getpaid_get_email_merge_tags', $merge_tags, $this->object, $this->id);
144 144
     }
145 145
 
146 146
     /**
@@ -150,13 +150,13 @@  discard block
 block discarded – undo
150 150
      * @param array $merge_tags
151 151
      * @return string
152 152
 	 */
153
-	public function add_merge_tags( $text, $merge_tags = array() ) {
153
+	public function add_merge_tags($text, $merge_tags = array()) {
154 154
 
155
-        foreach ( $merge_tags as $key => $value ) {
156
-            $text = str_replace( $key, $value, $text );
155
+        foreach ($merge_tags as $key => $value) {
156
+            $text = str_replace($key, $value, $text);
157 157
         }
158 158
 
159
-        return wptexturize( $text );
159
+        return wptexturize($text);
160 160
     }
161 161
 
162 162
     /**
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
      * @param array $extra_args Extra template args
167 167
      * @return string
168 168
 	 */
169
-	public function get_content( $merge_tags = array(), $extra_args = array() ) {
169
+	public function get_content($merge_tags = array(), $extra_args = array()) {
170 170
 
171 171
         $content = wpinv_get_template_html(
172 172
             "emails/wpinv-email-{$this->id}.php",
@@ -176,15 +176,15 @@  discard block
 block discarded – undo
176 176
                     'invoice'       => $this->object, // Backwards compat.
177 177
                     'object'        => $this->object,
178 178
                     'email_type'    => $this->id,
179
-                    'email_heading' => $this->add_merge_tags( $this->get_heading(), $merge_tags ),
179
+                    'email_heading' => $this->add_merge_tags($this->get_heading(), $merge_tags),
180 180
                     'sent_to_admin' => $this->is_admin_email(),
181 181
                     'plain_text'    => false,
182
-                    'message_body'  => wpautop( $this->add_merge_tags( $this->get_body(), $merge_tags ) ),
182
+                    'message_body'  => wpautop($this->add_merge_tags($this->get_body(), $merge_tags)),
183 183
                 )
184 184
             )
185 185
         );
186 186
 
187
-        return wpinv_email_style_body( $content );
187
+        return wpinv_email_style_body($content);
188 188
     }
189 189
 
190 190
 }
Please login to merge, or discard this patch.