Completed
Branch BUG-9042-ics-organizer-email (7b2e23)
by
unknown
29:24 queued 16:15
created
display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php 2 patches
Indentation   +146 added lines, -146 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
 
@@ -17,151 +17,151 @@  discard block
 block discarded – undo
17 17
 {
18 18
 
19 19
 
20
-    /**
21
-     * enqueues css and js, so that this can be called statically
22
-     */
23
-    public static function enqueue_styles_and_scripts()
24
-    {
25
-        wp_register_style(
26
-            'checkbox_dropdown_selector',
27
-            EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css',
28
-            array('espresso_default'),
29
-            EVENT_ESPRESSO_VERSION
30
-        );
31
-        wp_enqueue_style('checkbox_dropdown_selector');
32
-        wp_register_script(
33
-            'checkbox_dropdown_selector',
34
-            EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js',
35
-            array('jquery'),
36
-            EVENT_ESPRESSO_VERSION,
37
-            true
38
-        );
39
-        wp_enqueue_script('checkbox_dropdown_selector');
40
-    }
41
-
42
-
43
-
44
-    /**
45
-     * Informs the rest of the forms system what CSS and JS is needed to display the input
46
-     */
47
-    public function enqueue_js(){
48
-        EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts();
49
-    }
50
-
51
-
52
-
53
-    /**
54
-     * callback for Iframe::addStylesheets() child class methods
55
-     *
56
-     * @param array $iframe_css
57
-     * @return array
58
-     */
59
-    public function iframe_css(array $iframe_css){
60
-        $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css';
61
-        return $iframe_css;
62
-    }
63
-
64
-
65
-
66
-    /**
67
-     * callback for Iframe::addScripts() child class methods
68
-     *
69
-     * @param array $iframe_js
70
-     * @return array
71
-     */
72
-    public function iframe_js(array $iframe_js){
73
-        $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js';
74
-        return $iframe_js;
75
-    }
76
-
77
-
78
-    /**
79
-     * @throws EE_Error
80
-     * @return string of html to display the field
81
-     */
82
-    public function display()
83
-    {
84
-        $input = $this->get_input();
85
-        $select_button_text = $input instanceof EE_Checkbox_Dropdown_Selector_Input ? $input->select_button_text() : '';
86
-        // $multi = count( $input->options() ) > 1 ? TRUE : FALSE;
87
-        $input->set_label_sizes();
88
-        $label_size_class = $input->get_label_size_class();
89
-        if ( ! is_array($input->raw_value()) && $input->raw_value() !== null) {
90
-            EE_Error::doing_it_wrong(
91
-                'EE_Checkbox_Display_Strategy::display()',
92
-                sprintf(
93
-                    esc_html__(
94
-                        '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"',
95
-                        'event_espresso'
96
-                    ),
97
-                    $input->html_id(),
98
-                    var_export($input->raw_value(), true),
99
-                    $input->html_name() . '[]'
100
-                ),
101
-                '4.8.1'
102
-            );
103
-        }
104
-
105
-
106
-        $html = \EEH_HTML::div('', '', 'checkbox-dropdown-selector-wrap-dv');
107
-        $html .= '<button id="' . $input->html_id() . '-btn"';
108
-        // $html .= ' name="' . $input->html_name() . '"';
109
-        $html .= ' class="' . $input->html_class() . ' checkbox-dropdown-selector-btn button-secondary button"';
110
-        $html .= ' style="' . $input->html_style() . '"';
111
-        $html .= ' data-target="' . $input->html_id() . '-options-dv"';
112
-        $html .= ' ' . $input->html_other_attributes() . '>';
113
-        $html .= '<span class="checkbox-dropdown-selector-selected-spn">';
114
-        $html .= $select_button_text;
115
-        $html .= '</span> <span class="dashicons dashicons-arrow-down"></span>';
116
-        $html .= '</button>';
117
-        $html .= EEH_HTML::div(
118
-            '',
119
-            $input->html_id() . '-options-dv',
120
-            'checkbox-dropdown-selector'
121
-        );
122
-        $html .= EEH_HTML::link(
123
-            '',
124
-            '<span class="dashicons dashicons-no"></span>',
125
-            esc_html__('close datetime selector', 'event_espresso'),
126
-            '',
127
-            'close-espresso-notice'
128
-        );
129
-        $html .= EEH_HTML::ul();
130
-        $input_raw_value = (array)$input->raw_value();
131
-        foreach ($input->options() as $value => $display_text) {
132
-            $html .= EEH_HTML::li();
133
-            $value = $input->get_normalization_strategy()->unnormalize_one($value);
134
-            $html_id = $this->get_sub_input_id($value);
135
-            $html .= EEH_HTML::nl(0, 'checkbox');
136
-            $html .= '<label for="'
137
-                     . $html_id
138
-                     . '" id="'
139
-                     . $html_id
140
-                     . '-lbl" class="ee-checkbox-label-after'
141
-                     . $label_size_class
142
-                     . '">';
143
-            $html .= EEH_HTML::nl(1, 'checkbox');
144
-            $html .= '<input type="checkbox"';
145
-            $html .= ' name="' . $input->html_name() . '[]"';
146
-            $html .= ' id="' . $html_id . '"';
147
-            $html .= ' class="' . $input->html_class() . '-option"';
148
-            $html .= ' style="' . $input->html_style() . '"';
149
-            $html .= ' value="' . esc_attr($value) . '"';
150
-            $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true)
151
-                ? ' checked="checked"'
152
-                : '';
153
-            $html .= ' ' . $this->_input->other_html_attributes();
154
-            $html .= '>';
155
-            $html .= '<span class="datetime-selector-option-text-spn">' . $display_text . '</span>';
156
-            $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>';
157
-            $html .= EEH_HTML::lix();
158
-        }
159
-        $html .= EEH_HTML::ulx();
160
-        $html .= EEH_HTML::divx();
161
-        $html .= EEH_HTML::divx();
162
-        $html .= \EEH_HTML::br();
163
-        return $html;
164
-    }
20
+	/**
21
+	 * enqueues css and js, so that this can be called statically
22
+	 */
23
+	public static function enqueue_styles_and_scripts()
24
+	{
25
+		wp_register_style(
26
+			'checkbox_dropdown_selector',
27
+			EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css',
28
+			array('espresso_default'),
29
+			EVENT_ESPRESSO_VERSION
30
+		);
31
+		wp_enqueue_style('checkbox_dropdown_selector');
32
+		wp_register_script(
33
+			'checkbox_dropdown_selector',
34
+			EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js',
35
+			array('jquery'),
36
+			EVENT_ESPRESSO_VERSION,
37
+			true
38
+		);
39
+		wp_enqueue_script('checkbox_dropdown_selector');
40
+	}
41
+
42
+
43
+
44
+	/**
45
+	 * Informs the rest of the forms system what CSS and JS is needed to display the input
46
+	 */
47
+	public function enqueue_js(){
48
+		EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts();
49
+	}
50
+
51
+
52
+
53
+	/**
54
+	 * callback for Iframe::addStylesheets() child class methods
55
+	 *
56
+	 * @param array $iframe_css
57
+	 * @return array
58
+	 */
59
+	public function iframe_css(array $iframe_css){
60
+		$iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css';
61
+		return $iframe_css;
62
+	}
63
+
64
+
65
+
66
+	/**
67
+	 * callback for Iframe::addScripts() child class methods
68
+	 *
69
+	 * @param array $iframe_js
70
+	 * @return array
71
+	 */
72
+	public function iframe_js(array $iframe_js){
73
+		$iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js';
74
+		return $iframe_js;
75
+	}
76
+
77
+
78
+	/**
79
+	 * @throws EE_Error
80
+	 * @return string of html to display the field
81
+	 */
82
+	public function display()
83
+	{
84
+		$input = $this->get_input();
85
+		$select_button_text = $input instanceof EE_Checkbox_Dropdown_Selector_Input ? $input->select_button_text() : '';
86
+		// $multi = count( $input->options() ) > 1 ? TRUE : FALSE;
87
+		$input->set_label_sizes();
88
+		$label_size_class = $input->get_label_size_class();
89
+		if ( ! is_array($input->raw_value()) && $input->raw_value() !== null) {
90
+			EE_Error::doing_it_wrong(
91
+				'EE_Checkbox_Display_Strategy::display()',
92
+				sprintf(
93
+					esc_html__(
94
+						'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"',
95
+						'event_espresso'
96
+					),
97
+					$input->html_id(),
98
+					var_export($input->raw_value(), true),
99
+					$input->html_name() . '[]'
100
+				),
101
+				'4.8.1'
102
+			);
103
+		}
104
+
105
+
106
+		$html = \EEH_HTML::div('', '', 'checkbox-dropdown-selector-wrap-dv');
107
+		$html .= '<button id="' . $input->html_id() . '-btn"';
108
+		// $html .= ' name="' . $input->html_name() . '"';
109
+		$html .= ' class="' . $input->html_class() . ' checkbox-dropdown-selector-btn button-secondary button"';
110
+		$html .= ' style="' . $input->html_style() . '"';
111
+		$html .= ' data-target="' . $input->html_id() . '-options-dv"';
112
+		$html .= ' ' . $input->html_other_attributes() . '>';
113
+		$html .= '<span class="checkbox-dropdown-selector-selected-spn">';
114
+		$html .= $select_button_text;
115
+		$html .= '</span> <span class="dashicons dashicons-arrow-down"></span>';
116
+		$html .= '</button>';
117
+		$html .= EEH_HTML::div(
118
+			'',
119
+			$input->html_id() . '-options-dv',
120
+			'checkbox-dropdown-selector'
121
+		);
122
+		$html .= EEH_HTML::link(
123
+			'',
124
+			'<span class="dashicons dashicons-no"></span>',
125
+			esc_html__('close datetime selector', 'event_espresso'),
126
+			'',
127
+			'close-espresso-notice'
128
+		);
129
+		$html .= EEH_HTML::ul();
130
+		$input_raw_value = (array)$input->raw_value();
131
+		foreach ($input->options() as $value => $display_text) {
132
+			$html .= EEH_HTML::li();
133
+			$value = $input->get_normalization_strategy()->unnormalize_one($value);
134
+			$html_id = $this->get_sub_input_id($value);
135
+			$html .= EEH_HTML::nl(0, 'checkbox');
136
+			$html .= '<label for="'
137
+					 . $html_id
138
+					 . '" id="'
139
+					 . $html_id
140
+					 . '-lbl" class="ee-checkbox-label-after'
141
+					 . $label_size_class
142
+					 . '">';
143
+			$html .= EEH_HTML::nl(1, 'checkbox');
144
+			$html .= '<input type="checkbox"';
145
+			$html .= ' name="' . $input->html_name() . '[]"';
146
+			$html .= ' id="' . $html_id . '"';
147
+			$html .= ' class="' . $input->html_class() . '-option"';
148
+			$html .= ' style="' . $input->html_style() . '"';
149
+			$html .= ' value="' . esc_attr($value) . '"';
150
+			$html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true)
151
+				? ' checked="checked"'
152
+				: '';
153
+			$html .= ' ' . $this->_input->other_html_attributes();
154
+			$html .= '>';
155
+			$html .= '<span class="datetime-selector-option-text-spn">' . $display_text . '</span>';
156
+			$html .= EEH_HTML::nl(-1, 'checkbox') . '</label>';
157
+			$html .= EEH_HTML::lix();
158
+		}
159
+		$html .= EEH_HTML::ulx();
160
+		$html .= EEH_HTML::divx();
161
+		$html .= EEH_HTML::divx();
162
+		$html .= \EEH_HTML::br();
163
+		return $html;
164
+	}
165 165
 
166 166
 
167 167
 
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -24,14 +24,14 @@  discard block
 block discarded – undo
