Passed
Push — master ( 2256c9...a580d9 )
by Fernando
02:21
created

welcome.php ➔ lsx_activation_admin_notice_dismiss()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * LSX functions and definitions - Welcome page.
4
 *
5
 * @package    lsx
6
 * @subpackage welcome-page
7
 */
8
9
if ( ! defined( 'ABSPATH' ) ) {
10
	exit;
11
}
12
13
if ( ! function_exists( 'lsx_activation_admin_notice_dismiss' ) ) :
14
15
	/**
16
	 * Dismiss the admin notice (successful activation).
17
	 *
18
	 * @package    lsx
19
	 * @subpackage welcome-page
20
	 */
21
	function lsx_activation_admin_notice_dismiss() {
22
		update_option( 'lsx-notice-dismissed', '1' );
23
		wp_die();
24
	}
25
26
endif;
27
28
add_action( 'wp_ajax_lsx_dismiss_theme_notice', 'lsx_activation_admin_notice_dismiss' );
29
30
if ( ! function_exists( 'lsx_activation_admin_notice' ) ) :
31
32
	/**
33
	 * Adds an admin notice upon successful activation.
34
	 *
35
	 * @package    lsx
36
	 * @subpackage welcome-page
37
	 */
38
	function lsx_activation_admin_notice() {
39
		if ( empty( get_option( 'lsx-notice-dismissed' ) ) ) {
40
			add_action( 'admin_notices', 'lsx_welcome_admin_notice', 99 );
41
		}
42
	}
43
44
endif;
45
46
add_action( 'admin_notices', 'lsx_activation_admin_notice' );
47
48
if ( ! function_exists( 'lsx_welcome_admin_notice' ) ) :
49
50
	/**
51
	 * Display an admin notice linking to the welcome screen.
52
	 *
53
	 * @package    lsx
54
	 * @subpackage welcome-page
55
	 */
56
	function lsx_welcome_admin_notice() {
57
		?>
58
			<div class="lsx-theme-notice notice notice-success is-dismissible">
59
				<p>
60
					<?php
61
						printf(
62
							/* Translators: 1: HTML open tag link, 2: HTML close tag link */
63
							esc_html__( 'Thanks for choosing LSX! You can read hints and tips on how get the most out of your new theme on the %1$swelcome screen%2$s.', 'lsx' ),
64
							'<a href="' . esc_url( admin_url( 'themes.php?page=lsx-welcome' ) ) . '">',
65
							'</a>'
66
						);
67
					?>
68
				</p>
69
				<p><a href="<?php echo esc_url( admin_url( 'themes.php?page=lsx-welcome' ) ); ?>" class="button" style="text-decoration: none;"><?php esc_attr_e( 'Get started with LSX', 'lsx' ); ?></a></p>
70
			</div>
71
		<?php
72
	}
73
74
endif;
75
76
if ( ! function_exists( 'lsx_welcome_style' ) ) :
77
78
	/**
79
	 * Load welcome screen css.
80
	 *
81
	 * @package    lsx
82
	 * @subpackage welcome-page
83
	 *
84
	 * @param string $hook_suffix the current page hook suffix.
85
	 */
86
	function lsx_welcome_style( $hook_suffix ) {
87
		if ( 'appearance_page_lsx-welcome' === $hook_suffix ) {
88
			wp_enqueue_style( 'lsx-welcome-screen-mailchimp', '//cdn-images.mailchimp.com/embedcode/classic-10_7.css', array(), LSX_VERSION );
89
			wp_enqueue_style( 'lsx-welcome-screen', get_template_directory_uri() . '/assets/css/admin/welcome.css', array( 'lsx-welcome-screen-mailchimp' ), LSX_VERSION );
90
			wp_style_add_data( 'lsx-welcome-screen', 'rtl', 'replace' );
91
		}
92
	}
93
94
endif;
95
96
add_action( 'admin_enqueue_scripts', 'lsx_welcome_style' );
97
98
if ( ! function_exists( 'lsx_welcome_register_menu' ) ) :
99
100
	/**
101
	 * Creates the dashboard page.
102
	 *
103
	 * @package    lsx
104
	 * @subpackage welcome-page
105
	 */
106
	function lsx_welcome_register_menu() {
107
		add_theme_page( 'LSX', 'LSX', 'activate_plugins', 'lsx-welcome', 'lsx_welcome_screen' );
108
	}
109
110
endif;
111
112
add_action( 'admin_menu', 'lsx_welcome_register_menu' );
113
114
if ( ! function_exists( 'lsx_welcome_screen' ) ) :
115
116
	/**
117
	 * The welcome screen.
118
	 *
119
	 * @package    lsx
120
	 * @subpackage welcome-page
121
	 */
122
	function lsx_welcome_screen() {
123
		require_once( ABSPATH . 'wp-load.php' );
124
		require_once( ABSPATH . 'wp-admin/admin.php' );
125
		require_once( ABSPATH . 'wp-admin/admin-header.php' );
126
		?>
127
		<div class="wrap about-wrap">
128
			<?php
129
			/**
130
			 * Functions hooked into lsx_welcome action
131
			 *
132
			 * @hooked lsx_welcome_header  - 10
133
			 * @hooked lsx_welcome_enhance - 20
134
			 * @hooked lsx_welcome_footer  - 30
135
			 */
136
			do_action( 'lsx_welcome' ); ?>
137
		</div>
138
		<?php
139
	}
140
141
endif;
142
143
if ( ! function_exists( 'lsx_welcome_header' ) ) :
144
145
	/**
146
	 * Welcome screen intro.
147
	 *
148
	 * @package    lsx
149
	 * @subpackage welcome-page
150
	 */
151
	function lsx_welcome_header() {
152
		require_once( get_template_directory() . '/includes/admin/welcome-screen/component-header.php' );
153
	}
154
155
endif;
156
157
add_action( 'lsx_welcome', 'lsx_welcome_header', 10 );
158
159
if ( ! function_exists( 'lsx_welcome_enhance' ) ) :
160
161
	/**
162
	 * Welcome screen enhance section.
163
	 *
164
	 * @package    lsx
165
	 * @subpackage welcome-page
166
	 */
167
	function lsx_welcome_enhance() {
168
		require_once( get_template_directory() . '/includes/admin/welcome-screen/component-enhance.php' );
169
	}
170
171
endif;
172
173
add_action( 'lsx_welcome', 'lsx_welcome_enhance', 20 );
174
175
if ( ! function_exists( 'lsx_welcome_footer' ) ) :
176
177
	/**
178
	 * Welcome screen contribute section.
179
	 *
180
	 * @package    lsx
181
	 * @subpackage welcome-page
182
	 */
183
	function lsx_welcome_footer() {
184
		require_once( get_template_directory() . '/includes/admin/welcome-screen/component-footer.php' );
185
	}
186
187
endif;
188
189
add_action( 'lsx_welcome', 'lsx_welcome_footer', 30 );
190