root/wp-useronline/trunk/wp-useronline-widget.php

Revision 49927, 3.8 kB (checked in by GamerZ, 4 weeks ago)

Fixed MYSQL Charset Issue

Line 
1 <?php
2 /*
3 Plugin Name: WP-UserOnline Widget
4 Plugin URI: http://lesterchan.net/portfolio/programming/php/
5 Description: Adds a UserOnline Widget to display users online from WP-UserOnline Plugin. You need to activate WP-UserOnline first.
6 Version: 2.31
7 Author: Lester 'GaMerZ' Chan
8 Author URI: http://lesterchan.net
9 */
10
11
12 /* 
13     Copyright 2008  Lester Chan  (email : lesterchan@gmail.com)
14
15     This program is free software; you can redistribute it and/or modify
16     it under the terms of the GNU General Public License as published by
17     the Free Software Foundation; either version 2 of the License, or
18     (at your option) any later version.
19
20     This program is distributed in the hope that it will be useful,
21     but WITHOUT ANY WARRANTY; without even the implied warranty of
22     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23     GNU General Public License for more details.
24
25     You should have received a copy of the GNU General Public License
26     along with this program; if not, write to the Free Software
27     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28 */
29
30
31 ### Function: Init WP-UserOnline Widget
32 function widget_useronline_init() {
33     if (!function_exists('register_sidebar_widget')) {
34         return;
35     }
36
37     ### Function: WP-UserOnline Widget
38     function widget_useronline($args) {
39         extract($args);
40         $options = get_option('widget_useronline');
41         $title = htmlspecialchars(stripslashes($options['title']));
42         echo $before_widget.$before_title.$title.$after_title;
43         if (function_exists('useronline')) {
44             echo '<ul>'."\n";
45             echo '<li><div id="useronline-count">';
46             get_useronline();
47             echo '</div></li>'."\n";
48             if(intval($options['display_usersbrowsingsite']) == 1) {
49                 echo '<li><div id="useronline-browsing-site">';
50                 get_users_browsing_site();
51                 echo '</div></li>'."\n";
52             }
53             echo '</ul>'."\n";
54         }
55         echo $after_widget;
56     }
57
58     ### Function: WP-UserOnline Widget Options
59     function widget_useronline_options() {
60         $options = get_option('widget_useronline');
61         if (!is_array($options)) {
62             $options = array('display_usersbrowsingsite' => '0', 'title' => __('UserOnline', 'wp-useronline'));
63         }
64         if ($_POST['useronline-submit']) {
65             $options['display_usersbrowsingsite'] = intval($_POST['useronline-usersbrowsingsite']);
66             $options['title'] = strip_tags($_POST['useronline-title']);
67             update_option('widget_useronline', $options);
68         }
69         echo '<p style="text-align: left;"><label for="useronline-title">'.__('Widget Title', 'wp-useronline').':</label>&nbsp;&nbsp;&nbsp;<input type="text" id="useronline-title" name="useronline-title" value="'.htmlspecialchars(stripslashes($options['title'])).'" />';
70         echo '<p style="text-align: center;">'.__('Display Users Browsing Site Under Users Online Count?', 'wp-useronline').'</p>'."\n";
71         echo '<p style="text-align: center;"><input type="radio" id="useronline-usersbrowsingsite-1" name="useronline-usersbrowsingsite" value="1"';
72         checked(1, intval($options['display_usersbrowsingsite']));
73         echo ' />&nbsp;<label for="useronline-usersbrowsingsite-1">'.__('Yes', 'wp-useronline').'</label>&nbsp;&nbsp;&nbsp;<input type="radio" id="useronline-usersbrowsingsite-0" name="useronline-usersbrowsingsite" value="0"';
74         checked(0, intval($options['display_usersbrowsingsite']));
75         echo ' />&nbsp;<label for="useronline-usersbrowsingsite-0">'.__('No', 'wp-useronline').'</label></p>'."\n";
76         echo '<input type="hidden" id="useronline-submit" name="useronline-submit" value="1" />'."\n";
77     }
78
79     // Register Widgets
80     register_sidebar_widget('UserOnline', 'widget_useronline');
81     register_widget_control('UserOnline', 'widget_useronline_options', 350, 120);
82 }
83
84
85 ### Function: Load The WP-UserOnline Widget
86 add_action('plugins_loaded', 'widget_useronline_init');
87 ?>
Note: See TracBrowser for help on using the browser.