PluginProbe ʕ •ᴥ•ʔ
DearFlip – PDF Flipbook, 3D Flipbook, PDF embed, PDF viewer / 2.3.54
DearFlip – PDF Flipbook, 3D Flipbook, PDF embed, PDF viewer v2.3.54
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 / inc / settings.php
3d-flipbook-dflip-lite / inc Last commit date
index.php 1 year ago metaboxes.php 1 year ago post-type.php 1 year ago settings.php 1 year ago shortcode.php 1 year ago
settings.php
372 lines
1 <?php
2
3 /**
4 * Author : DeipGroup
5 * Date: 8/11/2016
6 * Time: 4:15 PM
7 *
8 * @package dflip
9 *
10 * @since dflip 1.2
11 */
12 class DFlip_Settings {
13
14 /**
15 * Holds the singleton class object.
16 *
17 * @since 1.2.0
18 *
19 * @var object
20 */
21 public static $instance;
22
23 public $hook;
24
25 /**
26 * Holds the base DFlip class object.
27 *
28 * @since 1.2.0
29 *
30 * @var object
31 */
32 public $base;
33
34 /**
35 * Holds the base DFlip class fields.
36 *
37 * @since 1.2.0
38 *
39 * @var object
40 */
41 public $fields;
42
43 /**
44 * Primary class constructor.
45 *
46 * @since 1.2.0
47 */
48 public function __construct() {
49
50 // Load the base class object.
51 $this->base = DFlip::get_instance();
52
53 add_action( 'admin_menu', array( $this, 'settings_menu' ) );
54
55 $this->fields = array_merge( array(), $this->base->defaults );
56
57 foreach ( $this->fields as $key => $value ) {
58
59 if ( isset( $value['choices'] ) && is_array( $value['choices'] ) && isset( $value['choices']['global'] ) ) {
60 unset( $this->fields[ $key ]['choices']['global'] );
61 }
62
63 }
64
65 // Load the metabox hooks and filters.
66 // add_action('add_meta_boxes', array($this, 'add_meta_boxes'), 100);
67
68 // Add action to save metabox config options.
69 // add_action('save_post', array($this, 'save_meta_boxes'), 10, 2);
70 }
71
72 /**
73 * Creates menu for the settings page
74 *
75 * @since 1.2
76 */
77 public function settings_menu() {
78 global $submenu;
79
80 $this->hook = add_submenu_page( 'edit.php?post_type=dflip', __( 'dFlip Global Settings', '3d-flipbook-dflip-lite' ), __( 'Global Settings', '3d-flipbook-dflip-lite' ), 'manage_options', $this->base->plugin_slug . '-settings',
81 array( $this, 'settings_page' ) );
82
83 //The resulting page's hook_suffix, or false if the user does not have the capability required.
84 if ( $this->hook ) {
85 add_action( 'load-' . $this->hook, array( $this, 'update_settings' ) );
86 }
87
88 $submenu['edit.php?post_type=dflip'][] = array('Upgrade DearFlip', 'manage_options', 'https://dearflip.com/go/wp-lite-upgrade-menu');
89
90 }
91
92 /**
93 * Callback to create the settings page
94 *
95 * @since 1.2
96 */
97 public function settings_page() {
98
99 $tabs = array(
100 'general' => __( 'General', '3d-flipbook-dflip-lite' ),
101 'advanced' => __( 'Advanced', '3d-flipbook-dflip-lite' )
102
103 );
104
105 //create tabs and content
106 ?>
107
108 <h2><?php echo esc_html( get_admin_page_title() ); ?></h2>
109 <form id="dflip-settings" method="post" class="dflip-settings postbox">
110
111 <?php
112 wp_nonce_field( 'dflip_settings_nonce', 'dflip_settings_nonce' );
113 submit_button( __( 'Update Settings', '3d-flipbook-dflip-lite' ), 'primary', 'dflip_settings_submit', false );
114 ?>
115
116 <div class="dflip-tabs">
117 <ul class="dflip-tabs-list">
118 <?php
119 //create tabs
120 $active_set = false;
121 foreach ( (array) $tabs as $id => $title ) {
122 ?>
123 <li class="dflip-update-hash dflip-tab <?php echo( $active_set == false ? 'dflip-active' : '' ) ?>">
124 <a href="#dflip-tab-content-<?php echo $id ?>"><?php echo $title ?></a></li>
125 <?php $active_set = true;
126 }
127 ?>
128 </ul>
129 <?php
130
131 $active_set = false;
132 foreach ( (array) $tabs as $id => $title ) {
133 ?>
134 <div id="dflip-tab-content-<?php echo $id ?>"
135 class="dflip-tab-content <?php echo( $active_set == false ? "dflip-active" : "" ) ?>">
136
137 <?php
138 $active_set = true;
139
140 //create content for tab
141 $function = $id . "_tab";
142 if ( method_exists( $this, $function ) ) {
143 call_user_func( array( $this, $function ) );
144 };
145
146 ?>
147 </div>
148 <?php } ?>
149 </div>
150 </form>
151 <?php
152
153 }
154
155 /**
156 * Creates the UI for General tab
157 *
158 * @since 1.0.0
159 *
160 */
161 public function general_tab() {
162 $this->base->create_setting( 'viewerType' );
163
164 ?>
165
166 <!--Clear-fix-->
167 <div class="dflip-box"></div>
168
169 <?php
170 }
171
172 public function layout_tab() {
173
174
175 ?>
176
177 <!--Clear-fix-->
178 <div class="dflip-box"></div>
179
180 <?php
181 }
182
183 public function post_tab() {
184
185 ?>
186
187 <!--Clear-fix-->
188 <div class="dflip-box"></div>
189
190 <?php
191 }
192
193
194 public function flipbook_tab() {
195
196
197 ?>
198
199 <!--Clear-fix-->
200 <div class="dflip-box"></div>
201
202 <?php
203 }
204
205
206 /**
207 * Creates the UI for Popup tab
208 *
209 * @since 2.1.23
210 *
211 */
212 public function popup_tab() {
213
214
215 ?>
216
217 <!--Clear-fix-->
218 <div class="dflip-box"></div>
219
220 <?php
221 }
222
223
224 /**
225 * Creates the UI for Controls tab
226 *
227 * @since 2.1.40
228 *
229 */
230 public function controls_tab() {
231
232
233 ?>
234
235 <!--Clear-fix-->
236 <div class="dflip-box"></div>
237
238 <?php
239 }
240
241 /**
242 * Creates the UI for Advanced tab
243 *
244 * @since 2.1.23
245 *
246 */
247 public function advanced_tab() {
248
249 $this->base->create_setting( 'selectiveScriptLoading' );
250
251
252 ?>
253
254 <!--Clear-fix-->
255 <div class="dflip-box"></div>
256
257 <?php
258 }
259
260 /**
261 * Creates the UI for PDF tab
262 *
263 * @since 2.1.23
264 *
265 */
266 public function pdf_tab() {
267
268
269 ?>
270
271 <!--Clear-fix-->
272 <div class="dflip-box"></div>
273
274 <?php
275 }
276
277 /**
278 * Creates the UI for Translate tab
279 *
280 * @since 1.0.0
281 *
282 */
283 public function translate_tab() {
284
285
286 ?>
287
288 <!--Clear-fix-->
289 <div class="dflip-box"></div>
290 <?php
291
292 }
293
294 /**
295 * Update settings
296 *
297 * @return null Invalid nonce / no need to save
298 * @since 1.2.0.1
299 *
300 */
301 public function update_settings() {
302
303 // Check form was submitted
304 if ( !isset( $_POST['dflip_settings_submit'] ) ) {
305 return;
306 }
307
308 // Check nonce is valid
309 if ( !wp_verify_nonce( $_POST['dflip_settings_nonce'], 'dflip_settings_nonce' ) ) {
310 return;
311 }
312
313 // Sanitize all user inputs.
314
315 $sanitized_data = array();
316 $sanitized_data['viewerType'] = sanitize_text_field( $_POST['_dflip']['viewerType'] );
317 $sanitized_data['selectiveScriptLoading'] = sanitize_text_field( $_POST['_dflip']['selectiveScriptLoading'] );
318
319 $settings = is_multisite() ? get_blog_option( null, '_dflip_settings', array() ) : get_option( '_dflip_settings', array() );
320 if ( empty( $settings ) || !is_array($settings)) {
321 $settings = array();
322 }
323 $settings = array_merge( $settings, $sanitized_data );
324
325 if ( is_multisite() ) {
326 // Update options
327 update_blog_option( null, '_dflip_settings', $settings );
328 } else {
329 // Update options
330 update_option( '_dflip_settings', $settings );
331 }
332 // Show confirmation
333 add_action( 'admin_notices', array( $this, 'updated_settings' ) );
334
335 }
336
337 /**
338 * display a saved notice
339 *
340 * @since 1.2.0.1
341 */
342 public function updated_settings() {
343 ?>
344 <div class="updated">
345 <p><?php _e( 'Settings updated.', '3d-flipbook-dflip-lite' ); ?></p>
346 </div>
347 <?php
348
349 }
350
351 /**
352 * Returns the singleton instance of the class.
353 *
354 * @return object DFlip_Settings object.
355 * @since 1.2.0
356 *
357 */
358 public static function get_instance() {
359
360 if ( !isset( self::$instance )
361 && !( self::$instance instanceof DFlip_Settings ) ) {
362 self::$instance = new DFlip_Settings();
363 }
364
365 return self::$instance;
366
367 }
368 }
369
370 // Load the DFlip_Settings class.
371 $dflip_settings = DFlip_Settings::get_instance();
372