'', 1 => __( 'Subscription pack updated.', 'wp-user-frontend' ), 2 => __( 'Custom field updated.', 'wp-user-frontend' ), 3 => __( 'Custom field deleted.', 'wp-user-frontend' ), 4 => __( 'Subscription pack updated.', 'wp-user-frontend' ), 5 => isset( $_GET['revision'] ) ? sprintf( __( 'Subscription pack restored to revision from %s', 'wp-user-frontend' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, 6 => __( 'Subscription pack published.', 'wp-user-frontend' ), 7 => __( 'Subscription pack saved.', 'wp-user-frontend' ), 8 => __( 'Subscription pack submitted.', 'wp-user-frontend' ), 9 => '', 10 => __( 'Subscription pack draft updated.', 'wp-user-frontend' ), ]; $messages['wpuf_subscription'] = $message; return $messages; } /** * Update user profile lock * * @param int $user_id */ public function profile_subscription_update( $user_id ) { if ( !is_admin() && !current_user_can( 'edit_users' ) ) { return; } $nonce = isset( $_REQUEST['wpuf-subscription-nonce'] ) ? sanitize_key( wp_unslash( $_REQUEST['wpuf-subscription-nonce'] ) ) : ''; if ( isset( $nonce ) && ! wp_verify_nonce( $nonce, 'update-profile_' . $user_id ) ) { return ; } if ( !isset( $_POST['pack_id'] ) ) { return; } if ( isset( $_POST['wpuf_profile_mail_noti'] ) ) { $wpuf_profile_mail_noti = sanitize_text_field( wp_unslash( $_POST['wpuf_profile_mail_noti'] ) ); update_user_meta( $user_id, '_pack_assign_notification', $wpuf_profile_mail_noti ); } $pack_id = isset( $_POST['pack_id'] ) ? intval( wp_unslash( $_POST['pack_id'] ) ) : ''; $u_id = isset( $_POST['user_id'] ) ? intval( wp_unslash( $_POST['user_id'] ) ) : ''; $pack = WPUF_Subscription::get_subscription( $pack_id ); $user_pack = WPUF_Subscription::get_user_pack( $u_id ); if ( isset( $user_pack['pack_id'] ) && $pack_id == $user_pack['pack_id'] ) { //updating number of posts if ( isset( $user_pack['posts'] ) ) { $p_type = isset( $_POST[$post_type] ) ? sanitize_text_field( wp_unslash( $_POST[$post_type] ) ) : ''; foreach ( $user_pack['posts'] as $post_type => $post_num ) { $user_pack['posts'][$post_type] = $p_type; } } //post expiration enable or disable if ( isset( $_POST['is_post_expiration_enabled'] ) ) { $user_pack['_enable_post_expiration'] = sanitize_text_field( wp_unslash( $_POST['is_post_expiration_enabled'] ) ); } else { unset( $user_pack['_enable_post_expiration'] ); } //updating post time if ( isset( $_POST['post_expiration_settings'] ) ) { $post_expiration_settings = array_map( 'sanitize_text_field', wp_unslash( $_POST['post_expiration_settings'] ) ); $user_pack['_post_expiration_time'] = $post_expiration_settings['expiration_time_value'] . ' ' . $post_expiration_settings['expiration_time_type']; echo esc_html( $user_pack['_post_expiration_time'] ); } if ( isset( $user_pack['recurring'] ) && $user_pack['recurring'] == 'yes' ) { foreach ( $user_pack['posts'] as $type => $value ) { $user_pack['posts'][$type] = isset( $_POST[$type] ) ? sanitize_text_field( wp_unslash( $_POST[$type] ) ) : 0; } } else { foreach ( $user_pack['posts'] as $type => $value ) { $user_pack['posts'][$type] = isset( $_POST[$type] ) ? sanitize_text_field( wp_unslash( $_POST[$type] ) ) : 0; } $user_pack['expire'] = isset( $_POST['expire'] ) ? wpuf_date2mysql( sanitize_text_field( wp_unslash( $_POST['expire'] ) ) ) : $user_pack['expire']; } wpuf_get_user( $user_id )->subscription()->update_meta( $user_pack ); } else { if ( $pack_id == '-1' ) { return; } $user_info = get_userdata( $user_id ); $cost = $pack->meta_value['billing_amount']; $billing_amount = apply_filters( 'wpuf_payment_amount', $cost ); $tax_amount = $billing_amount - $cost; $data = [ 'user_id' => $user_id, 'status' => 'completed', 'subtotal' => $cost, 'tax' => $tax_amount, 'cost' => $billing_amount, 'post_id' => 0, 'pack_id' => $pack_id, 'payer_first_name' => $user_info->first_name, 'payer_last_name' => $user_info->last_name, 'payer_email' => $user_info->user_email, 'payment_type' => 'bank', 'payer_address' => null, 'transaction_id' => 0, 'created' => current_time( 'mysql' ), 'profile_id' => null, ]; $is_recurring = false; if ( isset( $user_pack['recurring'] ) && $user_pack['recurring'] == 'yes' ) { $is_recurring = true; } WPUF_Payment::insert_payment( $data, 0, $is_recurring ); } } /** * Subscription column headings * * @param array $head * * @return array */ public function subscription_columns_head( $head ) { unset( $head['date'] ); $head['title'] = __( 'Pack Name', 'wp-user-frontend' ); $head['amount'] = __( 'Amount', 'wp-user-frontend' ); $head['subscribers'] = __( 'Subscribers', 'wp-user-frontend' ); $head['recurring'] = __( 'Recurring', 'wp-user-frontend' ); $head['duration'] = __( 'Duration', 'wp-user-frontend' ); return $head; } /** * Susbcription lists column content * * @param string $column_name * @param int $post_ID * * @return void */ public function subscription_columns_content( $column_name, $post_ID ) { switch ( $column_name ) { case 'amount': $amount = get_post_meta( $post_ID, '_billing_amount', true ); if ( intval( $amount ) == 0 ) { $amount = __( 'Free', 'wp-user-frontend' ); } else { $amount = wpuf_format_price( $amount ); } echo esc_html( $amount ); break; case 'subscribers': $users = WPUF_Subscription::init()->subscription_pack_users( $post_ID ); echo wp_kses_post( '' . count( $users ) . '' ); break; case 'recurring': $recurring = get_post_meta( $post_ID, '_recurring_pay', true ); if ( $recurring == 'yes' ) { esc_html_e( 'Yes', 'wp-user-frontend' ); } else { esc_html_e( 'No', 'wp-user-frontend' ); } break; case 'duration': $recurring_pay = get_post_meta( $post_ID, '_recurring_pay', true ); $billing_cycle_number = get_post_meta( $post_ID, '_billing_cycle_number', true ); $cycle_period = get_post_meta( $post_ID, '_cycle_period', true ); if ( $recurring_pay == 'yes' ) { echo esc_attr( $billing_cycle_number . ' ' . $cycle_period ) . '\'s (cycle)'; } else { $expiration_number = get_post_meta( $post_ID, '_expiration_number', true ); $expiration_period = get_post_meta( $post_ID, '_expiration_period', true ); echo esc_attr( $expiration_number . ' ' . $expiration_period ) . '\'s'; } break; } } public function get_post_types( $post_types = null ) { if ( !$post_types ) { $post_types = WPUF_Subscription::init()->get_all_post_type(); } ob_start(); foreach ( $post_types as $key => $name ) { $post_type_object = get_post_type_object( $key ); if ( $post_type_object ) { ?>
-1 for unlimited.', esc_html( $key ) ); ?>
post_content, 'post_content', ['editor_height' => 100, 'quicktags' => false, 'media_buttons' => false] ); } /** * Subscription settings metabox * * @return void */ public function subs_meta_box() { global $post; $sub_meta = WPUF_Subscription::init()->get_subscription_meta( $post->ID, $post ); $hidden_recurring_class = ( $sub_meta['recurring_pay'] != 'yes' ) ? 'none' : ''; $hidden_trial_class = ( $sub_meta['trial_status'] != 'yes' ) ? 'none' : ''; $hidden_expire = ( $sub_meta['recurring_pay'] == 'yes' ) ? 'none' : ''; $is_post_exp_selected = isset( $sub_meta['_enable_post_expiration'] ) && $sub_meta['_enable_post_expiration'] == 'on' ? 'checked' : ''; $_post_expiration_time = explode( ' ', isset( $sub_meta['_post_expiration_time'] ) ? $sub_meta['_post_expiration_time'] : ' ' ); $time_value = isset( $_post_expiration_time[0] ) ? $_post_expiration_time[0] : 1; $time_type = isset( $_post_expiration_time[1] ) ? $_post_expiration_time[1] : 'day'; $expired_post_status = isset( $sub_meta['_expired_post_status'] ) ? $sub_meta['_expired_post_status'] : ''; $is_enable_mail_after_expired = isset( $sub_meta['_enable_mail_after_expired'] ) && $sub_meta['_enable_mail_after_expired'] == 'on' ? 'checked' : ''; $post_expiration_message = isset( $sub_meta['_post_expiration_message'] ) ? $sub_meta['_post_expiration_message'] : ''; ?>
get_post_types( $sub_meta['post_type_name'] ), [ 'div' => [], 'tr' => [], 'td' => [], 'th' => [], 'label' => [ 'for' => [] ], 'input' => [ 'type' => [], 'size' => [], 'style' => [], 'id' => [], 'value' => [], 'name' => [] ], 'span' => [ 'class' => [] ], 'strong' => [] ] ); ?> 100, 'month' => 12, 'day' => 30, ]; ?>

