Plugin Directory

Changeset 144379


Ignore:
Timestamp:
08/10/2009 12:52:41 PM (17 years ago)
Author:
AdamBackstrom
Message:

Rename files from whos-online to wp-whos-online to match home in the repo.

Location:
wp-whos-online/trunk
Files:
2 moved

Legend:

Unmodified
Added
Removed
  • wp-whos-online/trunk/wp-whos-online.js

    r144355 r144379  
    33    * Update author "last online" timestamps
    44    */
    5     function getWhosonline(){
     5    function getwpwhosonline(){
    66        toggleUpdates();
    7         var queryString = whosonline.ajaxUrl +'?action=whosonline_ajax_update&load_time=' + whosonline.whosonlineLoadTime + '&frontpage=' + whosonline.isFirstFrontPage;
     7        var queryString = wpwhosonline.ajaxUrl +'?action=wpwhosonline_ajax_update&load_time=' + wpwhosonline.wpwhosonlineLoadTime + '&frontpage=' + wpwhosonline.isFirstFrontPage;
    88        ajaxCheckAuthors = $.getJSON(queryString, function(response){
    99            if(typeof response.latestupdate != 'undefined') {
    10                 whosonline.whosonlineLoadTime = response.latestupdate;
     10                wpwhosonline.wpwhosonlineLoadTime = response.latestupdate;
    1111                for(var i = 0; i < response.authors.length; i++) {
    12                     $('#whosonline-'+response.authors[i].user_id).
    13                         text( response.authors[i].whosonline ).
    14                         data('whosonline_timestamp', response.authors[i].whosonline_unix);
     12                    $('#wpwhosonline-'+response.authors[i].user_id).
     13                        text( response.authors[i].wpwhosonline ).
     14                        data('wpwhosonline_timestamp', response.authors[i].wpwhosonline_unix);
    1515                }
    1616            }
     
    2727        var ancient = 7200; // 2 hours
    2828
    29         $('.widget_whosonline span').each(function(){
     29        $('.widget_wpwhosonline span').each(function(){
    3030            var $o = $(this);
    3131            var since, oclass;
    3232
    33             var last = $o.data('whosonline_timestamp');
     33            var last = $o.data('wpwhosonline_timestamp');
    3434            if( typeof last == 'undefined' ) {
    3535                last = Date.parse($o.text()) / 1000;
     
    5151
    5252    function toggleUpdates() {
    53         if (0 == whosonline.getWhosonlineUpdate) {
    54             whosonline.getWhosonlineUpdate = setInterval(getWhosonline, 30000);
     53        if (0 == wpwhosonline.getwpwhosonlineUpdate) {
     54            wpwhosonline.getwpwhosonlineUpdate = setInterval(getwpwhosonline, 30000);
    5555        }
    5656        else {
    57             clearInterval(whosonline.getWhosonlineUpdate);
    58             whosonline.getWhosonlineUpdate = '0';
     57            clearInterval(wpwhosonline.getwpwhosonlineUpdate);
     58            wpwhosonline.getwpwhosonlineUpdate = '0';
    5959        }
    6060    }
  • wp-whos-online/trunk/wp-whos-online.php

    r144355 r144379  
    1010*/
    1111
    12 function whosonline_init() {
    13     add_action( 'wp_head', 'whosonline_pageoptions_js' );
    14     add_action( 'wp_head', 'whosonline_css' );
    15 
    16     wp_enqueue_script('whosonline', '/' . PLUGINDIR . '/whos-online/whos-online.js', array('jquery'));
    17 
    18     whosonline_update();
    19 }
    20 add_action('template_redirect', 'whosonline_init');
     12function wpwhosonline_init() {
     13    add_action( 'wp_head', 'wpwhosonline_pageoptions_js' );
     14    add_action( 'wp_head', 'wpwhosonline_css' );
     15
     16    wp_enqueue_script('wpwhosonline', '/' . PLUGINDIR . '/wp-whos-online/wp-whos-online.js', array('jquery'));
     17
     18    wpwhosonline_update();
     19}
     20add_action('template_redirect', 'wpwhosonline_init');
    2121
    2222// our own ajax call
    23 add_action( 'wp_ajax_whosonline_ajax_update', 'whosonline_ajax_update' );
     23add_action( 'wp_ajax_wpwhosonline_ajax_update', 'wpwhosonline_ajax_update' );
    2424
    2525// hook into p2 ajax calls, if they're there
    26 add_action( 'wp_ajax_prologue_latest_posts', 'whosonline_update' );
    27 add_action( 'wp_ajax_prologue_latest_comments', 'whosonline_update' );
     26add_action( 'wp_ajax_prologue_latest_posts', 'wpwhosonline_update' );
     27add_action( 'wp_ajax_prologue_latest_comments', 'wpwhosonline_update' );
    2828
    2929/**
    3030 * Update a user's "last online" timestamp.
    3131 */
    32 function whosonline_update() {
     32function wpwhosonline_update() {
    3333    if( !is_user_logged_in() )
    3434        return null;
     
    3636    global $user_ID;
    3737
    38     update_usermeta( $user_ID, 'whosonline_timestamp', time() );
    39 }//end whosonline_update
     38    update_usermeta( $user_ID, 'wpwhosonline_timestamp', time() );
     39}//end wpwhosonline_update
    4040
    4141/**
     
    4343 * since the client's last update.
    4444 */
    45 function whosonline_ajax_update() {
     45function wpwhosonline_ajax_update() {
    4646    global $wpdb;
    4747
    4848    // update timestamp of user who is checking
    49     whosonline_update();
     49    wpwhosonline_update();
    5050
    5151    $load_time = strtotime($_GET['load_time'] . ' GMT');
    52     $authors = $wpdb->get_results($wpdb->prepare("SELECT user_id, meta_value AS whosonline FROM $wpdb->usermeta
    53         WHERE meta_key = 'whosonline_timestamp' AND meta_value > %d", $load_time));
     52    $authors = $wpdb->get_results($wpdb->prepare("SELECT user_id, meta_value AS wpwhosonline FROM $wpdb->usermeta
     53        WHERE meta_key = 'wpwhosonline_timestamp' AND meta_value > %d", $load_time));
    5454
    5555    if( count($authors) == 0 ) {
     
    5959    $latest = 0;
    6060    foreach($authors as $author) {
    61         if( $author->whosonline > $latest )
    62             $latest = $author->whosonline;
    63 
    64         $author->whosonline_unix = (int)$author->whosonline;
    65         $author->whosonline = strftime( '%d %b %Y %H:%M:%S %Z', $author->whosonline );
     61        if( $author->wpwhosonline > $latest )
     62            $latest = $author->wpwhosonline;
     63
     64        $author->wpwhosonline_unix = (int)$author->wpwhosonline;
     65        $author->wpwhosonline = strftime( '%d %b %Y %H:%M:%S %Z', $author->wpwhosonline );
    6666    }
    6767
     
    7070}
    7171
    72 function whosonline_css() {
     72function wpwhosonline_css() {
    7373    ?><style type="text/css">
    74     .widget_whosonline .active { font-weight: bold; color: green; }
    75     .widget_whosonline .recent { }
    76     .widget_whosonline .ancient { font-style: italic; color: red; }
    77     .widget_whosonline ul li { float: none; width: auto; height: 33px; }
    78     .widget_whosonline h2 {}
    79     .widget_whosonline ul li strong {}
    80     .widget_whosonline ul li img.avatar { float: left; margin-right: 1ex; }
     74    .widget_wpwhosonline .active { font-weight: bold; color: green; }
     75    .widget_wpwhosonline .recent { }
     76    .widget_wpwhosonline .ancient { font-style: italic; color: red; }
     77    .widget_wpwhosonline ul li { float: none; width: auto; height: 33px; }
     78    .widget_wpwhosonline h2 {}
     79    .widget_wpwhosonline ul li strong {}
     80    .widget_wpwhosonline ul li img.avatar { float: left; margin-right: 1ex; }
    8181    /* kubrick style follows */
    82     #sidebar ul li.widget_whosonline ul li:before { content: none; }
     82    #sidebar ul li.widget_wpwhosonline ul li:before { content: none; }
    8383    </style><?php
    8484}
    8585
    86 function whosonline_pageoptions_js() {
     86function wpwhosonline_pageoptions_js() {
    8787    global $page_options;
    8888?><script type='text/javascript'>
    8989// <![CDATA[
    90 var whosonline = {
     90var wpwhosonline = {
    9191    'ajaxUrl': "<?php echo js_escape( get_bloginfo( 'wpurl' ) . '/wp-admin/admin-ajax.php' ); ?>",
    92     'whosonlineLoadTime': "<?php echo gmdate( 'Y-m-d H:i:s' ); ?>",
    93     'getWhosonlineUpdate': '0',
     92    'wpwhosonlineLoadTime': "<?php echo gmdate( 'Y-m-d H:i:s' ); ?>",
     93    'getwpwhosonlineUpdate': '0',
    9494    'isFirstFrontPage': "<?php echo is_home(); ?>"
    9595};
     
    9999
    100100/**
    101  * Custom version of wp_list_authors() for the whos-online plugin.
     101 * Custom version of wp_list_authors() for the wp-whos-online plugin.
    102102 *
    103103 * optioncount (boolean) (false): Show the count in parenthesis next to the
     
    115115 * @return null|string The output, if echo is set to false.
    116116 */
    117 function whosonline_list_authors($args = '') {
     117function wpwhosonline_list_authors($args = '') {
    118118    global $wpdb;
    119119
     
    122122        'show_fullname' => false, 'hide_empty' => true,
    123123        'feed' => '', 'feed_image' => '', 'feed_type' => '', 'echo' => true,
    124         'avatar_size' => 0, 'whosonline' => 0
     124        'avatar_size' => 0, 'wpwhosonline' => 0
    125125    );
    126126
     
    189189        }
    190190
    191         if ( $whosonline ) {
    192             $whosonline_time = get_usermeta( $author->ID, 'whosonline_timestamp' );
    193             if( $whosonline_time ) {
    194                 $whosonline_time = strftime( '%d %b %Y %H:%M:%S %Z', $whosonline_time );
     191        if ( $wpwhosonline ) {
     192            $wpwhosonline_time = get_usermeta( $author->ID, 'wpwhosonline_timestamp' );
     193            if( $wpwhosonline_time ) {
     194                $wpwhosonline_time = strftime( '%d %b %Y %H:%M:%S %Z', $wpwhosonline_time );
    195195            } else {
    196                 $whosonline_time = '';
     196                $wpwhosonline_time = '';
    197197            }
    198             $link .= '<br /><span id="whosonline-' . $author->ID . '" title="Last online timestamp">' . $whosonline_time . '</span>';
     198            $link .= '<br /><span id="wpwhosonline-' . $author->ID . '" title="Last online timestamp">' . $wpwhosonline_time . '</span>';
    199199        }
    200200
     
    207207}
    208208
    209 function widget_whosonline_init() {
     209function widget_wpwhosonline_init() {
    210210
    211211  // Check for the required plugin functions. This will prevent fatal
     
    215215
    216216  // This is the function that outputs the Authors code.
    217   function widget_whosonline($args) {
     217  function widget_wpwhosonline($args) {
    218218    extract($args);
    219219
     
    221221?>
    222222<ul>
    223 <?php whosonline_list_authors('optioncount=1&exclude_admin=0&show_fullname=1&hide_empty=0&avatar_size=32&whosonline=1'); ?>
     223<?php wpwhosonline_list_authors('optioncount=1&exclude_admin=0&show_fullname=1&hide_empty=0&avatar_size=32&wpwhosonline=1'); ?>
    224224</ul>
    225225<?php
     
    229229  // This registers our widget so it appears with the other available
    230230  // widgets and can be dragged and dropped into any active sidebars.
    231   register_sidebar_widget('Who\'s Online', 'widget_whosonline');
     231  register_sidebar_widget('Who\'s Online', 'widget_wpwhosonline');
    232232}
    233233
    234234// Run our code later in case this loads prior to any required plugins.
    235 add_action('plugins_loaded', 'widget_whosonline_init');
     235add_action('plugins_loaded', 'widget_wpwhosonline_init');
Note: See TracChangeset for help on using the changeset viewer.