Completed
Branch BUG-10532-replace-hooks-for-ts (65130e)
by
unknown
28:48 queued 15:20
created
form_sections/strategies/display/EE_Select_Display_Strategy.strategy.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@
 block discarded – undo
84 84
 	 * Checks if that value is the one selected
85 85
 	 *
86 86
 	 * @param string|int $option_value unnormalized value option (string). How it will appear in the HTML.
87
-	 * @return string
87
+	 * @return boolean
88 88
 	 */
89 89
 	protected function _check_if_option_selected($option_value ){
90 90
 		return $option_value === $this->_input->raw_value();
Please login to merge, or discard this patch.
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -38,15 +38,15 @@  discard block
 block discarded – undo
38 38
 		if ( EEH_Array::is_multi_dimensional_array( $this->_input->options() )) {
39 39
 			EEH_HTML::indent( 1, 'optgroup' );
40 40
 			foreach( $this->_input->options() as $opt_group_label => $opt_group ){
41
-			    if ( ! empty($opt_group_label)) {
42
-                    $html .= EEH_HTML::nl(0, 'optgroup') . '<optgroup label="' . esc_attr($opt_group_label) . '">';
43
-                }
41
+				if ( ! empty($opt_group_label)) {
42
+					$html .= EEH_HTML::nl(0, 'optgroup') . '<optgroup label="' . esc_attr($opt_group_label) . '">';
43
+				}
44 44
 				EEH_HTML::indent( 1, 'option' );
45 45
 				$html .= $this->_display_options( $opt_group );
46 46
 				EEH_HTML::indent( -1, 'option' );
47
-                if ( ! empty($opt_group_label)) {
48
-                    $html .= EEH_HTML::nl( 0, 'optgroup' ) . '</optgroup>';
49
-			    }
47
+				if ( ! empty($opt_group_label)) {
48
+					$html .= EEH_HTML::nl( 0, 'optgroup' ) . '</optgroup>';
49
+				}
50 50
 			}
51 51
 			EEH_HTML::indent( -1, 'optgroup' );
52 52
 		} else {
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
 		$html = '';
69 69
 		EEH_HTML::indent( 1, 'option' );
70 70
 		foreach( $options as $value => $display_text ){
71
-		    //even if this input uses EE_Text_Normalization if one of the array keys is a numeric string, like "123",
72
-            //PHP will have converted it to a PHP integer (eg 123). So we need to make sure it's a string
73
-            $unnormalized_value = $this->_input->get_normalization_strategy()->unnormalize_one( $value );
74
-            $selected = $this->_check_if_option_selected($unnormalized_value ) ? ' selected="selected"' : '';
75
-            $html.= EEH_HTML::nl( 0, 'option' ) . '<option value="' . esc_attr($unnormalized_value ) . '"' . $selected . '>' . $display_text . '</option>';
71
+			//even if this input uses EE_Text_Normalization if one of the array keys is a numeric string, like "123",
72
+			//PHP will have converted it to a PHP integer (eg 123). So we need to make sure it's a string
73
+			$unnormalized_value = $this->_input->get_normalization_strategy()->unnormalize_one( $value );
74
+			$selected = $this->_check_if_option_selected($unnormalized_value ) ? ' selected="selected"' : '';
75
+			$html.= EEH_HTML::nl( 0, 'option' ) . '<option value="' . esc_attr($unnormalized_value ) . '"' . $selected . '>' . $display_text . '</option>';
76 76
 		}
77 77
 		EEH_HTML::indent( -1, 'option' );
78 78
 		return $html;
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -11,49 +11,49 @@  discard block
 block discarded – undo
11 11
  * @since 				$VID:$
12 12
  *
13 13
  */
14
-class EE_Select_Display_Strategy extends EE_Display_Strategy_Base{
14
+class EE_Select_Display_Strategy extends EE_Display_Strategy_Base {
15 15
 
16 16
 	/**
17 17
 	 *
18 18
 	 * @throws EE_Error
19 19
 	 * @return string of html to display the field
20 20
 	 */
21
-	function display(){
22
-		if( ! $this->_input instanceof EE_Form_Input_With_Options_Base){
23
-			throw new EE_Error( sprintf( __( 'Cannot use Select Display Strategy with an input that doesn\'t have options', 'event_espresso' )));
21
+	function display() {
22
+		if ( ! $this->_input instanceof EE_Form_Input_With_Options_Base) {
23
+			throw new EE_Error(sprintf(__('Cannot use Select Display Strategy with an input that doesn\'t have options', 'event_espresso')));
24 24
 		}
25 25
 
26
-		$html = EEH_HTML::nl( 0, 'select' );
26
+		$html = EEH_HTML::nl(0, 'select');
27 27
 		$html .= '<select';
28
-		$html .= ' id="' . $this->_input->html_id() . '"';
29
-		$html .= ' name="' . $this->_input->html_name() . '"';
30
-		$class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class();
31
-		$html .= ' class="' . $class . '"';
28
+		$html .= ' id="'.$this->_input->html_id().'"';
29
+		$html .= ' name="'.$this->_input->html_name().'"';
30
+		$class = $this->_input->required() ? $this->_input->required_css_class().' '.$this->_input->html_class() : $this->_input->html_class();
31
+		$html .= ' class="'.$class.'"';
32 32
 		// add html5 required
33 33
 		$html .= $this->_input->required() ? ' required' : '';
34
-		$html .= ' style="' . $this->_input->html_style() . '"';
35
-		$html .= ' ' . $this->_input->other_html_attributes();
34
+		$html .= ' style="'.$this->_input->html_style().'"';
35
+		$html .= ' '.$this->_input->other_html_attributes();
36 36
 		$html .= '>';
37 37
 
38
-		if ( EEH_Array::is_multi_dimensional_array( $this->_input->options() )) {
39
-			EEH_HTML::indent( 1, 'optgroup' );
40
-			foreach( $this->_input->options() as $opt_group_label => $opt_group ){
38
+		if (EEH_Array::is_multi_dimensional_array($this->_input->options())) {
39
+			EEH_HTML::indent(1, 'optgroup');
40
+			foreach ($this->_input->options() as $opt_group_label => $opt_group) {
41 41
 			    if ( ! empty($opt_group_label)) {
42
-                    $html .= EEH_HTML::nl(0, 'optgroup') . '<optgroup label="' . esc_attr($opt_group_label) . '">';
42
+                    $html .= EEH_HTML::nl(0, 'optgroup').'<optgroup label="'.esc_attr($opt_group_label).'">';
43 43
                 }
44
-				EEH_HTML::indent( 1, 'option' );
45
-				$html .= $this->_display_options( $opt_group );
44
+				EEH_HTML::indent(1, 'option');
45
+				$html .= $this->_display_options($opt_group);
46 46
 				EEH_HTML::indent( -1, 'option' );
47 47
                 if ( ! empty($opt_group_label)) {
48
-                    $html .= EEH_HTML::nl( 0, 'optgroup' ) . '</optgroup>';
48
+                    $html .= EEH_HTML::nl(0, 'optgroup').'</optgroup>';
49 49
 			    }
50 50
 			}
51 51
 			EEH_HTML::indent( -1, 'optgroup' );
52 52
 		} else {
53
-			$html.=$this->_display_options( $this->_input->options() );
53
+			$html .= $this->_display_options($this->_input->options());
54 54
 		}
55 55
 
56
-		$html.= EEH_HTML::nl( 0, 'select' ) . '</select>';
56
+		$html .= EEH_HTML::nl(0, 'select').'</select>';
57 57
 		return $html;
58 58
 	}
59 59
 
@@ -64,15 +64,15 @@  discard block
 block discarded – undo
64 64
 	 * @param array $options
65 65
 	 * @return string
66 66
 	 */
67
-	protected function _display_options($options){
67
+	protected function _display_options($options) {
68 68
 		$html = '';
69
-		EEH_HTML::indent( 1, 'option' );
70
-		foreach( $options as $value => $display_text ){
69
+		EEH_HTML::indent(1, 'option');
70
+		foreach ($options as $value => $display_text) {
71 71
 		    //even if this input uses EE_Text_Normalization if one of the array keys is a numeric string, like "123",
72 72
             //PHP will have converted it to a PHP integer (eg 123). So we need to make sure it's a string
73
-            $unnormalized_value = $this->_input->get_normalization_strategy()->unnormalize_one( $value );
74
-            $selected = $this->_check_if_option_selected($unnormalized_value ) ? ' selected="selected"' : '';
75
-            $html.= EEH_HTML::nl( 0, 'option' ) . '<option value="' . esc_attr($unnormalized_value ) . '"' . $selected . '>' . $display_text . '</option>';
73
+            $unnormalized_value = $this->_input->get_normalization_strategy()->unnormalize_one($value);
74
+            $selected = $this->_check_if_option_selected($unnormalized_value) ? ' selected="selected"' : '';
75
+            $html .= EEH_HTML::nl(0, 'option').'<option value="'.esc_attr($unnormalized_value).'"'.$selected.'>'.$display_text.'</option>';
76 76
 		}
77 77
 		EEH_HTML::indent( -1, 'option' );
78 78
 		return $html;
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 * @param string|int $option_value unnormalized value option (string). How it will appear in the HTML.
87 87
 	 * @return string
88 88
 	 */
89
-	protected function _check_if_option_selected($option_value ){
89
+	protected function _check_if_option_selected($option_value) {
90 90
 		return $option_value === $this->_input->raw_value();
91 91
 	}
92 92
 
Please login to merge, or discard this patch.
libraries/form_sections/inputs/EE_Form_Input_With_Options_Base.input.php 2 patches
Indentation   +315 added lines, -315 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -16,320 +16,320 @@  discard block
 block discarded – undo
16 16
 class EE_Form_Input_With_Options_Base extends EE_Form_Input_Base
17 17
 {
18 18
 
19
-    /**
20
-     * array of available options to choose as an answer
21
-     *
22
-     * @var array
23
-     */
24
-    protected $_options = array();
25
-
26
-    /**
27
-     * whether to display the html_label_text above the checkbox/radio button options
28
-     *
29
-     * @var boolean
30
-     */
31
-    protected $_display_html_label_text = true;
32
-
33
-    /**
34
-     * whether to display an question option description as part of the input label
35
-     *
36
-     * @var boolean
37
-     */
38
-    protected $_use_desc_in_label = true;
39
-
40
-    /**
41
-     * strlen() result for the longest input value (what gets displayed in the label)
42
-     * this is used to apply a css class to the input label
43
-     *
44
-     * @var int
45
-     */
46
-    protected $_label_size = 0;
47
-
48
-    /**
49
-     * whether to enforce the label size value passed in the constructor
50
-     *
51
-     * @var boolean
52
-     */
53
-    protected $_enforce_label_size = false;
54
-
55
-    /**
56
-     * whether to allow multiple selections (ie, the value of this input should be an array)
57
-     * or not (ie, the value should be a simple int, string, etc)
58
-     *
59
-     * @var boolean
60
-     */
61
-    protected $_multiple_selections = false;
62
-
63
-
64
-
65
-    /**
66
-     * @param array     $answer_options
67
-     * @param array     $input_settings {
68
-     * @type int|string $label_size
69
-     * @type boolean    $display_html_label_text
70
-     *                                  }
71
-     *                                  And all the options accepted by EE_Form_Input_Base
72
-     */
73
-    public function __construct($answer_options = array(), $input_settings = array())
74
-    {
75
-        if (isset($input_settings['label_size'])) {
76
-            $this->_set_label_size($input_settings['label_size']);
77
-            if (isset($input_settings['enforce_label_size']) && $input_settings['enforce_label_size']) {
78
-                $this->_enforce_label_size = true;
79
-            }
80
-        }
81
-        if (isset($input_settings['display_html_label_text'])) {
82
-            $this->set_display_html_label_text($input_settings['display_html_label_text']);
83
-        }
84
-        $this->set_select_options($answer_options);
85
-        parent::__construct($input_settings);
86
-    }
87
-
88
-
89
-
90
-    /**
91
-     * Sets the allowed options for this input. Also has the side-effect of
92
-     * updating the normalization strategy to match the keys provided in the array
93
-     *
94
-     * @param array $answer_options
95
-     * @return void  just has the side-effect of setting the options for this input
96
-     */
97
-    public function set_select_options($answer_options = array())
98
-    {
99
-        $answer_options = is_array($answer_options) ? $answer_options : array($answer_options);
100
-        //get the first item in the select options and check it's type
101
-        $this->_options = reset($answer_options) instanceof EE_Question_Option
102
-            ? $this->_process_question_options($answer_options)
103
-            : $answer_options;
104
-        //d( $this->_options );
105
-        $select_option_keys = array_keys($this->_options);
106
-        // attempt to determine data type for values in order to set normalization type
107
-        //purposefully only
108
-        if (
109
-            count($this->_options) === 2
110
-            && (
111
-                (in_array(true, $select_option_keys, true) && in_array(false, $select_option_keys, true))
112
-                || (in_array(1, $select_option_keys, true) && in_array(0, $select_option_keys, true))
113
-            )
114
-        ) {
115
-            // values appear to be boolean, like TRUE, FALSE, 1, 0
116
-            $normalization = new EE_Boolean_Normalization();
117
-        } else {
118
-            //are ALL the options ints (even if we're using a multi-dimensional array)? If so use int validation
119
-            $all_ints = true;
120
-            array_walk_recursive(
121
-                $this->_options,
122
-                function($value,$key) use (&$all_ints){
123
-                    //is this a top-level key? ignore it
124
-                    if(! is_array($value)
125
-                        && ! is_int($key)
126
-                       && $key !== ''
127
-                       && $key !== null){
128
-                        $all_ints = false;
129
-                    }
130
-                }
131
-            );
132
-            if ($all_ints) {
133
-                $normalization = new EE_Int_Normalization();
134
-            } else {
135
-                $normalization = new EE_Text_Normalization();
136
-            }
137
-        }
138
-        // does input type have multiple options ?
139
-        if ($this->_multiple_selections) {
140
-            $this->_set_normalization_strategy(new EE_Many_Valued_Normalization($normalization));
141
-        } else {
142
-            $this->_set_normalization_strategy($normalization);
143
-        }
144
-    }
145
-
146
-
147
-
148
-    /**
149
-     * @return array
150
-     */
151
-    public function options()
152
-    {
153
-        return $this->_options;
154
-    }
155
-
156
-
157
-
158
-    /**
159
-     * Returns an array which is guaranteed to not be multidimensional
160
-     *
161
-     * @return array
162
-     */
163
-    public function flat_options()
164
-    {
165
-        return $this->_flatten_select_options($this->options());
166
-    }
167
-
168
-
169
-
170
-    /**
171
-     * Makes sure $arr is a flat array, not a multidimensional one
172
-     *
173
-     * @param array $arr
174
-     * @return array
175
-     */
176
-    protected function _flatten_select_options($arr)
177
-    {
178
-        $flat_array = array();
179
-        if (EEH_Array::is_multi_dimensional_array($arr)) {
180
-            foreach ($arr as $sub_array) {
181
-                foreach ((array)$sub_array as $key => $value) {
182
-                    $flat_array[$key] = $value;
183
-                    $this->_set_label_size($value);
184
-                }
185
-            }
186
-        } else {
187
-            foreach ($arr as $key => $value) {
188
-                $flat_array[$key] = $value;
189
-                $this->_set_label_size($value);
190
-            }
191
-        }
192
-        return $flat_array;
193
-    }
194
-
195
-
196
-
197
-    /**
198
-     * @param EE_Question_Option[] $question_options_array
199
-     * @return array
200
-     */
201
-    protected function _process_question_options($question_options_array = array())
202
-    {
203
-        $flat_array = array();
204
-        foreach ($question_options_array as $question_option) {
205
-            if ($question_option instanceof EE_Question_Option) {
206
-                $desc = '';
207
-                if ($this->_use_desc_in_label) {
208
-                    $desc = $question_option->desc();
209
-                    $desc = ! empty($desc) ? '<span class="ee-question-option-desc">' . $desc . '</span>' : '';
210
-                }
211
-                $value = $question_option->value();
212
-                // add value even if it's empty
213
-                $flat_array[$value] = $value;
214
-                // if both value and desc are not empty, then separate with a dash
215
-                if ( ! empty($value) && ! empty($desc)) {
216
-                    $flat_array[$value] .= ' - ' . $desc;
217
-                } else {
218
-                    // otherwise, just add desc, since either or both of the vars is empty, and no dash is necessary
219
-                    $flat_array[$value] .= $desc;
220
-                }
221
-            } elseif (is_array($question_option)) {
222
-                $flat_array += $this->_flatten_select_options($question_option);
223
-            }
224
-        }
225
-        return $flat_array;
226
-    }
227
-
228
-
229
-
230
-    /**
231
-     *    set_label_sizes
232
-     *
233
-     * @return void
234
-     */
235
-    public function set_label_sizes()
236
-    {
237
-        // did the input settings specifically say to NOT set the label size dynamically ?
238
-        if ( ! $this->_enforce_label_size) {
239
-            foreach ($this->_options as $option) {
240
-                // calculate the strlen of the label
241
-                $this->_set_label_size($option);
242
-            }
243
-        }
244
-    }
245
-
246
-
247
-
248
-    /**
249
-     *    _set_label_size_class
250
-     *
251
-     * @param int|string $value
252
-     * @return void
253
-     */
254
-    private function _set_label_size($value = '')
255
-    {
256
-        // determine length of option value
257
-        $val_size = is_int($value) ? $value : strlen($value);
258
-        // use new value if bigger than existing
259
-        $this->_label_size = $val_size > $this->_label_size ? $val_size : $this->_label_size;
260
-    }
261
-
262
-
263
-
264
-    /**
265
-     *    get_label_size_class
266
-     *
267
-     * @return string
268
-     */
269
-    public function get_label_size_class()
270
-    {
271
-        $size = ' medium-lbl';
272
-        // use maximum option value length to determine label size
273
-        if ($this->_label_size < 3) {
274
-            $size = ' nano-lbl';
275
-        } else if ($this->_label_size < 6) {
276
-            $size = ' micro-lbl';
277
-        } else if ($this->_label_size < 12) {
278
-            $size = ' tiny-lbl';
279
-        } else if ($this->_label_size < 25) {
280
-            $size = ' small-lbl';
281
-        } else if ($this->_label_size < 50) {
282
-            $size = ' medium-lbl';
283
-        } else if ($this->_label_size >= 100) {
284
-            $size = ' big-lbl';
285
-        }
286
-        return $size;
287
-    }
288
-
289
-
290
-
291
-    /**
292
-     * Returns the pretty value for the normalized value
293
-     *
294
-     * @return string
295
-     */
296
-    public function pretty_value()
297
-    {
298
-        $options = $this->flat_options();
299
-        $unnormalized_value_choices = $this->get_normalization_strategy()->unnormalize($this->_normalized_value);
300
-        if ( ! $this->_multiple_selections) {
301
-            $unnormalized_value_choices = array($unnormalized_value_choices);
302
-        }
303
-        $pretty_strings = array();
304
-        foreach ((array)$unnormalized_value_choices as $unnormalized_value_choice) {
305
-            if (isset($options[$unnormalized_value_choice])) {
306
-                $pretty_strings[] = $options[$unnormalized_value_choice];
307
-            } else {
308
-                $pretty_strings[] = $this->normalized_value();
309
-            }
310
-        }
311
-        return implode(', ', $pretty_strings);
312
-    }
313
-
314
-
315
-
316
-    /**
317
-     * @return boolean
318
-     */
319
-    public function display_html_label_text()
320
-    {
321
-        return $this->_display_html_label_text;
322
-    }
323
-
324
-
325
-
326
-    /**
327
-     * @param boolean $display_html_label_text
328
-     */
329
-    public function set_display_html_label_text($display_html_label_text)
330
-    {
331
-        $this->_display_html_label_text = filter_var($display_html_label_text, FILTER_VALIDATE_BOOLEAN);
332
-    }
19
+	/**
20
+	 * array of available options to choose as an answer
21
+	 *
22
+	 * @var array
23
+	 */
24
+	protected $_options = array();
25
+
26
+	/**
27
+	 * whether to display the html_label_text above the checkbox/radio button options
28
+	 *
29
+	 * @var boolean
30
+	 */
31
+	protected $_display_html_label_text = true;
32
+
33
+	/**
34
+	 * whether to display an question option description as part of the input label
35
+	 *
36
+	 * @var boolean
37
+	 */
38
+	protected $_use_desc_in_label = true;
39
+
40
+	/**
41
+	 * strlen() result for the longest input value (what gets displayed in the label)
42
+	 * this is used to apply a css class to the input label
43
+	 *
44
+	 * @var int
45
+	 */
46
+	protected $_label_size = 0;
47
+
48
+	/**
49
+	 * whether to enforce the label size value passed in the constructor
50
+	 *
51
+	 * @var boolean
52
+	 */
53
+	protected $_enforce_label_size = false;
54
+
55
+	/**
56
+	 * whether to allow multiple selections (ie, the value of this input should be an array)
57
+	 * or not (ie, the value should be a simple int, string, etc)
58
+	 *
59
+	 * @var boolean
60
+	 */
61
+	protected $_multiple_selections = false;
62
+
63
+
64
+
65
+	/**
66
+	 * @param array     $answer_options
67
+	 * @param array     $input_settings {
68
+	 * @type int|string $label_size
69
+	 * @type boolean    $display_html_label_text
70
+	 *                                  }
71
+	 *                                  And all the options accepted by EE_Form_Input_Base
72
+	 */
73
+	public function __construct($answer_options = array(), $input_settings = array())
74
+	{
75
+		if (isset($input_settings['label_size'])) {
76
+			$this->_set_label_size($input_settings['label_size']);
77
+			if (isset($input_settings['enforce_label_size']) && $input_settings['enforce_label_size']) {
78
+				$this->_enforce_label_size = true;
79
+			}
80
+		}
81
+		if (isset($input_settings['display_html_label_text'])) {
82
+			$this->set_display_html_label_text($input_settings['display_html_label_text']);
83
+		}
84
+		$this->set_select_options($answer_options);
85
+		parent::__construct($input_settings);
86
+	}
87
+
88
+
89
+
90
+	/**
91
+	 * Sets the allowed options for this input. Also has the side-effect of
92
+	 * updating the normalization strategy to match the keys provided in the array
93
+	 *
94
+	 * @param array $answer_options
95
+	 * @return void  just has the side-effect of setting the options for this input
96
+	 */
97
+	public function set_select_options($answer_options = array())
98
+	{
99
+		$answer_options = is_array($answer_options) ? $answer_options : array($answer_options);
100
+		//get the first item in the select options and check it's type
101
+		$this->_options = reset($answer_options) instanceof EE_Question_Option
102
+			? $this->_process_question_options($answer_options)
103
+			: $answer_options;
104
+		//d( $this->_options );
105
+		$select_option_keys = array_keys($this->_options);
106
+		// attempt to determine data type for values in order to set normalization type
107
+		//purposefully only
108
+		if (
109
+			count($this->_options) === 2
110
+			&& (
111
+				(in_array(true, $select_option_keys, true) && in_array(false, $select_option_keys, true))
112
+				|| (in_array(1, $select_option_keys, true) && in_array(0, $select_option_keys, true))
113
+			)
114
+		) {
115
+			// values appear to be boolean, like TRUE, FALSE, 1, 0
116
+			$normalization = new EE_Boolean_Normalization();
117
+		} else {
118
+			//are ALL the options ints (even if we're using a multi-dimensional array)? If so use int validation
119
+			$all_ints = true;
120
+			array_walk_recursive(
121
+				$this->_options,
122
+				function($value,$key) use (&$all_ints){
123
+					//is this a top-level key? ignore it
124
+					if(! is_array($value)
125
+						&& ! is_int($key)
126
+					   && $key !== ''
127
+					   && $key !== null){
128
+						$all_ints = false;
129
+					}
130
+				}
131
+			);
132
+			if ($all_ints) {
133
+				$normalization = new EE_Int_Normalization();
134
+			} else {
135
+				$normalization = new EE_Text_Normalization();
136
+			}
137
+		}
138
+		// does input type have multiple options ?
139
+		if ($this->_multiple_selections) {
140
+			$this->_set_normalization_strategy(new EE_Many_Valued_Normalization($normalization));
141
+		} else {
142
+			$this->_set_normalization_strategy($normalization);
143
+		}
144
+	}
145
+
146
+
147
+
148
+	/**
149
+	 * @return array
150
+	 */
151
+	public function options()
152
+	{
153
+		return $this->_options;
154
+	}
155
+
156
+
157
+
158
+	/**
159
+	 * Returns an array which is guaranteed to not be multidimensional
160
+	 *
161
+	 * @return array
162
+	 */
163
+	public function flat_options()
164
+	{
165
+		return $this->_flatten_select_options($this->options());
166
+	}
167
+
168
+
169
+
170
+	/**
171
+	 * Makes sure $arr is a flat array, not a multidimensional one
172
+	 *
173
+	 * @param array $arr
174
+	 * @return array
175
+	 */
176
+	protected function _flatten_select_options($arr)
177
+	{
178
+		$flat_array = array();
179
+		if (EEH_Array::is_multi_dimensional_array($arr)) {
180
+			foreach ($arr as $sub_array) {
181
+				foreach ((array)$sub_array as $key => $value) {
182
+					$flat_array[$key] = $value;
183
+					$this->_set_label_size($value);
184
+				}
185
+			}
186
+		} else {
187
+			foreach ($arr as $key => $value) {
188
+				$flat_array[$key] = $value;
189
+				$this->_set_label_size($value);
190
+			}
191
+		}
192
+		return $flat_array;
193
+	}
194
+
195
+
196
+
197
+	/**
198
+	 * @param EE_Question_Option[] $question_options_array
199
+	 * @return array
200
+	 */
201
+	protected function _process_question_options($question_options_array = array())
202
+	{
203
+		$flat_array = array();
204
+		foreach ($question_options_array as $question_option) {
205
+			if ($question_option instanceof EE_Question_Option) {
206
+				$desc = '';
207
+				if ($this->_use_desc_in_label) {
208
+					$desc = $question_option->desc();
209
+					$desc = ! empty($desc) ? '<span class="ee-question-option-desc">' . $desc . '</span>' : '';
210
+				}
211
+				$value = $question_option->value();
212
+				// add value even if it's empty
213
+				$flat_array[$value] = $value;
214
+				// if both value and desc are not empty, then separate with a dash
215
+				if ( ! empty($value) && ! empty($desc)) {
216
+					$flat_array[$value] .= ' - ' . $desc;
217
+				} else {
218
+					// otherwise, just add desc, since either or both of the vars is empty, and no dash is necessary
219
+					$flat_array[$value] .= $desc;
220
+				}
221
+			} elseif (is_array($question_option)) {
222
+				$flat_array += $this->_flatten_select_options($question_option);
223
+			}
224
+		}
225
+		return $flat_array;
226
+	}
227
+
228
+
229
+
230
+	/**
231
+	 *    set_label_sizes
232
+	 *
233
+	 * @return void
234
+	 */
235
+	public function set_label_sizes()
236
+	{
237
+		// did the input settings specifically say to NOT set the label size dynamically ?
238
+		if ( ! $this->_enforce_label_size) {
239
+			foreach ($this->_options as $option) {
240
+				// calculate the strlen of the label
241
+				$this->_set_label_size($option);
242
+			}
243
+		}
244
+	}
245
+
246
+
247
+
248
+	/**
249
+	 *    _set_label_size_class
250
+	 *
251
+	 * @param int|string $value
252
+	 * @return void
253
+	 */
254
+	private function _set_label_size($value = '')
255
+	{
256
+		// determine length of option value
257
+		$val_size = is_int($value) ? $value : strlen($value);
258
+		// use new value if bigger than existing
259
+		$this->_label_size = $val_size > $this->_label_size ? $val_size : $this->_label_size;
260
+	}
261
+
262
+
263
+
264
+	/**
265
+	 *    get_label_size_class
266
+	 *
267
+	 * @return string
268
+	 */
269
+	public function get_label_size_class()
270
+	{
271
+		$size = ' medium-lbl';
272
+		// use maximum option value length to determine label size
273
+		if ($this->_label_size < 3) {
274
+			$size = ' nano-lbl';
275
+		} else if ($this->_label_size < 6) {
276
+			$size = ' micro-lbl';
277
+		} else if ($this->_label_size < 12) {
278
+			$size = ' tiny-lbl';
279
+		} else if ($this->_label_size < 25) {
280
+			$size = ' small-lbl';
281
+		} else if ($this->_label_size < 50) {
282
+			$size = ' medium-lbl';
283
+		} else if ($this->_label_size >= 100) {
284
+			$size = ' big-lbl';
285
+		}
286
+		return $size;
287
+	}
288
+
289
+
290
+
291
+	/**
292
+	 * Returns the pretty value for the normalized value
293
+	 *
294
+	 * @return string
295
+	 */
296
+	public function pretty_value()
297
+	{
298
+		$options = $this->flat_options();
299
+		$unnormalized_value_choices = $this->get_normalization_strategy()->unnormalize($this->_normalized_value);
300
+		if ( ! $this->_multiple_selections) {
301
+			$unnormalized_value_choices = array($unnormalized_value_choices);
302
+		}
303
+		$pretty_strings = array();
304
+		foreach ((array)$unnormalized_value_choices as $unnormalized_value_choice) {
305
+			if (isset($options[$unnormalized_value_choice])) {
306
+				$pretty_strings[] = $options[$unnormalized_value_choice];
307
+			} else {
308
+				$pretty_strings[] = $this->normalized_value();
309
+			}
310
+		}
311
+		return implode(', ', $pretty_strings);
312
+	}
313
+
314
+
315
+
316
+	/**
317
+	 * @return boolean
318
+	 */
319
+	public function display_html_label_text()
320
+	{
321
+		return $this->_display_html_label_text;
322
+	}
323
+
324
+
325
+
326
+	/**
327
+	 * @param boolean $display_html_label_text
328
+	 */
329
+	public function set_display_html_label_text($display_html_label_text)
330
+	{
331
+		$this->_display_html_label_text = filter_var($display_html_label_text, FILTER_VALIDATE_BOOLEAN);
332
+	}
333 333
 
334 334
 
335 335
 
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -119,12 +119,12 @@  discard block
 block discarded – undo
119 119
             $all_ints = true;
120 120
             array_walk_recursive(
121 121
                 $this->_options,
122
-                function($value,$key) use (&$all_ints){
122
+                function($value, $key) use (&$all_ints){
123 123
                     //is this a top-level key? ignore it
124
-                    if(! is_array($value)
124
+                    if ( ! is_array($value)
125 125
                         && ! is_int($key)
126 126
                        && $key !== ''
127
-                       && $key !== null){
127
+                       && $key !== null) {
128 128
                         $all_ints = false;
129 129
                     }
130 130
                 }
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
         $flat_array = array();
179 179
         if (EEH_Array::is_multi_dimensional_array($arr)) {
180 180
             foreach ($arr as $sub_array) {
181
-                foreach ((array)$sub_array as $key => $value) {
181
+                foreach ((array) $sub_array as $key => $value) {
182 182
                     $flat_array[$key] = $value;
183 183
                     $this->_set_label_size($value);
184 184
                 }
@@ -206,14 +206,14 @@  discard block
 block discarded – undo
206 206
                 $desc = '';
207 207
                 if ($this->_use_desc_in_label) {
208 208
                     $desc = $question_option->desc();
209
-                    $desc = ! empty($desc) ? '<span class="ee-question-option-desc">' . $desc . '</span>' : '';
209
+                    $desc = ! empty($desc) ? '<span class="ee-question-option-desc">'.$desc.'</span>' : '';
210 210
                 }
211 211
                 $value = $question_option->value();
212 212
                 // add value even if it's empty
213 213
                 $flat_array[$value] = $value;
214 214
                 // if both value and desc are not empty, then separate with a dash
215 215
                 if ( ! empty($value) && ! empty($desc)) {
216
-                    $flat_array[$value] .= ' - ' . $desc;
216
+                    $flat_array[$value] .= ' - '.$desc;
217 217
                 } else {
218 218
                     // otherwise, just add desc, since either or both of the vars is empty, and no dash is necessary
219 219
                     $flat_array[$value] .= $desc;
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
             $unnormalized_value_choices = array($unnormalized_value_choices);
302 302
         }
303 303
         $pretty_strings = array();
304
-        foreach ((array)$unnormalized_value_choices as $unnormalized_value_choice) {
304
+        foreach ((array) $unnormalized_value_choices as $unnormalized_value_choice) {
305 305
             if (isset($options[$unnormalized_value_choice])) {
306 306
                 $pretty_strings[] = $options[$unnormalized_value_choice];
307 307
             } else {
Please login to merge, or discard this patch.
form_sections/strategies/normalization/EE_Text_Normalization.strategy.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -15,26 +15,26 @@
 block discarded – undo
15 15
 	 */
16 16
 	public function normalize($value_to_normalize) {
17 17
 		if(is_array($value_to_normalize)) {
18
-            return (string)array_shift($value_to_normalize);
19
-        }
20
-        // consider `"null"` values to be equivalent to null.
21
-        if($value_to_normalize === '' || $value_to_normalize === null) {
22
-		    return null;
18
+			return (string)array_shift($value_to_normalize);
23 19
 		}
24
-        return (string)$value_to_normalize;
25
-    }
20
+		// consider `"null"` values to be equivalent to null.
21
+		if($value_to_normalize === '' || $value_to_normalize === null) {
22
+			return null;
23
+		}
24
+		return (string)$value_to_normalize;
25
+	}
26 26
 	/**
27 27
 	 * IF its a string in PHP, it will be a string in the HTML form. easy
28 28
 	 * @param string $normalized_value
29 29
 	 * @return string
30 30
 	 */
31 31
 	public function unnormalize( $normalized_value ){
32
-	    //account for default "select here" option values
33
-	    if ($normalized_value === null) {
34
-	        return '';
35
-        }
36
-        //double-check it's a string. It's possible this value was a question option that happened to be a numeric
37
-        //string, in which case PHP has automatically converted it to an integer!
32
+		//account for default "select here" option values
33
+		if ($normalized_value === null) {
34
+			return '';
35
+		}
36
+		//double-check it's a string. It's possible this value was a question option that happened to be a numeric
37
+		//string, in which case PHP has automatically converted it to an integer!
38 38
 		return (string)$normalized_value;
39 39
 	}
40 40
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -7,35 +7,35 @@
 block discarded – undo
7 7
  * @subpackage
8 8
  * @author				Mike Nelson
9 9
  */
10
-class EE_Text_Normalization extends EE_Normalization_Strategy_Base{
10
+class EE_Text_Normalization extends EE_Normalization_Strategy_Base {
11 11
 
12 12
 	/**
13 13
 	 * @param string $value_to_normalize
14 14
 	 * @return array|mixed|string
15 15
 	 */
16 16
 	public function normalize($value_to_normalize) {
17
-		if(is_array($value_to_normalize)) {
18
-            return (string)array_shift($value_to_normalize);
17
+		if (is_array($value_to_normalize)) {
18
+            return (string) array_shift($value_to_normalize);
19 19
         }
20 20
         // consider `"null"` values to be equivalent to null.
21
-        if($value_to_normalize === '' || $value_to_normalize === null) {
21
+        if ($value_to_normalize === '' || $value_to_normalize === null) {
22 22
 		    return null;
23 23
 		}
24
-        return (string)$value_to_normalize;
24
+        return (string) $value_to_normalize;
25 25
     }
26 26
 	/**
27 27
 	 * IF its a string in PHP, it will be a string in the HTML form. easy
28 28
 	 * @param string $normalized_value
29 29
 	 * @return string
30 30
 	 */
31
-	public function unnormalize( $normalized_value ){
31
+	public function unnormalize($normalized_value) {
32 32
 	    //account for default "select here" option values
33 33
 	    if ($normalized_value === null) {
34 34
 	        return '';
35 35
         }
36 36
         //double-check it's a string. It's possible this value was a question option that happened to be a numeric
37 37
         //string, in which case PHP has automatically converted it to an integer!
38
-		return (string)$normalized_value;
38
+		return (string) $normalized_value;
39 39
 	}
40 40
 }
41 41
 
Please login to merge, or discard this patch.
admin_pages/support/Support_Admin_Page.core.php 2 patches
Indentation   +234 added lines, -234 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 
@@ -19,263 +19,263 @@  discard block
 block discarded – undo
19 19
 
20 20
 
21 21
 
22
-    protected function _init_page_props()
23
-    {
24
-        $this->page_slug = EE_SUPPORT_PG_SLUG;
25
-        $this->page_label = esc_html__('Help & Support', 'event_espresso');
26
-        $this->_admin_base_url = EE_SUPPORT_ADMIN_URL;
27
-        $this->_admin_base_path = EE_SUPPORT_ADMIN;
28
-    }
22
+	protected function _init_page_props()
23
+	{
24
+		$this->page_slug = EE_SUPPORT_PG_SLUG;
25
+		$this->page_label = esc_html__('Help & Support', 'event_espresso');
26
+		$this->_admin_base_url = EE_SUPPORT_ADMIN_URL;
27
+		$this->_admin_base_path = EE_SUPPORT_ADMIN;
28
+	}
29 29
 
30 30
 
31 31
 
32
-    protected function _ajax_hooks()
33
-    {
34
-    }
32
+	protected function _ajax_hooks()
33
+	{
34
+	}
35 35
 
36 36
 
37 37
 
38
-    protected function _define_page_props()
39
-    {
40
-        $this->_labels = array();
41
-        $this->_admin_page_title = $this->page_label;
42
-    }
38
+	protected function _define_page_props()
39
+	{
40
+		$this->_labels = array();
41
+		$this->_admin_page_title = $this->page_label;
42
+	}
43 43
 
44 44
 
45 45
 
46
-    protected function _set_page_routes()
47
-    {
48
-        $this->_page_routes = array(
49
-            'default'    => array(
50
-                'func'       => '_contact_support',
51
-                'capability' => 'ee_read_ee',
52
-            ),
53
-            'developers' => array(
54
-                'func'       => '_developers',
55
-                'capability' => 'ee_read_ee',
56
-            ),
57
-            'shortcodes' => array(
58
-                'func'       => '_shortcodes',
59
-                'capability' => 'ee_read_ee',
60
-            ),
61
-        );
62
-    }
46
+	protected function _set_page_routes()
47
+	{
48
+		$this->_page_routes = array(
49
+			'default'    => array(
50
+				'func'       => '_contact_support',
51
+				'capability' => 'ee_read_ee',
52
+			),
53
+			'developers' => array(
54
+				'func'       => '_developers',
55
+				'capability' => 'ee_read_ee',
56
+			),
57
+			'shortcodes' => array(
58
+				'func'       => '_shortcodes',
59
+				'capability' => 'ee_read_ee',
60
+			),
61
+		);
62
+	}
63 63
 
64 64
 
65 65
 
66
-    protected function _set_page_config()
67
-    {
68
-        $this->_page_config = array(
69
-            'default'    => array(
70
-                'nav'           => array(
71
-                    'label' => esc_html__('Support', 'event_espresso'),
72
-                    'order' => 30,
73
-                ),
74
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_support_boxes')),
75
-                'require_nonce' => false,
76
-            ),
77
-            'developers' => array(
78
-                'nav'           => array(
79
-                    'label' => esc_html__('Developers', 'event_espresso'),
80
-                    'order' => 50,
81
-                ),
82
-                'metaboxes'     => $this->_default_espresso_metaboxes,
83
-                'require_nonce' => false,
84
-            ),
85
-            'shortcodes' => array(
86
-                'nav'           => array(
87
-                    'label' => esc_html__('Shortcodes', 'event_espresso'),
88
-                    'order' => 60,
89
-                ),
90
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_shortcodes_boxes')),
91
-                'require_nonce' => false,
92
-            ),
93
-        );
94
-    }
66
+	protected function _set_page_config()
67
+	{
68
+		$this->_page_config = array(
69
+			'default'    => array(
70
+				'nav'           => array(
71
+					'label' => esc_html__('Support', 'event_espresso'),
72
+					'order' => 30,
73
+				),
74
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_support_boxes')),
75
+				'require_nonce' => false,
76
+			),
77
+			'developers' => array(
78
+				'nav'           => array(
79
+					'label' => esc_html__('Developers', 'event_espresso'),
80
+					'order' => 50,
81
+				),
82
+				'metaboxes'     => $this->_default_espresso_metaboxes,
83
+				'require_nonce' => false,
84
+			),
85
+			'shortcodes' => array(
86
+				'nav'           => array(
87
+					'label' => esc_html__('Shortcodes', 'event_espresso'),
88
+					'order' => 60,
89
+				),
90
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_shortcodes_boxes')),
91
+				'require_nonce' => false,
92
+			),
93
+		);
94
+	}
95 95
 
96 96
 
97 97
 
98
-    //none of the below group are currently used for Support pages
99
-    protected function _add_screen_options()
100
-    {
101
-    }
102
-
98
+	//none of the below group are currently used for Support pages
99
+	protected function _add_screen_options()
100
+	{
101
+	}
102
+
103 103
 
104 104
 
105
-    protected function _add_feature_pointers()
106
-    {
107
-    }
105
+	protected function _add_feature_pointers()
106
+	{
107
+	}
108 108
 
109 109
 
110 110
 
111
-    public function admin_init()
112
-    {
113
-    }
111
+	public function admin_init()
112
+	{
113
+	}
114 114
 
115 115
 
116 116
 
117
-    public function admin_notices()
118
-    {
119
-    }
117
+	public function admin_notices()
118
+	{
119
+	}
120 120
 
121
-
122
-
123
-    public function admin_footer_scripts()
124
-    {
125
-    }
126
-
127
-
128
-
129
-    public function load_scripts_styles()
130
-    {
131
-    }
132
-
133
-
134
-
135
-    protected function _installation()
136
-    {
137
-        $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_installation.template.php';
138
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
139
-            $template_path,
140
-            '',
141
-            true
142
-        );
143
-        $this->display_admin_page_with_sidebar();
144
-    }
145
-
146
-
147
-
148
-    protected function _resources()
149
-    {
150
-        $this->display_admin_page_with_sidebar();
151
-    }
152
-
153
-
154
-
155
-    protected function _add_settings_metabox($box, $label, array $args)
156
-    {
157
-        add_meta_box(
158
-            "espresso_{$box}_settings",
159
-            $label,
160
-            function ($post, $metabox) {
161
-                echo EEH_Template::display_template(
162
-                    $metabox['args']['template_path'],
163
-                    $metabox['args']['template_args'],
164
-                    true
165
-                );
166
-            },
167
-            $this->_current_screen->id,
168
-            'normal',
169
-            'high',
170
-            apply_filters(
171
-                "FHEE__Support_Admin_Page___add_settings_metabox__{$box}_args_array",
172
-                $args
173
-            )
174
-        );
175
-    }
176
-
177
-
178
-
179
-    protected function _resources_boxes()
180
-    {
181
-        $boxes = apply_filters(
182
-            'FHEE__Support_Admin_Page___resources_boxes__boxes_array',
183
-            array(
184
-                'favorite_theme_developers' => esc_html__('Favorite Theme Developers', 'event_espresso'),
185
-                'highly_recommended_themes' => esc_html__('Highly Recommended Themes', 'event_espresso'),
186
-                'hire_developer'            => esc_html__('Hire a Developer', 'event_espresso'),
187
-                'partners'                  => esc_html__('Partners', 'event_espresso'),
188
-                'recommended_plugins'       => esc_html__('Recommended Plugins', 'event_espresso'),
189
-                'other_resources'           => esc_html__('Other Resources', 'event_espresso'),
190
-            )
191
-        );
192
-        foreach ($boxes as $box => $label) {
193
-            $this->_add_settings_metabox(
194
-                $box,
195
-                $label,
196
-                array(
197
-                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
198
-                    'template_args' => $this->_template_args,
199
-                )
200
-            );
201
-        }
202
-    }
203
-
204
-
205
-
206
-    protected function _shortcodes()
207
-    {
208
-        $this->display_admin_page_with_sidebar();
209
-    }
210
-
211
-
212
-
213
-    protected function _shortcodes_boxes()
214
-    {
215
-        $boxes = apply_filters(
216
-            'FHEE__Support_Admin_Page___shortcodes_boxes__boxes_array',
217
-            array(
218
-                'shortcodes_event_listings'  => esc_html__('Event Listings', 'event_espresso'),
219
-                'shortcodes_ticket_selector' => esc_html__('Event Ticket Selector', 'event_espresso'),
220
-                'shortcodes_category'        => esc_html__('Event Categories', 'event_espresso'),
221
-                'shortcodes_attendee'        => esc_html__('Event Attendees', 'event_espresso')
222
-                /*'shortcodes_single_events' => esc_html__('Single Events', 'event_espresso'),*/
223
-                /*'shortcodes_attendee_listings' => esc_html__('Attendee Listings', 'event_espresso'),*/
224
-            )
225
-        );
226
-        foreach ($boxes as $box => $label) {
227
-            $this->_add_settings_metabox(
228
-                $box,
229
-                $label,
230
-                array(
231
-                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
232
-                    'template_args' => $this->_template_args,
233
-                )
234
-            );
235
-        }
236
-    }
237
-
238
-
239
-
240
-    protected function _contact_support()
241
-    {
242
-        $this->display_admin_page_with_sidebar();
243
-    }
244
-
245
-
246
-
247
-    protected function _support_boxes()
248
-    {
249
-        $boxes = apply_filters(
250
-            'FHEE__Support_Admin_Page___support_boxes__boxes_array',
251
-            array(
252
-                'contact_support'       => esc_html__('Contact Support', 'event_espresso'),
253
-                'important_information' => esc_html__('Important Information', 'event_espresso'),
254
-            )
255
-        );
256
-        foreach ($boxes as $box => $label) {
257
-            $this->_add_settings_metabox(
258
-                $box,
259
-                $label,
260
-                array(
261
-                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
262
-                    'template_args' => $this->_template_args,
263
-                )
264
-            );
265
-        }
266
-    }
267
-
268
-
269
-
270
-    protected function _developers()
271
-    {
272
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
273
-            EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'developers_admin_details.template.php',
274
-            array(),
275
-            true
276
-        );
277
-        $this->display_admin_page_with_sidebar();
278
-    }
121
+
122
+
123
+	public function admin_footer_scripts()
124
+	{
125
+	}
126
+
127
+
128
+
129
+	public function load_scripts_styles()
130
+	{
131
+	}
132
+
133
+
134
+
135
+	protected function _installation()
136
+	{
137
+		$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_installation.template.php';
138
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
139
+			$template_path,
140
+			'',
141
+			true
142
+		);
143
+		$this->display_admin_page_with_sidebar();
144
+	}
145
+
146
+
147
+
148
+	protected function _resources()
149
+	{
150
+		$this->display_admin_page_with_sidebar();
151
+	}
152
+
153
+
154
+
155
+	protected function _add_settings_metabox($box, $label, array $args)
156
+	{
157
+		add_meta_box(
158
+			"espresso_{$box}_settings",
159
+			$label,
160
+			function ($post, $metabox) {
161
+				echo EEH_Template::display_template(
162
+					$metabox['args']['template_path'],
163
+					$metabox['args']['template_args'],
164
+					true
165
+				);
166
+			},
167
+			$this->_current_screen->id,
168
+			'normal',
169
+			'high',
170
+			apply_filters(
171
+				"FHEE__Support_Admin_Page___add_settings_metabox__{$box}_args_array",
172
+				$args
173
+			)
174
+		);
175
+	}
176
+
177
+
178
+
179
+	protected function _resources_boxes()
180
+	{
181
+		$boxes = apply_filters(
182
+			'FHEE__Support_Admin_Page___resources_boxes__boxes_array',
183
+			array(
184
+				'favorite_theme_developers' => esc_html__('Favorite Theme Developers', 'event_espresso'),
185
+				'highly_recommended_themes' => esc_html__('Highly Recommended Themes', 'event_espresso'),
186
+				'hire_developer'            => esc_html__('Hire a Developer', 'event_espresso'),
187
+				'partners'                  => esc_html__('Partners', 'event_espresso'),
188
+				'recommended_plugins'       => esc_html__('Recommended Plugins', 'event_espresso'),
189
+				'other_resources'           => esc_html__('Other Resources', 'event_espresso'),
190
+			)
191
+		);
192
+		foreach ($boxes as $box => $label) {
193
+			$this->_add_settings_metabox(
194
+				$box,
195
+				$label,
196
+				array(
197
+					'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
198
+					'template_args' => $this->_template_args,
199
+				)
200
+			);
201
+		}
202
+	}
203
+
204
+
205
+
206
+	protected function _shortcodes()
207
+	{
208
+		$this->display_admin_page_with_sidebar();
209
+	}
210
+
211
+
212
+
213
+	protected function _shortcodes_boxes()
214
+	{
215
+		$boxes = apply_filters(
216
+			'FHEE__Support_Admin_Page___shortcodes_boxes__boxes_array',
217
+			array(
218
+				'shortcodes_event_listings'  => esc_html__('Event Listings', 'event_espresso'),
219
+				'shortcodes_ticket_selector' => esc_html__('Event Ticket Selector', 'event_espresso'),
220
+				'shortcodes_category'        => esc_html__('Event Categories', 'event_espresso'),
221
+				'shortcodes_attendee'        => esc_html__('Event Attendees', 'event_espresso')
222
+				/*'shortcodes_single_events' => esc_html__('Single Events', 'event_espresso'),*/
223
+				/*'shortcodes_attendee_listings' => esc_html__('Attendee Listings', 'event_espresso'),*/
224
+			)
225
+		);
226
+		foreach ($boxes as $box => $label) {
227
+			$this->_add_settings_metabox(
228
+				$box,
229
+				$label,
230
+				array(
231
+					'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
232
+					'template_args' => $this->_template_args,
233
+				)
234
+			);
235
+		}
236
+	}
237
+
238
+
239
+
240
+	protected function _contact_support()
241
+	{
242
+		$this->display_admin_page_with_sidebar();
243
+	}
244
+
245
+
246
+
247
+	protected function _support_boxes()
248
+	{
249
+		$boxes = apply_filters(
250
+			'FHEE__Support_Admin_Page___support_boxes__boxes_array',
251
+			array(
252
+				'contact_support'       => esc_html__('Contact Support', 'event_espresso'),
253
+				'important_information' => esc_html__('Important Information', 'event_espresso'),
254
+			)
255
+		);
256
+		foreach ($boxes as $box => $label) {
257
+			$this->_add_settings_metabox(
258
+				$box,
259
+				$label,
260
+				array(
261
+					'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
262
+					'template_args' => $this->_template_args,
263
+				)
264
+			);
265
+		}
266
+	}
267
+
268
+
269
+
270
+	protected function _developers()
271
+	{
272
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
273
+			EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'developers_admin_details.template.php',
274
+			array(),
275
+			true
276
+		);
277
+		$this->display_admin_page_with_sidebar();
278
+	}
279 279
 
280 280
 
281 281
 
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined('EVENT_ESPRESSO_VERSION')) {
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3 3
     exit('NO direct script access allowed');
4 4
 }
5 5
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
     protected function _installation()
136 136
     {
137
-        $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_installation.template.php';
137
+        $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_installation.template.php';
138 138
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
139 139
             $template_path,
140 140
             '',
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
         add_meta_box(
158 158
             "espresso_{$box}_settings",
159 159
             $label,
160
-            function ($post, $metabox) {
160
+            function($post, $metabox) {
161 161
                 echo EEH_Template::display_template(
162 162
                     $metabox['args']['template_path'],
163 163
                     $metabox['args']['template_args'],
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
                 $box,
195 195
                 $label,
196 196
                 array(
197
-                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
197
+                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH."support_admin_details_{$box}.template.php",
198 198
                     'template_args' => $this->_template_args,
199 199
                 )
200 200
             );
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
                 $box,
229 229
                 $label,
230 230
                 array(
231
-                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
231
+                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH."support_admin_details_{$box}.template.php",
232 232
                     'template_args' => $this->_template_args,
233 233
                 )
234 234
             );
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
                 $box,
259 259
                 $label,
260 260
                 array(
261
-                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
261
+                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH."support_admin_details_{$box}.template.php",
262 262
                     'template_args' => $this->_template_args,
263 263
                 )
264 264
             );
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
     protected function _developers()
271 271
     {
272 272
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
273
-            EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'developers_admin_details.template.php',
273
+            EE_SUPPORT_ADMIN_TEMPLATE_PATH.'developers_admin_details.template.php',
274 274
             array(),
275 275
             true
276 276
         );
Please login to merge, or discard this patch.
form_sections/strategies/normalization/EE_Int_Normalization.strategy.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
 		}
21 21
 
22 22
 		if ( is_null( $value_to_normalize ) || $value_to_normalize === '' ) {
23
-		    return null;
24
-        }
23
+			return null;
24
+		}
25 25
 
26 26
 		if( ! is_string( $value_to_normalize )){
27 27
 			throw new EE_Validation_Error( sprintf( __( 'The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso' ), print_r( $value_to_normalize, TRUE), gettype( $value_to_normalize ) ) );
@@ -56,9 +56,9 @@  discard block
 block discarded – undo
56 56
 	 * @return string
57 57
 	 */
58 58
 	public function unnormalize( $normalized_value ) {
59
-	    if ($normalized_value === null || $normalized_value === '') {
60
-	        return '';
61
-        }elseif( empty( $normalized_value ) ){
59
+		if ($normalized_value === null || $normalized_value === '') {
60
+			return '';
61
+		}elseif( empty( $normalized_value ) ){
62 62
 			return '0';
63 63
 		}else{
64 64
 			return "$normalized_value";
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @subpackage
8 8
  * @author				Mike Nelson
9 9
  */
10
-class EE_Int_Normalization extends EE_Normalization_Strategy_Base{
10
+class EE_Int_Normalization extends EE_Normalization_Strategy_Base {
11 11
 
12 12
 	/**
13 13
 	 * @param string $value_to_normalize
@@ -15,38 +15,38 @@  discard block
 block discarded – undo
15 15
 	 * @throws \EE_Validation_Error
16 16
 	 */
17 17
 	public function normalize($value_to_normalize) {
18
-		if( is_int( $value_to_normalize ) ){
18
+		if (is_int($value_to_normalize)) {
19 19
 			return $value_to_normalize;
20 20
 		}
21 21
 
22
-		if ( is_null( $value_to_normalize ) || $value_to_normalize === '' ) {
22
+		if (is_null($value_to_normalize) || $value_to_normalize === '') {
23 23
 		    return null;
24 24
         }
25 25
 
26
-		if( ! is_string( $value_to_normalize )){
27
-			throw new EE_Validation_Error( sprintf( __( 'The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso' ), print_r( $value_to_normalize, TRUE), gettype( $value_to_normalize ) ) );
26
+		if ( ! is_string($value_to_normalize)) {
27
+			throw new EE_Validation_Error(sprintf(__('The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso'), print_r($value_to_normalize, TRUE), gettype($value_to_normalize)));
28 28
 		}
29 29
 		$thousands_separator = EE_Config::instance()->currency->thsnds;
30
-		$value_to_normalize = str_replace( $thousands_separator, "", $value_to_normalize );
31
-		$value_to_normalize = str_replace( array(" ","\t"), '', $value_to_normalize );
32
-		if ( preg_match( '/^\d+$/', $value_to_normalize )) {
33
-			return intval( $value_to_normalize );
30
+		$value_to_normalize = str_replace($thousands_separator, "", $value_to_normalize);
31
+		$value_to_normalize = str_replace(array(" ", "\t"), '', $value_to_normalize);
32
+		if (preg_match('/^\d+$/', $value_to_normalize)) {
33
+			return intval($value_to_normalize);
34 34
 		} else {
35 35
 			//find if this input has a int validation strategy
36 36
 			//in which case, use its message
37 37
 			$validation_error_message = NULL;
38
-			foreach( $this->_input->get_validation_strategies() as $validation_strategy ){
39
-				if( $validation_strategy instanceof EE_Int_Validation_Strategy ){
38
+			foreach ($this->_input->get_validation_strategies() as $validation_strategy) {
39
+				if ($validation_strategy instanceof EE_Int_Validation_Strategy) {
40 40
 					$validation_error_message = $validation_strategy->get_validation_error_message();
41 41
 				}
42 42
 			}
43 43
 			//this really shouldn't ever happen because fields with a int normalization strategy
44 44
 			//should also have a int validation strategy, but in case it doesnt use the default
45
-			if( ! $validation_error_message ){
45
+			if ( ! $validation_error_message) {
46 46
 				$default_validation_strategy = new EE_Int_Validation_Strategy();
47 47
 				$validation_error_message = $default_validation_strategy->get_validation_error_message();
48 48
 			}
49
-			throw new EE_Validation_Error( $validation_error_message, 'numeric_only' );
49
+			throw new EE_Validation_Error($validation_error_message, 'numeric_only');
50 50
 		}
51 51
 	}
52 52
 
@@ -55,12 +55,12 @@  discard block
 block discarded – undo
55 55
 	 * @param int $normalized_value
56 56
 	 * @return string
57 57
 	 */
58
-	public function unnormalize( $normalized_value ) {
58
+	public function unnormalize($normalized_value) {
59 59
 	    if ($normalized_value === null || $normalized_value === '') {
60 60
 	        return '';
61
-        }elseif( empty( $normalized_value ) ){
61
+        }elseif (empty($normalized_value)) {
62 62
 			return '0';
63
-		}else{
63
+		} else {
64 64
 			return "$normalized_value";
65 65
 		}
66 66
 	}
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,9 +58,9 @@
 block discarded – undo
58 58
 	public function unnormalize( $normalized_value ) {
59 59
 	    if ($normalized_value === null || $normalized_value === '') {
60 60
 	        return '';
61
-        }elseif( empty( $normalized_value ) ){
61
+        } elseif( empty( $normalized_value ) ){
62 62
 			return '0';
63
-		}else{
63
+		} else{
64 64
 			return "$normalized_value";
65 65
 		}
66 66
 	}
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('ABSPATH')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /*
5 5
   Plugin Name:		Event Espresso
@@ -40,243 +40,243 @@  discard block
 block discarded – undo
40 40
  * @since            4.0
41 41
  */
42 42
 if (function_exists('espresso_version')) {
43
-    /**
44
-     *    espresso_duplicate_plugin_error
45
-     *    displays if more than one version of EE is activated at the same time
46
-     */
47
-    function espresso_duplicate_plugin_error()
48
-    {
49
-        ?>
43
+	/**
44
+	 *    espresso_duplicate_plugin_error
45
+	 *    displays if more than one version of EE is activated at the same time
46
+	 */
47
+	function espresso_duplicate_plugin_error()
48
+	{
49
+		?>
50 50
         <div class="error">
51 51
             <p>
52 52
                 <?php echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                ); ?>
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+				); ?>
56 56
             </p>
57 57
         </div>
58 58
         <?php
59
-        espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-    }
59
+		espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+	}
61 61
 
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
-    if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
+	if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                            esc_html__(
79
-                                    'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                                    'event_espresso'
81
-                            ),
82
-                            EE_MIN_PHP_VER_REQUIRED,
83
-                            PHP_VERSION,
84
-                            '<br/>',
85
-                            '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+							esc_html__(
79
+									'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+									'event_espresso'
81
+							),
82
+							EE_MIN_PHP_VER_REQUIRED,
83
+							PHP_VERSION,
84
+							'<br/>',
85
+							'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        /**
97
-         * espresso_version
98
-         * Returns the plugin version
99
-         *
100
-         * @return string
101
-         */
102
-        function espresso_version()
103
-        {
104
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.37.rc.007');
105
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		/**
97
+		 * espresso_version
98
+		 * Returns the plugin version
99
+		 *
100
+		 * @return string
101
+		 */
102
+		function espresso_version()
103
+		{
104
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.37.rc.007');
105
+		}
106 106
 
107
-        // define versions
108
-        define('EVENT_ESPRESSO_VERSION', espresso_version());
109
-        define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
-        define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
-        define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
-        //used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
-        if ( ! defined('DS')) {
115
-            define('DS', '/');
116
-        }
117
-        if ( ! defined('PS')) {
118
-            define('PS', PATH_SEPARATOR);
119
-        }
120
-        if ( ! defined('SP')) {
121
-            define('SP', ' ');
122
-        }
123
-        if ( ! defined('EENL')) {
124
-            define('EENL', "\n");
125
-        }
126
-        define('EE_SUPPORT_EMAIL', '[email protected]');
127
-        // define the plugin directory and URL
128
-        define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
-        define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
-        define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
-        // main root folder paths
132
-        define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
-        define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
-        define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
-        define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
-        define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
-        define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
-        define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
-        define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
-        // core system paths
141
-        define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
-        define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
-        define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
-        define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
-        define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
-        define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
-        define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
-        define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
-        define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
-        define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
-        define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
-        define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
-        // gateways
154
-        define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
-        define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
-        // asset URL paths
157
-        define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
-        define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
-        define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
-        define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
-        define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
-        define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
-        // define upload paths
164
-        $uploads = wp_upload_dir();
165
-        // define the uploads directory and URL
166
-        define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
-        define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
-        // define the templates directory and URL
169
-        define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
-        define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
-        // define the gateway directory and URL
172
-        define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
-        define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
-        // languages folder/path
175
-        define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
-        define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
-        //check for dompdf fonts in uploads
178
-        if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
-            define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
-        }
181
-        //ajax constants
182
-        define(
183
-                'EE_FRONT_AJAX',
184
-                isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
-        );
186
-        define(
187
-                'EE_ADMIN_AJAX',
188
-                isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
-        );
190
-        //just a handy constant occasionally needed for finding values representing infinity in the DB
191
-        //you're better to use this than its straight value (currently -1) in case you ever
192
-        //want to change its default value! or find when -1 means infinity
193
-        define('EE_INF_IN_DB', -1);
194
-        define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
-        define('EE_DEBUG', false);
196
-        // for older WP versions
197
-        if ( ! defined('MONTH_IN_SECONDS')) {
198
-            define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
-        }
200
-        /**
201
-         *    espresso_plugin_activation
202
-         *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
-         */
204
-        function espresso_plugin_activation()
205
-        {
206
-            update_option('ee_espresso_activation', true);
207
-        }
107
+		// define versions
108
+		define('EVENT_ESPRESSO_VERSION', espresso_version());
109
+		define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
+		define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
+		define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
+		//used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
+		if ( ! defined('DS')) {
115
+			define('DS', '/');
116
+		}
117
+		if ( ! defined('PS')) {
118
+			define('PS', PATH_SEPARATOR);
119
+		}
120
+		if ( ! defined('SP')) {
121
+			define('SP', ' ');
122
+		}
123
+		if ( ! defined('EENL')) {
124
+			define('EENL', "\n");
125
+		}
126
+		define('EE_SUPPORT_EMAIL', '[email protected]');
127
+		// define the plugin directory and URL
128
+		define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
+		define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
+		define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
+		// main root folder paths
132
+		define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
+		define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
+		define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
+		define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
+		define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
+		define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
+		define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
+		define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
+		// core system paths
141
+		define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
+		define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
+		define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
+		define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
+		define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
+		define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
+		define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
+		define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
+		define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
+		define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
+		define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
+		define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
+		// gateways
154
+		define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
+		define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
+		// asset URL paths
157
+		define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
+		define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
+		define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
+		define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
+		define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
+		define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
+		// define upload paths
164
+		$uploads = wp_upload_dir();
165
+		// define the uploads directory and URL
166
+		define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
+		define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
+		// define the templates directory and URL
169
+		define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
+		define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
+		// define the gateway directory and URL
172
+		define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
+		define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
+		// languages folder/path
175
+		define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
+		define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
+		//check for dompdf fonts in uploads
178
+		if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
+			define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
+		}
181
+		//ajax constants
182
+		define(
183
+				'EE_FRONT_AJAX',
184
+				isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
+		);
186
+		define(
187
+				'EE_ADMIN_AJAX',
188
+				isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
+		);
190
+		//just a handy constant occasionally needed for finding values representing infinity in the DB
191
+		//you're better to use this than its straight value (currently -1) in case you ever
192
+		//want to change its default value! or find when -1 means infinity
193
+		define('EE_INF_IN_DB', -1);
194
+		define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
+		define('EE_DEBUG', false);
196
+		// for older WP versions
197
+		if ( ! defined('MONTH_IN_SECONDS')) {
198
+			define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
+		}
200
+		/**
201
+		 *    espresso_plugin_activation
202
+		 *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
+		 */
204
+		function espresso_plugin_activation()
205
+		{
206
+			update_option('ee_espresso_activation', true);
207
+		}
208 208
 
209
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
-        /**
211
-         *    espresso_load_error_handling
212
-         *    this function loads EE's class for handling exceptions and errors
213
-         */
214
-        function espresso_load_error_handling()
215
-        {
216
-            // load debugging tools
217
-            if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
-                require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
-                EEH_Debug_Tools::instance();
220
-            }
221
-            // load error handling
222
-            if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
-                require_once(EE_CORE . 'EE_Error.core.php');
224
-            } else {
225
-                wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
-            }
227
-        }
209
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
+		/**
211
+		 *    espresso_load_error_handling
212
+		 *    this function loads EE's class for handling exceptions and errors
213
+		 */
214
+		function espresso_load_error_handling()
215
+		{
216
+			// load debugging tools
217
+			if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
+				require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
+				EEH_Debug_Tools::instance();
220
+			}
221
+			// load error handling
222
+			if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
+				require_once(EE_CORE . 'EE_Error.core.php');
224
+			} else {
225
+				wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
+			}
227
+		}
228 228
 
229
-        /**
230
-         *    espresso_load_required
231
-         *    given a class name and path, this function will load that file or throw an exception
232
-         *
233
-         * @param    string $classname
234
-         * @param    string $full_path_to_file
235
-         * @throws    EE_Error
236
-         */
237
-        function espresso_load_required($classname, $full_path_to_file)
238
-        {
239
-            static $error_handling_loaded = false;
240
-            if ( ! $error_handling_loaded) {
241
-                espresso_load_error_handling();
242
-                $error_handling_loaded = true;
243
-            }
244
-            if (is_readable($full_path_to_file)) {
245
-                require_once($full_path_to_file);
246
-            } else {
247
-                throw new EE_Error (
248
-                        sprintf(
249
-                                esc_html__(
250
-                                        'The %s class file could not be located or is not readable due to file permissions.',
251
-                                        'event_espresso'
252
-                                ),
253
-                                $classname
254
-                        )
255
-                );
256
-            }
257
-        }
229
+		/**
230
+		 *    espresso_load_required
231
+		 *    given a class name and path, this function will load that file or throw an exception
232
+		 *
233
+		 * @param    string $classname
234
+		 * @param    string $full_path_to_file
235
+		 * @throws    EE_Error
236
+		 */
237
+		function espresso_load_required($classname, $full_path_to_file)
238
+		{
239
+			static $error_handling_loaded = false;
240
+			if ( ! $error_handling_loaded) {
241
+				espresso_load_error_handling();
242
+				$error_handling_loaded = true;
243
+			}
244
+			if (is_readable($full_path_to_file)) {
245
+				require_once($full_path_to_file);
246
+			} else {
247
+				throw new EE_Error (
248
+						sprintf(
249
+								esc_html__(
250
+										'The %s class file could not be located or is not readable due to file permissions.',
251
+										'event_espresso'
252
+								),
253
+								$classname
254
+						)
255
+				);
256
+			}
257
+		}
258 258
 
259
-        espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
-        espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
-        espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
-        new EE_Bootstrap();
263
-    }
259
+		espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
+		espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
+		espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
+		new EE_Bootstrap();
263
+	}
264 264
 }
265 265
 if ( ! function_exists('espresso_deactivate_plugin')) {
266
-    /**
267
-     *    deactivate_plugin
268
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
-     *
270
-     * @access public
271
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
-     * @return    void
273
-     */
274
-    function espresso_deactivate_plugin($plugin_basename = '')
275
-    {
276
-        if ( ! function_exists('deactivate_plugins')) {
277
-            require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
-        }
279
-        unset($_GET['activate'], $_REQUEST['activate']);
280
-        deactivate_plugins($plugin_basename);
281
-    }
266
+	/**
267
+	 *    deactivate_plugin
268
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
+	 *
270
+	 * @access public
271
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
+	 * @return    void
273
+	 */
274
+	function espresso_deactivate_plugin($plugin_basename = '')
275
+	{
276
+		if ( ! function_exists('deactivate_plugins')) {
277
+			require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
+		}
279
+		unset($_GET['activate'], $_REQUEST['activate']);
280
+		deactivate_plugins($plugin_basename);
281
+	}
282 282
 }
283 283
\ No newline at end of file
Please login to merge, or discard this patch.