Changeset 2988127
- Timestamp:
- 11/02/2023 03:39:37 PM (2 years ago)
- Location:
- wpsite-show-ids
- Files:
-
- 5 added
- 2 edited
-
tags/1.1.10 (added)
-
tags/1.1.10/assets (added)
-
tags/1.1.10/assets/icon-256x256.png (added)
-
tags/1.1.10/readme.txt (added)
-
tags/1.1.10/wpsite-show-ids.php (added)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/wpsite-show-ids.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wpsite-show-ids/trunk/readme.txt
r2766929 r2988127 1 1 === Show IDs by DraftPress === 2 Contributor s: 99robots, charliepatel, DraftPress2 Contributor: 99robots, charliepatel, DraftPress 3 3 Donate link: 4 4 Tags: 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 5 5 Requires at least: 4.9 6 Tested up to: 6. 0.17 Stable tag: 1.1. 96 Tested up to: 6.3.2 7 Stable tag: 1.1.10 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 63 63 64 64 == Changelog == 65 = 1.1.10 = 2023-02-11 66 * Made compatible with WordPress 6.3.2 67 65 68 = 1.1.9 = 2022-08-05 66 69 * Made compatible with WordPress 6.0.1 -
wpsite-show-ids/trunk/wpsite-show-ids.php
r2766929 r2988127 3 3 * Plugin Name: Show IDs 4 4 * Plugin URI: https://draftpress.com/products 5 * Description: Show IDs on all post, page and taxonomy pages.6 * Version: 1.1. 95 * Description: Show IDs on all post, page, and taxonomy pages. 6 * Version: 1.1.10 7 7 * Author: DraftPress 8 8 * Author URI: https://draftpress.com/ 9 9 * 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 10 18 */ 11 19 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 */ 30 class 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 ?> 85 140 <style type="text/css"> 86 141 #wpsite-show-ids { … … 89 144 </style> 90 145 <?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 } 91 192 } 92 193 93 /**94 * Adds column to edit screen95 *96 * @param mixed $cols97 * @return void98 */99 public function add_column($cols)100 {101 102 $cols['wpsite-show-ids'] = 'ID';103 104 return $cols;105 }106 107 /**108 * Adds id value109 *110 * @param mixed $column_name111 * @param mixed $id112 * @return void113 */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 value123 *124 * @param mixed $value125 * @param mixed $column_name126 * @param mixed $id127 * @return void128 */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 }139 194 140 195 /** 141 196 * Start 197 * 142 198 * @var WPSite_Show_IDs 143 199 */ 144 new WPSite_Show_IDs; 200 new WPSite_Show_IDs(); 201 202 ?>
Note: See TracChangeset
for help on using the changeset viewer.