Embed Any Document - Version 1.1

Version Description

  • 2014-11-12 =
  • File Not Found fix

=

Download this release

Release Info

Developer awsmin
Plugin Icon Embed Any Document
Version 1.1
Comparing to
See all releases

Code changes from version 1.0.1 to 1.1

aswm-embed.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Embed Any Document
4
  Plugin URI: http://awsm.in/embed-any-documents
5
  Description: Embed Any Document WordPress plugin lets you upload and embed your documents easily in your WordPress website without any additional browser plugins like Flash or Acrobat reader. The plugin lets you choose between Google Docs Viewer and Microsoft Office Online to display your documents.
6
- Version: 1.0.1
7
  Author: Awsm Innovations
8
  Author URI: http://awsm.in
9
  License: GPL V3
@@ -15,6 +15,7 @@ class Awsm_embed {
15
  private $plugin_url;
16
  private $plugin_base;
17
  private $plugin_file;
 
18
  private $settings_slug;
19
  private $text_domain = 'ead';
20
  /**
@@ -38,6 +39,7 @@ class Awsm_embed {
38
  $this->plugin_base = dirname( plugin_basename( __FILE__ ) );
39
  $this->plugin_file = __FILE__ ;
40
  $this->settings_slug = 'ead-settings';
 
41
 
42
  load_plugin_textdomain($this->text_domain, false,$this->plugin_base . '/language' );
43
 
@@ -54,13 +56,15 @@ class Awsm_embed {
54
  add_action( 'wp_ajax_validateurl',array( $this, 'validateurl' ));
55
  //ajax Contact Form
56
  add_action( 'wp_ajax_supportform',array( $this, 'supportform' ));
 
 
57
  $this->run_plugin();
58
  }
59
  /**
60
  * Register admin Settings style
61
  */
62
  function setting_styles(){
63
- wp_register_style( 'embed-settings', plugins_url( 'css/settings.css', $this->plugin_file ), false, '1.0', 'all' );
64
  wp_enqueue_style('embed-settings');
65
  }
66
  /**
@@ -107,9 +111,6 @@ class Awsm_embed {
107
  * Embed Form popup
108
  */
109
  function embedpopup(){
110
- if (!current_user_can('manage_options')) {
111
- wp_die(__('You do not have sufficient permissions to access this page.'));
112
- }
113
  include($this->plugin_path.'inc/popup.php');
114
  }
115
  /**
@@ -117,14 +118,14 @@ class Awsm_embed {
117
  */
118
  function embed_helper(){
119
  wp_register_style( 'magnific-popup', plugins_url( 'css/magnific-popup.css', $this->plugin_file ), false, '0.9.9', 'all' );
120
- wp_register_style( 'embed-css', plugins_url( 'css/embed.css', $this->plugin_file ), false, '1.0', 'all' );
121
  wp_register_script( 'magnific-popup', plugins_url( 'js/magnific-popup.js', $this->plugin_file ), array( 'jquery' ), '0.9.9', true );
122
- wp_register_script( 'embed', plugins_url( 'js/embed.js', $this->plugin_file ), array( 'jquery' ), '0.9.9', true );
123
  wp_localize_script('embed','emebeder', array(
124
  'default_height' => get_option('ead_height', '500px' ),
125
  'default_width' => get_option('ead_width', '100%' ),
126
  'download' => get_option('ead_download', 'none' ),
127
- 'provider' => get_option('ead_provider', 'none' ),
128
  'ajaxurl' => admin_url( 'admin-ajax.php' ),
129
  'validtypes' => ead_validembedtypes(),
130
  'nocontent' => __('Nothing to insert', $this->text_domain),
@@ -164,16 +165,14 @@ class Awsm_embed {
164
  function register_eadsettings() {
165
  register_setting( 'ead-settings-group', 'ead_width' ,'ead_sanitize_dims');
166
  register_setting( 'ead-settings-group', 'ead_height','ead_sanitize_dims' );
 
167
  register_setting( 'ead-settings-group', 'ead_download' );
168
- register_setting( 'ead-settings-group', 'ead_provider' );
169
  }
170
  /**
171
  * Ajax validate file url
172
  */
173
  function validateurl(){
174
- if (!current_user_can('manage_options')) {
175
- wp_die(__('You do not have sufficient permissions to access this page.'));
176
- }
177
  $fileurl = $_POST['furl'];
178
  echo json_encode(ead_validateurl($fileurl));
179
  die(0);
@@ -206,11 +205,11 @@ class Awsm_embed {
206
  * Adds shortcode for supported media
207
  */
208
  function ead_media_insert( $html, $id, $attachment ) {
209
- if ( ead_validType( $attachment['url'] )) {
210
- return '[embeddoc url="' . $attachment['url'] . '"]';
211
- } else {
212
- return $html;
213
- }
214
  }
215
  /**
216
  * Adds additional mimetype for meadi uploader
@@ -221,6 +220,24 @@ class Awsm_embed {
221
  'ai' => 'application/postscript',
222
  ));
223
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
224
  }
225
 
226
  Awsm_embed::get_instance();
3
  Plugin Name: Embed Any Document
4
  Plugin URI: http://awsm.in/embed-any-documents
5
  Description: Embed Any Document WordPress plugin lets you upload and embed your documents easily in your WordPress website without any additional browser plugins like Flash or Acrobat reader. The plugin lets you choose between Google Docs Viewer and Microsoft Office Online to display your documents.
6
+ Version: 1.1
7
  Author: Awsm Innovations
8
  Author URI: http://awsm.in
9
  License: GPL V3
15
  private $plugin_url;
16
  private $plugin_base;
17
  private $plugin_file;
18
+ private $plugin_version;
19
  private $settings_slug;
20
  private $text_domain = 'ead';
21
  /**
39
  $this->plugin_base = dirname( plugin_basename( __FILE__ ) );
40
  $this->plugin_file = __FILE__ ;
41
  $this->settings_slug = 'ead-settings';
42
+ $this->plugin_version = '1.0.2';
43
 
44
  load_plugin_textdomain($this->text_domain, false,$this->plugin_base . '/language' );
45
 
56
  add_action( 'wp_ajax_validateurl',array( $this, 'validateurl' ));
57
  //ajax Contact Form
58
  add_action( 'wp_ajax_supportform',array( $this, 'supportform' ));
59
+ //default options
60
+ register_activation_hook($this->plugin_file, array( $this, 'ead_defaults' ));
61
  $this->run_plugin();
62
  }
63
  /**
64
  * Register admin Settings style
65
  */
66
  function setting_styles(){
67
+ wp_register_style( 'embed-settings', plugins_url( 'css/settings.css', $this->plugin_file ), false,$this->plugin_version, 'all' );
68
  wp_enqueue_style('embed-settings');
69
  }
70
  /**
111
  * Embed Form popup
112
  */
113
  function embedpopup(){
 
 
 
114
  include($this->plugin_path.'inc/popup.php');
115
  }
116
  /**
118
  */
119
  function embed_helper(){
120
  wp_register_style( 'magnific-popup', plugins_url( 'css/magnific-popup.css', $this->plugin_file ), false, '0.9.9', 'all' );
121
+ wp_register_style( 'embed-css', plugins_url( 'css/embed.css', $this->plugin_file ), false, $this->plugin_version, 'all' );
122
  wp_register_script( 'magnific-popup', plugins_url( 'js/magnific-popup.js', $this->plugin_file ), array( 'jquery' ), '0.9.9', true );
123
+ wp_register_script( 'embed', plugins_url( 'js/embed.js', $this->plugin_file ), array( 'jquery' ),$this->plugin_version, true );
124
  wp_localize_script('embed','emebeder', array(
125
  'default_height' => get_option('ead_height', '500px' ),
126
  'default_width' => get_option('ead_width', '100%' ),
127
  'download' => get_option('ead_download', 'none' ),
128
+ 'provider' => get_option('ead_provider', 'google' ),
129
  'ajaxurl' => admin_url( 'admin-ajax.php' ),
130
  'validtypes' => ead_validembedtypes(),
131
  'nocontent' => __('Nothing to insert', $this->text_domain),
165
  function register_eadsettings() {
166
  register_setting( 'ead-settings-group', 'ead_width' ,'ead_sanitize_dims');
167
  register_setting( 'ead-settings-group', 'ead_height','ead_sanitize_dims' );
168
+ register_setting( 'ead-settings-group', 'ead_provider','ead_sanitize_provider' );
169
  register_setting( 'ead-settings-group', 'ead_download' );
170
+ register_setting( 'ead-settings-group', 'ead_mediainsert' );
171
  }
172
  /**
173
  * Ajax validate file url
174
  */
175
  function validateurl(){
 
 
 
176
  $fileurl = $_POST['furl'];
177
  echo json_encode(ead_validateurl($fileurl));
178
  die(0);
205
  * Adds shortcode for supported media
206
  */
207
  function ead_media_insert( $html, $id, $attachment ) {
208
+ if(get_option( 'ead_mediainsert', 1 ))
209
+ if ( ead_validType( $attachment['url'] )) {
210
+ return '[embeddoc url="' . $attachment['url'] . '"]';
211
+ }
212
+ return $html;
213
  }
214
  /**
215
  * Adds additional mimetype for meadi uploader
220
  'ai' => 'application/postscript',
221
  ));
222
  }
223
+ /**
224
+ * To initialize default options
225
+ */
226
+ function ead_defaults()
227
+ {
228
+ $o = array(
229
+ 'ead_width' => '100%',
230
+ 'ead_height' => '500px',
231
+ 'ead_download' => 'none',
232
+ 'ead_provider' => 'google',
233
+ 'ead_mediainsert' => '1',
234
+ );
235
+ foreach ( $o as $k => $v )
236
+ {
237
+ if(!get_option($k)) update_option($k, $v);
238
+ }
239
+ return;
240
+ }
241
  }
242
 
243
  Awsm_embed::get_instance();
css/embed.css CHANGED
@@ -167,7 +167,8 @@ div.awsm-error p, div.awsm-updated p {
167
  .f-left{
168
  float:left;
169
  }
170
- .f-left.middle{ margin:0 25px; }
 
171
  .clear{ clear:both;}
172
  .input-small{ width:60px;}
173
  .box .urlerror{
167
  .f-left{
168
  float:left;
169
  }
170
+ .option-fields .f-left{ margin-right: 25px; }
171
+ .f-left.last{ margin:0; }
172
  .clear{ clear:both;}
173
  .input-small{ width:60px;}
174
  .box .urlerror{
inc/functions.php CHANGED
@@ -64,7 +64,20 @@ function ead_sanitize_dims( $dim ) {
64
  return false;
65
  }
66
  }
67
-
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  /**
69
  * Validate File url
70
  *
@@ -77,29 +90,29 @@ function ead_validateurl($url){
77
  $remote = wp_remote_head($url);
78
  $json['status'] = false;
79
  $json['message'] = '';
80
- if ( is_array( $remote ) ) {
81
- if ( isset( $remote['headers']['content-length'] ) ) {
82
- if(in_array($remote['headers']['content-type'], $types)){
83
- $json['message'] = __("Done",'ead');
84
- $filename = pathinfo($url);
85
- if(isset($filename)){
86
- $json['file']['filename'] = $filename['basename'];
87
- }else{
88
- $json['file']['filename'] = __("Document",'ead');
89
- }
90
- $json['file']['filesizeHumanReadable'] = ead_human_filesize($remote['headers']['content-length']);
91
- $json['status'] =true;
 
 
92
  }else{
93
- $json['message'] = __("File format is not supported.",'ead');
94
- $json['status'] = false;
95
- }
96
-
97
- } else {
98
- $json['message'] = __('Not a valid URL. Please try again.','ead');
99
- $json['status'] =false;
100
  }
101
- }elseif(is_wp_error( $result )){
102
- $json['message'] = $result->get_error_message();
103
  $json['status'] =false;
104
  }else{
105
  $json['message'] = __('Sorry, the file URL is not valid.','ead');
@@ -120,26 +133,45 @@ function ead_getprovider($atts){
120
  $default_height = ead_sanitize_dims( get_option('ead_height','500px') );
121
  $default_provider = get_option('ead_provider','google');
122
  $default_download = get_option('ead_download','none');
123
-
124
  extract(shortcode_atts( array(
125
  'url' => '',
126
  'width' => $default_width,
127
  'height' => $default_height,
128
  'language' => 'en',
129
- 'provider' => $default_provider,
130
  'download' => $default_download
131
  ), $atts ) );
 
132
  if($url):
133
  $filedata = wp_remote_head( $url );
134
- if(isset($filedata['headers']['content-length'])){
135
- if($provider == 'microsoft'){
136
- $micromime = microsoft_mimes();
137
- if(!in_array($filedata['headers']['content-type'], $micromime)){
138
- $provider = 'google';
139
- }
140
  }
141
- $url = esc_url( $url, array( 'http', 'https' ));
142
- switch ($provider) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  case 'google':
144
  $embedsrc = '//docs.google.com/viewer?url=%1$s&embedded=true&hl=%2$s';
145
  $iframe = sprintf( $embedsrc,
@@ -162,28 +194,27 @@ function ead_getprovider($atts){
162
 
163
  $iframe = '<iframe src="'.$iframe.'" '.$stylelink.'></iframe>';
164
  $show = false;
165
- if($download=='alluser'){
166
- $show = true;
167
- }elseif($download=='logged' AND is_user_logged_in()){
168
- $show = true;
169
- }
170
- if($show){
171
- $filesize ="";
172
- $url = esc_url( $url, array( 'http', 'https' ));
173
- if(isset($filedata['headers']['content-length']))
174
- $filesize = ead_human_filesize($filedata['headers']['content-length']);
175
- $durl = '<p class="embed_download"><a href="'.$url.'" download >'.__('Download','ead'). ' ['.$filesize.']</a></p>';
176
- }
177
-
178
  $embed = $iframe.$durl;
179
- }else{
180
- $embed = __('File Not Found','ead');
181
- }
182
  else:
183
  $embed = __('No Url Found','ead');
184
  endif;
185
  return $embed;
186
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
187
  /**
188
  * Get Email node
189
  *
@@ -221,8 +252,7 @@ function ead_validmimeTypes(){
221
  * @since 1.0
222
  * @return boolean
223
  */
224
- function ead_validType( $url ) {
225
- $doctypes=ead_validmimeTypes();
226
  if ( is_array( $doctypes ) ) {
227
  $allowed_ext = implode( "|", array_keys( $doctypes ) );
228
  if ( preg_match( "/\.($allowed_ext)$/i", $url ) ) {
@@ -249,7 +279,7 @@ function ead_validembedtypes(){
249
  * @since 1.0
250
  * @return array Mimetypes
251
  */
252
- function microsoft_mimes(){
253
  $micro_mime=array(
254
  'doc' => 'application/msword',
255
  'pot|pps|ppt' => 'application/vnd.ms-powerpoint',
64
  return false;
65
  }
66
  }
67
+ /**
68
+ * Sanitize provider
69
+ *
70
+ * @since 1.0.2
71
+ * @return string Sanitized provider
72
+ */
73
+ function ead_sanitize_provider( $provider ) {
74
+ $providerList = array('google','microsoft');
75
+ if (in_array($provider, $providerList) ) {
76
+ return $provider;
77
+ } else {
78
+ return 'google';
79
+ }
80
+ }
81
  /**
82
  * Validate File url
83
  *
90
  $remote = wp_remote_head($url);
91
  $json['status'] = false;
92
  $json['message'] = '';
93
+ if (wp_remote_retrieve_response_code($remote) ==200) {
94
+ //Gzip Support
95
+ $filename = pathinfo($url);
96
+ $doctypes = ead_validmimeTypes();
97
+ if(ead_validType($url,$doctypes)){
98
+ $json['status'] =true;
99
+ $json['message'] = __("Done",'ead');
100
+ if(isset($filename)){
101
+ $json['file']['filename'] = $filename['basename'];
102
+ }else{
103
+ $json['file']['filename'] = __("Document",'ead');
104
+ }
105
+ if(isset($remote['headers']['content-length'])){
106
+ $json['file']['filesizeHumanReadable'] = ead_human_filesize($remote['headers']['content-length']);
107
  }else{
108
+ $json['file']['filesizeHumanReadable'] = 0;
109
+ }
110
+ }else{
111
+ $json['message'] = __("File format is not supported.",'ead');
112
+ $json['status'] = false;
 
 
113
  }
114
+ }elseif(is_wp_error( $remote )){
115
+ $json['message'] = $remote->get_error_message();
116
  $json['status'] =false;
117
  }else{
118
  $json['message'] = __('Sorry, the file URL is not valid.','ead');
133
  $default_height = ead_sanitize_dims( get_option('ead_height','500px') );
134
  $default_provider = get_option('ead_provider','google');
135
  $default_download = get_option('ead_download','none');
136
+ $show = false;
137
  extract(shortcode_atts( array(
138
  'url' => '',
139
  'width' => $default_width,
140
  'height' => $default_height,
141
  'language' => 'en',
142
+ 'viewer' => $default_provider,
143
  'download' => $default_download
144
  ), $atts ) );
145
+
146
  if($url):
147
  $filedata = wp_remote_head( $url );
148
+ $durl = '';
149
+
150
+ if($download=='alluser' or $download=='all'){
151
+ $show = true;
152
+ }elseif($download=='logged' AND is_user_logged_in()){
153
+ $show = true;
154
  }
155
+ if($show){
156
+ $filesize = 0;
157
+ $url = esc_url( $url, array( 'http', 'https' ));
158
+
159
+ if (isset($filedata['headers']['content-length'])) {
160
+ $filesize = ead_human_filesize($filedata['headers']['content-length']);
161
+ }else{
162
+ $filesize = 0;
163
+ }
164
+ $fileHtml = '';
165
+ if($filesize)
166
+ $fileHtml = ' ['.$filesize.']';
167
+ $durl = '<p class="embed_download"><a href="'.$url.'" download >'.__('Download','ead'). $fileHtml .' </a></p>';
168
+ }
169
+
170
+ $url = esc_url( $url, array( 'http', 'https' ));
171
+ $providerList = array('google','microsoft');
172
+ if(!in_array($viewer, $providerList)) $viewer = 'google';
173
+ $viewer = ead_autoviewer($url,$viewer) ;
174
+ switch ($viewer) {
175
  case 'google':
176
  $embedsrc = '//docs.google.com/viewer?url=%1$s&embedded=true&hl=%2$s';
177
  $iframe = sprintf( $embedsrc,
194
 
195
  $iframe = '<iframe src="'.$iframe.'" '.$stylelink.'></iframe>';
196
  $show = false;
 
 
 
 
 
 
 
 
 
 
 
 
 
197
  $embed = $iframe.$durl;
 
 
 
198
  else:
199
  $embed = __('No Url Found','ead');
200
  endif;
201
  return $embed;
202
  }
203
+ /**
204
+ * Select Supported Viewer
205
+ *
206
+ * @since 1.1
207
+ * @return string email html
208
+ */
209
+ function ead_autoviewer($url,$viewer){
210
+ $autoviewer = $viewer;
211
+ if($viewer == 'microsoft'){
212
+ $doctypes = ead_microsoft_mimes();
213
+ if(!ead_validType($url ,$doctypes))
214
+ $autoviewer = 'google';
215
+ }
216
+ return $autoviewer;
217
+ }
218
  /**
219
  * Get Email node
220
  *
252
  * @since 1.0
253
  * @return boolean
254
  */
255
+ function ead_validType( $url ,$doctypes) {
 
256
  if ( is_array( $doctypes ) ) {
257
  $allowed_ext = implode( "|", array_keys( $doctypes ) );
258
  if ( preg_match( "/\.($allowed_ext)$/i", $url ) ) {
279
  * @since 1.0
280
  * @return array Mimetypes
281
  */
282
+ function ead_microsoft_mimes(){
283
  $micro_mime=array(
284
  'doc' => 'application/msword',
285
  'pot|pps|ppt' => 'application/vnd.ms-powerpoint',
inc/mime_types.php CHANGED
@@ -24,5 +24,7 @@
24
  'pages' => 'application/vnd.apple.pages',
25
  //Additional Mime Types
26
  'svg' => 'image/svg+xml',
27
- );
28
- ?>
 
 
24
  'pages' => 'application/vnd.apple.pages',
25
  //Additional Mime Types
26
  'svg' => 'image/svg+xml',
27
+ );
28
+ $extensions['all'] = array('.css','.js','.pdf','.ai','.tif','.tiff','.doc','.txt','.asc','.c','.cc','.h','.pot','.pps','.ppt','.xla','.xls','.xlt','.xlw','.docx','.dotx','.dotm','.xlsx','.xlsm','.pptx','.pages','.svg');
29
+ $extensions['ms'] = array('.doc','.pot','.pps','.ppt','.xla','.xls','.xlt','.xlw','.docx','.dotx','.dotm','.xlsx','.xlsm','.pptx');
30
+ ?>
inc/popup.php CHANGED
@@ -38,12 +38,19 @@
38
 
39
  <li>
40
  <div class="f-left"><label>Width</label> <input type="text" name="width" class="embedval input-small" id="ead_width" value="<?php echo get_option('ead_width', '100%' );?>"></div>
41
- <div class="f-left middle"><label>Height</label> <input type="text" name="height" class="embedval input-small" id="ead_height" value="<?php echo get_option('ead_height', '500px' );?>"></div>
42
  <div class="f-left">
43
  <label><?php _e('Show Download Link','ead');?></label>
44
  <?php
45
- $downoptions= array('alluser' => __('For all users',$this->text_domain),'logged' => __('For Logged-in users',$this->text_domain),'none' => __('None',$this->text_domain));
46
- ead_selectbuilder('ead_download', $downoptions,esc_attr( get_option('ead_download')),'embed_download');
 
 
 
 
 
 
 
47
  ?>
48
  </div>
49
  <div class="clear"></div>
38
 
39
  <li>
40
  <div class="f-left"><label>Width</label> <input type="text" name="width" class="embedval input-small" id="ead_width" value="<?php echo get_option('ead_width', '100%' );?>"></div>
41
+ <div class="f-left"><label>Height</label> <input type="text" name="height" class="embedval input-small" id="ead_height" value="<?php echo get_option('ead_height', '500px' );?>"></div>
42
  <div class="f-left">
43
  <label><?php _e('Show Download Link','ead');?></label>
44
  <?php
45
+ $downoptions= array('alluser' => __('For all users',$this->text_domain),'logged' => __('For Logged-in users',$this->text_domain),'none' => __('No Download',$this->text_domain));
46
+ ead_selectbuilder('ead_download', $downoptions,esc_attr( get_option('ead_download')),'embed_download ead_usc');
47
+ ?>
48
+ </div>
49
+ <div class="f-left last">
50
+ <label><?php _e('Provider','ead');?></label>
51
+ <?php
52
+ $providers = array('google' => __('Google Docs Viewer',$this->text_domain),'microsoft' => __('Microsoft Office Online',$this->text_domain));
53
+ ead_selectbuilder('ead_provider', $providers,esc_attr( get_option('ead_provider','google')),'ead_provider ead_usc');
54
  ?>
55
  </div>
56
  <div class="clear"></div>
inc/settings.php CHANGED
@@ -65,11 +65,20 @@
65
  <th scope="row"><?php _e('Show Download Link',$this->text_domain);?></th>
66
  <td>
67
  <?php
68
- $downoptions= array('alluser' => __('For all users',$this->text_domain),'logged' => __('For Logged-in users',$this->text_domain),'none' => __('None',$this->text_domain));
69
  ead_selectbuilder('ead_download', $downoptions,esc_attr( get_option('ead_download','none')));
70
  ?>
71
  </td>
72
  </tr>
 
 
 
 
 
 
 
 
 
73
  </table>
74
  <?php submit_button(); ?>
75
  </form>
65
  <th scope="row"><?php _e('Show Download Link',$this->text_domain);?></th>
66
  <td>
67
  <?php
68
+ $downoptions= array('alluser' => __('For all users',$this->text_domain),'logged' => __('For Logged-in users',$this->text_domain),'none' => __('No Download',$this->text_domain));
69
  ead_selectbuilder('ead_download', $downoptions,esc_attr( get_option('ead_download','none')));
70
  ?>
71
  </td>
72
  </tr>
73
+ <tr valign="top">
74
+ <th scope="row"><?php _e('Override Default Media Insert?',$this->text_domain);?></th>
75
+ <td>
76
+ <?php
77
+ $downoptions= array('1' => __('Auto-embed supported documents',$this->text_domain),'0' => __('Insert as link (WordPress Default)',$this->text_domain));
78
+ ead_selectbuilder('ead_mediainsert', $downoptions,esc_attr( get_option('ead_mediainsert','1')));
79
+ ?>
80
+ </td>
81
+ </tr>
82
  </table>
83
  <?php submit_button(); ?>
84
  </form>
js/embed.js CHANGED
@@ -37,13 +37,12 @@ jQuery(document).ready(function ($) {
37
  }).magnificPopup('open');
38
  });
39
  //Update shortcode on change
40
- $( ".embed_download" ).change(function() {
41
  updateshortcode();
42
  });
43
- $('.embedval').blur(function(){
44
  updateshortcode();
45
  });
46
-
47
  //Tabs Support
48
  $('ul.tabs').delegate('li:not(.current)', 'click', function () {
49
  $(this).addClass('current').siblings().removeClass('current')
@@ -82,18 +81,23 @@ jQuery(document).ready(function ($) {
82
  }
83
  //to getshortcode
84
  function getshortcode(url){
85
- var height=$('#ead_height').val(),width=$('#ead_width').val(),download=$('#ead_download').val(),heightstr="",widthstr="",downloadstr="";
86
- if(height!=emebeder.default_height) { heightstr = ' height="'+height+'"'; }
87
- if(width!=emebeder.default_width) { widthstr = ' width="'+width+'"'; }
88
- if(download!=emebeder.download) { downloadstr = ' download="'+download+'"'; }
89
- return '[embeddoc url="' + url + '"' + widthstr + heightstr + downloadstr +']';
 
90
 
91
  }
92
  //Print uploaded file details
93
  function uploaddetails(file){
94
  $('#insert_doc').removeAttr('disabled');
95
- $('#ead_filename').html(file.filename)
96
- $('#ead_filesize').html(file.filesizeHumanReadable);
 
 
 
 
97
  $('.upload-success').fadeIn();
98
  $container.hide();
99
  }
37
  }).magnificPopup('open');
38
  });
39
  //Update shortcode on change
40
+ $( ".ead_usc" ).change(function() {
41
  updateshortcode();
42
  });
43
+ $('.embedval').keyup(function(){
44
  updateshortcode();
45
  });
 
46
  //Tabs Support
47
  $('ul.tabs').delegate('li:not(.current)', 'click', function () {
48
  $(this).addClass('current').siblings().removeClass('current')
81
  }
82
  //to getshortcode
83
  function getshortcode(url){
84
+ var height=$('#ead_height').val(),width=$('#ead_width').val(),download=$('#ead_download').val(),provider=$('#ead_provider').val(),heightstr="",widthstr="",downloadstr="",providerstr="";
85
+ if(height!=emebeder.default_height) { heightstr = ' height="'+height+'"'; }
86
+ if(width!=emebeder.default_width) { widthstr = ' width="'+width+'"'; }
87
+ if(download!=emebeder.download) { downloadstr = ' download="'+download+'"'; }
88
+ if(provider!=emebeder.provider) { providerstr = ' provider="'+provider+'"'; }
89
+ return '[embeddoc url="' + url + '"' + widthstr + heightstr + downloadstr + providerstr +']';
90
 
91
  }
92
  //Print uploaded file details
93
  function uploaddetails(file){
94
  $('#insert_doc').removeAttr('disabled');
95
+ $('#ead_filename').html(file.filename);
96
+ if(file.filesizeHumanReadable){
97
+ $('#ead_filesize').html(file.filesizeHumanReadable);
98
+ }else{
99
+ $('#ead_filesize').html('&nbsp;');
100
+ }
101
  $('.upload-success').fadeIn();
102
  $container.hide();
103
  }
language/ead.pot CHANGED
@@ -1,18 +1,22 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Embed Any Document\n"
4
- "POT-Creation-Date: 2014-11-07 14:45+0530\n"
5
- "PO-Revision-Date: 2014-11-07 14:45+0530\n"
6
  "Last-Translator: \n"
7
  "Language-Team: Awsm Innovations <hello@awsm.in>\n"
8
- "Language: en\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
  "X-Generator: Poedit 1.6.10\n"
 
 
 
 
 
13
 
14
- #: aswm-embed.php:77
15
- #: inc/popup.php:6
16
  msgid "Add Document"
17
  msgstr ""
18
 
@@ -20,50 +24,51 @@ msgstr ""
20
  msgid "Settings"
21
  msgstr ""
22
 
23
- #: aswm-embed.php:111
24
- #: aswm-embed.php:156
25
- #: aswm-embed.php:174
26
- #: aswm-embed.php:185
27
- msgid "You do not have sufficient permissions to access this page."
28
- msgstr ""
29
-
30
- #: aswm-embed.php:129
31
  msgid "Nothing to insert"
32
  msgstr ""
33
 
34
- #: aswm-embed.php:130
35
  msgid "Add URL"
36
  msgstr ""
37
 
38
- #: aswm-embed.php:131
39
  msgid "Verifying..."
40
  msgstr ""
41
 
42
- #: inc/functions.php:87
43
- msgid "Download"
44
  msgstr ""
45
 
46
- #: inc/functions.php:105
47
  msgid "Done"
48
  msgstr ""
49
 
50
- #: inc/functions.php:110
51
  msgid "Document"
52
  msgstr ""
53
 
54
- #: inc/functions.php:115
55
  msgid "File format is not supported."
56
  msgstr ""
57
 
58
- #: inc/functions.php:120
59
  msgid "Not a valid URL. Please try again."
60
  msgstr ""
61
 
62
- #: inc/functions.php:127
63
  msgid "Sorry, the file URL is not valid."
64
  msgstr ""
65
 
66
- #: inc/functions.php:175
 
 
 
 
 
 
 
 
67
  msgid "No Url Found"
68
  msgstr ""
69
 
@@ -83,35 +88,43 @@ msgstr ""
83
  msgid "Advanced Options"
84
  msgstr ""
85
 
86
- #: inc/popup.php:43
87
- #: inc/settings.php:38
88
  msgid "Show Download Link"
89
  msgstr ""
90
 
91
- #: inc/popup.php:45
92
- #: inc/settings.php:41
93
  msgid "For all users"
94
  msgstr ""
95
 
96
- #: inc/popup.php:45
97
- #: inc/settings.php:41
98
  msgid "For Logged-in users"
99
  msgstr ""
100
 
101
- #: inc/popup.php:45
102
- #: inc/settings.php:41
103
  msgid "None"
104
  msgstr ""
105
 
106
- #: inc/popup.php:53
 
 
 
 
 
 
 
 
 
 
 
 
107
  msgid "Shortcode Preview"
108
  msgstr ""
109
 
110
- #: inc/popup.php:62
111
  msgid "Insert"
112
  msgstr ""
113
 
114
- #: inc/popup.php:66
115
  msgid "Cancel"
116
  msgstr ""
117
 
@@ -131,43 +144,51 @@ msgstr ""
131
  msgid "Embed Using"
132
  msgstr ""
133
 
134
- #: inc/settings.php:18
135
- msgid "Google Docs Viewer"
136
- msgstr ""
137
-
138
- #: inc/settings.php:18
139
- msgid "Microsoft Office Online"
140
  msgstr ""
141
 
142
- #: inc/settings.php:24
143
  msgid "Default Size"
144
  msgstr ""
145
 
146
- #: inc/settings.php:26
147
  msgid "Width"
148
  msgstr ""
149
 
150
- #: inc/settings.php:30
151
  msgid "Height"
152
  msgstr ""
153
 
154
- #: inc/settings.php:34
155
- msgid "Enter values in pixels or percentage (Example: 300px or 100%)"
 
 
 
 
 
 
 
 
156
  msgstr ""
157
 
158
- #: inc/settings.php:55
 
 
 
 
159
  msgid "Name"
160
  msgstr ""
161
 
162
- #: inc/settings.php:62
163
  msgid "Email ID"
164
  msgstr ""
165
 
166
- #: inc/settings.php:69
167
  msgid "Problem"
168
  msgstr ""
169
 
170
- #: inc/settings.php:77
171
  msgid "Submit"
172
  msgstr ""
173
 
@@ -186,9 +207,3 @@ msgstr ""
186
  #: inc/support-mail.php:38
187
  msgid "Cheating ?"
188
  msgstr ""
189
-
190
- #: inc/functions.php:180
191
- msgid "File Not Found"
192
- msgstr ""
193
-
194
-
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Embed Any Document\n"
4
+ "POT-Creation-Date: 2014-11-24 13:11+0530\n"
5
+ "PO-Revision-Date: 2014-11-24 13:12+0530\n"
6
  "Last-Translator: \n"
7
  "Language-Team: Awsm Innovations <hello@awsm.in>\n"
8
+ "Language: en_US\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
  "X-Generator: Poedit 1.6.10\n"
13
+ "X-Poedit-Basepath: ../\n"
14
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
+ "X-Poedit-KeywordsList: __;_e;esc_attr_e\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
 
19
+ #: aswm-embed.php:77 inc/popup.php:6
 
20
  msgid "Add Document"
21
  msgstr ""
22
 
24
  msgid "Settings"
25
  msgstr ""
26
 
27
+ #: aswm-embed.php:127
 
 
 
 
 
 
 
28
  msgid "Nothing to insert"
29
  msgstr ""
30
 
31
+ #: aswm-embed.php:128
32
  msgid "Add URL"
33
  msgstr ""
34
 
35
+ #: aswm-embed.php:129
36
  msgid "Verifying..."
37
  msgstr ""
38
 
39
+ #: aswm-embed.php:154 aswm-embed.php:181
40
+ msgid "You do not have sufficient permissions to access this page."
41
  msgstr ""
42
 
43
+ #: inc/functions.php:96
44
  msgid "Done"
45
  msgstr ""
46
 
47
+ #: inc/functions.php:101
48
  msgid "Document"
49
  msgstr ""
50
 
51
+ #: inc/functions.php:106
52
  msgid "File format is not supported."
53
  msgstr ""
54
 
55
+ #: inc/functions.php:111
56
  msgid "Not a valid URL. Please try again."
57
  msgstr ""
58
 
59
+ #: inc/functions.php:118
60
  msgid "Sorry, the file URL is not valid."
61
  msgstr ""
62
 
63
+ #: inc/functions.php:190
64
+ msgid "Download"
65
+ msgstr ""
66
+
67
+ #: inc/functions.php:195
68
+ msgid "File Not Found"
69
+ msgstr ""
70
+
71
+ #: inc/functions.php:198
72
  msgid "No Url Found"
73
  msgstr ""
74
 
88
  msgid "Advanced Options"
89
  msgstr ""
90
 
91
+ #: inc/popup.php:43 inc/settings.php:65
 
92
  msgid "Show Download Link"
93
  msgstr ""
94
 
95
+ #: inc/popup.php:45 inc/settings.php:68
 
96
  msgid "For all users"
97
  msgstr ""
98
 
99
+ #: inc/popup.php:45 inc/settings.php:68
 
100
  msgid "For Logged-in users"
101
  msgstr ""
102
 
103
+ #: inc/popup.php:45 inc/settings.php:68
 
104
  msgid "None"
105
  msgstr ""
106
 
107
+ #: inc/popup.php:50
108
+ msgid "Provider"
109
+ msgstr ""
110
+
111
+ #: inc/popup.php:52 inc/settings.php:18
112
+ msgid "Google Docs Viewer"
113
+ msgstr ""
114
+
115
+ #: inc/popup.php:52 inc/settings.php:18
116
+ msgid "Microsoft Office Online"
117
+ msgstr ""
118
+
119
+ #: inc/popup.php:60
120
  msgid "Shortcode Preview"
121
  msgstr ""
122
 
123
+ #: inc/popup.php:69
124
  msgid "Insert"
125
  msgstr ""
126
 
127
+ #: inc/popup.php:73
128
  msgid "Cancel"
129
  msgstr ""
130
 
144
  msgid "Embed Using"
145
  msgstr ""
146
 
147
+ #: inc/settings.php:22
148
+ msgid "Supported file formats"
 
 
 
 
149
  msgstr ""
150
 
151
+ #: inc/settings.php:51
152
  msgid "Default Size"
153
  msgstr ""
154
 
155
+ #: inc/settings.php:53
156
  msgid "Width"
157
  msgstr ""
158
 
159
+ #: inc/settings.php:57
160
  msgid "Height"
161
  msgstr ""
162
 
163
+ #: inc/settings.php:61
164
+ msgid "Enter values in pixels or percentage (Example: 500px or 100%)"
165
+ msgstr ""
166
+
167
+ #: inc/settings.php:74
168
+ msgid "Override Default Media Insert?"
169
+ msgstr ""
170
+
171
+ #: inc/settings.php:77
172
+ msgid "Auto-embed supported documents"
173
  msgstr ""
174
 
175
+ #: inc/settings.php:77
176
+ msgid "Insert as link (WordPress Default)"
177
+ msgstr ""
178
+
179
+ #: inc/settings.php:92
180
  msgid "Name"
181
  msgstr ""
182
 
183
+ #: inc/settings.php:96
184
  msgid "Email ID"
185
  msgstr ""
186
 
187
+ #: inc/settings.php:100
188
  msgid "Problem"
189
  msgstr ""
190
 
191
+ #: inc/settings.php:104
192
  msgid "Submit"
193
  msgstr ""
194
 
207
  #: inc/support-mail.php:38
208
  msgid "Cheating ?"
209
  msgstr ""
 
 
 
 
 
 
language/en_US.mo ADDED
Binary file
language/en_US.po ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Embed Any Document\n"
4
+ "POT-Creation-Date: 2014-11-24 13:11+0530\n"
5
+ "PO-Revision-Date: 2014-11-24 13:13+0530\n"
6
+ "Last-Translator: \n"
7
+ "Language-Team: Awsm Innovations <hello@awsm.in>\n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=UTF-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "X-Generator: Poedit 1.6.10\n"
12
+ "X-Poedit-Basepath: ../\n"
13
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
14
+ "X-Poedit-SourceCharset: UTF-8\n"
15
+ "X-Poedit-KeywordsList: __;_e;esc_attr_e\n"
16
+ "Language: en_US\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: aswm-embed.php:77 inc/popup.php:6
20
+ msgid "Add Document"
21
+ msgstr ""
22
+
23
+ #: aswm-embed.php:102
24
+ msgid "Settings"
25
+ msgstr ""
26
+
27
+ #: aswm-embed.php:127
28
+ msgid "Nothing to insert"
29
+ msgstr ""
30
+
31
+ #: aswm-embed.php:128
32
+ msgid "Add URL"
33
+ msgstr ""
34
+
35
+ #: aswm-embed.php:129
36
+ msgid "Verifying..."
37
+ msgstr ""
38
+
39
+ #: aswm-embed.php:154 aswm-embed.php:181
40
+ msgid "You do not have sufficient permissions to access this page."
41
+ msgstr ""
42
+
43
+ #: inc/functions.php:96
44
+ msgid "Done"
45
+ msgstr ""
46
+
47
+ #: inc/functions.php:101
48
+ msgid "Document"
49
+ msgstr ""
50
+
51
+ #: inc/functions.php:106
52
+ msgid "File format is not supported."
53
+ msgstr ""
54
+
55
+ #: inc/functions.php:111
56
+ msgid "Not a valid URL. Please try again."
57
+ msgstr ""
58
+
59
+ #: inc/functions.php:118
60
+ msgid "Sorry, the file URL is not valid."
61
+ msgstr ""
62
+
63
+ #: inc/functions.php:190
64
+ msgid "Download"
65
+ msgstr ""
66
+
67
+ #: inc/functions.php:195
68
+ msgid "File Not Found"
69
+ msgstr ""
70
+
71
+ #: inc/functions.php:198
72
+ msgid "No Url Found"
73
+ msgstr ""
74
+
75
+ #: inc/popup.php:12
76
+ msgid "Upload and Embed"
77
+ msgstr ""
78
+
79
+ #: inc/popup.php:13
80
+ msgid "Add From URL"
81
+ msgstr ""
82
+
83
+ #: inc/popup.php:21
84
+ msgid "Enter document URL"
85
+ msgstr ""
86
+
87
+ #: inc/popup.php:33
88
+ msgid "Advanced Options"
89
+ msgstr ""
90
+
91
+ #: inc/popup.php:43 inc/settings.php:65
92
+ msgid "Show Download Link"
93
+ msgstr ""
94
+
95
+ #: inc/popup.php:45 inc/settings.php:68
96
+ msgid "For all users"
97
+ msgstr ""
98
+
99
+ #: inc/popup.php:45 inc/settings.php:68
100
+ msgid "For Logged-in users"
101
+ msgstr ""
102
+
103
+ #: inc/popup.php:45 inc/settings.php:68
104
+ msgid "None"
105
+ msgstr ""
106
+
107
+ #: inc/popup.php:50
108
+ msgid "Provider"
109
+ msgstr ""
110
+
111
+ #: inc/popup.php:52 inc/settings.php:18
112
+ msgid "Google Docs Viewer"
113
+ msgstr ""
114
+
115
+ #: inc/popup.php:52 inc/settings.php:18
116
+ msgid "Microsoft Office Online"
117
+ msgstr ""
118
+
119
+ #: inc/popup.php:60
120
+ msgid "Shortcode Preview"
121
+ msgstr ""
122
+
123
+ #: inc/popup.php:69
124
+ msgid "Insert"
125
+ msgstr ""
126
+
127
+ #: inc/popup.php:73
128
+ msgid "Cancel"
129
+ msgstr ""
130
+
131
+ #: inc/settings.php:3
132
+ msgid "Embed Any Document by AWSM.in"
133
+ msgstr ""
134
+
135
+ #: inc/settings.php:5
136
+ msgid "General Settings"
137
+ msgstr ""
138
+
139
+ #: inc/settings.php:6
140
+ msgid "Support"
141
+ msgstr ""
142
+
143
+ #: inc/settings.php:15
144
+ msgid "Embed Using"
145
+ msgstr ""
146
+
147
+ #: inc/settings.php:22
148
+ msgid "Supported file formats"
149
+ msgstr ""
150
+
151
+ #: inc/settings.php:51
152
+ msgid "Default Size"
153
+ msgstr ""
154
+
155
+ #: inc/settings.php:53
156
+ msgid "Width"
157
+ msgstr ""
158
+
159
+ #: inc/settings.php:57
160
+ msgid "Height"
161
+ msgstr ""
162
+
163
+ #: inc/settings.php:61
164
+ msgid "Enter values in pixels or percentage (Example: 500px or 100%)"
165
+ msgstr ""
166
+
167
+ #: inc/settings.php:74
168
+ msgid "Override Default Media Insert?"
169
+ msgstr ""
170
+
171
+ #: inc/settings.php:77
172
+ msgid "Auto-embed supported documents"
173
+ msgstr ""
174
+
175
+ #: inc/settings.php:77
176
+ msgid "Insert as link (WordPress Default)"
177
+ msgstr ""
178
+
179
+ #: inc/settings.php:92
180
+ msgid "Name"
181
+ msgstr ""
182
+
183
+ #: inc/settings.php:96
184
+ msgid "Email ID"
185
+ msgstr ""
186
+
187
+ #: inc/settings.php:100
188
+ msgid "Problem"
189
+ msgstr ""
190
+
191
+ #: inc/settings.php:104
192
+ msgid "Submit"
193
+ msgstr ""
194
+
195
+ #: inc/support-mail.php:8
196
+ msgid "Please Fill Required Fields"
197
+ msgstr ""
198
+
199
+ #: inc/support-mail.php:30
200
+ msgid "We will get back to you soon"
201
+ msgstr ""
202
+
203
+ #: inc/support-mail.php:33
204
+ msgid "Something went wrong"
205
+ msgstr ""
206
+
207
+ #: inc/support-mail.php:38
208
+ msgid "Cheating ?"
209
+ msgstr ""
readme.txt CHANGED
@@ -81,10 +81,20 @@ Great. Send it to ead@awsm.in. We will answer it as soon as we can.
81
 
82
  == Changelog ==
83
 
 
 
 
 
 
 
84
  = V1.0.1 - 2014-11-12 =
85
  * Removed unsupported file types.
86
  * Updated support tab.
87
 
 
 
 
 
88
  == Upgrade Notice ==
89
 
90
  = V1.0.1 =
81
 
82
  == Changelog ==
83
 
84
+ = V1.0.2 - 2014-11-24 =
85
+ * Added option in advanced option to choose viewer.
86
+ * Added option in settings to enable and disable media library insert.
87
+ * Fixed: Editor permission issue.
88
+
89
+
90
  = V1.0.1 - 2014-11-12 =
91
  * Removed unsupported file types.
92
  * Updated support tab.
93
 
94
+ = V1.1 - 2014-11-12 =
95
+ * File Not Found fix
96
+
97
+
98
  == Upgrade Notice ==
99
 
100
  = V1.0.1 =