Completed
Branch FET-3467-waitlists (78124b)
by
unknown
141:27 queued 128:30
created
core/services/shortcodes/ShortcodeInterface.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -8,39 +8,39 @@
 block discarded – undo
8 8
 interface ShortcodeInterface
9 9
 {
10 10
 
11
-    /**
12
-     * the actual shortcode tag that gets registered with WordPress
13
-     *
14
-     * @return string
15
-     */
16
-    public function getTag();
17
-
18
-    /**
19
-     * the length of time in seconds to cache the results of the processShortcode() method
20
-     * 0 means the processShortcode() results will NOT be cached at all
21
-     *
22
-     * @return int
23
-     */
24
-    public function cacheExpiration();
25
-
26
-    /**
27
-     * a place for adding any initialization code that needs to run prior to wp_header().
28
-     * this may be required for shortcodes that utilize a corresponding module,
29
-     * and need to enqueue assets for that module
30
-     *
31
-     * @return void
32
-     */
33
-    public function initializeShortcode();
34
-
35
-    /**
36
-     * callback that runs when the shortcode is encountered in post content.
37
-     * IMPORTANT !!!
38
-     * remember that shortcode content should be RETURNED and NOT echoed out
39
-     *
40
-     * @param array $attributes
41
-     * @return string
42
-     */
43
-    public function processShortcode($attributes = array());
11
+	/**
12
+	 * the actual shortcode tag that gets registered with WordPress
13
+	 *
14
+	 * @return string
15
+	 */
16
+	public function getTag();
17
+
18
+	/**
19
+	 * the length of time in seconds to cache the results of the processShortcode() method
20
+	 * 0 means the processShortcode() results will NOT be cached at all
21
+	 *
22
+	 * @return int
23
+	 */
24
+	public function cacheExpiration();
25
+
26
+	/**
27
+	 * a place for adding any initialization code that needs to run prior to wp_header().
28
+	 * this may be required for shortcodes that utilize a corresponding module,
29
+	 * and need to enqueue assets for that module
30
+	 *
31
+	 * @return void
32
+	 */
33
+	public function initializeShortcode();
34
+
35
+	/**
36
+	 * callback that runs when the shortcode is encountered in post content.
37
+	 * IMPORTANT !!!
38
+	 * remember that shortcode content should be RETURNED and NOT echoed out
39
+	 *
40
+	 * @param array $attributes
41
+	 * @return string
42
+	 */
43
+	public function processShortcode($attributes = array());
44 44
 
45 45
 }
46 46
 // End of file ShortcodeInterface.php
Please login to merge, or discard this patch.
core/domain/entities/shortcodes/EspressoTxnPage.php 1 patch
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -27,91 +27,91 @@
 block discarded – undo
27 27
 
28 28
 
29 29
 
30
-    /**
31
-     * the actual shortcode tag that gets registered with WordPress
32
-     *
33
-     * @return string
34
-     */
35
-    public function getTag()
36
-    {
37
-        return 'ESPRESSO_TXN_PAGE';
38
-    }
39
-
40
-
41
-
42
-    /**
43
-     * the time in seconds to cache the results of the processShortcode() method
44
-     * 0 means the processShortcode() results will NOT be cached at all
45
-     *
46
-     * @return int
47
-     */
48
-    public function cacheExpiration()
49
-    {
50
-        return 0;
51
-    }
52
-
53
-
54
-    /**
55
-     * a place for adding any initialization code that needs to run prior to wp_header().
56
-     * this may be required for shortcodes that utilize a corresponding module,
57
-     * and need to enqueue assets for that module
58
-     *
59
-     * @return void
60
-     * @throws \Exception
61
-     * @throws \EE_Error
62
-     */
63
-    public function initializeShortcode()
64
-    {
65
-        $transaction = null;
66
-        if (EE_Registry::instance()->REQ->is_set('e_reg_url_link')) {
67
-            /** @var EEM_Transaction $EEM_Transaction */
68
-            $EEM_Transaction = EE_Registry::instance()->load_model('Transaction');
69
-            $transaction = $EEM_Transaction->get_transaction_from_reg_url_link();
70
-        }
71
-        if ($transaction instanceof EE_Transaction) {
72
-            $payment_method = null;
73
-            $payment_method_slug = EE_Registry::instance()->REQ->get('ee_payment_method', null);
74
-            if ($payment_method_slug) {
75
-                $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($payment_method_slug);
76
-            }
77
-            if ($payment_method instanceof EE_Payment_Method && $payment_method->is_off_site()) {
78
-                $gateway = $payment_method->type_obj()->get_gateway();
79
-                if (
80
-                    $gateway instanceof EE_Offsite_Gateway
81
-                    && $gateway->handle_IPN_in_this_request(
82
-                        \EE_Registry::instance()->REQ->params(),
83
-                        true
84
-                    )
85
-                ) {
86
-                    /** @type EE_Payment_Processor $payment_processor */
87
-                    $payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
88
-                    $payment_processor->process_ipn($_REQUEST, $transaction, $payment_method);
89
-                }
90
-            }
91
-            //allow gateways to add a filter to stop rendering the page
92
-            if (apply_filters('FHEE__EES_Espresso_Txn_Page__run__exit', false)) {
93
-                exit;
94
-            }
95
-        }
96
-    }
97
-
98
-
99
-
100
-    /**
101
-     * callback that runs when the shortcode is encountered in post content.
102
-     * IMPORTANT !!!
103
-     * remember that shortcode content should be RETURNED and NOT echoed out
104
-     *
105
-     * @param array $attributes
106
-     * @return string
107
-     */
108
-    public function processShortcode($attributes = array())
109
-    {
110
-        return esc_html__(
111
-            'This is the Event Espresso Transactions page. This page receives instant payment notification (IPN) requests and should have a status of published, but should not be easily accessible by site visitors. Do not add it to your website\'s navigation menu or link to it from another page. Also, do not delete it or change its status to private.',
112
-            'event_espresso'
113
-        );
114
-    }
30
+	/**
31
+	 * the actual shortcode tag that gets registered with WordPress
32
+	 *
33
+	 * @return string
34
+	 */
35
+	public function getTag()
36
+	{
37
+		return 'ESPRESSO_TXN_PAGE';
38
+	}
39
+
40
+
41
+
42
+	/**
43
+	 * the time in seconds to cache the results of the processShortcode() method
44
+	 * 0 means the processShortcode() results will NOT be cached at all
45
+	 *
46
+	 * @return int
47
+	 */
48
+	public function cacheExpiration()
49
+	{
50
+		return 0;
51
+	}
52
+
53
+
54
+	/**
55
+	 * a place for adding any initialization code that needs to run prior to wp_header().
56
+	 * this may be required for shortcodes that utilize a corresponding module,
57
+	 * and need to enqueue assets for that module
58
+	 *
59
+	 * @return void
60
+	 * @throws \Exception
61
+	 * @throws \EE_Error
62
+	 */
63
+	public function initializeShortcode()
64
+	{
65
+		$transaction = null;
66
+		if (EE_Registry::instance()->REQ->is_set('e_reg_url_link')) {
67
+			/** @var EEM_Transaction $EEM_Transaction */
68
+			$EEM_Transaction = EE_Registry::instance()->load_model('Transaction');
69
+			$transaction = $EEM_Transaction->get_transaction_from_reg_url_link();
70
+		}
71
+		if ($transaction instanceof EE_Transaction) {
72
+			$payment_method = null;
73
+			$payment_method_slug = EE_Registry::instance()->REQ->get('ee_payment_method', null);
74
+			if ($payment_method_slug) {
75
+				$payment_method = EEM_Payment_Method::instance()->get_one_by_slug($payment_method_slug);
76
+			}
77
+			if ($payment_method instanceof EE_Payment_Method && $payment_method->is_off_site()) {
78
+				$gateway = $payment_method->type_obj()->get_gateway();
79
+				if (
80
+					$gateway instanceof EE_Offsite_Gateway
81
+					&& $gateway->handle_IPN_in_this_request(
82
+						\EE_Registry::instance()->REQ->params(),
83
+						true
84
+					)
85
+				) {
86
+					/** @type EE_Payment_Processor $payment_processor */
87
+					$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
88
+					$payment_processor->process_ipn($_REQUEST, $transaction, $payment_method);
89
+				}
90
+			}
91
+			//allow gateways to add a filter to stop rendering the page
92
+			if (apply_filters('FHEE__EES_Espresso_Txn_Page__run__exit', false)) {
93
+				exit;
94
+			}
95
+		}
96
+	}
97
+
98
+
99
+
100
+	/**
101
+	 * callback that runs when the shortcode is encountered in post content.
102
+	 * IMPORTANT !!!
103
+	 * remember that shortcode content should be RETURNED and NOT echoed out
104
+	 *
105
+	 * @param array $attributes
106
+	 * @return string
107
+	 */
108
+	public function processShortcode($attributes = array())
109
+	{
110
+		return esc_html__(
111
+			'This is the Event Espresso Transactions page. This page receives instant payment notification (IPN) requests and should have a status of published, but should not be easily accessible by site visitors. Do not add it to your website\'s navigation menu or link to it from another page. Also, do not delete it or change its status to private.',
112
+			'event_espresso'
113
+		);
114
+	}
115 115
 }
116 116
 // End of file EspressoTxnPage.php
117 117
 // Location: EventEspresso\core\domain\entities\shortcodes/EspressoTxnPage.php
118 118
\ No newline at end of file
Please login to merge, or discard this patch.
core/domain/entities/shortcodes/EspressoCancelled.php 1 patch
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -24,79 +24,79 @@
 block discarded – undo
24 24
 
25 25
 
26 26
 
27
-    /**
28
-     * the actual shortcode tag that gets registered with WordPress
29
-     *
30
-     * @return string
31
-     */
32
-    public function getTag()
33
-    {
34
-        return 'ESPRESSO_CANCELLED';
35
-    }
36
-
37
-
38
-
39
-    /**
40
-     * the time in seconds to cache the results of the processShortcode() method
41
-     * 0 means the processShortcode() results will NOT be cached at all
42
-     *
43
-     * @return int
44
-     */
45
-    public function cacheExpiration()
46
-    {
47
-        return 0;
48
-    }
49
-
50
-
51
-    /**
52
-     * a place for adding any initialization code that needs to run prior to wp_header().
53
-     * this may be required for shortcodes that utilize a corresponding module,
54
-     * and need to enqueue assets for that module
55
-     *
56
-     * @return void
57
-     */
58
-    public function initializeShortcode()
59
-    {
60
-        // required by interface, but nothing to do atm
61
-    }
62
-
63
-
64
-    /**
65
-     * callback that runs when the shortcode is encountered in post content.
66
-     * IMPORTANT !!!
67
-     * remember that shortcode content should be RETURNED and NOT echoed out
68
-     *
69
-     * @param array $attributes
70
-     * @return string
71
-     * @throws \EE_Error
72
-     */
73
-    public function processShortcode($attributes = array())
74
-    {
75
-        $transaction = EE_Registry::instance()->SSN->get_session_data('transaction');
76
-        if ($transaction instanceof EE_Transaction) {
77
-            do_action('AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', $transaction);
78
-            $registrations = $transaction->registrations();
79
-            foreach ($registrations as $registration) {
80
-                if ($registration instanceof EE_Registration) {
81
-                    do_action('AHEE__EES_Espresso_Cancelled__process_shortcode__registration', $registration);
82
-                }
83
-            }
84
-        }
85
-        do_action('AHEE__EES_Espresso_Cancelled__process_shortcode__clear_session');
86
-        // remove all unwanted records from the db
87
-        if (EE_Registry::instance()->CART instanceof EE_Cart) {
88
-            EE_Registry::instance()->CART->delete_cart();
89
-        }
90
-        EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
91
-        return sprintf(
92
-            __(
93
-                '%sAll unsaved registration information entered during this session has been deleted.%s',
94
-                'event_espresso'
95
-            ),
96
-            '<p class="ee-registrations-cancelled-pg ee-attention">',
97
-            '</p>'
98
-        );
99
-    }
27
+	/**
28
+	 * the actual shortcode tag that gets registered with WordPress
29
+	 *
30
+	 * @return string
31
+	 */
32
+	public function getTag()
33
+	{
34
+		return 'ESPRESSO_CANCELLED';
35
+	}
36
+
37
+
38
+
39
+	/**
40
+	 * the time in seconds to cache the results of the processShortcode() method
41
+	 * 0 means the processShortcode() results will NOT be cached at all
42
+	 *
43
+	 * @return int
44
+	 */
45
+	public function cacheExpiration()
46
+	{
47
+		return 0;
48
+	}
49
+
50
+
51
+	/**
52
+	 * a place for adding any initialization code that needs to run prior to wp_header().
53
+	 * this may be required for shortcodes that utilize a corresponding module,
54
+	 * and need to enqueue assets for that module
55
+	 *
56
+	 * @return void
57
+	 */
58
+	public function initializeShortcode()
59
+	{
60
+		// required by interface, but nothing to do atm
61
+	}
62
+
63
+
64
+	/**
65
+	 * callback that runs when the shortcode is encountered in post content.
66
+	 * IMPORTANT !!!
67
+	 * remember that shortcode content should be RETURNED and NOT echoed out
68
+	 *
69
+	 * @param array $attributes
70
+	 * @return string
71
+	 * @throws \EE_Error
72
+	 */
73
+	public function processShortcode($attributes = array())
74
+	{
75
+		$transaction = EE_Registry::instance()->SSN->get_session_data('transaction');
76
+		if ($transaction instanceof EE_Transaction) {
77
+			do_action('AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', $transaction);
78
+			$registrations = $transaction->registrations();
79
+			foreach ($registrations as $registration) {
80
+				if ($registration instanceof EE_Registration) {
81
+					do_action('AHEE__EES_Espresso_Cancelled__process_shortcode__registration', $registration);
82
+				}
83
+			}
84
+		}
85
+		do_action('AHEE__EES_Espresso_Cancelled__process_shortcode__clear_session');
86
+		// remove all unwanted records from the db
87
+		if (EE_Registry::instance()->CART instanceof EE_Cart) {
88
+			EE_Registry::instance()->CART->delete_cart();
89
+		}
90
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
91
+		return sprintf(
92
+			__(
93
+				'%sAll unsaved registration information entered during this session has been deleted.%s',
94
+				'event_espresso'
95
+			),
96
+			'<p class="ee-registrations-cancelled-pg ee-attention">',
97
+			'</p>'
98
+		);
99
+	}
100 100
 
101 101
 }
102 102
 // End of file EspressoCancelled.php
Please login to merge, or discard this patch.
core/domain/entities/shortcodes/EspressoCheckout.php 1 patch
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -21,58 +21,58 @@
 block discarded – undo
21 21
 {
22 22
 
23 23
 
24
-    /**
25
-     * the actual shortcode tag that gets registered with WordPress
26
-     *
27
-     * @return string
28
-     */
29
-    public function getTag()
30
-    {
31
-        return 'ESPRESSO_CHECKOUT';
32
-    }
33
-
34
-
35
-
36
-    /**
37
-     * the time in seconds to cache the results of the processShortcode() method
38
-     * 0 means the processShortcode() results will NOT be cached at all
39
-     *
40
-     * @return int
41
-     */
42
-    public function cacheExpiration()
43
-    {
44
-        return 0;
45
-    }
46
-
47
-
48
-    /**
49
-     * a place for adding any initialization code that needs to run prior to wp_header().
50
-     * this may be required for shortcodes that utilize a corresponding module,
51
-     * and need to enqueue assets for that module
52
-     *
53
-     * @return void
54
-     * @throws \EE_Error
55
-     */
56
-    public function initializeShortcode()
57
-    {
58
-        global $wp_query;
59
-        EED_Single_Page_Checkout::init($wp_query);
60
-    }
61
-
62
-
63
-
64
-    /**
65
-     * callback that runs when the shortcode is encountered in post content.
66
-     * IMPORTANT !!!
67
-     * remember that shortcode content should be RETURNED and NOT echoed out
68
-     *
69
-     * @param array $attributes
70
-     * @return string
71
-     */
72
-    public function processShortcode($attributes = array())
73
-    {
74
-        return EE_Registry::instance()->REQ->get_output();
75
-    }
24
+	/**
25
+	 * the actual shortcode tag that gets registered with WordPress
26
+	 *
27
+	 * @return string
28
+	 */
29
+	public function getTag()
30
+	{
31
+		return 'ESPRESSO_CHECKOUT';
32
+	}
33
+
34
+
35
+
36
+	/**
37
+	 * the time in seconds to cache the results of the processShortcode() method
38
+	 * 0 means the processShortcode() results will NOT be cached at all
39
+	 *
40
+	 * @return int
41
+	 */
42
+	public function cacheExpiration()
43
+	{
44
+		return 0;
45
+	}
46
+
47
+
48
+	/**
49
+	 * a place for adding any initialization code that needs to run prior to wp_header().
50
+	 * this may be required for shortcodes that utilize a corresponding module,
51
+	 * and need to enqueue assets for that module
52
+	 *
53
+	 * @return void
54
+	 * @throws \EE_Error
55
+	 */
56
+	public function initializeShortcode()
57
+	{
58
+		global $wp_query;
59
+		EED_Single_Page_Checkout::init($wp_query);
60
+	}
61
+
62
+
63
+
64
+	/**
65
+	 * callback that runs when the shortcode is encountered in post content.
66
+	 * IMPORTANT !!!
67
+	 * remember that shortcode content should be RETURNED and NOT echoed out
68
+	 *
69
+	 * @param array $attributes
70
+	 * @return string
71
+	 */
72
+	public function processShortcode($attributes = array())
73
+	{
74
+		return EE_Registry::instance()->REQ->get_output();
75
+	}
76 76
 
77 77
 
78 78
 
Please login to merge, or discard this patch.
modules/event_single/EED_Event_Single.module.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -175,13 +175,13 @@
 block discarded – undo
175 175
 		}
176 176
 		// not a custom template?
177 177
 		if (
178
-            ! post_password_required($post)
178
+			! post_password_required($post)
179 179
 			&& (
180
-                apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', false)
181
-			    || EE_Registry::instance()
182
-                    ->load_core( 'Front_Controller', array(), false )
183
-                    ->get_selected_template() !== 'single-espresso_events.php'
184
-            )
180
+				apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', false)
181
+				|| EE_Registry::instance()
182
+					->load_core( 'Front_Controller', array(), false )
183
+					->get_selected_template() !== 'single-espresso_events.php'
184
+			)
185 185
 
186 186
 		) {
187 187
 			EEH_Template::load_espresso_theme_functions();
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 * @return EED_Event_Single
41 41
 	 */
42 42
 	public static function instance() {
43
-		return parent::get_instance( __CLASS__ );
43
+		return parent::get_instance(__CLASS__);
44 44
 	}
45 45
 
46 46
 
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 	 *  @return 	void
53 53
 	 */
54 54
 	public static function set_hooks() {
55
-		add_filter( 'FHEE_run_EE_wp', '__return_true' );
56
-		add_action( 'wp_loaded', array( 'EED_Event_Single', 'set_definitions' ), 2 );
57
-		EE_Config::register_route( __( 'event', 'event_espresso' ), 'Event_Single', 'run' );
55
+		add_filter('FHEE_run_EE_wp', '__return_true');
56
+		add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2);
57
+		EE_Config::register_route(__('event', 'event_espresso'), 'Event_Single', 'run');
58 58
 	}
59 59
 
60 60
 	/**
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 *  @return 	void
65 65
 	 */
66 66
 	public static function set_hooks_admin() {
67
-		add_action( 'wp_loaded', array( 'EED_Event_Single', 'set_definitions' ), 2 );
67
+		add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2);
68 68
 	}
69 69
 
70 70
 
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
 	 * @return void
79 79
 	 */
80 80
 	public static function set_definitions() {
81
-		define( 'EVENT_SINGLE_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS );
82
-		define( 'EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path( __FILE__ ) . 'templates' . DS );
81
+		define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS);
82
+		define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__).'templates'.DS);
83 83
 	}
84 84
 
85 85
 
@@ -89,10 +89,10 @@  discard block
 block discarded – undo
89 89
 	 *
90 90
 	 * @void
91 91
 	 */
