Members Only moved to addons, 2 new options made for enable it at all and enable it for comments.
Cleanup and fixes for the members only code todo: fix the archive/search to ignore the members category if user !comicpress_is_member() Signed-off-by: Philip M. Hofer (Frumph) <frumph_dragon@yahoo.com>
This commit is contained in:
parent
babb991ba3
commit
ee80a7c428
|
@ -65,8 +65,7 @@ function comicpress_admin() {
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (array(
|
foreach (array(
|
||||||
'graphicnav_directory',
|
'graphicnav_directory'
|
||||||
'members_post_category'
|
|
||||||
) as $key) {
|
) as $key) {
|
||||||
$comicpress_options[$key] = wp_filter_nohtml_kses($_REQUEST[$key]);
|
$comicpress_options[$key] = wp_filter_nohtml_kses($_REQUEST[$key]);
|
||||||
}
|
}
|
||||||
|
@ -152,6 +151,7 @@ function comicpress_admin() {
|
||||||
if ($_REQUEST['action'] == 'comicpress_save_addons') {
|
if ($_REQUEST['action'] == 'comicpress_save_addons') {
|
||||||
foreach (array(
|
foreach (array(
|
||||||
'enable_custom_image_header',
|
'enable_custom_image_header',
|
||||||
|
'enable_members_only_post_comments',
|
||||||
'buy_print_add_shipping'
|
'buy_print_add_shipping'
|
||||||
) as $key) {
|
) as $key) {
|
||||||
$comicpress_options[$key] = (bool)( $_REQUEST[$key] == 1 ? true : false );
|
$comicpress_options[$key] = (bool)( $_REQUEST[$key] == 1 ? true : false );
|
||||||
|
@ -159,6 +159,8 @@ function comicpress_admin() {
|
||||||
foreach (array(
|
foreach (array(
|
||||||
'custom_image_header_width',
|
'custom_image_header_width',
|
||||||
'custom_image_header_height',
|
'custom_image_header_height',
|
||||||
|
'enable_members_only',
|
||||||
|
'members_post_category',
|
||||||
'buy_print_email',
|
'buy_print_email',
|
||||||
'buy_print_url',
|
'buy_print_url',
|
||||||
'buy_print_us_amount',
|
'buy_print_us_amount',
|
||||||
|
|
|
@ -9,21 +9,22 @@
|
||||||
* example: [members]Only members can read this.[/members]
|
* example: [members]Only members can read this.[/members]
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Still need to do, make it a way to flag someone a site_member TRUE
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
global $comicpress_options;
|
||||||
|
|
||||||
|
if ($comicpress_options['enable_members_only']) {
|
||||||
|
|
||||||
|
add_shortcode( 'members', 'shortcode_for_comicpress_members_only' );
|
||||||
|
add_shortcode( 'member', 'shortcode_for_comicpress_members_only' );
|
||||||
|
add_action('show_user_profile', 'comicpress_profile_members_only');
|
||||||
|
add_action('edit_user_profile', 'comicpress_profile_members_only');
|
||||||
|
add_action('profile_update', 'comicpress_profile_members_only_save');
|
||||||
|
|
||||||
|
|
||||||
add_shortcode( 'members', 'shortcode_for_comicpress_members_only' );
|
if ($comicpress_options['members_post_category'])
|
||||||
add_shortcode( 'member', 'shortcode_for_comicpress_members_only' );
|
add_filter('pre_get_posts','comicpress_members_filter');
|
||||||
add_action('show_user_profile', 'comicpress_profile_members_only');
|
|
||||||
add_action('edit_user_profile', 'comicpress_profile_members_only');
|
|
||||||
add_action('profile_update', 'comicpress_profile_members_only_save');
|
|
||||||
|
|
||||||
|
function comicpress_members_filter($query) {
|
||||||
// add_filter('pre_get_posts','comicpress_members_filter');
|
|
||||||
|
|
||||||
function comicpress_members_filter($query) {
|
|
||||||
global $comicpress_options, $current_user;
|
global $comicpress_options, $current_user;
|
||||||
$members_post_category = $comicpress_options['members_post_category'];
|
$members_post_category = $comicpress_options['members_post_category'];
|
||||||
if ($members_post_category != 'none' && !empty($members_post_category) && !$query->is_search && !$query->is_page && !$query->is_archive) {
|
if ($members_post_category != 'none' && !empty($members_post_category) && !$query->is_search && !$query->is_page && !$query->is_archive) {
|
||||||
|
@ -44,9 +45,9 @@ function comicpress_members_filter($query) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
function shortcode_for_comicpress_members_only( $atts, $content = null ) {
|
function shortcode_for_comicpress_members_only( $atts, $content = null ) {
|
||||||
global $post, $userdata, $profileuser, $current_user, $errormsg;
|
global $post, $userdata, $profileuser, $current_user, $errormsg;
|
||||||
$returninfo = '<div class="non-member"><p>'.__('There is Members Only content here.<br />To view this content you need to be a member of this site.','comicpress').'</p></div>';
|
$returninfo = '<div class="non-member"><p>'.__('There is Members Only content here.<br />To view this content you need to be a member of this site.','comicpress').'</p></div>';
|
||||||
if ( !empty($current_user->ID) ) {
|
if ( !empty($current_user->ID) ) {
|
||||||
|
@ -58,9 +59,9 @@ function shortcode_for_comicpress_members_only( $atts, $content = null ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $returninfo;
|
return $returninfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
function comicpress_profile_members_only() {
|
function comicpress_profile_members_only() {
|
||||||
global $profileuser, $current_user, $errormsg;
|
global $profileuser, $current_user, $errormsg;
|
||||||
$comicpress_is_member = get_usermeta($profileuser->ID,'comicpress-is-member');
|
$comicpress_is_member = get_usermeta($profileuser->ID,'comicpress-is-member');
|
||||||
if (empty($comicpress_is_member)) $comicpress_is_member = 'no';
|
if (empty($comicpress_is_member)) $comicpress_is_member = 'no';
|
||||||
|
@ -87,31 +88,31 @@ function comicpress_profile_members_only() {
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<?php }
|
<?php }
|
||||||
|
|
||||||
|
|
||||||
function comicpress_profile_members_only_save() {
|
function comicpress_profile_members_only_save() {
|
||||||
$id = $_POST['user_id'];
|
$id = $_POST['user_id'];
|
||||||
$comicpress_is_member = $_POST['comicpress-is-member'];
|
$comicpress_is_member = $_POST['comicpress-is-member'];
|
||||||
|
|
||||||
if (!empty($comicpress_is_member)) {
|
if (!empty($comicpress_is_member)) {
|
||||||
update_usermeta($id, 'comicpress-is-member', $comicpress_is_member);
|
update_usermeta($id, 'comicpress-is-member', $comicpress_is_member);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if the current post is in the members category.
|
* Return true if the current post is in the members category.
|
||||||
*/
|
*/
|
||||||
function in_members_category() {
|
function in_members_category() {
|
||||||
global $post, $category_tree, $comicpress_options;
|
global $post, $category_tree, $comicpress_options;
|
||||||
$members_post_category = $comicpress_options['members_post_category'];
|
$members_post_category = $comicpress_options['members_post_category'];
|
||||||
$members_post_category_array = array();
|
$members_post_category_array = array();
|
||||||
$members_post_category_array = explode($members_post_category);
|
$members_post_category_array = explode($members_post_category);
|
||||||
|
|
||||||
return (count(array_intersect($members_post_category, wp_get_post_categories($post->ID))) > 0);
|
return (count(array_intersect($members_post_category, wp_get_post_categories($post->ID))) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function comicpress_is_member() {
|
function comicpress_is_member() {
|
||||||
global $user_ID;
|
global $user_ID;
|
||||||
if (!empty($user_ID)) {
|
if (!empty($user_ID)) {
|
||||||
$is_member = get_usermeta($user_ID,'comicpress-is-member');
|
$is_member = get_usermeta($user_ID,'comicpress-is-member');
|
||||||
|
@ -120,6 +121,19 @@ function comicpress_is_member() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function comicpress_members_comment_filter($content) {
|
||||||
|
global $comicpress_options;
|
||||||
|
if (comicpress_is_member() || !$comicpress_options['enable_members_only_post_comments']) {
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
return '<div class="non-member"><p>'.__('There is Members Only content here.<br />To view this content you need to be a member of this site.','comicpress').'</p></div>';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
add_filter('comment_text', 'comicpress_members_comment_filter', $content);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -2,27 +2,35 @@
|
||||||
/*
|
/*
|
||||||
Template Name: Members Only Blog
|
Template Name: Members Only Blog
|
||||||
*/
|
*/
|
||||||
?>
|
get_header();
|
||||||
<?php get_header(); global $members_post_category; ?>
|
global $comicpress_options;
|
||||||
<?php remove_filter('pre_get_posts','comicpress_members_filter'); ?>
|
remove_filter('pre_get_posts','comicpress_members_filter');
|
||||||
|
include(get_template_directory() . '/layout-head.php');
|
||||||
|
|
||||||
<?php include(get_template_directory() . '/layout-head.php'); ?>
|
if ($comicpress_options['enable_members_only']) {
|
||||||
|
if ($comicpress_options['members_post_category'] && comicpress_is_member()) {
|
||||||
<?php if (have_posts()):
|
$blog_query = 'showposts='.$comicpress_options['blog_postcount'].'&cat='.$comicpress_options['members_post_category'].'&paged='.$paged;
|
||||||
|
|
||||||
$blog_query = '&cat='.$members_post_category.'&paged='.$paged;
|
|
||||||
|
|
||||||
$posts = query_posts($blog_query);
|
$posts = query_posts($blog_query);
|
||||||
|
if (have_posts()) {
|
||||||
|
|
||||||
while (have_posts()) : the_post();
|
while (have_posts()) : the_post();
|
||||||
|
|
||||||
comicpress_display_post();
|
comicpress_display_post();
|
||||||
|
|
||||||
endwhile;
|
endwhile;
|
||||||
|
|
||||||
|
}
|
||||||
comicpress_pagination();
|
comicpress_pagination();
|
||||||
|
} else {
|
||||||
|
_e("This page is restricted to members only.",'comicpress');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_e('Member\'s Only content is not enabled on this installation.');
|
||||||
|
}
|
||||||
|
|
||||||
endif; ?>
|
get_sidebar('underblog');
|
||||||
<?php get_sidebar('underblog'); ?>
|
|
||||||
|
|
||||||
<?php include(get_template_directory() . '/layout-foot.php'); ?>
|
include(get_template_directory() . '/layout-foot.php');
|
||||||
<?php get_footer() ?>
|
|
||||||
|
get_footer() ?>
|
||||||
|
|
|
@ -40,6 +40,54 @@
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<table class="widefat">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th colspan="3"><?php _e('Members Only Content','comicpress'); ?></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tr class="alternate">
|
||||||
|
<th scope="row"><label for="enable_members_only"><?php _e('Enable Members Only options?','comicpress'); ?></label></th>
|
||||||
|
<td>
|
||||||
|
<input id="enable_members_only" name="enable_members_only" type="checkbox" value="1" <?php checked(true, $comicpress_options['enable_members_only']); ?> />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?php _e('When enabled this will allow all of the members only code to be active and working.','comicpress'); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row"><label for="enable_members_only_post_comments"><?php _e('Enable Members only comment content?','comicpress'); ?></label></th>
|
||||||
|
<td>
|
||||||
|
<input id="enable_members_only_post_comments" name="enable_members_only_post_comments" type="checkbox" value="1" <?php checked(true, $comicpress_options['enable_members_only_post_comments']); ?> />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?php _e('When enabled this will make all the content of each of the comments available to be seen only by users registered and set as members.','comicpress'); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="alternate">
|
||||||
|
<th scope="row" colspan="2">
|
||||||
|
<label for="members_post_category"><?php _e('Members category','comicpress'); ?></label>
|
||||||
|
<?php
|
||||||
|
$select = wp_dropdown_categories('show_option_none=Select category&show_count=0&orderby=name&echo=0&selected='.$comicpress_options['members_post_category']);
|
||||||
|
$select = preg_replace('#<select([^>]*)>#', '<select name="members_post_category" id="members_post_category">', $select);
|
||||||
|
echo $select;
|
||||||
|
?>
|
||||||
|
</th>
|
||||||
|
<td>
|
||||||
|
<?php _e('The category that is designated to show members only content.','comicpress'); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
<p><?php _e('USAGE: Edit the user with <em>Dashboard -> Users -> Authors & Users</em> and flag the user you want to be a member with the option at the bottom.','comicpress'); ?></p>
|
||||||
|
<p><?php _e('Inside posts, add [members] content you only want members to see [/members]','comicpress'); ?></p>
|
||||||
|
<p><?php _e('When setting a \'members\' category, you *cannot* use an existing comic category, uncategorized, or blog category!','comicpress'); ?></p>
|
||||||
|
<p><?php _e('You MUST create a whole new category and called it "members", then you select that category here and create a page called "Members" or something equivelant and associate the Member\'s Only template to it.','comicpress'); ?></p>
|
||||||
|
<p><?php _e('This will make it so that that category is only seen as blogposts inside that area and not anywhere else on the site unless the user has the members flag.','comicpress'); ?></p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
<table class="widefat">
|
<table class="widefat">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -188,36 +188,6 @@
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<table class="widefat">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th colspan="2"><?php _e('Members Only Content','comicpress'); ?></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tr class="alternate">
|
|
||||||
<th scope="row">
|
|
||||||
<label for="members_post_category"><?php _e('Members category','comicpress'); ?></label>
|
|
||||||
<?php
|
|
||||||
$select = wp_dropdown_categories('show_option_none=Select category&show_count=0&orderby=name&echo=0&selected='.$comicpress_options['members_post_category']);
|
|
||||||
$select = preg_replace('#<select([^>]*)>#', '<select name="members_post_category" id="members_post_category">', $select);
|
|
||||||
echo $select;
|
|
||||||
?>
|
|
||||||
</th>
|
|
||||||
<td>
|
|
||||||
<?php _e('The category that is designated to show members only content.','comicpress'); ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="2">
|
|
||||||
<p><?php _e('USAGE: Edit the user with <em>Dashboard -> Users -> Authors & Users</em> and flag the user you want to be a member with the option at the bottom.','comicpress'); ?></p>
|
|
||||||
<p><?php _e('Inside posts, add [members] content you only want members to see [/members]','comicpress'); ?></p>
|
|
||||||
<p><?php _e('When setting a \'members\' category, you *cannot* use an existing comic category, uncategorized, or blog category!','comicpress'); ?></p>
|
|
||||||
<p><?php _e('You MUST create a whole new category and called it "members", then you select that category here and create a page called "Members" or something equivelant and associate the Member\'s Only template to it.','comicpress'); ?></p>
|
|
||||||
<p><?php _e('This will make it so that that category is only seen as blogposts inside that area and not anywhere else on the site unless the user has the members flag.','comicpress'); ?></p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<table class="widefat">
|
<table class="widefat">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
Loading…
Reference in New Issue