PluginProbe ʕ •ᴥ•ʔ
Widget Options – Advanced Conditional Visibility for Gutenberg Blocks & Classic Widgets / 3.7.13
Widget Options – Advanced Conditional Visibility for Gutenberg Blocks & Classic Widgets v3.7.13
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 / widgets / option-tabs / settings.php
widget-options / includes / widgets / option-tabs Last commit date
alignment.php 4 years ago devices.php 4 years ago settings.php 4 years ago state.php 4 years ago upsell.php 4 years ago visibility.php 4 years ago
settings.php
194 lines
1 <?php
2 /**
3 * Settings Widget Options
4 *
5 * @copyright Copyright (c) 2015, Jeffrey Carandang
6 * @since 1.0
7 */
8
9 // Exit if accessed directly
10 if ( ! defined( 'ABSPATH' ) ) exit;
11
12 /**
13 * Add Settings Widget Options Tab
14 *
15 * @since 1.0
16 * @return void
17 */
18
19 /**
20 * Called on 'extended_widget_opts_tabs'
21 * create new tab navigation for alignment options
22 */
23 if( !function_exists( 'widgetopts_tab_settings' ) ):
24 function widgetopts_tab_settings( $args ){ ?>
25 <li class="extended-widget-opts-tab-class">
26 <a href="#extended-widget-opts-tab-<?php echo $args['id'];?>-class" title="<?php _e( 'Class,ID & Logic', 'widget-options' );?>" ><span class="dashicons dashicons-admin-generic"></span> <span class="tabtitle"><?php _e( 'Other Settings', 'widget-options' );?></span></a>
27 </li>
28 <?php
29 }
30 add_action( 'extended_widget_opts_tabs', 'widgetopts_tab_settings' );
31 endif;
32
33 /**
34 * Called on 'extended_widget_opts_tabcontent'
35 * create new tab content options for alignment options
36 */
37 if( !function_exists( 'widgetopts_tabcontent_settings' ) ):
38 function widgetopts_tabcontent_settings( $args ){
39 global $widget_options;
40
41 $id = '';
42 $classes = '';
43 $logic = '';
44 $selected = 0;
45 $check = '';
46 if( isset( $args['params'] ) && isset( $args['params']['class'] ) ){
47 if( isset( $args['params']['class']['id'] ) ){
48 $id = $args['params']['class']['id'];
49 }
50 if( isset( $args['params']['class']['classes'] ) ){
51 $classes = $args['params']['class']['classes'];
52 }
53 if( isset( $args['params']['class']['selected'] ) ){
54 $selected = $args['params']['class']['selected'];
55 }
56 if( isset( $args['params']['class']['logic'] ) ){
57 $logic = $args['params']['class']['logic'];
58 }
59 if( isset( $args['params']['class']['title'] ) && $args['params']['class']['title'] == '1' ){
60 $check = 'checked="checked"';
61 }
62 }
63
64 $predefined = array();
65 if( isset( $widget_options['settings']['classes'] ) && isset( $widget_options['settings']['classes']['classlists'] ) && !empty( $widget_options['settings']['classes']['classlists'] ) ){
66 $predefined = $widget_options['settings']['classes']['classlists'];
67 }
68 ?>
69 <div id="extended-widget-opts-tab-<?php echo $args['id'];?>-class" class="extended-widget-opts-tabcontent extended-widget-opts-inside-tabcontent extended-widget-opts-tabcontent-class">
70
71 <div class="extended-widget-opts-settings-tabs extended-widget-opts-inside-tabs">
72 <input type="hidden" id="extended-widget-opts-settings-selectedtab" value="<?php echo $selected;?>" name="<?php echo $args['namespace'];?>[extended_widget_opts][class][selected]" />
73 <!-- start tab nav -->
74 <ul class="extended-widget-opts-settings-tabnav-ul">
75 <?php if( 'activate' == $widget_options['hide_title'] ){ ?>
76 <li class="extended-widget-opts-settings-tab-title">
77 <a href="#extended-widget-opts-settings-tab-<?php echo $args['id'];?>-title" title="<?php _e( 'Misc', 'widget-options' );?>" ><?php _e( 'Misc', 'widget-options' );?></a>
78 </li>
79 <?php } ?>
80
81 <?php if( 'activate' == $widget_options['classes'] ){ ?>
82 <li class="extended-widget-opts-settings-tab-class">
83 <a href="#extended-widget-opts-settings-tab-<?php echo $args['id'];?>-class" title="<?php _e( 'Class & ID', 'widget-options' );?>" ><?php _e( 'Class & ID', 'widget-options' );?></a>
84 </li>
85 <?php } ?>
86
87 <?php if( 'activate' == $widget_options['logic'] ){ ?>
88 <li class="extended-widget-opts-settings-tab-logic">
89 <a href="#extended-widget-opts-settings-tab-<?php echo $args['id'];?>-logic" title="<?php _e( 'Display Logic', 'widget-options' );?>" ><?php _e( 'Logic', 'widget-options' );?></a>
90 </li>
91 <?php } ?>
92 <div class="extended-widget-opts-clearfix"></div>
93 </ul><!-- end tab nav -->
94 <div class="extended-widget-opts-clearfix"></div>
95
96 <?php if( 'activate' == $widget_options['hide_title'] ){ ?>
97 <!-- start title tab content -->
98 <div id="extended-widget-opts-settings-tab-<?php echo $args['id'];?>-title" class="extended-widget-opts-settings-tabcontent extended-widget-opts-inner-tabcontent">
99 <div class="widget-opts-title">
100 <?php if( 'activate' == $widget_options['hide_title'] ){ ?>
101 <p class="widgetopts-subtitle"><?php _e( 'Hide Widget Title', 'widget-options' );?></p>
102 <p>
103 <input type="checkbox" name="<?php echo $args['namespace'];?>[extended_widget_opts][class][title]" id="opts-class-title-<?php echo $args['id'];?>" value="1" <?php echo $check;?> />
104 <label for="opts-class-title-<?php echo $args['id'];?>"><?php _e( 'Check to hide widget title', 'widget-options' );?></label>
105 </p>
106 <?php } ?>
107 </div>
108 </div><!-- end title tab content -->
109 <?php } ?>
110
111 <?php if( 'activate' == $widget_options['classes'] ){ ?>
112 <!-- start class tab content -->
113 <div id="extended-widget-opts-settings-tab-<?php echo $args['id'];?>-class" class="extended-widget-opts-settings-tabcontent extended-widget-opts-inner-tabcontent">
114 <div class="widget-opts-class">
115 <table class="form-table">
116 <tbody>
117 <?php if( isset( $widget_options['settings']['classes'] ) && ( isset( $widget_options['settings']['classes']['id'] ) && '1' == $widget_options['settings']['classes']['id'] ) ){?>
118 <tr valign="top" class="widgetopts_id_fld">
119 <td scope="row">
120 <strong><?php _e( 'Widget CSS ID:', 'widget-options' );?></strong><br />
121 <input type="text" id="opts-class-id-<?php echo $args['id'];?>" class="widefat" name="<?php echo $args['namespace'];?>[extended_widget_opts][class][id]" value="<?php echo $id;?>" />
122 </td>
123 </tr>
124 <?php } ?>
125
126 <?php if( !isset( $widget_options['settings']['classes'] ) ||
127 ( isset( $widget_options['settings']['classes'] ) && isset( $widget_options['settings']['classes']['type'] ) && !in_array( $widget_options['settings']['classes']['type'] , array( 'hide', 'predefined' ) ) ) ){?>
128 <tr valign="top">
129 <td scope="row">
130 <strong><?php _e( 'Widget CSS Classes:', 'widget-options' );?></strong><br />
131 <input type="text" id="opts-class-classes-<?php echo $args['id'];?>" class="widefat" name="<?php echo $args['namespace'];?>[extended_widget_opts][class][classes]" value="<?php echo $classes;?>" />
132 <small><em><?php _e( 'Separate each class with space.', 'widget-options' );?></em></small>
133 </td>
134 </tr>
135 <?php } ?>
136 <?php if( !isset( $widget_options['settings']['classes'] ) ||
137 ( isset( $widget_options['settings']['classes'] ) && isset( $widget_options['settings']['classes']['type'] ) && !in_array( $widget_options['settings']['classes']['type'] , array( 'hide', 'text' ) ) ) ){?>
138 <?php if( is_array( $predefined ) && !empty( $predefined ) ){
139 $predefined = array_unique( $predefined ); //remove dups
140 ?>
141 <tr valign="top">
142 <td scope="row">
143 <strong><?php _e( 'Available Widget Classes:', 'widget-options' );?></strong><br />
144 <div class="extended-widget-opts-class-lists" style="max-height: 230px;padding: 5px;overflow:auto;">
145 <?php foreach ($predefined as $key => $value) {
146 if( isset( $args['params']['class']['predefined'] ) &&
147 is_array( $args['params']['class']['predefined'] ) &&
148 in_array( $value , $args['params']['class']['predefined'] ) ){
149 $checked = 'checked="checked"';
150 }else{
151 $checked = '';
152 }
153 ?>
154 <p>
155 <input type="checkbox" name="<?php echo $args['namespace'];?>[extended_widget_opts][class][predefined][]" id="<?php echo $args['id'];?>-opts-class-<?php echo $key;?>" value="<?php echo $value;?>" <?php echo $checked;?> />
156 <label for="<?php echo $args['id'];?>-opts-class-<?php echo $key;?>"><?php echo $value;?></label>
157 </p>
158 <?php } ?>
159 </div>
160 </td>
161 </tr>
162 <?php } ?>
163 <?php } ?>
164 </tbody>
165 </table>
166 </div>
167 </div><!-- end class tab content -->
168 <?php } ?>
169
170 <?php if( 'activate' == $widget_options['logic'] ){ ?>
171 <!-- start logic tab content -->
172 <div id="extended-widget-opts-settings-tab-<?php echo $args['id'];?>-logic" class="extended-widget-opts-settings-tabcontent extended-widget-opts-inner-tabcontent">
173 <div class="widget-opts-logic">
174 <p><small><?php _e( 'The text field lets you use <a href="http://codex.wordpress.org/Conditional_Tags" target="_blank">WP Conditional Tags</a>, or any general PHP code.', 'widget-options' );?></small></p>
175 <textarea class="widefat" name="<?php echo $args['namespace'];?>[extended_widget_opts][class][logic]"><?php echo stripslashes( $logic );?></textarea>
176
177 <?php if( !isset( $widget_options['settings']['logic'] ) ||
178 ( isset( $widget_options['settings']['logic'] ) && !isset( $widget_options['settings']['logic']['notice'] ) ) ){ ?>
179 <p><a href="#" class="widget-opts-toggler-note"><?php _e( 'Click to Toggle Note', 'widget-options' );?></a></p>
180 <p class="widget-opts-toggle-note"><small><?php _e( 'PLEASE NOTE that the display logic you introduce is EVAL\'d directly. Anyone who has access to edit widget appearance will have the right to add any code, including malicious and possibly destructive functions. There is an optional filter <em>"widget_options_logic_override"</em> which you can use to bypass the EVAL with your own code if needed.', 'widget-options' );?></small></p>
181 <?php } ?>
182 </div>
183 </div><!-- end logiv tab content -->
184 <?php } ?>
185
186 </div><!-- end .extended-widget-opts-settings-tabs -->
187
188
189 </div>
190 <?php
191 }
192 add_action( 'extended_widget_opts_tabcontent', 'widgetopts_tabcontent_settings');
193 endif; ?>
194