Plugin Directory

Changeset 347478


Ignore:
Timestamp:
02/18/2011 07:58:28 PM (15 years ago)
Author:
OsExpert.net
Message:
 
Location:
wp-post-limiter
Files:
4 added
2 edited

Legend:

Unmodified
Added
Removed
  • wp-post-limiter/trunk/readme.txt

    r225257 r347478  
    33Donate link: http://saquery.com/wordpress
    44Tags: Limit Posts, Maximum Posts, Restrict Posts
    5 Requires at least: 2.0.2
    6 Tested up to: 2.7.1
    7 Stable tag: 0.2
     5Requires at least: 3.0.5
     6Tested up to: 3.0.5
     7Stable tag: 1.0
    88
    99Restrict the number of possible posts for a Wordpress user.
  • wp-post-limiter/trunk/wp-post-limiter.php

    r225257 r347478  
    44Plugin URI: http://saquery.com/wordpress
    55Description: WP Post Limiter
    6 Version: 0.2
     6Version: 1.0
    77Author: Stephan Ahlf
    88Author URI: http://saquery.com
     
    1010
    1111/*
    12 Copyright 2009 Stephan Ahlf
     12Copyright 2009-2011 Stephan Ahlf
    1313
    1414This program is free software; you can redistribute it and/or modify
     
    3939    function saqPostLimitOptions(){
    4040        global $saq_postlimit_options;
    41         if($_POST['saq_save']){
     41        if(isset($_POST['saq_save'])){
    4242            $default_limit = (int)$_POST['default_limit'];
    4343                $saq_postlimit_options["default_limit"] = $default_limit;
     
    6060    function saqGetPostCountInfo(){
    6161        global $wpdb;
    62         return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = ".wp_get_current_user()->ID);
     62        return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status='publish' and post_author = ".wp_get_current_user()->ID);
    6363    }
    6464
    6565    function saqPostLimiter_admin_menu(){
    6666        global $menu, $submenu,$saq_postlimit_options;
    67 
    68             add_submenu_page('options-general.php', 'Post Limiter', 'Post Limiter', 8, __FILE__, 'saqPostLimitOptions');
     67       
     68        add_submenu_page('options-general.php', 'Post Limiter', 'Post Limiter', 'administrator', __FILE__, 'saqPostLimitOptions' );
    6969        if (wp_get_current_user()->ID!=1) {
    7070            $numposts = saqGetPostCountInfo();
    7171            foreach ($menu as $index => $item) {
    7272                if ($item[2] == 'index.php' ){
    73                     unset($menu[$index]);
     73                    //unset($menu[$index]);
    7474                    if (saqPostLimiter_isPage('index')) {
    7575                        wp_redirect(get_option('siteurl') . '/wp-admin/profile.php');
     
    9999        $curr = strtolower($_SERVER["REQUEST_URI"]);
    100100        if ($curr == '/wp-admin/') $curr.="index.php";
    101         return $curr=='/wp-admin/'.$p.'.php';
     101        return basename($curr)==$p.'.php';
    102102    }
    103103
     
    106106        if (wp_get_current_user()->ID!=1) {
    107107            if (saqPostLimiter_isPage('post-new')) {
     108
    108109                $postCount=saqGetPostCountInfo();
    109110                if ($postCount>=$saq_postlimit_options["default_limit"]){
    110                     print '<p>Permission denied. Your account is limited to '.$saq_postlimit_options["default_limit"].' posts. Your personal Postcount: '.$postCount.'. <a href="/wp-admin/profile.php">Back...</a></p>';
     111                    print '<p>Permission denied. Your account is limited to '.$saq_postlimit_options["default_limit"].' posts. Your personal Postcount: '.$postCount.'. <a href="javascript_void(0);" onclick="history.back()">Back...</a></p>';
    111112                    exit;
    112113                }
Note: See TracChangeset for help on using the changeset viewer.