-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththeme.php
More file actions
52 lines (45 loc) · 1.26 KB
/
theme.php
File metadata and controls
52 lines (45 loc) · 1.26 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
<?php
/**
* Theme setup.
*
* @package Create_WordPress_Theme
*/
namespace Alley\WP\Create_WordPress_Theme\Theme;
add_action( 'after_setup_theme', __NAMESPACE__ . '\action__after_setup_theme' );
add_action( 'admin_menu', __NAMESPACE__ . '\action__admin_menu' );
/**
* Setup theme defaults and registers support for various WordPress features.
*/
function action__after_setup_theme(): void {
// Add menu support.
add_theme_support( 'menus' );
// Register navigation menu locations.
register_nav_menus(
[
'header' => __( 'Header', 'create-wordpress-theme' ),
'footer' => __( 'Footer', 'create-wordpress-theme' ),
]
);
}
/**
* Add in the Customize link to the Appearance menu.
*
* @return void
*/
function action__admin_menu(): void {
if ( empty( $_SERVER['REQUEST_URI'] ) || ! is_string( $_SERVER['REQUEST_URI'] ) ) {
return;
}
// Build the customize.php URL.
$current_url = esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) );
$customize_url = add_query_arg( 'return', rawurlencode( remove_query_arg( wp_removable_query_args(), $current_url ) ), 'customize.php' );
add_submenu_page(
'themes.php',
__( 'Customize', 'create-wordpress-theme' ),
__( 'Customize', 'create-wordpress-theme' ),
'customize',
esc_url( $customize_url ),
'',
60
);
}