]*)(>)/', '\1 class="comment-reply-link"\2', $link ); return $link; } } /* Needed for <= WP27 Very crude version of WP28's esc_attr function. All I need really so good enough. */ if ( ! function_exists ( 'esc_attr' ) ) { function esc_attr( $text ) { $output = htmlspecialchars_decode( $text, ENT_QUOTES ); $output = htmlspecialchars( $output, ENT_QUOTES, get_bloginfo( 'charset' ) ); return $text != $output ? $output : $text; } } /* Quickly check that we're running with separated comments. Comment by type is set at the call to comments_template and there seems to be no way to force it so we need to check for it and render the comments differently for each case. @return bool True if we have a comment_by_type array set otherwise false. */ if ( ! function_exists( 'commenting_by_type' ) ) { function commenting_by_type( ) { global $wp_query; if ( property_exists( $wp_query, 'comments_by_type' ) && $wp_query->comments_by_type ) return true; else return false; } } /* Looks through the plug-in folder called style for any CSS files that can be used with this, and checks the theme folder for comments.css Collect the stylesheet array. If I wasn't targetting wp27 I'd store the content of this function in a transient to save doing the search twice in such a short period of time. Ah well, I'll kill wp2.7 support in a version or two so can do that then. @return array each file found has its own array containing title, url, basename and full filename. */ if ( ! function_exists( 'spec_find_stylesheets' ) ) { function spec_stylesheet_find( ) { $root = SPEC_COMMENT_PTH . '/style'; // Open the DIR if we can $dir = @opendir( $root ); if ( !is_resource( $dir ) ) { return false; } $stylesheets = array( ); while ( ( $dir_content = readdir( $dir ) ) !== false ) { $filename = $root . '/' . $dir_content; if ( is_dir( $filename ) || !is_readable( $filename ) || strtolower( substr( $dir_content, -3 ) ) != 'css' ) continue; if ( file_exists( $filename ) && is_file( $filename ) ) { $file = @fopen( $filename, 'r' ); $file_content = fread( $file, filesize( $filename ) ); @fclose( $file ); } // Find the first forward-slash asterix comment in the file. preg_match( '/(?:\/\*.*?\*\/)/s', $file_content, $comment ); if ( $comment[ 0 ] && preg_match( '/comment style:(.*)$/mi', $comment[ 0 ], $title ) ) { // This key will need changing to avoid conflicts with two very sim filenames $key = sanitize_title( $dir_content ); // Lets populate the array now. $stylesheets[ $key ][ 'filename' ] = $filename; $stylesheets[ $key ][ 'url'] = trailingslashit( SPEC_COMMENT_URL ) . 'style/' . basename( $filename ); $stylesheets[ $key ][ 'basename' ] = basename( $filename ); $stylesheets[ $key ][ 'title' ] = trim( preg_replace( "/\s*(?:\*\/|\?>).*/", '', $title[ 1 ] ) ); /* # @todo: Maybe at some point I'll use this. if ( preg_match( '/Description:(.*)$/mi', $comment[ 0 ], $description ) ) $stylesheets[ $key ][ 'description' ] = _cleanup_header_comment( $desc[ 1 ] ); */ } } if ( is_resource( $dir ) ) { @closedir( $dir ); } /* Add css for the stuff found in the theme, check first with any child theme then the parent. */ if ( file_exists( trailingslashit( STYLESHEETPATH ) . 'comments.css' ) ) { $stylesheets[ 'theme/template' ] = array( 'filename' => trailingslashit( STYLESHEETPATH ) . 'comments.css', 'basename' => 'comments.css', 'title' => __( 'Theme styling', SPEC_COMMENT_DOM ), 'url' => trailingslashit( get_stylesheet_directory_uri( ) ) . 'comments.css' ); } else if ( file_exists( trailingslashit( TEMPLATEPATH ) . 'comments.css' ) ) { $stylesheets[ 'theme/template' ] = array( 'filename' => trailingslashit( TEMPLATEPATH ) . 'comments.css', 'basename' => 'comments.css', 'title' => __( 'Theme styling', SPEC_COMMENT_DOM ), 'url' => trailingslashit( get_stylesheet_directory_uri( ) ) . 'comments.css' ); } return $stylesheets; } } /* The comment form. Simple as that really. In here rather than the template as it can be called in different places depending on comment order. @return null */ if ( ! function_exists( 'spec_comments_form' ) ) { function spec_comments_form( ) { global $post, $id, $comment, $user_ID, $current_user, $user_identity; if ( comments_open( ) ) { if ( ! is_user_logged_in( ) ) $commenter = wp_get_current_commenter( ); if ( spec_comment_option( 'form_avatar' ) ) $avatar = get_avatar( isset( $current_user->user_email ) ? $current_user->user_email : $commenter[ 'comment_author_email' ], apply_filters( 'spec_avatar_size_large', 64 ) ); ?>
  • ID ); $form_title = spec_comment_option( 'form_title' ); if ( $form_title != '' ) echo '
    ' . $form_title . '
    '; ?>
    user_email ) || isset( $commenter[ 'comment_author_email' ] ) ? '' . $avatar . '' : $avatar; ?>
    ID ); ?>
    ID ); if ( $user_ID ) {?>
    />
    />
    ID );?>
    ID ); }?>
  • ID ); } } } function spec_comment_moderation_link($moderation_action,$post_id,$comment_id){ $url = get_permalink($post_id); global $wp_rewrite; $rewrite = $wp_rewrite->wp_rewrite_rules(); if ( ! empty($rewrite) ) { $url .= '?'.$moderation_action.'comment='.$comment_id; } else { $url .= '&'.$moderation_action.'comment='.$comment_id; } // return $url; } function spec_comment_approve_link($post_id,$comment_id){ return spec_comment_moderation_link('approve',$post_id,$comment_id); } function spec_comment_delete_link($post_id,$comment_id){ return spec_comment_moderation_link('delete',$post_id,$comment_id); } function spec_comment_spam_link($post_id,$comment_id){ return spec_comment_moderation_link('spam',$post_id,$comment_id); } /* Comment layout function used by WP27 walker . @return null */ if ( ! function_exists( 'spec_comment_layout' ) ) { function spec_comment_layout( $comment, $args = array( ), $depth = null ) { global $post; $GLOBALS[ 'comment' ] = $comment; extract( $args, EXTR_SKIP ); if ( ! ( isset( $post ) && is_object( $post ) ) && ( isset( $post_id ) && intval( $post_id ) ) ) $post = get_post( $post_id ); if ( ! isset( $max_depth ) ) $max_depth = get_option( 'thread_comments_depth' ); $add_below = 'comment'; $tb = $comment->comment_type == 'trackback' || $comment->comment_type == 'pingback'; // Avatar ( Still in glorious 2D :P ) if ( get_option( 'show_avatars' ) && $avatar_size != 0 ) { $avatar = get_avatar( $comment, ( $depth == 1 ? apply_filters( 'spec_avatar_size_large', 64 ): apply_filters( 'spec_avatar_size_small', 32 ) ) ); } ?>
  • >
    comment_date; ?> ' . $avatar . '
    ' : ''; ?>
    comment_approved == 0){ // comment is awaiting approval! ?>
    $add_below, 'depth' => $depth, 'max_depth' => $max_depth, 'reply_text' => __( 'Reply', SPEC_COMMENT_DOM ) ) ), null, isset( $args[ 'post_id' ] ) && intval( $args[ 'post_id' ] ) ? intval( $args[ 'post_id' ] ) : null ); edit_comment_link( __( 'Edit', SPEC_COMMENT_DOM ), '', '' ); if ( spec_comment_option( 'link_button' ) ) { ?>