forked from johnlevandowski/WPselect-genesis-child
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
168 lines (146 loc) · 5.52 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
<?php
/** Start the engine */
require_once( get_template_directory() . '/lib/init.php' );
/** Child theme (do not remove) */
define( 'CHILD_THEME_NAME', 'WPselect' );
define( 'CHILD_THEME_URL', 'http://wpselect.com/' );
/** Child Theme Settings */
include_once( CHILD_DIR . '/lib/child-theme-settings.php');
/** Child Theme Widget Areas */
include_once( CHILD_DIR . '/lib/child-widgetize.php');
/** Child Theme Custom Post Content Functions */
include_once( CHILD_DIR . '/lib/child-post.php');
/** Add Viewport meta tag for mobile browsers */
add_action( 'genesis_meta', 'add_viewport_meta_tag' );
function add_viewport_meta_tag() {
echo '<meta name="viewport" content="width=device-width, initial-scale=1.0"/>';
}
/** Create additional color style options */
add_theme_support( 'genesis-style-selector', array(
'wpselect-blue' => 'Blue',
'wpselect-orange' => 'Orange',
'wpselect-red' => 'Red',
)
);
/** Add support for custom background */
add_theme_support( 'custom-background' );
/**
* Add support for custom header
* genesis/lib/structure/header.php
*/
add_theme_support( 'custom-header', array( 'width' => 1140, 'flex-height' => true, 'height' => 90, 'default-text-color' => 'fff', 'wp-head-callback' => 'wpselect_custom_header_style' ) );
function wpselect_custom_header_style() {
/** If no options set, don't waste the output. Do nothing. */
if ( HEADER_TEXTCOLOR == get_header_textcolor() && HEADER_IMAGE == get_header_image() )
return;
/** Header image CSS */
$output = sprintf( '#header .wrap { background-image: url(%s); min-height: %spx }', esc_url( get_header_image() ), get_custom_header()->height );
/** Header text color CSS, if showing text */
if ( 'blank' != get_header_textcolor() )
$output .= sprintf( '#title a, #title a:hover, #description { color: #%s; }', esc_html( get_header_textcolor() ) );
printf( '<style type="text/css">%s</style>', $output );
}
/** Add support for 3-column footer widgets */
add_theme_support( 'genesis-footer-widgets', 3 );
/** Move secondary nav menu above header */
remove_action( 'genesis_after_header', 'genesis_do_subnav' );
add_action( 'genesis_before_header', 'genesis_do_subnav' );
/**
* Remove default stylesheet
* Add minified stylesheet with version number
* genesis/lib/structure/layout.php
*/
remove_action( 'genesis_meta', 'genesis_load_stylesheet' );
add_action( 'genesis_meta', 'wpselect_load_stylesheet' );
function wpselect_load_stylesheet() {
wp_register_style(
'wpselect-style',
CHILD_URL . '/style-min.css',
false,
filemtime( CHILD_DIR . '/style-min.css' )
);
wp_enqueue_style( 'wpselect-style' );
}
/**
* Customize the post info function
* genesis/lib/structure/post.php
*/
add_filter( 'genesis_post_info', 'wpselect_post_info' );
function wpselect_post_info($post_info) {
if (!is_page()) {
$post_info = '[post_date] [post_comments] [post_edit]';
return $post_info;
}
}
/**
* Shortcode to display number of MySQL queries and time to generate page
*/
add_shortcode( 'wpselect_page_stats', 'wpselect_page_stats_shortcode' );
function wpselect_page_stats_shortcode( $atts ) {
$defaults = array(
'after' => '',
'before' => '',
);
$atts = shortcode_atts( $defaults, $atts );
$output = $atts['before'] . get_num_queries() . ' MySQL queries in ' . timer_stop($display = 0, $precision = 2) . ' seconds' . $atts['after'];
return $output;
}
/**
* Customize the credits
* genesis/lib/structure/footer.php
*/
add_filter('genesis_footer_creds_text', 'wpselect_footer_creds_text');
function wpselect_footer_creds_text($creds_text) {
$creds_text = '</p>' . wpautop( genesis_get_option('credits-text', 'wpselect-child-theme-settings') ) . '<p>';
return $creds_text;
}
/** Modify the length of post excerpts 55 default */
add_filter( 'excerpt_length', 'wpselect_excerpt_length' );
function wpselect_excerpt_length($length) {
return 60;
}
/** Modify the more link of post excerpts */
add_filter('excerpt_more', 'wpselect_excerpt_more');
function wpselect_excerpt_more($more) {
global $post;
return ' ... <a href="' . get_permalink($post->ID) . '">[Read more...]</a>';
}
/** Lower jpeg quality for media */
add_filter( 'jpeg_quality', 'wpselect_jpeg_quality' );
function wpselect_jpeg_quality( $quality ) {
return (int)79;
}
//** Google custom search if activated */
if ( genesis_get_option('google-cse-activate', 'wpselect-child-theme-settings') == 1 ) {
/**
* Customize the search text
* genesis/lib/structure/search.php
*/
add_filter( 'genesis_search_text', 'wpselect_genesis_search_text');
function wpselect_genesis_search_text() {
return esc_attr('Google Search ...');
}
/**
* Customize the search form
* genesis/lib/structure/search.php
*/
add_filter( 'genesis_search_form', 'wpselect_genesis_search_form', 10, 4);
function wpselect_genesis_search_form( $form, $search_text, $button_text, $label ) {
$onfocus = " onfocus=\"if (this.value == '$search_text') {this.value = '';}\"";
$onblur = " onblur=\"if (this.value == '') {this.value = '$search_text';}\"";
$form = '
<form method="get" class="searchform" action="' . esc_attr( genesis_get_option('google-cse-url', 'wpselect-child-theme-settings') ) . '" >' . $label . '
<input type="text" value="' . $search_text . '" name="q" class="s"' . $onfocus . $onblur . ' />
<input type="submit" name="submit" class="searchsubmit" value="' . $button_text . '" />
</form>
';
return $form;
}
}
/** YARPP Related Posts */
add_action( 'genesis_after_post_content', 'wpselect_related_posts', 9 );
function wpselect_related_posts() {
if ( is_single() && function_exists('related_posts') ) {
related_posts();
}
}