]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-content/plugins/akismet/admin.php
WordPress 3.7.2
[autoinstalls/wordpress.git] / wp-content / plugins / akismet / admin.php
index f80719169977cd3f11a0b76c564704af050b9f69..56d8c92d9e37058cc5c20f0aec085e8debec6df2 100644 (file)
@@ -39,13 +39,20 @@ function akismet_load_js_and_css() {
                'plugins_page_akismet-key-config', 
                'jetpack_page_akismet-key-config',
        ) ) ) {
-               wp_register_style( 'akismet.css', AKISMET_PLUGIN_URL . 'akismet.css', array(), '2.5.9' );
+               wp_register_style( 'akismet.css', AKISMET_PLUGIN_URL . 'akismet.css', array(), AKISMET_VERSION );
                wp_enqueue_style( 'akismet.css');
        
-               wp_register_script( 'akismet.js', AKISMET_PLUGIN_URL . 'akismet.js', array('jquery'), '2.5.9' );
+               wp_register_script( 'akismet.js', AKISMET_PLUGIN_URL . 'akismet.js', array('jquery'), AKISMET_VERSION );
                wp_enqueue_script( 'akismet.js' );
                wp_localize_script( 'akismet.js', 'WPAkismet', array(
-                       'comment_author_url_nonce' => wp_create_nonce( 'comment_author_url_nonce' )
+                       'comment_author_url_nonce' => wp_create_nonce( 'comment_author_url_nonce' ),
+                       'strings' => array(
+                               'Remove this URL' => __( 'Remove this URL' ),
+                               'Removing...' => __( 'Removing...' ),
+                               'URL removed' => __( 'URL removed' ),
+                               '(undo)' => __( '(undo)' ),
+                               'Re-adding...' => __( 'Re-adding...' ),
+                       )
                ) );
        }
 }
@@ -335,11 +342,7 @@ function akismet_stats() {
        $path = plugin_basename(__FILE__);
        echo '<h3>' . _x( 'Spam', 'comments' ) . '</h3>';
        global $submenu;
-       if ( isset( $submenu['edit-comments.php'] ) )
-               $link = 'edit-comments.php';
-       else
-               $link = 'edit.php';
-       echo '<p>'.sprintf( _n( '<a href="%1$s">Akismet</a> has protected your site from <a href="%2$s">%3$s spam comments</a>.', '<a href="%1$s">Akismet</a> has protected your site from <a href="%2$s">%3$s spam comments</a>.', $count ), 'http://akismet.com/?return=true', clean_url("$link?page=akismet-admin"), number_format_i18n($count) ).'</p>';
+       echo '<p>'.sprintf( _n( '<a href="%1$s">Akismet</a> has protected your site from <a href="%2$s">%3$s spam comments</a>.', '<a href="%1$s">Akismet</a> has protected your site from <a href="%2$s">%3$s spam comments</a>.', $count ), 'http://akismet.com/?return=true', esc_url( add_query_arg( array( 'page' => 'akismet-admin' ), admin_url( isset( $submenu['edit-comments.php'] ) ? 'edit-comments.php' : 'edit.php' ) ) ), number_format_i18n($count) ).'</p>';
 }
 add_action('activity_box_end', 'akismet_stats');
 
