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

293 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.6 Plugin: WP-Print 2.40 |
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['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 print_style_options = document.getElementById("print_style").value;
106 if (print_style_options == 4) {
107 document.getElementById("print_style_custom").style.display = 'block';
108 } else {
109 if(document.getElementById("print_style_custom").style.display == 'block') {
110 document.getElementById("print_style_custom").style.display = 'none';
111 }
112 }
113 }
114 function print_default_templates(template) {
115 var default_template;
116 switch(template) {
117 case 'html':
118 default_template = '<a href="%PRINT_URL%" rel="nofollow" title="%PRINT_TEXT%">%PRINT_TEXT%</a>';
119 break;
120 case 'disclaimer':
121 default_template = '<?php echo js_escape(sprintf(__('Copyright &copy; %s %s. All rights reserved.', 'wp-print'), date('Y'), get_option('blogname'))); ?>';
122 break;
123 }
124 document.getElementById("print_template_" + template).value = default_template;
125 }
126 /* ]]> */
127 </script>
128 <?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.$text.'</p></div>'; } ?>
129 <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
130 <div class="wrap">
131 <?php screen_icon(); ?>
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 = plugins_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 echo '<p>';
159 if($print_icon == $filename) {
160 echo '<input type="radio" name="print_icon" value="'.$filename.'" checked="checked" />'."\n";
161 } else {
162 echo '<input type="radio" name="print_icon" value="'.$filename.'" />'."\n";
163 }
164 echo '&nbsp;&nbsp;&nbsp;';
165 echo '<img src="'.$print_icon_url.'/'.$filename.'" alt="'.$filename.'" />'."\n";
166 echo '&nbsp;&nbsp;&nbsp;('.$filename.')';
167 echo '</p>'."\n";
168 }
169 }
170 }
171 closedir($handle);
172 }
173 ?>
174 </td>
175 </tr>
176 <tr>
177 <th scope="row" valign="top"><?php _e('Print Text Link Style', 'wp-print'); ?></th>
178 <td>
179 <select name="print_style" id="print_style" size="1" onchange="check_print_style();">
180 <option value="1"<?php selected('1', $print_options['print_style']); ?>><?php _e('Print Icon With Text Link', 'wp-print'); ?></option>
181 <option value="2"<?php selected('2', $print_options['print_style']); ?>><?php _e('Print Icon Only', 'wp-print'); ?></option>
182 <option value="3"<?php selected('3', $print_options['print_style']); ?>><?php _e('Print Text Link Only', 'wp-print'); ?></option>
183 <option value="4"<?php selected('4', $print_options['print_style']); ?>><?php _e('Custom', 'wp-print'); ?></option>
184 </select>
185 <div id="print_style_custom" style="display: <?php if(intval($print_options['print_style']) == 4) { echo 'block'; } else { echo 'none'; } ?>; margin-top: 20px;">
186 <textarea rows="2" cols="80" name="print_html" id="print_template_html"><?php echo htmlspecialchars(stripslashes($print_options['print_html'])); ?></textarea><br />
187 <?php _e('HTML is allowed.', 'wp-print'); ?><br />
188 %PRINT_URL% - <?php _e('URL to the printable post/page.', 'wp-print'); ?><br />
189 %PRINT_TEXT% - <?php _e('Print text link of the post/page that you have typed in above.', 'wp-print'); ?><br />
190 %PRINT_ICON_URL% - <?php _e('URL to the print icon you have chosen above.', 'wp-print'); ?><br />
191 <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template', 'wp-print'); ?>" onclick="print_default_templates('html');" class="button" />
192 </div>
193 </td>
194 </tr>
195 </table>
196 <h3><?php _e('Print Options', 'wp-print'); ?></h3>
197 <table class="form-table">
198 <tr>
199 <th scope="row" valign="top"><?php _e('Print Comments?', 'wp-print'); ?></th>
200 <td>
201 <select name="print_comments" size="1">
202 <option value="1"<?php selected('1', $print_options['comments']); ?>><?php _e('Yes', 'wp-print'); ?></option>
203 <option value="0"<?php selected('0', $print_options['comments']); ?>><?php _e('No', 'wp-print'); ?></option>
204 </select>
205 </td>
206 </tr>
207 <tr>
208 <th scope="row" valign="top"><?php _e('Print Links?', 'wp-print'); ?></th>
209 <td>
210 <select name="print_links" size="1">
211 <option value="1"<?php selected('1', $print_options['links']); ?>><?php _e('Yes', 'wp-print'); ?></option>
212 <option value="0"<?php selected('0', $print_options['links']); ?>><?php _e('No', 'wp-print'); ?></option>
213 </select>
214 </td>
215 </tr>
216 <tr>
217 <th scope="row" valign="top"><?php _e('Print Images?', 'wp-print'); ?></th>
218 <td>
219 <select name="print_images" size="1">
220 <option value="1"<?php selected('1', $print_options['images']); ?>><?php _e('Yes', 'wp-print'); ?></option>
221 <option value="0"<?php selected('0', $print_options['images']); ?>><?php _e('No', 'wp-print'); ?></option>
222 </select>
223 </td>
224 </tr>
225 <tr>
226 <th scope="row" valign="top"><?php _e('Print Videos?', 'wp-print'); ?></th>
227 <td>
228 <select name="print_videos" size="1">
229 <option value="1"<?php selected('1', $print_options['videos']); ?>><?php _e('Yes', 'wp-print'); ?></option>
230 <option value="0"<?php selected('0', $print_options['videos']); ?>><?php _e('No', 'wp-print'); ?></option>
231 </select>
232 </td>
233 </tr>
234 <tr>
235 <th scope="row" valign="top">
236 <?php _e('Disclaimer/Copyright Text?', 'wp-print'); ?>
237 <br /><br />
238 <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template', 'wp-print'); ?>" onclick="print_default_templates('disclaimer');" class="button" />
239 </th>
240 <td>
241 <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 />
242 </td>
243 </tr>
244 </table>
245 <p class="submit">
246 <input type="submit" name="Submit" class="button" value="<?php _e('Save Changes', 'wp-print'); ?>" />
247 </p>
248 </div>
249 </form>
250 <p>&nbsp;</p>
251
252 <!-- Uninstall WP-Print -->
253 <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
254 <div class="wrap">
255 <h3><?php _e('Uninstall WP-Print', 'wp-print'); ?></h3>
256 <p>
257 <?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'); ?>
258 </p>
259 <p style="color: red">
260 <strong><?php _e('WARNING:', 'wp-print'); ?></strong><br />
261 <?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'); ?>
262 </p>
263 <p style="color: red">
264 <strong><?php _e('The following WordPress Options will be DELETED:', 'wp-print'); ?></strong><br />
265 </p>
266 <table class="widefat">
267 <thead>
268 <tr>
269 <th><?php _e('WordPress Options', 'wp-print'); ?></th>
270 </tr>
271 </thead>
272 <tr>
273 <td valign="top">
274 <ol>
275 <?php
276 foreach($print_settings as $settings) {
277 echo '<li>'.$settings.'</li>'."\n";
278 }
279 ?>
280 </ol>
281 </td>
282 </tr>
283 </table>
284 <p>&nbsp;</p>
285 <p style="text-align: center;">
286 <input type="checkbox" name="uninstall_print_yes" value="yes" />&nbsp;<?php _e('Yes', 'wp-print'); ?><br /><br />
287 <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'); ?>')" />
288 </p>
289 </div>
290 </form>
291 <?php
292 } // End switch($mode)
293 ?>