PluginProbe ʕ •ᴥ•ʔ
Widget Options – Advanced Conditional Visibility for Gutenberg Blocks & Classic Widgets / trunk
Widget Options – Advanced Conditional Visibility for Gutenberg Blocks & Classic Widgets vtrunk
4.2.5 4.2.4 trunk 3.7.10 3.7.11 3.7.12 3.7.13 3.7.14 3.7.2 3.7.5 3.7.6 3.7.7 3.7.8 3.7.9 3.8 3.8.1 3.8.10 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.8.8 3.8.9 3.8.9.1 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.5.1 4.0.6 4.0.6.1 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.2 4.1.3 4.2.0 4.2.1 4.2.2 4.2.3
widget-options / includes / admin / settings / register-settings.php
widget-options / includes / admin / settings Last commit date
modules 3 months ago display-settings.php 2 years ago migration-page.php 3 months ago register-settings.php 2 years ago
register-settings.php
187 lines
1 <?php
2
3 /**
4 * Register Settings
5 * @since 4.1
6 */
7
8 // Exit if accessed directly
9 if (!defined('ABSPATH')) exit;
10
11 /**
12 * Get an option
13 *
14 * Looks to see if the specified setting exists, returns default if not
15 *
16 * @since 4.1
17 * @global $widget_options Array of all the Widget Options
18 * @return mixed
19 */
20 if (!function_exists('widgetopts_get_option')) :
21 function widgetopts_get_option($key = '', $default = false)
22 {
23 global $widget_options;
24
25 $value = !empty($widget_options[$key]) ? $widget_options[$key] : $default;
26 $value = apply_filters('widgetopts_get_option', $value, $key, $default);
27
28 return apply_filters('widgetopts_get_option_' . $key, $value, $key, $default);
29 }
30 endif;
31
32 /**
33 * Update an option
34 *
35 * Updates an widgetopts setting value in both the db and the global variable.
36 * Warning: Passing in an empty, false or null string value will remove
37 * the key from the widget_options array.
38 *
39 * @since 4.1
40 * @param string $key The Key to update
41 * @param string|bool|int $value The value to set the key to
42 * @global $widget_options Array of all the Widget Options
43 * @return boolean True if updated, false if not.
44 */
45 if (!function_exists('widgetopts_update_option')) :
46 function widgetopts_update_option($key = '', $value = false)
47 {
48
49 // If no key, exit
50 if (empty($key)) {
51 return false;
52 }
53
54 if (empty($value)) {
55 $remove_option = widgetopts_delete_option($key);
56 return $remove_option;
57 }
58
59 // First let's grab the current settings
60 $options = get_option('widgetopts_settings');
61
62 // Let's let devs alter that value coming in
63 $value = apply_filters('widgetopts_update_option', $value, $key);
64
65 // Next let's try to update the value
66 $options[$key] = $value;
67
68 $did_update = update_option('widgetopts_settings', $options);
69 // If it updated, let's update the global variable
70 if ($did_update) {
71 global $widget_options;
72 $widget_options[$key] = $value;
73 }
74 return $did_update;
75 }
76 endif;
77
78 /**
79 * Remove an option
80 *
81 * Removes widget options setting value in both the db and the global variable.
82 *
83 * @since 4.1
84 * @param string $key The Key to delete
85 * @global $widget_options Array of all the Widget Options
86 * @return boolean True if removed, false if not.
87 */
88 if (!function_exists('widgetopts_delete_option')) :
89 function widgetopts_delete_option($key = '')
90 {
91 // If no key, exit
92 if (empty($key)) {
93 return false;
94 }
95 // First let's grab the current settings
96 $options = get_option('widgetopts_settings');
97
98 // Next let's try to update the value
99 if (isset($options[$key])) {
100 unset($options[$key]);
101 }
102 $did_update = update_option('widgetopts_settings', $options);
103
104 // If it updated, let's update the global variable
105 if ($did_update) {
106 global $edd_options;
107 $edd_options = $options;
108 }
109 return $did_update;
110 }
111 endif;
112
113 /**
114 * Get Settings
115 *
116 * Retrieves all plugin settings
117 *
118 * @since 4.1
119 * @return array WIDGETOPTS settings
120 */
121 if (!function_exists('widgetopts_get_settings')) :
122 function widgetopts_get_settings()
123 {
124 if (is_multisite()) {
125 $settings = get_blog_option(get_current_blog_id(), 'widgetopts_settings');
126 } else {
127 $settings = get_option('widgetopts_settings');
128 }
129
130 if (empty($settings)) {
131
132 $opts_settings = get_option('widgetopts_tabmodule-settings');
133 //fallback to prevent error
134 if (is_serialized($opts_settings)) {
135 $opts_settings = maybe_unserialize($opts_settings);
136 }
137
138 // Update old settings with new single option
139 $settings = !empty($opts_settings) ? $opts_settings : array();
140 $visibility = array('visibility' => get_option('widgetopts_tabmodule-visibility'));
141 $devices = array('devices' => get_option('widgetopts_tabmodule-devices'));
142 $alignment = array('alignment' => get_option('widgetopts_tabmodule-alignment'));
143 $hide_title = array('hide_title' => get_option('widgetopts_tabmodule-hide_title'));
144 $classes = array('classes' => get_option('widgetopts_tabmodule-classes'));
145 $logic = array('logic' => get_option('widgetopts_tabmodule-logic'));
146 $siteorigin = array('siteorigin' => get_option('widgetopts_tabmodule-siteorigin'));
147 $search = array('search' => get_option('widgetopts_tabmodule-search'));
148 $move = array('move' => get_option('widgetopts_tabmodule-move'));
149 $elementor = array('elementor' => get_option('widgetopts_tabmodule-elementor'));
150 $widget_area = array('widget_area' => get_option('widgetopts_tabmodule-widget_area'));
151 $import_export = array('import_export' => get_option('widgetopts_tabmodule-import_export'));
152 $beaver = array('beaver' => get_option('widgetopts_tabmodule-beaver'));
153 $acf = array('acf' => get_option('widgetopts_tabmodule-acf'));
154 $state = array('state' => get_option('widgetopts_tabmodule-state'));
155 $classic_widgets_screen = array('state' => get_option('widgetopts_tabmodule-classic_widgets_screen'));
156 $page_and_post_block = array('hide_page_and_post_block' => get_option('widgetopts_tabmodule-hide_page_and_post_block'));
157 /*
158 * Available only on Extended version
159 */
160 // $columns = array( 'columns' => get_option( 'widgetopts_tabmodule-columns' ) );
161 // $dates = array( 'dates' => get_option( 'widgetopts_tabmodule-dates' ) );
162 // $styling = array( 'styling' => get_option( 'widgetopts_tabmodule-styling' ) );
163 // $roles = array( 'roles' => get_option( 'widgetopts_tabmodule-roles' ) );
164 // $links = array( 'links' => get_option( 'widgetopts_tabmodule-links' ) );
165 // $fixed = array( 'fixed' => get_option( 'widgetopts_tabmodule-fixed' ) );
166 // $taxonomies = array( 'taxonomies' => get_option( 'widgetopts_tabmodule-taxonomies' ) );
167 // $animation = array( 'animation' => get_option( 'widgetopts_tabmodule-animation' ) );
168 // $shortcodes = array( 'shortcodes' => get_option( 'widgetopts_tabmodule-shortcodes' ) );
169 // $cache = array( 'cache' => get_option( 'widgetopts_tabmodule-cache' ) );
170 // $disable_widgets = array( 'disable_widgets' => get_option( 'widgetopts_tabmodule-disable_widgets' ) );
171 // $permission = array( 'permission' => get_option( 'widgetopts_tabmodule-permission' ) );
172
173 $settings = array_merge(array('settings' => $settings), $visibility, $devices, $alignment, $hide_title, $classes, $logic, $siteorigin, $search, $move, $elementor, $widget_area, $import_export, $beaver, $acf, $state, $classic_widgets_screen, $page_and_post_block);
174
175 // Let's let devs alter that value coming in
176 $value = apply_filters('widgetopts_update_settings', $settings);
177
178 update_option('widgetopts_settings', $settings);
179 }
180
181 $default = array('settings' => array(), 'visibility' => '', 'devices' => '', 'alignment' => '', 'columns' => '', 'dates' => '', 'styling' => '', 'roles' => '', 'hide_title' => '', 'classes' => '', 'logic' => '', 'links' => '', 'fixed' => '', 'taxonomies' => '', 'animation' => '', 'shortcodes' => '', 'cache' => '', 'siteorigin' => '', 'search' => '', 'disable_widgets' => '', 'permission' => '', 'move' => '', 'clone' => '', 'elementor' => '', 'widget_area' => '', 'import_export' => '', 'urls' => '', 'beaver' => '', 'acf' => '', 'state' => '', 'sliding' => '', 'classic_widgets_screen' => 'activate', 'hide_page_and_post_block' => 'activate');
182 $settings = shortcode_atts($default, $settings);
183
184 return apply_filters('widgetopts_get_settings', $settings);
185 }
186 endif;
187