lsx_welcome_enhance()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 2
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_e( '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' ),
0 ignored issues
show
Bug introduced by
Are you sure the usage of esc_html_e('Thanks for c...me screen%2$s.', 'lsx') is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Bug introduced by
esc_html_e('Thanks for c...me screen%2$s.', 'lsx') of type null is incompatible with the type string expected by parameter $format of printf(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

63
							/** @scrutinizer ignore-type */ esc_html_e( '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' ),
Loading history...
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_html_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
			?>
138
		</div>
139
		<?php
140
	}
141
142
endif;
143
144
if ( ! function_exists( 'lsx_welcome_header' ) ) :
145
146
	/**
147
	 * Welcome screen intro.
148
	 *
149
	 * @package    lsx
150
	 * @subpackage welcome-page
151
	 */
152
	function lsx_welcome_header() {
153
		require_once get_template_directory() . '/includes/admin/welcome-screen/component-header.php';
154
	}
155
156
endif;
157
158
add_action( 'lsx_welcome', 'lsx_welcome_header', 10 );
159
160
if ( ! function_exists( 'lsx_welcome_enhance' ) ) :
161
162
	/**
163
	 * Welcome screen enhance section.
164
	 *
165
	 * @package    lsx
166
	 * @subpackage welcome-page
167
	 */
168
	function lsx_welcome_enhance() {
169
		require_once get_template_directory() . '/includes/admin/welcome-screen/component-enhance.php';
170
	}
171
172
endif;
173
174
add_action( 'lsx_welcome', 'lsx_welcome_enhance', 20 );
175
176
if ( ! function_exists( 'lsx_welcome_footer' ) ) :
177
178
	/**
179
	 * Welcome screen contribute section.
180
	 *
181
	 * @package    lsx
182
	 * @subpackage welcome-page
183
	 */
184
	function lsx_welcome_footer() {
185
		require_once get_template_directory() . '/includes/admin/welcome-screen/component-footer.php';
186
	}
187
188
endif;
189
190
add_action( 'lsx_welcome', 'lsx_welcome_footer', 30 );
191