Skip to content

Commit

Permalink
Merge pull request #13 from mt-support/task/updates-april-2023
Browse files Browse the repository at this point in the history
Task/updates april 2023
  • Loading branch information
skyshab authored Apr 30, 2023
2 parents 12f85db + 320cdde commit 4591dd8
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 10 deletions.
2 changes: 1 addition & 1 deletion plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin URI:
* GitHub Plugin URI: https://github.com/mt-support/tec-labs-members-only-tickets
* Description: Hide or limit purchase of members only tickets.
* Version: 1.0.1
* Version: 1.0.2
* Author: The Events Calendar
* Author URI: https://evnt.is/1971
* License: GPL version 3 or any later version
Expand Down
10 changes: 8 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Contributors: theeventscalendar
Donate link: https://evnt.is/29
Tags: events, calendar
Requires at least: 4.9
Tested up to: 5.7
Tested up to: 6.2
Requires PHP: 5.6
Stable tag: 1.0.0
Stable tag: 1.0.2
License: GPL version 3 or any later version
License URI: https://www.gnu.org/licenses/gpl-3.0.html

Expand Down Expand Up @@ -33,6 +33,12 @@ We're always interested in your feedback and our [Help Desk](https://theeventsca

== Changelog ==

= [1.0.2] 2023-04-30 =

* Fix - MemberPress now shows members tickets when expected.
* Fix - Added check for existence of WooCommerce before adding actions.
* Enhancement - Added style wrapper around admin settings.

= [1.0.1] 2022-05-19 =

* Remove trailing commas
Expand Down
2 changes: 1 addition & 1 deletion src/TEC_Labs/Integrations/Integration_Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct( $plugin ) {
* @return void
*/
public function boot() {
if ( ! $this->is_active() ) {
if ( ! $this->is_active() || ! class_exists( 'Woocommerce' ) ) {
return;
}

Expand Down
17 changes: 14 additions & 3 deletions src/TEC_Labs/Integrations/MemberPress.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ public function can_purchase( $product_id ) {
return false;
}

return current_user_can( 'mepr-active', "product: {$product_id}" );
$product = get_post( $product_id );
$is_locked = \MeprRule::is_locked( $product );

return ! $is_locked;
}

/**
Expand All @@ -95,6 +98,10 @@ protected function is_member_ticket( $ticket_id ) {
*/
public function settings( $settings ) {
$settings[ $this->get_id() ] = [
"{$this->get_id()}_members_settings_start" => [
'type' => 'html',
'html' => '<div class="tribe-settings-form-wrap">'
],
"{$this->get_id()}_members_settings_intro" => [
'type' => 'html',
'html' => sprintf(
Expand All @@ -107,15 +114,19 @@ public function settings( $settings ) {
'type' => 'checkbox_bool',
'label' => esc_html__( "Hide members only tickets.", 'et-members-only-tickets' ),
'tooltip' => esc_html__( "When enabled, only members will see members only tickets.", 'et-members-only-tickets'),
'validation_type' => 'boolean'
'validation_type' => 'boolean',
],
"{$this->get_id()}_members_only_message" => [
'type' => 'textarea',
'label' => esc_html__( "Message for non-members.", 'et-members-only-tickets' ),
'tooltip' => esc_html__( "Non-members will see this text as the ticket description.", 'et-members-only-tickets'),
'default' => esc_html__( "This ticket is for members only.", 'et-members-only-tickets' ),
'validation_type' => 'html'
]
],
"{$this->get_id()}_members_settings_end" => [
'type' => 'html',
'html' => '</div>'
],
];

return $settings;
Expand Down
10 changes: 9 additions & 1 deletion src/TEC_Labs/Integrations/Paid_Memberships_Pro.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ public function can_purchase( $product_id ) {
*/
public function settings( $settings ) {
$settings[ $this->get_id() ] = [
"{$this->get_id()}_members_settings_start" => [
'type' => 'html',
'html' => '<div class="tribe-settings-form-wrap">'
],
"{$this->get_id()}_members_settings_intro" => [
'type' => 'html',
'html' => sprintf(
Expand Down Expand Up @@ -153,7 +157,11 @@ public function settings( $settings ) {
'tooltip' => esc_html__( 'Non-members will see this text in place of the ticket description.', 'et-members-only-tickets' ),
'default' => esc_html__( 'This ticket is for members only.', 'et-members-only-tickets' ),
'validation_type' => 'html'
]
],
"{$this->get_id()}_members_settings_end" => [
'type' => 'html',
'html' => '</div>'
],
];

return $settings;
Expand Down
10 changes: 9 additions & 1 deletion src/TEC_Labs/Integrations/Restrict_Content_Pro.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ public function can_purchase( $product_id ) {
*/
public function settings( $settings ) {
$settings[ $this->get_id() ] = [
"{$this->get_id()}_members_settings_start" => [
'type' => 'html',
'html' => '<div class="tribe-settings-form-wrap">'
],
"{$this->get_id()}_members_settings_intro" => [
'type' => 'html',
'html' => sprintf(
Expand All @@ -81,7 +85,11 @@ public function settings( $settings ) {
'tooltip' => esc_html__( 'Non-members will see this text as the ticket description.', 'et-members-only-tickets'),
'default' => esc_html__( 'This ticket is for members only.', 'et-members-only-tickets' ),
'validation_type' => 'html'
]
],
"{$this->get_id()}_members_settings_end" => [
'type' => 'html',
'html' => '</div>'
],
];

return $settings;
Expand Down
10 changes: 9 additions & 1 deletion src/TEC_Labs/Integrations/WooCommerce_Memberships.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ public function can_purchase( $product_id ) {
*/
public function settings( $settings ) {
$settings[ $this->get_id() ] = [
"{$this->get_id()}_members_settings_start" => [
'type' => 'html',
'html' => '<div class="tribe-settings-form-wrap">'
],
"{$this->get_id()}_members_settings_intro" => [
'type' => 'html',
'html' => sprintf(
Expand All @@ -109,7 +113,11 @@ public function settings( $settings ) {
'tooltip' => esc_html__( 'Non-members will see this text as the ticket description.', 'et-members-only-tickets'),
'default' => esc_html__( 'This ticket is for members only.', 'et-members-only-tickets' ),
'validation_type' => 'html'
]
],
"{$this->get_id()}_members_settings_end" => [
'type' => 'html',
'html' => '</div>'
],
];

return $settings;
Expand Down

0 comments on commit 4591dd8

Please sign in to comment.