console.log('Repute log Test after setup'); "; return $return_script; }*/ function arm_renew_update_plan_action_func() { global $ARMember; $arm_capabilities = ''; $ARMember->arm_check_user_cap($arm_capabilities, '0'); $plan_id = intval($_POST['plan_id']); $setup_id = intval($_POST['setup_id']); if(is_user_logged_in()) { echo do_shortcode('[arm_setup_internal id="' . $setup_id . '" hide_plans="1" subscription_plan="' . $plan_id . '"]'); } else { global $arm_member_forms, $ARMember; $default_login_form_id = $arm_member_forms->arm_get_default_form_id('login'); echo do_shortcode("[arm_form id='$default_login_form_id' is_referer='1']"); $ARMember->enqueue_angular_script(true); } die; } function arm_cancel_bank_transfer_subscription($user_id, $plan_id) { global $wpdb, $ARMember, $arm_global_settings, $arm_subscription_plans, $arm_transaction, $arm_payment_gateways, $arm_manage_communication; if (!empty($user_id) && $user_id != 0 && !empty($plan_id) && $plan_id != 0) { $defaultPlanData = $arm_subscription_plans->arm_default_plan_array(); $userPlanDatameta = get_user_meta($user_id, 'arm_user_plan_' . $plan_id, true); $userPlanDatameta = !empty($userPlanDatameta) ? $userPlanDatameta : array(); $planData = shortcode_atts($defaultPlanData, $userPlanDatameta); $user_payment_gateway = $planData['arm_user_gateway']; $user_detail = get_userdata($user_id); $payer_email = $user_detail->user_email; if (in_array(strtolower($user_payment_gateway), array('bank_transfer', 'manual'))) { $arm_manage_communication->arm_user_plan_status_action_mail(array('plan_id' => $plan_id, 'user_id' => $user_id, 'action' => 'on_cancel_subscription')); } } } function arm_membership_setup_preview_func() { global $wpdb, $ARMember; if (isset($_REQUEST['arm_setup_preview']) && $_REQUEST['arm_setup_preview'] == '1') { if (file_exists(MEMBERSHIPLITE_VIEWS_DIR . '/arm_membership_setup_preview.php')) { include(MEMBERSHIPLITE_VIEWS_DIR . '/arm_membership_setup_preview.php'); } exit; } } function arm_membership_setup_form_ajax_action($setup_id = 0, $post_data = array()) { global $wp, $wpdb, $current_user, $arm_slugs, $arm_errors, $ARMember, $arm_member_forms, $arm_global_settings, $arm_payment_gateways,$arm_subscription_plans, $payment_done,$arm_manage_communication, $arm_transaction; $post_data = (!empty($_POST)) ? $_POST : $post_data; $setup_id = (!empty($post_data['setup_id']) && $post_data['setup_id'] != 0) ? intval($post_data['setup_id']) : $setup_id; $err_msg = $arm_global_settings->common_message['arm_general_msg']; $err_msg = (!empty($err_msg)) ? $err_msg : __('Sorry, Something went wrong. Please try again.', 'ARMember'); $response = array('status' => 'error', 'type' => 'message', 'message' => $err_msg); $validate = true; $validate_msgs = array(); if (!empty($setup_id) && $setup_id != 0 && !empty($post_data) && $post_data['setup_action'] == 'membership_setup') { do_action('arm_before_setup_form_action', $setup_id, $post_data); /* Unset unused variables. */ unset($post_data['ARMSETUPNEXT']); unset($post_data['ARMSETUPSUBMIT']); unset($post_data['setup_action']); $setup_data = $this->arm_get_membership_setup($setup_id); if (!empty($setup_data) && !empty($setup_data['setup_modules']['modules'])) { $form_slug = isset($post_data['arm_action']) ? sanitize_text_field($post_data['arm_action']) : ''; $form = new ARM_Form('slug', $form_slug); $form_id = 0; $plan_id = isset($post_data['subscription_plan']) ? intval($post_data['subscription_plan']) : 0; if ($plan_id == 0) { $plan_id = isset($post_data['_subscription_plan']) ? intval($post_data['_subscription_plan']) : 0; } $plan = new ARM_Plan($plan_id); $plan_type = $plan->type; $payment_gateway = isset($post_data['payment_gateway']) ? sanitize_text_field($post_data['payment_gateway']) : ''; if ($payment_gateway == '') { $payment_gateway = isset($post_data['_payment_gateway']) ? sanitize_text_field($post_data['_payment_gateway']) : ''; } if($plan->is_recurring()){ $payment_mode_ = !empty($post_data['arm_selected_payment_mode']) ? sanitize_text_field($post_data['arm_selected_payment_mode']) : 'manual_subscription'; if(isset($post_data['arm_payment_mode'][$payment_gateway])){ $payment_mode_ = !empty($post_data['arm_payment_mode'][$payment_gateway]) ? sanitize_text_field($post_data['arm_payment_mode'][$payment_gateway]) : 'manual_subscription'; } else{ $setup_data = $this->arm_get_membership_setup($setup_id); if (!empty($setup_data) && !empty($setup_data['setup_modules']['modules'])) { $setup_modules = $setup_data['setup_modules']; $modules = $setup_modules['modules']; $payment_mode_ = $modules['payment_mode'][$payment_gateway]; } } $payment_mode = 'manual_subscription'; if ($payment_mode_ == 'both') { $payment_mode = !empty($post_data['arm_selected_payment_mode']) ? sanitize_text_field($post_data['arm_selected_payment_mode']) : 'manual_subscription'; } else { $payment_mode = $payment_mode_; } } else{ $payment_mode = ''; } if ($payment_gateway == 'bank_transfer' && $plan->is_recurring()) { $payment_mode = 'manual_subscription'; } $post_data['arm_selected_payment_mode'] = $payment_mode; $payment_cycle = 0; if ($plan->is_recurring()) { $payment_cycle = isset($post_data['payment_cycle_' . $plan_id]) ? intval($post_data['payment_cycle_' . $plan_id]) : 0; } $post_data['arm_selected_payment_cycle'] = $payment_cycle; $user_info = wp_get_current_user(); $current_user_plan = array(); $user_id = $user_info->ID; if (!empty($user_info->ID)) { $entry_email = $user_info->user_email; $current_user_plan = get_user_meta($user_id, 'arm_user_plan_ids', true); $current_user_plan = !empty($current_user_plan) ? $current_user_plan : array(); } else { $entry_email = sanitize_email($post_data['user_email']); } $setup_redirect = ARMLITE_HOME_URL; $redirection_settings = get_option('arm_redirection_settings'); $redirection_settings = maybe_unserialize($redirection_settings); $arm_default_setup_url = (isset($redirection_settings['setup']['default']) && !empty($redirection_settings['setup']['default'])) ? $redirection_settings['setup']['default'] : ARMLITE_HOME_URL; if (is_user_logged_in()) { // IF same plan already exists in arm_user_plan_ids if (in_array($plan_id, $current_user_plan)) { //renew or recurring $PlanData = get_user_meta($user_id, 'arm_user_plan_' . $plan_id, true); if (!empty($PlanData)) { $PlanDetail = isset($PlanData['arm_current_plan_detail']) ? $PlanData['arm_current_plan_detail'] : array(); if (!empty($PlanData)) { $same_old_plan = new ARM_Plan(0); $same_old_plan->init((object) $PlanDetail); } else { $same_old_plan = new ARM_Plan($plan_id); } if ($same_old_plan->is_recurring()) { $oldPaymentMode = $PlanData['arm_payment_mode']; if ($oldPaymentMode == 'manual_subscription') { $oldPaymentCycle = $PlanData['arm_payment_cycle']; $completed_recurrence = $PlanData['arm_completed_recurring']; $same_plan_data = $same_old_plan->prepare_recurring_data($oldPaymentCycle); $oldPlanTotalRecurring = $same_plan_data['rec_time']; if ($oldPlanTotalRecurring == 'infinite' || ($completed_recurrence !== '' && $completed_recurrence < $oldPlanTotalRecurring)) { $payment_cycle = $oldPaymentCycle; $post_data['arm_selected_payment_cycle'] = $oldPaymentCycle; $payment_mode = $oldPaymentMode; $post_data['arm_selected_payment_mode'] = $oldPaymentMode; $plan = $same_old_plan; } } } } $arm_redirection_setup_change_type = (isset($redirection_settings['setup_renew']['type']) && !empty($redirection_settings['setup_renew']['type'])) ? $redirection_settings['setup_renew']['type'] : 'page'; if($arm_redirection_setup_change_type == 'page'){ $arm_redirection_setup_signup_page_id = (isset($redirection_settings['setup_renew']['page_id']) && !empty($redirection_settings['setup_renew']['page_id'])) ? $redirection_settings['setup_renew']['page_id'] : 0; if(!empty($arm_redirection_setup_signup_page_id)){ $setup_redirect = $arm_global_settings->arm_get_permalink('', $arm_redirection_setup_signup_page_id); } else{ $setup_redirect = $arm_default_setup_url; } } else if($arm_redirection_setup_change_type == 'url'){ $setup_redirect = (isset($redirection_settings['setup_renew']['url']) && !empty($redirection_settings['setup_renew']['url'])) ? $redirection_settings['setup_renew']['url'] : $arm_default_setup_url; } } else{ //change $arm_redirection_setup_change_type = (isset($redirection_settings['setup_change']['type']) && !empty($redirection_settings['setup_change']['type'])) ? $redirection_settings['setup_change']['type'] : 'page'; if($arm_redirection_setup_change_type == 'page'){ $arm_redirection_setup_signup_page_id = (isset($redirection_settings['setup_change']['page_id']) && !empty($redirection_settings['setup_change']['page_id'])) ? $redirection_settings['setup_change']['page_id'] : 0; if(!empty($arm_redirection_setup_signup_page_id)){ $setup_redirect = $arm_global_settings->arm_get_permalink('', $arm_redirection_setup_signup_page_id); } else{ $setup_redirect = $arm_default_setup_url; } } else if($arm_redirection_setup_change_type == 'url'){ $setup_redirect = (isset($redirection_settings['setup_change']['url']) && !empty($redirection_settings['setup_change']['url'])) ? $redirection_settings['setup_change']['url'] : $arm_default_setup_url; } } } else{ $arm_redirection_setup_signup_type = (isset($redirection_settings['setup_signup']['type']) && !empty($redirection_settings['setup_signup']['type'])) ? $redirection_settings['setup_signup']['type'] : 'page'; if($arm_redirection_setup_signup_type == 'page'){ $arm_redirection_setup_signup_page_id = (isset($redirection_settings['setup_signup']['page_id']) && !empty($redirection_settings['setup_signup']['page_id'])) ? $redirection_settings['setup_signup']['page_id'] : 0; if(!empty($arm_redirection_setup_signup_page_id)){ $setup_redirect = $arm_global_settings->arm_get_permalink('', $arm_redirection_setup_signup_page_id); } else{ $setup_redirect = $arm_default_setup_url; } } else if($arm_redirection_setup_signup_type == 'url'){ $setup_redirect = (isset($redirection_settings['setup_signup']['url']) && !empty($redirection_settings['setup_signup']['url'])) ? $redirection_settings['setup_signup']['url'] : $arm_default_setup_url; } } if ($plan->is_recurring()) { $planData = $plan->prepare_recurring_data($payment_cycle); $amount = !empty($planData['amount']) ? $planData['amount'] : 0; } else { $amount = !empty($plan->amount) ? $plan->amount : 0; } $amount = str_replace(',', '', $amount); $planOptions = $plan->options; if ($plan_type == 'paid_finite') { $plan_expiry_type = (isset($planOptions['expiry_type']) && $planOptions['expiry_type'] != '') ? $planOptions['expiry_type'] : 'joined_date_expiry'; $plan_expiry_date = (isset($planOptions['expiry_date']) && $planOptions['expiry_date'] != '') ? $planOptions['expiry_date'] : date('Y-m-d 23:59:59'); } $now = current_time('timestamp'); $setup_name = $setup_data['setup_name']; $modules = $setup_data['setup_modules']['modules']; $module_order = array( 'plans' => 1, 'forms' => 2, 'gateways' => 3, ); $all_payment_gateways = $arm_payment_gateways->arm_get_active_payment_gateways(); /* ====================/.Begin Module section validation./==================== */ foreach ($module_order as $module => $order) { if (!empty($modules[$module])) { if ($module == 'forms' && !empty($form_slug)) { $form_id = $form->ID; $arm_form_fields = $form->fields; $field_options = array(); foreach ($arm_form_fields as $fields) { if ($fields['arm_form_field_slug'] == 'user_login') { $field_options = $fields['arm_form_field_option']; if (isset($field_options['hide_username']) && $field_options['hide_username'] == 1) { $post_data['user_login'] = sanitize_email($post_data['user_email']); } } } $all_errors = $arm_member_forms->arm_member_validate_meta_details($form, $post_data); if ($all_errors !== TRUE) { $validate = false; $validate_msgs += $all_errors; } } if ($module == 'plans') { if ($plan->exists() && $plan->is_active()) { if ($plan->is_paid() && empty($payment_gateway)) { if ($plan->is_recurring() && $plan->has_trial_period() && $payment_mode == 'manual_subscription' && $planOptions['trial']['amount'] < 1) { } else { $validate = false; $err_msg = $arm_global_settings->common_message['arm_no_select_payment_geteway']; $validate_msgs['subscription_plan'] = (!empty($err_msg)) ? $err_msg : __('Your selected plan is paid, please select payment method.', 'ARMember'); } } if ($plan_type == 'paid_finite' && $plan_expiry_type == 'fixed_date_expiry') { if (strtotime($plan_expiry_date) <= $now) { $validate = false; $err_msg = $arm_global_settings->common_message['arm_invalid_plan_select']; $validate_msgs['subscription_plan'] = (!empty($err_msg)) ? $err_msg : __('Selected plan is not valid.', 'ARMember'); } } } else { $validate = false; $err_msg = $arm_global_settings->common_message['arm_invalid_plan_select']; $validate_msgs['subscription_plan'] = (!empty($err_msg)) ? $err_msg : __('Selected plan is not valid.', 'ARMember'); } } if ($module == 'gateways' && $plan->is_paid() && !empty($payment_gateway)) { $gateway_options = $all_payment_gateways[$payment_gateway]; $payment_mode_bt = ""; if ($plan->is_recurring()) { $payment_mode_bt = 'manual_subscription'; } else { $payment_mode_bt = 'auto_debit_subscription'; } if ($payment_gateway == 'bank_transfer' && $payment_mode_bt == '') { $validate = false; $validate_msgs['bank_transfer'] = __('Selected plan is not valid for bank transfer.', 'ARMember'); } else { $pgHasCCFields = apply_filters('arm_payment_gateway_has_ccfields', false, $payment_gateway, $gateway_options); if ($pgHasCCFields) { $cc_error = array(); if (empty($post_data[$payment_gateway]['card_number'])) { $err_msg = $arm_global_settings->common_message['arm_blank_credit_card_number']; } if (empty($post_data[$payment_gateway]['exp_month'])) { $err_msg = $arm_global_settings->common_message['arm_blank_expire_month']; } if (empty($post_data[$payment_gateway]['exp_year'])) { $err_msg = $arm_global_settings->common_message['arm_blank_expire_year']; } if (empty($post_data[$payment_gateway]['cvc'])) { $err_msg = $arm_global_settings->common_message['arm_blank_cvc_number']; } if (!empty($cc_error)) { $validate = false; $validate_msgs['card_number'] = implode('
', $cc_error); } } $pg_errors = apply_filters('arm_validate_payment_gateway_fields', true, $post_data, $payment_gateway, $gateway_options); if ($pg_errors !== true) { $validate = false; $validate_msgs[$payment_gateway] = $pg_errors; } } } } } /* ====================/.End Module section validation./==================== */ if ($validate && empty($validate_msgs)) { do_action('arm_after_setup_form_validate_action', $setup_id, $post_data); $entry_id = 0; $ip_address = $ARMember->arm_get_ip_address(); $description = maybe_serialize(array('browser' => $_SERVER['HTTP_USER_AGENT'], 'http_referrer' => @$_SERVER['HTTP_REFERER'])); $entry_post_data = $post_data; if (is_user_logged_in()) { $user_information = wp_get_current_user(); $user_id_info = $user_information->ID; $username_info = $user_information->user_login; $setup_redirect = str_replace('{ARMCURRENTUSERNAME}', $username_info, $setup_redirect); $setup_redirect = str_replace('{ARMCURRENTUSERID}', $user_id_info, $setup_redirect); } $entry_post_data['setup_redirect'] = $setup_redirect; foreach ($all_payment_gateways as $k => $data) { if (isset($entry_post_data[$k]) && isset($entry_post_data[$k]['card_number'])) { $cc_no = $entry_post_data[$k]['card_number']; unset($entry_post_data[$k]); if (!empty($cc_no)) { $entry_post_data[$k]['card_number'] = $arm_transaction->arm_mask_credit_card_number($cc_no); } } } $entry_post_data = apply_filters('arm_add_arm_entries_value', $entry_post_data); $new_entry = array( 'arm_entry_email' => $entry_email, 'arm_name' => $setup_name, 'arm_description' => $description, 'arm_ip_address' => $ip_address, 'arm_browser_info' => $_SERVER['HTTP_USER_AGENT'], 'arm_entry_value' => maybe_serialize($entry_post_data), 'arm_form_id' => $form_id, 'arm_user_id' => $user_id, 'arm_plan_id' => $plan_id, 'arm_created_date' => date('Y-m-d H:i:s') ); $new_entry_results = $wpdb->insert($ARMember->tbl_arm_entries, $new_entry); $entry_id = $wpdb->insert_id; if (!empty($entry_id) && $entry_id != 0) { $post_data['arm_entry_id'] = $entry_id; $payment_gateway_options = isset($all_payment_gateways[$payment_gateway]) ? $all_payment_gateways[$payment_gateway] : array(); if (is_user_logged_in()) { if (!empty($modules['plans'])) { $defaultPlanData = $arm_subscription_plans->arm_default_plan_array(); $userPlanDatameta = get_user_meta($user_id, 'arm_user_plan_' . $plan_id, true); $userPlanDatameta = !empty($userPlanDatameta) ? $userPlanDatameta : array(); $userPlanData = shortcode_atts($defaultPlanData, $userPlanDatameta); $post_data['old_plan_id'] = (isset($current_user_plan) && !empty($current_user_plan)) ? implode(",", $current_user_plan) : 0; $old_plan_id = isset($current_user_plan[0]) ? $current_user_plan[0] : 0; $oldPlanData = get_user_meta($user_id, 'arm_user_plan_' . $old_plan_id, true); $oldPlanData = !empty($oldPlanData) ? $oldPlanData : array(); $oldPlanData = shortcode_atts($defaultPlanData, $oldPlanData); $oldPlanDetail = isset($oldPlanData['arm_current_plan_detail']) ? $oldPlanData['arm_current_plan_detail'] : array(); if (!empty($oldPlanDetail)) { $old_plan = new ARM_Plan(0); $old_plan->init((object) $oldPlanDetail); } else { $old_plan = new ARM_Plan($old_plan_id); } $is_update_plan = true; $now = current_time('mysql'); $arm_last_payment_status = $wpdb->get_var($wpdb->prepare("SELECT `arm_transaction_status` FROM `" . $ARMember->tbl_arm_payment_log . "` WHERE `arm_user_id`=%d AND `arm_plan_id`=%d AND `arm_created_date`<=%s ORDER BY `arm_log_id` DESC LIMIT 0,1", $user_id, $plan_id, $now)); /* If plan is being renewd */ if (in_array($plan_id, $current_user_plan)) { /* if plan is recurring and old payment mode is auto debit, then if payment is done using 2checkout, old plan need to be canceled and plan renew date will be today date * In other payment gateway, plan renew date will be old ecpiry date */ if ($old_plan->is_recurring()) { if ($payment_mode == 'auto_debit_subscription') { $need_to_cancel_payment_gateway_array = $arm_payment_gateways->arm_need_to_cancel_old_subscription_gateways(); $need_to_cancel_payment_gateway_array = !empty($need_to_cancel_payment_gateway_array) ? $need_to_cancel_payment_gateway_array : array(); if (in_array($payment_gateway, $need_to_cancel_payment_gateway_array)) { do_action('arm_cancel_subscription_gateway_action', $user_id, $plan_id); } } } } else { /* if plan is being changed. */ /* check if upgrade downgrade action is applied * if it is immmediately then, cancel old subscription if plan is recurring immediately */ if ($old_plan->exists()) { if ($old_plan->is_lifetime() || $old_plan->is_free() || ($old_plan->is_recurring() && $plan->is_recurring())) { $is_update_plan = true; } else { $change_act = 'immediate'; if ($old_plan->enable_upgrade_downgrade_action == 1) { if (!empty($old_plan->downgrade_plans) && in_array($plan->ID, $old_plan->downgrade_plans)) { $change_act = $old_plan->downgrade_action; } if (!empty($old_plan->upgrade_plans) && in_array($plan->ID, $old_plan->upgrade_plans)) { $change_act = $old_plan->upgrade_action; } } $subscr_effective = $oldPlanData['arm_expire_plan']; if ($change_act == 'on_expire' && !empty($subscr_effective)) { $is_update_plan = false; $oldPlanData['arm_subscr_effective'] = $subscr_effective; $oldPlanData['arm_change_plan_to'] = $plan_id; update_user_meta($user_id, 'arm_user_plan_' . $old_plan_id, $oldPlanData); } } if ($is_update_plan && $old_plan->is_recurring()) { do_action('arm_cancel_subscription_gateway_action', $user_id, $old_plan_id); } } } if (!$plan->is_free()) { if (!empty($payment_gateway_options)) { if ($payment_gateway == 'bank_transfer') { $payment_mode_bt = ''; if ($plan->is_recurring()) { $payment_mode_bt = "manual_subscription"; } $arm_user_old_plan_details = (isset($userPlanData['arm_current_plan_detail']) && !empty($userPlanData['arm_current_plan_detail'])) ? $userPlanData['arm_current_plan_detail'] : array(); $arm_user_old_plan_details['arm_user_old_payment_mode'] = $userPlanData['arm_payment_mode']; $userPlanData['arm_current_plan_detail'] = $arm_user_old_plan_details; update_user_meta($user_id, 'arm_user_plan_' . $plan_id, $userPlanData); update_user_meta($user_id, 'arm_entry_id', $entry_id); if (!$plan->is_recurring() || $payment_mode_bt == 'manual_subscription') { $arm_payment_gateways->arm_bank_transfer_payment_gateway_action($payment_gateway, $payment_gateway_options, $post_data, $entry_id); global $payment_done; $response['status'] = 'success'; $response['type'] = 'redirect'; $response['message'] = ''; } else { $validate_msgs['payment_failed'] = __('Selected plan is not valid for bank transfer.', 'ARMember'); } } else { $post_data = apply_filters('arm_change_posted_data_before_payment_outside', $post_data, $payment_gateway, $payment_gateway_options, $entry_id); do_action('arm_payment_gateway_validation_from_setup', $payment_gateway, $payment_gateway_options, $post_data, $entry_id); global $payment_done; if (isset($payment_done['status']) && $payment_done['status'] === FALSE) { $validate_msgs['payment_failed'] = $payment_done['error']; } else { $pgs_arrays = apply_filters('arm_update_new_subscr_gateway_outside', array()); $log_id = $payment_done['log_id']; $log_detail = $wpdb->get_row("SELECT `arm_log_id`, `arm_user_id`, `arm_token`, `arm_transaction_id`, `arm_extra_vars` FROM `" . $ARMember->tbl_arm_payment_log . "` WHERE `arm_log_id`='$log_id'"); update_user_meta($user_id, 'arm_entry_id', $entry_id); $userPlanData['arm_user_gateway'] = $payment_gateway; $arm_user_old_plan_details = (isset($userPlanData['arm_current_plan_detail']) && !empty($userPlanData['arm_current_plan_detail'])) ? $userPlanData['arm_current_plan_detail'] : array(); $arm_user_old_plan_details['arm_user_old_payment_mode'] = $userPlanData['arm_payment_mode']; $userPlanData['arm_current_plan_detail'] = $arm_user_old_plan_details; if ($plan->is_recurring()) { $userPlanData['arm_payment_mode'] = $payment_mode; $userPlanData['arm_payment_cycle'] = $payment_cycle; } else { $userPlanData['arm_payment_mode'] = ''; $userPlanData['arm_payment_cycle'] = ''; } update_user_meta($user_id, 'arm_user_plan_' . $plan_id, $userPlanData); do_action('arm_update_user_meta_after_renew_outside', $user_id, $log_detail, $plan_id, $payment_gateway); if ($is_update_plan) { $arm_subscription_plans->arm_update_user_subscription($user_id, $plan_id, '', true, $arm_last_payment_status); } else { $arm_subscription_plans->arm_add_membership_history($user_id, $plan_id, 'change_subscription'); } $response['status'] = 'success'; $response['type'] = 'redirect'; $response['message'] = ''; } } } else { $err_msg = $arm_global_settings->common_message['arm_inactive_payment_gateway']; $validate_msgs['payment_gateway'] = (!empty($err_msg)) ? $err_msg : __('Payment gateway is not active, please contact site administrator.', 'ARMember'); $payment_done = array('status' => FALSE); } } else { if ($is_update_plan) { $arm_subscription_plans->arm_update_user_subscription($user_id, $plan_id); } else { $arm_subscription_plans->arm_add_membership_history($user_id, $plan_id, 'change_subscription'); } $response['status'] = 'success'; $response['type'] = 'redirect'; $response['message'] = ''; } } } else { if (!empty($modules['plans']) && $plan->is_paid()) { if (!empty($payment_gateway_options)) { if ($payment_gateway == 'bank_transfer') { $payment_mode_bt = "manual_subscription"; if ($plan->is_recurring()) { $payment_mode_bt = "manual_subscription"; } if (!$plan->is_recurring() || $payment_mode == 'manual_subscription') { $arm_payment_gateways->arm_bank_transfer_payment_gateway_action($payment_gateway, $payment_gateway_options, $post_data, $entry_id); global $payment_done; $payment_log_id = ''; if($payment_done['status']==1) { $payment_log_id = $payment_done['log_id']; } $response['status'] = 'success'; $response['type'] = 'redirect'; $response['message'] = ''; } else { $validate_msgs['payment_failed'] = __('Selected plan is not valid for bank transfer.', 'ARMember'); } } else { $post_data = apply_filters('arm_change_posted_data_before_payment_outside', $post_data, $payment_gateway, $payment_gateway_options, $entry_id); do_action('arm_payment_gateway_validation_from_setup', $payment_gateway, $payment_gateway_options, $post_data, $entry_id); global $payment_done; if (isset($payment_done['status']) && $payment_done['status'] === FALSE) { $validate_msgs['payment_failed'] = $payment_done['error']; } } } else { if ($plan->is_recurring() && $plan->has_trial_period() && $payment_mode == 'manual_subscription' && $planOptions['trial']['amount'] == 0) { $payment_data = array( 'arm_user_id' => '0', 'arm_plan_id' => (!empty($plan_id) ? $plan_id : 0), 'arm_payment_gateway' => 'paypal', 'arm_payment_type' => $plan->payment_type, 'arm_token' => '-', 'arm_payer_email' => (isset($post_data['user_email'])) ? sanitize_email($post_data['user_email']) : '', 'arm_receiver_email' => '', 'arm_transaction_id' => '-', 'arm_transaction_payment_type' => $plan->payment_type, 'arm_transaction_status' => 'completed', 'arm_payment_mode' => $payment_mode, 'arm_payment_date' => date('Y-m-d H:i:s'), 'arm_amount' => 0, 'arm_currency' => 'USD', 'arm_response_text' => '', 'arm_extra_vars' => '', 'arm_created_date' => current_time('mysql') ); $payment_log_id = $arm_payment_gateways->arm_save_payment_log($payment_data); $payment_done = array('status' => TRUE, 'log_id' => $payment_log_id, 'entry_id' => $entry_id); } else { $err_msg = $arm_global_settings->common_message['arm_inactive_payment_gateway']; $validate_msgs['payment_gateway'] = (!empty($err_msg)) ? $err_msg : __('Payment gateway is not active, please contact site administrator.', 'ARMember'); $payment_done = array('status' => FALSE); } } } else { $payment_done = array('status' => TRUE); } if (!empty($modules['forms']) && $payment_done['status'] == TRUE) { if (in_array($form->type, array('registration'))) { $post_data['arm_update_user_from_profile'] = 0; $user_id = $arm_member_forms->arm_register_new_member($post_data, $form); if (is_numeric($user_id) && !is_array($user_id)) { if(!empty($payment_log_id)) { $armLogTable = $ARMember->tbl_arm_bank_transfer_log; $chk_log_detail = $wpdb->get_row("SELECT `arm_log_id`, `arm_amount` FROM `{$armLogTable}` WHERE `arm_log_id`='{$payment_log_id}'"); if (!empty($chk_log_detail)) { $user_register_verification = isset($arm_global_settings->global_settings['user_register_verification']) ? $arm_global_settings->global_settings['user_register_verification'] : 'auto'; if($chk_log_detail->arm_amount==0 && $user_register_verification == 'auto') { $arm_transaction->arm_change_bank_transfer_status($payment_log_id, '1'); } } } $response['status'] = 'success'; $response['type'] = 'redirect'; $user_info = get_userdata($user_id); $username = $user_info->user_login; $setup_redirect = str_replace('{ARMCURRENTUSERNAME}', $username, $setup_redirect); $setup_redirect = str_replace('{ARMCURRENTUSERID}', $user_id, $setup_redirect); $response['message'] = ''; } else { $validate_msgs['register_error'] = $arm_errors->get_error_messages('arm_reg_error'); } } } } } else { $err_msg = $arm_global_settings->common_message['arm_general_msg']; $validate_msgs['entry_message'] = (!empty($err_msg)) ? $err_msg : __('Sorry, Something went wrong. Please contact to site administrator.', 'ARMember'); } } if (!empty($validate_msgs)) { $response['status'] = 'error'; $response['type'] = 'message'; $response['message'] = '
'; } else { $response['status'] = 'success'; if (isset($response['type']) && $response['type'] == 'redirect') { $response['message'] = $response['message']; } else { $response['type'] = 'message'; $response['message'] = '
'; } } } do_action('arm_after_setup_form_action', $setup_id, $post_data); } $arm_return_script = ''; $response['script'] = apply_filters('arm_after_setup_submit_sucess_outside',$arm_return_script); if ($post_data['action'] == 'arm_membership_setup_form_ajax_action') { echo json_encode($response); exit; } else { return $response; } } function arm_setup_shortcode_func($atts, $content = "") { global $wp, $wpdb, $current_user, $ARMember, $arm_member_forms, $arm_global_settings, $arm_payment_gateways, $arm_subscription_plans, $bpopup_loaded, $ARMSPAMFILEURL; /* ====================/.Begin Set Shortcode Attributes./==================== */ $defaults = array( 'id' => 0, /* Membership Setup Wizard ID */ 'hide_title' => false, 'class' => '', 'popup' => false, /* Form will be open in popup box when options is true */ 'link_type' => 'link', 'link_class' => '', /* /* Possible Options:- `link`, `button` */ 'link_title' => __('Click here to open Set up form', 'ARMember'), /* Default to form name */ 'popup_height' => '', 'popup_width' => '', 'overlay' => '0.6', 'modal_bgcolor' => '#000000', 'redirect_to' => '', 'link_css' => '', 'link_hover_css' => '', 'is_referer' => '0', 'preview' => false, 'setup_data' => '', 'subscription_plan' => 0, 'hide_plans' => 0, 'payment_duration' => 0, 'setup_form_id' => '', ); /* Extract Shortcode Attributes */ $args = shortcode_atts($defaults, $atts, 'arm_setup'); extract($args); $args['hide_title'] = ($args['hide_title'] === 'true' || $args['hide_title'] == '1') ? true : false; $args['popup'] = ($args['popup'] === 'true' || $args['popup'] == '1') ? true : false; $isPreview = ($args['preview'] === 'true' || $args['preview'] == '1') ? true : false; if ($args['popup']) { $bpopup_loaded = 1; } $completed_recurrence = ''; $total_recurring = ''; /* ====================/.End Set Shortcode Attributes./==================== */ if ((!empty($args['id']) && $args['id'] != 0) || ($isPreview && !empty($args['setup_data']))) { $setupID = $args['id']; if ($isPreview && !empty($args['setup_data'])) { $setup_data = maybe_unserialize($args['setup_data']); $setup_data['arm_setup_labels'] = $setup_data['setup_labels']; } else { $setup_data = $this->arm_get_membership_setup($setupID); } $setup_data = apply_filters('arm_setup_data_before_setup_shortcode', $setup_data, $args); do_action('arm_before_render_membership_setup_form', $setup_data, $args); if (!empty($setup_data) && !empty($setup_data['setup_modules']['modules'])) { $setupRandomID = $setupID . '_' . arm_generate_random_code(); $global_currency = $arm_payment_gateways->arm_get_global_currency(); $current_user_id = get_current_user_id(); $current_user_plan_ids = get_user_meta($current_user_id, 'arm_user_plan_ids', true); $current_user_plan_ids = !empty($current_user_plan_ids) ? $current_user_plan_ids : array(); $current_user_plan = ''; $current_plan_data = array(); if (!empty($current_user_plan_ids)) { $current_user_plan = $current_user_plan_ids[0]; $current_plan_data = get_user_meta($current_user_id, 'arm_user_plan_' . $current_user_plan, true); } $setup_name = (!empty($setup_data['setup_name'])) ? stripslashes($setup_data['setup_name']) : ''; $button_labels = $setup_data['setup_labels']['button_labels']; $submit_btn = (!empty($button_labels['submit'])) ? $button_labels['submit'] : __('Submit', 'ARMember'); $setup_modules = $setup_data['setup_modules']; $user_selected_plan = isset($setup_modules['selected_plan']) ? $setup_modules['selected_plan'] : ""; $modules = $setup_modules['modules']; $setup_style = isset($setup_modules['style']) ? $setup_modules['style'] : array(); $formPosition = (isset($setup_style['form_position']) && !empty($setup_style['form_position'])) ? $setup_style['form_position'] : 'left'; $plan_selection_area = (isset($setup_style['plan_area_position']) && !empty($setup_style['plan_area_position'])) ? $setup_style['plan_area_position'] : 'before'; $hide_current_plans = isset($setup_style['hide_current_plans']) ? $setup_style['hide_current_plans'] : 0; $previuos_button_label = (isset($button_labels['previous']) && !empty($button_labels['previous'])) ? $button_labels['previous'] : __('Previous', 'ARMember'); $next_button_label = (isset($button_labels['next']) && !empty($button_labels['next']) )? $button_labels['next'] : __('Next', 'ARMember'); $two_step = (isset($setup_style['two_step'])) ? $setup_style['two_step'] : 0; $fieldPosition = 'left'; $modules['step'] = (!empty($modules['step'])) ? $modules['step'] : array(-1); if ($plan_selection_area == 'before' || $two_step == 1) { $module_order = array( 'plans' => 1, 'payment_cycle' =>2, 'note' => 3, 'forms' => 4, 'gateways' => 5, 'order_detail' => 6, ); } else { $module_order = array( 'forms' => 1, 'plans' => 2, 'payment_cycle' => 3, 'note' => 4, 'gateways' => 5, 'order_detail' => 6, ); } $modules['forms'] = (!empty($modules['forms']) && $modules['forms'] != 0) ? $modules['forms'] : 0; $step_one_modules = $step_two_modules = ''; /* Check `GET` or `POST` Data */ /* first check if user have selected any plan than select that plan otherwise set value from options of setup */ if ($current_user_plan != '') { $selected_plan_id = $current_user_plan; } else { $selected_plan_id = $user_selected_plan; } if (!empty($_REQUEST['subscription_plan']) && $_REQUEST['subscription_plan'] != 0) { $selected_plan_id = intval($_REQUEST['subscription_plan']); } $selected_payment_duration = 1; if (!empty($_REQUEST['payment_duration']) && $_REQUEST['payment_duration'] != 0) { $selected_payment_duration = $_REQUEST['payment_duration']; } if (!empty($args['subscription_plan']) && $args['subscription_plan'] != 0) { $selected_plan_id = $args['subscription_plan']; if (!empty($args['payment_duration']) && $args['payment_duration'] != 0) { $selected_payment_duration = $args['payment_duration']; } } $isHidePlans = false; if (!empty($selected_plan_id) && $selected_plan_id != 0) { if (!empty($_REQUEST['hide_plans']) && $_REQUEST['hide_plans'] == 1) { $isHidePlans = true; } if (!empty($args['hide_plans']) && $args['hide_plans'] == 1) { $isHidePlans = true; } } $is_hide_plan_selection_area = false; if (isset($setup_style['hide_plans']) && $setup_style['hide_plans'] == 1) { $is_hide_plan_selection_area = true; } $arm_two_step_class = ''; if($two_step){ if ($isHidePlans == true || $is_hide_plan_selection_area == true) { } else{ $arm_two_step_class = ' arm_hide'; } } if (is_user_logged_in()) { global $current_user; if (!empty($current_user->data->arm_primary_status)) { $current_user_status = $current_user->data->arm_primary_status; } else { $current_user_status = arm_get_member_status($current_user_id); } } $selected_plan_data = array(); $module_html = $formStyle = $setupGoogleFonts = ''; $errPosCCField = 'right'; if (is_rtl()) { $is_form_class_rtl = 'arm_form_rtl'; } else { $is_form_class_rtl = 'arm_form_ltr'; } $form_style_class = ' arm_shortcode_form arm_form_0 arm_form_layout_writer armf_label_placeholder armf_alignment_left armf_layout_block armf_button_position_left ' . $is_form_class_rtl; $btn_style_class = ' arm_btn_style_flat '; if (!empty($modules['forms'])) { /* Query Monitor Change */ if( isset($GLOBALS['arm_setup_form_settings']) && isset($GLOBALS['arm_setup_form_settings'][$modules['forms']])){ $form_settings = $GLOBALS['arm_setup_form_settings'][$modules['forms']]; } else { $form_settings = $wpdb->get_var("SELECT `arm_form_settings` FROM `" . $ARMember->tbl_arm_forms . "` WHERE `arm_form_id`='" . $modules['forms'] . "'"); if( !isset($GLOBALS['arm_setup_form_settings']) ){ $GLOBALS['arm_setup_form_settings'] = array(); } $GLOBALS['arm_setup_form_settings'][$modules['forms']] = $form_settings; } $form_settings = (!empty($form_settings)) ? maybe_unserialize($form_settings) : array(); } $plan_payment_cycles = array(); foreach ($module_order as $module => $order) { $module_content = ''; $arm_user_id = 0; $arm_user_old_plan = 0; $plan_id_array = array(); $arm_user_selected_payment_mode = 0; $arm_user_selected_payment_cycle = 0; $arm_last_payment_status = 'success'; switch ($module) { case 'plans': if (!empty($modules['plans'])) { if (is_user_logged_in()) { global $current_user; $arm_user_id = $current_user->ID; $user_firstname = $current_user->user_firstname; $user_lastname = $current_user->user_lastname; $user_email = $current_user->user_email; if (!empty($current_user_plan_ids)) { $plan_name_array = array(); foreach ($current_user_plan_ids as $plan_id) { $planData = get_user_meta($arm_user_id, 'arm_user_plan_' . $plan_id, true); $arm_user_selected_payment_mode = $planData['arm_payment_mode']; $arm_user_current_plan_detail = $planData['arm_current_plan_detail']; $plan_name_array[] = isset($arm_user_current_plan_detail['arm_subscription_plan_name']) ? stripslashes($arm_user_current_plan_detail['arm_subscription_plan_name']) : ''; $plan_id_array[] = $plan_id; $curPlanDetail = $planData['arm_current_plan_detail']; $completed_recurrence = $planData['arm_completed_recurring']; if (!empty($curPlanDetail)) { $arm_user_old_plan_info = new ARM_Plan(0); $arm_user_old_plan_info->init((object) $curPlanDetail); } else { $arm_user_old_plan_info = new ARM_Plan($arm_user_old_plan); } $total_recurring = ''; $arm_user_old_plan_options = $arm_user_old_plan_info->options; if ($arm_user_old_plan_info->is_recurring()) { $arm_user_selected_payment_cycle = $planData['arm_payment_cycle']; $arm_user_old_plan_data = $arm_user_old_plan_info->prepare_recurring_data($arm_user_selected_payment_cycle); $total_recurring = $arm_user_old_plan_data['rec_time']; $now = current_time('mysql'); $arm_last_payment_status = $wpdb->get_var($wpdb->prepare("SELECT `arm_transaction_status` FROM `" . $ARMember->tbl_arm_payment_log . "` WHERE `arm_user_id`=%d AND `arm_plan_id`=%d AND `arm_created_date`<=%s ORDER BY `arm_log_id` DESC LIMIT 0,1", $arm_user_id, $plan_id, $now)); } $module_content .= ''; $module_content .= ''; $module_content .= ''; $module_content .= ''; $module_content .= ''; } } $arm_is_user_logged_in_flag = 1; } else { $arm_is_user_logged_in_flag = 0; } if (!empty($plan_id_array)) { $arm_user_old_plan = implode(",", $plan_id_array); } $module_content .= ''; $module_content .= ''; $planOrders = (isset($modules['plans_order']) && !empty($modules['plans_order'])) ? $modules['plans_order'] : array(); if (!empty($planOrders)) { asort($planOrders); } $plans = $this->armSortModuleOrders($modules['plans'], $planOrders); if (!empty($plans)) { $all_active_plans = $arm_subscription_plans->arm_get_all_active_subscription_plans(); $is_hide_class = ''; if ($isHidePlans == true || $is_hide_plan_selection_area == true) { $is_hide_class = 'style="display:none;"'; } $form_no = ''; $form_layout = ''; if (!empty($modules['forms']) && $modules['forms'] != 0) { if (!empty($form_settings)) { $form_no = 'arm_form_' . $modules['forms']; $form_layout = ' arm_form_layout_' . $form_settings['style']['form_layout']; } } if (!empty($current_user_plan_ids)) { $module_content .= '
' . __('Your Current Membership', 'ARMember') . ': ' . implode(", ", $plan_name_array) . '
'; } $module_content .= '
'; $column_type = (!empty($setup_modules['plans_columns'])) ? $setup_modules['plans_columns'] : '1'; $module_content .= ''; $allowed_payment_gateways = array(); if($hide_current_plans == 1){ if(!empty($current_user_plan_ids)){ $plans = array_diff($plans, $current_user_plan_ids); } } $module_content .= ''; $module_content .= '
'; $module_content = apply_filters('arm_after_setup_plan_section', $module_content, $setupID, $setup_data); $module_content .= '
'; $module_content .= ''; } } break; case 'forms': if (!empty($modules['forms']) && $modules['forms'] != 0) { if (!empty($form_settings)) { $form_style_class = 'arm_shortcode_form arm_form_' . $modules['forms']; $form_style_class .= ' arm_form_layout_' . $form_settings['style']['form_layout']; $form_style_class .= ($form_settings['style']['label_hide'] == '1') ? ' armf_label_placeholder' : ''; $form_style_class .= ' armf_alignment_' . $form_settings['style']['label_align']; $form_style_class .= ' armf_layout_' . $form_settings['style']['label_position']; $form_style_class .= ' armf_button_position_' . $form_settings['style']['button_position']; $form_style_class .= ($form_settings['style']['rtl'] == '1') ? ' arm_form_rtl' : ' arm_form_ltr'; $errPosCCField = !empty($form_settings['style']['validation_position']) ? $form_settings['style']['validation_position'] : 'bottom'; $buttonStyle = (isset($form_settings['style']['button_style']) && !empty($form_settings['style']['button_style'])) ? $form_settings['style']['button_style'] : 'flat'; $btn_style_class = ' arm_btn_style_' . $buttonStyle; $fieldPosition = !empty($form_settings['style']['field_position']) ? $form_settings['style']['field_position'] : 'left'; } if($two_step){ $module_content .= '
'; $module_content .= '
'; $module_content .= '
'; $module_content .= '
'; $module_content .= '' . html_entity_decode(stripslashes($next_button_label)) . ''; $module_content .= '
'; $module_content .= '
'; $module_content .= '
'; $module_content .= '
'; $module_content .= '
'; $module_content .= '
'; $module_content .= '
'; $module_content .= '
'; $module_content .= '' . html_entity_decode(stripslashes($previuos_button_label)) . ''; $module_content .= '
'; $module_content .= '
'; $module_content .= '
'; $module_content .= '
'; } if (is_user_logged_in() && !$isPreview) { $form = new ARM_Form('id', $modules['forms']); $ref_template = $form->form_detail['arm_ref_template']; $form_css = $arm_member_forms->arm_ajax_generate_form_styles($modules['forms'], $form_settings, array(), $ref_template); $formStyle .= $form_css['arm_css']; $modules['forms'] = 0; $setupGoogleFonts .= $form_css['arm_link']; } else { $formAttr = ''; if ($isPreview) { $formAttr = 'preview="true"'; } $module_content .= '
'; $module_content .= do_shortcode('[arm_form id="' . $modules['forms'] . '" setup="true" form_position="' . $formPosition . '" ' . $formAttr . ' setup_form_id="'.$setupRandomID.'"]'); $module_content .= '
'; $module_content = apply_filters('arm_after_setup_reg_form_section', $module_content, $setupID, $setup_data); $module_content .= '
'; } } else { if (!$isPreview) { /* Hide Setup Form for non-logged in users when there is no form configured */ return ''; } } break; case 'note': if (isset($setup_modules['note']) && !empty($setup_modules['note'])) { $module_content .= '
'; $module_content .= apply_filters('the_content', stripslashes($setup_modules['note'])); $module_content .= '
'; } break; case 'gateways': $form_layout = ''; if (!empty($form_settings)) { $form_layout = ' arm_form_layout_' . $form_settings['style']['form_layout']; } $payment_mode = "both"; if (!empty($modules['gateways'])) { $payment_gateway_skin = (isset($setup_style['gateway_skin']) && $setup_style['gateway_skin'] != '' ) ? $setup_style['gateway_skin'] : 'radio'; $gatewayOrders = array(); $gatewayOrders = (isset($modules['gateways_order']) && !empty($modules['gateways_order'])) ? $modules['gateways_order'] : array(); if (!empty($gatewayOrders)) { asort($gatewayOrders); } $gateways = $this->armSortModuleOrders($modules['gateways'], $gatewayOrders); if (!empty($gateways)) { $active_gateways = $arm_payment_gateways->arm_get_active_payment_gateways(); $is_display_pg = (!empty($selected_plan_data['arm_subscription_plan_type']) && $selected_plan_data['arm_subscription_plan_type'] == 'free') ? 'display:none;' : ''; $module_content .= '
'; if (isset($setup_data['setup_labels']['payment_section_title']) && !empty($setup_data['setup_labels']['payment_section_title'])) { $module_content .= '
' . $setup_data['setup_labels']['payment_section_title'] . '
'; } $module_content .= ''; $module_content .= '
'; $column_type = (!empty($setup_modules['gateways_columns'])) ? $setup_modules['gateways_columns'] : '1'; $doNotDisplayPaymentMode = array('bank_transfer'); $doNotDisplayPaymentMode = apply_filters('arm_not_display_payment_mode_setup', $doNotDisplayPaymentMode); $pglabels = isset($setup_data['arm_setup_labels']['payment_gateway_labels']) ? $setup_data['arm_setup_labels']['payment_gateway_labels'] : array(); $module_content .= '
    '; $i = 0; $pg_fields = $selectedKey = ''; foreach ($gateways as $pg) { if (in_array($pg, array_keys($active_gateways))) { if (!in_array($pg, $doNotDisplayPaymentMode)) { $payment_mode = $modules['payment_mode'][$pg]; } else { $payment_mode = 'manual_subscription'; } $pg_options = $active_gateways[$pg]; $pg_checked = $pg_checked_class = ''; $display_block = 'arm_hide'; if ($i == 0) { $pg_checked = 'checked="checked"'; $pg_checked_class = 'arm_active'; $display_block = ''; $selectedKey = $pg; } $pg_content = ''; switch ($pg) { case 'paypal': break; case 'bank_transfer': $pg_fields .= '
    '; if (isset($pg_options['note']) && !empty($pg_options['note'])) { $pg_fields .= '
    ' . stripslashes(nl2br($pg_options['note'])) . '
    '; } $pg_fields .= '
    '; $pg_fields .= $arm_payment_gateways->arm_get_bank_transfer_form($pg_options, $fieldPosition, $errPosCCField); $pg_fields .= '
    '; $pg_fields .= '
    '; break; default: $gateway_fields = apply_filters('arm_membership_setup_gateway_option', '', $pg, $pg_options); $pgHasCCFields = apply_filters('arm_payment_gateway_has_ccfields', false, $pg, $pg_options); if ($pgHasCCFields) { $gateway_fields .= $arm_payment_gateways->arm_get_credit_card_box($pg, $column_type, $fieldPosition, $errPosCCField); } if (!empty($gateway_fields)) { $pg_fields .= '
    '; $pg_fields .= '
    '; $pg_fields .= $gateway_fields; $pg_fields .= '
    '; $pg_fields .= '
    '; } break; } $module_content .= '
  • '; $module_content .= $pg_content; $module_content .= '
  • '; $i++; $module_content .= ""; } } $module_content .= '
