Completed
Branch fix-unit-tests (9a2fb0)
by
unknown
06:58 queued 05:09
created
domain/entities/route_match/specifications/admin/EspressoPostTypeEditor.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -18,22 +18,22 @@
 block discarded – undo
18 18
  */
19 19
 class EspressoPostTypeEditor extends MatchAnyRouteSpecification
20 20
 {
21
-    /**
22
-     * EspressoEventEditor constructor.
23
-     *
24
-     * @param EspressoStandardPostTypeEditor $standard_route_match
25
-     * @param EspressoAttendeePostTypeEditor $attendee_route_match
26
-     * @param RequestInterface          $request
27
-     * @throws InvalidEntityException
28
-     */
29
-    public function __construct(
30
-        EspressoStandardPostTypeEditor $standard_route_match,
31
-        EspressoAttendeePostTypeEditor $attendee_route_match,
32
-        RequestInterface $request
33
-    ) {
34
-        parent::__construct(
35
-            array($standard_route_match, $attendee_route_match),
36
-            $request
37
-        );
38
-    }
21
+	/**
22
+	 * EspressoEventEditor constructor.
23
+	 *
24
+	 * @param EspressoStandardPostTypeEditor $standard_route_match
25
+	 * @param EspressoAttendeePostTypeEditor $attendee_route_match
26
+	 * @param RequestInterface          $request
27
+	 * @throws InvalidEntityException
28
+	 */
29
+	public function __construct(
30
+		EspressoStandardPostTypeEditor $standard_route_match,
31
+		EspressoAttendeePostTypeEditor $attendee_route_match,
32
+		RequestInterface $request
33
+	) {
34
+		parent::__construct(
35
+			array($standard_route_match, $attendee_route_match),
36
+			$request
37
+		);
38
+	}
39 39
 }
Please login to merge, or discard this patch.
domain/entities/route_match/specifications/admin/WordPressPageEditor.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -18,22 +18,22 @@
 block discarded – undo
18 18
  */
19 19
 class WordPressPageEditor extends MatchAnyRouteSpecification
20 20
 {
21
-    /**
22
-     * WordPressPostsEditor constructor.
23
-     *
24
-     * @param WordPressPostsEditorEdit $edit_page_route_match
25
-     * @param WordPressPostsEditorAddNew $create_page_route_match
26
-     * @param RequestInterface           $request
27
-     * @throws \EventEspresso\core\exceptions\InvalidEntityException
28
-     */
29
-    public function __construct(
30
-        WordPressPageEditorEdit $edit_page_route_match,
31
-        WordPressPageEditorAddNew $create_page_route_match,
32
-        RequestInterface $request
33
-    ) {
34
-        parent::__construct(
35
-            array($edit_page_route_match, $create_page_route_match),
36
-            $request
37
-        );
38
-    }
21
+	/**
22
+	 * WordPressPostsEditor constructor.
23
+	 *
24
+	 * @param WordPressPostsEditorEdit $edit_page_route_match
25
+	 * @param WordPressPostsEditorAddNew $create_page_route_match
26
+	 * @param RequestInterface           $request
27
+	 * @throws \EventEspresso\core\exceptions\InvalidEntityException
28
+	 */
29
+	public function __construct(
30
+		WordPressPageEditorEdit $edit_page_route_match,
31
+		WordPressPageEditorAddNew $create_page_route_match,
32
+		RequestInterface $request
33
+	) {
34
+		parent::__construct(
35
+			array($edit_page_route_match, $create_page_route_match),
36
+			$request
37
+		);
38
+	}
39 39
 }
Please login to merge, or discard this patch.
core/entities/models/JsonModelSchema.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -76,22 +76,22 @@  discard block
 block discarded – undo
76 76
     public function getModelSchemaForFields(array $model_fields, array $schema)