92
-	protected function set_config(){
93
-		$this->set_config_section( 'template_settings' );
94
-		$this->set_config_class( 'EE_Event_Single_Config' );
95
-		$this->set_config_name( 'EED_Event_Single' );
92
+	protected function set_config() {
93
+		$this->set_config_section('template_settings');
94
+		$this->set_config_class('EE_Event_Single_Config');
95
+		$this->set_config_name('EED_Event_Single');
96 96
 	}
97 97
 
98 98
 
@@ -105,35 +105,35 @@  discard block
 block discarded – undo
105 105
 	 * @param \EE_Event_Single_Config $config
106 106
 	 * @return \EE_Template_Part_Manager
107 107
 	 */
108
-	public function initialize_template_parts( EE_Event_Single_Config $config = null ) {
108
+	public function initialize_template_parts(EE_Event_Single_Config $config = null) {
109 109
 		$config = $config instanceof EE_Event_Single_Config ? $config : $this->config();
110 110
 		EEH_Autoloader::instance()->register_template_part_autoloaders();
111 111
 		$template_parts = new EE_Template_Part_Manager();
112 112
 		$template_parts->add_template_part(
113 113
 			'tickets',
114
-			__( 'Ticket Selector', 'event_espresso' ),
114
+			__('Ticket Selector', 'event_espresso'),
115 115
 			'content-espresso_events-tickets.php',
116 116
 			$config->display_order_tickets
117 117
 		);
118 118
 		$template_parts->add_template_part(
119 119
 			'datetimes',
120
-			__( 'Dates and Times', 'event_espresso' ),
120
+			__('Dates and Times', 'event_espresso'),
121 121
 			'content-espresso_events-datetimes.php',
122 122
 			$config->display_order_datetimes
123 123
 		);
124 124
 		$template_parts->add_template_part(
125 125
 			'event',
126
-			__( 'Event Description', 'event_espresso' ),
126
+			__('Event Description', 'event_espresso'),
127 127
 			'content-espresso_events-details.php',
128 128
 			$config->display_order_event
129 129
 		);
130 130
 		$template_parts->add_template_part(
131 131
 			'venue',
132
-			__( 'Venue Information', 'event_espresso' ),
132
+			__('Venue Information', 'event_espresso'),
133 133
 			'content-espresso_events-venues.php',
134 134
 			$config->display_order_venue
135 135
 		);
136
-		do_action( 'AHEE__EED_Event_Single__initialize_template_parts', $template_parts );
136
+		do_action('AHEE__EED_Event_Single__initialize_template_parts', $template_parts);
137 137
 		return $template_parts;
138 138
 	}
139 139
 
@@ -147,14 +147,14 @@  discard block
 block discarded – undo
147 147
 	 * @param WP $WP
148 148
 	 * @return    void
149 149
 	 */
150
-	public function run( $WP ) {
150
+	public function run($WP) {
151 151
 		// ensure valid EE_Events_Single_Config() object exists
152 152
 		$this->set_config();
153 153
 		// check what template is loaded
154
-		add_filter( 'template_include',  array( $this, 'template_include' ), 999, 1 );
155
-		add_filter( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' );
154
+		add_filter('template_include', array($this, 'template_include'), 999, 1);
155
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
156 156
 		// load css
157
-		add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 10 );
157
+		add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
158 158
 	}
159 159
 
160 160
 
@@ -166,12 +166,12 @@  discard block
 block discarded – undo
166 166
 	 * @param 	string $template
167 167
 	 * @return 	string
168 168
 	 */
169
-	public function template_include( $template ) {
169
+	public function template_include($template) {
170 170
 		global $post;
171 171
 		/** @type EE_Event_Single_Config $config */
172 172
 		$config = $this->config();
173
-		if ( $config->display_status_banner_single ) {
174
-			add_filter( 'the_title', array( 'EED_Event_Single', 'the_title' ), 100, 2 );
173
+		if ($config->display_status_banner_single) {
174
+			add_filter('the_title', array('EED_Event_Single', 'the_title'), 100, 2);
175 175
 		}
176 176
 		// not a custom template?
177 177
 		if (
@@ -179,19 +179,19 @@  discard block
 block discarded – undo
179 179
 			&& (
180 180
                 apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', false)
181 181
 			    || EE_Registry::instance()
182
-                    ->load_core( 'Front_Controller', array(), false )
182
+                    ->load_core('Front_Controller', array(), false)
183 183
                     ->get_selected_template() !== 'single-espresso_events.php'
184 184
             )
185 185
 
186 186
 		) {
187 187
 			EEH_Template::load_espresso_theme_functions();
188 188
 			// then add extra event data via hooks
189
-			add_action( 'loop_start', array( 'EED_Event_Single', 'loop_start' ));
190
-			add_filter( 'get_the_excerpt', array( 'EED_Event_Single', 'get_the_excerpt' ), 1, 1 );
191
-			add_filter( 'the_content', array( 'EED_Event_Single', 'event_details' ), 1 );
192
-			add_action( 'loop_end', array( 'EED_Event_Single', 'loop_end' ));
189
+			add_action('loop_start', array('EED_Event_Single', 'loop_start'));
190
+			add_filter('get_the_excerpt', array('EED_Event_Single', 'get_the_excerpt'), 1, 1);
191
+			add_filter('the_content', array('EED_Event_Single', 'event_details'), 1);
192
+			add_action('loop_end', array('EED_Event_Single', 'loop_end'));
193 193
 			// don't display entry meta because the existing theme will take car of that
194
-			add_filter( 'FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false' );
194
+			add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false');
195 195
 		}
196 196
 		return $template;
197 197
 	}
@@ -205,9 +205,9 @@  discard block
 block discarded – undo
205 205
 	 * @param 	array $wp_query_array an array containing the WP_Query object
206 206
 	 * @return 	void
207 207
 	 */
208
-	public static function loop_start( $wp_query_array ) {
208
+	public static function loop_start($wp_query_array) {
209 209
 		global $post;
210
-		do_action( 'AHEE_event_details_before_post', $post, $wp_query_array );
210
+		do_action('AHEE_event_details_before_post', $post, $wp_query_array);
211 211
 	}
212 212
 
213 213
 
@@ -220,9 +220,9 @@  discard block
 block discarded – undo
220 220
 	 * @param 	int 	$id
221 221
 	 * @return 	string
222 222
 	 */
223
-	public static function the_title( $title = '', $id = 0 ) {
223
+	public static function the_title($title = '', $id = 0) {
224 224
 		global $post;
225
-		return in_the_loop() && $post->ID === (int) $id ? espresso_event_status_banner( $post->ID ) . $title :  $title;
225
+		return in_the_loop() && $post->ID === (int) $id ? espresso_event_status_banner($post->ID).$title : $title;
226 226
 	}
227 227
 
228 228
 
@@ -234,9 +234,9 @@  discard block
 block discarded – undo
234 234
 	 * @param        string $excerpt
235 235
 	 * @return        string
236 236
 	 */
237
-	public static function get_the_excerpt( $excerpt = '' ) {
237
+	public static function get_the_excerpt($excerpt = '') {
238 238
 		EED_Event_Single::$using_get_the_excerpt = true;
239
-		add_filter( 'wp_trim_excerpt', array( 'EED_Event_Single', 'end_get_the_excerpt' ), 999, 1 );
239
+		add_filter('wp_trim_excerpt', array('EED_Event_Single', 'end_get_the_excerpt'), 999, 1);
240 240
 		return $excerpt;
241 241
 	}
242 242
 
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 	 * @param  string $text
250 250
 	 * @return string
251 251
 	 */
252
-	public static function end_get_the_excerpt( $text = '' ) {
252
+	public static function end_get_the_excerpt($text = '') {
253 253
 		EED_Event_Single::$using_get_the_excerpt = false;
254 254
 		return $text;
255 255
 	}
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 	 * @param 	string 	$content
264 264
 	 * @return 	string
265 265
 	 */
266
-	public static function event_details( $content ) {
266
+	public static function event_details($content) {
267 267
 		global $post;
268 268
 		static $current_post_ID = 0;
269 269
 		if (
@@ -278,15 +278,15 @@  discard block
 block discarded – undo
278 278
 			// We want to allow those plugins to still do their thing and have access to our content, but depending on
279 279
 			// how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice,
280 280
 			// so the following allows this filter to be applied multiple times, but only once for real
281
-			$current_post_ID = did_action( 'loop_start' ) ? $post->ID : 0;
282
-			if ( EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order ) {
281
+			$current_post_ID = did_action('loop_start') ? $post->ID : 0;
282
+			if (EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order) {
283 283
 				// we need to first remove this callback from being applied to the_content()
284 284
 				// (otherwise it will recurse and blow up the interweb)
285
-				remove_filter( 'the_content', array( 'EED_Event_Single', 'event_details' ), 1 );
285
+				remove_filter('the_content', array('EED_Event_Single', 'event_details'), 1);
286 286
 				EED_Event_Single::instance()->template_parts = EED_Event_Single::instance()->initialize_template_parts();
287
-				$content = EEH_Template::locate_template( 'content-espresso_events-details.php' );
288
-				$content = EED_Event_Single::instance()->template_parts->apply_template_part_filters( $content );
289
-				add_filter( 'the_content', array( 'EED_Event_Single', 'event_details' ), 1 );
287
+				$content = EEH_Template::locate_template('content-espresso_events-details.php');
288
+				$content = EED_Event_Single::instance()->template_parts->apply_template_part_filters($content);
289
+				add_filter('the_content', array('EED_Event_Single', 'event_details'), 1);
290 290
 			} else {
291 291
 				$content = EED_Event_Single::use_filterable_display_order();
292 292
 			}
@@ -307,20 +307,20 @@  discard block
 block discarded – undo
307 307
 		// it uses the_content() for displaying the $post->post_content
308 308
 		// so in order to load a template that uses the_content() from within a callback being used to filter the_content(),
309 309
 		// we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb)
310
-		remove_filter( 'the_content', array( 'EED_Event_Single', 'event_details' ), 1 );
310
+		remove_filter('the_content', array('EED_Event_Single', 'event_details'), 1);
311 311
 		//now add additional content
312
-		add_filter( 'the_content', array( 'EED_Event_Single', 'event_datetimes' ), 2, 1 );
313
-		add_filter( 'the_content', array( 'EED_Event_Single', 'event_tickets' ), 3, 1 );
314
-		add_filter( 'the_content', array( 'EED_Event_Single', 'event_venues' ), 4, 1 );
315
-		do_action( 'AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters' );
312
+		add_filter('the_content', array('EED_Event_Single', 'event_datetimes'), 2, 1);
313
+		add_filter('the_content', array('EED_Event_Single', 'event_tickets'), 3, 1);
314
+		add_filter('the_content', array('EED_Event_Single', 'event_venues'), 4, 1);
315
+		do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters');
316 316
 		// now load our template
317
-		$content = EEH_Template::locate_template( 'content-espresso_events-details.php' );
317
+		$content = EEH_Template::locate_template('content-espresso_events-details.php');
318 318
 		//now add our filter back in, plus some others
319
-		add_filter( 'the_content', array( 'EED_Event_Single', 'event_details' ), 1 );
320
-		remove_filter( 'the_content', array( 'EED_Event_Single', 'event_datetimes' ), 2 );
321
-		remove_filter( 'the_content', array( 'EED_Event_Single', 'event_tickets' ), 3 );
322
-		remove_filter( 'the_content', array( 'EED_Event_Single', 'event_venues' ), 4 );
323
-		do_action( 'AHEE__EED_Event_Single__use_filterable_display_order__after_remove_filters' );
319
+		add_filter('the_content', array('EED_Event_Single', 'event_details'), 1);
320
+		remove_filter('the_content', array('EED_Event_Single', 'event_datetimes'), 2);
321
+		remove_filter('the_content', array('EED_Event_Single', 'event_tickets'), 3);
322
+		remove_filter('the_content', array('EED_Event_Single', 'event_venues'), 4);
323
+		do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_remove_filters');
324 324
 		// we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
325 325
 		return $content;
326 326
 	}
@@ -334,8 +334,8 @@  discard block
 block discarded – undo
334 334
 	 * @param        string $content
335 335
 	 * @return        string
336 336
 	 */
337
-	public static function event_datetimes( $content ) {
338
-		return EEH_Template::locate_template( 'content-espresso_events-datetimes.php' ) . $content;
337
+	public static function event_datetimes($content) {
338
+		return EEH_Template::locate_template('content-espresso_events-datetimes.php').$content;
339 339
 	}
340 340
 
341 341
 
@@ -347,8 +347,8 @@  discard block
 block discarded – undo
347 347
 	 * @param        string $content
348 348
 	 * @return        string
349 349
 	 */
350
-	public static function event_tickets( $content ) {
351
-		return EEH_Template::locate_template( 'content-espresso_events-tickets.php' ) . $content;
350
+	public static function event_tickets($content) {
351
+		return EEH_Template::locate_template('content-espresso_events-tickets.php').$content;
352 352
 	}
353 353
 
354 354
 
@@ -360,8 +360,8 @@  discard block
 block discarded – undo
360 360
 	 * @param 	string $content
361 361
 	 * @return 	string
362 362
 	 */
363
-	public static function event_venue( $content ) {
364
-		return EED_Event_Single::event_venues( $content );
363
+	public static function event_venue($content) {
364
+		return EED_Event_Single::event_venues($content);
365 365
 	}
366 366
 
367 367
 
@@ -373,8 +373,8 @@  discard block
 block discarded – undo
373 373
 	 * @param        string $content
374 374
 	 * @return        string
375 375
 	 */
376
-	public static function event_venues( $content ) {
377
-		return $content . EEH_Template::locate_template( 'content-espresso_events-venues.php' );
376
+	public static function event_venues($content) {
377
+		return $content.EEH_Template::locate_template('content-espresso_events-venues.php');
378 378
 	}
379 379
 
380 380
 
@@ -386,9 +386,9 @@  discard block
 block discarded – undo
386 386
 	 * 	@param		array 	$wp_query_array an array containing the WP_Query object
387 387
 	 *  	@return 		void
388 388
 	 */
389
-	public static function loop_end( $wp_query_array ) {
389
+	public static function loop_end($wp_query_array) {
390 390
 		global $post;
391
-		do_action( 'AHEE_event_details_after_post', $post, $wp_query_array );
391
+		do_action('AHEE_event_details_after_post', $post, $wp_query_array);
392 392
 	}
393 393
 
394 394
 
@@ -401,16 +401,16 @@  discard block
 block discarded – undo
401 401
 	 */
402 402
 	public function wp_enqueue_scripts() {
403 403
 		// get some style
404
-		if ( apply_filters( 'FHEE_enable_default_espresso_css', TRUE ) && apply_filters( 'FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', TRUE )) {
404
+		if (apply_filters('FHEE_enable_default_espresso_css', TRUE) && apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', TRUE)) {
405 405
 			// first check uploads folder
406
-			if ( is_readable( get_stylesheet_directory() . $this->theme . DS . 'style.css' )) {
407
-				wp_register_style( $this->theme, get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', array( 'dashicons', 'espresso_default' ));
406
+			if (is_readable(get_stylesheet_directory().$this->theme.DS.'style.css')) {
407
+				wp_register_style($this->theme, get_stylesheet_directory_uri().$this->theme.DS.'style.css', array('dashicons', 'espresso_default'));
408 408
 			} else {
409
-				wp_register_style( $this->theme, EE_TEMPLATES_URL . $this->theme . DS . 'style.css', array( 'dashicons', 'espresso_default' ));
409
+				wp_register_style($this->theme, EE_TEMPLATES_URL.$this->theme.DS.'style.css', array('dashicons', 'espresso_default'));
410 410
 			}
411
-			wp_enqueue_script( $this->theme );
412
-			if ( EE_Registry::instance()->CFG->map_settings->use_google_maps ) {
413
-				add_action('wp_enqueue_scripts', array( 'EEH_Maps', 'espresso_google_map_js' ), 11 );
411
+			wp_enqueue_script($this->theme);
412
+			if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
413
+				add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
414 414
 			}
415 415
 		}
416 416
 	}
@@ -431,9 +431,9 @@  discard block
 block discarded – undo
431 431
 	public static function display_venue() {
432 432
 		/** @type EE_Event_Single_Config $config */
433 433
 		$config = EED_Event_Single::instance()->config();
434
-		$display_venue= isset( $config->display_venue ) ? $config->display_venue : TRUE;
434
+		$display_venue = isset($config->display_venue) ? $config->display_venue : TRUE;
435 435
 		$venue_name = EEH_Venue_View::venue_name();
436
-		return $display_venue && ! empty( $venue_name ) ? TRUE : FALSE;
436
+		return $display_venue && ! empty($venue_name) ? TRUE : FALSE;
437 437
 	}
438 438
 
439 439
 
Please login to merge, or discard this patch.
core/helpers/EEH_Activation.helper.php 1 patch
Indentation   +1653 added lines, -1653 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,244 +14,244 @@  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
-                'AHEE_EE_Cron_Tasks__clean_out_old_gateway_logs'       => 'daily',
188
-            )
189
-        );
190
-        if ($which_to_include === 'old') {
191
-            $cron_tasks = array_filter(
192
-                $cron_tasks,
193
-                function ($value) {
194
-                    return $value === EEH_Activation::cron_task_no_longer_in_use;
195
-                }
196
-            );
197
-        } elseif ($which_to_include === 'current') {
198
-            $cron_tasks = array_filter($cron_tasks);
199
-        } elseif (WP_DEBUG && $which_to_include !== 'all') {
200
-            throw new EE_Error(
201
-                sprintf(
202
-                    __(
203
-                        'Invalid argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".',
204
-                        'event_espresso'
205
-                    ),
206
-                    $which_to_include
207
-                )
208
-            );
209
-        }
210
-        return $cron_tasks;
211
-    }
212
-
213
-
214
-    /**
215
-     * Ensure cron tasks are setup (the removal of crons should be done by remove_crons())
216
-     *
217
-     * @throws \EE_Error
218
-     */
219
-    public static function create_cron_tasks()
220
-    {
221
-
222
-        foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) {
223
-            if (! wp_next_scheduled($hook_name)) {
224
-                /**
225
-                 * This allows client code to define the initial start timestamp for this schedule.
226
-                 */
227
-                if (is_array($frequency)
228
-                    && count($frequency) === 2
229
-                    && isset($frequency[0], $frequency[1])
230
-                ) {
231
-                    $start_timestamp = $frequency[0];
232
-                    $frequency = $frequency[1];
233
-                } else {
234
-                    $start_timestamp = time();
235
-                }
236
-                wp_schedule_event($start_timestamp, $frequency, $hook_name);
237
-            }
238
-        }
239
-
240
-    }
241
-
242
-
243
-    /**
244
-     * Remove the currently-existing and now-removed cron tasks.
245
-     *
246
-     * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones
247
-     * @throws \EE_Error
248
-     */
249
-    public static function remove_cron_tasks($remove_all = true)
250
-    {
251
-        $cron_tasks_to_remove = $remove_all ? 'all' : 'old';
252
-        $crons                = _get_cron_array();
253
-        $crons                = is_array($crons) ? $crons : array();
254
-        /* 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
+				'AHEE_EE_Cron_Tasks__clean_out_old_gateway_logs'       => 'daily',
188
+			)
189
+		);
190
+		if ($which_to_include === 'old') {
191
+			$cron_tasks = array_filter(
192
+				$cron_tasks,
193
+				function ($value) {
194
+					return $value === EEH_Activation::cron_task_no_longer_in_use;
195
+				}
196
+			);
197
+		} elseif ($which_to_include === 'current') {
198
+			$cron_tasks = array_filter($cron_tasks);
199
+		} elseif (WP_DEBUG && $which_to_include !== 'all') {
200
+			throw new EE_Error(
201
+				sprintf(
202
+					__(
203
+						'Invalid argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".',
204
+						'event_espresso'
205
+					),
206
+					$which_to_include
207
+				)
208
+			);
209
+		}
210
+		return $cron_tasks;
211
+	}
212
+
213
+
214
+	/**
215
+	 * Ensure cron tasks are setup (the removal of crons should be done by remove_crons())
216
+	 *
217
+	 * @throws \EE_Error
218
+	 */
219
+	public static function create_cron_tasks()
220
+	{
221
+
222
+		foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) {
223
+			if (! wp_next_scheduled($hook_name)) {
224
+				/**
225
+				 * This allows client code to define the initial start timestamp for this schedule.
226
+				 */
227
+				if (is_array($frequency)
228
+					&& count($frequency) === 2
229
+					&& isset($frequency[0], $frequency[1])
230
+				) {
231
+					$start_timestamp = $frequency[0];
232
+					$frequency = $frequency[1];
233
+				} else {
234
+					$start_timestamp = time();
235
+				}
236
+				wp_schedule_event($start_timestamp, $frequency, $hook_name);
237
+			}
238
+		}
239
+
240
+	}
241
+
242
+
243
+	/**
244
+	 * Remove the currently-existing and now-removed cron tasks.
245
+	 *
246
+	 * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones
247
+	 * @throws \EE_Error
248
+	 */
249
+	public static function remove_cron_tasks($remove_all = true)
250
+	{
251
+		$cron_tasks_to_remove = $remove_all ? 'all' : 'old';
252
+		$crons                = _get_cron_array();
253
+		$crons                = is_array($crons) ? $crons : array();
254
+		/* reminder of what $crons look like:
255 255
          * Top-level keys are timestamps, and their values are arrays.
256 256
          * The 2nd level arrays have keys with each of the cron task hook names to run at that time
257 257
          * and their values are arrays.
@@ -268,912 +268,912 @@  discard block
 block discarded – undo
268 268
          *					...
269 269
          *      ...
270 270
          */
271
-        $ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks($cron_tasks_to_remove);
272
-        foreach ($crons as $timestamp => $hooks_to_fire_at_time) {
273
-            if (is_array($hooks_to_fire_at_time)) {
274
-                foreach ($hooks_to_fire_at_time as $hook_name => $hook_actions) {
275
-                    if (isset($ee_cron_tasks_to_remove[$hook_name])
276
-                        && is_array($ee_cron_tasks_to_remove[$hook_name])
277
-                    ) {
278
-                        unset($crons[$timestamp][$hook_name]);
279
-                    }
280
-                }
281
-                //also take care of any empty cron timestamps.
282
-                if (empty($hooks_to_fire_at_time)) {
283
-                    unset($crons[$timestamp]);
284
-                }
285
-            }
286
-        }
287
-        _set_cron_array($crons);
288
-    }
289
-
290
-
291
-    /**
292
-     *    CPT_initialization
293
-     *    registers all EE CPTs ( Custom Post Types ) then flushes rewrite rules so that all endpoints exist
294
-     *
295
-     * @access public
296
-     * @static
297
-     * @return void
298
-     */
299
-    public static function CPT_initialization()
300
-    {
301
-        // register Custom Post Types
302
-        EE_Registry::instance()->load_core('Register_CPTs');
303
-        flush_rewrite_rules();
304
-    }
305
-
306
-
307
-
308
-    /**
309
-     *    reset_and_update_config
310
-     * The following code was moved over from EE_Config so that it will no longer run on every request.
311
-     * If there is old calendar config data saved, then it will get converted on activation.
312
-     * This was basically a DMS before we had DMS's, and will get removed after a few more versions.
313
-     *
314
-     * @access public
315
-     * @static
316
-     * @return void
317
-     */
318
-    public static function reset_and_update_config()
319
-    {
320
-        do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config'));
321
-        add_filter(
322
-            'FHEE__EE_Config___load_core_config__config_settings',
323
-            array('EEH_Activation', 'migrate_old_config_data'),
324
-            10,
325
-            3
326
-        );
327
-        //EE_Config::reset();
328
-        if (! EE_Config::logging_enabled()) {
329
-            delete_option(EE_Config::LOG_NAME);
330
-        }
331
-    }
332
-
333
-
334
-    /**
335
-     *    load_calendar_config
336
-     *
337
-     * @access    public
338
-     * @return    void
339
-     */
340
-    public static function load_calendar_config()
341
-    {
342
-        // grab array of all plugin folders and loop thru it
343
-        $plugins = glob(WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR);
344
-        if (empty($plugins)) {
345
-            return;
346
-        }
347
-        foreach ($plugins as $plugin_path) {
348
-            // grab plugin folder name from path
349
-            $plugin = basename($plugin_path);
350
-            // drill down to Espresso plugins
351
-            // then to calendar related plugins
352
-            if (
353
-                strpos($plugin, 'espresso') !== false
354
-                || strpos($plugin, 'Espresso') !== false
355
-                || strpos($plugin, 'ee4') !== false
356
-                || strpos($plugin, 'EE4') !== false
357
-                || strpos($plugin, 'calendar') !== false
358
-            ) {
359
-                // this is what we are looking for
360
-                $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php';
361
-                // does it exist in this folder ?
362
-                if (is_readable($calendar_config)) {
363
-                    // YEAH! let's load it
364
-                    require_once($calendar_config);
365
-                }
366
-            }
367
-        }
368
-    }
369
-
370
-
371
-
372
-    /**
373
-     *    _migrate_old_config_data
374
-     *
375
-     * @access    public
376
-     * @param array|stdClass $settings
377
-     * @param string         $config
378
-     * @param \EE_Config     $EE_Config
379
-     * @return \stdClass
380
-     */
381
-    public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config)
382
-    {
383
-        $convert_from_array = array('addons');
384
-        // in case old settings were saved as an array
385
-        if (is_array($settings) && in_array($config, $convert_from_array)) {
386
-            // convert existing settings to an object
387
-            $config_array = $settings;
388
-            $settings = new stdClass();
389
-            foreach ($config_array as $key => $value) {
390
-                if ($key === 'calendar' && class_exists('EE_Calendar_Config')) {
391
-                    $EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value);
392
-                } else {
393
-                    $settings->{$key} = $value;
394
-                }
395
-            }
396
-            add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true');
397
-        }
398
-        return $settings;
399
-    }
400
-
401
-
402
-    /**
403
-     * deactivate_event_espresso
404
-     *
405
-     * @access public
406
-     * @static
407
-     * @return void
408
-     */
409
-    public static function deactivate_event_espresso()
410
-    {
411
-        // check permissions
412
-        if (current_user_can('activate_plugins')) {
413
-            deactivate_plugins(EE_PLUGIN_BASENAME, true);
414
-        }
415
-    }
416
-
417
-
418
-
419
-
420
-
421
-    /**
422
-     * verify_default_pages_exist
423
-     *
424
-     * @access public
425
-     * @static
426
-     * @return void
427
-     */
428
-    public static function verify_default_pages_exist()
429
-    {
430
-        $critical_page_problem = false;
431
-        $critical_pages = array(
432
-            array(
433
-                'id'   => 'reg_page_id',
434
-                'name' => __('Registration Checkout', 'event_espresso'),
435
-                'post' => null,
436
-                'code' => 'ESPRESSO_CHECKOUT',
437
-            ),
438
-            array(
439
-                'id'   => 'txn_page_id',
440
-                'name' => __('Transactions', 'event_espresso'),
441
-                'post' => null,
442
-                'code' => 'ESPRESSO_TXN_PAGE',
443
-            ),
444
-            array(
445
-                'id'   => 'thank_you_page_id',
446
-                'name' => __('Thank You', 'event_espresso'),
447
-                'post' => null,
448
-                'code' => 'ESPRESSO_THANK_YOU',
449
-            ),
450
-            array(
451
-                'id'   => 'cancel_page_id',
452
-                'name' => __('Registration Cancelled', 'event_espresso'),
453
-                'post' => null,
454
-                'code' => 'ESPRESSO_CANCELLED',
455
-            ),
456
-        );
457
-        $EE_Core_Config = EE_Registry::instance()->CFG->core;
458
-        foreach ($critical_pages as $critical_page) {
459
-            // is critical page ID set in config ?
460
-            if ($EE_Core_Config->{$critical_page['id']} !== false) {
461
-                // attempt to find post by ID
462
-                $critical_page['post'] = get_post($EE_Core_Config->{$critical_page['id']});
463
-            }
464
-            // no dice?
465
-            if ($critical_page['post'] === null) {
466
-                // attempt to find post by title
467
-                $critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']);
468
-                // still nothing?
469
-                if ($critical_page['post'] === null) {
470
-                    $critical_page = EEH_Activation::create_critical_page($critical_page);
471
-                    // REALLY? Still nothing ??!?!?
472
-                    if ($critical_page['post'] === null) {
473
-                        $msg = __(
474
-                            'The Event Espresso critical page configuration settings could not be updated.',
475
-                            'event_espresso'
476
-                        );
477
-                        EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
478
-                        break;
479
-                    }
480
-                }
481
-            }
482
-            // check that Post ID matches critical page ID in config
483
-            if (
484
-                isset($critical_page['post']->ID)
485
-                && $critical_page['post']->ID !== $EE_Core_Config->{$critical_page['id']}
486
-            ) {
487
-                //update Config with post ID
488
-                $EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID;
489
-                if (! EE_Config::instance()->update_espresso_config(false, false)) {
490
-                    $msg = __(
491
-                        'The Event Espresso critical page configuration settings could not be updated.',
492
-                        'event_espresso'
493
-                    );
494
-                    EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
495
-                }
496
-            }
497
-            $critical_page_problem =
498
-                ! isset($critical_page['post']->post_status)
499
-                || $critical_page['post']->post_status !== 'publish'
500
-                || strpos($critical_page['post']->post_content, $critical_page['code']) === false
501
-                    ? true
502
-                    : $critical_page_problem;
503
-        }
504
-        if ($critical_page_problem) {
505
-            $msg = sprintf(
506
-                __(
507
-                    'A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.',
508
-                    'event_espresso'
509
-                ),
510
-                '<a href="'
511
-                . admin_url('admin.php?page=espresso_general_settings&action=critical_pages')
512
-                . '">'
513
-                . __('Event Espresso Critical Pages Settings', 'event_espresso')
514
-                . '</a>'
515
-            );
516
-            EE_Error::add_persistent_admin_notice('critical_page_problem', $msg);
517
-        }
518
-        if (EE_Error::has_notices()) {
519
-            EE_Error::get_notices(false, true, true);
520
-        }
521
-    }
522
-
523
-
524
-
525
-    /**
526
-     * Returns the first post which uses the specified shortcode
527
-     *
528
-     * @param string $ee_shortcode usually one of the critical pages shortcodes, eg
529
-     *                             ESPRESSO_THANK_YOU. So we will search fora post with the content
530
-     *                             "[ESPRESSO_THANK_YOU"
531
-     *                             (we don't search for the closing shortcode bracket because they might have added
532
-     *                             parameter to the shortcode
533
-     * @return WP_Post or NULl
534
-     */
535
-    public static function get_page_by_ee_shortcode($ee_shortcode)
536
-    {
537
-        global $wpdb;
538
-        $shortcode_and_opening_bracket = '[' . $ee_shortcode;
539
-        $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1");
540
-        if ($post_id) {
541
-            return get_post($post_id);
542
-        } else {
543
-            return null;
544
-        }
545
-    }
546
-
547
-
548
-    /**
549
-     *    This function generates a post for critical espresso pages
550
-     *
551
-     * @access public
552
-     * @static
553
-     * @param array $critical_page
554
-     * @return array
555
-     */
556
-    public static function create_critical_page($critical_page)
557
-    {
558
-
559
-        $post_args = array(
560
-            'post_title'     => $critical_page['name'],
561
-            'post_status'    => 'publish',
562
-            'post_type'      => 'page',
563
-            'comment_status' => 'closed',
564
-            'post_content'   => '[' . $critical_page['code'] . ']',
565
-        );
566
-
567
-        $post_id = wp_insert_post($post_args);
568
-        if (! $post_id) {
569
-            $msg = sprintf(
570
-                __('The Event Espresso  critical page entitled "%s" could not be created.', 'event_espresso'),
571
-                $critical_page['name']
572
-            );
573
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
574
-            return $critical_page;
575
-        }
576
-        // get newly created post's details
577
-        if (! $critical_page['post'] = get_post($post_id)) {
578
-            $msg = sprintf(
579
-                __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'),
580
-                $critical_page['name']
581
-            );
582
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
583
-        }
584
-
585
-        return $critical_page;
586
-
587
-    }
588
-
589
-
590
-
591
-
592
-    /**
593
-     * Tries to find the oldest admin for this site.  If there are no admins for this site then return NULL.
594
-     * The role being used to check is filterable.
595
-     *
596
-     * @since  4.6.0
597
-     * @global WPDB $wpdb
598
-     * @return mixed null|int WP_user ID or NULL
599
-     */
600
-    public static function get_default_creator_id()
601
-    {
602
-        global $wpdb;
603
-        if ( ! empty(self::$_default_creator_id)) {
604
-            return self::$_default_creator_id;
605
-        }/**/
606
-        $role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator');
607
-        //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.
608
-        $pre_filtered_id = apply_filters(
609
-            'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id',
610
-            false,
611
-            $role_to_check
612
-        );
613
-        if ($pre_filtered_id !== false) {
614
-            return (int)$pre_filtered_id;
615
-        }
616
-        $capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('capabilities');
617
-        $query = $wpdb->prepare(
618
-            "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1",
619
-            '%' . $role_to_check . '%'
620
-        );
621
-        $user_id = $wpdb->get_var($query);
622
-        $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id);
623
-        if ($user_id && (int)$user_id) {
624
-            self::$_default_creator_id = (int)$user_id;
625
-            return self::$_default_creator_id;
626
-        } else {
627
-            return null;
628
-        }
629
-    }
630
-
631
-
632
-
633
-    /**
634
-     * used by EE and EE addons during plugin activation to create tables.
635
-     * Its a wrapper for EventEspresso\core\services\database\TableManager::createTable,
636
-     * but includes extra logic regarding activations.
637
-     *
638
-     * @access public
639
-     * @static
640
-     * @param string  $table_name              without the $wpdb->prefix
641
-     * @param string  $sql                     SQL for creating the table (contents between brackets in an SQL create
642
-     *                                         table query)
643
-     * @param string  $engine                  like 'ENGINE=MyISAM' or 'ENGINE=InnoDB'
644
-     * @param boolean $drop_pre_existing_table set to TRUE when you want to make SURE the table is completely empty
645
-     *                                         and new once this function is done (ie, you really do want to CREATE a
646
-     *                                         table, and expect it to be empty once you're done) leave as FALSE when
647
-     *                                         you just want to verify the table exists and matches this definition
648
-     *                                         (and if it HAS data in it you want to leave it be)
649
-     * @return void
650
-     * @throws EE_Error if there are database errors
651
-     */
652
-    public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false)
653
-    {
654
-        if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', false, $table_name, $sql)) {
655
-            return;
656
-        }
657
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
658
-        if ( ! function_exists('dbDelta')) {
659
-            require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
660
-        }
661
-        $tableAnalysis = \EEH_Activation::getTableAnalysis();
662
-        $wp_table_name = $tableAnalysis->ensureTableNameHasPrefix($table_name);
663
-        // do we need to first delete an existing version of this table ?
664
-        if ($drop_pre_existing_table && $tableAnalysis->tableExists($wp_table_name)) {
665
-            // ok, delete the table... but ONLY if it's empty
666
-            $deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name);
667
-            // table is NOT empty, are you SURE you want to delete this table ???
668
-            if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) {
669
-                \EEH_Activation::getTableManager()->dropTable($wp_table_name);
670
-            } else if ( ! $deleted_safely) {
671
-                // so we should be more cautious rather than just dropping tables so easily
672
-                error_log(
673
-                    sprintf(
674
-                        __(
675
-                            '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.',
676
-                            'event_espresso'
677
-                        ),
678
-                        $wp_table_name,
679
-                        '<br/>',
680
-                        'espresso_db_update'
681
-                    )
682
-                );
683
-            }
684
-        }
685
-        $engine = str_replace('ENGINE=', '', $engine);
686
-        \EEH_Activation::getTableManager()->createTable($table_name, $sql, $engine);
687
-    }
688
-
689
-
690
-
691
-    /**
692
-     *    add_column_if_it_doesn't_exist
693
-     *    Checks if this column already exists on the specified table. Handy for addons which want to add a column
694
-     *
695
-     * @access     public
696
-     * @static
697
-     * @deprecated instead use TableManager::addColumn()
698
-     * @param string $table_name  (without "wp_", eg "esp_attendee"
699
-     * @param string $column_name
700
-     * @param string $column_info if your SQL were 'ALTER TABLE table_name ADD price VARCHAR(10)', this would be
701
-     *                            'VARCHAR(10)'
702
-     * @return bool|int
703
-     */
704
-    public static function add_column_if_it_doesnt_exist(
705
-        $table_name,
706
-        $column_name,
707
-        $column_info = 'INT UNSIGNED NOT NULL'
708
-    ) {
709
-        return \EEH_Activation::getTableManager()->addColumn($table_name, $column_name, $column_info);
710
-    }
711
-
712
-
713
-    /**
714
-     * get_fields_on_table
715
-     * Gets all the fields on the database table.
716
-     *
717
-     * @access     public
718
-     * @deprecated instead use TableManager::getTableColumns()
719
-     * @static
720
-     * @param string $table_name , without prefixed $wpdb->prefix
721
-     * @return array of database column names
722
-     */
723
-    public static function get_fields_on_table($table_name = null)
724
-    {
725
-        return \EEH_Activation::getTableManager()->getTableColumns($table_name);
726
-    }
727
-
728
-
729
-    /**
730
-     * db_table_is_empty
731
-     *
732
-     * @access     public\
733
-     * @deprecated instead use TableAnalysis::tableIsEmpty()
734
-     * @static
735
-     * @param string $table_name
736
-     * @return bool
737
-     */
738
-    public static function db_table_is_empty($table_name)
739
-    {
740
-        return \EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name);
741
-    }
742
-
743
-
744
-    /**
745
-     * delete_db_table_if_empty
746
-     *
747
-     * @access public
748
-     * @static
749
-     * @param string $table_name
750
-     * @return bool | int
751
-     */
752
-    public static function delete_db_table_if_empty($table_name)
753
-    {
754
-        if (\EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name)) {
755
-            return \EEH_Activation::getTableManager()->dropTable($table_name);
756
-        }
757
-        return false;
758
-    }
759
-
760
-
761
-    /**
762
-     * delete_unused_db_table
763
-     *
764
-     * @access     public
765
-     * @static
766
-     * @deprecated instead use TableManager::dropTable()
767
-     * @param string $table_name
768
-     * @return bool | int
769
-     */
770
-    public static function delete_unused_db_table($table_name)
771
-    {
772
-        return \EEH_Activation::getTableManager()->dropTable($table_name);
773
-    }
774
-
775
-
776
-    /**
777
-     * drop_index
778
-     *
779
-     * @access     public
780
-     * @static
781
-     * @deprecated instead use TableManager::dropIndex()
782
-     * @param string $table_name
783
-     * @param string $index_name
784
-     * @return bool | int
785
-     */
786
-    public static function drop_index($table_name, $index_name)
787
-    {
788
-        return \EEH_Activation::getTableManager()->dropIndex($table_name, $index_name);
789
-    }
790
-
791
-
792
-
793
-    /**
794
-     * create_database_tables
795
-     *
796
-     * @access public
797
-     * @static
798
-     * @throws EE_Error
799
-     * @return boolean success (whether database is setup properly or not)
800
-     */
801
-    public static function create_database_tables()
802
-    {
803
-        EE_Registry::instance()->load_core('Data_Migration_Manager');
804
-        //find the migration script that sets the database to be compatible with the code
805
-        $dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms();
806
-        if ($dms_name) {
807
-            $current_data_migration_script = EE_Registry::instance()->load_dms($dms_name);
808
-            $current_data_migration_script->set_migrating(false);
809
-            $current_data_migration_script->schema_changes_before_migration();
810
-            $current_data_migration_script->schema_changes_after_migration();
811
-            if ($current_data_migration_script->get_errors()) {
812
-                if (WP_DEBUG) {
813
-                    foreach ($current_data_migration_script->get_errors() as $error) {
814
-                        EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
815
-                    }
816
-                } else {
817
-                    EE_Error::add_error(
818
-                        __(
819
-                            'There were errors creating the Event Espresso database tables and Event Espresso has been 
271
+		$ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks($cron_tasks_to_remove);
272
+		foreach ($crons as $timestamp => $hooks_to_fire_at_time) {
273
+			if (is_array($hooks_to_fire_at_time)) {
274
+				foreach ($hooks_to_fire_at_time as $hook_name => $hook_actions) {
275
+					if (isset($ee_cron_tasks_to_remove[$hook_name])
276
+						&& is_array($ee_cron_tasks_to_remove[$hook_name])
277
+					) {
278
+						unset($crons[$timestamp][$hook_name]);
279
+					}
280
+				}
281
+				//also take care of any empty cron timestamps.
282
+				if (empty($hooks_to_fire_at_time)) {
283
+					unset($crons[$timestamp]);
284
+				}
285
+			}
286
+		}
287
+		_set_cron_array($crons);
288
+	}
289
+
290
+
291
+	/**
292
+	 *    CPT_initialization
293
+	 *    registers all EE CPTs ( Custom Post Types ) then flushes rewrite rules so that all endpoints exist
294
+	 *
295
+	 * @access public
296
+	 * @static
297
+	 * @return void
298
+	 */
299
+	public static function CPT_initialization()
300
+	{
301
+		// register Custom Post Types
302
+		EE_Registry::instance()->load_core('Register_CPTs');
303
+		flush_rewrite_rules();
304
+	}
305
+
306
+
307
+
308
+	/**
309
+	 *    reset_and_update_config
310
+	 * The following code was moved over from EE_Config so that it will no longer run on every request.
311
+	 * If there is old calendar config data saved, then it will get converted on activation.
312
+	 * This was basically a DMS before we had DMS's, and will get removed after a few more versions.
313
+	 *
314
+	 * @access public
315
+	 * @static
316
+	 * @return void
317
+	 */
318
+	public static function reset_and_update_config()
319
+	{
320
+		do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config'));
321
+		add_filter(
322
+			'FHEE__EE_Config___load_core_config__config_settings',
323
+			array('EEH_Activation', 'migrate_old_config_data'),
324
+			10,
325
+			3
326
+		);
327
+		//EE_Config::reset();
328
+		if (! EE_Config::logging_enabled()) {
329
+			delete_option(EE_Config::LOG_NAME);
330
+		}
331
+	}
332
+
333
+
334
+	/**
335
+	 *    load_calendar_config
336
+	 *
337
+	 * @access    public
338
+	 * @return    void
339
+	 */
340
+	public static function load_calendar_config()
341
+	{
342
+		// grab array of all plugin folders and loop thru it
343
+		$plugins = glob(WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR);
344
+		if (empty($plugins)) {
345
+			return;
346
+		}
347
+		foreach ($plugins as $plugin_path) {
348
+			// grab plugin folder name from path
349
+			$plugin = basename($plugin_path);
350
+			// drill down to Espresso plugins
351
+			// then to calendar related plugins
352
+			if (
353
+				strpos($plugin, 'espresso') !== false
354
+				|| strpos($plugin, 'Espresso') !== false
355
+				|| strpos($plugin, 'ee4') !== false
356
+				|| strpos($plugin, 'EE4') !== false
357
+				|| strpos($plugin, 'calendar') !== false
358
+			) {
359
+				// this is what we are looking for
360
+				$calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php';
361
+				// does it exist in this folder ?
362
+				if (is_readable($calendar_config)) {
363
+					// YEAH! let's load it
364
+					require_once($calendar_config);
365
+				}
366
+			}
367
+		}
368
+	}
369
+
370
+
371
+
372
+	/**
373
+	 *    _migrate_old_config_data
374
+	 *
375
+	 * @access    public
376
+	 * @param array|stdClass $settings
377
+	 * @param string         $config
378
+	 * @param \EE_Config     $EE_Config
379
+	 * @return \stdClass
380
+	 */
381
+	public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config)
382
+	{
383
+		$convert_from_array = array('addons');
384
+		// in case old settings were saved as an array
385
+		if (is_array($settings) && in_array($config, $convert_from_array)) {
386
+			// convert existing settings to an object
387
+			$config_array = $settings;
388
+			$settings = new stdClass();
389
+			foreach ($config_array as $key => $value) {
390
+				if ($key === 'calendar' && class_exists('EE_Calendar_Config')) {
391
+					$EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value);
392
+				} else {
393
+					$settings->{$key} = $value;
394
+				}
395
+			}
396
+			add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true');
397
+		}
398
+		return $settings;
399
+	}
400
+
401
+
402
+	/**
403
+	 * deactivate_event_espresso
404
+	 *
405
+	 * @access public
406
+	 * @static
407
+	 * @return void
408
+	 */
409
+	public static function deactivate_event_espresso()
410
+	{
411
+		// check permissions
412
+		if (current_user_can('activate_plugins')) {
413
+			deactivate_plugins(EE_PLUGIN_BASENAME, true);
414
+		}
415
+	}
416
+
417
+
418
+
419
+
420
+
421
+	/**
422
+	 * verify_default_pages_exist
423
+	 *
424
+	 * @access public
425
+	 * @static
426
+	 * @return void
427
+	 */
428
+	public static function verify_default_pages_exist()
429
+	{
430
+		$critical_page_problem = false;
431
+		$critical_pages = array(
432
+			array(
433
+				'id'   => 'reg_page_id',
434
+				'name' => __('Registration Checkout', 'event_espresso'),
435
+				'post' => null,
436
+				'code' => 'ESPRESSO_CHECKOUT',
437
+			),
438
+			array(
439
+				'id'   => 'txn_page_id',
440
+				'name' => __('Transactions', 'event_espresso'),
441
+				'post' => null,
442
+				'code' => 'ESPRESSO_TXN_PAGE',
443
+			),
444
+			array(
445
+				'id'   => 'thank_you_page_id',
446
+				'name' => __('Thank You', 'event_espresso'),
447
+				'post' => null,
448
+				'code' => 'ESPRESSO_THANK_YOU',
449
+			),
450
+			array(
451
+				'id'   => 'cancel_page_id',
452
+				'name' => __('Registration Cancelled', 'event_espresso'),
453
+				'post' => null,
454
+				'code' => 'ESPRESSO_CANCELLED',
455
+			),
456
+		);
457
+		$EE_Core_Config = EE_Registry::instance()->CFG->core;
458
+		foreach ($critical_pages as $critical_page) {
459
+			// is critical page ID set in config ?
460
+			if ($EE_Core_Config->{$critical_page['id']} !== false) {
461
+				// attempt to find post by ID
462
+				$critical_page['post'] = get_post($EE_Core_Config->{$critical_page['id']});
463
+			}
464
+			// no dice?
465
+			if ($critical_page['post'] === null) {
466
+				// attempt to find post by title
467
+				$critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']);
468
+				// still nothing?
469
+				if ($critical_page['post'] === null) {
470
+					$critical_page = EEH_Activation::create_critical_page($critical_page);
471
+					// REALLY? Still nothing ??!?!?
472
+					if ($critical_page['post'] === null) {
473
+						$msg = __(
474
+							'The Event Espresso critical page configuration settings could not be updated.',
475
+							'event_espresso'
476
+						);
477
+						EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
478
+						break;
479
+					}
480
+				}
481
+			}
482
+			// check that Post ID matches critical page ID in config
483
+			if (
484
+				isset($critical_page['post']->ID)
485
+				&& $critical_page['post']->ID !== $EE_Core_Config->{$critical_page['id']}
486
+			) {
487
+				//update Config with post ID
488
+				$EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID;
489
+				if (! EE_Config::instance()->update_espresso_config(false, false)) {
490
+					$msg = __(
491
+						'The Event Espresso critical page configuration settings could not be updated.',
492
+						'event_espresso'
493
+					);
494
+					EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
495
+				}
496
+			}
497
+			$critical_page_problem =
498
+				! isset($critical_page['post']->post_status)
499
+				|| $critical_page['post']->post_status !== 'publish'
500
+				|| strpos($critical_page['post']->post_content, $critical_page['code']) === false
501
+					? true
502
+					: $critical_page_problem;
503
+		}
504
+		if ($critical_page_problem) {
505
+			$msg = sprintf(
506
+				__(
507
+					'A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.',
508
+					'event_espresso'
509
+				),
510
+				'<a href="'
511
+				. admin_url('admin.php?page=espresso_general_settings&action=critical_pages')
512
+				. '">'
513
+				. __('Event Espresso Critical Pages Settings', 'event_espresso')
514
+				. '</a>'
515
+			);
516
+			EE_Error::add_persistent_admin_notice('critical_page_problem', $msg);
517
+		}
518
+		if (EE_Error::has_notices()) {
519
+			EE_Error::get_notices(false, true, true);
520
+		}
521
+	}
522
+
523
+
524
+
525
+	/**
526
+	 * Returns the first post which uses the specified shortcode
527
+	 *
528
+	 * @param string $ee_shortcode usually one of the critical pages shortcodes, eg
529
+	 *                             ESPRESSO_THANK_YOU. So we will search fora post with the content
530
+	 *                             "[ESPRESSO_THANK_YOU"
531
+	 *                             (we don't search for the closing shortcode bracket because they might have added
532
+	 *                             parameter to the shortcode
533
+	 * @return WP_Post or NULl
534
+	 */
535
+	public static function get_page_by_ee_shortcode($ee_shortcode)
536
+	{
537
+		global $wpdb;
538
+		$shortcode_and_opening_bracket = '[' . $ee_shortcode;
539
+		$post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1");
540
+		if ($post_id) {
541
+			return get_post($post_id);
542
+		} else {
543
+			return null;
544
+		}
545
+	}
546
+
547
+
548
+	/**
549
+	 *    This function generates a post for critical espresso pages
550
+	 *
551
+	 * @access public
552
+	 * @static
553
+	 * @param array $critical_page
554
+	 * @return array
555
+	 */
556
+	public static function create_critical_page($critical_page)
557
+	{
558
+
559
+		$post_args = array(
560
+			'post_title'     => $critical_page['name'],
561
+			'post_status'    => 'publish',
562
+			'post_type'      => 'page',
563
+			'comment_status' => 'closed',
564
+			'post_content'   => '[' . $critical_page['code'] . ']',
565
+		);
566
+
567
+		$post_id = wp_insert_post($post_args);
568
+		if (! $post_id) {
569
+			$msg = sprintf(
570
+				__('The Event Espresso  critical page entitled "%s" could not be created.', 'event_espresso'),
571
+				$critical_page['name']
572
+			);
573
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
574
+			return $critical_page;
575
+		}
576
+		// get newly created post's details
577
+		if (! $critical_page['post'] = get_post($post_id)) {
578
+			$msg = sprintf(
579
+				__('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'),
580
+				$critical_page['name']
581
+			);
582
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
583
+		}
584
+
585
+		return $critical_page;
586
+
587
+	}
588
+
589
+
590
+
591
+
592
+	/**
593
+	 * Tries to find the oldest admin for this site.  If there are no admins for this site then return NULL.
594
+	 * The role being used to check is filterable.
595
+	 *
596
+	 * @since  4.6.0
597
+	 * @global WPDB $wpdb
598
+	 * @return mixed null|int WP_user ID or NULL
599
+	 */
600
+	public static function get_default_creator_id()
601
+	{
602
+		global $wpdb;
603
+		if ( ! empty(self::$_default_creator_id)) {
604
+			return self::$_default_creator_id;
605
+		}/**/
606
+		$role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator');
607
+		//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.
608
+		$pre_filtered_id = apply_filters(
609
+			'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id',
610
+			false,
611
+			$role_to_check
612
+		);
613
+		if ($pre_filtered_id !== false) {
614
+			return (int)$pre_filtered_id;
615
+		}
616
+		$capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('capabilities');
617
+		$query = $wpdb->prepare(
618
+			"SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1",
619
+			'%' . $role_to_check . '%'
620
+		);
621
+		$user_id = $wpdb->get_var($query);
622
+		$user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id);
623
+		if ($user_id && (int)$user_id) {
624
+			self::$_default_creator_id = (int)$user_id;
625
+			return self::$_default_creator_id;
626
+		} else {
627
+			return null;
628
+		}
629
+	}
630
+
631
+
632
+
633
+	/**
634
+	 * used by EE and EE addons during plugin activation to create tables.
635
+	 * Its a wrapper for EventEspresso\core\services\database\TableManager::createTable,
636
+	 * but includes extra logic regarding activations.
637
+	 *
638
+	 * @access public
639
+	 * @static
640
+	 * @param string  $table_name              without the $wpdb->prefix
641
+	 * @param string  $sql                     SQL for creating the table (contents between brackets in an SQL create
642
+	 *                                         table query)
643
+	 * @param string  $engine                  like 'ENGINE=MyISAM' or 'ENGINE=InnoDB'
644
+	 * @param boolean $drop_pre_existing_table set to TRUE when you want to make SURE the table is completely empty
645
+	 *                                         and new once this function is done (ie, you really do want to CREATE a
646
+	 *                                         table, and expect it to be empty once you're done) leave as FALSE when
647
+	 *                                         you just want to verify the table exists and matches this definition
648
+	 *                                         (and if it HAS data in it you want to leave it be)
649
+	 * @return void
650
+	 * @throws EE_Error if there are database errors
651
+	 */
652
+	public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false)
653
+	{
654
+		if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', false, $table_name, $sql)) {
655
+			return;
656
+		}
657
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
658
+		if ( ! function_exists('dbDelta')) {
659
+			require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
660
+		}
661
+		$tableAnalysis = \EEH_Activation::getTableAnalysis();
662
+		$wp_table_name = $tableAnalysis->ensureTableNameHasPrefix($table_name);
663
+		// do we need to first delete an existing version of this table ?
664
+		if ($drop_pre_existing_table && $tableAnalysis->tableExists($wp_table_name)) {
665
+			// ok, delete the table... but ONLY if it's empty
666
+			$deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name);
667
+			// table is NOT empty, are you SURE you want to delete this table ???
668
+			if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) {
669
+				\EEH_Activation::getTableManager()->dropTable($wp_table_name);
670
+			} else if ( ! $deleted_safely) {
671
+				// so we should be more cautious rather than just dropping tables so easily
672
+				error_log(
673
+					sprintf(
674
+						__(
675
+							'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.',
676
+							'event_espresso'
677
+						),
678
+						$wp_table_name,
679
+						'<br/>',
680
+						'espresso_db_update'
681
+					)
682
+				);
683
+			}
684
+		}
685
+		$engine = str_replace('ENGINE=', '', $engine);
686
+		\EEH_Activation::getTableManager()->createTable($table_name, $sql, $engine);
687
+	}
688
+
689
+
690
+
691
+	/**
692
+	 *    add_column_if_it_doesn't_exist
693
+	 *    Checks if this column already exists on the specified table. Handy for addons which want to add a column
694
+	 *
695
+	 * @access     public
696
+	 * @static
697
+	 * @deprecated instead use TableManager::addColumn()
698
+	 * @param string $table_name  (without "wp_", eg "esp_attendee"
699
+	 * @param string $column_name
700
+	 * @param string $column_info if your SQL were 'ALTER TABLE table_name ADD price VARCHAR(10)', this would be
701
+	 *                            'VARCHAR(10)'
702
+	 * @return bool|int
703
+	 */
704
+	public static function add_column_if_it_doesnt_exist(
705
+		$table_name,
706
+		$column_name,
707
+		$column_info = 'INT UNSIGNED NOT NULL'
708
+	) {
709
+		return \EEH_Activation::getTableManager()->addColumn($table_name, $column_name, $column_info);
710
+	}
711
+
712
+
713
+	/**
714
+	 * get_fields_on_table
715
+	 * Gets all the fields on the database table.
716
+	 *
717
+	 * @access     public
718
+	 * @deprecated instead use TableManager::getTableColumns()
719
+	 * @static
720
+	 * @param string $table_name , without prefixed $wpdb->prefix
721
+	 * @return array of database column names
722
+	 */
723
+	public static function get_fields_on_table($table_name = null)
724
+	{
725
+		return \EEH_Activation::getTableManager()->getTableColumns($table_name);
726
+	}
727
+
728
+
729
+	/**
730
+	 * db_table_is_empty
731
+	 *
732
+	 * @access     public\
733
+	 * @deprecated instead use TableAnalysis::tableIsEmpty()
734
+	 * @static
735
+	 * @param string $table_name
736
+	 * @return bool
737
+	 */
738
+	public static function db_table_is_empty($table_name)
739
+	{
740
+		return \EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name);
741
+	}
742
+
743
+
744
+	/**
745
+	 * delete_db_table_if_empty
746
+	 *
747
+	 * @access public
748
+	 * @static
749
+	 * @param string $table_name
750
+	 * @return bool | int
751
+	 */
752
+	public static function delete_db_table_if_empty($table_name)
753
+	{
754
+		if (\EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name)) {
755
+			return \EEH_Activation::getTableManager()->dropTable($table_name);
756
+		}
757
+		return false;
758
+	}
759
+
760
+
761
+	/**
762
+	 * delete_unused_db_table
763
+	 *
764
+	 * @access     public
765
+	 * @static
766
+	 * @deprecated instead use TableManager::dropTable()
767
+	 * @param string $table_name
768
+	 * @return bool | int
769
+	 */
770
+	public static function delete_unused_db_table($table_name)
771
+	{
772
+		return \EEH_Activation::getTableManager()->dropTable($table_name);
773
+	}
774
+
775
+
776
+	/**
777
+	 * drop_index
778
+	 *
779
+	 * @access     public
780
+	 * @static
781
+	 * @deprecated instead use TableManager::dropIndex()
782
+	 * @param string $table_name
783
+	 * @param string $index_name
784
+	 * @return bool | int
785
+	 */
786
+	public static function drop_index($table_name, $index_name)
787
+	{
788
+		return \EEH_Activation::getTableManager()->dropIndex($table_name, $index_name);
789
+	}
790
+
791
+
792
+
793
+	/**
794
+	 * create_database_tables
795
+	 *
796
+	 * @access public
797
+	 * @static
798
+	 * @throws EE_Error
799
+	 * @return boolean success (whether database is setup properly or not)
800
+	 */
801
+	public static function create_database_tables()
802
+	{
803
+		EE_Registry::instance()->load_core('Data_Migration_Manager');
804
+		//find the migration script that sets the database to be compatible with the code
805
+		$dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms();
806
+		if ($dms_name) {
807
+			$current_data_migration_script = EE_Registry::instance()->load_dms($dms_name);
808
+			$current_data_migration_script->set_migrating(false);
809
+			$current_data_migration_script->schema_changes_before_migration();
810
+			$current_data_migration_script->schema_changes_after_migration();
811
+			if ($current_data_migration_script->get_errors()) {
812
+				if (WP_DEBUG) {
813
+					foreach ($current_data_migration_script->get_errors() as $error) {
814
+						EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
815
+					}
816
+				} else {
817
+					EE_Error::add_error(
818
+						__(
819
+							'There were errors creating the Event Espresso database tables and Event Espresso has been 
820 820
                             deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.',
821
-                            'event_espresso'
822
-                        )
823
-                    );
824
-                }
825
-                return false;
826
-            }
827
-            EE_Data_Migration_Manager::instance()->update_current_database_state_to();
828
-        } else {
829
-            EE_Error::add_error(
830
-                __(
831
-                    'Could not determine most up-to-date data migration script from which to pull database schema
821
+							'event_espresso'
822
+						)
823
+					);
824
+				}
825
+				return false;
826
+			}
827
+			EE_Data_Migration_Manager::instance()->update_current_database_state_to();
828
+		} else {
829
+			EE_Error::add_error(
830
+				__(
831
+					'Could not determine most up-to-date data migration script from which to pull database schema
832 832
                      structure. So database is probably not setup properly',
833
-                    'event_espresso'
834
-                ),
835
-                __FILE__,
836
-                __FUNCTION__,
837
-                __LINE__
838
-            );
839
-            return false;
840
-        }
841
-        return true;
842
-    }
843
-
844
-
845
-
846
-    /**
847
-     * initialize_system_questions
848
-     *
849
-     * @access public
850
-     * @static
851
-     * @return void
852
-     */
853
-    public static function initialize_system_questions()
854
-    {
855
-        // QUESTION GROUPS
856
-        global $wpdb;
857
-        $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group');
858
-        $SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0";
859
-        // what we have
860
-        $question_groups = $wpdb->get_col($SQL);
861
-        // check the response
862
-        $question_groups = is_array($question_groups) ? $question_groups : array();
863
-        // what we should have
864
-        $QSG_systems = array(1, 2);
865
-        // loop thru what we should have and compare to what we have
866
-        foreach ($QSG_systems as $QSG_system) {
867
-            // reset values array
868
-            $QSG_values = array();
869
-            // 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)
870
-            if (! in_array("$QSG_system", $question_groups)) {
871
-                // add it
872
-                switch ($QSG_system) {
873
-                    case 1:
874
-                        $QSG_values = array(
875
-                            'QSG_name'            => __('Personal Information', 'event_espresso'),
876
-                            'QSG_identifier'      => 'personal-information-' . time(),
877
-                            'QSG_desc'            => '',
878
-                            'QSG_order'           => 1,
879
-                            'QSG_show_group_name' => 1,
880
-                            'QSG_show_group_desc' => 1,
881
-                            'QSG_system'          => EEM_Question_Group::system_personal,
882
-                            'QSG_deleted'         => 0,
883
-                        );
884
-                        break;
885
-                    case 2:
886
-                        $QSG_values = array(
887
-                            'QSG_name'            => __('Address Information', 'event_espresso'),
888
-                            'QSG_identifier'      => 'address-information-' . time(),
889
-                            'QSG_desc'            => '',
890
-                            'QSG_order'           => 2,
891
-                            'QSG_show_group_name' => 1,
892
-                            'QSG_show_group_desc' => 1,
893
-                            'QSG_system'          => EEM_Question_Group::system_address,
894
-                            'QSG_deleted'         => 0,
895
-                        );
896
-                        break;
897
-                }
898
-                // make sure we have some values before inserting them
899
-                if (! empty($QSG_values)) {
900
-                    // insert system question
901
-                    $wpdb->insert(
902
-                        $table_name,
903
-                        $QSG_values,
904
-                        array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d')
905
-                    );
906
-                    $QSG_IDs[$QSG_system] = $wpdb->insert_id;
907
-                }
908
-            }
909
-        }
910
-        // QUESTIONS
911
-        global $wpdb;
912
-        $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question');
913
-        $SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''";
914
-        // what we have
915
-        $questions = $wpdb->get_col($SQL);
916
-        // what we should have
917
-        $QST_systems = array(
918
-            'fname',
919
-            'lname',
920
-            'email',
921
-            'address',
922
-            'address2',
923
-            'city',
924
-            'country',
925
-            'state',
926
-            'zip',
927
-            'phone',
928
-        );
929
-        $order_for_group_1 = 1;
930
-        $order_for_group_2 = 1;
931
-        // loop thru what we should have and compare to what we have
932
-        foreach ($QST_systems as $QST_system) {
933
-            // reset values array
934
-            $QST_values = array();
935
-            // if we don't have what we should have
936
-            if (! in_array($QST_system, $questions)) {
937
-                // add it
938
-                switch ($QST_system) {
939
-                    case 'fname':
940
-                        $QST_values = array(
941
-                            'QST_display_text'  => __('First Name', 'event_espresso'),
942
-                            'QST_admin_label'   => __('First Name - System Question', 'event_espresso'),
943
-                            'QST_system'        => 'fname',
944
-                            'QST_type'          => 'TEXT',
945
-                            'QST_required'      => 1,
946
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
947
-                            'QST_order'         => 1,
948
-                            'QST_admin_only'    => 0,
949
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
950
-                            'QST_wp_user'       => self::get_default_creator_id(),
951
-                            'QST_deleted'       => 0,
952
-                        );
953
-                        break;
954
-                    case 'lname':
955
-                        $QST_values = array(
956
-                            'QST_display_text'  => __('Last Name', 'event_espresso'),
957
-                            'QST_admin_label'   => __('Last Name - System Question', 'event_espresso'),
958
-                            'QST_system'        => 'lname',
959
-                            'QST_type'          => 'TEXT',
960
-                            'QST_required'      => 1,
961
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
962
-                            'QST_order'         => 2,
963
-                            'QST_admin_only'    => 0,
964
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
965
-                            'QST_wp_user'       => self::get_default_creator_id(),
966
-                            'QST_deleted'       => 0,
967
-                        );
968
-                        break;
969
-                    case 'email':
970
-                        $QST_values = array(
971
-                            'QST_display_text'  => __('Email Address', 'event_espresso'),
972
-                            'QST_admin_label'   => __('Email Address - System Question', 'event_espresso'),
973
-                            'QST_system'        => 'email',
974
-                            'QST_type'          => 'EMAIL',
975
-                            'QST_required'      => 1,
976
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
977
-                            'QST_order'         => 3,
978
-                            'QST_admin_only'    => 0,
979
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
980
-                            'QST_wp_user'       => self::get_default_creator_id(),
981
-                            'QST_deleted'       => 0,
982
-                        );
983
-                        break;
984
-                    case 'address':
985
-                        $QST_values = array(
986
-                            'QST_display_text'  => __('Address', 'event_espresso'),
987
-                            'QST_admin_label'   => __('Address - System Question', 'event_espresso'),
988
-                            'QST_system'        => 'address',
989
-                            'QST_type'          => 'TEXT',
990
-                            'QST_required'      => 0,
991
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
992
-                            'QST_order'         => 4,
993
-                            'QST_admin_only'    => 0,
994
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
995
-                            'QST_wp_user'       => self::get_default_creator_id(),
996
-                            'QST_deleted'       => 0,
997
-                        );
998
-                        break;
999
-                    case 'address2':
1000
-                        $QST_values = array(
1001
-                            'QST_display_text'  => __('Address2', 'event_espresso'),
1002
-                            'QST_admin_label'   => __('Address2 - System Question', 'event_espresso'),
1003
-                            'QST_system'        => 'address2',
1004
-                            'QST_type'          => 'TEXT',
1005
-                            'QST_required'      => 0,
1006
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1007
-                            'QST_order'         => 5,
1008
-                            'QST_admin_only'    => 0,
1009
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1010
-                            'QST_wp_user'       => self::get_default_creator_id(),
1011
-                            'QST_deleted'       => 0,
1012
-                        );
1013
-                        break;
1014
-                    case 'city':
1015
-                        $QST_values = array(
1016
-                            'QST_display_text'  => __('City', 'event_espresso'),
1017
-                            'QST_admin_label'   => __('City - System Question', 'event_espresso'),
1018
-                            'QST_system'        => 'city',
1019
-                            'QST_type'          => 'TEXT',
1020
-                            'QST_required'      => 0,
1021
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1022
-                            'QST_order'         => 6,
1023
-                            'QST_admin_only'    => 0,
1024
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1025
-                            'QST_wp_user'       => self::get_default_creator_id(),
1026
-                            'QST_deleted'       => 0,
1027
-                        );
1028
-                        break;
1029
-                    case 'country':
1030
-                        $QST_values = array(
1031
-                            'QST_display_text'  => __('Country', 'event_espresso'),
1032
-                            'QST_admin_label'   => __('Country - System Question', 'event_espresso'),
1033
-                            'QST_system'        => 'country',
1034
-                            'QST_type'          => 'COUNTRY',
1035
-                            'QST_required'      => 0,
1036
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1037
-                            'QST_order'         => 7,
1038
-                            'QST_admin_only'    => 0,
1039
-                            'QST_wp_user'       => self::get_default_creator_id(),
1040
-                            'QST_deleted'       => 0,
1041
-                        );
1042
-                        break;
1043
-                    case 'state':
1044
-                        $QST_values = array(
1045
-                            'QST_display_text'  => __('State/Province', 'event_espresso'),
1046
-                            'QST_admin_label'   => __('State/Province - System Question', 'event_espresso'),
1047
-                            'QST_system'        => 'state',
1048
-                            'QST_type'          => 'STATE',
1049
-                            'QST_required'      => 0,
1050
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1051
-                            'QST_order'         => 8,
1052
-                            'QST_admin_only'    => 0,
1053
-                            'QST_wp_user'       => self::get_default_creator_id(),
1054
-                            'QST_deleted'       => 0,
1055
-                        );
1056
-                        break;
1057
-                    case 'zip':
1058
-                        $QST_values = array(
1059
-                            'QST_display_text'  => __('Zip/Postal Code', 'event_espresso'),
1060
-                            'QST_admin_label'   => __('Zip/Postal Code - System Question', 'event_espresso'),
1061
-                            'QST_system'        => 'zip',
1062
-                            'QST_type'          => 'TEXT',
1063
-                            'QST_required'      => 0,
1064
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1065
-                            'QST_order'         => 9,
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 'phone':
1073
-                        $QST_values = array(
1074
-                            'QST_display_text'  => __('Phone Number', 'event_espresso'),
1075
-                            'QST_admin_label'   => __('Phone Number - System Question', 'event_espresso'),
1076
-                            'QST_system'        => 'phone',
1077
-                            'QST_type'          => 'TEXT',
1078
-                            'QST_required'      => 0,
1079
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1080
-                            'QST_order'         => 10,
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
-                }
1088
-                if (! empty($QST_values)) {
1089
-                    // insert system question
1090
-                    $wpdb->insert(
1091
-                        $table_name,
1092
-                        $QST_values,
1093
-                        array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d')
1094
-                    );
1095
-                    $QST_ID = $wpdb->insert_id;
1096
-                    // QUESTION GROUP QUESTIONS
1097
-                    if (in_array($QST_system, array('fname', 'lname', 'email'))) {
1098
-                        $system_question_we_want = EEM_Question_Group::system_personal;
1099
-                    } else {
1100
-                        $system_question_we_want = EEM_Question_Group::system_address;
1101
-                    }
1102
-                    if (isset($QSG_IDs[$system_question_we_want])) {
1103
-                        $QSG_ID = $QSG_IDs[$system_question_we_want];
1104
-                    } else {
1105
-                        $id_col = EEM_Question_Group::instance()
1106
-                                                    ->get_col(array(array('QSG_system' => $system_question_we_want)));
1107
-                        if (is_array($id_col)) {
1108
-                            $QSG_ID = reset($id_col);
1109
-                        } else {
1110
-                            //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
1111
-                            EE_Log::instance()->log(
1112
-                                __FILE__,
1113
-                                __FUNCTION__,
1114
-                                sprintf(
1115
-                                    __(
1116
-                                        'Could not associate question %1$s to a question group because no system question
833
+					'event_espresso'
834
+				),
835
+				__FILE__,
836
+				__FUNCTION__,
837
+				__LINE__
838
+			);
839
+			return false;
840
+		}
841
+		return true;
842
+	}
843
+
844
+
845
+
846
+	/**
847
+	 * initialize_system_questions
848
+	 *
849
+	 * @access public
850
+	 * @static
851
+	 * @return void
852
+	 */
853
+	public static function initialize_system_questions()
854
+	{
855
+		// QUESTION GROUPS
856
+		global $wpdb;
857
+		$table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group');
858
+		$SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0";
859
+		// what we have
860
+		$question_groups = $wpdb->get_col($SQL);
861
+		// check the response
862
+		$question_groups = is_array($question_groups) ? $question_groups : array();
863
+		// what we should have
864
+		$QSG_systems = array(1, 2);
865
+		// loop thru what we should have and compare to what we have
866
+		foreach ($QSG_systems as $QSG_system) {
867
+			// reset values array
868
+			$QSG_values = array();
869
+			// 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)
870
+			if (! in_array("$QSG_system", $question_groups)) {
871
+				// add it
872
+				switch ($QSG_system) {
873
+					case 1:
874
+						$QSG_values = array(
875
+							'QSG_name'            => __('Personal Information', 'event_espresso'),
876
+							'QSG_identifier'      => 'personal-information-' . time(),
877
+							'QSG_desc'            => '',
878
+							'QSG_order'           => 1,
879
+							'QSG_show_group_name' => 1,
880
+							'QSG_show_group_desc' => 1,
881
+							'QSG_system'          => EEM_Question_Group::system_personal,
882
+							'QSG_deleted'         => 0,
883
+						);
884
+						break;
885
+					case 2:
886
+						$QSG_values = array(
887
+							'QSG_name'            => __('Address Information', 'event_espresso'),
888
+							'QSG_identifier'      => 'address-information-' . time(),
889
+							'QSG_desc'            => '',
890
+							'QSG_order'           => 2,
891
+							'QSG_show_group_name' => 1,
892
+							'QSG_show_group_desc' => 1,
893
+							'QSG_system'          => EEM_Question_Group::system_address,
894
+							'QSG_deleted'         => 0,
895
+						);
896
+						break;
897
+				}
898
+				// make sure we have some values before inserting them
899
+				if (! empty($QSG_values)) {
900
+					// insert system question
901
+					$wpdb->insert(
902
+						$table_name,
903
+						$QSG_values,
904
+						array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d')
905
+					);
906
+					$QSG_IDs[$QSG_system] = $wpdb->insert_id;
907
+				}
908
+			}
909
+		}
910
+		// QUESTIONS
911
+		global $wpdb;
912
+		$table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question');
913
+		$SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''";
914
+		// what we have
915
+		$questions = $wpdb->get_col($SQL);
916
+		// what we should have
917
+		$QST_systems = array(
918
+			'fname',
919
+			'lname',
920
+			'email',
921
+			'address',
922
+			'address2',
923
+			'city',
924
+			'country',
925
+			'state',
926
+			'zip',
927
+			'phone',
928
+		);
929
+		$order_for_group_1 = 1;
930
+		$order_for_group_2 = 1;
931
+		// loop thru what we should have and compare to what we have
932
+		foreach ($QST_systems as $QST_system) {
933
+			// reset values array
934
+			$QST_values = array();
935
+			// if we don't have what we should have
936
+			if (! in_array($QST_system, $questions)) {
937
+				// add it
938
+				switch ($QST_system) {
939
+					case 'fname':
940
+						$QST_values = array(
941
+							'QST_display_text'  => __('First Name', 'event_espresso'),
942
+							'QST_admin_label'   => __('First Name - System Question', 'event_espresso'),
943
+							'QST_system'        => 'fname',
944
+							'QST_type'          => 'TEXT',
945
+							'QST_required'      => 1,
946
+							'QST_required_text' => __('This field is required', 'event_espresso'),
947
+							'QST_order'         => 1,
948
+							'QST_admin_only'    => 0,
949
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
950
+							'QST_wp_user'       => self::get_default_creator_id(),
951
+							'QST_deleted'       => 0,
952
+						);
953
+						break;
954
+					case 'lname':
955
+						$QST_values = array(
956
+							'QST_display_text'  => __('Last Name', 'event_espresso'),
957
+							'QST_admin_label'   => __('Last Name - System Question', 'event_espresso'),
958
+							'QST_system'        => 'lname',
959
+							'QST_type'          => 'TEXT',
960
+							'QST_required'      => 1,
961
+							'QST_required_text' => __('This field is required', 'event_espresso'),
962
+							'QST_order'         => 2,
963
+							'QST_admin_only'    => 0,
964
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
965
+							'QST_wp_user'       => self::get_default_creator_id(),
966
+							'QST_deleted'       => 0,
967
+						);
968
+						break;
969
+					case 'email':
970
+						$QST_values = array(
971
+							'QST_display_text'  => __('Email Address', 'event_espresso'),
972
+							'QST_admin_label'   => __('Email Address - System Question', 'event_espresso'),
973
+							'QST_system'        => 'email',
974
+							'QST_type'          => 'EMAIL',
975
+							'QST_required'      => 1,
976
+							'QST_required_text' => __('This field is required', 'event_espresso'),
977
+							'QST_order'         => 3,
978
+							'QST_admin_only'    => 0,
979
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
980
+							'QST_wp_user'       => self::get_default_creator_id(),
981
+							'QST_deleted'       => 0,
982
+						);
983
+						break;
984
+					case 'address':
985
+						$QST_values = array(
986
+							'QST_display_text'  => __('Address', 'event_espresso'),
987
+							'QST_admin_label'   => __('Address - System Question', 'event_espresso'),
988
+							'QST_system'        => 'address',
989
+							'QST_type'          => 'TEXT',
990
+							'QST_required'      => 0,
991
+							'QST_required_text' => __('This field is required', 'event_espresso'),
992
+							'QST_order'         => 4,
993
+							'QST_admin_only'    => 0,
994
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
995
+							'QST_wp_user'       => self::get_default_creator_id(),
996
+							'QST_deleted'       => 0,
997
+						);
998
+						break;
999
+					case 'address2':
1000
+						$QST_values = array(
1001
+							'QST_display_text'  => __('Address2', 'event_espresso'),
1002
+							'QST_admin_label'   => __('Address2 - System Question', 'event_espresso'),
1003
+							'QST_system'        => 'address2',
1004
+							'QST_type'          => 'TEXT',
1005
+							'QST_required'      => 0,
1006
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1007
+							'QST_order'         => 5,
1008
+							'QST_admin_only'    => 0,
1009
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1010
+							'QST_wp_user'       => self::get_default_creator_id(),
1011
+							'QST_deleted'       => 0,
1012
+						);
1013
+						break;
1014
+					case 'city':
1015
+						$QST_values = array(
1016
+							'QST_display_text'  => __('City', 'event_espresso'),
1017
+							'QST_admin_label'   => __('City - System Question', 'event_espresso'),
1018
+							'QST_system'        => 'city',
1019
+							'QST_type'          => 'TEXT',
1020
+							'QST_required'      => 0,
1021
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1022
+							'QST_order'         => 6,
1023
+							'QST_admin_only'    => 0,
1024
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1025
+							'QST_wp_user'       => self::get_default_creator_id(),
1026
+							'QST_deleted'       => 0,
1027
+						);
1028
+						break;
1029
+					case 'country':
1030
+						$QST_values = array(
1031
+							'QST_display_text'  => __('Country', 'event_espresso'),
1032
+							'QST_admin_label'   => __('Country - System Question', 'event_espresso'),
1033
+							'QST_system'        => 'country',
1034
+							'QST_type'          => 'COUNTRY',
1035
+							'QST_required'      => 0,
1036
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1037
+							'QST_order'         => 7,
1038
+							'QST_admin_only'    => 0,
1039
+							'QST_wp_user'       => self::get_default_creator_id(),
1040
+							'QST_deleted'       => 0,
1041
+						);
1042
+						break;
1043
+					case 'state':
1044
+						$QST_values = array(
1045
+							'QST_display_text'  => __('State/Province', 'event_espresso'),
1046
+							'QST_admin_label'   => __('State/Province - System Question', 'event_espresso'),
1047
+							'QST_system'        => 'state',
1048
+							'QST_type'          => 'STATE',
1049
+							'QST_required'      => 0,
1050
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1051
+							'QST_order'         => 8,
1052
+							'QST_admin_only'    => 0,
1053
+							'QST_wp_user'       => self::get_default_creator_id(),
1054
+							'QST_deleted'       => 0,
1055
+						);
1056
+						break;
1057
+					case 'zip':
1058
+						$QST_values = array(
1059
+							'QST_display_text'  => __('Zip/Postal Code', 'event_espresso'),
1060
+							'QST_admin_label'   => __('Zip/Postal Code - System Question', 'event_espresso'),
1061
+							'QST_system'        => 'zip',
1062
+							'QST_type'          => 'TEXT',
1063
+							'QST_required'      => 0,
1064
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1065
+							'QST_order'         => 9,
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 'phone':
1073
+						$QST_values = array(
1074
+							'QST_display_text'  => __('Phone Number', 'event_espresso'),
1075
+							'QST_admin_label'   => __('Phone Number - System Question', 'event_espresso'),
1076
+							'QST_system'        => 'phone',
1077
+							'QST_type'          => 'TEXT',
1078
+							'QST_required'      => 0,
1079
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1080
+							'QST_order'         => 10,
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
+				}
1088
+				if (! empty($QST_values)) {
1089
+					// insert system question
1090
+					$wpdb->insert(
1091
+						$table_name,
1092
+						$QST_values,
1093
+						array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d')
1094
+					);
1095
+					$QST_ID = $wpdb->insert_id;
1096
+					// QUESTION GROUP QUESTIONS
1097
+					if (in_array($QST_system, array('fname', 'lname', 'email'))) {
1098
+						$system_question_we_want = EEM_Question_Group::system_personal;
1099
+					} else {
1100
+						$system_question_we_want = EEM_Question_Group::system_address;
1101
+					}
1102
+					if (isset($QSG_IDs[$system_question_we_want])) {
1103
+						$QSG_ID = $QSG_IDs[$system_question_we_want];
1104
+					} else {
1105
+						$id_col = EEM_Question_Group::instance()
1106
+													->get_col(array(array('QSG_system' => $system_question_we_want)));
1107
+						if (is_array($id_col)) {
1108
+							$QSG_ID = reset($id_col);
1109
+						} else {
1110
+							//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
1111
+							EE_Log::instance()->log(
1112
+								__FILE__,
1113
+								__FUNCTION__,
1114
+								sprintf(
1115
+									__(
1116
+										'Could not associate question %1$s to a question group because no system question
1117 1117
                                          group existed',
1118
-                                        'event_espresso'
1119
-                                    ),
1120
-                                    $QST_ID),
1121
-                                'error');
1122
-                            continue;
1123
-                        }
1124
-                    }
1125
-                    // add system questions to groups
1126
-                    $wpdb->insert(
1127
-                        \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group_question'),
1128
-                        array(
1129
-                            'QSG_ID'    => $QSG_ID,
1130
-                            'QST_ID'    => $QST_ID,
1131
-                            'QGQ_order' => ($QSG_ID === 1) ? $order_for_group_1++ : $order_for_group_2++,
1132
-                        ),
1133
-                        array('%d', '%d', '%d')
1134
-                    );
1135
-                }
1136
-            }
1137
-        }
1138
-    }
1139
-
1140
-
1141
-    /**
1142
-     * Makes sure the default payment method (Invoice) is active.
1143
-     * This used to be done automatically as part of constructing the old gateways config
1144
-     *
1145
-     * @throws \EE_Error
1146
-     */
1147
-    public static function insert_default_payment_methods()
1148
-    {
1149
-        if (! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) {
1150
-            EE_Registry::instance()->load_lib('Payment_Method_Manager');
1151
-            EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
1152
-        } else {
1153
-            EEM_Payment_Method::instance()->verify_button_urls();
1154
-        }
1155
-    }
1156
-
1157
-    /**
1158
-     * insert_default_status_codes
1159
-     *
1160
-     * @access public
1161
-     * @static
1162
-     * @return void
1163
-     */
1164
-    public static function insert_default_status_codes()
1165
-    {
1166
-
1167
-        global $wpdb;
1168
-
1169
-        if (\EEH_Activation::getTableAnalysis()->tableExists(EEM_Status::instance()->table())) {
1170
-
1171
-            $table_name = EEM_Status::instance()->table();
1172
-
1173
-            $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' );";
1174
-            $wpdb->query($SQL);
1175
-
1176
-            $SQL = "INSERT INTO $table_name
1118
+										'event_espresso'
1119
+									),
1120
+									$QST_ID),
1121
+								'error');
1122
+							continue;
1123
+						}
1124
+					}
1125
+					// add system questions to groups
1126
+					$wpdb->insert(
1127
+						\EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group_question'),
1128
+						array(
1129
+							'QSG_ID'    => $QSG_ID,
1130
+							'QST_ID'    => $QST_ID,
1131
+							'QGQ_order' => ($QSG_ID === 1) ? $order_for_group_1++ : $order_for_group_2++,
1132
+						),
1133
+						array('%d', '%d', '%d')
1134
+					);
1135
+				}
1136
+			}
1137
+		}
1138
+	}
1139
+
1140
+
1141
+	/**
1142
+	 * Makes sure the default payment method (Invoice) is active.
1143
+	 * This used to be done automatically as part of constructing the old gateways config
1144
+	 *
1145
+	 * @throws \EE_Error
1146
+	 */
1147
+	public static function insert_default_payment_methods()
1148
+	{
1149
+		if (! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) {
1150
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
1151
+			EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
1152
+		} else {
1153
+			EEM_Payment_Method::instance()->verify_button_urls();
1154
+		}
1155
+	}
1156
+
1157
+	/**
1158
+	 * insert_default_status_codes
1159
+	 *
1160
+	 * @access public
1161
+	 * @static
1162
+	 * @return void
1163
+	 */
1164
+	public static function insert_default_status_codes()
1165
+	{
1166
+
1167
+		global $wpdb;
1168
+
1169
+		if (\EEH_Activation::getTableAnalysis()->tableExists(EEM_Status::instance()->table())) {
1170
+
1171
+			$table_name = EEM_Status::instance()->table();
1172
+
1173
+			$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' );";
1174
+			$wpdb->query($SQL);
1175
+
1176
+			$SQL = "INSERT INTO $table_name
1177 1177
 					(STS_ID, STS_code, STS_type, STS_can_edit, STS_desc, STS_open) VALUES
1178 1178
 					('ACT', 'ACTIVE', 'event', 0, NULL, 1),
1179 1179
 					('NAC', 'NOT_ACTIVE', 'event', 0, NULL, 0),
@@ -1213,521 +1213,521 @@  discard block
 block discarded – undo
1213 1213
 					('MID', 'IDLE', 'message', 0, NULL, 1),
1214 1214
 					('MRS', 'RESEND', 'message', 0, NULL, 1),
1215 1215
 					('MIC', 'INCOMPLETE', 'message', 0, NULL, 0);";
1216
-            $wpdb->query($SQL);
1217
-
1218
-        }
1219
-
1220
-    }
1221
-
1222
-
1223
-    /**
1224
-     * create_upload_directories
1225
-     * Creates folders in the uploads directory to facilitate addons and templates
1226
-     *
1227
-     * @access public
1228
-     * @static
1229
-     * @return boolean success of verifying upload directories exist
1230
-     */
1231
-    public static function create_upload_directories()
1232
-    {
1233
-        // Create the required folders
1234
-        $folders = array(
1235
-            EVENT_ESPRESSO_TEMPLATE_DIR,
1236
-            EVENT_ESPRESSO_GATEWAY_DIR,
1237
-            EVENT_ESPRESSO_UPLOAD_DIR . 'logs/',
1238
-            EVENT_ESPRESSO_UPLOAD_DIR . 'css/',
1239
-            EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/',
1240
-        );
1241
-        foreach ($folders as $folder) {
1242
-            try {
1243
-                EEH_File::ensure_folder_exists_and_is_writable($folder);
1244
-                @ chmod($folder, 0755);
1245
-            } catch (EE_Error $e) {
1246
-                EE_Error::add_error(
1247
-                    sprintf(
1248
-                        __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'),
1249
-                        $folder,
1250
-                        '<br />' . $e->getMessage()
1251
-                    ),
1252
-                    __FILE__, __FUNCTION__, __LINE__
1253
-                );
1254
-                //indicate we'll need to fix this later
1255
-                update_option(EEH_Activation::upload_directories_incomplete_option_name, true);
1256
-                return false;
1257
-            }
1258
-        }
1259
-        //just add the .htaccess file to the logs directory to begin with. Even if logging
1260
-        //is disabled, there might be activation errors recorded in there
1261
-        EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs/');
1262
-        //remember EE's folders are all good
1263
-        delete_option(EEH_Activation::upload_directories_incomplete_option_name);
1264
-        return true;
1265
-    }
1266
-
1267
-    /**
1268
-     * Whether the upload directories need to be fixed or not.
1269
-     * If EE is installed but filesystem access isn't initially available,
1270
-     * we need to get the user's filesystem credentials and THEN create them,
1271
-     * so there might be period of time when EE is installed but its
1272
-     * upload directories aren't available. This indicates such a state
1273
-     *
1274
-     * @return boolean
1275
-     */
1276
-    public static function upload_directories_incomplete()
1277
-    {
1278
-        return get_option(EEH_Activation::upload_directories_incomplete_option_name, false);
1279
-    }
1280
-
1281
-
1282
-    /**
1283
-     * generate_default_message_templates
1284
-     *
1285
-     * @static
1286
-     * @throws EE_Error
1287
-     * @return bool     true means new templates were created.
1288
-     *                  false means no templates were created.
1289
-     *                  This is NOT an error flag. To check for errors you will want
1290
-     *                  to use either EE_Error or a try catch for an EE_Error exception.
1291
-     */
1292
-    public static function generate_default_message_templates()
1293
-    {
1294
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
1295
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
1296
-        /*
1216
+			$wpdb->query($SQL);
1217
+
1218
+		}
1219
+
1220
+	}
1221
+
1222
+
1223
+	/**
1224
+	 * create_upload_directories
1225
+	 * Creates folders in the uploads directory to facilitate addons and templates
1226
+	 *
1227
+	 * @access public
1228
+	 * @static
1229
+	 * @return boolean success of verifying upload directories exist
1230
+	 */
1231
+	public static function create_upload_directories()
1232
+	{
1233
+		// Create the required folders
1234
+		$folders = array(
1235
+			EVENT_ESPRESSO_TEMPLATE_DIR,
1236
+			EVENT_ESPRESSO_GATEWAY_DIR,
1237
+			EVENT_ESPRESSO_UPLOAD_DIR . 'logs/',
1238
+			EVENT_ESPRESSO_UPLOAD_DIR . 'css/',
1239
+			EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/',
1240
+		);
1241
+		foreach ($folders as $folder) {
1242
+			try {
1243
+				EEH_File::ensure_folder_exists_and_is_writable($folder);
1244
+				@ chmod($folder, 0755);
1245
+			} catch (EE_Error $e) {
1246
+				EE_Error::add_error(
1247
+					sprintf(
1248
+						__('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'),
1249
+						$folder,
1250
+						'<br />' . $e->getMessage()
1251
+					),
1252
+					__FILE__, __FUNCTION__, __LINE__
1253
+				);
1254
+				//indicate we'll need to fix this later
1255
+				update_option(EEH_Activation::upload_directories_incomplete_option_name, true);
1256
+				return false;
1257
+			}
1258
+		}
1259
+		//just add the .htaccess file to the logs directory to begin with. Even if logging
1260
+		//is disabled, there might be activation errors recorded in there
1261
+		EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs/');
1262
+		//remember EE's folders are all good
1263
+		delete_option(EEH_Activation::upload_directories_incomplete_option_name);
1264
+		return true;
1265
+	}
1266
+
1267
+	/**
1268
+	 * Whether the upload directories need to be fixed or not.
1269
+	 * If EE is installed but filesystem access isn't initially available,
1270
+	 * we need to get the user's filesystem credentials and THEN create them,
1271
+	 * so there might be period of time when EE is installed but its
1272
+	 * upload directories aren't available. This indicates such a state
1273
+	 *
1274
+	 * @return boolean
1275
+	 */
1276
+	public static function upload_directories_incomplete()
1277
+	{
1278
+		return get_option(EEH_Activation::upload_directories_incomplete_option_name, false);
1279
+	}
1280
+
1281
+
1282
+	/**
1283
+	 * generate_default_message_templates
1284
+	 *
1285
+	 * @static
1286
+	 * @throws EE_Error
1287
+	 * @return bool     true means new templates were created.
1288
+	 *                  false means no templates were created.
1289
+	 *                  This is NOT an error flag. To check for errors you will want
1290
+	 *                  to use either EE_Error or a try catch for an EE_Error exception.
1291
+	 */
1292
+	public static function generate_default_message_templates()
1293
+	{
1294
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
1295
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
1296
+		/*
1297 1297
          * This first method is taking care of ensuring any default messengers
1298 1298
          * that should be made active and have templates generated are done.
1299 1299
          */
1300
-        $new_templates_created_for_messenger = self::_activate_and_generate_default_messengers_and_message_templates(
1301
-            $message_resource_manager
1302
-        );
1303
-        /**
1304
-         * This method is verifying there are no NEW default message types
1305
-         * for ACTIVE messengers that need activated (and corresponding templates setup).
1306
-         */
1307
-        $new_templates_created_for_message_type = self::_activate_new_message_types_for_active_messengers_and_generate_default_templates(
1308
-            $message_resource_manager
1309
-        );
1310
-        //after all is done, let's persist these changes to the db.
1311
-        $message_resource_manager->update_has_activated_messengers_option();
1312
-        $message_resource_manager->update_active_messengers_option();
1313
-        // will return true if either of these are true.  Otherwise will return false.
1314
-        return $new_templates_created_for_message_type || $new_templates_created_for_messenger;
1315
-    }
1316
-
1317
-
1318
-
1319
-    /**
1320
-     * @param \EE_Message_Resource_Manager $message_resource_manager
1321
-     * @return array|bool
1322
-     * @throws \EE_Error
1323
-     */
1324
-    protected static function _activate_new_message_types_for_active_messengers_and_generate_default_templates(
1325
-        EE_Message_Resource_Manager $message_resource_manager
1326
-    ) {
1327
-        /** @type EE_messenger[] $active_messengers */
1328
-        $active_messengers = $message_resource_manager->active_messengers();
1329
-        $installed_message_types = $message_resource_manager->installed_message_types();
1330
-        $templates_created = false;
1331
-        foreach ($active_messengers as $active_messenger) {
1332
-            $default_message_type_names_for_messenger = $active_messenger->get_default_message_types();
1333
-            $default_message_type_names_to_activate = array();
1334
-            // looping through each default message type reported by the messenger
1335
-            // and setup the actual message types to activate.
1336
-            foreach ($default_message_type_names_for_messenger as $default_message_type_name_for_messenger) {
1337
-                // if already active or has already been activated before we skip
1338
-                // (otherwise we might reactivate something user's intentionally deactivated.)
1339
-                // we also skip if the message type is not installed.
1340
-                if (
1341
-                    $message_resource_manager->has_message_type_been_activated_for_messenger(
1342
-                        $default_message_type_name_for_messenger,
1343
-                        $active_messenger->name
1344
-                    )
1345
-                    || $message_resource_manager->is_message_type_active_for_messenger(
1346
-                        $active_messenger->name,
1347
-                        $default_message_type_name_for_messenger
1348
-                    )
1349
-                    || ! isset($installed_message_types[$default_message_type_name_for_messenger])
1350
-                ) {
1351
-                    continue;
1352
-                }
1353
-                $default_message_type_names_to_activate[] = $default_message_type_name_for_messenger;
1354
-            }
1355
-            //let's activate!
1356
-            $message_resource_manager->ensure_message_types_are_active(
1357
-                $default_message_type_names_to_activate,
1358
-                $active_messenger->name,
1359
-                false
1360
-            );
1361
-            //activate the templates for these message types
1362
-            if ( ! empty($default_message_type_names_to_activate)) {
1363
-                $templates_created = EEH_MSG_Template::generate_new_templates(
1364
-                    $active_messenger->name,
1365
-                    $default_message_type_names_for_messenger,
1366
-                    '',
1367
-                    true
1368
-                );
1369
-            }
1370
-        }
1371
-        return $templates_created;
1372
-    }
1373
-
1374
-
1375
-
1376
-    /**
1377
-     * This will activate and generate default messengers and default message types for those messengers.
1378
-     *
1379
-     * @param EE_message_Resource_Manager $message_resource_manager
1380
-     * @return array|bool  True means there were default messengers and message type templates generated.
1381
-     *                     False means that there were no templates generated
1382
-     *                     (which could simply mean there are no default message types for a messenger).
1383
-     * @throws EE_Error
1384
-     */
1385
-    protected static function _activate_and_generate_default_messengers_and_message_templates(
1386
-        EE_Message_Resource_Manager $message_resource_manager
1387
-    ) {
1388
-        /** @type EE_messenger[] $messengers_to_generate */
1389
-        $messengers_to_generate = self::_get_default_messengers_to_generate_on_activation($message_resource_manager);
1390
-        $installed_message_types = $message_resource_manager->installed_message_types();
1391
-        $templates_generated = false;
1392
-        foreach ($messengers_to_generate as $messenger_to_generate) {
1393
-            $default_message_type_names_for_messenger = $messenger_to_generate->get_default_message_types();
1394
-            //verify the default message types match an installed message type.
1395
-            foreach ($default_message_type_names_for_messenger as $key => $name) {
1396
-                if (
1397
-                    ! isset($installed_message_types[$name])
1398
-                    || $message_resource_manager->has_message_type_been_activated_for_messenger(
1399
-                        $name,
1400
-                        $messenger_to_generate->name
1401
-                    )
1402
-                ) {
1403
-                    unset($default_message_type_names_for_messenger[$key]);
1404
-                }
1405
-            }
1406
-            // in previous iterations, the active_messengers option in the db
1407
-            // needed updated before calling create templates. however with the changes this may not be necessary.
1408
-            // This comment is left here just in case we discover that we _do_ need to update before
1409
-            // passing off to create templates (after the refactor is done).
1410
-            // @todo remove this comment when determined not necessary.
1411
-            $message_resource_manager->activate_messenger(
1412
-                $messenger_to_generate->name,
1413
-                $default_message_type_names_for_messenger,
1414
-                false
1415
-            );
1416
-            //create any templates needing created (or will reactivate templates already generated as necessary).
1417
-            if ( ! empty($default_message_type_names_for_messenger)) {
1418
-                $templates_generated = EEH_MSG_Template::generate_new_templates(
1419
-                    $messenger_to_generate->name,
1420
-                    $default_message_type_names_for_messenger,
1421
-                    '',
1422
-                    true
1423
-                );
1424
-            }
1425
-        }
1426
-        return $templates_generated;
1427
-    }
1428
-
1429
-
1430
-    /**
1431
-     * This returns the default messengers to generate templates for on activation of EE.
1432
-     * It considers:
1433
-     * - whether a messenger is already active in the db.
1434
-     * - whether a messenger has been made active at any time in the past.
1435
-     *
1436
-     * @static
1437
-     * @param  EE_Message_Resource_Manager $message_resource_manager
1438
-     * @return EE_messenger[]
1439
-     */
1440
-    protected static function _get_default_messengers_to_generate_on_activation(
1441
-        EE_Message_Resource_Manager $message_resource_manager
1442
-    ) {
1443
-        $active_messengers    = $message_resource_manager->active_messengers();
1444
-        $installed_messengers = $message_resource_manager->installed_messengers();
1445
-        $has_activated        = $message_resource_manager->get_has_activated_messengers_option();
1446
-
1447
-        $messengers_to_generate = array();
1448
-        foreach ($installed_messengers as $installed_messenger) {
1449
-            //if installed messenger is a messenger that should be activated on install
1450
-            //and is not already active
1451
-            //and has never been activated
1452
-            if (
1453
-                ! $installed_messenger->activate_on_install
1454
-                || isset($active_messengers[$installed_messenger->name])
1455
-                || isset($has_activated[$installed_messenger->name])
1456
-            ) {
1457
-                continue;
1458
-            }
1459
-            $messengers_to_generate[$installed_messenger->name] = $installed_messenger;
1460
-        }
1461
-        return $messengers_to_generate;
1462
-    }
1463
-
1464
-
1465
-    /**
1466
-     * This simply validates active message types to ensure they actually match installed
1467
-     * message types.  If there's a mismatch then we deactivate the message type and ensure all related db
1468
-     * rows are set inactive.
1469
-     * Note: Messengers are no longer validated here as of 4.9.0 because they get validated automatically whenever
1470
-     * EE_Messenger_Resource_Manager is constructed.  Message Types are a bit more resource heavy for validation so they
1471
-     * are still handled in here.
1472
-     *
1473
-     * @since 4.3.1
1474
-     * @return void
1475
-     */
1476
-    public static function validate_messages_system()
1477
-    {
1478
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
1479
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
1480
-        $message_resource_manager->validate_active_message_types_are_installed();
1481
-        do_action('AHEE__EEH_Activation__validate_messages_system');
1482
-    }
1483
-
1484
-
1485
-    /**
1486
-     * create_no_ticket_prices_array
1487
-     *
1488
-     * @access public
1489
-     * @static
1490
-     * @return void
1491
-     */
1492
-    public static function create_no_ticket_prices_array()
1493
-    {
1494
-        // this creates an array for tracking events that have no active ticket prices created
1495
-        // this allows us to warn admins of the situation so that it can be corrected
1496
-        $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', false);
1497
-        if (! $espresso_no_ticket_prices) {
1498
-            add_option('ee_no_ticket_prices', array(), '', false);
1499
-        }
1500
-    }
1501
-
1502
-
1503
-    /**
1504
-     * plugin_deactivation
1505
-     *
1506
-     * @access public
1507
-     * @static
1508
-     * @return void
1509
-     */
1510
-    public static function plugin_deactivation()
1511
-    {
1512
-    }
1513
-
1514
-
1515
-    /**
1516
-     * Finds all our EE4 custom post types, and deletes them and their associated data
1517
-     * (like post meta or term relations)
1518
-     *
1519
-     * @global wpdb $wpdb
1520
-     * @throws \EE_Error
1521
-     */
1522
-    public static function delete_all_espresso_cpt_data()
1523
-    {
1524
-        global $wpdb;
1525
-        //get all the CPT post_types
1526
-        $ee_post_types = array();
1527
-        foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1528
-            if (method_exists($model_name, 'instance')) {
1529
-                $model_obj = call_user_func(array($model_name, 'instance'));
1530
-                if ($model_obj instanceof EEM_CPT_Base) {
1531
-                    $ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type());
1532
-                }
1533
-            }
1534
-        }
1535
-        //get all our CPTs
1536
-        $query   = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (" . implode(",", $ee_post_types) . ")";
1537
-        $cpt_ids = $wpdb->get_col($query);
1538
-        //delete each post meta and term relations too
1539
-        foreach ($cpt_ids as $post_id) {
1540
-            wp_delete_post($post_id, true);
1541
-        }
1542
-    }
1543
-
1544
-    /**
1545
-     * Deletes all EE custom tables
1546
-     *
1547
-     * @return array
1548
-     */
1549
-    public static function drop_espresso_tables()
1550
-    {
1551
-        $tables = array();
1552
-        // load registry
1553
-        foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1554
-            if (method_exists($model_name, 'instance')) {
1555
-                $model_obj = call_user_func(array($model_name, 'instance'));
1556
-                if ($model_obj instanceof EEM_Base) {
1557
-                    foreach ($model_obj->get_tables() as $table) {
1558
-                        if (strpos($table->get_table_name(), 'esp_')
1559
-                            &&
1560
-                            (
1561
-                                is_main_site()//main site? nuke them all
1562
-                                || ! $table->is_global()//not main site,but not global either. nuke it
1563
-                            )
1564
-                        ) {
1565
-                            $tables[] = $table->get_table_name();
1566
-                        }
1567
-                    }
1568
-                }
1569
-            }
1570
-        }
1571
-
1572
-        //there are some tables whose models were removed.
1573
-        //they should be removed when removing all EE core's data
1574
-        $tables_without_models = array(
1575
-            'esp_promotion',
1576
-            'esp_promotion_applied',
1577
-            'esp_promotion_object',
1578
-            'esp_promotion_rule',
1579
-            'esp_rule',
1580
-        );
1581
-        foreach ($tables_without_models as $table) {
1582
-            $tables[] = $table;
1583
-        }
1584
-        return \EEH_Activation::getTableManager()->dropTables($tables);
1585
-    }
1586
-
1587
-
1588
-
1589
-    /**
1590
-     * Drops all the tables mentioned in a single MYSQL query. Double-checks
1591
-     * each table name provided has a wpdb prefix attached, and that it exists.
1592
-     * Returns the list actually deleted
1593
-     *
1594
-     * @deprecated in 4.9.13. Instead use TableManager::dropTables()
1595
-     * @global WPDB $wpdb
1596
-     * @param array $table_names
1597
-     * @return array of table names which we deleted
1598
-     */
1599
-    public static function drop_tables($table_names)
1600
-    {
1601
-        return \EEH_Activation::getTableManager()->dropTables($table_names);
1602
-    }
1603
-
1604
-
1605
-
1606
-    /**
1607
-     * plugin_uninstall
1608
-     *
1609
-     * @access public
1610
-     * @static
1611
-     * @param bool $remove_all
1612
-     * @return void
1613
-     */
1614
-    public static function delete_all_espresso_tables_and_data($remove_all = true)
1615
-    {
1616
-        global $wpdb;
1617
-        self::drop_espresso_tables();
1618
-        $wp_options_to_delete = array(
1619
-            'ee_no_ticket_prices'                => true,
1620
-            'ee_active_messengers'               => true,
1621
-            'ee_has_activated_messenger'         => true,
1622
-            'ee_flush_rewrite_rules'             => true,
1623
-            'ee_config'                          => false,
1624
-            'ee_data_migration_current_db_state' => true,
1625
-            'ee_data_migration_mapping_'         => false,
1626
-            'ee_data_migration_script_'          => false,
1627
-            'ee_data_migrations'                 => true,
1628
-            'ee_dms_map'                         => false,
1629
-            'ee_notices'                         => true,
1630
-            'lang_file_check_'                   => false,
1631
-            'ee_maintenance_mode'                => true,
1632
-            'ee_ueip_optin'                      => true,
1633
-            'ee_ueip_has_notified'               => true,
1634
-            'ee_plugin_activation_errors'        => true,
1635
-            'ee_id_mapping_from'                 => false,
1636
-            'espresso_persistent_admin_notices'  => true,
1637
-            'ee_encryption_key'                  => true,
1638
-            'pue_force_upgrade_'                 => false,
1639
-            'pue_json_error_'                    => false,
1640
-            'pue_install_key_'                   => false,
1641
-            'pue_verification_error_'            => false,
1642
-            'pu_dismissed_upgrade_'              => false,
1643
-            'external_updates-'                  => false,
1644
-            'ee_extra_data'                      => true,
1645
-            'ee_ssn_'                            => false,
1646
-            'ee_rss_'                            => false,
1647
-            'ee_rte_n_tx_'                       => false,
1648
-            'ee_pers_admin_notices'              => true,
1649
-            'ee_job_parameters_'                 => false,
1650
-            'ee_upload_directories_incomplete'   => true,
1651
-            'ee_verified_db_collations'          => true,
1652
-        );
1653
-        if (is_main_site()) {
1654
-            $wp_options_to_delete['ee_network_config'] = true;
1655
-        }
1656
-        $undeleted_options = array();
1657
-        foreach ($wp_options_to_delete as $option_name => $no_wildcard) {
1658
-            if ($no_wildcard) {
1659
-                if ( ! delete_option($option_name)) {
1660
-                    $undeleted_options[] = $option_name;
1661
-                }
1662
-            } else {
1663
-                $option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'");
1664
-                foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) {
1665
-                    if ( ! delete_option($option_name_from_wildcard)) {
1666
-                        $undeleted_options[] = $option_name_from_wildcard;
1667
-                    }
1668
-                }
1669
-            }
1670
-        }
1671
-        //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it
1672
-        remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10);
1673
-        if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) {
1674
-            $db_update_sans_ee4 = array();
1675
-            foreach ($espresso_db_update as $version => $times_activated) {
1676
-                if ((string)$version[0] === '3') {//if its NON EE4
1677
-                    $db_update_sans_ee4[$version] = $times_activated;
1678
-                }
1679
-            }
1680
-            update_option('espresso_db_update', $db_update_sans_ee4);
1681
-        }
1682
-        $errors = '';
1683
-        if ( ! empty($undeleted_options)) {
1684
-            $errors .= sprintf(
1685
-                __('The following wp-options could not be deleted: %s%s', 'event_espresso'),
1686
-                '<br/>',
1687
-                implode(',<br/>', $undeleted_options)
1688
-            );
1689
-        }
1690
-        if ( ! empty($errors)) {
1691
-            EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__);
1692
-        }
1693
-    }
1694
-
1695
-    /**
1696
-     * Gets the mysql error code from the last used query by wpdb
1697
-     *
1698
-     * @return int mysql error code, see https://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html
1699
-     */
1700
-    public static function last_wpdb_error_code()
1701
-    {
1702
-        global $wpdb;
1703
-        if ($wpdb->use_mysqli) {
1704
-            return mysqli_errno($wpdb->dbh);
1705
-        } else {
1706
-            return mysql_errno($wpdb->dbh);
1707
-        }
1708
-    }
1709
-
1710
-    /**
1711
-     * Checks that the database table exists. Also works on temporary tables (for unit tests mostly).
1712
-     *
1713
-     * @global wpdb  $wpdb
1714
-     * @deprecated instead use TableAnalysis::tableExists()
1715
-     * @param string $table_name with or without $wpdb->prefix
1716
-     * @return boolean
1717
-     */
1718
-    public static function table_exists($table_name)
1719
-    {
1720
-        return \EEH_Activation::getTableAnalysis()->tableExists($table_name);
1721
-    }
1722
-
1723
-    /**
1724
-     * Resets the cache on EEH_Activation
1725
-     */
1726
-    public static function reset()
1727
-    {
1728
-        self::$_default_creator_id                             = null;
1729
-        self::$_initialized_db_content_already_in_this_request = false;
1730
-    }
1300
+		$new_templates_created_for_messenger = self::_activate_and_generate_default_messengers_and_message_templates(
1301
+			$message_resource_manager
1302
+		);
1303
+		/**
1304
+		 * This method is verifying there are no NEW default message types
1305
+		 * for ACTIVE messengers that need activated (and corresponding templates setup).
1306
+		 */
1307
+		$new_templates_created_for_message_type = self::_activate_new_message_types_for_active_messengers_and_generate_default_templates(
1308
+			$message_resource_manager
1309
+		);
1310
+		//after all is done, let's persist these changes to the db.
1311
+		$message_resource_manager->update_has_activated_messengers_option();
1312
+		$message_resource_manager->update_active_messengers_option();
1313
+		// will return true if either of these are true.  Otherwise will return false.
1314
+		return $new_templates_created_for_message_type || $new_templates_created_for_messenger;
1315
+	}
1316
+
1317
+
1318
+
1319
+	/**
1320
+	 * @param \EE_Message_Resource_Manager $message_resource_manager
1321
+	 * @return array|bool
1322
+	 * @throws \EE_Error
1323
+	 */
1324
+	protected static function _activate_new_message_types_for_active_messengers_and_generate_default_templates(
1325
+		EE_Message_Resource_Manager $message_resource_manager
1326
+	) {
1327
+		/** @type EE_messenger[] $active_messengers */
1328
+		$active_messengers = $message_resource_manager->active_messengers();
1329
+		$installed_message_types = $message_resource_manager->installed_message_types();
1330
+		$templates_created = false;
1331
+		foreach ($active_messengers as $active_messenger) {
1332
+			$default_message_type_names_for_messenger = $active_messenger->get_default_message_types();
1333
+			$default_message_type_names_to_activate = array();
1334
+			// looping through each default message type reported by the messenger
1335
+			// and setup the actual message types to activate.
1336
+			foreach ($default_message_type_names_for_messenger as $default_message_type_name_for_messenger) {
1337
+				// if already active or has already been activated before we skip
1338
+				// (otherwise we might reactivate something user's intentionally deactivated.)
1339
+				// we also skip if the message type is not installed.
1340
+				if (
1341
+					$message_resource_manager->has_message_type_been_activated_for_messenger(
1342
+						$default_message_type_name_for_messenger,
1343
+						$active_messenger->name
1344
+					)
1345
+					|| $message_resource_manager->is_message_type_active_for_messenger(
1346
+						$active_messenger->name,
1347
+						$default_message_type_name_for_messenger
1348
+					)
1349
+					|| ! isset($installed_message_types[$default_message_type_name_for_messenger])
1350
+				) {
1351
+					continue;
1352
+				}
1353
+				$default_message_type_names_to_activate[] = $default_message_type_name_for_messenger;
1354
+			}
1355
+			//let's activate!
1356
+			$message_resource_manager->ensure_message_types_are_active(
1357
+				$default_message_type_names_to_activate,
1358
+				$active_messenger->name,
1359
+				false
1360
+			);
1361
+			//activate the templates for these message types
1362
+			if ( ! empty($default_message_type_names_to_activate)) {
1363
+				$templates_created = EEH_MSG_Template::generate_new_templates(
1364
+					$active_messenger->name,
1365
+					$default_message_type_names_for_messenger,
1366
+					'',
1367
+					true
1368
+				);
1369
+			}
1370
+		}
1371
+		return $templates_created;
1372
+	}
1373
+
1374
+
1375
+
1376
+	/**
1377
+	 * This will activate and generate default messengers and default message types for those messengers.
1378
+	 *
1379
+	 * @param EE_message_Resource_Manager $message_resource_manager
1380
+	 * @return array|bool  True means there were default messengers and message type templates generated.
1381
+	 *                     False means that there were no templates generated
1382
+	 *                     (which could simply mean there are no default message types for a messenger).
1383
+	 * @throws EE_Error
1384
+	 */
1385
+	protected static function _activate_and_generate_default_messengers_and_message_templates(
1386
+		EE_Message_Resource_Manager $message_resource_manager
1387
+	) {
1388
+		/** @type EE_messenger[] $messengers_to_generate */
1389
+		$messengers_to_generate = self::_get_default_messengers_to_generate_on_activation($message_resource_manager);
1390
+		$installed_message_types = $message_resource_manager->installed_message_types();
1391
+		$templates_generated = false;
1392
+		foreach ($messengers_to_generate as $messenger_to_generate) {
1393
+			$default_message_type_names_for_messenger = $messenger_to_generate->get_default_message_types();
1394
+			//verify the default message types match an installed message type.
1395
+			foreach ($default_message_type_names_for_messenger as $key => $name) {
1396
+				if (
1397
+					! isset($installed_message_types[$name])
1398
+					|| $message_resource_manager->has_message_type_been_activated_for_messenger(
1399
+						$name,
1400
+						$messenger_to_generate->name
1401
+					)
1402
+				) {
1403
+					unset($default_message_type_names_for_messenger[$key]);
1404
+				}
1405
+			}
1406
+			// in previous iterations, the active_messengers option in the db
1407
+			// needed updated before calling create templates. however with the changes this may not be necessary.
1408
+			// This comment is left here just in case we discover that we _do_ need to update before
1409
+			// passing off to create templates (after the refactor is done).
1410
+			// @todo remove this comment when determined not necessary.
1411
+			$message_resource_manager->activate_messenger(
1412
+				$messenger_to_generate->name,
1413
+				$default_message_type_names_for_messenger,
1414
+				false
1415
+			);
1416
+			//create any templates needing created (or will reactivate templates already generated as necessary).
1417
+			if ( ! empty($default_message_type_names_for_messenger)) {
1418
+				$templates_generated = EEH_MSG_Template::generate_new_templates(
1419
+					$messenger_to_generate->name,
1420
+					$default_message_type_names_for_messenger,
1421
+					'',
1422
+					true
1423
+				);
1424
+			}
1425
+		}
1426
+		return $templates_generated;
1427
+	}
1428
+
1429
+
1430
+	/**
1431
+	 * This returns the default messengers to generate templates for on activation of EE.
1432
+	 * It considers:
1433
+	 * - whether a messenger is already active in the db.
1434
+	 * - whether a messenger has been made active at any time in the past.
1435
+	 *
1436
+	 * @static
1437
+	 * @param  EE_Message_Resource_Manager $message_resource_manager
1438
+	 * @return EE_messenger[]
1439
+	 */
1440
+	protected static function _get_default_messengers_to_generate_on_activation(
1441
+		EE_Message_Resource_Manager $message_resource_manager
1442
+	) {
1443
+		$active_messengers    = $message_resource_manager->active_messengers();
1444
+		$installed_messengers = $message_resource_manager->installed_messengers();
1445
+		$has_activated        = $message_resource_manager->get_has_activated_messengers_option();
1446
+
1447
+		$messengers_to_generate = array();
1448
+		foreach ($installed_messengers as $installed_messenger) {
1449
+			//if installed messenger is a messenger that should be activated on install
1450
+			//and is not already active
1451
+			//and has never been activated
1452
+			if (
1453
+				! $installed_messenger->activate_on_install
1454
+				|| isset($active_messengers[$installed_messenger->name])
1455
+				|| isset($has_activated[$installed_messenger->name])
1456
+			) {
1457
+				continue;
1458
+			}
1459
+			$messengers_to_generate[$installed_messenger->name] = $installed_messenger;
1460
+		}
1461
+		return $messengers_to_generate;
1462
+	}
1463
+
1464
+
1465
+	/**
1466
+	 * This simply validates active message types to ensure they actually match installed
1467
+	 * message types.  If there's a mismatch then we deactivate the message type and ensure all related db
1468
+	 * rows are set inactive.
1469
+	 * Note: Messengers are no longer validated here as of 4.9.0 because they get validated automatically whenever
1470
+	 * EE_Messenger_Resource_Manager is constructed.  Message Types are a bit more resource heavy for validation so they
1471
+	 * are still handled in here.
1472
+	 *
1473
+	 * @since 4.3.1
1474
+	 * @return void
1475
+	 */
1476
+	public static function validate_messages_system()
1477
+	{
1478
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
1479
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
1480
+		$message_resource_manager->validate_active_message_types_are_installed();
1481
+		do_action('AHEE__EEH_Activation__validate_messages_system');
1482
+	}
1483
+
1484
+
1485
+	/**
1486
+	 * create_no_ticket_prices_array
1487
+	 *
1488
+	 * @access public
1489
+	 * @static
1490
+	 * @return void
1491
+	 */
1492
+	public static function create_no_ticket_prices_array()
1493
+	{
1494
+		// this creates an array for tracking events that have no active ticket prices created
1495
+		// this allows us to warn admins of the situation so that it can be corrected
1496
+		$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', false);
1497
+		if (! $espresso_no_ticket_prices) {
1498
+			add_option('ee_no_ticket_prices', array(), '', false);
1499
+		}
1500
+	}
1501
+
1502
+
1503
+	/**
1504
+	 * plugin_deactivation
1505
+	 *
1506
+	 * @access public
1507
+	 * @static
1508
+	 * @return void
1509
+	 */
1510
+	public static function plugin_deactivation()
1511
+	{
1512
+	}
1513
+
1514
+
1515
+	/**
1516
+	 * Finds all our EE4 custom post types, and deletes them and their associated data
1517
+	 * (like post meta or term relations)
1518
+	 *
1519
+	 * @global wpdb $wpdb
1520
+	 * @throws \EE_Error
1521
+	 */
1522
+	public static function delete_all_espresso_cpt_data()
1523
+	{
1524
+		global $wpdb;
1525
+		//get all the CPT post_types
1526
+		$ee_post_types = array();
1527
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1528
+			if (method_exists($model_name, 'instance')) {
1529
+				$model_obj = call_user_func(array($model_name, 'instance'));
1530
+				if ($model_obj instanceof EEM_CPT_Base) {
1531
+					$ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type());
1532
+				}
1533
+			}
1534
+		}
1535
+		//get all our CPTs
1536
+		$query   = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (" . implode(",", $ee_post_types) . ")";
1537
+		$cpt_ids = $wpdb->get_col($query);
1538
+		//delete each post meta and term relations too
1539
+		foreach ($cpt_ids as $post_id) {
1540
+			wp_delete_post($post_id, true);
1541
+		}
1542
+	}
1543
+
1544
+	/**
1545
+	 * Deletes all EE custom tables
1546
+	 *
1547
+	 * @return array
1548
+	 */
1549
+	public static function drop_espresso_tables()
1550
+	{
1551
+		$tables = array();
1552
+		// load registry
1553
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1554
+			if (method_exists($model_name, 'instance')) {
1555
+				$model_obj = call_user_func(array($model_name, 'instance'));
1556
+				if ($model_obj instanceof EEM_Base) {
1557
+					foreach ($model_obj->get_tables() as $table) {
1558
+						if (strpos($table->get_table_name(), 'esp_')
1559
+							&&
1560
+							(
1561
+								is_main_site()//main site? nuke them all
1562
+								|| ! $table->is_global()//not main site,but not global either. nuke it
1563
+							)
1564
+						) {
1565
+							$tables[] = $table->get_table_name();
1566
+						}
1567
+					}
1568
+				}
1569
+			}
1570
+		}
1571
+
1572
+		//there are some tables whose models were removed.
1573
+		//they should be removed when removing all EE core's data
1574
+		$tables_without_models = array(
1575
+			'esp_promotion',
1576
+			'esp_promotion_applied',
1577
+			'esp_promotion_object',
1578
+			'esp_promotion_rule',
1579
+			'esp_rule',
1580
+		);
1581
+		foreach ($tables_without_models as $table) {
1582
+			$tables[] = $table;
1583
+		}
1584
+		return \EEH_Activation::getTableManager()->dropTables($tables);
1585
+	}
1586
+
1587
+
1588
+
1589
+	/**
1590
+	 * Drops all the tables mentioned in a single MYSQL query. Double-checks
1591
+	 * each table name provided has a wpdb prefix attached, and that it exists.
1592
+	 * Returns the list actually deleted
1593
+	 *
1594
+	 * @deprecated in 4.9.13. Instead use TableManager::dropTables()
1595
+	 * @global WPDB $wpdb
1596
+	 * @param array $table_names
1597
+	 * @return array of table names which we deleted
1598
+	 */
1599
+	public static function drop_tables($table_names)
1600
+	{
1601
+		return \EEH_Activation::getTableManager()->dropTables($table_names);
1602
+	}
1603
+
1604
+
1605
+
1606
+	/**
1607
+	 * plugin_uninstall
1608
+	 *
1609
+	 * @access public
1610
+	 * @static
1611
+	 * @param bool $remove_all
1612
+	 * @return void
1613
+	 */
1614
+	public static function delete_all_espresso_tables_and_data($remove_all = true)
1615
+	{
1616
+		global $wpdb;
1617
+		self::drop_espresso_tables();
1618
+		$wp_options_to_delete = array(
1619
+			'ee_no_ticket_prices'                => true,
1620
+			'ee_active_messengers'               => true,
1621
+			'ee_has_activated_messenger'         => true,
1622
+			'ee_flush_rewrite_rules'             => true,
1623
+			'ee_config'                          => false,
1624
+			'ee_data_migration_current_db_state' => true,
1625
+			'ee_data_migration_mapping_'         => false,
1626
+			'ee_data_migration_script_'          => false,
1627
+			'ee_data_migrations'                 => true,
1628
+			'ee_dms_map'                         => false,
1629
+			'ee_notices'                         => true,
1630
+			'lang_file_check_'                   => false,
1631
+			'ee_maintenance_mode'                => true,
1632
+			'ee_ueip_optin'                      => true,
1633
+			'ee_ueip_has_notified'               => true,
1634
+			'ee_plugin_activation_errors'        => true,
1635
+			'ee_id_mapping_from'                 => false,
1636
+			'espresso_persistent_admin_notices'  => true,
1637
+			'ee_encryption_key'                  => true,
1638
+			'pue_force_upgrade_'                 => false,
1639
+			'pue_json_error_'                    => false,
1640
+			'pue_install_key_'                   => false,
1641
+			'pue_verification_error_'            => false,
1642
+			'pu_dismissed_upgrade_'              => false,
1643
+			'external_updates-'                  => false,
1644
+			'ee_extra_data'                      => true,
1645
+			'ee_ssn_'                            => false,
1646
+			'ee_rss_'                            => false,
1647
+			'ee_rte_n_tx_'                       => false,
1648
+			'ee_pers_admin_notices'              => true,
1649
+			'ee_job_parameters_'                 => false,
1650
+			'ee_upload_directories_incomplete'   => true,
1651
+			'ee_verified_db_collations'          => true,
1652
+		);
1653
+		if (is_main_site()) {
1654
+			$wp_options_to_delete['ee_network_config'] = true;
1655
+		}
1656
+		$undeleted_options = array();
1657
+		foreach ($wp_options_to_delete as $option_name => $no_wildcard) {
1658
+			if ($no_wildcard) {
1659
+				if ( ! delete_option($option_name)) {
1660
+					$undeleted_options[] = $option_name;
1661
+				}
1662
+			} else {
1663
+				$option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'");
1664
+				foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) {
1665
+					if ( ! delete_option($option_name_from_wildcard)) {
1666
+						$undeleted_options[] = $option_name_from_wildcard;
1667
+					}
1668
+				}
1669
+			}
1670
+		}
1671
+		//also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it
1672
+		remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10);
1673
+		if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) {
1674
+			$db_update_sans_ee4 = array();
1675
+			foreach ($espresso_db_update as $version => $times_activated) {
1676
+				if ((string)$version[0] === '3') {//if its NON EE4
1677
+					$db_update_sans_ee4[$version] = $times_activated;
1678
+				}
1679
+			}
1680
+			update_option('espresso_db_update', $db_update_sans_ee4);
1681
+		}
1682
+		$errors = '';
1683
+		if ( ! empty($undeleted_options)) {
1684
+			$errors .= sprintf(
1685
+				__('The following wp-options could not be deleted: %s%s', 'event_espresso'),
1686
+				'<br/>',
1687
+				implode(',<br/>', $undeleted_options)
1688
+			);
1689
+		}
1690
+		if ( ! empty($errors)) {
1691
+			EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__);
1692
+		}
1693
+	}
1694
+
1695
+	/**
1696
+	 * Gets the mysql error code from the last used query by wpdb
1697
+	 *
1698
+	 * @return int mysql error code, see https://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html
1699
+	 */
1700
+	public static function last_wpdb_error_code()
1701
+	{
1702
+		global $wpdb;
1703
+		if ($wpdb->use_mysqli) {
1704
+			return mysqli_errno($wpdb->dbh);
1705
+		} else {
1706
+			return mysql_errno($wpdb->dbh);
1707
+		}
1708
+	}
1709
+
1710
+	/**
1711
+	 * Checks that the database table exists. Also works on temporary tables (for unit tests mostly).
1712
+	 *
1713
+	 * @global wpdb  $wpdb
1714
+	 * @deprecated instead use TableAnalysis::tableExists()
1715
+	 * @param string $table_name with or without $wpdb->prefix
1716
+	 * @return boolean
1717
+	 */
1718
+	public static function table_exists($table_name)
1719
+	{
1720
+		return \EEH_Activation::getTableAnalysis()->tableExists($table_name);
1721
+	}
1722
+
1723
+	/**
1724
+	 * Resets the cache on EEH_Activation
1725
+	 */
1726
+	public static function reset()
1727
+	{
1728
+		self::$_default_creator_id                             = null;
1729
+		self::$_initialized_db_content_already_in_this_request = false;
1730
+	}
1731 1731
 }
