X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/baca9ce86a38dc54c4574890ee2d352fd81f78b2..a349837896628462bf8c9bdc27d1477a10fe03eb:/wp-content/plugins/akismet/admin.php diff --git a/wp-content/plugins/akismet/admin.php b/wp-content/plugins/akismet/admin.php index 481b0f3d..56d8c92d 100644 --- a/wp-content/plugins/akismet/admin.php +++ b/wp-content/plugins/akismet/admin.php @@ -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.4.4' ); + 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.4.6' ); + 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...' ), + ) ) ); } } @@ -67,11 +74,14 @@ add_filter( 'plugin_action_links', 'akismet_plugin_action_links', 10, 2 ); function akismet_conf() { global $akismet_nonce, $current_user; - $new_key_link = 'https://akismet.com/get/'; - $api_key = akismet_get_key(); - $show_key_form = $api_key; - $key_status = 'empty'; - $saved_ok = false; + $new_key_link = 'https://akismet.com/get/'; + $config_link = esc_url( add_query_arg( array( 'page' => 'akismet-key-config', 'show' => 'enter-api-key' ), class_exists( 'Jetpack' ) ? admin_url( 'admin.php' ) : admin_url( 'plugins.php' ) ) ); + $stats_link = esc_url( add_query_arg( array( 'page' => 'akismet-stats-display' ), class_exists( 'Jetpack' ) ? admin_url( 'admin.php' ) : admin_url( 'index.php' ) ) ); + $api_key = akismet_get_key(); + $show_key_form = $api_key; + $key_status = 'empty'; + $saved_ok = false; + $key_status_text = ''; $ms = array(); @@ -98,17 +108,17 @@ function akismet_conf() { $ms[] = 'key_empty'; } else - $key_status = akismet_verify_key( $key ); - + $key_status = akismet_verify_key( $key ); + if ( $key != $api_key && $key_status == 'valid' ) { - update_option('wordpress_api_key', $key); $ms[] = 'new_key_valid'; + update_option('wordpress_api_key', $key); } elseif ( $key_status == 'invalid' ) $ms[] = 'new_key_invalid'; elseif ( $key_status == 'failed' ) $ms[] = 'new_key_failed'; - + $api_key = $key_status == 'valid' ? $key : false; if ( isset( $_POST['akismet_discard_month'] ) ) @@ -130,6 +140,9 @@ function akismet_conf() { check_admin_referer( $akismet_nonce ); akismet_get_server_connectivity(0); } + elseif ( isset( $_GET['show'] ) && $_GET['show'] == 'enter-api-key' ) { + $show_key_form = true; + } if ( $show_key_form ) { //check current key status @@ -154,7 +167,14 @@ function akismet_conf() { elseif ( !empty( $key ) && $key_status == 'failed' ) $ms[] = 'key_failed'; } - } + } + + $key_status_strings = array( + 'empty' => __( 'Empty' ), + 'valid' => __( 'Valid' ), + 'invalid' => __( 'Invalid' ), + 'failed' => __( 'Failed' ), + ); $messages = array( 'new_key_empty' => array( 'class' => 'updated fade', 'text' => __('Your key has been cleared.' ) ), @@ -174,7 +194,7 @@ function akismet_conf() {

-

Stats' ), esc_url( add_query_arg( array( 'page' => 'akismet-stats-display' ), class_exists( 'Jetpack' ) ? admin_url( 'admin.php' ) : admin_url( 'index.php' ) ) ) ); ?>

+

Stats' ), $stats_link ); ?>

@@ -182,10 +202,10 @@ function akismet_conf() { - +
- +
@@ -203,7 +223,7 @@ function akismet_conf() { -
+

create one here'), '#' );?>

@@ -212,8 +232,8 @@ function akismet_conf() {
-
- +
+
@@ -301,12 +321,13 @@ function akismet_conf() { function akismet_stats_display() { global $akismet_api_host, $akismet_api_port; - $blog = urlencode( get_bloginfo('url') ); - $api_key = akismet_get_key();?> + $blog = urlencode( get_bloginfo('url') ); + $api_key = akismet_get_key(); + $config_link = esc_url( add_query_arg( array( 'page' => 'akismet-key-config' ), class_exists( 'Jetpack' ) ? admin_url( 'admin.php' ) : admin_url( 'plugins.php' ) ) );?>
-

enter your Akismet API key for it to work.' ), esc_url( add_query_arg( array( 'page' => 'akismet-key-config' ), admin_url( 'admin.php' ) ) ) );?>

enter your Akismet API key for it to work.' ), $config_link );?>

@@ -321,11 +342,7 @@ function akismet_stats() { $path = plugin_basename(__FILE__); echo '

' . _x( 'Spam', 'comments' ) . '

'; global $submenu; - if ( isset( $submenu['edit-comments.php'] ) ) - $link = 'edit-comments.php'; - else - $link = 'edit.php'; - echo '

'.sprintf( _n( 'Akismet has protected your site from %3$s spam comments.', 'Akismet has protected your site from %3$s spam comments.', $count ), 'http://akismet.com/?return=true', clean_url("$link?page=akismet-admin"), number_format_i18n($count) ).'

'; + echo '

'.sprintf( _n( 'Akismet has protected your site from %3$s spam comments.', 'Akismet has protected your site from %3$s spam comments.', $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) ).'

'; } add_action('activity_box_end', 'akismet_stats'); @@ -368,7 +385,7 @@ function akismet_admin_warnings() { -
+ @@ -376,10 +393,10 @@ function akismet_admin_warnings() {
A
-
Activate your Akismet account
+
'.__('Activate your Akismet account').'
-
Almost done - activate your account and say goodbye to comment spam.
+
'.__('Almost done - activate your account and say goodbye to comment spam').'
@@ -532,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( @@ -567,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&recheckqueue=true&noheader=true'; - echo "
" . __('Check for Spam') . ""; + $link = add_query_arg( array( 'page' => 'akismet-admin', 'recheckqueue' => 'true', 'noheader' => 'true' ), admin_url( 'edit-comments.php' ) ); + + echo '
' . esc_html__('Check for Spam') . ''; + echo ''; } add_action('manage_comments_nav', 'akismet_check_for_spam_button'); @@ -757,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']; @@ -766,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'] ) ) @@ -801,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() {