mirror of
https://github.com/mashirozx/sakura.git
synced 2025-05-29 01:49:21 +08:00
commit
a81dc6891f
@ -466,17 +466,18 @@ function restyle_text($number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function set_post_views() {
|
function set_post_views() {
|
||||||
global $post;
|
if (is_singular()) {
|
||||||
$post_id = intval($post->ID);
|
global $post;
|
||||||
$count_key = 'views';
|
$post_id = intval($post->ID);
|
||||||
$views = get_post_custom($post_id);
|
if($post_id) {
|
||||||
$views = array_key_exists("views",$views) ? intval($views['views'][0]) : 0;
|
$views = get_post_meta($post_id, 'views', true);
|
||||||
if(is_single() || is_page()) {
|
if(!update_post_meta($post_id, 'views', ($views + 1))) {
|
||||||
if(!update_post_meta($post_id, 'views', ($views + 1))) {
|
add_post_meta($post_id, 'views', 1, true);
|
||||||
add_post_meta($post_id, 'views', 1, true);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
add_action('get_header', 'set_post_views');
|
add_action('get_header', 'set_post_views');
|
||||||
|
|
||||||
function get_post_views($post_id) {
|
function get_post_views($post_id) {
|
||||||
@ -487,10 +488,7 @@ function get_post_views($post_id) {
|
|||||||
return restyle_text(wp_statistics_pages('total','uri',$post_id));
|
return restyle_text(wp_statistics_pages('total','uri',$post_id));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$count_key = 'views';
|
$views = get_post_meta($post_id, 'views', true);
|
||||||
$views = get_post_custom($post_id);
|
|
||||||
$views = array_key_exists("views",$views) ? intval($views['views'][0]) : 0;
|
|
||||||
$post_views = intval(post_custom('views'));
|
|
||||||
if($views == '') {
|
if($views == '') {
|
||||||
return 0;
|
return 0;
|
||||||
}else{
|
}else{
|
||||||
@ -1521,8 +1519,8 @@ function html_tag_parser($content) {
|
|||||||
//With Thumbnail: !{alt}(url)[th_url]
|
//With Thumbnail: !{alt}(url)[th_url]
|
||||||
if (preg_match_all('/\!\{.*?\)\[.*?\]/i', $content,$matches)){
|
if (preg_match_all('/\!\{.*?\)\[.*?\]/i', $content,$matches)){
|
||||||
$i=0;
|
$i=0;
|
||||||
foreach ($matches as $val) {
|
if ($i<sizeof($matches)) {
|
||||||
$content=str_replace($val[$i],preg_replace(
|
$content=str_replace($matches[$i],preg_replace(
|
||||||
'/!\{([^\{\}]+)*\}\('.$url_regex.'\)\['.$url_regex.'\]/i',
|
'/!\{([^\{\}]+)*\}\('.$url_regex.'\)\['.$url_regex.'\]/i',
|
||||||
'<a data-fancybox="gallery"
|
'<a data-fancybox="gallery"
|
||||||
data-caption="$1"
|
data-caption="$1"
|
||||||
@ -1530,7 +1528,7 @@ function html_tag_parser($content) {
|
|||||||
href="$2"
|
href="$2"
|
||||||
alt="$1"
|
alt="$1"
|
||||||
title="$1"><img src="$7" target="_blank" rel="nofollow" class="fancybox"></a>',
|
title="$1"><img src="$7" target="_blank" rel="nofollow" class="fancybox"></a>',
|
||||||
$val[$i]),
|
$matches[$i]),
|
||||||
$content);
|
$content);
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user