WordPress.org

Plugin Directory

Changeset 539747


Ignore:
Timestamp:
05/04/12 01:24:55 (2 years ago)
Author:
brasofilo
Message:
 
Location:
featured-link-image
Files:
17 added
2 edited

Legend:

Unmodified
Added
Removed
  • featured-link-image/trunk/featured-link-image.php

    r537405 r539747  
    88Author: Rodolfo Buaiz 
    99Author URI: http://rodbuaiz.com/ 
    10 Stable Tag: 1.0 
    11 Version: 1.0 
     10Stable Tag: 1.1 
     11Version: 1.1 
    1212License: GPL 
    1313*/ 
     
    2929    add_action('load-link.php', 'brsfl_call_bookmarkImageMetaBox'); 
    3030    add_action('admin_head', 'brsfl_make_wpAdminHead'); 
     31    add_filter('get_bookmarks','brsfl_link_manager_order'); 
     32    add_action('admin_footer-link-manager.php', 'brsfl_link_add_style'); 
    3133} 
    3234 
     
    3941 
    4042    /* TODO: THE 'REQUEST' IS NOT WORKING FOR LINK-MANAGER.PHP */ 
    41     //  add_filter( 'request', 'brsfl_thumb_column_orderby' ); 
    42     //  add_filter( 'manage_link-manager_sortable_columns', 'brsfl_thumb_column_register_sortable' ); 
     43    add_filter( 'request', 'brsfl_thumb_column_orderby' ); 
     44    add_filter( 'manage_link-manager_sortable_columns', 'brsfl_thumb_column_register_sortable' ); 
    4345} 
    4446 
     
    8688 
    8789 
     90/* 
     91 * Insert $in item in position $pos inside the $src array 
     92 */ 
     93function brsfl_arrayPushAfter($src, $in, $pos) { 
     94    if (is_int($pos)) $R = array_merge(array_slice($src, 0, $pos + 1), $in, array_slice($src, $pos + 1)); 
     95    else { 
     96        foreach ($src as $k => $v) { 
     97            $R[$k] = $v; 
     98            if ($k == $pos) $R = array_merge($R, $in); 
     99        } 
     100    } 
     101    return $R; 
     102} 
     103 
     104/* 
     105 * Sort multidimensional array by stdClass 
     106 */ 
     107function sort_on_field(&$objects, $on, $order = 'ASC') { 
     108    $comparer = ($order === 'DESC') 
     109        ? "return -strcmp(\$a->{$on},\$b->{$on});" 
     110        : "return strcmp(\$a->{$on},\$b->{$on});"; 
     111    usort($objects, create_function('$a,$b', $comparer)); 
     112} 
    88113 
    89114/** 
     
    91116 */ 
    92117function brsfl_add_link_id_column($link_columns) { 
    93     $link_columns['thumbnail'] = __('Thumbnail', 'fli'); 
     118    $in                         = array("link_id" => "ID"); 
     119    $link_columns               = brsfl_arrayPushAfter($link_columns, $in, 0); 
     120    $link_columns['thumbnail']  = __('Thumbnail', 'fli'); 
    94121 
    95122    return $link_columns; 
     
    102129        echo $img; 
    103130    } 
     131    if ($column_name == 'link_id') { 
     132        $val = get_bookmark_field( 'link_id', $id); 
     133        echo $val; 
     134    } 
    104135} 
    105136 
    106137function brsfl_thumb_column_register_sortable( $columns ) { 
    107     $columns['thumbnail'] = 'thumbnail'; 
    108  
     138    $columns['thumbnail'] = 'link_image'; 
     139    $columns['link_id'] = 'link_id'; 
    109140    return $columns; 
    110141} 
     
    121152} 
    122153 
    123  
     154function brsfl_link_manager_order($links) { 
     155    global $current_screen; 
     156    if($current_screen->id == 'link-manager' && $_GET['orderby'] == 'link_image') 
     157    { 
     158        $order = ($_GET['order'] === 'asc') ? 'ASC' : 'DESC'; 
     159        sort_on_field($links, 'link_image', $order); 
     160        return $links; 
     161    } else return $links; 
     162} 
     163 
     164function brsfl_link_add_style() { 
     165    echo '<style>#link_id { width:4%; } #thumbnail { max-width:20%; }</style>'; 
     166} 
    124167 
    125168 
  • featured-link-image/trunk/readme.txt

    r537525 r539747  
    22Tags: image, featured image, links, media library, bookmarks, blogroll 
    33Requires at least: 3.1 
    4 Tested up to: 3.4-beta3 
    5 Stable tag: 1.0 
     4Tested up to: 3.4-beta4 
     5Stable tag: 1.1 
    66Contributors: brasofilo 
    77 
     
    3535 
    3636== Changelog == 
     37**Version 1.1 
     38 
     39* Added the ID column in the Links page, and sort by ID and Thumbnail 
     40 
    3741**Version 1.0 
    3842 
Note: See TracChangeset for help on using the changeset viewer.