__('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 ?>

value="1" />

'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 "

  • id="comment-"> user_id, $comment->comment_author_email, 32 ); ?>

    $depth, 'max_depth' => $args['max_depth'], 'before' => ' | ')) ?>

    comment_approved == '0' ) : ?>

    ', $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 = '' . $avatar . ''; $thiscomment .= ''; $post_title = wp_specialchars( strip_tags( get_the_title( $comment->comment_post_ID ) ) ); $excerpt = wp_html_excerpt( $post_title, 30 ); if ( $post_title != $excerpt ) $post_title = $excerpt.'…'; $comment_content = strip_tags( $comment->comment_content ); $excerpt = wp_html_excerpt( $comment_content, 50 ); if ( $comment_content != $excerpt ) $comment_content = $excerpt.'…'; $comment_url = get_comment_link( $comment ); // Only use the URL's #fragment if the comment is visible on the pgae. // Works by detecting if the comment's post is visible on the page... may break if P2 decides to do clever stuff with comments when paginated if ( @constant( 'DOING_AJAX' ) && isset( $_GET['vp'] ) && is_array( $_GET['vp'] ) && in_array( $comment->comment_post_ID, $_GET['vp'] ) ) { $comment_url = "#comment-{$comment->comment_ID}"; } else { static $posts_on_page = false; if ( false === $posts_on_page ) { global $wp_query; $posts_on_page = array(); foreach ( array_keys( $wp_query->posts ) as $k ) $posts_on_page[$wp_query->posts[$k]->ID] = true; } if ( isset( $posts_on_page[$comment->comment_post_ID] ) ) $comment_url = "#comment-{$comment->comment_ID}"; } $thiscomment .= sprintf( __( "%s on %s" , 'p2') . '', $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? " | ".__('Edit', 'p2')."" : ''; $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

    $comment_text
    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 = ''; } 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("/'.__('Error: not logged in.', 'p2').'

    '); } $post_id = $_POST['post_ID']; $post_id = substr( $post_id, strpos( $post_id, '-' ) + 1 ); if ( !current_user_can( 'edit_post', $post_id )) { die('

    '.__('Error: not allowed to edit post.', 'p2').'

    '); } $user_id = $current_user->ID; $post_content = $_POST['content']; // preserve custom "big" titles $thepost = get_post($post_id); $clean_title = str_replace('…', '', $thepost->post_title); if( strpos($thepost->post_content, $clean_title ) !== 0 ) { $post_title = $thepost->post_title; } else { $post_title = prologue_title_from_content( $post_content ); } $post = wp_update_post( array( 'post_title' => $post_title, 'post_content' => $post_content, 'post_modified' => current_time('mysql'), 'post_modified_gmt' => current_time('mysql', 1), 'ID' => $post_id )); $thepost = get_post( $post ); echo apply_filters( 'the_content', $thepost->post_content ); exit; } function prologue_inline_comment_save() { check_ajax_referer( 'ajaxnonce', '_inline_edit' ); if ( !is_user_logged_in() ) { die('

    '.__('Error: not logged in.', 'p2').'

    '); } $comment_id = $_POST['comment_ID']; $comment_id = substr( $comment_id, strpos( $comment_id, '-' ) + 1); $this_comment = get_comment( $comment_id ); if ( !current_user_can( 'edit_post', $this_comment->comment_post_ID ) ) { die('

    '.__('Error: not allowed to edit this comment.', 'p2').'

    '); } $user_id = $current_user->ID; $comment_content = $_POST['comment_content']; $comment = wp_update_comment( array( 'comment_content' => $comment_content, 'comment_ID' => $comment_id )); $thecomment = get_comment( $comment_id ); echo apply_filters( 'comment_text', $thecomment->comment_content ); exit; } function prologue_load_post() { check_ajax_referer( 'ajaxnonce', '_inline_edit' ); if ( !is_user_logged_in() ) { die('

    '.__('Error: not logged in.', 'p2').'

    '); } $post_id = $_GET['post_ID']; $post_id = substr( $post_id, strpos( $post_id, '-' ) + 1 ); if ( !current_user_can( 'edit_post', $post_id ) ) { die('

    '.__('Error: not allowed to edit post.', 'p2').'

    '); } $this_post = get_post( $post_id ); echo $this_post->post_content ; exit; } function prologue_load_comment() { check_ajax_referer( 'ajaxnonce', '_inline_edit' ); if ( !is_user_logged_in() ) { die('

    '.__('Error: not logged in.', 'p2').'

    '); } $comment_id = attribute_escape($_GET['comment_ID']); $comment_id = substr( $comment_id, strpos( $comment_id, '-' ) + 1); $this_comment = get_comment($comment_id); $comment_content = $this_comment->comment_content; echo $comment_content; exit; } function prologue_new_post() { if( 'POST' != $_SERVER['REQUEST_METHOD'] || empty( $_POST['action'] ) || $_POST['action'] != 'prologue_new_post' ) { die(); } if ( !is_user_logged_in() ) { die('

    '.__('Error: not logged in.', 'p2').'

    '); } if( !current_user_can( 'publish_posts' ) ) { die('

    '.__('Error: not allowed to post.', 'p2').'

    '); } check_ajax_referer( 'ajaxnonce', '_ajax_post' ); $user_id = $current_user->user_id; $post_content = $_POST['posttext']; $tags = trim( $_POST['tags'] ); if ( $tags == __('Tag it', 'p2') || $tags == 'Tag it' ) $tags = ''; $post_title = prologue_title_from_content( $post_content ); $post_id = wp_insert_post( array( 'post_author' => $user_id, 'post_title' => $post_title, 'post_content' => $post_content, 'tags_input' => $tags, 'post_status' => 'publish' ) ); echo $post_id? $post_id : '0'; exit; } function prologue_new_post_noajax() { if( 'POST' != $_SERVER['REQUEST_METHOD'] || empty( $_POST['action'] ) || $_POST['action'] != 'post' ) { return; } if ( ! is_user_logged_in() ) auth_redirect(); if( !current_user_can( 'publish_posts' ) ) { wp_redirect( get_bloginfo( 'url' ) . '/' ); exit; } check_admin_referer( 'new-post' ); $user_id = $current_user->user_id; $post_content = $_POST['posttext']; $tags = $_POST['tags']; $title = prologue_title_from_content( $post_content ); $post_id = wp_insert_post( array( 'post_author' => $user_id, 'post_title' => $post_title, 'post_content' => $post_content, 'tags_input' => $tags, 'post_status' => 'publish' ) ); wp_redirect( get_bloginfo( 'url' ) . '/' ); exit; } function prologue_new_comment() { if( 'POST' != $_SERVER['REQUEST_METHOD'] || empty( $_POST['action'] ) || $_POST['action'] != 'prologue_new_comment' ) { die(); } check_ajax_referer( 'ajaxnonce', '_ajax_post' ); $comment_content = isset( $_POST['comment'] )? trim( $_POST['comment'] ) : null; $comment_post_ID = isset( $_POST['comment_post_ID'] )? trim( $_POST['comment_post_ID'] ) : null; $user = wp_get_current_user(); if ( $user->ID ) { if ( empty( $user->display_name ) ) $user->display_name = $user->user_login; $comment_author = $user->display_name; $comment_author_email = $user->user_email; $comment_author_url = $user->user_url; $comment_author_url = $user->user_url; $user_ID = $user->ID; if ( current_user_can( 'unfiltered_html' ) ) { $unfiltered_html = isset($_POST['_wp_unfiltered_html_comment'])? $_POST['_wp_unfiltered_html_comment'] : ''; if ( wp_create_nonce( 'unfiltered-html-comment_' . $comment_post_ID) != $unfiltered_html ) { kses_remove_filters(); // start with a clean slate kses_init_filters(); // set up the filters } } } else { if ( get_option('comment_registration') ) { die('

    '.__('Error: you must be logged in to post a comment.', 'p2').'

    '); } } $comment_type = ''; if ( get_option( 'require_name_email' ) && !$user->ID ) { if ( strlen($comment_author_email) < 6 || '' == $comment_author ) { die('

    '.__('Error: please fill the required fields (name, email).', 'p2').'

    '); } elseif ( !is_email( $comment_author_email ) ) { die('

    '.__('Error: please enter a valid email address.', 'p2').'

    '); } } if ( '' == $comment_content ) { die('

    '.__('Error: Please type a comment.', 'p2').'

    '); } $comment_parent = isset( $_POST['comment_parent'] ) ? absint( $_POST['comment_parent'] ) : 0; $commentdata = compact( 'comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID' ); $comment_id = wp_new_comment( $commentdata ); $comment = get_comment( $comment_id ); if ( !$user->ID ) { setcookie('comment_author_' . COOKIEHASH, $comment->comment_author, time() + 30000000, COOKIEPATH, COOKIE_DOMAIN); setcookie('comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() + 30000000, COOKIEPATH, COOKIE_DOMAIN); setcookie('comment_author_url_' . COOKIEHASH, clean_url($comment->comment_author_url), time() + 30000000, COOKIEPATH, COOKIE_DOMAIN); } if ($comment) echo $comment_id; else echo __("Error: Unknown error occured. Comment not posted.", 'p2'); exit; } function prologue_latest_comments() { global $wpdb, $comments, $comment, $max_depth, $depth, $user_login, $user_ID, $user_identity; $number = 10; //max amount of comments to load $load_time = $_GET['load_time']; $lc_widget = $_GET['lcwidget']; $visible_posts = (array)$_GET['vp']; if ( get_option('thread_comments') ) $max_depth = get_option('thread_comments_depth'); else $max_depth = -1; //Widget info if ( !isset($options) ) $options = get_option('widget_recent_comments'); $size = $options[ 'avatar_size' ] ? $options[ 'avatar_size' ] : 32; //get new comments if ($user_ID) { $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE (comment_approved = '1' OR ( user_id = %d AND comment_approved = '0' )) AND comment_date_gmt > %s ORDER BY comment_date_gmt DESC LIMIT $number", $user_ID, $load_time)); } else if ( empty($comment_author) ) { $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_approved = '1' AND comment_date_gmt > %s ORDER BY comment_date_gmt DESC LIMIT $number", $load_time)); } else { $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE (comment_approved = '1' OR ( comment_author = %s AND comment_author_email = %s AND comment_approved = '0' ) ) AND comment_date_gmt > %s ORDER BY comment_date_gmt DESC LIMIT $number", $comment_author, $comment_author_email, $load_time)); } $number_of_new_comments = count($comments); $prepare_comments = array(); if ($number_of_new_comments > 0) { foreach ($comments as $comment) { // Setup comment html if post is visible $comment_html = ''; if ( in_array( $comment->comment_post_ID, $visible_posts ) ) { $comment_html = prologue_comment_frontpage($comment, array('max_depth' => $max_depth, 'before' => ' | '), $depth, false); } // Setup widget html if widget is visible $comment_widget_html = ''; if ( $lc_widget ) { $comment_widget_html = prologue_comment_widget_html( $comment, $size, 'top', false ); } $prepare_comments[] = array( "id" => $comment->comment_ID, "postID" => $comment->comment_post_ID, "commentParent" => $comment->comment_parent, "html" => $comment_html, "widgetHtml" => $comment_widget_html ); } $json_data = array("numberofnewcomments" => $number_of_new_comments, "comments" => $prepare_comments, "lastcommenttime" => gmdate( 'Y-m-d H:i:s' )); echo json_encode( $json_data ); } else { // No new comments echo('0'); } exit; } function prologue_latest_posts() { $load_time = $_GET['load_time']; $frontpage = $_GET['frontpage']; $num_posts = 10; //max amount of posts to load $number_of_new_posts = 0; $prologue_query = new WP_Query('showposts=' . $num_posts . '&post_status=publish'); ob_start(); while ($prologue_query->have_posts()) : $prologue_query->the_post(); $current_user_id = get_the_author_ID( ); if ( get_gmt_from_date( get_the_time( 'Y-m-d H:i:s' ) ) <= $load_time ) continue; $number_of_new_posts++; if ( $frontpage ) { ?>
  • on %s', 'p2'), get_the_time(), get_the_time( get_option('date_format') ) ); ?> | ' | ', 'reply_text' => __('Reply', 'p2'), 'add_below' => 'prologue'), get_the_id()); ?> |

     
  • $number_of_new_posts, "html" => $posts_html, "lastposttime" => gmdate( 'Y-m-d H:i:s' )); echo json_encode( $json_data ); } exit; } /* Recent comments with avatars */ function prologue_widget_recent_comments_avatar( $args ) { global $wpdb, $comments, $comment; extract($args, EXTR_SKIP); if ( !isset($options) ) $options = get_option('widget_recent_comments'); $title = empty($options['title']) ? __('Recent Comments', 'p2') : $options['title']; if ( !$number = (int) $options['number'] ) $number = 5; else if ( $number < 1 ) $number = 1; else if ( $number > 15 ) $number = 15; if ( !$comments = wp_cache_get( 'recent_avatar_comments', 'widget' ) ) { $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT $number"); wp_cache_add( 'recent_avatar_comments', $comments, 'widget' ); } $size = $options[ 'avatar_size' ] ? $options[ 'avatar_size' ] : 24; ?>
    15 ) $number = 15; ?>

    table.recentcommentsavatar img.avatar { border: 0px; margin:0; } table.recentcommentsavatar a {border: 0px !important; background-color: transparent !important} td.recentcommentsavatartop {padding:0px 0px 1px 0px; margin: 0px; {$avatar_bg} } td.recentcommentsavatarend {padding:0px 0px 1px 0px; margin:0px; {$avatar_bg} } td.recentcommentstexttop { {$text_bg} border: none !important; padding:0px 0px 0px 10px;} td.recentcommentstextend { {$text_bg} border: none !important; padding:0px 0px 2px 10px;} "; echo $style; } function prologue_widget_recent_comments_avatar_register() { $options = get_option('widget_recent_comments'); if( isset( $options[ 'avatar_size' ] ) && $options[ 'avatar_size' ] == 1 && is_admin() == false ) return; $class = array('classname' => 'widget_recent_comments'); wp_register_sidebar_widget('recent-comments', __('Recent Comments', 'p2'), 'prologue_widget_recent_comments_avatar', $class); wp_register_widget_control('recent-comments', __('Recent Comments', 'p2'), 'prologue_widget_recent_comments_avatar_control' ); if ( is_active_widget('prologue_widget_recent_comments_avatar') ) add_action('wp_head', 'prologue_widget_recent_comments_avatar_style'); } add_action('init', 'prologue_widget_recent_comments_avatar_register', 10); //Search related Functions function search_comments_distinct( $distinct ) { global $wp_query; if (!empty($wp_query->query_vars['s'])) { return 'DISTINCT'; } } add_filter('posts_distinct', 'search_comments_distinct'); function search_comments_where( $where ) { global $wp_query, $wpdb; if (!empty($wp_query->query_vars['s'])) { $or = " OR ( comment_post_ID = ".$wpdb->posts . ".ID AND comment_approved = '1' AND comment_content LIKE '%" . like_escape( $wpdb->escape($wp_query->query_vars['s'] ) ) . "%') "; $where = preg_replace( "/\bor\b/i", $or." OR", $where, 1 ); } return $where; } add_filter('posts_where', 'search_comments_where'); function search_comments_join( $join ) { global $wp_query, $wpdb, $request; if (!empty($wp_query->query_vars['s'])) { $join .= " LEFT JOIN $wpdb->comments ON ( comment_post_ID = ID AND comment_approved = '1')"; } return $join; } add_filter('posts_join', 'search_comments_join'); function get_search_query_terms() { $search = get_query_var('s'); $search_terms = get_query_var('search_terms'); if ( !empty($search_terms) ) { return $search_terms; } else if ( !empty($search) ) { return array($search); } return array(); } function hilite( $text ) { $query_terms = array_filter( array_map('trim', get_search_query_terms() ) ); foreach ( $query_terms as $term ) { $term = preg_quote( $term, '/' ); if ( !preg_match( '/<.+>/', $text ) ) { $text = preg_replace( '/(\b'.$term.'\b)/i','$1', $text ); } else { $text = preg_replace( '/(?<=>)([^<]+)?(\b'.$term.'\b)/i','$1$2', $text ); } } return $text; } function hilite_tags( $tags ) { $query_terms = array_filter( array_map('trim', get_search_query_terms() ) ); // tags are kept escaped in the db $query_terms = array_map( 'wp_specialchars', $query_terms ); foreach( array_filter((array)$tags) as $tag ) { if ( in_array( trim($tag->name), $query_terms ) ) { $tag->name ="". $tag->name . ""; } } return $tags; } // Highlight text and comments: add_filter('the_content', 'hilite'); add_filter('get_the_tags', 'hilite_tags'); add_filter('the_excerpt', 'hilite'); add_filter('comment_text', 'hilite'); function iphone_css() { if ( strstr( $_SERVER['HTTP_USER_AGENT'], 'iPhone' ) or isset($_GET['iphone']) && $_GET['iphone'] ) { ?> 'comment', 'respond_id' => 'respond', 'reply_text' => __('Reply', 'p2'), 'login_text' => __('Log in to Reply', 'p2'), 'depth' => 0, 'before' => '', 'after' => ''); $args = wp_parse_args($args, $defaults); if ( 0 == $args['depth'] || $args['max_depth'] <= $args['depth'] ) return; extract($args, EXTR_SKIP); $comment = get_comment($comment); $post = get_post($post); if ( 'open' != $post->comment_status ) return false; $link = ''; $reply_text = wp_specialchars( $reply_text ); if ( get_option('comment_registration') && !$user_ID ) $link = '' . wp_specialchars( $login_text ) . ''; else $link = "$reply_text"; return apply_filters('comment_reply_link', $before . $link . $after, $args, $comment, $post); } function prologue_comment_depth_loop( $comment_id, $depth ) { $comment = get_comment( $comment_id ); if ( $comment->comment_parent != 0 ) { return prologue_comment_depth_loop( $comment->comment_parent, $depth + 1 ); } return $depth; } function prologue_get_comment_depth( $comment_id ) { return prologue_comment_depth_loop( $comment_id, 1 ); } function prologue_comment_depth( $comment_id ) { echo prologue_get_comment_depth( $comment_id ); } function prologue_navigation() { ?> %1$s is proudly powered by %2$s.', 'p2'), get_bloginfo('name'), 'WordPress' ) ); } if ( defined('IS_WPCOM') && IS_WPCOM ) { add_filter( 'prologue_poweredby_link', returner(''.__('Blog at WordPress.com', 'p2').'.') ); }