Changeset 2106723
- Timestamp:
- 06/15/2019 06:06:38 PM (7 years ago)
- Location:
- admin-slug-column
- Files:
-
- 3 added
- 2 edited
-
tags/0.5.0 (added)
-
tags/0.5.0/admin-slug-column.php (added)
-
tags/0.5.0/readme.txt (added)
-
trunk/admin-slug-column.php (modified) (5 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
admin-slug-column/trunk/admin-slug-column.php
r1963840 r2106723 1 1 <?php 2 2 /** 3 * @link https://chuckreynolds. us3 * @link https://chuckreynolds.com 4 4 * @since 0.3.0 5 5 * @package Admin_Slug_Column 6 6 * 7 7 * Plugin Name: Admin Slug Column 8 * Plugin URI: http ://wordpress.org/plugins/admin-slug-column/9 * Description: Adds the post /page url slug in the admin columns of theedit screens.10 * Version: 0. 4.08 * Plugin URI: https://wordpress.org/plugins/admin-slug-column/ 9 * Description: Adds the post url slug and page url path to the admin columns on edit screens. 10 * Version: 0.5.0 11 11 * Author: Chuck Reynolds 12 * Author URI: https://chuckreynolds. us12 * Author URI: https://chuckreynolds.com 13 13 * License: GPL-2.0+ 14 14 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt … … 16 16 */ 17 17 18 // If this file is called directly, abort .18 // If this file is called directly, abort 19 19 if ( ! defined( 'WPINC' ) ) { 20 20 die; … … 37 37 add_filter( 'manage_pages_columns', array( $this, 'WPASC_posts' ) ); 38 38 add_action( 'manage_pages_custom_column', array( $this, 'WPASC_posts_data' ), 10, 2 ); 39 add_filter( 'manage_edit-post_sortable_columns', array( $this, 'WPASC_sort_posts' ) );40 add_filter( 'manage_edit-page_sortable_columns', array( $this, 'WPASC_sort_posts' ) );41 add_action( 'pre_get_posts', array( $this, 'WPASC_sort_posts_orderby' ) );42 39 } 43 40 … … 52 49 53 50 /** 54 * Adds Slug column to Posts /Pageslist column51 * Adds Slug column to Posts list column 55 52 * 56 * @param array $defaults An array of column names .53 * @param array $defaults An array of column names 57 54 */ 58 55 public function WPASC_posts( $defaults ) { 59 $defaults['wpasc-slug'] = __( ' Slug', 'admin-slug-column' );56 $defaults['wpasc-slug'] = __( 'URL Path', 'admin-slug-column' ); 60 57 return $defaults; 61 58 } 62 59 63 60 /** 64 * Gets the post info from get_post function and displays the slug 61 * Gets the post info from get_post function and displays the slug and/or path 65 62 * 66 63 * @param string $column_name Name of the column … … 74 71 $post_slug = $post_info->post_name; 75 72 $post_type = $post_info->post_type; 76 $post_parent = $post_info->post_parent;77 73 $post_status = $post_info->post_status; 78 74 79 // if post-type is page type we're going to do some extra stuff80 75 if ( $post_type === 'page' ) { 81 82 // add root slash but only for published pages; ignore drafts 83 if ( $post_status === 'publish' ) { 84 $post_slug = '/' . $post_slug; 85 } 86 87 // add the parent slug in there too if this is a child page 88 if ( $post_parent > 0 ) { 89 $pre_post_slug = get_post_field( 'post_name', $post_parent, 'raw' ); 90 $post_slug = '/' . $pre_post_slug . $post_slug; 91 } 92 76 // Get full permalink but remove domain.tld 77 $post_slug = str_replace( home_url(), '', get_permalink( $id ) ); 93 78 } 94 79 95 // if this is the front page then just show root slash 96 $frontpage_id = get_option( 'page_on_front' ); 97 if ( $frontpage_id == $id ) { 98 $post_slug = '/'; 80 if ( $post_type === 'post' ) { 81 // Add root & trailing slash to slug only for published or scheduled pages; ignore drafts 82 if ( $post_status === 'publish' || $post_status === 'future' ) { 83 $post_slug = '/' . $post_slug . '/'; 84 } 99 85 } 100 86 87 // Echo out what we've got 101 88 echo esc_attr( $post_slug ); 102 }103 }104 105 /**106 * Adds Slug column to Posts/Pages sortable detection107 *108 * @param array $sortable_columns An array of sortable column names.109 */110 public function WPASC_sort_posts( $sortable_columns ) {111 $sortable_columns[ 'wpasc-slug' ] = 'wpasc-slug';112 return $sortable_columns;113 }114 115 /**116 * Function to handle the sort ordering conditions117 *118 * @param array $query An array of admin url params119 */120 public function WPASC_sort_posts_orderby( $query ) {121 if ( ! $query->is_main_query() ) {122 return;123 }124 if ( 'wpasc-slug' === $query->get( 'orderby') ) {125 $query->set( 'orderby', 'post_name' );126 89 } 127 90 } -
admin-slug-column/trunk/readme.txt
r1963840 r2106723 2 2 Contributors: ryno267 3 3 Donate link: https://cash.me/$chuckreynolds 4 Tags: slug, admin columns, permalink, url, page titles4 Tags: slug, admin columns, permalink, url, url path, page titles 5 5 Requires at least: 3.5 6 Tested up to: 5. 07 Stable tag: 0. 4.06 Tested up to: 5.2.2 7 Stable tag: 0.5.0 8 8 License: GPL-2.0+ 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.txt … … 12 12 13 13 == Description == 14 Simply put, this plugin adds the p age/post sluginto the admin columns on the "All Posts" and "All Pages" views.15 I built this quickly out of necessity to help identify pages and posts by their slug as sometimes the titles clients make don't match up nicely with the url slug; so here's a fast way to do that. Nothing fancy, just does what it does.14 Simply put, this plugin adds the post slug and page url path into the admin columns on the "All Posts" and "All Pages" views. 15 I built this out of necessity to help identify pages and posts by their slug/path as sometimes the title's clients use don't match up nicely with the url slug; so here's a fast way to do that. Nothing fancy, just does what it does. 16 16 17 17 == Installation == … … 29 29 30 30 == Changelog == 31 = 0.5.0 = 32 33 Release Date - 2019-06-15 34 35 * [fix] pages now show the full url path now after the domain.tld, posts still just the slug 36 * tested on 5.2.2 37 31 38 = 0.4.0 = 32 39
Note: See TracChangeset
for help on using the changeset viewer.