WordPress.org

Plugin Directory

Changeset 1377298


Ignore:
Timestamp:
03/23/16 19:31:30 (18 months ago)
Author:
sladix
Message:

Fixed bugs

Location:
restrict-taxonomies
Files:
8 added
3 edited

Legend:

Unmodified
Added
Removed
  • restrict-taxonomies/trunk/README.md

    r1376674 r1377298  
    77* Requires at least: 3.1 
    88* Tested up to: 4.4.2 
    9 * Stable tag: 1.2.9 
     9* Stable tag: 1.3.0 
    1010* License: GPLv2 or later 
    1111* License URI: http://www.gnu.org/licenses/gpl-2.0.html 
  • restrict-taxonomies/trunk/readme.txt

    r1376674 r1377298  
    55Requires at least: 3.1 
    66Tested up to: 4.4.2 
    7 Stable tag: 1.2.9 
     7Stable tag: 1.3.0 
    88License: GPLv2 or later 
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html 
     
    1313== Description == 
    1414 
    15 Based on the Restrict Categories plugin, this plugin allows you to restrict the taxonomies terms that users or roles can use when they publish content. 
     15Based on the Restrict Categories plugin, this plugin allows you to restrict the taxonomies terms that users or roles can use when they publish content. It also provide front end restriction for non logged users. 
    1616 
    1717== Installation == 
     
    21211. Configure the plugin in Settings > Restrict Taxonomies 
    22221. Choose the taxonomies *AND* the corresponding post types 
     231. Activate (or don't, as you wish) the front end rescrictions 
    2324 
    2425== Frequently Asked Questions == 
     
    34354. Should the plugin restrict taxonomies in the front end ? 
    3536 
     37== ToDo List == 
     381. Prevent the user from accessing the single view of a CPT that is in a disallowed taxonomy 
     39 
    3640== Changelog == 
     41 
     42= 1.3.0 = 
     43* Fixed warnings on the plugin activation thanks to Gavin 
     44* Fixed bug when only a empty taxonomy is allowed 
    3745 
    3846= 1.2.9 = 
  • restrict-taxonomies/trunk/restrict-taxonomies.php

    r1376675 r1377298  
    55Author: Sladix 
    66Author URI: https://twitter.com/sladix 
    7 Version: 1.2.9 
     7Version: 1.3.0 
    88*/ 
    99 
     
    604604        // Get handled taxonomies 
    605605        $options = get_option('RestrictTaxs_post_type_options'); 
     606        if(!is_array($options)) 
     607        { 
     608            $options = array( 
     609                'post_types'    =>  array(), 
     610                'taxonomies'    =>  array() 
     611            ); 
     612        } 
    606613        $taxs = get_object_taxonomies( $this->get_current_post_type(), 'names' ); 
    607614        $lestax = array_intersect($taxs, $options['taxonomies']); 
     
    695702    public function posts_query( $query ){ 
    696703        if ( count($this->cat_list) > 0) { 
    697  
    698704            // Make sure the posts are removed by default or if filter category is ran 
    699705            $taxs = get_object_taxonomies( $this->get_current_post_type(), 'names' ); 
     
    738744        $str = rtrim($str, ","); 
    739745        $str_cats = rtrim($str_cats,","); 
    740         $excluded = " AND ( t.term_id IN ( $str_cats ) OR tt.taxonomy NOT IN ( $str ) )"; 
     746 
     747        //If there is no posts in the allowed categories, don't display any 
     748        if(!empty($str_cats)) 
     749            $excluded = " AND ( t.term_id IN ( $str_cats ) OR tt.taxonomy NOT IN ( $str ) )"; 
     750        else 
     751            $excluded = " AND t.term_id = 0"; 
     752 
    741753        return $excluded; 
    742754    } 
Note: See TracChangeset for help on using the changeset viewer.