Ejemplo n.º 1
0
function rcp_get_metabox_fields()
{
    //custom meta boxes
    $rcp_prefix = 'rcp_';
    $rcp_meta_box = array('id' => 'rcp_meta_box', 'title' => __('Restrict this content', 'rcp'), 'context' => 'normal', 'priority' => apply_filters('rcp_metabox_priority', 'high'), 'fields' => array(array('name' => __('Paid Only?', 'rcp'), 'id' => '_is_paid', 'type' => 'checkbox', 'desc' => __('Restrict this entry to active paid users only.', 'rcp')), array('name' => __('Show Excerpt?', 'rcp'), 'id' => $rcp_prefix . 'show_excerpt', 'type' => 'checkbox', 'desc' => __('Allow non active users to view the excerpt? If left unchecked, the message defined in settings will be used.', 'rcp')), array('name' => __('Hide from Feed?', 'rcp'), 'id' => $rcp_prefix . 'hide_from_feed', 'type' => 'checkbox', 'desc' => __('Hide the excerpt of this post / page from the Feed?', 'rcp')), array('name' => __('Access Level', 'rcp'), 'id' => $rcp_prefix . 'access_level', 'type' => 'select', 'desc' => __('Choose the access level required see this content. The access level is determined by the subscription the member is subscribed to.', 'rcp'), 'options' => rcp_get_access_levels(), 'std' => 'All'), array('name' => __('Subscription Level', 'rcp'), 'id' => $rcp_prefix . 'subscription_level', 'type' => 'levels', 'desc' => __('Choose the subscription levels allowed to view this content.', 'rcp'), 'std' => 'All'), array('name' => __('User Level', 'rcp'), 'id' => $rcp_prefix . 'user_level', 'type' => 'select', 'desc' => __('Choose the user level that can see this post / page\'s content. Users of this level and higher will be the only ones able to view the content.', 'rcp'), 'options' => array('All', 'Administrator', 'Editor', 'Author', 'Contributor', 'Subscriber'), 'std' => 'All')));
    return apply_filters('rcp_metabox_fields', $rcp_meta_box);
}
    /**
     * 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 
    }
_e('The description of this subscription. This is shown on the registration page.', '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 
foreach (rcp_get_access_levels() as $access) {
    echo '<option value="' . absint($access) . '" ' . selected($access, $level->level, false) . '">' . esc_html($access) . '</option>';
}
?>
					</select>
					<p class="description"><?php 
_e('Level of access this subscription gives.', 'rcp');
?>
</p>
				</td>
			</tr>
			<tr class="form-field">
				<th scope="row" valign="top">
					<label for="rcp-duration"><?php 
_e('Duration', 'rcp');
?>
Ejemplo n.º 4
0
/**
 * 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 
}
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 
}
Ejemplo n.º 7
0
    ?>
<br/>
			</label>
		<?php 
}
?>
	</p>
</div>
<div id="rcp-metabox-field-access-levels" class="rcp-metabox-field"<?php 
echo $access_display;
?>
>
	<p>
		<select name="rcp_access_level" id="rcp-access-level-field">
			<?php 
foreach (rcp_get_access_levels() as $key => $access_level_label) {
    ?>
				<option id="rcp_access_level<?php 
    echo $key;
    ?>
" value="<?php 
    echo esc_attr($key);
    ?>
"<?php 
    selected($key, $access_level);
    ?>
><?php 
    printf(__('%s and higher', 'rcp'), $key);
    ?>
</option>
			<?php