24 24
     {
25 25
         wp_register_style(
26 26
             'checkbox_dropdown_selector',
27
-            EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css',
27
+            EE_GLOBAL_ASSETS_URL.'css/checkbox_dropdown_selector.css',
28 28
             array('espresso_default'),
29 29
             EVENT_ESPRESSO_VERSION
30 30
         );
31 31
         wp_enqueue_style('checkbox_dropdown_selector');
32 32
         wp_register_script(
33 33
             'checkbox_dropdown_selector',
34
-            EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js',
34
+            EE_GLOBAL_ASSETS_URL.'scripts/checkbox_dropdown_selector.js',
35 35
             array('jquery'),
36 36
             EVENT_ESPRESSO_VERSION,
37 37
             true
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     /**
45 45
      * Informs the rest of the forms system what CSS and JS is needed to display the input
46 46
      */
47
-    public function enqueue_js(){
47
+    public function enqueue_js() {
48 48
         EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts();
49 49
     }
50 50
 
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
      * @param array $iframe_css
57 57
      * @return array
58 58
      */
59
-    public function iframe_css(array $iframe_css){
60
-        $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css';
59
+    public function iframe_css(array $iframe_css) {
60
+        $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL.'css/checkbox_dropdown_selector.css';
61 61
         return $iframe_css;
62 62
     }
63 63
 
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
      * @param array $iframe_js
70 70
      * @return array
71 71
      */
72
-    public function iframe_js(array $iframe_js){
73
-        $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js';
72
+    public function iframe_js(array $iframe_js) {
73
+        $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL.'scripts/checkbox_dropdown_selector.js';
74 74
         return $iframe_js;
75 75
     }
76 76
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
                     ),
97 97
                     $input->html_id(),
98 98
                     var_export($input->raw_value(), true),
99
-                    $input->html_name() . '[]'
99
+                    $input->html_name().'[]'
100 100
                 ),
101 101
                 '4.8.1'
102 102
             );
@@ -104,19 +104,19 @@  discard block
 block discarded – undo
104 104
 
105 105
 
106 106
         $html = \EEH_HTML::div('', '', 'checkbox-dropdown-selector-wrap-dv');
107
-        $html .= '<button id="' . $input->html_id() . '-btn"';
107
+        $html .= '<button id="'.$input->html_id().'-btn"';
108 108
         // $html .= ' name="' . $input->html_name() . '"';
109
-        $html .= ' class="' . $input->html_class() . ' checkbox-dropdown-selector-btn button-secondary button"';
110
-        $html .= ' style="' . $input->html_style() . '"';
111
-        $html .= ' data-target="' . $input->html_id() . '-options-dv"';
112
-        $html .= ' ' . $input->html_other_attributes() . '>';
109
+        $html .= ' class="'.$input->html_class().' checkbox-dropdown-selector-btn button-secondary button"';
110
+        $html .= ' style="'.$input->html_style().'"';
111
+        $html .= ' data-target="'.$input->html_id().'-options-dv"';
112
+        $html .= ' '.$input->html_other_attributes().'>';
113 113
         $html .= '<span class="checkbox-dropdown-selector-selected-spn">';
114 114
         $html .= $select_button_text;
115 115
         $html .= '</span> <span class="dashicons dashicons-arrow-down"></span>';
116 116
         $html .= '</button>';
117 117
         $html .= EEH_HTML::div(
118 118
             '',
119
-            $input->html_id() . '-options-dv',
119
+            $input->html_id().'-options-dv',
120 120
             'checkbox-dropdown-selector'
121 121
         );
122 122
         $html .= EEH_HTML::link(
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
             'close-espresso-notice'
128 128
         );
129 129
         $html .= EEH_HTML::ul();
130
-        $input_raw_value = (array)$input->raw_value();
130
+        $input_raw_value = (array) $input->raw_value();
131 131
         foreach ($input->options() as $value => $display_text) {
132 132
             $html .= EEH_HTML::li();
133 133
             $value = $input->get_normalization_strategy()->unnormalize_one($value);
@@ -142,18 +142,18 @@  discard block
 block discarded – undo
142 142
                      . '">';
143 143
             $html .= EEH_HTML::nl(1, 'checkbox');
144 144
             $html .= '<input type="checkbox"';
145
-            $html .= ' name="' . $input->html_name() . '[]"';
146
-            $html .= ' id="' . $html_id . '"';
147
-            $html .= ' class="' . $input->html_class() . '-option"';
148
-            $html .= ' style="' . $input->html_style() . '"';
149
-            $html .= ' value="' . esc_attr($value) . '"';
145
+            $html .= ' name="'.$input->html_name().'[]"';
146
+            $html .= ' id="'.$html_id.'"';
147
+            $html .= ' class="'.$input->html_class().'-option"';
148
+            $html .= ' style="'.$input->html_style().'"';
149
+            $html .= ' value="'.esc_attr($value).'"';
150 150
             $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true)
151 151
                 ? ' checked="checked"'
152 152
                 : '';
153
-            $html .= ' ' . $this->_input->other_html_attributes();
153
+            $html .= ' '.$this->_input->other_html_attributes();
154 154
             $html .= '>';
155
-            $html .= '<span class="datetime-selector-option-text-spn">' . $display_text . '</span>';
156
-            $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>';
155
+            $html .= '<span class="datetime-selector-option-text-spn">'.$display_text.'</span>';
156
+            $html .= EEH_HTML::nl(-1, 'checkbox').'</label>';
157 157
             $html .= EEH_HTML::lix();
158 158
         }
159 159
         $html .= EEH_HTML::ulx();
Please login to merge, or discard this patch.
modules/ticket_selector/TicketSelectorStandard.php 2 patches
Indentation   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -17,127 +17,127 @@
 block discarded – undo
17 17
 class TicketSelectorStandard extends TicketSelector
18 18
 {
19 19
 
20
-    /**
21
-     * @var string $date_format
22
-     */
23
-    protected $date_format;
24
-
25
-    /**
26
-     * @var string $time_format
27
-     */
28
-    protected $time_format;
29
-
30
-    /**
31
-     * @var \EE_Ticket_Selector_Config $ticket_selector_config
32
-     */
33
-    protected $ticket_selector_config;
34
-
35
-    /**
36
-     * @var \EE_Tax_Config $tax_config
37
-     */
38
-    protected $tax_config;
39
-
40
-
41
-
42
-    /**
43
-     * TicketSelectorSimple constructor.
44
-     *
45
-     * @param \EE_Event                  $event
46
-     * @param \EE_Ticket[]               $tickets
47
-     * @param int                        $max_attendees
48
-     * @param array                      $template_args
49
-     * @param string                     $date_format
50
-     * @param string                     $time_format
51
-     * @param \EE_Ticket_Selector_Config $ticket_selector_config
52
-     * @param \EE_Tax_Config             $tax_config
53
-     */
54
-    public function __construct(
55
-        \EE_Event $event,
56
-        array $tickets,
57
-        $max_attendees,
58
-        array $template_args,
59
-        $date_format = 'Y-m-d',
60
-        $time_format = 'g:i a',
61
-        \EE_Ticket_Selector_Config $ticket_selector_config = null,
62
-        \EE_Tax_Config $tax_config = null
63
-    ) {
64
-        $this->date_format = $date_format;
65
-        $this->time_format = $time_format;
66
-        // get EE_Ticket_Selector_Config and TicketDetails
67
-        $this->ticket_selector_config = isset (\EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector)
68
-            ? \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector
69
-            : new \EE_Ticket_Selector_Config();
70
-        // $template_settings->setDatetimeSelectorThreshold(2);
71
-        // \EEH_Debug_Tools::printr($template_settings->getShowDatetimeSelector(), 'getShowDatetimeSelector', __FILE__, __LINE__);
72
-        // \EEH_Debug_Tools::printr($template_settings->getDatetimeSelectorThreshold(), 'getDatetimeSelectorThreshold', __FILE__, __LINE__);
73
-        $this->tax_config = isset (\EE_Registry::instance()->CFG->tax_settings)
74
-            ? \EE_Registry::instance()->CFG->tax_settings
75
-            : new \EE_Tax_Config();
76
-        parent::__construct($event, $tickets, $max_attendees, $template_args);
77
-    }
78
-
79
-
80
-
81
-    /**
82
-     * sets any and all template args that are required for this Ticket Selector
83
-     *
84
-     * @return void
85
-     * @throws \EE_Error
86
-     */
87
-    protected function addTemplateArgs()
88
-    {
89
-        $row = 1;
90
-        $ticket_row_html = '';
91
-        $required_ticket_sold_out = false;
92
-        // flag to indicate that at least one taxable ticket has been encountered
93
-        $taxable_tickets = false;
94
-        $datetime_selector = null;
95
-        $this->template_args['datetime_selector'] = '';
96
-        if (
97
-            $this->ticket_selector_config->getShowDatetimeSelector()
98
-            !== \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
99
-        ) {
100
-            $datetime_selector = new DatetimeSelector(
101
-                $this->event,
102
-                $this->tickets,
103
-                $this->ticket_selector_config,
104
-                $this->date_format,
105
-                $this->time_format
106
-            );
107
-            $this->template_args['datetime_selector'] = $datetime_selector->getDatetimeSelector();
108
-        }
109
-        // loop through tickets
110
-        foreach ($this->tickets as $TKT_ID => $ticket) {
111
-            if ($ticket instanceof \EE_Ticket) {
112
-                $cols = 2;
113
-                $taxable_tickets = $ticket->taxable() ? true : $taxable_tickets;
114
-                $ticket_selector_row = new TicketSelectorRowStandard(
115
-                    $ticket,
116
-                    new TicketDetails($ticket, $this->ticket_selector_config, $this->template_args),
117
-                    $this->ticket_selector_config,
118
-                    $this->tax_config,
119
-                    $this->max_attendees,
120
-                    $row,
121
-                    $cols,
122
-                    $required_ticket_sold_out,
123
-                    $this->template_args['event_status'],
124
-                    $this->template_args['date_format'],
125
-                    $datetime_selector instanceof DatetimeSelector
126
-                        ? $datetime_selector->getTicketDatetimeClasses($ticket)
127
-                        : ''
128
-                );
129
-                $ticket_row_html .= $ticket_selector_row->getHtml();
130
-                $required_ticket_sold_out = $ticket_selector_row->getRequiredTicketSoldOut();
131
-                $row++;
132
-            }
133
-        }
134
-        $this->template_args['row'] = $row;
135
-        $this->template_args['ticket_row_html'] = $ticket_row_html;
136
-        $this->template_args['taxable_tickets'] = $taxable_tickets;
137
-        $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes;
138
-        $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php';
139
-        remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector');
140
-    }
20
+	/**
21
+	 * @var string $date_format
22
+	 */
23
+	protected $date_format;
24
+
25
+	/**
26
+	 * @var string $time_format
27
+	 */
28
+	protected $time_format;
29
+
30
+	/**
31
+	 * @var \EE_Ticket_Selector_Config $ticket_selector_config
32
+	 */
33
+	protected $ticket_selector_config;
34
+
35
+	/**
36
+	 * @var \EE_Tax_Config $tax_config
37
+	 */
38
+	protected $tax_config;
39
+
40
+
41
+
42
+	/**
43
+	 * TicketSelectorSimple constructor.
44
+	 *
45
+	 * @param \EE_Event                  $event
46
+	 * @param \EE_Ticket[]               $tickets
47
+	 * @param int                        $max_attendees
48
+	 * @param array                      $template_args
49
+	 * @param string                     $date_format
50
+	 * @param string                     $time_format
51
+	 * @param \EE_Ticket_Selector_Config $ticket_selector_config
52
+	 * @param \EE_Tax_Config             $tax_config
53
+	 */
54
+	public function __construct(
55
+		\EE_Event $event,
56
+		array $tickets,
57
+		$max_attendees,
58
+		array $template_args,
59
+		$date_format = 'Y-m-d',
60
+		$time_format = 'g:i a',
61
+		\EE_Ticket_Selector_Config $ticket_selector_config = null,
62
+		\EE_Tax_Config $tax_config = null
63
+	) {
64
+		$this->date_format = $date_format;
65
+		$this->time_format = $time_format;
66
+		// get EE_Ticket_Selector_Config and TicketDetails
67
+		$this->ticket_selector_config = isset (\EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector)
68
+			? \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector
69
+			: new \EE_Ticket_Selector_Config();
70
+		// $template_settings->setDatetimeSelectorThreshold(2);
71
+		// \EEH_Debug_Tools::printr($template_settings->getShowDatetimeSelector(), 'getShowDatetimeSelector', __FILE__, __LINE__);
72
+		// \EEH_Debug_Tools::printr($template_settings->getDatetimeSelectorThreshold(), 'getDatetimeSelectorThreshold', __FILE__, __LINE__);
73
+		$this->tax_config = isset (\EE_Registry::instance()->CFG->tax_settings)
74
+			? \EE_Registry::instance()->CFG->tax_settings
75
+			: new \EE_Tax_Config();
76
+		parent::__construct($event, $tickets, $max_attendees, $template_args);
77
+	}
78
+
79
+
80
+
81
+	/**
82
+	 * sets any and all template args that are required for this Ticket Selector
83
+	 *
84
+	 * @return void
85
+	 * @throws \EE_Error
86
+	 */
87
+	protected function addTemplateArgs()
88
+	{
89
+		$row = 1;
90
+		$ticket_row_html = '';
91
+		$required_ticket_sold_out = false;
92
+		// flag to indicate that at least one taxable ticket has been encountered
93
+		$taxable_tickets = false;
94
+		$datetime_selector = null;
95
+		$this->template_args['datetime_selector'] = '';
96
+		if (
97
+			$this->ticket_selector_config->getShowDatetimeSelector()
98
+			!== \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
99
+		) {
100
+			$datetime_selector = new DatetimeSelector(
101
+				$this->event,
102
+				$this->tickets,
103
+				$this->ticket_selector_config,
104
+				$this->date_format,
105
+				$this->time_format
106
+			);
107
+			$this->template_args['datetime_selector'] = $datetime_selector->getDatetimeSelector();
108
+		}
109
+		// loop through tickets
110
+		foreach ($this->tickets as $TKT_ID => $ticket) {
111
+			if ($ticket instanceof \EE_Ticket) {
112
+				$cols = 2;
113
+				$taxable_tickets = $ticket->taxable() ? true : $taxable_tickets;
114
+				$ticket_selector_row = new TicketSelectorRowStandard(
115
+					$ticket,
116
+					new TicketDetails($ticket, $this->ticket_selector_config, $this->template_args),
117
+					$this->ticket_selector_config,
118
+					$this->tax_config,
119
+					$this->max_attendees,
120
+					$row,
121
+					$cols,
122
+					$required_ticket_sold_out,
123
+					$this->template_args['event_status'],
124
+					$this->template_args['date_format'],
125
+					$datetime_selector instanceof DatetimeSelector
126
+						? $datetime_selector->getTicketDatetimeClasses($ticket)
127
+						: ''
128
+				);
129
+				$ticket_row_html .= $ticket_selector_row->getHtml();
130
+				$required_ticket_sold_out = $ticket_selector_row->getRequiredTicketSoldOut();
131
+				$row++;
132
+			}
133
+		}
134
+		$this->template_args['row'] = $row;
135
+		$this->template_args['ticket_row_html'] = $ticket_row_html;
136
+		$this->template_args['taxable_tickets'] = $taxable_tickets;
137
+		$this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes;
138
+		$this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php';
139
+		remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector');
140
+	}
141 141
 
142 142
 
143 143
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@
 block discarded – undo
135 135
         $this->template_args['ticket_row_html'] = $ticket_row_html;
136 136
         $this->template_args['taxable_tickets'] = $taxable_tickets;
137 137
         $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes;
138
-        $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php';
138
+        $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH.'standard_ticket_selector.template.php';
139 139
         remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector');
140 140
     }
141 141
 
Please login to merge, or discard this patch.
core/helpers/EEH_Activation.helper.php 2 patches
Indentation   +1711 added lines, -1711 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
 
@@ -14,243 +14,243 @@  discard block
 block discarded – undo
14 14
 class EEH_Activation
15 15
 {
16 16
 
17
-    /**
18
-     * constant used to indicate a cron task is no longer in use
19
-     */
20
-    const cron_task_no_longer_in_use = 'no_longer_in_use';
21
-
22
-    /**
23
-     * option name that will indicate whether or not we still
24
-     * need to create EE's folders in the uploads directory
25
-     * (because if EE was installed without file system access,
26
-     * we need to request credentials before we can create them)
27
-     */
28
-    const upload_directories_incomplete_option_name = 'ee_upload_directories_incomplete';
29
-
30
-    /**
31
-     * WP_User->ID
32
-     *
33
-     * @var int
34
-     */
35
-    private static $_default_creator_id;
36
-
37
-    /**
38
-     * indicates whether or not we've already verified core's default data during this request,
39
-     * because after migrations are done, any addons activated while in maintenance mode
40
-     * will want to setup their own default data, and they might hook into core's default data
41
-     * and trigger core to setup its default data. In which case they might all ask for core to init its default data.
42
-     * This prevents doing that for EVERY single addon.
43
-     *
44
-     * @var boolean
45
-     */
46
-    protected static $_initialized_db_content_already_in_this_request = false;
47
-
48
-    /**
49
-     * @var \EventEspresso\core\services\database\TableAnalysis $table_analysis
50
-     */
51
-    private static $table_analysis;
52
-
53
-    /**
54
-     * @var \EventEspresso\core\services\database\TableManager $table_manager
55
-     */
56
-    private static $table_manager;
57
-
58
-
59
-    /**
60
-     * @return \EventEspresso\core\services\database\TableAnalysis
61
-     */
62
-    public static function getTableAnalysis()
63
-    {
64
-        if (! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis) {
65
-            self::$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
66
-        }
67
-        return self::$table_analysis;
68
-    }
69
-
70
-
71
-    /**
72
-     * @return \EventEspresso\core\services\database\TableManager
73
-     */
74
-    public static function getTableManager()
75
-    {
76
-        if (! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager) {
77
-            self::$table_manager = EE_Registry::instance()->create('TableManager', array(), true);
78
-        }
79
-        return self::$table_manager;
80
-    }
81
-
82
-
83
-    /**
84
-     *    _ensure_table_name_has_prefix
85
-     *
86
-     * @deprecated instead use TableAnalysis::ensureTableNameHasPrefix()
87
-     * @access     public
88
-     * @static
89
-     * @param $table_name
90
-     * @return string
91
-     */
92
-    public static function ensure_table_name_has_prefix($table_name)
93
-    {
94
-        return \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix($table_name);
95
-    }
96
-
97
-
98
-    /**
99
-     *    system_initialization
100
-     *    ensures the EE configuration settings are loaded with at least default options set
101
-     *    and that all critical EE pages have been generated with the appropriate shortcodes in place
102
-     *
103
-     * @access public
104
-     * @static
105
-     * @return void
106
-     */
107
-    public static function system_initialization()
108
-    {
109
-        EEH_Activation::reset_and_update_config();
110
-        //which is fired BEFORE activation of plugin anyways
111
-        EEH_Activation::verify_default_pages_exist();
112
-    }
113
-
114
-
115
-    /**
116
-     * Sets the database schema and creates folders. This should
117
-     * be called on plugin activation and reactivation
118
-     *
119
-     * @return boolean success, whether the database and folders are setup properly
120
-     * @throws \EE_Error
121
-     */
122
-    public static function initialize_db_and_folders()
123
-    {
124
-        $good_filesystem = EEH_Activation::create_upload_directories();
125
-        $good_db         = EEH_Activation::create_database_tables();
126
-        return $good_filesystem && $good_db;
127
-    }
128
-
129
-
130
-    /**
131
-     * assuming we have an up-to-date database schema, this will populate it
132
-     * with default and initial data. This should be called
133
-     * upon activation of a new plugin, reactivation, and at the end
134
-     * of running migration scripts
135
-     *
136
-     * @throws \EE_Error
137
-     */
138
-    public static function initialize_db_content()
139
-    {
140
-        //let's avoid doing all this logic repeatedly, especially when addons are requesting it
141
-        if (EEH_Activation::$_initialized_db_content_already_in_this_request) {
142
-            return;
143
-        }
144
-        EEH_Activation::$_initialized_db_content_already_in_this_request = true;
145
-
146
-        EEH_Activation::initialize_system_questions();
147
-        EEH_Activation::insert_default_status_codes();
148
-        EEH_Activation::generate_default_message_templates();
149
-        EEH_Activation::create_no_ticket_prices_array();
150
-        EE_Registry::instance()->CAP->init_caps();
151
-
152
-        EEH_Activation::validate_messages_system();
153
-        EEH_Activation::insert_default_payment_methods();
154
-        //in case we've
155
-        EEH_Activation::remove_cron_tasks();
156
-        EEH_Activation::create_cron_tasks();
157
-        // remove all TXN locks since that is being done via extra meta now
158
-        delete_option('ee_locked_transactions');
159
-        //also, check for CAF default db content
160
-        do_action('AHEE__EEH_Activation__initialize_db_content');
161
-        //also: EEM_Gateways::load_all_gateways() outputs a lot of success messages
162
-        //which users really won't care about on initial activation
163
-        EE_Error::overwrite_success();
164
-    }
165
-
166
-
167
-    /**
168
-     * Returns an array of cron tasks. Array values are the actions fired by the cron tasks (the "hooks"),
169
-     * values are the frequency (the "recurrence"). See http://codex.wordpress.org/Function_Reference/wp_schedule_event
170
-     * If the cron task should NO longer be used, it should have a value of EEH_Activation::cron_task_no_longer_in_use
171
-     * (null)
172
-     *
173
-     * @param string $which_to_include can be 'current' (ones that are currently in use),
174
-     *                                 'old' (only returns ones that should no longer be used),or 'all',
175
-     * @return array
176
-     * @throws \EE_Error
177
-     */
178
-    public static function get_cron_tasks($which_to_include)
179
-    {
180
-        $cron_tasks = apply_filters(
181
-            'FHEE__EEH_Activation__get_cron_tasks',
182
-            array(
183
-                'AHEE__EE_Cron_Tasks__clean_up_junk_transactions'      => 'hourly',
17
+	/**
18
+	 * constant used to indicate a cron task is no longer in use
19
+	 */
20
+	const cron_task_no_longer_in_use = 'no_longer_in_use';
21
+
22
+	/**
23
+	 * option name that will indicate whether or not we still
24
+	 * need to create EE's folders in the uploads directory
25
+	 * (because if EE was installed without file system access,
26
+	 * we need to request credentials before we can create them)
27
+	 */
28
+	const upload_directories_incomplete_option_name = 'ee_upload_directories_incomplete';
29
+
30
+	/**
31
+	 * WP_User->ID
32
+	 *
33
+	 * @var int
34
+	 */
35
+	private static $_default_creator_id;
36
+
37
+	/**
38
+	 * indicates whether or not we've already verified core's default data during this request,
39
+	 * because after migrations are done, any addons activated while in maintenance mode
40
+	 * will want to setup their own default data, and they might hook into core's default data
41
+	 * and trigger core to setup its default data. In which case they might all ask for core to init its default data.
42
+	 * This prevents doing that for EVERY single addon.
43
+	 *
44
+	 * @var boolean
45
+	 */
46
+	protected static $_initialized_db_content_already_in_this_request = false;
47
+
48
+	/**
49
+	 * @var \EventEspresso\core\services\database\TableAnalysis $table_analysis
50
+	 */
51
+	private static $table_analysis;
52
+
53
+	/**
54
+	 * @var \EventEspresso\core\services\database\TableManager $table_manager
55
+	 */
56
+	private static $table_manager;
57
+
58
+
59
+	/**
60
+	 * @return \EventEspresso\core\services\database\TableAnalysis
61
+	 */
62
+	public static function getTableAnalysis()
63
+	{
64
+		if (! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis) {
65
+			self::$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
66
+		}
67
+		return self::$table_analysis;
68
+	}
69
+
70
+
71
+	/**
72
+	 * @return \EventEspresso\core\services\database\TableManager
73
+	 */
74
+	public static function getTableManager()
75
+	{
76
+		if (! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager) {
77
+			self::$table_manager = EE_Registry::instance()->create('TableManager', array(), true);
78
+		}
79
+		return self::$table_manager;
80
+	}
81
+
82
+
83
+	/**
84
+	 *    _ensure_table_name_has_prefix
85
+	 *
86
+	 * @deprecated instead use TableAnalysis::ensureTableNameHasPrefix()
87
+	 * @access     public
88
+	 * @static
89
+	 * @param $table_name
90
+	 * @return string
91
+	 */
92
+	public static function ensure_table_name_has_prefix($table_name)
93
+	{
94
+		return \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix($table_name);
95
+	}
96
+
97
+
98
+	/**
99
+	 *    system_initialization
100
+	 *    ensures the EE configuration settings are loaded with at least default options set
101
+	 *    and that all critical EE pages have been generated with the appropriate shortcodes in place
102
+	 *
103
+	 * @access public
104
+	 * @static
105
+	 * @return void
106
+	 */
107
+	public static function system_initialization()
108
+	{
109
+		EEH_Activation::reset_and_update_config();
110
+		//which is fired BEFORE activation of plugin anyways
111
+		EEH_Activation::verify_default_pages_exist();
112
+	}
113
+
114
+
115
+	/**
116
+	 * Sets the database schema and creates folders. This should
117
+	 * be called on plugin activation and reactivation
118
+	 *
119
+	 * @return boolean success, whether the database and folders are setup properly
120
+	 * @throws \EE_Error
121
+	 */
122
+	public static function initialize_db_and_folders()
123
+	{
124
+		$good_filesystem = EEH_Activation::create_upload_directories();
125
+		$good_db         = EEH_Activation::create_database_tables();
126
+		return $good_filesystem && $good_db;
127
+	}
128
+
129
+
130
+	/**
131
+	 * assuming we have an up-to-date database schema, this will populate it
132
+	 * with default and initial data. This should be called
133
+	 * upon activation of a new plugin, reactivation, and at the end
134
+	 * of running migration scripts
135
+	 *
136
+	 * @throws \EE_Error
137
+	 */
138
+	public static function initialize_db_content()
139
+	{
140
+		//let's avoid doing all this logic repeatedly, especially when addons are requesting it
141
+		if (EEH_Activation::$_initialized_db_content_already_in_this_request) {
142
+			return;
143
+		}
144
+		EEH_Activation::$_initialized_db_content_already_in_this_request = true;
145
+
146
+		EEH_Activation::initialize_system_questions();
147
+		EEH_Activation::insert_default_status_codes();
148
+		EEH_Activation::generate_default_message_templates();
149
+		EEH_Activation::create_no_ticket_prices_array();
150
+		EE_Registry::instance()->CAP->init_caps();
151
+
152
+		EEH_Activation::validate_messages_system();
153
+		EEH_Activation::insert_default_payment_methods();
154
+		//in case we've
155
+		EEH_Activation::remove_cron_tasks();
156
+		EEH_Activation::create_cron_tasks();
157
+		// remove all TXN locks since that is being done via extra meta now
158
+		delete_option('ee_locked_transactions');
159
+		//also, check for CAF default db content
160
+		do_action('AHEE__EEH_Activation__initialize_db_content');
161
+		//also: EEM_Gateways::load_all_gateways() outputs a lot of success messages
162
+		//which users really won't care about on initial activation
163
+		EE_Error::overwrite_success();
164
+	}
165
+
166
+
167
+	/**
168
+	 * Returns an array of cron tasks. Array values are the actions fired by the cron tasks (the "hooks"),
169
+	 * values are the frequency (the "recurrence"). See http://codex.wordpress.org/Function_Reference/wp_schedule_event
170
+	 * If the cron task should NO longer be used, it should have a value of EEH_Activation::cron_task_no_longer_in_use
171
+	 * (null)
172
+	 *
173
+	 * @param string $which_to_include can be 'current' (ones that are currently in use),
174
+	 *                                 'old' (only returns ones that should no longer be used),or 'all',
175
+	 * @return array
176
+	 * @throws \EE_Error
177
+	 */
178
+	public static function get_cron_tasks($which_to_include)
179
+	{
180
+		$cron_tasks = apply_filters(
181
+			'FHEE__EEH_Activation__get_cron_tasks',
182
+			array(
183
+				'AHEE__EE_Cron_Tasks__clean_up_junk_transactions'      => 'hourly',
184 184
 //				'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions' => EEH_Activation::cron_task_no_longer_in_use, actually this is still in use
185
-                'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use,
186
-                //there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates
187
-            )
188
-        );
189
-        if ($which_to_include === 'old') {
190
-            $cron_tasks = array_filter(
191
-                $cron_tasks,
192
-                function ($value) {
193
-                    return $value === EEH_Activation::cron_task_no_longer_in_use;
194
-                }
195
-            );
196
-        } elseif ($which_to_include === 'current') {
197
-            $cron_tasks = array_filter($cron_tasks);
198
-        } elseif (WP_DEBUG && $which_to_include !== 'all') {
199
-            throw new EE_Error(
200
-                sprintf(
201
-                    __(
202
-                        'Invalid argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".',
203
-                        'event_espresso'
204
-                    ),
205
-                    $which_to_include
206
-                )
207
-            );
208
-        }
209
-        return $cron_tasks;
210
-    }
211
-
212
-
213
-    /**
214
-     * Ensure cron tasks are setup (the removal of crons should be done by remove_crons())
215
-     *
216
-     * @throws \EE_Error
217
-     */
218
-    public static function create_cron_tasks()
219
-    {
220
-
221
-        foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) {
222
-            if (! wp_next_scheduled($hook_name)) {
223
-                /**
224
-                 * This allows client code to define the initial start timestamp for this schedule.
225
-                 */
226
-                if (is_array($frequency)
227
-                    && count($frequency) === 2
228
-                    && isset($frequency[0], $frequency[1])
229
-                ) {
230
-                    $start_timestamp = $frequency[0];
231
-                    $frequency = $frequency[1];
232
-                } else {
233
-                    $start_timestamp = time();
234
-                }
235
-                wp_schedule_event($start_timestamp, $frequency, $hook_name);
236
-            }
237
-        }
238
-
239
-    }
240
-
241
-
242
-    /**
243
-     * Remove the currently-existing and now-removed cron tasks.
244
-     *
245
-     * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones
246
-     * @throws \EE_Error
247
-     */
248
-    public static function remove_cron_tasks($remove_all = true)
249
-    {
250
-        $cron_tasks_to_remove = $remove_all ? 'all' : 'old';
251
-        $crons                = _get_cron_array();
252
-        $crons                = is_array($crons) ? $crons : array();
253
-        /* reminder of what $crons look like:
185
+				'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use,
186
+				//there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates
187
+			)
188
+		);
189
+		if ($which_to_include === 'old') {
190
+			$cron_tasks = array_filter(
191
+				$cron_tasks,
192
+				function ($value) {
193
+					return $value === EEH_Activation::cron_task_no_longer_in_use;
194
+				}
195
+			);
196
+		} elseif ($which_to_include === 'current') {
197
+			$cron_tasks = array_filter($cron_tasks);
198
+		} elseif (WP_DEBUG && $which_to_include !== 'all') {
199
+			throw new EE_Error(
200
+				sprintf(
201
+					__(
202
+						'Invalid argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".',
203
+						'event_espresso'
204
+					),
205
+					$which_to_include
206
+				)
207
+			);
208
+		}
209
+		return $cron_tasks;
210
+	}
211
+
212
+
213
+	/**
214
+	 * Ensure cron tasks are setup (the removal of crons should be done by remove_crons())
215
+	 *
216
+	 * @throws \EE_Error
217
+	 */
218
+	public static function create_cron_tasks()
219
+	{
220
+
221
+		foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) {
222
+			if (! wp_next_scheduled($hook_name)) {
223
+				/**
224
+				 * This allows client code to define the initial start timestamp for this schedule.
225
+				 */
226
+				if (is_array($frequency)
227
+					&& count($frequency) === 2
228
+					&& isset($frequency[0], $frequency[1])
229
+				) {
230
+					$start_timestamp = $frequency[0];
231
+					$frequency = $frequency[1];
232
+				} else {
233
+					$start_timestamp = time();
234
+				}
235
+				wp_schedule_event($start_timestamp, $frequency, $hook_name);
236
+			}
237
+		}
238
+
239
+	}
240
+
241
+
242
+	/**
243
+	 * Remove the currently-existing and now-removed cron tasks.
244
+	 *
245
+	 * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones
246
+	 * @throws \EE_Error
247
+	 */
248
+	public static function remove_cron_tasks($remove_all = true)
249
+	{
250
+		$cron_tasks_to_remove = $remove_all ? 'all' : 'old';
251
+		$crons                = _get_cron_array();
252
+		$crons                = is_array($crons) ? $crons : array();
253
+		/* reminder of what $crons look like:
254 254
          * Top-level keys are timestamps, and their values are arrays.
255 255
          * The 2nd level arrays have keys with each of the cron task hook names to run at that time
256 256
          * and their values are arrays.
@@ -267,971 +267,971 @@  discard block
 block discarded – undo
267 267
          *					...
268 268
          *      ...
269 269
          */
270
-        $ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks($cron_tasks_to_remove);
271
-        foreach ($crons as $timestamp => $hooks_to_fire_at_time) {
272
-            if (is_array($hooks_to_fire_at_time)) {
273
-                foreach ($hooks_to_fire_at_time as $hook_name => $hook_actions) {
274
-                    if (isset($ee_cron_tasks_to_remove[$hook_name])
275
-                        && is_array($ee_cron_tasks_to_remove[$hook_name])
276
-                    ) {
277
-                        unset($crons[$timestamp][$hook_name]);
278
-                    }
279
-                }
280
-                //also take care of any empty cron timestamps.
281
-                if (empty($hooks_to_fire_at_time)) {
282
-                    unset($crons[$timestamp]);
283
-                }
284
-            }
285
-        }
286
-        _set_cron_array($crons);
287
-    }
288
-
289
-
290
-    /**
291
-     *    CPT_initialization
292
-     *    registers all EE CPTs ( Custom Post Types ) then flushes rewrite rules so that all endpoints exist
293
-     *
294
-     * @access public
295
-     * @static
296
-     * @return void
297
-     */
298
-    public static function CPT_initialization()
299
-    {
300
-        // register Custom Post Types
301
-        EE_Registry::instance()->load_core('Register_CPTs');
302
-        flush_rewrite_rules();
303
-    }
304
-
305
-
306
-
307
-    /**
308
-     *    reset_and_update_config
309
-     * The following code was moved over from EE_Config so that it will no longer run on every request.
310
-     * If there is old calendar config data saved, then it will get converted on activation.
311
-     * This was basically a DMS before we had DMS's, and will get removed after a few more versions.
312
-     *
313
-     * @access public
314
-     * @static
315
-     * @return void
316
-     */
317
-    public static function reset_and_update_config()
318
-    {
319
-        do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config'));
320
-        add_filter(
321
-            'FHEE__EE_Config___load_core_config__config_settings',
322
-            array('EEH_Activation', 'migrate_old_config_data'),
323
-            10,
324
-            3
325
-        );
326
-        //EE_Config::reset();
327
-        if (! EE_Config::logging_enabled()) {
328
-            delete_option(EE_Config::LOG_NAME);
329
-        }
330
-    }
331
-
332
-
333
-    /**
334
-     *    load_calendar_config
335
-     *
336
-     * @access    public
337
-     * @return    void
338
-     */
339
-    public static function load_calendar_config()
340
-    {
341
-        // grab array of all plugin folders and loop thru it
342
-        $plugins = glob(WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR);
343
-        if (empty($plugins)) {
344
-            return;
345
-        }
346
-        foreach ($plugins as $plugin_path) {
347
-            // grab plugin folder name from path
348
-            $plugin = basename($plugin_path);
349
-            // drill down to Espresso plugins
350
-            // then to calendar related plugins
351
-            if (
352
-                strpos($plugin, 'espresso') !== false
353
-                || strpos($plugin, 'Espresso') !== false
354
-                || strpos($plugin, 'ee4') !== false
355
-                || strpos($plugin, 'EE4') !== false
356
-                || strpos($plugin, 'calendar') !== false
357
-            ) {
358
-                // this is what we are looking for
359
-                $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php';
360
-                // does it exist in this folder ?
361
-                if (is_readable($calendar_config)) {
362
-                    // YEAH! let's load it
363
-                    require_once($calendar_config);
364
-                }
365
-            }
366
-        }
367
-    }
368
-
369
-
370
-
371
-    /**
372
-     *    _migrate_old_config_data
373
-     *
374
-     * @access    public
375
-     * @param array|stdClass $settings
376
-     * @param string         $config
377
-     * @param \EE_Config     $EE_Config
378
-     * @return \stdClass
379
-     */
380
-    public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config)
381
-    {
382
-        $convert_from_array = array('addons');
383
-        // in case old settings were saved as an array
384
-        if (is_array($settings) && in_array($config, $convert_from_array)) {
385
-            // convert existing settings to an object
386
-            $config_array = $settings;
387
-            $settings = new stdClass();
388
-            foreach ($config_array as $key => $value) {
389
-                if ($key === 'calendar' && class_exists('EE_Calendar_Config')) {
390
-                    $EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value);
391
-                } else {
392
-                    $settings->{$key} = $value;
393
-                }
394
-            }
395
-            add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true');
396
-        }
397
-        return $settings;
398
-    }
399
-
400
-
401
-    /**
402
-     * deactivate_event_espresso
403
-     *
404
-     * @access public
405
-     * @static
406
-     * @return void
407
-     */
408
-    public static function deactivate_event_espresso()
409
-    {
410
-        // check permissions
411
-        if (current_user_can('activate_plugins')) {
412
-            deactivate_plugins(EE_PLUGIN_BASENAME, true);
413
-        }
414
-    }
415
-
416
-
417
-
418
-
419
-
420
-    /**
421
-     * verify_default_pages_exist
422
-     *
423
-     * @access public
424
-     * @static
425
-     * @return void
426
-     */
427
-    public static function verify_default_pages_exist()
428
-    {
429
-        $critical_page_problem = false;
430
-        $critical_pages = array(
431
-            array(
432
-                'id'   => 'reg_page_id',
433
-                'name' => __('Registration Checkout', 'event_espresso'),
434
-                'post' => null,
435
-                'code' => 'ESPRESSO_CHECKOUT',
436
-            ),
437
-            array(
438
-                'id'   => 'txn_page_id',
439
-                'name' => __('Transactions', 'event_espresso'),
440
-                'post' => null,
441
-                'code' => 'ESPRESSO_TXN_PAGE',
442
-            ),
443
-            array(
444
-                'id'   => 'thank_you_page_id',
445
-                'name' => __('Thank You', 'event_espresso'),
446
-                'post' => null,
447
-                'code' => 'ESPRESSO_THANK_YOU',
448
-            ),
449
-            array(
450
-                'id'   => 'cancel_page_id',
451
-                'name' => __('Registration Cancelled', 'event_espresso'),
452
-                'post' => null,
453
-                'code' => 'ESPRESSO_CANCELLED',
454
-            ),
455
-        );
456
-        $EE_Core_Config = EE_Registry::instance()->CFG->core;
457
-        foreach ($critical_pages as $critical_page) {
458
-            // is critical page ID set in config ?
459
-            if ($EE_Core_Config->{$critical_page['id']} !== false) {
460
-                // attempt to find post by ID
461
-                $critical_page['post'] = get_post($EE_Core_Config->{$critical_page['id']});
462
-            }
463
-            // no dice?
464
-            if ($critical_page['post'] === null) {
465
-                // attempt to find post by title
466
-                $critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']);
467
-                // still nothing?
468
-                if ($critical_page['post'] === null) {
469
-                    $critical_page = EEH_Activation::create_critical_page($critical_page);
470
-                    // REALLY? Still nothing ??!?!?
471
-                    if ($critical_page['post'] === null) {
472
-                        $msg = __(
473
-                            'The Event Espresso critical page configuration settings could not be updated.',
474
-                            'event_espresso'
475
-                        );
476
-                        EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
477
-                        break;
478
-                    }
479
-                }
480
-            }
481
-            // track post_shortcodes
482
-            if ($critical_page['post']) {
483
-                EEH_Activation::_track_critical_page_post_shortcodes($critical_page);
484
-            }
485
-            // check that Post ID matches critical page ID in config
486
-            if (
487
-                isset($critical_page['post']->ID)
488
-                && $critical_page['post']->ID !== $EE_Core_Config->{$critical_page['id']}
489
-            ) {
490
-                //update Config with post ID
491
-                $EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID;
492
-                if (! EE_Config::instance()->update_espresso_config(false, false)) {
493
-                    $msg = __(
494
-                        'The Event Espresso critical page configuration settings could not be updated.',
495
-                        'event_espresso'
496
-                    );
497
-                    EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
498
-                }
499
-            }
500
-            $critical_page_problem =
501
-                ! isset($critical_page['post']->post_status)
502
-                || $critical_page['post']->post_status !== 'publish'
503
-                || strpos($critical_page['post']->post_content, $critical_page['code']) === false
504
-                    ? true
505
-                    : $critical_page_problem;
506
-        }
507
-        if ($critical_page_problem) {
508
-            $msg = sprintf(
509
-                __(
510
-                    'A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.',
511
-                    'event_espresso'
512
-                ),
513
-                '<a href="'
514
-                . admin_url('admin.php?page=espresso_general_settings&action=critical_pages')
515
-                . '">'
516
-                . __('Event Espresso Critical Pages Settings', 'event_espresso')
517
-                . '</a>'
518
-            );
519
-            EE_Error::add_persistent_admin_notice('critical_page_problem', $msg);
520
-        }
521
-        if (EE_Error::has_notices()) {
522
-            EE_Error::get_notices(false, true, true);
523
-        }
524
-    }
525
-
526
-
527
-
528
-    /**
529
-     * Returns the first post which uses the specified shortcode
530
-     *
531
-     * @param string $ee_shortcode usually one of the critical pages shortcodes, eg
532
-     *                             ESPRESSO_THANK_YOU. So we will search fora post with the content
533
-     *                             "[ESPRESSO_THANK_YOU"
534
-     *                             (we don't search for the closing shortcode bracket because they might have added
535
-     *                             parameter to the shortcode
536
-     * @return WP_Post or NULl
537
-     */
538
-    public static function get_page_by_ee_shortcode($ee_shortcode)
539
-    {
540
-        global $wpdb;
541
-        $shortcode_and_opening_bracket = '[' . $ee_shortcode;
542
-        $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1");
543
-        if ($post_id) {
544
-            return get_post($post_id);
545
-        } else {
546
-            return null;
547
-        }
548
-    }
549
-
550
-
551
-    /**
552
-     *    This function generates a post for critical espresso pages
553
-     *
554
-     * @access public
555
-     * @static
556
-     * @param array $critical_page
557
-     * @return array
558
-     */
559
-    public static function create_critical_page($critical_page)
560
-    {
561
-
562
-        $post_args = array(
563
-            'post_title'     => $critical_page['name'],
564
-            'post_status'    => 'publish',
565
-            'post_type'      => 'page',
566
-            'comment_status' => 'closed',
567
-            'post_content'   => '[' . $critical_page['code'] . ']',
568
-        );
569
-
570
-        $post_id = wp_insert_post($post_args);
571
-        if (! $post_id) {
572
-            $msg = sprintf(
573
-                __('The Event Espresso  critical page entitled "%s" could not be created.', 'event_espresso'),
574
-                $critical_page['name']
575
-            );
576
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
577
-            return $critical_page;
578
-        }
579
-        // get newly created post's details
580
-        if (! $critical_page['post'] = get_post($post_id)) {
581
-            $msg = sprintf(
582
-                __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'),
583
-                $critical_page['name']
584
-            );
585
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
586
-        }
587
-
588
-        return $critical_page;
589
-
590
-    }
591
-
592
-
593
-
594
-
595
-
596
-    /**
597
-     *    This function adds a critical page's shortcode to the post_shortcodes array
598
-     *
599
-     * @access private
600
-     * @static
601
-     * @param array $critical_page
602
-     * @return void
603
-     */
604
-    private static function _track_critical_page_post_shortcodes($critical_page = array())
605
-    {
606
-        // check the goods
607
-        if ( ! $critical_page['post'] instanceof WP_Post) {
608
-            $msg = sprintf(
609
-                __(
610
-                    'The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.',
611
-                    'event_espresso'
612
-                ),
613
-                $critical_page['name']
614
-            );
615
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
616
-            return;
617
-        }
618
-        $EE_Core_Config = EE_Registry::instance()->CFG->core;
619
-        // map shortcode to post
620
-        $EE_Core_Config->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']] = $critical_page['post']->ID;
621
-        // and make sure it's NOT added to the WP "Posts Page"
622
-        // name of the WP Posts Page
623
-        $posts_page = EE_Config::get_page_for_posts();
624
-        if (isset($EE_Core_Config->post_shortcodes[$posts_page])) {
625
-            unset($EE_Core_Config->post_shortcodes[$posts_page][$critical_page['code']]);
626
-        }
627
-        if ($posts_page !== 'posts' && isset($EE_Core_Config->post_shortcodes['posts'])) {
628
-            unset($EE_Core_Config->post_shortcodes['posts'][$critical_page['code']]);
629
-        }
630
-        // update post_shortcode CFG
631
-        EE_Config::instance()->update_espresso_config(false, false);
632
-        // verify that saved ID in the config matches the ID for the post the shortcode is on
633
-        if (
634
-            EE_Registry::instance()->CFG->core->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']]
635
-            !== $critical_page['post']->ID
636
-        ) {
637
-            $msg = sprintf(
638
-                __(
639
-                    'The Event Espresso critical page shortcode for the %s page could not be configured properly.',
640
-                    'event_espresso'
641
-                ),
642
-                $critical_page['name']
643
-            );
644
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
645
-        }
646
-    }
647
-
648
-
649
-
650
-    /**
651
-     * Tries to find the oldest admin for this site.  If there are no admins for this site then return NULL.
652
-     * The role being used to check is filterable.
653
-     *
654
-     * @since  4.6.0
655
-     * @global WPDB $wpdb
656
-     * @return mixed null|int WP_user ID or NULL
657
-     */
658
-    public static function get_default_creator_id()
659
-    {
660
-        global $wpdb;
661
-        if ( ! empty(self::$_default_creator_id)) {
662
-            return self::$_default_creator_id;
663
-        }/**/
664
-        $role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator');
665
-        //let's allow pre_filtering for early exits by alternative methods for getting id.  We check for truthy result and if so then exit early.
666
-        $pre_filtered_id = apply_filters(
667
-            'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id',
668
-            false,
669
-            $role_to_check
670
-        );
671
-        if ($pre_filtered_id !== false) {
672
-            return (int)$pre_filtered_id;
673
-        }
674
-        $capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('capabilities');
675
-        $query = $wpdb->prepare(
676
-            "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1",
677
-            '%' . $role_to_check . '%'
678
-        );
679
-        $user_id = $wpdb->get_var($query);
680
-        $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id);
681
-        if ($user_id && (int)$user_id) {
682
-            self::$_default_creator_id = (int)$user_id;
683
-            return self::$_default_creator_id;
684
-        } else {
685
-            return null;
686
-        }
687
-    }
688
-
689
-
690
-
691
-    /**
692
-     * used by EE and EE addons during plugin activation to create tables.
693
-     * Its a wrapper for EventEspresso\core\services\database\TableManager::createTable,
694
-     * but includes extra logic regarding activations.
695
-     *
696
-     * @access public
697
-     * @static
698
-     * @param string  $table_name              without the $wpdb->prefix
699
-     * @param string  $sql                     SQL for creating the table (contents between brackets in an SQL create
700
-     *                                         table query)
701
-     * @param string  $engine                  like 'ENGINE=MyISAM' or 'ENGINE=InnoDB'
702
-     * @param boolean $drop_pre_existing_table set to TRUE when you want to make SURE the table is completely empty
703
-     *                                         and new once this function is done (ie, you really do want to CREATE a
704
-     *                                         table, and expect it to be empty once you're done) leave as FALSE when
705
-     *                                         you just want to verify the table exists and matches this definition
706
-     *                                         (and if it HAS data in it you want to leave it be)
707
-     * @return void
708
-     * @throws EE_Error if there are database errors
709
-     */
710
-    public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false)
711
-    {
712
-        if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', false, $table_name, $sql)) {
713
-            return;
714
-        }
715
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
716
-        if ( ! function_exists('dbDelta')) {
717
-            require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
718
-        }
719
-        $tableAnalysis = \EEH_Activation::getTableAnalysis();
720
-        $wp_table_name = $tableAnalysis->ensureTableNameHasPrefix($table_name);
721
-        // do we need to first delete an existing version of this table ?
722
-        if ($drop_pre_existing_table && $tableAnalysis->tableExists($wp_table_name)) {
723
-            // ok, delete the table... but ONLY if it's empty
724
-            $deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name);
725
-            // table is NOT empty, are you SURE you want to delete this table ???
726
-            if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) {
727
-                \EEH_Activation::getTableManager()->dropTable($wp_table_name);
728
-            } else if ( ! $deleted_safely) {
729
-                // so we should be more cautious rather than just dropping tables so easily
730
-                error_log(
731
-                    sprintf(
732
-                        __(
733
-                            'It appears that database table "%1$s" exists when it shouldn\'t, and therefore may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend: %2$s 1. create a new COMPLETE backup of your database, %2$s 2. delete ALL tables from your database, %2$s 3. restore to your previous backup. %2$s If, however, you have not restored to a backup, then somehow your "%3$s" WordPress option could not be read. You can probably ignore this message, but should investigate why that option is being removed.',
734
-                            'event_espresso'
735
-                        ),
736
-                        $wp_table_name,
737
-                        '<br/>',
738
-                        'espresso_db_update'
739
-                    )
740
-                );
741
-            }
742
-        }
743
-        $engine = str_replace('ENGINE=', '', $engine);
744
-        \EEH_Activation::getTableManager()->createTable($table_name, $sql, $engine);
745
-    }
746
-
747
-
748
-
749
-    /**
750
-     *    add_column_if_it_doesn't_exist
751
-     *    Checks if this column already exists on the specified table. Handy for addons which want to add a column
752
-     *
753
-     * @access     public
754
-     * @static
755
-     * @deprecated instead use TableManager::addColumn()
756
-     * @param string $table_name  (without "wp_", eg "esp_attendee"
757
-     * @param string $column_name
758
-     * @param string $column_info if your SQL were 'ALTER TABLE table_name ADD price VARCHAR(10)', this would be
759
-     *                            'VARCHAR(10)'
760
-     * @return bool|int
761
-     */
762
-    public static function add_column_if_it_doesnt_exist(
763
-        $table_name,
764
-        $column_name,
765
-        $column_info = 'INT UNSIGNED NOT NULL'
766
-    ) {
767
-        return \EEH_Activation::getTableManager()->addColumn($table_name, $column_name, $column_info);
768
-    }
769
-
770
-
771
-    /**
772
-     * get_fields_on_table
773
-     * Gets all the fields on the database table.
774
-     *
775
-     * @access     public
776
-     * @deprecated instead use TableManager::getTableColumns()
777
-     * @static
778
-     * @param string $table_name , without prefixed $wpdb->prefix
779
-     * @return array of database column names
780
-     */
781
-    public static function get_fields_on_table($table_name = null)
782
-    {
783
-        return \EEH_Activation::getTableManager()->getTableColumns($table_name);
784
-    }
785
-
786
-
787
-    /**
788
-     * db_table_is_empty
789
-     *
790
-     * @access     public\
791
-     * @deprecated instead use TableAnalysis::tableIsEmpty()
792
-     * @static
793
-     * @param string $table_name
794
-     * @return bool
795
-     */
796
-    public static function db_table_is_empty($table_name)
797
-    {
798
-        return \EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name);
799
-    }
800
-
801
-
802
-    /**
803
-     * delete_db_table_if_empty
804
-     *
805
-     * @access public
806
-     * @static
807
-     * @param string $table_name
808
-     * @return bool | int
809
-     */
810
-    public static function delete_db_table_if_empty($table_name)
811
-    {
812
-        if (\EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name)) {
813
-            return \EEH_Activation::getTableManager()->dropTable($table_name);
814
-        }
815
-        return false;
816
-    }
817
-
818
-
819
-    /**
820
-     * delete_unused_db_table
821
-     *
822
-     * @access     public
823
-     * @static
824
-     * @deprecated instead use TableManager::dropTable()
825
-     * @param string $table_name
826
-     * @return bool | int
827
-     */
828
-    public static function delete_unused_db_table($table_name)
829
-    {
830
-        return \EEH_Activation::getTableManager()->dropTable($table_name);
831
-    }
832
-
833
-
834
-    /**
835
-     * drop_index
836
-     *
837
-     * @access     public
838
-     * @static
839
-     * @deprecated instead use TableManager::dropIndex()
840
-     * @param string $table_name
841
-     * @param string $index_name
842
-     * @return bool | int
843
-     */
844
-    public static function drop_index($table_name, $index_name)
845
-    {
846
-        return \EEH_Activation::getTableManager()->dropIndex($table_name, $index_name);
847
-    }
848
-
849
-
850
-
851
-    /**
852
-     * create_database_tables
853
-     *
854
-     * @access public
855
-     * @static
856
-     * @throws EE_Error
857
-     * @return boolean success (whether database is setup properly or not)
858
-     */
859
-    public static function create_database_tables()
860
-    {
861
-        EE_Registry::instance()->load_core('Data_Migration_Manager');
862
-        //find the migration script that sets the database to be compatible with the code
863
-        $dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms();
864
-        if ($dms_name) {
865
-            $current_data_migration_script = EE_Registry::instance()->load_dms($dms_name);
866
-            $current_data_migration_script->set_migrating(false);
867
-            $current_data_migration_script->schema_changes_before_migration();
868
-            $current_data_migration_script->schema_changes_after_migration();
869
-            if ($current_data_migration_script->get_errors()) {
870
-                if (WP_DEBUG) {
871
-                    foreach ($current_data_migration_script->get_errors() as $error) {
872
-                        EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
873
-                    }
874
-                } else {
875
-                    EE_Error::add_error(
876
-                        __(
877
-                            'There were errors creating the Event Espresso database tables and Event Espresso has been 
270
+		$ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks($cron_tasks_to_remove);
271
+		foreach ($crons as $timestamp => $hooks_to_fire_at_time) {
272
+			if (is_array($hooks_to_fire_at_time)) {
273
+				foreach ($hooks_to_fire_at_time as $hook_name => $hook_actions) {
274
+					if (isset($ee_cron_tasks_to_remove[$hook_name])
275
+						&& is_array($ee_cron_tasks_to_remove[$hook_name])
276
+					) {
277
+						unset($crons[$timestamp][$hook_name]);
278
+					}
279
+				}
280
+				//also take care of any empty cron timestamps.
281
+				if (empty($hooks_to_fire_at_time)) {
282
+					unset($crons[$timestamp]);
283
+				}
284
+			}
285
+		}
286
+		_set_cron_array($crons);
287
+	}
288
+
289
+
290
+	/**
291
+	 *    CPT_initialization
292
+	 *    registers all EE CPTs ( Custom Post Types ) then flushes rewrite rules so that all endpoints exist
293
+	 *
294
+	 * @access public
295
+	 * @static
296
+	 * @return void
297
+	 */
298
+	public static function CPT_initialization()
299
+	{
300
+		// register Custom Post Types
301
+		EE_Registry::instance()->load_core('Register_CPTs');
302
+		flush_rewrite_rules();
303
+	}
304
+
305
+
306
+
307
+	/**
308
+	 *    reset_and_update_config
309
+	 * The following code was moved over from EE_Config so that it will no longer run on every request.
310
+	 * If there is old calendar config data saved, then it will get converted on activation.
311
+	 * This was basically a DMS before we had DMS's, and will get removed after a few more versions.
312
+	 *
313
+	 * @access public
314
+	 * @static
315
+	 * @return void
316
+	 */
317
+	public static function reset_and_update_config()
318
+	{
319
+		do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config'));
320
+		add_filter(
321
+			'FHEE__EE_Config___load_core_config__config_settings',
322
+			array('EEH_Activation', 'migrate_old_config_data'),
323
+			10,
324
+			3
325
+		);
326
+		//EE_Config::reset();
327
+		if (! EE_Config::logging_enabled()) {
328
+			delete_option(EE_Config::LOG_NAME);
329
+		}
330
+	}
331
+
332
+
333
+	/**
334
+	 *    load_calendar_config
335
+	 *
336
+	 * @access    public
337
+	 * @return    void
338
+	 */
339
+	public static function load_calendar_config()
340
+	{
341
+		// grab array of all plugin folders and loop thru it
342
+		$plugins = glob(WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR);
343
+		if (empty($plugins)) {
344
+			return;
345
+		}
346
+		foreach ($plugins as $plugin_path) {
347
+			// grab plugin folder name from path
348
+			$plugin = basename($plugin_path);
349
+			// drill down to Espresso plugins
350
+			// then to calendar related plugins
351
+			if (
352
+				strpos($plugin, 'espresso') !== false
353
+				|| strpos($plugin, 'Espresso') !== false
354
+				|| strpos($plugin, 'ee4') !== false
355
+				|| strpos($plugin, 'EE4') !== false
356
+				|| strpos($plugin, 'calendar') !== false
357
+			) {
358
+				// this is what we are looking for
359
+				$calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php';
360
+				// does it exist in this folder ?
361
+				if (is_readable($calendar_config)) {
362
+					// YEAH! let's load it
363
+					require_once($calendar_config);
364
+				}
365
+			}
366
+		}
367
+	}
368
+
369
+
370
+
371
+	/**
372
+	 *    _migrate_old_config_data
373
+	 *
374
+	 * @access    public
375
+	 * @param array|stdClass $settings
376
+	 * @param string         $config
377
+	 * @param \EE_Config     $EE_Config
378
+	 * @return \stdClass
379
+	 */
380
+	public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config)
381
+	{
382
+		$convert_from_array = array('addons');
383
+		// in case old settings were saved as an array
384
+		if (is_array($settings) && in_array($config, $convert_from_array)) {
385
+			// convert existing settings to an object
386
+			$config_array = $settings;
387
+			$settings = new stdClass();
388
+			foreach ($config_array as $key => $value) {
389
+				if ($key === 'calendar' && class_exists('EE_Calendar_Config')) {
390
+					$EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value);
391
+				} else {
392
+					$settings->{$key} = $value;
393
+				}
394
+			}
395
+			add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true');
396
+		}
397
+		return $settings;
398
+	}
399
+
400
+
401
+	/**
402
+	 * deactivate_event_espresso
403
+	 *
404
+	 * @access public
405
+	 * @static
406
+	 * @return void
407
+	 */
408
+	public static function deactivate_event_espresso()
409
+	{
410
+		// check permissions
411
+		if (current_user_can('activate_plugins')) {
412
+			deactivate_plugins(EE_PLUGIN_BASENAME, true);
413
+		}
414
+	}
415
+
416
+
417
+
418
+
419
+
420
+	/**
421
+	 * verify_default_pages_exist
422
+	 *
423
+	 * @access public
424
+	 * @static
425
+	 * @return void
426
+	 */
427
+	public static function verify_default_pages_exist()
428
+	{
429
+		$critical_page_problem = false;
430
+		$critical_pages = array(
431
+			array(
432
+				'id'   => 'reg_page_id',
433
+				'name' => __('Registration Checkout', 'event_espresso'),
434
+				'post' => null,
435
+				'code' => 'ESPRESSO_CHECKOUT',
436
+			),
437
+			array(
438
+				'id'   => 'txn_page_id',
439
+				'name' => __('Transactions', 'event_espresso'),
440
+				'post' => null,
441
+				'code' => 'ESPRESSO_TXN_PAGE',
442
+			),
443
+			array(
444
+				'id'   => 'thank_you_page_id',
445
+				'name' => __('Thank You', 'event_espresso'),
446
+				'post' => null,
447
+				'code' => 'ESPRESSO_THANK_YOU',
448
+			),
449
+			array(
450
+				'id'   => 'cancel_page_id',
451
+				'name' => __('Registration Cancelled', 'event_espresso'),
452
+				'post' => null,
453
+				'code' => 'ESPRESSO_CANCELLED',
454
+			),
455
+		);
456
+		$EE_Core_Config = EE_Registry::instance()->CFG->core;
457
+		foreach ($critical_pages as $critical_page) {
458
+			// is critical page ID set in config ?
459
+			if ($EE_Core_Config->{$critical_page['id']} !== false) {
460
+				// attempt to find post by ID
461
+				$critical_page['post'] = get_post($EE_Core_Config->{$critical_page['id']});
462
+			}
463
+			// no dice?
464
+			if ($critical_page['post'] === null) {
465
+				// attempt to find post by title
466
+				$critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']);
467
+				// still nothing?
468
+				if ($critical_page['post'] === null) {
469
+					$critical_page = EEH_Activation::create_critical_page($critical_page);
470
+					// REALLY? Still nothing ??!?!?
471
+					if ($critical_page['post'] === null) {
472
+						$msg = __(
473
+							'The Event Espresso critical page configuration settings could not be updated.',
474
+							'event_espresso'
475
+						);
476
+						EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
477
+						break;
478
+					}
479
+				}
480
+			}
481
+			// track post_shortcodes
482
+			if ($critical_page['post']) {
483
+				EEH_Activation::_track_critical_page_post_shortcodes($critical_page);
484
+			}
485
+			// check that Post ID matches critical page ID in config
486
+			if (
487
+				isset($critical_page['post']->ID)
488
+				&& $critical_page['post']->ID !== $EE_Core_Config->{$critical_page['id']}
489
+			) {
490
+				//update Config with post ID
491
+				$EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID;
492
+				if (! EE_Config::instance()->update_espresso_config(false, false)) {
493
+					$msg = __(
494
+						'The Event Espresso critical page configuration settings could not be updated.',
495
+						'event_espresso'
496
+					);
497
+					EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
498
+				}
499
+			}
500
+			$critical_page_problem =
501
+				! isset($critical_page['post']->post_status)
502
+				|| $critical_page['post']->post_status !== 'publish'
503
+				|| strpos($critical_page['post']->post_content, $critical_page['code']) === false
504
+					? true
505
+					: $critical_page_problem;
506
+		}
507
+		if ($critical_page_problem) {
508
+			$msg = sprintf(
509
+				__(
510
+					'A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.',
511
+					'event_espresso'
512
+				),
513
+				'<a href="'
514
+				. admin_url('admin.php?page=espresso_general_settings&action=critical_pages')
515
+				. '">'
516
+				. __('Event Espresso Critical Pages Settings', 'event_espresso')
517
+				. '</a>'
518
+			);
519
+			EE_Error::add_persistent_admin_notice('critical_page_problem', $msg);
520
+		}
521
+		if (EE_Error::has_notices()) {
522
+			EE_Error::get_notices(false, true, true);
523
+		}
524
+	}
525
+
526
+
527
+
528
+	/**
529
+	 * Returns the first post which uses the specified shortcode
530
+	 *
531
+	 * @param string $ee_shortcode usually one of the critical pages shortcodes, eg
532
+	 *                             ESPRESSO_THANK_YOU. So we will search fora post with the content
533
+	 *                             "[ESPRESSO_THANK_YOU"
534
+	 *                             (we don't search for the closing shortcode bracket because they might have added
535
+	 *                             parameter to the shortcode
536
+	 * @return WP_Post or NULl
537
+	 */
538
+	public static function get_page_by_ee_shortcode($ee_shortcode)
539
+	{
540
+		global $wpdb;
541
+		$shortcode_and_opening_bracket = '[' . $ee_shortcode;
542
+		$post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1");
543
+		if ($post_id) {
544
+			return get_post($post_id);
545
+		} else {
546
+			return null;
547
+		}
548
+	}
549
+
550
+
551
+	/**
552
+	 *    This function generates a post for critical espresso pages
553
+	 *
554
+	 * @access public
555
+	 * @static
556
+	 * @param array $critical_page
557
+	 * @return array
558
+	 */
559
+	public static function create_critical_page($critical_page)
560
+	{
561
+
562
+		$post_args = array(
563
+			'post_title'     => $critical_page['name'],
564
+			'post_status'    => 'publish',
565
+			'post_type'      => 'page',
566
+			'comment_status' => 'closed',
567
+			'post_content'   => '[' . $critical_page['code'] . ']',
568
+		);
569
+
570
+		$post_id = wp_insert_post($post_args);
571
+		if (! $post_id) {
572
+			$msg = sprintf(
573
+				__('The Event Espresso  critical page entitled "%s" could not be created.', 'event_espresso'),
574
+				$critical_page['name']
575
+			);
576
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
577
+			return $critical_page;
578
+		}
579
+		// get newly created post's details
580
+		if (! $critical_page['post'] = get_post($post_id)) {
581
+			$msg = sprintf(
582
+				__('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'),
583
+				$critical_page['name']
584
+			);
585
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
586
+		}
587
+
588
+		return $critical_page;
589
+
590
+	}
591
+
592
+
593
+
594
+
595
+
596
+	/**
597
+	 *    This function adds a critical page's shortcode to the post_shortcodes array
598
+	 *
599
+	 * @access private
600
+	 * @static
601
+	 * @param array $critical_page
602
+	 * @return void
603
+	 */
604
+	private static function _track_critical_page_post_shortcodes($critical_page = array())
605
+	{
606
+		// check the goods
607
+		if ( ! $critical_page['post'] instanceof WP_Post) {
608
+			$msg = sprintf(
609
+				__(
610
+					'The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.',
611
+					'event_espresso'
612
+				),
613
+				$critical_page['name']
614
+			);
615
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
616
+			return;
617
+		}
618
+		$EE_Core_Config = EE_Registry::instance()->CFG->core;
619
+		// map shortcode to post
620
+		$EE_Core_Config->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']] = $critical_page['post']->ID;
621
+		// and make sure it's NOT added to the WP "Posts Page"
622
+		// name of the WP Posts Page
623
+		$posts_page = EE_Config::get_page_for_posts();
624
+		if (isset($EE_Core_Config->post_shortcodes[$posts_page])) {
625
+			unset($EE_Core_Config->post_shortcodes[$posts_page][$critical_page['code']]);
626
+		}
627
+		if ($posts_page !== 'posts' && isset($EE_Core_Config->post_shortcodes['posts'])) {
628
+			unset($EE_Core_Config->post_shortcodes['posts'][$critical_page['code']]);
629
+		}
630
+		// update post_shortcode CFG
631
+		EE_Config::instance()->update_espresso_config(false, false);
632
+		// verify that saved ID in the config matches the ID for the post the shortcode is on
633
+		if (
634
+			EE_Registry::instance()->CFG->core->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']]
635
+			!== $critical_page['post']->ID
636
+		) {
637
+			$msg = sprintf(
638
+				__(
639
+					'The Event Espresso critical page shortcode for the %s page could not be configured properly.',
640
+					'event_espresso'
641
+				),
642
+				$critical_page['name']
643
+			);
644
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
645
+		}
646
+	}
647
+
648
+
649
+
650
+	/**
651
+	 * Tries to find the oldest admin for this site.  If there are no admins for this site then return NULL.
652
+	 * The role being used to check is filterable.
653
+	 *
654
+	 * @since  4.6.0
655
+	 * @global WPDB $wpdb
656
+	 * @return mixed null|int WP_user ID or NULL
657
+	 */
658
+	public static function get_default_creator_id()
659
+	{
660
+		global $wpdb;
661
+		if ( ! empty(self::$_default_creator_id)) {
662
+			return self::$_default_creator_id;
663
+		}/**/
664
+		$role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator');
665
+		//let's allow pre_filtering for early exits by alternative methods for getting id.  We check for truthy result and if so then exit early.
666
+		$pre_filtered_id = apply_filters(
667
+			'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id',
668
+			false,
669
+			$role_to_check
670
+		);
671
+		if ($pre_filtered_id !== false) {
672
+			return (int)$pre_filtered_id;
673
+		}
674
+		$capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('capabilities');
675
+		$query = $wpdb->prepare(
676
+			"SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1",
677
+			'%' . $role_to_check . '%'
678
+		);
679
+		$user_id = $wpdb->get_var($query);
680
+		$user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id);
681
+		if ($user_id && (int)$user_id) {
682
+			self::$_default_creator_id = (int)$user_id;
683
+			return self::$_default_creator_id;
684
+		} else {
685
+			return null;
686
+		}
687
+	}
688
+
689
+
690
+
691
+	/**
692
+	 * used by EE and EE addons during plugin activation to create tables.
693
+	 * Its a wrapper for EventEspresso\core\services\database\TableManager::createTable,
694
+	 * but includes extra logic regarding activations.
695
+	 *
696
+	 * @access public
697
+	 * @static
698
+	 * @param string  $table_name              without the $wpdb->prefix
699
+	 * @param string  $sql                     SQL for creating the table (contents between brackets in an SQL create
700
+	 *                                         table query)
701
+	 * @param string  $engine                  like 'ENGINE=MyISAM' or 'ENGINE=InnoDB'
702
+	 * @param boolean $drop_pre_existing_table set to TRUE when you want to make SURE the table is completely empty
703
+	 *                                         and new once this function is done (ie, you really do want to CREATE a
704
+	 *                                         table, and expect it to be empty once you're done) leave as FALSE when
705
+	 *                                         you just want to verify the table exists and matches this definition
706
+	 *                                         (and if it HAS data in it you want to leave it be)
707
+	 * @return void
708
+	 * @throws EE_Error if there are database errors
709
+	 */
710
+	public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false)
711
+	{
712
+		if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', false, $table_name, $sql)) {
713
+			return;
714
+		}
715
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
716
+		if ( ! function_exists('dbDelta')) {
717
+			require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
718
+		}
719
+		$tableAnalysis = \EEH_Activation::getTableAnalysis();
720
+		$wp_table_name = $tableAnalysis->ensureTableNameHasPrefix($table_name);
721
+		// do we need to first delete an existing version of this table ?
722
+		if ($drop_pre_existing_table && $tableAnalysis->tableExists($wp_table_name)) {
723
+			// ok, delete the table... but ONLY if it's empty
724
+			$deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name);
725
+			// table is NOT empty, are you SURE you want to delete this table ???
726
+			if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) {
727
+				\EEH_Activation::getTableManager()->dropTable($wp_table_name);
728
+			} else if ( ! $deleted_safely) {
729
+				// so we should be more cautious rather than just dropping tables so easily
730
+				error_log(
731
+					sprintf(
732
+						__(
733
+							'It appears that database table "%1$s" exists when it shouldn\'t, and therefore may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend: %2$s 1. create a new COMPLETE backup of your database, %2$s 2. delete ALL tables from your database, %2$s 3. restore to your previous backup. %2$s If, however, you have not restored to a backup, then somehow your "%3$s" WordPress option could not be read. You can probably ignore this message, but should investigate why that option is being removed.',
734
+							'event_espresso'
735
+						),
736
+						$wp_table_name,
737
+						'<br/>',
738
+						'espresso_db_update'
739
+					)
740
+				);
741
+			}
742
+		}
743
+		$engine = str_replace('ENGINE=', '', $engine);
744
+		\EEH_Activation::getTableManager()->createTable($table_name, $sql, $engine);
745
+	}
746
+
747
+
748
+
749
+	/**
750
+	 *    add_column_if_it_doesn't_exist
751
+	 *    Checks if this column already exists on the specified table. Handy for addons which want to add a column
752
+	 *
753
+	 * @access     public
754
+	 * @static
755
+	 * @deprecated instead use TableManager::addColumn()
756
+	 * @param string $table_name  (without "wp_", eg "esp_attendee"
757
+	 * @param string $column_name
758
+	 * @param string $column_info if your SQL were 'ALTER TABLE table_name ADD price VARCHAR(10)', this would be
759
+	 *                            'VARCHAR(10)'
760
+	 * @return bool|int
761
+	 */
762
+	public static function add_column_if_it_doesnt_exist(
763
+		$table_name,
764
+		$column_name,
765
+		$column_info = 'INT UNSIGNED NOT NULL'
766
+	) {
767
+		return \EEH_Activation::getTableManager()->addColumn($table_name, $column_name, $column_info);
768
+	}
769
+
770
+
771
+	/**
772
+	 * get_fields_on_table
773
+	 * Gets all the fields on the database table.
774
+	 *
775
+	 * @access     public
776
+	 * @deprecated instead use TableManager::getTableColumns()
777
+	 * @static
778
+	 * @param string $table_name , without prefixed $wpdb->prefix
779
+	 * @return array of database column names
780
+	 */
781
+	public static function get_fields_on_table($table_name = null)
782
+	{
783
+		return \EEH_Activation::getTableManager()->getTableColumns($table_name);
784
+	}
785
+
786
+
787
+	/**
788
+	 * db_table_is_empty
789
+	 *
790
+	 * @access     public\
791
+	 * @deprecated instead use TableAnalysis::tableIsEmpty()
792
+	 * @static
793
+	 * @param string $table_name
794
+	 * @return bool
795
+	 */
796
+	public static function db_table_is_empty($table_name)
797
+	{
798
+		return \EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name);
799
+	}
800
+
801
+
802
+	/**
803
+	 * delete_db_table_if_empty
804
+	 *
805
+	 * @access public
806
+	 * @static
807
+	 * @param string $table_name
808
+	 * @return bool | int
809
+	 */
810
+	public static function delete_db_table_if_empty($table_name)
811
+	{
812
+		if (\EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name)) {
813
+			return \EEH_Activation::getTableManager()->dropTable($table_name);
814
+		}
815
+		return false;
816
+	}
817
+
818
+
819
+	/**
820
+	 * delete_unused_db_table
821
+	 *
822
+	 * @access     public
823
+	 * @static
824
+	 * @deprecated instead use TableManager::dropTable()
825
+	 * @param string $table_name
826
+	 * @return bool | int
827
+	 */
828
+	public static function delete_unused_db_table($table_name)
829
+	{
830
+		return \EEH_Activation::getTableManager()->dropTable($table_name);
831
+	}
832
+
833
+
834
+	/**
835
+	 * drop_index
836
+	 *
837
+	 * @access     public
838
+	 * @static
839
+	 * @deprecated instead use TableManager::dropIndex()
840
+	 * @param string $table_name
841
+	 * @param string $index_name
842
+	 * @return bool | int
843
+	 */
844
+	public static function drop_index($table_name, $index_name)
845
+	{
846
+		return \EEH_Activation::getTableManager()->dropIndex($table_name, $index_name);
847
+	}
848
+
849
+
850
+
851
+	/**
852
+	 * create_database_tables
853
+	 *
854
+	 * @access public
855
+	 * @static
856
+	 * @throws EE_Error
857
+	 * @return boolean success (whether database is setup properly or not)
858
+	 */
859
+	public static function create_database_tables()
860
+	{
861
+		EE_Registry::instance()->load_core('Data_Migration_Manager');
862
+		//find the migration script that sets the database to be compatible with the code
863
+		$dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms();
864
+		if ($dms_name) {
865
+			$current_data_migration_script = EE_Registry::instance()->load_dms($dms_name);
866
+			$current_data_migration_script->set_migrating(false);
867
+			$current_data_migration_script->schema_changes_before_migration();
868
+			$current_data_migration_script->schema_changes_after_migration();
869
+			if ($current_data_migration_script->get_errors()) {
870
+				if (WP_DEBUG) {
871
+					foreach ($current_data_migration_script->get_errors() as $error) {
872
+						EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
873
+					}
874
+				} else {
875
+					EE_Error::add_error(
876
+						__(
877
+							'There were errors creating the Event Espresso database tables and Event Espresso has been 
878 878
                             deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.',
879
-                            'event_espresso'
880
-                        )
881
-                    );
882
-                }
883
-                return false;
884
-            }
885
-            EE_Data_Migration_Manager::instance()->update_current_database_state_to();
886
-        } else {
887
-            EE_Error::add_error(
888
-                __(
889
-                    'Could not determine most up-to-date data migration script from which to pull database schema
879
+							'event_espresso'
880
+						)
881
+					);
882
+				}
883
+				return false;
884
+			}
885
+			EE_Data_Migration_Manager::instance()->update_current_database_state_to();
886
+		} else {
887
+			EE_Error::add_error(
888
+				__(
889
+					'Could not determine most up-to-date data migration script from which to pull database schema
890 890
                      structure. So database is probably not setup properly',
891
-                    'event_espresso'
892
-                ),
893
-                __FILE__,
894
-                __FUNCTION__,
895
-                __LINE__
896
-            );
897
-            return false;
898
-        }
899
-        return true;
900
-    }
901
-
902
-
903
-
904
-    /**
905
-     * initialize_system_questions
906
-     *
907
-     * @access public
908
-     * @static
909
-     * @return void
910
-     */
911
-    public static function initialize_system_questions()
912
-    {
913
-        // QUESTION GROUPS
914
-        global $wpdb;
915
-        $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group');
916
-        $SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0";
917
-        // what we have
918
-        $question_groups = $wpdb->get_col($SQL);
919
-        // check the response
920
-        $question_groups = is_array($question_groups) ? $question_groups : array();
921
-        // what we should have
922
-        $QSG_systems = array(1, 2);
923
-        // loop thru what we should have and compare to what we have
924
-        foreach ($QSG_systems as $QSG_system) {
925
-            // reset values array
926
-            $QSG_values = array();
927
-            // if we don't have what we should have (but use $QST_system as as string because that's what we got from the db)
928
-            if (! in_array("$QSG_system", $question_groups)) {
929
-                // add it
930
-                switch ($QSG_system) {
931
-                    case 1:
932
-                        $QSG_values = array(
933
-                            'QSG_name'            => __('Personal Information', 'event_espresso'),
934
-                            'QSG_identifier'      => 'personal-information-' . time(),
935
-                            'QSG_desc'            => '',
936
-                            'QSG_order'           => 1,
937
-                            'QSG_show_group_name' => 1,
938
-                            'QSG_show_group_desc' => 1,
939
-                            'QSG_system'          => EEM_Question_Group::system_personal,
940
-                            'QSG_deleted'         => 0,
941
-                        );
942
-                        break;
943
-                    case 2:
944
-                        $QSG_values = array(
945
-                            'QSG_name'            => __('Address Information', 'event_espresso'),
946
-                            'QSG_identifier'      => 'address-information-' . time(),
947
-                            'QSG_desc'            => '',
948
-                            'QSG_order'           => 2,
949
-                            'QSG_show_group_name' => 1,
950
-                            'QSG_show_group_desc' => 1,
951
-                            'QSG_system'          => EEM_Question_Group::system_address,
952
-                            'QSG_deleted'         => 0,
953
-                        );
954
-                        break;
955
-                }
956
-                // make sure we have some values before inserting them
957
-                if (! empty($QSG_values)) {
958
-                    // insert system question
959
-                    $wpdb->insert(
960
-                        $table_name,
961
-                        $QSG_values,
962
-                        array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d')
963
-                    );
964
-                    $QSG_IDs[$QSG_system] = $wpdb->insert_id;
965
-                }
966
-            }
967
-        }
968
-        // QUESTIONS
969
-        global $wpdb;
970
-        $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question');
971
-        $SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''";
972
-        // what we have
973
-        $questions = $wpdb->get_col($SQL);
974
-        // what we should have
975
-        $QST_systems = array(
976
-            'fname',
977
-            'lname',
978
-            'email',
979
-            'address',
980
-            'address2',
981
-            'city',
982
-            'country',
983
-            'state',
984
-            'zip',
985
-            'phone',
986
-        );
987
-        $order_for_group_1 = 1;
988
-        $order_for_group_2 = 1;
989
-        // loop thru what we should have and compare to what we have
990
-        foreach ($QST_systems as $QST_system) {
991
-            // reset values array
992
-            $QST_values = array();
993
-            // if we don't have what we should have
994
-            if (! in_array($QST_system, $questions)) {
995
-                // add it
996
-                switch ($QST_system) {
997
-                    case 'fname':
998
-                        $QST_values = array(
999
-                            'QST_display_text'  => __('First Name', 'event_espresso'),
1000
-                            'QST_admin_label'   => __('First Name - System Question', 'event_espresso'),
1001
-                            'QST_system'        => 'fname',
1002
-                            'QST_type'          => 'TEXT',
1003
-                            'QST_required'      => 1,
1004
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1005
-                            'QST_order'         => 1,
1006
-                            'QST_admin_only'    => 0,
1007
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1008
-                            'QST_wp_user'       => self::get_default_creator_id(),
1009
-                            'QST_deleted'       => 0,
1010
-                        );
1011
-                        break;
1012
-                    case 'lname':
1013
-                        $QST_values = array(
1014
-                            'QST_display_text'  => __('Last Name', 'event_espresso'),
1015
-                            'QST_admin_label'   => __('Last Name - System Question', 'event_espresso'),
1016
-                            'QST_system'        => 'lname',
1017
-                            'QST_type'          => 'TEXT',
1018
-                            'QST_required'      => 1,
1019
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1020
-                            'QST_order'         => 2,
1021
-                            'QST_admin_only'    => 0,
1022
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1023
-                            'QST_wp_user'       => self::get_default_creator_id(),
1024
-                            'QST_deleted'       => 0,
1025
-                        );
1026
-                        break;
1027
-                    case 'email':
1028
-                        $QST_values = array(
1029
-                            'QST_display_text'  => __('Email Address', 'event_espresso'),
1030
-                            'QST_admin_label'   => __('Email Address - System Question', 'event_espresso'),
1031
-                            'QST_system'        => 'email',
1032
-                            'QST_type'          => 'EMAIL',
1033
-                            'QST_required'      => 1,
1034
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1035
-                            'QST_order'         => 3,
1036
-                            'QST_admin_only'    => 0,
1037
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1038
-                            'QST_wp_user'       => self::get_default_creator_id(),
1039
-                            'QST_deleted'       => 0,
1040
-                        );
1041
-                        break;
1042
-                    case 'address':
1043
-                        $QST_values = array(
1044
-                            'QST_display_text'  => __('Address', 'event_espresso'),
1045
-                            'QST_admin_label'   => __('Address - System Question', 'event_espresso'),
1046
-                            'QST_system'        => 'address',
1047
-                            'QST_type'          => 'TEXT',
1048
-                            'QST_required'      => 0,
1049
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1050
-                            'QST_order'         => 4,
1051
-                            'QST_admin_only'    => 0,
1052
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1053
-                            'QST_wp_user'       => self::get_default_creator_id(),
1054
-                            'QST_deleted'       => 0,
1055
-                        );
1056
-                        break;
1057
-                    case 'address2':
1058
-                        $QST_values = array(
1059
-                            'QST_display_text'  => __('Address2', 'event_espresso'),
1060
-                            'QST_admin_label'   => __('Address2 - System Question', 'event_espresso'),
1061
-                            'QST_system'        => 'address2',
1062
-                            'QST_type'          => 'TEXT',
1063
-                            'QST_required'      => 0,
1064
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1065
-                            'QST_order'         => 5,
1066
-                            'QST_admin_only'    => 0,
1067
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1068
-                            'QST_wp_user'       => self::get_default_creator_id(),
1069
-                            'QST_deleted'       => 0,
1070
-                        );
1071
-                        break;
1072
-                    case 'city':
1073
-                        $QST_values = array(
1074
-                            'QST_display_text'  => __('City', 'event_espresso'),
1075
-                            'QST_admin_label'   => __('City - System Question', 'event_espresso'),
1076
-                            'QST_system'        => 'city',
1077
-                            'QST_type'          => 'TEXT',
1078
-                            'QST_required'      => 0,
1079
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1080
-                            'QST_order'         => 6,
1081
-                            'QST_admin_only'    => 0,
1082
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1083
-                            'QST_wp_user'       => self::get_default_creator_id(),
1084
-                            'QST_deleted'       => 0,
1085
-                        );
1086
-                        break;
1087
-                    case 'country':
1088
-                        $QST_values = array(
1089
-                            'QST_display_text'  => __('Country', 'event_espresso'),
1090
-                            'QST_admin_label'   => __('Country - System Question', 'event_espresso'),
1091
-                            'QST_system'        => 'country',
1092
-                            'QST_type'          => 'COUNTRY',
1093
-                            'QST_required'      => 0,
1094
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1095
-                            'QST_order'         => 7,
1096
-                            'QST_admin_only'    => 0,
1097
-                            'QST_wp_user'       => self::get_default_creator_id(),
1098
-                            'QST_deleted'       => 0,
1099
-                        );
1100
-                        break;
1101
-                    case 'state':
1102
-                        $QST_values = array(
1103
-                            'QST_display_text'  => __('State/Province', 'event_espresso'),
1104
-                            'QST_admin_label'   => __('State/Province - System Question', 'event_espresso'),
1105
-                            'QST_system'        => 'state',
1106
-                            'QST_type'          => 'STATE',
1107
-                            'QST_required'      => 0,
1108
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1109
-                            'QST_order'         => 8,
1110
-                            'QST_admin_only'    => 0,
1111
-                            'QST_wp_user'       => self::get_default_creator_id(),
1112
-                            'QST_deleted'       => 0,
1113
-                        );
1114
-                        break;
1115
-                    case 'zip':
1116
-                        $QST_values = array(
1117
-                            'QST_display_text'  => __('Zip/Postal Code', 'event_espresso'),
1118
-                            'QST_admin_label'   => __('Zip/Postal Code - System Question', 'event_espresso'),
1119
-                            'QST_system'        => 'zip',
1120
-                            'QST_type'          => 'TEXT',
1121
-                            'QST_required'      => 0,
1122
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1123
-                            'QST_order'         => 9,
1124
-                            'QST_admin_only'    => 0,
1125
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1126
-                            'QST_wp_user'       => self::get_default_creator_id(),
1127
-                            'QST_deleted'       => 0,
1128
-                        );
1129
-                        break;
1130
-                    case 'phone':
1131
-                        $QST_values = array(
1132
-                            'QST_display_text'  => __('Phone Number', 'event_espresso'),
1133
-                            'QST_admin_label'   => __('Phone Number - System Question', 'event_espresso'),
1134
-                            'QST_system'        => 'phone',
1135
-                            'QST_type'          => 'TEXT',
1136
-                            'QST_required'      => 0,
1137
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1138
-                            'QST_order'         => 10,
1139
-                            'QST_admin_only'    => 0,
1140
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1141
-                            'QST_wp_user'       => self::get_default_creator_id(),
1142
-                            'QST_deleted'       => 0,
1143
-                        );
1144
-                        break;
1145
-                }
1146
-                if (! empty($QST_values)) {
1147
-                    // insert system question
1148
-                    $wpdb->insert(
1149
-                        $table_name,
1150
-                        $QST_values,
1151
-                        array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d')
1152
-                    );
1153
-                    $QST_ID = $wpdb->insert_id;
1154
-                    // QUESTION GROUP QUESTIONS
1155
-                    if (in_array($QST_system, array('fname', 'lname', 'email'))) {
1156
-                        $system_question_we_want = EEM_Question_Group::system_personal;
1157
-                    } else {
1158
-                        $system_question_we_want = EEM_Question_Group::system_address;
1159
-                    }
1160
-                    if (isset($QSG_IDs[$system_question_we_want])) {
1161
-                        $QSG_ID = $QSG_IDs[$system_question_we_want];
1162
-                    } else {
1163
-                        $id_col = EEM_Question_Group::instance()
1164
-                                                    ->get_col(array(array('QSG_system' => $system_question_we_want)));
1165
-                        if (is_array($id_col)) {
1166
-                            $QSG_ID = reset($id_col);
1167
-                        } else {
1168
-                            //ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method
1169
-                            EE_Log::instance()->log(
1170
-                                __FILE__,
1171
-                                __FUNCTION__,
1172
-                                sprintf(
1173
-                                    __(
1174
-                                        'Could not associate question %1$s to a question group because no system question
891
+					'event_espresso'
892
+				),
893
+				__FILE__,
894
+				__FUNCTION__,
895
+				__LINE__
896
+			);
897
+			return false;
898
+		}
899
+		return true;
900
+	}
901
+
902
+
903
+
904
+	/**
905
+	 * initialize_system_questions
906
+	 *
907
+	 * @access public
908
+	 * @static
909
+	 * @return void
910
+	 */
911
+	public static function initialize_system_questions()
912
+	{
913
+		// QUESTION GROUPS
914
+		global $wpdb;
915
+		$table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group');
916
+		$SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0";
917
+		// what we have
918
+		$question_groups = $wpdb->get_col($SQL);
919
+		// check the response
920
+		$question_groups = is_array($question_groups) ? $question_groups : array();
921
+		// what we should have
922
+		$QSG_systems = array(1, 2);
923
+		// loop thru what we should have and compare to what we have
924
+		foreach ($QSG_systems as $QSG_system) {
925
+			// reset values array
926
+			$QSG_values = array();
927
+			// if we don't have what we should have (but use $QST_system as as string because that's what we got from the db)
928
+			if (! in_array("$QSG_system", $question_groups)) {
929
+				// add it
930
+				switch ($QSG_system) {
931
+					case 1:
932
+						$QSG_values = array(
933
+							'QSG_name'            => __('Personal Information', 'event_espresso'),
934
+							'QSG_identifier'      => 'personal-information-' . time(),
935
+							'QSG_desc'            => '',
936
+							'QSG_order'           => 1,
937
+							'QSG_show_group_name' => 1,
938
+							'QSG_show_group_desc' => 1,
939
+							'QSG_system'          => EEM_Question_Group::system_personal,
940
+							'QSG_deleted'         => 0,
941
+						);
942
+						break;
943
+					case 2:
944
+						$QSG_values = array(
945
+							'QSG_name'            => __('Address Information', 'event_espresso'),
946
+							'QSG_identifier'      => 'address-information-' . time(),
947
+							'QSG_desc'            => '',
948
+							'QSG_order'           => 2,
949
+							'QSG_show_group_name' => 1,
950
+							'QSG_show_group_desc' => 1,
951
+							'QSG_system'          => EEM_Question_Group::system_address,
952
+							'QSG_deleted'         => 0,
953
+						);
954
+						break;
955
+				}
956
+				// make sure we have some values before inserting them
957
+				if (! empty($QSG_values)) {
958
+					// insert system question
959
+					$wpdb->insert(
960
+						$table_name,
961
+						$QSG_values,
962
+						array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d')
963
+					);
964
+					$QSG_IDs[$QSG_system] = $wpdb->insert_id;
965
+				}
966
+			}
967
+		}
968
+		// QUESTIONS
969
+		global $wpdb;
970
+		$table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question');
971
+		$SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''";
972
+		// what we have
973
+		$questions = $wpdb->get_col($SQL);
974
+		// what we should have
975
+		$QST_systems = array(
976
+			'fname',
977
+			'lname',
978
+			'email',
979
+			'address',
980
+			'address2',
981
+			'city',
982
+			'country',
983
+			'state',
984
+			'zip',
985
+			'phone',
986
+		);
987
+		$order_for_group_1 = 1;
988
+		$order_for_group_2 = 1;
989
+		// loop thru what we should have and compare to what we have
990
+		foreach ($QST_systems as $QST_system) {
991
+			// reset values array
992
+			$QST_values = array();
993
+			// if we don't have what we should have
994
+			if (! in_array($QST_system, $questions)) {
995
+				// add it
996
+				switch ($QST_system) {
997
+					case 'fname':
998
+						$QST_values = array(
999
+							'QST_display_text'  => __('First Name', 'event_espresso'),
1000
+							'QST_admin_label'   => __('First Name - System Question', 'event_espresso'),
1001
+							'QST_system'        => 'fname',
1002
+							'QST_type'          => 'TEXT',
1003
+							'QST_required'      => 1,
1004
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1005
+							'QST_order'         => 1,
1006
+							'QST_admin_only'    => 0,
1007
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1008
+							'QST_wp_user'       => self::get_default_creator_id(),
1009
+							'QST_deleted'       => 0,
1010
+						);
1011
+						break;
1012
+					case 'lname':
1013
+						$QST_values = array(
1014
+							'QST_display_text'  => __('Last Name', 'event_espresso'),
1015
+							'QST_admin_label'   => __('Last Name - System Question', 'event_espresso'),
1016
+							'QST_system'        => 'lname',
1017
+							'QST_type'          => 'TEXT',
1018
+							'QST_required'      => 1,
1019
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1020
+							'QST_order'         => 2,
1021
+							'QST_admin_only'    => 0,
1022
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1023
+							'QST_wp_user'       => self::get_default_creator_id(),
1024
+							'QST_deleted'       => 0,
1025
+						);
1026
+						break;
1027
+					case 'email':
1028
+						$QST_values = array(
1029
+							'QST_display_text'  => __('Email Address', 'event_espresso'),
1030
+							'QST_admin_label'   => __('Email Address - System Question', 'event_espresso'),
1031
+							'QST_system'        => 'email',
1032
+							'QST_type'          => 'EMAIL',
1033
+							'QST_required'      => 1,
1034
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1035
+							'QST_order'         => 3,
1036
+							'QST_admin_only'    => 0,
1037
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1038
+							'QST_wp_user'       => self::get_default_creator_id(),
1039
+							'QST_deleted'       => 0,
1040
+						);
1041
+						break;
1042
+					case 'address':
1043
+						$QST_values = array(
1044
+							'QST_display_text'  => __('Address', 'event_espresso'),
1045
+							'QST_admin_label'   => __('Address - System Question', 'event_espresso'),
1046
+							'QST_system'        => 'address',
1047
+							'QST_type'          => 'TEXT',
1048
+							'QST_required'      => 0,
1049
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1050
+							'QST_order'         => 4,
1051
+							'QST_admin_only'    => 0,
1052
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1053
+							'QST_wp_user'       => self::get_default_creator_id(),
1054
+							'QST_deleted'       => 0,
1055
+						);
1056
+						break;
1057
+					case 'address2':
1058
+						$QST_values = array(
1059
+							'QST_display_text'  => __('Address2', 'event_espresso'),
1060
+							'QST_admin_label'   => __('Address2 - System Question', 'event_espresso'),
1061
+							'QST_system'        => 'address2',
1062
+							'QST_type'          => 'TEXT',
1063
+							'QST_required'      => 0,
1064
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1065
+							'QST_order'         => 5,
1066
+							'QST_admin_only'    => 0,
1067
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1068
+							'QST_wp_user'       => self::get_default_creator_id(),
1069
+							'QST_deleted'       => 0,
1070
+						);
1071
+						break;
1072
+					case 'city':
1073
+						$QST_values = array(
1074
+							'QST_display_text'  => __('City', 'event_espresso'),
1075
+							'QST_admin_label'   => __('City - System Question', 'event_espresso'),
1076
+							'QST_system'        => 'city',
1077
+							'QST_type'          => 'TEXT',
1078
+							'QST_required'      => 0,
1079
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1080
+							'QST_order'         => 6,
1081
+							'QST_admin_only'    => 0,
1082
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1083
+							'QST_wp_user'       => self::get_default_creator_id(),
1084
+							'QST_deleted'       => 0,
1085
+						);
1086
+						break;
1087
+					case 'country':
1088
+						$QST_values = array(
1089
+							'QST_display_text'  => __('Country', 'event_espresso'),
1090
+							'QST_admin_label'   => __('Country - System Question', 'event_espresso'),
1091
+							'QST_system'        => 'country',
1092
+							'QST_type'          => 'COUNTRY',
1093
+							'QST_required'      => 0,
1094
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1095
+							'QST_order'         => 7,
1096
+							'QST_admin_only'    => 0,
1097
+							'QST_wp_user'       => self::get_default_creator_id(),
1098
+							'QST_deleted'       => 0,
1099
+						);
1100
+						break;
1101
+					case 'state':
1102
+						$QST_values = array(
1103
+							'QST_display_text'  => __('State/Province', 'event_espresso'),
1104
+							'QST_admin_label'   => __('State/Province - System Question', 'event_espresso'),
1105
+							'QST_system'        => 'state',
1106
+							'QST_type'          => 'STATE',
1107
+							'QST_required'      => 0,
1108
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1109
+							'QST_order'         => 8,
1110
+							'QST_admin_only'    => 0,
1111
+							'QST_wp_user'       => self::get_default_creator_id(),
1112
+							'QST_deleted'       => 0,
1113
+						);
1114
+						break;
1115
+					case 'zip':
1116
+						$QST_values = array(
1117
+							'QST_display_text'  => __('Zip/Postal Code', 'event_espresso'),
1118
+							'QST_admin_label'   => __('Zip/Postal Code - System Question', 'event_espresso'),
1119
+							'QST_system'        => 'zip',
1120
+							'QST_type'          => 'TEXT',
1121
+							'QST_required'      => 0,
1122
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1123
+							'QST_order'         => 9,
1124
+							'QST_admin_only'    => 0,
1125
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1126
+							'QST_wp_user'       => self::get_default_creator_id(),
1127
+							'QST_deleted'       => 0,
1128
+						);
1129
+						break;
1130
+					case 'phone':
1131
+						$QST_values = array(
1132
+							'QST_display_text'  => __('Phone Number', 'event_espresso'),
1133
+							'QST_admin_label'   => __('Phone Number - System Question', 'event_espresso'),
1134
+							'QST_system'        => 'phone',
1135
+							'QST_type'          => 'TEXT',
1136
+							'QST_required'      => 0,
1137
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1138
+							'QST_order'         => 10,
1139
+							'QST_admin_only'    => 0,
1140
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1141
+							'QST_wp_user'       => self::get_default_creator_id(),
1142
+							'QST_deleted'       => 0,
1143
+						);
1144
+						break;
1145
+				}
1146
+				if (! empty($QST_values)) {
1147
+					// insert system question
1148
+					$wpdb->insert(
1149
+						$table_name,
1150
+						$QST_values,
1151
+						array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d')
1152
+					);
1153
+					$QST_ID = $wpdb->insert_id;
1154
+					// QUESTION GROUP QUESTIONS
1155
+					if (in_array($QST_system, array('fname', 'lname', 'email'))) {
1156
+						$system_question_we_want = EEM_Question_Group::system_personal;
1157
+					} else {
1158
+						$system_question_we_want = EEM_Question_Group::system_address;
1159
+					}
1160
+					if (isset($QSG_IDs[$system_question_we_want])) {
1161
+						$QSG_ID = $QSG_IDs[$system_question_we_want];
1162
+					} else {
1163
+						$id_col = EEM_Question_Group::instance()
1164
+													->get_col(array(array('QSG_system' => $system_question_we_want)));
1165
+						if (is_array($id_col)) {
1166
+							$QSG_ID = reset($id_col);
1167
+						} else {
1168
+							//ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method
1169
+							EE_Log::instance()->log(
1170
+								__FILE__,
1171
+								__FUNCTION__,
1172
+								sprintf(
1173
+									__(
1174
+										'Could not associate question %1$s to a question group because no system question
1175 1175
                                          group existed',
1176
-                                        'event_espresso'
1177
-                                    ),
1178
-                                    $QST_ID),
1179
-                                'error');
1180
-                            continue;
1181
-                        }
1182
-                    }
1183
-                    // add system questions to groups
1184
-                    $wpdb->insert(
1185
-                        \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group_question'),
1186
-                        array(
1187
-                            'QSG_ID'    => $QSG_ID,
1188
-                            'QST_ID'    => $QST_ID,
1189
-                            'QGQ_order' => ($QSG_ID === 1) ? $order_for_group_1++ : $order_for_group_2++,
1190
-                        ),
1191
-                        array('%d', '%d', '%d')
1192
-                    );
1193
-                }
1194
-            }
1195
-        }
1196
-    }
1197
-
1198
-
1199
-    /**
1200
-     * Makes sure the default payment method (Invoice) is active.
1201
-     * This used to be done automatically as part of constructing the old gateways config
1202
-     *
1203
-     * @throws \EE_Error
1204
-     */
1205
-    public static function insert_default_payment_methods()
1206
-    {
1207
-        if (! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) {
1208
-            EE_Registry::instance()->load_lib('Payment_Method_Manager');
1209
-            EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
1210
-        } else {
1211
-            EEM_Payment_Method::instance()->verify_button_urls();
1212
-        }
1213
-    }
1214
-
1215
-    /**
1216
-     * insert_default_status_codes
1217
-     *
1218
-     * @access public
1219
-     * @static
1220
-     * @return void
1221
-     */
1222
-    public static function insert_default_status_codes()
1223
-    {
1224
-
1225
-        global $wpdb;
1226
-
1227
-        if (\EEH_Activation::getTableAnalysis()->tableExists(EEM_Status::instance()->table())) {
1228
-
1229
-            $table_name = EEM_Status::instance()->table();
1230
-
1231
-            $SQL = "DELETE FROM $table_name WHERE STS_ID IN ( 'ACT', 'NAC', 'NOP', 'OPN', 'CLS', 'PND', 'ONG', 'SEC', 'DRF', 'DEL', 'DEN', 'EXP', 'RPP', 'RCN', 'RDC', 'RAP', 'RNA', 'RWL', 'TAB', 'TIN', 'TFL', 'TCM', 'TOP', 'PAP', 'PCN', 'PFL', 'PDC', 'EDR', 'ESN', 'PPN', 'RIC', 'MSN', 'MFL', 'MID', 'MRS', 'MIC', 'MDO', 'MEX' );";
1232
-            $wpdb->query($SQL);
1233
-
1234
-            $SQL = "INSERT INTO $table_name
1176
+										'event_espresso'
1177
+									),
1178
+									$QST_ID),
1179
+								'error');
1180
+							continue;
1181
+						}
1182
+					}
1183
+					// add system questions to groups
1184
+					$wpdb->insert(
1185
+						\EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group_question'),
1186
+						array(
1187
+							'QSG_ID'    => $QSG_ID,
1188
+							'QST_ID'    => $QST_ID,
1189
+							'QGQ_order' => ($QSG_ID === 1) ? $order_for_group_1++ : $order_for_group_2++,
1190
+						),
1191
+						array('%d', '%d', '%d')
1192
+					);
1193
+				}
1194
+			}
1195
+		}
1196
+	}
1197
+
1198
+
1199
+	/**
1200
+	 * Makes sure the default payment method (Invoice) is active.
1201
+	 * This used to be done automatically as part of constructing the old gateways config
1202
+	 *
1203
+	 * @throws \EE_Error
1204
+	 */
1205
+	public static function insert_default_payment_methods()
1206
+	{
1207
+		if (! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) {
1208
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
1209
+			EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
1210
+		} else {
1211
+			EEM_Payment_Method::instance()->verify_button_urls();
1212
+		}
1213
+	}
1214
+
1215
+	/**
1216
+	 * insert_default_status_codes
1217
+	 *
1218
+	 * @access public
1219
+	 * @static
1220
+	 * @return void
1221
+	 */
1222
+	public static function insert_default_status_codes()
1223
+	{
1224
+
1225
+		global $wpdb;
1226
+
1227
+		if (\EEH_Activation::getTableAnalysis()->tableExists(EEM_Status::instance()->table())) {
1228
+
1229
+			$table_name = EEM_Status::instance()->table();
1230
+
1231
+			$SQL = "DELETE FROM $table_name WHERE STS_ID IN ( 'ACT', 'NAC', 'NOP', 'OPN', 'CLS', 'PND', 'ONG', 'SEC', 'DRF', 'DEL', 'DEN', 'EXP', 'RPP', 'RCN', 'RDC', 'RAP', 'RNA', 'RWL', 'TAB', 'TIN', 'TFL', 'TCM', 'TOP', 'PAP', 'PCN', 'PFL', 'PDC', 'EDR', 'ESN', 'PPN', 'RIC', 'MSN', 'MFL', 'MID', 'MRS', 'MIC', 'MDO', 'MEX' );";
1232
+			$wpdb->query($SQL);
1233
+
1234
+			$SQL = "INSERT INTO $table_name
1235 1235
 					(STS_ID, STS_code, STS_type, STS_can_edit, STS_desc, STS_open) VALUES
1236 1236
 					('ACT', 'ACTIVE', 'event', 0, NULL, 1),
1237 1237
 					('NAC', 'NOT_ACTIVE', 'event', 0, NULL, 0),
@@ -1271,521 +1271,521 @@  discard block
 block discarded – undo
1271 1271
 					('MID', 'IDLE', 'message', 0, NULL, 1),
1272 1272
 					('MRS', 'RESEND', 'message', 0, NULL, 1),
1273 1273
 					('MIC', 'INCOMPLETE', 'message', 0, NULL, 0);";
1274
-            $wpdb->query($SQL);
1275
-
1276
-        }
1277
-
1278
-    }
1279
-
1280
-
1281
-    /**
1282
-     * create_upload_directories
1283
-     * Creates folders in the uploads directory to facilitate addons and templates
1284
-     *
1285
-     * @access public
1286
-     * @static
1287
-     * @return boolean success of verifying upload directories exist
1288
-     */
1289
-    public static function create_upload_directories()
1290
-    {
1291
-        // Create the required folders
1292
-        $folders = array(
1293
-            EVENT_ESPRESSO_TEMPLATE_DIR,
1294
-            EVENT_ESPRESSO_GATEWAY_DIR,
1295
-            EVENT_ESPRESSO_UPLOAD_DIR . 'logs/',
1296
-            EVENT_ESPRESSO_UPLOAD_DIR . 'css/',
1297
-            EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/',
1298
-        );
1299
-        foreach ($folders as $folder) {
1300
-            try {
1301
-                EEH_File::ensure_folder_exists_and_is_writable($folder);
1302
-                @ chmod($folder, 0755);
1303
-            } catch (EE_Error $e) {
1304
-                EE_Error::add_error(
1305
-                    sprintf(
1306
-                        __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'),
1307
-                        $folder,
1308
-                        '<br />' . $e->getMessage()
1309
-                    ),
1310
-                    __FILE__, __FUNCTION__, __LINE__
1311
-                );
1312
-                //indicate we'll need to fix this later
1313
-                update_option(EEH_Activation::upload_directories_incomplete_option_name, true);
1314
-                return false;
1315
-            }
1316
-        }
1317
-        //just add the .htaccess file to the logs directory to begin with. Even if logging
1318
-        //is disabled, there might be activation errors recorded in there
1319
-        EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs/');
1320
-        //remember EE's folders are all good
1321
-        delete_option(EEH_Activation::upload_directories_incomplete_option_name);
1322
-        return true;
1323
-    }
1324
-
1325
-    /**
1326
-     * Whether the upload directories need to be fixed or not.
1327
-     * If EE is installed but filesystem access isn't initially available,
1328
-     * we need to get the user's filesystem credentials and THEN create them,
1329
-     * so there might be period of time when EE is installed but its
1330
-     * upload directories aren't available. This indicates such a state
1331
-     *
1332
-     * @return boolean
1333
-     */
1334
-    public static function upload_directories_incomplete()
1335
-    {
1336
-        return get_option(EEH_Activation::upload_directories_incomplete_option_name, false);
1337
-    }
1338
-
1339
-
1340
-    /**
1341
-     * generate_default_message_templates
1342
-     *
1343
-     * @static
1344
-     * @throws EE_Error
1345
-     * @return bool     true means new templates were created.
1346
-     *                  false means no templates were created.
1347
-     *                  This is NOT an error flag. To check for errors you will want
1348
-     *                  to use either EE_Error or a try catch for an EE_Error exception.
1349
-     */
1350
-    public static function generate_default_message_templates()
1351
-    {
1352
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
1353
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
1354
-        /*
1274
+			$wpdb->query($SQL);
1275
+
1276
+		}
1277
+
1278
+	}
1279
+
1280
+
1281
+	/**
1282
+	 * create_upload_directories
1283
+	 * Creates folders in the uploads directory to facilitate addons and templates
1284
+	 *
1285
+	 * @access public
1286
+	 * @static
1287
+	 * @return boolean success of verifying upload directories exist
1288
+	 */
1289
+	public static function create_upload_directories()
1290
+	{
1291
+		// Create the required folders
1292
+		$folders = array(
1293
+			EVENT_ESPRESSO_TEMPLATE_DIR,
1294
+			EVENT_ESPRESSO_GATEWAY_DIR,
1295
+			EVENT_ESPRESSO_UPLOAD_DIR . 'logs/',
1296
+			EVENT_ESPRESSO_UPLOAD_DIR . 'css/',
1297
+			EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/',
1298
+		);
1299
+		foreach ($folders as $folder) {
1300
+			try {
1301
+				EEH_File::ensure_folder_exists_and_is_writable($folder);
1302
+				@ chmod($folder, 0755);
1303
+			} catch (EE_Error $e) {
1304
+				EE_Error::add_error(
1305
+					sprintf(
1306
+						__('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'),
1307
+						$folder,
1308
+						'<br />' . $e->getMessage()
1309
+					),
1310
+					__FILE__, __FUNCTION__, __LINE__
1311
+				);
1312
+				//indicate we'll need to fix this later
1313
+				update_option(EEH_Activation::upload_directories_incomplete_option_name, true);
1314
+				return false;
1315
+			}
1316
+		}
1317
+		//just add the .htaccess file to the logs directory to begin with. Even if logging
1318
+		//is disabled, there might be activation errors recorded in there
1319
+		EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs/');
1320
+		//remember EE's folders are all good
1321
+		delete_option(EEH_Activation::upload_directories_incomplete_option_name);
1322
+		return true;
1323
+	}
1324
+
1325
+	/**
1326
+	 * Whether the upload directories need to be fixed or not.
1327
+	 * If EE is installed but filesystem access isn't initially available,
1328
+	 * we need to get the user's filesystem credentials and THEN create them,
1329
+	 * so there might be period of time when EE is installed but its
1330
+	 * upload directories aren't available. This indicates such a state
1331
+	 *
1332
+	 * @return boolean
1333
+	 */
1334
+	public static function upload_directories_incomplete()
1335
+	{
1336
+		return get_option(EEH_Activation::upload_directories_incomplete_option_name, false);
1337
+	}
1338
+
1339
+
1340
+	/**
1341
+	 * generate_default_message_templates
1342
+	 *
1343
+	 * @static
1344
+	 * @throws EE_Error
1345
+	 * @return bool     true means new templates were created.
1346
+	 *                  false means no templates were created.
1347
+	 *                  This is NOT an error flag. To check for errors you will want
1348
+	 *                  to use either EE_Error or a try catch for an EE_Error exception.
1349
+	 */
1350
+	public static function generate_default_message_templates()
1351
+	{
1352
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
1353
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
1354
+		/*
1355 1355
          * This first method is taking care of ensuring any default messengers
1356 1356
          * that should be made active and have templates generated are done.
1357 1357
          */
1358
-        $new_templates_created_for_messenger = self::_activate_and_generate_default_messengers_and_message_templates(
1359
-            $message_resource_manager
1360
-        );
1361
-        /**
1362
-         * This method is verifying there are no NEW default message types
1363
-         * for ACTIVE messengers that need activated (and corresponding templates setup).
1364
-         */
1365
-        $new_templates_created_for_message_type = self::_activate_new_message_types_for_active_messengers_and_generate_default_templates(
1366
-            $message_resource_manager
1367
-        );
1368
-        //after all is done, let's persist these changes to the db.
1369
-        $message_resource_manager->update_has_activated_messengers_option();
1370
-        $message_resource_manager->update_active_messengers_option();
1371
-        // will return true if either of these are true.  Otherwise will return false.
1372
-        return $new_templates_created_for_message_type || $new_templates_created_for_messenger;
1373
-    }
1374
-
1375
-
1376
-
1377
-    /**
1378
-     * @param \EE_Message_Resource_Manager $message_resource_manager
1379
-     * @return array|bool
1380
-     * @throws \EE_Error
1381
-     */
1382
-    protected static function _activate_new_message_types_for_active_messengers_and_generate_default_templates(
1383
-        EE_Message_Resource_Manager $message_resource_manager
1384
-    ) {
1385
-        /** @type EE_messenger[] $active_messengers */
1386
-        $active_messengers = $message_resource_manager->active_messengers();
1387
-        $installed_message_types = $message_resource_manager->installed_message_types();
1388
-        $templates_created = false;
1389
-        foreach ($active_messengers as $active_messenger) {
1390
-            $default_message_type_names_for_messenger = $active_messenger->get_default_message_types();
1391
-            $default_message_type_names_to_activate = array();
1392
-            // looping through each default message type reported by the messenger
1393
-            // and setup the actual message types to activate.
1394
-            foreach ($default_message_type_names_for_messenger as $default_message_type_name_for_messenger) {
1395
-                // if already active or has already been activated before we skip
1396
-                // (otherwise we might reactivate something user's intentionally deactivated.)
1397
-                // we also skip if the message type is not installed.
1398
-                if (
1399
-                    $message_resource_manager->has_message_type_been_activated_for_messenger(
1400
-                        $default_message_type_name_for_messenger,
1401
-                        $active_messenger->name
1402
-                    )
1403
-                    || $message_resource_manager->is_message_type_active_for_messenger(
1404
-                        $active_messenger->name,
1405
-                        $default_message_type_name_for_messenger
1406
-                    )
1407
-                    || ! isset($installed_message_types[$default_message_type_name_for_messenger])
1408
-                ) {
1409
-                    continue;
1410
-                }
1411
-                $default_message_type_names_to_activate[] = $default_message_type_name_for_messenger;
1412
-            }
1413
-            //let's activate!
1414
-            $message_resource_manager->ensure_message_types_are_active(
1415
-                $default_message_type_names_to_activate,
1416
-                $active_messenger->name,
1417
-                false
1418
-            );
1419
-            //activate the templates for these message types
1420
-            if ( ! empty($default_message_type_names_to_activate)) {
1421
-                $templates_created = EEH_MSG_Template::generate_new_templates(
1422
-                    $active_messenger->name,
1423
-                    $default_message_type_names_for_messenger,
1424
-                    '',
1425
-                    true
1426
-                );
1427
-            }
1428
-        }
1429
-        return $templates_created;
1430
-    }
1431
-
1432
-
1433
-
1434
-    /**
1435
-     * This will activate and generate default messengers and default message types for those messengers.
1436
-     *
1437
-     * @param EE_message_Resource_Manager $message_resource_manager
1438
-     * @return array|bool  True means there were default messengers and message type templates generated.
1439
-     *                     False means that there were no templates generated
1440
-     *                     (which could simply mean there are no default message types for a messenger).
1441
-     * @throws EE_Error
1442
-     */
1443
-    protected static function _activate_and_generate_default_messengers_and_message_templates(
1444
-        EE_Message_Resource_Manager $message_resource_manager
1445
-    ) {
1446
-        /** @type EE_messenger[] $messengers_to_generate */
1447
-        $messengers_to_generate = self::_get_default_messengers_to_generate_on_activation($message_resource_manager);
1448
-        $installed_message_types = $message_resource_manager->installed_message_types();
1449
-        $templates_generated = false;
1450
-        foreach ($messengers_to_generate as $messenger_to_generate) {
1451
-            $default_message_type_names_for_messenger = $messenger_to_generate->get_default_message_types();
1452
-            //verify the default message types match an installed message type.
1453
-            foreach ($default_message_type_names_for_messenger as $key => $name) {
1454
-                if (
1455
-                    ! isset($installed_message_types[$name])
1456
-                    || $message_resource_manager->has_message_type_been_activated_for_messenger(
1457
-                        $name,
1458
-                        $messenger_to_generate->name
1459
-                    )
1460
-                ) {
1461
-                    unset($default_message_type_names_for_messenger[$key]);
1462
-                }
1463
-            }
1464
-            // in previous iterations, the active_messengers option in the db
1465
-            // needed updated before calling create templates. however with the changes this may not be necessary.
1466
-            // This comment is left here just in case we discover that we _do_ need to update before
1467
-            // passing off to create templates (after the refactor is done).
1468
-            // @todo remove this comment when determined not necessary.
1469
-            $message_resource_manager->activate_messenger(
1470
-                $messenger_to_generate->name,
1471
-                $default_message_type_names_for_messenger,
1472
-                false
1473
-            );
1474
-            //create any templates needing created (or will reactivate templates already generated as necessary).
1475
-            if ( ! empty($default_message_type_names_for_messenger)) {
1476
-                $templates_generated = EEH_MSG_Template::generate_new_templates(
1477
-                    $messenger_to_generate->name,
1478
-                    $default_message_type_names_for_messenger,
1479
-                    '',
1480
-                    true
1481
-                );
1482
-            }
1483
-        }
1484
-        return $templates_generated;
1485
-    }
1486
-
1487
-
1488
-    /**
1489
-     * This returns the default messengers to generate templates for on activation of EE.
1490
-     * It considers:
1491
-     * - whether a messenger is already active in the db.
1492
-     * - whether a messenger has been made active at any time in the past.
1493
-     *
1494
-     * @static
1495
-     * @param  EE_Message_Resource_Manager $message_resource_manager
1496
-     * @return EE_messenger[]
1497
-     */
1498
-    protected static function _get_default_messengers_to_generate_on_activation(
1499
-        EE_Message_Resource_Manager $message_resource_manager
1500
-    ) {
1501
-        $active_messengers    = $message_resource_manager->active_messengers();
1502
-        $installed_messengers = $message_resource_manager->installed_messengers();
1503
-        $has_activated        = $message_resource_manager->get_has_activated_messengers_option();
1504
-
1505
-        $messengers_to_generate = array();
1506
-        foreach ($installed_messengers as $installed_messenger) {
1507
-            //if installed messenger is a messenger that should be activated on install
1508
-            //and is not already active
1509
-            //and has never been activated
1510
-            if (
1511
-                ! $installed_messenger->activate_on_install
1512
-                || isset($active_messengers[$installed_messenger->name])
1513
-                || isset($has_activated[$installed_messenger->name])
1514
-            ) {
1515
-                continue;
1516
-            }
1517
-            $messengers_to_generate[$installed_messenger->name] = $installed_messenger;
1518
-        }
1519
-        return $messengers_to_generate;
1520
-    }
1521
-
1522
-
1523
-    /**
1524
-     * This simply validates active message types to ensure they actually match installed
1525
-     * message types.  If there's a mismatch then we deactivate the message type and ensure all related db
1526
-     * rows are set inactive.
1527
-     * Note: Messengers are no longer validated here as of 4.9.0 because they get validated automatically whenever
1528
-     * EE_Messenger_Resource_Manager is constructed.  Message Types are a bit more resource heavy for validation so they
1529
-     * are still handled in here.
1530
-     *
1531
-     * @since 4.3.1
1532
-     * @return void
1533
-     */
1534
-    public static function validate_messages_system()
1535
-    {
1536
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
1537
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
1538
-        $message_resource_manager->validate_active_message_types_are_installed();
1539
-        do_action('AHEE__EEH_Activation__validate_messages_system');
1540
-    }
1541
-
1542
-
1543
-    /**
1544
-     * create_no_ticket_prices_array
1545
-     *
1546
-     * @access public
1547
-     * @static
1548
-     * @return void
1549
-     */
1550
-    public static function create_no_ticket_prices_array()
1551
-    {
1552
-        // this creates an array for tracking events that have no active ticket prices created
1553
-        // this allows us to warn admins of the situation so that it can be corrected
1554
-        $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', false);
1555
-        if (! $espresso_no_ticket_prices) {
1556
-            add_option('ee_no_ticket_prices', array(), '', false);
1557
-        }
1558
-    }
1559
-
1560
-
1561
-    /**
1562
-     * plugin_deactivation
1563
-     *
1564
-     * @access public
1565
-     * @static
1566
-     * @return void
1567
-     */
1568
-    public static function plugin_deactivation()
1569
-    {
1570
-    }
1571
-
1572
-
1573
-    /**
1574
-     * Finds all our EE4 custom post types, and deletes them and their associated data
1575
-     * (like post meta or term relations)
1576
-     *
1577
-     * @global wpdb $wpdb
1578
-     * @throws \EE_Error
1579
-     */
1580
-    public static function delete_all_espresso_cpt_data()
1581
-    {
1582
-        global $wpdb;
1583
-        //get all the CPT post_types
1584
-        $ee_post_types = array();
1585
-        foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1586
-            if (method_exists($model_name, 'instance')) {
1587
-                $model_obj = call_user_func(array($model_name, 'instance'));
1588
-                if ($model_obj instanceof EEM_CPT_Base) {
1589
-                    $ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type());
1590
-                }
1591
-            }
1592
-        }
1593
-        //get all our CPTs
1594
-        $query   = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (" . implode(",", $ee_post_types) . ")";
1595
-        $cpt_ids = $wpdb->get_col($query);
1596
-        //delete each post meta and term relations too
1597
-        foreach ($cpt_ids as $post_id) {
1598
-            wp_delete_post($post_id, true);
1599
-        }
1600
-    }
1601
-
1602
-    /**
1603
-     * Deletes all EE custom tables
1604
-     *
1605
-     * @return array
1606
-     */
1607
-    public static function drop_espresso_tables()
1608
-    {
1609
-        $tables = array();
1610
-        // load registry
1611
-        foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1612
-            if (method_exists($model_name, 'instance')) {
1613
-                $model_obj = call_user_func(array($model_name, 'instance'));
1614
-                if ($model_obj instanceof EEM_Base) {
1615
-                    foreach ($model_obj->get_tables() as $table) {
1616
-                        if (strpos($table->get_table_name(), 'esp_')
1617
-                            &&
1618
-                            (
1619
-                                is_main_site()//main site? nuke them all
1620
-                                || ! $table->is_global()//not main site,but not global either. nuke it
1621
-                            )
1622
-                        ) {
1623
-                            $tables[] = $table->get_table_name();
1624
-                        }
1625
-                    }
1626
-                }
1627
-            }
1628
-        }
1629
-
1630
-        //there are some tables whose models were removed.
1631
-        //they should be removed when removing all EE core's data
1632
-        $tables_without_models = array(
1633
-            'esp_promotion',
1634
-            'esp_promotion_applied',
1635
-            'esp_promotion_object',
1636
-            'esp_promotion_rule',
1637
-            'esp_rule',
1638
-        );
1639
-        foreach ($tables_without_models as $table) {
1640
-            $tables[] = $table;
1641
-        }
1642
-        return \EEH_Activation::getTableManager()->dropTables($tables);
1643
-    }
1644
-
1645
-
1646
-
1647
-    /**
1648
-     * Drops all the tables mentioned in a single MYSQL query. Double-checks
1649
-     * each table name provided has a wpdb prefix attached, and that it exists.
1650
-     * Returns the list actually deleted
1651
-     *
1652
-     * @deprecated in 4.9.13. Instead use TableManager::dropTables()
1653
-     * @global WPDB $wpdb
1654
-     * @param array $table_names
1655
-     * @return array of table names which we deleted
1656
-     */
1657
-    public static function drop_tables($table_names)
1658
-    {
1659
-        return \EEH_Activation::getTableManager()->dropTables($table_names);
1660
-    }
1661
-
1662
-
1663
-
1664
-    /**
1665
-     * plugin_uninstall
1666
-     *
1667
-     * @access public
1668
-     * @static
1669
-     * @param bool $remove_all
1670
-     * @return void
1671
-     */
1672
-    public static function delete_all_espresso_tables_and_data($remove_all = true)
1673
-    {
1674
-        global $wpdb;
1675
-        self::drop_espresso_tables();
1676
-        $wp_options_to_delete = array(
1677
-            'ee_no_ticket_prices'                => true,
1678
-            'ee_active_messengers'               => true,
1679
-            'ee_has_activated_messenger'         => true,
1680
-            'ee_flush_rewrite_rules'             => true,
1681
-            'ee_config'                          => false,
1682
-            'ee_data_migration_current_db_state' => true,
1683
-            'ee_data_migration_mapping_'         => false,
1684
-            'ee_data_migration_script_'          => false,
1685
-            'ee_data_migrations'                 => true,
1686
-            'ee_dms_map'                         => false,
1687
-            'ee_notices'                         => true,
1688
-            'lang_file_check_'                   => false,
1689
-            'ee_maintenance_mode'                => true,
1690
-            'ee_ueip_optin'                      => true,
1691
-            'ee_ueip_has_notified'               => true,
1692
-            'ee_plugin_activation_errors'        => true,
1693
-            'ee_id_mapping_from'                 => false,
1694
-            'espresso_persistent_admin_notices'  => true,
1695
-            'ee_encryption_key'                  => true,
1696
-            'pue_force_upgrade_'                 => false,
1697
-            'pue_json_error_'                    => false,
1698
-            'pue_install_key_'                   => false,
1699
-            'pue_verification_error_'            => false,
1700
-            'pu_dismissed_upgrade_'              => false,
1701
-            'external_updates-'                  => false,
1702
-            'ee_extra_data'                      => true,
1703
-            'ee_ssn_'                            => false,
1704
-            'ee_rss_'                            => false,
1705
-            'ee_rte_n_tx_'                       => false,
1706
-            'ee_pers_admin_notices'              => true,
1707
-            'ee_job_parameters_'                 => false,
1708
-            'ee_upload_directories_incomplete'   => true,
1709
-            'ee_verified_db_collations'          => true,
1710
-        );
1711
-        if (is_main_site()) {
1712
-            $wp_options_to_delete['ee_network_config'] = true;
1713
-        }
1714
-        $undeleted_options = array();
1715
-        foreach ($wp_options_to_delete as $option_name => $no_wildcard) {
1716
-            if ($no_wildcard) {
1717
-                if ( ! delete_option($option_name)) {
1718
-                    $undeleted_options[] = $option_name;
1719
-                }
1720
-            } else {
1721
-                $option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'");
1722
-                foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) {
1723
-                    if ( ! delete_option($option_name_from_wildcard)) {
1724
-                        $undeleted_options[] = $option_name_from_wildcard;
1725
-                    }
1726
-                }
1727
-            }
1728
-        }
1729
-        //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it
1730
-        remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10);
1731
-        if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) {
1732
-            $db_update_sans_ee4 = array();
1733
-            foreach ($espresso_db_update as $version => $times_activated) {
1734
-                if ((string)$version[0] === '3') {//if its NON EE4
1735
-                    $db_update_sans_ee4[$version] = $times_activated;
1736
-                }
1737
-            }
1738
-            update_option('espresso_db_update', $db_update_sans_ee4);
1739
-        }
1740
-        $errors = '';
1741
-        if ( ! empty($undeleted_options)) {
1742
-            $errors .= sprintf(
1743
-                __('The following wp-options could not be deleted: %s%s', 'event_espresso'),
1744
-                '<br/>',
1745
-                implode(',<br/>', $undeleted_options)
1746
-            );
1747
-        }
1748
-        if ( ! empty($errors)) {
1749
-            EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__);
1750
-        }
1751
-    }
1752
-
1753
-    /**
1754
-     * Gets the mysql error code from the last used query by wpdb
1755
-     *
1756
-     * @return int mysql error code, see https://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html
1757
-     */
1758
-    public static function last_wpdb_error_code()
1759
-    {
1760
-        global $wpdb;
1761
-        if ($wpdb->use_mysqli) {
1762
-            return mysqli_errno($wpdb->dbh);
1763
-        } else {
1764
-            return mysql_errno($wpdb->dbh);
1765
-        }
1766
-    }
1767
-
1768
-    /**
1769
-     * Checks that the database table exists. Also works on temporary tables (for unit tests mostly).
1770
-     *
1771
-     * @global wpdb  $wpdb
1772
-     * @deprecated instead use TableAnalysis::tableExists()
1773
-     * @param string $table_name with or without $wpdb->prefix
1774
-     * @return boolean
1775
-     */
1776
-    public static function table_exists($table_name)
1777
-    {
1778
-        return \EEH_Activation::getTableAnalysis()->tableExists($table_name);
1779
-    }
1780
-
1781
-    /**
1782
-     * Resets the cache on EEH_Activation
1783
-     */
1784
-    public static function reset()
1785
-    {
1786
-        self::$_default_creator_id                             = null;
1787
-        self::$_initialized_db_content_already_in_this_request = false;
1788
-    }
1358
+		$new_templates_created_for_messenger = self::_activate_and_generate_default_messengers_and_message_templates(
1359
+			$message_resource_manager
1360
+		);
1361
+		/**
1362
+		 * This method is verifying there are no NEW default message types
1363
+		 * for ACTIVE messengers that need activated (and corresponding templates setup).
1364
+		 */
1365
+		$new_templates_created_for_message_type = self::_activate_new_message_types_for_active_messengers_and_generate_default_templates(
1366
+			$message_resource_manager
1367
+		);
1368
+		//after all is done, let's persist these changes to the db.
1369
+		$message_resource_manager->update_has_activated_messengers_option();
1370
+		$message_resource_manager->update_active_messengers_option();
1371
+		// will return true if either of these are true.  Otherwise will return false.
1372
+		return $new_templates_created_for_message_type || $new_templates_created_for_messenger;
1373
+	}
1374
+
1375
+
1376
+
1377
+	/**
1378
+	 * @param \EE_Message_Resource_Manager $message_resource_manager
1379
+	 * @return array|bool
1380
+	 * @throws \EE_Error
1381
+	 */
1382
+	protected static function _activate_new_message_types_for_active_messengers_and_generate_default_templates(
1383
+		EE_Message_Resource_Manager $message_resource_manager
1384
+	) {
1385
+		/** @type EE_messenger[] $active_messengers */
1386
+		$active_messengers = $message_resource_manager->active_messengers();
1387
+		$installed_message_types = $message_resource_manager->installed_message_types();
1388
+		$templates_created = false;
1389
+		foreach ($active_messengers as $active_messenger) {
1390
+			$default_message_type_names_for_messenger = $active_messenger->get_default_message_types();
1391
+			$default_message_type_names_to_activate = array();
1392
+			// looping through each default message type reported by the messenger
1393
+			// and setup the actual message types to activate.
1394
+			foreach ($default_message_type_names_for_messenger as $default_message_type_name_for_messenger) {
1395
+				// if already active or has already been activated before we skip
1396
+				// (otherwise we might reactivate something user's intentionally deactivated.)
1397
+				// we also skip if the message type is not installed.
1398
+				if (
1399
+					$message_resource_manager->has_message_type_been_activated_for_messenger(
1400
+						$default_message_type_name_for_messenger,
1401
+						$active_messenger->name
1402
+					)
1403
+					|| $message_resource_manager->is_message_type_active_for_messenger(
1404
+						$active_messenger->name,
1405
+						$default_message_type_name_for_messenger
1406
+					)
1407
+					|| ! isset($installed_message_types[$default_message_type_name_for_messenger])
1408
+				) {
1409
+					continue;
1410
+				}
1411
+				$default_message_type_names_to_activate[] = $default_message_type_name_for_messenger;
1412
+			}
1413
+			//let's activate!
1414
+			$message_resource_manager->ensure_message_types_are_active(
1415
+				$default_message_type_names_to_activate,
1416
+				$active_messenger->name,
1417
+				false
1418
+			);
1419
+			//activate the templates for these message types
1420
+			if ( ! empty($default_message_type_names_to_activate)) {
1421
+				$templates_created = EEH_MSG_Template::generate_new_templates(
1422
+					$active_messenger->name,
1423
+					$default_message_type_names_for_messenger,
1424
+					'',
1425
+					true
1426
+				);
1427
+			}
1428
+		}
1429
+		return $templates_created;
1430
+	}
1431
+
1432
+
1433
+
1434
+	/**
1435
+	 * This will activate and generate default messengers and default message types for those messengers.
1436
+	 *
1437
+	 * @param EE_message_Resource_Manager $message_resource_manager
1438
+	 * @return array|bool  True means there were default messengers and message type templates generated.
1439
+	 *                     False means that there were no templates generated
1440
+	 *                     (which could simply mean there are no default message types for a messenger).
1441
+	 * @throws EE_Error
1442
+	 */
1443
+	protected static function _activate_and_generate_default_messengers_and_message_templates(
1444
+		EE_Message_Resource_Manager $message_resource_manager
1445
+	) {
1446
+		/** @type EE_messenger[] $messengers_to_generate */
1447
+		$messengers_to_generate = self::_get_default_messengers_to_generate_on_activation($message_resource_manager);
1448
+		$installed_message_types = $message_resource_manager->installed_message_types();
1449
+		$templates_generated = false;
1450
+		foreach ($messengers_to_generate as $messenger_to_generate) {
1451
+			$default_message_type_names_for_messenger = $messenger_to_generate->get_default_message_types();
1452
+			//verify the default message types match an installed message type.
1453
+			foreach ($default_message_type_names_for_messenger as $key => $name) {
1454
+				if (
1455
+					! isset($installed_message_types[$name])
1456
+					|| $message_resource_manager->has_message_type_been_activated_for_messenger(
1457
+						$name,
1458
+						$messenger_to_generate->name
1459
+					)
1460
+				) {
1461
+					unset($default_message_type_names_for_messenger[$key]);
1462
+				}
1463
+			}
1464
+			// in previous iterations, the active_messengers option in the db
1465
+			// needed updated before calling create templates. however with the changes this may not be necessary.
1466
+			// This comment is left here just in case we discover that we _do_ need to update before
1467
+			// passing off to create templates (after the refactor is done).
1468
+			// @todo remove this comment when determined not necessary.
1469
+			$message_resource_manager->activate_messenger(
1470
+				$messenger_to_generate->name,
1471
+				$default_message_type_names_for_messenger,
1472
+				false
1473
+			);
1474
+			//create any templates needing created (or will reactivate templates already generated as necessary).
1475
+			if ( ! empty($default_message_type_names_for_messenger)) {
1476
+				$templates_generated = EEH_MSG_Template::generate_new_templates(
1477
+					$messenger_to_generate->name,
1478
+					$default_message_type_names_for_messenger,
1479
+					'',
1480
+					true
1481
+				);
1482
+			}
1483
+		}
1484
+		return $templates_generated;
1485
+	}
1486
+
1487
+
1488
+	/**
1489
+	 * This returns the default messengers to generate templates for on activation of EE.
1490
+	 * It considers:
1491
+	 * - whether a messenger is already active in the db.
1492
+	 * - whether a messenger has been made active at any time in the past.
1493
+	 *
1494
+	 * @static
1495
+	 * @param  EE_Message_Resource_Manager $message_resource_manager
1496
+	 * @return EE_messenger[]
1497
+	 */
1498
+	protected static function _get_default_messengers_to_generate_on_activation(
1499
+		EE_Message_Resource_Manager $message_resource_manager
1500
+	) {
1501
+		$active_messengers    = $message_resource_manager->active_messengers();
1502
+		$installed_messengers = $message_resource_manager->installed_messengers();
1503
+		$has_activated        = $message_resource_manager->get_has_activated_messengers_option();
1504
+
1505
+		$messengers_to_generate = array();
1506
+		foreach ($installed_messengers as $installed_messenger) {
1507
+			//if installed messenger is a messenger that should be activated on install
1508
+			//and is not already active
1509
+			//and has never been activated
1510
+			if (
1511
+				! $installed_messenger->activate_on_install
1512
+				|| isset($active_messengers[$installed_messenger->name])
1513
+				|| isset($has_activated[$installed_messenger->name])
1514
+			) {
1515
+				continue;
1516
+			}
1517
+			$messengers_to_generate[$installed_messenger->name] = $installed_messenger;
1518
+		}
1519
+		return $messengers_to_generate;
1520
+	}
1521
+
1522
+
1523
+	/**
1524
+	 * This simply validates active message types to ensure they actually match installed
1525
+	 * message types.  If there's a mismatch then we deactivate the message type and ensure all related db
1526
+	 * rows are set inactive.
1527
+	 * Note: Messengers are no longer validated here as of 4.9.0 because they get validated automatically whenever
1528
+	 * EE_Messenger_Resource_Manager is constructed.  Message Types are a bit more resource heavy for validation so they
1529
+	 * are still handled in here.
1530
+	 *
1531
+	 * @since 4.3.1
1532
+	 * @return void
1533
+	 */
1534
+	public static function validate_messages_system()
1535
+	{
1536
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
1537
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
1538
+		$message_resource_manager->validate_active_message_types_are_installed();
1539
+		do_action('AHEE__EEH_Activation__validate_messages_system');
1540
+	}
1541
+
1542
+
1543
+	/**
1544
+	 * create_no_ticket_prices_array
1545
+	 *
1546
+	 * @access public
1547
+	 * @static
1548
+	 * @return void
1549
+	 */
1550
+	public static function create_no_ticket_prices_array()
1551
+	{
1552
+		// this creates an array for tracking events that have no active ticket prices created
1553
+		// this allows us to warn admins of the situation so that it can be corrected
1554
+		$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', false);
1555
+		if (! $espresso_no_ticket_prices) {
1556
+			add_option('ee_no_ticket_prices', array(), '', false);
1557
+		}
1558
+	}
1559
+
1560
+
1561
+	/**
1562
+	 * plugin_deactivation
1563
+	 *
1564
+	 * @access public
1565
+	 * @static
1566
+	 * @return void
1567
+	 */
1568
+	public static function plugin_deactivation()
1569
+	{
1570
+	}
1571
+
1572
+
1573
+	/**
1574
+	 * Finds all our EE4 custom post types, and deletes them and their associated data
1575
+	 * (like post meta or term relations)
1576
+	 *
1577
+	 * @global wpdb $wpdb
1578
+	 * @throws \EE_Error
1579
+	 */
1580
+	public static function delete_all_espresso_cpt_data()
1581
+	{
1582
+		global $wpdb;
1583
+		//get all the CPT post_types
1584
+		$ee_post_types = array();
1585
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1586
+			if (method_exists($model_name, 'instance')) {
1587
+				$model_obj = call_user_func(array($model_name, 'instance'));
1588
+				if ($model_obj instanceof EEM_CPT_Base) {
1589
+					$ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type());
1590
+				}
1591
+			}
1592
+		}
1593
+		//get all our CPTs
1594
+		$query   = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (" . implode(",", $ee_post_types) . ")";
1595
+		$cpt_ids = $wpdb->get_col($query);
1596
+		//delete each post meta and term relations too
1597
+		foreach ($cpt_ids as $post_id) {
1598
+			wp_delete_post($post_id, true);
1599
+		}
1600
+	}
1601
+
1602
+	/**
1603
+	 * Deletes all EE custom tables
1604
+	 *
1605
+	 * @return array
1606
+	 */
1607
+	public static function drop_espresso_tables()
1608
+	{
1609
+		$tables = array();
1610
+		// load registry
1611
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1612
+			if (method_exists($model_name, 'instance')) {
1613
+				$model_obj = call_user_func(array($model_name, 'instance'));
1614
+				if ($model_obj instanceof EEM_Base) {
1615
+					foreach ($model_obj->get_tables() as $table) {
1616
+						if (strpos($table->get_table_name(), 'esp_')
1617
+							&&
1618
+							(
1619
+								is_main_site()//main site? nuke them all
1620
+								|| ! $table->is_global()//not main site,but not global either. nuke it
1621
+							)
1622
+						) {
1623
+							$tables[] = $table->get_table_name();
1624
+						}
1625
+					}
1626
+				}
1627
+			}
1628
+		}
1629
+
1630
+		//there are some tables whose models were removed.
1631
+		//they should be removed when removing all EE core's data
1632
+		$tables_without_models = array(
1633
+			'esp_promotion',
1634
+			'esp_promotion_applied',
1635
+			'esp_promotion_object',
1636
+			'esp_promotion_rule',
1637
+			'esp_rule',
1638
+		);
1639
+		foreach ($tables_without_models as $table) {
1640
+			$tables[] = $table;
1641
+		}
1642
+		return \EEH_Activation::getTableManager()->dropTables($tables);
1643
+	}
1644
+
1645
+
1646
+
1647
+	/**
1648
+	 * Drops all the tables mentioned in a single MYSQL query. Double-checks
1649
+	 * each table name provided has a wpdb prefix attached, and that it exists.
1650
+	 * Returns the list actually deleted
1651
+	 *
1652
+	 * @deprecated in 4.9.13. Instead use TableManager::dropTables()
1653
+	 * @global WPDB $wpdb
1654
+	 * @param array $table_names
1655
+	 * @return array of table names which we deleted
1656
+	 */
1657
+	public static function drop_tables($table_names)
1658
+	{
1659
+		return \EEH_Activation::getTableManager()->dropTables($table_names);
1660
+	}
1661
+
1662
+
1663
+
1664
+	/**
1665
+	 * plugin_uninstall
1666
+	 *
1667
+	 * @access public
1668
+	 * @static
1669
+	 * @param bool $remove_all
1670
+	 * @return void
1671
+	 */
1672
+	public static function delete_all_espresso_tables_and_data($remove_all = true)
1673
+	{
1674
+		global $wpdb;
1675
+		self::drop_espresso_tables();
1676
+		$wp_options_to_delete = array(
1677
+			'ee_no_ticket_prices'                => true,
1678
+			'ee_active_messengers'               => true,
1679
+			'ee_has_activated_messenger'         => true,
1680
+			'ee_flush_rewrite_rules'             => true,
1681
+			'ee_config'                          => false,
1682
+			'ee_data_migration_current_db_state' => true,
1683
+			'ee_data_migration_mapping_'         => false,
1684
+			'ee_data_migration_script_'          => false,
1685
+			'ee_data_migrations'                 => true,
1686
+			'ee_dms_map'                         => false,
1687
+			'ee_notices'                         => true,
1688
+			'lang_file_check_'                   => false,
1689
+			'ee_maintenance_mode'                => true,
1690
+			'ee_ueip_optin'                      => true,
1691
+			'ee_ueip_has_notified'               => true,
1692
+			'ee_plugin_activation_errors'        => true,
1693
+			'ee_id_mapping_from'                 => false,
1694
+			'espresso_persistent_admin_notices'  => true,
1695
+			'ee_encryption_key'                  => true,
1696
+			'pue_force_upgrade_'                 => false,
1697
+			'pue_json_error_'                    => false,
1698
+			'pue_install_key_'                   => false,
1699
+			'pue_verification_error_'            => false,
1700
+			'pu_dismissed_upgrade_'              => false,
1701
+			'external_updates-'                  => false,
1702
+			'ee_extra_data'                      => true,
1703
+			'ee_ssn_'                            => false,
1704
+			'ee_rss_'                            => false,
1705
+			'ee_rte_n_tx_'                       => false,
1706
+			'ee_pers_admin_notices'              => true,
1707
+			'ee_job_parameters_'                 => false,
1708
+			'ee_upload_directories_incomplete'   => true,
1709
+			'ee_verified_db_collations'          => true,
1710
+		);
1711
+		if (is_main_site()) {
1712
+			$wp_options_to_delete['ee_network_config'] = true;
1713
+		}
1714
+		$undeleted_options = array();
1715
+		foreach ($wp_options_to_delete as $option_name => $no_wildcard) {
1716
+			if ($no_wildcard) {
1717
+				if ( ! delete_option($option_name)) {
1718
+					$undeleted_options[] = $option_name;
1719
+				}
1720
+			} else {
1721
+				$option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'");
1722
+				foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) {
1723
+					if ( ! delete_option($option_name_from_wildcard)) {
1724
+						$undeleted_options[] = $option_name_from_wildcard;
1725
+					}
1726
+				}
1727
+			}
1728
+		}
1729
+		//also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it
1730
+		remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10);
1731
+		if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) {
1732
+			$db_update_sans_ee4 = array();
1733
+			foreach ($espresso_db_update as $version => $times_activated) {
1734
+				if ((string)$version[0] === '3') {//if its NON EE4
1735
+					$db_update_sans_ee4[$version] = $times_activated;
1736
+				}
1737
+			}
1738
+			update_option('espresso_db_update', $db_update_sans_ee4);
1739
+		}
1740
+		$errors = '';
1741
+		if ( ! empty($undeleted_options)) {
1742
+			$errors .= sprintf(
1743
+				__('The following wp-options could not be deleted: %s%s', 'event_espresso'),
1744
+				'<br/>',
1745
+				implode(',<br/>', $undeleted_options)
1746
+			);
1747
+		}
1748
+		if ( ! empty($errors)) {
1749
+			EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__);
1750
+		}
1751
+	}
1752
+
1753
+	/**
1754
+	 * Gets the mysql error code from the last used query by wpdb
1755
+	 *
1756
+	 * @return int mysql error code, see https://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html
1757
+	 */
1758
+	public static function last_wpdb_error_code()
1759
+	{
1760
+		global $wpdb;
1761
+		if ($wpdb->use_mysqli) {
1762
+			return mysqli_errno($wpdb->dbh);
1763
+		} else {
1764
+			return mysql_errno($wpdb->dbh);
1765
+		}
1766
+	}
1767
+
1768
+	/**
1769
+	 * Checks that the database table exists. Also works on temporary tables (for unit tests mostly).
1770
+	 *
1771
+	 * @global wpdb  $wpdb
1772
+	 * @deprecated instead use TableAnalysis::tableExists()
1773
+	 * @param string $table_name with or without $wpdb->prefix
1774
+	 * @return boolean
1775
+	 */
1776
+	public static function table_exists($table_name)
1777
+	{
1778
+		return \EEH_Activation::getTableAnalysis()->tableExists($table_name);
1779
+	}
1780
+
1781
+	/**
1782
+	 * Resets the cache on EEH_Activation
1783
+	 */
1784
+	public static function reset()
1785
+	{
1786
+		self::$_default_creator_id                             = null;
1787
+		self::$_initialized_db_content_already_in_this_request = false;
1788
+	}
1789 1789
 }
