| 1 |
<?php |
| 2 |
/* |
| 3 |
+----------------------------------------------------------------+ |
| 4 |
| | |
| 5 |
| WordPress 2.1 Plugin: WP-Print 2.10 | |
| 6 |
| Copyright (c) 2007 Lester "GaMerZ" Chan | |
| 7 |
| | |
| 8 |
| File Written By: | |
| 9 |
| - Lester "GaMerZ" Chan | |
| 10 |
| - http://www.lesterchan.net | |
| 11 |
| | |
| 12 |
| File Information: | |
| 13 |
| - Print Options Page | |
| 14 |
| - wp-content/plugins/print/print-options.php | |
| 15 |
| | |
| 16 |
+----------------------------------------------------------------+ |
| 17 |
*/ |
| 18 |
|
| 19 |
|
| 20 |
### Variables Variables Variables |
| 21 |
$base_name = plugin_basename('print/print-options.php'); |
| 22 |
$base_page = 'admin.php?page='.$base_name; |
| 23 |
$id = intval($_GET['id']); |
| 24 |
|
| 25 |
### If Form Is Submitted |
| 26 |
if($_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 |
$update_print_queries = array(); |
| 37 |
$update_print_text = array(); |
| 38 |
$update_print_queries[] = update_option('print_options', $print_options); |
| 39 |
$update_print_text[] = __('Print Options', 'wp-print'); |
| 40 |
$i=0; |
| 41 |
$text = ''; |
| 42 |
foreach($update_print_queries as $update_print_query) { |
| 43 |
if($update_print_query) { |
| 44 |
$text .= '<font color="green">'.$update_print_text[$i].' '.__('Updated', 'wp-print').'</font><br />'; |
| 45 |
} |
| 46 |
$i++; |
| 47 |
} |
| 48 |
if(empty($text)) { |
| 49 |
$text = '<font color="red">'.__('No Print Option Updated', 'wp-print').'</font>'; |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
### Get Print Options |
| 54 |
$print_options = get_option('print_options'); |
| 55 |
?> |
| 56 |
<script type="text/javascript"> |
| 57 |
/* <![CDATA[*/ |
| 58 |
function check_print_style() { |
| 59 |
print_style_options = document.getElementById("print_style").value; |
| 60 |
if (print_style_options == 4) { |
| 61 |
document.getElementById("print_style_custom").style.display = 'block'; |
| 62 |
} else { |
| 63 |
if(document.getElementById("print_style_custom").style.display == 'block') { |
| 64 |
document.getElementById("print_style_custom").style.display = 'none'; |
| 65 |
} |
| 66 |
} |
| 67 |
} |
| 68 |
function print_default_templates(template) { |
| 69 |
var default_template; |
| 70 |
switch(template) { |
| 71 |
case 'html': |
| 72 |
default_template = '<a href="%PRINT_URL%" rel="nofollow" title="%PRINT_TEXT%">%PRINT_TEXT%</a>'; |
| 73 |
break; |
| 74 |
} |
| 75 |
document.getElementById("print_template_" + template).value = default_template; |
| 76 |
} |
| 77 |
/* ]]> */ |
| 78 |
</script> |
| 79 |
<?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.$text.'</p></div>'; } ?> |
| 80 |
<div class="wrap"> |
| 81 |
<h2><?php _e('Print Options', 'wp-print'); ?></h2> |
| 82 |
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> |
| 83 |
<fieldset class="options"> |
| 84 |
<legend><?php _e('Print Styles', 'wp-print'); ?></legend> |
| 85 |
<table width="100%" border="0" cellspacing="3" cellpadding="3"> |
| 86 |
<tr valign="top"> |
| 87 |
<th align="left" width="30%"><?php _e('Print Text Link For Post', 'wp-print'); ?></th> |
| 88 |
<td align="left"> |
| 89 |
<input type="text" name="print_post_text" value="<?php echo stripslashes($print_options['post_text']); ?>" size="30" /> |
| 90 |
</td> |
| 91 |
</tr> |
| 92 |
<tr valign="top"> |
| 93 |
<th align="left" width="30%"><?php _e('Print Text Link For Page', 'wp-print'); ?></th> |
| 94 |
<td align="left"> |
| 95 |
<input type="text" name="print_page_text" value="<?php echo stripslashes($print_options['page_text']); ?>" size="30" /> |
| 96 |
</td> |
| 97 |
</tr> |
| 98 |
<tr valign="top"> |
| 99 |
<th align="left" width="30%"><?php _e('Print Icon', 'wp-print'); ?></th> |
| 100 |
<td align="left"> |
| 101 |
<?php |
| 102 |
$print_icon = $print_options['print_icon']; |
| 103 |
$print_icon_url = get_option('siteurl').'/wp-content/plugins/print/images'; |
| 104 |
$print_icon_path = ABSPATH.'/wp-content/plugins/print/images'; |
| 105 |
if($handle = @opendir($print_icon_path)) { |
| 106 |
while (false !== ($filename = readdir($handle))) { |
| 107 |
if ($filename != '.' && $filename != '..') { |
| 108 |
if(is_file($print_icon_path.'/'.$filename)) { |
| 109 |
if($print_icon == $filename) { |
| 110 |
echo '<input type="radio" name="print_icon" value="'.$filename.'" checked="checked" />'."\n"; |
| 111 |
} else { |
| 112 |
echo '<input type="radio" name="print_icon" value="'.$filename.'" />'."\n"; |
| 113 |
} |
| 114 |
echo ' '; |
| 115 |
echo '<img src="'.$print_icon_url.'/'.$filename.'" alt="'.$filename.'" />'."\n"; |
| 116 |
echo ' ('.$filename.')'; |
| 117 |
echo '<br /><br />'."\n"; |
| 118 |
} |
| 119 |
} |
| 120 |
} |
| 121 |
closedir($handle); |
| 122 |
} |
| 123 |
?> |
| 124 |
</td> |
| 125 |
</tr> |
| 126 |
<tr valign="top"> |
| 127 |
<th align="left" width="30%"><?php _e('Print Text Link Style', 'wp-print'); ?></th> |
| 128 |
<td align="left"> |
| 129 |
<select name="print_style" id="print_style" size="1" onchange="check_print_style();"> |
| 130 |
<option value="1"<?php selected('1', $print_options['print_style']); ?>><?php _e('Print Icon With Text Link', 'wp-print'); ?></option> |
| 131 |
<option value="2"<?php selected('2', $print_options['print_style']); ?>><?php _e('Print Icon Only', 'wp-print'); ?></option> |
| 132 |
<option value="3"<?php selected('3', $print_options['print_style']); ?>><?php _e('Print Text Link Only', 'wp-print'); ?></option> |
| 133 |
<option value="4"<?php selected('4', $print_options['print_style']); ?>><?php _e('Custom', 'wp-print'); ?></option> |
| 134 |
</select> |
| 135 |
<div id="print_style_custom" style="display: <?php if(intval($print_options['print_style']) == 4) { echo 'block'; } else { echo 'none'; } ?>; margin-top: 20px;"> |
| 136 |
<textarea rows="2" cols="80" name="print_html" id="print_template_html"><?php echo htmlspecialchars(stripslashes($print_options['print_html'])); ?></textarea><br /> |
| 137 |
<?php _e('HTML is allowed.', 'wp-print'); ?><br /> |
| 138 |
%PRINT_URL% - <?php _e('URL to the printable post/page.', 'wp-print'); ?><br /> |
| 139 |
%PRINT_TEXT% - <?php _e('Print text link of the post/page that you have typed in above.', 'wp-print'); ?><br /> |
| 140 |
%PRINT_ICON_URL% - <?php _e('URL to the print icon you have chosen above.', 'wp-print'); ?><br /> |
| 141 |
<input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template', 'wp-print'); ?>" onclick="javascript: print_default_templates('html');" class="button" /> |
| 142 |
</div> |
| 143 |
</td> |
| 144 |
</tr> |
| 145 |
</table> |
| 146 |
</fieldset> |
| 147 |
<fieldset class="options"> |
| 148 |
<legend><?php _e('Print Options', 'wp-print'); ?></legend> |
| 149 |
<table width="100%" border="0" cellspacing="3" cellpadding="3"> |
| 150 |
<tr valign="top"> |
| 151 |
<th align="left" width="30%"><?php _e('Print Comments?', 'wp-print'); ?></th> |
| 152 |
<td align="left"> |
| 153 |
<select name="print_comments" size="1"> |
| 154 |
<option value="1"<?php selected('1', $print_options['comments']); ?>><?php _e('Yes', 'wp-print'); ?></option> |
| 155 |
<option value="0"<?php selected('0', $print_options['comments']); ?>><?php _e('No', 'wp-print'); ?></option> |
| 156 |
</select> |
| 157 |
</td> |
| 158 |
</tr> |
| 159 |
<tr valign="top"> |
| 160 |
<th align="left" width="30%"><?php _e('Print Links?', 'wp-print'); ?></th> |
| 161 |
<td align="left"> |
| 162 |
<select name="print_links" size="1"> |
| 163 |
<option value="1"<?php selected('1', $print_options['links']); ?>><?php _e('Yes', 'wp-print'); ?></option> |
| 164 |
<option value="0"<?php selected('0', $print_options['links']); ?>><?php _e('No', 'wp-print'); ?></option> |
| 165 |
</select> |
| 166 |
</td> |
| 167 |
</tr> |
| 168 |
<tr valign="top"> |
| 169 |
<th align="left" width="30%"><?php _e('Print Images?', 'wp-print'); ?></th> |
| 170 |
<td align="left"> |
| 171 |
<select name="print_images" size="1"> |
| 172 |
<option value="1"<?php selected('1', $print_options['images']); ?>><?php _e('Yes', 'wp-print'); ?></option> |
| 173 |
<option value="0"<?php selected('0', $print_options['images']); ?>><?php _e('No', 'wp-print'); ?></option> |
| 174 |
</select> |
| 175 |
</td> |
| 176 |
</tr> |
| 177 |
</table> |
| 178 |
</fieldset> |
| 179 |
<div align="center"> |
| 180 |
<input type="submit" name="Submit" class="button" value="<?php _e('Update Options', 'wp-print'); ?>" /> <input type="button" name="cancel" value="<?php _e('Cancel', 'wp-print'); ?>" class="button" onclick="javascript:history.go(-1)" /> |
| 181 |
</div> |
| 182 |
</form> |
| 183 |
</div> |