Completed
Branch FET-11146-improve-messages-dat... (304d27)
by
unknown
113:38 queued 102:27
created
core/domain/services/capabilities/RequiresCapCheckInterface.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -16,10 +16,10 @@
 block discarded – undo
16 16
 interface RequiresCapCheckInterface
17 17
 {
18 18
 
19
-    /**
20
-     * @return CapCheckInterface
21
-     */
22
-    public function getCapCheck();
19
+	/**
20
+	 * @return CapCheckInterface
21
+	 */
22
+	public function getCapCheck();
23 23
 
24 24
 }
25 25
 // End of file RequiresCapCheckInterface.php
Please login to merge, or discard this patch.
4_5_0_stages/EE_DMS_4_5_0_invoice_settings.dmsstage.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -51,15 +51,15 @@  discard block
 block discarded – undo
51 51
 
52 52
 
53 53
 
54
-    /**
55
-     *    _migration_step
56
-     *
57
-     * @access protected
58
-     * @param int $num_items
59
-     * @throws EE_Error
60
-     * @return int number of items ACTUALLY migrated
61
-     * @throws InvalidDataTypeException
62
-     */
54
+	/**
55
+	 *    _migration_step
56
+	 *
57
+	 * @access protected
58
+	 * @param int $num_items
59
+	 * @throws EE_Error
60
+	 * @return int number of items ACTUALLY migrated
61
+	 * @throws InvalidDataTypeException
62
+	 */
63 63
 	protected function _migration_step( $num_items = 1 ){
64 64
 		// if this isn't set then something is really wrong
65 65
 		if ( ! EE_Config::instance()->gateway instanceof EE_Gateway_Config ) {
@@ -86,29 +86,29 @@  discard block
 block discarded – undo
86 86
 			//update them from a DMS, we'd need to have the DMS create the message templates which is quite a lot of code;
87 87
 			//also we don't want to build a dependency on the messages code because it is likely to change soon
88 88
 			if( ! in_array( $invoice_settings[ 'invoice_css' ], array( '', 'simple.css' ) ) ){
89
-                new PersistentAdminNotice(
90
-                    'invoice_css_not_updated',
91
-                    sprintf(
92
-                        esc_html__(
93
-                            'You had previously set your Invoice Payment Method\'s stylesheet to be %1$s, but that setting has moved. PDF and HTML Invoices and Receipts are now Messages, which means you can easily modify them from your Wordpress Dashboard instead of using filters or uploading template files. Please visit Messages -> Receipt and Messages -> Invoice to change their stylesheets.',
94
-                            'event_espresso'
95
-                        ),
96
-                        $invoice_settings['invoice_css']
97
-                    )
98
-                );
89
+				new PersistentAdminNotice(
90
+					'invoice_css_not_updated',
91
+					sprintf(
92
+						esc_html__(
93
+							'You had previously set your Invoice Payment Method\'s stylesheet to be %1$s, but that setting has moved. PDF and HTML Invoices and Receipts are now Messages, which means you can easily modify them from your Wordpress Dashboard instead of using filters or uploading template files. Please visit Messages -> Receipt and Messages -> Invoice to change their stylesheets.',
94
+							'event_espresso'
95
+						),
96
+						$invoice_settings['invoice_css']
97
+					)
98
+				);
99 99
 			}
100 100
 			$templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
101 101
 			$overridden_invoice_body = EEH_Template::locate_template( $templates_relative_path . 'invoice_body.template.php', NULL, FALSE, FALSE, TRUE );
102 102
 			$overridden_receipt_body= EEH_Template::locate_template( $templates_relative_path . 'receipt_body.template.php', NULL, FALSE, FALSE, TRUE );
103 103
 			if( $overridden_invoice_body || $overridden_receipt_body ) {
104
-                new PersistentAdminNotice(
105
-                    'invoice_overriding_templates',
106
-                    esc_html__(
107
-                        'Note: in this version of Event Espresso, PDF and HTML Invoices and Receipts are now Messages and can be changed just like any other messages; however we noticed you had previously overridden the old default Invoice/Receipt templates. Because of this, your old Invoice/Receipt templates will continue to be used INSTEAD of the new Invoice/Receipt message equivalents. We recommend deleting your old Invoice/Receipt templates and modifying the new Invoice and Receipt messages\'s content in Messages -> Invoice and Messages -> Receipt.',
108
-                        'event_espresso'
109
-                    ),
110
-                    true
111
-                );
104
+				new PersistentAdminNotice(
105
+					'invoice_overriding_templates',
106
+					esc_html__(
107
+						'Note: in this version of Event Espresso, PDF and HTML Invoices and Receipts are now Messages and can be changed just like any other messages; however we noticed you had previously overridden the old default Invoice/Receipt templates. Because of this, your old Invoice/Receipt templates will continue to be used INSTEAD of the new Invoice/Receipt message equivalents. We recommend deleting your old Invoice/Receipt templates and modifying the new Invoice and Receipt messages\'s content in Messages -> Invoice and Messages -> Receipt.',
108
+						'event_espresso'
109
+					),
110
+					true
111
+				);
112 112
 			}
113 113
 
114 114
 		}
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 * Just initializes the status of the migration
33 33
 	 */
34 34
 	public function __construct() {
35
-		$this->_pretty_name = __( 'Update Invoice Gateway Settings', 'event_espresso' );
35
+		$this->_pretty_name = __('Update Invoice Gateway Settings', 'event_espresso');
36 36
 		parent::__construct();
37 37
 	}
38 38
 
@@ -60,32 +60,32 @@  discard block
 block discarded – undo
60 60
      * @return int number of items ACTUALLY migrated
61 61
      * @throws InvalidDataTypeException
62 62
      */
63
-	protected function _migration_step( $num_items = 1 ){
63
+	protected function _migration_step($num_items = 1) {
64 64
 		// if this isn't set then something is really wrong
65
-		if ( ! EE_Config::instance()->gateway instanceof EE_Gateway_Config ) {
66
-			throw new EE_Error( __( 'It appears the Event Espresso Core Configuration is not setup correctly.', 'event_espresso' ));
65
+		if ( ! EE_Config::instance()->gateway instanceof EE_Gateway_Config) {
66
+			throw new EE_Error(__('It appears the Event Espresso Core Configuration is not setup correctly.', 'event_espresso'));
67 67
 		}
68
-		$invoice_settings = isset( EE_Config::instance()->gateway->payment_settings[ 'Invoice' ] ) ? EE_Config::instance()->gateway->payment_settings[ 'Invoice' ] : NULL;
69
-		if( ! $invoice_settings ){
70
-			$this->add_error( __( 'Could not migrate EE4.4 invoice settings to EE4.5 because they didnt exist', 'event_espresso' ) );
71
-		}else{
72
-			$invoice_settings[ 'template_payment_instructions' ] = $invoice_settings[ 'pdf_instructions' ];
73
-			$invoice_settings[ 'template_invoice_payee_name' ] = $invoice_settings[ 'payable_to' ];
74
-			$invoice_settings[ 'template_invoice_address' ] = $invoice_settings[ 'payment_address' ];
75
-			$invoice_settings[ 'template_invoice_email' ] = '';
76
-			$invoice_settings[ 'template_invoice_tax_number' ] = '';
77
-			unset( $invoice_settings[ 'pdf_instructions' ] );
78
-			unset( $invoice_settings[ 'payable_to' ] );
79
-			unset( $invoice_settings[ 'payment_address' ] );
80
-			EE_Config::instance()->gateway->payment_settings[ 'Invoice' ] = $invoice_settings;
81
-			EE_Config::instance()->update_espresso_config(false,false);
68
+		$invoice_settings = isset(EE_Config::instance()->gateway->payment_settings['Invoice']) ? EE_Config::instance()->gateway->payment_settings['Invoice'] : NULL;
69
+		if ( ! $invoice_settings) {
70
+			$this->add_error(__('Could not migrate EE4.4 invoice settings to EE4.5 because they didnt exist', 'event_espresso'));
71
+		} else {
72
+			$invoice_settings['template_payment_instructions'] = $invoice_settings['pdf_instructions'];
73
+			$invoice_settings['template_invoice_payee_name'] = $invoice_settings['payable_to'];
74
+			$invoice_settings['template_invoice_address'] = $invoice_settings['payment_address'];
75
+			$invoice_settings['template_invoice_email'] = '';
76
+			$invoice_settings['template_invoice_tax_number'] = '';
77
+			unset($invoice_settings['pdf_instructions']);
78
+			unset($invoice_settings['payable_to']);
79
+			unset($invoice_settings['payment_address']);
80
+			EE_Config::instance()->gateway->payment_settings['Invoice'] = $invoice_settings;
81
+			EE_Config::instance()->update_espresso_config(false, false);
82 82
 
83 83
 			//@todo: check 'invoice_css' too because we can't easily affect that so we might need to set a persistent notice
84 84
 			//(why is it tough to change? because we want to update the receipt and invoice message template, but
85 85
 			//message templates are only initialized AFTER migrations and those two are new in 4.5. So if we wanted to
86 86
 			//update them from a DMS, we'd need to have the DMS create the message templates which is quite a lot of code;
87 87
 			//also we don't want to build a dependency on the messages code because it is likely to change soon
88
-			if( ! in_array( $invoice_settings[ 'invoice_css' ], array( '', 'simple.css' ) ) ){
88
+			if ( ! in_array($invoice_settings['invoice_css'], array('', 'simple.css'))) {
89 89
                 new PersistentAdminNotice(
90 90
                     'invoice_css_not_updated',
91 91
                     sprintf(
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
                 );
99 99
 			}
100 100
 			$templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
101
-			$overridden_invoice_body = EEH_Template::locate_template( $templates_relative_path . 'invoice_body.template.php', NULL, FALSE, FALSE, TRUE );
102
-			$overridden_receipt_body= EEH_Template::locate_template( $templates_relative_path . 'receipt_body.template.php', NULL, FALSE, FALSE, TRUE );
103
-			if( $overridden_invoice_body || $overridden_receipt_body ) {
101
+			$overridden_invoice_body = EEH_Template::locate_template($templates_relative_path.'invoice_body.template.php', NULL, FALSE, FALSE, TRUE);
102
+			$overridden_receipt_body = EEH_Template::locate_template($templates_relative_path.'receipt_body.template.php', NULL, FALSE, FALSE, TRUE);
103
+			if ($overridden_invoice_body || $overridden_receipt_body) {
104 104
                 new PersistentAdminNotice(
105 105
                     'invoice_overriding_templates',
106 106
                     esc_html__(
Please login to merge, or discard this patch.
4_6_0_stages/EE_DMS_4_6_0_invoice_settings.dmsstage.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -49,29 +49,29 @@
 block discarded – undo
49 49
 
50 50
 
51 51
 
52
-    /**
53
-     *    _migration_step
54
-     *
55
-     * @access protected
56
-     * @param int $num_items
57
-     * @throws EE_Error
58
-     * @return int number of items ACTUALLY migrated
59
-     * @throws InvalidDataTypeException
60
-     */
52
+	/**
53
+	 *    _migration_step
54
+	 *
55
+	 * @access protected
56
+	 * @param int $num_items
57
+	 * @throws EE_Error
58
+	 * @return int number of items ACTUALLY migrated
59
+	 * @throws InvalidDataTypeException
60
+	 */
61 61
 	protected function _migration_step( $num_items = 1 ){
62 62
 
63 63
 		$templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
64 64
 		$overridden_invoice_body = EEH_Template::locate_template( $templates_relative_path . 'invoice_body.template.php', NULL, FALSE, FALSE, TRUE );
65 65
 		$overridden_receipt_body= EEH_Template::locate_template( $templates_relative_path . 'receipt_body.template.php', NULL, FALSE, FALSE, TRUE );
66 66
 		if( $overridden_invoice_body || $overridden_receipt_body ) {
67
-            new PersistentAdminNotice(
68
-                'invoice_overriding_templates',
69
-                esc_html__(
70
-                    'Note: in this version of Event Espresso, PDF and HTML Invoices and Receipts are now Messages and can be changed just like any other messages; however we noticed you had previously overridden the old default Invoice/Receipt templates. Because of this, your old Invoice/Receipt templates will continue to be used INSTEAD of the new Invoice/Receipt message equivalents (but this will be removed in an upcoming version). We recommend deleting your old Invoice/Receipt templates and using the new messages system. Then modify the new Invoice and Receipt messages\'s content in Messages -> Invoice and Messages -> Receipt.',
71
-                    'event_espresso'
72
-                ),
73
-                true
74
-            );
67
+			new PersistentAdminNotice(
68
+				'invoice_overriding_templates',
69
+				esc_html__(
70
+					'Note: in this version of Event Espresso, PDF and HTML Invoices and Receipts are now Messages and can be changed just like any other messages; however we noticed you had previously overridden the old default Invoice/Receipt templates. Because of this, your old Invoice/Receipt templates will continue to be used INSTEAD of the new Invoice/Receipt message equivalents (but this will be removed in an upcoming version). We recommend deleting your old Invoice/Receipt templates and using the new messages system. Then modify the new Invoice and Receipt messages\'s content in Messages -> Invoice and Messages -> Receipt.',
71
+					'event_espresso'
72
+				),
73
+				true
74
+			);
75 75
 		}
76 76
 
77 77
 		//regardless of whether it worked or not, we ought to continue the migration
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 * Just initializes the status of the migration
31 31
 	 */
32 32
 	public function __construct() {
33
-		$this->_pretty_name = __( 'Update Invoice Settings', 'event_espresso' );
33
+		$this->_pretty_name = __('Update Invoice Settings', 'event_espresso');
34 34
 		parent::__construct();
35 35
 	}
36 36
 
@@ -58,12 +58,12 @@  discard block
 block discarded – undo
58 58
      * @return int number of items ACTUALLY migrated
59 59
      * @throws InvalidDataTypeException
60 60
      */
61
-	protected function _migration_step( $num_items = 1 ){
61
+	protected function _migration_step($num_items = 1) {
62 62
 
63 63
 		$templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
64
-		$overridden_invoice_body = EEH_Template::locate_template( $templates_relative_path . 'invoice_body.template.php', NULL, FALSE, FALSE, TRUE );
65
-		$overridden_receipt_body= EEH_Template::locate_template( $templates_relative_path . 'receipt_body.template.php', NULL, FALSE, FALSE, TRUE );
66
-		if( $overridden_invoice_body || $overridden_receipt_body ) {
64
+		$overridden_invoice_body = EEH_Template::locate_template($templates_relative_path.'invoice_body.template.php', NULL, FALSE, FALSE, TRUE);
65
+		$overridden_receipt_body = EEH_Template::locate_template($templates_relative_path.'receipt_body.template.php', NULL, FALSE, FALSE, TRUE);
66
+		if ($overridden_invoice_body || $overridden_receipt_body) {
67 67
             new PersistentAdminNotice(
68 68
                 'invoice_overriding_templates',
69 69
                 esc_html__(
Please login to merge, or discard this patch.
core/services/container/CoffeeMill.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -18,65 +18,65 @@
 block discarded – undo
18 18
 class CoffeeMill
19 19
 {
20 20
 
21
-    /**
22
-     * @var CoffeeShop $coffee_shop
23
-     */
24
-    private static $coffee_shop;
25
-
26
-
27
-
28
-    /**
29
-     * @return mixed
30
-     */
31
-    public static function getCoffeeShop()
32
-    {
33
-        return self::$coffee_shop;
34
-    }
35
-
36
-
37
-
38
-    /**
39
-     * @param CoffeeShop $coffee_shop
40
-     */
41
-    public static function setCoffeeShop(CoffeeShop $coffee_shop)
42
-    {
43
-        self::$coffee_shop = $coffee_shop;
44
-    }
45
-
46
-
47
-
48
-    /**
49
-     * @param string $identifier
50
-     * @param array  $arguments
51
-     * @param string $type
52
-     * @return mixed
53
-     * @throws ServiceNotFoundException
54
-     */
55
-    public static function createNew($identifier, $arguments = array(), $type = CoffeeMaker::BREW_NEW)
56
-    {
57
-        return self::$coffee_shop->brew($identifier, $arguments, $type);
58
-    }
59
-
60
-
61
-
62
-    /**
63
-     * IMPORTANT!!!
64
-     * Usage of this method is discouraged as it promotes service location.
65
-     * It's current use is only as a stop gap measure until the CoffeeShop
66
-     * Dependency Injection Container can be implemented properly for all classes.
67
-     * If it is at all possible, inject your dependencies via your class constructor.
68
-     * This method WILL BE DEPRECATED at some point in the near future.
69
-     *
70
-     * @param string $identifier
71
-     * @param array  $arguments
72
-     * @param string $type
73
-     * @return mixed
74
-     * @throws ServiceNotFoundException
75
-     */
76
-    public static function getService($identifier, $arguments = array(), $type = CoffeeMaker::BREW_SHARED)
77
-    {
78
-        return self::$coffee_shop->brew($identifier, $arguments, $type);
79
-    }
21
+	/**
22
+	 * @var CoffeeShop $coffee_shop
23
+	 */
24
+	private static $coffee_shop;
25
+
26
+
27
+
28
+	/**
29
+	 * @return mixed
30
+	 */
31
+	public static function getCoffeeShop()
32
+	{
33
+		return self::$coffee_shop;
34
+	}
35
+
36
+
37
+
38
+	/**
39
+	 * @param CoffeeShop $coffee_shop
40
+	 */
41
+	public static function setCoffeeShop(CoffeeShop $coffee_shop)
42
+	{
43
+		self::$coffee_shop = $coffee_shop;
44
+	}
45
+
46
+
47
+
48
+	/**
49
+	 * @param string $identifier
50
+	 * @param array  $arguments
51
+	 * @param string $type
52
+	 * @return mixed
53
+	 * @throws ServiceNotFoundException
54
+	 */
55
+	public static function createNew($identifier, $arguments = array(), $type = CoffeeMaker::BREW_NEW)
56
+	{
57
+		return self::$coffee_shop->brew($identifier, $arguments, $type);
58
+	}
59
+
60
+
61
+
62
+	/**
63
+	 * IMPORTANT!!!
64
+	 * Usage of this method is discouraged as it promotes service location.
65
+	 * It's current use is only as a stop gap measure until the CoffeeShop
66
+	 * Dependency Injection Container can be implemented properly for all classes.
67
+	 * If it is at all possible, inject your dependencies via your class constructor.
68
+	 * This method WILL BE DEPRECATED at some point in the near future.
69
+	 *
70
+	 * @param string $identifier
71
+	 * @param array  $arguments
72
+	 * @param string $type
73
+	 * @return mixed
74
+	 * @throws ServiceNotFoundException
75
+	 */
76
+	public static function getService($identifier, $arguments = array(), $type = CoffeeMaker::BREW_SHARED)
77
+	{
78
+		return self::$coffee_shop->brew($identifier, $arguments, $type);
79
+	}
80 80
 
81 81
 }
82 82
 // End of file CoffeeMill.php
Please login to merge, or discard this patch.
core/domain/services/capabilities/CapCheck.php 1 patch
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 use EventEspresso\core\exceptions\InvalidDataTypeException;
5 5
 
6 6
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
7
-    exit('No direct script access allowed');
7
+	exit('No direct script access allowed');
8 8
 }
9 9
 
10 10
 
@@ -20,72 +20,72 @@  discard block
 block discarded – undo
20 20
 class CapCheck implements CapCheckInterface
21 21
 {
22 22
 
23
-    /**
24
-     * @var string|array $capability
25
-     */
26
-    private $capability;
27
-
28
-    /**
29
-     * @var string $context
30
-     */
31
-    private $context;
32
-
33
-    /**
34
-     * @var int|string $ID
35
-     */
36
-    private $ID;
37
-
38
-
39
-
40
-    /**
41
-     * @param string|array $capability   - the capability to be checked, like: 'ee_edit_registrations',
42
-     *                                   or an array of capability strings
43
-     * @param string       $context      - what the user is attempting to do, like: 'Edit Registration'
44
-     * @param int          $ID           - (optional) ID for item where current_user_can is being called from
45
-     * @throws InvalidDataTypeException
46
-     */
47
-    public function __construct($capability, $context, $ID = 0)
48
-    {
49
-        if ( ! (is_string($capability) || is_array($capability))) {
50
-            throw new InvalidDataTypeException('$capability', $capability, 'string or array');
51
-        }
52
-        if ( ! is_string($context)) {
53
-            throw new InvalidDataTypeException('$context', $context, 'string');
54
-        }
55
-        $this->capability = $capability;
56
-        $this->context = strtolower(str_replace(' ', '_', $context));
57
-        $this->ID = $ID;
58
-    }
59
-
60
-
61
-
62
-    /**
63
-     * @return string|array
64
-     */
65
-    public function capability()
66
-    {
67
-        return $this->capability;
68
-    }
69
-
70
-
71
-
72
-    /**
73
-     * @return string
74
-     */
75
-    public function context()
76
-    {
77
-        return $this->context;
78
-    }
79
-
80
-
81
-
82
-    /**
83
-     * @return int|string
84
-     */
85
-    public function ID()
86
-    {
87
-        return $this->ID;
88
-    }
23
+	/**
24
+	 * @var string|array $capability
25
+	 */
26
+	private $capability;
27
+
28
+	/**
29
+	 * @var string $context
30
+	 */
31
+	private $context;
32
+
33
+	/**
34
+	 * @var int|string $ID
35
+	 */
36
+	private $ID;
37
+
38
+
39
+
40
+	/**
41
+	 * @param string|array $capability   - the capability to be checked, like: 'ee_edit_registrations',
42
+	 *                                   or an array of capability strings
43
+	 * @param string       $context      - what the user is attempting to do, like: 'Edit Registration'
44
+	 * @param int          $ID           - (optional) ID for item where current_user_can is being called from
45
+	 * @throws InvalidDataTypeException
46
+	 */
47
+	public function __construct($capability, $context, $ID = 0)
48
+	{
49
+		if ( ! (is_string($capability) || is_array($capability))) {
50
+			throw new InvalidDataTypeException('$capability', $capability, 'string or array');
51
+		}
52
+		if ( ! is_string($context)) {
53
+			throw new InvalidDataTypeException('$context', $context, 'string');
54
+		}
55
+		$this->capability = $capability;
56
+		$this->context = strtolower(str_replace(' ', '_', $context));
57
+		$this->ID = $ID;
58
+	}
59
+
60
+
61
+
62
+	/**
63
+	 * @return string|array
64
+	 */
65
+	public function capability()
66
+	{
67
+		return $this->capability;
68
+	}
69
+
70
+
71
+
72
+	/**
73
+	 * @return string
74
+	 */
75
+	public function context()
76
+	{
77
+		return $this->context;
78
+	}
79
+
80
+
81
+
82
+	/**
83
+	 * @return int|string
84
+	 */
85
+	public function ID()
86
+	{
87
+		return $this->ID;
88
+	}
89 89
 
90 90
 
91 91
 }
Please login to merge, or discard this patch.
core/services/collections/Collection.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	  *
116 116
 	  * @access public
117 117
 	  * @param mixed $identifier
118
-	  * @return mixed
118
+	  * @return boolean
119 119
 	  */
120 120
 	 public function get( $identifier ) {
121 121
 		 $this->rewind();
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 	  * advances pointer to the provided object
238 238
 	  *
239 239
 	  * @access public
240
-	  * @param $object
240
+	  * @param \EventEspresso\core\libraries\form_sections\form_handlers\SequentialStepForm $object
241 241
 	  * @return boolean
242 242
 	  */
243 243
 	 public function setCurrentUsingObject( $object ) {
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 	  *
276 276
 	  * @see http://stackoverflow.com/a/8736013
277 277
 	  * @param $object
278
-	  * @return boolean|int|string
278
+	  * @return integer
279 279
 	  */
280 280
 	 public function indexOf( $object ) {
281 281
 		 if ( ! $this->contains( $object ) ) {
Please login to merge, or discard this patch.
Indentation   +31 added lines, -32 removed lines patch added patch discarded remove patch
@@ -83,7 +83,6 @@  discard block
 block discarded – undo
83 83
 
84 84
 	 /**
85 85
 	  * setIdentifier
86
-
87 86
 	  * Sets the data associated with an object in the Collection
88 87
 	  * if no $identifier is supplied, then the spl_object_hash() is used
89 88
 	  *
@@ -172,9 +171,9 @@  discard block
 block discarded – undo
172 171
 
173 172
 	 /**
174 173
 	  * hasObjects
175
-      * returns true if there are objects within the Collection, and false if it is empty
176
-      *
177
-      * @access public
174
+	  * returns true if there are objects within the Collection, and false if it is empty
175
+	  *
176
+	  * @access public
178 177
 	  * @return bool
179 178
 	  */
180 179
 	 public function hasObjects() {
@@ -378,34 +377,34 @@  discard block
 block discarded – undo
378 377
 
379 378
 
380 379
 
381
-     /**
382
-      * detaches ALL objects from the Collection
383
-      */
384
-     public function detachAll()
385
-     {
386
-         $this->rewind();
387
-         while ($this->valid()) {
388
-             $object = $this->current();
389
-             $this->next();
390
-             $this->detach($object);
391
-         }
392
-     }
393
-
394
-
395
-
396
-     /**
397
-      * unsets and detaches ALL objects from the Collection
398
-      */
399
-     public function trashAndDetachAll()
400
-     {
401
-         $this->rewind();
402
-         while ($this->valid()) {
403
-             $object = $this->current();
404
-             $this->next();
405
-             $this->detach($object);
406
-             unset($object);
407
-         }
408
-     }
380
+	 /**
381
+	  * detaches ALL objects from the Collection
382
+	  */
383
+	 public function detachAll()
384
+	 {
385
+		 $this->rewind();
386
+		 while ($this->valid()) {
387
+			 $object = $this->current();
388
+			 $this->next();
389
+			 $this->detach($object);
390
+		 }
391
+	 }
392
+
393
+
394
+
395
+	 /**
396
+	  * unsets and detaches ALL objects from the Collection
397
+	  */
398
+	 public function trashAndDetachAll()
399
+	 {
400
+		 $this->rewind();
401
+		 while ($this->valid()) {
402
+			 $object = $this->current();
403
+			 $this->next();
404
+			 $this->detach($object);
405
+			 unset($object);
406
+		 }
407
+	 }
409 408
 
410 409
 
411 410
 
Please login to merge, or discard this patch.
core/helpers/EEH_Activation.helper.php 2 patches
Indentation   +1650 added lines, -1650 removed lines patch added patch discarded remove patch
@@ -18,243 +18,243 @@  discard block
 block discarded – undo
18 18
 class EEH_Activation implements ResettableInterface
19 19
 {
20 20
 
21
-    /**
22
-     * constant used to indicate a cron task is no longer in use
23
-     */
24
-    const cron_task_no_longer_in_use = 'no_longer_in_use';
25
-
26
-    /**
27
-     * option name that will indicate whether or not we still
28
-     * need to create EE's folders in the uploads directory
29
-     * (because if EE was installed without file system access,
30
-     * we need to request credentials before we can create them)
31
-     */
32
-    const upload_directories_incomplete_option_name = 'ee_upload_directories_incomplete';
33
-
34
-    /**
35
-     * WP_User->ID
36
-     *
37
-     * @var int
38
-     */
39
-    private static $_default_creator_id;
40
-
41
-    /**
42
-     * indicates whether or not we've already verified core's default data during this request,
43
-     * because after migrations are done, any addons activated while in maintenance mode
44
-     * will want to setup their own default data, and they might hook into core's default data
45
-     * and trigger core to setup its default data. In which case they might all ask for core to init its default data.
46
-     * This prevents doing that for EVERY single addon.
47
-     *
48
-     * @var boolean
49
-     */
50
-    protected static $_initialized_db_content_already_in_this_request = false;
51
-
52
-    /**
53
-     * @var \EventEspresso\core\services\database\TableAnalysis $table_analysis
54
-     */
55
-    private static $table_analysis;
56
-
57
-    /**
58
-     * @var \EventEspresso\core\services\database\TableManager $table_manager
59
-     */
60
-    private static $table_manager;
61
-
62
-
63
-    /**
64
-     * @return \EventEspresso\core\services\database\TableAnalysis
65
-     */
66
-    public static function getTableAnalysis()
67
-    {
68
-        if (! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis) {
69
-            self::$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
70
-        }
71
-        return self::$table_analysis;
72
-    }
73
-
74
-
75
-    /**
76
-     * @return \EventEspresso\core\services\database\TableManager
77
-     */
78
-    public static function getTableManager()
79
-    {
80
-        if (! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager) {
81
-            self::$table_manager = EE_Registry::instance()->create('TableManager', array(), true);
82
-        }
83
-        return self::$table_manager;
84
-    }
85
-
86
-
87
-    /**
88
-     *    _ensure_table_name_has_prefix
89
-     *
90
-     * @deprecated instead use TableAnalysis::ensureTableNameHasPrefix()
91
-     * @access     public
92
-     * @static
93
-     * @param $table_name
94
-     * @return string
95
-     */
96
-    public static function ensure_table_name_has_prefix($table_name)
97
-    {
98
-        return \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix($table_name);
99
-    }
100
-
101
-
102
-    /**
103
-     *    system_initialization
104
-     *    ensures the EE configuration settings are loaded with at least default options set
105
-     *    and that all critical EE pages have been generated with the appropriate shortcodes in place
106
-     *
107
-     * @access public
108
-     * @static
109
-     * @return void
110
-     */
111
-    public static function system_initialization()
112
-    {
113
-        EEH_Activation::reset_and_update_config();
114
-        //which is fired BEFORE activation of plugin anyways
115
-        EEH_Activation::verify_default_pages_exist();
116
-    }
117
-
118
-
119
-    /**
120
-     * Sets the database schema and creates folders. This should
121
-     * be called on plugin activation and reactivation
122
-     *
123
-     * @return boolean success, whether the database and folders are setup properly
124
-     * @throws \EE_Error
125
-     */
126
-    public static function initialize_db_and_folders()
127
-    {
128
-        $good_filesystem = EEH_Activation::create_upload_directories();
129
-        $good_db         = EEH_Activation::create_database_tables();
130
-        return $good_filesystem && $good_db;
131
-    }
132
-
133
-
134
-    /**
135
-     * assuming we have an up-to-date database schema, this will populate it
136
-     * with default and initial data. This should be called
137
-     * upon activation of a new plugin, reactivation, and at the end
138
-     * of running migration scripts
139
-     *
140
-     * @throws \EE_Error
141
-     */
142
-    public static function initialize_db_content()
143
-    {
144
-        //let's avoid doing all this logic repeatedly, especially when addons are requesting it
145
-        if (EEH_Activation::$_initialized_db_content_already_in_this_request) {
146
-            return;
147
-        }
148
-        EEH_Activation::$_initialized_db_content_already_in_this_request = true;
149
-
150
-        EEH_Activation::initialize_system_questions();
151
-        EEH_Activation::insert_default_status_codes();
152
-        EEH_Activation::generate_default_message_templates();
153
-        EEH_Activation::create_no_ticket_prices_array();
154
-
155
-        EEH_Activation::validate_messages_system();
156
-        EEH_Activation::insert_default_payment_methods();
157
-        //in case we've
158
-        EEH_Activation::remove_cron_tasks();
159
-        EEH_Activation::create_cron_tasks();
160
-        // remove all TXN locks since that is being done via extra meta now
161
-        delete_option('ee_locked_transactions');
162
-        //also, check for CAF default db content
163
-        do_action('AHEE__EEH_Activation__initialize_db_content');
164
-        //also: EEM_Gateways::load_all_gateways() outputs a lot of success messages
165
-        //which users really won't care about on initial activation
166
-        EE_Error::overwrite_success();
167
-    }
168
-
169
-
170
-    /**
171
-     * Returns an array of cron tasks. Array values are the actions fired by the cron tasks (the "hooks"),
172
-     * values are the frequency (the "recurrence"). See http://codex.wordpress.org/Function_Reference/wp_schedule_event
173
-     * If the cron task should NO longer be used, it should have a value of EEH_Activation::cron_task_no_longer_in_use
174
-     * (null)
175
-     *
176
-     * @param string $which_to_include can be 'current' (ones that are currently in use),
177
-     *                                 'old' (only returns ones that should no longer be used),or 'all',
178
-     * @return array
179
-     * @throws \EE_Error
180
-     */
181
-    public static function get_cron_tasks($which_to_include)
182
-    {
183
-        $cron_tasks = apply_filters(
184
-            'FHEE__EEH_Activation__get_cron_tasks',
185
-            array(
186
-                'AHEE__EE_Cron_Tasks__clean_up_junk_transactions'      => 'hourly',
21
+	/**
22
+	 * constant used to indicate a cron task is no longer in use
23
+	 */
24
+	const cron_task_no_longer_in_use = 'no_longer_in_use';
25
+
26
+	/**
27
+	 * option name that will indicate whether or not we still
28
+	 * need to create EE's folders in the uploads directory
29
+	 * (because if EE was installed without file system access,
30
+	 * we need to request credentials before we can create them)
31
+	 */
32
+	const upload_directories_incomplete_option_name = 'ee_upload_directories_incomplete';
33
+
34
+	/**
35
+	 * WP_User->ID
36
+	 *
37
+	 * @var int
38
+	 */
39
+	private static $_default_creator_id;
40
+
41
+	/**
42
+	 * indicates whether or not we've already verified core's default data during this request,
43
+	 * because after migrations are done, any addons activated while in maintenance mode
44
+	 * will want to setup their own default data, and they might hook into core's default data
45
+	 * and trigger core to setup its default data. In which case they might all ask for core to init its default data.
46
+	 * This prevents doing that for EVERY single addon.
47
+	 *
48
+	 * @var boolean
49
+	 */
50
+	protected static $_initialized_db_content_already_in_this_request = false;
51
+
52
+	/**
53
+	 * @var \EventEspresso\core\services\database\TableAnalysis $table_analysis
54
+	 */
55
+	private static $table_analysis;
56
+
57
+	/**
58
+	 * @var \EventEspresso\core\services\database\TableManager $table_manager
59
+	 */
60
+	private static $table_manager;
61
+
62
+
63
+	/**
64
+	 * @return \EventEspresso\core\services\database\TableAnalysis
65
+	 */
66
+	public static function getTableAnalysis()
67
+	{
68
+		if (! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis) {
69
+			self::$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
70
+		}
71
+		return self::$table_analysis;
72
+	}
73
+
74
+
75
+	/**
76
+	 * @return \EventEspresso\core\services\database\TableManager
77
+	 */
78
+	public static function getTableManager()
79
+	{
80
+		if (! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager) {
81
+			self::$table_manager = EE_Registry::instance()->create('TableManager', array(), true);
82
+		}
83
+		return self::$table_manager;
84
+	}
85
+
86
+
87
+	/**
88
+	 *    _ensure_table_name_has_prefix
89
+	 *
90
+	 * @deprecated instead use TableAnalysis::ensureTableNameHasPrefix()
91
+	 * @access     public
92
+	 * @static
93
+	 * @param $table_name
94
+	 * @return string
95
+	 */
96
+	public static function ensure_table_name_has_prefix($table_name)
97
+	{
98
+		return \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix($table_name);
99
+	}
100
+
101
+
102
+	/**
103
+	 *    system_initialization
104
+	 *    ensures the EE configuration settings are loaded with at least default options set
105
+	 *    and that all critical EE pages have been generated with the appropriate shortcodes in place
106
+	 *
107
+	 * @access public
108
+	 * @static
109
+	 * @return void
110
+	 */
111
+	public static function system_initialization()
112
+	{
113
+		EEH_Activation::reset_and_update_config();
114
+		//which is fired BEFORE activation of plugin anyways
115
+		EEH_Activation::verify_default_pages_exist();
116
+	}
117
+
118
+
119
+	/**
120
+	 * Sets the database schema and creates folders. This should
121
+	 * be called on plugin activation and reactivation
122
+	 *
123
+	 * @return boolean success, whether the database and folders are setup properly
124
+	 * @throws \EE_Error
125
+	 */
126
+	public static function initialize_db_and_folders()
127
+	{
128
+		$good_filesystem = EEH_Activation::create_upload_directories();
129
+		$good_db         = EEH_Activation::create_database_tables();
130
+		return $good_filesystem && $good_db;
131
+	}
132
+
133
+
134
+	/**
135
+	 * assuming we have an up-to-date database schema, this will populate it
136
+	 * with default and initial data. This should be called
137
+	 * upon activation of a new plugin, reactivation, and at the end
138
+	 * of running migration scripts
139
+	 *
140
+	 * @throws \EE_Error
141
+	 */
142
+	public static function initialize_db_content()
143
+	{
144
+		//let's avoid doing all this logic repeatedly, especially when addons are requesting it
145
+		if (EEH_Activation::$_initialized_db_content_already_in_this_request) {
146
+			return;
147
+		}
148
+		EEH_Activation::$_initialized_db_content_already_in_this_request = true;
149
+
150
+		EEH_Activation::initialize_system_questions();
151
+		EEH_Activation::insert_default_status_codes();
152
+		EEH_Activation::generate_default_message_templates();
153
+		EEH_Activation::create_no_ticket_prices_array();
154
+
155
+		EEH_Activation::validate_messages_system();
156
+		EEH_Activation::insert_default_payment_methods();
157
+		//in case we've
158
+		EEH_Activation::remove_cron_tasks();
159
+		EEH_Activation::create_cron_tasks();
160
+		// remove all TXN locks since that is being done via extra meta now
161
+		delete_option('ee_locked_transactions');
162
+		//also, check for CAF default db content
163
+		do_action('AHEE__EEH_Activation__initialize_db_content');
164
+		//also: EEM_Gateways::load_all_gateways() outputs a lot of success messages
165
+		//which users really won't care about on initial activation
166
+		EE_Error::overwrite_success();
167
+	}
168
+
169
+
170
+	/**
171
+	 * Returns an array of cron tasks. Array values are the actions fired by the cron tasks (the "hooks"),
172
+	 * values are the frequency (the "recurrence"). See http://codex.wordpress.org/Function_Reference/wp_schedule_event
173
+	 * If the cron task should NO longer be used, it should have a value of EEH_Activation::cron_task_no_longer_in_use
174
+	 * (null)
175
+	 *
176
+	 * @param string $which_to_include can be 'current' (ones that are currently in use),
177
+	 *                                 'old' (only returns ones that should no longer be used),or 'all',
178
+	 * @return array
179
+	 * @throws \EE_Error
180
+	 */
181
+	public static function get_cron_tasks($which_to_include)
182
+	{
183
+		$cron_tasks = apply_filters(
184
+			'FHEE__EEH_Activation__get_cron_tasks',
185
+			array(
186
+				'AHEE__EE_Cron_Tasks__clean_up_junk_transactions'      => 'hourly',
187 187
 //				'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions' => EEH_Activation::cron_task_no_longer_in_use, actually this is still in use
188
-                'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use,
189
-                //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
190
-                'AHEE_EE_Cron_Tasks__clean_out_old_gateway_logs'       => 'daily',
191
-            )
192
-        );
193
-        if ($which_to_include === 'old') {
194
-            $cron_tasks = array_filter(
195
-                $cron_tasks,
196
-                function ($value) {
197
-                    return $value === EEH_Activation::cron_task_no_longer_in_use;
198
-                }
199
-            );
200
-        } elseif ($which_to_include === 'current') {
201
-            $cron_tasks = array_filter($cron_tasks);
202
-        } elseif (WP_DEBUG && $which_to_include !== 'all') {
203
-            throw new EE_Error(
204
-                sprintf(
205
-                    __(
206
-                        'Invalid argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".',
207
-                        'event_espresso'
208
-                    ),
209
-                    $which_to_include
210
-                )
211
-            );
212
-        }
213
-        return $cron_tasks;
214
-    }
215
-
216
-
217
-    /**
218
-     * Ensure cron tasks are setup (the removal of crons should be done by remove_crons())
219
-     *
220
-     * @throws \EE_Error
221
-     */
222
-    public static function create_cron_tasks()
223
-    {
224
-
225
-        foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) {
226
-            if (! wp_next_scheduled($hook_name)) {
227
-                /**
228
-                 * This allows client code to define the initial start timestamp for this schedule.
229
-                 */
230
-                if (is_array($frequency)
231
-                    && count($frequency) === 2
232
-                    && isset($frequency[0], $frequency[1])
233
-                ) {
234
-                    $start_timestamp = $frequency[0];
235
-                    $frequency = $frequency[1];
236
-                } else {
237
-                    $start_timestamp = time();
238
-                }
239
-                wp_schedule_event($start_timestamp, $frequency, $hook_name);
240
-            }
241
-        }
242
-
243
-    }
244
-
245
-
246
-    /**
247
-     * Remove the currently-existing and now-removed cron tasks.
248
-     *
249
-     * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones
250
-     * @throws \EE_Error
251
-     */
252
-    public static function remove_cron_tasks($remove_all = true)
253
-    {
254
-        $cron_tasks_to_remove = $remove_all ? 'all' : 'old';
255
-        $crons                = _get_cron_array();
256
-        $crons                = is_array($crons) ? $crons : array();
257
-        /* reminder of what $crons look like:
188
+				'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use,
189
+				//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
190
+				'AHEE_EE_Cron_Tasks__clean_out_old_gateway_logs'       => 'daily',
191
+			)
192
+		);
193
+		if ($which_to_include === 'old') {
194
+			$cron_tasks = array_filter(
195
+				$cron_tasks,
196
+				function ($value) {
197
+					return $value === EEH_Activation::cron_task_no_longer_in_use;
198
+				}
199
+			);
200
+		} elseif ($which_to_include === 'current') {
201
+			$cron_tasks = array_filter($cron_tasks);
202
+		} elseif (WP_DEBUG && $which_to_include !== 'all') {
203
+			throw new EE_Error(
204
+				sprintf(
205
+					__(
206
+						'Invalid argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".',
207
+						'event_espresso'
208
+					),
209
+					$which_to_include
210
+				)
211
+			);
212
+		}
213
+		return $cron_tasks;
214
+	}
215
+
216
+
217
+	/**
218
+	 * Ensure cron tasks are setup (the removal of crons should be done by remove_crons())
219
+	 *
220
+	 * @throws \EE_Error
221
+	 */
222
+	public static function create_cron_tasks()
223
+	{
224
+
225
+		foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) {
226
+			if (! wp_next_scheduled($hook_name)) {
227
+				/**
228
+				 * This allows client code to define the initial start timestamp for this schedule.
229
+				 */
230
+				if (is_array($frequency)
231
+					&& count($frequency) === 2
232
+					&& isset($frequency[0], $frequency[1])
233
+				) {
234
+					$start_timestamp = $frequency[0];
235
+					$frequency = $frequency[1];
236
+				} else {
237
+					$start_timestamp = time();
238
+				}
239
+				wp_schedule_event($start_timestamp, $frequency, $hook_name);
240
+			}
241
+		}
242
+
243
+	}
244
+
245
+
246
+	/**
247
+	 * Remove the currently-existing and now-removed cron tasks.
248
+	 *
249
+	 * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones
250
+	 * @throws \EE_Error
251
+	 */
252
+	public static function remove_cron_tasks($remove_all = true)
253
+	{
254
+		$cron_tasks_to_remove = $remove_all ? 'all' : 'old';
255
+		$crons                = _get_cron_array();
256
+		$crons                = is_array($crons) ? $crons : array();
257
+		/* reminder of what $crons look like:
258 258
          * Top-level keys are timestamps, and their values are arrays.
259 259
          * The 2nd level arrays have keys with each of the cron task hook names to run at that time
260 260
          * and their values are arrays.
@@ -271,911 +271,911 @@  discard block
 block discarded – undo
271 271
          *					...
272 272
          *      ...
273 273
          */
274
-        $ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks($cron_tasks_to_remove);
275
-        foreach ($crons as $timestamp => $hooks_to_fire_at_time) {
276
-            if (is_array($hooks_to_fire_at_time)) {
277
-                foreach ($hooks_to_fire_at_time as $hook_name => $hook_actions) {
278
-                    if (isset($ee_cron_tasks_to_remove[$hook_name])
279
-                        && is_array($ee_cron_tasks_to_remove[$hook_name])
280
-                    ) {
281
-                        unset($crons[$timestamp][$hook_name]);
282
-                    }
283
-                }
284
-                //also take care of any empty cron timestamps.
285
-                if (empty($hooks_to_fire_at_time)) {
286
-                    unset($crons[$timestamp]);
287
-                }
288
-            }
289
-        }
290
-        _set_cron_array($crons);
291
-    }
292
-
293
-
294
-    /**
295
-     *    CPT_initialization
296
-     *    registers all EE CPTs ( Custom Post Types ) then flushes rewrite rules so that all endpoints exist
297
-     *
298
-     * @access public
299
-     * @static
300
-     * @return void
301
-     */
302
-    public static function CPT_initialization()
303
-    {
304
-        // register Custom Post Types
305
-        EE_Registry::instance()->load_core('Register_CPTs');
306
-        flush_rewrite_rules();
307
-    }
308
-
309
-
310
-
311
-    /**
312
-     *    reset_and_update_config
313
-     * The following code was moved over from EE_Config so that it will no longer run on every request.
314
-     * If there is old calendar config data saved, then it will get converted on activation.
315
-     * This was basically a DMS before we had DMS's, and will get removed after a few more versions.
316
-     *
317
-     * @access public
318
-     * @static
319
-     * @return void
320
-     */
321
-    public static function reset_and_update_config()
322
-    {
323
-        do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config'));
324
-        add_filter(
325
-            'FHEE__EE_Config___load_core_config__config_settings',
326
-            array('EEH_Activation', 'migrate_old_config_data'),
327
-            10,
328
-            3
329
-        );
330
-        //EE_Config::reset();
331
-        if (! EE_Config::logging_enabled()) {
332
-            delete_option(EE_Config::LOG_NAME);
333
-        }
334
-    }
335
-
336
-
337
-    /**
338
-     *    load_calendar_config
339
-     *
340
-     * @access    public
341
-     * @return    void
342
-     */
343
-    public static function load_calendar_config()
344
-    {
345
-        // grab array of all plugin folders and loop thru it
346
-        $plugins = glob(WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR);
347
-        if (empty($plugins)) {
348
-            return;
349
-        }
350
-        foreach ($plugins as $plugin_path) {
351
-            // grab plugin folder name from path
352
-            $plugin = basename($plugin_path);
353
-            // drill down to Espresso plugins
354
-            // then to calendar related plugins
355
-            if (
356
-                strpos($plugin, 'espresso') !== false
357
-                || strpos($plugin, 'Espresso') !== false
358
-                || strpos($plugin, 'ee4') !== false
359
-                || strpos($plugin, 'EE4') !== false
360
-                || strpos($plugin, 'calendar') !== false
361
-            ) {
362
-                // this is what we are looking for
363
-                $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php';
364
-                // does it exist in this folder ?
365
-                if (is_readable($calendar_config)) {
366
-                    // YEAH! let's load it
367
-                    require_once($calendar_config);
368
-                }
369
-            }
370
-        }
371
-    }
372
-
373
-
374
-
375
-    /**
376
-     *    _migrate_old_config_data
377
-     *
378
-     * @access    public
379
-     * @param array|stdClass $settings
380
-     * @param string         $config
381
-     * @param \EE_Config     $EE_Config
382
-     * @return \stdClass
383
-     */
384
-    public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config)
385
-    {
386
-        $convert_from_array = array('addons');
387
-        // in case old settings were saved as an array
388
-        if (is_array($settings) && in_array($config, $convert_from_array)) {
389
-            // convert existing settings to an object
390
-            $config_array = $settings;
391
-            $settings = new stdClass();
392
-            foreach ($config_array as $key => $value) {
393
-                if ($key === 'calendar' && class_exists('EE_Calendar_Config')) {
394
-                    $EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value);
395
-                } else {
396
-                    $settings->{$key} = $value;
397
-                }
398
-            }
399
-            add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true');
400
-        }
401
-        return $settings;
402
-    }
403
-
404
-
405
-    /**
406
-     * deactivate_event_espresso
407
-     *
408
-     * @access public
409
-     * @static
410
-     * @return void
411
-     */
412
-    public static function deactivate_event_espresso()
413
-    {
414
-        // check permissions
415
-        if (current_user_can('activate_plugins')) {
416
-            deactivate_plugins(EE_PLUGIN_BASENAME, true);
417
-        }
418
-    }
419
-
420
-
421
-
422
-    /**
423
-     * verify_default_pages_exist
424
-     *
425
-     * @access public
426
-     * @static
427
-     * @return void
428
-     * @throws InvalidDataTypeException
429
-     */
430
-    public static function verify_default_pages_exist()
431
-    {
432
-        $critical_page_problem = false;
433
-        $critical_pages = array(
434
-            array(
435
-                'id'   => 'reg_page_id',
436
-                'name' => __('Registration Checkout', 'event_espresso'),
437
-                'post' => null,
438
-                'code' => 'ESPRESSO_CHECKOUT',
439
-            ),
440
-            array(
441
-                'id'   => 'txn_page_id',
442
-                'name' => __('Transactions', 'event_espresso'),
443
-                'post' => null,
444
-                'code' => 'ESPRESSO_TXN_PAGE',
445
-            ),
446
-            array(
447
-                'id'   => 'thank_you_page_id',
448
-                'name' => __('Thank You', 'event_espresso'),
449
-                'post' => null,
450
-                'code' => 'ESPRESSO_THANK_YOU',
451
-            ),
452
-            array(
453
-                'id'   => 'cancel_page_id',
454
-                'name' => __('Registration Cancelled', 'event_espresso'),
455
-                'post' => null,
456
-                'code' => 'ESPRESSO_CANCELLED',
457
-            ),
458
-        );
459
-        $EE_Core_Config = EE_Registry::instance()->CFG->core;
460
-        foreach ($critical_pages as $critical_page) {
461
-            // is critical page ID set in config ?
462
-            if ($EE_Core_Config->{$critical_page['id']} !== false) {
463
-                // attempt to find post by ID
464
-                $critical_page['post'] = get_post($EE_Core_Config->{$critical_page['id']});
465
-            }
466
-            // no dice?
467
-            if ($critical_page['post'] === null) {
468
-                // attempt to find post by title
469
-                $critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']);
470
-                // still nothing?
471
-                if ($critical_page['post'] === null) {
472
-                    $critical_page = EEH_Activation::create_critical_page($critical_page);
473
-                    // REALLY? Still nothing ??!?!?
474
-                    if ($critical_page['post'] === null) {
475
-                        $msg = __(
476
-                            'The Event Espresso critical page configuration settings could not be updated.',
477
-                            'event_espresso'
478
-                        );
479
-                        EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
480
-                        break;
481
-                    }
482
-                }
483
-            }
484
-            // check that Post ID matches critical page ID in config
485
-            if (
486
-                isset($critical_page['post']->ID)
487
-                && $critical_page['post']->ID !== $EE_Core_Config->{$critical_page['id']}
488
-            ) {
489
-                //update Config with post ID
490
-                $EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID;
491
-                if (! EE_Config::instance()->update_espresso_config(false, false)) {
492
-                    $msg = __(
493
-                        'The Event Espresso critical page configuration settings could not be updated.',
494
-                        'event_espresso'
495
-                    );
496
-                    EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
497
-                }
498
-            }
499
-            $critical_page_problem =
500
-                ! isset($critical_page['post']->post_status)
501
-                || $critical_page['post']->post_status !== 'publish'
502
-                || strpos($critical_page['post']->post_content, $critical_page['code']) === false
503
-                    ? true
504
-                    : $critical_page_problem;
505
-        }
506
-        if ($critical_page_problem) {
507
-            new PersistentAdminNotice(
508
-                'critical_page_problem',
509
-                sprintf(
510
-                    esc_html__(
511
-                        'A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.',
512
-                        'event_espresso'
513
-                    ),
514
-                    '<a href="' . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') . '">'
515
-                    . __('Event Espresso Critical Pages Settings', 'event_espresso')
516
-                    . '</a>'
517
-                )
518
-            );
519
-        }
520
-        if (EE_Error::has_notices()) {
521
-            EE_Error::get_notices(false, true, true);
522
-        }
523
-    }
524
-
525
-
526
-
527
-    /**
528
-     * Returns the first post which uses the specified shortcode
529
-     *
530
-     * @param string $ee_shortcode usually one of the critical pages shortcodes, eg
531
-     *                             ESPRESSO_THANK_YOU. So we will search fora post with the content
532
-     *                             "[ESPRESSO_THANK_YOU"
533
-     *                             (we don't search for the closing shortcode bracket because they might have added
534
-     *                             parameter to the shortcode
535
-     * @return WP_Post or NULl
536
-     */
537
-    public static function get_page_by_ee_shortcode($ee_shortcode)
538
-    {
539
-        global $wpdb;
540
-        $shortcode_and_opening_bracket = '[' . $ee_shortcode;
541
-        $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1");
542
-        if ($post_id) {
543
-            return get_post($post_id);
544
-        } else {
545
-            return null;
546
-        }
547
-    }
548
-
549
-
550
-    /**
551
-     *    This function generates a post for critical espresso pages
552
-     *
553
-     * @access public
554
-     * @static
555
-     * @param array $critical_page
556
-     * @return array
557
-     */
558
-    public static function create_critical_page($critical_page)
559
-    {
560
-
561
-        $post_args = array(
562
-            'post_title'     => $critical_page['name'],
563
-            'post_status'    => 'publish',
564
-            'post_type'      => 'page',
565
-            'comment_status' => 'closed',
566
-            'post_content'   => '[' . $critical_page['code'] . ']',
567
-        );
568
-
569
-        $post_id = wp_insert_post($post_args);
570
-        if (! $post_id) {
571
-            $msg = sprintf(
572
-                __('The Event Espresso  critical page entitled "%s" could not be created.', 'event_espresso'),
573
-                $critical_page['name']
574
-            );
575
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
576
-            return $critical_page;
577
-        }
578
-        // get newly created post's details
579
-        if (! $critical_page['post'] = get_post($post_id)) {
580
-            $msg = sprintf(
581
-                __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'),
582
-                $critical_page['name']
583
-            );
584
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
585
-        }
586
-
587
-        return $critical_page;
588
-
589
-    }
590
-
591
-
592
-
593
-
594
-    /**
595
-     * Tries to find the oldest admin for this site.  If there are no admins for this site then return NULL.
596
-     * The role being used to check is filterable.
597
-     *
598
-     * @since  4.6.0
599
-     * @global WPDB $wpdb
600
-     * @return mixed null|int WP_user ID or NULL
601
-     */
602
-    public static function get_default_creator_id()
603
-    {
604
-        global $wpdb;
605
-        if ( ! empty(self::$_default_creator_id)) {
606
-            return self::$_default_creator_id;
607
-        }/**/
608
-        $role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator');
609
-        //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.
610
-        $pre_filtered_id = apply_filters(
611
-            'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id',
612
-            false,
613
-            $role_to_check
614
-        );
615
-        if ($pre_filtered_id !== false) {
616
-            return (int)$pre_filtered_id;
617
-        }
618
-        $capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('capabilities');
619
-        $query = $wpdb->prepare(
620
-            "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1",
621
-            '%' . $role_to_check . '%'
622
-        );
623
-        $user_id = $wpdb->get_var($query);
624
-        $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id);
625
-        if ($user_id && (int)$user_id) {
626
-            self::$_default_creator_id = (int)$user_id;
627
-            return self::$_default_creator_id;
628
-        } else {
629
-            return null;
630
-        }
631
-    }
632
-
633
-
634
-
635
-    /**
636
-     * used by EE and EE addons during plugin activation to create tables.
637
-     * Its a wrapper for EventEspresso\core\services\database\TableManager::createTable,
638
-     * but includes extra logic regarding activations.
639
-     *
640
-     * @access public
641
-     * @static
642
-     * @param string  $table_name              without the $wpdb->prefix
643
-     * @param string  $sql                     SQL for creating the table (contents between brackets in an SQL create
644
-     *                                         table query)
645
-     * @param string  $engine                  like 'ENGINE=MyISAM' or 'ENGINE=InnoDB'
646
-     * @param boolean $drop_pre_existing_table set to TRUE when you want to make SURE the table is completely empty
647
-     *                                         and new once this function is done (ie, you really do want to CREATE a
648
-     *                                         table, and expect it to be empty once you're done) leave as FALSE when
649
-     *                                         you just want to verify the table exists and matches this definition
650
-     *                                         (and if it HAS data in it you want to leave it be)
651
-     * @return void
652
-     * @throws EE_Error if there are database errors
653
-     */
654
-    public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false)
655
-    {
656
-        if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', false, $table_name, $sql)) {
657
-            return;
658
-        }
659
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
660
-        if ( ! function_exists('dbDelta')) {
661
-            require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
662
-        }
663
-        $tableAnalysis = \EEH_Activation::getTableAnalysis();
664
-        $wp_table_name = $tableAnalysis->ensureTableNameHasPrefix($table_name);
665
-        // do we need to first delete an existing version of this table ?
666
-        if ($drop_pre_existing_table && $tableAnalysis->tableExists($wp_table_name)) {
667
-            // ok, delete the table... but ONLY if it's empty
668
-            $deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name);
669
-            // table is NOT empty, are you SURE you want to delete this table ???
670
-            if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) {
671
-                \EEH_Activation::getTableManager()->dropTable($wp_table_name);
672
-            } else if ( ! $deleted_safely) {
673
-                // so we should be more cautious rather than just dropping tables so easily
674
-                error_log(
675
-                    sprintf(
676
-                        __(
677
-                            '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.',
678
-                            'event_espresso'
679
-                        ),
680
-                        $wp_table_name,
681
-                        '<br/>',
682
-                        'espresso_db_update'
683
-                    )
684
-                );
685
-            }
686
-        }
687
-        $engine = str_replace('ENGINE=', '', $engine);
688
-        \EEH_Activation::getTableManager()->createTable($table_name, $sql, $engine);
689
-    }
690
-
691
-
692
-
693
-    /**
694
-     *    add_column_if_it_doesn't_exist
695
-     *    Checks if this column already exists on the specified table. Handy for addons which want to add a column
696
-     *
697
-     * @access     public
698
-     * @static
699
-     * @deprecated instead use TableManager::addColumn()
700
-     * @param string $table_name  (without "wp_", eg "esp_attendee"
701
-     * @param string $column_name
702
-     * @param string $column_info if your SQL were 'ALTER TABLE table_name ADD price VARCHAR(10)', this would be
703
-     *                            'VARCHAR(10)'
704
-     * @return bool|int
705
-     */
706
-    public static function add_column_if_it_doesnt_exist(
707
-        $table_name,
708
-        $column_name,
709
-        $column_info = 'INT UNSIGNED NOT NULL'
710
-    ) {
711
-        return \EEH_Activation::getTableManager()->addColumn($table_name, $column_name, $column_info);
712
-    }
713
-
714
-
715
-    /**
716
-     * get_fields_on_table
717
-     * Gets all the fields on the database table.
718
-     *
719
-     * @access     public
720
-     * @deprecated instead use TableManager::getTableColumns()
721
-     * @static
722
-     * @param string $table_name , without prefixed $wpdb->prefix
723
-     * @return array of database column names
724
-     */
725
-    public static function get_fields_on_table($table_name = null)
726
-    {
727
-        return \EEH_Activation::getTableManager()->getTableColumns($table_name);
728
-    }
729
-
730
-
731
-    /**
732
-     * db_table_is_empty
733
-     *
734
-     * @access     public\
735
-     * @deprecated instead use TableAnalysis::tableIsEmpty()
736
-     * @static
737
-     * @param string $table_name
738
-     * @return bool
739
-     */
740
-    public static function db_table_is_empty($table_name)
741
-    {
742
-        return \EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name);
743
-    }
744
-
745
-
746
-    /**
747
-     * delete_db_table_if_empty
748
-     *
749
-     * @access public
750
-     * @static
751
-     * @param string $table_name
752
-     * @return bool | int
753
-     */
754
-    public static function delete_db_table_if_empty($table_name)
755
-    {
756
-        if (\EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name)) {
757
-            return \EEH_Activation::getTableManager()->dropTable($table_name);
758
-        }
759
-        return false;
760
-    }
761
-
762
-
763
-    /**
764
-     * delete_unused_db_table
765
-     *
766
-     * @access     public
767
-     * @static
768
-     * @deprecated instead use TableManager::dropTable()
769
-     * @param string $table_name
770
-     * @return bool | int
771
-     */
772
-    public static function delete_unused_db_table($table_name)
773
-    {
774
-        return \EEH_Activation::getTableManager()->dropTable($table_name);
775
-    }
776
-
777
-
778
-    /**
779
-     * drop_index
780
-     *
781
-     * @access     public
782
-     * @static
783
-     * @deprecated instead use TableManager::dropIndex()
784
-     * @param string $table_name
785
-     * @param string $index_name
786
-     * @return bool | int
787
-     */
788
-    public static function drop_index($table_name, $index_name)
789
-    {
790
-        return \EEH_Activation::getTableManager()->dropIndex($table_name, $index_name);
791
-    }
792
-
793
-
794
-
795
-    /**
796
-     * create_database_tables
797
-     *
798
-     * @access public
799
-     * @static
800
-     * @throws EE_Error
801
-     * @return boolean success (whether database is setup properly or not)
802
-     */
803
-    public static function create_database_tables()
804
-    {
805
-        EE_Registry::instance()->load_core('Data_Migration_Manager');
806
-        //find the migration script that sets the database to be compatible with the code
807
-        $dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms();
808
-        if ($dms_name) {
809
-            $current_data_migration_script = EE_Registry::instance()->load_dms($dms_name);
810
-            $current_data_migration_script->set_migrating(false);
811
-            $current_data_migration_script->schema_changes_before_migration();
812
-            $current_data_migration_script->schema_changes_after_migration();
813
-            if ($current_data_migration_script->get_errors()) {
814
-                if (WP_DEBUG) {
815
-                    foreach ($current_data_migration_script->get_errors() as $error) {
816
-                        EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
817
-                    }
818
-                } else {
819
-                    EE_Error::add_error(
820
-                        __(
821
-                            'There were errors creating the Event Espresso database tables and Event Espresso has been 
274
+		$ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks($cron_tasks_to_remove);
275
+		foreach ($crons as $timestamp => $hooks_to_fire_at_time) {
276
+			if (is_array($hooks_to_fire_at_time)) {
277
+				foreach ($hooks_to_fire_at_time as $hook_name => $hook_actions) {
278
+					if (isset($ee_cron_tasks_to_remove[$hook_name])
279
+						&& is_array($ee_cron_tasks_to_remove[$hook_name])
280
+					) {
281
+						unset($crons[$timestamp][$hook_name]);
282
+					}
283
+				}
284
+				//also take care of any empty cron timestamps.
285
+				if (empty($hooks_to_fire_at_time)) {
286
+					unset($crons[$timestamp]);
287
+				}
288
+			}
289
+		}
290
+		_set_cron_array($crons);
291
+	}
292
+
293
+
294
+	/**
295
+	 *    CPT_initialization
296
+	 *    registers all EE CPTs ( Custom Post Types ) then flushes rewrite rules so that all endpoints exist
297
+	 *
298
+	 * @access public
299
+	 * @static
300
+	 * @return void
301
+	 */
302
+	public static function CPT_initialization()
303
+	{
304
+		// register Custom Post Types
305
+		EE_Registry::instance()->load_core('Register_CPTs');
306
+		flush_rewrite_rules();
307
+	}
308
+
309
+
310
+
311
+	/**
312
+	 *    reset_and_update_config
313
+	 * The following code was moved over from EE_Config so that it will no longer run on every request.
314
+	 * If there is old calendar config data saved, then it will get converted on activation.
315
+	 * This was basically a DMS before we had DMS's, and will get removed after a few more versions.
316
+	 *
317
+	 * @access public
318
+	 * @static
319
+	 * @return void
320
+	 */
321
+	public static function reset_and_update_config()
322
+	{
323
+		do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config'));
324
+		add_filter(
325
+			'FHEE__EE_Config___load_core_config__config_settings',
326
+			array('EEH_Activation', 'migrate_old_config_data'),
327
+			10,
328
+			3
329
+		);
330
+		//EE_Config::reset();
331
+		if (! EE_Config::logging_enabled()) {
332
+			delete_option(EE_Config::LOG_NAME);
333
+		}
334
+	}
335
+
336
+
337
+	/**
338
+	 *    load_calendar_config
339
+	 *
340
+	 * @access    public
341
+	 * @return    void
342
+	 */
343
+	public static function load_calendar_config()
344
+	{
345
+		// grab array of all plugin folders and loop thru it
346
+		$plugins = glob(WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR);
347
+		if (empty($plugins)) {
348
+			return;
349
+		}
350
+		foreach ($plugins as $plugin_path) {
351
+			// grab plugin folder name from path
352
+			$plugin = basename($plugin_path);
353
+			// drill down to Espresso plugins
354
+			// then to calendar related plugins
355
+			if (
356
+				strpos($plugin, 'espresso') !== false
357
+				|| strpos($plugin, 'Espresso') !== false
358
+				|| strpos($plugin, 'ee4') !== false
359
+				|| strpos($plugin, 'EE4') !== false
360
+				|| strpos($plugin, 'calendar') !== false
361
+			) {
362
+				// this is what we are looking for
363
+				$calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php';
364
+				// does it exist in this folder ?
365
+				if (is_readable($calendar_config)) {
366
+					// YEAH! let's load it
367
+					require_once($calendar_config);
368
+				}
369
+			}
370
+		}
371
+	}
372
+
373
+
374
+
375
+	/**
376
+	 *    _migrate_old_config_data
377
+	 *
378
+	 * @access    public
379
+	 * @param array|stdClass $settings
380
+	 * @param string         $config
381
+	 * @param \EE_Config     $EE_Config
382
+	 * @return \stdClass
383
+	 */
384
+	public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config)
385
+	{
386
+		$convert_from_array = array('addons');
387
+		// in case old settings were saved as an array
388
+		if (is_array($settings) && in_array($config, $convert_from_array)) {
389
+			// convert existing settings to an object
390
+			$config_array = $settings;
391
+			$settings = new stdClass();
392
+			foreach ($config_array as $key => $value) {
393
+				if ($key === 'calendar' && class_exists('EE_Calendar_Config')) {
394
+					$EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value);
395
+				} else {
396
+					$settings->{$key} = $value;
397
+				}
398
+			}
399
+			add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true');
400
+		}
401
+		return $settings;
402
+	}
403
+
404
+
405
+	/**
406
+	 * deactivate_event_espresso
407
+	 *
408
+	 * @access public
409
+	 * @static
410
+	 * @return void
411
+	 */
412
+	public static function deactivate_event_espresso()
413
+	{
414
+		// check permissions
415
+		if (current_user_can('activate_plugins')) {
416
+			deactivate_plugins(EE_PLUGIN_BASENAME, true);
417
+		}
418
+	}
419
+
420
+
421
+
422
+	/**
423
+	 * verify_default_pages_exist
424
+	 *
425
+	 * @access public
426
+	 * @static
427
+	 * @return void
428
+	 * @throws InvalidDataTypeException
429
+	 */
430
+	public static function verify_default_pages_exist()
431
+	{
432
+		$critical_page_problem = false;
433
+		$critical_pages = array(
434
+			array(
435
+				'id'   => 'reg_page_id',
436
+				'name' => __('Registration Checkout', 'event_espresso'),
437
+				'post' => null,
438
+				'code' => 'ESPRESSO_CHECKOUT',
439
+			),
440
+			array(
441
+				'id'   => 'txn_page_id',
442
+				'name' => __('Transactions', 'event_espresso'),
443
+				'post' => null,
444
+				'code' => 'ESPRESSO_TXN_PAGE',
445
+			),
446
+			array(
447
+				'id'   => 'thank_you_page_id',
448
+				'name' => __('Thank You', 'event_espresso'),
449
+				'post' => null,
450
+				'code' => 'ESPRESSO_THANK_YOU',
451
+			),
452
+			array(
453
+				'id'   => 'cancel_page_id',
454
+				'name' => __('Registration Cancelled', 'event_espresso'),
455
+				'post' => null,
456
+				'code' => 'ESPRESSO_CANCELLED',
457
+			),
458
+		);
459
+		$EE_Core_Config = EE_Registry::instance()->CFG->core;
460
+		foreach ($critical_pages as $critical_page) {
461
+			// is critical page ID set in config ?
462
+			if ($EE_Core_Config->{$critical_page['id']} !== false) {
463
+				// attempt to find post by ID
464
+				$critical_page['post'] = get_post($EE_Core_Config->{$critical_page['id']});
465
+			}
466
+			// no dice?
467
+			if ($critical_page['post'] === null) {
468
+				// attempt to find post by title
469
+				$critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']);
470
+				// still nothing?
471
+				if ($critical_page['post'] === null) {
472
+					$critical_page = EEH_Activation::create_critical_page($critical_page);
473
+					// REALLY? Still nothing ??!?!?
474
+					if ($critical_page['post'] === null) {
475
+						$msg = __(
476
+							'The Event Espresso critical page configuration settings could not be updated.',
477
+							'event_espresso'
478
+						);
479
+						EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
480
+						break;
481
+					}
482
+				}
483
+			}
484
+			// check that Post ID matches critical page ID in config
485
+			if (
486
+				isset($critical_page['post']->ID)
487
+				&& $critical_page['post']->ID !== $EE_Core_Config->{$critical_page['id']}
488
+			) {
489
+				//update Config with post ID
490
+				$EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID;
491
+				if (! EE_Config::instance()->update_espresso_config(false, false)) {
492
+					$msg = __(
493
+						'The Event Espresso critical page configuration settings could not be updated.',
494
+						'event_espresso'
495
+					);
496
+					EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
497
+				}
498
+			}
499
+			$critical_page_problem =
500
+				! isset($critical_page['post']->post_status)
501
+				|| $critical_page['post']->post_status !== 'publish'
502
+				|| strpos($critical_page['post']->post_content, $critical_page['code']) === false
503
+					? true
504
+					: $critical_page_problem;
505
+		}
506
+		if ($critical_page_problem) {
507
+			new PersistentAdminNotice(
508
+				'critical_page_problem',
509
+				sprintf(
510
+					esc_html__(
511
+						'A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.',
512
+						'event_espresso'
513
+					),
514
+					'<a href="' . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') . '">'
515
+					. __('Event Espresso Critical Pages Settings', 'event_espresso')
516
+					. '</a>'
517
+				)
518
+			);
519
+		}
520
+		if (EE_Error::has_notices()) {
521
+			EE_Error::get_notices(false, true, true);
522
+		}
523
+	}
524
+
525
+
526
+
527
+	/**
528
+	 * Returns the first post which uses the specified shortcode
529
+	 *
530
+	 * @param string $ee_shortcode usually one of the critical pages shortcodes, eg
531
+	 *                             ESPRESSO_THANK_YOU. So we will search fora post with the content
532
+	 *                             "[ESPRESSO_THANK_YOU"
533
+	 *                             (we don't search for the closing shortcode bracket because they might have added
534
+	 *                             parameter to the shortcode
535
+	 * @return WP_Post or NULl
536
+	 */
537
+	public static function get_page_by_ee_shortcode($ee_shortcode)
538
+	{
539
+		global $wpdb;
540
+		$shortcode_and_opening_bracket = '[' . $ee_shortcode;
541
+		$post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1");
542
+		if ($post_id) {
543
+			return get_post($post_id);
544
+		} else {
545
+			return null;
546
+		}
547
+	}
548
+
549
+
550
+	/**
551
+	 *    This function generates a post for critical espresso pages
552
+	 *
553
+	 * @access public
554
+	 * @static
555
+	 * @param array $critical_page
556
+	 * @return array
557
+	 */
558
+	public static function create_critical_page($critical_page)
559
+	{
560
+
561
+		$post_args = array(
562
+			'post_title'     => $critical_page['name'],
563
+			'post_status'    => 'publish',
564
+			'post_type'      => 'page',
565
+			'comment_status' => 'closed',
566
+			'post_content'   => '[' . $critical_page['code'] . ']',
567
+		);
568
+
569
+		$post_id = wp_insert_post($post_args);
570
+		if (! $post_id) {
571
+			$msg = sprintf(
572
+				__('The Event Espresso  critical page entitled "%s" could not be created.', 'event_espresso'),
573
+				$critical_page['name']
574
+			);
575
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
576
+			return $critical_page;
577
+		}
578
+		// get newly created post's details
579
+		if (! $critical_page['post'] = get_post($post_id)) {
580
+			$msg = sprintf(
581
+				__('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'),
582
+				$critical_page['name']
583
+			);
584
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
585
+		}
586
+
587
+		return $critical_page;
588
+
589
+	}
590
+
591
+
592
+
593
+
594
+	/**
595
+	 * Tries to find the oldest admin for this site.  If there are no admins for this site then return NULL.
596
+	 * The role being used to check is filterable.
597
+	 *
598
+	 * @since  4.6.0
599
+	 * @global WPDB $wpdb
600
+	 * @return mixed null|int WP_user ID or NULL
601
+	 */
602
+	public static function get_default_creator_id()
603
+	{
604
+		global $wpdb;
605
+		if ( ! empty(self::$_default_creator_id)) {
606
+			return self::$_default_creator_id;
607
+		}/**/
608
+		$role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator');
609
+		//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.
610
+		$pre_filtered_id = apply_filters(
611
+			'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id',
612
+			false,
613
+			$role_to_check
614
+		);
615
+		if ($pre_filtered_id !== false) {
616
+			return (int)$pre_filtered_id;
617
+		}
618
+		$capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('capabilities');
619
+		$query = $wpdb->prepare(
620
+			"SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1",
621
+			'%' . $role_to_check . '%'
622
+		);
623
+		$user_id = $wpdb->get_var($query);
624
+		$user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id);
625
+		if ($user_id && (int)$user_id) {
626
+			self::$_default_creator_id = (int)$user_id;
627
+			return self::$_default_creator_id;
628
+		} else {
629
+			return null;
630
+		}
631
+	}
632
+
633
+
634
+
635
+	/**
636
+	 * used by EE and EE addons during plugin activation to create tables.
637
+	 * Its a wrapper for EventEspresso\core\services\database\TableManager::createTable,
638
+	 * but includes extra logic regarding activations.
639
+	 *
640
+	 * @access public
641
+	 * @static
642
+	 * @param string  $table_name              without the $wpdb->prefix
643
+	 * @param string  $sql                     SQL for creating the table (contents between brackets in an SQL create
644
+	 *                                         table query)
645
+	 * @param string  $engine                  like 'ENGINE=MyISAM' or 'ENGINE=InnoDB'
646
+	 * @param boolean $drop_pre_existing_table set to TRUE when you want to make SURE the table is completely empty
647
+	 *                                         and new once this function is done (ie, you really do want to CREATE a
648
+	 *                                         table, and expect it to be empty once you're done) leave as FALSE when
649
+	 *                                         you just want to verify the table exists and matches this definition
650
+	 *                                         (and if it HAS data in it you want to leave it be)
651
+	 * @return void
652
+	 * @throws EE_Error if there are database errors
653
+	 */
654
+	public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false)
655
+	{
656
+		if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', false, $table_name, $sql)) {
657
+			return;
658
+		}
659
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
660
+		if ( ! function_exists('dbDelta')) {
661
+			require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
662
+		}
663
+		$tableAnalysis = \EEH_Activation::getTableAnalysis();
664
+		$wp_table_name = $tableAnalysis->ensureTableNameHasPrefix($table_name);
665
+		// do we need to first delete an existing version of this table ?
666
+		if ($drop_pre_existing_table && $tableAnalysis->tableExists($wp_table_name)) {
667
+			// ok, delete the table... but ONLY if it's empty
668
+			$deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name);
669
+			// table is NOT empty, are you SURE you want to delete this table ???
670
+			if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) {
671
+				\EEH_Activation::getTableManager()->dropTable($wp_table_name);
672
+			} else if ( ! $deleted_safely) {
673
+				// so we should be more cautious rather than just dropping tables so easily
674
+				error_log(
675
+					sprintf(
676
+						__(
677
+							'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.',
678
+							'event_espresso'
679
+						),
680
+						$wp_table_name,
681
+						'<br/>',
682
+						'espresso_db_update'
683
+					)
684
+				);
685
+			}
686
+		}
687
+		$engine = str_replace('ENGINE=', '', $engine);
688
+		\EEH_Activation::getTableManager()->createTable($table_name, $sql, $engine);
689
+	}
690
+
691
+
692
+
693
+	/**
694
+	 *    add_column_if_it_doesn't_exist
695
+	 *    Checks if this column already exists on the specified table. Handy for addons which want to add a column
696
+	 *
697
+	 * @access     public
698
+	 * @static
699
+	 * @deprecated instead use TableManager::addColumn()
700
+	 * @param string $table_name  (without "wp_", eg "esp_attendee"
701
+	 * @param string $column_name
702
+	 * @param string $column_info if your SQL were 'ALTER TABLE table_name ADD price VARCHAR(10)', this would be
703
+	 *                            'VARCHAR(10)'
704
+	 * @return bool|int
705
+	 */
706
+	public static function add_column_if_it_doesnt_exist(
707
+		$table_name,
708
+		$column_name,
709
+		$column_info = 'INT UNSIGNED NOT NULL'
710
+	) {
711
+		return \EEH_Activation::getTableManager()->addColumn($table_name, $column_name, $column_info);
712
+	}
713
+
714
+
715
+	/**
716
+	 * get_fields_on_table
717
+	 * Gets all the fields on the database table.
718
+	 *
719
+	 * @access     public
720
+	 * @deprecated instead use TableManager::getTableColumns()
721
+	 * @static
722
+	 * @param string $table_name , without prefixed $wpdb->prefix
723
+	 * @return array of database column names
724
+	 */
725
+	public static function get_fields_on_table($table_name = null)
726
+	{
727
+		return \EEH_Activation::getTableManager()->getTableColumns($table_name);
728
+	}
729
+
730
+
731
+	/**
732
+	 * db_table_is_empty
733
+	 *
734
+	 * @access     public\
735
+	 * @deprecated instead use TableAnalysis::tableIsEmpty()
736
+	 * @static
737
+	 * @param string $table_name
738
+	 * @return bool
739
+	 */
740
+	public static function db_table_is_empty($table_name)
741
+	{
742
+		return \EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name);
743
+	}
744
+
745
+
746
+	/**
747
+	 * delete_db_table_if_empty
748
+	 *
749
+	 * @access public
750
+	 * @static
751
+	 * @param string $table_name
752
+	 * @return bool | int
753
+	 */
754
+	public static function delete_db_table_if_empty($table_name)
755
+	{
756
+		if (\EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name)) {
757
+			return \EEH_Activation::getTableManager()->dropTable($table_name);
758
+		}
759
+		return false;
760
+	}
761
+
762
+
763
+	/**
764
+	 * delete_unused_db_table
765
+	 *
766
+	 * @access     public
767
+	 * @static
768
+	 * @deprecated instead use TableManager::dropTable()
769
+	 * @param string $table_name
770
+	 * @return bool | int
771
+	 */
772
+	public static function delete_unused_db_table($table_name)
773
+	{
774
+		return \EEH_Activation::getTableManager()->dropTable($table_name);
775
+	}
776
+
777
+
778
+	/**
779
+	 * drop_index
780
+	 *
781
+	 * @access     public
782
+	 * @static
783
+	 * @deprecated instead use TableManager::dropIndex()
784
+	 * @param string $table_name
785
+	 * @param string $index_name
786
+	 * @return bool | int
787
+	 */
788
+	public static function drop_index($table_name, $index_name)
789
+	{
790
+		return \EEH_Activation::getTableManager()->dropIndex($table_name, $index_name);
791
+	}
792
+
793
+
794
+
795
+	/**
796
+	 * create_database_tables
797
+	 *
798
+	 * @access public
799
+	 * @static
800
+	 * @throws EE_Error
801
+	 * @return boolean success (whether database is setup properly or not)
802
+	 */
803
+	public static function create_database_tables()
804
+	{
805
+		EE_Registry::instance()->load_core('Data_Migration_Manager');
806
+		//find the migration script that sets the database to be compatible with the code
807
+		$dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms();
808
+		if ($dms_name) {
809
+			$current_data_migration_script = EE_Registry::instance()->load_dms($dms_name);
810
+			$current_data_migration_script->set_migrating(false);
811
+			$current_data_migration_script->schema_changes_before_migration();
812
+			$current_data_migration_script->schema_changes_after_migration();
813
+			if ($current_data_migration_script->get_errors()) {
814
+				if (WP_DEBUG) {
815
+					foreach ($current_data_migration_script->get_errors() as $error) {
816
+						EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
817
+					}
818
+				} else {
819
+					EE_Error::add_error(
820
+						__(
821
+							'There were errors creating the Event Espresso database tables and Event Espresso has been 
822 822
                             deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.',
823
-                            'event_espresso'
824
-                        )
825
-                    );
826
-                }
827
-                return false;
828
-            }
829
-            EE_Data_Migration_Manager::instance()->update_current_database_state_to();
830
-        } else {
831
-            EE_Error::add_error(
832
-                __(
833
-                    'Could not determine most up-to-date data migration script from which to pull database schema
823
+							'event_espresso'
824
+						)
825
+					);
826
+				}
827
+				return false;
828
+			}
829
+			EE_Data_Migration_Manager::instance()->update_current_database_state_to();
830
+		} else {
831
+			EE_Error::add_error(
832
+				__(
833
+					'Could not determine most up-to-date data migration script from which to pull database schema
834 834
                      structure. So database is probably not setup properly',
835
-                    'event_espresso'
836
-                ),
837
-                __FILE__,
838
-                __FUNCTION__,
839
-                __LINE__
840
-            );
841
-            return false;
842
-        }
843
-        return true;
844
-    }
845
-
846
-
847
-
848
-    /**
849
-     * initialize_system_questions
850
-     *
851
-     * @access public
852
-     * @static
853
-     * @return void
854
-     */
855
-    public static function initialize_system_questions()
856
-    {
857
-        // QUESTION GROUPS
858
-        global $wpdb;
859
-        $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group');
860
-        $SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0";
861
-        // what we have
862
-        $question_groups = $wpdb->get_col($SQL);
863
-        // check the response
864
-        $question_groups = is_array($question_groups) ? $question_groups : array();
865
-        // what we should have
866
-        $QSG_systems = array(1, 2);
867
-        // loop thru what we should have and compare to what we have
868
-        foreach ($QSG_systems as $QSG_system) {
869
-            // reset values array
870
-            $QSG_values = array();
871
-            // 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)
872
-            if (! in_array("$QSG_system", $question_groups)) {
873
-                // add it
874
-                switch ($QSG_system) {
875
-                    case 1:
876
-                        $QSG_values = array(
877
-                            'QSG_name'            => __('Personal Information', 'event_espresso'),
878
-                            'QSG_identifier'      => 'personal-information-' . time(),
879
-                            'QSG_desc'            => '',
880
-                            'QSG_order'           => 1,
881
-                            'QSG_show_group_name' => 1,
882
-                            'QSG_show_group_desc' => 1,
883
-                            'QSG_system'          => EEM_Question_Group::system_personal,
884
-                            'QSG_deleted'         => 0,
885
-                        );
886
-                        break;
887
-                    case 2:
888
-                        $QSG_values = array(
889
-                            'QSG_name'            => __('Address Information', 'event_espresso'),
890
-                            'QSG_identifier'      => 'address-information-' . time(),
891
-                            'QSG_desc'            => '',
892
-                            'QSG_order'           => 2,
893
-                            'QSG_show_group_name' => 1,
894
-                            'QSG_show_group_desc' => 1,
895
-                            'QSG_system'          => EEM_Question_Group::system_address,
896
-                            'QSG_deleted'         => 0,
897
-                        );
898
-                        break;
899
-                }
900
-                // make sure we have some values before inserting them
901
-                if (! empty($QSG_values)) {
902
-                    // insert system question
903
-                    $wpdb->insert(
904
-                        $table_name,
905
-                        $QSG_values,
906
-                        array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d')
907
-                    );
908
-                    $QSG_IDs[$QSG_system] = $wpdb->insert_id;
909
-                }
910
-            }
911
-        }
912
-        // QUESTIONS
913
-        global $wpdb;
914
-        $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question');
915
-        $SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''";
916
-        // what we have
917
-        $questions = $wpdb->get_col($SQL);
918
-        // what we should have
919
-        $QST_systems = array(
920
-            'fname',
921
-            'lname',
922
-            'email',
923
-            'address',
924
-            'address2',
925
-            'city',
926
-            'country',
927
-            'state',
928
-            'zip',
929
-            'phone',
930
-        );
931
-        $order_for_group_1 = 1;
932
-        $order_for_group_2 = 1;
933
-        // loop thru what we should have and compare to what we have
934
-        foreach ($QST_systems as $QST_system) {
935
-            // reset values array
936
-            $QST_values = array();
937
-            // if we don't have what we should have
938
-            if (! in_array($QST_system, $questions)) {
939
-                // add it
940
-                switch ($QST_system) {
941
-                    case 'fname':
942
-                        $QST_values = array(
943
-                            'QST_display_text'  => __('First Name', 'event_espresso'),
944
-                            'QST_admin_label'   => __('First Name - System Question', 'event_espresso'),
945
-                            'QST_system'        => 'fname',
946
-                            'QST_type'          => 'TEXT',
947
-                            'QST_required'      => 1,
948
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
949
-                            'QST_order'         => 1,
950
-                            'QST_admin_only'    => 0,
951
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
952
-                            'QST_wp_user'       => self::get_default_creator_id(),
953
-                            'QST_deleted'       => 0,
954
-                        );
955
-                        break;
956
-                    case 'lname':
957
-                        $QST_values = array(
958
-                            'QST_display_text'  => __('Last Name', 'event_espresso'),
959
-                            'QST_admin_label'   => __('Last Name - System Question', 'event_espresso'),
960
-                            'QST_system'        => 'lname',
961
-                            'QST_type'          => 'TEXT',
962
-                            'QST_required'      => 1,
963
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
964
-                            'QST_order'         => 2,
965
-                            'QST_admin_only'    => 0,
966
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
967
-                            'QST_wp_user'       => self::get_default_creator_id(),
968
-                            'QST_deleted'       => 0,
969
-                        );
970
-                        break;
971
-                    case 'email':
972
-                        $QST_values = array(
973
-                            'QST_display_text'  => __('Email Address', 'event_espresso'),
974
-                            'QST_admin_label'   => __('Email Address - System Question', 'event_espresso'),
975
-                            'QST_system'        => 'email',
976
-                            'QST_type'          => 'EMAIL',
977
-                            'QST_required'      => 1,
978
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
979
-                            'QST_order'         => 3,
980
-                            'QST_admin_only'    => 0,
981
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
982
-                            'QST_wp_user'       => self::get_default_creator_id(),
983
-                            'QST_deleted'       => 0,
984
-                        );
985
-                        break;
986
-                    case 'address':
987
-                        $QST_values = array(
988
-                            'QST_display_text'  => __('Address', 'event_espresso'),
989
-                            'QST_admin_label'   => __('Address - System Question', 'event_espresso'),
990
-                            'QST_system'        => 'address',
991
-                            'QST_type'          => 'TEXT',
992
-                            'QST_required'      => 0,
993
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
994
-                            'QST_order'         => 4,
995
-                            'QST_admin_only'    => 0,
996
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
997
-                            'QST_wp_user'       => self::get_default_creator_id(),
998
-                            'QST_deleted'       => 0,
999
-                        );
1000
-                        break;
1001
-                    case 'address2':
1002
-                        $QST_values = array(
1003
-                            'QST_display_text'  => __('Address2', 'event_espresso'),
1004
-                            'QST_admin_label'   => __('Address2 - System Question', 'event_espresso'),
1005
-                            'QST_system'        => 'address2',
1006
-                            'QST_type'          => 'TEXT',
1007
-                            'QST_required'      => 0,
1008
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1009
-                            'QST_order'         => 5,
1010
-                            'QST_admin_only'    => 0,
1011
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1012
-                            'QST_wp_user'       => self::get_default_creator_id(),
1013
-                            'QST_deleted'       => 0,
1014
-                        );
1015
-                        break;
1016
-                    case 'city':
1017
-                        $QST_values = array(
1018
-                            'QST_display_text'  => __('City', 'event_espresso'),
1019
-                            'QST_admin_label'   => __('City - System Question', 'event_espresso'),
1020
-                            'QST_system'        => 'city',
1021
-                            'QST_type'          => 'TEXT',
1022
-                            'QST_required'      => 0,
1023
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1024
-                            'QST_order'         => 6,
1025
-                            'QST_admin_only'    => 0,
1026
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1027
-                            'QST_wp_user'       => self::get_default_creator_id(),
1028
-                            'QST_deleted'       => 0,
1029
-                        );
1030
-                        break;
1031
-                    case 'country':
1032
-                        $QST_values = array(
1033
-                            'QST_display_text'  => __('Country', 'event_espresso'),
1034
-                            'QST_admin_label'   => __('Country - System Question', 'event_espresso'),
1035
-                            'QST_system'        => 'country',
1036
-                            'QST_type'          => 'COUNTRY',
1037
-                            'QST_required'      => 0,
1038
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1039
-                            'QST_order'         => 7,
1040
-                            'QST_admin_only'    => 0,
1041
-                            'QST_wp_user'       => self::get_default_creator_id(),
1042
-                            'QST_deleted'       => 0,
1043
-                        );
1044
-                        break;
1045
-                    case 'state':
1046
-                        $QST_values = array(
1047
-                            'QST_display_text'  => __('State/Province', 'event_espresso'),
1048
-                            'QST_admin_label'   => __('State/Province - System Question', 'event_espresso'),
1049
-                            'QST_system'        => 'state',
1050
-                            'QST_type'          => 'STATE',
1051
-                            'QST_required'      => 0,
1052
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1053
-                            'QST_order'         => 8,
1054
-                            'QST_admin_only'    => 0,
1055
-                            'QST_wp_user'       => self::get_default_creator_id(),
1056
-                            'QST_deleted'       => 0,
1057
-                        );
1058
-                        break;
1059
-                    case 'zip':
1060
-                        $QST_values = array(
1061
-                            'QST_display_text'  => __('Zip/Postal Code', 'event_espresso'),
1062
-                            'QST_admin_label'   => __('Zip/Postal Code - System Question', 'event_espresso'),
1063
-                            'QST_system'        => 'zip',
1064
-                            'QST_type'          => 'TEXT',
1065
-                            'QST_required'      => 0,
1066
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1067
-                            'QST_order'         => 9,
1068
-                            'QST_admin_only'    => 0,
1069
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1070
-                            'QST_wp_user'       => self::get_default_creator_id(),
1071
-                            'QST_deleted'       => 0,
1072
-                        );
1073
-                        break;
1074
-                    case 'phone':
1075
-                        $QST_values = array(
1076
-                            'QST_display_text'  => __('Phone Number', 'event_espresso'),
1077
-                            'QST_admin_label'   => __('Phone Number - System Question', 'event_espresso'),
1078
-                            'QST_system'        => 'phone',
1079
-                            'QST_type'          => 'TEXT',
1080
-                            'QST_required'      => 0,
1081
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1082
-                            'QST_order'         => 10,
1083
-                            'QST_admin_only'    => 0,
1084
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1085
-                            'QST_wp_user'       => self::get_default_creator_id(),
1086
-                            'QST_deleted'       => 0,
1087
-                        );
1088
-                        break;
1089
-                }
1090
-                if (! empty($QST_values)) {
1091
-                    // insert system question
1092
-                    $wpdb->insert(
1093
-                        $table_name,
1094
-                        $QST_values,
1095
-                        array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d')
1096
-                    );
1097
-                    $QST_ID = $wpdb->insert_id;
1098
-                    // QUESTION GROUP QUESTIONS
1099
-                    if (in_array($QST_system, array('fname', 'lname', 'email'))) {
1100
-                        $system_question_we_want = EEM_Question_Group::system_personal;
1101
-                    } else {
1102
-                        $system_question_we_want = EEM_Question_Group::system_address;
1103
-                    }
1104
-                    if (isset($QSG_IDs[$system_question_we_want])) {
1105
-                        $QSG_ID = $QSG_IDs[$system_question_we_want];
1106
-                    } else {
1107
-                        $id_col = EEM_Question_Group::instance()
1108
-                                                    ->get_col(array(array('QSG_system' => $system_question_we_want)));
1109
-                        if (is_array($id_col)) {
1110
-                            $QSG_ID = reset($id_col);
1111
-                        } else {
1112
-                            //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
1113
-                            EE_Log::instance()->log(
1114
-                                __FILE__,
1115
-                                __FUNCTION__,
1116
-                                sprintf(
1117
-                                    __(
1118
-                                        'Could not associate question %1$s to a question group because no system question
835
+					'event_espresso'
836
+				),
837
+				__FILE__,
838
+				__FUNCTION__,
839
+				__LINE__
840
+			);
841
+			return false;
842
+		}
843
+		return true;
844
+	}
845
+
846
+
847
+
848
+	/**
849
+	 * initialize_system_questions
850
+	 *
851
+	 * @access public
852
+	 * @static
853
+	 * @return void
854
+	 */
855
+	public static function initialize_system_questions()
856
+	{
857
+		// QUESTION GROUPS
858
+		global $wpdb;
859
+		$table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group');
860
+		$SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0";
861
+		// what we have
862
+		$question_groups = $wpdb->get_col($SQL);
863
+		// check the response
864
+		$question_groups = is_array($question_groups) ? $question_groups : array();
865
+		// what we should have
866
+		$QSG_systems = array(1, 2);
867
+		// loop thru what we should have and compare to what we have
868
+		foreach ($QSG_systems as $QSG_system) {
869
+			// reset values array
870
+			$QSG_values = array();
871
+			// 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)
872
+			if (! in_array("$QSG_system", $question_groups)) {
873
+				// add it
874
+				switch ($QSG_system) {
875
+					case 1:
876
+						$QSG_values = array(
877
+							'QSG_name'            => __('Personal Information', 'event_espresso'),
878
+							'QSG_identifier'      => 'personal-information-' . time(),
879
+							'QSG_desc'            => '',
880
+							'QSG_order'           => 1,
881
+							'QSG_show_group_name' => 1,
882
+							'QSG_show_group_desc' => 1,
883
+							'QSG_system'          => EEM_Question_Group::system_personal,
884
+							'QSG_deleted'         => 0,
885
+						);
886
+						break;
887
+					case 2:
888
+						$QSG_values = array(
889
+							'QSG_name'            => __('Address Information', 'event_espresso'),
890
+							'QSG_identifier'      => 'address-information-' . time(),
891
+							'QSG_desc'            => '',
892
+							'QSG_order'           => 2,
893
+							'QSG_show_group_name' => 1,
894
+							'QSG_show_group_desc' => 1,
895
+							'QSG_system'          => EEM_Question_Group::system_address,
896
+							'QSG_deleted'         => 0,
897
+						);
898
+						break;
899
+				}
900
+				// make sure we have some values before inserting them
901
+				if (! empty($QSG_values)) {
902
+					// insert system question
903
+					$wpdb->insert(
904
+						$table_name,
905
+						$QSG_values,
906
+						array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d')
907
+					);
908
+					$QSG_IDs[$QSG_system] = $wpdb->insert_id;
909
+				}
910
+			}
911
+		}
912
+		// QUESTIONS
913
+		global $wpdb;
914
+		$table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question');
915
+		$SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''";
916
+		// what we have
917
+		$questions = $wpdb->get_col($SQL);
918
+		// what we should have
919
+		$QST_systems = array(
920
+			'fname',
921
+			'lname',
922
+			'email',
923
+			'address',
924
+			'address2',
925
+			'city',
926
+			'country',
927
+			'state',
928
+			'zip',
929
+			'phone',
930
+		);
931
+		$order_for_group_1 = 1;
932
+		$order_for_group_2 = 1;
933
+		// loop thru what we should have and compare to what we have
934
+		foreach ($QST_systems as $QST_system) {
935
+			// reset values array
936
+			$QST_values = array();
937
+			// if we don't have what we should have
938
+			if (! in_array($QST_system, $questions)) {
939
+				// add it
940
+				switch ($QST_system) {
941
+					case 'fname':
942
+						$QST_values = array(
943
+							'QST_display_text'  => __('First Name', 'event_espresso'),
944
+							'QST_admin_label'   => __('First Name - System Question', 'event_espresso'),
945
+							'QST_system'        => 'fname',
946
+							'QST_type'          => 'TEXT',
947
+							'QST_required'      => 1,
948
+							'QST_required_text' => __('This field is required', 'event_espresso'),
949
+							'QST_order'         => 1,
950
+							'QST_admin_only'    => 0,
951
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
952
+							'QST_wp_user'       => self::get_default_creator_id(),
953
+							'QST_deleted'       => 0,
954
+						);
955
+						break;
956
+					case 'lname':
957
+						$QST_values = array(
958
+							'QST_display_text'  => __('Last Name', 'event_espresso'),
959
+							'QST_admin_label'   => __('Last Name - System Question', 'event_espresso'),
960
+							'QST_system'        => 'lname',
961
+							'QST_type'          => 'TEXT',
962
+							'QST_required'      => 1,
963
+							'QST_required_text' => __('This field is required', 'event_espresso'),
964
+							'QST_order'         => 2,
965
+							'QST_admin_only'    => 0,
966
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
967
+							'QST_wp_user'       => self::get_default_creator_id(),
968
+							'QST_deleted'       => 0,
969
+						);
970
+						break;
971
+					case 'email':
972
+						$QST_values = array(
973
+							'QST_display_text'  => __('Email Address', 'event_espresso'),
974
+							'QST_admin_label'   => __('Email Address - System Question', 'event_espresso'),
975
+							'QST_system'        => 'email',
976
+							'QST_type'          => 'EMAIL',
977
+							'QST_required'      => 1,
978
+							'QST_required_text' => __('This field is required', 'event_espresso'),
979
+							'QST_order'         => 3,
980
+							'QST_admin_only'    => 0,
981
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
982
+							'QST_wp_user'       => self::get_default_creator_id(),
983
+							'QST_deleted'       => 0,
984
+						);
985
+						break;
986
+					case 'address':
987
+						$QST_values = array(
988
+							'QST_display_text'  => __('Address', 'event_espresso'),
989
+							'QST_admin_label'   => __('Address - System Question', 'event_espresso'),
990
+							'QST_system'        => 'address',
991
+							'QST_type'          => 'TEXT',
992
+							'QST_required'      => 0,
993
+							'QST_required_text' => __('This field is required', 'event_espresso'),
994
+							'QST_order'         => 4,
995
+							'QST_admin_only'    => 0,
996
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
997
+							'QST_wp_user'       => self::get_default_creator_id(),
998
+							'QST_deleted'       => 0,
999
+						);
1000
+						break;
1001
+					case 'address2':
1002
+						$QST_values = array(
1003
+							'QST_display_text'  => __('Address2', 'event_espresso'),
1004
+							'QST_admin_label'   => __('Address2 - System Question', 'event_espresso'),
1005
+							'QST_system'        => 'address2',
1006
+							'QST_type'          => 'TEXT',
1007
+							'QST_required'      => 0,
1008
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1009
+							'QST_order'         => 5,
1010
+							'QST_admin_only'    => 0,
1011
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1012
+							'QST_wp_user'       => self::get_default_creator_id(),
1013
+							'QST_deleted'       => 0,
1014
+						);
1015
+						break;
1016
+					case 'city':
1017
+						$QST_values = array(
1018
+							'QST_display_text'  => __('City', 'event_espresso'),
1019
+							'QST_admin_label'   => __('City - System Question', 'event_espresso'),
1020
+							'QST_system'        => 'city',
1021
+							'QST_type'          => 'TEXT',
1022
+							'QST_required'      => 0,
1023
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1024
+							'QST_order'         => 6,
1025
+							'QST_admin_only'    => 0,
1026
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1027
+							'QST_wp_user'       => self::get_default_creator_id(),
1028
+							'QST_deleted'       => 0,
1029
+						);
1030
+						break;
1031
+					case 'country':
1032
+						$QST_values = array(
1033
+							'QST_display_text'  => __('Country', 'event_espresso'),
1034
+							'QST_admin_label'   => __('Country - System Question', 'event_espresso'),
1035
+							'QST_system'        => 'country',
1036
+							'QST_type'          => 'COUNTRY',
1037
+							'QST_required'      => 0,
1038
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1039
+							'QST_order'         => 7,
1040
+							'QST_admin_only'    => 0,
1041
+							'QST_wp_user'       => self::get_default_creator_id(),
1042
+							'QST_deleted'       => 0,
1043
+						);
1044
+						break;
1045
+					case 'state':
1046
+						$QST_values = array(
1047
+							'QST_display_text'  => __('State/Province', 'event_espresso'),
1048
+							'QST_admin_label'   => __('State/Province - System Question', 'event_espresso'),
1049
+							'QST_system'        => 'state',
1050
+							'QST_type'          => 'STATE',
1051
+							'QST_required'      => 0,
1052
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1053
+							'QST_order'         => 8,
1054
+							'QST_admin_only'    => 0,
1055
+							'QST_wp_user'       => self::get_default_creator_id(),
1056
+							'QST_deleted'       => 0,
1057
+						);
1058
+						break;
1059
+					case 'zip':
1060
+						$QST_values = array(
1061
+							'QST_display_text'  => __('Zip/Postal Code', 'event_espresso'),
1062
+							'QST_admin_label'   => __('Zip/Postal Code - System Question', 'event_espresso'),
1063
+							'QST_system'        => 'zip',
1064
+							'QST_type'          => 'TEXT',
1065
+							'QST_required'      => 0,
1066
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1067
+							'QST_order'         => 9,
1068
+							'QST_admin_only'    => 0,
1069
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1070
+							'QST_wp_user'       => self::get_default_creator_id(),
1071
+							'QST_deleted'       => 0,
1072
+						);
1073
+						break;
1074
+					case 'phone':
1075
+						$QST_values = array(
1076
+							'QST_display_text'  => __('Phone Number', 'event_espresso'),
1077
+							'QST_admin_label'   => __('Phone Number - System Question', 'event_espresso'),
1078
+							'QST_system'        => 'phone',
1079
+							'QST_type'          => 'TEXT',
1080
+							'QST_required'      => 0,
1081
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1082
+							'QST_order'         => 10,
1083
+							'QST_admin_only'    => 0,
1084
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1085
+							'QST_wp_user'       => self::get_default_creator_id(),
1086
+							'QST_deleted'       => 0,
1087
+						);
1088
+						break;
1089
+				}
1090
+				if (! empty($QST_values)) {
1091
+					// insert system question
1092
+					$wpdb->insert(
1093
+						$table_name,
1094
+						$QST_values,
1095
+						array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d')
1096
+					);
1097
+					$QST_ID = $wpdb->insert_id;
1098
+					// QUESTION GROUP QUESTIONS
1099
+					if (in_array($QST_system, array('fname', 'lname', 'email'))) {
1100
+						$system_question_we_want = EEM_Question_Group::system_personal;
1101
+					} else {
1102
+						$system_question_we_want = EEM_Question_Group::system_address;
1103
+					}
1104
+					if (isset($QSG_IDs[$system_question_we_want])) {
1105
+						$QSG_ID = $QSG_IDs[$system_question_we_want];
1106
+					} else {
1107
+						$id_col = EEM_Question_Group::instance()
1108
+													->get_col(array(array('QSG_system' => $system_question_we_want)));
1109
+						if (is_array($id_col)) {
1110
+							$QSG_ID = reset($id_col);
1111
+						} else {
1112
+							//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
1113
+							EE_Log::instance()->log(
1114
+								__FILE__,
1115
+								__FUNCTION__,
1116
+								sprintf(
1117
+									__(
1118
+										'Could not associate question %1$s to a question group because no system question
1119 1119
                                          group existed',
1120
-                                        'event_espresso'
1121
-                                    ),
1122
-                                    $QST_ID),
1123
-                                'error');
1124
-                            continue;
1125
-                        }
1126
-                    }
1127
-                    // add system questions to groups
1128
-                    $wpdb->insert(
1129
-                        \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group_question'),
1130
-                        array(
1131
-                            'QSG_ID'    => $QSG_ID,
1132
-                            'QST_ID'    => $QST_ID,
1133
-                            'QGQ_order' => ($QSG_ID === 1) ? $order_for_group_1++ : $order_for_group_2++,
1134
-                        ),
1135
-                        array('%d', '%d', '%d')
1136
-                    );
1137
-                }
1138
-            }
1139
-        }
1140
-    }
1141
-
1142
-
1143
-    /**
1144
-     * Makes sure the default payment method (Invoice) is active.
1145
-     * This used to be done automatically as part of constructing the old gateways config
1146
-     *
1147
-     * @throws \EE_Error
1148
-     */
1149
-    public static function insert_default_payment_methods()
1150
-    {
1151
-        if (! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) {
1152
-            EE_Registry::instance()->load_lib('Payment_Method_Manager');
1153
-            EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
1154
-        } else {
1155
-            EEM_Payment_Method::instance()->verify_button_urls();
1156
-        }
1157
-    }
1158
-
1159
-    /**
1160
-     * insert_default_status_codes
1161
-     *
1162
-     * @access public
1163
-     * @static
1164
-     * @return void
1165
-     */
1166
-    public static function insert_default_status_codes()
1167
-    {
1168
-
1169
-        global $wpdb;
1170
-
1171
-        if (\EEH_Activation::getTableAnalysis()->tableExists(EEM_Status::instance()->table())) {
1172
-
1173
-            $table_name = EEM_Status::instance()->table();
1174
-
1175
-            $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' );";
1176
-            $wpdb->query($SQL);
1177
-
1178
-            $SQL = "INSERT INTO $table_name
1120
+										'event_espresso'
1121
+									),
1122
+									$QST_ID),
1123
+								'error');
1124
+							continue;
1125
+						}
1126
+					}
1127
+					// add system questions to groups
1128
+					$wpdb->insert(
1129
+						\EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group_question'),
1130
+						array(
1131
+							'QSG_ID'    => $QSG_ID,
1132
+							'QST_ID'    => $QST_ID,
1133
+							'QGQ_order' => ($QSG_ID === 1) ? $order_for_group_1++ : $order_for_group_2++,
1134
+						),
1135
+						array('%d', '%d', '%d')
1136
+					);
1137
+				}
1138
+			}
1139
+		}
1140
+	}
1141
+
1142
+
1143
+	/**
1144
+	 * Makes sure the default payment method (Invoice) is active.
1145
+	 * This used to be done automatically as part of constructing the old gateways config
1146
+	 *
1147
+	 * @throws \EE_Error
1148
+	 */
1149
+	public static function insert_default_payment_methods()
1150
+	{
1151
+		if (! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) {
1152
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
1153
+			EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
1154
+		} else {
1155
+			EEM_Payment_Method::instance()->verify_button_urls();
1156
+		}
1157
+	}
1158
+
1159
+	/**
1160
+	 * insert_default_status_codes
1161
+	 *
1162
+	 * @access public
1163
+	 * @static
1164
+	 * @return void
1165
+	 */
1166
+	public static function insert_default_status_codes()
1167
+	{
1168
+
1169
+		global $wpdb;
1170
+
1171
+		if (\EEH_Activation::getTableAnalysis()->tableExists(EEM_Status::instance()->table())) {
1172
+
1173
+			$table_name = EEM_Status::instance()->table();
1174
+
1175
+			$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' );";
1176
+			$wpdb->query($SQL);
1177
+
1178
+			$SQL = "INSERT INTO $table_name
1179 1179
 					(STS_ID, STS_code, STS_type, STS_can_edit, STS_desc, STS_open) VALUES
1180 1180
 					('ACT', 'ACTIVE', 'event', 0, NULL, 1),
1181 1181
 					('NAC', 'NOT_ACTIVE', 'event', 0, NULL, 0),
@@ -1215,521 +1215,521 @@  discard block
 block discarded – undo
1215 1215
 					('MID', 'IDLE', 'message', 0, NULL, 1),
1216 1216
 					('MRS', 'RESEND', 'message', 0, NULL, 1),
1217 1217
 					('MIC', 'INCOMPLETE', 'message', 0, NULL, 0);";
1218
-            $wpdb->query($SQL);
1219
-
1220
-        }
1221
-
1222
-    }
1223
-
1224
-
1225
-    /**
1226
-     * create_upload_directories
1227
-     * Creates folders in the uploads directory to facilitate addons and templates
1228
-     *
1229
-     * @access public
1230
-     * @static
1231
-     * @return boolean success of verifying upload directories exist
1232
-     */
1233
-    public static function create_upload_directories()
1234
-    {
1235
-        // Create the required folders
1236
-        $folders = array(
1237
-            EVENT_ESPRESSO_TEMPLATE_DIR,
1238
-            EVENT_ESPRESSO_GATEWAY_DIR,
1239
-            EVENT_ESPRESSO_UPLOAD_DIR . 'logs/',
1240
-            EVENT_ESPRESSO_UPLOAD_DIR . 'css/',
1241
-            EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/',
1242
-        );
1243
-        foreach ($folders as $folder) {
1244
-            try {
1245
-                EEH_File::ensure_folder_exists_and_is_writable($folder);
1246
-                @ chmod($folder, 0755);
1247
-            } catch (EE_Error $e) {
1248
-                EE_Error::add_error(
1249
-                    sprintf(
1250
-                        __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'),
1251
-                        $folder,
1252
-                        '<br />' . $e->getMessage()
1253
-                    ),
1254
-                    __FILE__, __FUNCTION__, __LINE__
1255
-                );
1256
-                //indicate we'll need to fix this later
1257
-                update_option(EEH_Activation::upload_directories_incomplete_option_name, true);
1258
-                return false;
1259
-            }
1260
-        }
1261
-        //just add the .htaccess file to the logs directory to begin with. Even if logging
1262
-        //is disabled, there might be activation errors recorded in there
1263
-        EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs/');
1264
-        //remember EE's folders are all good
1265
-        delete_option(EEH_Activation::upload_directories_incomplete_option_name);
1266
-        return true;
1267
-    }
1268
-
1269
-    /**
1270
-     * Whether the upload directories need to be fixed or not.
1271
-     * If EE is installed but filesystem access isn't initially available,
1272
-     * we need to get the user's filesystem credentials and THEN create them,
1273
-     * so there might be period of time when EE is installed but its
1274
-     * upload directories aren't available. This indicates such a state
1275
-     *
1276
-     * @return boolean
1277
-     */
1278
-    public static function upload_directories_incomplete()
1279
-    {
1280
-        return get_option(EEH_Activation::upload_directories_incomplete_option_name, false);
1281
-    }
1282
-
1283
-
1284
-    /**
1285
-     * generate_default_message_templates
1286
-     *
1287
-     * @static
1288
-     * @throws EE_Error
1289
-     * @return bool     true means new templates were created.
1290
-     *                  false means no templates were created.
1291
-     *                  This is NOT an error flag. To check for errors you will want
1292
-     *                  to use either EE_Error or a try catch for an EE_Error exception.
1293
-     */
1294
-    public static function generate_default_message_templates()
1295
-    {
1296
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
1297
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
1298
-        /*
1218
+			$wpdb->query($SQL);
1219
+
1220
+		}
1221
+
1222
+	}
1223
+
1224
+
1225
+	/**
1226
+	 * create_upload_directories
1227
+	 * Creates folders in the uploads directory to facilitate addons and templates
1228
+	 *
1229
+	 * @access public
1230
+	 * @static
1231
+	 * @return boolean success of verifying upload directories exist
1232
+	 */
1233
+	public static function create_upload_directories()
1234
+	{
1235
+		// Create the required folders
1236
+		$folders = array(
1237
+			EVENT_ESPRESSO_TEMPLATE_DIR,
1238
+			EVENT_ESPRESSO_GATEWAY_DIR,
1239
+			EVENT_ESPRESSO_UPLOAD_DIR . 'logs/',
1240
+			EVENT_ESPRESSO_UPLOAD_DIR . 'css/',
1241
+			EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/',
1242
+		);
1243
+		foreach ($folders as $folder) {
1244
+			try {
1245
+				EEH_File::ensure_folder_exists_and_is_writable($folder);
1246
+				@ chmod($folder, 0755);
1247
+			} catch (EE_Error $e) {
1248
+				EE_Error::add_error(
1249
+					sprintf(
1250
+						__('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'),
1251
+						$folder,
1252
+						'<br />' . $e->getMessage()
1253
+					),
1254
+					__FILE__, __FUNCTION__, __LINE__
1255
+				);
1256
+				//indicate we'll need to fix this later
1257
+				update_option(EEH_Activation::upload_directories_incomplete_option_name, true);
1258
+				return false;
1259
+			}
1260
+		}
1261
+		//just add the .htaccess file to the logs directory to begin with. Even if logging
1262
+		//is disabled, there might be activation errors recorded in there
1263
+		EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs/');
1264
+		//remember EE's folders are all good
1265
+		delete_option(EEH_Activation::upload_directories_incomplete_option_name);
1266
+		return true;
1267
+	}
1268
+
1269
+	/**
1270
+	 * Whether the upload directories need to be fixed or not.
1271
+	 * If EE is installed but filesystem access isn't initially available,
1272
+	 * we need to get the user's filesystem credentials and THEN create them,
1273
+	 * so there might be period of time when EE is installed but its
1274
+	 * upload directories aren't available. This indicates such a state
1275
+	 *
1276
+	 * @return boolean
1277
+	 */
1278
+	public static function upload_directories_incomplete()
1279
+	{
1280
+		return get_option(EEH_Activation::upload_directories_incomplete_option_name, false);
1281
+	}
1282
+
1283
+
1284
+	/**
1285
+	 * generate_default_message_templates
1286
+	 *
1287
+	 * @static
1288
+	 * @throws EE_Error
1289
+	 * @return bool     true means new templates were created.
1290
+	 *                  false means no templates were created.
1291
+	 *                  This is NOT an error flag. To check for errors you will want
1292
+	 *                  to use either EE_Error or a try catch for an EE_Error exception.
1293
+	 */
1294
+	public static function generate_default_message_templates()
1295
+	{
1296
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
1297
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
1298
+		/*
1299 1299
          * This first method is taking care of ensuring any default messengers
1300 1300
          * that should be made active and have templates generated are done.
1301 1301
          */
1302
-        $new_templates_created_for_messenger = self::_activate_and_generate_default_messengers_and_message_templates(
1303
-            $message_resource_manager
1304
-        );
1305
-        /**
1306
-         * This method is verifying there are no NEW default message types
1307
-         * for ACTIVE messengers that need activated (and corresponding templates setup).
1308
-         */
1309
-        $new_templates_created_for_message_type = self::_activate_new_message_types_for_active_messengers_and_generate_default_templates(
1310
-            $message_resource_manager
1311
-        );
1312
-        //after all is done, let's persist these changes to the db.
1313
-        $message_resource_manager->update_has_activated_messengers_option();
1314
-        $message_resource_manager->update_active_messengers_option();
1315
-        // will return true if either of these are true.  Otherwise will return false.
1316
-        return $new_templates_created_for_message_type || $new_templates_created_for_messenger;
1317
-    }
1318
-
1319
-
1320
-
1321
-    /**
1322
-     * @param \EE_Message_Resource_Manager $message_resource_manager
1323
-     * @return array|bool
1324
-     * @throws \EE_Error
1325
-     */
1326
-    protected static function _activate_new_message_types_for_active_messengers_and_generate_default_templates(
1327
-        EE_Message_Resource_Manager $message_resource_manager
1328
-    ) {
1329
-        /** @type EE_messenger[] $active_messengers */
1330
-        $active_messengers = $message_resource_manager->active_messengers();
1331
-        $installed_message_types = $message_resource_manager->installed_message_types();
1332
-        $templates_created = false;
1333
-        foreach ($active_messengers as $active_messenger) {
1334
-            $default_message_type_names_for_messenger = $active_messenger->get_default_message_types();
1335
-            $default_message_type_names_to_activate = array();
1336
-            // looping through each default message type reported by the messenger
1337
-            // and setup the actual message types to activate.
1338
-            foreach ($default_message_type_names_for_messenger as $default_message_type_name_for_messenger) {
1339
-                // if already active or has already been activated before we skip
1340
-                // (otherwise we might reactivate something user's intentionally deactivated.)
1341
-                // we also skip if the message type is not installed.
1342
-                if (
1343
-                    $message_resource_manager->has_message_type_been_activated_for_messenger(
1344
-                        $default_message_type_name_for_messenger,
1345
-                        $active_messenger->name
1346
-                    )
1347
-                    || $message_resource_manager->is_message_type_active_for_messenger(
1348
-                        $active_messenger->name,
1349
-                        $default_message_type_name_for_messenger
1350
-                    )
1351
-                    || ! isset($installed_message_types[$default_message_type_name_for_messenger])
1352
-                ) {
1353
-                    continue;
1354
-                }
1355
-                $default_message_type_names_to_activate[] = $default_message_type_name_for_messenger;
1356
-            }
1357
-            //let's activate!
1358
-            $message_resource_manager->ensure_message_types_are_active(
1359
-                $default_message_type_names_to_activate,
1360
-                $active_messenger->name,
1361
-                false
1362
-            );
1363
-            //activate the templates for these message types
1364
-            if ( ! empty($default_message_type_names_to_activate)) {
1365
-                $templates_created = EEH_MSG_Template::generate_new_templates(
1366
-                    $active_messenger->name,
1367
-                    $default_message_type_names_for_messenger,
1368
-                    '',
1369
-                    true
1370
-                );
1371
-            }
1372
-        }
1373
-        return $templates_created;
1374
-    }
1375
-
1376
-
1377
-
1378
-    /**
1379
-     * This will activate and generate default messengers and default message types for those messengers.
1380
-     *
1381
-     * @param EE_message_Resource_Manager $message_resource_manager
1382
-     * @return array|bool  True means there were default messengers and message type templates generated.
1383
-     *                     False means that there were no templates generated
1384
-     *                     (which could simply mean there are no default message types for a messenger).
1385
-     * @throws EE_Error
1386
-     */
1387
-    protected static function _activate_and_generate_default_messengers_and_message_templates(
1388
-        EE_Message_Resource_Manager $message_resource_manager
1389
-    ) {
1390
-        /** @type EE_messenger[] $messengers_to_generate */
1391
-        $messengers_to_generate = self::_get_default_messengers_to_generate_on_activation($message_resource_manager);
1392
-        $installed_message_types = $message_resource_manager->installed_message_types();
1393
-        $templates_generated = false;
1394
-        foreach ($messengers_to_generate as $messenger_to_generate) {
1395
-            $default_message_type_names_for_messenger = $messenger_to_generate->get_default_message_types();
1396
-            //verify the default message types match an installed message type.
1397
-            foreach ($default_message_type_names_for_messenger as $key => $name) {
1398
-                if (
1399
-                    ! isset($installed_message_types[$name])
1400
-                    || $message_resource_manager->has_message_type_been_activated_for_messenger(
1401
-                        $name,
1402
-                        $messenger_to_generate->name
1403
-                    )
1404
-                ) {
1405
-                    unset($default_message_type_names_for_messenger[$key]);
1406
-                }
1407
-            }
1408
-            // in previous iterations, the active_messengers option in the db
1409
-            // needed updated before calling create templates. however with the changes this may not be necessary.
1410
-            // This comment is left here just in case we discover that we _do_ need to update before
1411
-            // passing off to create templates (after the refactor is done).
1412
-            // @todo remove this comment when determined not necessary.
1413
-            $message_resource_manager->activate_messenger(
1414
-                $messenger_to_generate->name,
1415
-                $default_message_type_names_for_messenger,
1416
-                false
1417
-            );
1418
-            //create any templates needing created (or will reactivate templates already generated as necessary).
1419
-            if ( ! empty($default_message_type_names_for_messenger)) {
1420
-                $templates_generated = EEH_MSG_Template::generate_new_templates(
1421
-                    $messenger_to_generate->name,
1422
-                    $default_message_type_names_for_messenger,
1423
-                    '',
1424
-                    true
1425
-                );
1426
-            }
1427
-        }
1428
-        return $templates_generated;
1429
-    }
1430
-
1431
-
1432
-    /**
1433
-     * This returns the default messengers to generate templates for on activation of EE.
1434
-     * It considers:
1435
-     * - whether a messenger is already active in the db.
1436
-     * - whether a messenger has been made active at any time in the past.
1437
-     *
1438
-     * @static
1439
-     * @param  EE_Message_Resource_Manager $message_resource_manager
1440
-     * @return EE_messenger[]
1441
-     */
1442
-    protected static function _get_default_messengers_to_generate_on_activation(
1443
-        EE_Message_Resource_Manager $message_resource_manager
1444
-    ) {
1445
-        $active_messengers    = $message_resource_manager->active_messengers();
1446
-        $installed_messengers = $message_resource_manager->installed_messengers();
1447
-        $has_activated        = $message_resource_manager->get_has_activated_messengers_option();
1448
-
1449
-        $messengers_to_generate = array();
1450
-        foreach ($installed_messengers as $installed_messenger) {
1451
-            //if installed messenger is a messenger that should be activated on install
1452
-            //and is not already active
1453
-            //and has never been activated
1454
-            if (
1455
-                ! $installed_messenger->activate_on_install
1456
-                || isset($active_messengers[$installed_messenger->name])
1457
-                || isset($has_activated[$installed_messenger->name])
1458
-            ) {
1459
-                continue;
1460
-            }
1461
-            $messengers_to_generate[$installed_messenger->name] = $installed_messenger;
1462
-        }
1463
-        return $messengers_to_generate;
1464
-    }
1465
-
1466
-
1467
-    /**
1468
-     * This simply validates active message types to ensure they actually match installed
1469
-     * message types.  If there's a mismatch then we deactivate the message type and ensure all related db
1470
-     * rows are set inactive.
1471
-     * Note: Messengers are no longer validated here as of 4.9.0 because they get validated automatically whenever
1472
-     * EE_Messenger_Resource_Manager is constructed.  Message Types are a bit more resource heavy for validation so they
1473
-     * are still handled in here.
1474
-     *
1475
-     * @since 4.3.1
1476
-     * @return void
1477
-     */
1478
-    public static function validate_messages_system()
1479
-    {
1480
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
1481
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
1482
-        $message_resource_manager->validate_active_message_types_are_installed();
1483
-        do_action('AHEE__EEH_Activation__validate_messages_system');
1484
-    }
1485
-
1486
-
1487
-    /**
1488
-     * create_no_ticket_prices_array
1489
-     *
1490
-     * @access public
1491
-     * @static
1492
-     * @return void
1493
-     */
1494
-    public static function create_no_ticket_prices_array()
1495
-    {
1496
-        // this creates an array for tracking events that have no active ticket prices created
1497
-        // this allows us to warn admins of the situation so that it can be corrected
1498
-        $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', false);
1499
-        if (! $espresso_no_ticket_prices) {
1500
-            add_option('ee_no_ticket_prices', array(), '', false);
1501
-        }
1502
-    }
1503
-
1504
-
1505
-    /**
1506
-     * plugin_deactivation
1507
-     *
1508
-     * @access public
1509
-     * @static
1510
-     * @return void
1511
-     */
1512
-    public static function plugin_deactivation()
1513
-    {
1514
-    }
1515
-
1516
-
1517
-    /**
1518
-     * Finds all our EE4 custom post types, and deletes them and their associated data
1519
-     * (like post meta or term relations)
1520
-     *
1521
-     * @global wpdb $wpdb
1522
-     * @throws \EE_Error
1523
-     */
1524
-    public static function delete_all_espresso_cpt_data()
1525
-    {
1526
-        global $wpdb;
1527
-        //get all the CPT post_types
1528
-        $ee_post_types = array();
1529
-        foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1530
-            if (method_exists($model_name, 'instance')) {
1531
-                $model_obj = call_user_func(array($model_name, 'instance'));
1532
-                if ($model_obj instanceof EEM_CPT_Base) {
1533
-                    $ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type());
1534
-                }
1535
-            }
1536
-        }
1537
-        //get all our CPTs
1538
-        $query   = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (" . implode(",", $ee_post_types) . ")";
1539
-        $cpt_ids = $wpdb->get_col($query);
1540
-        //delete each post meta and term relations too
1541
-        foreach ($cpt_ids as $post_id) {
1542
-            wp_delete_post($post_id, true);
1543
-        }
1544
-    }
1545
-
1546
-    /**
1547
-     * Deletes all EE custom tables
1548
-     *
1549
-     * @return array
1550
-     */
1551
-    public static function drop_espresso_tables()
1552
-    {
1553
-        $tables = array();
1554
-        // load registry
1555
-        foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1556
-            if (method_exists($model_name, 'instance')) {
1557
-                $model_obj = call_user_func(array($model_name, 'instance'));
1558
-                if ($model_obj instanceof EEM_Base) {
1559
-                    foreach ($model_obj->get_tables() as $table) {
1560
-                        if (strpos($table->get_table_name(), 'esp_')
1561
-                            &&
1562
-                            (
1563
-                                is_main_site()//main site? nuke them all
1564
-                                || ! $table->is_global()//not main site,but not global either. nuke it
1565
-                            )
1566
-                        ) {
1567
-                            $tables[$table->get_table_name()] = $table->get_table_name();
1568
-                        }
1569
-                    }
1570
-                }
1571
-            }
1572
-        }
1573
-
1574
-        //there are some tables whose models were removed.
1575
-        //they should be removed when removing all EE core's data
1576
-        $tables_without_models = array(
1577
-            'esp_promotion',
1578
-            'esp_promotion_applied',
1579
-            'esp_promotion_object',
1580
-            'esp_promotion_rule',
1581
-            'esp_rule',
1582
-        );
1583
-        foreach ($tables_without_models as $table) {
1584
-            $tables[$table] = $table;
1585
-        }
1586
-        return \EEH_Activation::getTableManager()->dropTables($tables);
1587
-    }
1588
-
1589
-
1590
-
1591
-    /**
1592
-     * Drops all the tables mentioned in a single MYSQL query. Double-checks
1593
-     * each table name provided has a wpdb prefix attached, and that it exists.
1594
-     * Returns the list actually deleted
1595
-     *
1596
-     * @deprecated in 4.9.13. Instead use TableManager::dropTables()
1597
-     * @global WPDB $wpdb
1598
-     * @param array $table_names
1599
-     * @return array of table names which we deleted
1600
-     */
1601
-    public static function drop_tables($table_names)
1602
-    {
1603
-        return \EEH_Activation::getTableManager()->dropTables($table_names);
1604
-    }
1605
-
1606
-
1607
-
1608
-    /**
1609
-     * plugin_uninstall
1610
-     *
1611
-     * @access public
1612
-     * @static
1613
-     * @param bool $remove_all
1614
-     * @return void
1615
-     */
1616
-    public static function delete_all_espresso_tables_and_data($remove_all = true)
1617
-    {
1618
-        global $wpdb;
1619
-        self::drop_espresso_tables();
1620
-        $wp_options_to_delete = array(
1621
-            'ee_no_ticket_prices'                => true,
1622
-            'ee_active_messengers'               => true,
1623
-            'ee_has_activated_messenger'         => true,
1624
-            'ee_flush_rewrite_rules'             => true,
1625
-            'ee_config'                          => false,
1626
-            'ee_data_migration_current_db_state' => true,
1627
-            'ee_data_migration_mapping_'         => false,
1628
-            'ee_data_migration_script_'          => false,
1629
-            'ee_data_migrations'                 => true,
1630
-            'ee_dms_map'                         => false,
1631
-            'ee_notices'                         => true,
1632
-            'lang_file_check_'                   => false,
1633
-            'ee_maintenance_mode'                => true,
1634
-            'ee_ueip_optin'                      => true,
1635
-            'ee_ueip_has_notified'               => true,
1636
-            'ee_plugin_activation_errors'        => true,
1637
-            'ee_id_mapping_from'                 => false,
1638
-            'espresso_persistent_admin_notices'  => true,
1639
-            'ee_encryption_key'                  => true,
1640
-            'pue_force_upgrade_'                 => false,
1641
-            'pue_json_error_'                    => false,
1642
-            'pue_install_key_'                   => false,
1643
-            'pue_verification_error_'            => false,
1644
-            'pu_dismissed_upgrade_'              => false,
1645
-            'external_updates-'                  => false,
1646
-            'ee_extra_data'                      => true,
1647
-            'ee_ssn_'                            => false,
1648
-            'ee_rss_'                            => false,
1649
-            'ee_rte_n_tx_'                       => false,
1650
-            'ee_pers_admin_notices'              => true,
1651
-            'ee_job_parameters_'                 => false,
1652
-            'ee_upload_directories_incomplete'   => true,
1653
-            'ee_verified_db_collations'          => true,
1654
-        );
1655
-        if (is_main_site()) {
1656
-            $wp_options_to_delete['ee_network_config'] = true;
1657
-        }
1658
-        $undeleted_options = array();
1659
-        foreach ($wp_options_to_delete as $option_name => $no_wildcard) {
1660
-            if ($no_wildcard) {
1661
-                if ( ! delete_option($option_name)) {
1662
-                    $undeleted_options[] = $option_name;
1663
-                }
1664
-            } else {
1665
-                $option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'");
1666
-                foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) {
1667
-                    if ( ! delete_option($option_name_from_wildcard)) {
1668
-                        $undeleted_options[] = $option_name_from_wildcard;
1669
-                    }
1670
-                }
1671
-            }
1672
-        }
1673
-        //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it
1674
-        remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10);
1675
-        if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) {
1676
-            $db_update_sans_ee4 = array();
1677
-            foreach ($espresso_db_update as $version => $times_activated) {
1678
-                if ((string)$version[0] === '3') {//if its NON EE4
1679
-                    $db_update_sans_ee4[$version] = $times_activated;
1680
-                }
1681
-            }
1682
-            update_option('espresso_db_update', $db_update_sans_ee4);
1683
-        }
1684
-        $errors = '';
1685
-        if ( ! empty($undeleted_options)) {
1686
-            $errors .= sprintf(
1687
-                __('The following wp-options could not be deleted: %s%s', 'event_espresso'),
1688
-                '<br/>',
1689
-                implode(',<br/>', $undeleted_options)
1690
-            );
1691
-        }
1692
-        if ( ! empty($errors)) {
1693
-            EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__);
1694
-        }
1695
-    }
1696
-
1697
-    /**
1698
-     * Gets the mysql error code from the last used query by wpdb
1699
-     *
1700
-     * @return int mysql error code, see https://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html
1701
-     */
1702
-    public static function last_wpdb_error_code()
1703
-    {
1704
-        global $wpdb;
1705
-        if ($wpdb->use_mysqli) {
1706
-            return mysqli_errno($wpdb->dbh);
1707
-        } else {
1708
-            return mysql_errno($wpdb->dbh);
1709
-        }
1710
-    }
1711
-
1712
-    /**
1713
-     * Checks that the database table exists. Also works on temporary tables (for unit tests mostly).
1714
-     *
1715
-     * @global wpdb  $wpdb
1716
-     * @deprecated instead use TableAnalysis::tableExists()
1717
-     * @param string $table_name with or without $wpdb->prefix
1718
-     * @return boolean
1719
-     */
1720
-    public static function table_exists($table_name)
1721
-    {
1722
-        return \EEH_Activation::getTableAnalysis()->tableExists($table_name);
1723
-    }
1724
-
1725
-    /**
1726
-     * Resets the cache on EEH_Activation
1727
-     */
1728
-    public static function reset()
1729
-    {
1730
-        self::$_default_creator_id                             = null;
1731
-        self::$_initialized_db_content_already_in_this_request = false;
1732
-    }
1302
+		$new_templates_created_for_messenger = self::_activate_and_generate_default_messengers_and_message_templates(
1303
+			$message_resource_manager
1304
+		);
1305
+		/**
1306
+		 * This method is verifying there are no NEW default message types
1307
+		 * for ACTIVE messengers that need activated (and corresponding templates setup).
1308
+		 */
1309
+		$new_templates_created_for_message_type = self::_activate_new_message_types_for_active_messengers_and_generate_default_templates(
1310
+			$message_resource_manager
1311
+		);
1312
+		//after all is done, let's persist these changes to the db.
1313
+		$message_resource_manager->update_has_activated_messengers_option();
1314
+		$message_resource_manager->update_active_messengers_option();
1315
+		// will return true if either of these are true.  Otherwise will return false.
1316
+		return $new_templates_created_for_message_type || $new_templates_created_for_messenger;
1317
+	}
1318
+
1319
+
1320
+
1321
+	/**
1322
+	 * @param \EE_Message_Resource_Manager $message_resource_manager
1323
+	 * @return array|bool
1324
+	 * @throws \EE_Error
1325
+	 */
1326
+	protected static function _activate_new_message_types_for_active_messengers_and_generate_default_templates(
1327
+		EE_Message_Resource_Manager $message_resource_manager
1328
+	) {
1329
+		/** @type EE_messenger[] $active_messengers */
1330
+		$active_messengers = $message_resource_manager->active_messengers();
1331
+		$installed_message_types = $message_resource_manager->installed_message_types();
1332
+		$templates_created = false;
1333
+		foreach ($active_messengers as $active_messenger) {
1334
+			$default_message_type_names_for_messenger = $active_messenger->get_default_message_types();
1335
+			$default_message_type_names_to_activate = array();
1336
+			// looping through each default message type reported by the messenger
1337
+			// and setup the actual message types to activate.
1338
+			foreach ($default_message_type_names_for_messenger as $default_message_type_name_for_messenger) {
1339
+				// if already active or has already been activated before we skip
1340
+				// (otherwise we might reactivate something user's intentionally deactivated.)
1341
+				// we also skip if the message type is not installed.
1342
+				if (
1343
+					$message_resource_manager->has_message_type_been_activated_for_messenger(
1344
+						$default_message_type_name_for_messenger,
1345
+						$active_messenger->name
1346
+					)
1347
+					|| $message_resource_manager->is_message_type_active_for_messenger(
1348
+						$active_messenger->name,
1349
+						$default_message_type_name_for_messenger
1350
+					)
1351
+					|| ! isset($installed_message_types[$default_message_type_name_for_messenger])
1352
+				) {
1353
+					continue;
1354
+				}
1355
+				$default_message_type_names_to_activate[] = $default_message_type_name_for_messenger;
1356
+			}
1357
+			//let's activate!
1358
+			$message_resource_manager->ensure_message_types_are_active(
1359
+				$default_message_type_names_to_activate,
1360
+				$active_messenger->name,
1361
+				false
1362
+			);
1363
+			//activate the templates for these message types
1364
+			if ( ! empty($default_message_type_names_to_activate)) {
1365
+				$templates_created = EEH_MSG_Template::generate_new_templates(
1366
+					$active_messenger->name,
1367
+					$default_message_type_names_for_messenger,
1368
+					'',
1369
+					true
1370
+				);
1371
+			}
1372
+		}
1373
+		return $templates_created;
1374
+	}
1375
+
1376
+
1377
+
1378
+	/**
1379
+	 * This will activate and generate default messengers and default message types for those messengers.
1380
+	 *
1381
+	 * @param EE_message_Resource_Manager $message_resource_manager
1382
+	 * @return array|bool  True means there were default messengers and message type templates generated.
1383
+	 *                     False means that there were no templates generated
1384
+	 *                     (which could simply mean there are no default message types for a messenger).
1385
+	 * @throws EE_Error
1386
+	 */
1387
+	protected static function _activate_and_generate_default_messengers_and_message_templates(
1388
+		EE_Message_Resource_Manager $message_resource_manager
1389
+	) {
1390
+		/** @type EE_messenger[] $messengers_to_generate */
1391
+		$messengers_to_generate = self::_get_default_messengers_to_generate_on_activation($message_resource_manager);
1392
+		$installed_message_types = $message_resource_manager->installed_message_types();
1393
+		$templates_generated = false;
1394
+		foreach ($messengers_to_generate as $messenger_to_generate) {
1395
+			$default_message_type_names_for_messenger = $messenger_to_generate->get_default_message_types();
1396
+			//verify the default message types match an installed message type.
1397
+			foreach ($default_message_type_names_for_messenger as $key => $name) {
1398
+				if (
1399
+					! isset($installed_message_types[$name])
1400
+					|| $message_resource_manager->has_message_type_been_activated_for_messenger(
1401
+						$name,
1402
+						$messenger_to_generate->name
1403
+					)
1404
+				) {
1405
+					unset($default_message_type_names_for_messenger[$key]);
1406
+				}
1407
+			}
1408
+			// in previous iterations, the active_messengers option in the db
1409
+			// needed updated before calling create templates. however with the changes this may not be necessary.
1410
+			// This comment is left here just in case we discover that we _do_ need to update before
1411
+			// passing off to create templates (after the refactor is done).
1412
+			// @todo remove this comment when determined not necessary.
1413
+			$message_resource_manager->activate_messenger(
1414
+				$messenger_to_generate->name,
1415
+				$default_message_type_names_for_messenger,
1416
+				false
1417
+			);
1418
+			//create any templates needing created (or will reactivate templates already generated as necessary).
1419
+			if ( ! empty($default_message_type_names_for_messenger)) {
1420
+				$templates_generated = EEH_MSG_Template::generate_new_templates(
1421
+					$messenger_to_generate->name,
1422
+					$default_message_type_names_for_messenger,
1423
+					'',
1424
+					true
1425
+				);
1426
+			}
1427
+		}
1428
+		return $templates_generated;
1429
+	}
1430
+
1431
+
1432
+	/**
1433
+	 * This returns the default messengers to generate templates for on activation of EE.
1434
+	 * It considers:
1435
+	 * - whether a messenger is already active in the db.
1436
+	 * - whether a messenger has been made active at any time in the past.
1437
+	 *
1438
+	 * @static
1439
+	 * @param  EE_Message_Resource_Manager $message_resource_manager
1440
+	 * @return EE_messenger[]
1441
+	 */
1442
+	protected static function _get_default_messengers_to_generate_on_activation(
1443
+		EE_Message_Resource_Manager $message_resource_manager
1444
+	) {
1445
+		$active_messengers    = $message_resource_manager->active_messengers();
1446
+		$installed_messengers = $message_resource_manager->installed_messengers();
1447
+		$has_activated        = $message_resource_manager->get_has_activated_messengers_option();
1448
+
1449
+		$messengers_to_generate = array();
1450
+		foreach ($installed_messengers as $installed_messenger) {
1451
+			//if installed messenger is a messenger that should be activated on install
1452
+			//and is not already active
1453
+			//and has never been activated
1454
+			if (
1455
+				! $installed_messenger->activate_on_install
1456
+				|| isset($active_messengers[$installed_messenger->name])
1457
+				|| isset($has_activated[$installed_messenger->name])
1458
+			) {
1459
+				continue;
1460
+			}
1461
+			$messengers_to_generate[$installed_messenger->name] = $installed_messenger;
1462
+		}
1463
+		return $messengers_to_generate;
1464
+	}
1465
+
1466
+
1467
+	/**
1468
+	 * This simply validates active message types to ensure they actually match installed
1469
+	 * message types.  If there's a mismatch then we deactivate the message type and ensure all related db
1470
+	 * rows are set inactive.
1471
+	 * Note: Messengers are no longer validated here as of 4.9.0 because they get validated automatically whenever
1472
+	 * EE_Messenger_Resource_Manager is constructed.  Message Types are a bit more resource heavy for validation so they
1473
+	 * are still handled in here.
1474
+	 *
1475
+	 * @since 4.3.1
1476
+	 * @return void
1477
+	 */
1478
+	public static function validate_messages_system()
1479
+	{
1480
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
1481
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
1482
+		$message_resource_manager->validate_active_message_types_are_installed();
1483
+		do_action('AHEE__EEH_Activation__validate_messages_system');
1484
+	}
1485
+
1486
+
1487
+	/**
1488
+	 * create_no_ticket_prices_array
1489
+	 *
1490
+	 * @access public
1491
+	 * @static
1492
+	 * @return void
1493
+	 */
1494
+	public static function create_no_ticket_prices_array()
1495
+	{
1496
+		// this creates an array for tracking events that have no active ticket prices created
1497
+		// this allows us to warn admins of the situation so that it can be corrected
1498
+		$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', false);
1499
+		if (! $espresso_no_ticket_prices) {
1500
+			add_option('ee_no_ticket_prices', array(), '', false);
1501
+		}
1502
+	}
1503
+
1504
+
1505
+	/**
1506
+	 * plugin_deactivation
1507
+	 *
1508
+	 * @access public
1509
+	 * @static
1510
+	 * @return void
1511
+	 */
1512
+	public static function plugin_deactivation()
1513
+	{
1514
+	}
1515
+
1516
+
1517
+	/**
1518
+	 * Finds all our EE4 custom post types, and deletes them and their associated data
1519
+	 * (like post meta or term relations)
1520
+	 *
1521
+	 * @global wpdb $wpdb
1522
+	 * @throws \EE_Error
1523
+	 */
1524
+	public static function delete_all_espresso_cpt_data()
1525
+	{
1526
+		global $wpdb;
1527
+		//get all the CPT post_types
1528
+		$ee_post_types = array();
1529
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1530
+			if (method_exists($model_name, 'instance')) {
1531
+				$model_obj = call_user_func(array($model_name, 'instance'));
1532
+				if ($model_obj instanceof EEM_CPT_Base) {
1533
+					$ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type());
1534
+				}
1535
+			}
1536
+		}
1537
+		//get all our CPTs
1538
+		$query   = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (" . implode(",", $ee_post_types) . ")";
1539
+		$cpt_ids = $wpdb->get_col($query);
1540
+		//delete each post meta and term relations too
1541
+		foreach ($cpt_ids as $post_id) {
1542
+			wp_delete_post($post_id, true);
1543
+		}
1544
+	}
1545
+
1546
+	/**
1547
+	 * Deletes all EE custom tables
1548
+	 *
1549
+	 * @return array
1550
+	 */
1551
+	public static function drop_espresso_tables()
1552
+	{
1553
+		$tables = array();
1554
+		// load registry
1555
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1556
+			if (method_exists($model_name, 'instance')) {
1557
+				$model_obj = call_user_func(array($model_name, 'instance'));
1558
+				if ($model_obj instanceof EEM_Base) {
1559
+					foreach ($model_obj->get_tables() as $table) {
1560
+						if (strpos($table->get_table_name(), 'esp_')
1561
+							&&
1562
+							(
1563
+								is_main_site()//main site? nuke them all
1564
+								|| ! $table->is_global()//not main site,but not global either. nuke it
1565
+							)
1566
+						) {
1567
+							$tables[$table->get_table_name()] = $table->get_table_name();
1568
+						}
1569
+					}
1570
+				}
1571
+			}
1572
+		}
1573
+
1574
+		//there are some tables whose models were removed.
1575
+		//they should be removed when removing all EE core's data
1576
+		$tables_without_models = array(
1577
+			'esp_promotion',
1578
+			'esp_promotion_applied',
1579
+			'esp_promotion_object',
1580
+			'esp_promotion_rule',
1581
+			'esp_rule',
1582
+		);
1583
+		foreach ($tables_without_models as $table) {
1584
+			$tables[$table] = $table;
1585
+		}
1586
+		return \EEH_Activation::getTableManager()->dropTables($tables);
1587
+	}
1588
+
1589
+
1590
+
1591
+	/**
1592
+	 * Drops all the tables mentioned in a single MYSQL query. Double-checks
1593
+	 * each table name provided has a wpdb prefix attached, and that it exists.
1594
+	 * Returns the list actually deleted
1595
+	 *
1596
+	 * @deprecated in 4.9.13. Instead use TableManager::dropTables()
1597
+	 * @global WPDB $wpdb
1598
+	 * @param array $table_names
1599
+	 * @return array of table names which we deleted
1600
+	 */
1601
+	public static function drop_tables($table_names)
1602
+	{
1603
+		return \EEH_Activation::getTableManager()->dropTables($table_names);
1604
+	}
1605
+
1606
+
1607
+
1608
+	/**
1609
+	 * plugin_uninstall
1610
+	 *
1611
+	 * @access public
1612
+	 * @static
1613
+	 * @param bool $remove_all
1614
+	 * @return void
1615
+	 */
1616
+	public static function delete_all_espresso_tables_and_data($remove_all = true)
1617
+	{
1618
+		global $wpdb;
1619
+		self::drop_espresso_tables();
1620
+		$wp_options_to_delete = array(
1621
+			'ee_no_ticket_prices'                => true,
1622
+			'ee_active_messengers'               => true,
1623
+			'ee_has_activated_messenger'         => true,
1624
+			'ee_flush_rewrite_rules'             => true,
1625
+			'ee_config'                          => false,
1626
+			'ee_data_migration_current_db_state' => true,
1627
+			'ee_data_migration_mapping_'         => false,
1628
+			'ee_data_migration_script_'          => false,
1629
+			'ee_data_migrations'                 => true,
1630
+			'ee_dms_map'                         => false,
1631
+			'ee_notices'                         => true,
1632
+			'lang_file_check_'                   => false,
1633
+			'ee_maintenance_mode'                => true,
1634
+			'ee_ueip_optin'                      => true,
1635
+			'ee_ueip_has_notified'               => true,
1636
+			'ee_plugin_activation_errors'        => true,
1637
+			'ee_id_mapping_from'                 => false,
1638
+			'espresso_persistent_admin_notices'  => true,
1639
+			'ee_encryption_key'                  => true,
1640
+			'pue_force_upgrade_'                 => false,
1641
+			'pue_json_error_'                    => false,
1642
+			'pue_install_key_'                   => false,
1643
+			'pue_verification_error_'            => false,
1644
+			'pu_dismissed_upgrade_'              => false,
1645
+			'external_updates-'                  => false,
1646
+			'ee_extra_data'                      => true,
1647
+			'ee_ssn_'                            => false,
1648
+			'ee_rss_'                            => false,
1649
+			'ee_rte_n_tx_'                       => false,
1650
+			'ee_pers_admin_notices'              => true,
1651
+			'ee_job_parameters_'                 => false,
1652
+			'ee_upload_directories_incomplete'   => true,
1653
+			'ee_verified_db_collations'          => true,
1654
+		);
1655
+		if (is_main_site()) {
1656
+			$wp_options_to_delete['ee_network_config'] = true;
1657
+		}
1658
+		$undeleted_options = array();
1659
+		foreach ($wp_options_to_delete as $option_name => $no_wildcard) {
1660
+			if ($no_wildcard) {
1661
+				if ( ! delete_option($option_name)) {
1662
+					$undeleted_options[] = $option_name;
1663
+				}
1664
+			} else {
1665
+				$option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'");
1666
+				foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) {
1667
+					if ( ! delete_option($option_name_from_wildcard)) {
1668
+						$undeleted_options[] = $option_name_from_wildcard;
1669
+					}
1670
+				}
1671
+			}
1672
+		}
1673
+		//also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it
1674
+		remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10);
1675
+		if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) {
1676
+			$db_update_sans_ee4 = array();
1677
+			foreach ($espresso_db_update as $version => $times_activated) {
1678
+				if ((string)$version[0] === '3') {//if its NON EE4
1679
+					$db_update_sans_ee4[$version] = $times_activated;
1680
+				}
1681
+			}
1682
+			update_option('espresso_db_update', $db_update_sans_ee4);
1683
+		}
1684
+		$errors = '';
1685
+		if ( ! empty($undeleted_options)) {
1686
+			$errors .= sprintf(
1687
+				__('The following wp-options could not be deleted: %s%s', 'event_espresso'),
1688
+				'<br/>',
1689
+				implode(',<br/>', $undeleted_options)
1690
+			);
1691
+		}
1692
+		if ( ! empty($errors)) {
1693
+			EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__);
1694
+		}
1695
+	}
1696
+
1697
+	/**
1698
+	 * Gets the mysql error code from the last used query by wpdb
1699
+	 *
1700
+	 * @return int mysql error code, see https://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html
1701
+	 */
1702
+	public static function last_wpdb_error_code()
1703
+	{
1704
+		global $wpdb;
1705
+		if ($wpdb->use_mysqli) {
1706
+			return mysqli_errno($wpdb->dbh);
1707
+		} else {
1708
+			return mysql_errno($wpdb->dbh);
1709
+		}
1710
+	}
1711
+
1712
+	/**
1713
+	 * Checks that the database table exists. Also works on temporary tables (for unit tests mostly).
1714
+	 *
1715
+	 * @global wpdb  $wpdb
1716
+	 * @deprecated instead use TableAnalysis::tableExists()
1717
+	 * @param string $table_name with or without $wpdb->prefix
1718
+	 * @return boolean
1719
+	 */
1720
+	public static function table_exists($table_name)
1721
+	{
1722
+		return \EEH_Activation::getTableAnalysis()->tableExists($table_name);
1723
+	}
1724
+
1725
+	/**
1726
+	 * Resets the cache on EEH_Activation
1727
+	 */
1728
+	public static function reset()
1729
+	{
1730
+		self::$_default_creator_id                             = null;
1731
+		self::$_initialized_db_content_already_in_this_request = false;
1732
+	}
1733 1733
 }
