Completed
Branch models-cleanup/main (de94a1)
by
unknown
86:45 queued 77:08
created
core/db_models/EEM_Country.model.php 2 patches
Indentation   +200 added lines, -200 removed lines patch added patch discarded remove patch
@@ -10,204 +10,204 @@
 block discarded – undo
10 10
 class EEM_Country extends EEM_Base
11 11
 {
12 12
 
13
-    // private instance of the Attendee object
14
-    protected static $_instance;
15
-
16
-    // array of all countries
17
-    private static $_all_countries = false;
18
-
19
-    // array of all active countries
20
-    private static $_active_countries = false;
21
-
22
-
23
-    /**
24
-     * Resets the country
25
-     *
26
-     * @param string $timezone
27
-     * @return EEM_Country
28
-     * @throws EE_Error
29
-     * @throws ReflectionException
30
-     */
31
-    public static function reset($timezone = ''): EEM_Country
32
-    {
33
-        self::$_active_countries = null;
34
-        self::$_all_countries    = null;
35
-        return parent::reset($timezone);
36
-    }
37
-
38
-
39
-    /**
40
-     * EEM_Country constructor.
41
-     *
42
-     * @param string $timezone
43
-     * @throws EE_Error
44
-     */
45
-    protected function __construct(string $timezone = '')
46
-    {
47
-        $this->singular_item = esc_html__('Country', 'event_espresso');
48
-        $this->plural_item   = esc_html__('Countries', 'event_espresso');
49
-
50
-        $this->_tables = [
51
-            'Country' => new EE_Primary_Table('esp_country', 'CNT_ISO'),
52
-        ];
53
-
54
-        $this->_fields          = [
55
-            'Country' => [
56
-                'CNT_active'      => new EE_Boolean_Field(
57
-                    'CNT_active',
58
-                    esc_html__(
59
-                        'Country Appears in Dropdown Select Lists',
60
-                        'event_espresso'
61
-                    ),
62
-                    false,
63
-                    true
64
-                ),
65
-                'CNT_ISO'         => new EE_Primary_Key_String_Field(
66
-                    'CNT_ISO',
67
-                    esc_html__('Country ISO Code', 'event_espresso')
68
-                ),
69
-                'CNT_ISO3'        => new EE_All_Caps_Text_Field(
70
-                    'CNT_ISO3',
71
-                    esc_html__('Country ISO3 Code', 'event_espresso'),
72
-                    false,
73
-                    ''
74
-                ),
75
-                'RGN_ID'          => new EE_Integer_Field(
76
-                    'RGN_ID',
77
-                    esc_html__('Region ID', 'event_espresso'),
78
-                    false,
79
-                    0
80
-                ),
81
-                // should be a foreign key, but no region table exists yet
82
-                'CNT_name'        => new EE_Plain_Text_Field(
83
-                    'CNT_name',
84
-                    esc_html__('Country Name', 'event_espresso'),
85
-                    false,
86
-                    ''
87
-                ),
88
-                'CNT_cur_code'    => new EE_All_Caps_Text_Field(
89
-                    'CNT_cur_code',
90
-                    esc_html__('Country Currency Code', 'event_espresso'),
91
-                    false
92
-                ),
93
-                'CNT_cur_single'  => new EE_Plain_Text_Field(
94
-                    'CNT_cur_single',
95
-                    esc_html__('Currency Name Singular', 'event_espresso'),
96
-                    false
97
-                ),
98
-                'CNT_cur_plural'  => new EE_Plain_Text_Field(
99
-                    'CNT_cur_plural',
100
-                    esc_html__('Currency Name Plural', 'event_espresso'),
101
-                    false
102
-                ),
103
-                'CNT_cur_sign'    => new EE_Plain_Text_Field(
104
-                    'CNT_cur_sign',
105
-                    esc_html__('Currency Sign', 'event_espresso'),
106
-                    false
107
-                ),
108
-                'CNT_cur_sign_b4' => new EE_Boolean_Field(
109
-                    'CNT_cur_sign_b4',
110
-                    esc_html__('Currency Sign Before Number', 'event_espresso'),
111
-                    false,
112
-                    true
113
-                ),
114
-                'CNT_cur_dec_plc' => new EE_Integer_Field(
115
-                    'CNT_cur_dec_plc',
116
-                    esc_html__('Currency Decimal Places', 'event_espresso'),
117
-                    false,
118
-                    2
119
-                ),
120
-                'CNT_cur_dec_mrk' => new EE_Plain_Text_Field(
121
-                    'CNT_cur_dec_mrk',
122
-                    esc_html__('Currency Decimal Mark', 'event_espresso'),
123
-                    false,
124
-                    '.'
125
-                ),
126
-                'CNT_cur_thsnds'  => new EE_Plain_Text_Field(
127
-                    'CNT_cur_thsnds',
128
-                    esc_html__('Currency Thousands Separator', 'event_espresso'),
129
-                    false,
130
-                    ','
131
-                ),
132
-                'CNT_tel_code'    => new EE_Plain_Text_Field(
133
-                    'CNT_tel_code',
134
-                    esc_html__('Country Telephone Code', 'event_espresso'),
135
-                    false,
136
-                    ''
137
-                ),
138
-                'CNT_is_EU'       => new EE_Boolean_Field(
139
-                    'CNT_is_EU',
140
-                    esc_html__('Country is Member of EU', 'event_espresso'),
141
-                    false,
142
-                    false
143
-                ),
144
-            ],
145
-        ];
146
-        $this->_model_relations = [
147
-            'Attendee' => new EE_Has_Many_Relation(),
148
-            'State'    => new EE_Has_Many_Relation(),
149
-            'Venue'    => new EE_Has_Many_Relation(),
150
-        ];
151
-        // only anyone to view, but only those with the default role can do anything
152
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
153
-
154
-        parent::__construct($timezone);
155
-    }
156
-
157
-
158
-    /**
159
-     * @return array
160
-     * @throws EE_Error
161
-     * @throws ReflectionException
162
-     */
163
-    public function get_all_countries()
164
-    {
165
-        if (! self::$_all_countries) {
166
-            self::$_all_countries = $this->get_all(['order_by' => ['CNT_name' => 'ASC'], 'limit' => [0, 99999]]);
167
-        }
168
-        return self::$_all_countries;
169
-    }
170
-
171
-
172
-    /**
173
-     * _get_countries
174
-     * Gets and caches the list of active countries. If you know the list of active countries
175
-     * has changed during this request, first use EEM_Country::reset() to flush the cache
176
-     *
177
-     * @return array
178
-     * @throws EE_Error
179
-     * @throws ReflectionException
180
-     */
181
-    public function get_all_active_countries()
182
-    {
183
-        if (! self::$_active_countries) {
184
-            self::$_active_countries =
185
-                $this->get_all([['CNT_active' => true], 'order_by' => ['CNT_name' => 'ASC'], 'limit' => [0, 99999]]);
186
-        }
187
-        return self::$_active_countries;
188
-    }
189
-
190
-
191
-    /**
192
-     * Gets the country's name by its ISO
193
-     *
194
-     * @param string $country_ISO
195
-     * @return string
196
-     * @throws EE_Error
197
-     * @throws ReflectionException
198
-     */
199
-    public function get_country_name_by_ISO($country_ISO)
200
-    {
201
-        if (
202
-            isset(self::$_all_countries[ $country_ISO ])
203
-            && self::$_all_countries[ $country_ISO ] instanceof EE_Country
204
-        ) {
205
-            return self::$_all_countries[ $country_ISO ]->name();
206
-        }
207
-        $names = $this->get_col([['CNT_ISO' => $country_ISO], 'limit' => 1], 'CNT_name');
208
-        if (is_array($names) && ! empty($names)) {
209
-            return reset($names);
210
-        }
211
-        return '';
212
-    }
13
+	// private instance of the Attendee object
14
+	protected static $_instance;
15
+
16
+	// array of all countries
17
+	private static $_all_countries = false;
18
+
19
+	// array of all active countries
20
+	private static $_active_countries = false;
21
+
22
+
23
+	/**
24
+	 * Resets the country
25
+	 *
26
+	 * @param string $timezone
27
+	 * @return EEM_Country
28
+	 * @throws EE_Error
29
+	 * @throws ReflectionException
30
+	 */
31
+	public static function reset($timezone = ''): EEM_Country
32
+	{
33
+		self::$_active_countries = null;
34
+		self::$_all_countries    = null;
35
+		return parent::reset($timezone);
36
+	}
37
+
38
+
39
+	/**
40
+	 * EEM_Country constructor.
41
+	 *
42
+	 * @param string $timezone
43
+	 * @throws EE_Error
44
+	 */
45
+	protected function __construct(string $timezone = '')
46
+	{
47
+		$this->singular_item = esc_html__('Country', 'event_espresso');
48
+		$this->plural_item   = esc_html__('Countries', 'event_espresso');
49
+
50
+		$this->_tables = [
51
+			'Country' => new EE_Primary_Table('esp_country', 'CNT_ISO'),
52
+		];
53
+
54
+		$this->_fields          = [
55
+			'Country' => [
56
+				'CNT_active'      => new EE_Boolean_Field(
57
+					'CNT_active',
58
+					esc_html__(
59
+						'Country Appears in Dropdown Select Lists',
60
+						'event_espresso'
61
+					),
62
+					false,
63
+					true
64
+				),
65
+				'CNT_ISO'         => new EE_Primary_Key_String_Field(
66
+					'CNT_ISO',
67
+					esc_html__('Country ISO Code', 'event_espresso')
68
+				),
69
+				'CNT_ISO3'        => new EE_All_Caps_Text_Field(
70
+					'CNT_ISO3',
71
+					esc_html__('Country ISO3 Code', 'event_espresso'),
72
+					false,
73
+					''
74
+				),
75
+				'RGN_ID'          => new EE_Integer_Field(
76
+					'RGN_ID',
77
+					esc_html__('Region ID', 'event_espresso'),
78
+					false,
79
+					0
80
+				),
81
+				// should be a foreign key, but no region table exists yet
82
+				'CNT_name'        => new EE_Plain_Text_Field(
83
+					'CNT_name',
84
+					esc_html__('Country Name', 'event_espresso'),
85
+					false,
86
+					''
87
+				),
88
+				'CNT_cur_code'    => new EE_All_Caps_Text_Field(
89
+					'CNT_cur_code',
90
+					esc_html__('Country Currency Code', 'event_espresso'),
91
+					false
92
+				),
93
+				'CNT_cur_single'  => new EE_Plain_Text_Field(
94
+					'CNT_cur_single',
95
+					esc_html__('Currency Name Singular', 'event_espresso'),
96
+					false
97
+				),
98
+				'CNT_cur_plural'  => new EE_Plain_Text_Field(
99
+					'CNT_cur_plural',
100
+					esc_html__('Currency Name Plural', 'event_espresso'),
101
+					false
102
+				),
103
+				'CNT_cur_sign'    => new EE_Plain_Text_Field(
104
+					'CNT_cur_sign',
105
+					esc_html__('Currency Sign', 'event_espresso'),
106
+					false
107
+				),
108
+				'CNT_cur_sign_b4' => new EE_Boolean_Field(
109
+					'CNT_cur_sign_b4',
110
+					esc_html__('Currency Sign Before Number', 'event_espresso'),
111
+					false,
112
+					true
113
+				),
114
+				'CNT_cur_dec_plc' => new EE_Integer_Field(
115
+					'CNT_cur_dec_plc',
116
+					esc_html__('Currency Decimal Places', 'event_espresso'),
117
+					false,
118
+					2
119
+				),
120
+				'CNT_cur_dec_mrk' => new EE_Plain_Text_Field(
121
+					'CNT_cur_dec_mrk',
122
+					esc_html__('Currency Decimal Mark', 'event_espresso'),
123
+					false,
124
+					'.'
125
+				),
126
+				'CNT_cur_thsnds'  => new EE_Plain_Text_Field(
127
+					'CNT_cur_thsnds',
128
+					esc_html__('Currency Thousands Separator', 'event_espresso'),
129
+					false,
130
+					','
131
+				),
132
+				'CNT_tel_code'    => new EE_Plain_Text_Field(
133
+					'CNT_tel_code',
134
+					esc_html__('Country Telephone Code', 'event_espresso'),
135
+					false,
136
+					''
137
+				),
138
+				'CNT_is_EU'       => new EE_Boolean_Field(
139
+					'CNT_is_EU',
140
+					esc_html__('Country is Member of EU', 'event_espresso'),
141
+					false,
142
+					false
143
+				),
144
+			],
145
+		];
146
+		$this->_model_relations = [
147
+			'Attendee' => new EE_Has_Many_Relation(),
148
+			'State'    => new EE_Has_Many_Relation(),
149
+			'Venue'    => new EE_Has_Many_Relation(),
150
+		];
151
+		// only anyone to view, but only those with the default role can do anything
152
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
153
+
154
+		parent::__construct($timezone);
155
+	}
156
+
157
+
158
+	/**
159
+	 * @return array
160
+	 * @throws EE_Error
161
+	 * @throws ReflectionException
162
+	 */
163
+	public function get_all_countries()
164
+	{
165
+		if (! self::$_all_countries) {
166
+			self::$_all_countries = $this->get_all(['order_by' => ['CNT_name' => 'ASC'], 'limit' => [0, 99999]]);
167
+		}
168
+		return self::$_all_countries;
169
+	}
170
+
171
+
172
+	/**
173
+	 * _get_countries
174
+	 * Gets and caches the list of active countries. If you know the list of active countries
175
+	 * has changed during this request, first use EEM_Country::reset() to flush the cache
176
+	 *
177
+	 * @return array
178
+	 * @throws EE_Error
179
+	 * @throws ReflectionException
180
+	 */
181
+	public function get_all_active_countries()
182
+	{
183
+		if (! self::$_active_countries) {
184
+			self::$_active_countries =
185
+				$this->get_all([['CNT_active' => true], 'order_by' => ['CNT_name' => 'ASC'], 'limit' => [0, 99999]]);
186
+		}
187
+		return self::$_active_countries;
188
+	}
189
+
190
+
191
+	/**
192
+	 * Gets the country's name by its ISO
193
+	 *
194
+	 * @param string $country_ISO
195
+	 * @return string
196
+	 * @throws EE_Error
197
+	 * @throws ReflectionException
198
+	 */
199
+	public function get_country_name_by_ISO($country_ISO)
200
+	{
201
+		if (
202
+			isset(self::$_all_countries[ $country_ISO ])
203
+			&& self::$_all_countries[ $country_ISO ] instanceof EE_Country
204
+		) {
205
+			return self::$_all_countries[ $country_ISO ]->name();
206
+		}
207
+		$names = $this->get_col([['CNT_ISO' => $country_ISO], 'limit' => 1], 'CNT_name');
208
+		if (is_array($names) && ! empty($names)) {
209
+			return reset($names);
210
+		}
211
+		return '';
212
+	}
213 213
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
             'Country' => new EE_Primary_Table('esp_country', 'CNT_ISO'),
52 52
         ];
53 53
 
