Page Restrict - Version 2.02

Version Description

Download this release

Release Info

Developer theandystratton
Plugin Icon wp plugin Page Restrict
Version 2.02
Comparing to
See all releases

Code changes from version 2.01 to 2.02

Files changed (3) hide show
  1. inc/admin.php +26 -11
  2. pagerestrict.php +1 -1
  3. readme.txt +1 -1
inc/admin.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://sivel.net/wordpress/
5
  */
6
 
7
  //
8
- $pr_version = '2.01';
9
 
10
  // Full path and plugin basename of the main plugin file
11
  $pr_plugin_file = dirname ( dirname ( __FILE__ ) ) . '/pagerestrict.php';
@@ -191,18 +191,23 @@ function pr_admin_page () {
191
  */
192
  function page_restriction_status_meta_box ( $post ) {
193
  $post_ID = $post->ID;
194
- $page_ids = pr_get_opt ( 'pages' );
 
 
 
 
 
195
  if ( ! is_array ( $page_ids ) )
196
  $page_ids = array ();
197
  ?>
198
  <p>
199
  <input name="pr" type="hidden" value="update" />
200
  <label for="restriction_status" class="selectit">
201
- <input type="checkbox" name="restriction_status" id="restriction_status"<?php if ( in_array ( $post_ID , pr_get_opt ( 'pages' ) ) ) echo ' checked="checked"'; ?>/>
202
- Restrict Page
203
  </label>
204
  </p>
205
- <p>These settings apply to this page only. For a full list of restriction statuses see the <a href="options-general.php?page=pagerestrict">global options page</a>.</p>
206
  <?php
207
  }
208
 
@@ -211,6 +216,7 @@ function page_restriction_status_meta_box ( $post ) {
211
  */
212
  function pr_meta_box () {
213
  add_meta_box ( 'pagerestrictionstatusdiv' , 'Restriction' , 'page_restriction_status_meta_box' , 'page' , 'normal' , 'high' );
 
214
  }
215
 
216
  /**
@@ -219,14 +225,23 @@ function pr_meta_box () {
219
  function pr_meta_save () {
220
  if ( isset ( $_POST['pr'] ) && $_POST['pr'] == 'update' ) :
221
  $post_ID = $_POST['post_ID'];
222
- $restricted_pages = pr_get_opt ( 'pages' );
223
- if ( ! is_array ( $restricted_pages ) )
224
- $restricted_pages = array ();
 
 
 
 
 
 
 
 
 
225
  if ( ! empty ( $_POST['restriction_status'] ) && $_POST['restriction_status'] == 'on' ) :
226
- $restricted_pages[] = $post_ID ;
227
- $pr_options['pages'] = $restricted_pages;
228
  else :
229
- $pr_options['pages'] = array_filter ( $restricted_pages , 'pr_array_delete' );
230
  endif;
231
  $pr_options['loginform'] = pr_get_opt ( 'loginform' );
232
  $pr_options['method'] = pr_get_opt ( 'method' );
5
  */
6
 
7
  //
8
+ $pr_version = '2.02';
9
 
10
  // Full path and plugin basename of the main plugin file
11
  $pr_plugin_file = dirname ( dirname ( __FILE__ ) ) . '/pagerestrict.php';
191
  */
192
  function page_restriction_status_meta_box ( $post ) {
193
  $post_ID = $post->ID;
194
+ if ( $post->post_type == 'page' ) {
195
+ $the_IDs = pr_get_opt ('pages');
196
+ }
197
+ else {
198
+ $the_IDs = pr_get_opt ('posts');
199
+ }
200
  if ( ! is_array ( $page_ids ) )
201
  $page_ids = array ();
202
  ?>
203
  <p>
204
  <input name="pr" type="hidden" value="update" />
205
  <label for="restriction_status" class="selectit">
206
+ <input type="checkbox" name="restriction_status" id="restriction_status"<?php if ( in_array ( $post_ID , $the_IDs ) ) echo ' checked="checked"'; ?>/>
207
+ Restrict <?php echo $post->post_type == 'post' ? 'Post' : 'Page'; ?>
208
  </label>
209
  </p>
210
+ <p>These settings apply to this <?php echo $post->post_type == 'post' ? 'post' : 'page'; ?> only. For a full list of restriction statuses see the <a href="options-general.php?page=pagerestrict">global options page</a>.</p>
211
  <?php
212
  }
213
 
216
  */
217
  function pr_meta_box () {
218
  add_meta_box ( 'pagerestrictionstatusdiv' , 'Restriction' , 'page_restriction_status_meta_box' , 'page' , 'normal' , 'high' );
219
+ add_meta_box ( 'pagerestrictionstatusdiv' , 'Restriction' , 'page_restriction_status_meta_box' , 'post' , 'normal' , 'high' );
220
  }
221
 
222
  /**
225
  function pr_meta_save () {
226
  if ( isset ( $_POST['pr'] ) && $_POST['pr'] == 'update' ) :
227
  $post_ID = $_POST['post_ID'];
228
+ $post = get_post($post_ID);
229
+ if ( $post->post_type == 'page' ) {
230
+ $restrict_type = 'pages';
231
+ }
232
+ else {
233
+ $restrict_type = 'posts';
234
+ }
235
+ $pr_options['pages'] = pr_get_opt('pages');
236
+ $pr_options['posts'] = pr_get_opt('posts');
237
+ $restricted = $pr_options[ $restrict_type ];
238
+ if ( ! is_array ( $restricted ) )
239
+ $restricted = array ();
240
  if ( ! empty ( $_POST['restriction_status'] ) && $_POST['restriction_status'] == 'on' ) :
241
+ $restricted[] = $post_ID ;
242
+ $pr_options[ $restrict_type ] = $restricted;
243
  else :
244
+ $pr_options[ $restrict_type ] = array_filter ( $restricted , 'pr_array_delete' );
245
  endif;
246
  $pr_options['loginform'] = pr_get_opt ( 'loginform' );
247
  $pr_options['method'] = pr_get_opt ( 'method' );
pagerestrict.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://theandystratton.com/pagerestrict
5
  Description: Restrict certain pages to logged in users
6
  Author: Matt Martz & Andy Stratton
7
  Author URI: http://theandystratton.com
8
- Version: 2.01
9
 
10
  Copyright (c) 2008 Matt Martz (http://sivel.net)
11
  Page Restrict is released under the GNU Lesser General Public License (LGPL)
5
  Description: Restrict certain pages to logged in users
6
  Author: Matt Martz & Andy Stratton
7
  Author URI: http://theandystratton.com
8
+ Version: 2.02
9
 
10
  Copyright (c) 2008 Matt Martz (http://sivel.net)
11
  Page Restrict is released under the GNU Lesser General Public License (LGPL)
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: theandystratton, sivel
3
  Tags: pages, page, restrict, restriction, logged in, cms
4
  Requires at least: 2.6
5
  Tested up to: 2.9
6
- Stable tag: 2.01
7
 
8
  Restrict certain pages or posts to logged in users.
9
 
3
  Tags: pages, page, restrict, restriction, logged in, cms
4
  Requires at least: 2.6
5
  Tested up to: 2.9
6
+ Stable tag: 2.02
7
 
8
  Restrict certain pages or posts to logged in users.
9