PageRenderTime 43ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/justjs/wp-content/themes/atahualpa2/_plugins/upload-WP-2.5-2.6/wp-print/print-options.php

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