@@ -546,11 +549,11 @@ function akismet_rightnow() {
        global $submenu, $wp_db_version;
 
        if ( 8645 < $wp_db_version  ) // 2.7
-               $link = 'edit-comments.php?comment_status=spam';
+               $link = add_query_arg( array( 'comment_status' => 'spam' ), admin_url( 'edit-comments.php' ) );
        elseif ( isset( $submenu['edit-comments.php'] ) )
-               $link = 'edit-comments.php?page=akismet-admin';
+               $link = add_query_arg( array( 'page' => 'akismet-admin' ), admin_url( 'edit-comments.php' ) );
        else
-               $link = 'edit.php?page=akismet-admin';
+               $link = add_query_arg( array( 'page' => 'akismet-admin' ), admin_url( 'edit.php' ) );
 
        if ( $count = get_option('akismet_spam_count') ) {
                $intro = sprintf( _n(
@@ -581,14 +584,17 @@ add_action('rightnow_end', 'akismet_rightnow');
 
 
 // For WP >= 2.5
-function akismet_check_for_spam_button($comment_status) {
+function akismet_check_for_spam_button( $comment_status ) {
        if ( 'approved' == $comment_status )
                return;
+               
        if ( function_exists('plugins_url') )
-               $link = 'admin.php?action=akismet_recheck_queue';
+               $link = add_query_arg( array( 'action' => 'akismet_recheck_queue' ), admin_url( 'admin.php' ) );
        else
-               $link = 'edit-comments.php?page=akismet-admin&amp;recheckqueue=true&amp;noheader=true';
-       echo "</div><div class='alignleft'><a class='button-secondary checkforspam' href='$link'>" . __('Check for Spam') . "</a>";
+               $link = add_query_arg( array( 'page' => 'akismet-admin', 'recheckqueue' => 'true', 'noheader' => 'true' ), admin_url( 'edit-comments.php' ) );  
+               
+       echo '</div><div class="alignleft"><a class="button-secondary checkforspam" href="' . $link . '">' . esc_html__('Check for Spam') . '</a>';
+       echo '<img src="' . esc_url( admin_url( 'images/wpspin_light.gif' ) ) . '" class="checkforspam-spinner" />';
 }
 add_action('manage_comments_nav', 'akismet_check_for_spam_button');
 
@@ -771,8 +777,12 @@ function akismet_recheck_queue() {
 
        if ( ! ( isset( $_GET['recheckqueue'] ) || ( isset( $_REQUEST['action'] ) && 'akismet_recheck_queue' == $_REQUEST['action'] ) ) )
                return;
-               
-       $moderation = $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = '0'", ARRAY_A );
+                                       
+       $paginate = ''; 
+       if ( isset( $_POST['limit'] ) && isset( $_POST['offset'] ) ) { 
+               $paginate = $wpdb->prepare( " LIMIT %d OFFSET %d", array( $_POST['limit'], $_POST['offset'] ) ); 
+       } 
+       $moderation = $wpdb->get_results( "SELECT * FROM {$wpdb->comments} WHERE comment_approved = '0'{$paginate}", ARRAY_A );
        foreach ( (array) $moderation as $c ) {
                $c['user_ip']    = $c['comment_author_IP'];
                $c['user_agent'] = $c['comment_agent'];
@@ -780,7 +790,7 @@ function akismet_recheck_queue() {
                $c['blog']       = get_bloginfo('url');
                $c['blog_lang']  = get_locale();
                $c['blog_charset'] = get_option('blog_charset');
-               $c['permalink']  = get_permalink($c['comment_post_ID']);
+               $c['permalink']    = get_permalink($c['comment_post_ID']);
 
                $c['user_role'] = '';
                if ( isset( $c['user_ID'] ) )
@@ -815,12 +825,20 @@ function akismet_recheck_queue() {
 
                delete_comment_meta( $c['comment_ID'], 'akismet_rechecking' );
        }
-       $redirect_to = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : admin_url( 'edit-comments.php' );
-       wp_safe_redirect( $redirect_to );
-       exit;
+       if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { 
+               wp_send_json( array( 
+                       'processed' => count((array) $moderation), 
+               )); 
+       } 
+       else { 
+               $redirect_to = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : admin_url( 'edit-comments.php' ); 
+               wp_safe_redirect( $redirect_to ); 
+               exit; 
+       }
 }
 
 add_action('admin_action_akismet_recheck_queue', 'akismet_recheck_queue');
+add_action('wp_ajax_akismet_recheck_queue', 'akismet_recheck_queue');
 
 // Adds an 'x' link next to author URLs, clicking will remove the author URL and show an undo link
 function akismet_remove_comment_author_url() {