Plugin Directory

Changeset 1812588


Ignore:
Timestamp:
01/31/2018 09:49:15 AM (8 years ago)
Author:
clarionwpdeveloper
Message:

Version Upgrade & tested compatibility with latest stable versions 4.9.2.

Location:
author-filters/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • author-filters/trunk/author-filters.php

    r1462179 r1812588  
    11<?php
    22/**
    3     * Plugin Name: Author Filters
    4     * Version: 2.0.0
    5     * Description: Author filters plugin integrates an author filter drop down to sort listing with respect to an author on post, page, custom post type in administration.
    6     * Author: Clarion Technologies
    7     * Author URI: http://www.clariontechnologies.co.in
    8     * Plugin URI: https://wordpress.org/plugins/author-filters
    9     * Text Domain: author-filters
    10     * @package Author Filters
     3 * @package Author Filters
    114 */
     5/*
     6/*
     7Plugin Name: Author Filters
     8Version: 3.0.0
     9Description: Author filters plugin integrates an author filter drop down to sort listing with respect to an author on post, page, custom post type in administration.
     10Author: Clarion Technologies
     11Author URI: http://www.clariontechnologies.co.in
     12Plugin URI: https://wordpress.org/plugins/author-filters
     13Text Domain: author-filters
     14*/
    1215
    13     defined('ABSPATH') or die('Direct Access Restricted!'); // Check point to restrict direct access to the file
    14    
    15     /*
    16         Class: author_filters
    17     */
     16/*
     17This program is free software; you can redistribute it and/or
     18modify it under the terms of the GNU General Public License
     19as published by the Clarion Technologies; either version 2
     20of the License, or (at your option) any later version.
    1821
    19     class author_filters{
    20        
    21         /*
    22             Function: author_filters_install
    23             Description: 
    24                 * function is attached to plugin activation hook,
    25                 * performs pre-configuration activities
    26         */
     22You should have received a copy of the GNU General Public License
     23along with this program; if not, write to the Clarion Technologies.
    2724
    28         public static function author_filters_install() {
     25Copyright 2005-2018  Clarion Technologies.
     26*/
     27defined('ABSPATH') or die('Direct Access Restricted!'); // Check point to restrict direct access to the file
    2928
    30             // Clear the permalinks after the post type has been registered
    31             flush_rewrite_rules();
    32         }
     29// Make sure we don't expose any info if called directly
     30if ( !function_exists( 'add_action' ) ) {
     31    echo 'Hi there!  I\'m just a plugin, not much I can do when called directly.';
     32    exit;
     33}
    3334
    34         /*
    35             Function: author_filters_deactivation
    36             Description: 
    37                 * function is attached to plugin deactivation hook,
    38                 * a call to flush_rewrite_rules function is done to Clear the permalinks to remove rewrite rules
    39         */
    40        
    41         public static function author_filters_deactivation() {
     35define( 'AUTHOR_FILTER__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
     36 
     37register_activation_hook( __FILE__, array( 'authorFilters', 'plugin_activation' ) );
     38register_deactivation_hook( __FILE__, array( 'authorFilters', 'plugin_deactivation' ) ); 
    4239
    43             // Clear the permalinks to remove our post type's rules
    44             flush_rewrite_rules();
    45         }
     40require_once( AUTHOR_FILTER__PLUGIN_DIR . 'class.authorfilter.php' );
    4641
    47         /*
    48             Function: author_filters_post_types
    49             Description: 
    50                 * function is attached to plugin deactivation hook,
    51                 * a call to flush_rewrite_rules function is done to Clear the permalinks to remove rewrite rules
    52         */
    53        
    54         public static function author_filters_post_types() {
    55 
    56             $args = array(
    57                 'public' => true,
    58                 '_builtin' => true
    59             );
    60 
    61             $output = ''; // names or objects, note names is the default
    62             $operator = 'or'; // 'and' or 'or'
    63 
    64             $post_types_arrays = get_post_types($args, $output, $operator); //get & store posty types supported by the system
    65 
    66             $types_array = array(); //initialise an array
    67 
    68             $exclude_post_types = array('attachment', 'revision', 'nav_menu_item'); //array of post types to be excluded from array of post types of system
    69 
    70             foreach ($post_types_arrays as $post_types_aray) { // foreach - iteration to list through array of post types supported by the system
    71                
    72                 if (!in_array($post_types_aray->name, $exclude_post_types)) {
    73                    
    74                     array_push($types_array, $post_types_aray->name); //populate $types_array
    75                    
    76                 }
    77                
    78             } // end: foreach
    79 
    80             return $types_array;
    81         }
    82 
    83         /*
    84             Function: author_filters_admin
    85             Description: 
    86                 * function is attached to restrict_manage_posts hook of core system
    87                 * generates user drop-down select box
    88                 * defining the filter that will be used so we can select posts by 'author'
    89         */
    90        
    91         public static function author_filters_admin() {
    92 
    93             $types_array = self::author_filters_post_types();
    94 
    95             //execute only on the 'post' or 'page' content type
    96             global $post_type;
    97 
    98             if (in_array($post_type, $types_array)) {
    99                 //get a listing of all users that are 'author' or above
    100                 $user_args = array(
    101                     'show_option_all' => 'All Users',
    102                     'orderby' => 'display_name',
    103                     'order' => 'ASC',
    104                     'name' => 'author_admin_filter',
    105                     'who' => 'authors',
    106                     'include_selected' => true
    107                 );
    108 
    109                 //determine if we have selected a user to be filtered by already
    110                 if (isset($_GET['author_admin_filter'])) {
    111                     //set the selected value to the value of the author
    112                     $user_args['selected'] = (int) sanitize_text_field($_GET['author_admin_filter']);
    113                 }
    114 
    115                 wp_dropdown_users($user_args); //display the users as a drop down
    116             }
    117         }  //end: author_filters_admin()
    118 
    119         /*
    120             Function: author_filters_query
    121             Description: 
    122                 * function is attached to pre_get_posts hook of core system
    123                 * restrict the posts or pages by an additional author filter
    124         */
    125        
    126         public static function author_filters_query($query) {
    127 
    128             global $post_type, $pagenow;
    129            
    130             $types_array = self::author_filters_post_types();
    131 
    132             //if we are currently on the edit screen of the post or page type listings
    133 
    134             if ('edit.php' == $pagenow && (in_array($post_type, $types_array))) {
    135 
    136                 if (isset($_GET['author_admin_filter'])) {
    137 
    138                     //set the query variable for 'author' to the desired value
    139                     $author_id = sanitize_text_field($_GET['author_admin_filter']);
    140 
    141                     //if the author is not 0 (meaning all)
    142                     if (0 != $author_id) {
    143                         $query->query_vars['author'] = $author_id;
    144                     }
    145                 }
    146             }
    147         } //end: author_filters_query()
    148        
    149     } //end: class - author_filters
    150    
    151    
    152     register_activation_hook(__FILE__, array('author_filters', 'author_filters_install'));
    153        
    154     register_deactivation_hook(__FILE__, array('author_filters', 'author_filters_deactivation'));   
    155    
    156     add_action('pre_get_posts', array('author_filters', 'author_filters_query'));
    157 
    158     add_action('restrict_manage_posts', array('author_filters', 'author_filters_admin'));
     42add_action( 'init', array( 'authorFilters', 'init' ) );
  • author-filters/trunk/readme.txt

    r1462179 r1812588  
    33Tags: posts, pages, custom post types, author, sorting, filters
    44Requires at least: 3.0.1
    5 Tested up to: 4.6
    6 Stable tag: 4.6
     5Tested up to: 4.9.2
     6Stable tag: 4.9.2
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3636
    3737== Changelog ==
     38= 3.0.0 =
     39 Version Upgrade & tested compatibility with latest stable versions 4.9.2.
     40
    3841= 2.0.0 =
    3942Second version - Update in readme text to add Changelog section. And upgraded version to 2.0.0.
Note: See TracChangeset for help on using the changeset viewer.