WordPress.org

Plugin Directory

Changeset 563796


Ignore:
Timestamp:
06/25/12 23:54:37 (22 months ago)
Author:
ryanimel
Message:

Tagging version 0.3 with a fun new feature

Location:
p2-check-in
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • p2-check-in/tags/0.3/p2-check-in.css

    r563753 r563796  
    9494} 
    9595 
     96.p2checkinwidget-list li p.minor { 
     97    font-size: 9px; 
     98    line-height: 18px !important; 
     99    text-transform: uppercase; 
     100} 
     101 
    96102.p2checkinwidget-list li p.user-link { 
    97103    font-size: 13px; 
     
    102108    opacity: 0.4; 
    103109} 
    104  
    105 /* kubrick style follows */ 
    106 #sidebar ul li.widget_p2checkinwidget ul li:before { content: none; } 
  • p2-check-in/tags/0.3/p2-check-in.php

    r563765 r563796  
    44Plugin URI: http://wordpress.org/extend/plugins/p2-check-in 
    55Description: This plugin adds the ability for users to "check in" to the P2 theme when they're active. Once activated you'll find a new "Who is Checked In" widget that you can add to your sidebar, and a "Log In/I'm here!/I'm leaving!" button will automatically be added to your P2's header. 
    6 Version: 0.2.1 
     6Version: 0.3 
    77Author: Ryan Imel 
    88Author URI: http://wpcandy.com 
     
    1414// Adds the CSS to the front end. 
    1515function p2checkinwidget_enqueue() { 
    16     wp_enqueue_style(  'p2checkinwidget_css', plugins_url('p2-check-in.css', __FILE__), null, '0.2' ); 
     16    wp_enqueue_style(  'p2checkinwidget_css', plugins_url('p2-check-in.css', __FILE__), null, '0.3' ); 
    1717} 
    1818add_action('wp_enqueue_scripts', 'p2checkinwidget_enqueue'); 
     
    3737         
    3838            array( 
    39                 'key' => 'currently_checked_in', 
     39                'key' => 'p2checkin_currently_checked_in', 
    4040                'value' => true // this makes sure the user is checked in 
    4141            ) 
     
    5656} 
    5757 
     58// List of checked out users 
    5859function p2checkinwidget_checkedout ( $args = array() ) { 
    5960     
    6061    $args = wp_parse_args( $args, array( 
    6162     
    62         'meta_key' => 'currently_checked_in', 
     63        'meta_key' => 'p2checkin_currently_checked_in', 
    6364        'meta_value' => false 
    6465         
     
    7879} 
    7980 
     81// List of checked in users 
    8082function p2checkinwidget_list_authors() { 
    8183    $users = p2checkinwidget_checkedin(); 
     
    9092        $item = '<li id="p2checkinwidget-' . $user->ID . '" class="checkedin">' . $item . '</li>'; 
    9193        $html .= $item; 
     94         
    9295    } 
    9396     
     
    111114 */ 
    112115function p2checkinwidget_user( $last_online_ts, $user ) { 
    113     $avatar = '<a class="user-img" href="' . get_author_posts_url( $user->ID, $user->user_nicename ) . '" title="' . esc_attr( sprintf(__("Posts by %s"), $user->display_name) ) . '">' . get_avatar( $user->user_email, 32 ) . '</a>'; 
     116    $avatar = '<a class="user-img" href="' . get_author_posts_url( $user->ID, $user->user_nicename ) . '" title="' . esc_attr( sprintf(__("Posts by %s"), $user->display_name) ) . '">' . get_avatar( $user->user_email, 52 ) . '</a>'; 
    114117    $name = $user->display_name; 
    115118    $link = '<p class="user-link"><a href="' . get_author_posts_url( $user->ID, $user->user_nicename ) . '" title="' . esc_attr( sprintf(__("Posts by %s"), $user->display_name) ) . '">' . $name . '</a></p>'; 
     
    117120    $link = apply_filters( 'p2checkinwidget_author_link', $link, $user ); 
    118121 
    119     $rwi_checkedin = get_user_meta( $user->ID, 'currently_checked_in', true ); 
    120     $rwi_checkedouttime = get_user_meta( $user->ID, 'time_checked_out', true ); 
     122    $rwi_checkedin = get_user_meta( $user->ID, 'p2checkin_currently_checked_in', true ); 
     123    $rwi_checkedouttime = get_user_meta( $user->ID, 'p2checkin_time_checked_out', true ); 
    121124    $timenow = current_time( 'timestamp', 1 ); 
    122     $minutes = 0.5; // how long to show someone has been gone 
     125    $minutes = 5; // how long to show someone has been gone 
    123126    $timetoshow = (60 * $minutes); 
     127     
     128    $p2checkin_totaltimedisplay = get_user_meta( $user->ID, 'p2checkin_totaltime', true ); 
     129    $p2time_readable = number_format( ( $p2checkin_totaltimedisplay / 60 / 60 ), 2, '.', '' ); 
    124130 
    125131    if ( $rwi_checkedin ) { 
    126132         
    127         $timein = get_user_meta( $user->ID , 'time_checked_in', true ); 
    128         $timephrase = '<p>Checked in for ' . human_time_diff( $timein, $timenow ) . '<p>'; 
     133        $timein = get_user_meta( $user->ID , 'p2checkin_time_checked_in', true ); 
     134        $timesofar = ( $timenow - $timein ); 
     135        $p2time_readable_temp = number_format( ( ( $timesofar + $p2checkin_totaltimedisplay ) / 60 / 60 ), 2, '.', '' ); 
     136        $timephrase = '<p><strong>Checked in for ' . human_time_diff( $timein, $timenow ) . '</strong></p><p class="minor">Total: ' . $p2time_readable_temp . ' hours<p>'; 
    129137         
    130138        // If there's data, woot 
     
    133141    } else if ( !($rwi_checkedin ) AND ( ( $timenow - $rwi_checkedouttime ) < $timetoshow ) )  { 
    134142         
    135         $timephrase = '<p>Left ' . human_time_diff( $rwi_checkedouttime, $timenow ) . ' ago.</p>'; 
     143        $timephrase = '<p><strong>Left ' . human_time_diff( $rwi_checkedouttime, $timenow ) . ' ago.</strong></p><p class="minor">Total: ' . $p2time_readable . ' hours</p>'; 
    136144         
    137145        // They left somewhat recently 
     
    155163         
    156164        // So we know they're in 
    157         update_user_meta( $current_user->ID , 'currently_checked_in', true ); 
     165        update_user_meta( $current_user->ID , 'p2checkin_currently_checked_in', true ); 
    158166         
    159167        // So we know what time they showed up 
    160         update_user_meta( $current_user->ID , 'time_checked_in', current_time( 'timestamp' , 1 ) ); 
     168        update_user_meta( $current_user->ID , 'p2checkin_time_checked_in', current_time( 'timestamp' , 1 ) ); 
    161169         
    162170    } else if ( $current_user->ID AND isset( $_GET[checkout] ) ) { 
    163171         
    164         // So we know they're out 
    165         update_user_meta( $current_user->ID , 'currently_checked_in', false ); 
    166          
    167         // So we know what time they left 
    168         update_user_meta( $current_user->ID, 'time_checked_out', current_time( 'timestamp', 1 ) ); 
    169          
    170     } 
    171      
    172     $nowin = get_user_meta( $current_user->ID, 'currently_checked_in', true ); 
     172        // Prevent cheatin' 
     173        $rwi_checkedin = get_user_meta( $current_user->ID, 'p2checkin_time_checked_in', true ); 
     174        $rwi_checkedouttime = get_user_meta( $current_user->ID, 'p2checkin_time_checked_out', true ); 
     175         
     176        if ( $rwi_checkedouttime > $rwi_checkedin ) { 
     177             
     178            echo '<p>Cheating? Tsk tsk.</p>'; 
     179         
     180        } else { 
     181             
     182            // So we know they're out 
     183            update_user_meta( $current_user->ID , 'p2checkin_currently_checked_in', false ); 
     184 
     185            // So we know what time they left 
     186            update_user_meta( $current_user->ID , 'p2checkin_time_checked_out', current_time( 'timestamp', 1 ) ); 
     187 
     188            // Keep a running total of checked in time. Why not? 
     189            $rwi_checkedouttime_realz = get_user_meta( $current_user->ID, 'p2checkin_time_checked_out', true ); 
     190            $p2checkin_timesofar = get_user_meta( $current_user->ID, 'p2checkin_totaltime', true ); 
     191            $p2checkin_sessiontime = ( $rwi_checkedouttime_realz - $rwi_checkedin ); 
     192            $p2checkin_timesofar += $p2checkin_sessiontime; 
     193 
     194            update_user_meta( $current_user->ID, 'p2checkin_totaltime', $p2checkin_timesofar ); 
     195             
     196        } 
     197         
     198    } 
     199     
     200    $nowin = get_user_meta( $current_user->ID, 'p2checkin_currently_checked_in', true ); 
    173201     
    174202    // Is anyone logged in? If not, make the button a log in button.     
     
    186214         
    187215    } 
    188      
     216         
    189217    return $buttonoutput; 
    190218     
     
    224252    wp_register_sidebar_widget( 'widget_p2checkinwidget', "Who's Checked In", 'widget_p2checkinwidget', array( 'description' => 'Display who has checked into the office (or wherever) via P2.') ); 
    225253} 
    226  
  • p2-check-in/tags/0.3/readme.txt

    r563765 r563796  
    44Requires at least: 3.0 
    55Tested up to: 3.4 
    6 Stable tag: 0.2.1 
     6Stable tag: 0.3 
    77License: GPLv2 or later 
    88 
     
    1717The language in this plugin is purposefully left a big vague so you can use it for your own purposes. Checking in could mean literally checking into a building to show you're there (the purpose I developed the plugin for) or it could mean that you are simply available, and actively watching the P2. 
    1818 
    19 ### Kudos 
     19In addition, the total amount of time someone has logged when "checked in" is displayed 
     20 
     21#### Kudos 
    2022 
    2123Props to the Who's Online plugin for P2, since I cribbed a number of the elements from that plugin to make the development of mine go a bit faster. 
     
    3537== Changelog == 
    3638 
     39= 0.3 = 
     40* Feature: Total checked in time is now logged and displayed, by default, with the user list in the sidebar. Get competitive! 
     41* Also removed some more unused CSS. 
     42* Note: Unfortunately this release my end up checking users out if they're in at the time you upgrade. This is due to this release making the meta values uniform (with proper namespacing across the board). Ideally this will be the only release that resets anyone. 
     43 
    3744= 0.2.1 = 
    3845* Added kudos to the end of the description. 
  • p2-check-in/trunk/p2-check-in.css

    r563753 r563796  
    9494} 
    9595 
     96.p2checkinwidget-list li p.minor { 
     97    font-size: 9px; 
     98    line-height: 18px !important; 
     99    text-transform: uppercase; 
     100} 
     101 
    96102.p2checkinwidget-list li p.user-link { 
    97103    font-size: 13px; 
     
    102108    opacity: 0.4; 
    103109} 
    104  
    105 /* kubrick style follows */ 
    106 #sidebar ul li.widget_p2checkinwidget ul li:before { content: none; } 
  • p2-check-in/trunk/p2-check-in.php

    r563765 r563796  
    44Plugin URI: http://wordpress.org/extend/plugins/p2-check-in 
    55Description: This plugin adds the ability for users to "check in" to the P2 theme when they're active. Once activated you'll find a new "Who is Checked In" widget that you can add to your sidebar, and a "Log In/I'm here!/I'm leaving!" button will automatically be added to your P2's header. 
    6 Version: 0.2.1 
     6Version: 0.3 
    77Author: Ryan Imel 
    88Author URI: http://wpcandy.com 
     
    1414// Adds the CSS to the front end. 
    1515function p2checkinwidget_enqueue() { 
    16     wp_enqueue_style(  'p2checkinwidget_css', plugins_url('p2-check-in.css', __FILE__), null, '0.2' ); 
     16    wp_enqueue_style(  'p2checkinwidget_css', plugins_url('p2-check-in.css', __FILE__), null, '0.3' ); 
    1717} 
    1818add_action('wp_enqueue_scripts', 'p2checkinwidget_enqueue'); 
     
    3737         
    3838            array( 
    39                 'key' => 'currently_checked_in', 
     39                'key' => 'p2checkin_currently_checked_in', 
    4040                'value' => true // this makes sure the user is checked in 
    4141            ) 
     
    5656} 
    5757 
     58// List of checked out users 
    5859function p2checkinwidget_checkedout ( $args = array() ) { 
    5960     
    6061    $args = wp_parse_args( $args, array( 
    6162     
    62         'meta_key' => 'currently_checked_in', 
     63        'meta_key' => 'p2checkin_currently_checked_in', 
    6364        'meta_value' => false 
    6465         
     
    7879} 
    7980 
     81// List of checked in users 
    8082function p2checkinwidget_list_authors() { 
    8183    $users = p2checkinwidget_checkedin(); 
     
    9092        $item = '<li id="p2checkinwidget-' . $user->ID . '" class="checkedin">' . $item . '</li>'; 
    9193        $html .= $item; 
     94         
    9295    } 
    9396     
     
    111114 */ 
    112115function p2checkinwidget_user( $last_online_ts, $user ) { 
    113     $avatar = '<a class="user-img" href="' . get_author_posts_url( $user->ID, $user->user_nicename ) . '" title="' . esc_attr( sprintf(__("Posts by %s"), $user->display_name) ) . '">' . get_avatar( $user->user_email, 32 ) . '</a>'; 
     116    $avatar = '<a class="user-img" href="' . get_author_posts_url( $user->ID, $user->user_nicename ) . '" title="' . esc_attr( sprintf(__("Posts by %s"), $user->display_name) ) . '">' . get_avatar( $user->user_email, 52 ) . '</a>'; 
    114117    $name = $user->display_name; 
    115118    $link = '<p class="user-link"><a href="' . get_author_posts_url( $user->ID, $user->user_nicename ) . '" title="' . esc_attr( sprintf(__("Posts by %s"), $user->display_name) ) . '">' . $name . '</a></p>'; 
     
    117120    $link = apply_filters( 'p2checkinwidget_author_link', $link, $user ); 
    118121 
    119     $rwi_checkedin = get_user_meta( $user->ID, 'currently_checked_in', true ); 
    120     $rwi_checkedouttime = get_user_meta( $user->ID, 'time_checked_out', true ); 
     122    $rwi_checkedin = get_user_meta( $user->ID, 'p2checkin_currently_checked_in', true ); 
     123    $rwi_checkedouttime = get_user_meta( $user->ID, 'p2checkin_time_checked_out', true ); 
    121124    $timenow = current_time( 'timestamp', 1 ); 
    122     $minutes = 0.5; // how long to show someone has been gone 
     125    $minutes = 5; // how long to show someone has been gone 
    123126    $timetoshow = (60 * $minutes); 
     127     
     128    $p2checkin_totaltimedisplay = get_user_meta( $user->ID, 'p2checkin_totaltime', true ); 
     129    $p2time_readable = number_format( ( $p2checkin_totaltimedisplay / 60 / 60 ), 2, '.', '' ); 
    124130 
    125131    if ( $rwi_checkedin ) { 
    126132         
    127         $timein = get_user_meta( $user->ID , 'time_checked_in', true ); 
    128         $timephrase = '<p>Checked in for ' . human_time_diff( $timein, $timenow ) . '<p>'; 
     133        $timein = get_user_meta( $user->ID , 'p2checkin_time_checked_in', true ); 
     134        $timesofar = ( $timenow - $timein ); 
     135        $p2time_readable_temp = number_format( ( ( $timesofar + $p2checkin_totaltimedisplay ) / 60 / 60 ), 2, '.', '' ); 
     136        $timephrase = '<p><strong>Checked in for ' . human_time_diff( $timein, $timenow ) . '</strong></p><p class="minor">Total: ' . $p2time_readable_temp . ' hours<p>'; 
    129137         
    130138        // If there's data, woot 
     
    133141    } else if ( !($rwi_checkedin ) AND ( ( $timenow - $rwi_checkedouttime ) < $timetoshow ) )  { 
    134142         
    135         $timephrase = '<p>Left ' . human_time_diff( $rwi_checkedouttime, $timenow ) . ' ago.</p>'; 
     143        $timephrase = '<p><strong>Left ' . human_time_diff( $rwi_checkedouttime, $timenow ) . ' ago.</strong></p><p class="minor">Total: ' . $p2time_readable . ' hours</p>'; 
    136144         
    137145        // They left somewhat recently 
     
    155163         
    156164        // So we know they're in 
    157         update_user_meta( $current_user->ID , 'currently_checked_in', true ); 
     165        update_user_meta( $current_user->ID , 'p2checkin_currently_checked_in', true ); 
    158166         
    159167        // So we know what time they showed up 
    160         update_user_meta( $current_user->ID , 'time_checked_in', current_time( 'timestamp' , 1 ) ); 
     168        update_user_meta( $current_user->ID , 'p2checkin_time_checked_in', current_time( 'timestamp' , 1 ) ); 
    161169         
    162170    } else if ( $current_user->ID AND isset( $_GET[checkout] ) ) { 
    163171         
    164         // So we know they're out 
    165         update_user_meta( $current_user->ID , 'currently_checked_in', false ); 
    166          
    167         // So we know what time they left 
    168         update_user_meta( $current_user->ID, 'time_checked_out', current_time( 'timestamp', 1 ) ); 
    169          
    170     } 
    171      
    172     $nowin = get_user_meta( $current_user->ID, 'currently_checked_in', true ); 
     172        // Prevent cheatin' 
     173        $rwi_checkedin = get_user_meta( $current_user->ID, 'p2checkin_time_checked_in', true ); 
     174        $rwi_checkedouttime = get_user_meta( $current_user->ID, 'p2checkin_time_checked_out', true ); 
     175         
     176        if ( $rwi_checkedouttime > $rwi_checkedin ) { 
     177             
     178            echo '<p>Cheating? Tsk tsk.</p>'; 
     179         
     180        } else { 
     181             
     182            // So we know they're out 
     183            update_user_meta( $current_user->ID , 'p2checkin_currently_checked_in', false ); 
     184 
     185            // So we know what time they left 
     186            update_user_meta( $current_user->ID , 'p2checkin_time_checked_out', current_time( 'timestamp', 1 ) ); 
     187 
     188            // Keep a running total of checked in time. Why not? 
     189            $rwi_checkedouttime_realz = get_user_meta( $current_user->ID, 'p2checkin_time_checked_out', true ); 
     190            $p2checkin_timesofar = get_user_meta( $current_user->ID, 'p2checkin_totaltime', true ); 
     191            $p2checkin_sessiontime = ( $rwi_checkedouttime_realz - $rwi_checkedin ); 
     192            $p2checkin_timesofar += $p2checkin_sessiontime; 
     193 
     194            update_user_meta( $current_user->ID, 'p2checkin_totaltime', $p2checkin_timesofar ); 
     195             
     196        } 
     197         
     198    } 
     199     
     200    $nowin = get_user_meta( $current_user->ID, 'p2checkin_currently_checked_in', true ); 
    173201     
    174202    // Is anyone logged in? If not, make the button a log in button.     
     
    186214         
    187215    } 
    188      
     216         
    189217    return $buttonoutput; 
    190218     
     
    224252    wp_register_sidebar_widget( 'widget_p2checkinwidget', "Who's Checked In", 'widget_p2checkinwidget', array( 'description' => 'Display who has checked into the office (or wherever) via P2.') ); 
    225253} 
    226  
  • p2-check-in/trunk/readme.txt

    r563765 r563796  
    44Requires at least: 3.0 
    55Tested up to: 3.4 
    6 Stable tag: 0.2.1 
     6Stable tag: 0.3 
    77License: GPLv2 or later 
    88 
     
    1717The language in this plugin is purposefully left a big vague so you can use it for your own purposes. Checking in could mean literally checking into a building to show you're there (the purpose I developed the plugin for) or it could mean that you are simply available, and actively watching the P2. 
    1818 
    19 ### Kudos 
     19In addition, the total amount of time someone has logged when "checked in" is displayed 
     20 
     21#### Kudos 
    2022 
    2123Props to the Who's Online plugin for P2, since I cribbed a number of the elements from that plugin to make the development of mine go a bit faster. 
     
    3537== Changelog == 
    3638 
     39= 0.3 = 
     40* Feature: Total checked in time is now logged and displayed, by default, with the user list in the sidebar. Get competitive! 
     41* Also removed some more unused CSS. 
     42* Note: Unfortunately this release my end up checking users out if they're in at the time you upgrade. This is due to this release making the meta values uniform (with proper namespacing across the board). Ideally this will be the only release that resets anyone. 
     43 
    3744= 0.2.1 = 
    3845* Added kudos to the end of the description. 
Note: See TracChangeset for help on using the changeset viewer.