Skip to content

Commit 02f899b

Browse files
committed
STYLE: fix indentation based on phpcs rules
1 parent 0ccdf2b commit 02f899b

File tree

3 files changed

+119
-106
lines changed

3 files changed

+119
-106
lines changed

includes/Admin/Subscription.php

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,12 @@ public static function subscriber_cancel( $user_id, $pack_id ) {
6363
'SELECT transaction_id FROM ' . $wpdb->prefix . 'wpuf_transaction
6464
WHERE user_id = %d AND pack_id = %d LIMIT 1', $user_id, $pack_id
6565
);
66-
$result = $wpdb->get_row( $wpdb->prepare(
67-
'SELECT transaction_id FROM ' . $wpdb->prefix . 'wpuf_transaction
66+
$result = $wpdb->get_row(
67+
$wpdb->prepare(
68+
'SELECT transaction_id FROM ' . $wpdb->prefix . 'wpuf_transaction
6869
WHERE user_id = %d AND pack_id = %d LIMIT 1', $user_id, $pack_id
69-
) );
70+
)
71+
);
7072

7173
$transaction_id = $result ? $result->transaction_id : 'Free';
7274

@@ -391,9 +393,9 @@ public function save_form_meta( $subscription_id, $post ) {
391393

392394
$post_data = wp_unslash( $_POST );
393395

394-
// if ( ! isset( $post_data['billing_amount'] ) ) {
395-
// return;
396-
// }
396+
// if ( ! isset( $post_data['billing_amount'] ) ) {
397+
// return;
398+
// }
397399

398400
$expiration_time = '';
399401
$enable_post_expir = '';
@@ -755,11 +757,13 @@ public static function post_by_orderid( $order_id ) {
755757
WHERE p.ID = m.post_id AND p.post_status <> 'publish' AND m.meta_key = '_wpuf_order_id' AND m.meta_value = %s", $order_id
756758
);
757759

758-
return $wpdb->get_row( $wpdb->prepare(
759-
"SELECT p.ID, p.post_status
760+
return $wpdb->get_row(
761+
$wpdb->prepare(
762+
"SELECT p.ID, p.post_status
760763
FROM $wpdb->posts p, $wpdb->postmeta m
761764
WHERE p.ID = m.post_id AND p.post_status <> 'publish' AND m.meta_key = '_wpuf_order_id' AND m.meta_value = %s", $order_id
762-
) );
765+
)
766+
);
763767
}
764768

765769
/**
@@ -874,7 +878,7 @@ public function subscription_packs( $atts = null ) {
874878
! empty( $current_pack['pack_id'] ) &&
875879
isset( $current_pack['status'] ) &&
876880
$current_pack['status'] === 'completed'
877-
) {
881+
) {
878882
global $wpdb;
879883

880884
$user_id = get_current_user_id();
@@ -885,7 +889,7 @@ public function subscription_packs( $atts = null ) {
885889

886890
<?php echo wp_kses_post( __( '<p><i>You have a subscription pack activated. </i></p>', 'wp-user-frontend' ) ); ?>
887891
<?php /* translators: %s: pack title */ ?>
888-
<?php echo sprintf( wp_kses_post( __( '<p><i>Pack name: %s </i></p>', 'wp-user-frontend' ) ), esc_html( get_the_title( $current_pack['pack_id'] ) ) ); ?>
892+
<?php printf( wp_kses_post( __( '<p><i>Pack name: %s </i></p>', 'wp-user-frontend' ) ), esc_html( get_the_title( $current_pack['pack_id'] ) ) ); ?>
889893

890894
<?php echo '<p><i>' . esc_html__( 'To cancel the pack, press the following cancel button', 'wp-user-frontend' ) . '</i></p>'; ?>
891895

