PluginProbe ʕ •ᴥ•ʔ
Responsive Lightbox & Gallery / trunk
Responsive Lightbox & Gallery vtrunk
2.7.8 trunk 1.0.0 1.0.1 1.0.1.1 1.0.2 1.0.3 1.0.4 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.4.0 1.4.0.1 1.4.1 1.4.11 1.4.12 1.4.13 1.4.14 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.6.0 1.6.1 1.6.10 1.6.11 1.6.12 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 2.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.3.1 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.1 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7
responsive-lightbox / includes / class-tour.php
responsive-lightbox / includes Last commit date
galleries 2 weeks ago providers 4 months ago settings 4 months ago class-fast-image.php 2 years ago class-folders.php 2 weeks ago class-frontend.php 2 weeks ago class-galleries.php 4 months ago class-multilang.php 2 years ago class-remote-library-api.php 2 weeks ago class-remote-library.php 2 weeks ago class-settings-api.php 1 month ago class-settings-data.php 5 months ago class-settings-pages.php 4 months ago class-settings.php 4 months ago class-tour.php 5 months ago class-welcome.php 4 months ago class-widgets.php 2 years ago functions.php 3 years ago
class-tour.php
367 lines
1 <?php
2 // exit if accessed directly
3 if ( ! defined( 'ABSPATH' ) )
4 exit;
5
6 new Responsive_Lightbox_Tour();
7
8 /**
9 * Responsive_Lightbox_Tour class.
10 *
11 * @class Responsive_Lightbox_Tour
12 */
13 class Responsive_Lightbox_Tour {
14
15 /**
16 * Class constructor.
17 *
18 * @return void
19 */
20 public function __construct() {
21 // actions
22 add_action( 'admin_init', [ $this, 'init_tour' ] );
23 add_action( 'wp_ajax_rl-ignore-tour', [ $this, 'ignore_tour' ] );
24 }
25
26 /**
27 * Initialize tour.
28 *
29 * Detects rl_start_tour=1 parameter, sets tour transient, and redirects to first tour target.
30 * After redirect, displays tour pointers on each admin page via start_tour().
31 *
32 * @since 2.7.0 Updated to use parameter-based trigger instead of stub tour page.
33 *
34 * @global string $pagenow
35 *
36 * @return void
37 */
38 public function init_tour() {
39 $rl = Responsive_Lightbox();
40
41 // get master capability
42 $capability = apply_filters( 'rl_lightbox_settings_capability', $rl->options['capabilities']['active'] ? 'edit_lightbox_settings' : 'manage_options' );
43
44 // if capabilities are active, ensure admin-level users have the required capability
45 // this must happen before the capability check below (mirrors logic in class-settings.php)
46 if ( $rl->options['capabilities']['active'] ) {
47 $user = wp_get_current_user();
48
49 // grant capability to users with manage_options (admins) who don't have it yet
50 if ( is_a( $user, 'WP_User' ) && $user->has_cap( 'manage_options' ) && ! $user->has_cap( $capability ) ) {
51 $user->add_cap( $capability );
52 }
53 }
54
55 if ( ! current_user_can( $capability ) )
56 return;
57
58 global $pagenow;
59
60 $page = isset( $_GET['page'] ) ? sanitize_key( $_GET['page'] ) : '';
61 $start_tour = isset( $_GET['rl_start_tour'] ) ? sanitize_key( $_GET['rl_start_tour'] ) : '';
62 $start_nonce = isset( $_GET['rl_nonce'] ) ? sanitize_key( $_GET['rl_nonce'] ) : '';
63
64 if ( $pagenow === 'admin.php' && $page === 'responsive-lightbox-settings' && $start_tour === '1' ) {
65 if ( $start_nonce === '' || wp_verify_nonce( $start_nonce, 'rl-start-tour' ) === false )
66 return;
67
68 set_transient( 'rl_active_tour', 1, 0 );
69
70 $target = $rl->options['builder']['gallery_builder']
71 ? admin_url( 'edit.php?post_type=rl_gallery' )
72 : admin_url( 'admin.php?page=responsive-lightbox-settings&tab=settings' );
73
74 wp_safe_redirect( $target );
75 exit;
76 }
77
78 if ( (int) get_transient( 'rl_active_tour' ) === 1 ) {
79 add_action( 'admin_enqueue_scripts', [ $this, 'tour_scripts_styles' ] );
80 add_action( 'admin_print_footer_scripts', [ $this, 'start_tour' ] );
81 }
82 }
83
84 /**
85 * Load pointer scripts.
86 *
87 * @return void
88 */
89 public function tour_scripts_styles() {
90 // enqueue styles
91 wp_enqueue_style( 'wp-pointer' );
92
93 // enqueue scripts
94 wp_enqueue_script( 'jquery-ui' );
95 wp_enqueue_script( 'wp-pointer' );
96 wp_enqueue_script( 'utils' );
97 }
98
99 /**
100 * Load the introduction tour.
101 *
102 * @since 2.7.0 Updated for Settings API migration - uses tab-based URLs instead of legacy page slugs.
103 *
104 * @global string $pagenow
105 *
106 * @return void
107 */
108 public function start_tour() {
109 global $pagenow;
110
111 $pointer = [];
112 $rl = Responsive_Lightbox();
113
114 // get page
115 $page = isset( $_GET['page'] ) ? sanitize_key( $_GET['page'] ) : '';
116
117 // get tab (Settings API)
118 $tab = isset( $_GET['tab'] ) ? sanitize_key( $_GET['tab'] ) : '';
119
120 // get post type
121 $post_type = isset( $_GET['post_type'] ) ? sanitize_key( $_GET['post_type'] ) : '';
122
123 // get taxonomy
124 $taxonomy = isset( $_GET['taxonomy'] ) ? sanitize_key( $_GET['taxonomy'] ) : '';
125
126 // galleries
127 if ( $pagenow === 'edit.php' ) {
128 if ( $post_type && $post_type === 'rl_gallery' && $rl->options['builder']['gallery_builder'] ) {
129 $pointer = [
130 'content' => '<h3>' . esc_html__( 'Gallery Builder', 'responsive-lightbox' ) . '</h3><p>' . esc_html__( 'This is an advanced gallery builder. Here you can see a preview of all created galleries along with their settings, such as the name, type, source of images, author or date of publication. You can also add a new gallery, edit existing ones or quickly copy the code allowing its use on the site.', 'responsive-lightbox' ) . '</p>',
131 'button2' => __( 'Next', 'responsive-lightbox' ),
132 'id' => '#wpbody-content h1'
133 ];
134
135 // next categories?
136 if ( $rl->options['builder']['categories'] )
137 $pointer['function'] = 'window.location="' . esc_url_raw( admin_url( 'edit-tags.php?taxonomy=rl_category&post_type=rl_gallery' ) ) . '";';
138 // next tags?
139 elseif ( $rl->options['builder']['tags'] )
140 $pointer['function'] = 'window.location="' . esc_url_raw( admin_url( 'edit-tags.php?taxonomy=rl_tag&post_type=rl_gallery' ) ) . '";';
141 // or settings?
142 else
143 $pointer['function'] = 'window.location="' . esc_url_raw( admin_url( 'admin.php?page=responsive-lightbox-settings' ) ) . '";';
144 }
145 // gallery taxonomies
146 } elseif ( $pagenow === 'edit-tags.php' ) {
147 if ( $post_type && $taxonomy && $post_type === 'rl_gallery' ) {
148 if ( $taxonomy === 'rl_category' ) {
149 $pointer = [
150 'content' => '<h3>' . esc_html__( 'Gallery Categories', 'responsive-lightbox' ) . '</h3><p>' . esc_html__( 'Gallery categories allow you to arrange galleries into individual groups that you can potentially use. Here you can create, name and edit them. However, assigning the gallery to the category takes place on the gallery editing screen.', 'responsive-lightbox' ) . '</p>',
151 'button2' => __( 'Next', 'responsive-lightbox' ),
152 'id' => '#wpbody-content h1'
153 ];
154
155 // next tags?
156 if ( $rl->options['builder']['tags'] )
157 $pointer['function'] = 'window.location="' . esc_url_raw( admin_url( 'edit-tags.php?taxonomy=rl_tag&post_type=rl_gallery' ) ) . '";';
158 // or settings?
159 else
160 $pointer['function'] = 'window.location="' . esc_url_raw( admin_url( 'admin.php?page=responsive-lightbox-settings' ) ) . '";';
161 } elseif ( $taxonomy === 'rl_tag' ) {
162 $pointer = [
163 'content' => '<h3>' . esc_html__( 'Gallery Tags', 'responsive-lightbox' ) . '</h3><p>' . esc_html__( 'Gallery tags, like categories, allow you to arrange galleries into groups. You can think of them as keywords, which you can use to further specify your galleries. Here you can create, name and edit them.', 'responsive-lightbox' ) . '</p>',
164 'button2' => __( 'Next', 'responsive-lightbox' ),
165 'id' => '#wpbody-content h1',
166 'function' => 'window.location="' . esc_url_raw( admin_url( 'admin.php?page=responsive-lightbox-settings' ) ) . '";'
167 ];
168 }
169 }
170 // settings
171 } elseif ( $pagenow === 'admin.php' && $page === 'responsive-lightbox-settings' ) {
172 // Settings API single-page with tabs
173 // Default to 'settings' tab if none specified
174 if ( empty( $tab ) )
175 $tab = 'settings';
176
177 // general
178 if ( $tab === 'settings' ) {
179 $pointer = [
180 'content' => '<h3>' . esc_html__( 'General Settings', 'responsive-lightbox' ) . '</h3><p>' . esc_html__( "Here are the main settings for Responsive Lightbox & Gallery. They allow you to specify general rules of the plugin's operation and technical parameters of the lightbox effect and gallery. For example - you can choose your favorite lightbox effect, specify for which elements it will automatically launch and set its parameters. You can also choose the default gallery and its settings.", 'responsive-lightbox' ) . '</p>',
181 'button2' => __( 'Next', 'responsive-lightbox' ),
182 'id' => '#wpbody-content .wrap .nav-tab-active',
183 'function' => 'window.location="' . esc_url_raw( admin_url( 'admin.php?page=responsive-lightbox-settings&tab=configuration' ) ) . '";'
184 ];
185 // lightboxes
186 } elseif ( $tab === 'configuration' ) {
187 $pointer = [
188 'content' => '<h3>' . esc_html__( 'Lightboxes Settings', 'responsive-lightbox' ) . '</h3><p>' . esc_html__( 'Each lightbox has different look, possibilities and parameters. Here is a list of available lightbox effects along with their settings. After entering the tab you can see the settings of the currently selected lightbox, but you can also modify or restore the settings of the others.', 'responsive-lightbox' ) . '</p>',
189 'button2' => __( 'Next', 'responsive-lightbox' ),
190 'id' => '#wpbody-content .wrap .nav-tab-active',
191 'function' => 'window.location="' . esc_url_raw( admin_url( 'admin.php?page=responsive-lightbox-settings&tab=gallery' ) ) . '";'
192 ];
193 // galleries
194 } elseif ( $tab === 'gallery' ) {
195 $pointer = [
196 'content' => '<h3>' . esc_html__( 'Galleries Settings', 'responsive-lightbox' ) . '</h3><p>' . esc_html__( "This is the screen of the default gallery settings. As in the case of lightbox effects, there is a list of available galleries and their parameters. After entering the tab you can see the settings of the currently selected gallery. You can modify and adjust them to your needs or restore it's default settings.", 'responsive-lightbox' ) . '</p>',
197 'button2' => __( 'Next', 'responsive-lightbox' ),
198 'id' => '#wpbody-content .wrap .nav-tab-active',
199 'function' => 'window.location="' . esc_url_raw( admin_url( 'admin.php?page=responsive-lightbox-settings&tab=builder' ) ) . '";'
200 ];
201 // builder
202 } elseif ( $tab === 'builder' ) {
203 $pointer = [
204 'content' => '<h3>' . esc_html__( 'Builder Settings', 'responsive-lightbox' ) . '</h3><p>' . esc_html__( 'You can use the galleries in many ways - insert them into posts using the Add Gallery button, insert manually using shortcodes or add to the theme using functions. But you can also display them in archives just like other post types. Use these settings to specify the functionality of the gallery builder like categories, tags, archives and permalinks.', 'responsive-lightbox' ) . '</p>',
205 'button2' => __( 'Next', 'responsive-lightbox' ),
206 'id' => '#wpbody-content .wrap .nav-tab-active',
207 'function' => 'window.location="' . esc_url_raw( admin_url( 'admin.php?page=responsive-lightbox-settings&tab=folders' ) ) . '";'
208 ];
209 // media folders
210 } elseif ( $tab === 'folders' ) {
211 $pointer = [
212 'content' => '<h3>' . esc_html__( 'Folders Settings', 'responsive-lightbox' ) . '</h3><p>' . esc_html__( 'Responsive Lithbox & Gallery comes with an optional Media Folders feature that extends your WordPress Media Library with visual folders. It allows you to organize your attachments in a folder tree structure. Move, copy, rename and delete files and folders with a nice drag and drop interface.', 'responsive-lightbox' ) . '</p>',
213 'button2' => __( 'Next', 'responsive-lightbox' ),
214 'id' => '#wpbody-content .wrap .nav-tab-active',
215 'function' => 'window.location="' . esc_url_raw( admin_url( 'admin.php?page=responsive-lightbox-settings&tab=capabilities' ) ) . '";'
216 ];
217 // capabilities
218 } elseif ( $tab === 'capabilities' ) {
219 $pointer = [
220 'content' => '<h3>' . esc_html__( 'Capabilities Settings', 'responsive-lightbox' ) . '</h3><p>' . esc_html__( 'Capabilities give you the ability to control what users can and cannot do within the plugin. By default only the Administrator role allows a user to perform all possible capabilities. But you can fine tune these settings to match your specific requirements.', 'responsive-lightbox' ) . '</p>',
221 'button2' => __( 'Next', 'responsive-lightbox' ),
222 'id' => '#wpbody-content .wrap .nav-tab-active',
223 'function' => 'window.location="' . esc_url_raw( admin_url( 'admin.php?page=responsive-lightbox-settings&tab=remote_library' ) ) . '";'
224 ];
225 // remote library
226 } elseif ( $tab === 'remote_library' ) {
227 // get tabs from Settings API
228 $settings_pages = $rl->settings_api->get_pages();
229 $tabs = isset( $settings_pages['settings']['tabs'] ) ? array_keys( $settings_pages['settings']['tabs'] ) : [];
230
231 // get current tab index
232 $tab_index = ! empty( $tabs ) ? (int) array_search( 'remote_library', $tabs, true ) : -1;
233
234 // determine next tab (licenses is conditional, fallback to addons)
235 $next_tab = 'addons';
236 if ( $tab_index !== -1 && isset( $tabs[$tab_index + 1] ) )
237 $next_tab = $tabs[$tab_index + 1];
238
239 $pointer = [
240 'content' => '<h3>' . esc_html__( 'Remote Library Settings', 'responsive-lightbox' ) . '</h3><p>' . esc_html__( 'Are you looking for free royalty free public domain and CC0-Licensed images for your website? Or you need to access your images stored in photo-sharing apps? Remote Library allows you to use images from multiple sources like Unsplash, Pixabay, Flickr or Instagram directly in your WordPress Media Manager. Now you can create galleries, browse, insert and import images as never before.', 'responsive-lightbox' ) . '</p>',
241 'button2' => __( 'Next', 'responsive-lightbox' ),
242 'id' => '#wpbody-content .wrap .nav-tab-active',
243 'function' => 'window.location="' . esc_url_raw( admin_url( 'admin.php?page=responsive-lightbox-settings&tab=' . $next_tab ) ) . '";'
244 ];
245 // licenses
246 } elseif ( $tab === 'licenses' ) {
247 $pointer = [
248 'content' => '<h3>' . esc_html__( 'Licenses Settings', 'responsive-lightbox' ) . '</h3><p>' . esc_html__( 'This section contains a list of currently installed premium extensions. Activate your licenses to have access to automatic updates from your site. To activate the license, copy and paste the license key for the extension and save the changes. Available license keys can be found on your account on our website.', 'responsive-lightbox' ) . '</p>',
249 'button2' => __( 'Next', 'responsive-lightbox' ),
250 'id' => '#wpbody-content .wrap .nav-tab-active',
251 'function' => 'window.location="' . esc_url_raw( admin_url( 'admin.php?page=responsive-lightbox-settings&tab=addons' ) ) . '";'
252 ];
253 // addons
254 } elseif ( $tab === 'addons' ) {
255 $pointer = [
256 'content' => '<h3>' . esc_html__( 'Add-ons', 'responsive-lightbox' ) . '</h3><p>' . esc_html__( 'Responsive Lightbox & Gallery is more than that. Do you need a beautiful lightbox effect, integration with social media, an attractive image gallery? Among our products you will surely find something for yourself. Boost your creativity and enhance your website with these beautiful, easy to use extensions, designed with Responsive Lightbox & Gallery integration in mind.', 'responsive-lightbox' ) . '</p>',
257 'button2' => '',
258 'id' => '#wpbody-content .wrap .nav-tab-active',
259 'function' => ''
260 ];
261 // Add-on tabs: delegate to add-ons via filter
262 // Add-ons should hook 'rl_tour_pointer' and return pointer array when $tab matches their tab key
263 // See responsive-lightbox-comments/includes/class-settings.php for implementation example
264 } else
265 $pointer = apply_filters( 'rl_tour_pointer', [], $tab );
266 }
267
268 // valid pointer?
269 if ( ! empty( $pointer ) ) {
270 $this->print_scripts(
271 $pointer['id'],
272 [
273 'content' => $pointer['content'],
274 'pointerWidth' => 400,
275 'position' => [
276 'edge' => 'top',
277 'align' => is_rtl() ? 'right' : 'left'
278 ]
279 ],
280 __( 'Close', 'responsive-lightbox' ),
281 $pointer['button2'],
282 $pointer['function']
283 );
284 }
285 }
286
287 /**
288 * Ignore tour.
289 *
290 * @return void
291 */
292 public function ignore_tour() {
293 if ( isset( $_POST['rl_nonce'] ) && ctype_alnum( $_POST['rl_nonce'] ) && wp_verify_nonce( $_POST['rl_nonce'], 'rl-ignore-tour' ) !== false )
294 delete_transient( 'rl_active_tour' );
295
296 exit;
297 }
298
299 /**
300 * Print the pointer script.
301 *
302 * @return void
303 */
304 public function print_scripts( $selector, $options, $button1, $button2 = false, $function = '' ) {
305 ?>
306 <script type="text/javascript">
307 //<![CDATA[
308 ( function( $ ) {
309 // ready event
310 $( function() {
311 var rlPointerOptions = <?php echo wp_json_encode( $options ); ?>;
312 var setup;
313
314 function rlSetIgnore( option, hide, nonce ) {
315 $.post( ajaxurl, {
316 action: 'rl-ignore-tour',
317 rl_nonce: nonce
318 }, function( data ) {
319 if ( data ) {
320 $( '#' + hide ).hide();
321 $( '#hidden_ignore_' + option ).val( 'ignore' );
322 }
323 } );
324 }
325
326 rlPointerOptions = $.extend( rlPointerOptions, {
327 buttons: function( event, t ) {
328 var button = $( '<a id="rl-pointer-close" style="margin-left: 5px;" class="button-secondary">' + '<?php esc_html_e( $button1 ); ?>' + '</a>' );
329
330 button.on( 'click.pointer', function() {
331 t.element.pointer( 'close' );
332 } );
333
334 return button;
335 },
336 close: function() {}
337 } );
338
339 setup = function() {
340 $( '<?php echo esc_js( $selector ); ?>' ).pointer( rlPointerOptions ).pointer( 'open' );
341
342 <?php if ( $button2 ) { ?>
343
344 $( '#rl-pointer-close' ).after( '<a id="pointer-primary" class="button-primary">' + '<?php esc_html_e( $button2 ); ?>' + '</a>' );
345 $( '#pointer-primary' ).on( 'click', function() {
346 <?php echo $function; ?>
347 } );
348
349 <?php } ?>
350
351 $( '#rl-pointer-close' ).on( 'click', function() {
352 rlSetIgnore( 'tour', 'wp-pointer-0', '<?php echo esc_js( wp_create_nonce( 'rl-ignore-tour' ) ); ?>' );
353 } );
354 };
355
356 if ( rlPointerOptions.position && rlPointerOptions.position.defer_loading )
357 $( window ).on( 'load.wp-pointers', setup );
358 else
359 $( document ).ready( setup );
360 } );
361 } )( jQuery );
362 //]]>
363 </script>
364 <?php
365 }
366 }
367