-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathfunctions.php
479 lines (415 loc) · 17.7 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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
<?php
/**
* Spacious functions related to defining constants, adding files and WordPress core functionality.
*
* Defining some constants, loading all the required files and Adding some core functionality.
*
* @uses add_theme_support() To add support for post thumbnails and automatic feed links.
* @uses register_nav_menu() To add support for navigation menu.
* @uses set_post_thumbnail_size() To set a custom post thumbnail size.
*
* @package ThemeGrill
* @subpackage Spacious
* @since Spacious 1.0
*/
/**
* Set the content width based on the theme's design and stylesheet.
*/
if ( ! isset( $content_width ) ) {
$content_width = 750;
}
/**
* $content_width global variable adjustment as per layout option.
*/
function spacious_content_width() {
global $post;
global $content_width;
if ( $post ) {
$layout_meta = get_post_meta( $post->ID, 'spacious_page_layout', true );
}
if ( empty( $layout_meta ) || is_archive() || is_search() ) {
$layout_meta = 'default_layout';
}
$spacious_default_layout = get_theme_mod( 'default_layout', 'right_sidebar' );
if ( $layout_meta == 'default_layout' ) {
if ( ( get_theme_mod( 'spacious_site_layout', 'box_1218px' ) == 'box_978px' ) || ( get_theme_mod( 'spacious_site_layout', 'box_1218px' ) == 'wide_978px' ) ) {
if ( $spacious_default_layout == 'no_sidebar_full_width' ) {
$content_width = 978; /* pixels */
} else {
$content_width = 642; /* pixels */
}
} elseif ( $spacious_default_layout == 'no_sidebar_full_width' ) {
$content_width = 1218; /* pixels */
} else {
$content_width = 750; /* pixels */
}
} elseif ( ( get_theme_mod( 'spacious_site_layout', 'box_1218px' ) == 'box_978px' ) || ( get_theme_mod( 'spacious_site_layout', 'box_1218px' ) == 'wide_978px' ) ) {
if ( $layout_meta == 'no_sidebar_full_width' ) {
$content_width = 978; /* pixels */
} else {
$content_width = 642; /* pixels */
}
} elseif ( $layout_meta == 'no_sidebar_full_width' ) {
$content_width = 1218; /* pixels */
} else {
$content_width = 750; /* pixels */
}
}
add_action( 'template_redirect', 'spacious_content_width' );
/**
* All setup functionalities.
*
* @since 1.0
*/
if ( ! function_exists( 'spacious_setup' ) ) :
function spacious_setup() {
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
*/
load_theme_textdomain( 'spacious', get_template_directory() . '/languages' );
// Add default posts and comments RSS feed links to head
add_theme_support( 'automatic-feed-links' );
// This theme uses Featured Images (also known as post thumbnails) for per-post/per-page.
add_theme_support( 'post-thumbnails' );
// Supporting title tag via add_theme_support (since WordPress 4.1)
add_theme_support( 'title-tag' );
// Adds the support for the Custom Logo introduced in WordPress 4.5
add_theme_support(
'custom-logo',
array(
'height' => 100,
'width' => 100,
'flex-width' => true,
'flex-height' => true,
)
);
// Registering navigation menus.
register_nav_menus(
array(
'header' => esc_html__( 'Header Menu', 'spacious' ),
'primary' => esc_html__( 'Primary Menu', 'spacious' ),
'footer' => esc_html__( 'Footer Menu', 'spacious' ),
)
);
// Cropping the images to different sizes to be used in the theme
add_image_size( 'featured-blog-large', 750, 350, true );
add_image_size( 'featured-blog-medium', 270, 270, true );
add_image_size( 'featured', 642, 300, true );
add_image_size( 'featured-blog-medium-small', 230, 230, true );
// Setup the WordPress core custom background feature.
add_theme_support(
'custom-background',
apply_filters(
'spacious_custom_background_args',
array(
'default-color' => 'eaeaea',
)
)
);
// Adding excerpt option box for pages as well
add_post_type_support( 'page', 'excerpt' );
/**
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support(
'html5',
array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
)
);
// Support for selective refresh widgets in Customizer
add_theme_support( 'customize-selective-refresh-widgets' );
// Gutenberg wide layout support.
add_theme_support( 'align-wide' );
// Gutenberg block styles support.
add_theme_support( 'wp-block-styles' );
// Gutenberg responsive embeds support.
add_theme_support( 'responsive-embeds' );
// Define and register starter content to showcase the theme on new sites.
$starter_content = array(
'widgets' => array(
// Add the search widget to the header sidebar.
'spacious_header_sidebar' => array(
'header_search' => array(
'search',
array(
'title' => '',
),
),
),
// Add text widgets to the contact sidebar.
'spacious_contact_page_sidebar' => array(
'text_business_info',
'text_about',
),
// Add text widget and cta widget in the Business Top sidebar.
'spacious_business_page_top_section_sidebar' => array(
'text_top_sidebar_info' => array(
'text',
array(
'title' => esc_html__( 'Business Top Sidebar', 'spacious' ),
'text' => esc_html__( 'Shows widgets on Business Page Template Top Section.', 'spacious' ) . ' ' . __( 'Suitable widget: TG: Services, TG: Call To Action Widget, TG: Featured Widget', 'spacious' ) .
'<ul>
<li>' . '<strong>' . esc_html__( 'TG: Services', 'spacious' ) . '</strong>' . ' - ' . esc_html__( 'Display some pages as services. Best for Business Top or Bottom sidebar.', 'spacious' ) . '</li>
<li>' . '<strong>' . esc_html__( 'TG: Call To Action Widget', 'spacious' ) . '</strong>' . ' - ' . esc_html__( 'Use this widget to show the call to action section.', 'spacious' ) . '</li>
<li>' . '<strong>' . esc_html__( 'TG: Featured Widget', 'spacious' ) . '</strong>' . ' - ' . esc_html__( 'Show your some pages as recent work. Best for Business Top or Bottom sidebar.', 'spacious' ) . '</li>
</ul>',
),
),
'call_to_action' => array(
'spacious_call_to_action_widget',
array(
'text_main' => esc_html__( 'Call to Action Main Text', 'spacious' ),
'text_additional' => esc_html__( 'Call to Action Additional Text', 'spacious' ),
'button_text' => esc_html__( 'Theme Info', 'spacious' ),
'button_url' => 'https://themegrill.com/themes/spacious/',
),
),
),
// Add text widget and featured single page widget in the Business Middle Left Sidebar.
'spacious_business_page_middle_section_left_half_sidebar' => array(
'text_middle_left_sidebar_info' => array(
'text',
array(
'title' => esc_html__( 'Business Middle Left Sidebar', 'spacious' ),
'text' => esc_html__( 'Shows widgets on Business Page Template Middle Section Left Half.', 'spacious' ) . ' ' . esc_html__( 'Suitable widget: TG: Testimonial, TG: Featured Single Page', 'spacious' ),
),
),
'featured_single_page' => array(
'spacious_featured_single_page_widget',
array(
'page_id' => '02',
),
),
),
// Add text widget and testimonial widget in the Business Middle Right Sidebar.
'spacious_business_page_middle_section_right_half_sidebar' => array(
'text_middle_right_sidebar_info' => array(
'text',
array(
'title' => esc_html__( 'Business Middle Right Sidebar', 'spacious' ),
'text' => esc_html__( 'Shows widgets on Business Page Template Middle Section Right Half.', 'spacious' ) . ' ' . esc_html__( 'Suitable widget: TG: Testimonial, TG: Featured Single Page', 'spacious' ),
),
),
'testimonial' => array(
'spacious_testimonial_widget',
array(
'title' => esc_html__( 'TG: Testimonial', 'spacious' ),
'text' => 'Chocolate bar caramels fruitcake icing. Jujubes gingerbread marzipan applicake sweet lemon drops. Marshmallow cupcake bear claw oat cake candy marzipan. Cookie soufflé bear claw. ',
'name' => 'Mr. Bipin Singh',
'byline' => 'CEO',
),
),
),
// Add text widget in the Business Bottom Sidebar.
'spacious_business_page_bottom_section_sidebar' => array(
'text_bottom_sidebar_info' => array(
'text',
array(
'title' => esc_html__( 'Business Bottom Sidebar', 'spacious' ),
'text' => esc_html__( 'Shows widgets on Business Page Template Bottom Section.', 'spacious' ) . ' ' . __( 'Suitable widget: TG: Services, TG: Call To Action Widget, TG: Featured Widget', 'spacious' ) .
'<ul>
<li>' . '<strong>' . esc_html__( 'TG: Services', 'spacious' ) . '</strong>' . ' - ' . esc_html__( 'Display some pages as services. Best for Business Top or Bottom sidebar.', 'spacious' ) . '</li>
<li>' . '<strong>' . esc_html__( 'TG: Call To Action Widget', 'spacious' ) . '</strong>' . ' - ' . esc_html__( 'Use this widget to show the call to action section.', 'spacious' ) . '</li>
<li>' . '<strong>' . esc_html__( 'TG: Featured Widget', 'spacious' ) . '</strong>' . ' - ' . esc_html__( 'Show your some pages as recent work. Best for Business Top or Bottom sidebar.', 'spacious' ) . '</li>
</ul>',
),
),
),
// Add the text widget in the footer siderbar 1.
'spacious_footer_sidebar_one' => array(
'text_business_info',
),
// Add search widget and text widget in the footer siderbar 2.
'spacious_footer_sidebar_two' => array(
'search',
'text_about',
),
// Add the text widget in the footer siderbar 3.
'spacious_footer_sidebar_three' => array(
'text_custom_menu' => array(
'text',
array(
'title' => esc_html__( 'Spacious Important Links', 'spacious' ),
'text' => '<ul>
<li><a href="https://themegrill.com/themes/spacious/">' . esc_html__( 'Theme Info', 'spacious' ) . '</a></li>
<li><a href="https://themegrilldemos.com/spacious/">' . esc_html__( 'View Demo', 'spacious' ) . '</a></li>
<li><a href="https://www.youtube.com/watch?v=rhiybsv3vUU">' . esc_html__( 'Import Demo', 'spacious' ) . '</a></li>
<li><a href="https://docs.themegrill.com/spacious/">' . esc_html__( 'Documentation', 'spacious' ) . '</a></li>
<li><a href="https://wordpress.org/support/theme/spacious/">' . esc_html__( 'Support Forum', 'spacious' ) . '</a></li>
</ul>',
),
),
),
// Add the featured single page widget in the footer siderbar 4.
'spacious_footer_sidebar_four' => array(
'featured_single_page' => array(
'spacious_featured_single_page_widget',
array(
'page_id' => '02',
),
),
),
),
// Specify the core-defined pages to create.
'posts' => array(
'home' => array(
'template' => 'page-templates/business.php',
),
'about',
'blog',
'contact' => array(
'template' => 'page-templates/contact.php',
),
),
// Create the custom image attachments for site logo.
'attachments' => array(
'image-logo' => array(
'post_title' => 'spacious logo image',
'file' => 'images/spacious-logo.png', // URL relative to the template directory.
),
),
// Default to a static front page and assign the front and posts pages.
'options' => array(
'show_on_front' => 'page',
'page_on_front' => '{{home}}',
'page_for_posts' => '{{blog}}',
),
// Setting theme mods of slider settings.
'theme_mods' => array(
'custom_logo' => '{{image-logo}}',
'spacious[spacious_show_header_logo_text]' => 'both',
'spacious[spacious_activate_slider]' => '1',
'spacious[spacious_blog_slider]' => '1',
'spacious[spacious_slider_image1]' => get_template_directory_uri() . '/images/book.jpg',
'spacious[spacious_slider_title1]' => esc_html__( 'Enter title for your slider.', 'spacious' ),
'spacious[spacious_slider_text1]' => 'Chocolate bar caramels fruitcake icing. Jujubes gingerbread marzipan applicake sweet lemon drops. Marshmallow cupcake bear claw oat cake candy marzipan. Cookie soufflé bear claw.',
'spacious[spacious_slider_button_text1]' => esc_html__( 'Read more', 'spacious' ),
'spacious[spacious_slider_link1]' => '#',
'spacious[spacious_slider_image2]' => get_template_directory_uri() . '/images/chess.jpg',
'spacious[spacious_slider_title2]' => esc_html__( 'Enter title for your slider.', 'spacious' ),
'spacious[spacious_slider_text2]' => 'Chocolate bar caramels fruitcake icing. Jujubes gingerbread marzipan applicake sweet lemon drops. Marshmallow cupcake bear claw oat cake candy marzipan. Cookie soufflé bear claw.',
'spacious[spacious_slider_button_text2]' => esc_html__( 'Read more', 'spacious' ),
'spacious[spacious_slider_link2]' => '#',
),
// Set up nav menus for each of the two areas registered in the theme.
'nav_menus' => array(
// Assign a menu to the "primary" location.
'primary' => array(
'name' => esc_html__( 'Primary Menu', 'spacious' ),
'items' => array(
'link_home',
// Note that the core "home" page is actually a link in case a static front page is not used.
'page_about',
'page_blog',
'page_contact',
),
),
// Assign a menu to the "footer" location.
'footer' => array(
'name' => esc_html__( 'Footer Menu', 'spacious' ),
'items' => array(
'page_about',
'page_blog',
'page_contact',
),
),
),
);
$starter_content = apply_filters( 'spacious_starter_content', $starter_content );
add_theme_support( 'starter-content', $starter_content );
}
endif;
add_action( 'after_setup_theme', 'spacious_setup' );
// Theme version.
$spacious_theme = wp_get_theme( 'spacious' );
define( 'SPACIOUS_THEME_VERSION', $spacious_theme->get( 'Version' ) );
/**
* Define Directory Location Constants
*/
define( 'SPACIOUS_PARENT_DIR', get_template_directory() );
define( 'SPACIOUS_CHILD_DIR', get_stylesheet_directory() );
define( 'SPACIOUS_INCLUDES_DIR', SPACIOUS_PARENT_DIR . '/inc' );
define( 'SPACIOUS_CSS_DIR', SPACIOUS_PARENT_DIR . '/css' );
define( 'SPACIOUS_JS_DIR', SPACIOUS_PARENT_DIR . '/js' );
define( 'SPACIOUS_LANGUAGES_DIR', SPACIOUS_PARENT_DIR . '/languages' );
define( 'SPACIOUS_ADMIN_DIR', SPACIOUS_INCLUDES_DIR . '/admin' );
define( 'SPACIOUS_WIDGETS_DIR', SPACIOUS_INCLUDES_DIR . '/widgets' );
define( 'SPACIOUS_ELEMENTOR_DIR', SPACIOUS_INCLUDES_DIR . '/elementor' );
define( 'SPACIOUS_ADMIN_IMAGES_DIR', SPACIOUS_ADMIN_DIR . '/images' );
define( 'SPACIOUS_ADMIN_CSS_DIR', SPACIOUS_ADMIN_DIR . '/css' );
/**
* Define URL Location Constants
*/
define( 'SPACIOUS_PARENT_URL', get_template_directory_uri() );
define( 'SPACIOUS_CHILD_URL', get_stylesheet_directory_uri() );
define( 'SPACIOUS_INCLUDES_URL', SPACIOUS_PARENT_URL . '/inc' );
define( 'SPACIOUS_CSS_URL', SPACIOUS_PARENT_URL . '/css' );
define( 'SPACIOUS_JS_URL', SPACIOUS_PARENT_URL . '/js' );
define( 'SPACIOUS_LANGUAGES_URL', SPACIOUS_PARENT_URL . '/languages' );
define( 'SPACIOUS_ADMIN_URL', SPACIOUS_INCLUDES_URL . '/admin' );
define( 'SPACIOUS_WIDGETS_URL', SPACIOUS_INCLUDES_URL . '/widgets' );
define( 'SPACIOUS_ADMIN_IMAGES_URL', SPACIOUS_ADMIN_URL . '/images' );
define( 'SPACIOUS_ADMIN_CSS_URL', SPACIOUS_ADMIN_URL . '/css' );
/** Load functions */
require_once SPACIOUS_INCLUDES_DIR . '/custom-header.php';
require_once SPACIOUS_INCLUDES_DIR . '/functions.php';
require_once SPACIOUS_INCLUDES_DIR . '/header-functions.php';
require_once SPACIOUS_INCLUDES_DIR . '/customizer/class-spacious-customizer.php';
require_once SPACIOUS_INCLUDES_DIR . '/customizer/class-spacious-customizer-partials.php';
require_once SPACIOUS_ADMIN_DIR . '/meta-boxes.php';
require_once SPACIOUS_INCLUDES_DIR . '/enqueue-scripts.php';
require_once SPACIOUS_INCLUDES_DIR . '/class-spacious-dynamic-css.php';
require_once SPACIOUS_INCLUDES_DIR . '/migration.php';
/** Load demo import migration scripts. */
require_once SPACIOUS_INCLUDES_DIR . '/demo-import-migration.php';
/** Load Widgets and Widgetized Area */
require_once SPACIOUS_WIDGETS_DIR . '/widgets.php';
define( 'SPACIOUS_CUSTOMIZER_DIR', SPACIOUS_INCLUDES_DIR . '/customizer' );
/**
* Detect plugin. For use on Front End only.
*/
require_once ABSPATH . 'wp-admin/includes/plugin.php';
/**
* Assign the Spacious version to a variable.
*/
$theme = wp_get_theme( 'spacious' );
$spacious_version = $theme['Version'];
/**
* Calling in the admin area for the Welcome Page as well as for the new theme notice too.
*/
if ( is_admin() ) {
require get_template_directory() . '/inc/admin/class-spacious-admin.php';
require get_template_directory() . '/inc/admin/class-spacious-dashboard.php';
require get_template_directory() . '/inc/admin/class-spacious-theme-review-notice.php';
require get_template_directory() . '/inc/admin/class-spacious-tdi-notice.php';
require get_template_directory() . '/inc/admin/class-spacious-welcome-notice.php';
require get_template_directory() . '/inc/admin/class-spacious-notice.php';
require get_template_directory() . '/inc/admin/class-spacious-upgrade-notice.php';
}
/**
* Load the Spacious Toolkit file.
*/
if ( class_exists( 'Spacious_Toolkit' ) ) {
require_once SPACIOUS_INCLUDES_DIR . '/spacious-toolkit.php';
}
/**
* Load Jetpack compatibility file.
*/
if ( defined( 'JETPACK__VERSION' ) ) {
require_once get_template_directory() . '/inc/jetpack.php';
}
/** Add the Elementor compatibility file */
if ( defined( 'ELEMENTOR_VERSION' ) ) {
require_once SPACIOUS_INCLUDES_DIR . '/elementor/elementor.php';
}
/**
* Load deprecated functions.
*/
require get_template_directory() . '/inc/deprecated/deprecated-functions.php';