welcome-screen.php
3.7 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
/**
* Welcome Screen Class
* Sets up the welcome screen page, hides the menu item
* and contains the screen content.
*/
class Storefront_Welcome {
/**
* Constructor
* Sets up the welcome screen
*/
public function __construct() {
add_action( 'admin_menu', array( $this, 'storefront_welcome_register_menu' ) );
add_action( 'load-themes.php', array( $this, 'storefront_activation_admin_notice' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'storefront_welcome_style' ) );
add_action( 'storefront_welcome', array( $this, 'storefront_welcome_intro' ), 10 );
add_action( 'storefront_welcome', array( $this, 'storefront_welcome_enhance' ), 20 );
add_action( 'storefront_welcome', array( $this, 'storefront_welcome_contribute' ), 30 );
} // end constructor
/**
* Adds an admin notice upon successful activation.
* @since 1.0.3
*/
public function storefront_activation_admin_notice() {
global $pagenow;
if ( is_admin() && 'themes.php' == $pagenow && isset( $_GET['activated'] ) ) { // input var okay
add_action( 'admin_notices', array( $this, 'storefront_welcome_admin_notice' ), 99 );
}
}
/**
* Display an admin notice linking to the welcome screen
* @since 1.0.3
*/
public function storefront_welcome_admin_notice() {
?>
<div class="updated notice is-dismissible">
<p><?php echo sprintf( esc_html__( 'Thanks for choosing Storefront! You can read hints and tips on how get the most out of your new theme on the %swelcome screen%s.', 'storefront' ), '<a href="' . esc_url( admin_url( 'themes.php?page=storefront-welcome' ) ) . '">', '</a>' ); ?></p>
<p><a href="<?php echo esc_url( admin_url( 'themes.php?page=storefront-welcome' ) ); ?>" class="button" style="text-decoration: none;"><?php _e( 'Get started with Storefront', 'storefront' ); ?></a></p>
</div>
<?php
}
/**
* Load welcome screen css
* @return void
* @since 1.4.4
*/
public function storefront_welcome_style( $hook_suffix ) {
global $storefront_version;
if ( 'appearance_page_storefront-welcome' == $hook_suffix ) {
wp_enqueue_style( 'storefront-welcome-screen', get_template_directory_uri() . '/inc/admin/welcome-screen/css/welcome.css', $storefront_version );
wp_enqueue_style( 'thickbox' );
wp_enqueue_script( 'thickbox' );
}
}
/**
* Creates the dashboard page
* @see add_theme_page()
* @since 1.0.0
*/
public function storefront_welcome_register_menu() {
add_theme_page( 'Storefront', 'Storefront', 'activate_plugins', 'storefront-welcome', array( $this, 'storefront_welcome_screen' ) );
}
/**
* The welcome screen
* @since 1.0.0
*/
public function storefront_welcome_screen() {
require_once( ABSPATH . 'wp-load.php' );
require_once( ABSPATH . 'wp-admin/admin.php' );
require_once( ABSPATH . 'wp-admin/admin-header.php' );
?>
<div class="wrap about-wrap">
<?php
/**
* @hooked storefront_welcome_intro - 10
* @hooked storefront_welcome_enhance - 20
* @hooked storefront_welcome_contribute - 30
*/
do_action( 'storefront_welcome' ); ?>
</div>
<?php
}
/**
* Welcome screen intro
* @since 1.0.0
*/
public function storefront_welcome_intro() {
require_once( get_template_directory() . '/inc/admin/welcome-screen/sections/intro.php' );
}
/**
* Welcome screen enhance section
* @since 1.5.2
*/
public function storefront_welcome_enhance() {
require_once( get_template_directory() . '/inc/admin/welcome-screen/sections/enhance.php' );
}
/**
* Welcome screen contribute section
* @since 1.5.2
*/
public function storefront_welcome_contribute() {
require_once( get_template_directory() . '/inc/admin/welcome-screen/sections/contribute.php' );
}
}
$GLOBALS['Storefront_Welcome'] = new Storefront_Welcome();