1734 1734
 // End of file EEH_Activation.helper.php
1735 1735
 // Location: /helpers/EEH_Activation.core.php
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      */
66 66
     public static function getTableAnalysis()
67 67
     {
68
-        if (! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis) {
68
+        if ( ! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis) {
69 69
             self::$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
70 70
         }
71 71
         return self::$table_analysis;
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
      */
78 78
     public static function getTableManager()
79 79
     {
80
-        if (! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager) {
80
+        if ( ! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager) {
81 81
             self::$table_manager = EE_Registry::instance()->create('TableManager', array(), true);
82 82
         }
83 83
         return self::$table_manager;
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
         if ($which_to_include === 'old') {
194 194
             $cron_tasks = array_filter(
195 195
                 $cron_tasks,
196
-                function ($value) {
196
+                function($value) {
197 197
                     return $value === EEH_Activation::cron_task_no_longer_in_use;
198 198
                 }
199 199
             );
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
     {
224 224
 
225 225
         foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) {
226
-            if (! wp_next_scheduled($hook_name)) {
226
+            if ( ! wp_next_scheduled($hook_name)) {
227 227
                 /**
228 228
                  * This allows client code to define the initial start timestamp for this schedule.
229 229
                  */
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
             3
329 329
         );
330 330
         //EE_Config::reset();
331
-        if (! EE_Config::logging_enabled()) {
331
+        if ( ! EE_Config::logging_enabled()) {
332 332
             delete_option(EE_Config::LOG_NAME);
333 333
         }
334 334
     }
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
     public static function load_calendar_config()
344 344
     {
345 345
         // grab array of all plugin folders and loop thru it
346
-        $plugins = glob(WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR);
346
+        $plugins = glob(WP_PLUGIN_DIR.DS.'*', GLOB_ONLYDIR);
347 347
         if (empty($plugins)) {
348 348
             return;
349 349
         }
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
                 || strpos($plugin, 'calendar') !== false
361 361
             ) {
362 362
                 // this is what we are looking for
363
-                $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php';
363
+                $calendar_config = $plugin_path.DS.'EE_Calendar_Config.php';
364 364
                 // does it exist in this folder ?
365 365
                 if (is_readable($calendar_config)) {
366 366
                     // YEAH! let's load it
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
             ) {
489 489
                 //update Config with post ID
490 490
                 $EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID;
491
-                if (! EE_Config::instance()->update_espresso_config(false, false)) {
491
+                if ( ! EE_Config::instance()->update_espresso_config(false, false)) {
492 492
                     $msg = __(
493 493
                         'The Event Espresso critical page configuration settings could not be updated.',
494 494
                         'event_espresso'
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
                         'A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.',
512 512
                         'event_espresso'
513 513
                     ),
514
-                    '<a href="' . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') . '">'
514
+                    '<a href="'.admin_url('admin.php?page=espresso_general_settings&action=critical_pages').'">'
515 515
                     . __('Event Espresso Critical Pages Settings', 'event_espresso')
516 516
                     . '</a>'
517 517
                 )
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
     public static function get_page_by_ee_shortcode($ee_shortcode)
538 538
     {
539 539
         global $wpdb;
540
-        $shortcode_and_opening_bracket = '[' . $ee_shortcode;
540
+        $shortcode_and_opening_bracket = '['.$ee_shortcode;
541 541
         $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1");
542 542
         if ($post_id) {
543 543
             return get_post($post_id);
@@ -563,11 +563,11 @@  discard block
 block discarded – undo
563 563
             'post_status'    => 'publish',
564 564
             'post_type'      => 'page',
565 565
             'comment_status' => 'closed',
566
-            'post_content'   => '[' . $critical_page['code'] . ']',
566
+            'post_content'   => '['.$critical_page['code'].']',
567 567
         );
568 568
 
569 569
         $post_id = wp_insert_post($post_args);
570
-        if (! $post_id) {
570
+        if ( ! $post_id) {
571 571
             $msg = sprintf(
572 572
                 __('The Event Espresso  critical page entitled "%s" could not be created.', 'event_espresso'),
573 573
                 $critical_page['name']
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
             return $critical_page;
577 577
         }
578 578
         // get newly created post's details
579
-        if (! $critical_page['post'] = get_post($post_id)) {
579
+        if ( ! $critical_page['post'] = get_post($post_id)) {
580 580
             $msg = sprintf(
581 581
                 __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'),
582 582
                 $critical_page['name']
@@ -613,17 +613,17 @@  discard block
 block discarded – undo
613 613
             $role_to_check
614 614
         );
615 615
         if ($pre_filtered_id !== false) {
616
-            return (int)$pre_filtered_id;
616
+            return (int) $pre_filtered_id;
617 617
         }
618 618
         $capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('capabilities');
619 619
         $query = $wpdb->prepare(
620 620
             "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1",
621
-            '%' . $role_to_check . '%'
621
+            '%'.$role_to_check.'%'
622 622
         );
623 623
         $user_id = $wpdb->get_var($query);
624 624
         $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id);
625
-        if ($user_id && (int)$user_id) {
626
-            self::$_default_creator_id = (int)$user_id;
625
+        if ($user_id && (int) $user_id) {
626
+            self::$_default_creator_id = (int) $user_id;
627 627
             return self::$_default_creator_id;
628 628
         } else {
629 629
             return null;
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
         }
659 659
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
660 660
         if ( ! function_exists('dbDelta')) {
661
-            require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
661
+            require_once(ABSPATH.'wp-admin/includes/upgrade.php');
662 662
         }
663 663
         $tableAnalysis = \EEH_Activation::getTableAnalysis();
664 664
         $wp_table_name = $tableAnalysis->ensureTableNameHasPrefix($table_name);
@@ -869,13 +869,13 @@  discard block
 block discarded – undo
869 869
             // reset values array
870 870
             $QSG_values = array();
871 871
             // 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)
872
-            if (! in_array("$QSG_system", $question_groups)) {
872
+            if ( ! in_array("$QSG_system", $question_groups)) {
873 873
                 // add it
874 874
                 switch ($QSG_system) {
875 875
                     case 1:
876 876
                         $QSG_values = array(
877 877
                             'QSG_name'            => __('Personal Information', 'event_espresso'),
878
-                            'QSG_identifier'      => 'personal-information-' . time(),
878
+                            'QSG_identifier'      => 'personal-information-'.time(),
879 879
                             'QSG_desc'            => '',
880 880
                             'QSG_order'           => 1,
881 881
                             'QSG_show_group_name' => 1,
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
                     case 2:
888 888
                         $QSG_values = array(
889 889
                             'QSG_name'            => __('Address Information', 'event_espresso'),
890
-                            'QSG_identifier'      => 'address-information-' . time(),
890
+                            'QSG_identifier'      => 'address-information-'.time(),
891 891
                             'QSG_desc'            => '',
892 892
                             'QSG_order'           => 2,
893 893
                             'QSG_show_group_name' => 1,
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
                         break;
899 899
                 }
900 900
                 // make sure we have some values before inserting them
901
-                if (! empty($QSG_values)) {
901
+                if ( ! empty($QSG_values)) {
902 902
                     // insert system question
903 903
                     $wpdb->insert(
904 904
                         $table_name,
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
             // reset values array
936 936
             $QST_values = array();
937 937
             // if we don't have what we should have
938
-            if (! in_array($QST_system, $questions)) {
938
+            if ( ! in_array($QST_system, $questions)) {
939 939
                 // add it
940 940
                 switch ($QST_system) {
941 941
                     case 'fname':
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
                         );
1088 1088
                         break;
1089 1089
                 }
1090
-                if (! empty($QST_values)) {
1090
+                if ( ! empty($QST_values)) {
1091 1091
                     // insert system question
1092 1092
                     $wpdb->insert(
1093 1093
                         $table_name,
@@ -1148,7 +1148,7 @@  discard block
 block discarded – undo
1148 1148
      */
1149 1149
     public static function insert_default_payment_methods()
1150 1150
     {
1151
-        if (! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) {
1151
+        if ( ! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) {
1152 1152
             EE_Registry::instance()->load_lib('Payment_Method_Manager');
1153 1153
             EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
1154 1154
         } else {
@@ -1236,9 +1236,9 @@  discard block
 block discarded – undo
1236 1236
         $folders = array(
1237 1237
             EVENT_ESPRESSO_TEMPLATE_DIR,
1238 1238
             EVENT_ESPRESSO_GATEWAY_DIR,
1239
-            EVENT_ESPRESSO_UPLOAD_DIR . 'logs/',
1240
-            EVENT_ESPRESSO_UPLOAD_DIR . 'css/',
1241
-            EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/',
1239
+            EVENT_ESPRESSO_UPLOAD_DIR.'logs/',
1240
+            EVENT_ESPRESSO_UPLOAD_DIR.'css/',
1241
+            EVENT_ESPRESSO_UPLOAD_DIR.'tickets/',
1242 1242
         );
1243 1243
         foreach ($folders as $folder) {
1244 1244
             try {
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
                     sprintf(
1250 1250
                         __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'),
1251 1251
                         $folder,
1252
-                        '<br />' . $e->getMessage()
1252
+                        '<br />'.$e->getMessage()
1253 1253
                     ),
1254 1254
                     __FILE__, __FUNCTION__, __LINE__
1255 1255
                 );
@@ -1260,7 +1260,7 @@  discard block
 block discarded – undo
1260 1260
         }
1261 1261
         //just add the .htaccess file to the logs directory to begin with. Even if logging
1262 1262
         //is disabled, there might be activation errors recorded in there
1263
-        EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs/');
1263
+        EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs/');
1264 1264
         //remember EE's folders are all good
1265 1265
         delete_option(EEH_Activation::upload_directories_incomplete_option_name);
1266 1266
         return true;
@@ -1496,7 +1496,7 @@  discard block
 block discarded – undo
1496 1496
         // this creates an array for tracking events that have no active ticket prices created
1497 1497
         // this allows us to warn admins of the situation so that it can be corrected
1498 1498
         $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', false);
1499
-        if (! $espresso_no_ticket_prices) {
1499
+        if ( ! $espresso_no_ticket_prices) {
1500 1500
             add_option('ee_no_ticket_prices', array(), '', false);
1501 1501
         }
1502 1502
     }
@@ -1535,7 +1535,7 @@  discard block
 block discarded – undo
1535 1535
             }
1536 1536
         }
1537 1537
         //get all our CPTs
1538
-        $query   = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (" . implode(",", $ee_post_types) . ")";
1538
+        $query   = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",", $ee_post_types).")";
1539 1539
         $cpt_ids = $wpdb->get_col($query);
1540 1540
         //delete each post meta and term relations too
1541 1541
         foreach ($cpt_ids as $post_id) {
@@ -1675,7 +1675,7 @@  discard block
 block discarded – undo
1675 1675
         if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) {
1676 1676
             $db_update_sans_ee4 = array();
1677 1677
             foreach ($espresso_db_update as $version => $times_activated) {
1678
-                if ((string)$version[0] === '3') {//if its NON EE4
1678
+                if ((string) $version[0] === '3') {//if its NON EE4
1679 1679
                     $db_update_sans_ee4[$version] = $times_activated;
1680 1680
                 }
1681 1681
             }
Please login to merge, or discard this patch.
core/admin/EE_Admin.core.php 2 patches
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
     public static function instance()
40 40
     {
41 41
         // check if class object is instantiated
42
-        if (! self::$_instance instanceof EE_Admin) {
42
+        if ( ! self::$_instance instanceof EE_Admin) {
43 43
             self::$_instance = new self();
44 44
         }
45 45
         return self::$_instance;
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
      */
100 100
     private function _define_all_constants()
101 101
     {
102
-        if (! defined('EE_ADMIN_URL')) {
103
-            define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/');
104
-            define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/');
105
-            define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS);
106
-            define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/');
102
+        if ( ! defined('EE_ADMIN_URL')) {
103
+            define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL.'core/admin/');
104
+            define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL.'admin_pages/');
105
+            define('EE_ADMIN_TEMPLATE', EE_ADMIN.'templates'.DS);
106
+            define('WP_ADMIN_PATH', ABSPATH.'wp-admin/');
107 107
             define('WP_AJAX_URL', admin_url('admin-ajax.php'));
108 108
         }
109 109
     }
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
         // set $main_file in stone
122 122
         static $main_file;
123 123
         // if $main_file is not set yet
124
-        if (! $main_file) {
124
+        if ( ! $main_file) {
125 125
             $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE);
126 126
         }
127 127
         if ($plugin === $main_file) {
@@ -174,9 +174,9 @@  discard block
 block discarded – undo
174 174
     public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array())
175 175
     {
176 176
         return array(
177
-            'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS,
178
-            'about'       => EE_ADMIN_PAGES . 'about' . DS,
179
-            'support'     => EE_ADMIN_PAGES . 'support' . DS,
177
+            'maintenance' => EE_ADMIN_PAGES.'maintenance'.DS,
178
+            'about'       => EE_ADMIN_PAGES.'about'.DS,
179
+            'support'     => EE_ADMIN_PAGES.'support'.DS,
180 180
         );
181 181
     }
182 182
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
             add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2);
218 218
         }
219 219
         // run the admin page factory but ONLY if we are doing an ee admin ajax request
220
-        if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) {
220
+        if ( ! defined('DOING_AJAX') || EE_ADMIN_AJAX) {
221 221
             try {
222 222
                 //this loads the controller for the admin pages which will setup routing etc
223 223
                 EE_Registry::instance()->load_core('Admin_Page_Loader');
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
     public function enable_hidden_ee_nav_menu_metaboxes()
273 273
     {
274 274
         global $wp_meta_boxes, $pagenow;
275
-        if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
275
+        if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
276 276
             return;
277 277
         }
278 278
         $user = wp_get_current_user();
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
      */
344 344
     public function modify_edit_post_link($link, $id)
345 345
     {
346
-        if (! $post = get_post($id)) {
346
+        if ( ! $post = get_post($id)) {
347 347
             return $link;
348 348
         }
349 349
         if ($post->post_type === 'espresso_attendees') {
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
 
570 570
         //loop through to remove any critical pages from the array.
571 571
         foreach ($critical_pages as $page_id) {
572
-            $needle = 'value="' . $page_id . '"';
572
+            $needle = 'value="'.$page_id.'"';
573 573
             foreach ($split_output as $key => $haystack) {
574 574
                 if (strpos($haystack, $needle) !== false) {
575 575
                     unset($split_output[$key]);
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
         // calls.
594 594
         wp_enqueue_script(
595 595
             'ee-inject-wp',
596
-            EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',
596
+            EE_ADMIN_URL.'assets/ee-cpt-wp-injects.js',
597 597
             array('jquery'),
598 598
             EVENT_ESPRESSO_VERSION,
599 599
             true
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
         // register cookie script for future dependencies
602 602
         wp_register_script(
603 603
             'jquery-cookie',
604
-            EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js',
604
+            EE_THIRD_PARTY_URL.'joyride/jquery.cookie.js',
605 605
             array('jquery'),
606 606
             '2.1',
607 607
             true
@@ -610,16 +610,16 @@  discard block
 block discarded – undo
610 610
         // via: add_filter('FHEE_load_joyride', '__return_true' );
611 611
         if (apply_filters('FHEE_load_joyride', false)) {
612 612
             //joyride style
613
-            wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1');
613
+            wp_register_style('joyride-css', EE_THIRD_PARTY_URL.'joyride/joyride-2.1.css', array(), '2.1');
614 614
             wp_register_style(
615 615
                 'ee-joyride-css',
616
-                EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css',
616
+                EE_GLOBAL_ASSETS_URL.'css/ee-joyride-styles.css',
617 617
                 array('joyride-css'),
618 618
                 EVENT_ESPRESSO_VERSION
619 619
             );
620 620
             wp_register_script(
621 621
                 'joyride-modernizr',
622
-                EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js',
622
+                EE_THIRD_PARTY_URL.'joyride/modernizr.mq.js',
623 623
                 array(),
624 624
                 '2.1',
625 625
                 true
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
             //joyride JS
628 628
             wp_register_script(
629 629
                 'jquery-joyride',
630
-                EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js',
630
+                EE_THIRD_PARTY_URL.'joyride/jquery.joyride-2.1.js',
631 631
                 array('jquery-cookie', 'joyride-modernizr'),
632 632
                 '2.1',
633 633
                 true
@@ -696,21 +696,21 @@  discard block
 block discarded – undo
696 696
                 ),
697 697
             )
698 698
         );
699
-        $items['registrations']['url']   = EE_Admin_Page::add_query_args_and_nonce(
699
+        $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce(
700 700
             array('page' => 'espresso_registrations'),
701 701
             admin_url('admin.php')
702 702
         );
703
-        $items['registrations']['text']  = sprintf(
703
+        $items['registrations']['text'] = sprintf(
704 704
             _n('%s Registration', '%s Registrations', $registrations),
705 705
             number_format_i18n($registrations)
706 706
         );
707 707
         $items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso');
708 708
 
709
-        $items = (array)apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
709
+        $items = (array) apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
710 710
 
711 711
         foreach ($items as $type => $item_properties) {
712 712
             $elements[] = sprintf(
713
-                '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>',
713
+                '<a class="ee-dashboard-link-'.$type.'" href="%s" title="%s">%s</a>',
714 714
                 $item_properties['url'],
715 715
                 $item_properties['title'],
716 716
                 $item_properties['text']
@@ -735,10 +735,10 @@  discard block
 block discarded – undo
735 735
         // check for date_format or time_format
736 736
         switch ($option) {
737 737
             case 'date_format':
738
-                $date_time_format = $value . ' ' . get_option('time_format');
738
+                $date_time_format = $value.' '.get_option('time_format');
739 739
                 break;
740 740
             case 'time_format':
741
-                $date_time_format = get_option('date_format') . ' ' . $value;
741
+                $date_time_format = get_option('date_format').' '.$value;
742 742
                 break;
743 743
             default:
744 744
                 $date_time_format = false;
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 
762 762
 
763 763
                 foreach ($error_msg as $error) {
764
-                    $msg .= '<li>' . $error . '</li>';
764
+                    $msg .= '<li>'.$error.'</li>';
765 765
                 }
766 766
 
767 767
                 $msg .= '</ul></p><p>'
Please login to merge, or discard this patch.
Indentation   +851 added lines, -851 removed lines patch added patch discarded remove patch
@@ -21,409 +21,409 @@  discard block
 block discarded – undo
21 21
 final class EE_Admin implements InterminableInterface
22 22
 {
23 23
 
24
-    /**
25
-     * @var EE_Admin $_instance
26
-     */
27
-    private static $_instance;
28
-
29
-    /**
30
-     * @var PersistentAdminNoticeManager $persistent_admin_notice_manager
31
-     */
32
-    private $persistent_admin_notice_manager;
33
-
34
-    /**
35
-     * @singleton method used to instantiate class object
36
-     * @return EE_Admin
37
-     * @throws EE_Error
38
-     */
39
-    public static function instance()
40
-    {
41
-        // check if class object is instantiated
42
-        if (! self::$_instance instanceof EE_Admin) {
43
-            self::$_instance = new self();
44
-        }
45
-        return self::$_instance;
46
-    }
47
-
48
-
49
-    /**
50
-     * @return EE_Admin
51
-     * @throws EE_Error
52
-     */
53
-    public static function reset()
54
-    {
55
-        self::$_instance = null;
56
-        return self::instance();
57
-    }
58
-
59
-
60
-    /**
61
-     * class constructor
62
-     *
63
-     * @throws EE_Error
64
-     * @throws InvalidDataTypeException
65
-     * @throws InvalidInterfaceException
66
-     * @throws InvalidArgumentException
67
-     */
68
-    protected function __construct()
69
-    {
70
-        // define global EE_Admin constants
71
-        $this->_define_all_constants();
72
-        // set autoloaders for our admin page classes based on included path information
73
-        EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN);
74
-        // admin hooks
75
-        add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2);
76
-        // load EE_Request_Handler early
77
-        add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request'));
78
-        add_action('AHEE__EE_System__initialize_last', array($this, 'init'));
79
-        add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2);
80
-        add_action('wp_loaded', array($this, 'wp_loaded'), 100);
81
-        add_action('admin_init', array($this, 'admin_init'), 100);
82
-        add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20);
83
-        add_action('admin_notices', array($this, 'display_admin_notices'), 10);
84
-        add_action('network_admin_notices', array($this, 'display_admin_notices'), 10);
85
-        add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2);
86
-        add_filter('admin_footer_text', array($this, 'espresso_admin_footer'));
87
-        //reset Environment config (we only do this on admin page loads);
88
-        EE_Registry::instance()->CFG->environment->recheck_values();
89
-        do_action('AHEE__EE_Admin__loaded');
90
-    }
91
-
92
-
93
-
94
-    /**
95
-     * _define_all_constants
96
-     * define constants that are set globally for all admin pages
97
-     *
98
-     * @return void
99
-     */
100
-    private function _define_all_constants()
101
-    {
102
-        if (! defined('EE_ADMIN_URL')) {
103
-            define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/');
104
-            define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/');
105
-            define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS);
106
-            define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/');
107
-            define('WP_AJAX_URL', admin_url('admin-ajax.php'));
108
-        }
109
-    }
110
-
111
-
112
-    /**
113
-     * filter_plugin_actions - adds links to the Plugins page listing
114
-     *
115
-     * @param    array  $links
116
-     * @param    string $plugin
117
-     * @return    array
118
-     */
119
-    public function filter_plugin_actions($links, $plugin)
120
-    {
121
-        // set $main_file in stone
122
-        static $main_file;
123
-        // if $main_file is not set yet
124
-        if (! $main_file) {
125
-            $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE);
126
-        }
127
-        if ($plugin === $main_file) {
128
-            // compare current plugin to this one
129
-            if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) {
130
-                $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"'
131
-                                    . ' title="Event Espresso is in maintenance mode.  Click this link to learn why.">'
132
-                                    . esc_html__('Maintenance Mode Active', 'event_espresso')
133
-                                    . '</a>';
134
-                array_unshift($links, $maintenance_link);
135
-            } else {
136
-                $org_settings_link = '<a href="admin.php?page=espresso_general_settings">'
137
-                                     . esc_html__('Settings', 'event_espresso')
138
-                                     . '</a>';
139
-                $events_link       = '<a href="admin.php?page=espresso_events">'
140
-                                     . esc_html__('Events', 'event_espresso')
141
-                                     . '</a>';
142
-                // add before other links
143
-                array_unshift($links, $org_settings_link, $events_link);
144
-            }
145
-        }
146
-        return $links;
147
-    }
148
-
149
-
150
-    /**
151
-     * _get_request
152
-     *
153
-     * @return void
154
-     * @throws EE_Error
155
-     * @throws InvalidArgumentException
156
-     * @throws InvalidDataTypeException
157
-     * @throws InvalidInterfaceException
158
-     * @throws ReflectionException
159
-     */
160
-    public function get_request()
161
-    {
162
-        EE_Registry::instance()->load_core('Request_Handler');
163
-        EE_Registry::instance()->load_core('CPT_Strategy');
164
-    }
165
-
166
-
167
-
168
-    /**
169
-     * hide_admin_pages_except_maintenance_mode
170
-     *
171
-     * @param array $admin_page_folder_names
172
-     * @return array
173
-     */
174
-    public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array())
175
-    {
176
-        return array(
177
-            'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS,
178
-            'about'       => EE_ADMIN_PAGES . 'about' . DS,
179
-            'support'     => EE_ADMIN_PAGES . 'support' . DS,
180
-        );
181
-    }
182
-
183
-
184
-
185
-    /**
186
-     * init- should fire after shortcode, module,  addon, other plugin (default priority), and even
187
-     * EE_Front_Controller's init phases have run
188
-     *
189
-     * @return void
190
-     * @throws EE_Error
191
-     * @throws InvalidArgumentException
192
-     * @throws InvalidDataTypeException
193
-     * @throws InvalidInterfaceException
194
-     * @throws ReflectionException
195
-     * @throws ServiceNotFoundException
196
-     */
197
-    public function init()
198
-    {
199
-        //only enable most of the EE_Admin IF we're not in full maintenance mode
200
-        if (EE_Maintenance_Mode::instance()->models_can_query()) {
201
-            //ok so we want to enable the entire admin
202
-            $this->persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
203
-                'EventEspresso\core\services\notifications\PersistentAdminNoticeManager',
204
-                array(
205
-                    EE_Admin_Page::add_query_args_and_nonce(
206
-                        array(
207
-                            'page'   => EE_Registry::instance()->REQ->get('page', ''),
208
-                            'action' => EE_Registry::instance()->REQ->get('action', ''),
209
-                        ),
210
-                        EE_ADMIN_URL
211
-                    ),
212
-                )
213
-            );
214
-            //at a glance dashboard widget
215
-            add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10);
216
-            //filter for get_edit_post_link used on comments for custom post types
217
-            add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2);
218
-        }
219
-        // run the admin page factory but ONLY if we are doing an ee admin ajax request
220
-        if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) {
221
-            try {
222
-                //this loads the controller for the admin pages which will setup routing etc
223
-                EE_Registry::instance()->load_core('Admin_Page_Loader');
224
-            } catch (EE_Error $e) {
225
-                $e->get_error();
226
-            }
227
-        }
228
-        add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1);
229
-        //make sure our CPTs and custom taxonomy metaboxes get shown for first time users
230
-        add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10);
231
-        add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10);
232
-        //exclude EE critical pages from all nav menus and wp_list_pages
233
-        add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10);
234
-    }
235
-
236
-
237
-
238
-    /**
239
-     * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from
240
-     * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in
241
-     * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that
242
-     * to override any queries found in the existing query for the given post type.  Note that _default_query is not a
243
-     * normal property on the post_type object.  It's found ONLY in this particular context.
244
-     *
245
-     * @param WP_Post $post_type WP post type object
246
-     * @return WP_Post
247
-     * @throws InvalidArgumentException
248
-     * @throws InvalidDataTypeException
249
-     * @throws InvalidInterfaceException
250
-     */
251
-    public function remove_pages_from_nav_menu($post_type)
252
-    {
253
-        //if this isn't the "pages" post type let's get out
254
-        if ($post_type->name !== 'page') {
255
-            return $post_type;
256
-        }
257
-        $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
258
-        $post_type->_default_query = array(
259
-            'post__not_in' => $critical_pages,
260
-        );
261
-        return $post_type;
262
-    }
263
-
264
-
265
-
266
-    /**
267
-     * WP by default only shows three metaboxes in "nav-menus.php" for first times users.  We want to make sure our
268
-     * metaboxes get shown as well
269
-     *
270
-     * @return void
271
-     */
272
-    public function enable_hidden_ee_nav_menu_metaboxes()
273
-    {
274
-        global $wp_meta_boxes, $pagenow;
275
-        if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
276
-            return;
277
-        }
278
-        $user = wp_get_current_user();
279
-        //has this been done yet?
280
-        if (get_user_option('ee_nav_menu_initialized', $user->ID)) {
281
-            return;
282
-        }
283
-
284
-        $hidden_meta_boxes  = get_user_option('metaboxhidden_nav-menus', $user->ID);
285
-        $initial_meta_boxes = apply_filters(
286
-            'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes',
287
-            array(
288
-                'nav-menu-theme-locations',
289
-                'add-page',
290
-                'add-custom-links',
291
-                'add-category',
292
-                'add-espresso_events',
293
-                'add-espresso_venues',
294
-                'add-espresso_event_categories',
295
-                'add-espresso_venue_categories',
296
-                'add-post-type-post',
297
-                'add-post-type-page',
298
-            )
299
-        );
300
-
301
-        if (is_array($hidden_meta_boxes)) {
302
-            foreach ($hidden_meta_boxes as $key => $meta_box_id) {
303
-                if (in_array($meta_box_id, $initial_meta_boxes, true)) {
304
-                    unset($hidden_meta_boxes[$key]);
305
-                }
306
-            }
307
-        }
308
-        update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
309
-        update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true);
310
-    }
311
-
312
-
313
-
314
-    /**
315
-     * This method simply registers custom nav menu boxes for "nav_menus.php route"
316
-     * Currently EE is using this to make sure there are menu options for our CPT archive page routes.
317
-     *
318
-     * @todo   modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by
319
-     *         addons etc.
320
-     * @return void
321
-     */
322
-    public function register_custom_nav_menu_boxes()
323
-    {
324
-        add_meta_box(
325
-            'add-extra-nav-menu-pages',
326
-            esc_html__('Event Espresso Pages', 'event_espresso'),
327
-            array($this, 'ee_cpt_archive_pages'),
328
-            'nav-menus',
329
-            'side',
330
-            'core'
331
-        );
332
-    }
333
-
334
-
335
-
336
-    /**
337
-     * Use this to edit the post link for our cpts so that the edit link points to the correct page.
338
-     *
339
-     * @since   4.3.0
340
-     * @param string $link the original link generated by wp
341
-     * @param int    $id   post id
342
-     * @return string  the (maybe) modified link
343
-     */
344
-    public function modify_edit_post_link($link, $id)
345
-    {
346
-        if (! $post = get_post($id)) {
347
-            return $link;
348
-        }
349
-        if ($post->post_type === 'espresso_attendees') {
350
-            $query_args = array(
351
-                'action' => 'edit_attendee',
352
-                'post'   => $id,
353
-            );
354
-            return EEH_URL::add_query_args_and_nonce(
355
-                $query_args,
356
-                admin_url('admin.php?page=espresso_registrations')
357
-            );
358
-        }
359
-        return $link;
360
-    }
361
-
362
-
363
-
364
-    public function ee_cpt_archive_pages()
365
-    {
366
-        global $nav_menu_selected_id;
367
-        $db_fields   = false;
368
-        $walker      = new Walker_Nav_Menu_Checklist($db_fields);
369
-        $current_tab = 'event-archives';
370
-        $removed_args = array(
371
-            'action',
372
-            'customlink-tab',
373
-            'edit-menu-item',
374
-            'menu-item',
375
-            'page-tab',
376
-            '_wpnonce',
377
-        );
378
-        ?>
24
+	/**
25
+	 * @var EE_Admin $_instance
26
+	 */
27
+	private static $_instance;
28
+
29
+	/**
30
+	 * @var PersistentAdminNoticeManager $persistent_admin_notice_manager
31
+	 */
32
+	private $persistent_admin_notice_manager;
33
+
34
+	/**
35
+	 * @singleton method used to instantiate class object
36
+	 * @return EE_Admin
37
+	 * @throws EE_Error
38
+	 */
39
+	public static function instance()
40
+	{
41
+		// check if class object is instantiated
42
+		if (! self::$_instance instanceof EE_Admin) {
43
+			self::$_instance = new self();
44
+		}
45
+		return self::$_instance;
46
+	}
47
+
48
+
49
+	/**
50
+	 * @return EE_Admin
51
+	 * @throws EE_Error
52
+	 */
53
+	public static function reset()
54
+	{
55
+		self::$_instance = null;
56
+		return self::instance();
57
+	}
58
+
59
+
60
+	/**
61
+	 * class constructor
62
+	 *
63
+	 * @throws EE_Error
64
+	 * @throws InvalidDataTypeException
65
+	 * @throws InvalidInterfaceException
66
+	 * @throws InvalidArgumentException
67
+	 */
68
+	protected function __construct()
69
+	{
70
+		// define global EE_Admin constants
71
+		$this->_define_all_constants();
72
+		// set autoloaders for our admin page classes based on included path information
73
+		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN);
74
+		// admin hooks
75
+		add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2);
76
+		// load EE_Request_Handler early
77
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request'));
78
+		add_action('AHEE__EE_System__initialize_last', array($this, 'init'));
79
+		add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2);
80
+		add_action('wp_loaded', array($this, 'wp_loaded'), 100);
81
+		add_action('admin_init', array($this, 'admin_init'), 100);
82
+		add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20);
83
+		add_action('admin_notices', array($this, 'display_admin_notices'), 10);
84
+		add_action('network_admin_notices', array($this, 'display_admin_notices'), 10);
85
+		add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2);
86
+		add_filter('admin_footer_text', array($this, 'espresso_admin_footer'));
87
+		//reset Environment config (we only do this on admin page loads);
88
+		EE_Registry::instance()->CFG->environment->recheck_values();
89
+		do_action('AHEE__EE_Admin__loaded');
90
+	}
91
+
92
+
93
+
94
+	/**
95
+	 * _define_all_constants
96
+	 * define constants that are set globally for all admin pages
97
+	 *
98
+	 * @return void
99
+	 */
100
+	private function _define_all_constants()
101
+	{
102
+		if (! defined('EE_ADMIN_URL')) {
103
+			define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/');
104
+			define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/');
105
+			define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS);
106
+			define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/');
107
+			define('WP_AJAX_URL', admin_url('admin-ajax.php'));
108
+		}
109
+	}
110
+
111
+
112
+	/**
113
+	 * filter_plugin_actions - adds links to the Plugins page listing
114
+	 *
115
+	 * @param    array  $links
116
+	 * @param    string $plugin
117
+	 * @return    array
118
+	 */
119
+	public function filter_plugin_actions($links, $plugin)
120
+	{
121
+		// set $main_file in stone
122
+		static $main_file;
123
+		// if $main_file is not set yet
124
+		if (! $main_file) {
125
+			$main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE);
126
+		}
127
+		if ($plugin === $main_file) {
128
+			// compare current plugin to this one
129
+			if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) {
130
+				$maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"'
131
+									. ' title="Event Espresso is in maintenance mode.  Click this link to learn why.">'
132
+									. esc_html__('Maintenance Mode Active', 'event_espresso')
133
+									. '</a>';
134
+				array_unshift($links, $maintenance_link);
135
+			} else {
136
+				$org_settings_link = '<a href="admin.php?page=espresso_general_settings">'
137
+									 . esc_html__('Settings', 'event_espresso')
138
+									 . '</a>';
139
+				$events_link       = '<a href="admin.php?page=espresso_events">'
140
+									 . esc_html__('Events', 'event_espresso')
141
+									 . '</a>';
142
+				// add before other links
143
+				array_unshift($links, $org_settings_link, $events_link);
144
+			}
145
+		}
146
+		return $links;
147
+	}
148
+
149
+
150
+	/**
151
+	 * _get_request
152
+	 *
153
+	 * @return void
154
+	 * @throws EE_Error
155
+	 * @throws InvalidArgumentException
156
+	 * @throws InvalidDataTypeException
157
+	 * @throws InvalidInterfaceException
158
+	 * @throws ReflectionException
159
+	 */
160
+	public function get_request()
161
+	{
162
+		EE_Registry::instance()->load_core('Request_Handler');
163
+		EE_Registry::instance()->load_core('CPT_Strategy');
164
+	}
165
+
166
+
167
+
168
+	/**
169
+	 * hide_admin_pages_except_maintenance_mode
170
+	 *
171
+	 * @param array $admin_page_folder_names
172
+	 * @return array
173
+	 */
174
+	public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array())
175
+	{
176
+		return array(
177
+			'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS,
178
+			'about'       => EE_ADMIN_PAGES . 'about' . DS,
179
+			'support'     => EE_ADMIN_PAGES . 'support' . DS,
180
+		);
181
+	}
182
+
183
+
184
+
185
+	/**
186
+	 * init- should fire after shortcode, module,  addon, other plugin (default priority), and even
187
+	 * EE_Front_Controller's init phases have run
188
+	 *
189
+	 * @return void
190
+	 * @throws EE_Error
191
+	 * @throws InvalidArgumentException
192
+	 * @throws InvalidDataTypeException
193
+	 * @throws InvalidInterfaceException
194
+	 * @throws ReflectionException
195
+	 * @throws ServiceNotFoundException
196
+	 */
197
+	public function init()
198
+	{
199
+		//only enable most of the EE_Admin IF we're not in full maintenance mode
200
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
201
+			//ok so we want to enable the entire admin
202
+			$this->persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
203
+				'EventEspresso\core\services\notifications\PersistentAdminNoticeManager',
204
+				array(
205
+					EE_Admin_Page::add_query_args_and_nonce(
206
+						array(
207
+							'page'   => EE_Registry::instance()->REQ->get('page', ''),
208
+							'action' => EE_Registry::instance()->REQ->get('action', ''),
209
+						),
210
+						EE_ADMIN_URL
211
+					),
212
+				)
213
+			);
214
+			//at a glance dashboard widget
215
+			add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10);
216
+			//filter for get_edit_post_link used on comments for custom post types
217
+			add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2);
218
+		}
219
+		// run the admin page factory but ONLY if we are doing an ee admin ajax request
220
+		if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) {
221
+			try {
222
+				//this loads the controller for the admin pages which will setup routing etc
223
+				EE_Registry::instance()->load_core('Admin_Page_Loader');
224
+			} catch (EE_Error $e) {
225
+				$e->get_error();
226
+			}
227
+		}
228
+		add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1);
229
+		//make sure our CPTs and custom taxonomy metaboxes get shown for first time users
230
+		add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10);
231
+		add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10);
232
+		//exclude EE critical pages from all nav menus and wp_list_pages
233
+		add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10);
234
+	}
235
+
236
+
237
+
238
+	/**
239
+	 * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from
240
+	 * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in
241
+	 * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that
242
+	 * to override any queries found in the existing query for the given post type.  Note that _default_query is not a
243
+	 * normal property on the post_type object.  It's found ONLY in this particular context.
244
+	 *
245
+	 * @param WP_Post $post_type WP post type object
246
+	 * @return WP_Post
247
+	 * @throws InvalidArgumentException
248
+	 * @throws InvalidDataTypeException
249
+	 * @throws InvalidInterfaceException
250
+	 */
251
+	public function remove_pages_from_nav_menu($post_type)
252
+	{
253
+		//if this isn't the "pages" post type let's get out
254
+		if ($post_type->name !== 'page') {
255
+			return $post_type;
256
+		}
257
+		$critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
258
+		$post_type->_default_query = array(
259
+			'post__not_in' => $critical_pages,
260
+		);
261
+		return $post_type;
262
+	}
263
+
264
+
265
+
266
+	/**
267
+	 * WP by default only shows three metaboxes in "nav-menus.php" for first times users.  We want to make sure our
268
+	 * metaboxes get shown as well
269
+	 *
270
+	 * @return void
271
+	 */
272
+	public function enable_hidden_ee_nav_menu_metaboxes()
273
+	{
274
+		global $wp_meta_boxes, $pagenow;
275
+		if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
276
+			return;
277
+		}
278
+		$user = wp_get_current_user();
279
+		//has this been done yet?
280
+		if (get_user_option('ee_nav_menu_initialized', $user->ID)) {
281
+			return;
282
+		}
283
+
284
+		$hidden_meta_boxes  = get_user_option('metaboxhidden_nav-menus', $user->ID);
285
+		$initial_meta_boxes = apply_filters(
286
+			'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes',
287
+			array(
288
+				'nav-menu-theme-locations',
289
+				'add-page',
290
+				'add-custom-links',
291
+				'add-category',
292
+				'add-espresso_events',
293
+				'add-espresso_venues',
294
+				'add-espresso_event_categories',
295
+				'add-espresso_venue_categories',
296
+				'add-post-type-post',
297
+				'add-post-type-page',
298
+			)
299
+		);
300
+
301
+		if (is_array($hidden_meta_boxes)) {
302
+			foreach ($hidden_meta_boxes as $key => $meta_box_id) {
303
+				if (in_array($meta_box_id, $initial_meta_boxes, true)) {
304
+					unset($hidden_meta_boxes[$key]);
305
+				}
306
+			}
307
+		}
308
+		update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
309
+		update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true);
310
+	}
311
+
312
+
313
+
314
+	/**
315
+	 * This method simply registers custom nav menu boxes for "nav_menus.php route"
316
+	 * Currently EE is using this to make sure there are menu options for our CPT archive page routes.
317
+	 *
318
+	 * @todo   modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by
319
+	 *         addons etc.
320
+	 * @return void
321
+	 */
322
+	public function register_custom_nav_menu_boxes()
323
+	{
324
+		add_meta_box(
325
+			'add-extra-nav-menu-pages',
326
+			esc_html__('Event Espresso Pages', 'event_espresso'),
327
+			array($this, 'ee_cpt_archive_pages'),
328
+			'nav-menus',
329
+			'side',
330
+			'core'
331
+		);
332
+	}
333
+
334
+
335
+
336
+	/**
337
+	 * Use this to edit the post link for our cpts so that the edit link points to the correct page.
338
+	 *
339
+	 * @since   4.3.0
340
+	 * @param string $link the original link generated by wp
341
+	 * @param int    $id   post id
342
+	 * @return string  the (maybe) modified link
343
+	 */
344
+	public function modify_edit_post_link($link, $id)
345
+	{
346
+		if (! $post = get_post($id)) {
347
+			return $link;
348
+		}
349
+		if ($post->post_type === 'espresso_attendees') {
350
+			$query_args = array(
351
+				'action' => 'edit_attendee',
352
+				'post'   => $id,
353
+			);
354
+			return EEH_URL::add_query_args_and_nonce(
355
+				$query_args,
356
+				admin_url('admin.php?page=espresso_registrations')
357
+			);
358
+		}
359
+		return $link;
360
+	}
361
+
362
+
363
+
364
+	public function ee_cpt_archive_pages()
365
+	{
366
+		global $nav_menu_selected_id;
367
+		$db_fields   = false;
368
+		$walker      = new Walker_Nav_Menu_Checklist($db_fields);
369
+		$current_tab = 'event-archives';
370
+		$removed_args = array(
371
+			'action',
372
+			'customlink-tab',
373
+			'edit-menu-item',
374
+			'menu-item',
375
+			'page-tab',
376
+			'_wpnonce',
377
+		);
378
+		?>
379 379
         <div id="posttype-extra-nav-menu-pages" class="posttypediv">
380 380
             <ul id="posttype-extra-nav-menu-pages-tabs" class="posttype-tabs add-menu-item-tabs">
381 381
                 <li <?php echo('event-archives' === $current_tab ? ' class="tabs"' : ''); ?>>
382 382
                     <a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives"
383 383
                        href="<?php if ($nav_menu_selected_id) {
384
-                            echo esc_url(
385
-                                add_query_arg(
386
-                                    'extra-nav-menu-pages-tab',
387
-                                    'event-archives',
388
-                                    remove_query_arg($removed_args)
389
-                                )
390
-                            );
391
-                       } ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives">
384
+							echo esc_url(
385
+								add_query_arg(
386
+									'extra-nav-menu-pages-tab',
387
+									'event-archives',
388
+									remove_query_arg($removed_args)
389
+								)
390
+							);
391
+					   } ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives">
392 392
                         <?php _e('Event Archive Pages', 'event_espresso'); ?>
393 393
                     </a>
394 394
                 </li>
395 395
             </ul><!-- .posttype-tabs -->
396 396
 
397 397
             <div id="tabs-panel-posttype-extra-nav-menu-pages-event-archives" class="tabs-panel <?php
398
-                echo('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
399
-                ?>">
398
+				echo('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
399
+				?>">
400 400
                     <ul id="extra-nav-menu-pageschecklist-event-archives" class="categorychecklist form-no-clear">
401 401
                         <?php
402
-                        $pages          = $this->_get_extra_nav_menu_pages_items();
403
-                        $args['walker'] = $walker;
404
-                        echo walk_nav_menu_tree(
405
-                            array_map(
406
-                                array($this, '_setup_extra_nav_menu_pages_items'),
407
-                                $pages
408
-                            ),
409
-                            0,
410
-                            (object) $args
411
-                        );
412
-                        ?>
402
+						$pages          = $this->_get_extra_nav_menu_pages_items();
403
+						$args['walker'] = $walker;
404
+						echo walk_nav_menu_tree(
405
+							array_map(
406
+								array($this, '_setup_extra_nav_menu_pages_items'),
407
+								$pages
408
+							),
409
+							0,
410
+							(object) $args
411
+						);
412
+						?>
413 413
                     </ul>
414 414
                 </div><!-- /.tabs-panel -->
415 415
 
416 416
                 <p class="button-controls">
417 417
                 <span class="list-controls">
418 418
                     <a href="<?php
419
-                    echo esc_url(add_query_arg(
420
-                        array(
421
-                            'extra-nav-menu-pages-tab' => 'event-archives',
422
-                            'selectall'                => 1,
423
-                        ),
424
-                        remove_query_arg($removed_args)
425
-                    ));
426
-                    ?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All'); ?></a>
419
+					echo esc_url(add_query_arg(
420
+						array(
421
+							'extra-nav-menu-pages-tab' => 'event-archives',
422
+							'selectall'                => 1,
423
+						),
424
+						remove_query_arg($removed_args)
425
+					));
426
+					?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All'); ?></a>
427 427
                 </span>
428 428
                 <span class="add-to-menu">
429 429
                     <input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?>
@@ -436,471 +436,471 @@  discard block
 block discarded – undo
436 436
 
437 437
         </div><!-- /.posttypediv -->
438 438
         <?php
439
-    }
440
-
441
-
442
-    /**
443
-     * Returns an array of event archive nav items.
444
-     *
445
-     * @todo  for now this method is just in place so when it gets abstracted further we can substitute in whatever
446
-     *        method we use for getting the extra nav menu items
447
-     * @return array
448
-     */
449
-    private function _get_extra_nav_menu_pages_items()
450
-    {
451
-        $menuitems[] = array(
452
-            'title'       => esc_html__('Event List', 'event_espresso'),
453
-            'url'         => get_post_type_archive_link('espresso_events'),
454
-            'description' => esc_html__('Archive page for all events.', 'event_espresso'),
455
-        );
456
-        return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems);
457
-    }
458
-
459
-
460
-    /**
461
-     * Setup nav menu walker item for usage in the event archive nav menu metabox.  It receives a menu_item array with
462
-     * the properties and converts it to the menu item object.
463
-     *
464
-     * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php
465
-     * @param $menu_item_values
466
-     * @return stdClass
467
-     */
468
-    private function _setup_extra_nav_menu_pages_items($menu_item_values)
469
-    {
470
-        $menu_item = new stdClass();
471
-        $keys      = array(
472
-            'ID'               => 0,
473
-            'db_id'            => 0,
474
-            'menu_item_parent' => 0,
475
-            'object_id'        => -1,
476
-            'post_parent'      => 0,
477
-            'type'             => 'custom',
478
-            'object'           => '',
479
-            'type_label'       => esc_html__('Extra Nav Menu Item', 'event_espresso'),
480
-            'title'            => '',
481
-            'url'              => '',
482
-            'target'           => '',
483
-            'attr_title'       => '',
484
-            'description'      => '',
485
-            'classes'          => array(),
486
-            'xfn'              => '',
487
-        );
488
-
489
-        foreach ($keys as $key => $value) {
490
-            $menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value;
491
-        }
492
-        return $menu_item;
493
-    }
494
-
495
-
496
-    /**
497
-     * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an
498
-     * EE_Admin_Page route is called.
499
-     *
500
-     * @return void
501
-     */
502
-    public function route_admin_request()
503
-    {
504
-    }
505
-
506
-
507
-    /**
508
-     * wp_loaded should fire on the WordPress wp_loaded hook.  This fires on a VERY late priority.
509
-     *
510
-     * @return void
511
-     */
512
-    public function wp_loaded()
513
-    {
514
-    }
515
-
516
-
517
-    /**
518
-     * admin_init
519
-     *
520
-     * @return void
521
-     * @throws EE_Error
522
-     * @throws InvalidArgumentException
523
-     * @throws InvalidDataTypeException
524
-     * @throws InvalidInterfaceException
525
-     * @throws ReflectionException
526
-     */
527
-    public function admin_init()
528
-    {
529
-
530
-        /**
531
-         * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php),
532
-         * so any hooking into core WP routes is taken care of.  So in this next few lines of code:
533
-         * - check if doing post processing.
534
-         * - check if doing post processing of one of EE CPTs
535
-         * - instantiate the corresponding EE CPT model for the post_type being processed.
536
-         */
537
-        if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') {
538
-            EE_Registry::instance()->load_core('Register_CPTs');
539
-            EE_Register_CPTs::instantiate_cpt_models($_POST['post_type']);
540
-        }
541
-
542
-
543
-        /**
544
-         * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting
545
-         * critical pages.  The only place critical pages need included in a generated dropdown is on the "Critical
546
-         * Pages" tab in the EE General Settings Admin page.
547
-         * This is for user-proofing.
548
-         */
549
-        add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages'));
550
-    }
551
-
552
-
553
-    /**
554
-     * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection.
555
-     *
556
-     * @param string $output Current output.
557
-     * @return string
558
-     * @throws InvalidArgumentException
559
-     * @throws InvalidDataTypeException
560
-     * @throws InvalidInterfaceException
561
-     */
562
-    public function modify_dropdown_pages($output)
563
-    {
564
-        //get critical pages
565
-        $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
566
-
567
-        //split current output by line break for easier parsing.
568
-        $split_output = explode("\n", $output);
569
-
570
-        //loop through to remove any critical pages from the array.
571
-        foreach ($critical_pages as $page_id) {
572
-            $needle = 'value="' . $page_id . '"';
573
-            foreach ($split_output as $key => $haystack) {
574
-                if (strpos($haystack, $needle) !== false) {
575
-                    unset($split_output[$key]);
576
-                }
577
-            }
578
-        }
579
-        //replace output with the new contents
580
-        return implode("\n", $split_output);
581
-    }
582
-
583
-
584
-    /**
585
-     * enqueue all admin scripts that need loaded for admin pages
586
-     *
587
-     * @return void
588
-     */
589
-    public function enqueue_admin_scripts()
590
-    {
591
-        // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.
592
-        // Note: the intention of this script is to only do TARGETED injections.  I.E, only injecting on certain script
593
-        // calls.
594
-        wp_enqueue_script(
595
-            'ee-inject-wp',
596
-            EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',
597
-            array('jquery'),
598
-            EVENT_ESPRESSO_VERSION,
599
-            true
600
-        );
601
-        // register cookie script for future dependencies
602
-        wp_register_script(
603
-            'jquery-cookie',
604
-            EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js',
605
-            array('jquery'),
606
-            '2.1',
607
-            true
608
-        );
609
-        //joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again
610
-        // via: add_filter('FHEE_load_joyride', '__return_true' );
611
-        if (apply_filters('FHEE_load_joyride', false)) {
612
-            //joyride style
613
-            wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1');
614
-            wp_register_style(
615
-                'ee-joyride-css',
616
-                EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css',
617
-                array('joyride-css'),
618
-                EVENT_ESPRESSO_VERSION
619
-            );
620
-            wp_register_script(
621
-                'joyride-modernizr',
622
-                EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js',
623
-                array(),
624
-                '2.1',
625
-                true
626
-            );
627
-            //joyride JS
628
-            wp_register_script(
629
-                'jquery-joyride',
630
-                EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js',
631
-                array('jquery-cookie', 'joyride-modernizr'),
632
-                '2.1',
633
-                true
634
-            );
635
-            // wanna go for a joyride?
636
-            wp_enqueue_style('ee-joyride-css');
637
-            wp_enqueue_script('jquery-joyride');
638
-        }
639
-    }
640
-
641
-
642
-    /**
643
-     * display_admin_notices
644
-     *
645
-     * @return void
646
-     */
647
-    public function display_admin_notices()
648
-    {
649
-        echo EE_Error::get_notices();
650
-    }
651
-
652
-
653
-
654
-    /**
655
-     * @param array $elements
656
-     * @return array
657
-     * @throws EE_Error
658
-     * @throws InvalidArgumentException
659
-     * @throws InvalidDataTypeException
660
-     * @throws InvalidInterfaceException
661
-     */
662
-    public function dashboard_glance_items($elements)
663
-    {
664
-        $elements                        = is_array($elements) ? $elements : array($elements);
665
-        $events                          = EEM_Event::instance()->count();
666
-        $items['events']['url']          = EE_Admin_Page::add_query_args_and_nonce(
667
-            array('page' => 'espresso_events'),
668
-            admin_url('admin.php')
669
-        );
670
-        $items['events']['text']         = sprintf(_n('%s Event', '%s Events', $events), number_format_i18n($events));
671
-        $items['events']['title']        = esc_html__('Click to view all Events', 'event_espresso');
672
-        $registrations                   = EEM_Registration::instance()->count(
673
-            array(
674
-                array(
675
-                    'STS_ID' => array('!=', EEM_Registration::status_id_incomplete),
676
-                ),
677
-            )
678
-        );
679
-        $items['registrations']['url']   = EE_Admin_Page::add_query_args_and_nonce(
680
-            array('page' => 'espresso_registrations'),
681
-            admin_url('admin.php')
682
-        );
683
-        $items['registrations']['text']  = sprintf(
684
-            _n('%s Registration', '%s Registrations', $registrations),
685
-            number_format_i18n($registrations)
686
-        );
687
-        $items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso');
688
-
689
-        $items = (array)apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
690
-
691
-        foreach ($items as $type => $item_properties) {
692
-            $elements[] = sprintf(
693
-                '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>',
694
-                $item_properties['url'],
695
-                $item_properties['title'],
696
-                $item_properties['text']
697
-            );
698
-        }
699
-        return $elements;
700
-    }
701
-
702
-
703
-    /**
704
-     * check_for_invalid_datetime_formats
705
-     * if an admin changes their date or time format settings on the WP General Settings admin page, verify that
706
-     * their selected format can be parsed by PHP
707
-     *
708
-     * @param    $value
709
-     * @param    $option
710
-     * @throws EE_Error
711
-     * @return    string
712
-     */
713
-    public function check_for_invalid_datetime_formats($value, $option)
714
-    {
715
-        // check for date_format or time_format
716
-        switch ($option) {
717
-            case 'date_format':
718
-                $date_time_format = $value . ' ' . get_option('time_format');
719
-                break;
720
-            case 'time_format':
721
-                $date_time_format = get_option('date_format') . ' ' . $value;
722
-                break;
723
-            default:
724
-                $date_time_format = false;
725
-        }
726
-        // do we have a date_time format to check ?
727
-        if ($date_time_format) {
728
-            $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format);
729
-
730
-            if (is_array($error_msg)) {
731
-                $msg = '<p>'
732
-                       . sprintf(
733
-                           esc_html__(
734
-                               'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:',
735
-                               'event_espresso'
736
-                           ),
737
-                           date($date_time_format),
738
-                           $date_time_format
739
-                       )
740
-                       . '</p><p><ul>';
741
-
742
-
743
-                foreach ($error_msg as $error) {
744
-                    $msg .= '<li>' . $error . '</li>';
745
-                }
746
-
747
-                $msg .= '</ul></p><p>'
748
-                        . sprintf(
749
-                            esc_html__(
750
-                                '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s',
751
-                                'event_espresso'
752
-                            ),
753
-                            '<span style="color:#D54E21;">',
754
-                            '</span>'
755
-                        )
756
-                        . '</p>';
757
-
758
-                // trigger WP settings error
759
-                add_settings_error(
760
-                    'date_format',
761
-                    'date_format',
762
-                    $msg
763
-                );
764
-
765
-                // set format to something valid
766
-                switch ($option) {
767
-                    case 'date_format':
768
-                        $value = 'F j, Y';
769
-                        break;
770
-                    case 'time_format':
771
-                        $value = 'g:i a';
772
-                        break;
773
-                }
774
-            }
775
-        }
776
-        return $value;
777
-    }
778
-
779
-
780
-    /**
781
-     * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso"
782
-     *
783
-     * @param $content
784
-     * @return    string
785
-     */
786
-    public function its_eSpresso($content)
787
-    {
788
-        return str_replace('[EXPRESSO_', '[ESPRESSO_', $content);
789
-    }
790
-
791
-
792
-    /**
793
-     * espresso_admin_footer
794
-     *
795
-     * @return    string
796
-     */
797
-    public function espresso_admin_footer()
798
-    {
799
-        return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer'));
800
-    }
801
-
802
-
803
-    /**
804
-     * static method for registering ee admin page.
805
-     * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register.
806
-     *
807
-     * @since      4.3.0
808
-     * @deprecated 4.3.0    Use EE_Register_Admin_Page::register() instead
809
-     * @see        EE_Register_Admin_Page::register()
810
-     * @param       $page_basename
811
-     * @param       $page_path
812
-     * @param array $config
813
-     * @return void
814
-     * @throws EE_Error
815
-     */
816
-    public static function register_ee_admin_page($page_basename, $page_path, $config = array())
817
-    {
818
-        EE_Error::doing_it_wrong(
819
-            __METHOD__,
820
-            sprintf(
821
-                esc_html__(
822
-                    'Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.',
823
-                    'event_espresso'
824
-                ),
825
-                $page_basename
826
-            ),
827
-            '4.3'
828
-        );
829
-        if (class_exists('EE_Register_Admin_Page')) {
830
-            $config['page_path'] = $page_path;
831
-        }
832
-        EE_Register_Admin_Page::register($page_basename, $config);
833
-    }
834
-
835
-
836
-    /**
837
-     * @deprecated 4.8.41
838
-     * @param  int      $post_ID
839
-     * @param  \WP_Post $post
840
-     * @return void
841
-     */
842
-    public static function parse_post_content_on_save($post_ID, $post)
843
-    {
844
-        EE_Error::doing_it_wrong(
845
-            __METHOD__,
846
-            esc_html__('Usage is deprecated', 'event_espresso'),
847
-            '4.8.41'
848
-        );
849
-    }
850
-
851
-
852
-    /**
853
-     * @deprecated 4.8.41
854
-     * @param  $option
855
-     * @param  $old_value
856
-     * @param  $value
857
-     * @return void
858
-     */
859
-    public function reset_page_for_posts_on_change($option, $old_value, $value)
860
-    {
861
-        EE_Error::doing_it_wrong(
862
-            __METHOD__,
863
-            esc_html__('Usage is deprecated', 'event_espresso'),
864
-            '4.8.41'
865
-        );
866
-    }
867
-
868
-
869
-
870
-    /**
871
-     * @deprecated 4.9.27
872
-     * @return void
873
-     */
874
-    public function get_persistent_admin_notices()
875
-    {
876
-        EE_Error::doing_it_wrong(
877
-            __METHOD__,
878
-            sprintf(
879
-                __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
880
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
881
-            ),
882
-            '4.9.27'
883
-        );
884
-    }
885
-
886
-
887
-
888
-    /**
889
-     * @deprecated 4.9.27
890
-     * @throws InvalidInterfaceException
891
-     * @throws InvalidDataTypeException
892
-     * @throws DomainException
893
-     */
894
-    public function dismiss_ee_nag_notice_callback()
895
-    {
896
-        EE_Error::doing_it_wrong(
897
-            __METHOD__,
898
-            sprintf(
899
-                __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
900
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
901
-            ),
902
-            '4.9.27'
903
-        );
904
-        $this->persistent_admin_notice_manager->dismissNotice();
905
-    }
439
+	}
440
+
441
+
442
+	/**
443
+	 * Returns an array of event archive nav items.
444
+	 *
445
+	 * @todo  for now this method is just in place so when it gets abstracted further we can substitute in whatever
446
+	 *        method we use for getting the extra nav menu items
447
+	 * @return array
448
+	 */
449
+	private function _get_extra_nav_menu_pages_items()
450
+	{
451
+		$menuitems[] = array(
452
+			'title'       => esc_html__('Event List', 'event_espresso'),
453
+			'url'         => get_post_type_archive_link('espresso_events'),
454
+			'description' => esc_html__('Archive page for all events.', 'event_espresso'),
455
+		);
456
+		return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems);
457
+	}
458
+
459
+
460
+	/**
461
+	 * Setup nav menu walker item for usage in the event archive nav menu metabox.  It receives a menu_item array with
462
+	 * the properties and converts it to the menu item object.
463
+	 *
464
+	 * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php
465
+	 * @param $menu_item_values
466
+	 * @return stdClass
467
+	 */
468
+	private function _setup_extra_nav_menu_pages_items($menu_item_values)
469
+	{
470
+		$menu_item = new stdClass();
471
+		$keys      = array(
472
+			'ID'               => 0,
473
+			'db_id'            => 0,
474
+			'menu_item_parent' => 0,
475
+			'object_id'        => -1,
476
+			'post_parent'      => 0,
477
+			'type'             => 'custom',
478
+			'object'           => '',
479
+			'type_label'       => esc_html__('Extra Nav Menu Item', 'event_espresso'),
480
+			'title'            => '',
481
+			'url'              => '',
482
+			'target'           => '',
483
+			'attr_title'       => '',
484
+			'description'      => '',
485
+			'classes'          => array(),
486
+			'xfn'              => '',
487
+		);
488
+
489
+		foreach ($keys as $key => $value) {
490
+			$menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value;
491
+		}
492
+		return $menu_item;
493
+	}
494
+
495
+
496
+	/**
497
+	 * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an
498
+	 * EE_Admin_Page route is called.
499
+	 *
500
+	 * @return void
501
+	 */
502
+	public function route_admin_request()
503
+	{
504
+	}
505
+
506
+
507
+	/**
508
+	 * wp_loaded should fire on the WordPress wp_loaded hook.  This fires on a VERY late priority.
509
+	 *
510
+	 * @return void
511
+	 */
512
+	public function wp_loaded()
513
+	{
514
+	}
515
+
516
+
517
+	/**
518
+	 * admin_init
519
+	 *
520
+	 * @return void
521
+	 * @throws EE_Error
522
+	 * @throws InvalidArgumentException
523
+	 * @throws InvalidDataTypeException
524
+	 * @throws InvalidInterfaceException
525
+	 * @throws ReflectionException
526
+	 */
527
+	public function admin_init()
528
+	{
529
+
530
+		/**
531
+		 * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php),
532
+		 * so any hooking into core WP routes is taken care of.  So in this next few lines of code:
533
+		 * - check if doing post processing.
534
+		 * - check if doing post processing of one of EE CPTs
535
+		 * - instantiate the corresponding EE CPT model for the post_type being processed.
536
+		 */
537
+		if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') {
538
+			EE_Registry::instance()->load_core('Register_CPTs');
539
+			EE_Register_CPTs::instantiate_cpt_models($_POST['post_type']);
540
+		}
541
+
542
+
543
+		/**
544
+		 * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting
545
+		 * critical pages.  The only place critical pages need included in a generated dropdown is on the "Critical
546
+		 * Pages" tab in the EE General Settings Admin page.
547
+		 * This is for user-proofing.
548
+		 */
549
+		add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages'));
550
+	}
551
+
552
+
553
+	/**
554
+	 * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection.
555
+	 *
556
+	 * @param string $output Current output.
557
+	 * @return string
558
+	 * @throws InvalidArgumentException
559
+	 * @throws InvalidDataTypeException
560
+	 * @throws InvalidInterfaceException
561
+	 */
562
+	public function modify_dropdown_pages($output)
563
+	{
564
+		//get critical pages
565
+		$critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
566
+
567
+		//split current output by line break for easier parsing.
568
+		$split_output = explode("\n", $output);
569
+
570
+		//loop through to remove any critical pages from the array.
571
+		foreach ($critical_pages as $page_id) {
572
+			$needle = 'value="' . $page_id . '"';
573
+			foreach ($split_output as $key => $haystack) {
574
+				if (strpos($haystack, $needle) !== false) {
575
+					unset($split_output[$key]);
576
+				}
577
+			}
578
+		}
579
+		//replace output with the new contents
580
+		return implode("\n", $split_output);
581
+	}
582
+
583
+
584
+	/**
585
+	 * enqueue all admin scripts that need loaded for admin pages
586
+	 *
587
+	 * @return void
588
+	 */
589
+	public function enqueue_admin_scripts()
590
+	{
591
+		// this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.
592
+		// Note: the intention of this script is to only do TARGETED injections.  I.E, only injecting on certain script
593
+		// calls.
594
+		wp_enqueue_script(
595
+			'ee-inject-wp',
596
+			EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',
597
+			array('jquery'),
598
+			EVENT_ESPRESSO_VERSION,
599
+			true
600
+		);
601
+		// register cookie script for future dependencies
602
+		wp_register_script(
603
+			'jquery-cookie',
604
+			EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js',
605
+			array('jquery'),
606
+			'2.1',
607
+			true
608
+		);
609
+		//joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again
610
+		// via: add_filter('FHEE_load_joyride', '__return_true' );
611
+		if (apply_filters('FHEE_load_joyride', false)) {
612
+			//joyride style
613
+			wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1');
614
+			wp_register_style(
615
+				'ee-joyride-css',
616
+				EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css',
617
+				array('joyride-css'),
618
+				EVENT_ESPRESSO_VERSION
619
+			);
620
+			wp_register_script(
621
+				'joyride-modernizr',
622
+				EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js',
623
+				array(),
624
+				'2.1',
625
+				true
626
+			);
627
+			//joyride JS
628
+			wp_register_script(
629
+				'jquery-joyride',
630
+				EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js',
631
+				array('jquery-cookie', 'joyride-modernizr'),
632
+				'2.1',
633
+				true
634
+			);
635
+			// wanna go for a joyride?
636
+			wp_enqueue_style('ee-joyride-css');
637
+			wp_enqueue_script('jquery-joyride');
638
+		}
639
+	}
640
+
641
+
642
+	/**
643
+	 * display_admin_notices
644
+	 *
645
+	 * @return void
646
+	 */
647
+	public function display_admin_notices()
648
+	{
649
+		echo EE_Error::get_notices();
650
+	}
651
+
652
+
653
+
654
+	/**
655
+	 * @param array $elements
656
+	 * @return array
657
+	 * @throws EE_Error
658
+	 * @throws InvalidArgumentException
659
+	 * @throws InvalidDataTypeException
660
+	 * @throws InvalidInterfaceException
661
+	 */
662
+	public function dashboard_glance_items($elements)
663
+	{
664
+		$elements                        = is_array($elements) ? $elements : array($elements);
665
+		$events                          = EEM_Event::instance()->count();
666
+		$items['events']['url']          = EE_Admin_Page::add_query_args_and_nonce(
667
+			array('page' => 'espresso_events'),
668
+			admin_url('admin.php')
669
+		);
670
+		$items['events']['text']         = sprintf(_n('%s Event', '%s Events', $events), number_format_i18n($events));
671
+		$items['events']['title']        = esc_html__('Click to view all Events', 'event_espresso');
672
+		$registrations                   = EEM_Registration::instance()->count(
673
+			array(
674
+				array(
675
+					'STS_ID' => array('!=', EEM_Registration::status_id_incomplete),
676
+				),
677
+			)
678
+		);
679
+		$items['registrations']['url']   = EE_Admin_Page::add_query_args_and_nonce(
680
+			array('page' => 'espresso_registrations'),
681
+			admin_url('admin.php')
682
+		);
683
+		$items['registrations']['text']  = sprintf(
684
+			_n('%s Registration', '%s Registrations', $registrations),
685
+			number_format_i18n($registrations)
686
+		);
687
+		$items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso');
688
+
689
+		$items = (array)apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
690
+
691
+		foreach ($items as $type => $item_properties) {
692
+			$elements[] = sprintf(
693
+				'<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>',
694
+				$item_properties['url'],
695
+				$item_properties['title'],
696
+				$item_properties['text']
697
+			);
698
+		}
699
+		return $elements;
700
+	}
701
+
702
+
703
+	/**
704
+	 * check_for_invalid_datetime_formats
705
+	 * if an admin changes their date or time format settings on the WP General Settings admin page, verify that
706
+	 * their selected format can be parsed by PHP
707
+	 *
708
+	 * @param    $value
709
+	 * @param    $option
710
+	 * @throws EE_Error
711
+	 * @return    string
712
+	 */
713
+	public function check_for_invalid_datetime_formats($value, $option)
714
+	{
715
+		// check for date_format or time_format
716
+		switch ($option) {
717
+			case 'date_format':
718
+				$date_time_format = $value . ' ' . get_option('time_format');
719
+				break;
720
+			case 'time_format':
721
+				$date_time_format = get_option('date_format') . ' ' . $value;
722
+				break;
723
+			default:
724
+				$date_time_format = false;
725
+		}
726
+		// do we have a date_time format to check ?
727
+		if ($date_time_format) {
728
+			$error_msg = EEH_DTT_Helper::validate_format_string($date_time_format);
729
+
730
+			if (is_array($error_msg)) {
731
+				$msg = '<p>'
732
+					   . sprintf(
733
+						   esc_html__(
734
+							   'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:',
735
+							   'event_espresso'
736
+						   ),
737
+						   date($date_time_format),
738
+						   $date_time_format
739
+					   )
740
+					   . '</p><p><ul>';
741
+
742
+
743
+				foreach ($error_msg as $error) {
744
+					$msg .= '<li>' . $error . '</li>';
745
+				}
746
+
747
+				$msg .= '</ul></p><p>'
748
+						. sprintf(
749
+							esc_html__(
750
+								'%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s',
751
+								'event_espresso'
752
+							),
753
+							'<span style="color:#D54E21;">',
754
+							'</span>'
755
+						)
756
+						. '</p>';
757
+
758
+				// trigger WP settings error
759
+				add_settings_error(
760
+					'date_format',
761
+					'date_format',
762
+					$msg
763
+				);
764
+
765
+				// set format to something valid
766
+				switch ($option) {
767
+					case 'date_format':
768
+						$value = 'F j, Y';
769
+						break;
770
+					case 'time_format':
771
+						$value = 'g:i a';
772
+						break;
773
+				}
774
+			}
775
+		}
776
+		return $value;
777
+	}
778
+
779
+
780
+	/**
781
+	 * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso"
782
+	 *
783
+	 * @param $content
784
+	 * @return    string
785
+	 */
786
+	public function its_eSpresso($content)
787
+	{
788
+		return str_replace('[EXPRESSO_', '[ESPRESSO_', $content);
789
+	}
790
+
791
+
792
+	/**
793
+	 * espresso_admin_footer
794
+	 *
795
+	 * @return    string
796
+	 */
797
+	public function espresso_admin_footer()
798
+	{
799
+		return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer'));
800
+	}
801
+
802
+
803
+	/**
804
+	 * static method for registering ee admin page.
805
+	 * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register.
806
+	 *
807
+	 * @since      4.3.0
808
+	 * @deprecated 4.3.0    Use EE_Register_Admin_Page::register() instead
809
+	 * @see        EE_Register_Admin_Page::register()
810
+	 * @param       $page_basename
811
+	 * @param       $page_path
812
+	 * @param array $config
813
+	 * @return void
814
+	 * @throws EE_Error
815
+	 */
816
+	public static function register_ee_admin_page($page_basename, $page_path, $config = array())
817
+	{
818
+		EE_Error::doing_it_wrong(
819
+			__METHOD__,
820
+			sprintf(
821
+				esc_html__(
822
+					'Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.',
823
+					'event_espresso'
824
+				),
825
+				$page_basename
826
+			),
827
+			'4.3'
828
+		);
829
+		if (class_exists('EE_Register_Admin_Page')) {
830
+			$config['page_path'] = $page_path;
831
+		}
832
+		EE_Register_Admin_Page::register($page_basename, $config);
833
+	}
834
+
835
+
836
+	/**
837
+	 * @deprecated 4.8.41
838
+	 * @param  int      $post_ID
839
+	 * @param  \WP_Post $post
840
+	 * @return void
841
+	 */
842
+	public static function parse_post_content_on_save($post_ID, $post)
843
+	{
844
+		EE_Error::doing_it_wrong(
845
+			__METHOD__,
846
+			esc_html__('Usage is deprecated', 'event_espresso'),
847
+			'4.8.41'
848
+		);
849
+	}
850
+
851
+
852
+	/**
853
+	 * @deprecated 4.8.41
854
+	 * @param  $option
855
+	 * @param  $old_value
856
+	 * @param  $value
857
+	 * @return void
858
+	 */
859
+	public function reset_page_for_posts_on_change($option, $old_value, $value)
860
+	{
861
+		EE_Error::doing_it_wrong(
862
+			__METHOD__,
863
+			esc_html__('Usage is deprecated', 'event_espresso'),
864
+			'4.8.41'
865
+		);
866
+	}
867
+
868
+
869
+
870
+	/**
871
+	 * @deprecated 4.9.27
872
+	 * @return void
873
+	 */
874
+	public function get_persistent_admin_notices()
875
+	{
876
+		EE_Error::doing_it_wrong(
877
+			__METHOD__,
878
+			sprintf(
879
+				__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
880
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
881
+			),
882
+			'4.9.27'
883
+		);
884
+	}
885
+
886
+
887
+
888
+	/**
889
+	 * @deprecated 4.9.27
890
+	 * @throws InvalidInterfaceException
891
+	 * @throws InvalidDataTypeException
892
+	 * @throws DomainException
893
+	 */
894
+	public function dismiss_ee_nag_notice_callback()
895
+	{
896
+		EE_Error::doing_it_wrong(
897
+			__METHOD__,
898
+			sprintf(
899
+				__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
900
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
901
+			),
902
+			'4.9.27'
903
+		);
904
+		$this->persistent_admin_notice_manager->dismissNotice();
905
+	}
906 906
 }
