post_type, 'comments' ) : true; if( function_exists( 'wp_list_comments' ) && is_singular( ) && $post_type_supports && comments_open( $post->ID ) ) { $prefix = ! defined( 'SCRIPT_DEBUG' ) || ( defined( 'SCRIPT_DEBUG' ) && ! SCRIPT_DEBUG ) ? '.min' : ''; wp_register_script( 'json2', SPEC_COMMENT_URL . "/js/json2.js", array( ), '20090817', true ); wp_register_script( 'autogrow', SPEC_COMMENT_URL . "/js/jquery.autogrow-textarea$prefix.js", array( 'jquery' ), 1.04, true ); wp_register_script( 'scrollto', SPEC_COMMENT_URL . "/js/jquery.scrollTo-1.4.2-min.js", array( 'jquery' ), '1.4.2', true ); // Make sure we have jQuery version 1.3.2 or better if ( isset( $wp_scripts->registered[ 'jquery' ]->ver ) && version_compare( $wp_scripts->registered[ 'jquery' ]->ver, '1.3.2', '<' ) ){ wp_deregister_script( 'jquery' ); wp_register_script( 'jquery', SPEC_COMMENT_URL . "/js/jquery.js", array( ), '1.3.2', true ); } wp_deregister_script( 'comment-reply' ); // dealt with by the included jQuery global $post; $localisation = array( 'tb_show' => __( 'Show trackbacks', SPEC_COMMENT_DOM ), 'tb_hide' => __( 'Hide trackbacks', SPEC_COMMENT_DOM ), 'rpl_hide_2' => __( "Hide %count% replies to %name%'s comment", SPEC_COMMENT_DOM ), 'rpl_show_2' => __( "View %count% replies to %name%'s comment", SPEC_COMMENT_DOM ), 'rpl_hide_1' => __( "Hide the reply to %name%'s comment", SPEC_COMMENT_DOM ), 'rpl_show_1' => __( "View the reply to %name%'s comment", SPEC_COMMENT_DOM ), 'tb_from' => __( 'Trackback from: %s', SPEC_COMMENT_DOM ), 'err_txt_mis' => __( 'Missing some fields', SPEC_COMMENT_DOM ), 'unknown' => __( 'Unknown commenter', SPEC_COMMENT_DOM ), 'order' => get_option( 'comment_order' ), 'polling' => spec_comment_option( 'polling' ), 'update' => $this->check_live( $post->ID ) && comments_open( $post->ID ) ? 1 : 0, 'time' => current_time( 'mysql', false ), 'post_id' => $post->ID, 'ajax_url' => trailingslashit( home_url( ) ), 'nest_depth' => spec_comment_option( 'comments_nest_depth' ), 'max_depth' => get_option( 'thread_comments_depth' ) ); if ( spec_comment_option( 'quote_button' ) || spec_comment_option( 'quote_select' ) ) { wp_enqueue_script( 'spec_quote_button', SPEC_COMMENT_URL . "/js/quote$prefix.js", array( 'jquery' ), '1.0.3', true ); $quote_options = array( 'button_text' => __( 'Quote', SPEC_COMMENT_DOM ), 'quote_button' => spec_comment_option( 'quote_button' ), 'quote_select' => spec_comment_option( 'quote_select' ), 'quote_target' => spec_comment_option( 'quote_target' ) ); wp_localize_script( 'spec_quote_button', 'specQuoteLn', $quote_options ); } wp_enqueue_script( 'commenting', apply_filters( 'spec_comment_js', SPEC_COMMENT_URL . "/js/commenting$prefix.js" ), array( 'jquery', 'autogrow', 'jquery-form', 'json2', 'scrollto' ), '1.0.3', true ); wp_localize_script( 'commenting', 'commentingL10n', apply_filters( 'spec_comment_local_js', $localisation ) ); } } /* Change the path to the comments.php to point to our new comments.php file. @param string $passed passed in by comments_template apply_filters call and would normally contain the path to the theme's comments.php @return string the new comments.php if it exists otherwise just return the one we were given before. */ function comment_template_hijack( $passed ){ if ( file_exists( SPEC_COMMENT_TMP ) ) return SPEC_COMMENT_TMP; else return $passed; } /* Add the comments.css file to the head of pages that'll need comments. @uses apply_filters( ) Calls 'spec_comment_css' hook on the the path to the stylesheet so that you can roll your own should you need/want to. @return null; */ function css( ){ if ( is_singular( ) && strtolower( spec_comment_option( 'stylesheet' ) ) != 'disabled' ) { ?> = 9 && $version < 10 ) { $class[ ] = 'ie'; $class[ ] = 'ie9'; // Look forward to the day when this is the standard IE, shouldn't need this anymore then. :D } elseif ( ! in_array( 'ie8', $class ) && $version >= 8 && $version < 9 ) { $class[ ] = 'ie'; $class[ ] = 'ie8'; } elseif ( ! in_array( 'ie7', $class ) && $version >= 7 && $version < 8 ) { $class[ ] = 'ie'; $class[ ] = 'ie7'; } elseif ( ! in_array( 'ie6', $class ) && $version >= 6 && $version < 7 ) { $class[ ] = 'ie'; $class[ ] = 'ie6'; } elseif ( ! in_array( 'ie55', $class ) && $version >= 5.5 && $version < 6 ) { $class[ ] = 'ie'; $class[ ] = 'ie55'; } elseif ( ! in_array( 'ie5', $class ) && $version >= 5 && $version < 5.5 ) { $class[ ] = 'ie'; $class[ ] = 'ie5'; } elseif ( ! in_array( 'ie-old', $class ) && $version < 5 ) { $class[ ] = 'ie'; $class[ ] = 'ie-old'; } else { // Unknown IE. $class[ ] = 'ie'; $class[ ] = 'iexx'; } } return $class; } /* This is attached to the comment_form action and just echos out our credit link. If you don't want to give us credit for this :( then you can hide the link from the admin page. */ function our_credit( ){ if ( spec_comment_option( 'credit' ) ) { echo '

' . sprintf( __( 'Threaded commenting powered by %s code.', SPEC_COMMENT_DOM ), 'Spectacu.la' ) . '

'; } else { // If you've unticked the show our credit link we'll just have it as an HTML comment instead. // Nothing to stop you removing this line too. But please don't. echo "\n\n"; } } /* Add the metaboxes to all post_types available or post and pages for WordPress 2.9 and older. */ function add_meta_boxes( ) { global $wp_version; if ( version_compare( $wp_version, '3.0', 'ge' ) ) { // WordPress 3.0 and above. foreach( ( array ) get_post_types( array( 'show_ui' => 1 ) ) as $post_type ) { if( post_type_supports( $post_type, 'comments' ) ) add_meta_box( 'spec_live_toggle', __( 'Live Discussion', SPEC_COMMENT_DOM ), array( &$this, 'metabox_live_toggle' ), $post_type, 'advanced', 'default' ); } } else { // Add to post and page for older versions of WordPress. add_meta_box( 'spec_live_toggle', __( 'Live Discussion', SPEC_COMMENT_DOM ), array( &$this, 'metabox_live_toggle' ), 'post', 'advanced', 'default' ); add_meta_box( 'spec_live_toggle', __( 'Live Discussion', SPEC_COMMENT_DOM ), array( &$this, 'metabox_live_toggle' ), 'page', 'advanced', 'default' ); } } /* This is the metabox that'll let you toggle the default status of live commenting on a post by post basis. @param obj $post The post object as passed in by add_meta_box. */ function metabox_live_toggle( $post = '' ) { if ( ! is_object( $post ) ) return false; ?>