54
-        $this->_fields          = [
54
+        $this->_fields = [
55 55
             'Country' => [
56 56
                 'CNT_active'      => new EE_Boolean_Field(
57 57
                     'CNT_active',
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
             'Venue'    => new EE_Has_Many_Relation(),
150 150
         ];
151 151
         // only anyone to view, but only those with the default role can do anything
152
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
152
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
153 153
 
154 154
         parent::__construct($timezone);
155 155
     }
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
      */
163 163
     public function get_all_countries()
164 164
     {
165
-        if (! self::$_all_countries) {
165
+        if ( ! self::$_all_countries) {
166 166
             self::$_all_countries = $this->get_all(['order_by' => ['CNT_name' => 'ASC'], 'limit' => [0, 99999]]);
167 167
         }
168 168
         return self::$_all_countries;
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
      */
181 181
     public function get_all_active_countries()
182 182
     {
183
-        if (! self::$_active_countries) {
183
+        if ( ! self::$_active_countries) {
184 184
             self::$_active_countries =
185 185
                 $this->get_all([['CNT_active' => true], 'order_by' => ['CNT_name' => 'ASC'], 'limit' => [0, 99999]]);
186 186
         }
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
     public function get_country_name_by_ISO($country_ISO)
200 200
     {
201 201
         if (
202
-            isset(self::$_all_countries[ $country_ISO ])
203
-            && self::$_all_countries[ $country_ISO ] instanceof EE_Country
202
+            isset(self::$_all_countries[$country_ISO])
203
+            && self::$_all_countries[$country_ISO] instanceof EE_Country
204 204
         ) {
205
-            return self::$_all_countries[ $country_ISO ]->name();
205
+            return self::$_all_countries[$country_ISO]->name();
206 206
         }
207 207
         $names = $this->get_col([['CNT_ISO' => $country_ISO], 'limit' => 1], 'CNT_name');
208 208
         if (is_array($names) && ! empty($names)) {
Please login to merge, or discard this patch.
core/db_models/EEM_Term.model.php 2 patches
Indentation   +270 added lines, -270 removed lines patch added patch discarded remove patch
@@ -13,290 +13,290 @@
 block discarded – undo
13 13
 class EEM_Term extends EEM_Base
14 14
 {
15 15
 
16
-    /**
17
-     * @var EEM_Term
18
-     */
19
-    protected static $_instance;
16
+	/**
17
+	 * @var EEM_Term
18
+	 */
19
+	protected static $_instance;
20 20
 
21 21
 
22
-    /**
23
-     * @param string $timezone
24
-     * @throws EE_Error
25
-     */
26
-    protected function __construct(string $timezone = '')
27
-    {
28
-        $this->singular_item                                        = esc_html__('Term', 'event_espresso');
29
-        $this->plural_item                                          = esc_html__('Terms', 'event_espresso');
30
-        $this->_tables                                              = [
31
-            'Term' => new EE_Primary_Table('terms', 'term_id'),
32
-        ];
33
-        $this->_fields                                              = [
34
-            'Term' => [
35
-                'term_id'    => new EE_Primary_Key_Int_Field(
36
-                    'term_id',
37
-                    esc_html__('Term ID', 'event_espresso')
38
-                ),
39
-                'name'       => new EE_Plain_Text_Field(
40
-                    'name',
41
-                    esc_html__('Term Name', 'event_espresso'),
42
-                    false,
43
-                    ''
44
-                ),
45
-                'slug'       => new EE_Slug_Field(
46
-                    'slug',
47
-                    esc_html__('Term Slug', 'event_espresso'),
48
-                    false
49
-                ),
50
-                'term_group' => new EE_Integer_Field(
51
-                    'term_group',
52
-                    esc_html__("Term Group", "event_espresso"),
53
-                    false,
54
-                    0
55
-                ),
56
-            ],
57
-        ];
58
-        $this->_model_relations                                     = [
59
-            'Term_Taxonomy' => new EE_Has_Many_Relation(),
60
-        ];
61
-        $this->_wp_core_model                                       = true;
62
-        $path_to_tax_model                                          = 'Term_Taxonomy';
63
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ]   = new EE_Restriction_Generator_Public();
64
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ]
65
-                                                                    = new EE_Restriction_Generator_Taxonomy_Protected(
66
-            $path_to_tax_model
67
-        );
68
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ]   = false;
69
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false;
70
-        $path_to_tax_model                                          = $path_to_tax_model . '.';
71
-        // add cap restrictions for editing relating to the "ee_edit_*"
72
-        $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions(
73
-            [
74
-                $path_to_tax_model . 'taxonomy*ee_edit_event_category' => ['!=', 'espresso_event_categories'],
75
-            ]
76
-        );
77
-        $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions(
78
-            [
79
-                $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => ['!=', 'espresso_venue_categories'],
80
-            ]
81
-        );
82
-        $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type']     = new EE_Default_Where_Conditions(
83
-            [
84
-                $path_to_tax_model . 'taxonomy*ee_edit_event_type' => ['!=', 'espresso_event_type'],
85
-            ]
86
-        );
87
-        // add cap restrictions for deleting relating to the "ee_deleting_*"
88
-        $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions(
89
-            [
90
-                $path_to_tax_model . 'taxonomy*ee_delete_event_category' => ['!=', 'espresso_event_categories'],
91
-            ]
92
-        );
93
-        $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions(
94
-            [
95
-                $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => ['!=', 'espresso_venue_categories'],
96
-            ]
97
-        );
98
-        $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type']     = new EE_Default_Where_Conditions(
99
-            [
100
-                $path_to_tax_model . 'taxonomy*ee_delete_event_type' => ['!=', 'espresso_event_type'],
101
-            ]
102
-        );
103
-        parent::__construct($timezone);
104
-        add_filter('FHEE__Read__create_model_query_params', ['EEM_Term', 'rest_api_query_params'], 10, 3);
105
-    }
22
+	/**
23
+	 * @param string $timezone
24
+	 * @throws EE_Error
25
+	 */
26
+	protected function __construct(string $timezone = '')
27
+	{
28
+		$this->singular_item                                        = esc_html__('Term', 'event_espresso');
29
+		$this->plural_item                                          = esc_html__('Terms', 'event_espresso');
30
+		$this->_tables                                              = [
31
+			'Term' => new EE_Primary_Table('terms', 'term_id'),
32
+		];
33
+		$this->_fields                                              = [
34
+			'Term' => [
35
+				'term_id'    => new EE_Primary_Key_Int_Field(
36
+					'term_id',
37
+					esc_html__('Term ID', 'event_espresso')
38
+				),
39
+				'name'       => new EE_Plain_Text_Field(
40
+					'name',
41
+					esc_html__('Term Name', 'event_espresso'),
42
+					false,
43
+					''
44
+				),
45
+				'slug'       => new EE_Slug_Field(
46
+					'slug',
47
+					esc_html__('Term Slug', 'event_espresso'),
48
+					false
49
+				),
50
+				'term_group' => new EE_Integer_Field(
51
+					'term_group',
52
+					esc_html__("Term Group", "event_espresso"),
53
+					false,
54
+					0
55
+				),
56
+			],
57
+		];
58
+		$this->_model_relations                                     = [
59
+			'Term_Taxonomy' => new EE_Has_Many_Relation(),
60
+		];
61
+		$this->_wp_core_model                                       = true;
62
+		$path_to_tax_model                                          = 'Term_Taxonomy';
63
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ]   = new EE_Restriction_Generator_Public();
64
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ]
65
+																	= new EE_Restriction_Generator_Taxonomy_Protected(
66
+			$path_to_tax_model
67
+		);
68
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ]   = false;
69
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false;
70
+		$path_to_tax_model                                          = $path_to_tax_model . '.';
71
+		// add cap restrictions for editing relating to the "ee_edit_*"
72
+		$this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions(
73
+			[
74
+				$path_to_tax_model . 'taxonomy*ee_edit_event_category' => ['!=', 'espresso_event_categories'],
75
+			]
76
+		);
77
+		$this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions(
78
+			[
79
+				$path_to_tax_model . 'taxonomy*ee_edit_venue_category' => ['!=', 'espresso_venue_categories'],
80
+			]
81
+		);
82
+		$this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type']     = new EE_Default_Where_Conditions(
83
+			[
84
+				$path_to_tax_model . 'taxonomy*ee_edit_event_type' => ['!=', 'espresso_event_type'],
85
+			]
86
+		);
87
+		// add cap restrictions for deleting relating to the "ee_deleting_*"
88
+		$this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions(
89
+			[
90
+				$path_to_tax_model . 'taxonomy*ee_delete_event_category' => ['!=', 'espresso_event_categories'],
91
+			]
92
+		);
93
+		$this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions(
94
+			[
95
+				$path_to_tax_model . 'taxonomy*ee_delete_venue_category' => ['!=', 'espresso_venue_categories'],
96
+			]
97
+		);
98
+		$this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type']     = new EE_Default_Where_Conditions(
99
+			[
100
+				$path_to_tax_model . 'taxonomy*ee_delete_event_type' => ['!=', 'espresso_event_type'],
101
+			]
102
+		);
103
+		parent::__construct($timezone);
104
+		add_filter('FHEE__Read__create_model_query_params', ['EEM_Term', 'rest_api_query_params'], 10, 3);
105
+	}
106 106
 
107 107
 
108
-    /**
109
-     * retrieves a list of all EE event categories
110
-     *
111
-     * @access public
112
-     * @param bool $show_uncategorized
113
-     * @return EE_Base_Class[]
114
-     * @throws EE_Error
115
-     * @throws ReflectionException
116
-     */
117
-    public function get_all_ee_categories(bool $show_uncategorized = false): array
118
-    {
119
-        $where_params = [
120
-            'Term_Taxonomy.taxonomy' => 'espresso_event_categories',
121
-            'NOT'                    => ['name' => esc_html__('Uncategorized', 'event_espresso')],
122
-        ];
123
-        if ($show_uncategorized) {
124
-            unset($where_params['NOT']);
125
-        }
126
-        return EEM_Term::instance()->get_all(
127
-            [
128
-                $where_params,
129
-                'order_by' => ['name' => 'ASC'],
130
-            ]
131
-        );
132
-    }
108
+	/**
109
+	 * retrieves a list of all EE event categories
110
+	 *
111
+	 * @access public
112
+	 * @param bool $show_uncategorized
113
+	 * @return EE_Base_Class[]
114
+	 * @throws EE_Error
115
+	 * @throws ReflectionException
116
+	 */
117
+	public function get_all_ee_categories(bool $show_uncategorized = false): array
118
+	{
119
+		$where_params = [
120
+			'Term_Taxonomy.taxonomy' => 'espresso_event_categories',
121
+			'NOT'                    => ['name' => esc_html__('Uncategorized', 'event_espresso')],
122
+		];
123
+		if ($show_uncategorized) {
124
+			unset($where_params['NOT']);
125
+		}
126
+		return EEM_Term::instance()->get_all(
127
+			[
128
+				$where_params,
129
+				'order_by' => ['name' => 'ASC'],
130
+			]
131
+		);
132
+	}
133 133
 
134 134
 
135
-    /**
136
-     * retrieves a list of all post_tags associated with an EE CPT
137
-     *
138
-     * @access public
139
-     * @param string $post_type
140
-     * @return array
141
-     * @throws EE_Error
142
-     * @throws ReflectionException
143
-     */
144
-    public function get_all_CPT_post_tags(string $post_type = ''): array
145
-    {
146
-        switch ($post_type) {
147
-            case 'espresso_events':
148
-                return $this->get_all_event_post_tags();
149
-            case 'espresso_venues':
150
-                return $this->get_all_venue_post_tags();
151
-            default:
152
-                $event_tags = $this->get_all_event_post_tags();
153
-                $venue_tags = $this->get_all_venue_post_tags();
154
-                return array_merge($event_tags, $venue_tags);
155
-        }
156
-    }
135
+	/**
136
+	 * retrieves a list of all post_tags associated with an EE CPT
137
+	 *
138
+	 * @access public
139
+	 * @param string $post_type
140
+	 * @return array
141
+	 * @throws EE_Error
142
+	 * @throws ReflectionException
143
+	 */
144
+	public function get_all_CPT_post_tags(string $post_type = ''): array
145
+	{
146
+		switch ($post_type) {
147
+			case 'espresso_events':
148
+				return $this->get_all_event_post_tags();
149
+			case 'espresso_venues':
150
+				return $this->get_all_venue_post_tags();
151
+			default:
152
+				$event_tags = $this->get_all_event_post_tags();
153
+				$venue_tags = $this->get_all_venue_post_tags();
154
+				return array_merge($event_tags, $venue_tags);
155
+		}
156
+	}
157 157
 
158 158
 
159
-    /**
160
-     * returns an EE_Term object for the given tag
161
-     * if it has been utilized by any EE_Events or EE_Venues
162
-     *
163
-     * @param string $tag
164
-     * @return EE_Term|null
165
-     * @throws EE_Error
166
-     * @throws InvalidArgumentException
167
-     * @throws InvalidDataTypeException
168
-     * @throws InvalidInterfaceException
169
-     * @throws ReflectionException
170
-     */
171
-    public function get_post_tag_for_event_or_venue(string $tag): ?EE_Term
172
-    {
173
-        $post_tag_results = $this->get_all_wpdb_results(
174
-            [
175
-                [
176
-                    'slug'                   => $tag,
177
-                    'Term_Taxonomy.taxonomy' => 'post_tag',
178
-                    'OR'                     => [
179
-                        'Term_Taxonomy.Venue.post_type' => 'espresso_venues',
180
-                        'Term_Taxonomy.Event.post_type' => 'espresso_events',
181
-                    ],
182
-                ],
183
-                'default_where_conditions' => 'none',
184
-                'extra_selects'            => [
185
-                    'event_post_type' => ['Term_Taxonomy___Event_CPT.post_type', '%s'],
186
-                    'venue_post_type' => ['Term_Taxonomy___Venue_CPT.post_type', '%s'],
187
-                ],
188
-                'group_by'                 => [
189
-                    'event_post_type',
190
-                    'venue_post_type',
191
-                ],
192
-                'limit'                    => 2,
193
-            ]
194
-        );
159
+	/**
160
+	 * returns an EE_Term object for the given tag
161
+	 * if it has been utilized by any EE_Events or EE_Venues
162
+	 *
163
+	 * @param string $tag
164
+	 * @return EE_Term|null
165
+	 * @throws EE_Error
166
+	 * @throws InvalidArgumentException
167
+	 * @throws InvalidDataTypeException
168
+	 * @throws InvalidInterfaceException
169
+	 * @throws ReflectionException
170
+	 */
171
+	public function get_post_tag_for_event_or_venue(string $tag): ?EE_Term
172
+	{
173
+		$post_tag_results = $this->get_all_wpdb_results(
174
+			[
175
+				[
176
+					'slug'                   => $tag,
177
+					'Term_Taxonomy.taxonomy' => 'post_tag',
178
+					'OR'                     => [
179
+						'Term_Taxonomy.Venue.post_type' => 'espresso_venues',
180
+						'Term_Taxonomy.Event.post_type' => 'espresso_events',
181
+					],
182
+				],
183
+				'default_where_conditions' => 'none',
184
+				'extra_selects'            => [
185
+					'event_post_type' => ['Term_Taxonomy___Event_CPT.post_type', '%s'],
186
+					'venue_post_type' => ['Term_Taxonomy___Venue_CPT.post_type', '%s'],
187
+				],
188
+				'group_by'                 => [
189
+					'event_post_type',
190
+					'venue_post_type',
191
+				],
192
+				'limit'                    => 2,
193
+			]
194
+		);
195 195
 
196
-        $post_types = [];
197
-        foreach ((array) $post_tag_results as $row) {
198
-            if ($row['event_post_type'] === 'espresso_events') {
199
-                $post_types[] = EEM_Event::instance()->post_type();
200
-            } elseif ($row['venue_post_type'] === 'espresso_venues') {
201
-                $post_types[] = EEM_Venue::instance()->post_type();
202
-            }
203
-        }
204
-        $post_tag_row = reset($post_tag_results);
205
-        $post_tag     = $this->instantiate_class_from_array_or_object($post_tag_row);
206
-        if (! $post_tag instanceof EE_Term) {
207
-            return null;
208
-        }
196
+		$post_types = [];
197
+		foreach ((array) $post_tag_results as $row) {
198
+			if ($row['event_post_type'] === 'espresso_events') {
199
+				$post_types[] = EEM_Event::instance()->post_type();
200
+			} elseif ($row['venue_post_type'] === 'espresso_venues') {
201
+				$post_types[] = EEM_Venue::instance()->post_type();
202
+			}
203
+		}
204
+		$post_tag_row = reset($post_tag_results);
205
+		$post_tag     = $this->instantiate_class_from_array_or_object($post_tag_row);
206
+		if (! $post_tag instanceof EE_Term) {
207
+			return null;
208
+		}
209 209
 
210
-        if ($post_tag->post_type === null) {
211
-            $post_tag->post_type = [];
212
-        }
213
-        $post_tag->post_type = array_merge($post_tag->post_type, array_unique($post_types));
214
-        return $post_tag;
215
-    }
210
+		if ($post_tag->post_type === null) {
211
+			$post_tag->post_type = [];
212
+		}
213
+		$post_tag->post_type = array_merge($post_tag->post_type, array_unique($post_types));
214
+		return $post_tag;
215
+	}
216 216
 
217 217
 
218
-    /**
219
-     * get_all_event_post_tags
220
-     *
221
-     * @return EE_Base_Class[]
222
-     * @throws EE_Error
223
-     * @throws ReflectionException
224
-     */
225
-    public function get_all_event_post_tags(): array
226
-    {
227
-        $post_tags = EEM_Term::instance()->get_all(
228
-            [
229
-                [
230
-                    'Term_Taxonomy.taxonomy'        => 'post_tag',
231
-                    'Term_Taxonomy.Event.post_type' => 'espresso_events',
232
-                ],
233
-                'order_by'   => ['name' => 'ASC'],
234
-                'force_join' => ['Term_Taxonomy.Event'],
235
-            ]
236
-        );
237
-        foreach ($post_tags as $key => $post_tag) {
238
-            if (! isset($post_tag->post_type)) {
239
-                $post_tag->post_type = [];
240
-            }
241
-            $post_tag->post_type[] = 'espresso_events';
242
-            $post_tags[ $key ]     = $post_tag;
243
-        }
244
-        return $post_tags;
245
-    }
218
+	/**
219
+	 * get_all_event_post_tags
220
+	 *
221
+	 * @return EE_Base_Class[]
222
+	 * @throws EE_Error
223
+	 * @throws ReflectionException
224
+	 */
225
+	public function get_all_event_post_tags(): array
226
+	{
227
+		$post_tags = EEM_Term::instance()->get_all(
228
+			[
229
+				[
230
+					'Term_Taxonomy.taxonomy'        => 'post_tag',
231
+					'Term_Taxonomy.Event.post_type' => 'espresso_events',
232
+				],
233
+				'order_by'   => ['name' => 'ASC'],
234
+				'force_join' => ['Term_Taxonomy.Event'],
235
+			]
236
+		);
237
+		foreach ($post_tags as $key => $post_tag) {
238
+			if (! isset($post_tag->post_type)) {
239
+				$post_tag->post_type = [];
240
+			}
241
+			$post_tag->post_type[] = 'espresso_events';
242
+			$post_tags[ $key ]     = $post_tag;
243
+		}
244
+		return $post_tags;
245
+	}
246 246
 
247 247
 
248
-    /**
249
-     * get_all_venue_post_tags
250
-     *
251
-     * @return EE_Base_Class[]
252
-     * @throws EE_Error
253
-     * @throws ReflectionException
254
-     */
255
-    public function get_all_venue_post_tags(): array
256
-    {
257
-        $post_tags = EEM_Term::instance()->get_all(
258
-            [
259
-                [
260
-                    'Term_Taxonomy.taxonomy'        => 'post_tag',
261
-                    'Term_Taxonomy.Venue.post_type' => 'espresso_venues',
262
-                ],
263
-                'order_by'   => ['name' => 'ASC'],
264
-                'force_join' => ['Term_Taxonomy'],
265
-            ]
266
-        );
267
-        foreach ($post_tags as $key => $post_tag) {
268
-            if (! isset($post_tag->post_type)) {
269
-                $post_tag->post_type = [];
270
-            }
271
-            $post_tag->post_type[] = 'espresso_venues';
272
-            $post_tags[ $key ]     = $post_tag;
273
-        }
274
-        return $post_tags;
275
-    }
248
+	/**
249
+	 * get_all_venue_post_tags
250
+	 *
251
+	 * @return EE_Base_Class[]
252
+	 * @throws EE_Error
253
+	 * @throws ReflectionException
254
+	 */
255
+	public function get_all_venue_post_tags(): array
256
+	{
257
+		$post_tags = EEM_Term::instance()->get_all(
258
+			[
259
+				[
260
+					'Term_Taxonomy.taxonomy'        => 'post_tag',
261
+					'Term_Taxonomy.Venue.post_type' => 'espresso_venues',
262
+				],
263
+				'order_by'   => ['name' => 'ASC'],
264
+				'force_join' => ['Term_Taxonomy'],
265
+			]
266
+		);
267
+		foreach ($post_tags as $key => $post_tag) {
268
+			if (! isset($post_tag->post_type)) {
269
+				$post_tag->post_type = [];
270
+			}
271
+			$post_tag->post_type[] = 'espresso_venues';
272
+			$post_tags[ $key ]     = $post_tag;
273
+		}
274
+		return $post_tags;
275
+	}
276 276
 
277 277
 