'; $module_content .= '
'; $module_content .= $pg_fields; $module_content .= '
'; $module_content .= '
'; $module_content = apply_filters('arm_after_setup_gateway_section', $module_content, $setupID, $setup_data); $module_content .= '
'; $module_content .= '
'; /* Payment Mode Module */ $arm_automatic_sub_label = (isset($setup_data['setup_labels']['automatic_subscription']) && !empty($setup_data['setup_labels']['automatic_subscription'])) ? $setup_data['setup_labels']['automatic_subscription'] : __('Auto Debit Payment', 'ARMember'); $arm_semi_automatic_sub_label = (isset($setup_data['setup_labels']['semi_automatic_subscription']) && !empty($setup_data['setup_labels']['semi_automatic_subscription'])) ? $setup_data['setup_labels']['semi_automatic_subscription'] : __('Manual Payment', 'ARMember'); $module_content .= "
"; $setup_data['setup_labels']['payment_mode_selection'] = (isset($setup_data['setup_labels']['payment_mode_selection']) && !empty($setup_data['setup_labels']['payment_mode_selection'])) ? $setup_data['setup_labels']['payment_mode_selection'] : __('How you want to pay?', 'ARMember'); $module_content .= "
" . $setup_data['setup_labels']['payment_mode_selection'] . "
"; $module_content .= "
"; $module_content .= "
"; $module_content .= ""; $module_content .= "
"; } } break; case 'order_detail': if (!empty($modules['plans'])) { $module_content = apply_filters('arm_after_setup_order_detail', $module_content, $setupID, $setup_data); if (isset($setup_data['setup_labels']['summary_text']) && !empty($setup_data['setup_labels']['summary_text'])) { $setupSummaryText = stripslashes($setup_data['setup_labels']['summary_text']); $setupSummaryText = str_replace('[PLAN_NAME]', '', $setupSummaryText); $setupSummaryText = str_replace('[PLAN_AMOUNT]', ' ', $setupSummaryText); $setupSummaryText = str_replace('[DISCOUNT_AMOUNT]', ' ', $setupSummaryText); $setupSummaryText = str_replace('[PAYABLE_AMOUNT]', ' ', $setupSummaryText); $setupSummaryText = str_replace('[TRIAL_AMOUNT]', ' ', $setupSummaryText); $module_content .= "
"; $module_content .= ''; $module_content .= ''; $module_content .= '
' . nl2br($setupSummaryText) . '
'; $module_content .= '
'; } } break; default: break; } $module_html .= $module_content; } $content = apply_filters('arm_before_setup_form_content', $content, $setupID, $setup_data); $content .= '
'; $content .= ''; $content .= $setupGoogleFonts; $content .= '
'; $form_attr = ' data-ng-controller="ARMCtrl" data-ng-submit="armSetupFormSubmit(arm_form.$valid, \'arm_setup_form' . $setupRandomID . '\', $event);" onsubmit="return false;"'; $is_form_class_rtl = ''; if (is_rtl()) { $is_form_class_rtl = 'is_form_class_rtl'; } $captcha_code = arm_generate_captcha_code(); if (!isset($_SESSION['ARM_FILTER_INPUT'])) { $_SESSION['ARM_FILTER_INPUT'] = array(); } if (isset($_SESSION['ARM_FILTER_INPUT'][$setupRandomID])) { unset($_SESSION['ARM_FILTER_INPUT'][$setupRandomID]); } $_SESSION['ARM_FILTER_INPUT'][$setupRandomID] = $captcha_code; $_SESSION['ARM_VALIDATE_SCRIPT'] = true; $form_attr .= ' data-submission-key="' . $captcha_code . '" '; $content .= '
'; if ($args['hide_title'] == false && $args['popup'] == false) { $content .= '

