public function edit_level($id) { //Check we are on the admin end and user has management permission SwpmMiscUtils::check_user_permission_and_is_admin('membership level edit'); //Check nonce if (!isset($_POST['_wpnonce_edit_swpmlevel_admin_end']) || !wp_verify_nonce($_POST['_wpnonce_edit_swpmlevel_admin_end'], 'edit_swpmlevel_admin_end')) { //Nonce check failed. wp_die(SwpmUtils::_("Error! Nonce verification failed for membership level edit from admin end.")); } global $wpdb; $query = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "swpm_membership_tbl WHERE id = %d", $id); $level = $wpdb->get_row($query, ARRAY_A); $form = new SwpmLevelForm($level); if ($form->is_valid()) { $wpdb->update($wpdb->prefix . "swpm_membership_tbl", $form->get_sanitized(), array('id' => $id)); //@todo meta table and collect all relevant info and pass as argument $custom = apply_filters('swpm_admin_edit_membership_level', array(), $id); $this->save_custom_fields($id, $custom); $message = array('succeeded' => true, 'message' => '<p>' . SwpmUtils::_('Membership Level Updated Successfully.') . '</p>'); SwpmTransfer::get_instance()->set('status', $message); wp_redirect('admin.php?page=simple_wp_membership_levels'); exit(0); } $message = array('succeeded' => false, 'message' => SwpmUtils::_('Please correct the following:'), 'extra' => $form->get_errors()); SwpmTransfer::get_instance()->set('status', $message); }
public function swpm_ty_page_rego_sc($args) { $output = ''; $settings = SwpmSettings::get_instance(); //If user is logged in then the purchase will be applied to the existing profile if (SwpmMemberUtils::is_member_logged_in()) { $username = SwpmMemberUtils::get_logged_in_members_username(); $output .= '<div class="swpm-ty-page-registration-logged-in swpm-yellow-box">'; $output .= '<p>' . SwpmUtils::_('Your membership profile will be updated to reflect the payment.') . '</p>'; $output .= SwpmUtils::_('Your profile username: '******'</div>'; return $output; } $output .= '<div class="swpm-ty-page-registration">'; $member_data = SwpmUtils::get_incomplete_paid_member_info_by_ip(); if ($member_data) { //Found a member profile record for this IP that needs to be completed $reg_page_url = $settings->get_value('registration-page-url'); $rego_complete_url = add_query_arg(array('member_id' => $member_data->member_id, 'code' => $member_data->reg_code), $reg_page_url); $output .= '<div class="swpm-ty-page-registration-link swpm-yellow-box">'; $output .= '<p>' . SwpmUtils::_('Click on the following link to complete the registration.') . '</p>'; $output .= '<p><a href="' . $rego_complete_url . '">' . SwpmUtils::_('Click here to complete your paid registration') . '</a></p>'; $output .= '</div>'; } else { //Nothing found. Check again later. $output .= '<div class="swpm-ty-page-registration-link swpm-yellow-box">'; $output .= SwpmUtils::_('If you have just made a membership payment then your payment is yet to be processed. Please check back in a few minutes. An email will be sent to you with the details shortly.'); $output .= '</div>'; } $output .= '</div>'; //end of .swpm-ty-page-registration return $output; }
function column_user_name($item) { $user_name = $item['user_name']; if (empty($user_name)) { $user_name = '[' . SwpmUtils::_('incomplete') . ']'; } return $user_name; }
public static function get_logged_in_members_level_name() { $auth = SwpmAuth::get_instance(); if ($auth->is_logged_in()) { return $auth->get('alias'); } return SwpmUtils::_("User is not logged in."); }
public static function validate_user_name_ajax() { global $wpdb; $field_value = filter_input(INPUT_GET, 'fieldValue'); $field_id = filter_input(INPUT_GET, 'fieldId'); $table = $wpdb->prefix . "swpm_members_tbl"; $query = $wpdb->prepare("SELECT COUNT(*) FROM {$table} WHERE user_name = %s", $field_value); $exists = $wpdb->get_var($query) > 0; echo '[ "' . $field_id . ($exists ? '",false,"χ ' . SwpmUtils::_('Aready taken') . '"]' : '",true,"√ ' . SwpmUtils::_('Available') . '"]'); exit; }
function process_delete_action() { if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete_payment_btn') { //Delete link was clicked for a row in list table $record_id = strip_tags($_REQUEST['button_id']); wp_delete_post($record_id); $success_msg = '<div id="message" class="updated"><p>'; $success_msg .= SwpmUtils::_('The selected entry was deleted!'); $success_msg .= '</p></div>'; echo $success_msg; } }
public function swpm_show_expiry_date_sc($args) { $output = '<div class="swpm-show-expiry-date">'; if (SwpmMemberUtils::is_member_logged_in()) { $auth = SwpmAuth::get_instance(); $expiry_date = $auth->get_expire_date(); $output .= SwpmUtils::_('Expiry: ') . $expiry_date; } else { $output .= SwpmUtils::_('You are not logged-in as a member'); } $output .= '</div>'; return $output; }
public static function update_category_list() { $selected = filter_input(INPUT_POST, 'membership_level_id'); $selected_level_id = empty($selected) ? 1 : $selected; $category = $selected_level_id == 1 ? SwpmProtection::get_instance() : SwpmPermission::get_instance($selected_level_id); $args = array('ids' => array('filter' => FILTER_VALIDATE_INT, 'flags' => FILTER_REQUIRE_ARRAY)); $filtered = filter_input_array(INPUT_POST, $args); $ids = $filtered['ids']; $args = array('ids_in_page' => array('filter' => FILTER_VALIDATE_INT, 'flags' => FILTER_REQUIRE_ARRAY)); $filtered = filter_input_array(INPUT_POST, $args); $ids_in_page = $filtered['ids_in_page']; $category->remove($ids_in_page, 'category')->apply($ids, 'category')->save(); $message = array('succeeded' => true, 'message' => '<p>' . SwpmUtils::_('Category protection updated!') . '</p>'); SwpmTransfer::get_instance()->set('status', $message); }
public function edit($id) { global $wpdb; $query = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "swpm_membership_tbl WHERE id = %d", $id); $level = $wpdb->get_row($query, ARRAY_A); $form = new SwpmLevelForm($level); if ($form->is_valid()) { $wpdb->update($wpdb->prefix . "swpm_membership_tbl", $form->get_sanitized(), array('id' => $id)); //@todo meta table and collect all relevant info and pass as argument $custom = apply_filters('swpm_admin_edit_membership_level', array(), $id); $this->save_custom_fields($id, $custom); $message = array('succeeded' => true, 'message' => '<p>' . SwpmUtils::_('Updated Successfully.') . '</p>'); SwpmTransfer::get_instance()->set('status', $message); wp_redirect('admin.php?page=simple_wp_membership_levels'); exit(0); } $message = array('succeeded' => false, 'message' => SwpmUtils::_('Please correct the following:'), 'extra' => $form->get_errors()); SwpmTransfer::get_instance()->set('status', $message); }
public static function check_and_restrict_comment_posting_to_members() { $allow_comments = SwpmSettings::get_instance()->get_value('members-login-to-comment'); if (empty($allow_comments)) { return; } if (is_admin()) { return; } if (SwpmAuth::get_instance()->is_logged_in()) { return; } $comment_id = filter_input(INPUT_POST, 'comment_post_ID'); if (empty($comment_id)) { return; } //Stop this request -> 1)we are on the front-side. 2) Comment posted by a not logged in member. 3) comment_post_ID missing. $_POST = array(); wp_die(SwpmUtils::_('Comments not allowed by a non-member.')); }
public static function swpm_load_template($template_name, $require_once = true) { //List of file paths (in order of priority) where the plugin should check for the template. $template_files = array(get_stylesheet_directory() . '/' . SIMPLE_WP_MEMBERSHIP_TEMPLATE_PATH . '/' . $template_name, get_template_directory() . '/' . SIMPLE_WP_MEMBERSHIP_TEMPLATE_PATH . '/' . $template_name, SIMPLE_WP_MEMBERSHIP_PATH . 'views/' . $template_name); //Filter hook to allow overriding of the template file path $template_files = apply_filters('swpm_load_template_files', $template_files, $template_name); foreach ($template_files as $file) { if (file_exists($file)) { $template_to_load = $file; break; } } //Lets load this template if ($template_to_load) { if ($require_once) { require_once $template_to_load; } else { require $template_to_load; } } else { wp_die(SwpmUtils::_('Error! Failed to find a template path for the specified template: ' . $template_name)); } }
protected function subscription_period() { $subscript_duration_type = filter_input(INPUT_POST, 'subscription_duration_type'); if ($subscript_duration_type == SwpmMembershipLevel::NO_EXPIRY) { $this->sanitized['subscription_period'] = ""; return; } $subscription_period = filter_input(INPUT_POST, 'subscription_period_' . $subscript_duration_type); if ($subscript_duration_type == SwpmMembershipLevel::FIXED_DATE) { $dateinfo = date_parse($subscription_period); if ($dateinfo['warning_count'] || $dateinfo['error_count']) { $this->errors['subscription_period'] = SwpmUtils::_("Date format is not valid."); return; } $this->sanitized['subscription_period'] = sanitize_text_field($subscription_period); return; } if (!is_numeric($subscription_period)) { $this->errors['subscription_period'] = SwpmUtils::_("Access duration must be > 0."); return; } $this->sanitized['subscription_period'] = sanitize_text_field($subscription_period); }
public static function delete_account_button() { $allow_account_deletion = SwpmSettings::get_instance()->get_value('allow-account-deletion'); if (empty($allow_account_deletion)) { return ""; } return '<a href="/?delete_account=1"><div class="swpm-account-delete-button">' . SwpmUtils::_("Delete Account") . '</div></a>'; }
function handle_main_membership_level_admin_menu() { do_action('swpm_membership_level_menu_start'); $level_action = filter_input(INPUT_GET, 'level_action'); $action = $level_action; $selected = $action; ?> <div class="wrap swpm-admin-menu-wrap"><!-- start wrap --> <!-- page title --> <h1><?php echo SwpmUtils::_('Simple WP Membership::Membership Levels'); ?> </h1> <!-- start nav menu tabs --> <h2 class="nav-tab-wrapper"> <a class="nav-tab <?php echo $selected == "" ? 'nav-tab-active' : ''; ?> " href="admin.php?page=simple_wp_membership_levels"><?php echo SwpmUtils::_('Membership Levels'); ?> </a> <a class="nav-tab <?php echo $selected == "add" ? 'nav-tab-active' : ''; ?> " href="admin.php?page=simple_wp_membership_levels&level_action=add"><?php echo SwpmUtils::_('Add Level'); ?> </a> <a class="nav-tab <?php echo $selected == "manage" ? 'nav-tab-active' : ''; ?> " href="admin.php?page=simple_wp_membership_levels&level_action=manage"><?php echo SwpmUtils::_('Manage Content Production'); ?> </a> <a class="nav-tab <?php echo $selected == "category_list" ? 'nav-tab-active' : ''; ?> " href="admin.php?page=simple_wp_membership_levels&level_action=category_list"><?php echo SwpmUtils::_('Category Protection'); ?> </a> <?php //Trigger hooks that allows an extension to add extra nav tabs in the membership levels menu. do_action('swpm_membership_levels_menu_nav_tabs', $selected); $menu_tabs = apply_filters('swpm_membership_levels_additional_menu_tabs_array', array()); foreach ($menu_tabs as $level_action => $title) { ?> <a class="nav-tab <?php echo $selected == $member_action ? 'nav-tab-active' : ''; ?> " href="admin.php?page=simple_wp_membership_levels&level_action=<?php echo $level_action; ?> " ><?php SwpmUtils::e($title); ?> </a> <?php } ?> </h2> <!-- end nav menu tabs --> <?php do_action('swpm_membership_level_menu_after_nav_tabs'); //Trigger hook so anyone listening for this particular action can handle the output. do_action('swpm_membership_level_menu_body_' . $action); //Allows an addon to completely override the body section of the membership level admin menu for a given action. $output = apply_filters('swpm_membership_level_menu_body_override', '', $action); if (!empty($output)) { //An addon has overriden the body of this page for the given action. So no need to do anything in core. echo $output; echo '</div>'; //<!-- end of wrap --> return; } //Switch case for the various different actions handled by the core plugin. switch ($action) { case 'add': case 'edit': $this->process_form_request(); break; case 'manage': $this->manage(); break; case 'category_list': $this->manage_categroy(); break; case 'delete': $this->delete_level(); default: $this->show_levels(); break; } echo '</div>'; //<!-- end of wrap --> }
function swpm_render_pp_subscription_button_sc_output($button_code, $args) { $button_id = isset($args['id']) ? $args['id'] : ''; if (empty($button_id)) { return '<p style="color: red;">Error! swpm_render_pp_subscription_button_sc_output() function requires the button ID value to be passed to it.</p>'; } //Check new_window parameter $window_target = isset($args['new_window']) ? 'target="_blank"' : ''; $settings = SwpmSettings::get_instance(); $button_cpt = get_post($button_id); //Retrieve the CPT for this button $membership_level_id = get_post_meta($button_id, 'membership_level_id', true); $paypal_email = get_post_meta($button_id, 'paypal_email', true); $payment_currency = get_post_meta($button_id, 'payment_currency', true); //Subscription payment details $billing_amount = get_post_meta($button_id, 'billing_amount', true); if (!is_numeric($billing_amount)) { return '<p style="color: red;">Error! The billing amount value of the button must be a numeric number. Example: 49.50 </p>'; } $billing_amount = round($billing_amount, 2); //round the amount to 2 decimal place. $billing_cycle = get_post_meta($button_id, 'billing_cycle', true); $billing_cycle_term = get_post_meta($button_id, 'billing_cycle_term', true); $billing_cycle_count = get_post_meta($button_id, 'billing_cycle_count', true); $billing_reattempt = get_post_meta($button_id, 'billing_reattempt', true); //Trial billing details $trial_billing_amount = get_post_meta($button_id, 'trial_billing_amount', true); if (!empty($trial_billing_amount)) { if (!is_numeric($trial_billing_amount)) { return '<p style="color: red;">Error! The trial billing amount value of the button must be a numeric number. Example: 19.50 </p>'; } } $trial_billing_cycle = get_post_meta($button_id, 'trial_billing_cycle', true); $trial_billing_cycle_term = get_post_meta($button_id, 'trial_billing_cycle_term', true); $sandbox_enabled = $settings->get_value('enable-sandbox-testing'); $notify_url = SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL . '/?swpm_process_ipn=1'; $return_url = get_post_meta($button_id, 'return_url', true); if (empty($return_url)) { $return_url = SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL; } $cancel_url = SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL; $user_ip = SwpmUtils::get_user_ip_address(); $_SESSION['swpm_payment_button_interaction'] = $user_ip; //Custom field data $custom_field_value = 'subsc_ref=' . $membership_level_id; $custom_field_value .= '&user_ip=' . $user_ip; if (SwpmMemberUtils::is_member_logged_in()) { $custom_field_value .= '&swpm_id=' . SwpmMemberUtils::get_logged_in_members_id(); } $custom_field_value = apply_filters('swpm_custom_field_value_filter', $custom_field_value); /* === PayPal Subscription Button Form === */ $output = ''; $output .= '<div class="swpm-button-wrapper swpm-pp-subscription-wrapper">'; if ($sandbox_enabled) { $output .= '<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" ' . $window_target . '>'; } else { $output .= '<form action="https://www.paypal.com/cgi-bin/webscr" method="post" ' . $window_target . '>'; } $output .= '<input type="hidden" name="cmd" value="_xclick-subscriptions" />'; $output .= '<input type="hidden" name="charset" value="utf-8" />'; $output .= '<input type="hidden" name="bn" value="TipsandTricks_SP" />'; $output .= '<input type="hidden" name="business" value="' . $paypal_email . '" />'; $output .= '<input type="hidden" name="currency_code" value="' . $payment_currency . '" />'; $output .= '<input type="hidden" name="item_number" value="' . $button_id . '" />'; $output .= '<input type="hidden" name="item_name" value="' . htmlspecialchars($button_cpt->post_title) . '" />'; //Check trial billing if (!empty($trial_billing_cycle)) { $output .= '<input type="hidden" name="a1" value="' . $trial_billing_amount . '" /><input type="hidden" name="p1" value="' . $trial_billing_cycle . '" /><input type="hidden" name="t1" value="' . $trial_billing_cycle_term . '" />'; } //Main subscription billing if (!empty($billing_cycle)) { $output .= '<input type="hidden" name="a3" value="' . $billing_amount . '" /><input type="hidden" name="p3" value="' . $billing_cycle . '" /><input type="hidden" name="t3" value="' . $billing_cycle_term . '" />'; } //Re-attempt on failure if ($billing_reattempt != '') { $output .= '<input type="hidden" name="sra" value="1" />'; } //Reccurring times if ($billing_cycle_count > 1) { //do not include srt value if billing cycle count set to 1 or a negetive number. $output .= '<input type="hidden" name="src" value="1" /><input type="hidden" name="srt" value="' . $billing_cycle_count . '" />'; } else { if (empty($billing_cycle_count)) { $output .= '<input type="hidden" name="src" value="1" />'; } } //Other required data $output .= '<input type="hidden" name="no_shipping" value="1" />'; //Do not prompt for an address $output .= '<input type="hidden" name="notify_url" value="' . $notify_url . '" />'; $output .= '<input type="hidden" name="return" value="' . $return_url . '" />'; $output .= '<input type="hidden" name="cancel_return" value="' . $cancel_url . '" />'; $output .= '<input type="hidden" name="custom" value="' . $custom_field_value . '" />'; //Filter to add additional payment input fields to the form (example: langauge code or country code etc). $output .= apply_filters('swpm_pp_payment_form_additional_fields', ''); //Submit button $button_image_url = get_post_meta($button_id, 'button_image_url', true); if (!empty($button_image_url)) { $output .= '<input type="image" src="' . $button_image_url . '" class="swpm-subscription-button-submit" alt="' . SwpmUtils::_('Subscribe Now') . '"/>'; } else { $button_text = isset($args['button_text']) ? $args['button_text'] : SwpmUtils::_('Subscribe Now'); $output .= '<input type="submit" class="swpm-subscription-button-submit" value="' . $button_text . '" />'; } $output .= '</form>'; //End .form $output .= '</div>'; //End .swpm_button_wrapper return $output; }
echo SwpmUtils::account_state_dropdown('active'); ?> </select> </td> </tr> <?php include 'admin_member_form_common_part.php'; ?> </tbody> </table> <?php include 'admin_member_form_common_js.php'; ?> <?php submit_button(SwpmUtils::_('Add New Member '), 'primary', 'createswpmuser', true, array('id' => 'createswpmusersub')); ?> </form> </div> <script> jQuery(document).ready(function($){ $.validationEngineLanguage.allRules['ajaxUserCall']['url']= '<?php echo admin_url('admin-ajax.php'); ?> '; $.validationEngineLanguage.allRules['ajaxEmailCall']['url']= '<?php echo admin_url('admin-ajax.php'); ?> '; $("#swpm-create-user").validationEngine('attach'); });
</p> </form> <?php if (isset($_REQUEST['member_action']) && $_REQUEST['member_action'] == 'delete') { //Delete this record $this->delete(); $success_msg = '<div id="message" class="updated"><p>'; $success_msg .= SwpmUtils::_('The selected entry was deleted!'); $success_msg .= '</p></div>'; echo $success_msg; } $this->prepare_items(); ?> <form id="tables-filter" method="get" onSubmit="return confirm('Are you sure you want to perform this bulk operation on the selected entries?');"> <!-- For plugins, we also need to ensure that the form posts back to our current page --> <input type="hidden" name="page" value="<?php echo $_REQUEST['page']; ?> " /> <!-- Now we can render the completed list table --> <?php $this->display(); ?> </form> <p> <a href="admin.php?page=simple_wp_membership&member_action=add" class="button-primary"><?php echo SwpmUtils::_('Add New'); ?> </a> </p>
echo SwpmUtils::_('Membership Level'); ?> </label> <?php echo $membership_level_alias; ?> --> <input type="hidden" value="<?php echo $membership_level; ?> " size="50" name="membership_level" tabindex="7" id="membership_level" /> <p align="center"><input type="submit" value="<?php echo SwpmUtils::_('Register'); ?> " class="btn btn-success" tabindex="8" id="submit" name="swpm_registration_submit" /></p> <input type="hidden" name="action" value="custom_posts" /> <?php wp_nonce_field('name_of_my_action', 'name_of_nonce_field'); session_destroy(); ?> </form> </div> <script> jQuery(document).ready(function($){ $.validationEngineLanguage.allRules['ajaxUserCall']['url']= '<?php echo admin_url('admin-ajax.php'); ?> ';
<div class="swpm-pw-reset-widget-form"> <form id="swpm-pw-reset-form" name="swpm-reset-form" method="post" action=""> <div class="swpm-pw-reset-widget-inside"> <div class="swpm-pw-reset-email swpm-margin-top-10"> <label for="swpm_reset_email" class="swpm_label swpm-pw-reset-email-label"><?php echo SwpmUtils::_('Email Address'); ?> </label> </div> <div class="swpm-pw-reset-email-input swpm-margin-top-10"> <input type="text" name="swpm_reset_email" class="swpm-text-field swpm-pw-reset-text" id="swpm_reset_email" value="" size="60" /> </div> <div class="swpm-pw-reset-submit-button swpm-margin-top-10"> <input type="submit" name="swpm-reset" class="swpm-pw-reset-submit" value="<?php echo SwpmUtils::_('Reset Password'); ?> " /> </div> </div> </form> </div>
function process_delete_action() { if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete_payment_btn') { //Delete link was clicked for a row in list table $record_id = sanitize_text_field($_REQUEST['button_id']); if (!is_numeric($record_id)) { wp_die('Error! ID must be a numeric number.'); } wp_delete_post($record_id); $success_msg = '<div id="message" class="updated"><p>'; $success_msg .= SwpmUtils::_('The selected entry was deleted!'); $success_msg .= '</p></div>'; echo $success_msg; } }
function get_bulk_actions() { $actions = array('delete' => SwpmUtils::_('Delete')); return $actions; }
<div class="inside"> <form action="" method="post"> <input type="radio" name="button_type" value="pp_buy_now" checked><?php SwpmUtils::e('PayPal Buy Now'); ?> <br /> <input type="radio" name="button_type" value="pp_subscription"><?php SwpmUtils::e('PayPal Subscription'); ?> <br /> <?php apply_filters('swpm_new_button_select_button_type', ''); ?> <br /> <input type="submit" name="swpm_button_type_selected" class="button-primary" value="<?php echo SwpmUtils::_('Next'); ?> " /> </form> </div> </div><!-- end of .postbox --> <?php } else { //Button type has been selected. Show the payment button configuration option. //Fire the action hook. The addons can render the payment button configuration option as appropriate. $button_type = strip_tags($_REQUEST['button_type']); do_action('swpm_create_new_button_for_' . $button_type); //The payment addons will create the button from then redirect to the "edit" interface of that button after save. }
<?php $output = ''; echo '<link type="text/css" rel="stylesheet" href="' . SIMPLE_WP_MEMBERSHIP_URL . '/css/swpm.addons.listing.css" />' . "\n"; ?> <h1><?php echo SwpmUtils::_('Simple WP Membership::Add-ons'); ?> </h1> <div class="wrap"> <?php $addons_data = array(); $addon_1 = array('name' => 'After Login Redirection', 'thumbnail' => SIMPLE_WP_MEMBERSHIP_URL . '/images/addons/swpm-login-redirection.png', 'description' => 'Allows you to configure after login redirection to a specific page based on the member\'s level', 'page_url' => 'https://simple-membership-plugin.com/configure-login-redirection-members/'); array_push($addons_data, $addon_1); $addon_2 = array('name' => 'MailChimp Integration', 'thumbnail' => SIMPLE_WP_MEMBERSHIP_URL . '/images/addons/mailchimp-integration.png', 'description' => 'Allows you to signup the member to your MailChimp list after registration', 'page_url' => 'https://simple-membership-plugin.com/signup-members-mailchimp-list/'); array_push($addons_data, $addon_2); $addon_3 = array('name' => 'Form Shortcode', 'thumbnail' => SIMPLE_WP_MEMBERSHIP_URL . '/images/addons/form-shortcode-generator.png', 'description' => 'Simple Membership Addon to generate form shortcode for specific membership level.', 'page_url' => 'https://simple-membership-plugin.com/simple-membership-registration-form-shortcode-generator/'); array_push($addons_data, $addon_3); $addon_4 = array('name' => 'WP User Import', 'thumbnail' => SIMPLE_WP_MEMBERSHIP_URL . '/images/addons/wp-user-import.png', 'description' => 'Addon for importing existing Wordpress users to Simple Membership plugin', 'page_url' => 'https://simple-membership-plugin.com/import-existing-wordpress-users-simple-membership-plugin/'); array_push($addons_data, $addon_4); $addon_5 = array('name' => 'Form Builder', 'thumbnail' => SIMPLE_WP_MEMBERSHIP_URL . '/images/addons/swpm-form-builder.png', 'description' => 'Allows you to fully customize the fields that appear on the registration and edit profile forms of your membership site', 'page_url' => 'https://simple-membership-plugin.com/simple-membership-form-builder-addon/'); array_push($addons_data, $addon_5); $addon_6 = array('name' => 'Custom Messages', 'thumbnail' => SIMPLE_WP_MEMBERSHIP_URL . '/images/addons/swpm-custom-messages.png', 'description' => 'Custom Messages addon allows you to customize the content protection message that gets output from the membership plugin', 'page_url' => 'https://simple-membership-plugin.com/simple-membership-custom-messages-addon/'); array_push($addons_data, $addon_6); $addon_7 = array('name' => 'Protect Older Posts', 'thumbnail' => SIMPLE_WP_MEMBERSHIP_URL . '/images/addons/swpm-older-posts-protection.png', 'description' => 'The protect older posts addon allows you to control protection of posts that were published before a member\'s access start date.', 'page_url' => 'https://simple-membership-plugin.com/simple-membership-protect-older-posts-addon/'); array_push($addons_data, $addon_7); foreach ($addons_data as $addon) { $output .= '<div class="swpm_addon_item_canvas">'; $output .= '<div class="swpm_addon_item_thumb">';
function swpm_edit_pp_subscription_button() { //Retrieve the payment button data and present it for editing. $button_id = sanitize_text_field($_REQUEST['button_id']); $button_id = absint($button_id); $button_type = sanitize_text_field($_REQUEST['button_type']); $button = get_post($button_id); //Retrieve the CPT for this button $membership_level_id = get_post_meta($button_id, 'membership_level_id', true); //$payment_amount = get_post_meta($button_id, 'payment_amount', true); $payment_currency = get_post_meta($button_id, 'payment_currency', true); $return_url = get_post_meta($button_id, 'return_url', true); $paypal_email = get_post_meta($button_id, 'paypal_email', true); $button_image_url = get_post_meta($button_id, 'button_image_url', true); //Subscription billing details $billing_amount = get_post_meta($button_id, 'billing_amount', true); $billing_cycle = get_post_meta($button_id, 'billing_cycle', true); $billing_cycle_term = get_post_meta($button_id, 'billing_cycle_term', true); $billing_cycle_count = get_post_meta($button_id, 'billing_cycle_count', true); $billing_reattempt = get_post_meta($button_id, 'billing_reattempt', true); //Trial billing details $trial_billing_amount = get_post_meta($button_id, 'trial_billing_amount', true); $trial_billing_cycle = get_post_meta($button_id, 'trial_billing_cycle', true); $trial_billing_cycle_term = get_post_meta($button_id, 'trial_billing_cycle_term', true); ?> <form id="pp_button_config_form" method="post"> <div class="postbox"> <h3 class="hndle"><label for="title"><?php echo SwpmUtils::_('PayPal Subscription Button Configuration'); ?> </label></h3> <div class="inside"> <table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6"> <tr valign="top"> <th scope="row"><?php echo SwpmUtils::_('Button ID'); ?> </th> <td> <input type="text" size="10" name="button_id" value="<?php echo $button_id; ?> " readonly required /> <p class="description">This is the ID of this payment button. It is automatically generated for you and it cannot be changed.</p> </td> </tr> <tr valign="top"> <th scope="row"><?php echo SwpmUtils::_('Button Title'); ?> </th> <td> <input type="text" size="50" name="button_name" value="<?php echo $button->post_title; ?> " required /> <p class="description">Give this membership payment button a name. Example: Gold membership payment</p> </td> </tr> <tr valign="top"> <th scope="row"><?php echo SwpmUtils::_('Membership Level'); ?> </th> <td> <select id="membership_level_id" name="membership_level_id"> <?php echo SwpmUtils::membership_level_dropdown($membership_level_id); ?> </select> <p class="description">Select the membership level this payment button is for.</p> </td> </tr> <tr valign="top"> <th scope="row"><?php echo SwpmUtils::_('Payment Currency'); ?> </th> <td> <select id="payment_currency" name="payment_currency"> <option value="USD" <?php echo $payment_currency == 'USD' ? 'selected="selected"' : ''; ?> >US Dollars ($)</option> <option value="EUR" <?php echo $payment_currency == 'EUR' ? 'selected="selected"' : ''; ?> >Euros (€)</option> <option value="GBP" <?php echo $payment_currency == 'GBP' ? 'selected="selected"' : ''; ?> >Pounds Sterling (£)</option> <option value="AUD" <?php echo $payment_currency == 'AUD' ? 'selected="selected"' : ''; ?> >Australian Dollars ($)</option> <option value="BRL" <?php echo $payment_currency == 'BRL' ? 'selected="selected"' : ''; ?> >Brazilian Real (R$)</option> <option value="CAD" <?php echo $payment_currency == 'CAD' ? 'selected="selected"' : ''; ?> >Canadian Dollars ($)</option> <option value="CNY" <?php echo $payment_currency == 'CNY' ? 'selected="selected"' : ''; ?> >Chinese Yuan</option> <option value="CZK" <?php echo $payment_currency == 'CZK' ? 'selected="selected"' : ''; ?> >Czech Koruna</option> <option value="DKK" <?php echo $payment_currency == 'DKK' ? 'selected="selected"' : ''; ?> >Danish Krone</option> <option value="HKD" <?php echo $payment_currency == 'HKD' ? 'selected="selected"' : ''; ?> >Hong Kong Dollar ($)</option> <option value="HUF" <?php echo $payment_currency == 'HUF' ? 'selected="selected"' : ''; ?> >Hungarian Forint</option> <option value="INR" <?php echo $payment_currency == 'INR' ? 'selected="selected"' : ''; ?> >Indian Rupee</option> <option value="IDR" <?php echo $payment_currency == 'IDR' ? 'selected="selected"' : ''; ?> >Indonesia Rupiah</option> <option value="ILS" <?php echo $payment_currency == 'ILS' ? 'selected="selected"' : ''; ?> >Israeli Shekel</option> <option value="JPY" <?php echo $payment_currency == 'JPY' ? 'selected="selected"' : ''; ?> >Japanese Yen (¥)</option> <option value="MYR" <?php echo $payment_currency == 'MYR' ? 'selected="selected"' : ''; ?> >Malaysian Ringgits</option> <option value="MXN" <?php echo $payment_currency == 'MXN' ? 'selected="selected"' : ''; ?> >Mexican Peso ($)</option> <option value="NZD" <?php echo $payment_currency == 'NZD' ? 'selected="selected"' : ''; ?> >New Zealand Dollar ($)</option> <option value="NOK" <?php echo $payment_currency == 'NOK' ? 'selected="selected"' : ''; ?> >Norwegian Krone</option> <option value="PHP" <?php echo $payment_currency == 'PHP' ? 'selected="selected"' : ''; ?> >Philippine Pesos</option> <option value="PLN" <?php echo $payment_currency == 'PLN' ? 'selected="selected"' : ''; ?> >Polish Zloty</option> <option value="SGD" <?php echo $payment_currency == 'SGD' ? 'selected="selected"' : ''; ?> >Singapore Dollar ($)</option> <option value="ZAR" <?php echo $payment_currency == 'ZAR' ? 'selected="selected"' : ''; ?> >South African Rand (R)</option> <option value="KRW" <?php echo $payment_currency == 'KRW' ? 'selected="selected"' : ''; ?> >South Korean Won</option> <option value="SEK" <?php echo $payment_currency == 'SEK' ? 'selected="selected"' : ''; ?> >Swedish Krona</option> <option value="CHF" <?php echo $payment_currency == 'CHF' ? 'selected="selected"' : ''; ?> >Swiss Franc</option> <option value="TWD" <?php echo $payment_currency == 'TWD' ? 'selected="selected"' : ''; ?> >Taiwan New Dollars</option> <option value="THB" <?php echo $payment_currency == 'THB' ? 'selected="selected"' : ''; ?> >Thai Baht</option> <option value="TRY" <?php echo $payment_currency == 'TRY' ? 'selected="selected"' : ''; ?> >Turkish Lira</option> <option value="VND" <?php echo $payment_currency == 'VND' ? 'selected="selected"' : ''; ?> >Vietnamese Dong</option> </select> <p class="description">Select the currency for this payment button.</p> </td> </tr> <tr valign="top"> <th scope="row"><?php echo SwpmUtils::_('PayPal Email'); ?> </th> <td> <input type="text" size="50" name="paypal_email" value="<?php echo $paypal_email; ?> " required /> <p class="description">Enter your PayPal email address. The payment will go to this PayPal account.</p> </td> </tr> <tr valign="top"> <th scope="row"><?php echo SwpmUtils::_('Billing Amount Each Cycle'); ?> </th> <td> <input type="text" size="6" name="billing_amount" value="<?php echo $billing_amount; ?> " required /> <p class="description">Amount to be charged on every billing cycle. If used with a trial period then this amount will be charged after the trial period is over. Example values: 10.00 or 19.50 or 299.95 etc (do not put currency symbol).</p> </td> </tr> <tr valign="top"> <th scope="row"><?php echo SwpmUtils::_('Billing Cycle'); ?> </th> <td> <input type="text" size="4" name="billing_cycle" value="<?php echo $billing_cycle; ?> " required /> <select id="billing_cycle_term" name="billing_cycle_term"> <option value="D" <?php echo $billing_cycle_term == 'D' ? 'selected="selected"' : ''; ?> >Day(s)</option> <option value="M" <?php echo $billing_cycle_term == 'M' ? 'selected="selected"' : ''; ?> >Month(s)</option> <option value="Y" <?php echo $billing_cycle_term == 'Y' ? 'selected="selected"' : ''; ?> >Year(s)</option> </select> <p class="description">Set the interval of the recurring payment. Example value: 1 Month (if you want to charge every month)</p> </td> </tr> <tr valign="top"> <th scope="row"><?php echo SwpmUtils::_('Billing Cycle Count'); ?> </th> <td> <input type="text" size="6" name="billing_cycle_count" value="<?php echo $billing_cycle_count; ?> " /> <p class="description">After how many cycles should billing stop. Leave this field empty (or enter 0) if you want the payment to continue until the subscription is canceled.</p> </td> </tr> <tr valign="top"> <th scope="row"><?php echo SwpmUtils::_('Re-attempt on Failure'); ?> </th> <td> <input type="checkbox" name="billing_reattempt" value="1" <?php if ($billing_reattempt != '') { echo ' checked="checked"'; } ?> /> <p class="description">When checked, the payment will be re-attempted two more times if the payment fails. After the third failure, the subscription will be canceled..</p> </td> </tr> </table> </div> </div><!-- end of main button configuration box --> <div class="postbox"> <h3 class="hndle"><label for="title"><?php echo SwpmUtils::_('Trial Billing Details (Leave empty if you are not offering a trial period)'); ?> </label></h3> <div class="inside"> <table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6"> <tr valign="top"> <th scope="row"><?php echo SwpmUtils::_('Trial Billing Amount'); ?> </th> <td> <input type="text" size="6" name="trial_billing_amount" value="<?php echo $trial_billing_amount; ?> " /> <p class="description">Amount to be charged for the trial period. Enter 0 if you want to offer a free trial period.</p> </td> </tr> <tr valign="top"> <th scope="row"><?php echo SwpmUtils::_('Trial Billing Period'); ?> </th> <td> <input type="text" size="4" name="trial_billing_cycle" value="<?php echo $trial_billing_cycle; ?> " /> <select id="billing_cycle_term" name="trial_billing_cycle_term"> <option value="D" <?php echo $trial_billing_cycle_term == 'D' ? 'selected="selected"' : ''; ?> >Day(s)</option> <option value="M" <?php echo $trial_billing_cycle_term == 'M' ? 'selected="selected"' : ''; ?> >Month(s)</option> <option value="Y" <?php echo $trial_billing_cycle_term == 'Y' ? 'selected="selected"' : ''; ?> >Year(s)</option> </select> <p class="description">Length of the trial period</p> </td> </tr> </table> </div> </div><!-- end of trial billing details box --> <div class="postbox"> <h3 class="hndle"><label for="title"><?php echo SwpmUtils::_('Optional Details'); ?> </label></h3> <div class="inside"> <table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6"> <tr valign="top"> <th scope="row"><?php echo SwpmUtils::_('Return URL'); ?> </th> <td> <input type="text" size="100" name="return_url" value="<?php echo $return_url; ?> " /> <p class="description">This is the URL the user will be redirected to after a successful payment. Enter the URL of your Thank You page here.</p> </td> </tr> <tr valign="top"> <th scope="row"><?php echo SwpmUtils::_('Button Image URL'); ?> </th> <td> <input type="text" size="100" name="button_image_url" value="<?php echo $button_image_url; ?> " /> <p class="description">If you want to customize the look of the button using an image then enter the URL of the image.</p> </td> </tr> </table> </div> </div><!-- end of optional details box --> <p class="submit"> <input type="submit" name="swpm_pp_subscription_save_submit" class="button-primary" value="<?php echo SwpmUtils::_('Save Payment Data'); ?> " > </p> </form> <?php }
function handle_main_payments_admin_menu() { do_action('swpm_payments_menu_start'); $output = ''; $tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : ''; $selected = $tab; ?> <div class="wrap swpm-admin-menu-wrap"><!-- start wrap --> <h1><?php echo SwpmUtils::_('Simple Membership::Payments'); ?> </h1><!-- page title --> <!-- start nav menu tabs --> <h2 class="nav-tab-wrapper"> <a class="nav-tab <?php echo $tab == '' ? 'nav-tab-active' : ''; ?> " href="admin.php?page=simple_wp_membership_payments"><?php SwpmUtils::e('Transactions'); ?> </a> <a class="nav-tab <?php echo $tab == 'payment_buttons' ? 'nav-tab-active' : ''; ?> " href="admin.php?page=simple_wp_membership_payments&tab=payment_buttons"><?php SwpmUtils::e('Manage Payment Buttons'); ?> </a> <a class="nav-tab <?php echo $tab == 'create_new_button' ? 'nav-tab-active' : ''; ?> " href="admin.php?page=simple_wp_membership_payments&tab=create_new_button"><?php SwpmUtils::e('Create New Button'); ?> </a> <?php if ($tab == 'edit_button') { //Only show the "edit button" tab when a button is being edited. echo '<a class="nav-tab nav-tab-active" href="#">Edit Button</a>'; } //Trigger hooks that allows an extension to add extra nav tabs in the payments menu. do_action('swpm_payments_menu_nav_tabs', $selected); $menu_tabs = apply_filters('swpm_payments_menu_additional_menu_tabs_array', array()); foreach ($menu_tabs as $menu_action => $title) { ?> <a class="nav-tab <?php echo $selected == $menu_action ? 'nav-tab-active' : ''; ?> " href="admin.php?page=simple_wp_membership_payments&tab=<?php echo $menu_action; ?> " ><?php SwpmUtils::e($title); ?> </a> <?php } ?> </h2> <!-- end nav menu tabs --> <?php do_action('swpm_payments_menu_after_nav_tabs'); //Allows an addon to completely override the body section of the payments admin menu for a given action. $output = apply_filters('swpm_payments_menu_body_override', '', $tab); if (!empty($output)) { //An addon has overriden the body of this page for the given tab/action. So no need to do anything in core. echo $output; echo '</div>'; //<!-- end of wrap --> return; } echo '<div id="poststuff"><div id="post-body">'; //TODO - move most of the following includes to functions of this class instead. //Switch case for the various different tabs handled by the core plugin. switch ($tab) { case 'payment_buttons': include_once SIMPLE_WP_MEMBERSHIP_PATH . '/views/payments/admin_payment_buttons.php'; break; case 'create_new_button': include_once SIMPLE_WP_MEMBERSHIP_PATH . '/views/payments/admin_create_payment_buttons.php'; break; case 'edit_button': include_once SIMPLE_WP_MEMBERSHIP_PATH . '/views/payments/admin_edit_payment_buttons.php'; break; case 'all_txns': include_once SIMPLE_WP_MEMBERSHIP_PATH . '/views/payments/admin_all_payment_transactions.php'; break; default: include_once SIMPLE_WP_MEMBERSHIP_PATH . '/views/payments/admin_all_payment_transactions.php'; break; } echo '</div></div>'; //<!-- end of post-body --> echo '</div>'; //<!-- end of .wrap --> }
public function reset_password($email) { $email = sanitize_email($email); if (!is_email($email)) { $message = '<div class="swpm-reset-pw-error">' . SwpmUtils::_("Email address not valid.") . '</div>'; $message = array('succeeded' => false, 'message' => $message); SwpmTransfer::get_instance()->set('status', $message); return; } global $wpdb; $query = 'SELECT member_id,user_name,first_name, last_name FROM ' . $wpdb->prefix . 'swpm_members_tbl ' . ' WHERE email = %s'; $user = $wpdb->get_row($wpdb->prepare($query, $email)); if (empty($user)) { $message = '<div class="swpm-reset-pw-error">' . SwpmUtils::_("No user found with that email address.") . '</div>'; $message .= '<div class="swpm-reset-pw-error-email">' . SwpmUtils::_("Email Address: ") . $email . '</div>'; $message = array('succeeded' => false, 'message' => $message); SwpmTransfer::get_instance()->set('status', $message); return; } $settings = SwpmSettings::get_instance(); $password = wp_generate_password(); $password_hash = SwpmUtils::encrypt_password(trim($password)); //should use $saned??; $wpdb->update($wpdb->prefix . "swpm_members_tbl", array('password' => $password_hash), array('member_id' => $user->member_id)); //Update wp user password add_filter('send_password_change_email', array(&$this, 'dont_send_password_change_email'), 1, 3); //Stop wordpress from sending a reset password email to admin. SwpmUtils::update_wp_user($user->user_name, array('plain_password' => $password)); $body = $settings->get_value('reset-mail-body'); $subject = $settings->get_value('reset-mail-subject'); $search = array('{user_name}', '{first_name}', '{last_name}', '{password}'); $replace = array($user->user_name, $user->first_name, $user->last_name, $password); $body = html_entity_decode($body); $body = str_replace($search, $replace, $body); $from = $settings->get_value('email-from'); $headers = "From: " . $from . "\r\n"; wp_mail($email, $subject, $body, $headers); SwpmLog::log_simple_debug("Member password has been reset. Password reset email sent to: " . $email, true); $message = '<div class="swpm-reset-pw-success">' . SwpmUtils::_("New password has been sent to your email address.") . '</div>'; $message .= '<div class="swpm-reset-pw-success-email">' . SwpmUtils::_("Email Address: ") . $email . '</div>'; $message = array('succeeded' => false, 'message' => $message); SwpmTransfer::get_instance()->set('status', $message); }
" size="50" name="country" /></td> </tr> <tr> <td><label for="membership_level"><?php echo SwpmUtils::_('Membership Level'); ?> </label></td> <td> <?php echo $membership_level_alias; ?> </td> </tr> </table> <p align="center"><input type="submit" value="<?php echo SwpmUtils::_('Update'); ?> " class="swpm-edit-profile-submit" name="swpm_editprofile_submit" /> </p> <?php echo SwpmUtils::delete_account_button(); ?> <input type="hidden" name="action" value="custom_posts" /> <?php wp_nonce_field('name_of_my_action', 'name_of_nonce_field'); ?> </form> </div> <script> jQuery(document).ready(function($){
<?php //Render the all payment buttons tab ?> <div style="background: #DDDDDD;border: 1px solid #CCCCCC;color: #383838;margin: 10px 0;padding: 5px 5px 5px 10px;text-shadow: 1px 1px #FFFFFF;"> <p> <?php echo SwpmUtils::_('All the membership buttons that you created in the plugin are displayed here.'); ?> </p> </div> <?php include_once SIMPLE_WP_MEMBERSHIP_PATH . 'classes/admin-includes/class.swpm-payment-buttons-list-table.php'; //Create an instance of our package class... $payments_buttons_table = new SwpmPaymentButtonsListTable(); //Fetch, prepare, sort, and filter our data... $payments_buttons_table->prepare_items(); ?> <form id="swpm-payment-buttons-filter" method="post" onSubmit="return confirm('Are you sure you want to perform this bulk operation on the selected entries?');"> <input type="hidden" name="page" value="" /> <!-- Now we can render the completed list table --> <?php $payments_buttons_table->display(); ?> </form> <p>
public static function delete_account_button() { $allow_account_deletion = SwpmSettings::get_instance()->get_value('allow-account-deletion'); if (empty($allow_account_deletion)) { return ""; } $account_delete_link = '<div class="swpm-profile-account-delete-section">'; $account_delete_link .= '<a href="' . SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL . '/?swpm_delete_account=1"><div class="swpm-account-delete-button">' . SwpmUtils::_("Delete Account") . '</div></a>'; $account_delete_link .= '</div>'; return $account_delete_link; }
<?php $output = ''; $tab = isset($_GET['tab']) ? $_GET['tab'] : ''; ?> <div class="wrap"> <h2><?php echo SwpmUtils::_('Simple Membership::Payments'); ?> </h2> <div id="poststuff"><div id="post-body"> <h2 class="nav-tab-wrapper"> <a class="nav-tab <?php echo $tab == '' ? 'nav-tab-active' : ''; ?> " href="admin.php?page=simple_wp_membership_payments"><?php SwpmUtils::e('Transactions'); ?> </a> <a class="nav-tab <?php echo $tab == 'payment_buttons' ? 'nav-tab-active' : ''; ?> " href="admin.php?page=simple_wp_membership_payments&tab=payment_buttons"><?php SwpmUtils::e('Manage Payment Buttons'); ?> </a> <a class="nav-tab <?php