Google Doc Embedder - Version 1.8.1

Version Description

  • Added: Temporary (I hope) workaround option to insert help statement for users of IE8 - more info
Download this release

Release Info

Developer k3davis
Plugin Icon wp plugin Google Doc Embedder
Version 1.8.1
Comparing to
See all releases

Code changes from version 1.8 to 1.8.1

Files changed (4) hide show
  1. functions.php +3 -1
  2. gviewer.php +48 -27
  3. options.php +18 -2
  4. readme.txt +3 -0
functions.php CHANGED
@@ -10,7 +10,9 @@ function getDefaults() {
10
  "gde_show_dl" => 1,
11
  "gde_link_text" => "Download (%FT, %FS)",
12
  "gde_link_pos" => "below",
13
- "gde_link_func" => "default"
 
 
14
  );
15
  return $defaults;
16
  }
10
  "gde_show_dl" => 1,
11
  "gde_link_text" => "Download (%FT, %FS)",
12
  "gde_link_pos" => "below",
13
+ "gde_link_func" => "default",
14
+ "gde_ie8_warn" => 0,
15
+ "gde_bypass_check" => 0
16
  );
17
  return $defaults;
18
  }
gviewer.php CHANGED
@@ -5,24 +5,34 @@ 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.8
9
  */
10
 
11
- /* Copyright 2009 Kevin Davis. E-mail: kev@tnw.org
12
- This program is free software; you can redistribute it and/or modify
13
- it under the terms of the GNU General Public License as published by
14
- the Free Software Foundation; either version 2 of the License, or
15
- (at your option) any later version.
16
-
17
- This program is distributed in the hope that it will be useful,
18
- but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
- GNU General Public License for more details.
21
-
22
- You should have received a copy of the GNU General Public License
23
- along with this program; if not, write to the Free Software
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');
@@ -33,12 +43,14 @@ function gviewer_func($atts) {
33
  // current settings
34
  $dl = get_option('gde_show_dl');
35
  $txt = get_option('gde_link_text');
 
 
36
  extract(shortcode_atts(array(
37
  'file' => '',
38
  'save' => $dl,
39
  'width' => '',
40
  'height' => '',
41
- 'force' => ''
42
  ), $atts));
43
  $width = str_replace("px", "", trim($width));
44
  if (!$width || !preg_match("/^\d+%?$/", $width)) {
@@ -75,10 +87,13 @@ function gviewer_func($atts) {
75
  $fsize = formatBytes($fsize);
76
 
77
  $code=<<<HERE
 
78
  <iframe src="%U%" width="%W%" height="%H%" frameborder="0" style="min-width:305px;" class="gde-frame"></iframe>\n
 
79
  HERE;
80
 
81
  $lnk = "http://docs.google.com/viewer?url=".urlencode($file)."&embedded=true";
 
82
 
83
  if ($save == "1") {
84
 
@@ -105,15 +120,21 @@ HERE;
105
  $dlFile = $file;
106
  $target = "_self";
107
  }
108
- $linkcode = "<p class=\"gde-text\"><a href=\"$dlFile\" target=\"$target\" class=\"gde-link\">$txt</a></p>";
109
-
110
- if (get_option('gde_link_pos') == "above") {
111
- $code = $linkcode . '' . $code;
112
- } else {
113
- $code = $code . '' . $linkcode;
114
- }
115
  }
116
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  $code = str_replace("%U%", $lnk, $code);
118
  $code = str_replace("%W%", $width, $code);
119
  $code = str_replace("%H%", $height, $code);
@@ -157,13 +178,13 @@ function gde_options() {
157
  }
158
 
159
  // add additional settings link, for convenience
160
- $plugin = plugin_basename(__FILE__);
161
- function my_plugin_actlinks( $links ) {
162
  $settings_link = '<a href="options-general.php?page=gviewer.php">Settings</a>';
163
  array_unshift($links, $settings_link);
164
  return $links;
165
  }
166
- add_filter("plugin_action_links_$plugin", 'my_plugin_actlinks' );
167
 
168
  // activate shortcode
169
  add_shortcode('gview', 'gviewer_func');
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.8.1
9
  */
10
 
11
+ /**
12
+ * LICENSE
13
+ * This file is part of Google Doc Embedder.
14
+ *
15
+ * Google Doc Embedder is free software; you can redistribute it and/or
16
+ * modify it under the terms of the GNU General Public License
17
+ * as published by the Free Software Foundation; either version 2
18
+ * of the License, or (at your option) any later version.
19
+ *
20
+ * This program is distributed in the hope that it will be useful,
21
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ * GNU General Public License for more details.
24
+ *
25
+ * You should have received a copy of the GNU General Public License
26
+ * along with this program; if not, write to the Free Software
27
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
+ *
29
+ * @package google-document-embedder
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.8.1
34
+ * @link http://davismetro.com/gde/
35
+ */
36
 
37
  include_once('wpframe.php');
38
  include_once('functions.php');
43
  // current settings
44
  $dl = get_option('gde_show_dl');
45
  $txt = get_option('gde_link_text');
46
+ $ie8warn = get_option('gde_ie8_warn');
47
+ $bypass = get_option('gde_bypass_check');
48
  extract(shortcode_atts(array(
49
  'file' => '',
50
  'save' => $dl,
51
  'width' => '',
52
  'height' => '',
53
+ 'force' => $bypass
54
  ), $atts));