' . $setup_name . '

'; } $content .= ''; $content .= ''; $content .= ""; $content .= '
'; $content .= ''; $content .= $module_html; $content .= '
'; $content .= '
'; $content .= '
'; $content .= '
'; $content .= '
'; $content .= '
'; $ngClick = 'ng-click="armSubmitBtnClick($event)"'; if (current_user_can('administrator')) { $ngClick = 'onclick="return false;"'; } $content .= '' . file_get_contents(MEMBERSHIPLITE_IMAGES_DIR . "/loader.svg") . '' . html_entity_decode(stripslashes($submit_btn)) . ''; $content .= '
'; $content .= '
'; $content .= '
'; $content .= '
'; $content .= '
'; $content .= '
'; if ($args['popup'] !== false) { $popup_content = '
'; $link_title = (!empty($args['link_title'])) ? $args['link_title'] : $setup_name; $link_style = $link_hover_style = ''; $popup_content .= ''; $pformRandomID = $setupID . '_popup_' . arm_generate_random_code(); $popupLinkID = 'arm_setup_form_popup_link_' . $setupID; $popupLinkClass = 'arm_setup_form_popup_link arm_setup_form_popup_link_' . $setupID; if (!empty($args['link_class'])) { $popupLinkClass.=" " . esc_html($args['link_class']); } $popupLinkAttr = 'data-form_id="' . $pformRandomID . '" data-toggle="armmodal" data-modal_bg="' . $args['modal_bgcolor'] . '" data-overlay="' . $args['overlay'] . '"'; if (!empty($args['link_type']) && strtolower($args['link_type']) == 'button') { $popup_content .= ''; } else { $popup_content .= '' . $link_title . ''; } $popup_style = $popup_content_height = ''; $popupHeight = 'auto'; $popupWidth = '500'; if (!empty($args['popup_height'])) { if ($args['popup_height'] == 'auto') { $popup_style .= 'height: auto;'; } else { $popup_style .= 'overflow: hidden;height: ' . $args['popup_height'] . 'px;'; $popupHeight = ($args['popup_height'] - 70) . 'px'; $popup_content_height = 'overflow-x: hidden;overflow-y: auto;height: ' . ($args['popup_height'] - 70) . 'px;'; } } if (!empty($args['popup_width'])) { if ($args['popup_width'] == 'auto') { $popup_style .= ''; } else { $popupWidth = $args['popup_width']; $popup_style .= 'width: ' . $args['popup_width'] . 'px;'; } } $popup_content .= ''; $popup_content .= '
'; $content = $popup_content; $content .= '
 
