Changeset 425987
- Timestamp:
- 08/19/2011 07:03:01 PM (15 years ago)
- Location:
- wordpress-restrictions
- Files:
-
- 2 edited
- 3 copied
-
tags/0.1.3 (copied) (copied from wordpress-restrictions/trunk)
-
tags/0.1.3/readme.txt (copied) (copied from wordpress-restrictions/trunk/readme.txt) (2 diffs)
-
tags/0.1.3/wp-restrictions.php (copied) (copied from wordpress-restrictions/trunk/wp-restrictions.php) (6 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/wp-restrictions.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wordpress-restrictions/tags/0.1.3/readme.txt
r425713 r425987 3 3 Donate link: http://sonicedges.com/ 4 4 Tags: wordpress, restrictions, permissions, capabilities, users, roles 5 Requires at least: 3. 05 Requires at least: 3.1 6 6 Tested up to: 3.2.1 7 Stable tag: 0.1. 27 Stable tag: 0.1.3 8 8 9 9 WordPress Restrictions allows you to set restrictions on when and what content can be edited/deleted on your WordPress Install. … … 16 16 17 17 <ul> 18 <li>Options to set a timeframe (in days) when editors andauthors can delete or edit posts.</li>18 <li>Options to set a timeframe (in days) when editors / authors can delete or edit posts.</li> 19 19 <li>Options to set a timeframe (in days) when editors can delete or edit pages.</li> 20 20 <li>Options to exclude certain Users, Posts, and Pages from restrictions set within WordPress Restrictions.</li> 21 <li>Options to set a limit on the number of posts an author / edit may make each day.</li> 21 22 </ul> 22 23 -
wordpress-restrictions/tags/0.1.3/wp-restrictions.php
r425713 r425987 4 4 Plugin URI: http://sonicedges.com/plugins/wordpress-restrictions/ 5 5 Description: With WordPress Restrictions, you can specify when and what content may be edited/deleted by Editors and/or Authors. 6 Version: 0.1. 26 Version: 0.1.3 7 7 Author: Brandon Smith 8 8 Author URI: http://sonicedges.com/ 9 9 */ 10 10 11 define('WP_REST_VERSION', '0.1.2'); 11 define('WP_REST_VERSION', '0.1.3'); 12 define('WP_REST_CURR_DAY', date("j")); 13 define('WP_REST_CURR_MONTH', date("n")); 14 define('WP_REST_CURR_YEAR', date("Y")); 15 16 function wp_restrictions() { 17 wp_restrictions::get_user_role(); // Define Current User's Role 18 wp_restrictions::get_user_id(); // Define Current User's ID 19 wp_restrictions_max_posts(); // Restricts # of Posts per Day 20 } 21 22 class wp_restrictions { 23 public function get_user_role() { 24 if (current_user_can('editor') || current_user_can('author')) { 25 if (current_user_can('editor')) { 26 $role = 'editor'; 27 } else { 28 $role = 'author'; 29 } 30 } 31 define('WP_REST_ROLE', $role); 32 } 33 public function get_user_id() { 34 global $current_user; 35 get_currentuserinfo(); 36 $user_id = $current_user->ID; 37 define('WP_REST_UID', $user_id); 38 } 39 } 12 40 13 41 function wp_restrictions_excluded_user($user_id) { … … 249 277 'edit_post' => $_POST['editor_edit_posts'], 250 278 'delete_page' => $_POST['editor_delete_pages'], 251 'edit_page' => $_POST['editor_edit_pages'] 279 'edit_page' => $_POST['editor_edit_pages'], 280 'max_posts' => $_POST['editor_max_posts'] 252 281 ), 253 282 'author' => array( 254 283 'delete_post' => $_POST['author_delete_posts'], 255 'edit_post' => $_POST['author_edit_posts'] 284 'edit_post' => $_POST['author_edit_posts'], 285 'max_posts' => $_POST['author_max_posts'] 256 286 ), 257 287 'excluded' => array( … … 279 309 <h3>WordPress Restrictions</h3> 280 310 <p>I (Brandon Smith) developed WordPress Restrictions to offer an easier and more practicable solution to control what can be edited/deleted on your WordPress Install. While several other plugins already allow you to modify WordPress User Roles and Capabilities, they require that you tweak the default settings of each user role or create a new user role (which can get a bit confusing for the average webmaster). With WordPress Restrictions, you can specify when and what content may be edited by Editors and/or Authors. If you need help or assistance, or would like to submit a feature request, please contact me at btks1995@gmail.com.</p> 281 <form name="w p_role_security" method="POST" action="">311 <form name="wordpress_restrictions" method="POST" action=""> 282 312 <h3>Restrictions for Editors</h3> 283 313 <label>Delete Posts Timeframe (In Days): </label><input type="text" name="editor_delete_posts" value="<?php echo $wp_restrictions['editor']['delete_post']; ?>" /><span style="margin-left: 5px;">Specify a Number of Days. A post published on 8-16-2011 would be deletable by <strong>EDITORS</strong> until 8-20-2011 if the timeframe was 4 Days.</span><br /> … … 285 315 <label>Edit Posts Timeframe (In Days): </label><input type="text" name="editor_edit_posts" value="<?php echo $wp_restrictions['editor']['edit_post']; ?>" /> <span style="margin-left: 5px;">Specify a Number of Days. A post published on 8-16-2011 would be editable by <strong>EDITORS</strong> until 8-20-2011 if the timeframe was 4 Days.</span><br /> 286 316 <label>Edit Pages Timeframe (In Days): </label><input type="text" name="editor_edit_pages" value="<?php echo $wp_restrictions['editor']['edit_page']; ?>" /> <span style="margin-left: 5px;">Specify a Number of Days. A page published on 8-16-2011 would be deletable by <strong>EDITORS</strong> until 8-20-2011 if the timeframe was 4 Days.</span><br /> 317 <label>Max Number of Posts a Day: </label><input type="text" name="editor_max_posts" value="<?php echo $wp_restrictions['editor']['max_posts']; ?>" /> <span style="margin-left: 5px;">Specify a Number. If you input a number of '5', then each <strong>EDITOR</strong> can make up to 5 posts within 24 hours.</span><br /> 287 318 288 319 <h3>Restrictions for Authors</h3> 289 320 <label>Delete Posts Timeframe (In Days): </label><input type="text" name="author_delete_posts" value="<?php echo $wp_restrictions['author']['delete_post']; ?>" /><span style="margin-left: 5px;">Specify a Number of Days. A post published on 8-16-2011 would be deletable by the <strong>AUTHOR</strong> until 8-20-2011 if the timeframe was 4 Days.</span><br /> 290 321 <label>Edit Posts Timeframe (In Days): </label><input type="text" name="author_edit_posts" value="<?php echo $wp_restrictions['author']['edit_post']; ?>" /> <span style="margin-left: 5px;">Specify a Number of Days. A post published on 8-16-2011 would be editable by the <strong>AUTHOR</strong> until 8-20-2011 if the timeframe was 4 Days.</span><br /> 322 <label>Max Number of Posts a Day: </label><input type="text" name="author_max_posts" value="<?php echo $wp_restrictions['author']['max_posts']; ?>" /> <span style="margin-left: 5px;">Specify a Number. If you input a number of '5', then each <strong>AUTHOR</strong> can make up to 5 posts within 24 hours.</span><br /> 291 323 292 324 <h3>Exclude Restrictions</h3> … … 316 348 } 317 349 350 function wp_restrictions_max_posts() { 351 global $wp_query; 352 if (WP_REST_ROLE == 'editor' || WP_REST_ROLE == 'author' && !wp_restrictions_excluded_user(WP_REST_UID)) { 353 $wp_query = new WP_Query(array('author' => WP_REST_UID, 'monthnum' => WP_REST_CURR_MONTH, 'day' => WP_REST_CURR_DAY, 'year' => WP_REST_CURR_YEAR)); 354 while($wp_query->have_posts()) : $wp_query->the_post(); 355 $post_count = $wp_query->post_count; 356 endwhile; 357 wp_reset_postdata(); 358 359 $wp_restrictions = get_option('wp_restrictions'); 360 $max_posts = $wp_restrictions[WP_REST_ROLE]['max_posts']; 361 362 if ($post_count >= $wp_restrictions[WP_REST_ROLE]['max_posts']) { 363 remove_submenu_page('edit.php', 'post-new.php'); 364 365 if (strpos($_SERVER['REQUEST_URI'], 'post-new.php')) { 366 wp_die("You're only allowed to publish $max_posts posts within 24 hours. Please try again tomorrow."); 367 } 368 } 369 } 370 } 371 318 372 function wp_restrictions_uninstall() { 319 373 delete_option('wp_restrictions'); … … 321 375 } 322 376 323 add_action('admin_init', 'wp_restrictions_user_role'); 377 // WordPress Restrictions Actions 378 add_action('admin_init', 'wp_restrictions'); 324 379 add_action('admin_menu', 'wp_restrictions_menu'); 380 381 // WordPress Restrictions Filters 325 382 add_filter('map_meta_cap', 'wp_restrictions_mmc', 10, 4); 326 383 -
wordpress-restrictions/trunk/readme.txt
r425713 r425987 3 3 Donate link: http://sonicedges.com/ 4 4 Tags: wordpress, restrictions, permissions, capabilities, users, roles 5 Requires at least: 3. 05 Requires at least: 3.1 6 6 Tested up to: 3.2.1 7 Stable tag: 0.1. 27 Stable tag: 0.1.3 8 8 9 9 WordPress Restrictions allows you to set restrictions on when and what content can be edited/deleted on your WordPress Install. … … 16 16 17 17 <ul> 18 <li>Options to set a timeframe (in days) when editors andauthors can delete or edit posts.</li>18 <li>Options to set a timeframe (in days) when editors / authors can delete or edit posts.</li> 19 19 <li>Options to set a timeframe (in days) when editors can delete or edit pages.</li> 20 20 <li>Options to exclude certain Users, Posts, and Pages from restrictions set within WordPress Restrictions.</li> 21 <li>Options to set a limit on the number of posts an author / edit may make each day.</li> 21 22 </ul> 22 23 -
wordpress-restrictions/trunk/wp-restrictions.php
r425713 r425987 4 4 Plugin URI: http://sonicedges.com/plugins/wordpress-restrictions/ 5 5 Description: With WordPress Restrictions, you can specify when and what content may be edited/deleted by Editors and/or Authors. 6 Version: 0.1. 26 Version: 0.1.3 7 7 Author: Brandon Smith 8 8 Author URI: http://sonicedges.com/ 9 9 */ 10 10 11 define('WP_REST_VERSION', '0.1.2'); 11 define('WP_REST_VERSION', '0.1.3'); 12 define('WP_REST_CURR_DAY', date("j")); 13 define('WP_REST_CURR_MONTH', date("n")); 14 define('WP_REST_CURR_YEAR', date("Y")); 15 16 function wp_restrictions() { 17 wp_restrictions::get_user_role(); // Define Current User's Role 18 wp_restrictions::get_user_id(); // Define Current User's ID 19 wp_restrictions_max_posts(); // Restricts # of Posts per Day 20 } 21 22 class wp_restrictions { 23 public function get_user_role() { 24 if (current_user_can('editor') || current_user_can('author')) { 25 if (current_user_can('editor')) { 26 $role = 'editor'; 27 } else { 28 $role = 'author'; 29 } 30 } 31 define('WP_REST_ROLE', $role); 32 } 33 public function get_user_id() { 34 global $current_user; 35 get_currentuserinfo(); 36 $user_id = $current_user->ID; 37 define('WP_REST_UID', $user_id); 38 } 39 } 12 40 13 41 function wp_restrictions_excluded_user($user_id) { … … 249 277 'edit_post' => $_POST['editor_edit_posts'], 250 278 'delete_page' => $_POST['editor_delete_pages'], 251 'edit_page' => $_POST['editor_edit_pages'] 279 'edit_page' => $_POST['editor_edit_pages'], 280 'max_posts' => $_POST['editor_max_posts'] 252 281 ), 253 282 'author' => array( 254 283 'delete_post' => $_POST['author_delete_posts'], 255 'edit_post' => $_POST['author_edit_posts'] 284 'edit_post' => $_POST['author_edit_posts'], 285 'max_posts' => $_POST['author_max_posts'] 256 286 ), 257 287 'excluded' => array( … … 279 309 <h3>WordPress Restrictions</h3> 280 310 <p>I (Brandon Smith) developed WordPress Restrictions to offer an easier and more practicable solution to control what can be edited/deleted on your WordPress Install. While several other plugins already allow you to modify WordPress User Roles and Capabilities, they require that you tweak the default settings of each user role or create a new user role (which can get a bit confusing for the average webmaster). With WordPress Restrictions, you can specify when and what content may be edited by Editors and/or Authors. If you need help or assistance, or would like to submit a feature request, please contact me at btks1995@gmail.com.</p> 281 <form name="w p_role_security" method="POST" action="">311 <form name="wordpress_restrictions" method="POST" action=""> 282 312 <h3>Restrictions for Editors</h3> 283 313 <label>Delete Posts Timeframe (In Days): </label><input type="text" name="editor_delete_posts" value="<?php echo $wp_restrictions['editor']['delete_post']; ?>" /><span style="margin-left: 5px;">Specify a Number of Days. A post published on 8-16-2011 would be deletable by <strong>EDITORS</strong> until 8-20-2011 if the timeframe was 4 Days.</span><br /> … … 285 315 <label>Edit Posts Timeframe (In Days): </label><input type="text" name="editor_edit_posts" value="<?php echo $wp_restrictions['editor']['edit_post']; ?>" /> <span style="margin-left: 5px;">Specify a Number of Days. A post published on 8-16-2011 would be editable by <strong>EDITORS</strong> until 8-20-2011 if the timeframe was 4 Days.</span><br /> 286 316 <label>Edit Pages Timeframe (In Days): </label><input type="text" name="editor_edit_pages" value="<?php echo $wp_restrictions['editor']['edit_page']; ?>" /> <span style="margin-left: 5px;">Specify a Number of Days. A page published on 8-16-2011 would be deletable by <strong>EDITORS</strong> until 8-20-2011 if the timeframe was 4 Days.</span><br /> 317 <label>Max Number of Posts a Day: </label><input type="text" name="editor_max_posts" value="<?php echo $wp_restrictions['editor']['max_posts']; ?>" /> <span style="margin-left: 5px;">Specify a Number. If you input a number of '5', then each <strong>EDITOR</strong> can make up to 5 posts within 24 hours.</span><br /> 287 318 288 319 <h3>Restrictions for Authors</h3> 289 320 <label>Delete Posts Timeframe (In Days): </label><input type="text" name="author_delete_posts" value="<?php echo $wp_restrictions['author']['delete_post']; ?>" /><span style="margin-left: 5px;">Specify a Number of Days. A post published on 8-16-2011 would be deletable by the <strong>AUTHOR</strong> until 8-20-2011 if the timeframe was 4 Days.</span><br /> 290 321 <label>Edit Posts Timeframe (In Days): </label><input type="text" name="author_edit_posts" value="<?php echo $wp_restrictions['author']['edit_post']; ?>" /> <span style="margin-left: 5px;">Specify a Number of Days. A post published on 8-16-2011 would be editable by the <strong>AUTHOR</strong> until 8-20-2011 if the timeframe was 4 Days.</span><br /> 322 <label>Max Number of Posts a Day: </label><input type="text" name="author_max_posts" value="<?php echo $wp_restrictions['author']['max_posts']; ?>" /> <span style="margin-left: 5px;">Specify a Number. If you input a number of '5', then each <strong>AUTHOR</strong> can make up to 5 posts within 24 hours.</span><br /> 291 323 292 324 <h3>Exclude Restrictions</h3> … … 316 348 } 317 349 350 function wp_restrictions_max_posts() { 351 global $wp_query; 352 if (WP_REST_ROLE == 'editor' || WP_REST_ROLE == 'author' && !wp_restrictions_excluded_user(WP_REST_UID)) { 353 $wp_query = new WP_Query(array('author' => WP_REST_UID, 'monthnum' => WP_REST_CURR_MONTH, 'day' => WP_REST_CURR_DAY, 'year' => WP_REST_CURR_YEAR)); 354 while($wp_query->have_posts()) : $wp_query->the_post(); 355 $post_count = $wp_query->post_count; 356 endwhile; 357 wp_reset_postdata(); 358 359 $wp_restrictions = get_option('wp_restrictions'); 360 $max_posts = $wp_restrictions[WP_REST_ROLE]['max_posts']; 361 362 if ($post_count >= $wp_restrictions[WP_REST_ROLE]['max_posts']) { 363 remove_submenu_page('edit.php', 'post-new.php'); 364 365 if (strpos($_SERVER['REQUEST_URI'], 'post-new.php')) { 366 wp_die("You're only allowed to publish $max_posts posts within 24 hours. Please try again tomorrow."); 367 } 368 } 369 } 370 } 371 318 372 function wp_restrictions_uninstall() { 319 373 delete_option('wp_restrictions'); … … 321 375 } 322 376 323 add_action('admin_init', 'wp_restrictions_user_role'); 377 // WordPress Restrictions Actions 378 add_action('admin_init', 'wp_restrictions'); 324 379 add_action('admin_menu', 'wp_restrictions_menu'); 380 381 // WordPress Restrictions Filters 325 382 add_filter('map_meta_cap', 'wp_restrictions_mmc', 10, 4); 326 383
Note: See TracChangeset
for help on using the changeset viewer.