Completed
Branch master (89fa75)
by
unknown
05:04
created
core/db_models/EEM_Form_Element.model.php 1 patch
Indentation   +224 added lines, -224 removed lines patch added patch discarded remove patch
@@ -27,228 +27,228 @@
 block discarded – undo
27 27
  */
28 28
 class EEM_Form_Element extends EEM_Base
29 29
 {
30
-    protected static ?EEM_Form_Element $_instance = null;
31
-
32
-    private RequestInterface $request;
33
-
34
-    private InputTypes $input_types;
35
-
36
-
37
-    /**
38
-     * EEM_Form_Element constructor.
39
-     *
40
-     * @param FormStatus  $form_status
41
-     * @param InputTypes  $input_types
42
-     * @param string|null $timezone
43
-     * @throws EE_Error
44
-     */
45
-    protected function __construct(FormStatus $form_status, InputTypes $input_types, ?string $timezone = '')
46
-    {
47
-        $this->input_types   = $input_types;
48
-        $this->singular_item = esc_html__('Form Element', 'event_espresso');
49
-        $this->plural_item   = esc_html__('Form Elements', 'event_espresso');
50
-
51
-        $this->_tables = [
52
-            'Form_Element' => new EE_Primary_Table('esp_form_element', 'FIN_UUID'),
53
-        ];
54
-        $this->_fields = [
55
-            'Form_Element' => [
56
-                'FIN_UUID'       => new EE_Primary_Key_String_Field(
57
-                    'FIN_UUID',
58
-                    esc_html__('Form Element UUID (universally unique identifier)', 'event_espresso')
59
-                ),
60
-                'FSC_UUID'       => new EE_Foreign_Key_String_Field(
61
-                    'FSC_UUID',
62
-                    esc_html__('UUID of parent form section this form input belongs to.', 'event_espresso'),
63
-                    false,
64
-                    null,
65
-                    ['Form_Section'],
66
-                    false
67
-                ),
68
-                'FIN_adminOnly'  => new EE_Boolean_Field(
69
-                    'FIN_adminOnly',
70
-                    esc_html__(
71
-                        'Whether or not input is only displayed in the admin. If false, input will appear in public forms',
72
-                        'event_espresso'
73
-                    ),
74
-                    false,
75
-                    false
76
-                ),
77
-                'FIN_attributes' => new EE_JSON_Field(
78
-                    'FIN_attributes',
79
-                    esc_html__(
80
-                        'JSON string of HTML attributes such as class, max, min, placeholder, type, etc.',
81
-                        'event_espresso'
82
-                    ),
83
-                    true,
84
-                    '{}'
85
-                ),
86
-                'FIN_helpText'   => new EE_JSON_Field(
87
-                    'FIN_helpText',
88
-                    esc_html__(
89
-                        'JSON string of properties pertaining to any help text required for an input.',
90
-                        'event_espresso'
91
-                    ),
92
-                    true,
93
-                    '{}'
94
-                ),
95
-                'FIN_label'      => new EE_JSON_Field(
96
-                    'FIN_label',
97
-                    esc_html__(
98
-                        'JSON string of properties pertaining to an element\'s label.',
99
-                        'event_espresso'
100
-                    ),
101
-                    true,
102
-                    '{}'
103
-                ),
104
-                'FIN_mapsTo'     => new EE_Plain_Text_Field(
105
-                    'FIN_mapsTo',
106
-                    esc_html__(
107
-                        'Model and Fields name that this element maps to; ex: Attendee.email',
108
-                        'event_espresso'
109
-                    ),
110
-                    true,
111
-                    null
112
-                ),
113
-                'FIN_options'    => new EE_JSON_Field(
114
-                    'FIN_options',
115
-                    esc_html__(
116
-                        'JSON string of options for ENUM type inputs like checkboxes, radio buttons, select inputs, etc.',
117
-                        'event_espresso'
118
-                    ),
119
-                    true,
120
-                    '[]'
121
-                ),
122
-                'FIN_order'      => new EE_Integer_Field(
123
-                    'FIN_order',
124
-                    esc_html__('Order in which form input appears in a form.', 'event_espresso'),
125
-                    false,
126
-                    0
127
-                ),
128
-                'FIN_required'   => new EE_JSON_Field(
129
-                    'FIN_required',
130
-                    esc_html__(
131
-                        'properties pertaining to an input\'s required status and the validation text to display.',
132
-                        'event_espresso'
133
-                    ),
134
-                    false,
135
-                    '{"required":false,"validationText":""}'
136
-                ),
137
-                'FIN_status'     => new EE_Enum_Text_Field(
138
-                    'FIN_status',
139
-                    esc_html(
140
-                        sprintf(
141
-                            /* translators: 1 class name */
142
-                            esc_html__(
143
-                                'Whether form element is active, archived, trashed, or used as a default on new forms. Values correspond to the %1$s class constants.',
144
-                                'event_espresso'
145
-                            ),
146
-                            'EventEspresso\core\services\form\meta\FormStatus'
147
-                        )
148
-                    ),
149
-                    false,
150
-                    FormStatus::ACTIVE,
151
-                    $form_status->validStatusOptions()
152
-                ),
153
-                'FIN_type'       => new EE_Enum_Text_Field(
154
-                    'FIN_type',
155
-                    esc_html__('Form element type.', 'event_espresso'),
156
-                    false,
157
-                    Text::TYPE_TEXT,
158
-                    $input_types->validTypeOptions()
159
-                ),
160
-                'FIN_wpUser'     => new EE_WP_User_Field(
161
-                    'FIN_wpUser',
162
-                    esc_html__('ID of the WP User that created this form input.', 'event_espresso'),
163
-                    false
164
-                ),
165
-            ],
166
-        ];
167
-
168
-        $this->_model_relations = [
169
-            'Form_Section' => new EE_Belongs_To_Relation(),
170
-            'WP_User'      => new EE_Belongs_To_Relation(),
171
-        ];
172
-        // this model is generally available for reading
173
-        $this->_cap_restriction_generators = [
174
-            EEM_Base::caps_read       => new EE_Restriction_Generator_Public(),
175
-            EEM_Base::caps_read_admin => new EE_Restriction_Generator_Reg_Form('FIN_applies_to'),
176
-            EEM_Base::caps_edit       => new EE_Restriction_Generator_Reg_Form('FIN_applies_to'),
177
-            EEM_Base::caps_delete     => new EE_Restriction_Generator_Reg_Form('FIN_applies_to'),
178
-        ];
179
-        parent::__construct($timezone);
180
-        $this->request = $this->getLoader()->getShared('EventEspresso\core\services\request\RequestInterface');
181
-    }
182
-
183
-
184
-    /**
185
-     * @param array $query_params
186
-     * @return array
187
-     */
188
-    private function addDefaultWhereConditions(array $query_params): array
189
-    {
190
-        // might need to add a way to identify GQL requests for admin domains
191
-        $admin_request                            = $this->request->isAdmin() || $this->request->isAdminAjax();
192
-        $query_params['default_where_conditions'] = $admin_request
193
-            ? EEM_Base::default_where_conditions_none
194
-            : EEM_Base::default_where_conditions_all;
195
-        return $query_params;
196
-    }
197
-
198
-
199
-    /**
200
-     * form inputs should always be sorted in ascending order via the FIN_order field
201
-     *
202
-     * @param array $query_params
203
-     * @return array
204
-     */
205
-    private function addOrderByQueryParams(array $query_params): array
206
-    {
207
-        $query_params['order_by'] = ['FIN_order' => 'ASC'];
208
-        return $query_params;
209
-    }
210
-
211
-
212
-    /**
213
-     * @param EE_Form_Section   $form_section
214
-     * @param EE_Form_Element[] $all_form_elements
215
-     * @return EE_Form_Element[]
216
-     * @throws EE_Error
217
-     * @throws ReflectionException
218
-     */
219
-    public function filterFormElementsForFormSection(EE_Form_Section $form_section, array $all_form_elements): array
220
-    {
221
-        return array_filter($all_form_elements, $form_section->formElementFilter());
222
-    }
223
-
224
-
225
-    /**
226
-     * @param EE_Form_Section[] $form_sections
227
-     * @return EE_Form_Element[]
228
-     * @throws EE_Error
229
-     * @throws ReflectionException
230
-     */
231
-    public function getAllFormElementsForFormSections(array $form_sections): array
232
-    {
233
-        $FSC_UUIDs = [];
234
-        foreach ($form_sections as $form_section) {
235
-            if ($form_section instanceof EE_Form_Section) {
236
-                $FSC_UUIDs[] = $form_section->UUID();
237
-            }
238
-        }
239
-        $where_params = ['FSC_UUID' => ['IN', $FSC_UUIDs]];
240
-        $query_params = $this->addDefaultWhereConditions([$where_params]);
241
-        $query_params = $this->addOrderByQueryParams($query_params);
242
-        return $this->get_all($query_params);
243
-    }
244
-
245
-
246
-    /**
247
-     * @param bool $constants_only
248
-     * @return array
249
-     */
250
-    public function validTypeOptions(bool $constants_only = false): array
251
-    {
252
-        return $this->input_types->validTypeOptions($constants_only);
253
-    }
30
+	protected static ?EEM_Form_Element $_instance = null;
31
+
32
+	private RequestInterface $request;
33
+
34
+	private InputTypes $input_types;
35
+
36
+
37
+	/**
38
+	 * EEM_Form_Element constructor.
39
+	 *
40
+	 * @param FormStatus  $form_status
41
+	 * @param InputTypes  $input_types
42
+	 * @param string|null $timezone
43
+	 * @throws EE_Error
44
+	 */
45
+	protected function __construct(FormStatus $form_status, InputTypes $input_types, ?string $timezone = '')
46
+	{
47
+		$this->input_types   = $input_types;
48
+		$this->singular_item = esc_html__('Form Element', 'event_espresso');
49
+		$this->plural_item   = esc_html__('Form Elements', 'event_espresso');
50
+
51
+		$this->_tables = [
52
+			'Form_Element' => new EE_Primary_Table('esp_form_element', 'FIN_UUID'),
53
+		];
54
+		$this->_fields = [
55
+			'Form_Element' => [
56
+				'FIN_UUID'       => new EE_Primary_Key_String_Field(
57
+					'FIN_UUID',
58
+					esc_html__('Form Element UUID (universally unique identifier)', 'event_espresso')
59
+				),
60
+				'FSC_UUID'       => new EE_Foreign_Key_String_Field(
61
+					'FSC_UUID',
62
+					esc_html__('UUID of parent form section this form input belongs to.', 'event_espresso'),
63
+					false,
64
+					null,
65
+					['Form_Section'],
66
+					false
67
+				),
68
+				'FIN_adminOnly'  => new EE_Boolean_Field(
69
+					'FIN_adminOnly',
70
+					esc_html__(
71
+						'Whether or not input is only displayed in the admin. If false, input will appear in public forms',
72
+						'event_espresso'
73
+					),
74
+					false,
75
+					false
76
+				),
77
+				'FIN_attributes' => new EE_JSON_Field(
78
+					'FIN_attributes',
79
+					esc_html__(
80
+						'JSON string of HTML attributes such as class, max, min, placeholder, type, etc.',
81
+						'event_espresso'
82
+					),
83
+					true,
84
+					'{}'
85
+				),
86
+				'FIN_helpText'   => new EE_JSON_Field(
87
+					'FIN_helpText',
88
+					esc_html__(
89
+						'JSON string of properties pertaining to any help text required for an input.',
90
+						'event_espresso'
91
+					),
92
+					true,
93
+					'{}'
94
+				),
95
+				'FIN_label'      => new EE_JSON_Field(
96
+					'FIN_label',
97
+					esc_html__(
98
+						'JSON string of properties pertaining to an element\'s label.',
99
+						'event_espresso'
100
+					),
101
+					true,
102
+					'{}'
103
+				),
104
+				'FIN_mapsTo'     => new EE_Plain_Text_Field(
105
+					'FIN_mapsTo',
106
+					esc_html__(
107
+						'Model and Fields name that this element maps to; ex: Attendee.email',
108
+						'event_espresso'
109
+					),
110
+					true,
111
+					null
112
+				),
113
+				'FIN_options'    => new EE_JSON_Field(
114
+					'FIN_options',
115
+					esc_html__(
116
+						'JSON string of options for ENUM type inputs like checkboxes, radio buttons, select inputs, etc.',
117
+						'event_espresso'
118
+					),
119
+					true,
120
+					'[]'
121
+				),
122
+				'FIN_order'      => new EE_Integer_Field(
123
+					'FIN_order',
124
+					esc_html__('Order in which form input appears in a form.', 'event_espresso'),
125
+					false,
126
+					0
127
+				),
128
+				'FIN_required'   => new EE_JSON_Field(
129
+					'FIN_required',
130
+					esc_html__(
131
+						'properties pertaining to an input\'s required status and the validation text to display.',
132
+						'event_espresso'
133
+					),
134
+					false,
135
+					'{"required":false,"validationText":""}'
136
+				),
137
+				'FIN_status'     => new EE_Enum_Text_Field(
138
+					'FIN_status',
139
+					esc_html(
140
+						sprintf(
141
+							/* translators: 1 class name */
142
+							esc_html__(
143
+								'Whether form element is active, archived, trashed, or used as a default on new forms. Values correspond to the %1$s class constants.',
144
+								'event_espresso'
145
+							),
146
+							'EventEspresso\core\services\form\meta\FormStatus'
147
+						)
148
+					),
149
+					false,
150
+					FormStatus::ACTIVE,
151
+					$form_status->validStatusOptions()
152
+				),
153
+				'FIN_type'       => new EE_Enum_Text_Field(
154
+					'FIN_type',
155
+					esc_html__('Form element type.', 'event_espresso'),
156
+					false,
157
+					Text::TYPE_TEXT,
158
+					$input_types->validTypeOptions()
159
+				),
160
+				'FIN_wpUser'     => new EE_WP_User_Field(
161
+					'FIN_wpUser',
162
+					esc_html__('ID of the WP User that created this form input.', 'event_espresso'),
163
+					false
164
+				),
165
+			],
166
+		];
167
+
168
+		$this->_model_relations = [
169
+			'Form_Section' => new EE_Belongs_To_Relation(),
170
+			'WP_User'      => new EE_Belongs_To_Relation(),
171
+		];
172
+		// this model is generally available for reading
173
+		$this->_cap_restriction_generators = [
174
+			EEM_Base::caps_read       => new EE_Restriction_Generator_Public(),
175
+			EEM_Base::caps_read_admin => new EE_Restriction_Generator_Reg_Form('FIN_applies_to'),
176
+			EEM_Base::caps_edit       => new EE_Restriction_Generator_Reg_Form('FIN_applies_to'),
177
+			EEM_Base::caps_delete     => new EE_Restriction_Generator_Reg_Form('FIN_applies_to'),
178
+		];
179
+		parent::__construct($timezone);
180
+		$this->request = $this->getLoader()->getShared('EventEspresso\core\services\request\RequestInterface');
181
+	}
182
+
183
+
184
+	/**
185
+	 * @param array $query_params
186
+	 * @return array
187
+	 */
188
+	private function addDefaultWhereConditions(array $query_params): array
189
+	{
190
+		// might need to add a way to identify GQL requests for admin domains
191
+		$admin_request                            = $this->request->isAdmin() || $this->request->isAdminAjax();
192
+		$query_params['default_where_conditions'] = $admin_request
193
+			? EEM_Base::default_where_conditions_none
194
+			: EEM_Base::default_where_conditions_all;
195
+		return $query_params;
196
+	}
197
+
198
+
199
+	/**
200
+	 * form inputs should always be sorted in ascending order via the FIN_order field
201
+	 *
202
+	 * @param array $query_params
203
+	 * @return array
204
+	 */
205
+	private function addOrderByQueryParams(array $query_params): array
206
+	{
207
+		$query_params['order_by'] = ['FIN_order' => 'ASC'];
208
+		return $query_params;
209
+	}
210
+
211
+
212
+	/**
213
+	 * @param EE_Form_Section   $form_section
214
+	 * @param EE_Form_Element[] $all_form_elements
215
+	 * @return EE_Form_Element[]
216
+	 * @throws EE_Error
217
+	 * @throws ReflectionException
218
+	 */
219
+	public function filterFormElementsForFormSection(EE_Form_Section $form_section, array $all_form_elements): array
220
+	{
221
+		return array_filter($all_form_elements, $form_section->formElementFilter());
222
+	}
223
+
224
+
225
+	/**
226
+	 * @param EE_Form_Section[] $form_sections
227
+	 * @return EE_Form_Element[]
228
+	 * @throws EE_Error
229
+	 * @throws ReflectionException
230
+	 */
231
+	public function getAllFormElementsForFormSections(array $form_sections): array
232
+	{
233
+		$FSC_UUIDs = [];
234
+		foreach ($form_sections as $form_section) {
235
+			if ($form_section instanceof EE_Form_Section) {
236
+				$FSC_UUIDs[] = $form_section->UUID();
237
+			}
238
+		}
239
+		$where_params = ['FSC_UUID' => ['IN', $FSC_UUIDs]];
240
+		$query_params = $this->addDefaultWhereConditions([$where_params]);
241
+		$query_params = $this->addOrderByQueryParams($query_params);
242
+		return $this->get_all($query_params);
243
+	}
244
+
245
+
246
+	/**
247
+	 * @param bool $constants_only
248
+	 * @return array
249
+	 */
250
+	public function validTypeOptions(bool $constants_only = false): array
251
+	{
252
+		return $this->input_types->validTypeOptions($constants_only);
253
+	}
254 254
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Foreign_Key_Int_Field.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -4,36 +4,36 @@
 block discarded – undo
4 4
 
5 5
 class EE_Foreign_Key_Int_Field extends EE_Foreign_Key_Field_Base
6 6
 {
7
-    /**
8
-     * @param string  $table_column  name fo column for field
9
-     * @param string  $nicename      should eb internationalized with esc_html__('blah','event_espresso')
10
-     * @param boolean $nullable
11
-     * @param mixed   $default_value if this is a integer field, it shoudl be an int. if it's a string field, it shoul
12
-     *                               dbe a string
13
-     * @param string|string[]  $model_name    eg 'Event','Answer','Term', etc. Basically its the model class's name without the
14
-     *                               "EEM_"
15
-     */
16
-    public function __construct($table_column, $nicename, $nullable, $default_value, $model_name)
17
-    {
18
-        parent::__construct($table_column, $nicename, $nullable, $default_value, $model_name);
19
-        $this->setSchemaType(SchemaType::INTEGER);
20
-    }
7
+	/**
8
+	 * @param string  $table_column  name fo column for field
9
+	 * @param string  $nicename      should eb internationalized with esc_html__('blah','event_espresso')
10
+	 * @param boolean $nullable
11
+	 * @param mixed   $default_value if this is a integer field, it shoudl be an int. if it's a string field, it shoul
12
+	 *                               dbe a string
13
+	 * @param string|string[]  $model_name    eg 'Event','Answer','Term', etc. Basically its the model class's name without the
14
+	 *                               "EEM_"
15
+	 */
16
+	public function __construct($table_column, $nicename, $nullable, $default_value, $model_name)
17
+	{
18
+		parent::__construct($table_column, $nicename, $nullable, $default_value, $model_name);
19
+		$this->setSchemaType(SchemaType::INTEGER);
20
+	}
21 21
 
22 22
 
23
-    /**
24
-     * @param int|EE_Base_Class $value_inputted_for_field_on_model_object
25
-     * @return int
26
-     */
27
-    public function prepare_for_set($value_inputted_for_field_on_model_object)
28
-    {
29
-        if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) {
30
-            $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID();
31
-        }
32
-        return absint($value_inputted_for_field_on_model_object);
33
-    }
23
+	/**
24
+	 * @param int|EE_Base_Class $value_inputted_for_field_on_model_object
25
+	 * @return int
26
+	 */
27
+	public function prepare_for_set($value_inputted_for_field_on_model_object)
28
+	{
29
+		if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) {
30
+			$value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID();
31
+		}
32
+		return absint($value_inputted_for_field_on_model_object);
33
+	}
34 34
 
