@@ -18,22 +18,22 @@ |
||
18 | 18 | */ |
19 | 19 | class WordPressPostsEditor extends MatchAnyRouteSpecification |
20 | 20 | { |
21 | - /** |
|
22 | - * WordPressPostsEditor constructor. |
|
23 | - * |
|
24 | - * @param WordPressPostsEditorEdit $edit_post_route_match |
|
25 | - * @param WordPressPostsEditorAddNew $create_post_route_match |
|
26 | - * @param RequestInterface $request |
|
27 | - * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
28 | - */ |
|
29 | - public function __construct( |
|
30 | - WordPressPostsEditorEdit $edit_post_route_match, |
|
31 | - WordPressPostsEditorAddNew $create_post_route_match, |
|
32 | - RequestInterface $request |
|
33 | - ) { |
|
34 | - parent::__construct( |
|
35 | - array($edit_post_route_match, $create_post_route_match), |
|
36 | - $request |
|
37 | - ); |
|
38 | - } |
|
21 | + /** |
|
22 | + * WordPressPostsEditor constructor. |
|
23 | + * |
|
24 | + * @param WordPressPostsEditorEdit $edit_post_route_match |
|
25 | + * @param WordPressPostsEditorAddNew $create_post_route_match |
|
26 | + * @param RequestInterface $request |
|
27 | + * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
28 | + */ |
|
29 | + public function __construct( |
|
30 | + WordPressPostsEditorEdit $edit_post_route_match, |
|
31 | + WordPressPostsEditorAddNew $create_post_route_match, |
|
32 | + RequestInterface $request |
|
33 | + ) { |
|
34 | + parent::__construct( |
|
35 | + array($edit_post_route_match, $create_post_route_match), |
|
36 | + $request |
|
37 | + ); |
|
38 | + } |
|
39 | 39 | } |
@@ -19,22 +19,22 @@ |
||
19 | 19 | */ |
20 | 20 | class EspressoEventEditor extends MatchAnyRouteSpecification |
21 | 21 | { |
22 | - /** |
|
23 | - * EspressoEventEditor constructor. |
|
24 | - * |
|
25 | - * @param EspressoEventEditorEdit $edit_event_route_match |
|
26 | - * @param EspressoEventEditorAddNew $create_event_route_match |
|
27 | - * @param RequestInterface $request |
|
28 | - * @throws InvalidEntityException |
|
29 | - */ |
|
30 | - public function __construct( |
|
31 | - EspressoEventEditorEdit $edit_event_route_match, |
|
32 | - EspressoEventEditorAddNew $create_event_route_match, |
|
33 | - RequestInterface $request |
|
34 | - ) { |
|
35 | - parent::__construct( |
|
36 | - array($edit_event_route_match, $create_event_route_match), |
|
37 | - $request |
|
38 | - ); |
|
39 | - } |
|
22 | + /** |
|
23 | + * EspressoEventEditor constructor. |
|
24 | + * |
|
25 | + * @param EspressoEventEditorEdit $edit_event_route_match |
|
26 | + * @param EspressoEventEditorAddNew $create_event_route_match |
|
27 | + * @param RequestInterface $request |
|
28 | + * @throws InvalidEntityException |
|
29 | + */ |
|
30 | + public function __construct( |
|
31 | + EspressoEventEditorEdit $edit_event_route_match, |
|
32 | + EspressoEventEditorAddNew $create_event_route_match, |
|
33 | + RequestInterface $request |
|
34 | + ) { |
|
35 | + parent::__construct( |
|
36 | + array($edit_event_route_match, $create_event_route_match), |
|
37 | + $request |
|
38 | + ); |
|
39 | + } |
|
40 | 40 | } |
@@ -19,22 +19,22 @@ |
||
19 | 19 | */ |
20 | 20 | class EspressoVenueEditor extends MatchAnyRouteSpecification |
21 | 21 | { |
22 | - /** |
|
23 | - * EspressoVenueEditor constructor. |
|
24 | - * |
|
25 | - * @param EspressoVenueEditorEdit $edit_venue_route_match |
|
26 | - * @param EspressoVenueEditorAddNew $create_venue_route_match |
|
27 | - * @param RequestInterface $request |
|
28 | - * @throws InvalidEntityException |
|
29 | - */ |
|
30 | - public function __construct( |
|
31 | - EspressoVenueEditorEdit $edit_venue_route_match, |
|
32 | - EspressoVenueEditorAddNew $create_venue_route_match, |
|
33 | - RequestInterface $request |
|
34 | - ) { |
|
35 | - parent::__construct( |
|
36 | - array($edit_venue_route_match, $create_venue_route_match), |
|
37 | - $request |
|
38 | - ); |
|
39 | - } |
|
22 | + /** |
|
23 | + * EspressoVenueEditor constructor. |
|
24 | + * |
|
25 | + * @param EspressoVenueEditorEdit $edit_venue_route_match |
|
26 | + * @param EspressoVenueEditorAddNew $create_venue_route_match |
|
27 | + * @param RequestInterface $request |
|
28 | + * @throws InvalidEntityException |
|
29 | + */ |
|
30 | + public function __construct( |
|
31 | + EspressoVenueEditorEdit $edit_venue_route_match, |
|
32 | + EspressoVenueEditorAddNew $create_venue_route_match, |
|
33 | + RequestInterface $request |
|
34 | + ) { |
|
35 | + parent::__construct( |
|
36 | + array($edit_venue_route_match, $create_venue_route_match), |
|
37 | + $request |
|
38 | + ); |
|
39 | + } |
|
40 | 40 | } |
@@ -18,22 +18,22 @@ |
||
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 | } |
@@ -18,22 +18,22 @@ |
||
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 | } |
@@ -76,22 +76,22 @@ discard block |
||
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 |
||
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' |
@@ -25,255 +25,255 @@ |
||
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 | - * // if echoed, would convert schema to 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 | + * // if echoed, would convert schema to 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 | } |
@@ -40,7 +40,7 @@ discard block |
||
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 |
||
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' |
@@ -18,46 +18,46 @@ |
||
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 |
@@ -23,7 +23,7 @@ discard block |
||
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 |
||
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 | } |
@@ -16,65 +16,65 @@ |
||
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 | } |
@@ -24,92 +24,92 @@ |
||
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 | } |
@@ -80,7 +80,7 @@ |
||
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( |