post_type != 'wpuf_subscription' ) { return; } wp_enqueue_script( 'wpuf-metabox-tabs', WPUF_ASSET_URI . '/js/metabox-tabs.js', [ 'jquery' ] ); } /** * Enqueue script for profile * * @return void */ public function enqueue_profile_script() { $screen = get_current_screen(); if ( 'profile' != $screen->base ) { return; } wp_enqueue_script( 'wpuf-admin-profile-subs', WPUF_ASSET_URI . '/js/admin-profile-subs.js', [ 'jquery' ] ); } /** * Option fields for date type * * @param string $selected * * @return void */ public function option_field( $selected ) { ?> $pack ) { $recurring = isset( $pack->meta_value['recurring_pay'] ) ? $pack->meta_value['recurring_pay'] : ''; if ( $recurring == 'yes' ) { continue; } ?> subscription()->current_pack_id() ) { // return; } $userdata = get_userdata( $profileuser->ID ); //wp 3.3 fix $packs = WPUF_Subscription::init()->get_subscriptions(); $user_sub = WPUF_Subscription::get_user_pack( $userdata->ID ); $pack_id = isset( $user_sub['pack_id'] ) ? $user_sub['pack_id'] : ''; ?>

get_details_meta_value(); $billing_amount = ( isset( $pack->meta_value['billing_amount'] ) && intval( $pack->meta_value['billing_amount'] ) > 0 ) ? $details_meta['symbol'] . $pack->meta_value['billing_amount'] : __( 'Free', 'wp-user-frontend' ); $recurring_pay = ( isset( $pack->meta_value['recurring_pay'] ) && $pack->meta_value['recurring_pay'] == 'yes' ) ? true : false; if ( $billing_amount && $recurring_pay ) { $recurring_des = sprintf( __( 'For each %s %s', 'wp-user-frontend' ), $pack->meta_value['billing_cycle_number'], $pack->meta_value['cycle_period'], $pack->meta_value['trial_duration_type'] ); $recurring_des .= !empty( $pack->meta_value['billing_limit'] ) ? sprintf( __( ', for %s installments', 'wp-user-frontend' ), $pack->meta_value['billing_limit'] ) : ''; $recurring_des = $recurring_des; } else { $recurring_des = ''; } ?>
post_title ) ? esc_html( $pack->post_title ) : ''; ?>