35
-    public function prepare_for_set_from_db($value_found_in_db_for_model_object)
36
-    {
37
-        return intval($value_found_in_db_for_model_object);
38
-    }
35
+	public function prepare_for_set_from_db($value_found_in_db_for_model_object)
36
+	{
37
+		return intval($value_found_in_db_for_model_object);
38
+	}
39 39
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_WP_Post_Status_Field.php 2 patches
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -2,120 +2,120 @@
 block discarded – undo
2 2
 
3 3
 class EE_WP_Post_Status_Field extends EE_Enum_Text_Field
4 4
 {
5
-    protected $_wp_post_stati;
5
+	protected $_wp_post_stati;
6 6
 
7 7
 
8
-    /**
9
-     * constructor
10
-     *
11
-     * @param string $table_column        column on table
12
-     * @param string $nicename            nice name for column(field)
13
-     * @param bool   $nullable            is this field nullable
14
-     * @param string $default_value       default status
15
-     * @param array  $new_stati           If additional stati are to be used other than the default WP statuses then
16
-     *                                    they can be registered via this property.  The format of the array should be
17
-     *                                    as follows: array(
18
-     *                                    'status_reference' => array(
19
-     *                                    'label' => esc_html__('Status Reference Label', 'event_espresso')
20
-     *                                    'public' => true, //'Whether posts of this status should be shown on the
21
-     *                                    frontend of the site'
22
-     *                                    'exclude_from_search' => false, //'Whether posts of this status should be
23
-     *                                    excluded from wp searches'
24
-     *                                    'show_in_admin_all_list' => true, //whether posts of this status are included
25
-     *                                    in queries for the admin "all" view in list table views.
26
-     *                                    'show_in_admin_status_list' => true, //Show in the list of statuses with post
27
-     *                                    counts at the top of the admin list tables (i.e. Status Reference(2) )
28
-     *                                    'label_count' => _n_noop( 'Status Reference <span class="count">(%s)</span>',
29
-     *                                    'Status References <span class="count">(%s)</span>' ), //the text to display
30
-     *                                    on the admin screen( or you won't see your status count ).
31
-     *                                    )
32
-     *                                    )
33
-     * @link http://codex.wordpress.org/Function_Reference/register_post_status for more info
34
-     */
35
-    public function __construct($table_column, $nicename, $nullable, $default_value, array $new_stati = [])
36
-    {
37
-        $this->_register_new_stati($new_stati);
38
-        $this->_set_allowed_enum_values();
39
-        parent::__construct($table_column, $nicename, $nullable, $default_value, $this->_allowed_enum_values);
40
-    }
8
+	/**
9
+	 * constructor
10
+	 *
11
+	 * @param string $table_column        column on table
12
+	 * @param string $nicename            nice name for column(field)
13
+	 * @param bool   $nullable            is this field nullable
14
+	 * @param string $default_value       default status
15
+	 * @param array  $new_stati           If additional stati are to be used other than the default WP statuses then
16
+	 *                                    they can be registered via this property.  The format of the array should be
17
+	 *                                    as follows: array(
18
+	 *                                    'status_reference' => array(
19
+	 *                                    'label' => esc_html__('Status Reference Label', 'event_espresso')
20
+	 *                                    'public' => true, //'Whether posts of this status should be shown on the
21
+	 *                                    frontend of the site'
22
+	 *                                    'exclude_from_search' => false, //'Whether posts of this status should be
23
+	 *                                    excluded from wp searches'
24
+	 *                                    'show_in_admin_all_list' => true, //whether posts of this status are included
25
+	 *                                    in queries for the admin "all" view in list table views.
26
+	 *                                    'show_in_admin_status_list' => true, //Show in the list of statuses with post
27
+	 *                                    counts at the top of the admin list tables (i.e. Status Reference(2) )
28
+	 *                                    'label_count' => _n_noop( 'Status Reference <span class="count">(%s)</span>',
29
+	 *                                    'Status References <span class="count">(%s)</span>' ), //the text to display
30
+	 *                                    on the admin screen( or you won't see your status count ).
31
+	 *                                    )
32
+	 *                                    )
33
+	 * @link http://codex.wordpress.org/Function_Reference/register_post_status for more info
34
+	 */
35
+	public function __construct($table_column, $nicename, $nullable, $default_value, array $new_stati = [])
36
+	{
37
+		$this->_register_new_stati($new_stati);
38
+		$this->_set_allowed_enum_values();
39
+		parent::__construct($table_column, $nicename, $nullable, $default_value, $this->_allowed_enum_values);
40
+	}
41 41
 
42 42
 
43
-    /**
44
-     * This registers any new statuses sent via the $new_stati array on construct
45
-     *
46
-     * @access protected
47
-     * @param array $new_stati statuses
48
-     * @return void
49
-     */
50
-    protected function _register_new_stati($new_stati)
51
-    {
52
-        foreach ((array) $new_stati as $status_key => $status_args) {
53
-            $args = [
54
-                'label'                     => $status_args['label'] ?? $status_key,
55
-                'public'                    => ! (isset($status_args['public']) && is_bool($status_args['public']))
56
-                                               || $status_args['public'],
57
-                'exclude_from_search'       => isset($status_args['exclude_from_search'])
58
-                                               && is_bool($status_args['exclude_from_search'])
59
-                                               && $status_args['exclude_from_search'],
60
-                'show_in_admin_all_list'    => isset($status_args['show_in_admin_all_list'])
61
-                                               && is_bool($status_args['show_in_admin_all_list'])
62
-                                               && $status_args['show_in_admin_all_list'],
63
-                'show_in_admin_status_list' => ! (
64
-                        isset($status_args['show_in_admin_status_list'])
65
-                        && is_bool($status_args['show_in_admin_status_list'])
66
-                    ) || $status_args['show_in_admin_status_list'],
67
-                'label_count'               => $status_args['label_count'] ?? '',
68
-            ];
69
-            register_post_status($status_key, $args);
70
-        }
71
-    }
43
+	/**
44
+	 * This registers any new statuses sent via the $new_stati array on construct
45
+	 *
46
+	 * @access protected
47
+	 * @param array $new_stati statuses
48
+	 * @return void
49
+	 */
50
+	protected function _register_new_stati($new_stati)
51
+	{
52
+		foreach ((array) $new_stati as $status_key => $status_args) {
53
+			$args = [
54
+				'label'                     => $status_args['label'] ?? $status_key,
55
+				'public'                    => ! (isset($status_args['public']) && is_bool($status_args['public']))
56
+											   || $status_args['public'],
57
+				'exclude_from_search'       => isset($status_args['exclude_from_search'])
58
+											   && is_bool($status_args['exclude_from_search'])
59
+											   && $status_args['exclude_from_search'],
60
+				'show_in_admin_all_list'    => isset($status_args['show_in_admin_all_list'])
61
+											   && is_bool($status_args['show_in_admin_all_list'])
62
+											   && $status_args['show_in_admin_all_list'],
63
+				'show_in_admin_status_list' => ! (
64
+						isset($status_args['show_in_admin_status_list'])
65
+						&& is_bool($status_args['show_in_admin_status_list'])
66
+					) || $status_args['show_in_admin_status_list'],
67
+				'label_count'               => $status_args['label_count'] ?? '',
68
+			];
69
+			register_post_status($status_key, $args);
70
+		}
71
+	}
72 72
 
73 73
 
74
-    /**
75
-     * This sets the _allowed_enum_values property using the $wp_post_stati array
76
-     *
77
-     * @access protected
78
-     * @regurn void
79
-     */
80
-    protected function _set_allowed_enum_values()
81
-    {
82
-        // first let's get the post_statuses
83
-        global $wp_post_statuses;
84
-        $this->_wp_post_stati = $wp_post_statuses;
74
+	/**
75
+	 * This sets the _allowed_enum_values property using the $wp_post_stati array
76
+	 *
77
+	 * @access protected
78
+	 * @regurn void
79
+	 */
80
+	protected function _set_allowed_enum_values()
81
+	{
82
+		// first let's get the post_statuses
83
+		global $wp_post_statuses;
84
+		$this->_wp_post_stati = $wp_post_statuses;
85 85
 
86
-        foreach ($this->_wp_post_stati as $post_status => $args_object) {
87
-            $this->_allowed_enum_values[ $post_status ] = $args_object->label;
88
-        }
89
-    }
86
+		foreach ($this->_wp_post_stati as $post_status => $args_object) {
87
+			$this->_allowed_enum_values[ $post_status ] = $args_object->label;
88
+		}
89
+	}
90 90
 
91 91
 
92
-    /**
93
-     * Before calling parent, first double-checks our list of acceptable post
94
-     * types is up-to-date
95
-     *
96
-     * @param string $value_inputted_for_field_on_model_object
97
-     * @return string
98
-     */
99
-    public function prepare_for_set($value_inputted_for_field_on_model_object)
100
-    {
101
-        $this->_set_allowed_enum_values();
102
-        return parent::prepare_for_set($value_inputted_for_field_on_model_object);
103
-    }
92
+	/**
93
+	 * Before calling parent, first double-checks our list of acceptable post
94
+	 * types is up-to-date
95
+	 *
96
+	 * @param string $value_inputted_for_field_on_model_object
97
+	 * @return string
98
+	 */
99
+	public function prepare_for_set($value_inputted_for_field_on_model_object)
100
+	{
101
+		$this->_set_allowed_enum_values();
102
+		return parent::prepare_for_set($value_inputted_for_field_on_model_object);
103
+	}
104 104
 
105 105
 
106 106
 
107
-    // helper methods for getting various $wp_post_statuses stuff.
107
+	// helper methods for getting various $wp_post_statuses stuff.
108 108
 
109 109
 
110
-    /**
111
-     * This just returns the status object for the given status
112
-     *
113
-     * @param string $status What status object you want
114
-     * @return object|null         the status object or FALSE if it doesn't exist.
115
-     * @see    wp_register_post_status in wp-includes/post.php for a list of properties of the status object
116
-     */
117
-    public function get_status_object($status)
118
-    {
119
-        return $this->_wp_post_stati[ $status ] ?? null;
120
-    }
110
+	/**
111
+	 * This just returns the status object for the given status
112
+	 *
113
+	 * @param string $status What status object you want
114
+	 * @return object|null         the status object or FALSE if it doesn't exist.
115
+	 * @see    wp_register_post_status in wp-includes/post.php for a list of properties of the status object
116
+	 */
117
+	public function get_status_object($status)
118
+	{
119
+		return $this->_wp_post_stati[ $status ] ?? null;
120
+	}
121 121
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
         $this->_wp_post_stati = $wp_post_statuses;
85 85
 
86 86
         foreach ($this->_wp_post_stati as $post_status => $args_object) {
87
-            $this->_allowed_enum_values[ $post_status ] = $args_object->label;
87
+            $this->_allowed_enum_values[$post_status] = $args_object->label;
88 88
         }
89 89
     }
