| @@ -15,8 +15,10 @@ | ||
| 15 | 15 | add_action( 'admin_init', array( $this, 'patternswp_ensure_hourly_cron' ) ); |
| 16 | 16 | add_action( 'wp_ajax_patternswp_background_transient_load_ajax', array( $this, 'patternswp_background_transient_load_ajaxcc' ) ); |
| 17 | 17 | add_action( 'wp_ajax_nopriv_patternswp_background_transient_load_ajax', array( $this, 'patternswp_background_transient_load_ajaxcc' ) ); |
| 18 | 18 | add_action( 'patternswp_load_patterns_by_ra', array( $this, 'patternswp_load_patterns_by_remote_ajax' ) ); |
| 19 | + register_activation_hook(plugin_dir_path(__DIR__) . 'patternswp.php', array($this, 'patternswp_on_activation')); | |
| 20 | + add_action('admin_init', array($this, 'patternswp_redirect_on_activation')); | |
| 19 | 21 | } |
| 20 | 22 | |
| 21 | 23 | /** |
| 22 | 24 | * Add admin menu |
| @@ -93,8 +95,13 @@ | ||
| 93 | 95 | <h4><?php echo esc_html('Hello, ' . wp_get_current_user()->display_name . ' 👋'); ?></h4> |
| 94 | 96 | <h1 class="feature-title"><?php esc_html_e('Welcome to PatternsWP', 'patternswp'); ?></h1> |
| 95 | 97 | <p><?php esc_html_e('Thanks for choosing PatternsWP! Follow these three simple steps to get started!', 'patternswp'); ?></p> |
| 96 | 98 | </div> |
| 99 | + <div class="column" style="padding: 10px; text-align: center;"> | |
| 100 | + <a href="<?php echo esc_url(admin_url('post-new.php?post_type=page')); ?>" class="button button-primary"> | |
| 101 | + <?php esc_html_e('Start building with PatternsWP', 'patternswp'); ?> | |
| 102 | + </a> | |
| 103 | + </div> | |
| 97 | 104 | </div> |
| 98 | 105 | <div class="about__section has-3-columns"> |
| 99 | 106 | <div class="column" style="padding: 40px;"> |
| 100 | 107 | <div class="about__image"> |
| @@ -313,7 +320,27 @@ | ||
| 313 | 320 | 'blocking' => false, |
| 314 | 321 | 'sslverify' => false, |
| 315 | 322 | )); |
| 316 | 323 | } |
| 324 | + | |
| 325 | + /** | |
| 326 | + * Set transient on plugin activation | |
| 327 | + */ | |
| 328 | + public function patternswp_on_activation() { | |
| 329 | + set_transient('patternswp_activation_redirect', true, 30); | |
| 330 | + } | |
| 331 | + | |
| 332 | + /** | |
| 333 | + * Redirect to welcome page after activation | |
| 334 | + */ | |
| 335 | +public function patternswp_redirect_on_activation() { | |
| 336 | + if (get_transient('patternswp_activation_redirect')) { | |
| 337 | + delete_transient('patternswp_activation_redirect'); | |
| 338 | + if (!is_network_admin() && !isset($_GET['activate-multi'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Safe usage: only checking if 'activate-multi' is set | |
| 339 | + wp_safe_redirect(admin_url('admin.php?page=patternswp-plugin-menu')); | |
| 340 | + exit; | |
| 341 | + } | |
| 342 | + } | |
| 343 | +} | |
| 317 | 344 | } |
| 318 | 345 | |
| 319 | 346 | new PatternsWP_Admin(); |