-
Notifications
You must be signed in to change notification settings - Fork 65
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
CampTix: Add "Remote" ticket type #386
Conversation
Types can be edited using the `camptix_ticket_types` filter, this also sets up a "Remote" type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Tested locally.
Some comments, but no blockers.
function get_slug_from_value( $value ) { | ||
$match = wp_list_pluck( wp_list_filter( get_types(), array( 'slug' => $value ) ), 'slug' ); | ||
if ( count( $match ) > 0 ) { | ||
return current( $match ); | ||
} | ||
return 'default'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the types were registered as an associative array, with the slug as the key? Then this function might be simpler or even unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea — less magic with wp_list_*
🙂
if ( ! isset( $_POST['action'] ) || 'editpost' != $_POST['action'] ) { | ||
return; | ||
} | ||
|
||
// Security check. | ||
$nonce_action = 'update-post_' . $post_id; | ||
check_admin_referer( $nonce_action ); | ||
|
||
if ( isset( $_POST['tix_type'] ) ) { | ||
update_post_meta( $post_id, META_KEY, $_POST['tix_type'] ); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend using filter_input()
here (everywhere) to retrieve the $_POST
values, instead of referencing them directly. It gives you some built-in validation and sanitizing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sanitization callback in register_post_meta
takes care of this, but just to be extra-sure I added it.
public_html/wp-content/mu-plugins/camptix-tweaks/addons/ticket-types/remote.php
Outdated
Show resolved
Hide resolved
For me, copy looks good. |
I'd probably go with either one, or the other. I think "Livestream" is likely more common here, so I'd recommend just using that work as the ticket label. |
@ryelle I saw you said in #community-events on Slack the Livestream ticket type was available. I tested on my local environment and see the new feature related to ccf415b. I checked the 2020 Birmingham site where I'm an organizer and I do not see this feature available. |
@CdrMarks It was my mistake— I left the "don't enable this on production" flag in. It's now available for all sites. |
Set up a "Ticket Type", which pulls from a global list of types (set up in code) and can conditionally alter the registration process. Types are set up as a safelist of slug+name, and the type is saved in ticket post meta. This also updates the allergy & accommodations questions, by adding filters to skip rendering the question and/or reword the question text. Other ticket types are possible in the future, by filtering
camptix_ticket_types
& similarly working with CampTix filters.Fixes #385
👩🏼💻 Dev notes…
I went through 2 architecture iterations before landing here— intentionally not using the
CampTix_Addon
class & instead sticking to plain namespacing so that the ticket-type files can easily access theget_type*
functions. This way, we can add another file toticket-types
, exworkshop.php
, and just likeremote.php
set it up to filtercamptix_ticket_types
. I tried to make minimal changes to CampTix itself & the hardcoded questions. Overall this works pretty well but I'd still be interested in any feedback.📝 I could use copy advice!
You can see these strings "in context" in the screenshots below, but I'd appreciate better phrasing or even re-worked ideas.
Screenshots
Creating a new ticket type allows for picking a type
Once a ticket is purchased, this is disabled
The ticket type is added to the ticket list table
In the ticket form, we don't ask the allergy question, and the accommodations question is updated.
How to test the changes in this Pull Request: