function rcp_members_page() { global $rcp_options, $rcp_db_name, $wpdb; $current_page = admin_url('/admin.php?page=rcp-members'); ?> <div class="wrap" id="rcp-members-page"> <?php if (isset($_GET['edit_member']) || isset($_GET['view_member'])) { include 'edit-member.php'; } else { ?> <h2><?php _e(' Paid Subscribers', 'rcp'); ?> </h2> <?php $subscription_id = isset($_GET['subscription']) && $_GET['subscription'] != 'all' ? urldecode($_GET['subscription']) : null; $status = !empty($_GET['status']) ? urldecode($_GET['status']) : 'active'; $order = !empty($_GET['order']) ? urldecode($_GET['order']) : 'DESC'; $recurring = isset($_GET['recurring']) ? absint($_GET['recurring']) : null; $search = !empty($_GET['s']) ? urldecode($_GET['s']) : ''; $base_url = admin_url('admin.php?page=rcp-members'); if ($search) { $base_url = add_query_arg('s', $search, $base_url); } // get subscriber count $active_count = rcp_count_members($subscription_id, 'active', $recurring, $search); $pending_count = rcp_count_members($subscription_id, 'pending', $recurring, $search); $expired_count = rcp_count_members($subscription_id, 'expired', $recurring, $search); $cancelled_count = rcp_count_members($subscription_id, 'cancelled', $recurring, $search); $free_count = rcp_count_members($subscription_id, 'free', $recurring, $search); $current_count = rcp_count_members($subscription_id, $status, $recurring, $search); // pagination variables $page = isset($_GET['p']) ? absint($_GET['p']) : 1; $user = get_current_user_id(); $screen = get_current_screen(); $screen_option = $screen->get_option('per_page', 'option'); $per_page = get_user_meta($user, $screen_option, true); if (empty($per_page) || $per_page < 1) { $per_page = $screen->get_option('per_page', 'default'); } $total_pages = 1; $offset = $per_page * ($page - 1); $total_pages = ceil($current_count / $per_page); ?> <ul class="subsubsub"> <li><?php _e('Status: ', 'rcp'); ?> </li> <li> <a href="<?php echo esc_url(add_query_arg('status', 'active', $base_url)); ?> " title="<?php _e('View all active subscribers', 'rcp'); ?> " <?php echo isset($_GET['status']) && $_GET['status'] == 'active' || !isset($_GET['status']) ? 'class="current"' : ''; ?> > <?php _e('Active', 'rcp'); ?> </a>(<?php echo $active_count; ?> ) </li> <li> <a href="<?php echo esc_url(add_query_arg('status', 'pending', $base_url)); ?> " title="<?php _e('View all pending subscribers', 'rcp'); ?> " <?php echo isset($_GET['status']) && $_GET['status'] == 'pending' ? 'class="current"' : ''; ?> > <?php _e('Pending', 'rcp'); ?> </a>(<?php echo $pending_count; ?> ) </li> <li> <a href="<?php echo esc_url(add_query_arg('status', 'expired', $base_url)); ?> " title="<?php _e('View all expired subscribers', 'rcp'); ?> " <?php echo isset($_GET['status']) && $_GET['status'] == 'expired' ? 'class="current"' : ''; ?> > <?php _e('Expired', 'rcp'); ?> </a>(<?php echo $expired_count; ?> ) </li> <li> <a href="<?php echo esc_url(add_query_arg('status', 'cancelled', $base_url)); ?> " title="<?php _e('View all cancelled subscribers', 'rcp'); ?> " <?php echo isset($_GET['status']) && $_GET['status'] == 'cancelled' ? 'class="current"' : ''; ?> > <?php _e('Cancelled', 'rcp'); ?> </a>(<?php echo $cancelled_count; ?> ) </li> <li> <a href="<?php echo esc_url(add_query_arg('status', 'free', $base_url)); ?> " title="<?php _e('View all free members', 'rcp'); ?> " <?php echo isset($_GET['status']) && $_GET['status'] == 'free' ? 'class="current"' : ''; ?> > <?php _e('Free', 'rcp'); ?> </a>(<?php echo $free_count; ?> ) </li> <?php do_action('rcp_members_page_statuses'); ?> </ul> <form id="rcp-member-search" method="get" action="<?php menu_page_url('rcp-members'); ?> "> <label class="screen-reader-text" for="rcp-member-search-input"><?php _e('Search Members', 'rcp'); ?> </label> <input type="search" id="rcp-member-search-input" name="s" value="<?php echo esc_attr($search); ?> "/> <input type="hidden" name="page" value="rcp-members"/> <input type="hidden" name="status" value="<?php echo esc_attr($status); ?> "/> <input type="submit" name="" id="rcp-member-search-submit" class="button" value="<?php _e('Search members', 'rcp'); ?> "/> </form> <form id="members-filter" action="" method="get"> <?php $levels = rcp_get_subscription_levels('all'); if ($levels) { ?> <select name="subscription" id="rcp-subscription"> <option value="all"><?php _e('All Subscriptions', 'rcp'); ?> </option> <?php foreach ($levels as $level) { echo '<option value="' . $level->id . '" ' . selected($subscription_id, $level->id, false) . '>' . $level->name . '</option>'; } ?> </select> <?php } ?> <select name="recurring" id="rcp-recurring"> <option value="0"><?php _e('Either', 'rcp'); ?> </option> <option value="1"<?php selected(1, $recurring); ?> ><?php _e('Not Recurring', 'rcp'); ?> </option> <option value="2"<?php selected(2, $recurring); ?> ><?php _e('Recurring', 'rcp'); ?> </option> </select> <select name="order" id="rcp-order"> <option value="DESC" <?php selected($order, 'DESC'); ?> ><?php _e('Newest First', 'rcp'); ?> </option> <option value="ASC" <?php selected($order, 'ASC'); ?> ><?php _e('Oldest First', 'rcp'); ?> </option> </select> <input type="hidden" name="page" value="rcp-members"/> <input type="hidden" name="status" value="<?php echo isset($_GET['status']) ? $_GET['status'] : 'active'; ?> "/> <input type="submit" class="button-secondary" value="<?php _e('Filter', 'rcp'); ?> "/> </form> <?php do_action('rcp_members_above_table'); ?> <form id="rcp-members-form" action="<?php echo esc_attr(admin_url('admin.php?page=rcp-members')); ?> " method="post"> <div id="rcp-bulk-action-options"> <label for="rcp-bulk-member-action" class="screen-reader-text"><?php _e('Select bulk action', 'rcp'); ?> </label> <select name="rcp-bulk-action" id="rcp-bulk-member-action"> <option value="-1"><?php _e('Bulk Actions', 'rcp'); ?> </option> <option value="mark-active"><?php _e('Mark as Active', 'rcp'); ?> </option> <option value="mark-expired"><?php _e('Mark as Expired', 'rcp'); ?> </option> <option value="mark-cancelled"><?php _e('Revoke Access', 'rcp'); ?> </option> <option value="delete"><?php _e('Delete', 'rcp'); ?> </option> </select> <input type="text" class="rcp-datepicker" name="expiration" placeholder="<?php esc_attr_e('New Expiration Date', 'rcp'); ?> " id="rcp-bulk-expiration" value=""/> <input type="submit" id="rcp-submit-bulk-action" class="button action" value="<?php _e('Apply', 'rcp'); ?> "/> </div> <?php echo wp_nonce_field('rcp_bulk_edit_nonce', 'rcp_bulk_edit_nonce'); ?> <table class="wp-list-table widefat fixed posts"> <thead> <tr> <th class="rcp-checkbox-col"><input type="checkbox" id="rcp-bulk-select-all"/></th> <th class="rcp-user-col"><?php _e('User', 'rcp'); ?> </th> <th class="rcp-id-col"><?php _e('ID', 'rcp'); ?> </th> <th class="rcp-email-col"><?php _e('Email', 'rcp'); ?> </th> <th class="rcp-sub-col"><?php _e('Subscription', 'rcp'); ?> </th> <th class="rcp-status-col"><?php _e('Status', 'rcp'); ?> </th> <th class="rcp-recurring-col"><?php _e('Recurring', 'rcp'); ?> </th> <th class="rcp-expiration-col"><?php _e('Expiration', 'rcp'); ?> </th> <th class="rcp-role-col"><?php _e('User Role', 'rcp'); ?> </th> <?php do_action('rcp_members_page_table_header'); ?> <th class="rcp-actions-role"><?php _e('Actions', 'rcp'); ?> </th> </tr> </thead> <tfoot> <tr> <th class="rcp-checkbox-col"></th> <th><?php _e('User', 'rcp'); ?> </th> <th><?php _e('ID', 'rcp'); ?> </th> <th><?php _e('Email', 'rcp'); ?> </th> <th><?php _e('Subscription', 'rcp'); ?> </th> <th><?php _e('Status', 'rcp'); ?> </th> <th><?php _e('Recurring', 'rcp'); ?> </th> <th><?php _e('Expiration', 'rcp'); ?> </th> <th><?php _e('User Role', 'rcp'); ?> </th> <?php do_action('rcp_members_page_table_footer'); ?> <th><?php _e('Actions', 'rcp'); ?> </th> </tr> </tfoot> <tbody> <?php if (isset($_GET['signup_method'])) { $method = $_GET['signup_method'] == 'live' ? 'live' : 'manual'; $members = get_users(array('meta_key' => 'rcp_signup_method', 'meta_value' => $method, 'number' => 999999)); $per_page = 999999; } else { $members = rcp_get_members($status, $subscription_id, $offset, $per_page, $order, $recurring, $search); } if ($members) { $i = 1; foreach ($members as $key => $member) { ?> <tr class="rcp_row <?php do_action('rcp_member_row_class', $member); if (rcp_is_odd($i)) { echo ' alternate'; } ?> "> <td> <input type="checkbox" class="rcp-member-cb" name="member-ids[]" value="<?php echo absint($member->ID); ?> "/> </td> <td><a href="<?php echo add_query_arg('user_id', $member->ID, admin_url('user-edit.php')); ?> " title="<?php _e('View User\'s Profile', 'rcp'); ?> "><?php echo $member->user_login; ?> </a></td> <td><?php echo $member->ID; ?> </td> <td><?php echo $member->user_email; ?> </td> <td><?php echo rcp_get_subscription($member->ID); ?> </td> <td><?php echo rcp_print_status($member->ID, false); ?> </td> <td><?php echo rcp_is_recurring($member->ID) ? __('yes', 'rcp') : __('no', 'rcp'); ?> <td><?php echo rcp_get_expiration_date($member->ID); ?> </td> <td><?php echo rcp_get_user_role($member->ID); ?> </td> <?php do_action('rcp_members_page_table_column', $member->ID); ?> <td> <?php if (current_user_can('rcp_manage_members')) { ?> <a href="<?php echo esc_url(add_query_arg('edit_member', $member->ID, $current_page)); ?> "><?php _e('Edit', 'rcp'); ?> </a> <?php if (isset($_GET['status']) && $_GET['status'] == 'cancelled') { ?> | <a href="<?php echo esc_url(add_query_arg('activate_member', $member->ID, $current_page)); ?> " class="rcp_activate"><?php _e('Enable Access', 'rcp'); ?> </a> <?php } elseif (isset($_GET['status']) && $_GET['status'] == 'active' || !isset($_GET['status'])) { ?> | <a href="<?php echo esc_url(add_query_arg('revoke_access', $member->ID, $current_page)); ?> " class="rcp_revoke"><?php _e('Revoke Access', 'rcp'); ?> </a> <?php } ?> <?php if (rcp_can_member_cancel($member->ID)) { ?> | <a href="<?php echo wp_nonce_url(add_query_arg('cancel_member', $member->ID, $current_page), 'rcp-cancel-nonce'); ?> " class="rcp_cancel"><?php _e('Cancel', 'rcp'); ?> </a> <?php } ?> <?php if ($switch_to_url = rcp_get_switch_to_url($member->ID)) { ?> | <a href="<?php echo esc_url($switch_to_url); ?> " class="rcp_switch"><?php _e('Switch to User', 'rcp'); ?> </a> <?php } ?> <?php do_action('rcp_member_row_actions', $member->ID); ?> <?php } ?> </td> </tr> <?php $i++; } } else { ?> <tr><td colspan="9"><?php _e('No subscribers found', 'rcp'); ?> </td></tr> <?php } ?> </table> </form> <?php if ($total_pages > 1 && !isset($_GET['signup_method'])) { ?> <div class="tablenav"> <div class="tablenav-pages alignright"> <?php $query_string = $_SERVER['QUERY_STRING']; $base = 'admin.php?' . remove_query_arg('p', $query_string) . '%_%'; echo paginate_links(array('base' => $base, 'format' => '&p=%#%', 'prev_text' => __('« Previous'), 'next_text' => __('Next »'), 'total' => $total_pages, 'current' => $page, 'end_size' => 1, 'mid_size' => 5)); ?> </div> </div><!--end .tablenav--> <?php } ?> <?php do_action('rcp_members_below_table'); ?> <h3><?php _e('Add New Subscription (for existing user)', 'rcp'); ?> </h3> <form id="rcp-add-new-member" action="" method="post"> <table class="form-table"> <tbody> <tr class="form-field"> <th scope="row" valign="top"> <label for="rcp-username"><?php _e('Username', 'rcp'); ?> </label> </th> <td> <input type="text" name="user" id="rcp-user" autocomplete="off" class="regular-text rcp-user-search" style="width: 120px;"/> <img class="rcp-ajax waiting" src="<?php echo admin_url('images/wpspin_light.gif'); ?> " style="display: none;"/> <div id="rcp_user_search_results"></div> <p class="description"><?php _e('Begin typing the user name to add a subscription to.', 'rcp'); ?> </p> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <label for="rcp-level"><?php _e('Subscription Level', 'rcp'); ?> </label> </th> <td> <select name="level" id="rcp-level"> <option value="choose"><?php _e('--choose--', 'rcp'); ?> </option> <?php foreach (rcp_get_subscription_levels() as $level) { echo '<option value="' . $level->id . '">' . $level->name . '</option>'; } ?> </select> <p class="description"><?php _e('Choose the subscription level for this user', 'rcp'); ?> </p> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <label for="rcp-expiration"><?php _e('Expiration date', 'rcp'); ?> </label> </th> <td> <input name="expiration" id="rcp-expiration" type="text" style="width: 120px;" class="rcp-datepicker"/> <label for="rcp-unlimited"> <input name="unlimited" id="rcp-unlimited" type="checkbox"/> <span class="description"><?php _e('Never expires?', 'rcp'); ?> </span> </label> <p class="description"><?php _e('Enter the expiration date for this user in the format of yyyy-mm-dd', 'rcp'); ?> </p> </td> </tr> </tbody> </table> <p class="submit"> <input type="hidden" name="rcp-action" value="add-subscription"/> <input type="submit" value="<?php _e('Add User Subscription', 'rcp'); ?> " class="button-primary"/> </p> </form> <?php } ?> </div><!--end wrap--> <?php }
function rcp_discounts_page() { global $rcp_options, $rcp_discounts_db_name, $wpdb; $page = admin_url('/admin.php?page=rcp-discounts'); ?> <div class="wrap"> <?php if (isset($_GET['edit_discount'])) { include 'edit-discount.php'; } else { ?> <h2><?php _e('Discount Codes', 'rcp'); ?> </h2> <table class="wp-list-table widefat fixed posts"> <thead> <tr> <th class="rcp-discounts-id-col"><?php _e('ID', 'rcp'); ?> </th> <th class="rcp-discounts-name-col" ><?php _e('Name', 'rcp'); ?> </th> <th class="rcp-discounts-desc-col"><?php _e('Description', 'rcp'); ?> </th> <th class="rcp-discounts-code-col" ><?php _e('Code', 'rcp'); ?> </th> <th class="rcp-discounts-subscription-col" ><?php _e('Subscription', 'rcp'); ?> </th> <th class="rcp-discounts-amount-col"><?php _e('Amount', 'rcp'); ?> </th> <th class="rcp-discounts-type-col"><?php _e('Type', 'rcp'); ?> </th> <th class="rcp-discounts-status-col"><?php _e('Status', 'rcp'); ?> </th> <th class="rcp-discounts-uses-col"><?php _e('Uses', 'rcp'); ?> </th> <th class="rcp-discounts-uses-left-col"><?php _e('Uses Left', 'rcp'); ?> </th> <th class="rcp-discounts-expir-col" ><?php _e('Expiration', 'rcp'); ?> </th> <?php do_action('rcp_discounts_page_table_header'); ?> <th class="rcp-discounts-actions-col" ><?php _e('Actions', 'rcp'); ?> </th> </tr> </thead> <tfoot> <tr> <th><?php _e('ID', 'rcp'); ?> </th> <th><?php _e('Name', 'rcp'); ?> </th> <th><?php _e('Description', 'rcp'); ?> </th> <th><?php _e('Code', 'rcp'); ?> </th> <th><?php _e('Subscription', 'rcp'); ?> </th> <th><?php _e('Amount', 'rcp'); ?> </th> <th><?php _e('Type', 'rcp'); ?> </th> <th><?php _e('Status', 'rcp'); ?> </th> <th><?php _e('Uses', 'rcp'); ?> </th> <th><?php _e('Uses Left', 'rcp'); ?> </th> <th><?php _e('Expiration', 'rcp'); ?> </th> <?php do_action('rcp_discounts_page_table_header'); ?> <?php if (current_user_can('rcp_manage_discounts')) { ?> <th><?php _e('Actions', 'rcp'); ?> </th> <?php } ?> </tr> </tfoot> <tbody> <?php $codes = rcp_get_discounts(); ?> <?php if ($codes) { $i = 1; foreach ($codes as $key => $code) { ?> <tr class="rcp_row <?php if (rcp_is_odd($i)) { echo 'alternate'; } ?> "> <td><?php echo $code->id; ?> </td> <td><?php echo stripslashes($code->name); ?> </td> <td><?php echo stripslashes($code->description); ?> </td> <td><?php echo $code->code; ?> </td> <td> <?php if ($code->subscription_id > 0) { echo rcp_get_subscription_name($code->subscription_id); } else { echo __('All Levels', 'rcp'); } ?> </td> <td><?php echo rcp_discount_sign_filter($code->amount, $code->unit); ?> </td> <td><?php echo $code->unit == '%' ? __('Percentage', 'rcp') : __('Flat', 'rcp'); ?> </td> <td> <?php if (rcp_is_discount_not_expired($code->id)) { echo rcp_get_discount_status($code->id) == 'active' ? __('active', 'rcp') : __('disabled', 'rcp'); } else { _e('expired', 'rcp'); } ?> </td> <td><?php if ($code->max_uses > 0) { echo rcp_count_discount_code_uses($code->code) . '/' . $code->max_uses; } else { echo rcp_count_discount_code_uses($code->code); } ?> </td> <td><?php echo rcp_discount_has_uses_left($code->id) ? 'yes' : 'no'; ?> </td> <td><?php echo $code->expiration == '' ? __('none', 'rcp') : date_i18n('Y-m-d', strtotime($code->expiration)); ?> </td> <?php do_action('rcp_discounts_page_table_column', $code->id); ?> <?php if (current_user_can('rcp_manage_discounts')) { ?> <td> <a href="<?php echo add_query_arg('edit_discount', $code->id, $page); ?> "><?php _e('Edit', 'rcp'); ?> </a> | <?php if (rcp_get_discount_status($code->id) == 'active') { ?> <a href="<?php echo add_query_arg('deactivate_discount', $code->id, $page); ?> "><?php _e('Deactivate', 'rcp'); ?> </a> | <?php } else { ?> <a href="<?php echo add_query_arg('activate_discount', $code->id, $page); ?> "><?php _e('Activate', 'rcp'); ?> </a> | <?php } ?> <a href="<?php echo add_query_arg('delete_discount', $code->id, $page); ?> " class="rcp_delete_discount"><?php _e('Delete', 'rcp'); ?> </a> </td> <?php } ?> </tr> <?php $i++; } } else { ?> <tr><td colspan="11"><?php _e('No discount codes added yet.', 'rcp'); ?> </td> <?php } ?> </table> <?php do_action('rcp_discounts_below_table'); ?> <?php if (current_user_can('rcp_manage_levels')) { ?> <h3><?php _e('Add New Discount', 'rcp'); ?> </h3> <form id="rcp-discounts" action="" method="POST"> <table class="form-table"> <tbody> <tr class="form-field"> <th scope="row" valign="top"> <label for="rcp-name"><?php _e('Name', 'rcp'); ?> </label> </th> <td> <input name="name" id="rcp-name" type="text" value="" style="width: 300px;"/> <p class="description"><?php _e('The name of this discount', 'rcp'); ?> </p> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <label for="rcp-description"><?php _e('Description', 'rcp'); ?> </label> </th> <td> <textarea name="description" id="rcp-description" style="width: 300px;"></textarea> <p class="description"><?php _e('The description of this discount code', 'rcp'); ?> </p> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <label for="rcp-code"><?php _e('Code', 'rcp'); ?> </label> </th> <td> <input type="text" id="rcp-code" name="code" value="" style="width: 300px;"/> <p class="description"><?php _e('Enter a code for this discount, such as 10PERCENT', 'rcp'); ?> </p> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <label for="rcp-unit"><?php _e('Type', 'rcp'); ?> </label> </th> <td> <select name="unit" id="rcp-duration-unit"> <option value="%"><?php _e('Percentage', 'rcp'); ?> </option> <option value="flat"><?php _e('Flat amount', 'rcp'); ?> </option> </select> <p class="description"><?php _e('The kind of discount to apply for this discount.', 'rcp'); ?> </p> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <label for="rcp-amount"><?php _e('Amount', 'rcp'); ?> </label> </th> <td> <input type="text" id="rcp-amount" name="amount" value="" style="width: 40px;"/> <p class="description"><?php _e('The amount of this discount code.', 'rcp'); ?> </p> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <label for="rcp-subscription"><?php _e('Subscription', 'rcp'); ?> </label> </th> <td> <?php $levels = rcp_get_subscription_levels('all', false); if ($levels) { ?> <select name="subscription" id="rcp-subscription"> <option value="0"><?php _e('All Levels', 'rcp'); ?> </option> <?php foreach ($levels as $level) { echo '<option value="' . $level->id . '">' . $level->name . '</option>'; } ?> </select> <?php } ?> <p class="description"><?php _e('The subscription levels this discount code can be used for.', 'rcp'); ?> </p> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <label for="rcp-expiration"><?php _e('Expiration date', 'rcp'); ?> </label> </th> <td> <input name="expiration" id="rcp-expiration" type="text" style="width: 120px;" class="rcp-datepicker"/> <p class="description"><?php _e('Enter the expiration date for this discount code in the format of yyyy-mm-dd. For no expiration, leave blank', 'rcp'); ?> </p> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <label for="rcp-max-uses"><?php _e('Max Uses', 'rcp'); ?> </label> </th> <td> <input type="text" id="rcp-max-uses" name="max" value="" style="width: 40px;"/> <p class="description"><?php _e('The maximum number of times this discount can be used. Leave blank for unlimited.', 'rcp'); ?> </p> </td> </tr> <?php do_action('rcp_add_discount_form'); ?> </tbody> </table> <p class="submit"> <input type="hidden" name="rcp-action" value="add-discount"/> <input type="submit" value="<?php _e('Add Discount Code', 'rcp'); ?> " class="button-primary"/> </p> </form> <?php } ?> <?php } ?> </div><!--end wrap--> <?php }
/** * Renders the Restrict > Payments page * * @since 1.0 * @return void */ function rcp_payments_page() { global $rcp_options; $current_page = admin_url('/admin.php?page=rcp-payments'); ?> <div class="wrap"> <?php if (isset($_GET['view']) && 'new-payment' == $_GET['view']) { include 'new-payment.php'; } elseif (isset($_GET['view']) && 'edit-payment' == $_GET['view']) { include 'edit-payment.php'; } else { ?> <h2> <?php _e('Payments', 'rcp'); ?> <a href="<?php echo admin_url('/admin.php?page=rcp-payments&view=new-payment'); ?> " class="add-new-h2"> <?php _e('Create Payment', 'rcp'); ?> </a> </h2> <?php do_action('rcp_payments_page_top'); $rcp_payments = new RCP_Payments(); $page = isset($_GET['p']) ? $_GET['p'] : 1; $per_page = 20; $search = !empty($_GET['s']) ? urldecode($_GET['s']) : ''; $user = get_current_user_id(); $screen = get_current_screen(); $screen_option = $screen->get_option('per_page', 'option'); $per_page = get_user_meta($user, $screen_option, true); if (empty($per_page) || $per_page < 1) { $per_page = $screen->get_option('per_page', 'default'); } $total_pages = 1; $offset = $per_page * ($page - 1); $user_id = isset($_GET['user_id']) ? $_GET['user_id'] : 0; $payments = $rcp_payments->get_payments(array('offset' => $offset, 'number' => $per_page, 'user_id' => $user_id, 's' => $search)); $payment_count = $rcp_payments->count(array('user_id' => $user_id)); $total_pages = ceil($payment_count / $per_page); ?> <form id="rcp-member-search" method="get" action="<?php menu_page_url('rcp-payments'); ?> "> <label class="screen-reader-text" for="rcp-member-search-input"><?php _e('Search Payments', 'rcp'); ?> </label> <input type="search" id="rcp-member-search-input" name="s" value="<?php echo esc_attr($search); ?> "/> <input type="hidden" name="page" value="rcp-payments"/> <input type="submit" name="" id="rcp-member-search-submit" class="button" value="<?php _e('Search Payments', 'rcp'); ?> "/> </form> <p class="total"><strong><?php _e('Total Earnings', 'rcp'); ?> : <?php echo rcp_currency_filter(number_format_i18n($rcp_payments->get_earnings(), 2)); ?> </strong></p> <?php if (!empty($user_id)) { ?> <p><a href="<?php echo admin_url('admin.php?page=rcp-payments'); ?> " class="button-secondary" title="<?php _e('View all payments', 'rcp'); ?> "><?php _e('Reset User Filter', 'rcp'); ?> </a></p> <?php } ?> <table class="wp-list-table widefat fixed posts rcp-payments"> <thead> <tr> <th style="width: 40px;"><?php _e('ID', 'rcp'); ?> </th> <th style="width: 90px;"><?php _e('User', 'rcp'); ?> </th> <th style="width: 150px;"><?php _e('Subscription', 'rcp'); ?> </th> <th><?php _e('Date', 'rcp'); ?> </th> <th style="width: 90px;"><?php _e('Amount', 'rcp'); ?> </th> <th><?php _e('Type', 'rcp'); ?> </th> <th><?php _e('Transaction ID', 'rcp'); ?> </th> <th><?php _e('Status', 'rcp'); ?> </th> <?php do_action('rcp_payments_page_table_header'); ?> <?php if (current_user_can('rcp_manage_payments')) { ?> <th><?php _e('Actions', 'rcp'); ?> </th> <?php } ?> </tr> </thead> <tfoot> <tr> <th style="width: 40px;"><?php _e('ID', 'rcp'); ?> </th> <th><?php _e('User', 'rcp'); ?> </th> <th><?php _e('Subscription', 'rcp'); ?> </th> <th><?php _e('Date', 'rcp'); ?> </th> <th><?php _e('Amount', 'rcp'); ?> </th> <th><?php _e('Type', 'rcp'); ?> </th> <th><?php _e('Transaction ID', 'rcp'); ?> </th> <th><?php _e('Status', 'rcp'); ?> </th> <?php do_action('rcp_payments_page_table_footer'); ?> <?php if (current_user_can('rcp_manage_payments')) { ?> <th><?php _e('Actions', 'rcp'); ?> </th> <?php } ?> </tr> </tfoot> <tbody> <?php if ($payments) { $i = 0; $total_earnings = 0; foreach ($payments as $payment) { $user = get_userdata($payment->user_id); ?> <tr class="rcp_payment <?php if (rcp_is_odd($i)) { echo 'alternate'; } ?> "> <td><?php echo absint($payment->id); ?> </td> <td> <a href="<?php echo esc_url(add_query_arg('user_id', $payment->user_id, menu_page_url('rcp-payments', false))); ?> " title="<?php _e('View payments by this user', 'rcp'); ?> "> <?php echo isset($user->display_name) ? esc_html($user->display_name) : ''; ?> </a> </td> <td><?php echo esc_html($payment->subscription); ?> </td> <td><?php echo esc_html($payment->date); ?> </td> <td><?php echo rcp_currency_filter($payment->amount); ?> </td> <td><?php echo esc_html($payment->payment_type); ?> </td> <td><?php echo $payment->transaction_id; ?> </td> <td><?php echo rcp_get_payment_status_label($payment); ?> </td> <?php do_action('rcp_payments_page_table_column', $payment->id); ?> <?php if (current_user_can('rcp_manage_payments')) { ?> <td> <a href="<?php echo rcp_get_pdf_download_url($payment->id); ?> " class="rcp-payment-invoice"><?php _e('Download Invoice', 'rcp'); ?> </a> <span> | </span> <a href="<?php echo esc_url(add_query_arg(array('payment_id' => $payment->id, 'view' => 'edit-payment'), admin_url('admin.php?page=rcp-payments'))); ?> " class="rcp-edit-payment"><?php _e('Edit', 'rcp'); ?> </a> <span> | </span> <a href="<?php echo wp_nonce_url(add_query_arg(array('payment_id' => $payment->id, 'rcp-action' => 'delete_payment'), admin_url('admin.php?page=rcp-payments')), 'rcp_delete_payment_nonce'); ?> " class="rcp-delete-payment"><?php _e('Delete', 'rcp'); ?> </a> </td> <?php } ?> </tr> <?php $i++; $total_earnings = $total_earnings + $payment->amount; } } else { ?> <tr><td colspan="8"><?php _e('No payments recorded yet', 'rcp'); ?> </td></tr> <?php } ?> </table> <?php if ($total_pages > 1) { ?> <div class="tablenav"> <div class="tablenav-pages alignright"> <?php $base = 'admin.php?' . remove_query_arg('p', $_SERVER['QUERY_STRING']) . '%_%'; echo paginate_links(array('base' => $base, 'format' => '&p=%#%', 'prev_text' => __('« Previous'), 'next_text' => __('Next »'), 'total' => $total_pages, 'current' => $page, 'end_size' => 1, 'mid_size' => 5)); ?> </div> </div><!--end .tablenav--> <?php } ?> <?php do_action('rcp_payments_page_bottom'); ?> <?php } ?> </div><!--end wrap--> <?php }
function rcp_member_levels_page() { global $rcp_options, $rcp_db_name, $wpdb; $page = admin_url('/admin.php?page=rcp-member-levels'); ?> <div class="wrap"> <?php if (isset($_GET['edit_subscription'])) { include 'edit-subscription.php'; } else { ?> <h2><?php _e('Subscription Levels', 'rcp'); ?> </h2> <table class="wp-list-table widefat fixed posts rcp-subscriptions"> <thead> <tr> <th scope="col" class="rcp-sub-name-col column-primary"><?php _e('Name', 'rcp'); ?> </th> <th scope="col" class="rcp-sub-desc-col"><?php _e('Description', 'rcp'); ?> </th> <th scope="col" class="rcp-sub-level-col"><?php _e('Access Level', 'rcp'); ?> </th> <th scope="col" class="rcp-sub-duration-col"><?php _e('Duration', 'rcp'); ?> </th> <th scope="col" class="rcp-sub-price-col"><?php _e('Price', 'rcp'); ?> </th> <th scope="col" class="rcp-sub-subs-col"><?php _e('Subscribers', 'rcp'); ?> </th> <?php do_action('rcp_levels_page_table_header'); ?> <th scope="col" class="rcp-sub-order-col"><?php _e('Order', 'rcp'); ?> </th> </tr> </thead> <tbody id="the-list"> <?php $levels = rcp_get_subscription_levels('all'); ?> <?php if ($levels) { $i = 1; foreach ($levels as $key => $level) { ?> <tr id="recordsArray_<?php echo $level->id; ?> " class="rcp-subscription rcp_row <?php if (rcp_is_odd($i)) { echo 'alternate'; } ?> "> <td class="rcp-sub-name-col column-primary has-row-actions" data-colname="<?php _e('Name', 'rcp'); ?> "> <strong><a href="<?php echo esc_url(add_query_arg('edit_subscription', $level->id, $page)); ?> "><?php echo stripslashes($level->name); ?> </a></strong> <?php if (current_user_can('rcp_manage_levels')) { ?> <div class="row-actions"> <span class="rcp-sub-id-col" data-colname="<?php _e('ID:', 'rcp'); ?> "> <?php echo __('ID:', 'rcp') . ' ' . $level->id; ?> | </span> <a href="<?php echo esc_url(add_query_arg('edit_subscription', $level->id, $page)); ?> "><?php _e('Edit', 'rcp'); ?> </a> | <?php if ($level->status != 'inactive') { ?> <a href="<?php echo esc_url(add_query_arg('deactivate_subscription', $level->id, $page)); ?> "><?php _e('Deactivate', 'rcp'); ?> </a> | <?php } else { ?> <a href="<?php echo esc_url(add_query_arg('activate_subscription', $level->id, $page)); ?> "><?php _e('Activate', 'rcp'); ?> </a> | <?php } ?> <a href="<?php echo esc_url(add_query_arg('delete_subscription', $level->id, $page)); ?> " class="rcp_delete_subscription"><?php _e('Delete', 'rcp'); ?> </a> </div> <?php } ?> <button type="button" class="toggle-row"><span class="screen-reader-text"><?php _e('Show more details', 'rcp'); ?> </span></button> </td> <td class="rcp-sub-desc-col" data-colname="<?php _e('Description', 'rcp'); ?> "><?php echo stripslashes($level->description); ?> </td> <td class="rcp-sub-level-col" data-colname="<?php _e('Access Level', 'rcp'); ?> "><?php echo $level->level != '' ? $level->level : __('none', 'rcp'); ?> </td> <td class="rcp-sub-duration-col" data-colname="<?php _e('Duration', 'rcp'); ?> "> <?php if ($level->duration > 0) { echo $level->duration . ' ' . rcp_filter_duration_unit($level->duration_unit, $level->duration); } else { echo __('unlimited', 'rcp'); } ?> </td> <td class="rcp-sub-price-col" data-colname="<?php _e('Price', 'rcp'); ?> "> <?php $price = rcp_get_subscription_price($level->id); if (!$price) { echo __('Free', 'rcp'); } else { echo rcp_currency_filter($price); } ?> </td> <td class="rcp-sub-subs-col" data-colname="<?php _e('Subscribers', 'rcp'); ?> "> <?php if ($price || $level->duration > 0) { echo rcp_get_subscription_member_count($level->id, 'active'); } else { echo rcp_get_subscription_member_count($level->id, 'free'); } ?> </td> <?php do_action('rcp_levels_page_table_column', $level->id); ?> <td class="rcp-sub-order-col"><a href="#" class="dragHandle"></a></td> </tr> <?php $i++; } } else { ?> <tr><td colspan="9"><?php _e('No subscription levels added yet.', 'rcp'); ?> </td></tr> <?php } ?> </tbody> <tfoot> <tr> <th scope="col" class="rcp-sub-name-col column-primary"><?php _e('Name', 'rcp'); ?> </th> <th scope="col" class="rcp-sub-desc-col"><?php _e('Description', 'rcp'); ?> </th> <th scope="col" class="rcp-sub-level-col"><?php _e('Access Level', 'rcp'); ?> </th> <th scope="col" class="rcp-sub-duration-col"><?php _e('Duration', 'rcp'); ?> </th> <th scope="col" class="rcp-sub-price-col"><?php _e('Price', 'rcp'); ?> </th> <th scope="col" class="rcp-sub-subs-col"><?php _e('Subscribers', 'rcp'); ?> </th> <?php do_action('rcp_levels_page_table_footer'); ?> <th scope="col" class="rcp-sub-order-col"><?php _e('Order', 'rcp'); ?> </th> </tr> </tfoot> </table> <?php do_action('rcp_levels_below_table'); ?> <?php if (current_user_can('rcp_manage_levels')) { ?> <h3><?php _e('Add New Level', 'rcp'); ?> </h3> <form id="rcp-member-levels" action="" method="post"> <table class="form-table"> <tbody> <tr class="form-field"> <th scope="row" valign="top"> <label for="rcp-name"><?php _e('Name', 'rcp'); ?> </label> </th> <td> <input type="text" id="rcp-name" name="name" value="" style="width: 300px;"/> <p class="description"><?php _e('The name of the membership level.', 'rcp'); ?> </p> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <label for="rcp-description"><?php _e('Description', 'rcp'); ?> </label> </th> <td> <textarea id="rcp-description" name="description" style="width: 300px;"></textarea> <p class="description"><?php _e('Membership level description. This is shown on the registration form.', 'rcp'); ?> </p> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <label for="rcp-level"><?php _e('Access Level', 'rcp'); ?> </label> </th> <td> <select id="rcp-level" name="level"> <?php $access_levels = rcp_get_access_levels(); foreach ($access_levels as $access) { echo '<option value="' . $access . '">' . $access . '</option>'; } ?> </select> <p class="description"> <?php _e('Level of access this subscription gives. Leave None for default or you are unsure what this is.', 'rcp'); ?> <span alt="f223" class="rcp-help-tip dashicons dashicons-editor-help" title="<?php _e('<strong>Access Level</strong>: refers to a tiered system where a member\'s ability to view content is determined by the access level assigned to their account. A member with an access level of 5 can view content assigned to access levels of 5 and lower, whereas a member with an access level of 4 can only view content assigned to levels of 4 and lower.', 'rcp'); ?> "></span> </p> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <label for="rcp-duration"><?php _e('Duration', 'rcp'); ?> </label> </th> <td> <input type="text" id="rcp-duration" style="width: 40px;" name="duration" value="0"/> <select name="duration_unit" id="rcp-duration-unit"> <option value="day"><?php _e('Day(s)', 'rcp'); ?> </option> <option value="month"><?php _e('Month(s)', 'rcp'); ?> </option> <option value="year"><?php _e('Year(s)', 'rcp'); ?> </option> </select> <p class="description"> <?php _e('Length of time for this membership level. Enter 0 for unlimited.', 'rcp'); ?> <span alt="f223" class="rcp-help-tip dashicons dashicons-editor-help" title="<?php _e('<strong>Example</strong>: setting this to 1 month would make memberships last 1 month, after which they will renew automatically or be marked as expired.', 'rcp'); ?> "></span> </p> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <label for="rcp-price"><?php _e('Price', 'rcp'); ?> </label> </th> <td> <input type="text" id="rcp-price" name="price" value="0" pattern="^(\d+\.\d{2})|(\d+)$" style="width: 40px;"/> <select name="rcp-price-select" id="rcp-price-select"> <option value="normal"><?php echo rcp_get_currency(); ?> </option> <option value="free"><?php _e('Free', 'rcp'); ?> </option> </select> <p class="description"> <?php _e('The price of this membership level. Enter 0 for free.', 'rcp'); ?> <span alt="f223" class="rcp-help-tip dashicons dashicons-editor-help" title="<?php _e('This price refers to the amount paid per duration period. For example, if duration period is set to 1 month, this would be the amount charged each month.', 'rcp'); ?> "></span> </p> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <label for="rcp-fee"><?php _e('Signup Fee', 'rcp'); ?> </label> </th> <td> <input type="text" id="rcp-fee" name="fee" value="0" style="width: 40px;"/> <p class="description"><?php _e('Optional signup fee to charge subscribers for the first billing cycle. Enter a negative number to give a discount on the first payment.', 'rcp'); ?> </p> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <label for="rcp-status"><?php _e('Status', 'rcp'); ?> </label> </th> <td> <select name="status" id="rcp-status"> <option value="active"><?php _e('Active', 'rcp'); ?> </option> <option value="inactive"><?php _e('Inactive', 'rcp'); ?> </option> </select> <p class="description"><?php _e('Members may only sign up for active subscription levels.', 'rcp'); ?> </p> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <label for="rcp-role"><?php _e('User Role', 'rcp'); ?> </label> </th> <td> <select name="role" id="rcp-role"> <?php wp_dropdown_roles('subscriber'); ?> </select> <p class="description"><?php _e('The user role given to the member after signing up.', 'rcp'); ?> </p> </td> </tr> <?php do_action('rcp_add_subscription_form'); ?> </tbody> </table> <p class="submit"> <input type="hidden" name="rcp-action" value="add-level"/> <input type="submit" value="<?php _e('Add Membership Level', 'rcp'); ?> " class="button-primary"/> </p> <?php wp_nonce_field('rcp_add_level_nonce', 'rcp_add_level_nonce'); ?> </form> <?php } ?> <?php } ?> </div><!--end wrap--> <?php }
function rcp_member_levels_page() { global $rcp_options, $rcp_db_name, $wpdb; $page = admin_url('/admin.php?page=rcp-member-levels'); ?> <div class="wrap"> <?php if (isset($_GET['edit_subscription'])) { include 'edit-subscription.php'; } else { ?> <h2><?php _e('Subscription Levels', 'rcp'); ?> </h2> <table class="wp-list-table widefat fixed posts rcp-subscriptions"> <thead> <tr> <th class="rcp-sub-order-col"><?php _e('Order', 'rcp'); ?> </th> <th class="rcp-sub-id-col"><?php _e('ID', 'rcp'); ?> </th> <th class="rcp-sub-name-col"><?php _e('Name', 'rcp'); ?> </th> <th class="rcp-sub-desc-col"><?php _e('Description', 'rcp'); ?> </th> <th class="rcp-sub-level-col"><?php _e('Access Level', 'rcp'); ?> </th> <th class="rcp-sub-duration-col"><?php _e('Duration', 'rcp'); ?> </th> <th class="rcp-sub-price-col"><?php _e('Price', 'rcp'); ?> </th> <th class="rcp-sub-subs-col"><?php _e('Subscribers', 'rcp'); ?> </th> <?php do_action('rcp_levels_page_table_header'); ?> <?php if (current_user_can('rcp_manage_levels')) { ?> <th class="rcp-sub-actions-col"><?php _e('Actions', 'rcp'); ?> </th> <?php } ?> </tr> </thead> <tfoot> <tr> <th class="rcp-sub-order-col"><?php _e('Order', 'rcp'); ?> </th> <th class="rcp-sub-id-col"><?php _e('ID', 'rcp'); ?> </th> <th class="rcp-sub-name-col"><?php _e('Name', 'rcp'); ?> </th> <th class="rcp-sub-desc-col" style="width: 300px;"><?php _e('Description', 'rcp'); ?> </th> <th class="rcp-sub-level-col"><?php _e('Access Level', 'rcp'); ?> </th> <th class="rcp-sub-duration-col"><?php _e('Duration', 'rcp'); ?> </th> <th class="rcp-sub-price-col"><?php _e('Price', 'rcp'); ?> </th> <th class="rcp-sub-subs-col"><?php _e('Subscribers', 'rcp'); ?> </th> <?php do_action('rcp_levels_page_table_footer'); ?> <?php if (current_user_can('rcp_manage_levels')) { ?> <th class="rcp-sub-actions-col"><?php _e('Actions', 'rcp'); ?> </th> <?php } ?> </tr> </tfoot> <tbody> <?php $levels = rcp_get_subscription_levels('all'); ?> <?php if ($levels) { $i = 1; foreach ($levels as $key => $level) { ?> <tr id="recordsArray_<?php echo $level->id; ?> " class="rcp-subscription rcp_row <?php if (rcp_is_odd($i)) { echo 'alternate'; } ?> "> <td class="rcp-sub-order-col"><a href="#" class="dragHandle"></a></td> <td class="rcp-sub-id-col"><?php echo $level->id; ?> </td> <td class="rcp-sub-name-col"><?php echo stripslashes($level->name); ?> </td> <td class="rcp-sub-desc-col"><?php echo stripslashes($level->description); ?> </td> <td class="rcp-sub-level-col"><?php echo $level->level != '' ? $level->level : __('none', 'rcp'); ?> </td> <td class="rcp-sub-duration-col"> <?php if ($level->duration > 0) { echo $level->duration . ' ' . rcp_filter_duration_unit($level->duration_unit, $level->duration); } else { echo __('unlimited', 'rcp'); } ?> </td> <td class="rcp-sub-price-col"> <?php $price = rcp_get_subscription_price($level->id); if (!$price) { echo __('Free', 'rcp'); } else { echo rcp_currency_filter($price); } ?> </td> <td class="rcp-sub-subs-col"> <?php if ($price || $level->duration > 0) { echo rcp_count_members($level->id, 'active'); } else { echo rcp_count_members($level->id, 'free'); } ?> </td> <?php do_action('rcp_levels_page_table_column', $level->id); ?> <?php if (current_user_can('rcp_manage_levels')) { ?> <td class="rcp-sub-actions-col"> <a href="<?php echo esc_url(add_query_arg('edit_subscription', $level->id, $page)); ?> "><?php _e('Edit', 'rcp'); ?> </a> | <?php if ($level->status != 'inactive') { ?> <a href="<?php echo esc_url(add_query_arg('deactivate_subscription', $level->id, $page)); ?> "><?php _e('Deactivate', 'rcp'); ?> </a> | <?php } else { ?> <a href="<?php echo esc_url(add_query_arg('activate_subscription', $level->id, $page)); ?> "><?php _e('Activate', 'rcp'); ?> </a> | <?php } ?> <a href="<?php echo esc_url(add_query_arg('delete_subscription', $level->id, $page)); ?> " class="rcp_delete_subscription"><?php _e('Delete', 'rcp'); ?> </a> </td> <?php } ?> </tr> <?php $i++; } } else { ?> <tr><td colspan="9"><?php _e('No subscription levels added yet.', 'rcp'); ?> </td> <?php } ?> </table> <?php do_action('rcp_levels_below_table'); ?> <?php if (current_user_can('rcp_manage_levels')) { ?> <h3><?php _e('Add New Level', 'rcp'); ?> </h3> <form id="rcp-member-levels" action="" method="post"> <table class="form-table"> <tbody> <tr class="form-field"> <th scope="row" valign="top"> <label for="rcp-name"><?php _e('Name', 'rcp'); ?> </label> </th> <td> <input type="text" id="rcp-name" name="name" value="" style="width: 300px;"/> <p class="description"><?php _e('The name of the membership level.', 'rcp'); ?> </p> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <label for="rcp-description"><?php _e('Description', 'rcp'); ?> </label> </th> <td> <textarea id="rcp-description" name="description" style="width: 300px;"></textarea> <p class="description"><?php _e('Membership level description. This is shown on the registration form.', 'rcp'); ?> </p> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <label for="rcp-level"><?php _e('Access Level', 'rcp'); ?> </label> </th> <td> <select id="rcp-level" name="level"> <?php $access_levels = rcp_get_access_levels(); foreach ($access_levels as $access) { echo '<option value="' . $access . '">' . $access . '</option>'; } ?> </select> <p class="description"><?php _e('Level of access this subscription gives. Leave None for default or you are unsure what this is.', 'rcp'); ?> </p> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <label for="rcp-duration"><?php _e('Duration', 'rcp'); ?> </label> </th> <td> <input type="text" id="rcp-duration" style="width: 40px;" name="duration" value=""/> <select name="duration_unit" id="rcp-duration-unit"> <option value="day"><?php _e('Day(s)', 'rcp'); ?> </option> <option value="month"><?php _e('Month(s)', 'rcp'); ?> </option> <option value="year"><?php _e('Year(s)', 'rcp'); ?> </option> </select> <p class="description"><?php _e('Length of time for this membership level. Enter 0 for unlimited.', 'rcp'); ?> </p> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <label for="rcp-price"><?php _e('Price', 'rcp'); ?> </label> </th> <td> <input type="text" id="rcp-price" name="price" value="" style="width: 40px;"/> <select name="rcp-price-select" id="rcp-price-select"> <option value="normal"><?php echo isset($rcp_options['currency']) ? $rcp_options['currency'] : 'USD'; ?> </option> <option value="free"><?php _e('Free', 'rcp'); ?> </option> </select> <p class="description"><?php _e('The price of this membership level. Enter 0 for free.', 'rcp'); ?> </p> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <label for="rcp-fee"><?php _e('Signup Fee', 'rcp'); ?> </label> </th> <td> <input type="text" id="rcp-fee" name="fee" value="" style="width: 40px;"/> <p class="description"><?php _e('Optional signup fee to charge subscribers for the first billing cycle. Enter a negative number to give a discount on the first payment. This only applies to recurring subscriptions.', 'rcp'); ?> </p> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <label for="rcp-status"><?php _e('Status', 'rcp'); ?> </label> </th> <td> <select name="status" id="rcp-status"> <option value="active"><?php _e('Active', 'rcp'); ?> </option> <option value="inactive"><?php _e('Inactive', 'rcp'); ?> </option> </select> <p class="description"><?php _e('Members may only sign up for active subscription levels.', 'rcp'); ?> </p> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <label for="rcp-role"><?php _e('User Role', 'rcp'); ?> </label> </th> <td> <select name="role" id="rcp-role"> <?php wp_dropdown_roles('subscriber'); ?> </select> <p class="description"><?php _e('The user role given to the member after signing up.', 'rcp'); ?> </p> </td> </tr> <?php do_action('rcp_add_subscription_form'); ?> </tbody> </table> <p class="submit"> <input type="hidden" name="rcp-action" value="add-level"/> <input type="submit" value="<?php _e('Add Membership Level', 'rcp'); ?> " class="button-primary"/> </p> </form> <?php } ?> <?php } ?> </div><!--end wrap--> <?php }
public function draw_page() { global $wpdb; $page = admin_url('/admin.php?page=rcp-gifts'); ?> <div class="wrap"> <?php // get all discounts ids $discounts_db = rcp_get_discounts_db_name(); $discount_ids = $wpdb->get_col("SELECT meta_value FROM {$wpdb->postmeta} WHERE meta_key = '_edd_rcp_gift_id';"); $discount_ids = implode(',', $discount_ids); $discounts = $wpdb->get_results("SELECT * FROM {$discounts_db} WHERE id IN (" . $discount_ids . ");"); ?> <h2><?php _e('Restrict Content Pro Gifts', 'rcp-gifts'); ?> </h2> <table class="wp-list-table widefat fixed posts"> <thead> <tr> <th class="rcp-discounts-id-col"><?php _e('ID', 'rcp-gifts'); ?> </th> <th class="rcp-discounts-name-col" ><?php _e('Name', 'rcp-gifts'); ?> </th> <th class="rcp-discounts-desc-col"><?php _e('Description', 'rcp-gifts'); ?> </th> <th class="rcp-discounts-code-col" ><?php _e('Code', 'rcp-gifts'); ?> </th> <th class="rcp-discounts-subscription-col" ><?php _e('Subscription', 'rcp-gifts'); ?> </th> <th class="rcp-discounts-amount-col"><?php _e('Amount', 'rcp-gifts'); ?> </th> <th class="rcp-discounts-type-col"><?php _e('Type', 'rcp-gifts'); ?> </th> <th class="rcp-discounts-status-col"><?php _e('Status', 'rcp-gifts'); ?> </th> <th class="rcp-discounts-uses-col"><?php _e('Uses', 'rcp-gifts'); ?> </th> <th class="rcp-discounts-uses-left-col"><?php _e('Uses Left', 'rcp-gifts'); ?> </th> <th class="rcp-discounts-expir-col" ><?php _e('Expiration', 'rcp-gifts'); ?> </th> <th class="rcp-discounts-actions-col" ><?php _e('Actions', 'rcp-gifts'); ?> </th> </tr> </thead> <tfoot> <tr> <th><?php _e('ID', 'rcp-gifts'); ?> </th> <th><?php _e('Name', 'rcp-gifts'); ?> </th> <th><?php _e('Description', 'rcp-gifts'); ?> </th> <th><?php _e('Code', 'rcp-gifts'); ?> </th> <th><?php _e('Subscription', 'rcp-gifts'); ?> </th> <th><?php _e('Amount', 'rcp-gifts'); ?> </th> <th><?php _e('Type', 'rcp-gifts'); ?> </th> <th><?php _e('Status', 'rcp-gifts'); ?> </th> <th><?php _e('Uses', 'rcp-gifts'); ?> </th> <th><?php _e('Uses Left', 'rcp-gifts'); ?> </th> <th><?php _e('Expiration', 'rcp-gifts'); ?> </th> <th><?php _e('Actions', 'rcp-gifts'); ?> </th> </tr> </tfoot> <tbody> <?php if ($discounts) { $i = 1; foreach ($discounts as $key => $discount) { ?> <tr class="rcp_row <?php if (rcp_is_odd($i)) { echo 'alternate'; } ?> "> <td><?php echo $discount->id; ?> </td> <td><?php echo stripslashes($discount->name); ?> </td> <td><?php echo stripslashes($discount->description); ?> </td> <td><?php echo $discount->code; ?> </td> <td> <?php if ($discount->subscription_id > 0) { echo rcp_get_subscription_name($discount->subscription_id); } else { echo __('All Levels', 'rcp-gifts'); } ?> </td> <td><?php echo rcp_discount_sign_filter($discount->amount, $discount->unit); ?> </td> <td><?php echo $discount->unit == '%' ? __('Percentage', 'rcp-gifts') : __('Flat', 'rcp-gifts'); ?> </td> <td> <?php if (rcp_is_discount_not_expired($discount->id)) { echo rcp_get_discount_status($discount->id) == 'active' ? __('active', 'rcp-gifts') : __('disabled', 'rcp-gifts'); } else { _e('expired', 'rcp-gifts'); } ?> </td> <td><?php if ($discount->max_uses > 0) { echo rcp_count_discount_code_uses($discount->code) . '/' . $discount->max_uses; } else { echo rcp_count_discount_code_uses($discount->code); } ?> </td> <td><?php echo rcp_discount_has_uses_left($discount->id) ? 'yes' : 'no'; ?> </td> <td><?php echo $discount->expiration == '' ? __('none', 'rcp-gifts') : date_i18n('Y-m-d', strtotime($discount->expiration)); ?> </td> <?php do_action('rcp_discounts_page_table_column', $discount->id); ?> <td> <?php if (rcp_get_discount_status($discount->id) == 'active') { ?> <a href="<?php echo add_query_arg('deactivate_discount', $discount->id, $page); ?> "><?php _e('Deactivate', 'rcp-gifts'); ?> </a> | <?php } else { ?> <a href="<?php echo add_query_arg('activate_discount', $discount->id, $page); ?> "><?php _e('Activate', 'rcp-gifts'); ?> </a> | <?php } ?> <a href="<?php echo add_query_arg('delete_discount', $discount->id, $page); ?> " class="rcp_delete_discount"><?php _e('Delete', 'rcp-gifts'); ?> </a> </td> </tr> <?php $i++; } } else { ?> <tr><td colspan="11"><?php _e('No discount codes added yet.', 'rcp-gifts'); ?> </td> <?php } ?> </table> </div> <?php }
function rcp_members_page() { global $rcp_options, $rcp_db_name, $wpdb; $current_page = admin_url('/admin.php?page=rcp-members'); ?> <div class="wrap" id="rcp-members-page"> <?php if (isset($_GET['edit_member']) || isset($_GET['view_member'])) { include 'edit-member.php'; } else { ?> <h2><?php _e(' Paid Subscribers', 'rcp'); ?> </h2> <?php $subscription_id = isset($_GET['subscription']) && $_GET['subscription'] != 'all' ? urldecode($_GET['subscription']) : null; $status = !empty($_GET['status']) ? urldecode($_GET['status']) : 'active'; $order = !empty($_GET['order']) ? urldecode($_GET['order']) : 'DESC'; $search = !empty($_GET['s']) ? urldecode($_GET['s']) : ''; $base_url = admin_url('admin.php?page=rcp-members'); if ($search) { $base_url = add_query_arg('s', $search, $base_url); } // Get subscriber count if (!empty($search) || !empty($subscription_id)) { // Query counts $active_count = rcp_count_members($subscription_id, 'active', null, $search); $pending_count = rcp_count_members($subscription_id, 'pending', null, $search); $expired_count = rcp_count_members($subscription_id, 'expired', null, $search); $cancelled_count = rcp_count_members($subscription_id, 'cancelled', null, $search); $free_count = rcp_count_members($subscription_id, 'free', null, $search); $current_count = rcp_count_members($subscription_id, $status, null, $search); } else { // Retrieve static counts $active_count = rcp_get_member_count('active'); $pending_count = rcp_get_member_count('pending'); $expired_count = rcp_get_member_count('expired'); $cancelled_count = rcp_get_member_count('cancelled'); $free_count = rcp_get_member_count('free'); $current_count = rcp_get_member_count($status); } // pagination variables $page = isset($_GET['p']) ? absint($_GET['p']) : 1; $user = get_current_user_id(); $screen = get_current_screen(); $screen_option = $screen->get_option('per_page', 'option'); $per_page = get_user_meta($user, $screen_option, true); if (empty($per_page) || $per_page < 1) { $per_page = $screen->get_option('per_page', 'default'); } $total_pages = 1; $offset = $per_page * ($page - 1); $total_pages = ceil($current_count / $per_page); ?> <ul class="subsubsub"> <li><?php _e('Status: ', 'rcp'); ?> </li> <li> <a href="<?php echo esc_url(add_query_arg('status', 'active', $base_url)); ?> " title="<?php _e('View all active subscribers', 'rcp'); ?> " <?php echo isset($_GET['status']) && $_GET['status'] == 'active' || !isset($_GET['status']) ? 'class="current"' : ''; ?> > <?php _e('Active', 'rcp'); ?> </a>(<?php echo $active_count; ?> ) </li> <li> <a href="<?php echo esc_url(add_query_arg('status', 'pending', $base_url)); ?> " title="<?php _e('View all pending subscribers', 'rcp'); ?> " <?php echo isset($_GET['status']) && $_GET['status'] == 'pending' ? 'class="current"' : ''; ?> > <?php _e('Pending', 'rcp'); ?> </a>(<?php echo $pending_count; ?> ) </li> <li> <a href="<?php echo esc_url(add_query_arg('status', 'expired', $base_url)); ?> " title="<?php _e('View all expired subscribers', 'rcp'); ?> " <?php echo isset($_GET['status']) && $_GET['status'] == 'expired' ? 'class="current"' : ''; ?> > <?php _e('Expired', 'rcp'); ?> </a>(<?php echo $expired_count; ?> ) </li> <li> <a href="<?php echo esc_url(add_query_arg('status', 'cancelled', $base_url)); ?> " title="<?php _e('View all cancelled subscribers', 'rcp'); ?> " <?php echo isset($_GET['status']) && $_GET['status'] == 'cancelled' ? 'class="current"' : ''; ?> > <?php _e('Cancelled', 'rcp'); ?> </a>(<?php echo $cancelled_count; ?> ) </li> <li> <a href="<?php echo esc_url(add_query_arg('status', 'free', $base_url)); ?> " title="<?php _e('View all free members', 'rcp'); ?> " <?php echo isset($_GET['status']) && $_GET['status'] == 'free' ? 'class="current"' : ''; ?> > <?php _e('Free', 'rcp'); ?> </a>(<?php echo $free_count; ?> ) </li> <?php do_action('rcp_members_page_statuses'); ?> </ul> <form id="rcp-member-search" method="get" action="<?php menu_page_url('rcp-members'); ?> "> <label class="screen-reader-text" for="rcp-member-search-input"><?php _e('Search Members', 'rcp'); ?> </label> <input type="search" id="rcp-member-search-input" name="s" value="<?php echo esc_attr($search); ?> "/> <input type="hidden" name="page" value="rcp-members"/> <input type="hidden" name="status" value="<?php echo esc_attr($status); ?> "/> <input type="submit" name="" id="rcp-member-search-submit" class="button" value="<?php _e('Search members', 'rcp'); ?> "/> </form> <form id="members-filter" action="" method="get"> <?php $levels = rcp_get_subscription_levels('all'); if ($levels) { ?> <select name="subscription" id="rcp-subscription"> <option value="all"><?php _e('All Subscriptions', 'rcp'); ?> </option> <?php foreach ($levels as $level) { echo '<option value="' . $level->id . '" ' . selected($subscription_id, $level->id, false) . '>' . $level->name . '</option>'; } ?> </select> <?php } ?> <select name="order" id="rcp-order"> <option value="DESC" <?php selected($order, 'DESC'); ?> ><?php _e('Newest First', 'rcp'); ?> </option> <option value="ASC" <?php selected($order, 'ASC'); ?> ><?php _e('Oldest First', 'rcp'); ?> </option> </select> <input type="hidden" name="page" value="rcp-members"/> <input type="hidden" name="status" value="<?php echo isset($_GET['status']) ? $_GET['status'] : 'active'; ?> "/> <input type="submit" class="button-secondary" value="<?php _e('Filter', 'rcp'); ?> "/> </form> <?php do_action('rcp_members_above_table'); ?> <form id="rcp-members-form" action="<?php echo esc_attr(admin_url('admin.php?page=rcp-members')); ?> " method="post"> <div id="rcp-bulk-action-options" class="tablenav top"> <label for="rcp-bulk-member-action" class="screen-reader-text"><?php _e('Select bulk action', 'rcp'); ?> </label> <select name="rcp-bulk-action" id="rcp-bulk-member-action"> <option value="-1"><?php _e('Bulk Actions', 'rcp'); ?> </option> <option value="mark-active"><?php _e('Mark as Active', 'rcp'); ?> </option> <option value="mark-expired"><?php _e('Mark as Expired', 'rcp'); ?> </option> <option value="mark-cancelled"><?php _e('Revoke Access', 'rcp'); ?> </option> </select> <input type="text" class="rcp-datepicker" name="expiration" placeholder="<?php esc_attr_e('New Expiration Date', 'rcp'); ?> " id="rcp-bulk-expiration" value=""/> <input type="submit" id="rcp-submit-bulk-action" class="button action" value="<?php _e('Apply', 'rcp'); ?> "/> </div> <?php wp_nonce_field('rcp_bulk_edit_nonce', 'rcp_bulk_edit_nonce'); ?> <table class="wp-list-table widefat"> <thead> <tr> <td id="cb" class="manage-column column-cb check-column"> <label class="screen-reader-text" for="cb-select-all-1"><?php _e('Select All', 'rcp'); ?> </label> <input id="cb-select-all-1" type="checkbox"> </td> <th scope="col" class="rcp-user-col manage-column column-primary"><?php _e('User', 'rcp'); ?> </th> <th scope="col" class="rcp-sub-col manage-column"><?php _e('Subscription', 'rcp'); ?> </th> <th scope="col" class="rcp-status-col manage-column"><?php _e('Status', 'rcp'); ?> </th> <th scope="col" class="rcp-recurring-col manage-column"><?php _e('Recurring', 'rcp'); ?> </th> <th scope="col" class="rcp-expiration-col manage-column"><?php _e('Expiration', 'rcp'); ?> </th> <th scope="col" class="rcp-role-col manage-column"><?php _e('User Role', 'rcp'); ?> </th> <?php do_action('rcp_members_page_table_header'); ?> </tr> </thead> <tbody id="the-list"> <?php if (isset($_GET['signup_method'])) { $method = $_GET['signup_method'] == 'live' ? 'live' : 'manual'; $members = get_users(array('meta_key' => 'rcp_signup_method', 'meta_value' => $method, 'number' => 999999)); $per_page = 999999; } else { $members = rcp_get_members($status, $subscription_id, $offset, $per_page, $order, null, $search); } if ($members) { $i = 1; foreach ($members as $key => $member) { $rcp_member = new RCP_Member($member->ID); // Show pending expiration date for members with a pending status. See https://github.com/restrictcontentpro/restrict-content-pro/issues/708. if ('pending' === $status) { $expiration = $rcp_member->get_expiration_date(true, true); } else { $expiration = $rcp_member->get_expiration_date(true, false); } ?> <tr class="rcp_row <?php do_action('rcp_member_row_class', $member); if (rcp_is_odd($i)) { echo ' alternate'; } ?> "> <th scope="row" class="check-column"> <input type="checkbox" class="rcp-member-cb" name="member-ids[]" value="<?php echo absint($member->ID); ?> "/> </th> <td class="has-row-actions column-primary" data-colname="<?php _e('User', 'rcp'); ?> "> <strong> <a href="<?php echo esc_url(add_query_arg('edit_member', $member->ID, $current_page)); ?> " title="<?php _e('Edit Member', 'rcp'); ?> "><?php echo $member->user_login; ?> </a> <?php if ($member->user_login != $member->user_email) { ?> <?php echo ' – ' . $member->user_email; ?> <?php } ?> </strong> <?php if (current_user_can('rcp_manage_members')) { ?> <div class="row-actions"> <span class="edit"> <a href="<?php echo esc_url(add_query_arg('edit_member', $member->ID, $current_page)); ?> "><?php _e('Edit Member', 'rcp'); ?> </a> <span class="rcp-separator"> | </span> <a href="<?php echo esc_url(add_query_arg('user_id', $member->ID, admin_url('user-edit.php'))); ?> " title="<?php _e('View User\'s Profile', 'rcp'); ?> "><?php _e('Edit User Account', 'rcp'); ?> </a> </span> <?php if (rcp_can_member_cancel($member->ID)) { ?> <span> | <a href="<?php echo wp_nonce_url(add_query_arg('cancel_member', $member->ID, $current_page), 'rcp-cancel-nonce'); ?> " class="trash rcp_cancel"><?php _e('Cancel', 'rcp'); ?> </a></span> <?php } ?> <?php if ($switch_to_url = rcp_get_switch_to_url($member->ID)) { ?> <span> | <a href="<?php echo esc_url($switch_to_url); ?> " class="rcp_switch"><?php _e('Switch to User', 'rcp'); ?> </a></span> <?php } ?> <span class="rcp-separator"> | </span> <span class="id rcp-member-id"><?php echo __('ID:', 'rcp') . ' ' . $member->ID; ?> </span> <?php do_action('rcp_member_row_actions', $member->ID); ?> </div> <?php } ?> <button type="button" class="toggle-row"><span class="screen-reader-text"><?php _e('Show more details', 'rcp'); ?> </span></button> </td> <td data-colname="<?php _e('Subscription', 'rcp'); ?> "><?php echo rcp_get_subscription($member->ID); ?> </td> <td data-colname="<?php _e('Status', 'rcp'); ?> "><?php echo rcp_print_status($member->ID, false); ?> </td> <td data-colname="<?php _e('Recurring', 'rcp'); ?> "><?php echo rcp_is_recurring($member->ID) ? __('yes', 'rcp') : __('no', 'rcp'); ?> </td> <td data-colname="<?php _e('Expiration', 'rcp'); ?> "><?php echo $expiration; ?> </td> <td data-colname="<?php _e('User Role', 'rcp'); ?> "><?php echo rcp_get_user_role($member->ID); ?> </td> <?php do_action('rcp_members_page_table_column', $member->ID); ?> </tr> <?php $i++; } } else { ?> <tr><td colspan="6"><?php _e('No subscribers found', 'rcp'); ?> </td></tr> <?php } ?> </tbody> <tfoot> <tr> <td id="cb" class="manage-column column-cb check-column"> <label class="screen-reader-text" for="cb-select-all-1"><?php _e('Select All', 'rcp'); ?> </label> <input id="cb-select-all-1" type="checkbox"> </td> <th scope="col" class="rcp-user-col manage-column column-primary"><?php _e('User', 'rcp'); ?> </th> <th scope="col" class="rcp-sub-col manage-column"><?php _e('Subscription', 'rcp'); ?> </th> <th scope="col" class="rcp-status-col manage-column"><?php _e('Status', 'rcp'); ?> </th> <th scope="col" class="rcp-recurring-col manage-column"><?php _e('Recurring', 'rcp'); ?> </th> <th scope="col" class="rcp-expiration-col manage-column"><?php _e('Expiration', 'rcp'); ?> </th> <th scope="col" class="rcp-role-col manage-column"><?php _e('User Role', 'rcp'); ?> </th> <?php do_action('rcp_members_page_table_footer'); ?> </tr> </tfoot> </table> </form> <?php if ($total_pages > 1 && !isset($_GET['signup_method'])) { ?> <div class="tablenav bottom"> <div class="tablenav-pages alignright"> <?php $query_string = $_SERVER['QUERY_STRING']; $base = 'admin.php?' . remove_query_arg('p', $query_string) . '%_%'; echo paginate_links(array('base' => $base, 'format' => '&p=%#%', 'prev_text' => __('« Previous', 'rcp'), 'next_text' => __('Next »', 'rcp'), 'total' => $total_pages, 'current' => $page, 'end_size' => 1, 'mid_size' => 5)); ?> </div> </div><!--end .tablenav--> <?php } ?> <?php do_action('rcp_members_below_table'); ?> <h3> <?php _e('Add New Subscription (for existing user)', 'rcp'); ?> <span alt="f223" class="rcp-help-tip dashicons dashicons-editor-help" title="<?php _e('If you wish to create a brand new account, that may be done from Users → Add New. <br/><strong>Note</strong>: this will not create a payment profile for the member. That must be done manually through your merchant account.', 'rcp'); ?> "></span> </h3> <form id="rcp-add-new-member" action="" method="post"> <table class="form-table"> <tbody> <tr class="form-field"> <th scope="row" valign="top"> <label for="rcp-username"><?php _e('Username', 'rcp'); ?> </label> </th> <td> <input type="text" name="user" id="rcp-user" autocomplete="off" class="regular-text rcp-user-search" style="width: 120px;"/> <img class="rcp-ajax waiting" src="<?php echo admin_url('images/wpspin_light.gif'); ?> " style="display: none;"/> <div id="rcp_user_search_results"></div> <p class="description"><?php _e('Begin typing the user name to add a subscription to.', 'rcp'); ?> </p> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <label for="rcp-level"><?php _e('Subscription Level', 'rcp'); ?> </label> </th> <td> <select name="level" id="rcp-level"> <option value="choose"><?php _e('--choose--', 'rcp'); ?> </option> <?php foreach (rcp_get_subscription_levels() as $level) { echo '<option value="' . $level->id . '">' . $level->name . '</option>'; } ?> </select> <span alt="f223" class="rcp-help-tip dashicons dashicons-editor-help" title="<?php _e('The subscription level determines the content the member has access to. <strong>Note</strong>: adding a subscription level to a member will not create a payment profile in your merchant account.', 'rcp'); ?> "></span> <p class="description"><?php _e('Choose the subscription level for this user.', 'rcp'); ?> </p> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <label for="rcp-expiration"><?php _e('Expiration date', 'rcp'); ?> </label> </th> <td> <input name="expiration" id="rcp-expiration" type="text" style="width: 120px;" class="rcp-datepicker"/> <label for="rcp-unlimited"> <input name="unlimited" id="rcp-unlimited" type="checkbox"/> <span class="description"><?php _e('Never expires?', 'rcp'); ?> </span> </label> <p class="description"><?php _e('Enter the expiration date for this user in the format of yyyy-mm-dd', 'rcp'); ?> </p> </td> </tr> </tbody> </table> <p class="submit"> <input type="hidden" name="rcp-action" value="add-subscription"/> <input type="submit" value="<?php _e('Add User Subscription', 'rcp'); ?> " class="button-primary"/> </p> <?php wp_nonce_field('rcp_add_member_nonce', 'rcp_add_member_nonce'); ?> </form> <?php } ?> </div><!--end wrap--> <?php }