forked from gramophone-wp/Gramophone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
112 lines (90 loc) · 3.23 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
<?php
/**
*******************************************************************************
* //functions.php
*******************************************************************************
*
* The theme functions.
*
* CODEX REF
* https://codex.wordpress.org/Functions_File_Explained
*
* @author
* @copyright
* @link
* @todo
* @license
* @since
* @version
**/
if( !isset( $content_width ) ) {
$content_width = 600;
}
// Theme Dependencies ~ best not remove these!
require_once locate_template('includes/class-tgm-plugin-activation.php');
require_once( 'includes/bootstrap_walker.php' );
require_once( 'includes/comments.php' );
// Admin Customisations
require_once( 'config/admin.php' );
require_once( 'config/login.php' );
// Theme Specific Customisations
require_once( 'config/enqueue.php' );
require_once( 'config/menus.php' );
require_once( 'config/widgets.php' );
require_once( 'config/comments.php' );
require_once( 'config/support.php' );
require_once( 'config/breadcrumbs.php' );
require_once( 'config/pagination.php' );
require_once( 'config/styling.php' );
// Theme Recommended & Required Plugins
require_once( 'config/required_plugins.php' );
// Theme custom post types
// require_once( '' );
function theme_queue_js() {
if (!is_admin()) {
if ( is_singular() AND comments_open() AND (get_option('thread_comments') == 1)) {
wp_enqueue_script( 'comment-reply' );
}
}
}
add_action('get_header', 'theme_queue_js');
add_filter( "the_excerpt", "add_class_to_excerpt" );
function add_class_to_excerpt( $excerpt ) {
return str_replace('<p', '<p class="card-title"', $excerpt);
}
add_filter('post_gallery','format_gallery_bootstrap',10,3);
function format_gallery_bootstrap( $output, $atts, $instance ){
$atts = shortcode_atts( array(
'columns' => 3,
'link' => 'attachment',
'size' => 'thumbnail'
), $atts);
$output = '<div id="container" class="container">';
$posts = get_posts(array('include' => $atts['ids'],'post_type' => 'attachment','orderby'=>$atts['orderby']));
$post_chuncks = array_chunk( $posts, $atts[ 'columns' ] );
foreach( $post_chuncks as $post_chunk ){
$output .= '<div class="row">';
foreach( $post_chunk as $post ){
$src = wp_get_attachment_image_src($post->ID, $atts['size'])[0];
$link = false;
if( 'attachment' == $atts[ 'link' ] ){
$link = get_attachment_link($post->ID);
} elseif( 'file' == $atts[ 'link' ] ){
$link = $src;
}
$class = ( 'thumbnail' == $atts[ 'size' ] ) ? 'img-thumbnail' : 'img-fluid';
$output .= '<div class="col-sm">';
if( $link ) $output .= '<a href="'.$link.'" style="display:block;">';
$output .= '<div class="text-center">';
$output .= '<img alt="'.$post->post_title.'" src="'.$src.'" class="'.$class.'" style="margin:auto;" />';
$output .= '</div>';
if( $link ) $output .= '</a>';
$output .= '<div class="text-muted text-center">'.$post->post_excerpt.'</div>';
$output .= '</div>';
}
$output .= '</div>';
}
$output .= "</div>";
return $output;
}
?>