'; } $content = apply_filters('arm_after_setup_form_content', $content, $setupID, $setup_data); } } $ARMember->arm_check_font_awesome_icons($content); $ARMember->enqueue_angular_script(true); $inbuild = ''; $hiddenvalue = ''; $hostname = $_SERVER["SERVER_NAME"]; global $arm_members_activity, $arm_version; $arm_request_version = get_bloginfo('version'); $hiddenvalue = ' '; return do_shortcode($content.$hiddenvalue); } function arm_setup_shortcode_func_internal($atts, $content = "") { global $wp, $wpdb, $current_user, $ARMember, $arm_member_forms, $arm_global_settings, $arm_payment_gateways, $arm_subscription_plans, $bpopup_loaded, $ARMSPAMFILEURL; /* ====================/.Begin Set Shortcode Attributes./==================== */ $defaults = array( 'id' => 0, /* Membership Setup Wizard ID */ 'hide_title' => false, 'class' => '', 'popup' => false, /* Form will be open in popup box when options is true */ 'link_type' => 'link', 'link_class' => '', /* /* Possible Options:- `link`, `button` */ 'link_title' => __('Click here to open Set up form', 'ARMember'), /* Default to form name */ 'popup_height' => '', 'popup_width' => '', 'overlay' => '0.6', 'modal_bgcolor' => '#000000', 'redirect_to' => '', 'link_css' => '', 'link_hover_css' => '', 'is_referer' => '0', 'preview' => false, 'setup_data' => '', 'subscription_plan' => 0, 'hide_plans' => 0, ); /* Extract Shortcode Attributes */ $args = shortcode_atts($defaults, $atts, 'arm_setup'); extract($args); $args['hide_title'] = ($args['hide_title'] === 'true' || $args['hide_title'] == '1') ? true : false; $args['popup'] = ($args['popup'] === 'true' || $args['popup'] == '1') ? true : false; $isPreview = ($args['preview'] === 'true' || $args['preview'] == '1') ? true : false; if ($args['popup']) { $bpopup_loaded = 1; } $completed_recurrence = ''; $total_recurring = ''; if ((!empty($args['id']) && $args['id'] != 0) || ($isPreview && !empty($args['setup_data']))) { $setupID = $args['id']; if ($isPreview && !empty($args['setup_data'])) { $setup_data = maybe_unserialize($args['setup_data']); $setup_data['arm_setup_labels'] = $setup_data['setup_labels']; } else { $setup_data = $this->arm_get_membership_setup($setupID); } $setup_data = apply_filters('arm_setup_data_before_setup_shortcode', $setup_data, $args); do_action('arm_before_render_membership_setup_form', $setup_data, $args); if (!empty($setup_data) && !empty($setup_data['setup_modules']['modules'])) { $setupRandomID = $setupID . '_' . arm_generate_random_code(); $global_currency = $arm_payment_gateways->arm_get_global_currency(); $current_user_id = get_current_user_id(); $current_user_plan_ids = get_user_meta($current_user_id, 'arm_user_plan_ids', true); $current_user_plan_ids = !empty($current_user_plan_ids) ? $current_user_plan_ids : array(); $current_user_plan = ''; $current_plan_data = array(); if (!empty($current_user_plan_ids)) { $current_user_plan = $current_user_plan_ids[0]; $current_plan_data = get_user_meta($current_user_id, 'arm_user_plan_' . $current_user_plan, true); } $setup_name = (!empty($setup_data['setup_name'])) ? stripslashes($setup_data['setup_name']) : ''; $button_labels = $setup_data['setup_labels']['button_labels']; $submit_btn = (!empty($button_labels['submit'])) ? $button_labels['submit'] : __('Submit', 'ARMember'); $setup_modules = $setup_data['setup_modules']; $user_selected_plan = isset($setup_modules['selected_plan']) ? $setup_modules['selected_plan'] : ""; $modules = $setup_modules['modules']; $setup_style = isset($setup_modules['style']) ? $setup_modules['style'] : array(); $formPosition = (isset($setup_style['form_position']) && !empty($setup_style['form_position'])) ? $setup_style['form_position'] : 'left'; $plan_selection_area = (isset($setup_style['plan_area_position']) && !empty($setup_style['plan_area_position'])) ? $setup_style['plan_area_position'] : 'before'; $fieldPosition = 'left'; $custom_css = isset($setup_modules['custom_css']) ? $setup_modules['custom_css'] : ''; $modules['step'] = (!empty($modules['step'])) ? $modules['step'] : array(-1); if ($plan_selection_area == 'before') { $module_order = array( 'plans' => 1, 'forms' => 2, 'note' => 3, 'payment_cycle' => 4, 'gateways' => 5, 'order_detail' => 6, ); } else { $module_order = array( 'forms' => 1, 'plans' => 2, 'note' => 3, 'payment_cycle' => 4, 'gateways' => 5, 'order_detail' => 6, ); } $modules['forms'] = (!empty($modules['forms']) && $modules['forms'] != 0) ? $modules['forms'] : 0; $step_one_modules = $step_two_modules = ''; /* Check `GET` or `POST` Data */ /* first check if user have selected any plan than select that plan otherwise set value from options of setup */ if ($current_user_plan != '') { $selected_plan_id = $current_user_plan; } else { $selected_plan_id = $user_selected_plan; } if (!empty($_REQUEST['subscription_plan']) && $_REQUEST['subscription_plan'] != 0) { $selected_plan_id = intval($_REQUEST['subscription_plan']); } if (!empty($args['subscription_plan']) && $args['subscription_plan'] != 0) { $selected_plan_id = $args['subscription_plan']; } $isHidePlans = false; if (!empty($selected_plan_id) && $selected_plan_id != 0) { if (!empty($_REQUEST['hide_plans']) && $_REQUEST['hide_plans'] == 1) { $isHidePlans = true; } if (!empty($args['hide_plans']) && $args['hide_plans'] == 1) { $isHidePlans = true; } } $is_hide_plan_selection_area = false; if (isset($setup_style['hide_plans']) && $setup_style['hide_plans'] == 1) { $is_hide_plan_selection_area = true; } if (is_user_logged_in()) { global $current_user; if (!empty($current_user->data->arm_primary_status)) { $current_user_status = $current_user->data->arm_primary_status; } else { $current_user_status = arm_get_member_status($current_user_id); } } $selected_plan_data = array(); $module_html = $formStyle = $setupGoogleFonts = ''; $errPosCCField = 'right'; if (is_rtl()) { $is_form_class_rtl = 'arm_form_rtl'; } else { $is_form_class_rtl = 'arm_form_ltr'; } $form_style_class = ' arm_shortcode_form arm_form_0 arm_form_layout_writer armf_label_placeholder armf_alignment_left armf_layout_block armf_button_position_left ' . $is_form_class_rtl; $btn_style_class = ' arm_btn_style_flat '; if (!empty($modules['forms'])) { $form_settings = $wpdb->get_var("SELECT `arm_form_settings` FROM `" . $ARMember->tbl_arm_forms . "` WHERE `arm_form_id`='" . $modules['forms'] . "'"); $form_settings = (!empty($form_settings)) ? maybe_unserialize($form_settings) : array(); } $plan_payment_cycles = array(); foreach ($module_order as $module => $order) { $module_content = ''; $arm_user_id = 0; $arm_user_old_plan = 0; $plan_id_array = array(); $arm_user_selected_payment_mode = 0; $arm_user_selected_payment_cycle = 0; $arm_last_payment_status = 'success'; switch ($module) { case 'plans': if (is_user_logged_in()) { global $current_user; $arm_user_id = $current_user->ID; $user_firstname = $current_user->user_firstname; $user_lastname = $current_user->user_lastname; $user_email = $current_user->user_email; if (!empty($current_user_plan_ids)) { $plan_name_array = array(); foreach ($current_user_plan_ids as $plan_id) { $planData = get_user_meta($arm_user_id, 'arm_user_plan_' . $plan_id, true); $arm_user_selected_payment_mode = $planData['arm_payment_mode']; $arm_user_current_plan_detail = $planData['arm_current_plan_detail']; $plan_name_array[] = stripslashes($arm_user_current_plan_detail['arm_subscription_plan_name']); $plan_id_array[] = $plan_id; $curPlanDetail = $planData['arm_current_plan_detail']; $completed_recurrence = $planData['arm_completed_recurring']; if (!empty($curPlanDetail)) { $arm_user_old_plan_info = new ARM_Plan(0); $arm_user_old_plan_info->init((object) $curPlanDetail); } else { $arm_user_old_plan_info = new ARM_Plan($arm_user_old_plan); } $total_recurring = ''; $arm_user_old_plan_options = $arm_user_old_plan_info->options; if ($arm_user_old_plan_info->is_recurring()) { $arm_user_selected_payment_cycle = $planData['arm_payment_cycle']; $arm_user_old_plan_data = $arm_user_old_plan_info->prepare_recurring_data($arm_user_selected_payment_cycle); $total_recurring = $arm_user_old_plan_data['rec_time']; $now = current_time('mysql'); $arm_last_payment_status = $wpdb->get_var($wpdb->prepare("SELECT `arm_transaction_status` FROM `" . $ARMember->tbl_arm_payment_log . "` WHERE `arm_user_id`=%d AND `arm_plan_id`=%d AND `arm_created_date`<=%s ORDER BY `arm_log_id` DESC LIMIT 0,1", $arm_user_id, $plan_id, $now)); } $module_content .= ''; $module_content .= ''; $module_content .= ''; $module_content .= ''; $module_content .= ''; } } $arm_is_user_logged_in_flag = 1; } else { $arm_is_user_logged_in_flag = 0; } if (!empty($plan_id_array)) { $arm_user_old_plan = implode(",", $plan_id_array); } $module_content .= ''; $module_content .= ''; $all_active_plans = $arm_subscription_plans->arm_get_all_active_subscription_plans(); $plans = array_keys($all_active_plans); if (!empty($plans)) { $is_hide_class = ''; if ($isHidePlans == true || $is_hide_plan_selection_area == true) { $is_hide_class = 'style="display:none;"'; } $form_no = ''; $form_layout = ''; if (!empty($modules['forms']) && $modules['forms'] != 0) { if (!empty($form_settings)) { $form_no = 'arm_form_' . $modules['forms']; $form_layout = ' arm_form_layout_' . $form_settings['style']['form_layout']; } } if (!empty($current_user_plan_ids)) { $module_content .= '
' . __('Your Current Membership', 'ARMember') . ': ' . implode(", ", $plan_name_array) . '
'; } $module_content .= '
'; $column_type = (!empty($setup_modules['plans_columns'])) ? $setup_modules['plans_columns'] : '1'; $module_content .= ''; $allowed_payment_gateways = array(); $module_content .= ''; $module_content .= '
'; $module_content = apply_filters('arm_after_setup_plan_section', $module_content, $setupID, $setup_data); $module_content .= '
'; $module_content .= ''; } break; case 'forms': if (!empty($modules['forms']) && $modules['forms'] != 0) { if (!empty($form_settings)) { $form_style_class = 'arm_shortcode_form arm_form_' . $modules['forms']; $form_style_class .= ' arm_form_layout_' . $form_settings['style']['form_layout']; $form_style_class .= ($form_settings['style']['label_hide'] == '1') ? ' armf_label_placeholder' : ''; $form_style_class .= ' armf_alignment_' . $form_settings['style']['label_align']; $form_style_class .= ' armf_layout_' . $form_settings['style']['label_position']; $form_style_class .= ' armf_button_position_' . $form_settings['style']['button_position']; $form_style_class .= ($form_settings['style']['rtl'] == '1') ? ' arm_form_rtl' : ' arm_form_ltr'; $errPosCCField = !empty($form_settings['style']['validation_position']) ? $form_settings['style']['validation_position'] : 'bottom'; $buttonStyle = (isset($form_settings['style']['button_style']) && !empty($form_settings['style']['button_style'])) ? $form_settings['style']['button_style'] : 'flat'; $btn_style_class = ' arm_btn_style_' . $buttonStyle; $fieldPosition = !empty($form_settings['style']['field_position']) ? $form_settings['style']['field_position'] : 'left'; } if (is_user_logged_in() && !$isPreview) { $form = new ARM_Form('id', $modules['forms']); $ref_template = $form->form_detail['arm_ref_template']; $form_css = $arm_member_forms->arm_ajax_generate_form_styles($modules['forms'], $form_settings, array(), $ref_template); $formStyle .= $form_css['arm_css']; $modules['forms'] = 0; } else { $formAttr = ''; if ($isPreview) { $formAttr = 'preview="true"'; } $module_content .= '
'; $module_content .= do_shortcode('[arm_form id="' . $modules['forms'] . '" setup="true" form_position="' . $formPosition . '" ' . $formAttr . ']'); $module_content .= '
'; $module_content = apply_filters('arm_after_setup_reg_form_section', $module_content, $setupID, $setup_data); $module_content .= '
'; } } else { if (!$isPreview) { /* Hide Setup Form for non-logged in users when there is no form configured */ return ''; } } break; case 'note': if (isset($setup_modules['note']) && !empty($setup_modules['note'])) { $module_content .= '
'; $module_content .= apply_filters('the_content', stripslashes($setup_modules['note'])); $module_content .= '
'; } break; case 'payment_cycle': $form_layout = ''; if (!empty($form_settings)) { $form_layout = ' arm_form_layout_' . $form_settings['style']['form_layout']; } $payment_mode = "both"; $module_content .= '
'; if (!empty($plan_payment_cycles)) { foreach ($plan_payment_cycles as $payment_cycle_plan_id => $plan_payment_cycle_data) { $arm_user_selected_payment_cycle = 0; if (!empty($current_plan_data)) { $arm_user_selected_payment_cycle = $current_plan_data['arm_payment_cycle']; } if (!empty($plan_payment_cycle_data)) { $module_content .= '
'; if (isset($setup_data['setup_labels']['payment_cycle_section_title']) && !empty($setup_data['setup_labels']['payment_cycle_section_title'])) { $module_content .= '
' . $setup_data['setup_labels']['payment_cycle_section_title'] . '
'; } else { $module_content .= '
' . __('Select Payment Cycle', 'ARMember') . '
'; } $column_type = (!empty($setup_modules['cycle_columns'])) ? $setup_modules['cycle_columns'] : '1'; if (is_array($plan_payment_cycle_data)) { if (count($plan_payment_cycle_data) <= $arm_user_selected_payment_cycle) { $arm_user_selected_payment_cycle_no = 0; } else { $arm_user_selected_payment_cycle_no = $arm_user_selected_payment_cycle; } $module_content .= ''; } $module_content .= ''; $module_content .= '
'; } } } $module_content = apply_filters('arm_after_setup_payment_cycle_section', $module_content, $setupID, $setup_data); $module_content .= '
'; break; case 'gateways': $form_layout = ''; if (!empty($form_settings)) { $form_layout = ' arm_form_layout_' . $form_settings['style']['form_layout']; } $payment_mode = "both"; $payment_gateway_skin = (isset($setup_style['gateway_skin']) && $setup_style['gateway_skin'] != '' ) ? $setup_style['gateway_skin'] : 'radio'; $active_gateways = $arm_payment_gateways->arm_get_active_payment_gateways(); $gateways = array_keys($active_gateways); if (!empty($gateways)) { $is_display_pg = (!empty($selected_plan_data['arm_subscription_plan_type']) && $selected_plan_data['arm_subscription_plan_type'] == 'free') ? 'display:none;' : ''; $module_content .= '
'; if (isset($setup_data['setup_labels']['payment_section_title']) && !empty($setup_data['setup_labels']['payment_section_title'])) { $module_content .= '
' . $setup_data['setup_labels']['payment_section_title'] . '
'; } $module_content .= ''; $module_content .= '
'; $column_type = (!empty($setup_modules['gateways_columns'])) ? $setup_modules['gateways_columns'] : '1'; $doNotDisplayPaymentMode = array('bank_transfer'); $doNotDisplayPaymentMode = apply_filters('arm_not_display_payment_mode_setup', $doNotDisplayPaymentMode); $pglabels = isset($setup_data['arm_setup_labels']['payment_gateway_labels']) ? $setup_data['arm_setup_labels']['payment_gateway_labels'] : array(); if ($payment_gateway_skin == 'radio') { $module_content .= ''; } else { $paymentSkinFloat = "float:none;"; switch ($formPosition) { case 'left': $paymentSkinFloat = ""; break; case 'right': $paymentSkinFloat = "float:right;"; break; } $module_content .= '
'; $module_content .= '
'; $module_content .= ''; $i = 0; $pg_fields = $selectedKey = ''; foreach ($gateways as $pg) { if (in_array($pg, array_keys($active_gateways))) { $payment_gateway_name = $pg; if (isset($selected_plan_data['arm_subscription_plan_options']['trial']['is_trial_period']) && $pg == 'stripe' && $selected_plan_data['arm_subscription_plan_options']['payment_type'] == 'subscription') { if ($selected_plan_data['arm_subscription_plan_options']['trial']['amount'] > 0) { // continue; } } if (!in_array($pg, $doNotDisplayPaymentMode)) { $payment_mode = $modules['payment_mode'][$pg]; } else { $payment_mode = 'manual_subscription'; } $pg_options = $active_gateways[$pg]; $pg_checked = $pg_checked_class = ''; $display_block = 'arm_hide'; if ($i == 0) { $pg_checked = 'selected="selected"'; $pg_checked_class = 'arm_active'; $display_block = ''; $selectedKey = $pg; } switch ($pg) { case 'paypal': break; case 'stripe': if ($pg_options['stripe_payment_mode'] == 'live') { $apikey = $pg_options['stripe_pub_key']; } else { $apikey = $pg_options['stripe_test_pub_key']; } $pg_fields .= ''; $pg_fields .= '
'; $pg_fields .= '
'; $pg_fields .= $arm_payment_gateways->arm_get_credit_card_box('stripe', $column_type, $fieldPosition, $errPosCCField); $pg_fields .= '
'; $pg_fields .= '
'; break; case 'authorize_net': $pg_fields .= '
'; $pg_fields .= '
'; $pg_fields .= $arm_payment_gateways->arm_get_credit_card_box('authorize_net', $column_type, $fieldPosition, $errPosCCField); $pg_fields .= '
'; $pg_fields .= '
'; break; case '2checkout': break; case 'bank_transfer': $pg_fields .= '
'; if (isset($pg_options['note']) && !empty($pg_options['note'])) { $pg_fields .= '
' . stripslashes($pg_options['note']) . '
'; } $pg_fields .= '
'; $pg_fields .= $arm_payment_gateways->arm_get_bank_transfer_form($pg_options, $fieldPosition, $errPosCCField); $pg_fields .= '
'; $pg_fields .= '
'; break; default: $gateway_fields = apply_filters('arm_membership_setup_gateway_option', '', $pg, $pg_options); $pgHasCCFields = apply_filters('arm_payment_gateway_has_ccfields', false, $pg, $pg_options); if ($pgHasCCFields) { $gateway_fields .= $arm_payment_gateways->arm_get_credit_card_box($pg, $column_type, $fieldPosition, $errPosCCField); } if (!empty($gateway_fields)) { $pg_fields .= '
'; $pg_fields .= '
'; $pg_fields .= $gateway_fields; $pg_fields .= '
'; $pg_fields .= '
'; } break; } if (!empty($pglabels)) { if(isset($pglabels[$pg])){ $pg_options['gateway_name'] = $pglabels[$pg]; } } $module_content .='' . $pg_options['gateway_name'] . ''; $i++; $module_content .= ""; } } $module_content .= '
'; $module_content .= '
'; } $module_content .= '
'; $module_content .= $pg_fields; $module_content .= '
'; $module_content .= '
'; $module_content = apply_filters('arm_after_setup_gateway_section', $module_content, $setupID, $setup_data); $module_content .= '
'; $module_content .= '
'; /* Payment Mode Module */ $arm_automatic_sub_label = (isset($setup_data['setup_labels']['automatic_subscription']) && !empty($setup_data['setup_labels']['automatic_subscription'])) ? $setup_data['setup_labels']['automatic_subscription'] : __('Auto Debit Payment', 'ARMember'); $arm_semi_automatic_sub_label = (isset($setup_data['setup_labels']['semi_automatic_subscription']) && !empty($setup_data['setup_labels']['semi_automatic_subscription'])) ? $setup_data['setup_labels']['semi_automatic_subscription'] : __('Manual Payment', 'ARMember'); $module_content .= "
"; $setup_data['setup_labels']['payment_mode_selection'] = (isset($setup_data['setup_labels']['payment_mode_selection']) && !empty($setup_data['setup_labels']['payment_mode_selection'])) ? $setup_data['setup_labels']['payment_mode_selection'] : __('How you want to pay?', 'ARMember'); $module_content .= "
" . $setup_data['setup_labels']['payment_mode_selection'] . "
"; $module_content .= "
"; $module_content .= "
"; $module_content .= ""; $module_content .= "
"; } break; case 'order_detail': if (!empty($modules['plans'])) { /* $module_content .= '
'; */ if ($arm_manage_coupons->isCouponFeature && !empty($modules['coupons']) && $modules['coupons'] == '1') { $labels = array( 'title' => (!empty($button_labels['coupon_title'])) ? $button_labels['coupon_title'] : '', 'button' => (!empty($button_labels['coupon_button'])) ? $button_labels['coupon_button'] : '', ); $is_used_as_invitation_code = (isset($setup_modules['modules']['coupon_as_invitation']) && $setup_modules['modules']['coupon_as_invitation'] == 1) ? true : false; $module_content .= '
'; if (isset($button_labels['coupon_title']) && !empty($button_labels['coupon_title'])) { $module_content .= '
' . $button_labels['coupon_title'] . '
'; } $module_content .= '
'; $is_display_coupons = (!empty($selected_plan_data['arm_subscription_plan_type']) && $selected_plan_data['arm_subscription_plan_type'] == 'free') ? 'display:none;' : ''; $module_content .= '
'; $module_content .= '
'; $module_content .= '
'; $module_content .= $arm_manage_coupons->arm_redeem_coupon_html('', $labels, $selected_plan_data, $btn_style_class, $is_used_as_invitation_code, $setupRandomID, $formPosition); $module_content .= '
'; $module_content .= '
'; $module_content .= '
'; $module_content .= '
'; $module_content .= '
'; $module_content .= '
'; } $module_content = apply_filters('arm_after_setup_order_detail', $module_content, $setupID, $setup_data); if (isset($setup_data['setup_labels']['summary_text']) && !empty($setup_data['setup_labels']['summary_text'])) { $setupSummaryText = stripslashes($setup_data['setup_labels']['summary_text']); $setupSummaryText = str_replace('[PLAN_NAME]', '', $setupSummaryText); $setupSummaryText = str_replace('[PLAN_AMOUNT]', ' ', $setupSummaryText); $setupSummaryText = str_replace('[DISCOUNT_AMOUNT]', ' ', $setupSummaryText); $setupSummaryText = str_replace('[PAYABLE_AMOUNT]', ' ', $setupSummaryText); $setupSummaryText = str_replace('[TRIAL_AMOUNT]', ' ', $setupSummaryText); $module_content .= "
"; $module_content .= ''; $module_content .= ''; $module_content .= '
' . nl2br($setupSummaryText) . '
'; $module_content .= '
'; } } break; default: break; } $module_html .= $module_content; } $content = apply_filters('arm_before_setup_form_content', $content, $setupID, $setup_data); $content .= '
'; $content .= ''; $content .= $setupGoogleFonts; $content .= '
'; $form_attr = ' data-ng-controller="ARMCtrl" data-ng-submit="armSetupFormSubmit(arm_form.$valid, \'arm_setup_form' . $setupRandomID . '\', $event);" onsubmit="return false;"'; $is_form_class_rtl = ''; if (is_rtl()) { $is_form_class_rtl = 'is_form_class_rtl'; } $captcha_code = arm_generate_captcha_code(); if (!isset($_SESSION['ARM_FILTER_INPUT'])) { $_SESSION['ARM_FILTER_INPUT'] = array(); } if (isset($_SESSION['ARM_FILTER_INPUT'][$setupRandomID])) { unset($_SESSION['ARM_FILTER_INPUT'][$setupRandomID]); } $_SESSION['ARM_FILTER_INPUT'][$setupRandomID] = $captcha_code; $_SESSION['ARM_VALIDATE_SCRIPT'] = true; $form_attr .= ' data-submission-key="' . $captcha_code . '" '; $content .= '
'; if ($args['hide_title'] == false && $args['popup'] == false) { $content .= '

