forked from srikat/genesis-sample
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
executable file
·223 lines (172 loc) · 7.47 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
/**
* Genesis Sample.
*
* This file adds functions to the Genesis Sample Theme.
*
* @package Genesis Sample
* @author Yosef Eliezrie
* @license GPL-2.0+
* @link https://github.com/yosefeliezrie/genesis-sample
*/
///* Start the engine
include_once( get_template_directory() . '/lib/init.php' );
//* Setup Theme
include_once( get_stylesheet_directory() . '/lib/theme-defaults.php' );
//* Set Localization (do not remove)
load_child_theme_textdomain( 'genesis-sample', apply_filters( 'child_theme_textdomain', get_stylesheet_directory() . '/languages', 'genesis-sample' ) );
//* Child theme (do not remove)
define( 'CHILD_THEME_NAME', 'Genesis Sample' );
define( 'CHILD_THEME_URL', 'http://www.studiopress.com/' );
define( 'CHILD_THEME_VERSION', '2.4.2' );
//* Enqueue Scripts and Styles
add_action( 'wp_enqueue_scripts', 'genesis_sample_enqueue_scripts_styles' );
function genesis_sample_enqueue_scripts_styles() {
wp_enqueue_style( 'genesis-sample-fonts', '//fonts.googleapis.com/css?family=Source+Sans+Pro:400,600,700', array(), CHILD_THEME_VERSION );
wp_enqueue_style( 'dashicons' );
wp_enqueue_script( 'genesis-sample-responsive-menu', CHILD_URL . '/js/responsive-menu.js', array( 'jquery' ), '1.0.0', true );
$output = array(
'mainMenu' => __( 'Menu', 'genesis-sample' ),
'subMenu' => __( 'Menu', 'genesis-sample' ),
);
wp_localize_script( 'genesis-sample-responsive-menu', 'genesisSampleL10n', $output );
}
//* Add HTML5 markup structure
add_theme_support( 'html5', array( 'caption', 'comment-form', 'comment-list', 'gallery', 'search-form' ) );
//* Add Accessibility support
add_theme_support( 'genesis-accessibility', array( '404-page', 'drop-down-menu', 'headings', 'rems', 'search-form', 'skip-links' ) );
//* Add viewport meta tag for mobile browsers
add_theme_support( 'genesis-responsive-viewport' );
//* Add support for custom header
add_theme_support( 'custom-header', array(
'width' => 600,
'height' => 160,
'flex-height' => true,
'flex-width' => true,
'header-text' => false,
) );
//* Add support for custom background
add_theme_support( 'custom-background' );
//* Add support for after entry widget
add_theme_support( 'genesis-after-entry-widget-area' );
//* Add support for 3-column footer widgets
add_theme_support( 'genesis-footer-widgets', 3 );
//* Add Image Sizes
add_image_size( 'featured-image', 720, 400, true );
//* Rename primary and secondary navigation menus
add_theme_support( 'genesis-menus' , array( 'primary' => __( 'Primary Navigation', 'genesis-sample' ), 'secondary' => __( 'Footer Menu', 'genesis-sample' ) ) );
//* Reposition the secondary navigation menu
remove_action( 'genesis_after_header', 'genesis_do_subnav' );
add_action( 'genesis_footer', 'genesis_do_subnav', 5 );
//* Reduce the secondary navigation menu to one level depth
add_filter( 'wp_nav_menu_args', 'genesis_sample_secondary_menu_args' );
function genesis_sample_secondary_menu_args( $args ) {
if ( 'secondary' != $args['theme_location'] ) {
return $args;
}
$args['depth'] = 1;
return $args;
}
//* Modify size of the Gravatar in the author box
add_filter( 'genesis_author_box_gravatar_size', 'genesis_sample_author_box_gravatar' );
function genesis_sample_author_box_gravatar( $size ) {
return 90;
}
//* Modify size of the Gravatar in the entry comments
add_filter( 'genesis_comment_list_args', 'genesis_sample_comments_gravatar' );
function genesis_sample_comments_gravatar( $args ) {
$args['avatar_size'] = 60;
return $args;
}
// Remove Header Right widget area
unregister_sidebar( 'header-right' );
// Reposition the primary navigation menu
remove_action( 'genesis_after_header', 'genesis_do_nav' );
add_action( 'genesis_header', 'genesis_do_nav' );
// Remove Primary Navigation's wrap
add_theme_support( 'genesis-structural-wraps', array(
'header',
// 'nav',
'subnav',
'footer-widgets',
'footer'
) );
// Remove custom Genesis custom header style
remove_action( 'wp_head', 'genesis_custom_header_style' );
/**********************************
*
* Replace Header Site Title with Inline Logo
*
* @author AlphaBlossom / Tony Eppright, Neil Gee
* @link http://www.alphablossom.com/a-better-wordpress-genesis-responsive-logo-header/
* @link https://wpbeaches.com/adding-in-a-responsive-html-logoimage-header-via-the-customizer-for-genesis/
*
* @edited by Sridhar Katakam
* @link https://sridharkatakam.com/
*
************************************/
add_filter( 'genesis_seo_title', 'custom_header_inline_logo', 10, 3 );
function custom_header_inline_logo( $title, $inside, $wrap ) {
if ( get_header_image() ) {
$logo = '<img src="' . get_header_image() . '" width="' . esc_attr( get_custom_header()->width ) . '" height="' . esc_attr( get_custom_header()->height ) . '" alt="' . esc_attr( get_bloginfo( 'name' ) ) . ' Homepage">';
} else {
$logo = get_bloginfo( 'name' );
}
$inside = sprintf( '<a href="%s">%s<span class="screen-reader-text">%s</span></a>', trailingslashit( home_url() ), $logo, get_bloginfo( 'name' ) );
// Determine which wrapping tags to use
$wrap = genesis_is_root_page() && 'title' === genesis_get_seo_option( 'home_h1_on' ) ? 'h1' : 'p';
// A little fallback, in case an SEO plugin is active
$wrap = genesis_is_root_page() && ! genesis_get_seo_option( 'home_h1_on' ) ? 'h1' : $wrap;
// And finally, $wrap in h1 if HTML5 & semantic headings enabled
$wrap = genesis_html5() && genesis_get_seo_option( 'semantic_headings' ) ? 'h1' : $wrap;
return sprintf( '<%1$s %2$s>%3$s</%1$s>', $wrap, genesis_attr( 'site-title' ), $inside );
}
// Hide tagline
// add_filter( 'genesis_attr_site-description', 'abte_add_site_description_class' );
/**
* Add class for screen readers to site description.
*
* Unhook this if you'd like to show the site description.
*
* @since 1.0.0
*
* @param array $attributes Existing HTML attributes for site description element.
* @return string Amended HTML attributes for site description element.
*/
function abte_add_site_description_class( $attributes ) {
$attributes['class'] .= ' screen-reader-text';
return $attributes;
}
/**
* Remove Genesis Page Templates
*
* @author Bill Erickson
* @link http://www.billerickson.net/remove-genesis-page-templates
*
* @param array $page_templates
* @return array
*/
function be_remove_genesis_page_templates( $page_templates ) {
unset( $page_templates['page_archive.php'] );
unset( $page_templates['page_blog.php'] );
return $page_templates;
}
add_filter( 'theme_page_templates', 'be_remove_genesis_page_templates' );
// Add post navigation
add_action( 'genesis_after_loop', 'genesis_prev_next_post_nav' );
// Display author box on single posts
// add_filter( 'get_the_author_genesis_author_box_single', '__return_true' );
// Display author box on archive pages
// add_filter( 'get_the_author_genesis_author_box_archive', '__return_true' );
/**
* Remove Metaboxes
* This removes unused or unneeded metaboxes from Genesis > Theme Settings.
* See /genesis/lib/admin/theme-settings for all metaboxes.
*
* @author Bill Erickson
* @link http://www.billerickson.net/code/remove-metaboxes-from-genesis-theme-settings/
*/
function be_remove_metaboxes( $_genesis_theme_settings_pagehook ) {
remove_meta_box( 'genesis-theme-settings-blogpage', $_genesis_theme_settings_pagehook, 'main' );
}
add_action( 'genesis_theme_settings_metaboxes', 'be_remove_metaboxes' );