Plugin Directory

Changeset 638877


Ignore:
Timestamp:
12/13/2012 10:25:08 PM (13 years ago)
Author:
codepress
Message:

1.4.9

Location:
codepress-admin-columns
Files:
78 added
1 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • codepress-admin-columns/trunk/classes/license.php

    r637684 r638877  
    55    /**
    66     * The type of licence to check or activate
    7      * 
     7     *
    88     * @var string $type
    99     */
    1010    public $type;
    11    
    12     public function __construct($type) 
     11
     12    public function __construct($type)
    1313    {
    1414        $this->type = $type;
    1515    }
    16    
     16
    1717    /**
    1818     * Unlocks
     
    2323    {
    2424        return preg_match( '/^[a-f0-9]{40}$/i', $this->get_license_key( $this->type ) );
    25     }   
    26    
     25    }
     26
    2727    /**
    2828     * Check license key with API
     
    3131     */
    3232    public function check_remote_key( $key )
    33     {   
     33    {
    3434        if ( empty( $key ) ) {
    3535            return false;
    3636        }
    37        
    38         // check key with remote API       
    39         $response = wp_remote_post( 'http://www.codepress.nl/', array(         
     37
     38        // check key with remote API
     39        $response = wp_remote_post( 'http://www.codepress.nl/', array(
    4040            'body'  => array(
    4141                'api'   => 'addon',
    4242                'key'   => $key,
    43                 'type'  => $this->type             
     43                'type'  => $this->type
    4444            )
    4545        ));
     
    4949            return true;
    5050        }
    51    
     51
    5252        return false;
    5353    }
    54    
     54
    5555    /**
    5656     * Set masked license key
     
    5858     * @since 1.3.1
    5959     */
    60     public function get_masked_license_key() 
     60    public function get_masked_license_key()
    6161    {
    62         return '**************************'.substr( $this->get_license_key(), -4 );     
    63     }   
    64        
     62        return '**************************'.substr( $this->get_license_key(), -4 );
     63    }
     64
    6565    /**
    6666     * Get license key
     
    7272        return get_option("cpac_{$this->type}_ac");
    7373    }
    74    
     74
    7575    /**
    7676     * Set license key
     
    7979     */
    8080    public function set_license_key( $key )
    81     {           
     81    {
    8282        update_option( "cpac_{$this->type}_ac", trim( $key ) );
    8383    }
    84    
     84
    8585    /**
    8686     * Remove license key
     
    9292        delete_option( "cpac_{$this->type}_ac" );
    9393        delete_transient("cpac_{$this->type}_trnsnt");
    94     }   
     94    }
    9595}
  • codepress-admin-columns/trunk/classes/sortable.php

    r637026 r638877  
    88 */
    99class Codepress_Sortable_Columns extends Codepress_Admin_Columns
    10 {   
    11     private $post_types, 
    12             $unlocked, 
     10{
     11    private $post_types,
     12            $unlocked,
    1313            $show_all_results,
    1414            $current_user_id;
    15    
     15
    1616    /**
    1717     * Constructor
     
    2323        add_action( 'wp_loaded', array( $this, 'init') );
    2424    }
    25    
     25
    2626    /**
    2727     * Initialize
     
    3232    {
    3333        $licence = new cpac_licence('sortable');
    34        
     34
    3535        // vars
    3636        $this->unlocked         = $licence->is_unlocked();
     
    3838        $this->show_all_results = false;
    3939        $this->current_user_id  = get_current_user_id();
    40        
     40
    4141        // init sorting
    4242        add_action( 'admin_init', array( $this, 'register_sortable_columns' ) );
    43        
     43
    4444        // init filtering
    4545        add_action( 'admin_init', array( $this, 'register_filtering_columns' ) );
    46        
     46
    4747        // handle requests for sorting columns
    4848        add_filter( 'request', array( $this, 'handle_requests_orderby_column'), 1 );
     
    5050        add_action( 'admin_init', array( $this, 'handle_requests_orderby_links_column'), 1 );
    5151        add_action( 'admin_init', array( $this, 'handle_requests_orderby_comments_column'), 1 );
    52     }   
    53    
     52    }
     53
    5454    /**
    5555     *  Register sortable columns
     
    6363        if ( ! $this->unlocked )
    6464            return false;
    65    
     65
    6666        /** Posts */
    6767        foreach ( $this->post_types as $post_type ) {
    68             add_filter( "manage_edit-{$post_type}_sortable_columns", array($this, 'callback_add_sortable_posts_column'));               
    69         }
    70        
     68            add_filter( "manage_edit-{$post_type}_sortable_columns", array($this, 'callback_add_sortable_posts_column'));
     69        }
     70
    7171        /** Users */
    7272        add_filter( "manage_users_sortable_columns", array($this, 'callback_add_sortable_users_column'));
    73        
     73
    7474        /** Media */
    7575        add_filter( "manage_upload_sortable_columns", array($this, 'callback_add_sortable_media_column'));
    76        
     76
    7777        /** Links */
    7878        add_filter( "manage_link-manager_sortable_columns", array($this, 'callback_add_sortable_links_column'));
    79        
     79
    8080        /** Comments */
    8181        add_filter( "manage_edit-comments_sortable_columns", array($this, 'callback_add_sortable_comments_column'));
    8282    }
    83    
     83
    8484    /**
    8585     *  Callback add Posts sortable column
     
    8787     *  @since     1.0
    8888     */
    89     public function callback_add_sortable_posts_column($columns) 
     89    public function callback_add_sortable_posts_column($columns)
    9090    {
    9191        global $post_type;
    92        
     92
    9393        // in some cases post_type is an array ( when clicking a tag inside the overview screen icm CCTM ), then we use this as a fallback so we get a string
    9494        if ( is_array($post_type) )
    9595            $post_type = $_REQUEST['post_type'];
    96        
     96
    9797        return $this->add_managed_sortable_columns($post_type, $columns);
    9898    }
     
    103103     *  @since     1.1
    104104     */
    105     public function callback_add_sortable_users_column($columns) 
     105    public function callback_add_sortable_users_column($columns)
    106106    {
    107107        return $this->add_managed_sortable_columns('wp-users', $columns);
    108108    }
    109    
     109
    110110    /**
    111111     *  Callback add Media sortable column
     
    113113     *  @since     1.3
    114114     */
    115     public function callback_add_sortable_media_column($columns) 
     115    public function callback_add_sortable_media_column($columns)
    116116    {
    117117        return $this->add_managed_sortable_columns('wp-media', $columns);
    118118    }
    119    
     119
    120120    /**
    121121     *  Callback add Links sortable column
     
    123123     *  @since     1.3.1
    124124     */
    125     public function callback_add_sortable_links_column($columns) 
     125    public function callback_add_sortable_links_column($columns)
    126126    {
    127127        return $this->add_managed_sortable_columns('wp-links', $columns);
    128128    }
    129    
     129
    130130    /**
    131131     *  Callback add Comments sortable column
     
    133133     *  @since     1.3.1
    134134     */
    135     public function callback_add_sortable_comments_column($columns) 
     135    public function callback_add_sortable_comments_column($columns)
    136136    {
    137137        return $this->add_managed_sortable_columns('wp-comments', $columns);
    138138    }
    139    
     139
    140140    /**
    141141     *  Add managed sortable columns by Type
     
    143143     *  @since     1.1
    144144     */
    145     private function add_managed_sortable_columns( $type = 'post', $columns ) 
    146     {       
     145    private function add_managed_sortable_columns( $type = 'post', $columns )
     146    {
    147147        $display_columns    = $this->get_merged_columns($type);
    148        
     148
    149149        if ( ! $display_columns )
    150150            return $columns;
    151        
     151
    152152        foreach ( $display_columns as $id => $vars ) {
    153             if ( isset($vars['options']['sortorder']) && $vars['options']['sortorder'] == 'on' ){           
    154                
     153            if ( isset($vars['options']['sortorder']) && $vars['options']['sortorder'] == 'on' ){
     154
    155155                // register format
    156                 $columns[$id] = $this->sanitize_string($vars['label']);         
     156                $columns[$id] = $this->sanitize_string($vars['label']);
    157157            }
    158         }   
     158        }
    159159
    160160        return $columns;
    161161    }
    162    
     162
    163163    /**
    164164     * Admin requests for orderby column
     
    168168     * @since     1.0
    169169     */
    170     public function handle_requests_orderby_column( $vars ) 
     170    public function handle_requests_orderby_column( $vars )
    171171    {
    172172        /** Users */
    173         // You would expect to see get_orderby_users_vars(), but sorting for 
     173        // You would expect to see get_orderby_users_vars(), but sorting for
    174174        // users is handled through a different filter. Not 'request', but 'pre_user_query'.
    175175        // See handle_requests_orderby_users_column().
    176                        
     176
    177177        /** Media */
    178178        if ( $this->request_uri_is('upload') ) {
    179179            $vars = $this->get_orderby_media_vars($vars);
    180180        }
    181        
     181
    182182        /** Posts */
    183183        elseif ( !empty($vars['post_type']) ) {
    184             $vars = $this->get_orderby_posts_vars($vars);   
    185         }
    186                
     184            $vars = $this->get_orderby_posts_vars($vars);
     185        }
     186
    187187        return $vars;
    188     }   
    189    
     188    }
     189
    190190    /**
    191191     * Orderby Users column
     
    194194     */
    195195    public function handle_requests_orderby_users_column($user_query)
    196     {       
     196    {
    197197        // query vars
    198         $vars = $user_query->query_vars;   
    199        
     198        $vars = $user_query->query_vars;
     199
    200200        // Column
    201201        $column = $this->get_orderby_type( $vars['orderby'], 'wp-users' );
    202202
    203203        if ( empty($column) )
    204             return $user_query;     
    205        
     204            return $user_query;
     205
    206206        // id
    207207        $type = $id = key($column);
    208        
     208
    209209        // Check for user custom fields: column-meta-[customfieldname]
    210210        if ( Codepress_Admin_Columns::is_column_meta($type) )
    211211            $type = 'column-user-meta';
    212        
     212
    213213        // Check for post count: column-user_postcount-[posttype]
    214214        if ( Codepress_Admin_Columns::get_posttype_by_postcount_column($type) )
    215215            $type = 'column-user_postcount';
    216        
     216
    217217        // var
    218         $cusers = array();     
     218        $cusers = array();
    219219        switch( $type ) :
    220            
     220
    221221            case 'column-user_id':
    222222                $user_query->query_orderby = "ORDER BY ID {$user_query->query_vars['order']}";
    223223                $user_query->query_vars['orderby'] = 'ID';
    224224                break;
    225                
    226             case 'column-user_registered':             
     225
     226            case 'column-user_registered':
    227227                $user_query->query_orderby = "ORDER BY user_registered {$user_query->query_vars['order']}";
    228228                $user_query->query_vars['orderby'] = 'registered';
    229229                break;
    230            
     230
    231231            case 'column-nickname' :
    232232                $sort_flag = SORT_REGULAR;
     
    235235                        $cusers[$u->ID] = $this->prepare_sort_string_value($u->nickname);
    236236                    }
    237                 }               
    238                 break;
    239            
     237                }
     238                break;
     239
    240240            case 'column-first_name' :
    241241                $sort_flag = SORT_REGULAR;
     
    244244                        $cusers[$u->ID] = $this->prepare_sort_string_value($u->first_name);
    245245                    }
    246                 }               
    247                 break;
    248            
     246                }
     247                break;
     248
    249249            case 'column-last_name' :
    250250                $sort_flag = SORT_REGULAR;
     
    253253                        $cusers[$u->ID] = $this->prepare_sort_string_value($u->last_name);
    254254                    }
    255                 }               
    256                 break;
    257                
     255                }
     256                break;
     257
    258258            case 'column-user_url' :
    259259                $sort_flag = SORT_REGULAR;
     
    262262                        $cusers[$u->ID] = $this->prepare_sort_string_value($u->user_url);
    263263                    }
    264                 }               
    265                 break;
    266            
     264                }
     265                break;
     266
    267267            case 'column-user_description' :
    268268                $sort_flag = SORT_REGULAR;
     
    271271                        $cusers[$u->ID] = $this->prepare_sort_string_value($u->user_description);
    272272                    }
    273                 }               
    274                 break;
    275            
    276             case 'column-user_postcount' :             
     273                }
     274                break;
     275
     276            case 'column-user_postcount' :
    277277                $post_type  = Codepress_Admin_Columns::get_posttype_by_postcount_column($id);
    278278                if ( $post_type ) {
     
    281281                        $count = Codepress_Admin_Columns::get_post_count( $post_type, $u->ID );
    282282                        $cusers[$u->ID] = $this->prepare_sort_string_value($count);
    283                     }                   
    284                 }
    285                 break;
    286            
    287             case 'column-user-meta' :   
     283                    }
     284                }
     285                break;
     286
     287            case 'column-user-meta' :
    288288                $field = $column[$id]['field'];
    289289                if ( $field ) {
    290                
     290
    291291                    // order numeric or string
    292292                    $sort_flag = SORT_REGULAR;
     
    294294                        $sort_flag = SORT_NUMERIC;
    295295                    }
    296                    
     296
    297297                    // sort by metavalue
    298298                    foreach ( $this->get_users_data() as $u ) {
    299299                        $value = get_metadata('user', $u->ID, $field, true);
    300300                        $cusers[$u->ID] = $this->prepare_sort_string_value($value);
    301                     }                   
    302                 }
    303                 break;
    304            
     301                    }
     302                }
     303                break;
     304
    305305            /** native WP columns */
    306            
     306
    307307            // role column
    308308            case 'role' :
     
    314314                    }
    315315                }
    316                 break;         
    317        
    318         endswitch;     
    319        
     316                break;
     317
     318        endswitch;
     319
    320320        if ( isset($sort_flag) ) {
    321321            $user_query = $this->get_users_query_vars( $user_query, $cusers, $sort_flag );
    322322        }
    323        
     323
    324324        return $user_query;
    325325    }
    326    
     326
    327327    /**
    328328     *  Orderby Links column
    329329     *
    330      *  Makes use of filter 'get_bookmarks' from bookmark.php to change the result set of the links 
     330     *  Makes use of filter 'get_bookmarks' from bookmark.php to change the result set of the links
    331331     *
    332332     *  @since     1.3.1
     
    337337        if ( $this->request_uri_is('link-manager') )
    338338            add_filter( 'get_bookmarks', array( $this, 'callback_requests_orderby_links_column'), 10, 2);
    339     }   
    340    
     339    }
     340
    341341    /**
    342342     *  Orderby Links column
    343      * 
     343     *
    344344     *  @since     1.3.1
    345345     */
    346     public function callback_requests_orderby_links_column($results, $vars) 
    347     {   
    348         global $wpdb;       
    349        
     346    public function callback_requests_orderby_links_column($results, $vars)
     347    {
     348        global $wpdb;
     349
    350350        // apply sorting preference
    351351        $this->apply_sorting_preference( $vars, 'wp-links' );
    352        
     352
    353353        // Column
    354354        $column = $this->get_orderby_type( $vars['orderby'], 'wp-links' );
    355355
    356356        if ( empty($column) )
    357             return $results;       
    358        
     357            return $results;
     358
    359359        // id
    360360        $type = $id = key($column);
    361361
    362362        // var
    363         $length = '';       
     363        $length = '';
    364364        switch( $type ) :
    365            
     365
    366366            case 'column-link_id':
    367367                if ( version_compare( get_bloginfo('version'), '3.2', '>' ) )
     
    370370                    $vars['orderby'] = 'id';
    371371                break;
    372                
     372
    373373            case 'column-owner':
    374374                $vars['orderby'] = 'link_owner';
    375375                break;
    376            
     376
    377377            case 'column-length':
    378378                $vars['orderby'] = 'length';
    379379                $length = ", CHAR_LENGTH(link_name) AS length";
    380380                break;
    381            
     381
    382382            case 'column-target':
    383383                $vars['orderby'] = 'link_target';
    384384                break;
    385            
     385
    386386            case 'column-description':
    387387                $vars['orderby'] = 'link_description';
    388388                break;
    389                
     389
    390390            case 'column-notes':
    391391                $vars['orderby'] = 'link_notes';
    392392                break;
    393            
     393
    394394            case 'column-rss':
    395395                $vars['orderby'] = 'link_rss';
    396396                break;
    397            
     397
    398398            /** native WP columns */
    399            
     399
    400400            // Relationship
    401             case 'rel':             
     401            case 'rel':
    402402                $vars['orderby'] = 'link_rel';
    403403                break;
    404            
     404
    405405            default:
    406                 $vars['orderby'] = '';         
    407        
     406                $vars['orderby'] = '';
     407
    408408        endswitch;
    409        
     409
    410410        // get bookmarks by orderby vars
    411411        if ( $vars['orderby'] ) {
    412             $vars['order']  = mysql_escape_string($vars['order']);         
    413             $sql            = "SELECT * {$length} FROM {$wpdb->links} WHERE 1=1 ORDER BY {$vars['orderby']} {$vars['order']}"; 
     412            $vars['order']  = mysql_escape_string($vars['order']);
     413            $sql            = "SELECT * {$length} FROM {$wpdb->links} WHERE 1=1 ORDER BY {$vars['orderby']} {$vars['order']}";
    414414            $results        = $wpdb->get_results($sql);
    415            
     415
    416416            // check for errors
    417417            if( is_wp_error($results) )
     
    421421        return $results;
    422422    }
    423    
     423
    424424    /**
    425425     *  Orderby Comments column
    426      * 
     426     *
    427427     *  @since     1.3.1
    428428     */
    429     public function callback_requests_orderby_comments_column($pieces, $ref_comment) 
    430     {
    431         // get query vars       
     429    public function callback_requests_orderby_comments_column($pieces, $ref_comment)
     430    {
     431        // get query vars
    432432        $vars = $ref_comment->query_vars;
    433        
     433
    434434        // Column
    435435        $column = $this->get_orderby_type( $vars['orderby'], 'wp-comments' );
    436436
    437437        if ( empty($column) )
    438             return $pieces;     
    439        
     438            return $pieces;
     439
    440440        // id
    441441        $type = $id = key($column);
    442442
    443         // var 
     443        // var
    444444        switch( $type ) :
    445            
     445
    446446            case 'column-comment_id':
    447447                $pieces['orderby'] = 'comment_ID';
    448448                break;
    449            
     449
    450450            case 'column-author_author':
    451451                $pieces['orderby'] = 'comment_author';
    452452                break;
    453            
     453
    454454            case 'column-author_ip':
    455455                $pieces['orderby'] = 'comment_author_IP';
    456456                break;
    457                
     457
    458458            case 'column-author_url':
    459459                $pieces['orderby'] = 'comment_author_url';
    460460                break;
    461            
     461
    462462            case 'column-author_email':
    463463                $pieces['orderby'] = 'comment_author_email';
    464464                break;
    465            
     465
    466466            case 'column-reply_to':
    467467                break;
    468            
     468
    469469            case 'column-approved':
    470470                $pieces['orderby'] = 'comment_approved';
    471471                break;
    472            
     472
    473473            case 'column-date':
    474474                $pieces['orderby'] = 'comment_date';
    475475                break;
    476            
     476
    477477            case 'column-agent':
    478478                $pieces['orderby'] = 'comment_agent';
    479479                break;
    480            
     480
    481481            case 'column-excerpt':
    482482                $pieces['orderby'] = 'comment_content';
    483483                break;
    484            
     484
    485485            case 'column-date_gmt':
    486486                break;
    487            
     487
    488488            /** native WP columns */
    489            
     489
    490490            // Relationship
    491             case 'comment':             
     491            case 'comment':
    492492                $pieces['orderby'] = 'comment_content';
    493493                break;
    494            
     494
    495495            default:
    496                 $vars['orderby'] = '';         
    497        
     496                $vars['orderby'] = '';
     497
    498498        endswitch;
    499499
    500500        return $pieces;
    501501    }
    502    
     502
    503503    /**
    504504     *  Orderby Comments column
     
    507507     */
    508508    public function handle_requests_orderby_comments_column()
    509     {       
     509    {
    510510        // fire only when we are in the admins edit-comments
    511511        if ( $this->request_uri_is('edit-comments') ) {
     
    513513        }
    514514    }
    515    
     515
    516516    /**
    517517     * Get sorting vars in User Query Object
     
    520520     */
    521521    private function get_users_query_vars( $user_query, $sortusers, $sort_flags = SORT_REGULAR )
    522     {   
     522    {
    523523        global $wpdb;
    524        
     524
    525525        // vars
    526526        $vars = $user_query->query_vars;
     
    532532            arsort($sortusers, $sort_flags);
    533533
    534         // alter orderby SQL       
    535         if ( ! empty ( $sortusers ) ) {         
     534        // alter orderby SQL
     535        if ( ! empty ( $sortusers ) ) {
    536536            $ids = implode(',', array_keys($sortusers));
    537537            $user_query->query_where    .= " AND {$wpdb->prefix}users.ID IN ({$ids})";
    538538            $user_query->query_orderby  = "ORDER BY FIELD({$wpdb->prefix}users.ID,{$ids})";
    539539        }
    540        
     540
    541541        // cleanup the vars we dont need
    542542        $vars['order']      = '';
    543543        $vars['orderby']    = '';
    544        
     544
    545545        // set query vars
    546546        $user_query->query_vars = $vars;
    547        
     547
    548548        return $user_query;
    549     }   
    550    
     549    }
     550
    551551    /**
    552552     * Orderby Media column
     
    555555     */
    556556    private function get_orderby_media_vars($vars)
    557     {       
     557    {
    558558        // apply sorting preference
    559559        $this->apply_sorting_preference( $vars, 'wp-media' );
    560        
     560
    561561        // when sorting still isn't set we will just return the requested vars
    562562        if ( empty( $vars['orderby'] ) )
    563563            return $vars;
    564        
     564
    565565        // Column
    566         $column = $this->get_orderby_type( $vars['orderby'], 'wp-media' );     
     566        $column = $this->get_orderby_type( $vars['orderby'], 'wp-media' );
    567567
    568568        if ( empty($column) )
    569569            return $vars;
    570        
     570
    571571        $id = key($column);
    572        
     572
    573573        // var
    574         $cposts = array();     
     574        $cposts = array();
    575575        switch( $id ) :
    576        
     576
    577577            case 'column-mediaid' :
    578578                $vars['orderby'] = 'ID';
    579579                break;
    580            
     580
    581581            case 'column-width' :
    582582                $sort_flag = SORT_NUMERIC;
     
    588588                }
    589589                break;
    590                
     590
    591591            case 'column-height' :
    592592                $sort_flag = SORT_NUMERIC;
     
    598598                }
    599599                break;
    600            
     600
    601601            case 'column-dimensions' :
    602602                $sort_flag = SORT_NUMERIC;
     
    606606                    $width   = !empty($meta['width'])   ? $meta['width']    : 0;
    607607                    $surface = $height*$width;
    608                    
     608
    609609                    if ( $surface || $this->show_all_results )
    610610                        $cposts[$p->ID] = $surface;
    611611                }
    612612                break;
    613            
     613
    614614            case 'column-caption' :
    615615                $sort_flag = SORT_STRING;
     
    620620                }
    621621                break;
    622                
     622
    623623            case 'column-description' :
    624624                $sort_flag = SORT_STRING;
     
    629629                }
    630630                break;
    631            
     631
    632632            case 'column-mime_type' :
    633633                $sort_flag = SORT_STRING;
     
    636636                        $cposts[$p->ID] = $this->prepare_sort_string_value( $p->post_mime_type );
    637637                    }
    638                 }       
    639                 break;
    640            
     638                }
     639                break;
     640
    641641            case 'column-file_name' :
    642642                $sort_flag = SORT_STRING;
    643                 foreach ( $this->get_any_posts_by_posttype('attachment') as $p ) {         
    644                     $meta   = get_post_meta($p->ID, '_wp_attached_file', true);                 
     643                foreach ( $this->get_any_posts_by_posttype('attachment') as $p ) {
     644                    $meta   = get_post_meta($p->ID, '_wp_attached_file', true);
    645645                    $file   = !empty($meta) ? basename($meta) : '';
    646646                    if ( $file || $this->show_all_results ) {
    647647                        $cposts[$p->ID] = $file;
    648648                    }
    649                 }               
     649                }
    650650                break;
    651651
     
    659659                }
    660660                break;
    661                
     661
    662662            case 'column-filesize' :
    663663                $sort_flag = SORT_NUMERIC;
    664664                foreach ( $this->get_any_posts_by_posttype('attachment') as $p ) {
    665                     $file   = wp_get_attachment_url($p->ID);                   
     665                    $file   = wp_get_attachment_url($p->ID);
    666666                    if ( $file || $this->show_all_results ) {
    667667                        $abs            = str_replace( WP_CONTENT_URL, WP_CONTENT_DIR, $file);
     
    670670                }
    671671                break;
    672        
     672
    673673        endswitch;
    674        
     674
    675675        // we will add the sorted post ids to vars['post__in'] and remove unused vars
    676676        if ( isset($sort_flag) ) {
     
    680680        return $vars;
    681681    }
    682    
     682
    683683    /**
    684684     * Orderby Posts column
     
    689689    {
    690690        $post_type = $vars['post_type'];
    691        
     691
    692692        // apply sorting preference
    693693        $this->apply_sorting_preference( $vars, $post_type );
    694    
     694
    695695        // no sorting
    696         if ( empty( $vars['orderby'] ) ) {             
    697             return $vars;       
    698         }
    699        
     696        if ( empty( $vars['orderby'] ) ) {
     697            return $vars;
     698        }
     699
    700700        // Column
    701         $column = $this->get_orderby_type( $vars['orderby'], $post_type );     
     701        $column = $this->get_orderby_type( $vars['orderby'], $post_type );
    702702
    703703        if ( empty($column) )
    704704            return $vars;
    705        
     705
    706706        // id
    707707        $type = $id = key($column);
    708    
    709         // Check for taxonomies, such as column-taxonomy-[taxname] 
     708
     709        // Check for taxonomies, such as column-taxonomy-[taxname]
    710710        if ( strpos($type, 'column-taxonomy-') !== false )
    711711            $type = 'column-taxonomy';
    712        
     712
    713713        // Check for Custom Field
    714714        if ( Codepress_Admin_Columns::is_column_meta($type) )
     
    716716
    717717        // var
    718         $cposts = array();     
     718        $cposts = array();
    719719        switch( $type ) :
    720        
     720
    721721            case 'column-postid' :
    722722                $vars['orderby'] = 'ID';
    723723                break;
    724                
    725             case 'column-order' : 
     724
     725            case 'column-order' :
    726726                $vars['orderby'] = 'menu_order';
    727727                break;
    728                
    729             case 'column-modified' : 
     728
     729            case 'column-modified' :
    730730                $vars['orderby'] = 'modified';
    731731                break;
    732            
    733             case 'column-comment-count' : 
     732
     733            case 'column-comment-count' :
    734734                $vars['orderby'] = 'comment_count';
    735735                break;
    736            
    737             case 'column-post-meta' :               
    738                 $field      = $column[$id]['field'];               
    739                
     736
     737            case 'column-post-meta' :
     738                $field      = $column[$id]['field'];
     739
    740740                // orderby type
    741741                $field_type = 'meta_value';
     
    748748                ));
    749749                break;
    750                
     750
    751751            case 'column-excerpt' :
    752752                $sort_flag = SORT_STRING;
    753753                foreach ( $this->get_any_posts_by_posttype($post_type) as $p ) {
    754754                    $cposts[$p->ID] = $this->prepare_sort_string_value($p->post_content);
    755                 }               
    756                 break;
    757                
     755                }
     756                break;
     757
    758758            case 'column-word-count' :
    759759                $sort_flag = SORT_NUMERIC;
    760                 foreach ( $this->get_any_posts_by_posttype($post_type) as $p ) {       
     760                foreach ( $this->get_any_posts_by_posttype($post_type) as $p ) {
    761761                    $cposts[$p->ID] = str_word_count( Codepress_Admin_Columns::strip_trim( $p->post_content ) );
    762762                }
    763763                break;
    764                
     764
    765765            case 'column-page-template' :
    766766                $sort_flag = SORT_STRING;
    767767                $templates      = get_page_templates();
    768                 foreach ( $this->get_any_posts_by_posttype($post_type) as $p ) {                   
     768                foreach ( $this->get_any_posts_by_posttype($post_type) as $p ) {
    769769                    $page_template  = get_post_meta($p->ID, '_wp_page_template', true);
    770770                    $cposts[$p->ID] = array_search($page_template, $templates);
    771                 }               
    772                 break;
    773            
     771                }
     772                break;
     773
    774774            case 'column-post_formats' :
    775775                $sort_flag = SORT_REGULAR;
    776                 foreach ( $this->get_any_posts_by_posttype($post_type) as $p ) {                   
     776                foreach ( $this->get_any_posts_by_posttype($post_type) as $p ) {
    777777                    $cposts[$p->ID] = get_post_format($p->ID);
    778778                }
    779779                break;
    780                
     780
    781781            case 'column-attachment' :
    782782            case 'column-attachment-count' :
     
    785785                    $cposts[$p->ID] = count( Codepress_Admin_Columns::get_attachment_ids($p->ID) );
    786786                }
    787                 break;             
    788                
     787                break;
     788
    789789            case 'column-page-slug' :
    790790                $sort_flag = SORT_REGULAR;
    791791                foreach ( $this->get_any_posts_by_posttype($post_type) as $p ) {
    792792                    $cposts[$p->ID] = $p->post_name;
    793                 }               
    794                 break;
    795            
     793                }
     794                break;
     795
    796796            case 'column-sticky' :
    797797                $sort_flag = SORT_REGULAR;
     
    804804                }
    805805                break;
    806            
     806
    807807            case 'column-featured_image' :
    808808                $sort_flag = SORT_REGULAR;
     
    815815                }
    816816                break;
    817            
     817
    818818            case 'column-roles' :
    819819                $sort_flag = SORT_STRING;
     
    826826                }
    827827                break;
    828            
     828
    829829            case 'column-status' :
    830830                $sort_flag = SORT_STRING;
     
    833833                }
    834834                break;
    835            
    836             case 'column-comment-status' : 
     835
     836            case 'column-comment-status' :
    837837                $sort_flag = SORT_STRING;
    838838                foreach ( $this->get_any_posts_by_posttype($post_type) as $p ) {
     
    840840                }
    841841                break;
    842            
    843             case 'column-ping-status' : 
     842
     843            case 'column-ping-status' :
    844844                $sort_flag = SORT_STRING;
    845845                foreach ( $this->get_any_posts_by_posttype($post_type) as $p ) {
     
    847847                }
    848848                break;
    849            
     849
    850850            case 'column-taxonomy' :
    851851                $sort_flag  = SORT_STRING; // needed to sort
     
    853853                $cposts     = $this->get_posts_sorted_by_taxonomy($post_type, $taxonomy);
    854854                break;
    855                
     855
    856856            case 'column-author-name' :
    857857                $sort_flag  = SORT_STRING;
     
    862862                foreach ( $this->get_any_posts_by_posttype($post_type) as $p ) {
    863863                    if ( !empty($p->post_author) ) {
    864                         $name = Codepress_Admin_Columns::get_author_field_by_nametype($display_as, $p->post_author);                           
     864                        $name = Codepress_Admin_Columns::get_author_field_by_nametype($display_as, $p->post_author);
    865865                        $cposts[$p->ID] = $name;
    866866                    }
    867867                }
    868868                break;
    869                
     869
    870870            case 'column-before-moretag' :
    871871                $sort_flag = SORT_STRING;
    872872                foreach ( $this->get_any_posts_by_posttype($post_type) as $p ) {
    873873                    $extended   = get_extended($p->post_content);
    874                     $content    = !empty($extended['extended']) ? $extended['main'] : '';                   
     874                    $content    = !empty($extended['extended']) ? $extended['main'] : '';
    875875                    $cposts[$p->ID] = $this->prepare_sort_string_value($content);
    876876                }
    877877                break;
    878            
     878
    879879            /** native WP columns */
    880            
     880
    881881            // categories
    882882            case 'categories' :
     
    884884                $cposts     = $this->get_posts_sorted_by_taxonomy($post_type, 'category');
    885885                break;
    886                
     886
    887887            // tags
    888888            case 'tags' :
     
    890890                $cposts     = $this->get_posts_sorted_by_taxonomy($post_type, 'post_tag');
    891891                break;
    892            
    893         endswitch;         
    894        
     892
     893        endswitch;
     894
    895895        // we will add the sorted post ids to vars['post__in'] and remove unused vars
    896896        if ( isset($sort_flag) ) {
     
    900900        return $vars;
    901901    }
    902    
     902
    903903    /**
    904904     * Set sorting preference
    905905     *
    906906     * after sorting we will save this sorting preference to the column item
    907      * we set the default_order to either asc, desc or empty. 
     907     * we set the default_order to either asc, desc or empty.
    908908     * only ONE column item PER type can have a default_order
    909909     *
     
    914914        if ( !$orderby )
    915915            return false;
    916                
     916
    917917        $options = get_user_meta( $this->current_user_id, 'cpac_sorting_preference', true );
    918        
     918
    919919        $options[$type] = array(
    920920            'orderby'   => $orderby,
    921921            'order'     => $order
    922922        );
    923        
     923
    924924        update_user_meta( $this->current_user_id, 'cpac_sorting_preference', $options );
    925925    }
    926    
     926
    927927    /**
    928928     *  Get sorting preference
     
    936936    {
    937937        $options = get_user_meta( $this->current_user_id, 'cpac_sorting_preference', true );
    938        
    939         if ( empty($options[$type]) ) 
     938
     939        if ( empty($options[$type]) )
    940940            return false;
    941        
     941
    942942        return $options[$type];
    943943    }
    944    
     944
    945945    /**
    946946     * Apply sorting preference
     
    952952        // user has not sorted
    953953        if ( empty( $vars['orderby'] ) ) {
    954        
     954
    955955            // did the user sorted this column some other time?
    956956            if ( $preference = $this->get_sorting_preference($type) ) {
    957957                $vars['orderby']    = $preference['orderby'];
    958958                $vars['order']      = $preference['order'];
    959                
     959
    960960                // used by active state in column header
    961961                $_GET['orderby'] = $preference['orderby'];
     
    969969        }
    970970    }
    971    
     971
    972972    /**
    973973     * Get posts sorted by taxonomy
     
    977977     * @since     1.4.5
    978978     */
    979     function get_posts_sorted_by_taxonomy($post_type, $taxonomy = 'category') 
     979    function get_posts_sorted_by_taxonomy($post_type, $taxonomy = 'category')
    980980    {
    981981        $cposts     = array();
    982982        foreach ( $this->get_any_posts_by_posttype($post_type) as $p ) {
    983             $cposts[$p->ID] = '';                       
     983            $cposts[$p->ID] = '';
    984984            $terms = get_the_terms($p->ID, $taxonomy);
    985985            if ( !is_wp_error($terms) && !empty($terms) ) {
     
    988988                if ( isset($term->term_id) ) {
    989989                    $cposts[$p->ID] = sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display');
    990                 }                       
     990                }
    991991            }
    992992        }
    993993        return $cposts;
    994994    }
    995    
     995
    996996    /**
    997997     * Set post__in for use in WP_Query
     
    10161016        $vars['order']      = '';
    10171017        $vars['orderby']    = '';
    1018        
     1018
    10191019        // add the sorted post ids to the query with the use of post__in
    10201020        $vars['post__in'] = array_keys($sortposts);
    1021        
     1021
    10221022        return $vars;
    10231023    }
    1024    
     1024
    10251025    /**
    10261026     * Get orderby type
     
    10291029     */
    10301030    private function get_orderby_type($orderby, $type)
    1031     {       
     1031    {
    10321032        $db_columns = Codepress_Admin_Columns::get_stored_columns($type);
    10331033
    10341034        if ( $db_columns ) {
    10351035            foreach ( $db_columns as $id => $vars ) {
    1036            
     1036
    10371037                // check which custom column was clicked
    10381038                if ( isset( $vars['label'] ) && $orderby ==  $this->sanitize_string( $vars['label'] ) ) {
    10391039                    $column[$id] = $vars;
    1040                     return $column;
     1040                    return apply_filters( 'cpac-get-orderby-type', $column, $orderby, $type );
    10411041                }
    10421042            }
    10431043        }
    1044         return false;
    1045     }
    1046    
    1047     /**
    1048      * Maintain order of ids that are set in the post__in var. 
    1049      *
    1050      * This will force the returned posts to use the order of the ID's that 
     1044        return apply_filters( 'cpac-get-orderby-type', false, $orderby, $type );
     1045    }
     1046
     1047    /**
     1048     * Maintain order of ids that are set in the post__in var.
     1049     *
     1050     * This will force the returned posts to use the order of the ID's that
    10511051     * have been set in post__in. Without this the ID's will be set in numeric order.
    10521052     * See the WP_Query object for more info about the use of post__in.
     
    10541054     * @since     1.2.1
    10551055     */
    1056     public function filter_orderby_post__in($orderby, $wp) 
     1056    public function filter_orderby_post__in($orderby, $wp)
    10571057    {
    10581058        global $wpdb;
    10591059
    10601060        // we need the query vars
    1061         $vars = $wp->query_vars;   
    1062         if ( ! empty ( $vars['post__in'] ) ) {         
     1061        $vars = $wp->query_vars;
     1062        if ( ! empty ( $vars['post__in'] ) ) {
    10631063            // now we can get the ids
    10641064            $ids = implode(',', $vars['post__in']);
    1065            
     1065
    10661066            // by adding FIELD to the SQL query we are forcing the order of the ID's
    10671067            return "FIELD({$wpdb->prefix}posts.ID,{$ids})";
    10681068        }
    10691069    }
    1070    
     1070
    10711071    /**
    10721072     * Get any posts by post_type
     
    10811081            'post_type'     => $post_type
    10821082        ));
    1083        
     1083
    10841084        // trash posts are not included in the posts_status 'any' by default
    10851085        $trash_posts = (array) get_posts(array(
     
    10871087            'post_status'   => 'trash',
    10881088            'post_type'     => $post_type
    1089         ));     
    1090        
     1089        ));
     1090
    10911091        $all_posts = array_merge($any_posts, $trash_posts);
    1092        
    1093         return (array) $all_posts;     
    1094     }
    1095    
     1092
     1093        return (array) $all_posts;
     1094    }
     1095
    10961096    /**
    10971097     * Request URI is
     
    11011101    private function request_uri_is( $screen_id = '' )
    11021102    {
    1103         if (strpos( $_SERVER['REQUEST_URI'], "/{$screen_id}.php" ) !== false ) 
     1103        if (strpos( $_SERVER['REQUEST_URI'], "/{$screen_id}.php" ) !== false )
    11041104            return true;
    1105        
     1105
    11061106        return false;
    11071107    }
    1108    
     1108
    11091109    /**
    11101110     * Prepare the value for being by sorting
     
    11161116        // remove tags and only get the first 20 chars and force lowercase.
    11171117        $string = strtolower( substr( Codepress_Admin_Columns::strip_trim($string),0 ,20 ) );
    1118        
     1118
    11191119        return $string;
    11201120    }
    1121    
     1121
    11221122    /**
    11231123     * Get users data
     
    11251125     * @since     1.3
    11261126     */
    1127     function get_users_data() 
     1127    function get_users_data()
    11281128    {
    11291129        $userdatas = array();
    11301130        $wp_users = get_users( array(
    1131             'blog_id' => $GLOBALS['blog_id'],       
     1131            'blog_id' => $GLOBALS['blog_id'],
    11321132        ));
    11331133        foreach ( $wp_users as $u ) {
     
    11361136        return $userdatas;
    11371137    }
    1138    
     1138
    11391139    /**
    11401140     *  Register filtering columns
     
    11461146        if ( ! $this->unlocked || apply_filters( 'cpac-remove-filtering-columns', true ) )
    11471147            return false;
    1148        
     1148
    11491149        // hook into wordpress
    11501150        add_action('restrict_manage_posts', array($this, 'callback_restrict_posts'));
    11511151    }
    1152    
     1152
    11531153    /**
    11541154     *  Add taxonomy filters to posts
     
    11591159    {
    11601160        global $post_type_object;
    1161        
     1161
    11621162        if ( !isset($post_type_object->name) )
    11631163            return false;
     
    11651165        // make a filter foreach taxonomy
    11661166        $taxonomies = get_object_taxonomies($post_type_object->name, 'names');
    1167        
     1167
    11681168        // get stored columns
    11691169        $db_columns = Codepress_Admin_Columns::get_stored_columns($post_type_object->name);
     
    11711171        if ( $taxonomies ) {
    11721172            foreach ( $taxonomies as $tax ) {
    1173            
     1173
    11741174                // ignore core taxonomies
    11751175                if ( in_array($tax, array('post_tag','category','post_format') ) ) {
    11761176                    continue;
    11771177                }
    1178                
     1178
    11791179                // only display taxonomy that is active as a column
    11801180                if ( isset($db_columns['column-taxonomy-'.$tax]) && $db_columns['column-taxonomy-'.$tax]['state'] == 'on' ) {
    1181                    
     1181
    11821182                    $terms = get_terms($tax);
    11831183                    $terms = $this->indent($terms, 0, 'parent', 'term_id');
    11841184                    $terms = $this->apply_dropdown_markup($terms);
    1185                      
     1185
    11861186                    $select = "<option value=''>".__('Show all ', CPAC_TEXTDOMAIN)."{$tax}</option>";
    11871187                    if (!empty($terms)) {
    11881188                        foreach( $terms as $term_slug => $term) {
    1189                            
     1189
    11901190                            $selected = isset($_GET[$tax]) && $term_slug == $_GET[$tax] ? " selected='selected'" : '';
    11911191                            $select .= "<option value='{$term_slug}'{$selected}>{$term}</option>";
    11921192                        }
    11931193                        echo "<select class='postform' name='{$tax}'>{$select}</select>";
    1194                     }                   
     1194                    }
    11951195                }
    11961196            }
    11971197        }
    11981198    }
    1199    
     1199
    12001200    /**
    12011201     *  Applies dropdown markup for taxonomy dropdown
     
    12041204     */
    12051205    private function apply_dropdown_markup($array, $level = 0, $output = array())
    1206     {               
     1206    {
    12071207        foreach($array as $v) {
    1208            
    1209             $prefix = '';       
     1208
     1209            $prefix = '';
    12101210            for($i=0; $i<$level; $i++) {
    1211                 $prefix .= '&nbsp;&nbsp;'; 
     1211                $prefix .= '&nbsp;&nbsp;';
    12121212            }
    12131213
    12141214            $output[$v->slug] = $prefix . $v->name;
    1215            
     1215
    12161216            if ( !empty($v->children) ) {
    12171217                $output = $this->apply_dropdown_markup($v->children, ($level + 1), $output);
    12181218            }
    12191219        }
    1220        
     1220
    12211221        return $output;
    12221222    }
    1223    
     1223
    12241224    /**
    12251225     * Indents any object as long as it has a unique id and that of its parent.
     
    12271227     * @since     1.4.2
    12281228     */
    1229     private function indent($array, $parentId = 0, $parentKey = 'post_parent', $selfKey = 'ID', $childrenKey = 'children') 
     1229    private function indent($array, $parentId = 0, $parentKey = 'post_parent', $selfKey = 'ID', $childrenKey = 'children')
    12301230    {
    12311231        $indent = array();
    1232        
     1232
    12331233        // clean counter
    12341234        $i = 0;
    1235        
     1235
    12361236        foreach($array as $v) {
    12371237
     
    12391239                $indent[$i] = $v;
    12401240                $indent[$i]->$childrenKey = $this->indent($array, $v->$selfKey, $parentKey, $selfKey);
    1241                
     1241
    12421242                $i++;
    12431243            }
  • codepress-admin-columns/trunk/classes/values.php

    r637026 r638877  
    88 */
    99class CPAC_Values
    10 {   
     10{
    1111    protected $excerpt_length, $thumbnail_size;
    12    
     12
    1313    /**
    1414     * Constructor
     
    1717     */
    1818    function __construct()
    19     {   
     19    {
    2020        // number of words
    21         $this->excerpt_length   = 20;       
     21        $this->excerpt_length   = 20;
    2222        $this->thumbnail_size   = apply_filters( 'cpac_thumbnail_size', array(80,80) );
    2323    }
    24    
     24
    2525    /**
    2626     * Admin requests for orderby column
     
    2929     */
    3030    public function get_stored_columns($type)
    31     { 
     31    {
    3232        return Codepress_Admin_Columns::get_stored_columns($type);
    3333    }
    34    
     34
    3535    /**
    3636     * Checks if column-meta key exists
     
    3838     * @since     1.0
    3939     */
    40     public static function is_column_meta( $id = '' ) 
     40    public static function is_column_meta( $id = '' )
    4141    {
    4242        return Codepress_Admin_Columns::is_column_meta( $id );
    4343    }
    44    
     44
    4545    /**
    4646     * Returns excerpt
     
    4848     * @since     1.0
    4949     */
    50     protected function get_post_excerpt($post_id) 
     50    protected function get_post_excerpt($post_id)
    5151    {
    5252        global $post;
    53            
     53
    5454        $save_post  = $post;
    5555        $post       = get_post($post_id);
    5656        $excerpt    = get_the_excerpt();
    5757        $post       = $save_post;
    58        
    59         $output = $this->get_shortened_string($excerpt, $this->excerpt_length );   
    60        
     58
     59        $output = $this->get_shortened_string($excerpt, $this->excerpt_length );
     60
    6161        return $output;
    6262    }
    63    
     63
    6464    /**
    6565     * Returns shortened string
     
    6767     * @since     1.0
    6868     */
    69     protected function get_shortened_string($string = '', $num_words = 55, $more = null) 
     69    protected function get_shortened_string($string = '', $num_words = 55, $more = null)
    7070    {
    7171        if (!$string)
    7272            return false;
    73        
     73
    7474        return wp_trim_words( $string, $num_words, $more );
    7575    }
     
    8484        if ( $name )
    8585            return sprintf("<img alt='' src='%s' title='%s'/>", CPAC_URL."/assets/images/{$name}", $title);
    86     }   
    87    
     86    }
     87
    8888    /**
    8989     *  Shorten URL
     
    9595        if ( !$url )
    9696            return false;
    97            
     97
    9898        // shorten url
    9999        $short_url  = url_shorten( $url );
    100        
    101         return "<a title='{$url}' href='{$url}'>{$short_url}</a>";     
    102     }
    103    
     100
     101        return "<a title='{$url}' href='{$url}'>{$short_url}</a>";
     102    }
     103
    104104    /**
    105105     *  Get column value of post attachments
     
    107107     *  @since     1.0
    108108     */
    109     protected function get_column_value_attachments( $post_id ) 
     109    protected function get_column_value_attachments( $post_id )
    110110    {
    111111        $result         = '';
     
    119119        return $result;
    120120    }
    121    
     121
    122122    /**
    123123     *  Get column value of post attachments
     
    125125     *  @since     1.2.1
    126126     */
    127     protected function get_attachment_ids( $post_id ) 
     127    protected function get_attachment_ids( $post_id )
    128128    {
    129129        return Codepress_Admin_Columns::get_attachment_ids( $post_id );
    130130    }
    131    
     131
    132132    /**
    133133     * Get a thumbnail
     
    135135     * @since     1.0
    136136     */
    137     protected function get_thumbnail( $image = '' ) 
    138     {       
     137    protected function get_thumbnail( $image = '' )
     138    {
    139139        if ( empty($image) )
    140140            return false;
    141        
     141
    142142        // get thumbnail image size
    143143        $image_size = $this->thumbnail_size; // w, h
    144        
     144
    145145        // incase the thumbnail dimension is set by name
    146146        if ( !is_array($image_size) ) {
     
    151151            }
    152152        }
    153        
     153
    154154        // fallback for image size incase the passed size name does not exists
    155155        if ( !isset($image_size[0]) || !isset($image_size[1]) ) {
    156156            $image_size = array(80, 80);
    157157        }
    158        
     158
    159159        // get correct image path
    160160        $image_path = str_replace( WP_CONTENT_URL, WP_CONTENT_DIR, $image);
    161        
    162         // resize image     
     161
     162        // resize image
    163163        if ( file_exists($image_path) && $this->is_image($image_path) ) {
    164164            $resized = image_resize( $image_path, $image_size[0], $image_size[1], true);
    165            
     165
    166166            // resize worked
    167167            if ( ! is_wp_error( $resized ) ) {
    168168                $image  = str_replace( WP_CONTENT_DIR, WP_CONTENT_URL, $resized);
    169                
     169
    170170                return "<img src='{$image}' alt='' width='{$image_size[0]}' height='{$image_size[1]}' />";
    171171            }
    172            
     172
    173173            // resizing failed so let's return full image with maxed dimensions
    174174            else {
    175                 return "<img src='{$image}' alt='' style='max-width:{$image_size[0]}px;max-height:{$image_size[1]}px' />";             
    176             }           
    177         }
    178        
     175                return "<img src='{$image}' alt='' style='max-width:{$image_size[0]}px;max-height:{$image_size[1]}px' />";
     176            }
     177        }
     178
    179179        return false;
    180180    }
    181    
     181
    182182    /**
    183183     * Checks an URL for image extension
     
    185185     * @since     1.2
    186186     */
    187     protected function is_image($url) 
     187    protected function is_image($url)
    188188    {
    189189        $validExt   = array('.jpg', '.jpeg', '.gif', '.png', '.bmp');
    190190        $ext        = strrchr($url, '.');
    191        
     191
    192192        return in_array($ext, $validExt);
    193     }   
    194    
     193    }
     194
    195195    /**
    196196     * Get a thumbnail
     
    198198     * @since     1.3.1
    199199     */
    200     protected function get_media_thumbnails($meta) 
     200    protected function get_media_thumbnails($meta)
    201201    {
    202202        $meta = $this->strip_trim( str_replace(' ','', $meta) );
    203        
     203
    204204        // split media ids
    205205        $media_ids = array($meta);
    206         if ( strpos($meta, ',') !== false )         
     206        if ( strpos($meta, ',') !== false )
    207207            $media_ids = explode(',', $meta);
    208        
     208
    209209        // check if media exists
    210210        $thumbs = '';
     
    212212            if ( is_numeric($media_id) )
    213213                $thumbs .= wp_get_attachment_url($media_id) ? "<span class='cpac-column-value-image'>".wp_get_attachment_image( $media_id, array(80,80), true )."</span>" : '';
    214        
    215         return $thumbs;     
    216     }   
    217    
     214
     215        return $thumbs;
     216    }
     217
    218218    /**
    219219     *  Convert file size to readable format
     
    226226        return $size ? round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . $filesizename[$i] : '0 Bytes';
    227227    }
    228    
     228
    229229    /**
    230230     *  Get column value of Custom Field
    231231     *
    232232     *  @since     1.0
    233      */ 
    234     protected function get_column_value_custom_field($object_id, $column_name, $meta_type = 'post') 
     233     */
     234    protected function get_column_value_custom_field($object_id, $column_name, $meta_type = 'post')
    235235    {
    236236        /** Users */
    237         if ( $meta_type == 'user' ) {
     237        if ( 'user' == $meta_type ) {
    238238            $type = 'wp-users';
    239239        }
    240        
     240
    241241        /** Media */
    242         if ( $meta_type == 'media' ) {
     242        elseif ( 'media' == $meta_type ) {
    243243            $type = 'wp-media';
    244244            $meta_type = 'post';
    245245        }
    246        
     246
    247247        /** Posts */
    248248        else {
    249249            $type   = get_post_type($object_id);
    250250        }
    251        
     251
    252252        // get column
    253253        $columns    = $this->get_stored_columns($type);
    254        
     254
    255255        // inputs
    256256        $field      = isset($columns[$column_name]['field'])      ? $columns[$column_name]['field']         : '';
     
    258258        $before     = isset($columns[$column_name]['before'])     ? $columns[$column_name]['before']        : '';
    259259        $after      = isset($columns[$column_name]['after'])      ? $columns[$column_name]['after']         : '';
    260        
     260
    261261        // rename hidden custom fields to their original name
    262262        $field = substr($field,0,10) == "cpachidden" ? str_replace('cpachidden','',$field) : $field;
    263        
     263
    264264        // Get meta field value
    265265        $meta       = get_metadata($meta_type, $object_id, $field, true);
    266266
    267267        // multiple meta values
    268         if ( ( $fieldtype == 'array' && is_array($meta) ) || is_array($meta) ) {           
     268        if ( ( $fieldtype == 'array' && is_array($meta) ) || is_array($meta) ) {
    269269            $meta   = get_metadata($meta_type, $object_id, $field, true);
    270270            $meta   = $this->recursive_implode(', ', $meta);
     
    272272
    273273        // make sure there are no serialized arrays or null data
    274         if ( !is_string($meta) )   
    275             return false;
    276        
     274        if ( !is_string($meta) )
     275            return false;
     276
    277277        // handles each field type differently..
    278         switch ($fieldtype) :           
    279        
     278        switch ($fieldtype) :
     279
    280280            // Image
    281281            case "image" :
    282282                $meta = $this->get_thumbnail($meta);
    283283                break;
    284                
     284
    285285            // Media Library ID
    286286            case "library_id" :
    287                 $meta = $this->get_media_thumbnails($meta);             
    288                 break;
    289            
     287                $meta = $this->get_media_thumbnails($meta);
     288                break;
     289
    290290            // Excerpt
    291291            case "excerpt" :
    292292                $meta = $this->get_shortened_string($meta, $this->excerpt_length);
    293293                break;
    294            
     294
    295295            // Date
    296296            case "date" :
    297297                $meta = $this->get_date($meta);
    298298                break;
    299            
     299
    300300            // Post Title
    301301            case "title_by_id" :
     
    304304                    $meta = $titles;
    305305                break;
    306            
     306
    307307            // User Name
    308308            case "user_by_id" :
    309309                $names = $this->get_custom_field_value_user($meta);
    310310                if ( $names )
    311                     $meta = $names;     
    312                 break;
    313                
     311                    $meta = $names;
     312                break;
     313
    314314            // Checkmark
    315315            case "checkmark" :
    316316                $checkmark = $this->get_asset_image('checkmark.png');
    317                
     317
    318318                if ( empty($meta) || 'false' === $meta || '0' === $meta ) {
    319319                    $checkmark = '';
    320320                }
    321                
    322                 $meta = $checkmark;             
    323                 break;
    324            
     321
     322                $meta = $checkmark;
     323                break;
     324
    325325            // Color
    326326            case "color" :
     
    329329                }
    330330                break;
    331            
    332         endswitch;     
     331
     332        endswitch;
    333333
    334334        // filter for customization
    335335        $meta = apply_filters('cpac_get_column_value_custom_field', $meta, $fieldtype, $field, $type, $object_id );
    336        
     336
    337337        // add before and after string
    338338        if ( $meta ) {
    339339            $meta = "{$before}{$meta}{$after}";
    340340        }
    341        
     341
    342342        return $meta;
    343343    }
    344    
     344
    345345    /**
    346346     *  Get custom field value 'Title by ID'
     
    348348     *  @since     1.3
    349349     */
    350     protected function get_custom_field_value_title($meta) 
     350    protected function get_custom_field_value_title($meta)
    351351    {
    352352        //remove white spaces and strip tags
    353353        $meta = $this->strip_trim( str_replace(' ','', $meta) );
    354        
     354
    355355        // var
    356356        $ids = $titles = array();
    357        
     357
    358358        // check for multiple id's
    359359        if ( strpos($meta, ',') !== false )
    360             $ids = explode(',',$meta);         
     360            $ids = explode(',',$meta);
    361361        elseif ( is_numeric($meta) )
    362             $ids[] = $meta;         
    363        
     362            $ids[] = $meta;
     363
    364364        // display title with link
    365365        if ( $ids && is_array($ids) ) {
    366             foreach ( $ids as $id ) {               
     366            foreach ( $ids as $id ) {
    367367                $title = is_numeric($id) ? get_the_title($id) : '';
    368368                $link  = get_edit_post_link($id);
     
    371371            }
    372372        }
    373        
     373
    374374        return implode('<span class="cpac-divider"></span>', $titles);
    375375    }
    376    
     376
    377377    /**
    378378     *  Get custom field value 'User by ID'
     
    380380     *  @since     1.4.6.3
    381381     */
    382     protected function get_custom_field_value_user($meta) 
     382    protected function get_custom_field_value_user($meta)
    383383    {
    384384        //remove white spaces and strip tags
    385385        $meta = $this->strip_trim( str_replace(' ','', $meta) );
    386        
     386
    387387        // var
    388388        $ids = $names = array();
    389        
     389
    390390        // check for multiple id's
    391391        if ( strpos($meta, ',') !== false )
    392392            $ids = explode(',',$meta);
    393393        elseif ( is_numeric($meta) )
    394             $ids[] = $meta;         
    395        
     394            $ids[] = $meta;
     395
    396396        // display username
    397397        if ( $ids && is_array($ids) ) {
     
    399399                if ( !is_numeric($id) )
    400400                    continue;
    401                
     401
    402402                $userdata = get_userdata($id);
    403403                if ( is_object($userdata) && !empty( $userdata->display_name ) ) {
    404404                    $names[] = $userdata->display_name;
    405                 }               
    406             }
    407         }
    408        
     405                }
     406            }
     407        }
     408
    409409        return implode('<span class="cpac-divider"></span>', $names);
    410410    }
    411    
     411
    412412    /**
    413413     *  Get column value of Custom Field
     
    415415     *  @since     1.2
    416416     */
    417     protected function get_user_column_value_custom_field($user_id, $id) 
    418     {       
     417    protected function get_user_column_value_custom_field($user_id, $id)
     418    {
    419419        $columns    = $this->get_stored_columns('wp-users');
    420        
     420
    421421        // inputs
    422422        $field      = isset($columns[$id]['field'])      ? $columns[$id]['field']       : '';
     
    424424        $before     = isset($columns[$id]['before'])     ? $columns[$id]['before']      : '';
    425425        $after      = isset($columns[$id]['after'])      ? $columns[$id]['after']       : '';
    426        
     426
    427427        // Get meta field value
    428428        $meta       = get_user_meta($user_id, $field, true);
    429        
     429
    430430        // multiple meta values
    431         if ( ( $fieldtype == 'array' && is_array($meta) ) || is_array($meta) ) {           
     431        if ( ( $fieldtype == 'array' && is_array($meta) ) || is_array($meta) ) {
    432432            $meta   = get_user_meta($user_id, $field);
    433433            $meta   = $this->recursive_implode(', ', $meta);
    434434        }
    435        
     435
    436436        // make sure there are no serialized arrays or empty meta data
    437         if ( empty($meta) || !is_string($meta) )   
    438             return false;
    439                    
     437        if ( empty($meta) || !is_string($meta) )
     438            return false;
     439
    440440        // handles each field type differently..
    441         switch ($fieldtype) :           
    442        
     441        switch ($fieldtype) :
     442
    443443            // Image
    444             case "image" :             
     444            case "image" :
    445445                $meta = $this->get_thumbnail($meta);
    446446                break;
    447                
     447
    448448            // Media Library ID
    449449            case "library_id" :
    450450                $meta = $this->get_media_thumbnails($meta);
    451451                break;
    452            
     452
    453453            // Excerpt
    454454            case "excerpt" :
    455455                $meta = $this->get_shortened_string($meta, $this->excerpt_length);
    456456                break;
    457                                
    458         endswitch;     
    459        
     457
     458        endswitch;
     459
    460460        // filter for customization
    461461        $meta = apply_filters('cpac_get_user_column_value_custom_field', $meta, $fieldtype, $field );
    462        
     462
    463463        // add before and after string
    464464        $meta = "{$before}{$meta}{$after}";
    465        
     465
    466466        return $meta;
    467467    }
     
    472472     *  @since     1.0
    473473     */
    474     protected function recursive_implode( $glue, $pieces ) 
     474    protected function recursive_implode( $glue, $pieces )
    475475    {
    476476        foreach( $pieces as $r_pieces ) {
     
    484484        if ( isset($retVal) && is_array($retVal) )
    485485            return implode( $glue, $retVal );
    486        
     486
    487487        return false;
    488488    }
    489    
     489
    490490    /**
    491491     * Strip tags and trim
     
    493493     * @since     1.3
    494494     */
    495     protected function strip_trim($string) 
     495    protected function strip_trim($string)
    496496    {
    497497        return Codepress_Admin_Columns::strip_trim($string);
    498498    }
    499    
     499
    500500    /**
    501501     * Get date
     
    503503     * @since     1.3.1
    504504     */
    505     protected function get_date($date)
     505    protected function get_date( $date )
     506    {
     507        if ( empty( $date ) || in_array( $date, array( '0000-00-00 00:00:00', '0000-00-00', '00:00:00' ) ) )
     508            return false;
     509
     510        return date_i18n( get_option('date_format'), strtotime($date) );
     511    }
     512
     513    /**
     514     * Get time
     515     *
     516     * @since     1.3.1
     517     */
     518    protected function get_time($date)
    506519    {
    507520        if ( ! $date )
    508521            return false;
    509            
    510         return date_i18n( get_option('date_format'), strtotime($date) );
    511     }
    512    
    513     /**
    514      * Get time
    515      *
    516      * @since     1.3.1
    517      */
    518     protected function get_time($date)
    519     {
    520         if ( ! $date )
    521             return false;
    522            
     522
    523523        if ( ! is_numeric($date) )
    524524            $date = strtotime($date);
    525        
     525
    526526        return date_i18n( get_option('time_format'), $date );
    527527    }
  • codepress-admin-columns/trunk/classes/values/comments.php

    r637026 r638877  
    88 */
    99class CPAC_Comments_Values extends CPAC_Values
    10 {   
     10{
    1111    /**
    1212     * Constructor
     
    1717    {
    1818        parent::__construct();
    19        
     19
    2020        add_action( 'manage_comments_custom_column', array( $this, 'manage_comments_column_value'), 10, 2 );
    2121    }
    22    
     22
    2323    /**
    2424     * Manage custom column for Comments
     
    2929    {
    3030        $type = $column_name;
    31        
     31
    3232        // comments object
    3333        $comment = get_comment($comment_id);
    34        
     34
    3535        // Check for custom fields, such as column-meta-[customfieldname]
    3636        if ( $this->is_column_meta($type) )
    3737            $type = 'column-comment-meta';
    38        
    39         // Hook 
     38
     39        // Hook
    4040        do_action('cpac-manage-comments-column', $type, $column_name, $comment_id);
    41        
     41
    4242        $result = '';
    43         switch ($type) :           
    44            
     43        switch ($type) :
     44
    4545            // comment id
    4646            case "column-comment_id" :
    4747                $result = $comment_id;
    4848                break;
    49            
     49
    5050            // author
    5151            case "column-author_author" :
    5252                $result = $comment->comment_author;
    5353                break;
    54                
     54
    5555            // avatar
    5656            case "column-author_avatar" :
    57                 $result = get_avatar( $comment, 80 );               
    58                 break;
    59                
     57                $result = get_avatar( $comment, 80 );
     58                break;
     59
    6060            // url
    61             case "column-author_url" :             
    62                 $result = $this->get_shorten_url($comment->comment_author_url);             
    63                 break;
    64                
     61            case "column-author_url" :
     62                $result = $this->get_shorten_url($comment->comment_author_url);
     63                break;
     64
    6565            // ip
    6666            case "column-author_ip" :
    6767                $result = $comment->comment_author_IP;
    6868                break;
    69                
     69
    7070            // email
    7171            case "column-author_email" :
    7272                $result = $comment->comment_author_email;
    7373                break;
    74                
     74
    7575            // parent
    7676            case "column-reply_to" :
    77                 if ( $comment->comment_approved ) {             
     77                if ( $comment->comment_approved ) {
    7878                    $parent         = get_comment( $comment->comment_parent );
    7979                    $parent_link    = esc_url( get_comment_link( $comment->comment_parent ) );
     
    8181                    $result         = sprintf( '<a href="%1$s">%2$s</a>', $parent_link, $name );
    8282                }
    83                 break; 
    84            
     83                break;
     84
    8585            // approved
    8686            case "column-approved" :
     
    8989                    $result = $this->get_asset_image('checkmark.png');
    9090                break;
    91            
     91
    9292            // date
    9393            case "column-date" :
    9494                $comment_url = esc_url( get_comment_link( $comment_id ) );
    95                 $result      = sprintf( __( 'Submitted on <a href="%1$s">%2$s at %3$s</a>' ), 
     95                $result      = sprintf( __( 'Submitted on <a href="%1$s">%2$s at %3$s</a>' ),
    9696                    $comment_url,
    9797                    $this->get_date($comment->comment_date),
     
    100100                $result      = "<div class='submitted-on'>{$result}</div>";
    101101                break;
    102            
     102
    103103            // date GMT
    104104            case "column-date_gmt" :
    105105                $comment_url = esc_url( get_comment_link( $comment_id ) );
    106                 $result      = sprintf( __( 'Submitted on <a href="%1$s">%2$s at %3$s</a>' ), 
     106                $result      = sprintf( __( 'Submitted on <a href="%1$s">%2$s at %3$s</a>' ),
    107107                    $comment_url,
    108108                    $this->get_date($comment->comment_date_gmt),
     
    111111                $result      = "<div class='submitted-on'>{$result}</div>";
    112112                break;
    113                
     113
    114114            // custom field
    115115            case "column-comment-meta" :
    116                 $result = $this->get_column_value_custom_field($comment_id, $column_name, 'comment');       
    117                 break;
    118                
     116                $result = $this->get_column_value_custom_field($comment_id, $column_name, 'comment');
     117                break;
     118
    119119            // agent
    120120            case "column-agent" :
    121                 $result = $comment->comment_agent;     
    122                 break; 
    123                
     121                $result = $comment->comment_agent;
     122                break;
     123
    124124            // excerpt
    125125            case "column-excerpt" :
    126126                $comment    = get_comment($comment_id);
    127127                $result     = $this->get_shortened_string($comment->comment_content, $this->excerpt_length);
    128                 break; 
    129            
     128                break;
     129
    130130            // actions
    131131            case "column-actions" :
    132132                $result = $this->get_column_value_actions($comment);
    133133                break;
    134            
     134
    135135            // word count
    136136            case "column-word-count" :
    137137                $result = str_word_count( $this->strip_trim( $comment->comment_content ) );
    138138                break;
    139            
     139
    140140            default :
    141141                $result = '';
    142            
     142
    143143        endswitch;
    144        
     144
    145145        // Filter for customizing the result output
    146146        apply_filters('cpac-comments-column-result', $result, $type, $column_name, $comment_id);
    147        
     147
    148148        echo $result;
    149149    }
    150    
     150
    151151    /**
    152152     *  Get column value of comments actions
     
    156156     *  @since     1.4.2
    157157     */
    158     private function get_column_value_actions( $comment ) 
    159     {   
     158    private function get_column_value_actions( $comment )
     159    {
    160160        global $post, $comment_status;
    161        
     161
    162162        // set uased vars
    163163        $user_can           = current_user_can( 'edit_comment', $comment->comment_ID );
    164164        $the_comment_status = wp_get_comment_status( $comment->comment_ID );
    165        
     165
    166166        if ( $user_can ) {
    167167            $del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
     
    178178            $delete_url = esc_url( $url . "&action=deletecomment&$del_nonce" );
    179179        }
    180        
     180
    181181        /** begin - copied from class-wp-comments-list-table */
    182182        if ( $user_can ) {
  • codepress-admin-columns/trunk/classes/values/link.php

    r564496 r638877  
    88 */
    99class CPAC_Link_Values extends CPAC_Values
    10 {   
     10{
    1111    /**
    1212     * Constructor
     
    1717    {
    1818        parent::__construct();
    19        
     19
    2020        add_action( 'manage_link_custom_column', array( $this, 'manage_link_column_value'), 10, 2 );
    2121    }
    22    
     22
    2323    /**
    2424     * Manage custom column for Links
     
    2929    {
    3030        $type = $column_name;
    31        
     31
    3232        // links object... called bookmark
    3333        $bookmark = get_bookmark($link_id);
    3434
    35         // Hook 
     35        // Hook
    3636        do_action('cpac-manage-link-column', $type, $column_name, $link_id);
    37        
     37
    3838        $result = '';
    39         switch ($type) :           
    40            
     39        switch ($type) :
     40
    4141            // link id
    4242            case "column-link_id" :
    4343                $result = $link_id;
    4444                break;
    45            
     45
    4646            // description
    4747            case "column-description" :
    4848                $result = $bookmark->link_description;
    4949                break;
    50            
     50
    5151            // target
    5252            case "column-target" :
    5353                $result = $bookmark->link_target;
    5454                break;
    55            
     55
    5656            // notes
    5757            case "column-notes" :
    5858                $result = $this->get_shortened_string($bookmark->link_notes, $this->excerpt_length);
    5959                break;
    60            
     60
    6161            // rss
    6262            case "column-rss" :
    6363                $result     = $this->get_shorten_url($bookmark->link_rss);
    6464                break;
    65                
     65
    6666            // image
    6767            case "column-image" :
    6868                $result = $this->get_thumbnail($bookmark->link_image);
    6969                break;
    70                
     70
    7171            // name length
    72             case "column-length" :             
     72            case "column-length" :
    7373                $result = strlen($bookmark->link_name);
    7474                break;
    75                
     75
    7676            // owner
    7777            case "column-owner" :
    7878                $result = $bookmark->link_owner;
    79                
     79
    8080                // add user link
    81                 $userdata = get_userdata( $bookmark->link_owner );             
     81                $userdata = get_userdata( $bookmark->link_owner );
    8282                if (!empty($userdata->data)) {
    8383                    $result = $userdata->data->user_nicename;
     
    8585                }
    8686                break;
    87            
     87
    8888            // link actions
    8989            case "column-actions" :
    9090                $result = $this->get_column_value_actions($bookmark);
    9191                break;
    92            
     92
    9393            default :
    9494                $result = '';
    95            
     95
    9696        endswitch;
    97        
     97
    9898        // Filter for customizing the result output
    9999        apply_filters('cpac-link-column-result', $result, $type, $column_name, $link_id);
    100        
     100
    101101        echo $result;
    102102    }
    103    
     103
    104104    /**
    105105     *  Get column value of link actions
     
    109109     *  @since     1.4.2
    110110     */
    111     private function get_column_value_actions( $link ) 
     111    private function get_column_value_actions( $link )
    112112    {
    113113        $actions = array();
    114        
     114
    115115        $edit_link = get_edit_bookmark_link( $link );
    116        
     116
    117117        $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
    118118        $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( "link.php?action=delete&amp;link_id=$link->link_id", 'delete-bookmark_' . $link->link_id ) . "' onclick=\"if ( confirm( '" . esc_js( sprintf( __( "You are about to delete this link '%s'\n  'Cancel' to stop, 'OK' to delete." ), $link->link_name ) ) . "' ) ) { return true;}return false;\">" . __( 'Delete' ) . "</a>";
    119        
     119
    120120        return implode(' | ', $actions);
    121121    }
  • codepress-admin-columns/trunk/classes/values/media.php

    r637026 r638877  
    88 */
    99class CPAC_Media_Values extends CPAC_Values
    10 {   
     10{
    1111    /**
    1212     * Constructor
     
    1717    {
    1818        parent::__construct();
    19        
    20         add_action( 'manage_media_custom_column', array( $this, 'manage_media_column_value'), 10, 2 );     
     19
     20        add_action( 'manage_media_custom_column', array( $this, 'manage_media_column_value'), 10, 2 );
    2121    }
    22    
     22
    2323    /**
    2424     * Manage custom column for Media.
     
    2929    {
    3030        $type   = $column_name;
    31        
     31
    3232        //$meta     = wp_get_attachment_metadata($media_id);
    3333        $meta   = get_post_meta( $media_id, '_wp_attachment_metadata', true );
    3434        $p      = get_post($media_id);
    35        
     35
    3636        // Check for custom fields, such as column-meta-[customfieldname]
    3737        if ( $this->is_column_meta($type) )
    3838            $type = 'column-meta';
    39        
    40         // Hook 
     39
     40        // Hook
    4141        do_action('cpac-manage-media-column', $type, $column_name, $media_id);
    42        
     42
    4343        $result = '';
    44         switch ($type) :           
    45            
     44        switch ($type) :
     45
    4646            // media id
    4747            case "column-mediaid" :
    4848                $result = $media_id;
    49                 break;         
    50            
     49                break;
     50
    5151            // dimensions
    5252            case "column-dimensions" :
     
    5454                    $result = "{$meta['width']} x {$meta['height']}";
    5555                break;
    56            
     56
    5757            // width
    5858            case "column-width" :
    5959                $result = !empty($meta['width']) ? $meta['width'] : '';
    6060                break;
    61            
     61
    6262            // height
    6363            case "column-height" :
    6464                $result = !empty($meta['height']) ? $meta['height'] : '';
    6565                break;
    66            
     66
    6767            // description
    6868            case "column-description" :
    6969                $result = $p->post_content;
    7070                break;
    71                
     71
    7272            // caption
    7373            case "column-caption" :
    7474                $result = $p->post_excerpt;
    7575                break;
    76                
     76
    7777            // alternate text
    7878            case "column-alternate_text" :
     
    8080                $result = $this->strip_trim($alt);
    8181                break;
    82                
     82
    8383            // mime type
    84             case "column-mime_type" :               
     84            case "column-mime_type" :
    8585                $result = $p->post_mime_type;
    8686                break;
    87            
     87
    8888            // file name
    8989            case "column-file_name" :
     
    9292                $result     = "<a title='{$filename}' href='{$file}'>{$filename}</a>";
    9393                break;
    94                
     94
    9595            // file paths
    9696            case "column-file_paths" :
    9797                $sizes      = get_intermediate_image_sizes();
    9898                $url        = wp_get_attachment_url($p->ID);
    99                 $filename   = basename($url);               
     99                $filename   = basename($url);
    100100                $paths[]    = "<a title='{$filename}' href='{$url}'>" . __('original', CPAC_TEXTDOMAIN) . "</a>";
    101101                if ( $sizes ) {
    102102                    foreach ( $sizes as $size ) {
    103                         $src    = wp_get_attachment_image_src( $media_id, $size );                     
     103                        $src    = wp_get_attachment_image_src( $media_id, $size );
    104104                        if (!empty($src[0])) {
    105105                            $filename = basename($src[0]);
     
    107107                        }
    108108                    }
    109                 }               
     109                }
    110110                $result = implode('<span class="cpac-divider"></span>', $paths);
    111111                break;
    112            
     112
    113113            case "column-actions" :
    114114                $result = $this->get_column_value_actions($media_id);
    115115                break;
    116                
     116
    117117            case "column-filesize" :
    118118                $file   = wp_get_attachment_url($p->ID);
     
    122122                }
    123123                break;
    124            
     124
    125125            // Custom Field
    126126            case "column-meta" :
    127                 $result = $this->get_column_value_custom_field($media_id, $column_name, 'media');       
    128                 break;
    129            
    130             // Image metadata EXIF or IPTC data         
     127                $result = $this->get_column_value_custom_field($media_id, $column_name, 'media');
     128                break;
     129
     130            // Image metadata EXIF or IPTC data
    131131            case "column-image-aperture" :
    132                 $result = !empty( $meta['image_meta']['aperture'] ) ? $meta['image_meta']['aperture'] : '';             
    133                 break;
    134                
     132                $result = !empty( $meta['image_meta']['aperture'] ) ? $meta['image_meta']['aperture'] : '';
     133                break;
     134
    135135            case "column-image-credit" :
    136                 $result = !empty( $meta['image_meta']['credit'] ) ? $meta['image_meta']['credit'] : '';             
    137                 break;
    138                
     136                $result = !empty( $meta['image_meta']['credit'] ) ? $meta['image_meta']['credit'] : '';
     137                break;
     138
    139139            case "column-image-camera" :
    140                 $result = !empty( $meta['image_meta']['camera'] ) ? $meta['image_meta']['camera'] : '';             
    141                 break;
    142            
     140                $result = !empty( $meta['image_meta']['camera'] ) ? $meta['image_meta']['camera'] : '';
     141                break;
     142
    143143            case "column-image-caption" :
    144                 $result = !empty( $meta['image_meta']['caption'] ) ? $meta['image_meta']['caption'] : '';               
    145                 break;
    146            
     144                $result = !empty( $meta['image_meta']['caption'] ) ? $meta['image_meta']['caption'] : '';
     145                break;
     146
    147147            case "column-image-created_timestamp" :
    148148                if ( !empty( $meta['image_meta']['created_timestamp'] ) ) {
    149149                    $result = date_i18n( get_option('date_format') . ' ' . get_option('time_format') , strtotime($meta['image_meta']['created_timestamp']) );
    150                 }       
    151                 break;
    152                
     150                }
     151                break;
     152
    153153            case "column-image-copyright" :
    154                 $result = !empty( $meta['image_meta']['copyright'] ) ? $meta['image_meta']['copyright'] : '';               
    155                 break;
    156                
     154                $result = !empty( $meta['image_meta']['copyright'] ) ? $meta['image_meta']['copyright'] : '';
     155                break;
     156
    157157            case "column-image-focal_length" :
    158                 $result = !empty( $meta['image_meta']['focal_length'] ) ? $meta['image_meta']['focal_length'] : '';             
    159                 break;
    160            
     158                $result = !empty( $meta['image_meta']['focal_length'] ) ? $meta['image_meta']['focal_length'] : '';
     159                break;
     160
    161161            case "column-image-iso" :
    162                 $result = !empty( $meta['image_meta']['iso'] ) ? $meta['image_meta']['iso'] : '';               
    163                 break;
    164            
     162                $result = !empty( $meta['image_meta']['iso'] ) ? $meta['image_meta']['iso'] : '';
     163                break;
     164
    165165            case "column-image-shutter_speed" :
    166                 $result = !empty( $meta['image_meta']['shutter_speed'] ) ? $meta['image_meta']['shutter_speed'] : '';               
    167                 break;
    168            
     166                $result = !empty( $meta['image_meta']['shutter_speed'] ) ? $meta['image_meta']['shutter_speed'] : '';
     167                break;
     168
    169169            case "column-image-title" :
    170                 $result = !empty( $meta['image_meta']['title'] ) ? $meta['image_meta']['title'] : '';               
    171                 break;
    172                
     170                $result = !empty( $meta['image_meta']['title'] ) ? $meta['image_meta']['title'] : '';
     171                break;
     172
    173173            default :
    174174                $result = '';
    175            
     175
    176176        endswitch;
    177        
     177
    178178        // Filter for customizing the result output
    179179        apply_filters('cpac-media-column-result', $result, $type, $column_name, $media_id);
    180        
     180
    181181        echo $result;
    182182    }
    183    
     183
    184184    /**
    185185     *  Get column value of media actions
     
    189189     *  @since     1.4.2
    190190     */
    191     private function get_column_value_actions( $id ) 
    192     {   
     191    private function get_column_value_actions( $id )
     192    {
    193193        if ( file_exists(ABSPATH . 'wp-admin/includes/class-wp-list-table.php') )
    194194            require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
    195195        if ( file_exists(ABSPATH . 'wp-admin/includes/class-wp-media-list-table.php') )
    196196            require_once(ABSPATH . 'wp-admin/includes/class-wp-media-list-table.php');
    197        
     197
    198198        // we need class to get the object actions
    199199        $m = new WP_Media_List_Table;
    200        
     200
    201201        // prevent php notice
    202202        $m->is_trash = isset( $_REQUEST['status'] ) && 'trash' == $_REQUEST['status'];
    203        
     203
    204204        // get media actions
    205205        $media      = get_post($id);
    206206        $actions    = $m->_get_row_actions( $media, _draft_or_post_title($id) );
    207        
     207
    208208        return implode(' | ', $actions);
    209209    }
  • codepress-admin-columns/trunk/classes/values/posts.php

    r637026 r638877  
    88 */
    99class CPAC_Posts_Values extends CPAC_Values
    10 {   
     10{
    1111    /**
    1212     * Constructor
     
    1515     */
    1616    function __construct()
    17     {       
     17    {
    1818        parent::__construct();
    19        
    20         add_action( 'manage_pages_custom_column', array( $this, 'manage_posts_column_value'), 10, 2 ); 
     19
     20        add_action( 'manage_pages_custom_column', array( $this, 'manage_posts_column_value'), 10, 2 );
    2121        add_action( 'manage_posts_custom_column', array( $this, 'manage_posts_column_value'), 10, 2 );
    2222    }
    23    
     23
    2424    /**
    2525     * Manage custom column for Post Types.
     
    2727     * @since     1.0
    2828     */
    29     public function manage_posts_column_value($column_name, $post_id) 
     29    public function manage_posts_column_value($column_name, $post_id)
    3030    {
    3131        $type = $column_name;
    3232
    33         // Check for taxonomies, such as column-taxonomy-[taxname] 
     33        // Check for taxonomies, such as column-taxonomy-[taxname]
    3434        if ( strpos($type, 'column-taxonomy-') !== false )
    3535            $type = 'column-taxonomy';
    36        
     36
    3737        // Check for custom fields, such as column-meta-[customfieldname]
    3838        if ( $this->is_column_meta($type) )
    3939            $type = 'column-post-meta';
    40        
    41         // Hook 
     40
     41        // Hook
    4242        do_action('cpac-manage-posts-column', $type, $column_name, $post_id);
    43    
     43
    4444        // Switch Types
    4545        $result = '';
    46         switch ($type) :           
    47            
     46        switch ($type) :
     47
    4848            // Post ID
    4949            case "column-postid" :
    5050                $result = $post_id;
    5151                break;
    52            
     52
    5353            // Excerpt
    5454            case "column-excerpt" :
    5555                $result = $this->get_post_excerpt($post_id);
    5656                break;
    57            
     57
    5858            // Featured Image
    5959            case "column-featured_image" :
     
    6161                    $result = get_the_post_thumbnail($post_id, $this->thumbnail_size);
    6262                break;
    63                
     63
    6464            // Sticky Post
    6565            case "column-sticky" :
    66                 if ( is_sticky($post_id) )                 
     66                if ( is_sticky($post_id) )
    6767                    $result = $this->get_asset_image('checkmark.png');
    6868                break;
    69            
     69
    7070            // Order
    7171            case "column-order" :
    72                 $result = get_post_field('menu_order', $post_id);           
    73                 break;
    74                
     72                $result = get_post_field('menu_order', $post_id);
     73                break;
     74
    7575            // Post Formats
    7676            case "column-post_formats" :
    77                 $result = get_post_format($post_id);           
    78                 break;
    79            
     77                $result = get_post_format($post_id);
     78                break;
     79
    8080            // Page template
    8181            case "column-page-template" :
    8282                // file name
    83                 $page_template  = get_post_meta($post_id, '_wp_page_template', true);           
     83                $page_template  = get_post_meta($post_id, '_wp_page_template', true);
    8484
    8585                // get template nice name
    86                 $result = array_search($page_template, get_page_templates());           
    87                 break;
    88            
     86                $result = array_search($page_template, get_page_templates());
     87                break;
     88
    8989            // Slug
    9090            case "column-page-slug" :
    9191                $result = get_post($post_id)->post_name;
    9292                break;
    93            
     93
    9494            // Slug
    9595            case "column-word-count" :
    9696                $result = str_word_count( $this->strip_trim( get_post($post_id)->post_content ) );
    9797                break;
    98            
     98
    9999            // Taxonomy
    100100            case "column-taxonomy" :
     
    102102                $tags   = get_the_terms($post_id, $tax);
    103103                $tarr   = array();
    104                
     104
    105105                // for post formats we will display standard instead of empty
    106106                if ( $tax == 'post_format' && empty($tags) ) {
    107107                    $result = __('Standard');
    108108                }
    109                
     109
    110110                // add name with link
    111                 elseif ( !empty($tags) ) { 
     111                elseif ( !empty($tags) ) {
    112112                    $post_type = get_post_type($post_id);
    113113                    foreach($tags as $tag) {
     
    119119                    }
    120120                    $result = implode(', ', $tarr);
    121                 }           
    122                 break;
    123            
     121                }
     122                break;
     123
    124124            // Custom Field
    125125            case "column-post-meta" :
    126                 $result = $this->get_column_value_custom_field($post_id, $column_name, 'post');     
    127                 break;
    128            
     126                $result = $this->get_column_value_custom_field($post_id, $column_name, 'post');
     127                break;
     128
    129129            // Attachment
    130130            case "column-attachment" :
    131131                $result = $this->get_column_value_attachments($post_id);
    132132                break;
    133                
     133
    134134            // Attachment count
    135135            case "column-attachment-count" :
    136136                $result = count($this->get_attachment_ids($post_id));
    137137                break;
    138                
     138
    139139            // Roles
    140140            case "column-roles" :
     
    144144                    $result = implode(', ',$userdata->roles);
    145145                break;
    146            
     146
    147147            // Post status
    148148            case "column-status" :
     
    152152                    $result = $result . " <p class='description'>" . date_i18n( get_option('date_format') . ' ' . get_option('time_format') , strtotime($p->post_date) ) . "</p>";
    153153                break;
    154                
     154
    155155            // Post comment status
    156156            case "column-comment-status" :
     
    160160                    $result = $this->get_asset_image('checkmark.png', $p->comment_status);
    161161                break;
    162                
     162
    163163            // Post ping status
    164164            case "column-ping-status" :
     
    168168                    $result = $this->get_asset_image('checkmark.png', $p->ping_status);
    169169                break;
    170            
     170
    171171            // Post actions ( delete, edit etc. )
    172172            case "column-actions" :
    173173                $result = $this->get_column_value_actions($post_id);
    174174                break;
    175            
     175
    176176            // Post Last modified
    177177            case "column-modified" :
     
    179179                $result = $this->get_date($p->post_modified) . ' ' . $this->get_time($p->post_modified);
    180180                break;
    181                
     181
    182182            // Post Comment count
    183183            case "column-comment-count" :
    184                 $result = WP_List_Table::comments_bubble( $post_id, get_pending_comments_num( $post_id ) );                 
    185                 $result .= $this->get_comment_count_details( $post_id );               
    186                 break;         
    187            
     184                $result = WP_List_Table::comments_bubble( $post_id, get_pending_comments_num( $post_id ) );
     185                $result .= $this->get_comment_count_details( $post_id );
     186                break;
     187
    188188            // Author Name
    189189            case "column-author-name" :
    190                 $result = $this->get_column_value_authorname($post_id, $column_name);                   
    191                 break;
    192            
     190                $result = $this->get_column_value_authorname($post_id, $column_name);
     191                break;
     192
    193193            // Before More Tag
    194194            case "column-before-moretag" :
    195195                $p          = get_post($post_id);
    196196                $extended   = get_extended($p->post_content);
    197                
     197
    198198                if ( !empty($extended['extended']) ) {
    199199                    $result = $this->get_shortened_string($extended['main'], $this->excerpt_length );
    200200                }
    201201                break;
    202            
     202
    203203            default :
    204204                $result = '';
    205                        
     205
    206206        endswitch;
    207        
     207
    208208        // Filter for customizing the result output
    209209        apply_filters('cpac-posts-column-result', $result, $type, $column_name, $post_id);
    210        
    211         echo $result;   
    212     }
    213    
     210
     211        echo $result;
     212    }
     213
    214214    /**
    215215     * Returns the friendly name for a given status
     
    217217     * @since     1.4.4
    218218     */
    219     private function get_post_status_friendly_name( $status ) 
     219    private function get_post_status_friendly_name( $status )
    220220    {
    221221        $builtin = array(
     
    227227            'trash'     => __( 'Trash', CPAC_TEXTDOMAIN )
    228228        );
    229        
     229
    230230        if ( isset($builtin[$status]) )
    231231            $status = $builtin[$status];
    232        
    233         return $status;         
    234     }
    235    
     232
     233        return $status;
     234    }
     235
    236236    /**
    237237     * Comment count extended
     
    260260            $details .= "<a href='{$url}' class='cp-trash' title='".__('trash', CPAC_TEXTDOMAIN) . "'>{$c->trash}</a>";
    261261        }
    262        
    263         if ( $details ) 
     262
     263        if ( $details )
    264264            return "<p class='description row-actions'>{$details}</p>";
    265        
     265
    266266        return false;
    267267    }
    268    
     268
    269269    /**
    270270     *  Get column value of post actions
     
    274274     *  @since     1.4.2
    275275     */
    276     protected function get_column_value_actions( $post_id ) 
    277     {   
     276    protected function get_column_value_actions( $post_id )
     277    {
    278278        $actions = array();
    279        
     279
    280280        $post               = get_post($post_id);
    281281        $title              = _draft_or_post_title();
    282282        $post_type_object   = get_post_type_object( $post->post_type );
    283283        $can_edit_post      = current_user_can( $post_type_object->cap->edit_post, $post->ID );
    284        
     284
    285285        if ( $can_edit_post && 'trash' != $post->post_status ) {
    286286            $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '" title="' . esc_attr( __( 'Edit this item' ) ) . '">' . __( 'Edit' ) . '</a>';
     
    302302                $actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
    303303            }
    304         }   
    305        
     304        }
     305
    306306        return implode(' | ', $actions);
    307307    }
    308    
     308
    309309    /**
    310310     *  Get column value of Custom Field
    311311     *
    312312     *  @since     1.4.6.1
    313      */ 
    314     protected function get_column_value_authorname($post_id, $column_name) 
    315     {       
     313     */
     314    protected function get_column_value_authorname($post_id, $column_name)
     315    {
    316316        $type = get_post_type($post_id);
    317        
     317
    318318        // get column
    319319        $columns    = $this->get_stored_columns($type);
    320        
     320
    321321        // get the type of author name
    322322        $display_as = isset($columns[$column_name]['display_as']) ? $columns[$column_name]['display_as'] : '';
    323        
     323
    324324        // get the author
    325325        $post = get_post($post_id);
    326326        if ( !isset( $post->post_author) )
    327327            return false;
    328        
     328
    329329        $name = Codepress_Admin_Columns::get_author_field_by_nametype($display_as, $post->post_author);
    330        
     330
    331331        // filter for customization
    332332        $name = apply_filters('cpac_get_column_value_authorname', $name, $column_name, $post_id );
    333        
     333
    334334        // add link filter
    335335        $class  = isset( $_GET['author'] ) && $_GET['author'] == $userdata->ID ? ' class="current"' : '';
    336        
     336
    337337        $name = "<a href='edit.php?post_type={$type}&author={$post->post_author}'{$class}>{$name}</a>";
    338        
     338
    339339        return $name;
    340340    }
  • codepress-admin-columns/trunk/classes/values/users.php

    r637026 r638877  
    88 */
    99class CPAC_Users_Values extends CPAC_Values
    10 {   
     10{
    1111    /**
    1212     * Constructor
     
    1717    {
    1818        parent::__construct();
    19        
     19
    2020        add_filter( 'manage_users_custom_column', array( $this, 'manage_users_column_value'), 10, 3 );
    2121    }
    22    
     22
    2323    /**
    2424     * Manage custom column for Users.
     
    2929    {
    3030        $type = $column_name;
    31        
     31
    3232        $userdata = get_userdata( $user_id );
    3333
    3434        if ( ! $userdata )
    3535            return false;
    36        
     36
    3737        // Check for user custom fields: column-meta-[customfieldname]
    3838        if ( $this->is_column_meta($type) )
    3939            $type = 'column-user-meta';
    40            
     40
    4141        // Check for post count: column-user_postcount-[posttype]
    4242        if ( Codepress_Admin_Columns::get_posttype_by_postcount_column($type) )
    4343            $type = 'column-user_postcount';
    44        
    45         // Hook 
     44
     45        // Hook
    4646        do_action('cpac-manage-users-column', $type, $column_name, $user_id);
    47        
     47
    4848        $result = '';
    49         switch ($type) :           
    50            
     49        switch ($type) :
     50
    5151            // user id
    5252            case "column-user_id" :
    5353                $result = $user_id;
    5454                break;
    55            
     55
    5656            // first name
    5757            case "column-nickname" :
    5858                $result = $userdata->nickname;
    5959                break;
    60            
     60
    6161            // first name
    6262            case "column-first_name" :
    6363                $result = $userdata->first_name;
    6464                break;
    65                
     65
    6666            // last name
    6767            case "column-last_name" :
    6868                $result = $userdata->last_name;
    6969                break;
    70            
     70
    7171            // user url
    7272            case "column-user_url" :
    7373                $result = $userdata->user_url;
    7474                break;
    75                
     75
    7676            // user registration date
    7777            case "column-user_registered" :
    7878                $result = $userdata->user_registered;
    7979                break;
    80                
     80
    8181            // user description
    8282            case "column-user_description" :
    8383                $result = $this->get_shortened_string( get_the_author_meta('user_description', $user_id), $this->excerpt_length );
    8484                break;
    85                
     85
    8686            // user description
    8787            case "column-user_postcount" :
    8888                $post_type  = Codepress_Admin_Columns::get_posttype_by_postcount_column($column_name);
    89                
     89
    9090                // get post count
    9191                $count      = Codepress_Admin_Columns::get_post_count( $post_type, $user_id );
    92                
     92
    9393                // set result
    9494                $result     = $count > 0 ? "<a href='edit.php?post_type={$post_type}&author={$user_id}'>{$count}</a>" : (string) $count;
    95                 break; 
    96            
     95                break;
     96
    9797            // user actions
    9898            case "column-actions" :
    9999                $result = $this->get_column_value_actions($user_id, 'users');
    100100                break;
    101            
     101
    102102            // user meta data ( custom field )
    103103            case "column-user-meta" :
    104104                $result = $this->get_column_value_custom_field($user_id, $column_name, 'user');
    105105                break;
    106            
     106
    107107            default :
    108108                $result = $value;
    109                
     109
    110110        endswitch;
    111        
     111
    112112        // Filter for customizing the result output
    113113        apply_filters('cpac-users-column-result', $result, $type, $column_name, $user_id);
    114        
     114
    115115        return $result;
    116116    }
    117    
     117
    118118    /**
    119119     *  Get column value of user actions
     
    123123     *  @since     1.4.2
    124124     */
    125     private function get_column_value_actions( $id ) 
    126     {   
     125    private function get_column_value_actions( $id )
     126    {
    127127        $actions = array();
    128                
     128
    129129        $user_object = new WP_User( $id );
    130130        $screen      = get_current_screen();
    131        
     131
    132132        if ( 'site-users-network' == $screen->id )
    133133            $url = "site-users.php?id={$this->site_id}&amp;";
    134134        else
    135135            $url = 'users.php?';
    136        
     136
    137137        if ( get_current_user_id() == $user_object->ID ) {
    138138            $edit_link = 'profile.php';
     
    140140            $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), "user-edit.php?user_id=$user_object->ID" ) );
    141141        }
    142        
     142
    143143        if ( current_user_can( 'edit_user',  $user_object->ID ) ) {
    144144            $edit = "<strong><a href=\"$edit_link\">$user_object->user_login</a></strong><br />";
     
    152152        if ( is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'remove_user', $user_object->ID ) )
    153153            $actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url( $url."action=remove&amp;user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Remove' ) . "</a>";
    154            
     154
    155155        return implode(' | ', $actions);
    156156    }
  • codepress-admin-columns/trunk/codepress-admin-columns.php

    r637684 r638877  
    33
    44Plugin Name:        Codepress Admin Columns
    5 Version:            1.4.8
     5Version:            1.4.9
    66Description:        Customise columns on the administration screens for post(types), pages, media, comments, links and users with an easy to use drag-and-drop interface.
    77Author:             Codepress
     
    2828*/
    2929
    30 define( 'CPAC_VERSION',     '1.4.8' );
     30define( 'CPAC_VERSION',     '1.4.9' );
    3131define( 'CPAC_TEXTDOMAIN',  'codepress-admin-columns' );
    3232define( 'CPAC_SLUG',        'codepress-admin-columns' );
     
    4242 * @since     1.3
    4343 */
    44 require_once dirname( __FILE__ ) . '/classes/utility.php';
    4544require_once dirname( __FILE__ ) . '/classes/sortable.php';
    46 require_once dirname( __FILE__ ) . '/classes/values.php';       
     45require_once dirname( __FILE__ ) . '/classes/values.php';
    4746require_once dirname( __FILE__ ) . '/classes/values/posts.php';
    4847require_once dirname( __FILE__ ) . '/classes/values/users.php';
     
    5150require_once dirname( __FILE__ ) . '/classes/values/comments.php';
    5251require_once dirname( __FILE__ ) . '/classes/license.php';
     52require_once dirname( __FILE__ ) . '/classes/third_party.php';
    5353
    5454/**
     
    5858 *
    5959 */
    60 class Codepress_Admin_Columns 
    61 {   
     60class Codepress_Admin_Columns
     61{
    6262    private $post_types,
    6363            $codepress_url,
     
    6565            $admin_page,
    6666            $use_hidden_custom_fields;
    67    
     67
    6868    /**
    6969     * Constructor
     
    7272     */
    7373    function __construct()
    74     {       
     74    {
    7575        // wp is loaded
    7676        add_action( 'wp_loaded', array( $this, 'init') );
    7777    }
    78    
     78
    7979    /**
    8080     * Initialize plugin.
     
    9191        // set
    9292        $this->codepress_url    = 'http://www.codepress.nl/plugins/codepress-admin-columns';
    93         $this->plugins_url      = 'http://wordpress.org/extend/plugins/codepress-admin-columns/';           
    94         $this->wordpress_url    = 'http://wordpress.org/tags/codepress-admin-columns';             
    95        
     93        $this->plugins_url      = 'http://wordpress.org/extend/plugins/codepress-admin-columns/';
     94        $this->wordpress_url    = 'http://wordpress.org/tags/codepress-admin-columns';
     95
    9696        // enable the use of custom hidden fields
    9797        $this->use_hidden_custom_fields = apply_filters('cpac_use_hidden_custom_fields', false);
    98        
     98
    9999        // translations
    100100        load_plugin_textdomain( CPAC_TEXTDOMAIN, false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
    101        
     101
    102102        // register settings
    103         add_action( 'admin_menu', array( $this, 'settings_menu') );     
     103        add_action( 'admin_menu', array( $this, 'settings_menu') );
    104104        add_action( 'admin_init', array( $this, 'register_settings') );
    105105
     
    108108        add_filter( 'admin_body_class', array( $this, 'admin_class' ) );
    109109        add_action( 'admin_head', array( $this, 'admin_css') );
    110        
     110
    111111        // register columns
    112112        add_action( 'admin_init', array( $this, 'register_columns_headings' ) );
    113         add_action( 'admin_init', array( $this, 'register_columns_values' ) ); 
    114        
     113        add_action( 'admin_init', array( $this, 'register_columns_values' ) );
     114
    115115        // action ajax
    116116        add_action( 'wp_ajax_cpac_addon_activation', array( $this, 'ajax_activation'));
    117        
     117
    118118        // handle requests gets a low priority so it will trigger when all other plugins have loaded their columns
    119         add_action( 'admin_init', array( $this, 'handle_requests' ), 1000 );       
    120        
     119        add_action( 'admin_init', array( $this, 'handle_requests' ), 1000 );
     120
    121121        // filters
    122         add_filter( 'plugin_action_links',  array( $this, 'add_settings_link'), 1, 2);     
    123     }   
     122        add_filter( 'plugin_action_links',  array( $this, 'add_settings_link'), 1, 2);
     123    }
    124124
    125125    /**
     
    130130     * @since     1.0
    131131     */
    132     public function settings_menu() 
     132    public function settings_menu()
    133133    {
    134134        $page = add_options_page(
    135135            // Page title
    136             esc_html__( 'Admin Columns Settings', CPAC_TEXTDOMAIN ), 
     136            esc_html__( 'Admin Columns Settings', CPAC_TEXTDOMAIN ),
    137137            // Menu Title
    138             esc_html__( 'Admin Columns', CPAC_TEXTDOMAIN ), 
     138            esc_html__( 'Admin Columns', CPAC_TEXTDOMAIN ),
    139139            // Capability
    140140            'manage_options',
     
    143143            // Callback
    144144            array( $this, 'plugin_settings_page')
    145         );     
     145        );
    146146
    147147        // set admin page
    148148        $this->admin_page = $page;
    149        
     149
    150150        // settings page specific styles and scripts
    151151        add_action( "admin_print_styles-$page", array( $this, 'admin_styles') );
    152152        add_action( "admin_print_scripts-$page", array( $this, 'admin_scripts') );
    153        
     153
    154154        // add help tabs
    155155        add_action("load-$page", array( $this, 'help_tabs'));
    156156    }
    157    
     157
    158158    /**
    159159     * Add Settings link to plugin page
     
    164164     * @return  string - link to settings page
    165165     */
    166     function add_settings_link( $links, $file ) 
     166    function add_settings_link( $links, $file )
    167167    {
    168168        if ( $file != plugin_basename( __FILE__ ))
     
    171171        array_unshift($links, '<a href="' . admin_url("admin.php") . '?page=' . CPAC_SLUG . '">' . __( 'Settings' ) . '</a>');
    172172        return $links;
    173     }   
    174        
    175     /**
    176      *  Register Column Values 
     173    }
     174
     175    /**
     176     *  Register Column Values
    177177     *
    178178     *  initializes each Class per type
     
    196196     */
    197197    public function register_columns_headings()
    198     {   
    199         /** Posts */       
     198    {
     199        /** Posts */
    200200        foreach ( $this->post_types as $post_type ) {
    201201
    202202            // register column per post type
    203203            add_filter("manage_edit-{$post_type}_columns", array($this, 'callback_add_posts_column_headings'));
    204         } 
    205        
     204        }
     205
    206206        /** Users */
    207         add_filter( "manage_users_columns", array($this, 'callback_add_users_column_headings'), 9); 
     207        add_filter( "manage_users_columns", array($this, 'callback_add_users_column_headings'), 9);
    208208        // give higher priority, so it will load just before other plugins to prevent conflicts
    209        
     209
    210210        /** Media */
    211211        add_filter( "manage_upload_columns", array($this, 'callback_add_media_column_headings'));
    212        
     212
    213213        /** Links */
    214214        add_filter( "manage_link-manager_columns", array($this, 'callback_add_links_column_headings'));
    215        
     215
    216216        /** Comments */
    217217        add_filter( "manage_edit-comments_columns", array($this, 'callback_add_comments_column_headings'));
    218218    }
    219    
     219
    220220    /**
    221221     *  Callback add Posts Column
     
    223223     *  @since     1.0
    224224     */
    225     public function callback_add_posts_column_headings($columns) 
    226     {
    227         return $this->add_columns_headings( get_post_type(), $columns);     
    228     }
    229    
     225    public function callback_add_posts_column_headings($columns)
     226    {
     227        return $this->add_columns_headings( get_post_type(), $columns);
     228    }
     229
    230230    /**
    231231     *  Callback add Users column
     
    233233     *  @since     1.1
    234234     */
    235     public function callback_add_users_column_headings($columns) 
     235    public function callback_add_users_column_headings($columns)
    236236    {
    237237        return $this->add_columns_headings('wp-users', $columns);
    238238    }
    239    
     239
    240240    /**
    241241     *  Callback add Media column
     
    243243     *  @since     1.3
    244244     */
    245     public function callback_add_media_column_headings($columns) 
     245    public function callback_add_media_column_headings($columns)
    246246    {
    247247        return $this->add_columns_headings('wp-media', $columns);
    248248    }
    249    
     249
    250250    /**
    251251     *  Callback add Links column
     
    253253     *  @since     1.3.1
    254254     */
    255     public function callback_add_links_column_headings($columns) 
     255    public function callback_add_links_column_headings($columns)
    256256    {
    257257        return $this->add_columns_headings('wp-links', $columns);
    258258    }
    259    
     259
    260260    /**
    261261     *  Callback add Comments column
     
    263263     *  @since     1.3.1
    264264     */
    265     public function callback_add_comments_column_headings($columns) 
     265    public function callback_add_comments_column_headings($columns)
    266266    {
    267267        return $this->add_columns_headings('wp-comments', $columns);
    268268    }
    269    
    270    
    271    
     269
     270
     271
    272272    /**
    273273     *  Add managed columns by Type
     
    275275     *  @since 1.4.6.5
    276276     */
    277     private function get_comment_icon() 
     277    private function get_comment_icon()
    278278    {
    279279        return "<span class='vers'><img src='" . trailingslashit( get_admin_url() ) . 'images/comment-grey-bubble.png' . "' alt='Comments'></span>";
    280280    }
    281    
     281
    282282    /**
    283283     *  Add managed columns by Type
     
    285285     *  @since     1.1
    286286     */
    287     protected function add_columns_headings( $type, $columns ) 
     287    protected function add_columns_headings( $type, $columns )
    288288    {
    289289        // only get stored columns.. the rest we don't need
     
    292292        if ( !$db_columns )
    293293            return $columns;
    294        
     294
    295295        // filter already loaded columns by plugins
    296296        $set_columns = $this->filter_preset_columns( $type, $columns );
    297297
    298298        // loop through columns
    299         foreach ( $db_columns as $id => $values ) {         
     299        foreach ( $db_columns as $id => $values ) {
    300300            // is active
    301             if ( isset($values['state']) && $values['state'] == 'on' ){             
    302                
     301            if ( isset($values['state']) && $values['state'] == 'on' ){
     302
    303303                $label = $values['label'];
    304                
     304
    305305                // exception for comments
    306306                if( 'comments' == $id ) {
    307307                    $label = $this->get_comment_icon();
    308308                }
    309                
     309
    310310                // register format
    311311                $set_columns[$id] = $label;
    312312            }
    313313        }
    314        
     314
    315315        return $set_columns;
    316316    }
    317    
     317
    318318    /**
    319319     * Filter preset columns. These columns apply either for every post or set by a plugin.
     
    321321     * @since     1.0
    322322     */
    323     private function filter_preset_columns( $type, $columns ) 
     323    private function filter_preset_columns( $type, $columns )
    324324    {
    325325        $options    = get_option('cpac_options_default');
    326        
     326
    327327        if ( !$options )
    328328            return $columns;
    329        
     329
    330330        // we use the wp default columns for filtering...
    331331        $stored_wp_default_columns  = $options[$type];
     
    333333        // ... the ones that are set by plugins, theme functions and such.
    334334        $dif_columns    = array_diff(array_keys($columns), array_keys($stored_wp_default_columns));
    335            
     335
    336336        // we add those to the columns
    337337        $pre_columns = array();
     
    341341            }
    342342        }
    343        
     343
    344344        return $pre_columns;
    345345    }
    346    
     346
    347347    /**
    348348     * Get a list of Column options per post type
     
    350350     * @since     1.0
    351351     */
    352     private function get_column_boxes($type) 
    353     {   
     352    private function get_column_boxes($type)
     353    {
    354354        // merge all columns
    355355        $display_columns    = $this->get_merged_columns($type);
    356        
     356
    357357        // define
    358         $list = ''; 
    359        
     358        $list = '';
     359
    360360        // loop throught the active columns
    361361        if ( $display_columns ) {
    362             foreach ( $display_columns as $id => $values ) {       
    363                
     362            foreach ( $display_columns as $id => $values ) {
     363
    364364                $classes = array();
    365365
    366366                // set state
    367367                $state  = isset($values['state']) ? $values['state'] : '';
    368                
     368
    369369                // class
    370370                $classes[] = "cpac-box-{$id}";
     
    376376                }
    377377                $class = implode(' ', $classes);
    378                    
    379                 // more box options 
     378
     379                // more box options
    380380                $more_options   = $this->get_additional_box_options($type, $id, $values);
    381381                $action         = "<a class='cpac-action' href='#open'>open</a>";
    382                        
     382
    383383                // type label
    384384                $type_label = isset($values['options']['type_label']) ? $values['options']['type_label'] : '';
    385                
     385
    386386                // label
    387387                $label = isset($values['label']) ? str_replace("'", '"', $values['label']) : '';
    388                
     388
    389389                // main label
    390                 $main_label = $values['label']; 
    391                
     390                $main_label = $values['label'];
     391
    392392                // main label exception for comments
    393393                if ( 'comments' == $id ) {
    394394                    $main_label = $this->get_comment_icon();
    395395                }
    396                
     396
    397397                // width
    398398                $width          = isset($values['width']) ? $values['width'] : 0;
    399399                $width_descr    = isset($values['width']) && $values['width'] > 0 ? $values['width'] . '%' : __('default', CPAC_TEXTDOMAIN);
    400                
     400
    401401                // hide box options
    402402                $label_hidden = '';
     
    404404                    $label_hidden = ' style="display:none"';
    405405                }
    406                
     406
    407407                $list .= "
    408408                    <li class='{$class}'>
    409409                        <div class='cpac-sort-handle'></div>
    410                         <div class='cpac-type-options'>                 
     410                        <div class='cpac-type-options'>
    411411                            <div class='cpac-checkbox'></div>
    412412                            <input type='hidden' class='cpac-state' name='cpac_options[columns][{$type}][{$id}][state]' value='{$state}'/>
     
    417417                            <span>{$type_label}</span>
    418418                        </div>
    419                         <div class='cpac-type-inside'>             
     419                        <div class='cpac-type-inside'>
    420420                            <label for='cpac_options-{$type}-{$id}-label'{$label_hidden}>Label: </label>
    421421                            <input type='text' name='cpac_options[columns][{$type}][{$id}][label]' id='cpac_options-{$type}-{$id}-label' value='{$label}' class='text'{$label_hidden}/>
    422                             <label for='cpac_options-{$type}-{$id}-width'>" . __('Width', CPAC_TEXTDOMAIN) . ":</label>         
     422                            <label for='cpac_options-{$type}-{$id}-width'>" . __('Width', CPAC_TEXTDOMAIN) . ":</label>
    423423                            <input type='hidden' maxlength='4' class='input-width' name='cpac_options[columns][{$type}][{$id}][width]' id='cpac_options-{$type}-{$id}-width' value='{$width}' />
    424424                            <div class='description width-decription' title='" . __('default', CPAC_TEXTDOMAIN) . "'>{$width_descr}</div>
     
    428428                        </div>
    429429                    </li>
    430                 ";         
     430                ";
    431431            }
    432432        }
    433        
     433
    434434        // custom field button
    435435        $button_add_column = '';
    436436        if ( $this->get_meta_by_type($type) )
    437437            $button_add_column = "<a href='javacript:;' class='cpac-add-customfield-column button'>+ " . __('Add Custom Field Column', CPAC_TEXTDOMAIN) . "</a>";
    438        
     438
    439439        return "
    440440            <div class='cpac-box'>
    441441                <ul class='cpac-option-list'>
    442                     {$list}         
     442                    {$list}
    443443                </ul>
    444444                {$button_add_column}
    445                 <div class='cpac-reorder-msg'>" . __('drag and drop to reorder', CPAC_TEXTDOMAIN) . "</div>     
     445                <div class='cpac-reorder-msg'>" . __('drag and drop to reorder', CPAC_TEXTDOMAIN) . "</div>
    446446            </div>
    447447            ";
     
    453453     * @since     1.0
    454454     */
    455     protected function get_merged_columns( $type ) 
     455    protected function get_merged_columns( $type )
    456456    {
    457457        /** Comments */
     
    460460            $wp_custom_columns  = $this->get_custom_comments_columns();
    461461        }
    462        
     462
    463463        /** Links */
    464464        elseif ( $type == 'wp-links' ) {
     
    466466            $wp_custom_columns  = $this->get_custom_links_columns();
    467467        }
    468        
     468
    469469        /** Users */
    470470        elseif ( $type == 'wp-users' ) {
     
    472472            $wp_custom_columns  = $this->get_custom_users_columns();
    473473        }
    474        
     474
    475475        /** Media */
    476476        elseif ( $type == 'wp-media' ) {
     
    478478            $wp_custom_columns  = $this->get_custom_media_columns();
    479479        }
    480        
     480
    481481        /** Posts */
    482482        else {
     
    484484            $wp_custom_columns  = $this->get_custom_posts_columns($type);
    485485        }
    486        
     486
    487487        // merge columns
    488488        $display_columns = $this->parse_columns($wp_custom_columns, $wp_default_columns, $type);
    489        
    490         return $display_columns;       
    491     }
    492    
     489
     490        return $display_columns;
     491    }
     492
    493493    /**
    494494     * Merge the default columns (set by WordPress) and the added custom columns (set by plugins, theme etc.)
     
    496496     * @since     1.3.3
    497497     */
    498     function parse_columns($wp_custom_columns, $wp_default_columns, $type) 
     498    function parse_columns($wp_custom_columns, $wp_default_columns, $type)
    499499    {
    500500        // merge columns
    501501        $default_columns = wp_parse_args($wp_custom_columns, $wp_default_columns);
    502        
     502
    503503        //get saved database columns
    504504        $db_columns = self::get_stored_columns($type);
    505505        if ( $db_columns ) {
    506            
     506
    507507            // let's remove any unavailable columns.. such as disabled plugins
    508508            $db_columns      = $this->remove_unavailable_columns($db_columns, $default_columns);
    509            
     509
    510510            // loop throught the active columns
    511511            foreach ( $db_columns as $id => $values ) {
    512            
     512
    513513                // get column meta options from custom columns
    514                 if ( $this->is_column_meta($id) && !empty($wp_custom_columns['column-meta-1']['options']) ) {                   
    515                     $db_columns[$id]['options'] = $wp_custom_columns['column-meta-1']['options'];           
     514                if ( $this->is_column_meta($id) && !empty($wp_custom_columns['column-meta-1']['options']) ) {
     515                    $db_columns[$id]['options'] = $wp_custom_columns['column-meta-1']['options'];
    516516                }
    517                
     517
    518518                // add static options
    519519                elseif ( isset($default_columns[$id]['options']) )
    520520                    $db_columns[$id]['options'] = $default_columns[$id]['options'];
    521                
    522                 unset($default_columns[$id]);           
     521
     522                unset($default_columns[$id]);
    523523            }
    524         }   
    525        
     524        }
     525
    526526        // merge all
    527527        return wp_parse_args($db_columns, $default_columns);
    528528    }
    529    
     529
    530530    /**
    531531     * Remove deactivated (plugin) columns
     
    540540        // check or differences
    541541        $diff = array_diff( array_keys($db_columns), array_keys($default_columns) );
    542        
    543         if ( ! empty($diff) && is_array($diff) ) {                     
    544             foreach ( $diff as $column_name ){             
     542
     543        if ( ! empty($diff) && is_array($diff) ) {
     544            foreach ( $diff as $column_name ){
    545545                // make an exception for column-meta-xxx
    546546                if ( ! $this->is_column_meta($column_name) ) {
     
    549549            }
    550550        }
    551        
     551
    552552        return $db_columns;
    553553    }
    554    
     554
    555555    /**
    556556     * Get checkbox
     
    558558     * @since     1.0
    559559     */
    560     private function get_box($type, $id, $values) 
     560    private function get_box($type, $id, $values)
    561561    {
    562562        $classes = array();
     
    564564        // set state
    565565        $state  = isset($values['state']) ? $values['state'] : '';
    566        
     566
    567567        // class
    568568        $classes[] = "cpac-box-{$id}";
     
    574574        }
    575575        $class = implode(' ', $classes);
    576            
    577         // more box options 
     576
     577        // more box options
    578578        $more_options   = $this->get_additional_box_options($type, $id, $values);
    579579        $action         = "<a class='cpac-action' href='#open'>open</a>";
    580                
     580
    581581        // type label
    582582        $type_label = isset($values['options']['type_label']) ? $values['options']['type_label'] : '';
    583        
     583
    584584        // label
    585585        $label = isset($values['label']) ? str_replace("'", '"', $values['label']) : '';
    586        
     586
    587587        // main label
    588         $main_label = $values['label']; 
    589        
     588        $main_label = $values['label'];
     589
    590590        // main label exception for comments
    591591        if ( 'comments' == $id ) {
    592592            $main_label = $this->get_comment_icon();
    593593        }
    594        
     594
    595595        // width
    596596        $width          = isset($values['width']) ? $values['width'] : 0;
    597597        $width_descr    = isset($values['width']) && $values['width'] > 0 ? $values['width'] . '%' : __('default', CPAC_TEXTDOMAIN);
    598        
     598
    599599        // hide box options
    600600        $label_hidden = '';
     
    602602            $label_hidden = ' style="display:none"';
    603603        }
    604        
     604
    605605        $list = "
    606606            <li class='{$class}'>
    607607                <div class='cpac-sort-handle'></div>
    608                 <div class='cpac-type-options'>                 
     608                <div class='cpac-type-options'>
    609609                    <div class='cpac-checkbox'></div>
    610610                    <input type='hidden' class='cpac-state' name='cpac_options[columns][{$type}][{$id}][state]' value='{$state}'/>
     
    615615                    <span>{$type_label}</span>
    616616                </div>
    617                 <div class='cpac-type-inside'>             
     617                <div class='cpac-type-inside'>
    618618                    <label for='cpac_options-{$type}-{$id}-label'{$label_hidden}>Label: </label>
    619619                    <input type='text' name='cpac_options[columns][{$type}][{$id}][label]' id='cpac_options-{$type}-{$id}-label' value='{$label}' class='text'{$label_hidden}/>
    620                     <label for='cpac_options-{$type}-{$id}-width'>" . __('Width', CPAC_TEXTDOMAIN) . ":</label>         
     620                    <label for='cpac_options-{$type}-{$id}-width'>" . __('Width', CPAC_TEXTDOMAIN) . ":</label>
    621621                    <input type='hidden' maxlength='4' class='input-width' name='cpac_options[columns][{$type}][{$id}][width]' id='cpac_options-{$type}-{$id}-width' value='{$width}' />
    622622                    <div class='description width-decription' title='" . __('default', CPAC_TEXTDOMAIN) . "'>{$width_descr}</div>
     
    627627            </li>
    628628        ";
    629        
     629
    630630        return $list;
    631631    }
     
    636636     * @since     1.0
    637637     */
    638     private function get_additional_box_options($type, $id, $values) 
     638    private function get_additional_box_options($type, $id, $values)
    639639    {
    640640        $fields = '';
    641        
     641
    642642        // Custom Fields
    643643        if( $this->is_column_meta($id) ) {
    644644            $fields = $this->get_box_options_customfields($type, $id, $values);
    645645        }
    646            
     646
    647647        // Author Fields
    648648        if( 'column-author-name' == $id) {
    649649            $fields = $this->get_box_options_author($type, $id, $values);
    650650        }
    651        
     651
    652652        return $fields;
    653653    }
     
    658658     * @since     1.0
    659659     */
    660     private function get_box_options_customfields($type, $id, $values) 
    661     {
    662         // get post meta fields 
     660    private function get_box_options_customfields($type, $id, $values)
     661    {
     662        // get post meta fields
    663663        $fields = $this->get_meta_by_type($type);
    664        
    665         if ( empty($fields) ) 
     664
     665        if ( empty($fields) )
    666666            return false;
    667        
     667
    668668        // set meta field options
    669669        $current = ! empty($values['field']) ? $values['field'] : '' ;
    670670        $field_options = '';
    671671        foreach ($fields as $field) {
    672            
     672
    673673            $field_options .= sprintf
    674674            (
     
    676676                $field,
    677677                $field == $current? ' selected="selected"':'',
    678                
     678
    679679                // change label on hidden fields
    680                 substr($field,0,10) == "cpachidden" ? str_replace('cpachidden','',$field) : $field     
    681             );     
    682         }
    683        
     680                substr($field,0,10) == "cpachidden" ? str_replace('cpachidden','',$field) : $field
     681            );
     682        }
     683
    684684        // set meta fieldtype options
    685685        $currenttype = ! empty($values['field_type']) ? $values['field_type'] : '' ;
     
    698698            'color'         => __('Color', CPAC_TEXTDOMAIN),
    699699        );
    700        
     700
    701701        // add filter
    702702        $fieldtypes = apply_filters('cpac-field-types', $fieldtypes );
    703        
     703
    704704        // set select options
    705705        foreach ( $fieldtypes as $fkey => $fieldtype ) {
     
    712712            );
    713713        }
    714        
     714
    715715        // before and after string
    716716        $before = ! empty($values['before'])    ? $values['before'] : '' ;
    717717        $after  = ! empty($values['after'])     ? $values['after']  : '' ;
    718        
     718
    719719        if ( empty($field_options) )
    720720            return false;
    721        
     721
    722722        // add remove button
    723723        $remove = '<p class="remove-description description">'.__('This field can not be removed', CPAC_TEXTDOMAIN).'</p>';
     
    729729            ";
    730730        }
    731        
     731
    732732        $inside = "
    733733            <label for='cpac-{$type}-{$id}-field'>".__('Custom Field', CPAC_TEXTDOMAIN).": </label>
     
    738738            <br/>
    739739            <label for='cpac-{$type}-{$id}-before'>".__('Before', CPAC_TEXTDOMAIN).": </label>
    740             <input type='text' class='cpac-before' name='cpac_options[columns][{$type}][{$id}][before]' id='cpac-{$type}-{$id}-before' value='{$before}'/>             
    741             <br/>   
     740            <input type='text' class='cpac-before' name='cpac_options[columns][{$type}][{$id}][before]' id='cpac-{$type}-{$id}-before' value='{$before}'/>
     741            <br/>
    742742            <label for='cpac-{$type}-{$id}-after'>".__('After', CPAC_TEXTDOMAIN).": </label>
    743             <input type='text' class='cpac-after' name='cpac_options[columns][{$type}][{$id}][after]' id='cpac-{$type}-{$id}-after' value='{$after}'/>             
    744             <br/>       
     743            <input type='text' class='cpac-after' name='cpac_options[columns][{$type}][{$id}][after]' id='cpac-{$type}-{$id}-after' value='{$after}'/>
     744            <br/>
    745745            {$remove}
    746746        ";
    747        
     747
    748748        return $inside;
    749749    }
    750    
     750
    751751    /**
    752752     * Box Options: Custom Fields
     
    754754     * @since     1.0
    755755     */
    756     private function get_box_options_author($type, $id, $values) 
     756    private function get_box_options_author($type, $id, $values)
    757757    {
    758758        $options = '';
     
    772772            $options .= "<option value='{$k}' {$selected}>{$name}</option>";
    773773        }
    774        
     774
    775775        $inside = "
    776776            <label for='cpac-{$type}-{$id}-display_as'>".__('Display name as', CPAC_TEXTDOMAIN).": </label>
    777777            <select name='cpac_options[columns][{$type}][{$id}][display_as]' id='cpac-{$type}-{$id}-display_as'>
    778778                {$options}
    779             </select>           
     779            </select>
    780780        ";
    781        
     781
    782782        return $inside;
    783783    }
     
    788788     * @since     1.0
    789789     */
    790     private function get_meta_by_type($type = 'post') 
     790    private function get_meta_by_type($type = 'post')
    791791    {
    792792        global $wpdb;
     
    796796            $sql = "SELECT DISTINCT meta_key FROM {$wpdb->commentmeta} ORDER BY 1";
    797797        }
    798        
     798
    799799        /** Users */
    800800        elseif ( $type == 'wp-users') {
    801801            $sql = "SELECT DISTINCT meta_key FROM {$wpdb->usermeta} ORDER BY 1";
    802802        }
    803        
     803
    804804        /** Media */
    805805        elseif ( $type == 'wp-media') {
    806806            $sql = "SELECT DISTINCT meta_key FROM {$wpdb->postmeta} pm JOIN {$wpdb->posts} p ON pm.post_id = p.ID WHERE p.post_type = 'attachment' ORDER BY 1";
    807807        }
    808        
     808
    809809        /** Posts */
    810810        else {
    811811            $sql = $wpdb->prepare( "SELECT DISTINCT meta_key FROM {$wpdb->postmeta} pm JOIN {$wpdb->posts} p ON pm.post_id = p.ID WHERE p.post_type = %s ORDER BY 1", $type);
    812812        }
    813        
     813
    814814        // run sql
    815815        $fields = $wpdb->get_results($sql, ARRAY_N);
    816        
     816
    817817        // filter out hidden meta fields
    818818        $meta_fields = array();
    819         if ( $fields ) {           
     819        if ( $fields ) {
    820820            foreach ($fields as $field) {
    821                
     821
    822822                // give hidden fields a prefix for identifaction
    823823                if ( $this->use_hidden_custom_fields && substr($field[0],0,1) == "_") {
    824824                    $meta_fields[] = 'cpachidden'.$field[0];
    825825                }
    826                
     826
    827827                // non hidden fields are saved as is
    828828                elseif ( substr($field[0],0,1) != "_" ) {
    829829                    $meta_fields[] = $field[0];
    830                 }   
    831             }           
    832         }
    833        
    834         if ( !empty($meta_fields) )
    835             return $meta_fields;
    836        
    837         return false;
     830                }
     831            }
     832        }
     833
     834        if ( empty($meta_fields) )
     835            $meta_fields = false;
     836
     837        return apply_filters( 'cpac-get-meta-by-type', $meta_fields, $type );
    838838    }
    839839
     
    843843     * @since     1.0
    844844     */
    845     public function admin_scripts() 
     845    public function admin_scripts()
    846846    {
    847847        wp_enqueue_script( 'wp-pointer' );
    848         wp_enqueue_script( 'jquery-ui-slider' );       
     848        wp_enqueue_script( 'jquery-ui-slider' );
    849849        wp_enqueue_script( 'cpac-qtip2', CPAC_URL.'/assets/js/jquery.qtip.js', array('jquery'), CPAC_VERSION );
    850850        wp_enqueue_script( 'cpac-admin', CPAC_URL.'/assets/js/admin-column.js', array('jquery', 'dashboard', 'jquery-ui-sortable'), CPAC_VERSION );
    851     }   
    852    
     851    }
     852
    853853    /**
    854854     *  Get column types
     
    863863        $types['wp-links']      = 'wp-links';
    864864        $types['wp-comments']   = 'wp-comments';
    865        
     865
    866866        return $types;
    867867    }
    868    
     868
    869869    /**
    870870     * Get post types
     
    879879        $post_types['post'] = 'post';
    880880        $post_types['page'] = 'page';
    881        
     881
    882882        return apply_filters('cpac-get-post-types', $post_types);
    883883    }
     
    891891    {
    892892        wp_enqueue_style( 'wp-pointer' );
    893         wp_enqueue_style( 'jquery-ui-lightness', CPAC_URL.'/assets/ui-theme/jquery-ui-1.8.18.custom.css', array(), CPAC_VERSION, 'all' );   
    894         wp_enqueue_style( 'cpac-admin', CPAC_URL.'/assets/css/admin-column.css', array(), CPAC_VERSION, 'all' );   
    895     }
    896    
     893        wp_enqueue_style( 'jquery-ui-lightness', CPAC_URL.'/assets/ui-theme/jquery-ui-1.8.18.custom.css', array(), CPAC_VERSION, 'all' );
     894        wp_enqueue_style( 'cpac-admin', CPAC_URL.'/assets/css/admin-column.css', array(), CPAC_VERSION, 'all' );
     895    }
     896
    897897    /**
    898898     * Register column css
     
    902902    public function column_styles()
    903903    {
    904         wp_enqueue_style( 'cpac-columns', CPAC_URL.'/assets/css/column.css', array(), CPAC_VERSION, 'all' );   
     904        wp_enqueue_style( 'cpac-columns', CPAC_URL.'/assets/css/column.css', array(), CPAC_VERSION, 'all' );
    905905    }
    906906
     
    910910     * @since     1.0
    911911     */
    912     public function register_settings() 
     912    public function register_settings()
    913913    {
    914914        // If we have no options in the database, let's add them now.
     
    916916            add_option( 'cpac_options', $this->get_default_plugin_options() );
    917917        }
    918        
     918
    919919        register_setting( 'cpac-settings-group', 'cpac_options', array($this, 'options_callback') );
    920     }   
     920    }
    921921
    922922    /**
     
    925925     * @since     1.0
    926926     */
    927     public function get_default_plugin_options() 
     927    public function get_default_plugin_options()
    928928    {
    929929        return apply_filters( 'cpac_default_plugin_options', array() );
     
    936936     */
    937937    public function options_callback($options)
    938     {   
     938    {
    939939        return $options;
    940940    }
     
    945945     * @since     1.0
    946946     */
    947     public function handle_requests() 
     947    public function handle_requests()
    948948    {
    949949        // only handle updates from the admin columns page
    950950        if ( isset($_REQUEST['page']) && CPAC_SLUG == $_REQUEST['page'] ) {
    951                
     951
    952952            // settings updated
    953953            if ( ! empty($_REQUEST['settings-updated']) ) {
    954954                $this->store_wp_default_columns();
    955955            }
    956            
    957             // restore defaults 
     956
     957            // restore defaults
    958958            if ( ! empty($_REQUEST['cpac-restore-defaults']) ) {
    959959                $this->restore_defaults();
     
    961961        }
    962962    }
    963    
     963
    964964    /**
    965965     * Stores WP default columns
     
    969969     * @since     1.2
    970970     */
    971     private function store_wp_default_columns() 
    972     {   
     971    private function store_wp_default_columns()
     972    {
    973973        // stores the default columns that are set by WP or theme.
    974974        $wp_default_columns = array();
    975        
     975
    976976        // Posts
    977977        foreach ( $this->post_types as $post_type ) {
    978978            $wp_default_columns[$post_type] = $this->get_wp_default_posts_columns($post_type);
    979979        }
    980        
     980
    981981        // Users
    982982        $wp_default_columns['wp-users'] = $this->get_wp_default_users_columns();
    983        
     983
    984984        // Media
    985985        $wp_default_columns['wp-media'] = $this->get_wp_default_media_columns();
    986        
     986
    987987        // Links
    988988        $wp_default_columns['wp-links'] = $this->get_wp_default_links_columns();
    989        
     989
    990990        // Comments
    991         $wp_default_columns['wp-comments'] = $this->get_wp_default_comments_columns();     
    992        
     991        $wp_default_columns['wp-comments'] = $this->get_wp_default_comments_columns();
     992
    993993        update_option( 'cpac_options_default', $wp_default_columns );
    994994    }
     
    999999     * @since     1.0
    10001000     */
    1001     private function restore_defaults() 
    1002     {   
     1001    private function restore_defaults()
     1002    {
    10031003        delete_option( 'cpac_options' );
    1004         delete_option( 'cpac_options_default' );       
    1005     }   
    1006    
     1004        delete_option( 'cpac_options_default' );
     1005    }
     1006
    10071007    /**
    10081008     * Get author field by nametype
     
    10151015    {
    10161016        $userdata = get_userdata( $user_id );
    1017    
     1017
    10181018        switch ( $nametype ) :
    1019            
     1019
    10201020            case "display_name" :
    10211021                $name = $userdata->display_name;
    10221022                break;
    1023                
     1023
    10241024            case "first_name" :
    10251025                $name = $userdata->first_name;
    1026                 break;     
    1027                
     1026                break;
     1027
    10281028            case "last_name" :
    10291029                $name = $userdata->last_name;
    10301030                break;
    1031                
     1031
    10321032            case "first_last_name" :
    10331033                $first = !empty($userdata->first_name) ? $userdata->first_name : '';
     
    10351035                $name = $first.$last;
    10361036                break;
    1037                
     1037
    10381038            case "nickname" :
    10391039                $name = $userdata->nickname;
    1040                 break;     
    1041                
     1040                break;
     1041
    10421042            case "username" :
    10431043                $name = $userdata->user_login;
    10441044                break;
    1045            
     1045
    10461046            case "email" :
    10471047                $name = $userdata->user_email;
    10481048                break;
    1049                
     1049
    10501050            case "userid" :
    10511051                $name = $userdata->ID;
    10521052                break;
    1053                
     1053
    10541054            default :
    10551055                $name = $userdata->display_name;
    1056            
     1056
    10571057        endswitch;
    1058        
     1058
    10591059        return $name;
    10601060    }
    1061    
     1061
    10621062    /**
    10631063     *  Get WP default supported admin columns per post type.
     
    10651065     *  @since     1.0
    10661066     */
    1067     private function get_wp_default_posts_columns($post_type = 'post')
    1068     {
    1069         // we need to change the current screen
    1070         global $current_screen;
    1071            
    1072         // some plugins depend on settings the $_GET['post_type'] variable such as ALL in One SEO
    1073         $_GET['post_type'] = $post_type;
    1074        
    1075         // to prevent possible warning from initializing load-edit.php
    1076         // we will set a dummy screen object
    1077         if ( empty($current_screen->post_type) ) {
    1078             $current_screen = (object) array( 'post_type' => $post_type, 'id' => '', 'base' => '' );           
    1079         }       
    1080        
    1081         // for 3rd party plugin support we will call load-edit.php so all the
    1082         // additional columns that are set by them will be avaible for us       
    1083         do_action('load-edit.php');
    1084        
     1067    private function get_wp_default_posts_columns($post_type = 'post')
     1068    {
     1069        // You can use this filter to add thirdparty columns by hooking into this. See classes/third_party.php for an example.
     1070        do_action( 'cpac-get-default-columns-posts', $post_type );
     1071
    10851072        // some plugins directly hook into get_column_headers, such as woocommerce
    10861073        $columns = get_column_headers( 'edit-'.$post_type );
    1087        
    1088         // get default columns     
    1089         if ( empty($columns) ) {       
    1090            
     1074
     1075        // get default columns
     1076        if ( empty($columns) ) {
     1077
    10911078            // deprecated as of wp3.3
    10921079            if ( file_exists(ABSPATH . 'wp-admin/includes/template.php') )
    10931080                require_once(ABSPATH . 'wp-admin/includes/template.php');
    1094                
     1081
    10951082            // introduced since wp3.3
    10961083            if ( file_exists(ABSPATH . 'wp-admin/includes/screen.php') )
    10971084                require_once(ABSPATH . 'wp-admin/includes/screen.php');
    1098                
     1085
    10991086            // used for getting columns
    11001087            if ( file_exists(ABSPATH . 'wp-admin/includes/class-wp-list-table.php') )
     
    11021089            if ( file_exists(ABSPATH . 'wp-admin/includes/class-wp-posts-list-table.php') )
    11031090                require_once(ABSPATH . 'wp-admin/includes/class-wp-posts-list-table.php');
    1104                        
     1091
    11051092            // As of WP Release 3.5 we can use the following.
    11061093            if ( version_compare( get_bloginfo('version'), '3.4.10', '>=' ) ) {
    1107                
     1094
    11081095                $table      = new WP_Posts_List_Table( array( 'screen' => $post_type ) );
    11091096                $columns    = $table->get_columns();
    11101097            }
    1111            
     1098
    11121099            // WP versions older then 3.5
    11131100            // @todo: make this deprecated
    1114             else {         
    1115            
     1101            else {
     1102
    11161103                // we need to change the current screen... first lets save original
    11171104                $org_current_screen = $current_screen;
    1118                
    1119                 // prevent php warning 
     1105
     1106                // prevent php warning
    11201107                if ( !isset($current_screen) ) $current_screen = new stdClass;
    1121                
     1108
    11221109                // overwrite current_screen global with our post type of choose...
    11231110                $current_screen->post_type = $post_type;
    1124                
    1125                 // ...so we can get its columns     
    1126                 $columns = WP_Posts_List_Table::get_columns();             
    1127                
     1111
     1112                // ...so we can get its columns
     1113                $columns = WP_Posts_List_Table::get_columns();
     1114
    11281115                // reset current screen
    11291116                $current_screen = $org_current_screen;
    11301117            }
    11311118        }
    1132        
     1119
    11331120        if ( empty ( $columns ) )
    11341121            return false;
    1135            
     1122
    11361123        // change to uniform format
    1137         $columns = $this->get_uniform_format($columns);     
     1124        $columns = $this->get_uniform_format($columns);
    11381125
    11391126        // add sorting to some of the default links columns
    11401127        $columns = $this->set_sorting_to_default_posts_columns($columns);
    1141        
     1128
    11421129        return $columns;
    11431130    }
    1144    
     1131
    11451132    /**
    11461133     *  Add Sorting to WP default Posts columns
     
    11491136     */
    11501137    private function set_sorting_to_default_posts_columns($columns)
    1151     {   
     1138    {
    11521139        //  categories
    11531140        if ( !empty($columns['categories']) ) {
     
    11601147        return $columns;
    11611148    }
    1162    
     1149
    11631150    /**
    11641151     *  Get WP default users columns per post type.
     
    11681155    private function get_wp_default_users_columns()
    11691156    {
     1157        // You can use this filter to add third_party columns by hooking into this.
     1158        do_action( 'cpac-get-default-columns-users' );
     1159
    11701160        if ( file_exists(ABSPATH . 'wp-admin/includes/class-wp-list-table.php') )
    11711161            require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
    11721162        if ( file_exists(ABSPATH . 'wp-admin/includes/class-wp-users-list-table.php') )
    11731163            require_once(ABSPATH . 'wp-admin/includes/class-wp-users-list-table.php');
    1174        
     1164
    11751165        // turn off site users
    11761166        $this->is_site_users = false;
    1177        
     1167
    11781168        // get users columns
    11791169        $columns = WP_Users_List_Table::get_columns();
    1180        
     1170
    11811171        // change to uniform format
    11821172        $columns = $this->get_uniform_format($columns);
     
    11841174        return apply_filters('cpac-default-users-columns', $columns);
    11851175    }
    1186    
     1176
    11871177    /**
    11881178     *  Get WP default media columns.
     
    11911181     */
    11921182    private function get_wp_default_media_columns()
    1193     {       
     1183    {
     1184        // You can use this filter to add third_party columns by hooking into this.
     1185        do_action( 'cpac-get-default-columns-media' );
     1186
    11941187        // @todo could use _get_list_table('WP_Media_List_Table') ?
    11951188        if ( file_exists(ABSPATH . 'wp-admin/includes/class-wp-list-table.php') )
     
    11971190        if ( file_exists(ABSPATH . 'wp-admin/includes/class-wp-media-list-table.php') )
    11981191            require_once(ABSPATH . 'wp-admin/includes/class-wp-media-list-table.php');
    1199        
     1192
    12001193        // As of WP Release 3.5 we can use the following.
    12011194        if ( version_compare( get_bloginfo('version'), '3.4.10', '>=' ) ) {
    1202            
     1195
    12031196            $table      = new WP_Media_List_Table(array( 'screen' => 'upload' ));
    12041197            $columns    = $table->get_columns();
    12051198        }
    1206        
     1199
    12071200        // WP versions older then 3.5
    12081201        // @todo: make this deprecated
    1209         else { 
    1210        
     1202        else {
     1203
    12111204            global $current_screen;
    12121205
    12131206            // save original
    12141207            $org_current_screen = $current_screen;
    1215            
    1216             // prevent php warning 
     1208
     1209            // prevent php warning
    12171210            if ( !isset($current_screen) ) $current_screen = new stdClass;
    1218            
     1211
    12191212            // overwrite current_screen global with our media id...
    12201213            $current_screen->id = 'upload';
    1221            
     1214
    12221215            // init media class
    12231216            $wp_media = new WP_Media_List_Table;
    1224            
    1225             // get media columns       
     1217
     1218            // get media columns
    12261219            $columns = $wp_media->get_columns();
    1227            
     1220
    12281221            // reset current screen
    12291222            $current_screen = $org_current_screen;
    12301223        }
    1231        
     1224
    12321225        // change to uniform format
    12331226        $columns = $this->get_uniform_format($columns);
    1234        
     1227
    12351228        return apply_filters('cpac-default-media-columns', $columns);
    12361229    }
    1237    
     1230
    12381231    /**
    12391232     *  Get WP default links columns.
     
    12431236    private function get_wp_default_links_columns()
    12441237    {
     1238        // You can use this filter to add third_party columns by hooking into this.
     1239        do_action( 'cpac-get-default-columns-links' );
     1240
    12451241        // dependencies
    12461242        if ( file_exists(ABSPATH . 'wp-admin/includes/class-wp-list-table.php') )
     
    12481244        if ( file_exists(ABSPATH . 'wp-admin/includes/class-wp-links-list-table.php') )
    12491245            require_once(ABSPATH . 'wp-admin/includes/class-wp-links-list-table.php');
    1250        
     1246
    12511247        // get links columns
    12521248        $columns = WP_Links_List_Table::get_columns();
     
    12541250        // change to uniform format
    12551251        $columns = $this->get_uniform_format($columns);
    1256        
     1252
    12571253        // add sorting to some of the default links columns
    12581254        $columns = $this->set_sorting_to_default_links_columns($columns);
    1259        
     1255
    12601256        return apply_filters('cpac-default-links-columns', $columns);
    12611257    }
    1262    
     1258
    12631259    /**
    12641260     *  Add Sorting to WP default links columns
     
    12741270        return $columns;
    12751271    }
    1276    
     1272
    12771273    /**
    12781274     *  Get WP default links columns.
     
    12811277     */
    12821278    private function get_wp_default_comments_columns()
    1283     {       
     1279    {
     1280        // You can use this filter to add third_party columns by hooking into this.
     1281        do_action( 'cpac-get-default-columns-comments' );
     1282
    12841283        // dependencies
    12851284        if ( file_exists(ABSPATH . 'wp-admin/includes/class-wp-list-table.php') )
     
    12871286        if ( file_exists(ABSPATH . 'wp-admin/includes/class-wp-comments-list-table.php') )
    12881287            require_once(ABSPATH . 'wp-admin/includes/class-wp-comments-list-table.php');
    1289        
     1288
    12901289        // As of WP Release 3.5 we can use the following.
    12911290        if ( version_compare( get_bloginfo('version'), '3.4.10', '>=' ) ) {
    1292            
     1291
    12931292            $table      = new WP_Comments_List_Table( array( 'screen' => 'edit-comments' ) );
    12941293            $columns    = $table->get_columns();
    12951294        }
    1296        
     1295
    12971296        // WP versions older then 3.5
    12981297        // @todo: make this deprecated
    12991298        else {
    1300        
     1299
    13011300            global $current_screen;
    13021301
    1303             // save original       
     1302            // save original
    13041303            $org_current_screen = $current_screen;
    1305            
    1306             // prevent php warning 
     1304
     1305            // prevent php warning
    13071306            if ( !isset($current_screen) ) $current_screen = new stdClass;
    1308            
     1307
    13091308            // overwrite current_screen global with our media id...
    13101309            $current_screen->id = 'edit-comments';
    1311            
     1310
    13121311            // init table object
    1313             $wp_comment = new WP_Comments_List_Table;       
    1314            
     1312            $wp_comment = new WP_Comments_List_Table;
     1313
    13151314            // get comments
    13161315            $columns = $wp_comment->get_columns();
    1317            
     1316
    13181317            // reset current screen
    13191318            $current_screen = $org_current_screen;
    13201319        }
    1321        
     1320
    13221321        // change to uniform format
    13231322        $columns = $this->get_uniform_format($columns);
    1324        
     1323
    13251324        // add sorting to some of the default links columns
    13261325        $columns = $this->set_sorting_to_default_comments_columns($columns);
    1327        
     1326
    13281327        return apply_filters('cpac-default-comments-columns', $columns);
    13291328    }
    1330    
     1329
    13311330    /**
    13321331     *  Add Sorting to WP default comments columns
     
    13481347     * @since     1.0
    13491348     */
    1350     private function get_uniform_format($columns) 
    1351     {
    1352         // we remove the checkbox column as an option... 
     1349    private function get_uniform_format($columns)
     1350    {
     1351        // we remove the checkbox column as an option...
    13531352        if ( isset($columns['cb']) )
    13541353            unset($columns['cb']);
    1355        
     1354
    13561355        // change to uniform format
    13571356        $uniform_columns = array();
     
    13591358            $hide_options   = false;
    13601359            $type_label     = $label;
    1361            
    1362             // comment exception       
    1363             if ( 'comments' == $id ) {                 
     1360
     1361            // comment exception
     1362            if ( 'comments' == $id ) {
    13641363                $label          = '';
    13651364                $type_label     = __('Comments', CPAC_TEXTDOMAIN);
    13661365                $hide_options   = true;
    13671366            }
    1368            
     1367
    13691368            // user icon exception
    13701369            if ( $id == 'icon' ) {
    13711370                $type_label     = __('Icon', CPAC_TEXTDOMAIN);
    13721371            }
    1373            
     1372
    13741373            $uniform_columns[$id] = array(
    13751374                'label'         => $label,
     
    13841383        return $uniform_columns;
    13851384    }
    1386    
     1385
    13871386    /**
    13881387     * Custom posts columns
     
    13901389     * @since     1.0
    13911390     */
    1392     private function get_custom_posts_columns($post_type) 
     1391    private function get_custom_posts_columns($post_type)
    13931392    {
    13941393        $custom_columns = array(
     
    14461445            ),
    14471446            'column-before-moretag' => array(
    1448                 'label' => __('Before More Tag', CPAC_TEXTDOMAIN)               
     1447                'label' => __('Before More Tag', CPAC_TEXTDOMAIN)
    14491448            )
    14501449        );
    1451        
     1450
    14521451        // Word count support
    14531452        if ( post_type_supports($post_type, 'editor') ) {
     
    14561455            );
    14571456        }
    1458        
     1457
    14591458        // Sticky support
    1460         if ( $post_type == 'post' ) {       
     1459        if ( $post_type == 'post' ) {
    14611460            $custom_columns['column-sticky'] = array(
    14621461                'label'         => __('Sticky', CPAC_TEXTDOMAIN)
    14631462            );
    14641463        }
    1465        
     1464
    14661465        // Order support
    14671466        if ( post_type_supports($post_type, 'page-attributes') ) {
    14681467            $custom_columns['column-order'] = array(
    1469                 'label'         => __('Page Order', CPAC_TEXTDOMAIN),               
     1468                'label'         => __('Page Order', CPAC_TEXTDOMAIN),
    14701469                'options'       => array(
    14711470                    'type_label'    => __('Order', CPAC_TEXTDOMAIN)
    1472                 )           
     1471                )
    14731472            );
    14741473        }
    1475        
     1474
    14761475        // Page Template
    1477         if ( $post_type == 'page' ) { 
     1476        if ( $post_type == 'page' ) {
    14781477            $custom_columns['column-page-template'] = array(
    14791478                'label' => __('Page Template', CPAC_TEXTDOMAIN)
    1480             ); 
    1481         }
    1482        
     1479            );
     1480        }
     1481
    14831482        // Post Formats
    14841483        if ( post_type_supports($post_type, 'post-formats') ) {
     
    14871486            );
    14881487        }
    1489        
     1488
    14901489        // Taxonomy support
    14911490        $taxonomies = get_object_taxonomies($post_type, 'objects');
     
    14991498                            'type_label'    => __('Taxonomy', CPAC_TEXTDOMAIN)
    15001499                        )
    1501                     );             
     1500                    );
    15021501                }
    15031502            }
    15041503        }
    1505        
     1504
    15061505        // Custom Field support
    15071506        if ( $this->get_meta_by_type($post_type) ) {
     
    15151514                    'type_label'    => __('Field', CPAC_TEXTDOMAIN),
    15161515                    'class'         => 'cpac-box-metafield'
    1517                 )           
     1516                )
    15181517            );
    1519         }   
    1520        
     1518        }
     1519
    15211520        // merge with defaults
    15221521        $custom_columns = $this->parse_defaults($custom_columns);
    1523        
     1522
    15241523        return apply_filters('cpac-custom-posts-columns', $custom_columns);
    15251524    }
    1526    
     1525
    15271526    /**
    15281527     * Custom users columns
     
    15301529     * @since     1.1
    15311530     */
    1532     private function get_custom_users_columns() 
     1531    private function get_custom_users_columns()
    15331532    {
    15341533        $custom_columns = array(
     
    15611560            ),
    15621561        );
    1563        
     1562
    15641563        // User total number of posts
    15651564        foreach ( self::get_post_types() as $post_type ) {
     
    15721571            );
    15731572        }
    1574        
     1573
    15751574        // Custom Field support
    15761575        $custom_columns['column-meta-1'] = array(
     
    15841583                'class'         => 'cpac-box-metafield'
    15851584            )
    1586         ); 
    1587        
     1585        );
     1586
    15881587        // merge with defaults
    15891588        $custom_columns = $this->parse_defaults($custom_columns);
    1590        
     1589
    15911590        return apply_filters('cpac-custom-users-columns', $custom_columns);
    15921591    }
    1593    
     1592
    15941593    /**
    15951594     * Custom media columns
     
    15971596     * @since     1.3
    15981597     */
    1599     private function get_custom_media_columns() 
     1598    private function get_custom_media_columns()
    16001599    {
    16011600        $custom_columns = array(
     
    16411640            'column-filesize' => array(
    16421641                'label' => __('File size', CPAC_TEXTDOMAIN)
    1643             )           
     1642            )
    16441643        );
    1645        
     1644
    16461645        // Get extended image metadata, exif or iptc as available.
    16471646        // uses exif_read_data()
     
    17101709            ));
    17111710        }
    1712        
     1711
    17131712        // Custom Field support
    17141713        if ( $this->get_meta_by_type('wp-media') ) {
     
    17251724            );
    17261725        }
    1727        
     1726
    17281727        // merge with defaults
    17291728        $custom_columns = $this->parse_defaults($custom_columns);
    1730        
     1729
    17311730        return apply_filters('cpac-custom-media-columns', $custom_columns);
    17321731    }
    1733    
     1732
    17341733    /**
    17351734     * Custom links columns
     
    17371736     * @since     1.3.1
    17381737     */
    1739     private function get_custom_links_columns() 
     1738    private function get_custom_links_columns()
    17401739    {
    17411740        $custom_columns = array(
     
    17691768                    'sortorder' => false
    17701769                )
    1771             )           
    1772         ); 
    1773        
     1770            )
     1771        );
     1772
    17741773        // merge with defaults
    17751774        $custom_columns = $this->parse_defaults($custom_columns);
    1776        
     1775
    17771776        return apply_filters('cpac-custom-links-columns', $custom_columns);
    17781777    }
    1779    
     1778
    17801779    /**
    17811780     * Custom comments columns
     
    17831782     * @since     1.3.1
    17841783     */
    1785     private function get_custom_comments_columns() 
     1784    private function get_custom_comments_columns()
    17861785    {
    17871786        $custom_columns = array(
     
    18051804            ),
    18061805            'column-reply_to' => array(
    1807                 'label'         => __('In Reply To', CPAC_TEXTDOMAIN), 
    1808                 'options'       => array(                   
     1806                'label'         => __('In Reply To', CPAC_TEXTDOMAIN),
     1807                'options'       => array(
    18091808                    'sortorder'     => false
    18101809                )
     
    18371836                )
    18381837            )
    1839         );     
    1840        
     1838        );
     1839
    18411840        // Custom Field support
    18421841        if ( $this->get_meta_by_type('wp-comments') ) {
     
    18531852                )
    18541853            );
    1855         }       
    1856        
     1854        }
     1855
    18571856        // merge with defaults
    18581857        $custom_columns = $this->parse_defaults($custom_columns);
    1859        
     1858
    18601859        return apply_filters('cpac-custom-comments-columns', $custom_columns);
    18611860    }
    1862    
     1861
    18631862    /**
    18641863     * Parse defaults
     
    18661865     * @since     1.1
    18671866     */
    1868     private function parse_defaults($columns) 
     1867    private function parse_defaults($columns)
    18691868    {
    18701869        // default arguments
    1871         $defaults = array( 
    1872            
     1870        $defaults = array(
     1871
    18731872            // stored values
    18741873            'label'         => '', // custom label
    18751874            'state'         => '', // display state
    1876             'width'         => '', // column width         
    1877            
     1875            'width'         => '', // column width
     1876
    18781877            // static values
    1879             'options'       => array(               
     1878            'options'       => array(
    18801879                'type_label'    => __('Custom', CPAC_TEXTDOMAIN),
    18811880                'hide_options'  => false,
     
    18841883            )
    18851884        );
    1886        
     1885
    18871886        // parse args
    18881887        foreach ( $columns as $k => $column ) {
    18891888            $c[$k] = wp_parse_args( $column, $defaults);
    1890            
     1889
    18911890            // parse options args
    18921891            if ( isset($column['options']) )
    18931892                $c[$k]['options'] = wp_parse_args( $column['options'], $defaults['options']);
    1894                
     1893
    18951894            // set type label
    18961895            if ( empty($column['options']['type_label']) && !empty($column['label']) )
    18971896                $c[$k]['options']['type_label'] = $column['label'];
    18981897        }
    1899        
     1898
    19001899        return $c;
    19011900    }
     
    19071906     */
    19081907    public static function get_stored_columns($type)
    1909     { 
     1908    {
    19101909        // get plugin options
    19111910        $options        = get_option('cpac_options');
     
    19141913        if ( !empty($options['columns'][$type]) )
    19151914            return $options['columns'][$type];
    1916        
     1915
    19171916        return false;
    19181917    }
     
    19231922     * @since     1.0
    19241923     */
    1925     private function get_menu() 
     1924    private function get_menu()
    19261925    {
    19271926        // set
    19281927        $menu   = '';
    19291928        $count  = 1;
    1930        
     1929
    19311930        // referer
    19321931        $referer = ! empty($_REQUEST['cpac_type']) ? $_REQUEST['cpac_type'] : '';
    1933            
     1932
    19341933        // loop
    19351934        foreach ( $this->get_types() as $type ) {
    19361935            $label       = $this->get_singular_name($type);
    19371936            $clean_label = $this->sanitize_string($type);
    1938            
     1937
    19391938            // divider
    19401939            $divider    = $count++ == 1 ? '' : ' | ';
    1941            
    1942             // current     
     1940
     1941            // current
    19431942            $current = '';
    19441943            if ( $this->is_menu_type_current($type) )
    19451944                $current = ' class="current"';
    1946            
     1945
    19471946            // menu list
    19481947            $menu .= "
     
    19501949            ";
    19511950        }
    1952        
     1951
    19531952        // settings url
    19541953        $class_current_settings = $this->is_menu_type_current('plugin_settings') ? ' current': '';
    1955        
     1954
    19561955        // options button
    19571956        $options_btn = "<a href='#cpac-box-plugin_settings' class='cpac-settings-link{$class_current_settings}'>".__('Addons', CPAC_TEXTDOMAIN)."</a>";
    19581957        //$options_btn = '';
    1959        
     1958
    19601959        return "
    19611960        <div class='cpac-menu'>
     
    19731972     * @since     1.0
    19741973     */
    1975     private function is_menu_type_current( $type ) 
    1976     {   
     1974    private function is_menu_type_current( $type )
     1975    {
    19771976        // referer
    19781977        $referer = ! empty($_REQUEST['cpac_type']) ? $_REQUEST['cpac_type'] : '';
    1979        
     1978
    19801979        // get label
    19811980        $clean_label = $this->sanitize_string($type);
    1982        
     1981
    19831982        // get first element from post-types
    19841983        $first      = array_shift( array_values($this->post_types) );
    1985        
     1984
    19861985        // display the page that was being viewed before saving
    19871986        if ( $referer ) {
     
    19891988                return true;
    19901989            }
    1991        
     1990
    19921991        // settings page has not yet been saved
    19931992        } elseif ( $first == $type  ) {
    19941993            return true;
    19951994        }
    1996        
    1997         return false;   
     1995
     1996        return false;
    19981997    }
    19991998
     
    20032002     * @since     1.0
    20042003     */
    2005     private function get_singular_name( $type ) 
     2004    private function get_singular_name( $type )
    20062005    {
    20072006        // Links
    20082007        if ( $type == 'wp-links' )
    20092008            $label = __('Links');
    2010            
     2009
    20112010        // Comments
    20122011        elseif ( $type == 'wp-comments' )
    20132012            $label = __('Comments');
    2014            
     2013
    20152014        // Users
    20162015        elseif ( $type == 'wp-users' )
    20172016            $label = __('Users');
    2018        
     2017
    20192018        // Media
    20202019        elseif ( $type == 'wp-media' )
    20212020            $label = __('Media Library');
    2022        
     2021
    20232022        // Posts
    20242023        else {
     
    20262025            $label          = $posttype_obj->labels->singular_name;
    20272026        }
    2028        
     2027
    20292028        return $label;
    20302029    }
    2031    
     2030
    20322031    /**
    20332032     * Get plural name of post type
     
    20352034     * @since     1.3.1
    20362035     */
    2037     private function get_plural_name( $type ) 
     2036    private function get_plural_name( $type )
    20382037    {
    20392038        $posttype_obj = get_post_type_object($type);
    20402039        if ( $posttype_obj )
    20412040            return $posttype_obj->labels->name;
    2042        
     2041
    20432042        return false;
    20442043    }
    2045    
     2044
    20462045    /**
    20472046     * Get screen link to overview screen
     
    20492048     * @since     1.3.1
    20502049     */
    2051     private function get_type_screen_link( $type ) 
    2052     {       
     2050    private function get_type_screen_link( $type )
     2051    {
    20532052        // Links
    20542053        if ( $type == 'wp-comments' )
    20552054            $link = get_admin_url() . 'edit-comments.php';
    2056            
     2055
    20572056            // Links
    20582057        if ( $type == 'wp-links' )
    20592058            $link = get_admin_url() . 'link-manager.php';
    2060        
     2059
    20612060        // Users
    20622061        if ( $type == 'wp-users' )
    20632062            $link = get_admin_url() . 'users.php';
    2064        
     2063
    20652064        // Media
    20662065        elseif ( $type == 'wp-media' )
    20672066            $link = get_admin_url() . 'upload.php';
    2068        
     2067
    20692068        // Posts
    2070         else   
    2071             $link = get_admin_url() . "edit.php?post_type={$type}";     
    2072                
     2069        else
     2070            $link = get_admin_url() . "edit.php?post_type={$type}";
     2071
    20732072        return $link;
    20742073    }
     
    20812080     * @since     1.0
    20822081     */
    2083     protected function sanitize_string($string) 
    2084     {   
     2082    protected function sanitize_string($string)
     2083    {
    20852084        $string = esc_url($string);
    20862085        $string = str_replace('http://','', $string);
    20872086        $string = str_replace('https://','', $string);
    2088        
     2087
    20892088        return $string;
    20902089    }
    2091    
     2090
    20922091    /**
    20932092     * Checks if column-meta key exists
     
    20952094     * @since     1.0
    20962095     */
    2097     public static function is_column_meta( $id = '' ) 
     2096    public static function is_column_meta( $id = '' )
    20982097    {
    20992098        if ( strpos($id, 'column-meta-') !== false )
    21002099            return true;
    2101        
     2100
    21022101        return false;
    21032102    }
    2104    
     2103
    21052104    /**
    21062105     * Get the posttype from columnname
     
    21082107     * @since     1.3.1
    21092108     */
    2110     public static function get_posttype_by_postcount_column( $id = '' ) 
    2111     {
    2112         if ( strpos($id, 'column-user_postcount-') !== false )         
     2109    public static function get_posttype_by_postcount_column( $id = '' )
     2110    {
     2111        if ( strpos($id, 'column-user_postcount-') !== false )
    21132112            return str_replace('column-user_postcount-', '', $id);
    2114                
     2113
    21152114        return false;
    21162115    }
    2117    
     2116
    21182117    /**
    21192118     *  Get column value of post attachments
     
    21212120     *  @since     1.2.1
    21222121     */
    2123     public static function get_attachment_ids( $post_id ) 
     2122    public static function get_attachment_ids( $post_id )
    21242123    {
    21252124        return get_posts(array(
     
    21312130        ));
    21322131    }
    2133    
     2132
    21342133    /**
    21352134     * Strip tags and trim
     
    21372136     * @since     1.3
    21382137     */
    2139     public static function strip_trim($string) 
     2138    public static function strip_trim($string)
    21402139    {
    21412140        return trim(strip_tags($string));
    21422141    }
    2143    
     2142
    21442143    /**
    21452144     * Admin body class
     
    21472146     * @since     1.4
    21482147     */
    2149     function admin_class( $classes ) 
    2150     {       
     2148    function admin_class( $classes )
     2149    {
    21512150        global $current_screen;
    2152        
     2151
    21532152        // we dont need the 'edit-' part
    21542153        $screen = str_replace('edit-', '', $current_screen->id);
    2155        
     2154
    21562155        // media library exception
    21572156        if ( $current_screen->base == 'upload' && $current_screen->id == 'upload' ) {
    21582157            $screen = 'media';
    21592158        }
    2160        
     2159
    21612160        // link exception
    21622161        if ( $current_screen->base == 'link-manager' && $current_screen->id == 'link-manager' ) {
     
    21652164
    21662165        // loop the available types
    2167         foreach ( $this->get_types() as $type => $label ) {         
    2168            
     2166        foreach ( $this->get_types() as $type => $label ) {
     2167
    21692168            // match against screen or wp-screen
    21702169            if ( $type == $screen || $type == "wp-{$screen}" )
     
    21752174    }
    21762175
    2177    
     2176
    21782177    /**
    21792178     * Admin CSS for Column width
     
    21812180     * @since     1.4
    21822181     */
    2183     function admin_css() 
    2184     {   
     2182    function admin_css()
     2183    {
    21852184        $css = '';
    2186        
     2185
    21872186        // loop throug the available types...
    21882187        foreach ( $this->get_types() as $type ) {
    2189             $cols = self::get_stored_columns($type);   
     2188            $cols = self::get_stored_columns($type);
    21902189            if ( $cols ) {
    2191            
     2190
    21922191                // loop through each available column...
    21932192                foreach ( $cols as $col_name => $col ) {
    2194                
     2193
    21952194                    // and check for stored width and add it to the css
    21962195                    if (!empty($col['width']) && is_numeric($col['width']) && $col['width'] > 0 ) {
     
    22002199            }
    22012200        }
    2202        
     2201
    22032202        echo "<style type='text/css'>{$css}</style>";
    22042203    }
    2205    
     2204
    22062205    /**
    22072206     * Ajax activation
     
    22142213        $key    = $_POST['key'];
    22152214        $type   = $_POST['type'];
    2216        
     2215
    22172216        $licence = new cpac_licence( $type );
    2218        
     2217
    22192218        // update key
    22202219        if ( $key == 'remove' ) {
    22212220            $licence->remove_license_key();
    22222221        }
    2223            
     2222
    22242223        // set license key
    22252224        elseif ( $licence->check_remote_key( $key ) ) {
    2226        
     2225
    22272226            // set key
    22282227            $licence->set_license_key( $key );
    2229            
     2228
    22302229            // returned masked key
    22312230            echo json_encode( $licence->get_masked_license_key() );
     
    22342233        exit;
    22352234    }
    2236    
     2235
    22372236    /**
    22382237     * Add help tabs
     
    22402239     * @since     1.3
    22412240     */
    2242     public function help_tabs($page) 
    2243     {       
     2241    public function help_tabs($page)
     2242    {
    22442243        $screen = get_current_screen();
    22452244
    22462245        if ( $screen->id != $this->admin_page || ! method_exists($screen,'add_help_tab') )
    22472246            return;
    2248        
     2247
    22492248        $admin_url = get_admin_url();
    2250        
     2249
    22512250        // add help content
    22522251        $tabs = array(
     
    22572256                    <p>
    22582257                        This plugin is for adding and removing additional columns to the administration screens for post(types), pages, media library, comments, links and users. Change the column's label and reorder them.
    2259                     </p>   
    2260                    
     2258                    </p>
     2259
    22612260                "
    22622261            ),
     
    23002299                    </ul>
    23012300                "
    2302             )           
     2301            )
    23032302        );
    2304        
     2303
    23052304        foreach ( $tabs as $k => $tab ) {
    2306             $screen->add_help_tab(array(               
     2305            $screen->add_help_tab(array(
    23072306                'id'        => 'cpac-tab-'.$k,  // unique id
    23082307                'title'     => $tab['title'],   // label
     
    23112310        }
    23122311    }
    2313    
     2312
    23142313    /**
    23152314     * Plugin Settings
     
    23172316     * @since     1.3.1
    23182317     */
    2319     private function plugin_settings() 
     2318    private function plugin_settings()
    23202319    {
    23212320        $class_current_settings = $this->is_menu_type_current('plugin_settings') ? ' current' : ' hidden'; '';
    2322        
     2321
    23232322        /** Sortable */
    23242323        $masked_key                 = '';
    23252324        $class_sortorder_activate   = '';
    23262325        $class_sortorder_deactivate = ' hidden';
    2327        
     2326
    23282327        // is unlocked
    23292328        $licence = new cpac_licence('sortable');
    2330        
     2329
    23312330        if ( $licence->is_unlocked() ) {
    23322331            $masked_key      = $licence->get_masked_license_key('sortable');
     
    23342333            $class_sortorder_deactivate = '';
    23352334        }
    2336        
     2335
    23372336        // find out more
    23382337        $find_out_more = "<a href='{$this->codepress_url}/sortorder-addon/' class='button-primary alignright' target='_blank'>".__('find out more', CPAC_TEXTDOMAIN)." &raquo</a>";
    2339        
     2338
    23402339        // info box
    23412340        $sortable_tooltip = "
     
    23432342            <p>".__('By default WordPress let\'s you sort by title, date, comments and author. This will make you be able to <strong>sort by any column of any type!</strong>', CPAC_TEXTDOMAIN)."</p>
    23442343            <p>".__('Perfect for sorting your articles, media files, comments, links and users', CPAC_TEXTDOMAIN).".</p>
    2345             <p class='description'>".__('(columns that are added by other plugins are not supported)', CPAC_TEXTDOMAIN).".</p>         
     2344            <p class='description'>".__('(columns that are added by other plugins are not supported)', CPAC_TEXTDOMAIN).".</p>
    23462345            <img src='" . CPAC_URL.'/assets/images/addon_sortable_1.png' . "' alt='' />
    23472346            {$find_out_more}
    23482347        ";
    2349        
    2350         // addons 
     2348
     2349        // addons
    23512350        $addons = "
    23522351            <tr>
     
    23952394                                <td class='activation_more'>{$find_out_more}</td>
    23962395                            </tr><!-- #cpac-activation-sortable -->
    2397                         </tbody>                   
     2396                        </tbody>
    23982397                    </table>
    23992398                    <div class='addon-translation-string hidden'>
     
    24042403            </tr>
    24052404        ";
    2406                
     2405
    24072406        // general options
    24082407        $general_options = "
     
    24142413                        <li>
    24152414                            <div class='cpac-option-label'>Thumbnail size</div>
    2416                             <div class='cpac-option-inputs'>                                       
     2415                            <div class='cpac-option-inputs'>
    24172416                                <input type='text' id='thumbnail_size_w' class='small-text' name='cpac_options[settings][thumb_width]' value='80'/>
    24182417                                <label for='thumbnail_size_w'>Width</label>
    2419                                 <br/>                                       
     2418                                <br/>
    24202419                                <input type='text' id='thumbnail_size_h' class='small-text' name='cpac_options[settings][thumb_height]' value='80'/>
    24212420                                <label for='thumbnail_size_h'>Height</label>
     
    24242423                        <li>
    24252424                            <div class='cpac-option-label'>Excerpt length</div>
    2426                             <div class='cpac-option-inputs'>                                       
    2427                                
     2425                            <div class='cpac-option-inputs'>
     2426
    24282427                                <input type='text' id='excerpt_length' class='small-text' name='cpac_options[settings][excerpt_length]' value='15'/>
    24292428                                <label for='excerpt_length'>Number of words</label>
    24302429                            </div>
    24312430                        </li>
    2432                     </ul>                       
     2431                    </ul>
    24332432                </td>
    24342433            </tr>
    24352434            -->
    24362435        ";
    2437        
     2436
    24382437        // settings
    24392438        $row = "
     
    24412440            <td colspan='2'>
    24422441                <table class='nopadding'>
    2443                     {$addons}                   
     2442                    {$addons}
    24442443                    {$general_options}
    24452444                </table>
     
    24472446        </tr><!-- #cpac-box-plugin_settings -->
    24482447        ";
    2449        
     2448
    24502449        return $row;
    24512450    }
    2452    
     2451
    24532452    /**
    24542453     *  Get post count
     
    24592458    {
    24602459        global $wpdb;
    2461        
     2460
    24622461        if ( ! post_type_exists($post_type) || empty($user_id) )
    24632462            return false;
    2464        
     2463
    24652464        $sql = "
    24662465            SELECT COUNT(ID)
     
    24702469            AND post_type = %s
    24712470        ";
    2472        
     2471
    24732472        return $wpdb->get_var( $wpdb->prepare($sql, $user_id, $post_type) );
    24742473    }
    2475    
     2474
    24762475    /**
    24772476     * Settings Page Template.
     
    24792478     * This function in conjunction with others uses the WordPress
    24802479     * Settings API to create a settings page where users can adjust
    2481      * the behaviour of this plugin. 
    2482      *
    2483      * @since     1.0
    2484      */
    2485     public function plugin_settings_page() 
     2480     * the behaviour of this plugin.
     2481     *
     2482     * @since     1.0
     2483     */
     2484    public function plugin_settings_page()
    24862485    {
    24872486        // loop through post types
    24882487        $rows = '';
    24892488        foreach ( $this->get_types() as $type ) {
    2490            
     2489
    24912490            // post type label
    24922491            $label = $this->get_singular_name($type);
    2493            
     2492
    24942493            // id
    2495             $id = $this->sanitize_string($type); 
    2496            
     2494            $id = $this->sanitize_string($type);
     2495
    24972496            // build draggable boxes
    24982497            $boxes = $this->get_column_boxes($type);
     
    25002499            // class
    25012500            $class = $this->is_menu_type_current($type) ? ' current' : ' hidden';
    2502            
     2501
    25032502            $rows .= "
    25042503                <tr id='cpac-box-{$id}' valign='top' class='cpac-box-row{$class}'>
     
    25082507                    <td>
    25092508                        <h3 class='cpac_post_type hidden'>{$label}</h3>
    2510                         {$boxes}                       
     2509                        {$boxes}
    25112510                    </td>
    25122511                </tr>
    25132512            ";
    25142513        }
    2515        
     2514
    25162515        // General Setttings
    25172516        $general_settings = $this->plugin_settings();
    2518        
     2517
    25192518        // Post Type Menu
    25202519        $menu = $this->get_menu();
    2521        
     2520
    25222521        // Help screen message
    25232522        $help_text = '';
    25242523        if ( version_compare( get_bloginfo('version'), '3.2', '>' ) )
    25252524            $help_text = '<p>'.__('You will find a short overview at the <strong>Help</strong> section in the top-right screen.', CPAC_TEXTDOMAIN).'</p>';
    2526        
     2525
    25272526        // find out more
    25282527        $find_out_more = "<a href='{$this->codepress_url}/sortorder-addon/' class='alignright green' target='_blank'>".__('find out more', CPAC_TEXTDOMAIN)." &raquo</a>";
    2529        
     2528
    25302529    ?>
    25312530        <div id="cpac" class="wrap">
     
    25332532            <h2><?php _e('Codepress Admin Columns', CPAC_TEXTDOMAIN); ?></h2>
    25342533            <?php echo $menu ?>
    2535            
     2534
    25362535            <div class="postbox-container cpac-col-right">
    2537                 <div class="metabox-holder">   
    2538                     <div class="meta-box-sortables">                       
    2539                        
     2536                <div class="metabox-holder">
     2537                    <div class="meta-box-sortables">
     2538
    25402539                        <div id="addons-cpac-settings" class="postbox">
    25412540                            <div title="Click to toggle" class="handlediv"><br></div>
     
    25502549                            </div>
    25512550                        </div><!-- addons-cpac-settings -->
    2552                                                
     2551
    25532552                        <div id="likethisplugin-cpac-settings" class="postbox">
    25542553                            <div title="Click to toggle" class="handlediv"><br></div>
     
    25602559                                <ul>
    25612560                                    <li><a href="<?php echo $this->plugins_url ?>"><?php _e('Give it a 5 star rating on WordPress.org.', CPAC_TEXTDOMAIN) ?></a></li>
    2562                                     <li><a href="<?php echo $this->codepress_url ?>/"><?php _e('Link to it so other folks can find out about it.', CPAC_TEXTDOMAIN) ?></a></li>                                 
     2561                                    <li><a href="<?php echo $this->codepress_url ?>/"><?php _e('Link to it so other folks can find out about it.', CPAC_TEXTDOMAIN) ?></a></li>
    25632562                                    <li class="donate_link"><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZDZRSYLQ4Z76J"><?php _e('Donate a token of your appreciation.', CPAC_TEXTDOMAIN) ?></a></li>
    2564                                 </ul>                               
     2563                                </ul>
    25652564                            </div>
    25662565                        </div><!-- likethisplugin-cpac-settings -->
    2567                        
     2566
    25682567                        <div id="latest-news-cpac-settings" class="postbox">
    25692568                            <div title="Click to toggle" class="handlediv"><br></div>
     
    25712570                                <span><?php _e('Follow us', CPAC_TEXTDOMAIN) ?></span>
    25722571                            </h3>
    2573                             <div class="inside">                               
     2572                            <div class="inside">
    25742573                                <ul>
    25752574                                    <li class="twitter"><a href="http://twitter.com/codepressNL"><?php _e('Follow Codepress on Twitter.', CPAC_TEXTDOMAIN) ?></a></li>
    25762575                                    <li class="facebook"><a href="https://www.facebook.com/codepressNL"><?php _e('Like Codepress on Facebook.', CPAC_TEXTDOMAIN) ?></a></li>
    2577                        
    2578                                 </ul>                               
     2576
     2577                                </ul>
    25792578                            </div>
    25802579                        </div><!-- latest-news-cpac-settings -->
    2581                        
     2580
    25822581                        <div id="side-cpac-settings" class="postbox">
    25832582                            <div title="Click to toggle" class="handlediv"><br></div>
     
    25852584                                <span><?php _e('Need support?', CPAC_TEXTDOMAIN) ?></span>
    25862585                            </h3>
    2587                             <div class="inside">                               
     2586                            <div class="inside">
    25882587                                <?php echo $help_text ?>
    25892588                                <p><?php printf(__('If you are having problems with this plugin, please talk about them in the <a href="%s">Support forums</a> or send me an email %s.', CPAC_TEXTDOMAIN), $this->wordpress_url, '<a href="mailto:[email protected]">[email protected]</a>' );?></p>
     
    25912590                            </div>
    25922591                        </div><!-- side-cpac-settings -->
    2593                    
     2592
    25942593                    </div>
    25952594                </div>
    25962595            </div><!-- .postbox-container -->
    2597            
     2596
    25982597            <div class="postbox-container cpac-col-left">
    2599                 <div class="metabox-holder">   
     2598                <div class="metabox-holder">
    26002599                    <div class="meta-box-sortables">
    2601                    
     2600
    26022601                        <div id="general-cpac-settings" class="postbox">
    26032602                            <div title="Click to toggle" class="handlediv"><br></div>
     
    26072606                            <div class="inside">
    26082607                                <form method="post" action="options.php">
    2609                                
     2608
    26102609                                <?php settings_fields( 'cpac-settings-group' ); ?>
    2611                                
     2610
    26122611                                <table class="form-table">
    26132612                                    <!-- columns -->
    2614                                     <?php echo $rows; ?>                               
    2615                                    
     2613                                    <?php echo $rows; ?>
     2614
    26162615                                    <!-- activation -->
    26172616                                    <?php echo $general_settings; ?>
    2618                                    
     2617
    26192618                                    <tr class="bottom" valign="top">
    26202619                                        <th scope="row"></th>
     
    26242623                                            </p>
    26252624                                        </td>
    2626                                     </tr>               
    2627                                 </table>           
    2628                                 </form>                     
    2629                             </div>                     
     2625                                    </tr>
     2626                                </table>
     2627                                </form>
     2628                            </div>
    26302629                        </div><!-- general-settings -->
    2631                        
     2630
    26322631                        <div id="restore-cpac-settings" class="postbox">
    26332632                            <div title="Click to toggle" class="handlediv"><br></div>
     
    26362635                            </h3>
    26372636                            <div class="inside">
    2638                                 <form method="post" action="">                 
     2637                                <form method="post" action="">
    26392638                                    <input type="submit" class="button" name="cpac-restore-defaults" value="<?php _e('Restore default settings', CPAC_TEXTDOMAIN ) ?>" onclick="return confirm('<?php _e("Warning! ALL saved admin columns data will be deleted. This cannot be undone. \'OK\' to delete, \'Cancel\' to stop", CPAC_TEXTDOMAIN); ?>');" />
    26402639                                </form>
     
    26422641                            </div>
    26432642                        </div><!-- restore-cpac-settings -->
    2644                    
     2643
    26452644                    </div>
    26462645                </div>
    2647             </div><!-- .postbox-container -->           
     2646            </div><!-- .postbox-container -->
    26482647        </div>
    26492648    <?php
  • codepress-admin-columns/trunk/readme.txt

    r637684 r638877  
    55Requires at least: 3.1
    66Tested up to: 3.5
    7 Stable tag: 1.4.8
     7Stable tag: 1.4.9
    88
    99Customise columns on the administration screens for post(types), pages, media, comments, links and users with an easy to use drag-and-drop interface.
     
    1111== Description ==
    1212
    13 Completely customise the columns on the administration screens with a nice drag and drop interface. 
    14 
    15 By default, WordPress only shows a few built-in columns. This plugin will give you many additional columns. You will have full control over all columns for pages, posts, posttypes, media, links, comments and users. 
     13Completely customise the columns on the administration screens with a nice drag and drop interface.
     14
     15By default, WordPress only shows a few built-in columns. This plugin will give you many additional columns. You will have full control over all columns for pages, posts, posttypes, media, links, comments and users.
    1616
    1717Add or remove columns, change their label, change their width and reorder them.
     
    3535* Status
    3636* Number of Attachments
    37 * Last Modified 
     37* Last Modified
    3838* Comment count
    3939* Before More Tag Content
     
    114114It will work nice with other plugins and support their additional custom columns. A few examples of plugins that are supported: WordPress SEO by Yoast (Robots Meta), Post Admin Shortcuts (Pin), WP Show IDs (ID) and User Access Manager (Access), Co-Authors Plus and Advanced Custom Fields.
    115115
    116 = Translations = 
     116= Translations =
    117117
    118118If you like to contrinute a language, please send them to <a href="mailto:[email protected]">[email protected]</a>.
     
    165165add_image_size( 'admin-columns', $my_width, $my_height, true );
    166166add_filter('cpac_thumbnail_size', 'cb_cpac_thumbnail_size' );
    167 function cb_cpac_thumbnail_size() { 
     167function cb_cpac_thumbnail_size() {
    168168    return 'admin-columns';
    169169};
     
    219219    $my_post_type  = 'demo';
    220220    $my_field_name = 'city';
    221    
     221
    222222    // make sure we have the correct posttype and fieldname
    223223    if ( $my_post_type == $type && $my_field_name == $custom_field ) {
    224        
     224
    225225        if ( '33' == $value )
    226226            $value = 'Amsterdam';
    227        
     227
    228228        elseif ( '34' == $value )
    229             $value = 'New York';   
     229            $value = 'New York';
    230230    }
    231     return $value; 
     231    return $value;
    232232}
    233233add_filter( 'cpac_get_column_value_custom_field', 'my_custom_field_value', 10, 5 );
     
    246246
    247247== Changelog ==
     248
     249= 1.4.9
     250* fixed bug: thirdparty columns that were previous loaded through load-edit.php will now use do_action( 'cpac-get-default-columns-{$type}' )
    248251
    249252= 1.4.8 =
Note: See TracChangeset for help on using the changeset viewer.