' . $setup_name . '

'; } $content .= ''; $content .= ''; $content .= ""; $content .= '
'; $content .= ''; $content .= $module_html; $content .= '
'; $content .= '
'; $content .= '
'; $content .= '
'; $content .= '
'; $content .= '
'; $content .= '
'; $ngClick = 'ng-click="armSubmitBtnClick($event)"'; if (current_user_can('administrator')) { $ngClick = 'onclick="return false;"'; } $content .= '' . file_get_contents(MEMBERSHIPLITE_IMAGES_DIR . "/loader.svg") . '' . html_entity_decode(stripslashes($submit_btn)) . ''; $content .= '
'; $content .= '
'; $content .= '
'; $content .= '
'; $content .= '
'; $content .= '
'; if ($args['popup'] !== false) { $popup_content = '
'; $link_title = (!empty($args['link_title'])) ? $args['link_title'] : $setup_name; $link_style = $link_hover_style = ''; $popup_content .= ''; $pformRandomID = $setupID . '_popup_' . arm_generate_random_code(); $popupLinkID = 'arm_setup_form_popup_link_' . $setupID; $popupLinkClass = 'arm_setup_form_popup_link arm_setup_form_popup_link_' . $setupID; if (!empty($args['link_class'])) { $popupLinkClass.=" " . esc_html($args['link_class']); } $popupLinkAttr = 'data-form_id="' . $pformRandomID . '" data-toggle="armmodal" data-modal_bg="' . $args['modal_bgcolor'] . '" data-overlay="' . $args['overlay'] . '"'; if (!empty($args['link_type']) && strtolower($args['link_type']) == 'button') { $popup_content .= ''; } else { $popup_content .= '' . $link_title . ''; } $popup_style = $popup_content_height = ''; $popupHeight = 'auto'; $popupWidth = '500'; if (!empty($args['popup_height'])) { if ($args['popup_height'] == 'auto') { $popup_style .= 'height: auto;'; } else { $popup_style .= 'overflow: hidden;height: ' . $args['popup_height'] . 'px;'; $popupHeight = ($args['popup_height'] - 70) . 'px'; $popup_content_height = 'overflow-x: hidden;overflow-y: auto;height: ' . ($args['popup_height'] - 70) . 'px;'; } } if (!empty($args['popup_width'])) { if ($args['popup_width'] == 'auto') { $popup_style .= ''; } else { $popupWidth = $args['popup_width']; $popup_style .= 'width: ' . $args['popup_width'] . 'px;'; } } $popup_content .= ''; $popup_content .= '
'; $content = $popup_content; $content .= '
 