278
-    /**
279
-     * Makes sure that during REST API queries, we only return terms
280
-     * for term taxonomies which should be shown in the rest api
281
-     *
282
-     * @param array    $model_query_params
283
-     * @param array    $querystring_query_params
284
-     * @param EEM_Base $model
285
-     * @return array
286
-     * @throws EE_Error
287
-     * @throws EE_Error
288
-     */
289
-    public static function rest_api_query_params(
290
-        array $model_query_params,
291
-        array $querystring_query_params,
292
-        EEM_Base $model
293
-    ): array {
294
-        if ($model === EEM_Term::instance()) {
295
-            $taxonomies = get_taxonomies(['show_in_rest' => true]);
296
-            if (! empty($taxonomies)) {
297
-                $model_query_params[0]['Term_Taxonomy.taxonomy'] = ['IN', $taxonomies];
298
-            }
299
-        }
300
-        return $model_query_params;
301
-    }
278
+	/**
279
+	 * Makes sure that during REST API queries, we only return terms
280
+	 * for term taxonomies which should be shown in the rest api
281
+	 *
282
+	 * @param array    $model_query_params
283
+	 * @param array    $querystring_query_params
284
+	 * @param EEM_Base $model
285
+	 * @return array
286
+	 * @throws EE_Error
287
+	 * @throws EE_Error
288
+	 */
289
+	public static function rest_api_query_params(
290
+		array $model_query_params,
291
+		array $querystring_query_params,
292
+		EEM_Base $model
293
+	): array {
294
+		if ($model === EEM_Term::instance()) {
295
+			$taxonomies = get_taxonomies(['show_in_rest' => true]);
296
+			if (! empty($taxonomies)) {
297
+				$model_query_params[0]['Term_Taxonomy.taxonomy'] = ['IN', $taxonomies];
298
+			}
299
+		}
300
+		return $model_query_params;
301
+	}
302 302
 }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -60,44 +60,44 @@  discard block
 block discarded – undo
60 60
         ];
61 61
         $this->_wp_core_model                                       = true;
62 62
         $path_to_tax_model                                          = 'Term_Taxonomy';
63
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ]   = new EE_Restriction_Generator_Public();
64
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ]
63
+        $this->_cap_restriction_generators[EEM_Base::caps_read]   = new EE_Restriction_Generator_Public();
64
+        $this->_cap_restriction_generators[EEM_Base::caps_read_admin]
65 65
                                                                     = new EE_Restriction_Generator_Taxonomy_Protected(
66 66
             $path_to_tax_model
67 67
         );
68
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ]   = false;
69
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false;
70
-        $path_to_tax_model                                          = $path_to_tax_model . '.';
68
+        $this->_cap_restriction_generators[EEM_Base::caps_edit]   = false;
69
+        $this->_cap_restriction_generators[EEM_Base::caps_delete] = false;
70
+        $path_to_tax_model                                          = $path_to_tax_model.'.';
71 71
         // add cap restrictions for editing relating to the "ee_edit_*"
72
-        $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions(
72
+        $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_category'] = new EE_Default_Where_Conditions(
73 73
             [
74
-                $path_to_tax_model . 'taxonomy*ee_edit_event_category' => ['!=', 'espresso_event_categories'],
74
+                $path_to_tax_model.'taxonomy*ee_edit_event_category' => ['!=', 'espresso_event_categories'],
75 75
             ]
76 76
         );
77
-        $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions(
77
+        $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_venue_category'] = new EE_Default_Where_Conditions(
78 78
             [
79
-                $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => ['!=', 'espresso_venue_categories'],
79
+                $path_to_tax_model.'taxonomy*ee_edit_venue_category' => ['!=', 'espresso_venue_categories'],
80 80
             ]
81 81
         );
82
-        $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type']     = new EE_Default_Where_Conditions(
82
+        $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_type'] = new EE_Default_Where_Conditions(
83 83
             [
84
-                $path_to_tax_model . 'taxonomy*ee_edit_event_type' => ['!=', 'espresso_event_type'],
84
+                $path_to_tax_model.'taxonomy*ee_edit_event_type' => ['!=', 'espresso_event_type'],
85 85
             ]
86 86
         );
87 87
         // add cap restrictions for deleting relating to the "ee_deleting_*"
88
-        $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions(
88
+        $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_category'] = new EE_Default_Where_Conditions(
89 89
             [
90
-                $path_to_tax_model . 'taxonomy*ee_delete_event_category' => ['!=', 'espresso_event_categories'],
90
+                $path_to_tax_model.'taxonomy*ee_delete_event_category' => ['!=', 'espresso_event_categories'],
91 91
             ]
92 92
         );
93
-        $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions(
93
+        $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_venue_category'] = new EE_Default_Where_Conditions(
94 94
             [
95
-                $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => ['!=', 'espresso_venue_categories'],
95
+                $path_to_tax_model.'taxonomy*ee_delete_venue_category' => ['!=', 'espresso_venue_categories'],
96 96
             ]
97 97
         );
98
-        $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type']     = new EE_Default_Where_Conditions(
98
+        $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_type'] = new EE_Default_Where_Conditions(
99 99
             [
100
-                $path_to_tax_model . 'taxonomy*ee_delete_event_type' => ['!=', 'espresso_event_type'],
100
+                $path_to_tax_model.'taxonomy*ee_delete_event_type' => ['!=', 'espresso_event_type'],
101 101
             ]
102 102
         );
103 103
         parent::__construct($timezone);
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
         }
204 204
         $post_tag_row = reset($post_tag_results);
205 205
         $post_tag     = $this->instantiate_class_from_array_or_object($post_tag_row);
206
-        if (! $post_tag instanceof EE_Term) {
206
+        if ( ! $post_tag instanceof EE_Term) {
207 207
             return null;
208 208
         }
209 209
 
@@ -235,11 +235,11 @@  discard block
 block discarded – undo
235 235
             ]
236 236
         );
237 237
         foreach ($post_tags as $key => $post_tag) {
238
-            if (! isset($post_tag->post_type)) {
238
+            if ( ! isset($post_tag->post_type)) {
239 239
                 $post_tag->post_type = [];
240 240
             }
241 241
             $post_tag->post_type[] = 'espresso_events';
242
-            $post_tags[ $key ]     = $post_tag;
242
+            $post_tags[$key]     = $post_tag;
243 243
         }
244 244
         return $post_tags;
245 245
     }
@@ -265,11 +265,11 @@  discard block
 block discarded – undo
265 265
             ]
266 266
         );
