-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
181 lines (122 loc) · 4.52 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
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
<?php
/*
* WORDPRESS FUNCTIONS
* https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package cpar-website-wp
*/
if ( ! defined( 'ABSPATH' ) ) : exit; endif; // SILENCE IS GOLDEN
/*
* DEFINITIONS
* define values needed for website usage
*/
define( 'CPAR_DOMAIN', $_SERVER[ 'SERVER_NAME' ] );
// THEME
define( 'CPAR_THEME', 'cpar-website-wp' );
define( 'CPAR_THEME_PATH', trailingslashit( get_template_directory() ) );
define( 'CPAR_THEME_URL', trailingslashit( get_template_directory_uri() ) );
// DIRECTORIES
define( 'CPAR_ADMIN', trailingslashit( 'cpar-admin' ) );
define( 'CPAR_CONTENT', trailingslashit( 'cpar-content' ) );
define( 'CPAR_INCLUDES', trailingslashit( 'cpar-includes' ) );
define( 'CPAR_BLOCKS', trailingslashit( CPAR_CONTENT . 'blocks' ) );
define( 'CPAR_FIELDS', trailingslashit( CPAR_CONTENT . 'fields' ) );
define( 'CPAR_FORMS', trailingslashit( CPAR_CONTENT . 'forms' ) );
define( 'CPAR_LAYOUTS', trailingslashit( CPAR_CONTENT . 'layouts' ) );
define( 'CPAR_ASSETS', trailingslashit( 'assets' ) );
define( 'CPAR_ASSETS_CSS', trailingslashit( CPAR_ASSETS . 'css' ) );
define( 'CPAR_ASSETS_FONTS', trailingslashit( CPAR_ASSETS . 'fonts' ) );
define( 'CPAR_ASSETS_IMAGES', trailingslashit( CPAR_ASSETS . 'images' ) );
define( 'CPAR_ASSETS_JS', trailingslashit( CPAR_ASSETS . 'js' ) );
/*
* BASELINE
* initialize theme only if ACF Pro plugin is active
*/
if ( class_exists( 'ACF_PRO' ) ) :
require_once CPAR_ADMIN . 'init.php';
require_once CPAR_INCLUDES . 'init.php';
require_once CPAR_CONTENT . 'init.php';
add_action( 'after_setup_theme', 'cpar_theme_setup' );
add_action( 'wp_enqueue_scripts', 'cpar_theme_assets_front', 999999998 );
add_action( 'admin_enqueue_scripts', 'cpar_theme_assets_back', 999999998 );
endif;
/*
* THEME SETUP
* define theme configurations
*/
function cpar_theme_setup() {
// FEATURES
add_post_type_support( 'page', 'excerpt' );
add_theme_support( 'align-wide' );
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'block-template-parts' );
add_theme_support( 'custom-units', 'rem' );
add_theme_support( 'editor-styles' );
add_theme_support( 'html5' , array(
'search-form',
'comment-form',
'comment-list',
'caption',
'style',
'script'
) );
add_theme_support( 'post-thumbnails' );
add_theme_support( 'responsive-embeds' );
add_theme_support( 'title-tag' );
add_theme_support( 'disable-custom-colors' );
add_theme_support( 'disable-custom-gradients' );
add_theme_support( 'disable-custom-font-sizes' );
add_theme_support( 'disable-custom-line-height' );
add_theme_support( 'disable-custom-spacing' );
remove_theme_support( 'core-block-patterns' );
// POST THUMBNAIL
set_post_thumbnail_size( 1920, 1080 );
// NAV MENUS
register_nav_menus( array(
'cpar-menu-footer-default' => 'Default Footer',
'cpar-menu-header-default' => 'Default Header',
'cpar-menu-panel-default' => 'Default Panel'
) );
}
/*
* ASSETS
* enhance layout and user experience
*/
// FRONT-END
function cpar_theme_assets_front() {
// STYLESHEET
wp_enqueue_style(
'CPar Website (Global)',
CPAR_THEME_URL . 'style.css',
array(),
null,
'all'
);
// STYLESHEET - PRINT
wp_enqueue_style(
'CPar Website (Print)',
CPAR_THEME_URL . 'style-print.css',
array( 'CPar Website (Global)' ),
null,
'all'
);
// SCRIPTS
wp_enqueue_script(
'CPar Website (Global)',
CPAR_THEME_URL . 'script.js',
array( 'jquery' ),
null,
true
);
}
// ADMIN AREA
function cpar_theme_assets_back() {
// STYLESHEET
wp_enqueue_style(
'CPar Website (Admin)',
CPAR_THEME_URL . CPAR_ADMIN . CPAR_ASSETS_CSS . 'admin.css',
array(),
null,
'all'
);
}