90 90
 
@@ -116,6 +116,6 @@  discard block
 block discarded – undo
116 116
      */
117 117
     public function get_status_object($status)
118 118
     {
119
-        return $this->_wp_post_stati[ $status ] ?? null;
119
+        return $this->_wp_post_stati[$status] ?? null;
120 120
     }
121 121
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Enum_Text_Field.php 1 patch
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -12,121 +12,121 @@
 block discarded – undo
12 12
  */
13 13
 class EE_Enum_Text_Field extends EE_Text_Field_Base
14 14
 {
15
-    public array $_allowed_enum_values;
15
+	public array $_allowed_enum_values;
16 16
 
17 17
 
18
-    /**
19
-     * @param string  $table_column
20
-     * @param string  $nice_name
21
-     * @param boolean $nullable
22
-     * @param mixed   $default_value
23
-     * @param array   $allowed_enum_values keys are values to be used in the DB, values are how they should be displayed
24
-     */
25
-    public function __construct($table_column, $nice_name, $nullable, $default_value, array $allowed_enum_values)
26
-    {
27
-        $this->_allowed_enum_values = (array) $allowed_enum_values;
28
-        parent::__construct($table_column, $nice_name, $nullable, $default_value);
29
-        $this->setSchemaType(SchemaType::OBJECT);
30
-    }
18
+	/**
19
+	 * @param string  $table_column
20
+	 * @param string  $nice_name
21
+	 * @param boolean $nullable
22
+	 * @param mixed   $default_value
23
+	 * @param array   $allowed_enum_values keys are values to be used in the DB, values are how they should be displayed
24
+	 */
25
+	public function __construct($table_column, $nice_name, $nullable, $default_value, array $allowed_enum_values)
26
+	{
27
+		$this->_allowed_enum_values = (array) $allowed_enum_values;
28
+		parent::__construct($table_column, $nice_name, $nullable, $default_value);
29
+		$this->setSchemaType(SchemaType::OBJECT);
30
+	}
31 31
 
32 32
 
33
-    /**
34
-     * Returns the list of allowed enum options, but filterable.
35
-     * This is used internally
36
-     *
37
-     * @return array
38
-     */
39
-    protected function _allowed_enum_values(): array
40
-    {
41
-        return (array) apply_filters(
42
-            'FHEE__EE_Enum_Text_Field___allowed_enum_options',
43
-            $this->_allowed_enum_values,
44
-            $this
45
-        );
46
-    }
33
+	/**
34
+	 * Returns the list of allowed enum options, but filterable.
35
+	 * This is used internally
36
+	 *
37
+	 * @return array
38
+	 */
39
+	protected function _allowed_enum_values(): array
40
+	{
41
+		return (array) apply_filters(
42
+			'FHEE__EE_Enum_Text_Field___allowed_enum_options',
43
+			$this->_allowed_enum_values,
44
+			$this
45
+		);
46
+	}
47 47
 
48 48
 
49
-    /**
50
-     * When setting, just verify that the value being used matches what we've defined as allowable enum values.
51
-     * If not, throw an error (but if WP_DEBUG is false, just set the value to default).
52
-     *
53
-     * @param string $value_inputted_for_field_on_model_object
54
-     * @return string
55
-     */
56
-    public function prepare_for_set($value_inputted_for_field_on_model_object)
57
-    {
58
-        if (
59
-            $value_inputted_for_field_on_model_object !== null
60
-            && ! array_key_exists($value_inputted_for_field_on_model_object, $this->_allowed_enum_values())
61
-        ) {
62
-            if (defined('WP_DEBUG') && WP_DEBUG) {
63
-                $msg  = sprintf(
64
-                    esc_html__('System is assigning incompatible value "%1$s" to field "%2$s"', 'event_espresso'),
65
-                    $value_inputted_for_field_on_model_object,
66
-                    $this->_name
67
-                );
68
-                $msg2 = sprintf(
69
-                    esc_html__('Allowed values for "%1$s" are "%2$s". You provided: "%3$s"', 'event_espresso'),
70
-                    $this->_name,
71
-                    implode(', ', array_keys($this->_allowed_enum_values())),
72
-                    $value_inputted_for_field_on_model_object
73
-                );
74
-                EE_Error::add_error("$msg||$msg2", __FILE__, __FUNCTION__, __LINE__);
75
-            }
76
-            return $this->get_default_value();
77
-        }
78
-        return $value_inputted_for_field_on_model_object;
79
-    }
49
+	/**
50
+	 * When setting, just verify that the value being used matches what we've defined as allowable enum values.
51
+	 * If not, throw an error (but if WP_DEBUG is false, just set the value to default).
52
+	 *
53
+	 * @param string $value_inputted_for_field_on_model_object
54
+	 * @return string
55
+	 */
56
+	public function prepare_for_set($value_inputted_for_field_on_model_object)
57
+	{
58
+		if (
59
+			$value_inputted_for_field_on_model_object !== null
60
+			&& ! array_key_exists($value_inputted_for_field_on_model_object, $this->_allowed_enum_values())
61
+		) {
62
+			if (defined('WP_DEBUG') && WP_DEBUG) {
63
+				$msg  = sprintf(
64
+					esc_html__('System is assigning incompatible value "%1$s" to field "%2$s"', 'event_espresso'),
65
+					$value_inputted_for_field_on_model_object,
66
+					$this->_name
67
+				);
68
+				$msg2 = sprintf(
69
+					esc_html__('Allowed values for "%1$s" are "%2$s". You provided: "%3$s"', 'event_espresso'),
70
+					$this->_name,
71
+					implode(', ', array_keys($this->_allowed_enum_values())),
72
+					$value_inputted_for_field_on_model_object
73
+				);
74
+				EE_Error::add_error("$msg||$msg2", __FILE__, __FUNCTION__, __LINE__);
75
+			}
76
+			return $this->get_default_value();
77
+		}
78
+		return $value_inputted_for_field_on_model_object;
79
+	}
80 80
 
81 81
 
82
-    /**
83
-     * Gets the pretty version of the enum's value.
84
-     *
85
-     * @param int|string  $value_on_field_to_be_outputted
86
-     * @param string|null $schema
87
-     * @return    string
88
-     */
89
-    public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, ?string $schema = null)
90
-    {
91
-        $options = $this->_allowed_enum_values();
92
-        return $options[ $value_on_field_to_be_outputted ] ?? $value_on_field_to_be_outputted;
93
-    }
82
+	/**
83
+	 * Gets the pretty version of the enum's value.
84
+	 *
85
+	 * @param int|string  $value_on_field_to_be_outputted
86
+	 * @param string|null $schema
87
+	 * @return    string
88
+	 */
89
+	public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, ?string $schema = null)
90
+	{
91
+		$options = $this->_allowed_enum_values();
92
+		return $options[ $value_on_field_to_be_outputted ] ?? $value_on_field_to_be_outputted;
93
+	}
94 94
 
