PluginProbe ʕ •ᴥ•ʔ
DearFlip – PDF Flipbook, 3D Flipbook, PDF embed, PDF viewer / 2.3.24
DearFlip – PDF Flipbook, 3D Flipbook, PDF embed, PDF viewer v2.3.24
2.4.30 trunk 1.7.16 1.7.35 2.0.86 2.2.32 2.2.39 2.2.41 2.2.47 2.2.54 2.2.55 2.2.56 2.3.24 2.3.32 2.3.52 2.3.53 2.3.54 2.3.55 2.3.57 2.3.74 2.3.75 2.4.20 2.4.27
3d-flipbook-dflip-lite / 3d-flipbook-dflip-lite.php
3d-flipbook-dflip-lite Last commit date
assets 1 year ago inc 1 year ago 3d-flipbook-dflip-lite.php 1 year ago index.php 1 year ago readme.txt 1 year ago
3d-flipbook-dflip-lite.php
882 lines
1 <?php
2 // @formatter:off
3 /**
4 * Plugin Name: 3D FlipBook : Dflip Lite
5 * Description: Realistic 3D Flip-books for WordPress <a href="https://dearflip.com/go/wp-lite-full-version" >Get Full Version Here</a><strong> NOTE : Deactivate this lite version before activating Full Version</strong>
6 *
7 * Version: 2.3.24
8 *
9 * Text Domain: 3d-flipbook-dflip-lite
10 * Author: DearHive
11 * Author URI: https://dearflip.com/go/wp-lite-author
12 *
13 */
14 // @formatter:on
15
16 // Exit if accessed directly.
17 if ( !defined( 'ABSPATH' ) ) {
18 exit;
19 }
20
21 if ( !class_exists( 'DFlip' ) ) {
22 /**
23 * Main dFlip plugin class.
24 *
25 * @since 1.0.0
26 *
27 * @package DFlip
28 * @author Deepak Ghimire
29 */
30 class DFlip {
31
32 /**
33 * Holds the singleton class object.
34 *
35 * @since 1.0.0
36 *
37 * @var object
38 */
39 public static $instance;
40
41 /**
42 * Plugin version
43 *
44 * @since 1.0.0
45 *
46 * @var string
47 */
48 public $version = '2.3.24';
49
50 /**
51 * The name of the plugin.
52 *
53 * @since 1.0.0
54 *
55 * @var string
56 */
57 public $plugin_name = 'dFlip';
58
59 /**
60 * Unique plugin slug identifier.
61 *
62 * @since 1.0.0
63 *
64 * @var string
65 */
66 public $plugin_slug = 'dflip';
67 public $settings_help_page = 'https://dearflip.com/docs/dearflip-wordpress/features/settings/';
68 public $plugin_url = "https://wordpress.org/plugins/3d-flipbook-dflip-lite/";
69 /**
70 * Plugin file.
71 *
72 * @since 1.0.0
73 *
74 * @var string
75 */
76 public $file = __FILE__;
77
78 /**
79 * Default values.
80 *
81 * @since 1.2.6
82 *
83 * @var string
84 */
85 public $defaults;
86
87 /**
88 * Primary class constructor.
89 *
90 * @since 1.0.0
91 */
92 public $settings_text;
93 public $external_translate;
94 public $selective_script_loading;
95 public function __construct() {
96
97 $this->settings_text = array();
98 $this->external_translate = false;
99 // Load the plugin.
100 add_action( 'init', array( $this, 'init' ), 0 );
101
102 }
103
104 /**
105 * Loads the plugin into WordPress.
106 *
107 * @since 1.0.0
108 */
109 public function init() {
110
111 $this->defaults = array(
112
113 'text_toggle_sound' => __( "Turn on/off Sound", '3d-flipbook-dflip-lite' ),
114 'text_toggle_thumbnails' => __( "Toggle Thumbnails", '3d-flipbook-dflip-lite' ),
115 'text_toggle_outline' => __( "Toggle Outline/Bookmark", '3d-flipbook-dflip-lite' ),
116 'text_previous_page' => __( "Previous Page", '3d-flipbook-dflip-lite' ),
117 'text_next_page' => __( "Next Page", '3d-flipbook-dflip-lite' ),
118 'text_toggle_fullscreen' => __( "Toggle Fullscreen", '3d-flipbook-dflip-lite' ),
119 'text_zoom_in' => __( "Zoom In", '3d-flipbook-dflip-lite' ),
120 'text_zoom_out' => __( "Zoom Out", '3d-flipbook-dflip-lite' ),
121 'text_toggle_help' => __( "Toggle Help", '3d-flipbook-dflip-lite' ),
122 'text_single_page_mode' => __( "Single Page Mode", '3d-flipbook-dflip-lite' ),
123 'text_double_page_mode' => __( "Double Page Mode", '3d-flipbook-dflip-lite' ),
124 'text_download_PDF_file' => __( "Download PDF File", '3d-flipbook-dflip-lite' ),
125 'text_goto_first_page' => __( "Goto First Page", '3d-flipbook-dflip-lite' ),
126 'text_goto_last_page' => __( "Goto Last Page", '3d-flipbook-dflip-lite' ),
127 'text_share' => __( "Share", '3d-flipbook-dflip-lite' ),
128 'text_mail_subject' => __( "I wanted you to see this FlipBook", '3d-flipbook-dflip-lite' ),
129 'text_mail_body' => __( "Check out this site {{url}}", '3d-flipbook-dflip-lite' ),
130 'text_loading' => __( "DearFlip: Loading ", '3d-flipbook-dflip-lite' ),
131
132 'external_translate' => array(
133 'std' => 'false',
134 ),
135 'more_controls' => array(
136 'std' => "download,pageMode,startPage,endPage,sound",
137 ),
138 'hide_controls' => array(
139 'std' => "",
140 ),
141 'scroll_wheel' => array(
142 'std' => 'false',
143 ),
144 'bg_color' => array(
145 'std' => "#777",
146 'title' => __( 'Background Color', '3d-flipbook-dflip-lite' ),
147 'desc' => __( 'Background color in hexadecimal format eg:<code>#FFF</code> or <code>#666666</code>', '3d-flipbook-dflip-lite' ),
148 'placeholder' => 'Example: #ffffff',
149 'type' => 'text'
150 ),
151 'bg_image' => array(
152 'std' => "",
153 'class' => '',
154 'title' => __( 'Background Image', '3d-flipbook-dflip-lite' ),
155 'desc' => __( 'Background image JPEG or PNG format:', '3d-flipbook-dflip-lite' ),
156 'placeholder' => __( 'Select an image', '3d-flipbook-dflip-lite' ),
157 'type' => 'upload',
158 'button-tooltip' => __( 'Select Background Image', '3d-flipbook-dflip-lite' ),
159 'button-text' => __( 'Select Image', '3d-flipbook-dflip-lite' ),
160 ),
161 'height' => array(
162 'std' => "auto",
163 'title' => __( 'Container Height', '3d-flipbook-dflip-lite' ),
164 'desc' => __( 'Height of the flipbook container when in embed mode.', '3d-flipbook-dflip-lite' ),
165 'placeholder' => 'Example: 500',
166 'type' => 'text'
167 ),
168 'padding_left' => array(
169 'std' => "20",
170 ),
171 'padding_right' => array(
172 'std' => "20",
173 ),
174 'duration' => array(
175 'std' => 800,
176 'class' => '',
177 'title' => __( 'Flip Duration', '3d-flipbook-dflip-lite' ),
178 'desc' => __( 'Time in milliseconds eg:<code>1000</code>for 1second', '3d-flipbook-dflip-lite' ),
179 'placeholder' => 'Example: 1000',
180 'type' => 'number'
181 ),
182 'zoom_ratio' => array(
183 'std' => 1.5,
184 ),
185 'stiffness' => array(
186 'std' => 3,
187 ),
188 'auto_sound' => array(
189 'std' => 'true',
190 'choices' => array(
191 'global' => __( 'Global Setting', '3d-flipbook-dflip-lite' ),
192 'true' => __( 'True', '3d-flipbook-dflip-lite' ),
193 'false' => __( 'False', '3d-flipbook-dflip-lite' )
194 ),
195 'class' => '',
196 'title' => __( 'Auto Enable Sound', '3d-flipbook-dflip-lite' ),
197 'desc' => __( 'Sound will play from the start.', '3d-flipbook-dflip-lite' ),
198 ),
199 'enable_download' => array(
200 'std' => 'true',
201 'choices' => array(
202 'global' => __( 'Global Setting', '3d-flipbook-dflip-lite' ),
203 'true' => __( 'True', '3d-flipbook-dflip-lite' ),
204 'false' => __( 'False', '3d-flipbook-dflip-lite' )
205 ),
206 'class' => '',
207 'title' => __( 'Enable Download', '3d-flipbook-dflip-lite' ),
208 'desc' => __( 'Enable PDF download', '3d-flipbook-dflip-lite' ),
209 ),
210 'enable_search' => array(
211 'std' => 'false',
212 ),
213 'enable_print' => array(
214 'std' => 'false',
215 ),
216 'enable_annotation' => array(
217 'std' => 'false',
218 ),
219 'enable_analytics' => array(
220 'std' => 'false',
221 ),
222 'webgl' => array(
223 'std' => 'true',
224 'choices' => array(
225 'global' => __( 'Global Setting', '3d-flipbook-dflip-lite' ),
226 'true' => __( 'WebGL 3D', '3d-flipbook-dflip-lite' ),
227 'false' => __( 'CSS 3D/2D', '3d-flipbook-dflip-lite' )
228 ),
229 'title' => __( '3D or 2D', '3d-flipbook-dflip-lite' ),
230 'desc' => __( 'Choose the mode of display. WebGL for realistic 3d', '3d-flipbook-dflip-lite' ),
231 ),
232 'hard' => array(
233 'std' => 'none',
234 'choices' => array(
235 'global' => __( 'Global Setting', '3d-flipbook-dflip-lite' ),
236 'cover' => __( 'Cover Pages', '3d-flipbook-dflip-lite' ),
237 'all' => __( 'All Pages', '3d-flipbook-dflip-lite' ),
238 'none' => __( 'None', '3d-flipbook-dflip-lite' )
239 ),
240 'class' => '',
241 'title' => __( 'Hard Pages', '3d-flipbook-dflip-lite' ),
242 'desc' => __( 'Choose which pages to act as hard.(Only in CSS mode)', '3d-flipbook-dflip-lite' ),
243 ),
244 'direction' => array(
245 'std' => 1,
246 'choices' => array(
247 1 => __( 'Left to Right', '3d-flipbook-dflip-lite' ),
248 2 => __( 'Right to Left', '3d-flipbook-dflip-lite' )
249 ),
250 'title' => __( 'Direction', '3d-flipbook-dflip-lite' ),
251 'desc' => __( 'Left to Right or Right to Left.', '3d-flipbook-dflip-lite' ),
252 ),
253 'source_type' => array(
254 'std' => 'pdf',
255 'choices' => array(
256 'pdf' => __( 'PDF File', '3d-flipbook-dflip-lite' ),
257 'image' => __( 'Images', '3d-flipbook-dflip-lite' )
258 ),
259 'title' => __( 'Book Source Type', '3d-flipbook-dflip-lite' ),
260 'desc' => __( 'Choose the source of this book. "PDF" for pdf files. "Images" for image files.', '3d-flipbook-dflip-lite' ),
261 ),
262 'pdf_source' => array(
263 'std' => "",
264 'title' => __( 'PDF File', '3d-flipbook-dflip-lite' ),
265 'desc' => __( 'Choose a PDF File to use as source for the book.', '3d-flipbook-dflip-lite' ),
266 'placeholder' => __( 'Select a PDF File', '3d-flipbook-dflip-lite' ),
267 'type' => 'upload',
268 'button-tooltip' => __( 'Select a PDF File', '3d-flipbook-dflip-lite' ),
269 'button-text' => __( 'Select PDF', '3d-flipbook-dflip-lite' ),
270 'condition' => 'dflip_source_type:is(pdf)',
271 'class' => 'hide-on-fail'
272 ),
273 'pdf_thumb' => array(
274 'std' => "",
275 'title' => __( 'PDF Thumbnail Image', '3d-flipbook-dflip-lite' ),
276 'desc' => __( 'Choose an image file for PDF thumb.', '3d-flipbook-dflip-lite' ),
277 'placeholder' => __( 'Select an image', '3d-flipbook-dflip-lite' ),
278 'type' => 'upload',
279 'button-tooltip' => __( 'Select PDF Thumb Image', '3d-flipbook-dflip-lite' ),
280 'button-text' => __( 'Select Thumb', '3d-flipbook-dflip-lite' ),
281 'condition' => 'dflip_source_type:is(pdf)',
282 'class' => 'hide-on-fail'
283 ),
284 'overwrite_outline' => array(
285 'std' => 'false', //isset mis-interprets 0 and false differently than expected
286 'choices' => array(
287 'true' => __( 'True', '3d-flipbook-dflip-lite' ),
288 'false' => __( 'False', '3d-flipbook-dflip-lite' )
289 ),
290 'class' => '',
291 'title' => __( 'Overwrite PDF Outline', '3d-flipbook-dflip-lite' ),
292 'desc' => __( 'Choose if PDF Outline will overwritten.', '3d-flipbook-dflip-lite' ),
293 'condition' => 'dflip_source_type:is(pdf)'
294 ),
295 'auto_outline' => array(
296 'std' => 'false', //isset mis-interprets 0 and false differently than expected
297 'choices' => array(
298 'true' => __( 'True', '3d-flipbook-dflip-lite' ),
299 'false' => __( 'False', '3d-flipbook-dflip-lite' )
300 ),
301 'class' => '',
302 'title' => __( 'Auto Enable Outline', '3d-flipbook-dflip-lite' ),
303 'desc' => __( 'Choose if outline will be auto enabled on start.', '3d-flipbook-dflip-lite' ),
304 ),
305 'auto_thumbnail' => array(
306 'std' => 'false', //isset mis-interprets 0 and false differently than expected
307 'choices' => array(
308 'true' => __( 'True', '3d-flipbook-dflip-lite' ),
309 'false' => __( 'False', '3d-flipbook-dflip-lite' )
310 ),
311 'class' => '',
312 'title' => __( 'Auto Enable Thumbnail', '3d-flipbook-dflip-lite' ),
313 'desc' => __( 'Choose if thumbnail will be auto enabled on start.Note : Either thumbnail or outline will be active at a time.)', '3d-flipbook-dflip-lite' ),
314 ),
315 'page_mode' => array(
316 'std' => '0',
317 'choices' => array(
318 'global' => __( 'Global Setting', '3d-flipbook-dflip-lite' ),
319 '0' => __( 'Auto', '3d-flipbook-dflip-lite' ),
320 '1' => __( 'Single Page', '3d-flipbook-dflip-lite' ),
321 '2' => __( 'Double Page', '3d-flipbook-dflip-lite' ),
322 ),
323 'class' => '',
324 'title' => __( 'Page Mode', '3d-flipbook-dflip-lite' ),
325 'desc' => __( 'Choose whether you want single mode or double page mode. Recommended Auto', '3d-flipbook-dflip-lite' ),
326 ),
327
328 'page_size' => array(
329 'std' => '0',
330 'choices' => array(
331 '0' => __( 'Auto', '3d-flipbook-dflip-lite' ),
332 '1' => __( 'Single Page', '3d-flipbook-dflip-lite' ),
333 '2' => __( 'Double Internal Page', '3d-flipbook-dflip-lite' ),
334 ),
335 'class' => '',
336 'title' => __( 'Page Size', '3d-flipbook-dflip-lite' ),
337 'desc' => __( 'Choose whether Layout is single page mode or double internal. Recommended Auto if PDF file', '3d-flipbook-dflip-lite' ),
338 ),
339 'single_page_mode' => array(
340 'std' => '0',
341 'choices' => array(
342 'global' => __( 'Global Setting', '3d-flipbook-dflip-lite' ),
343 '0' => __( 'Auto', '3d-flipbook-dflip-lite' ),
344 '1' => __( 'Normal Zoom', '3d-flipbook-dflip-lite' ),
345 '2' => __( 'Booklet Mode', '3d-flipbook-dflip-lite' ),
346 ),
347 'class' => '',
348 'title' => __( 'Single Page Mode', '3d-flipbook-dflip-lite' ),
349 'desc' => __( 'Choose how the single page will behave. If set to Auto, then in mobiles single page mode will be in Booklet mode.', '3d-flipbook-dflip-lite' ),
350 ),
351 'controls_position' => array(
352 'std' => 'bottom',
353 'choices' => array(
354 'global' => __( 'Global Setting', '3d-flipbook-dflip-lite' ),
355 'bottom' => __( 'Bottom', '3d-flipbook-dflip-lite' ),
356 'top' => __( 'Top', '3d-flipbook-dflip-lite' ),
357 'hide' => __( 'Hidden', '3d-flipbook-dflip-lite' ),
358 ),
359 'class' => '',
360 'title' => __( 'Controls Position', '3d-flipbook-dflip-lite' ),
361 'desc' => __( 'Choose where you want to display the controls bar or not display at all.', '3d-flipbook-dflip-lite' ),
362 ),
363 'texture_size' => array(
364 'std' => '1600',
365 'choices' => array(
366 'global' => __( 'Global Setting', '3d-flipbook-dflip-lite' ),
367 '1024' => '1024 px',
368 '1400' => '1400 px',
369 '1600' => '1600 px',
370 '1800' => '1800 px',
371 '2048' => '2048 px',
372 ),
373 'class' => '',
374 'title' => __( 'Page Render Size', '3d-flipbook-dflip-lite' ),
375 'desc' => __( 'Choose the size of image to be generated.', '3d-flipbook-dflip-lite' ),
376 ),
377 'link_target' => array(
378 'std' => '2',
379 ),
380 'share_prefix' => array(
381 'std' => "flipbook-",
382 ),
383
384 'share_slug' => array(
385 'std' => 'false',
386 ),
387
388 'attachment_lightbox' => array(
389 'std' => 'false',
390 ),
391
392 'range_size' => array(
393 'std' => '524288',
394 ),
395 'autoplay' => array(
396 'std' => 'false',
397 'choices' => array(
398 'global' => __( 'Global Setting', '3d-flipbook-dflip-lite' ),
399 'true' => __( 'True', '3d-flipbook-dflip-lite' ),
400 'false' => __( 'False', '3d-flipbook-dflip-lite' )
401 ),
402 'class' => '',
403 'title' => __( 'Enable AutoPlay', '3d-flipbook-dflip-lite' ),
404 'desc' => __( 'Enable AutoPlay in Flipbook', '3d-flipbook-dflip-lite' ),
405 ),
406
407 'autoplay_start' => array(
408 'std' => 'false',
409 'choices' => array(
410 'global' => __( 'Global Setting', '3d-flipbook-dflip-lite' ),
411 'true' => __( 'True', '3d-flipbook-dflip-lite' ),
412 'false' => __( 'False', '3d-flipbook-dflip-lite' )
413 ),
414 'class' => '',
415 'title' => __( 'Enable AutoPlay Automatically', '3d-flipbook-dflip-lite' ),
416 'desc' => __( 'Enable AutoPlay automatically when flipbook loads', '3d-flipbook-dflip-lite' ),
417 ),
418 'autoplay_duration' => array(
419 'std' => 5000,
420 'class' => '',
421 'title' => __( 'Autoplay Duration', '3d-flipbook-dflip-lite' ),
422 'desc' => __( 'Time in milliseconds eg:<code>1000</code>for 1second', '3d-flipbook-dflip-lite' ),
423 'placeholder' => 'Example: 5000',
424 'type' => 'number'
425 ),
426 'pages' => array()
427 );
428 $this->defaults['viewerType'] = array(
429 'std' => 'flipbook',
430 'choices' => array(
431 'global' => __( 'Global Setting', 'DFLIP' ),
432 'reader' => __( 'Vertical Reader', 'DFLIP' ),
433 'flipbook' => __( 'Flipbook', 'DFLIP' ),
434 'slider' => __( 'Slider', 'DFLIP' )
435 ),
436 'title' => __( 'Viewer Type', 'DFLIP' ),
437 'desc' => __( 'Choose the Viewer Type. Flipbook or normal viewer', 'DFLIP' )
438 );
439
440 $this->defaults['selectiveScriptLoading'] = array(
441 'std' => 'false',
442 'choices' => array(
443 'true' => 'True (Enable)',
444 'false' => 'False (Disable)',
445 ),
446 'title' => 'Selective Script Loading',
447 'desc' => 'Load Scripts only on pages where shortcodes are added. May not work properly in AJAX based themes. Also clear your CACHE PLUGIN CACHE!',
448 );
449
450 $this->selective_script_loading = $this->get_config( 'selectiveScriptLoading' ) == "true";
451 $external_translate = $this->get_config( 'external_translate' );
452 $this->external_translate = $external_translate == "true";
453
454
455 // Load admin only components.
456 if ( is_admin() && !wp_doing_ajax() ) {
457 $this->init_admin();
458 } else { // Load frontend only components.
459 $this->init_front();
460 }
461
462 // Load global components.
463 $this->init_global();
464
465 }
466
467 /**
468 * Loads all admin related files into scope.
469 *
470 * @since 1.0.0
471 */
472 public function init_admin() {
473
474 include_once( dirname( __FILE__ ) . '/inc/settings.php' );
475
476 //include the metaboxes file
477 include_once dirname( __FILE__ ) . "/inc/metaboxes.php";
478
479 }
480
481 /**
482 * Loads all frontend user related files
483 *
484 * @since 1.0.0
485 */
486 public function init_front() {
487
488 //include the shortcode parser
489 include_once dirname( __FILE__ ) . "/inc/shortcode.php";
490
491 //include the scripts and styles for front end
492 add_action( 'wp_enqueue_scripts', array( $this, 'init_front_scripts' ) );
493
494 //some custom js that need to be passed
495 add_action( 'wp_print_footer_scripts', array( $this, 'hook_script' ) );
496
497 }
498
499 /**
500 * Loads all global files into scope.
501 *
502 * @since 1.0.0
503 */
504 public function init_global() {
505
506 //include the post-type that manages the custom post
507 include_once dirname( __FILE__ ) . '/inc/post-type.php';
508
509 }
510
511 /**
512 * Loads all script and style sheets for frontend into scope.
513 *
514 * @since 1.0.0
515 */
516 public function init_front_scripts() {
517
518 //register scripts and style
519 wp_register_script( $this->plugin_slug . '-script', plugins_url( 'assets/js/dflip.min.js', __FILE__ ), array( "jquery" ), $this->version, true );
520 wp_register_style( $this->plugin_slug . '-style', plugins_url( 'assets/css/dflip.min.css', __FILE__ ), array(), $this->version );
521
522 if ( $this->selective_script_loading != true ) {
523 //enqueue scripts and style
524 wp_enqueue_script( $this->plugin_slug . '-script' );
525 wp_enqueue_style( $this->plugin_slug . '-style' );
526 }
527
528 }
529
530 public function add_defer_attribute( $tag, $handle ) {
531 // add script handles to the array below
532 //cache for plugin_slug
533 $_slug = $this->plugin_slug;
534 $scripts_to_defer = array( 'jquery-core', $_slug . '-script', $_slug . '-parse-script' );
535
536 foreach ( $scripts_to_defer as $defer_script ) {
537 if ( $defer_script === $handle ) {
538 return str_replace( ' src', ' data-cfasync="false" src', $tag );
539 }
540 }
541
542 return $tag;
543 }
544
545 /**
546 * Registers a javascript variable into HTML DOM for url access
547 *
548 * @since 1.0.0
549 */
550 public function hook_script() {
551
552 $data = array(
553 'text' => array(
554 'toggleSound' => $this->get_translate( 'text_toggle_sound' ),
555 'toggleThumbnails' => $this->get_translate( 'text_toggle_thumbnails' ),
556 'toggleOutline' => $this->get_translate( 'text_toggle_outline' ),
557 'previousPage' => $this->get_translate( 'text_previous_page' ),
558 'nextPage' => $this->get_translate( 'text_next_page' ),
559 'toggleFullscreen' => $this->get_translate( 'text_toggle_fullscreen' ),
560 'zoomIn' => $this->get_translate( 'text_zoom_in' ),
561 'zoomOut' => $this->get_translate( 'text_zoom_out' ),
562 'toggleHelp' => $this->get_translate( 'text_toggle_help' ),
563 'singlePageMode' => $this->get_translate( 'text_single_page_mode' ),
564 'doublePageMode' => $this->get_translate( 'text_double_page_mode' ),
565 'downloadPDFFile' => $this->get_translate( 'text_download_PDF_file' ),
566 'gotoFirstPage' => $this->get_translate( 'text_goto_first_page' ),
567 'gotoLastPage' => $this->get_translate( 'text_goto_last_page' ),
568 'share' => $this->get_translate( 'text_share' ),
569 'mailSubject' => $this->get_translate( 'text_mail_subject' ),
570 'mailBody' => $this->get_translate( 'text_mail_body' ),
571 'loading' => $this->get_translate( 'text_loading' )
572 ),
573 'viewerType' => $this->get_config( 'viewerType' ),
574 'moreControls' => $this->get_config( 'more_controls' ),
575 'hideControls' => $this->get_config( 'hide_controls' ),
576 'scrollWheel' => $this->get_config( 'scroll_wheel' ),
577 'backgroundColor' => $this->get_config( 'bg_color' ),
578 'backgroundImage' => $this->get_config( 'bg_image' ),
579 'height' => $this->get_config( 'height' ),
580 'paddingLeft' => $this->get_config( 'padding_left' ),
581 'paddingRight' => $this->get_config( 'padding_right' ),
582 'controlsPosition' => $this->get_config( 'controls_position' ),
583 'duration' => $this->get_config( 'duration' ),
584 'soundEnable' => $this->get_config( 'auto_sound' ),
585 'enableDownload' => $this->get_config( 'enable_download' ),
586 'showSearchControl'=> $this->get_config( 'enable_search' ),
587 'showPrintControl' => $this->get_config( 'enable_print' ),
588 'enableAnnotation' => $this->get_config( 'enable_annotation' ) == "true",
589 'enableAnalytics' => $this->get_config( 'enable_analytics' ),
590 'webgl' => $this->get_config( 'webgl' ),
591 'hard' => $this->get_config( 'hard' ),
592 'maxTextureSize' => $this->get_config( 'texture_size' ),
593 'rangeChunkSize' => $this->get_config( 'range_size' ),
594 'zoomRatio' => $this->get_config( 'zoom_ratio' ),
595 'stiffness' => $this->get_config( 'stiffness' ),
596 'pageMode' => $this->get_config( 'page_mode' ),
597 'singlePageMode' => $this->get_config( 'single_page_mode' ),
598 'pageSize' => $this->get_config( 'page_size' ),
599 'autoPlay' => $this->get_config( 'autoplay' ),
600 'autoPlayDuration' => $this->get_config( 'autoplay_duration' ),
601 'autoPlayStart' => $this->get_config( 'autoplay_start' ),
602 'linkTarget' => $this->get_config( 'link_target' ),
603 'sharePrefix' => $this->get_config( 'share_prefix' )
604 );
605
606 //registers a variable that stores the location of plugin
607 $output = '<script data-cfasync="false"> var dFlipLocation = "' . plugins_url( 'assets/', __FILE__ ) . '"; var dFlipWPGlobal = ' . json_encode( $data ) . ';</script>';
608 echo $output;
609
610 }
611
612 /**
613 * Helper method for retrieving config values.
614 *
615 * @param string $key The config key to retrieve.
616 *
617 * @return string Key value on success, empty string on failure.
618 * @since 1.2.6
619 *
620 */
621 public function get_config( $key ) {
622
623 $values = is_multisite() ? get_blog_option( null, '_dflip_settings', true ) : get_option( '_dflip_settings', true );
624 $value = isset( $values[ $key ] ) ? $values[ $key ] : '';
625
626 $default = $this->get_default( $key );
627
628 /* set standard value */
629 if ( $default !== null ) {
630 $value = $this->filter_std_value( $value, $default );
631 }
632
633 return $value;
634
635 }
636
637 public function get_global_config( $key ) {
638 return $this->get_config( $key );
639 }
640
641
642 /**
643 * Helper method for retrieving global check values.
644 *
645 * @param string $key The config key to retrieve.
646 *
647 * @return string Key value on success, empty string on failure.
648 * @since 1.0.0
649 *
650 */
651 public function global_config( $key ) {//todo name is not proper
652
653 $global_value = $this->get_global_config( $key );
654 $value = isset( $this->defaults[ $key ] ) ? is_array( $this->defaults[ $key ] ) ? isset( $this->defaults[ $key ]['choices'][ $global_value ] )
655 ? $this->defaults[ $key ]['choices'][ $global_value ] : $global_value : $global_value : $global_value;
656
657 return $value;
658
659 }
660
661 public function get_translate( $key ) {
662 if ( $this->external_translate == true ) {
663 return $this->get_default( $key );
664 } else {
665 return $this->get_config( $key );
666 }
667 }
668
669 /**
670 * Helper method for retrieving default values.
671 *
672 * @param string $key The config key to retrieve.
673 *
674 * @return string Key value on success, empty string on failure.
675 * @since 1.0.0
676 *
677 */
678 public function get_default( $key ) {
679
680 $default = isset( $this->defaults[ $key ] ) ? is_array( $this->defaults[ $key ] ) ? isset( $this->defaults[ $key ]['std'] ) ? $this->defaults[ $key ]['std'] : '' : $this->defaults[ $key ] : '';
681
682 return $default;
683
684 }
685
686 /**
687 * Helper function to filter standard option values.
688 *
689 * @param mixed $value Saved string or array value
690 * @param mixed $std Standard string or array value
691 *
692 * @return mixed String or array
693 *
694 * @access public
695 * @since 1.0.0
696 */
697 public function filter_std_value( $value = '', $std = '' ) {
698
699 $std = maybe_unserialize( $std );
700
701 if ( is_array( $value ) && is_array( $std ) ) {
702
703 foreach ( $value as $k => $v ) {
704
705 if ( '' === $value[ $k ] && isset( $std[ $k ] ) ) {
706
707 $value[ $k ] = $std[ $k ];
708
709 }
710
711 }
712
713 } else {
714 if ( '' === $value && $std !== null ) {
715
716 $value = $std;
717
718 }
719 }
720
721 return $value;
722
723 }
724
725
726 /**
727 * Helper function to create settings boxes
728 *
729 * @access public
730 *
731 * @param $key
732 * @param null $setting
733 * @param null $value
734 * @param null $global_key
735 * @param string $global_value
736 *
737 * @since 1.2.6
738 *
739 */
740 public function create_setting( $key, $setting = null, $value = null, $global_key = null, $global_value = '' ) {
741
742 $slug = $this->plugin_slug;
743 $setting = is_null( $setting ) ? $this->defaults[ $key ] : $setting;
744 if ( is_null( $setting ) ) {
745 echo "<!-- " . esc_html( $key ) . " Not found -->";
746
747 return;
748 }
749 $type = isset( $setting['type'] ) ? $setting['type'] : '';
750 $value = is_null( $value ) ? $this->get_global_config( $key ) : $value;
751 $condition = isset( $setting['condition'] ) ? $setting['condition'] : '';
752 $class = isset( $setting['class'] ) ? $setting['class'] : '';
753 $placeholder = isset( $setting['placeholder'] ) ? $setting['placeholder'] : '';
754 $desc = isset( $setting['desc'] ) ? $setting['desc'] : '';
755 $title = isset( $setting['title'] ) ? $setting['title'] : '';
756 if ( $title == 'std' ) {//useful in translate settings
757 $title = $this->get_default( $key );
758 }
759 $global_attr = !is_null( $global_key ) ? $global_key : "";
760 $global_face_value = $global_value;
761
762 echo '<div id="' . $slug . '_' . esc_attr( $key ) . '_box" class="df-box ' . esc_attr( $class ) . '" data-condition="' . esc_attr( $condition ) . '">
763 <div class="df-label"><label for="' . $slug . '_' . esc_attr( $key ) . '" >
764 ' . esc_attr( $title ) . '
765 </label></div>';
766 echo '<div class="df-option">';
767 if ( isset( $setting['choices'] ) && is_array( $setting['choices'] ) ) {
768
769 echo '<div class="df-select">
770 <select name="_' . $slug . '[' . esc_attr( $key ) . ']" id="' . $slug . '_' . esc_attr( $key ) . '" class="" data-global="' . esc_attr( $global_attr ) . '">';
771
772 /** @noinspection PhpCastIsUnnecessaryInspection */
773 foreach ( (array) $setting['choices'] as $val => $label ) {
774
775 if ( is_null( $global_key ) && $val === "global" ) {
776 continue;
777 }
778
779 echo '<option value="' . esc_attr( $val ) . '" ' . selected( $value, $val, false ) . '>' . esc_attr( $label ) . '</option>';
780
781 // }
782 }
783 echo '</select>';
784 $global_face_value = $this->global_config( $key );
785
786 } else if ( $type == 'upload' ) {
787 $tooltip = isset( $setting['button-tooltip'] ) ? $setting['button-tooltip'] : 'Select';
788 $button_text = isset( $setting['button-text'] ) ? $setting['button-text'] : 'Select';
789 echo '<div class="df-upload">
790 <input placeholder="' . esc_attr( $placeholder ) . '" type="text" name="_' . $slug . '[' . esc_attr( $key ) . ']" id="' . $slug . '_' . esc_attr( $key ) . '"
791 value="' . esc_attr( $value ) . '"
792 class="widefat df-upload-input " data-global="' . esc_attr( $global_attr ) . '"/>
793 <a href="javascript:void(0);" id="' . $slug . '_upload_' . esc_attr( $key ) . '"
794 class="df-upload-media df-button button button-primary light"
795 title="' . esc_attr( $tooltip ) . '">
796 ' . esc_attr( $button_text ) . '
797 </a>';
798
799 } else if ( $type == 'textarea' ) {
800 echo '<div class="">
801 <textarea rows="3" cols="40" name="_' . $slug . '[' . esc_attr( $key ) . ']" id="' . $slug . '_' . esc_attr( $key ) . '"
802 class="" data-global="' . esc_attr( $global_attr ) . '">' . esc_attr( $value ) . '</textarea>';
803 } else {
804 $attrHTML = ' ';
805
806 if ( isset( $setting['attr'] ) ) {
807 foreach ( $setting['attr'] as $attr_key => $attr_value ) {
808 $attrHTML .= $attr_key . "=" . $attr_value . " ";
809 }
810 }
811
812 echo '<div class="">
813 <input placeholder="' . esc_attr( $placeholder ) . '" value="' . esc_attr( $value ) . '" type="' . esc_attr( $type ) . '" ' . esc_attr( $attrHTML ) . ' name="_' . $slug . '[' . esc_attr( $key ) . ']" id="' . $slug . '_' . esc_attr( $key ) . '" class="" data-global="' . esc_attr( $global_attr ) . '"/>';
814 }
815
816 if ( !is_null( $global_key ) ) {
817 echo '<div class="df-global-value" data-global-value="' . esc_attr( $global_value ) . '"><i>Default:</i>
818 <code>' . esc_attr( $global_face_value ) . '</code></div>';
819 }
820 echo '</div>
821 <div class="df-desc">
822 ' . $desc . '
823 <a class="df-help-link" target="_blank" href="' . $this->settings_help_page . '#' . esc_attr( strtolower( $key ) ) . '">More Info >> </a>
824 </div></div>
825 </div>';
826
827 }
828
829 public function dflip_lite_check() {
830 if ( is_admin() ) {
831 if ( $this->is_plugin_active( 'dflip/dflip.php' ) ) {
832 add_action( 'admin_notices', array( $this, 'dflip_lite_check_notice' ) );
833 }
834 }
835 }
836
837 public function dflip_lite_check_notice() {
838
839 ?>
840 <div class="update-nag notice">
841 <p>dFlip Lite version is also active. Disable lite version to use dFlip Full Version.</p>
842 </div>
843 <?php
844
845 }
846
847 function is_plugin_active( $plugin ) {
848 return in_array( $plugin, (array) get_option( 'active_plugins', array() ) );
849 }
850
851 public function create_separator( $title = '' ) {
852 echo '<div class="df-box df-box-separator">' . $title . '</div>';
853 }
854
855 /**
856 * Returns the singleton instance of the class.
857 *
858 * @return object DFlip object.
859 * @since 1.0.0
860 *
861 */
862 public static function get_instance() {
863
864 if ( !isset( self::$instance ) && !( self::$instance instanceof DFlip ) ) {
865 self::$instance = new DFlip();
866 }
867
868 return self::$instance;
869
870 }
871
872 }
873
874 //Load the dFlip Plugin Class
875 $dflip = DFlip::get_instance();
876 }
877
878
879
880
881 /*Avoid PHP closing tag to prevent "Headers already sent"*/
882