Skip to content

Commit

Permalink
CSfix and code optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
sapayth committed Sep 30, 2024
1 parent 7abde4c commit c921651
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion assets/js/stores/subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export const useSubscriptionStore = defineStore( 'subscription', {
return;
}

if ( typeof this.currentSubscription.meta_value[key] === 'string' ) {
if ( (typeof this.currentSubscription.meta_value[key] === 'string') && key === 'additional_cpt_options' ) {
this.currentSubscription.meta_value[key] = {};
}

Expand Down
2 changes: 1 addition & 1 deletion assets/js/subscriptions.min.js

Large diffs are not rendered by default.

14 changes: 11 additions & 3 deletions includes/Admin/Admin_Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,17 @@ public function third_party_cpt_options( $additional_options ) {
'db_type' => 'meta_serialized',
'serialize_key' => $key,
'type' => 'input-number',
'label' => sprintf( 'Number of %s', esc_html( $post_type_object->label ) ),
'tooltip' => sprintf(
'Set the maximum number of %s users can create within their subscription period. Enter -1 for unlimited',
'label' => sprintf(
// translators: %s: post type label
__( 'Number of %s', 'wp-user-frontend' ),
esc_html( $post_type_object->label )
),
'tooltip' => sprintf(
// translators: %s: post type label
__(
'Set the maximum number of %s users can create within their subscription period. Enter -1 for unlimited',
'wp-user-frontend'
),
esc_html( $key )
),
'default' => '-1',
Expand Down
3 changes: 3 additions & 0 deletions includes/Ajax/Frontend_Form_Ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ class Frontend_Form_Ajax {
private $expired_post_status = 'wpuf-expired_post_status';

private $post_expiration_message = 'wpuf-post_expiration_message';

/**
* An array of form fields retrieved from the form configuration.
*
* @var array
*/
private $form_fields;
Expand Down
2 changes: 1 addition & 1 deletion includes/Traits/TaxableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ function wpuf_tax_rate_country_state( $country, $state ) {
continue;
}
if ( $rate['state'] === $state && $rate['country'] === $country ) {
$tax_amount = ! empty( $rate['rate'] ) ? $rate['rate'] : 0;
$tax_amount = isset( $rate['rate'] ) ? $rate['rate'] : 0;
}

if ( intval( $tax_amount ) === 0 && $rate['country'] === $country && 'country_wide' === $rate['state'] ) {
Expand Down
3 changes: 2 additions & 1 deletion includes/User_Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,12 @@ public function add_pack( $pack_id, $profile_id, $recurring, $status = null ) {
$subscription = wpuf()->subscription->get_subscription( $pack_id );

$additional_cpt_options = ! empty( $subscription->meta_value['additional_cpt_options'] ) ? $subscription->meta_value['additional_cpt_options'] : [];
$post_type_name = isset( $subscription->meta_value['post_type_name'] ) && is_array( $subscription->meta_value['post_type_name'] ) ? $subscription->meta_value['post_type_name'] : [];

if ( $this->user->id && $subscription ) {
$user_meta = [
'pack_id' => $pack_id,
'posts' => array_merge( $subscription->meta_value['post_type_name'], $additional_cpt_options ),
'posts' => array_merge( $post_type_name, $additional_cpt_options ),
'total_feature_item' => $subscription->meta_value['_total_feature_item'],
'remove_feature_item' => $subscription->meta_value['_remove_feature_item'],
'status' => $status,
Expand Down

0 comments on commit c921651

Please sign in to comment.