95 95
 
96
-    /**
97
-     * When retrieving something from the DB, don't enforce the enum's options. If it's in the DB, we just have to live
98
-     * with that. Note also: when we're saving to the DB again, we also don't enforce the enum options. It's ONLY
99
-     * when we're receiving USER input from prepare_for_set() that we enforce the enum options.
100
-     *
101
-     * @param mixed $value_in_db
102
-     * @return mixed
103
-     */
104
-    public function prepare_for_set_from_db($value_in_db)
105
-    {
106
-        return $value_in_db;
107
-    }
96
+	/**
97
+	 * When retrieving something from the DB, don't enforce the enum's options. If it's in the DB, we just have to live
98
+	 * with that. Note also: when we're saving to the DB again, we also don't enforce the enum options. It's ONLY
99
+	 * when we're receiving USER input from prepare_for_set() that we enforce the enum options.
100
+	 *
101
+	 * @param mixed $value_in_db
102
+	 * @return mixed
103
+	 */
104
+	public function prepare_for_set_from_db($value_in_db)
105
+	{
106
+		return $value_in_db;
107
+	}
108 108
 
109 109
 
110
-    public function getSchemaProperties(): array
111
-    {
112
-        return [
113
-            'raw'    => [
114
-                'description' => sprintf(
115
-                    esc_html__('%s - the value in the database.', 'event_espresso'),
116
-                    $this->get_nicename()
117
-                ),
118
-                'type'        => SchemaType::STRING,
119
-                'enum'        => array_keys($this->_allowed_enum_values),
120
-            ],
121
-            'pretty' => [
122
-                'description' => sprintf(
123
-                    esc_html__('%s - the value for display.', 'event_espresso'),
124
-                    $this->get_nicename()
125
-                ),
126
-                'type'        => SchemaType::STRING,
127
-                'enum'        => array_values($this->_allowed_enum_values),
128
-                'read_only'   => true,
129
-            ],
130
-        ];
131
-    }
110
+	public function getSchemaProperties(): array
111
+	{
112
+		return [
113
+			'raw'    => [
114
+				'description' => sprintf(
115
+					esc_html__('%s - the value in the database.', 'event_espresso'),
116
+					$this->get_nicename()
117
+				),
118
+				'type'        => SchemaType::STRING,
119
+				'enum'        => array_keys($this->_allowed_enum_values),
120
+			],
121
+			'pretty' => [
122
+				'description' => sprintf(
123
+					esc_html__('%s - the value for display.', 'event_espresso'),
124
+					$this->get_nicename()
125
+				),
126
+				'type'        => SchemaType::STRING,
127
+				'enum'        => array_values($this->_allowed_enum_values),
128
+				'read_only'   => true,
129
+			],
130
+		];
131
+	}
132 132
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Post_Content_Field.php 1 patch
Indentation   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -8,133 +8,133 @@
 block discarded – undo