77 77
     {
78 78
         foreach ($model_fields as $field => $model_field) {
79
-            if (! $model_field instanceof EE_Model_Field_Base) {
79
+            if ( ! $model_field instanceof EE_Model_Field_Base) {
80 80
                 continue;
81 81
             }
82
-            $schema['properties'][ $field ] = $model_field->getSchema();
82
+            $schema['properties'][$field] = $model_field->getSchema();
83 83
 
84 84
             // if this is a primary key field add the primary key item
85 85
             if ($model_field instanceof EE_Primary_Key_Field_Base) {
86
-                $schema['properties'][ $field ]['primary_key'] = true;
86
+                $schema['properties'][$field]['primary_key'] = true;
87 87
                 if ($model_field instanceof EE_Primary_Key_Int_Field) {
88
-                    $schema['properties'][ $field ]['readonly'] = true;
88
+                    $schema['properties'][$field]['readonly'] = true;
89 89
                 }
90 90
             }
91 91
 
92 92
             // if this is a foreign key field add the foreign key item
93 93
             if ($model_field instanceof EE_Foreign_Key_Field_Base) {
94
-                $schema['properties'][ $field ]['foreign_key'] = array(
94
+                $schema['properties'][$field]['foreign_key'] = array(
95 95
                     'description' => esc_html__(
96 96
                         'This is a foreign key the points to the given models.',
97 97
                         'event_espresso'
@@ -115,18 +115,18 @@  discard block
 block discarded – undo
115 115
     public function getModelSchemaForRelations(array $relations_on_model, array $schema)
116 116
     {
117 117
         foreach ($relations_on_model as $model_name => $relation) {
118
-            if (! $relation instanceof EE_Model_Relation_Base) {
118
+            if ( ! $relation instanceof EE_Model_Relation_Base) {
119 119
                 continue;
120 120
             }
121 121
             $model_name_for_schema = $relation instanceof EE_Belongs_To_Relation
122 122
                 ? strtolower($model_name)
123 123
                 : EEH_Inflector::pluralize_and_lower($model_name);
124
-            $schema['properties'][ $model_name_for_schema ] = $relation->getSchema();
125
-            $schema['properties'][ $model_name_for_schema ]['relation_model'] = $model_name;
124
+            $schema['properties'][$model_name_for_schema] = $relation->getSchema();
125
+            $schema['properties'][$model_name_for_schema]['relation_model'] = $model_name;
126 126
 
127 127
             // links schema
128
-            $links_key = 'https://api.eventespresso.com/' . strtolower($model_name);
129
-            $schema['properties']['_links']['properties'][ $links_key ] = array(
128
+            $links_key = 'https://api.eventespresso.com/'.strtolower($model_name);
129
+            $schema['properties']['_links']['properties'][$links_key] = array(
130 130
                 'description' => esc_html__(
131 131
                     'Array of objects describing the link(s) for this relation resource.',
132 132
                     'event_espresso'
Please login to merge, or discard this patch.
Indentation   +234 added lines, -234 removed lines patch added patch discarded remove patch
@@ -25,255 +25,255 @@
 block discarded – undo
25 25
 class JsonModelSchema
26 26
 {
27 27
 
28
-    /**
29
-     * @var EEM_Base
30
-     */
31
-    protected $model;
28
+	/**
29
+	 * @var EEM_Base
30
+	 */
31
+	protected $model;
32 32
 
33
-    /**
34
-     * @var CalculatedModelFields
35
-     */
36
-    protected $fields_calculator;
33
+	/**
34
+	 * @var CalculatedModelFields
35
+	 */
36
+	protected $fields_calculator;
37 37
 
38 38
 
39
-    /**
40
-     * JsonModelSchema constructor.
41
-     *
42
-     * @param EEM_Base              $model
43
-     * @param CalculatedModelFields $fields_calculator
44
-     */
45
-    public function __construct(EEM_Base $model, CalculatedModelFields $fields_calculator)
46
-    {
47
-        $this->model = $model;
48
-        $this->fields_calculator = $fields_calculator;
49
-    }
39
+	/**
40
+	 * JsonModelSchema constructor.
41
+	 *
42
+	 * @param EEM_Base              $model
43
+	 * @param CalculatedModelFields $fields_calculator
44
+	 */
45
+	public function __construct(EEM_Base $model, CalculatedModelFields $fields_calculator)
46
+	{
47
+		$this->model = $model;
48
+		$this->fields_calculator = $fields_calculator;
49
+	}
50 50
 
51 51
 
52
-    /**
53
-     * Return the schema for a given model from a given model.
54
-     *
55
-     * @return array
56
-     */
57
-    public function getModelSchema()
58
-    {
59
-        return $this->getModelSchemaForRelations(
60
-            $this->model->relation_settings(),
61
-            $this->getModelSchemaForFields(
62
-                $this->model->field_settings(),
63
-                $this->getInitialSchemaStructure()
64
-            )
65
-        );
66
-    }
52
+	/**
53
+	 * Return the schema for a given model from a given model.
54
+	 *
55
+	 * @return array
56
+	 */
57
+	public function getModelSchema()
58
+	{
59
+		return $this->getModelSchemaForRelations(
60
+			$this->model->relation_settings(),
61
+			$this->getModelSchemaForFields(
62
+				$this->model->field_settings(),
63
+				$this->getInitialSchemaStructure()
64
+			)
65
+		);
66
+	}
67 67
 
68 68
 
69
-    /**
70
-     * Get the schema for a given set of model fields.
71
-     *
72
-     * @param EE_Model_Field_Base[] $model_fields
73
-     * @param array                  $schema
74
-     * @return array
75
-     */
76
-    public function getModelSchemaForFields(array $model_fields, array $schema)
77
-    {
78
-        foreach ($model_fields as $field => $model_field) {
79
-            if (! $model_field instanceof EE_Model_Field_Base) {
80
-                continue;
81
-            }
82
-            $schema['properties'][ $field ] = $model_field->getSchema();
69
+	/**
70
+	 * Get the schema for a given set of model fields.
71
+	 *
72
+	 * @param EE_Model_Field_Base[] $model_fields
73
+	 * @param array                  $schema
74
+	 * @return array
75
+	 */
76
+	public function getModelSchemaForFields(array $model_fields, array $schema)
77
+	{
78
+		foreach ($model_fields as $field => $model_field) {
79
+			if (! $model_field instanceof EE_Model_Field_Base) {
80
+				continue;
81
+			}
82
+			$schema['properties'][ $field ] = $model_field->getSchema();
83 83
 
84
-            // if this is a primary key field add the primary key item
85
-            if ($model_field instanceof EE_Primary_Key_Field_Base) {
86
-                $schema['properties'][ $field ]['primary_key'] = true;
87
-                if ($model_field instanceof EE_Primary_Key_Int_Field) {
88
-                    $schema['properties'][ $field ]['readonly'] = true;
89
-                }
90
-            }
84
+			// if this is a primary key field add the primary key item
85
+			if ($model_field instanceof EE_Primary_Key_Field_Base) {
86
+				$schema['properties'][ $field ]['primary_key'] = true;
87
+				if ($model_field instanceof EE_Primary_Key_Int_Field) {
88
+					$schema['properties'][ $field ]['readonly'] = true;
89
+				}
90
+			}
91 91
 
92
-            // if this is a foreign key field add the foreign key item
93
-            if ($model_field instanceof EE_Foreign_Key_Field_Base) {
94
-                $schema['properties'][ $field ]['foreign_key'] = array(
95
-                    'description' => esc_html__(
96
-                        'This is a foreign key the points to the given models.',
97
-                        'event_espresso'
98
-                    ),
99
-                    'type'        => 'array',
100
-                    'enum'        => $model_field->get_model_class_names_pointed_to(),
101
-                );
102
-            }
103
-        }
104
-        return $schema;
105
-    }
92
+			// if this is a foreign key field add the foreign key item
93
+			if ($model_field instanceof EE_Foreign_Key_Field_Base) {
94
+				$schema['properties'][ $field ]['foreign_key'] = array(
95
+					'description' => esc_html__(
96
+						'This is a foreign key the points to the given models.',
97
+						'event_espresso'
98
+					),
99
+					'type'        => 'array',
100
+					'enum'        => $model_field->get_model_class_names_pointed_to(),
101
+				);
102
+			}
103
+		}
104
+		return $schema;
105
+	}
106 106
 
107 107
 
108
-    /**
109
-     * Get the schema for a given set of model relations
110
-     *
111
-     * @param EE_Model_Relation_Base[] $relations_on_model
112
-     * @param array                    $schema
113
-     * @return array
114
-     */
115
-    public function getModelSchemaForRelations(array $relations_on_model, array $schema)
116
-    {
117
-        foreach ($relations_on_model as $model_name => $relation) {
118
-            if (! $relation instanceof EE_Model_Relation_Base) {
119
-                continue;
120
-            }
121
-            $model_name_for_schema = $relation instanceof EE_Belongs_To_Relation
122
-                ? strtolower($model_name)
123
-                : EEH_Inflector::pluralize_and_lower($model_name);
124
-            $schema['properties'][ $model_name_for_schema ] = $relation->getSchema();
125
-            $schema['properties'][ $model_name_for_schema ]['relation_model'] = $model_name;
108
+	/**
109
+	 * Get the schema for a given set of model relations
110
+	 *
111
+	 * @param EE_Model_Relation_Base[] $relations_on_model
112
+	 * @param array                    $schema
113
+	 * @return array
114
+	 */
115
+	public function getModelSchemaForRelations(array $relations_on_model, array $schema)
116
+	{
117
+		foreach ($relations_on_model as $model_name => $relation) {
118
+			if (! $relation instanceof EE_Model_Relation_Base) {
119
+				continue;
120
+			}
121
+			$model_name_for_schema = $relation instanceof EE_Belongs_To_Relation
122
+				? strtolower($model_name)
123
+				: EEH_Inflector::pluralize_and_lower($model_name);
124
+			$schema['properties'][ $model_name_for_schema ] = $relation->getSchema();
125
+			$schema['properties'][ $model_name_for_schema ]['relation_model'] = $model_name;
126 126
 
127
-            // links schema
128
-            $links_key = 'https://api.eventespresso.com/' . strtolower($model_name);
129
-            $schema['properties']['_links']['properties'][ $links_key ] = array(
130
-                'description' => esc_html__(
131
-                    'Array of objects describing the link(s) for this relation resource.',
132
-                    'event_espresso'
133
-                ),
134
-                'type' => 'array',
135
-                'readonly' => true,
136
-                'items' => array(
137
-                    'type' => 'object',
138
-                    'properties' => array(
139
-                        'href' => array(
140
-                            'type' => 'string',
141
-                            'description' => sprintf(
142
-                                // translators: placeholder is the model name for the relation.
143
-                                esc_html__(
144
-                                    'The link to the resource for the %s relation(s) to this entity',
145
-                                    'event_espresso'
146
-                                ),
147
-                                $model_name
148
-                            ),
149
-                        ),
150
-                        'single' => array(
151
-                            'type' => 'boolean',
152
-                            'description' => sprintf(
153
-                                // translators: placeholder is the model name for the relation.
154
-                                esc_html__(
155
-                                    'Whether or not there is only a single %s relation to this entity',
156
-                                    'event_espresso'
157
-                                ),
158
-                                $model_name
159
-                            ),
160
-                        ),
161
-                    ),
162
-                    'additionalProperties' => false
163
-                ),
164
-            );
165
-        }
166
-        return $schema;
167
-    }
127
+			// links schema
128
+			$links_key = 'https://api.eventespresso.com/' . strtolower($model_name);
129
+			$schema['properties']['_links']['properties'][ $links_key ] = array(
130
+				'description' => esc_html__(
131
+					'Array of objects describing the link(s) for this relation resource.',
132
+					'event_espresso'
133
+				),
134
+				'type' => 'array',
135
+				'readonly' => true,
136
+				'items' => array(
137
+					'type' => 'object',
138
+					'properties' => array(
139
+						'href' => array(
140
+							'type' => 'string',
141
+							'description' => sprintf(
142
+								// translators: placeholder is the model name for the relation.
143
+								esc_html__(
144
+									'The link to the resource for the %s relation(s) to this entity',
145
+									'event_espresso'
146
+								),
147
+								$model_name
148
+							),
149
+						),
150
+						'single' => array(
151
+							'type' => 'boolean',
152
+							'description' => sprintf(
153
+								// translators: placeholder is the model name for the relation.
154
+								esc_html__(
155
+									'Whether or not there is only a single %s relation to this entity',
156
+									'event_espresso'
157
+								),
158
+								$model_name
159
+							),
160
+						),
161
+					),
162
+					'additionalProperties' => false
163
+				),
164
+			);
165
+		}
166
+		return $schema;
167
+	}
168 168
 
169 169
 
170
-    /**
171
-     * Outputs the schema header for a model.
172
-     *
173
-     * @return array
174
-     */
175
-    public function getInitialSchemaStructure()
176
-    {
177
-        return array(
178
-            '$schema'    => 'http://json-schema.org/draft-04/schema#',
179
-            'title'      => $this->model->get_this_model_name(),
180
-            'type'       => 'object',
181
-            'properties' => array(
182
-                'link' => array(
183
-                    'description' => esc_html__(
184
-                        'Link to event on WordPress site hosting events.',
185
-                        'event_espresso'
186
-                    ),
187
-                    'type' => 'string',
188
-                    'readonly' => true,
189
-                ),
190
-                '_links' => array(
191
-                    'description' => esc_html__(
192
-                        'Various links for resources related to the entity.',
193
-                        'event_espresso'
194
-                    ),
195
-                    'type' => 'object',
196
-                    'readonly' => true,
197
-                    'properties' => array(
198
-                        'self' => array(
199
-                            'description' => esc_html__(
200
-                                'Link to this entities resource.',
201
-                                'event_espresso'
202
-                            ),
203
-                            'type' => 'array',
204
-                            'items' => array(
205
-                                'type' => 'object',
206
-                                'properties' => array(
207
-                                    'href' => array(
208
-                                        'type' => 'string',
209
-                                    ),
210
-                                ),
211
-                                'additionalProperties' => false
212
-                            ),
213
-                            'readonly' => true
214
-                        ),
215
-                        'collection' => array(
216
-                            'description' => esc_html__(
217
-                                'Link to this entities collection resource.',
218
-                                'event_espresso'
219
-                            ),
220
-                            'type' => 'array',
221
-                            'items' => array(
222
-                                'type' => 'object',
223
-                                'properties' => array(
224
-                                    'href' => array(
225
-                                        'type' => 'string'
226
-                                    ),
227
-                                ),
228
-                                'additionalProperties' => false
229
-                            ),
230
-                            'readonly' => true
231
-                        ),
232
-                    ),
233
-                    'additionalProperties' => false,
234
-                ),
235
-                '_calculated_fields' => array_merge(
236
-                    $this->fields_calculator->getJsonSchemaForModel($this->model),
237
-                    array(
238
-                        '_protected' => $this->getProtectedFieldsSchema()
239
-                    )
240
-                ),
241
-                '_protected' => $this->getProtectedFieldsSchema()
242
-            ),
243
-            'additionalProperties' => false,
244
-        );
245
-    }
170
+	/**
171
+	 * Outputs the schema header for a model.
172
+	 *
173
+	 * @return array
174
+	 */
175
+	public function getInitialSchemaStructure()
176
+	{
177
+		return array(
178
+			'$schema'    => 'http://json-schema.org/draft-04/schema#',
179
+			'title'      => $this->model->get_this_model_name(),
180
+			'type'       => 'object',
181
+			'properties' => array(
182
+				'link' => array(
183
+					'description' => esc_html__(
184
+						'Link to event on WordPress site hosting events.',
185
+						'event_espresso'
186
+					),
187
+					'type' => 'string',
188
+					'readonly' => true,
189
+				),
190
+				'_links' => array(
191
+					'description' => esc_html__(
192
+						'Various links for resources related to the entity.',
193
+						'event_espresso'
194
+					),
195
+					'type' => 'object',
196
+					'readonly' => true,
197
+					'properties' => array(
198
+						'self' => array(
199
+							'description' => esc_html__(
200
+								'Link to this entities resource.',
201
+								'event_espresso'
202
+							),
203
+							'type' => 'array',
204
+							'items' => array(
205
+								'type' => 'object',
206
+								'properties' => array(
207
+									'href' => array(
208
+										'type' => 'string',
209
+									),
210
+								),
211
+								'additionalProperties' => false
212
+							),
213
+							'readonly' => true
214
+						),
215
+						'collection' => array(
216
+							'description' => esc_html__(
217
+								'Link to this entities collection resource.',
218
+								'event_espresso'
219
+							),
220
+							'type' => 'array',
221
+							'items' => array(
222
+								'type' => 'object',
223
+								'properties' => array(
224
+									'href' => array(
225
+										'type' => 'string'
226
+									),
227
+								),
228
+								'additionalProperties' => false
229
+							),
230
+							'readonly' => true
231
+						),
232
+					),
233
+					'additionalProperties' => false,
234
+				),
235
+				'_calculated_fields' => array_merge(
236
+					$this->fields_calculator->getJsonSchemaForModel($this->model),
237
+					array(
238
+						'_protected' => $this->getProtectedFieldsSchema()
239
+					)
240
+				),
241
+				'_protected' => $this->getProtectedFieldsSchema()
242
+			),
243
+			'additionalProperties' => false,
244
+		);
245
+	}
246 246
 
247
-    /**
248
-     * Returns an array of JSON schema to describe the _protected property on responses
249
-     * @since 4.9.74.p
250
-     * @return array
251
-     */
252
-    protected function getProtectedFieldsSchema()
253
-    {
254
-        return array(
255
-            'description' => esc_html__('Array of property names whose values were replaced with their default (because they are related to a password-protected entity.)', 'event_espresso'),
256
-            'type' => 'array',
257
-            'items' => array(
258
-                'description' => esc_html__('Each name corresponds to a property that is protected by password for this entity and has its default value returned in the response.', 'event_espresso'),
259
-                'type' => 'string',
260
-                'readonly' => true,
261
-            ),
262
-            'readonly' => true
263
-        );
264
-    }
247
+	/**
248
+	 * Returns an array of JSON schema to describe the _protected property on responses
249
+	 * @since 4.9.74.p
250
+	 * @return array
251
+	 */
252
+	protected function getProtectedFieldsSchema()
253
+	{
254
+		return array(
255
+			'description' => esc_html__('Array of property names whose values were replaced with their default (because they are related to a password-protected entity.)', 'event_espresso'),
256
+			'type' => 'array',
257
+			'items' => array(
258
+				'description' => esc_html__('Each name corresponds to a property that is protected by password for this entity and has its default value returned in the response.', 'event_espresso'),
259
+				'type' => 'string',
260
+				'readonly' => true,
261
+			),
262
+			'readonly' => true
263
+		);
264
+	}
265 265
 
266 266
 
267
-    /**
268
-     * Allows one to just use the object as a string to get the json.
269
-     * eg.
270
-     * $json_schema = new JsonModelSchema(EEM_Event::instance(), new CalculatedModelFields);
271
-     * echo $json_schema; //outputs the schema as a json formatted string.
272
-     *
273
-     * @return bool|false|mixed|string
274
-     */
275
-    public function __toString()
276
-    {
277
-        return wp_json_encode($this->getModelSchema());
278
-    }
267
+	/**
268
+	 * Allows one to just use the object as a string to get the json.
269
+	 * eg.
270
+	 * $json_schema = new JsonModelSchema(EEM_Event::instance(), new CalculatedModelFields);
271
+	 * echo $json_schema; //outputs the schema as a json formatted string.
272
+	 *
273
+	 * @return bool|false|mixed|string
274
+	 */
275
+	public function __toString()
276
+	{
277
+		return wp_json_encode($this->getModelSchema());
278
+	}
279 279
 }
Please login to merge, or discard this patch.
core/libraries/rest_api/calculations/CalculatedModelFieldsFactory.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
      */
41 41
     public function createFromModel($model_name)
42 42
     {
43
-        return $this->createFromClassname('EventEspresso\core\libraries\rest_api\calculations\\' . $model_name);
43
+        return $this->createFromClassname('EventEspresso\core\libraries\rest_api\calculations\\'.$model_name);
44 44
     }
45 45
 
46 46
     /**
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     public function createFromClassname($calculator_classname)
52 52
     {
53 53
         $calculator = $this->loader->getShared($calculator_classname);
54
-        if (!$calculator instanceof Base) {
54
+        if ( ! $calculator instanceof Base) {
55 55
             throw new UnexpectedEntityException(
56 56
                 $calculator_classname,
57 57
                 'EventEspresso\core\libraries\rest_api\calculations\Base'
Please login to merge, or discard this patch.
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -18,46 +18,46 @@
 block discarded – undo
18 18
  */
19 19
 class CalculatedModelFieldsFactory
20 20
 {
21
-    private $loader;
21
+	private $loader;
22 22
 
23
-    /**
24
-     * CalculatedModelFieldsFactory constructor.
25
-     * @param LoaderInterface $loader
26
-     */
27
-    public function __construct(LoaderInterface $loader)
28
-    {
29
-        $this->loader = $loader;
30
-    }
23
+	/**
24
+	 * CalculatedModelFieldsFactory constructor.
25
+	 * @param LoaderInterface $loader
26
+	 */
27
+	public function __construct(LoaderInterface $loader)
28
+	{
29
+		$this->loader = $loader;
30
+	}
31 31
 
32
-    /**
33
-     * Creates the calculator class that corresponds to that particular model
34
-     * @since 4.9.68.p
35
-     * @param string $model_name
36
-     * @return Base
37
-     * @throws UnexpectedEntityException
38
-     */
39
-    public function createFromModel($model_name)
40
-    {
41
-        return $this->createFromClassname('EventEspresso\core\libraries\rest_api\calculations\\' . $model_name);
42
-    }
32
+	/**
33
+	 * Creates the calculator class that corresponds to that particular model
34
+	 * @since 4.9.68.p
35
+	 * @param string $model_name
36
+	 * @return Base
37
+	 * @throws UnexpectedEntityException
38
+	 */
39
+	public function createFromModel($model_name)
40
+	{
41
+		return $this->createFromClassname('EventEspresso\core\libraries\rest_api\calculations\\' . $model_name);
42
+	}
43 43
 
44
-    /**
45
-     * Creates the calculator class that corresponds to that classname and verifies it's of the correct type
46
-     * @param string $calculator_classname
47
-     * @return Base
48
-     * @throws UnexpectedEntityException
49
-     */
50
-    public function createFromClassname($calculator_classname)
51
-    {
52
-        $calculator = $this->loader->getShared($calculator_classname);
53
-        if (!$calculator instanceof Base) {
54
-            throw new UnexpectedEntityException(
55
-                $calculator_classname,
56
-                'EventEspresso\core\libraries\rest_api\calculations\Base'
57
-            );
58
-        }
59
-        return $calculator;
60
-    }
44
+	/**
45
+	 * Creates the calculator class that corresponds to that classname and verifies it's of the correct type
46
+	 * @param string $calculator_classname
47
+	 * @return Base
48
+	 * @throws UnexpectedEntityException
49
+	 */
50
+	public function createFromClassname($calculator_classname)
51
+	{
52
+		$calculator = $this->loader->getShared($calculator_classname);
53
+		if (!$calculator instanceof Base) {
54
+			throw new UnexpectedEntityException(
55
+				$calculator_classname,
56
+				'EventEspresso\core\libraries\rest_api\calculations\Base'
57
+			);
58
+		}
59
+		return $calculator;
60
+	}
61 61
 }
62 62
 // End of file CalculationsFactory.php
63 63
 // Location: EventEspresso\core\libraries\rest_api\calculations/CalculationsFactory.php
Please login to merge, or discard this patch.
core/libraries/rest_api/calculations/Base.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      */
24 24
     protected function verifyCurrentUserCan($required_permission, $attempted_calculation)
25 25
     {
26
-        if (! current_user_can($required_permission)) {
26
+        if ( ! current_user_can($required_permission)) {
27 27
             throw new RestException(
28 28
                 'permission_denied',
29 29
                 sprintf(
@@ -75,6 +75,6 @@  discard block
 block discarded – undo
75 75
     public function schemaForCalculation($calculation_index)
76 76
     {
77 77
         $schema_map = $this->schemaForCalculations();
78
-        return isset($schema_map[ $calculation_index ]) ? $schema_map[ $calculation_index ] : array();
78
+        return isset($schema_map[$calculation_index]) ? $schema_map[$calculation_index] : array();
79 79
     }
80 80
 }
Please login to merge, or discard this patch.
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -16,65 +16,65 @@
 block discarded – undo
16 16
 class Base
17 17
 {
18 18
 
19
-    /**
20
-     * @param $required_permission
21
-     * @param $attempted_calculation
22
-     * @throws RestException
23
-     */
24
-    protected function verifyCurrentUserCan($required_permission, $attempted_calculation)
25
-    {
26
-        if (! current_user_can($required_permission)) {
27
-            throw new RestException(
28
-                'permission_denied',
29
-                sprintf(
30
-                    esc_html__(
31
-                    // @codingStandardsIgnoreStart
32
-                        'Permission denied, you cannot calculate %1$s on %2$s because you do not have the capability "%3$s"',
33
-                        // @codingStandardsIgnoreEnd
34
-                        'event_espresso'
35
-                    ),
36
-                    $attempted_calculation,
37
-                    EEH_Inflector::pluralize_and_lower($this->getResourceName()),
38
-                    $required_permission
39
-                )
40
-            );
41
-        }
42
-    }
19
+	/**
20
+	 * @param $required_permission
21
+	 * @param $attempted_calculation
22
+	 * @throws RestException
23
+	 */
24
+	protected function verifyCurrentUserCan($required_permission, $attempted_calculation)
25
+	{
26
+		if (! current_user_can($required_permission)) {
27
+			throw new RestException(
28
+				'permission_denied',
29
+				sprintf(
30
+					esc_html__(
31
+					// @codingStandardsIgnoreStart
32
+						'Permission denied, you cannot calculate %1$s on %2$s because you do not have the capability "%3$s"',
33
+						// @codingStandardsIgnoreEnd
34
+						'event_espresso'
35
+					),
36
+					$attempted_calculation,
37
+					EEH_Inflector::pluralize_and_lower($this->getResourceName()),
38
+					$required_permission
39
+				)
40
+			);
41
+		}
42
+	}
43 43
 
44 44
 
45
-    /**
46
-     * Gets the name of the resource of the called class
47
-     *
48
-     * @return string
49
-     */
50
-    public function getResourceName()
51
-    {
52
-        return substr(__CLASS__, strrpos(__CLASS__, '\\') + 1);
53
-    }
45
+	/**
46
+	 * Gets the name of the resource of the called class
47
+	 *
48
+	 * @return string
49
+	 */
50
+	public function getResourceName()
51
+	{
52
+		return substr(__CLASS__, strrpos(__CLASS__, '\\') + 1);
53
+	}
54 54
 
55
-    /**
56
-     * Returns an array to be used for the schema for the calculated fields.
57
-     * @since 4.9.68.p
58
-     * @return array keys are calculated field names (eg "optimum_sales_at_start") values are arrays {
59
-     * @type string $description
60
-     * @type string $type, eg "string", "int", "boolean", "object", "array", etc
61
-     * }
62
-     */
63
-    public function schemaForCalculations()
64
-    {
65
-        return array();
66
-    }
55
+	/**
56
+	 * Returns an array to be used for the schema for the calculated fields.
57
+	 * @since 4.9.68.p
58
+	 * @return array keys are calculated field names (eg "optimum_sales_at_start") values are arrays {
59
+	 * @type string $description
60
+	 * @type string $type, eg "string", "int", "boolean", "object", "array", etc
61
+	 * }
62
+	 */
63
+	public function schemaForCalculations()
64
+	{
65
+		return array();
66
+	}
67 67
 
68
-    /**
69
-     * Returns the json schema for the given calculation index.
70
-     *
71
-     * @since 4.9.68.p
72
-     * @param $calculation_index
73
-     * @return array
74
-     */
75
-    public function schemaForCalculation($calculation_index)
76
-    {
77
-        $schema_map = $this->schemaForCalculations();
78
-        return isset($schema_map[ $calculation_index ]) ? $schema_map[ $calculation_index ] : array();
79
-    }
68
+	/**
69
+	 * Returns the json schema for the given calculation index.
70
+	 *
71
+	 * @since 4.9.68.p
72
+	 * @param $calculation_index
73
+	 * @return array
74
+	 */
75
+	public function schemaForCalculation($calculation_index)
76
+	{
77
+		$schema_map = $this->schemaForCalculations();
78
+		return isset($schema_map[ $calculation_index ]) ? $schema_map[ $calculation_index ] : array();
79
+	}
80 80
 }
Please login to merge, or discard this patch.
core/domain/entities/shortcodes/EspressoTicketSelector.php 2 patches
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -24,92 +24,92 @@
 block discarded – undo
24 24
 {
25 25
 
26 26
 
27
-    /**
28
-     * the actual shortcode tag that gets registered with WordPress
29
-     *
30
-     * @return string
31
-     */
32
-    public function getTag()
33
-    {
34
-        return 'ESPRESSO_TICKET_SELECTOR';
35
-    }
27
+	/**
28
+	 * the actual shortcode tag that gets registered with WordPress
29
+	 *
30
+	 * @return string
31
+	 */
32
+	public function getTag()
33
+	{
34
+		return 'ESPRESSO_TICKET_SELECTOR';
35
+	}
36 36
 
37 37
 
38
-    /**
39
-     * the time in seconds to cache the results of the processShortcode() method
40
-     * 0 means the processShortcode() results will NOT be cached at all
41
-     *
42
-     * @return int
43
-     */
44
-    public function cacheExpiration()
45
-    {
46
-        return 0;
47
-    }
38
+	/**
39
+	 * the time in seconds to cache the results of the processShortcode() method
40
+	 * 0 means the processShortcode() results will NOT be cached at all
41
+	 *
42
+	 * @return int
43
+	 */
44
+	public function cacheExpiration()
45
+	{
46
+		return 0;
47
+	}
48 48
 
49 49
 
50
-    /**
51
-     * a place for adding any initialization code that needs to run prior to wp_header().
52
-     * this may be required for shortcodes that utilize a corresponding module,
53
-     * and need to enqueue assets for that module
54
-     *
55
-     * @return void
56
-     */
57
-    public function initializeShortcode()
58
-    {
59
-        add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
60
-        $this->shortcodeHasBeenInitialized();
61
-    }
50
+	/**
51
+	 * a place for adding any initialization code that needs to run prior to wp_header().
52
+	 * this may be required for shortcodes that utilize a corresponding module,
53
+	 * and need to enqueue assets for that module
54
+	 *
55
+	 * @return void
56
+	 */
57
+	public function initializeShortcode()
58
+	{
59
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
60
+		$this->shortcodeHasBeenInitialized();
61
+	}
62 62
 
63 63
 
64
-    /**
65
-     * callback that runs when the shortcode is encountered in post content.
66
-     * IMPORTANT !!!
67
-     * remember that shortcode content should be RETURNED and NOT echoed out
68
-     *
69
-     * @param array $attributes
70
-     * @return string
71
-     * @throws InvalidArgumentException
72
-     * @throws EE_Error
73
-     * @throws InvalidDataTypeException
74
-     * @throws InvalidInterfaceException
75
-     * @throws ReflectionException
76
-     * @throws Exception
77
-     */
78
-    public function processShortcode($attributes = array())
79
-    {
80
-        extract($attributes, EXTR_OVERWRITE);
81
-        $event_id = isset($event_id) ? $event_id : 0;
82
-        $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id);
83
-        if (! $event instanceof EE_Event) {
84
-            if (WP_DEBUG === true && current_user_can('edit_pages')) {
85
-                new ExceptionStackTraceDisplay(
86
-                    new InvalidArgumentException(
87
-                        sprintf(
88
-                            esc_html__(
89
-                                'A valid Event ID is required to use the "%1$s" shortcode.%4$sAn Event with an ID of "%2$s" could not be found.%4$sPlease verify that the shortcode added to this post\'s content includes an "%3$s" argument and that its value corresponds to a valid Event ID.',
90
-                                'event_espresso'
91
-                            ),
92
-                            $this->getTag(),
93
-                            $event_id,
94
-                            'event_id',
95
-                            '<br />'
96
-                        )
97
-                    )
98
-                );
99
-                return '';
100
-            }
101
-            return sprintf(
102
-                esc_html__(
103
-                    'An Event with an ID of "%s" could not be found. Please contact the event administrator for assistance.',
104
-                    'event_espresso'
105
-                ),
106
-                $event_id
107
-            );
108
-        }
109
-        ob_start();
110
-        do_action('AHEE_event_details_before_post', $event_id);
111
-        espresso_ticket_selector($event);
112
-        do_action('AHEE_event_details_after_post');
113
-        return ob_get_clean();
114
-    }
64
+	/**
65
+	 * callback that runs when the shortcode is encountered in post content.
66
+	 * IMPORTANT !!!
67
+	 * remember that shortcode content should be RETURNED and NOT echoed out
68
+	 *
69
+	 * @param array $attributes
70
+	 * @return string
71
+	 * @throws InvalidArgumentException
72
+	 * @throws EE_Error
73
+	 * @throws InvalidDataTypeException
74
+	 * @throws InvalidInterfaceException
75
+	 * @throws ReflectionException
76
+	 * @throws Exception
77
+	 */
78
+	public function processShortcode($attributes = array())
79
+	{
80
+		extract($attributes, EXTR_OVERWRITE);
81
+		$event_id = isset($event_id) ? $event_id : 0;
82
+		$event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id);
83
+		if (! $event instanceof EE_Event) {
84
+			if (WP_DEBUG === true && current_user_can('edit_pages')) {
85
+				new ExceptionStackTraceDisplay(
86
+					new InvalidArgumentException(
87
+						sprintf(
88
+							esc_html__(
89
+								'A valid Event ID is required to use the "%1$s" shortcode.%4$sAn Event with an ID of "%2$s" could not be found.%4$sPlease verify that the shortcode added to this post\'s content includes an "%3$s" argument and that its value corresponds to a valid Event ID.',
90
+								'event_espresso'
91
+							),
92
+							$this->getTag(),
93
+							$event_id,
94
+							'event_id',
95
+							'<br />'
96
+						)
97
+					)
98
+				);
99
+				return '';
100
+			}
101
+			return sprintf(
102
+				esc_html__(
103
+					'An Event with an ID of "%s" could not be found. Please contact the event administrator for assistance.',
104
+					'event_espresso'
105
+				),
106
+				$event_id
107
+			);
108
+		}
109
+		ob_start();
110
+		do_action('AHEE_event_details_before_post', $event_id);
111
+		espresso_ticket_selector($event);
112
+		do_action('AHEE_event_details_after_post');
113
+		return ob_get_clean();
114
+	}
115 115
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@
 block discarded – undo
80 80
         extract($attributes, EXTR_OVERWRITE);
81 81
         $event_id = isset($event_id) ? $event_id : 0;
82 82
         $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id);
83
-        if (! $event instanceof EE_Event) {
83
+        if ( ! $event instanceof EE_Event) {
84 84
             if (WP_DEBUG === true && current_user_can('edit_pages')) {
85 85
                 new ExceptionStackTraceDisplay(
86 86
                     new InvalidArgumentException(
Please login to merge, or discard this patch.
core/libraries/messages/messenger/EE_Pdf_messenger.class.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
             'base_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'base', $this->_variation),
260 260
             'print_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'print', $this->_variation),
261 261
             'main_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'main', $this->_variation),
262
-            'extra_css' => EE_LIBRARIES_URL . 'messages/defaults/default/variations/pdf_base_default.css',
262
+            'extra_css' => EE_LIBRARIES_URL.'messages/defaults/default/variations/pdf_base_default.css',
263 263
             'main_body' => apply_filters('FHEE__EE_Pdf_messenger___send_message__main_body', wpautop($this->_content), $this->_content)
264 264
         );
265 265
         $this->_deregister_wp_hooks();
@@ -323,8 +323,8 @@  discard block
 block discarded – undo
323 323
         $invoice_name = $this->_subject;
324 324
 
325 325
         // only load dompdf if nobody else has yet...
326
-        if (! class_exists('Dompdf\Dompdf')) {
327
-            require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php');
326
+        if ( ! class_exists('Dompdf\Dompdf')) {
327
+            require_once(EE_THIRD_PARTY.'dompdf/src/Autoloader.php');
328 328
             Dompdf\Autoloader::register();
329 329
         }
330 330
         $options = new Dompdf\Options();
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
         $dompdf->loadHtml($content);
337 337
         $dompdf->render();
338 338
         // forcing the browser to open a download dialog.
339
-        $dompdf->stream($invoice_name . ".pdf", array('Attachment' => true));
339
+        $dompdf->stream($invoice_name.".pdf", array('Attachment' => true));
340 340
     }
341 341
 
342 342
 
Please login to merge, or discard this patch.
Indentation   +344 added lines, -344 removed lines patch added patch discarded remove patch
@@ -15,349 +15,349 @@
 block discarded – undo
15 15
 {
16 16
 
17 17
 
18
-    /**
19
-     * The following are the properties that this messenger requires for generating pdf
20
-     */
21
-
22
-    /**
23
-     * This is the pdf body generated by the template via the message type.
24
-     *
25
-     * @var string
26
-     */
27
-    protected $_content;
28
-
29
-
30
-    /**
31
-     * This is for the page title that gets displayed.  This will end up being the filename for the generated pdf.
32
-     *
33
-     * @var string
34
-     */
35
-    protected $_subject;
36
-
37
-
38
-    /**
39
-     * @return EE_Pdf_messenger
40
-     */
41
-    public function __construct()
42
-    {
43
-        // set properties
44
-        $this->name = 'pdf';
45
-        $this->description = esc_html__('This messenger is used for generating a pdf version of the message.', 'event_espresso');
46
-        $this->label = array(
47
-            'singular' => esc_html__('PDF', 'event_espresso'),
48
-            'plural' => esc_html__('PDFs', 'event_espresso')
49
-        );
50
-        $this->activate_on_install = true;
51
-
52
-        parent::__construct();
53
-    }
54
-
55
-
56
-    /**
57
-     * PDF Messenger desires execution immediately.
58
-     * @see  parent::send_now() for documentation.
59
-     * @since  4.9.0
60
-     * @return bool
61
-     */
62
-    public function send_now()
63
-    {
64
-        return true;
65
-    }
66
-
67
-
68
-    /**
69
-     * HTML Messenger allows an empty to field.
70
-     * @see parent::allow_empty_to_field() for documentation
71
-     * @since  4.9.0
72
-     * @return bool
73
-     */
74
-    public function allow_empty_to_field()
75
-    {
76
-        return true;
77
-    }
78
-
79
-
80
-    /**
81
-     * @see abstract declaration in EE_messenger for details.
82
-     */
83
-    protected function _set_admin_pages()
84
-    {
85
-        $this->admin_registered_pages = array('events_edit' => false);
86
-    }
87
-
88
-
89
-    /**
90
-     * @see abstract declaration in EE_messenger for details.
91
-     */
92
-    protected function _set_valid_shortcodes()
93
-    {
94
-        $this->_valid_shortcodes = array();
95
-    }
96
-
97
-
98
-    /**
99
-     * @see abstract declaration in EE_messenger for details.
100
-     */
101
-    protected function _set_validator_config()
102
-    {
103
-        $this->_validator_config = array(
104
-            'subject' => array(
105
-                'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime')
106
-            ),
107
-            'content' => array(
108
-                'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime')
109
-            ),
110
-            'attendee_list' => array(
111
-                'shortcodes' => array('attendee', 'event_list', 'ticket_list'),
112
-                'required' => array('[ATTENDEE_LIST]')
113
-            ),
114
-            'event_list' => array(
115
-                'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'venue', 'datetime_list', 'attendee', 'primary_registration_details', 'primary_registration_list', 'event_author', 'recipient_details', 'recipient_list'),
116
-                'required' => array('[EVENT_LIST]')
117
-            ),
118
-            'ticket_list' => array(
119
-                'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'primary_registration_details', 'recipient_details'),
120
-                'required' => array('[TICKET_LIST]')
121
-            ),
122
-            'datetime_list' => array(
123
-                'shortcodes' => array('datetime'),
124
-                'required' => array('[DATETIME_LIST]')
125
-            ),
126
-        );
127
-    }
128
-
129
-
130
-    /**
131
-     * Takes care of enqueuing any necessary scripts or styles for the page.  A do_action() so message types using this messenger can add their own js.
132
-     *
133
-     * @return void.
134
-     */
135
-    public function enqueue_scripts_styles()
136
-    {
137
-        parent::enqueue_scripts_styles();
138
-        do_action('AHEE__EE_Pdf_messenger__enqueue_scripts_styles');
139
-    }
140
-
141
-
142
-    /**
143
-     * _set_template_fields
144
-     * This sets up the fields that a messenger requires for the message to go out.
145
-     *
146
-     * @access  protected
147
-     * @return void
148
-     */
149
-    protected function _set_template_fields()
150
-    {
151
-        // any extra template fields that are NOT used by the messenger but will get used by a messenger field for shortcode replacement get added to the 'extra' key in an associated array indexed by the messenger field they relate to.  This is important for the Messages_admin to know what fields to display to the user.  Also, notice that the "values" are equal to the field type that messages admin will use to know what kind of field to display. The values ALSO have one index labeled "shortcode".  the values in that array indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) is required in order for this extra field to be displayed.  If the required shortcode isn't part of the shortcodes array then the field is not needed and will not be displayed/parsed.
152
-        $this->_template_fields = array(
153
-            'subject' => array(
154
-                'input' => 'text',
155
-                'label' => esc_html__('Page Title', 'event_espresso'),
156
-                'type' => 'string',
157
-                'required' => true,
158
-                'validation' => true,
159
-                'css_class' => 'large-text',
160
-                'format' => '%s'
161
-            ),
162
-            'content' => '', // left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field.
163
-            'extra' => array(
164
-                'content' => array(
165
-                    'main' => array(
166
-                        'input' => 'wp_editor',
167
-                        'label' => esc_html__('Main Content', 'event_espresso'),
168
-                        'type' => 'string',
169
-                        'required' => true,
170
-                        'validation' => true,
171
-                        'format' => '%s',
172
-                        'rows' => '15'
173
-                    ),
174
-                    'event_list' => array(
175
-                        'input' => 'wp_editor',
176
-                        'label' => '[EVENT_LIST]',
177
-                        'type' => 'string',
178
-                        'required' => true,
179
-                        'validation' => true,
180
-                        'format' => '%s',
181
-                        'rows' => '15',
182
-                        'shortcodes_required' => array('[EVENT_LIST]')
183
-                    ),
184
-                    'attendee_list' => array(
185
-                        'input' => 'textarea',
186
-                        'label' => '[ATTENDEE_LIST]',
187
-                        'type' => 'string',
188
-                        'required' => true,
189
-                        'validation' => true,
190
-                        'format' => '%s',
191
-                        'css_class' => 'large-text',
192
-                        'rows' => '5',
193
-                        'shortcodes_required' => array('[ATTENDEE_LIST]')
194
-                    ),
195
-                    'ticket_list' => array(
196
-                        'input' => 'textarea',
197
-                        'label' => '[TICKET_LIST]',
198
-                        'type' => 'string',
199
-                        'required' => true,
200
-                        'validation' => true,
201
-                        'format' => '%s',
202
-                        'css_class' => 'large-text',
203
-                        'rows' => '10',
204
-                        'shortcodes_required' => array('[TICKET_LIST]')
205
-                    ),
206
-                    'datetime_list' => array(
207
-                        'input' => 'textarea',
208
-                        'label' => '[DATETIME_LIST]',
209
-                        'type' => 'string',
210
-                        'required' => true,
211
-                        'validation' => true,
212
-                        'format' => '%s',
213
-                        'css_class' => 'large-text',
214
-                        'rows' => '10',
215
-                        'shortcodes_required' => array('[DATETIME_LIST]')
216
-                    )
217
-                )
218
-            )
219
-        );
220
-    }
221
-
222
-
223
-    /**
224
-     * @see definition of this method in parent
225
-     *
226
-     * @since 4.5.0
227
-     *
228
-     */
229
-    protected function _set_default_message_types()
230
-    {
231
-        // note currently PDF is only a secondary messenger so it never has any associated message types.
232
-        $this->_default_message_types = array();
233
-    }
234
-
235
-
236
-    /**
237
-     * @see definition of this method in parent
238
-     *
239
-     * @since 4.5.0
240
-     */
241
-    protected function _set_valid_message_types()
242
-    {
243
-        $this->_valid_message_types = array();
244
-    }
245
-
246
-
247
-    /**
248
-     * Generates html version of the message content and then sends it to the pdf generator.
249
-     *
250
-     *
251
-     * @since 4.5.0
252
-     *
253
-     * @return string.
254
-     */
255
-    protected function _send_message()
256
-    {
257
-        $this->_template_args = array(
258
-            'page_title' => $this->_subject,
259
-            'base_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'base', $this->_variation),
260
-            'print_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'print', $this->_variation),
261
-            'main_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'main', $this->_variation),
262
-            'extra_css' => EE_LIBRARIES_URL . 'messages/defaults/default/variations/pdf_base_default.css',
263
-            'main_body' => apply_filters('FHEE__EE_Pdf_messenger___send_message__main_body', wpautop($this->_content), $this->_content)
264
-        );
265
-        $this->_deregister_wp_hooks();
266
-        add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles'));
267
-        $content = $this->_get_main_template();
18
+	/**
19
+	 * The following are the properties that this messenger requires for generating pdf
20
+	 */
21
+
22
+	/**
23
+	 * This is the pdf body generated by the template via the message type.
24
+	 *
25
+	 * @var string
26
+	 */
27
+	protected $_content;
28
+
29
+
30
+	/**
31
+	 * This is for the page title that gets displayed.  This will end up being the filename for the generated pdf.
32
+	 *
33
+	 * @var string
34
+	 */
35
+	protected $_subject;
36
+
37
+
38
+	/**
39
+	 * @return EE_Pdf_messenger
40
+	 */
41
+	public function __construct()
42
+	{
43
+		// set properties
44
+		$this->name = 'pdf';
45
+		$this->description = esc_html__('This messenger is used for generating a pdf version of the message.', 'event_espresso');
46
+		$this->label = array(
47
+			'singular' => esc_html__('PDF', 'event_espresso'),
48
+			'plural' => esc_html__('PDFs', 'event_espresso')
49
+		);
50
+		$this->activate_on_install = true;
51
+
52
+		parent::__construct();
53
+	}
54
+
55
+
56
+	/**
57
+	 * PDF Messenger desires execution immediately.
58
+	 * @see  parent::send_now() for documentation.
59
+	 * @since  4.9.0
60
+	 * @return bool
61
+	 */
62
+	public function send_now()
63
+	{
64
+		return true;
65
+	}
66
+
67
+
68
+	/**
69
+	 * HTML Messenger allows an empty to field.
70
+	 * @see parent::allow_empty_to_field() for documentation
71
+	 * @since  4.9.0
72
+	 * @return bool
73
+	 */
74
+	public function allow_empty_to_field()
75
+	{
76
+		return true;
77
+	}
78
+
79
+
80
+	/**
81
+	 * @see abstract declaration in EE_messenger for details.
82
+	 */
83
+	protected function _set_admin_pages()
84
+	{
85
+		$this->admin_registered_pages = array('events_edit' => false);
86
+	}
87
+
88
+
89
+	/**
90
+	 * @see abstract declaration in EE_messenger for details.
91
+	 */
92
+	protected function _set_valid_shortcodes()
93
+	{
94
+		$this->_valid_shortcodes = array();
95
+	}
96
+
97
+
98
+	/**
99
+	 * @see abstract declaration in EE_messenger for details.
100
+	 */
101
+	protected function _set_validator_config()
102
+	{
103
+		$this->_validator_config = array(
104
+			'subject' => array(
105
+				'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime')
106
+			),
107
+			'content' => array(
108
+				'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime')
109
+			),
110
+			'attendee_list' => array(
111
+				'shortcodes' => array('attendee', 'event_list', 'ticket_list'),
112
+				'required' => array('[ATTENDEE_LIST]')
113
+			),
114
+			'event_list' => array(
115
+				'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'venue', 'datetime_list', 'attendee', 'primary_registration_details', 'primary_registration_list', 'event_author', 'recipient_details', 'recipient_list'),
116
+				'required' => array('[EVENT_LIST]')
117
+			),
118
+			'ticket_list' => array(
119
+				'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'primary_registration_details', 'recipient_details'),
120
+				'required' => array('[TICKET_LIST]')
121
+			),
122
+			'datetime_list' => array(
123
+				'shortcodes' => array('datetime'),
124
+				'required' => array('[DATETIME_LIST]')
125
+			),
126
+		);
127
+	}
128
+
129
+
130
+	/**
131
+	 * Takes care of enqueuing any necessary scripts or styles for the page.  A do_action() so message types using this messenger can add their own js.
132
+	 *
133
+	 * @return void.
134
+	 */
135
+	public function enqueue_scripts_styles()
136
+	{
137
+		parent::enqueue_scripts_styles();
138
+		do_action('AHEE__EE_Pdf_messenger__enqueue_scripts_styles');
139
+	}
140
+
141
+
142
+	/**
143
+	 * _set_template_fields
144
+	 * This sets up the fields that a messenger requires for the message to go out.
145
+	 *
146
+	 * @access  protected
147
+	 * @return void
148
+	 */
149
+	protected function _set_template_fields()
150
+	{
151
+		// any extra template fields that are NOT used by the messenger but will get used by a messenger field for shortcode replacement get added to the 'extra' key in an associated array indexed by the messenger field they relate to.  This is important for the Messages_admin to know what fields to display to the user.  Also, notice that the "values" are equal to the field type that messages admin will use to know what kind of field to display. The values ALSO have one index labeled "shortcode".  the values in that array indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) is required in order for this extra field to be displayed.  If the required shortcode isn't part of the shortcodes array then the field is not needed and will not be displayed/parsed.
152
+		$this->_template_fields = array(
153
+			'subject' => array(
154
+				'input' => 'text',
155
+				'label' => esc_html__('Page Title', 'event_espresso'),
156
+				'type' => 'string',
157
+				'required' => true,
158
+				'validation' => true,
159
+				'css_class' => 'large-text',
160
+				'format' => '%s'
161
+			),
162
+			'content' => '', // left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field.
163
+			'extra' => array(
164
+				'content' => array(
165
+					'main' => array(
166
+						'input' => 'wp_editor',
167
+						'label' => esc_html__('Main Content', 'event_espresso'),
168
+						'type' => 'string',
169
+						'required' => true,
170
+						'validation' => true,
171
+						'format' => '%s',
172
+						'rows' => '15'
173
+					),
174
+					'event_list' => array(
175
+						'input' => 'wp_editor',
176
+						'label' => '[EVENT_LIST]',
177
+						'type' => 'string',
178
+						'required' => true,
179
+						'validation' => true,
180
+						'format' => '%s',
181
+						'rows' => '15',
182
+						'shortcodes_required' => array('[EVENT_LIST]')
183
+					),
184
+					'attendee_list' => array(
185
+						'input' => 'textarea',
186
+						'label' => '[ATTENDEE_LIST]',
187
+						'type' => 'string',
188
+						'required' => true,
189
+						'validation' => true,
190
+						'format' => '%s',
191
+						'css_class' => 'large-text',
192
+						'rows' => '5',
193
+						'shortcodes_required' => array('[ATTENDEE_LIST]')
194
+					),
195
+					'ticket_list' => array(
196
+						'input' => 'textarea',
197
+						'label' => '[TICKET_LIST]',
198
+						'type' => 'string',
199
+						'required' => true,
200
+						'validation' => true,
201
+						'format' => '%s',
202
+						'css_class' => 'large-text',
203
+						'rows' => '10',
204
+						'shortcodes_required' => array('[TICKET_LIST]')
205
+					),
206
+					'datetime_list' => array(
207
+						'input' => 'textarea',
208
+						'label' => '[DATETIME_LIST]',
209
+						'type' => 'string',
210
+						'required' => true,
211
+						'validation' => true,
212
+						'format' => '%s',
213
+						'css_class' => 'large-text',
214
+						'rows' => '10',
215
+						'shortcodes_required' => array('[DATETIME_LIST]')
216
+					)
217
+				)
218
+			)
219
+		);
220
+	}
221
+
222
+
223
+	/**
224
+	 * @see definition of this method in parent
225
+	 *
226
+	 * @since 4.5.0
227
+	 *
228
+	 */
229
+	protected function _set_default_message_types()
230
+	{
231
+		// note currently PDF is only a secondary messenger so it never has any associated message types.
232
+		$this->_default_message_types = array();
233
+	}
234
+
235
+
236
+	/**
237
+	 * @see definition of this method in parent
238
+	 *
239
+	 * @since 4.5.0
240
+	 */
241
+	protected function _set_valid_message_types()
242
+	{
243
+		$this->_valid_message_types = array();
244
+	}
245
+
246
+
247
+	/**
248
+	 * Generates html version of the message content and then sends it to the pdf generator.
249
+	 *
250
+	 *
251
+	 * @since 4.5.0
252
+	 *
253
+	 * @return string.
254
+	 */
255
+	protected function _send_message()
256
+	{
257
+		$this->_template_args = array(
258
+			'page_title' => $this->_subject,
259
+			'base_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'base', $this->_variation),
260
+			'print_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'print', $this->_variation),
261
+			'main_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'main', $this->_variation),
262
+			'extra_css' => EE_LIBRARIES_URL . 'messages/defaults/default/variations/pdf_base_default.css',
263
+			'main_body' => apply_filters('FHEE__EE_Pdf_messenger___send_message__main_body', wpautop($this->_content), $this->_content)
264
+		);
265
+		$this->_deregister_wp_hooks();
266
+		add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles'));
267
+		$content = $this->_get_main_template();
268 268
 //      die( $content );
269
-        $this->_do_pdf($content);
270
-        exit(0);
271
-    }
272
-
273
-
274
-    /**
275
-     * The purpose of this function is to de register all actions hooked into wp_head and wp_footer so that it doesn't interfere with our templates.  If users want to add any custom styles or scripts they must use the AHEE__EE_Pdf_messenger__enqueue_scripts_styles hook.
276
-     *
277
-     * @since 4.5.0
278
-     *
279
-     * @return void
280
-     */
281
-    protected function _deregister_wp_hooks()
282
-    {
283
-        remove_all_actions('wp_head');
284
-        remove_all_actions('wp_footer');
285
-        remove_all_actions('wp_print_footer_scripts');
286
-        remove_all_actions('wp_enqueue_scripts');
287
-        global $wp_scripts, $wp_styles;
288
-        $wp_scripts = $wp_styles = array();
289
-
290
-        // just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load.
291
-        add_action('wp_head', 'wp_enqueue_scripts');
292
-        add_action('wp_footer', 'wp_print_footer_scripts');
293
-        add_action('wp_print_footer_scripts', '_wp_footer_scripts');
294
-    }
295
-
296
-
297
-    /**
298
-     * Overwrite parent _get_main_template for pdf purposes.
299
-     *
300
-     * @since  4.5.0
301
-     *
302
-     * @param bool $preview
303
-     * @return string
304
-     */
305
-    protected function _get_main_template($preview = false)
306
-    {
307
-        $wrapper_template = $this->_tmp_pack->get_wrapper('html', 'main');
308
-        // add message type to template_args
309
-        $this->_template_args['message_type'] = $this->_incoming_message_type;
310
-        return EEH_Template::display_template($wrapper_template, $this->_template_args, true);
311
-    }
312
-
313
-
314
-    /**
315
-     * This takes care of loading the dompdf library and generating the actual pdf
316
-     *
317
-     * @param string $content This is the generated html content being converted into a pdf.
318
-     *
319
-     * @return void
320
-     */
321
-    protected function _do_pdf($content = '')
322
-    {
323
-        $invoice_name = $this->_subject;
324
-
325
-        // only load dompdf if nobody else has yet...
326
-        if (! class_exists('Dompdf\Dompdf')) {
327
-            require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php');
328
-            Dompdf\Autoloader::register();
329
-        }
330
-        $options = new Dompdf\Options();
331
-        $options->set('isRemoteEnabled', true);
332
-        $options->set('isJavascriptEnabled', false);
333
-        if (defined('DOMPDF_FONT_DIR')) {
334
-            $options->setFontDir(DOMPDF_FONT_DIR);
335
-            $options->setFontCache(DOMPDF_FONT_DIR);
336
-        }
337
-        // Allow changing the paper size.
338
-        if (defined('DOMPDF_DEFAULT_PAPER_SIZE')) {
339
-            $options->set('defaultPaperSize', DOMPDF_DEFAULT_PAPER_SIZE);
340
-        }
341
-        $dompdf = new Dompdf\Dompdf($options);
342
-        // Remove all spaces between HTML tags
343
-        $content = preg_replace('/>\s+</', '><', $content);
344
-        $dompdf->loadHtml($content);
345
-        $dompdf->render();
346
-        // forcing the browser to open a download dialog.
347
-        $dompdf->stream($invoice_name . ".pdf", array('Attachment' => true));
348
-    }
349
-
350
-
351
-    /**
352
-     * @return string
353
-     */
354
-    protected function _preview()
355
-    {
356
-        return $this->_send_message();
357
-    }
358
-
359
-
360
-    protected function _set_admin_settings_fields()
361
-    {
362
-    }
269
+		$this->_do_pdf($content);
270
+		exit(0);
271
+	}
272
+
273
+
274
+	/**
275
+	 * The purpose of this function is to de register all actions hooked into wp_head and wp_footer so that it doesn't interfere with our templates.  If users want to add any custom styles or scripts they must use the AHEE__EE_Pdf_messenger__enqueue_scripts_styles hook.
276
+	 *
277
+	 * @since 4.5.0
278
+	 *
279
+	 * @return void
280
+	 */
281
+	protected function _deregister_wp_hooks()
282
+	{
283
+		remove_all_actions('wp_head');
284
+		remove_all_actions('wp_footer');
285
+		remove_all_actions('wp_print_footer_scripts');
286
+		remove_all_actions('wp_enqueue_scripts');
287
+		global $wp_scripts, $wp_styles;
288
+		$wp_scripts = $wp_styles = array();
289
+
290
+		// just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load.
291
+		add_action('wp_head', 'wp_enqueue_scripts');
292
+		add_action('wp_footer', 'wp_print_footer_scripts');
293
+		add_action('wp_print_footer_scripts', '_wp_footer_scripts');
294
+	}
295
+
296
+
297
+	/**
298
+	 * Overwrite parent _get_main_template for pdf purposes.
299
+	 *
300
+	 * @since  4.5.0
301
+	 *
302
+	 * @param bool $preview
303
+	 * @return string
304
+	 */
305
+	protected function _get_main_template($preview = false)
306
+	{
307
+		$wrapper_template = $this->_tmp_pack->get_wrapper('html', 'main');
308
+		// add message type to template_args
309
+		$this->_template_args['message_type'] = $this->_incoming_message_type;
310
+		return EEH_Template::display_template($wrapper_template, $this->_template_args, true);
311
+	}
312
+
313
+
314
+	/**
315
+	 * This takes care of loading the dompdf library and generating the actual pdf
316
+	 *
317
+	 * @param string $content This is the generated html content being converted into a pdf.
318
+	 *
319
+	 * @return void
320
+	 */
321
+	protected function _do_pdf($content = '')
322
+	{
323
+		$invoice_name = $this->_subject;
324
+
325
+		// only load dompdf if nobody else has yet...
326
+		if (! class_exists('Dompdf\Dompdf')) {
327
+			require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php');
328
+			Dompdf\Autoloader::register();
329
+		}
330
+		$options = new Dompdf\Options();
331
+		$options->set('isRemoteEnabled', true);
332
+		$options->set('isJavascriptEnabled', false);
333
+		if (defined('DOMPDF_FONT_DIR')) {
334
+			$options->setFontDir(DOMPDF_FONT_DIR);
335
+			$options->setFontCache(DOMPDF_FONT_DIR);
336
+		}
337
+		// Allow changing the paper size.
338
+		if (defined('DOMPDF_DEFAULT_PAPER_SIZE')) {
339
+			$options->set('defaultPaperSize', DOMPDF_DEFAULT_PAPER_SIZE);
340
+		}
341
+		$dompdf = new Dompdf\Dompdf($options);
342
+		// Remove all spaces between HTML tags
343
+		$content = preg_replace('/>\s+</', '><', $content);
344
+		$dompdf->loadHtml($content);
345
+		$dompdf->render();
346
+		// forcing the browser to open a download dialog.
347
+		$dompdf->stream($invoice_name . ".pdf", array('Attachment' => true));
348
+	}
349
+
350
+
351
+	/**
352
+	 * @return string
353
+	 */
354
+	protected function _preview()
355
+	{
356
+		return $this->_send_message();
357
+	}
358
+
359
+
360
+	protected function _set_admin_settings_fields()
361
+	{
362
+	}
363 363
 }
Please login to merge, or discard this patch.
core/services/validators/URLValidator.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -16,16 +16,16 @@
 block discarded – undo
16 16
  */
17 17
 class URLValidator
18 18
 {
19
-    /**
20
-     * Returns whether or not the URL is valid
21
-     * @since 4.9.68.p
22
-     * @param $url
23
-     * @return boolean
24
-     */
25
-    public function isValid($url)
26
-    {
27
-        return  esc_url_raw($url) === $url;
28
-    }
19
+	/**
20
+	 * Returns whether or not the URL is valid
21
+	 * @since 4.9.68.p
22
+	 * @param $url
23
+	 * @return boolean
24
+	 */
25
+	public function isValid($url)
26
+	{
27
+		return  esc_url_raw($url) === $url;
28
+	}
29 29
 }
30 30
 // End of file URLValidator.php
31 31
 // Location: ${NAMESPACE}/URLValidator.php
Please login to merge, or discard this patch.
core/db_models/EEM_Term.model.php 2 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -44,43 +44,43 @@  discard block
 block discarded – undo
44 44
         );
45 45
         $this->_wp_core_model = true;
46 46
         $path_to_tax_model = 'Term_Taxonomy';
47
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
48
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected(
47
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
48
+        $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Taxonomy_Protected(
49 49
             $path_to_tax_model
50 50
         );
51
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false;
52
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false;
53
-        $path_to_tax_model = $path_to_tax_model . '.';
51
+        $this->_cap_restriction_generators[EEM_Base::caps_edit] = false;
52
+        $this->_cap_restriction_generators[EEM_Base::caps_delete] = false;
53
+        $path_to_tax_model = $path_to_tax_model.'.';
54 54
         // add cap restrictions for editing relating to the "ee_edit_*"
55
-        $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions(
55
+        $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_category'] = new EE_Default_Where_Conditions(
56 56
             array(
57
-                $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'),
57
+                $path_to_tax_model.'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'),
58 58
             )
59 59
         );
60
-        $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions(
60
+        $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_venue_category'] = new EE_Default_Where_Conditions(
61 61
             array(
62
-                $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'),
62
+                $path_to_tax_model.'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'),
63 63
             )
64 64
         );
65
-        $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions(
65
+        $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_type'] = new EE_Default_Where_Conditions(
66 66
             array(
67
-                $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'),
67
+                $path_to_tax_model.'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'),
68 68
             )
69 69
         );
70 70
         // add cap restrictions for deleting relating to the "ee_deleting_*"
71
-        $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions(
71
+        $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_category'] = new EE_Default_Where_Conditions(
72 72
             array(
73
-                $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'),
73
+                $path_to_tax_model.'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'),
74 74
             )
75 75
         );
76
-        $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions(
76
+        $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_venue_category'] = new EE_Default_Where_Conditions(
77 77
             array(
78
-                $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'),
78
+                $path_to_tax_model.'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'),
79 79
             )
80 80
         );
81
-        $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions(
81
+        $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_type'] = new EE_Default_Where_Conditions(
82 82
             array(
83
-                $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'),
83
+                $path_to_tax_model.'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'),
84 84
             )
85 85
         );
86 86
         parent::__construct($timezone);
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
         }
186 186
         $post_tag_row = reset($post_tag_results);
187 187
         $post_tag = $this->instantiate_class_from_array_or_object($post_tag_row);
188
-        if (! $post_tag instanceof EE_Term) {
188
+        if ( ! $post_tag instanceof EE_Term) {
189 189
             return null;
190 190
         }
191 191
 
@@ -216,10 +216,10 @@  discard block
 block discarded – undo
216 216
             )
217 217
         );
218 218
         foreach ($post_tags as $key => $post_tag) {
219
-            if (! isset($post_tags[ $key ]->post_type)) {
220
-                $post_tags[ $key ]->post_type = array();
219
+            if ( ! isset($post_tags[$key]->post_type)) {
220
+                $post_tags[$key]->post_type = array();
221 221
             }
222
-            $post_tags[ $key ]->post_type[] = 'espresso_events';
222
+            $post_tags[$key]->post_type[] = 'espresso_events';
223 223
         }
224 224
         return $post_tags;
225 225
     }
@@ -244,10 +244,10 @@  discard block
 block discarded – undo
244 244
             )
245 245
         );
246 246
         foreach ($post_tags as $key => $post_tag) {
247
-            if (! isset($post_tags[ $key ]->post_type)) {
248
-                $post_tags[ $key ]->post_type = array();
247
+            if ( ! isset($post_tags[$key]->post_type)) {
248
+                $post_tags[$key]->post_type = array();
249 249
             }
250
-            $post_tags[ $key ]->post_type[] = 'espresso_venues';
250
+            $post_tags[$key]->post_type[] = 'espresso_venues';
251 251
         }
252 252
         return $post_tags;
253 253
     }
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
     {
268 268
         if ($model === EEM_Term::instance()) {
269 269
             $taxonomies = get_taxonomies(array('show_in_rest' => true));
270
-            if (! empty($taxonomies)) {
270
+            if ( ! empty($taxonomies)) {
271 271
                 $model_query_params[0]['Term_Taxonomy.taxonomy'] = array('IN', $taxonomies);
272 272
             }
273 273
         }
Please login to merge, or discard this patch.
Indentation   +237 added lines, -237 removed lines patch added patch discarded remove patch
@@ -14,263 +14,263 @@
 block discarded – undo
14 14
 class EEM_Term extends EEM_Base
15 15
 {
16 16
 
17
-    // private instance of the Attendee object
18
-    protected static $_instance = null;
17
+	// private instance of the Attendee object
18
+	protected static $_instance = null;
19 19
 
20 20
 
21 21
 
22
-    /**
23
-     *__construct
24
-     *
25
-     * @param string $timezone
26
-     */
27
-    protected function __construct($timezone = null)
28
-    {
29
-        $this->singular_item = esc_html__('Term', 'event_espresso');
30
-        $this->plural_item = esc_html__('Terms', 'event_espresso');
31
-        $this->_tables = array(
32
-            'Term' => new EE_Primary_Table('terms', 'term_id'),
33
-        );
34
-        $this->_fields = array(
35
-            'Term' => array(
36
-                'term_id'    => new EE_Primary_Key_Int_Field('term_id', esc_html__('Term ID', 'event_espresso')),
37
-                'name'       => new EE_Plain_Text_Field('name', esc_html__('Term Name', 'event_espresso'), false, ''),
38
-                'slug'       => new EE_Slug_Field('slug', esc_html__('Term Slug', 'event_espresso'), false),
39
-                'term_group' => new EE_Integer_Field('term_group', esc_html__("Term Group", "event_espresso"), false, 0),
40
-            ),
41
-        );
42
-        $this->_model_relations = array(
43
-            'Term_Taxonomy' => new EE_Has_Many_Relation(),
44
-        );
45
-        $this->_wp_core_model = true;
46
-        $path_to_tax_model = 'Term_Taxonomy';
47
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
48
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected(
49
-            $path_to_tax_model
50
-        );
51
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false;
52
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false;
53
-        $path_to_tax_model = $path_to_tax_model . '.';
54
-        // add cap restrictions for editing relating to the "ee_edit_*"
55
-        $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions(
56
-            array(
57
-                $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'),
58
-            )
59
-        );
60
-        $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions(
61
-            array(
62
-                $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'),
63
-            )
64
-        );
65
-        $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions(
66
-            array(
67
-                $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'),
68
-            )
69
-        );
70
-        // add cap restrictions for deleting relating to the "ee_deleting_*"
71
-        $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions(
72
-            array(
73
-                $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'),
74
-            )
75
-        );
76
-        $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions(
77
-            array(
78
-                $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'),
79
-            )
80
-        );
81
-        $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions(
82
-            array(
83
-                $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'),
84
-            )
85
-        );
86
-        parent::__construct($timezone);
87
-        add_filter('FHEE__Read__create_model_query_params', array('EEM_Term', 'rest_api_query_params'), 10, 3);
88
-    }
22
+	/**
23
+	 *__construct
24
+	 *
25
+	 * @param string $timezone
26
+	 */
27
+	protected function __construct($timezone = null)
28
+	{
29
+		$this->singular_item = esc_html__('Term', 'event_espresso');
30
+		$this->plural_item = esc_html__('Terms', 'event_espresso');
31
+		$this->_tables = array(
32
+			'Term' => new EE_Primary_Table('terms', 'term_id'),
33
+		);
34
+		$this->_fields = array(
35
+			'Term' => array(
36
+				'term_id'    => new EE_Primary_Key_Int_Field('term_id', esc_html__('Term ID', 'event_espresso')),
37
+				'name'       => new EE_Plain_Text_Field('name', esc_html__('Term Name', 'event_espresso'), false, ''),
38
+				'slug'       => new EE_Slug_Field('slug', esc_html__('Term Slug', 'event_espresso'), false),
39
+				'term_group' => new EE_Integer_Field('term_group', esc_html__("Term Group", "event_espresso"), false, 0),
40
+			),
41
+		);
42
+		$this->_model_relations = array(
43
+			'Term_Taxonomy' => new EE_Has_Many_Relation(),
44
+		);
45
+		$this->_wp_core_model = true;
46
+		$path_to_tax_model = 'Term_Taxonomy';
47
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
48
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected(
49
+			$path_to_tax_model
50
+		);
51
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false;
52
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false;
53
+		$path_to_tax_model = $path_to_tax_model . '.';
54
+		// add cap restrictions for editing relating to the "ee_edit_*"
55
+		$this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions(
56
+			array(
57
+				$path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'),
58
+			)
59
+		);
60
+		$this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions(
61
+			array(
62
+				$path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'),
63
+			)
64
+		);
65
+		$this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions(
66
+			array(
67
+				$path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'),
68
+			)
69
+		);
70
+		// add cap restrictions for deleting relating to the "ee_deleting_*"
71
+		$this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions(
72
+			array(
73
+				$path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'),
74
+			)
75
+		);
76
+		$this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions(
77
+			array(
78
+				$path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'),
79
+			)
80
+		);
81
+		$this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions(
82
+			array(
83
+				$path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'),
84
+			)
85
+		);
86
+		parent::__construct($timezone);
87
+		add_filter('FHEE__Read__create_model_query_params', array('EEM_Term', 'rest_api_query_params'), 10, 3);
88
+	}
89 89
 
90 90
 
91 91
 
92
-    /**
93
-     * retrieves a list of all EE event categories
94
-     *
95
-     * @access public
96
-     * @param bool $show_uncategorized
97
-     * @return \EE_Base_Class[]
98
-     */
99
-    public function get_all_ee_categories($show_uncategorized = false)
100
-    {
101
-        $where_params = array(
102
-            'Term_Taxonomy.taxonomy' => 'espresso_event_categories',
103
-            'NOT'                    => array('name' => esc_html__('Uncategorized', 'event_espresso')),
104
-        );
105
-        if ($show_uncategorized) {
106
-            unset($where_params['NOT']);
107
-        }
108
-        return EEM_Term::instance()->get_all(
109
-            array(
110
-                $where_params,
111
-                'order_by' => array('name' => 'ASC'),
112
-            )
113
-        );
114
-    }
92
+	/**
93
+	 * retrieves a list of all EE event categories
94
+	 *
95
+	 * @access public
96
+	 * @param bool $show_uncategorized
97
+	 * @return \EE_Base_Class[]
98
+	 */
99
+	public function get_all_ee_categories($show_uncategorized = false)
100
+	{
101
+		$where_params = array(
102
+			'Term_Taxonomy.taxonomy' => 'espresso_event_categories',
103
+			'NOT'                    => array('name' => esc_html__('Uncategorized', 'event_espresso')),
104
+		);
105
+		if ($show_uncategorized) {
106
+			unset($where_params['NOT']);
107
+		}
108
+		return EEM_Term::instance()->get_all(
109
+			array(
110
+				$where_params,
111
+				'order_by' => array('name' => 'ASC'),
112
+			)
113
+		);
114
+	}
115 115
 
116 116
 
117 117
 
118
-    /**
119
-     * retrieves a list of all post_tags associated with an EE CPT
120
-     *
121
-     * @access public
122
-     * @param string $post_type
123
-     * @return array
124
-     */
125
-    public function get_all_CPT_post_tags($post_type = '')
126
-    {
127
-        switch ($post_type) {
128
-            case 'espresso_events':
129
-                return $this->get_all_event_post_tags();
130
-                break;
131
-            case 'espresso_venues':
132
-                return $this->get_all_venue_post_tags();
133
-                break;
134
-            default:
135
-                $event_tags = $this->get_all_event_post_tags();
136
-                $venue_tags = $this->get_all_venue_post_tags();
137
-                return array_merge($event_tags, $venue_tags);
138
-        }
139
-    }
118
+	/**
119
+	 * retrieves a list of all post_tags associated with an EE CPT
120
+	 *
121
+	 * @access public
122
+	 * @param string $post_type
123
+	 * @return array
124
+	 */
125
+	public function get_all_CPT_post_tags($post_type = '')
126
+	{
127
+		switch ($post_type) {
128
+			case 'espresso_events':
129
+				return $this->get_all_event_post_tags();
130
+				break;
131
+			case 'espresso_venues':
132
+				return $this->get_all_venue_post_tags();
133
+				break;
134
+			default:
135
+				$event_tags = $this->get_all_event_post_tags();
136
+				$venue_tags = $this->get_all_venue_post_tags();
137
+				return array_merge($event_tags, $venue_tags);
138
+		}
139
+	}
140 140
 
141 141
 
142
-    /**
143
-     * returns an EE_Term object for the given tag
144
-     * if it has been utilized by any EE_Events or EE_Venues
145
-     *
146
-     * @param string $tag
147
-     * @return EE_Term|null
148
-     * @throws EE_Error
149
-     * @throws InvalidArgumentException
150
-     * @throws InvalidDataTypeException
151
-     * @throws InvalidInterfaceException
152
-     */
153
-    public function get_post_tag_for_event_or_venue($tag)
154
-    {
155
-        $post_tag_results = $this->get_all_wpdb_results(
156
-            array(
157
-                array(
158
-                    'slug' => $tag,
159
-                    'Term_Taxonomy.taxonomy' => 'post_tag',
160
-                    'OR' => array(
161
-                        'Term_Taxonomy.Venue.post_type' => 'espresso_venues',
162
-                        'Term_Taxonomy.Event.post_type' => 'espresso_events',
163
-                    ),
164
-                ),
165
-                'default_where_conditions' => 'none',
166
-                'extra_selects' => array(
167
-                    'event_post_type' => array('Term_Taxonomy___Event_CPT.post_type', '%s'),
168
-                    'venue_post_type' => array('Term_Taxonomy___Venue_CPT.post_type', '%s')
169
-                ),
170
-                'group_by' => array(
171
-                    'event_post_type',
172
-                    'venue_post_type',
173
-                ),
174
-                'limit' => 2
175
-            )
176
-        );
142
+	/**
143
+	 * returns an EE_Term object for the given tag
144
+	 * if it has been utilized by any EE_Events or EE_Venues
145
+	 *
146
+	 * @param string $tag
147
+	 * @return EE_Term|null
148
+	 * @throws EE_Error
149
+	 * @throws InvalidArgumentException
150
+	 * @throws InvalidDataTypeException
151
+	 * @throws InvalidInterfaceException
152
+	 */
153
+	public function get_post_tag_for_event_or_venue($tag)
154
+	{
155
+		$post_tag_results = $this->get_all_wpdb_results(
156
+			array(
157
+				array(
158
+					'slug' => $tag,
159
+					'Term_Taxonomy.taxonomy' => 'post_tag',
160
+					'OR' => array(
161
+						'Term_Taxonomy.Venue.post_type' => 'espresso_venues',
162
+						'Term_Taxonomy.Event.post_type' => 'espresso_events',
163
+					),
164
+				),
165
+				'default_where_conditions' => 'none',
166
+				'extra_selects' => array(
167
+					'event_post_type' => array('Term_Taxonomy___Event_CPT.post_type', '%s'),
168
+					'venue_post_type' => array('Term_Taxonomy___Venue_CPT.post_type', '%s')
169
+				),
170
+				'group_by' => array(
171
+					'event_post_type',
172
+					'venue_post_type',
173
+				),
174
+				'limit' => 2
175
+			)
176
+		);
177 177
 
178
-        $post_types = array();
179
-        foreach ((array) $post_tag_results as $row) {
180
-            if ($row['event_post_type'] === 'espresso_events') {
181
-                $post_types[] = EEM_Event::instance()->post_type();
182
-            } elseif ($row['venue_post_type'] === 'espresso_venues') {
183
-                $post_types[] = EEM_Venue::instance()->post_type();
184
-            }
185
-        }
186
-        $post_tag_row = reset($post_tag_results);
187
-        $post_tag = $this->instantiate_class_from_array_or_object($post_tag_row);
188
-        if (! $post_tag instanceof EE_Term) {
189
-            return null;
190
-        }
178
+		$post_types = array();
179
+		foreach ((array) $post_tag_results as $row) {
180
+			if ($row['event_post_type'] === 'espresso_events') {
181
+				$post_types[] = EEM_Event::instance()->post_type();
182
+			} elseif ($row['venue_post_type'] === 'espresso_venues') {
183
+				$post_types[] = EEM_Venue::instance()->post_type();
184
+			}
185
+		}
186
+		$post_tag_row = reset($post_tag_results);
187
+		$post_tag = $this->instantiate_class_from_array_or_object($post_tag_row);
188
+		if (! $post_tag instanceof EE_Term) {
189
+			return null;
190
+		}
191 191
 
192
-        if ($post_tag->post_type === null) {
193
-            $post_tag->post_type = array();
194
-        }
195
-        $post_tag->post_type = array_merge($post_tag->post_type, array_unique($post_types));
196
-        return $post_tag;
197
-    }
192
+		if ($post_tag->post_type === null) {
193
+			$post_tag->post_type = array();
194
+		}
195
+		$post_tag->post_type = array_merge($post_tag->post_type, array_unique($post_types));
196
+		return $post_tag;
197
+	}
198 198
 
199 199
 
200 200
 
201
-    /**
202
-     * get_all_event_post_tags
203
-     *
204
-     * @return EE_Base_Class[]
205
-     */
206
-    public function get_all_event_post_tags()
207
-    {
208
-        $post_tags = EEM_Term::instance()->get_all(
209
-            array(
210
-                array(
211
-                    'Term_Taxonomy.taxonomy'        => 'post_tag',
212
-                    'Term_Taxonomy.Event.post_type' => 'espresso_events',
213
-                ),
214
-                'order_by'   => array('name' => 'ASC'),
215
-                'force_join' => array('Term_Taxonomy.Event'),
216
-            )
217
-        );
218
-        foreach ($post_tags as $key => $post_tag) {
219
-            if (! isset($post_tags[ $key ]->post_type)) {
220
-                $post_tags[ $key ]->post_type = array();
221
-            }
222
-            $post_tags[ $key ]->post_type[] = 'espresso_events';
223
-        }
224
-        return $post_tags;
225
-    }
201
+	/**
202
+	 * get_all_event_post_tags
203
+	 *
204
+	 * @return EE_Base_Class[]
205
+	 */
206
+	public function get_all_event_post_tags()
207
+	{
208
+		$post_tags = EEM_Term::instance()->get_all(
209
+			array(
210
+				array(
211
+					'Term_Taxonomy.taxonomy'        => 'post_tag',
212
+					'Term_Taxonomy.Event.post_type' => 'espresso_events',
213
+				),
214
+				'order_by'   => array('name' => 'ASC'),
215
+				'force_join' => array('Term_Taxonomy.Event'),
216
+			)
217
+		);
218
+		foreach ($post_tags as $key => $post_tag) {
219
+			if (! isset($post_tags[ $key ]->post_type)) {
220
+				$post_tags[ $key ]->post_type = array();
221
+			}
222
+			$post_tags[ $key ]->post_type[] = 'espresso_events';
223
+		}
224
+		return $post_tags;
225
+	}
226 226
 
227 227
 
228 228
 
229
-    /**
230
-     * get_all_venue_post_tags
231
-     *
232
-     * @return EE_Base_Class[]
233
-     */
234
-    public function get_all_venue_post_tags()
235
-    {
236
-        $post_tags = EEM_Term::instance()->get_all(
237
-            array(
238
-                array(
239
-                    'Term_Taxonomy.taxonomy'        => 'post_tag',
240
-                    'Term_Taxonomy.Venue.post_type' => 'espresso_venues',
241
-                ),
242
-                'order_by'   => array('name' => 'ASC'),
243
-                'force_join' => array('Term_Taxonomy'),
244
-            )
245
-        );
246
-        foreach ($post_tags as $key => $post_tag) {
247
-            if (! isset($post_tags[ $key ]->post_type)) {
248
-                $post_tags[ $key ]->post_type = array();
249
-            }
250
-            $post_tags[ $key ]->post_type[] = 'espresso_venues';
251
-        }
252
-        return $post_tags;
253
-    }
229
+	/**
230
+	 * get_all_venue_post_tags
231
+	 *
232
+	 * @return EE_Base_Class[]
233
+	 */
234
+	public function get_all_venue_post_tags()
235
+	{
236
+		$post_tags = EEM_Term::instance()->get_all(
237
+			array(
238
+				array(
239
+					'Term_Taxonomy.taxonomy'        => 'post_tag',
240
+					'Term_Taxonomy.Venue.post_type' => 'espresso_venues',
241
+				),
242
+				'order_by'   => array('name' => 'ASC'),
243
+				'force_join' => array('Term_Taxonomy'),
244
+			)
245
+		);
246
+		foreach ($post_tags as $key => $post_tag) {
247
+			if (! isset($post_tags[ $key ]->post_type)) {
248
+				$post_tags[ $key ]->post_type = array();
249
+			}
250
+			$post_tags[ $key ]->post_type[] = 'espresso_venues';
251
+		}
252
+		return $post_tags;
253
+	}
254 254
 
255 255
 
256 256
 
257
-    /**
258
-     * Makes sure that during REST API queries, we only return terms
259
-     * for term taxonomies which should be shown in the rest api
260
-     *
261
-     * @param array    $model_query_params
262
-     * @param array    $querystring_query_params
263
-     * @param EEM_Base $model
264
-     * @return array
265
-     */
266
-    public static function rest_api_query_params($model_query_params, $querystring_query_params, $model)
267
-    {
268
-        if ($model === EEM_Term::instance()) {
269
-            $taxonomies = get_taxonomies(array('show_in_rest' => true));
270
-            if (! empty($taxonomies)) {
271
-                $model_query_params[0]['Term_Taxonomy.taxonomy'] = array('IN', $taxonomies);
272
-            }
273
-        }
274
-        return $model_query_params;
275
-    }
257
+	/**
258
+	 * Makes sure that during REST API queries, we only return terms
259
+	 * for term taxonomies which should be shown in the rest api
260
+	 *
261
+	 * @param array    $model_query_params
262
+	 * @param array    $querystring_query_params
263
+	 * @param EEM_Base $model
264
+	 * @return array
265
+	 */
266
+	public static function rest_api_query_params($model_query_params, $querystring_query_params, $model)
267
+	{
268
+		if ($model === EEM_Term::instance()) {
269
+			$taxonomies = get_taxonomies(array('show_in_rest' => true));
270
+			if (! empty($taxonomies)) {
271
+				$model_query_params[0]['Term_Taxonomy.taxonomy'] = array('IN', $taxonomies);
272
+			}
273
+		}
274
+		return $model_query_params;
275
+	}
276 276
 }
Please login to merge, or discard this patch.