267 267
         foreach ($post_tags as $key => $post_tag) {
268
-            if (! isset($post_tag->post_type)) {
268
+            if ( ! isset($post_tag->post_type)) {
269 269
                 $post_tag->post_type = [];
270 270
             }
271 271
             $post_tag->post_type[] = 'espresso_venues';
272
-            $post_tags[ $key ]     = $post_tag;
272
+            $post_tags[$key]     = $post_tag;
273 273
         }
274 274
         return $post_tags;
275 275
     }
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
     ): array {
294 294
         if ($model === EEM_Term::instance()) {
295 295
             $taxonomies = get_taxonomies(['show_in_rest' => true]);
296
-            if (! empty($taxonomies)) {
296
+            if ( ! empty($taxonomies)) {
297 297
                 $model_query_params[0]['Term_Taxonomy.taxonomy'] = ['IN', $taxonomies];
298 298
             }
299 299
         }
Please login to merge, or discard this patch.
core/db_models/EEM_System_Status.model.php 2 patches
Indentation   +388 added lines, -388 removed lines patch added patch discarded remove patch
@@ -6,392 +6,392 @@
 block discarded – undo
6 6
 class EEM_System_Status
7 7
 {
8 8
 
9
-    /**
10
-     * @var EEM_System_Status
11
-     */
12
-    protected static $_instance;
13
-
14
-
15
-    /**
16
-     * This function is a singleton method used to instantiate the EEM_Attendee object
17
-     *
18
-     * @return EEM_System_Status
19
-     */
20
-    public static function instance(): EEM_System_Status
21
-    {
22
-
23
-        // check if instance of EEM_System_Status already exists
24
-        if (self::$_instance === null) {
25
-            // instantiate EEM_System_Status
26
-            self::$_instance = new self();
27
-        }
28
-        return self::$_instance;
29
-    }
30
-
31
-
32
-    private function __construct()
33
-    {
34
-    }
35
-
36
-
37
-    /**
38
-     * @return array where each key is a function name on this class, and each value is SOMETHING--
39
-     * it might be a value, an array, or an object
40
-     */
41
-    public function get_system_stati(): array
42
-    {
43
-        return apply_filters(
44
-            'FHEE__EEM_System_Status__get_system_stati',
45
-            [
46
-                'ee_version'            => $this->get_ee_version(),
47
-                'ee_activation_history' => $this->get_ee_activation_history(),
48
-                'ee_config'             => $this->get_ee_config(),
49
-                'ee_migration_history'  => $this->get_ee_migration_history(),
50
-                'active_plugins'        => $this->get_active_plugins(),
51
-                'wp_settings'           => $this->get_wp_settings(),
52
-                'wp_maintenance_mode'   => $this->get_wp_maintenance_mode(),
53
-                'https_enabled'         => $this->get_https_enabled(),
54
-                'logging_enabled'       => $this->get_logging_enabled(),
55
-                'remote_posting'        => $this->get_remote_posting(),
56
-                'php_version'           => $this->php_version(),
57
-                'php.ini_settings'      => $this->get_php_ini_all(),
58
-                'php_info'              => $this->get_php_info(),
59
-            ],
60
-            $this
61
-        );
62
-    }
63
-
64
-
65
-    /**
66
-     *
67
-     * @return string
68
-     */
69
-    public function get_ee_version(): string
70
-    {
71
-        return espresso_version();
72
-    }
73
-
74
-
75
-    /**
76
-     *
77
-     * @return string
78
-     */
79
-    public function php_version(): string
80
-    {
81
-        return phpversion();
82
-    }
83
-
84
-
85
-    /**
86
-     *
87
-     * @return array, where each key is a plugin name (lower-cased), values are sub-arrays.
88
-     * Sub-arrays like described in wp function get_plugin_data. Ie,     *
89
-     *  'Name' => 'Plugin Name',
90
-     * 'PluginURI' => 'Plugin URI',
91
-     * 'Version' => 'Version',
92
-     * 'Description' => 'Description',
93
-     * 'Author' => 'Author',
94
-     * 'AuthorURI' => 'Author URI',
95
-     * 'TextDomain' => 'Text Domain',
96
-     * 'DomainPath' => 'Domain Path',
97
-     * 'Network' => 'Network',
98
-     */
99
-    public function get_active_plugins(): array
100
-    {
101
-        $active_plugins = (array) get_option('active_plugins', []);
102
-        if (is_multisite()) {
103
-            $active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', []));
104
-        }
105
-        $active_plugins = array_map('strtolower', $active_plugins);
106
-        $plugin_info    = [];
107
-        foreach ($active_plugins as $plugin) {
108
-            $plugin_data = @get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin);
109
-
110
-            $plugin_info[ $plugin ] = $plugin_data;
111
-        }
112
-        return $plugin_info;
113
-    }
114
-
115
-
116
-    /**
117
-     *
118
-     * @return array with keys 'home_url' and 'site_url'
119
-     */
120
-    public function get_wp_settings(): array
121
-    {
122
-        $wp_memory_int = $this->let_to_num(WP_MEMORY_LIMIT);
123
-        if ($wp_memory_int < 67108864) {
124
-            $wp_memory_to_display = '<mark class="error">'
125
-                                    . sprintf(
126
-                                        esc_html__(
127
-                                            '%s - We recommend setting memory to at least 64MB. See: %s Increasing memory allocated to PHP %s',
128
-                                            'event_espresso'
129
-                                        ),
130
-                                        WP_MEMORY_LIMIT,
131
-                                        '<a href="http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP">',
132
-                                        '</a>"'
133
-                                    )
134
-                                    . '</mark>';
135
-        } else {
136
-            $wp_memory_to_display = '<mark class="yes">' . size_format($wp_memory_int) . '</mark>';
137
-        }
138
-        return [
139
-            'name'                => get_bloginfo('name', 'display'),
140
-            'is_multisite'        => is_multisite(),
141
-            'version'             => get_bloginfo('version', 'display'),
142
-            'home_url'            => home_url(),
143
-            'site_url'            => site_url(),
144
-            'WP_DEBUG'            => WP_DEBUG,
145
-            'permalink_structure' => get_option('permalink_structure'),
146
-            'theme'               => wp_get_theme(),
147
-            'gmt_offset'          => get_option('gmt_offset'),
148
-            'timezone_string'     => get_option('timezone_string'),
149
-            'admin_email'         => get_bloginfo('admin_email', 'display'),
150
-            'language'            => get_bloginfo('language', 'display'),
151
-            'wp_max_upload_size'  => size_format(wp_max_upload_size()),
152
-            'wp_memory'           => $wp_memory_to_display,
153
-        ];
154
-    }
155
-
156
-
157
-    /**
158
-     * Gets an array of information about the history of ee versions installed
159
-     *
160
-     * @return array
161
-     */
162
-    public function get_ee_activation_history(): array
163
-    {
164
-        return get_option('espresso_db_update');
165
-    }
166
-
167
-
168
-    /**
169
-     * Gets an array where keys are ee versions, and their values are arrays indicating all the different times that
170
-     * version was installed
171
-     *
172
-     * @return EE_Data_Migration_Script_Base[]
173
-     */
174
-    public function get_ee_migration_history(): array
175
-    {
176
-        $presentable_migration_scripts = [];
177
-        $options                       = EE_Data_Migration_Manager::instance()->get_all_migration_script_options();
178
-        foreach ($options as $option_array) {
179
-            $key                                   = str_replace(
180
-                EE_Data_Migration_Manager::data_migration_script_option_prefix,
181
-                '',
182
-                $option_array['option_name']
183
-            );
184
-            $presentable_migration_scripts[ $key ] = maybe_unserialize($option_array['option_value']);
185
-        }
186
-        return $presentable_migration_scripts;
187
-    }
188
-
189
-
190
-    /**
191
-     *
192
-     * @return EE_Config
193
-     */
194
-    public function get_ee_config(): EE_Config
195
-    {
196
-        return EE_Config::instance();
197
-    }
198
-
199
-
200
-    /**
201
-     * Gets an array of php setup info, pilfered from http://www.php.net/manual/en/function.phpinfo.php#87463
202
-     *
203
-     * @return array like the output of phpinfo(), but in an array
204
-     */
205
-    public function get_php_info(): array
206
-    {
207
-        ob_start();
208
-        phpinfo(-1);
209
-
210
-        $pi = preg_replace(
211
-            [
212
-                '#^.*<body>(.*)</body>.*$#ms',
213
-                '#<h2>PHP License</h2>.*$#ms',
214
-                '#<h1>Configuration</h1>#',
215
-                "#\r?\n#",
216
-                "#</(h1|h2|h3|tr)>#",
217
-                '# +<#',
218
-                "#[ \t]+#",
219
-                '#&nbsp;#',
220
-                '#  +#',
221
-                '# class=".*?"#',
222
-                '%&#039;%',
223
-                '#<tr>(?:.*?)" src="(?:.*?)=(.*?)" alt="PHP Logo" /></a>'
224
-                . '<h1>PHP Version (.*?)</h1>(?:\n+?)</td></tr>#',
225
-                '#<h1><a href="(?:.*?)\?=(.*?)">PHP Credits</a></h1>#',
226
-                '#<tr>(?:.*?)" src="(?:.*?)=(.*?)"(?:.*?)Zend Engine (.*?),(?:.*?)</tr>#',
227
-                "# +#",
228
-                '#<tr>#',
229
-                '#</tr>#',
230
-            ],
231
-            [
232
-                '$1',
233
-                '',
234
-                '',
235
-                '',
236
-                '</$1>' . "\n",
237
-                '<',
238
-                ' ',
239
-                ' ',
240
-                ' ',
241
-                '',
242
-                ' ',
243
-                '<h2>PHP Configuration</h2>' . "\n" . '<tr><td>PHP Version</td><td>$2</td></tr>' .
244
-                "\n" . '<tr><td>PHP Egg</td><td>$1</td></tr>',
245
-                '<tr><td>PHP Credits Egg</td><td>$1</td></tr>',
246
-                '<tr><td>Zend Engine</td><td>$2</td></tr>' . "\n" .
247
-                '<tr><td>Zend Egg</td><td>$1</td></tr>',
248
-                ' ',
249
-                '%S%',
250
-                '%E%',
251
-            ],
252
-            ob_get_clean()
253
-        );
254
-
255
-        $sections = explode('<h2>', strip_tags($pi, '<h2><th><td>'));
256
-        unset($sections[0]);
257
-
258
-        $pi = [];
259
-        foreach ($sections as $section) {
260
-            $n = substr($section, 0, strpos($section, '</h2>'));
261
-            preg_match_all(
262
-                '#%S%(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?%E%#',
263
-                $section,
264
-                $ask_apache,
265
-                PREG_SET_ORDER
266
-            );
267
-            foreach ($ask_apache as $m) {
268
-                $m2 = $m[2] ?? null;
269
-            }
270
-            $pi[ $n ][ $m[1] ] = (! isset($m[3]) || $m2 == $m[3])
271
-                ? $m2
272
-                : array_slice($m, 2);
273
-        }
274
-
275
-        return $pi;
276
-    }
277
-
278
-
279
-    /**
280
-     * Checks if site responds ot HTTPS
281
-     *
282
-     * @return string
283
-     */
284
-    public function get_https_enabled(): string
285
-    {
286
-        $home     = str_replace("http://", "https://", home_url());
287
-        $response = wp_remote_get($home);
288
-        if ($response instanceof WP_Error) {
289
-            $error_string = '';
290
-            foreach ($response->errors as $short_name => $description_array) {
291
-                $error_string .= "<b>$short_name</b>: " . implode(", ", $description_array);
292
-            }
293
-            return $error_string;
294
-        }
295
-        return "ok!";
296
-    }
297
-
298
-
299
-    /**
300
-     * Whether or not a .maintenance file is detected
301
-     *
302
-     * @return string wp_maintenance_mode status
303
-     */
304
-    public function get_wp_maintenance_mode(): string
305
-    {
306
-        $opened = file_exists(ABSPATH . '.maintenance');
307
-        return $opened
308
-            ? sprintf(
309
-                esc_html__(
310
-                    '%s.maintenance file detected.%s Wordpress may have a failed auto-update which could prevent Event Espresso from updating the database correctly.',
311
-                    'event_espresso'
312
-                ),
313
-                '<strong>',
314
-                '</strong>'
315
-            )
316
-            : esc_html__('.maintenance file not detected. WordPress is not in maintenance mode.', 'event_espresso');
317
-    }
318
-
319
-
320
-    /**
321
-     * Whether or not logging is enabled
322
-     *
323
-     * @return string logging's status
324
-     */
325
-    public function get_logging_enabled(): string
326
-    {
327
-        $opened = @fopen(EVENT_ESPRESSO_UPLOAD_DIR . '/logs/espresso_log.txt', 'a');
328
-        return $opened
329
-            ? esc_html__('Log Directory is writable', 'event_espresso')
330
-            : sprintf(__('%sLog directory is NOT writable%s', 'event_espresso'), '<mark class="error"', '</mark>');
331
-    }
332
-
333
-
334
-    /**
335
-     *  Whether curl ro fsock works
336
-     *
337
-     * @return string describing posting's status
338
-     */
339
-    public function get_remote_posting(): string
340
-    {
341
-        $fsock_works = function_exists('fsockopen');
342
-        $curl_works  = function_exists('curl_init');
343
-        if ($fsock_works && $curl_works) {
344
-            $status = esc_html__('Your server has fsockopen and cURL enabled.', 'event_espresso');
345
-        } elseif ($fsock_works) {
346
-            $status = esc_html__('Your server has fsockopen enabled, cURL is disabled.', 'event_espresso');
347
-        } elseif ($curl_works) {
348
-            $status = esc_html__('Your server has cURL enabled, fsockopen is disabled.', 'event_espresso');
349
-        } else {
350
-            $status = esc_html__(
351
-                          'Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.',
352
-                          'event_espresso'
353
-                      ) . '</mark>';
354
-        }
355
-        return $status;
356
-    }
357
-
358
-
359
-    /**
360
-     * Gets all the php.ini settings
361
-     *
362
-     * @return array
363
-     */
364
-    public function get_php_ini_all(): array
365
-    {
366
-        return ini_get_all();
367
-    }
368
-
369
-
370
-    /**
371
-     * Transforms the php.ini notation for numbers (like '2M') to an integer.
372
-     *
373
-     * @param string $size
374
-     * @return int
375
-     * @noinspection PhpMissingBreakStatementInspection
376
-     */
377
-    public function let_to_num(string $size): int
378
-    {
379
-        $l   = substr($size, -1);
380
-        $ret = substr($size, 0, -1);
381
-        // phpcs:disable PSR2.ControlStructures.SwitchDeclaration.TerminatingComment
382
-        switch (strtoupper($l)) {
383
-            case 'P':
384
-                $ret *= 1024;
385
-            case 'T':
386
-                $ret *= 1024;
387
-            case 'G':
388
-                $ret *= 1024;
389
-            case 'M':
390
-                $ret *= 1024;
391
-            case 'K':
392
-                $ret *= 1024;
393
-        }
394
-        // phpcs:enable
395
-        return $ret;
396
-    }
9
+	/**
10
+	 * @var EEM_System_Status
11
+	 */
12
+	protected static $_instance;
13
+
14
+
15
+	/**
16
+	 * This function is a singleton method used to instantiate the EEM_Attendee object
17
+	 *
18
+	 * @return EEM_System_Status
19
+	 */
20
+	public static function instance(): EEM_System_Status
21
+	{
22
+
23
+		// check if instance of EEM_System_Status already exists
24
+		if (self::$_instance === null) {
25
+			// instantiate EEM_System_Status
26
+			self::$_instance = new self();
27
+		}
28
+		return self::$_instance;
29
+	}
30
+
31
+
32
+	private function __construct()
33
+	{
34
+	}
35
+
36
+
37
+	/**
38
+	 * @return array where each key is a function name on this class, and each value is SOMETHING--
39
+	 * it might be a value, an array, or an object
40
+	 */
41
+	public function get_system_stati(): array
42
+	{
43
+		return apply_filters(
44
+			'FHEE__EEM_System_Status__get_system_stati',
45
+			[
46
+				'ee_version'            => $this->get_ee_version(),
47
+				'ee_activation_history' => $this->get_ee_activation_history(),
48
+				'ee_config'             => $this->get_ee_config(),
49
+				'ee_migration_history'  => $this->get_ee_migration_history(),
50
+				'active_plugins'        => $this->get_active_plugins(),
51
+				'wp_settings'           => $this->get_wp_settings(),
52
+				'wp_maintenance_mode'   => $this->get_wp_maintenance_mode(),
53
+				'https_enabled'         => $this->get_https_enabled(),
54
+				'logging_enabled'       => $this->get_logging_enabled(),
55
+				'remote_posting'        => $this->get_remote_posting(),
56
+				'php_version'           => $this->php_version(),
57
+				'php.ini_settings'      => $this->get_php_ini_all(),
58
+				'php_info'              => $this->get_php_info(),
59
+			],
60
+			$this
61
+		);
62
+	}
63
+
64
+
65
+	/**
66
+	 *
67
+	 * @return string
68
+	 */
69
+	public function get_ee_version(): string
70
+	{
71
+		return espresso_version();
72
+	}
73
+
74
+
75
+	/**
76
+	 *
77
+	 * @return string
78
+	 */
79
+	public function php_version(): string
80
+	{
81
+		return phpversion();
82
+	}
83
+
84
+
85
+	/**
86
+	 *
87
+	 * @return array, where each key is a plugin name (lower-cased), values are sub-arrays.
88
+	 * Sub-arrays like described in wp function get_plugin_data. Ie,     *
89
+	 *  'Name' => 'Plugin Name',
90
+	 * 'PluginURI' => 'Plugin URI',
91
+	 * 'Version' => 'Version',
92
+	 * 'Description' => 'Description',
93
+	 * 'Author' => 'Author',
94
+	 * 'AuthorURI' => 'Author URI',
95
+	 * 'TextDomain' => 'Text Domain',
96
+	 * 'DomainPath' => 'Domain Path',
97
+	 * 'Network' => 'Network',
98
+	 */
99
+	public function get_active_plugins(): array
100
+	{
101
+		$active_plugins = (array) get_option('active_plugins', []);
102
+		if (is_multisite()) {
103
+			$active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', []));
104
+		}
105
+		$active_plugins = array_map('strtolower', $active_plugins);
106
+		$plugin_info    = [];
107
+		foreach ($active_plugins as $plugin) {
108
+			$plugin_data = @get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin);
109
+
110
+			$plugin_info[ $plugin ] = $plugin_data;
111
+		}
112
+		return $plugin_info;
113
+	}
114
+
115
+
116
+	/**
117
+	 *
118
+	 * @return array with keys 'home_url' and 'site_url'
119
+	 */
120
+	public function get_wp_settings(): array
121
+	{
122
+		$wp_memory_int = $this->let_to_num(WP_MEMORY_LIMIT);
123
+		if ($wp_memory_int < 67108864) {
124
+			$wp_memory_to_display = '<mark class="error">'
125
+									. sprintf(
126
+										esc_html__(
127
+											'%s - We recommend setting memory to at least 64MB. See: %s Increasing memory allocated to PHP %s',
128
+											'event_espresso'
129
+										),
130
+										WP_MEMORY_LIMIT,
131
+										'<a href="http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP">',
132
+										'</a>"'
133
+									)
134
+									. '</mark>';
135
+		} else {
136
+			$wp_memory_to_display = '<mark class="yes">' . size_format($wp_memory_int) . '</mark>';
137
+		}
138
+		return [
139
+			'name'                => get_bloginfo('name', 'display'),
140
+			'is_multisite'        => is_multisite(),
141
+			'version'             => get_bloginfo('version', 'display'),
142
+			'home_url'            => home_url(),
143
+			'site_url'            => site_url(),
144
+			'WP_DEBUG'            => WP_DEBUG,
145
+			'permalink_structure' => get_option('permalink_structure'),
146
+			'theme'               => wp_get_theme(),
147
+			'gmt_offset'          => get_option('gmt_offset'),
148
+			'timezone_string'     => get_option('timezone_string'),
149
+			'admin_email'         => get_bloginfo('admin_email', 'display'),
150
+			'language'            => get_bloginfo('language', 'display'),
151
+			'wp_max_upload_size'  => size_format(wp_max_upload_size()),
152
+			'wp_memory'           => $wp_memory_to_display,
153
+		];
154
+	}
155
+
156
+
157
+	/**
158
+	 * Gets an array of information about the history of ee versions installed
159
+	 *
160
+	 * @return array
161
+	 */
162
+	public function get_ee_activation_history(): array
163
+	{
164
+		return get_option('espresso_db_update');
165
+	}
166
+
167
+
168
+	/**
169
+	 * Gets an array where keys are ee versions, and their values are arrays indicating all the different times that
170
+	 * version was installed
171
+	 *
172
+	 * @return EE_Data_Migration_Script_Base[]
173
+	 */
174
+	public function get_ee_migration_history(): array
175
+	{
176
+		$presentable_migration_scripts = [];
177
+		$options                       = EE_Data_Migration_Manager::instance()->get_all_migration_script_options();
178
+		foreach ($options as $option_array) {
179
+			$key                                   = str_replace(
180
+				EE_Data_Migration_Manager::data_migration_script_option_prefix,
181
+				'',
182
+				$option_array['option_name']
183
+			);
184
+			$presentable_migration_scripts[ $key ] = maybe_unserialize($option_array['option_value']);
185
+		}
186
+		return $presentable_migration_scripts;
187
+	}
188
+
189
+
190
+	/**
191
+	 *
192
+	 * @return EE_Config
193
+	 */
194
+	public function get_ee_config(): EE_Config
195
+	{
196
+		return EE_Config::instance();
197
+	}
198
+
199
+
200
+	/**
201
+	 * Gets an array of php setup info, pilfered from http://www.php.net/manual/en/function.phpinfo.php#87463
202
+	 *
203
+	 * @return array like the output of phpinfo(), but in an array
204
+	 */
205
+	public function get_php_info(): array
206
+	{
207
+		ob_start();
208
+		phpinfo(-1);
209
+
210
+		$pi = preg_replace(
211
+			[
212
+				'#^.*<body>(.*)</body>.*$#ms',
213
+				'#<h2>PHP License</h2>.*$#ms',
214
+				'#<h1>Configuration</h1>#',
215
+				"#\r?\n#",
216
+				"#</(h1|h2|h3|tr)>#",
217
+				'# +<#',
218
+				"#[ \t]+#",
219
+				'#&nbsp;#',
220
+				'#  +#',
221
+				'# class=".*?"#',
222
+				'%&#039;%',
223
+				'#<tr>(?:.*?)" src="(?:.*?)=(.*?)" alt="PHP Logo" /></a>'
224
+				. '<h1>PHP Version (.*?)</h1>(?:\n+?)</td></tr>#',
225
+				'#<h1><a href="(?:.*?)\?=(.*?)">PHP Credits</a></h1>#',
226
+				'#<tr>(?:.*?)" src="(?:.*?)=(.*?)"(?:.*?)Zend Engine (.*?),(?:.*?)</tr>#',
227
+				"# +#",
228
+				'#<tr>#',
229
+				'#</tr>#',
230
+			],
231
+			[
232
+				'$1',
233
+				'',
234
+				'',
235
+				'',
236
+				'</$1>' . "\n",
237
+				'<',
238
+				' ',
239
+				' ',
240
+				' ',
241
+				'',
242
+				' ',
243
+				'<h2>PHP Configuration</h2>' . "\n" . '<tr><td>PHP Version</td><td>$2</td></tr>' .
244
+				"\n" . '<tr><td>PHP Egg</td><td>$1</td></tr>',
245
+				'<tr><td>PHP Credits Egg</td><td>$1</td></tr>',
246
+				'<tr><td>Zend Engine</td><td>$2</td></tr>' . "\n" .
247
+				'<tr><td>Zend Egg</td><td>$1</td></tr>',
248
+				' ',
249
+				'%S%',
250
+				'%E%',
251
+			],
252
+			ob_get_clean()
253
+		);
254
+
255
+		$sections = explode('<h2>', strip_tags($pi, '<h2><th><td>'));
256
+		unset($sections[0]);
257
+
258
+		$pi = [];
259
+		foreach ($sections as $section) {
260
+			$n = substr($section, 0, strpos($section, '</h2>'));
261
+			preg_match_all(
262
+				'#%S%(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?%E%#',
263
+				$section,
264
+				$ask_apache,
265
+				PREG_SET_ORDER
266
+			);
267
+			foreach ($ask_apache as $m) {
268
+				$m2 = $m[2] ?? null;
269
+			}
270
+			$pi[ $n ][ $m[1] ] = (! isset($m[3]) || $m2 == $m[3])
271
+				? $m2
272
+				: array_slice($m, 2);
273
+		}
274
+
275
+		return $pi;
276
+	}
277
+
278
+
279
+	/**
280
+	 * Checks if site responds ot HTTPS
281
+	 *
282
+	 * @return string
283
+	 */
284
+	public function get_https_enabled(): string
285
+	{
286
+		$home     = str_replace("http://", "https://", home_url());
287
+		$response = wp_remote_get($home);
288
+		if ($response instanceof WP_Error) {
289
+			$error_string = '';
290
+			foreach ($response->errors as $short_name => $description_array) {
291
+				$error_string .= "<b>$short_name</b>: " . implode(", ", $description_array);
292
+			}
293
+			return $error_string;
294
+		}
295
+		return "ok!";
296
+	}
297
+
298
+
299
+	/**
300
+	 * Whether or not a .maintenance file is detected
301
+	 *
302
+	 * @return string wp_maintenance_mode status
303
+	 */
304
+	public function get_wp_maintenance_mode(): string
305
+	{
306
+		$opened = file_exists(ABSPATH . '.maintenance');
307
+		return $opened
308
+			? sprintf(
309
+				esc_html__(
310
+					'%s.maintenance file detected.%s Wordpress may have a failed auto-update which could prevent Event Espresso from updating the database correctly.',
311
+					'event_espresso'
312
+				),
313
+				'<strong>',
314
+				'</strong>'
315
+			)
316
+			: esc_html__('.maintenance file not detected. WordPress is not in maintenance mode.', 'event_espresso');
317
+	}
318
+
319
+
320
+	/**
321
+	 * Whether or not logging is enabled
322
+	 *
323
+	 * @return string logging's status
324
+	 */
325
+	public function get_logging_enabled(): string
326
+	{
327
+		$opened = @fopen(EVENT_ESPRESSO_UPLOAD_DIR . '/logs/espresso_log.txt', 'a');
328
+		return $opened
329
+			? esc_html__('Log Directory is writable', 'event_espresso')
330
+			: sprintf(__('%sLog directory is NOT writable%s', 'event_espresso'), '<mark class="error"', '</mark>');
331
+	}
332
+
333
+
334
+	/**
335
+	 *  Whether curl ro fsock works
336
+	 *
337
+	 * @return string describing posting's status
338
+	 */
339
+	public function get_remote_posting(): string
340
+	{
341
+		$fsock_works = function_exists('fsockopen');
342
+		$curl_works  = function_exists('curl_init');
343
+		if ($fsock_works && $curl_works) {
344
+			$status = esc_html__('Your server has fsockopen and cURL enabled.', 'event_espresso');
345
+		} elseif ($fsock_works) {
346
+			$status = esc_html__('Your server has fsockopen enabled, cURL is disabled.', 'event_espresso');
347
+		} elseif ($curl_works) {
348
+			$status = esc_html__('Your server has cURL enabled, fsockopen is disabled.', 'event_espresso');
349
+		} else {
350
+			$status = esc_html__(
351
+						  'Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.',
352
+						  'event_espresso'
353
+					  ) . '</mark>';
354
+		}
355
+		return $status;
356
+	}
357
+
358
+
359
+	/**
360
+	 * Gets all the php.ini settings
361
+	 *
362
+	 * @return array
363
+	 */
364
+	public function get_php_ini_all(): array
365
+	{
366
+		return ini_get_all();
367
+	}
368
+
369
+
370
+	/**
371
+	 * Transforms the php.ini notation for numbers (like '2M') to an integer.
372
+	 *
373
+	 * @param string $size
374
+	 * @return int
375
+	 * @noinspection PhpMissingBreakStatementInspection
376
+	 */
377
+	public function let_to_num(string $size): int
378
+	{
379
+		$l   = substr($size, -1);
380
+		$ret = substr($size, 0, -1);
381
+		// phpcs:disable PSR2.ControlStructures.SwitchDeclaration.TerminatingComment
382
+		switch (strtoupper($l)) {
383
+			case 'P':
384
+				$ret *= 1024;
385
+			case 'T':
386
+				$ret *= 1024;
387
+			case 'G':
388
+				$ret *= 1024;
389
+			case 'M':
390
+				$ret *= 1024;
391
+			case 'K':
392
+				$ret *= 1024;
393
+		}
394
+		// phpcs:enable
395
+		return $ret;
396
+	}
397 397
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
         $active_plugins = array_map('strtolower', $active_plugins);
106 106
         $plugin_info    = [];
107 107
         foreach ($active_plugins as $plugin) {
108
-            $plugin_data = @get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin);
108
+            $plugin_data = @get_plugin_data(WP_PLUGIN_DIR.'/'.$plugin);
109 109
 
110
-            $plugin_info[ $plugin ] = $plugin_data;
110
+            $plugin_info[$plugin] = $plugin_data;
111 111
         }
112 112
         return $plugin_info;
113 113
     }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
                                     )
134 134
                                     . '</mark>';
135 135
         } else {
136
-            $wp_memory_to_display = '<mark class="yes">' . size_format($wp_memory_int) . '</mark>';
136
+            $wp_memory_to_display = '<mark class="yes">'.size_format($wp_memory_int).'</mark>';
137 137
         }
138 138
         return [
139 139
             'name'                => get_bloginfo('name', 'display'),
@@ -176,12 +176,12 @@  discard block
 block discarded – undo
176 176
         $presentable_migration_scripts = [];
177 177
         $options                       = EE_Data_Migration_Manager::instance()->get_all_migration_script_options();
178 178
         foreach ($options as $option_array) {
179
-            $key                                   = str_replace(
179
+            $key = str_replace(
180 180
                 EE_Data_Migration_Manager::data_migration_script_option_prefix,
181 181
                 '',
182 182
                 $option_array['option_name']
183 183
             );
184
-            $presentable_migration_scripts[ $key ] = maybe_unserialize($option_array['option_value']);
184
+            $presentable_migration_scripts[$key] = maybe_unserialize($option_array['option_value']);
185 185
         }
186 186
         return $presentable_migration_scripts;
187 187
     }
@@ -233,17 +233,17 @@  discard block
 block discarded – undo
233 233
                 '',
234 234
                 '',
235 235
                 '',
236
-                '</$1>' . "\n",
236
+                '</$1>'."\n",
237 237
                 '<',
238 238
                 ' ',
239 239
                 ' ',
240 240
                 ' ',
241 241
                 '',
242 242
                 ' ',
243
-                '<h2>PHP Configuration</h2>' . "\n" . '<tr><td>PHP Version</td><td>$2</td></tr>' .
244
-                "\n" . '<tr><td>PHP Egg</td><td>$1</td></tr>',
243
+                '<h2>PHP Configuration</h2>'."\n".'<tr><td>PHP Version</td><td>$2</td></tr>'.
244
+                "\n".'<tr><td>PHP Egg</td><td>$1</td></tr>',
245 245
                 '<tr><td>PHP Credits Egg</td><td>$1</td></tr>',
246
-                '<tr><td>Zend Engine</td><td>$2</td></tr>' . "\n" .
246
+                '<tr><td>Zend Engine</td><td>$2</td></tr>'."\n".
247 247
                 '<tr><td>Zend Egg</td><td>$1</td></tr>',
248 248
                 ' ',
249 249
                 '%S%',
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
             foreach ($ask_apache as $m) {
268 268
                 $m2 = $m[2] ?? null;
269 269
             }
270
-            $pi[ $n ][ $m[1] ] = (! isset($m[3]) || $m2 == $m[3])
270
+            $pi[$n][$m[1]] = ( ! isset($m[3]) || $m2 == $m[3])
271 271
                 ? $m2
272 272
                 : array_slice($m, 2);
273 273
         }
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
         if ($response instanceof WP_Error) {
289 289
             $error_string = '';
290 290
             foreach ($response->errors as $short_name => $description_array) {
291
-                $error_string .= "<b>$short_name</b>: " . implode(", ", $description_array);
291
+                $error_string .= "<b>$short_name</b>: ".implode(", ", $description_array);
292 292
             }
293 293
             return $error_string;
294 294
         }
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
      */