@@ -978,15 +982,14 @@ public function pack_details( $pack, $details_meta, $current_pack_id = '', $coup
978982

979983
$recurring_des = sprintf( __( 'Every', 'wp-user-frontend' ) . ' %s %s', $cycle_number, self::get_cycle_label( $pack->meta_value['cycle_period'], $pack->meta_value['billing_cycle_number'] ), $pack->meta_value['_trial_duration_type'] );
980984

981-
982985
if ( wpuf_is_checkbox_or_toggle_on( $pack->meta_value['enable_billing_limit'] ) && ! empty( $pack->meta_value['billing_limit'] ) && '-1' !== $pack->meta_value['billing_limit'] ) {
983986
$recurring_des .= ! empty( $pack->meta_value['billing_limit'] ) ? sprintf( ', ' . __( 'for', 'wp-user-frontend' ) . ' %s ' . __( 'installments', 'wp-user-frontend' ), $pack->meta_value['billing_limit'] ) : '';
984987
}
985988

986989
$recurring_des = '<div class="wpuf-pack-cycle wpuf-nullamount-hide">' . $recurring_des . '</div>';
987990
}
988991

989-
if ( $billing_amount && wpuf_is_checkbox_or_toggle_on( $pack->meta_value['recurring_pay'] ) && wpuf_is_checkbox_or_toggle_on( $pack->meta_value['_trial_status'] ) ) {
992+
if ( $billing_amount && wpuf_is_checkbox_or_toggle_on( $pack->meta_value['recurring_pay'] ) && wpuf_is_checkbox_or_toggle_on( $pack->meta_value['_trial_status'] ) ) {
990993
//phpcs:ignore
991994
$duration = _n( $pack->meta_value['_trial_duration_type'], $pack->meta_value['_trial_duration_type'] . 's', $pack->meta_value['_trial_duration'], 'wp-user-frontend' );
992995
/* translators: %s: trial days */

includes/User_Subscription.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,12 @@ public function current_pack() {
5656
if ( ! isset( $this->pack['pack_id'] ) ) {
5757
$pack_page = get_permalink( wpuf_get_option( 'subscription_page', 'wpuf_payment' ) );
5858

59-
return new WP_Error( 'no-pack', sprintf(
59+
return new WP_Error(
60+
'no-pack', sprintf(
6061
// translators: %s is the user pack page url
61-
__( 'You must <a href="%s">purchase a subscription package</a> before posting', 'wp-user-frontend' ), $pack_page ) );
62+
__( 'You must <a href="%s">purchase a subscription package</a> before posting', 'wp-user-frontend' ), $pack_page
63+
)
64+
);
6265
}
6366

6467
// seems like the user has a pack, now check expiration
@@ -83,7 +86,7 @@ public function expired() {
8386

8487
$expire_date = isset( $this->pack['expire'] ) ? $this->pack['expire'] : 0;
8588
$expired = true;
86-
89+
8790
// phpcs:disable
8891
if ( strtolower( $expire_date ) == 'unlimited' || empty( $expire_date ) || $expire_date == '-1' ) {
8992
$expired = false;

templates/dashboard/subscription.php

Lines changed: 97 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
<strong><?php esc_html_e( 'Package & billing details: ', 'wp-user-frontend' ); ?></strong>
88
<?php echo esc_html( $billing_amount . ' ' . $recurring_des ); ?>
99
</div>
10-
<?php if ( is_wp_error( $user_sub ) ) { ?>
10+
<?php if ( is_wp_error( $user_sub ) ) { ?>
1111
<div>
1212
<strong><?php esc_html_e( 'Subscription Status: ', 'wp-user-frontend' ); ?></strong>
1313
<?php esc_html_e( 'Subscription Expired!', 'wp-user-frontend' ); ?>
1414
</div>
15-
<?php } else {
16-
if ( ! empty( $user_sub['total_feature_item'] ) && -1 === $user_sub['total_feature_item'] ) { ?>
15+
<?php
16+
} else {
17+
if ( ! empty( $user_sub['total_feature_item'] ) && -1 === $user_sub['total_feature_item'] ) {
18+
?>
1719
<div><strong><?php esc_html_e( 'Number of featured item: ', 'wp-user-frontend' ); ?></strong><?php echo esc_html( $user_sub['total_feature_item'] ); ?></div>
1820
<?php } ?>
1921
<div>
@@ -31,7 +33,7 @@
3133
if ( ! $post_type_obj ) {
3234
continue;
3335
}
34-
$post_count++;
36+
++$post_count;
3537
}
3638
}
3739
?>
@@ -49,17 +51,17 @@
4951
continue;
5052
}
5153
$value = ( $value == '-1' ) ? __( 'Unlimited', 'wp-user-frontend' ) : $value;
52-
$hidden_class = ($i >= 3) ? 'wpuf-remaining-post-hidden' : '';
54+
$hidden_class = ( $i >= 0 ) ? 'wpuf-remaining-post-hidden' : '';
5355
?>
5456
<div class="<?php echo esc_attr( $hidden_class ); ?>"><?php echo esc_html( $post_type_obj->labels->name ) . ': ' . esc_html( $value ); ?></div>
5557
<?php
56-
$i ++;
58+
++$i;
5759
}
5860
}
5961
echo $i ? '' : esc_attr( $i );
6062
?>
6163
</div>
62-
<?php if ( $post_count > 3 ) : ?>
64+
<?php if ( $post_count > 0 ) : ?>
6365
<button type="button" id="wpuf-remaining-posts-toggle" class="btn btn-link" style="padding:0;"><?php esc_html_e( 'Show More', 'wp-user-frontend' ); ?></button>
6466
<script>
6567
(function(){
@@ -80,8 +82,9 @@
8082
</div>
8183
<?php
8284
if ( $user_sub['recurring'] != 'yes' ) {
83-
if ( !empty( $user_sub['expire'] ) ) {
84-
$expiry_date = ( 'unlimited' === $user_sub['expire'] ) ? __( 'Unlimited', 'wp-user-frontend' ) : wpuf_get_date( wpuf_date2mysql( $user_sub['expire'] ) ); ?>
85+
if ( ! empty( $user_sub['expire'] ) ) {
86+
$expiry_date = ( 'unlimited' === $user_sub['expire'] ) ? __( 'Unlimited', 'wp-user-frontend' ) : wpuf_get_date( wpuf_date2mysql( $user_sub['expire'] ) );
87+
?>
8588
<div class="wpuf-expire">
8689
<strong><?php echo esc_html__( 'Expire date:', 'wp-user-frontend' ); ?></strong> <?php echo esc_html( $expiry_date ); ?>
8790
</div>
@@ -105,136 +108,140 @@
105108
* @param array $user_sub User subscription data
106109
* @return array Subscription data
107110
*/
108-
function get_subscription_data( $user_sub ) {
109-
global $wpdb;
110-
111-
$user_id = get_current_user_id();
112-
$pack_id = $user_sub['pack_id'];
113-
$subscription = wpuf()->subscription->get_subscription( $pack_id );
114-
// Get payment gateway
115-
$payment_gateway = $wpdb->get_var( $wpdb->prepare(
111+
function get_subscription_data( $user_sub ) {
112+
global $wpdb;
113+
114+
$user_id = get_current_user_id();
115+
$pack_id = $user_sub['pack_id'];
116+
$subscription = wpuf()->subscription->get_subscription( $pack_id );
117+
// Get payment gateway
118+
$payment_gateway = $wpdb->get_var(
119+
$wpdb->prepare(
116120
"SELECT payment_type
117121
FROM {$wpdb->prefix}wpuf_transaction
118122
WHERE user_id = %d
119123
AND status = 'completed'
120-
ORDER BY created DESC",
121-
$user_id
122-
) );
123-
$payment_gateway = strtolower( $payment_gateway );
124+
ORDER BY created DESC",
125+
$user_id
126+
)
127+
);
128+
$payment_gateway = strtolower( $payment_gateway );
124129

125-
// Get last payment date
126-
$last_payment_date = $wpdb->get_var( $wpdb->prepare(
130+
// Get last payment date
131+
$last_payment_date = $wpdb->get_var(
132+
$wpdb->prepare(
127133
"SELECT created
128134
FROM {$wpdb->prefix}wpuf_transaction
129135
WHERE user_id = %d
130136
AND status = 'completed'
131137
ORDER BY created DESC
132138
LIMIT 1",
133139
$user_id
134-
) );
140+
)
141+
);
135142

136-
// Get billing cycle details
137-
$cycle_number = intval( $subscription->meta_value['billing_cycle_number'] );
138-
$cycle_period = $subscription->meta_value['cycle_period'];
139-
140-
// Get trial details
141-
$trial_status = $subscription->meta_value['trial_status'];
142-
$trial_duration = $subscription->meta_value['trial_duration'];
143-
$trial_duration_type = $subscription->meta_value['trial_duration_type'];
143+
// Get billing cycle details
144+
$cycle_number = intval( $subscription->meta_value['billing_cycle_number'] );
145+
$cycle_period = $subscription->meta_value['cycle_period'];
144146

145-
return [
146-
'payment_gateway' => $payment_gateway,
147-
'last_payment_date' => $last_payment_date,
148-
'cycle_number' => $cycle_number,
149-
'cycle_period' => $cycle_period,
150-
'trial_status' => $trial_status,
151-
'trial_duration' => $trial_duration,
152-
'trial_duration_type' => $trial_duration_type
153-
];
154-
}
147+
// Get trial details
148+
$trial_status = $subscription->meta_value['trial_status'];
149+
$trial_duration = $subscription->meta_value['trial_duration'];
150+
$trial_duration_type = $subscription->meta_value['trial_duration_type'];
151+
152+
return [
153+
'payment_gateway' => $payment_gateway,
154+
'last_payment_date' => $last_payment_date,
155+
'cycle_number' => $cycle_number,
156+
'cycle_period' => $cycle_period,
157+
'trial_status' => $trial_status,
158+
'trial_duration' => $trial_duration,
159+
'trial_duration_type' => $trial_duration_type,
160+
];
161+
}
155162

156163
/**
157164
* Display subscription details
158165
*
159166
* @param array $subscription_data Subscription data
160167
* @return void
161168
*/
162-
function display_subscription_details( $subscription_data ) {
163-
$trial_html = get_trial_expiration_html( $subscription_data );
164-
$billing_html = get_next_billing_html( $subscription_data );
165-
?>
169+
function display_subscription_details( $subscription_data ) {
170+
$trial_html = get_trial_expiration_html( $subscription_data );
171+
$billing_html = get_next_billing_html( $subscription_data );
172+
?>
166173
<br>
167-
<?php if ( $subscription_data['trial_status'] == 'on' ): ?>
174+
<?php if ( $subscription_data['trial_status'] == 'on' ) : ?>
168175
<?php echo wp_kses_post( $trial_html ); ?>
169-
<?php elseif ( $subscription_data['trial_status'] === 'off' ): ?>
176+
<?php elseif ( $subscription_data['trial_status'] === 'off' ) : ?>
170177
<div class="wpuf-recurring-info">
171178
<?php echo wp_kses_post( $billing_html ); ?>
172179
</div>
173180
<?php endif; ?>
174181

175182
<p><i><?php esc_html_e( 'To cancel the pack, press the following cancel button.', 'wp-user-frontend' ); ?></i></p>
176183
<form action="" method="post" style="text-align: center;">
177-
<?php wp_nonce_field( 'wpuf-sub-cancel' ); ?>
184+
<?php wp_nonce_field( 'wpuf-sub-cancel' ); ?>
178185
<input type="hidden" name="gateway" value="<?php echo esc_attr( $subscription_data['payment_gateway'] ); ?>">
179186
<input type="submit" name="wpuf_cancel_subscription" class="btn btn-sm btn-danger" value="<?php esc_html_e( 'Cancel', 'wp-user-frontend' ); ?>">
180187
</form>
181188
<?php
182-
}
189+
}
183190

184191
/**
185192
* Get trial expiration HTML
186193
*
187194
* @param array $subscription_data Subscription data
188195
* @return string HTML for trial expiration
189196
*/
190-
function get_trial_expiration_html( $subscription_data ) {
191-
if ( $subscription_data['trial_status'] !== 'on' ) {
192-
return '';
193-
}
197+
function get_trial_expiration_html( $subscription_data ) {
198+
if ( $subscription_data['trial_status'] !== 'on' ) {
199+
return '';
200+
}
194201

195-
$trial_expiration_date = date(
196-
'Y-m-d',
197-
strtotime(
198-
"+{$subscription_data['trial_duration']} {$subscription_data['trial_duration_type']}",
199-
strtotime( $subscription_data['last_payment_date'] )
200-
)
201-
);
202+
$trial_expiration_date = date(
203+
'Y-m-d',
204+
strtotime(
205+
"+{$subscription_data['trial_duration']} {$subscription_data['trial_duration_type']}",
206+
strtotime( $subscription_data['last_payment_date'] )
207+
)
208+
);
202209

203-
return sprintf(
204-
'<div><strong>%s</strong> %s</div>',
205-
esc_html__( 'Trial expiration date:', 'wp-user-frontend' ),
206-
esc_html( $trial_expiration_date )
207-
);
208-
}
210+
return sprintf(
211+
'<div><strong>%s</strong> %s</div>',
212+
esc_html__( 'Trial expiration date:', 'wp-user-frontend' ),
213+
esc_html( $trial_expiration_date )
214+
);
215+
}
209216

210217
/**
211218
* Get next billing HTML
212219
*
213220
* @param array $subscription_data Subscription data
214221
* @return string HTML for next billing
215222
*/
216-
function get_next_billing_html( $subscription_data ) {
217-
if ( ! $subscription_data['last_payment_date'] ||
218-
! $subscription_data['cycle_number'] ||
219-
! $subscription_data['cycle_period'] ) {
220-
return sprintf(
221-
'<div><strong>%s</strong> %s</div>',
222-
esc_html__( 'Next billing date:', 'wp-user-frontend' ),
223-
esc_html__( 'N/A', 'wp-user-frontend' )
224-
);
225-
}
223+
function get_next_billing_html( $subscription_data ) {
224+
if ( ! $subscription_data['last_payment_date'] ||
225+
! $subscription_data['cycle_number'] ||
226+
! $subscription_data['cycle_period'] ) {
227+
return sprintf(
228+
'<div><strong>%s</strong> %s</div>',
229+
esc_html__( 'Next billing date:', 'wp-user-frontend' ),
230+
esc_html__( 'N/A', 'wp-user-frontend' )
231+
);
232+
}
226233

227-
$next_billing_date = date(
228-
'Y-m-d',
229-
strtotime(
230-
"+{$subscription_data['cycle_number']} {$subscription_data['cycle_period']}",
231-
strtotime( $subscription_data['last_payment_date'] )
232-
)
233-
);
234-
return sprintf(
235-
'<div><strong>%s</strong> %s</div>',
236-
esc_html__( 'Next billing date:', 'wp-user-frontend' ),
237-
esc_html( $next_billing_date )
238-
);
239-
}
234+
$next_billing_date = date(
235+
'Y-m-d',
236+
strtotime(
237+
"+{$subscription_data['cycle_number']} {$subscription_data['cycle_period']}",
238+
strtotime( $subscription_data['last_payment_date'] )
239+
)
240+
);
241+
return sprintf(
242+
'<div><strong>%s</strong> %s</div>',
243+
esc_html__( 'Next billing date:', 'wp-user-frontend' ),
244+
esc_html( $next_billing_date )
245+
);
246+
}
240247
?>

0 commit comments

Comments
 (0)