-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
272 lines (184 loc) · 6.48 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
<?php
// Change-Detector-XXXX - for Espresso.app
function custom_register_styles() {
wp_enqueue_style(
'parent-style', // $handle
get_template_directory_uri() . '/style.css' // $src
);
/**
* Custom CSS
*/
$dev_mode = true;
$host = $_SERVER['HTTP_HOST'];
if ( current_user_can('edit_others_pages') ) {
$dev_mode = true;
} else if ( $host != 'greyscalepress.com' ) {
$dev_mode = true;
}
if ( $dev_mode == true ) {
// DEV: the MAIN stylesheet - uncompressed
wp_enqueue_style(
'main-style',
get_stylesheet_directory_uri() . '/css/dev/00-main.css', // main.css
false, // dependencies
time() // version
);
} else {
// PROD: the MAIN stylesheet - combined and minified
wp_enqueue_style(
'main-style',
get_stylesheet_directory_uri() . '/css/prod/styles.20170127233400.css', // main.css
false, // dependencies
null // version
);
}
// wp_dequeue_style( 'ippo-style' );
// wp_deregister_style( 'ippo-style' );
//
wp_dequeue_style( 'coup-font-enqueue' );
wp_deregister_style( 'coup-font-enqueue' );
$hkgrotesk = get_template_directory_uri() . '/assets/fonts/hk-grotesk/stylesheet.css';
wp_enqueue_style(
'hkgrotesk',
$hkgrotesk, // main.css
false, // dependencies
null // version
);
wp_enqueue_script(
// the MAIN JavaScript file -- development version
'main-script',
get_stylesheet_directory_uri() . '/js/scripts.js', // scripts.js
array('jquery'), // dependencies
null, // version
true // in footer
);
}
add_action( 'wp_enqueue_scripts', 'custom_register_styles', 25 );
// Header Cleanup
remove_action('wp_head', 'wp_generator');
/**
* Prints HTML with meta information for the current post-date/time and author.
*/
function coup_posted_on() {
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
}
$time_string = sprintf( $time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() ),
esc_attr( get_the_modified_date( 'c' ) ),
esc_html( get_the_modified_date() )
);
$posted_on = '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>';
// $byline = sprintf(
// esc_html_x( 'By : %s', 'post author', 'coup-shop' ),
// '<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>'
// );
echo '<span class="posted-on"> ' . $posted_on . '</span>'; // WPCS: XSS OK.
}
// Admin Styles
//
/*
* Admin CSS
*
* For all users accessing the admin interface
*/
function greyscale_admin_css() {
echo '<style>
#setting-error-ippo {
/* display: none; */
}
</style>';
}
add_action('admin_head', 'greyscale_admin_css');
//require_once('functions/galleries.php');
//
//require_once('functions/agenda.php');
//
//require_once('functions/content.php');
//
//require_once('functions/members.php');
//
//require_once('functions/prev-next.php');
// WooCommerce Modification
add_action( 'woocommerce_archive_description', 'greyscale_author_metadata', 10 );
function greyscale_author_metadata() {
if ( is_product_taxonomy() && 0 === absint( get_query_var( 'paged' ) ) ) {
// check for image:
$queried_object = get_queried_object();
$taxonomy = $queried_object->taxonomy;
$term_id = $queried_object->term_id;
$image = get_field( 'author_picture', $taxonomy.'_'.$term_id);
// echo '<pre>';
// var_dump($image);
// echo '</pre>';
if( !empty($image) ): ?>
<img src="<?php echo $image['sizes']['medium']; ?>" alt="<?php echo $image['alt']; ?>" class="author-img" />
<?php endif;
$biography = get_field( 'biography', $taxonomy.'_'.$term_id);
if( !empty($biography) ): ?>
<div class="author-biography">
<?php echo $biography; ?>
</div>
<?php endif;
}
}
function gs_author_content( $term ) {
$term_id = $term->term_id;
$taxonomy = $term->taxonomy;
$description = $term->description;
$term_link = esc_url( get_term_link($term) );
$image = get_field( 'author_picture', $taxonomy.'_'.$term_id);
$content = '<article id="term-'.$term_id.'" class="post type-post status-publish format-standard has-post-thumbnail hentry">';
if( !empty($image) ) {
$content .= '<div class="featured-content featured-image vertical-img">
<a href="'. $term_link .'"><img width="140" height="199" src="'.$image['sizes']['medium'].'" class="wp-post-image" alt="'.$image['alt'].'" /></a>
<a class="more-link" href="'. $term_link .'">Read More</a>
</div>';
}
$content .= '<header class="entry-header">
<h2 class="entry-title"><a href="'. $term_link .'" rel="bookmark">' . $term->name . '</a></h2> </header><!-- .entry-header -->';
if( !empty($description) ) {
$content .= '<div class="entry-content">'.$description.'</div><!-- .entry-content -->';
}
$content .= '<a class="more-link" href="'. $term_link .'">Read More</a>';
$content .= '</article><!-- #post-## -->';
return $content;
}
// WooCommerce Add MetaBox (Discussion settings for Products)
add_action( 'add_meta_boxes' , 'greyscale_meta_boxes', 40 );
function greyscale_meta_boxes() {
// add_meta_box( 'commentstatusdiv', 'product', 'normal');
add_meta_box(
'commentstatusdiv', // Meta box ID
__( 'Discussion' ), // Title
'post_comment_status_meta_box' // callback Function
// null, // screen
// 'normal', // context within the screen
// 'core' // priority
);
}
// Problem : add Products to archive pages
// use is_year()
/**
* add Products to archive pages
*
* @param object $query
* @return object
*/
function greyscale_yearly_archives( $query ) {
if ( $query->is_year() ) {
/*$query->set( 'post_type', array('post', 'portfolio', 'product'));*/
// $query->set('post_type', 'post');
$query->set( 'post_type', array('post', 'portfolio', 'product'));
return $query;
} else if ( $query->is_home() && $query->is_main_query() ) {
// echo '<pre>';
// var_dump($query);
// echo '</pre>';
$query->set( 'post_type', array('post', 'portfolio', 'product'));
return $query;
}
}
add_filter( 'pre_get_posts', 'greyscale_yearly_archives' );