Skip to content

Commit

Permalink
Merge pull request #4 from mt-support/1.0.2
Browse files Browse the repository at this point in the history
1.1.0
  • Loading branch information
andrasguseo authored Sep 24, 2024
2 parents 670581e + c4c4711 commit a59085d
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 24 deletions.
5 changes: 2 additions & 3 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin URI: https://theeventscalendar.com/extensions/default-ticket-fieldset/
* GitHub Plugin URI: https://github.com/mt-support/tec-labs-default-ticket-fieldset
* Description: Select a fieldset that will be added to all RSVPs and tickets when they are created. You can find the settings under Events > Settings > Tickets tab > Default Ticket Fieldsets section.
* Version: 1.0.1
* Version: 1.1.0
* Author: The Events Calendar
* Author URI: https://evnt.is/1971
* License: GPL version 3 or any later version
Expand Down Expand Up @@ -71,5 +71,4 @@ function tribe_extension_default_ticket_fieldset() {
}

// Loads after common is already properly loaded.
add_action( 'tribe_common_loaded', 'tribe_extension_default_ticket_fieldset' );
add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), '\Tribe\Extensions\Default_Ticket_Fieldset\Plugin::plugin_settings_link' );
add_action( 'tribe_common_loaded', 'tribe_extension_default_ticket_fieldset' );
15 changes: 11 additions & 4 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
Contributors: theeventscalendar
Donate link: https://evnt.is/29
Tags: events, calendar
Requires at least: 4.9
Tested up to: 5.8.1
Requires PHP: 5.6
Stable tag: 1.0.1
Requires at least: 6.3
Tested up to: 6.6.2
Requires PHP: 7.4
Stable tag: 1.1.0
License: GPL version 3 or any later version
License URI: https://www.gnu.org/licenses/gpl-3.0.html

Expand Down Expand Up @@ -36,6 +36,13 @@ We're always interested in your feedback and our [Help Desk](https://support.the

== Changelog ==

= [1.1.0] 2024-09-24 =

* Feature - Add support for Tickets Commerce tickets.
* Fix - Ensure the Settings link is added to the plugin actions the correct way and points to the right page.
* Fix - Correct the URL pointing to the Ticket Fieldsets admin page.
* Tweak - Make sure the settings show up under Tickets → Settings → Attendee Registration.

= [1.0.1] 2023-06-24 =

* Fix - Update to use the new Service_Provider contract in common.
Expand Down
43 changes: 30 additions & 13 deletions src/Tec/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Plugin extends Service_Provider {
*
* @var string
*/
const VERSION = '1.0.1';
const VERSION = '1.1.0';

/**
* Stores the base slug for the plugin.
Expand Down Expand Up @@ -75,7 +75,7 @@ class Plugin extends Service_Provider {
private $settings;

/**
* Setup the Extension's properties.
* Set up the Extension's properties.
*
* This always executes even if the required plugins are not present.
*
Expand Down Expand Up @@ -103,6 +103,7 @@ public function register() {

// Start binds.

add_filter( 'plugin_action_links_' . $this->plugin_dir . 'plugin.php', [ $this, 'plugin_settings_link' ], 10, 4 );
add_action( 'tribe_tickets_ticket_add', [ $this, 'apply_default_fieldset' ], 10, 3 );

// End binds.
Expand Down Expand Up @@ -214,19 +215,29 @@ function apply_default_fieldset( $post_id, $ticket, $data ) {
return;
}

if ( Tribe__Tickets__RSVP == $data['ticket_provider'] ) {
$default_form_post_id = $options['rsvp_default_fieldset'];
} elseif ( Tribe__Tickets_Plus__Commerce__WooCommerce__Main == $data['ticket_provider'] ) {
$default_form_post_id = $options['wooticket_default_fieldset'];
} elseif ( Tribe__Tickets_Plus__Commerce__EDD__Main == $data['ticket_provider'] ) {
$default_form_post_id = $options['eddticket_default_fieldset'];
} else {
return;
switch ( $data['ticket_provider'] ) {
case 'Tribe__Tickets__RSVP':
$default_form_post_id = $options['rsvp_default_fieldset'];
break;
/**
* @since 1.1.0
*/
case 'TEC\Tickets\Commerce\Module':
$default_form_post_id = $options['tickets_commerce_default_fieldset'];
break;
case 'Tribe__Tickets_Plus__Commerce__WooCommerce__Main':
$default_form_post_id = $options['wooticket_default_fieldset'];
break;
case 'Tribe__Tickets_Plus__Commerce__EDD__Main':
$default_form_post_id = $options['eddticket_default_fieldset'];
break;
default:
return;
}

