-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin-post-info.php
38 lines (31 loc) · 1.08 KB
/
admin-post-info.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
/**
* Plugin Name: Admin Post Info
* Description: Display the page or post relative URL and template.
* Author: Rich Edmunds
* Author URI: https://www.richedmunds.com
* Text Domain: custom
* Version: 1.0
*
* @package Custom
*/
function rich_edmunds_api_column( $columns ) {
$columns['url'] = esc_html__( 'URL', 'custom' );
$columns['template'] = esc_html__( 'Template', 'custom' );
return $columns;
}
add_filter( 'manage_page_posts_columns', 'rich_edmunds_api_column', 10 );
add_filter( 'manage_post_posts_columns', 'rich_edmunds_api_column', 10 );
function rich_edmunds_api_add_column( $column_name, $post_id ) {
if ( 'url' === $column_name ) {
echo esc_html( wp_make_link_relative( get_permalink( $post_id ) ) );
}
if ( 'template' === $column_name ) {
$page_template = basename( get_page_template() );
if ( 'page.php' !== $page_template ) {
echo esc_html( $page_template );
}
}
}
add_filter( 'manage_page_posts_custom_column', 'rich_edmunds_api_add_column', 10, 2 );
add_filter( 'manage_post_posts_custom_column', 'rich_edmunds_api_add_column', 10, 2 );