global_settings = $this->arm_get_all_global_settings(TRUE); $this->block_settings = $this->arm_get_parsed_block_settings(); $this->common_message = $this->arm_get_all_common_message_settings(); $sub_installation = trim(str_replace(ARMLITE_HOME_URL, '', site_url()), ' /'); if ($sub_installation && substr($sub_installation, 0, 4) != 'http') { $this->sub_folder = $sub_installation . '/'; } $this->is_subdir_mu = false; if (is_multisite()) { $this->is_subdir_mu = true; if ((defined('SUBDOMAIN_INSTALL') && SUBDOMAIN_INSTALL) || (defined('VHOST') && VHOST == 'yes')) { $this->is_subdir_mu = false; } } if (is_multisite() && !$this->sub_folder && $this->is_subdir_mu) { $this->sub_folder = ltrim(parse_url(trim(get_blog_option(BLOG_ID_CURRENT_SITE, 'home'), '/') . '/', PHP_URL_PATH), '/'); } if (is_multisite() && !$this->blog_path && $this->is_subdir_mu) { global $current_blog; $this->blog_path = str_replace($this->sub_folder, '', $current_blog->path); } /* ====================================/.End Set Global Settings For Class./==================================== */ add_action('wp_ajax_arm_send_test_mail', array(&$this, 'arm_send_test_mail')); add_action('wp_ajax_arm_update_global_settings', array(&$this, 'arm_update_all_settings')); add_action('wp_ajax_arm_update_block_settings', array(&$this, 'arm_update_all_settings')); add_action('wp_ajax_arm_update_redirect_settings', array(&$this, 'arm_update_all_settings')); add_action('wp_ajax_arm_page_settings', array(&$this, 'arm_update_all_settings')); add_action('wp_ajax_arm_update_common_message_settings', array(&$this, 'arm_update_all_settings')); add_action('wp_ajax_arm_update_access_restriction_settings', array(&$this, 'arm_update_all_settings')); add_action('wp_ajax_arm_shortcode_exist_in_page', array(&$this, 'arm_shortcode_exist_in_page')); add_action('wp_ajax_arm_social_form_exist_in_page', array(&$this, 'arm_social_form_exist_in_page')); add_action('wp_ajax_arm_update_feature_settings', array(&$this, 'arm_update_feature_settings')); /* Apply Global Setting Action */ add_action('init', array(&$this, 'arm_apply_global_settings'), 200); add_action('login_head', array(&$this, 'arm_login_enqueue_assets'), 50); add_filter('option_users_can_register', array(&$this, 'arm_remove_registration_link')); /* Enable Shortcodes in Widgets */ add_filter('widget_text', 'do_shortcode'); /* Filter Post Excerpt for plugin shortcodes */ add_filter("the_excerpt", array(&$this, 'arm_filter_the_excerpt')); add_filter("the_excerpt_rss", array(&$this, 'arm_filter_the_excerpt')); /* Rewrite Rules */ add_action('admin_notices', array(&$this, 'arm_admin_notices')); add_filter('arm_display_admin_notices', array(&$this, 'arm_global_settings_notices')); /* Filter `get_avatar` */ add_filter('get_avatar', array(&$this, 'arm_filter_get_avatar'), 20, 5); add_filter('arm_check_member_status_before_login', array(&$this, 'arm_check_member_status'), 10, 2); /* add_filter('arm_check_member_status_before_login', array(&$this, 'arm_check_block_settings'), 5, 2); */ /* Delete Term Action Hook */ add_action('delete_term', array(&$this, 'arm_after_delete_term'), 10, 4); /* Added From Name And Form Email Hook */ add_action('admin_enqueue_scripts', array(&$this, 'arm_add_page_label_css'), 20); add_filter('display_post_states', array(&$this, 'arm_add_set_page_label'), 999, 2); /* Set Global Profile URL */ add_filter('query_vars', array(&$this, 'arm_user_query_vars'), 10, 1); add_action('wp_ajax_arm_clear_form_fields', array(&$this, 'arm_clear_form_fields')); add_action('wp_ajax_arm_failed_login_lockdown_clear', array(&$this, 'arm_failed_login_lockdown_clear')); add_action('wp_ajax_arm_failed_login_history_clear', array(&$this, 'arm_failed_login_history_clear')); add_action('after_switch_theme',array(&$this,'arm_set_permalink_for_profile_page'),10); add_action('permalink_structure_changed', array(&$this,'arm_set_session_for_permalink')); add_action('admin_footer',array(&$this,'arm_rewrite_rules_for_profile_page'),100); add_filter( 'generate_rewrite_rules', array(&$this,'arm_generate_rewrite_rules'),10 ); add_action('admin_init',array(&$this,'arm_plugin_add_suggested_privacy_content'),20); } function arm_plugin_add_suggested_privacy_content(){ if(function_exists('wp_add_privacy_policy_content')) { $content = $this->arm_get_privacy_content(); wp_add_privacy_policy_content( 'ARMember', $content); } } function arm_get_privacy_content(){ $arm_gdpr_mode_cnt_default = '

'.__('What personal data collected in ARMember','ARMember') .'

' . '

'.__('User\'s Signup Details such as Username, Password, First Name, Last Name and Custom Fields value( Address, Gender etc)','ARMember') . '

' . '

'.__('User\'s IP Address Information','ARMember') . '

' . '

'.__('User\'s Basic Details Sending to opt-ins such as (Email, First Name, Last Name)','ARMember') . '

' . '

'.__('User\'s Logged in / Logout details','ARMember') . '

' . '

'.__('User\'s Basic Payment Transaction Details (Not Storing any sensitive Payment Data such as Credit/Debit Card Details.)','ARMember') . '

'; return $arm_gdpr_mode_cnt_default; } function arm_set_permalink_for_profile_page(){ $this->arm_user_rewrite_rules(); } function arm_set_session_for_permalink(){ $_SESSION['arm_site_permalink_is_changed'] = true; } function arm_rewrite_rules_for_profile_page(){ global $wp_rewrite; if( isset($_SESSION['arm_site_permalink_is_changed']) && $_SESSION['arm_site_permalink_is_changed'] == true ){ $this->arm_user_rewrite_rules(); $wp_rewrite->flush_rules(false); unset($_SESSION['arm_site_permalink_is_changed']); } } function arm_failed_login_lockdown_clear() { global $wpdb, $ARMember, $arm_capabilities_global; if(isset($_POST['reset_attempts_users']) && !empty($_POST['reset_attempts_users'])) { $ARMember->arm_check_user_cap($arm_capabilities_global['arm_manage_block_settings'], '1'); if(in_array('all', $_POST['reset_attempts_users'])) { $delete = $wpdb->query("TRUNCATE TABLE `$ARMember->tbl_arm_fail_attempts`"); $delete = $wpdb->query("TRUNCATE TABLE `$ARMember->tbl_arm_lockdown`"); } else { foreach($_POST['reset_attempts_users'] as $user_id){ $wpdb->delete( $ARMember->tbl_arm_fail_attempts, array( 'arm_user_id' => $user_id ), array( '%d' ) ); $wpdb->delete( $ARMember->tbl_arm_lockdown, array( 'arm_user_id' => $user_id ), array( '%d' ) ); } } } die(); } function arm_failed_login_history_clear() { global $wpdb, $ARMember; $armembermessage = $ARMember->arm_alert_messages(); $message = $armembermessage['clearLoginHistory']; $delete = $wpdb->query("DELETE FROM `$ARMember->tbl_arm_login_history`"); $ARMember->arm_set_message('success', $message); die(); } function arm_clear_form_fields() { global $wpdb, $ARMember, $arm_capabilities_global; $ARMember->arm_check_user_cap($arm_capabilities_global['arm_manage_general_settings'], '1'); $arm_posted_data = isset($_POST['clear_fields']) ? $_POST['clear_fields'] : array(); $arm_deleted_fields = array(); $presetFormFields = get_option('arm_preset_form_fields', ''); $dbFormFields = maybe_unserialize($presetFormFields); if (isset($arm_posted_data) && !empty($arm_posted_data)) { foreach ($arm_posted_data as $key => $arm_field_key) { $wpdb->query("DELETE FROM `" . $wpdb->usermeta . "` WHERE `meta_key`='" . $key . "'"); unset($dbFormFields['other'][$key]); array_push($arm_deleted_fields, $key); } } update_option('arm_preset_form_fields', $dbFormFields); echo json_encode($arm_deleted_fields); die(); } function arm_send_test_mail() { global $ARMember, $arm_capabilities_global; $ARMember->arm_check_user_cap($arm_capabilities_global['arm_manage_general_settings'], '1'); $reply_to = (isset($_POST['reply_to']) && !empty($_POST['reply_to'])) ? sanitize_email($_POST['reply_to']) : ''; $send_to = (isset($_POST['send_to']) && !empty($_POST['send_to'])) ? sanitize_email($_POST['send_to']) : ''; $subject = (isset($_POST['subject']) && !empty($_POST['subject'])) ? sanitize_text_field($_POST['subject']) : __('SMTP Test E-Mail', 'ARMember'); $message = (isset($_POST['message']) && !empty($_POST['message'])) ? sanitize_textarea_field($_POST['message']) : ''; $reply_to_name = (isset($_POST['reply_to_name']) && !empty($_POST['reply_to_name'])) ? sanitize_text_field($_POST['reply_to_name']) : ''; $mail_authentication = (isset($_POST['mail_authentication'])) ? intval($_POST['mail_authentication']) : '1'; $arm_mail_server = (isset($_POST['mail_server']) && !empty($_POST['mail_server'])) ? sanitize_text_field($_POST['mail_server']) : ''; $arm_mail_port = (isset($_POST['mail_port']) && !empty($_POST['mail_port'])) ? intval($_POST['mail_port']) : ''; $arm_mail_login_name = (isset($_POST['mail_login_name']) && !empty($_POST['mail_login_name'])) ? sanitize_text_field($_POST['mail_login_name']) : ''; $arm_mail_password = (isset($_POST['mail_password']) && !empty($_POST['mail_password'])) ? $_POST['mail_password'] : ''; $arm_mail_enc = (isset($_POST['mail_enc']) && !empty($_POST['mail_enc'])) ? sanitize_text_field($_POST['mail_enc']) : ''; if (empty($send_to) || empty($reply_to) || empty($message) || empty($subject)) { return; } echo $this->arm_send_tedst_mail_func($reply_to, $send_to, $subject, $message, array(), $reply_to_name, $arm_mail_server, $arm_mail_port, $arm_mail_login_name, $arm_mail_password, $arm_mail_enc, $mail_authentication); die(); } public function arm_send_tedst_mail_func($from, $recipient, $subject, $message, $attachments = array(), $reply_to_name = '', $arm_mail_server = '', $arm_mail_port = '', $arm_mail_login_name = '', $arm_mail_password = '', $arm_mail_enc = '', $mail_authentication = '1') { global $wp, $wpdb, $ARMember, $arm_slugs, $arm_email_settings, $arm_plain_text; $return = false; $reply_to_name = ($reply_to_name == '') ? wp_specialchars_decode(get_option('blogname'), ENT_QUOTES) : $reply_to_name; $use_only_smtp_settings = false; $emailSettings = $arm_email_settings->arm_get_all_email_settings(); $email_server = 'smtp_server'; $reply_to_name = ($reply_to_name == '') ? wp_specialchars_decode(get_option('blogname'), ENT_QUOTES) : $reply_to_name; $reply_to = ($from == '' or $from == '[admin_email]') ? get_option('admin_email') : $from; $from_name = (!empty($emailSettings['arm_email_from_name'])) ? $emailSettings['arm_email_from_name'] : wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); $from_email = (!empty($emailSettings['arm_email_from_email'])) ? $emailSettings['arm_email_from_email'] : get_option('admin_email'); $content_type = (@$arm_plain_text) ? 'text/plain' : 'text/html'; $from_name = $from_name; $reply_to = (!empty($from)) ? $from : $from_email; /* Set Email Headers */ $headers = array(); $header[] = 'From: "' . $reply_to_name . '" <' . $reply_to . '>'; $header[] = 'Reply-To: ' . $reply_to; $headers[] = 'Content-Type: ' . $content_type . '; charset="' . get_option('blog_charset') . '"'; /* Filter Email Subject & Message */ $subject = wp_specialchars_decode(strip_tags(stripslashes($subject)), ENT_QUOTES); $message = do_shortcode($message); $message = wordwrap(stripslashes($message), 70, "\r\n"); if (@$arm_plain_text) { $message = wp_specialchars_decode(strip_tags($message), ENT_QUOTES); } $subject = apply_filters('arm_email_subject', $subject); $message = apply_filters('arm_change_email_content', $message); $recipient = apply_filters('arm_email_recipients', $recipient); $headers = apply_filters('arm_email_header', $headers, $recipient, $subject); remove_filter('wp_mail_from', 'bp_core_email_from_address_filter'); remove_filter('wp_mail_from_name', 'bp_core_email_from_name_filter'); if (file_exists(MEMBERSHIPLITE_LIBRARY_DIR . '/phpmailer/class.arm_phpmailer.php')) { require_once(MEMBERSHIPLITE_LIBRARY_DIR . '/phpmailer/class.arm_phpmailer.php' ); } if (file_exists(MEMBERSHIPLITE_LIBRARY_DIR . '/phpmailer/class.smtp.php')) { require_once(MEMBERSHIPLITE_LIBRARY_DIR . '/phpmailer/class.smtp.php' ); } do_action('arm_before_send_email_notification', $from, $recipient, $subject, $message, $attachments); $armPMailer = new armPHPMailer(); /* Character Set of the message. */ $armPMailer->CharSet = "UTF-8"; $armPMailer->SMTPDebug = 0; /* $armPMailer->Debugoutput = 'html'; */ if ($email_server == 'smtp_server') { $armPMailer->isSMTP(); $armPMailer->Host = isset($arm_mail_server) ? $arm_mail_server : ''; $armPMailer->SMTPAuth = ($mail_authentication==1) ? true : false; $armPMailer->Username = isset($arm_mail_login_name) ? $arm_mail_login_name : ''; $armPMailer->Password = isset($arm_mail_password) ? $arm_mail_password : ''; if (isset($arm_mail_enc) && !empty($arm_mail_enc) && $arm_mail_enc != 'none') { $armPMailer->SMTPSecure = $arm_mail_enc; } if( $arm_mail_enc == 'none' ){ $armPMailer->SMTPAutoTLS = false; } $armPMailer->Port = isset($arm_mail_port) ? $arm_mail_port : ''; } else { $armPMailer->isMail(); } $armPMailer->setFrom($reply_to, $reply_to_name); $armPMailer->addReplyTo($reply_to, $reply_to_name); $armPMailer->addAddress($recipient); if (isset($attachments) && !empty($attachments)) { foreach ($attachments as $attachment) { $armPMailer->addAttachment($attachment); } } $armPMailer->isHTML(true); $armPMailer->Subject = $subject; $armPMailer->Body = $message; if (@$arm_plain_text) { $armPMailer->AltBody = $message; } /* Send Email */ if ($email_server == 'smtp_server' || $email_server == 'phpmailer') { if (!$armPMailer->send()) { echo json_encode(array('success' => 'false', 'msg' => $armPMailer->ErrorInfo)); } else { echo json_encode(array('success' => 'true', 'msg' => '')); } } else { if (!wp_mail($recipient, $subject, $message, $header, $attachments)) { if (!$armPMailer->send()) { return false; } else { return true; } } else { return true; } } } function arm_change_from_email($from_email) { global $arm_email_settings; $all_email_settings = $arm_email_settings->arm_get_all_email_settings(); $from_email = (!empty($all_email_settings['arm_email_from_email'])) ? $all_email_settings['arm_email_from_email'] : get_option('admin_email'); return $from_email; } function arm_change_from_name($from_name) { global $arm_email_settings; $all_email_settings = $arm_email_settings->arm_get_all_email_settings(); $from_name = (!empty($all_email_settings['arm_email_from_name'])) ? $all_email_settings['arm_email_from_name'] : get_option('blogname'); return $from_name; } function arm_admin_notices() { global $wp, $wpdb, $wp_rewrite, $arm_errors, $arm_slugs, $ARMember; /* * ====================/.Begin Display Admin Notices./====================* */ $current_cookie = str_replace(SITECOOKIEPATH, '', ADMIN_COOKIE_PATH); /* For non-sudomain and with paths mu: */ if (!$current_cookie) { $current_cookie = 'wp-admin'; } if(isset($_GET['page'])) { $_GET['page'] = isset($_GET['page']) ? $_GET['page'] : ''; } global $current_screen, $pagenow, $arm_access_rules; $default_rule_link = admin_url('admin.php?page=' . $arm_slugs->general_settings . '&action=access_rules_options'); if ($current_screen->base == 'nav-menus' || $pagenow == 'nav-menus.php') { $default_access_rules = $arm_access_rules->arm_get_default_access_rules(); $nav_rules = (isset($default_access_rules['nav_menu'])) ? $default_access_rules['nav_menu'] : ''; if (!empty($nav_rules)) { $warning_msg = '

