forked from foru17/Yasuko
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
95 lines (73 loc) · 2.89 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
<?php
define('YASOKU_VERSION','1.0.3');
function angela_get_background_image($post_id){
if( has_post_thumbnail($post_id) ){
$timthumb_src = wp_get_attachment_image_src(get_post_thumbnail_id($post_id),'full');
$output = $timthumb_src[0];
} else {
$content = get_post_field('post_content', $post_id);
$defaltthubmnail = get_template_directory_uri().'/images/default.jpg';
preg_match_all('/<img.*?(?: |\\t|\\r|\\n)?src=[\'"]?(.+?)[\'"]?(?:(?: |\\t|\\r|\\n)+.*?)?>/sim', $content, $strResult, PREG_PATTERN_ORDER);
$n = count($strResult[1]);
if($n > 0){
$output = $strResult[1][0];
} else {
$output = $defaltthubmnail;
}
}
return $output;
}
function angela_is_has_image($post_id){
static $has_image;
global $post;
if( has_post_thumbnail($post_id) ){
$has_image = true;
} else {
$content = get_post_field('post_content', $post_id);
preg_match_all('/<img.*?(?: |\\t|\\r|\\n)?src=[\'"]?(.+?)[\'"]?(?:(?: |\\t|\\r|\\n)+.*?)?>/sim', $content, $strResult, PREG_PATTERN_ORDER);
$n = count($strResult[1]);
if($n > 0){
$has_image = true;
} else {
$has_image = false;
}
}
return $has_image;
}
function yasuko_setup() {
add_theme_support( 'post-thumbnails' );
}
add_action( 'after_setup_theme', 'yasuko_setup' );
function yasuko_scripts_styles() {
/*
* Adds JavaScript to pages with the comment form to support
* sites with threaded comments (when in use).
*/
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
wp_enqueue_script( 'comment-reply' );
// Loads our main stylesheet.
//wp_enqueue_style( 'yasuko-style', get_stylesheet_uri(), array(), YASOKU_VERSION );
wp_enqueue_style( 'yasuko-min', get_template_directory_uri() . '/build/css/app.css', array(), YASOKU_VERSION );
}
add_action( 'wp_enqueue_scripts', 'yasuko_scripts_styles' );
function yasuko_wp_title( $title, $sep ) {
global $paged, $page;
if ( is_feed() )
return $title;
// Add the site name.
$title .= get_bloginfo( 'name', 'display' );
// Add the site description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) )
$title = "$title $sep $site_description";
// Add a page number if necessary.
if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() )
$title = "$title $sep " . sprintf( __( 'Page %s', 'twentythirteen' ), max( $paged, $page ) );
return $title;
}
add_filter( 'wp_title', 'yasuko_wp_title', 10, 2 );
function get_ssl_avatar($avatar) {
$avatar = str_replace(array("www.gravatar.com","0.gravatar.com","1.gravatar.com","2.gravatar.com"),"secure.gravatar.com",$avatar);
return $avatar;
}
add_filter('get_avatar', 'get_ssl_avatar');