PluginProbe ʕ •ᴥ•ʔ
Responsive Lightbox & Gallery / 2.0
Responsive Lightbox & Gallery v2.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
class-frontend.php 8 years ago class-galleries.php 8 years ago class-settings.php 8 years ago class-tour.php 8 years ago class-welcome.php 8 years ago class-widgets.php 8 years ago functions.php 8 years ago
class-tour.php
288 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 public function __construct() {
16 // actions
17 add_action( 'admin_menu', array( $this, 'admin_menu' ) );
18 add_action( 'admin_init', array( $this, 'init_tour' ) );
19 add_action( 'wp_ajax_rl-ignore-tour', array( $this, 'ignore_tour' ) );
20 }
21
22 /**
23 * Initialize tour.
24 */
25 public function init_tour() {
26 if ( ! current_user_can( apply_filters( 'rl_lightbox_settings_capability', 'manage_options' ) ) )
27 return;
28
29 global $pagenow;
30
31 if ( $pagenow === 'admin.php' && isset( $_GET['page'] ) && $_GET['page'] === 'responsive-lightbox-tour' ) {
32 set_transient( 'rl_active_tour', 1, 0 );
33
34 if ( Responsive_Lightbox()->options['builder']['gallery_builder'] )
35 wp_redirect( admin_url( 'edit.php?post_type=rl_gallery' ) );
36 else
37 wp_redirect( admin_url( 'admin.php?page=responsive-lightbox-settings' ) );
38
39 exit;
40 }
41
42 if ( (int) get_transient( 'rl_active_tour' ) === 1 ) {
43 add_action( 'admin_enqueue_scripts', array( $this, 'tour_scripts_styles' ) );
44 add_action( 'admin_print_footer_scripts', array( $this, 'start_tour' ) );
45 }
46 }
47
48 /**
49 * Add temporary admin menu.
50 */
51 public function admin_menu() {
52 global $pagenow;
53
54 if ( $pagenow === 'admin.php' && isset( $_GET['page'] ) && $_GET['page'] === 'responsive-lightbox-tour' )
55 add_submenu_page( 'responsive-lightbox-settings', '', '', apply_filters( 'rl_lightbox_settings_capability', 'manage_options' ), 'responsive-lightbox-tour', array( $this, 'temporary_submenu' ) );
56 }
57
58 /**
59 *
60 */
61 function temporary_submenu() {
62 // nothing to do here
63 }
64
65 /**
66 * Load pointer scripts.
67 */
68 public function tour_scripts_styles() {
69 wp_enqueue_style( 'wp-pointer' );
70 wp_enqueue_script( 'jquery-ui' );
71 wp_enqueue_script( 'wp-pointer' );
72 wp_enqueue_script( 'utils' );
73 }
74
75 /**
76 * Load the introduction tour.
77 */
78 public function start_tour() {
79 global $pagenow;
80
81 $pointer = array();
82
83 // galleries
84 if ( $pagenow === 'edit.php' ) {
85 if ( isset( $_GET['post_type'] ) && $_GET['post_type'] === 'rl_gallery' && Responsive_Lightbox()->options['builder']['gallery_builder'] ) {
86 $pointer = array(
87 'content' => '<h3>' . __( 'Gallery Builder', 'responsive-lightbox' ) . '</h3>' .
88 '<p>' . __( '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>',
89 'button2' => __( 'Next', 'responsive-lightbox' ),
90 'id' => '#wpbody-content h1'
91 );
92
93 // next categories?
94 if ( Responsive_Lightbox()->options['builder']['categories'] )
95 $pointer['function'] = 'window.location="' . admin_url( 'edit-tags.php?taxonomy=rl_category&post_type=rl_gallery' ) . '";';
96 // next tags?
97 elseif ( Responsive_Lightbox()->options['builder']['tags'] )
98 $pointer['function'] = 'window.location="' . admin_url( 'edit-tags.php?taxonomy=rl_tag&post_type=rl_gallery' ) . '";';
99 // or settings?
100 else
101 $pointer['function'] = 'window.location="' . admin_url( 'admin.php?page=responsive-lightbox-settings' ) . '";';
102 }
103 // gallery taxonomies
104 } elseif ( $pagenow === 'edit-tags.php' ) {
105 if ( isset( $_GET['taxonomy'], $_GET['post_type'] ) && $_GET['post_type'] === 'rl_gallery' ) {
106 if ( $_GET['taxonomy'] === 'rl_category' ) {
107 $pointer = array(
108 'content' => '<h3>' . __( 'Gallery Categories', 'responsive-lightbox' ) . '</h3>' .
109 '<p>' . __( '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>',
110 'button2' => __( 'Next', 'responsive-lightbox' ),
111 'id' => '#wpbody-content h1'
112 );
113
114 // next tags?
115 if ( Responsive_Lightbox()->options['builder']['tags'] )
116 $pointer['function'] = 'window.location="' . admin_url( 'edit-tags.php?taxonomy=rl_tag&post_type=rl_gallery' ) . '";';
117 // or settings?
118 else
119 $pointer['function'] = 'window.location="' . admin_url( 'admin.php?page=responsive-lightbox-settings' ) . '";';
120 } elseif ( $_GET['taxonomy'] === 'rl_tag' ) {
121 $pointer = array(
122 'content' => '<h3>' . __( 'Gallery Tags', 'responsive-lightbox' ) . '</h3>' .
123 '<p>' . __( '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>',
124 'button2' => __( 'Next', 'responsive-lightbox' ),
125 'id' => '#wpbody-content h1',
126 'function' => 'window.location="' . admin_url( 'admin.php?page=responsive-lightbox-settings' ) . '";'
127 );
128 }
129 }
130 // settings
131 } elseif ( $pagenow === 'admin.php' && isset( $_GET['page'] ) ) {
132 // general
133 if ( $_GET['page'] === 'responsive-lightbox-settings' ) {
134 $pointer = array(
135 'content' => '<h3>' . __( 'General Settings', 'responsive-lightbox' ) . '</h3>' .
136 '<p>' . __( "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 with its settings.", 'responsive-lightbox' ) . '</p>',
137 'button2' => __( 'Next', 'responsive-lightbox' ),
138 'id' => '#wpbody-content .wrap h2:first',
139 'function' => 'window.location="' . admin_url( 'admin.php?page=responsive-lightbox-configuration' ) . '";'
140 );
141 } elseif ( $_GET['page'] === 'responsive-lightbox-configuration' ) {
142 // get additional plugins based on tabs
143 $plugins = array_values( array_diff( array_keys( Responsive_Lightbox()->settings->tabs ), array( 'settings', 'configuration', 'gallery', 'builder', 'licenses', 'addons' ) ) );
144
145 if ( ! empty( $plugins ) ) {
146 // get first plugin tab key
147 $plugin_key = $plugins[0];
148 } else
149 $plugin_key = 'gallery';
150
151 $pointer = array(
152 'content' => '<h3>' . __( 'Lightboxe Settings', 'responsive-lightbox' ) . '</h3>' .
153 '<p>' . __( '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>',
154 'button2' => __( 'Next', 'responsive-lightbox' ),
155 'id' => '#wpbody-content .wrap h2:first',
156 'function' => 'window.location="' . admin_url( 'admin.php?page=responsive-lightbox-' . $plugin_key ) . '";'
157 );
158 } elseif ( $_GET['page'] === 'responsive-lightbox-gallery' ) {
159 $pointer = array(
160 'content' => '<h3>' . __( 'Gallery Settings', 'responsive-lightbox' ) . '</h3>' .
161 '<p>' . __( "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>',
162 'button2' => __( 'Next', 'responsive-lightbox' ),
163 'id' => '#wpbody-content .wrap h2:first',
164 'function' => 'window.location="' . admin_url( 'admin.php?page=responsive-lightbox-builder' ) . '";'
165 );
166 } elseif ( $_GET['page'] === 'responsive-lightbox-builder' ) {
167 $pointer = array(
168 'content' => '<h3>' . __( 'Builder Settings', 'responsive-lightbox' ) . '</h3>' .
169 '<p>' . __( '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>',
170 'button2' => __( 'Next', 'responsive-lightbox' ),
171 'id' => '#wpbody-content .wrap h2:first',
172 'function' => 'window.location="' . admin_url( 'admin.php?page=responsive-lightbox-' . ( ! empty( Responsive_Lightbox()->settings->tabs['licenses'] ) ? 'licenses' : 'addons' ) ) . '";'
173 );
174 } elseif ( $_GET['page'] === 'responsive-lightbox-licenses' ) {
175 $pointer = array(
176 'content' => '<h3>' . __( 'License Settings', 'responsive-lightbox' ) . '</h3>' .
177 '<p>' . __( '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>',
178 'button2' => __( 'Next', 'responsive-lightbox' ),
179 'id' => '#wpbody-content .wrap h2:first',
180 'function' => 'window.location="' . admin_url( 'admin.php?page=responsive-lightbox-addons' ) . '";'
181 );
182 } elseif ( $_GET['page'] === 'responsive-lightbox-addons' ) {
183 $pointer = array(
184 'content' => '<h3>' . __( 'Add-ons', 'responsive-lightbox' ) . '</h3>' .
185 '<p>' . __( 'Responsive Lightbox & Gallery is more that 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>',
186 'button2' => '',
187 'id' => '#wpbody-content .wrap h2:first',
188 'function' => ''
189 );
190 // plugins related tabs
191 } else {
192 $pointer = apply_filters( 'rl_tour_pointer', array(), esc_attr( $_GET['page'] ) );
193 }
194 }
195
196 // valid pointer?
197 if ( ! empty( $pointer ) ) {
198 $valid_pointer = array(
199 'content' => $pointer['content'],
200 'position' => array(
201 'edge' => 'top',
202 'align' => is_rtl() ? 'right' : 'left'
203 ),
204 'pointerWidth' => 400,
205 );
206
207 $this->print_scripts( $pointer['id'], $valid_pointer, __( 'Close', 'responsive-lightbox' ), $pointer['button2'], $pointer['function'] );
208 }
209 }
210
211 /**
212 * Ignore tour.
213 */
214 public function ignore_tour() {
215 if ( isset( $_POST['rl_nonce'] ) && wp_verify_nonce( $_POST['rl_nonce'], 'rl-ignore-tour' ) !== false )
216 delete_transient( 'rl_active_tour' );
217
218 exit;
219 }
220
221 /**
222 * Prints the pointer script
223 */
224 public function print_scripts( $selector, $options, $button1, $button2 = false, $button2_function = '', $button1_function = '' ) {
225 ?>
226 <script type="text/javascript">
227 //<![CDATA[
228 ( function ( $ ) {
229 $( document ).ready( function ( $ ) {
230 var rl_pointer_options = <?php echo json_encode( $options ); ?>,
231 setup;
232
233 function rl_set_ignore( option, hide, nonce ) {
234 $.post( ajaxurl, {
235 action: 'rl-ignore-tour',
236 rl_nonce: nonce
237 }, function ( data ) {
238 if ( data ) {
239 $( '#' + hide ).hide();
240 $( '#hidden_ignore_' + option ).val( 'ignore' );
241 }
242 }
243 );
244 }
245
246 rl_pointer_options = $.extend( rl_pointer_options, {
247 buttons: function ( event, t ) {
248 var button = $( '<a id="rl-pointer-close" style="margin-left: 5px;" class="button-secondary">' + '<?php echo $button1; ?>' + '</a>' );
249
250 button.bind( 'click.pointer', function () {
251 t.element.pointer( 'close' );
252 } );
253
254 return button;
255 },
256 close: function () {}
257 } );
258
259 setup = function () {
260 $( '<?php echo $selector; ?>' ).pointer( rl_pointer_options ).pointer( 'open' );
261
262 <?php if ( $button2 ) { ?>
263
264 $( '#rl-pointer-close' ).after( '<a id="pointer-primary" class="button-primary">' + '<?php echo $button2; ?>' + '</a>' );
265 $( '#pointer-primary' ).click( function () {
266 <?php echo $button2_function; ?>
267 } );
268
269 <?php } ?>
270
271 $( '#rl-pointer-close' ).click( function () {
272 rl_set_ignore( 'tour', 'wp-pointer-0', '<?php echo esc_js( wp_create_nonce( 'rl-ignore-tour' ) ); ?>' );
273 } );
274 };
275
276 if ( rl_pointer_options.position && rl_pointer_options.position.defer_loading )
277 $( window ).bind( 'load.wp-pointers', setup );
278 else
279 $( document ).ready( setup );
280 } );
281 } )( jQuery );
282 //]]>
283 </script>
284 <?php
285 }
286
287 }
288