Plugin Directory

Changeset 700584


Ignore:
Timestamp:
04/20/2013 05:01:45 AM (13 years ago)
Author:
kobenland
Message:

Changes for 1.2.0

Location:
wp-last-login/trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • wp-last-login/trunk/obenland-wp-plugins.php

    r525795 r700584  
    22/** obenland-wp-plugins.php
    33 *
    4  * @author      Konstantin Obenland
    5  * @version     1.5
     4 * @author  Konstantin Obenland
     5 * @version 3.0.1
    66 */
    77
    88
    9 class Obenland_Wp_Plugins_v15 {
    10 
     9class Obenland_Wp_Plugins_v301 {
    1110
    1211    /////////////////////////////////////////////////////////////////////////////
     
    1514
    1615    /**
    17      * The plugins' text domain
    18      *
    19      * @author  Konstantin Obenland
    20      * @since   1.1 - 03.04.2011
    21      * @access  protected
    22      *
    23      * @var     string
     16     * The plugins' text domain.
     17     *
     18     * @author Konstantin Obenland
     19     * @since  1.1 - 03.04.2011
     20     * @access protected
     21     *
     22     * @var    string
    2423     */
    2524    protected $textdomain;
     
    2726
    2827    /**
    29      * The name of the calling plugin
    30      *
    31      * @author  Konstantin Obenland
    32      * @since   1.0 - 23.03.2011
    33      * @access  protected
    34      *
    35      * @var     string
     28     * The name of the calling plugin.
     29     *
     30     * @author Konstantin Obenland
     31     * @since  1.0 - 23.03.2011
     32     * @access protected
     33     *
     34     * @var    string
    3635     */
    3736    protected $plugin_name;
     
    3938
    4039    /**
    41      * The donate link for the plugin
    42      *
    43      * @author  Konstantin Obenland
    44      * @since   1.0 - 23.03.2011
    45      * @access  protected
    46      *
    47      * @var     string
     40     * The donate link for the plugin.
     41     *
     42     * @author Konstantin Obenland
     43     * @since  1.0 - 23.03.2011
     44     * @access protected
     45     *
     46     * @var    string
    4847     */
    4948    protected $donate_link;
     
    5150
    5251    /**
    53      * The path to the plugin folder
     52     * The path to the plugin file.
     53     *
     54     * /path/to/wp-content/plugins/{plugin-name}/{plugin-name}.php
     55     *
     56     * @author Konstantin Obenland
     57     * @since  2.0.0 - 30.05.2012
     58     * @access protected
     59     *
     60     * @var    string
     61     */
     62    protected $plugin_path;
     63
     64
     65    /**
     66     * The path to the plugin directory.
    5467     *
    5568     * /path/to/wp-content/plugins/{plugin-name}/
    5669     *
    57      * @author  Konstantin Obenland
    58      * @since   1.2 - 21.04.2011
    59      * @access  protected
    60      *
    61      * @var     string
    62      */
    63     protected $plugin_path;
     70     * @author Konstantin Obenland
     71     * @since  1.2 - 21.04.2011
     72     * @access protected
     73     *
     74     * @var    string
     75     */
     76    protected $plugin_dir_path;
    6477
    6578
     
    7184     * Constructor
    7285     *
    73      * @author  Konstantin Obenland
    74      * @since   1.0 - 23.03.2011
    75      * @access  public
    76      *
    77      * @param   array   $args   Expects three keys: 'textdomain', 'plugin_path', 'donate_link_id'
    78      *
    79      * @return  Obenland_Wp_Plugins
     86     * @author Konstantin Obenland
     87     * @since  1.0 - 23.03.2011
     88     * @access public
     89     *
     90     * @param  string $plugin_name
     91     * @param  string $donate_link_id
     92     *
     93     * @return Obenland_Wp_Plugins
    8094     */
    8195    public function __construct( $args = array() ) {
    8296
    8397        // Set class properties
    84         $this->textdomain   =   $args['textdomain'];
    85         $this->plugin_path  =   plugin_dir_path( $args['plugin_path'] );
    86         $this->plugin_name  =   plugin_basename( $args['plugin_path'] );
     98        $this->textdomain      = $args['textdomain'];
     99        $this->plugin_path     = $args['plugin_path'];
     100        $this->plugin_dir_path = plugin_dir_path( $args['plugin_path'] );
     101        $this->plugin_name     = plugin_basename( $args['plugin_path'] );
     102
     103        load_plugin_textdomain( 'obenland-wp', false, $this->textdomain . '/lang' );
    87104
    88105        $this->set_donate_link( $args['donate_link_id'] );
    89 
    90         // Add actions and filters
     106        $this->hook( 'plugins_loaded', 'parent_plugins_loaded' );
     107    }
     108
     109
     110    /**
     111     * Hooks in all the hooks :)
     112     *
     113     * @author Konstantin Obenland
     114     * @since  2.0.0 - 12.04.2012
     115     * @access public
     116     *
     117     * @return void
     118     */
     119    public function parent_plugins_loaded() {
    91120        $this->hook( 'plugin_row_meta' );
    92     }
    93 
    94 
    95     /**
    96      *
    97      * @author  Konstantin Obenland
    98      * @since   1.0 - 23.03.2011
    99      * @access  public
    100      *
    101      * @param   array   $plugin_meta
    102      * @param   string  $plugin_file
    103      *
    104      * @return  string
     121        if ( ! has_action( 'obenland_side_info_column' ) ) {
     122            $this->hook( 'obenland_side_info_column', 'donate_box', 1 );
     123            $this->hook( 'obenland_side_info_column', 'feed_box'      );
     124        }
     125    }
     126
     127
     128    /**
     129     *
     130     * @author Konstantin Obenland
     131     * @since  1.0 - 23.03.2011
     132     * @access public
     133     *
     134     * @param  array  $plugin_meta
     135     * @param  string $plugin_file
     136     *
     137     * @return string
    105138     */
    106139    public function plugin_row_meta( $plugin_meta, $plugin_file ) {
    107140        if ( $this->plugin_name == $plugin_file ) {
    108             $plugin_meta[]  =   sprintf('
    109                 <a href="%1$s" target="_blank" title="%2$s">%2$s</a>',
     141            $plugin_meta[] = sprintf(
     142                '<a href="%1$s" target="_blank" title="%2$s">%2$s</a>',
    110143                $this->donate_link,
    111                 __('Donate', $this->textdomain)
     144                __( 'Donate', 'obenland-wp' )
    112145            );
    113146        }
     
    116149
    117150
     151    /**
     152     * Displays a box with a donate button and call to action links.
     153     *
     154     * Props Joost de Valk, as this is almost entirely from his awesome WordPress
     155     * SEO Plugin.
     156     * @see    http://plugins.svn.wordpress.org/wordpress-seo/tags/1.1.5/admin/class-config.php
     157     *
     158     * @author Joost de Valk, Konstantin Obenland
     159     * @since  2.0.0 - 31.03.2012
     160     * @access public
     161     *
     162     * @return void
     163     */
     164    public function donate_box() {
     165        $plugin_data = get_plugin_data( $this->plugin_path );
     166        ?>
     167        <div id="formatdiv" class="postbox">
     168            <h3 class="hndle"><span><?php esc_html_e( 'Help spread the word!', 'obenland-wp' ); ?></span></h3>
     169            <div class="inside">
     170                <p><strong><?php printf( _x( 'Want to help make this plugin even better? All donations are used to improve %1$s, so donate $20, $50 or $100 now!', 'Plugin Name', 'obenland-wp' ), esc_html($plugin_data['Name']) ); ?></strong></p>
     171                <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
     172                    <input type="hidden" name="cmd" value="_s-xclick">
     173                    <input type="hidden" name="hosted_button_id" value="G65Y5CM3HVRNY">
     174                    <input type="image" src="https://www.paypalobjects.com/<?php echo get_locale(); ?>/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal Ñ The safer, easier way to pay online.">
     175                    <img alt="" border="0" src="https://www.paypalobjects.com/de_DE/i/scr/pixel.gif" width="1" height="1">
     176                </form>
     177                <p><?php _e( 'Or you could:', 'obenland-wp' ); ?></p>
     178                <ul>
     179                    <li><a href="http://wordpress.org/extend/plugins/wp-approve-user/"><?php _e( 'Rate the plugin 5&#9733; on WordPress.org', 'obenland-wp' ); ?></a></li>
     180                    <li><a href="<?php echo esc_url( $plugin_data['PluginURI'] ); ?>"><?php _e( 'Blog about it &amp; link to the plugin page', 'obenland-wp' ); ?></a></li>
     181                </ul>
     182            </div>
     183        </div>
     184        <?php
     185    }
     186
     187
     188    /**
     189     * Displays a box with feed items and social media links.
     190     *
     191     * Props Joost de Valk, as this is almost entirely from his awesome WordPress
     192     * SEO Plugin.
     193     * @see    http://plugins.svn.wordpress.org/wordpress-seo/tags/1.1.5/admin/yst_plugin_tools.php
     194     *
     195     * @author Joost de Valk, Konstantin Obenland
     196     * @since  2.0.0 - 31.03.2012
     197     * @access public
     198     *
     199     * @return void
     200     */
     201    public function feed_box() {
     202
     203        include_once( ABSPATH . WPINC . '/feed.php' );
     204        $feed_url = 'http://en.wp.obenland.it/feed/';
     205        $rss      = fetch_feed( $feed_url );
     206
     207        // Bail if feed doesn't work.
     208        if ( is_wp_error( $rss ) )
     209            return;
     210
     211        $rss_items = $rss->get_items( 0, $rss->get_item_quantity( 5 ) );
     212
     213        // If the feed was erroneously.
     214        if ( ! $rss_items ) {
     215            $md5 = md5( $feed_url );
     216            delete_transient( 'feed_' . $md5 );
     217            delete_transient( 'feed_mod_' . $md5 );
     218            $rss       = fetch_feed( $feed_url );
     219            $rss_items = $rss->get_items( 0, $rss->get_item_quantity( 5 ) );
     220        }
     221        ?>
     222        <div id="formatdiv" class="postbox">
     223            <h3 class="hndle"><span><?php esc_html_e( 'News from Konstantin', 'obenland-wp' ); ?></span></h3>
     224            <div class="inside">
     225                <ul>
     226                    <?php if ( ! $rss_items ) : ?>
     227                    <li><?php _e( 'No news items, feed might be broken...', 'obenland-wp' ); ?></li>
     228                    <?php else :
     229                    foreach ( $rss_items as $item ) :
     230                        $url = preg_replace( '/#.*/', '#utm_source=wordpress&utm_medium=sidebannerpostbox&utm_term=rssitem&utm_campaign=' . $this->textdomain, $item->get_permalink() ); ?>
     231                <li><a class="rsswidget" href="<?php echo esc_url( $url ); ?>"><?php echo esc_html( $item->get_title() ); ?></a></li>
     232                <?php endforeach; endif; ?>
     233                    <li class="twitter"><a href="http://twitter.com/obenland"><?php _e( 'Follow Konstantin on Twitter', 'obenland-wp' ); ?></a></li>
     234                    <li class="rss"><a href="<?php echo esc_url( $feed_url ); ?>"><?php _e( 'Subscribe via RSS', 'obenland-wp' ); ?></a></li>
     235                </ul>
     236            </div>
     237        </div>
     238        <?php
     239    }
     240
     241
    118242    ///////////////////////////////////////////////////////////////////////////
    119243    // METHODS, PROTECTED
     
    121245
    122246    /**
    123      * Hooks methods to their WordPress Actions and Filters
     247     * Hooks methods to their WordPress Actions and Filters.
    124248     *
    125249     * @example:
     
    128252     * $this->hook( 'omg', 'is_really_tedious', 3 );
    129253     *
    130      * @author  Mark Jaquith
    131      * @see     http://sliwww.slideshare.net/markjaquith/creating-and-maintaining-wordpress-plugins
    132      * @since   1.5 - 12.02.2012
    133      * @access  protected
    134      *
    135      * @param   string  $hook Action or Filter Hook name
    136      *
    137      * @return  boolean true
     254     * @author Mark Jaquith
     255     * @see    http://sliwww.slideshare.net/markjaquith/creating-and-maintaining-wordpress-plugins
     256     * @since  1.5 - 12.02.2012
     257     * @access protected
     258     *
     259     * @param  string $hook Action or Filter Hook name.
     260     *
     261     * @return boolean true
    138262     */
    139263    protected function hook( $hook ) {
    140         $priority   =   10;
    141         $method     =   $this->sanitize_method( $hook );
    142         $args       =   func_get_args();
     264        $priority = 10;
     265        $method   = $this->sanitize_method( $hook );
     266        $args     = func_get_args();
    143267        unset( $args[0] ); // Filter name
    144268
    145269        foreach ( (array) $args as $arg ) {
    146             if ( is_int( $arg ) ) {
    147                 $priority   =   $arg;
    148             }
    149             else {
    150                 $method     =   $arg;
    151             }
     270            if ( is_int( $arg ) )
     271                $priority = $arg;
     272            else
     273                $method   = $arg;
    152274        }
    153275
    154276        return add_action( $hook, array( $this, $method ), $priority , 999 );
    155277    }
    156    
    157    
    158     /**
    159      * Sets the donate link
    160      *
    161      * @author  Konstantin Obenland
    162      * @since   1.1 - 03.04.2011
    163      * @access  protected
    164      *
    165      * @param   string  $donate_link_id
    166      *
    167      * @return  void
     278
     279
     280    /**
     281     * Sets the donate link.
     282     *
     283     * @author Konstantin Obenland
     284     * @since  1.1 - 03.04.2011
     285     * @access protected
     286     *
     287     * @param  string $donate_link_id
     288     *
     289     * @return void
    168290     */
    169291    protected function set_donate_link( $donate_link_id ) {
    170         $this->donate_link  =   add_query_arg( array(
    171             'cmd'               =>  '_s-xclick',
    172             'hosted_button_id'  =>  $donate_link_id
     292        $this->donate_link = add_query_arg( array(
     293            'cmd'              => '_s-xclick',
     294            'hosted_button_id' => $donate_link_id
    173295        ), 'https://www.paypal.com/cgi-bin/webscr' );
    174296    }
    175297
    176 
    177     /**
    178      * Retrieve option value based on the environment.
    179      *
    180      * @author  Konstantin Obenland
    181      * @since   1.4 - 23.12.2011
    182      * @access  protected
    183      *
    184      * @param   string  $option_name    Name of option to retrieve. Expected to not be SQL-escaped.
    185      * @param   mixed   $default        Optional. Default value to return if the option does not exist.
    186      * @param   boolean $use_cache      Optional. Whether to use cache. Multisite only. Default true.
    187      *
    188      * @return  mixed   Value set for the option.
    189      */
    190     protected function get_option( $option_name, $default = false, $use_cache = true ) {
    191        
    192         $options    =   $this->get_options( $default, $use_cache );
    193 
    194         if ( isset($options[$option_name]) ) {
    195             return $options[$option_name];
    196         }
    197 
    198         return $default;
    199     }
    200 
    201    
    202     /**
    203      *
    204      * @author  Konstantin Obenland
    205      * @since   1.5 - 12.02.2012
    206      * @access  protected
    207      *
    208      * @param   string  $option_name    Name of option to retrieve. Expected to not be SQL-escaped.
    209      * @param   mixed   $value          Option value. Expected to not be SQL-escaped.
    210      *
    211      * @return  boolen  False if value was not updated and true if value was updated.
    212      */
    213     protected function set_option( $option_name, $value ) {
    214         $options        =   $this->get_options();
    215         $options[$key]  =   $value;
    216        
    217         if ( is_plugin_active_for_network($this->plugin_name) ) {
    218             return update_site_option( $this->textdomain, $options );
    219         }
    220        
    221         return update_option( $this->textdomain, $options );
    222     }
    223 
    224 
    225298    ///////////////////////////////////////////////////////////////////////////
    226299    // METHODS, PRIVATE
     
    228301
    229302    /**
    230      * Retrieve options based on the environment.
    231      *
    232      * @author  Konstantin Obenland
    233      * @since   1.5 - 12.02.2012
    234      * @access  private
    235      *
    236      * @param   mixed   $default    Optional. Default value to return if the option does not exist.
    237      * @param   boolean $use_cache  Optional. Whether to use cache. Multisite only. Default true.
    238      *
    239      * @return  mixed   Value set for the option.
    240      */
    241     private function get_options( $default = false, $use_cache = true ) {
    242        
    243         if ( is_plugin_active_for_network($this->plugin_name) ) {
    244             $options    =   get_site_option( $this->textdomain, $default, $use_cache );
    245         } else {
    246             $options    =   get_option( $this->textdomain, $default );
    247         }
    248        
    249         return  $options;
    250     }
    251    
    252    
    253     /**
    254      * Sanitizes method names
    255      *
    256      * @author  Mark Jaquith
    257      * @see     http://sliwww.slideshare.net/markjaquith/creating-and-maintaining-wordpress-plugins
    258      * @since   1.5 - 12.02.2012
    259      * @access  private
    260      *
    261      * @param   string  $method     Method name to be sanitized
    262      *
    263      * @return  string  Sanitized method name
     303     * Sanitizes method names.
     304     *
     305     * @author Mark Jaquith
     306     * @see    http://sliwww.slideshare.net/markjaquith/creating-and-maintaining-wordpress-plugins
     307     * @since  1.5 - 12.02.2012
     308     * @access private
     309     *
     310     * @param  string $method Method name to be sanitized.
     311     *
     312     * @return string Sanitized method name
    264313     */
    265314    private function sanitize_method( $method ) {
     
    267316    }
    268317
    269 } // End of class Obenland_Wp_Plugins
     318} // End of class Obenland_Wp_Plugins.
    270319
    271320
  • wp-last-login/trunk/readme.txt

    r529901 r700584  
    11=== WP Last Login ===
    2 Contributors: kobenland
     2Contributors: obenland
    33Tags: admin, user, login, last login, plugin
    44Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=K32M878XHREQC
    5 Requires at least: 3.0
    6 Tested up to: 3.3.1
    7 Stable tag: 1.1.2
     5Requires at least: 3.1
     6Tested up to: 3.6
     7Stable tag: 1.2.0
    88
    99Make the last login for each user visibile in the user overview.
     
    1212
    1313This plugin adds an extra column to the users overview with the date of the last login for each user.
     14Additionally, users can be sorted by the date of their last login.
    1415
    1516= Translations =
     
    1920* Arabic
    2021* Chinese
    21 * Fran&ccedil;ais
    22 * Deutsch
     22* French
    2323* English
    24 * Espa&ntilde;ol
    25 * Italiano
     24* German
     25* Italian
    2626* Japanese
    2727* Nederlands
    28 * Polski
    29 * Portugu&ecirc;s
    30 * Rom&acirc;n
     28* Polish
     29* Portuguese
     30* Rumanian
    3131* Russian
     32* Spanish
    3233
    3334
     
    5051
    5152== Changelog ==
     53
     54= 1.2.0 =
     55* Users are now sortable by last login!
     56* Updated utility class.
     57* Added Danish translation. Props thomasclausen.
     58
    5259= 1.1.2 =
    5360* Fixed a bug where content of other custom columns were not displayed.
    5461
    5562= 1.1.1 =
    56 * Updated utility class
     63* Updated utility class.
    5764
    5865= 1.1.0 =
    59 * Made the display of the column filterable
    60 * Widened the column a bit to accomodate for large date strings
     66* Made the display of the column filterable.
     67* Widened the column a bit to accomodate for large date strings.
    6168
    6269= 1.0 =
    63 * Initial Release
     70* Initial Release.
    6471
    6572
  • wp-last-login/trunk/uninstall.php

    r525795 r700584  
    11<?php
    2 //Don't uninstall unless you absolutely want to!
    3 if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
     2// Don't uninstall unless you absolutely want to!
     3if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) )
    44    wp_die( 'WP_UNINSTALL_PLUGIN undefined.' );
    5 }
    65
    7 $user_ids   =   get_users(array(
    8     'blog_id'   =>  '',
    9     'fields'    =>  'ID'
    10 ));
     6$user_ids = get_users( array(
     7    'blog_id' => '',
     8    'fields'  => 'ID',
     9) );
    1110
    12 foreach ( $user_ids as $user_id ) {
     11foreach ( $user_ids as $user_id )
    1312    delete_user_meta( $user_id, 'wp-last-login' );
    14 }
    1513
    1614
  • wp-last-login/trunk/wp-last-login.php

    r529901 r700584  
    22/** wp-last-login.php
    33 *
    4  * Plugin Name: WP Last Login
    5  * Plugin URI:  http://en.wp.obenland.it/wp-last-login/?utm_source=wordpress&utm_medium=plugin&utm_campaign=wp-last-login
    6  * Description: Displays the date of the last login in user lists.
    7  * Version:     1.1.2
    8  * Author:      Konstantin Obenland
    9  * Author URI:  http://en.wp.obenland.it/?utm_source=wordpress&utm_medium=plugin&utm_campaign=wp-last-login
     4 * Plugin Name: WP Last Login
     5 * Plugin URI:  http://en.wp.obenland.it/wp-last-login/#utm_source=wordpress&utm_medium=plugin&utm_campaign=wp-last-login
     6 * Description: Displays the date of the last login in user lists.
     7 * Version:     1.2.0
     8 * Author:      Konstantin Obenland
     9 * Author URI:  http://en.wp.obenland.it/#utm_source=wordpress&utm_medium=plugin&utm_campaign=wp-last-login
    1010 * Text Domain: wp-last-login
    1111 * Domain Path: /lang
    12  * License:     GPLv2
     12 * License:     GPLv2
    1313 */
    1414
    1515
    16 if ( ! class_exists('Obenland_Wp_Plugins_v15') ) {
     16if ( ! class_exists( 'Obenland_Wp_Plugins_v301' ) )
    1717    require_once( 'obenland-wp-plugins.php' );
    18 }
    19 
    20 
    21 class Obenland_Wp_Last_Login extends Obenland_Wp_Plugins_v15 {
    22    
    23    
     18
     19
     20class Obenland_Wp_Last_Login extends Obenland_Wp_Plugins_v301 {
     21
     22
    2423    ///////////////////////////////////////////////////////////////////////////
    2524    // METHODS, PUBLIC
    2625    ///////////////////////////////////////////////////////////////////////////
    27    
     26
    2827    /**
    2928     * Constructor
    3029     *
    31      * @author  Konstantin Obenland
    32      * @since   1.0 - 23.01.2012
    33      * @access  public
    34      *
    35      * @return  Obenland_Wp_Last_Login
     30     * @author Konstantin Obenland
     31     * @since  1.0 - 23.01.2012
     32     * @access public
     33     *
     34     * @return Obenland_Wp_Last_Login
    3635     */
    3736    public function __construct() {
    38        
     37
    3938        parent::__construct( array(
    40             'textdomain'        =>  'wp-last-login',
    41             'plugin_path'       =>  __FILE__,
    42             'donate_link_id'    =>  'K32M878XHREQC'
    43         ));
    44        
     39            'textdomain'     => 'wp-last-login',
     40            'plugin_path'    => __FILE__,
     41            'donate_link_id' => 'K32M878XHREQC',
     42        ) );
     43
    4544        load_plugin_textdomain( 'wp-last-login', false, 'wp-last-login/lang' );
    46        
     45
    4746        $this->hook( 'wp_login' );
    48        
     47
    4948        /**
    5049         * Programmers:
     
    5655         *
    5756         * function prefix_wpll_visibility( $bool ) {
    58          *      return current_user_can( 'manage_options' ); // Only for Admins
     57         *     return current_user_can( 'manage_options' ); // Only for Admins
    5958         * }
    6059         * add_filter( 'wpll_current_user_can', 'prefix_wpll_visibility' );
     
    6261         */
    6362        if ( is_admin() AND apply_filters( 'wpll_current_user_can', true ) ) {
    64            
    65             $this->hook( 'manage_site-users-network_columns',   'add_column',   1 );
    66             $this->hook( 'manage_users_columns',                'add_column',   1 );
    67             $this->hook( 'wpmu_users_columns',                  'add_column',   1 );
    68             $this->hook( 'admin_print_styles-users.php',        'column_style' );
    69             $this->hook( 'admin_print_styles-site-users.php',   'column_style' );
    70             $this->hook( 'manage_users_custom_column' );
     63
     64            $this->hook( 'manage_site-users-network_columns',     'add_column', 1 );
     65            $this->hook( 'manage_users_columns',                  'add_column', 1 );
     66            $this->hook( 'wpmu_users_columns',                    'add_column', 1 );
     67            $this->hook( 'admin_print_styles-users.php',          'column_style'  );
     68            $this->hook( 'admin_print_styles-site-users.php',     'column_style'  );
     69            $this->hook( 'manage_users_custom_column'                             );
     70            $this->hook( 'manage_users_sortable_columns',         'add_sortable'  );
     71            $this->hook( 'manage_users-network_sortable_columns', 'add_sortable'  );
     72            $this->hook( 'request'                                                );
    7173        }
    7274    }
    7375
    74        
     76
    7577    /**
    7678     * Update the login timestamp
    7779     *
    78      * @author  Konstantin Obenland
    79      * @since   1.0 - 23.01.2012
    80      * @access  public
    81      *
    82      * @param   string  $user_login The user's login name
    83      *
    84      * @return  void
    85      */
    86     public function wp_login( $user_login ) {
    87         $user   =   get_user_by( 'login', $user_login );
     80     * @author Konstantin Obenland
     81     * @since  1.0 - 23.01.2012
     82     * @access public
     83     *
     84     * @param  string $user_login The user's login name
     85     *
     86     * @return void
     87     */
     88    public function wp_login( $user_login, $user ) {
    8889        update_user_meta( $user->ID, $this->textdomain, time() );
    8990    }
    90    
    91    
     91
     92
    9293    /**
    9394     * Adds the last login column to the network admin user list
    9495     *
    95      * @author  Konstantin Obenland
    96      * @since   1.0 - 23.01.2012
    97      * @access  public
    98      *
    99      * @param   array   $cols   The default columns
    100      *
    101      * @return  array
     96     * @author Konstantin Obenland
     97     * @since  1.0 - 23.01.2012
     98     * @access public
     99     *
     100     * @param  array $cols The default columns
     101     *
     102     * @return array
    102103     */
    103104    public function add_column( $cols ) {
    104         $cols[$this->textdomain]    =   __( 'Last Login', 'wp-last-login' );
     105        $cols[ $this->textdomain ] = __( 'Last Login', 'wp-last-login' );
    105106        return $cols;
    106     }
    107 
    108    
     107    }
     108
     109
    109110    /**
    110111     * Adds the last login column to the network admin user list
    111112     *
    112      * @author  Konstantin Obenland
    113      * @since   1.0 - 23.01.2012
    114      * @access  public
    115      *
    116      * @param   string  $value          Value of the custom column
    117      * @param   string  $column_name    The name of the column
    118      * @param   int     $user_id        The user's id
    119      *
    120      * @return  string
     113     * @author Konstantin Obenland
     114     * @since  1.0 - 23.01.2012
     115     * @access public
     116     *
     117     * @param  string $value       Value of the custom column
     118     * @param  string $column_name The name of the column
     119     * @param  int    $user_id     The user's id
     120     *
     121     * @return string
    121122     */
    122123    public function manage_users_custom_column( $value, $column_name, $user_id ) {
    123        
     124
    124125        if ( $this->textdomain == $column_name ) {
    125             $last_login =   get_user_meta( $user_id, $this->textdomain, true );
    126            
     126            $value      = __( 'Never.', 'wp-last-login' );
     127            $last_login = (int) get_user_meta( $user_id, $this->textdomain, true );
     128
    127129            if ( $last_login ) {
    128                 $format =   apply_filters( 'wpll_date_format', get_option('date_format') );
    129                 return date_i18n( $format, $last_login );
     130                $format = apply_filters( 'wpll_date_format', get_option( 'date_format' ) );
     131                $value  = date_i18n( $format, $last_login );
    130132            }
    131            
    132             return __( 'Never.', 'wp-last-login' );
    133133        }
    134        
     134
    135135        return $value;
    136136    }
    137    
    138    
     137
     138
     139    /**
     140     * Register the column as sortable
     141     *
     142     * @author Konstantin Obenland
     143     * @since  1.2.0 - 11.12.2012
     144     * @access public
     145     *
     146     * @param  array $columns
     147     *
     148     * @return array
     149     */
     150    public function add_sortable( $columns ) {
     151        $columns[ $this->textdomain ] = $this->textdomain;
     152
     153        return $columns;
     154    }
     155
     156
     157    /**
     158     * Handle ordering by last login
     159     *
     160     * @author Silviu-Cristian Burca
     161     * @since  1.2.0 - 11.12.2012
     162     * @access public
     163     *
     164     * @param  array $vars Request arguments
     165     *
     166     * @return array
     167     */
     168    public function request( $vars ) {
     169        if ( isset( $vars['orderby'] ) && $this->textdomain == $vars['orderby'] ) {
     170            $vars = array_merge( $vars, array(
     171                'meta_key' => $this->textdomain,
     172                'orderby'  => 'meta_value_num',
     173            ) );
     174        }
     175
     176        return $vars;
     177    }
     178
     179
    139180    /**
    140181     * Defines the width of the column
    141182     *
    142      * @author  Konstantin Obenland
    143      * @since   1.0 - 23.01.2012
    144      * @access  public
    145      *
    146      * @return  void
     183     * @author Konstantin Obenland
     184     * @since  1.0 - 23.01.2012
     185     * @access public
     186     *
     187     * @return void
    147188     */
    148189    public function column_style() {
    149190        ?>
    150191        <style type="text/css">
    151             .column-wp-last-login { width: 9%; }
     192            .column-wp-last-login { width: 12%; }
    152193        </style>
    153194        <?php
    154195    }
    155196
    156 }  // End of class Obenland_Wp_Last_Login
     197} // End of class Obenland_Wp_Last_Login.
    157198
    158199
Note: See TracChangeset for help on using the changeset viewer.