This repository was archived by the owner on Jun 28, 2020. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathfunctions.php
More file actions
194 lines (165 loc) · 5.47 KB
/
Copy pathfunctions.php
File metadata and controls
194 lines (165 loc) · 5.47 KB
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
<?php
/**
* Theme functions.
*
* @link https://codex.wordpress.org/Functions_File_Explained
* @package gramophone
**/
if ( ! isset( $content_width ) ) {
$content_width = 600;
}
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'custom-background' );
add_theme_support( 'custom-header' );
add_theme_support( 'menus' );
add_theme_support( 'post-thumbnails' );
add_theme_support( 'post-formats' );
add_theme_support( 'title-tag' );
add_theme_support( 'editor-style' );
add_theme_support( 'html5' );
add_theme_support( 'widgets' );
// Theme Dependencies
require_once locate_template( 'externals/class-tgm-plugin-activation.php' );
// require_once 'externals/bootstrap_walker.php';
require_once 'externals/class-wp-bootstrap-navwalker.php';
require_once 'internals/comments.php';
// Admin Customisations.
require_once 'includes/admin.php';
require_once 'includes/login.php';
// Gramophone Specific Customisations.
require_once 'includes/enqueue.php';
require_once 'includes/menus.php';
require_once 'includes/comments.php';
require_once 'includes/breadcrumbs.php';
require_once 'includes/pagination.php';
require_once 'includes/styling.php';
// Theme Recommended & Required Plugins.
require_once 'includes/required_plugins.php';
function create_left_footer_widget() {
register_sidebar(
array(
'name' => __( 'Footer Left', 'gramophone' ),
'id' => __( 'footer_left', 'gramophone' ),
'description' => __( 'The left footer widget', 'gramophone' ),
'before_widget' => '<div class="widget">',
'after_widget' => '</div>',
'before_title' => '<h4 class="text-center" id="widget-title">',
'after_title' => '</h4>',
)
);
}
add_action( 'widgets_init', 'create_left_footer_widget' );
function create_center_footer_widget() {
register_sidebar(
array(
'name' => __( 'Footer Center', 'gramophone' ),
'id' => __( 'footer_center', 'gramophone' ),
'description' => __( 'The center footer widget', 'gramophone' ),
'before_widget' => '<div class="widget">',
'after_widget' => '</div>',
'before_title' => '<h4 class="text-center" id="widget-title">',
'after_title' => '</h4>',
)
);
}
add_action( 'widgets_init', 'create_center_footer_widget' );
function create_right_footer_widget() {
register_sidebar(
array(
'name' => __( 'Footer Right', 'gramophone' ),
'id' => __( 'footer_right', 'gramophone' ),
'description' => __( 'The right footer widget', 'gramophone' ),
'before_widget' => '<div class="widget">',
'after_widget' => '</div>',
'before_title' => '<h4 class="text-center" id="widget-title">',
'after_title' => '</h4>',
)
);
}
add_action( 'widgets_init', 'create_right_footer_widget' );
function create_page_widget() {
register_sidebar(
array(
'name' => __( 'Page Widget', 'gramophone' ),
'id' => __( 'page', 'gramophone' ),
'description' => __( 'The page widget container', 'gramophone' ),
'before_widget' => '<div class="widget">',
'after_widget' => '</div>',
'before_title' => '<h4 class="text-center" id="widget-title">',
'after_title' => '</h4>',
)
);
}
add_action( 'widgets_init', 'create_page_widget' );
function create_post_widget() {
register_sidebar(
array(
'name' => __( 'Post Widget', 'gramophone' ),
'id' => __( 'post', 'gramophone' ),
'description' => __( 'The post widget container', 'gramophone' ),
'before_widget' => '<div class="widget">',
'after_widget' => '</div>',
'before_title' => '<h4 class="text-center" id="widget-title">',
'after_title' => '</h4>',
)
);
}
add_action( 'widgets_init', 'create_page_widget' );
function theme_queue_js() {
if ( ! is_admin() ) {
if ( is_singular() && comments_open() && ( get_option( 'thread_comments' ) === 1 ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
}
add_action( 'get_header', 'theme_queue_js' );
function add_class_to_excerpt( $excerpt ) {
return str_replace( '<p', '<p class="card-title"', $excerpt );
}
add_filter( 'the_excerpt', 'add_class_to_excerpt' );
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(
'post_type' => 'attachment',
)
);
$post_chuncks = array_chunk( $posts, $atts['columns'] );
foreach ( $post_chuncks as $post_chunk ) {
$output .= '<div class="row">';
foreach ( $post_chunk as $post ) {
$image_metadata = wp_get_attachment_image_src( $post->ID, $atts['size'] );
$src = $image_metadata[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;
}
add_filter( 'post_gallery', 'format_gallery_bootstrap', 10, 3 );