| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: Catch IDs |
| 4 |
Plugin URI: http://catchthemes.com/wp-plugins/catch-ids/ |
| 5 |
Description: Catch IDs is a simple and light weight plugin to show the Post ID, Page ID, Media ID, Links ID, Category ID, Tag ID and User ID in the Admin Section Table. This plugin was initially develop to support our themes features slider. Then we thought that this will be helpful to all the WordPress Admin Users. Just activate and catch IDs in your page, post, category, tag and media pages. |
| 6 |
Version: 1.4 |
| 7 |
License: GNU General Public License, version 3 (GPLv3) |
| 8 |
License URI: http://www.gnu.org/licenses/gpl-3.0.txt |
| 9 |
Author: Catch Themes |
| 10 |
Author URI: http://catchthemes.com |
| 11 |
Text Domain: catch-ids |
| 12 |
Tags: catch-ids, simple, admin, wp-admin, show, ids, post, page, category, media, links, tag, user, id, post id, page id, category id |
| 13 |
*/ |
| 14 |
|
| 15 |
/* |
| 16 |
Copyright (C) 2012-2016 Catch Themes, (info@catchthemes.com) |
| 17 |
|
| 18 |
This program is free software; you can redistribute it and/or modify |
| 19 |
it under the terms of the GNU General Public License as published by |
| 20 |
the Free Software Foundation; either version 3 of the License, or |
| 21 |
(at your option) any later version. |
| 22 |
|
| 23 |
This program is distributed in the hope that it will be useful, |
| 24 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 25 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 26 |
GNU General Public License for more details. |
| 27 |
|
| 28 |
You should have received a copy of the GNU General Public License |
| 29 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 30 |
*/ |
| 31 |
|
| 32 |
/** |
| 33 |
* Make plugin available for translation |
| 34 |
* Translations can be filed in the /languages/ directory |
| 35 |
*/ |
| 36 |
function catchids_load_textdomain() { |
| 37 |
load_plugin_textdomain( 'catch-ids', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' ); |
| 38 |
} |
| 39 |
add_action( 'plugins_loaded', 'catchids_load_textdomain' ); |
| 40 |
|
| 41 |
|
| 42 |
/** |
| 43 |
* @package Catch Themes |
| 44 |
* @subpackage Catch IDs |
| 45 |
* @since Catch IDs 1.0 |
| 46 |
*/ |
| 47 |
|
| 48 |
if ( ! function_exists( 'catchids_column' ) ): |
| 49 |
/** |
| 50 |
* Prepend the new column to the columns array |
| 51 |
*/ |
| 52 |
function catchids_column($cols) { |
| 53 |
$column_id = array( 'catchids' => __( 'ID', 'catch-ids' ) ); |
| 54 |
$cols = array_slice( $cols, 0, 1, true ) + $column_id + array_slice( $cols, 1, NULL, true ); |
| 55 |
return $cols; |
| 56 |
} |
| 57 |
|
| 58 |
endif; // catchids_column |
| 59 |
|
| 60 |
if ( ! function_exists( 'catchids_value' ) ) : |
| 61 |
/** |
| 62 |
* Echo the ID for the new column |
| 63 |
*/ |
| 64 |
function catchids_value( $column_name, $id ) { |
| 65 |
if ( 'catchids' == $column_name ) { |
| 66 |
echo $id; |
| 67 |
} |
| 68 |
} |
| 69 |
endif; // catchids_value |
| 70 |
|
| 71 |
|
| 72 |
if ( ! function_exists( 'catchids_return_value' ) ) : |
| 73 |
function catchids_return_value( $value, $column_name, $id ) { |
| 74 |
if ( 'catchids' == $column_name ) { |
| 75 |
$value .= $id; |
| 76 |
} |
| 77 |
return $value; |
| 78 |
} |
| 79 |
endif; // catchids_return_value |
| 80 |
|
| 81 |
|
| 82 |
if ( ! function_exists( 'catchids_css' ) ) : |
| 83 |
/** |
| 84 |
* Output CSS for width of new column |
| 85 |
*/ |
| 86 |
function catchids_css() { |
| 87 |
?> |
| 88 |
<style type="text/css"> |
| 89 |
#catchids { |
| 90 |
width: 50px; |
| 91 |
} |
| 92 |
</style> |
| 93 |
<?php |
| 94 |
} |
| 95 |
endif; // catchids_css |
| 96 |
add_action( 'admin_head', 'catchids_css'); |
| 97 |
|
| 98 |
|
| 99 |
if ( ! function_exists( 'catchids_add' ) ) : |
| 100 |
/** |
| 101 |
* Actions/Filters for various tables and the css output |
| 102 |
*/ |
| 103 |
function catchids_add() { |
| 104 |
// For Media Management |
| 105 |
add_action( "manage_media_columns" , 'catchids_column' ); |
| 106 |
add_filter( "manage_media_custom_column" , 'catchids_value' , 10 , 3 ); |
| 107 |
|
| 108 |
// For Link Management |
| 109 |
add_action( 'manage_link_custom_column', 'catchids_value', 10, 2 ); |
| 110 |
add_filter( 'manage_link-manager_columns', 'catchids_column' ); |
| 111 |
|
| 112 |
// For Category Management |
| 113 |
add_action( 'manage_edit-link-categories_columns', 'catchids_column' ); |
| 114 |
add_filter( 'manage_link_categories_custom_column', 'catchids_return_value', 10, 3 ); |
| 115 |
|
| 116 |
// For Category, Tags and other custom taxonomies Management |
| 117 |
foreach( get_taxonomies() as $taxonomy ) { |
| 118 |
add_action( "manage_edit-${taxonomy}_columns" , 'catchids_column' ); |
| 119 |
add_filter( "manage_${taxonomy}_custom_column" , 'catchids_return_value' , 10 , 3 ); |
| 120 |
if( version_compare($GLOBALS['wp_version'], '3.0.999', '>') ) { |
| 121 |
add_filter( "manage_edit-${taxonomy}_sortable_columns" , 'catchids_column' ); |
| 122 |
} |
| 123 |
} |
| 124 |
|
| 125 |
foreach( get_post_types() as $ptype ) { |
| 126 |
add_action( "manage_edit-${ptype}_columns" , 'catchids_column' ); |
| 127 |
add_filter( "manage_${ptype}_posts_custom_column" , 'catchids_value' , 10 , 3 ); |
| 128 |
if( version_compare($GLOBALS['wp_version'], '3.0.999', '>') ) { |
| 129 |
add_filter( "manage_edit-${ptype}_sortable_columns" , 'catchids_column' ); |
| 130 |
} |
| 131 |
} |
| 132 |
|
| 133 |
// For User Management |
| 134 |
add_action( 'manage_users_columns', 'catchids_column' ); |
| 135 |
add_filter( 'manage_users_custom_column', 'catchids_return_value', 10, 3 ); |
| 136 |
if( version_compare($GLOBALS['wp_version'], '3.0.999', '>') ) { |
| 137 |
add_filter( "manage_users_sortable_columns" , 'catchids_column' ); |
| 138 |
} |
| 139 |
|
| 140 |
// For Comment Management |
| 141 |
add_action( 'manage_edit-comments_columns', 'catchids_column' ); |
| 142 |
add_action( 'manage_comments_custom_column', 'catchids_value', 10, 2 ); |
| 143 |
if( version_compare($GLOBALS['wp_version'], '3.0.999', '>') ) { |
| 144 |
add_filter( "manage_edit-comments_sortable_columns" , 'catchids_column' ); |
| 145 |
} |
| 146 |
} |
| 147 |
endif; // catchids_add |
| 148 |
add_action( 'admin_init', 'catchids_add' ); |
| 149 |
|