$value ) { $post_type_object = get_post_type_object( $key ); if ( $post_type_object ) { ?>

100, 'month' => 12, 'day' => 30, ]; ?>
>

true, ], 'objects' ); foreach ( $builtin_taxs as $builtin_tax ) { if ( is_taxonomy_hierarchical( $builtin_tax->name ) ) { $tax_terms = get_terms( [ 'taxonomy' => $builtin_tax->name, 'hide_empty' => false, ] ); foreach ( $tax_terms as $tax_term ) { if ( in_array( $tax_term->term_id, $allowed_tax_id_arr ) ) { ?> false], 'objects' ); foreach ( $custom_taxs as $custom_tax ) { if ( is_taxonomy_hierarchical( $custom_tax->name ) ) { $tax_terms = get_terms( [ 'taxonomy' => $custom_tax->name, 'hide_empty' => false, ] ); foreach ( $tax_terms as $tax_term ) { if ( in_array( $tax_term->term_id, $allowed_tax_id_arr ) ) { ?>
name ); ?> name ); ?>
ID, 'wpuf-subscription-nonce' ); do_action( 'wpuf_admin_subscription_content', $userdata->ID ); ?>
recurring_change_status( $userid, 'Cancel' ); if ( isset( $_POST['packid'] ) ) { $pack_id = intval( wp_unslash( $_POST['packid'] ) ); WPUF_Subscription::subscriber_cancel( $userid, $pack_id ); } exit; } /** * Add help link to the subscriptions listing page * * @return void */ public function add_help_link() { $screen = get_current_screen(); if ( 'edit-wpuf_subscription' != $screen->id ) { return; } ?>