3d-flipbook-dflip-lite
Last commit date
assets
4 weeks ago
inc
4 weeks ago
3d-flipbook-dflip-lite.php
4 weeks ago
index.php
4 weeks ago
readme.txt
4 weeks ago
3d-flipbook-dflip-lite.php
884 lines
| 1 | <?php |
| 2 | // @formatter:off |
| 3 | /** |
| 4 | * Plugin Name: 3D FlipBook : DearFlip 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.4.30 |
| 8 | * Text Domain: 3d-flipbook-dflip-lite |
| 9 | * Author: DearHive |
| 10 | * Author URI: https://dearflip.com/go/wp-lite-author |
| 11 | * License: GPL2+ |
| 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.4.30'; |
| 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', '3d-flipbook-dflip-lite' ), |
| 432 | 'reader' => __( 'Vertical Reader', '3d-flipbook-dflip-lite' ), |
| 433 | 'flipbook' => __( 'Flipbook', '3d-flipbook-dflip-lite' ), |
| 434 | 'slider' => __( 'Slider', '3d-flipbook-dflip-lite' ) |
| 435 | ), |
| 436 | 'title' => __( 'Viewer Type', '3d-flipbook-dflip-lite' ), |
| 437 | 'desc' => __( 'Choose the Viewer Type. Flipbook or normal viewer', '3d-flipbook-dflip-lite' ) |
| 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( 'dflip-script', plugins_url( 'assets/js/dflip.min.js', __FILE__ ), array( "jquery" ), $this->version, true ); |
| 520 | wp_register_style( 'dflip-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( 'dflip-script' ); |
| 525 | wp_enqueue_style( 'dflip-style' ); |
| 526 | } |
| 527 | |
| 528 | } |
| 529 | |
| 530 | public function add_defer_attribute( $tag, $handle ) { |
| 531 | // add script handles to the array below |
| 532 | $scripts_to_defer = array( 'jquery-core', 'dflip-script', 'dflip-parse-script' ); |
| 533 | |
| 534 | foreach ( $scripts_to_defer as $defer_script ) { |
| 535 | if ( $defer_script === $handle ) { |
| 536 | return str_replace( ' src', ' data-cfasync="false" src', $tag ); |
| 537 | } |
| 538 | } |
| 539 | |
| 540 | return $tag; |
| 541 | } |
| 542 | |
| 543 | /** |
| 544 | * Registers a javascript variable into HTML DOM for url access |
| 545 | * |
| 546 | * @since 1.0.0 |
| 547 | */ |
| 548 | public function hook_script() { |
| 549 | |
| 550 | $data = array( |
| 551 | 'text' => array( |
| 552 | 'toggleSound' => $this->get_translate( 'text_toggle_sound' ), |
| 553 | 'toggleThumbnails' => $this->get_translate( 'text_toggle_thumbnails' ), |
| 554 | 'toggleOutline' => $this->get_translate( 'text_toggle_outline' ), |
| 555 | 'previousPage' => $this->get_translate( 'text_previous_page' ), |
| 556 | 'nextPage' => $this->get_translate( 'text_next_page' ), |
| 557 | 'toggleFullscreen' => $this->get_translate( 'text_toggle_fullscreen' ), |
| 558 | 'zoomIn' => $this->get_translate( 'text_zoom_in' ), |
| 559 | 'zoomOut' => $this->get_translate( 'text_zoom_out' ), |
| 560 | 'toggleHelp' => $this->get_translate( 'text_toggle_help' ), |
| 561 | 'singlePageMode' => $this->get_translate( 'text_single_page_mode' ), |
| 562 | 'doublePageMode' => $this->get_translate( 'text_double_page_mode' ), |
| 563 | 'downloadPDFFile' => $this->get_translate( 'text_download_PDF_file' ), |
| 564 | 'gotoFirstPage' => $this->get_translate( 'text_goto_first_page' ), |
| 565 | 'gotoLastPage' => $this->get_translate( 'text_goto_last_page' ), |
| 566 | 'share' => $this->get_translate( 'text_share' ), |
| 567 | 'mailSubject' => $this->get_translate( 'text_mail_subject' ), |
| 568 | 'mailBody' => $this->get_translate( 'text_mail_body' ), |
| 569 | 'loading' => $this->get_translate( 'text_loading' ) |
| 570 | ), |
| 571 | 'viewerType' => $this->get_config( 'viewerType' ), |
| 572 | 'moreControls' => $this->get_config( 'more_controls' ), |
| 573 | 'hideControls' => $this->get_config( 'hide_controls' ), |
| 574 | 'scrollWheel' => $this->get_config( 'scroll_wheel' ), |
| 575 | 'backgroundColor' => $this->get_config( 'bg_color' ), |
| 576 | 'backgroundImage' => $this->get_config( 'bg_image' ), |
| 577 | 'height' => $this->get_config( 'height' ), |
| 578 | 'paddingLeft' => $this->get_config( 'padding_left' ), |
| 579 | 'paddingRight' => $this->get_config( 'padding_right' ), |
| 580 | 'controlsPosition' => $this->get_config( 'controls_position' ), |
| 581 | 'duration' => $this->get_config( 'duration' ), |
| 582 | 'soundEnable' => $this->get_config( 'auto_sound' ), |
| 583 | 'enableDownload' => $this->get_config( 'enable_download' ), |
| 584 | 'showSearchControl'=> $this->get_config( 'enable_search' ), |
| 585 | 'showPrintControl' => $this->get_config( 'enable_print' ), |
| 586 | 'enableAnnotation' => $this->get_config( 'enable_annotation' ) == "true", |
| 587 | 'enableAnalytics' => $this->get_config( 'enable_analytics' ), |
| 588 | 'webgl' => $this->get_config( 'webgl' ), |
| 589 | 'hard' => $this->get_config( 'hard' ), |
| 590 | 'maxTextureSize' => $this->get_config( 'texture_size' ), |
| 591 | 'rangeChunkSize' => $this->get_config( 'range_size' ), |
| 592 | 'zoomRatio' => $this->get_config( 'zoom_ratio' ), |
| 593 | 'stiffness' => $this->get_config( 'stiffness' ), |
| 594 | 'pageMode' => $this->get_config( 'page_mode' ), |
| 595 | 'singlePageMode' => $this->get_config( 'single_page_mode' ), |
| 596 | 'pageSize' => $this->get_config( 'page_size' ), |
| 597 | 'autoPlay' => $this->get_config( 'autoplay' ), |
| 598 | 'autoPlayDuration' => $this->get_config( 'autoplay_duration' ), |
| 599 | 'autoPlayStart' => $this->get_config( 'autoplay_start' ), |
| 600 | 'linkTarget' => $this->get_config( 'link_target' ), |
| 601 | 'sharePrefix' => $this->get_config( 'share_prefix' ) |
| 602 | ); |
| 603 | |
| 604 | //registers a variable that stores the location of plugin |
| 605 | ?> |
| 606 | <script data-cfasync="false"> |
| 607 | window.dFlipLocation = '<?php echo esc_url(plugins_url( 'assets/', __FILE__ ));?>'; |
| 608 | window.dFlipWPGlobal = <?php echo json_encode( $data );?>; |
| 609 | </script> |
| 610 | <?php |
| 611 | |
| 612 | } |
| 613 | |
| 614 | /** |
| 615 | * Helper method for retrieving config values. |
| 616 | * |
| 617 | * @param string $key The config key to retrieve. |
| 618 | * |
| 619 | * @return string Key value on success, empty string on failure. |
| 620 | * @since 1.2.6 |
| 621 | * |
| 622 | */ |
| 623 | public function get_config( $key ) { |
| 624 | |
| 625 | $values = is_multisite() ? get_blog_option( null, '_dflip_settings', true ) : get_option( '_dflip_settings', true ); |
| 626 | $value = isset( $values[ $key ] ) ? $values[ $key ] : ''; |
| 627 | |
| 628 | $default = $this->get_default( $key ); |
| 629 | |
| 630 | /* set standard value */ |
| 631 | if ( $default !== null ) { |
| 632 | $value = $this->filter_std_value( $value, $default ); |
| 633 | } |
| 634 | |
| 635 | return $value; |
| 636 | |
| 637 | } |
| 638 | |
| 639 | public function get_global_config( $key ) { |
| 640 | return $this->get_config( $key ); |
| 641 | } |
| 642 | |
| 643 | |
| 644 | /** |
| 645 | * Helper method for retrieving global check values. |
| 646 | * |
| 647 | * @param string $key The config key to retrieve. |
| 648 | * |
| 649 | * @return string Key value on success, empty string on failure. |
| 650 | * @since 1.0.0 |
| 651 | * |
| 652 | */ |
| 653 | public function global_config( $key ) {//todo name is not proper |
| 654 | |
| 655 | $global_value = $this->get_global_config( $key ); |
| 656 | $value = isset( $this->defaults[ $key ] ) ? is_array( $this->defaults[ $key ] ) ? isset( $this->defaults[ $key ]['choices'][ $global_value ] ) |
| 657 | ? $this->defaults[ $key ]['choices'][ $global_value ] : $global_value : $global_value : $global_value; |
| 658 | |
| 659 | return $value; |
| 660 | |
| 661 | } |
| 662 | |
| 663 | public function get_translate( $key ) { |
| 664 | if ( $this->external_translate == true ) { |
| 665 | return $this->get_default( $key ); |
| 666 | } else { |
| 667 | return $this->get_config( $key ); |
| 668 | } |
| 669 | } |
| 670 | |
| 671 | /** |
| 672 | * Helper method for retrieving default values. |
| 673 | * |
| 674 | * @param string $key The config key to retrieve. |
| 675 | * |
| 676 | * @return string Key value on success, empty string on failure. |
| 677 | * @since 1.0.0 |
| 678 | * |
| 679 | */ |
| 680 | public function get_default( $key ) { |
| 681 | |
| 682 | $default = isset( $this->defaults[ $key ] ) ? is_array( $this->defaults[ $key ] ) ? isset( $this->defaults[ $key ]['std'] ) ? $this->defaults[ $key ]['std'] : '' : $this->defaults[ $key ] : ''; |
| 683 | |
| 684 | return $default; |
| 685 | |
| 686 | } |
| 687 | |
| 688 | /** |
| 689 | * Helper function to filter standard option values. |
| 690 | * |
| 691 | * @param mixed $value Saved string or array value |
| 692 | * @param mixed $std Standard string or array value |
| 693 | * |
| 694 | * @return mixed String or array |
| 695 | * |
| 696 | * @access public |
| 697 | * @since 1.0.0 |
| 698 | */ |
| 699 | public function filter_std_value( $value = '', $std = '' ) { |
| 700 | |
| 701 | $std = maybe_unserialize( $std ); |
| 702 | |
| 703 | if ( is_array( $value ) && is_array( $std ) ) { |
| 704 | |
| 705 | foreach ( $value as $k => $v ) { |
| 706 | |
| 707 | if ( '' === $value[ $k ] && isset( $std[ $k ] ) ) { |
| 708 | |
| 709 | $value[ $k ] = $std[ $k ]; |
| 710 | |
| 711 | } |
| 712 | |
| 713 | } |
| 714 | |
| 715 | } else { |
| 716 | if ( '' === $value && $std !== null ) { |
| 717 | |
| 718 | $value = $std; |
| 719 | |
| 720 | } |
| 721 | } |
| 722 | |
| 723 | return $value; |
| 724 | |
| 725 | } |
| 726 | |
| 727 | |
| 728 | /** |
| 729 | * Helper function to create settings boxes |
| 730 | * |
| 731 | * @access public |
| 732 | * |
| 733 | * @param $key |
| 734 | * @param null $setting |
| 735 | * @param null $value |
| 736 | * @param null $global_key |
| 737 | * @param string $global_value |
| 738 | * |
| 739 | * @since 1.2.6 |
| 740 | * |
| 741 | */ |
| 742 | public function create_setting( $key, $setting = null, $value = null, $global_key = null, $global_value = '' ) { |
| 743 | |
| 744 | $setting = is_null( $setting ) ? $this->defaults[ $key ] : $setting; |
| 745 | if ( is_null( $setting ) ) { |
| 746 | echo "<!-- " . esc_html( $key ) . " Not found -->"; |
| 747 | |
| 748 | return; |
| 749 | } |
| 750 | $type = isset( $setting['type'] ) ? $setting['type'] : ''; |
| 751 | $value = is_null( $value ) ? $this->get_global_config( $key ) : $value; |
| 752 | $condition = isset( $setting['condition'] ) ? $setting['condition'] : ''; |
| 753 | $class = isset( $setting['class'] ) ? $setting['class'] : ''; |
| 754 | $placeholder = isset( $setting['placeholder'] ) ? $setting['placeholder'] : ''; |
| 755 | $desc = isset( $setting['desc'] ) ? $setting['desc'] : ''; |
| 756 | $title = isset( $setting['title'] ) ? $setting['title'] : ''; |
| 757 | if ( $title == 'std' ) {//useful in translate settings |
| 758 | $title = $this->get_default( $key ); |
| 759 | } |
| 760 | $global_attr = !is_null( $global_key ) ? $global_key : ""; |
| 761 | $global_face_value = $global_value; |
| 762 | |
| 763 | echo '<div id="dflip_' . esc_attr( $key ) . '_box" class="df-box ' . esc_attr( $class ) . '" data-condition="' . esc_attr( $condition ) . '"> |
| 764 | <div class="df-label"><label for="dflip_' . esc_attr( $key ) . '" > |
| 765 | ' . esc_attr( $title ) . ' |
| 766 | </label></div>'; |
| 767 | echo '<div class="df-option">'; |
| 768 | if ( isset( $setting['choices'] ) && is_array( $setting['choices'] ) ) { |
| 769 | |
| 770 | echo '<div class="df-select"> |
| 771 | <select name="_dflip[' . esc_attr( $key ) . ']" id="dflip_' . esc_attr( $key ) . '" class="" data-global="' . esc_attr( $global_attr ) . '">'; |
| 772 | |
| 773 | /** @noinspection PhpCastIsUnnecessaryInspection */ |
| 774 | foreach ( (array) $setting['choices'] as $val => $label ) { |
| 775 | |
| 776 | if ( is_null( $global_key ) && $val === "global" ) { |
| 777 | continue; |
| 778 | } |
| 779 | |
| 780 | echo '<option value="' . esc_attr( $val ) . '" ' . selected( $value, $val, false ) . '>' . esc_attr( $label ) . '</option>'; |
| 781 | |
| 782 | // } |
| 783 | } |
| 784 | echo '</select>'; |
| 785 | $global_face_value = $this->global_config( $key ); |
| 786 | |
| 787 | } else if ( $type == 'upload' ) { |
| 788 | $tooltip = isset( $setting['button-tooltip'] ) ? $setting['button-tooltip'] : 'Select'; |
| 789 | $button_text = isset( $setting['button-text'] ) ? $setting['button-text'] : 'Select'; |
| 790 | echo '<div class="df-upload"> |
| 791 | <input placeholder="' . esc_attr( $placeholder ) . '" type="text" name="_dflip[' . esc_attr( $key ) . ']" id="dflip_' . esc_attr( $key ) . '" |
| 792 | value="' . esc_attr( $value ) . '" |
| 793 | class="widefat df-upload-input " data-global="' . esc_attr( $global_attr ) . '"/> |
| 794 | <a href="javascript:void(0);" id="dflip_upload_' . esc_attr( $key ) . '" |
| 795 | class="df-upload-media df-button button button-primary light" |
| 796 | title="' . esc_attr( $tooltip ) . '"> |
| 797 | ' . esc_attr( $button_text ) . ' |
| 798 | </a>'; |
| 799 | |
| 800 | } else if ( $type == 'textarea' ) { |
| 801 | echo '<div class=""> |
| 802 | <textarea rows="3" cols="40" name="_dflip[' . esc_attr( $key ) . ']" id="dflip_' . esc_attr( $key ) . '" |
| 803 | class="" data-global="' . esc_attr( $global_attr ) . '">' . esc_attr( $value ) . '</textarea>'; |
| 804 | } else { |
| 805 | $attrHTML = ' '; |
| 806 | |
| 807 | if ( isset( $setting['attr'] ) ) { |
| 808 | foreach ( $setting['attr'] as $attr_key => $attr_value ) { |
| 809 | $attrHTML .= $attr_key . "=" . $attr_value . " "; |
| 810 | } |
| 811 | } |
| 812 | |
| 813 | echo '<div class=""> |
| 814 | <input placeholder="' . esc_attr( $placeholder ) . '" value="' . esc_attr( $value ) . '" type="' . esc_attr( $type ) . '" ' . esc_attr( $attrHTML ) . ' name="_dflip[' . esc_attr( $key ) . ']" id="dflip_' . esc_attr( $key ) . '" class="" data-global="' . esc_attr( $global_attr ) . '"/>'; |
| 815 | } |
| 816 | |
| 817 | if ( !is_null( $global_key ) ) { |
| 818 | echo '<div class="df-global-value" data-global-value="' . esc_attr( $global_value ) . '"><i>Default:</i> |
| 819 | <code>' . esc_attr( $global_face_value ) . '</code></div>'; |
| 820 | } |
| 821 | echo '</div> |
| 822 | <div class="df-desc"> |
| 823 | ' . wp_kses_post($desc) . ' |
| 824 | <a class="df-help-link" target="_blank" href="' . esc_url($this->settings_help_page) . '#' . esc_attr( strtolower( $key ) ) . '">More Info >> </a> |
| 825 | </div></div> |
| 826 | </div>'; |
| 827 | |
| 828 | } |
| 829 | |
| 830 | |
| 831 | public function dflip_lite_check() { |
| 832 | if ( is_admin() ) { |
| 833 | if ( $this->is_plugin_active( 'dflip/dflip.php' ) ) { |
| 834 | add_action( 'admin_notices', array( $this, 'dflip_lite_check_notice' ) ); |
| 835 | } |
| 836 | } |
| 837 | } |
| 838 | |
| 839 | public function dflip_lite_check_notice() { |
| 840 | |
| 841 | ?> |
| 842 | <div class="update-nag notice"> |
| 843 | <p>dFlip Lite version is also active. Disable lite version to use dFlip Full Version.</p> |
| 844 | </div> |
| 845 | <?php |
| 846 | |
| 847 | } |
| 848 | |
| 849 | function is_plugin_active( $plugin ) { |
| 850 | return in_array( $plugin, (array) get_option( 'active_plugins', array() ) ); |
| 851 | } |
| 852 | |
| 853 | public function create_separator( $title = '' ) { |
| 854 | echo '<div class="df-box df-box-separator">' . esc_html($title) . '</div>'; |
| 855 | } |
| 856 | |
| 857 | /** |
| 858 | * Returns the singleton instance of the class. |
| 859 | * |
| 860 | * @return object DFlip object. |
| 861 | * @since 1.0.0 |
| 862 | * |
| 863 | */ |
| 864 | public static function get_instance() { |
| 865 | |
| 866 | if ( !isset( self::$instance ) && !( self::$instance instanceof DFlip ) ) { |
| 867 | self::$instance = new DFlip(); |
| 868 | } |
| 869 | |
| 870 | return self::$instance; |
| 871 | |
| 872 | } |
| 873 | |
| 874 | } |
| 875 | |
| 876 | //Load the dFlip Plugin Class |
| 877 | $dflip = DFlip::get_instance(); |
| 878 | } |
| 879 | |
| 880 | |
| 881 | |
| 882 | |
| 883 | /*Avoid PHP closing tag to prevent "Headers already sent"*/ |
| 884 |