Version Description
- Improved error checking.
- Improved customization options for download text.
- Added option to override default browser behavior for PDF links (force download).
- Added option to reset options to defaults.
Download this release
Release Info
Developer | k3davis |
Plugin | Google Doc Embedder |
Version | 1.5 |
Comparing to | |
See all releases |
Code changes from version 1.0.3 to 1.5
- functions.php +106 -0
- gviewer.php +49 -32
- options.php +67 -16
- pdf.php +49 -0
- readme.txt +7 -1
- screenshot-2.png +0 -0
- uninstall.php +3 -3
functions.php
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function getDefaults() {
|
4 |
+
// set global default settings
|
5 |
+
$defaults = array(
|
6 |
+
"gde_default_width" => "600",
|
7 |
+
"gde_default_height" => "500",
|
8 |
+
"gde_show_dl" => 1,
|
9 |
+
"gde_link_text" => "Download (%FT, %FS)",
|
10 |
+
"gde_link_pos" => "below",
|
11 |
+
"gde_link_func" => "default"
|
12 |
+
);
|
13 |
+
|
14 |
+
return $defaults;
|
15 |
+
}
|
16 |
+
|
17 |
+
function validLink($link) {
|
18 |
+
|
19 |
+
$urlregex = "^https?\:\/\/([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)?[a-z0-9+\$_-]+(\.[a-z0-9+\$_-]+)*(\:[0-9]{2,5})?(\/([a-z0-9+\$_-]\.?)+)*\/?(\?[a-z+&\$_.-][a-z0-9;:@/&%=+\$_.-]*)?(#[a-z_.-][a-z0-9+\$_.-]*)?\$";
|
20 |
+
|
21 |
+
if (eregi($urlregex, $link)) {
|
22 |
+
return true;
|
23 |
+
} else {
|
24 |
+
return false;
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
function validType($link, $exts) {
|
29 |
+
|
30 |
+
if(preg_match("/($exts)$/i",$link)){
|
31 |
+
return true;
|
32 |
+
} else {
|
33 |
+
return false;
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
+
function validUrl($url) {
|
38 |
+
|
39 |
+
// checks for existence and returns filesize
|
40 |
+
$handle = curl_init($url);
|
41 |
+
if (false === $handle)
|
42 |
+
{
|
43 |
+
return false;
|
44 |
+
}
|
45 |
+
curl_setopt($handle, CURLOPT_HEADER, true);
|
46 |
+
curl_setopt($handle, CURLOPT_FAILONERROR, true);
|
47 |
+
curl_setopt($handle, CURLOPT_HTTPHEADER, Array("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15") ); // needed for some sites (such as digg.com)
|
48 |
+
curl_setopt($handle, CURLOPT_NOBODY, true);
|
49 |
+
curl_setopt($handle, CURLOPT_FOLLOWLOCATION, true); // only useful in case of redirects
|
50 |
+
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
|
51 |
+
$data = curl_exec($handle);
|
52 |
+
curl_close($handle);
|
53 |
+
|
54 |
+
$contentLength = "Unknown";
|
55 |
+
if (preg_match('/Content-Length: (\d+)/', $data, $matches)) {
|
56 |
+
$contentLength = (int)$matches[1];
|
57 |
+
}
|
58 |
+
return $contentLength;
|
59 |
+
}
|
60 |
+
|
61 |
+
function splitFilename($filename) {
|
62 |
+
$pos = strrpos($filename, '.');
|
63 |
+
if ($pos === false)
|
64 |
+
{ // dot is not found in the filename
|
65 |
+
return array($filename, ''); // no extension
|
66 |
+
}
|
67 |
+
else
|
68 |
+
{
|
69 |
+
$basename = substr($filename, 0, $pos);
|
70 |
+
$extension = strtoupper(substr($filename, $pos+1));
|
71 |
+
return array($basename, $extension);
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
function formatBytes($bytes, $precision = 2) {
|
76 |
+
$units = array('B', 'KB', 'MB', 'GB', 'TB');
|
77 |
+
|
78 |
+
$bytes = max($bytes, 0);
|
79 |
+
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
|
80 |
+
$pow = min($pow, count($units) - 1);
|
81 |
+
|
82 |
+
$bytes /= pow(1024, $pow);
|
83 |
+
|
84 |
+
return round($bytes, $precision) . '' . $units[$pow];
|
85 |
+
}
|
86 |
+
|
87 |
+
function sanitizeOpt($value) {
|
88 |
+
$value = ereg_replace('[^0-9]+', '', $value);
|
89 |
+
return $value;
|
90 |
+
}
|
91 |
+
|
92 |
+
function getPluginUrl() {
|
93 |
+
// this is a backwards-compatibility function for WP 2.5
|
94 |
+
if (!function_exists('plugins_url')) {
|
95 |
+
return get_option('siteurl') . '/wp-content/plugins/' . plugin_basename(dirname(__FILE__));
|
96 |
+
}
|
97 |
+
|
98 |
+
return plugins_url(plugin_basename(dirname(__FILE__)));
|
99 |
+
}
|
100 |
+
|
101 |
+
|
102 |
+
function shortUrl($u) {
|
103 |
+
return file_get_contents('http://tinyurl.com/api-create.php?url='.$u);
|
104 |
+
}
|
105 |
+
|
106 |
+
?>
|
gviewer.php
CHANGED
@@ -5,7 +5,7 @@ Plugin Name: Google Doc Embedder
|
|
5 |
Plugin URI: http://wordpress.org/extend/plugins/google-document-embedder/
|
6 |
Description: Lets you embed PDF files and PowerPoint presentations in a page or post using the Google Document Viewer.
|
7 |
Author: Kevin Davis
|
8 |
-
Version: 1.
|
9 |
*/
|
10 |
|
11 |
/* Copyright 2009 Kevin Davis. E-mail: kev@tnw.org
|
@@ -24,12 +24,13 @@ Version: 1.0.3
|
|
24 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
25 |
*/
|
26 |
|
27 |
-
|
|
|
28 |
|
29 |
// usage: [gview file="http://path.to/file.pdf" save="1" width="600" height="500"]
|
30 |
function gviewer_func($atts) {
|
31 |
|
32 |
-
//
|
33 |
$dl = get_option('gde_show_dl');
|
34 |
$wd = get_option('gde_default_width');
|
35 |
$ht = get_option('gde_default_height');
|
@@ -49,54 +50,70 @@ function gviewer_func($atts) {
|
|
49 |
$code = "\n<!-- GDE EMBED ERROR: invalid URL, please use fully qualified URL -->\n";
|
50 |
} elseif (!validType($file,$exts)) {
|
51 |
$code = "\n<!-- GDE EMBED ERROR: unsupported file type -->\n";
|
|
|
|
|
52 |
} else {
|
53 |
-
|
|
|
|
|
|
|
54 |
$code=<<<HERE
|
55 |
-
<iframe src="http://docs.google.com/gview?url=%U%&embedded=true" style="width:%W%px; height:%H%px;" frameborder="0"></iframe
|
56 |
HERE;
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
$code = str_replace("%U%", $file, $code);
|
59 |
$code = str_replace("%W%", $width, $code);
|
60 |
$code = str_replace("%H%", $height, $code);
|
61 |
-
|
62 |
-
$code
|
63 |
-
|
64 |
|
65 |
}
|
66 |
|
67 |
return $code;
|
68 |
}
|
69 |
|
70 |
-
function validLink($link) {
|
71 |
-
|
72 |
-
$urlregex = "^https?\:\/\/([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)?[a-z0-9+\$_-]+(\.[a-z0-9+\$_-]+)*(\:[0-9]{2,5})?(\/([a-z0-9+\$_-]\.?)+)*\/?(\?[a-z+&\$_.-][a-z0-9;:@/&%=+\$_.-]*)?(#[a-z_.-][a-z0-9+\$_.-]*)?\$";
|
73 |
-
|
74 |
-
if (eregi($urlregex, $link)) {
|
75 |
-
return true;
|
76 |
-
} else {
|
77 |
-
return false;
|
78 |
-
}
|
79 |
-
}
|
80 |
-
|
81 |
-
function validType($link, $exts) {
|
82 |
-
|
83 |
-
if(preg_match("/($exts)$/i",$link)){
|
84 |
-
return true;
|
85 |
-
} else {
|
86 |
-
return false;
|
87 |
-
}
|
88 |
-
}
|
89 |
-
|
90 |
// activate plugin
|
91 |
register_activation_hook( __FILE__, 'gde_activate');
|
92 |
function gde_activate() {
|
93 |
global $wpdb;
|
94 |
|
95 |
// initial options
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
}
|
101 |
|
102 |
// add an option page
|
5 |
Plugin URI: http://wordpress.org/extend/plugins/google-document-embedder/
|
6 |
Description: Lets you embed PDF files and PowerPoint presentations in a page or post using the Google Document Viewer.
|
7 |
Author: Kevin Davis
|
8 |
+
Version: 1.5
|
9 |
*/
|
10 |
|
11 |
/* Copyright 2009 Kevin Davis. E-mail: kev@tnw.org
|
24 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
25 |
*/
|
26 |
|
27 |
+
include_once('wpframe.php');
|
28 |
+
include_once('functions.php');
|
29 |
|
30 |
// usage: [gview file="http://path.to/file.pdf" save="1" width="600" height="500"]
|
31 |
function gviewer_func($atts) {
|
32 |
|
33 |
+
// current settings
|
34 |
$dl = get_option('gde_show_dl');
|
35 |
$wd = get_option('gde_default_width');
|
36 |
$ht = get_option('gde_default_height');
|
50 |
$code = "\n<!-- GDE EMBED ERROR: invalid URL, please use fully qualified URL -->\n";
|
51 |
} elseif (!validType($file,$exts)) {
|
52 |
$code = "\n<!-- GDE EMBED ERROR: unsupported file type -->\n";
|
53 |
+
} elseif (!$fsize = validUrl($file)) {
|
54 |
+
$code = "\n<!-- GDE EMBED ERROR: file not found -->\n";
|
55 |
} else {
|
56 |
+
$fn = basename($file);
|
57 |
+
$fnp = splitFilename($fn);
|
58 |
+
$fsize = formatBytes($fsize);
|
59 |
+
|
60 |
$code=<<<HERE
|
61 |
+
<iframe src="http://docs.google.com/gview?url=%U%&embedded=true" style="width:%W%px; height:%H%px;" frameborder="0" class="gde-frame"></iframe>\n
|
62 |
HERE;
|
63 |
|
64 |
+
if ($save == "1") {
|
65 |
+
|
66 |
+
$dlMethod = get_option('gde_link_func');
|
67 |
+
if ($fnp[1] == "PDF") {
|
68 |
+
if ($dlMethod == "force" or $dlMethod == "force-mask") {
|
69 |
+
$dlFile = getPluginUrl();
|
70 |
+
$fileParts = parse_url($file);
|
71 |
+
$fileStr = str_replace($fileParts['scheme']."://","",$file);
|
72 |
+
$dlFile .= "/pdf.php?file=".$fileStr."&dl=1&fn=".$fn;
|
73 |
+
$target = "_self";
|
74 |
+
} elseif ($dlMethod == "default") {
|
75 |
+
$dlFile = $file;
|
76 |
+
$target = "_blank";
|
77 |
+
}
|
78 |
+
if ($dlMethod == "force-mask") {
|
79 |
+
$dlFile = shortUrl($dlFile);
|
80 |
+
}
|
81 |
+
|
82 |
+
} else {
|
83 |
+
$dlFile = $file;
|
84 |
+
$target = "_blank";
|
85 |
+
}
|
86 |
+
$linkcode = "<p class=\"gde-link\"><a href=\"$dlFile\" target=\"$target\">$txt</a></p>";
|
87 |
+
|
88 |
+
if (get_option('gde_link_pos') == "above") {
|
89 |
+
$code = $linkcode . '' . $code;
|
90 |
+
} else {
|
91 |
+
$code = $code . '' . $linkcode;
|
92 |
+
}
|
93 |
+
}
|
94 |
+
|
95 |
$code = str_replace("%U%", $file, $code);
|
96 |
$code = str_replace("%W%", $width, $code);
|
97 |
$code = str_replace("%H%", $height, $code);
|
98 |
+
$code = str_replace("%FN", $fn, $code);
|
99 |
+
$code = str_replace("%FT", $fnp[1], $code);
|
100 |
+
$code = str_replace("%FS", $fsize, $code);
|
101 |
|
102 |
}
|
103 |
|
104 |
return $code;
|
105 |
}
|
106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
// activate plugin
|
108 |
register_activation_hook( __FILE__, 'gde_activate');
|
109 |
function gde_activate() {
|
110 |
global $wpdb;
|
111 |
|
112 |
// initial options
|
113 |
+
$defaults = getDefaults();
|
114 |
+
foreach($defaults as $set => $val) {
|
115 |
+
add_option($set, $val);
|
116 |
+
}
|
117 |
}
|
118 |
|
119 |
// add an option page
|
options.php
CHANGED
@@ -1,19 +1,46 @@
|
|
1 |
<?php
|
2 |
-
|
|
|
3 |
|
4 |
-
if(isset($_REQUEST['
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
if(isset($_POST['gde_show_dl'])) {
|
6 |
update_option('gde_show_dl', 1);
|
7 |
} else {
|
8 |
update_option('gde_show_dl', 0);
|
9 |
}
|
10 |
if(isset($_POST['gde_default_width'])) {
|
11 |
-
|
|
|
12 |
}
|
13 |
if(isset($_POST['gde_default_height'])) {
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
15 |
}
|
16 |
-
if(isset($_POST['
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
showMessage("Options updated");
|
18 |
}
|
19 |
?>
|
@@ -26,7 +53,7 @@ if(isset($_REQUEST['submit']) and $_REQUEST['submit']) {
|
|
26 |
<table class="form-table">
|
27 |
<tr valign="top">
|
28 |
<td colspan="2"><strong>Global Viewer Size</strong><br/>
|
29 |
-
|
30 |
</tr>
|
31 |
<tr valign="top">
|
32 |
<th scope="row">Default Width</th>
|
@@ -38,20 +65,43 @@ if(isset($_REQUEST['submit']) and $_REQUEST['submit']) {
|
|
38 |
</tr>
|
39 |
<tr valign="top">
|
40 |
<td colspan="2"><strong>Download Link Options</strong><br/>
|
41 |
-
|
42 |
</tr>
|
43 |
<tr valign="top">
|
44 |
-
<td colspan="2"><?php
|
45 |
</tr>
|
46 |
<tr valign="top">
|
47 |
<th scope="row">Link Text</th>
|
48 |
-
<td><input type="text" name="gde_link_text" value="<?php echo get_option('gde_link_text'); ?>"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
</tr>
|
50 |
</table>
|
51 |
<p class="submit">
|
52 |
<input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID ?>" />
|
53 |
<span id="autosave"></span>
|
54 |
-
<input type="submit" name="submit" value="<?php e('Save Options') ?>"
|
|
|
|
|
55 |
</p>
|
56 |
|
57 |
</form>
|
@@ -59,15 +109,16 @@ if(isset($_REQUEST['submit']) and $_REQUEST['submit']) {
|
|
59 |
</div>
|
60 |
|
61 |
<?php
|
62 |
-
function
|
63 |
?>
|
64 |
<input type="checkbox" name="<?php echo $option; ?>" value="1" id="<?php echo $option?>" <?php if(get_option($option)) print " checked='checked'"; ?> />
|
65 |
<label for="<?php echo $option?>"><?php e($title) ?></label><br />
|
66 |
|
67 |
<?php
|
68 |
}
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
}
|
|
1 |
<?php
|
2 |
+
include_once('wpframe.php');
|
3 |
+
include_once('functions.php');
|
4 |
|
5 |
+
if(isset($_REQUEST['defaults'])) {
|
6 |
+
|
7 |
+
// reset to plug-in defaults
|
8 |
+
$set = getDefaults();
|
9 |
+
update_option('gde_default_width', $set['gde_default_width']);
|
10 |
+
update_option('gde_default_height', $set['gde_default_height']);
|
11 |
+
update_option('gde_show_dl', $set['gde_show_dl']);
|
12 |
+
update_option('gde_link_text', $set['gde_link_text']);
|
13 |
+
update_option('gde_link_pos', $set['gde_link_pos']);
|
14 |
+
update_option('gde_link_func', $set['gde_link_func']);
|
15 |
+
|
16 |
+
showMessage("Options reset to defaults");
|
17 |
+
} elseif(isset($_REQUEST['submit'])) {
|
18 |
+
|
19 |
+
// change user defaults
|
20 |
if(isset($_POST['gde_show_dl'])) {
|
21 |
update_option('gde_show_dl', 1);
|
22 |
} else {
|
23 |
update_option('gde_show_dl', 0);
|
24 |
}
|
25 |
if(isset($_POST['gde_default_width'])) {
|
26 |
+
$neww = $_POST['gde_default_width'];
|
27 |
+
if (strlen($neww) > 0) update_option('gde_default_width', sanitizeOpt($neww));
|
28 |
}
|
29 |
if(isset($_POST['gde_default_height'])) {
|
30 |
+
$newh = $_POST['gde_default_height'];
|
31 |
+
if (strlen($newh) > 0) update_option('gde_default_height', sanitizeOpt($newh));
|
32 |
+
}
|
33 |
+
if(isset($_POST['gde_link_text'])) {
|
34 |
+
$newt = $_POST['gde_link_text'];
|
35 |
+
if (strlen(utf8_decode($newt))) update_option('gde_link_text', $newt);
|
36 |
}
|
37 |
+
if(isset($_POST['gde_link_pos'])) {
|
38 |
+
update_option('gde_link_pos', $_POST['gde_link_pos']);
|
39 |
+
}
|
40 |
+
if(isset($_POST['gde_link_func'])) {
|
41 |
+
update_option('gde_link_func', $_POST['gde_link_func']);
|
42 |
+
}
|
43 |
+
|
44 |
showMessage("Options updated");
|
45 |
}
|
46 |
?>
|
53 |
<table class="form-table">
|
54 |
<tr valign="top">
|
55 |
<td colspan="2"><strong>Global Viewer Size</strong><br/>
|
56 |
+
To override on individual posts, manually set <code>height=</code> and <code>width=</code> (number in px) in the post shortcode.</td>
|
57 |
</tr>
|
58 |
<tr valign="top">
|
59 |
<th scope="row">Default Width</th>
|
65 |
</tr>
|
66 |
<tr valign="top">
|
67 |
<td colspan="2"><strong>Download Link Options</strong><br/>
|
68 |
+
To override display setting on an individual post, use <code>save="1"</code> (show) or <code>save="0"</code> (hide) in the post shortcode.</em></td>
|
69 |
</tr>
|
70 |
<tr valign="top">
|
71 |
+
<td colspan="2"><?php showCheck('gde_show_dl', t('Display the download link by default')); ?></td>
|
72 |
</tr>
|
73 |
<tr valign="top">
|
74 |
<th scope="row">Link Text</th>
|
75 |
+
<td><input type="text" size="50" name="gde_link_text" value="<?php echo get_option('gde_link_text'); ?>" /><br/>
|
76 |
+
<em>You can further customize text using these dynamic replacements:</em><br/>
|
77 |
+
<code>%FN</code> : filename
|
78 |
+
<code>%FT</code> : file type
|
79 |
+
<code>%FS</code> : file size</td>
|
80 |
+
</tr>
|
81 |
+
<tr valign="top">
|
82 |
+
<th scope="row">Link Position</th>
|
83 |
+
<td><select name="gde_link_pos">
|
84 |
+
<?php showOption('above', 'gde_link_pos', t('Above Viewer')); ?>
|
85 |
+
<?php showOption('below', 'gde_link_pos', t('Below Viewer')); ?>
|
86 |
+
</select>
|
87 |
+
</td>
|
88 |
+
</tr>
|
89 |
+
<r valign="top">
|
90 |
+
<th scope="row">Link Behavior</th>
|
91 |
+
<td><select name="gde_link_func">
|
92 |
+
<?php showOption('default', 'gde_link_func', t('Browser Default')); ?>
|
93 |
+
<?php showOption('force', 'gde_link_func', t('Force Download')); ?>
|
94 |
+
<?php showOption('force-mask', 'gde_link_func', t('Force Download (Mask URL)')); ?>
|
95 |
+
</select>
|
96 |
+
</td>
|
97 |
</tr>
|
98 |
</table>
|
99 |
<p class="submit">
|
100 |
<input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID ?>" />
|
101 |
<span id="autosave"></span>
|
102 |
+
<input type="submit" name="submit" value="<?php e('Save Options') ?>" />
|
103 |
+
|
104 |
+
<input type="submit" name="defaults" value="<?php e('Reset to Defaults') ?>" onClick="javascript:return confirm('Are you sure you want to reset all settings to defaults?')" />
|
105 |
</p>
|
106 |
|
107 |
</form>
|
109 |
</div>
|
110 |
|
111 |
<?php
|
112 |
+
function showCheck($option, $title) {
|
113 |
?>
|
114 |
<input type="checkbox" name="<?php echo $option; ?>" value="1" id="<?php echo $option?>" <?php if(get_option($option)) print " checked='checked'"; ?> />
|
115 |
<label for="<?php echo $option?>"><?php e($title) ?></label><br />
|
116 |
|
117 |
<?php
|
118 |
}
|
119 |
+
function showOption($value, $option, $title) {
|
120 |
+
?>
|
121 |
+
<option value="<?php echo $value; ?>"<?php if((get_option($option)) == $value) print " selected='yes'"; ?>><?php echo $title; ?></option>
|
122 |
+
<?php
|
123 |
+
}
|
124 |
+
?>
|
pdf.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/* Calls remote PDF file locally (automates remote fetch)
|
4 |
+
|
5 |
+
USAGE: pdf.php?
|
6 |
+
file=file.pdf (the name of the remote file, required)
|
7 |
+
download=1 (force save dialog rather than display in browser, optional)
|
8 |
+
*/
|
9 |
+
|
10 |
+
$str = $_SERVER['QUERY_STRING'];
|
11 |
+
parse_str($str);
|
12 |
+
|
13 |
+
if (!$file) {
|
14 |
+
echo "<html>No filename specified, action cancelled.</html>\n";
|
15 |
+
exit;
|
16 |
+
} elseif (!preg_match("/.pdf$/i",$file)) {
|
17 |
+
# invalid filename or hack attempt
|
18 |
+
echo "<html>Invalid filename, action cancelled.</html>\n";
|
19 |
+
exit;
|
20 |
+
}
|
21 |
+
|
22 |
+
$file = "http://".$file;
|
23 |
+
$handle = fopen("$file", "rb");
|
24 |
+
|
25 |
+
if (!$handle) {
|
26 |
+
# file doesn't exist
|
27 |
+
echo "<html>Nonexistant filename, action cancelled.</html>\n";
|
28 |
+
fclose($handle);
|
29 |
+
exit;
|
30 |
+
}
|
31 |
+
|
32 |
+
$contents = '';
|
33 |
+
while (!feof($handle)) {
|
34 |
+
$contents .= fread($handle, 8192);
|
35 |
+
}
|
36 |
+
fclose($handle);
|
37 |
+
|
38 |
+
|
39 |
+
// We'll be outputting a PDF
|
40 |
+
header('Content-type: application/pdf');
|
41 |
+
|
42 |
+
// force save dialog with given name
|
43 |
+
if ($dl) {
|
44 |
+
header('Content-Disposition: attachment; filename="'.$fn.'"');
|
45 |
+
}
|
46 |
+
|
47 |
+
// spit it out
|
48 |
+
echo $contents;
|
49 |
+
?>
|
readme.txt
CHANGED
@@ -44,7 +44,7 @@ Optional attributes:
|
|
44 |
* `height=` : To override the default height of the viewer, enter a new height value (number in pixels)
|
45 |
|
46 |
= Nothing is showing up! What do I do? =
|
47 |
-
View the source on the web page where you've embedded the viewer. In order to degrade gracefully in case an error occurs, error messages will be inserted as HTML comments in these pages at the spot the viewer is called
|
48 |
|
49 |
= I wish the plug-in had feature XYZ... =
|
50 |
That's not a question ;) but if you have any particular ideas on further development of this plug-in, please <a href="http://wordpress.org/tags/google-document-embedder?forum_id=10#postform">post a message</a> and I'll see what I can do.
|
@@ -56,6 +56,12 @@ That's not a question ;) but if you have any particular ideas on further develop
|
|
56 |
|
57 |
== Changelog ==
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
= 1.0.3 =
|
60 |
* Installation bug fix.
|
61 |
|
44 |
* `height=` : To override the default height of the viewer, enter a new height value (number in pixels)
|
45 |
|
46 |
= Nothing is showing up! What do I do? =
|
47 |
+
View the source on the web page where you've embedded the viewer. In order to degrade gracefully in case an error occurs, error messages will be inserted as HTML comments in these pages at the spot the viewer is called: `<-- GDE ERROR: (error) -->`
|
48 |
|
49 |
= I wish the plug-in had feature XYZ... =
|
50 |
That's not a question ;) but if you have any particular ideas on further development of this plug-in, please <a href="http://wordpress.org/tags/google-document-embedder?forum_id=10#postform">post a message</a> and I'll see what I can do.
|
56 |
|
57 |
== Changelog ==
|
58 |
|
59 |
+
= 1.5 =
|
60 |
+
* Improved error checking.
|
61 |
+
* Improved customization options for download text.
|
62 |
+
* Added option to override default browser behavior for PDF links (force download).
|
63 |
+
* Added option to reset options to defaults.
|
64 |
+
|
65 |
= 1.0.3 =
|
66 |
* Installation bug fix.
|
67 |
|
screenshot-2.png
CHANGED
Binary file
|
uninstall.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
|
|
2 |
|
3 |
// perform cleanup, be a good citizen
|
4 |
|
5 |
-
$options =
|
6 |
-
|
7 |
-
foreach ($options as $opt) {
|
8 |
delete_option($opt);
|
9 |
}
|
10 |
|
1 |
<?php
|
2 |
+
include_once('functions.php');
|
3 |
|
4 |
// perform cleanup, be a good citizen
|
5 |
|
6 |
+
$options = getDefaults();
|
7 |
+
foreach ($options as $opt => $val) {
|
|
|
8 |
delete_option($opt);
|
9 |
}
|
10 |
|