'; $warning_msg .= '' . __('ARMember Warning', 'ARMember') . ': '; $warning_msg .= __('Please review', 'ARMember'); $warning_msg .= ' ' . __('Access Rules', 'ARMember') . ' '; $warning_msg .= __('after adding new menu items. Default access rule will be applied to new menu items.', 'ARMember'); $warning_msg .= '

'; echo $warning_msg; } } if ($current_screen->base == 'edit-tags' || $pagenow == 'edit-tags.php') { if (!isset($_REQUEST['tag_ID']) || empty($_REQUEST['tag_ID'])) { $taxonomy = $current_screen->taxonomy; $taxo_data = get_taxonomy($taxonomy); $default_access_rules = $arm_access_rules->arm_get_default_access_rules(); if ($taxo_data->name == 'category') { $taxo_rules = (isset($default_access_rules['category'])) ? $default_access_rules['category'] : ''; $taxo_data->label = __('category(s)', 'ARMember'); } else { $taxo_rules = (isset($default_access_rules['taxonomy'])) ? $default_access_rules['taxonomy'] : ''; $taxo_data->label = __('custom taxonomy(s)', 'ARMember'); } if (!empty($taxo_rules)) { $warning_msg = '

'; $warning_msg .= '' . __('ARMember Warning', 'ARMember') . ': '; $warning_msg .= __('Please review', 'ARMember'); $warning_msg .= ' ' . __('Access Rules', 'ARMember') . ' '; $warning_msg .= __('after adding new', 'ARMember') . ' ' . $taxo_data->label . '. '; $warning_msg .= __('Default access rule will be applied to new', 'ARMember') . ' ' . $taxo_data->label . '. '; $warning_msg .= '

