| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
function widget_email_init() { |
|---|
| 33 |
if (!function_exists('register_sidebar_widget')) { |
|---|
| 34 |
return; |
|---|
| 35 |
} |
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 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 |
|
|---|
| 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 & 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> '; |
|---|
| 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" /> '."\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 |
|
|---|
| 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 |
|
|---|
| 106 |
add_action('plugins_loaded', 'widget_email_init') |
|---|
| 107 |
?> |
|---|