0,
'message' => '',
);
/* Extract Shortcode Attributes */
$opts = shortcode_atts($defaults, $atts, $tag);
extract($opts);
/* ---------------------/.End Set Shortcode Attributes--------------------- */
if (!empty($id) && $id != 0) {
$user_id = get_current_user_id();
if (!empty($user_id) && $user_id != 0) {
$user_plans = get_user_meta($user_id, 'arm_user_plan_ids', true);
$user_plans = !empty($user_plans) ? $user_plans : array();
if (in_array($id, $user_plans)) {
return do_shortcode($content);
}
}
}
return $message;
}
function arm_plan_not_shortcode_func($atts, $content, $tag) {
if (current_user_can('administrator')) {
return do_shortcode($content);
}
global $wp, $wpdb, $current_user, $arm_errors, $ARMember, $arm_global_settings, $arm_subscription_plans;
/* ---------------------/.Begin Set Shortcode Attributes--------------------- */
$defaults = array(
'id' => 0,
'message' => '',
);
/* Extract Shortcode Attributes */
$opts = shortcode_atts($defaults, $atts, $tag);
extract($opts);
/* ---------------------/.End Set Shortcode Attributes--------------------- */
if (!empty($id) && $id != 0) {
$user_id = get_current_user_id();
if (!empty($user_id) && $user_id != 0) {
$user_plans = get_user_meta($user_id, 'arm_user_plan_ids', true);
$user_plans = !empty($user_plans) ? $user_plans : array();
if (!in_array($id, $user_plans)) {
return do_shortcode($content);
}
}
}
return $message;
}
function arm_restrict_content_shortcode_func($atts, $content, $tag) {
global $ARMember;
$arm_check_is_gutenberg_page = $ARMember->arm_check_is_gutenberg_page();
if($arm_check_is_gutenberg_page)
{
return;
}
/* ---------------------/.Begin Set Shortcode Attributes--------------------- */
$defaults = array(
'type' => 'hide', /* Shortcode behaviour type */
'plan' => '', /* Plan Id or comma separated plan ids. */
);
/* Extract Shortcode Attributes */
$opts = shortcode_atts($defaults, $atts, $tag);
extract($opts);
/* ---------------------/.End Set Shortcode Attributes--------------------- */
global $wp, $wpdb, $current_user, $arm_errors, $ARMember, $arm_global_settings, $arm_subscription_plans;
$main_content = $else_content = NULL;
$else_tag = '[armelse]';
if (strpos($content, $else_tag) !== FALSE) {
list($main_content, $else_content) = explode($else_tag, $content, 2);
} else {
$main_content = $content;
}
/* Always Display Content For Admins */
if (current_user_can('administrator')) {
return do_shortcode($main_content);
}
$hasaccess = FALSE;
$isLoggedIn = is_user_logged_in();
$current_user_id = get_current_user_id();
$arm_user_plan = get_user_meta($current_user_id, 'arm_user_plan_ids', true);
$arm_user_plan = !empty($arm_user_plan) ? $arm_user_plan : array();
if(!empty($arm_user_plan)){
$suspended_plan_ids = get_user_meta($current_user_id, 'arm_user_suspended_plan_ids', true);
if( ! empty($suspended_plan_ids)) {
foreach ($suspended_plan_ids as $suspended_plan_id) {
if(in_array($suspended_plan_id, $arm_user_plan)) {
unset($arm_user_plan[array_search($suspended_plan_id, $arm_user_plan)]);
}
}
}
}
if (!empty($plan)) {
/* Plans Section */
if (strpos($plan, ",")) {
$plans = explode(",", $plan);
} else {
$plans = array($plan);
}
$plans = array_filter($plans);
$registered = FALSE;
if (in_array('registered', $plans)) {
$registered = TRUE;
$rkey = array_search('registered', $plans);
unset($plans[$rkey]);
}
$unregistered = FALSE;
if (in_array('unregistered', $plans)) {
$unregistered = TRUE;
$ukey = array_search('unregistered', $plans);
unset($plans[$ukey]);
}
$return_array = array_intersect($arm_user_plan, $plans);
if ($type == 'show') {
if ($isLoggedIn) {
if ($registered) {
$hasaccess = TRUE;
}
if (!empty($plans) && !empty($return_array)) {
$hasaccess = TRUE;
}
if(!empty($arm_user_plan) && in_array("any_plan", $plans)) {
$hasaccess = TRUE;
}
} else {
/* Show Content To Non LoggedIn Members */
if ($unregistered) {
$hasaccess = TRUE;
}
}
} else {
if ($isLoggedIn) {
/* Need to check this condition and confirm */
if ($unregistered) {
$hasaccess = TRUE;
}
/* Need to check this condition and confirm */
if (!empty($plans) && empty($return_array)) {
$hasaccess = TRUE;
}
if(!empty($arm_user_plan) && in_array('any_plan', $plans)) {
$hasaccess = FALSE;
}
} else {
/* Hide Content From Non LoggedIn Members */
if (!$unregistered) {
$hasaccess = TRUE;
}
}
}
} else {
if ($type == 'show') {
$hasaccess = TRUE;
}
}
$hasaccess = apply_filters('arm_restrict_content_shortcode_hasaccess', $hasaccess, $opts);
if ($hasaccess) {
return do_shortcode($main_content);
} else {
return do_shortcode($else_content);
}
}
function arm_if_user_in_trial_func($atts, $content, $tag) {
global $ARMember;
$arm_check_is_gutenberg_page = $ARMember->arm_check_is_gutenberg_page();
if($arm_check_is_gutenberg_page)
{
return;
}
$main_content = $content;
$else_content = NULL;
/* Always Display Content For Admins */
if (current_user_can('administrator')) {
return do_shortcode($main_content);
}
$hasaccess = FALSE;
if (is_user_logged_in()) {
$current_user_id = get_current_user_id();
$arm_user_plans = get_user_meta($current_user_id, 'arm_user_plan_ids', true);
$hasaccess = FALSE;
if (!empty($arm_user_plans) && is_array($arm_user_plans)) {
foreach ($arm_user_plans as $arm_user_plan) {
/* Plans Section */
$planData = get_user_meta($current_user_id, 'arm_user_plan_' . $arm_user_plan, true);
if (!empty($planData)) {
$planDetail = $planData['arm_current_plan_detail'];
if (!empty($planDetail)) {
$plan_info = new ARM_Plan(0);
$plan_info->init((object) $planDetail);
} else {
$plan_info = new ARM_Plan($arm_user_plan);
}
if ($plan_info->is_recurring()) {
$arm_is_trial = $planData['arm_is_trial_plan'];
if ($arm_is_trial == 1) {
$arm_plan_trial_expiry_date = $planData['arm_trial_end'];
if ($arm_plan_trial_expiry_date != '') {
$now = current_time('timestamp');
if ($now <= $arm_plan_trial_expiry_date) {
$hasaccess = TRUE;
break;
}
}
}
}
}
}
}
}
$main_content = apply_filters('arm_is_user_in_trial_shortcode_content', $main_content);
$else_content = apply_filters('arm_is_user_in_trial_shortcode_else_content', $else_content);
$hasaccess = apply_filters('arm_is_user_in_trial_shortcode_hasaccess', $hasaccess);
if ($hasaccess) {
return do_shortcode($main_content);
} else {
return do_shortcode($else_content);
}
}
function arm_not_if_user_in_trial_func($atts, $content, $tag) {
global $ARMember;
$arm_check_is_gutenberg_page = $ARMember->arm_check_is_gutenberg_page();
if($arm_check_is_gutenberg_page)
{
return;
}
$main_content = $content;
$else_content = NULL;
/* Always Display Content For Admins */
if (current_user_can('administrator')) {
return do_shortcode($main_content);
}
$hasaccess = FALSE;
if (is_user_logged_in()) {
$current_user_id = get_current_user_id();
$arm_user_plans = get_user_meta($current_user_id, 'arm_user_plan_ids', true);
if (!empty($arm_user_plans) && is_array($arm_user_plans)) {
foreach ($arm_user_plans as $arm_user_plan) {
$hasaccess = FALSE;
/* Plans Section */
$planData = get_user_meta($current_user_id, 'arm_user_plan_' . $arm_user_plan, true);
$planDetail = $planData['arm_current_plan_detail'];
if (!empty($planDetail)) {
$plan_info = new ARM_Plan(0);
$plan_info->init((object) $planDetail);
} else {
$plan_info = new ARM_Plan($arm_user_plan);
}
if ($plan_info->is_recurring()) {
$arm_is_trial = $planData['arm_is_trial_plan'];
if ($arm_is_trial == 1) {
$arm_plan_trial_expiry_date = $planData['arm_trial_end'];
if ($arm_plan_trial_expiry_date != '') {
$now = current_time('timestamp');
if ($now > $arm_plan_trial_expiry_date) {
$hasaccess = TRUE;
}
}
} else {
$hasaccess = TRUE;
}
} else {
$hasaccess = TRUE;
}
if ($hasaccess == FALSE) {
break;
}
}
} else {
$hasaccess = TRUE;
}
}
$main_content = apply_filters('arm_not_is_user_in_trial_shortcode_content', $main_content);
$else_content = apply_filters('arm_not_is_user_in_trial_shortcode_else_content', $else_content);
$hasaccess = apply_filters('arm_not_is_user_in_trial_shortcode_hasaccess', $hasaccess);
if ($hasaccess) {
return do_shortcode($main_content);
} else {
return do_shortcode($else_content);
}
}
function arm_content_shortcode_func($atts, $content, $tag) {
global $ARMember;
$arm_check_is_gutenberg_page = $ARMember->arm_check_is_gutenberg_page();
if($arm_check_is_gutenberg_page)
{
return;
}
/* Always Display Content For Admins */
if (current_user_can('administrator')) {
return do_shortcode($content);
}
/* ---------------------/.Begin Set Shortcode Attributes--------------------- */
$defaults = array(
'plan' => 'all', /* Plan Id or comma separated plan ids. */
'message' => '', /* Message for restricted area. */
);
/* Extract Shortcode Attributes */
$opts = shortcode_atts($defaults, $atts, $tag);
extract($opts);
/* ---------------------/.End Set Shortcode Attributes--------------------- */
global $wp, $wpdb, $current_user, $arm_errors, $ARMember, $arm_global_settings, $arm_subscription_plans;
$hasaccess = TRUE;
/* Check if User is logged in */
if (is_user_logged_in()) {
$user_id = $current_user->ID;
$arm_user_plan = get_user_meta($user_id, 'arm_user_plan_ids', true);
$arm_user_plan = !empty($arm_user_plan) ? $arm_user_plan : array();
/* Plans Section */
if (strpos($plan, ",")) {
$plans = explode(",", $plan);
} else {
$plans = array($plan);
}
$return_array = array_intersect($arm_user_plan, $plans);
if ($plan != 'all' && (!empty($plans) && empty($return_array))) {
$hasaccess = FALSE;
}
} else {
$hasaccess = FALSE;
}
$hasaccess = apply_filters('arm_content_shortcode_hasaccess', $hasaccess);
if ($hasaccess) {
return do_shortcode($content);
} else {
return $message;
}
}
function arm_not_login_content_shortcode_func($atts, $content, $tag) {
global $ARMember;
$arm_check_is_gutenberg_page = $ARMember->arm_check_is_gutenberg_page();
if($arm_check_is_gutenberg_page)
{
return;
}
/* ---------------------/.Begin Set Shortcode Attributes--------------------- */
/* Extract Shortcode Attributes */
$opts = shortcode_atts(array('message' => ''), $atts, $tag);
extract($opts);
/* ---------------------/.End Set Shortcode Attributes--------------------- */
if (!is_user_logged_in()) {
$content = do_shortcode($content);
} else {
$content = $message;
}
return $content;
}
/**
* Directory Template AJAX Pagination Content
*/
function arm_directory_paging_action() {
global $wpdb, $ARMember, $arm_global_settings, $arm_members_directory, $arm_members_class;
if (isset($_POST['action']) && $_POST['action'] == 'arm_directory_paging_action') {
unset($_POST['action']);
$content = '';
if (!empty($_POST)) {
if (isset($_POST['temp_data']) && !empty($_POST['temp_data'])) {
$_POST['temp_data'] = stripslashes($_POST['temp_data']);
}
if (isset($_POST['pagination']) && $_POST['pagination'] == 'infinite') {
$opts = $_POST;
if ($opts['id'] == 'add') {
$temp_data = maybe_unserialize($opts['temp_data']);
$temp_data = (object) $temp_data;
} else {
$temp_data = $wpdb->get_row("SELECT * FROM `" . $ARMember->tbl_arm_member_templates . "` WHERE `arm_id`='{$opts['id']}' AND `arm_type`='{$opts['type']}'");
}
if (!empty($temp_data)) {
$temp_data->arm_options = isset($temp_data->arm_options) ? maybe_unserialize($temp_data->arm_options) : array();
$opts['template_options'] = $temp_data->arm_options;
$opts['current_page'] = (isset($opts['current_page'])) ? $opts['current_page'] : 1;
$opts['pagination'] = (isset($opts['template_options']['pagination'])) ? $opts['template_options']['pagination'] : 'numeric';
$opts['show_joining'] = (isset($opts['template_options']['show_joining']) && $opts['template_options']['show_joining'] == '1') ? true : false;
$opts['show_admin_users'] = (isset($opts['template_options']['show_admin_users']) && $opts['template_options']['show_admin_users'] == '1') ? true : false;
$content = $arm_members_directory->arm_get_directory_members($temp_data, $opts);
}
} else {
$shortcode_param = '';
foreach ($_POST as $k => $v) {
$shortcode_param .= "{$k}='{$v}' ";
}
$content = do_shortcode("[arm_template $shortcode_param]");
}
echo do_shortcode($content);
exit;
}
}
}
function arm_template_shortcode_func($atts, $content, $tag) {
global $wpdb, $ARMember, $arm_global_settings, $arm_members_directory, $arm_members_class, $arm_social_feature;
$arm_check_is_gutenberg_page = $ARMember->arm_check_is_gutenberg_page();
if($arm_check_is_gutenberg_page)
{
return;
}
if (!$arm_social_feature->isSocialFeature) {
return do_shortcode($content);
}
$common_messages = $arm_global_settings->arm_get_all_common_message_settings();
$alphabaticalSortByTxt = (!empty($common_messages['directory_sort_by_alphabatically'])) ? $common_messages['directory_sort_by_alphabatically'] : __('Alphabetically', 'ARMember');
$recentlyJoinedTxt = (!empty($common_messages['directory_sort_by_recently_joined'])) ? $common_messages['directory_sort_by_recently_joined'] : __('Recently Joined', 'ARMember');
/* ---------------------/.Begin Set Shortcode Attributes./--------------------- */
/* Extract Shortcode Attributes */
$opts = shortcode_atts(array(
'id' => '',
'type' => '',
'user_id' => 0,
'role' => 'all',
'listof' => 'all',
'search' => '',
'orderby' => 'display_name',
'order' => 'ASC',
'current_page' => 1,
'per_page' => 10,
'pagination' => 'numeric',
'sample' => false,
'temp_data' => '',
'is_preview' => 0,
), $atts, $tag);
extract($opts);
$opts['listof'] = (!empty($opts['listof'])) ? $opts['listof'] : 'all';
$opts['sample'] = ($opts['sample'] === 'true' || $opts['sample'] === '1') ? true : false;
$opts['is_preview'] = ($opts['is_preview'] === 'true' || $opts['is_preview'] === '1') ? 1 : 0;
/* ---------------------/.End Set Shortcode Attributes./--------------------- */
$date_format = $arm_global_settings->arm_get_wp_date_format();
$pd_templates = array();
if (!empty($id) && !empty($type)) {
$user_id = 0;
if($type == 'profile'){
$current_user_info = false;
global $wp_query;
$reqUser = $wp_query->get('arm_user');
if (empty($reqUser)) {
$reqUser = (isset($_REQUEST['arm_user']) && !empty($_REQUEST['arm_user'])) ? $_REQUEST['arm_user'] : '';
}
if (!empty($reqUser)) {
$permalinkBase = isset($arm_global_settings->global_settings['profile_permalink_base']) ? $arm_global_settings->global_settings['profile_permalink_base'] : 'user_login';
if ($permalinkBase == 'user_login') {
$current_user_info = get_user_by('login', urldecode($reqUser));
} else {
$current_user_info = get_user_by('id', $reqUser);
}
if ($current_user_info !== false) {
$user_id = $current_user_info->ID;
} else {
return do_shortcode($content);
}
} else {
if (is_user_logged_in()) {
$user_id = get_current_user_id();
$current_user_info = get_user_by('id', $user_id);
} else {
return do_shortcode($content);
}
}
if($current_user_info!=false)
{
$arm_member_statuses = $wpdb->get_row("SELECT `arm_primary_status`, `arm_secondary_status` FROM `" . $ARMember->tbl_arm_members . "` WHERE `arm_user_id`='" . $user_id . "' ");
$arm_member_status = '';
if ($arm_member_statuses != null) {
$arm_member_status = $arm_member_statuses->arm_primary_status;
$arm_member_secondary_status = $arm_member_statuses->arm_secondary_status;
if (($arm_member_status == '2' && in_array($arm_member_secondary_status, array(0, 1))) || $arm_member_status == 4) {
$current_user_info = false;
}
}
}
}
$is_admin_user = $display_admin_user = 0;
if( user_can($user_id,'administrator') ){
$is_admin_user = 1;
}
if ($id == 'add') {
$temp_data = maybe_unserialize($opts['temp_data']);
$temp_data = (object) $temp_data;
} else {
if($type == 'profile'){
$user_plans = get_user_meta($user_id, 'arm_user_plan_ids', true);
$temp_id_admin = $wpdb->get_row($wpdb->prepare('SELECT `arm_id` FROM `'. $ARMember->tbl_arm_member_templates.'` WHERE `arm_enable_admin_profile` = %d ORDER BY `arm_id` ASC LIMIT %d',1,1));
$admin_template_data = array();
if(empty($user_plans) || $is_admin_user ){
if( $is_admin_user && isset($temp_id_admin->arm_id) && $temp_id_admin->arm_id > 0 && $temp_id_admin->arm_id != '' ){
$temp_data = $wpdb->get_row("SELECT * FROM `" . $ARMember->tbl_arm_member_templates . "` WHERE `arm_id`='{$temp_id_admin->arm_id}' AND `arm_type`='{$type}'");
$display_admin_user = 1;
} else {
$temp_data = $wpdb->get_row("SELECT * FROM `" . $ARMember->tbl_arm_member_templates . "` WHERE `arm_id`='{$id}' AND `arm_type`='{$type}'");
}
}else{
foreach($user_plans as $user_plan){
$temp_count = $wpdb->get_var("SELECT count(*) FROM `" . $ARMember->tbl_arm_member_templates . "` WHERE FIND_IN_SET(" . $user_plan . ", `arm_subscription_plan`) AND `arm_type`='{$type}'");
if($temp_count > 0){
$temp_data = $wpdb->get_row("SELECT * FROM `" . $ARMember->tbl_arm_member_templates . "` WHERE FIND_IN_SET(" . $user_plan . ", `arm_subscription_plan`) AND `arm_type`='{$type}' LIMIT 0,1");
break;
}
}
if($temp_count == 0){
$temp_data = $wpdb->get_row("SELECT * FROM `" . $ARMember->tbl_arm_member_templates . "` WHERE `arm_id`='{$id}' AND `arm_type`='{$type}'");
}
}
if (file_exists(MEMBERSHIPLITE_VIEWS_DIR . '/templates/' . $temp_data->arm_slug.'.css')) {
wp_enqueue_style('arm_template_style_' . $temp_data->arm_slug, MEMBERSHIPLITE_VIEWS_URL . '/templates/' . $temp_data->arm_slug . '.css', array(), MEMBERSHIPLITE_VERSION);
}
}
else{
$temp_data = $wpdb->get_row("SELECT * FROM `" . $ARMember->tbl_arm_member_templates . "` WHERE `arm_id`='{$id}' AND `arm_type`='{$type}'");
}
}
if (!empty($temp_data)) {
$temp_data->arm_options = isset($temp_data->arm_options) ? maybe_unserialize($temp_data->arm_options) : array();
$opts['template_options'] = $temp_data->arm_options;
$opts['pagination'] = (isset($opts['template_options']['pagination'])) ? $opts['template_options']['pagination'] : 'numeric';
$opts['per_page'] = (isset($opts['template_options']['per_page_users'])) ? $opts['template_options']['per_page_users'] : 10;
$opts['show_admin_users'] = isset($display_admin_user) && $display_admin_user == 1 ? true : false;
$opts['show_joining'] = (isset($opts['template_options']['show_joining']) && $opts['template_options']['show_joining'] == '1') ? true : false;
$_data = array();
$content = apply_filters('arm_change_content_before_display_profile_and_directory', $content, $opts);
$randomTempID = $id . '_' . arm_generate_random_code();
$content .= '
';
$all_global_settings = $arm_global_settings->arm_get_all_global_settings();
$general_settings = $all_global_settings['general_settings'];
$enable_crop = isset($general_settings['enable_crop']) ? $general_settings['enable_crop'] : 1;
if($enable_crop){
$content .='
';
$content .='';
$content .='
';
$content .='
';
$content .='';
$content .='';
$content .='
';
$content .='
' . __('(Use Cropper to set image and
use mouse scroller for zoom image.)', 'ARMember') . '
';
$content .='
';
$content .='
';
$content .='';
$content .='
';
$content .='
';
$content .='';
$content .='';
$content .='
';
$content .='
' . __('(Use Cropper to set image and use mouse scroller for zoom image.)', 'ARMember') . '
';
$content .='
';
}
$content .= $arm_members_directory->arm_template_style($id, $opts['template_options']);
$arm_profile_form_rtl = $arm_directory_form_rtl = '';
if (is_rtl()) {
$arm_profile_form_rtl = 'arm_profile_form_rtl';
$arm_directory_form_rtl = 'arm_directory_form_rtl';
}
if ($type == 'profile') {
$content .= '
';
if (!empty($current_user_info)) {
$_data = array($current_user_info);
$_data = $arm_members_directory->arm_prepare_users_detail_for_template($_data, $opts);
$_data = apply_filters('arm_change_user_detail_before_display_in_profile_and_directory', $_data, $opts);
$content .= $arm_members_directory->arm_profile_template_blocks((array) $temp_data, $_data, $opts);
}
$content .= '
';
} elseif ($type == 'directory') {
$content .= '
';
}
$content .= '
';
$content .= '
';
$content = apply_filters('arm_change_content_after_display_profile_and_directory', $content, $opts);
}
}
$ARMember->arm_check_font_awesome_icons($content);
$inbuild = '';
$hiddenvalue = '';
$hostname = $_SERVER["SERVER_NAME"];
global $arm_members_activity, $arm_version;
$arm_request_version = get_bloginfo('version');
$hiddenvalue = '
';
return do_shortcode($content.$hiddenvalue);
}
/**
* Transaction AJAX Pagination Content
*/
function arm_transaction_paging_action() {
global $wpdb, $ARMember, $arm_global_settings, $arm_members_directory, $arm_members_class;
if (isset($_POST['action']) && $_POST['action'] == 'arm_transaction_paging_action') {
unset($_POST['action']);
if (!empty($_POST)) {
$shortcode_param = '';
foreach ($_POST as $k => $v) {
$shortcode_param .= $k . '="' . $v . '" ';
}
echo do_shortcode("[arm_member_transaction $shortcode_param]");
exit;
}
}
}
function arm_login_history_paging_action() {
global $wpdb, $ARMember, $arm_global_settings, $arm_members_directory, $arm_members_class;
if (isset($_POST['action']) && $_POST['action'] == 'arm_login_history_paging_action') {
unset($_POST['action']);
if (!empty($_POST)) {
$shortcode_param = '';
foreach ($_POST as $k => $v) {
$shortcode_param .= $k . '="' . $v . '" ';
}
echo do_shortcode("[arm_login_history $shortcode_param]");
exit;
}
}
}
function arm_member_transaction_func($atts, $content, $tag) {
global $ARMember;
$arm_check_is_gutenberg_page = $ARMember->arm_check_is_gutenberg_page();
if($arm_check_is_gutenberg_page)
{
return;
}
/* ====================/.Begin Set Shortcode Attributes./==================== */
$default_transaction_fields = __('Transaction ID', 'ARMember') . ',' . __('Plan', 'ARMember') . ',' . __('Payment Gateway', 'ARMember') . ',' . __('Payment Type', 'ARMember') . ',' . __('Transaction Status', 'ARMember') . ',' . __('Amount', 'ARMember') . ',' . __('Payment Date', 'ARMember');
$defaults = array(
'user_id' => '',
'title' => __('Transactions', 'ARMember'),
'current_page' => 0,
'per_page' => 5,
'message_no_record' => __('There is no any Transactions found', 'ARMember'),
'label' => 'transaction_id,plan,payment_gateway,payment_type,transaction_status,amount,payment_date',
'value' => $default_transaction_fields,
);
/* Extract Shortcode Attributes */
$args = shortcode_atts($defaults, $atts, $tag);
extract($args);
/* ====================/.End Set Shortcode Attributes./==================== */
global $wp, $wpdb, $current_user, $current_site, $arm_errors, $ARMember, $arm_transaction, $arm_global_settings, $arm_subscription_plans, $arm_payment_gateways, $bpopup_loaded;
$bpopup_loaded = 1;
$date_format = $arm_global_settings->arm_get_wp_date_format();
$date_time_format = $arm_global_settings->arm_get_wp_date_time_format();
$labels = explode(',', rtrim($args['label'], ','));
$values = explode(',', rtrim($args['value'], ','));
if (is_user_logged_in()) {
$user_id = $args['user_id'];
if (empty($user_id) || $user_id == 0 || $user_id == 'current') {
$user_id = get_current_user_id();
}
wp_enqueue_style('arm_form_style_css');
$offset = (!empty($current_page) && $current_page > 1) ? (($current_page - 1) * $per_page) : 0;
$trans_count = $arm_transaction->arm_get_total_transaction($user_id);
$transactions = $arm_transaction->arm_get_all_transaction($user_id, $offset, $per_page);
$content = apply_filters('arm_before_member_transaction_shortcode_content', $content, $args);
$content .= "";
$frontfontstyle = $arm_global_settings->arm_get_front_font_style();
//$content .=!empty($frontfontstyle['google_font_url']) ? '
' : '';
$content .=!empty($frontfontstyle['google_font_url']) ? wp_enqueue_style( 'google-font', $frontfontstyle['google_font_url'], array(), MEMBERSHIPLITE_VERSION ) : '';
$content .= '';
if (!empty($title)) {
$content .= '
' . $title . '
';
$content .= '
';
}
$content .= '
';
$content .= '';
$content .= "
";
$content = apply_filters('arm_after_member_transaction_shortcode_content', $content, $args);
}
return do_shortcode($content);
}
function arm_account_detail_shortcode_func($atts, $content, $tag) {
global $ARMember;
$arm_check_is_gutenberg_page = $ARMember->arm_check_is_gutenberg_page();
if($arm_check_is_gutenberg_page)
{
return;
}
/* ====================/.Begin Set Shortcode Attributes./==================== */
$atts = shortcode_atts(array(
'section' => 'profile', /* Values:-> `profile,membership,transactions,close_account,logout` */
'show_change_subscription' => false,
'change_subscription_url' => '',
'fields' => '',
'social_fields' => '',
'label' => 'first_name,last_name,user_login,user_email',
'value' => 'First Name,Last Name,Username,Email',
), $atts, $tag);
/* ====================/.End Set Shortcode Attributes./==================== */
global $wp, $wpdb, $current_user, $current_site, $ARMember, $arm_member_forms, $arm_global_settings, $arm_social_feature, $arm_members_activity;
$common_messages = $arm_global_settings->arm_get_all_common_message_settings();
$profileTabTxt = __('Profile', 'ARMember');
$membershipTabTxt = __('Membership', 'ARMember');
$transactionTabTxt = __('Transactions', 'ARMember');
$closeaccountTabTxt = __('Close Account', 'ARMember');
if (is_user_logged_in()) {
$user_id = get_current_user_id();
$defaultTabSettings = array(
'profile' => $profileTabTxt,
'membership' => $membershipTabTxt,
'transactions' => $transactionTabTxt,
'close_account' => $closeaccountTabTxt,
);
$atts['section'] = strtolower(str_replace(' ', '', $atts['section']));
$show_subscription = ($atts['show_change_subscription'] === 'true') ? true : false;
$sections = (!empty($atts['section'])) ? explode(',', $atts['section']) : array('profile');
$sections = $ARMember->arm_array_trim($sections);
$sections = $ARMember->arm_array_unique($sections);
$displaySections = array();
if (!empty($sections)) {
foreach ($defaultTabSettings as $tab => $title) {
if (in_array($tab, $sections)) {
$displaySections[] = $tab;
}
}
} else {
$displaySections[] = 'profile';
}
$content = apply_filters('arm_change_account_details_before_display', $content, $atts);
$frontfontstyle = $arm_global_settings->arm_get_front_font_style();
//$content .=!empty($frontfontstyle['google_font_url']) ? '' : '';
$content .=!empty($frontfontstyle['google_font_url']) ? wp_enqueue_style( 'google-font', $frontfontstyle['google_font_url'], array(), MEMBERSHIPLITE_VERSION ) : '';
$content .= '';
if (is_rtl()) {
$is_account_detail_class_rtl = 'is_account_detail_class_rtl';
} else {
$is_account_detail_class_rtl = '';
}
$content .= '';
if (count($displaySections) == 1) {
$content .= "
";
$content .= '
';
if ($tab == 'membership') {
$content .= $this->arm_account_detail_tab_content($displaySections[0], $user_id, $show_subscription);
} else {
$content .= $this->arm_account_detail_tab_content($displaySections[0], $user_id, false, $atts['fields'], $atts['social_fields'], array(), array(), $atts);
}
$content .= '
';
$content .= '
';
} else {
$tabLinks = $tabContent = $tabContentActiveClass = '';
$i = 0;
foreach ($displaySections as $tab) {
$tabLinkClass = 'arm_account_link_tab';
$tabBtnClass = 'arm_account_btn_tab';
$tabContentActiveClass = 'arm_account_content_right';
if ($i == 0) {
$tabLinkClass .= ($i == 0) ? ' arm_account_link_tab_active' : '';
$tabBtnClass .= ($i == 0) ? ' arm_account_btn_tab_active' : '';
$tabContentActiveClass = 'arm_account_content_active';
}
$tabLinks .= '
';
$tabLinks .= '' . $defaultTabSettings[$tab] . '';
$tabLinks .= '';
$tabContent .= '
';
$tabContent .= '
';
if ($tab == 'membership') {
$tabContent .= $this->arm_account_detail_tab_content($tab, $user_id, $show_subscription);
} else {
$tabContent .= $this->arm_account_detail_tab_content($tab, $user_id);
}
$tabContent .= '
';
$i++;
}
$tabLinks .= '
';
$content .= '
';
$content .= '
';
$content .= '
' . $tabContent . '
';
$content .= '
';
}
$content .= '
';
$content = apply_filters('arm_change_account_details_after_display', $content, $atts);
} else {
$default_login_form_id = $arm_member_forms->arm_get_default_form_id('login');
$arm_all_global_settings = $arm_global_settings->arm_get_all_global_settings();
$page_settings = $arm_all_global_settings['page_settings'];
$general_settings = $arm_all_global_settings['general_settings'];
$login_page_id = (isset($page_settings['login_page_id']) && $page_settings['login_page_id'] != '' && $page_settings['login_page_id'] != 404 ) ? $page_settings['login_page_id'] : 0;
if ($login_page_id == 0) {
if ($general_settings['hide_wp_login'] == 1) {
$login_page_url = ARMLITE_HOME_URL;
} else {
$referral_url = wp_get_current_page_url();
$referral_url = (!empty($referral_url) && $referral_url != '') ? $referral_url : wp_get_current_page_url();
$login_page_url = wp_login_url($referral_url);
}
} else {
$login_page_url = get_permalink($login_page_id) . '?arm_redirect=' . urlencode(wp_get_current_page_url());
}
if (preg_match_all('/arm_redirect/', $login_page_url, $match) < 2) {
wp_redirect($login_page_url);
}
}
return $content;
}
function arm_account_detail_tab_content($tab, $user_id = 0, $show_subscription = false, $fields = '', $social_fields = '', $renew_subscription_options = array(), $cancel_subscription_options = array(), $atts = array()) {
global $wp, $wpdb, $current_user, $current_site, $ARMember, $arm_member_forms, $arm_global_settings;
if (empty($renew_subscription_options)) {
$renew_subscription_options['display_renew_btn'] = "true";
$renew_subscription_options['renew_text'] = __('Renew', 'ARMember');
$renew_subscription_options['renew_url'] = '';
$renew_subscription_options['renew_css'] = '';
$renew_subscription_options['renew_hover_css'] = '';
}
if (empty($cancel_subscription_options)) {
$cancel_subscription_options['display_cancel_btn'] = "true";
$cancel_subscription_options['cancel_text'] = __('Cancel', 'ARMember');
$cancel_subscription_options['cancel_css'] = '';
$cancel_subscription_options['cancel_hover_css'] = '';
}
$content = $tabTitle = $tabTitleLinks = $tabContent = '';
$global_settings = $arm_global_settings->global_settings;
switch ($tab) {
case 'profile':
$tabTitle = __('Profile Detail', 'ARMember');
$tabContent = do_shortcode("[arm_view_profile fields='{$fields}' label='{$atts["label"]}' value='{$atts["value"]}' social_fields='{$social_fields}']");
if (isset($global_settings['edit_profile_page_id']) && $global_settings['edit_profile_page_id'] != 0) {
$editProfilePage = $arm_global_settings->arm_get_permalink('', $global_settings['edit_profile_page_id']);
$tabTitleLinks .= '' . __("Edit Profile", 'ARMember') . '';
}
/* $tabTitleLinks .= do_shortcode('[arm_logout label="Logout" type="link" user_info="false" redirect_to="' . ARMLITE_HOME_URL . '"]'); */
break;
case 'membership':
$tabTitle = ( isset($atts['title']) && !empty($atts['title'])) ? $atts['title'] : __('Current Membership', 'ARMember');
$label = "label=''";
$value = "value=''";
if (isset($atts) && !empty($atts)) {
$label = "label='" . $atts['membership_label'] . "'";
$value = "value='" . $atts['membership_value'] . "'";
}
$display_renew_btn = "display_renew_button='" . $renew_subscription_options['display_renew_btn'] . "'";
$renew_text = "renew_text='" . $renew_subscription_options['renew_text'] . "'";
$renew_url = "renew_url='" . $renew_subscription_options['renew_url'] . "'";
$renew_css = "renew_css='" . $renew_subscription_options['renew_css'] . "'";
$renew_hover_css = "renew_hover_css='" . $renew_subscription_options['renew_hover_css'] . "'";
$display_cancel_btn = "display_cancel_button='" . $cancel_subscription_options['display_cancel_btn'] . "'";
$cancel_text = "cancel_text='" . $cancel_subscription_options['cancel_text'] . "'";
$cancel_css = "cancel_css='" . $cancel_subscription_options['cancel_css'] . "'";
$cancel_hover_css = "cancel_hover_css='" . $cancel_subscription_options['cancel_hover_css'] . "'";
$shortcode = '[arm_subscription_detail ' . $label . ' ' . $value . ' ' . $display_renew_btn . ' ' . $renew_text . ' ' . $renew_url . ' ' . $renew_css . ' ' . $renew_hover_css . ' ' . $display_cancel_btn . ' ' . $cancel_text . ' ' . $cancel_css . ' ' . $cancel_hover_css . ']';
$tabContent = do_shortcode($shortcode);
if ($show_subscription) {
$tabTitleLinks = '' . __("Change Subscription", 'ARMember') . '';
}
break;
case 'transactions':
$tabTitle = __('Transaction History', 'ARMember');
$noRecordText = __('There is no any Transactions found', 'ARMember');
$tabContent = do_shortcode('[arm_member_transaction user_id="' . $user_id . '" title="" message_no_record="' . $noRecordText . '"]');
break;
case 'close_account':
$tabTitle = __('Close Account', 'ARMember');
$tabContent = do_shortcode('[arm_close_account]');
break;
case 'logout':
$tabContent = do_shortcode('[arm_logout label="Logout" type="link" user_info="false" redirect_to="' . ARMLITE_HOME_URL . '"]');
break;
default:
break;
}
if (!empty($tabTitle)) {
$content .= '' . $tabTitle . '
';
}
if (!empty($tabTitleLinks)) {
$content .= '' . $tabTitleLinks . '
';
}
$content .= '' . $tabContent . '
';
return $content;
}
function arm_view_profile_shortcode_func($atts, $content, $tag) {
global $ARMember;
$arm_check_is_gutenberg_page = $ARMember->arm_check_is_gutenberg_page();
if($arm_check_is_gutenberg_page)
{
return;
}
global $arm_global_settings;
/* ====================/.Begin Set Shortcode Attributes./==================== */
$atts = shortcode_atts(array(
'title' => __('', 'ARMember'),
'label' => 'first_name,last_name,user_login,user_email',
'fields' => '',
'value' => 'First Name,Last Name,Username,Email',
'social_fields' => '',
), $atts, $tag);
/* ====================/.End Set Shortcode Attributes./==================== */
if(!empty($atts['fields'])){
$display_fields = explode(',', rtrim($atts['fields'], ','));
$display_fields_value = array();
}
else{
$display_fields = explode(',', rtrim($atts['label'], ','));
$display_fields_value = explode(',', rtrim($atts['value'], ','));
}
$date_time_format = $arm_global_settings->arm_get_wp_date_format();
$social_fields = explode(',', rtrim($atts['social_fields'], ','));
global $wp, $wpdb, $wp_roles, $current_user, $current_site, $arm_errors, $ARMember, $arm_members_class, $arm_member_forms, $arm_global_settings, $arm_subscription_plans, $arm_social_feature, $arm_members_directory;
if (is_user_logged_in()) {
$dbFormFields = $arm_member_forms->arm_get_db_form_fields(true);
$user_id = get_current_user_id();
$user = get_user_by('id', $user_id);
$user_metas = get_user_meta($user_id);
$role_names = $wp_roles->get_names();
$content = '';
$content .= '';
$content .= '
';
$content .= '
';
} else {
$default_login_form_id = $arm_member_forms->arm_get_default_form_id('login');
return do_shortcode("[arm_form id='$default_login_form_id' is_referer='1']");
}
return $content;
}
function arm_close_account_shortcode_func($atts, $content, $tag) {
global $ARMember;
$arm_check_is_gutenberg_page = $ARMember->arm_check_is_gutenberg_page();
if($arm_check_is_gutenberg_page)
{
return;
}
/* ====================/.Begin Set Shortcode Attributes./==================== */
$atts = shortcode_atts(array(
'title' => __('', 'ARMember'),
'set_id' => __('', 'ARMember'),
'css' => __('', 'ARMember'),
), $atts, $tag);
/* ====================/.End Set Shortcode Attributes./==================== */
global $wp, $wpdb, $wp_roles, $current_user, $arm_errors, $ARMember, $arm_members_class, $arm_member_forms, $arm_global_settings;
$common_messages = $arm_global_settings->arm_get_all_common_message_settings();
$caFormTitle = isset($arm_global_settings->common_message['arm_form_title_close_account']) ? $arm_global_settings->common_message['arm_form_title_close_account'] : '';
$caFormDesc = isset($arm_global_settings->common_message['arm_form_description_close_account']) ? $arm_global_settings->common_message['arm_form_description_close_account'] : '';
$passwordFieldLabel = isset($arm_global_settings->common_message['arm_password_label_close_account']) ? $arm_global_settings->common_message['arm_password_label_close_account'] : __('Your Password', 'ARMember');
$submitBtnTxt = isset($arm_global_settings->common_message['arm_submit_btn_close_account']) ? $arm_global_settings->common_message['arm_submit_btn_close_account'] : __('Submit', 'ARMember');
$caBlankPassMsg = isset($arm_global_settings->common_message['arm_blank_password_close_account']) ? $arm_global_settings->common_message['arm_blank_password_close_account'] : __('Password cannot be left Blank.', 'ARMember');
if (is_user_logged_in()) {
do_action('arm_before_render_close_account_form', $atts);
$user_id = get_current_user_id();
$formRandomID = arm_generate_random_code();
$content = apply_filters('arm_before_close_account_shortcode_content', $content, $atts);
$validation_pos = 'bottom';
$field_position = 'left';
$form_style = array(
'form_title_position' => 'left'
);
if (!isset($atts['set_id']) || $atts['set_id'] == '') {
$setform_settings = $wpdb->get_row("SELECT `arm_form_id`, `arm_form_type`, `arm_form_settings`, `arm_set_name` FROM `" . $ARMember->tbl_arm_forms . "` WHERE `arm_form_type`='login' AND `arm_is_default`='1' ORDER BY arm_form_id DESC LIMIT 1");
} else {
$setform_settings = $wpdb->get_row("SELECT `arm_form_id`, `arm_form_type`, `arm_form_settings`, `arm_set_name` FROM `" . $ARMember->tbl_arm_forms . "` WHERE `arm_form_id` = '" . $atts['set_id'] . "' AND `arm_form_type`='login' ORDER BY arm_form_id DESC LIMIT 1");
if (empty($setform_settings)) {
$setform_settings = $wpdb->get_row("SELECT `arm_form_id`, `arm_form_type`, `arm_form_settings`, `arm_set_name` FROM `" . $ARMember->tbl_arm_forms . "` WHERE `arm_form_type`='login' AND `arm_is_default`='1' ORDER BY arm_form_id DESC LIMIT 1");
}
}
$set_style_option = maybe_unserialize($setform_settings->arm_form_settings);
$form_style = $set_style_option['style'];
$form_style_class = ' arm_form_close_account';
$form_style_class .= ' arm_form_layout_' . $form_style['form_layout'];
$form_style_class .= ($form_style['label_hide'] == '1') ? ' armf_label_placeholder' : '';
$form_style_class .= ' armf_alignment_' . $form_style['label_align'];
$form_style_class .= ' armf_layout_' . $form_style['label_position'];
$form_style_class .= ' armf_button_position_' . $form_style['button_position'];
$form_style_class .= ($form_style['rtl'] == '1') ? ' arm_form_rtl' : ' arm_form_ltr';
if (is_rtl()) {
$form_style_class .= ' arm_form_rtl';
$form_style_class .= ' arm_rtl_site';
} else {
$form_style_class .= ' arm_form_ltr';
}
$validation_pos = !empty($form_style['validation_position']) ? $form_style['validation_position'] : 'bottom';
$field_position = !empty($form_style['field_position']) ? $form_style['field_position'] : 'left';
$content .= $this->arm_close_account_form_style($setform_settings->arm_form_id, $formRandomID);
if (isset($atts['css']) && $atts['css'] != '') {
$content .= '';
}
$content .= '';
$content .= '
';
$content .= '
';
$content = apply_filters('arm_after_close_account_shortcode_content', $content, $atts);
} else {
$default_login_form_id = $arm_member_forms->arm_get_default_form_id('login');
$arm_all_global_settings = $arm_global_settings->arm_get_all_global_settings();
$page_settings = $arm_all_global_settings['page_settings'];
$general_settings = $arm_all_global_settings['general_settings'];
$login_page_id = (isset($page_settings['login_page_id']) && $page_settings['login_page_id'] != '' && $page_settings['login_page_id'] != 404 ) ? $page_settings['login_page_id'] : 0;
if ($login_page_id == 0) {
if ($general_settings['hide_wp_login'] == 1) {
$login_page_url = ARMLITE_HOME_URL;
} else {
$referral_url = wp_get_current_page_url();
$referral_url = (!empty($referral_url) && $referral_url != '') ? $referral_url : wp_get_current_page_url();
$login_page_url = wp_login_url($referral_url);
}
} else {
$login_page_url = get_permalink($login_page_id) . '?arm_redirect=' . urlencode(wp_get_current_page_url());
}
if (preg_match_all('/arm_redirect/', $login_page_url, $match) < 2) {
wp_redirect($login_page_url);
}
}
$ARMember->enqueue_angular_script();
return $content;
}
function arm_membership_detail_shortcode_func($atts, $content, $tag) {
global $ARMember;
$arm_check_is_gutenberg_page = $ARMember->arm_check_is_gutenberg_page();
if($arm_check_is_gutenberg_page)
{
return;
}
/* ====================/.Begin Set Shortcode Attributes./==================== */
$default_membership_fields = __('No.', 'ARMember') . ',' .__('Membership Plan', 'ARMember') . ',' .__('Plan Type', 'ARMember') . ',' . __('Starts On', 'ARMember') . ',' . __('Expires On', 'ARMember') . ',' . __('Cycle Date', 'ARMember') . ',' . __('Action', 'ARMember');
$atts = shortcode_atts(array(
'title' => __('Current Membership', 'ARMember'),
'membership_label' => 'current_membership_no,current_membership_is,current_membership_started_on,current_membership_expired_on,current_membership_next_billing_date,action_button',
'membership_value' => $default_membership_fields,
'display_renew_button' => 'true',
'renew_css' => '',
'renew_hover_css' => '',
'renew_text' => __('Renew', 'ARMember'),
'make_payment_text' => __('Make Payment', 'ARMember'),
'display_cancel_button' => 'true',
'cancel_css' => '',
'cancel_hover_css' => '',
'cancel_text' => __('Cancel', 'ARMember'),
'setup_id' => '',
'trial_active' => __('trial active', 'ARMember'),
'cancel_message' => __('Your Subscription has been cancelled.', 'ARMember'),
'message_no_record' => __('There is no membership found.', 'ARMember'),
), $atts, $tag);
extract($atts);
/* ====================/.End Set Shortcode Attributes./==================== */
global $wp, $wpdb, $current_user, $current_site, $arm_errors, $arm_member_forms, $ARMember, $arm_global_settings, $arm_subscription_plans, $arm_payment_gateways, $arm_membership_setup;
$date_format = $arm_global_settings->arm_get_wp_date_format();
$labels = explode(',', rtrim($atts['membership_label'], ','));
$values = explode(',', rtrim($atts['membership_value'], ','));
if (is_user_logged_in()) {
$setup_plans = array();
if (isset($setup_id) && $setup_id > 0) {
$setup_data = $arm_membership_setup->arm_get_membership_setup($setup_id);
$setup_plans = isset($setup_data['arm_setup_modules']['modules']['plans']) ? $setup_data['arm_setup_modules']['modules']['plans'] : array();
} else {
$setup_data = $wpdb->get_row("SELECT * FROM `" . $ARMember->tbl_arm_membership_setup . "` ORDER BY `arm_setup_id`", ARRAY_A);
if (!empty($setup_data)) {
$setup_id = isset($setup_data['arm_setup_id']) ? $setup_data['arm_setup_id'] : 0;
$setup_data['arm_setup_modules'] = maybe_unserialize($setup_data['arm_setup_modules']);
$setup_plans = isset($setup_data['arm_setup_modules']['modules']['plans']) ? $setup_data['arm_setup_modules']['modules']['plans'] : array();
} else {
$setup_plans = $arm_subscription_plans->arm_get_all_active_subscription_plans();
}
}
$user_id = get_current_user_id();
$user_plans = get_user_meta($user_id, 'arm_user_plan_ids', true);
$user_plans = !empty($user_plans) ? $user_plans : array();
$user_future_plans = get_user_meta($user_id, 'arm_user_future_plan_ids', true);
$user_future_plans = !empty($user_future_plans) ? $user_future_plans : array();
$content = apply_filters('arm_before_current_membership_shortcode_content', $content, $atts);
$content .= "";
$content .= "
";
$content .= "";
$frontfontstyle = $arm_global_settings->arm_get_front_font_style();
//$content .=!empty($frontfontstyle['google_font_url']) ? '
' : '';
$content .=!empty($frontfontstyle['google_font_url']) ? wp_enqueue_style( 'google-font', $frontfontstyle['google_font_url'], array(), MEMBERSHIPLITE_VERSION ) : '';
$content .= '';
if (!empty($title)) {
$content .= '
' . $title . '
';
$content .= '
';
}
$content .= '
";
$content .= "";
$content = apply_filters('arm_after_current_membership_shortcode_content', $content, $atts);
}
else {
$default_login_form_id = $arm_member_forms->arm_get_default_form_id('login');
return do_shortcode("[arm_form id='$default_login_form_id' is_referer='1']");
}
$ARMember->enqueue_angular_script(true);
return do_shortcode($content);
}
function arm_close_account_form_style($set_id = '', $formRandomID = 0) {
global $wp, $wpdb, $wp_roles, $current_user, $arm_errors, $ARMember, $arm_members_class, $arm_member_forms, $arm_global_settings;
$frontfontstyle = $arm_global_settings->arm_get_front_font_style();
$labelFontFamily = isset($frontfontstyle['frontOptions']['level_3_font']['font_family']) ? $frontfontstyle['frontOptions']['level_3_font']['font_family'] : 'Helvetica';
$labelFontSize = isset($frontfontstyle['frontOptions']['level_3_font']['font_size']) ? $frontfontstyle['frontOptions']['level_3_font']['font_size'] : '14';
$labelFontColor = (isset($frontfontstyle['frontOptions']['level_3_font']['font_color'])) ? $frontfontstyle['frontOptions']['level_3_font']['font_color'] : "";
$labelFontBold = (isset($frontfontstyle['frontOptions']['level_3_font']['font_bold']) && $frontfontstyle['frontOptions']['level_3_font']['font_bold'] == '1') ? 1 : 0;
$labelFontItalic = (isset($frontfontstyle['frontOptions']['level_3_font']['font_italic']) && $frontfontstyle['frontOptions']['level_3_font']['font_italic'] == '1') ? 1 : 0;
$labelFontDecoration = (!empty($frontfontstyle['frontOptions']['level_3_font']['font_decoration'])) ? $frontfontstyle['frontOptions']['level_3_font']['font_decoration'] : '';
$buttonFontFamily = isset($frontfontstyle['frontOptions']['button_font']['font_family']) ? $frontfontstyle['frontOptions']['button_font']['font_family'] : 'Helvetica';
$buttonFontSize = isset($frontfontstyle['frontOptions']['button_font']['font_size']) ? $frontfontstyle['frontOptions']['button_font']['font_size'] : '14';
$buttonFontColor = (isset($frontfontstyle['frontOptions']['button_font']['font_color'])) ? $frontfontstyle['frontOptions']['button_font']['font_color'] : "";
$buttonFontBold = (isset($frontfontstyle['frontOptions']['button_font']['font_bold']) && $frontfontstyle['frontOptions']['button_font']['font_bold'] == '1') ? 1 : 0;
$buttonFontItalic = (isset($frontfontstyle['frontOptions']['button_font']['font_italic']) && $frontfontstyle['frontOptions']['button_font']['font_italic'] == '1') ? 1 : 0;
$buttonFontDecoration = (!empty($frontfontstyle['frontOptions']['button_font']['font_decoration'])) ? $frontfontstyle['frontOptions']['button_font']['font_decoration'] : '';
$form_settings = array();
if (isset($set_id) && $set_id != '') {
$setform_settings = $wpdb->get_row("SELECT `arm_form_id`, `arm_form_type`, `arm_form_settings` FROM `" . $ARMember->tbl_arm_forms . "` WHERE `arm_form_id` = '" . $set_id . "' AND `arm_form_type`='login' ORDER BY arm_form_id DESC LIMIT 1");
$set_style_option = maybe_unserialize($setform_settings->arm_form_settings);
if (isset($set_style_option['style'])) {
$form_settings['style'] = $set_style_option['style'];
}
if (isset($set_style_option['custom_css'])) {
$form_settings['custom_css'] = $set_style_option['custom_css'];
}
$form_css = $arm_member_forms->arm_ajax_generate_form_styles('close_account', $form_settings);
} else {
// Get Default style
$form_settings['style'] = $arm_member_forms->arm_default_form_style_login();
$form_css = $arm_member_forms->arm_ajax_generate_form_styles('close_account', $form_settings);
}
$caFormStyle = '';
if (!empty($frontfontstyle['google_font_url'])) {
//$caFormStyle .= '';
$caFormStyle .= wp_enqueue_style( 'google-font', $frontfontstyle['google_font_url'], array(), MEMBERSHIPLITE_VERSION );
}
$closeAccountcontainer = ".arm_form_close_account";
$caFormStyle .= "";
return $caFormStyle;
}
function arm_close_account_form_action() {
global $wp, $wpdb, $current_user, $current_site, $arm_errors, $ARMember, $arm_members_class, $arm_global_settings, $arm_email_settings, $arm_members_activity, $arm_subscription_plans;
$posted_data = $_POST;
$arm_capabilities = '';
$ARMember->arm_check_user_cap($arm_capabilities);
$user = wp_get_current_user();
if (isset($posted_data['arm_action'])) {
do_action('arm_before_close_account_form_action', $posted_data, $user);
if (isset($posted_data['pass'])) {
if ($user && wp_check_password($posted_data['pass'], $user->data->user_pass, $user->ID)) {
arm_set_member_status($user->ID, 2, 1);
$plan_ids = get_user_meta($user->ID, 'arm_user_plan_ids', true);
$stop_future_plan_ids = get_user_meta($user->ID, 'arm_user_future_plan_ids', true);
$defaultPlanData = $arm_subscription_plans->arm_default_plan_array();
if(!empty($stop_future_plan_ids) && is_array($stop_future_plan_ids)){
foreach($stop_future_plan_ids as $stop_future_plan_id){
$arm_subscription_plans->arm_add_membership_history($user->ID, $stop_future_plan_id, 'cancel_subscription', array(), 'terminate');
delete_user_meta($user->ID, 'arm_user_plan_' . $stop_future_plan_id);
}
delete_user_meta($user->ID, 'arm_user_future_plan_ids');
}
if (!empty($plan_ids) && is_array($plan_ids)) {
foreach ($plan_ids as $plan_id) {
$planData = get_user_meta($user->ID, 'arm_user_plan_' . $plan_id, true);
$userPlanDatameta = !empty($planData) ? $planData : array();
$planData = shortcode_atts($defaultPlanData, $userPlanDatameta);
$plan_detail = $planData['arm_current_plan_detail'];
$planData['arm_cencelled_plan'] = 'yes';
update_user_meta($user->ID, 'arm_user_plan_' . $plan_id, $planData);
if (!empty($plan_detail)) {
$planObj = new ARM_Plan(0);
$planObj->init((object) $plan_detail);
} else {
$planObj = new ARM_Plan($plan_id);
}
if ($planObj->exists() && $planObj->is_recurring()) {
do_action('arm_cancel_subscription_gateway_action', $user->ID, $planObj->ID);
}
$arm_subscription_plans->arm_add_membership_history($user->ID, $planObj->ID, 'cancel_subscription', array(), 'close_account');
do_action('arm_cancel_subscription', $user->ID, $planObj->ID);
$arm_subscription_plans->arm_clear_user_plan_detail($user->ID, $planObj->ID);
}
}
do_action('arm_after_close_account', $user->ID, $user);
wp_cache_delete($user->ID, 'users');
wp_cache_delete($user->user_login, 'userlogins');
$res_var = wp_delete_user($user->ID, 1);
wp_logout();
$home_url = ARMLITE_HOME_URL;
$response = array('type' => 'success', 'msg' => __('Your account is closed successfully.', 'ARMember'), 'url' => $home_url);
} else {
$err_msg = $arm_global_settings->common_message['arm_invalid_password_close_account'];
$all_errors = (!empty($err_msg)) ? $err_msg : __('Your current password is invalid.', 'ARMember');
$response = array('type' => 'error', 'msg' => __($all_errors, 'ARMember'));
}
}
do_action('arm_after_close_account_form_action', $posted_data, $user);
}
echo json_encode($response);
die();
}
/**
* Add Shortcode Button in TinyMCE Editor.
*/
function arm_insert_shortcode_button($content) {
/* if (!in_array(basename($_SERVER['PHP_SELF']), array('post.php', 'page.php', 'post-new.php', 'page-new.php'))) {
return;
} */
if (!in_array(basename($_SERVER['PHP_SELF']), array('post.php', 'post-new.php'))) {
return;
}
if (basename($_SERVER['PHP_SELF']) == 'post.php') {
$post_id = $_REQUEST['post'];
$post_type = get_post_type($post_id);
}
if (basename($_SERVER['PHP_SELF']) == 'post-new.php') {
if (isset($_REQUEST['post_type'])) {
$post_type = $_REQUEST['post_type'];
} else {
$post_type = 'post';
}
}
if (!in_array($post_type, array('post', 'page'))) {
return;
}
?>
arm_google_fonts_list();
$allFonts = array_merge($allFonts, $g_fonts); */
foreach ($allFonts as $font) {
$armFontFamily .= $font . '=' . $font . ';';
}
$initArray['font_formats'] = trim($armFontFamily, " ");
}
return $initArray;
}
function arm_username_func() {
global $ARMember;
$arm_check_is_gutenberg_page = $ARMember->arm_check_is_gutenberg_page();
if($arm_check_is_gutenberg_page)
{
return;
}
$return_content = '';
if (is_user_logged_in()) {
$user_id = get_current_user_id();
$user_data = wp_get_current_user($user_id);
$return_content = $user_data->data->user_login;
}
return $return_content;
}
function arm_userid_func() {
global $ARMember;
$arm_check_is_gutenberg_page = $ARMember->arm_check_is_gutenberg_page();
if($arm_check_is_gutenberg_page)
{
return;
}
$return_content = '';
if (is_user_logged_in()) {
$user_id = get_current_user_id();
$return_content = $user_id;
}
return $return_content;
}
function arm_displayname_func() {
global $ARMember;
$arm_check_is_gutenberg_page = $ARMember->arm_check_is_gutenberg_page();
if($arm_check_is_gutenberg_page)
{
return;
}
$return_content = '';
if (is_user_logged_in()) {
$user_id = get_current_user_id();
$user_data = wp_get_current_user($user_id);
$return_content = $user_data->data->display_name;
}
return $return_content;
}
function arm_avatar_func() {
global $ARMember;
$arm_check_is_gutenberg_page = $ARMember->arm_check_is_gutenberg_page();
if($arm_check_is_gutenberg_page)
{
return;
}
$avatar = '';
if (is_user_logged_in()) {
$user_id = get_current_user_id();
$user_data = wp_get_current_user($user_id);
$user_email = $user_data->data->user_email;
$avatar = get_avatar($user_email);
}
return $avatar;
}
function arm_firstname_lastname_func() {
global $ARMember;
$arm_check_is_gutenberg_page = $ARMember->arm_check_is_gutenberg_page();
if($arm_check_is_gutenberg_page)
{
return;
}
$return_content = '';
if (is_user_logged_in()) {
$user_id = get_current_user_id();
$return_content = get_user_meta($user_id, 'first_name', true) . " " . get_user_meta($user_id, 'last_name', true);
}
return $return_content;
}
function arm_user_plan_func() {
global $ARMember;
$arm_check_is_gutenberg_page = $ARMember->arm_check_is_gutenberg_page();
if($arm_check_is_gutenberg_page)
{
return;
}
$user_current_plan = '';
$user_current_plan_arr = array();
if (is_user_logged_in()) {
$user_id = get_current_user_id();
$all_plans_ids = get_user_meta($user_id, 'arm_user_plan_ids', true);
if( ! empty($all_plans_ids)) {
foreach ($all_plans_ids as $single_plans_id) {
$single_plan_details = get_user_meta($user_id, 'arm_user_plan_' . $single_plans_id, true);
if( ! empty($single_plan_details) && isset($single_plan_details['arm_current_plan_detail']['arm_subscription_plan_name']) && $single_plan_details['arm_current_plan_detail']['arm_subscription_plan_name'] != "" ) {
$plan_name = $single_plan_details['arm_current_plan_detail']['arm_subscription_plan_name'];
$user_current_plan_arr[] = "" . $plan_name . "";
}
}
}
}
if( ! empty($user_current_plan_arr) ) {
$user_current_plan = implode(", ", $user_current_plan_arr);
}
return $user_current_plan;
}
function arm_usermeta_func($atts, $content, $tag) {
global $ARMember;
$arm_check_is_gutenberg_page = $ARMember->arm_check_is_gutenberg_page();
if($arm_check_is_gutenberg_page)
{
return;
}
global $ARMember, $arm_global_settings;
$return_content = '';
if( isset($atts['id']) && $atts['id'] != '' && $atts['id'] > 0){
$user_id = $atts['id'];
} else if(is_user_logged_in()) {
$user_id = get_current_user_id();
}
if (isset($atts['meta']) && $atts['meta'] != "") {
$user_object = get_user_by('ID',$user_id);
$meta_name = $atts['meta'];
switch($meta_name){
case 'user_login':
case 'user_email':
case 'display_name':
case 'user_nicename':
case 'user_url':
$return_content = $user_object->data->$meta_name;
break;
case 'avatar':
$return_content = get_avatar($user_object ->user_email);
break;
default:
$return_content = get_user_meta($user_id, $meta_name, true);
$pattern = '/^(date\_(.*))/';
$pattern_file = '/^(file\_(.*))/';
if(preg_match($pattern, $meta_name)){
$date_time_format = $arm_global_settings->arm_get_wp_date_format();
$return_content = date_i18n($date_time_format, strtotime($return_content));
}
else if(preg_match($pattern_file, $meta_name)){
if ($return_content != '') {
$exp_val = explode("/", $return_content);
$filename = $exp_val[count($exp_val) - 1];
$file_extension = explode('.', $filename);
$file_ext = $file_extension[count($file_extension) - 1];
if (in_array($file_ext, array('jpg', 'jpeg', 'jpe', 'png', 'bmp', 'tif', 'tiff', 'JPG', 'JPEG', 'JPE', 'PNG', 'BMP', 'TIF', 'TIFF'))) {
$fileUrl = $return_content;
} else {
$fileUrl = MEMBERSHIPLITE_IMAGES_URL . '/file_icon.png';
}
if (preg_match("@^http@", $return_content)) {
$temp_data = explode("://", $return_content);
$return_content = '//' . $temp_data[1];
}
if (file_exists(strstr($fileUrl, "//"))) {
$fileUrl = strstr($fileUrl, "//");
}
$return_content = '';
}
}
break;
}
if(is_array($return_content)){
$return_content = $ARMember->arm_array_trim($return_content);
$return_content = implode(', ', $return_content);
}
}
return $return_content;
}
function arm_user_planinfo_func($atts, $content, $tag) {
if (current_user_can('administrator')) {
return;
}
global $ARMember;
$arm_check_is_gutenberg_page = $ARMember->arm_check_is_gutenberg_page();
if($arm_check_is_gutenberg_page)
{
return;
}
global $arm_global_settings, $arm_subscription_plans, $arm_payment_gateways;
if (is_user_logged_in()) {
$user_id = get_current_user_id();
if (isset($atts['plan_id']) && !empty($atts['plan_id'])) {
$plan_id = $atts['plan_id'];
$user_plan_ids = get_user_meta($user_id, 'arm_user_plan_ids', true);
$user_plan_ids = !empty($user_plan_ids) ? $user_plan_ids : array();
$date_format = $arm_global_settings->arm_get_wp_date_format();
if (in_array($plan_id, $user_plan_ids)) {
if (isset($atts['plan_info']) && !empty($atts['plan_info'])) {
$plan_info = trim($atts['plan_info']);
$defaultPlanData = $arm_subscription_plans->arm_default_plan_array();
$planData = get_user_meta($user_id, 'arm_user_plan_' . $plan_id, true);
$userPlanDatameta = !empty($planData) ? $planData : array();
$planData = shortcode_atts($defaultPlanData, $userPlanDatameta);
switch ($plan_info) {
case 'arm_start_plan':
if(!empty($planData['arm_start_plan'])){
$content.= date_i18n($date_format, $planData['arm_start_plan']);
}
break;
case 'arm_expire_plan':
if(!empty($planData['arm_expire_plan'])){
$content.= date_i18n($date_format, $planData['arm_expire_plan']);
}
break;
case 'arm_trial_start':
if(!empty($planData['arm_trial_start'])){
$content.= date_i18n($date_format, $planData['arm_trial_start']);
}
break;
case 'arm_trial_end':
if(!empty($planData['arm_trial_end'])){
$content.= date_i18n($date_format, $planData['arm_trial_end']);
}
break;
case 'arm_grace_period_end':
if(!empty($planData['arm_grace_period_end'])){
$content.= date_i18n($date_format, $planData['arm_grace_period_end']);
}
break;
case 'arm_user_gateway':
if(!empty($planData['arm_user_gateway'])){
$content.= $arm_payment_gateways->arm_gateway_name_by_key($planData['arm_user_gateway']);
}
break;
case 'arm_completed_recurring':
$content.= $planData['arm_completed_recurring'];
break;
case 'arm_next_due_payment':
if(!empty($planData['arm_next_due_payment'])){
$content.= date_i18n($date_format, $planData['arm_next_due_payment']);
}
break;
case 'arm_payment_mode':
if(!empty($planData['arm_payment_mode'])){
if($planData['arm_payment_mode'] == 'auto_debit_subscription'){
$content.= __('Automatic Subscription', 'ARMember');
}else if($planData['arm_payment_mode'] == 'manual_subscription'){
$content.= __('Semi Automatic Subscription', 'ARMember');
}
}
break;
case 'arm_payment_cycle':
if($planData['arm_payment_cycle'] != ''){
$user_selected_payment_cycle = $planData['arm_payment_cycle'];
$plan_detail = $planData['arm_current_plan_detail'];
$plan_options = maybe_unserialize($plan_detail['arm_subscription_plan_options']);
$payment_cycle_data = $plan_options['payment_cycles'];
if(!empty($payment_cycle_data)){
if(isset($payment_cycle_data[$user_selected_payment_cycle]) && !empty($payment_cycle_data[$user_selected_payment_cycle])){
$content .= $payment_cycle_data[$user_selected_payment_cycle]['cycle_label'];
}
}
}
break;
case 'default':
break;
}
}
}
}
}
return $content;
}
function arm_br2nl($arm_string) {
return preg_replace('/\
/i', "\n", $arm_string);
}
}
}
global $arm_shortcodes;
$arm_shortcodes = new ARM_shortcodes();