This repository has been archived by the owner on Apr 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfunctions.php
98 lines (77 loc) · 2.71 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
<?php
require "inc/customizer/announcement.php";
require "inc/customizer/call-to-action.php";
require "inc/application-flow/index.php";
require "inc/breadcrumbs.php";
require "inc/children.php";
require "inc/post-types.php";
require "inc/taxonomies.php";
require "inc/blocks.php";
require "inc/course-search.php";
require "inc/custom-fields.php";
add_editor_style( 'dist/css/editor.css' );
function lbh_load_scripts_and_styles() {
wp_enqueue_style("main", get_stylesheet_directory_uri()."/dist/css/index.css");
wp_enqueue_style("fonts", "https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;600;700;800&display=swap");
wp_enqueue_script("maps", "https://maps.googleapis.com/maps/api/js?key=" . GOOGLE_CLIENT_KEY);
wp_enqueue_script("main", get_stylesheet_directory_uri()."/dist/js/index.js");
}
add_action("wp_enqueue_scripts", "lbh_load_scripts_and_styles");
add_theme_support( 'custom-logo' );
add_theme_support( 'post-thumbnails' );
add_post_type_support( 'page', 'excerpt' );
function lbh_register_menus() {
register_nav_menus(
array(
"header-menu" => __( "Header area" ),
"top-header-menu" => __( "Top header area" ),
"footer-left-menu" => __( "Left footer area" ),
"footer-right-menu" => __( "Right footer area" ),
"popular-courses-menu" => __( "Popular courses" )
)
);
}
add_action( "init", "lbh_register_menus" );
// Configure ACF Google Maps field
function lbh_acf_init() {
acf_update_setting('google_api_key', GOOGLE_CLIENT_KEY);
}
add_action('acf/init', 'lbh_acf_init');
function lo_custom_excerpt_length( $length ) {
return 20;
}
add_filter( 'excerpt_length', 'lo_custom_excerpt_length', 999 );
function lo_excerpt_more($more) {
return '...';
}
add_filter('excerpt_more', 'lo_excerpt_more');
// Add query vars for course search
function lbh_course_search_query_vars($qvars) {
$qvars[] = 'keywords';
$qvars[] = 'topic';
$qvars[] = 'only';
$qvars[] = 'type';
// for quiz
$qvars[] = 'sectors';
$qvars[] = 'curriculum_areas';
return $qvars;
}
add_filter( 'query_vars', 'lbh_course_search_query_vars' );
function truncate($text, $length){
if ($length >= \strlen($text)) {
return $text;
}
return preg_replace(
"/^(.{1,$length})(\s.*|$)/s",
'\\1...',
$text
);
}
// stop relevanssi indexing private opportunities
// https://www.relevanssi.com/knowledge-base/private-posts-custom-post-types/
add_filter('relevanssi_post_ok', 'lbh_handle_private_courses', 11, 2);
function lbh_handle_private_courses($post_ok, $post_id) {
$status = relevanssi_get_post_status($post_id);
if ($status == 'private') $post_ok = false;
return $post_ok;
}