Google Doc Embedder - Version 2.5.13

Version Description

  • Fixed: Javascript error within WP 3.9 visual editor (thanks Sergey)
  • Fixed: (E) Unsupported browser message on some documents
  • Changed: (E) Lengthened default network timeout
  • Removed: Long-useless authonly
Download this release

Release Info

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

Code changes from version 2.5.12 to 2.5.13

functions-admin.php CHANGED
@@ -348,7 +348,6 @@ function gde_import_settings( $data ) {
348
  global $gdeoptions;
349
 
350
  $current = $gdeoptions;
351
- unset( $current['api_key'] );
352
 
353
  if ( $current == $data ) {
354
  // nothing to do
348
  global $gdeoptions;
349
 
350
  $current = $gdeoptions;
 
351
 
352
  if ( $current == $data ) {
353
  // nothing to do
gviewer.php CHANGED
@@ -8,7 +8,7 @@ Author: Kevin Davis
8
  Author URI: http://www.davistribe.org/
9
  Text Domain: gde
10
  Domain Path: /languages/
11
- Version: 2.5.12
12
  License: GPLv2
13
  */
14
 
@@ -38,7 +38,7 @@ License: GPLv2
38
  */
39
 
40
  // boring init junk
41
- $gde_ver = "2.5.12.98";
42
  $gde_db_ver = "1.2"; // update also in gde_activate()
43
 
44
  require_once( plugin_dir_path( __FILE__ ) . 'functions.php' );
@@ -94,13 +94,9 @@ function gde_do_shortcode( $atts ) {
94
  'save' => '',
95
  'width' => '',
96
  'height' => '',
97
- 'cache' => '',
98
- 'title' => '', // not yet implemented
99
  //'page' => '', // support broken in Google Viewer
100
-
101
- // backwards compatibility < gde 2.5 (still work but now "deprecated" and discouraged in the documentation)
102
- 'authonly' => '',
103
- 'lang' => ''
104
  ), $atts ) );
105
 
106
  // get requested profile data (or default if doesn't exist)
@@ -110,7 +106,7 @@ function gde_do_shortcode( $atts ) {
110
  if ( ! $profile = gde_get_profiles( $term ) ) {
111
  gde_dx_log("Loading default profile instead");
112
  if ( ! $profile = gde_get_profiles( 1 ) ) {
113
- $code = gde_show_error( __('Unable to load requested profile.', 'gde') );
114
  } else {
115
  $pid = 1;
116
  }
@@ -122,7 +118,7 @@ function gde_do_shortcode( $atts ) {
122
  if ( ! $profile = gde_get_profiles( strtolower( $term ) ) ) {
123
  gde_dx_log("Loading default profile instead");
124
  if ( ! $profile = gde_get_profiles( 1 ) ) {
125
- $code = gde_show_error( __('Unable to load requested profile.', 'gde') );
126
  } else {
127
  $pid = 1;
128
  }
@@ -148,11 +144,9 @@ function gde_do_shortcode( $atts ) {
148
  $cache = $profile['cache'];
149
  }
150
  }
151
- if ( empty( $lang ) ) {
152
- if ( $profile['language'] !== "en_US" ) {
153
- $lang = $profile['language'];
154
- }
155
- }
156
 
157
  // tweak the dimensions if necessary
158
  $width = gde_sanitize_dims( $width );
@@ -181,6 +175,11 @@ function gde_do_shortcode( $atts ) {
181
  $fn = basename( $file );
182
  $fnp = gde_split_filename( $fn );
183
 
 
 
 
 
 
184
  // file validation
185
  if ( $gdeoptions['error_check'] == "no" ) {
186
  $force = true;
@@ -278,7 +277,7 @@ function gde_do_shortcode( $atts ) {
278
  if ( ! empty( $links[1] ) ) { // link empty = secure document; ignore any other save attribute
279
  if ( $save == "all" || $save == "1" ) {
280
  $allow_save = true;
281
- } elseif ( ( $save == "users" || $authonly == "1" ) && is_user_logged_in() ) {
282
  $allow_save = true;
283
  }
284
  }
8
  Author URI: http://www.davistribe.org/
9
  Text Domain: gde
10
  Domain Path: /languages/
11
+ Version: 2.5.13
12
  License: GPLv2
13
  */
14
 
38
  */
39
 
40
  // boring init junk
41
+ $gde_ver = "2.5.13.98";
42
  $gde_db_ver = "1.2"; // update also in gde_activate()
43
 
44
  require_once( plugin_dir_path( __FILE__ ) . 'functions.php' );
94
  'save' => '',
95
  'width' => '',
96
  'height' => '',
97
+ 'cache' => ''
98
+ //'title' => '', // not yet implemented
99
  //'page' => '', // support broken in Google Viewer
 
 
 
 
100
  ), $atts ) );
101
 
102
  // get requested profile data (or default if doesn't exist)
106
  if ( ! $profile = gde_get_profiles( $term ) ) {
107
  gde_dx_log("Loading default profile instead");
108
  if ( ! $profile = gde_get_profiles( 1 ) ) {
109
+ return gde_show_error( __('Unable to load requested profile.', 'gde') );
110
  } else {
111
  $pid = 1;
112
  }
118
  if ( ! $profile = gde_get_profiles( strtolower( $term ) ) ) {
119
  gde_dx_log("Loading default profile instead");
120
  if ( ! $profile = gde_get_profiles( 1 ) ) {
121
+ return gde_show_error( __('Unable to load requested profile.', 'gde') );
122
  } else {
123
  $pid = 1;
124
  }
144
  $cache = $profile['cache'];
145
  }
146
  }
147
+ //if ( $profile['language'] !== "en_US" ) {
148
+ $lang = $profile['language'];
149
+ //}
 
 
150
 
151
  // tweak the dimensions if necessary
152
  $width = gde_sanitize_dims( $width );
175
  $fn = basename( $file );
176
  $fnp = gde_split_filename( $fn );
177
 
178
+ // check for missing required field
179
+ if ( ! $file ) {
180
+ return gde_show_error( __('File not specified, check shortcode syntax', 'gde') );
181
+ }
182
+
183
  // file validation
184
  if ( $gdeoptions['error_check'] == "no" ) {
185
  $force = true;
277
  if ( ! empty( $links[1] ) ) { // link empty = secure document; ignore any other save attribute
278
  if ( $save == "all" || $save == "1" ) {
279
  $allow_save = true;
280
+ } elseif ( $save == "users" && is_user_logged_in() ) {
281
  $allow_save = true;
282
  }
283
  }
js/editor_plugin.js CHANGED
@@ -1,5 +1,4 @@
1
  (function() {
2
- tinymce.PluginManager.requireLangPack('gde');
3
  tinymce.create('tinymce.plugins.gde', {
4
  init : function(ed,url) {
5
  // fix path
1
  (function() {
 
2
  tinymce.create('tinymce.plugins.gde', {
3
  init : function(ed,url) {
4
  // fix path
js/gde-jquery.js CHANGED
@@ -340,7 +340,6 @@ jQuery(function ($) {
340
  }
341
  });
342
 
343
-
344
  // validate input
345
  $("#debugsend").click(function(e) {
346
  $(".err").hide();
@@ -354,7 +353,9 @@ jQuery(function ($) {
354
 
355
  e.preventDefault();
356
 
357
- if ($('#sc').val() == "" && $('#msg').val() == "") {
 
 
358
  alert( jqs_vars.baddebug );
359
  } else {
360
  $("#debugsend").attr("disabled","true");
340
  }
341
  });
342
 
 
343
  // validate input
344
  $("#debugsend").click(function(e) {
345
  $(".err").hide();
353
 
354
  e.preventDefault();
355
 
356
+ if ($('#sc').val() !== "" && $('#msg').val() == "") {
357
+ alert( jqs_vars.baddebug );
358
+ } else if ($('#msg').val() == "") {
359
  alert( jqs_vars.baddebug );
360
  } else {
361
  $("#debugsend").attr("disabled","true");
libs/lib-formsubmit.php CHANGED
@@ -17,12 +17,12 @@ if ( ! function_exists('gde_activate') ) {
17
  // gather settings and profiles
18
  $datasrc = GDE_PLUGIN_URL . 'libs/lib-service.php?json=all';
19
  $response = wp_remote_get( $datasrc );
20
- if ( is_wp_error( $response ) ) {
21
- $contents = "Error attaching export data.";
22
- $file = "export-error.txt";
23
- } else {
24
  $contents = $response['body'];
25
  $file = "gde-export.txt";
 
 
 
26
  }
27
  $phpmailer->AddStringAttachment( $contents, $file, 'base64', 'text/plain' );
28
 
17
  // gather settings and profiles
18
  $datasrc = GDE_PLUGIN_URL . 'libs/lib-service.php?json=all';
19
  $response = wp_remote_get( $datasrc );
20
+ if ( !is_wp_error( $response ) && strlen( strip_tags( $response['body'] ) ) > 0 ) {
 
 
 
21
  $contents = $response['body'];
22
  $file = "gde-export.txt";
23
+ } else {
24
+ $contents = "Error attaching export data.";
25
+ $file = "export-error.txt";
26
  }
27
  $phpmailer->AddStringAttachment( $contents, $file, 'base64', 'text/plain' );
28
 
libs/lib-profile.php CHANGED
@@ -114,7 +114,7 @@ function gde_profile_form( $id = 1 ) {
114
  <?php
115
  gde_profile_checkbox( $p['tb_fullwin'], 'fs_win', __('Open in New Window', 'gde') );
116
  gde_profile_checkbox( $p['tb_fulluser'], 'fs_user', __('Allow Logged-in Users Only', 'gde'), 'blockAnon' );
117
- gde_profile_checkbox( $p['tb_print'], 'fs_print', __('Allow Printing', 'gde'), 'allowPrint' );
118
  ?>
119
  </td>
120
  </tr>
114
  <?php
115
  gde_profile_checkbox( $p['tb_fullwin'], 'fs_win', __('Open in New Window', 'gde') );
116
  gde_profile_checkbox( $p['tb_fulluser'], 'fs_user', __('Allow Logged-in Users Only', 'gde'), 'blockAnon' );
117
+ //gde_profile_checkbox( $p['tb_print'], 'fs_print', __('Allow Printing', 'gde'), 'allowPrint' );
118
  ?>
119
  </td>
120
  </tr>
libs/lib-service.php CHANGED
@@ -13,9 +13,6 @@ if ( ! function_exists('gde_activate') ) {
13
  }
14
 
15
  if ( isset( $_REQUEST['json'] ) ) {
16
- // exclude API key from export to file (can't be imported)
17
- unset( $gdeoptions['api_key'] );
18
-
19
  switch ( $_REQUEST['json'] ) {
20
  case "profiles":
21
  if ( isset( $_REQUEST['id'] ) ) {
13
  }
14
 
15
  if ( isset( $_REQUEST['json'] ) ) {
 
 
 
16
  switch ( $_REQUEST['json'] ) {
17
  case "profiles":
18
  if ( isset( $_REQUEST['id'] ) ) {
libs/lib-setup.php CHANGED
@@ -1,5 +1,10 @@
1
  <?php
2
 
 
 
 
 
 
3
  /**
4
  * Define system defaults (settings/profiles)
5
  *
@@ -18,16 +23,14 @@ function gde_defaults( $type ) {
18
  $env = array(
19
  'pdata' => $pdata,
20
  'baseurl' => $baseurl,
21
- 'default_lang' => $default_lang,
22
- 'apikey' => $apikey
23
  );
24
  }
25
 
26
  // define "global" options (multisite only)
27
  $globalopts = array(
28
  'file_maxsize' => '12',
29
- 'beta_check' => 'no',
30
- 'api_key' => $env['apikey']
31
  );
32
 
33
  // define default options
@@ -42,8 +45,7 @@ function gde_defaults( $type ) {
42
  'beta_check' => 'no',
43
  'ga_enable' => 'no',
44
  'ga_category' => $env['pdata']['Name'],
45
- 'ga_label' => 'url',
46
- 'api_key' => $env['apikey']
47
  );
48
 
49
  // define default profile(s)
@@ -274,13 +276,6 @@ function gde_get_options() {
274
  gde_dx_log('Options were updated');
275
  update_option('gde_options', $defopts);
276
  }
277
-
278
- // set API key if empty (ie., failed on earlier attempt or first upgrade)
279
- if ( empty( $gdeoptions['api_key'] ) && ! empty( $apikey ) ) {
280
- $gdeoptions['api_key'] = $apikey;
281
- gde_dx_log("Updated API Key");
282
- update_option( 'gde_options', $gdeoptions );
283
- }
284
  }
285
  }
286
 
1
  <?php
2
 
3
+ if ( ! function_exists('gde_activate') ) {
4
+ // no access if parent plugin is disabled or when accessed directly
5
+ wp_die('<p>'.__('You do not have sufficient permissions to access this page.').'</p>');
6
+ }
7
+
8
  /**
9
  * Define system defaults (settings/profiles)
10
  *
23
  $env = array(
24
  'pdata' => $pdata,
25
  'baseurl' => $baseurl,
26
+ 'default_lang' => $default_lang
 
27
  );
28
  }
29
 
30
  // define "global" options (multisite only)
31
  $globalopts = array(
32
  'file_maxsize' => '12',
33
+ 'beta_check' => 'no'
 
34
  );
35
 
36
  // define default options
45
  'beta_check' => 'no',
46
  'ga_enable' => 'no',
47
  'ga_category' => $env['pdata']['Name'],
48
+ 'ga_label' => 'url'
 
49
  );
50
 
51
  // define default profile(s)
276
  gde_dx_log('Options were updated');
277
  update_option('gde_options', $defopts);
278
  }
 
 
 
 
 
 
 
279
  }
280
  }
281
 
libs/tab-support.php CHANGED
@@ -64,7 +64,7 @@
64
  </td>
65
  </tr>
66
  <tr valign="top">
67
- <th scope="row"><label for="msg" id="msg_label"><?php _e('Message', 'gde'); ?></label></th>
68
  <td>
69
  <textarea name="message" id="msg" style="width:75%;min-height:50px;"></textarea>
70
  </td>
@@ -89,7 +89,6 @@
89
  echo "=== GDE Debug Information ===\n\n";
90
 
91
  echo "GDE Version: $gde_ver / GDE DB: " . get_site_option( 'gde_db_version', 0 ) . "\n";
92
- echo "API Key: " . $gdeoptions['api_key'] . "\n";
93
  echo "Profiles: " . gde_debug_tables( 'gde_profiles', true ) . "\n";
94
  echo "Secure Docs: " . gde_debug_tables( 'gde_secure', true );
95
 
64
  </td>
65
  </tr>
66
  <tr valign="top">
67
+ <th scope="row"><label for="msg" id="msg_label"><?php _e('Message', 'gde'); ?>*</label></th>
68
  <td>
69
  <textarea name="message" id="msg" style="width:75%;min-height:50px;"></textarea>
70
  </td>
89
  echo "=== GDE Debug Information ===\n\n";
90
 
91
  echo "GDE Version: $gde_ver / GDE DB: " . get_site_option( 'gde_db_version', 0 ) . "\n";
 
92
  echo "Profiles: " . gde_debug_tables( 'gde_profiles', true ) . "\n";
93
  echo "Secure Docs: " . gde_debug_tables( 'gde_secure', true );
94
 
load.php CHANGED
@@ -97,7 +97,7 @@ if ( ! $contents || empty( $contents ) ) {
97
  }
98
 
99
  // output document
100
- header('Content-type: '.$type);
101
  header('Content-Disposition: attachment; filename="'.$fn.'"');
102
 
103
  echo $contents;
97
  }
98
 
99
  // output document
100
+ header('Content-type: '.$type.'; charset=utf-8');
101
  header('Content-Disposition: attachment; filename="'.$fn.'"');
102
 
103
  echo $contents;
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: doc, docx, pdf, ppt, pptx, xls, psd, zip, rar, tiff, ttf, office, powerpoi
4
  Author URI: http://www.davistribe.org/code/
5
  Donate link: http://www.davistribe.org/gde/donate/
6
  Requires at least: 3.5
7
- Tested up to: 3.8
8
  Stable tag: trunk
9
  License: GPLv2 or later
10
 
@@ -74,7 +74,8 @@ You can upload it to your WordPress site using the standard techniques, or link
74
  There are several ways you can insert a supported document, depending on your preference:
75
 
76
  * Manually enter the shortcode (explained below).
77
- * Upload a supported file type from a page or post, and from the Media Library, click the "Insert" button.
 
78
  * Use the Google Doc Embedder button in the Visual editor to insert the `[gview]` shortcode.
79
  * Paste the URL into the HTML editor, select it, and click the "GDE" quicktag button (HTML/Text editor).
80
 
@@ -135,6 +136,12 @@ More common questions are answered on the GDE web site [here](http://www.davistr
135
 
136
  (E) Enhanced Viewer
137
 
 
 
 
 
 
 
138
  = 2.5.12 =
139
  * Changed: Updated mobile detection library
140
  * Changed: Updated settings navigation style for WP 3.8+
@@ -233,5 +240,5 @@ More common questions are answered on the GDE web site [here](http://www.davistr
233
 
234
  == Upgrade Notice ==
235
 
236
- = 2.5.12 =
237
  Maintenance release
4
  Author URI: http://www.davistribe.org/code/
5
  Donate link: http://www.davistribe.org/gde/donate/
6
  Requires at least: 3.5
7
+ Tested up to: 3.9
8
  Stable tag: trunk
9
  License: GPLv2 or later
10
 
74
  There are several ways you can insert a supported document, depending on your preference:
75
 
76
  * Manually enter the shortcode (explained below).
77
+ * Click the "Add Media" button to upload or select a file from your media library, and ensure the "Link To" setting in Attachment Display Settings
78
+ is set to "Media File." Then click "Insert into post."
79
  * Use the Google Doc Embedder button in the Visual editor to insert the `[gview]` shortcode.
80
  * Paste the URL into the HTML editor, select it, and click the "GDE" quicktag button (HTML/Text editor).
81
 
136
 
137
  (E) Enhanced Viewer
138
 
139
+ = 2.5.13 =
140
+ * Fixed: Javascript error within WP 3.9 visual editor (thanks Sergey)
141
+ * Fixed: (E) Unsupported browser message on some documents
142
+ * Changed: (E) Lengthened default network timeout
143
+ * Removed: Long-useless authonly= and lang= shortcode parameters (use profiles)
144
+
145
  = 2.5.12 =
146
  * Changed: Updated mobile detection library
147
  * Changed: Updated settings navigation style for WP 3.8+
240
 
241
  == Upgrade Notice ==
242
 
243
+ = 2.5.13 =
244
  Maintenance release
view.php CHANGED
@@ -6,7 +6,12 @@
6
 
7
  // access wp functions externally
8
  require_once('libs/lib-bootstrap.php');
9
-
 
 
 
 
 
10
  if ( isset( $_GET['a'] ) && $_GET['a'] == 'gt') {
11
  // proxy xml content - must be done to avoid XSS failures (contains embedded link data and enables text selection)
12
 
@@ -252,9 +257,9 @@ if ( isset( $_GET['a'] ) && $_GET['a'] == 'gt') {
252
  if ( $profile['tb_fullwin'] == "same" ) {
253
  $arg[] = "a=fs";
254
  }
255
- if ( $profile['tb_print'] == "yes" ) {
256
- $arg[] = "p=1";
257
- }
258
  if ( isset( $arg ) && is_array( $arg ) ) {
259
  $src .= "?hl=$lang&" . implode("&", $arg);
260
  }
@@ -291,7 +296,13 @@ if ( isset( $_GET['a'] ) && $_GET['a'] == 'gt') {
291
  */
292
  function gde_get_contents( $url ) {
293
 
294
- $response = wp_remote_get( $url, array( 'timeout' => 15, 'sslverify' => false ) );
 
 
 
 
 
 
295
 
296
  if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
297
  gde_dx_log("Error retrieving document");
@@ -326,7 +337,7 @@ function gde_curl_get_contents( $url ) {
326
  curl_setopt_array( $ch, array(
327
  CURLOPT_URL => $url,
328
  CURLOPT_RETURNTRANSFER => true,
329
- CURLOPT_CONNECTTIMEOUT => 15, // HTTP API is 5, overridden in gde_get_contents to match this
330
  CURLOPT_SSL_VERIFYPEER => false
331
  ) );
332
  $file_contents = curl_exec( $ch );
@@ -384,7 +395,8 @@ function gde_get_mode( $get ) {
384
  } elseif ( isset( $get['mobile'] ) ) {
385
  return "mobile";
386
  } elseif ( isset( $get['chrome'] ) ) {
387
- return "chrome";
 
388
  } else {
389
  return false;
390
  }
6
 
7
  // access wp functions externally
8
  require_once('libs/lib-bootstrap.php');
9
+
10
+ // no access if parent plugin is disabled
11
+ if ( ! function_exists('gde_activate') ) {
12
+ wp_die('<p>'.__('You do not have sufficient permissions to access this page.').'</p>');
13
+ }
14
+
15
  if ( isset( $_GET['a'] ) && $_GET['a'] == 'gt') {
16
  // proxy xml content - must be done to avoid XSS failures (contains embedded link data and enables text selection)
17
 
257
  if ( $profile['tb_fullwin'] == "same" ) {
258
  $arg[] = "a=fs";
259
  }
260
+ //if ( $profile['tb_print'] == "yes" ) {
261
+ // $arg[] = "p=1";
262
+ //}
263
  if ( isset( $arg ) && is_array( $arg ) ) {
264
  $src .= "?hl=$lang&" . implode("&", $arg);
265
  }
296
  */
297
  function gde_get_contents( $url ) {
298
 
299
+ $opts = array(
300
+ 'user-agent' => 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0',
301
+ 'timeout' => 20,
302
+ 'ssl_verify' => false
303
+ );
304
+
305
+ $response = wp_remote_get( $url, $opts );
306
 
307
  if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
308
  gde_dx_log("Error retrieving document");
337
  curl_setopt_array( $ch, array(
338
  CURLOPT_URL => $url,
339
  CURLOPT_RETURNTRANSFER => true,
340
+ CURLOPT_CONNECTTIMEOUT => 20, // HTTP API is 5, overridden in gde_get_contents to match this
341
  CURLOPT_SSL_VERIFYPEER => false
342
  ) );
343
  $file_contents = curl_exec( $ch );
395
  } elseif ( isset( $get['mobile'] ) ) {
396
  return "mobile";
397
  } elseif ( isset( $get['chrome'] ) ) {
398
+ //return "chrome";
399
+ return "embedded";
400
  } else {
401
  return false;
402
  }