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