~canonical-sysadmins/wordpress/4.7.1

« back to all changes in this revision

Viewing changes to wp-content/plugins/akismet/class.akismet.php

  • Committer: Barry Price
  • Date: 2016-06-22 02:23:41 UTC
  • mfrom: (1.1.17 upstream)
  • Revision ID: barry.price@canonical.com-20160622022341-9qrp2nesacwfx017
Merge WP4.5.3 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
505
505
                         ( isset( $_POST['spam'] )   && (int) $_POST['spam'] == 1 ) ||
506
506
                         ( isset( $_POST['unspam'] ) && (int) $_POST['unspam'] == 1 ) ||
507
507
                         ( isset( $_POST['comment_status'] )  && in_array( $_POST['comment_status'], array( 'spam', 'unspam' ) ) ) ||
508
 
                         ( isset( $_GET['action'] )  && in_array( $_GET['action'], array( 'spam', 'unspam' ) ) ) ||
509
 
                         ( isset( $_POST['action'] ) && in_array( $_POST['action'], array( 'editedcomment' ) ) )
 
508
                         ( isset( $_GET['action'] )  && in_array( $_GET['action'], array( 'spam', 'unspam', 'spamcomment', 'unspamcomment', ) ) ) ||
 
509
                         ( isset( $_POST['action'] ) && in_array( $_POST['action'], array( 'editedcomment' ) ) ) ||
 
510
                         ( isset( $_GET['for'] ) && ( 'jetpack' == $_GET['for'] ) ) // Moderation via WP.com notifications/WP app/etc.
510
511
                 ) {
511
512
                        if ( $new_status == 'spam' && ( $old_status == 'approved' || $old_status == 'unapproved' || !$old_status ) ) {
512
513
                                return self::submit_spam_comment( $comment->comment_ID );
824
825
 
825
826
        // filter handler used to return a spam result to pre_comment_approved
826
827
        public static function last_comment_status( $approved, $comment ) {
 
828
                if ( is_null( self::$last_comment_result ) ) {
 
829
                        // We didn't have reason to store the result of the last check.
 
830
                        return $approved;
 
831
                }
 
832
 
827
833
                // Only do this if it's the correct comment
828
 
                if ( is_null(self::$last_comment_result) || ! self::matches_last_comment( $comment ) ) {
 
834
                if ( ! self::matches_last_comment( $comment ) ) {
829
835
                        self::log( "comment_is_spam mismatched comment, returning unaltered $approved" );
830
836
                        return $approved;
831
837
                }
1087
1093
                if ( version_compare( $GLOBALS['wp_version'], AKISMET__MINIMUM_WP_VERSION, '<' ) ) {
1088
1094
                        load_plugin_textdomain( 'akismet' );
1089
1095
                        
1090
 
                        $message = '<strong>'.sprintf(esc_html__( 'Akismet %s requires WordPress %s or higher.' , 'akismet'), AKISMET_VERSION, AKISMET__MINIMUM_WP_VERSION ).'</strong> '.sprintf(__('Please <a href="%1$s">upgrade WordPress</a> to a current version, or <a href="%2$s">downgrade to version 2.4 of the Akismet plugin</a>.', 'akismet'), 'https://codex.wordpress.org/Upgrading_WordPress', 'http://wordpress.org/extend/plugins/akismet/download/');
 
1096
                        $message = '<strong>'.sprintf(esc_html__( 'Akismet %s requires WordPress %s or higher.' , 'akismet'), AKISMET_VERSION, AKISMET__MINIMUM_WP_VERSION ).'</strong> '.sprintf(__('Please <a href="%1$s">upgrade WordPress</a> to a current version, or <a href="%2$s">downgrade to version 2.4 of the Akismet plugin</a>.', 'akismet'), 'https://codex.wordpress.org/Upgrading_WordPress', 'https://wordpress.org/extend/plugins/akismet/download/');
1091
1097
 
1092
1098
                        Akismet::bail_on_activation( $message );
1093
1099
                }
1114
1120
        /**
1115
1121
         * Log debugging info to the error log.
1116
1122
         *
1117
 
         * Enabled when WP_DEBUG_LOG is enabled, but can be disabled via the akismet_debug_log filter.
 
1123
         * Enabled when WP_DEBUG_LOG is enabled (and WP_DEBUG, since according to
 
1124
         * core, "WP_DEBUG_DISPLAY and WP_DEBUG_LOG perform no function unless
 
1125
         * WP_DEBUG is true), but can be disabled via the akismet_debug_log filter.
1118
1126
         *
1119
1127
         * @param mixed $akismet_debug The data to log.
1120
1128
         */
1121
1129
        public static function log( $akismet_debug ) {
1122
 
                if ( apply_filters( 'akismet_debug_log', defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) ) {
 
1130
                if ( apply_filters( 'akismet_debug_log', defined( 'WP_DEBUG' ) && WP_DEBUG && defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) ) {
1123
1131
                        error_log( print_r( compact( 'akismet_debug' ), true ) );
1124
1132
                }
1125
1133
        }