This repository has been archived by the owner on Mar 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
functions.php
executable file
·201 lines (156 loc) · 7.17 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
<?php
// Start the engine
include_once( get_template_directory() . '/lib/init.php' );
// Child theme (do not remove)
define( 'CHILD_THEME_NAME', 'Pods IO Genesis Child Theme' );
define( 'CHILD_THEME_URL', 'http://www.studiopress.com/' );
define( 'CHILD_THEME_VERSION', '1.0' );
define( 'CHILD_DOMAIN', 'podsio-genesis');
/**
* Set the content width based on the theme's design and stylesheet.
*
* @since Twenty Fifteen 1.0
*/
if ( ! isset( $content_width ) ) {
$content_width = 680;
}
// Enqueue Google Fonts
add_action( 'wp_enqueue_scripts', 'genesis_sample_google_fonts' );
function genesis_sample_google_fonts() {
wp_enqueue_style( 'google-fonts', '//fonts.googleapis.com/css?family=Lato:300,400,500,700', array(), CHILD_THEME_VERSION );
}
// Add HTML5 markup structure
add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' ) );
// Add Accessibility support
// add_theme_support( 'genesis-accessibility', array( 'headings', 'drop-down-menu', 'search-form', 'skip-links', 'rems' ) );
add_theme_support( 'genesis-accessibility', array( 'headings', 'search-form', 'skip-links', 'rems' ) );
// Add viewport meta tag for mobile browsers
add_theme_support( 'genesis-responsive-viewport' );
// Add support for custom background
add_theme_support( 'custom-background' );
// Add support for 3-column footer widgets
add_theme_support( 'genesis-footer-widgets', 3 );
/**********************************
*
* Replace Header Site Title with Inline Logo
*
* Fixes Genesis bug - when using static front page and blog page (admin reading settings) Home page is <p> tag and Blog page is <h1> tag
*
* Replaces "is_home" with "is_front_page" to correctly display Home page wit <h1> tag and Blog page with <p> tag
*
* @author AlphaBlossom / Tony Eppright
* @link http://www.alphablossom.com/a-better-wordpress-genesis-responsive-logo-header/
*
* @edited by Sridhar Katakam
* @link http://www.sridharkatakam.com/use-inline-logo-instead-background-image-genesis/
*
************************************/
add_filter( 'genesis_seo_title', 'custom_header_inline_logo', 10, 3 );
function custom_header_inline_logo( $title, $inside, $wrap ) {
$logo = '<img src="' . get_stylesheet_directory_uri() . '/images/logo.png" alt="' . esc_attr( get_bloginfo( 'name' ) ) . '" title="' . esc_attr( get_bloginfo( 'name' ) ) . '" width="300" height="60" />';
$inside = sprintf( '<a href="%s" title="%s">%s</a>', trailingslashit( home_url() ), esc_attr( get_bloginfo( 'name' ) ), $logo );
// Determine which wrapping tags to use - changed is_home to is_front_page to fix Genesis bug
$wrap = is_front_page() && 'title' === genesis_get_seo_option( 'home_h1_on' ) ? 'h1' : 'p';
// A little fallback, in case an SEO plugin is active - changed is_home to is_front_page to fix Genesis bug
$wrap = is_front_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 );
}
// Remove the site description
/* remove_action( 'genesis_site_description', 'genesis_seo_site_description' ); */
// Enqueue scripts and styles
add_action( 'wp_enqueue_scripts', 'custom_scripts_styles_mobile_responsive' );
function custom_scripts_styles_mobile_responsive() {
wp_enqueue_script( 'responsive-menu', get_stylesheet_directory_uri() . '/js/responsive-menu.js', array( 'jquery' ), '1.2.0', true );
wp_enqueue_style( 'dashicons' );
wp_enqueue_style( 'podsio-fontawesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css');
wp_localize_script( 'responsive-menu', 'screenReaderText', array(
'expand' => '<span class="screen-reader-text">' . __( 'expand child menu', 'podsio-genesis' ) . '</span>',
'collapse' => '<span class="screen-reader-text">' . __( 'collapse child menu', 'podsio-genesis' ) . '</span>',
) );
}
// Customize the previous page link
add_filter ( 'genesis_prev_link_text' , 'sp_previous_page_link' );
function sp_previous_page_link ( $text ) {
return g_ent( '« ' ) . __( 'Previous Page', CHILD_DOMAIN );
}
// Customize the next page link
add_filter ( 'genesis_next_link_text' , 'sp_next_page_link' );
function sp_next_page_link ( $text ) {
return __( 'Next Page', CHILD_DOMAIN ) . g_ent( ' » ' );
}
/**
* 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' );
function type_label ($post_type) {
if ($post_type == 'page') { return 'Documentation'; }
$post_type_obj = get_post_type_object( $post_type );
$post_type_label = $post_type_obj->labels->singular_name;
return $post_type_label;
}
/* Add Menu Social Links filters */
add_filter( 'storm_social_icons_use_latest', '__return_true' );
/* Add Post Excerpt to Pages */
add_action( 'init', 'my_add_excerpts_to_pages' );
function my_add_excerpts_to_pages() {
add_post_type_support( 'page', 'excerpt' );
}
/* Remove JetPack Sharing from Excerpt Display */
function jetpacktweak_remove_share () {
remove_filter( 'the_excerpt', 'sharing_display', 19 );
}
add_action( 'loop_start', 'jetpacktweak_remove_share' );
function change_doc_entry_text( $title ) {
$screen = get_current_screen();
if ( 'page' == $screen->post_type ) {
$title = 'Enter Documentation Title';
}
return $title;
}
add_filter( 'enter_title_here', 'change_doc_entry_text' );
/* Output filter for my_date
Use this against a date field in your Pods Fields like so:
{@post_date,my_date}
The Function below should be in your functions.php
*/
function return_date($input_date) {
return date("F d, Y", strtotime($input_date));
}
function return_age($input_date) {
$now = date("Y-m-d");
return date_diff(date_create($input_date), date_create($now))->format('%a days ago');
}
/* This filter fixes an issue where the Blog page is highlighted as a menu item
* for archives/singles of other post types.
*/
function custom_type_nav_class($classes, $item) {
$post_type = get_post_type();
// Remove current_page_parent from classes if the current item is the blog page
// Note: The object_id property seems to be the ID of the menu item's target.
if ($post_type != 'post' && $item->object_id == get_option('page_for_posts')) {
$current_value = "current_page_parent";
$classes = array_filter($classes, function ($element) use ($current_value) { return ($element != $current_value); } );
}
// Now look for post-type-<name> in the classes. A menu item with this class
// should be given a class that will highlight it.
$this_type_class = 'post-type-' . $post_type;
if (in_array( $this_type_class, $classes )) {
array_push($classes, 'current_page_parent');
};
return $classes;
}
add_filter('nav_menu_css_class', 'custom_type_nav_class', 10, 2);
/* Adding Facet WP to Genesis */