Plugin Directory

Changeset 886963


Ignore:
Timestamp:
04/03/2014 06:41:26 PM (12 years ago)
Author:
fpalme
Message:

New Version 1.1

  • Medias can now also be personalized.
  • Minor bugfixes
Location:
custom-columns
Files:
16 added
5 edited

Legend:

Unmodified
Added
Removed
  • custom-columns/trunk/CustomColumns.php

    r884627 r886963  
    44* Plugin URI:       http://florian-palme.de
    55* Description:      Create Custom Columns for your Post Types easily
    6 * Version:          1.0
     6* Version:          1.1
    77* Author:           Florian Palme
    88* Author URI:       http://florian-palme.de
  • custom-columns/trunk/CustomColumnsManager.class.php

    r884627 r886963  
    1818     *
    1919     * @since   1.0
     20     * @updated 1.1
    2021     */
    2122    public function __construct()
     
    2526            if( ! count( $oOptions->aTabs ) ) continue;
    2627           
    27             // Register column header
    28             add_filter( 'manage_' . $sPosttype . '_posts_columns', array( $this, 'addColumnHeader' ) );
    29            
    30             // Register column output
    31             add_filter( 'manage_' . $sPosttype . '_posts_custom_column', array( $this, 'addColumnOutput' ), 10, 2 );
    32            
    33             // Register sortable
    34             add_filter( 'manage_edit-' . $sPosttype . '_sortable_columns', array( $this, 'addSortableColumns' ) );
     28            // we need other action/filters for media
     29            if( $sPosttype == 'media' ){
     30                add_filter( 'manage_media_columns', array( $this, 'addColumnHeader' ) );
     31               
     32                add_filter( 'manage_media_custom_column', array( $this, 'addColumnOutput' ), 10, 2 );
     33               
     34                // Register sortable
     35                add_filter( 'manage_upload_sortable_columns', array( $this, 'addSortableColumns' ) );
     36            } else {
     37                // Register column header
     38                add_filter( 'manage_' . $sPosttype . '_posts_columns', array( $this, 'addColumnHeader' ) );
     39               
     40                // Register column output
     41                add_filter( 'manage_' . $sPosttype . '_posts_custom_column', array( $this, 'addColumnOutput' ), 10, 2 );
     42               
     43                // Register sortable
     44                add_filter( 'manage_edit-' . $sPosttype . '_sortable_columns', array( $this, 'addSortableColumns' ) );
     45            }
    3546        }
    3647       
     
    5768       
    5869        global $wpdb;
    59        
    60         $aTabs = $this->getPosttypeOptions( fpFunctions::getCurrentPosttype() )->aTabs;
     70
     71        $aTabs = $this->getPosttypeOptions( fpFunctions::getCurrentPosttype(true) )->aTabs;
    6172
    6273        foreach( $aTabs as $sIdent => $aTab ){
     
    107118        if( ! isset( $aVars[ 'orderby' ] ) ) return $aVars;
    108119       
    109         $aTabs = $this->getPosttypeOptions( fpFunctions::getCurrentPosttype() )->aTabs;
     120        $aTabs = $this->getPosttypeOptions( fpFunctions::getCurrentPosttype(true) )->aTabs;
    110121       
    111122        foreach( $aTabs as $sIdent => $aTab ){
     
    137148    {
    138149        // put all columns to the array and merge with default
    139         $aTabs = $this->getPosttypeOptions( fpFunctions::getCurrentPosttype() )->aTabs;
     150        $aTabs = $this->getPosttypeOptions( fpFunctions::getCurrentPosttype(true) )->aTabs;
    140151       
    141152        foreach( $aTabs as $sIdent => $aTab ){
     
    159170    public function addColumnOutput( $sColumn, $iID )
    160171    {
    161         $aTabs = $this->getPosttypeOptions( fpFunctions::getCurrentPosttype() )->aTabs;
    162 
     172        $aTabs = $this->getPosttypeOptions( fpFunctions::getCurrentPosttype(true) )->aTabs;
     173       
    163174        if( isset( $aTabs[ $sColumn ] ) ){
    164175            $aTab = $aTabs[ $sColumn ];
     
    259270
    260271        // put all columns to the array and merge with default
    261         $aTabs = $this->getPosttypeOptions( fpFunctions::getCurrentPosttype() )->aTabs;
    262        
     272        $aTabs = $this->getPosttypeOptions( fpFunctions::getCurrentPosttype(true) )->aTabs;
     273
    263274        foreach( $aTabs as $sIdent => $aTab ){
    264275            $aCustomColumns[ $sIdent ] = __( $aTab[ 'sTitle' ], 'custom-columns-user' );   
  • custom-columns/trunk/CustomColumnsPage.class.php

    r884627 r886963  
    111111     *
    112112     * @since   1.0
     113     * @updated 1.1
    113114     *
    114115     * @return  array
     
    125126            unset( $aPosttypes[ 'attachment' ] );
    126127            $aPosttypes[ 'media' ] = $aMedia;
    127            
    128             // 1.0 media not supported yet... just unset it
    129             unset( $aPosttypes[ 'media' ] );
    130128           
    131129            $this->aAviablePosttypes = $aPosttypes;
     
    335333     *
    336334     * @since   1.0
     335     * @updated 1.1
    337336     */
    338337    protected function addTemplateTabContent()
     
    360359                                <label for="tab-options-%%sIdent%%-options-sortable-type"><?php _e( 'Choose sort type', 'custom-columns' ); ?></label>
    361360                                <select data-tab-group="%%sIdent%%" id="tab-options-%%sIdent%%-options-sortable-type" name="aTabs[%%sIdent%%][aOptions][sortable][sType]">
    362                                     <option value="posts_table"><?php _e( 'Posts-Table', 'custom-columns' ); ?></option>   
    363                                     <option value="post_meta"><?php _e( 'Post Meta', 'custom-columns' ); ?></option>   
    364                                     <option value="taxonomies"><?php _e( 'Taxonomy', 'custom-columns' ); ?></option>   
     361                                    <option value="posts_table"><?php _e( 'Posts-Table', 'custom-columns' ); ?></option>
     362                                   
     363                                    <?php if( count( $aMetakeys ) ): ?>
     364                                    <option value="post_meta"><?php _e( 'Post Meta', 'custom-columns' ); ?></option>
     365                                    <?php endif; ?>
     366                                   
     367                                    <?php if( count( $aTaxonomies ) ): ?>
     368                                    <option value="taxonomies"><?php _e( 'Taxonomy', 'custom-columns' ); ?></option>
     369                                    <?php endif; ?>
    365370                                </select>
    366371                               
  • custom-columns/trunk/functions.php

    r884627 r886963  
    102102     *
    103103     * @since   1.0
     104     * @updated 1.1
     105     *
     106     * @param   boolean $blRewriteAttachment
    104107     *
    105108     * @return  string
    106109     */
    107     public static function getCurrentPosttype() {
    108       global $post, $typenow, $current_screen;
     110    public static function getCurrentPosttype( $blRewriteAttachment = false )
     111    {
     112        $sPosttype = self::_getCurrentPosttype();
     113       
     114        if( $blRewriteAttachment && $sPosttype !== null && $sPosttype == 'attachment' ){
     115            $sPosttype = 'media';
     116        }
     117       
     118        return $sPosttype;
     119    }
     120   
     121   
     122    /**
     123     * Gets the current post type
     124     *
     125     * @since   1.1
     126     *
     127     * @return  string
     128     */
     129    protected function _getCurrentPosttype()
     130    {
     131        global $post, $typenow, $current_screen;
    109132   
    110133      //we have a post so we can just get the post type from that
  • custom-columns/trunk/readme.txt

    r884633 r886963  
    4747== Changelog ==
    4848
     49= 1.1 =
     50* Medias can now also be personalized.
     51* Minor bugfixes
     52
    4953= 1.0 =
    5054* Changed License
Note: See TracChangeset for help on using the changeset viewer.