File manager - Edit - /home/rangceb/diohome.com/wp-includes6790ed/pomo/akismet.tar
Back
readme.txt 0000644 00000006061 15222563563 0006556 0 ustar 00 === Akismet Spam Protection === Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal, cfinke, automattic, jgs, procifer, stephdau Tags: comments, spam, antispam, anti-spam, contact form, anti spam, comment moderation, comment spam, contact form spam, spam comments Requires at least: 4.6 Tested up to: 5.8 Stable tag: 4.1.10 License: GPLv2 or later The best anti-spam protection to block spam comments and spam in a contact form. The most trusted antispam solution for WordPress and WooCommerce. == Description == Akismet checks your comments and contact form submissions against our global database of spam to prevent your site from publishing malicious content. You can review the comment spam it catches on your blog's "Comments" admin screen. Major features in Akismet include: * Automatically checks all comments and filters out the ones that look like spam. * Each comment has a status history, so you can easily see which comments were caught or cleared by Akismet and which were spammed or unspammed by a moderator. * URLs are shown in the comment body to reveal hidden or misleading links. * Moderators can see the number of approved comments for each user. * A discard feature that outright blocks the worst spam, saving you disk space and speeding up your site. PS: You'll be prompted to get an Akismet.com API key to use it, once activated. Keys are free for personal blogs; paid subscriptions are available for businesses and commercial sites. == Installation == Upload the Akismet plugin to your blog, activate it, and then enter your Akismet.com API key. 1, 2, 3: You're done! == Changelog == = 4.1.10 = *Release Date - 6 July 2021* * Simplified the code around checking comments in REST API and XML-RPC requests. * Updated Plus plan terminology in notices to match current subscription names. * Added `rel="noopener"` to the widget link to avoid warnings in Google Lighthouse. * Set the Akismet JavaScript as deferred instead of async to improve responsiveness. * Improved the preloading of screenshot popups on the edit comments admin page. = 4.1.9 = *Release Date - 2 March 2021* * Improved handling of pingbacks in XML-RPC multicalls = 4.1.8 = *Release Date - 6 January 2021* * Fixed missing fields in submit-spam and submit-ham calls that could lead to reduced accuracy. * Fixed usage of deprecated jQuery function. = 4.1.7 = *Release Date - 22 October 2020* * Show the "Set up your Akismet account" banner on the comments admin screen, where it's relevant to mention if Akismet hasn't been configured. * Don't use wp_blacklist_check when the new wp_check_comment_disallowed_list function is available. = 4.1.6 = *Release Date - 4 June 2020* * Disable "Check for Spam" button until the page is loaded to avoid errors with clicking through to queue recheck endpoint directly. * Add filter "akismet_enable_mshots" to allow disabling screenshot popups on the edit comments admin page. For older changelog entries, please see the [additional changelog.txt file](https://plugins.svn.wordpress.org/akismet/trunk/changelog.txt) delivered with the plugin. wrapper.php 0000644 00000014446 15222563563 0006757 0 ustar 00 <?php global $wpcom_api_key, $akismet_api_host, $akismet_api_port; $wpcom_api_key = defined( 'WPCOM_API_KEY' ) ? constant( 'WPCOM_API_KEY' ) : ''; $akismet_api_host = Akismet::get_api_key() . '.rest.akismet.com'; $akismet_api_port = 80; function akismet_test_mode() { return Akismet::is_test_mode(); } function akismet_http_post( $request, $host, $path, $port = 80, $ip = null ) { $path = str_replace( '/1.1/', '', $path ); return Akismet::http_post( $request, $path, $ip ); } function akismet_microtime() { return Akismet::_get_microtime(); } function akismet_delete_old() { return Akismet::delete_old_comments(); } function akismet_delete_old_metadata() { return Akismet::delete_old_comments_meta(); } function akismet_check_db_comment( $id, $recheck_reason = 'recheck_queue' ) { return Akismet::check_db_comment( $id, $recheck_reason ); } function akismet_rightnow() { if ( !class_exists( 'Akismet_Admin' ) ) return false; return Akismet_Admin::rightnow_stats(); } function akismet_admin_init() { _deprecated_function( __FUNCTION__, '3.0' ); } function akismet_version_warning() { _deprecated_function( __FUNCTION__, '3.0' ); } function akismet_load_js_and_css() { _deprecated_function( __FUNCTION__, '3.0' ); } function akismet_nonce_field( $action = -1 ) { return wp_nonce_field( $action ); } function akismet_plugin_action_links( $links, $file ) { return Akismet_Admin::plugin_action_links( $links, $file ); } function akismet_conf() { _deprecated_function( __FUNCTION__, '3.0' ); } function akismet_stats_display() { _deprecated_function( __FUNCTION__, '3.0' ); } function akismet_stats() { return Akismet_Admin::dashboard_stats(); } function akismet_admin_warnings() { _deprecated_function( __FUNCTION__, '3.0' ); } function akismet_comment_row_action( $a, $comment ) { return Akismet_Admin::comment_row_actions( $a, $comment ); } function akismet_comment_status_meta_box( $comment ) { return Akismet_Admin::comment_status_meta_box( $comment ); } function akismet_comments_columns( $columns ) { _deprecated_function( __FUNCTION__, '3.0' ); return $columns; } function akismet_comment_column_row( $column, $comment_id ) { _deprecated_function( __FUNCTION__, '3.0' ); } function akismet_text_add_link_callback( $m ) { return Akismet_Admin::text_add_link_callback( $m ); } function akismet_text_add_link_class( $comment_text ) { return Akismet_Admin::text_add_link_class( $comment_text ); } function akismet_check_for_spam_button( $comment_status ) { return Akismet_Admin::check_for_spam_button( $comment_status ); } function akismet_submit_nonspam_comment( $comment_id ) { return Akismet::submit_nonspam_comment( $comment_id ); } function akismet_submit_spam_comment( $comment_id ) { return Akismet::submit_spam_comment( $comment_id ); } function akismet_transition_comment_status( $new_status, $old_status, $comment ) { return Akismet::transition_comment_status( $new_status, $old_status, $comment ); } function akismet_spam_count( $type = false ) { return Akismet_Admin::get_spam_count( $type ); } function akismet_recheck_queue() { return Akismet_Admin::recheck_queue(); } function akismet_remove_comment_author_url() { return Akismet_Admin::remove_comment_author_url(); } function akismet_add_comment_author_url() { return Akismet_Admin::add_comment_author_url(); } function akismet_check_server_connectivity() { return Akismet_Admin::check_server_connectivity(); } function akismet_get_server_connectivity( $cache_timeout = 86400 ) { return Akismet_Admin::get_server_connectivity( $cache_timeout ); } function akismet_server_connectivity_ok() { _deprecated_function( __FUNCTION__, '3.0' ); return true; } function akismet_admin_menu() { return Akismet_Admin::admin_menu(); } function akismet_load_menu() { return Akismet_Admin::load_menu(); } function akismet_init() { _deprecated_function( __FUNCTION__, '3.0' ); } function akismet_get_key() { return Akismet::get_api_key(); } function akismet_check_key_status( $key, $ip = null ) { return Akismet::check_key_status( $key, $ip ); } function akismet_update_alert( $response ) { return Akismet::update_alert( $response ); } function akismet_verify_key( $key, $ip = null ) { return Akismet::verify_key( $key, $ip ); } function akismet_get_user_roles( $user_id ) { return Akismet::get_user_roles( $user_id ); } function akismet_result_spam( $approved ) { return Akismet::comment_is_spam( $approved ); } function akismet_result_hold( $approved ) { return Akismet::comment_needs_moderation( $approved ); } function akismet_get_user_comments_approved( $user_id, $comment_author_email, $comment_author, $comment_author_url ) { return Akismet::get_user_comments_approved( $user_id, $comment_author_email, $comment_author, $comment_author_url ); } function akismet_update_comment_history( $comment_id, $message, $event = null ) { return Akismet::update_comment_history( $comment_id, $message, $event ); } function akismet_get_comment_history( $comment_id ) { return Akismet::get_comment_history( $comment_id ); } function akismet_cmp_time( $a, $b ) { return Akismet::_cmp_time( $a, $b ); } function akismet_auto_check_update_meta( $id, $comment ) { return Akismet::auto_check_update_meta( $id, $comment ); } function akismet_auto_check_comment( $commentdata ) { return Akismet::auto_check_comment( $commentdata ); } function akismet_get_ip_address() { return Akismet::get_ip_address(); } function akismet_cron_recheck() { return Akismet::cron_recheck(); } function akismet_add_comment_nonce( $post_id ) { return Akismet::add_comment_nonce( $post_id ); } function akismet_fix_scheduled_recheck() { return Akismet::fix_scheduled_recheck(); } function akismet_spam_comments() { _deprecated_function( __FUNCTION__, '3.0' ); return array(); } function akismet_spam_totals() { _deprecated_function( __FUNCTION__, '3.0' ); return array(); } function akismet_manage_page() { _deprecated_function( __FUNCTION__, '3.0' ); } function akismet_caught() { _deprecated_function( __FUNCTION__, '3.0' ); } function redirect_old_akismet_urls() { _deprecated_function( __FUNCTION__, '3.0' ); } function akismet_kill_proxy_check( $option ) { _deprecated_function( __FUNCTION__, '3.0' ); return 0; } function akismet_pingback_forwarded_for( $r, $url ) { // This functionality is now in core. return false; } function akismet_pre_check_pingback( $method ) { return Akismet::pre_check_pingback( $method ); } class.akismet-rest-api.php 0000644 00000025577 15222563563 0011571 0 ustar 00 <?php class Akismet_REST_API { /** * Register the REST API routes. */ public static function init() { if ( ! function_exists( 'register_rest_route' ) ) { // The REST API wasn't integrated into core until 4.4, and we support 4.0+ (for now). return false; } register_rest_route( 'akismet/v1', '/key', array( array( 'methods' => WP_REST_Server::READABLE, 'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ), 'callback' => array( 'Akismet_REST_API', 'get_key' ), ), array( 'methods' => WP_REST_Server::EDITABLE, 'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ), 'callback' => array( 'Akismet_REST_API', 'set_key' ), 'args' => array( 'key' => array( 'required' => true, 'type' => 'string', 'sanitize_callback' => array( 'Akismet_REST_API', 'sanitize_key' ), 'description' => __( 'A 12-character Akismet API key. Available at akismet.com/get/', 'akismet' ), ), ), ), array( 'methods' => WP_REST_Server::DELETABLE, 'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ), 'callback' => array( 'Akismet_REST_API', 'delete_key' ), ) ) ); register_rest_route( 'akismet/v1', '/settings/', array( array( 'methods' => WP_REST_Server::READABLE, 'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ), 'callback' => array( 'Akismet_REST_API', 'get_settings' ), ), array( 'methods' => WP_REST_Server::EDITABLE, 'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ), 'callback' => array( 'Akismet_REST_API', 'set_boolean_settings' ), 'args' => array( 'akismet_strictness' => array( 'required' => false, 'type' => 'boolean', 'description' => __( 'If true, Akismet will automatically discard the worst spam automatically rather than putting it in the spam folder.', 'akismet' ), ), 'akismet_show_user_comments_approved' => array( 'required' => false, 'type' => 'boolean', 'description' => __( 'If true, show the number of approved comments beside each comment author in the comments list page.', 'akismet' ), ), ), ) ) ); register_rest_route( 'akismet/v1', '/stats', array( 'methods' => WP_REST_Server::READABLE, 'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ), 'callback' => array( 'Akismet_REST_API', 'get_stats' ), 'args' => array( 'interval' => array( 'required' => false, 'type' => 'string', 'sanitize_callback' => array( 'Akismet_REST_API', 'sanitize_interval' ), 'description' => __( 'The time period for which to retrieve stats. Options: 60-days, 6-months, all', 'akismet' ), 'default' => 'all', ), ), ) ); register_rest_route( 'akismet/v1', '/stats/(?P<interval>[\w+])', array( 'args' => array( 'interval' => array( 'description' => __( 'The time period for which to retrieve stats. Options: 60-days, 6-months, all', 'akismet' ), 'type' => 'string', ), ), array( 'methods' => WP_REST_Server::READABLE, 'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ), 'callback' => array( 'Akismet_REST_API', 'get_stats' ), ) ) ); register_rest_route( 'akismet/v1', '/alert', array( array( 'methods' => WP_REST_Server::READABLE, 'permission_callback' => array( 'Akismet_REST_API', 'remote_call_permission_callback' ), 'callback' => array( 'Akismet_REST_API', 'get_alert' ), 'args' => array( 'key' => array( 'required' => false, 'type' => 'string', 'sanitize_callback' => array( 'Akismet_REST_API', 'sanitize_key' ), 'description' => __( 'A 12-character Akismet API key. Available at akismet.com/get/', 'akismet' ), ), ), ), array( 'methods' => WP_REST_Server::EDITABLE, 'permission_callback' => array( 'Akismet_REST_API', 'remote_call_permission_callback' ), 'callback' => array( 'Akismet_REST_API', 'set_alert' ), 'args' => array( 'key' => array( 'required' => false, 'type' => 'string', 'sanitize_callback' => array( 'Akismet_REST_API', 'sanitize_key' ), 'description' => __( 'A 12-character Akismet API key. Available at akismet.com/get/', 'akismet' ), ), ), ), array( 'methods' => WP_REST_Server::DELETABLE, 'permission_callback' => array( 'Akismet_REST_API', 'remote_call_permission_callback' ), 'callback' => array( 'Akismet_REST_API', 'delete_alert' ), 'args' => array( 'key' => array( 'required' => false, 'type' => 'string', 'sanitize_callback' => array( 'Akismet_REST_API', 'sanitize_key' ), 'description' => __( 'A 12-character Akismet API key. Available at akismet.com/get/', 'akismet' ), ), ), ) ) ); } /** * Get the current Akismet API key. * * @param WP_REST_Request $request * @return WP_Error|WP_REST_Response */ public static function get_key( $request = null ) { return rest_ensure_response( Akismet::get_api_key() ); } /** * Set the API key, if possible. * * @param WP_REST_Request $request * @return WP_Error|WP_REST_Response */ public static function set_key( $request ) { if ( defined( 'WPCOM_API_KEY' ) ) { return rest_ensure_response( new WP_Error( 'hardcoded_key', __( 'This site\'s API key is hardcoded and cannot be changed via the API.', 'akismet' ), array( 'status'=> 409 ) ) ); } $new_api_key = $request->get_param( 'key' ); if ( ! self::key_is_valid( $new_api_key ) ) { return rest_ensure_response( new WP_Error( 'invalid_key', __( 'The value provided is not a valid and registered API key.', 'akismet' ), array( 'status' => 400 ) ) ); } update_option( 'wordpress_api_key', $new_api_key ); return self::get_key(); } /** * Unset the API key, if possible. * * @param WP_REST_Request $request * @return WP_Error|WP_REST_Response */ public static function delete_key( $request ) { if ( defined( 'WPCOM_API_KEY' ) ) { return rest_ensure_response( new WP_Error( 'hardcoded_key', __( 'This site\'s API key is hardcoded and cannot be deleted.', 'akismet' ), array( 'status'=> 409 ) ) ); } delete_option( 'wordpress_api_key' ); return rest_ensure_response( true ); } /** * Get the Akismet settings. * * @param WP_REST_Request $request * @return WP_Error|WP_REST_Response */ public static function get_settings( $request = null ) { return rest_ensure_response( array( 'akismet_strictness' => ( get_option( 'akismet_strictness', '1' ) === '1' ), 'akismet_show_user_comments_approved' => ( get_option( 'akismet_show_user_comments_approved', '1' ) === '1' ), ) ); } /** * Update the Akismet settings. * * @param WP_REST_Request $request * @return WP_Error|WP_REST_Response */ public static function set_boolean_settings( $request ) { foreach ( array( 'akismet_strictness', 'akismet_show_user_comments_approved', ) as $setting_key ) { $setting_value = $request->get_param( $setting_key ); if ( is_null( $setting_value ) ) { // This setting was not specified. continue; } // From 4.7+, WP core will ensure that these are always boolean // values because they are registered with 'type' => 'boolean', // but we need to do this ourselves for prior versions. $setting_value = Akismet_REST_API::parse_boolean( $setting_value ); update_option( $setting_key, $setting_value ? '1' : '0' ); } return self::get_settings(); } /** * Parse a numeric or string boolean value into a boolean. * * @param mixed $value The value to convert into a boolean. * @return bool The converted value. */ public static function parse_boolean( $value ) { switch ( $value ) { case true: case 'true': case '1': case 1: return true; case false: case 'false': case '0': case 0: return false; default: return (bool) $value; } } /** * Get the Akismet stats for a given time period. * * Possible `interval` values: * - all * - 60-days * - 6-months * * @param WP_REST_Request $request * @return WP_Error|WP_REST_Response */ public static function get_stats( $request ) { $api_key = Akismet::get_api_key(); $interval = $request->get_param( 'interval' ); $stat_totals = array(); $response = Akismet::http_post( Akismet::build_query( array( 'blog' => get_option( 'home' ), 'key' => $api_key, 'from' => $interval ) ), 'get-stats' ); if ( ! empty( $response[1] ) ) { $stat_totals[$interval] = json_decode( $response[1] ); } return rest_ensure_response( $stat_totals ); } /** * Get the current alert code and message. Alert codes are used to notify the site owner * if there's a problem, like a connection issue between their site and the Akismet API, * invalid requests being sent, etc. * * @param WP_REST_Request $request * @return WP_Error|WP_REST_Response */ public static function get_alert( $request ) { return rest_ensure_response( array( 'code' => get_option( 'akismet_alert_code' ), 'message' => get_option( 'akismet_alert_msg' ), ) ); } /** * Update the current alert code and message by triggering a call to the Akismet server. * * @param WP_REST_Request $request * @return WP_Error|WP_REST_Response */ public static function set_alert( $request ) { delete_option( 'akismet_alert_code' ); delete_option( 'akismet_alert_msg' ); // Make a request so the most recent alert code and message are retrieved. Akismet::verify_key( Akismet::get_api_key() ); return self::get_alert( $request ); } /** * Clear the current alert code and message. * * @param WP_REST_Request $request * @return WP_Error|WP_REST_Response */ public static function delete_alert( $request ) { delete_option( 'akismet_alert_code' ); delete_option( 'akismet_alert_msg' ); return self::get_alert( $request ); } private static function key_is_valid( $key ) { $response = Akismet::http_post( Akismet::build_query( array( 'key' => $key, 'blog' => get_option( 'home' ) ) ), 'verify-key' ); if ( $response[1] == 'valid' ) { return true; } return false; } public static function privileged_permission_callback() { return current_user_can( 'manage_options' ); } /** * For calls that Akismet.com makes to the site to clear outdated alert codes, use the API key for authorization. */ public static function remote_call_permission_callback( $request ) { $local_key = Akismet::get_api_key(); return $local_key && ( strtolower( $request->get_param( 'key' ) ) === strtolower( $local_key ) ); } public static function sanitize_interval( $interval, $request, $param ) { $interval = trim( $interval ); $valid_intervals = array( '60-days', '6-months', 'all', ); if ( ! in_array( $interval, $valid_intervals ) ) { $interval = 'all'; } return $interval; } public static function sanitize_key( $key, $request, $param ) { return trim( $key ); } } _inc/form.js 0000644 00000001274 15222563563 0006772 0 ustar 00 var ak_js = document.getElementById( "ak_js" ); if ( ! ak_js ) { ak_js = document.createElement( 'input' ); ak_js.setAttribute( 'id', 'ak_js' ); ak_js.setAttribute( 'name', 'ak_js' ); ak_js.setAttribute( 'type', 'hidden' ); } else { ak_js.parentNode.removeChild( ak_js ); } ak_js.setAttribute( 'value', ( new Date() ).getTime() ); var commentForm = document.getElementById( 'commentform' ); if ( commentForm ) { commentForm.appendChild( ak_js ); } else { var replyRowContainer = document.getElementById( 'replyrow' ); if ( replyRowContainer ) { var children = replyRowContainer.getElementsByTagName( 'td' ); if ( children.length > 0 ) { children[0].appendChild( ak_js ); } } } _inc/akismet.js 0000644 00000031706 15222563563 0007467 0 ustar 00 jQuery( function ( $ ) { var mshotRemovalTimer = null; var mshotRetryTimer = null; var mshotTries = 0; var mshotRetryInterval = 1000; var mshotEnabledLinkSelector = 'a[id^="author_comment_url"], tr.pingback td.column-author a:first-of-type, td.comment p a'; var preloadedMshotURLs = []; $('.akismet-status').each(function () { var thisId = $(this).attr('commentid'); $(this).prependTo('#comment-' + thisId + ' .column-comment'); }); $('.akismet-user-comment-count').each(function () { var thisId = $(this).attr('commentid'); $(this).insertAfter('#comment-' + thisId + ' .author strong:first').show(); }); akismet_enable_comment_author_url_removal(); $( '#the-comment-list' ).on( 'click', '.akismet_remove_url', function () { var thisId = $(this).attr('commentid'); var data = { action: 'comment_author_deurl', _wpnonce: WPAkismet.comment_author_url_nonce, id: thisId }; $.ajax({ url: ajaxurl, type: 'POST', data: data, beforeSend: function () { // Removes "x" link $("a[commentid='"+ thisId +"']").hide(); // Show temp status $("#author_comment_url_"+ thisId).html( $( '<span/>' ).text( WPAkismet.strings['Removing...'] ) ); }, success: function (response) { if (response) { // Show status/undo link $("#author_comment_url_"+ thisId) .attr('cid', thisId) .addClass('akismet_undo_link_removal') .html( $( '<span/>' ).text( WPAkismet.strings['URL removed'] ) ) .append( ' ' ) .append( $( '<span/>' ) .text( WPAkismet.strings['(undo)'] ) .addClass( 'akismet-span-link' ) ); } } }); return false; }).on( 'click', '.akismet_undo_link_removal', function () { var thisId = $(this).attr('cid'); var thisUrl = $(this).attr('href'); var data = { action: 'comment_author_reurl', _wpnonce: WPAkismet.comment_author_url_nonce, id: thisId, url: thisUrl }; $.ajax({ url: ajaxurl, type: 'POST', data: data, beforeSend: function () { // Show temp status $("#author_comment_url_"+ thisId).html( $( '<span/>' ).text( WPAkismet.strings['Re-adding...'] ) ); }, success: function (response) { if (response) { // Add "x" link $("a[commentid='"+ thisId +"']").show(); // Show link. Core strips leading http://, so let's do that too. $("#author_comment_url_"+ thisId).removeClass('akismet_undo_link_removal').text( thisUrl.replace( /^http:\/\/(www\.)?/ig, '' ) ); } } }); return false; }); // Show a preview image of the hovered URL. Applies to author URLs and URLs inside the comments. if ( "enable_mshots" in WPAkismet && WPAkismet.enable_mshots ) { $( '#the-comment-list' ).on( 'mouseover', mshotEnabledLinkSelector, function () { clearTimeout( mshotRemovalTimer ); if ( $( '.akismet-mshot' ).length > 0 ) { if ( $( '.akismet-mshot:first' ).data( 'link' ) == this ) { // The preview is already showing for this link. return; } else { // A new link is being hovered, so remove the old preview. $( '.akismet-mshot' ).remove(); } } clearTimeout( mshotRetryTimer ); var linkUrl = $( this ).attr( 'href' ); if ( preloadedMshotURLs.indexOf( linkUrl ) !== -1 ) { // This preview image was already preloaded, so begin with a retry URL so the user doesn't see the placeholder image for the first second. mshotTries = 2; } else { mshotTries = 1; } var mShot = $( '<div class="akismet-mshot mshot-container"><div class="mshot-arrow"></div><img src="' + akismet_mshot_url( linkUrl, mshotTries ) + '" width="450" height="338" class="mshot-image" /></div>' ); mShot.data( 'link', this ); mShot.data( 'url', linkUrl ); mShot.find( 'img' ).on( 'load', function () { $( '.akismet-mshot' ).data( 'pending-request', false ); } ); var offset = $( this ).offset(); mShot.offset( { left : Math.min( $( window ).width() - 475, offset.left + $( this ).width() + 10 ), // Keep it on the screen if the link is near the edge of the window. top: offset.top + ( $( this ).height() / 2 ) - 101 // 101 = top offset of the arrow plus the top border thickness } ); $( 'body' ).append( mShot ); mshotRetryTimer = setTimeout( retryMshotUntilLoaded, mshotRetryInterval ); } ).on( 'mouseout', 'a[id^="author_comment_url"], tr.pingback td.column-author a:first-of-type, td.comment p a', function () { mshotRemovalTimer = setTimeout( function () { clearTimeout( mshotRetryTimer ); $( '.akismet-mshot' ).remove(); }, 200 ); } ); var preloadDelayTimer = null; $( window ).on( 'scroll resize', function () { clearTimeout( preloadDelayTimer ); preloadDelayTimer = setTimeout( preloadMshotsInViewport, 500 ); } ); preloadMshotsInViewport(); } /** * The way mShots works is if there was no screenshot already recently generated for the URL, * it returns a "loading..." image for the first request. Then, some subsequent request will * receive the actual screenshot, but it's unknown how long it will take. So, what we do here * is continually re-request the mShot, waiting a second after every response until we get the * actual screenshot. */ function retryMshotUntilLoaded() { clearTimeout( mshotRetryTimer ); var imageWidth = $( '.akismet-mshot img' ).get(0).naturalWidth; if ( imageWidth == 0 ) { // It hasn't finished loading yet the first time. Check again shortly. setTimeout( retryMshotUntilLoaded, mshotRetryInterval ); } else if ( imageWidth == 400 ) { // It loaded the preview image. if ( mshotTries == 20 ) { // Give up if we've requested the mShot 20 times already. return; } if ( ! $( '.akismet-mshot' ).data( 'pending-request' ) ) { $( '.akismet-mshot' ).data( 'pending-request', true ); mshotTries++; $( '.akismet-mshot .mshot-image' ).attr( 'src', akismet_mshot_url( $( '.akismet-mshot' ).data( 'url' ), mshotTries ) ); } mshotRetryTimer = setTimeout( retryMshotUntilLoaded, mshotRetryInterval ); } else { // All done. } } function preloadMshotsInViewport() { var windowWidth = $( window ).width(); var windowHeight = $( window ).height(); $( '#the-comment-list' ).find( mshotEnabledLinkSelector ).each( function ( index, element ) { var linkUrl = $( this ).attr( 'href' ); // Don't attempt to preload an mshot for a single link twice. if ( preloadedMshotURLs.indexOf( linkUrl ) !== -1 ) { // The URL is already preloaded. return true; } if ( typeof element.getBoundingClientRect !== 'function' ) { // The browser is too old. Return false to stop this preloading entirely. return false; } var rect = element.getBoundingClientRect(); if ( rect.top >= 0 && rect.left >= 0 && rect.bottom <= windowHeight && rect.right <= windowWidth ) { akismet_preload_mshot( linkUrl ); $( this ).data( 'akismet-mshot-preloaded', true ); } } ); } $( '.checkforspam.enable-on-load' ).on( 'click', function( e ) { if ( $( this ).hasClass( 'ajax-disabled' ) ) { // Akismet hasn't been configured yet. Allow the user to proceed to the button's link. return; } e.preventDefault(); if ( $( this ).hasClass( 'button-disabled' ) ) { window.location.href = $( this ).data( 'success-url' ).replace( '__recheck_count__', 0 ).replace( '__spam_count__', 0 ); return; } $('.checkforspam').addClass('button-disabled').addClass( 'checking' ); $('.checkforspam-spinner').addClass( 'spinner' ).addClass( 'is-active' ); akismet_check_for_spam(0, 100); }).removeClass( 'button-disabled' ); var spam_count = 0; var recheck_count = 0; function akismet_check_for_spam(offset, limit) { var check_for_spam_buttons = $( '.checkforspam' ); var nonce = check_for_spam_buttons.data( 'nonce' ); // We show the percentage complete down to one decimal point so even queues with 100k // pending comments will show some progress pretty quickly. var percentage_complete = Math.round( ( recheck_count / check_for_spam_buttons.data( 'pending-comment-count' ) ) * 1000 ) / 10; // Update the progress counter on the "Check for Spam" button. $( '.checkforspam' ).text( check_for_spam_buttons.data( 'progress-label' ).replace( '%1$s', percentage_complete ) ); $.post( ajaxurl, { 'action': 'akismet_recheck_queue', 'offset': offset, 'limit': limit, 'nonce': nonce }, function(result) { if ( 'error' in result ) { // An error is only returned in the case of a missing nonce, so we don't need the actual error message. window.location.href = check_for_spam_buttons.data( 'failure-url' ); return; } recheck_count += result.counts.processed; spam_count += result.counts.spam; if (result.counts.processed < limit) { window.location.href = check_for_spam_buttons.data( 'success-url' ).replace( '__recheck_count__', recheck_count ).replace( '__spam_count__', spam_count ); } else { // Account for comments that were caught as spam and moved out of the queue. akismet_check_for_spam(offset + limit - result.counts.spam, limit); } } ); } if ( "start_recheck" in WPAkismet && WPAkismet.start_recheck ) { $( '.checkforspam' ).click(); } if ( typeof MutationObserver !== 'undefined' ) { // Dynamically add the "X" next the the author URL links when a comment is quick-edited. var comment_list_container = document.getElementById( 'the-comment-list' ); if ( comment_list_container ) { var observer = new MutationObserver( function ( mutations ) { for ( var i = 0, _len = mutations.length; i < _len; i++ ) { if ( mutations[i].addedNodes.length > 0 ) { akismet_enable_comment_author_url_removal(); // Once we know that we'll have to check for new author links, skip the rest of the mutations. break; } } } ); observer.observe( comment_list_container, { attributes: true, childList: true, characterData: true } ); } } function akismet_enable_comment_author_url_removal() { $( '#the-comment-list' ) .find( 'tr.comment, tr[id ^= "comment-"]' ) .find( '.column-author a[href^="http"]:first' ) // Ignore mailto: links, which would be the comment author's email. .each(function () { if ( $( this ).parent().find( '.akismet_remove_url' ).length > 0 ) { return; } var linkHref = $(this).attr( 'href' ); // Ignore any links to the current domain, which are diagnostic tools, like the IP address link // or any other links another plugin might add. var currentHostParts = document.location.href.split( '/' ); var currentHost = currentHostParts[0] + '//' + currentHostParts[2] + '/'; if ( linkHref.indexOf( currentHost ) != 0 ) { var thisCommentId = $(this).parents('tr:first').attr('id').split("-"); $(this) .attr("id", "author_comment_url_"+ thisCommentId[1]) .after( $( '<a href="#" class="akismet_remove_url">x</a>' ) .attr( 'commentid', thisCommentId[1] ) .attr( 'title', WPAkismet.strings['Remove this URL'] ) ); } }); } /** * Generate an mShot URL if given a link URL. * * @param string linkUrl * @param int retry If retrying a request, the number of the retry. * @return string The mShot URL; */ function akismet_mshot_url( linkUrl, retry ) { var mshotUrl = '//s0.wp.com/mshots/v1/' + encodeURIComponent( linkUrl ) + '?w=900'; if ( retry > 1 ) { mshotUrl += '&r=' + encodeURIComponent( retry ); } mshotUrl += '&source=akismet'; return mshotUrl; } /** * Begin loading an mShot preview of a link. * * @param string linkUrl */ function akismet_preload_mshot( linkUrl ) { var img = new Image(); img.src = akismet_mshot_url( linkUrl ); preloadedMshotURLs.push( linkUrl ); } $( '.akismet-could-be-primary' ).each( function () { var form = $( this ).closest( 'form' ); form.data( 'initial-state', form.serialize() ); form.on( 'change keyup', function () { var self = $( this ); var submit_button = self.find( '.akismet-could-be-primary' ); if ( self.serialize() != self.data( 'initial-state' ) ) { submit_button.addClass( 'akismet-is-primary' ); } else { submit_button.removeClass( 'akismet-is-primary' ); } } ); } ); /** * Shows the Enter API key form */ $( '.akismet-enter-api-key-box a' ).on( 'click', function ( e ) { e.preventDefault(); var div = $( '.enter-api-key' ); div.show( 500 ); div.find( 'input[name=key]' ).focus(); $( this ).hide(); } ); /** * Hides the Connect with Jetpack form | Shows the Activate Akismet Account form */ $( 'a.toggle-ak-connect' ).on( 'click', function ( e ) { e.preventDefault(); $( '.akismet-ak-connect' ).slideToggle('slow'); $( 'a.toggle-ak-connect' ).hide(); $( '.akismet-jp-connect' ).hide(); $( 'a.toggle-jp-connect' ).show(); } ); /** * Shows the Connect with Jetpack form | Hides the Activate Akismet Account form */ $( 'a.toggle-jp-connect' ).on( 'click', function ( e ) { e.preventDefault(); $( '.akismet-jp-connect' ).slideToggle('slow'); $( 'a.toggle-jp-connect' ).hide(); $( '.akismet-ak-connect' ).hide(); $( 'a.toggle-ak-connect' ).show(); } ); }); _inc/akismet.css 0000644 00000030437 15222563563 0007643 0 ustar 00 .wp-admin.jetpack_page_akismet-key-config, .wp-admin.settings_page_akismet-key-config { background-color:#f3f6f8; } #submitted-on { position: relative; } #the-comment-list .author .akismet-user-comment-count { display: inline; } #the-comment-list .author a span { text-decoration: none; color: #999; } #the-comment-list .author a span.akismet-span-link { text-decoration: inherit; color: inherit; } #the-comment-list .akismet_remove_url { margin-left: 3px; color: #999; padding: 2px 3px 2px 0; } #the-comment-list .akismet_remove_url:hover { color: #A7301F; font-weight: bold; padding: 2px 2px 2px 0; } #dashboard_recent_comments .akismet-status { display: none; } .akismet-status { float: right; } .akismet-status a { color: #AAA; font-style: italic; } table.comments td.comment p a { text-decoration: underline; } table.comments td.comment p a:after { content: attr(href); color: #aaa; display: inline-block; /* Show the URL without the link's underline extending under it. */ padding: 0 1ex; /* Because it's inline block, we can't just use spaces in the content: attribute to separate it from the link text. */ } .mshot-arrow { width: 0; height: 0; border-top: 10px solid transparent; border-bottom: 10px solid transparent; border-right: 10px solid #5C5C5C; position: absolute; left: -6px; top: 91px; } .mshot-container { background: #5C5C5C; position: absolute; top: -94px; padding: 7px; width: 450px; height: 338px; z-index: 20000; -moz-border-radius: 6px; border-radius: 6px; -webkit-border-radius: 6px; } .akismet-mshot { position: absolute; z-index: 100; } .akismet-mshot .mshot-image { margin: 0; height: 338px; width: 450px; } .checkforspam { display: inline-block !important; } .checkforspam-spinner { display: inline-block; margin-top: 7px; } .akismet-right { float: right; } .akismet-card .akismet-right { margin: 1em 0; } .akismet-alert-text { color: #dd3d36; font-weight: bold; font-size: 120%; margin-top: .5rem; } .akismet-alert { border: 1px solid #e5e5e5; padding: 0.4em 1em 1.4em 1em; border-radius: 3px; -webkit-border-radius: 3px; border-width: 1px; border-style: solid; } .akismet-alert h3.akismet-key-status { color: #fff; margin: 1em 0 0.5em 0; } .akismet-alert.akismet-critical { background-color: #993300; } .akismet-alert.akismet-active { background-color: #649316; } .akismet-alert p.akismet-key-status { font-size: 24px; } .akismet-alert p.akismet-description { color:#fff; font-size: 14px; margin: 0 0; font-style: normal; } .akismet-alert p.akismet-description a, .akismet-alert p.akismet-description a, .akismet-alert p.akismet-description a, .akismet-alert p.akismet-description a { color: #fff; } .akismet-new-snapshot { margin-top: 1em; padding: 1em; text-align: center; background: #fff; } .akismet-new-snapshot h3 { background: #f5f5f5; color: #888; font-size: 11px; margin: 0; padding: 3px; } .new-snapspot ul { font-size: 12px; width: 100%; } .akismet-new-snapshot ul li { color: #999; float: left; font-size: 11px; padding: 0 20px; text-transform: uppercase; width: 33%; box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; -ms-box-sizing: border-box; } .akismet-new-snapshot ul li:first-child, .akismet-new-snapshot ul li:nth-child(2) { border-right:1px dotted #ccc; } .akismet-new-snapshot ul li span { color: #52accc; display: block; font-size: 32px; font-weight: lighter; line-height: 1.5em; } .akismet-settings th:first-child { vertical-align: top; padding-top: 15px; } .akismet-settings th.akismet-api-key { vertical-align: middle; padding-top: 0; } .akismet-settings input[type=text] { width: 75%; } .akismet-settings span.akismet-note{ float: left; padding-left: 23px; font-size: 75%; margin-top: -10px; } /** * For the activation notice on the plugins page. */ #akismet_setup_prompt { background: none; border: none; margin: 0; padding: 0; width: 100%; } .akismet_activate { border: 1px solid #4F800D; padding: 5px; margin: 15px 0; background: #83AF24; background-image: -webkit-gradient(linear, 0% 0, 80% 100%, from(#83AF24), to(#4F800D)); background-image: -moz-linear-gradient(80% 100% 120deg, #4F800D, #83AF24); -moz-border-radius: 3px; border-radius: 3px; -webkit-border-radius: 3px; position: relative; overflow: hidden; } .akismet_activate .aa_a { position: absolute; top: -5px; right: 10px; font-size: 140px; color: #769F33; font-family: Georgia, "Times New Roman", Times, serif; } .akismet_activate .aa_button { font-weight: bold; border: 1px solid #029DD6; border-top: 1px solid #06B9FD; font-size: 15px; text-align: center; padding: 9px 0 8px 0; color: #FFF; background: #029DD6; background-image: -webkit-gradient(linear, 0% 0, 0% 100%, from(#029DD6), to(#0079B1)); background-image: -moz-linear-gradient(0% 100% 90deg, #0079B1, #029DD6); -moz-border-radius: 2px; border-radius: 2px; -webkit-border-radius: 2px; width: 100%; cursor: pointer; margin: 0; } .akismet_activate .aa_button:hover { text-decoration: none !important; border: 1px solid #029DD6; border-bottom: 1px solid #00A8EF; font-size: 15px; text-align: center; padding: 9px 0 8px 0; color: #F0F8FB; background: #0079B1; background-image: -webkit-gradient(linear, 0% 0, 0% 100%, from(#0079B1), to(#0092BF)); background-image: -moz-linear-gradient(0% 100% 90deg, #0092BF, #0079B1); -moz-border-radius: 2px; border-radius: 2px; -webkit-border-radius: 2px; } .akismet_activate .aa_button_border { border: 1px solid #006699; -moz-border-radius: 2px; border-radius: 2px; -webkit-border-radius: 2px; background: #029DD6; background-image: -webkit-gradient(linear, 0% 0, 0% 100%, from(#029DD6), to(#0079B1)); background-image: -moz-linear-gradient(0% 100% 90deg, #0079B1, #029DD6); } .akismet_activate .aa_button_container { box-sizing: border-box; display: inline-block; background: #DEF1B8; padding: 5px; -moz-border-radius: 2px; border-radius: 2px; -webkit-border-radius: 2px; width: 266px; } .akismet_activate .aa_description { position: absolute; top: 22px; left: 285px; margin-left: 25px; color: #E5F2B1; font-size: 15px; } .akismet_activate .aa_description strong { color: #FFF; font-weight: normal; } @media (max-width: 550px) { .akismet_activate .aa_a { display: none; } .akismet_activate .aa_button_container { width: 100%; } } @media (max-width: 782px) { .akismet_activate { min-width: 0; } } @media (max-width: 850px) { #akismet_setup_prompt .aa_description { display: none; } .akismet_activate { min-width: 0; } } .jetpack_page_akismet-key-config #wpcontent, .settings_page_akismet-key-config #wpcontent { padding-left: 0; } .akismet-masthead { background-color:#fff; text-align:center; box-shadow:0 1px 0 rgba(200,215,225,0.5),0 1px 2px #e9eff3 } @media (max-width: 45rem) { .akismet-masthead { padding:0 1.25rem } } .akismet-masthead__inside-container { padding:.375rem 0; margin:0 auto; width:100%; max-width:45rem; text-align: left; } .akismet-masthead__logo-container { padding:.3125rem 0 0 } .akismet-masthead__logo { width:10.375rem; height:1.8125rem; } .akismet-masthead__logo-link { display:inline-block; outline:none; vertical-align:middle } .akismet-masthead__logo-link:focus { line-height:0; box-shadow:0 0 0 2px #78dcfa } .akismet-masthead__logo-link+code { margin:0 10px; padding:5px 9px; border-radius:2px; background:#e6ecf1; color:#647a88 } .akismet-masthead__links { display:-ms-flexbox; display:flex; -ms-flex-flow:row wrap; flex-flow:row wrap; -ms-flex:2 50%; flex:2 50%; -ms-flex-pack:end; justify-content:flex-end; margin:0 } @media (max-width: 480px) { .akismet-masthead__links { padding-right:.625rem } } .akismet-masthead__link-li { margin:0; padding:0 } .akismet-masthead__link { font-style:normal; color:#0087be; padding:.625rem; display:inline-block } .akismet-masthead__link:visited { color:#0087be } .akismet-masthead__link:active,.akismet-masthead__link:hover { color:#00aadc } .akismet-masthead__link:hover { text-decoration:underline } .akismet-masthead__link .dashicons { display:none } @media (max-width: 480px) { .akismet-masthead__link:hover,.akismet-masthead__link:active { text-decoration:none } .akismet-masthead__link .dashicons { display:block; font-size:1.75rem } .akismet-masthead__link span+span { display:none } } .akismet-masthead__link-li:last-of-type .akismet-masthead__link { padding-right:0 } .akismet-lower { margin: 0 auto; text-align: left; max-width: 45rem; padding: 1.5rem; } .akismet-lower .notice { margin-bottom: 2rem; } .akismet-card { margin-top: 1rem; margin-bottom: 0; position: relative; margin: 0 auto 0.625rem auto; box-sizing: border-box; background: white; box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3; } .akismet-card:after, .akismet-card .inside:after, .akismet-masthead__logo-container:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } .akismet-card .inside { padding: 1.5rem; padding-top: 1rem; } .akismet-card .akismet-card-actions { margin-top: 1rem; } .jetpack_page_akismet-key-config .update-nag, .settings_page_akismet-key-config .update-nag { display: none; } .akismet-masthead .akismet-right { line-height: 2.125rem; font-size: 0.9rem; } .akismet-box { box-sizing: border-box; background: white; border: 1px solid rgba(200, 215, 225, 0.5); } .akismet-box h2, .akismet-box h3 { padding: 1.5rem 1.5rem .5rem 1.5rem; margin: 0; } .akismet-box p { padding: 0 1.5rem 1.5rem 1.5rem; margin: 0; } .akismet-jetpack-email { font-style: oblique; } .akismet-jetpack-gravatar { padding: 0 0 0 1.5rem; float: left; margin-right: 1rem; width: 54px; height: 54px; } .akismet-box p:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } .akismet-box .akismet-right { padding-right: 1.5rem; } .akismet-boxes .akismet-box { margin-bottom: 0; padding: 0; margin-top: -1px; } .akismet-boxes .akismet-box:last-child { margin-bottom: 1.5rem; } .akismet-boxes .akismet-box:first-child { margin-top: 1.5rem; } .akismet-box-header { max-width: 700px; margin: 0 auto 40px auto; line-height: 1.5; } .akismet-box-header h2 { margin: 1.5rem 10% 0; font-size: 1.375rem; font-weight: 700; color: #000; } .akismet-box .centered { text-align: center; } .akismet-enter-api-key-box { margin: 1.5rem 0; } .akismet-box .enter-api-key { display: none; margin-top: 1.5rem; } .akismet-box .akismet-toggles { margin: 3rem 0; } .akismet-box .akismet-ak-connect, .akismet-box .toggle-jp-connect { display: none; } .akismet-box .enter-api-key p { padding: 0 1.5rem; } .akismet-button, .akismet-button:hover, .akismet-button:visited { background: white; border-color: #c8d7e1; border-style: solid; border-width: 1px 1px 2px; color: #2e4453; cursor: pointer; display: inline-block; margin: 0; outline: 0; overflow: hidden; font-size: 14px; font-weight: 500; text-overflow: ellipsis; text-decoration: none; vertical-align: top; box-sizing: border-box; font-size: 14px; line-height: 21px; border-radius: 4px; padding: 7px 14px 9px; -webkit-appearance: none; -moz-appearance: none; appearance: none; } .akismet-button:hover { border-color: #a8bece; } .akismet-button:active { border-width: 2px 1px 1px; } .akismet-is-primary, .akismet-is-primary:hover, .akismet-is-primary:visited { background: #00aadc; border-color: #0087be; color: white; } .akismet-is-primary:hover, .akismet-is-primary:focus { border-color: #005082; } .akismet-is-primary:hover { border-color: #005082; } .akismet-section-header { position: relative; margin: 0 auto 0.625rem auto; padding: 1rem; box-sizing: border-box; box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3; background: #ffffff; width: 100%; padding-top: 0.6875rem; padding-bottom: 0.6875rem; display: flex; } .akismet-section-header__label { display: -ms-flexbox; display: flex; -ms-flex-align: center; align-items: center; -ms-flex-positive: 1; flex-grow: 1; line-height: 1.75rem; position: relative; font-size: 0.875rem; color: #4f748e; } .akismet-section-header__actions { line-height: 1.75rem; } .akismet-setup-instructions { text-align: center; } .akismet-setup-instructions form { padding-bottom: 1.5rem; } class.akismet-cli.php 0000644 00000011067 15222563563 0010601 0 ustar 00 <?php WP_CLI::add_command( 'akismet', 'Akismet_CLI' ); /** * Filter spam comments. */ class Akismet_CLI extends WP_CLI_Command { /** * Checks one or more comments against the Akismet API. * * ## OPTIONS * <comment_id>... * : The ID(s) of the comment(s) to check. * * [--noaction] * : Don't change the status of the comment. Just report what Akismet thinks it is. * * ## EXAMPLES * * wp akismet check 12345 * * @alias comment-check */ public function check( $args, $assoc_args ) { foreach ( $args as $comment_id ) { if ( isset( $assoc_args['noaction'] ) ) { // Check the comment, but don't reclassify it. $api_response = Akismet::check_db_comment( $comment_id, 'wp-cli' ); } else { $api_response = Akismet::recheck_comment( $comment_id, 'wp-cli' ); } if ( 'true' === $api_response ) { WP_CLI::line( sprintf( __( "Comment #%d is spam.", 'akismet' ), $comment_id ) ); } else if ( 'false' === $api_response ) { WP_CLI::line( sprintf( __( "Comment #%d is not spam.", 'akismet' ), $comment_id ) ); } else { if ( false === $api_response ) { WP_CLI::error( __( "Failed to connect to Akismet.", 'akismet' ) ); } else if ( is_wp_error( $api_response ) ) { WP_CLI::warning( sprintf( __( "Comment #%d could not be checked.", 'akismet' ), $comment_id ) ); } } } } /** * Recheck all comments in the Pending queue. * * ## EXAMPLES * * wp akismet recheck_queue * * @alias recheck-queue */ public function recheck_queue() { $batch_size = 100; $start = 0; $total_counts = array(); do { $result_counts = Akismet_Admin::recheck_queue_portion( $start, $batch_size ); if ( $result_counts['processed'] > 0 ) { foreach ( $result_counts as $key => $count ) { if ( ! isset( $total_counts[ $key ] ) ) { $total_counts[ $key ] = $count; } else { $total_counts[ $key ] += $count; } } $start += $batch_size; $start -= $result_counts['spam']; // These comments will have been removed from the queue. } } while ( $result_counts['processed'] > 0 ); WP_CLI::line( sprintf( _n( "Processed %d comment.", "Processed %d comments.", $total_counts['processed'], 'akismet' ), number_format( $total_counts['processed'] ) ) ); WP_CLI::line( sprintf( _n( "%d comment moved to Spam.", "%d comments moved to Spam.", $total_counts['spam'], 'akismet' ), number_format( $total_counts['spam'] ) ) ); if ( $total_counts['error'] ) { WP_CLI::line( sprintf( _n( "%d comment could not be checked.", "%d comments could not be checked.", $total_counts['error'], 'akismet' ), number_format( $total_counts['error'] ) ) ); } } /** * Fetches stats from the Akismet API. * * ## OPTIONS * * [<interval>] * : The time period for which to retrieve stats. * --- * default: all * options: * - days * - months * - all * --- * * [--format=<format>] * : Allows overriding the output of the command when listing connections. * --- * default: table * options: * - table * - json * - csv * - yaml * - count * --- * * [--summary] * : When set, will display a summary of the stats. * * ## EXAMPLES * * wp akismet stats * wp akismet stats all * wp akismet stats days * wp akismet stats months * wp akismet stats all --summary */ public function stats( $args, $assoc_args ) { $api_key = Akismet::get_api_key(); if ( empty( $api_key ) ) { WP_CLI::error( __( 'API key must be set to fetch stats.', 'akismet' ) ); } switch ( $args[0] ) { case 'days': $interval = '60-days'; break; case 'months': $interval = '6-months'; break; default: $interval = 'all'; break; } $response = Akismet::http_post( Akismet::build_query( array( 'blog' => get_option( 'home' ), 'key' => $api_key, 'from' => $interval, ) ), 'get-stats' ); if ( empty( $response[1] ) ) { WP_CLI::error( __( 'Currently unable to fetch stats. Please try again.', 'akismet' ) ); } $response_body = json_decode( $response[1], true ); if ( is_null( $response_body ) ) { WP_CLI::error( __( 'Stats response could not be decoded.', 'akismet' ) ); } if ( isset( $assoc_args['summary'] ) ) { $keys = array( 'spam', 'ham', 'missed_spam', 'false_positives', 'accuracy', 'time_saved', ); WP_CLI\Utils\format_items( $assoc_args['format'], array( $response_body ), $keys ); } else { $stats = $response_body['breakdown']; WP_CLI\Utils\format_items( $assoc_args['format'], $stats, array_keys( end( $stats ) ) ); } } } index.php 0000644 00000000032 15222563563 0006370 0 ustar 00 <?php # Silence is golden. views/config.php 0000644 00000027206 15222563563 0007677 0 ustar 00 <div id="akismet-plugin-container"> <div class="akismet-masthead"> <div class="akismet-masthead__inside-container"> <div class="akismet-masthead__logo-container"> <img class="akismet-masthead__logo" src="<?php echo esc_url( plugins_url( '../_inc/img/logo-full-2x.png', __FILE__ ) ); ?>" alt="Akismet" /> </div> </div> </div> <div class="akismet-lower"> <?php if ( Akismet::get_api_key() ) { ?> <?php Akismet_Admin::display_status(); ?> <?php } ?> <?php if ( ! empty( $notices ) ) { ?> <?php foreach ( $notices as $notice ) { ?> <?php Akismet::view( 'notice', $notice ); ?> <?php } ?> <?php } ?> <?php if ( $stat_totals && isset( $stat_totals['all'] ) && (int) $stat_totals['all']->spam > 0 ) : ?> <div class="akismet-card"> <div class="akismet-section-header"> <div class="akismet-section-header__label"> <span><?php esc_html_e( 'Statistics' , 'akismet'); ?></span> </div> <div class="akismet-section-header__actions"> <a href="<?php echo esc_url( Akismet_Admin::get_page_url( 'stats' ) ); ?>"> <?php esc_html_e( 'Detailed Stats' , 'akismet');?> </a> </div> </div> <div class="akismet-new-snapshot"> <iframe allowtransparency="true" scrolling="no" frameborder="0" style="width: 100%; height: 220px; overflow: hidden;" src="<?php printf( '//akismet.com/web/1.0/snapshot.php?blog=%s&api_key=%s&height=200&locale=%s', urlencode( get_option( 'home' ) ), Akismet::get_api_key(), get_locale() );?>"></iframe> <ul> <li> <h3><?php esc_html_e( 'Past six months' , 'akismet');?></h3> <span><?php echo number_format( $stat_totals['6-months']->spam );?></span> <?php echo esc_html( _n( 'Spam blocked', 'Spam blocked', $stat_totals['6-months']->spam, 'akismet' ) ); ?> </li> <li> <h3><?php esc_html_e( 'All time' , 'akismet');?></h3> <span><?php echo number_format( $stat_totals['all']->spam );?></span> <?php echo esc_html( _n( 'Spam blocked', 'Spam blocked', $stat_totals['all']->spam, 'akismet' ) ); ?> </li> <li> <h3><?php esc_html_e( 'Accuracy' , 'akismet');?></h3> <span><?php echo floatval( $stat_totals['all']->accuracy ); ?>%</span> <?php printf( _n( '%s missed spam', '%s missed spam', $stat_totals['all']->missed_spam, 'akismet' ), number_format( $stat_totals['all']->missed_spam ) ); ?> | <?php printf( _n( '%s false positive', '%s false positives', $stat_totals['all']->false_positives, 'akismet' ), number_format( $stat_totals['all']->false_positives ) ); ?> </li> </ul> </div> </div> <?php endif;?> <?php if ( $akismet_user ):?> <div class="akismet-card"> <div class="akismet-section-header"> <div class="akismet-section-header__label"> <span><?php esc_html_e( 'Settings' , 'akismet'); ?></span> </div> </div> <div class="inside"> <form action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="POST"> <table cellspacing="0" class="akismet-settings"> <tbody> <?php if ( ! Akismet::predefined_api_key() ) { ?> <tr> <th class="akismet-api-key" width="10%" align="left" scope="row"><?php esc_html_e('API Key', 'akismet');?></th> <td width="5%"/> <td align="left"> <span class="api-key"><input id="key" name="key" type="text" size="15" value="<?php echo esc_attr( get_option('wordpress_api_key') ); ?>" class="<?php echo esc_attr( 'regular-text code ' . $akismet_user->status ); ?>"></span> </td> </tr> <?php } ?> <?php if ( isset( $_GET['ssl_status'] ) ) { ?> <tr> <th align="left" scope="row"><?php esc_html_e( 'SSL Status', 'akismet' ); ?></th> <td></td> <td align="left"> <p> <?php if ( ! wp_http_supports( array( 'ssl' ) ) ) { ?><b><?php esc_html_e( 'Disabled.', 'akismet' ); ?></b> <?php esc_html_e( 'Your Web server cannot make SSL requests; contact your Web host and ask them to add support for SSL requests.', 'akismet' ); ?><?php } else { $ssl_disabled = get_option( 'akismet_ssl_disabled' ); if ( $ssl_disabled ) { ?><b><?php esc_html_e( 'Temporarily disabled.', 'akismet' ); ?></b> <?php esc_html_e( 'Akismet encountered a problem with a previous SSL request and disabled it temporarily. It will begin using SSL for requests again shortly.', 'akismet' ); ?><?php } else { ?><b><?php esc_html_e( 'Enabled.', 'akismet' ); ?></b> <?php esc_html_e( 'All systems functional.', 'akismet' ); ?><?php } } ?> </p> </td> </tr> <?php } ?> <tr> <th align="left" scope="row"><?php esc_html_e('Comments', 'akismet');?></th> <td></td> <td align="left"> <p> <label for="akismet_show_user_comments_approved" title="<?php esc_attr_e( 'Show approved comments' , 'akismet'); ?>"> <input name="akismet_show_user_comments_approved" id="akismet_show_user_comments_approved" value="1" type="checkbox" <?php // If the option isn't set, or if it's enabled ('1'), or if it was enabled a long time ago ('true'), check the checkbox. checked( true, ( in_array( get_option( 'akismet_show_user_comments_approved' ), array( false, '1', 'true' ), true ) ) ); ?> /> <?php esc_html_e( 'Show the number of approved comments beside each comment author', 'akismet' ); ?> </label> </p> </td> </tr> <tr> <th class="strictness" align="left" scope="row"><?php esc_html_e('Strictness', 'akismet'); ?></th> <td></td> <td align="left"> <fieldset><legend class="screen-reader-text"><span><?php esc_html_e('Akismet anti-spam strictness', 'akismet'); ?></span></legend> <p><label for="akismet_strictness_1"><input type="radio" name="akismet_strictness" id="akismet_strictness_1" value="1" <?php checked('1', get_option('akismet_strictness')); ?> /> <?php esc_html_e('Silently discard the worst and most pervasive spam so I never see it.', 'akismet'); ?></label></p> <p><label for="akismet_strictness_0"><input type="radio" name="akismet_strictness" id="akismet_strictness_0" value="0" <?php checked('0', get_option('akismet_strictness')); ?> /> <?php esc_html_e('Always put spam in the Spam folder for review.', 'akismet'); ?></label></p> </fieldset> <span class="akismet-note"><strong><?php esc_html_e('Note:', 'akismet');?></strong> <?php $delete_interval = max( 1, intval( apply_filters( 'akismet_delete_comment_interval', 15 ) ) ); printf( _n( 'Spam in the <a href="%1$s">spam folder</a> older than 1 day is deleted automatically.', 'Spam in the <a href="%1$s">spam folder</a> older than %2$d days is deleted automatically.', $delete_interval, 'akismet' ), admin_url( 'edit-comments.php?comment_status=spam' ), $delete_interval ); ?> </td> </tr> <tr> <th class="comment-form-privacy-notice" align="left" scope="row"><?php esc_html_e('Privacy', 'akismet'); ?></th> <td></td> <td align="left"> <fieldset><legend class="screen-reader-text"><span><?php esc_html_e('Akismet privacy notice', 'akismet'); ?></span></legend> <p><label for="akismet_comment_form_privacy_notice_display"><input type="radio" name="akismet_comment_form_privacy_notice" id="akismet_comment_form_privacy_notice_display" value="display" <?php checked('display', get_option('akismet_comment_form_privacy_notice')); ?> /> <?php esc_html_e('Display a privacy notice under your comment forms.', 'akismet'); ?></label></p> <p><label for="akismet_comment_form_privacy_notice_hide"><input type="radio" name="akismet_comment_form_privacy_notice" id="akismet_comment_form_privacy_notice_hide" value="hide" <?php echo in_array( get_option('akismet_comment_form_privacy_notice'), array('display', 'hide') ) ? checked('hide', get_option('akismet_comment_form_privacy_notice'), false) : 'checked="checked"'; ?> /> <?php esc_html_e('Do not display privacy notice.', 'akismet'); ?></label></p> </fieldset> <span class="akismet-note"><?php esc_html_e( 'To help your site with transparency under privacy laws like the GDPR, Akismet can display a notice to your users under your comment forms. This feature is disabled by default, however, you can turn it on above.', 'akismet' );?></span> </td> </tr> </tbody> </table> <div class="akismet-card-actions"> <?php if ( ! Akismet::predefined_api_key() ) { ?> <div id="delete-action"> <a class="submitdelete deletion" href="<?php echo esc_url( Akismet_Admin::get_page_url( 'delete_key' ) ); ?>"><?php esc_html_e('Disconnect this account', 'akismet'); ?></a> </div> <?php } ?> <?php wp_nonce_field(Akismet_Admin::NONCE) ?> <div id="publishing-action"> <input type="hidden" name="action" value="enter-key"> <input type="submit" name="submit" id="submit" class="akismet-button akismet-could-be-primary" value="<?php esc_attr_e('Save Changes', 'akismet');?>"> </div> <div class="clear"></div> </div> </form> </div> </div> <?php if ( ! Akismet::predefined_api_key() ) { ?> <div class="akismet-card"> <div class="akismet-section-header"> <div class="akismet-section-header__label"> <span><?php esc_html_e( 'Account' , 'akismet'); ?></span> </div> </div> <div class="inside"> <table cellspacing="0" border="0" class="akismet-settings"> <tbody> <tr> <th scope="row" align="left"><?php esc_html_e( 'Subscription Type' , 'akismet');?></th> <td width="5%"/> <td align="left"> <p><?php echo esc_html( $akismet_user->account_name ); ?></p> </td> </tr> <tr> <th scope="row" align="left"><?php esc_html_e( 'Status' , 'akismet');?></th> <td width="5%"/> <td align="left"> <p><?php if ( 'cancelled' == $akismet_user->status ) : esc_html_e( 'Cancelled', 'akismet' ); elseif ( 'suspended' == $akismet_user->status ) : esc_html_e( 'Suspended', 'akismet' ); elseif ( 'missing' == $akismet_user->status ) : esc_html_e( 'Missing', 'akismet' ); elseif ( 'no-sub' == $akismet_user->status ) : esc_html_e( 'No Subscription Found', 'akismet' ); else : esc_html_e( 'Active', 'akismet' ); endif; ?></p> </td> </tr> <?php if ( $akismet_user->next_billing_date ) : ?> <tr> <th scope="row" align="left"><?php esc_html_e( 'Next Billing Date' , 'akismet');?></th> <td width="5%"/> <td align="left"> <p><?php echo date( 'F j, Y', $akismet_user->next_billing_date ); ?></p> </td> </tr> <?php endif; ?> </tbody> </table> <div class="akismet-card-actions"> <div id="publishing-action"> <?php Akismet::view( 'get', array( 'text' => ( $akismet_user->account_type == 'free-api-key' && $akismet_user->status == 'active' ? __( 'Upgrade' , 'akismet') : __( 'Change' , 'akismet') ), 'redirect' => 'upgrade' ) ); ?> </div> <div class="clear"></div> </div> </div> </div> <?php } ?> <?php endif;?> </div> </div> views/stats.php 0000644 00000001352 15222563563 0007562 0 ustar 00 <div id="akismet-plugin-container"> <div class="akismet-masthead"> <div class="akismet-masthead__inside-container"> <a href="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" class="akismet-right"><?php esc_html_e( 'Anti-Spam Settings', 'akismet' ); ?></a> <div class="akismet-masthead__logo-container"> <img class="akismet-masthead__logo" src="<?php echo esc_url( plugins_url( '../_inc/img/logo-full-2x.png', __FILE__ ) ); ?>" alt="Akismet" /> </div> </div> </div> <iframe src="<?php echo esc_url( sprintf( '//akismet.com/web/1.0/user-stats.php?blog=%s&api_key=%s&locale=%s', urlencode( get_option( 'home' ) ), Akismet::get_api_key(), get_locale() ) ); ?>" width="100%" height="2500px" frameborder="0"></iframe> </div>