PluginProbe
WP-Print / 2.50
WP-Print v2.50
3.0.0 trunk 1.00 2.00 2.01 2.02 2.03 2.04 2.05 2.06 2.10 2.11 2.20 2.30 2.31 2.40 2.50 2.52 2.53 2.54 2.55 2.56 2.57 2.57.1 2.57.2 All 29 releases
wp-print / print-options.php

print-options.php in WP-Print 2.50, at print-options.php

292 lines 12.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 +----------------------------------------------------------------+
4 | |
5 | WordPress 2.7 Plugin: WP-Print 2.50 |
6 | Copyright (c) 2008 Lester "GaMerZ" Chan |
7 | |
8 | File Written By: |
9 | - Lester "GaMerZ" Chan |
10 | - http://lesterchan.net |
11 | |
12 | File Information: |
13 | - Print Options Page |
14 | - wp-content/plugins/wp-print/print-options.php |
15 | |
16 +----------------------------------------------------------------+
17 */
18
19
20 ### Variables Variables Variables
21 $base_name = plugin_basename('wp-print/print-options.php');
22 $base_page = 'admin.php?page='.$base_name;
23 $id = intval($_GET['id']);
24 $mode = trim($_GET['mode']);
25 $print_settings = array('print_options');
26
27
28 ### Form Processing
29 // Update Options
30 if(!empty($_POST['Submit'])) {
31 $print_options = array();
32 $print_options['post_text'] = addslashes(trim(wp_filter_kses($_POST['print_post_text'])));
33 $print_options['page_text'] = addslashes(trim(wp_filter_kses($_POST['print_page_text'])));
34 $print_options['print_icon'] = trim($_POST['print_icon']);
35 $print_options['print_style'] = intval($_POST['print_style']);
36 $print_options['print_html'] = trim($_POST['print_html']);
37 $print_options['comments'] = intval($_POST['print_comments']);
38 $print_options['links'] = intval($_POST['print_links']);
39 $print_options['images'] = intval($_POST['print_images']);
40 $print_options['videos'] = intval($_POST['print_videos']);
41 $print_options['disclaimer'] = trim($_POST['print_disclaimer']);
42 $update_print_queries = array();
43 $update_print_text = array();
44 $update_print_queries[] = update_option('print_options', $print_options);
45 $update_print_text[] = __('Print Options', 'wp-print');
46 $i=0;
47 $text = '';
48 foreach($update_print_queries as $update_print_query) {
49 if($update_print_query) {
50 $text .= '<font color="green">'.$update_print_text[$i].' '.__('Updated', 'wp-print').'</font><br />';
51 }
52 $i++;
53 }
54 if(empty($text)) {
55 $text = '<font color="red">'.__('No Print Option Updated', 'wp-print').'</font>';
56 }
57 }
58 // Uninstall WP-Print
59 if(!empty($_POST['do'])) {
60 switch($_POST['do']) {
61 case __('UNINSTALL WP-Print', 'wp-print') :
62 if(trim($_POST['uninstall_print_yes']) == 'yes') {
63 echo '<div id="message" class="updated fade">';
64 echo '<p>';
65 foreach($print_settings as $setting) {
66 $delete_setting = delete_option($setting);
67 if($delete_setting) {
68 echo '<font color="green">';
69 printf(__('Setting Key \'%s\' has been deleted.', 'wp-print'), "<strong><em>{$setting}</em></strong>");
70 echo '</font><br />';
71 } else {
72 echo '<font color="red">';
73 printf(__('Error deleting Setting Key \'%s\'.', 'wp-print'), "<strong><em>{$setting}</em></strong>");
74 echo '</font><br />';
75 }
76 }
77 echo '</p>';
78 echo '</div>';
79 $mode = 'end-UNINSTALL';
80 }
81 break;
82 }
83 }
84
85 ### Determines Which Mode It Is
86 switch($mode) {
87 // Deactivating WP-Print
88 case 'end-UNINSTALL':
89 $deactivate_url = 'plugins.php?action=deactivate&amp;plugin=wp-print/wp-print.php';
90 if(function_exists('wp_nonce_url')) {
91 $deactivate_url = wp_nonce_url($deactivate_url, 'deactivate-plugin_wp-print/wp-print.php');
92 }
93 echo '<div class="wrap">';
94 echo '<h2>'.__('Uninstall WP-Print', 'wp-print').'</h2>';
95 echo '<p><strong>'.sprintf(__('<a href="%s">Click Here</a> To Finish The Uninstallation And WP-Print Will Be Deactivated Automatically.', 'wp-print'), $deactivate_url).'</strong></p>';
96 echo '</div>';
97 break;
98 // Main Page
99 default:
100 $print_options = get_option('print_options');
101 ?>
102 <script type="text/javascript">
103 /* <![CDATA[*/
104 function check_print_style() {
105 if (parseInt(jQuery("#print_style").val()) == 4) {
106 jQuery("#print_style_custom").show();
107 } else {
108 if(jQuery("#print_style_custom").is(":visible")) {
109 jQuery("#print_style_custom").hide();
110 }
111 }
112 }
113 function print_default_templates(template) {
114 var default_template;
115 switch(template) {
116 case 'html':
117 default_template = '<a href="%PRINT_URL%" rel="nofollow" title="%PRINT_TEXT%">%PRINT_TEXT%</a>';
118 break;
119 case 'disclaimer':
120 default_template = '<?php echo js_escape(sprintf(__('Copyright &copy; %s %s. All rights reserved.', 'wp-print'), date('Y'), get_option('blogname'))); ?>';
121 break;
122 }
123 jQuery("#print_template_" + template).val(default_template);
124 }
125 /* ]]> */
126 </script>
127 <?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.$text.'</p></div>'; } ?>
128 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?page=<?php echo plugin_basename(__FILE__); ?>">
129 <div class="wrap">
130 <?php screen_icon(); ?>
131 <h2><?php _e('Print Options', 'wp-print'); ?></h2>
132 <h3><?php _e('Print Styles', 'wp-print'); ?></h3>
133 <table class="form-table">
134 <tr>
135 <th scope="row" valign="top"><?php _e('Print Text Link For Post', 'wp-print'); ?></th>
136 <td>
137 <input type="text" name="print_post_text" value="<?php echo stripslashes($print_options['post_text']); ?>" size="30" />
138 </td>
139 </tr>
140 <tr>
141 <th scope="row" valign="top"><?php _e('Print Text Link For Page', 'wp-print'); ?></th>
142 <td>
143 <input type="text" name="print_page_text" value="<?php echo stripslashes($print_options['page_text']); ?>" size="30" />
144 </td>
145 </tr>
146 <tr>
147 <th scope="row" valign="top"><?php _e('Print Icon', 'wp-print'); ?></th>
148 <td>
149 <?php
150 $print_icon = $print_options['print_icon'];
151 $print_icon_url = plugins_url('wp-print/images');
152 $print_icon_path = WP_PLUGIN_DIR.'/wp-print/images';
153 if($handle = @opendir($print_icon_path)) {
154 while (false !== ($filename = readdir($handle))) {
155 if ($filename != '.' && $filename != '..') {
156 if(is_file($print_icon_path.'/'.$filename)) {
157 echo '<p>';
158 if($print_icon == $filename) {
159 echo '<input type="radio" name="print_icon" value="'.$filename.'" checked="checked" />'."\n";
160 } else {
161 echo '<input type="radio" name="print_icon" value="'.$filename.'" />'."\n";
162 }
163 echo '&nbsp;&nbsp;&nbsp;';
164 echo '<img src="'.$print_icon_url.'/'.$filename.'" alt="'.$filename.'" />'."\n";
165 echo '&nbsp;&nbsp;&nbsp;('.$filename.')';
166 echo '</p>'."\n";
167 }
168 }
169 }
170 closedir($handle);
171 }
172 ?>
173 </td>
174 </tr>
175 <tr>
176 <th scope="row" valign="top"><?php _e('Print Text Link Style', 'wp-print'); ?></th>
177 <td>
178 <select name="print_style" id="print_style" size="1" onchange="check_print_style();">
179 <option value="1"<?php selected('1', $print_options['print_style']); ?>><?php _e('Print Icon With Text Link', 'wp-print'); ?></option>
180 <option value="2"<?php selected('2', $print_options['print_style']); ?>><?php _e('Print Icon Only', 'wp-print'); ?></option>
181 <option value="3"<?php selected('3', $print_options['print_style']); ?>><?php _e('Print Text Link Only', 'wp-print'); ?></option>
182 <option value="4"<?php selected('4', $print_options['print_style']); ?>><?php _e('Custom', 'wp-print'); ?></option>
183 </select>
184 <div id="print_style_custom" style="display: <?php if(intval($print_options['print_style']) == 4) { echo 'block'; } else { echo 'none'; } ?>; margin-top: 20px;">
185 <textarea rows="2" cols="80" name="print_html" id="print_template_html"><?php echo htmlspecialchars(stripslashes($print_options['print_html'])); ?></textarea><br />
186 <?php _e('HTML is allowed.', 'wp-print'); ?><br />
187 %PRINT_URL% - <?php _e('URL to the printable post/page.', 'wp-print'); ?><br />
188 %PRINT_TEXT% - <?php _e('Print text link of the post/page that you have typed in above.', 'wp-print'); ?><br />
189 %PRINT_ICON_URL% - <?php _e('URL to the print icon you have chosen above.', 'wp-print'); ?><br />
190 <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template', 'wp-print'); ?>" onclick="print_default_templates('html');" class="button" />
191 </div>
192 </td>
193 </tr>
194 </table>
195 <h3><?php _e('Print Options', 'wp-print'); ?></h3>
196 <table class="form-table">
197 <tr>
198 <th scope="row" valign="top"><?php _e('Print Comments?', 'wp-print'); ?></th>
199 <td>
200 <select name="print_comments" size="1">
201 <option value="1"<?php selected('1', $print_options['comments']); ?>><?php _e('Yes', 'wp-print'); ?></option>
202 <option value="0"<?php selected('0', $print_options['comments']); ?>><?php _e('No', 'wp-print'); ?></option>
203 </select>
204 </td>
205 </tr>
206 <tr>
207 <th scope="row" valign="top"><?php _e('Print Links?', 'wp-print'); ?></th>
208 <td>
209 <select name="print_links" size="1">
210 <option value="1"<?php selected('1', $print_options['links']); ?>><?php _e('Yes', 'wp-print'); ?></option>
211 <option value="0"<?php selected('0', $print_options['links']); ?>><?php _e('No', 'wp-print'); ?></option>
212 </select>
213 </td>
214 </tr>
215 <tr>
216 <th scope="row" valign="top"><?php _e('Print Images?', 'wp-print'); ?></th>
217 <td>
218 <select name="print_images" size="1">
219 <option value="1"<?php selected('1', $print_options['images']); ?>><?php _e('Yes', 'wp-print'); ?></option>
220 <option value="0"<?php selected('0', $print_options['images']); ?>><?php _e('No', 'wp-print'); ?></option>
221 </select>
222 </td>
223 </tr>
224 <tr>
225 <th scope="row" valign="top"><?php _e('Print Videos?', 'wp-print'); ?></th>
226 <td>
227 <select name="print_videos" size="1">
228 <option value="1"<?php selected('1', $print_options['videos']); ?>><?php _e('Yes', 'wp-print'); ?></option>
229 <option value="0"<?php selected('0', $print_options['videos']); ?>><?php _e('No', 'wp-print'); ?></option>
230 </select>
231 </td>
232 </tr>
233 <tr>
234 <th scope="row" valign="top">
235 <?php _e('Disclaimer/Copyright Text?', 'wp-print'); ?>
236 <br /><br />
237 <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template', 'wp-print'); ?>" onclick="print_default_templates('disclaimer');" class="button" />
238 </th>
239 <td>
240 <textarea rows="2" cols="80" name="print_disclaimer" id="print_template_disclaimer"><?php echo htmlspecialchars(stripslashes($print_options['disclaimer'])); ?></textarea><br /><?php _e('HTML is allowed.', 'wp-print'); ?><br />
241 </td>
242 </tr>
243 </table>
244 <p class="submit">
245 <input type="submit" name="Submit" class="button" value="<?php _e('Save Changes', 'wp-print'); ?>" />
246 </p>
247 </div>
248 </form>
249 <p>&nbsp;</p>
250
251 <!-- Uninstall WP-Print -->
252 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?page=<?php echo plugin_basename(__FILE__); ?>">
253 <div class="wrap">
254 <h3><?php _e('Uninstall WP-Print', 'wp-print'); ?></h3>
255 <p>
256 <?php _e('Deactivating WP-Print plugin does not remove any data that may have been created, such as the print options. To completely remove this plugin, you can uninstall it here.', 'wp-print'); ?>
257 </p>
258 <p style="color: red">
259 <strong><?php _e('WARNING:', 'wp-print'); ?></strong><br />
260 <?php _e('Once uninstalled, this cannot be undone. You should use a Database Backup plugin of WordPress to back up all the data first.', 'wp-print'); ?>
261 </p>
262 <p style="color: red">
263 <strong><?php _e('The following WordPress Options will be DELETED:', 'wp-print'); ?></strong><br />
264 </p>
265 <table class="widefat">
266 <thead>
267 <tr>
268 <th><?php _e('WordPress Options', 'wp-print'); ?></th>
269 </tr>
270 </thead>
271 <tr>
272 <td valign="top">
273 <ol>
274 <?php
275 foreach($print_settings as $settings) {
276 echo '<li>'.$settings.'</li>'."\n";
277 }
278 ?>
279 </ol>
280 </td>
281 </tr>
282 </table>
283 <p>&nbsp;</p>
284 <p style="text-align: center;">
285 <input type="checkbox" name="uninstall_print_yes" value="yes" />&nbsp;<?php _e('Yes', 'wp-print'); ?><br /><br />
286 <input type="submit" name="do" value="<?php _e('UNINSTALL WP-Print', 'wp-print'); ?>" class="button" onclick="return confirm('<?php _e('You Are About To Uninstall WP-Print From WordPress.\nThis Action Is Not Reversible.\n\n Choose [Cancel] To Stop, [OK] To Uninstall.', 'wp-print'); ?>')" />
287 </p>
288 </div>
289 </form>
290 <?php
291 } // End switch($mode)
292 ?>