"", 'date_format' => 'F jS, Y \a\t g:i a', 'input_id' => 'comment', 'author_id' => 'author', 'url_id' => 'url', 'empty_string' => 'Click the "Preview" button to preview your comment here.', 'ver' => time() )); } function wp_print_scripts() { if ( !is_single() && !is_page() ) return; extract(get_option( 'ajax_comment_preview' )); wp_enqueue_script( 'ajax_comment_preview', '/' . Ajax_Comment_Preview::htmldir( __FILE__ ) . '/ajax-comment-preview-js.php', array('sack'), Ajax_Comment_Preview::version() . $ver ); } function wp_head() { if ( is_single() || is_page() ) { global $sack_js; extract(get_option( 'ajax_comment_preview' )); if ( !$sack_js ) { echo '' . "\n"; $sack_js = true; } echo '' . "\n"; } } function comment_form() { echo ''; echo '
'; } function send() { global $user_ID, $user_url, $user_identity; $author = trim($_POST['author']); if (!$author) $author = 'Anonymous'; $url = trim($_POST['url']); $text = trim($_POST['text']); get_currentuserinfo(); if ( $user_ID ) : $author = addslashes($user_identity); $url = addslashes($user_url); endif; $text = apply_filters('pre_comment_content', $text); $text = apply_filters('post_comment_text', $text); // Deprecated $text = apply_filters('comment_content_presave', $text); // Deprecated $text = stripslashes($text); $text = apply_filters('get_comment_text', $text); $text = apply_filters('comment_text', $text); $author = apply_filters('pre_comment_author_name', $author); $author = stripslashes($author); $author = apply_filters('get_comment_author', $author); if ( $url && 'http://' !== $url ) : $url = apply_filters('pre_comment_author_url', $url); $url = stripslashes($url); $url = apply_filters('get_comment_url', $url); $author = '' . $author . ''; $author = apply_filters('get_comment_author_link', $author); $author = apply_filters('comment_author_link', $author); endif; $preview_vars = get_option( 'ajax_comment_preview' ); return str_replace( array('%author%', '%date%', '%content%'), array($author, date($preview_vars['date_format'], time() + get_settings('gmt_offset') * 3600), $text), $preview_vars['template'] ); } //Only works for files in wp-content function htmldir($relative_path) { $realdir = dirname(realpath($relative_path)); $htmldir = PREVIEW_ROOT_URL . strstr($realdir, '/wp-content'); return trim($htmldir, ' /'); } function admin_menu() { add_options_page( 'AJAX Comment Preview', 'AJAX Comment Preview', 'manage_options', __FILE__, array('Ajax_Comment_Preview', 'admin_page') ); } function admin_page() { if ( isset($_POST['ajax_comment_preview_options_submit']) ) { check_admin_referer( 'ajax_comment_preview' ); $ajax_comment_preview_options = stripslashes_deep($_POST['acp']); $ajax_comment_preview_options['ver'] = time(); update_option( 'ajax_comment_preview', $ajax_comment_preview_options ); echo '

Ajax Comment Preview options updated.

'; } extract(get_option( 'ajax_comment_preview' )); ?>

Ajax Comment Preview Options

Input HTML IDs

Enter the HTML IDs of the following input fields of your blog's comment form below.

Author's name
Author's URL
Comment Text

Comment Template

Enter your theme's comment template below. The following special tags are available.

%author%
The name of the comment author linked to the comment author's url.
%date%
The date formatted as above.
%content%
The text of the comment.