-
Notifications
You must be signed in to change notification settings - Fork 2
/
functions.php
223 lines (183 loc) · 6.3 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
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
<?php
/**
* Rosa Lite functions and definitions
*
* @package Rosa Lite
* @since Rosa Lite 1.0
*/
if ( ! function_exists(' rosa_lite_theme_setup' ) ) {
/**
* 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 rosa_lite_theme_setup() {
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on Rosa Lite, use a find and replace
* to change 'patch' to the name of your theme in all the template files
*/
load_theme_textdomain( '__theme_txtd', get_template_directory() . '/languages' );
//add theme support for RSS feed links automatically generated in the head section
add_theme_support( 'automatic-feed-links' );
//tell galleries and captions to behave nicely and use HTML5 markup
add_theme_support( 'html5', array( 'gallery', 'caption' ) );
// Add theme support for Featured Images
add_theme_support( 'post-thumbnails' );
$sizes = array(
/**
* MAXIMUM SIZE
* Maximum Full Image Size
* - Sliders
* - Lightbox
*/
'full-size' => array(
'width' => 2048
),
/**
* LARGE SIZE
* - Single post without sidebar
*/
'large-size' => array(
'width' => 1200
),
/**
* MEDIUM SIZE
* - Tablet Sliders
* - Archive Featured Image
* - Single Featured Image
*/
'medium-size' => array(
'width' => 900,
),
/**
* SMALL SIZE
* - Masonry Grid
* - Mobile Sliders
*/
'small-size' => array(
'width' => 400,
),
);
foreach ( $sizes as $size_key => $values ) {
$width = 0;
if ( isset( $values['width'] ) ) {
$width = $values['width'];
}
$height = 0;
if ( isset( $values['height'] ) ) {
$height = $values['height'];
}
$hard_crop = false;
if ( isset( $values['hard_crop'] ) ) {
$hard_crop = $values['hard_crop'];
}
add_image_size( $size_key, $width, $height, $hard_crop );
}
register_nav_menus( array(
'main_menu' => esc_html__( 'Main Menu', '__theme_txtd' ),
'footer_menu' => esc_html__( 'Footer Menu', '__theme_txtd' ),
) );
add_theme_support( 'title-tag' );
/*
* Enable support for custom logo.
*/
add_theme_support( 'custom-logo', array(
'height' => 60,
'width' => 180,
'flex-height' => true,
'flex-width' => true,
'header-text' => array(
'site-title',
'site-description-text',
)
) );
/**
* Enable support for the Style Manager Customizer section (via Customify).
*/
add_theme_support( 'customizer_style_manager' );
add_editor_style( array( 'editor-style.css', rosa_lite_google_fonts_url() ) );
}
}
add_action( 'after_setup_theme', 'rosa_lite_theme_setup' );
if ( ! function_exists( 'rosa_lite_load_assets' ) ) {
function rosa_lite_load_assets(){
$theme = wp_get_theme( get_template() );
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
// Styles
wp_enqueue_style( 'rosa-main-style', get_template_directory_uri() . '/style.css', array(), $theme->get( 'Version' ) );
wp_style_add_data( 'rosa-main-style', 'rtl', 'replace' );
wp_enqueue_style( 'rosa-google-fonts', rosa_lite_google_fonts_url() );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
if ( is_404() ) {
wp_enqueue_style( 'rosa-404-style', get_template_directory_uri() . '/404.css', array(), time(), 'all' );
}
// Scripts
$script_dependencies = array( 'jquery', );
wp_register_script( 'modernizr', get_parent_theme_file_uri( '/assets/js/vendor/modernizr.min.js' ), array(), '3.6.0' );
$script_dependencies[] = 'modernizr';
wp_enqueue_script( 'rosa-plugins-scripts', get_parent_theme_file_uri( '/assets/js/plugins' . $suffix . '.js' ), $script_dependencies, $theme->get( 'Version' ), true );
wp_enqueue_script( 'rosa-main-scripts', get_parent_theme_file_uri( '/assets/js/main' . $suffix . '.js' ), array( 'rosa-plugins-scripts' ), $theme->get( 'Version' ), true );
$localization_array = array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'tPrev' => esc_html__( 'Previous (Left arrow key)', '__theme_txtd' ),
'tNext' => esc_html__( 'Next (Right arrow key)', '__theme_txtd' ),
'tCounter' => esc_html__( 'of', '__theme_txtd' ),
);
wp_localize_script( 'rosa-main-scripts', 'rosaStrings', $localization_array );
}
}
add_action( 'wp_enqueue_scripts', 'rosa_lite_load_assets' );
if ( ! function_exists( 'rosa_lite_register_sidebars' ) ) {
/*
* Register Widgets areas.
*/
function rosa_lite_register_sidebars() {
register_sidebar( array(
'id' => 'sidebar-main',
'name' => esc_html__( 'Main Sidebar', '__theme_txtd' ),
'description' => esc_html__( 'Add widgets here to appear in sidebar.', '__theme_txtd' ),
'before_title' => '<h4 class="widget__title widget--sidebar-blog__title">',
'after_title' => '</h4>',
'before_widget' => '<div id="%1$s" class="widget widget--sidebar-blog %2$s">',
'after_widget' => '</div>',
) );
}
}
add_action( 'widgets_init', 'rosa_lite_register_sidebars' );
/**
* Set the content width in pixels, based on the theme's design and stylesheet.
*
* Priority 0 to make it available to lower priority callbacks.
*
* @global int $content_width
*/
function rosa_lite_content_width() {
$GLOBALS['content_width'] = apply_filters( 'rosa_lite_content_width', 960, 0 );
}
add_action( 'after_setup_theme', 'rosa_lite_content_width', 0 );
/**
* Custom template tags for this theme.
*/
require_once trailingslashit( get_template_directory() ) . 'inc/template-tags.php';
/**
* Custom functions that act independently of the theme templates.
*/
require_once trailingslashit( get_template_directory() ) . 'inc/extras.php';
/**
* Customizer additions.
*/
require_once trailingslashit( get_template_directory() ) . 'inc/customizer.php';
/**
* Load various plugin integrations
*/
require_once trailingslashit( get_template_directory() ) . 'inc/integrations.php';
/**
* Admin dashboard related logic.
*/
require_once trailingslashit( get_template_directory() ) . 'inc/admin.php';