PluginProbe ʕ •ᴥ•ʔ
Slider Ultimate / 2.0.8
Slider Ultimate v2.0.8
trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9
ultimate-slider / includes / InstallationWalkthrough.class.php
ultimate-slider / includes Last commit date
BackwardsCompatibility.class.php 4 years ago Blocks.class.php 4 years ago CustomPostTypes.class.php 4 years ago Dashboard.class.php 4 years ago DeactivationSurvey.class.php 4 years ago InstallationWalkthrough.class.php 4 years ago Permissions.class.php 4 years ago ReviewAsk.class.php 4 years ago Settings.class.php 4 years ago Widgets.class.php 4 years ago WooCommerceIntegration.class.php 4 years ago template-functions.php 4 years ago
InstallationWalkthrough.class.php
331 lines
1 <?php
2
3 /**
4 * Class to handle everything related to the walk-through that runs on plugin activation
5 */
6
7 if ( ! defined( 'ABSPATH' ) )
8 exit;
9
10 class ewdusInstallationWalkthrough {
11
12 public function __construct() {
13 add_action( 'admin_menu', array( $this, 'register_install_screen' ) );
14 add_action( 'admin_head', array( $this, 'hide_install_screen_menu_item' ) );
15 add_action( 'admin_init', array( $this, 'redirect' ), 9999 );
16
17 add_action( 'admin_head', array( $this, 'admin_enqueue' ) );
18
19 add_action( 'wp_ajax_us_welcome_add_slide', array( $this, 'create_slide' ) );
20 add_action( 'wp_ajax_us_welcome_add_slider_page', array( $this, 'add_slider_page' ) );
21 add_action( 'wp_ajax_us_welcome_set_options', array( $this, 'set_options' ) );
22 }
23
24 /**
25 * On activation, redirect the user if they haven't used the plugin before
26 * @since 2.0.0
27 */
28 public function redirect() {
29 if ( ! get_transient( 'ewd-us-getting-started' ) )
30 return;
31
32 delete_transient( 'ewd-us-getting-started' );
33
34 if ( is_network_admin() || isset( $_GET['activate-multi'] ) )
35 return;
36
37 if ( ! empty( get_posts( array( 'post_type' => EWD_US_SLIDER_POST_TYPE ) ) ) ) {
38 return;
39 }
40
41 wp_safe_redirect( admin_url( 'index.php?page=ewd-us-getting-started' ) );
42 exit;
43 }
44
45 /**
46 * Create the installation admin page
47 * @since 2.0.0
48 */
49 public function register_install_screen() {
50
51 add_dashboard_page(
52 esc_html__( 'Ultimate Slider - Welcome!', 'ultimate-slider' ),
53 esc_html__( 'Ultimate Slider - Welcome!', 'ultimate-slider' ),
54 'manage_options',
55 'ewd-us-getting-started',
56 array( $this, 'display_install_screen' )
57 );
58 }
59
60 /**
61 * Hide the installation admin page from the WordPress sidebar menu
62 * @since 2.0.0
63 */
64 public function hide_install_screen_menu_item() {
65
66 remove_submenu_page( 'index.php', 'ewd-us-getting-started' );
67 }
68
69 /**
70 * Create a new slide (image, title, description)
71 * @since 2.0.0
72 */
73 public function create_slide() {
74
75 $post_id = wp_insert_post( array(
76 'post_title' => isset( $_POST['slide_title'] ) ? sanitize_text_field( $_POST['slide_title'] ) : '',
77 'post_content' => isset( $_POST['slide_description'] ) ? '<!-- wp:paragraph --><p>' . sanitize_textarea_field( $_POST['slide_description'] ) . '</p><!-- /wp:paragraph -->' : '',
78 'post_status' => 'publish',
79 'post_type' => 'ultimate_slider'
80 ) );
81
82 if ( $post_id ) {
83
84 update_post_meta( $post_id, "EWD_US_Slide_Order", 999 );
85
86 $attachment_id = isset( $_POST['slide_image'] ) ? attachment_url_to_postid( esc_url_raw( $_POST['slide_image'] ) ) : false;
87 if ( $attachment_id ) {
88
89 set_post_thumbnail( $post_id, $attachment_id );
90 }
91 }
92
93 exit();
94 }
95
96 /**
97 * Add in a page with the slider shortcode
98 * @since 2.0.0
99 */
100 public function add_slider_page() {
101
102 $slider_page = wp_insert_post( array(
103 'post_title' => isset( $_POST['slider_page_title'] ) ? sanitize_text_field( $_POST['slider_page_title'] ) : '',
104 'post_content' => '<!-- wp:paragraph --><p> [ultimate-slider] </p><!-- /wp:paragraph -->',
105 'post_status' => 'publish',
106 'post_type' => 'page'
107 ) );
108
109 exit();
110 }
111
112 /**
113 * Set a number of key options selected during the walk-through process
114 * @since 2.0.0
115 */
116 public function set_options() {
117
118 $ewd_us_options = get_option( 'ewd-us-settings' );
119
120 if ( isset( $_POST['autoplay_slideshow'] ) ) { $ewd_us_options['autoplay-slideshow'] = $_POST['autoplay_slideshow'] == 'true' ? 1 : 0; }
121 if ( isset( $_POST['aspect_ratio'] ) ) { $ewd_us_options['aspect-ratio'] = sanitize_text_field( $_POST['aspect_ratio'] ); }
122 if ( isset( $_POST['carousel'] ) ) { $ewd_us_options['carousel'] = $_POST['carousel'] == 'true' ? 1 : 0; }
123 if ( isset( $_POST['slide_indicators'] ) ) { $ewd_us_options['slide-indicators'] = sanitize_text_field( $_POST['slide_indicators'] ); }
124 if ( isset( $_POST['timer_bar'] ) ) { $ewd_us_options['timer-bar'] = sanitize_text_field( $_POST['timer_bar'] ); }
125
126 update_option( 'ewd-us-settings', $ewd_us_options );
127
128 exit();
129 }
130
131 /**
132 * Enqueue the admin assets necessary to run the walk-through and display it nicely
133 * @since 2.0.0
134 */
135 public function admin_enqueue() {
136
137 if ( ! isset( $_GET['page'] ) or $_GET['page'] != 'ewd-us-getting-started' ) { return; }
138
139 wp_enqueue_style( 'ewd-us-admin-css', EWD_US_PLUGIN_URL . '/assets/css/admin.css', array(), EWD_US_VERSION );
140 wp_enqueue_style( 'ewd-us-sap-admin-css', EWD_US_PLUGIN_URL . '/lib/simple-admin-pages/css/admin.css', array(), EWD_US_VERSION );
141 wp_enqueue_style( 'ewd-us-welcome-screen', EWD_US_PLUGIN_URL . '/assets/css/ewd-us-welcome-screen.css', array(), EWD_US_VERSION );
142 wp_enqueue_style( 'ewd-us-admin-settings-css', EWD_US_PLUGIN_URL . '/lib/simple-admin-pages/css/admin-settings.css', array(), EWD_US_VERSION );
143
144 wp_enqueue_script( 'ewd-us-getting-started', EWD_US_PLUGIN_URL . '/assets/js/ewd-us-welcome-screen.js', array( 'jquery' ), EWD_US_VERSION );
145 wp_enqueue_script( 'ewd-us-admin-settings-js', EWD_US_PLUGIN_URL . '/lib/simple-admin-pages/js/admin-settings.js', array( 'jquery' ), EWD_US_VERSION );
146 wp_enqueue_script( 'ewd-us-admin-spectrum-js', EWD_US_PLUGIN_URL . '/lib/simple-admin-pages/js/spectrum.js', array( 'jquery' ), EWD_US_VERSION );
147 }
148
149 /**
150 * Output the HTML of the walk-through screen
151 * @since 2.0.0
152 */
153 public function display_install_screen() { ?>
154
155 <div class='ewd-us-welcome-screen'>
156
157 <div class='ewd-us-welcome-screen-header'>
158 <h1><?php _e( 'Welcome to the Ultimate Slider Plugin', 'ultimate-slider' ); ?></h1>
159 <p><?php _e( 'Thanks for choosing the Ultimate Slider! The following will help you get started with the plugin, by choosing which images the slider should be displayed for as well as the look of the slider.', 'ultimate-slider' ); ?></p>
160 </div>
161
162 <div class='ewd-us-welcome-screen-box ewd-us-welcome-screen-add_slides ewd-us-welcome-screen-open' data-screen='add_slides'>
163 <h2><?php _e( '1. Add Slides', 'ultimate-slider' ); ?></h2>
164 <div class='ewd-us-welcome-screen-box-content'>
165 <table class='form-table ewd-us-welcome-screen-created-slides'>
166 <tr class='ewd-us-welcome-screen-add-slide-image ewd-us-welcome-screen-box-content-divs'>
167 <th scope='row'><?php _e( 'Slide Image', 'ultimate-slider' ); ?></th>
168 <td class='ewd-us-welcome-screen-option ewd-us-welcome-screen-image-preview-container'>
169 <div class='ewd-us-hidden ewd-us-welcome-screen-image-preview'>
170 <img>
171 </div>
172 <input type='hidden' name='slide_image_url'>
173 <input id="welcome_slide_image_button" class="button" type="button" value="Upload Image">
174 </td>
175 </tr>
176 <tr class='ewd-us-welcome-screen-add-slide-title ewd-us-welcome-screen-box-content-divs'>
177 <th scope='row'><?php _e( 'Slide Title', 'ultimate-slider' ); ?></th>
178 <td class='ewd-us-welcome-screen-option'>
179 <input type='text'>
180 </td>
181 </tr>
182 <tr class='ewd-us-welcome-screen-add-slide-description ewd-us-welcome-screen-box-content-divs'>
183 <th scope='row'><?php _e( 'Description', 'ultimate-slider' ); ?></th>
184 <td class='ewd-us-welcome-screen-option'>
185 <textarea></textarea>
186 </td>
187 </tr>
188 <tr>
189 <th scope='row'></th>
190 <td>
191 <div class='ewd-us-welcome-screen-add-slide-button'><?php _e( 'Add Slide', 'ultimate-slider' ); ?></div>
192 </td>
193 </tr>
194 <tr></tr>
195 <tr>
196 <td colspan="2">
197 <h3><?php _e( 'Created Slides', 'ultimate-slider' ); ?></h3>
198 <table class="ewd-us-welcome-screen-show-created-slides">
199 <tr>
200 <th class="ewd-us-welcome-screen-show-created-slides-image"><?php _e( 'Image', 'ultimate-slider' ); ?></th>
201 <th class="ewd-us-welcome-screen-show-created-slides-title"><?php _e( 'Name', 'ultimate-slider' ); ?></th>
202 <th class="ewd-us-welcome-screen-show-created-slides-description"><?php _e( 'Description', 'ultimate-slider' ); ?></th>
203 </tr>
204 </table>
205 </td>
206 </tr>
207 </table>
208
209 <div class="ewd-us-welcome-clear"></div>
210 <div class='ewd-us-welcome-screen-next-button' data-nextaction='slider_page'><?php _e( 'Next Step', 'ultimate-slider' ); ?></div>
211 <div class='clear'></div>
212 </div>
213 </div>
214
215 <div class='ewd-us-welcome-screen-box ewd-us-welcome-screen-slider_page' data-screen='slider_page'>
216 <h2><?php _e( '2. Add a Slider Page', 'ultimate-slider' ); ?></h2>
217 <div class='ewd-us-welcome-screen-box-content'>
218 <p><?php _e( 'You can create a dedicated page for your slider below, or skip this step and add your slider to a page you\'ve already created manually.', 'ultimate-slider' ); ?></p>
219 <table class='form-table ewd-us-welcome-screen-menu-page'>
220 <tr class='ewd-us-welcome-screen-add-slider-page-name ewd-us-welcome-screen-box-content-divs'>
221 <th scope='row'><?php _e( 'Page Title', 'ultimate-slider' ); ?></th>
222 <td class='ewd-us-welcome-screen-option'>
223 <input type='text' value='Slider'>
224 </td>
225 </tr>
226 <tr>
227 <th scope='row'></th>
228 <td>
229 <div class='ewd-us-welcome-screen-add-slider-page-button' data-nextaction='options'><?php _e( 'Create Page', 'ultimate-slider' ); ?></div>
230 </td>
231 </tr>
232 </table>
233
234 <div class="ewd-us-welcome-clear"></div>
235 <div class='ewd-us-welcome-screen-next-button' data-nextaction='options'><?php _e( 'Next Step', 'ultimate-slider' ); ?></div>
236 <div class='ewd-us-welcome-screen-previous-button' data-previousaction='add_slides'><?php _e( 'Previous Step', 'ultimate-slider' ); ?></div>
237 <div class='clear'></div>
238 </div>
239 </div>
240
241 <div class='ewd-us-welcome-screen-box ewd-us-welcome-screen-options' data-screen='options'>
242 <h2><?php _e( '3. Key Options', 'ultimate-slider' ); ?></h2>
243 <div class='ewd-us-welcome-screen-box-content'>
244 <table class="form-table">
245 <tr>
246 <th scope='row'><?php _e( 'Autoplay Slides', 'ultimate-slider' ); ?></th>
247 <td class='ewd-us-welcome-screen-option'>
248 <fieldset>
249 <div class="sap-admin-hide-radios">
250 <input type='checkbox' name='autoplay_slideshow' value='1'>
251 </div>
252 <label class="sap-admin-switch">
253 <input type="checkbox" class="sap-admin-option-toggle" data-inputname="autoplay_slideshow" checked="checked">
254 <span class="sap-admin-switch-slider round"></span>
255 </label>
256 </fieldset>
257 </td>
258 </tr>
259
260 <tr>
261 <th scope='row'><?php _e( 'Show Timer Bar', 'ultimate-slider' ); ?></th>
262 <td class='ewd-us-welcome-screen-option'>
263 <fieldset>
264 <label title='Top' class='sap-admin-input-container'><input type='radio' name='timer_bar' value='top'><span class='sap-admin-radio-button'></span> <span><?php _e( 'Top', 'ultimate-slider' )?></span></label><br>
265 <label title='Bottom' class='sap-admin-input-container'><input type='radio' name='timer_bar' value='bottom' checked><span class='sap-admin-radio-button'></span> <span><?php _e( 'Bottom', 'ultimate-slider' )?></span></label><br>
266 <label title='Off' class='sap-admin-input-container'><input type='radio' name='timer_bar' value='off'><span class='sap-admin-radio-button'></span> <span><?php _e( 'Off', 'ultimate-slider' )?></span></label><br>
267 </fieldset>
268 </td>
269 </tr>
270
271 <tr>
272 <th scope='row'><?php _e( 'Carousel Mode', 'ultimate-slider' ); ?></th>
273 <td class='ewd-us-welcome-screen-option'>
274 <fieldset>
275 <div class="sap-admin-hide-radios">
276 <input type='checkbox' name='carousel' value='1'>
277 </div>
278 <label class="sap-admin-switch">
279 <input type="checkbox" class="sap-admin-option-toggle" data-inputname="carousel" checked="checked">
280 <span class="sap-admin-switch-slider round"></span>
281 </label>
282 </fieldset>
283 </td>
284 </tr>
285
286 <tr>
287 <th scope='row'><?php _e( 'Aspect Ratio', 'ultimate-slider' ); ?></th>
288 <td class='ewd-us-welcome-screen-option'>
289 <select name='aspect_ratio'>
290 <option value='3_1'>3:1</option>
291 <option value='16_7' selected>16:7</option>
292 <option value='2_1'>2:1</option>
293 <option value='16_9'>16:9</option>
294 <option value='3_2'>3:2</option>
295 <option value='4_3'>4:3</option>
296 <option value='1_1'>1:1</option>
297 </select>
298 </td>
299 </tr>
300
301 <tr>
302 <th scope='row'><?php _e( 'Slide Indicators', 'ultimate-slider' ); ?></th>
303 <td class='ewd-us-welcome-screen-option'>
304 <fieldset>
305 <label title='None' class='sap-admin-input-container'><input type='radio' name='slide_indicators' value='none'><span class='sap-admin-radio-button'></span> <span><?php _e( 'None', 'ultimate-slider' )?></span></label><br>
306 <label title='Dots' class='sap-admin-input-container'><input type='radio' name='slide_indicators' value='dots' checked><span class='sap-admin-radio-button'></span> <span><?php _e( 'Dots', 'ultimate-slider' )?></span></label><br>
307 <label title='Thumbnails' class='sap-admin-input-container'><input type='radio' name='slide_indicators' value='thumbnails'><span class='sap-admin-radio-button'></span> <span><?php _e( 'Thumbnails', 'ultimate-slider' )?></span></label><br>
308 <label title='Side Thumbnails' class='sap-admin-input-container'><input type='radio' name='slide_indicators' value='sidethumbnails'><span class='sap-admin-radio-button'></span> <span><?php _e( 'Side Thumbnails', 'ultimate-slider' )?></span></label><br>
309 </fieldset>
310 </td>
311 </tr>
312 </table>
313
314 <div class='ewd-us-welcome-screen-save-options-button'><?php _e( 'Save Options', 'ultimate-slider' ); ?></div>
315 <div class="ewd-us-welcome-clear"></div>
316 <div class='ewd-us-welcome-screen-previous-button' data-previousaction='add_slider'><?php _e( 'Previous Step', 'ultimate-slider' ); ?></div>
317 <div class='ewd-us-welcome-screen-finish-button'><a href='admin.php?page=ewd-us-settings'><?php _e('Finish', 'ultimate-slider'); ?></a></div>
318 <div class='clear'></div>
319 </div>
320 </div>
321
322 <div class='ewd-us-welcome-screen-skip-container'>
323 <a href='admin.php?page=ewd-us-settings'><div class='ewd-us-welcome-screen-skip-button'><?php _e( 'Skip Setup', 'ultimate-slider' ); ?></div></a>
324 </div>
325 </div>
326
327 <?php }
328 }
329
330
331 ?>