55
  $width = str_replace("px", "", trim($width));
56
  if (!$width || !preg_match("/^\d+%?$/", $width)) {
87
  $fsize = formatBytes($fsize);
88
 
89
  $code=<<<HERE
90
+ %A%
91
  <iframe src="%U%" width="%W%" height="%H%" frameborder="0" style="min-width:305px;" class="gde-frame"></iframe>\n
92
+ %B%
93
  HERE;
94
 
95
  $lnk = "http://docs.google.com/viewer?url=".urlencode($file)."&embedded=true";
96
+ $linkcode = "";
97
 
98
  if ($save == "1") {
99
 
120
  $dlFile = $file;
121
  $target = "_self";
122
  }
123
+ $linkcode .= "<p class=\"gde-text\"><a href=\"$dlFile\" target=\"$target\" class=\"gde-link\">$txt</a></p>";
 
 
 
 
 
 
124
  }
125
 
126
+ if ($ie8warn == "1") {
127
+ $warn = __("IE8 User: If you're having trouble viewing this document, go to Tools -> Internet Options -> Privacy -> Advanced -> Check &quot;Override automatic cookie handling&quot;.");
128
+ $linkcode .= "\n<!--[if gte IE 8]>\n<p class=\"gde-iewarn\">".$warn."</p>\n<![endif]-->\n";
129
+ }
130
+
131
+ if (get_option('gde_link_pos') == "above") {
132
+ $code = str_replace("%A%", $linkcode, $code);
133
+ $code = str_replace("%B%", '', $code);
134
+ } else {
135
+ $code = str_replace("%A%", '', $code);
136
+ $code = str_replace("%B%", $linkcode, $code);
137
+ }
138
  $code = str_replace("%U%", $lnk, $code);
139
  $code = str_replace("%W%", $width, $code);
140
  $code = str_replace("%H%", $height, $code);
178
  }
179
 
180
  // add additional settings link, for convenience
181
+ $plugin = plugin_basename(__FILE__);
182
+ function gde_actlinks( $links ) {
183
  $settings_link = '<a href="options-general.php?page=gviewer.php">Settings</a>';
184
  array_unshift($links, $settings_link);
185
  return $links;
186
  }
187
+ add_filter("plugin_action_links_$plugin", 'gde_actlinks' );
188
 
189
  // activate shortcode
190
  add_shortcode('gview', 'gviewer_func');
options.php CHANGED
@@ -14,6 +14,8 @@ if(isset($_REQUEST['defaults'])) {
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
 
18
  showMessage("Options reset to defaults");
19
  } elseif(isset($_REQUEST['submit'])) {
@@ -48,12 +50,23 @@ if(isset($_REQUEST['defaults'])) {
48
  if(isset($_POST['gde_link_func'])) {
49
  update_option('gde_link_func', $_POST['gde_link_func']);
50
  }
51
-
 
 
 
 
 
 
 
 
 
52
  showMessage("Options updated");
53
  }
54
  ?>
55
  <div class="wrap">
56
- <h2>Google Doc Embedder Settings</h2>
 
 
57
 
58
  <form action="" method="post">
59
  <?php wp_nonce_field('update-options'); ?>
@@ -78,6 +91,9 @@ To override size on individual posts, manually set in the post shortcode using (
78
  </select></td>
79
  </tr>
80
  <tr valign="top">
 
 
 
81
  <td colspan="2"><strong>Download Link Options</strong><br/>
82
  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>
83
  </tr>
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'])) {
50
  if(isset($_POST['gde_link_func'])) {
51
  update_option('gde_link_func', $_POST['gde_link_func']);
52
  }
53
+ if(isset($_POST['gde_ie8_warn'])) {
54
+ update_option('gde_ie8_warn', 1);
55
+ } else {
56
+ update_option('gde_ie8_warn', 0);
57
+ }
58
+ if(isset($_POST['gde_bypass_check'])) {
59
+ update_option('gde_bypass_check', 1);
60
+ } else {
61
+ update_option('gde_bypass_check', 0);
62
+ }
63
  showMessage("Options updated");
64
  }
65
  ?>
66
  <div class="wrap">
67
+ <?php
68
+ echo "<h2>".__('Google Doc Embedder Settings')."</h2>";
69
+ ?>
70
 
71
  <form action="" method="post">
72
  <?php wp_nonce_field('update-options'); ?>
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>
readme.txt CHANGED
@@ -60,6 +60,9 @@ That's not a question ;) but if you have any particular ideas on further develop
60
 
61
  == Changelog ==
62
 
 
 
 
63
  = 1.8 =
64
  * Added: Ability to set height/width to percentage (thanks eturfboer)
65
  * Fixed: Compatibility with PHP 5.3+, various function tuning
60
 
61
  == Changelog ==
62
 
63
+ = 1.8.1 =
64
+ * Added: Temporary (I hope) workaround option to insert help statement for users of IE8 - <a href="http://davismetro.com/gde/ie8" target="_blank">more info</a>
65
+
66
  = 1.8 =
67
  * Added: Ability to set height/width to percentage (thanks eturfboer)
68
  * Fixed: Compatibility with PHP 5.3+, various function tuning