PluginProbe ʕ •ᴥ•ʔ
Widget Options – Advanced Conditional Visibility for Gutenberg Blocks & Classic Widgets / 3.9.3
Widget Options – Advanced Conditional Visibility for Gutenberg Blocks & Classic Widgets v3.9.3
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 / scripts.php
widget-options / includes Last commit date
admin 3 years ago pagebuilders 3 years ago widgets 3 years ago ajax-functions.php 8 years ago extras.php 4 years ago install.php 4 years ago scripts.php 3 years ago transient.php 8 years ago
scripts.php
202 lines
1 <?php
2 /**
3 * Scripts
4 *
5 * @copyright Copyright (c) 2016, Jeffrey Carandang
6 * @since 3.0
7 */
8
9 // Exit if accessed directly
10 if ( ! defined( 'ABSPATH' ) ) exit;
11
12 /**
13 * Load Scripts
14 *
15 * Enqueues the required scripts.
16 *
17 * @since 3.0
18 * @return void
19 */
20
21 function widgetopts_load_scripts(){
22 $css_dir = WIDGETOPTS_PLUGIN_URL . 'assets/css/';
23 wp_enqueue_style( 'widgetopts-styles', $css_dir . 'widget-options.css' , array(), null );
24 }
25 add_action( 'wp_enqueue_scripts', 'widgetopts_load_scripts' );
26 add_action( 'customize_controls_enqueue_scripts', 'widgetopts_load_scripts' );
27
28 /**
29 * Load Admin Scripts
30 *
31 * Enqueues the required admin scripts.
32 *
33 * @since 3.0
34 * @global $widget_options
35 * @param string $hook Page hook
36 * @return void
37 */
38 if( !function_exists( 'widgetopts_load_admin_scripts' ) ):
39 function widgetopts_load_admin_scripts( $hook ) {
40 global $widget_options;
41
42 $js_dir = WIDGETOPTS_PLUGIN_URL . 'assets/js/';
43 $css_dir = WIDGETOPTS_PLUGIN_URL . 'assets/css/';
44
45 // Use minified libraries if SCRIPT_DEBUG is turned off
46 $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
47
48 wp_enqueue_style( 'widgetopts-admin-styles', $css_dir . 'admin.css' , array(), null );
49
50 if( !in_array( $hook, apply_filters( 'widgetopts_exclude_jqueryui', array( 'toplevel_page_et_divi_options', 'toplevel_page_wpcf7', 'edit.php' ) ) ) ){
51 wp_enqueue_style( 'jquery-ui' );
52 }
53
54 if( in_array( $hook, apply_filters( 'widgetopts_load_liveFilter_scripts', array( 'widgets.php' ) ) ) ){
55 wp_enqueue_script(
56 'jquery-liveFilter',
57 plugins_url( 'assets/js/jquery.liveFilter.js' , dirname(__FILE__) ),
58 array( 'jquery' ),
59 '',
60 true
61 );
62 }
63
64 wp_enqueue_script(
65 'jquery-widgetopts-option-tabs',
66 plugins_url( 'assets/js/wpWidgetOpts.js' , dirname(__FILE__) ),
67 array( 'jquery', 'jquery-ui-core', 'jquery-ui-tabs', 'jquery-ui-datepicker'),
68 '',
69 true
70 );
71
72
73 wp_enqueue_style( 'jquery-widgetopts-select2-css', plugins_url( 'assets/css/select2.min.css' , dirname(__FILE__) ), array(), null );
74 wp_enqueue_script(
75 'jquery-widgetopts-select2-script',
76 $js_dir .'select2.min.js',
77 array( 'jquery' ),
78 '',
79 true
80 );
81
82 $form = '<div id="widgetopts-widgets-chooser">
83 <label class="screen-reader-text" for="widgetopts-search-chooser">'. __( 'Search Sidebar', 'widget-options' ) .'</label>
84 <input type="text" id="widgetopts-search-chooser" class="widgetopts-widgets-search" placeholder="'. __( 'Search sidebar&hellip;', 'widget-options' ) .'" />
85 <div class="widgetopts-search-icon" aria-hidden="true"></div>
86 <button type="button" class="widgetopts-clear-results"><span class="screen-reader-text">'. __( 'Clear Results', 'widget-options' ) .'</span></button>
87 <p class="screen-reader-text" id="widgetopts-chooser-desc">'. __( 'The search results will be updated as you type.', 'widget-options' ) .'</p>
88 </div>';
89
90 $btn_controls = '';
91 if( isset( $widget_options['move'] ) && 'activate' == $widget_options['move'] ){
92 $btn_controls .= ' | <button type="button" class="button-link widgetopts-control" data-action="move">'. __( 'Move', 'widget-options' ) .'</button>';
93 }
94
95 $sidebaropts = '';
96 if( isset( $widget_options['widget_area'] ) && 'activate' == $widget_options['widget_area'] ){
97 /* Updated by Haive Vistal - 04/20/2023 - Make sure no empty space in under the widgets if no activated links */
98 $remove_widget_link = 0;
99 $download_backup_link = 0;
100 $delete_all_widget_link = 0;
101
102 if( isset( $widget_options['settings']['widget_area'] ) && isset( $widget_options['settings']['widget_area']['remove'] ) && '1' == $widget_options['settings']['widget_area']['remove'] ){
103 $remove_widget_link = 1;
104 }
105 if( isset( $widget_options['settings']['widget_area'] ) && isset( $widget_options['settings']['widget_area']['backup'] ) && '1' == $widget_options['settings']['widget_area']['backup'] ){
106 $download_backup_link = 1;
107 }
108
109 if( isset( $widget_options['settings']['widget_area'] ) && isset( $widget_options['settings']['widget_area']['remove'] ) && '1' == $widget_options['settings']['widget_area']['remove'] ){
110 $delete_all_widget_link = 1;
111 }
112
113 if( $remove_widget_link == 1 || $download_backup_link == 1 || $delete_all_widget_link == 1 ) {
114 $sidebaropts = '<div class="widgetopts-sidebaropts">';
115 if( $remove_widget_link == 1 ) {
116 $sidebaropts .= '<a href="#" class="sidebaropts-clear">
117 <span class="dashicons dashicons-warning"></span> '. __( 'Remove All Widgets', 'widget-options' ) .'
118 </a>';
119 }
120 if( $download_backup_link == 1 ) {
121 $sidebaropts .= '<a href="'. esc_url( wp_nonce_url( admin_url('tools.php?page=widgetopts_migrator_settings&action=export&single_sidebar=__sidebaropts__'), 'widgeopts_export', 'widgeopts_nonce_export') ) .'">
122 <span class="dashicons dashicons-download"></span> '. __( 'Download Backup', 'widget-options' ) .'
123 </a>';
124 }
125 if( $delete_all_widget_link == 1 ) {
126 $sidebaropts .= '<div class="sidebaropts-confirm"><p>
127 '. __( 'Are you sure you want to DELETE ALL widgets associated to __sidebar_opts__?', 'widget-options' ) .'
128 </p>
129 <button class="button">'. __( 'No', 'widget-options' ) .'</button>
130 <button class="button button-primary">'. __( 'Yes', 'widget-options' ) .'</button>
131 </div>';
132 }
133 $sidebaropts .= '</div>';
134 }
135 }
136
137 /* Added by Haive Vistal - 04/20/2023 - Default link for all widgets to go through widget options panel settings */
138 // $sidebaropts .= '<div class="widgetopts-super widgetopts-sidebaropts">';
139 // $sidebaropts .= '<a href="'. esc_url( wp_nonce_url( admin_url('options-general.php?page=widgetopts_plugin_settings'), 'widgeopts_setings', 'widgeopts_nonce_settings') ) .'">
140 // <span class="dashicons dashicons-admin-settings"></span> '. __( 'Enable more Widget Options superpowers', 'widget-options' ) .'
141 // </a>';
142 // $sidebaropts .= '</div>';
143
144 wp_localize_script( 'jquery-widgetopts-option-tabs', 'widgetopts10n', array( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'opts_page' => esc_url( admin_url( 'options-general.php?page=widgetopts_plugin_settings' ) ), 'search_form' => $form, 'sidebaropts' => $sidebaropts, 'controls' => $btn_controls, 'translation' => array( 'manage_settings' => __( 'Manage Widget Options', 'widget-options' ), 'search_chooser' => __( 'Search sidebar&hellip;', 'widget-options' ) )) );
145
146 if( in_array( $hook, apply_filters( 'widgetopts_load_settings_scripts', array( 'settings_page_widgetopts_plugin_settings' ) ) ) ){
147 wp_register_script(
148 'jquery-widgetopts-settings',
149 $js_dir .'settings'. $suffix .'.js',
150 array( 'jquery' ),
151 '',
152 true
153 );
154
155 $translation = array(
156 'save_settings' => __( 'Save Settings', 'widget-options' ),
157 'close_settings' => __( 'Close', 'widget-options' ),
158 'show_settings' => __( 'Configure Settings', 'widget-options' ),
159 'hide_settings' => __( 'Hide Settings', 'widget-options' ),
160 'show_description' => __( 'Learn More', 'widget-options' ),
161 'hide_description' => __( 'Hide Details', 'widget-options' ),
162 'show_information' => __( 'Show Details', 'widget-options' ),
163 'activate' => __( 'Enable', 'widget-options' ),
164 'deactivate' => __( 'Disable', 'widget-options' ),
165 'successful_save' => __( 'Settings saved successfully for %1$s.', 'widget-options' ),
166 'deactivate_btn' => __( 'Deactivate License', 'widget-options' ),
167 'activate_btn' => __( 'Activate License', 'widget-options' ),
168 'status_valid' => __( 'Valid', 'widget-options' ),
169 'status_invalid' => __( 'Invalid', 'widget-options' ),
170 );
171
172 wp_enqueue_script( 'jquery-widgetopts-settings' );
173 wp_localize_script( 'jquery-widgetopts-settings', 'widgetopts', array( 'translation' => $translation, 'ajax_action' => 'widgetopts_ajax_settings', 'ajax_nonce' => wp_create_nonce( 'widgetopts-settings-nonce' ), ) );
174 }
175 }
176 add_action( 'admin_enqueue_scripts', 'widgetopts_load_admin_scripts', 100 );
177 endif;
178
179 if( !function_exists( 'widgetopts_widgets_footer' ) ){
180 function widgetopts_widgets_footer(){
181 global $widget_options;?>
182 <div class="widgetsopts-chooser" style="display:none;">
183 <?php if( isset( $widget_options['search'] ) && 'activate' == $widget_options['search'] ): ?>
184 <div id="widgetopts-widgets-chooser">
185 <label class="screen-reader-text" for="widgetopts-search-chooser"><?php _e( 'Search Sidebar', 'widget-options' );?></label>
186 <input type="text" id="widgetsopts-widgets-search" class="widgetopts-widgets-search widgetsopts-widgets-search" placeholder="Search sidebar…">
187 <div class="widgetopts-search-icon" aria-hidden="true"></div>
188 <button type="button" class="widgetopts-clear-results"><span class="screen-reader-text"><?php _e( 'Clear Results', 'widget-options' );?></span></button>
189 <p class="screen-reader-text" id="widgetopts-chooser-desc"><?php _e( 'The search results will be updated as you type.', 'widget-options' );?></p>
190 </div>
191 <?php endif; ?>
192 <ul class="widgetopts-chooser-sidebars"></ul>
193 <div class="widgetsopts-chooser-actions">
194 <button class="button widgetsopts-chooser-cancel"><?php _e( 'Cancel', 'widget-options' ); ?></button>
195 <button class="button button-primary widgetopts-chooser-action"><span><?php _e( 'Move', 'widget-options' ); ?></span> <?php _e( 'Widget', 'widget-options' ); ?></button>
196 </div>
197 </div>
198 <?php }
199 add_action( 'admin_footer-widgets.php', 'widgetopts_widgets_footer' );
200 }
201 ?>
202