-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
156 lines (107 loc) · 4.94 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
<?php
// 1. customize ACF path
add_filter('acf/settings/path', 'my_acf_settings_path');
function my_acf_settings_path( $path ) {
// update path
$path = get_template_directory() . '/vendor/acf/';
// return
return $path;
}
// 2. customize ACF dir
add_filter('acf/settings/dir', 'my_acf_settings_dir');
function my_acf_settings_dir( $dir ) {
// update path
$dir = get_template_directory_uri() . '/vendor/acf/';
// return
return $dir;
}
// 3. Hide ACF field group menu item
add_filter('acf/settings/show_admin', '__return_false');
// 4. Include ACF
include_once( get_template_directory() . '/vendor/acf/acf.php' );
// Theme support options
require_once(get_template_directory().'/assets/functions/theme-support.php');
// WP Head and other cleanup functions
require_once(get_template_directory().'/assets/functions/cleanup.php');
// Register scripts and stylesheets
require_once(get_template_directory().'/assets/functions/enqueue-scripts.php');
// Register custom menus and menu walkers
require_once(get_template_directory().'/assets/functions/menu.php');
require_once(get_template_directory().'/assets/functions/menu-walkers.php');
// Register sidebars/widget areas
require_once(get_template_directory().'/assets/functions/sidebar.php');
// Makes WordPress comments suck less
require_once(get_template_directory().'/assets/functions/comments.php');
// Replace 'older/newer' post links with numbered navigation
require_once(get_template_directory().'/assets/functions/page-navi.php');
// Adds support for multiple languages
require_once(get_template_directory().'/assets/translation/translation.php');
// Adds site styles to the WordPress editor
//require_once(get_template_directory().'/assets/functions/editor-styles.php');
// Related post function - no need to rely on plugins
// require_once(get_template_directory().'/assets/functions/related-posts.php');
// Use this as a template for custom post types
require_once(get_template_directory().'/assets/functions/custom-post-type.php');
// Customize the WordPress login menu
require_once(get_template_directory().'/assets/functions/login.php');
// Customize the WordPress admin
require_once(get_template_directory().'/assets/functions/admin.php');
// Customize the WordPress customizer
require_once(get_template_directory().'/assets/functions/customize.php');
/* ADD RESOURCE AND NEWS POST TYPES TO THE MAIN QUERY ON AUTHOR AND CATEGORY PAGES */
add_filter( 'pre_get_posts', 'my_get_posts' );
function my_get_posts( $query ) {
if ( is_author() && $query->is_main_query() || is_category() && $query->is_main_query() )
$query->set( 'post_type', array( 'post', 'resource', 'news' ) );
return $query;
}
/* Admin init */
add_action( 'admin_init', 'my_settings_init' );
/* Settings Init */
function my_settings_init(){
/* Create settings section */
add_settings_section(
'contact-section-id', // Section ID
'Site Contact Details', // Section title
'contact_settings_section_description', // Section callback function
'general' // Settings page slug
);
/* Create settings field */
}
/* Setting Section Description */
function contact_settings_section_description(){
echo wpautop( "Please add Twitter and Email contact details here. These will display on the front-end contact sections of the website" );
}
add_filter('admin_init', 'my_general_settings_register_fields');
function my_general_settings_register_fields()
{
register_setting('general', 'twitter_field', 'esc_attr');
add_settings_field('twitter_field', '<label for="twitter_field">'.__('Twitter' , 'twitter_field' ).'</label>' , 'my_general_settings_fields_html', 'general', 'contact-section-id');
}
function my_general_settings_fields_html()
{
$value = get_option( 'twitter_field', '' );
echo '<input type="text" id="twitter_field" name="twitter_field" value="' . $value . '" />';
}
add_filter('admin_init', 'my_email_settings_register_fields');
function my_email_settings_register_fields()
{
register_setting('general', 'email_field', 'esc_attr');
add_settings_field('email_field', '<label for="email_field">'.__('Email' , 'email_field' ).'</label>' , 'my_email_settings_fields_html', 'general', 'contact-section-id');
}
function my_email_settings_fields_html()
{
$value = get_option( 'email_field', '' );
echo '<input type="text" id="email_field" name="email_field" value="' . $value . '" />';
}
add_filter('admin_init', 'my_upload_settings_register_fields');
function my_upload_settings_register_fields()
{
register_setting('general', 'upload_field', 'esc_attr');
add_settings_field('upload_field', '<label for="upload_field">'.__('Email' , 'upload_field' ).'</label>' , 'my_upload_settings_fields_html', 'general', 'contact-section-id');
}
function my_upload_settings_fields_html()
{
$value = get_option( 'upload_field', '' );
echo '<input type="file" id="upload_field" name="upload_field" value="' . $value . '" />';
}