304 304
     public function get_wp_maintenance_mode(): string
305 305
     {
306
-        $opened = file_exists(ABSPATH . '.maintenance');
306
+        $opened = file_exists(ABSPATH.'.maintenance');
307 307
         return $opened
308 308
             ? sprintf(
309 309
                 esc_html__(
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
      */
325 325
     public function get_logging_enabled(): string
326 326
     {
327
-        $opened = @fopen(EVENT_ESPRESSO_UPLOAD_DIR . '/logs/espresso_log.txt', 'a');
327
+        $opened = @fopen(EVENT_ESPRESSO_UPLOAD_DIR.'/logs/espresso_log.txt', 'a');
328 328
         return $opened
329 329
             ? esc_html__('Log Directory is writable', 'event_espresso')
330 330
             : sprintf(__('%sLog directory is NOT writable%s', 'event_espresso'), '<mark class="error"', '</mark>');
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
             $status = esc_html__(
351 351
                           'Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.',
352 352
                           'event_espresso'
353
-                      ) . '</mark>';
353
+                      ).'</mark>';
354 354
         }
355 355
         return $status;
356 356
     }
Please login to merge, or discard this patch.
core/db_models/EEM_Question_Group_Question.model.php 2 patches
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -14,74 +14,74 @@
 block discarded – undo
14 14
 class EEM_Question_Group_Question extends EEM_Base
15 15
 {
16 16
 
17
-    /**
18
-     * @var EEM_Question_Group_Question
19
-     */
20
-    protected static $_instance;
17
+	/**
18
+	 * @var EEM_Question_Group_Question
19
+	 */
20
+	protected static $_instance;
21 21
 
22 22
 
23
-    /**
24
-     * EEM_Question_Group_Question constructor.
25
-     *
26
-     * @param string $timezone
27
-     * @throws EE_Error
28
-     */
29
-    protected function __construct(string $timezone = '')
30
-    {
31
-        $this->singular_item    = esc_html__('Question Group to Question Link', 'event_espresso');
32
-        $this->plural_item      = esc_html__('Question Group to Question Links', 'event_espresso');
33
-        $this->_tables          = [
34
-            'Question_Group_Question' => new EE_Primary_Table('esp_question_group_question', 'QGQ_ID'),
35
-        ];
36
-        $this->_fields          = [
37
-            'Question_Group_Question' => [
38
-                'QGQ_ID'    => new EE_Primary_Key_Int_Field(
39
-                    'QGQ_ID',
40
-                    esc_html__('Question Group to Question Link ID', 'event_espresso')
41
-                ),
42
-                'QSG_ID'    => new EE_Foreign_Key_Int_Field(
43
-                    'QSG_ID',
44
-                    esc_html__('Question Group ID', 'event_espresso'),
45
-                    false,
46
-                    0,
47
-                    'Question_Group'
48
-                ),
49
-                'QST_ID'    => new EE_Foreign_Key_Int_Field(
50
-                    'QST_ID',
51
-                    esc_html__('Question Id', 'event_espresso'),
52
-                    false,
53
-                    0,
54
-                    'Question'
55
-                ),
56
-                'QGQ_order' => new EE_Integer_Field(
57
-                    'QGQ_order',
58
-                    esc_html__('Question Group Question Order', 'event_espresso'),
59
-                    false,
60
-                    0
61
-                ),
62
-            ],
63
-        ];
64
-        $this->_model_relations = [
65
-            'Question_Group' => new EE_Belongs_To_Relation(),
66
-            'Question'       => new EE_Belongs_To_Relation(),
67
-        ];
23
+	/**
24
+	 * EEM_Question_Group_Question constructor.
25
+	 *
26
+	 * @param string $timezone
27
+	 * @throws EE_Error
28
+	 */
29
+	protected function __construct(string $timezone = '')
30
+	{
31
+		$this->singular_item    = esc_html__('Question Group to Question Link', 'event_espresso');
32
+		$this->plural_item      = esc_html__('Question Group to Question Links', 'event_espresso');
33
+		$this->_tables          = [
34
+			'Question_Group_Question' => new EE_Primary_Table('esp_question_group_question', 'QGQ_ID'),
35
+		];
36
+		$this->_fields          = [
37
+			'Question_Group_Question' => [
38
+				'QGQ_ID'    => new EE_Primary_Key_Int_Field(
39
+					'QGQ_ID',
40
+					esc_html__('Question Group to Question Link ID', 'event_espresso')
41
+				),
42
+				'QSG_ID'    => new EE_Foreign_Key_Int_Field(
43
+					'QSG_ID',
44
+					esc_html__('Question Group ID', 'event_espresso'),
45
+					false,
46
+					0,
47
+					'Question_Group'
48
+				),
49
+				'QST_ID'    => new EE_Foreign_Key_Int_Field(
50
+					'QST_ID',
51
+					esc_html__('Question Id', 'event_espresso'),
52
+					false,
53
+					0,
54
+					'Question'
55
+				),
56
+				'QGQ_order' => new EE_Integer_Field(
57
+					'QGQ_order',
58
+					esc_html__('Question Group Question Order', 'event_espresso'),
59
+					false,
60
+					0
61
+				),
62
+			],
63
+		];
64
+		$this->_model_relations = [
65
+			'Question_Group' => new EE_Belongs_To_Relation(),
66
+			'Question'       => new EE_Belongs_To_Relation(),
67
+		];
68 68
 
69
-        $this->_model_chain_to_wp_user = 'Question_Group';
69
+		$this->_model_chain_to_wp_user = 'Question_Group';
70 70
 
71
-        // this model is generally available for reading
72
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ]       = new EE_Restriction_Generator_Public();
73
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form(
74
-                'Question_Group.QSG_system'
75
-            );
76
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ]       = new EE_Restriction_Generator_Reg_Form(
77
-                'Question_Group.QSG_system'
78
-            );
79
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ]     = new EE_Restriction_Generator_Reg_Form(
80
-                'Question_Group.QSG_system'
81
-            );
71
+		// this model is generally available for reading
72
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ]       = new EE_Restriction_Generator_Public();
73
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form(
74
+				'Question_Group.QSG_system'
75
+			);
76
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ]       = new EE_Restriction_Generator_Reg_Form(
77
+				'Question_Group.QSG_system'
78
+			);
79
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ]     = new EE_Restriction_Generator_Reg_Form(
80
+				'Question_Group.QSG_system'
81
+			);
82 82
 
83
-        // use the caps for question groups
84
-        $this->_caps_slug = 'question_groups';
85
-        parent::__construct($timezone);
86
-    }
83
+		// use the caps for question groups
84
+		$this->_caps_slug = 'question_groups';
85
+		parent::__construct($timezone);
86
+	}
87 87
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -69,14 +69,14 @@
 block discarded – undo
69 69
         $this->_model_chain_to_wp_user = 'Question_Group';
70 70
 
71 71
         // this model is generally available for reading
72
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ]       = new EE_Restriction_Generator_Public();
73
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form(
72
+        $this->_cap_restriction_generators[EEM_Base::caps_read]       = new EE_Restriction_Generator_Public();
73
+        $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Reg_Form(
74 74
                 'Question_Group.QSG_system'
75 75
             );
76
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ]       = new EE_Restriction_Generator_Reg_Form(
76
+        $this->_cap_restriction_generators[EEM_Base::caps_edit]       = new EE_Restriction_Generator_Reg_Form(
77 77
                 'Question_Group.QSG_system'
78 78
             );
79
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ]     = new EE_Restriction_Generator_Reg_Form(
79
+        $this->_cap_restriction_generators[EEM_Base::caps_delete]     = new EE_Restriction_Generator_Reg_Form(
80 80
                 'Question_Group.QSG_system'
81 81
             );
82 82
 
Please login to merge, or discard this patch.
core/db_models/EEM_Event_Venue.model.php 2 patches
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -9,68 +9,68 @@
 block discarded – undo
9 9
  */
10 10
 class EEM_Event_Venue extends EEM_Base
11 11
 {
12
-    // private instance of the Attendee object
13
-    protected static $_instance;
12
+	// private instance of the Attendee object
13
+	protected static $_instance;
14 14
 
15 15
 
16
-    protected function __construct(string $timezone = '')
17
-    {
18
-        $this->singular_item    = esc_html__('Event to Question Group Link', 'event_espresso');
19
-        $this->plural_item      = esc_html__('Event to Question Group Links', 'event_espresso');
20
-        $this->_tables          = [
21
-            'Event_Venue' => new EE_Primary_Table('esp_event_venue', 'EVV_ID'),
22
-        ];
23
-        $this->_fields          = [
24
-            'Event_Venue' => [
25
-                'EVV_ID'      => new EE_Primary_Key_Int_Field(
26
-                    'EVV_ID',
27
-                    esc_html__('Event to Venue Link ID', 'event_espresso')
28
-                ),
29
-                'EVT_ID'      => new EE_Foreign_Key_Int_Field(
30
-                    'EVT_ID',
31
-                    esc_html__('Event ID', 'event_espresso'),
32
-                    false,
33
-                    0,
34
-                    'Event'
35
-                ),
36
-                'VNU_ID'      => new EE_Foreign_Key_Int_Field(
37
-                    'VNU_ID',
38
-                    esc_html__('Venue ID', 'event_espresso'),
39
-                    false,
40
-                    0,
41
-                    'Venue'
42
-                ),
43
-                'EVV_primary' => new EE_Boolean_Field(
44
-                    'EVV_primary',
45
-                    esc_html__("Flag indicating venue is primary one for event", "event_espresso"),
46
-                    false,
47
-                    true
48
-                ),
16
+	protected function __construct(string $timezone = '')
17
+	{
18
+		$this->singular_item    = esc_html__('Event to Question Group Link', 'event_espresso');
19
+		$this->plural_item      = esc_html__('Event to Question Group Links', 'event_espresso');
20
+		$this->_tables          = [
21
+			'Event_Venue' => new EE_Primary_Table('esp_event_venue', 'EVV_ID'),
22
+		];
23
+		$this->_fields          = [
24
+			'Event_Venue' => [
25
+				'EVV_ID'      => new EE_Primary_Key_Int_Field(
26
+					'EVV_ID',
27
+					esc_html__('Event to Venue Link ID', 'event_espresso')
28
+				),
29
+				'EVT_ID'      => new EE_Foreign_Key_Int_Field(
30
+					'EVT_ID',
31
+					esc_html__('Event ID', 'event_espresso'),
32
+					false,
33
+					0,
34
+					'Event'
35
+				),
36
+				'VNU_ID'      => new EE_Foreign_Key_Int_Field(
37
+					'VNU_ID',
38
+					esc_html__('Venue ID', 'event_espresso'),
39
+					false,
40
+					0,
41
+					'Venue'
42
+				),
43
+				'EVV_primary' => new EE_Boolean_Field(
44
+					'EVV_primary',
45
+					esc_html__("Flag indicating venue is primary one for event", "event_espresso"),
46
+					false,
47
+					true
48
+				),
49 49
 
50
-            ],
51
-        ];
52
-        $this->_model_relations = [
53
-            'Event' => new EE_Belongs_To_Relation(),
54
-            'Venue' => new EE_Belongs_To_Relation(),
55
-        ];
56
-        // this model is generally available for reading
57
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public(
58
-            'Event'
59
-        );
60
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ]
61
-                                                                  = new EE_Restriction_Generator_Event_Related_Protected(
62
-            'Event'
63
-        );
64
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ]
65
-                                                                  = new EE_Restriction_Generator_Event_Related_Protected(
66
-            'Event'
67
-        );
68
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ]
69
-                                                                  = new EE_Restriction_Generator_Event_Related_Protected(
70
-            'Event',
71
-            EEM_Base::caps_edit
72
-        );
73
-        $this->model_chain_to_password                            = 'Event';
74
-        parent::__construct($timezone);
75
-    }
50
+			],
51
+		];
52
+		$this->_model_relations = [
53
+			'Event' => new EE_Belongs_To_Relation(),
54
+			'Venue' => new EE_Belongs_To_Relation(),
55
+		];
56
+		// this model is generally available for reading
57
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public(
58
+			'Event'
59
+		);
60
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ]
61
+																  = new EE_Restriction_Generator_Event_Related_Protected(
62
+			'Event'
63
+		);
64
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ]
65
+																  = new EE_Restriction_Generator_Event_Related_Protected(
66
+			'Event'
67
+		);
68
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ]
69
+																  = new EE_Restriction_Generator_Event_Related_Protected(
70
+			'Event',
71
+			EEM_Base::caps_edit
72
+		);
73
+		$this->model_chain_to_password                            = 'Event';
74
+		parent::__construct($timezone);
75
+	}
76 76
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -54,23 +54,23 @@
 block discarded – undo
54 54
             'Venue' => new EE_Belongs_To_Relation(),
55 55
         ];
56 56
         // this model is generally available for reading
57
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public(
57
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public(
58 58
             'Event'
59 59
         );
60
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ]
60
+        $this->_cap_restriction_generators[EEM_Base::caps_read_admin]
61 61
                                                                   = new EE_Restriction_Generator_Event_Related_Protected(
62 62
             'Event'
63 63
         );
64
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ]
64
+        $this->_cap_restriction_generators[EEM_Base::caps_edit]
65 65
                                                                   = new EE_Restriction_Generator_Event_Related_Protected(
66 66
             'Event'
67 67
         );
68
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ]
68
+        $this->_cap_restriction_generators[EEM_Base::caps_delete]
69 69
                                                                   = new EE_Restriction_Generator_Event_Related_Protected(
70 70
             'Event',
71 71
             EEM_Base::caps_edit
72 72
         );
73
-        $this->model_chain_to_password                            = 'Event';
73
+        $this->model_chain_to_password = 'Event';
74 74
         parent::__construct($timezone);
75 75
     }
76 76
 }
Please login to merge, or discard this patch.
core/db_models/EEM_WP_User.model.php 1 patch
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -13,132 +13,132 @@
 block discarded – undo
13 13
 class EEM_WP_User extends EEM_Base
