PluginProbe ʕ •ᴥ•ʔ
Responsive Lightbox & Gallery / 2.6.0
Responsive Lightbox & Gallery v2.6.0
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
providers 1 year ago class-fast-image.php 2 years ago class-folders.php 6 months ago class-frontend.php 6 months ago class-galleries.php 6 months ago class-multilang.php 2 years ago class-remote-library-api.php 1 year ago class-remote-library.php 6 months ago class-settings.php 6 months ago class-tour.php 2 years ago class-welcome.php 2 years ago class-widgets.php 2 years ago functions.php 3 years ago
class-tour.php
336 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_menu', [ $this, 'admin_menu' ] );
23 add_action( 'admin_init', [ $this, 'init_tour' ] );
24 add_action( 'wp_ajax_rl-ignore-tour', [ $this, 'ignore_tour' ] );
25 }
26
27 /**
28 * Initialize tour.
29 *
30 * @global string $pagenow
31 *
32 * @return void
33 */
34 public function init_tour() {
35 if ( ! current_user_can( apply_filters( 'rl_lightbox_settings_capability', 'manage_options' ) ) )
36 return;
37
38 global $pagenow;
39
40 if ( $pagenow === 'admin.php' && isset( $_GET['page'] ) && $_GET['page'] === 'responsive-lightbox-tour' ) {
41 set_transient( 'rl_active_tour', 1, 0 );
42
43 if ( Responsive_Lightbox()->options['builder']['gallery_builder'] )
44 wp_redirect( admin_url( 'edit.php?post_type=rl_gallery' ) );
45 else
46 wp_redirect( admin_url( 'admin.php?page=responsive-lightbox-settings' ) );
47
48 exit;
49 }
50
51 if ( (int) get_transient( 'rl_active_tour' ) === 1 ) {
52 add_action( 'admin_enqueue_scripts', [ $this, 'tour_scripts_styles' ] );
53 add_action( 'admin_print_footer_scripts', [ $this, 'start_tour' ] );
54 }
55 }
56
57 /**
58 * Add temporary admin menu.
59 *
60 * @global string $pagenow
61 *
62 * @return void
63 */
64 public function admin_menu() {
65 global $pagenow;
66
67 if ( $pagenow === 'admin.php' && isset( $_GET['page'] ) && $_GET['page'] === 'responsive-lightbox-tour' )
68 add_submenu_page( 'responsive-lightbox-settings', '', '', apply_filters( 'rl_lightbox_settings_capability', 'manage_options' ), 'responsive-lightbox-tour', function() {} );
69 }
70
71 /**
72 * Load pointer scripts.
73 *
74 * @return void
75 */
76 public function tour_scripts_styles() {
77 // enqueue styles
78 wp_enqueue_style( 'wp-pointer' );
79
80 // enqueue scripts
81 wp_enqueue_script( 'jquery-ui' );
82 wp_enqueue_script( 'wp-pointer' );
83 wp_enqueue_script( 'utils' );
84 }
85
86 /**
87 * Load the introduction tour.
88 *
89 * @global string $pagenow
90 *
91 * @return void
92 */
93 public function start_tour() {
94 global $pagenow;
95
96 $pointer = [];
97 $rl = Responsive_Lightbox();
98
99 // get page
100 $page = isset( $_GET['page'] ) ? sanitize_key( $_GET['page'] ) : '';
101
102 // get post type
103 $post_type = isset( $_GET['post_type'] ) ? sanitize_key( $_GET['post_type'] ) : '';
104
105 // get taxonomy
106 $taxonomy = isset( $_GET['taxonomy'] ) ? sanitize_key( $_GET['taxonomy'] ) : '';
107
108 // galleries
109 if ( $pagenow === 'edit.php' ) {
110 if ( $post_type && $post_type === 'rl_gallery' && $rl->options['builder']['gallery_builder'] ) {
111 $pointer = [
112 '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>',
113 'button2' => __( 'Next', 'responsive-lightbox' ),
114 'id' => '#wpbody-content h1'
115 ];
116
117 // next categories?
118 if ( $rl->options['builder']['categories'] )
119 $pointer['function'] = 'window.location="' . esc_url_raw( admin_url( 'edit-tags.php?taxonomy=rl_category&post_type=rl_gallery' ) ) . '";';
120 // next tags?
121 elseif ( $rl->options['builder']['tags'] )
122 $pointer['function'] = 'window.location="' . esc_url_raw( admin_url( 'edit-tags.php?taxonomy=rl_tag&post_type=rl_gallery' ) ) . '";';
123 // or settings?
124 else
125 $pointer['function'] = 'window.location="' . esc_url_raw( admin_url( 'admin.php?page=responsive-lightbox-settings' ) ) . '";';
126 }
127 // gallery taxonomies
128 } elseif ( $pagenow === 'edit-tags.php' ) {
129 if ( $post_type && $taxonomy && $post_type === 'rl_gallery' ) {
130 if ( $taxonomy === 'rl_category' ) {
131 $pointer = [
132 '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>',
133 'button2' => __( 'Next', 'responsive-lightbox' ),
134 'id' => '#wpbody-content h1'
135 ];
136
137 // next tags?
138 if ( $rl->options['builder']['tags'] )
139 $pointer['function'] = 'window.location="' . esc_url_raw( admin_url( 'edit-tags.php?taxonomy=rl_tag&post_type=rl_gallery' ) ) . '";';
140 // or settings?
141 else
142 $pointer['function'] = 'window.location="' . esc_url_raw( admin_url( 'admin.php?page=responsive-lightbox-settings' ) ) . '";';
143 } elseif ( $taxonomy === 'rl_tag' ) {
144 $pointer = [
145 '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>',
146 'button2' => __( 'Next', 'responsive-lightbox' ),
147 'id' => '#wpbody-content h1',
148 'function' => 'window.location="' . esc_url_raw( admin_url( 'admin.php?page=responsive-lightbox-settings' ) ) . '";'
149 ];
150 }
151 }
152 // settings
153 } elseif ( $pagenow === 'admin.php' && $page ) {
154 // general
155 if ( $page === 'responsive-lightbox-settings' ) {
156 $pointer = [
157 '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>',
158 'button2' => __( 'Next', 'responsive-lightbox' ),
159 'id' => '#wpbody-content .wrap .nav-tab-active',
160 'function' => 'window.location="' . esc_url_raw( admin_url( 'admin.php?page=responsive-lightbox-configuration' ) ) . '";'
161 ];
162 // lightboxes
163 } elseif ( $page === 'responsive-lightbox-configuration' ) {
164 $pointer = [
165 '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>',
166 'button2' => __( 'Next', 'responsive-lightbox' ),
167 'id' => '#wpbody-content .wrap .nav-tab-active',
168 'function' => 'window.location="' . esc_url_raw( admin_url( 'admin.php?page=responsive-lightbox-gallery' ) ) . '";'
169 ];
170 // galleries
171 } elseif ( $page === 'responsive-lightbox-gallery' ) {
172 $pointer = [
173 '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>',
174 'button2' => __( 'Next', 'responsive-lightbox' ),
175 'id' => '#wpbody-content .wrap .nav-tab-active',
176 'function' => 'window.location="' . esc_url_raw( admin_url( 'admin.php?page=responsive-lightbox-builder' ) ) . '";'
177 ];
178 // builder
179 } elseif ( $page === 'responsive-lightbox-builder' ) {
180 $pointer = [
181 '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>',
182 'button2' => __( 'Next', 'responsive-lightbox' ),
183 'id' => '#wpbody-content .wrap .nav-tab-active',
184 'function' => 'window.location="' . esc_url_raw( admin_url( 'admin.php?page=responsive-lightbox-folders' ) ) . '";'
185 ];
186 // media folders
187 } elseif ( $page === 'responsive-lightbox-folders' ) {
188 $pointer = [
189 '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>',
190 'button2' => __( 'Next', 'responsive-lightbox' ),
191 'id' => '#wpbody-content .wrap .nav-tab-active',
192 'function' => 'window.location="' . esc_url_raw( admin_url( 'admin.php?page=responsive-lightbox-capabilities' ) ) . '";'
193 ];
194 // capabilities
195 } elseif ( $page === 'responsive-lightbox-capabilities' ) {
196 $pointer = [
197 '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>',
198 'button2' => __( 'Next', 'responsive-lightbox' ),
199 'id' => '#wpbody-content .wrap .nav-tab-active',
200 'function' => 'window.location="' . esc_url_raw( admin_url( 'admin.php?page=responsive-lightbox-remote_library' ) ) . '";'
201 ];
202 // remote library
203 } elseif ( $page === 'responsive-lightbox-remote_library' ) {
204 // get tabs
205 $tabs = array_keys( $rl->settings->get_data( 'tabs' ) );
206
207 // get current tab index
208 $tab_index = (int) array_search( 'remote_library', $tabs, true );
209
210 $pointer = [
211 '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>',
212 'button2' => __( 'Next', 'responsive-lightbox' ),
213 'id' => '#wpbody-content .wrap .nav-tab-active',
214 'function' => 'window.location="' . esc_url_raw( admin_url( 'admin.php?page=responsive-lightbox-' . $tabs[$tab_index + 1] ) ) . '";'
215 ];
216 // licenses
217 } elseif ( $page === 'responsive-lightbox-licenses' ) {
218 $pointer = [
219 '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>',
220 'button2' => __( 'Next', 'responsive-lightbox' ),
221 'id' => '#wpbody-content .wrap .nav-tab-active',
222 'function' => 'window.location="' . esc_url_raw( admin_url( 'admin.php?page=responsive-lightbox-addons' ) ) . '";'
223 ];
224 // addons
225 } elseif ( $page === 'responsive-lightbox-addons' ) {
226 $pointer = [
227 '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>',
228 'button2' => '',
229 'id' => '#wpbody-content .wrap .nav-tab-active',
230 'function' => ''
231 ];
232 // plugins related tabs
233 } else
234 $pointer = apply_filters( 'rl_tour_pointer', [], $page );
235 }
236
237 // valid pointer?
238 if ( ! empty( $pointer ) ) {
239 $this->print_scripts(
240 $pointer['id'],
241 [
242 'content' => $pointer['content'],
243 'pointerWidth' => 400,
244 'position' => [
245 'edge' => 'top',
246 'align' => is_rtl() ? 'right' : 'left'
247 ]
248 ],
249 __( 'Close', 'responsive-lightbox' ),
250 $pointer['button2'],
251 $pointer['function']
252 );
253 }
254 }
255
256 /**
257 * Ignore tour.
258 *
259 * @return void
260 */
261 public function ignore_tour() {
262 if ( isset( $_POST['rl_nonce'] ) && ctype_alnum( $_POST['rl_nonce'] ) && wp_verify_nonce( $_POST['rl_nonce'], 'rl-ignore-tour' ) !== false )
263 delete_transient( 'rl_active_tour' );
264
265 exit;
266 }
267
268 /**
269 * Print the pointer script.
270 *
271 * @return void
272 */
273 public function print_scripts( $selector, $options, $button1, $button2 = false, $function = '' ) {
274 ?>
275 <script type="text/javascript">
276 //<![CDATA[
277 ( function( $ ) {
278 // ready event
279 $( function() {
280 var rlPointerOptions = <?php echo wp_json_encode( $options ); ?>;
281 var setup;
282
283 function rlSetIgnore( option, hide, nonce ) {
284 $.post( ajaxurl, {
285 action: 'rl-ignore-tour',
286 rl_nonce: nonce
287 }, function( data ) {
288 if ( data ) {
289 $( '#' + hide ).hide();
290 $( '#hidden_ignore_' + option ).val( 'ignore' );
291 }
292 } );
293 }
294
295 rlPointerOptions = $.extend( rlPointerOptions, {
296 buttons: function( event, t ) {
297 var button = $( '<a id="rl-pointer-close" style="margin-left: 5px;" class="button-secondary">' + '<?php esc_html_e( $button1 ); ?>' + '</a>' );
298
299 button.on( 'click.pointer', function() {
300 t.element.pointer( 'close' );
301 } );
302
303 return button;
304 },
305 close: function() {}
306 } );
307
308 setup = function() {
309 $( '<?php echo esc_js( $selector ); ?>' ).pointer( rlPointerOptions ).pointer( 'open' );
310
311 <?php if ( $button2 ) { ?>
312
313 $( '#rl-pointer-close' ).after( '<a id="pointer-primary" class="button-primary">' + '<?php esc_html_e( $button2 ); ?>' + '</a>' );
314 $( '#pointer-primary' ).on( 'click', function() {
315 <?php echo $function; ?>
316 } );
317
318 <?php } ?>
319
320 $( '#rl-pointer-close' ).on( 'click', function() {
321 rlSetIgnore( 'tour', 'wp-pointer-0', '<?php echo esc_js( wp_create_nonce( 'rl-ignore-tour' ) ); ?>' );
322 } );
323 };
324
325 if ( rlPointerOptions.position && rlPointerOptions.position.defer_loading )
326 $( window ).on( 'load.wp-pointers', setup );
327 else
328 $( document ).ready( setup );
329 } );
330 } )( jQuery );
331 //]]>
332 </script>
333 <?php
334 }
335 }
336