-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
96 lines (80 loc) · 2.38 KB
/
functions.php
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
<?php
/**
* Functions and definitions.
*
* @package luna
*/
namespace Luna\Functions;
// @codingStandardsIgnoreStart
// The theme version, is used for the ?ver parameter of scripts and styles.
define( 'THEME_VERSION', '1582905119' );
// @codingStandardsIgnoreEnd
/**
* Custom functions for Gutenberg.
*/
require get_template_directory() . '/gutenberg.php';
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which
* runs before the init hook. The init hook is too late for some features, such
* as indicating support for post thumbnails.
*/
function setup() {
// Make theme available for translation.
load_theme_textdomain( 'luna', get_template_directory() . '/languages' );
// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
// Let WordPress manage the document title.
add_theme_support( 'title-tag' );
// Enable support for Post Thumbnails on posts and pages.
add_theme_support( 'post-thumbnails' );
// Register nav menus.
register_nav_menus(
[
'primary' => esc_html__( 'Primary Menu', 'luna' ),
]
);
// Switch default core markup for search form, comment form, and comment to output valid HTML5.
add_theme_support(
'html5',
[
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
]
);
/**
* Add Editor Scripts.
*/
add_theme_support( 'editor-styles' );
add_editor_style( 'style-editor.css' );
/**
* Add Custom Image Sizes.
*/
add_image_size( 'max-width', 2200, 2200 );
}
add_action( 'after_setup_theme', __NAMESPACE__ . '\setup' );
/**
* Enqueue scripts and styles.
*
* @return void
*/
function scripts() {
// Load theme's stylesheet.
wp_enqueue_style( 'luna-style', get_template_directory_uri() . '/style.css', [], THEME_VERSION );
wp_register_script( 'luna-script', get_template_directory_uri() . '/dist/build.js', [ 'jquery' ], THEME_VERSION, true );
$data = [
'home_url' => home_url(),
'nonce' => wp_create_nonce( 'wp_rest' ),
'debug' => defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG,
];
wp_localize_script( 'luna-script', 'luna', $data );
wp_enqueue_script( 'luna-script' );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\scripts' );