WordPress.org

Ready to get started?Download WordPress

Forums

Advanced Page Manager
[resolved] Question Revealing ID of Pages? (2 posts)

  1. paknot
    Member
    Posted 7 months ago #

    Hi,

    I would like to show the ID of every page so I've tried a plugin to Reveal the ID on "All Pages" in the Admin Panel", but it doesn't work with this Plugin.

    This is my website: meerkerk.sitebysite.nl
    Plugin I've tried to reveal the ID: Reveal IDs

    I hope there is a possibility to have this option in this plugin.

    Thank you.

    http://wordpress.org/plugins/advanced-page-manager/

  2. Uncategorized Creations
    Member
    Plugin Author

    Posted 7 months ago #

    It's Christmas :-)

    Here's the code you need :

    <?php
    /**
     * Advanced Page Manager addon that adds an "ID" column to pages tree and lists.
     * @author Uncategorized Creations
     */
    class ApmRevealIdsColumn{
    
    	public static function hooks(){
    		add_filter('apm_manage_pages_columns', array(__CLASS__, 'apm_manage_pages_columns'),15);
    		add_filter('apm_manage_pages_custom_column', array(__CLASS__, 'apm_manage_pages_custom_column'),10,3);
    		add_filter('apm_custom_sql_orderby', array(__CLASS__, 'apm_custom_sql_orderby'),10,3);
    	}
    
    	public static function apm_manage_pages_columns($columns){
    
    		$label = apply_filters('apm_addon_reveal_ids_column_label',__('ID', ApmConfig::i18n_domain));	
    
    		//Add "ID" column before native APM "template" column :
    		$additionnal_column = array('apm-reveal-ids' => '<a href="#" class="custom-sortable">
    														    <span>'. __($label) .'</span>
    														    <span class="sorting-indicator"></span>
    													    </a>');
    
    		$index = array_search('add_page', array_keys($columns));
    
    		$columns = array_slice($columns, 0, $index, true) + $additionnal_column + array_slice($columns, $index, count($columns) - $index, true) ;
    
    		return $columns;
    	}
    
    	public static function apm_manage_pages_custom_column($column_name,$post_id,$node){
    
    		if( $column_name == 'apm-reveal-ids' ){
    			if( $node->status > -2 ){ //Display for all "displayable" pages status
    				$page_id_html = '<p class="apm-reveal-ids">'. $post_id .'</p>';
    				$page_id_html = apply_filters('apm_addon_reveal_ids',$page_id_html,$post_id,$node);
    				echo $page_id_html;
    			}
    		}
    
    	}
    
    	public static function apm_custom_sql_orderby($order_by_sql,$order_by,$order){
    
    		if( $order_by == 'apm-reveal-ids' ){
    			$order_by_sql = "p.ID $order";
    		}
    
    		return $order_by_sql;
    	}
    
    }
    
    ApmRevealIdsColumn::hooks();

    The best way do use it is to create a PHP file called reveal_ids_column.php and drop it into the lib/addons plugin subfolder.

    Then access the Settings panel and activate the new addon.

Reply

You must log in to post.

About this Plugin

About this Topic