Version Description
- Added: Revealed more troubleshooting options (under "Advanced Options")
- Fixed: No longer relies on cURL for any function
- Changed: Function overhaul for general efficiency and reduced database calls
- Removed: WP 2.5 compatibility. Now requires WordPress 2.7+.
Download this release
Release Info
Developer | k3davis |
Plugin | Google Doc Embedder |
Version | 1.9 |
Comparing to | |
See all releases |
Code changes from version 1.8.2 to 1.9
- functions.php +110 -58
- gviewer.php +50 -54
- ie-warn.txt +1 -0
- options.php +76 -66
- readme.txt +9 -3
- screenshot-2.png +0 -0
- uninstall.php +2 -12
functions.php
CHANGED
@@ -1,36 +1,89 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
5 |
$defaults = array(
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
16 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
return $defaults;
|
18 |
}
|
19 |
|
20 |
-
function
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
);
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
}
|
30 |
|
31 |
-
function
|
32 |
|
33 |
-
$urlregex = '/^(([\w]+:)?\/\/)
|
34 |
|
35 |
if (preg_match($urlregex, $link)) {
|
36 |
return true;
|
@@ -39,7 +92,7 @@ function validLink($link) {
|
|
39 |
}
|
40 |
}
|
41 |
|
42 |
-
function
|
43 |
|
44 |
if(preg_match("/($exts)$/i",$link)) {
|
45 |
return true;
|
@@ -48,34 +101,18 @@ function validType($link, $exts) {
|
|
48 |
}
|
49 |
}
|
50 |
|
51 |
-
function
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
$
|
56 |
-
|
57 |
-
return false;
|
58 |
-
}
|
59 |
-
curl_setopt($handle, CURLOPT_HEADER, true);
|
60 |
-
curl_setopt($handle, CURLOPT_FAILONERROR, true);
|
61 |
-
curl_setopt($handle, CURLOPT_HTTPHEADER, Array("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3") ); // needed for some sites (such as digg.com)
|
62 |
-
curl_setopt($handle, CURLOPT_NOBODY, true);
|
63 |
-
curl_setopt($handle, CURLOPT_FOLLOWLOCATION, true); // only useful in case of redirects
|
64 |
-
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
|
65 |
-
$data = curl_exec($handle);
|
66 |
-
curl_close($handle);
|
67 |
-
|
68 |
-
$contentLength = 0;
|
69 |
-
if (preg_match('/Content-Length: (\d+)/i', $data, $matches)) {
|
70 |
-
$contentLength = (int)$matches[1];
|
71 |
-
}
|
72 |
-
return $contentLength;
|
73 |
} else {
|
74 |
-
return
|
75 |
}
|
76 |
}
|
77 |
|
78 |
-
function
|
79 |
$pos = strrpos($filename, '.');
|
80 |
if ($pos === false)
|
81 |
{ // dot is not found in the filename
|
@@ -90,7 +127,7 @@ function splitFilename($filename) {
|
|
90 |
}
|
91 |
}
|
92 |
|
93 |
-
function
|
94 |
if ($bytes < 1) {
|
95 |
return "Unknown";
|
96 |
} else {
|
@@ -106,7 +143,7 @@ function formatBytes($bytes, $precision = 2) {
|
|
106 |
}
|
107 |
}
|
108 |
|
109 |
-
function
|
110 |
$value = preg_replace("/[^0-9]*/", '', $value);
|
111 |
if (($type == "pc") && ($value > 100)) {
|
112 |
$value = "100";
|
@@ -114,17 +151,32 @@ function sanitizeOpt($value, $type) {
|
|
114 |
return $value;
|
115 |
}
|
116 |
|
117 |
-
function
|
118 |
-
|
119 |
-
|
120 |
-
return get_option('siteurl') . '/wp-content/plugins/' . plugin_basename(dirname(__FILE__));
|
121 |
-
}
|
122 |
|
123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
}
|
|
|
|
|
125 |
|
126 |
-
function
|
127 |
-
|
|
|
|
|
|
|
|
|
|
|
128 |
}
|
129 |
|
130 |
?>
|
1 |
<?php
|
2 |
|
3 |
+
// external urls (help, etc.)
|
4 |
+
@define('GDE_IE8_URL', 'http://davismetro.com/gde/ie8/');
|
5 |
+
@define('GDE_CONFLICT_URL', 'http://davismetro.com/gde/conflicts/');
|
6 |
+
|
7 |
+
function gde_init($reset = NULL) {
|
8 |
+
// define global default settings
|
9 |
$defaults = array(
|
10 |
+
'default_width' => '600',
|
11 |
+
'width_type' => 'px',
|
12 |
+
'default_height' => '500',
|
13 |
+
'height_type' => 'px',
|
14 |
+
'show_dl' => 'yes',
|
15 |
+
'link_text' => 'Download (%FT, %FS)',
|
16 |
+
'link_pos' => 'below',
|
17 |
+
'link_func' => 'default',
|
18 |
+
'ie8_warn' => 'no',
|
19 |
+
'bypass_check' => 'no',
|
20 |
+
'ignore_conflicts' => 'no'
|
21 |
);
|
22 |
+
|
23 |
+
if (!$exists = get_option('gde_options')) {
|
24 |
+
foreach($defaults as $key => $value) {
|
25 |
+
// convert old settings if found
|
26 |
+
$currvalue = get_option('gde_' . $key);
|
27 |
+
if ($currvalue || $currvalue === "0" || $currvalue === "1") {
|
28 |
+
if ($reset !== "reset") {
|
29 |
+
if ($currvalue === "0") { $defaults[$key] = "no"; }
|
30 |
+
elseif ($currvalue === "1") { $defaults[$key] = "yes"; }
|
31 |
+
else { $defaults[$key] = $currvalue; }
|
32 |
+
}
|
33 |
+
delete_option('gde_' . $key);
|
34 |
+
}
|
35 |
+
}
|
36 |
+
add_option('gde_options', $defaults);
|
37 |
+
} else {
|
38 |
+
update_option('gde_options', $defaults);
|
39 |
+
}
|
40 |
return $defaults;
|
41 |
}
|
42 |
|
43 |
+
function gde_validTests($file = NULL, $force) {
|
44 |
+
global $exts;
|
45 |
+
|
46 |
+
// error messages
|
47 |
+
$nofile = 'file attribute not found (check syntax)';
|
48 |
+
$badlink = 'invalid URL, please use fully qualified URL';
|
49 |
+
$badtype = '%e is not a supported file type';
|
50 |
+
$notfound = 'retrieve error (%e), use force="1" to bypass this check';
|
51 |
+
|
52 |
+
if (!$file) {
|
53 |
+
return $nofile;
|
54 |
+
}
|
55 |
+
|
56 |
+
$result = gde_validUrl($file);
|
57 |
+
if ($force == "1" || $force == "yes") {
|
58 |
+
return $result;
|
59 |
+
} else {
|
60 |
+
if ($result['code'] !== 200) {
|
61 |
+
if (!gde_validLink($file)) {
|
62 |
+
return $badlink;
|
63 |
+
} else {
|
64 |
+
$err = $result['code'].":".$result['message'];
|
65 |
+
$notfound = str_replace("%e", $err, $notfound);
|
66 |
+
|
67 |
+
return $notfound;
|
68 |
+
}
|
69 |
+
} else {
|
70 |
+
if (!gde_validType($file,$exts)) {
|
71 |
+
$fn = basename($file);
|
72 |
+
$fnp = gde_splitFilename($fn);
|
73 |
+
$type = $fnp[1];
|
74 |
+
$badtype = str_replace("%e", $type, $badtype);
|
75 |
+
|
76 |
+
return $badtype;
|
77 |
+
} else {
|
78 |
+
return $result;
|
79 |
+
}
|
80 |
+
}
|
81 |
+
}
|
82 |
}
|
83 |
|
84 |
+
function gde_validLink($link) {
|
85 |
|
86 |
+
$urlregex = '/^(([\w]+:)?\/\/)(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/i';
|
87 |
|
88 |
if (preg_match($urlregex, $link)) {
|
89 |
return true;
|
92 |
}
|
93 |
}
|
94 |
|
95 |
+
function gde_validType($link, $exts) {
|
96 |
|
97 |
if(preg_match("/($exts)$/i",$link)) {
|
98 |
return true;
|
101 |
}
|
102 |
}
|
103 |
|
104 |
+
function gde_validUrl($url) {
|
105 |
+
$request = new WP_Http;
|
106 |
+
$result = $request->request($url);
|
107 |
+
if (is_array($result)) {
|
108 |
+
$result['response']['fsize'] = $result['headers']['content-length'];
|
109 |
+
return $result['response'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
} else {
|
111 |
+
return false;
|
112 |
}
|
113 |
}
|
114 |
|
115 |
+
function gde_splitFilename($filename) {
|
116 |
$pos = strrpos($filename, '.');
|
117 |
if ($pos === false)
|
118 |
{ // dot is not found in the filename
|
127 |
}
|
128 |
}
|
129 |
|
130 |
+
function gde_formatBytes($bytes, $precision = 2) {
|
131 |
if ($bytes < 1) {
|
132 |
return "Unknown";
|
133 |
} else {
|
143 |
}
|
144 |
}
|
145 |
|
146 |
+
function gde_sanitizeOpt($value, $type) {
|
147 |
$value = preg_replace("/[^0-9]*/", '', $value);
|
148 |
if (($type == "pc") && ($value > 100)) {
|
149 |
$value = "100";
|
151 |
return $value;
|
152 |
}
|
153 |
|
154 |
+
function gde_shortUrl($u) {
|
155 |
+
return file_get_contents('http://tinyurl.com/api-create.php?url='.$u);
|
156 |
+
}
|
|
|
|
|
157 |
|
158 |
+
function gde_warnText($u) {
|
159 |
+
return file_get_contents($u."/ie-warn.txt");
|
160 |
+
}
|
161 |
+
|
162 |
+
function gde_conflict_check() {
|
163 |
+
global $gde_conflict;
|
164 |
+
|
165 |
+
// Markdown
|
166 |
+
if (function_exists('mdwp_add_p')) {
|
167 |
+
$gde_conflict = "markdown";
|
168 |
+
add_action('admin_notices', 'gde_admin_warning');
|
169 |
}
|
170 |
+
return;
|
171 |
+
}
|
172 |
|
173 |
+
function gde_admin_warning() {
|
174 |
+
global $gde_conflict;
|
175 |
+
$gde_link = GDE_CONFLICT_URL."#$gde_conflict";
|
176 |
+
|
177 |
+
echo "
|
178 |
+
<div id='gde-warning' class='updated fade'><p><strong>".__('Google Doc Embedder Warning:')."</strong> ".sprintf(__('You have an active plugin that may conflict with GDE. See <a href="%1$s">more info</a> or <a href="%2$s">turn off this warning</a>.'), "$gde_link", "options-general.php?page=gviewer.php")."</p></div>
|
179 |
+
";
|
180 |
}
|
181 |
|
182 |
?>
|
gviewer.php
CHANGED
@@ -3,9 +3,9 @@
|
|
3 |
/*
|
4 |
Plugin Name: Google Doc Embedder
|
5 |
Plugin URI: http://davismetro.com/gde/
|
6 |
-
Description: Lets you embed PDF files, PowerPoint presentations, and TIFF images in a web page using the Google Docs Viewer.
|
7 |
Author: Kevin Davis
|
8 |
-
Version: 1.
|
9 |
*/
|
10 |
|
11 |
/**
|
@@ -30,39 +30,39 @@ Version: 1.8.2
|
|
30 |
* @author Kevin Davis <kev@tnw.org>
|
31 |
* @copyright Copyright 2009 Kevin Davis
|
32 |
* @license http://www.gnu.org/licenses/gpl.txt GPL 2.0
|
33 |
-
* @version 1.
|
34 |
* @link http://davismetro.com/gde/
|
35 |
*/
|
36 |
|
37 |
include_once('wpframe.php');
|
38 |
include_once('functions.php');
|
|
|
39 |
|
40 |
-
// usage: [gview file="http://path.to/file.pdf"
|
41 |
-
function
|
42 |
|
43 |
// current settings
|
44 |
-
$
|
45 |
-
|
46 |
-
$ie8warn = get_option('gde_ie8_warn');
|
47 |
-
$bypass = get_option('gde_bypass_check');
|
48 |
extract(shortcode_atts(array(
|
49 |
'file' => '',
|
50 |
-
'save' => $
|
51 |
'width' => '',
|
52 |
'height' => '',
|
53 |
-
'force' => $
|
54 |
), $atts));
|
|
|
55 |
$width = str_replace("px", "", trim($width));
|
56 |
if (!$width || !preg_match("/^\d+%?$/", $width)) {
|
57 |
-
$width =
|
58 |
-
if (
|
59 |
$width .= "%";
|
60 |
}
|
61 |
}
|
62 |
$height = str_replace("px", "", trim($height));
|
63 |
if (!$height || !preg_match("/^\d+%?$/", $height)) {
|
64 |
-
$height =
|
65 |
-
if (
|
66 |
$height .= "%";
|
67 |
}
|
68 |
}
|
@@ -71,25 +71,17 @@ function gviewer_func($atts) {
|
|
71 |
$exts = "pdf|ppt|tif|tiff";
|
72 |
|
73 |
// check link for validity
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
$code = "\n<!-- GDE EMBED ERROR: invalid URL, please use fully qualified URL -->\n";
|
78 |
-
} elseif ((!validType($file,$exts)) && ($force !== "1")) {
|
79 |
-
$code = "\n<!-- GDE EMBED ERROR: unsupported file type -->\n";
|
80 |
-
} elseif ((!$fsize = validUrl($file)) && ($force !== "1")) {
|
81 |
-
$code = "\n<!-- GDE EMBED ERROR: file not found -->\n";
|
82 |
} else {
|
83 |
-
|
84 |
-
|
85 |
-
} else {
|
86 |
-
$code = "";
|
87 |
-
}
|
88 |
-
$pUrl = getPluginUrl();
|
89 |
|
90 |
$fn = basename($file);
|
91 |
-
$fnp =
|
92 |
-
$fsize =
|
|
|
93 |
|
94 |
$code .=<<<HERE
|
95 |
%A%
|
@@ -100,9 +92,9 @@ HERE;
|
|
100 |
$lnk = "http://docs.google.com/viewer?url=".urlencode($file)."&embedded=true";
|
101 |
$linkcode = "";
|
102 |
|
103 |
-
if ($save == "1") {
|
104 |
|
105 |
-
$dlMethod =
|
106 |
if ($fnp[1] == "PDF") {
|
107 |
if ($dlMethod == "force" or $dlMethod == "force-mask") {
|
108 |
$dlFile = $pUrl;
|
@@ -115,25 +107,26 @@ HERE;
|
|
115 |
$target = "_blank";
|
116 |
}
|
117 |
if ($dlMethod == "force-mask") {
|
118 |
-
$dlFile =
|
119 |
}
|
120 |
|
121 |
} elseif ($dlMethod == "force-mask") {
|
122 |
-
$dlFile =
|
123 |
$target = "_self";
|
124 |
} else {
|
125 |
$dlFile = $file;
|
126 |
$target = "_self";
|
127 |
}
|
|
|
128 |
$linkcode .= "<p class=\"gde-text\"><a href=\"$dlFile\" target=\"$target\" class=\"gde-link\">$txt</a></p>";
|
129 |
}
|
130 |
|
131 |
-
if ($
|
132 |
-
$warn =
|
133 |
-
$linkcode .= "\n<!--[if gte IE
|
134 |
}
|
135 |
|
136 |
-
if (
|
137 |
$code = str_replace("%A%", $linkcode, $code);
|
138 |
$code = str_replace("%B%", '', $code);
|
139 |
} else {
|
@@ -146,7 +139,6 @@ HERE;
|
|
146 |
$code = str_replace("%FN", $fn, $code);
|
147 |
$code = str_replace("%FT", $fnp[1], $code);
|
148 |
$code = str_replace("%FS", $fsize, $code);
|
149 |
-
|
150 |
}
|
151 |
|
152 |
return $code;
|
@@ -154,20 +146,12 @@ HERE;
|
|
154 |
|
155 |
// activate plugin
|
156 |
register_activation_hook( __FILE__, 'gde_activate');
|
|
|
157 |
function gde_activate() {
|
158 |
global $wpdb;
|
159 |
|
160 |
// initial options
|
161 |
-
$
|
162 |
-
foreach($defaults as $set => $val) {
|
163 |
-
add_option($set, $val);
|
164 |
-
}
|
165 |
-
|
166 |
-
// remove deprecated options if present
|
167 |
-
$legacy_options = getObsolete();
|
168 |
-
foreach ($legacy_options as $lopt => $val) {
|
169 |
-
delete_option($lopt);
|
170 |
-
}
|
171 |
}
|
172 |
|
173 |
// add an option page
|
@@ -180,18 +164,30 @@ function gde_options() {
|
|
180 |
if (! user_can_access_admin_page()) wp_die( t('You do not have sufficient permissions to access this page') );
|
181 |
|
182 |
require(ABSPATH. '/wp-content/plugins/google-document-embedder/options.php');
|
|
|
183 |
}
|
184 |
|
185 |
// add additional settings link, for convenience
|
186 |
$plugin = plugin_basename(__FILE__);
|
187 |
function gde_actlinks( $links ) {
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
}
|
192 |
add_filter("plugin_action_links_$plugin", 'gde_actlinks' );
|
193 |
|
194 |
// activate shortcode
|
195 |
-
add_shortcode('gview', '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
|
197 |
?>
|
3 |
/*
|
4 |
Plugin Name: Google Doc Embedder
|
5 |
Plugin URI: http://davismetro.com/gde/
|
6 |
+
Description: Lets you embed PDF files, PowerPoint presentations, and TIFF images in a web page using the Google Docs Viewer (no Flash or PDF browser plug-ins required).
|
7 |
Author: Kevin Davis
|
8 |
+
Version: 1.9
|
9 |
*/
|
10 |
|
11 |
/**
|
30 |
* @author Kevin Davis <kev@tnw.org>
|
31 |
* @copyright Copyright 2009 Kevin Davis
|
32 |
* @license http://www.gnu.org/licenses/gpl.txt GPL 2.0
|
33 |
+
* @version 1.9
|
34 |
* @link http://davismetro.com/gde/
|
35 |
*/
|
36 |
|
37 |
include_once('wpframe.php');
|
38 |
include_once('functions.php');
|
39 |
+
$options = get_option('gde_options');
|
40 |
|
41 |
+
// basic usage: [gview file="http://path.to/file.pdf"]
|
42 |
+
function gde_gviewer_func($atts) {
|
43 |
|
44 |
// current settings
|
45 |
+
global $options, $exts;
|
46 |
+
|
|
|
|
|
47 |
extract(shortcode_atts(array(
|
48 |
'file' => '',
|
49 |
+
'save' => $options['show_dl'],
|
50 |
'width' => '',
|
51 |
'height' => '',
|
52 |
+
'force' => $options['bypass_check']
|
53 |
), $atts));
|
54 |
+
|
55 |
$width = str_replace("px", "", trim($width));
|
56 |
if (!$width || !preg_match("/^\d+%?$/", $width)) {
|
57 |
+
$width = $options['default_width'];
|
58 |
+
if ($options['width_type'] == "pc") {
|
59 |
$width .= "%";
|
60 |
}
|
61 |
}
|
62 |
$height = str_replace("px", "", trim($height));
|
63 |
if (!$height || !preg_match("/^\d+%?$/", $height)) {
|
64 |
+
$height = $options['default_height'];
|
65 |
+
if ($options['height_type'] == "pc") {
|
66 |
$height .= "%";
|
67 |
}
|
68 |
}
|
71 |
$exts = "pdf|ppt|tif|tiff";
|
72 |
|
73 |
// check link for validity
|
74 |
+
$status = gde_validTests($file, $force);
|
75 |
+
if ($status && !is_array($status)) {
|
76 |
+
$code = "\n<!-- GDE EMBED ERROR: $status -->\n";
|
|
|
|
|
|
|
|
|
|
|
77 |
} else {
|
78 |
+
$code = "";
|
79 |
+
$pUrl = plugins_url(plugin_basename(dirname(__FILE__)));
|
|
|
|
|
|
|
|
|
80 |
|
81 |
$fn = basename($file);
|
82 |
+
$fnp = gde_splitFilename($fn);
|
83 |
+
$fsize = $status['fsize'];
|
84 |
+
$fsize = gde_formatBytes($fsize);
|
85 |
|
86 |
$code .=<<<HERE
|
87 |
%A%
|
92 |
$lnk = "http://docs.google.com/viewer?url=".urlencode($file)."&embedded=true";
|
93 |
$linkcode = "";
|
94 |
|
95 |
+
if ($save == "yes" || $save == "1") {
|
96 |
|
97 |
+
$dlMethod = $options['link_func'];
|
98 |
if ($fnp[1] == "PDF") {
|
99 |
if ($dlMethod == "force" or $dlMethod == "force-mask") {
|
100 |
$dlFile = $pUrl;
|
107 |
$target = "_blank";
|
108 |
}
|
109 |
if ($dlMethod == "force-mask") {
|
110 |
+
$dlFile = gde_shortUrl($dlFile);
|
111 |
}
|
112 |
|
113 |
} elseif ($dlMethod == "force-mask") {
|
114 |
+
$dlFile = gde_shortUrl($file);
|
115 |
$target = "_self";
|
116 |
} else {
|
117 |
$dlFile = $file;
|
118 |
$target = "_self";
|
119 |
}
|
120 |
+
$txt = $options['link_text'];
|
121 |
$linkcode .= "<p class=\"gde-text\"><a href=\"$dlFile\" target=\"$target\" class=\"gde-link\">$txt</a></p>";
|
122 |
}
|
123 |
|
124 |
+
if ($options['ie8_warn'] == "yes") {
|
125 |
+
$warn = gde_warnText($pUrl);
|
126 |
+
$linkcode .= "\n<!--[if gte IE 7]>\n<p class=\"gde-iewarn\">".$warn."</p>\n<![endif]-->\n";
|
127 |
}
|
128 |
|
129 |
+
if ($options['link_pos'] == "above") {
|
130 |
$code = str_replace("%A%", $linkcode, $code);
|
131 |
$code = str_replace("%B%", '', $code);
|
132 |
} else {
|
139 |
$code = str_replace("%FN", $fn, $code);
|
140 |
$code = str_replace("%FT", $fnp[1], $code);
|
141 |
$code = str_replace("%FS", $fsize, $code);
|
|
|
142 |
}
|
143 |
|
144 |
return $code;
|
146 |
|
147 |
// activate plugin
|
148 |
register_activation_hook( __FILE__, 'gde_activate');
|
149 |
+
|
150 |
function gde_activate() {
|
151 |
global $wpdb;
|
152 |
|
153 |
// initial options
|
154 |
+
$init = gde_init();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
}
|
156 |
|
157 |
// add an option page
|
164 |
if (! user_can_access_admin_page()) wp_die( t('You do not have sufficient permissions to access this page') );
|
165 |
|
166 |
require(ABSPATH. '/wp-content/plugins/google-document-embedder/options.php');
|
167 |
+
add_action('in_admin_footer', 'gde_admin_footer');
|
168 |
}
|
169 |
|
170 |
// add additional settings link, for convenience
|
171 |
$plugin = plugin_basename(__FILE__);
|
172 |
function gde_actlinks( $links ) {
|
173 |
+
$settings_link = '<a href="options-general.php?page=gviewer.php">Settings</a>';
|
174 |
+
array_unshift($links, $settings_link);
|
175 |
+
return $links;
|
176 |
}
|
177 |
add_filter("plugin_action_links_$plugin", 'gde_actlinks' );
|
178 |
|
179 |
// activate shortcode
|
180 |
+
add_shortcode('gview', 'gde_gviewer_func');
|
181 |
+
|
182 |
+
// display any conflict warnings (admin)
|
183 |
+
if (($options['ignore_conflicts'] !== "yes") && (!isset($_REQUEST['submit']))) {
|
184 |
+
add_action('plugins_loaded', 'gde_conflict_check');
|
185 |
+
}
|
186 |
+
|
187 |
+
// footer credit
|
188 |
+
function gde_admin_footer() {
|
189 |
+
$plugin_data = get_plugin_data( __FILE__ );
|
190 |
+
printf('%1$s plugin | Version %2$s<br />', $plugin_data['Title'], $plugin_data['Version']);
|
191 |
+
}
|
192 |
|
193 |
?>
|
ie-warn.txt
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
IE User: If you're having trouble viewing this document, go to Tools → Internet Options → Privacy → Sites → Add "google.com" to allowed sites list.
|
options.php
CHANGED
@@ -2,64 +2,64 @@
|
|
2 |
include_once('wpframe.php');
|
3 |
include_once('functions.php');
|
4 |
|
|
|
|
|
|
|
5 |
if(isset($_REQUEST['defaults'])) {
|
6 |
|
7 |
-
|
8 |
-
$
|
9 |
-
update_option('gde_default_width', $set['gde_default_width']);
|
10 |
-
update_option('gde_width_type', $set['gde_width_type']);
|
11 |
-
update_option('gde_default_height', $set['gde_default_height']);
|
12 |
-
update_option('gde_height_type', $set['gde_height_type']);
|
13 |
-
update_option('gde_show_dl', $set['gde_show_dl']);
|
14 |
-
update_option('gde_link_text', $set['gde_link_text']);
|
15 |
-
update_option('gde_link_pos', $set['gde_link_pos']);
|
16 |
-
update_option('gde_link_func', $set['gde_link_func']);
|
17 |
-
update_option('gde_ie8_warn', $set['gde_ie8_warn']);
|
18 |
-
update_option('gde_bypass_check', $set['gde_bypass_check']);
|
19 |
-
|
20 |
showMessage("Options reset to defaults");
|
|
|
21 |
} elseif(isset($_REQUEST['submit'])) {
|
22 |
|
23 |
// change user defaults
|
24 |
-
if(isset($_POST['
|
25 |
-
|
26 |
} else {
|
27 |
-
|
28 |
}
|
29 |
-
if(isset($_POST['
|
30 |
-
$neww = $_POST['
|
31 |
-
if (strlen($neww) > 0)
|
32 |
}
|
33 |
-
if(isset($_POST['
|
34 |
-
|
35 |
}
|
36 |
-
if(isset($_POST['
|
37 |
-
$newh = $_POST['
|
38 |
-
if (strlen($newh) > 0)
|
39 |
}
|
40 |
-
if(isset($_POST['
|
41 |
-
|
42 |
}
|
43 |
-
if(isset($_POST['
|
44 |
-
$newt = $_POST['
|
45 |
-
if (strlen(utf8_decode($newt)))
|
46 |
}
|
47 |
-
if(isset($_POST['
|
48 |
-
|
49 |
}
|
50 |
-
if(isset($_POST['
|
51 |
-
|
52 |
}
|
53 |
-
if(isset($_POST['
|
54 |
-
|
55 |
} else {
|
56 |
-
|
57 |
}
|
58 |
-
if(isset($_POST['
|
59 |
-
|
60 |
} else {
|
61 |
-
|
62 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
showMessage("Options updated");
|
64 |
}
|
65 |
?>
|
@@ -78,31 +78,28 @@ To override size on individual posts, manually set in the post shortcode using (
|
|
78 |
</tr>
|
79 |
<tr valign="top">
|
80 |
<th scope="row">Default Width</th>
|
81 |
-
<td><input type="text" size="5" name="
|
82 |
-
<?php
|
83 |
-
<?php
|
84 |
</select></td>
|
85 |
</tr>
|
86 |
<tr valign="top">
|
87 |
<th scope="row">Default Height</th>
|
88 |
-
<td><input type="text" size="5" name="
|
89 |
-
<?php
|
90 |
-
<?php
|
91 |
</select></td>
|
92 |
</tr>
|
93 |
<tr valign="top">
|
94 |
-
<td colspan="2"><?php showCheck('gde_ie8_warn', t('Show help message to IE8 users (<a href="http://davismetro.com/gde/ie8/" target="_blank">more info</a>)')); ?></td>
|
95 |
-
</tr>
|
96 |
-
<tr valign="top">
|
97 |
<td colspan="2"><strong>Download Link Options</strong><br/>
|
98 |
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>
|
99 |
</tr>
|
100 |
<tr valign="top">
|
101 |
-
<td colspan="2"><?php
|
102 |
</tr>
|
103 |
<tr valign="top">
|
104 |
<th scope="row">Link Text</th>
|
105 |
-
<td><input type="text" size="50" name="
|
106 |
<em>You can further customize text using these dynamic replacements:</em><br/>
|
107 |
<code>%FN</code> : filename
|
108 |
<code>%FT</code> : file type
|
@@ -110,28 +107,37 @@ To override display setting on an individual post, use <code>save="1"</code> (sh
|
|
110 |
</tr>
|
111 |
<tr valign="top">
|
112 |
<th scope="row">Link Position</th>
|
113 |
-
<td><select name="
|
114 |
-
<?php
|
115 |
-
<?php
|
116 |
</select>
|
117 |
</td>
|
118 |
</tr>
|
119 |
<r valign="top">
|
120 |
<th scope="row">Link Behavior</th>
|
121 |
-
<td><select name="
|
122 |
-
<?php
|
123 |
-
<?php
|
124 |
-
<?php
|
125 |
</select>
|
126 |
</td>
|
127 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
</table>
|
129 |
-
<p class="submit">
|
130 |
<input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID ?>" />
|
131 |
<span id="autosave"></span>
|
132 |
-
<input type="submit" name="submit" value="<?php e('Save Options') ?>" />
|
133 |
|
134 |
-
<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?')" />
|
135 |
</p>
|
136 |
|
137 |
</form>
|
@@ -139,16 +145,20 @@ To override display setting on an individual post, use <code>save="1"</code> (sh
|
|
139 |
</div>
|
140 |
|
141 |
<?php
|
142 |
-
function
|
|
|
|
|
143 |
?>
|
144 |
-
<input type="checkbox" name="<?php echo $option; ?>" value="1" id="<?php echo $option?>"
|
145 |
-
<label for="<?php echo $option?>"><?php e($title) ?></label
|
146 |
-
|
147 |
<?php
|
148 |
}
|
149 |
-
|
|
|
|
|
|
|
150 |
?>
|
151 |
-
<option value="<?php echo $value; ?>"<?php
|
152 |
<?php
|
153 |
}
|
154 |
?>
|
2 |
include_once('wpframe.php');
|
3 |
include_once('functions.php');
|
4 |
|
5 |
+
$ie8_link = GDE_IE8_URL;
|
6 |
+
global $options;
|
7 |
+
|
8 |
if(isset($_REQUEST['defaults'])) {
|
9 |
|
10 |
+
$set = gde_init('reset');
|
11 |
+
$options = get_option('gde_options');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
showMessage("Options reset to defaults");
|
13 |
+
|
14 |
} elseif(isset($_REQUEST['submit'])) {
|
15 |
|
16 |
// change user defaults
|
17 |
+
if(isset($_POST['show_dl'])) {
|
18 |
+
$options['show_dl'] = "yes";
|
19 |
} else {
|
20 |
+
$options['show_dl'] = "no";
|
21 |
}
|
22 |
+
if(isset($_POST['default_width'])) {
|
23 |
+
$neww = $_POST['default_width'];
|
24 |
+
if (strlen($neww) > 0) $options['default_width'] = gde_sanitizeOpt($neww, $_POST['width_type']);
|
25 |
}
|
26 |
+
if(isset($_POST['width_type'])) {
|
27 |
+
$options['width_type'] = $_POST['width_type'];
|
28 |
}
|
29 |
+
if(isset($_POST['default_height'])) {
|
30 |
+
$newh = $_POST['default_height'];
|
31 |
+
if (strlen($newh) > 0) $options['default_height'] = gde_sanitizeOpt($newh, $_POST['height_type']);
|
32 |
}
|
33 |
+
if(isset($_POST['height_type'])) {
|
34 |
+
$options['height_type'] = $_POST['height_type'];
|
35 |
}
|
36 |
+
if(isset($_POST['link_text'])) {
|
37 |
+
$newt = $_POST['link_text'];
|
38 |
+
if (strlen(utf8_decode($newt))) $options['link_text'] = $newt;
|
39 |
}
|
40 |
+
if(isset($_POST['link_pos'])) {
|
41 |
+
$options['link_pos'] = $_POST['link_pos'];
|
42 |
}
|
43 |
+
if(isset($_POST['link_func'])) {
|
44 |
+
$options['link_func'] = $_POST['link_func'];
|
45 |
}
|
46 |
+
if(isset($_POST['ie8_warn'])) {
|
47 |
+
$options['ie8_warn'] = "yes";
|
48 |
} else {
|
49 |
+
$options['ie8_warn'] = "no";
|
50 |
}
|
51 |
+
if(isset($_POST['bypass_check'])) {
|
52 |
+
$options['bypass_check'] = "yes";
|
53 |
} else {
|
54 |
+
$options['bypass_check'] = "no";
|
55 |
}
|
56 |
+
if(isset($_POST['ignore_conflicts'])) {
|
57 |
+
$options['ignore_conflicts'] = "yes";
|
58 |
+
} else {
|
59 |
+
$options['ignore_conflicts'] = "no";
|
60 |
+
}
|
61 |
+
|
62 |
+
update_option('gde_options', $options);
|
63 |
showMessage("Options updated");
|
64 |
}
|
65 |
?>
|
78 |
</tr>
|
79 |
<tr valign="top">
|
80 |
<th scope="row">Default Width</th>
|
81 |
+
<td><input type="text" size="5" name="default_width" value="<?php echo $options['default_width']; ?>" /> <select name="width_type">
|
82 |
+
<?php gde_showOption('px', 'width_type', t('px')); ?>
|
83 |
+
<?php gde_showOption('pc', 'width_type', t('%')); ?>
|
84 |
</select></td>
|
85 |
</tr>
|
86 |
<tr valign="top">
|
87 |
<th scope="row">Default Height</th>
|
88 |
+
<td><input type="text" size="5" name="default_height" value="<?php echo $options['default_height']; ?>" /> <select name="height_type">
|
89 |
+
<?php gde_showOption('px', 'height_type', t('px')); ?>
|
90 |
+
<?php gde_showOption('pc', 'height_type', t('%')); ?>
|
91 |
</select></td>
|
92 |
</tr>
|
93 |
<tr valign="top">
|
|
|
|
|
|
|
94 |
<td colspan="2"><strong>Download Link Options</strong><br/>
|
95 |
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>
|
96 |
</tr>
|
97 |
<tr valign="top">
|
98 |
+
<td colspan="2"><?php gde_showCheck('show_dl', t('Display the download link by default')); ?></td>
|
99 |
</tr>
|
100 |
<tr valign="top">
|
101 |
<th scope="row">Link Text</th>
|
102 |
+
<td><input type="text" size="50" name="link_text" value="<?php echo $options['link_text']; ?>" /><br/>
|
103 |
<em>You can further customize text using these dynamic replacements:</em><br/>
|
104 |
<code>%FN</code> : filename
|
105 |
<code>%FT</code> : file type
|
107 |
</tr>
|
108 |
<tr valign="top">
|
109 |
<th scope="row">Link Position</th>
|
110 |
+
<td><select name="link_pos">
|
111 |
+
<?php gde_showOption('above', 'link_pos', t('Above Viewer')); ?>
|
112 |
+
<?php gde_showOption('below', 'link_pos', t('Below Viewer')); ?>
|
113 |
</select>
|
114 |
</td>
|
115 |
</tr>
|
116 |
<r valign="top">
|
117 |
<th scope="row">Link Behavior</th>
|
118 |
+
<td><select name="link_func">
|
119 |
+
<?php gde_showOption('default', 'link_func', t('Browser Default')); ?>
|
120 |
+
<?php gde_showOption('force', 'link_func', t('Force Download')); ?>
|
121 |
+
<?php gde_showOption('force-mask', 'link_func', t('Force Download (Mask URL)')); ?>
|
122 |
</select>
|
123 |
</td>
|
124 |
</tr>
|
125 |
+
<tr valign="top">
|
126 |
+
<td colspan="2"><strong><a style="text-decoration:none;" href="javascript:;" onmousedown="if(document.getElementById('advopt').style.display == 'none'){ document.getElementById('advopt').style.display = 'block'; }else{ document.getElementById('advopt').style.display = 'none'; }">[ + ]</a> Advanced Options</strong><br />
|
127 |
+
<div id="advopt" style="display:none;">
|
128 |
+
<?php gde_showCheck('ie8_warn', t('Show help message to IE8 users (<a href="'.$ie8_link.'" target="_blank">more info</a>)')); ?><br />
|
129 |
+
<?php gde_showCheck('bypass_check', t('Let Google Doc Viewer handle all errors (for individual files, use <code>force="1"</code>)')); ?><br />
|
130 |
+
<?php gde_showCheck('ignore_conflicts', t('Turn off plugin conflict warnings')); ?>
|
131 |
+
</div></td>
|
132 |
+
</tr>
|
133 |
+
</tr>
|
134 |
</table>
|
135 |
+
<p class="submit" style="padding-bottom:0;">
|
136 |
<input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID ?>" />
|
137 |
<span id="autosave"></span>
|
138 |
+
<input class="button-primary" type="submit" name="submit" value="<?php e('Save Options') ?>" />
|
139 |
|
140 |
+
<input class="button-secondary" 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?')" />
|
141 |
</p>
|
142 |
|
143 |
</form>
|
145 |
</div>
|
146 |
|
147 |
<?php
|
148 |
+
function gde_showCheck($option, $title) {
|
149 |
+
global $options;
|
150 |
+
if ($options[$option] == "yes") { $chk = ' checked="checked"'; }
|
151 |
?>
|
152 |
+
<input type="checkbox" name="<?php echo $option; ?>" value="1" id="<?php echo $option; ?>"<?php echo $chk; ?> />
|
153 |
+
<label for="<?php echo $option; ?>"><?php e($title) ?></label>
|
|
|
154 |
<?php
|
155 |
}
|
156 |
+
|
157 |
+
function gde_showOption($value, $option, $title) {
|
158 |
+
global $options;
|
159 |
+
if ($options[$option] == $value) { $chk = ' selected="yes"'; }
|
160 |
?>
|
161 |
+
<option value="<?php echo $value; ?>"<?php echo $chk; ?>><?php echo $title; ?></option>
|
162 |
<?php
|
163 |
}
|
164 |
?>
|
readme.txt
CHANGED
@@ -2,15 +2,15 @@
|
|
2 |
Contributors: k3davis
|
3 |
Donate link: http://pledgie.com/campaigns/6048
|
4 |
Tags: pdf, ppt, tiff, powerpoint, google, embed, google docs, document
|
5 |
-
Requires at least: 2.
|
6 |
Tested up to: 2.9-rare
|
7 |
Stable tag: trunk
|
8 |
|
9 |
-
Lets you embed PDF, PowerPoint presentations (PPT), and TIFF images in a web page using the Google Docs Viewer.
|
10 |
|
11 |
== Description ==
|
12 |
|
13 |
-
Google Doc Embedder lets you embed PDF files, PowerPoint presentations, and TIFF images in a web page using the Google Docs Viewer.
|
14 |
|
15 |
Similar to services like Scribd, Google Doc Embedder will allow you to embed a PDF, PowerPoint (PPT), or TIFF file directly into your page or post, not requiring the user to have Adobe Reader, PowerPoint, or other software installed to view the contents. Unlike Scribd, the files do not need to be uploaded to any service first - including Google Documents - but can exist anywhere accessible on your site or the internet.
|
16 |
|
@@ -60,6 +60,12 @@ That's not a question ;) but if you have any particular ideas on further develop
|
|
60 |
|
61 |
== Changelog ==
|
62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
= 1.8.2 =
|
64 |
* Fixed: Fatal PHP error if cURL library not active (WAMPServer, etc.)
|
65 |
|
2 |
Contributors: k3davis
|
3 |
Donate link: http://pledgie.com/campaigns/6048
|
4 |
Tags: pdf, ppt, tiff, powerpoint, google, embed, google docs, document
|
5 |
+
Requires at least: 2.7
|
6 |
Tested up to: 2.9-rare
|
7 |
Stable tag: trunk
|
8 |
|
9 |
+
Lets you embed PDF, PowerPoint presentations (PPT), and TIFF images in a web page using the Google Docs Viewer (no Flash or PDF browser plug-ins required).
|
10 |
|
11 |
== Description ==
|
12 |
|
13 |
+
Google Doc Embedder lets you embed PDF files, PowerPoint presentations, and TIFF images in a web page using the Google Docs Viewer (no Flash or PDF browser plug-ins required).
|
14 |
|
15 |
Similar to services like Scribd, Google Doc Embedder will allow you to embed a PDF, PowerPoint (PPT), or TIFF file directly into your page or post, not requiring the user to have Adobe Reader, PowerPoint, or other software installed to view the contents. Unlike Scribd, the files do not need to be uploaded to any service first - including Google Documents - but can exist anywhere accessible on your site or the internet.
|
16 |
|
60 |
|
61 |
== Changelog ==
|
62 |
|
63 |
+
= 1.9 =
|
64 |
+
* Added: Revealed more troubleshooting options (under "Advanced Options")
|
65 |
+
* Fixed: No longer relies on cURL for any function
|
66 |
+
* Changed: Function overhaul for general efficiency and reduced database calls
|
67 |
+
* Removed: WP 2.5 compatibility. Now requires WordPress 2.7+.
|
68 |
+
|
69 |
= 1.8.2 =
|
70 |
* Fixed: Fatal PHP error if cURL library not active (WAMPServer, etc.)
|
71 |
|
screenshot-2.png
CHANGED
Binary file
|
uninstall.php
CHANGED
@@ -2,17 +2,7 @@
|
|
2 |
include_once('functions.php');
|
3 |
|
4 |
// perform cleanup, be a good citizen
|
5 |
-
|
6 |
-
|
7 |
-
foreach ($options as $opt => $val) {
|
8 |
-
delete_option($opt);
|
9 |
-
}
|
10 |
-
|
11 |
-
// remove deprecated options if present
|
12 |
-
|
13 |
-
$legacy_options = getObsolete();
|
14 |
-
foreach ($legacy_options as $lopt => $val) {
|
15 |
-
delete_option($lopt);
|
16 |
-
}
|
17 |
|
18 |
?>
|
2 |
include_once('functions.php');
|
3 |
|
4 |
// perform cleanup, be a good citizen
|
5 |
+
$init = gde_init();
|
6 |
+
delete_option('gde_options');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
?>
|