'; } $content = apply_filters('arm_after_setup_form_content', $content, $setupID, $setup_data); } } $ARMember->arm_check_font_awesome_icons($content); $ARMember->enqueue_angular_script(); return do_shortcode($content); } function arm_generate_setup_style($setupid = 0, $setup_style = array()) { $defaultStyle = array( 'content_width' => '800', 'plan_skin' => '', 'font_family' => 'Helvetica', 'title_font_size' => 24, 'title_font_bold' => 1, 'title_font_italic' => '', 'title_font_decoration' => '', 'description_font_size' => 16, 'description_font_bold' => 0, 'description_font_italic' => '', 'description_font_decoration' => '', 'price_font_size' => 30, 'price_font_bold' => 1, 'price_font_italic' => '', 'price_font_decoration' => '', 'summary_font_size' => 15, 'summary_font_bold' => 0, 'summary_font_italic' => '', 'summary_font_decoration' => '', 'plan_title_font_color' => '#504f51', 'plan_desc_font_color' => '#504f51', 'price_font_color' => '#504f51', 'summary_font_color' => '#504f51', 'bg_active_color' => '#39a5ff', 'selected_plan_title_font_color' => '#000000', 'selected_plan_desc_font_color' => '#000000', 'selected_price_font_color' => '#000000', ); $setup_style = shortcode_atts($defaultStyle, $setup_style); $summary_font_style = (isset($setup_style['summary_font_bold']) && $setup_style['summary_font_bold'] == '1') ? "font-weight: bold;" : "font-weight: normal;"; $summary_font_style .= (isset($setup_style['summary_font_italic']) && $setup_style['summary_font_italic'] == '1') ? "font-style: italic;" : ""; $summary_font_style .= (isset($setup_style['summary_font_decoration']) && !empty($setup_style['summary_font_decoration'])) ? "text-decoration: " . $setup_style['summary_font_decoration'] . ";" : ""; $title_font_style = (isset($setup_style['title_font_bold']) && $setup_style['title_font_bold'] == '1') ? "font-weight: bold;" : "font-weight: normal;"; $title_font_style .= (isset($setup_style['title_font_italic']) && $setup_style['title_font_italic'] == '1') ? "font-style: italic;" : ""; $title_font_style .= (isset($setup_style['title_font_decoration']) && !empty($setup_style['title_font_decoration'])) ? "text-decoration: " . $setup_style['title_font_decoration'] . ";" : ""; $description_font_style = (isset($setup_style['description_font_bold']) && $setup_style['description_font_bold'] == '1') ? "font-weight: bold;" : "font-weight: normal;"; $description_font_style .= (isset($setup_style['description_font_italic']) && $setup_style['description_font_italic'] == '1') ? "font-style: italic;" : ""; $description_font_style .= (isset($setup_style['description_font_decoration']) && !empty($setup_style['description_font_decoration'])) ? "text-decoration: " . $setup_style['description_font_decoration'] . ";" : ""; $price_font_style = (isset($setup_style['price_font_bold']) && $setup_style['price_font_bold'] == '1') ? "font-weight: bold;" : "font-weight: normal;"; $price_font_style .= (isset($setup_style['price_font_italic']) && $setup_style['price_font_italic'] == '1') ? "font-style: italic;" : ""; $price_font_style .= (isset($setup_style['price_font_decoration']) && !empty($setup_style['price_font_decoration'])) ? "text-decoration: " . $setup_style['price_font_decoration'] . ";" : ""; $setup_content_width = ($setup_style['content_width'] == 0 && $setup_style['content_width'] != '') ? '800' : $setup_style['content_width']; $setup_content_width = ($setup_content_width == '') ? 'auto' : $setup_content_width.'px'; $setup_css = ' .arm_setup_form_' . $setupid . '{ width: ' . $setup_content_width . '; margin: 0 auto; } .arm_setup_form_' . $setupid . ' .arm_setup_form_title, .arm_setup_form_' . $setupid . ' .arm_setup_section_title_wrapper{ font-family: ' . $setup_style['font_family'] . ', sans-serif, \'Trebuchet MS\'; font-size: 20px !important; font-size: ' . ($setup_style['title_font_size'] + 2) . 'px !important; color: ' . $setup_style['plan_title_font_color'] . '; font-weight: normal; } .arm_setup_form_' . $setupid . ' .arm_payment_mode_label{ font-family: ' . $setup_style['font_family'] . ', sans-serif, \'Trebuchet MS\'; font-size: ' . $setup_style['description_font_size'] . 'px !important; color: ' . $setup_style['plan_desc_font_color'] . '; font-weight : normal; } .arm_setup_form_' . $setupid . ' .arm_setup_column_item .arm_module_plan_name, .arm_setup_form_' . $setupid . ' .arm_setup_column_item .arm_module_gateway_name, .arm_setup_form_' . $setupid . ' .arm_setup_column_item .arm_module_payment_cycle_name{ font-family: ' . $setup_style['font_family'] . ', sans-serif, \'Trebuchet MS\'; font-size: ' . $setup_style['title_font_size'] . 'px !important; color: ' . $setup_style['plan_title_font_color'] . ' !important; ' . $title_font_style . ' } .arm_setup_form_' . $setupid . ' .arm_setup_column_item.arm_active .arm_module_plan_option .arm_module_plan_name, .arm_setup_form_' . $setupid . ' .arm_setup_column_item.arm_active .arm_module_plan_name{ color: ' . $setup_style['selected_plan_title_font_color'] . ' !important; } .arm_setup_form_' . $setupid . ' .arm_setup_column_item .arm_module_plan_price{ font-family: ' . $setup_style['font_family'] . ', sans-serif, \'Trebuchet MS\'; font-size: ' . $setup_style['price_font_size'] . 'px !important; color: ' . $setup_style['price_font_color'] . ' !important; ' . $price_font_style . ' } .arm_setup_form_' . $setupid . ' .arm_setup_column_item.arm_active .arm_module_plan_option .arm_module_plan_price_type .arm_module_plan_price, .arm_setup_form_' . $setupid . ' .arm_setup_column_item.arm_active .arm_module_plan_price{ color: ' . $setup_style['selected_price_font_color'] . ' !important; } .arm_setup_form_' . $setupid . ' .arm_setup_column_item .arm_module_plan_description{ font-family: ' . $setup_style['font_family'] . ', sans-serif, \'Trebuchet MS\'; font-size: ' . $setup_style['description_font_size'] . 'px !important; color: ' . $setup_style['plan_desc_font_color'] . '; ' . $description_font_style . ' } .arm_setup_form_' . $setupid . ' .arm_setup_column_item.arm_active .arm_module_plan_option .arm_module_plan_description, .arm_setup_form_' . $setupid . ' .arm_setup_column_item.arm_active .arm_module_plan_description{ color: ' . $setup_style['selected_plan_desc_font_color'] . '; } .arm_setup_form_' . $setupid . ' .arm_setup_summary_text_container .arm_setup_summary_text{ font-family: ' . $setup_style['font_family'] . ', sans-serif, \'Trebuchet MS\'; font-size: ' . $setup_style['summary_font_size'] . 'px !important; color: ' . $setup_style['summary_font_color'] . '; ' . $summary_font_style . ' } .arm_setup_form_' . $setupid . ' .arm_setup_column_item:hover .arm_module_plan_option, .arm_setup_form_' . $setupid . ' .arm_setup_column_item.arm_active .arm_module_plan_option, .arm_setup_form_' . $setupid . ' .arm_setup_column_item:hover .arm_module_gateway_option, .arm_setup_form_' . $setupid . ' .arm_setup_column_item.arm_active .arm_module_gateway_option, .arm_setup_form_' . $setupid . ' .arm_setup_column_item:hover .arm_module_payment_cycle_option, .arm_setup_form_' . $setupid . ' .arm_setup_column_item.arm_active .arm_module_payment_cycle_option{ border: 1px solid ' . $setup_style['bg_active_color'] . '; } .arm_setup_form_' . $setupid . ' .arm_setup_column_item .arm_module_plan_name, .arm_setup_form_' . $setupid . ' .arm_setup_column_item .arm_module_gateway_name, .arm_setup_form_' . $setupid . ' .arm_setup_column_item .arm_module_payment_cycle_name{ font-size: ' . $setup_style['title_font_size'] . 'px !important; color: ' . $setup_style['plan_title_font_color'] . '; ' . $title_font_style . ' } .arm_setup_form_' . $setupid . ' .arm_plan_default_skin.arm_setup_column_item.arm_active .arm_module_plan_option{ background-color: ' . $setup_style['bg_active_color'] . '; border: 1px solid ' . $setup_style['bg_active_color'] . '; } .arm_setup_form_' . $setupid . ' .arm_plan_default_skin.arm_setup_column_item.arm_active .arm_module_plan_option{ background-color: ' . $setup_style['bg_active_color'] . '; border: 1px solid ' . $setup_style['bg_active_color'] . '; } .arm_setup_form_' . $setupid . ' .arm_plan_skin1.arm_setup_column_item:hover .arm_module_plan_option .arm_module_plan_price_type, .arm_setup_form_' . $setupid . ' .arm_plan_skin1.arm_setup_column_item.arm_active .arm_module_plan_option .arm_module_plan_price_type { transition: all 0.7s ease 0s; -webkit-transition: all 0.7s ease 0s; -moz-transiton: all 0.7s ease 0s; -o-transition: all 0.7s ease 0s; background-color: ' . $setup_style['bg_active_color'] . '; border: 1px solid ' . $setup_style['bg_active_color'] . '; } .arm_setup_form_' . $setupid . ' .arm_plan_skin1.arm_setup_column_item:hover .arm_module_plan_option .arm_module_plan_price_type .arm_module_plan_price, .arm_setup_form_' . $setupid . ' .arm_plan_skin1.arm_setup_column_item.arm_active .arm_module_plan_option .arm_module_plan_price_type .arm_module_plan_price{ color: ' . $setup_style['selected_price_font_color'] . ' !important; } .arm_setup_form_' . $setupid . ' .arm_plan_skin2.arm_setup_column_item:hover .arm_module_plan_option .arm_module_plan_name, .arm_setup_form_' . $setupid . ' .arm_plan_skin2.arm_setup_column_item.arm_active .arm_module_plan_option .arm_module_plan_name{ transition: all 0.7s ease 0s; -webkit-transition: all 0.7s ease 0s; -moz-transiton: all 0.7s ease 0s; -o-transition: all 0.7s ease 0s; background-color: ' . $setup_style['bg_active_color'] . '; border: 1px solid ' . $setup_style['bg_active_color'] . '; } .arm_setup_form_' . $setupid . ' .arm_plan_skin6.arm_setup_column_item:hover .arm_module_plan_option, .arm_setup_form_' . $setupid . ' .arm_plan_skin6.arm_setup_column_item.arm_active .arm_module_plan_option{ transition: all 0.7s ease 0s; -webkit-transition: all 0.7s ease 0s; -moz-transiton: all 0.7s ease 0s; -o-transition: all 0.7s ease 0s; background-color: ' . $setup_style['bg_active_color'] . '; border: 1px solid ' . $setup_style['bg_active_color'] . '; color: '.$setup_style['selected_plan_title_font_color'].' !important; } .arm_setup_form_' . $setupid . ' .arm_plan_skin6.arm_setup_column_item:hover .arm_module_plan_option .arm_module_plan_name, .arm_setup_form_' . $setupid . ' .arm_plan_skin6.arm_setup_column_item.arm_active .arm_module_plan_option .arm_module_plan_name, .arm_setup_form_' . $setupid . ' .arm_plan_skin6.arm_setup_column_item:hover .arm_module_plan_option .arm_module_plan_price, .arm_setup_form_' . $setupid . ' .arm_plan_skin6.arm_setup_column_item.arm_active .arm_module_plan_option .arm_module_plan_price, .arm_setup_form_' . $setupid . ' .arm_plan_skin6.arm_setup_column_item:hover .arm_module_plan_option .arm_module_plan_description, .arm_setup_form_' . $setupid . ' .arm_plan_skin6.arm_setup_column_item.arm_active .arm_module_plan_option .arm_module_plan_description{ transition: all 0.7s ease 0s; -webkit-transition: all 0.7s ease 0s; -moz-transiton: all 0.7s ease 0s; -o-transition: all 0.7s ease 0s; color: '.$setup_style['selected_plan_title_font_color']. ' !important; } .arm_setup_form_' . $setupid . ' .arm_plan_skin2.arm_setup_column_item:hover .arm_module_plan_option .arm_module_plan_name, .arm_setup_form_' . $setupid . ' .arm_plan_skin2.arm_setup_column_item.arm_active .arm_module_plan_option .arm_module_plan_name{ color: ' . $setup_style['selected_plan_title_font_color'] . ' !important; } .arm_setup_form_' . $setupid . ' .arm_setup_check_circle{ border-color: ' . $setup_style['bg_active_color'] . ' !important; color: ' . $setup_style['bg_active_color'] . ' !important; } .arm_setup_form_' . $setupid . ' .arm_plan_skin3 .arm_module_plan_option .arm_setup_check_circle i, .arm_setup_form_' . $setupid . ' .arm_plan_skin3 .arm_module_plan_option:hover .arm_setup_check_circle i{ color: ' . $setup_style['bg_active_color'] . ' !important; } .arm_setup_form_' . $setupid . ' .arm_plan_skin3 .arm_module_plan_option .arm_setup_check_circle, .arm_setup_form_' . $setupid . ' .arm_plan_skin3 .arm_module_plan_option .arm_setup_check_circle, .arm_setup_form_' . $setupid . ' .arm_plan_skin3 .arm_module_plan_option .arm_setup_check_circle, .arm_setup_form_' . $setupid . ' .arm_plan_skin5 .arm_module_plan_option .arm_setup_check_circle{ border-color: ' . $setup_style['bg_active_color'] . ' !important; } .arm_setup_form_' . $setupid . ' .arm_module_gateways_container .arm_module_gateway_fields{ font-family: ' . $setup_style['font_family'] . ', sans-serif, \'Trebuchet MS\'; } '; return $setup_css; } function armSortModuleOrders(Array $array, Array $orderArray) { $ordered = array(); if (!empty($array) && !empty($orderArray)) { foreach ($array as $key => $val) { if (array_key_exists($val, $orderArray)) { $ordered[$orderArray[$val]] = $val; unset($array[$key]); } } } else { $ordered = $array; } if (!empty($ordered)) { ksort($ordered); } return $ordered; } function arm_sort_module_by_order($items = array(), $item_order = array()) { $new_items = array(); if (!empty($items)) { if (!empty($item_order)) { asort($item_order); foreach ($item_order as $key => $order) { if (!empty($items[$key])) { $new_items[$key] = $items[$key]; unset($items[$key]); } } $new_items = $new_items + $items; } else { $new_items = $items; } } return $new_items; } function arm_refresh_setup_items() { global $wp, $wpdb, $ARMember, $arm_global_settings, $arm_payment_gateways,$arm_subscription_plans, $arm_capabilities_global; $module_items = ''; $ARMember->arm_check_user_cap($arm_capabilities_global['arm_manage_setups'], '1'); if (!empty($_POST['module'])) { $module_items = $this->arm_get_module_items_box($_POST['module']); } echo $module_items; exit; } function arm_get_module_items_box($module_type = 'plans', $options = array()) { global $wp, $wpdb, $ARMember, $arm_slugs, $arm_global_settings, $arm_payment_gateways, $arm_subscription_plans; $module_box = ''; $alertMessages = $ARMember->arm_alert_messages(); $add_plan_link = admin_url('admin.php?page=' . $arm_slugs->manage_plans . '&action=new'); $manage_gateway_link = admin_url('admin.php?page=' . $arm_slugs->general_settings . '&&action=payment_options'); $selected_items = (!empty($options['selected'])) ? $options['selected'] : array(); $items_order = (!empty($options['items_order'])) ? $options['items_order'] : array(); $column_type = (!empty($options['column'])) ? $options['column'] : 1; $input_prefix = 'setup_data[setup_modules]'; if ($module_type == 'plans') { $active_plans = $arm_subscription_plans->arm_get_all_active_subscription_plans(); $filtered_items = $this->arm_sort_module_by_order($active_plans, $items_order); $module_box .= '
'; if (!empty($filtered_items)) { $module_box .= '
'; $module_box .= '
'; $column1_class = ($column_type == 1) ? 'arm_active_label' : ''; $module_box .= ''; $column2_class = ($column_type == 2) ? 'arm_active_label' : ''; $module_box .= ''; $column3_class = ($column_type == 3) ? 'arm_active_label' : ''; $module_box .= ''; $module_box .= '
'; $module_box .= '
'; $module_box .= ''; } else { $module_box .= ''; $module_box .= ''; $module_box .= '
' . __('There is no any plan configured yet.', 'ARMember'); $module_box .= ' ' . __('Please click here to add plan.', 'ARMember') . ''; $module_box .= ' ' . __('After adding plan, click on refresh button', 'ARMember'); $module_box .= ' () ' . __('to get added plans.', 'ARMember'); $module_box .= '
'; } $module_box .= '
'; } elseif ($module_type == 'gateways') { $active_gateways = $arm_payment_gateways->arm_get_active_payment_gateways(); $filtered_gatways = $this->arm_sort_module_by_order($active_gateways, $items_order); $module_box .= '
'; if (!empty($filtered_gatways)) { $module_box .= '
'; $module_box .= '
'; $column1_class = ($column_type == 1) ? 'arm_active_label' : ''; $module_box .= ''; $column2_class = ($column_type == 2) ? 'arm_active_label' : ''; $module_box .= ''; $column3_class = ($column_type == 3) ? 'arm_active_label' : ''; $module_box .= ''; $module_box .= '
'; $module_box .= '
'; $module_box .= ''; $module_box .= '
'; $module_box .= '
'; $module_box .= '' . (implode(',', $bankNotPlans)) . ' ' . __("plan's configuration is not supported by Bank Transfer. So it will be hide as a payment option when user will select this plan(s).", 'ARMember') . ''; $module_box .= '
'; $module_box .= '
'; } else { $module_box .= ''; $module_box .= ''; $module_box .= '
' . __('There is no any payment gateway configured yet.', 'ARMember'); $module_box .= ' ' . __('Please click here to add payment method.', 'ARMember') . ''; $module_box .= ' ' . __('After setup payment gateway, click on refresh button', 'ARMember'); $module_box .= ' () ' . __('to get added payment gateways.', 'ARMember'); $module_box .= '
'; } $module_box .= '
'; } return $module_box; } function arm_update_plan_form_gateway_selection() { global $wp, $wpdb, $ARMember, $arm_payment_gateways, $arm_subscription_plans, $arm_capabilities_global; $ARMember->arm_check_user_cap($arm_capabilities_global['arm_manage_setups'], '1'); $returnArr = array( 'plans' => '', 'plan_layout_list' => '', 'forms' => $this->arm_setup_form_list_options(), 'gateways' => '', ); $totalPlans = isset($_POST['total_plans']) ? intval($_POST['total_plans']) : 0; $totalGateways = isset($_POST['total_gateways']) ? intval($_POST['total_gateways']) : 0; $selectedPlans = (isset($_POST['selected_plans']) && !empty($_POST['selected_plans'])) ? explode(',', $_POST['selected_plans']) : array(); $plansOrder = (isset($_POST['setup_data']['setup_modules']['modules']['plans_order'])) ? $_POST['setup_data']['setup_modules']['modules']['plans_order'] : array(); $selectedGateways = (isset($_POST['selected_gateways']) && !empty($_POST['selected_gateways'])) ? explode(',', $_POST['selected_gateways']) : array(); $user_selected_plan = (isset($_POST['default_selected_plan'])) ? intval($_POST['default_selected_plan']) : ''; $activePlanCounts = $arm_subscription_plans->arm_get_total_active_plan_counts(); if ($activePlanCounts == 0) { $returnArr['plans'] = ""; } else if ($activePlanCounts != $totalPlans) { $allPlans = $arm_subscription_plans->arm_get_all_active_subscription_plans(); $returnArr['plans'] = $this->arm_setup_plan_list_options($selectedPlans, $allPlans); $returnArr['plan_layout_list'] = $this->arm_setup_plan_layout_list_options($plansOrder, $selectedPlans, $user_selected_plan); } $activeGateways = $arm_payment_gateways->arm_get_active_payment_gateways(); if (count($activeGateways) == 0) { $returnArr['gateways'] = ""; } else if (count($activeGateways) != $totalGateways) { $activeGateways = $arm_payment_gateways->arm_get_active_payment_gateways(); $returnArr['gateways'] = $this->arm_setup_gateway_list_options($selectedGateways, $activeGateways); } echo json_encode($returnArr); exit; } function arm_setup_plan_list_options($selectedPlans = array(), $allPlans = array()) { global $wp, $wpdb, $ARMember, $arm_subscription_plans; $planList = ''; if (!empty($allPlans)) { foreach ($allPlans as $plan) { $planObj = new ARM_Plan(0); $planObj->init((object) $plan); $plan_id = $planObj->ID; $plan_options = $planObj->options; $arm_show_plan_payment_cycles = (isset($plan_options['show_payment_cycle']) && $plan_options['show_payment_cycle'] == '1') ? 1 : 0; $plan_checked = (in_array($plan_id, $selectedPlans) ? 'checked="checked"' : ''); $planInputAttr = $plan_checked . ' data-plan_name="' . $planObj->name . '" data-plan_type="' . $planObj->type . '" data-payment_type="' . $planObj->payment_type . '" data-show_payment_cycle="' . $arm_show_plan_payment_cycles . '" '; $planList .= '
'; $planList .= ''; $planList .= ''; $planList .= '
'; } } return $planList; } function arm_setup_plan_layout_list_options($planOrders = array(), $selectedPlans = array(), $user_selected_plan = '') { global $wp, $wpdb, $ARMember, $arm_subscription_plans; $planOrderList = ''; $allPlans = $arm_subscription_plans->arm_get_all_subscription_plans(); $orderPlans = $this->arm_sort_module_by_order($allPlans, $planOrders); $user_selected_plan = (isset($user_selected_plan)) ? $user_selected_plan : ''; if (!empty($orderPlans)) { $pi = 1; foreach ($orderPlans as $plan) { $plan_id = $plan['arm_subscription_plan_id']; /* if no plan selected than set first plan default selected */ if ($pi == 1 && $user_selected_plan == '') { $user_selected_plan = $plan_id; } $planClass = 'arm_membership_setup_plans_li_' . $plan_id; $planClass .= (!in_array($plan_id, $selectedPlans) ? ' hidden_section ' : ''); $planOrderList .= '
  • '; $planOrderList .= '
    '; $planOrderList .= ''; $planOrderList .= ''; $planOrderList .= ''; $planOrderList .= '
  • '; $pi++; } } return $planOrderList; } function arm_setup_form_list_options() { global $wp, $wpdb, $ARMember, $arm_member_forms; $registerForms = $arm_member_forms->arm_get_member_forms_by_type('registration', false); $formList = '
  • ' . __('Select Form', 'ARMember') . '
  • '; if (!empty($registerForms)) { foreach ($registerForms as $form) { $formList .= '
  • ' . strip_tags(stripslashes($form['arm_form_label'])) . '
  • '; } } return $formList; } function arm_setup_gateway_list_options($selectedGateways = array(), $activeGateways = array(), $selectedPaymentModes = array(), $selectedPlans = array(), $plan_object_array = array()) { global $wp, $wpdb, $ARMember, $arm_payment_gateways, $arm_subscription_plans; $gatewayList = ''; $arm_display_payment_mode_box = 'display: none;'; if (!empty($selectedPlans) && count($selectedPlans) > 0) { foreach ($selectedPlans as $plan) { $planObj = $plan_object_array[$plan]; if(is_object($planObj)){ $plan_type = $planObj->type; $plan_options = $planObj->options; $arm_show_plan_payment_cycles = (isset($plan_options['show_payment_cycle']) && $plan_options['show_payment_cycle'] == '1') ? 1 : 0; if ($planObj->is_recurring() || ($plan_type == 'paid_finite' && $arm_show_plan_payment_cycles == 1)) { $arm_display_payment_mode_box = 'display: block;'; } } } } if (!empty($activeGateways)) { $doNotDisplayPaymentMode = array('bank_transfer'); $doNotDisplayPaymentMode = apply_filters('arm_not_display_payment_mode_setup', $doNotDisplayPaymentMode); foreach ($activeGateways as $key => $pg) { $selectedPaymentModes[$key] = isset($selectedPaymentModes[$key]) ? $selectedPaymentModes[$key] : 'both'; $checked_auto = ($selectedPaymentModes[$key] == 'auto_debit_subscription') ? 'checked="checked"' : ''; $checked_manual = ($selectedPaymentModes[$key] == 'manual_subscription') ? 'checked="checked"' : ''; $checked_both = ($selectedPaymentModes[$key] == 'both') ? 'checked="checked"' : ''; $gatewayChecked = in_array($key, $selectedGateways) ? 'checked="checked"' : ''; if (in_array($key, $selectedGateways)) { $display_payment_mode = 'display: block;'; } else { $display_payment_mode = 'display: none;'; } $gatewayList .= '
    '; $gatewayList .= ''; $gatewayList .= ''; if (!in_array($key, $doNotDisplayPaymentMode)) { $gateway_note = ''; $gateway_note = apply_filters('arm_setup_show_payment_gateway_notice', $gateway_note, $key); $gatewayList .= '




    ' . $gateway_note . '
    '; } if (in_array($key, $doNotDisplayPaymentMode)) { $gatewayList .= ''; } $gatewayList .= '
    '; } } return $gatewayList; } function arm_total_setups() { global $wpdb,$ARMember; $setup_count = $wpdb->get_var("SELECT COUNT(`arm_setup_id`) FROM `" . $ARMember->tbl_arm_membership_setup . "`"); return $setup_count; } function arm_get_membership_setup($setup_id = 0) { global $wp, $wpdb, $current_user, $ARMember, $arm_global_settings; if (is_numeric($setup_id) && $setup_id != 0) { /* Query Monitor Change */ if( isset($GLOBALS['arm_setup_data']) && isset($GLOBALS['arm_setup_data'][$setup_id]) ){ $setup_data = $GLOBALS['arm_setup_data'][$setup_id]; } else { $setup_data = $wpdb->get_row("SELECT * FROM `" . $ARMember->tbl_arm_membership_setup . "` WHERE `arm_setup_id`='" . $setup_id . "'", ARRAY_A); if( !isset($GLOBALS['arm_setup_data']) ){ $GLOBALS['arm_setup_data'] = array(); } $GLOBALS['arm_setup_data'][$setup_id] = $setup_data; } if (!empty($setup_data)) { $setup_data['arm_setup_name'] = (!empty($setup_data['arm_setup_name'])) ? stripslashes($setup_data['arm_setup_name']) : ''; $setup_data['arm_setup_modules'] = maybe_unserialize($setup_data['arm_setup_modules']); $setup_data['arm_setup_labels'] = maybe_unserialize($setup_data['arm_setup_labels']); $setup_data['setup_name'] = $setup_data['arm_setup_name']; $setup_data['setup_modules'] = $setup_data['arm_setup_modules']; $setup_data['setup_labels'] = $setup_data['arm_setup_labels']; } return $setup_data; } else { return FALSE; } } function arm_save_membership_setups_func($posted_data = array()) { global $wp, $wpdb, $current_user, $arm_slugs, $ARMember, $arm_global_settings, $arm_payment_gateways; $redirect_to = admin_url('admin.php?page=' . $arm_slugs->membership_setup); if (isset($posted_data) && !empty($posted_data) && in_array($posted_data['form_action'], array('add', 'update'))) { $setup_data = $posted_data['setup_data']; if (!empty($setup_data)) { $setup_name = (!empty($setup_data['setup_name'])) ? $setup_data['setup_name'] : __('Untitled Setup', 'ARMember'); $setup_modules = (!empty($setup_data['setup_modules'])) ? $setup_data['setup_modules'] : array(); $setup_labels = (!empty($setup_data['setup_labels'])) ? $setup_data['setup_labels'] : array(); $payment_gateways = $arm_payment_gateways->arm_get_all_payment_gateways_for_setup(); foreach ($payment_gateways as $pgkey => $gateway) { if ($setup_labels['payment_gateway_labels'][$pgkey] == '') { $setup_labels['payment_gateway_labels'][$pgkey] = $gateway['gateway_name']; } } if (!empty($setup_modules['modules']['module_order'])) { asort($setup_modules['modules']['module_order']); } $db_data = array( 'arm_setup_name' => $setup_name, 'arm_setup_modules' => maybe_serialize($setup_modules), 'arm_setup_labels' => maybe_serialize($setup_labels), ); if ($posted_data['form_action'] == 'add') { $db_data['arm_status'] = 1; $db_data['arm_created_date'] = date('Y-m-d H:i:s'); /* Insert Form Fields. */ $wpdb->insert($ARMember->tbl_arm_membership_setup, $db_data); $setup_id = $wpdb->insert_id; /* Action After Adding Setup Details */ do_action('arm_saved_membership_setup', $setup_id, $db_data); $ARMember->arm_set_message('success', __('Membership setup wizard has been added successfully.', 'ARMember')); $redirect_to = $arm_global_settings->add_query_arg("action", "edit_setup", $redirect_to); $redirect_to = $arm_global_settings->add_query_arg("id", $setup_id, $redirect_to); wp_redirect($redirect_to); exit; } elseif ($posted_data['form_action'] == 'update' && !empty($posted_data['id']) && $posted_data['id'] != 0) { $setup_id = $posted_data['id']; $field_update = $wpdb->update($ARMember->tbl_arm_membership_setup, $db_data, array('arm_setup_id' => $setup_id)); /* Action After Updating Setup Details */ do_action('arm_saved_membership_setup', $setup_id, $db_data); $ARMember->arm_set_message('success', __('Membership setup wizard has been updated successfully.', 'ARMember')); $redirect_to = $arm_global_settings->add_query_arg("action", "edit_setup", $redirect_to); $redirect_to = $arm_global_settings->add_query_arg("id", $setup_id, $redirect_to); wp_redirect($redirect_to); exit; } } } return; } function arm_delete_single_setup() { global $wp, $wpdb, $current_user, $ARMember, $arm_members_class, $arm_member_forms, $arm_global_settings, $arm_capabilities_global; $ARMember->arm_check_user_cap($arm_capabilities_global['arm_manage_setups'], '1'); $action = esc_attr($_POST['act']); $id = intval($_POST['id']); if ($action == 'delete') { if (empty($id)) { $errors[] = __('Invalid action.', 'ARMember'); } else { if (!current_user_can('arm_manage_setups')) { $errors[] = __('Sorry, You do not have permission to perform this action', 'ARMember'); } else { $res_var = $wpdb->delete($ARMember->tbl_arm_membership_setup, array('arm_setup_id' => $id)); if ($res_var) { $message = __('Setup has been deleted successfully.', 'ARMember'); } } } } $return_array = $arm_global_settings->handle_return_messages(@$errors, @$message); echo json_encode($return_array); exit; } function arm_setup_shortcode_preview_func() { global $wpdb, $ARMember, $arm_capabilities_global; if (isset($_POST['action']) && $_POST['action'] == 'arm_setup_shortcode_preview' & isset($_POST['setup_data'])) { $user = wp_get_current_user(); $setup_id = intval($_POST['id']); $setupData = esc_attr($_POST['setup_data']); $ARMember->arm_check_user_cap($arm_capabilities_global['arm_manage_setups'], '1'); ?> set_front_css(true); $ARMember->set_front_js(true); } function arm_setup_skin_default_color_array() { $font_colors = array( 'skin1' => array( 'arm_setup_plan_title_font_color' => '#616161', 'arm_setup_plan_desc_font_color' => '#616161', 'arm_setup_price_font_color' => '#616161', 'arm_setup_summary_font_color' => '#616161', 'arm_setup_selected_plan_title_font_color' => '#23b7e5', 'arm_setup_selected_plan_desc_font_color' => '#616161', 'arm_setup_selected_price_font_color' => '#ffffff', 'arm_setup_bg_active_color' => '#23b7e5' ), 'skin2' => array( 'arm_setup_plan_title_font_color' => '#616161', 'arm_setup_plan_desc_font_color' => '#616161', 'arm_setup_price_font_color' => '#616161', 'arm_setup_summary_font_color' => '#616161', 'arm_setup_selected_plan_title_font_color' => '#ffffff', 'arm_setup_selected_plan_desc_font_color' => '#616161', 'arm_setup_selected_price_font_color' => '#23b7e5', 'arm_setup_bg_active_color' => '#23b7e5' ), 'skin3' => array( 'arm_setup_plan_title_font_color' => '#616161', 'arm_setup_plan_desc_font_color' => '#616161', 'arm_setup_price_font_color' => '#616161', 'arm_setup_summary_font_color' => '#616161', 'arm_setup_selected_plan_title_font_color' => '#616161', 'arm_setup_selected_plan_desc_font_color' => '#616161', 'arm_setup_selected_price_font_color' => '#616161', 'arm_setup_bg_active_color' => '#23b7e5' ), 'skin4' => array( 'arm_setup_plan_title_font_color' => '#616161', 'arm_setup_plan_desc_font_color' => '#616161', 'arm_setup_price_font_color' => '#616161', 'arm_setup_summary_font_color' => '#616161', 'arm_setup_selected_plan_title_font_color' => '#ffffff', 'arm_setup_selected_plan_desc_font_color' => '#ffffff', 'arm_setup_selected_price_font_color' => '#ffffff', 'arm_setup_bg_active_color' => '#23b7e5' ), 'skin5' => array( 'arm_setup_plan_title_font_color' => '#616161', 'arm_setup_plan_desc_font_color' => '#616161', 'arm_setup_price_font_color' => '#616161', 'arm_setup_summary_font_color' => '#616161', 'arm_setup_selected_plan_title_font_color' => '#23b7e5', 'arm_setup_selected_plan_desc_font_color' => '#616161', 'arm_setup_selected_price_font_color' => '#ffffff', 'arm_setup_bg_active_color' => '#23b7e5' ), 'skin6' => array( 'arm_setup_plan_title_font_color' => '#616161', 'arm_setup_plan_desc_font_color' => '#6b6e78', 'arm_setup_price_font_color' => '#616161', 'arm_setup_summary_font_color' => '#616161', 'arm_setup_selected_plan_title_font_color' => '#ffffff', 'arm_setup_selected_plan_desc_font_color' => '#ffffff', 'arm_setup_selected_price_font_color' => '#ffffff', 'arm_setup_bg_active_color' => '#23b7e5' ), ); return apply_filters('arm_membership_setup_skin_colors', $font_colors); } } } global $arm_membership_setup; $arm_membership_setup = new ARM_membership_setup();