~canonical-sysadmins/wordpress/4.9.7

« back to all changes in this revision

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

  • Committer: Barry Price
  • Date: 2017-11-02 04:15:48 UTC
  • mfrom: (1.1.29 upstream)
  • Revision ID: barry.price@canonical.com-20171102041548-n4kg8l9f98xajt7m
Merge WP4.8.3 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
91
91
        }
92
92
 
93
93
        public static function load_menu() {
94
 
                if ( class_exists( 'Jetpack' ) )
 
94
                if ( class_exists( 'Jetpack' ) ) {
95
95
                        $hook = add_submenu_page( 'jetpack', __( 'Akismet' , 'akismet'), __( 'Akismet' , 'akismet'), 'manage_options', 'akismet-key-config', array( 'Akismet_Admin', 'display_page' ) );
96
 
                else
 
96
                }
 
97
                else {
97
98
                        $hook = add_options_page( __('Akismet', 'akismet'), __('Akismet', 'akismet'), 'manage_options', 'akismet-key-config', array( 'Akismet_Admin', 'display_page' ) );
98
 
 
99
 
                if ( version_compare( $GLOBALS['wp_version'], '3.3', '>=' ) ) {
 
99
                }
 
100
                
 
101
                if ( $hook ) {
100
102
                        add_action( "load-$hook", array( 'Akismet_Admin', 'admin_help' ) );
101
103
                }
102
104
        }
248
250
        }
249
251
 
250
252
        public static function enter_api_key() {
251
 
                if ( function_exists('current_user_can') && !current_user_can('manage_options') )
252
 
                        die(__('Cheatin’ uh?', 'akismet'));
 
253
                if ( ! current_user_can( 'manage_options' ) ) {
 
254
                        die( __( 'Cheatin’ uh?', 'akismet' ) );
 
255
                }
253
256
 
254
257
                if ( !wp_verify_nonce( $_POST['_wpnonce'], self::NONCE ) )
255
258
                        return false;
303
306
        }
304
307
 
305
308
        public static function dashboard_stats() {
306
 
                if ( !function_exists('did_action') || did_action( 'rightnow_end' ) )
 
309
                if ( did_action( 'rightnow_end' ) ) {
307
310
                        return; // We already displayed this info in the "Right Now" section
 
311
                }
308
312
 
309
313
                if ( !$count = get_option('akismet_spam_count') )
310
314
                        return;
356
360
                        return;
357
361
                }
358
362
 
359
 
                if ( function_exists('plugins_url') )
360
 
                        $link = add_query_arg( array( 'action' => 'akismet_recheck_queue' ), admin_url( 'admin.php' ) );
361
 
                else
362
 
                        $link = add_query_arg( array( 'page' => 'akismet-admin', 'recheckqueue' => 'true', 'noheader' => 'true' ), admin_url( 'edit-comments.php' ) );
 
363
                $link = add_query_arg( array( 'action' => 'akismet_recheck_queue' ), admin_url( 'admin.php' ) );
363
364
 
 
365
                $comments_count = wp_count_comments();
 
366
                
364
367
                echo '</div>';
365
368
                echo '<div class="alignleft">';
366
369
                echo '<a
367
370
                                class="button-secondary checkforspam"
368
371
                                href="' . esc_url( $link ) . '"
369
372
                                data-active-label="' . esc_attr( __( 'Checking for Spam', 'akismet' ) ) . '"
370
 
                                data-progress-label-format="' . esc_attr( __( '(%1$s...)', 'akismet' ) ) . '"
 
373
                                data-progress-label-format="' . esc_attr( __( '(%1$s%)', 'akismet' ) ) . '"
371
374
                                data-success-url="' . esc_attr( remove_query_arg( 'akismet_recheck', add_query_arg( array( 'akismet_recheck_complete' => 1, 'recheck_count' => urlencode( '__recheck_count__' ), 'spam_count' => urlencode( '__spam_count__' ) ) ) ) ) . '"
 
375
                                data-pending-comment-count="' . esc_attr( $comments_count->moderated ) . '"
372
376
                                >';
373
377
                        echo '<span class="akismet-label">' . esc_html__('Check for Spam', 'akismet') . '</span>';
374
378
                        echo '<span class="checkforspam-progress"></span>';
467
471
        }
468
472
 
469
473
        public static function comment_row_action( $a, $comment ) {
470
 
 
471
 
                // failsafe for old WP versions
472
 
                if ( !function_exists('add_comment_meta') )
473
 
                        return $a;
474
 
 
475
474
                $akismet_result = get_comment_meta( $comment->comment_ID, 'akismet_result', true );
476
475
                $akismet_error  = get_comment_meta( $comment->comment_ID, 'akismet_error', true );
477
476
                $user_result    = get_comment_meta( $comment->comment_ID, 'akismet_user_result', true);
500
499
                                $b[ $k ] = $item;
501
500
                                if (
502
501
                                        $k == 'edit'
503
 
                                        || ( $k == 'unspam' && $GLOBALS['wp_version'] >= 3.4 )
 
502
                                        || $k == 'unspam'
504
503
                                ) {
505
504
                                        $b['history'] = '<a href="comment.php?action=editcomment&amp;c='.$comment->comment_ID.'#akismet-status" title="'. esc_attr__( 'View comment history' , 'akismet') . '"> '. esc_html__('History', 'akismet') . '</a>';
506
505
                                }
645
644
                if ( !$type ) { // total
646
645
                        $count = wp_cache_get( 'akismet_spam_count', 'widget' );
647
646
                        if ( false === $count ) {
648
 
                                if ( function_exists('wp_count_comments') ) {
649
 
                                        $count = wp_count_comments();
650
 
                                        $count = $count->spam;
651
 
                                } else {
652
 
                                        $count = (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM {$wpdb->comments} WHERE comment_approved = 'spam'");
653
 
                                }
 
647
                                $count = wp_count_comments();
 
648
                                $count = $count->spam;
654
649
                                wp_cache_set( 'akismet_spam_count', $count, 'widget', 3600 );
655
650
                        }
656
651
                        return $count;
706
701
                        update_option('akismet_connectivity_time', time());
707
702
                }
708
703
 
709
 
                if ( function_exists( 'wp_http_supports' ) && ( wp_http_supports( array( 'ssl' ) ) ) ) {
 
704
                if ( wp_http_supports( array( 'ssl' ) ) ) {
710
705
                        $response = wp_remote_get( 'https://rest.akismet.com/1.1/test' );
711
706
                }
712
707
                else {