forked from jb510/JB-Genesis-Child
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
executable file
·239 lines (201 loc) · 7.65 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
<?php
/**
* Functions
*
* @package BE_Genesis_Child
* @since 1.0.0
* @link https://github.com/billerickson/BE-Genesis-Child
* @author Bill Erickson <[email protected]>
* @copyright Copyright (c) 2011, Bill Erickson
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
*
*/
/**
* Theme Setup
* @since 1.0.0
*
* This setup function attaches all of the site-wide functions
* to the correct hooks and filters. All the functions themselves
* are defined below this setup function.
*
*/
add_action('genesis_setup','child_theme_setup', 15);
function child_theme_setup() {
define( 'CHILD_THEME_VERSION', filemtime( get_stylesheet_directory() . '/style.css' ) );
// ** Backend **
// Image Sizes
// add_image_size( 'be_featured', 400, 100, true );
// Structural Wraps
add_theme_support( 'genesis-structural-wraps', array( 'header', 'nav', 'subnav', 'inner', 'footer-widgets', 'footer' ) );
// Menus
add_theme_support( 'genesis-menus', array( 'primary' => 'Primary Navigation Menu' ) );
// Sidebars
unregister_sidebar( 'sidebar-alt' );
//genesis_register_sidebar( array( 'name' => 'Blog Sidebar', 'id' => 'blog-sidebar' ) );
//add_theme_support( 'genesis-footer-widgets', 4 );
// Remove Unused Page Layouts
genesis_unregister_layout( 'content-sidebar-sidebar' );
genesis_unregister_layout( 'sidebar-sidebar-content' );
genesis_unregister_layout( 'sidebar-content-sidebar' );
// Remove Unused User Settings
add_filter( 'user_contactmethods', 'be_contactmethods' );
remove_action( 'show_user_profile', 'genesis_user_options_fields' );
remove_action( 'edit_user_profile', 'genesis_user_options_fields' );
remove_action( 'show_user_profile', 'genesis_user_archive_fields' );
remove_action( 'edit_user_profile', 'genesis_user_archive_fields' );
remove_action( 'show_user_profile', 'genesis_user_seo_fields' );
remove_action( 'edit_user_profile', 'genesis_user_seo_fields' );
remove_action( 'show_user_profile', 'genesis_user_layout_fields' );
remove_action( 'edit_user_profile', 'genesis_user_layout_fields' );
// Editor Styles
add_editor_style( 'editor-style.css' );
// Setup Theme Settings
include_once( CHILD_DIR . '/lib/functions/child-theme-settings.php' );
// Reposition Genesis Metaboxes
remove_action( 'admin_menu', 'genesis_add_inpost_seo_box' );
add_action( 'admin_menu', 'be_add_inpost_seo_box' );
remove_action( 'admin_menu', 'genesis_add_inpost_layout_box' );
add_action( 'admin_menu', 'be_add_inpost_layout_box' );
// Remove Genesis Widgets
add_action( 'widgets_init', 'be_remove_genesis_widgets', 20 );
// Remove Genesis Theme Settings Metaboxes
add_action( 'genesis_theme_settings_metaboxes', 'be_remove_genesis_metaboxes' );
// Don't update theme
add_filter( 'http_request_args', 'be_dont_update_theme', 5, 2 );
// ** Frontend **
// Remove Edit link
add_filter( 'genesis_edit_post_link', '__return_false' );
// Responsive Meta Tag
add_action( 'genesis_meta', 'be_viewport_meta_tag' );
// Footer
remove_action( 'genesis_footer', 'genesis_do_footer' );
add_action( 'genesis_footer', 'be_footer' );
}
// ** Backend Functions ** //
/**
* Customize Contact Methods
* @since 1.0.0
*
* @author Bill Erickson
* @link http://sillybean.net/2010/01/creating-a-user-directory-part-1-changing-user-contact-fields/
*
* @param array $contactmethods
* @return array
*/
function be_contactmethods( $contactmethods ) {
unset( $contactmethods['aim'] );
unset( $contactmethods['yim'] );
unset( $contactmethods['jabber'] );
return $contactmethods;
}
/**
* Register a new meta box to the post / page edit screen, so that the user can
* set SEO options on a per-post or per-page basis.
*
* @category Genesis
* @package Admin
* @subpackage Inpost-Metaboxes
*
* @since 0.1.3
*
* @see genesis_inpost_seo_box() Generates the content in the meta box
*/
function be_add_inpost_seo_box() {
if ( genesis_detect_seo_plugins() )
return;
foreach ( (array) get_post_types( array( 'public' => true ) ) as $type ) {
if ( post_type_supports( $type, 'genesis-seo' ) )
add_meta_box( 'genesis_inpost_seo_box', __( 'Theme SEO Settings', 'genesis' ), 'genesis_inpost_seo_box', $type, 'normal', 'default' );
}
}
/**
* Register a new meta box to the post / page edit screen, so that the user can
* set layout options on a per-post or per-page basis.
*
* @category Genesis
* @package Admin
* @subpackage Inpost-Metaboxes
*
* @since 0.2.2
*
* @see genesis_inpost_layout_box() Generates the content in the boxes
*
* @return null Returns null if Genesis layouts are not supported
*/
function be_add_inpost_layout_box() {
if ( ! current_theme_supports( 'genesis-inpost-layouts' ) )
return;
foreach ( (array) get_post_types( array( 'public' => true ) ) as $type ) {
if ( post_type_supports( $type, 'genesis-layouts' ) )
add_meta_box( 'genesis_inpost_layout_box', __( 'Layout Settings', 'genesis' ), 'genesis_inpost_layout_box', $type, 'normal', 'default' );
}
}
/**
* Remove Genesis widgets
*
* @since 1.0.0
*/
function be_remove_genesis_widgets() {
unregister_widget( 'Genesis_eNews_Updates' );
unregister_widget( 'Genesis_Featured_Page' );
unregister_widget( 'Genesis_Featured_Post' );
unregister_widget( 'Genesis_Latest_Tweets_Widget' );
unregister_widget( 'Genesis_User_Profile_Widget' );
}
/**
* Remove Genesis Theme Settings Metaboxes
*
* @since 1.0.0
* @param string $_genesis_theme_settings_pagehook
*/
function be_remove_genesis_metaboxes( $_genesis_theme_settings_pagehook ) {
//remove_meta_box( 'genesis-theme-settings-feeds', $_genesis_theme_settings_pagehook, 'main' );
//remove_meta_box( 'genesis-theme-settings-header', $_genesis_theme_settings_pagehook, 'main' );
remove_meta_box( 'genesis-theme-settings-nav', $_genesis_theme_settings_pagehook, 'main' );
//remove_meta_box( 'genesis-theme-settings-breadcrumb', $_genesis_theme_settings_pagehook, 'main' );
//remove_meta_box( 'genesis-theme-settings-comments', $_genesis_theme_settings_pagehook, 'main' );
//remove_meta_box( 'genesis-theme-settings-posts', $_genesis_theme_settings_pagehook, 'main' );
remove_meta_box( 'genesis-theme-settings-blogpage', $_genesis_theme_settings_pagehook, 'main' );
//remove_meta_box( 'genesis-theme-settings-scripts', $_genesis_theme_settings_pagehook, 'main' );
}
/**
* Don't Update Theme
* @since 1.0.0
*
* If there is a theme in the repo with the same name,
* this prevents WP from prompting an update.
*
* @author Mark Jaquith
* @link http://markjaquith.wordpress.com/2009/12/14/excluding-your-plugin-or-theme-from-update-checks/
*
* @param array $r, request arguments
* @param string $url, request url
* @return array request arguments
*/
function be_dont_update_theme( $r, $url ) {
if ( 0 !== strpos( $url, 'http://api.wordpress.org/themes/update-check' ) )
return $r; // Not a theme update request. Bail immediately.
$themes = unserialize( $r['body']['themes'] );
unset( $themes[ get_option( 'template' ) ] );
unset( $themes[ get_option( 'stylesheet' ) ] );
$r['body']['themes'] = serialize( $themes );
return $r;
}
// ** Frontend Functions ** //
/**
* Viewport Meta Tag for Mobile Browsers
*
* @author Bill Erickson
* @link http://www.billerickson.net/code/responsive-meta-tag
*/
function be_viewport_meta_tag() {
echo '<meta name="viewport" content="width=device-width, initial-scale=1.0"/>';
}
/**
* Footer
*
*/
function be_footer() {
echo '<div class="one-half first" id="footer-left">' . wpautop( genesis_get_option( 'footer-left', 'child-settings' ) ) . '</div>';
echo '<div class="one-half" id="footer-right">' . wpautop( genesis_get_option( 'footer-right', 'child-settings' ) ) . '</div>';
}