Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mospaw committed Apr 17, 2013
1 parent 35d7e33 commit 5ab15b5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 27 deletions.
50 changes: 26 additions & 24 deletions print-options.php
@@ -1,7 +1,7 @@
<?php
/*
* WordPress Plugin: WP-Print
* Copyright (c) 2012 Lester "GaMerZ" Chan
* Copyright (c) 2013 Lester "GaMerZ" Chan
*
* File Written By:
* - Lester "GaMerZ" Chan
Expand All @@ -24,6 +24,7 @@
### Form Processing
// Update Options
if(!empty($_POST['Submit'])) {
check_admin_referer('wp-print_options');
$print_options = array();
$print_options['post_text'] = addslashes(trim(wp_filter_kses($_POST['print_post_text'])));
$print_options['page_text'] = addslashes(trim(wp_filter_kses($_POST['print_page_text'])));
Expand Down Expand Up @@ -53,7 +54,7 @@
}
// Uninstall WP-Print
if(!empty($_POST['do'])) {
switch($_POST['do']) {
switch($_POST['do']) {
case __('UNINSTALL WP-Print', 'wp-print') :
if(trim($_POST['uninstall_print_yes']) == 'yes') {
echo '<div id="message" class="updated fade">';
Expand All @@ -71,7 +72,7 @@
}
}
echo '</p>';
echo '</div>';
echo '</div>';
$mode = 'end-UNINSTALL';
}
break;
Expand All @@ -83,7 +84,7 @@
// Deactivating WP-Print
case 'end-UNINSTALL':
$deactivate_url = 'plugins.php?action=deactivate&amp;plugin=wp-print/wp-print.php';
if(function_exists('wp_nonce_url')) {
if(function_exists('wp_nonce_url')) {
$deactivate_url = wp_nonce_url($deactivate_url, 'deactivate-plugin_wp-print/wp-print.php');
}
echo '<div class="wrap">';
Expand Down Expand Up @@ -122,9 +123,10 @@ function print_default_templates(template) {
</script>
<?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.$text.'</p></div>'; } ?>
<form method="post" action="<?php echo admin_url('admin.php?page='.plugin_basename(__FILE__)); ?>">
<div class="wrap">
<?php wp_nonce_field('wp-print_options'); ?>
<div class="wrap">
<?php screen_icon(); ?>
<h2><?php _e('Print Options', 'wp-print'); ?></h2>
<h2><?php _e('Print Options', 'wp-print'); ?></h2>
<h3><?php _e('Print Styles', 'wp-print'); ?></h3>
<table class="form-table">
<tr>
Expand All @@ -146,13 +148,13 @@ function print_default_templates(template) {
$print_icon = $print_options['print_icon'];
$print_icon_url = plugins_url('wp-print/images');
$print_icon_path = WP_PLUGIN_DIR.'/wp-print/images';
if($handle = @opendir($print_icon_path)) {
while (false !== ($filename = readdir($handle))) {
if($handle = @opendir($print_icon_path)) {
while (false !== ($filename = readdir($handle))) {
if ($filename != '.' && $filename != '..') {
if(is_file($print_icon_path.'/'.$filename)) {
echo '<p>';
if($print_icon == $filename) {
echo '<input type="radio" name="print_icon" value="'.$filename.'" checked="checked" />'."\n";
echo '<input type="radio" name="print_icon" value="'.$filename.'" checked="checked" />'."\n";
} else {
echo '<input type="radio" name="print_icon" value="'.$filename.'" />'."\n";
}
Expand All @@ -161,8 +163,8 @@ function print_default_templates(template) {
echo '&nbsp;&nbsp;&nbsp;('.$filename.')';
echo '</p>'."\n";
}
}
}
}
}
closedir($handle);
}
?>
Expand Down Expand Up @@ -199,54 +201,54 @@ function print_default_templates(template) {
</select>
</td>
</tr>
<tr>
<tr>
<th scope="row" valign="top"><?php _e('Print Links?', 'wp-print'); ?></th>
<td>
<select name="print_links" size="1">
<option value="1"<?php selected('1', $print_options['links']); ?>><?php _e('Yes', 'wp-print'); ?></option>
<option value="0"<?php selected('0', $print_options['links']); ?>><?php _e('No', 'wp-print'); ?></option>
</select>
</td>
</td>
</tr>
<tr>
<tr>
<th scope="row" valign="top"><?php _e('Print Images?', 'wp-print'); ?></th>
<td>
<select name="print_images" size="1">
<option value="1"<?php selected('1', $print_options['images']); ?>><?php _e('Yes', 'wp-print'); ?></option>
<option value="0"<?php selected('0', $print_options['images']); ?>><?php _e('No', 'wp-print'); ?></option>
</select>
</td>
</td>
</tr>
<tr>
<tr>
<th scope="row" valign="top"><?php _e('Print Videos?', 'wp-print'); ?></th>
<td>
<select name="print_videos" size="1">
<option value="1"<?php selected('1', $print_options['videos']); ?>><?php _e('Yes', 'wp-print'); ?></option>
<option value="0"<?php selected('0', $print_options['videos']); ?>><?php _e('No', 'wp-print'); ?></option>
</select>
</td>
</td>
</tr>
<tr>
<th scope="row" valign="top">
<tr>
<th scope="row" valign="top">
<?php _e('Disclaimer/Copyright Text?', 'wp-print'); ?>
<br /><br />
<input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template', 'wp-print'); ?>" onclick="print_default_templates('disclaimer');" class="button" />
</th>
<td>
<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 />
</td>
<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 />
</td>
</tr>
</table>
<p class="submit">
<input type="submit" name="Submit" class="button" value="<?php _e('Save Changes', 'wp-print'); ?>" />
</p>
</div>
</form>
</form>
<p>&nbsp;</p>

<!-- Uninstall WP-Print -->
<form method="post" action="<?php echo admin_url('admin.php?page='.plugin_basename(__FILE__)); ?>">
<div class="wrap">
<div class="wrap">
<h3><?php _e('Uninstall WP-Print', 'wp-print'); ?></h3>
<p>
<?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'); ?>
Expand Down Expand Up @@ -281,7 +283,7 @@ function print_default_templates(template) {
<input type="checkbox" name="uninstall_print_yes" value="yes" />&nbsp;<?php _e('Yes', 'wp-print'); ?><br /><br />
<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'); ?>')" />
</p>
</div>
</div>
</form>
<?php
} // End switch($mode)
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Expand Up @@ -3,7 +3,7 @@ Contributors: GamerZ, aaroncampbell
Donate link: http://lesterchan.net/site/donation/
Tags: print, printer, wp-print
Requires at least: 2.8
Tested up to: 3.3.2
Tested up to: 3.5.1
Stable tag: trunk

Displays a printable version of your WordPress blog's post/page.
Expand Down Expand Up @@ -104,6 +104,9 @@ if(function_exists('wp_print')) {

== Changelog ==

= 2.52 =
* FIXED: Added nonce to Options. Credits to Charlie Eriksen via Secunia SVCRP.

= 2.51 =
* NEW: Support for links that start with "//"
* FIXED: Unable to load WP-Print on Password Protected posts
Expand Down
5 changes: 3 additions & 2 deletions wp-print.php
Expand Up @@ -3,14 +3,15 @@
Plugin Name: WP-Print
Plugin URI: http://lesterchan.net/portfolio/programming/php/
Description: Displays a printable version of your WordPress blog's post/page.
Version: 2.51
Version: 2.52
Author: Lester 'GaMerZ' Chan
Author URI: http://lesterchan.net
Text Domain: wp-print
*/


/*
Copyright 2012 Lester Chan (email : lesterchan@gmail.com)
Copyright 2013 Lester Chan (email : lesterchan@gmail.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down

0 comments on commit 5ab15b5

Please sign in to comment.