Advertisements

akismet_admin_warnings

Definition:
function akismet_admin_warnings() {}

Defined filters

  • akismet_show_user_comments_approved
    apply_filters( 'akismet_show_user_comments_approved', get_option('akismet_show_user_comments_approved')

Source code

function akismet_admin_warnings() {

	global $wpcom_api_key;

	if ( !get_option('wordpress_api_key') && !$wpcom_api_key && !isset($_POST['submit']) ) {

		function akismet_warning() {

			echo "

			<div id='akismet-warning' class='updated fade'><p><strong>".__('Akismet is almost ready.')."</strong> ".sprintf(__('You must <a href="%1$s">enter your Akismet API key</a> for it to work.'), "plugins.php?page=akismet-key-config")."</p></div>

			";

		}

		add_action('admin_notices', 'akismet_warning');

		return;

	} elseif ( ( empty($_SERVER['SCRIPT_FILENAME']) || basename($_SERVER['SCRIPT_FILENAME']) == 'edit-comments.php' ) &&  wp_next_scheduled('akismet_schedule_cron_recheck') ) {

		function akismet_warning() {

			global $wpdb;

				$waiting = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->commentmeta WHERE meta_key = 'akismet_error'" ) );

				$next_check = human_time_diff( wp_next_scheduled('akismet_schedule_cron_recheck') );

				if ( $waiting > 0 )

					echo "

			<div id='akismet-warning' class='updated fade'><p><strong>".__('Akismet has detected a problem.')."</strong> ".sprintf(_n('A server or network problem prevented Akismet from checking %d comment. It has been temporarily held for moderation and will be automatically re-checked in %s.', 'A server or network problem prevented Akismet from checking %d comments. They have been temporarily held for moderation and will be automatically re-checked in %s.', $waiting), number_format_i18n( $waiting ), $next_check)."</p></div>

			";

		}

		add_action('admin_notices', 'akismet_warning');

		return;

	}

}



// FIXME placeholder



function akismet_comment_row_action( $a, $comment ) {



	// failsafe for old WP versions

	if ( !function_exists('add_comment_meta') )

		return $a;



	$akismet_result = get_comment_meta( $comment->comment_ID, 'akismet_result', true );

	$user_result = get_comment_meta( $comment->comment_ID, 'akismet_user_result', true);

	$comment_status = wp_get_comment_status( $comment->comment_ID );

	$desc = null;

	if ( !$user_result || $user_result == $akismet_result ) {

		// Show the original Akismet result if the user hasn't overridden it, or if their decision was the same

		if ( $akismet_result == 'true' && $comment_status != 'spam' && $comment_status != 'trash' )

			$desc = __( 'Flagged as spam by Akismet' );

		elseif ( $akismet_result == 'false' && $comment_status == 'spam' )

			$desc = __( 'Cleared by Akismet' );

	} else {

		$who = get_comment_meta( $comment->comment_ID, 'akismet_user', true );

		if ( $user_result == 'true' )

			$desc = sprintf( __('Flagged as spam by %s'), $who );

		else

			$desc = sprintf( __('Un-spammed by %s'), $who );

	}



	// add a History item to the hover links, just after Edit

	if ( $akismet_result ) {

		$b = array();

		foreach ( $a as $k => $item ) {

			$b[ $k ] = $item;

			if ( $k == 'edit' )

				$b['history'] = '<a href="comment.php?action=editcomment&amp;c='.$comment->comment_ID.'#akismet-status" title="'. esc_attr__( 'View comment history' ) . '"> '. __('History') . '</a>';

		}

		

		$a = $b;

	}

		

	if ( $desc )

		echo '<span class="akismet-status" commentid="'.$comment->comment_ID.'"><a href="comment.php?action=editcomment&amp;c='.$comment->comment_ID.'#akismet-status" title="' . esc_attr__( 'View comment history' ) . '">'.htmlspecialchars($desc).'</a></span>';

		

	if ( apply_filters( 'akismet_show_user_comments_approved', get_option('akismet_show_user_comments_approved') ) == 'true' ) {

		$comment_count = akismet_get_user_comments_approved( $comment->user_id, $comment->comment_author_email, $comment->comment_author, $comment->comment_author_url );

		$comment_count = intval( $comment_count );

		echo '<span class="akismet-user-comment-count" commentid="'.$comment->comment_ID.'" style="display:none;"><br><span class="akismet-user-comment-counts">'.sprintf( _n( '%s approved', '%s approved', $comment_count ), number_format_i18n( $comment_count ) ) . '</span></span>';

	}

	

	return $a;

}



add_filter( 'comment_row_actions', 'akismet_comment_row_action', 10, 2 );



function akismet_comment_status_meta_box($comment) {

	$history = akismet_get_comment_history( $comment->comment_ID );



	if ( $history ) {

		echo '<div class="akismet-history" style="margin: 13px;">';

		foreach ( $history as $row ) {

			$time = date( 'D d M Y @ h:i:m a', $row['time'] ) . ' GMT';

			echo '<div style="margin-bottom: 13px;"><span style="color: #999;" alt="' . $time . '" title="' . $time . '">' . sprintf( __('%s ago'), human_time_diff( $row['time'] ) ) . '</span> - ';

			echo htmlspecialchars( $row['message'] ) . '</div>';

		}

		

		echo '</div>';



	}

}





// add an extra column header to the comments screen

function akismet_comments_columns( $columns ) {

	$columns[ 'akismet' ] = __( 'Akismet' );

	return $columns;

}



#add_filter( 'manage_edit-comments_columns', 'akismet_comments_columns' );



// Show stuff in the extra column

function akismet_comment_column_row( $column, $comment_id ) {

	if ( $column != 'akismet' )

		return;

		

	$history = akismet_get_comment_history( $comment_id );

	

	if ( $history ) {

		echo '<dl class="akismet-history">';

		foreach ( $history as $row ) {

			echo '<dt>' . sprintf( __('%s ago'), human_time_diff( $row['time'] ) ) . '</dt>';

			echo '<dd>' . htmlspecialchars( $row['message'] ) . '</dd>';

		}

		

		echo '</dl>';

	}

}



#add_action( 'manage_comments_custom_column', 'akismet_comment_column_row', 10, 2 );



// END FIXME



// call out URLS in comments

function akismet_text_add_link_callback( $m ) {

	

		// bare link?

        if ( $m[4] == $m[2] )

                return '<a '.$m[1].' href="'.$m[2].'" '.$m[3].' class="comment-link">'.$m[4].'</a>';

        else

                return '<span title="'.$m[2].'" class="comment-link"><a '.$m[1].' href="'.$m[2].'" '.$m[3].' class="comment-link">'.$m[4].'</a></span>';

}



function akismet_text_add_link_class( $comment_text ) {



        return preg_replace_callback( '#<a ([^>]*)href="([^"]+)"([^>]*)>(.*?)</a>#i', 'akismet_text_add_link_callback', $comment_text );

}



add_filter('comment_text', 'akismet_text_add_link_class');





// WP 2.5+

function akismet_rightnow() {

	global $submenu, $wp_db_version;



	// clean_url was deprecated in WP 3.0

	$esc_url = 'clean_url';

	if ( function_exists( 'esc_url' ) )

		$esc_url = 'esc_url';



	if ( 8645 < $wp_db_version  ) // 2.7

		$link = 'edit-comments.php?comment_status=spam';

	elseif ( isset( $submenu['edit-comments.php'] ) )

		$link = 'edit-comments.php?page=akismet-admin';

	else

		$link = 'edit.php?page=akismet-admin';



	if ( $count = get_option('akismet_spam_count') ) {

		$intro = sprintf( _n(

			'<a href="%1$s">Akismet</a> has protected your site from %2$s spam comment already. ',

			'<a href="%1$s">Akismet</a> has protected your site from %2$s spam comments already. ',

			$count

		), 'http://akismet.com/', number_format_i18n( $count ) );

	} else {

		$intro = sprintf( __('<a href="%1$s">Akismet</a> blocks spam from getting to your blog. '), 'http://akismet.com/' );

	}



	if ( $queue_count = akismet_spam_count() ) {

		$queue_text = sprintf( _n(

			'There\'s <a href="%2$s">%1$s comment</a> in your spam queue right now.',

			'There are <a href="%2$s">%1$s comments</a> in your spam queue right now.',

			$queue_count

		), number_format_i18n( $queue_count ), $esc_url($link) );

	} else {

		$queue_text = sprintf( __( "There's nothing in your <a href='%1\$s'>spam queue</a> at the moment." ), $esc_url($link) );

	}



	$text = $intro . '<br />' . $queue_text;

	echo "<p class='akismet-right-now'>$text</p>\n";

}

	

411

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: