__('Tag it', 'p2'),
'goto_homepage' => __('Go to homepage', 'p2'),
// the number is calculated in the javascript in a complex way, so we can't use ngettext
'n_new_updates' => __('%d new update(s)', 'p2'),
'n_new_comments' => __('%d new comment(s)', 'p2'),
'jump_to_top' => __('Jump to top', 'p2'),
'not_posted_error' => __('An error has occured, your post was not posted', 'p2'),
'update_posted' => __('You update has been posted', 'p2'),
'loading' => __('Loading...', 'p2'),
'cancel' => __('Cancel', 'p2'),
'save' => __('Save', 'p2'),
'hide_threads' => __('Hide threads', 'p2'),
'show_threads' => __('Show threads', 'p2'),
'unsaved_changes' => __('Your comments or posts will be lost if you continue.', 'p2'),
));
if ( ( $prologue_inlineedit ) && is_user_logged_in() )
wp_enqueue_script( 'jeditable', get_bloginfo('template_directory').'/inc/jquery.jeditable.js', array( 'jquery' ) );
wp_enqueue_script( 'scrollit', get_bloginfo('template_directory').'/inc/jquery.scrollTo-min.js', array( 'jquery' ) );
}
function prologue_pageoptions_init() {
global $page_options;
get_currentuserinfo();
$page_options['nonce']= wp_create_nonce( 'ajaxnonce' );
$page_options['prologue_updates'] = 1;
$page_options['prologue_comments_updates'] = 1;
$page_options['prologue_tagsuggest'] = 1;
$page_options['prologue_inlineedit'] = 1;
$page_options['prologue_comments_inlineedit'] = 1;
$page_options['is_single'] = (int)is_single();
$page_options['is_page'] = (int)is_page();
$page_options['is_front_page'] = (int)is_front_page();
$page_options['is_first_front_page'] = (int)(is_front_page() && !is_paged() );
$page_options['is_user_logged_in'] = (int)is_user_logged_in();
}
add_action('wp_head', 'prologue_pageoptions_init');
function prologue_pageoptions_js() {
global $page_options;
?>
';
// header
echo "" . __( 'Prologue Options', 'p2' ) . "
";
// options form
?>
'all' ) );
$recent_tags = array();
foreach( $all_tags as $tag ) {
if( $tag->count < 1 )
continue;
$tag_posts = get_objects_in_term( $tag->term_id, 'post_tag' );
$recent_post_id = max( $tag_posts );
$recent_tags[$tag->term_id] = $recent_post_id;
}
arsort( $recent_tags );
$num_tags = count( $recent_tags );
if( $num_tags > $num_to_show ) {
$reduce_by = (int) $num_tags - $num_to_show;
for( $i = 0; $i < $reduce_by; $i++ ) {
array_pop( $recent_tags );
}
}
wp_cache_set( 'prologue_theme_tag_list', array( $num_to_show => $recent_tags ) );
}
echo $before;
echo "\n";
foreach( $recent_tags as $term_id => $post_id ) {
$tag = get_term( $term_id, 'post_tag' );
$tag_link = get_tag_link( $tag->term_id );
?>
-
name ); ?> ( count ); ?> )
id="comment-">
user_id, $comment->comment_author_email, 32 ); ?>
$depth, 'max_depth' => $args['max_depth'], 'before' => ' | ')) ?>
', $after = '') {
global $post, $looping;
$t = $post->post_title;
if($looping == 0)
return $t;
$pos = 0;
if(get_option('prologue_show_titles') != 1)
return false;
$post->post_content = trim($post->post_content);
$post->post_title = trim($post->post_title);
$post->post_title = preg_replace('/\.\.\.$/','',$post->post_title);
$post->post_title = str_replace("\n", ' ', $post->post_title );
$post->post_title = str_replace(' ',' ', $post->post_title);
$post->post_content = str_replace("\n", ' ', strip_tags($post->post_content) );
$post->post_content = str_replace(' ',' ', $post->post_content);
$post->post_content = trim($post->post_content);
$post->post_title = trim($post->post_title);
if( is_int( strpos($post->post_title, 'http') ) ) {
$split = str_split( $post->post_content, strpos($post->post_content, 'http'));
$post->post_content = $split[0];
$split2 = str_split( $post->post_title, strpos($post->post_title, 'http'));
$post->post_title = $split2[0];
}
$pos = @strpos( $post->post_content, $post->post_title );
// these are for debugging
/*
error_log('content '.$post->post_content);
error_log('title '.$post->post_title);
error_log($pos);*/
if( (false === $pos or $pos > 0) && $post->post_title != '')
echo (is_single()) ? $before.$t.$after : $before.''.$t.''.$after;
}
function prologue_loop() {
global $looping;
$looping = ($looping === 1 ) ? 0 : 1;
}
add_action('loop_start', 'prologue_loop');
add_action('loop_end', 'prologue_loop');
function prologue_comment_widget_html( $comment, $size, $tdclass, $echocomment = true ) {
if ( !$size = (int) $size )
$size = 32;
if ( $comment->comment_author == '' )
$comment->comment_author = __('Anonymous', 'p2');
$author = $comment->comment_author;
$excerpt = wp_html_excerpt( $author, 20 );
if ( $author != $excerpt )
$author = $excerpt.'…';
$avatar = get_avatar( $comment, $size );
if ( $comment_author_url = $comment->comment_author_url ? clean_url( $comment->comment_author_url ) : '' ) {
$avatar = "$avatar";
// entitities in comment author are kept escaped in the db and tags are not allowed, so
// no need of HTML escaping here
$author = "$author";
}
$thiscomment = '';
$thiscomment .= '
', $author, $comment_url, attribute_escape($comment_content), $post_title );
if ($echocomment)
echo $thiscomment;
else
return $thiscomment;
}
function prologue_comment_frontpage( $comment, $args, $echocomment = true ) {
$GLOBALS['comment'] = $comment;
$depth = prologue_get_comment_depth( get_comment_ID() );
$comment_text = apply_filters( 'comment_text', $comment->comment_content );
$comment_class = comment_class( $class = '', $comment_id = null, $post_id = null, $echo = false );
$comment_time = get_comment_time();
$comment_date = get_comment_date();
$id = get_comment_ID();
$avatar = prologue_get_avatar( $comment->user_id, $comment->comment_author_email, 32 );
$author_link = get_comment_author_link();
$reply_link = prologue_get_comment_reply_link(
array('depth' => $depth, 'max_depth' => $args['max_depth'], 'before' => ' | ', 'reply_text' => __('Reply', 'p2') ),
$comment->comment_ID, $comment->comment_post_ID );
$can_edit = current_user_can( 'edit_post', $comment->comment_post_ID );
$edit_comment_url = get_edit_comment_link( $comment->comment_ID );
$edit_link = $can_edit? " | " : '';
$content_class = $can_edit? 'commentcontent comment-edit' : 'commentcontent';
$awaiting_message = $comment->comment_approved == '0'? ''.__('Your comment is awaiting moderation.', 'p2').'
' : '';
$permalink = clean_url( get_comment_link() );
$permalink_text = __('Permalink', 'p2');
$date_time = sprintf( __('%s on %s', 'p2'), get_comment_time(), get_comment_date() );
$html = <<
$avatar
$author_link
$date_time
$permalink_text $reply_link $edit_link
HTML;
if(get_comment_type() != 'comment')
return false;
if ($echocomment)
echo $html;
else
return $html;
}
function tags_with_count( $format = 'list', $before = '', $sep = '', $after = '' ) {
global $post;
$posttags = get_the_tags($post->ID, 'post_tag');
if ( !$posttags )
return;
foreach ( $posttags as $tag ) {
if ( $tag->count > 1 && !is_tag($tag->slug) ) {
$tag_link = '' . $tag->name . ' (' . number_format_i18n( $tag->count ) . ')';
} else {
$tag_link = $tag->name;
}
if ( $format == 'list' )
$tag_link = '' . $tag_link . '';
$tag_links[] = $tag_link;
}
echo $before . join( $sep, $tag_links ) . $after;
}
function latest_post_permalink() {
global $wpdb;
$sql = "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1";
$last_post_id = $wpdb->get_var($sql);
$permalink = get_permalink($last_post_id);
return $permalink;
}
function prologue_ajax_tag_search() {
global $wpdb;
$s = $_GET['q'];
if ( false !== strpos( $s, ',' ) ) {
$s = explode( ',', $s );
$s = $s[count( $s ) - 1];
}
$s = trim( $s );
if ( strlen( $s ) < 2 )
die; // require 2 chars for matching
$results = $wpdb->get_col( "SELECT t.name FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = 'post_tag' AND t.name LIKE ('%". like_escape( $wpdb->escape( $s ) ) . "%')" );
echo join( $results, "\n" );
exit;
}
function prologue_title_from_content( $content ) {
static $strlen = null;
if ( !$strlen ) {
$strlen = function_exists('mb_strlen')? 'mb_strlen' : 'strlen';
}
$max_len = 40;
$title = $strlen( $content ) > $max_len? wp_html_excerpt( $content, $max_len ) . '...' : $content;
$title = trim( strip_tags( $title ) );
$title = str_replace("\n", " ", $title);
//Try to detect image or video only posts, and set post title accordingly
if ( !$title ) {
if ( preg_match("/