]*)(>)/', '\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 ) ); ?>