8 8
  */
9 9
 class EE_Post_Content_Field extends EE_Text_Field_Base
10 10
 {
11
-    /**
12
-     * @param string $table_column
13
-     * @param string $nicename
14
-     * @param bool   $nullable
15
-     * @param null   $default_value
16
-     */
17
-    public function __construct($table_column, $nicename, $nullable, $default_value = null)
18
-    {
19
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
20
-        $this->setSchemaType(SchemaType::STRING);
21
-    }
11
+	/**
12
+	 * @param string $table_column
13
+	 * @param string $nicename
14
+	 * @param bool   $nullable
15
+	 * @param null   $default_value
16
+	 */
17
+	public function __construct($table_column, $nicename, $nullable, $default_value = null)
18
+	{
19
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
20
+		$this->setSchemaType(SchemaType::STRING);
21
+	}
22 22
 
23 23
 
24
-    /**
25
-     * removes all tags which a WP Post wouldn't allow in its content normally
26
-     *
27
-     * @param string $value
28
-     * @return string
29
-     */
30
-    public function prepare_for_set($value)
31
-    {
32
-        if (! current_user_can('unfiltered_html')) {
33
-            $value = wp_kses("$value", wp_kses_allowed_html('post'));
34
-        }
35
-        return parent::prepare_for_set($value);
36
-    }
24
+	/**
25
+	 * removes all tags which a WP Post wouldn't allow in its content normally
26
+	 *
27
+	 * @param string $value
28
+	 * @return string
29
+	 */
30
+	public function prepare_for_set($value)
31
+	{
32
+		if (! current_user_can('unfiltered_html')) {
33
+			$value = wp_kses("$value", wp_kses_allowed_html('post'));
34
+		}
35
+		return parent::prepare_for_set($value);
36
+	}
37 37
 
38 38
 
39
-    /**
40
-     * Runs the content through `the_content`, or if prepares the content for placing in a form input
41
-     *
42
-     * @param string      $value_on_field_to_be_outputted
43
-     * @param string|null $schema possible values: 'form_input' or null (if null, will run through 'the_content')
44
-     * @return string
45
-     * @throws EE_Error when WP_DEBUG is on and recursive calling is detected
46
-     */
47
-    public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, ?string $schema = null)
48
-    {
49
-        switch ($schema) {
50
-            case 'form_input':
51
-                return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema);
52
-            case 'the_content':
53
-                if (doing_filter('the_content')) {
54
-                    if (defined('WP_DEBUG') && WP_DEBUG) {
55
-                        throw new EE_Error(
56
-                            sprintf(
57
-                                esc_html__(
58
-                                    'You have recursively called "%1$s" with %2$s set to %3$s which uses "%2$s" filter. You should use it with %2$s "%3$s" instead here.',
59
-                                    'event_espresso'
60
-                                ),
61
-                                'EE_Post_Content_Field::prepare_for_pretty_echoing',
62
-                                '$schema',
63
-                                'the_content',
64
-                                'the_content_wp_core_only'
65
-                            )
66
-                        );
67
-                    } else {
68
-                        return $this->prepare_for_pretty_echoing(
69
-                            $value_on_field_to_be_outputted,
70
-                            'the_content_wp_core_only'
71
-                        );
72
-                    }
73
-                }
74
-                return apply_filters(
75
-                    'the_content',
76
-                    parent::prepare_for_pretty_echoing(
77
-                        $value_on_field_to_be_outputted,
78
-                        $schema
79
-                    )
80
-                );
81
-            case 'the_content_wp_core_only':
82
-            default:
83
-                self::_setup_the_content_wp_core_only_filters();
84
-                $return_value = apply_filters(
85
-                    'the_content_wp_core_only',
86
-                    parent::prepare_for_pretty_echoing(
87
-                        $value_on_field_to_be_outputted,
88
-                        $schema
89
-                    )
90
-                );
91
-                // ya know what? adding these filters is super fast. Let's just
92
-                // avoid needing to maintain global state and set this up as-needed
93
-                remove_all_filters('the_content_wp_core_only');
94
-                do_action('AHEE__EE_Post_Content_Field__prepare_for_pretty_echoing__the_content_wp_core_only__done');
95
-                return $return_value;
96
-        }
97
-    }
39
+	/**
40
+	 * Runs the content through `the_content`, or if prepares the content for placing in a form input
41
+	 *
42
+	 * @param string      $value_on_field_to_be_outputted
43
+	 * @param string|null $schema possible values: 'form_input' or null (if null, will run through 'the_content')
44
+	 * @return string
45
+	 * @throws EE_Error when WP_DEBUG is on and recursive calling is detected
46
+	 */
47
+	public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, ?string $schema = null)
48
+	{
49
+		switch ($schema) {
50
+			case 'form_input':
51
+				return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema);
52
+			case 'the_content':
53
+				if (doing_filter('the_content')) {
54
+					if (defined('WP_DEBUG') && WP_DEBUG) {
55
+						throw new EE_Error(
56
+							sprintf(
57
+								esc_html__(
58
+									'You have recursively called "%1$s" with %2$s set to %3$s which uses "%2$s" filter. You should use it with %2$s "%3$s" instead here.',
59
+									'event_espresso'
60
+								),
61
+								'EE_Post_Content_Field::prepare_for_pretty_echoing',
62
+								'$schema',
63
+								'the_content',
64
+								'the_content_wp_core_only'
65
+							)
66
+						);
67
+					} else {
68
+						return $this->prepare_for_pretty_echoing(
69
+							$value_on_field_to_be_outputted,
70
+							'the_content_wp_core_only'
71
+						);
72
+					}
73
+				}
74
+				return apply_filters(
75
+					'the_content',
76
+					parent::prepare_for_pretty_echoing(
77
+						$value_on_field_to_be_outputted,
78
+						$schema
79
+					)
80
+				);
81
+			case 'the_content_wp_core_only':
82
+			default:
83
+				self::_setup_the_content_wp_core_only_filters();
84
+				$return_value = apply_filters(
85
+					'the_content_wp_core_only',
86
+					parent::prepare_for_pretty_echoing(
87
+						$value_on_field_to_be_outputted,
88
+						$schema
89
+					)
90
+				);
91
+				// ya know what? adding these filters is super fast. Let's just
92
+				// avoid needing to maintain global state and set this up as-needed
93
+				remove_all_filters('the_content_wp_core_only');
94
+				do_action('AHEE__EE_Post_Content_Field__prepare_for_pretty_echoing__the_content_wp_core_only__done');
95
+				return $return_value;
96
+		}
97
+	}
98 98
 
