-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathclass.wp-wiki-tooltip-base.php
82 lines (67 loc) · 2.53 KB
/
class.wp-wiki-tooltip-base.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/**
* Class WP_Wiki_Tooltip_Base
*/
class WP_Wiki_Tooltip_Base {
protected $version = '2.0.2';
protected $tooltipster_version = '4.2.8';
protected $options_base = false;
protected $options_error = false;
protected $options_design = false;
protected $options_thumb = false;
protected function load_single_option( $default_key, $old_options, $new_options, $default_options, $keys ) {
if( false == $new_options ) {
if( false != $old_options ) {
foreach( $keys as $key ) {
if( isset( $old_options[ $key ] ) ) {
$new_options[ $key ] = $old_options[ $key ];
}
}
} else {
$new_options = $default_options[ $default_key ];
}
}
return $new_options;
}
public function load_all_options() {
global $wp_wiki_tooltip_default_options;
$old_options = get_option( 'wp-wiki-tooltip-settings' );
$this->options_base = $this->load_single_option(
'base',
$old_options,
get_option( 'wp-wiki-tooltip-settings-base' ),
$wp_wiki_tooltip_default_options,
array( 'wiki-urls', 'a-target', 'trigger', 'trigger-hover-action', 'min-screen-width' )
);
$this->options_error = $this->load_single_option(
'error',
$old_options,
get_option( 'wp-wiki-tooltip-settings-error' ),
$wp_wiki_tooltip_default_options,
array( 'page-error-handling', 'own-error-title', 'own-error-message', 'section-error-handling' )
);
$this->options_design = $this->load_single_option(
'design',
$old_options,
get_option( 'wp-wiki-tooltip-settings-design' ),
$wp_wiki_tooltip_default_options,
array( 'theme', 'animation', 'tooltip-head', 'tooltip-body', 'tooltip-foot', 'a-style' )
);
$this->options_thumb = $this->load_single_option(
'thumb',
$old_options,
get_option( 'wp-wiki-tooltip-settings-thumb' ),
$wp_wiki_tooltip_default_options,
array( 'thumb-enable', 'thumb-align', 'thumb-width', 'thumb-style' )
);
}
public static function log( $msg = '' ) {
if ( true === WP_DEBUG ) {
if ( is_array( $msg ) || is_object( $msg ) ) {
error_log( print_r( $msg, true ) );
} else {
error_log( $msg );
}
}
}
}