1732 1732
 // End of file EEH_Activation.helper.php
1733 1733
 // Location: /helpers/EEH_Activation.core.php
Please login to merge, or discard this patch.
core/EES_Shortcode.shortcode.php 2 patches
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -20,17 +20,17 @@  discard block
 block discarded – undo
20 20
 
21 21
 
22 22
 
23
-    /**
24
-     * class constructor - should ONLY be instantiated by EE_Front_Controller
25
-     */
26
-    final public function __construct()
27
-    {
28
-        $shortcode = LegacyShortcodesManager::generateShortcodeTagFromClassName(get_class($this));
29
-        // assign shortcode to the preferred callback, which overwrites the "fallback shortcode processor" assigned earlier
30
-        add_shortcode($shortcode, array($this, 'process_shortcode'));
31
-        // make sure system knows this is an EE page
32
-        EE_Registry::instance()->REQ->set_espresso_page(true);
33
-    }
23
+	/**
24
+	 * class constructor - should ONLY be instantiated by EE_Front_Controller
25
+	 */
26
+	final public function __construct()
27
+	{
28
+		$shortcode = LegacyShortcodesManager::generateShortcodeTagFromClassName(get_class($this));
29
+		// assign shortcode to the preferred callback, which overwrites the "fallback shortcode processor" assigned earlier
30
+		add_shortcode($shortcode, array($this, 'process_shortcode'));
31
+		// make sure system knows this is an EE page
32
+		EE_Registry::instance()->REQ->set_espresso_page(true);
33
+	}
34 34
 
