Version Description
Settings -> PDF Embedder page so you can now set site-wide defaults for width, height, and toolbar location/appearance.
Download this release
Release Info
Developer | danlester |
Plugin | PDF Embedder |
Version | 2.1 |
Comparing to | |
See all releases |
Code changes from version 2.0 to 2.1
- core/core_pdf_embedder.php +216 -40
- css/pdfemb-admin.css +98 -0
- js/admin/pdfemb-admin.js +37 -0
- pdf_embedder.php +34 -37
- readme.txt +12 -25
core/core_pdf_embedder.php
CHANGED
@@ -77,21 +77,35 @@ class core_pdf_embedder {
|
|
77 |
$url = $atts['url'];
|
78 |
|
79 |
$this->insert_scripts();
|
|
|
|
|
|
|
|
|
80 |
|
81 |
-
$width = isset($atts['width']) ? $atts['width'] : '
|
82 |
$height = isset($atts['height']) ? $atts['height'] : 'auto';
|
83 |
|
84 |
$extra_style = "";
|
85 |
if (is_numeric($width)) {
|
86 |
$extra_style .= "width: ".$width."px; ";
|
87 |
}
|
|
|
|
|
|
|
|
|
88 |
if (is_numeric($height)) {
|
89 |
$extra_style .= "height: ".$height."px; ";
|
90 |
}
|
91 |
|
92 |
-
$toolbar = isset($atts['toolbar']) && in_array($atts['toolbar'], array('top', 'bottom', 'both')) ? $atts['toolbar'] : '
|
|
|
|
|
|
|
93 |
|
94 |
-
$toolbar_fixed = isset($atts['toolbarfixed'])
|
|
|
|
|
|
|
95 |
|
96 |
$returnhtml = '<div class="pdfemb-viewer" data-pdf-url="'.esc_attr($this->modify_pdfurl($url)).'" style="'.esc_attr($extra_style).'" '
|
97 |
.'data-width="'.esc_attr($width).'" data-height="'.esc_attr($height).'" ';
|
@@ -141,8 +155,11 @@ class core_pdf_embedder {
|
|
141 |
}
|
142 |
|
143 |
public function pdfemb_options_do_page() {
|
144 |
-
|
145 |
-
|
|
|
|
|
|
|
146 |
|
147 |
if (is_multisite()) {
|
148 |
$this->pdfemb_options_do_network_errors();
|
@@ -151,61 +168,188 @@ class core_pdf_embedder {
|
|
151 |
|
152 |
<div>
|
153 |
|
154 |
-
|
155 |
-
|
156 |
-
<div id="pdfemb-tablewrapper">
|
157 |
-
|
158 |
-
<?php $this->pdfemb_mainsection_text(); ?>
|
159 |
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
|
165 |
-
$this->pdfemb_options_submit();
|
166 |
?>
|
|
|
|
|
|
|
|
|
167 |
|
168 |
-
|
169 |
-
|
|
|
|
|
170 |
|
171 |
</div> <?php
|
172 |
}
|
173 |
-
|
174 |
-
|
|
|
|
|
|
|
|
|
175 |
protected function pdfemb_mainsection_text() {
|
|
|
176 |
?>
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
}
|
191 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
public function pdfemb_options_validate($input) {
|
193 |
$newinput = Array();
|
194 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
return $newinput;
|
196 |
}
|
197 |
|
198 |
protected function get_error_string($fielderror) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
return 'Unspecified error';
|
200 |
}
|
201 |
-
|
202 |
public function pdfemb_save_network_options() {
|
203 |
check_admin_referer( $this->get_options_pagename().'-options' );
|
204 |
|
205 |
if (isset($_POST[$this->get_options_name()]) && is_array($_POST[$this->get_options_name()])) {
|
206 |
$inoptions = $_POST[$this->get_options_name()];
|
207 |
|
208 |
-
$outoptions = $this->
|
209 |
|
210 |
$error_code = Array();
|
211 |
$error_setting = Array();
|
@@ -262,13 +406,23 @@ class core_pdf_embedder {
|
|
262 |
}
|
263 |
|
264 |
// OPTIONS
|
265 |
-
|
|
|
|
|
|
|
|
|
266 |
protected function get_default_options() {
|
267 |
-
return Array(
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
}
|
269 |
|
270 |
protected $pdfemb_options = null;
|
271 |
-
protected function
|
272 |
if ($this->pdfemb_options != null) {
|
273 |
return $this->pdfemb_options;
|
274 |
}
|
@@ -285,7 +439,12 @@ class core_pdf_embedder {
|
|
285 |
$this->pdfemb_options = $option;
|
286 |
return $this->pdfemb_options;
|
287 |
}
|
288 |
-
|
|
|
|
|
|
|
|
|
|
|
289 |
// ADMIN
|
290 |
|
291 |
public function pdfemb_admin_init() {
|
@@ -304,6 +463,21 @@ class core_pdf_embedder {
|
|
304 |
// Override in Premium
|
305 |
public function pdfemb_init() {
|
306 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
307 |
|
308 |
protected function add_actions() {
|
309 |
|
@@ -323,6 +497,8 @@ class core_pdf_embedder {
|
|
323 |
if (is_multisite()) {
|
324 |
add_action('network_admin_edit_'.$this->get_options_menuname(), array($this, 'pdfemb_save_network_options'));
|
325 |
}
|
|
|
|
|
326 |
}
|
327 |
}
|
328 |
|
77 |
$url = $atts['url'];
|
78 |
|
79 |
$this->insert_scripts();
|
80 |
+
|
81 |
+
// Get defaults
|
82 |
+
|
83 |
+
$options = $this->get_option_pdfemb();
|
84 |
|
85 |
+
$width = isset($atts['width']) ? $atts['width'] : $options['pdfemb_width'];
|
86 |
$height = isset($atts['height']) ? $atts['height'] : 'auto';
|
87 |
|
88 |
$extra_style = "";
|
89 |
if (is_numeric($width)) {
|
90 |
$extra_style .= "width: ".$width."px; ";
|
91 |
}
|
92 |
+
elseif ($width!='max' && $width!='auto') {
|
93 |
+
$width = 'max';
|
94 |
+
}
|
95 |
+
|
96 |
if (is_numeric($height)) {
|
97 |
$extra_style .= "height: ".$height."px; ";
|
98 |
}
|
99 |
|
100 |
+
$toolbar = isset($atts['toolbar']) && in_array($atts['toolbar'], array('top', 'bottom', 'both')) ? $atts['toolbar'] : $options['pdfemb_toolbar'];
|
101 |
+
if (!in_array($toolbar, array('top', 'bottom', 'both'))) {
|
102 |
+
$toolbar = 'bottom';
|
103 |
+
}
|
104 |
|
105 |
+
$toolbar_fixed = isset($atts['toolbarfixed']) ? $atts['toolbarfixed'] : $options['pdfemb_toolbarfixed'];
|
106 |
+
if (!in_array($toolbar_fixed, array('on', 'off'))) {
|
107 |
+
$toolbar_fixed = 'off';
|
108 |
+
}
|
109 |
|
110 |
$returnhtml = '<div class="pdfemb-viewer" data-pdf-url="'.esc_attr($this->modify_pdfurl($url)).'" style="'.esc_attr($extra_style).'" '
|
111 |
.'data-width="'.esc_attr($width).'" data-height="'.esc_attr($height).'" ';
|
155 |
}
|
156 |
|
157 |
public function pdfemb_options_do_page() {
|
158 |
+
|
159 |
+
wp_enqueue_script( 'pdfemb_admin_js', $this->my_plugin_url().'js/admin/pdfemb-admin.js', array('jquery') );
|
160 |
+
wp_enqueue_style( 'pdfemb_admin_css', $this->my_plugin_url().'css/pdfemb-admin.css' );
|
161 |
+
|
162 |
+
$submit_page = is_multisite() ? 'edit.php?action='.$this->get_options_menuname() : 'options.php';
|
163 |
|
164 |
if (is_multisite()) {
|
165 |
$this->pdfemb_options_do_network_errors();
|
168 |
|
169 |
<div>
|
170 |
|
171 |
+
<h2>PDF Embedder setup</h2>
|
|
|
|
|
|
|
|
|
172 |
|
173 |
+
<p>To use the plugin, just embed PDFs in the same way as you would normally embed images in your posts/pages - but try with a PDF file instead.</p>
|
174 |
+
<p>From the post editor, click Add Media, and then drag-and-drop your PDF file into the media library.
|
175 |
+
When you insert the PDF into your post, it will automatically embed using the plugin's viewer.</p>
|
176 |
+
|
177 |
+
|
178 |
+
<div id="pdfemb-tablewrapper">
|
179 |
+
|
180 |
+
<div id="pdfemb-tableleft" class="pdfemb-tablecell">
|
181 |
+
|
182 |
+
<h2 id="pdfemb-tabs" class="nav-tab-wrapper">
|
183 |
+
<a href="#main" id="main-tab" class="nav-tab nav-tab-active">Main Settings</a>
|
184 |
+
<a href="#mobile" id="mobile-tab" class="nav-tab">Mobile</a>
|
185 |
+
<a href="#secure" id="secure-tab" class="nav-tab">Secure</a>
|
186 |
+
<?php $this->draw_more_tabs(); ?>
|
187 |
+
</h2>
|
188 |
+
|
189 |
+
<form action="<?php echo $submit_page; ?>" method="post" id="pdfemb_form" enctype="multipart/form-data" >
|
190 |
+
|
191 |
+
<?php
|
192 |
+
|
193 |
+
echo '<div id="main-section" class="pdfembtab active">';
|
194 |
+
$this->pdfemb_mainsection_text();
|
195 |
+
echo '</div>';
|
196 |
+
|
197 |
+
echo '<div id="mobile-section" class="pdfembtab">';
|
198 |
+
$this->pdfemb_mobilesection_text();
|
199 |
+
echo '</div>';
|
200 |
+
|
201 |
+
echo '<div id="secure-section" class="pdfembtab">';
|
202 |
+
$this->pdfemb_securesection_text();
|
203 |
+
echo '</div>';
|
204 |
+
|
205 |
+
settings_fields($this->get_options_pagename());
|
206 |
|
|
|
207 |
?>
|
208 |
+
|
209 |
+
<p class="submit">
|
210 |
+
<input type="submit" value="Save Changes" class="button button-primary" id="submit" name="submit">
|
211 |
+
</p>
|
212 |
|
213 |
+
</form>
|
214 |
+
</div>
|
215 |
+
|
216 |
+
</div>
|
217 |
|
218 |
</div> <?php
|
219 |
}
|
220 |
+
|
221 |
+
protected function draw_more_tabs() {
|
222 |
+
}
|
223 |
+
|
224 |
+
|
225 |
+
// Override elsewhere
|
226 |
protected function pdfemb_mainsection_text() {
|
227 |
+
$options = $this->get_option_pdfemb();
|
228 |
?>
|
229 |
+
|
230 |
+
|
231 |
+
<h2>Default Viewer Settings</h2>
|
232 |
+
|
233 |
+
<label for="input_pdfemb_width" class="textinput">Width</label>
|
234 |
+
<input id='input_pdfemb_width' class='textinput' name='<?php echo $this->get_options_name(); ?>[pdfemb_width]' size='10' type='text' value='<?php echo esc_attr($options['pdfemb_width']); ?>' />
|
235 |
+
<br class="clear"/>
|
236 |
+
|
237 |
+
<label for="input_pdfemb_height" class="textinput">Height</label>
|
238 |
+
<input id='input_pdfemb_height' class='textinput' name='<?php echo $this->get_options_name(); ?>[pdfemb_height]' size='10' type='text' value='<?php echo esc_attr($options['pdfemb_height']); ?>' />
|
239 |
+
<br class="clear"/>
|
240 |
+
|
241 |
+
<p class="desc big"><i>Enter <b>max</b> or an integer number of pixels</i></p>
|
242 |
+
|
243 |
+
<br class="clear"/>
|
244 |
+
|
245 |
+
<label for="pdfemb_toolbar" class="textinput">Toolbar Location</label>
|
246 |
+
<select name='<?php echo $this->get_options_name(); ?>[pdfemb_toolbar]' id='pdfemb_toolbar' class='select'>
|
247 |
+
<option value="top" <?php echo $options['pdfemb_toolbar'] == 'top' ? 'selected' : ''; ?>>Top</option>
|
248 |
+
<option value="bottom" <?php echo $options['pdfemb_toolbar'] == 'bottom' ? 'selected' : ''; ?>>Bottom</option>
|
249 |
+
<option value="both" <?php echo $options['pdfemb_toolbar'] == 'both' ? 'selected' : ''; ?>>Both</option>
|
250 |
+
</select>
|
251 |
+
<br class="clear" />
|
252 |
+
<br class="clear" />
|
253 |
+
|
254 |
+
<label for="pdfemb_toolbarfixed" class="textinput">Toolbar Hover</label>
|
255 |
+
<span>
|
256 |
+
<input type="radio" name='<?php echo $this->get_options_name(); ?>[pdfemb_toolbarfixed]' id='pdfemb_toolbarfixed_off' class='radio' value="off" <?php echo $options['pdfemb_toolbarfixed'] == 'off' ? 'checked' : ''; ?> />
|
257 |
+
<label for="pdfemb_toolbarfixed_off" class="radio">Toolbar appears only on hover over document</label>
|
258 |
+
</span>
|
259 |
+
<br/>
|
260 |
+
<span>
|
261 |
+
<input type="radio" name='<?php echo $this->get_options_name(); ?>[pdfemb_toolbarfixed]' id='pdfemb_toolbarfixed_on' class='radio' value="on" <?php echo $options['pdfemb_toolbarfixed'] == 'on' ? 'checked' : ''; ?> />
|
262 |
+
<label for="pdfemb_toolbarfixed_on" class="radio">Toolbar always visible</label>
|
263 |
+
</span>
|
264 |
+
<br class="clear" />
|
265 |
+
<br class="clear" />
|
266 |
+
|
267 |
+
<p>You can override these defaults for specific embeds by modifying the shortcodes - see <a href="<?php echo $this->get_instructions_url(); ?>" target="_blank">instructions</a>.</p>
|
268 |
+
|
269 |
+
<?php
|
270 |
}
|
271 |
+
|
272 |
+
protected function get_instructions_url() {
|
273 |
+
return 'http://wp-pdf.com/free-instructions/?utm_source=PDF%20Settings%20Main&utm_medium=freemium&utm_campaign=Freemium';
|
274 |
+
}
|
275 |
+
|
276 |
+
protected function pdfemb_mobilesection_text() {
|
277 |
+
}
|
278 |
+
|
279 |
+
protected function pdfemb_securesection_text()
|
280 |
+
{
|
281 |
+
?>
|
282 |
+
|
283 |
+
<h2>Protect your PDFs using PDF Embedder Secure</h2>
|
284 |
+
<p>Our <b>PDF Embedder Premium Secure</b> plugin provides the same simple but elegant viewer for your website visitors, with the added protection that
|
285 |
+
it is difficult for users to download or print the original PDF document.</p>
|
286 |
+
|
287 |
+
<p>This means that your PDF is unlikely to be shared outside your site where you have no control over who views, prints, or shares it.</p>
|
288 |
+
|
289 |
+
<p>See our website <a href="http://wp-pdf.com/secure/?utm_source=PDF%20Settings%20Secure&utm_medium=freemium&utm_campaign=Freemium">wp-pdf.com</a> for more
|
290 |
+
details and purchase options.
|
291 |
+
</p>
|
292 |
+
|
293 |
+
<?php
|
294 |
+
}
|
295 |
+
|
296 |
public function pdfemb_options_validate($input) {
|
297 |
$newinput = Array();
|
298 |
+
|
299 |
+
$newinput['pdfemb_width'] = isset($input['pdfemb_width']) ? trim(strtolower($input['pdfemb_width'])) : 'max';
|
300 |
+
if (!is_numeric($newinput['pdfemb_width']) && $newinput['pdfemb_width']!='max' && $newinput['pdfemb_width']!='auto') {
|
301 |
+
add_settings_error(
|
302 |
+
'pdfemb_width',
|
303 |
+
'widtherror',
|
304 |
+
self::get_error_string('pdfemb_width|widtherror'),
|
305 |
+
'error'
|
306 |
+
);
|
307 |
+
}
|
308 |
+
|
309 |
+
$newinput['pdfemb_height'] = isset($input['pdfemb_height']) ? trim(strtolower($input['pdfemb_height'])) : 'max';
|
310 |
+
if (!is_numeric($newinput['pdfemb_height']) && $newinput['pdfemb_height']!='max' && $newinput['pdfemb_height']!='auto') {
|
311 |
+
add_settings_error(
|
312 |
+
'pdfemb_height',
|
313 |
+
'heighterror',
|
314 |
+
self::get_error_string('pdfemb_height|heighterror'),
|
315 |
+
'error'
|
316 |
+
);
|
317 |
+
}
|
318 |
+
|
319 |
+
if (isset($input['pdfemb_toolbar']) && in_array($input['pdfemb_toolbar'], array('top', 'bottom', 'both'))) {
|
320 |
+
$newinput['pdfemb_toolbar'] = $input['pdfemb_toolbar'];
|
321 |
+
}
|
322 |
+
else {
|
323 |
+
$newinput['pdfemb_toolbar'] = 'bottom';
|
324 |
+
}
|
325 |
+
|
326 |
+
if (isset($input['pdfemb_toolbarfixed']) && in_array($input['pdfemb_toolbarfixed'], array('on', 'off'))) {
|
327 |
+
$newinput['pdfemb_toolbarfixed'] = $input['pdfemb_toolbarfixed'];
|
328 |
+
}
|
329 |
+
|
330 |
+
$newinput['pdfemb_version'] = $this->PLUGIN_VERSION;
|
331 |
return $newinput;
|
332 |
}
|
333 |
|
334 |
protected function get_error_string($fielderror) {
|
335 |
+
$local_error_strings = Array(
|
336 |
+
'pdfemb_width|widtherror' => 'Width must be "max" or an integer (number of pixels)',
|
337 |
+
'pdfemb_height|heighterror' => 'Height must be "max" or an integer (number of pixels)'
|
338 |
+
);
|
339 |
+
if (isset($local_error_strings[$fielderror])) {
|
340 |
+
return $local_error_strings[$fielderror];
|
341 |
+
}
|
342 |
+
|
343 |
return 'Unspecified error';
|
344 |
}
|
345 |
+
|
346 |
public function pdfemb_save_network_options() {
|
347 |
check_admin_referer( $this->get_options_pagename().'-options' );
|
348 |
|
349 |
if (isset($_POST[$this->get_options_name()]) && is_array($_POST[$this->get_options_name()])) {
|
350 |
$inoptions = $_POST[$this->get_options_name()];
|
351 |
|
352 |
+
$outoptions = $this->pdfemb_options_validate($inoptions);
|
353 |
|
354 |
$error_code = Array();
|
355 |
$error_setting = Array();
|
406 |
}
|
407 |
|
408 |
// OPTIONS
|
409 |
+
|
410 |
+
protected function get_options_name() {
|
411 |
+
return 'pdfemb';
|
412 |
+
}
|
413 |
+
|
414 |
protected function get_default_options() {
|
415 |
+
return Array(
|
416 |
+
'pdfemb_width' => 'max',
|
417 |
+
'pdfemb_height' => 'max',
|
418 |
+
'pdfemb_toolbar' => 'bottom',
|
419 |
+
'pdfemb_toolbarfixed' => 'off',
|
420 |
+
'pdfemb_version' => $this->PLUGIN_VERSION
|
421 |
+
);
|
422 |
}
|
423 |
|
424 |
protected $pdfemb_options = null;
|
425 |
+
protected function get_option_pdfemb() {
|
426 |
if ($this->pdfemb_options != null) {
|
427 |
return $this->pdfemb_options;
|
428 |
}
|
439 |
$this->pdfemb_options = $option;
|
440 |
return $this->pdfemb_options;
|
441 |
}
|
442 |
+
|
443 |
+
protected function save_option_pdfemb($option) {
|
444 |
+
update_site_option($this->get_options_name(), $option);
|
445 |
+
$this->pdfemb_options = $option;
|
446 |
+
}
|
447 |
+
|
448 |
// ADMIN
|
449 |
|
450 |
public function pdfemb_admin_init() {
|
463 |
// Override in Premium
|
464 |
public function pdfemb_init() {
|
465 |
}
|
466 |
+
|
467 |
+
public function pdfemb_plugin_action_links( $links, $file ) {
|
468 |
+
if ($file == $this->my_plugin_basename()) {
|
469 |
+
$links = $this->extra_plugin_action_links($links);
|
470 |
+
|
471 |
+
$settings_link = '<a href="' . $this->get_settings_url() . '">Settings</a>';
|
472 |
+
array_unshift($links, $settings_link);
|
473 |
+
}
|
474 |
+
|
475 |
+
return $links;
|
476 |
+
}
|
477 |
+
|
478 |
+
protected function extra_plugin_action_links( $links ) {
|
479 |
+
return $links;
|
480 |
+
}
|
481 |
|
482 |
protected function add_actions() {
|
483 |
|
497 |
if (is_multisite()) {
|
498 |
add_action('network_admin_edit_'.$this->get_options_menuname(), array($this, 'pdfemb_save_network_options'));
|
499 |
}
|
500 |
+
|
501 |
+
add_filter(is_multisite() ? 'network_admin_plugin_action_links' : 'plugin_action_links', array($this, 'pdfemb_plugin_action_links'), 10, 2 );
|
502 |
}
|
503 |
}
|
504 |
|
css/pdfemb-admin.css
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
.pdfembtab.active {
|
3 |
+
display: block;
|
4 |
+
}
|
5 |
+
|
6 |
+
.pdfembtab {
|
7 |
+
display: none;
|
8 |
+
}
|
9 |
+
|
10 |
+
label {
|
11 |
+
float: left;
|
12 |
+
margin-left: 6px;
|
13 |
+
}
|
14 |
+
|
15 |
+
input.textinput, textarea.textinput, select.select, input.checkbox {
|
16 |
+
float: left;
|
17 |
+
margin: 12px 3px 0 0;
|
18 |
+
padding: 5px;
|
19 |
+
}
|
20 |
+
|
21 |
+
label.radio {
|
22 |
+
float: none;
|
23 |
+
margin-left: 6px;
|
24 |
+
}
|
25 |
+
|
26 |
+
select.select {
|
27 |
+
padding: 2px 5px;
|
28 |
+
}
|
29 |
+
|
30 |
+
input.checkbox.double {
|
31 |
+
margin-top: 2px;
|
32 |
+
}
|
33 |
+
|
34 |
+
label.textinput, label.select, label.checkbox {
|
35 |
+
background-color: rgba(0, 0, 0, 0);
|
36 |
+
margin: 10px 0 5px;
|
37 |
+
width: 180px;
|
38 |
+
font-weight: bold;
|
39 |
+
}
|
40 |
+
|
41 |
+
label.checkbox.plain {
|
42 |
+
font-weight: normal;
|
43 |
+
width: 400px;
|
44 |
+
}
|
45 |
+
|
46 |
+
label.big {
|
47 |
+
font-size: 1.3em;
|
48 |
+
padding-top: 8px;
|
49 |
+
}
|
50 |
+
|
51 |
+
p.desc {
|
52 |
+
font-style: italic;
|
53 |
+
margin: 6px 0 10px;
|
54 |
+
padding: 0 0 8px 22px;
|
55 |
+
}
|
56 |
+
|
57 |
+
p.desc.big {
|
58 |
+
padding-left: 180px;
|
59 |
+
}
|
60 |
+
|
61 |
+
a#pdfemb-personalinstrlink {
|
62 |
+
color: #0074A2;
|
63 |
+
text-decoration: underline;
|
64 |
+
}
|
65 |
+
|
66 |
+
#pdfemb-tablewrapper {
|
67 |
+
display: table;
|
68 |
+
width: 100%;
|
69 |
+
}
|
70 |
+
|
71 |
+
#pdfemb-tableleft {
|
72 |
+
|
73 |
+
}
|
74 |
+
|
75 |
+
#pdfemb-tableright {
|
76 |
+
padding: 0 0 0 40px;
|
77 |
+
width: 281px;
|
78 |
+
}
|
79 |
+
|
80 |
+
#pdfemb-tableright div {
|
81 |
+
width: 235px;
|
82 |
+
padding: 5px;
|
83 |
+
background-color: #E4E4E4;
|
84 |
+
text-align: center;
|
85 |
+
margin-bottom: 20px;
|
86 |
+
}
|
87 |
+
|
88 |
+
#pdfemb-tableright div span {
|
89 |
+
padding: 5px;
|
90 |
+
}
|
91 |
+
|
92 |
+
.pdfemb-tablecell {
|
93 |
+
display: table-cell;
|
94 |
+
height: 500px;
|
95 |
+
margin: 0;
|
96 |
+
padding: 0;
|
97 |
+
vertical-align: top;
|
98 |
+
}
|
js/admin/pdfemb-admin.js
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
jQuery(document).ready(function() {
|
3 |
+
|
4 |
+
function pdfembSetActionToTab(id) {
|
5 |
+
var frm = jQuery('#pdfemb_form');
|
6 |
+
frm.attr('action', frm.attr('action').replace(/(#.+)?$/, '#' + id));
|
7 |
+
}
|
8 |
+
|
9 |
+
jQuery('#pdfemb-tabs').find('a').click(function () {
|
10 |
+
jQuery('#pdfemb-tabs').find('a').removeClass('nav-tab-active');
|
11 |
+
jQuery('.pdfembtab').removeClass('active');
|
12 |
+
var id = jQuery(this).attr('id').replace('-tab', '');
|
13 |
+
jQuery('#' + id + '-section').addClass('active');
|
14 |
+
jQuery(this).addClass('nav-tab-active');
|
15 |
+
|
16 |
+
// Set submit URL to this tab
|
17 |
+
pdfembSetActionToTab(id);
|
18 |
+
});
|
19 |
+
|
20 |
+
// Did page load with a tab active?
|
21 |
+
var active_tab = window.location.hash.replace('#', '');
|
22 |
+
if (active_tab != '') {
|
23 |
+
var activeSection = jQuery('#' + active_tab + '-section');
|
24 |
+
var activeTab = jQuery('#' + active_tab + '-tab');
|
25 |
+
|
26 |
+
if (activeSection && activeTab) {
|
27 |
+
jQuery('#pdfemb-tabs').find('a').removeClass('nav-tab-active');
|
28 |
+
jQuery('.pdfembtab').removeClass('active');
|
29 |
+
|
30 |
+
activeSection.addClass('active');
|
31 |
+
activeTab.addClass('nav-tab-active');
|
32 |
+
pdfembSetActionToTab(active_tab);
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
});
|
37 |
+
|
pdf_embedder.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: PDF Embedder
|
5 |
* Plugin URI: http://wp-pdf.com/
|
6 |
* Description: Embed PDFs straight into your posts and pages, with flexible width and height. No third-party services required.
|
7 |
-
* Version: 2.
|
8 |
* Author: Dan Lester
|
9 |
* Author URI: http://wp-pdf.com/
|
10 |
* License: GPL3
|
@@ -13,6 +13,8 @@
|
|
13 |
require_once( plugin_dir_path(__FILE__).'/core/core_pdf_embedder.php' );
|
14 |
|
15 |
class pdfemb_basic_pdf_embedder extends core_pdf_embedder {
|
|
|
|
|
16 |
|
17 |
protected function useminified() {
|
18 |
/* using-minified */ return true;
|
@@ -52,49 +54,44 @@ class pdfemb_basic_pdf_embedder extends core_pdf_embedder {
|
|
52 |
|
53 |
// ADMIN
|
54 |
|
55 |
-
protected function
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
// Don't need a submit button here
|
60 |
-
protected function pdfemb_options_submit() {
|
61 |
-
}
|
62 |
-
|
63 |
-
protected function pdfemb_mainsection_text() {
|
64 |
-
parent::pdfemb_mainsection_text();
|
65 |
-
?>
|
66 |
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
|
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
|
|
|
|
|
83 |
|
84 |
-
|
85 |
-
|
86 |
-
<p>Our <b>PDF Embedder Premium Secure</b> plugin provides the same simple but elegant viewer for your website visitors, with the added protection that
|
87 |
-
it is difficult for users to download or print the original PDF document.</p>
|
88 |
|
89 |
-
|
|
|
|
|
90 |
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
<?php
|
96 |
}
|
97 |
-
|
98 |
// AUX
|
99 |
|
100 |
protected function my_plugin_basename() {
|
4 |
* Plugin Name: PDF Embedder
|
5 |
* Plugin URI: http://wp-pdf.com/
|
6 |
* Description: Embed PDFs straight into your posts and pages, with flexible width and height. No third-party services required.
|
7 |
+
* Version: 2.1
|
8 |
* Author: Dan Lester
|
9 |
* Author URI: http://wp-pdf.com/
|
10 |
* License: GPL3
|
13 |
require_once( plugin_dir_path(__FILE__).'/core/core_pdf_embedder.php' );
|
14 |
|
15 |
class pdfemb_basic_pdf_embedder extends core_pdf_embedder {
|
16 |
+
|
17 |
+
protected $PLUGIN_VERSION = '2.1';
|
18 |
|
19 |
protected function useminified() {
|
20 |
/* using-minified */ return true;
|
54 |
|
55 |
// ADMIN
|
56 |
|
57 |
+
protected function pdfemb_mobilesection_text()
|
58 |
+
{
|
59 |
+
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
+
<h2>Mobile-friendly embedding using PDF Embedder Premium</h2>
|
62 |
+
<p>This free version of the plugin should work on most mobile browsers, but it will be cumbersome for users with
|
63 |
+
small screens - it is difficult to position
|
64 |
+
the document entirely within the screen, and your users' fingers may catch the entire browser page when
|
65 |
+
they're trying only to move about the document...</p>
|
66 |
|
67 |
+
<p>Our <b>PDF Embedder Premium</b> plugin solves this problem with an intelligent 'full screen' mode.
|
68 |
+
When the document is smaller than a certain width, the document displays only as a 'thumbnail' with a large
|
69 |
+
'View in Full Screen' button for the
|
70 |
+
user to click when they want to study your document.
|
71 |
+
This opens up the document so it has the full focus of the mobile browser, and the user can move about the
|
72 |
+
document without hitting other parts of
|
73 |
+
the web page by mistake. Click Exit to return to the regular web page.
|
74 |
+
</p>
|
75 |
|
76 |
+
<p>See our website <a
|
77 |
+
href="http://wp-pdf.com/premium/?utm_source=PDF%20Settings%20Premium&utm_medium=freemium&utm_campaign=Freemium">wp-pdf.com</a>
|
78 |
+
for more
|
79 |
+
details and purchase options.
|
80 |
+
</p>
|
81 |
|
82 |
+
<?php
|
83 |
+
}
|
|
|
|
|
84 |
|
85 |
+
protected function extra_plugin_action_links( $links ) {
|
86 |
+
$secure_link = '<a href="http://wp-pdf.com/secure/?utm_source=Plugins%20Secure&utm_medium=freemium&utm_campaign=Freemium" target="_blank">Secure</a>';
|
87 |
+
$mobile_link = '<a href="http://wp-pdf.com/premium/?utm_source=Plugins%20Premium&utm_medium=freemium&utm_campaign=Freemium" target="_blank">Mobile</a>';
|
88 |
|
89 |
+
array_unshift( $links, $secure_link );
|
90 |
+
array_unshift( $links, $mobile_link );
|
91 |
+
|
92 |
+
return $links;
|
|
|
93 |
}
|
94 |
+
|
95 |
// AUX
|
96 |
|
97 |
protected function my_plugin_basename() {
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: danlester
|
|
3 |
Tags: doc, docx, pdf, office, powerpoint, google, document, embed, intranet
|
4 |
Requires at least: 3.3
|
5 |
Tested up to: 4.2
|
6 |
-
Stable tag: 2.
|
7 |
License: GPLv3
|
8 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
9 |
|
@@ -27,7 +27,9 @@ When you insert into your post, it will appear in the editor as a 'shortcode' as
|
|
27 |
|
28 |
[pdf-embedder url="https://mysite.com/wp-content/uploads/2015/01/Plan-Summary.pdf"]
|
29 |
|
30 |
-
|
|
|
|
|
31 |
|
32 |
= Mobile-friendly embedding using PDF Embedder Premium =
|
33 |
|
@@ -65,41 +67,22 @@ Always include your full shortcode, plus links to the relevant pages, and screen
|
|
65 |
We may occasionally be able to respond to support queries posted on the 'Support' forum here on the wordpress.org
|
66 |
plugin page, but we recommend sending us an email instead if possible.
|
67 |
|
68 |
-
= How can I change the Size? =
|
69 |
-
|
70 |
-
You can optionally override width and height as follows:
|
71 |
-
|
72 |
-
[pdf-embedder url="https://mysite.com/wp-content/uploads/2015/01/Plan-Summary.pdf" **width="500"**]
|
73 |
|
74 |
-
|
75 |
|
76 |
Resizing works as follows:
|
77 |
|
78 |
* If width='max' the width will take as much space as possible within its parent container (e.g. column within your page).
|
79 |
-
* If width='auto' the width will be equal to the 'natural' width of the PDF document contents (i.e. whatever width the PDF says it should be by default).
|
80 |
* If width is a number (e.g. width='500') then it will display at that number of pixels wide.
|
81 |
|
82 |
*In all cases, if the parent container is narrower than the width calculated above, then the document width will be reduced to the size of the container.*
|
83 |
|
84 |
The height will be calculated so that the document fits naturally, given the width already calculated.
|
85 |
|
86 |
-
|
87 |
-
The height will be reduced to fit if it is larger than needed to display the document correctly.
|
88 |
-
|
89 |
-
= Can I customize the Toolbar? =
|
90 |
-
|
91 |
-
_Toolbar Location_
|
92 |
-
|
93 |
-
Add toolbar="[top|bottom|both]" to the shortcode to change the location of the Next/Prev toolbar (default is 'bottom').
|
94 |
|
95 |
-
|
96 |
-
|
97 |
-
_Toolbar Fixed/Hover_
|
98 |
-
|
99 |
-
Add toolbarfixed="on" (default is 'off') to keep the toolbar open at all times rather than only when the user hovers over the document.
|
100 |
-
Note this of course extends the length of your embedded area.
|
101 |
-
|
102 |
-
E.g. [pdf-embedder url="https://mysite.com/wp-content/uploads/2015/01/Plan-Summary.pdf" **toolbarfixed="on"**]
|
103 |
|
104 |
= Can I improve the viewing experience for mobile users? =
|
105 |
|
@@ -136,6 +119,10 @@ the Plugins section of your Wordpress admin
|
|
136 |
|
137 |
== Changelog ==
|
138 |
|
|
|
|
|
|
|
|
|
139 |
= 2.0 =
|
140 |
|
141 |
Added zoom feature. Toolbars can be fixed instead of appearing on hover.
|
3 |
Tags: doc, docx, pdf, office, powerpoint, google, document, embed, intranet
|
4 |
Requires at least: 3.3
|
5 |
Tested up to: 4.2
|
6 |
+
Stable tag: 2.1
|
7 |
License: GPLv3
|
8 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
9 |
|
27 |
|
28 |
[pdf-embedder url="https://mysite.com/wp-content/uploads/2015/01/Plan-Summary.pdf"]
|
29 |
|
30 |
+
You can change the default appearance - e.g. width, and toolbar position/appearance through **Settings -> PDF Embedder**.
|
31 |
+
|
32 |
+
To override your site-wide defaults on an individual embed, see the [Plugin Instructions](http://wp-pdf.com/free-instructions/?utm_source=PDF%20Readme%20Instructions&utm_medium=freemium&utm_campaign=Freemium) for information about sizing options plus other ways to customize the shortcodes.
|
33 |
|
34 |
= Mobile-friendly embedding using PDF Embedder Premium =
|
35 |
|
67 |
We may occasionally be able to respond to support queries posted on the 'Support' forum here on the wordpress.org
|
68 |
plugin page, but we recommend sending us an email instead if possible.
|
69 |
|
70 |
+
= How can I change the Size or customize the Toolbar? =
|
|
|
|
|
|
|
|
|
71 |
|
72 |
+
See Settings -> PDF Embedder in your WordPress admin to change site-wide defaults. You can also override individual embeds by modifying the shortcode.
|
73 |
|
74 |
Resizing works as follows:
|
75 |
|
76 |
* If width='max' the width will take as much space as possible within its parent container (e.g. column within your page).
|
|
|
77 |
* If width is a number (e.g. width='500') then it will display at that number of pixels wide.
|
78 |
|
79 |
*In all cases, if the parent container is narrower than the width calculated above, then the document width will be reduced to the size of the container.*
|
80 |
|
81 |
The height will be calculated so that the document fits naturally, given the width already calculated.
|
82 |
|
83 |
+
The Next/Prev toolbar can appear at the top or bottom of the document (or both), and it can either appear only when the user hovers over the document or it can be fixed at all times.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
|
85 |
+
See the [Plugin Instructions](http://wp-pdf.com/free-instructions/?utm_source=PDF%20Readme%20FAQ&utm_medium=freemium&utm_campaign=Freemium) for more details about sizing and toolbar options.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
|
87 |
= Can I improve the viewing experience for mobile users? =
|
88 |
|
119 |
|
120 |
== Changelog ==
|
121 |
|
122 |
+
= 2.1 =
|
123 |
+
|
124 |
+
Settings -> PDF Embedder page so you can now set site-wide defaults for width, height, and toolbar location/appearance.
|
125 |
+
|
126 |
= 2.0 =
|
127 |
|
128 |
Added zoom feature. Toolbars can be fixed instead of appearing on hover.
|