public function metabox($post_id = 0) { global $rcp_gifts; $is_gift = $rcp_gifts->is_gift_product($post_id); $is_multiuse = $rcp_gifts->is_gift_multiuse($post_id); $expires = $rcp_gifts->gift_expires($post_id); $gift_level = $rcp_gifts->gift_subscription_level($post_id); $levels = rcp_get_subscription_levels(); echo '<p>'; echo '<strong>' . __('Gift Creation', 'rcp-gifts') . '</strong><br/>'; echo '</p>'; echo '<p>'; echo '<input type="checkbox" name="_rcp_gift_product" id="_rcp_gift_product" value="1"' . checked(true, $is_gift, false) . '/>'; echo '<label for="_rcp_gift_product">' . __('Enable RCP Gift creation for this product', 'rcp-gifts') . '</label>'; echo '</p>'; // enable multi-use echo '<p>'; echo '<input type="checkbox" name="_rcp_gift_multiuse" id="_rcp_gift_multiuse" value="1"' . checked(true, $is_multiuse, false) . '/>'; echo '<label for="_rcp_gift_multiuse">' . __('Enable coupon to be used multiple times.', 'rcp-gifts') . '</label>'; echo '</p>'; // set expiration date echo '<p>'; echo '<input type="date" class="datepicker" name="_rcp_gift_expires" id="_rcp_gift_expires" value="' . esc_attr($expires) . '">'; echo '<label for="_rcp_gift_expires">' . __('Select optional expiration date.', 'rcp-gifts') . '</label>'; echo '</p>'; // choose subscription level echo '<p>'; echo '<select name="_rcp_gift_subscription_level" id="_rcp_gift_subscription_level"/> '; foreach ($levels as $level) { echo '<option value="' . absint($level->id) . '"' . selected($gift_level, $level->id, false) . '>' . $level->name . '</option>'; } echo '</select>'; echo '</p>'; }
/** * Adds the subscription level dropdown to the member directory edit screen. */ function jp_um_admin_extend_directory_options_general($this) { $post_id = get_the_ID(); $saved_level = get_post_meta($post_id, 'um_rcp_subscription_level', true); $saved_level = !empty($saved_level) ? absint($saved_level) : 'none'; ?> <p> <label class="um-admin-half">RCP Members to Display</label> <span class="um-admin-half"> <select name="um_rcp_subscription_level" id="um_rcp_subscription_level" class="umaf-selectjs um-adm-conditional" style="width: 300px" data-cond1='other' data-cond1-show='custom-field'> <option value="none" <?php selected('none', $saved_level); ?> >None</option> <?php foreach (rcp_get_subscription_levels() as $key => $level) { echo '<option value="' . $level->id . '" ' . selected($level->id, $saved_level) . '>' . $level->name . '</option>'; } ?> </select> </span> </p><div class="um-admin-clear"></div> <?php wp_nonce_field('um_rcp_subscription_level_nonce', 'um_rcp_subscription_level_nonce'); }
function rcp_render_meta_box() { global $post; $rcp_meta_box = rcp_get_metabox_fields(); // Use nonce for verification echo '<input type="hidden" name="rcp_meta_box" value="', wp_create_nonce(basename(__FILE__)), '" />'; echo '<table class="form-table">'; echo '<tr><td colspan="3">' . sprintf(__('Use these options to restrict this entire entry, or the [restrict] ... [/restrict] short code to restrict partial content. %sView documentation%s.', 'rcp'), '<a href="' . esc_url('http://docs.pippinsplugins.com/article/36-restricting-post-and-page-content') . '" target="_blank">', '</a>') . '</td></tr>'; do_action('rcp_metabox_fields_before'); foreach ($rcp_meta_box['fields'] as $field) { // get current post meta data $meta = get_post_meta($post->ID, $field['id'], true); echo '<tr>'; echo '<th style="width:20%" class="rcp_meta_box_label"><label for="', $field['id'], '">', $field['name'], '</label></th>'; echo '<td class="rcp_meta_box_field">'; switch ($field['type']) { case 'select': echo '<select name="', $field['id'], '" id="', $field['id'], '">'; foreach ($field['options'] as $option) { echo '<option', $meta == $option ? ' selected="selected"' : '', '>', $option, '</option>'; } echo '</select>'; break; case 'levels': $selected = is_array($meta) ? $meta : array($meta); $levels = rcp_get_subscription_levels('all'); foreach ($levels as $level) { echo '<input type="checkbox" value="' . $level->id . '"' . checked(true, in_array($level->id, $selected), false) . ' name="' . $field['id'] . '[]" id="' . $field['id'] . '_' . $level->id . '" /> '; echo '<label for="' . $field['id'] . '_' . $level->id . '">' . $level->name . '</label><br/>'; } break; case 'checkbox': echo '<input type="checkbox" value="1" name="', $field['id'], '" id="', $field['id'], '"', $meta ? ' checked="checked"' : '', ' />'; break; } echo '</td>'; echo '<td class="rcp_meta_box_desc">', $field['desc'], '</td>'; echo '</tr>'; } do_action('rcp_metabox_fields_after'); echo '<tr><td colspan="3"><strong>' . __('Note 1', 'rcp') . '</strong>: ' . __('To hide this content from logged-out users, but allow free and paid, set the User Level to "Subscriber".', 'rcp') . '</td></tr>'; echo '<tr><td colspan="3"><strong>' . __('Note 2', 'rcp') . '</strong>: ' . __('Access level, subscription level, and user level can all be combined to require the user meet all three specifications.', 'rcp') . '</td></tr>'; echo '</table>'; }
/** * Display product settings * * @access public * @since 2.2 */ public function data_display() { ?> <div id="rcp_access_control" class="panel woocommerce_options_panel"> <div class="options_group"> <p><?php _e('Restrict purchasing of this product to:', 'rcp'); ?> </p> <?php woocommerce_wp_checkbox(array('id' => '_rcp_woo_active_to_purchase', 'label' => __('Active subscribers only?', 'rcp'), 'cbvalue' => 1)); $levels = (array) get_post_meta(get_the_ID(), '_rcp_woo_subscription_levels_to_purchase', true); foreach (rcp_get_subscription_levels('all') as $level) { woocommerce_wp_checkbox(array('name' => '_rcp_woo_subscription_levels_to_purchase[]', 'id' => '_rcp_woo_subscription_level_' . $level->id, 'label' => $level->name, 'value' => in_array($level->id, $levels) ? $level->id : 0, 'cbvalue' => $level->id)); } woocommerce_wp_select(array('id' => '_rcp_woo_access_level_to_purchase', 'label' => __('Access level required?', 'rcp'), 'options' => rcp_get_access_levels())); ?> </div> <div class="options_group"> <p><?php _e('Restrict viewing of this product to:', 'rcp'); ?> </p> <?php woocommerce_wp_checkbox(array('id' => '_rcp_woo_active_to_view', 'label' => __('Active subscribers only?', 'rcp'), 'cbvalue' => 1)); $levels = (array) get_post_meta(get_the_ID(), '_rcp_woo_subscription_levels_to_view', true); foreach (rcp_get_subscription_levels('all') as $level) { woocommerce_wp_checkbox(array('name' => '_rcp_woo_subscription_levels_to_view[]', 'id' => '_rcp_woo_subscription_level_to_view_' . $level->id, 'label' => $level->name, 'value' => in_array($level->id, $levels) ? $level->id : 0, 'cbvalue' => $level->id)); } woocommerce_wp_select(array('id' => '_rcp_woo_access_level_to_view', 'label' => __('Access level required?', 'rcp'), 'options' => rcp_get_access_levels())); ?> </div> </div> <?php }
function rcp_export_page() { global $rcp_options, $rcp_db_name, $wpdb; $current_page = admin_url('/admin.php?page=rcp-export'); ?> <div class="wrap"> <h2><?php _e('Export', 'rcp'); ?> </h2> <?php do_action('rcp_export_page_top'); ?> <h3><?php _e('Members Export', 'rcp'); ?> </h3> <p><?php _e('Download member data as a CSV file. This is useful for tasks such as importing batch users into MailChimp, or other systems.', 'rcp'); ?> </p> <form id="rcp_export" action="<?php echo $current_page; ?> " method="post"> <p> <select name="rcp-subscription" id="rcp-subscription"> <option value="0"><?php _e('All', 'rcp'); ?> </option> <?php $levels = rcp_get_subscription_levels('all'); if ($levels) { foreach ($levels as $key => $level) { ?> <option value="<?php echo absint($level->id); ?> "><?php echo esc_html($level->name); ?> </option> <?php } } ?> </select> <label for="rcp-subscription"><?php _e('Choose the subscription to export members from', 'rcp'); ?> </label><br/> <select name="rcp-status" id="rcp-status"> <option value="active"><?php _e('Active', 'rcp'); ?> </option> <option value="pending"><?php _e('Pending', 'rcp'); ?> </option> <option value="expired"><?php _e('Expired', 'rcp'); ?> </option> <option value="cancelled"><?php _e('Cancelled', 'rcp'); ?> </option> <option value="free"><?php _e('Free', 'rcp'); ?> </option> </select> <label for="rcp-status"><?php _e('Choose the status to export', 'rcp'); ?> </label><br/> <input type="number" id="rcp-number" name="rcp-number" class="small-text" value="500" /> <label for="rcp-number"><?php _e('Maximum number of members to export', 'rcp'); ?> <br/> <input type="number" id="rcp-offset" name="rcp-offset" class="small-text" value="0" /> <label for="rcp-offset"><?php _e('The number of members to skip', 'rcp'); ?> </p> <p><?php _e('If you need to export a large number of members, export them in batches using the max and offset options', 'rcp'); ?> </p> <input type="hidden" name="rcp-action" value="export-members"/> <input type="submit" class="button-secondary" value="<?php _e('Download Member CSV', 'rcp'); ?> "/> </form> <!-- payments export --> <h3><?php _e('Payments Export', 'rcp'); ?> </h3> <p><?php _e('Download payment data as a CSV file. Use this file for your own record keeping or tracking.', 'rcp'); ?> </p> <form id="rcp_export" action="<?php echo esc_url($current_page); ?> " method="post"> <p> <select name="rcp-year" id="rcp-year"> <option value="0"><?php _e('All years', 'rcp'); ?> <?php $current = date('Y'); $year = $current; $end = $current - 5; while ($year >= $end) { ?> <option value="<?php echo $year; ?> "><?php echo $year; ?> </option> <?php $year--; } ?> </select> <select name="rcp-month" id="rcp-month"> <option value="0"><?php _e('All months', 'rcp'); ?> <?php for ($i = 1; $i <= 12; $i++) { ?> <option value="<?php echo $i; ?> "><?php echo rcp_get_month_name($i); ?> </option> <?php } ?> </select> </p> <p> <input type="submit" class="button-secondary" value="<?php _e('Download Payments CSV', 'rcp'); ?> "/> <input type="hidden" name="rcp-action" value="export-payments"/> </p> </form> <?php do_action('rcp_export_page_bottom'); ?> </div><!--end wrap--> <?php }
/** * Return the paid levels * * @since 2.5 * @return array() */ function rcp_get_paid_levels() { $paid_levels = array(); foreach (rcp_get_subscription_levels() as $level) { if ($level->price > 0 && $level->status == 'active') { $paid_levels[] = $level; } } return apply_filters('rcp_get_paid_levels', $paid_levels); }
<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 . '" ' . selected($code->subscription_id, $level->id, false) . '>' . $level->name . '</option>'; } ?> </select> <?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 }
/** * widget function. * * @see WP_Widget * @access public * @param array $args * @param array $instance * @return void */ function widget($args, $instance) { if ($this->get_cached_widget($args)) { return; } ob_start(); extract($args); $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); $description = $instance['description']; $levels = rcp_get_subscription_levels('active'); if (!$levels) { return; } $content = ob_get_clean(); echo $before_widget; ?> <div class="container"> <?php if ($title) { echo $before_title . $title . $after_title; } ?> <?php if ($description) { ?> <p class="homepage-widget-description"><?php echo $description; ?> </p> <?php } ?> <div class="pricing-table-widget-<?php echo count($levels); ?> "> <?php foreach ($levels as $key => $level) { ?> <?php if (rcp_show_subscription_level($level->id)) { ?> <div id="rcp_subscription_level_<?php echo $level->id; ?> " class="pricing-table-widget rcp_subscription_level_fake" data-href="<?php echo esc_url(get_permalink(jobify_find_page_with_shortcode(array('register_form')))); ?> "> <div class="pricing-table-widget-title" style="background-color: #01da90"> <span class="rcp_subscription_level_name"><?php echo stripslashes($level->name); ?> </span> </div> <div class="pricing-table-widget-description"> <h2><span class="rcp_price" rel="<?php echo esc_attr($level->price); ?> "><?php echo $level->price > 0 ? rcp_currency_filter($level->price) : __('free', 'jobify'); ?> </h2> <p><span class="rcp_level_duration"><?php echo $level->duration > 0 ? $level->duration . ' ' . rcp_filter_duration_unit($level->duration_unit, $level->duration) : __('unlimited', 'jobify'); ?> </span></p> <?php echo wpautop(wp_kses($level->description, rcp_allowed_html_tags())); ?> </div> </div> <?php } ?> <?php } ?> </div> </div> <?php echo $after_widget; echo $content; $this->cache_widget($args, $content); }
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 }
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 }
<label for="rcp_subscription_level_specific"> <input type="radio" name="rcp_subscription_level_any_set" id="rcp_subscription_level_specific" value="specific"<?php checked(true, is_array($sub_levels)); ?> /> <?php _e('Members of specific subscription levels', 'rcp'); ?> <br/> </label> <p class="rcp-subscription-levels"<?php echo $levels_display; ?> > <?php foreach (rcp_get_subscription_levels() as $level) { ?> <label for="rcp_subscription_level_<?php echo $level->id; ?> "> <input type="checkbox" name="rcp_subscription_level[]"<?php checked(true, in_array($level->id, (array) $sub_levels)); ?> class="rcp_subscription_level" id="rcp_subscription_level_<?php echo $level->id; ?> " value="<?php echo esc_attr($level->id); ?> " data-price="<?php
/** * widget function. * * @see WP_Widget * @access public * @param array $args * @param array $instance * @return void */ function widget($args, $instance) { if ($this->get_cached_widget($args)) { return; } ob_start(); extract($args); $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); $description = $instance['description']; $levels = rcp_get_subscription_levels('active'); if (!$levels) { return; } $content = ob_get_clean(); echo $before_widget; ?> <div class="container"> <?php if ($title) { echo $before_title . $title . $after_title; } ?> <?php if ($description) { ?> <p class="homepage-widget-description"><?php echo $description; ?> </p> <?php } ?> <div class="job-packages row"> <?php foreach ($levels as $key => $level) { ?> <?php if (rcp_show_subscription_level($level->id)) { ?> <div class="col-lg-4 col-md-6 col-sm-12 pricing-table-widget-wrapper"> <div class="pricing-table-widget rcp_subscription_level rcp_subscription_level_fake" data-href="<?php echo esc_url(get_permalink(jobify_find_page_with_shortcode(array('register_form')))); ?> "> <div class="pricing-table-widget-title"> <span class="rcp_subscription_level_name"><?php echo stripslashes($level->name); ?> </span> </div> <div class="pricing-table-widget-description"> <h2> <span class="rcp_price" rel="<?php echo esc_attr($level->price); ?> "> <?php if ($level->fee) { ?> <?php $adjusted_price = $level->price + $level->fee; ?> <?php echo $adjusted_price > 0 ? rcp_currency_filter($adjusted_price) : __('free', 'jobify'); ?> </h2> <small> <?php $promo_duration = sprintf(_n('%2$s', '%1$s %2$ss', $level->duration, 'jobify'), $level->duration, $level->duration_unit); ?> <?php printf(__('* %s after first %s', 'jobify'), rcp_currency_filter($level->price), $promo_duration); ?> </small> <?php } else { ?> <?php $adjusted_price = $level->price; ?> <?php echo $adjusted_price > 0 ? rcp_currency_filter($adjusted_price) : __('free', 'jobify'); ?> </h2> <?php } ?> </span> </h2> <p><span class="rcp_level_duration"><?php echo $level->duration > 0 ? $level->duration . ' ' . rcp_filter_duration_unit($level->duration_unit, $level->duration) : __('unlimited', 'jobify'); ?> </span></p> <?php echo wpautop(wp_kses(stripslashes($level->description), rcp_allowed_html_tags())); ?> <p><a href="#" class="rcp-select button"><?php _e('Get Started', 'jobify'); ?> </a></p> </div> </div> </div> <?php } ?> <?php } ?> </div> </div> <?php echo $after_widget; echo $content; $this->cache_widget($args, $content); }
_e('The status of this user\'s subscription', 'rcp'); ?> </p> </td> </tr> <tr valign="top"> <th scope="row" valign="top"> <label for="rcp-level"><?php _e('Subscription Level', 'rcp'); ?> </label> </th> <td> <select name="level" id="rcp-level"> <?php foreach (rcp_get_subscription_levels('all') as $key => $level) { echo '<option value="' . esc_attr(absint($level->id)) . '"' . selected($level->name, rcp_get_subscription($member->ID), false) . '>' . esc_html($level->name) . '</option>'; } ?> </select> <p class="description"><?php _e('Choose the subscription level for this user', 'rcp'); ?> </p> </td> </tr> <tr valign="top"> <th scope="row" valign="top"> <label for="rcp-key"><?php _e('Subscription Key', 'rcp'); ?>
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 }
function after_register() { $_GET['level'] = get_usermeta($_GET['id'], 'reg_type'); $levels = rcp_get_subscription_levels('active'); $gateways = rcp_get_enabled_payment_gateways(); rcp_show_error_messages('register'); ?> <form id="rcp_registration_form" class="rcp_form" method="POST" action="<?php echo esc_url(rcp_get_current_url()); if (isset($_GET['id'])) { echo '?id=' . $_GET['id']; } ?> "> <div class="saloginwrapper"> <h2 class="section-title"><span>Successful Registration!</span></h2> <div class="clear"></div> <ul id="rcp_subscription_levels" style="display:none;"> <?php foreach ($levels as $key => $level) { ?> <?php if (rcp_show_subscription_level($level->id)) { ?> <li id="rcp_subscription_level_<?php echo $level->id; ?> " class="rcp_subscription_level"> <input type="radio" class="required rcp_level" <?php if (isset($_GET['level']) && $_GET['level'] == $level->id) { echo 'checked="checked"'; } ?> name="rcp_level" rel="<?php echo esc_attr($level->price); ?> " value="<?php echo esc_attr(absint($level->id)); ?> " <?php if ($level->duration == 0) { echo 'data-duration="forever"'; } ?> /> <span class="rcp_subscription_level_name"><?php echo rcp_get_subscription_name($level->id); ?> </span><span class="rcp_separator"> - </span><span class="rcp_price" rel="<?php echo esc_attr($level->price); ?> "><?php echo $level->price > 0 ? rcp_currency_filter($level->price) : __('free', 'rcp'); ?> <span class="rcp_separator"> - </span></span> <span class="rcp_level_duration"><?php echo $level->duration > 0 ? $level->duration . ' ' . rcp_filter_duration_unit($level->duration_unit, $level->duration) : __('unlimited', 'rcp'); ?> </span> <div class="rcp_level_description"> <?php echo rcp_get_subscription_description($level->id); ?> </div> </li> <?php } ?> <?php } ?> </ul> <?php $gateways = rcp_get_enabled_payment_gateways(); if (count($gateways) > 1) { $display = rcp_has_paid_levels() ? '' : ' style="display: none;"'; ?> <fieldset class="rcp_gateways_fieldset"> <p> <label><?php _e('Choose Your Payment Method', 'rcp'); ?> </label> </p> <p id="rcp_payment_gateways"<?php echo $display; ?> > <select name="rcp_gateway" id="rcp_gateway" style="float:left; position:relative;"> <?php foreach ($gateways as $key => $gateway) { ?> <option value="<?php echo esc_attr($key); ?> "><?php echo esc_html($gateway); ?> </option> <?php } ?> </select> </p> </fieldset> <?php } ?> <?php do_action('rcp_before_registration_submit_field', $levels); ?> <p id="rcp_submit_wrap"> <input type="hidden" name="rcp_register_nonce" value="<?php echo wp_create_nonce('rcp-register-nonce'); ?> "/> <input type="submit" name="rcp_submit_registration" id="rcp_submit" value="<?php echo apply_filters('rcp_registration_register_button', __('Register', 'rcp')); ?> "/> </p> <div class="clear"></div> </div></form> <?php }
/** * Add restriction options to the edit category page * * @access public * @since 2.0 * @return void */ function rcp_category_edit_meta_fields($term) { // retrieve the existing value(s) for this meta field. This returns an array $term_meta = get_option("rcp_category_meta_{$term->term_id}"); $access_level = isset($term_meta['access_level']) ? absint($term_meta['access_level']) : 0; $subscription_levels = isset($term_meta['subscriptions']) ? array_map('absint', $term_meta['subscriptions']) : array(); ?> <tr> <th scope="row"><?php _e('Paid Only?', 'rcp'); ?> </th> <td> <label for="rcp_category_meta[paid_only]"> <input type="checkbox" name="rcp_category_meta[paid_only]" id="rcp_category_meta[paid_only]" value="1"<?php checked(true, isset($term_meta['paid_only'])); ?> > <span class="description"><?php _e('Restrict items in this category to paid subscribers only?', 'rcp'); ?> </span> </label> </td> </tr> <tr> <th scope="row"><?php _e('Access Level', 'rcp'); ?> </th> <td> <label for="rcp_category_meta[access_level]"> <select name="rcp_category_meta[access_level]" id="rcp_category_meta[access_level]"> <?php foreach (rcp_get_access_levels() as $level) { ?> <option value="<?php echo esc_attr($level); ?> "<?php selected($level, $access_level); ?> ><?php echo $level; ?> </option> <?php } ?> </select> <span class="description"><?php _e('Access level required to view content in this category.', 'rcp'); ?> </span> </label> </td> </tr> <tr> <th scope="row"><?php _e('Subscription Levels', 'rcp'); ?> </th> <td> <?php foreach (rcp_get_subscription_levels() as $level) { ?> <label for="rcp_category_meta[subscriptions][<?php echo $level->id; ?> ]"> <input type="checkbox" name="rcp_category_meta[subscriptions][<?php echo $level->id; ?> ]" id="rcp_category_meta[subscriptions][<?php echo $level->id; ?> ]" value="1"<?php checked(true, in_array($level->id, $subscription_levels)); ?> > <?php echo $level->name; ?> </label><br/> <?php } ?> <span class="description"><?php _e('Subscription levels allowed to view content in this category. Leave unchecked for all.', 'rcp'); ?> </span> <?php wp_nonce_field('rcp_edit_category', 'rcp_edit_category'); ?> </td> </tr> <?php }
/** * Show report graph date filters * * @since 1.8 * @return void */ function rcp_reports_graph_controls() { $date_options = apply_filters('rcp_report_date_options', array('this_week' => __('This Week', 'rcp'), 'last_week' => __('Last Week', 'rcp'), 'this_month' => __('This Month', 'rcp'), 'last_month' => __('Last Month', 'rcp'), 'this_quarter' => __('This Quarter', 'rcp'), 'last_quarter' => __('Last Quarter', 'rcp'), 'this_year' => __('This Year', 'rcp'), 'last_year' => __('Last Year', 'rcp'), 'other' => __('Custom', 'rcp'))); $dates = rcp_get_report_dates(); $display = $dates['range'] == 'other' ? '' : 'style="display:none;"'; $active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'earnings'; $selected_level = isset($_GET['subscription']) ? absint($_GET['subscription']) : false; ?> <form id="rcp-garphs-filter" method="get"> <div class="tablenav top"> <div class="alignleft actions"> <input type="hidden" name="page" value="rcp-reports"/> <select id="rcp-graphs-date-options" name="range"> <?php foreach ($date_options as $key => $option) { echo '<option value="' . esc_attr($key) . '" ' . selected($key, $dates['range']) . '>' . esc_html($option) . '</option>'; } ?> </select> <div id="rcp-date-range-options" <?php echo $display; ?> > <span><?php _e('From', 'rcp'); ?> </span> <select id="rcp-graphs-month-start" name="m_start"> <?php for ($i = 1; $i <= 12; $i++) { ?> <option value="<?php echo absint($i); ?> " <?php selected($i, $dates['m_start']); ?> ><?php echo rcp_get_month_name($i); ?> </option> <?php } ?> </select> <select id="rcp-graphs-year" name="year"> <?php for ($i = 2007; $i <= $dates['year_end']; $i++) { ?> <option value="<?php echo absint($i); ?> " <?php selected($i, $dates['year']); ?> ><?php echo $i; ?> </option> <?php } ?> </select> <span><?php _e('To', 'rcp'); ?> </span> <select id="rcp-graphs-month-start" name="m_end"> <?php for ($i = 1; $i <= 12; $i++) { ?> <option value="<?php echo absint($i); ?> " <?php selected($i, $dates['m_end']); ?> ><?php echo rcp_get_month_name($i); ?> </option> <?php } ?> </select> <select id="rcp-graphs-year" name="year_end"> <?php for ($i = 2007; $i <= $dates['year_end']; $i++) { ?> <option value="<?php echo absint($i); ?> " <?php selected($i, $dates['year_end']); ?> ><?php echo $i; ?> </option> <?php } ?> </select> </div> <?php if ('earnings' == $active_tab) { $levels = rcp_get_subscription_levels(); ?> <select id="rcp-graphs-subscriptions" name="subscription"> <option value="0"><?php _e('All Subscription Levels', 'rcp'); ?> </option> <?php foreach ($levels as $level) { ?> <option value="<?php echo $level->id; ?> "<?php selected($selected_level, $level->id); ?> ><?php echo $level->name; ?> </option> <?php } ?> </select> <?php } ?> <input type="hidden" name="rcp_action" value="" /> <input type="hidden" name="tab" value="<?php echo $active_tab; ?> " /> <input type="submit" class="button-secondary" value="<?php _e('Filter', 'rcp'); ?> "/> </div> </div> </form> <?php }
function rcp_has_paid_levels() { $levels = rcp_get_subscription_levels(); if ($levels) { foreach ($levels as $level) { if ($level->price > 0 && $level->status == 'active') { return true; } } } return false; }
echo apply_filters('rcp_registration_header_logged_out', __('Upgrade Your Subscription', 'jobify')); ?> </h3> <?php } // show any error messages after form submission rcp_show_error_messages('register'); ?> <form id="rcp_registration_form" method="POST" action="<?php echo esc_url(rcp_get_current_url()); ?> "> <?php $levels = rcp_get_subscription_levels('active'); if ($levels && count($levels) > 1) { ?> <fieldset class="rcp_subscription_fieldset"> <p class="rcp_subscription_message"><?php echo apply_filters('rcp_registration_choose_subscription', __('Choose your subscription level', 'jobify')); ?> </p> <div class="job-packages row"> <?php foreach ($levels as $key => $level) { ?> <?php if (rcp_show_subscription_level($level->id)) {
/** * Print fields for this gateway * * @return string */ public function fields() { global $rcp_options; if (is_user_logged_in()) { $email = wp_get_current_user()->user_email; } else { $email = false; } $data = apply_filters('rcp_stripe_checkout_form_data', array('key' => $this->publishable_key, 'locale' => 'auto', 'allowRememberMe' => true, 'email' => $email, 'currency' => rcp_get_currency(), 'alipay' => isset($rcp_options['stripe_alipay']) && '1' === $rcp_options['stripe_alipay'] && 'USD' === rcp_get_currency() ? true : false)); $subscriptions = array(); foreach (rcp_get_subscription_levels('active') as $subscription) { $subscriptions[$subscription->id] = array('description' => $subscription->description, 'name' => $subscription->name, 'panelLabel' => __('Register', 'rcp')); } $subscriptions = apply_filters('rcp_stripe_checkout_subscription_data', $subscriptions); ob_start(); ?> <script> var rcp_script_options; var rcpSubscriptions = <?php echo json_encode($subscriptions); ?> ; var checkoutArgs = <?php echo json_encode($data); ?> ; // define the token function checkoutArgs.token = function(token){ jQuery('body').trigger('rcp_stripe_checkout_submit', token); }; if( ! checkoutArgs.email ) { checkoutArgs.email = jQuery('#rcp_registration_form #rcp_user_email' ).val(); } jQuery('#rcp_registration_form #rcp_submit').val( rcp_script_options.pay_now ); jQuery('body').on('rcp_level_change', function(event, target) { jQuery('#rcp_registration_form #rcp_submit').val( jQuery(target).attr('rel') > 0 ? rcp_script_options.pay_now : rcp_script_options.register ); }); jQuery('body').on('rcp_stripe_checkout_submit', function(e, token){ jQuery('#rcp_registration_form').append('<input type="hidden" name="stripeToken" value="' + token.id + '" />').submit(); }); jQuery('#rcp_registration_form #rcp_user_email' ).focusout(function() { checkoutArgs.email = jQuery('#rcp_registration_form #rcp_user_email' ).val(); }); var rcpStripeCheckout = StripeCheckout.configure(checkoutArgs); jQuery('#rcp_registration_form #rcp_submit').on('click', function(e) { if ( jQuery('#rcp_gateway option:selected').val() !== 'stripe_checkout' && jQuery('input[name=rcp_gateway]').val() !== 'stripe_checkout' && jQuery('input[name=rcp_gateway]:checked').val() !== 'stripe_checkout' ) { return; } var $form = jQuery(this).closest('form'); var $level = $form.find('input[name=rcp_level]:checked'); var $price = $level.parent().find('.rcp_price').attr('rel') * <?php echo rcp_stripe_get_currency_multiplier(); ?> ; if ( ! $level.length ) { $level = $form.find('input[name=rcp_level]'); $price = $form.find('.rcp_level').attr('rel') * <?php echo rcp_stripe_get_currency_multiplier(); ?> ; } if( jQuery('.rcp_gateway_fields').hasClass('rcp_discounted_100') ) { return true; } // Open Checkout with further options if ( $price > 0 ) { rcpStripeCheckout.open(rcpSubscriptions[$level.val()]); e.preventDefault(); return false; } }); // Close Checkout on page navigation jQuery(window).on('popstate', function() { rcpStripeCheckout.close(); }); </script> <?php return ob_get_clean(); }
function rcp_save_meta_data($post_id) { // verify nonce if (!isset($_POST['rcp_meta_box']) || !wp_verify_nonce($_POST['rcp_meta_box'], basename(__FILE__))) { return; } // check autosave if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; } // check permissions if ('page' == $_POST['post_type']) { if (!current_user_can('edit_page', $post_id)) { return; } } elseif (!current_user_can('edit_post', $post_id)) { return; } $is_paid = false; $restrict_by = sanitize_text_field($_POST['rcp_restrict_by']); switch ($restrict_by) { case 'unrestricted': delete_post_meta($post_id, 'rcp_access_level'); delete_post_meta($post_id, 'rcp_subscription_level'); delete_post_meta($post_id, 'rcp_user_level'); break; case 'subscription-level': $level_set = sanitize_text_field($_POST['rcp_subscription_level_any_set']); switch ($level_set) { case 'any': update_post_meta($post_id, 'rcp_subscription_level', 'any'); break; case 'any-paid': $is_paid = true; update_post_meta($post_id, 'rcp_subscription_level', 'any-paid'); break; case 'specific': $levels = array_map('absint', $_POST['rcp_subscription_level']); foreach ($levels as $level) { $price = rcp_get_subscription_price($level); if (!empty($price)) { $is_paid = true; break; } } update_post_meta($post_id, 'rcp_subscription_level', $levels); break; } // Remove unneeded fields delete_post_meta($post_id, 'rcp_access_level'); break; case 'access-level': update_post_meta($post_id, 'rcp_access_level', absint($_POST['rcp_access_level'])); $levels = rcp_get_subscription_levels(); foreach ($levels as $level) { if (!empty($level->price)) { $is_paid = true; break; } } // Remove unneeded fields delete_post_meta($post_id, 'rcp_subscription_level'); break; case 'registered-users': // Remove unneeded fields delete_post_meta($post_id, 'rcp_access_level'); // Remove unneeded fields delete_post_meta($post_id, 'rcp_subscription_level'); $levels = rcp_get_subscription_levels(); foreach ($levels as $level) { if (!empty($level->price)) { $is_paid = true; break; } } break; } $show_excerpt = isset($_POST['rcp_show_excerpt']); $hide_in_feed = isset($_POST['rcp_hide_from_feed']); $user_role = sanitize_text_field($_POST['rcp_user_level']); update_post_meta($post_id, 'rcp_show_excerpt', $show_excerpt); update_post_meta($post_id, 'rcp_hide_from_feed', $hide_in_feed); if ('unrestricted' !== $_POST['rcp_restrict_by']) { update_post_meta($post_id, 'rcp_user_level', $user_role); } update_post_meta($post_id, '_is_paid', $is_paid); }
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 }
/** * Get subscriptions to which this user can upgrade * * @since 2.5 * @param int $user_id the ID of the user to check * * @return mixed|void */ function rcp_get_upgrade_paths($user_id = 0) { if (empty($user_id)) { $user_id = get_current_user_id(); } // make sure the user is active and get the subscription ID $user_subscription = rcp_is_recurring($user_id) && rcp_is_active($user_id) && 'cancelled' !== rcp_get_status() ? rcp_get_subscription_id($user_id) : ''; $subscriptions = rcp_get_subscription_levels('active'); // remove the user's current subscription from the list foreach ($subscriptions as $key => $subscription) { if ($user_subscription == $subscription->id) { unset($subscriptions[$key]); } } return apply_filters('rcp_get_upgrade_paths', array_values($subscriptions), $user_id); }
function jobify_rcp_subscription_selector($settings) { if (!defined('RCP_PLUGIN_VERSION')) { return $settings; } $levels = rcp_get_subscription_levels('all'); if (empty($levels)) { return $settings; } $keys = wp_list_pluck($levels, 'id'); $names = wp_list_pluck($levels, 'name'); if (!(is_array($keys) && is_array($names))) { return $settings; } $options = array_combine($keys, $names); $settings['subscription'] = array('label' => __('Subscription Level Visibility:', 'jobify'), 'std' => 0, 'type' => 'multicheck', 'options' => $options); return $settings; }