Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple categories to be used in ESPRESSO_EVENTS #3125

Merged
merged 4 commits into from
Sep 17, 2020

Conversation

Pebblo
Copy link
Member

@Pebblo Pebblo commented Sep 17, 2020

See: https://eventespresso.com/topic/multiple-categories-in-shortcode-filter/

From the above request I start looking into do it via a support token, ended up finding:

https://events.codebasehq.com/projects/event-espresso/tickets/7323

How has this been tested

Add something like [ESPRESSO_EVENTS category_slug=cat-1] to a page.

Confirm that events set to that category show up and not others.

Change is to [ESPRESSO_EVENTS category_slug='cat-1'] (Note the single quotes, because people do it)..

Then change that to [ESPRESSO_EVENTS category_slug=cat-1,cat-2]
(Note no quotes required as there isn't a space in the shortcode)

Now check that event from both cat-1 and cat-2 show up.

Then change that to [ESPRESSO_EVENTS category_slug='cat-1, cat-2']
(single quotes required as there's a space this time)

Again confirm that the expected events show up.

Checklist

…m each element in the array to remove whitespaces

Use $event_category_slugs_array to build out an placeholder string to be used with prepare. (Count the number of slugs and add N number of placeholders to a string)

Switch to use IN in the SQL query and pass both $event_category_slugs_prepare and $event_category_slugs_array to prepare.
Copy link
Member

@tn3rb tn3rb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ummm... think this needs a fix still

return sanitize_title_with_dashes(EE_Registry::instance()->REQ->get('event_query_category', $category));
return sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_category', $category));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

core/helpers/EEH_Event_Query.helper.php Outdated Show resolved Hide resolved
Copy link
Member

@tn3rb tn3rb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ya this looks great, good job 💯

@garthkoyle
Copy link
Contributor

This works as expected. Nice work!

@Pebblo Pebblo merged commit 311299c into master Sep 17, 2020
@Pebblo Pebblo deleted the ENH/espresso-events-multiple-categories branch September 17, 2020 20:32
eeteamcodebase pushed a commit that referenced this pull request Sep 17, 2020
…tiple categories to be used in ESPRESSO_EVENTS (#3125)

* Switch to sanitize_text_field() so that dashes aren't stripped from the categories passed.

* Build out $event_category_slugs_array from whatever is passed and trim each element in the array to remove whitespaces

Use $event_category_slugs_array to build out an placeholder string to be used with prepare. (Count the number of slugs and add N number of placeholders to a string)

Switch to use IN in the SQL query and pass both $event_category_slugs_prepare and $event_category_slugs_array to prepare.

* Add braces around $event_category_slugs_prepare

* Style fixes."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants