-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
324 lines (279 loc) · 11.5 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
<?php
/*
This file is part of codium_now. Hack and customize by henri labarre and based on the marvelous sandbox theme codium_now is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.
*/
if ( ! function_exists( 'codium_now_setup' ) ) :
function codium_now_setup() {
// Make theme available for translation
// Translations can be filed in the /languages/ directory
load_theme_textdomain( 'codium-now', get_template_directory() . '/languages' );
// add_editor_style support
add_editor_style( 'editor-style.css' );
//feed
add_theme_support('automatic-feed-links');
add_theme_support( 'html5', array(
'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
) );
register_nav_menus( array(
'primary' => __( 'Top primary menu', 'codium-now' ),
) );
// Post thumbnails support for post
add_theme_support( 'post-thumbnails', array( 'post' ) ); // Add it for posts
set_post_thumbnail_size( 450, 250, true ); // Normal post thumbnails
// This theme allows users to set a custom background
add_theme_support( 'custom-background' );
// This theme allows users to set a custom header image
//custom header for 3.4 and compatability for prior version
$args = array(
'width' => 1280,
'height' => 250,
'default-image' => '',
'default-text-color' => '444',
'wp-head-callback' => 'codium_now_header_style',
'admin-head-callback' => 'codium_now_admin_header_style',
);
$args = apply_filters( 'codium_now_custom_header', $args );
add_theme_support( 'custom-header', $args );
}
endif; // codium_now_setup
add_action( 'after_setup_theme', 'codium_now_setup' );
if ( ! function_exists( 'codium_now_scripts_styles' ) ) :
function codium_now_scripts_styles() {
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
wp_enqueue_script( 'comment-reply' );
// Loads our main stylesheet.
wp_enqueue_style( 'codium_now-style', get_stylesheet_uri(), array(), '2014-11-22' );
wp_enqueue_script( 'codium_now-script', get_template_directory_uri() . '/js/menu.js', array( 'jquery' ), '20140630', true );
}
endif; // codium_now_scripts_styles
add_action( 'wp_enqueue_scripts', 'codium_now_scripts_styles' );
if ( ! function_exists( 'codium_now_header_style' ) ) :
// gets included in the site header
function codium_now_header_style() {
if (get_header_image() != ''){
?>
<style type="text/css">
div#wrapperimage {
background: url(<?php header_image(); ?>); background-size:cover; height :250px;
}
@media only screen and (min-width: 888px) and (max-width: 1220px) {
div#wrapperimage {
background: url(<?php header_image(); ?>); background-size:cover; height :150px;
}
}
@media only screen and (max-width: 600px) {
div#wrapperimage {
background: url(<?php header_image(); ?>); background-size:cover; height :100px;
}
}
@media only screen and (min-width: 600px) and (max-width: 887px) {
div#wrapperimage {
background: url(<?php header_image(); ?>); background-size:cover; height :100px;
}
}
</style>
<?php }
if ( 'blank' == get_header_textcolor() ) { ?>
<style type="text/css">
h1.blogtitle,.description,.blogtitle { display: none; }
</style>
<?php } else { ?>
<style type="text/css">
h1.blogtitle a,.blogtitle a,.description,.menu-toggle:before, .search-toggle:before,.site-navigation a { color:#<?php header_textcolor() ?>; }
.site-navigation a:hover { background:#<?php header_textcolor() ?>; }
</style>
<?php }
}
endif; // codium_now_header_style
if ( ! function_exists( 'codium_now_admin_header_style' ) ) :
// gets included in the admin header
function codium_now_admin_header_style() {
?>
<style type="text/css">
#headimg {
width: <?php echo HEADER_IMAGE_WIDTH; ?>px;
height: <?php echo HEADER_IMAGE_HEIGHT; ?>px;
}
</style>
<?php
}
endif; // codium_now_admin_header_style
// Set the content width based on the theme's design and stylesheet.
if ( ! isset( $content_width ) )
$content_width = 800;
if ( ! function_exists( 'codium_now_cats_meow' ) ) :
// For category lists on category archives: Returns other categories except the current one (redundant)
function codium_now_cats_meow($glue) {
$current_cat = single_cat_title( '', false );
$separator = "\n";
$cats = explode( $separator, get_the_category_list($separator) );
foreach ( $cats as $i => $str ) {
if ( strstr( $str, ">$current_cat<" ) ) {
unset($cats[$i]);
break;
}
}
if ( empty($cats) )
return false;
return trim(join( $glue, $cats ));
}
endif; // codium_now_cats_meow
if ( ! function_exists( 'codium_now_posted_on' ) ) :
// data before post
function codium_now_posted_on() {
printf( __( '<span class="%1$s">Posted on</span> %2$s <span class="meta-sep">by</span> %3$s.', 'codium-now' ),
'meta-prep meta-prep-author',
sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a>',
get_permalink(),
esc_attr( get_the_time() ),
get_the_date()
),
sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>',
get_author_posts_url( get_the_author_meta( 'ID' ) ),
sprintf( esc_attr__( 'View all posts by %s', 'codium-now' ), get_the_author() ),
get_the_author()
)
);
}
endif;
if ( ! function_exists( 'codium_now_posted_in' ) ) :
// data after post
function codium_now_posted_in() {
// Retrieves tag list of current post, separated by commas.
$tag_list = get_the_tag_list( '', ', ' );
if ( $tag_list ) {
$posted_in = __( 'This entry was posted in %1$s and tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'codium-now' );
} elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
$posted_in = __( 'This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'codium-now' );
} else {
$posted_in = __( 'Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'codium-now' );
}
// Prints the string, replacing the placeholders.
printf(
$posted_in,
get_the_category_list( ', ' ),
$tag_list,
get_permalink(),
the_title_attribute( 'echo=0' )
);
}
endif;
if ( ! function_exists( 'codium_now_widgets_init' ) ) :
// Widgets plugin: intializes the plugin after the widgets above have passed snuff
function codium_now_widgets_init() {
register_sidebar(array(
'name' => __( 'Left Widget for Footer', 'codium-now' ),
'description' => __( 'Left Footer widget', 'codium-now' ),
'id' => 'widgetfooterleft',
'before_widget' => "\n\t\t\t" . '',
'after_widget' => "\n\t\t\t<div class=\"clear\"></div><div class=\"center\"></div>\n",
'before_title' => "\n\t\t\t\t". '<h3 class="widgettitle">',
'after_title' => "</h3>\n" .''
));
register_sidebar(array(
'name' => __( 'Center Widget for Footer', 'codium-now' ),
'description' => __( 'Center Footer widget', 'codium-now' ),
'id' => 'widgetfootercenter',
'before_widget' => "\n\t\t\t" . '',
'after_widget' => "\n\t\t\t<div class=\"clear\"></div><div class=\"center\"></div>\n",
'before_title' => "\n\t\t\t\t". '<h3 class="widgettitle">',
'after_title' => "</h3>\n" .''
));
register_sidebar(array(
'name' => __( 'Right Widget for Footer', 'codium-now' ),
'description' => __( 'Right Footer widget', 'codium-now' ),
'id' => 'widgetfooterright',
'before_widget' => "\n\t\t\t" . '',
'after_widget' => "\n\t\t\t<div class=\"clear\"></div><div class=\"center\"></div>\n",
'before_title' => "\n\t\t\t\t". '<h3 class="widgettitle">',
'after_title' => "</h3>\n" .''
));
register_sidebar(array(
'name' => __( 'Widget for Right Sidebar', 'codium-now' ),
'description' => __( 'Widget Right Sidebar', 'codium-now' ),
'id' => 'sidebarright',
'before_widget' => "\n\t\t\t" . '',
'after_widget' => "\n\t\t\t<div class=\"clear\"></div><div class=\"center\"></div>\n",
'before_title' => "\n\t\t\t\t". '<h3 class="widgettitlesidebar">',
'after_title' => "</h3>\n" .''
));
}
endif;
add_action( 'widgets_init', 'codium_now_widgets_init' );
if ( ! function_exists( 'codium_now_excerpt_more' ) ) :
// Changes default [...] in excerpt to a real link
function codium_now_excerpt_more($more) {
global $post;
$readmore = __(' read more <span class="meta-nav"></span>', 'codium-now' );
return ' <a href="'. get_permalink($post->ID) . '">' . $readmore . '</a>';
}
endif;
add_filter('excerpt_more', 'codium_now_excerpt_more');
// Adds filters for the description/meta content in archives.php
add_filter( 'archive_meta', 'wptexturize' );
add_filter( 'archive_meta', 'convert_smilies' );
add_filter( 'archive_meta', 'convert_chars' );
add_filter( 'archive_meta', 'wpautop' );
// Remember: the codium_now is for play.
// footer link
add_action('wp_footer', 'codium_now_footer_link');
if ( ! function_exists( 'codium_now_footer_link' ) ) :
function codium_now_footer_link() {
if ( is_front_page() && !is_paged()) {
$powered = __( 'powered by', 'codium-now' );
$theme = __( 'by', 'codium-now' );
$madelove = __( 'Theme made with', 'codium-now' );
$content = '<div class="credits entry-content-footer">'.$madelove.'<span class="love"></span>'.$theme.' <a href="http://codiumnow.emploinow.fr/" title="Emploi Now">Emploi Now</a>, '.$powered.' <a href="http://wordpress.org" title="WordPress"><span class="wordpress"></span></a></div>';
echo $content;
} else {
$powered = __( 'Powered by', 'codium-now' );
$content = '<div class="credits entry-content-footer">'.$powered.' <a href="http://wordpress.org" title="WordPress"><span class="wordpress"></span></a></div>';
echo $content;
}
}
endif;
if ( ! function_exists( 'codium_now_cleanCut' ) ) :
//clean cut paragraph
function codium_now_cleanCut($string,$length,$cutString = '...')
{
if(strlen($string) <= $length)
{
return $string;
}
$str = substr($string,0,$length-strlen($cutString)+1);
return substr($str,0,strrpos($str,' ')).$cutString;
}
endif;
if ( ! function_exists( 'codium_now_wp_title' ) ) :
//wp title
function codium_now_wp_title( $title, $sep ) {
if ( is_feed() ) {
return $title;
}
global $page, $paged;
// Add the blog name
$title .= get_bloginfo( 'name', 'display' );
// Add the blog description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) ) {
$title .= " $sep $site_description";
}
// Add a page number if necessary:
if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
$title .= " $sep " . sprintf( __( 'Page %s', '_s' ), max( $paged, $page ) );
}
return $title;
}
endif;
add_filter( 'wp_title', 'codium_now_wp_title', 10, 2 );
//exclude twitter for iframe responsive code
add_filter( 'embed_oembed_html', 'codium_now_tdd_oembed_filter', 10, 4 ) ;
function codium_now_tdd_oembed_filter($html, $url, $attr, $post_ID) {
if (preg_match_all("/twitter/", $url, $matches, PREG_SET_ORDER)) {
return $html;
} else {
$return = '<div class="video-container '.$url.'">'.$html.'</div>';
return $return;
}
}
?>