]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-content/plugins/akismet/akismet.php
Wordpress 2.7.1
[autoinstalls/wordpress.git] / wp-content / plugins / akismet / akismet.php
index 21933883c678c827a9b0994709849997600f93f4..20034734795715c418aa3745b9239e64e84d1c7d 100644 (file)
@@ -2,8 +2,8 @@
 /*
 Plugin Name: Akismet
 Plugin URI: http://akismet.com/
-Description: Akismet checks your comments against the Akismet web service to see if they look like spam or not. You need a <a href="http://wordpress.com/api-keys/">WordPress.com API key</a> to use it. You can review the spam it catches under "Comments." To show off your Akismet stats just put <code>&lt;?php akismet_counter(); ?></code> in your template. See also: <a href="http://wordpress.org/extend/plugins/stats/">WP Stats plugin</a>.
-Version: 2.1.8
+Description: Akismet checks your comments against the Akismet web service to see if they look like spam or not. You need a <a href="http://wordpress.com/api-keys/">WordPress.com API key</a> to use it. You can review the spam it catches under "Comments." To show off your Akismet stats just put <code>&lt;?php akismet_counter(); ?&gt;</code> in your template. See also: <a href="http://wordpress.org/extend/plugins/stats/">WP Stats plugin</a>.
+Version: 2.2.3
 Author: Matt Mullenweg
 Author URI: http://ma.tt/
 */
@@ -21,9 +21,19 @@ function akismet_init() {
 
        $akismet_api_port = 80;
        add_action('admin_menu', 'akismet_config_page');
+       add_action('admin_menu', 'akismet_stats_page');
 }
 add_action('init', 'akismet_init');
 
+function akismet_admin_init() {
+       if ( function_exists( 'get_plugin_page_hook' ) )
+               $hook = get_plugin_page_hook( 'akismet-stats-display', 'index.php' );
+       else
+               $hook = 'dashboard_page_akismet-stats-display';
+       add_action('admin_head-'.$hook, 'akismet_stats_script');
+}
+add_action('admin_init', 'akismet_admin_init');
+
 if ( !function_exists('wp_nonce_field') ) {
        function akismet_nonce_field($action = -1) { return; }
        $akismet_nonce = -1;
@@ -137,6 +147,43 @@ function akismet_conf() {
 <?php
 }
 
+function akismet_stats_page() {
+       if ( function_exists('add_submenu_page') )
+               add_submenu_page('index.php', __('Akismet Stats'), __('Akismet Stats'), 'manage_options', 'akismet-stats-display', 'akismet_stats_display');
+
+}
+
+function akismet_stats_script() {
+       ?>
+<script type="text/javascript">
+function resizeIframe() {
+    var height = document.documentElement.clientHeight;
+    height -= document.getElementById('akismet-stats-frame').offsetTop;
+    height += 100; // magic padding
+    
+    document.getElementById('akismet-stats-frame').style.height = height +"px";
+    
+};
+function resizeIframeInit() {
+       document.getElementById('akismet-stats-frame').onload = resizeIframe;
+       window.onresize = resizeIframe;
+}
+addLoadEvent(resizeIframeInit);
+</script><?php
+}
+
+
+function akismet_stats_display() {
+       global $akismet_api_host, $akismet_api_port, $wpcom_api_key;
+       $blog = urlencode( get_option('home') );
+       $url = "http://".get_option('wordpress_api_key').".web.akismet.com/1.0/user-stats.php?blog={$blog}";
+       ?>
+       <div class="wrap">
+       <iframe src="<?php echo $url; ?>" width="100%" height="100%" frameborder="0" id="akismet-stats-frame"></iframe>
+       </div>
+       <?php
+}
+
 function akismet_verify_key( $key ) {
        global $akismet_api_host, $akismet_api_port, $wpcom_api_key;
        $blog = urlencode( get_option('home') );
@@ -263,6 +310,9 @@ add_action('wp_set_comment_status', 'akismet_submit_spam_comment');
 add_action('edit_comment', 'akismet_submit_spam_comment');
 add_action('preprocess_comment', 'akismet_auto_check_comment', 1);
 
+function akismet_spamtoham( $comment ) { akismet_submit_nonspam_comment( $comment->comment_ID ); }
+add_filter( 'comment_spam_to_approved', 'akismet_spamtoham' );
+
 // Total spam in queue
 // get_option( 'akismet_spam_count' ) is the total caught ever
 function akismet_spam_count( $type = false ) {
@@ -660,11 +710,14 @@ add_action('activity_box_end', 'akismet_stats');
 
 // WP 2.5+
 function akismet_rightnow() {
-       global $submenu;
-       if ( isset( $submenu['edit-comments.php'] ) )
-               $link = 'edit-comments.php';
+       global $submenu, $wp_db_version;
+
+       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';
+               $link = 'edit.php?page=akismet-admin';
 
        if ( $count = get_option('akismet_spam_count') ) {
                $intro = sprintf( __ngettext(
@@ -681,9 +734,9 @@ function akismet_rightnow() {
                        'and there\'s <a href="%2$s">%1$s comment</a> in your spam queue right now.',
                        'and there are <a href="%2$s">%1$s comments</a> in your spam queue right now.',
                        $queue_count
-               ), number_format_i18n( $queue_count ), clean_url("$link?page=akismet-admin") );
+               ), number_format_i18n( $queue_count ), clean_url($link) );
        } else {
-               $queue_text = sprintf( __( "but there's nothing in your <a href='%1\$s'>spam queue</a> at the moment." ), clean_url("$link?page=akismet-admin") );
+               $queue_text = sprintf( __( "but there's nothing in your <a href='%1\$s'>spam queue</a> at the moment." ), clean_url($link) );
        }
 
        $text = sprintf( _c( '%1$s %2$s|akismet_rightnow' ), $intro, $queue_text );