WordPress.org

Plugin Directory

Changeset 626429


Ignore:
Timestamp:
11/17/12 12:45:30 (17 months ago)
Author:
bainternet
Message:

fixed post type any bug, and tagged 2.8

Location:
bainternet-posts-creation-limits
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • bainternet-posts-creation-limits/tags/2.8/bapl.php

    r624539 r626429  
    44Plugin URI: http://en.bainternet.info/category/plugins 
    55Description: this plugin helps you to limit the number of posts/pages/custom post types each user can create on your site. 
    6 Version: 2.7 
     6Version: 2.8 
    77Author: bainternet 
    88Author URI: http://en.bainternet.info 
     
    110110            if ($rules_BY_ANY){ 
    111111                foreach((array)$rules_BY_ANY as $ke => $arr){ 
    112                     if ($arr['post_type'] == $type){ 
     112                    if ($arr['post_type'] == $type || $arr['post_type'] == "any"){ 
    113113                        //$count_posts = get_posts(array('author'=>$user_id,'post_type' => $type,'post_status' => $arr['status'],'fields' => 'ids')); 
     114                        $ptype = ($arr['post_type'] == 'any')? "IN ('".implode("', '",get_post_types('', 'names')). "')" : " = '".$arr['post_type']."'"; 
    114115                        $time = (isset($arr['time_span']) && $arr['time_span'] != "FOREVER" ) ? " AND TIMEDIFF(NOW(), post_date) < '".$arr['time_span']."'" : ""; 
    115116                        $pstatus = ($arr['status'] == 'any') ? "IN ('publish', 'pending', 'draft', 'future', 'private', 'trash')": " = '".$arr['status']."'"; 
    116                         $count = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->posts WHERE post_status ". $pstatus ." AND post_author = $user_id AND post_type = '$type'".$time); 
     117                        $count = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->posts WHERE post_status ". $pstatus ." AND post_author = $user_id AND post_type $ptype".$time); 
    117118                        if($count >= $arr['limit']){ 
    118119                            if ($use_m) 
     
    129130            if ($rules_BY_roles){ 
    130131                foreach((array)$rules_BY_roles as $ke => $arr){ 
    131                     if ($arr['post_type'] == $type){ 
     132                    if ($arr['post_type'] == $type || $arr['post_type'] == "any"){ 
    132133                        //$count_posts = get_posts(array('author'=>$user_id,'post_type' => $type,'post_status' => $arr['status'],'fields' => 'ids')); 
    133                         //$count = count($count_posts); 
     134                        $ptype = ($arr['post_type'] == 'any')? "IN ('".implode("', '",get_post_types('', 'names')). "')" : " = '".$arr['post_type']."'"; 
    134135                        $time = (isset($arr['time_span']) && $arr['time_span'] != "FOREVER" ) ? " AND TIMEDIFF(NOW(), post_date) < '".$arr['time_span']."'" : ""; 
    135136                        $pstatus = ($arr['status'] == 'any') ? "IN ('publish', 'pending', 'draft', 'future', 'private', 'trash')": " = '".$arr['status']."'"; 
    136                         $count = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->posts WHERE post_status ". $pstatus ." AND post_author = $user_id AND post_type = '$type'".$time); 
     137                        $count = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->posts WHERE post_status ". $pstatus ." AND post_author = $user_id AND post_type $ptype".$time); 
    137138                        if($count >= $arr['limit']){ 
    138139                            if ($use_m) 
     
    148149            if ($rules_BY_id){ 
    149150                foreach((array)$rules_BY_id as $ke => $arr){ 
    150                     if ($arr['post_type'] == $type){ 
     151                    if ($arr['post_type'] == $type || $arr['post_type'] == "any"){ 
     152                        $ptype = ($arr['post_type'] == 'any')? "IN ('".implode("', '",get_post_types('', 'names')). "')" : " = '".$arr['post_type']."'"; 
    151153                        $time = (isset($arr['time_span']) && $arr['time_span'] != "FOREVER" ) ? " AND TIMEDIFF(NOW(), post_date) < '".$arr['time_span']."'" : ""; 
    152154                        $pstatus = ($arr['status'] == 'any') ? "IN ('publish', 'pending', 'draft', 'future', 'private', 'trash')": " = '".$arr['status']."'"; 
    153                         $count = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->posts WHERE post_status ". $pstatus ." AND post_author = $user_id AND post_type = '$type'".$time); 
     155                        $count = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->posts WHERE post_status ". $pstatus ." AND post_author = $user_id AND post_type $ptype".$time); 
    154156                        if($count >= $arr['limit']){ 
    155157                            if ($use_m) 
  • bainternet-posts-creation-limits/tags/2.8/readme.txt

    r624539 r626429  
    55Requires at least: 3.0 
    66Tested up to: 3.5 beta 1 
    7 Stable tag: 2.7 
     7Stable tag: 2.8 
    88 
    99this plugin helps you to limit the number of posts/pages/custom post types each user can create on your site. 
     
    119119 
    120120== Changelog == 
     1212.8 Fixed post type "any" limitation bug. 
     122 
    1211232.7 Fixed Missing argument 2 for bapl::limit_xml_rpc() issue. 
    122124 
  • bainternet-posts-creation-limits/trunk/bapl.php

    r624539 r626429  
    44Plugin URI: http://en.bainternet.info/category/plugins 
    55Description: this plugin helps you to limit the number of posts/pages/custom post types each user can create on your site. 
    6 Version: 2.7 
     6Version: 2.8 
    77Author: bainternet 
    88Author URI: http://en.bainternet.info 
     
    110110            if ($rules_BY_ANY){ 
    111111                foreach((array)$rules_BY_ANY as $ke => $arr){ 
    112                     if ($arr['post_type'] == $type){ 
     112                    if ($arr['post_type'] == $type || $arr['post_type'] == "any"){ 
    113113                        //$count_posts = get_posts(array('author'=>$user_id,'post_type' => $type,'post_status' => $arr['status'],'fields' => 'ids')); 
     114                        $ptype = ($arr['post_type'] == 'any')? "IN ('".implode("', '",get_post_types('', 'names')). "')" : " = '".$arr['post_type']."'"; 
    114115                        $time = (isset($arr['time_span']) && $arr['time_span'] != "FOREVER" ) ? " AND TIMEDIFF(NOW(), post_date) < '".$arr['time_span']."'" : ""; 
    115116                        $pstatus = ($arr['status'] == 'any') ? "IN ('publish', 'pending', 'draft', 'future', 'private', 'trash')": " = '".$arr['status']."'"; 
    116                         $count = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->posts WHERE post_status ". $pstatus ." AND post_author = $user_id AND post_type = '$type'".$time); 
     117                        $count = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->posts WHERE post_status ". $pstatus ." AND post_author = $user_id AND post_type $ptype".$time); 
    117118                        if($count >= $arr['limit']){ 
    118119                            if ($use_m) 
     
    129130            if ($rules_BY_roles){ 
    130131                foreach((array)$rules_BY_roles as $ke => $arr){ 
    131                     if ($arr['post_type'] == $type){ 
     132                    if ($arr['post_type'] == $type || $arr['post_type'] == "any"){ 
    132133                        //$count_posts = get_posts(array('author'=>$user_id,'post_type' => $type,'post_status' => $arr['status'],'fields' => 'ids')); 
    133                         //$count = count($count_posts); 
     134                        $ptype = ($arr['post_type'] == 'any')? "IN ('".implode("', '",get_post_types('', 'names')). "')" : " = '".$arr['post_type']."'"; 
    134135                        $time = (isset($arr['time_span']) && $arr['time_span'] != "FOREVER" ) ? " AND TIMEDIFF(NOW(), post_date) < '".$arr['time_span']."'" : ""; 
    135136                        $pstatus = ($arr['status'] == 'any') ? "IN ('publish', 'pending', 'draft', 'future', 'private', 'trash')": " = '".$arr['status']."'"; 
    136                         $count = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->posts WHERE post_status ". $pstatus ." AND post_author = $user_id AND post_type = '$type'".$time); 
     137                        $count = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->posts WHERE post_status ". $pstatus ." AND post_author = $user_id AND post_type $ptype".$time); 
    137138                        if($count >= $arr['limit']){ 
    138139                            if ($use_m) 
     
    148149            if ($rules_BY_id){ 
    149150                foreach((array)$rules_BY_id as $ke => $arr){ 
    150                     if ($arr['post_type'] == $type){ 
     151                    if ($arr['post_type'] == $type || $arr['post_type'] == "any"){ 
     152                        $ptype = ($arr['post_type'] == 'any')? "IN ('".implode("', '",get_post_types('', 'names')). "')" : " = '".$arr['post_type']."'"; 
    151153                        $time = (isset($arr['time_span']) && $arr['time_span'] != "FOREVER" ) ? " AND TIMEDIFF(NOW(), post_date) < '".$arr['time_span']."'" : ""; 
    152154                        $pstatus = ($arr['status'] == 'any') ? "IN ('publish', 'pending', 'draft', 'future', 'private', 'trash')": " = '".$arr['status']."'"; 
    153                         $count = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->posts WHERE post_status ". $pstatus ." AND post_author = $user_id AND post_type = '$type'".$time); 
     155                        $count = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->posts WHERE post_status ". $pstatus ." AND post_author = $user_id AND post_type $ptype".$time); 
    154156                        if($count >= $arr['limit']){ 
    155157                            if ($use_m) 
  • bainternet-posts-creation-limits/trunk/readme.txt

    r624539 r626429  
    55Requires at least: 3.0 
    66Tested up to: 3.5 beta 1 
    7 Stable tag: 2.7 
     7Stable tag: 2.8 
    88 
    99this plugin helps you to limit the number of posts/pages/custom post types each user can create on your site. 
     
    119119 
    120120== Changelog == 
     1212.8 Fixed post type "any" limitation bug. 
     122 
    1211232.7 Fixed Missing argument 2 for bapl::limit_xml_rpc() issue. 
    122124 
Note: See TracChangeset for help on using the changeset viewer.