14 14
 {
15 15
 
16
-    /**
17
-     * private instance of the EEM_WP_User object
18
-     *
19
-     * @type EEM_WP_User
20
-     */
21
-    protected static $_instance;
16
+	/**
17
+	 * private instance of the EEM_WP_User object
18
+	 *
19
+	 * @type EEM_WP_User
20
+	 */
21
+	protected static $_instance;
22 22
 
23 23
 
24
-    /**
25
-     *    constructor
26
-     *
27
-     * @param string                 $timezone
28
-     * @param ModelFieldFactory|null $model_field_factory
29
-     * @throws EE_Error
30
-     */
31
-    protected function __construct(string $timezone = '', ModelFieldFactory $model_field_factory = null)
32
-    {
33
-        $this->singular_item = esc_html__('WP_User', 'event_espresso');
34
-        $this->plural_item = esc_html__('WP_Users', 'event_espresso');
35
-        global $wpdb;
36
-        $this->_tables = array(
37
-            'WP_User' => new EE_Primary_Table($wpdb->users, 'ID', true),
38
-        );
39
-        $this->_fields = array(
40
-            'WP_User' => array(
41
-                'ID'                  => $model_field_factory->createPrimaryKeyIntField(
42
-                    'ID',
43
-                    esc_html__('WP_User ID', 'event_espresso')
44
-                ),
45
-                'user_login'          => $model_field_factory->createPlainTextField(
46
-                    'user_login',
47
-                    esc_html__('User Login', 'event_espresso'),
48
-                    false
49
-                ),
50
-                'user_pass'           => $model_field_factory->createPlainTextField(
51
-                    'user_pass',
52
-                    esc_html__('User Password', 'event_espresso'),
53
-                    false
54
-                ),
55
-                'user_nicename'       => $model_field_factory->createPlainTextField(
56
-                    'user_nicename',
57
-                    esc_html__(' User Nice Name', 'event_espresso'),
58
-                    false
59
-                ),
60
-                'user_email'          => $model_field_factory->createEmailField(
61
-                    'user_email',
62
-                    esc_html__('User Email', 'event_espresso'),
63
-                    false,
64
-                    null
65
-                ),
66
-                'user_registered'     => $model_field_factory->createDatetimeField(
67
-                    'user_registered',
68
-                    esc_html__('Date User Registered', 'event_espresso'),
69
-                    $timezone
70
-                ),
71
-                'user_activation_key' => $model_field_factory->createPlainTextField(
72
-                    'user_activation_key',
73
-                    esc_html__('User Activation Key', 'event_espresso'),
74
-                    false
75
-                ),
76
-                'user_status'         => $model_field_factory->createIntegerField(
77
-                    'user_status',
78
-                    esc_html__('User Status', 'event_espresso')
79
-                ),
80
-                'display_name'        => $model_field_factory->createPlainTextField(
81
-                    'display_name',
82
-                    esc_html__('Display Name', 'event_espresso'),
83
-                    false
84
-                ),
85
-            ),
86
-        );
87
-        $this->_model_relations = array(
88
-            'Attendee'       => new EE_Has_Many_Relation(),
89
-            // all models are related to the change log
90
-            // 'Change_Log'     => new EE_Has_Many_Relation(),
91
-            'Event'          => new EE_Has_Many_Relation(),
92
-            'Message'        => new EE_Has_Many_Relation(),
93
-            'Payment_Method' => new EE_Has_Many_Relation(),
94
-            'Price'          => new EE_Has_Many_Relation(),
95
-            'Price_Type'     => new EE_Has_Many_Relation(),
96
-            'Question'       => new EE_Has_Many_Relation(),
97
-            'Question_Group' => new EE_Has_Many_Relation(),
98
-            'Ticket'         => new EE_Has_Many_Relation(),
99
-            'Venue'          => new EE_Has_Many_Relation(),
100
-        );
101
-        $this->foreign_key_aliases = [
102
-            'Event.EVT_wp_user'          => 'WP_User.ID',
103
-            'Payment_Method.PMD_wp_user' => 'WP_User.ID',
104
-            'Price.PRC_wp_user'          => 'WP_User.ID',
105
-            'Price_Type.PRT_wp_user'     => 'WP_User.ID',
106
-            'Question.QST_wp_user'       => 'WP_User.ID',
107
-            'Question_Group.QSG_wp_user' => 'WP_User.ID',
108
-            'Ticket.VNU_wp_user'         => 'WP_User.ID',
109
-            'Venue.TKT_wp_user'          => 'WP_User.ID',
110
-        ];
111
-        $this->_wp_core_model = true;
112
-        $this->_caps_slug = 'users';
113
-        $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read ] = 'list';
114
-        $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read_admin ] = 'list';
115
-        foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) {
116
-            $this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_WP_User();
117
-        }
118
-        // @todo: account for create_users controls whether they can create users at all
119
-        parent::__construct($timezone);
120
-    }
24
+	/**
25
+	 *    constructor
26
+	 *
27
+	 * @param string                 $timezone
28
+	 * @param ModelFieldFactory|null $model_field_factory
29
+	 * @throws EE_Error
30
+	 */
31
+	protected function __construct(string $timezone = '', ModelFieldFactory $model_field_factory = null)
32
+	{
33
+		$this->singular_item = esc_html__('WP_User', 'event_espresso');
34
+		$this->plural_item = esc_html__('WP_Users', 'event_espresso');
35
+		global $wpdb;
36
+		$this->_tables = array(
37
+			'WP_User' => new EE_Primary_Table($wpdb->users, 'ID', true),
38
+		);
39
+		$this->_fields = array(
40
+			'WP_User' => array(
41
+				'ID'                  => $model_field_factory->createPrimaryKeyIntField(
42
+					'ID',
43
+					esc_html__('WP_User ID', 'event_espresso')
44
+				),
45
+				'user_login'          => $model_field_factory->createPlainTextField(
46
+					'user_login',
47
+					esc_html__('User Login', 'event_espresso'),
48
+					false
49
+				),
50
+				'user_pass'           => $model_field_factory->createPlainTextField(
51
+					'user_pass',
52
+					esc_html__('User Password', 'event_espresso'),
53
+					false
54
+				),
55
+				'user_nicename'       => $model_field_factory->createPlainTextField(
56
+					'user_nicename',
57
+					esc_html__(' User Nice Name', 'event_espresso'),
58
+					false
59
+				),
60
+				'user_email'          => $model_field_factory->createEmailField(
61
+					'user_email',
62
+					esc_html__('User Email', 'event_espresso'),
63
+					false,
64
+					null
65
+				),
66
+				'user_registered'     => $model_field_factory->createDatetimeField(
67
+					'user_registered',
68
+					esc_html__('Date User Registered', 'event_espresso'),
69
+					$timezone
70
+				),
71
+				'user_activation_key' => $model_field_factory->createPlainTextField(
72
+					'user_activation_key',
73
+					esc_html__('User Activation Key', 'event_espresso'),
74
+					false
75
+				),
76
+				'user_status'         => $model_field_factory->createIntegerField(
77
+					'user_status',
78
+					esc_html__('User Status', 'event_espresso')
79
+				),
80
+				'display_name'        => $model_field_factory->createPlainTextField(
81
+					'display_name',
82
+					esc_html__('Display Name', 'event_espresso'),
83
+					false
84
+				),
85
+			),
86
+		);
87
+		$this->_model_relations = array(
88
+			'Attendee'       => new EE_Has_Many_Relation(),
89
+			// all models are related to the change log
90
+			// 'Change_Log'     => new EE_Has_Many_Relation(),
91
+			'Event'          => new EE_Has_Many_Relation(),
92
+			'Message'        => new EE_Has_Many_Relation(),
93
+			'Payment_Method' => new EE_Has_Many_Relation(),
94
+			'Price'          => new EE_Has_Many_Relation(),
95
+			'Price_Type'     => new EE_Has_Many_Relation(),
96
+			'Question'       => new EE_Has_Many_Relation(),
97
+			'Question_Group' => new EE_Has_Many_Relation(),
98
+			'Ticket'         => new EE_Has_Many_Relation(),
99
+			'Venue'          => new EE_Has_Many_Relation(),
100
+		);
101
+		$this->foreign_key_aliases = [
102
+			'Event.EVT_wp_user'          => 'WP_User.ID',
103
+			'Payment_Method.PMD_wp_user' => 'WP_User.ID',
104
+			'Price.PRC_wp_user'          => 'WP_User.ID',
105
+			'Price_Type.PRT_wp_user'     => 'WP_User.ID',
106
+			'Question.QST_wp_user'       => 'WP_User.ID',
107
+			'Question_Group.QSG_wp_user' => 'WP_User.ID',
108
+			'Ticket.VNU_wp_user'         => 'WP_User.ID',
109
+			'Venue.TKT_wp_user'          => 'WP_User.ID',
110
+		];
111
+		$this->_wp_core_model = true;
112
+		$this->_caps_slug = 'users';
113
+		$this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read ] = 'list';
114
+		$this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read_admin ] = 'list';
115
+		foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) {
116
+			$this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_WP_User();
117
+		}
118
+		// @todo: account for create_users controls whether they can create users at all
119
+		parent::__construct($timezone);
120
+	}
121 121
 
122 122
 
123
-    /**
124
-     * We don't need a foreign key to the WP_User model, we just need its primary key
125
-     *
126
-     * @return string
127
-     * @throws EE_Error
128
-     */
129
-    public function wp_user_field_name(): string
130
-    {
131
-        return $this->primary_key_name();
132
-    }
123
+	/**
124
+	 * We don't need a foreign key to the WP_User model, we just need its primary key
125
+	 *
126
+	 * @return string
127
+	 * @throws EE_Error
128
+	 */
129
+	public function wp_user_field_name(): string
130
+	{
131
+		return $this->primary_key_name();
132
+	}
133 133
 
134 134
 
135
-    /**
136
-     * This WP_User model IS owned, even though it doesn't have a foreign key to itself
137
-     *
138
-     * @return boolean
139
-     */
140
-    public function is_owned(): bool
141
-    {
142
-        return true;
143
-    }
135
+	/**
136
+	 * This WP_User model IS owned, even though it doesn't have a foreign key to itself
137
+	 *
138
+	 * @return boolean
139
+	 */
140
+	public function is_owned(): bool
141
+	{
142
+		return true;
143
+	}
144 144
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Datetime_Ticket.model.php 2 patches
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -11,77 +11,77 @@
 block discarded – undo
11 11
 {
12 12
 
13 13
 
14
-    // private instance of the EEM_Datetime_Ticket object
15
-    protected static $_instance;
14
+	// private instance of the EEM_Datetime_Ticket object
15
+	protected static $_instance;
16 16
 
17 17
 
18
-    /**
19
-     *      private constructor to prevent direct creation
20
-     *
21
-     * @Constructor
22
-     * @access private
23
-     * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any
24
-     *                         incoming timezone data that gets saved).  Note this just sends the timezone info to the
25
-     *                         date time model field objects.  Default is NULL (and will be assumed using the set
26
-     *                         timezone in the 'timezone_string' wp option)
27
-     * @return void
28
-     * @throws EE_Error
29
-     */
30
-    protected function __construct(string $timezone = '')
31
-    {
32
-        $this->singular_item = esc_html__('Datetime Ticket', 'event_espresso');
33
-        $this->plural_item   = esc_html__('Datetime Tickets', 'event_espresso');
18
+	/**
19
+	 *      private constructor to prevent direct creation
20
+	 *
21
+	 * @Constructor
22
+	 * @access private
23
+	 * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any
24
+	 *                         incoming timezone data that gets saved).  Note this just sends the timezone info to the
25
+	 *                         date time model field objects.  Default is NULL (and will be assumed using the set
26
+	 *                         timezone in the 'timezone_string' wp option)
27
+	 * @return void
28
+	 * @throws EE_Error
29
+	 */
30
+	protected function __construct(string $timezone = '')
31
+	{
32
+		$this->singular_item = esc_html__('Datetime Ticket', 'event_espresso');
33
+		$this->plural_item   = esc_html__('Datetime Tickets', 'event_espresso');
34 34
 
35
-        $this->_tables          = [
36
-            'Datetime_Ticket' => new EE_Primary_Table(
37
-                'esp_datetime_ticket',
38
-                'DTK_ID'
39
-            ),
40
-        ];
41
-        $this->_fields          = [
42
-            'Datetime_Ticket' => [
43
-                'DTK_ID' => new EE_Primary_Key_Int_Field(
44
-                    'DTK_ID',
45
-                    esc_html__('Datetime Ticket ID', 'event_espresso')
46
-                ),
47
-                'DTT_ID' => new EE_Foreign_Key_Int_Field(
48
-                    'DTT_ID',
49
-                    esc_html__('The ID to the Datetime', 'event_espresso'),
50
-                    false,
51
-                    0,
52
-                    'Datetime'
53
-                ),
54
-                'TKT_ID' => new EE_Foreign_Key_Int_Field(
55
-                    'TKT_ID',
56
-                    esc_html__('The ID to the Ticket', 'event_espresso'),
57
-                    false,
58
-                    0,
59
-                    'Ticket'
60
-                ),
61
-            ],
62
-        ];
63
-        $this->_model_relations = [
64
-            'Ticket'   => new EE_Belongs_To_Relation(),
65
-            'Datetime' => new EE_Belongs_To_Relation(),
66
-        ];
67
-        // this model is generally available for reading
68
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public(
69
-            'Datetime.Event'
70
-        );
71
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ]
72
-                                                                  = new EE_Restriction_Generator_Event_Related_Protected(
73
-            'Datetime.Event'
74
-        );
75
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ]
76
-                                                                  = new EE_Restriction_Generator_Event_Related_Protected(
77
-            'Datetime.Event'
78
-        );
79
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ]
80
-                                                                  = new EE_Restriction_Generator_Event_Related_Protected(
81
-            'Datetime.Event',
82
-            EEM_Base::caps_edit
83
-        );
84
-        $this->model_chain_to_password                            = 'Datetime.Event';
85
-        parent::__construct($timezone);
86
-    }
35
+		$this->_tables          = [
36
+			'Datetime_Ticket' => new EE_Primary_Table(
37
+				'esp_datetime_ticket',
38
+				'DTK_ID'
39
+			),
40
+		];
41
+		$this->_fields          = [
42
+			'Datetime_Ticket' => [
43
+				'DTK_ID' => new EE_Primary_Key_Int_Field(
44
+					'DTK_ID',
45
+					esc_html__('Datetime Ticket ID', 'event_espresso')
46
+				),
47
+				'DTT_ID' => new EE_Foreign_Key_Int_Field(
48
+					'DTT_ID',
49
+					esc_html__('The ID to the Datetime', 'event_espresso'),
50
+					false,
51
+					0,
52
+					'Datetime'
53
+				),
54
+				'TKT_ID' => new EE_Foreign_Key_Int_Field(
55
+					'TKT_ID',
56
+					esc_html__('The ID to the Ticket', 'event_espresso'),
57
+					false,
58
+					0,
59
+					'Ticket'
60
+				),
61
+			],
62
+		];
63
+		$this->_model_relations = [
64
+			'Ticket'   => new EE_Belongs_To_Relation(),
65
+			'Datetime' => new EE_Belongs_To_Relation(),
66
+		];
67
+		// this model is generally available for reading
68
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public(
69
+			'Datetime.Event'
70
+		);
71
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ]
72
+																  = new EE_Restriction_Generator_Event_Related_Protected(
73
+			'Datetime.Event'
74
+		);
75
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ]
76
+																  = new EE_Restriction_Generator_Event_Related_Protected(
77
+			'Datetime.Event'
78
+		);
79
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ]
80
+																  = new EE_Restriction_Generator_Event_Related_Protected(
81
+			'Datetime.Event',
82
+			EEM_Base::caps_edit
83
+		);
84
+		$this->model_chain_to_password                            = 'Datetime.Event';
85
+		parent::__construct($timezone);
86
+	}
87 87
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -32,13 +32,13 @@  discard block
 block discarded – undo
32 32
         $this->singular_item = esc_html__('Datetime Ticket', 'event_espresso');
33 33
         $this->plural_item   = esc_html__('Datetime Tickets', 'event_espresso');
34 34
 
