-
Notifications
You must be signed in to change notification settings - Fork 21
/
bctt-welcome.php
92 lines (71 loc) · 2.8 KB
/
bctt-welcome.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
/*
* Welcome Wizard Handler Class
*
* This is the base class for adding Welcome onboarding
*
* @since 5.7.0
*
*/
if ( ! defined( 'ABSPATH' ) && !current_user_can('manage_options') ) {
exit;
}
if ( ! class_exists( 'BCTT_Welcome' ) ):
class BCTT_Welcome {
public function __construct( ) {
$this->hooks();
}
private function hooks() {
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
add_action( 'admin_init', array( $this, 'welcome_page' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
}
public function admin_menu() {
add_dashboard_page( '', '', 'manage_options', 'bctt-welcome', '' );
}
public function welcome_page() {
if( !current_user_can('manage_options')){
exit;
}
set_current_screen();
// Update twitter handle
if ( isset( $_POST['bctt-twitter']) && current_user_can('manage_options')
&& wp_verify_nonce( $_POST['save-the-handle'], 'change-handle' ) ) {
update_option( 'bctt-twitter-handle', $_POST['bctt-twitter'] );
wp_safe_redirect( bctt_get_step_url( 'bctt-usage' ) );
exit;
}
// Get page header
require_once 'includes/views/welcome/_header.php';
// Get step content
switch ( bctt_get_step() ) {
case 'bctt-setup':
require_once 'includes/views/welcome/_welcome.php';
break;
case 'bctt-usage':
require_once 'includes/views/welcome/_usage.php';
break;
case 'bctt-content':
require_once 'includes/views/welcome/_content.php';
break;
case 'bctt-grow':
require_once 'includes/views/welcome/_grow.php';
break;
case 'bctt-done':
require_once 'includes/views/welcome/_done.php';
break;
default:
require_once 'includes/views/welcome/_welcome.php';
break;
}
// Get page footer
require_once 'includes/views/welcome/_footer.php';
exit;
}
public function enqueue_scripts() {
wp_enqueue_style( 'bctt_welcome_utilitie', plugins_url( '/assets/css/utility.css', __FILE__ ) , array(), null );
wp_enqueue_style( 'bctt_welcome_styles', plugins_url( '/assets/css/bctt-welcome.css', __FILE__ ) , array(), null );
}
}
$bctt_welcome = new BCTT_Welcome();
endif;