%2$s', esc_url(get_permalink(get_the_ID())), sprintf($read_more_text . '%s', '' . get_the_title(get_the_ID()) . '') ); $link = apply_filters('fansub_excerpt_continue_reading_link', $link); return apply_filters('fansub_excerpt_more', '… ' . $link); } add_filter('excerpt_more', 'fansub_excerpt_more'); function fansub_post_change_content_url($old_url, $new_url) { global $wpdb; $sql = "UPDATE $wpdb->posts SET post_content = (REPLACE (post_content, '$old_url', '$new_url'))"; return $wpdb->query($sql); } function fansub_get_post_views($post_id = null) { if(!is_numeric($post_id)) { $post_id = get_the_ID(); } $result = get_post_meta($post_id, 'views', true); $result = absint($result); if(is_single() && $result < 1) { $result = 1; update_post_meta($post_id, 'views', 1); } return $result; } function fansub_get_post_likes($post_id = null) { if(!is_numeric($post_id)) { $post_id = get_the_ID(); } $result = get_post_meta($post_id, 'likes', true); $result = absint($result); return $result; } function fansub_get_post_dislikes($post_id = null) { if(!is_numeric($post_id)) { $post_id = get_the_ID(); } $result = get_post_meta($post_id, 'dislikes', true); $result = absint($result); return $result; } function fansub_get_post_thumbnail_url($post_id = '', $size = 'full') { $result = ''; if(empty($post_id)) { $post_id = get_the_ID(); } if(has_post_thumbnail($post_id)) { $thumbnail_id = get_post_thumbnail_id($post_id); if(fansub_media_file_exists($thumbnail_id)) { $image_attributes = wp_get_attachment_image_src($thumbnail_id, $size); if($image_attributes) { $result = $image_attributes[0]; } } } if(empty($result)) { $result = get_post_meta($post_id, 'thumbnail_url', true); } $result = apply_filters('fansub_post_thumbnail_pre_from_content', $result, $post_id, $size); if(empty($result)) { $post = get_post($post_id); if(fansub_object_valid($post)) { $result = fansub_get_first_image_source($post->post_content); } if(empty($result)) { $thumbnail = fansub_option_get_value('writing', 'default_post_thumbnail'); $thumbnail = fansub_sanitize_media_value($thumbnail); $result = $thumbnail['url']; } } $result = apply_filters('fansub_post_pre_post_thumbnail', $result, $post_id); if(empty($result)) { $no_thumbnail = FANSUB_URL . '/images/no-thumbnail.png'; $no_thumbnail = apply_filters('fansub_no_thumbnail_url', $no_thumbnail); $result = $no_thumbnail; } $result = apply_filters('fansub_post_thumbnail', $result, $post_id); return $result; } function fansub_post_thumbnail_large_if_not_default($result, $post_id) { if(empty($result)) { $post_id = get_post_meta($post_id, 'large_thumbnail', true); } return $result; } add_filter('fansub_post_thumbnail_pre_from_content', 'fansub_post_thumbnail_large_if_not_default', 10, 2); function fansub_post_thumbnail($args = array()) { $post_id = isset($args['post_id']) ? $args['post_id'] : ''; if(empty($post_id)) { $post_id = get_the_ID(); } if(post_password_required($post_id) || is_attachment()) { return; } $thumbnail_url = fansub_get_value_by_key($args, 'thumbnail_url'); if(empty($thumbnail_url)) { $large_size = fansub_get_value_by_key($args, 'large_size'); if($large_size) { $thumbnail_url = get_post_meta($post_id, 'large_thumbnail', true); $thumbnail_url = fansub_sanitize_media_value($thumbnail_url); $thumbnail_url = $thumbnail_url['url']; if(empty($thumbnail_url)) { $thumbnail_url = fansub_get_post_thumbnail_url($post_id); } } else { $thumbnail_url = fansub_get_post_thumbnail_url($post_id); } } if(empty($thumbnail_url)) { return; } $bfi_thumb = isset($args['bfi_thumb']) ? $args['bfi_thumb'] : true; $bfi_thumb = apply_filters('fansub_use_bfi_thumb', $bfi_thumb, $post_id); $size = fansub_sanitize_size($args); $width = $size[0]; $height = $size[1]; $enlarge = apply_filters('fansub_enlarge_post_thumbnail_on_mobile', false); if($enlarge && wp_is_mobile()) { $ratio = 600 / $width; $ratio = round($ratio); if($ratio > 1) { $width *= $ratio; $height *= $ratio; } } $original = $thumbnail_url; if($bfi_thumb) { $params = isset($args['params']) ? $args['params'] : array(); if(is_numeric($width) && $width > 0) { $params['width'] = $width; } if(is_numeric($height) && $height > 0) { $params['height'] = $height; } $bfi_url = apply_filters('fansub_pre_bfi_thumb', '', $thumbnail_url, $params); if(empty($bfi_url)) { $bfi_url = bfi_thumb($thumbnail_url, $params); } if(!empty($bfi_url)) { $thumbnail_url = $bfi_url; } } $img = new FANSUB_HTML('img'); if(is_numeric($width) && $width > 0) { $img->set_attribute('width', $size[0]); } if(is_numeric($height) && $height > 0) { $img->set_attribute('height', $size[1]); } $img->set_attribute('data-original', $original); $permalink = fansub_get_value_by_key($args, 'permalink', get_permalink($post_id)); $lazyload = fansub_get_value_by_key($args, 'lazyload', false); $before = fansub_get_value_by_key($args, 'before'); $after = fansub_get_value_by_key($args, 'after'); $img->set_attribute('alt', get_the_title($post_id)); $img->set_class('attachment-post-thumbnail wp-post-image img-responsive'); $img->set_attribute('src', $thumbnail_url); $bk_img = ''; if((bool)$lazyload) { $img->set_wrap_tag('noscript'); $bk_img = $img->build(); $img->set_wrap_tag(''); $loading_icon = fansub_get_value_by_key($args, 'loading_icon'); if(!fansub_is_image($loading_icon)) { $loading_icon = fansub_get_image_url('transparent.gif'); } $img->set_image_src($loading_icon); $img->set_attribute('data-original', $thumbnail_url); $img->add_class('lazyload'); } $loop = isset($args['loop']) ? $args['loop'] : true; $custom_html = isset($args['custom_html']) ? $args['custom_html'] : ''; $cover = fansub_get_value_by_key($args, 'cover'); $only_image = fansub_get_value_by_key($args, 'only_image'); if((bool)$only_image) { $img->output(); if((bool)$lazyload) { echo $bk_img; } return; } echo $before; if(is_singular() && !$loop) : ?>