35
-        $this->_tables          = [
35
+        $this->_tables = [
36 36
             'Datetime_Ticket' => new EE_Primary_Table(
37 37
                 'esp_datetime_ticket',
38 38
                 'DTK_ID'
39 39
             ),
40 40
         ];
41
-        $this->_fields          = [
41
+        $this->_fields = [
42 42
             'Datetime_Ticket' => [
43 43
                 'DTK_ID' => new EE_Primary_Key_Int_Field(
44 44
                     'DTK_ID',
@@ -65,23 +65,23 @@  discard block
 block discarded – undo
65 65
             'Datetime' => new EE_Belongs_To_Relation(),
66 66
         ];
67 67
         // this model is generally available for reading
68
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public(
68
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public(
69 69
             'Datetime.Event'
70 70
         );
71
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ]
71
+        $this->_cap_restriction_generators[EEM_Base::caps_read_admin]
72 72
                                                                   = new EE_Restriction_Generator_Event_Related_Protected(
73 73
             'Datetime.Event'
74 74
         );
75
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ]
75
+        $this->_cap_restriction_generators[EEM_Base::caps_edit]
76 76
                                                                   = new EE_Restriction_Generator_Event_Related_Protected(
77 77
             'Datetime.Event'
78 78
         );
79
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ]
79
+        $this->_cap_restriction_generators[EEM_Base::caps_delete]
80 80
                                                                   = new EE_Restriction_Generator_Event_Related_Protected(
81 81
             'Datetime.Event',
82 82
             EEM_Base::caps_edit
83 83
         );
84
-        $this->model_chain_to_password                            = 'Datetime.Event';
84
+        $this->model_chain_to_password = 'Datetime.Event';
85 85
         parent::__construct($timezone);
86 86
     }
87 87
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Status.model.php 2 patches
Indentation   +310 added lines, -310 removed lines patch added patch discarded remove patch
@@ -10,325 +10,325 @@
 block discarded – undo
10 10
 class EEM_Status extends EEM_Base
11 11
 {
12 12
 
13
-    /**
14
-     * @var EEM_Status
15
-     */
16
-    protected static $_instance;
13
+	/**
14
+	 * @var EEM_Status
15
+	 */
16
+	protected static $_instance;
17 17
 
18 18
 
19
-    /**
20
-     * EEM_Status constructor.
21
-     *
22
-     * @param string $timezone
23
-     * @throws EE_Error
24
-     */
25
-    protected function __construct(string $timezone = '')
26
-    {
27
-        $this->singular_item    = esc_html__('Status', 'event_espresso');
28
-        $this->plural_item      = esc_html__('Stati', 'event_espresso');
29
-        $this->_tables          = [
30
-            'StatusTable' => new EE_Primary_Table('esp_status', 'STS_ID'),
31
-        ];
32
-        $this->_fields          = [
33
-            'StatusTable' => [
34
-                'STS_ID'       => new EE_Primary_Key_String_Field(
35
-                    'STS_ID',
36
-                    esc_html__('Status ID', 'event_espresso')
37
-                ),
38
-                'STS_code'     => new EE_Plain_Text_Field(
39
-                    'STS_code',
40
-                    esc_html__('Status Code', 'event_espresso'),
41
-                    false,
42
-                    ''
43
-                ),
44
-                'STS_type'     => new EE_Enum_Text_Field(
45
-                    'STS_type',
46
-                    esc_html__("Type", "event_espresso"),
47
-                    false,
48
-                    'event',
49
-                    [
50
-                        'event'        => esc_html__("Event", "event_espresso"),// deprecated
51
-                        'registration' => esc_html__("Registration", "event_espresso"),
52
-                        'transaction'  => esc_html__("Transaction", "event_espresso"),
53
-                        'payment'      => esc_html__("Payment", "event_espresso"),
54
-                        'email'        => esc_html__("Email", "event_espresso"),
55
-                        'message'      => esc_html__("Message", "event_espresso"),
56
-                    ]
57
-                ),
58
-                'STS_can_edit' => new EE_Boolean_Field(
59
-                    'STS_can_edit',
60
-                    esc_html__('Editable?', 'event_espresso'),
61
-                    false,
62
-                    false
63
-                ),
64
-                'STS_desc'     => new EE_Simple_HTML_Field(
65
-                    'STS_desc',
66
-                    esc_html__("Description", "event_espresso"),
67
-                    false,
68
-                    ''
69
-                ),
70
-                'STS_open'     => new EE_Boolean_Field(
71
-                    'STS_open',
72
-                    esc_html__("Open?", "event_espresso"),
73
-                    false,
74
-                    false
75
-                ),
76
-            ],
77
-        ];
78
-        $this->_model_relations = [
79
-            'Registration' => new EE_Has_Many_Relation(),
80
-            'Transaction'  => new EE_Has_Many_Relation(),
81
-            'Payment'      => new EE_Has_Many_Relation(),
82
-        ];
83
-        // this model is generally available for reading
84
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
19
+	/**
20
+	 * EEM_Status constructor.
21
+	 *
22
+	 * @param string $timezone
23
+	 * @throws EE_Error
24
+	 */
25
+	protected function __construct(string $timezone = '')
26
+	{
27
+		$this->singular_item    = esc_html__('Status', 'event_espresso');
28
+		$this->plural_item      = esc_html__('Stati', 'event_espresso');
29
+		$this->_tables          = [
30
+			'StatusTable' => new EE_Primary_Table('esp_status', 'STS_ID'),
31
+		];
32
+		$this->_fields          = [
33
+			'StatusTable' => [
34
+				'STS_ID'       => new EE_Primary_Key_String_Field(
35
+					'STS_ID',
36
+					esc_html__('Status ID', 'event_espresso')
37
+				),
38
+				'STS_code'     => new EE_Plain_Text_Field(
39
+					'STS_code',
40
+					esc_html__('Status Code', 'event_espresso'),
41
+					false,
42
+					''
43
+				),
44
+				'STS_type'     => new EE_Enum_Text_Field(
45
+					'STS_type',
46
+					esc_html__("Type", "event_espresso"),
47
+					false,
48
+					'event',
49
+					[
50
+						'event'        => esc_html__("Event", "event_espresso"),// deprecated
51
+						'registration' => esc_html__("Registration", "event_espresso"),
52
+						'transaction'  => esc_html__("Transaction", "event_espresso"),
53
+						'payment'      => esc_html__("Payment", "event_espresso"),
54
+						'email'        => esc_html__("Email", "event_espresso"),
55
+						'message'      => esc_html__("Message", "event_espresso"),
56
+					]
57
+				),
58
+				'STS_can_edit' => new EE_Boolean_Field(
59
+					'STS_can_edit',
60
+					esc_html__('Editable?', 'event_espresso'),
61
+					false,
62
+					false
63
+				),
64
+				'STS_desc'     => new EE_Simple_HTML_Field(
65
+					'STS_desc',
66
+					esc_html__("Description", "event_espresso"),
67
+					false,
68
+					''
69
+				),
70
+				'STS_open'     => new EE_Boolean_Field(
71
+					'STS_open',
72
+					esc_html__("Open?", "event_espresso"),
73
+					false,
74
+					false
75
+				),
76
+			],
77
+		];
78
+		$this->_model_relations = [
79
+			'Registration' => new EE_Has_Many_Relation(),
80
+			'Transaction'  => new EE_Has_Many_Relation(),
81
+			'Payment'      => new EE_Has_Many_Relation(),
82
+		];
83
+		// this model is generally available for reading
84
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
85 85
 
86
-        parent::__construct($timezone);
87
-    }
86
+		parent::__construct($timezone);
87
+	}
88 88
 
89 89
 
90
-    /**
91
-     * This method provides the localized singular or plural string for a given status id
92
-     *
93
-     * @param array   $statuses  This should be an array of statuses in the format array( $status_id, $status_code ).
94
-     *                           That way if there isn't a translation in the index we'll return the default code.
95
-     * @param boolean $plural    Whether to return plural string or not. Note, nearly all of the plural strings are the
96
-     *                           same as the singular (in English), however, this may NOT be the case with other
97
-     *                           languages
98
-     * @param string  $schema    This can be either 'upper', 'lower', or 'sentence'.  Basically indicates how we want
99
-     *                           the status string returned ( UPPER, lower, Sentence)
100
-     * @return array             an array of translated strings for the incoming status id.
101
-     * @throws EE_Error
102
-     */
103
-    public function localized_status(array $statuses, bool $plural = false, string $schema = 'upper'): array
104
-    {
105
-        // note these are all in lower case because ucwords() on upper case will NOT convert.
106
-        $translation_array = [
107
-            EEM_Registration::status_id_pending_payment => [
108
-                esc_html__('pending payment', 'event_espresso'), // singular
109
-                esc_html__('pending payments', 'event_espresso') // plural
110
-            ],
111
-            EEM_Registration::status_id_approved        => [
112
-                esc_html__('approved', 'event_espresso'), // singular
113
-                esc_html__('approved', 'event_espresso') // plural
114
-            ],
115
-            EEM_Registration::status_id_not_approved    => [
116
-                esc_html__('not approved', 'event_espresso'),
117
-                esc_html__('not approved', 'event_espresso'),
118
-            ],
119
-            EEM_Registration::status_id_cancelled       => [
120
-                esc_html__('cancelled', 'event_espresso'),
121
-                esc_html__('cancelled', 'event_espresso'),
122
-            ],
123
-            EEM_Registration::status_id_incomplete      => [
124
-                esc_html__('incomplete', 'event_espresso'),
125
-                esc_html__('incomplete', 'event_espresso'),
126
-            ],
127
-            EEM_Registration::status_id_declined        => [
128
-                esc_html__('declined', 'event_espresso'),
129
-                esc_html__('declined', 'event_espresso'),
130
-            ],
131
-            EEM_Registration::status_id_wait_list       => [
132
-                esc_html__('wait list', 'event_espresso'),
133
-                esc_html__('wait list', 'event_espresso'),
134
-            ],
135
-            EEM_Transaction::overpaid_status_code       => [
136
-                esc_html__('overpaid', 'event_espresso'),
137
-                esc_html__('overpaid', 'event_espresso'),
138
-            ],
139
-            EEM_Transaction::complete_status_code       => [
140
-                esc_html__('complete', 'event_espresso'),
141
-                esc_html__('complete', 'event_espresso'),
142
-            ],
143
-            EEM_Transaction::incomplete_status_code     => [
144
-                esc_html__('incomplete', 'event_espresso'),
145
-                esc_html__('incomplete', 'event_espresso'),
146
-            ],
147
-            EEM_Transaction::failed_status_code         => [
148
-                esc_html__('failed', 'event_espresso'),
149
-                esc_html__('failed', 'event_espresso'),
150
-            ],
151
-            EEM_Transaction::abandoned_status_code      => [
152
-                esc_html__('abandoned', 'event_espresso'),
153
-                esc_html__('abandoned', 'event_espresso'),
154
-            ],
155
-            EEM_Payment::status_id_approved             => [
156
-                esc_html__('accepted', 'event_espresso'),
157
-                esc_html__('accepted', 'event_espresso'),
158
-            ],
159
-            EEM_Payment::status_id_pending              => [
160
-                esc_html__('pending', 'event_espresso'),
161
-                esc_html__('pending', 'event_espresso'),
162
-            ],
163
-            EEM_Payment::status_id_cancelled            => [
164
-                esc_html__('cancelled', 'event_espresso'),
165
-                esc_html__('cancelled', 'event_espresso'),
166
-            ],
167
-            EEM_Payment::status_id_declined             => [
168
-                esc_html__('declined', 'event_espresso'),
169
-                esc_html__('declined', 'event_espresso'),
170
-            ],
171
-            EEM_Payment::status_id_failed               => [
172
-                esc_html__('failed', 'event_espresso'),
173
-                esc_html__('failed', 'event_espresso'),
174
-            ],
175
-            // following statuses are NOT part of the EEM_Status but to keep things centralized we include in here.
176
-            EEM_Event::sold_out                         => [
177
-                esc_html__('sold out', 'event_espresso'),
178
-                esc_html__('sold out', 'event_espresso'),
179
-            ],
180
-            EEM_Event::postponed                        => [
181
-                esc_html__('postponed', 'event_espresso'),
182
-                esc_html__('Postponed', 'event_espresso'),
183
-            ],
184
-            EEM_Event::cancelled                        => [
185
-                esc_html__('cancelled', 'event_espresso'),
186
-                esc_html__('cancelled', 'event_espresso'),
187
-            ],
188
-            EE_Ticket::archived                         => [
189
-                esc_html__('archived', 'event_espresso'),
190
-                esc_html__('archived', 'event_espresso'),
191
-            ],
192
-            EE_Ticket::expired                          => [
193
-                esc_html__('expired', 'event_espresso'),
194
-                esc_html__('expired', 'event_espresso'),
195
-            ],
196
-            EE_Ticket::sold_out                         => [
197
-                esc_html__('sold out', 'event_espresso'),
198
-                esc_html__('sold out', 'event_espresso'),
199
-            ],
200
-            EE_Ticket::pending                          => [
201
-                esc_html__('upcoming', 'event_espresso'),
202
-                esc_html__('upcoming', 'event_espresso'),
203
-            ],
204
-            EE_Ticket::onsale                           => [
205
-                esc_html__('on sale', 'event_espresso'),
206
-                esc_html__('on sale', 'event_espresso'),
207
-            ],
208
-            EE_Datetime::cancelled                      => [
209
-                esc_html__('cancelled', 'event_espresso'),
210
-                esc_html__('cancelled', 'event_espresso'),
211
-            ],
212
-            EE_Datetime::sold_out                       => [
213
-                esc_html__('sold out', 'event_espresso'),
214
-                esc_html__('sold out', 'event_espresso'),
215
-            ],
216
-            EE_Datetime::expired                        => [
217
-                esc_html__('expired', 'event_espresso'),
218
-                esc_html__('expired', 'event_espresso'),
219
-            ],
220
-            EE_Datetime::inactive                       => [
221
-                esc_html__('inactive', 'event_espresso'),
222
-                esc_html__('inactive', 'event_espresso'),
223
-            ],
224
-            EE_Datetime::upcoming                       => [
225
-                esc_html__('upcoming', 'event_espresso'),
226
-                esc_html__('upcoming', 'event_espresso'),
227
-            ],
228
-            EE_Datetime::active                         => [
229
-                esc_html__('active', 'event_espresso'),
230
-                esc_html__('active', 'event_espresso'),
231
-            ],
232
-            EE_Datetime::postponed                      => [
233
-                esc_html__('postponed', 'event_espresso'),
234
-                esc_html__('postponed', 'event_espresso'),
235
-            ],
236
-            // messages related
237
-            EEM_Message::status_sent                    => [
238
-                esc_html__('sent', 'event_espresso'),
239
-                esc_html__('sent', 'event_espresso'),
240
-            ],
241
-            EEM_Message::status_idle                    => [
242
-                esc_html__('queued for sending', 'event_espresso'),
243
-                esc_html__('queued for sending', 'event_espresso'),
244
-            ],
245
-            EEM_Message::status_failed                  => [
246
-                esc_html__('failed', 'event_espresso'),
247
-                esc_html__('failed', 'event_espresso'),
248
-            ],
249
-            EEM_Message::status_debug_only              => [
250
-                esc_html__('debug only', 'event_espresso'),
251
-                esc_html__('debug only', 'event_espresso'),
252
-            ],
253
-            EEM_Message::status_messenger_executing     => [
254
-                esc_html__('messenger is executing', 'event_espresso'),
255
-                esc_html__('messenger is executing', 'event_espresso'),
256
-            ],
257
-            EEM_Message::status_resend                  => [
258
-                esc_html__('queued for resending', 'event_espresso'),
259
-                esc_html__('queued for resending', 'event_espresso'),
260
-            ],
261
-            EEM_Message::status_incomplete              => [
262
-                esc_html__('queued for generating', 'event_espresso'),
263
-                esc_html__('queued for generating', 'event_espresso'),
264
-            ],
265
-            EEM_Message::status_retry                   => [
266
-                esc_html__('failed sending, can be retried', 'event_espresso'),
267
-                esc_html__('failed sending, can be retried', 'event_espresso'),
268
-            ],
269
-            EEM_CPT_Base::post_status_publish           => [
270
-                esc_html__('published', 'event_espresso'),
271
-                esc_html__('published', 'event_espresso'),
272
-            ],
273
-            EEM_CPT_Base::post_status_future            => [
274
-                esc_html__('scheduled', 'event_espresso'),
275
-                esc_html__('scheduled', 'event_espresso'),
276
-            ],
277
-            EEM_CPT_Base::post_status_draft             => [
278
-                esc_html__('draft', 'event_espresso'),
279
-                esc_html__('draft', 'event_espresso'),
280
-            ],
281
-            EEM_CPT_Base::post_status_pending           => [
282
-                esc_html__('pending', 'event_espresso'),
283
-                esc_html__('pending', 'event_espresso'),
284
-            ],
285
-            EEM_CPT_Base::post_status_private           => [
286
-                esc_html__('private', 'event_espresso'),
287
-                esc_html__('private', 'event_espresso'),
288
-            ],
289
-            EEM_CPT_Base::post_status_trashed           => [
290
-                esc_html__('trashed', 'event_espresso'),
291
-                esc_html__('trashed', 'event_espresso'),
292
-            ],
293
-        ];
90
+	/**
91
+	 * This method provides the localized singular or plural string for a given status id
92
+	 *
93
+	 * @param array   $statuses  This should be an array of statuses in the format array( $status_id, $status_code ).
94
+	 *                           That way if there isn't a translation in the index we'll return the default code.
95
+	 * @param boolean $plural    Whether to return plural string or not. Note, nearly all of the plural strings are the
96
+	 *                           same as the singular (in English), however, this may NOT be the case with other
97
+	 *                           languages
98
+	 * @param string  $schema    This can be either 'upper', 'lower', or 'sentence'.  Basically indicates how we want
99
+	 *                           the status string returned ( UPPER, lower, Sentence)
100
+	 * @return array             an array of translated strings for the incoming status id.
101
+	 * @throws EE_Error
102
+	 */
103
+	public function localized_status(array $statuses, bool $plural = false, string $schema = 'upper'): array
104
+	{
105
+		// note these are all in lower case because ucwords() on upper case will NOT convert.
106
+		$translation_array = [
107
+			EEM_Registration::status_id_pending_payment => [
108
+				esc_html__('pending payment', 'event_espresso'), // singular
109
+				esc_html__('pending payments', 'event_espresso') // plural
110
+			],
111
+			EEM_Registration::status_id_approved        => [
112
+				esc_html__('approved', 'event_espresso'), // singular
113
+				esc_html__('approved', 'event_espresso') // plural
114
+			],
115
+			EEM_Registration::status_id_not_approved    => [
116
+				esc_html__('not approved', 'event_espresso'),
117
+				esc_html__('not approved', 'event_espresso'),
118
+			],
119
+			EEM_Registration::status_id_cancelled       => [
120
+				esc_html__('cancelled', 'event_espresso'),
121
+				esc_html__('cancelled', 'event_espresso'),
122
+			],
123
+			EEM_Registration::status_id_incomplete      => [
124
+				esc_html__('incomplete', 'event_espresso'),
125
+				esc_html__('incomplete', 'event_espresso'),
126
+			],
127
+			EEM_Registration::status_id_declined        => [
128
+				esc_html__('declined', 'event_espresso'),
129
+				esc_html__('declined', 'event_espresso'),
130
+			],
131
+			EEM_Registration::status_id_wait_list       => [
132
+				esc_html__('wait list', 'event_espresso'),
133
+				esc_html__('wait list', 'event_espresso'),
134
+			],
135
+			EEM_Transaction::overpaid_status_code       => [
136
+				esc_html__('overpaid', 'event_espresso'),
137
+				esc_html__('overpaid', 'event_espresso'),
138
+			],
139
+			EEM_Transaction::complete_status_code       => [
140
+				esc_html__('complete', 'event_espresso'),
141
+				esc_html__('complete', 'event_espresso'),
142
+			],
143
+			EEM_Transaction::incomplete_status_code     => [
144
+				esc_html__('incomplete', 'event_espresso'),
145
+				esc_html__('incomplete', 'event_espresso'),
146
+			],
147
+			EEM_Transaction::failed_status_code         => [
148
+				esc_html__('failed', 'event_espresso'),
149
+				esc_html__('failed', 'event_espresso'),
150
+			],
151
+			EEM_Transaction::abandoned_status_code      => [
152
+				esc_html__('abandoned', 'event_espresso'),
153
+				esc_html__('abandoned', 'event_espresso'),
154
+			],
155
+			EEM_Payment::status_id_approved             => [
156
+				esc_html__('accepted', 'event_espresso'),
157
+				esc_html__('accepted', 'event_espresso'),
158
+			],
159
+			EEM_Payment::status_id_pending              => [
160
+				esc_html__('pending', 'event_espresso'),
161
+				esc_html__('pending', 'event_espresso'),
162
+			],
163
+			EEM_Payment::status_id_cancelled            => [
164
+				esc_html__('cancelled', 'event_espresso'),
165
+				esc_html__('cancelled', 'event_espresso'),
166
+			],
167
+			EEM_Payment::status_id_declined             => [
168
+				esc_html__('declined', 'event_espresso'),
169
+				esc_html__('declined', 'event_espresso'),
170
+			],
171
+			EEM_Payment::status_id_failed               => [
172
+				esc_html__('failed', 'event_espresso'),
173
+				esc_html__('failed', 'event_espresso'),
174
+			],
175
+			// following statuses are NOT part of the EEM_Status but to keep things centralized we include in here.
176
+			EEM_Event::sold_out                         => [
177
+				esc_html__('sold out', 'event_espresso'),
178
+				esc_html__('sold out', 'event_espresso'),
179
+			],
180
+			EEM_Event::postponed                        => [
181
+				esc_html__('postponed', 'event_espresso'),
182
+				esc_html__('Postponed', 'event_espresso'),
183
+			],
184
+			EEM_Event::cancelled                        => [
185
+				esc_html__('cancelled', 'event_espresso'),
186
+				esc_html__('cancelled', 'event_espresso'),
187
+			],
188
+			EE_Ticket::archived                         => [
189
+				esc_html__('archived', 'event_espresso'),
190
+				esc_html__('archived', 'event_espresso'),
191
+			],
192
+			EE_Ticket::expired                          => [
193
+				esc_html__('expired', 'event_espresso'),
194
+				esc_html__('expired', 'event_espresso'),
195
+			],
196
+			EE_Ticket::sold_out                         => [
197
+				esc_html__('sold out', 'event_espresso'),
198
+				esc_html__('sold out', 'event_espresso'),
199
+			],
200
+			EE_Ticket::pending                          => [
201
+				esc_html__('upcoming', 'event_espresso'),
202
+				esc_html__('upcoming', 'event_espresso'),
203
+			],
204
+			EE_Ticket::onsale                           => [
205
+				esc_html__('on sale', 'event_espresso'),
206
+				esc_html__('on sale', 'event_espresso'),
207
+			],
208
+			EE_Datetime::cancelled                      => [
209
+				esc_html__('cancelled', 'event_espresso'),
210
+				esc_html__('cancelled', 'event_espresso'),
211
+			],
212
+			EE_Datetime::sold_out                       => [
213
+				esc_html__('sold out', 'event_espresso'),
214
+				esc_html__('sold out', 'event_espresso'),
215
+			],
216
+			EE_Datetime::expired                        => [
217
+				esc_html__('expired', 'event_espresso'),
218
+				esc_html__('expired', 'event_espresso'),
219
+			],
220
+			EE_Datetime::inactive                       => [
221
+				esc_html__('inactive', 'event_espresso'),
222
+				esc_html__('inactive', 'event_espresso'),
223
+			],
224
+			EE_Datetime::upcoming                       => [
225
+				esc_html__('upcoming', 'event_espresso'),
226
+				esc_html__('upcoming', 'event_espresso'),
227
+			],
228
+			EE_Datetime::active                         => [
229
+				esc_html__('active', 'event_espresso'),
230
+				esc_html__('active', 'event_espresso'),
231
+			],
232
+			EE_Datetime::postponed                      => [
233
+				esc_html__('postponed', 'event_espresso'),
234
+				esc_html__('postponed', 'event_espresso'),
235
+			],
236
+			// messages related
237
+			EEM_Message::status_sent                    => [
238
+				esc_html__('sent', 'event_espresso'),
239
+				esc_html__('sent', 'event_espresso'),
240
+			],
241
+			EEM_Message::status_idle                    => [
242
+				esc_html__('queued for sending', 'event_espresso'),
243
+				esc_html__('queued for sending', 'event_espresso'),
244
+			],
245
+			EEM_Message::status_failed                  => [
246
+				esc_html__('failed', 'event_espresso'),
247
+				esc_html__('failed', 'event_espresso'),
248
+			],
249
+			EEM_Message::status_debug_only              => [
250
+				esc_html__('debug only', 'event_espresso'),
251
+				esc_html__('debug only', 'event_espresso'),
252
+			],
253
+			EEM_Message::status_messenger_executing     => [
254
+				esc_html__('messenger is executing', 'event_espresso'),
255
+				esc_html__('messenger is executing', 'event_espresso'),
256
+			],
257
+			EEM_Message::status_resend                  => [
258
+				esc_html__('queued for resending', 'event_espresso'),
259
+				esc_html__('queued for resending', 'event_espresso'),
260
+			],
261
+			EEM_Message::status_incomplete              => [
262
+				esc_html__('queued for generating', 'event_espresso'),
263
+				esc_html__('queued for generating', 'event_espresso'),
264
+			],
265
+			EEM_Message::status_retry                   => [
266
+				esc_html__('failed sending, can be retried', 'event_espresso'),
267
+				esc_html__('failed sending, can be retried', 'event_espresso'),
268
+			],
269
+			EEM_CPT_Base::post_status_publish           => [
270
+				esc_html__('published', 'event_espresso'),
271
+				esc_html__('published', 'event_espresso'),
272
+			],
273
+			EEM_CPT_Base::post_status_future            => [
274
+				esc_html__('scheduled', 'event_espresso'),
275
+				esc_html__('scheduled', 'event_espresso'),
276
+			],
277
+			EEM_CPT_Base::post_status_draft             => [
278
+				esc_html__('draft', 'event_espresso'),
279
+				esc_html__('draft', 'event_espresso'),
280
+			],
281
+			EEM_CPT_Base::post_status_pending           => [
282
+				esc_html__('pending', 'event_espresso'),
283
+				esc_html__('pending', 'event_espresso'),
284
+			],
285
+			EEM_CPT_Base::post_status_private           => [
286
+				esc_html__('private', 'event_espresso'),
287
+				esc_html__('private', 'event_espresso'),
288
+			],
289
+			EEM_CPT_Base::post_status_trashed           => [
290
+				esc_html__('trashed', 'event_espresso'),
291
+				esc_html__('trashed', 'event_espresso'),
292
+			],
293
+		];
294 294
 
295
-        $translation_array = apply_filters('FHEE__EEM_Status__localized_status__translation_array', $translation_array);
295
+		$translation_array = apply_filters('FHEE__EEM_Status__localized_status__translation_array', $translation_array);
296 296
 
297
-        if (! is_array($statuses)) {
298
-            throw new EE_Error(
299
-               esc_html__(
300
-                   'The incoming statuses argument must be an array with keys as the $status_id and values as the $status_code',
301
-                   'event_espresso'
302
-               )
303
-            );
304
-        }
297
+		if (! is_array($statuses)) {
298
+			throw new EE_Error(
299
+			   esc_html__(
300
+				   'The incoming statuses argument must be an array with keys as the $status_id and values as the $status_code',
301
+				   'event_espresso'
302
+			   )
303
+			);
304
+		}
305 305
 
306
-        $translation = [];
306
+		$translation = [];
307 307
 
308
-        foreach ($statuses as $id => $code) {
309
-            if (isset($translation_array[ $id ])) {
310
-                $translation[ $id ] = $plural
311
-                    ? $translation_array[ $id ][1]
312
-                    : $translation_array[ $id ][0];
313
-            } else {
314
-                $translation[ $id ] = $code;
315
-            }
308
+		foreach ($statuses as $id => $code) {
309
+			if (isset($translation_array[ $id ])) {
310
+				$translation[ $id ] = $plural
311
+					? $translation_array[ $id ][1]
312
+					: $translation_array[ $id ][0];
313
+			} else {
314
+				$translation[ $id ] = $code;
315
+			}
316 316
 
317
-            // schema
318
-            switch ($schema) {
319
-                case 'lower':
320
-                    // even though these start in lower case, this will catch any statuses added via filter.
321
-                    $translation[ $id ] = strtolower($translation[ $id ]);
322
-                    break;
323
-                case 'sentence':
324
-                    $translation[ $id ] = ucwords($translation[ $id ]);
325
-                    break;
326
-                case 'upper':
327
-                    $translation[ $id ] = strtoupper($translation[ $id ]);
328
-                    break;
329
-            }
330
-        }
317
+			// schema
318
+			switch ($schema) {
319
+				case 'lower':
320
+					// even though these start in lower case, this will catch any statuses added via filter.
321
+					$translation[ $id ] = strtolower($translation[ $id ]);
322
+					break;
323
+				case 'sentence':
324
+					$translation[ $id ] = ucwords($translation[ $id ]);
325
+					break;
326
+				case 'upper':
327
+					$translation[ $id ] = strtoupper($translation[ $id ]);
328
+					break;
329
+			}
330
+		}
331 331
 
332
-        return $translation;
333
-    }
332
+		return $translation;
333
+	}
334 334
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
                     false,
48 48
                     'event',
49 49
                     [
50
-                        'event'        => esc_html__("Event", "event_espresso"),// deprecated
50
+                        'event'        => esc_html__("Event", "event_espresso"), // deprecated
51 51
                         'registration' => esc_html__("Registration", "event_espresso"),
52 52
                         'transaction'  => esc_html__("Transaction", "event_espresso"),
53 53
                         'payment'      => esc_html__("Payment", "event_espresso"),
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
             'Payment'      => new EE_Has_Many_Relation(),
82 82
         ];
83 83
         // this model is generally available for reading
84
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
84
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
85 85
 
86 86
         parent::__construct($timezone);
87 87
     }
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 
295 295
         $translation_array = apply_filters('FHEE__EEM_Status__localized_status__translation_array', $translation_array);
296 296
 
297
-        if (! is_array($statuses)) {
297
+        if ( ! is_array($statuses)) {
298 298
             throw new EE_Error(
299 299
                esc_html__(
300 300
                    'The incoming statuses argument must be an array with keys as the $status_id and values as the $status_code',
@@ -306,25 +306,25 @@  discard block
 block discarded – undo
306 306
         $translation = [];
307 307
 
308 308
         foreach ($statuses as $id => $code) {
309
-            if (isset($translation_array[ $id ])) {
310
-                $translation[ $id ] = $plural
311
-                    ? $translation_array[ $id ][1]
312
-                    : $translation_array[ $id ][0];
309
+            if (isset($translation_array[$id])) {
310
+                $translation[$id] = $plural
311
+                    ? $translation_array[$id][1]
312
+                    : $translation_array[$id][0];
313 313
             } else {
314
-                $translation[ $id ] = $code;
314
+                $translation[$id] = $code;
315 315
             }
316 316
 
317 317
             // schema
318 318
             switch ($schema) {
319 319
                 case 'lower':
320 320
                     // even though these start in lower case, this will catch any statuses added via filter.
321
-                    $translation[ $id ] = strtolower($translation[ $id ]);
321
+                    $translation[$id] = strtolower($translation[$id]);
322 322
                     break;
323 323
                 case 'sentence':
324
-                    $translation[ $id ] = ucwords($translation[ $id ]);
324
+                    $translation[$id] = ucwords($translation[$id]);
325 325
                     break;
326 326
                 case 'upper':
327
-                    $translation[ $id ] = strtoupper($translation[ $id ]);
327
+                    $translation[$id] = strtoupper($translation[$id]);
328 328
                     break;
329 329
             }
330 330
         }
Please login to merge, or discard this patch.
core/db_models/relations/EE_Belongs_To_Relation.php 1 patch
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -12,137 +12,137 @@
 block discarded – undo
12 12
 class EE_Belongs_To_Relation extends EE_Model_Relation_Base
13 13
 {
14 14
 
15
-    /**
16
-     * Object representing the relationship between two models. Belongs_To means that THIS model has the foreign key
17
-     * to the other model. This knows how to join the models,
18
-     * get related models across the relation, and add-and-remove the relationships.
19
-     *
20
-     * @param boolean $block_deletes                                For Belongs_To relations, this is set to FALSE by
21
-     *                                                              default. if there are related models across this
22
-     *                                                              relation, block (prevent and add an error) the
23
-     *                                                              deletion of this model
24
-     * @param string  $related_model_objects_deletion_error_message a customized error message on blocking deletes
25
-     *                                                              instead of the default
26
-     */
27
-    public function __construct($block_deletes = false, $related_model_objects_deletion_error_message = null)
28
-    {
29
-        parent::__construct($block_deletes, $related_model_objects_deletion_error_message);
30
-    }
15
+	/**
16
+	 * Object representing the relationship between two models. Belongs_To means that THIS model has the foreign key
17
+	 * to the other model. This knows how to join the models,
18
+	 * get related models across the relation, and add-and-remove the relationships.
19
+	 *
20
+	 * @param boolean $block_deletes                                For Belongs_To relations, this is set to FALSE by
21
+	 *                                                              default. if there are related models across this
22
+	 *                                                              relation, block (prevent and add an error) the
23
+	 *                                                              deletion of this model
24
+	 * @param string  $related_model_objects_deletion_error_message a customized error message on blocking deletes
25
+	 *                                                              instead of the default
26
+	 */
27
+	public function __construct($block_deletes = false, $related_model_objects_deletion_error_message = null)
28
+	{
29
+		parent::__construct($block_deletes, $related_model_objects_deletion_error_message);
30
+	}
31 31
 
32 32
 
33
-    /**
34
-     * get_join_statement
35
-     *
36
-     * @param string $model_relation_chain
37
-     * @return string
38
-     * @throws \EE_Error
39
-     */
40
-    public function get_join_statement($model_relation_chain)
41
-    {
42
-        // create the sql string like
43
-        $this_table_fk_field  = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
44
-        $other_table_pk_field = $this->get_other_model()->get_primary_key_field();
45
-        $this_table_alias     = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix(
46
-            $model_relation_chain,
47
-            $this->get_this_model()->get_this_model_name()
48
-        ) . $this_table_fk_field->get_table_alias();
49
-        $other_table_alias    = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix(
50
-            $model_relation_chain,
51
-            $this->get_other_model()->get_this_model_name()
52
-        ) . $other_table_pk_field->get_table_alias();
53
-        $other_table          = $this->get_other_model()->get_table_for_alias($other_table_alias);
54
-        return $this->_left_join(
55
-            $other_table,
56
-            $other_table_alias,
57
-            $other_table_pk_field->get_table_column(),
58
-            $this_table_alias,
59
-            $this_table_fk_field->get_table_column()
60
-        ) . $this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias);
61
-    }
33
+	/**
34
+	 * get_join_statement
35
+	 *
36
+	 * @param string $model_relation_chain
37
+	 * @return string
38
+	 * @throws \EE_Error
39
+	 */
40
+	public function get_join_statement($model_relation_chain)
41
+	{
42
+		// create the sql string like
43
+		$this_table_fk_field  = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
44
+		$other_table_pk_field = $this->get_other_model()->get_primary_key_field();
45
+		$this_table_alias     = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix(
46
+			$model_relation_chain,
47
+			$this->get_this_model()->get_this_model_name()
48
+		) . $this_table_fk_field->get_table_alias();
49
+		$other_table_alias    = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix(
50
+			$model_relation_chain,
51
+			$this->get_other_model()->get_this_model_name()
52
+		) . $other_table_pk_field->get_table_alias();
53
+		$other_table          = $this->get_other_model()->get_table_for_alias($other_table_alias);
54
+		return $this->_left_join(
55
+			$other_table,
56
+			$other_table_alias,
57
+			$other_table_pk_field->get_table_column(),
58
+			$this_table_alias,
59
+			$this_table_fk_field->get_table_column()
60
+		) . $this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias);
61
+	}
62 62
 
63 63
 
64
-    /**
65
-     * Sets this model object's foreign key to the other model object's primary key. Feel free to do this manually if
66
-     * you like.
67
-     *
68
-     * @param EE_Base_Class|int $this_obj_or_id
69
-     * @param EE_Base_Class|int $other_obj_or_id
70
-     * @param array             $extra_join_model_fields_n_values
71
-     * @return \EE_Base_Class
72
-     * @throws \EE_Error
73
-     */
74
-    public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array())
75
-    {
76
-        $this_model_obj  = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true);
77
-        $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true);
78
-        // find the field on the other model which is a foreign key to this model
79
-        $fk_on_this_model = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
80
-        if ($this_model_obj->get($fk_on_this_model->get_name()) != $other_model_obj->ID()) {
81
-            // set that field on the other model to this model's ID
82
-            $this_model_obj->set($fk_on_this_model->get_name(), $other_model_obj->ID());
83
-            $this_model_obj->save();
84
-        }
85
-        return $other_model_obj;
86
-    }
64
+	/**
65
+	 * Sets this model object's foreign key to the other model object's primary key. Feel free to do this manually if
66
+	 * you like.
67
+	 *
68
+	 * @param EE_Base_Class|int $this_obj_or_id
69
+	 * @param EE_Base_Class|int $other_obj_or_id
70
+	 * @param array             $extra_join_model_fields_n_values
71
+	 * @return \EE_Base_Class
72
+	 * @throws \EE_Error
73
+	 */
74
+	public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array())
75
+	{
76
+		$this_model_obj  = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true);
77
+		$other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true);
78
+		// find the field on the other model which is a foreign key to this model
79
+		$fk_on_this_model = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
80
+		if ($this_model_obj->get($fk_on_this_model->get_name()) != $other_model_obj->ID()) {
81
+			// set that field on the other model to this model's ID
82
+			$this_model_obj->set($fk_on_this_model->get_name(), $other_model_obj->ID());
83
+			$this_model_obj->save();
84
+		}
85
+		return $other_model_obj;
86
+	}
87 87
 