99 99
 
100
-    /**
101
-     * Verifies we've setup the standard WP core filters on  'the_content_wp_core_only' filter
102
-     */
103
-    protected static function _setup_the_content_wp_core_only_filters()
104
-    {
105
-        add_filter('the_content_wp_core_only', [$GLOBALS['wp_embed'], 'run_shortcode'], 8);
106
-        add_filter('the_content_wp_core_only', [$GLOBALS['wp_embed'], 'autoembed'], 8);
107
-        add_filter('the_content_wp_core_only', 'wptexturize', 10);
108
-        add_filter('the_content_wp_core_only', 'wpautop', 10);
109
-        add_filter('the_content_wp_core_only', 'shortcode_unautop', 10);
110
-        add_filter('the_content_wp_core_only', 'prepend_attachment', 10);
111
-        if (function_exists('wp_filter_content_tags')) {
112
-            add_filter('the_content_wp_core_only', 'wp_filter_content_tags', 10);
113
-        } elseif (function_exists('wp_make_content_images_responsive')) {
114
-            add_filter('the_content_wp_core_only', 'wp_make_content_images_responsive', 10);
115
-        }
116
-        add_filter('the_content_wp_core_only', 'do_shortcode', 11);
117
-        add_filter('the_content_wp_core_only', 'convert_smilies', 20);
118
-    }
100
+	/**
101
+	 * Verifies we've setup the standard WP core filters on  'the_content_wp_core_only' filter
102
+	 */
103
+	protected static function _setup_the_content_wp_core_only_filters()
104
+	{
105
+		add_filter('the_content_wp_core_only', [$GLOBALS['wp_embed'], 'run_shortcode'], 8);
106
+		add_filter('the_content_wp_core_only', [$GLOBALS['wp_embed'], 'autoembed'], 8);
107
+		add_filter('the_content_wp_core_only', 'wptexturize', 10);
108
+		add_filter('the_content_wp_core_only', 'wpautop', 10);
109
+		add_filter('the_content_wp_core_only', 'shortcode_unautop', 10);
110
+		add_filter('the_content_wp_core_only', 'prepend_attachment', 10);
111
+		if (function_exists('wp_filter_content_tags')) {
112
+			add_filter('the_content_wp_core_only', 'wp_filter_content_tags', 10);
113
+		} elseif (function_exists('wp_make_content_images_responsive')) {
114
+			add_filter('the_content_wp_core_only', 'wp_make_content_images_responsive', 10);
115
+		}
116
+		add_filter('the_content_wp_core_only', 'do_shortcode', 11);
117
+		add_filter('the_content_wp_core_only', 'convert_smilies', 20);
118
+	}
119 119
 
120 120
 
121
-    public function getSchemaProperties(): array
122
-    {
123
-        return [
124
-            'raw'      => [
125
-                'description' => sprintf(
126
-                    esc_html__('%s - the content as it exists in the database.', 'event_espresso'),
127
-                    $this->get_nicename()
128
-                ),
129
-                'type'        => SchemaType::STRING,
130
-            ],
131
-            'rendered' => [
132
-                'description' => sprintf(
133
-                    esc_html__('%s - the content rendered for display.', 'event_espresso'),
134
-                    $this->get_nicename()
135
-                ),
136
-                'type'        => SchemaType::STRING,
137
-            ],
138
-        ];
139
-    }
121
+	public function getSchemaProperties(): array
122
+	{
123
+		return [
124
+			'raw'      => [
125
+				'description' => sprintf(
126
+					esc_html__('%s - the content as it exists in the database.', 'event_espresso'),
127
+					$this->get_nicename()
128
+				),
129
+				'type'        => SchemaType::STRING,
130
+			],
131
+			'rendered' => [
132
+				'description' => sprintf(
133
+					esc_html__('%s - the content rendered for display.', 'event_espresso'),
134
+					$this->get_nicename()
135
+				),
136
+				'type'        => SchemaType::STRING,
137
+			],
138
+		];
139
+	}
140 140
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Password_Field.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -10,53 +10,53 @@
 block discarded – undo
10 10
  */
11 11
 class EE_Password_Field extends EE_Text_Field_Base
