Plugin Directory

Changeset 1939555


Ignore:
Timestamp:
09/11/2018 10:59:30 PM (7 years ago)
Author:
edir
Message:

multiple emails and wp code standards

Location:
vulnerability-alerts
Files:
16 added
6 edited

Legend:

Unmodified
Added
Removed
  • vulnerability-alerts/trunk/languages/vulnerability-alerts-pt_BR.po

    r1787624 r1939555  
    22msgstr ""
    33"Project-Id-Version: Vulnerability Alerts\n"
    4 "POT-Creation-Date: 2017-12-15 10:55-0300\n"
    5 "PO-Revision-Date: 2017-12-15 10:55-0300\n"
     4"POT-Creation-Date: 2018-09-11 19:48-0300\n"
     5"PO-Revision-Date: 2018-09-11 19:49-0300\n"
    66"Last-Translator: Edir Pedro <[email protected]>\n"
    77"Language-Team: \n"
    8 "Language: Português Brasileiro\n"
     8"Language: pt_BR\n"
    99"MIME-Version: 1.0\n"
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "X-Generator: Poedit 1.5.7\n"
     12"X-Generator: Poedit 2.1.1\n"
    1313"X-Poedit-KeywordsList: _;__;_e;_n:1,2\n"
    1414"X-Poedit-Basepath: .\n"
     
    1616"X-Poedit-SearchPath-0: ..\n"
    1717
    18 #: ../report.php:3 ../vulnerability-alerts.php:175
     18#: ../report.php:3 ../vulnerability-alerts.php:184
     19#: ../vulnerability-alerts.php:185
    1920msgid "Vulnerability Alerts"
    2021msgstr "Alertas de Vulnerabilidade"
     
    2930msgstr "Última verificação no %s em %s"
    3031
    31 #: ../report.php:11
     32#: ../report.php:12
    3233msgid ""
    3334"Some paid plugins and themes, or developed exclusively for this website and "
     
    3738"e não compartilhados com o público, podem não ser reportados pelo WPScan."
    3839
    39 #: ../report.php:21 ../report.php:40 ../report.php:61
     40#: ../report.php:22 ../report.php:43 ../report.php:66
    4041msgid "Name"
    4142msgstr "Nome"
    4243
    43 #: ../report.php:22 ../report.php:41 ../report.php:62
     44#: ../report.php:23 ../report.php:44 ../report.php:67
    4445msgid "Vulnerabilities"
    4546msgstr "Vulnerabilidades"
    4647
    47 #: ../report.php:28 ../report.php:48 ../report.php:69
     48#: ../report.php:30 ../report.php:52 ../report.php:75
    4849#, php-format
    4950msgid "Version %s"
    5051msgstr "Versão %s"
    5152
    52 #: ../report.php:34 ../vulnerability-alerts.php:564
     53#: ../report.php:37 ../vulnerability-alerts.php:610
    5354msgid "Plugins"
    5455msgstr "Plugins"
    5556
    56 #: ../report.php:55 ../vulnerability-alerts.php:576
     57#: ../report.php:60 ../vulnerability-alerts.php:622
    5758msgid "Themes"
    5859msgstr "Temas"
    5960
    60 #: ../vulnerability-alerts.php:114
     61#: ../vulnerability-alerts.php:117
    6162#, php-format
    6263msgid "%d vulnerability found"
     
    6566msgstr[1] "%d vulnerabilidades encontradas"
    6667
    67 #: ../vulnerability-alerts.php:187
     68#: ../vulnerability-alerts.php:201
    6869msgid "View"
    6970msgstr "Ver"
    7071
    71 #: ../vulnerability-alerts.php:259
     72#: ../vulnerability-alerts.php:275
    7273msgid "Report updated."
    7374msgstr "Relatório atualizado."
    7475
    75 #: ../vulnerability-alerts.php:307
     76#: ../vulnerability-alerts.php:329
    7677msgid "Report not available"
    7778msgstr "Relatório não disponível"
    7879
    79 #: ../vulnerability-alerts.php:332
     80#: ../vulnerability-alerts.php:355
    8081msgid "Not fixed"
    8182msgstr "Sem correção"
    8283
    83 #: ../vulnerability-alerts.php:332
     84#: ../vulnerability-alerts.php:355
    8485#, php-format
    8586msgid "Fixed in version %s"
    8687msgstr "Corrigido na versão %s"
    8788
    88 #: ../vulnerability-alerts.php:382
     89#: ../vulnerability-alerts.php:410
    8990msgid "Notification"
    9091msgstr "Notificação"
    9192
    92 #: ../vulnerability-alerts.php:388
     93#: ../vulnerability-alerts.php:416
    9394msgid "E-mail Address"
    9495msgstr "Endereço de E-mail"
    9596
    96 #: ../vulnerability-alerts.php:395
     97#: ../vulnerability-alerts.php:423
    9798msgid "Send E-mail Alerts"
    9899msgstr "Enviar Alertas no E-mail"
    99100
    100 #: ../vulnerability-alerts.php:403
     101#: ../vulnerability-alerts.php:431
    101102msgid "Vulnerabilities to Ignore"
    102103msgstr "Vulnerabilidades Ignoradas"
    103104
    104 #: ../vulnerability-alerts.php:416
     105#: ../vulnerability-alerts.php:444
    105106msgid ""
    106107"Fill the options below if you want to be notified by mail about new "
     
    110111"vulnerabilidades."
    111112
    112 #: ../vulnerability-alerts.php:438
     113#: ../vulnerability-alerts.php:455
     114msgid "Add multiple e-mail addresses separating them by comma."
     115msgstr "Adicione múltiplos endereços de e-mail separando-os por vírgula."
     116
     117#: ../vulnerability-alerts.php:467
    113118msgid "Daily"
    114119msgstr "Diariamente"
    115120
    116 #: ../vulnerability-alerts.php:439
     121#: ../vulnerability-alerts.php:468
    117122msgid "Every Monday"
    118123msgstr "Toda Segunda"
    119124
    120 #: ../vulnerability-alerts.php:440
     125#: ../vulnerability-alerts.php:469
    121126msgid "Every Tuesday"
    122127msgstr "Toda Terça"
    123128
    124 #: ../vulnerability-alerts.php:441
     129#: ../vulnerability-alerts.php:470
    125130msgid "Every Wednesday"
    126131msgstr "Toda Quarta"
    127132
    128 #: ../vulnerability-alerts.php:442
     133#: ../vulnerability-alerts.php:471
    129134msgid "Every Thursday"
    130135msgstr "Toda Quinta"
    131136
    132 #: ../vulnerability-alerts.php:443
     137#: ../vulnerability-alerts.php:472
    133138msgid "Every Friday"
    134139msgstr "Toda Sexta"
    135140
    136 #: ../vulnerability-alerts.php:444
     141#: ../vulnerability-alerts.php:473
    137142msgid "Every Saturday"
    138143msgstr "Todo Sábado"
    139144
    140 #: ../vulnerability-alerts.php:445
     145#: ../vulnerability-alerts.php:474
    141146msgid "Every Sunday"
    142147msgstr "Todo Domingo"
    143148
    144 #: ../vulnerability-alerts.php:446
     149#: ../vulnerability-alerts.php:475
    145150msgid "Every Month"
    146151msgstr "Todo Mês"
    147152
    148 #: ../vulnerability-alerts.php:504
     153#: ../vulnerability-alerts.php:541
    149154msgid "You have entered an invalid e-mail address."
    150155msgstr "Você informou um endereço de e-mail inválido."
    151156
    152 #: ../vulnerability-alerts.php:545
     157#: ../vulnerability-alerts.php:591
    153158msgid "Hello Friend,"
    154159msgstr "Olá Amigo(a),"
    155160
    156 #: ../vulnerability-alerts.php:546
     161#: ../vulnerability-alerts.php:592
    157162#, php-format
    158163msgid "Some vulnerabilities were found in %s, visit the site for more details."
     
    161166"detalhes."
    162167
    163 #: ../vulnerability-alerts.php:582
     168#: ../vulnerability-alerts.php:628
    164169msgid "Hope this help!"
    165170msgstr "Espero que isso ajude!"
    166171
    167 #: ../vulnerability-alerts.php:586
     172#: ../vulnerability-alerts.php:632
    168173#, php-format
    169174msgid "Some vulnerabilities were found in %s"
  • vulnerability-alerts/trunk/readme.txt

    r1845067 r1939555  
    33Tags: security, vulnerability, wpscan, hack, scan, exploit, secure
    44Requires at least: 3.4
    5 Tested up to: 4.9.4
    6 Stable tag: 1.3.5
     5Tested up to: 4.9.8
     6Stable tag: 1.3.6
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3333== Changelog ==
    3434
     35= 1.3.6 =
     36* [Added] Support to send to multiple e-mails
     37
    3538= 1.3.5 =
    3639* [Fixed] Prevent cron jobs duplication.
  • vulnerability-alerts/trunk/report.php

    r1393065 r1939555  
    11<div class="wrap">
    22
    3     <h1><?php _e('Vulnerability Alerts', self::$id) ?></h1>
    4    
     3    <h1><?php _e( 'Vulnerability Alerts', self::$id ) ?></h1>
     4
    55    <?php settings_errors(); ?>
    66
    7     <form method='post'>
    8         <input type="hidden" name="verify" value="1">
    9         <p class="alignright"><?php submit_button(__('Check Now', self::$id), 'primary', 'submit', false) ?></p>
    10         <p><?php printf(__('Last request to %s on %s', self::$id), '<a href="https://wpvulndb.com/" target="_blank">WPScan Vulnerability Database</a>', date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $report['cache'])) ?><br>
    11         <?php _e('Some paid plugins and themes, or developed exclusively for this website and not shared for the public, may not be reported on WPScan.', self::$id) ?>
    12         </p>
    13     </form>
    14    
    15     <h3>WordPress</h3>
    16    
    17     <table class="wp-list-table widefat striped plugins">
    18     <thead>
    19         <tr>
    20             <td scope="col" class="manage-column check-column">&nbsp;</td>
    21             <th scope="col" class="manage-column column-name column-primary" width="250"><?php _e('Name', self::$id) ?></th>
    22             <th scope="col" class="manage-column column-description"><?php _e('Vulnerabilities', self::$id) ?></th>
    23         </tr>
    24     </thead>
    25     <tbody id="report-wordpress">
    26         <tr>
    27             <th scope="row" class="check-column" align="center"><?php echo self::get_status('wordpress') ?></span></th>
    28             <td class="plugin-title column-primary"><strong>WordPress</strong> <?php echo sprintf(__('Version %s', self::$id), get_bloginfo('version')) ?></td>
    29             <td><?php self::list_vulnerabilities('wordpress') ?></td>
    30         </tr>
    31     </tbody>
    32     </table>
    33    
    34     <h3><?php _e('Plugins', self::$id) ?></h3>
    35    
    36     <table class="wp-list-table widefat striped plugins">
    37     <thead>
    38         <tr>
    39             <td scope="col" class="manage-column check-column">&nbsp;</td>
    40             <th scope="col" class="manage-column column-name column-primary" width="250"><?php _e('Name', self::$id) ?></th>
    41             <th scope="col" class="manage-column column-description"><?php _e('Vulnerabilities', self::$id) ?></th>
    42         </tr>
    43     </thead>
    44     <tbody id="report-plugins">
    45     <?php foreach(get_plugins() as $name => $details) : ?>
    46         <tr>
    47             <th scope="row" class="check-column" align="center"><?php echo self::get_status('plugins', $name) ?></span></th>
    48             <td class="plugin-title column-primary"><strong><?php echo $details['Name'] ?></strong> <?php echo sprintf(__('Version %s', self::$id), $details['Version']) ?></td>
    49             <td><?php self::list_vulnerabilities('plugins', $name) ?></td>
    50         </tr>
    51     <?php endforeach; ?>
    52     </tbody>
    53     </table>
    54    
    55     <h3><?php _e('Themes', self::$id) ?></h3>
    56    
    57     <table class="wp-list-table widefat striped plugins">
    58     <thead>
    59         <tr>
    60             <td scope="col" class="manage-column check-column">&nbsp;</td>
    61             <th scope="col" class="manage-column column-name column-primary" width="250"><?php _e('Name', self::$id) ?></th>
    62             <th scope="col" class="manage-column column-description"><?php _e('Vulnerabilities', self::$id) ?></th>
    63         </tr>
    64     </thead>
    65     <tbody id="report-themes">
    66     <?php foreach(wp_get_themes() as $name => $details) : ?>
    67         <tr>
    68             <th scope="row" class="check-column" align="center"><?php echo self::get_status('themes', $name) ?></span></th>
    69             <td class="plugin-title column-primary"><strong><?php echo $details['Name'] ?></strong> <?php echo sprintf(__('Version %s', self::$id), $details['Version']) ?></td>
    70             <td><?php self::list_vulnerabilities('themes', $name) ?></td>
    71         </tr>
    72     <?php endforeach; ?>
    73     </tbody>
    74     </table>
    75    
    76     <form action='options.php' method='post'>
    77         <?php
    78         settings_fields(self::$id . '_notification');
    79         do_settings_sections(self::$id . '_notification');
     7    <form method='post'>
     8        <input type="hidden" name="verify" value="1">
     9        <p class="alignright"><?php submit_button( __( 'Check Now', self::$id ), 'primary', 'submit', false ) ?></p>
     10        <p><?php printf( __( 'Last request to %s on %s', self::$id ), '<a href="https://wpvulndb.com/" target="_blank">WPScan Vulnerability Database</a>', date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $report['cache'] ) ) ?>
     11            <br>
     12            <?php _e( 'Some paid plugins and themes, or developed exclusively for this website and not shared for the public, may not be reported on WPScan.', self::$id ) ?>
     13        </p>
     14    </form>
     15
     16    <h3>WordPress</h3>
     17
     18    <table class="wp-list-table widefat striped plugins">
     19        <thead>
     20        <tr>
     21            <td scope="col" class="manage-column check-column">&nbsp;</td>
     22            <th scope="col" class="manage-column column-name column-primary" width="250"><?php _e( 'Name', self::$id ) ?></th>
     23            <th scope="col" class="manage-column column-description"><?php _e( 'Vulnerabilities', self::$id ) ?></th>
     24        </tr>
     25        </thead>
     26        <tbody id="report-wordpress">
     27        <tr>
     28            <th scope="row" class="check-column" align="center"><?php echo self::get_status( 'wordpress' ) ?></span></th>
     29            <td class="plugin-title column-primary">
     30                <strong>WordPress</strong> <?php echo sprintf( __( 'Version %s', self::$id ), get_bloginfo( 'version' ) ) ?>
     31            </td>
     32            <td><?php self::list_vulnerabilities( 'wordpress' ) ?></td>
     33        </tr>
     34        </tbody>
     35    </table>
     36
     37    <h3><?php _e( 'Plugins', self::$id ) ?></h3>
     38
     39    <table class="wp-list-table widefat striped plugins">
     40        <thead>
     41        <tr>
     42            <td scope="col" class="manage-column check-column">&nbsp;</td>
     43            <th scope="col" class="manage-column column-name column-primary" width="250"><?php _e( 'Name', self::$id ) ?></th>
     44            <th scope="col" class="manage-column column-description"><?php _e( 'Vulnerabilities', self::$id ) ?></th>
     45        </tr>
     46        </thead>
     47        <tbody id="report-plugins">
     48        <?php foreach ( get_plugins() as $name => $details ) : ?>
     49            <tr>
     50                <th scope="row" class="check-column" align="center"><?php echo self::get_status( 'plugins', $name ) ?></span></th>
     51                <td class="plugin-title column-primary">
     52                    <strong><?php echo $details['Name'] ?></strong> <?php echo sprintf( __( 'Version %s', self::$id ), $details['Version'] ) ?>
     53                </td>
     54                <td><?php self::list_vulnerabilities( 'plugins', $name ) ?></td>
     55            </tr>
     56        <?php endforeach; ?>
     57        </tbody>
     58    </table>
     59
     60    <h3><?php _e( 'Themes', self::$id ) ?></h3>
     61
     62    <table class="wp-list-table widefat striped plugins">
     63        <thead>
     64        <tr>
     65            <td scope="col" class="manage-column check-column">&nbsp;</td>
     66            <th scope="col" class="manage-column column-name column-primary" width="250"><?php _e( 'Name', self::$id ) ?></th>
     67            <th scope="col" class="manage-column column-description"><?php _e( 'Vulnerabilities', self::$id ) ?></th>
     68        </tr>
     69        </thead>
     70        <tbody id="report-themes">
     71        <?php foreach ( wp_get_themes() as $name => $details ) : ?>
     72            <tr>
     73                <th scope="row" class="check-column" align="center"><?php echo self::get_status( 'themes', $name ) ?></span></th>
     74                <td class="plugin-title column-primary">
     75                    <strong><?php echo $details['Name'] ?></strong> <?php echo sprintf( __( 'Version %s', self::$id ), $details['Version'] ) ?>
     76                </td>
     77                <td><?php self::list_vulnerabilities( 'themes', $name ) ?></td>
     78            </tr>
     79        <?php endforeach; ?>
     80        </tbody>
     81    </table>
     82
     83    <form action='options.php' method='post'>
     84    <?php
     85        settings_fields( self::$id . '_notification' );
     86        do_settings_sections( self::$id . '_notification' );
    8087        submit_button();
    81         ?>     
    82     </form>
     88    ?>
     89    </form>
    8390
    8491</div>
  • vulnerability-alerts/trunk/uninstall.php

    r1498915 r1939555  
    22
    33// If uninstall is not called from WordPress, exit
    4 if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) {
    5     exit();
     4if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
     5    exit();
    66}
    7  
     7
    88$option_name = 'vulnerability-alerts';
    99
    10 if(is_multisite()) {
     10if ( is_multisite() ) {
    1111    global $wpdb;
    12    
    13     $blogs = $wpdb->get_results("SELECT blog_id FROM {$wpdb->blogs}", ARRAY_A);
    14     if($blogs) {
    15         foreach($blogs as $blog) {
    16             switch_to_blog($blog['blog_id']);
    17             delete_option($option_name);
    18             delete_option($option_name . '_notification');
     12
     13    $blogs = $wpdb->get_results( "SELECT blog_id FROM {$wpdb->blogs}", ARRAY_A );
     14    if ( $blogs ) {
     15        foreach ( $blogs as $blog ) {
     16            switch_to_blog( $blog['blog_id'] );
     17            delete_option( $option_name );
     18            delete_option( $option_name . '_notification' );
    1919        }
    2020        restore_current_blog();
    2121    }
    2222} else {
    23     delete_option($option_name);
    24     delete_option($option_name . '_notification');
     23    delete_option( $option_name );
     24    delete_option( $option_name . '_notification' );
    2525}
    26 
    27 ?>
  • vulnerability-alerts/trunk/vulnerability-alerts.php

    r1845067 r1939555  
    11<?php
    2    
     2
    33/**
    44 * Plugin Name: Vulnerability Alerts
    55 * Description: Scans your system to find vulnerabilities listed in WPScan Vulnerability Database.
    66 * Plugin URI: http://wordpress.org/plugins/vulnerability-alerts/
    7  * Version: 1.3.5
     7 * Version: 1.3.6
    88 * Author: Edir Pedro
    99 * Author URI: http://edirpedro.com.br
     
    1414
    1515// File Security Check
    16 defined('ABSPATH') or die("No script kiddies please!");
    17    
    18 
    19 class VulnerabiltyAlerts {
    20    
     16defined( 'ABSPATH' ) or die( "No script kiddies please!" );
     17
     18
     19class Vulnerabilty_Alerts {
     20
    2121    // Plugin name
    2222    static public $id = 'vulnerability-alerts';
    23    
     23
    2424    // Report shortcut
    2525    static public $report = array();
    26    
     26
    2727    // Arguments to WP Remote Get
    2828    static public $remote = array(
    2929        'user-agent' => 'WordPress Plugin Vulnerability Alerts'
    30         );
    31    
     30    );
     31
    3232    /*
    3333    * Initialize actions
     
    3636
    3737        // Languages
    38         load_plugin_textdomain(self::$id, false, dirname(plugin_basename(__FILE__)) . '/languages');
    39        
     38        load_plugin_textdomain( self::$id, false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
     39
    4040        // Arguments to wp remote get
    41         self::$remote['user-agent'] .=  '; ' . get_bloginfo('url');
    42        
     41        self::$remote['user-agent'] .= '; ' . get_bloginfo( 'url' );
     42
    4343        // Report
    44         self::$report = get_option(self::$id);
    45        
     44        self::$report = get_option( self::$id );
     45
    4646        // Hooks
    47         add_action('admin_menu', array(__CLASS__, 'menu'));
    48         add_action('admin_bar_menu', array(__CLASS__, 'admin_bar'), 65); // Between Updates, Comments and New Content menu
    49         add_action('admin_init', array('VulnerabiltyAlerts_Notification', 'init'));
    50         add_action(self::$id . '_schedule', array(__CLASS__, 'schedule'), 999);
    51         add_filter('plugin_action_links_' . plugin_basename(__FILE__), array(__CLASS__, 'add_action_links'));       
    52 
    53     }
    54    
     47        add_action( 'admin_menu', array( __CLASS__, 'menu' ) );
     48        add_action( 'admin_bar_menu', array( __CLASS__, 'admin_bar' ), 65 ); // Between Updates, Comments and New Content menu
     49        add_action( 'admin_init', array( 'Vulnerabilty_Alerts_Notification', 'init' ) );
     50        add_action( self::$id . '_schedule', array( __CLASS__, 'schedule' ), 999 );
     51        add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( __CLASS__, 'add_action_links' ) );
     52
     53    }
     54
    5555
    5656    /*
     
    6060
    6161        // Languages
    62         load_plugin_textdomain(self::$id, false, dirname(plugin_basename(__FILE__)) . '/languages');
    63 
    64     }
    65    
     62        load_plugin_textdomain( self::$id, false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
     63
     64    }
     65
    6666    /*
    6767    * Activate actions
    6868    */
    6969    static public function activate() {
    70        
    71         wp_clear_scheduled_hook(self::$id . '_schedule'); // Prevent duplication
    72         wp_schedule_event(time(), 'daily', self::$id . '_schedule');
    73    
     70
     71        wp_clear_scheduled_hook( self::$id . '_schedule' ); // Prevent duplication
     72        wp_schedule_event( time(), 'daily', self::$id . '_schedule' );
     73
    7474        self::verify();
    75        
    76     }
    77    
     75
     76    }
     77
    7878    /*
    7979    * Deactivate actions
    8080    */
    8181    static public function deactivate() {
    82        
    83         wp_clear_scheduled_hook(self::$id . '_schedule');
    84        
    85     }
    86    
     82
     83        wp_clear_scheduled_hook( self::$id . '_schedule' );
     84
     85    }
     86
    8787    /*
    8888    * Schedule and event to run verify() function
    8989    */
    9090    static public function schedule() {
    91        
     91
    9292        self::verify();
    93        
     93
    9494        // Notify by mail when solicited
    95         VulnerabiltyAlerts_Notification::notify();
    96 
    97     }
    98    
     95        Vulnerabilty_Alerts_Notification::notify();
     96
     97    }
     98
    9999    /*
    100100    * Create a shortcut on Admin Bar to show the total of vulnerabilities found
    101101    */
    102     static public function admin_bar($wp_admin_bar) {
    103    
    104         if(!current_user_can('manage_options'))
     102    static public function admin_bar( $wp_admin_bar ) {
     103
     104        if ( ! current_user_can( 'manage_options' ) ) {
    105105            return;
    106            
     106        }
     107
    107108        $report = self::$report;
    108109        $total = self::get_total();
    109        
    110         if(!empty($report) and $total > 0) {
     110
     111        if ( ! empty( $report ) and $total > 0 ) {
    111112            $args = array(
    112113                'id' => self::$id,
    113                 'title' => '<span class="ab-icon dashicons-shield"></span><span class="ab-label">' . $total .'</span>',
    114                 'href' => admin_url('tools.php?page=' . self::$id),
     114                'title' => '<span class="ab-icon dashicons-shield"></span><span class="ab-label">' . $total . '</span>',
     115                'href' => admin_url( 'tools.php?page=' . self::$id ),
    115116                'meta' => array(
    116                     'title' => sprintf(_n('%d vulnerability found', '%d vulnerabilities found', $total, self::$id), $total)
     117                    'title' => sprintf( _n( '%d vulnerability found', '%d vulnerabilities found', $total, self::$id ), $total )
    117118                )
    118119            );
    119             $wp_admin_bar->add_node($args);
    120         }
    121        
    122     }
    123    
     120            $wp_admin_bar->add_node( $args );
     121        }
     122
     123    }
     124
    124125    /*
    125126    * Return the total of vulnerabilities found
     
    127128    static public function get_total() {
    128129        $report = self::$report;
    129         $options = get_option(self::$id . '_notification');
    130         $ignored = empty($options['ignored']) ? array() : $options['ignored'];
    131        
     130        $options = get_option( self::$id . '_notification' );
     131        $ignored = empty( $options['ignored'] ) ? array() : $options['ignored'];
     132
    132133        $total = 0;
    133134        $total += $report['wordpress']['total'];
    134135        $total += $report['plugins']['total'];
    135136        $total += $report['themes']['total'];
    136                
     137
    137138        // WordPress ignored
    138         if($report['wordpress']['total'] > 0) {
    139             foreach($report['wordpress']['vulnerabilities'] as $item) {
    140                 if(in_array($item->id, $ignored))
     139        if ( $report['wordpress']['total'] > 0 ) {
     140            foreach ( $report['wordpress']['vulnerabilities'] as $item ) {
     141                if ( in_array( $item->id, $ignored ) ) {
    141142                    $total -= 1;
    142             }
    143         }
    144        
     143                }
     144            }
     145        }
     146
    145147        // Plugins ignored
    146         if($report['plugins']['total'] > 0) {
    147             foreach($report['plugins'] as $plugin) {
    148                 if(empty($plugin['vulnerabilities']))
     148        if ( $report['plugins']['total'] > 0 ) {
     149            foreach ( $report['plugins'] as $plugin ) {
     150                if ( empty( $plugin['vulnerabilities'] ) ) {
    149151                    continue;
    150                 foreach($plugin['vulnerabilities'] as $item) {
    151                     if(in_array($item->id, $ignored))
     152                }
     153                foreach ( $plugin['vulnerabilities'] as $item ) {
     154                    if ( in_array( $item->id, $ignored ) ) {
    152155                        $total -= 1;
    153                 }
    154             }
    155         }
    156        
     156                    }
     157                }
     158            }
     159        }
     160
    157161        // Themes ignored
    158         if($report['themes']['total'] > 0) {
    159             foreach($report['themes'] as $theme) {
    160                 if(empty($theme['vulnerabilities']))
     162        if ( $report['themes']['total'] > 0 ) {
     163            foreach ( $report['themes'] as $theme ) {
     164                if ( empty( $theme['vulnerabilities'] ) ) {
    161165                    continue;
    162                 foreach($theme['vulnerabilities'] as $item) {
    163                     if(in_array($item->id, $ignored))
     166                }
     167                foreach ( $theme['vulnerabilities'] as $item ) {
     168                    if ( in_array( $item->id, $ignored ) ) {
    164169                        $total -= 1;
    165                 }
    166             }
    167         }
    168        
     170                    }
     171                }
     172            }
     173        }
     174
    169175        return $total;
    170176    }
    171    
     177
    172178    /*
    173179    * Create a menu on Tools section
    174180    */
    175181    static public function menu() {
    176        
    177         add_management_page(__('Vulnerability Alerts', self::$id), __('Vulnerability Alerts', self::$id), 'manage_options', self::$id, array(__CLASS__, 'report'));
    178    
    179     }
    180    
     182
     183        add_management_page(
     184            __( 'Vulnerability Alerts', self::$id ),
     185            __( 'Vulnerability Alerts', self::$id ),
     186            'manage_options',
     187            self::$id,
     188            array( __CLASS__, 'report' )
     189        );
     190
     191    }
     192
    181193    /*
    182194    * Include a shortcut on Plugins Page
     
    185197    * @return array
    186198    */
    187     static public function add_action_links($links) {
    188        
    189         $links[] = '<a href="' . admin_url('tools.php?page=' . self::$id) . '">' . __('View') . '</a>';
     199    static public function add_action_links( $links ) {
     200
     201        $links[] = '<a href="' . admin_url( 'tools.php?page=' . self::$id ) . '">' . __( 'View' ) . '</a>';
     202
    190203        return $links;
    191        
     204
    192205    }
    193206
     
    196209    */
    197210    static public function verify() {
    198                
     211
    199212        // Suppports during WP Cron
    200         if(!function_exists('get_plugins'))
     213        if ( ! function_exists( 'get_plugins' ) ) {
    201214            require_once ABSPATH . 'wp-admin/includes/plugin.php';
    202        
     215        }
     216
    203217        $report = array();
    204        
     218
    205219        // WordPress
    206220        $report['wordpress'] = array();
    207221        $report['wordpress']['total'] = 0;
    208         $version = get_bloginfo('version');
    209         $response = wp_remote_get('https://wpvulndb.com/api/v2/wordpresses/' . str_replace('.', '', $version), self::$remote);
    210         if(is_array($response)) {
    211             $result = (array) json_decode($response['body']);
    212             if(!empty($result)) {
    213                 $report['wordpress']['vulnerabilities'] = self::get_vulnerabilities($result, $version);
    214                 $report['wordpress']['total'] = count($report['wordpress']['vulnerabilities']);
     222        $version = get_bloginfo( 'version' );
     223        $response = wp_remote_get( 'https://wpvulndb.com/api/v2/wordpresses/' . str_replace( '.', '', $version ), self::$remote );
     224        if ( is_array( $response ) ) {
     225            $result = (array) json_decode( $response['body'] );
     226            if ( ! empty( $result ) ) {
     227                $report['wordpress']['vulnerabilities'] = self::get_vulnerabilities( $result, $version );
     228                $report['wordpress']['total'] = count( $report['wordpress']['vulnerabilities'] );
    215229            }
    216230        }
     
    219233        $report['plugins'] = array();
    220234        $report['plugins']['total'] = 0;
    221         foreach(get_plugins() as $name => $details) {
    222             $parts = pathinfo($name);
    223             $response = wp_remote_get('https://wpvulndb.com/api/v2/plugins/' . $parts['dirname'], self::$remote);
    224             if(is_array($response)) {
    225                 $result = (array) json_decode($response['body']);
    226                 if(!empty($result)) {
    227                     $report['plugins'][$name]['vulnerabilities'] = self::get_vulnerabilities($result, $details['Version']);
    228                     $report['plugins']['total'] += count($report['plugins'][$name]['vulnerabilities']);
    229                 }
    230             }
    231         }
    232        
     235        foreach ( get_plugins() as $name => $details ) {
     236            $parts = pathinfo( $name );
     237            $response = wp_remote_get( 'https://wpvulndb.com/api/v2/plugins/' . $parts['dirname'], self::$remote );
     238            if ( is_array( $response ) ) {
     239                $result = (array) json_decode( $response['body'] );
     240                if ( ! empty( $result ) ) {
     241                    $report['plugins'][ $name ]['vulnerabilities'] = self::get_vulnerabilities( $result, $details['Version'] );
     242                    $report['plugins']['total'] += count( $report['plugins'][ $name ]['vulnerabilities'] );
     243                }
     244            }
     245        }
     246
    233247        // Themes
    234248        $report['themes'] = array();
    235249        $report['themes']['total'] = 0;
    236         foreach(wp_get_themes() as $name => $details) {
    237             $response = wp_remote_get('https://wpvulndb.com/api/v2/themes/' . $name, self::$remote);
    238             if(is_array($response)) {
    239                 $result = (array) json_decode($response['body']);
    240                 if(!empty($result)) {
    241                     $report['themes'][$name]['vulnerabilities'] = self::get_vulnerabilities($result, $details['Version']);
    242                     $report['themes']['total'] += count($report['themes'][$name]['vulnerabilities']);
    243                 }
    244             }
    245         }
    246            
     250        foreach ( wp_get_themes() as $name => $details ) {
     251            $response = wp_remote_get( 'https://wpvulndb.com/api/v2/themes/' . $name, self::$remote );
     252            if ( is_array( $response ) ) {
     253                $result = (array) json_decode( $response['body'] );
     254                if ( ! empty( $result ) ) {
     255                    $report['themes'][ $name ]['vulnerabilities'] = self::get_vulnerabilities( $result, $details['Version'] );
     256                    $report['themes']['total'] += count( $report['themes'][ $name ]['vulnerabilities'] );
     257                }
     258            }
     259        }
     260
    247261        // Caching
    248         $report['cache'] = strtotime(current_time('mysql'));
    249         update_option(self::$id, $report, true);
     262        $report['cache'] = strtotime( current_time( 'mysql' ) );
     263        update_option( self::$id, $report, true );
    250264        self::$report = $report;
    251                
    252     }
    253    
     265
     266    }
     267
    254268    /*
    255269    * Report Page
    256270    */
    257271    static public function report() {
    258        
     272
    259273        // Button Check Now
    260         if(isset($_POST['verify'])) {
    261             add_settings_error(self::$id, 'update', __('Report updated.', self::$id), 'updated');
     274        if ( isset( $_POST['verify'] ) ) {
     275            add_settings_error( self::$id, 'update', __( 'Report updated.', self::$id ), 'updated' );
    262276            self::verify();
    263277        }
    264                
     278
    265279        $report = self::$report;
    266280        include 'report.php';
    267        
    268     }
    269    
     281
     282    }
     283
    270284    /*
    271285    * Filter vulnerability list from WPScan
     
    275289    * @return string
    276290    */
    277     static public function get_vulnerabilities($data, $version) {
    278        
     291    static public function get_vulnerabilities( $data, $version ) {
     292
    279293        $list = array();
    280         $key = key($data);
    281        
    282         if(empty($data[$key]->vulnerabilities))
     294        $key = key( $data );
     295
     296        if ( empty( $data[ $key ]->vulnerabilities ) ) {
    283297            return $list;
    284        
    285         foreach($data[$key]->vulnerabilities as $item) {
    286             if($item->fixed_in) {
    287                 if(version_compare($version, $item->fixed_in, '<'))
    288                     $list[] = $item;
     298        }
     299
     300        foreach ( $data[ $key ]->vulnerabilities as $item ) {
     301            if ( $item->fixed_in ) {
     302                if ( version_compare( $version, $item->fixed_in, '<' ) ) {
     303                    $list[] = $item;
     304                }
    289305            } else {
    290                 $list[] = $item;
    291             }
    292         }
    293        
     306                $list[] = $item;
     307            }
     308        }
     309
    294310        return $list;
    295        
    296     }
    297    
     311
     312    }
     313
    298314    /*
    299315    * List vulnerabilities on screen
     
    303319    * @return string
    304320    */
    305     static public function list_vulnerabilities($type, $name = null) {
    306 
    307         $report = self::$report[$type];
    308         if(array_key_exists($name, $report))
    309             $report = $report[$name];
    310 
    311         if(!isset($report['vulnerabilities'])) {
    312             _e('Report not available', self::$id);
     321    static public function list_vulnerabilities( $type, $name = null ) {
     322
     323        $report = self::$report[ $type ];
     324        if ( array_key_exists( $name, $report ) ) {
     325            $report = $report[ $name ];
     326        }
     327
     328        if ( ! isset( $report['vulnerabilities'] ) ) {
     329            _e( 'Report not available', self::$id );
     330
    313331            return;
    314332        }
    315    
     333
    316334        $list = array();
    317        
    318         foreach($report['vulnerabilities'] as $item) {
    319             $html  = '<a href="' . esc_url('https://wpvulndb.com/vulnerabilities/' . $item->id) . '" target="_blank">';
    320             $html .= self::get_vulnerability_title($item);
     335
     336        foreach ( $report['vulnerabilities'] as $item ) {
     337            $html = '<a href="' . esc_url( 'https://wpvulndb.com/vulnerabilities/' . $item->id ) . '" target="_blank">';
     338            $html .= self::get_vulnerability_title( $item );
    321339            $html .= '</a>';
    322340            $list[] = $html;
    323341        }
    324        
    325         echo empty($list) ? '- -' : join('<br>', $list);
    326        
    327     }
    328    
     342
     343        echo empty( $list ) ? '- -' : join( '<br>', $list );
     344
     345    }
     346
    329347    /*
    330348    * Get vulnerability title
     
    333351    * @return string
    334352    */
    335     static public function get_vulnerability_title($vulnerability) {
    336         $title = esc_html($vulnerability->title) . ' - ';
    337         $title .= empty($vulnerability->fixed_in) ? __('Not fixed', self::$id) : sprintf(__('Fixed in version %s', self::$id),  $vulnerability->fixed_in);
     353    static public function get_vulnerability_title( $vulnerability ) {
     354        $title = esc_html( $vulnerability->title ) . ' - ';
     355        $title .= empty( $vulnerability->fixed_in ) ? __( 'Not fixed', self::$id ) : sprintf( __( 'Fixed in version %s', self::$id ), $vulnerability->fixed_in );
     356
    338357        return $title;
    339358    }
    340        
     359
    341360    /*
    342361    * Show status icons: checked, attention and error
     
    346365    * @return string
    347366    */
    348     static public function get_status($type, $name = null) {
    349        
    350         $report = self::$report[$type];
    351         if(array_key_exists($name, $report))
    352             $report = $report[$name];
    353 
    354         if(!isset($report['vulnerabilities']))
     367    static public function get_status( $type, $name = null ) {
     368
     369        $report = self::$report[ $type ];
     370        if ( array_key_exists( $name, $report ) ) {
     371            $report = $report[ $name ];
     372        }
     373
     374        if ( ! isset( $report['vulnerabilities'] ) ) {
    355375            return '&nbsp; <span class="dashicons dashicons-no-alt" style="color:gray"></span>';
    356 
    357         if(empty($report['vulnerabilities']))
     376        }
     377
     378        if ( empty( $report['vulnerabilities'] ) ) {
    358379            return '&nbsp; <span class="dashicons dashicons-yes" style="color:green"></span>';
    359         else
     380        } else {
    360381            return '&nbsp; <span class="dashicons dashicons-warning" style="color:Crimson"></span>';
    361 
    362     }
    363    
     382        }
     383
     384    }
     385
    364386}
    365387
     
    367389* Notification System
    368390*/
    369 class VulnerabiltyAlerts_Notification extends VulnerabiltyAlerts {
    370    
     391
     392class Vulnerabilty_Alerts_Notification extends Vulnerabilty_Alerts {
     393
    371394    /*
    372395    * Notification Options
    373396    */
    374397    static public function init() {
    375        
     398
    376399        $report = self::$report;
    377                
     400
    378401        $total = 0;
    379402        $total += $report['wordpress']['total'];
    380403        $total += $report['plugins']['total'];
    381404        $total += $report['themes']['total'];
    382                        
    383         register_setting(self::$id . '_notification', self::$id . '_notification', array(__CLASS__, 'validate'));
    384        
     405
     406        register_setting( self::$id . '_notification', self::$id . '_notification', array( __CLASS__, 'validate' ) );
     407
    385408        add_settings_section(
    386             self::$id . '_notification_section',
    387             __('Notification', self::$id),
    388             array(__CLASS__, 'introduction'),
    389             self::$id . '_notification');
     409            self::$id . '_notification_section',
     410            __( 'Notification', self::$id ),
     411            array( __CLASS__, 'introduction' ),
     412            self::$id . '_notification' );
    390413
    391414        add_settings_field(
    392             'email',
    393             __('E-mail Address', self::$id),
    394             array(__CLASS__, 'field_email'),
    395             self::$id . '_notification',
    396             self::$id . '_notification_section');
    397            
     415            'email',
     416            __( 'E-mail Address', self::$id ),
     417            array( __CLASS__, 'field_email' ),
     418            self::$id . '_notification',
     419            self::$id . '_notification_section' );
     420
    398421        add_settings_field(
    399             'interval',
    400             __('Send E-mail Alerts', self::$id),
    401             array(__CLASS__, 'field_interval'),
    402             self::$id . '_notification',
    403             self::$id . '_notification_section');
    404 
    405         if($total > 0) {
     422            'interval',
     423            __( 'Send E-mail Alerts', self::$id ),
     424            array( __CLASS__, 'field_interval' ),
     425            self::$id . '_notification',
     426            self::$id . '_notification_section' );
     427
     428        if ( $total > 0 ) {
    406429            add_settings_field(
    407                 'ignored',
    408                 __('Vulnerabilities to Ignore', self::$id),
    409                 array(__CLASS__, 'field_ignored'),
    410                 self::$id . '_notification',
    411                 self::$id . '_notification_section');
    412         }
    413                            
    414     }
    415    
     430                'ignored',
     431                __( 'Vulnerabilities to Ignore', self::$id ),
     432                array( __CLASS__, 'field_ignored' ),
     433                self::$id . '_notification',
     434                self::$id . '_notification_section' );
     435        }
     436
     437    }
     438
    416439    /*
    417440    * Introduction
     
    419442    static public function introduction() {
    420443
    421         echo '<p>' . __('Fill the options below if you want to be notified by mail about new vulnerabilities.', self::$id) . '</p>';
    422 
    423     }
    424    
     444        echo '<p>' . __( 'Fill the options below if you want to be notified by mail about new vulnerabilities.', self::$id ) . '</p>';
     445
     446    }
     447
    425448    /*
    426449    * Field E-mail
     
    428451    static public function field_email() {
    429452
    430         $options = get_option(self::$id . '_notification');
    431         echo '<input type="text" name="' . self::$id . '_notification[email]" value="' . $options['email'] . '" class="regular-text">';
    432 
    433     }
    434    
     453        $options = get_option( self::$id . '_notification' );
     454        echo '<input type="text" name="' . self::$id . '_notification[email]" value="' . $options['email'] . '" class="regular-text" placeholder="[email protected], [email protected]">';
     455        echo '<p class="description">' . __( 'Add multiple e-mail addresses separating them by comma.', self::$id ) . '</p>';
     456
     457    }
     458
    435459    /*
    436460    * Field Interval
     
    438462    static public function field_interval() {
    439463
    440         $options = get_option(self::$id . '_notification');
    441         $interval = empty($options['interval']) ? 'd' : $options['interval'];
     464        $options = get_option( self::$id . '_notification' );
     465        $interval = empty( $options['interval'] ) ? 'd' : $options['interval'];
    442466        echo '<select name="' . self::$id . '_notification[interval]">';
    443         echo '<option value="d" ' . selected('d', $interval, false) . '>' . __('Daily', self::$id) . '</option>';
    444         echo '<option value="1" ' . selected(1, $interval, false) . '>' . __('Every Monday', self::$id) . '</option>';
    445         echo '<option value="2" ' . selected(2, $interval, false) . '>' . __('Every Tuesday', self::$id) . '</option>';
    446         echo '<option value="3" ' . selected(3, $interval, false) . '>' . __('Every Wednesday', self::$id) . '</option>';
    447         echo '<option value="4" ' . selected(4, $interval, false) . '>' . __('Every Thursday', self::$id) . '</option>';
    448         echo '<option value="5" ' . selected(5, $interval, false) . '>' . __('Every Friday', self::$id) . '</option>';
    449         echo '<option value="6" ' . selected(6, $interval, false) . '>' . __('Every Saturday', self::$id) . '</option>';
    450         echo '<option value="7" ' . selected(7, $interval, false) . '>' . __('Every Sunday', self::$id) . '</option>';
    451         echo '<option value="m" ' . selected('m', $interval, false) . '>' . __('Every Month', self::$id) . '</option>';
     467        echo '<option value="d" ' . selected( 'd', $interval, false ) . '>' . __( 'Daily', self::$id ) . '</option>';
     468        echo '<option value="1" ' . selected( 1, $interval, false ) . '>' . __( 'Every Monday', self::$id ) . '</option>';
     469        echo '<option value="2" ' . selected( 2, $interval, false ) . '>' . __( 'Every Tuesday', self::$id ) . '</option>';
     470        echo '<option value="3" ' . selected( 3, $interval, false ) . '>' . __( 'Every Wednesday', self::$id ) . '</option>';
     471        echo '<option value="4" ' . selected( 4, $interval, false ) . '>' . __( 'Every Thursday', self::$id ) . '</option>';
     472        echo '<option value="5" ' . selected( 5, $interval, false ) . '>' . __( 'Every Friday', self::$id ) . '</option>';
     473        echo '<option value="6" ' . selected( 6, $interval, false ) . '>' . __( 'Every Saturday', self::$id ) . '</option>';
     474        echo '<option value="7" ' . selected( 7, $interval, false ) . '>' . __( 'Every Sunday', self::$id ) . '</option>';
     475        echo '<option value="m" ' . selected( 'm', $interval, false ) . '>' . __( 'Every Month', self::$id ) . '</option>';
    452476        echo '</selected>';
    453477
    454478    }
    455    
     479
    456480    /*
    457481    * Field Ignore
     
    459483    static public function field_ignored() {
    460484
    461         $options = get_option(self::$id . '_notification');
    462         $ignored = empty($options['ignored']) ? array() : $options['ignored'];
    463 
    464         self::list_vulnerabilities_to_ignore('wordpress');
    465            
    466         foreach(get_plugins() as $name => $details)
    467             self::list_vulnerabilities_to_ignore('plugins', $name);
    468        
    469         foreach(wp_get_themes() as $name => $details)
    470             self::list_vulnerabilities_to_ignore('themes', $name);
    471            
    472     }
    473    
     485        $options = get_option( self::$id . '_notification' );
     486        $ignored = empty( $options['ignored'] ) ? array() : $options['ignored'];
     487
     488        self::list_vulnerabilities_to_ignore( 'wordpress' );
     489
     490        foreach ( get_plugins() as $name => $details ) {
     491            self::list_vulnerabilities_to_ignore( 'plugins', $name );
     492        }
     493
     494        foreach ( wp_get_themes() as $name => $details ) {
     495            self::list_vulnerabilities_to_ignore( 'themes', $name );
     496        }
     497
     498    }
     499
    474500    /*
    475501    * List of vulnerabilities
     
    479505    * @return string
    480506    */
    481     static public function list_vulnerabilities_to_ignore($type, $name = null) {
    482 
    483         $report = self::$report[$type];
    484         if(array_key_exists($name, $report))
    485             $report = $report[$name];
    486 
    487         if(!isset($report['vulnerabilities'])) {
     507    static public function list_vulnerabilities_to_ignore( $type, $name = null ) {
     508
     509        $report = self::$report[ $type ];
     510        if ( array_key_exists( $name, $report ) ) {
     511            $report = $report[ $name ];
     512        }
     513
     514        if ( ! isset( $report['vulnerabilities'] ) ) {
    488515            return null;
    489516        }
     517
     518        $options = get_option( self::$id . '_notification' );
     519        $ignored = empty( $options['ignored'] ) ? array() : $options['ignored'];
     520
     521        foreach ( $report['vulnerabilities'] as $item ) {
     522            echo '<label><input type="checkbox" name="' . self::$id . '_notification[ignored][]" value="' . $item->id . '" ' . ( in_array( $item->id, $ignored ) ? 'checked="checked"' : null ) . '> ';
     523            echo self::get_vulnerability_title( $item );
     524            echo '</label><br>';
     525        }
     526
     527    }
     528
     529    /*
     530    * Validating fields
     531    */
     532    static public function validate( $input ) {
     533
     534        // Email
     535        if ( ! empty( $input['email'] ) ) {
     536           
     537            $emails = explode( ',', $input['email'] );
    490538   
    491         $options = get_option(self::$id . '_notification');
    492         $ignored = empty($options['ignored']) ? array() : $options['ignored'];
    493        
    494         foreach($report['vulnerabilities'] as $item) {
    495             echo '<label><input type="checkbox" name="' . self::$id . '_notification[ignored][]" value="' . $item->id . '" ' . (in_array($item->id, $ignored) ? 'checked="checked"' : null) . '> ';
    496             echo self::get_vulnerability_title($item);
    497             echo '</label><br>';
    498         }
    499 
    500     }
     539            foreach ( $emails as $email ) {
     540                if ( ! is_email( trim( $email ) ) ) {
     541                    add_settings_error( self::$id . '_notification', 'invalid-email', __( 'You have entered an invalid e-mail address.', self::$id ) );
     542                }
     543            }
    501544   
    502     /*
    503     * Validating fields
    504     */
    505     static public function validate($input) {
    506        
    507         // Email
    508         if(!empty($input['email']) && !is_email($input['email']))
    509             add_settings_error(self::$id . '_notification', 'invalid-email', __('You have entered an invalid e-mail address.', self::$id));
     545        }
    510546
    511547        return $input;
    512        
    513     }
    514    
     548
     549    }
     550
    515551    /*
    516552    * Sending notification
    517553    */
    518554    static public function notify() {
    519        
     555
    520556        // Suppports during WP Cron
    521         if(!function_exists('get_plugins'))
     557        if ( ! function_exists( 'get_plugins' ) ) {
    522558            require_once ABSPATH . 'wp-admin/includes/plugin.php';
     559        }
    523560
    524561        $report = self::$report;
    525562        $total = self::get_total();
    526        
    527         if($total == 0)
     563
     564        if ( $total == 0 ) {
    528565            return;
    529        
    530         $options = get_option(self::$id . '_notification');
    531         $email = empty($options['email']) ? null : $options['email'];
    532         $interval = empty($options['interval']) ? 'd' : $options['interval'];
    533         $ignored = empty($options['ignored']) ? array() : $options['ignored'];
    534        
     566        }
     567
     568        $options = get_option( self::$id . '_notification' );
     569        $email = empty( $options['email'] ) ? null : $options['email'];
     570        $interval = empty( $options['interval'] ) ? 'd' : $options['interval'];
     571        $ignored = empty( $options['ignored'] ) ? array() : $options['ignored'];
     572
    535573        // Check email             
    536         if(empty($email))
     574        if ( empty( $email ) ) {
    537575            return;
     576        }
    538577
    539578        // Check weekly interval
    540         if(is_numeric($interval) && date('N') != $interval)
     579        if ( is_numeric( $interval ) && date( 'N' ) != $interval ) {
    541580            return;
    542            
     581        }
     582
    543583        // Check monthly interval
    544         if($interval == 'm' && date('j') != 1)
     584        if ( $interval == 'm' && date( 'j' ) != 1 ) {
    545585            return;
    546                    
     586        }
     587
    547588        // Send email
    548589        $has_vulnerabilities = false;
    549         $msg  = '<doctype html><html><head><meta charset="utf-8"></head><body>';
    550         $msg .= '<p>' . __('Hello Friend,', self::$id) . '</p>';
    551         $msg .= '<p>' . sprintf(__('Some vulnerabilities were found in %s, visit the site for more details.', self::$id), '<a href="' . get_bloginfo('url') . '">' . get_bloginfo('name') . '</a>') . '</p>';
    552        
     590        $msg = '<doctype html><html><head><meta charset="utf-8"></head><body>';
     591        $msg .= '<p>' . __( 'Hello Friend,', self::$id ) . '</p>';
     592        $msg .= '<p>' . sprintf( __( 'Some vulnerabilities were found in %s, visit the site for more details.', self::$id ), '<a href="' . get_bloginfo( 'url' ) . '">' . get_bloginfo( 'name' ) . '</a>' ) . '</p>';
     593
    553594        // WordPress
    554         if($report['wordpress']['total'] > 0) {
    555             $list = self::email_vulnerabilities('wordpress');
    556             if(!empty($list)) {
     595        if ( $report['wordpress']['total'] > 0 ) {
     596            $list = self::email_vulnerabilities( 'wordpress' );
     597            if ( ! empty( $list ) ) {
    557598                $has_vulnerabilities = true;
    558599                $msg .= '<p><b>WordPress</b><br>';
    559                 $msg .= join('<br>', $list) . '</p>';
    560             }
    561         }
    562        
     600                $msg .= join( '<br>', $list ) . '</p>';
     601            }
     602        }
     603
    563604        // Plugins
    564         if($report['plugins']['total'] > 0) {
    565             foreach(get_plugins() as $name => $details) {
    566                 $list = self::email_vulnerabilities('plugins', $name);
    567                 if(!empty($list)) {
     605        if ( $report['plugins']['total'] > 0 ) {
     606            foreach ( get_plugins() as $name => $details ) {
     607                $list = self::email_vulnerabilities( 'plugins', $name );
     608                if ( ! empty( $list ) ) {
    568609                    $has_vulnerabilities = true;
    569                     $msg .= '<p><b>' . __('Plugins', self::$id) . ' ' . $details['Name'] . '</b><br>';
    570                     $msg .= join('<br>', $list) . '</p>';
    571                 }
    572             }
    573         }
    574        
     610                    $msg .= '<p><b>' . __( 'Plugins', self::$id ) . ' ' . $details['Name'] . '</b><br>';
     611                    $msg .= join( '<br>', $list ) . '</p>';
     612                }
     613            }
     614        }
     615
    575616        // Themes
    576         if($report['themes']['total'] > 0) {
    577             foreach(wp_get_themes() as $name => $details) {
    578                 $list = self::email_vulnerabilities('themes', $name);
    579                 if(!empty($list)) {
     617        if ( $report['themes']['total'] > 0 ) {
     618            foreach ( wp_get_themes() as $name => $details ) {
     619                $list = self::email_vulnerabilities( 'themes', $name );
     620                if ( ! empty( $list ) ) {
    580621                    $has_vulnerabilities = true;
    581                     $msg .= '<p><b>' . __('Themes', self::$id) . ' ' . $details['Name'] . '</b><br>';
    582                     $msg .= join('<br>', $list) . '</p>';
    583                 }
    584             }
    585         }
    586        
    587         $msg .= '<p>' . __('Hope this help!', self::$id) . '</p>';
     622                    $msg .= '<p><b>' . __( 'Themes', self::$id ) . ' ' . $details['Name'] . '</b><br>';
     623                    $msg .= join( '<br>', $list ) . '</p>';
     624                }
     625            }
     626        }
     627
     628        $msg .= '<p>' . __( 'Hope this help!', self::$id ) . '</p>';
    588629        $msg .= '</body></html>';
    589                
    590         if($has_vulnerabilities) { 
    591             $subject = sprintf(__('Some vulnerabilities were found in %s', self::$id), get_bloginfo('name'));
    592             $headers = array('Content-Type: text/html; charset=UTF-8');
    593             wp_mail($options['email'], $subject, $msg, $headers);
    594         }
    595        
    596     }
    597    
     630
     631        if ( $has_vulnerabilities ) {
     632            $subject = sprintf( __( 'Some vulnerabilities were found in %s', self::$id ), get_bloginfo( 'name' ) );
     633            $headers = array( 'Content-Type: text/html; charset=UTF-8' );
     634            wp_mail( $options['email'], $subject, $msg, $headers );
     635        }
     636
     637    }
     638
    598639    /*
    599640    * List of vulnerabilities to send by mail
    600641    */
    601     static public function email_vulnerabilities($type, $name = null) {
    602 
    603         $report = self::$report[$type];
    604         if(array_key_exists($name, $report))
    605             $report = $report[$name];
    606 
    607         if(!isset($report['vulnerabilities'])) {
     642    static public function email_vulnerabilities( $type, $name = null ) {
     643
     644        $report = self::$report[ $type ];
     645        if ( array_key_exists( $name, $report ) ) {
     646            $report = $report[ $name ];
     647        }
     648
     649        if ( ! isset( $report['vulnerabilities'] ) ) {
    608650            return null;
    609651        }
    610        
    611         $options = get_option(self::$id . '_notification');
    612         $ignored = empty($options['ignored']) ? array() : $options['ignored'];
     652
     653        $options = get_option( self::$id . '_notification' );
     654        $ignored = empty( $options['ignored'] ) ? array() : $options['ignored'];
    613655
    614656        $list = array();
    615        
    616         foreach($report['vulnerabilities'] as $item) {
    617             if(!in_array($item->id, $ignored)) {
    618                 $html  = '<a href="' . esc_url('https://wpvulndb.com/vulnerabilities/' . $item->id) . '" target="_blank">';
    619                 $html .= self::get_vulnerability_title($item);
     657
     658        foreach ( $report['vulnerabilities'] as $item ) {
     659            if ( ! in_array( $item->id, $ignored ) ) {
     660                $html = '<a href="' . esc_url( 'https://wpvulndb.com/vulnerabilities/' . $item->id ) . '" target="_blank">';
     661                $html .= self::get_vulnerability_title( $item );
    620662                $html .= '</a>';
    621663                $list[] = $html;
    622664            }
    623665        }
    624        
     666
    625667        return $list;
    626        
    627     }
    628    
     668
     669    }
     670
    629671}
    630672
    631673
    632674// Activating
    633 register_activation_hook(__FILE__, array('VulnerabiltyAlerts', 'activate'));
     675register_activation_hook( __FILE__, array( 'Vulnerabilty_Alerts', 'activate' ) );
    634676
    635677// Deactivating
    636 register_deactivation_hook(__FILE__, array('VulnerabiltyAlerts', 'deactivate'));
     678register_deactivation_hook( __FILE__, array( 'Vulnerabilty_Alerts', 'deactivate' ) );
    637679
    638680// Initialize
    639 add_action('init', array('VulnerabiltyAlerts', 'init'));
    640 
    641 ?>
     681add_action( 'init', array( 'Vulnerabilty_Alerts', 'init' ) );
     682
Note: See TracChangeset for help on using the changeset viewer.