Please login to merge, or discard this patch.
core/libraries/payment_methods/EE_Payment_Method_Manager.lib.php 1 patch
Indentation   +565 added lines, -565 removed lines patch added patch discarded remove patch
@@ -21,571 +21,571 @@
 block discarded – undo
21 21
 class EE_Payment_Method_Manager implements ResettableInterface
22 22
 {
23 23
 
24
-    /**
25
-     * prefix added to all payment method capabilities names
26
-     */
27
-    const   CAPABILITIES_PREFIX= 'ee_payment_method_';
28
-
29
-    /**
30
-     * @var EE_Payment_Method_Manager $_instance
31
-     */
32
-    private static $_instance;
33
-
34
-    /**
35
-     * @var boolean
36
-     */
37
-    protected $payment_method_caps_initialized = false;
38
-
39
-    /**
40
-     * @var array keys are class names without 'EE_PMT_', values are their filepaths
41
-     */
42
-    protected $_payment_method_types = array();
43
-
44
-    /**
45
-     * @var EE_PMT_Base[]
46
-     */
47
-    protected $payment_method_objects = array();
48
-
49
-
50
-
51
-    /**
52
-     * EE_Payment_Method_Manager constructor.
53
-     *
54
-     * @throws EE_Error
55
-     * @throws DomainException
56
-     */
57
-    public function __construct()
58
-    {
59
-        // if in admin lets ensure caps are set.
60
-        if (is_admin()) {
61
-            $this->_register_payment_methods();
62
-            // set them immediately
63
-            $this->initializePaymentMethodCaps();
64
-            // plus any time they get reset
65
-            add_filter(
66
-                'FHEE__EE_Capabilities__addCaps__capabilities_to_add',
67
-                array($this, 'addPaymentMethodCapsDuringReset')
68
-            );
69
-        }
70
-    }
71
-
72
-
73
-
74
-    /**
75
-     * @singleton method used to instantiate class object
76
-     * @return EE_Payment_Method_Manager instance
77
-     * @throws DomainException
78
-     * @throws EE_Error
79
-     */
80
-    public static function instance()
81
-    {
82
-        // check if class object is instantiated, and instantiated properly
83
-        if (! self::$_instance instanceof EE_Payment_Method_Manager) {
84
-            EE_Registry::instance()->load_lib('PMT_Base');
85
-            self::$_instance = new self();
86
-        }
87
-        return self::$_instance;
88
-    }
89
-
90
-
91
-
92
-    /**
93
-     * Resets the instance and returns a new one
94
-     *
95
-     * @return EE_Payment_Method_Manager
96
-     * @throws DomainException
97
-     * @throws EE_Error
98
-     */
99
-    public static function reset()
100
-    {
101
-        self::$_instance = null;
102
-        return self::instance();
103
-    }
104
-
105
-
106
-
107
-    /**
108
-     * If necessary, re-register payment methods
109
-     *
110
-     * @param boolean $force_recheck whether to recheck for payment method types,
111
-     *                               or just re-use the PMTs we found last time we checked during this request (if
112
-     *                               we have not yet checked during this request, then we need to check anyways)
113
-     */
114
-    public function maybe_register_payment_methods($force_recheck = false)
115
-    {
116
-        if (! $this->_payment_method_types || $force_recheck) {
117
-            $this->_register_payment_methods();
118
-        }
119
-    }
120
-
121
-
122
-
123
-    /**
124
-     * register_payment_methods
125
-     *
126
-     * @return array
127
-     */
128
-    protected function _register_payment_methods()
129
-    {
130
-        // grab list of installed modules
131
-        $pm_to_register = glob(EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR);
132
-        // filter list of modules to register
133
-        $pm_to_register = apply_filters(
134
-            'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register',
135
-            $pm_to_register
136
-        );
137
-        // remove any duplicates if that should happen for some reason
138
-        $pm_to_register = array_unique($pm_to_register);
139
-        // loop through folders
140
-        foreach ($pm_to_register as $pm_path) {
141
-            $this->register_payment_method($pm_path);
142
-        }
143
-        do_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods');
144
-        // filter list of installed modules
145
-        //keep them organized alphabetically by the payment method type's name
146
-        ksort($this->_payment_method_types);
147
-        return apply_filters(
148
-            'FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods',
149
-            $this->_payment_method_types
150
-        );
151
-    }
152
-
153
-
154
-
155
-    /**
156
-     * register_payment_method- makes core aware of this payment method
157
-     *
158
-     * @param string $payment_method_path - full path up to and including payment method folder
159
-     * @return boolean
160
-     */
161
-    public function register_payment_method($payment_method_path = '')
162
-    {
163
-        do_action('AHEE__EE_Payment_Method_Manager__register_payment_method__begin', $payment_method_path);
164
-        $module_ext = '.pm.php';
165
-        // make all separators match
166
-        $payment_method_path = rtrim(str_replace('/\\', DS, $payment_method_path), DS);
167
-        // grab and sanitize module name
168
-        $module_dir = basename($payment_method_path);
169
-        // create class name from module directory name
170
-        $module = str_replace(array('_', ' '), array(' ', '_'), $module_dir);
171
-        // add class prefix
172
-        $module_class = 'EE_PMT_' . $module;
173
-        // does the module exist ?
174
-        if (! is_readable($payment_method_path . DS . $module_class . $module_ext)) {
175
-            $msg = sprintf(
176
-                esc_html__(
177
-                    'The requested %s payment method file could not be found or is not readable due to file permissions.',
178
-                    'event_espresso'
179
-                ), $module
180
-            );
181
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
182
-            return false;
183
-        }
184
-        // load the module class file
185
-        require_once($payment_method_path . DS . $module_class . $module_ext);
186
-        // verify that class exists
187
-        if (! class_exists($module_class)) {
188
-            $msg = sprintf(
189
-                esc_html__('The requested %s module class does not exist.', 'event_espresso'),
190
-                $module_class
191
-            );
192
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
193
-            return false;
194
-        }
195
-        // add to array of registered modules
196
-        $this->_payment_method_types[$module] = $payment_method_path . DS . $module_class . $module_ext;
197
-        return true;
198
-    }
199
-
200
-
201
-
202
-    /**
203
-     * Checks if a payment method has been registered, and if so includes it
204
-     *
205
-     * @param string  $payment_method_name like 'PayPal_Pro', (ie class name without the prefix 'EEPM_')
206
-     * @param boolean $force_recheck       whether to force re-checking for new payment method types
207
-     * @return boolean
208
-     */
209
-    public function payment_method_type_exists($payment_method_name, $force_recheck = false)
210
-    {
211
-        if (
212
-            $force_recheck
213
-            || ! is_array($this->_payment_method_types)
214
-            || ! isset($this->_payment_method_types[$payment_method_name])
215
-        ) {
216
-            $this->maybe_register_payment_methods($force_recheck);
217
-        }
218
-        if (isset($this->_payment_method_types[$payment_method_name])) {
219
-            require_once($this->_payment_method_types[$payment_method_name]);
220
-            return true;
221
-        }
222
-        return false;
223
-    }
224
-
225
-
226
-
227
-    /**
228
-     * Returns all the class names of the various payment method types
229
-     *
230
-     * @param boolean $with_prefixes TRUE: get payment method type class names; false just their 'names'
231
-     *                               (what you'd find in wp_esp_payment_method.PMD_type)
232
-     * @param boolean $force_recheck whether to force re-checking for new payment method types
233
-     * @return array
234
-     */
235
-    public function payment_method_type_names($with_prefixes = false, $force_recheck = false)
236
-    {
237
-        $this->maybe_register_payment_methods($force_recheck);
238
-        if ($with_prefixes) {
239
-            $classnames = array_keys($this->_payment_method_types);
240
-            $payment_methods = array();
241
-            foreach ($classnames as $classname) {
242
-                $payment_methods[] = $this->payment_method_class_from_type($classname);
243
-            }
244
-            return $payment_methods;
245
-        }
246
-        return array_keys($this->_payment_method_types);
247
-    }
248
-
249
-
250
-
251
-    /**
252
-     * Gets an object of each payment method type, none of which are bound to a
253
-     * payment method instance
254
-     *
255
-     * @param boolean $force_recheck whether to force re-checking for new payment method types
256
-     * @return EE_PMT_Base[]
257
-     */
258
-    public function payment_method_types($force_recheck = false)
259
-    {
260
-        if ($force_recheck || empty($this->payment_method_objects)) {
261
-            $this->maybe_register_payment_methods($force_recheck);
262
-            foreach ($this->payment_method_type_names(true) as $classname) {
263
-                if (! isset($this->payment_method_objects[$classname])) {
264
-                    $this->payment_method_objects[$classname] = new $classname;
265
-                }
266
-            }
267
-        }
268
-        return $this->payment_method_objects;
269
-    }
270
-
271
-
272
-
273
-    /**
274
-     * Changes the payment method's class name into the payment method type's name
275
-     * (as used on the payment method's table's PMD_type field)
276
-     *
277
-     * @param string $classname
278
-     * @return string
279
-     */
280
-    public function payment_method_type_sans_class_prefix($classname)
281
-    {
282
-        return str_replace('EE_PMT_', '', $classname);
283
-    }
284
-
285
-
286
-
287
-    /**
288
-     * Does the opposite of payment-method_type_sans_prefix
289
-     *
290
-     * @param string $type
291
-     * @return string
292
-     */
293
-    public function payment_method_class_from_type($type)
294
-    {
295
-        return 'EE_PMT_' . $type;
296
-    }
297
-
298
-
299
-
300
-    /**
301
-     * Activates a payment method of the given type.
302
-     *
303
-     * @param string $payment_method_type the PMT_type; for EE_PMT_Invoice this would be 'Invoice'
304
-     * @return EE_Payment_Method
305
-     * @throws InvalidDataTypeException
306
-     * @throws EE_Error
307
-     */
308
-    public function activate_a_payment_method_of_type($payment_method_type)
309
-    {
310
-        $this->maybe_register_payment_methods();
311
-        $payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type);
312
-        if (! $payment_method instanceof EE_Payment_Method) {
313
-            $pm_type_class = $this->payment_method_class_from_type($payment_method_type);
314
-            if (class_exists($pm_type_class)) {
315
-                /** @var $pm_type_obj EE_PMT_Base */
316
-                $pm_type_obj = new $pm_type_class;
317
-                $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name());
318
-                if (! $payment_method) {
319
-                    $payment_method = $this->create_payment_method_of_type($pm_type_obj);
320
-                }
321
-                $payment_method->set_type($payment_method_type);
322
-                $this->initialize_payment_method($payment_method);
323
-            } else {
324
-                throw new EE_Error(
325
-                    sprintf(
326
-                        esc_html__(
327
-                            'There is no payment method of type %1$s, so it could not be activated',
328
-                            'event_espresso'
329
-                        ),
330
-                        $pm_type_class
331
-                    )
332
-                );
333
-            }
334
-        }
335
-        $payment_method->set_active();
336
-        $payment_method->save();
337
-        if ($payment_method->type() === 'Invoice') {
338
-            /** @type EE_Message_Resource_Manager $message_resource_manager */
339
-            $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
340
-            $message_resource_manager->ensure_message_type_is_active('invoice', 'html');
341
-            $message_resource_manager->ensure_messenger_is_active('pdf');
342
-            new PersistentAdminNotice(
343
-                'invoice_pm_requirements_notice',
344
-                sprintf(
345
-                    esc_html__(
346
-                        'The Invoice payment method has been activated. It requires the invoice message type, html messenger, and pdf messenger be activated as well for the %1$smessages system%2$s, so it has been automatically verified that they are also active.',
347
-                        'event_espresso'
348
-                    ),
349
-                    '<a href="' . admin_url('admin.php?page=espresso_messages') . '">',
350
-                    '</a>'
351
-                ),
352
-                true
353
-            );
354
-        }
355
-        return $payment_method;
356
-    }
357
-
358
-
359
-
360
-    /**
361
-     * Creates a payment method of the specified type. Does not save it.
362
-     *
363
-     * @global WP_User    $current_user
364
-     * @param EE_PMT_Base $pm_type_obj
365
-     * @return EE_Payment_Method
366
-     * @throws EE_Error
367
-     */
368
-    public function create_payment_method_of_type($pm_type_obj)
369
-    {
370
-        global $current_user;
371
-        $payment_method = EE_Payment_Method::new_instance(
372
-            array(
373
-                'PMD_type'       => $pm_type_obj->system_name(),
374
-                'PMD_name'       => $pm_type_obj->pretty_name(),
375
-                'PMD_admin_name' => $pm_type_obj->pretty_name(),
376
-                'PMD_slug'       => $pm_type_obj->system_name(),//automatically converted to slug
377
-                'PMD_wp_user'    => $current_user->ID,
378
-                'PMD_order'      => EEM_Payment_Method::instance()->count(
379
-                        array(array('PMD_type' => array('!=', 'Admin_Only')))
380
-                    ) * 10,
381
-            )
382
-        );
383
-        return $payment_method;
384
-    }
385
-
386
-
387
-
388
-    /**
389
-     * Sets the initial payment method properties (including extra meta)
390
-     *
391
-     * @param EE_Payment_Method $payment_method
392
-     * @return EE_Payment_Method
393
-     * @throws EE_Error
394
-     */
395
-    public function initialize_payment_method($payment_method)
396
-    {
397
-        $pm_type_obj = $payment_method->type_obj();
398
-        $payment_method->set_description($pm_type_obj->default_description());
399
-        if (! $payment_method->button_url()) {
400
-            $payment_method->set_button_url($pm_type_obj->default_button_url());
401
-        }
402
-        //now add setup its default extra meta properties
403
-        $extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs();
404
-        if (! empty($extra_metas)) {
405
-            //verify the payment method has an ID before adding extra meta
406
-            if (! $payment_method->ID()) {
407
-                $payment_method->save();
408
-            }
409
-            foreach ($extra_metas as $meta_name => $input) {
410
-                $payment_method->update_extra_meta($meta_name, $input->raw_value());
411
-            }
412
-        }
413
-        return $payment_method;
414
-    }
415
-
416
-
417
-
418
-    /**
419
-     * Makes sure the payment method is related to the specified payment method
420
-     *
421
-     * @deprecated in 4.9.40 because the currency payment method table is being deprecated
422
-     * @param EE_Payment_Method $payment_method
423
-     * @return EE_Payment_Method
424
-     * @throws EE_Error
425
-     */
426
-    public function set_usable_currencies_on_payment_method($payment_method)
427
-    {
428
-        EE_Error::doing_it_wrong(
429
-            'EE_Payment_Method_Manager::set_usable_currencies_on_payment_method',
430
-            esc_html__(
431
-                'We no longer define what currencies are usable by payment methods. Its not used nor efficient.',
432
-                'event_espresso'
433
-            ),
434
-            '4.9.40'
435
-        );
436
-        return $payment_method;
437
-    }
438
-
439
-
440
-
441
-    /**
442
-     * Deactivates a payment method of the given payment method slug.
443
-     *
444
-     * @param string $payment_method_slug The slug for the payment method to deactivate.
445
-     * @return int count of rows updated.
446
-     * @throws EE_Error
447
-     */
448
-    public function deactivate_payment_method($payment_method_slug)
449
-    {
450
-        EE_Log::instance()->log(
451
-            __FILE__,
452
-            __FUNCTION__,
453
-            sprintf(
454
-                esc_html__(
455
-                    'Payment method with slug %1$s is being deactivated by site admin',
456
-                    'event_espresso'
457
-                ),
458
-                $payment_method_slug
459
-            ),
460
-            'payment_method_change'
461
-        );
462
-        $count_updated = EEM_Payment_Method::instance()->update(
463
-            array('PMD_scope' => array()),
464
-            array(array('PMD_slug' => $payment_method_slug))
465
-        );
466
-        return $count_updated;
467
-    }
468
-
469
-
470
-
471
-    /**
472
-     * initializes payment method access caps via EE_Capabilities::init_role_caps()
473
-     * upon EE_Payment_Method_Manager construction
474
-     *
475
-     * @throws EE_Error
476
-     * @throws DomainException
477
-     */
478
-    protected function initializePaymentMethodCaps()
479
-    {
480
-        // don't do this twice
481
-        if ($this->payment_method_caps_initialized) {
482
-            return;
483
-        }
484
-        EE_Capabilities::instance()->addCaps(
485
-            $this->getPaymentMethodCaps()
486
-        );
487
-        $this->payment_method_caps_initialized = true;
488
-    }
489
-
490
-
491
-
492
-    /**
493
-     * array  of dynamic payment method access caps.
494
-     * at the time of writing, october 20 2014, these are the caps added:
495
-     *  ee_payment_method_admin_only
496
-     *  ee_payment_method_aim
497
-     *  ee_payment_method_bank
498
-     *  ee_payment_method_check
499
-     *  ee_payment_method_invoice
500
-     *  ee_payment_method_mijireh
501
-     *  ee_payment_method_paypal_pro
502
-     *  ee_payment_method_paypal_standard
503
-     * Any other payment methods added to core or via addons will also get
504
-     * their related capability automatically added too, so long as they are
505
-     * registered properly using EE_Register_Payment_Method::register()
506
-     *
507
-     * @return array
508
-     * @throws DomainException
509
-     */
510
-    protected function getPaymentMethodCaps()
511
-    {
512
-        $caps = array();
513
-        foreach ($this->payment_method_type_names() as $payment_method_name) {
514
-            $caps = $this->addPaymentMethodCap($payment_method_name,$caps);
515
-        }
516
-        return $caps;
517
-    }
518
-
519
-
520
-
521
-    /**
522
-     * @param string $payment_method_name
523
-     * @param array  $payment_method_caps
524
-     * @param string $role
525
-     * @return array
526
-     * @throws DomainException
527
-     */
528
-    public function addPaymentMethodCap($payment_method_name, array $payment_method_caps, $role = 'administrator')
529
-    {
530
-        if (empty($payment_method_name)) {
531
-            throw new DomainException(
532
-                esc_html__(
533
-                    'The name of a payment method must be specified to add capabilities.',
534
-                    'event_espresso'
535
-                )
536
-            );
537
-        }
538
-        if (empty($role)) {
539
-            throw new DomainException(
540
-                sprintf(
541
-                    esc_html__(
542
-                        'No role was supplied while trying to add capabilities for the %1$s payment method.',
543
-                        'event_espresso'
544
-                    ),
545
-                    $payment_method_name
546
-                )
547
-            );
548
-        }
549
-        if(! isset($payment_method_caps[$role])) {
550
-            $payment_method_caps[$role] = array();
551
-        }
552
-        $payment_method_caps[$role][] = EE_Payment_Method_Manager::CAPABILITIES_PREFIX
553
-                                                  . strtolower($payment_method_name);
554
-        return $payment_method_caps;
555
-    }
556
-
557
-
558
-
559
-    /**
560
-     * callback for FHEE__EE_Capabilities__init_role_caps__caps_map filter
561
-     * to add dynamic payment method access caps when capabilities are reset
562
-     * (or if that filter is called and PM caps are not already set)
563
-     *
564
-     * @param array $caps capabilities being filtered
565
-     * @param bool  $reset
566
-     * @return array
567
-     * @throws DomainException
568
-     */
569
-    public function addPaymentMethodCapsDuringReset(array $caps, $reset = false)
570
-    {
571
-        if ($reset || ! $this->payment_method_caps_initialized) {
572
-            $this->payment_method_caps_initialized = true;
573
-            $caps = array_merge_recursive($caps, $this->getPaymentMethodCaps());
574
-        }
575
-        return $caps;
576
-    }
577
-
578
-
579
-
580
-    /**
581
-     * @deprecated 4.9.42
582
-     * @param $caps
583
-     * @return mixed
584
-     */
585
-    public function add_payment_method_caps($caps)
586
-    {
587
-        return $caps;
588
-    }
24
+	/**
25
+	 * prefix added to all payment method capabilities names
26
+	 */
27
+	const   CAPABILITIES_PREFIX= 'ee_payment_method_';
28
+
29
+	/**
30
+	 * @var EE_Payment_Method_Manager $_instance
31
+	 */
32
+	private static $_instance;
33
+
34
+	/**
35
+	 * @var boolean
36
+	 */
37
+	protected $payment_method_caps_initialized = false;
38
+
39
+	/**
40
+	 * @var array keys are class names without 'EE_PMT_', values are their filepaths
41
+	 */
42
+	protected $_payment_method_types = array();
43
+
44
+	/**
45
+	 * @var EE_PMT_Base[]
46
+	 */
47
+	protected $payment_method_objects = array();
48
+
49
+
50
+
51
+	/**
52
+	 * EE_Payment_Method_Manager constructor.
53
+	 *
54
+	 * @throws EE_Error
55
+	 * @throws DomainException
56
+	 */
57
+	public function __construct()
58
+	{
59
+		// if in admin lets ensure caps are set.
60
+		if (is_admin()) {
61
+			$this->_register_payment_methods();
62
+			// set them immediately
63
+			$this->initializePaymentMethodCaps();
64
+			// plus any time they get reset
65
+			add_filter(
66
+				'FHEE__EE_Capabilities__addCaps__capabilities_to_add',
67
+				array($this, 'addPaymentMethodCapsDuringReset')
68
+			);
69
+		}
70
+	}
71
+
72
+
73
+
74
+	/**
75
+	 * @singleton method used to instantiate class object
76
+	 * @return EE_Payment_Method_Manager instance
77
+	 * @throws DomainException
78
+	 * @throws EE_Error
79
+	 */
80
+	public static function instance()
81
+	{
82
+		// check if class object is instantiated, and instantiated properly
83
+		if (! self::$_instance instanceof EE_Payment_Method_Manager) {
84
+			EE_Registry::instance()->load_lib('PMT_Base');
85
+			self::$_instance = new self();
86
+		}
87
+		return self::$_instance;
88
+	}
89
+
90
+
91
+
92
+	/**
93
+	 * Resets the instance and returns a new one
94
+	 *
95
+	 * @return EE_Payment_Method_Manager
96
+	 * @throws DomainException
97
+	 * @throws EE_Error
98
+	 */
99
+	public static function reset()
100
+	{
101
+		self::$_instance = null;
102
+		return self::instance();
103
+	}
104
+
105
+
106
+
107
+	/**
108
+	 * If necessary, re-register payment methods
109
+	 *
110
+	 * @param boolean $force_recheck whether to recheck for payment method types,
111
+	 *                               or just re-use the PMTs we found last time we checked during this request (if
112
+	 *                               we have not yet checked during this request, then we need to check anyways)
113
+	 */
114
+	public function maybe_register_payment_methods($force_recheck = false)
115
+	{
116
+		if (! $this->_payment_method_types || $force_recheck) {
117
+			$this->_register_payment_methods();
118
+		}
119
+	}
120
+
121
+
122
+
123
+	/**
124
+	 * register_payment_methods
125
+	 *
126
+	 * @return array
127
+	 */
128
+	protected function _register_payment_methods()
129
+	{
130
+		// grab list of installed modules
131
+		$pm_to_register = glob(EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR);
132
+		// filter list of modules to register
133
+		$pm_to_register = apply_filters(
134
+			'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register',
135
+			$pm_to_register
136
+		);
137
+		// remove any duplicates if that should happen for some reason
138
+		$pm_to_register = array_unique($pm_to_register);
139
+		// loop through folders
140
+		foreach ($pm_to_register as $pm_path) {
141
+			$this->register_payment_method($pm_path);
142
+		}
143
+		do_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods');
144
+		// filter list of installed modules
145
+		//keep them organized alphabetically by the payment method type's name
146
+		ksort($this->_payment_method_types);
147
+		return apply_filters(
148
+			'FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods',
149
+			$this->_payment_method_types
150
+		);
151
+	}
152
+
153
+
154
+
155
+	/**
156
+	 * register_payment_method- makes core aware of this payment method
157
+	 *
158
+	 * @param string $payment_method_path - full path up to and including payment method folder
159
+	 * @return boolean
160
+	 */
161
+	public function register_payment_method($payment_method_path = '')
162
+	{
163
+		do_action('AHEE__EE_Payment_Method_Manager__register_payment_method__begin', $payment_method_path);
164
+		$module_ext = '.pm.php';
165
+		// make all separators match
166
+		$payment_method_path = rtrim(str_replace('/\\', DS, $payment_method_path), DS);
167
+		// grab and sanitize module name
168
+		$module_dir = basename($payment_method_path);
169
+		// create class name from module directory name
170
+		$module = str_replace(array('_', ' '), array(' ', '_'), $module_dir);
171
+		// add class prefix
172
+		$module_class = 'EE_PMT_' . $module;
173
+		// does the module exist ?
174
+		if (! is_readable($payment_method_path . DS . $module_class . $module_ext)) {
175
+			$msg = sprintf(
176
+				esc_html__(
177
+					'The requested %s payment method file could not be found or is not readable due to file permissions.',
178
+					'event_espresso'
179
+				), $module
180
+			);
181
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
182
+			return false;
183
+		}
184
+		// load the module class file
185
+		require_once($payment_method_path . DS . $module_class . $module_ext);
186
+		// verify that class exists
187
+		if (! class_exists($module_class)) {
188
+			$msg = sprintf(
189
+				esc_html__('The requested %s module class does not exist.', 'event_espresso'),
190
+				$module_class
191
+			);
192
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
193
+			return false;
194
+		}
195
+		// add to array of registered modules
196
+		$this->_payment_method_types[$module] = $payment_method_path . DS . $module_class . $module_ext;
197
+		return true;
198
+	}
199
+
200
+
201
+
202
+	/**
203
+	 * Checks if a payment method has been registered, and if so includes it
204
+	 *
205
+	 * @param string  $payment_method_name like 'PayPal_Pro', (ie class name without the prefix 'EEPM_')
206
+	 * @param boolean $force_recheck       whether to force re-checking for new payment method types
207
+	 * @return boolean
208
+	 */
209
+	public function payment_method_type_exists($payment_method_name, $force_recheck = false)
210
+	{
211
+		if (
212
+			$force_recheck
213
+			|| ! is_array($this->_payment_method_types)
214
+			|| ! isset($this->_payment_method_types[$payment_method_name])
215
+		) {
216
+			$this->maybe_register_payment_methods($force_recheck);
217
+		}
218
+		if (isset($this->_payment_method_types[$payment_method_name])) {
219
+			require_once($this->_payment_method_types[$payment_method_name]);
220
+			return true;
221
+		}
222
+		return false;
223
+	}
224
+
225
+
226
+
227
+	/**
228
+	 * Returns all the class names of the various payment method types
229
+	 *
230
+	 * @param boolean $with_prefixes TRUE: get payment method type class names; false just their 'names'
231
+	 *                               (what you'd find in wp_esp_payment_method.PMD_type)
232
+	 * @param boolean $force_recheck whether to force re-checking for new payment method types
233
+	 * @return array
234
+	 */
235
+	public function payment_method_type_names($with_prefixes = false, $force_recheck = false)
236
+	{
237
+		$this->maybe_register_payment_methods($force_recheck);
238
+		if ($with_prefixes) {
239
+			$classnames = array_keys($this->_payment_method_types);
240
+			$payment_methods = array();
241
+			foreach ($classnames as $classname) {
242
+				$payment_methods[] = $this->payment_method_class_from_type($classname);
243
+			}
244
+			return $payment_methods;
245
+		}
246
+		return array_keys($this->_payment_method_types);
247
+	}
248
+
249
+
250
+
251
+	/**
252
+	 * Gets an object of each payment method type, none of which are bound to a
253
+	 * payment method instance
254
+	 *
255
+	 * @param boolean $force_recheck whether to force re-checking for new payment method types
256
+	 * @return EE_PMT_Base[]
257
+	 */
258
+	public function payment_method_types($force_recheck = false)
259
+	{
260
+		if ($force_recheck || empty($this->payment_method_objects)) {
261
+			$this->maybe_register_payment_methods($force_recheck);
262
+			foreach ($this->payment_method_type_names(true) as $classname) {
263
+				if (! isset($this->payment_method_objects[$classname])) {
264
+					$this->payment_method_objects[$classname] = new $classname;
265
+				}
266
+			}
267
+		}
268
+		return $this->payment_method_objects;
269
+	}
270
+
271
+
272
+
273
+	/**
274
+	 * Changes the payment method's class name into the payment method type's name
275
+	 * (as used on the payment method's table's PMD_type field)
276
+	 *
277
+	 * @param string $classname
278
+	 * @return string
279
+	 */
280
+	public function payment_method_type_sans_class_prefix($classname)
281
+	{
282
+		return str_replace('EE_PMT_', '', $classname);
283
+	}
284
+
285
+
286
+
287
+	/**
288
+	 * Does the opposite of payment-method_type_sans_prefix
289
+	 *
290
+	 * @param string $type
291
+	 * @return string
292
+	 */
293
+	public function payment_method_class_from_type($type)
294
+	{
295
+		return 'EE_PMT_' . $type;
296
+	}
297
+
298
+
299
+
300
+	/**
301
+	 * Activates a payment method of the given type.
302
+	 *
303
+	 * @param string $payment_method_type the PMT_type; for EE_PMT_Invoice this would be 'Invoice'
304
+	 * @return EE_Payment_Method
305
+	 * @throws InvalidDataTypeException
306
+	 * @throws EE_Error
307
+	 */
308
+	public function activate_a_payment_method_of_type($payment_method_type)
309
+	{
310
+		$this->maybe_register_payment_methods();
311
+		$payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type);
312
+		if (! $payment_method instanceof EE_Payment_Method) {
313
+			$pm_type_class = $this->payment_method_class_from_type($payment_method_type);
314
+			if (class_exists($pm_type_class)) {
315
+				/** @var $pm_type_obj EE_PMT_Base */
316
+				$pm_type_obj = new $pm_type_class;
317
+				$payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name());
318
+				if (! $payment_method) {
319
+					$payment_method = $this->create_payment_method_of_type($pm_type_obj);
320
+				}
321
+				$payment_method->set_type($payment_method_type);
322
+				$this->initialize_payment_method($payment_method);
323
+			} else {
324
+				throw new EE_Error(
325
+					sprintf(
326
+						esc_html__(
327
+							'There is no payment method of type %1$s, so it could not be activated',
328
+							'event_espresso'
329
+						),
330
+						$pm_type_class
331
+					)
332
+				);
333
+			}
334
+		}
335
+		$payment_method->set_active();
336
+		$payment_method->save();
337
+		if ($payment_method->type() === 'Invoice') {
338
+			/** @type EE_Message_Resource_Manager $message_resource_manager */
339
+			$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
340
+			$message_resource_manager->ensure_message_type_is_active('invoice', 'html');
341
+			$message_resource_manager->ensure_messenger_is_active('pdf');
342
+			new PersistentAdminNotice(
343
+				'invoice_pm_requirements_notice',
344
+				sprintf(
345
+					esc_html__(
346
+						'The Invoice payment method has been activated. It requires the invoice message type, html messenger, and pdf messenger be activated as well for the %1$smessages system%2$s, so it has been automatically verified that they are also active.',
347
+						'event_espresso'
348
+					),
349
+					'<a href="' . admin_url('admin.php?page=espresso_messages') . '">',
350
+					'</a>'
351
+				),
352
+				true
353
+			);
354
+		}
355
+		return $payment_method;
356
+	}
357
+
358
+
359
+
360
+	/**
361
+	 * Creates a payment method of the specified type. Does not save it.
362
+	 *
363
+	 * @global WP_User    $current_user
364
+	 * @param EE_PMT_Base $pm_type_obj
365
+	 * @return EE_Payment_Method
366
+	 * @throws EE_Error
367
+	 */
368
+	public function create_payment_method_of_type($pm_type_obj)
369
+	{
370
+		global $current_user;
371
+		$payment_method = EE_Payment_Method::new_instance(
372
+			array(
373
+				'PMD_type'       => $pm_type_obj->system_name(),
374
+				'PMD_name'       => $pm_type_obj->pretty_name(),
375
+				'PMD_admin_name' => $pm_type_obj->pretty_name(),
376
+				'PMD_slug'       => $pm_type_obj->system_name(),//automatically converted to slug
377
+				'PMD_wp_user'    => $current_user->ID,
378
+				'PMD_order'      => EEM_Payment_Method::instance()->count(
379
+						array(array('PMD_type' => array('!=', 'Admin_Only')))
380
+					) * 10,
381
+			)
382
+		);
383
+		return $payment_method;
384
+	}
385
+
386
+
387
+
388
+	/**
389
+	 * Sets the initial payment method properties (including extra meta)
390
+	 *
391
+	 * @param EE_Payment_Method $payment_method
392
+	 * @return EE_Payment_Method
393
+	 * @throws EE_Error
394
+	 */
395
+	public function initialize_payment_method($payment_method)
396
+	{
397
+		$pm_type_obj = $payment_method->type_obj();
398
+		$payment_method->set_description($pm_type_obj->default_description());
399
+		if (! $payment_method->button_url()) {
400
+			$payment_method->set_button_url($pm_type_obj->default_button_url());
401
+		}
402
+		//now add setup its default extra meta properties
403
+		$extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs();
404
+		if (! empty($extra_metas)) {
405
+			//verify the payment method has an ID before adding extra meta
406
+			if (! $payment_method->ID()) {
407
+				$payment_method->save();
408
+			}
409
+			foreach ($extra_metas as $meta_name => $input) {
410
+				$payment_method->update_extra_meta($meta_name, $input->raw_value());
411
+			}
412
+		}
413
+		return $payment_method;
414
+	}
415
+
416
+
417
+
418
+	/**
419
+	 * Makes sure the payment method is related to the specified payment method
420
+	 *
421
+	 * @deprecated in 4.9.40 because the currency payment method table is being deprecated
422
+	 * @param EE_Payment_Method $payment_method
423
+	 * @return EE_Payment_Method
424
+	 * @throws EE_Error
425
+	 */
426
+	public function set_usable_currencies_on_payment_method($payment_method)
427
+	{
428
+		EE_Error::doing_it_wrong(
429
+			'EE_Payment_Method_Manager::set_usable_currencies_on_payment_method',
430
+			esc_html__(
431
+				'We no longer define what currencies are usable by payment methods. Its not used nor efficient.',
432
+				'event_espresso'
433
+			),
434
+			'4.9.40'
435
+		);
436
+		return $payment_method;
437
+	}
438
+
439
+
440
+
441
+	/**
442
+	 * Deactivates a payment method of the given payment method slug.
443
+	 *
444
+	 * @param string $payment_method_slug The slug for the payment method to deactivate.
445
+	 * @return int count of rows updated.
446
+	 * @throws EE_Error
447
+	 */
448
+	public function deactivate_payment_method($payment_method_slug)
449
+	{
450
+		EE_Log::instance()->log(
451
+			__FILE__,
452
+			__FUNCTION__,
453
+			sprintf(
454
+				esc_html__(
455
+					'Payment method with slug %1$s is being deactivated by site admin',
456
+					'event_espresso'
457
+				),
458
+				$payment_method_slug
459
+			),
460
+			'payment_method_change'
461
+		);
462
+		$count_updated = EEM_Payment_Method::instance()->update(
463
+			array('PMD_scope' => array()),
464
+			array(array('PMD_slug' => $payment_method_slug))
465
+		);
466
+		return $count_updated;
467
+	}
468
+
469
+
470
+
471
+	/**
472
+	 * initializes payment method access caps via EE_Capabilities::init_role_caps()
473
+	 * upon EE_Payment_Method_Manager construction
474
+	 *
475
+	 * @throws EE_Error
476
+	 * @throws DomainException
477
+	 */
478
+	protected function initializePaymentMethodCaps()
479
+	{
480
+		// don't do this twice
481
+		if ($this->payment_method_caps_initialized) {
482
+			return;
483
+		}
484
+		EE_Capabilities::instance()->addCaps(
485
+			$this->getPaymentMethodCaps()
486
+		);
487
+		$this->payment_method_caps_initialized = true;
488
+	}
489
+
490
+
491
+
492
+	/**
493
+	 * array  of dynamic payment method access caps.
494
+	 * at the time of writing, october 20 2014, these are the caps added:
495
+	 *  ee_payment_method_admin_only
496
+	 *  ee_payment_method_aim
497
+	 *  ee_payment_method_bank
498
+	 *  ee_payment_method_check
499
+	 *  ee_payment_method_invoice
500
+	 *  ee_payment_method_mijireh
501
+	 *  ee_payment_method_paypal_pro
502
+	 *  ee_payment_method_paypal_standard
503
+	 * Any other payment methods added to core or via addons will also get
504
+	 * their related capability automatically added too, so long as they are
505
+	 * registered properly using EE_Register_Payment_Method::register()
506
+	 *
507
+	 * @return array
508
+	 * @throws DomainException
509
+	 */
510
+	protected function getPaymentMethodCaps()
511
+	{
512
+		$caps = array();
513
+		foreach ($this->payment_method_type_names() as $payment_method_name) {
514
+			$caps = $this->addPaymentMethodCap($payment_method_name,$caps);
515
+		}
516
+		return $caps;
517
+	}
518
+
519
+
520
+
521
+	/**
522
+	 * @param string $payment_method_name
523
+	 * @param array  $payment_method_caps
524
+	 * @param string $role
525
+	 * @return array
526
+	 * @throws DomainException
527
+	 */
528
+	public function addPaymentMethodCap($payment_method_name, array $payment_method_caps, $role = 'administrator')
529
+	{
530
+		if (empty($payment_method_name)) {
531
+			throw new DomainException(
532
+				esc_html__(
533
+					'The name of a payment method must be specified to add capabilities.',
534
+					'event_espresso'
535
+				)
536
+			);
537
+		}
538
+		if (empty($role)) {
539
+			throw new DomainException(
540
+				sprintf(
541
+					esc_html__(
542
+						'No role was supplied while trying to add capabilities for the %1$s payment method.',
543
+						'event_espresso'
544
+					),
545
+					$payment_method_name
546
+				)
547
+			);
548
+		}
549
+		if(! isset($payment_method_caps[$role])) {
550
+			$payment_method_caps[$role] = array();
551
+		}
552
+		$payment_method_caps[$role][] = EE_Payment_Method_Manager::CAPABILITIES_PREFIX
553
+												  . strtolower($payment_method_name);
554
+		return $payment_method_caps;
555
+	}
556
+
557
+
558
+
559
+	/**
560
+	 * callback for FHEE__EE_Capabilities__init_role_caps__caps_map filter
561
+	 * to add dynamic payment method access caps when capabilities are reset
562
+	 * (or if that filter is called and PM caps are not already set)
563
+	 *
564
+	 * @param array $caps capabilities being filtered
565
+	 * @param bool  $reset
566
+	 * @return array
567
+	 * @throws DomainException
568
+	 */
569
+	public function addPaymentMethodCapsDuringReset(array $caps, $reset = false)
570
+	{
571
+		if ($reset || ! $this->payment_method_caps_initialized) {
572
+			$this->payment_method_caps_initialized = true;
573
+			$caps = array_merge_recursive($caps, $this->getPaymentMethodCaps());
574
+		}
575
+		return $caps;
576
+	}
577
+
578
+
579
+
580
+	/**
581
+	 * @deprecated 4.9.42
582
+	 * @param $caps
583
+	 * @return mixed
584
+	 */
585
+	public function add_payment_method_caps($caps)
586
+	{
587
+		return $caps;
588
+	}
589 589
 
590 590
 
591 591
 
Please login to merge, or discard this patch.