'; echo $warning_msg; } } } /* * ====================/.End Display Admin Notices./====================* */ } function is_permalink() { global $wp_rewrite; if (!isset($wp_rewrite) || !is_object($wp_rewrite) || !$wp_rewrite->using_permalinks()) { return false; } return true; } function arm_mod_rewrite_rules($rules) { global $wp, $wpdb, $arm_errors, $ARMember; $home_root = parse_url(ARMLITE_HOME_URL); if (isset($home_root['path'])) { $home_root = trailingslashit($home_root['path']); } else { $home_root = '/'; } $rules = str_replace('(.*) ' . $home_root . '$1$2 ', '(.*) $1$2 ', $rules); return $rules; } function arm_apply_global_settings() { global $wp, $wpdb, $wp_rewrite, $arm_errors, $current_user, $arm_slugs, $ARMember, $arm_members_class, $arm_restriction, $arm_member_forms; $all_settings = $this->global_settings; /* Hide admin bar for non-admin users. */ $allow_access_admin_roles = array(); $hide_admin_bar = isset($all_settings['hide_admin_bar']) ? $all_settings['hide_admin_bar'] : 0; remove_all_filters('show_admin_bar'); if ($hide_admin_bar == 1) { if(isset($all_settings['arm_exclude_role_for_hide_admin']) && is_array($all_settings['arm_exclude_role_for_hide_admin'])) { $allow_access_admin_roles = $all_settings['arm_exclude_role_for_hide_admin']; } else { $allow_access_admin_roles = (isset($all_settings['arm_exclude_role_for_hide_admin']) && !empty($all_settings['arm_exclude_role_for_hide_admin'])) ? explode(',', $all_settings['arm_exclude_role_for_hide_admin']) : array(); } $user_match_role = array_intersect($current_user->roles, $allow_access_admin_roles); if(empty($user_match_role)) { if (!is_admin() && !current_user_can('administrator')) { add_filter('show_admin_bar', '__return_false'); } } }/* End `($hide_admin_bar == 1)` */ /* New User Verification */ $user_register_verification = isset($all_settings['user_register_verification']) ? $all_settings['user_register_verification'] : 'auto'; if ($user_register_verification != 'auto') { add_action('user_register', array($arm_members_class, 'arm_add_member_activation_key')); } /* Verify Member Detail Before Login */ add_filter('authenticate', array(&$arm_members_class, 'arm_user_register_verification'), 10, 3); /** * Load Google Fonts for TinyMCE Editor */ } function arm_get_home_path() { $home = get_option('home'); $siteurl = get_option('siteurl'); if (!empty($home) && 0 !== strcasecmp($home, $siteurl)) { $wp_path_rel_to_home = str_ireplace($home, '', $siteurl); /* $siteurl - $home */ $pos = strripos(str_replace('\\', '/', $_SERVER['SCRIPT_FILENAME']), trailingslashit($wp_path_rel_to_home)); $home_path = substr($_SERVER['SCRIPT_FILENAME'], 0, $pos); $home_path = trailingslashit($home_path); } else { $home_path = ABSPATH; } return $home_path; } function arm_check_member_status($return = true, $user_id = 0) { global $wp, $wpdb, $arm_errors, $ARMember, $arm_members_class, $arm_member_forms; if (!empty($user_id) && $user_id != 0) { if (is_super_admin($user_id)) { return true; } $primary_status = arm_get_member_status($user_id); $secondary_status = arm_get_member_status($user_id, 'secondary'); switch ($primary_status) { case 'pending': case 3: $pending_msg = (!empty($this->common_message['arm_account_pending'])) ? $this->common_message['arm_account_pending'] : '' . __('Account Pending', 'ARMember') . ': ' . __('Your account is currently not active. An administrator needs to activate your account before you can login.', 'ARMember'); $return = $arm_errors; /* Remove other filters when there is an error */ remove_all_filters('arm_check_member_status_before_login'); break; case 'inactive': case 2: if(($primary_status == '2' && in_array($secondary_status, array(0,1))) || $primary_status == 4){ $err_msg = (!empty($this->common_message['arm_account_inactive'])) ? $this->common_message['arm_account_inactive'] : '' . __('Account Inactive', 'ARMember') . ': ' . __('Your account is currently not active. Please contact system administrator.', 'ARMember'); $arm_errors->add('access_denied', $err_msg); } $return = $arm_errors; /* Remove other filters when there is an error */ remove_all_filters('arm_check_member_status_before_login'); break; case 'active': case 1: $return = TRUE; break; default: $return = TRUE; break; } } else { $return = FALSE; } return $return; } function arm_global_settings_notices($notices = array()) { global $wp, $wpdb, $arm_errors, $ARMember, $arm_slugs, $arm_social_feature; $default_global_settings = $this->arm_default_global_settings(); $default_page_settings = $default_global_settings['page_settings']; $page_settings = $this->arm_get_single_global_settings('page_settings'); $final_page_settings = shortcode_atts($default_page_settings, $page_settings); if (!empty($final_page_settings)) { $empty_pages = array(); foreach ($final_page_settings as $key => $page_id) { if (in_array($key, array('logout_page_id', 'guest_page_id', 'thank_you_page_id', 'cancel_payment_page_id'))) { continue; } if ($key == 'member_profile_page_id' && !$arm_social_feature->isSocialFeature) { continue; } if (empty($page_id) || $page_id == 0) { $name = str_replace('_page_id', '', $key); $name = str_replace('_', ' ', $name); $name = ucfirst($name); $empty_pages[] = $name; } } if (!empty($empty_pages)) { $empty_pages = trim(implode(', ', $empty_pages), ', '); $page_settings_url = admin_url('admin.php?page=' . $arm_slugs->general_settings . '&action=page_setup'); $notices[] = array('type' => 'error', 'message' => __('You need to set', 'ARMember') . ' \'' . $empty_pages . '\' ' . __('page(s) in', 'ARMember') . ' ' . __('page settings', 'ARMember') . ''); } } return $notices; } function arm_get_default_invoice_template(){ $arm_default_invoice_template = '
'; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= '
'; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= ''; $arm_default_invoice_template .= '
'; $arm_default_invoice_template .= '

Invoice {ARM_INVOICE_INVOICEID}

'; $arm_default_invoice_template .= '
{ARM_INVOICE_PAYMENTDATE}
'; $arm_default_invoice_template .= '
Invoice to{ARM_INVOICE_USERFIRSTNAME} {ARM_INVOICE_USERLASTNAME} ( {ARM_INVOICE_PAYEREMAIL} )
Plan Name{ARM_INVOICE_SUBSCRIPTIONNAME}
Description{ARM_INVOICE_SUBSCRIPTIONDESCRIPTION}
Plan Amount{ARM_INVOICE_AMOUNT}
transaction Id{ARM_INVOICE_TRANSACTIONID}
subscription id{ARM_INVOICE_SUBSCRIPTIONID}
payment gateway{ARM_INVOICE_GATEWAY}
trial amount{ARM_INVOICE_TRIALAMOUNT}
trial period{ARM_INVOICE_TRIALPERIOD}
coupon code{ARM_INVOICE_COUPONCODE}
coupon discount{ARM_INVOICE_COUPONAMOUNT}
Tax Percentage{ARM_INVOICE_TAXPERCENTAGE}
Tax Amount{ARM_INVOICE_TAXAMOUNT}
'; $arm_default_invoice_template .= '
'; $arm_default_invoice_template .= '
'; return $arm_default_invoice_template; } function arm_default_global_settings() { global $wpdb, $ARMember, $arm_members_class, $arm_member_forms; $default_global_settings = array(); /* General Settings */ $arm_default_invoice_template = $this->arm_get_default_invoice_template(); $default_global_settings['general_settings'] = array( 'hide_admin_bar' => 0, 'arm_exclude_role_for_hide_admin' => 0, 'restrict_admin_panel' => 0, 'arm_exclude_role_for_restrict_admin' => 0, 'hide_wp_login' => 0, 'rename_wp_admin' => 0, 'temp_wp_admin_path' => '', 'new_wp_admin_path' => 'wp-admin', 'hide_register_link' => 0, 'user_register_verification' => 'auto', 'arm_new_signup_status' => 1, 'hide_feed' => 0, 'disable_wp_login_style' => 0, 'restrict_site_access' => 0, 'arm_access_page_for_restrict_site' => 0, 'autolock_shared_account' => 0, 'paymentcurrency' => 'USD', 'custom_currency' => array( 'status' => 0, 'symbol' => '', 'shortname' => '', 'place' => 'prefix', ), 'enable_tax' => 0, 'tax_amount' => 0, 'file_upload_size_limit' => '2', 'enable_gravatar' => 1, 'enable_crop' => 1, 'enqueue_all_js_css' => 0, 'global_custom_css' => '', 'badge_width' => 30, 'badge_height' => 30, 'profile_permalink_base' => 'user_login', 'bbpress_profile_page' => 0, 'arm_email_schedular_time' => 12, 'arm_invoice_template' => $arm_default_invoice_template, 'front_settings' => array( 'level_1_font' => array( 'font_family' => 'Open Sans', 'font_size' => '18', 'font_color' => '#32323a', 'font_bold' => 1, 'font_italic' => 0, 'font_decoration' => '', ), 'level_2_font' => array( 'font_family' => 'Open Sans', 'font_size' => '16', 'font_color' => '#32323a', 'font_bold' => 1, 'font_italic' => 0, 'font_decoration' => '', ), 'level_3_font' => array( 'font_family' => 'Open Sans', 'font_size' => '15', 'font_color' => '#727277', 'font_bold' => 0, 'font_italic' => 0, 'font_decoration' => '', ), 'level_4_font' => array( 'font_family' => 'Open Sans', 'font_size' => '14', 'font_color' => '#727277', 'font_bold' => 0, 'font_italic' => 0, 'font_decoration' => '', ), 'link_font' => array( 'font_family' => 'Open Sans', 'font_size' => '14', 'font_color' => '#0c7cd5', 'font_bold' => 0, 'font_italic' => 0, 'font_decoration' => '', ), 'button_font' => array( 'font_family' => 'Open Sans', 'font_size' => '14', 'font_color' => '#FFFFFF', 'font_bold' => 0, 'font_italic' => 0, 'font_decoration' => '', ), ), ); /* Page Settings */ $default_global_settings['page_settings'] = array( 'register_page_id' => 0, 'login_page_id' => 0, 'forgot_password_page_id' => 0, 'edit_profile_page_id' => 0, 'change_password_page_id' => 0, 'member_profile_page_id' => 0, 'logout_page_id' => 0, 'guest_page_id' => 0, 'thank_you_page_id' => 0, 'cancel_payment_page_id' => 0, ); $default_global_settings = apply_filters('arm_default_global_settings', $default_global_settings); return $default_global_settings; } function arm_default_pages_content() { global $wpdb, $ARMember, $arm_members_class, $arm_slugs, $arm_member_forms; $default_rf_id = $arm_member_forms->arm_get_default_form_id('registration'); $default_lf_id = $arm_member_forms->arm_get_default_form_id('login'); $default_ff_id = $arm_member_forms->arm_get_default_form_id('forgot_password'); $default_cf_id = $arm_member_forms->arm_get_default_form_id('change_password'); $logged_in_message = __('You are already logged in.', 'ARMember'); $all_pages = array( 'register_page_id' => array( 'post_title' => 'Register', 'post_name' => 'arm_register', 'post_content' => '[arm_form id="' . $default_rf_id . '" logged_in_message="' . $logged_in_message . '"]', 'post_status' => 'publish', 'post_parent' => 0, 'post_author' => 1, 'post_type' => 'page', ), 'login_page_id' => array( 'post_title' => 'Login', 'post_name' => 'arm_login', 'post_content' => '[arm_form id="' . $default_lf_id . '" logged_in_message="' . $logged_in_message . '"]', 'post_status' => 'publish', 'post_parent' => 0, 'post_author' => 1, 'post_type' => 'page', ), 'forgot_password_page_id' => array( 'post_title' => 'Forgot Password', 'post_name' => 'arm_forgot_password', 'post_content' => '[arm_form id="' . $default_ff_id . '" logged_in_message="' . $logged_in_message . '"]', 'post_status' => 'publish', 'post_parent' => 0, 'post_author' => 1, 'post_type' => 'page', ), 'edit_profile_page_id' => array( 'post_title' => 'Edit Profile', 'post_name' => 'arm_edit_profile', 'post_content' => '[arm_edit_profile title="Edit Your Profile" form_id="101" form_position="center" social_fields="facebook,twitter,linkedin,googleplush,vk,instagram,pinterest,youtube,dribbble,delicious,tumblr,vine," submit_text="Update Profile" message="Your profile has been updated successfully."]', 'post_status' => 'publish', 'post_parent' => 0, 'post_author' => 1, 'post_type' => 'page', ), 'change_password_page_id' => array( 'post_title' => 'Change Password', 'post_name' => 'arm_change_password', 'post_content' => '[arm_form id="' . $default_cf_id . '"]', 'post_status' => 'publish', 'post_parent' => 0, 'post_author' => 1, 'post_type' => 'page', ), 'guest_page_id' => array( 'post_title' => 'Guest', 'post_name' => 'arm_guest', 'post_content' => '

' . __('Welcome Guest', 'ARMember') . ',

', 'post_status' => 'publish', 'post_parent' => 0, 'post_author' => 1, 'post_type' => 'page', ), 'thank_you_page_id' => array( 'post_title' => 'Thank You', 'post_name' => 'arm_thank_you', 'post_content' => "

" . __('Thank you for payment with us, We will reach you soon.', 'ARMember') . "

", 'post_status' => 'publish', 'post_parent' => 0, 'post_author' => 1, 'post_type' => 'page', ), 'cancel_payment_page_id' => array( 'post_title' => 'Cancel Payment', 'post_name' => 'arm_cancel_payment', 'post_content' => __('Your purchase has not been completed.', 'ARMember') . '
' . __('Sorry something went wrong while processing your payment.', 'ARMember'), 'post_status' => 'publish', 'post_parent' => 0, 'post_author' => 1, 'post_type' => 'page', ), ); return $all_pages; } function arm_default_common_messages() { global $wpdb, $ARMember, $arm_members_class, $arm_member_forms; $common_messages = array( 'arm_user_not_exist' => __('No such user exist in system.', 'ARMember'), 'arm_invalid_password_login' => __('The password you entered is invalid.', 'ARMember'), 'arm_attempts_login_failed' => __('Remaining Login Attempts :', 'ARMember') . ' ' . '[ATTEMPTS]', 'arm_attempts_many_login_failed' => __('You have made too many failed login attempts.', 'ARMember'), 'arm_not_authorized_login' => __('Your account is inactive, you are not authorized to login.', 'ARMember'), 'arm_spam_msg' => __('Spam detected.', 'ARMember'), 'social_login_failed_msg' => __('Login Failed, please try again.', 'ARMember'), 'arm_no_registered_email' => __('There is no user registered with that email address/Username.', 'ARMember'), 'arm_reset_pass_not_allow' => __('Password reset is not allowed for this user.', 'ARMember'), 'arm_email_not_sent' => __('Email could not sent, please contact site admin.', 'ARMember'), 'arm_password_reset' => __('Your Password has been reset.', 'ARMember') . ' [LOGINLINK]' . __('Log in', 'ARMember') . ' [/LOGINLINK]', 'arm_password_enter_new_pwd' => __('Please enter new password', 'ARMember'), 'arm_password_reset_pwd_link_expired' => __('Reset Password Link is invalid.', 'ARMember'), 'arm_form_title_close_account' => __('Close Account', 'ARMember'), 'arm_form_description_close_account' => __('Are you sure you want to delete your account? This will erase all of your account data from the site. To delete your account enter your password below.', 'ARMember'), 'arm_password_label_close_account' => __('Your Password', 'ARMember'), 'arm_submit_btn_close_account' => __('Submit', 'ARMember'), 'arm_blank_password_close_account' => __('Password cannot be left Blank.', 'ARMember'), 'arm_invalid_password_close_account' => __('The password you entered is invalid.', 'ARMember'), 'arm_user_not_created' => __('Error while creating user.', 'ARMember'), 'arm_username_exist' => __('This username is already registered, please choose another one.', 'ARMember'), 'arm_email_exist' => __('This email is already registered, please choose another one.', 'ARMember'), 'arm_avtar_label' => __('Avatar', 'ARMember'), 'arm_profile_cover_label' => __('Profile Cover.', 'ARMember'), 'arm_maxlength_invalid' => __('Maximum', 'ARMember') . ' [MAXVALUE]' . __(' characters allowed.', 'ARMember'), 'arm_minlength_invalid' => __('Please enter at least', 'ARMember') . ' [MINVALUE]' . __(' characters.', 'ARMember'), 'arm_expire_activation_link' => __('Activation link is expired or invalid.', 'ARMember'), 'arm_expire_reset_password_activation_link' => __('Reset Password Link is expired.', 'ARMember'), 'arm_email_activation_manual_pending' => __('Your account is not activated yet. Please contact site administrator.', 'ARMember'), 'arm_already_active_account' => __('Your account has been activated.', 'ARMember'), 'arm_account_disabled' => __('Your account is disabled. Please contact system administrator.', 'ARMember'), 'arm_account_inactive' => __('Your account is currently not active. Please contact system administrator.', 'ARMember'), 'arm_account_pending' => __('Your account is currently not active. An administrator needs to activate your account before you can login.', 'ARMember'), 'arm_account_expired' => __('Your account has expired. Please contact system administrator.', 'ARMember'), 'arm_invalid_credit_card' => __('Please enter correct card details.', 'ARMember'), 'arm_unauthorized_credit_card' => __('Card details could not be authorized, please use other card detail.', 'ARMember'), 'arm_credit_card_declined' => __('Your Card is declined.', 'ARMember'), 'arm_blank_expire_month' => __('Expiry month should not be blank.', 'ARMember'), 'arm_blank_expire_year' => __('Expiry year should not be blank.', 'ARMember'), 'arm_blank_cvc_number' => __('CVC Number should not be blank.', 'ARMember'), 'arm_blank_credit_card_number' => __('Card Number should not be blank.', 'ARMember'), 'arm_invalid_plan_select' => __('Selected plan is not valid.', 'ARMember'), 'arm_no_select_payment_geteway' => __('Your selected plan is paid, please select payment method.', 'ARMember'), 'arm_inactive_payment_gateway' => __('Payment gateway is not active, please contact site administrator.', 'ARMember'), 'arm_general_msg' => __('Sorry, Something went wrong. Please contact to site administrator.', 'ARMember'), 'arm_search_result_found' => __('No Search Result Found.', 'ARMember'), 'arm_armif_invalid_argument' => __('Invalid conditional argument(s).', 'ARMember'), 'arm_armif_already_logged_in' => __('You are already logged in.', 'ARMember'), 'profile_directory_upload_cover_photo' => __('Upload Cover Photo', 'ARMember'), 'profile_directory_remove_cover_photo' => __('Remove Cover Photo', 'ARMember'), 'profile_template_upload_profile_photo' => __('Upload Profile Photo', 'ARMember'), 'profile_template_remove_profile_photo' => __('Remove Profile Photo', 'ARMember'), 'directory_sort_by_alphabatically' => __('Alphabetically', 'ARMember'), 'directory_sort_by_recently_joined' => __('Recently Joined', 'ARMember'), 'arm_profile_member_since' => __('Member Since', 'ARMember'), 'arm_profile_view_profile' => __('View profile', 'ARMember'), ); return $common_messages; } function arm_get_social_form_page_shortcodes($page_id = 0, $selected_form = '') { global $wp, $wpdb, $ARMember, $arm_member_forms; $form_shortcodes = $setupForms = array(); $sel_form_id = (!empty($selected_form)) ? $selected_form : ''; $form_select_box = ''; $error_message = true; $page_detail = get_post($page_id); $page_on_front = get_option('page_on_front'); $page_for_posts = get_option('page_for_posts'); if (!empty($page_detail->ID) && $page_detail->ID != 0 && !in_array($page_detail->ID, array($page_on_front, $page_for_posts))) { $post_content = $page_detail->post_content; $is_setup_shortcode = $this->arm_find_match_shortcode_func('arm_setup', $post_content); if ($is_setup_shortcode) { $allSetups = $wpdb->get_results("SELECT `arm_setup_id`, `arm_setup_modules` FROM `" . $ARMember->tbl_arm_membership_setup . "` ORDER BY `arm_setup_id` DESC", ARRAY_A); if (!empty($allSetups)) { foreach ($allSetups as $setup) { $setup_id = $setup['arm_setup_id']; $setupModules = maybe_unserialize($setup['arm_setup_modules']); foreach (array("'$setup_id'", $setup_id, '"' . $setup_id . '"') as $val) { if (preg_match_all('/\[arm_setup(.*)id=' . $val . '(.*)\]/s', $post_content, $matches) > 0) { if (isset($setupModules['modules']['forms']) && !empty($setupModules['modules']['forms'])) { $setupForms[] = $setupModules['modules']['forms']; } } } } $setupForms = (!empty($setupForms)) ? $ARMember->arm_array_unique($setupForms) : array(); } } $is_shortcode = $this->arm_find_match_shortcode_func('arm_form', $post_content); if (!$is_shortcode) { $is_shortcode = apply_filters('armember_cs_check_shortcode_in_page', $is_shortcode, 'cs_armember_cs', $post_content); } $forms = $arm_member_forms->arm_get_member_forms_by_type('registration'); $allow_fields = array('text', 'email', 'textarea', 'hidden'); if (!empty($forms)) { foreach ($forms as $form) { $form_id = $form['arm_form_id']; $form_slug = $form['arm_form_slug']; if (in_array($form_id, $setupForms)) { $form_shortcodes['forms'][$form_id] = array( 'id' => $form['arm_form_id'], 'slug' => $form['arm_form_slug'], 'name' => strip_tags(stripslashes($form['arm_form_label'])), ); } if ($is_shortcode) { foreach (array("'$form_id'", $form_id, '"' . $form_id . '"') as $val) { if (preg_match_all('/id=' . $val . '|arm_form_registration=' . $val . '/s', $post_content, $matches) > 0) { $form_shortcodes['forms'][$form_id] = array( 'id' => $form['arm_form_id'], 'slug' => $form['arm_form_slug'], 'name' => strip_tags(stripslashes($form['arm_form_label'])), ); } } /* END `foreach (array("'$form_slug'", $form_slug, '"' . $form_slug . '"') as $val)` */ } } /* END `foreach ($forms as $form)` */ } /* END `if (!empty($forms))` */ if (!empty($form_shortcodes['forms'])) { $form_select_box = ''; $allFoundForms = $form_shortcodes['forms']; $firstForm = array_shift($form_shortcodes['forms']); $sel_form_id = (!empty($selected_form)) ? $selected_form : $firstForm['id']; if (count($allFoundForms) == 1) { $form_select_box .= ''; $form_select_box .= $firstForm['name']; } else { $form_select_box .= ''; $form_select_box .= '
'; $form_select_box .= '
'; $form_select_box .= '
'; $form_select_box .= '
'; } } } if (empty($form_select_box)) { $error_message = false; $form_select_box .= ''; } $return_data = array( 'forms' => $form_select_box, 'form_id' => $sel_form_id, 'status' => $error_message, ); return $return_data; } function arm_social_form_exist_in_page() { global $wp, $wpdb, $ARMember, $arm_member_forms; $page_id = intval($_POST['page_id']); $form_shortcodes = $this->arm_get_social_form_page_shortcodes($page_id); $forms = $form_shortcodes['forms']; $return = array('forms' => $forms, 'form_id' => $form_shortcodes['form_id'], 'status' => $form_shortcodes['status']); echo json_encode($return); exit; } function arm_registration_form_shortcode_exist_in_page($shortcode_type = '', $page_id = 0) { global $wp, $wpdb, $ARMember, $arm_member_forms; $is_exist = false; $page_detail = get_post($page_id); if (!empty($page_detail->ID) && $page_detail->ID != 0) { $post_content = $page_detail->post_content; $shortcode_text = array(); switch ($shortcode_type) { case 'registration': case 'login': $is_shortcode = $this->arm_find_match_shortcode_func('arm_form', $post_content); $is_cs_shortcode = $this->arm_find_match_shortcode_func('cs_armember_cs', $post_content); if ($is_shortcode || $is_cs_shortcode) { $forms = $arm_member_forms->arm_get_member_forms_by_type($shortcode_type, false); if (!empty($forms)) { foreach ($forms as $form) { $form_slug = $form['arm_form_id']; $shortcode_text[] = "id='$form_slug'"; $shortcode_text[] = "id=$form_slug"; $shortcode_text[] = 'id="' . $form_slug . '"'; if( $shortcode_type == 'registration' ){ $shortcode_text[] = 'arm_form_registration="'.$form_slug.'"'; } else if( $shortcode_type == 'login' ){ $shortcode_text[] = 'arm_form_login="'.$form_slug.'"'; } else if( $shortcode_type == 'change_password' ){ $shortcode_text[] = 'arm_form_change_password="'.$form_slug.'"'; } else if( $shortcode_type == 'forgot_password' ){ $shortcode_text[] = 'arm_form_forgot_password="'.$form_slug.'"'; } } $is_exist = $this->arm_find_registration_match_func($shortcode_text, $post_content); } } break; default : break; } } return $is_exist; } function arm_shortcode_exist_in_page($shortcode_type = '', $page_id = 0) { global $wp, $wpdb, $ARMember, $arm_member_forms, $arm_capabilities_global; $is_exist = false; if (isset($_POST['action']) && $_POST['action'] == 'arm_shortcode_exist_in_page') { $shortcode_type = sanitize_text_field($_POST['shortcode_type']); $page_id = intval($_POST['page_id']); $ARMember->arm_check_user_cap($arm_capabilities_global['arm_manage_general_settings'], '1'); } $page_detail = get_post($page_id); if (!empty($shortcode_type) && !empty($page_detail->ID) && $page_detail->ID != 0) { $post_content = $page_detail->post_content; $shortcode_text = array(); switch ($shortcode_type) { case 'registration': case 'login': case 'forgot_password': case 'change_password': $is_shortcode = $this->arm_find_match_shortcode_func('arm_form', $post_content); $is_cs_shortcode = false; $is_cs_shortcode = apply_filters('armember_cs_check_shortcode_in_page', $is_cs_shortcode, 'cs_armember_cs', $post_content); if ($is_shortcode || $is_cs_shortcode) { $forms = $arm_member_forms->arm_get_member_forms_by_type($shortcode_type, false); if (!empty($forms)) { foreach ($forms as $form) { $form_slug = $form['arm_form_id']; $shortcode_text[] = "id='$form_slug'"; $shortcode_text[] = "id=$form_slug"; $shortcode_text[] = 'id="' . $form_slug . '"'; if ($shortcode_type == 'registration') { $shortcode_text[] = 'arm_form_registration="' . $form_slug . '"'; } else if ($shortcode_type == 'login') { $shortcode_text[] = 'arm_form_login="' . $form_slug . '"'; } else if ($shortcode_type == 'change_password') { $shortcode_text[] = 'arm_form_change_password="' . $form_slug . '"'; } else if ($shortcode_type == 'forgot_password') { $shortcode_text[] = 'arm_form_forgot_password="' . $form_slug . '"'; } } $is_exist = $this->arm_find_match_func($shortcode_text, $post_content); } } /* Check Membership Setup Wizard Shortcode */ if ($shortcode_type == 'registration' && !$is_exist) { $is_exist = $this->arm_find_match_shortcode_func('arm_setup', $post_content); if (!$is_exist) { $is_exist = apply_filters('armember_cs_check_shortcode_in_page', $is_exist, 'cs_armember_cs', $post_content); } } break; case 'edit_profile': $is_exist = $this->arm_find_match_shortcode_func('arm_edit_profile', $post_content); if (!$is_exist) { $is_exist = apply_filters('armember_cs_check_shortcode_in_page', $is_exist, 'cs_armember_cs', $post_content); } break; case 'members_directory': $is_exist = $this->arm_find_match_shortcode_func('arm_template', $post_content); break; default : break; } } if (isset($_POST['action']) && $_POST['action'] == 'arm_shortcode_exist_in_page') { echo json_encode(array('status' => $is_exist)); exit; } else { return $is_exist; } } function arm_find_match_shortcode_func($key = '', $string = '') { $matched = false; $pattern = '\[' . $key . '(.*?)\]'; if (!empty($key) && !empty($string)) { if (preg_match_all('/' . $pattern . '/s', $string, $matches) > 0) { $matched = true; } } return $matched; } function arm_find_match_func($key = array(), $string = '') { if (!empty($key) && !empty($string)) { foreach ($key as $val) { if (preg_match_all('/' . $val . '/s', $string, $matches) > 0) { return true; } } } return false; } function arm_find_registration_match_func($key = array(), $string = '') { if (!empty($key) && !empty($string)) { foreach ($key as $val) { if (preg_match_all('/' . $val . '/s', $string, $matches) > 0) { $val = preg_replace('/[a-z=\'\"]/','',$val); return $val; } } } return false; } /** * Parse shortcodes in Feed Post Excerpt */ function arm_filter_the_excerpt($content) { $isARMShortcode = $this->arm_find_match_shortcode_func('arm_', $content); if ($isARMShortcode) { $content = do_shortcode($content); } return $content; } function arm_get_all_roles() { $allRoles = array(); if (!function_exists('get_editable_roles') && file_exists(ABSPATH . '/wp-admin/includes/user.php')) { require_once(ABSPATH . '/wp-admin/includes/user.php'); } global $wp_roles; $roles = get_editable_roles(); if (!empty($roles)) { unset($roles['administrator']); foreach ($roles as $key => $role) { $allRoles[$key] = $role['name']; } } return $allRoles; } function arm_get_permalink($slug = '', $id = 0) { global $wp, $wpdb, $ARMember; $link = ARMLITE_HOME_URL; if (!empty($slug) && $slug != '') { $object = $wpdb->get_results("SELECT `ID` FROM " . $wpdb->posts . " WHERE `post_name`='" . $slug . "'"); if (!empty($object)) { $link = get_permalink($object[0]->ID); } } elseif (!empty($id) && $id != 0) { $link = get_permalink($id); } return $link; } function arm_get_user_profile_url($userid = 0, $show_admin_users = 0) { global $wp, $wpdb, $ARMember, $arm_social_feature; if ($show_admin_users == 0) { if (user_can($userid, 'administrator')) { return '#'; } } $profileUrl = ARMLITE_HOME_URL; if ($arm_social_feature->isSocialFeature) { if (isset($this->profile_url) && !empty($this->profile_url)) { $profileUrl = $this->profile_url; } else { $profile_page_id = isset($this->global_settings['member_profile_page_id']) ? $this->global_settings['member_profile_page_id'] : 0; $profile_page_url = get_permalink($profile_page_id); $profileUrl = (!empty($profile_page_url)) ? $profile_page_url : $profileUrl; $this->profile_url = $profileUrl; } if (!empty($userid) && $userid != 0) { $permalinkBase = isset($this->global_settings['profile_permalink_base']) ? $this->global_settings['profile_permalink_base'] : 'user_login'; $userBase = $userid; if ($permalinkBase == 'user_login') { $userInfo = get_userdata($userid); $userBase = $userInfo->user_login; } if (get_option('permalink_structure')) { $profileUrl = trailingslashit(untrailingslashit($profileUrl)); $profileUrl = $profileUrl . $userBase . '/'; } else { $profileUrl = $this->add_query_arg('arm_user', $userBase, $profileUrl); } } } else { if (isset($this->global_settings['edit_profile_page_id']) && $this->global_settings['edit_profile_page_id'] != 0) { $profileUrl = get_permalink($this->global_settings['edit_profile_page_id']); } } return $profileUrl; } function arm_user_query_vars($public_query_vars) { $public_query_vars[] = 'arm_user'; return $public_query_vars; } function arm_user_rewrite_rules() { global $wp, $wpdb, $wp_rewrite, $ARMember; $allGlobalSettings = $this->arm_get_all_global_settings(TRUE); if (isset($allGlobalSettings['member_profile_page_id']) && $allGlobalSettings['member_profile_page_id'] != 0) { $profile_page_id = $allGlobalSettings['member_profile_page_id']; $profilePage = get_post($profile_page_id); if (isset($profilePage->post_name)) { $profileSlug = $profilePage->post_name; add_rewrite_rule($profileSlug . '/([^/]+)/?$', 'index.php?page_id=' . $profile_page_id . '&arm_user=$matches[1]', 'top'); } } } function arm_generate_rewrite_rules( $wp_rewrite ) { global $wp, $wpdb, $wp_rewrite, $ARMember; $allGlobalSettings = $this->arm_get_all_global_settings(TRUE); if (isset($allGlobalSettings['member_profile_page_id']) && $allGlobalSettings['member_profile_page_id'] != 0) { $profile_page_id = $allGlobalSettings['member_profile_page_id']; $profilePage = get_post($profile_page_id); if (isset($profilePage->post_name)) { $profileSlug = $profilePage->post_name; //add_rewrite_rule($profileSlug . '/([^/]+)/?$', 'index.php?page_id=' . $profile_page_id . '&arm_user=$matches[1]', 'top'); $feed_rules = array( $profileSlug.'/([^/]+)/?$' => 'index.php?page_id=' . $profile_page_id . '&arm_user=$matches[1]', ); $wp_rewrite->rules = $feed_rules + $wp_rewrite->rules; } } return $wp_rewrite->rules; } /** * Create Pagination Links * @param Int $total Total Number Of Records * @param Int $per_page Number Of Records Per Page */ function arm_get_paging_links($current = 1, $total = 10, $per_page = 10, $type = "") { global $wp, $wp_rewrite; $return_links = ''; $current = (!empty($current) && $current != 0) ? $current : 1; $total_links = ceil($total / $per_page); /* Don't print empty markup if there's only one page. */ if ($total_links < 1) { return; } $end_size = 1; $mid_size = 1; $page_links = array(); $dots = false; if ($current && 1 < $current) { $page_links[] = ''; } else { $page_links[] = ''; } for ($n = 1; $n <= $total_links; $n++) { if ($n == $current) { $page_links[] = '' . number_format_i18n($n) . ''; $dots = true; } else { if ($n <= $end_size || ($current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total_links - $end_size) { $page_links[] = '' . number_format_i18n($n) . ''; $dots = true; } elseif ($dots) { $page_links[] = ''; $dots = false; } } } if ($current && ( $current < $total_links || -1 == $total_links )) { $page_links[] = ''; } else { $page_links[] = ''; } if (!empty($page_links)) { $startNum = (!empty($current) && $current > 1) ? (($current - 1) * $per_page) + 1 : 1; $endNum = $current * $per_page; $endNum = ($endNum > $total) ? $total : $endNum; /* Join Links */ $links = join("\n", $page_links); $return_links = '
'; $return_links .= '
'; switch ($type) { case 'activity': $return_links .= __('Showing', 'ARMember') . ' ' . $startNum . ' ' . __('to', 'ARMember') . ' ' . $endNum . ' ' . __('of', 'ARMember') . ' ' . $total . ' ' . __('total activities', 'ARMember'); break; case 'membership_history': $return_links .= __('Showing', 'ARMember') . ' ' . $startNum . ' ' . __('to', 'ARMember') . ' ' . $endNum . ' ' . __('of', 'ARMember') . ' ' . $total . ' ' . __('total records', 'ARMember'); break; case 'directory': $return_links .= __('Showing', 'ARMember') . ' ' . $startNum . ' - ' . $endNum . ' ' . __('of', 'ARMember') . ' ' . $total . ' ' . __('members', 'ARMember'); break; case 'transaction': $return_links .= __('Showing', 'ARMember') . ' ' . $startNum . ' - ' . $endNum . ' ' . __('of', 'ARMember') . ' ' . $total . ' ' . __('transactions', 'ARMember'); break; default: $return_links .= __('Showing', 'ARMember') . ' ' . $startNum . ' - ' . $endNum . ' ' . __('of', 'ARMember') . ' ' . $total . ' ' . __('records', 'ARMember'); break; } $return_links .= '
'; $return_links .= ''; $return_links .= '
'; } return $return_links; } function arm_filter_get_avatar($avatar, $id_or_email, $size, $default, $alt = '') { global $pagenow; /* Do not filter if inside WordPress options page OR `enable_gravatar` set to '0' */ if ('options-discussion.php' == $pagenow) { return $avatar; } $user_avatar = $this->arm_get_user_avatar($id_or_email, $size, $default, $alt); if (!empty($user_avatar)) { $avatar = $user_avatar; } else { if ($this->global_settings['enable_gravatar'] == '0') { $avatar = ""; } else { $avatar = str_replace('avatar-' . $size, 'arm_grid_avatar arm-avatar avatar-' . $size, $avatar); } } return apply_filters('arm_change_user_avatar', $avatar, $id_or_email, $size, $default, $alt); } function arm_get_avatar($id_or_email, $size = '96', $default = '', $alt = false) { global $wp, $wpdb, $ARMember; $user_avatar = $this->arm_get_user_avatar($id_or_email, $size, $default, $alt); if ($this->global_settings['enable_gravatar'] == '1' && !empty($user_avatar)) { $avatar = apply_filters('arm_change_user_avatar', $user_avatar, $id_or_email, $size, $default, $alt); } else { $avatar = get_avatar($id_or_email, $size, $default, $alt); } return $avatar; } function arm_get_user_avatar($id_or_email, $size = '96', $default = '', $alt = false) { global $wp, $wpdb, $ARMember; $safe_alt = (false === $alt) ? '' : esc_attr($alt); if (is_numeric($id_or_email)) { $user_id = (int) $id_or_email; } elseif (is_string($id_or_email) && ($user = get_user_by('email', $id_or_email))) { $user_id = $user->ID; } elseif (is_object($id_or_email) && !empty($id_or_email->user_id)) { $user_id = (int) $id_or_email->user_id; } else { $user_id = 0; } $user = get_user_by('id', $user_id); $avatar_url = get_user_meta($user_id, 'avatar', true); $avatar_w_h_class = ''; if (!empty($avatar_url) && file_exists(MEMBERSHIPLITE_UPLOAD_DIR . '/' . basename($avatar_url))) { $avatar_detail = @getimagesize(MEMBERSHIPLITE_UPLOAD_DIR . '/' . basename($avatar_url)); if ($size > $avatar_detail[0]) { $avatar_w_h_class = ' arm_avatar_small_width'; } if ($size > $avatar_detail[1]) { $avatar_w_h_class .= ' arm_avatar_small_height'; } } $avatar_class = 'arm_grid_avatar gravatar avatar arm-avatar photo avatar-' . $size . ' ' . $avatar_w_h_class; if (empty($safe_alt) && $user) { $safe_alt = __('Profile photo of', 'ARMember') . $user->user_login; } if (!empty($avatar_url) && file_exists(MEMBERSHIPLITE_UPLOAD_DIR . '/' . basename($avatar_url))) { $avatar_filesize = @filesize(MEMBERSHIPLITE_UPLOAD_DIR . '/' . basename($avatar_url)); if($avatar_filesize>0) { if (file_exists(strstr($avatar_url, "//"))) { $avatar_url = strstr($avatar_url, "//"); } else if (file_exists($avatar_url)) { $avatar_url = $avatar_url; } else { $avatar_url = $avatar_url; } $avatar = '' . $safe_alt . ''; } else { $avatar = ''; } } else { $avatar = ''; } return $avatar; } function arm_default_avatar_url($default = '') { global $wp, $wpdb, $ARMember; $avatar_default = get_option('avatar_default'); $default = (!empty($avatar_default)) ? $avatar_default : 'mystery'; if (is_ssl()) { $host = 'https://secure.gravatar.com'; } else { $host = 'http://0.gravatar.com'; } if ('mystery' == $default) { $default = "$host/avatar/ad516503a11cd5ca435acc9bb6523536?s={$size}"; } elseif ('blank' == $default) { $default = includes_url('images/blank.gif'); } elseif ('gravatar_default' == $default) { $default = "$host/avatar/?s={$size}"; } elseif (strpos($default, 'http://') === 0) { $default = add_query_arg('s', $size, $default); } return esc_url($default); } /** * Get Single Global Setting by option name */ function arm_get_single_global_settings($option_name, $default = '') { global $wpdb, $ARMember, $arm_members_class, $arm_member_forms; $all_settings = $this->global_settings; $option_value = $default; if (!empty($option_name)) { if (isset($all_settings[$option_name]) && !empty($all_settings[$option_name])) { $option_value = $all_settings[$option_name]; } elseif ($option_name == 'page_settings') { $defaultGS = $this->arm_default_global_settings(); $option_value = shortcode_atts($defaultGS['page_settings'], $all_settings); } } return $option_value; } function arm_get_all_global_settings($merge = FALSE) { global $wpdb, $ARMember, $arm_members_class, $arm_member_forms; $default_global_settings = $this->arm_default_global_settings(); $global_settings = get_option('arm_global_settings', $default_global_settings); $all_global_settings = maybe_unserialize($global_settings); $all_global_settings = apply_filters('arm_get_all_global_settings', $all_global_settings); if ($merge) { $all_global_settings['general_settings'] = isset($all_global_settings['general_settings']) ? $all_global_settings['general_settings'] : $default_global_settings['general_settings']; $all_global_settings['page_settings'] = isset($all_global_settings['page_settings']) ? $all_global_settings['page_settings'] : $default_global_settings['page_settings']; $arm_merge_global_settings = array_merge($all_global_settings['general_settings'], $all_global_settings['page_settings']); return $arm_merge_global_settings; } return $all_global_settings; } function arm_get_all_block_settings() { global $wpdb, $ARMember, $arm_members_class, $arm_member_forms; $default_block_settings = array( 'failed_login_lockdown' => 1, 'remained_login_attempts' => 1, 'track_login_history' => 1, 'max_login_retries' => 5, 'temporary_lockdown_duration' => 10, 'permanent_login_retries' => 15, 'permanent_lockdown_duration' => 24, 'arm_block_usernames' => '', 'arm_block_usernames_msg' => __('Username should not contain bad words.', 'ARMember'), 'arm_block_emails' => '', 'arm_block_emails_msg' => __('Email Address should not contain bad words.', 'ARMember'), ); $block_settings = get_option('arm_block_settings', $default_block_settings); $all_block_settings = maybe_unserialize($block_settings); if(!is_array($all_block_settings)) { $all_block_settings = array(); } $all_block_settings['arm_block_usernames_msg'] = !empty($all_block_settings['arm_block_usernames_msg']) ? stripslashes($all_block_settings['arm_block_usernames_msg']) : ''; $all_block_settings['arm_block_emails_msg'] = !empty($all_block_settings['arm_block_emails_msg']) ? stripslashes($all_block_settings['arm_block_emails_msg']) : ''; $all_block_settings = apply_filters('arm_get_all_block_settings', $all_block_settings); return $all_block_settings; } function arm_get_parsed_block_settings() { global $wpdb, $ARMember, $arm_members_class, $arm_member_forms; $parsed_block_settings = $this->arm_get_all_block_settings(); if(is_array($parsed_block_settings)) { foreach ($parsed_block_settings as $type => $val) { if (!empty($val) && in_array($type, array('arm_block_usernames', 'arm_block_emails'))) { $new_val = array_map('strtolower', array_map('trim', explode("\n", $val))); $parsed_block_settings[$type] = $new_val; } } } $parsed_block_settings = apply_filters('arm_get_parsed_block_settings', $parsed_block_settings); return $parsed_block_settings; } function arm_get_all_common_message_settings() { global $wpdb, $ARMember, $arm_members_class, $arm_member_forms; $arm_default_common_messages = $this->arm_default_common_messages(); $common_message_settings = get_option('arm_common_message_settings', $arm_default_common_messages); $all_common_message_settings = maybe_unserialize($common_message_settings); $all_common_message_settings = (!empty($all_common_message_settings)) ? $all_common_message_settings : array(); if (!empty($all_common_message_settings)) { foreach ($all_common_message_settings as $key => $val) { $all_common_message_settings[$key] = stripslashes($val); } } $all_common_message_settings = apply_filters('arm_get_all_common_message_settings', $all_common_message_settings); return $all_common_message_settings; } function arm_update_all_settings() { global $wpdb, $wp_rewrite, $ARMember, $arm_members_class, $arm_member_forms, $arm_email_settings, $arm_payment_gateways, $arm_access_rules, $arm_crons, $arm_capabilities_global; $response = array('type' => 'error', 'msg' => __('There is a error while updating settings, please try again.', 'ARMember')); $is_new_wp_admin_path = FALSE; $default_global_settings = $this->arm_default_global_settings(); $old_global_settings = $this->arm_get_all_global_settings(); if (isset($_POST['action']) && $_POST['action'] == 'arm_update_global_settings') { $ARMember->arm_check_user_cap($arm_capabilities_global['arm_manage_general_settings'], '1'); $save_all = isset($_POST['save_all']) ? $_POST['save_all'] : ''; $_POST['arm_general_settings']['hide_register_link'] = isset($_POST['arm_general_settings']['hide_register_link']) ? intval($_POST['arm_general_settings']['hide_register_link']) : 0; $_POST['arm_general_settings']['enable_gravatar'] = isset($_POST['arm_general_settings']['enable_gravatar']) ? intval($_POST['arm_general_settings']['enable_gravatar']) : 0; $_POST['arm_general_settings']['enable_crop'] = isset($_POST['arm_general_settings']['enable_crop']) ? intval($_POST['arm_general_settings']['enable_crop']) : 0; $_POST['arm_general_settings']['enable_tax'] = isset($_POST['arm_general_settings']['enable_tax']) ? $_POST['arm_general_settings']['enable_tax'] : 0; $arm_general_settings = isset($_POST['arm_general_settings']) ? $_POST['arm_general_settings'] : array(); $new_global_settings['general_settings'] = shortcode_atts($default_global_settings['general_settings'], $arm_general_settings); if ($new_global_settings['general_settings']['user_register_verification'] != 'auto') { $new_global_settings['general_settings']['arm_new_signup_status'] = 3; } $flush_rewrite_rules = false; $all_saved_global_settings = maybe_unserialize(get_option('arm_global_settings')); $logout = true; $home_root = parse_url(home_url()); if (isset($home_root['path'])) $home_root = trailingslashit($home_root['path']); else $home_root = '/'; if (!isset($new_global_settings['general_settings']['custom_currency']['status'])) { $new_global_settings['general_settings']['custom_currency'] = array( 'status' => 0, 'symbol' => '', 'shortname' => '', 'place' => 'prefix', ); } $new_global_settings['page_settings'] = $old_global_settings['page_settings']; $arm_exclude_role_for_hide_admin = ( isset($_POST['arm_general_settings']['arm_exclude_role_for_hide_admin']) && !empty($_POST['arm_general_settings']['arm_exclude_role_for_hide_admin']) )? implode(',',$_POST['arm_general_settings']['arm_exclude_role_for_hide_admin']) : ''; $new_general_settings['arm_exclude_role_for_hide_admin'] = $arm_exclude_role_for_hide_admin; // set old global setting because its updated from other page $new_global_settings['general_settings']['arm_exclude_role_for_restrict_admin'] = isset($old_global_settings['general_settings']['arm_exclude_role_for_restrict_admin']) ? $old_global_settings['general_settings']['arm_exclude_role_for_restrict_admin'] : ''; $new_global_settings['general_settings']['restrict_admin_panel'] = isset($old_global_settings['general_settings']['restrict_admin_panel']) ? $old_global_settings['general_settings']['restrict_admin_panel'] : 0; $new_global_settings['page_settings']['guest_page_id'] = isset($old_global_settings['page_settings']['guest_page_id']) ? $old_global_settings['page_settings']['guest_page_id'] : 0; $new_global_settings['page_settings']['arm_access_page_for_restrict_site'] = isset($old_global_settings['page_settings']['arm_access_page_for_restrict_site']) ? $old_global_settings['page_settings']['arm_access_page_for_restrict_site'] : ''; $new_global_settings = apply_filters('arm_before_update_global_settings', $new_global_settings, $_POST); /* -------- Update Email Schedular Start ------- */ $arm_old_general_settings = $old_global_settings['general_settings']; $arm_old_email_schedular = isset($arm_old_general_settings['arm_email_schedular_time']) ? $arm_old_general_settings['arm_email_schedular_time'] : 0; if ($arm_old_email_schedular != $new_global_settings['general_settings']['arm_email_schedular_time']) { $arm_all_crons = $arm_crons->arm_get_cron_hook_names(); foreach ($arm_all_crons as $arm_cron_hook_name) { $arm_crons->arm_clear_cron($arm_cron_hook_name); } } /* -------- Update Email Schedular End------- */ $new_global_settings_result = maybe_serialize($new_global_settings); update_option('arm_global_settings', $new_global_settings_result); $arm_email_settings->arm_update_email_settings(); $arm_payment_gateways->arm_update_payment_gate_status(); $response = array('type' => 'success', 'msg' => __('Global Settings Saved Successfully.', 'ARMember')); if (isset($redirect_to) && $redirect_to != '') { if (!$logout) { $response['url'] = $redirect_to; } else { wp_destroy_current_session(); wp_clear_auth_cookie(); $response['url'] = wp_login_url(); } } } if (isset($_POST['action']) && $_POST['action'] == 'arm_page_settings') { $ARMember->arm_check_user_cap($arm_capabilities_global['arm_manage_general_settings'], '1'); $default_global_settings = $this->arm_default_global_settings(); $arm_page_settings = $_POST['arm_page_settings']; $old_page_settings = shortcode_atts($default_global_settings['page_settings'], $old_global_settings['page_settings']); $new_global_settings['page_settings'] = shortcode_atts($old_page_settings, $arm_page_settings); $new_global_settings['general_settings'] = $old_global_settings['general_settings']; $new_global_settings = apply_filters('arm_before_update_page_settings', $new_global_settings, $_POST); $new_global_settings_result = maybe_serialize($new_global_settings); update_option('arm_global_settings', $new_global_settings_result); $this->arm_user_rewrite_rules(); $wp_rewrite->flush_rules(false); $response = array('type' => 'success', 'msg' => __('Page Settings Saved Successfully.', 'ARMember')); } if (isset($_POST['action']) && $_POST['action'] == 'arm_update_block_settings') { $ARMember->arm_check_user_cap($arm_capabilities_global['arm_manage_block_settings'], '1'); $post_block_settings = $_POST['arm_block_settings']; $post_block_settings['failed_login_lockdown'] = isset($post_block_settings['failed_login_lockdown']) ? intval($post_block_settings['failed_login_lockdown']) : 0; $post_block_settings['remained_login_attempts'] = isset($post_block_settings['remained_login_attempts']) ? intval($post_block_settings['remained_login_attempts']) : 0; $post_block_settings['track_login_history'] = isset($post_block_settings['track_login_history']) ? intval($post_block_settings['track_login_history']) : 0; $arm_block_usernames = implode(PHP_EOL, array_filter(array_map('trim', explode(PHP_EOL, $post_block_settings['arm_block_usernames'])))); $arm_block_emails = implode(PHP_EOL, array_filter(array_map('trim', explode(PHP_EOL, $post_block_settings['arm_block_emails'])))); $is_update = true; if ($is_update == true) { $post_block_settings['arm_block_usernames'] = $arm_block_usernames; $post_block_settings['arm_block_emails'] = $arm_block_emails; $post_block_settings = apply_filters('arm_before_update_block_settings', $post_block_settings, $_POST); $new_block_settings_result = maybe_serialize($post_block_settings); update_option('arm_block_settings', $new_block_settings_result); $response = array('type' => 'success', 'msg' => __('Settings Saved Successfully.', 'ARMember')); } else { $response = array('type' => 'error', 'msg' => __('Some of users are having administrator previlegs. So those cant be block.', 'ARMember')); } } if (isset($_POST['action']) && $_POST['action'] == 'arm_update_redirect_settings') { $ARMember->arm_check_user_cap($arm_capabilities_global['arm_manage_general_settings'], '1'); $post_redirection_settings = $_POST['arm_redirection_settings']; $default_redirection_url = $post_redirection_settings['login']['conditional_redirect']['default']; unset($post_redirection_settings['login']['conditional_redirect']['default']); $post_redirection_settings['login']['conditional_redirect'] = array_values($post_redirection_settings['login']['conditional_redirect']); $post_redirection_settings['login']['conditional_redirect']['default'] = $default_redirection_url; $is_update = true; if ($is_update == true) { $post_redirection_settings = apply_filters('arm_before_update_redirection_settings', $post_redirection_settings, $_POST); $new_redirection_settings_result = maybe_serialize($post_redirection_settings); update_option('arm_redirection_settings', $new_redirection_settings_result); $response = array('type' => 'success', 'msg' => __('Settings Saved Successfully.', 'ARMember')); } else { $response = array('type' => 'error', 'msg' => __('Some of users are having administrator previlegs. So those cant be block.', 'ARMember')); } } if (isset($_POST['action']) && $_POST['action'] == 'arm_update_common_message_settings') { $ARMember->arm_check_user_cap($arm_capabilities_global['arm_manage_general_settings'], '1'); $common_message = $_POST['arm_common_message_settings']; $common_message = apply_filters('arm_before_update_common_message_settings', $common_message, $_POST); $new_common_message_settings_result = maybe_serialize($common_message); update_option('arm_common_message_settings', $new_common_message_settings_result); $response = array('type' => 'success', 'msg' => __('Settings Saved Successfully.', 'ARMember')); } if (isset($_POST['action']) && $_POST['action'] == 'arm_update_access_restriction_settings') { $ARMember->arm_check_user_cap($arm_capabilities_global['arm_manage_general_settings'], '1'); $default_global_settings = $this->arm_default_global_settings(); $restrict_admin_panel = isset($_POST['arm_general_settings']['restrict_admin_panel']) ? $_POST['arm_general_settings']['restrict_admin_panel'] : 0; $arm_exclude_role_for_restrict_admin = ( isset($_POST['arm_general_settings']['arm_exclude_role_for_restrict_admin']) && !empty($_POST['arm_general_settings']['arm_exclude_role_for_restrict_admin']) )? implode(',',$_POST['arm_general_settings']['arm_exclude_role_for_restrict_admin']) : ''; $new_general_settings = shortcode_atts($default_global_settings['general_settings'], $old_global_settings['general_settings']); $new_global_settings['page_settings'] = $old_global_settings['page_settings']; $new_global_settings['page_settings']['guest_page_id'] = isset($_POST['arm_page_settings']['guest_page_id']) ? intval($_POST['arm_page_settings']['guest_page_id']) : 0; $new_global_settings['page_settings']['arm_access_page_for_restrict_site'] = (isset($_POST['arm_general_settings']['arm_access_page_for_restrict_site']) && !empty($_POST['arm_general_settings']['arm_access_page_for_restrict_site'])) ? implode(',',$_POST['arm_general_settings']['arm_access_page_for_restrict_site']) : ''; $new_global_settings['general_settings'] = $new_general_settings; $new_global_settings = apply_filters('arm_before_update_access_restriction_settings', $new_global_settings, $_POST); $new_global_settings_result = maybe_serialize($new_global_settings); update_option('arm_global_settings', $new_global_settings_result); $arm_access_rules->arm_update_default_access_rules(); $response = array('type' => 'success', 'msg' => __('Global Settings Saved Successfully.', 'ARMember')); } echo json_encode($response); die(); } function remove_loginpage_label_text($text) { $remove_txts = array( 'username', 'username:', 'username *', 'username or email', 'password', 'my password:', 'password *', 'e-mail', 'email address *', 'first name *', 'last name *', ); if (in_array(strtolower($text), $remove_txts)) { $text = ''; } if ($text == 'Remember Me') { $text = 'Remember'; } return $text; } function arm_remove_registration_link($value) { global $wpdb, $ARMember, $arm_members_class, $arm_member_forms, $pagenow; $hideRegister = isset($this->global_settings['hide_register_link']) ? $this->global_settings['hide_register_link'] : 0; if ($hideRegister == 1) { $action = isset($_GET['action']) ? $_GET['action'] : ''; if ($pagenow == 'wp-login.php' && $action != 'register') { $value = false; } } return $value; } function arm_login_enqueue_assets() { global $arm_global_settings, $ARMember; $all_global_settings = $arm_global_settings->arm_get_all_global_settings(); $general_settings = $all_global_settings['general_settings']; wp_enqueue_style('arm_wp_login', MEMBERSHIPLITE_URL . '/css/arm_wp_login.css', array(), MEMBERSHIPLITE_VERSION); if (version_compare($GLOBALS['wp_version'], '3.8', '<')) { wp_enqueue_style('arm_login_css_lt_3.8', MEMBERSHIPLITE_URL . '/css/arm_login_lt_3.8.css', array(), MEMBERSHIPLITE_VERSION); } ?> $v) { if ($v === false) { unset($qs[$k]); } } $ret = build_query($qs); $ret = trim($ret, '?'); $ret = preg_replace('#=(&|$)#', '$1', $ret); $ret = $protocol . $base . $ret . $frag; $ret = rtrim($ret, '?'); $ret = esc_url_raw($ret); return $ret; } public function handle_return_messages($errors = '', $message = '') { global $wpdb, $ARMember, $arm_members_class; $type = 'error'; $return = ''; if (!empty($errors)) { if (isset($errors) && is_array($errors) && count($errors) > 0) { foreach ($errors as $error) { $return .= '
' . stripslashes($error) . '
'; } } } elseif (isset($message) && $message != '') { $type = 'success'; $return = $message; } else { $return = false; } return array('type' => $type, 'msg' => $return); } public function get_param($param, $default = '', $src = 'get') { if (strpos($param, '[')) { $params = explode('[', $param); $param = $params[0]; } @$str = stripslashes_deep(@$_POST['form']); @$str = json_decode(@$str, true); if ($src == 'get') { $value = ( isset($_POST[$param]) ? stripslashes_deep($_POST[$param]) : (isset($str[$param]) ? stripslashes_deep($str[$param]) : (isset($_GET[$param]) ? stripslashes_deep($_GET[$param]) : $default))); if ((!isset($_POST[$param]) or ! isset($str[$param])) and isset($_GET[$param]) and ! is_array($value)) { $value = urldecode($value); } } else { $value = isset($_POST[$param]) ? stripslashes_deep(maybe_unserialize($_POST[$param])) : isset($str[$param]) ? stripslashes_deep(maybe_unserialize($str[$param])) : $default; } if (isset($params) and is_array($value) and ! empty($value)) { foreach ($params as $k => $p) { if (!$k or ! is_array($value)) { continue; } $p = trim($p, ']'); $value = (isset($value[$p])) ? $value[$p] : $default; } } return $value; } public function get_unique_key($name = '', $table_name = '', $column = '', $id = 0, $num_chars = 8) { global $wpdb; $key = ''; if (!empty($name)) { if (function_exists('sanitize_key')) $key = sanitize_key($name); else $key = sanitize_title_with_dashes($name); } if (empty($key)) { $max_slug_value = pow(36, $num_chars); $min_slug_value = 37; $key = base_convert(rand($min_slug_value, $max_slug_value), 10, 36); } if (!empty($table_name)) { $query = "SELECT $column FROM `$table_name` WHERE `$column` = '%s' LIMIT 1"; $key_check = $wpdb->get_var($wpdb->prepare($query, $key)); if ($key_check or is_numeric($key_check)) { $suffix = 2; do { $alt_post_name = substr($key, 0, 200 - (strlen($suffix) + 1)) . "$suffix"; $key_check = $wpdb->get_var($wpdb->prepare($query, $alt_post_name, $id)); $suffix++; } while ($key_check || is_numeric($key_check)); $key = $alt_post_name; } } return $key; } public function armStringMatchWithWildcard($source, $pattern) { $pattern = preg_quote($pattern, '/'); $pattern = str_replace('\*', '.*', $pattern); return preg_match('/^' . $pattern . '$/i', $source); } public function arm_find_url_match($check_url = '', $urls = array()) { global $wp, $wpdb, $arm_errors; if (!empty($check_url) && !empty($urls)) { if (!preg_match('#^http(s)?://#', $check_url)) { $check_url = 'http://' . $check_url; } $parse_check_url = parse_url($check_url); $parse_check_url['path'] = (isset($parse_check_url['path'])) ? $parse_check_url['path'] : ''; $parse_check_url['query'] = (isset($parse_check_url['query'])) ? $parse_check_url['query'] : ''; foreach ($urls as $url) { $check_wildcard = explode('*', $url); $wildcard_count = substr_count($url, '*'); if ($wildcard_count > 0) { if ($this->armStringMatchWithWildcard($check_url, $url)) { return TRUE; } if ($this->armStringMatchWithWildcard($check_url, $url . '/')) { return TRUE; } } else { if (!preg_match('/^http(s)?:\/\//', $url)) { $url = 'http://' . $url; } $parse_url = parse_url($url); $parse_url['path'] = (isset($parse_url['path'])) ? $parse_url['path'] : ''; $parse_url['query'] = (isset($parse_url['query'])) ? $parse_url['query'] : ''; /* Compare URL Details. */ $diff = array_diff($parse_check_url, $parse_url); if ($parse_check_url['path'] == $parse_url['path']) { if (isset($parse_check_url['query']) || isset($parse_url['query'])) { if ($parse_check_url['query'] == $parse_url['query']) { return TRUE; } else { continue; } } return TRUE; } } } } return FALSE; } /** * Set Email Content Type */ public function arm_mail_content_type() { return 'text/html'; } public function arm_mailer($temp_slug, $user_id, $admin_template_id = '', $follower_id = '') { global $wpdb, $ARMember, $arm_slugs, $arm_email_settings; if (!empty($user_id) && $user_id != 0) { $user_info = get_user_by('id', $user_id); $to_user = $user_info->user_email; $to_admin = get_option('admin_email'); $all_email_settings = $arm_email_settings->arm_get_all_email_settings(); if (!empty($temp_slug)) { $template = $arm_email_settings->arm_get_email_template($temp_slug); if ($template->arm_template_status == '1') { $message = $this->arm_filter_email_with_user_detail($template->arm_template_content, $user_id, 0, $follower_id); $subject = $this->arm_filter_email_with_user_detail($template->arm_template_subject, $user_id, 0, $follower_id); /* Send Email To User */ $user_send_mail = $this->arm_wp_mail('', $to_user, $subject, $message); } } if (!empty($admin_template_id)) { $admin_template = $arm_email_settings->arm_get_single_email_template($admin_template_id); if ($admin_template->arm_template_status == '1') { $message_admin = $this->arm_filter_email_with_user_detail($admin_template->arm_template_content, $user_id, 0, $follower_id); $subject_admin = $this->arm_filter_email_with_user_detail($admin_template->arm_template_subject, $user_id, 0, $follower_id); $admin_send_mail = $this->arm_send_message_to_armember_admin_users($to_user, $subject_admin, $message_admin); } } } } public function arm_send_message_to_armember_admin_users($from = '', $subject = '', $message = '') { global $arm_email_settings, $arm_global_settings; $all_email_settings = $arm_email_settings->arm_get_all_email_settings(); $admin_email = (!empty($all_email_settings['arm_email_admin_email'])) ? $all_email_settings['arm_email_admin_email'] : get_option('admin_email'); $exploded_admin_email = array(); if (strpos($admin_email, ',') !== false) { $exploded_admin_email = explode(",", trim($admin_email)); } if (isset($exploded_admin_email) && !empty($exploded_admin_email)) { foreach ($exploded_admin_email as $admin_email_from_array) { if ($admin_email_from_array != '') { $admin_email_from_array = apply_filters('arm_admin_email', trim($admin_email_from_array)); $admin_send_mail = $arm_global_settings->arm_wp_mail($from, $admin_email_from_array, $subject, $message); } } } else { if ($admin_email) { $admin_email = apply_filters('arm_admin_email', $admin_email); $admin_send_mail = $arm_global_settings->arm_wp_mail($from, $admin_email, $subject, $message); } } return $admin_send_mail; } public function arm_wp_mail($from, $recipient, $subject, $message, $attachments = array()) { global $wp, $wpdb, $ARMember, $arm_slugs, $arm_email_settings, $arm_plain_text; remove_all_actions('phpmailer_init'); $return = false; $emailSettings = $arm_email_settings->arm_get_all_email_settings(); $arm_mail_authentication = (isset($emailSettings['arm_mail_authentication'])) ? $emailSettings['arm_mail_authentication'] : '1'; $email_server = (!empty($emailSettings['arm_email_server'])) ? $emailSettings['arm_email_server'] : 'wordpress_server'; $from_name = (!empty($emailSettings['arm_email_from_name'])) ? $emailSettings['arm_email_from_name'] : wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); $from_email = (!empty($emailSettings['arm_email_from_email'])) ? $emailSettings['arm_email_from_email'] : get_option('admin_email'); $content_type = (@$arm_plain_text) ? 'text/plain' : 'text/html'; $from_name = $from_name; $reply_to = (!empty($from)) ? $from : $from_email; /* Set Email Headers */ $headers = array(); //$headers[] = 'From: "' . $from_name . '" <' . $reply_to . '>'; $headers[] = 'From: "' . $from_name . '" <' . $from_email . '>'; $headers[] = 'Reply-To: ' . $reply_to; $headers[] = 'Content-Type: ' . $content_type . '; charset="' . get_option('blog_charset') . '"'; /* Filter Email Subject & Message */ $subject = wp_specialchars_decode(strip_tags(stripslashes($subject)), ENT_QUOTES); $message = do_shortcode($message); $message = wordwrap(stripslashes($message), 70, "\r\n"); if (@$arm_plain_text) { $message = wp_specialchars_decode(strip_tags($message), ENT_QUOTES); } $subject = apply_filters('arm_email_subject', $subject); $message = apply_filters('arm_change_email_content', $message); $recipient = apply_filters('arm_email_recipients', $recipient); $headers = apply_filters('arm_email_header', $headers, $recipient, $subject); remove_filter('wp_mail_from', 'bp_core_email_from_address_filter'); remove_filter('wp_mail_from_name', 'bp_core_email_from_name_filter'); if (file_exists(MEMBERSHIPLITE_LIBRARY_DIR . '/phpmailer/class.arm_phpmailer.php')) { require_once(MEMBERSHIPLITE_LIBRARY_DIR . '/phpmailer/class.arm_phpmailer.php' ); } if (file_exists(MEMBERSHIPLITE_LIBRARY_DIR . '/phpmailer/class.smtp.php')) { require_once(MEMBERSHIPLITE_LIBRARY_DIR . '/phpmailer/class.smtp.php' ); } do_action('arm_before_send_email_notification', $from, $recipient, $subject, $message, $attachments); $armPMailer = new armPHPMailer(); /* Character Set of the message. */ $armPMailer->CharSet = "UTF-8"; $armPMailer->SMTPDebug = 0; /* $armPMailer->Debugoutput = 'html'; */ if ($email_server == 'smtp_server') { $armPMailer->isSMTP(); $armPMailer->Host = isset($emailSettings['arm_mail_server']) ? $emailSettings['arm_mail_server'] : ''; $armPMailer->SMTPAuth = ($arm_mail_authentication==1) ? true : false; $armPMailer->Username = isset($emailSettings['arm_mail_login_name']) ? $emailSettings['arm_mail_login_name'] : ''; $armPMailer->Password = isset($emailSettings['arm_mail_password']) ? $emailSettings['arm_mail_password'] : ''; if (isset($emailSettings['arm_smtp_enc']) && !empty($emailSettings['arm_smtp_enc']) && $emailSettings['arm_smtp_enc'] != 'none') { $armPMailer->SMTPSecure = $emailSettings['arm_smtp_enc']; } if($emailSettings['arm_smtp_enc'] == 'none'){ $armPMailer->SMTPAutoTLS = false; } $armPMailer->Port = isset($emailSettings['arm_mail_port']) ? $emailSettings['arm_mail_port'] : ''; } else { $armPMailer->isMail(); } $armPMailer->setFrom($from_email, $from_name); $armPMailer->addReplyTo($reply_to, $from_name); $armPMailer->addAddress($recipient); if (isset($attachments) && !empty($attachments)) { foreach ($attachments as $attachment) { $armPMailer->addAttachment($attachment); } } $armPMailer->isHTML(true); $armPMailer->Subject = $subject; $armPMailer->Body = $message; if (@$arm_plain_text) { $armPMailer->AltBody = $message; } if (MEMBERSHIPLITE_DEBUG_LOG == true) { if (MEMBERSHIPLITE_DEBUG_LOG_TYPE == 'ARM_ALL' || MEMBERSHIPLITE_DEBUG_LOG_TYPE == 'ARM_MAIL') { global $arm_case_types, $wpdb; $arm_case_types['mail']['protected'] = true; $arm_case_types['mail']['type'] = ''; $arm_case_types['mail']['message'] = " Email Server : " . $email_server . "
Email Recipient : " . $recipient . "
Message Content : " . $message; $ARMember->arm_debug_response_log('arm_wp_mail', $arm_case_types, array(), $wpdb->last_query, true); } } /* Send Email */ if ($email_server == 'smtp_server' || $email_server == 'phpmailer') { if ($armPMailer->send()) { $return = true; } } else { add_filter('wp_mail_content_type', array($this, 'arm_mail_content_type')); if (!wp_mail($recipient, $subject, $message, $headers, $attachments)) { if ($armPMailer->send()) { $return = true; } } else { $return = true; } remove_filter('wp_mail_content_type', array($this, 'arm_mail_content_type')); } do_action('arm_after_send_email_notification', $from, $recipient, $subject, $message, $attachments); return $return; } public function arm_filter_email_with_user_detail($content, $user_id = 0, $plan_id = 0, $follower_id = 0, $key = '') { global $wp, $wpdb, $ARMember, $arm_slugs, $arm_payment_gateways, $arm_email_settings, $arm_global_settings; $user_info = get_user_by('id', $user_id); $f_displayname = ''; $u_plan_description = ''; if ($follower_id != 0 && !empty($follower_id)) { $follower_info = get_user_by('id', $follower_id); $follower_name = $follower_info->first_name . ' ' . $follower_info->last_name; if (empty($follower_info->first_name) && empty($follower_info->last_name)) { $follower_name = $follower_info->user_login; } $f_displayname = "" . $follower_name . ""; } if ($user_id != 0 && !empty($user_info)) { $u_email = $user_info->user_email; $u_displayname = $user_info->display_name; $u_username = $user_info->user_login; $u_fname = $user_info->first_name; $u_lname = $user_info->last_name; $u_grace_period_days = 0; $u_trial_amount = 0; $u_plan_discount = 0; $u_payable_amount = 0; $now = current_time('timestamp'); // or your date as well $arm_is_user_in_grace = 0; $arm_user_grace_end_date = ''; $plan_detail = array(); $user_plans = get_user_meta($user_id, 'arm_user_plan_ids', true); $user_plan = 0; $using_gateway = ''; $payment_cycle = 0; if(!empty($plan_id)){ $user_plan = $plan_id; $planData = get_user_meta($user_id, 'arm_user_plan_'.$plan_id, true); if(!empty($planData)) { $arm_is_user_in_grace = (isset($planData['arm_is_user_in_grace']) && !empty($planData['arm_is_user_in_grace'])) ? $planData['arm_is_user_in_grace'] : 0; $arm_user_grace_end_date = $planData['arm_grace_period_end']; $plan_detail = $planData['arm_current_plan_detail']; $using_gateway = $planData['arm_user_gateway']; $payment_cycle = $planData['arm_payment_cycle']; $expire_time = $planData['arm_expire_plan']; } } if ($arm_is_user_in_grace == 1) { $datediff = $arm_user_grace_end_date - $now; $u_grace_period_days = floor($datediff / (60 * 60 * 24)); } $activation_key = get_user_meta($user_id, 'arm_user_activation_key', true); $login_page_id = isset($this->global_settings['login_page_id']) ? $this->global_settings['login_page_id'] : 0; if ($login_page_id == 0) { $arm_login_page_url = wp_login_url(); } else { $arm_login_page_url = $this->arm_get_permalink('', $login_page_id); } $arm_login_page_url = $arm_global_settings->add_query_arg('arm-key', urlencode($activation_key), $arm_login_page_url); $arm_login_page_url = $arm_global_settings->add_query_arg('email', urlencode($u_email), $arm_login_page_url); $validate_url = $arm_login_page_url; $pending = ''; $login_url = $this->arm_get_permalink('', $login_page_id); $profile_link = $this->arm_get_user_profile_url($user_info->ID); $blog_name = get_bloginfo('name'); $blog_url = ARMLITE_HOME_URL; $arm_currency = $arm_payment_gateways->arm_get_global_currency(); $all_email_settings = $arm_email_settings->arm_get_all_email_settings(); $admin_email = (!empty($all_email_settings['arm_email_admin_email'])) ? $all_email_settings['arm_email_admin_email'] : get_option('admin_email'); $u_plan_name = '-'; $u_plan_amount = '-'; $u_plan_discount = '-'; $u_payment_type = '-'; $u_payment_gateway = '-'; $u_transaction_id = '-'; $plan_expire = ''; if (!empty($plan_detail)) { $plan_detail = maybe_unserialize($plan_detail); if (!empty($plan_detail)) { $planObj = new ARM_Plan(0); $planObj->init((object) $plan_detail); } else { $planObj = new ARM_Plan($user_plan); } $u_plan_name = $planObj->name; $u_plan_description = $planObj->description; if($planObj->is_recurring()){ $plan_data = $planObj->prepare_recurring_data($payment_cycle); $u_plan_amount = $plan_data['amount']; $u_plan_amount = $arm_payment_gateways->arm_amount_set_separator($arm_currency, $u_plan_amount); } else{ $u_plan_amount = $arm_payment_gateways->arm_amount_set_separator($arm_currency, $planObj->amount); } $plan_expire = __('Never Expires', 'ARMember'); if (!empty($expire_time)) { $date_format = $this->arm_get_wp_date_format(); $plan_expire = date_i18n($date_format, $expire_time); } if (!empty($using_gateway)) { $u_payment_gateway = $arm_payment_gateways->arm_gateway_name_by_key($using_gateway); } // if ($planObj->has_trial_period()) { // $planTrialOpts = isset($planObj->options['trial']) ? $planObj->options['trial'] : array(); // $u_plan_amount = $arm_payment_gateways->arm_amount_set_separator($arm_currency, $planTrialOpts['amount']); // } if ($planObj->is_paid()) { if ($planObj->is_lifetime()) { $u_payment_type = __('Life Time', 'ARMember'); } else { if ($planObj->is_recurring()) { $u_payment_type = __('Subscription', 'ARMember'); } else { $u_payment_type = __('One Time', 'ARMember'); } } } else { $u_payment_type = __('Free', 'ARMember'); } $selectColumns = '`arm_log_id`, `arm_user_id`, `arm_transaction_id`, `arm_is_trial`, `arm_amount`, `arm_extra_vars`'; if ($using_gateway == 'bank_transfer') { /* Change Log Table For Bank Transfer Method */ $armLogTable = $ARMember->tbl_arm_bank_transfer_log; } else { $armLogTable = $ARMember->tbl_arm_payment_log; $selectColumns .= ', `arm_token`'; } $log_detail = $wpdb->get_row("SELECT {$selectColumns} FROM `{$armLogTable}` WHERE `arm_user_id`='{$user_id}' AND `arm_plan_id`='{$user_plan}' ORDER BY `arm_log_id` DESC"); if (!empty($log_detail)) { $u_transaction_id = $log_detail->arm_transaction_id; $extravars = maybe_unserialize($log_detail->arm_extra_vars); if ($using_gateway == 'bank_transfer') { if(isset($extravars['coupon'])){ $u_plan_discount = isset($extravars['coupon']['amount']) ? $extravars['coupon']['amount'] : 0; } else{ $u_plan_discount = $log_detail->arm_coupon_discount.$log_detail->arm_coupon_discount_type; } } else{ $u_plan_discount = isset($extravars['coupon']['amount']) ? $extravars['coupon']['amount'] : 0; } if (!empty($log_detail->arm_is_trial) && $log_detail->arm_is_trial == 1) { $u_trial_amount= isset($extravars['trial']['amount']) ? $extravars['trial']['amount'] : 0; } $u_payable_amount = $log_detail->arm_amount; } } if (empty($user_plans)) { $arm_user_entry_id = get_user_meta($user_id, 'arm_entry_id', true); if (isset($arm_user_entry_id) && $arm_user_entry_id != '') { $armentryTable = $ARMember->tbl_arm_entries; $arm_user_entry_data_ser = $wpdb->get_var("SELECT `arm_entry_value` FROM `{$armentryTable}` WHERE `arm_entry_id` = {$arm_user_entry_id}"); $arm_user_entry_data = maybe_unserialize($arm_user_entry_data_ser); $arm_user_payment_gateway = ''; if (isset($arm_user_entry_data['arm_front_gateway_skin_type']) && $arm_user_entry_data['arm_front_gateway_skin_type'] == 'dropdown') { $arm_user_payment_gateway = $arm_user_entry_data['_payment_gateway']; $arm_plan_skin_type = $arm_user_entry_data['arm_front_plan_skin_type']; $arm_subscription_plan = isset($arm_user_entry_data['subscription_plan']) ? $arm_user_entry_data['subscription_plan'] : ''; } else if (isset($arm_user_entry_data['arm_front_gateway_skin_type']) && $arm_user_entry_data['arm_front_gateway_skin_type'] == 'radio') { $arm_user_payment_gateway = $arm_user_entry_data['payment_gateway']; $arm_plan_skin_type = $arm_user_entry_data['arm_front_plan_skin_type']; $arm_subscription_plan = isset($arm_user_entry_data['subscription_plan']) ? $arm_user_entry_data['subscription_plan'] : ''; } if ($arm_user_payment_gateway == 'bank_transfer') { $userplanObj = new ARM_Plan($arm_subscription_plan); $u_plan_name = $userplanObj->name; $u_plan_description = $userplanObj->description; $u_payment_gateway = $arm_payment_gateways->arm_gateway_name_by_key('bank_transfer'); $plan_expire = ''; $u_trial_amount = 0; $u_plan_discount =0; $u_payable_amount = 0; if($userplanObj->is_recurring()){ $plan_data = $userplanObj->prepare_recurring_data($payment_cycle); $u_plan_amount = $plan_data['amount']; $u_plan_amount = $arm_payment_gateways->arm_amount_set_separator($arm_currency, $u_plan_amount); } else{ $u_plan_amount = $arm_payment_gateways->arm_amount_set_separator($arm_currency, $userplanObj->amount); } if ($userplanObj->has_trial_period()) { $planTrialOpts = isset($userplanObj->options['trial']) ? $userplanObj->options['trial'] : array(); $u_plan_amount = $arm_payment_gateways->arm_amount_set_separator($arm_currency, $planTrialOpts['amount']); } if ($userplanObj->is_paid()) { if ($userplanObj->is_lifetime()) { $u_payment_type = __('Life Time', 'ARMember'); } else { if ($userplanObj->is_recurring()) { $u_payment_type = __('Subscription', 'ARMember'); } else { $u_payment_type = __('One Time', 'ARMember'); } } } $selectColumns = '`arm_transaction_id`, `arm_extra_vars`, `arm_is_trial`, `arm_amount`'; $armLogTable = $ARMember->tbl_arm_bank_transfer_log; $log_detail = $wpdb->get_row("SELECT {$selectColumns} FROM `{$armLogTable}` WHERE `arm_user_id`='{$user_id}' AND `arm_plan_id`='{$arm_subscription_plan}' ORDER BY `arm_log_id` DESC"); if (!empty($log_detail)) { $u_transaction_id = $log_detail->arm_transaction_id; $u_payable_amount = $log_detail->arm_amount; $extravars = maybe_unserialize($log_detail->arm_extra_vars); if (!empty($log_detail->arm_is_trial) && $log_detail->arm_is_trial == 1) { $u_trial_amount= isset($extravars['trial']['amount']) ? $extravars['trial']['amount'] : 0; } } } } } if ($key != '' && !empty($key)) { $change_password_page_id = isset($arm_global_settings->global_settings['change_password_page_id']) ? $arm_global_settings->global_settings['change_password_page_id'] : 0; if ($change_password_page_id == 0) { $arm_reset_password_link = network_site_url("wp-login.php?action=rp&key=" . rawurlencode($key) . "&login=" . rawurlencode($u_username), 'login'); } else { $arm_change_password_page_url = $arm_global_settings->arm_get_permalink('', $change_password_page_id); $arm_change_password_page_url = $arm_global_settings->add_query_arg('action', 'rp', $arm_change_password_page_url); $arm_change_password_page_url = $arm_global_settings->add_query_arg('key', rawurlencode($key), $arm_change_password_page_url); $arm_change_password_page_url = $arm_global_settings->add_query_arg('login', rawurlencode($u_username), $arm_change_password_page_url); $arm_reset_password_link = $arm_change_password_page_url; } $varification_key = get_user_meta($user_id, 'arm_user_activation_key', true); $user_status = arm_get_member_status($user_id); if($user_status == 3){ $rp_link = $arm_global_settings->add_query_arg('varify_key', rawurlencode($varification_key), $arm_reset_password_link); } $content = str_replace('{ARM_RESET_PASSWORD_LINK}', $arm_reset_password_link, $content); } else { $content = str_replace('{ARM_RESET_PASSWORD_LINK}', '', $content); } $content = str_replace('{ARM_USER_ID}', $user_id, $content); $content = str_replace('{ARM_USERNAME}', $u_username, $content); $content = str_replace('{ARM_FIRST_NAME}', $u_fname, $content); $content = str_replace('{ARM_LAST_NAME}', $u_lname, $content); $content = str_replace('{ARM_NAME}', $u_displayname, $content); $content = str_replace('{ARM_EMAIL}', $u_email, $content); $content = str_replace('{ARM_ADMIN_EMAIL}', $admin_email, $content); $content = str_replace('{ARM_BLOGNAME}', $blog_name, $content); $content = str_replace('{ARM_BLOG_URL}', $blog_url, $content); $content = str_replace('{ARM_VALIDATE_URL}', $validate_url, $content); $content = str_replace('{ARM_CHANGE_PASSWORD_CONFIRMATION_URL}', $pending, $content); $content = str_replace('{ARM_PENDING_REQUESTS_URL}', $pending, $content); $content = str_replace('{ARM_PROFILE_FIELDS}', $pending, $content); $content = str_replace('{ARM_PROFILE_LINK}', $profile_link, $content); $content = str_replace('{ARM_LOGIN_URL}', $login_url, $content); $content = str_replace('{ARM_PLAN}', $u_plan_name, $content); $content = str_replace('{ARM_PLAN_DESCRIPTION}', $u_plan_description, $content); $content = str_replace('{ARM_PLAN_AMOUNT}', $u_plan_amount, $content); $content = str_replace('{ARM_PLAN_DISCOUNT}', $u_plan_discount, $content); $content = str_replace('{ARM_TRIAL_AMOUNT}', $u_trial_amount, $content); $content = str_replace('{ARM_PAYABLE_AMOUNT}', $u_payable_amount, $content); $content = str_replace('{ARM_PAYMENT_TYPE}', $u_payment_type, $content); $content = str_replace('{ARM_PAYMENT_GATEWAY}', $u_payment_gateway, $content); $content = str_replace('{ARM_TRANSACTION_ID}', $u_transaction_id, $content); $content = str_replace('{ARM_GRACE_PERIOD_DAYS}', $u_grace_period_days, $content); $Content = str_replace('{ARM_CURRENCY}',$arm_currency, $content); $Content = str_replace('{ARM_PLAN_EXPIRE}',$plan_expire, $content); $networ_name = get_site_option('site_name'); $networ_url = get_site_option('siteurl'); $Content = str_replace('{ARM_MESSAGE_NETWORKNAME}',$networ_name, $content); $Content = str_replace('{ARM_MESSAGE_NETWORKURL}',$networ_url, $content); /* Content replace for user meta */ $matches = array(); preg_match_all("/\b(\w*ARM_USERMETA_\w*)\b/", $content, $matches, PREG_PATTERN_ORDER); $matches = $matches[0]; if (!empty($matches)) { foreach ($matches as $mat_var) { $key = str_replace('ARM_USERMETA_', '', $mat_var); $meta_val = ""; if (!empty($key)) { $meta_val = get_user_meta($user_id, $key, TRUE); if(is_array($meta_val)) { $meta_val = implode(',', $meta_val); } } $content = str_replace('{' . $mat_var . '}', $meta_val, $content); } } } $content = nl2br($content); $content = apply_filters('arm_change_email_content_with_user_detail', $content, $user_id); return $content; } function arm_get_wp_pages($args = '', $columns = array()){ $defaults = array( 'depth' => 0, 'child_of' => 0, 'selected' => 0, 'echo' => 1, 'name' => 'page_id', 'id' => '', 'show_option_none' => 'Select Page', 'show_option_no_change' => '', 'option_none_value' => '', 'class' => '', 'required' => false, 'required_msg' => false, ); $arm_r = wp_parse_args($args, $defaults); $arm_pages = get_pages($arm_r); $arm_new_pages = array(); if(!empty($arm_pages)){ if(!empty($columns)) { $n = 0; foreach($arm_pages as $page) { foreach($columns as $column){ $arm_new_pages[$n][$column] = $page->$column; } $n++; } } else { $arm_new_pages = $arm_pages; } } return $arm_new_pages; } function arm_wp_dropdown_pages($args = '', $dd_class = '') { $defaults = array( 'depth' => 0, 'child_of' => 0, 'selected' => 0, 'echo' => 1, 'name' => 'page_id', 'id' => '', 'show_option_none' => 'Select Page', 'show_option_no_change' => '', 'option_none_value' => '', 'class' => '', 'required' => false, 'required_msg' => false, ); $r = wp_parse_args($args, $defaults); $pages = get_pages($r); $output = ''; if (empty($r['id'])) { $r['id'] = $r['name']; } $pageIds = array(); if (!empty($pages)) { $pageIds = array(); foreach ($pages as $p) { $pageIds[] = $p->ID; } } if (!in_array($r['selected'], $pageIds)) { $r['selected'] = ''; } $required = ($r['required']) ? 'required="required"' : ''; $required_msg = ($r['required_msg']) ? 'data-msg-required="' . $r['required_msg'] . '"' : ''; $output .= ""; $output .= "
"; $output .= "
" . (!empty($r['selected']) ? get_the_title($r['selected']) : 'Select Page') . "
"; $output .= "
"; $output .= ""; $output .= "
"; $output .= "
"; $html = apply_filters('arm_wp_dropdown_pages', $output); if ($r['echo']) { echo $html; } return $html; } function arm_get_wp_date_format() { global $wp, $wpdb; if (is_multisite()) { $wp_format_date = get_option('date_format'); } else{ $wp_format_date = get_site_option('date_format'); } if (empty($wp_format_date)) { $date_format = 'M d, Y'; } else { $date_format = $wp_format_date; } return $date_format; } function arm_get_wp_date_time_format() { global $wp, $wpdb; if (is_multisite()) { $wp_date_time_format = get_option('date_format') . " " . get_option('time_format'); } else { $wp_date_time_format = get_site_option('date_format') . " " . get_site_option('time_format'); } if (empty($wp_date_time_format)) { $date_time_format = 'M d, Y H:i:s'; } else { $date_time_format = $wp_date_time_format; } return $date_time_format; } function arm_time_elapsed($ptime) { $etime = current_time('timestamp') - $ptime; if ($etime < 1) { return __('now!', 'ARMember'); } $a = array(12 * 30 * 24 * 60 * 60 => __('year', 'ARMember'), 30 * 24 * 60 * 60 => __('month', 'ARMember'), 24 * 60 * 60 => __('day', 'ARMember'), 60 * 60 => __('hour', 'ARMember'), 60 => __('minute', 'ARMember'), 1 => __('second', 'ARMember') ); foreach ($a as $secs => $str) { $d = $etime / $secs; if ($d >= 1) { $r = round($d); return $r . ' ' . $str . ($r > 1 ? 's' : '') . __(' ago', 'ARMember'); } } return '-'; } function arm_time_remaining($rtime) { $etime = $rtime - current_time('timestamp'); if ($etime < 1) { return __('now!', 'ARMember'); } $a = array(12 * 30 * 24 * 60 * 60 => __('year', 'ARMember'), 30 * 24 * 60 * 60 => __('month', 'ARMember'), 24 * 60 * 60 => __('day', 'ARMember'), 60 * 60 => __('hour', 'ARMember'), 60 => __('minute', 'ARMember'), 1 => __('second', 'ARMember') ); foreach ($a as $secs => $str) { $d = $etime / $secs; if ($d >= 1) { $r = round($d); return $r . ' ' . $str . ($r > 1 ? 's' : ''); } } return '-'; } function arm_get_remaining_occurrence($start_date, $end_date, $interval) { $dates = array(); $now = current_time('timestamp'); while ($start_date <= $end_date) { if ($now < $start_date) { $dates[] = date('Y-m-d H:i:s', $start_date); } $start_date = strtotime($interval, $start_date); } return (count($dates) - 1); } function arm_get_confirm_box($item_id = 0, $confirmText = '', $btnClass = '', $deleteType = '') { global $wp, $wpdb, $ARMember, $arm_slugs; $confirmBox = "
"; $confirmBox .= "
"; $confirmBox .= "
"; $confirmBox .= "
{$confirmText}
"; $confirmBox .= "
"; $confirmBox .= ""; $confirmBox .= ""; $confirmBox .= "
"; $confirmBox .= "
"; $confirmBox .= "
"; return $confirmBox; } function arm_get_bpopup_html($args) { global $wp, $wpdb, $ARMember, $arm_slugs; $defaults = array( 'id' => '', 'class' => 'arm_bpopup_wrapper', 'title' => '', 'content' => '', 'button_id' => '', 'button_onclick' => '', 'ok_btn_class' => '', 'ok_btn_text' => __('Ok', 'ARMember'), 'cancel_btn_text' => __('Cancel', 'ARMember'), ); extract(shortcode_atts($defaults, $args)); /* Generate Popup HTML */ $popup = ''; return $popup; } function arm_get_bpopup_html_payment($args) { global $wp, $wpdb, $ARMember, $arm_slugs; $defaults = array( 'id' => '', 'class' => 'arm_bpopup_wrapper', 'title' => '', 'content' => '', 'button_id' => '', 'button_onclick' => '', 'ok_btn_class' => '', 'ok_btn_text' => __('Ok', 'ARMember'), 'cancel_btn_text' => __('Cancel', 'ARMember'), ); extract(shortcode_atts($defaults, $args)); /* Generate Popup HTML */ $popup = ''; return $popup; } function arm_after_delete_term($term, $tt_id, $taxonomy, $deleted_term) { global $wp, $wpdb, $ARMember, $arm_slugs; delete_arm_term_meta($term, 'arm_protection'); delete_arm_term_meta($term, 'arm_access_plan'); } /** * ************************************************************************************** * * String Utilities Functions * * ************************************************************************************* */ /** * Trims deeply; alias of `trim_deep`. * @param string|array $value Either a string, an array, or a multi-dimensional array, filled with integer and/or string values. * @return string|array Either the input string, or the input array; after all data is trimmed up according to arguments passed in. */ public static function trim($value = '', $chars = FALSE, $extra_chars = FALSE) { return self::trim_deep($value, $chars, $extra_chars); } /** * Trims deeply; or use {@link s2Member\Utilities\self::trim()}. * @param string|array $value Either a string, an array, or a multi-dimensional array, filled with integer and/or string values. * @return string|array Either the input string, or the input array; after all data is trimmed up according to arguments passed in. */ public static function trim_deep($value = '', $chars = FALSE, $extra_chars = FALSE) { $chars = (is_string($chars)) ? $chars : " \t\n\r\0\x0B"; $chars = (is_string($extra_chars)) ? $chars . $extra_chars : $chars; if (is_array($value)) { foreach ($value as &$r) { $r = self::trim_deep($r, $chars); } return $value; } return trim((string) $value, $chars); } /** * Trims all single/double quote entity variations deeply. * This is useful on Shortcode attributes mangled by a Visual Editor. * @param string|array $value Either a string, an array, or a multi-dimensional array, filled with integer and/or string values. * @return string|array Either the input string, or the input array; after all data is trimmed up. */ public static function trim_qts_deep($value = '') { $quote_entities_variations = array( ''' => ''', '�*39;' => ''', '&#[xX]0*27;' => ''', '‘' => '‘', '�*8216;' => '‘', '&#[xX]0*2018;' => '‘', '’' => '’', '�*8217;' => '’', '&#[xX]0*2019;' => '’', '"' => '"', '�*34;' => '"', '&#[xX]0*22;' => '"', '“' => '“', '�*8220;' => '“', '&#[xX]0*201[cC];' => '“', '”' => '”', '�*8221;' => '”', '&#[xX]0*201[dD];' => '”' ); $qts = implode('|', array_keys($quote_entities_variations)); return is_array($value) ? array_map('self::trim_qts_deep', $value) : preg_replace('/^(?:' . $qts . ')+|(?:' . $qts . ')+$/', '', (string) $value); } /** * Trims HTML whitespace. * This is useful on Shortcode content. * @param string $string Input string to trim. * @return string Output string with all HTML whitespace trimmed away. */ public static function trim_html($string = '') { $whitespace = ' |\|\|\(?: )*\<\/p\>'; return preg_replace('/^(?:' . $whitespace . ')+|(?:' . $whitespace . ')+$/', '', (string) $string); } public static function arm_set_ini_for_access_rules() { $memoryLimit = ini_get('memory_limit'); if (preg_match('/^(\d+)(.)$/', $memoryLimit, $matches)) { if ($matches[2] == 'M') { $memoryLimit = $matches[1] * 1024 * 1024; } else if ($matches[2] == 'K') { $memoryLimit = $matches[1] * 1024; } } if ($memoryLimit < (256 * 1024 * 1024)) { /* @define('WP_MEMORY_LIMIT', '256M'); */ @ini_set('memory_limit', '256M'); } set_time_limit(0); /* Set Maximum Execution Time */ } public static function arm_set_ini_for_importing_users() { $memoryLimit = ini_get('memory_limit'); if (preg_match('/^(\d+)(.)$/', $memoryLimit, $matches)) { if ($matches[2] == 'M') { $memoryLimit = $matches[1] * 1024 * 1024; } else if ($matches[2] == 'K') { $memoryLimit = $matches[1] * 1024; } } if ($memoryLimit < (512 * 1024 * 1024)) { /* @define('WP_MEMORY_LIMIT', '256M'); */ @ini_set('memory_limit', '512M'); } set_time_limit(0); /* Set Maximum Execution Time */ } function arm_add_page_label_css($hook) { if ('edit.php' != $hook) { return; } $postLabelCss = ''; echo $postLabelCss; } function arm_add_set_page_label($states, $post = null) { global $wpdb, $ARMember, $post; if (isset($post->ID)) { $str = ''; if (get_post_type($post->ID) == 'page') { $arm_page_settings = $this->arm_get_single_global_settings('page_settings'); if (!empty($arm_page_settings)) { foreach ($arm_page_settings as $key => $value) { if ($value == $post->ID) { switch (strtolower($key)) { case 'register_page_id': $title_label = __('Registration page', 'ARMember'); break; case 'login_page_id': $title_label = __('Login page', 'ARMember'); break; case 'forgot_password_page_id': $title_label = __('Forgot Password page', 'ARMember'); break; case 'edit_profile_page_id': $title_label = __('Edit Profile page', 'ARMember'); break; case 'change_password_page_id': $title_label = __('Change Password page', 'ARMember'); break; case 'member_profile_page_id': $title_label = __('Member Profile page', 'ARMember'); break; case 'guest_page_id': $title_label = __('Guest page', 'ARMember'); break; } if (!empty($title_label)) { $str .= '
ARMember ' . $title_label . '
'; } } } } } $arm_protect = 0; $item_plans = get_post_meta($post->ID, 'arm_access_plan'); $item_plans = (!empty($item_plans)) ? $item_plans : array(); if (count($item_plans) == 0) $arm_protect = 0; else $arm_protect = 1; if (!empty($arm_protect) && $arm_protect == 1) { $str .= '
' . __("ARMember Protected", 'ARMember') . '
'; } /** * Check If Post Has Drip Rules */ if (!empty($str)) { $states[] = $str; } } return $states; } function arm_update_feature_settings() { global $wp, $wpdb, $wp_rewrite, $ARMember, $arm_capabilities_global; $ARMember->arm_check_user_cap($arm_capabilities_global['arm_manage_feature_settings'], '1'); $response = array('type' => 'error', 'msg' => __('Sorry, Something went wrong. Please try again.', 'ARMember')); if (!empty($_POST['arm_features_options'])) { $features_options = $_POST['arm_features_options']; $arm_features_status = (!empty($_POST['arm_features_status'])) ? intval($_POST['arm_features_status']) : 0; if ($arm_features_status == 1) { //do_action('arm_update_feature_settings', $_POST); if ($features_options == 'arm_is_social_feature') { $isPageExist = false; $old_member_profile_page_id = isset($this->global_settings['member_profile_page_id']) ? $this->global_settings['member_profile_page_id'] : 0; if (!empty($old_member_profile_page_id) && $old_member_profile_page_id != 0) { $isPageExist = true; $pageData = get_post($old_member_profile_page_id); if (!isset($pageData->ID) || empty($pageData->ID)) { $isPageExist = false; } } if (!$isPageExist) { $profileTemplateID = $wpdb->get_var("SELECT `arm_id` FROM `" . $ARMember->tbl_arm_member_templates . "` WHERE `arm_type`='profile' ORDER BY `arm_id` ASC LIMIT 1"); $profileTemplateShortcode = (!empty($profileTemplateID)) ? '[arm_template type="profile" id="' . $profileTemplateID . '"]' : ''; $profilePageData = array( 'post_title' => 'Profile', 'post_name' => 'arm_member_profile', 'post_content' => $profileTemplateShortcode, 'post_status' => 'publish', 'post_parent' => 0, 'post_author' => 1, 'post_type' => 'page', ); $page_id = wp_insert_post($profilePageData); $new_global_settings = $this->arm_get_all_global_settings(); $new_global_settings['page_settings']['member_profile_page_id'] = $page_id; $new_global_settings_result = maybe_serialize($new_global_settings); update_option('arm_global_settings', $new_global_settings_result); $this->arm_user_rewrite_rules(); $wp_rewrite->flush_rules(false); } $arm_features_status = (!empty($_POST['arm_features_status'])) ? intval($_POST['arm_features_status']) : 0; update_option('arm_is_social_feature', '1'); $response = array('type' => 'success', 'msg' => __('Features Settings Updated Successfully.', 'ARMember')); echo json_encode($response); die(); } /*else { $arm_features_status = (!empty($_POST['arm_features_status'])) ? $_POST['arm_features_status'] : 0; update_option($features_options, $arm_features_status); $response = array('type' => 'success', 'msg' => __('Features Settings Updated Successfully.', 'ARMember')); echo json_encode($response); die(); }*/ } else if($arm_features_status == 0 && $features_options == 'arm_is_social_feature') { //do_action('arm_deactivate_feature_settings', $_POST); update_option('arm_is_social_feature', 0); $response = array('type' => 'success', 'msg' => __('Features Settings Updated Successfully.', 'ARMember')); echo json_encode($response); die(); } } /* END `(!empty($_POST['arm_features_options']))` */ } function arm_get_front_font_style() { global $wp, $wpdb, $arm_slugs, $current_user, $arm_errors, $ARMember, $arm_subscription_plans, $arm_member_forms; $frontfontstyle = array(); $frontFontFamilys = array(); $frontfontOptions = array('level_1_font', 'level_2_font', 'level_3_font', 'level_4_font', 'link_font', 'button_font'); $frontOptions = isset($this->global_settings['front_settings']) ? $this->global_settings['front_settings'] : array(); foreach ($frontfontOptions as $key) { $ffont_family = (isset($frontOptions[$key]['font_family'])) ? $frontOptions[$key]['font_family'] : "Helvetica"; $frontFontFamilys[] = $ffont_family; $ffont_size = (isset($frontOptions[$key]['font_size'])) ? $frontOptions[$key]['font_size'] : ""; $ffont_color = (isset($frontOptions[$key]['font_color'])) ? $frontOptions[$key]['font_color'] : ""; $ffont_bold = (isset($frontOptions[$key]['font_bold']) && $frontOptions[$key]['font_bold'] == '1') ? "font-weight: bold !important;" : "font-weight: normal !important;"; $ffont_italic = (isset($frontOptions[$key]['font_italic']) && $frontOptions[$key]['font_italic'] == '1') ? "font-style: italic !important;" : "font-style: normal !important;"; $ffont_decoration = (!empty($frontOptions[$key]['font_decoration'])) ? "text-decoration: " . $frontOptions[$key]['font_decoration'] . " !important;" : "text-decoration: none !important;"; $frontOptions[$key]['font'] = "font-family: {$ffont_family}, sans-serif, 'Trebuchet MS' !important;font-size: {$ffont_size}px !important;color: {$ffont_color} !important;{$ffont_bold}{$ffont_italic}{$ffont_decoration}"; } $gFontUrl = $arm_member_forms->arm_get_google_fonts_url($frontFontFamilys); if (!empty($gFontUrl)) { $frontfontstyle['google_font_url'] = $gFontUrl; } $frontfontstyle['frontOptions'] = $frontOptions; return $frontfontstyle; } } } global $arm_global_settings; $arm_global_settings = new ARM_global_settings(); if (!function_exists('arm_generate_random_code')) { function arm_generate_random_code($length = 10) { $charLength = round($length * 0.8); $numLength = round($length * 0.2); $keywords = array( array('count' => $charLength, 'char' => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), array('count' => $numLength, 'char' => '0123456789') ); $temp_array = array(); foreach ($keywords as $char_set) { for ($i = 0; $i < $char_set['count']; $i++) { $temp_array[] = $char_set['char'][rand(0, strlen($char_set['char']) - 1)]; } } shuffle($temp_array); return implode('', $temp_array); } } if (!function_exists('arm_generate_captcha_code')) { function arm_generate_captcha_code($length = 8) { $possible_letters = '23456789bcdfghjkmnpqrstvwxyz'; $random_dots = 0; $random_lines = 20; $code = ''; $i = 0; while ($i < $length) { $code .= substr($possible_letters, mt_rand(0, strlen($possible_letters) - 1), 1); $i++; } return $code; } } if (!function_exists('add_arm_term_meta')) { /** * Add meta data field to a term. * * @param int $term_id Post ID. * @param string $key Metadata name. * @param mixed $value Metadata value. * @param bool $unique Optional, default is false. Whether the same key should not be added. * @return bool False for failure. True for success. */ function add_arm_term_meta($term_id, $meta_key, $meta_value, $unique = false) { return add_metadata('arm_term', $term_id, $meta_key, $meta_value, $unique); } } if (!function_exists('delete_arm_term_meta')) { /** * Remove metadata matching criteria from a term. * * You can match based on the key, or key and value. Removing based on key and * value, will keep from removing duplicate metadata with the same key. It also * allows removing all metadata matching key, if needed. * * @param int $term_id term ID * @param string $meta_key Metadata name. * @param mixed $meta_value Optional. Metadata value. * @return bool False for failure. True for success. */ function delete_arm_term_meta($term_id, $meta_key, $meta_value = '') { return delete_metadata('arm_term', $term_id, $meta_key, $meta_value); } } if (!function_exists('get_arm_term_meta')) { /** * Retrieve term meta field for a term. * * @param int $term_id Term ID. * @param string $key The meta key to retrieve. * @param bool $single Whether to return a single value. * @return mixed Will be an array if $single is false. Will be value of meta data field if $single * is true. */ function get_arm_term_meta($term_id, $key, $single = false) { return get_metadata('arm_term', $term_id, $key, $single); } } if (!function_exists('update_arm_term_meta')) { /** * Update term meta field based on term ID. * * Use the $prev_value parameter to differentiate between meta fields with the * same key and term ID. * * If the meta field for the term does not exist, it will be added. * * @param int $term_id Term ID. * @param string $key Metadata key. * @param mixed $value Metadata value. * @param mixed $prev_value Optional. Previous value to check before removing. * @return bool False on failure, true if success. */ function update_arm_term_meta($term_id, $meta_key, $meta_value, $prev_value = '') { return update_metadata('arm_term', $term_id, $meta_key, $meta_value, $prev_value); } } if (!function_exists('armXML_to_Array')) { /** * Convert XML File Data Into Array * @param type $content (xml file content) */ function armXML_to_Array($contents, $get_attributes = 1, $priority = 'tag') { if (!$contents) { return array(); } if (!function_exists('xml_parser_create')) { /* print "'xml_parser_create()' function not found!"; */ return array(); } /* Get the XML parser of PHP - PHP must have this module for the parser to work */ $parser = xml_parser_create(''); xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8"); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); xml_parse_into_struct($parser, trim($contents), $xml_values); xml_parser_free($parser); if (!$xml_values) { return; } /* Initializations */ $xml_array = array(); $parents = array(); $opened_tags = array(); $arr = array(); $current = &$xml_array; /* Refference */ $repeated_tag_index = array(); /* Multiple tags with same name will be turned into an array */ foreach ($xml_values as $data) { unset($attributes, $value); /* Remove existing values, or there will be trouble */ /** * This command will extract these variables into the foreach scope tag(string), type(string), level(int), attributes(array). */ extract($data); $result = array(); $attributes_data = array(); if (isset($value)) { if ($priority == 'tag') { $result = $value; } else { $result['value'] = $value; /* Put the value in a assoc array if we are in the 'Attribute' mode */ } } /* Set the attributes too. */ if (isset($attributes) and $get_attributes) { foreach ($attributes as $attr => $val) { if ($priority == 'tag') { $attributes_data[$attr] = $val; } else { $result['attr'][$attr] = $val; /* Set all the attributes in a array called 'attr' */ } } } /* See tag status and do the needed. */ if ($type == "open") { /* The starting of the tag '' */ $parent[$level - 1] = &$current; if (!is_array($current) or ( !in_array($tag, array_keys($current)))) { $current[$tag] = $result; if ($attributes_data) $current[$tag . '_attr'] = $attributes_data; $repeated_tag_index[$tag . '_' . $level] = 1; $current = &$current[$tag]; } else { /* There was another element with the same tag name */ if (isset($current[$tag][0])) { /* If there is a 0th element it is already an array */ $current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result; $repeated_tag_index[$tag . '_' . $level] ++; } else { /* This section will make the value an array if multiple tags with the same name appear together */ /* This will combine the existing item and the new item together to make an array */ $current[$tag] = array($current[$tag], $result); $repeated_tag_index[$tag . '_' . $level] = 2; if (isset($current[$tag . '_attr'])) { /* The attribute of the last(0th) tag must be moved as well */ $current[$tag]['0_attr'] = $current[$tag . '_attr']; unset($current[$tag . '_attr']); } } $last_item_index = $repeated_tag_index[$tag . '_' . $level] - 1; $current = &$current[$tag][$last_item_index]; } } elseif ($type == "complete") { /* Tags that ends in 1 line '' */ /* See if the key is already taken. */ if (!isset($current[$tag])) { $current[$tag] = $result; $repeated_tag_index[$tag . '_' . $level] = 1; if ($priority == 'tag' and $attributes_data) $current[$tag . '_attr'] = $attributes_data; } else { /* If taken, put all things inside a list(array) */ if (isset($current[$tag][0]) and is_array($current[$tag])) { $current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result; if ($priority == 'tag' and $get_attributes and $attributes_data) { $current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data; } $repeated_tag_index[$tag . '_' . $level] ++; } else { $current[$tag] = array($current[$tag], $result); $repeated_tag_index[$tag . '_' . $level] = 1; if ($priority == 'tag' and $get_attributes) { if (isset($current[$tag . '_attr'])) { $current[$tag]['0_attr'] = $current[$tag . '_attr']; unset($current[$tag . '_attr']); } if ($attributes_data) { $current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data; } } $repeated_tag_index[$tag . '_' . $level] ++; /* 0 and 1 index is already taken */ } } } elseif ($type == 'close') { /* End of tag '' */ $current = &$parent[$level - 1]; } } return $xml_array; } } if (!function_exists('arm_array_map')) { function arm_array_map($input = array()) { if (empty($input)) { return $input; } return is_array($input) ? array_map('arm_array_map', $input) : trim($input); } } if (!function_exists('arm_wp_date_format_to_bootstrap_datepicker')) { function arm_wp_date_format_to_bootstrap_datepicker($date_format = '') { if ($date_format == '') { $date_format = get_option('date_format'); } $SYMBOLS_MATCHING = array( 'd' => 'DD', 'D' => 'ddd', 'j' => 'D', 'l' => 'dddd', 'N' => '', 'S' => '', 'w' => '', 'z' => 'o', 'W' => '', 'F' => 'MMMM', 'm' => 'MM', 'M' => 'M', 'n' => 'm', 't' => '', 'L' => '', 'o' => '', 'Y' => 'YYYY', 'y' => 'y', 'a' => '', 'A' => '', 'B' => '', 'g' => '', 'G' => '', 'h' => '', 'H' => '', 'i' => '', 's' => '', 'u' => '' ); $jqueryui_format = ""; $escaping = false; for ($i = 0; $i < strlen($date_format); $i++) { $char = $date_format[$i]; if ($char === '\\') { // PHP date format escaping character $i++; if ($escaping) $jqueryui_format .= $date_format[$i]; else $jqueryui_format .= '\'' . $date_format[$i]; $escaping = true; } else { if ($escaping) { $jqueryui_format .= "'"; $escaping = false; } if (isset($SYMBOLS_MATCHING[$char])) $jqueryui_format .= $SYMBOLS_MATCHING[$char]; else $jqueryui_format .= $char; } } return $jqueryui_format; } } if (!function_exists('arm_strtounicode')) { function arm_strtounicode($str = '') { if ($str == '') { return $str; } return preg_replace_callback("([\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}|[\xF8-\xFB][\x80-\xBF]{4}|[\xFC-\xFD][\x80-\xBF]{5})", function($m) { $c = $m[0]; $out = bindec(ltrim(decbin(ord($c[0])), "1")); $l = strlen($c); for ($i = 1; $i < $l; $i++) { $out = ($out << 6) | bindec(ltrim(decbin(ord($c[$i])), "1")); } if ($out < 256) return chr($out); return "&#" . $out . ";"; }, $str); } } if( !function_exists('arm_check_date_format') ){ function arm_check_date_format($date_value,$key = 0){ $date_formats = array( 'd/m/Y', 'm/d/Y', 'Y/m/d', 'M d, Y', 'F d, Y', 'd M, Y', 'd F, Y', 'Y, M d', 'Y, F d' ); $final_date_format = false; foreach($date_formats as $k => $format){ if( DateTime::createFromFormat($format,$date_value) ){ $final_date_format = DateTime::createFromFormat($format,$date_value); break; } } if( $final_date_format == "" || empty($final_date_format)){ try{ $final_date_format = new DateTime($date_value); } catch(Exception $e){ $date_value = str_replace('/', '-', $date_value); $final_date_format = new DateTime($date_value); } } return $final_date_format; } }