12 12
 {
13
-    protected array $protected_fields;
13
+	protected array $protected_fields;
14 14
 
15 15
 
16
-    /**
17
-     * EE_Password_Field constructor.
18
-     *
19
-     * @param       $table_column
20
-     * @param       $nicename
21
-     * @param       $nullable
22
-     * @param null  $default_value
23
-     * @param array $protected_fields
24
-     */
25
-    public function __construct(
26
-        $table_column,
27
-        $nicename,
28
-        $nullable,
29
-        $default_value = null,
30
-        array $protected_fields =
31
-        []
32
-    ) {
33
-        $this->protected_fields = $protected_fields;
34
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
35
-    }
16
+	/**
17
+	 * EE_Password_Field constructor.
18
+	 *
19
+	 * @param       $table_column
20
+	 * @param       $nicename
21
+	 * @param       $nullable
22
+	 * @param null  $default_value
23
+	 * @param array $protected_fields
24
+	 */
25
+	public function __construct(
26
+		$table_column,
27
+		$nicename,
28
+		$nullable,
29
+		$default_value = null,
30
+		array $protected_fields =
31
+		[]
32
+	) {
33
+		$this->protected_fields = $protected_fields;
34
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
35
+	}
36 36
 
37 37
 
38
-    /**
39
-     * Returns the names of the fields on this model that this password field should protect
40
-     *
41
-     * @return array
42
-     * @since 4.9.74.p
43
-     */
44
-    public function protectedFields(): array
45
-    {
46
-        return $this->protected_fields;
47
-    }
38
+	/**
39
+	 * Returns the names of the fields on this model that this password field should protect
40
+	 *
41
+	 * @return array
42
+	 * @since 4.9.74.p
43
+	 */
44
+	public function protectedFields(): array
45
+	{
46
+		return $this->protected_fields;
47
+	}
48 48
 
49 49
 
50
-    /**
51
-     * Returns whether or not the specified field is protected by this model
52
-     *
53
-     * @param $field_name
54
-     * @return bool
55
-     * @since 4.9.74.p
56
-     */
57
-    public function fieldIsProtected($field_name): bool
58
-    {
59
-        return in_array($field_name, $this->protectedFields(), true);
60
-    }
50
+	/**
51
+	 * Returns whether or not the specified field is protected by this model
52
+	 *
53
+	 * @param $field_name
54
+	 * @return bool
55
+	 * @since 4.9.74.p
56
+	 */
57
+	public function fieldIsProtected($field_name): bool
58
+	{
59
+		return in_array($field_name, $this->protectedFields(), true);
60
+	}
61 61
 }
62 62
 // Location: ${NAMESPACE}/EE_Password_Field.php
Please login to merge, or discard this patch.
core/db_models/fields/EE_Float_Field.php 1 patch
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -8,84 +8,84 @@
 block discarded – undo
8 8
  */
9 9
 class EE_Float_Field extends EE_Model_Field_Base
10 10
 {
11
-    /**
12
-     * @var EE_Currency_Config
13
-     */
14
-    protected $currency;
11
+	/**
12
+	 * @var EE_Currency_Config
13
+	 */
14
+	protected $currency;
15 15
 
16 16
 
17
-    /**
18
-     * @param string $table_column
19
-     * @param string $nicename
20
-     * @param bool   $nullable
21
-     * @param null   $default_value
22
-     */
23
-    public function __construct($table_column, $nicename, $nullable, $default_value = null)
24
-    {
25
-        $this->currency = EE_Config::instance()->currency instanceof EE_Currency_Config
26
-            ? EE_Config::instance()->currency
27
-            : new EE_Currency_Config();
28
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
29
-        $this->setSchemaType(SchemaType::NUMBER);
30
-    }
17
+	/**
18
+	 * @param string $table_column
19
+	 * @param string $nicename
20
+	 * @param bool   $nullable
21
+	 * @param null   $default_value
22
+	 */
23
+	public function __construct($table_column, $nicename, $nullable, $default_value = null)
24
+	{
25
+		$this->currency = EE_Config::instance()->currency instanceof EE_Currency_Config
26
+			? EE_Config::instance()->currency
27
+			: new EE_Currency_Config();
28
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
29
+		$this->setSchemaType(SchemaType::NUMBER);
30
+	}
31 31
 
32 32
 
33
-    /**
34
-     * If provided a string, strips out number-related formatting, like commas, periods, spaces, other junk, etc.
35
-     * However, treats commas and periods as thousand-separators ro decimal marks, as indicate by the config's currency.
36
-     * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, typecast as float first.
37
-     * Returns a float
38
-     *
39
-     * @param float|string $number
40
-     * @return float
41
-     */
42
-    public function prepare_for_set($number)
43
-    {
44
-        // remove whitespaces and thousands separators
45
-        if (is_string($number)) {
46
-            // scientific notation can just be cast as a float
47
-            if (strpos($number, 'e') || strpos($number, 'E')) {
48
-                return (float) $number;
49
-            }
50
-            $number = str_replace(
51
-                array(" ", $this->currency->thsnds),
52
-                "",
53
-                $number
54
-            );
55
-            // normalize it so periods are decimal marks (we don't care where you're from: we're talking PHP now)
56
-            $number = str_replace(
57
-                $this->currency->dec_mrk,
58
-                ".",
59
-                $number
60
-            );
61
-            // double-check there's absolutely nothing left on this string besides numbers
62
-            $number = preg_replace(
63
-                "/[^0-9,.]/",
64
-                "",
65
-                $number
66
-            );
67
-        }
68
-        return (float) $number;
69
-    }
33
+	/**
34
+	 * If provided a string, strips out number-related formatting, like commas, periods, spaces, other junk, etc.
35
+	 * However, treats commas and periods as thousand-separators ro decimal marks, as indicate by the config's currency.
36
+	 * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, typecast as float first.
37
+	 * Returns a float
38
+	 *
39
+	 * @param float|string $number
40
+	 * @return float
41
+	 */
42
+	public function prepare_for_set($number)
43
+	{
44
+		// remove whitespaces and thousands separators
45
+		if (is_string($number)) {
46
+			// scientific notation can just be cast as a float
47
+			if (strpos($number, 'e') || strpos($number, 'E')) {
48
+				return (float) $number;
49
+			}
50
+			$number = str_replace(
51
+				array(" ", $this->currency->thsnds),
52
+				"",
53
+				$number
54
+			);
55
+			// normalize it so periods are decimal marks (we don't care where you're from: we're talking PHP now)
56
+			$number = str_replace(
57
+				$this->currency->dec_mrk,
58
+				".",
59
+				$number
60
+			);
61
+			// double-check there's absolutely nothing left on this string besides numbers
62
+			$number = preg_replace(
63
+				"/[^0-9,.]/",
64
+				"",
65
+				$number
66
+			);
67
+		}
68
+		return (float) $number;
69
+	}
70 70
 
71
-    /**
72
-     * Returns the number formatted according to local custom (set by the country of the blog).
73
-     *
74
-     * @param float $number
75
-     * @return string
76
-     */
77
-    public function prepare_for_pretty_echoing($number, ?string $schema = null)
78
-    {
79
-        return number_format(
80
-            $number,
81
-            $this->currency->dec_plc,
82
-            $this->currency->dec_mrk,
83
-            $this->currency->thsnds
84
-        );
85
-    }
71
+	/**
72
+	 * Returns the number formatted according to local custom (set by the country of the blog).
73
+	 *
74
+	 * @param float $number
75
+	 * @return string
76
+	 */
77
+	public function prepare_for_pretty_echoing($number, ?string $schema = null)
78
+	{
79
+		return number_format(
80
+			$number,
81
+			$this->currency->dec_plc,
82
+			$this->currency->dec_mrk,
83
+			$this->currency->thsnds
84
+		);
85
+	}
86 86
 
87
-    public function prepare_for_set_from_db($number)
88
-    {
89
-        return (float) $number;
90
-    }
87
+	public function prepare_for_set_from_db($number)
88
+	{
89
+		return (float) $number;
90
+	}
91 91
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Text_Field_Base.php 1 patch
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -8,68 +8,68 @@
 block discarded – undo
8 8
  */
9 9
 abstract class EE_Text_Field_Base extends EE_Model_Field_Base
10 10
 {
11
-    /**
12
-     * @param string $table_column
13
-     * @param string $nicename
14
-     * @param bool   $nullable
15
-     * @param null   $default_value
16
-     */
17
-    public function __construct($table_column, $nicename, $nullable, $default_value = null)
18
-    {
19
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
20
-        $this->setSchemaType(SchemaType::STRING);
21
-    }
11
+	/**
12
+	 * @param string $table_column
13
+	 * @param string $nicename
14
+	 * @param bool   $nullable
15
+	 * @param null   $default_value
16
+	 */
17
+	public function __construct($table_column, $nicename, $nullable, $default_value = null)
18
+	{
19
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
20
+		$this->setSchemaType(SchemaType::STRING);
21
+	}
22 22
 
23 23
 
24
-    /**
25
-     * Gets the value in the format expected when being set.
26
-     * For display on the front-end, usually you would use prepare_for_pretty_echoing() instead.
27
-     *
28
-     * @param mixed $value_of_field_on_model_object
29
-     * @return mixed|string
30
-     */
31
-    public function prepare_for_get($value_of_field_on_model_object)
32
-    {
33
-        if ($value_of_field_on_model_object === null) {
34
-            return $this->is_nullable() ? null : '';
35
-        }
36
-        return $value_of_field_on_model_object;
37
-    }
24
+	/**
25
+	 * Gets the value in the format expected when being set.
26
+	 * For display on the front-end, usually you would use prepare_for_pretty_echoing() instead.
27
+	 *
28
+	 * @param mixed $value_of_field_on_model_object
29
+	 * @return mixed|string
30
+	 */
31
+	public function prepare_for_get($value_of_field_on_model_object)
32
+	{
33
+		if ($value_of_field_on_model_object === null) {
34
+			return $this->is_nullable() ? null : '';
35
+		}
36
+		return $value_of_field_on_model_object;
37
+	}
38 38
 
39 39
 
40
-    /**
41
-     * Accepts schema of 'form_input' which formats the string for echoing in form input's value.
42
-     *
43
-     * @param mixed       $value_on_field_to_be_outputted
44
-     * @param string|null $schema
45
-     * @return string
46
-     */
47
-    public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, ?string $schema = null)
48
-    {
49
-        if ($schema === 'form_input') {
50
-            $value_on_field_to_be_outputted = htmlentities(
51
-                (string) $value_on_field_to_be_outputted,
52
-                ENT_QUOTES,
53
-                'UTF-8'
54
-            );
55
-        }
56
-        return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted);
57
-    }
40
+	/**
41
+	 * Accepts schema of 'form_input' which formats the string for echoing in form input's value.
42
+	 *
43
+	 * @param mixed       $value_on_field_to_be_outputted
44
+	 * @param string|null $schema
45
+	 * @return string
46
+	 */
47
+	public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, ?string $schema = null)
48
+	{
49
+		if ($schema === 'form_input') {
50
+			$value_on_field_to_be_outputted = htmlentities(
51
+				(string) $value_on_field_to_be_outputted,
52
+				ENT_QUOTES,
53
+				'UTF-8'
54
+			);
55
+		}
56
+		return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted);
57
+	}
58 58
 
