Google Doc Embedder - Version 2.5.6

Version Description

  • Fixed: (E) Hangs on document load due to Google code changes
  • Fixed: (E) Profile language not honored on New Window button tip (thanks Ege)
  • Fixed: New profiles appear blank on initial load
  • Fixed: HTTP status code check is too stringent for some servers
  • Fixed: Spurious database error on deactivation if log table not present
  • Fixed: PHP error when API key retrieval fails
Download this release

Release Info

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

Code changes from version 2.5.5 to 2.5.6

functions-admin.php CHANGED
@@ -168,6 +168,7 @@ function gde_write_profile( $data, $id = null, $overwrite = false ) {
168
  // overwrite description
169
  $newdata['profile_desc'] = $data[1];
170
  }
 
171
  if ( ! empty( $data[2] ) && ( $data[2] !== serialize( $olddata ) ) ) {
172
  // overwrite data
173
  $newdata['profile_data'] = $data[2];
168
  // overwrite description
169
  $newdata['profile_desc'] = $data[1];
170
  }
171
+
172
  if ( ! empty( $data[2] ) && ( $data[2] !== serialize( $olddata ) ) ) {
173
  // overwrite data
174
  $newdata['profile_data'] = $data[2];
functions.php CHANGED
@@ -125,7 +125,7 @@ function gde_validate_file( $file = NULL, $force ) {
125
  // can't validate
126
  return -1;
127
  } else {
128
- if ( isset( $result['code'] ) && $result['code'] !== 200 ) {
129
  if ( ! gde_valid_link( $file ) ) {
130
  return $badlink;
131
  } else {
125
  // can't validate
126
  return -1;
127
  } else {
128
+ if ( isset( $result['code'] ) && $result['code'] != 200 ) {
129
  if ( ! gde_valid_link( $file ) ) {
130
  return $badlink;
131
  } else {
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.5
12
  License: GPLv2
13
  */
14
 
@@ -38,7 +38,7 @@ License: GPLv2
38
  */
39
 
40
  // boring init junk
41
- $gde_ver = "2.5.5.98";
42
  $gde_db_ver = "1.2"; // update also in gde_activate()
43
 
44
  require_once( plugin_dir_path( __FILE__ ) . 'functions.php' );
@@ -413,7 +413,7 @@ function gde_deactivate() {
413
  $blogid = get_current_blog_id();
414
  $wpdb->query("DELETE FROM $table WHERE blogid = '$blogid'");
415
  } else {
416
- $wpdb->query("DROP TABLE $table");
417
  }
418
  }
419
 
8
  Author URI: http://www.davistribe.org/
9
  Text Domain: gde
10
  Domain Path: /languages/
11
+ Version: 2.5.6
12
  License: GPLv2
13
  */
14
 
38
  */
39
 
40
  // boring init junk
41
+ $gde_ver = "2.5.6.98";
42
  $gde_db_ver = "1.2"; // update also in gde_activate()
43
 
44
  require_once( plugin_dir_path( __FILE__ ) . 'functions.php' );
413
  $blogid = get_current_blog_id();
414
  $wpdb->query("DELETE FROM $table WHERE blogid = '$blogid'");
415
  } else {
416
+ $wpdb->query("DROP TABLE IF EXISTS $table");
417
  }
418
  }
419
 
js/tb-newwin.php CHANGED
@@ -36,16 +36,33 @@ if (top === self) {
36
  } else {
37
  // replace new window function
38
 
 
 
 
 
39
  // recreate button (change icon, tip, and function)
40
  var dv1 = document.createElement("div");
41
  dv1.setAttribute("id", "gdeControlbarOpenInViewerButton");
42
  dv1.setAttribute("class", "goog-inline-block goog-toolbar-button-outer-box");
43
- dv1.setAttribute("title", "<?php echo $tip; ?>");
44
  dv1.setAttribute("onclick", "<?php echo $func; ?>();");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  dv1.innerHTML = '<div class="goog-inline-block goog-toolbar-button-inner-box"><div id="<?php echo $ico; ?>" class="toolbar-button-icon"></div></div>';
46
 
47
- // replace it
48
- var dv2 = document.getElementById('controlbarOpenInViewerButton');
49
  var parentDiv = dv2.parentNode;
50
  parentDiv.replaceChild(dv1, dv2);
51
  }
36
  } else {
37
  // replace new window function
38
 
39
+ // get current button and title
40
+ var dv2 = document.getElementById('controlbarOpenInViewerButton');
41
+ var btntext = dv2.getAttribute("title");
42
+
43
  // recreate button (change icon, tip, and function)
44
  var dv1 = document.createElement("div");
45
  dv1.setAttribute("id", "gdeControlbarOpenInViewerButton");
46
  dv1.setAttribute("class", "goog-inline-block goog-toolbar-button-outer-box");
 
47
  dv1.setAttribute("onclick", "<?php echo $func; ?>();");
48
+
49
+ <?php
50
+ // use WP language (not Google) for tooltip if full screen - this string doesn't exist in Google version
51
+ if ( $_GET['a'] == "fs" ) {
52
+ ?>
53
+ dv1.setAttribute("title", "<?php echo $tip; ?>");
54
+ <?php
55
+ } else {
56
+ // use Google language version for new window, instead of WP language
57
+ ?>
58
+ dv1.setAttribute("title", btntext);
59
+ <?php
60
+ }
61
+ ?>
62
+
63
  dv1.innerHTML = '<div class="goog-inline-block goog-toolbar-button-inner-box"><div id="<?php echo $ico; ?>" class="toolbar-button-icon"></div></div>';
64
 
65
+ // replace the button
 
66
  var parentDiv = dv2.parentNode;
67
  parentDiv.replaceChild(dv1, dv2);
68
  }
libs/lib-profile.php CHANGED
@@ -33,6 +33,18 @@ function gde_profile_form( $id = 1 ) {
33
  }
34
  ?>
35
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  <div id="profile-form">
37
 
38
  <form action="" method="post">
33
  }
34
  ?>
35
 
36
+ <!--
37
+
38
+ <?php
39
+
40
+ echo "id: $id\n\n";
41
+ echo gettype($p)."\n\n";
42
+ print_r($p);
43
+
44
+ ?>
45
+
46
+ -->
47
+
48
  <div id="profile-form">
49
 
50
  <form action="" method="post">
libs/lib-service.php CHANGED
@@ -13,6 +13,9 @@ if ( ! function_exists('gde_activate') ) {
13
  }
14
 
15
  if ( isset( $_REQUEST['json'] ) ) {
 
 
 
16
  switch ( $_REQUEST['json'] ) {
17
  case "profiles":
18
  if ( isset( $_REQUEST['id'] ) ) {
@@ -36,8 +39,6 @@ if ( isset( $_REQUEST['json'] ) ) {
36
  }
37
  case "settings":
38
  if ( isset( $_REQUEST['save'] ) && $_REQUEST['save'] == "1" ) {
39
- // exclude API key from export to file (can't be imported)
40
- unset( $gdeoptions['api_key'] );
41
  $file = 'gde-settings';
42
  gde_output_json( json_encode( $gdeoptions ), true, $file );
43
  } else {
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'] ) ) {
39
  }
40
  case "settings":
41
  if ( isset( $_REQUEST['save'] ) && $_REQUEST['save'] == "1" ) {
 
 
42
  $file = 'gde-settings';
43
  gde_output_json( json_encode( $gdeoptions ), true, $file );
44
  } else {
libs/lib-setup.php CHANGED
@@ -211,22 +211,22 @@ function update_profiles() {
211
  $updated = false;
212
 
213
  $id = $profile['profile_id'];
214
- $data = unserialize( $profile['profile_data'] );
215
-
216
- foreach ( $default as $k => $v ) {
217
- if ( $k !== "desc" && ! array_key_exists( $k, $data ) ) {
218
- $data[$k] = $default[$k];
219
-
220
- $updated = true;
221
  }
222
- }
223
-
224
- if ( $updated ) {
225
- // write updated profile
226
- $data = serialize( $data );
227
- $newpro = array( $profile['profile_name'], $profile['profile_desc'], $data );
228
- if ( gde_write_profile( $newpro, $id, true ) < 1 ) {
229
- gde_dx_log("Failed to update profile '" . $profile['profile_name'] . "'");
230
  }
231
  }
232
  }
@@ -320,7 +320,7 @@ function gde_get_api_key( $ver ) {
320
  $response = wp_remote_get( $api_url );
321
 
322
  if ( is_wp_error( $response ) ) {
323
- $error = $result->get_error_message();
324
  gde_dx_log("API Error: " . $error);
325
  // can't get response
326
  return '';
211
  $updated = false;
212
 
213
  $id = $profile['profile_id'];
214
+ if ( $data = @unserialize( $profile['profile_data'] ) ) {
215
+ foreach ( $default as $k => $v ) {
216
+ if ( $k !== "desc" && ! array_key_exists( $k, $data ) ) {
217
+ $data[$k] = $default[$k];
218
+
219
+ $updated = true;
220
+ }
221
  }
222
+
223
+ if ( $updated ) {
224
+ // write updated profile
225
+ $data = serialize( $data );
226
+ $newpro = array( $profile['profile_name'], $profile['profile_desc'], $data );
227
+ if ( gde_write_profile( $newpro, $id, true ) < 1 ) {
228
+ gde_dx_log("Failed to update profile '" . $profile['profile_name'] . "'");
229
+ }
230
  }
231
  }
232
  }
320
  $response = wp_remote_get( $api_url );
321
 
322
  if ( is_wp_error( $response ) ) {
323
+ $error = $response->get_error_message();
324
  gde_dx_log("API Error: " . $error);
325
  // can't get response
326
  return '';
options.php CHANGED
@@ -20,7 +20,7 @@ if ( isset( $_POST['_general_default'] ) ) {
20
  $tabid = "protab";
21
 
22
  if ( ! empty( $_POST['profile-name'] ) ) {
23
- $name = preg_replace( "/[^A-Za-z0-9 -]/", '', $_POST['profile-name'] );
24
  $name = strtolower( str_replace( " ", "-", $name ) );
25
 
26
  if ( ! preg_match( '/[\pL]/u', $name ) ) {
@@ -31,7 +31,7 @@ if ( isset( $_POST['_general_default'] ) ) {
31
  gde_show_msg( __('Profile name already exists. Please choose another name.', 'gde'), true );
32
  } elseif ( gde_profile_to_profile( $_POST['parent'], $name, stripslashes( $_POST['description'] ) ) ) {
33
  // intercept and redirect to edit profile page
34
- $lastid = $wpdb->insert_id;
35
  $_POST['action'] = "edit";
36
  $_POST['profile'] = $lastid;
37
  $noload = "gentab";
20
  $tabid = "protab";
21
 
22
  if ( ! empty( $_POST['profile-name'] ) ) {
23
+ $name = preg_replace( "/[^A-Za-z0-9 -]/", '', trim( $_POST['profile-name'] ) );
24
  $name = strtolower( str_replace( " ", "-", $name ) );
25
 
26
  if ( ! preg_match( '/[\pL]/u', $name ) ) {
31
  gde_show_msg( __('Profile name already exists. Please choose another name.', 'gde'), true );
32
  } elseif ( gde_profile_to_profile( $_POST['parent'], $name, stripslashes( $_POST['description'] ) ) ) {
33
  // intercept and redirect to edit profile page
34
+ $lastid = gde_profile_name_exists( $name );
35
  $_POST['action'] = "edit";
36
  $_POST['profile'] = $lastid;
37
  $noload = "gentab";
readme.txt CHANGED
@@ -137,12 +137,20 @@ More common questions are answered on the GDE web site [here](http://www.davistr
137
 
138
  (E) Enhanced Viewer
139
 
 
 
 
 
 
 
 
 
140
  = 2.5.5 =
141
- * Added: Option to restrict full screen view to logged-in users
 
142
  * Fixed: Rate limit exceeded on is.gd shortened URLs (thanks Dan)
143
  * Fixed: Some settings remain in database after uninstall
144
  * Fixed: Dimensions not sanitized in editor dialog
145
- * Changed: Activation rebuilt to alleviate profile related errors
146
  * Changed: Insert from Media Library ability restored for WP 3.5+
147
 
148
  = 2.5.4 =
@@ -236,5 +244,5 @@ More common questions are answered on the GDE web site [here](http://www.davistr
236
 
237
  == Upgrade Notice ==
238
 
239
- = 2.5.4 =
240
  Bug fix release
137
 
138
  (E) Enhanced Viewer
139
 
140
+ = 2.5.6 =
141
+ * Fixed: (E) Hangs on document load due to Google code changes
142
+ * Fixed: (E) Profile language not honored on New Window button tip (thanks Ege)
143
+ * Fixed: New profiles appear blank on initial load
144
+ * Fixed: HTTP status code check is too stringent for some servers
145
+ * Fixed: Spurious database error on deactivation if log table not present
146
+ * Fixed: PHP error when API key retrieval fails
147
+
148
  = 2.5.5 =
149
+ * Added: (E) Option to restrict full screen view to logged-in users
150
+ * Fixed: "Unable to load profile settings" on some installs
151
  * Fixed: Rate limit exceeded on is.gd shortened URLs (thanks Dan)
152
  * Fixed: Some settings remain in database after uninstall
153
  * Fixed: Dimensions not sanitized in editor dialog
 
154
  * Changed: Insert from Media Library ability restored for WP 3.5+
155
 
156
  = 2.5.4 =
244
 
245
  == Upgrade Notice ==
246
 
247
+ = 2.5.6 =
248
  Bug fix release
view.php CHANGED
@@ -24,13 +24,11 @@ if ( isset( $_GET['a'] ) && $_GET['a'] == 'gt') {
24
  header( "Location: https://docs.google.com/viewer?" . $_SERVER['QUERY_STRING'] );
25
 
26
  } elseif ( isset( $_GET['jsfile'] ) ) {
27
- // proxy javascript content - not currently used
28
-
29
- /*
30
  $code = gde_get_contents("https://docs.google.com/" . $_GET['jsfile']);
31
  header('Content-type: text/javascript');
32
  echo $code;
33
- */
34
  } else {
35
 
36
  // trap language
@@ -72,8 +70,8 @@ if ( isset( $_GET['a'] ) && $_GET['a'] == 'gt') {
72
  } else {
73
  // fix js path
74
  $search[] = "gview/resources_gview/client/js";
75
- $replace[] = "https://docs.google.com/gview/resources_gview/client/js";
76
- //$replace[] = "?jsfile=gview/resources_gview/client/js"; // use this instead to proxy the js
77
 
78
  // mode-specific styles
79
  if ( $mode == "chrome" ) {
24
  header( "Location: https://docs.google.com/viewer?" . $_SERVER['QUERY_STRING'] );
25
 
26
  } elseif ( isset( $_GET['jsfile'] ) ) {
27
+ // proxy javascript content - not doing anything here but Google changes return 404 if not proxied (??)
 
 
28
  $code = gde_get_contents("https://docs.google.com/" . $_GET['jsfile']);
29
  header('Content-type: text/javascript');
30
  echo $code;
31
+
32
  } else {
33
 
34
  // trap language
70
  } else {
71
  // fix js path
72
  $search[] = "gview/resources_gview/client/js";
73
+ //$replace[] = "https://docs.google.com/gview/resources_gview/client/js"; // use this if js not proxied
74
+ $replace[] = "?jsfile=gview/resources_gview/client/js"; // use this instead to proxy the js
75
 
76
  // mode-specific styles
77
  if ( $mode == "chrome" ) {