1790 1790
 // End of file EEH_Activation.helper.php
1791 1791
 // Location: /helpers/EEH_Activation.core.php
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public static function getTableAnalysis()
63 63
     {
64
-        if (! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis) {
64
+        if ( ! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis) {
65 65
             self::$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
66 66
         }
67 67
         return self::$table_analysis;
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
      */
74 74
     public static function getTableManager()
75 75
     {
76
-        if (! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager) {
76
+        if ( ! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager) {
77 77
             self::$table_manager = EE_Registry::instance()->create('TableManager', array(), true);
78 78
         }
79 79
         return self::$table_manager;
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
         if ($which_to_include === 'old') {
190 190
             $cron_tasks = array_filter(
191 191
                 $cron_tasks,
192
-                function ($value) {
192
+                function($value) {
193 193
                     return $value === EEH_Activation::cron_task_no_longer_in_use;
194 194
                 }
195 195
             );
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
     {
220 220
 
221 221
         foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) {
222
-            if (! wp_next_scheduled($hook_name)) {
222
+            if ( ! wp_next_scheduled($hook_name)) {
223 223
                 /**
224 224
                  * This allows client code to define the initial start timestamp for this schedule.
225 225
                  */
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
             3
325 325
         );
326 326
         //EE_Config::reset();
327
-        if (! EE_Config::logging_enabled()) {
327
+        if ( ! EE_Config::logging_enabled()) {
328 328
             delete_option(EE_Config::LOG_NAME);
329 329
         }
330 330
     }
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
     public static function load_calendar_config()
340 340
     {
341 341
         // grab array of all plugin folders and loop thru it
342
-        $plugins = glob(WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR);
342
+        $plugins = glob(WP_PLUGIN_DIR.DS.'*', GLOB_ONLYDIR);
343 343
         if (empty($plugins)) {
344 344
             return;
345 345
         }
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
                 || strpos($plugin, 'calendar') !== false
357 357
             ) {
358 358
                 // this is what we are looking for
359
-                $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php';
359
+                $calendar_config = $plugin_path.DS.'EE_Calendar_Config.php';
360 360
                 // does it exist in this folder ?
361 361
                 if (is_readable($calendar_config)) {
362 362
                     // YEAH! let's load it
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
             ) {
490 490
                 //update Config with post ID
491 491
                 $EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID;
492
-                if (! EE_Config::instance()->update_espresso_config(false, false)) {
492
+                if ( ! EE_Config::instance()->update_espresso_config(false, false)) {
493 493
                     $msg = __(
494 494
                         'The Event Espresso critical page configuration settings could not be updated.',
495 495
                         'event_espresso'
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
     public static function get_page_by_ee_shortcode($ee_shortcode)
539 539
     {
540 540
         global $wpdb;
541
-        $shortcode_and_opening_bracket = '[' . $ee_shortcode;
541
+        $shortcode_and_opening_bracket = '['.$ee_shortcode;
542 542
         $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1");
543 543
         if ($post_id) {
544 544
             return get_post($post_id);
@@ -564,11 +564,11 @@  discard block
 block discarded – undo
564 564
             'post_status'    => 'publish',
565 565
             'post_type'      => 'page',
566 566
             'comment_status' => 'closed',
567
-            'post_content'   => '[' . $critical_page['code'] . ']',
567
+            'post_content'   => '['.$critical_page['code'].']',
568 568
         );
569 569
 
570 570
         $post_id = wp_insert_post($post_args);
571
-        if (! $post_id) {
571
+        if ( ! $post_id) {
572 572
             $msg = sprintf(
573 573
                 __('The Event Espresso  critical page entitled "%s" could not be created.', 'event_espresso'),
574 574
                 $critical_page['name']
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
             return $critical_page;
578 578
         }
579 579
         // get newly created post's details
580
-        if (! $critical_page['post'] = get_post($post_id)) {
580
+        if ( ! $critical_page['post'] = get_post($post_id)) {
581 581
             $msg = sprintf(
582 582
                 __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'),
583 583
                 $critical_page['name']
@@ -664,17 +664,17 @@  discard block
 block discarded – undo
664 664
             $role_to_check
665 665
         );
666 666
         if ($pre_filtered_id !== false) {
667
-            return (int)$pre_filtered_id;
667
+            return (int) $pre_filtered_id;
668 668
         }
669 669
         $capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('capabilities');
670 670
         $query = $wpdb->prepare(
671 671
             "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1",
672
-            '%' . $role_to_check . '%'
672
+            '%'.$role_to_check.'%'
673 673
         );
674 674
         $user_id = $wpdb->get_var($query);
675 675
         $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id);
676
-        if ($user_id && (int)$user_id) {
677
-            self::$_default_creator_id = (int)$user_id;
676
+        if ($user_id && (int) $user_id) {
677
+            self::$_default_creator_id = (int) $user_id;
678 678
             return self::$_default_creator_id;
679 679
         } else {
680 680
             return null;
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
         }
710 710
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
711 711
         if ( ! function_exists('dbDelta')) {
712
-            require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
712
+            require_once(ABSPATH.'wp-admin/includes/upgrade.php');
713 713
         }
714 714
         $tableAnalysis = \EEH_Activation::getTableAnalysis();
715 715
         $wp_table_name = $tableAnalysis->ensureTableNameHasPrefix($table_name);
@@ -920,13 +920,13 @@  discard block
 block discarded – undo
920 920
             // reset values array
921 921
             $QSG_values = array();
922 922
             // if we don't have what we should have (but use $QST_system as as string because that's what we got from the db)
923
-            if (! in_array("$QSG_system", $question_groups)) {
923
+            if ( ! in_array("$QSG_system", $question_groups)) {
924 924
                 // add it
925 925
                 switch ($QSG_system) {
926 926
                     case 1:
927 927
                         $QSG_values = array(
928 928
                             'QSG_name'            => __('Personal Information', 'event_espresso'),
929
-                            'QSG_identifier'      => 'personal-information-' . time(),
929
+                            'QSG_identifier'      => 'personal-information-'.time(),
930 930
                             'QSG_desc'            => '',
931 931
                             'QSG_order'           => 1,
932 932
                             'QSG_show_group_name' => 1,
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
                     case 2:
939 939
                         $QSG_values = array(
940 940
                             'QSG_name'            => __('Address Information', 'event_espresso'),
941
-                            'QSG_identifier'      => 'address-information-' . time(),
941
+                            'QSG_identifier'      => 'address-information-'.time(),
942 942
                             'QSG_desc'            => '',
943 943
                             'QSG_order'           => 2,
944 944
                             'QSG_show_group_name' => 1,
@@ -949,7 +949,7 @@  discard block
 block discarded – undo
949 949
                         break;
950 950
                 }
951 951
                 // make sure we have some values before inserting them
952
-                if (! empty($QSG_values)) {
952
+                if ( ! empty($QSG_values)) {
953 953
                     // insert system question
954 954
                     $wpdb->insert(
955 955
                         $table_name,
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
             // reset values array
987 987
             $QST_values = array();
988 988
             // if we don't have what we should have
989
-            if (! in_array($QST_system, $questions)) {
989
+            if ( ! in_array($QST_system, $questions)) {
990 990
                 // add it
991 991
                 switch ($QST_system) {
992 992
                     case 'fname':
@@ -1138,7 +1138,7 @@  discard block
 block discarded – undo
1138 1138
                         );
1139 1139
                         break;
1140 1140
                 }
1141
-                if (! empty($QST_values)) {
1141
+                if ( ! empty($QST_values)) {
1142 1142
                     // insert system question
1143 1143
                     $wpdb->insert(
1144 1144
                         $table_name,
@@ -1199,7 +1199,7 @@  discard block
 block discarded – undo
1199 1199
      */
1200 1200
     public static function insert_default_payment_methods()
1201 1201
     {
1202
-        if (! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) {
1202
+        if ( ! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) {
1203 1203
             EE_Registry::instance()->load_lib('Payment_Method_Manager');
1204 1204
             EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
1205 1205
         } else {
@@ -1287,9 +1287,9 @@  discard block
 block discarded – undo
1287 1287
         $folders = array(
1288 1288
             EVENT_ESPRESSO_TEMPLATE_DIR,
1289 1289
             EVENT_ESPRESSO_GATEWAY_DIR,
1290
-            EVENT_ESPRESSO_UPLOAD_DIR . 'logs/',
1291
-            EVENT_ESPRESSO_UPLOAD_DIR . 'css/',
1292
-            EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/',
1290
+            EVENT_ESPRESSO_UPLOAD_DIR.'logs/',
1291
+            EVENT_ESPRESSO_UPLOAD_DIR.'css/',
1292
+            EVENT_ESPRESSO_UPLOAD_DIR.'tickets/',
1293 1293
         );
1294 1294
         foreach ($folders as $folder) {
1295 1295
             try {
@@ -1300,7 +1300,7 @@  discard block
 block discarded – undo
1300 1300
                     sprintf(
1301 1301
                         __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'),
1302 1302
                         $folder,
1303
-                        '<br />' . $e->getMessage()
1303
+                        '<br />'.$e->getMessage()
1304 1304
                     ),
1305 1305
                     __FILE__, __FUNCTION__, __LINE__
1306 1306
                 );
@@ -1311,7 +1311,7 @@  discard block
 block discarded – undo
1311 1311
         }
1312 1312
         //just add the .htaccess file to the logs directory to begin with. Even if logging
1313 1313
         //is disabled, there might be activation errors recorded in there
1314
-        EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs/');
1314
+        EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs/');
1315 1315
         //remember EE's folders are all good
1316 1316
         delete_option(EEH_Activation::upload_directories_incomplete_option_name);
1317 1317
         return true;
@@ -1547,7 +1547,7 @@  discard block
 block discarded – undo
1547 1547
         // this creates an array for tracking events that have no active ticket prices created
1548 1548
         // this allows us to warn admins of the situation so that it can be corrected
1549 1549
         $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', false);
1550
-        if (! $espresso_no_ticket_prices) {
1550
+        if ( ! $espresso_no_ticket_prices) {
1551 1551
             add_option('ee_no_ticket_prices', array(), '', false);
1552 1552
         }
1553 1553
     }
@@ -1586,7 +1586,7 @@  discard block
 block discarded – undo
1586 1586
             }
1587 1587
         }
1588 1588
         //get all our CPTs
1589
-        $query   = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (" . implode(",", $ee_post_types) . ")";
1589
+        $query   = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",", $ee_post_types).")";
1590 1590
         $cpt_ids = $wpdb->get_col($query);
1591 1591
         //delete each post meta and term relations too
1592 1592
         foreach ($cpt_ids as $post_id) {
@@ -1726,7 +1726,7 @@  discard block
 block discarded – undo
1726 1726
         if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) {
1727 1727
             $db_update_sans_ee4 = array();
1728 1728
             foreach ($espresso_db_update as $version => $times_activated) {
1729
-                if ((string)$version[0] === '3') {//if its NON EE4
1729
+                if ((string) $version[0] === '3') {//if its NON EE4
1730 1730
                     $db_update_sans_ee4[$version] = $times_activated;
1731 1731
                 }
1732 1732
             }
Please login to merge, or discard this patch.
modules/ticket_selector/EED_Ticket_Selector.module.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	 * process_ticket_selections
199 199
 	 *
200 200
 	 * @access        public
201
-	 * @return        array  or FALSE
201
+	 * @return        boolean|null  or FALSE
202 202
 	 * @throws \EE_Error
203 203
 	 */
204 204
 	public function process_ticket_selections() {
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
      * cancel_ticket_selections
213 213
      *
214 214
      * @access        public
215
-     * @return        string
215
+     * @return        false|null
216 216
      */
217 217
     public static function cancel_ticket_selections()
218 218
     {
Please login to merge, or discard this patch.
Indentation   +244 added lines, -244 removed lines patch added patch discarded remove patch
@@ -22,15 +22,15 @@  discard block
 block discarded – undo
22 22
  */
23 23
 class EED_Ticket_Selector extends  EED_Module {
24 24
 
25
-    /**
26
-     * @var EventEspresso\modules\ticket_selector\DisplayTicketSelector $ticket_selector
27
-     */
28
-    private static $ticket_selector;
25
+	/**
26
+	 * @var EventEspresso\modules\ticket_selector\DisplayTicketSelector $ticket_selector
27
+	 */
28
+	private static $ticket_selector;
29 29
 
30
-    /**
31
-     * @var EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton $iframe_embed_button
32
-     */
33
-    private static $iframe_embed_button;
30
+	/**
31
+	 * @var EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton $iframe_embed_button
32
+	 */
33
+	private static $iframe_embed_button;
34 34
 
35 35
 
36 36
 
@@ -61,13 +61,13 @@  discard block
 block discarded – undo
61 61
 		// routing
62 62
 		EE_Config::register_route( 'iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector' );
63 63
 		EE_Config::register_route( 'process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections' );
64
-        EE_Config::register_route('cancel_ticket_selections', 'EED_Ticket_Selector', 'cancel_ticket_selections');
65
-        add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 );
64
+		EE_Config::register_route('cancel_ticket_selections', 'EED_Ticket_Selector', 'cancel_ticket_selections');
65
+		add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 );
66 66
 		add_action( 'AHEE_event_details_header_bottom', array( 'EED_Ticket_Selector', 'display_ticket_selector' ), 10, 1 );
67
-        add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'translate_js_strings' ), 0 );
68
-        add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 );
69
-        EED_Ticket_Selector::loadIframeAssets();
70
-    }
67
+		add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'translate_js_strings' ), 0 );
68
+		add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 );
69
+		EED_Ticket_Selector::loadIframeAssets();
70
+	}
71 71
 
72 72
 
73 73
 
@@ -86,16 +86,16 @@  discard block
 block discarded – undo
86 86
 			10
87 87
 		);
88 88
 
89
-        /**
90
-         * Make sure assets for the ticket selector are loaded on the espresso registrations route so  admin side
91
-         * registrations work.
92
-         */
89
+		/**
90
+		 * Make sure assets for the ticket selector are loaded on the espresso registrations route so  admin side
91
+		 * registrations work.
92
+		 */
93 93
 		add_action(
94
-		    'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_registrations__new_registration',
95
-            array('EED_Ticket_Selector', 'set_definitions'),
96
-            10
97
-        );
98
-    }
94
+			'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_registrations__new_registration',
95
+			array('EED_Ticket_Selector', 'set_definitions'),
96
+			10
97
+		);
98
+	}
99 99
 
100 100
 
101 101
 
@@ -111,23 +111,23 @@  discard block
 block discarded – undo
111 111
 
112 112
 		//if config is not set, initialize
113 113
 		if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config ) {
114
-            \EED_Ticket_Selector::instance()->set_config();
115
-            \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config();
114
+			\EED_Ticket_Selector::instance()->set_config();
115
+			\EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config();
116 116
 		}
117 117
 	}
118 118
 
119 119
 
120 120
 
121 121
 	/**
122
-     * @return \EventEspresso\modules\ticket_selector\DisplayTicketSelector
123
-     */
124
-    public static function ticketSelector()
125
-    {
126
-        if ( ! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) {
127
-            EED_Ticket_Selector::$ticket_selector = new DisplayTicketSelector();
128
-        }
129
-        return EED_Ticket_Selector::$ticket_selector;
130
-    }
122
+	 * @return \EventEspresso\modules\ticket_selector\DisplayTicketSelector
123
+	 */
124
+	public static function ticketSelector()
125
+	{
126
+		if ( ! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) {
127
+			EED_Ticket_Selector::$ticket_selector = new DisplayTicketSelector();
128
+		}
129
+		return EED_Ticket_Selector::$ticket_selector;
130
+	}
131 131
 
132 132
 
133 133
 	/**
@@ -180,15 +180,15 @@  discard block
 block discarded – undo
180 180
 
181 181
 
182 182
 
183
-    /**
184
-     *    creates buttons for selecting number of attendees for an event
185
-     *
186
-     * @access    public
187
-     * @param    WP_Post|int $event
188
-     * @param    bool        $view_details
189
-     * @return    string
190
-     * @throws \EE_Error
191
-     */
183
+	/**
184
+	 *    creates buttons for selecting number of attendees for an event
185
+	 *
186
+	 * @access    public
187
+	 * @param    WP_Post|int $event
188
+	 * @param    bool        $view_details
189
+	 * @return    string
190
+	 * @throws \EE_Error
191
+	 */
192 192
 	public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) {
193 193
 		return EED_Ticket_Selector::ticketSelector()->display( $event, $view_details );
194 194
 	}
@@ -209,233 +209,233 @@  discard block
 block discarded – undo
209 209
 
210 210
 
211 211
 
212
-    /**
213
-     * cancel_ticket_selections
214
-     *
215
-     * @access        public
216
-     * @return        string
217
-     */
218
-    public static function cancel_ticket_selections()
219
-    {
220
-        $form = new ProcessTicketSelector();
221
-        return $form->cancelTicketSelections();
222
-    }
212
+	/**
213
+	 * cancel_ticket_selections
214
+	 *
215
+	 * @access        public
216
+	 * @return        string
217
+	 */
218
+	public static function cancel_ticket_selections()
219
+	{
220
+		$form = new ProcessTicketSelector();
221
+		return $form->cancelTicketSelections();
222
+	}
223 223
 
224 224
 
225 225
 
226 226
 	/**
227
-	* @return void
228
-	*/
227
+	 * @return void
228
+	 */
229 229
 	public static function translate_js_strings() {
230
-        EE_Registry::$i18n_js_strings['please_select_date_filter_notice'] = esc_html__(
231
-            'please select a datetime', 'event_espresso'
232
-        );
233
-    }
230
+		EE_Registry::$i18n_js_strings['please_select_date_filter_notice'] = esc_html__(
231
+			'please select a datetime', 'event_espresso'
232
+		);
233
+	}
234 234
 
235 235
 
236 236
 
237 237
 	/**
238
-	* 	load js
239
-	*
240
-	* 	@access 		public
241
-	* 	@return 		void
242
-	*/
238
+	 * 	load js
239
+	 *
240
+	 * 	@access 		public
241
+	 * 	@return 		void
242
+	 */
243 243
 	public static function load_tckt_slctr_assets() {
244 244
 		if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) {
245
-            // add some style
245
+			// add some style
246 246
 			wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css');
247 247
 			wp_enqueue_style('ticket_selector');
248 248
 			// make it dance
249 249
 			wp_register_script('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', array('espresso_core'), '', TRUE);
250 250
 			wp_enqueue_script('ticket_selector');
251
-            require_once( EE_LIBRARIES.'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php');
252
-            \EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts();
253
-        }
251
+			require_once( EE_LIBRARIES.'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php');
252
+			\EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts();
253
+		}
254
+	}
255
+
256
+
257
+
258
+	/**
259
+	 * @return void
260
+	 */
261
+	public static function loadIframeAssets()
262
+	{
263
+		// for event lists
264
+		add_filter(
265
+			'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
266
+			array('EED_Ticket_Selector', 'iframeCss')
267
+		);
268
+		add_filter(
269
+			'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
270
+			array('EED_Ticket_Selector', 'iframeJs')
271
+		);
272
+		// for ticket selectors
273
+		add_filter(
274
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
275
+			array('EED_Ticket_Selector', 'iframeCss')
276
+		);
277
+		add_filter(
278
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
279
+			array('EED_Ticket_Selector', 'iframeJs')
280
+		);
281
+	}
282
+
283
+
284
+
285
+	/**
286
+	 * Informs the rest of the forms system what CSS and JS is needed to display the input
287
+	 *
288
+	 * @param array $iframe_css
289
+	 * @return array
290
+	 */
291
+	public static function iframeCss(array $iframe_css)
292
+	{
293
+		$iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css';
294
+		return $iframe_css;
254 295
 	}
255 296
 
256 297
 
257 298
 
258
-    /**
259
-     * @return void
260
-     */
261
-    public static function loadIframeAssets()
262
-    {
263
-        // for event lists
264
-        add_filter(
265
-            'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
266
-            array('EED_Ticket_Selector', 'iframeCss')
267
-        );
268
-        add_filter(
269
-            'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
270
-            array('EED_Ticket_Selector', 'iframeJs')
271
-        );
272
-        // for ticket selectors
273
-        add_filter(
274
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
275
-            array('EED_Ticket_Selector', 'iframeCss')
276
-        );
277
-        add_filter(
278
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
279
-            array('EED_Ticket_Selector', 'iframeJs')
280
-        );
281
-    }
282
-
283
-
284
-
285
-    /**
286
-     * Informs the rest of the forms system what CSS and JS is needed to display the input
287
-     *
288
-     * @param array $iframe_css
289
-     * @return array
290
-     */
291
-    public static function iframeCss(array $iframe_css)
292
-    {
293
-        $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css';
294
-        return $iframe_css;
295
-    }
296
-
297
-
298
-
299
-    /**
300
-     * Informs the rest of the forms system what CSS and JS is needed to display the input
301
-     *
302
-     * @param array $iframe_js
303
-     * @return array
304
-     */
305
-    public static function iframeJs(array $iframe_js)
306
-    {
307
-        $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js';
308
-        return $iframe_js;
309
-    }
299
+	/**
300
+	 * Informs the rest of the forms system what CSS and JS is needed to display the input
301
+	 *
302
+	 * @param array $iframe_js
303
+	 * @return array
304
+	 */
305
+	public static function iframeJs(array $iframe_js)
306
+	{
307
+		$iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js';
308
+		return $iframe_js;
309
+	}
310 310
 
311 311
 
312 312
 	/****************************** DEPRECATED ******************************/
313 313
 
314 314
 
315 315
 
316
-    /**
317
-     * @deprecated
318
-     * @return string
319
-     * @throws \EE_Error
320
-     */
321
-    public static function display_view_details_btn()
322
-    {
323
-        // todo add doing_it_wrong() notice during next major version
324
-        return EED_Ticket_Selector::ticketSelector()->displayViewDetailsButton();
325
-    }
326
-
327
-
328
-
329
-    /**
330
-     * @deprecated
331
-     * @return string
332
-     * @throws \EE_Error
333
-     */
334
-    public static function display_ticket_selector_submit()
335
-    {
336
-        // todo add doing_it_wrong() notice during next major version
337
-        return EED_Ticket_Selector::ticketSelector()->displaySubmitButton();
338
-    }
339
-
340
-
341
-
342
-    /**
343
-     * @deprecated
344
-     * @param string $permalink_string
345
-     * @param int    $id
346
-     * @param string $new_title
347
-     * @param string $new_slug
348
-     * @return string
349
-     */
350
-    public static function iframe_code_button($permalink_string, $id, $new_title = '', $new_slug = '')
351
-    {
352
-        // todo add doing_it_wrong() notice during next major version
353
-        if (
354
-        	\EE_Registry::instance()->REQ->get('page') === 'espresso_events'
355
-        	&& \EE_Registry::instance()->REQ->get('action') === 'edit'
356
-        ) {
357
-            $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton();
358
-            $iframe_embed_button->addEventEditorIframeEmbedButton();
359
-        }
360
-        return '';
361
-    }
362
-
363
-
364
-
365
-    /**
366
-     * @deprecated
367
-     * @param int    $ID
368
-     * @param string $external_url
369
-     * @return string
370
-     */
371
-    public static function ticket_selector_form_open($ID = 0, $external_url = '')
372
-    {
373
-        // todo add doing_it_wrong() notice during next major version
374
-        return EED_Ticket_Selector::ticketSelector()->formOpen($ID, $external_url);
375
-    }
376
-
377
-
378
-
379
-    /**
380
-     * @deprecated
381
-     * @return string
382
-     */
383
-    public static function ticket_selector_form_close()
384
-    {
385
-        // todo add doing_it_wrong() notice during next major version
386
-        return EED_Ticket_Selector::ticketSelector()->formClose();
387
-    }
388
-
389
-
390
-
391
-    /**
392
-     * @deprecated
393
-     * @return string
394
-     */
395
-    public static function no_tkt_slctr_end_dv()
396
-    {
397
-        // todo add doing_it_wrong() notice during next major version
398
-        return EED_Ticket_Selector::ticketSelector()->ticketSelectorEndDiv();
399
-    }
400
-
401
-
402
-
403
-    /**
404
-     * @deprecated 4.9.13
405
-     * @return string
406
-     */
407
-    public static function tkt_slctr_end_dv()
408
-    {
409
-        return EED_Ticket_Selector::ticketSelector()->clearTicketSelector();
410
-    }
411
-
412
-
413
-
414
-    /**
415
-     * @deprecated
416
-     * @return string
417
-     */
418
-    public static function clear_tkt_slctr()
419
-    {
420
-        return EED_Ticket_Selector::ticketSelector()->clearTicketSelector();
421
-    }
422
-
423
-
424
-
425
-    /**
426
-     * @deprecated
427
-     */
428
-    public static function load_tckt_slctr_assets_admin()
429
-    {
430
-        // todo add doing_it_wrong() notice during next major version
431
-	    if (
432
-		    \EE_Registry::instance()->REQ->get( 'page' ) === 'espresso_events'
433
-		    && \EE_Registry::instance()->REQ->get( 'action' ) === 'edit'
434
-	    ) {
435
-		    $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton();
436
-            $iframe_embed_button->embedButtonAssets();
437
-        }
438
-    }
316
+	/**
317
+	 * @deprecated
318
+	 * @return string
319
+	 * @throws \EE_Error
320
+	 */
321
+	public static function display_view_details_btn()
322
+	{
323
+		// todo add doing_it_wrong() notice during next major version
324
+		return EED_Ticket_Selector::ticketSelector()->displayViewDetailsButton();
325
+	}
326
+
327
+
328
+
329
+	/**
330
+	 * @deprecated
331
+	 * @return string
332
+	 * @throws \EE_Error
333
+	 */
334
+	public static function display_ticket_selector_submit()
335
+	{
336
+		// todo add doing_it_wrong() notice during next major version
337
+		return EED_Ticket_Selector::ticketSelector()->displaySubmitButton();
338
+	}
339
+
340
+
341
+
342
+	/**
343
+	 * @deprecated
344
+	 * @param string $permalink_string
345
+	 * @param int    $id
346
+	 * @param string $new_title
347
+	 * @param string $new_slug
348
+	 * @return string
349
+	 */
350
+	public static function iframe_code_button($permalink_string, $id, $new_title = '', $new_slug = '')
351
+	{
352
+		// todo add doing_it_wrong() notice during next major version
353
+		if (
354
+			\EE_Registry::instance()->REQ->get('page') === 'espresso_events'
355
+			&& \EE_Registry::instance()->REQ->get('action') === 'edit'
356
+		) {
357
+			$iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton();
358
+			$iframe_embed_button->addEventEditorIframeEmbedButton();
359
+		}
360
+		return '';
361
+	}
362
+
363
+
364
+
365
+	/**
366
+	 * @deprecated
367
+	 * @param int    $ID
368
+	 * @param string $external_url
369
+	 * @return string
370
+	 */
371
+	public static function ticket_selector_form_open($ID = 0, $external_url = '')
372
+	{
373
+		// todo add doing_it_wrong() notice during next major version
374
+		return EED_Ticket_Selector::ticketSelector()->formOpen($ID, $external_url);
375
+	}
376
+
377
+
378
+
379
+	/**
380
+	 * @deprecated
381
+	 * @return string
382
+	 */
383
+	public static function ticket_selector_form_close()
384
+	{
385
+		// todo add doing_it_wrong() notice during next major version
386
+		return EED_Ticket_Selector::ticketSelector()->formClose();
387
+	}
388
+
389
+
390
+
391
+	/**
392
+	 * @deprecated
393
+	 * @return string
394
+	 */
395
+	public static function no_tkt_slctr_end_dv()
396
+	{
397
+		// todo add doing_it_wrong() notice during next major version
398
+		return EED_Ticket_Selector::ticketSelector()->ticketSelectorEndDiv();
399
+	}
400
+
401
+
402
+
403
+	/**
404
+	 * @deprecated 4.9.13
405
+	 * @return string
406
+	 */
407
+	public static function tkt_slctr_end_dv()
408
+	{
409
+		return EED_Ticket_Selector::ticketSelector()->clearTicketSelector();
410
+	}
411
+
412
+
413
+
414
+	/**
415
+	 * @deprecated
416
+	 * @return string
417
+	 */
418
+	public static function clear_tkt_slctr()
419
+	{
420
+		return EED_Ticket_Selector::ticketSelector()->clearTicketSelector();
421
+	}
422
+
423
+
424
+
425
+	/**
426
+	 * @deprecated
427
+	 */
428
+	public static function load_tckt_slctr_assets_admin()
429
+	{
430
+		// todo add doing_it_wrong() notice during next major version
431
+		if (
432
+			\EE_Registry::instance()->REQ->get( 'page' ) === 'espresso_events'
433
+			&& \EE_Registry::instance()->REQ->get( 'action' ) === 'edit'
434
+		) {
435
+			$iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton();
436
+			$iframe_embed_button->embedButtonAssets();
437
+		}
438
+	}
439 439
 
440 440
 
441 441
 }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 use EventEspresso\modules\ticket_selector\TicketSelectorIframe;
4 4
 use EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton;
5 5
 
6
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
7
-	exit( 'No direct script access allowed' );
6
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
7
+	exit('No direct script access allowed');
8 8
 }
9 9
 
10 10
 
@@ -38,15 +38,15 @@  discard block
 block discarded – undo
38 38
 	 * @return EED_Ticket_Selector
39 39
 	 */
40 40
 	public static function instance() {
41
-		return parent::get_instance( __CLASS__ );
41
+		return parent::get_instance(__CLASS__);
42 42
 	}
43 43
 
44 44
 
45 45
 
46
-	protected function set_config(){
47
-		$this->set_config_section( 'template_settings' );
48
-		$this->set_config_class( 'EE_Ticket_Selector_Config' );
49
-		$this->set_config_name( 'EED_Ticket_Selector' );
46
+	protected function set_config() {
47
+		$this->set_config_section('template_settings');
48
+		$this->set_config_class('EE_Ticket_Selector_Config');
49
+		$this->set_config_name('EED_Ticket_Selector');
50 50
 	}
51 51
 
52 52
 
@@ -59,13 +59,13 @@  discard block
 block discarded – undo
59 59
 	 */
60 60
 	public static function set_hooks() {
61 61
 		// routing
62
-		EE_Config::register_route( 'iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector' );
63
-		EE_Config::register_route( 'process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections' );
62
+		EE_Config::register_route('iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector');
63
+		EE_Config::register_route('process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections');
64 64
         EE_Config::register_route('cancel_ticket_selections', 'EED_Ticket_Selector', 'cancel_ticket_selections');
65
-        add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 );
66
-		add_action( 'AHEE_event_details_header_bottom', array( 'EED_Ticket_Selector', 'display_ticket_selector' ), 10, 1 );
67
-        add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'translate_js_strings' ), 0 );
68
-        add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 );
65
+        add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2);
66
+		add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1);
67
+        add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'translate_js_strings'), 0);
68
+        add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10);
69 69
         EED_Ticket_Selector::loadIframeAssets();
70 70
     }
71 71
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 		// to load assets for "espresso_events" page on the "edit" route (action)
83 83
 		add_action(
84 84
 			'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__edit',
85
-			array( 'EED_Ticket_Selector', 'ticket_selector_iframe_embed_button' ),
85
+			array('EED_Ticket_Selector', 'ticket_selector_iframe_embed_button'),
86 86
 			10
87 87
 		);
88 88
 
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 	 *  @return 	void
107 107
 	 */
108 108
 	public static function set_definitions() {
109
-		define( 'TICKET_SELECTOR_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS );
110
-		define( 'TICKET_SELECTOR_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS );
109
+		define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS);
110
+		define('TICKET_SELECTOR_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS);
111 111
 
112 112
 		//if config is not set, initialize
113
-		if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config ) {
113
+		if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) {
114 114
             \EED_Ticket_Selector::instance()->set_config();
115 115
             \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config();
116 116
 		}
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	 * 	@param	WP $WP
138 138
 	 * 	@return void
139 139
 	 */
140
-	public function run( $WP ) {}
140
+	public function run($WP) {}
141 141
 
142 142
 
143 143
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * @return \EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton
146 146
 	 */
147 147
 	public static function getIframeEmbedButton() {
148
-		if ( ! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton ) {
148
+		if ( ! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton) {
149 149
 			self::$iframe_embed_button = new TicketSelectorIframeEmbedButton();
150 150
 		}
151 151
 		return self::$iframe_embed_button;
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
      * @return    string
190 190
      * @throws \EE_Error
191 191
      */
192
-	public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) {
193
-		return EED_Ticket_Selector::ticketSelector()->display( $event, $view_details );
192
+	public static function display_ticket_selector($event = NULL, $view_details = FALSE) {
193
+		return EED_Ticket_Selector::ticketSelector()->display($event, $view_details);
194 194
 	}
195 195
 
196 196
 
@@ -241,14 +241,14 @@  discard block
 block discarded – undo
241 241
 	* 	@return 		void
242 242
 	*/
243 243
 	public static function load_tckt_slctr_assets() {
244
-		if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) {
244
+		if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE)) {
245 245
             // add some style
246
-			wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css');
246
+			wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css');
247 247
 			wp_enqueue_style('ticket_selector');
248 248
 			// make it dance
249
-			wp_register_script('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', array('espresso_core'), '', TRUE);
249
+			wp_register_script('ticket_selector', TICKET_SELECTOR_ASSETS_URL.'ticket_selector.js', array('espresso_core'), '', TRUE);
250 250
 			wp_enqueue_script('ticket_selector');
251
-            require_once( EE_LIBRARIES.'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php');
251
+            require_once(EE_LIBRARIES.'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php');
252 252
             \EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts();
253 253
         }
254 254
 	}
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
      */
291 291
     public static function iframeCss(array $iframe_css)
292 292
     {
293
-        $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css';
293
+        $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css';
294 294
         return $iframe_css;
295 295
     }
296 296
 
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
      */
305 305
     public static function iframeJs(array $iframe_js)
306 306
     {
307
-        $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js';
307
+        $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL.'ticket_selector.js';
308 308
         return $iframe_js;
309 309
     }
310 310
 
@@ -429,8 +429,8 @@  discard block
 block discarded – undo
429 429
     {
430 430
         // todo add doing_it_wrong() notice during next major version
431 431
 	    if (
432
-		    \EE_Registry::instance()->REQ->get( 'page' ) === 'espresso_events'
433
-		    && \EE_Registry::instance()->REQ->get( 'action' ) === 'edit'
432
+		    \EE_Registry::instance()->REQ->get('page') === 'espresso_events'
433
+		    && \EE_Registry::instance()->REQ->get('action') === 'edit'
434 434
 	    ) {
435 435
 		    $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton();
436 436
             $iframe_embed_button->embedButtonAssets();
Please login to merge, or discard this patch.
public/template_tags.php 2 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
  * can_use_espresso_conditionals
144 144
  * tests whether the Espresso Conditional tags like is_espresso_event_single() can be called
145 145
  *
146
- * @param $conditional_tag
146
+ * @param string $conditional_tag
147 147
  * @return bool
148 148
  */
149 149
 function can_use_espresso_conditionals( $conditional_tag ) {
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
 	/**
856 856
 	 * espresso_event_venues
857 857
 	 *
858
-	 * @return array  all venues related to an event
858
+	 * @return EE_Venue[]  all venues related to an event
859 859
 	 */
860 860
 	function espresso_event_venues() {
861 861
 		return EEH_Venue_View::get_event_venues();
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
 	 *
889 889
 	 * @param int     $VNU_ID optional, the venue id to check.
890 890
 	 *
891
-	 * @return bool | null
891
+	 * @return null|boolean | null
892 892
 	 */
893 893
 	function espresso_is_venue_private( $VNU_ID = 0 ) {
894 894
 		return EEH_Venue_View::is_venue_private( $VNU_ID );
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
 	 * returns true or false if a venue is password protected or not
903 903
 	 *
904 904
 	 * @param int     $VNU_ID optional, the venue id to check.
905
-	 * @return string
905
+	 * @return boolean
906 906
 	 */
907 907
 	function espresso_venue_is_password_protected( $VNU_ID = 0 ) {
908 908
 		EE_Registry::instance()->load_helper( 'Venue_View' );
Please login to merge, or discard this patch.
Spacing   +276 added lines, -276 removed lines patch added patch discarded remove patch
@@ -27,12 +27,12 @@  discard block
 block discarded – undo
27 27
  * @param int | \EE_Event $event
28 28
  * @return bool
29 29
  */
30
-function is_espresso_event( $event = NULL ) {
31
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
30
+function is_espresso_event($event = NULL) {
31
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
32 32
 		// extract EE_Event object from passed param regardless of what it is (within reason of course)
33
-		$event = EEH_Event_View::get_event( $event );
33
+		$event = EEH_Event_View::get_event($event);
34 34
 		// do we have a valid event ?
35
-		return $event instanceof EE_Event  ? TRUE : FALSE;
35
+		return $event instanceof EE_Event ? TRUE : FALSE;
36 36
 	}
37 37
 	return FALSE;
38 38
 }
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
  * @return bool
45 45
  */
46 46
 function is_espresso_event_single() {
47
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
47
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
48 48
 		global $wp_query;
49 49
 		// return conditionals set by CPTs
50 50
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_single : FALSE;
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
  * @return bool
60 60
  */
61 61
 function is_espresso_event_archive() {
62
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
62
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
63 63
 		global $wp_query;
64 64
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_archive : FALSE;
65 65
 	}
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
  * @return bool
74 74
  */
75 75
 function is_espresso_event_taxonomy() {
76
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
76
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
77 77
 		global $wp_query;
78 78
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_taxonomy : FALSE;
79 79
 	}
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
  * @param int | \EE_Venue $venue
88 88
  * @return bool
89 89
  */
90
-function is_espresso_venue( $venue = NULL ) {
91
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
90
+function is_espresso_venue($venue = NULL) {
91
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
92 92
 		// extract EE_Venue object from passed param regardless of what it is (within reason of course)
93
-		$venue = EEH_Venue_View::get_venue( $venue, FALSE );
93
+		$venue = EEH_Venue_View::get_venue($venue, FALSE);
94 94
 		// do we have a valid event ?
95 95
 		return $venue instanceof EE_Venue ? TRUE : FALSE;
96 96
 	}
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
  * @return bool
105 105
  */
106 106
 function is_espresso_venue_single() {
107
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
107
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
108 108
 		global $wp_query;
109 109
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_single : FALSE;
110 110
 	}
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
  * @return bool
119 119
  */
120 120
 function is_espresso_venue_archive() {
121
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
121
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
122 122
 		global $wp_query;
123 123
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_archive : FALSE;
124 124
 	}
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
  * @return bool
133 133
  */
134 134
 function is_espresso_venue_taxonomy() {
135
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
135
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
136 136
 		global $wp_query;
137 137
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_taxonomy : FALSE;
138 138
 	}
@@ -146,12 +146,12 @@  discard block
 block discarded – undo
146 146
  * @param $conditional_tag
147 147
  * @return bool
148 148
  */
149
-function can_use_espresso_conditionals( $conditional_tag ) {
150
-	if ( ! did_action( 'AHEE__EE_System__initialize' )) {
149
+function can_use_espresso_conditionals($conditional_tag) {
150
+	if ( ! did_action('AHEE__EE_System__initialize')) {
151 151
 		EE_Error::doing_it_wrong(
152 152
 			__FUNCTION__,
153 153
 			sprintf(
154
-				__( 'The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.','event_espresso'),
154
+				__('The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.', 'event_espresso'),
155 155
 				$conditional_tag
156 156
 			),
157 157
 			'4.4.0'
@@ -166,13 +166,13 @@  discard block
 block discarded – undo
166 166
 
167 167
 /*************************** Event Queries ***************************/
168 168
 
169
-if ( ! function_exists( 'espresso_get_events' )) {
169
+if ( ! function_exists('espresso_get_events')) {
170 170
 	/**
171 171
 	 * 	espresso_get_events
172 172
 	 * @param array $params
173 173
 	 * @return array
174 174
 	 */
175
-	function espresso_get_events( $params = array() ) {
175
+	function espresso_get_events($params = array()) {
176 176
 		//set default params
177 177
 		$default_espresso_events_params = array(
178 178
 			'limit' => 10,
@@ -183,18 +183,18 @@  discard block
 block discarded – undo
183 183
 			'sort' => 'ASC'
184 184
 		);
185 185
 		// allow the defaults to be filtered
186
-		$default_espresso_events_params = apply_filters( 'espresso_get_events__default_espresso_events_params', $default_espresso_events_params );
186
+		$default_espresso_events_params = apply_filters('espresso_get_events__default_espresso_events_params', $default_espresso_events_params);
187 187
 		// grab params and merge with defaults, then extract
188
-		$params = array_merge( $default_espresso_events_params, $params );
188
+		$params = array_merge($default_espresso_events_params, $params);
189 189
 		// run the query
190
-		$events_query = new EE_Event_List_Query( $params );
190
+		$events_query = new EE_Event_List_Query($params);
191 191
 		// assign results to a variable so we can return it
192 192
 		$events = $events_query->have_posts() ? $events_query->posts : array();
193 193
 		// but first reset the query and postdata
194 194
 		wp_reset_query();
195 195
 		wp_reset_postdata();
196 196
 		EED_Events_Archive::remove_all_events_archive_filters();
197
-		unset( $events_query );
197
+		unset($events_query);
198 198
 		return $events;
199 199
 	}
200 200
 }
@@ -208,32 +208,32 @@  discard block
 block discarded – undo
208 208
  * espresso_load_ticket_selector
209 209
  */
210 210
 function espresso_load_ticket_selector() {
211
-	EE_Registry::instance()->load_file( EE_MODULES . 'ticket_selector', 'EED_Ticket_Selector', 'module' );
211
+	EE_Registry::instance()->load_file(EE_MODULES.'ticket_selector', 'EED_Ticket_Selector', 'module');
212 212
 }
213 213
 
214
-if ( ! function_exists( 'espresso_ticket_selector' )) {
214
+if ( ! function_exists('espresso_ticket_selector')) {
215 215
 	/**
216 216
 	 * espresso_ticket_selector
217 217
 	 * @param null $event
218 218
 	 */
219
-	function espresso_ticket_selector( $event = NULL ) {
220
-		if (  ! apply_filters( 'FHEE_disable_espresso_ticket_selector', FALSE ) ) {
219
+	function espresso_ticket_selector($event = NULL) {
220
+		if ( ! apply_filters('FHEE_disable_espresso_ticket_selector', FALSE)) {
221 221
 			espresso_load_ticket_selector();
222
-			echo EED_Ticket_Selector::display_ticket_selector( $event );
222
+			echo EED_Ticket_Selector::display_ticket_selector($event);
223 223
 		}
224 224
 	}
225 225
 }
226 226
 
227 227
 
228
-	if ( ! function_exists( 'espresso_view_details_btn' )) {
228
+	if ( ! function_exists('espresso_view_details_btn')) {
229 229
 	/**
230 230
 	 * espresso_view_details_btn
231 231
 	 * @param null $event
232 232
 	 */
233
-	function espresso_view_details_btn( $event = NULL ) {
234
-		if (  ! apply_filters( 'FHEE_disable_espresso_view_details_btn', FALSE ) ) {
233
+	function espresso_view_details_btn($event = NULL) {
234
+		if ( ! apply_filters('FHEE_disable_espresso_view_details_btn', FALSE)) {
235 235
 			espresso_load_ticket_selector();
236
-			echo EED_Ticket_Selector::display_ticket_selector( $event, TRUE );
236
+			echo EED_Ticket_Selector::display_ticket_selector($event, TRUE);
237 237
 		}
238 238
 	}
239 239
 }
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 
244 244
 /*************************** EEH_Event_View ***************************/
245 245
 
246
-if ( ! function_exists( 'espresso_load_event_list_assets' )) {
246
+if ( ! function_exists('espresso_load_event_list_assets')) {
247 247
 	/**
248 248
 	 * espresso_load_event_list_assets
249 249
 	 * ensures that event list styles and scripts are loaded
@@ -252,13 +252,13 @@  discard block
 block discarded – undo
252 252
 	 */
253 253
 	function espresso_load_event_list_assets() {
254 254
 		$event_list = EED_Events_Archive::instance();
255
-		add_action( 'AHEE__EE_System__initialize_last', array( $event_list, 'load_event_list_assets' ), 10 );
256
-		add_filter( 'FHEE_enable_default_espresso_css', '__return_true' );
255
+		add_action('AHEE__EE_System__initialize_last', array($event_list, 'load_event_list_assets'), 10);
256
+		add_filter('FHEE_enable_default_espresso_css', '__return_true');
257 257
 	}
258 258
 }
259 259
 
260 260
 
261
-if ( ! function_exists( 'espresso_event_reg_button' )) {
261
+if ( ! function_exists('espresso_event_reg_button')) {
262 262
 	/**
263 263
 	 * espresso_event_reg_button
264 264
 	 * returns the "Register Now" button if event is active,
@@ -270,9 +270,9 @@  discard block
 block discarded – undo
270 270
 	 * @param bool $EVT_ID
271 271
 	 * @return string
272 272
 	 */
273
-	function espresso_event_reg_button( $btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE ) {
274
-		$event_status = EEH_Event_View::event_active_status( $EVT_ID );
275
-		switch ( $event_status ) {
273
+	function espresso_event_reg_button($btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE) {
274
+		$event_status = EEH_Event_View::event_active_status($EVT_ID);
275
+		switch ($event_status) {
276 276
 			case EE_Datetime::sold_out :
277 277
 				$btn_text = __('Sold Out', 'event_espresso');
278 278
 				$class = 'ee-pink';
@@ -288,10 +288,10 @@  discard block
 block discarded – undo
288 288
 			case EE_Datetime::upcoming :
289 289
 			case EE_Datetime::active :
290 290
 			default :
291
-				$btn_text =! empty( $btn_text_if_active ) ? $btn_text_if_active : __( 'Register Now', 'event_espresso' );
291
+				$btn_text = ! empty($btn_text_if_active) ? $btn_text_if_active : __('Register Now', 'event_espresso');
292 292
 				$class = 'ee-green';
293 293
 		}
294
-		if ( $event_status < 1 && ! empty( $btn_text_if_inactive )) {
294
+		if ($event_status < 1 && ! empty($btn_text_if_inactive)) {
295 295
 			$btn_text = $btn_text_if_inactive;
296 296
 			$class = 'ee-grey';
297 297
 		}
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 
306 306
 
307 307
 
308
-if ( ! function_exists( 'espresso_display_ticket_selector' )) {
308
+if ( ! function_exists('espresso_display_ticket_selector')) {
309 309
 	/**
310 310
 	 * espresso_display_ticket_selector
311 311
 	 * whether or not to display the Ticket Selector for an event
@@ -313,14 +313,14 @@  discard block
 block discarded – undo
313 313
 	 * @param bool $EVT_ID
314 314
 	 * @return boolean
315 315
 	 */
316
-	function espresso_display_ticket_selector( $EVT_ID = FALSE ) {
317
-		return EEH_Event_View::display_ticket_selector( $EVT_ID );
316
+	function espresso_display_ticket_selector($EVT_ID = FALSE) {
317
+		return EEH_Event_View::display_ticket_selector($EVT_ID);
318 318
 	}
319 319
 }
320 320
 
321 321
 
322 322
 
323
-if ( ! function_exists( 'espresso_event_status_banner' )) {
323
+if ( ! function_exists('espresso_event_status_banner')) {
324 324
 	/**
325 325
 	 * espresso_event_status
326 326
 	 * returns a banner showing the event status if it is sold out, expired, or inactive
@@ -328,13 +328,13 @@  discard block
 block discarded – undo
328 328
 	 * @param bool $EVT_ID
329 329
 	 * @return string
330 330
 	 */
331
-	function espresso_event_status_banner( $EVT_ID = FALSE ) {
332
-		return EEH_Event_View::event_status( $EVT_ID );
331
+	function espresso_event_status_banner($EVT_ID = FALSE) {
332
+		return EEH_Event_View::event_status($EVT_ID);
333 333
 	}
334 334
 }
335 335
 
336 336
 
337
-if ( ! function_exists( 'espresso_event_status' )) {
337
+if ( ! function_exists('espresso_event_status')) {
338 338
 	/**
339 339
 	 * espresso_event_status
340 340
 	 * returns the event status if it is sold out, expired, or inactive
@@ -343,17 +343,17 @@  discard block
 block discarded – undo
343 343
 	 * @param bool $echo
344 344
 	 * @return string
345 345
 	 */
346
-	function espresso_event_status( $EVT_ID = 0, $echo = TRUE ) {
347
-		if ( $echo ) {
348
-			echo EEH_Event_View::event_active_status( $EVT_ID );
346
+	function espresso_event_status($EVT_ID = 0, $echo = TRUE) {
347
+		if ($echo) {
348
+			echo EEH_Event_View::event_active_status($EVT_ID);
349 349
 			return '';
350 350
 		}
351
-		return EEH_Event_View::event_active_status( $EVT_ID );
351
+		return EEH_Event_View::event_active_status($EVT_ID);
352 352
 	}
353 353
 }
354 354
 
355 355
 
356
-if ( ! function_exists( 'espresso_event_categories' )) {
356
+if ( ! function_exists('espresso_event_categories')) {
357 357
 	/**
358 358
 	 * espresso_event_categories
359 359
 	 * returns the terms associated with an event
@@ -363,17 +363,17 @@  discard block
 block discarded – undo
363 363
 	 * @param bool $echo
364 364
 	 * @return string
365 365
 	 */
366
-	function espresso_event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE ) {
367
-		if ( $echo ) {
368
-			echo EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized );
366
+	function espresso_event_categories($EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) {
367
+		if ($echo) {
368
+			echo EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized);
369 369
 			return '';
370 370
 		}
371
-		return EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized );
371
+		return EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized);
372 372
 	}
373 373
 }
374 374
 
375 375
 
376
-if ( ! function_exists( 'espresso_event_tickets_available' )) {
376
+if ( ! function_exists('espresso_event_tickets_available')) {
377 377
 	/**
378 378
 	 * espresso_event_tickets_available
379 379
 	 * returns the ticket types available for purchase for an event
@@ -383,26 +383,26 @@  discard block
 block discarded – undo
383 383
 	 * @param bool $format
384 384
 	 * @return string
385 385
 	 */
386
-	function espresso_event_tickets_available( $EVT_ID = 0, $echo = TRUE, $format = TRUE ) {
387
-		$tickets = EEH_Event_View::event_tickets_available( $EVT_ID );
388
-		if ( is_array( $tickets ) && ! empty( $tickets )) {
386
+	function espresso_event_tickets_available($EVT_ID = 0, $echo = TRUE, $format = TRUE) {
387
+		$tickets = EEH_Event_View::event_tickets_available($EVT_ID);
388
+		if (is_array($tickets) && ! empty($tickets)) {
389 389
 			// if formatting then $html will be a string, else it will be an array of ticket objects
390
-			$html = $format ? '<ul id="ee-event-tickets-ul-' . $EVT_ID . '" class="ee-event-tickets-ul">' : array();
391
-			foreach ( $tickets as $ticket ) {
392
-				if ( $ticket instanceof EE_Ticket ) {
393
-					if ( $format ) {
394
-						$html .= '<li id="ee-event-tickets-li-' . $ticket->ID() . '" class="ee-event-tickets-li">';
395
-						$html .= $ticket->name() . ' ' . EEH_Template::format_currency( $ticket->get_ticket_total_with_taxes() );
390
+			$html = $format ? '<ul id="ee-event-tickets-ul-'.$EVT_ID.'" class="ee-event-tickets-ul">' : array();
391
+			foreach ($tickets as $ticket) {
392
+				if ($ticket instanceof EE_Ticket) {
393
+					if ($format) {
394
+						$html .= '<li id="ee-event-tickets-li-'.$ticket->ID().'" class="ee-event-tickets-li">';
395
+						$html .= $ticket->name().' '.EEH_Template::format_currency($ticket->get_ticket_total_with_taxes());
396 396
 						$html .= '</li>';
397 397
 					} else {
398 398
 						$html[] = $ticket;
399 399
 					}
400 400
 				}
401 401
 			}
402
-			if ( $format ) {
402
+			if ($format) {
403 403
 				$html .= '</ul>';
404 404
 			}
405
-			if ( $echo && ! $format ) {
405
+			if ($echo && ! $format) {
406 406
 				echo $html;
407 407
 				return '';
408 408
 			}
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 	}
413 413
 }
414 414
 
415
-if ( ! function_exists( 'espresso_event_date_obj' )) {
415
+if ( ! function_exists('espresso_event_date_obj')) {
416 416
 	/**
417 417
 	 * espresso_event_date_obj
418 418
 	 * returns the primary date object for an event
@@ -420,13 +420,13 @@  discard block
 block discarded – undo
420 420
 	 * @param bool $EVT_ID
421 421
 	 * @return object
422 422
 	 */
423
-	function espresso_event_date_obj( $EVT_ID = FALSE ) {
424
-		return EEH_Event_View::get_primary_date_obj( $EVT_ID );
423
+	function espresso_event_date_obj($EVT_ID = FALSE) {
424
+		return EEH_Event_View::get_primary_date_obj($EVT_ID);
425 425
 	}
426 426
 }
427 427
 
428 428
 
429
-if ( ! function_exists( 'espresso_event_date' )) {
429
+if ( ! function_exists('espresso_event_date')) {
430 430
 	/**
431 431
 	 * espresso_event_date
432 432
 	 * returns the primary date for an event
@@ -437,22 +437,22 @@  discard block
 block discarded – undo
437 437
 	 * @param bool $echo
438 438
 	 * @return string
439 439
 	 */
440
-	function espresso_event_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) {
441
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
442
-		$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
443
-		$date_format = apply_filters( 'FHEE__espresso_event_date__date_format', $date_format );
444
-		$time_format = apply_filters( 'FHEE__espresso_event_date__time_format', $time_format );
445
-		if($echo){
446
-			echo EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID );
440
+	function espresso_event_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) {
441
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
442
+		$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
443
+		$date_format = apply_filters('FHEE__espresso_event_date__date_format', $date_format);
444
+		$time_format = apply_filters('FHEE__espresso_event_date__time_format', $time_format);
445
+		if ($echo) {
446
+			echo EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID);
447 447
 			return '';
448 448
 		}
449
-		return EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID );
449
+		return EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID);
450 450
 
451 451
 	}
452 452
 }
453 453
 
454 454
 
455
-if ( ! function_exists( 'espresso_list_of_event_dates' )) {
455
+if ( ! function_exists('espresso_list_of_event_dates')) {
456 456
 	/**
457 457
 	 * espresso_list_of_event_dates
458 458
 	 * returns a unordered list of dates for an event
@@ -467,40 +467,40 @@  discard block
 block discarded – undo
467 467
 	 * @param null   $limit
468 468
 	 * @return string
469 469
 	 */
470
-	function espresso_list_of_event_dates( $EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL ) {
471
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
472
-		$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
473
-		$date_format = apply_filters( 'FHEE__espresso_list_of_event_dates__date_format', $date_format );
474
-		$time_format = apply_filters( 'FHEE__espresso_list_of_event_dates__time_format', $time_format );
475
-		$datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, $show_expired, FALSE, $limit );
476
-		if ( ! $format ) {
477
-			return apply_filters( 'FHEE__espresso_list_of_event_dates__datetimes', $datetimes );
470
+	function espresso_list_of_event_dates($EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL) {
471
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
472
+		$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
473
+		$date_format = apply_filters('FHEE__espresso_list_of_event_dates__date_format', $date_format);
474
+		$time_format = apply_filters('FHEE__espresso_list_of_event_dates__time_format', $time_format);
475
+		$datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, $show_expired, FALSE, $limit);
476
+		if ( ! $format) {
477
+			return apply_filters('FHEE__espresso_list_of_event_dates__datetimes', $datetimes);
478 478
 		}
479 479
 		//d( $datetimes );
480
-		if ( is_array( $datetimes ) && ! empty( $datetimes )) {
480
+		if (is_array($datetimes) && ! empty($datetimes)) {
481 481
 			global $post;
482
-			$html = $format ? '<ul id="ee-event-datetimes-ul-' . $post->ID . '" class="ee-event-datetimes-ul ee-clearfix">' : '';
483
-			foreach ( $datetimes as $datetime ) {
484
-				if ( $datetime instanceof EE_Datetime ) {
485
-					$html .= '<li id="ee-event-datetimes-li-' . $datetime->ID();
486
-					$html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-' . $datetime->get_active_status() . '">';
482
+			$html = $format ? '<ul id="ee-event-datetimes-ul-'.$post->ID.'" class="ee-event-datetimes-ul ee-clearfix">' : '';
483
+			foreach ($datetimes as $datetime) {
484
+				if ($datetime instanceof EE_Datetime) {
485
+					$html .= '<li id="ee-event-datetimes-li-'.$datetime->ID();
486
+					$html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-'.$datetime->get_active_status().'">';
487 487
 					$datetime_name = $datetime->name();
488
-					$html .= ! empty( $datetime_name ) ? '<strong>' . $datetime_name . '</strong>' : '';
489
-					$html .= ! empty( $datetime_name )  && $add_breaks ? '<br />' : '';
490
-					$html .= '<span class="dashicons dashicons-calendar"></span>' . $datetime->date_range( $date_format ) . '<br/>';
491
-					$html .= '<span class="dashicons dashicons-clock"></span>' . $datetime->time_range( $time_format );
488
+					$html .= ! empty($datetime_name) ? '<strong>'.$datetime_name.'</strong>' : '';
489
+					$html .= ! empty($datetime_name) && $add_breaks ? '<br />' : '';
490
+					$html .= '<span class="dashicons dashicons-calendar"></span>'.$datetime->date_range($date_format).'<br/>';
491
+					$html .= '<span class="dashicons dashicons-clock"></span>'.$datetime->time_range($time_format);
492 492
 					$datetime_description = $datetime->description();
493
-					$html .= ! empty( $datetime_description )  && $add_breaks ? '<br />' : '';
494
-					$html .= ! empty( $datetime_description ) ? ' - ' . $datetime_description : '';
495
-					$html = apply_filters( 'FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime );
493
+					$html .= ! empty($datetime_description) && $add_breaks ? '<br />' : '';
494
+					$html .= ! empty($datetime_description) ? ' - '.$datetime_description : '';
495
+					$html = apply_filters('FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime);
496 496
 					$html .= '</li>';
497 497
 				}
498 498
 			}
499 499
 			$html .= $format ? '</ul>' : '';
500 500
 		} else {
501
-			$html = $format ?  '<p><span class="dashicons dashicons-marker pink-text"></span>' . __( 'There are no upcoming dates for this event.', 'event_espresso' ) . '</p><br/>' : '';
501
+			$html = $format ? '<p><span class="dashicons dashicons-marker pink-text"></span>'.__('There are no upcoming dates for this event.', 'event_espresso').'</p><br/>' : '';
502 502
 		}
503
-		if ( $echo ) {
503
+		if ($echo) {
504 504
 			echo $html;
505 505
 			return '';
506 506
 		}
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 }
510 510
 
511 511
 
512
-if ( ! function_exists( 'espresso_event_end_date' )) {
512
+if ( ! function_exists('espresso_event_end_date')) {
513 513
 	/**
514 514
 	 * espresso_event_end_date
515 515
 	 * returns the last date for an event
@@ -520,20 +520,20 @@  discard block
 block discarded – undo
520 520
 	 * @param bool   $echo
521 521
 	 * @return string
522 522
 	 */
523
-	function espresso_event_end_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) {
524
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
525
-		$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
526
-		$date_format = apply_filters( 'FHEE__espresso_event_end_date__date_format', $date_format );
527
-		$time_format = apply_filters( 'FHEE__espresso_event_end_date__time_format', $time_format );
528
-		if($echo){
529
-			echo EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID );
523
+	function espresso_event_end_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) {
524
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
525
+		$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
526
+		$date_format = apply_filters('FHEE__espresso_event_end_date__date_format', $date_format);
527
+		$time_format = apply_filters('FHEE__espresso_event_end_date__time_format', $time_format);
528
+		if ($echo) {
529
+			echo EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID);
530 530
 			return '';
531 531
 		}
532
-		return EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID );
532
+		return EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID);
533 533
 	}
534 534
 }
535 535
 
536
-if ( ! function_exists( 'espresso_event_date_range' )) {
536
+if ( ! function_exists('espresso_event_date_range')) {
537 537
 	/**
538 538
 	 * espresso_event_date_range
539 539
 	 * returns the first and last chronologically ordered dates for an event (if different)
@@ -546,31 +546,31 @@  discard block
 block discarded – undo
546 546
 	 * @param bool   $echo
547 547
 	 * @return string
548 548
 	 */
549
-	function espresso_event_date_range( $date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE ) {
549
+	function espresso_event_date_range($date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE) {
550 550
 		// set and filter date and time formats when a range is returned
551
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
552
-		$date_format = apply_filters( 'FHEE__espresso_event_date_range__date_format', $date_format );
551
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
552
+		$date_format = apply_filters('FHEE__espresso_event_date_range__date_format', $date_format);
553 553
 		// get the start and end date with NO time portion
554
-		$the_event_date = EEH_Event_View::the_earliest_event_date( $date_format, '', $EVT_ID );
555
-		$the_event_end_date = EEH_Event_View::the_latest_event_date( $date_format, '', $EVT_ID );
554
+		$the_event_date = EEH_Event_View::the_earliest_event_date($date_format, '', $EVT_ID);
555
+		$the_event_end_date = EEH_Event_View::the_latest_event_date($date_format, '', $EVT_ID);
556 556
 		// now we can determine if date range spans more than one day
557
-		if ( $the_event_date != $the_event_end_date ) {
558
-			$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
559
-			$time_format = apply_filters( 'FHEE__espresso_event_date_range__time_format', $time_format );
557
+		if ($the_event_date != $the_event_end_date) {
558
+			$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
559
+			$time_format = apply_filters('FHEE__espresso_event_date_range__time_format', $time_format);
560 560
 			$html = sprintf(
561
-				__( '%1$s - %2$s', 'event_espresso' ),
562
-				EEH_Event_View::the_earliest_event_date( $date_format, $time_format, $EVT_ID ),
563
-				EEH_Event_View::the_latest_event_date( $date_format, $time_format, $EVT_ID )
561
+				__('%1$s - %2$s', 'event_espresso'),
562
+				EEH_Event_View::the_earliest_event_date($date_format, $time_format, $EVT_ID),
563
+				EEH_Event_View::the_latest_event_date($date_format, $time_format, $EVT_ID)
564 564
 			);
565 565
 		} else {
566 566
 			// set and filter date and time formats when only a single datetime is returned
567
-			$single_date_format = ! empty( $single_date_format ) ? $single_date_format : get_option( 'date_format' );
568
-			$single_time_format = ! empty( $single_time_format ) ? $single_time_format : get_option( 'time_format' );
569
-			$single_date_format = apply_filters( 'FHEE__espresso_event_date_range__single_date_format', $single_date_format );
570
-			$single_time_format = apply_filters( 'FHEE__espresso_event_date_range__single_time_format', $single_time_format );
571
-			$html = EEH_Event_View::the_earliest_event_date( $single_date_format, $single_time_format, $EVT_ID );
567
+			$single_date_format = ! empty($single_date_format) ? $single_date_format : get_option('date_format');
568
+			$single_time_format = ! empty($single_time_format) ? $single_time_format : get_option('time_format');
569
+			$single_date_format = apply_filters('FHEE__espresso_event_date_range__single_date_format', $single_date_format);
570
+			$single_time_format = apply_filters('FHEE__espresso_event_date_range__single_time_format', $single_time_format);
571
+			$html = EEH_Event_View::the_earliest_event_date($single_date_format, $single_time_format, $EVT_ID);
572 572
 		}
573
-		if ( $echo ) {
573
+		if ($echo) {
574 574
 			echo $html;
575 575
 			return '';
576 576
 		}
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
 }
580 580
 
581 581
 
582
-if ( ! function_exists( 'espresso_event_date_as_calendar_page' )) {
582
+if ( ! function_exists('espresso_event_date_as_calendar_page')) {
583 583
 	/**
584 584
 	 * espresso_event_date_as_calendar_page
585 585
 	 * returns the primary date for an event, stylized to appear as the page of a calendar
@@ -587,15 +587,15 @@  discard block
 block discarded – undo
587 587
 	 * @param bool $EVT_ID
588 588
 	 * @return string
589 589
 	 */
590
-	function espresso_event_date_as_calendar_page( $EVT_ID = FALSE ) {
591
-		EEH_Event_View::event_date_as_calendar_page( $EVT_ID );
590
+	function espresso_event_date_as_calendar_page($EVT_ID = FALSE) {
591
+		EEH_Event_View::event_date_as_calendar_page($EVT_ID);
592 592
 	}
593 593
 }
594 594
 
595 595
 
596 596
 
597 597
 
598
-if ( ! function_exists( 'espresso_event_link_url' )) {
598
+if ( ! function_exists('espresso_event_link_url')) {
599 599
 	/**
600 600
 	 * espresso_event_link_url
601 601
 	 *
@@ -603,18 +603,18 @@  discard block
 block discarded – undo
603 603
 	 * @param bool $echo
604 604
 	 * @return string
605 605
 	 */
606
-	function espresso_event_link_url( $EVT_ID = 0, $echo = TRUE ) {
607
-		if ( $echo ) {
608
-			echo EEH_Event_View::event_link_url( $EVT_ID );
606
+	function espresso_event_link_url($EVT_ID = 0, $echo = TRUE) {
607
+		if ($echo) {
608
+			echo EEH_Event_View::event_link_url($EVT_ID);
609 609
 			return '';
610 610
 		}
611
-		return EEH_Event_View::event_link_url( $EVT_ID );
611
+		return EEH_Event_View::event_link_url($EVT_ID);
612 612
 	}
613 613
 }
614 614
 
615 615
 
616 616
 
617
-if ( ! function_exists( 'espresso_event_has_content_or_excerpt' )) {
617
+if ( ! function_exists('espresso_event_has_content_or_excerpt')) {
618 618
 	/**
619 619
 	 *    espresso_event_has_content_or_excerpt
620 620
 	 *
@@ -622,15 +622,15 @@  discard block
 block discarded – undo
622 622
 	 * @param bool $EVT_ID
623 623
 	 * @return    boolean
624 624
 	 */
625
-	function espresso_event_has_content_or_excerpt( $EVT_ID = FALSE ) {
626
-		return EEH_Event_View::event_has_content_or_excerpt( $EVT_ID );
625
+	function espresso_event_has_content_or_excerpt($EVT_ID = FALSE) {
626
+		return EEH_Event_View::event_has_content_or_excerpt($EVT_ID);
627 627
 	}
628 628
 }
629 629
 
630 630
 
631 631
 
632 632
 
633
-if ( ! function_exists( 'espresso_event_content_or_excerpt' )) {
633
+if ( ! function_exists('espresso_event_content_or_excerpt')) {
634 634
 	/**
635 635
 	 * espresso_event_content_or_excerpt
636 636
 	 *
@@ -639,18 +639,18 @@  discard block
 block discarded – undo
639 639
 	 * @param bool $echo
640 640
 	 * @return string
641 641
 	 */
642
-	function espresso_event_content_or_excerpt( $num_words = 55, $more = NULL, $echo = TRUE ) {
643
-		if ( $echo ) {
644
-			echo EEH_Event_View::event_content_or_excerpt( $num_words, $more );
642
+	function espresso_event_content_or_excerpt($num_words = 55, $more = NULL, $echo = TRUE) {
643
+		if ($echo) {
644
+			echo EEH_Event_View::event_content_or_excerpt($num_words, $more);
645 645
 			return '';
646 646
 		}
647
-		return EEH_Event_View::event_content_or_excerpt( $num_words, $more );
647
+		return EEH_Event_View::event_content_or_excerpt($num_words, $more);
648 648
 	}
649 649
 }
650 650
 
651 651
 
652 652
 
653
-if ( ! function_exists( 'espresso_event_phone' )) {
653
+if ( ! function_exists('espresso_event_phone')) {
654 654
 	/**
655 655
 	 * espresso_event_phone
656 656
 	 *
@@ -658,18 +658,18 @@  discard block
 block discarded – undo
658 658
 	 * @param bool $echo
659 659
 	 * @return string
660 660
 	 */
661
-	function espresso_event_phone( $EVT_ID = 0, $echo = TRUE ) {
662
-		if ( $echo ) {
663
-			echo EEH_Event_View::event_phone( $EVT_ID );
661
+	function espresso_event_phone($EVT_ID = 0, $echo = TRUE) {
662
+		if ($echo) {
663
+			echo EEH_Event_View::event_phone($EVT_ID);
664 664
 			return '';
665 665
 		}
666
-		return EEH_Event_View::event_phone( $EVT_ID );
666
+		return EEH_Event_View::event_phone($EVT_ID);
667 667
 	}
668 668
 }
669 669
 
670 670
 
671 671
 
672
-if ( ! function_exists( 'espresso_edit_event_link' )) {
672
+if ( ! function_exists('espresso_edit_event_link')) {
673 673
 	/**
674 674
 	 * espresso_edit_event_link
675 675
 	 * returns a link to edit an event
@@ -678,39 +678,39 @@  discard block
 block discarded – undo
678 678
 	 * @param bool $echo
679 679
 	 * @return string
680 680
 	 */
681
-	function espresso_edit_event_link( $EVT_ID = 0, $echo = TRUE ) {
682
-		if ( $echo ) {
683
-			echo EEH_Event_View::edit_event_link( $EVT_ID );
681
+	function espresso_edit_event_link($EVT_ID = 0, $echo = TRUE) {
682
+		if ($echo) {
683
+			echo EEH_Event_View::edit_event_link($EVT_ID);
684 684
 			return '';
685 685
 		}
686
-		return EEH_Event_View::edit_event_link( $EVT_ID );
686
+		return EEH_Event_View::edit_event_link($EVT_ID);
687 687
 	}
688 688
 }
689 689
 
690 690
 
691
-if ( ! function_exists( 'espresso_organization_name' )) {
691
+if ( ! function_exists('espresso_organization_name')) {
692 692
 	/**
693 693
 	 * espresso_organization_name
694 694
 	 * @param bool $echo
695 695
 	 * @return string
696 696
 	 */
697 697
 	function espresso_organization_name($echo = TRUE) {
698
-		if($echo){
699
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'name' );
698
+		if ($echo) {
699
+			echo EE_Registry::instance()->CFG->organization->get_pretty('name');
700 700
 			return '';
701 701
 		}
702
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'name' );
702
+		return EE_Registry::instance()->CFG->organization->get_pretty('name');
703 703
 	}
704 704
 }
705 705
 
706
-if ( ! function_exists( 'espresso_organization_address' )) {
706
+if ( ! function_exists('espresso_organization_address')) {
707 707
 	/**
708 708
 	 * espresso_organization_address
709 709
 	 * @param string $type
710 710
 	 * @return string
711 711
 	 */
712
-	function espresso_organization_address( $type = 'inline' ) {
713
-		if ( EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config ) {
712
+	function espresso_organization_address($type = 'inline') {
713
+		if (EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config) {
714 714
 			$address = new EventEspresso\core\domain\entities\GenericAddress(
715 715
 				EE_Registry::instance()->CFG->organization->address_1,
716 716
 				EE_Registry::instance()->CFG->organization->address_2,
@@ -719,129 +719,129 @@  discard block
 block discarded – undo
719 719
 				EE_Registry::instance()->CFG->organization->zip,
720 720
 				EE_Registry::instance()->CFG->organization->CNT_ISO
721 721
 			);
722
-			return EEH_Address::format( $address, $type );
722
+			return EEH_Address::format($address, $type);
723 723
 		}
724 724
 		return '';
725 725
 	}
726 726
 }
727 727
 
728
-if ( ! function_exists( 'espresso_organization_email' )) {
728
+if ( ! function_exists('espresso_organization_email')) {
729 729
 	/**
730 730
 	 * espresso_organization_email
731 731
 	 * @param bool $echo
732 732
 	 * @return string
733 733
 	 */
734
-	function espresso_organization_email( $echo = TRUE ) {
735
-		if($echo){
736
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'email' );
734
+	function espresso_organization_email($echo = TRUE) {
735
+		if ($echo) {
736
+			echo EE_Registry::instance()->CFG->organization->get_pretty('email');
737 737
 			return '';
738 738
 		}
739
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'email' );
739
+		return EE_Registry::instance()->CFG->organization->get_pretty('email');
740 740
 	}
741 741
 }
742 742
 
743
-if ( ! function_exists( 'espresso_organization_logo_url' )) {
743
+if ( ! function_exists('espresso_organization_logo_url')) {
744 744
 	/**
745 745
 	 * espresso_organization_logo_url
746 746
 	 * @param bool $echo
747 747
 	 * @return string
748 748
 	 */
749
-	function espresso_organization_logo_url( $echo = TRUE ) {
750
-		if($echo){
751
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' );
749
+	function espresso_organization_logo_url($echo = TRUE) {
750
+		if ($echo) {
751
+			echo EE_Registry::instance()->CFG->organization->get_pretty('logo_url');
752 752
 			return '';
753 753
 		}
754
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' );
754
+		return EE_Registry::instance()->CFG->organization->get_pretty('logo_url');
755 755
 	}
756 756
 }
757 757
 
758
-if ( ! function_exists( 'espresso_organization_facebook' )) {
758
+if ( ! function_exists('espresso_organization_facebook')) {
759 759
 	/**
760 760
 	 * espresso_organization_facebook
761 761
 	 * @param bool $echo
762 762
 	 * @return string
763 763
 	 */
764
-	function espresso_organization_facebook( $echo = TRUE ) {
765
-		if($echo){
766
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' );
764
+	function espresso_organization_facebook($echo = TRUE) {
765
+		if ($echo) {
766
+			echo EE_Registry::instance()->CFG->organization->get_pretty('facebook');
767 767
 			return '';
768 768
 		}
769
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' );
769
+		return EE_Registry::instance()->CFG->organization->get_pretty('facebook');
770 770
 	}
771 771
 }
772 772
 
773
-if ( ! function_exists( 'espresso_organization_twitter' )) {
773
+if ( ! function_exists('espresso_organization_twitter')) {
774 774
 	/**
775 775
 	 * espresso_organization_twitter
776 776
 	 * @param bool $echo
777 777
 	 * @return string
778 778
 	 */
779
-	function espresso_organization_twitter( $echo = TRUE ) {
780
-		if($echo){
781
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' );
779
+	function espresso_organization_twitter($echo = TRUE) {
780
+		if ($echo) {
781
+			echo EE_Registry::instance()->CFG->organization->get_pretty('twitter');
782 782
 			return '';
783 783
 		}
784
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' );
784
+		return EE_Registry::instance()->CFG->organization->get_pretty('twitter');
785 785
 	}
786 786
 }
787 787
 
788
-if ( ! function_exists( 'espresso_organization_linkedin' )) {
788
+if ( ! function_exists('espresso_organization_linkedin')) {
789 789
 	/**
790 790
 	 * espresso_organization_linkedin
791 791
 	 * @param bool $echo
792 792
 	 * @return string
793 793
 	 */
794
-	function espresso_organization_linkedin( $echo = TRUE ) {
795
-		if($echo){
796
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' );
794
+	function espresso_organization_linkedin($echo = TRUE) {
795
+		if ($echo) {
796
+			echo EE_Registry::instance()->CFG->organization->get_pretty('linkedin');
797 797
 			return '';
798 798
 		}
799
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' );
799
+		return EE_Registry::instance()->CFG->organization->get_pretty('linkedin');
800 800
 	}
801 801
 }
802 802
 
803
-if ( ! function_exists( 'espresso_organization_pinterest' )) {
803
+if ( ! function_exists('espresso_organization_pinterest')) {
804 804
 	/**
805 805
 	 * espresso_organization_pinterest
806 806
 	 * @param bool $echo
807 807
 	 * @return string
808 808
 	 */
809
-	function espresso_organization_pinterest( $echo = TRUE ) {
810
-		if($echo){
811
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' );
809
+	function espresso_organization_pinterest($echo = TRUE) {
810
+		if ($echo) {
811
+			echo EE_Registry::instance()->CFG->organization->get_pretty('pinterest');
812 812
 			return '';
813 813
 		}
814
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' );
814
+		return EE_Registry::instance()->CFG->organization->get_pretty('pinterest');
815 815
 	}
816 816
 }
817 817
 
818
-if ( ! function_exists( 'espresso_organization_google' )) {
818
+if ( ! function_exists('espresso_organization_google')) {
819 819
 	/**
820 820
 	 * espresso_organization_google
821 821
 	 * @param bool $echo
822 822
 	 * @return string
823 823
 	 */
824
-	function espresso_organization_google( $echo = TRUE ) {
825
-		if($echo){
826
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'google' );
824
+	function espresso_organization_google($echo = TRUE) {
825
+		if ($echo) {
826
+			echo EE_Registry::instance()->CFG->organization->get_pretty('google');
827 827
 			return '';
828 828
 		}
829
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'google' );
829
+		return EE_Registry::instance()->CFG->organization->get_pretty('google');
830 830
 	}
831 831
 }
832 832
 
833
-if ( ! function_exists( 'espresso_organization_instagram' )) {
833
+if ( ! function_exists('espresso_organization_instagram')) {
834 834
 	/**
835 835
 	 * espresso_organization_instagram
836 836
 	 * @param bool $echo
837 837
 	 * @return string
838 838
 	 */
839
-	function espresso_organization_instagram( $echo = TRUE ) {
840
-		if($echo){
841
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' );
839
+	function espresso_organization_instagram($echo = TRUE) {
840
+		if ($echo) {
841
+			echo EE_Registry::instance()->CFG->organization->get_pretty('instagram');
842 842
 			return '';
843 843
 		}
844
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' );
844
+		return EE_Registry::instance()->CFG->organization->get_pretty('instagram');
845 845
 	}
846 846
 }
847 847
 
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
 
852 852
 
853 853
 
854
-if ( ! function_exists( 'espresso_event_venues' )) {
854
+if ( ! function_exists('espresso_event_venues')) {
855 855
 	/**
856 856
 	 * espresso_event_venues
857 857
 	 *
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
 
866 866
 
867 867
 
868
-if ( ! function_exists( 'espresso_venue_id' )) {
868
+if ( ! function_exists('espresso_venue_id')) {
869 869
 	/**
870 870
 	 *    espresso_venue_name
871 871
 	 *
@@ -873,15 +873,15 @@  discard block
 block discarded – undo
873 873
 	 * @param     int $EVT_ID
874 874
 	 * @return    string
875 875
 	 */
876
-	function espresso_venue_id( $EVT_ID = 0 ) {
877
-		$venue = EEH_Venue_View::get_venue( $EVT_ID );
876
+	function espresso_venue_id($EVT_ID = 0) {
877
+		$venue = EEH_Venue_View::get_venue($EVT_ID);
878 878
 		return $venue instanceof EE_Venue ? $venue->ID() : 0;
879 879
 	}
880 880
 }
881 881
 
882 882
 
883 883
 
884
-if ( ! function_exists( 'espresso_is_venue_private' ) ) {
884
+if ( ! function_exists('espresso_is_venue_private')) {
885 885
 	/**
886 886
 	 * Return whether a venue is private or not.
887 887
 	 * @see EEH_Venue_View::get_venue() for more info on expected return results.
@@ -890,45 +890,45 @@  discard block
 block discarded – undo
890 890
 	 *
891 891
 	 * @return bool | null
892 892
 	 */
893
-	function espresso_is_venue_private( $VNU_ID = 0 ) {
894
-		return EEH_Venue_View::is_venue_private( $VNU_ID );
893
+	function espresso_is_venue_private($VNU_ID = 0) {
894
+		return EEH_Venue_View::is_venue_private($VNU_ID);
895 895
 	}
896 896
 }
897 897
 
898 898
 
899 899
 
900
-if ( ! function_exists( 'espresso_venue_is_password_protected' ) ) {
900
+if ( ! function_exists('espresso_venue_is_password_protected')) {
901 901
 	/**
902 902
 	 * returns true or false if a venue is password protected or not
903 903
 	 *
904 904
 	 * @param int     $VNU_ID optional, the venue id to check.
905 905
 	 * @return string
906 906
 	 */
907
-	function espresso_venue_is_password_protected( $VNU_ID = 0 ) {
908
-		EE_Registry::instance()->load_helper( 'Venue_View' );
909
-		return EEH_Venue_View::is_venue_password_protected( $VNU_ID );
907
+	function espresso_venue_is_password_protected($VNU_ID = 0) {
908
+		EE_Registry::instance()->load_helper('Venue_View');
909
+		return EEH_Venue_View::is_venue_password_protected($VNU_ID);
910 910
 	}
911 911
 }
912 912
 
913 913
 
914 914
 
915
-if ( ! function_exists( 'espresso_password_protected_venue_form' ) ) {
915
+if ( ! function_exists('espresso_password_protected_venue_form')) {
916 916
 	/**
917 917
 	 * Returns a password form if venue is password protected.
918 918
 	 *
919 919
 	 * @param int     $VNU_ID optional, the venue id to check.
920 920
 	 * @return string
921 921
 	 */
922
-	function espresso_password_protected_venue_form( $VNU_ID = 0 ) {
923
-		EE_Registry::instance()->load_helper( 'Venue_View' );
924
-		return EEH_Venue_View::password_protected_venue_form( $VNU_ID );
922
+	function espresso_password_protected_venue_form($VNU_ID = 0) {
923
+		EE_Registry::instance()->load_helper('Venue_View');
924
+		return EEH_Venue_View::password_protected_venue_form($VNU_ID);
925 925
 	}
926 926
 }
927 927
 
928 928
 
929 929
 
930 930
 
931
-if ( ! function_exists( 'espresso_venue_name' )) {
931
+if ( ! function_exists('espresso_venue_name')) {
932 932
 	/**
933 933
 	 *    espresso_venue_name
934 934
 	 *
@@ -938,19 +938,19 @@  discard block
 block discarded – undo
938 938
 	 * @param bool   $echo
939 939
 	 * @return    string
940 940
 	 */
941
-	function espresso_venue_name( $VNU_ID = 0, $link_to = 'details', $echo = TRUE ) {
942
-		if($echo){
943
-			echo EEH_Venue_View::venue_name( $link_to, $VNU_ID );
941
+	function espresso_venue_name($VNU_ID = 0, $link_to = 'details', $echo = TRUE) {
942
+		if ($echo) {
943
+			echo EEH_Venue_View::venue_name($link_to, $VNU_ID);
944 944
 			return '';
945 945
 		}
946
-		return EEH_Venue_View::venue_name( $link_to, $VNU_ID );
946
+		return EEH_Venue_View::venue_name($link_to, $VNU_ID);
947 947
 	}
948 948
 }
949 949
 
950 950
 
951 951
 
952 952
 
953
-if ( ! function_exists( 'espresso_venue_link' )) {
953
+if ( ! function_exists('espresso_venue_link')) {
954 954
 	/**
955 955
 	 * 	espresso_venue_link
956 956
 	 *
@@ -959,14 +959,14 @@  discard block
 block discarded – undo
959 959
 	 *  @param 	string 	$text
960 960
 	 *  @return 	string
961 961
 	 */
962
-	function espresso_venue_link( $VNU_ID = 0, $text = '' ) {
963
-		return EEH_Venue_View::venue_details_link( $VNU_ID, $text );
962
+	function espresso_venue_link($VNU_ID = 0, $text = '') {
963
+		return EEH_Venue_View::venue_details_link($VNU_ID, $text);
964 964
 	}
965 965
 }
966 966
 
967 967
 
968 968
 
969
-if ( ! function_exists( 'espresso_venue_description' )) {
969
+if ( ! function_exists('espresso_venue_description')) {
970 970
 	/**
971 971
 	 *    espresso_venue_description
972 972
 	 *
@@ -975,17 +975,17 @@  discard block
 block discarded – undo
975 975
 	 * @param bool $echo
976 976
 	 * @return    string
977 977
 	 */
978
-	function espresso_venue_description( $VNU_ID = FALSE, $echo = TRUE ) {
979
-		if($echo){
980
-			echo EEH_Venue_View::venue_description( $VNU_ID );
978
+	function espresso_venue_description($VNU_ID = FALSE, $echo = TRUE) {
979
+		if ($echo) {
980
+			echo EEH_Venue_View::venue_description($VNU_ID);
981 981
 			return '';
982 982
 		}
983
-		return EEH_Venue_View::venue_description( $VNU_ID );
983
+		return EEH_Venue_View::venue_description($VNU_ID);
984 984
 	}
985 985
 }
986 986
 
987 987
 
988
-if ( ! function_exists( 'espresso_venue_excerpt' )) {
988
+if ( ! function_exists('espresso_venue_excerpt')) {
989 989
 	/**
990 990
 	 *    espresso_venue_excerpt
991 991
 	 *
@@ -994,18 +994,18 @@  discard block
 block discarded – undo
994 994
 	 * @param bool $echo
995 995
 	 * @return    string
996 996
 	 */
997
-	function espresso_venue_excerpt( $VNU_ID = 0,  $echo = TRUE ) {
998
-		if ( $echo ) {
999
-			echo EEH_Venue_View::venue_excerpt( $VNU_ID );
997
+	function espresso_venue_excerpt($VNU_ID = 0, $echo = TRUE) {
998
+		if ($echo) {
999
+			echo EEH_Venue_View::venue_excerpt($VNU_ID);
1000 1000
 			return '';
1001 1001
 		}
1002
-		return EEH_Venue_View::venue_excerpt( $VNU_ID );
1002
+		return EEH_Venue_View::venue_excerpt($VNU_ID);
1003 1003
 	}
1004 1004
 }
1005 1005
 
1006 1006
 
1007 1007
 
1008
-if ( ! function_exists( 'espresso_venue_categories' )) {
1008
+if ( ! function_exists('espresso_venue_categories')) {
1009 1009
 	/**
1010 1010
 	 * espresso_venue_categories
1011 1011
 	 * returns the terms associated with a venue
@@ -1015,17 +1015,17 @@  discard block
 block discarded – undo
1015 1015
 	 * @param bool $echo
1016 1016
 	 * @return string
1017 1017
 	 */
1018
-	function espresso_venue_categories( $VNU_ID = 0, $hide_uncategorized = TRUE,  $echo = TRUE ) {
1019
-		if ( $echo ) {
1020
-			echo EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized );
1018
+	function espresso_venue_categories($VNU_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) {
1019
+		if ($echo) {
1020
+			echo EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized);
1021 1021
 			return '';
1022 1022
 		}
1023
-		return EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized );
1023
+		return EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized);
1024 1024
 	}
1025 1025
 }
1026 1026
 
1027 1027
 
1028
-if ( ! function_exists( 'espresso_venue_address' )) {
1028
+if ( ! function_exists('espresso_venue_address')) {
1029 1029
 	/**
1030 1030
 	 * espresso_venue_address
1031 1031
 	 * returns a formatted block of html  for displaying a venue's address
@@ -1035,17 +1035,17 @@  discard block
 block discarded – undo
1035 1035
 	 * @param bool   $echo
1036 1036
 	 * @return string
1037 1037
 	 */
1038
-	function espresso_venue_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) {
1039
-		if ( $echo ) {
1040
-			echo EEH_Venue_View::venue_address( $type, $VNU_ID );
1038
+	function espresso_venue_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) {
1039
+		if ($echo) {
1040
+			echo EEH_Venue_View::venue_address($type, $VNU_ID);
1041 1041
 			return '';
1042 1042
 		}
1043
-		return EEH_Venue_View::venue_address( $type, $VNU_ID );
1043
+		return EEH_Venue_View::venue_address($type, $VNU_ID);
1044 1044
 	}
1045 1045
 }
1046 1046
 
1047 1047
 
1048
-if ( ! function_exists( 'espresso_venue_raw_address' )) {
1048
+if ( ! function_exists('espresso_venue_raw_address')) {
1049 1049
 	/**
1050 1050
 	 * espresso_venue_address
1051 1051
 	 * returns an UN-formatted string containing a venue's address
@@ -1055,17 +1055,17 @@  discard block
 block discarded – undo
1055 1055
 	 * @param bool     $echo
1056 1056
 	 * @return string
1057 1057
 	 */
1058
-	function espresso_venue_raw_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) {
1059
-		if ( $echo ) {
1060
-			echo EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE );
1058
+	function espresso_venue_raw_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) {
1059
+		if ($echo) {
1060
+			echo EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE);
1061 1061
 			return '';
1062 1062
 		}
1063
-		return EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE );
1063
+		return EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE);
1064 1064
 	}
1065 1065
 }
1066 1066
 
1067 1067
 
1068
-if ( ! function_exists( 'espresso_venue_has_address' )) {
1068
+if ( ! function_exists('espresso_venue_has_address')) {
1069 1069
 	/**
1070 1070
 	 * espresso_venue_has_address
1071 1071
 	 * returns TRUE or FALSE if a Venue has address information
@@ -1073,13 +1073,13 @@  discard block
 block discarded – undo
1073 1073
 	 * @param int $VNU_ID
1074 1074
 	 * @return bool
1075 1075
 	 */
1076
-	function espresso_venue_has_address( $VNU_ID = 0 ) {
1077
-		return EEH_Venue_View::venue_has_address( $VNU_ID );
1076
+	function espresso_venue_has_address($VNU_ID = 0) {
1077
+		return EEH_Venue_View::venue_has_address($VNU_ID);
1078 1078
 	}
1079 1079
 }
1080 1080
 
1081 1081
 
1082
-if ( ! function_exists( 'espresso_venue_gmap' )) {
1082
+if ( ! function_exists('espresso_venue_gmap')) {
1083 1083
 	/**
1084 1084
 	 * espresso_venue_gmap
1085 1085
 	 * returns a google map for the venue address
@@ -1090,17 +1090,17 @@  discard block
 block discarded – undo
1090 1090
 	 * @param bool     $echo
1091 1091
 	 * @return string
1092 1092
 	 */
1093
-	function espresso_venue_gmap( $VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE  ) {
1094
-		if ( $echo ) {
1095
-			echo EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap );
1093
+	function espresso_venue_gmap($VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE) {
1094
+		if ($echo) {
1095
+			echo EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap);
1096 1096
 			return '';
1097 1097
 		}
1098
-		return EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap );
1098
+		return EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap);
1099 1099
 	}
1100 1100
 }
1101 1101
 
1102 1102
 
1103
-if ( ! function_exists( 'espresso_venue_phone' )) {
1103
+if ( ! function_exists('espresso_venue_phone')) {
1104 1104
 	/**
1105 1105
 	 * espresso_venue_phone
1106 1106
 	 *
@@ -1108,18 +1108,18 @@  discard block
 block discarded – undo
1108 1108
 	 * @param bool $echo
1109 1109
 	 * @return string
1110 1110
 	 */
1111
-	function espresso_venue_phone( $VNU_ID = 0, $echo = TRUE ) {
1112
-		if ( $echo ) {
1113
-			echo EEH_Venue_View::venue_phone( $VNU_ID );
1111
+	function espresso_venue_phone($VNU_ID = 0, $echo = TRUE) {
1112
+		if ($echo) {
1113
+			echo EEH_Venue_View::venue_phone($VNU_ID);
1114 1114
 			return '';
1115 1115
 		}
1116
-		return EEH_Venue_View::venue_phone( $VNU_ID );
1116
+		return EEH_Venue_View::venue_phone($VNU_ID);
1117 1117
 	}
1118 1118
 }
1119 1119
 
1120 1120
 
1121 1121
 
1122
-if ( ! function_exists( 'espresso_venue_website' )) {
1122
+if ( ! function_exists('espresso_venue_website')) {
1123 1123
 	/**
1124 1124
 	 * espresso_venue_website
1125 1125
 	 *
@@ -1127,18 +1127,18 @@  discard block
 block discarded – undo
1127 1127
 	 * @param bool $echo
1128 1128
 	 * @return string
1129 1129
 	 */
1130
-	function espresso_venue_website( $VNU_ID = 0, $echo = TRUE ) {
1131
-		if ( $echo ) {
1132
-			echo EEH_Venue_View::venue_website_link( $VNU_ID );
1130
+	function espresso_venue_website($VNU_ID = 0, $echo = TRUE) {
1131
+		if ($echo) {
1132
+			echo EEH_Venue_View::venue_website_link($VNU_ID);
1133 1133
 			return '';
1134 1134
 		}
1135
-		return EEH_Venue_View::venue_website_link( $VNU_ID );
1135
+		return EEH_Venue_View::venue_website_link($VNU_ID);
1136 1136
 	}
1137 1137
 }
1138 1138
 
1139 1139
 
1140 1140
 
1141
-if ( ! function_exists( 'espresso_edit_venue_link' )) {
1141
+if ( ! function_exists('espresso_edit_venue_link')) {
1142 1142
 	/**
1143 1143
 	 * espresso_edit_venue_link
1144 1144
 	 *
@@ -1146,12 +1146,12 @@  discard block
 block discarded – undo
1146 1146
 	 * @param bool $echo
1147 1147
 	 * @return string
1148 1148
 	 */
1149
-	function espresso_edit_venue_link( $VNU_ID = 0, $echo = TRUE ) {
1150
-		if($echo){
1151
-			echo EEH_Venue_View::edit_venue_link( $VNU_ID );
1149
+	function espresso_edit_venue_link($VNU_ID = 0, $echo = TRUE) {
1150
+		if ($echo) {
1151
+			echo EEH_Venue_View::edit_venue_link($VNU_ID);
1152 1152
 			return '';
1153 1153
 		}
1154
-		return EEH_Venue_View::edit_venue_link( $VNU_ID );
1154
+		return EEH_Venue_View::edit_venue_link($VNU_ID);
1155 1155
 	}
1156 1156
 }
1157 1157
 
Please login to merge, or discard this patch.
core/EED_Module.module.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * Event Espresso
4 6
  *
Please login to merge, or discard this patch.
core/EE_Maintenance_Mode.core.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 */
74 74
 	public static function instance() {
75 75
 		// check if class object is instantiated
76
-		if ( self::$_instance === NULL  or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Maintenance_Mode )) {
76
+		if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Maintenance_Mode)) {
77 77
 			self::$_instance = new self();
78 78
 		}
79 79
 		return self::$_instance;
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 * Resets maintenance mode (mostly just re-checks whether or not we should be in maintenance mode)
84 84
 	 * @return EE_Maintenance_Mode
85 85
 	 */
86
-	public static function reset(){
86
+	public static function reset() {
87 87
 		self::instance()->set_maintenance_mode_if_db_old();
88 88
 		return self::instance();
89 89
 	}
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 	 */
99 99
 	private function __construct() {
100 100
 		// if M-Mode level 2 is engaged, we still need basic assets loaded
101
-		add_action( 'wp_enqueue_scripts', array( $this, 'load_assets_required_for_m_mode' ));
101
+		add_action('wp_enqueue_scripts', array($this, 'load_assets_required_for_m_mode'));
102 102
 		// shut 'er down down for maintenance ?
103
-		add_filter( 'the_content', array( $this, 'the_content' ), 2 );
103
+		add_filter('the_content', array($this, 'the_content'), 2);
104 104
 		// add powered by EE msg
105
-		add_action( 'shutdown', array( $this, 'display_maintenance_mode_notice' ), 10 );
105
+		add_action('shutdown', array($this, 'display_maintenance_mode_notice'), 10);
106 106
 	}
107 107
 
108 108
 
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 	 * retrieves the maintenance mode option value from the db
113 113
 	 * @return int
114 114
 	 */
115
-	public function real_level(){
116
-		return get_option( self::option_name_maintenance_mode, EE_Maintenance_Mode::level_0_not_in_maintenance );
115
+	public function real_level() {
116
+		return get_option(self::option_name_maintenance_mode, EE_Maintenance_Mode::level_0_not_in_maintenance);
117 117
 	}
118 118
 
119 119
 	/**
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 * thinks their tables are present and up-to-date).
122 122
 	 * @return boolean
123 123
 	 */
124
-	public function models_can_query(){
124
+	public function models_can_query() {
125 125
 		return $this->real_level() != EE_Maintenance_Mode::level_2_complete_maintenance;
126 126
 	}
127 127
 
@@ -134,14 +134,14 @@  discard block
 block discarded – undo
134 134
 	 * EE_Maintenance_Mode::level_2_complete_maintenance => frontend and backend maintenance mode
135 135
 	 * @return int
136 136
 	 */
137
-	public function level(){
137
+	public function level() {
138 138
 		$real_maintenance_mode_level = $this->real_level();
139 139
 		//if this is an admin request, we'll be honest... except if it's ajax, because that might be from the frontend
140
-		if( ( ! is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) && //only on frontend or ajax requests
140
+		if (( ! is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) && //only on frontend or ajax requests
141 141
 			current_user_can('administrator') && //when the user is an admin
142
-			$real_maintenance_mode_level == EE_Maintenance_Mode::level_1_frontend_only_maintenance){//and we're in level 1
142
+			$real_maintenance_mode_level == EE_Maintenance_Mode::level_1_frontend_only_maintenance) {//and we're in level 1
143 143
 			$maintenance_mode_level = EE_Maintenance_Mode::level_0_not_in_maintenance;
144
-		}else{
144
+		} else {
145 145
 			$maintenance_mode_level = $real_maintenance_mode_level;
146 146
 		}
147 147
 		return $maintenance_mode_level;
@@ -151,17 +151,17 @@  discard block
 block discarded – undo
151 151
 	 * Determines if we need to put EE in maintenance mode because the database needs updating
152 152
 	 * @return boolean true if DB is old and maintenance mode was triggered; false otherwise
153 153
 	 */
154
-	public function set_maintenance_mode_if_db_old(){
155
-		EE_Registry::instance()->load_core( 'Data_Migration_Manager' );
156
-		if( EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()){
154
+	public function set_maintenance_mode_if_db_old() {
155
+		EE_Registry::instance()->load_core('Data_Migration_Manager');
156
+		if (EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) {
157 157
 			update_option(self::option_name_maintenance_mode, self::level_2_complete_maintenance);
158 158
 			return true;
159
-		}elseif( $this->level() == self::level_2_complete_maintenance ){
159
+		}elseif ($this->level() == self::level_2_complete_maintenance) {
160 160
 			//we also want to handle the opposite: if the site is mm2, but there aren't any migrations to run
161 161
 			//then we shouldn't be in mm2. (Maybe an addon got deactivated?)
162
-			update_option( self::option_name_maintenance_mode, self::level_0_not_in_maintenance );
162
+			update_option(self::option_name_maintenance_mode, self::level_0_not_in_maintenance);
163 163
 			return false;
164
-		}else{
164
+		} else {
165 165
 			return false;
166 166
 		}
167 167
 	}
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
 	 * @param int $level
172 172
 	 * @return void
173 173
 	 */
174
-	public function set_maintenance_level($level){
175
-		do_action( 'AHEE__EE_Maintenance_Mode__set_maintenance_level', $level );
174
+	public function set_maintenance_level($level) {
175
+		do_action('AHEE__EE_Maintenance_Mode__set_maintenance_level', $level);
176 176
 		update_option(self::option_name_maintenance_mode, intval($level));
177 177
 	}
178 178
 
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
 	 *  @return 	string
200 200
 	 */
201 201
 	public function load_assets_required_for_m_mode() {
202
-		if ( $this->real_level() == EE_Maintenance_Mode::level_2_complete_maintenance && ! wp_script_is( 'espresso_core', 'enqueued' )) {
203
-			wp_register_style( 'espresso_default', EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', array( 'dashicons' ), EVENT_ESPRESSO_VERSION );
202
+		if ($this->real_level() == EE_Maintenance_Mode::level_2_complete_maintenance && ! wp_script_is('espresso_core', 'enqueued')) {
203
+			wp_register_style('espresso_default', EE_GLOBAL_ASSETS_URL.'css/espresso_default.css', array('dashicons'), EVENT_ESPRESSO_VERSION);
204 204
 			wp_enqueue_style('espresso_default');
205
-			wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE );
206
-			wp_enqueue_script( 'espresso_core' );
205
+			wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE);
206
+			wp_enqueue_script('espresso_core');
207 207
 		}
208 208
 	}
209 209
 
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 	 */
222 222
 	public static function template_include() {
223 223
 		// shut 'er down down for maintenance ? then don't use any of our templates for our endpoints
224
-		return get_template_directory() . '/index.php';
224
+		return get_template_directory().'/index.php';
225 225
 	}
226 226
 
227 227
 
@@ -235,12 +235,12 @@  discard block
 block discarded – undo
235 235
 	 * @param    string $the_content
236 236
 	 * @return    string
237 237
 	 */
238
-	public function the_content( $the_content ) {
238
+	public function the_content($the_content) {
239 239
 		// check if M-mode is engaged and for EE shortcode
240
-		if ( $this->level() && strpos( $the_content, '[ESPRESSO_' ) !== false ) {
240
+		if ($this->level() && strpos($the_content, '[ESPRESSO_') !== false) {
241 241
 			// this can eventually be moved to a template, or edited via admin. But for now...
242 242
 			$the_content = sprintf(
243
-				__( '%sMaintenance Mode%sEvent Registration has been temporarily closed while system maintenance is being performed. We\'re sorry for any inconveniences this may have caused. Please try back again later.%s', 'event_espresso' ),
243
+				__('%sMaintenance Mode%sEvent Registration has been temporarily closed while system maintenance is being performed. We\'re sorry for any inconveniences this may have caused. Please try back again later.%s', 'event_espresso'),
244 244
 				'<h3>',
245 245
 				'</h3><p>',
246 246
 				'</p>'
@@ -264,16 +264,16 @@  discard block
 block discarded – undo
264 264
 		// check if M-mode is engaged and for EE shortcode
265 265
 		if (
266 266
 			$this->real_level() &&
267
-			current_user_can( 'administrator' ) &&
267
+			current_user_can('administrator') &&
268 268
 			! is_admin() &&
269
-			! ( defined( 'DOING_AJAX' ) && DOING_AJAX )
269
+			! (defined('DOING_AJAX') && DOING_AJAX)
270 270
 			&& EE_Registry::instance()->REQ->is_espresso_page()
271 271
 		) {
272 272
 			printf(
273
-				__( '%sclose%sEvent Registration is currently disabled because Event Espresso has been placed into Maintenance Mode. To change Maintenance Mode settings, click here %sEE Maintenance Mode Admin Page%s', 'event_espresso' ),
273
+				__('%sclose%sEvent Registration is currently disabled because Event Espresso has been placed into Maintenance Mode. To change Maintenance Mode settings, click here %sEE Maintenance Mode Admin Page%s', 'event_espresso'),
274 274
 				'<div id="ee-m-mode-admin-notice-dv" class="ee-really-important-notice-dv"><a class="close-espresso-notice" title="',
275 275
 				'"><span class="dashicons dashicons-no"></span></a><p>',
276
-				' &raquo; <a href="' . add_query_arg( array( 'page' => 'espresso_maintenance_settings' ), admin_url( 'admin.php' )) . '">',
276
+				' &raquo; <a href="'.add_query_arg(array('page' => 'espresso_maintenance_settings'), admin_url('admin.php')).'">',
277 277
 				'</a></p></div>'
278 278
 			);
279 279
 		}
@@ -291,9 +291,9 @@  discard block
 block discarded – undo
291 291
 	 *		@ return void
292 292
 	 */
293 293
 	final function __destruct() {}
294
-	final function __call($a,$b) {}
294
+	final function __call($a, $b) {}
295 295
 	final function __get($a) {}
296
-	final function __set($a,$b) {}
296
+	final function __set($a, $b) {}
297 297
 	final function __isset($a) {}
298 298
 	final function __unset($a) {}
299 299
 	final function __sleep() {
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 	final function __invoke() {}
305 305
 	final function __set_state() {}
306 306
 	final function __clone() {}
307
-	final static function __callStatic($a,$b) {}
307
+	final static function __callStatic($a, $b) {}
308 308
 
309 309
 }
310 310
 // End of file EE_Maintenance_Mode.core.php
Please login to merge, or discard this patch.
core/templates/json_linked_data_for_event.template.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,8 +32,8 @@
 block discarded – undo
32 32
       "price": "<?php echo $ticket['price']; ?>",
33 33
       "priceCurrency": "<?php echo $currency; ?>"
34 34
     }<?php if (is_array($event_tickets) && end($event_tickets) !== $ticket) { echo ','; }
35
-    }
36
-    ?>
35
+	}
36
+	?>
37 37
     ]<?php if ($venue_name) { ?>,
38 38
   "location": {
39 39
     "@type": "Place",
Please login to merge, or discard this patch.
espresso.php 2 patches
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -129,54 +129,54 @@  discard block
 block discarded – undo
129 129
         define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130 130
         define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131 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);
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 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);
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 153
         // gateways
154
-        define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
-        define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
154
+        define('EE_GATEWAYS', EE_MODULES.'gateways'.DS);
155
+        define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL.'modules'.DS.'gateways'.DS);
156 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/');
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 163
         // define upload paths
164 164
         $uploads = wp_upload_dir();
165 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);
166
+        define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'].DS.'espresso'.DS);
167
+        define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'].DS.'espresso'.DS);
168 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);
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 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);
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 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);
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 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);
178
+        if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS)) {
179
+            define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS);
180 180
         }
181 181
         //ajax constants
182 182
         define(
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
         //you're better to use this than its straight value (currently -1) in case you ever
192 192
         //want to change its default value! or find when -1 means infinity
193 193
         define('EE_INF_IN_DB', -1);
194
-        define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
194
+        define('EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX);
195 195
         define('EE_DEBUG', false);
196 196
         // for older WP versions
197 197
         if ( ! defined('MONTH_IN_SECONDS')) {
@@ -214,13 +214,13 @@  discard block
 block discarded – undo
214 214
         function espresso_load_error_handling()
215 215
         {
216 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');
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 219
                 EEH_Debug_Tools::instance();
220 220
             }
221 221
             // load error handling
222
-            if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
-                require_once(EE_CORE . 'EE_Error.core.php');
222
+            if (is_readable(EE_CORE.'EE_Error.core.php')) {
223
+                require_once(EE_CORE.'EE_Error.core.php');
224 224
             } else {
225 225
                 wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226 226
             }
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
             if (is_readable($full_path_to_file)) {
245 245
                 require_once($full_path_to_file);
246 246
             } else {
247
-                throw new EE_Error (
247
+                throw new EE_Error(
248 248
                         sprintf(
249 249
                                 esc_html__(
250 250
                                         'The %s class file could not be located or is not readable due to file permissions.',
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
             }
257 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');
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 262
         new EE_Bootstrap();
263 263
     }
264 264
 }
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
     function espresso_deactivate_plugin($plugin_basename = '')
275 275
     {
276 276
         if ( ! function_exists('deactivate_plugins')) {
277
-            require_once(ABSPATH . 'wp-admin/includes/plugin.php');
277
+            require_once(ABSPATH.'wp-admin/includes/plugin.php');
278 278
         }
279 279
         unset($_GET['activate'], $_REQUEST['activate']);
280 280
         deactivate_plugins($plugin_basename);
Please login to merge, or discard this 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.29.rc.004');
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.29.rc.004');
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
 }
Please login to merge, or discard this patch.