Plugin Directory

Changeset 2988127


Ignore:
Timestamp:
11/02/2023 03:39:37 PM (2 years ago)
Author:
99robots
Message:

1.1.10 = 2023-02-11

Location:
wpsite-show-ids
Files:
5 added
2 edited

Legend:

Unmodified
Added
Removed
  • wpsite-show-ids/trunk/readme.txt

    r2766929 r2988127  
    11=== Show IDs by DraftPress ===
    2 Contributors: 99robots, charliepatel, DraftPress
     2Contributor: 99robots, charliepatel, DraftPress
    33Donate link:
    44Tags: ID, show id, display id, show post id, display post id, reveal id, reveal post id, post, category, media, page, post type, post id, category id, media id, page id, post type id, comments, comment id, custom post type id, link id, show, display, reveal, taxonomy, taxonomy id, wordpress id, wp id, user, user id, tag, tag id, wp-admin
    55Requires at least: 4.9
    6 Tested up to: 6.0.1
    7 Stable tag: 1.1.9
     6Tested up to: 6.3.2
     7Stable tag: 1.1.10
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    6363
    6464== Changelog ==
     65= 1.1.10 = 2023-02-11
     66* Made compatible with WordPress 6.3.2
     67
    6568= 1.1.9 = 2022-08-05
    6669* Made compatible with WordPress 6.0.1
  • wpsite-show-ids/trunk/wpsite-show-ids.php

    r2766929 r2988127  
    33 * Plugin Name: Show IDs
    44 * Plugin URI: https://draftpress.com/products
    5  * Description: Show IDs on all post, page and taxonomy pages.
    6  * Version: 1.1.9
     5 * Description: Show IDs on all post, page, and taxonomy pages.
     6 * Version: 1.1.10
    77 * Author: DraftPress
    88 * Author URI: https://draftpress.com/
    99 * License: GPL2
     10 * php version: 7.0
     11 *
     12 * @category Plugin
     13 * @package  ShowIDs
     14 * @author   DraftPress <support@draftpress.com>
     15 * @license  GNU General Public License 2
     16 *           (https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)
     17 * @link     https://draftpress.com/products
    1018 */
    1119
    12 class WPSite_Show_IDs
    13 {
    14 
    15     public function __construct()
    16     {
    17 
    18         add_action('admin_init', array($this, 'custom_objects'));
    19         add_action('admin_head', array($this, 'add_css'));
    20 
    21         // For Post Management
    22         add_filter('manage_posts_columns', array($this, 'add_column'));
    23         add_action('manage_posts_custom_column', array($this, 'add_value'), 10, 2);
    24 
    25         // For Page Management
    26         add_filter('manage_pages_columns', array($this, 'add_column'));
    27         add_action('manage_pages_custom_column', array($this, 'add_value'), 10, 2);
    28 
    29         // For Media Management
    30         add_filter('manage_media_columns', array($this, 'add_column'));
    31         add_action('manage_media_custom_column', array($this, 'add_value'), 10, 2);
    32 
    33         // For Link Management
    34         add_filter('manage_link-manager_columns', array($this, 'add_column'));
    35         add_action('manage_link_custom_column', array($this, 'add_value'), 10, 2);
    36 
    37         // For Category Management
    38         add_action('manage_edit-link-categories_columns', array($this, 'add_column'));
    39         add_filter('manage_link_categories_custom_column', array($this, 'add_return_value'), 10, 3);
    40 
    41         // For User Management
    42         add_action('manage_users_columns', array($this, 'add_column'));
    43         add_filter('manage_users_custom_column', array($this, 'add_return_value'), 10, 3);
    44 
    45         // For Comment Management
    46         add_action('manage_edit-comments_columns', array($this, 'add_column'));
    47         add_action('manage_comments_custom_column', array($this, 'add_value'), 10, 2);
    48     }
    49 
    50     /**
    51      * Hooks to the 'admin_init'
    52      *
    53      * @return void
    54      */
    55     public function custom_objects()
    56     {
    57 
    58         // For Custom Taxonomies
    59         $taxonomies = get_taxonomies(array('public' => true), 'names');
    60         foreach ($taxonomies as $custom_taxonomy) {
    61             if (isset($custom_taxonomy)) {
    62                 add_action('manage_edit-' . $custom_taxonomy . '_columns', array($this, 'add_column'));
    63                 add_filter('manage_' . $custom_taxonomy . '_custom_column', array($this, 'add_return_value'), 10, 3);
    64             }
    65         }
    66 
    67         // For Custom Post Types
    68         $post_types = get_post_types(array('public' => true), 'names');
    69         foreach ($post_types as $post_type) {
    70             if (isset($post_type)) {
    71                 add_action('manage_edit-' . $post_type . '_columns', array($this, 'add_column'));
    72                 add_filter('manage_' . $post_type . '_custom_column', array($this, 'add_return_value'), 10, 3);
    73             }
    74         }
    75     }
    76 
    77     /**
    78      * Hooks to 'admin_head'
    79      *
    80      * @return void
    81      */
    82     public function add_css()
    83     {
    84         ?>
     20/**
     21 * Class WPSite_Show_IDs
     22 *
     23 * @category Class
     24 * @package  ShowIDs
     25 * @author   DraftPress <support@draftpress.com>
     26 * @license  GNU General Public License 2
     27 *          (https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)
     28 * @link     https://draftpress.com/products
     29 */
     30class WPSite_Show_IDs {
     31
     32
     33    /**
     34     * Class constructor. Initializes actions and filters.
     35     */
     36    public function __construct() {
     37
     38        add_action( 'admin_init', array( $this, 'custom_objects' ) );
     39        add_action( 'admin_head', array( $this, 'add_css' ) );
     40
     41        // For Post Management.
     42        add_filter( 'manage_posts_columns', array( $this, 'add_column' ) );
     43        add_action( 'manage_posts_custom_column', array( $this, 'add_value' ), 10, 2 );
     44
     45        // For Page Management.
     46        add_filter( 'manage_pages_columns', array( $this, 'add_column' ) );
     47        add_action( 'manage_pages_custom_column', array( $this, 'add_value' ), 10, 2 );
     48
     49        // For Media Management.
     50        add_filter( 'manage_media_columns', array( $this, 'add_column' ) );
     51        add_action( 'manage_media_custom_column', array( $this, 'add_value' ), 10, 2 );
     52
     53        // For Link Management.
     54        add_filter( 'manage_link-manager_columns', array( $this, 'add_column' ) );
     55        add_action( 'manage_link_custom_column', array( $this, 'add_value' ), 10, 2 );
     56
     57        // For Category Management.
     58        add_action(
     59            'manage_edit-link-categories_columns',
     60            array( $this, 'add_column' )
     61        );
     62        add_filter(
     63            'manage_link_categories_custom_column',
     64            array( $this, 'add_return_value' ),
     65            10,
     66            3
     67        );
     68
     69        // For User Management.
     70        add_action( 'manage_users_columns', array( $this, 'add_column' ) );
     71        add_filter(
     72            'manage_users_custom_column',
     73            array( $this, 'add_return_value' ),
     74            10,
     75            3
     76        );
     77
     78        // For Comment Management.
     79        add_action(
     80            'manage_edit-comments_columns',
     81            array( $this, 'add_column' )
     82        );
     83        add_action(
     84            'manage_comments_custom_column',
     85            array( $this, 'add_value' ),
     86            10,
     87            2
     88        );
     89    }
     90
     91    /**
     92     * Hooks to the 'admin_init'
     93     *
     94     * @return void
     95     */
     96    public function custom_objects() {
     97
     98        // For Custom Taxonomies.
     99        $taxonomies = get_taxonomies( array( 'public' => true ), 'names' );
     100        foreach ( $taxonomies as $custom_taxonomy ) {
     101            if ( isset( $custom_taxonomy ) ) {
     102                add_action(
     103                    'manage_edit-' . $custom_taxonomy . '_columns',
     104                    array( $this, 'add_column' )
     105                );
     106                add_filter(
     107                    'manage_' . $custom_taxonomy . '_custom_column',
     108                    array( $this, 'add_return_value' ),
     109                    10,
     110                    3
     111                );
     112            }
     113        }
     114
     115        // For Custom Post Types.
     116        $post_types = get_post_types( array( 'public' => true ), 'names' );
     117        foreach ( $post_types as $post_type ) {
     118            if ( isset( $post_type ) ) {
     119                add_action(
     120                    'manage_edit-' . $post_type . '_columns',
     121                    array( $this, 'add_column' )
     122                );
     123                add_filter(
     124                    'manage_' . $post_type . '_custom_column',
     125                    array( $this, 'add_return_value' ),
     126                    10,
     127                    3
     128                );
     129            }
     130        }
     131    }
     132
     133    /**
     134     * Hooks to 'admin_head'
     135     *
     136     * @return void
     137     */
     138    public function add_css() {
     139        ?>
    85140        <style type="text/css">
    86141            #wpsite-show-ids {
     
    89144        </style>
    90145        <?php
     146    }
     147
     148    /**
     149     * Adds a column to the edit screen.
     150     *
     151     * @param mixed $cols The existing columns.
     152     *
     153     * @return string
     154     */
     155    public function add_column( $cols ) {
     156        $cols['wpsite-show-ids'] = 'ID';
     157        return $cols;
     158    }
     159
     160
     161    /**
     162     * Adds id value to a column.
     163     *
     164     * @param mixed $column_name The name of the column.
     165     * @param mixed $id The ID value to add.
     166     *
     167     * @return void
     168     */
     169    public function add_value( $column_name, $id ) {
     170        if ( 'wpsite-show-ids' === $column_name ) {
     171            echo esc_html( $id );
     172        }
     173    }
     174
     175
     176    /**
     177     * Adds an ID value as a return value for a column.
     178     *
     179     * @param mixed $value       The current column value.
     180     * @param mixed $column_name The name of the column.
     181     * @param mixed $id          The ID value.
     182     *
     183     * @return string
     184     */
     185    public function add_return_value( $value, $column_name, $id ) {
     186        if ( 'wpsite-show-ids' === $column_name ) {
     187            $value = $id;
     188        }
     189
     190        return $value;
     191    }
    91192}
    92193
    93     /**
    94      * Adds column to edit screen
    95      *
    96      * @param mixed $cols
    97      * @return void
    98      */
    99     public function add_column($cols)
    100     {
    101 
    102         $cols['wpsite-show-ids'] = 'ID';
    103 
    104         return $cols;
    105     }
    106 
    107     /**
    108      * Adds id value
    109      *
    110      * @param mixed $column_name
    111      * @param mixed $id
    112      * @return void
    113      */
    114     public function add_value($column_name, $id)
    115     {
    116         if ('wpsite-show-ids' === $column_name) {
    117             echo $id;
    118         }
    119     }
    120 
    121     /**
    122      * Adds id value
    123      *
    124      * @param mixed $value
    125      * @param mixed $column_name
    126      * @param mixed $id
    127      * @return void
    128      */
    129     public function add_return_value($value, $column_name, $id)
    130     {
    131 
    132         if ('wpsite-show-ids' === $column_name) {
    133             $value = $id;
    134         }
    135 
    136         return $value;
    137     }
    138 }
    139194
    140195/**
    141196 * Start
     197 *
    142198 * @var WPSite_Show_IDs
    143199 */
    144 new WPSite_Show_IDs;
     200new WPSite_Show_IDs();
     201
     202?>
Note: See TracChangeset for help on using the changeset viewer.