59 59
 
60
-    /**
61
-     * Data received from the user should be exactly as they hope to save it in the DB, with the exception that
62
-     * quotes need to have slashes added to it. This method takes care of removing the slashes added by WP
63
-     * in magic-quotes fashion. We used to call html_entity_decode on the value here,
64
-     * because we called htmlentities when in EE_Text_Field_Base::prepare_for_pretty_echoing, but that's not necessary
65
-     * because web browsers always decode HTML entities in element attributes, like a form element's value attribute.
66
-     * So if we do it again here, we'll be removing HTML entities the user intended to have.)
67
-     *
68
-     * @param string|null $value_inputted_for_field_on_model_object
69
-     * @return string
70
-     */
71
-    public function prepare_for_set($value_inputted_for_field_on_model_object)
72
-    {
73
-        return stripslashes((string) parent::prepare_for_set($value_inputted_for_field_on_model_object));
74
-    }
60
+	/**
61
+	 * Data received from the user should be exactly as they hope to save it in the DB, with the exception that
62
+	 * quotes need to have slashes added to it. This method takes care of removing the slashes added by WP
63
+	 * in magic-quotes fashion. We used to call html_entity_decode on the value here,
64
+	 * because we called htmlentities when in EE_Text_Field_Base::prepare_for_pretty_echoing, but that's not necessary
65
+	 * because web browsers always decode HTML entities in element attributes, like a form element's value attribute.
66
+	 * So if we do it again here, we'll be removing HTML entities the user intended to have.)
67
+	 *
68
+	 * @param string|null $value_inputted_for_field_on_model_object
69
+	 * @return string
70
+	 */
71
+	public function prepare_for_set($value_inputted_for_field_on_model_object)
72
+	{
73
+		return stripslashes((string) parent::prepare_for_set($value_inputted_for_field_on_model_object));
74
+	}
75 75
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Infinite_Integer_Field.php 1 patch
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -11,77 +11,77 @@
 block discarded – undo
11 11
  */
12 12
 class EE_Infinite_Integer_Field extends EE_Model_Field_Base
13 13
 {
14
-    /**
15
-     * @param string $table_column
16
-     * @param string $nicename
17
-     * @param bool   $nullable
18
-     * @param null   $default_value
19
-     */
20
-    public function __construct($table_column, $nicename, $nullable, $default_value = null)
21
-    {
22
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
23
-        $this->setSchemaType([SchemaType::INTEGER, SchemaType::NULL]);
24
-    }
14
+	/**
15
+	 * @param string $table_column
16
+	 * @param string $nicename
17
+	 * @param bool   $nullable
18
+	 * @param null   $default_value
19
+	 */
20
+	public function __construct($table_column, $nicename, $nullable, $default_value = null)
21
+	{
22
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
23
+		$this->setSchemaType([SchemaType::INTEGER, SchemaType::NULL]);
24
+	}
25 25
 
26 26
 
27
-    public function prepare_for_use_in_db($value_of_field_on_model_object)
28
-    {
29
-        if ($value_of_field_on_model_object === EE_INF) {
30
-            return EE_INF_IN_DB;
31
-        }
32
-        return (int) $value_of_field_on_model_object;
33
-    }
27
+	public function prepare_for_use_in_db($value_of_field_on_model_object)
28
+	{
29
+		if ($value_of_field_on_model_object === EE_INF) {
30
+			return EE_INF_IN_DB;
31
+		}
32
+		return (int) $value_of_field_on_model_object;
33
+	}
34 34
 
35 35
 
36
-    public function prepare_for_set($value_inputted_for_field_on_model_object)
37
-    {
38
-        if (
39
-            $value_inputted_for_field_on_model_object === EE_INF_IN_DB ||
40
-            $value_inputted_for_field_on_model_object === EE_INF ||
41
-            $value_inputted_for_field_on_model_object === "EE_INF" ||
42
-            $value_inputted_for_field_on_model_object === ""
43
-        ) {
44
-            return EE_INF;
45
-        }
46
-        return (int) $value_inputted_for_field_on_model_object;
47
-    }
36
+	public function prepare_for_set($value_inputted_for_field_on_model_object)
37
+	{
38
+		if (
39
+			$value_inputted_for_field_on_model_object === EE_INF_IN_DB ||
40
+			$value_inputted_for_field_on_model_object === EE_INF ||
41
+			$value_inputted_for_field_on_model_object === "EE_INF" ||
42
+			$value_inputted_for_field_on_model_object === ""
43
+		) {
44
+			return EE_INF;
45
+		}
46
+		return (int) $value_inputted_for_field_on_model_object;
47
+	}
48 48
 
49 49
 
50
-    public function prepare_for_set_from_db($value_inputted_for_field_on_model_object)
51
-    {
52
-        $intval = (int) $value_inputted_for_field_on_model_object;
53
-        if ($intval == EE_INF_IN_DB) {
54
-            return EE_INF;
55
-        }
56
-        return $intval;
57
-    }
50
+	public function prepare_for_set_from_db($value_inputted_for_field_on_model_object)
51
+	{
52
+		$intval = (int) $value_inputted_for_field_on_model_object;
53
+		if ($intval == EE_INF_IN_DB) {
54
+			return EE_INF;
55
+		}
56
+		return $intval;
57
+	}
58 58
 
59 59
 
60
-    /**
61
-     * For outputting this field's value. If you want to output it into an input or something,
62
-     * use $schema=='input', as it will replace EE_INF with ''. If you want a readable version, use $schema=='text'
63
-     * as it will replace EE_INF with i18n Infinite
64
-     *
65
-     * @param mixed       $value_on_field_to_be_outputted
66
-     * @param string|null $schema input, symbol, text; or any string you want to show if the value equals EE_INF
67
-     * @return string
68
-     */
69
-    public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, ?string $schema = null)
70
-    {
71
-        if ($value_on_field_to_be_outputted === EE_INF) {
72
-            switch ($schema) {
73
-                case 'input':
74
-                case 'form_input':
75
-                    return '';
76
-                case 'symbol':
77
-                    return "&infin;";
78
-                case 'text':
79
-                case null:
80
-                    return esc_html__("Unlimited", "event_espresso");
81
-                default:
82
-                    return $schema;
83
-            }
84
-        }
85
-        return $value_on_field_to_be_outputted;
86
-    }
60
+	/**
61
+	 * For outputting this field's value. If you want to output it into an input or something,
62
+	 * use $schema=='input', as it will replace EE_INF with ''. If you want a readable version, use $schema=='text'
63
+	 * as it will replace EE_INF with i18n Infinite
64
+	 *
65
+	 * @param mixed       $value_on_field_to_be_outputted
66
+	 * @param string|null $schema input, symbol, text; or any string you want to show if the value equals EE_INF
67
+	 * @return string
68
+	 */
69
+	public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, ?string $schema = null)
70
+	{
71
+		if ($value_on_field_to_be_outputted === EE_INF) {
72
+			switch ($schema) {
73
+				case 'input':
74
+				case 'form_input':
75
+					return '';
76
+				case 'symbol':
77
+					return "&infin;";
78
+				case 'text':
79
+				case null:
80
+					return esc_html__("Unlimited", "event_espresso");
81
+				default:
82
+					return $schema;
83
+			}
84
+		}
85
+		return $value_on_field_to_be_outputted;
86
+	}
87 87
 }
Please login to merge, or discard this patch.