Exemple #1
0
function post_body_keywords($ID, $max = 20)
{
    global $wpdb;
    $content = strip_tags(apply_filters_if_white('the_content', $wpdb->get_var("select post_content from {$wpdb->posts} where ID = {$ID}")));
    $content = html_entity_strip($content);
    return yarpp_extract_keywords($content, $max);
}
Exemple #2
0
function post_body_keywords($ID, $max = 20)
{
    $posts = get_posts(array('p' => $ID));
    if (count($posts) != 1) {
        return '';
    }
    $content = strip_tags(apply_filters_if_white('the_content', $posts[0]->post_content));
    $content = html_entity_strip($content);
    return yarpp_extract_keywords($content, $max);
}
function post_body_keywords($ID, $max = 20)
{
    global $wpdb;
    $content = strip_tags(apply_filters_if_white('the_content', $wpdb->get_var("select post_content from {$wpdb->posts} where ID = {$ID}")));
    //echo "<!--".get_option('blog_charset')."-->";
    /*if (get_option('blog_charset') == 'UTF-8')
    		$content = html_entity_decode_utf8($content);
    	else
    		$content = html_entity_decode($content,ENT_QUOTES,get_option('blog_charset'));*/
    $content = html_entity_strip($content);
    return yarpp_extract_keywords($content, $max);
}
function yarpp_related($type, $args, $echo = true, $domain = 'website')
{
    global $wpdb, $post, $userdata;
    get_currentuserinfo();
    // set the "domain prefix", used for all the preferences.
    if ($domain == 'rss') {
        $domainprefix = 'rss_';
    } else {
        $domainprefix = '';
    }
    // get options
    // note the 2.1 change... the options array changed from what you might call a "list" to a "hash"... this changes the structure of the $args to something which is, in the long term, much more useful
    $options = array('before_related' => "{$domainprefix}before_related", 'after_related' => "{$domainprefix}after_related", 'before_title' => "{$domainprefix}before_title", 'after_title' => "{$domainprefix}after_title", 'show_excerpt' => "{$domainprefix}show_excerpt", 'excerpt_length' => "{$domainprefix}excerpt_length", 'before_post' => "{$domainprefix}before_post", 'after_post' => "{$domainprefix}after_post", 'no_results' => "{$domainprefix}no_results", 'promote_yarpp' => "{$domainprefix}promote_yarpp");
    $optvals = array();
    foreach (array_keys($options) as $option) {
        if (isset($args[$option])) {
            $optvals[$option] = stripslashes($args[$option]);
        } else {
            $optvals[$option] = stripslashes(stripslashes(yarpp_get_option($options[$option])));
        }
    }
    extract($optvals);
    $sql = yarpp_sql($type, $args, true, $domain);
    $results = $wpdb->get_results($sql);
    $output = '';
    if ($results) {
        foreach ($results as $result) {
            $title = stripslashes(apply_filters('the_title', $result->post_title));
            $permalink = get_permalink($result->ID);
            $post_content = strip_tags(apply_filters_if_white('the_content', $result->post_content));
            //$post_content = stripslashes($post_content);
            $post_excerpt = strip_tags($result->post_excerpt);
            if ($post_excerpt == '') {
                $post_excerpt = $post_content;
            }
            //this is okay because it will be clipped later anyway.
            $output .= "{$before_title}<a href='{$permalink}' rel='bookmark' title='Permanent Link: {$title}'>{$title}";
            if ($userdata->user_level >= 8 and $domain != 'rss') {
                $output .= ' <abbr title="' . sprintf(__('%f is the YARPP match score between the current entry and this related entry. You are seeing this value because you are logged in to WordPress as an administrator. It is not shown to regular visitors.', 'yarpp'), round($result->score, 3)) . '">(' . round($result->score, 3) . ')</abbr>';
            }
            $output .= '</a>';
            if ($show_excerpt) {
                $output .= $before_post . yarpp_excerpt($post_excerpt, $excerpt_length) . $after_post;
            }
            $output .= $after_title;
        }
        $output = stripslashes(stripslashes($before_related)) . $output . stripslashes(stripslashes($after_related));
        if ($promote_yarpp) {
            $output .= "\n<p>" . __("Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.", 'yarpp') . "</p>";
        }
    } else {
        $output = $no_results;
    }
    if ($echo) {
        echo $output;
    } else {
        return (!empty($output) ? "\n\n" : '') . $output;
    }
}
function post_body_keywords($max = 20)
{
    global $post;
    $content = strip_tags(apply_filters_if_white('the_content', $post->post_content));
    return yarpp_extract_keywords($content, $max);
}