Plugin Directory

Changeset 942231

Timestamp:
07/02/2014 03:31:15 PM (10 years ago)
Author:
eoigal
Message:
  • Fix spam/ham reports to work outside of dashboard, i.e. Notifications
  • Remove jQuery dependancy for comment form
Location:
akismet/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • akismet/trunk/_inc/akismet.css

    r893039 r942231  
    7676}
    7777.checkforspam-spinner {
    78     display: none;
    79     margin-top: 10px;
     78    display: ;
     79    margin-top: px;
    8080}
    8181
  • akismet/trunk/_inc/akismet.js

    r891006 r942231  
    126126    $('.checkforspam:not(.button-disabled)').click( function(e) {
    127127        $('.checkforspam:not(.button-disabled)').addClass('button-disabled');
    128         $('.checkforspam-spinner').show();
     128        $('.checkforspam-spinner').);
    129129        akismet_check_for_spam(0, 100);
    130130        e.preventDefault();
  • akismet/trunk/_inc/form.js

    r875752 r942231  
    1 jQuery( function ( $ ) {
    2     var ak_js = $( '#ak_js' );
    3 
    4     // If the form field already exists just use that
    5     if ( ak_js.length == 0 ) {
    6         ak_js = $( '<input type="hidden" id="ak_js" name="ak_js" />' );
    7     }
    8     else {
    9         ak_js.remove();
    10     }
    11 
    12     ak_js.val( ( new Date() ).getTime() );
    13 
    14     // single page, front-end comment form
    15     // inline comment reply, wp-admin
    16     $( '#commentform, #replyrow td:first' ).append( ak_js );
    17 } );
     1if(typeof jQuery!=="undefined"){jQuery(function(e){var t=e("#ak_js");if(t.length==0){t=e('<input type="hidden" id="ak_js" name="ak_js" />')}else{t.remove()}t.val((new Date).getTime());e("#commentform, #replyrow td:first").append(t)})}else{document.addEventListener("DOMContentLoaded",function(){var e=document.getElementById("ak_js");if(!e){e=document.createElement("input");e.setAttribute("id","ak_js");e.setAttribute("type","hidden");e.setAttribute("name","ak_js")}else{e.parentNode.removeChild(e)}e.setAttribute("value",(new Date).getTime());var t=document.getElementById("commentform");if(t){t.appendChild(e)}else{var n=document.getElementById("replyrow");if(n){var r=n.getElementsByTagName("td");if(r.length>0){r[0].appendChild(aj_js)}}}},false)}
  • akismet/trunk/class.akismet-admin.php

    r941969 r942231  
    3434        add_action( 'rightnow_end', array( 'Akismet_Admin', 'rightnow_stats' ) );
    3535        add_action( 'manage_comments_nav', array( 'Akismet_Admin', 'check_for_spam_button' ) );
    36         add_action( 'transition_comment_status', array( 'Akismet_Admin', 'transition_comment_status' ), 10, 3 );
    3736        add_action( 'admin_action_akismet_recheck_queue', array( 'Akismet_Admin', 'recheck_queue' ) );
    3837        add_action( 'wp_ajax_akismet_recheck_queue', array( 'Akismet_Admin', 'recheck_queue' ) );
     
    6564   
    6665    public static function admin_plugin_settings_link( $links ) {
    67         $settings_link = '<a href="'.self::get_page_url().'">'.__('Settings', 'akismet').'</a>';
     66        $settings_link = '<a href="'.).'">'.__('Settings', 'akismet').'</a>';
    6867        array_unshift( $links, $settings_link );
    6968        return $links;
     
    332331            $link = add_query_arg( array( 'page' => 'akismet-admin', 'recheckqueue' => 'true', 'noheader' => 'true' ), admin_url( 'edit-comments.php' ) );
    333332
    334         echo '</div><div class="alignleft"><a class="button-secondary checkforspam" href="' . esc_url( $link ) . '">' . esc_html__('Check for Spam', 'akismet') . '</a>';
    335         echo '<img src="' . esc_url( admin_url( 'images/wpspin_light.gif' ) ) . '" class="checkforspam-spinner" />';
    336     }
    337 
    338     public static function transition_comment_status( $new_status, $old_status, $comment ) {
    339         if ( $new_status == $old_status )
    340             return;
    341 
    342         # we don't need to record a history item for deleted comments
    343         if ( $new_status == 'delete' )
    344             return;
    345 
    346         if ( !is_admin() )
    347             return;
    348 
    349         if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) && !current_user_can( 'moderate_comments' ) )
    350             return;
    351 
    352         if ( defined('WP_IMPORTING') && WP_IMPORTING == true )
    353             return;
    354 
    355         // if this is present, it means the status has been changed by a re-check, not an explicit user action
    356         if ( get_comment_meta( $comment->comment_ID, 'akismet_rechecking' ) )
    357             return;
    358 
    359         global $current_user;
    360         $reporter = '';
    361         if ( is_object( $current_user ) )
    362             $reporter = $current_user->user_login;
    363 
    364         // Assumption alert:
    365         // We want to submit comments to Akismet only when a moderator explicitly spams or approves it - not if the status
    366         // is changed automatically by another plugin.  Unfortunately WordPress doesn't provide an unambiguous way to
    367         // determine why the transition_comment_status action was triggered.  And there are several different ways by which
    368         // to spam and unspam comments: bulk actions, ajax, links in moderation emails, the dashboard, and perhaps others.
    369         // We'll assume that this is an explicit user action if POST or GET has an 'action' key.
    370         if ( isset($_POST['action']) || isset($_GET['action']) ) {
    371             if ( $new_status == 'spam' && ( $old_status == 'approved' || $old_status == 'unapproved' || !$old_status ) ) {
    372                 return self::submit_spam_comment( $comment->comment_ID );
    373             } elseif ( $old_status == 'spam' && ( $new_status == 'approved' || $new_status == 'unapproved' ) ) {
    374                 return self::submit_nonspam_comment( $comment->comment_ID );
    375             }
    376         }
    377 
    378         Akismet::update_comment_history( $comment->comment_ID, sprintf( __('%1$s changed the comment status to %2$s', 'akismet'), $reporter, $new_status ), 'status-' . $new_status );
     333        echo '</div><div class="alignleft"><a class="button-secondary checkforspam" href="' . esc_url( $link ) . '">' . esc_html__('Check for Spam', 'akismet') . '</a><span class="checkforspam-spinner"></span>';
    379334    }
    380335
     
    561516    }
    562517
    563     public static function submit_spam_comment( $comment_id ) {
    564         global $wpdb, $current_user, $current_site;
    565 
    566         $comment_id = (int) $comment_id;
    567 
    568         $comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->comments} WHERE comment_ID = %d", $comment_id ) );
    569 
    570         if ( !$comment ) // it was deleted
    571             return;
    572 
    573         if ( 'spam' != $comment->comment_approved )
    574             return;
    575 
    576         // use the original version stored in comment_meta if available
    577         $as_submitted = get_comment_meta( $comment_id, 'akismet_as_submitted', true);
    578 
    579         if ( $as_submitted && is_array( $as_submitted ) && isset( $as_submitted['comment_content'] ) )
    580             $comment = (object) array_merge( (array)$comment, $as_submitted );
    581 
    582         $comment->blog         = get_bloginfo('url');
    583         $comment->blog_lang    = get_locale();
    584         $comment->blog_charset = get_option('blog_charset');
    585         $comment->permalink    = get_permalink($comment->comment_post_ID);
    586 
    587         if ( is_object($current_user) )
    588             $comment->reporter = $current_user->user_login;
    589 
    590         if ( is_object($current_site) )
    591             $comment->site_domain = $current_site->domain;
    592 
    593         $comment->user_role = '';
    594         if ( isset( $comment->user_ID ) )
    595             $comment->user_role = Akismet::get_user_roles( $comment->user_ID );
    596 
    597         if ( Akismet::is_test_mode() )
    598             $comment->is_test = 'true';
    599 
    600         $post = get_post( $comment->comment_post_ID );
    601         $comment->comment_post_modified_gmt = $post->post_modified_gmt;
    602 
    603         $response = Akismet::http_post( build_query( $comment ), 'submit-spam' );
    604         if ( $comment->reporter ) {
    605             Akismet::update_comment_history( $comment_id, sprintf( __('%s reported this comment as spam', 'akismet'), $comment->reporter ), 'report-spam' );
    606             update_comment_meta( $comment_id, 'akismet_user_result', 'true' );
    607             update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
    608         }
    609 
    610         do_action('akismet_submit_spam_comment', $comment_id, $response[1]);
    611     }
    612 
    613     public static function submit_nonspam_comment( $comment_id ) {
    614         global $wpdb, $current_user, $current_site;
    615 
    616         $comment_id = (int) $comment_id;
    617 
    618         $comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->comments} WHERE comment_ID = %d", $comment_id ) );
    619         if ( !$comment ) // it was deleted
    620             return;
    621 
    622         // use the original version stored in comment_meta if available
    623         $as_submitted = get_comment_meta( $comment_id, 'akismet_as_submitted', true);
    624 
    625         if ( $as_submitted && is_array($as_submitted) && isset($as_submitted['comment_content']) )
    626             $comment = (object) array_merge( (array)$comment, $as_submitted );
    627 
    628         $comment->blog         = get_bloginfo('url');
    629         $comment->blog_lang    = get_locale();
    630         $comment->blog_charset = get_option('blog_charset');
    631         $comment->permalink    = get_permalink( $comment->comment_post_ID );
    632         $comment->user_role    = '';
    633 
    634         if ( is_object($current_user) )
    635             $comment->reporter = $current_user->user_login;
    636 
    637         if ( is_object($current_site) )
    638             $comment->site_domain = $current_site->domain;
    639 
    640         if ( isset( $comment->user_ID ) )
    641             $comment->user_role = Akismet::get_user_roles($comment->user_ID);
    642 
    643         if ( Akismet::is_test_mode() )
    644             $comment->is_test = 'true';
    645 
    646         $post = get_post( $comment->comment_post_ID );
    647         $comment->comment_post_modified_gmt = $post->post_modified_gmt;
    648 
    649         $response = Akismet::http_post( build_query( $comment ), 'submit-ham' );
    650         if ( $comment->reporter ) {
    651             Akismet::update_comment_history( $comment_id, sprintf( __('%s reported this comment as not spam', 'akismet'), $comment->reporter ), 'report-ham' );
    652             update_comment_meta( $comment_id, 'akismet_user_result', 'false' );
    653             update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
    654         }
    655 
    656         do_action('akismet_submit_nonspam_comment', $comment_id, $response[1]);
    657     }
    658 
    659518    // Total spam in queue
    660519    // get_option( 'akismet_spam_count' ) is the total caught ever
     
    792651    public static function display_spam_check_warning() {
    793652        Akismet::fix_scheduled_recheck();
     653
     654
    794655
    795656        if ( self::get_number_spam_waiting() > 0 && wp_next_scheduled('akismet_schedule_cron_recheck') > time() )
    796             Akismet::view( 'notice', array( 'type' => 'spam-check' ) );
     657            Akismet::view( 'notice', array( 'type' => 'spam-check' ) );
    797658    }
    798659
  • akismet/trunk/class.akismet.php

    r940667 r942231  
    4040        add_filter( 'comment_moderation_recipients', array( 'Akismet', 'disable_moderation_emails_if_unreachable' ), 1000, 2 );
    4141        add_filter( 'pre_comment_approved', array( 'Akismet', 'last_comment_status' ), 10, 2 );
     42
     43
    4244
    4345        if ( '3.0.5' == $GLOBALS['wp_version'] ) {
     
    372374
    373375        return ( is_array( $response ) && ! empty( $response[1] ) ) ? $response[1] : false;
     376
     377
     378
     379
     380
     381
     382
     383
     384
     385
     386
     387
     388
     389
     390
     391
     392
     393
     394
     395
     396
     397
     398
     399
     400
     401
     402
     403
     404
     405
     406
     407
     408
     409
     410
     411
     412
     413
     414
     415
     416
     417
     418
     419
     420
     421
     422
     423
     424
     425
     426
     427
     428
     429
     430
     431
     432
     433
     434
     435
     436
     437
     438
     439
     440
     441
     442
     443
     444
     445
     446
     447
     448
     449
     450
     451
     452
     453
     454
     455
     456
     457
     458
     459
     460
     461
     462
     463
     464
     465
     466
     467
     468
     469
     470
     471
     472
     473
     474
     475
     476
     477
     478
     479
     480
     481
     482
     483
     484
     485
     486
     487
     488
     489
     490
     491
     492
     493
     494
     495
     496
     497
     498
     499
     500
     501
     502
     503
     504
     505
     506
     507
     508
     509
     510
     511
     512
     513
     514
     515
     516
     517
     518
     519
    374520    }
    375521
     
    676822
    677823    public static function load_form_js() {
    678         wp_enqueue_script( 'akismet-form', AKISMET__PLUGIN_URL . '_inc/form.js', array( 'jquery' ), AKISMET_VERSION );
     824        wp_enqueue_script( 'akismet-form', AKISMET__PLUGIN_URL . '_inc/form.js', array( );
    679825    }
    680826
  • akismet/trunk/readme.txt

    r938204 r942231  
    33Tags: akismet, comments, spam
    44Requires at least: 3.0
    5 Tested up to: 3.9
     5Tested up to: 3.9
    66Stable tag: 3.0.0
    77License: GPLv2 or later
     
    3333= 3.0.1-alpha =
    3434* Removed dependency on PHP's fsockopen function
     35
     36
    3537
    3638= 3.0.0 =
  • akismet/trunk/wrapper.php

    r899802 r942231  
    1616    _deprecated_function( __FUNCTION__, '3.0', 'Akismet::http_post()' );
    1717
    18     $path = str_replace( '/1.1/', '', $path );
     18    $path = str_replace( '/1.1/', '', $path );
    1919
    2020    return Akismet::http_post( $request, $path, $ip );
     
    121121}
    122122function akismet_submit_nonspam_comment( $comment_id ) {
    123     _deprecated_function( __FUNCTION__, '3.0', 'Akismet_Admin::submit_nonspam_comment()' );
    124 
    125     return Akismet_Admin::submit_nonspam_comment( $comment_id );
     123    _deprecated_function( __FUNCTION__, '3.0', 'Akismet::submit_nonspam_comment()' );
     124
     125    return Akismet::submit_nonspam_comment( $comment_id );
    126126}
    127127function akismet_submit_spam_comment( $comment_id ) {
    128     _deprecated_function( __FUNCTION__, '3.0', 'Akismet_Admin::submit_spam_comment()' );
    129 
    130     return Akismet_Admin::submit_spam_comment( $comment_id );
     128    _deprecated_function( __FUNCTION__, '3.0', 'Akismet::submit_spam_comment()' );
     129
     130    return Akismet::submit_spam_comment( $comment_id );
    131131}
    132132function akismet_transition_comment_status( $new_status, $old_status, $comment ) {
    133     _deprecated_function( __FUNCTION__, '3.0', 'Akismet_Admin::transition_comment_status()' );
    134 
    135     return Akismet_Admin::transition_comment_status( $new_status, $old_status, $comment );
     133    _deprecated_function( __FUNCTION__, '3.0', 'Akismet::transition_comment_status()' );
     134
     135    return Akismet::transition_comment_status( $new_status, $old_status, $comment );
    136136}
    137137function akismet_spam_count( $type = false ) {
Note: See TracChangeset for help on using the changeset viewer.