PluginProbe
Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls / 6.3.4
Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls v6.3.4
6.4.9 6.4.8 6.4.7 6.4.6 6.4.5 6.4.4 6.4.3 6.4.2 6.4.1 6.4.0 6.3.9 6.3.8 6.3.7 6.3.6 6.3.5 6.3.4 6.3.3 5.6.0 5.6.1 5.6.2 5.6.3 5.6.4 5.6.5 5.6.6 5.6.7 All 152 releases
poll-maker / includes / class-poll-maker-ays-welcome.php

class-poll-maker-ays-welcome.php in Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls 6.3.4, at includes/class-poll-maker-ays-welcome.php

408 lines 21.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class Poll_Maker_Ays_Welcome {
4
5 /**
6 * Hidden welcome page slug.
7 *
8 * @since 4.6.4
9 */
10 const SLUG = 'poll-maker-getting-started';
11
12 /**
13 * Primary class constructor.
14 *
15 * @since 4.6.4
16 */
17 public function __construct() {
18 add_action( 'plugins_loaded', [ $this, 'hooks' ] );
19 }
20
21 public function hooks() {
22 add_action( 'admin_menu', [ $this, 'register' ] );
23 add_action( 'admin_head', [ $this, 'hide_menu' ] );
24 add_action( 'admin_init', [ $this, 'redirect' ], 9999 );
25 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_styles' ], 10, 1 );
26 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
27 }
28
29 /**
30 * Register the pages to be used for the Welcome screen (and tabs).
31 *
32 * These pages will be removed from the Dashboard menu, so they will
33 * not actually show. Sneaky, sneaky.
34 *
35 * @since 1.0.0
36 */
37 public function register() {
38
39 add_dashboard_page(
40 esc_html__( 'Welcome to Poll Maker', "poll-maker" ),
41 esc_html__( 'Welcome to Poll Maker', "poll-maker" ),
42 'manage_options',
43 self::SLUG,
44 [ $this, 'output' ]
45 );
46 }
47
48 /**
49 * Removed the dashboard pages from the admin menu.
50 *
51 * This means the pages are still available to us, but hidden.
52 *
53 * @since 4.6.4
54 */
55 public function hide_menu() {
56
57 remove_submenu_page( 'index.php', self::SLUG );
58 }
59
60 /**
61 * Welcome screen redirect.
62 *
63 * This function checks if a new install or update has just occurred. If so,
64 * then we redirect the user to the appropriate page.
65 *
66 * @since 4.6.4
67 */
68 public function redirect() {
69
70 $current_page = isset( $_GET['page'] ) ? $_GET['page'] : '';
71
72 // Check if we are already on the welcome page.
73 if ( $current_page === self::SLUG ) {
74 return;
75 }
76
77 // Get the activation status
78 $first_activation = get_option('ays_poll_maker_first_time_activation_page', false);
79
80 // Check if we're in a multisite environment
81 if (function_exists('is_multisite') && is_multisite()) {
82 // Get current blog ID
83 $blog_id = get_current_blog_id();
84
85 // Use a blog-specific option name to track activation for each site
86 $blog_specific_option = 'ays_poll_maker_first_time_activation_page_blog_' . $blog_id;
87 $blog_first_activation = get_option($blog_specific_option, null);
88
89 // If blog-specific option doesn't exist yet, set it based on the main option
90 if ($blog_first_activation === null) {
91 update_option($blog_specific_option, $first_activation);
92 $first_activation = $first_activation;
93 } else {
94 // Use the blog-specific activation status
95 $first_activation = $blog_first_activation;
96 }
97 }
98
99 if (isset($_GET['page']) && strpos($_GET['page'], POLL_MAKER_AYS_NAME) !== false && $first_activation) {
100 wp_safe_redirect( admin_url( 'index.php?page=' . self::SLUG ) );
101 exit;
102 }
103 }
104
105 /**
106 * Enqueue custom CSS styles for the welcome page.
107 *
108 * @since 4.6.4
109 */
110 public function enqueue_styles( $hook ) {
111
112 if (strpos( $hook, 'poll-maker-ays-dashboard' ) === false && strpos( $hook, 'poll-maker-getting-started' ) === false) {
113 return;
114 }
115
116 wp_enqueue_style(
117 'poll-maker-ays-welcome-css',
118 esc_url(POLL_MAKER_AYS_ADMIN_URL) . '/css/poll-maker-ays-welcome.css',
119 array(), false, 'all'
120 );
121 }
122
123
124 /**
125 * Register the JavaScript for the welcome page.
126 *
127 * @since 4.6.4
128 */
129 public function enqueue_scripts() {
130
131 wp_enqueue_script( 'poll-maker-ays-welcome', esc_url(POLL_MAKER_AYS_ADMIN_URL) . '/js/poll-maker-ays-welcome.js', array('jquery'), false, true);
132 wp_localize_script( 'poll-maker-ays-welcome', 'poll_maker_ays_welcome', array(
133 'show_more' => esc_html__( 'Show More', "poll-maker" ),
134 'show_less' => esc_html__( 'Show Less', "poll-maker" ),
135 ) );
136 }
137
138 private function get_latest_changelog_entries($limit = 3) {
139 $readme_path = plugin_dir_path(__FILE__) . '../README.txt';
140 if ( ! file_exists( $readme_path ) ) {
141 return array();
142 }
143
144 $content = file_get_contents( $readme_path );
145
146 // Extract only the Changelog section
147 if ( preg_match( '/==\s*Changelog\s*==(.*)/is', $content, $matches ) ) {
148 $changelog = trim($matches[1]);
149 } else {
150 return array();
151 }
152
153 // Split each version entry
154 preg_match_all( '/=+\s*(.*?)\s*=+\s*(.*?)(?=(?:=+\s*[\d\.]+|\Z))/is', $changelog, $entries, PREG_SET_ORDER );
155
156 $releases = array();
157 foreach ( $entries as $entry ) {
158 $title = trim($entry[1]);
159 $changes = trim($entry[2]);
160
161 // Extract version and date if available
162 if ( preg_match('/([\d\.]+).*?\((.*?)\)/', $title, $version_match) ) {
163 $version = trim($version_match[1]);
164 $date = trim($version_match[2]);
165 } else {
166 $version = $title;
167 $date = '';
168 }
169
170 // Split lines like * Added: Something
171 $lines = array_filter(array_map('trim', preg_split('/\r\n|\r|\n/', $changes)));
172 $lines = array_map(function($line) {
173 return preg_replace('/^\*\s*/', '', $line);
174 }, $lines);
175
176 $releases[] = array(
177 'version' => $version,
178 'date' => $date,
179 'changes' => $lines,
180 );
181 }
182
183 return array_slice($releases, 0, $limit);
184 }
185
186 /**
187 * Getting Started screen. Shows after first install.
188 *
189 * @since 1.0.0
190 */
191 public function output($hide_close_button = false) {
192
193 $latest_changelog = $this->get_latest_changelog_entries(3);
194
195 ?>
196 <div class="ays-pm-w-container">
197 <!-- Header -->
198 <section class="ays-pm-w-section ays-pm-w-header-wrapper ays-pm-w-text-center">
199 <div class="ays-pm-w-header-dismiss" <?php if($hide_close_button) echo 'style="display: none"'; ?>>
200 <a href="<?php echo admin_url( 'admin.php?page=' . POLL_MAKER_AYS_NAME ) ?> ">
201 <img src="<?php echo esc_url(POLL_MAKER_AYS_ADMIN_URL); ?>/images/icons/close.svg" alt="<?php echo esc_html__( 'Close', "poll-maker" ); ?>">
202 </a>
203 </div>
204 <div class="ays-pm-w-header-icon">
205 <img src="<?php echo esc_url(POLL_MAKER_AYS_ADMIN_URL) . '/images/icons/poll-maker-logo.png'?>" alt="poll-w-logo">
206 </div>
207 <h1 class="ays-pm-w-header-title"><?php echo esc_html__( 'Welcome to Poll Maker', "poll-maker" ); ?></h1>
208 <p class="ays-pm-w-header-desc"><?php echo esc_html__( 'Thank you for choosing Poll Maker — the best poll and survey plugin for WordPress', "poll-maker" ); ?></p>
209 <div class="ays-pm-w-header-create">
210 <a href="<?php echo esc_url( admin_url( 'admin.php?page=' . POLL_MAKER_AYS_NAME . "&action=add") ); ?>" class="poll-maker-btn poll-maker-btn-block poll-maker-btn-lg poll-maker-btn-orange">
211 <?php echo esc_html__( 'Create Your First Poll', "poll-maker" ); ?>
212 </a>
213 </div>
214 </section>
215
216 <!-- Quick Start Steps -->
217 <section class="ays-pm-w-section">
218 <div class="ays-pm-w-text-center">
219 <h2 class="ays-pm-w-header-title" style="font-size:1.5rem;"><?php echo esc_html__( 'Get Started in a Few Steps', "poll-maker" ); ?></h2>
220 <p class="ays-pm-w-header-desc" style="font-size:1rem;"><?php echo esc_html__( 'Follow these simple steps to create your first poll', "poll-maker" ); ?></p>
221 </div>
222
223 <div class="ays-pm-w-steps-wrapper" style="margin-top:2rem;">
224 <!-- Step 1 -->
225 <div class="ays-pm-w-step-item">
226 <div class="ays-pm-w-step-number"><?php echo esc_html__( 'Step 1', "poll-maker" ); ?></div>
227 <div class="ays-pm-w-step-content">
228 <h3><?php echo esc_html__( 'Add a New Poll', "poll-maker" ); ?></h3>
229 </div>
230 </div>
231 <!-- Step 2 -->
232 <div class="ays-pm-w-step-item">
233 <div class="ays-pm-w-step-number"><?php echo esc_html__( 'Step 2', "poll-maker" ); ?></div>
234 <div class="ays-pm-w-step-content">
235 <h3><?php echo esc_html__( 'Add Options', "poll-maker" ); ?></h3>
236 </div>
237 </div>
238 <!-- Step 3 -->
239 <div class="ays-pm-w-step-item">
240 <div class="ays-pm-w-step-number"><?php echo esc_html__( 'Step 3', "poll-maker" ); ?></div>
241 <div class="ays-pm-w-step-content">
242 <h3><?php echo esc_html__( 'Save the Poll', "poll-maker" ); ?></h3>
243 </div>
244 </div>
245 <!-- Step 4 -->
246 <div class="ays-pm-w-step-item">
247 <div class="ays-pm-w-step-number"><?php echo esc_html__( 'Step 4', "poll-maker" ); ?></div>
248 <div class="ays-pm-w-step-content">
249 <h3><?php echo esc_html__( 'Copy the Shortcode', "poll-maker" ); ?></h3>
250 </div>
251 </div>
252 </div>
253 </section>
254
255 <!-- Video Tutorials -->
256 <section class="ays-pm-w-section">
257 <div class="ays-pm-w-text-center">
258 <h2 class="ays-pm-w-header-title" style="font-size:1.5rem;"><?php echo esc_html__( 'Learn with Video', "poll-maker" ); ?></h2>
259 <p class="ays-pm-w-header-desc" style="font-size:1rem;"><?php echo esc_html__( 'Watch these quick tutorials to master Poll Maker', "poll-maker" ); ?></p>
260 </div>
261
262 <div class="ays-pm-w-video-grid" style="margin-top:2rem;">
263 <!-- Video 1 -->
264 <div class="ays-pm-w-video-card" data-video-id="8Z4aJ0jhSa8">
265 <div class="ays-pm-w-video-thumb">
266 <img src="https://img.youtube.com/vi/8Z4aJ0jhSa8/hqdefault.jpg" alt="Getting Started with Poll Maker">
267 <div class="ays-pm-w-video-overlay">
268 <div class="ays-pm-w-play-btn">
269 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="18" height="18" style="margin-left:3px">
270 <polygon points="6 4 20 12 6 20 6 4"></polygon>
271 </svg>
272 </div>
273 </div>
274 <span class="ays-pm-w-video-duration">1:18</span>
275 </div>
276 <div class="ays-pm-w-video-title"><?php echo esc_html__( 'WordPress Poll Plugin', "poll-maker" ); ?></div>
277 </div>
278
279 <!-- Video 2 -->
280 <div class="ays-pm-w-video-card" data-video-id="JrTkFtliTVQ">
281 <div class="ays-pm-w-video-thumb">
282 <img src="https://img.youtube.com/vi/JrTkFtliTVQ/hqdefault.jpg" alt="Advanced Poll Customization">
283 <div class="ays-pm-w-video-overlay">
284 <div class="ays-pm-w-play-btn">
285 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="18" height="18" style="margin-left:3px">
286 <polygon points="6 4 20 12 6 20 6 4"></polygon>
287 </svg>
288 </div>
289 </div>
290 <span class="ays-pm-w-video-duration">2:00</span>
291 </div>
292 <div class="ays-pm-w-video-title"><?php echo esc_html__( 'Best Way to Create WordPress Anonymous Poll', "poll-maker" ); ?></div>
293 </div>
294
295 <!-- Video 3 -->
296 <div class="ays-pm-w-video-card" data-video-id="y9yu9Md4vCs">
297 <div class="ays-pm-w-video-thumb">
298 <img src="https://img.youtube.com/vi/y9yu9Md4vCs/hqdefault.jpg" alt="Embedding Polls on Your Site">
299 <div class="ays-pm-w-video-overlay">
300 <div class="ays-pm-w-play-btn">
301 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="18" height="18" style="margin-left:3px">
302 <polygon points="6 4 20 12 6 20 6 4"></polygon>
303 </svg>
304 </div>
305 </div>
306 <span class="ays-pm-w-video-duration">3:26</span>
307 </div>
308 <div class="ays-pm-w-video-title"><?php echo esc_html__( 'How to Create a Password Protected Poll', "poll-maker" ); ?></div>
309 </div>
310 </div>
311 </section>
312
313 <!-- Useful Resources -->
314 <section class="ays-pm-w-section">
315 <div class="ays-pm-w-text-center">
316 <h2 class="ays-pm-w-header-title" style="font-size:1.5rem;"><?php echo esc_html__( 'Help & Support', "poll-maker" ); ?></h2>
317 </div>
318
319 <div class="ays-pm-w-resource-grid" style="margin-top:2rem;">
320 <!-- Card Template -->
321 <div class="ays-pm-w-resource-card">
322 <div class="ays-pm-w-resource-icon ays-pm-w-demo" style="background:#d1fae5;color:#047857;"><img src="<?php echo esc_url(POLL_MAKER_AYS_ADMIN_URL) . '/images/icons/poll-w-demo.svg'?>" alt="demo"></div>
323 <div class="ays-pm-w-resource-content">
324 <div class="ays-pm-w-resource-title"><?php echo esc_html__( 'Demo', "poll-maker" ); ?></div>
325 <p class="ays-pm-w-resource-desc"><?php echo esc_html__( 'See Poll Maker in action with live examples and use cases', "poll-maker" ); ?></p>
326 <a href="https://poll-plugin.com/wordpress-poll-plugin-free-demo" target="_blank" class="ays-pm-w-resource-action"><?php echo esc_html__( 'View Demo →', "poll-maker" ); ?></a>
327 </div>
328 </div>
329 <div class="ays-pm-w-resource-card">
330 <div class="ays-pm-w-resource-icon ays-pm-w-doc" style="background:#dbeafe;color:#2563eb;"><img src="<?php echo esc_url(POLL_MAKER_AYS_ADMIN_URL) . '/images/icons/poll-w-doc.svg'?>" alt="doc"></div>
331 <div class="ays-pm-w-resource-content">
332 <div class="ays-pm-w-resource-title"><?php echo esc_html__( 'Documentation', "poll-maker" ); ?></div>
333 <p class="ays-pm-w-resource-desc"><?php echo esc_html__( 'Complete guides, tutorials, and API reference for developers', "poll-maker" ); ?></p>
334 <a href="https://ays-pro.com/wordpress-poll-maker-user-manual" target="_blank" class="ays-pm-w-resource-action"><?php echo esc_html__( 'Read Docs →', "poll-maker" ); ?></a>
335 </div>
336 </div>
337 <div class="ays-pm-w-resource-card">
338 <div class="ays-pm-w-resource-icon ays-pm-w-community" style="background:#ffedd5;color:#c2410c;"><img src="<?php echo esc_url(POLL_MAKER_AYS_ADMIN_URL) . '/images/icons/poll-w-community.svg'?>" alt="community"></div>
339 <div class="ays-pm-w-resource-content">
340 <div class="ays-pm-w-resource-title"><?php echo esc_html__( 'Community Forum', "poll-maker" ); ?></div>
341 <p class="ays-pm-w-resource-desc"><?php echo esc_html__( 'Ask questions, share ideas, and get help from the Poll Maker community', "poll-maker" ); ?></p>
342 <a href="https://wordpress.org/support/plugin/poll-maker" target="_blank" class="ays-pm-w-resource-action"><?php echo esc_html__( 'Join Forum →', "poll-maker" ); ?></a>
343 </div>
344 </div>
345 <div class="ays-pm-w-resource-card">
346 <div class="ays-pm-w-resource-icon ays-pm-w-support" style="background:#ede9fe;color:#6b21a8;"><img src="<?php echo esc_url(POLL_MAKER_AYS_ADMIN_URL) . '/images/icons/poll-w-support.svg'?>" alt="support"></div>
347 <div class="ays-pm-w-resource-content">
348 <div class="ays-pm-w-resource-title"><?php echo esc_html__( 'Contact Support', "poll-maker" ); ?></div>
349 <p class="ays-pm-w-resource-desc"><?php echo esc_html__( 'Get help from our friendly support team whenever you need it', "poll-maker" ); ?></p>
350 <a href="https://ays-pro.com/contact" target="_blank" class="ays-pm-w-resource-action"><?php echo esc_html__( 'Get Support →', "poll-maker" ); ?></a>
351 </div>
352 </div>
353 </div>
354 </section>
355
356 <!-- What's New -->
357 <?php
358 if ( ! empty( $latest_changelog ) ) :
359 ?>
360 <section class="ays-pm-w-section ays-pm-w-wn-section" style="position:relative;">
361 <div class="ays-pm-w-text-center">
362 <h2 class="ays-pm-w-header-title" style="font-size:1.5rem;"><?php echo esc_html__( "What's New", "poll-maker" ); ?></h2>
363 <button id="wn-toggle" class="ays-pm-w-wn-toggle" style="position:absolute; top:1rem; right:1rem; background:none;border:none;font-size:0.875rem;color:#2563eb;cursor:pointer;display:flex;align-items:center;gap:0.25rem;"><?php echo esc_html__( "Show More", "poll-maker" ); ?> <span class="ays-pm-w-wn-arrow"></span></button>
364 <p class="ays-pm-w-header-desc" style="font-size:1rem;margin-top:0.5rem;"><?php echo esc_html__( "Latest updates and improvements to Poll Maker", "poll-maker" ); ?></p>
365 </div>
366 <div class="ays-pm-w-changelog ays-pm-w-collapsed" style="margin-top:2rem;">
367 <?php foreach ( $latest_changelog as $release ) : ?>
368 <div class="ays-pm-w-release">
369 <div class="ays-pm-w-release-header">
370 <span class="ays-pm-w-badge">v<?php echo esc_html( $release['version'] ); ?></span>
371 <?php if ( ! empty( $release['date'] ) ) : ?>
372 <span class="ays-pm-w-release-date"><?php echo esc_html( $release['date'] ); ?></span>
373 <?php endif; ?>
374 </div>
375 <ul class="ays-pm-w-release-list">
376 <?php foreach ( $release['changes'] as $change ) : ?>
377 <li><?php echo esc_html( $change ); ?></li>
378 <?php endforeach; ?>
379 </ul>
380 </div>
381 <?php endforeach; ?>
382 </div>
383 </section>
384 <?php endif; ?>
385 </div>
386 <!-- Video Lightbox -->
387 <div id="ays-pm-w-video-lightbox" class="ays-pm-w-video-lightbox">
388 <div class="ays-pm-w-video-lightbox-content">
389 <button id="ays-pm-w-video-lightbox-close" class="ays-pm-w-video-lightbox-close">
390 <img src="<?php echo esc_url(POLL_MAKER_AYS_ADMIN_URL); ?>/images/icons/close.svg" alt="<?php echo esc_html__( 'Close', "poll-maker" ); ?>">
391 </button>
392 <div class="ays-pm-w-video-wrapper">
393 <iframe id="ays-pm-w-video-iframe" width="560" height="315" src="" frameborder="0" allowfullscreen></iframe>
394 </div>
395 </div>
396 </div>
397 <?php
398 // Update both the general option and the blog-specific option if in multisite
399 update_option('ays_poll_maker_first_time_activation_page', false);
400
401 if (function_exists('is_multisite') && is_multisite()) {
402 $blog_id = get_current_blog_id();
403 $blog_specific_option = 'ays_poll_maker_first_time_activation_page_blog_' . $blog_id;
404 update_option($blog_specific_option, false);
405 }
406 }
407 }
408 new Poll_Maker_Ays_Welcome();