-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
353 lines (257 loc) · 9.78 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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
<?php
// Start the engine
require_once( get_template_directory() . '/lib/init.php' );
require_once(CHILD_DIR.'/theme-js.php');
//Add Localization Support
load_child_theme_textdomain( 'mp', apply_filters( 'child_theme_textdomain', get_stylesheet_directory() . '/languages', 'mp' ) );
// Child theme (do not remove)
define( 'CHILD_THEME_NAME', __( 'Modern Portfolio Theme', 'mp' ) );
define( 'CHILD_THEME_URL', 'http://my.studiopress.com/themes/modern-portfolio/' );
// Add Viewport meta tag for mobile browsers
add_action( 'genesis_meta', 'mp_viewport_meta_tag' );
function mp_viewport_meta_tag() {
echo '<meta name="viewport" content="width=device-width, initial-scale=1.0"/>';
}
// Add new image sizes
add_image_size( 'blog', 320, 120, TRUE );
add_image_size( 'portfolio', 320, 210, TRUE );
// Unregister layout settings
genesis_unregister_layout( 'content-sidebar-sidebar' );
genesis_unregister_layout( 'sidebar-content-sidebar' );
genesis_unregister_layout( 'sidebar-sidebar-content' );
// Unregister secondary sidebar
unregister_sidebar( 'sidebar-alt' );
// Remove the site description
remove_action( 'genesis_site_description', 'genesis_seo_site_description' );
// Add support for custom background
add_theme_support( 'custom-background' );
// Add support for custom header
add_theme_support( 'genesis-custom-header', array(
'width' => 1152,
'height' => 120
) );
// Modify the size of the Gravatar in author box
add_filter( 'genesis_author_box_gravatar_size', 'mp_author_box_gravatar_size' );
function mp_author_box_gravatar_size( $size ) {
return 80;
}
// Add support for 3-column footer widgets
add_theme_support( 'genesis-footer-widgets', 3 );
/**
* Genesis Next/Previous Post Navigation (after post, before comments)
*
*/
add_action( 'genesis_after_post_content', 'ac_next_prev_post_nav' );
function ac_next_prev_post_nav() {
if ( is_single() ) {
echo '<div class="loop-nav">';
previous_post_link( '<div class="previous">Previous: %link</div>', '%title' );
next_post_link( '<div class="next">Next: %link</div>', '%title' );
echo '</div><!-- .loop-nav -->';
}
}
// Hooks after-post widget area to single posts
add_action( 'genesis_after_post_content', 'metro_after_post' );
function metro_after_post() {
if ( is_single() && is_active_sidebar( 'after-post' ) ) {
echo '<div class="after-post"><div class="wrap">';
dynamic_sidebar( 'after-post' );
echo '</div></div>';
}
}
// Hooks after-post widget area to single posts
add_action( 'genesis_after_footer', 'timemachine_after_footer' );
function timemachine_after_footer() {
if ( is_page( 'about' ) ) {
echo '<div id="timemachine"></div>';
}
}
/** Register widget areas */
genesis_register_sidebar( array(
'id' => 'top',
'name' => __( 'Top', 'mp' ),
'description' => __( 'This is the top section.', 'mp' ),
) );
genesis_register_sidebar( array(
'id' => 'about',
'name' => __( 'About', 'mp' ),
'description' => __( 'This is the about section.', 'mp' ),
) );
genesis_register_sidebar( array(
'id' => 'portfolio',
'name' => __( 'Portfolio', 'mp' ),
'description' => __( 'This is the portfolio section.', 'mp' ),
) );
genesis_register_sidebar( array(
'id' => 'services',
'name' => __( 'Services', 'mp' ),
'description' => __( 'This is the Services section.', 'mp' ),
) );
genesis_register_sidebar( array(
'id' => 'clients',
'name' => __( 'Clients', 'mp' ),
'description' => __( 'This is the Ideal Clients section.', 'mp' ),
) );
genesis_register_sidebar( array(
'id' => 'blog',
'name' => __( 'Blog', 'mp' ),
'description' => __( 'This is the Blog section.', 'mp' ),
) );
genesis_register_sidebar( array(
'id' => 'contact',
'name' => __( 'Contact', 'mp' ),
'description' => __( 'This is the Contact section.', 'mp' ),
) );
genesis_register_sidebar( array(
'id' => 'after-post',
'name' => __( 'After Post', 'mp' ),
'description' => __( 'This is the after post section.', 'mp' ),
) );
genesis_register_sidebar( array(
'id' => 'after-portfolio-widget',
'name' => __( 'After Post', 'mp' ),
'description' => __( 'This is the after post section.', 'mp' ),
) );
add_filter('widget_text', 'do_shortcode');
if ( ! isset( $content_width ) )
$content_width = 1080;
/** Customize Read More Text */
add_filter( 'excerpt_more', 'child_read_more_link' );
add_filter( 'get_the_content_more_link', 'child_read_more_link' );
add_filter( 'the_content_more_link', 'child_read_more_link' );
function child_read_more_link() {
return '<br></br><a href="' . get_permalink() . '" rel="nofollow" class="more-link" > Keep Reading...</a>';
}
remove_action( 'genesis_after_post_content', 'genesis_post_meta' );
//* Add Jetpack share buttons above post
remove_filter( 'the_content', 'sharing_display', 19 );
remove_filter( 'the_excerpt', 'sharing_display', 19 );
add_filter( 'the_content', 'share_buttons_above_post', 19 );
add_filter( 'the_excerpt', 'share_buttons_above_post', 19 );
function share_buttons_above_post( $content = '' ) {
if ( function_exists( 'sharing_display' ) && is_single() ) {
return sharing_display() . $content;
}
else {
return $content;
}
}
add_filter( 'genesis_pre_get_option_site_layout', 'change_layout_blog_genesis');
function change_layout_blog_genesis( $opt ) {
if (is_single() || is_page_template( 'page_blog.php' ) ) {
$opt = 'content-sidebar';
return $opt;
}
}
add_action( 'wp_enqueue_scripts', 'smoothscroll_scripts' );
/**
* Enqueue Scripts
*/
function smoothscroll_scripts() {
if ( is_page() || is_single( ) || is_home() || is_front_page() ) {
wp_enqueue_script( 'scrollTo', get_stylesheet_directory_uri() . '/js/jquery.scrollTo.min.js', array( 'jquery' ), '1.4.5-beta', true );
wp_enqueue_script( 'localScroll', get_stylesheet_directory_uri() . '/js/jquery.localScroll.min.js', array( 'scrollTo' ), '1.2.8b', true );
wp_enqueue_script( 'scroll', get_stylesheet_directory_uri() . '/js/scroll.js', array( 'localScroll' ), '', true );
}
}
/*
//* Enqueue scripts
add_action( 'wp_enqueue_scripts', 'scripts_footer_services_page' );
function scripts_footer_services_page() {
if ( is_single('482') ) {
wp_enqueue_script( 'services-1', get_stylesheet_directory_uri() . '/js/services-1.js', array( 'jquery' ), '', true );
wp_enqueue_script( 'services-2', get_stylesheet_directory_uri() . '/js/services-2.js', array( 'jquery' ), '', true );
}
}
*/
/**add_action( 'genesis_after_footer', 'scripts_footer_services_page' );
/**
* Enqueue Scripts
*/
/**
function scripts_footer_services_page() {
if ( is_single('482') ) {
wp_enqueue_script( 'services-1', get_stylesheet_directory_uri() . '/js/services-1.js', array( 'jquery' ), '', true );
wp_enqueue_script( 'services-2', get_stylesheet_directory_uri() . '/js/services-2.js', array( 'jquery' ), '', true );
}
}
*/
/** Add mobile menu toggle */
add_action( 'genesis_header_right', 'mycustom_mobile_menu_toggle', 5 );
function mycustom_mobile_menu_toggle() {
echo '<div class="menu-toggle">';
echo '<span><a href="#">Menu</a></span>';
echo '<i class="icon-reorder"></i>';
echo '</div>';
}
/**
* Registers and loads font awesome
* CSS files using a CDN.
*Read more at http://youneedfat.com/font-awesome-wordpress-cdn/#MIIsB8FzXehhUups.99
* @link http://www.bootstrapcdn.com/#tab_fontawesome
* @author FAT Media
*/
/**add_action( 'wp_enqueue_scripts', 'mytheme_add_the_awesome' );
function mytheme_add_the_awesome() {
// Register the awesomeness.
wp_register_style( 'font-awesome', '//netdna.bootstrapcdn.com/font-awesome/3.2.0/css/font-awesome.min.css', null, '3.2.0' );
do_action( 'mytheme_add_the_awesome' );
}
// Load the awesomeness
add_action( 'mytheme_add_the_awesome' , 'mytheme_load_the_awesome' );
function mytheme_load_the_awesome() {
wp_enqueue_style( 'font-awesome' );
}
*/
// fix the content with for embeds
if ( ! isset( $content_width ) )
$content_width = 708;
function custom_content_width() {
global $content_width;
$layout = genesis_site_layout();
if( in_array( $layout, array( 'content-sidebar-sidebar', 'sidebar-content-sidebar', 'sidebar-sidebar-content' ) ) )
$content_width = 676;
elseif( 'full-width-content' == $layout )
$content_width = 1080;
}
add_action( 'template_redirect', 'custom_content_width' );
// Add support for Genesis layouts to listings post type
add_post_type_support( 'portfolio', 'genesis-layouts' );
// Force layout on custom post type
add_filter('genesis_site_layout', 'ts_portfolio_layout');
function ts_portfolio_layout($opt) {
if ( 'portfolio' == get_post_type() )
$opt = 'full-width-content';
return $opt;
}
add_action('genesis_before_loop','sfws_tax_single');
/**
* Remove post meta and post info on single post type.
*
* @author Sure Fire Web Services
* @link http://surefirewebservices.com/?p=1563
*
*/
function sfws_tax_single() {
if (is_singular('portfolio')) { //Replace post_type with your post type slug
remove_action( 'genesis_before_post_content', 'genesis_post_info' );
remove_action( 'genesis_after_post_content', 'genesis_post_meta' );
remove_action( 'genesis_after_post_content', 'metro_after_post' );
}
}
// Hooks after-post widget area to single posts
add_action( 'genesis_after_post_content', 'after_portfolio_post' );
/**
* Add After Portfolio Widget to Custom Post Type Portfolio
*
* @author Jay Gidwitz
* @link http://studioissa.com/
*
*/
function after_portfolio_post() {
if ( is_single('portfolio') && is_active_sidebar( 'after-portfolio-widget' ) ) {
echo '<div class="after-post"><div class="wrap">';
dynamic_sidebar( 'after-post' );
echo '</div></div>';
}
}