Plugin Directory

Changeset 2106723


Ignore:
Timestamp:
06/15/2019 06:06:38 PM (7 years ago)
Author:
ryno267
Message:

Added depth to page paths, rem sorting, tested to WP 5.2.2

Location:
admin-slug-column
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • admin-slug-column/trunk/admin-slug-column.php

    r1963840 r2106723  
    11<?php
    22/**
    3  * @link         https://chuckreynolds.us
     3 * @link         https://chuckreynolds.com
    44 * @since        0.3.0
    55 * @package      Admin_Slug_Column
    66 *
    77 * 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 the edit screens.
    10  * Version:      0.4.0
     8 * 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
    1111 * Author:       Chuck Reynolds
    12  * Author URI:   https://chuckreynolds.us
     12 * Author URI:   https://chuckreynolds.com
    1313 * License:      GPL-2.0+
    1414 * License URI:  http://www.gnu.org/licenses/gpl-2.0.txt
     
    1616 */
    1717
    18 // If this file is called directly, abort.
     18// If this file is called directly, abort
    1919if ( ! defined( 'WPINC' ) ) {
    2020    die;
     
    3737        add_filter( 'manage_pages_columns',              array( $this, 'WPASC_posts' ) );
    3838        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' ) );
    4239    }
    4340
     
    5249
    5350    /**
    54      * Adds Slug column to Posts/Pages list column
     51     * Adds Slug column to Posts list column
    5552     *
    56      * @param array $defaults An array of column names.
     53     * @param array $defaults An array of column names
    5754     */
    5855    public function WPASC_posts( $defaults ) {
    59         $defaults['wpasc-slug'] = __( 'Slug', 'admin-slug-column' );
     56        $defaults['wpasc-slug'] = __( 'URL Path', 'admin-slug-column' );
    6057        return $defaults;
    6158    }
    6259
    6360    /**
    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
    6562     *
    6663     * @param string $column_name Name of the column
     
    7471            $post_slug   = $post_info->post_name;
    7572            $post_type   = $post_info->post_type;
    76             $post_parent = $post_info->post_parent;
    7773            $post_status = $post_info->post_status;
    7874
    79             // if post-type is page type we're going to do some extra stuff
    8075            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 ) );
    9378            }
    9479
    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                }
    9985            }
    10086
     87            // Echo out what we've got
    10188            echo esc_attr( $post_slug );
    102         }
    103     }
    104 
    105     /**
    106      * Adds Slug column to Posts/Pages sortable detection
    107      *
    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 conditions
    117      *
    118      * @param array $query An array of admin url params
    119      */
    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' );
    12689        }
    12790    }
  • admin-slug-column/trunk/readme.txt

    r1963840 r2106723  
    22Contributors: ryno267
    33Donate link: https://cash.me/$chuckreynolds
    4 Tags: slug, admin columns, permalink, url, page titles
     4Tags: slug, admin columns, permalink, url, url path, page titles
    55Requires at least: 3.5
    6 Tested up to: 5.0
    7 Stable tag: 0.4.0
     6Tested up to: 5.2.2
     7Stable tag: 0.5.0
    88License: GPL-2.0+
    99License URI: http://www.gnu.org/licenses/gpl-2.0.txt
     
    1212
    1313== Description ==
    14 Simply put, this plugin adds the page/post slug into 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.
     14Simply put, this plugin adds the post slug and page url path into the admin columns on the "All Posts" and "All Pages" views.
     15I 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.
    1616
    1717== Installation ==
     
    2929
    3030== Changelog ==
     31= 0.5.0 =
     32
     33Release 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
    3138= 0.4.0 =
    3239
Note: See TracChangeset for help on using the changeset viewer.