88 88
 
89
-    /**
90
-     * Sets the this model object's foreign key to its default, instead of pointing to the other model object
91
-     *
92
-     * @param EE_Base_Class|int $this_obj_or_id
93
-     * @param EE_Base_Class|int $other_obj_or_id
94
-     * @param array             $where_query
95
-     * @return \EE_Base_Class
96
-     * @throws \EE_Error
97
-     */
98
-    public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array())
99
-    {
100
-        $this_model_obj  = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true);
101
-        $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id);
102
-        // find the field on the other model which is a foreign key to this model
103
-        $fk_on_this_model = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
104
-        // set that field on the other model to this model's ID
105
-        $this_model_obj->set($fk_on_this_model->get_name(), null, true);
106
-        $this_model_obj->save();
107
-        return $other_model_obj;
108
-    }
89
+	/**
90
+	 * Sets the this model object's foreign key to its default, instead of pointing to the other model object
91
+	 *
92
+	 * @param EE_Base_Class|int $this_obj_or_id
93
+	 * @param EE_Base_Class|int $other_obj_or_id
94
+	 * @param array             $where_query
95
+	 * @return \EE_Base_Class
96
+	 * @throws \EE_Error
97
+	 */
98
+	public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array())
99
+	{
100
+		$this_model_obj  = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true);
101
+		$other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id);
102
+		// find the field on the other model which is a foreign key to this model
103
+		$fk_on_this_model = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
104
+		// set that field on the other model to this model's ID
105
+		$this_model_obj->set($fk_on_this_model->get_name(), null, true);
106
+		$this_model_obj->save();
107
+		return $other_model_obj;
108
+	}
109 109
 
110 110
 
111
-    /**
112
-     * Overrides parent so that we don't NEED to save the $model_object before getting the related objects.
113
-     *
114
-     * @param EE_Base_Class $model_obj_or_id
115
-     * @param array         $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
116
-     * @param boolean       $values_already_prepared_by_model_object @deprecated since 4.8.1
117
-     * @return EE_Base_Class[]
118
-     * @throws \EE_Error
119
-     */
120
-    public function get_all_related(
121
-        $model_obj_or_id,
122
-        $query_params = array(),
123
-        $values_already_prepared_by_model_object = false
124
-    ) {
125
-        if ($values_already_prepared_by_model_object !== false) {
126
-            EE_Error::doing_it_wrong(
127
-                'EE_Model_Relation_Base::get_all_related',
128
-                esc_html__('The argument $values_already_prepared_by_model_object is no longer used.', 'event_espresso'),
129
-                '4.8.1'
130
-            );
131
-        }
132
-        // get column on this model object which is a foreign key to the other model
133
-        $fk_field_obj = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
134
-        // get its value
135
-        if ($model_obj_or_id instanceof EE_Base_Class) {
136
-            $model_obj = $model_obj_or_id;
137
-        } else {
138
-            $model_obj = $this->get_this_model()->ensure_is_obj($model_obj_or_id);
139
-        }
140
-        $ID_value_on_other_model = $model_obj->get($fk_field_obj->get_name());
141
-        // get all where their PK matches that value
142
-        $query_params[0][ $this->get_other_model()->get_primary_key_field()->get_name() ] = $ID_value_on_other_model;
143
-        $query_params                                                                   = $this->_disable_default_where_conditions_on_query_param($query_params);
111
+	/**
112
+	 * Overrides parent so that we don't NEED to save the $model_object before getting the related objects.
113
+	 *
114
+	 * @param EE_Base_Class $model_obj_or_id
115
+	 * @param array         $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
116
+	 * @param boolean       $values_already_prepared_by_model_object @deprecated since 4.8.1
117
+	 * @return EE_Base_Class[]
118
+	 * @throws \EE_Error
119
+	 */
120
+	public function get_all_related(
121
+		$model_obj_or_id,
122
+		$query_params = array(),
123
+		$values_already_prepared_by_model_object = false
124
+	) {
125
+		if ($values_already_prepared_by_model_object !== false) {
126
+			EE_Error::doing_it_wrong(
127
+				'EE_Model_Relation_Base::get_all_related',
128
+				esc_html__('The argument $values_already_prepared_by_model_object is no longer used.', 'event_espresso'),
129
+				'4.8.1'
130
+			);
131
+		}
132
+		// get column on this model object which is a foreign key to the other model
133
+		$fk_field_obj = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
134
+		// get its value
135
+		if ($model_obj_or_id instanceof EE_Base_Class) {
136
+			$model_obj = $model_obj_or_id;
137
+		} else {
138
+			$model_obj = $this->get_this_model()->ensure_is_obj($model_obj_or_id);
139
+		}
140
+		$ID_value_on_other_model = $model_obj->get($fk_field_obj->get_name());
141
+		// get all where their PK matches that value
142
+		$query_params[0][ $this->get_other_model()->get_primary_key_field()->get_name() ] = $ID_value_on_other_model;
143
+		$query_params                                                                   = $this->_disable_default_where_conditions_on_query_param($query_params);
144 144
 //      echo '$query_params';
145 145
 //      var_dump($query_params);
146
-        return $this->get_other_model()->get_all($query_params);
147
-    }
146
+		return $this->get_other_model()->get_all($query_params);
147
+	}
148 148
 }
Please login to merge, or discard this patch.