This repository was archived by the owner on Jul 16, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathwelcome-screen.php
More file actions
284 lines (224 loc) · 10.7 KB
/
Copy pathwelcome-screen.php
File metadata and controls
284 lines (224 loc) · 10.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
<?php
/**
* Welcome Screen Class
*/
class Zerif_Welcome {
/**
* Constructor for the welcome screen
*/
public function __construct() {
/* create dashbord page */
add_action( 'admin_menu', array( $this, 'zerif_lite_welcome_register_menu' ) );
/* activation notice */
add_action( 'load-themes.php', array( $this, 'zerif_lite_activation_admin_notice' ) );
/* enqueue script and style for welcome screen */
add_action( 'admin_enqueue_scripts', array( $this, 'zerif_lite_welcome_style_and_scripts' ) );
/* enqueue script for customizer */
add_action( 'customize_controls_enqueue_scripts', array( $this, 'zerif_lite_welcome_scripts_for_customizer' ) );
/* load welcome screen */
add_action( 'zerif_lite_welcome', array( $this, 'zerif_lite_welcome_getting_started' ), 10 );
add_action( 'zerif_lite_welcome', array( $this, 'zerif_lite_welcome_actions_required' ), 20 );
add_action( 'zerif_lite_welcome', array( $this, 'zerif_lite_welcome_child_themes' ), 30 );
add_action( 'zerif_lite_welcome', array( $this, 'zerif_lite_welcome_github' ), 40 );
add_action( 'zerif_lite_welcome', array( $this, 'zerif_lite_welcome_changelog' ), 50 );
add_action( 'zerif_lite_welcome', array( $this, 'zerif_lite_welcome_free_pro' ), 60 );
/* ajax callback for dismissable required actions */
add_action( 'wp_ajax_zerif_lite_dismiss_required_action', array( $this, 'zerif_lite_dismiss_required_action_callback') );
add_action( 'wp_ajax_nopriv_zerif_lite_dismiss_required_action', array($this, 'zerif_lite_dismiss_required_action_callback') );
}
/**
* Creates the dashboard page
* @see add_theme_page()
* @since 1.8.2.4
*/
public function zerif_lite_welcome_register_menu() {
add_theme_page( __( 'About Zerif Lite', 'zerif-lite' ), __( 'About Zerif Lite', 'zerif-lite' ), 'activate_plugins', 'zerif-lite-welcome', array( $this, 'zerif_lite_welcome_screen' ) );
}
/**
* Adds an admin notice upon successful activation.
* @since 1.8.2.4
*/
public function zerif_lite_activation_admin_notice() {
global $pagenow;
if ( is_admin() && ('themes.php' == $pagenow) && isset( $_GET['activated'] ) ) {
add_action( 'admin_notices', array( $this, 'zerif_lite_welcome_admin_notice' ), 99 );
}
}
/**
* Display an admin notice linking to the welcome screen
* @since 1.8.2.4
*/
public function zerif_lite_welcome_admin_notice() {
?>
<div class="updated notice is-dismissible">
<p><?php echo sprintf( esc_html__( 'Welcome! Thank you for choosing Zerif Lite! To fully take advantage of the best our theme can offer please make sure you visit our %swelcome page%s.', 'zerif-lite' ), '<a href="' . esc_url( admin_url( 'themes.php?page=zerif-lite-welcome' ) ) . '">', '</a>' ); ?></p>
<p><a href="<?php echo esc_url( admin_url( 'themes.php?page=zerif-lite-welcome' ) ); ?>" class="button" style="text-decoration: none;"><?php _e( 'Get started with Zerif Lite', 'zerif-lite' ); ?></a></p>
</div>
<?php
}
/**
* Load welcome screen css and javascript
* @since 1.8.2.4
*/
public function zerif_lite_welcome_style_and_scripts( $hook_suffix ) {
if ( 'appearance_page_zerif-lite-welcome' == $hook_suffix ) {
wp_enqueue_style( 'zerif-lite-welcome-screen-css', get_template_directory_uri() . '/inc/admin/welcome-screen/css/welcome.css' );
wp_enqueue_script( 'zerif-lite-welcome-screen-js', get_template_directory_uri() . '/inc/admin/welcome-screen/js/welcome.js', array('jquery') );
global $zerif_required_actions;
$nr_actions_required = 0;
/* get number of required actions */
if( get_option('zerif_show_required_actions') ):
$zerif_show_required_actions = get_option('zerif_show_required_actions');
else:
$zerif_show_required_actions = array();
endif;
if( !empty($zerif_required_actions) ):
foreach( $zerif_required_actions as $zerif_required_action_value ):
if(( !isset( $zerif_required_action_value['check'] ) || ( isset( $zerif_required_action_value['check'] ) && ( $zerif_required_action_value['check'] == false ) ) ) && ((isset($zerif_show_required_actions[$zerif_required_action_value['id']]) && ($zerif_show_required_actions[$zerif_required_action_value['id']] == true)) || !isset($zerif_show_required_actions[$zerif_required_action_value['id']]) )) :
$nr_actions_required++;
endif;
endforeach;
endif;
wp_localize_script( 'zerif-lite-welcome-screen-js', 'zerifLiteWelcomeScreenObject', array(
'nr_actions_required' => $nr_actions_required,
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'template_directory' => get_template_directory_uri(),
'no_required_actions_text' => __( 'Hooray! There are no required actions for you right now.','zerif-lite' )
) );
}
}
/**
* Load scripts for customizer page
* @since 1.8.2.4
*/
public function zerif_lite_welcome_scripts_for_customizer() {
wp_enqueue_style( 'zerif-lite-welcome-screen-customizer-css', get_template_directory_uri() . '/inc/admin/welcome-screen/css/welcome_customizer.css' );
wp_enqueue_script( 'zerif-lite-welcome-screen-customizer-js', get_template_directory_uri() . '/inc/admin/welcome-screen/js/welcome_customizer.js', array('jquery'), '20120206', true );
global $zerif_required_actions;
$nr_actions_required = 0;
/* get number of required actions */
if( get_option('zerif_show_required_actions') ):
$zerif_show_required_actions = get_option('zerif_show_required_actions');
else:
$zerif_show_required_actions = array();
endif;
if( !empty($zerif_required_actions) ):
foreach( $zerif_required_actions as $zerif_required_action_value ):
if(( !isset( $zerif_required_action_value['check'] ) || ( isset( $zerif_required_action_value['check'] ) && ( $zerif_required_action_value['check'] == false ) ) ) && ((isset($zerif_show_required_actions[$zerif_required_action_value['id']]) && ($zerif_show_required_actions[$zerif_required_action_value['id']] == true)) || !isset($zerif_show_required_actions[$zerif_required_action_value['id']]) )) :
$nr_actions_required++;
endif;
endforeach;
endif;
wp_localize_script( 'zerif-lite-welcome-screen-customizer-js', 'zerifLiteWelcomeScreenCustomizerObject', array(
'nr_actions_required' => $nr_actions_required,
'aboutpage' => esc_url( admin_url( 'themes.php?page=zerif-lite-welcome#actions_required' ) ),
'customizerpage' => esc_url( admin_url( 'customize.php#actions_required' ) ),
'themeinfo' => __('View Theme Info','zerif-lite'),
) );
}
/**
* Dismiss required actions
* @since 1.8.2.4
*/
public function zerif_lite_dismiss_required_action_callback() {
global $zerif_required_actions;
$zerif_dismiss_id = (isset($_GET['dismiss_id'])) ? $_GET['dismiss_id'] : 0;
echo $zerif_dismiss_id; /* this is needed and it's the id of the dismissable required action */
if( !empty($zerif_dismiss_id) ):
/* if the option exists, update the record for the specified id */
if( get_option('zerif_show_required_actions') ):
$zerif_show_required_actions = get_option('zerif_show_required_actions');
$zerif_show_required_actions[$zerif_dismiss_id] = false;
update_option( 'zerif_show_required_actions',$zerif_show_required_actions );
/* create the new option,with false for the specified id */
else:
$zerif_show_required_actions_new = array();
if( !empty($zerif_required_actions) ):
foreach( $zerif_required_actions as $zerif_required_action ):
if( $zerif_required_action['id'] == $zerif_dismiss_id ):
$zerif_show_required_actions_new[$zerif_required_action['id']] = false;
else:
$zerif_show_required_actions_new[$zerif_required_action['id']] = true;
endif;
endforeach;
update_option( 'zerif_show_required_actions', $zerif_show_required_actions_new );
endif;
endif;
endif;
die(); // this is required to return a proper result
}
/**
* Welcome screen content
* @since 1.8.2.4
*/
public function zerif_lite_welcome_screen() {
require_once( ABSPATH . 'wp-load.php' );
require_once( ABSPATH . 'wp-admin/admin.php' );
require_once( ABSPATH . 'wp-admin/admin-header.php' );
?>
<ul class="zerif-lite-nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#getting_started" aria-controls="getting_started" role="tab" data-toggle="tab"><?php esc_html_e( 'Getting started','zerif-lite'); ?></a></li>
<li role="presentation" class="zerif-lite-w-red-tab"><a href="#actions_required" aria-controls="actions_required" role="tab" data-toggle="tab"><?php esc_html_e( 'Actions required','zerif-lite'); ?></a></li>
<li role="presentation"><a href="#child_themes" aria-controls="child_themes" role="tab" data-toggle="tab"><?php esc_html_e( 'Child themes','zerif-lite'); ?></a></li>
<li role="presentation"><a href="#github" aria-controls="github" role="tab" data-toggle="tab"><?php esc_html_e( 'Contribute','zerif-lite'); ?></a></li>
<li role="presentation"><a href="#changelog" aria-controls="changelog" role="tab" data-toggle="tab"><?php esc_html_e( 'Changelog','zerif-lite'); ?></a></li>
<li role="presentation"><a href="#free_pro" aria-controls="free_pro" role="tab" data-toggle="tab"><?php esc_html_e( 'Free VS PRO','zerif-lite'); ?></a></li>
</ul>
<div class="zerif-lite-tab-content">
<?php
/**
* @hooked zerif_lite_welcome_getting_started - 10
* @hooked zerif_lite_welcome_actions_required - 20
* @hooked zerif_lite_welcome_child_themes - 30
* @hooked zerif_lite_welcome_github - 40
* @hooked zerif_lite_welcome_changelog - 50
* @hooked zerif_lite_welcome_free_pro - 60
*/
do_action( 'zerif_lite_welcome' ); ?>
</div>
<?php
}
/**
* Getting started
* @since 1.8.2.4
*/
public function zerif_lite_welcome_getting_started() {
require_once( get_template_directory() . '/inc/admin/welcome-screen/sections/getting-started.php' );
}
/**
* Actions required
* @since 1.8.2.4
*/
public function zerif_lite_welcome_actions_required() {
require_once( get_template_directory() . '/inc/admin/welcome-screen/sections/actions-required.php' );
}
/**
* Child themes
* @since 1.8.2.4
*/
public function zerif_lite_welcome_child_themes() {
require_once( get_template_directory() . '/inc/admin/welcome-screen/sections/child-themes.php' );
}
/**
* Contribute
* @since 1.8.2.4
*/
public function zerif_lite_welcome_github() {
require_once( get_template_directory() . '/inc/admin/welcome-screen/sections/github.php' );
}
/**
* Changelog
* @since 1.8.2.4
*/
public function zerif_lite_welcome_changelog() {
require_once( get_template_directory() . '/inc/admin/welcome-screen/sections/changelog.php' );
}
/**
* Free vs PRO
* @since 1.8.2.4
*/
public function zerif_lite_welcome_free_pro() {
require_once( get_template_directory() . '/inc/admin/welcome-screen/sections/free_pro.php' );
}
}
$GLOBALS['Zerif_Welcome'] = new Zerif_Welcome();