"", 'date_format' => 'F jS, Y \a\t g:i a', 'empty_string' => 'Click the "Preview" button to preview your comment here.', 'button_value' => 'Preview', 'ver' => time() )); } function wp_print_scripts() { if ( !is_single() && !is_page() || !comments_open() ) return; extract(get_option( 'ajax_comment_preview' )); wp_enqueue_script( 'ajax_comment_preview', Ajax_Comment_Preview::htmldir() . '/ajax-comment-preview-js.php', array('sack'), Ajax_Comment_Preview::version() . $ver ); } function comment_form() { $preview_vars = get_option( 'ajax_comment_preview' ); echo ''; echo '
'; } function send() { global $user_ID, $user_url, $user_identity, $user_email; $author = trim($_POST['author']); if (!$author) $author = 'Anonymous'; $url = trim($_POST['url']); $text = trim($_POST['text']); $email = trim($_POST['email']); get_currentuserinfo(); if ( $user_ID ) : $author = addslashes($user_identity); $url = addslashes($user_url); $email = addslashes($user_email); 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); $email = apply_filters('pre_comment_author_email', $email); $email = stripslashes($email); $email = apply_filters('get_comment_author_email', $email); 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' ); $preview_vars['template'] = str_replace( array('%author%', '%date%', '%content%', '%email%'), array($author, date_i18n($preview_vars['date_format'], time() + get_settings('gmt_offset') * 3600 - date('Z')), $text, $email), $preview_vars['template'] ); if ( false !== strpos($preview_vars['template'], '%email_hash%') ) $preview_vars['template'] = str_replace('%email_hash%', md5($email), $preview_vars['template']); return $preview_vars['template']; } //Only works for files in wp-content function htmldir() { $realdir = dirname(realpath(__FILE__)); return get_option( 'siteurl' ) . strstr($realdir, '/wp-content'); } function admin_menu() { add_options_page( 'AJAX Comment Preview', 'AJAX Comment Preview', 'manage_options', 'acp-admin', 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']); if ( !$ajax_comment_preview_options['button_value'] ) $ajax_comment_preview_options['button_value'] = 'Preview'; $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

Enter the markup from your theme's comment template here. 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 .
%content%
The text of the comment.
%email%
The email of the comment author.
%email_hash%
The MD5 hash of the comment author's email address. Useful for gravatars.