@@ -13,20 +13,20 @@ |
||
13 | 13 | class EE_Select_Input extends EE_Form_Input_With_Options_Base |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * @param array $answer_options |
|
18 | - * @param array $input_settings |
|
19 | - */ |
|
20 | - public function __construct($answer_options, $input_settings = array()) |
|
21 | - { |
|
22 | - $this->_set_display_strategy(new EE_Select_Display_Strategy($answer_options)); |
|
23 | - $this->_add_validation_strategy( |
|
24 | - new EE_Enum_Validation_Strategy( |
|
25 | - isset($input_settings['validation_error_message']) |
|
26 | - ? $input_settings['validation_error_message'] |
|
27 | - : null |
|
28 | - ) |
|
29 | - ); |
|
30 | - parent::__construct($answer_options, $input_settings); |
|
31 | - } |
|
16 | + /** |
|
17 | + * @param array $answer_options |
|
18 | + * @param array $input_settings |
|
19 | + */ |
|
20 | + public function __construct($answer_options, $input_settings = array()) |
|
21 | + { |
|
22 | + $this->_set_display_strategy(new EE_Select_Display_Strategy($answer_options)); |
|
23 | + $this->_add_validation_strategy( |
|
24 | + new EE_Enum_Validation_Strategy( |
|
25 | + isset($input_settings['validation_error_message']) |
|
26 | + ? $input_settings['validation_error_message'] |
|
27 | + : null |
|
28 | + ) |
|
29 | + ); |
|
30 | + parent::__construct($answer_options, $input_settings); |
|
31 | + } |
|
32 | 32 | } |
@@ -9,40 +9,40 @@ |
||
9 | 9 | abstract class EE_Form_Input_Strategy_Base |
10 | 10 | { |
11 | 11 | |
12 | - /** |
|
13 | - * Form Input to display |
|
14 | - * |
|
15 | - * @var EE_Form_Input_Base |
|
16 | - */ |
|
17 | - protected $_input; |
|
12 | + /** |
|
13 | + * Form Input to display |
|
14 | + * |
|
15 | + * @var EE_Form_Input_Base |
|
16 | + */ |
|
17 | + protected $_input; |
|
18 | 18 | |
19 | 19 | |
20 | 20 | |
21 | - public function __construct() |
|
22 | - { |
|
23 | - } |
|
21 | + public function __construct() |
|
22 | + { |
|
23 | + } |
|
24 | 24 | |
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * The form input on which this strategy is to perform |
|
29 | - * |
|
30 | - * @param EE_Form_Input_Base $form_input |
|
31 | - */ |
|
32 | - public function _construct_finalize(EE_Form_Input_Base $form_input) |
|
33 | - { |
|
34 | - $this->_input = $form_input; |
|
35 | - } |
|
27 | + /** |
|
28 | + * The form input on which this strategy is to perform |
|
29 | + * |
|
30 | + * @param EE_Form_Input_Base $form_input |
|
31 | + */ |
|
32 | + public function _construct_finalize(EE_Form_Input_Base $form_input) |
|
33 | + { |
|
34 | + $this->_input = $form_input; |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * Gets this strategy's input |
|
41 | - * |
|
42 | - * @return EE_Form_Input_Base |
|
43 | - */ |
|
44 | - public function get_input() |
|
45 | - { |
|
46 | - return $this->_input; |
|
47 | - } |
|
39 | + /** |
|
40 | + * Gets this strategy's input |
|
41 | + * |
|
42 | + * @return EE_Form_Input_Base |
|
43 | + */ |
|
44 | + public function get_input() |
|
45 | + { |
|
46 | + return $this->_input; |
|
47 | + } |
|
48 | 48 | } |
@@ -12,29 +12,29 @@ |
||
12 | 12 | class EE_Submit_Input_Display_Strategy extends EE_Display_Strategy_Base |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * @return string of html to display the input |
|
17 | - */ |
|
18 | - public function display() |
|
19 | - { |
|
20 | - $default_value = $this->_input->get_default(); |
|
21 | - if ($this->_input->get_normalization_strategy() instanceof EE_Normalization_Strategy_Base) { |
|
22 | - $default_value = $this->_input->get_normalization_strategy()->unnormalize($default_value); |
|
23 | - } |
|
24 | - $html = $this->_opening_tag('input'); |
|
25 | - $html .= $this->_attributes_string( |
|
26 | - array_merge( |
|
27 | - $this->_standard_attributes_array(), |
|
28 | - array( |
|
29 | - 'type' => 'submit', |
|
30 | - 'value' => $default_value, |
|
31 | - // overwrite the standard id with the backwards compatible one |
|
32 | - 'id' => $this->_input->html_id() . '-submit', |
|
33 | - 'class' => $this->_input->html_class() . ' ' . $this->_input->button_css_attributes() |
|
34 | - ) |
|
35 | - ) |
|
36 | - ); |
|
37 | - $html .= $this->_close_tag(); |
|
38 | - return $html; |
|
39 | - } |
|
15 | + /** |
|
16 | + * @return string of html to display the input |
|
17 | + */ |
|
18 | + public function display() |
|
19 | + { |
|
20 | + $default_value = $this->_input->get_default(); |
|
21 | + if ($this->_input->get_normalization_strategy() instanceof EE_Normalization_Strategy_Base) { |
|
22 | + $default_value = $this->_input->get_normalization_strategy()->unnormalize($default_value); |
|
23 | + } |
|
24 | + $html = $this->_opening_tag('input'); |
|
25 | + $html .= $this->_attributes_string( |
|
26 | + array_merge( |
|
27 | + $this->_standard_attributes_array(), |
|
28 | + array( |
|
29 | + 'type' => 'submit', |
|
30 | + 'value' => $default_value, |
|
31 | + // overwrite the standard id with the backwards compatible one |
|
32 | + 'id' => $this->_input->html_id() . '-submit', |
|
33 | + 'class' => $this->_input->html_class() . ' ' . $this->_input->button_css_attributes() |
|
34 | + ) |
|
35 | + ) |
|
36 | + ); |
|
37 | + $html .= $this->_close_tag(); |
|
38 | + return $html; |
|
39 | + } |
|
40 | 40 | } |
@@ -29,8 +29,8 @@ |
||
29 | 29 | 'type' => 'submit', |
30 | 30 | 'value' => $default_value, |
31 | 31 | // overwrite the standard id with the backwards compatible one |
32 | - 'id' => $this->_input->html_id() . '-submit', |
|
33 | - 'class' => $this->_input->html_class() . ' ' . $this->_input->button_css_attributes() |
|
32 | + 'id' => $this->_input->html_id().'-submit', |
|
33 | + 'class' => $this->_input->html_class().' '.$this->_input->button_css_attributes() |
|
34 | 34 | ) |
35 | 35 | ) |
36 | 36 | ); |
@@ -11,13 +11,13 @@ |
||
11 | 11 | */ |
12 | 12 | class EE_Hidden_Display_Strategy extends EE_Display_Strategy_Base |
13 | 13 | { |
14 | - /** |
|
15 | - * |
|
16 | - * @return string of html to display the HIDDEN field |
|
17 | - */ |
|
18 | - public function display() |
|
19 | - { |
|
20 | - $input = $this->_input; |
|
21 | - return "<input type='hidden' id='{$input->html_id()}' name='{$input->html_name()}' class='{$input->html_class()}' style='{$input->html_style()}' value='{$input->raw_value_in_form()}' {$input->other_html_attributes()}/>"; |
|
22 | - } |
|
14 | + /** |
|
15 | + * |
|
16 | + * @return string of html to display the HIDDEN field |
|
17 | + */ |
|
18 | + public function display() |
|
19 | + { |
|
20 | + $input = $this->_input; |
|
21 | + return "<input type='hidden' id='{$input->html_id()}' name='{$input->html_name()}' class='{$input->html_class()}' style='{$input->html_style()}' value='{$input->raw_value_in_form()}' {$input->other_html_attributes()}/>"; |
|
22 | + } |
|
23 | 23 | } |
@@ -12,54 +12,54 @@ |
||
12 | 12 | class EE_Select_Multiple_Display_Strategy extends EE_Select_Display_Strategy |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * |
|
17 | - * @throws EE_Error |
|
18 | - * @return string of html to display the field |
|
19 | - */ |
|
20 | - public function display() |
|
21 | - { |
|
15 | + /** |
|
16 | + * |
|
17 | + * @throws EE_Error |
|
18 | + * @return string of html to display the field |
|
19 | + */ |
|
20 | + public function display() |
|
21 | + { |
|
22 | 22 | |
23 | - if (! $this->_input instanceof EE_Form_Input_With_Options_Base) { |
|
24 | - throw new EE_Error(sprintf(__('Cannot use Select Multiple Display Strategy with an input that doesn\'t have options', "event_espresso"))); |
|
25 | - } |
|
23 | + if (! $this->_input instanceof EE_Form_Input_With_Options_Base) { |
|
24 | + throw new EE_Error(sprintf(__('Cannot use Select Multiple Display Strategy with an input that doesn\'t have options', "event_espresso"))); |
|
25 | + } |
|
26 | 26 | |
27 | - $html = EEH_HTML::nl(0, 'select'); |
|
28 | - $html .= '<select multiple'; |
|
29 | - $html .= ' id="' . $this->_input->html_id() . '"'; |
|
30 | - $html .= ' name="' . $this->_input->html_name() . '[]"'; |
|
31 | - $class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class(); |
|
32 | - $html .= ' class="' . $class . '"'; |
|
33 | - // add html5 required |
|
34 | - $html .= $this->_input->required() ? ' required' : ''; |
|
35 | - $html .= ' style="' . $this->_input->html_style() . '"'; |
|
36 | - $html .= ' ' . $this->_input->other_html_attributes(); |
|
37 | - $html .= '>'; |
|
27 | + $html = EEH_HTML::nl(0, 'select'); |
|
28 | + $html .= '<select multiple'; |
|
29 | + $html .= ' id="' . $this->_input->html_id() . '"'; |
|
30 | + $html .= ' name="' . $this->_input->html_name() . '[]"'; |
|
31 | + $class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class(); |
|
32 | + $html .= ' class="' . $class . '"'; |
|
33 | + // add html5 required |
|
34 | + $html .= $this->_input->required() ? ' required' : ''; |
|
35 | + $html .= ' style="' . $this->_input->html_style() . '"'; |
|
36 | + $html .= ' ' . $this->_input->other_html_attributes(); |
|
37 | + $html .= '>'; |
|
38 | 38 | |
39 | - EEH_HTML::indent(1, 'select'); |
|
40 | - if (EEH_Array::is_multi_dimensional_array($this->_input->options())) { |
|
41 | - throw new EE_Error(sprintf(__("Select multiple display strategy does not allow for nested arrays of options.", "event_espresso"))); |
|
42 | - } else { |
|
43 | - $html.=$this->_display_options($this->_input->options()); |
|
44 | - } |
|
39 | + EEH_HTML::indent(1, 'select'); |
|
40 | + if (EEH_Array::is_multi_dimensional_array($this->_input->options())) { |
|
41 | + throw new EE_Error(sprintf(__("Select multiple display strategy does not allow for nested arrays of options.", "event_espresso"))); |
|
42 | + } else { |
|
43 | + $html.=$this->_display_options($this->_input->options()); |
|
44 | + } |
|
45 | 45 | |
46 | - $html.= EEH_HTML::nl(-1, 'select') . "</select>"; |
|
47 | - return $html; |
|
48 | - } |
|
46 | + $html.= EEH_HTML::nl(-1, 'select') . "</select>"; |
|
47 | + return $html; |
|
48 | + } |
|
49 | 49 | |
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * Checks if that $value is one of the selected ones |
|
54 | - * @param string|int $value unnormalized value option (string) |
|
55 | - * @return boolean |
|
56 | - */ |
|
57 | - protected function _check_if_option_selected($value) |
|
58 | - { |
|
59 | - $selected_options = $this->_input->raw_value(); |
|
60 | - if (empty($selected_options)) { |
|
61 | - return false; |
|
62 | - } |
|
63 | - return in_array($value, $selected_options) ? true : false; |
|
64 | - } |
|
52 | + /** |
|
53 | + * Checks if that $value is one of the selected ones |
|
54 | + * @param string|int $value unnormalized value option (string) |
|
55 | + * @return boolean |
|
56 | + */ |
|
57 | + protected function _check_if_option_selected($value) |
|
58 | + { |
|
59 | + $selected_options = $this->_input->raw_value(); |
|
60 | + if (empty($selected_options)) { |
|
61 | + return false; |
|
62 | + } |
|
63 | + return in_array($value, $selected_options) ? true : false; |
|
64 | + } |
|
65 | 65 | } |
@@ -20,30 +20,30 @@ |
||
20 | 20 | public function display() |
21 | 21 | { |
22 | 22 | |
23 | - if (! $this->_input instanceof EE_Form_Input_With_Options_Base) { |
|
23 | + if ( ! $this->_input instanceof EE_Form_Input_With_Options_Base) { |
|
24 | 24 | throw new EE_Error(sprintf(__('Cannot use Select Multiple Display Strategy with an input that doesn\'t have options', "event_espresso"))); |
25 | 25 | } |
26 | 26 | |
27 | 27 | $html = EEH_HTML::nl(0, 'select'); |
28 | 28 | $html .= '<select multiple'; |
29 | - $html .= ' id="' . $this->_input->html_id() . '"'; |
|
30 | - $html .= ' name="' . $this->_input->html_name() . '[]"'; |
|
31 | - $class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class(); |
|
32 | - $html .= ' class="' . $class . '"'; |
|
29 | + $html .= ' id="'.$this->_input->html_id().'"'; |
|
30 | + $html .= ' name="'.$this->_input->html_name().'[]"'; |
|
31 | + $class = $this->_input->required() ? $this->_input->required_css_class().' '.$this->_input->html_class() : $this->_input->html_class(); |
|
32 | + $html .= ' class="'.$class.'"'; |
|
33 | 33 | // add html5 required |
34 | 34 | $html .= $this->_input->required() ? ' required' : ''; |
35 | - $html .= ' style="' . $this->_input->html_style() . '"'; |
|
36 | - $html .= ' ' . $this->_input->other_html_attributes(); |
|
35 | + $html .= ' style="'.$this->_input->html_style().'"'; |
|
36 | + $html .= ' '.$this->_input->other_html_attributes(); |
|
37 | 37 | $html .= '>'; |
38 | 38 | |
39 | 39 | EEH_HTML::indent(1, 'select'); |
40 | 40 | if (EEH_Array::is_multi_dimensional_array($this->_input->options())) { |
41 | 41 | throw new EE_Error(sprintf(__("Select multiple display strategy does not allow for nested arrays of options.", "event_espresso"))); |
42 | 42 | } else { |
43 | - $html.=$this->_display_options($this->_input->options()); |
|
43 | + $html .= $this->_display_options($this->_input->options()); |
|
44 | 44 | } |
45 | 45 | |
46 | - $html.= EEH_HTML::nl(-1, 'select') . "</select>"; |
|
46 | + $html .= EEH_HTML::nl(-1, 'select')."</select>"; |
|
47 | 47 | return $html; |
48 | 48 | } |
49 | 49 |
@@ -13,58 +13,58 @@ |
||
13 | 13 | */ |
14 | 14 | class EE_Text_Input_Display_Strategy extends EE_Display_Strategy_Base |
15 | 15 | { |
16 | - /** |
|
17 | - * The html "type" attribute value. default is "text" |
|
18 | - * @var string |
|
19 | - */ |
|
20 | - protected $_type; |
|
16 | + /** |
|
17 | + * The html "type" attribute value. default is "text" |
|
18 | + * @var string |
|
19 | + */ |
|
20 | + protected $_type; |
|
21 | 21 | |
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * @param string $type |
|
26 | - */ |
|
27 | - public function __construct($type = 'text') |
|
28 | - { |
|
29 | - $this->_type = $type; |
|
30 | - parent::__construct(); |
|
31 | - } |
|
24 | + /** |
|
25 | + * @param string $type |
|
26 | + */ |
|
27 | + public function __construct($type = 'text') |
|
28 | + { |
|
29 | + $this->_type = $type; |
|
30 | + parent::__construct(); |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * Gets the html "type" attribute's value |
|
37 | - * @return string |
|
38 | - */ |
|
39 | - public function get_type() |
|
40 | - { |
|
41 | - if ($this->_type === 'email' |
|
42 | - && ! apply_filters('FHEE__EE_Text_Input_Display_Strategy__use_html5_email', false) |
|
43 | - ) { |
|
44 | - return 'text'; |
|
45 | - } |
|
46 | - return $this->_type; |
|
47 | - } |
|
35 | + /** |
|
36 | + * Gets the html "type" attribute's value |
|
37 | + * @return string |
|
38 | + */ |
|
39 | + public function get_type() |
|
40 | + { |
|
41 | + if ($this->_type === 'email' |
|
42 | + && ! apply_filters('FHEE__EE_Text_Input_Display_Strategy__use_html5_email', false) |
|
43 | + ) { |
|
44 | + return 'text'; |
|
45 | + } |
|
46 | + return $this->_type; |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | 50 | |
51 | - /** |
|
52 | - * |
|
53 | - * @return string of html to display the field |
|
54 | - */ |
|
55 | - public function display() |
|
56 | - { |
|
57 | - $input = '<input type="'. $this->get_type() .'"'; |
|
58 | - $input .= ' name="' . $this->_input->html_name() . '"'; |
|
59 | - $input .= ' id="' . $this->_input->html_id() . '"'; |
|
60 | - $class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class(); |
|
61 | - $input .= ' class="' . $class . '"'; |
|
62 | - // add html5 required |
|
63 | - $input .= $this->_input->required() ? ' required' : ''; |
|
64 | - $input .= ' value="' . $this->_input->raw_value_in_form() . '"'; |
|
65 | - $input .= ' style="' . $this->_input->html_style() . '"'; |
|
66 | - $input .= $this->_input->other_html_attributes(); |
|
67 | - $input .= '/>'; |
|
68 | - return $input; |
|
69 | - } |
|
51 | + /** |
|
52 | + * |
|
53 | + * @return string of html to display the field |
|
54 | + */ |
|
55 | + public function display() |
|
56 | + { |
|
57 | + $input = '<input type="'. $this->get_type() .'"'; |
|
58 | + $input .= ' name="' . $this->_input->html_name() . '"'; |
|
59 | + $input .= ' id="' . $this->_input->html_id() . '"'; |
|
60 | + $class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class(); |
|
61 | + $input .= ' class="' . $class . '"'; |
|
62 | + // add html5 required |
|
63 | + $input .= $this->_input->required() ? ' required' : ''; |
|
64 | + $input .= ' value="' . $this->_input->raw_value_in_form() . '"'; |
|
65 | + $input .= ' style="' . $this->_input->html_style() . '"'; |
|
66 | + $input .= $this->_input->other_html_attributes(); |
|
67 | + $input .= '/>'; |
|
68 | + return $input; |
|
69 | + } |
|
70 | 70 | } |
@@ -54,15 +54,15 @@ |
||
54 | 54 | */ |
55 | 55 | public function display() |
56 | 56 | { |
57 | - $input = '<input type="'. $this->get_type() .'"'; |
|
58 | - $input .= ' name="' . $this->_input->html_name() . '"'; |
|
59 | - $input .= ' id="' . $this->_input->html_id() . '"'; |
|
60 | - $class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class(); |
|
61 | - $input .= ' class="' . $class . '"'; |
|
57 | + $input = '<input type="'.$this->get_type().'"'; |
|
58 | + $input .= ' name="'.$this->_input->html_name().'"'; |
|
59 | + $input .= ' id="'.$this->_input->html_id().'"'; |
|
60 | + $class = $this->_input->required() ? $this->_input->required_css_class().' '.$this->_input->html_class() : $this->_input->html_class(); |
|
61 | + $input .= ' class="'.$class.'"'; |
|
62 | 62 | // add html5 required |
63 | 63 | $input .= $this->_input->required() ? ' required' : ''; |
64 | - $input .= ' value="' . $this->_input->raw_value_in_form() . '"'; |
|
65 | - $input .= ' style="' . $this->_input->html_style() . '"'; |
|
64 | + $input .= ' value="'.$this->_input->raw_value_in_form().'"'; |
|
65 | + $input .= ' style="'.$this->_input->html_style().'"'; |
|
66 | 66 | $input .= $this->_input->other_html_attributes(); |
67 | 67 | $input .= '/>'; |
68 | 68 | return $input; |
@@ -12,158 +12,158 @@ |
||
12 | 12 | { |
13 | 13 | |
14 | 14 | |
15 | - /** |
|
16 | - * enqueues css and js, so that this can be called statically |
|
17 | - */ |
|
18 | - public static function enqueue_styles_and_scripts() |
|
19 | - { |
|
20 | - wp_register_style( |
|
21 | - 'checkbox_dropdown_selector', |
|
22 | - EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css', |
|
23 | - array('espresso_default'), |
|
24 | - EVENT_ESPRESSO_VERSION |
|
25 | - ); |
|
26 | - wp_register_style( |
|
27 | - 'espresso_default', |
|
28 | - EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
29 | - array('dashicons'), |
|
30 | - EVENT_ESPRESSO_VERSION |
|
31 | - ); |
|
32 | - wp_enqueue_style('checkbox_dropdown_selector'); |
|
33 | - wp_register_script( |
|
34 | - 'checkbox_dropdown_selector', |
|
35 | - EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js', |
|
36 | - array('jquery'), |
|
37 | - EVENT_ESPRESSO_VERSION, |
|
38 | - true |
|
39 | - ); |
|
40 | - wp_enqueue_script('checkbox_dropdown_selector'); |
|
41 | - } |
|
15 | + /** |
|
16 | + * enqueues css and js, so that this can be called statically |
|
17 | + */ |
|
18 | + public static function enqueue_styles_and_scripts() |
|
19 | + { |
|
20 | + wp_register_style( |
|
21 | + 'checkbox_dropdown_selector', |
|
22 | + EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css', |
|
23 | + array('espresso_default'), |
|
24 | + EVENT_ESPRESSO_VERSION |
|
25 | + ); |
|
26 | + wp_register_style( |
|
27 | + 'espresso_default', |
|
28 | + EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
29 | + array('dashicons'), |
|
30 | + EVENT_ESPRESSO_VERSION |
|
31 | + ); |
|
32 | + wp_enqueue_style('checkbox_dropdown_selector'); |
|
33 | + wp_register_script( |
|
34 | + 'checkbox_dropdown_selector', |
|
35 | + EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js', |
|
36 | + array('jquery'), |
|
37 | + EVENT_ESPRESSO_VERSION, |
|
38 | + true |
|
39 | + ); |
|
40 | + wp_enqueue_script('checkbox_dropdown_selector'); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | 44 | |
45 | - /** |
|
46 | - * Informs the rest of the forms system what CSS and JS is needed to display the input |
|
47 | - */ |
|
48 | - public function enqueue_js() |
|
49 | - { |
|
50 | - EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts(); |
|
51 | - } |
|
45 | + /** |
|
46 | + * Informs the rest of the forms system what CSS and JS is needed to display the input |
|
47 | + */ |
|
48 | + public function enqueue_js() |
|
49 | + { |
|
50 | + EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts(); |
|
51 | + } |
|
52 | 52 | |
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * callback for Iframe::addStylesheets() child class methods |
|
57 | - * |
|
58 | - * @param array $iframe_css |
|
59 | - * @return array |
|
60 | - */ |
|
61 | - public function iframe_css(array $iframe_css) |
|
62 | - { |
|
63 | - $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css'; |
|
64 | - return $iframe_css; |
|
65 | - } |
|
55 | + /** |
|
56 | + * callback for Iframe::addStylesheets() child class methods |
|
57 | + * |
|
58 | + * @param array $iframe_css |
|
59 | + * @return array |
|
60 | + */ |
|
61 | + public function iframe_css(array $iframe_css) |
|
62 | + { |
|
63 | + $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css'; |
|
64 | + return $iframe_css; |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | 68 | |
69 | - /** |
|
70 | - * callback for Iframe::addScripts() child class methods |
|
71 | - * |
|
72 | - * @param array $iframe_js |
|
73 | - * @return array |
|
74 | - */ |
|
75 | - public function iframe_js(array $iframe_js) |
|
76 | - { |
|
77 | - $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js'; |
|
78 | - return $iframe_js; |
|
79 | - } |
|
69 | + /** |
|
70 | + * callback for Iframe::addScripts() child class methods |
|
71 | + * |
|
72 | + * @param array $iframe_js |
|
73 | + * @return array |
|
74 | + */ |
|
75 | + public function iframe_js(array $iframe_js) |
|
76 | + { |
|
77 | + $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js'; |
|
78 | + return $iframe_js; |
|
79 | + } |
|
80 | 80 | |
81 | 81 | |
82 | - /** |
|
83 | - * @throws EE_Error |
|
84 | - * @return string of html to display the field |
|
85 | - */ |
|
86 | - public function display() |
|
87 | - { |
|
88 | - $input = $this->get_input(); |
|
89 | - $select_button_text = $input instanceof EE_Checkbox_Dropdown_Selector_Input ? $input->select_button_text() : ''; |
|
90 | - // $multi = count( $input->options() ) > 1 ? TRUE : FALSE; |
|
91 | - $input->set_label_sizes(); |
|
92 | - $label_size_class = $input->get_label_size_class(); |
|
93 | - if (! is_array($input->raw_value()) && $input->raw_value() !== null) { |
|
94 | - EE_Error::doing_it_wrong( |
|
95 | - 'EE_Checkbox_Display_Strategy::display()', |
|
96 | - sprintf( |
|
97 | - esc_html__( |
|
98 | - 'Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"', |
|
99 | - 'event_espresso' |
|
100 | - ), |
|
101 | - $input->html_id(), |
|
102 | - var_export($input->raw_value(), true), |
|
103 | - $input->html_name() . '[]' |
|
104 | - ), |
|
105 | - '4.8.1' |
|
106 | - ); |
|
107 | - } |
|
82 | + /** |
|
83 | + * @throws EE_Error |
|
84 | + * @return string of html to display the field |
|
85 | + */ |
|
86 | + public function display() |
|
87 | + { |
|
88 | + $input = $this->get_input(); |
|
89 | + $select_button_text = $input instanceof EE_Checkbox_Dropdown_Selector_Input ? $input->select_button_text() : ''; |
|
90 | + // $multi = count( $input->options() ) > 1 ? TRUE : FALSE; |
|
91 | + $input->set_label_sizes(); |
|
92 | + $label_size_class = $input->get_label_size_class(); |
|
93 | + if (! is_array($input->raw_value()) && $input->raw_value() !== null) { |
|
94 | + EE_Error::doing_it_wrong( |
|
95 | + 'EE_Checkbox_Display_Strategy::display()', |
|
96 | + sprintf( |
|
97 | + esc_html__( |
|
98 | + 'Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"', |
|
99 | + 'event_espresso' |
|
100 | + ), |
|
101 | + $input->html_id(), |
|
102 | + var_export($input->raw_value(), true), |
|
103 | + $input->html_name() . '[]' |
|
104 | + ), |
|
105 | + '4.8.1' |
|
106 | + ); |
|
107 | + } |
|
108 | 108 | |
109 | 109 | |
110 | - $html = \EEH_HTML::div('', '', 'checkbox-dropdown-selector-wrap-dv'); |
|
111 | - $html .= '<button id="' . $input->html_id() . '-btn"'; |
|
112 | - // $html .= ' name="' . $input->html_name() . '"'; |
|
113 | - $html .= ' class="' . $input->html_class() . ' checkbox-dropdown-selector-btn button-secondary button"'; |
|
114 | - $html .= ' style="' . $input->html_style() . '"'; |
|
115 | - $html .= ' data-target="' . $input->html_id() . '-options-dv"'; |
|
116 | - $html .= ' ' . $input->html_other_attributes() . '>'; |
|
117 | - $html .= '<span class="checkbox-dropdown-selector-selected-spn">'; |
|
118 | - $html .= $select_button_text; |
|
119 | - $html .= '</span> <span class="dashicons dashicons-arrow-down"></span>'; |
|
120 | - $html .= '</button>'; |
|
121 | - $html .= EEH_HTML::div( |
|
122 | - '', |
|
123 | - $input->html_id() . '-options-dv', |
|
124 | - 'checkbox-dropdown-selector' |
|
125 | - ); |
|
126 | - $html .= EEH_HTML::link( |
|
127 | - '', |
|
128 | - '<span class="dashicons dashicons-no"></span>', |
|
129 | - esc_html__('close datetime selector', 'event_espresso'), |
|
130 | - '', |
|
131 | - 'close-espresso-notice' |
|
132 | - ); |
|
133 | - $html .= EEH_HTML::ul(); |
|
134 | - $input_raw_value = (array) $input->raw_value(); |
|
135 | - foreach ($input->options() as $value => $display_text) { |
|
136 | - $html .= EEH_HTML::li(); |
|
137 | - $value = $input->get_normalization_strategy()->unnormalize_one($value); |
|
138 | - $html_id = $this->get_sub_input_id($value); |
|
139 | - $html .= EEH_HTML::nl(0, 'checkbox'); |
|
140 | - $html .= '<label for="' |
|
141 | - . $html_id |
|
142 | - . '" id="' |
|
143 | - . $html_id |
|
144 | - . '-lbl" class="ee-checkbox-label-after' |
|
145 | - . $label_size_class |
|
146 | - . '">'; |
|
147 | - $html .= EEH_HTML::nl(1, 'checkbox'); |
|
148 | - $html .= '<input type="checkbox"'; |
|
149 | - $html .= ' name="' . $input->html_name() . '[]"'; |
|
150 | - $html .= ' id="' . $html_id . '"'; |
|
151 | - $html .= ' class="' . $input->html_class() . '-option"'; |
|
152 | - $html .= ' style="' . $input->html_style() . '"'; |
|
153 | - $html .= ' value="' . esc_attr($value) . '"'; |
|
154 | - $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true) |
|
155 | - ? ' checked="checked"' |
|
156 | - : ''; |
|
157 | - $html .= ' ' . $this->_input->other_html_attributes(); |
|
158 | - $html .= '>'; |
|
159 | - $html .= '<span class="datetime-selector-option-text-spn">' . $display_text . '</span>'; |
|
160 | - $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>'; |
|
161 | - $html .= EEH_HTML::lix(); |
|
162 | - } |
|
163 | - $html .= EEH_HTML::ulx(); |
|
164 | - $html .= EEH_HTML::divx(); |
|
165 | - $html .= EEH_HTML::divx(); |
|
166 | - $html .= \EEH_HTML::br(); |
|
167 | - return $html; |
|
168 | - } |
|
110 | + $html = \EEH_HTML::div('', '', 'checkbox-dropdown-selector-wrap-dv'); |
|
111 | + $html .= '<button id="' . $input->html_id() . '-btn"'; |
|
112 | + // $html .= ' name="' . $input->html_name() . '"'; |
|
113 | + $html .= ' class="' . $input->html_class() . ' checkbox-dropdown-selector-btn button-secondary button"'; |
|
114 | + $html .= ' style="' . $input->html_style() . '"'; |
|
115 | + $html .= ' data-target="' . $input->html_id() . '-options-dv"'; |
|
116 | + $html .= ' ' . $input->html_other_attributes() . '>'; |
|
117 | + $html .= '<span class="checkbox-dropdown-selector-selected-spn">'; |
|
118 | + $html .= $select_button_text; |
|
119 | + $html .= '</span> <span class="dashicons dashicons-arrow-down"></span>'; |
|
120 | + $html .= '</button>'; |
|
121 | + $html .= EEH_HTML::div( |
|
122 | + '', |
|
123 | + $input->html_id() . '-options-dv', |
|
124 | + 'checkbox-dropdown-selector' |
|
125 | + ); |
|
126 | + $html .= EEH_HTML::link( |
|
127 | + '', |
|
128 | + '<span class="dashicons dashicons-no"></span>', |
|
129 | + esc_html__('close datetime selector', 'event_espresso'), |
|
130 | + '', |
|
131 | + 'close-espresso-notice' |
|
132 | + ); |
|
133 | + $html .= EEH_HTML::ul(); |
|
134 | + $input_raw_value = (array) $input->raw_value(); |
|
135 | + foreach ($input->options() as $value => $display_text) { |
|
136 | + $html .= EEH_HTML::li(); |
|
137 | + $value = $input->get_normalization_strategy()->unnormalize_one($value); |
|
138 | + $html_id = $this->get_sub_input_id($value); |
|
139 | + $html .= EEH_HTML::nl(0, 'checkbox'); |
|
140 | + $html .= '<label for="' |
|
141 | + . $html_id |
|
142 | + . '" id="' |
|
143 | + . $html_id |
|
144 | + . '-lbl" class="ee-checkbox-label-after' |
|
145 | + . $label_size_class |
|
146 | + . '">'; |
|
147 | + $html .= EEH_HTML::nl(1, 'checkbox'); |
|
148 | + $html .= '<input type="checkbox"'; |
|
149 | + $html .= ' name="' . $input->html_name() . '[]"'; |
|
150 | + $html .= ' id="' . $html_id . '"'; |
|
151 | + $html .= ' class="' . $input->html_class() . '-option"'; |
|
152 | + $html .= ' style="' . $input->html_style() . '"'; |
|
153 | + $html .= ' value="' . esc_attr($value) . '"'; |
|
154 | + $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true) |
|
155 | + ? ' checked="checked"' |
|
156 | + : ''; |
|
157 | + $html .= ' ' . $this->_input->other_html_attributes(); |
|
158 | + $html .= '>'; |
|
159 | + $html .= '<span class="datetime-selector-option-text-spn">' . $display_text . '</span>'; |
|
160 | + $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>'; |
|
161 | + $html .= EEH_HTML::lix(); |
|
162 | + } |
|
163 | + $html .= EEH_HTML::ulx(); |
|
164 | + $html .= EEH_HTML::divx(); |
|
165 | + $html .= EEH_HTML::divx(); |
|
166 | + $html .= \EEH_HTML::br(); |
|
167 | + return $html; |
|
168 | + } |
|
169 | 169 | } |
@@ -19,20 +19,20 @@ discard block |
||
19 | 19 | { |
20 | 20 | wp_register_style( |
21 | 21 | 'checkbox_dropdown_selector', |
22 | - EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css', |
|
22 | + EE_GLOBAL_ASSETS_URL.'css/checkbox_dropdown_selector.css', |
|
23 | 23 | array('espresso_default'), |
24 | 24 | EVENT_ESPRESSO_VERSION |
25 | 25 | ); |
26 | 26 | wp_register_style( |
27 | 27 | 'espresso_default', |
28 | - EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
28 | + EE_GLOBAL_ASSETS_URL.'css/espresso_default.css', |
|
29 | 29 | array('dashicons'), |
30 | 30 | EVENT_ESPRESSO_VERSION |
31 | 31 | ); |
32 | 32 | wp_enqueue_style('checkbox_dropdown_selector'); |
33 | 33 | wp_register_script( |
34 | 34 | 'checkbox_dropdown_selector', |
35 | - EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js', |
|
35 | + EE_GLOBAL_ASSETS_URL.'scripts/checkbox_dropdown_selector.js', |
|
36 | 36 | array('jquery'), |
37 | 37 | EVENT_ESPRESSO_VERSION, |
38 | 38 | true |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function iframe_css(array $iframe_css) |
62 | 62 | { |
63 | - $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css'; |
|
63 | + $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL.'css/checkbox_dropdown_selector.css'; |
|
64 | 64 | return $iframe_css; |
65 | 65 | } |
66 | 66 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function iframe_js(array $iframe_js) |
76 | 76 | { |
77 | - $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js'; |
|
77 | + $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL.'scripts/checkbox_dropdown_selector.js'; |
|
78 | 78 | return $iframe_js; |
79 | 79 | } |
80 | 80 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | // $multi = count( $input->options() ) > 1 ? TRUE : FALSE; |
91 | 91 | $input->set_label_sizes(); |
92 | 92 | $label_size_class = $input->get_label_size_class(); |
93 | - if (! is_array($input->raw_value()) && $input->raw_value() !== null) { |
|
93 | + if ( ! is_array($input->raw_value()) && $input->raw_value() !== null) { |
|
94 | 94 | EE_Error::doing_it_wrong( |
95 | 95 | 'EE_Checkbox_Display_Strategy::display()', |
96 | 96 | sprintf( |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | ), |
101 | 101 | $input->html_id(), |
102 | 102 | var_export($input->raw_value(), true), |
103 | - $input->html_name() . '[]' |
|
103 | + $input->html_name().'[]' |
|
104 | 104 | ), |
105 | 105 | '4.8.1' |
106 | 106 | ); |
@@ -108,19 +108,19 @@ discard block |
||
108 | 108 | |
109 | 109 | |
110 | 110 | $html = \EEH_HTML::div('', '', 'checkbox-dropdown-selector-wrap-dv'); |
111 | - $html .= '<button id="' . $input->html_id() . '-btn"'; |
|
111 | + $html .= '<button id="'.$input->html_id().'-btn"'; |
|
112 | 112 | // $html .= ' name="' . $input->html_name() . '"'; |
113 | - $html .= ' class="' . $input->html_class() . ' checkbox-dropdown-selector-btn button-secondary button"'; |
|
114 | - $html .= ' style="' . $input->html_style() . '"'; |
|
115 | - $html .= ' data-target="' . $input->html_id() . '-options-dv"'; |
|
116 | - $html .= ' ' . $input->html_other_attributes() . '>'; |
|
113 | + $html .= ' class="'.$input->html_class().' checkbox-dropdown-selector-btn button-secondary button"'; |
|
114 | + $html .= ' style="'.$input->html_style().'"'; |
|
115 | + $html .= ' data-target="'.$input->html_id().'-options-dv"'; |
|
116 | + $html .= ' '.$input->html_other_attributes().'>'; |
|
117 | 117 | $html .= '<span class="checkbox-dropdown-selector-selected-spn">'; |
118 | 118 | $html .= $select_button_text; |
119 | 119 | $html .= '</span> <span class="dashicons dashicons-arrow-down"></span>'; |
120 | 120 | $html .= '</button>'; |
121 | 121 | $html .= EEH_HTML::div( |
122 | 122 | '', |
123 | - $input->html_id() . '-options-dv', |
|
123 | + $input->html_id().'-options-dv', |
|
124 | 124 | 'checkbox-dropdown-selector' |
125 | 125 | ); |
126 | 126 | $html .= EEH_HTML::link( |
@@ -146,18 +146,18 @@ discard block |
||
146 | 146 | . '">'; |
147 | 147 | $html .= EEH_HTML::nl(1, 'checkbox'); |
148 | 148 | $html .= '<input type="checkbox"'; |
149 | - $html .= ' name="' . $input->html_name() . '[]"'; |
|
150 | - $html .= ' id="' . $html_id . '"'; |
|
151 | - $html .= ' class="' . $input->html_class() . '-option"'; |
|
152 | - $html .= ' style="' . $input->html_style() . '"'; |
|
153 | - $html .= ' value="' . esc_attr($value) . '"'; |
|
149 | + $html .= ' name="'.$input->html_name().'[]"'; |
|
150 | + $html .= ' id="'.$html_id.'"'; |
|
151 | + $html .= ' class="'.$input->html_class().'-option"'; |
|
152 | + $html .= ' style="'.$input->html_style().'"'; |
|
153 | + $html .= ' value="'.esc_attr($value).'"'; |
|
154 | 154 | $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true) |
155 | 155 | ? ' checked="checked"' |
156 | 156 | : ''; |
157 | - $html .= ' ' . $this->_input->other_html_attributes(); |
|
157 | + $html .= ' '.$this->_input->other_html_attributes(); |
|
158 | 158 | $html .= '>'; |
159 | - $html .= '<span class="datetime-selector-option-text-spn">' . $display_text . '</span>'; |
|
160 | - $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>'; |
|
159 | + $html .= '<span class="datetime-selector-option-text-spn">'.$display_text.'</span>'; |
|
160 | + $html .= EEH_HTML::nl(-1, 'checkbox').'</label>'; |
|
161 | 161 | $html .= EEH_HTML::lix(); |
162 | 162 | } |
163 | 163 | $html .= EEH_HTML::ulx(); |
@@ -11,73 +11,73 @@ |
||
11 | 11 | class EE_Admin_File_Uploader_Display_Strategy extends EE_Display_Strategy_Base |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * Its important this media only get enqueued AFTER init, but before the footer... where the |
|
16 | - * rest of our forms JS gets enqueued. Otherwise the JS gets enqueued fine, and loaded on the page fine, |
|
17 | - * but when you upload an image it gets uploaded fine to the server, but it doesn't display and reports an error |
|
18 | - * (also it doesn't show any of the currently existing media in the modal window that pops up when you click the button |
|
19 | - * to select media). |
|
20 | - * Besides that, no special consideration should be required to make the media uploader appear, besides having |
|
21 | - * this input displayed. |
|
22 | - * @deprecated. enqueue_js should be called automatically now |
|
23 | - */ |
|
24 | - public static function enqueue_scripts() |
|
25 | - { |
|
26 | - EE_Error::doing_it_wrong(__FUNCTION__, __('EE_Admin_File_Uploader_Display_Strategy::enqueue_scripts() no longer needs to be called in order to display the admin uploader input correctly. This is handled now by EE_Admin_File_Uploader_Display_Strategy::enqueue_js() which is called automatically when enqueueing JS and CSS for the form', 'event_espresso'), '4.9.8.rc.015'); |
|
27 | - wp_enqueue_media(); |
|
28 | - wp_enqueue_script('media-upload'); |
|
29 | - wp_enqueue_script('ee-payments', EE_GLOBAL_ASSETS_URL.'scripts/ee-media-uploader.js'); |
|
30 | - } |
|
14 | + /** |
|
15 | + * Its important this media only get enqueued AFTER init, but before the footer... where the |
|
16 | + * rest of our forms JS gets enqueued. Otherwise the JS gets enqueued fine, and loaded on the page fine, |
|
17 | + * but when you upload an image it gets uploaded fine to the server, but it doesn't display and reports an error |
|
18 | + * (also it doesn't show any of the currently existing media in the modal window that pops up when you click the button |
|
19 | + * to select media). |
|
20 | + * Besides that, no special consideration should be required to make the media uploader appear, besides having |
|
21 | + * this input displayed. |
|
22 | + * @deprecated. enqueue_js should be called automatically now |
|
23 | + */ |
|
24 | + public static function enqueue_scripts() |
|
25 | + { |
|
26 | + EE_Error::doing_it_wrong(__FUNCTION__, __('EE_Admin_File_Uploader_Display_Strategy::enqueue_scripts() no longer needs to be called in order to display the admin uploader input correctly. This is handled now by EE_Admin_File_Uploader_Display_Strategy::enqueue_js() which is called automatically when enqueueing JS and CSS for the form', 'event_espresso'), '4.9.8.rc.015'); |
|
27 | + wp_enqueue_media(); |
|
28 | + wp_enqueue_script('media-upload'); |
|
29 | + wp_enqueue_script('ee-payments', EE_GLOBAL_ASSETS_URL.'scripts/ee-media-uploader.js'); |
|
30 | + } |
|
31 | 31 | |
32 | - /** |
|
33 | - * Enqueues the JS and CSS needed to display this input |
|
34 | - */ |
|
35 | - public function enqueue_js() |
|
36 | - { |
|
37 | - wp_enqueue_media(); |
|
38 | - wp_enqueue_script('media-upload'); |
|
39 | - wp_enqueue_script('ee-payments', EE_GLOBAL_ASSETS_URL.'scripts/ee-media-uploader.js'); |
|
40 | - parent::enqueue_js(); |
|
41 | - } |
|
32 | + /** |
|
33 | + * Enqueues the JS and CSS needed to display this input |
|
34 | + */ |
|
35 | + public function enqueue_js() |
|
36 | + { |
|
37 | + wp_enqueue_media(); |
|
38 | + wp_enqueue_script('media-upload'); |
|
39 | + wp_enqueue_script('ee-payments', EE_GLOBAL_ASSETS_URL.'scripts/ee-media-uploader.js'); |
|
40 | + parent::enqueue_js(); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | 44 | |
45 | - /** |
|
46 | - * |
|
47 | - * @return string of html to display the field |
|
48 | - */ |
|
45 | + /** |
|
46 | + * |
|
47 | + * @return string of html to display the field |
|
48 | + */ |
|
49 | 49 | |
50 | - public function display() |
|
51 | - { |
|
52 | - // the actual input |
|
53 | - $input = '<input type="text" size="34" '; |
|
54 | - $input .= 'name="' . $this->_input->html_name() . '" '; |
|
55 | - $input .= $this->_input->html_class() != '' ? 'class="large-text ee_media_url ' . $this->_input->html_class() . '" ' : 'class="large-text ee_media_url" '; |
|
56 | - $input .= 'value="' . $this->_input->raw_value_in_form() . '" '; |
|
57 | - $input .= $this->_input->other_html_attributes() . '>'; |
|
58 | - // image uploader |
|
59 | - $uploader = EEH_HTML::link('#', '<img src="' . admin_url('images/media-button-image.gif') . '" >', __('click to add an image', 'event_espresso'), '', 'ee_media_upload'); |
|
60 | - // only attempt to show the image if it at least exists |
|
61 | - $image = $this->src_exists($this->_input->raw_value()) ? EEH_HTML::br(2) . EEH_HTML::img($this->_input->raw_value(), __('logo', 'event_espresso'), '', 'ee_media_image') : ''; |
|
62 | - // html string |
|
63 | - return EEH_HTML::div($input . EEH_HTML::nbsp() . $uploader . $image, '', 'ee_media_uploader_area'); |
|
64 | - } |
|
50 | + public function display() |
|
51 | + { |
|
52 | + // the actual input |
|
53 | + $input = '<input type="text" size="34" '; |
|
54 | + $input .= 'name="' . $this->_input->html_name() . '" '; |
|
55 | + $input .= $this->_input->html_class() != '' ? 'class="large-text ee_media_url ' . $this->_input->html_class() . '" ' : 'class="large-text ee_media_url" '; |
|
56 | + $input .= 'value="' . $this->_input->raw_value_in_form() . '" '; |
|
57 | + $input .= $this->_input->other_html_attributes() . '>'; |
|
58 | + // image uploader |
|
59 | + $uploader = EEH_HTML::link('#', '<img src="' . admin_url('images/media-button-image.gif') . '" >', __('click to add an image', 'event_espresso'), '', 'ee_media_upload'); |
|
60 | + // only attempt to show the image if it at least exists |
|
61 | + $image = $this->src_exists($this->_input->raw_value()) ? EEH_HTML::br(2) . EEH_HTML::img($this->_input->raw_value(), __('logo', 'event_espresso'), '', 'ee_media_image') : ''; |
|
62 | + // html string |
|
63 | + return EEH_HTML::div($input . EEH_HTML::nbsp() . $uploader . $image, '', 'ee_media_uploader_area'); |
|
64 | + } |
|
65 | 65 | |
66 | 66 | |
67 | 67 | |
68 | - /** |
|
69 | - * Asserts an image actually exists as quickly as possible by sending a HEAD |
|
70 | - * request |
|
71 | - * @param string $src |
|
72 | - * @return boolean |
|
73 | - */ |
|
74 | - protected function src_exists($src) |
|
75 | - { |
|
76 | - $results = wp_remote_head($src); |
|
77 | - if (is_array($results) && ! $results instanceof WP_Error) { |
|
78 | - return strpos($results['headers']['content-type'], "image") !== false; |
|
79 | - } else { |
|
80 | - return false; |
|
81 | - } |
|
82 | - } |
|
68 | + /** |
|
69 | + * Asserts an image actually exists as quickly as possible by sending a HEAD |
|
70 | + * request |
|
71 | + * @param string $src |
|
72 | + * @return boolean |
|
73 | + */ |
|
74 | + protected function src_exists($src) |
|
75 | + { |
|
76 | + $results = wp_remote_head($src); |
|
77 | + if (is_array($results) && ! $results instanceof WP_Error) { |
|
78 | + return strpos($results['headers']['content-type'], "image") !== false; |
|
79 | + } else { |
|
80 | + return false; |
|
81 | + } |
|
82 | + } |
|
83 | 83 | } |
@@ -51,16 +51,16 @@ |
||
51 | 51 | { |
52 | 52 | // the actual input |
53 | 53 | $input = '<input type="text" size="34" '; |
54 | - $input .= 'name="' . $this->_input->html_name() . '" '; |
|
55 | - $input .= $this->_input->html_class() != '' ? 'class="large-text ee_media_url ' . $this->_input->html_class() . '" ' : 'class="large-text ee_media_url" '; |
|
56 | - $input .= 'value="' . $this->_input->raw_value_in_form() . '" '; |
|
57 | - $input .= $this->_input->other_html_attributes() . '>'; |
|
54 | + $input .= 'name="'.$this->_input->html_name().'" '; |
|
55 | + $input .= $this->_input->html_class() != '' ? 'class="large-text ee_media_url '.$this->_input->html_class().'" ' : 'class="large-text ee_media_url" '; |
|
56 | + $input .= 'value="'.$this->_input->raw_value_in_form().'" '; |
|
57 | + $input .= $this->_input->other_html_attributes().'>'; |
|
58 | 58 | // image uploader |
59 | - $uploader = EEH_HTML::link('#', '<img src="' . admin_url('images/media-button-image.gif') . '" >', __('click to add an image', 'event_espresso'), '', 'ee_media_upload'); |
|
59 | + $uploader = EEH_HTML::link('#', '<img src="'.admin_url('images/media-button-image.gif').'" >', __('click to add an image', 'event_espresso'), '', 'ee_media_upload'); |
|
60 | 60 | // only attempt to show the image if it at least exists |
61 | - $image = $this->src_exists($this->_input->raw_value()) ? EEH_HTML::br(2) . EEH_HTML::img($this->_input->raw_value(), __('logo', 'event_espresso'), '', 'ee_media_image') : ''; |
|
61 | + $image = $this->src_exists($this->_input->raw_value()) ? EEH_HTML::br(2).EEH_HTML::img($this->_input->raw_value(), __('logo', 'event_espresso'), '', 'ee_media_image') : ''; |
|
62 | 62 | // html string |
63 | - return EEH_HTML::div($input . EEH_HTML::nbsp() . $uploader . $image, '', 'ee_media_uploader_area'); |
|
63 | + return EEH_HTML::div($input.EEH_HTML::nbsp().$uploader.$image, '', 'ee_media_uploader_area'); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 |
@@ -15,69 +15,69 @@ |
||
15 | 15 | class EE_Select2_Display_Strategy extends EE_Select_Display_Strategy |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * Arguments that will be passed into the select2 javascript constructor |
|
20 | - * @var array |
|
21 | - */ |
|
22 | - protected $_select2_js_args = array(); |
|
18 | + /** |
|
19 | + * Arguments that will be passed into the select2 javascript constructor |
|
20 | + * @var array |
|
21 | + */ |
|
22 | + protected $_select2_js_args = array(); |
|
23 | 23 | |
24 | - /** |
|
25 | - * |
|
26 | - * @param array $select2_js_args pass in the EXACT array of JS arguments you want |
|
27 | - * to pass into the select2 js/html input. See https://select2.github.io |
|
28 | - */ |
|
29 | - public function __construct($select2_js_args = array()) |
|
30 | - { |
|
31 | - $this->_select2_js_args = $select2_js_args; |
|
32 | - parent::__construct(); |
|
33 | - } |
|
24 | + /** |
|
25 | + * |
|
26 | + * @param array $select2_js_args pass in the EXACT array of JS arguments you want |
|
27 | + * to pass into the select2 js/html input. See https://select2.github.io |
|
28 | + */ |
|
29 | + public function __construct($select2_js_args = array()) |
|
30 | + { |
|
31 | + $this->_select2_js_args = $select2_js_args; |
|
32 | + parent::__construct(); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * enqueues the select2 initializing js (which depends on the select2 js) and |
|
37 | - * the select2 css |
|
38 | - */ |
|
39 | - public function enqueue_js() |
|
40 | - { |
|
41 | - // need to first deregister the select2 script in case some other plugin **cough cough Toolset Types cough** |
|
42 | - // is carelessly registering an older version of Select2 on admin pages that don't even belong to them |
|
43 | - wp_deregister_script('select2'); |
|
44 | - wp_deregister_style('select2'); |
|
45 | - wp_register_script('select2', EE_GLOBAL_ASSETS_URL . 'scripts/select2.min.js', array(), '4.0.2', true); |
|
46 | - wp_register_style('select2', EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', array(), '4.0.2', 'all'); |
|
47 | - wp_enqueue_script('form_section_select2_init', EE_GLOBAL_ASSETS_URL . 'scripts/form_section_select2_init.js', array( 'select2' ), '1.0.0', true); |
|
48 | - wp_enqueue_style('select2', EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', array(), '4.0.2', 'all'); |
|
49 | - } |
|
35 | + /** |
|
36 | + * enqueues the select2 initializing js (which depends on the select2 js) and |
|
37 | + * the select2 css |
|
38 | + */ |
|
39 | + public function enqueue_js() |
|
40 | + { |
|
41 | + // need to first deregister the select2 script in case some other plugin **cough cough Toolset Types cough** |
|
42 | + // is carelessly registering an older version of Select2 on admin pages that don't even belong to them |
|
43 | + wp_deregister_script('select2'); |
|
44 | + wp_deregister_style('select2'); |
|
45 | + wp_register_script('select2', EE_GLOBAL_ASSETS_URL . 'scripts/select2.min.js', array(), '4.0.2', true); |
|
46 | + wp_register_style('select2', EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', array(), '4.0.2', 'all'); |
|
47 | + wp_enqueue_script('form_section_select2_init', EE_GLOBAL_ASSETS_URL . 'scripts/form_section_select2_init.js', array( 'select2' ), '1.0.0', true); |
|
48 | + wp_enqueue_style('select2', EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', array(), '4.0.2', 'all'); |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * Gets the javascript args which will be localized and passed into the select2 js/html input |
|
53 | - * @return array |
|
54 | - */ |
|
55 | - public function get_js_args() |
|
56 | - { |
|
57 | - return $this->_select2_js_args; |
|
58 | - } |
|
51 | + /** |
|
52 | + * Gets the javascript args which will be localized and passed into the select2 js/html input |
|
53 | + * @return array |
|
54 | + */ |
|
55 | + public function get_js_args() |
|
56 | + { |
|
57 | + return $this->_select2_js_args; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * Sets the exact js args which will be passed into the select2 js/html input |
|
62 | - * @param array $js_args |
|
63 | - */ |
|
64 | - public function set_js_args($js_args) |
|
65 | - { |
|
66 | - $this->_select2_js_args = $js_args; |
|
67 | - } |
|
60 | + /** |
|
61 | + * Sets the exact js args which will be passed into the select2 js/html input |
|
62 | + * @param array $js_args |
|
63 | + */ |
|
64 | + public function set_js_args($js_args) |
|
65 | + { |
|
66 | + $this->_select2_js_args = $js_args; |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * Adds select2 data for localization |
|
71 | - * @param array $other_js_data |
|
72 | - * @return array |
|
73 | - */ |
|
74 | - public function get_other_js_data($other_js_data = array()) |
|
75 | - { |
|
76 | - $other_js_data = parent::get_other_js_data($other_js_data); |
|
77 | - if (! isset($other_js_data['select2s'])) { |
|
78 | - $other_js_data['select2s'] = array(); |
|
79 | - } |
|
80 | - $other_js_data['select2s'][ $this->_input->html_id() ] = $this->get_js_args(); |
|
81 | - return $other_js_data; |
|
82 | - } |
|
69 | + /** |
|
70 | + * Adds select2 data for localization |
|
71 | + * @param array $other_js_data |
|
72 | + * @return array |
|
73 | + */ |
|
74 | + public function get_other_js_data($other_js_data = array()) |
|
75 | + { |
|
76 | + $other_js_data = parent::get_other_js_data($other_js_data); |
|
77 | + if (! isset($other_js_data['select2s'])) { |
|
78 | + $other_js_data['select2s'] = array(); |
|
79 | + } |
|
80 | + $other_js_data['select2s'][ $this->_input->html_id() ] = $this->get_js_args(); |
|
81 | + return $other_js_data; |
|
82 | + } |
|
83 | 83 | } |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | // is carelessly registering an older version of Select2 on admin pages that don't even belong to them |
43 | 43 | wp_deregister_script('select2'); |
44 | 44 | wp_deregister_style('select2'); |
45 | - wp_register_script('select2', EE_GLOBAL_ASSETS_URL . 'scripts/select2.min.js', array(), '4.0.2', true); |
|
46 | - wp_register_style('select2', EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', array(), '4.0.2', 'all'); |
|
47 | - wp_enqueue_script('form_section_select2_init', EE_GLOBAL_ASSETS_URL . 'scripts/form_section_select2_init.js', array( 'select2' ), '1.0.0', true); |
|
48 | - wp_enqueue_style('select2', EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', array(), '4.0.2', 'all'); |
|
45 | + wp_register_script('select2', EE_GLOBAL_ASSETS_URL.'scripts/select2.min.js', array(), '4.0.2', true); |
|
46 | + wp_register_style('select2', EE_GLOBAL_ASSETS_URL.'css/select2.min.css', array(), '4.0.2', 'all'); |
|
47 | + wp_enqueue_script('form_section_select2_init', EE_GLOBAL_ASSETS_URL.'scripts/form_section_select2_init.js', array('select2'), '1.0.0', true); |
|
48 | + wp_enqueue_style('select2', EE_GLOBAL_ASSETS_URL.'css/select2.min.css', array(), '4.0.2', 'all'); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -74,10 +74,10 @@ discard block |
||
74 | 74 | public function get_other_js_data($other_js_data = array()) |
75 | 75 | { |
76 | 76 | $other_js_data = parent::get_other_js_data($other_js_data); |
77 | - if (! isset($other_js_data['select2s'])) { |
|
77 | + if ( ! isset($other_js_data['select2s'])) { |
|
78 | 78 | $other_js_data['select2s'] = array(); |
79 | 79 | } |
80 | - $other_js_data['select2s'][ $this->_input->html_id() ] = $this->get_js_args(); |
|
80 | + $other_js_data['select2s'][$this->_input->html_id()] = $this->get_js_args(); |
|
81 | 81 | return $other_js_data; |
82 | 82 | } |
83 | 83 | } |