Esempio n. 1
0
/**
 * 作用: comment有reply时,通过邮件通知留言发布者.
 * 来源: Comment Email Reply
 * URL:  http://kilozwo.de/wordpress-comment-email-reply-plugin
 */
function apip_comment_inserted($comment_id, $comment_object)
{
    if ($comment_object->comment_parent > 0) {
        $comment_parent = get_comment($comment_object->comment_parent);
        $bg_head = '<div style="background:transparent; color: inherit; font-size:12px;"><div style="max-width: 520px; margin:0 auto;background:rgba(220,220,220,0.6); padding:25px 70px;margin: 15px;color: #333; border-top: 3px solid #85FF3F; border-bottom: 3px solid #85FF3F; box-shadow: 0px 15px 25px -17px #E7797A;">';
        $content_border_head = '<p style="border: 3px double #E7797A;padding: 20px; margin: 15px 0; width: 60% ; background:rgba(220,220,220,0.6); ">';
        $random_posts = apip_random_post(get_the_ID(), 1);
        foreach ($random_posts as $random_post) {
            $random_link = get_permalink($random_post->ID);
        }
        $mailcontent = '<p>亲爱的 <b style="color:#222; font-weight:800; padding:0 5px ;">' . $comment_parent->comment_author . '</b>, 您的留言:</p>';
        $mailcontent = $mailcontent . $content_border_head . $comment_parent->comment_content . '</p><p>有了新回复:</p>';
        $mailcontent = $mailcontent . $content_border_head . $comment_object->comment_content . '</p>';
        $mailcontent = $mailcontent . sprintf('<p>欢迎<a href="%1$s">继续参与讨论</a>或者<a href="%2$s">随便逛逛</a>。<a href="%3$s">「破襪子」</a>期待您再次赏光。</p>', get_comment_link($comment_object->comment_ID), $random_link, get_bloginfo('url'));
        $mailcontent = $bg_head . $mailcontent . '</div></div>';
        $headers = 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
        $headers .= 'From: 破襪子站长 <*****@*****.**>' . "\r\n";
        //$headers .= 'Bcc: lifishake@gmail.com'. "\r\n";
        wp_mail($comment_parent->comment_author_email, '您在『' . get_option('blogname') . '』 的留言有了新回复。', $mailcontent, $headers);
    }
}
Esempio n. 2
0
/**
 * 作用: 显示相关
 * 来源: 自产
 * URL:  
 */
function apip_related_post()
{
    global $apip_options;
    $limit = $apip_options['local_definition_count'] ? $apip_options['local_definition_count'] : 5;
    global $wpdb;
    $object_ids = array();
    $post_id = get_the_ID();
    $tags = array();
    $tags = get_the_terms($post_id, 'post_tag');
    if ($tags != 0) {
        $term_taxonomy_ids = wp_list_pluck($tags, 'term_taxonomy_id');
        $term_taxonomy_ids_str = implode(",", $term_taxonomy_ids);
        $object_ids = $wpdb->get_col("SELECT object_id FROM {$wpdb->term_relationships} WHERE term_taxonomy_id IN ( {$term_taxonomy_ids_str} ) AND object_id != '{$post_id}' ");
        $object_ids = array_count_values($object_ids);
        arsort($object_ids);
        $object_ids = array_keys($object_ids);
    }
    if (count($object_ids) < $limit) {
        $random_posts = apip_random_post(get_the_ID(), $limit - count($object_ids) + 1);
        if (count($random_posts) > 0) {
            $random_ids = wp_list_pluck($random_posts, 'ID');
            $object_ids = array_merge($object_ids, $random_ids);
        }
    }
    while (count($object_ids) > $limit) {
        array_pop($object_ids);
    }
    $ret = '<ul class = "apip-ralated-content">';
    $terms = wp_get_post_terms(get_the_ID(), 'post_tag', array('fields' => 'ids'));
    $inc_str = implode(",", $object_ids);
    $related_posts = get_posts(array('include' => $inc_str, 'posts_per_page' => $limit));
    foreach ($related_posts as $related_post) {
        $ret = $ret . '<li> <a class="related-post" href="' . get_permalink($related_post->ID) . '">';
        $ret = $ret . $related_post->post_title . '</a></li>';
    }
    $ret = $ret . '</ul>';
    return $ret;
}