if (
empty( $default_form_post_id )
|| !isset ( $default_form_post_id )
|| ! isset ( $default_form_post_id )
|| 0 == $default_form_post_id
) {
return;
Expand All @@ -250,8 +261,14 @@ function apply_default_fieldset( $post_id, $ticket, $data ) {
*
* @return array
*/
public function plugin_settings_link( $links ) {
$url = get_admin_url() . 'edit.php?post_type=tribe_events&page=tribe-common&tab=event-tickets#default-ticket-fieldset-settings';
public function plugin_settings_link( $links, $plugin_file, $plugin_data, $context ) {
$url = add_query_arg(
array(
'page' => 'tec-tickets-settings',
'tab' => 'attendee-registration'
),
admin_url('admin.php')
) . '#default-ticket-fieldset-settings';
$settings_link = '<a href="' . $url . '">' . __( 'Settings', 'tec-labs-default-ticket-fieldset' ) . '</a>';
array_push( $links, $settings_link );

Expand Down
31 changes: 27 additions & 4 deletions src/Tec/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,27 @@ public function add_settings() {
],
];

/**
* @since 1.1.0
*/
if ( tec_tickets_commerce_is_enabled() ) {
$fields['tickets_commerce_default_fieldset'] = [
'type' => 'dropdown',
'label' => esc_html_x( 'Tickets Commerce ticket', 'Setting label', 'tec-labs-default-ticket-fieldset' ),
'tooltip' => sprintf(
// Translators: %s Name of the eCommerce platform.
esc_html_x(
'The Ticket Fieldset to be added when a ticket with %s is created.',
'Setting description',
'tec-labs-default-ticket-fieldset'
),
'Tickets Commerce'
),
'validation_type' => 'options',
'options' => $ticket_fieldsets,
];
}

if ( class_exists( 'WooCommerce' ) ) {
$fields['wooticket_default_fieldset'] = [
'type' => 'dropdown',
Expand Down Expand Up @@ -266,9 +287,9 @@ public function add_settings() {

$this->settings_helper->add_fields(
$this->prefix_settings_field_keys( $fields ),
'event-tickets',
'ticket-paypal-heading',
true
'attendee-registration',
'ticket-attendee-page-id',
false
);
}

Expand Down Expand Up @@ -304,6 +325,8 @@ private function get_default_fieldset_intro_text() {
$result .= esc_html_x( 'You can set up default fieldsets that will be saved with every newly created RSVP or ticket, for tickets created both on the backend or through the Community Events submission form.', 'Setting section description', 'tec-labs-default-ticket-fieldset' );
$result .= ' ';
$result .= esc_html_x( 'If a fieldset is already being added to a ticket manually, then the defaults will not be applied, unless the override setting is enabled.', 'Setting section description', 'tec-labs-default-ticket-fieldset' );
$result .= ' ';
$result .= esc_html_x( 'Individual Attendee Collection fields are added based on the setting above.', 'Setting section description', 'tec-labs-default-ticket-fieldset' );
$result .= '<br>';
$result .= sprintf(
// Translators: %1$s opening <a> tag with URL, %2$s closing </a> tag
Expand All @@ -312,7 +335,7 @@ private function get_default_fieldset_intro_text() {
'Setting section description',
'tec-labs-default-ticket-fieldset'
),
'<a href="' . get_site_url() . ' . /wp-admin/edit.php?post_type=ticket-meta-fieldset">',
'<a href="' . get_site_url() . '/wp-admin/edit.php?post_type=ticket-meta-fieldset">',
'</a>'
);
$result .= '</p>';
Expand Down

0 comments on commit a59085d

Please sign in to comment.