-
Notifications
You must be signed in to change notification settings - Fork 94
Added option to load and enable select2 in ticket registration form #212
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -470,9 +470,18 @@ function enqueue_scripts() { | |
| 'enterEmail' => __( 'Please enter the e-mail addresses in the forms above.', 'camptix' ), | ||
| 'ajaxURL' => admin_url( 'admin-ajax.php' ), | ||
| ) ); | ||
|
|
||
| // Let's play by the rules and print this in the <head> section. | ||
| wp_enqueue_style( 'camptix' ); | ||
|
|
||
|
|
||
| if ( (bool) $this->options['select2_enabled'] ) { | ||
| wp_register_style( 'select2', plugins_url( '/external/select2/css/select2.min.css', __FILE__ ), array(), $this->version ); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The version numbers used to register the stylesheet and script should be the version of Select2, not CampTix. |
||
| wp_register_script( 'select2', plugins_url( '/external/select2/js/select2.min.js', __FILE__ ), array(), $this->version ); | ||
|
|
||
| wp_enqueue_style( 'select2' ); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just noting here at that since the Select2 assets will always be both registered and enqueued if the option is enabled, you can save a step by just calling the But I guess another question is, should the assets always be enqueued, or only for certain views? |
||
| wp_enqueue_script( 'select2' ); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| function admin_enqueue_scripts() { | ||
|
|
@@ -1493,7 +1502,10 @@ function menu_setup_controls() { | |
| $this->add_settings_field_helper( 'currency', __( 'Currency', 'camptix' ), 'field_currency' ); | ||
|
|
||
| $this->add_settings_field_helper( 'refunds_enabled', __( 'Enable Refunds', 'camptix' ), 'field_enable_refunds', false, | ||
| __( "This will allows your customers to refund their tickets purchase by filling out a simple refund form.", 'camptix' ) | ||
| __( "This will allow your customers to refund their tickets purchase by filling out a simple refund form.", 'camptix' ) | ||
| ); | ||
| $this->add_settings_field_helper( 'select2_enabled', __( 'Enable Select2', 'camptix' ), 'field_enable_select2', false, | ||
| __( "This will render all the dropdown answers as a searchable dropdown instead of normal select dropdown", 'camptix' ) | ||
| ); | ||
|
|
||
| break; | ||
|
|
@@ -1621,7 +1633,7 @@ function validate_options( $input ) { | |
| if ( isset( $input['refunds_date_end'], $input['refunds_enabled'] ) && (bool) $input['refunds_enabled'] && strtotime( $input['refunds_date_end'] ) ) | ||
| $output['refunds_date_end'] = $input['refunds_date_end']; | ||
|
|
||
| $yesno_fields = array( 'refunds_enabled' ); | ||
| $yesno_fields = array( 'refunds_enabled', 'select2_enabled' ); | ||
|
|
||
| // Beta features checkboxes | ||
| if ( $this->beta_features_enabled ) | ||
|
|
@@ -1766,6 +1778,17 @@ function field_enable_refunds( $args ) { | |
| <?php | ||
| } | ||
|
|
||
| function field_enable_select2( $args ) {?> | ||
| <div id="tix-select2-enabled-radios"> | ||
| <label class="tix-yes-no description"><input type="radio" name="<?php echo esc_attr( $args['name'] ); ?>" value="1" <?php checked( $args['value'], true ); ?>> <?php _e( 'Yes', 'camptix' ); ?></label> | ||
| <label class="tix-yes-no description"><input type="radio" name="<?php echo esc_attr( $args['name'] ); ?>" value="0" <?php checked( $args['value'], false ); ?>> <?php _e( 'No', 'camptix' ); ?></label> | ||
| </div> | ||
| <?php if ( isset( $args['description'] ) ) : ?> | ||
| <p class="description"><?php echo wp_kses_post( $args['description'] ); ?></p> | ||
| <?php endif; ?> | ||
| <?php | ||
| } | ||
|
|
||
| /** | ||
| * The currency field for the Settings API. | ||
| */ | ||
|
|
@@ -5480,7 +5503,8 @@ function form_attendee_info() { | |
| $questions = $this->get_sorted_questions( $ticket->ID ); | ||
| ?> | ||
| <input type="hidden" name="tix_attendee_info[<?php echo esc_attr( $i ); ?>][ticket_id]" value="<?php echo intval( $ticket->ID ); ?>" /> | ||
| <table class="tix_tickets_table tix-attendee-form"> | ||
| <table class="tix_tickets_table tix-attendee-form <?php echo ( isset($this->options['select2_enabled']) && (bool) ( $this->options['select2_enabled'] ) ) ? | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is one of the places we'd like to add it. It'd also be use it for the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a separate patch for currency, since its not a part of camptix. Or am I confusing with a different currency dropdown ?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah. CampTix has a currency dropdown on the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah ok. Added. |
||
| 'tix-select2-enabled' : '' ?>"> | ||
| <tbody> | ||
| <tr> | ||
| <th colspan="2"> | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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 don't think we need an option for this; adding it doesn't break backwards-compatibiliity, and I don't imagine many users wanting to disable it. Here's some more info on how we typically approach options:
https://nacin.com/2011/12/18/in-open-source-learn-to-decide/
https://wordpress.org/about/philosophy/
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 want a configuration because of accessibility (select2/select2#3744) . Looks like this is also the blocker for merging select2 in core. What do you think ? At the very least, we should enable by 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.
That's a good point. They could always call
wp_dequeue_script()from a plugin to disable it, but I realize that'd require some development experience.It sounds like one our coworkers has already forked Select2 to make it accessible, so maybe we should switch to that instead?
If you feel like it, it might even be good to send a PR to selectWoo to merge in the upstream changes. That'd help us by fixing any bugs that haven't made it downstream; help selectWoo users for the same reason; and eventually help WP Core and Drupal, by making it easy to merge the a11y fixes upstream.
In general we try to be good open source citizens, but of course it always has to be balanced against time spent on our own priorities. This seems like a really good opportunity, though.
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.
Or, rather than trying to merge downstream, maybe it'd be better to just cherry-pick commits from downstream and send PRs upstream? That may be more efficient, since any changes will need to be tested in either direction. Whichever you think is best :)
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 have send in some PRs in wooSelect (woocommerce/selectWoo#18 and woocommerce/selectWoo#17) but it will take a while before they get merged. I want to wait till they get before we use wooSelect, since it doesn't have downstream changes, but we can use it right away as well. What do you think ?
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.
It sounds like they'll be looking at it soon, so waiting is probably fine in this case. If it takes them longer than expected, then we can always go ahead and use the setup the latest
masterbuild now, and then update it after your PRs are merged.