PluginProbe ʕ •ᴥ•ʔ
Widget Options – Advanced Conditional Visibility for Gutenberg Blocks & Classic Widgets / 3.7.7
Widget Options – Advanced Conditional Visibility for Gutenberg Blocks & Classic Widgets v3.7.7
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 5 years ago pagebuilders 4 years ago widgets 5 years ago ajax-functions.php 5 years ago extras.php 5 years ago install.php 5 years ago scripts.php 5 years ago transient.php 5 years ago
scripts.php
170 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( 'widgetopts-jquery-ui', $css_dir . 'jqueryui/1.11.4/themes/ui-lightness/jquery-ui.css' , array(), null );
52 wp_enqueue_style( 'jquery-ui' );
53 }
54
55 if( in_array( $hook, apply_filters( 'widgetopts_load_liveFilter_scripts', array( 'widgets.php' ) ) ) ){
56 wp_enqueue_script(
57 'jquery-liveFilter',
58 plugins_url( 'assets/js/jquery.liveFilter.js' , dirname(__FILE__) ),
59 array( 'jquery' ),
60 '',
61 true
62 );
63 }
64
65 wp_enqueue_script(
66 'jquery-widgetopts-option-tabs',
67 plugins_url( 'assets/js/wpWidgetOpts.js' , dirname(__FILE__) ),
68 array( 'jquery', 'jquery-ui-core', 'jquery-ui-tabs', 'jquery-ui-datepicker'),
69 '',
70 true
71 );
72
73 $form = '<div id="widgetopts-widgets-chooser">
74 <label class="screen-reader-text" for="widgetopts-search-chooser">'. __( 'Search Sidebar', 'widget-options' ) .'</label>
75 <input type="text" id="widgetopts-search-chooser" class="widgetopts-widgets-search" placeholder="'. __( 'Search sidebar&hellip;', 'widget-options' ) .'" />
76 <div class="widgetopts-search-icon" aria-hidden="true"></div>
77 <button type="button" class="widgetopts-clear-results"><span class="screen-reader-text">'. __( 'Clear Results', 'widget-options' ) .'</span></button>
78 <p class="screen-reader-text" id="widgetopts-chooser-desc">'. __( 'The search results will be updated as you type.', 'widget-options' ) .'</p>
79 </div>';
80
81 $btn_controls = '';
82 if( isset( $widget_options['move'] ) && 'activate' == $widget_options['move'] ){
83 $btn_controls .= ' | <button type="button" class="button-link widgetopts-control" data-action="move">'. __( 'Move', 'widget-options' ) .'</button>';
84 }
85
86 $sidebaropts = '';
87 if( isset( $widget_options['widget_area'] ) && 'activate' == $widget_options['widget_area'] ){
88 $sidebaropts = '<div class="widgetopts-sidebaropts">';
89 if( isset( $widget_options['settings']['widget_area'] ) && isset( $widget_options['settings']['widget_area']['remove'] ) && '1' == $widget_options['settings']['widget_area']['remove'] ){
90 $sidebaropts .= '<a href="#" class="sidebaropts-clear">
91 <span class="dashicons dashicons-warning"></span> '. __( 'Remove All Widgets', 'widget-options' ) .'
92 </a>';
93 }
94 if( isset( $widget_options['settings']['widget_area'] ) && isset( $widget_options['settings']['widget_area']['backup'] ) && '1' == $widget_options['settings']['widget_area']['backup'] ){
95 $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') ) .'">
96 <span class="dashicons dashicons-download"></span> '. __( 'Download Backup', 'widget-options' ) .'
97 </a>';
98 }
99
100 if( isset( $widget_options['settings']['widget_area'] ) && isset( $widget_options['settings']['widget_area']['remove'] ) && '1' == $widget_options['settings']['widget_area']['remove'] ){
101 $sidebaropts .= '<div class="sidebaropts-confirm"><p>
102 '. __( 'Are you sure you want to DELETE ALL widgets associated to __sidebar_opts__?', 'widget-options' ) .'
103 </p>
104 <button class="button">'. __( 'No', 'widget-options' ) .'</button>
105 <button class="button button-primary">'. __( 'Yes', 'widget-options' ) .'</button>
106 </div>';
107 }
108
109 $sidebaropts .= '</div>';
110 }
111
112 wp_localize_script( 'jquery-widgetopts-option-tabs', 'widgetopts10n', array( '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' ) )) );
113
114 if( in_array( $hook, apply_filters( 'widgetopts_load_settings_scripts', array( 'settings_page_widgetopts_plugin_settings' ) ) ) ){
115 wp_register_script(
116 'jquery-widgetopts-settings',
117 $js_dir .'settings'. $suffix .'.js',
118 array( 'jquery' ),
119 '',
120 true
121 );
122
123 $translation = array(
124 'save_settings' => __( 'Save Settings', 'widget-options' ),
125 'close_settings' => __( 'Close', 'widget-options' ),
126 'show_settings' => __( 'Configure Settings', 'widget-options' ),
127 'hide_settings' => __( 'Hide Settings', 'widget-options' ),
128 'show_description' => __( 'Learn More', 'widget-options' ),
129 'hide_description' => __( 'Hide Details', 'widget-options' ),
130 'show_information' => __( 'Show Details', 'widget-options' ),
131 'activate' => __( 'Enable', 'widget-options' ),
132 'deactivate' => __( 'Disable', 'widget-options' ),
133 'successful_save' => __( 'Settings saved successfully for %1$s.', 'widget-options' ),
134 'deactivate_btn' => __( 'Deactivate License', 'widget-options' ),
135 'activate_btn' => __( 'Activate License', 'widget-options' ),
136 'status_valid' => __( 'Valid', 'widget-options' ),
137 'status_invalid' => __( 'Invalid', 'widget-options' ),
138 );
139
140 wp_enqueue_script( 'jquery-widgetopts-settings' );
141 wp_localize_script( 'jquery-widgetopts-settings', 'widgetopts', array( 'translation' => $translation, 'ajax_action' => 'widgetopts_ajax_settings', 'ajax_nonce' => wp_create_nonce( 'widgetopts-settings-nonce' ), ) );
142 }
143 }
144 add_action( 'admin_enqueue_scripts', 'widgetopts_load_admin_scripts', 100 );
145 endif;
146
147 if( !function_exists( 'widgetopts_widgets_footer' ) ){
148 function widgetopts_widgets_footer(){
149 global $widget_options;?>
150 <div class="widgetsopts-chooser" style="display:none;">
151 <?php if( isset( $widget_options['search'] ) && 'activate' == $widget_options['search'] ): ?>
152 <div id="widgetopts-widgets-chooser">
153 <label class="screen-reader-text" for="widgetopts-search-chooser"><?php _e( 'Search Sidebar', 'widget-options' );?></label>
154 <input type="text" id="widgetsopts-widgets-search" class="widgetopts-widgets-search widgetsopts-widgets-search" placeholder="Search sidebar…">
155 <div class="widgetopts-search-icon" aria-hidden="true"></div>
156 <button type="button" class="widgetopts-clear-results"><span class="screen-reader-text"><?php _e( 'Clear Results', 'widget-options' );?></span></button>
157 <p class="screen-reader-text" id="widgetopts-chooser-desc"><?php _e( 'The search results will be updated as you type.', 'widget-options' );?></p>
158 </div>
159 <?php endif; ?>
160 <ul class="widgetopts-chooser-sidebars"></ul>
161 <div class="widgetsopts-chooser-actions">
162 <button class="button widgetsopts-chooser-cancel"><?php _e( 'Cancel', 'widget-options' ); ?></button>
163 <button class="button button-primary widgetopts-chooser-action"><span><?php _e( 'Move', 'widget-options' ); ?></span> <?php _e( 'Widget', 'widget-options' ); ?></button>
164 </div>
165 </div>
166 <?php }
167 add_action( 'admin_footer-widgets.php', 'widgetopts_widgets_footer' );
168 }
169 ?>
170