35 35
 
36 36
 
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
 		}
78 78
 		$shortcode = str_replace( 'EES_', '', strtoupper( $shortcode_class ));
79 79
 		$shortcode_obj = isset( EE_Registry::instance()->shortcodes->{$shortcode} )
80
-            ? EE_Registry::instance()->shortcodes->{$shortcode}
81
-            : null;
80
+			? EE_Registry::instance()->shortcodes->{$shortcode}
81
+			: null;
82 82
 		return $shortcode_obj instanceof $shortcode_class || $shortcode_class === 'self'
83
-            ? $shortcode_obj
84
-            : new $shortcode_class();
83
+			? $shortcode_obj
84
+			: new $shortcode_class();
85 85
 	}
86 86
 
87 87
 
@@ -135,59 +135,59 @@  discard block
 block discarded – undo
135 135
 
136 136
 
137 137
 
138
-    /**
139
-     * Performs basic sanitization on shortcode attributes
140
-     * Since incoming attributes from the shortcode usage in the WP editor will all be strings,
141
-     * most attributes will by default be sanitized using the sanitize_text_field() function.
142
-     * This can be overridden by supplying an array for the $custom_sanitization param,
143
-     * where keys match keys in your attributes array,
144
-     * and values represent the sanitization function you wish to be applied to that attribute.
145
-     * So for example, if you had an integer attribute named "event_id"
146
-     * that you wanted to be sanitized using absint(),
147
-     * then you would pass the following for your $custom_sanitization array:
148
-     *      array('event_id' => 'absint')
149
-     * all other attributes would be sanitized using the defaults in the switch statement below
150
-     *
151
-     * @param array $attributes
152
-     * @param array $custom_sanitization
153
-     * @return array
154
-     */
155
-    public static function sanitize_attributes(array $attributes, $custom_sanitization = array())
156
-    {
157
-        foreach ($attributes as $key => $value) {
158
-            // is a custom sanitization callback specified ?
159
-            if ( isset($custom_sanitization[$key])) {
160
-                $callback = $custom_sanitization[$key];
161
-                if ($callback === 'skip_sanitization') {
162
-                    $attributes[$key] = $value;
163
-                    continue;
164
-                } else if (function_exists($callback)){
165
-                    $attributes[$key] = $callback($value);
166
-                    continue;
167
-                }
168
-            }
169
-            switch (true) {
170
-                case $value === null :
171
-                case is_int($value) :
172
-                case is_float($value) :
173
-                    // typical booleans
174
-                case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true) :
175
-                    $attributes[$key] = $value;
176
-                    break;
177
-                case is_string($value) :
178
-                    $attributes[$key] = sanitize_text_field($value);
179
-                    break;
180
-                case is_array($value) :
181
-                    $attributes[$key] = \EES_Shortcode::sanitize_attributes($value);
182
-                    break;
183
-                default :
184
-                    // only remaining data types are Object and Resource
185
-                    // which are not allowed as shortcode attributes
186
-                    $attributes[$key] = null;
187
-                    break;
188
-            }
189
-        }
190
-        return $attributes;
138
+	/**
139
+	 * Performs basic sanitization on shortcode attributes
140
+	 * Since incoming attributes from the shortcode usage in the WP editor will all be strings,
141
+	 * most attributes will by default be sanitized using the sanitize_text_field() function.
142
+	 * This can be overridden by supplying an array for the $custom_sanitization param,
143
+	 * where keys match keys in your attributes array,
144
+	 * and values represent the sanitization function you wish to be applied to that attribute.
145
+	 * So for example, if you had an integer attribute named "event_id"
146
+	 * that you wanted to be sanitized using absint(),
147
+	 * then you would pass the following for your $custom_sanitization array:
148
+	 *      array('event_id' => 'absint')
149
+	 * all other attributes would be sanitized using the defaults in the switch statement below
150
+	 *
151
+	 * @param array $attributes
152
+	 * @param array $custom_sanitization
153
+	 * @return array
154
+	 */
155
+	public static function sanitize_attributes(array $attributes, $custom_sanitization = array())
156
+	{
157
+		foreach ($attributes as $key => $value) {
158
+			// is a custom sanitization callback specified ?
159
+			if ( isset($custom_sanitization[$key])) {
160
+				$callback = $custom_sanitization[$key];
161
+				if ($callback === 'skip_sanitization') {
162
+					$attributes[$key] = $value;
163
+					continue;
164
+				} else if (function_exists($callback)){
165
+					$attributes[$key] = $callback($value);
166
+					continue;
167
+				}
168
+			}
169
+			switch (true) {
170
+				case $value === null :
171
+				case is_int($value) :
172
+				case is_float($value) :
173
+					// typical booleans
174
+				case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true) :
175
+					$attributes[$key] = $value;
176
+					break;
177
+				case is_string($value) :
178
+					$attributes[$key] = sanitize_text_field($value);
179
+					break;
180
+				case is_array($value) :
181
+					$attributes[$key] = \EES_Shortcode::sanitize_attributes($value);
182
+					break;
183
+				default :
184
+					// only remaining data types are Object and Resource
185
+					// which are not allowed as shortcode attributes
186
+					$attributes[$key] = null;
187
+					break;
188
+			}
189
+		}
190
+		return $attributes;
191 191
 	}
