PluginProbe
WP-Print / 2.31
WP-Print v2.31
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.31, at print-options.php

301 lines 12.7 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.5 Plugin: WP-Print 2.31 |
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($_POST['print_post_text']));
33 $print_options['page_text'] = addslashes(trim($_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['text_direction'] = trim($_POST['print_text_direction']);
42 $print_options['disclaimer'] = trim($_POST['print_disclaimer']);
43 $update_print_queries = array();
44 $update_print_text = array();
45 $update_print_queries[] = update_option('print_options', $print_options);
46 $update_print_text[] = __('Print Options', 'wp-print');
47 $i=0;
48 $text = '';
49 foreach($update_print_queries as $update_print_query) {
50 if($update_print_query) {
51 $text .= '<font color="green">'.$update_print_text[$i].' '.__('Updated', 'wp-print').'</font><br />';
52 }
53 $i++;
54 }
55 if(empty($text)) {
56 $text = '<font color="red">'.__('No Print Option Updated', 'wp-print').'</font>';
57 }
58 }
59 // Uninstall WP-Print
60 if(!empty($_POST['do'])) {
61 switch($_POST['do']) {
62 case __('UNINSTALL WP-Print', 'wp-print') :
63 if(trim($_POST['uninstall_print_yes']) == 'yes') {
64 echo '<div id="message" class="updated fade">';
65 echo '<p>';
66 foreach($print_settings as $setting) {
67 $delete_setting = delete_option($setting);
68 if($delete_setting) {
69 echo '<font color="green">';
70 printf(__('Setting Key \'%s\' has been deleted.', 'wp-print'), "<strong><em>{$setting}</em></strong>");
71 echo '</font><br />';
72 } else {
73 echo '<font color="red">';
74 printf(__('Error deleting Setting Key \'%s\'.', 'wp-print'), "<strong><em>{$setting}</em></strong>");
75 echo '</font><br />';
76 }
77 }
78 echo '</p>';
79 echo '</div>';
80 $mode = 'end-UNINSTALL';
81 }
82 break;
83 }
84 }
85
86 ### Determines Which Mode It Is
87 switch($mode) {
88 // Deactivating WP-Print
89 case 'end-UNINSTALL':
90 $deactivate_url = 'plugins.php?action=deactivate&amp;plugin=wp-print/wp-print.php';
91 if(function_exists('wp_nonce_url')) {
92 $deactivate_url = wp_nonce_url($deactivate_url, 'deactivate-plugin_wp-print/wp-print.php');
93 }
94 echo '<div class="wrap">';
95 echo '<h2>'.__('Uninstall WP-Print', 'wp-print').'</h2>';
96 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>';
97 echo '</div>';
98 break;
99 // Main Page
100 default:
101 $print_options = get_option('print_options');
102 ?>
103 <script type="text/javascript">
104 /* <![CDATA[*/
105 function check_print_style() {
106 print_style_options = document.getElementById("print_style").value;
107 if (print_style_options == 4) {
108 document.getElementById("print_style_custom").style.display = 'block';
109 } else {
110 if(document.getElementById("print_style_custom").style.display == 'block') {
111 document.getElementById("print_style_custom").style.display = 'none';
112 }
113 }
114 }
115 function print_default_templates(template) {
116 var default_template;
117 switch(template) {
118 case 'html':
119 default_template = '<a href="%PRINT_URL%" rel="nofollow" title="%PRINT_TEXT%">%PRINT_TEXT%</a>';
120 break;
121 case 'disclaimer':
122 default_template = '<?php echo js_escape(sprintf(__('Copyright &copy; %s %s. All rights reserved.', 'wp-print'), date('Y'), get_option('blogname'))); ?>';
123 break;
124 }
125 document.getElementById("print_template_" + template).value = default_template;
126 }
127 /* ]]> */
128 </script>
129 <?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.$text.'</p></div>'; } ?>
130 <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
131 <div class="wrap">
132 <h2><?php _e('Print Options', 'wp-print'); ?></h2>
133 <h3><?php _e('Print Styles', 'wp-print'); ?></h3>
134 <table class="form-table">
135 <tr>
136 <th scope="row" valign="top"><?php _e('Print Text Link For Post', 'wp-print'); ?></th>
137 <td>
138 <input type="text" name="print_post_text" value="<?php echo stripslashes($print_options['post_text']); ?>" size="30" />
139 </td>
140 </tr>
141 <tr>
142 <th scope="row" valign="top"><?php _e('Print Text Link For Page', 'wp-print'); ?></th>
143 <td>
144 <input type="text" name="print_page_text" value="<?php echo stripslashes($print_options['page_text']); ?>" size="30" />
145 </td>
146 </tr>
147 <tr>
148 <th scope="row" valign="top"><?php _e('Print Icon', 'wp-print'); ?></th>
149 <td>
150 <?php
151 $print_icon = $print_options['print_icon'];
152 $print_icon_url =WP_PLUGIN_URL.'/wp-print/images';
153 $print_icon_path = WP_PLUGIN_DIR.'/wp-print/images';
154 if($handle = @opendir($print_icon_path)) {
155 while (false !== ($filename = readdir($handle))) {
156 if ($filename != '.' && $filename != '..') {
157 if(is_file($print_icon_path.'/'.$filename)) {
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 '<br /><br />'."\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"><?php _e('Text Direction?', 'wp-print'); ?></th>
235 <td>
236 <select name="print_text_direction" size="1">
237 <option value="ltr"<?php selected('ltr', $print_options['text_direction']); ?>><?php _e('Left To Right', 'wp-print'); ?></option>
238 <option value="rtl"<?php selected('rtl', $print_options['text_direction']); ?>><?php _e('Right To Left', 'wp-print'); ?></option>
239 </select>
240 </td>
241 </tr>
242 <tr>
243 <th scope="row" valign="top">
244 <?php _e('Disclaimer/Copyright Text?', 'wp-print'); ?>
245 <br /><br />
246 <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template', 'wp-print'); ?>" onclick="print_default_templates('disclaimer');" class="button" />
247 </th>
248 <td>
249 <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 />
250 </td>
251 </tr>
252 </table>
253 <p class="submit">
254 <input type="submit" name="Submit" class="button" value="<?php _e('Save Changes', 'wp-print'); ?>" />
255 </p>
256 </div>
257 </form>
258 <p>&nbsp;</p>
259
260 <!-- Uninstall WP-Print -->
261 <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
262 <div class="wrap">
263 <h2><?php _e('Uninstall WP-Print', 'wp-print'); ?></h2>
264 <p style="text-align: left;">
265 <?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'); ?>
266 </p>
267 <p style="text-align: left; color: red">
268 <strong><?php _e('WARNING:', 'wp-print'); ?></strong><br />
269 <?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'); ?>
270 </p>
271 <p style="text-align: left; color: red">
272 <strong><?php _e('The following WordPress Options will be DELETED:', 'wp-print'); ?></strong><br />
273 </p>
274 <table class="widefat">
275 <thead>
276 <tr>
277 <th><?php _e('WordPress Options', 'wp-print'); ?></th>
278 </tr>
279 </thead>
280 <tr>
281 <td valign="top">
282 <ol>
283 <?php
284 foreach($print_settings as $settings) {
285 echo '<li>'.$settings.'</li>'."\n";
286 }
287 ?>
288 </ol>
289 </td>
290 </tr>
291 </table>
292 <p>&nbsp;</p>
293 <p style="text-align: center;">
294 <input type="checkbox" name="uninstall_print_yes" value="yes" />&nbsp;<?php _e('Yes', 'wp-print'); ?><br /><br />
295 <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'); ?>')" />
296 </p>
297 </div>
298 </form>
299 <?php
300 } // End switch($mode)
301 ?>