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

Revision 51863, 4.4 kB (checked in by GamerZ, 2 weeks ago)

Fixed Language For Russian Translation

Line 
1 <?php
2 /*
3 Plugin Name: WP-EMail Widget
4 Plugin URI: http://lesterchan.net/portfolio/programming/php/
5 Description: Adds a EMail Widget to display most emailed posts and/or pages on your sidebar. You will need to activate WP-EMail 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-EMail Widget
32 function widget_email_init() {
33     if (!function_exists('register_sidebar_widget')) {
34         return;
35     }
36
37     ### Function: WP-EMail Most EMailed Widget
38     function widget_email_most_emailed($args) {
39         extract($args);
40         $options = get_option('widget_email_most_emailed');
41         $title = htmlspecialchars(stripslashes($options['title']));       
42         if (function_exists('get_mostemailed')) {
43             echo $before_widget.$before_title.$title.$after_title;
44             echo '<ul>'."\n";
45             get_mostemailed($options['mode'], $options['limit'], $options['chars']);
46             echo '</ul>'."\n";
47             echo $after_widget;
48         }       
49     }
50
51     ### Function: WP-EMail Most EMailed Widget Options
52     function widget_email_most_emailed_options() {
53         $options = get_option('widget_email_most_emailed');
54         if (!is_array($options)) {
55             $options = array('title' => __('Most Emailed', 'wp-email'), 'mode' => 'post', 'limit' => 10, 'chars' => 200);
56         }
57         if ($_POST['most_emailed-submit']) {
58             $options['title'] = strip_tags($_POST['most_emailed-title']);
59             $options['mode'] = strip_tags($_POST['most_emailed-mode']);
60             $options['limit'] = intval($_POST['most_emailed-limit']);
61             $options['chars'] = intval($_POST['most_emailed-chars']);
62             update_option('widget_email_most_emailed', $options);
63         }
64         echo '<p style="text-align: left;"><label for="most_emailed-title">';
65         _e('Title', 'wp-email');
66         echo ': </label><input type="text" id="most_emailed-title" name="most_emailed-title" value="'.htmlspecialchars(stripslashes($options['title'])).'" /></p>'."\n";
67         echo '<p style="text-align: left;"><label for="most_emailed-mode">';
68         _e('Show Views For: ', 'wp-email');
69         echo ' </label>'."\n";
70         echo '<select id="most_emailed-mode" name="most_emailed-mode" size="1">'."\n";
71         echo '<option value="both"';
72         selected('both', $options['mode']);
73         echo '>';
74         _e('Posts &amp; Pages', 'wp-email');
75         echo '</option>'."\n";
76         echo '<option value="post"';
77         selected('post', $options['mode']);
78         echo '>';
79         _e('Posts', 'wp-email');
80         echo '</option>'."\n";
81         echo '<option value="page"';
82         selected('page', $options['mode']);
83         echo '>';
84         _e('Pages', 'wp-email');
85         echo '</option>'."\n";
86         echo '</select>&nbsp;&nbsp;';
87         _e('Only', 'wp-email');
88         echo '</p>'."\n";
89         echo '<p style="text-align: left;"><label for="most_emailed-limit">';
90         _e('Limit', 'wp-email');
91         echo ': </label><input type="text" id="most_emailed-limit" name="most_emailed-limit" value="'.intval($options['limit']).'" size="3" /></p>'."\n";
92         echo '<p style="text-align: left;"><label for="most_emailed-chars">';
93         _e('Post Title Length (Characters)', 'wp-email');
94         echo ': </label><input type="text" id="most_emailed-chars" name="most_emailed-chars" value="'.intval($options['chars']).'" size="5" />&nbsp;&nbsp;'."\n";
95         _e('(<strong>0</strong> to disable)', 'wp-email');
96         echo '</p>'."\n";
97         echo '<input type="hidden" id="most_emailed-submit" name="most_emailed-submit" value="1" />'."\n";
98     }
99     // Register Widgets
100     register_sidebar_widget(array('Most Emailed', 'wp-email'), 'widget_email_most_emailed');
101     register_widget_control(array('Most Emailed', 'wp-email'), 'widget_email_most_emailed_options', 400, 200);
102 }
103
104
105 ### Function: Load The WP-EMail Widget
106 add_action('plugins_loaded', 'widget_email_init')
107 ?>
Note: See TracBrowser for help on using the browser.