192 192
 
193 193
 
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 * @param WP $WP
48 48
 	 * @return    void
49 49
 	 */
50
-	public abstract function run( WP $WP );
50
+	public abstract function run(WP $WP);
51 51
 
52 52
 
53 53
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	 *  @param		array 	$attributes
60 60
 	 *  @return 	mixed
61 61
 	 */
62
-	public abstract function process_shortcode( $attributes = array() );
62
+	public abstract function process_shortcode($attributes = array());
63 63
 
64 64
 
65 65
 
@@ -70,13 +70,13 @@  discard block
 block discarded – undo
70 70
 	 * @param 	string $shortcode_class
71 71
 	 * @return 	\EES_Shortcode
72 72
 	 */
73
-	final public static function instance( $shortcode_class = null ) {
74
-		$shortcode_class = ! empty( $shortcode_class ) ? $shortcode_class : get_called_class();
75
-		if ( $shortcode_class === 'EES_Shortcode' || empty( $shortcode_class )) {
73
+	final public static function instance($shortcode_class = null) {
74
+		$shortcode_class = ! empty($shortcode_class) ? $shortcode_class : get_called_class();
75
+		if ($shortcode_class === 'EES_Shortcode' || empty($shortcode_class)) {
76 76
 			return null;
77 77
 		}
78
-		$shortcode = str_replace( 'EES_', '', strtoupper( $shortcode_class ));
79
-		$shortcode_obj = isset( EE_Registry::instance()->shortcodes->{$shortcode} )
78
+		$shortcode = str_replace('EES_', '', strtoupper($shortcode_class));
79
+		$shortcode_obj = isset(EE_Registry::instance()->shortcodes->{$shortcode} )
80 80
             ? EE_Registry::instance()->shortcodes->{$shortcode}
81 81
             : null;
82 82
 		return $shortcode_obj instanceof $shortcode_class || $shortcode_class === 'self'
@@ -95,23 +95,23 @@  discard block
 block discarded – undo
95 95
 	 * @param 	$attributes
96 96
 	 * @return 	mixed
97 97
 	 */
98
-	final public static function fallback_shortcode_processor( $attributes ) {
99
-		if ( EE_Maintenance_Mode::disable_frontend_for_maintenance() ) {
98
+	final public static function fallback_shortcode_processor($attributes) {
99
+		if (EE_Maintenance_Mode::disable_frontend_for_maintenance()) {
100 100
 			return null;
101 101
 		}
102 102
 		// what shortcode was actually parsed ?
103 103
 		$shortcode_class = get_called_class();
104 104
 		// notify rest of system that fallback processor was triggered
105
-		add_filter( 'FHEE__fallback_shortcode_processor__' . $shortcode_class, '__return_true' );
105
+		add_filter('FHEE__fallback_shortcode_processor__'.$shortcode_class, '__return_true');
106 106
 		// get instance of actual shortcode
107
-		$shortcode_obj = self::instance( $shortcode_class );
107
+		$shortcode_obj = self::instance($shortcode_class);
108 108
 		// verify class
109
-		if ( $shortcode_obj instanceof EES_Shortcode ) {
109
+		if ($shortcode_obj instanceof EES_Shortcode) {
110 110
 			global $wp;
111
-			$shortcode_obj->run( $wp );
111
+			$shortcode_obj->run($wp);
112 112
 			// set attributes and run the shortcode
113
-			$shortcode_obj->_attributes = (array)$attributes;
114
-			return $shortcode_obj->process_shortcode( $shortcode_obj->_attributes );
113
+			$shortcode_obj->_attributes = (array) $attributes;
114
+			return $shortcode_obj->process_shortcode($shortcode_obj->_attributes);
115 115
 		} else {
116 116
 			return null;
117 117
 		}
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	 * @param 	$attributes
128 128
 	 * @return 	string
129 129
 	 */
130
-	final public static function invalid_shortcode_processor( $attributes ) {
130
+	final public static function invalid_shortcode_processor($attributes) {
131 131
 		return '';
132 132
 	}
133 133
 
@@ -156,12 +156,12 @@  discard block
 block discarded – undo
156 156
     {
157 157
         foreach ($attributes as $key => $value) {
158 158
             // is a custom sanitization callback specified ?
159
-            if ( isset($custom_sanitization[$key])) {
159
+            if (isset($custom_sanitization[$key])) {
160 160
                 $callback = $custom_sanitization[$key];
161 161
                 if ($callback === 'skip_sanitization') {
162 162
                     $attributes[$key] = $value;
163 163
                     continue;
164
-                } else if (function_exists($callback)){
164
+                } else if (function_exists($callback)) {
165 165
                     $attributes[$key] = $callback($value);
166 166
                     continue;
167 167
                 }
Please login to merge, or discard this patch.
core/admin/EE_Admin.core.php 1 patch
Spacing   +138 added lines, -138 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	public static function instance() {
42 42
 		// check if class object is instantiated
43
-		if (  ! self::$_instance instanceof EE_Admin ) {
43
+		if ( ! self::$_instance instanceof EE_Admin) {
44 44
 			self::$_instance = new self();
45 45
 		}
46 46
 		return self::$_instance;
@@ -57,25 +57,25 @@  discard block
 block discarded – undo
57 57
 		// define global EE_Admin constants
58 58
 		$this->_define_all_constants();
59 59
 		// set autoloaders for our admin page classes based on included path information
60
-		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( EE_ADMIN );
60
+		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN);
61 61
 		// admin hooks
62
-		add_filter( 'plugin_action_links', array( $this, 'filter_plugin_actions' ), 10, 2 );
62
+		add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2);
63 63
 		// load EE_Request_Handler early
64
-		add_action( 'AHEE__EE_System__core_loaded_and_ready', array( $this, 'get_request' ));
65
-		add_action( 'AHEE__EE_System__initialize_last', array( $this, 'init' ));
66
-		add_action( 'AHEE__EE_Admin_Page__route_admin_request', array( $this, 'route_admin_request' ), 100, 2 );
67
-		add_action( 'wp_loaded', array( $this, 'wp_loaded' ), 100 );
68
-		add_action( 'admin_init', array( $this, 'admin_init' ), 100 );
69
-		add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ), 20 );
70
-		add_action( 'admin_notices', array( $this, 'display_admin_notices' ), 10 );
71
-		add_action( 'network_admin_notices', array( $this, 'display_admin_notices' ), 10 );
72
-		add_filter( 'pre_update_option', array( $this, 'check_for_invalid_datetime_formats' ), 100, 2 );
73
-		add_filter('admin_footer_text', array( $this, 'espresso_admin_footer' ));
64
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request'));
65
+		add_action('AHEE__EE_System__initialize_last', array($this, 'init'));
66
+		add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2);
67
+		add_action('wp_loaded', array($this, 'wp_loaded'), 100);
68
+		add_action('admin_init', array($this, 'admin_init'), 100);
69
+		add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20);
70
+		add_action('admin_notices', array($this, 'display_admin_notices'), 10);
71
+		add_action('network_admin_notices', array($this, 'display_admin_notices'), 10);
72
+		add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2);
73
+		add_filter('admin_footer_text', array($this, 'espresso_admin_footer'));
74 74
 
75 75
 		//reset Environment config (we only do this on admin page loads);
76 76
 		EE_Registry::instance()->CFG->environment->recheck_values();
77 77
 
78
-		do_action( 'AHEE__EE_Admin__loaded' );
78
+		do_action('AHEE__EE_Admin__loaded');
79 79
 	}
80 80
 
81 81
 
@@ -90,11 +90,11 @@  discard block
 block discarded – undo
90 90
 	 * @return void
91 91
 	 */
92 92
 	private function _define_all_constants() {
93
-		define( 'EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/' );
94
-		define( 'EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/' );
95
-		define( 'EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS );
96
-		define( 'WP_ADMIN_PATH', ABSPATH . 'wp-admin/' );
97
-		define( 'WP_AJAX_URL', admin_url( 'admin-ajax.php' ));
93
+		define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL.'core/admin/');
94
+		define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL.'admin_pages/');
95
+		define('EE_ADMIN_TEMPLATE', EE_ADMIN.'templates'.DS);
96
+		define('WP_ADMIN_PATH', ABSPATH.'wp-admin/');
97
+		define('WP_AJAX_URL', admin_url('admin-ajax.php'));
98 98
 	}
99 99
 
100 100
 
@@ -107,23 +107,23 @@  discard block
 block discarded – undo
107 107
 	 * @param 	string 	$plugin
108 108
 	 * @return 	array
109 109
 	 */
110
-	public function filter_plugin_actions( $links, $plugin ) {
110
+	public function filter_plugin_actions($links, $plugin) {
111 111
 		// set $main_file in stone
112 112
 		static $main_file;
113 113
 		// if $main_file is not set yet
114
-		if ( ! $main_file ) {
115
-			$main_file = plugin_basename( EVENT_ESPRESSO_MAIN_FILE );
114
+		if ( ! $main_file) {
115
+			$main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE);
116 116
 		}
117
-		 if ( $plugin === $main_file ) {
117
+		 if ($plugin === $main_file) {
118 118
 		 	// compare current plugin to this one
119
-			if ( EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance ) {
120
-				$maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings" title="Event Espresso is in maintenance mode.  Click this link to learn why.">' . __('Maintenance Mode Active', 'event_espresso' ) . '</a>';
121
-				array_unshift( $links, $maintenance_link );
119
+			if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) {
120
+				$maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings" title="Event Espresso is in maintenance mode.  Click this link to learn why.">'.__('Maintenance Mode Active', 'event_espresso').'</a>';
121
+				array_unshift($links, $maintenance_link);
122 122
 			} else {
123
-				$org_settings_link = '<a href="admin.php?page=espresso_general_settings">' . __( 'Settings', 'event_espresso' ) . '</a>';
124
-				$events_link = '<a href="admin.php?page=espresso_events">' . __( 'Events', 'event_espresso' ) . '</a>';
123
+				$org_settings_link = '<a href="admin.php?page=espresso_general_settings">'.__('Settings', 'event_espresso').'</a>';
124
+				$events_link = '<a href="admin.php?page=espresso_events">'.__('Events', 'event_espresso').'</a>';
125 125
 				// add before other links
126
-				array_unshift( $links, $org_settings_link, $events_link );
126
+				array_unshift($links, $org_settings_link, $events_link);
127 127
 			}
128 128
 		}
129 129
 		return $links;
@@ -138,8 +138,8 @@  discard block
 block discarded – undo
138 138
 	 *	@return void
139 139
 	 */
140 140
 	public function get_request() {
141
-		EE_Registry::instance()->load_core( 'Request_Handler' );
142
-		EE_Registry::instance()->load_core( 'CPT_Strategy' );
141
+		EE_Registry::instance()->load_core('Request_Handler');
142
+		EE_Registry::instance()->load_core('CPT_Strategy');
143 143
 	}
144 144
 
145 145
 
@@ -151,11 +151,11 @@  discard block
 block discarded – undo
151 151
 	 * @param array $admin_page_folder_names
152 152
 	 * @return array
153 153
 	 */
154
-	public function hide_admin_pages_except_maintenance_mode( $admin_page_folder_names = array() ){
154
+	public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array()) {
155 155
 		return array(
156
-			'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS,
157
-			'about' => EE_ADMIN_PAGES . 'about' . DS,
158
-			'support' => EE_ADMIN_PAGES . 'support' . DS
156
+			'maintenance' => EE_ADMIN_PAGES.'maintenance'.DS,
157
+			'about' => EE_ADMIN_PAGES.'about'.DS,
158
+			'support' => EE_ADMIN_PAGES.'support'.DS
159 159
 		);
160 160
 	}
161 161
 
@@ -169,31 +169,31 @@  discard block
 block discarded – undo
169 169
 	*/
170 170
 	public function init() {
171 171
 		//only enable most of the EE_Admin IF we're not in full maintenance mode
172
-		if ( EE_Maintenance_Mode::instance()->models_can_query() ){
172
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
173 173
 			//ok so we want to enable the entire admin
174
-			add_action( 'wp_ajax_dismiss_ee_nag_notice', array( $this, 'dismiss_ee_nag_notice_callback' ));
175
-			add_action( 'admin_notices', array( $this, 'get_persistent_admin_notices' ), 9 );
176
-			add_action( 'network_admin_notices', array( $this, 'get_persistent_admin_notices' ), 9 );
174
+			add_action('wp_ajax_dismiss_ee_nag_notice', array($this, 'dismiss_ee_nag_notice_callback'));
175
+			add_action('admin_notices', array($this, 'get_persistent_admin_notices'), 9);
176
+			add_action('network_admin_notices', array($this, 'get_persistent_admin_notices'), 9);
177 177
 			//at a glance dashboard widget
178
-			add_filter( 'dashboard_glance_items', array( $this, 'dashboard_glance_items' ), 10 );
178
+			add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10);
179 179
 			//filter for get_edit_post_link used on comments for custom post types
180
-			add_filter( 'get_edit_post_link', array( $this, 'modify_edit_post_link' ), 10, 2 );
180
+			add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2);
181 181
 		}
182 182
 		// run the admin page factory but ONLY if we are doing an ee admin ajax request
183
-		if ( !defined('DOING_AJAX') || EE_ADMIN_AJAX ) {
183
+		if ( ! defined('DOING_AJAX') || EE_ADMIN_AJAX) {
184 184
 			try {
185 185
 				//this loads the controller for the admin pages which will setup routing etc
186
-				EE_Registry::instance()->load_core( 'Admin_Page_Loader' );
187
-			} catch ( EE_Error $e ) {
186
+				EE_Registry::instance()->load_core('Admin_Page_Loader');
187
+			} catch (EE_Error $e) {
188 188
 				$e->get_error();
189 189
 			}
190 190
 		}
191
-		add_filter( 'content_save_pre', array( $this, 'its_eSpresso' ), 10, 1 );
191
+		add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1);
192 192
 		//make sure our CPTs and custom taxonomy metaboxes get shown for first time users
193
-		add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes' ), 10 );
194
-		add_action('admin_head', array( $this, 'register_custom_nav_menu_boxes' ), 10 );
193
+		add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10);
194
+		add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10);
195 195
 		//exclude EE critical pages from all nav menus and wp_list_pages
196
-		add_filter('nav_menu_meta_box_object', array( $this, 'remove_pages_from_nav_menu'), 10 );
196
+		add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10);
197 197
 	}
198 198
 
199 199
 
@@ -206,9 +206,9 @@  discard block
 block discarded – undo
206 206
 	 * @param  object $post_type WP post type object
207 207
 	 * @return object            WP post type object
208 208
 	 */
209
-	public function remove_pages_from_nav_menu( $post_type ) {
209
+	public function remove_pages_from_nav_menu($post_type) {
210 210
 		//if this isn't the "pages" post type let's get out
211
-		if ( $post_type->name !== 'page' ) {
211
+		if ($post_type->name !== 'page') {
212 212
 			return $post_type;
213 213
 		}
214 214
 		$critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
@@ -228,28 +228,28 @@  discard block
 block discarded – undo
228 228
 	 */
229 229
 	public function enable_hidden_ee_nav_menu_metaboxes() {
230 230
 		global $wp_meta_boxes, $pagenow;
231
-		if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php' ) {
231
+		if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
232 232
 			return;
233 233
 		}
234 234
 		$user = wp_get_current_user();
235 235
 		//has this been done yet?
236
-		if ( get_user_option( 'ee_nav_menu_initialized', $user->ID ) ) {
236
+		if (get_user_option('ee_nav_menu_initialized', $user->ID)) {
237 237
 			return;
238 238
 		}
239 239
 
240
-		$hidden_meta_boxes = get_user_option( 'metaboxhidden_nav-menus', $user->ID );
241
-		$initial_meta_boxes = apply_filters( 'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', array( 'nav-menu-theme-locations', 'add-page', 'add-custom-links', 'add-category', 'add-espresso_events', 'add-espresso_venues', 'add-espresso_event_categories', 'add-espresso_venue_categories', 'add-post-type-post', 'add-post-type-page' ) );
240
+		$hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID);
241
+		$initial_meta_boxes = apply_filters('FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', array('nav-menu-theme-locations', 'add-page', 'add-custom-links', 'add-category', 'add-espresso_events', 'add-espresso_venues', 'add-espresso_event_categories', 'add-espresso_venue_categories', 'add-post-type-post', 'add-post-type-page'));
242 242
 
243
-		if ( is_array( $hidden_meta_boxes ) ) {
244
-			foreach ( $hidden_meta_boxes as $key => $meta_box_id ) {
245
-				if ( in_array( $meta_box_id, $initial_meta_boxes ) ) {
246
-					unset( $hidden_meta_boxes[ $key ] );
243
+		if (is_array($hidden_meta_boxes)) {
244
+			foreach ($hidden_meta_boxes as $key => $meta_box_id) {
245
+				if (in_array($meta_box_id, $initial_meta_boxes)) {
246
+					unset($hidden_meta_boxes[$key]);
247 247
 				}
248 248
 			}
249 249
 		}
250 250
 
251
-		update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true );
252
-		update_user_option( $user->ID, 'ee_nav_menu_initialized', 1, true );
251
+		update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
252
+		update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true);
253 253
 	}
254 254
 
255 255
 
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 	 * @return void
269 269
 	 */
270 270
 	public function register_custom_nav_menu_boxes() {
271
-		add_meta_box( 'add-extra-nav-menu-pages', __('Event Espresso Pages', 'event_espresso'), array( $this, 'ee_cpt_archive_pages' ), 'nav-menus', 'side', 'core' );
271
+		add_meta_box('add-extra-nav-menu-pages', __('Event Espresso Pages', 'event_espresso'), array($this, 'ee_cpt_archive_pages'), 'nav-menus', 'side', 'core');
272 272
 	}
273 273
 
274 274
 
@@ -284,16 +284,16 @@  discard block
 block discarded – undo
284 284
 	 *
285 285
 	 * @return string  the (maybe) modified link
286 286
 	 */
287
-	public function modify_edit_post_link( $link, $id ) {
288
-		if ( ! $post = get_post( $id ) ){
287
+	public function modify_edit_post_link($link, $id) {
288
+		if ( ! $post = get_post($id)) {
289 289
 			return $link;
290 290
 		}
291
-		if ( $post->post_type === 'espresso_attendees' ) {
291
+		if ($post->post_type === 'espresso_attendees') {
292 292
 			$query_args = array(
293 293
 				'action' => 'edit_attendee',
294 294
 				'post' => $id
295 295
 			);
296
-			return EEH_URL::add_query_args_and_nonce( $query_args, admin_url('admin.php?page=espresso_registrations') );
296
+			return EEH_URL::add_query_args_and_nonce($query_args, admin_url('admin.php?page=espresso_registrations'));
297 297
 		}
298 298
 		return $link;
299 299
 	}
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 		global $nav_menu_selected_id;
306 306
 
307 307
 		$db_fields = false;
308
-		$walker = new Walker_Nav_Menu_Checklist( $db_fields );
308
+		$walker = new Walker_Nav_Menu_Checklist($db_fields);
309 309
 		$current_tab = 'event-archives';
310 310
 
311 311
 		/*if ( ! empty( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) {
@@ -324,9 +324,9 @@  discard block
 block discarded – undo
324 324
 		?>
325 325
 		<div id="posttype-extra-nav-menu-pages" class="posttypediv">
326 326
 			<ul id="posttype-extra-nav-menu-pages-tabs" class="posttype-tabs add-menu-item-tabs">
327
-				<li <?php echo ( 'event-archives' === $current_tab ? ' class="tabs"' : '' ); ?>>
328
-					<a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" href="<?php if ( $nav_menu_selected_id ) {echo esc_url(add_query_arg('extra-nav-menu-pages-tab', 'event-archives', remove_query_arg($removed_args)));} ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives">
329
-						<?php _e( 'Event Archive Pages', 'event_espresso' ); ?>
327
+				<li <?php echo ('event-archives' === $current_tab ? ' class="tabs"' : ''); ?>>
328
+					<a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" href="<?php if ($nav_menu_selected_id) {echo esc_url(add_query_arg('extra-nav-menu-pages-tab', 'event-archives', remove_query_arg($removed_args))); } ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives">
329
+						<?php _e('Event Archive Pages', 'event_espresso'); ?>
330 330
 					</a>
331 331
 				</li>
332 332
 			<?php /* // temporarily removing but leaving skeleton in place in case we ever decide to add more tabs.
@@ -344,13 +344,13 @@  discard block
 block discarded – undo
344 344
  			<?php */ ?>
345 345
 
346 346
 			<div id="tabs-panel-posttype-extra-nav-menu-pages-event-archives" class="tabs-panel <?php
347
-			echo ( 'event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
347
+			echo ('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
348 348
 			?>">
349 349
 				<ul id="extra-nav-menu-pageschecklist-event-archives" class="categorychecklist form-no-clear">
350 350
 					<?php
351 351
 					$pages = $this->_get_extra_nav_menu_pages_items();
352 352
 					$args['walker'] = $walker;
353
-					echo walk_nav_menu_tree( array_map( array( $this, '_setup_extra_nav_menu_pages_items' ), $pages), 0, (object) $args );
353
+					echo walk_nav_menu_tree(array_map(array($this, '_setup_extra_nav_menu_pages_items'), $pages), 0, (object) $args);
354 354
 					?>
355 355
 				</ul>
356 356
 			</div><!-- /.tabs-panel -->
@@ -358,18 +358,18 @@  discard block
 block discarded – undo
358 358
 			<p class="button-controls">
359 359
 				<span class="list-controls">
360 360
 					<a href="<?php
361
-						echo esc_url( add_query_arg(
361
+						echo esc_url(add_query_arg(
362 362
 							array(
363 363
 								'extra-nav-menu-pages-tab' => 'event-archives',
364 364
 								'selectall' => 1,
365 365
 							),
366
-							remove_query_arg( $removed_args )
366
+							remove_query_arg($removed_args)
367 367
 						));
368 368
 					?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All'); ?></a>
369 369
 				</span>
370 370
 
371 371
 				<span class="add-to-menu">
372
-					<input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( __( 'Add to Menu' ) ); ?>" name="add-post-type-menu-item" id="<?php esc_attr_e( 'submit-posttype-extra-nav-menu-pages' ); ?>" />
372
+					<input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e(__('Add to Menu')); ?>" name="add-post-type-menu-item" id="<?php esc_attr_e('submit-posttype-extra-nav-menu-pages'); ?>" />
373 373
 					<span class="spinner"></span>
374 374
 				</span>
375 375
 			</p>
@@ -390,10 +390,10 @@  discard block
 block discarded – undo
390 390
 	private function _get_extra_nav_menu_pages_items() {
391 391
 		$menuitems[] = array(
392 392
 			'title' => __('Event List', 'event_espresso'),
393
-			'url' => get_post_type_archive_link( 'espresso_events' ),
393
+			'url' => get_post_type_archive_link('espresso_events'),
394 394
 			'description' => __('Archive page for all events.', 'event_espresso')
395 395
 		);
396
-		return apply_filters( 'FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems );
396
+		return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems);
397 397
 	}
398 398
 
399 399
 
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 	 * @param $menu_item_values
406 406
 	 * @return stdClass
407 407
 	 */
408
-	private function _setup_extra_nav_menu_pages_items( $menu_item_values ) {
408
+	private function _setup_extra_nav_menu_pages_items($menu_item_values) {
409 409
 		$menu_item = new stdClass();
410 410
 		$keys = array(
411 411
 			'ID' => 0,
@@ -425,8 +425,8 @@  discard block
 block discarded – undo
425 425
 			'xfn' => ''
426 426
 		);
427 427
 
428
-		foreach ( $keys as $key => $value) {
429
-			$menu_item->{$key} = isset( $menu_item_values[ $key]) ? $menu_item_values[ $key] : $value;
428
+		foreach ($keys as $key => $value) {
429
+			$menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value;
430 430
 		}
431 431
 		return $menu_item;
432 432
 	}
@@ -465,9 +465,9 @@  discard block
 block discarded – undo
465 465
 		 * - check if doing post processing of one of EE CPTs
466 466
 		 * - instantiate the corresponding EE CPT model for the post_type being processed.
467 467
 		 */
468
-		if ( isset( $_POST['action'], $_POST['post_type'] ) && $_POST['action'] === 'editpost' ) {
469
-			EE_Registry::instance()->load_core( 'Register_CPTs' );
470
-			EE_Register_CPTs::instantiate_cpt_models( $_POST['post_type'] );
468
+		if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') {
469
+			EE_Registry::instance()->load_core('Register_CPTs');
470
+			EE_Register_CPTs::instantiate_cpt_models($_POST['post_type']);
471 471
 		}
472 472
 
473 473
 
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
          * tab in the EE General Settings Admin page.
478 478
          * This is for user-proofing.
479 479
 		 */
480
-        add_filter( 'wp_dropdown_pages', array( $this, 'modify_dropdown_pages' ) );
480
+        add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages'));
481 481
 
482 482
 	}
483 483
 
@@ -488,25 +488,25 @@  discard block
 block discarded – undo
488 488
 	 * @param string $output  Current output.
489 489
 	 * @return string
490 490
 	 */
491
-	public function modify_dropdown_pages( $output ) {
491
+	public function modify_dropdown_pages($output) {
492 492
 		//get critical pages
493 493
 		$critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
494 494
 
495 495
 		//split current output by line break for easier parsing.
496
-		$split_output = explode( "\n", $output );
496
+		$split_output = explode("\n", $output);
497 497
 
498 498
 		//loop through to remove any critical pages from the array.
499
-		foreach ( $critical_pages as $page_id ) {
500
-			$needle = 'value="' . $page_id . '"';
501
-			foreach( $split_output as $key => $haystack ) {
502
-				if( strpos( $haystack, $needle ) !== false ) {
503
-					unset( $split_output[$key] );
499
+		foreach ($critical_pages as $page_id) {
500
+			$needle = 'value="'.$page_id.'"';
501
+			foreach ($split_output as $key => $haystack) {
502
+				if (strpos($haystack, $needle) !== false) {
503
+					unset($split_output[$key]);
504 504
 				}
505 505
 			}
506 506
 		}
507 507
 
508 508
 		//replace output with the new contents
509
-		return implode( "\n", $split_output );
509
+		return implode("\n", $split_output);
510 510
 	}
511 511
 
512 512
 
@@ -520,36 +520,36 @@  discard block
 block discarded – undo
520 520
 	public function enqueue_admin_scripts() {
521 521
 		// this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.
522 522
 		// Note: the intention of this script is to only do TARGETED injections.  I.E, only injecting on certain script calls.
523
-		wp_enqueue_script('ee-inject-wp', EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE);
523
+		wp_enqueue_script('ee-inject-wp', EE_ADMIN_URL.'assets/ee-cpt-wp-injects.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE);
524 524
 		// register cookie script for future dependencies
525
-		wp_register_script('jquery-cookie', EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js', array('jquery'), '2.1', TRUE );
525
+		wp_register_script('jquery-cookie', EE_THIRD_PARTY_URL.'joyride/jquery.cookie.js', array('jquery'), '2.1', TRUE);
526 526
 		// jquery_validate loading is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again via:  add_filter( 'FHEE_load_jquery_validate', '__return_true' );
527
-		if ( apply_filters( 'FHEE_load_jquery_validate', FALSE ) ) {
527
+		if (apply_filters('FHEE_load_jquery_validate', FALSE)) {
528 528
 			// register jQuery Validate
529
-			wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', array('jquery'), '1.15.0', TRUE);
529
+			wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', array('jquery'), '1.15.0', TRUE);
530 530
 		}
531 531
 		//joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again vai: add_filter('FHEE_load_joyride', '__return_true' );
532
-		if ( apply_filters( 'FHEE_load_joyride', FALSE ) ) {
532
+		if (apply_filters('FHEE_load_joyride', FALSE)) {
533 533
 			//joyride style
534
-			wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1');
535
-			wp_register_style('ee-joyride-css', EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css', array('joyride-css'), EVENT_ESPRESSO_VERSION );
536
-			wp_register_script('joyride-modernizr', EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js', array(), '2.1', TRUE );
534
+			wp_register_style('joyride-css', EE_THIRD_PARTY_URL.'joyride/joyride-2.1.css', array(), '2.1');
535
+			wp_register_style('ee-joyride-css', EE_GLOBAL_ASSETS_URL.'css/ee-joyride-styles.css', array('joyride-css'), EVENT_ESPRESSO_VERSION);
536
+			wp_register_script('joyride-modernizr', EE_THIRD_PARTY_URL.'joyride/modernizr.mq.js', array(), '2.1', TRUE);
537 537
 			//joyride JS
538
-			wp_register_script('jquery-joyride', EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js', array('jquery-cookie', 'joyride-modernizr'), '2.1', TRUE );
538
+			wp_register_script('jquery-joyride', EE_THIRD_PARTY_URL.'joyride/jquery.joyride-2.1.js', array('jquery-cookie', 'joyride-modernizr'), '2.1', TRUE);
539 539
 			// wanna go for a joyride?
540 540
 			wp_enqueue_style('ee-joyride-css');
541 541
 			wp_enqueue_script('jquery-joyride');
542 542
 		}
543 543
 		//qtip is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again via: add_filter('FHEE_load_qtips', '__return_true' );
544
-		if ( apply_filters( 'FHEE_load_qtip', FALSE ) ) {
544
+		if (apply_filters('FHEE_load_qtip', FALSE)) {
545 545
 			EEH_Qtip_Loader::instance()->register_and_enqueue();
546 546
 		}
547 547
 		//accounting.js library
548 548
 		// @link http://josscrowcroft.github.io/accounting.js/
549
-		if ( apply_filters( 'FHEE_load_accounting_js', FALSE ) ) {
550
-			wp_register_script( 'ee-accounting', EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE );
551
-			wp_register_script( 'ee-accounting-core', EE_THIRD_PARTY_URL . 'accounting/accounting.js', array('underscore'), '0.3.2', TRUE );
552
-			wp_enqueue_script( 'ee-accounting' );
549
+		if (apply_filters('FHEE_load_accounting_js', FALSE)) {
550
+			wp_register_script('ee-accounting', EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE);
551
+			wp_register_script('ee-accounting-core', EE_THIRD_PARTY_URL.'accounting/accounting.js', array('underscore'), '0.3.2', TRUE);
552
+			wp_enqueue_script('ee-accounting');
553 553
 			// array of settings to get converted to JSON array via wp_localize_script
554 554
 			$currency_config = array(
555 555
 				'currency' => array(
@@ -596,11 +596,11 @@  discard block
 block discarded – undo
596 596
 	public function get_persistent_admin_notices() {
597 597
 		// http://www.example.com/wp-admin/admin.php?page=espresso_general_settings&action=critical_pages&critical_pages_nonce=2831ce0f30
598 598
 		$args = array(
599
-			'page' => EE_Registry::instance()->REQ->is_set( 'page' ) ? EE_Registry::instance()->REQ->get( 'page' ) : '',
600
-			'action' => EE_Registry::instance()->REQ->is_set( 'action' ) ? EE_Registry::instance()->REQ->get( 'action' ) : '',
599
+			'page' => EE_Registry::instance()->REQ->is_set('page') ? EE_Registry::instance()->REQ->get('page') : '',
600
+			'action' => EE_Registry::instance()->REQ->is_set('action') ? EE_Registry::instance()->REQ->get('action') : '',
601 601
 		);
602
-		$return_url = EE_Admin_Page::add_query_args_and_nonce( $args, EE_ADMIN_URL );
603
-		echo EE_Error::get_persistent_admin_notices( $return_url );
602
+		$return_url = EE_Admin_Page::add_query_args_and_nonce($args, EE_ADMIN_URL);
603
+		echo EE_Error::get_persistent_admin_notices($return_url);
604 604
 	}
605 605
 
606 606
 
@@ -625,24 +625,24 @@  discard block
 block discarded – undo
625 625
 	public function dashboard_glance_items($elements) {
626 626
         $elements = is_array($elements) ? $elements : array($elements);
627 627
 		$events = EEM_Event::instance()->count();
628
-		$items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce( array('page' => 'espresso_events'), admin_url('admin.php') );
629
-		$items['events']['text'] = sprintf( _n( '%s Event', '%s Events', $events ), number_format_i18n( $events ) );
628
+		$items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_events'), admin_url('admin.php'));
629
+		$items['events']['text'] = sprintf(_n('%s Event', '%s Events', $events), number_format_i18n($events));
630 630
 		$items['events']['title'] = __('Click to view all Events', 'event_espresso');
631 631
 		$registrations = EEM_Registration::instance()->count(
632 632
 			array(
633 633
 				array(
634
-					'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete )
634
+					'STS_ID' => array('!=', EEM_Registration::status_id_incomplete)
635 635
 				)
636 636
 			)
637 637
 		);
638
-		$items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( array('page' => 'espresso_registrations' ), admin_url('admin.php') );
639
-		$items['registrations']['text'] = sprintf( _n( '%s Registration', '%s Registrations', $registrations ), number_format_i18n($registrations) );
638
+		$items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_registrations'), admin_url('admin.php'));
639
+		$items['registrations']['text'] = sprintf(_n('%s Registration', '%s Registrations', $registrations), number_format_i18n($registrations));
640 640
 		$items['registrations']['title'] = __('Click to view all registrations', 'event_espresso');
641 641
 
642
-		$items = (array) apply_filters( 'FHEE__EE_Admin__dashboard_glance_items__items', $items );
642
+		$items = (array) apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
643 643
 
644
-		foreach ( $items as $type => $item_properties ) {
645
-			$elements[] = sprintf( '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', $item_properties['url'], $item_properties['title'], $item_properties['text'] );
644
+		foreach ($items as $type => $item_properties) {
645
+			$elements[] = sprintf('<a class="ee-dashboard-link-'.$type.'" href="%s" title="%s">%s</a>', $item_properties['url'], $item_properties['title'], $item_properties['text']);
646 646
 		}
647 647
 		return $elements;
648 648
 	}
@@ -659,31 +659,31 @@  discard block
 block discarded – undo
659 659
 	 * @throws EE_Error
660 660
 	 * @return    string
661 661
 	 */
662
-	public function check_for_invalid_datetime_formats( $value, $option ) {
662
+	public function check_for_invalid_datetime_formats($value, $option) {
663 663
 		// check for date_format or time_format
664
-		switch ( $option ) {
664
+		switch ($option) {
665 665
 			case 'date_format' :
666
-				$date_time_format = $value . ' ' . get_option('time_format');
666
+				$date_time_format = $value.' '.get_option('time_format');
667 667
 				break;
668 668
 			case 'time_format' :
669
-				$date_time_format = get_option('date_format') . ' ' . $value;
669
+				$date_time_format = get_option('date_format').' '.$value;
670 670
 				break;
671 671
 			default :
672 672
 				$date_time_format = FALSE;
673 673
 		}
674 674
 		// do we have a date_time format to check ?
675
-		if ( $date_time_format ) {
676
-			$error_msg = EEH_DTT_Helper::validate_format_string( $date_time_format );
675
+		if ($date_time_format) {
676
+			$error_msg = EEH_DTT_Helper::validate_format_string($date_time_format);
677 677
 
678
-			if ( is_array( $error_msg ) ) {
679
-				$msg = '<p>' . sprintf( __( 'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', 'event_espresso' ), date( $date_time_format ) , $date_time_format  ) . '</p><p><ul>';
678
+			if (is_array($error_msg)) {
679
+				$msg = '<p>'.sprintf(__('The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', 'event_espresso'), date($date_time_format), $date_time_format).'</p><p><ul>';
680 680
 
681 681
 
682
-				foreach ( $error_msg as $error ) {
683
-					$msg .= '<li>' . $error . '</li>';
682
+				foreach ($error_msg as $error) {
683
+					$msg .= '<li>'.$error.'</li>';
684 684
 				}
685 685
 
686
-				$msg .= '</ul></p><p>' . sprintf( __( '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', 'event_espresso' ), '<span style="color:#D54E21;">', '</span>' ) . '</p>';
686
+				$msg .= '</ul></p><p>'.sprintf(__('%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', 'event_espresso'), '<span style="color:#D54E21;">', '</span>').'</p>';
687 687
 
688 688
 				// trigger WP settings error
689 689
 				add_settings_error(
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
 				);
694 694
 
695 695
 				// set format to something valid
696
-				switch ( $option ) {
696
+				switch ($option) {
697 697
 					case 'date_format' :
698 698
 						$value = 'F j, Y';
699 699
 						break;
@@ -715,8 +715,8 @@  discard block
 block discarded – undo
715 715
 	 * @param $content
716 716
 	 * @return    string
717 717
 	 */
718
-	public function its_eSpresso( $content ) {
719
-		return str_replace( '[EXPRESSO_', '[ESPRESSO_', $content );
718
+	public function its_eSpresso($content) {
719
+		return str_replace('[EXPRESSO_', '[ESPRESSO_', $content);
720 720
 	}
721 721
 
722 722
 
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
 	 *  @return 	string
729 729
 	 */
730 730
 	public function espresso_admin_footer() {
731
-		return \EEH_Template::powered_by_event_espresso( 'aln-cntr', '', array( 'utm_content' => 'admin_footer' ));
731
+		return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer'));
732 732
 	}
733 733
 
734 734
 
@@ -747,12 +747,12 @@  discard block
 block discarded – undo
747 747
 	 * @param array $config
748 748
 	 * @return void
749 749
 	 */
750
-	public static function register_ee_admin_page( $page_basename, $page_path, $config = array() ) {
751
-		EE_Error::doing_it_wrong( __METHOD__, sprintf( __('Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.', 'event_espresso'), $page_basename), '4.3' );
752
-		if ( class_exists( 'EE_Register_Admin_Page' ) ) {
750
+	public static function register_ee_admin_page($page_basename, $page_path, $config = array()) {
751
+		EE_Error::doing_it_wrong(__METHOD__, sprintf(__('Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.', 'event_espresso'), $page_basename), '4.3');
752
+		if (class_exists('EE_Register_Admin_Page')) {
753 753
 			$config['page_path'] = $page_path;
754 754
 		}
755
-		EE_Register_Admin_Page::register( $page_basename, $config );
755
+		EE_Register_Admin_Page::register($page_basename, $config);
756 756
 
757 757
 	}
758 758
 
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
 	 * @param  \WP_Post $post
766 766
 	 * @return void
767 767
 	 */
768
-	public static function parse_post_content_on_save( $post_ID, $post ) {
768
+	public static function parse_post_content_on_save($post_ID, $post) {
769 769
 		EE_Error::doing_it_wrong(
770 770
 			__METHOD__,
771 771
 			__('Usage is deprecated', 'event_espresso'),
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
 	 * @param  $value
784 784
 	 * @return void
785 785
 	 */
786
-	public function reset_page_for_posts_on_change( $option, $old_value, $value ) {
786
+	public function reset_page_for_posts_on_change($option, $old_value, $value) {
787 787
 		EE_Error::doing_it_wrong(
788 788
 			__METHOD__,
789 789
 			__('Usage is deprecated', 'event_espresso'),
Please login to merge, or discard this patch.
core/domain/entities/shortcodes/EspressoEvents.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@
 block discarded – undo
108 108
     private function getAttributes(array $attributes)
109 109
     {
110 110
         return array_merge(
111
-            (array)apply_filters(
111
+            (array) apply_filters(
112 112
                 'EES_Espresso_Events__process_shortcode__default_espresso_events_shortcode_atts',
113 113
                 array(
114 114
                     'title'         => '',
Please login to merge, or discard this patch.
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -34,133 +34,133 @@
 block discarded – undo
34 34
 
35 35
 
36 36
 
37
-    /**
38
-     * the actual shortcode tag that gets registered with WordPress
39
-     *
40
-     * @return string
41
-     */
42
-    public function getTag()
43
-    {
44
-        return 'ESPRESSO_EVENTS';
45
-    }
46
-
47
-
48
-
49
-    /**
50
-     * the time in seconds to cache the results of the processShortcode() method
51
-     * 0 means the processShortcode() results will NOT be cached at all
52
-     *
53
-     * @return int
54
-     */
55
-    public function cacheExpiration()
56
-    {
57
-        return MINUTE_IN_SECONDS * 15;
58
-    }
59
-
60
-
61
-
62
-    /**
63
-     * a place for adding any initialization code that needs to run prior to wp_header().
64
-     * this may be required for shortcodes that utilize a corresponding module,
65
-     * and need to enqueue assets for that module
66
-     *
67
-     * @return void
68
-     */
69
-    public function initializeShortcode()
70
-    {
71
-        EED_Events_Archive::instance()->event_list();
72
-    }
73
-
74
-
75
-
76
-    /**
77
-     * callback that runs when the shortcode is encountered in post content.
78
-     * IMPORTANT !!!
79
-     * remember that shortcode content should be RETURNED and NOT echoed out
80
-     *
81
-     * @param array $attributes
82
-     * @return string
83
-     */
84
-    public function processShortcode($attributes = array())
85
-    {
86
-        // grab attributes and merge with defaults
87
-        $attributes = $this->getAttributes($attributes);
88
-        // make sure we use the_excerpt()
89
-        add_filter('FHEE__EES_Espresso_Events__process_shortcode__true', '__return_true');
90
-        // apply query filters
91
-        add_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true');
92
-        // run the query
93
-        global $wp_query;
94
-        // yes we have to overwrite the main wp query, but it's ok...
95
-        // we're going to reset it again below, so everything will be Hunky Dory (amazing album)
96
-        $wp_query = new EventListQuery($attributes);
97
-        // check what template is loaded and load filters accordingly
98
-        EED_Events_Archive::instance()->template_include('loop-espresso_events.php');
99
-        // load our template
100
-        $event_list = EEH_Template::locate_template('loop-espresso_events.php', array(), true, true);
101
-        // now reset the query and postdata
102
-        wp_reset_query();
103
-        wp_reset_postdata();
104
-        EED_Events_Archive::remove_all_events_archive_filters();
105
-        // remove query filters
106
-        remove_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true');
107
-        // pull our content from the output buffer and return it
108
-        return $event_list;
109
-    }
110
-
111
-
112
-
113
-    /**
114
-     * merge incoming attributes with filtered defaults
115
-     *
116
-     * @param array $attributes
117
-     * @return array
118
-     */
119
-    private function getAttributes(array $attributes)
120
-    {
121
-        return array_merge(
122
-            (array)apply_filters(
123
-                'EES_Espresso_Events__process_shortcode__default_espresso_events_shortcode_atts',
124
-                array(
125
-                    'title'         => '',
126
-                    'limit'         => 10,
127
-                    'css_class'     => '',
128
-                    'show_expired'  => false,
129
-                    'month'         => '',
130
-                    'category_slug' => '',
131
-                    'order_by'      => 'start_date',
132
-                    'sort'          => 'ASC',
133
-                    'show_title'    => true,
134
-                )
135
-            ),
136
-            $attributes
137
-        );
138
-    }
139
-
140
-
141
-
142
-    /**
143
-     * array for defining custom attribute sanitization callbacks,
144
-     * where keys match keys in your attributes array,
145
-     * and values represent the sanitization function you wish to be applied to that attribute.
146
-     * So for example, if you had an integer attribute named "event_id"
147
-     * that you wanted to be sanitized using absint(),
148
-     * then you would pass the following for your $custom_sanitization array:
149
-     *      array('event_id' => 'absint')
150
-     *
151
-     * @return array
152
-     */
153
-    protected function customAttributeSanitizationMap()
154
-    {
155
-        // the following get sanitized/whitelisted in EEH_Event_Query
156
-        return array(
157
-            'category_slug' => 'skip_sanitization',
158
-            'show_expired'  => 'skip_sanitization',
159
-            'order_by'      => 'skip_sanitization',
160
-            'month'         => 'skip_sanitization',
161
-            'sort'          => 'skip_sanitization',
162
-        );
163
-    }
37
+	/**
38
+	 * the actual shortcode tag that gets registered with WordPress
39
+	 *
40
+	 * @return string
41
+	 */
42
+	public function getTag()
43
+	{
44
+		return 'ESPRESSO_EVENTS';
45
+	}
46
+
47
+
48
+
49
+	/**
50
+	 * the time in seconds to cache the results of the processShortcode() method
51
+	 * 0 means the processShortcode() results will NOT be cached at all
52
+	 *
53
+	 * @return int
54
+	 */
55
+	public function cacheExpiration()
56
+	{
57
+		return MINUTE_IN_SECONDS * 15;
58
+	}
59
+
60
+
61
+
62
+	/**
63
+	 * a place for adding any initialization code that needs to run prior to wp_header().
64
+	 * this may be required for shortcodes that utilize a corresponding module,
65
+	 * and need to enqueue assets for that module
66
+	 *
67
+	 * @return void
68
+	 */
69
+	public function initializeShortcode()
70
+	{
71
+		EED_Events_Archive::instance()->event_list();
72
+	}
73
+
74
+
75
+
76
+	/**
77
+	 * callback that runs when the shortcode is encountered in post content.
78
+	 * IMPORTANT !!!
79
+	 * remember that shortcode content should be RETURNED and NOT echoed out
80
+	 *
81
+	 * @param array $attributes
82
+	 * @return string
83
+	 */
84
+	public function processShortcode($attributes = array())
85
+	{
86
+		// grab attributes and merge with defaults
87
+		$attributes = $this->getAttributes($attributes);
88
+		// make sure we use the_excerpt()
89
+		add_filter('FHEE__EES_Espresso_Events__process_shortcode__true', '__return_true');
90
+		// apply query filters
91
+		add_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true');
92
+		// run the query
93
+		global $wp_query;
94
+		// yes we have to overwrite the main wp query, but it's ok...
95
+		// we're going to reset it again below, so everything will be Hunky Dory (amazing album)
96
+		$wp_query = new EventListQuery($attributes);
97
+		// check what template is loaded and load filters accordingly
98
+		EED_Events_Archive::instance()->template_include('loop-espresso_events.php');
99
+		// load our template
100
+		$event_list = EEH_Template::locate_template('loop-espresso_events.php', array(), true, true);
101
+		// now reset the query and postdata
102
+		wp_reset_query();
103
+		wp_reset_postdata();
104
+		EED_Events_Archive::remove_all_events_archive_filters();
105
+		// remove query filters
106
+		remove_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true');
107
+		// pull our content from the output buffer and return it
108
+		return $event_list;
109
+	}
110
+
111
+
112
+
113
+	/**
114
+	 * merge incoming attributes with filtered defaults
115
+	 *
116
+	 * @param array $attributes
117
+	 * @return array
118
+	 */
119
+	private function getAttributes(array $attributes)
120
+	{
121
+		return array_merge(
122
+			(array)apply_filters(
123
+				'EES_Espresso_Events__process_shortcode__default_espresso_events_shortcode_atts',
124
+				array(
125
+					'title'         => '',
126
+					'limit'         => 10,
127
+					'css_class'     => '',
128
+					'show_expired'  => false,
129
+					'month'         => '',
130
+					'category_slug' => '',
131
+					'order_by'      => 'start_date',
132
+					'sort'          => 'ASC',
133
+					'show_title'    => true,
134
+				)
135
+			),
136
+			$attributes
137
+		);
138
+	}
139
+
140
+
141
+
142
+	/**
143
+	 * array for defining custom attribute sanitization callbacks,
144
+	 * where keys match keys in your attributes array,
145
+	 * and values represent the sanitization function you wish to be applied to that attribute.
146
+	 * So for example, if you had an integer attribute named "event_id"
147
+	 * that you wanted to be sanitized using absint(),
148
+	 * then you would pass the following for your $custom_sanitization array:
149
+	 *      array('event_id' => 'absint')
150
+	 *
151
+	 * @return array
152
+	 */
153
+	protected function customAttributeSanitizationMap()
154
+	{
155
+		// the following get sanitized/whitelisted in EEH_Event_Query
156
+		return array(
157
+			'category_slug' => 'skip_sanitization',
158
+			'show_expired'  => 'skip_sanitization',
159
+			'order_by'      => 'skip_sanitization',
160
+			'month'         => 'skip_sanitization',
161
+			'sort'          => 'skip_sanitization',
162
+		);
163
+	}
164 164
 
165 165
 
166 166
 
Please login to merge, or discard this patch.