Plugin Directory

Changeset 3367391


Ignore:
Timestamp:
09/24/2025 07:40:39 PM (6 months ago)
Author:
awesomefootnotes
Message:

Adding the first version of my plugin

Location:
0-day-analytics
Files:
3 deleted
22 edited
1 copied

Legend:

Unmodified
Added
Removed
  • 0-day-analytics/tags/3.7.0/advanced-analytics.php

    r3366898 r3367391  
    1313 * Plugin Name:     WP Control
    1414 * Description:     Take full control of error log, crons, transients, plugins, requests, mails and DB tables.
    15  * Version:         3.6.4
     15 * Version:         3.7.0
    1616 * Author:          Stoil Dobrev
    1717 * Author URI:      https://github.com/sdobreff/
     
    3939// Constants.
    4040if ( ! defined( 'ADVAN_VERSION' ) ) {
    41     define( 'ADVAN_VERSION', '3.6.4' );
     41    define( 'ADVAN_VERSION', '3.7.0' );
    4242    define( 'ADVAN_TEXTDOMAIN', '0-day-analytics' );
    4343    define( 'ADVAN_NAME', 'WP Control' );
  • 0-day-analytics/tags/3.7.0/classes/controllers/class-requests-log.php

    r3343900 r3367391  
    1414use ADVAN\Helpers\Settings;
    1515use ADVAN\Helpers\Context_Helper;
     16use ADVAN\Helpers\Plugin_Theme_Helper;
    1617use ADVAN\Entities\Requests_Log_Entity;
    1718
     
    139140                'requests'       => self::$requests,
    140141                'trace'          => self::get_trace(),
     142                'plugin'         => ( isset( \json_decode( self::$trace, true )[7] ) && isset( \json_decode( self::$trace, true )[7]['file'] ) ) ? self::add_plugin_info_to_collected_item( \json_decode( self::$trace, true )[7]['file'] ) : '',
    141143            );
    142144
     
    326328                'requests'       => self::$requests,
    327329                'trace'          => self::get_trace(),
     330                'plugin'         => ( isset( \json_decode( self::$trace, true )[7] ) && isset( \json_decode( self::$trace, true )[7]['file'] ) ) ? self::add_plugin_info_to_collected_item( \json_decode( self::$trace, true )[7]['file'] ) : '',
    328331            );
    329332
     
    337340            return $response;
    338341        }
     342
     343        /**
     344         * Adds plugin info to the database using the file path collected from the trace.
     345         *
     346         * @param string $message - File path from the trace.
     347         *
     348         * @return string
     349         *
     350         * @since latest
     351         */
     352        private static function add_plugin_info_to_collected_item( string $message ) {
     353
     354            $plugins_dir_basename = basename( \WP_PLUGIN_DIR );
     355
     356            if ( false !== \mb_strpos( $message, $plugins_dir_basename . \DIRECTORY_SEPARATOR ) ) {
     357
     358                $split_plugin = explode( \DIRECTORY_SEPARATOR, $message );
     359
     360                $next        = false;
     361                $plugin_base = '';
     362                foreach ( $split_plugin as $part ) {
     363                    if ( $next ) {
     364                        $plugin_base = $part;
     365                        break;
     366                    }
     367                    if ( $plugins_dir_basename === $part ) {
     368                        $next = true;
     369                    }
     370                }
     371
     372                $plugin = Plugin_Theme_Helper::get_plugin_from_path( $plugin_base );
     373                if ( ! empty( $plugin ) ) {
     374
     375                    return $plugin_base;
     376                }
     377            }
     378
     379            return '';
     380        }
    339381    }
    340382}
  • 0-day-analytics/tags/3.7.0/classes/entities/class-requests-log-entity.php

    r3334916 r3367391  
    1212namespace ADVAN\Entities;
    1313
     14use ADVAN\Helpers\Plugin_Theme_Helper;
     15
    1416// Exit if accessed directly.
    1517if ( ! defined( 'ABSPATH' ) ) {
     
    3234
    3335        /**
     36         * Inner class cache for rendered dorp down with of of the collected data from sites.
     37         *
     38         * @var string
     39         *
     40         * @since latest
     41         */
     42        private static $drop_down_sites_rendered = false;
     43
     44        /**
    3445         * Keeps the info about the columns of the table - name, type.
    3546         *
     
    4152            'id'             => 'int',
    4253            'type'           => 'string',
     54            'plugin'         => 'string',
    4355            'url'            => 'string',
    4456            'page_url'       => 'string',
     
    6678            'id'             => 0,
    6779            'type'           => '',
     80            'plugin'         => '',
    6881            'url'            => '',
    6982            'page_url'       => '',
     
    102115                    id BIGINT unsigned not null auto_increment,
    103116                    type VARCHAR(20) NOT NULL DEFAULT "",
     117                    plugin VARCHAR(200) NOT NULL DEFAULT "",
    104118                    url TEXT(2048),
    105119                    page_url TEXT(2048),
     
    124138
    125139        /**
     140         * Responsible for adding the plugin column to the table (version 3.7.0).
     141         *
     142         * @return array|bool
     143         *
     144         * @since 3.7.0
     145         */
     146        public static function alter_table_370() {
     147            $sql = 'ALTER TABLE `' . self::get_table_name() . '` ADD `plugin` TEXT DEFAULT "" AFTER `type`;';
     148
     149            return Common_Table::execute_query( $sql );
     150        }
     151
     152        /**
    126153         * Returns the table CMS admin fields
    127154         *
     
    134161                'date_added'     => __( 'Date', '0-day-analytics' ),
    135162                'type'           => __( 'Type', '0-day-analytics' ),
     163                'plugin'         => __( 'Plugin Name', '0-day-analytics' ),
    136164                'request_status' => __( 'Status', '0-day-analytics' ),
    137165                'url'            => __( 'URL', '0-day-analytics' ),
     
    142170            );
    143171        }
     172
     173        /**
     174         * Generates drop down with all the subsites that have mail logs.
     175         *
     176         * @param string $selected - The selected (if any) site ID.
     177         * @param string $which - Indicates position of the dropdown (top or bottom).
     178         *
     179         * @return string
     180         *
     181         * @since 3.6.3
     182         */
     183        public static function get_all_plugins_dropdown( $selected = '', $which = '' ): string {
     184
     185            if ( false === self::$drop_down_sites_rendered ) {
     186                $sql = 'SELECT plugin FROM ' . self::get_table_name() . ' GROUP BY plugin ORDER BY plugin DESC';
     187
     188                $results = self::get_results( $sql );
     189                $plugins   = array();
     190                $output  = '';
     191
     192                if ( $results ) {
     193                    foreach ( $results as $result ) {
     194                        if ( ! isset( $result['plugin'] ) || empty( trim( (string) $result['plugin'] ) ) ) {
     195                            continue;
     196                        }
     197                        $details = Plugin_Theme_Helper::get_plugin_from_path( $result['plugin'] );
     198                        $name    = ( $details ) ? $details['Name'] : \sprintf( /* translators: %s: Site ID */ __( '%s', '0-day-analytics' ), (int) $result['plugin'] );
     199                        $plugins[] = array(
     200                            'id'   => $result['plugin'],
     201                            'name' => $name,
     202                        );
     203                    }
     204                }
     205
     206                if ( ! empty( $plugins ) ) {
     207
     208                    $output  = '<select class="plugin_filter" name="plugin_' . \esc_attr( $which ) . '" id="plugin_' . \esc_attr( $which ) . '">';
     209                    $output .= '<option value="-1">' . __( 'All plugins', '0-day-analytics' ) . '</option>';
     210                    foreach ( $plugins as $plugin_info ) {
     211                        if ( isset( $selected ) && ! empty( trim( (string) $selected ) ) && (string) $selected === (string) $plugin_info['id'] ) {
     212                            $output .= '<option value="' . \esc_attr( $plugin_info['id'] ) . '" selected>' . \esc_html( $plugin_info['name'] ) . '</option>';
     213
     214                            continue;
     215                        }
     216                        $output .= '<option value="' . \esc_attr( $plugin_info['id'] ) . '">' . \esc_html( $plugin_info['name'] ) . '</option>';
     217                    }
     218
     219                    $output .= '</select>';
     220                }
     221                self::$drop_down_sites_rendered = $output;
     222            }
     223
     224            return self::$drop_down_sites_rendered;
     225        }
    144226    }
    145227}
  • 0-day-analytics/tags/3.7.0/classes/entities/class-wp-mail-entity.php

    r3366898 r3367391  
    3232         */
    3333        protected static $table = ADVAN_PREFIX . 'wp_mail_log';
     34
     35        /**
     36         * Inner class cache for rendered dorp down with of of the collected data from sites.
     37         *
     38         * @var string
     39         *
     40         * @since latest
     41         */
     42        private static $drop_down_sites_rendered = false;
    3443
    3544        /**
     
    182191         */
    183192        public static function get_all_sites_dropdown( $selected = '', $which = '' ): string {
    184             $sql = 'SELECT blog_id FROM ' . self::get_table_name() . ' GROUP BY blog_id ORDER BY blog_id DESC';
    185 
    186             $results = self::get_results( $sql );
    187             $sites   = array();
    188             $output  = '';
    189 
    190             if ( $results ) {
    191                 foreach ( $results as $result ) {
    192                     $details = \get_blog_details( array( 'blog_id' => $result['blog_id'] ) );
    193                     $name    = ( $details ) ? $details->blogname : \sprintf( /* translators: %s: Site ID */ __( 'Site %s', '0-day-analytics' ), (int) $result['blog_id'] );
    194                     $sites[] = array(
    195                         'id'   => $result['blog_id'],
    196                         'name' => $name,
    197                     );
     193
     194            if ( false === self::$drop_down_sites_rendered ) {
     195                $sql = 'SELECT blog_id FROM ' . self::get_table_name() . ' GROUP BY blog_id ORDER BY blog_id DESC';
     196
     197                $results = self::get_results( $sql );
     198                $sites   = array();
     199                $output  = '';
     200
     201                if ( $results ) {
     202                    foreach ( $results as $result ) {
     203                        $details = \get_blog_details( array( 'blog_id' => $result['blog_id'] ) );
     204                        $name    = ( $details ) ? $details->blogname : \sprintf( /* translators: %s: Site ID */ __( 'Site %s', '0-day-analytics' ), (int) $result['blog_id'] );
     205                        $sites[] = array(
     206                            'id'   => $result['blog_id'],
     207                            'name' => $name,
     208                        );
     209                    }
    198210                }
     211
     212                if ( ! empty( $sites ) ) {
     213
     214                    $output  = '<select class="site_id_filter" name="site_id_' . \esc_attr( $which ) . '" id="site_id_' . \esc_attr( $which ) . '">';
     215                    $output .= '<option value="-1">' . __( 'All sites', '0-day-analytics' ) . '</option>';
     216                    foreach ( $sites as $site_info ) {
     217                        if ( isset( $selected ) && ! empty( trim( (string) $selected ) ) && (int) $selected === (int) $site_info['id'] ) {
     218                            $output .= '<option value="' . \esc_attr( $site_info['id'] ) . '" selected>' . \esc_html( $site_info['name'] ) . '</option>';
     219
     220                            continue;
     221                        }
     222                        $output .= '<option value="' . \esc_attr( $site_info['id'] ) . '">' . \esc_html( $site_info['name'] ) . '</option>';
     223                    }
     224
     225                    $output .= '</select>';
     226                }
     227                self::$drop_down_sites_rendered = $output;
    199228            }
    200229
    201             if ( ! empty( $sites ) ) {
    202 
    203                 $output  = '<select class="site_id_filter" name="site_id_' . \esc_attr( $which ) . '" id="site_id_' . \esc_attr( $which ) . '">';
    204                 $output .= '<option value="-1">' . __( 'All sites', '0-day-analytics' ) . '</option>';
    205                 foreach ( $sites as $site_info ) {
    206                     if ( isset( $selected ) && ! empty( trim( (string) $selected ) ) && (int) $selected === (int) $site_info['id'] ) {
    207                         $output .= '<option value="' . \esc_attr( $site_info['id'] ) . '" selected>' . \esc_html( $site_info['name'] ) . '</option>';
    208 
    209                         continue;
    210                     }
    211                     $output .= '<option value="' . \esc_attr( $site_info['id'] ) . '">' . \esc_html( $site_info['name'] ) . '</option>';
    212                 }
    213 
    214                 $output .= '</select>';
    215             }
    216 
    217             return $output;
     230            return self::$drop_down_sites_rendered;
    218231        }
    219232    }
  • 0-day-analytics/tags/3.7.0/classes/helpers/class-plugin-theme-helper.php

    r3349349 r3367391  
    7979        public static function get_plugins(): array {
    8080            if ( empty( self::$plugins ) ) {
     81                if ( ! \function_exists( 'get_plugins' ) ) {
     82                    include_once ABSPATH . 'wp-admin/includes/plugin.php';
     83                }
    8184                self::$plugins = \get_plugins();
    8285            }
  • 0-day-analytics/tags/3.7.0/classes/lists/class-logs-list.php

    r3363736 r3367391  
    18981898                    $base .= 'code';
    18991899
    1900                     $data['body']  = $event['severity'] . ' ' . $event['message'];
     1900                    $data['body']  = \esc_html( $event['severity'] ) . ' ' . \html_entity_decode( $event['message'] );
    19011901                    $data['title'] = $in;
    19021902                    $data['icon']  = 'data:image/svg+xml;base64,' . $base( file_get_contents( \ADVAN_PLUGIN_ROOT . 'assets/icon.svg' ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode, WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
  • 0-day-analytics/tags/3.7.0/classes/lists/class-requests-list.php

    r3352278 r3367391  
    2222use ADVAN\ControllersApi\Endpoints;
    2323use ADVAN\Lists\Views\Requests_View;
     24use ADVAN\Helpers\Plugin_Theme_Helper;
    2425use ADVAN\Entities\Requests_Log_Entity;
    2526
     
    5253
    5354        public const REQUESTS_MENU_SLUG = 'advan_requests';
     55
     56        public const PLUGIN_FILTER_ACTION = 'filter_plugin';
    5457
    5558        /**
     
    123126        public static function init() {
    124127            \add_filter( 'advan_cron_hooks', array( __CLASS__, 'add_cron_job' ) );
     128            \add_action( 'admin_post_' . self::PLUGIN_FILTER_ACTION, array( Requests_View::class, 'plugin_filter_action' ) );
    125129        }
    126130
     
    297301            $search_string = self::escaped_search_input();
    298302
     303            if ( isset( $_REQUEST['plugin'] ) && ! empty( $_REQUEST['plugin'] ) ) {
     304                if ( -1 === (int) $_REQUEST['plugin'] ) {
     305                    $plugin = -1;
     306                } else {
     307                    $plugin = \sanitize_text_field( \wp_unslash( $_REQUEST['plugin'] ) );
     308                }
     309            } else {
     310                $plugin = '';
     311            }
     312
    299313            $search_sql = '';
    300314
     
    305319                }
    306320                $search_sql .= ') ';
     321            }
     322
     323            if ( '' !== $plugin && -1 !== (int) $plugin ) {
     324                $search_sql .= ' AND plugin = "' . (string) $plugin . '" ';
    307325            }
    308326
     
    524542                        $time,
    525543                    ) . $this->row_actions( $actions ) . $data;
     544
     545                case 'plugin':
     546                    if ( ! empty( $item['plugin'] ) ) {
     547                        $plugin = Plugin_Theme_Helper::get_plugin_from_path( $item['plugin'] );
     548                        if ( ! empty( $plugin ) ) {
     549
     550                            return __( 'Plugin: ', '0-day-analytics' ) . '<b>' . \esc_html( $plugin['Name'] ) . '</b><br>' . \__( 'Current version: ' ) . \esc_html( $plugin['Version'] );
     551                        }
     552                    } else {
     553                        return \esc_html__( 'Core or Unknown', '0-day-analytics' );
     554                    }
    526555            }
    527556        }
     
    706735         */
    707736        public function extra_tablenav( $which ) {
    708 
    709             if ( 'top' === $which ) {
    710                 ?>
     737            if ( isset( $_REQUEST['plugin'] ) && ! empty( $_REQUEST['plugin'] ) ) {
     738                if ( -1 === (int) $_REQUEST['plugin'] ) {
     739                    $plugin = -1;
     740                } else {
     741                    $plugin = \sanitize_text_field( \wp_unslash( $_REQUEST['plugin'] ) );
     742                }
     743            } else {
     744                $plugin = 0;
     745            }
     746            ?>
     747                <div class="alignleft actions bulkactions">
     748                   
     749                    <?php echo Requests_Log_Entity::get_all_plugins_dropdown( $plugin, $which ); ?>
     750                   
     751                </div>
     752                <script>
     753                    jQuery('form .plugin_filter').on('change', function(e) {
     754                        jQuery('form .plugin_filter').val(jQuery(this).val());
     755                        jQuery( this ).closest( 'form' ).attr( 'action', '<?php echo \esc_url( \admin_url( 'admin-post.php' ) ); ?>').append('<input type="hidden" name="action" value="<?php echo \esc_attr( self::PLUGIN_FILTER_ACTION ); ?>">').append('<?php \wp_nonce_field( self::PLUGIN_FILTER_ACTION, self::PLUGIN_FILTER_ACTION . 'nonce' ); ?>').submit();
     756                    });
     757                </script>
     758                <?php
     759
     760                if ( 'top' === $which ) {
     761                    ?>
    711762                <style>
    712763                    .flex {
     
    10751126            if ( json_last_error() === JSON_ERROR_NONE ) {
    10761127
     1128                if ( ! is_array( $encoded ) ) {
     1129                    return $encoded;
     1130                }
     1131
    10771132                foreach ( $encoded as $key => $value ) {
    10781133                    if ( ! empty( $value ) && is_string( $value ) && ! is_numeric( $value ) ) {
  • 0-day-analytics/tags/3.7.0/classes/lists/class-wp-mail-list.php

    r3366898 r3367391  
    241241            } else {
    242242                $site_id = '';
     243            }
     244
     245            if ( isset( $type ) && ! empty( $type ) ) {
     246                $site_id = -1;
    243247            }
    244248
     
    352356            );
    353357
    354             $per_page = $parsed_args['number'];
    355             $offset   = $parsed_args['offset'];
    356 
    357             // $current_page = $this->get_pagenum();
    358             // if ( 1 < $current_page ) {
    359             // $offset = $per_page * ( $current_page - 1 );
    360             // } else {
    361             // $offset = 0;
    362             // }
    363 
    364             $search_string = $parsed_args['search'];
    365             $site_id       = $parsed_args['site_id'];
    366 
    367358            $search_sql = '';
    368 
    369             if ( '' !== $search_string ) {
    370                 $search_sql = 'AND (id LIKE "%' . $wpdb->esc_like( $search_string ) . '%"';
    371                 foreach ( array_keys( WP_Mail_Entity::get_column_names_admin() ) as $value ) {
    372                     $search_sql .= ' OR ' . $value . ' LIKE "%' . esc_sql( $wpdb->esc_like( $search_string ) ) . '%" ';
    373                 }
    374                 $search_sql .= ') ';
    375             }
    376 
    377             if ( '' !== $site_id && -1 !== (int) $site_id ) {
    378                 $search_sql .= ' AND blog_id = ' . (int) $site_id . ' ';
    379             } elseif ( ( '' === $site_id && -1 !== (int) $site_id ) && WP_Helper::is_multisite() && ! \is_main_site() ) {
    380                 $search_sql .= ' AND blog_id = ' . (int) \get_current_blog_id() . ' ';
    381             }
    382 
    383             if ( ! empty( $parsed_args['type'] ) ) {
    384                 if ( 'successful' === $parsed_args['type'] ) {
    385                     $search_sql .= ' AND status = 1';
    386                 }
    387                 if ( 'unsuccessful' === $parsed_args['type'] ) {
    388                     $search_sql .= ' AND status = 0';
    389                 }
    390                 if ( 'html' === $parsed_args['type'] ) {
    391                     $search_sql .= ' AND is_html = 1';
    392                 }
    393                 if ( 'text' === $parsed_args['type'] ) {
    394                     $search_sql .= ' AND is_html != 1';
    395                 }
    396                 if ( 'attachments' === $parsed_args['type'] ) {
    397                     $search_sql .= ' AND attachments != "[]"';
    398                 }
    399             }
    400359
    401360            $orderby = $parsed_args['orderby'];
     
    407366            $wpdb_table = $this->get_table_name();
    408367
    409             $query = 'SELECT
     368            if ( ! isset( $parsed_args['all'] ) ) {
     369
     370                $per_page = $parsed_args['number'];
     371                $offset   = $parsed_args['offset'];
     372
     373                // $current_page = $this->get_pagenum();
     374                // if ( 1 < $current_page ) {
     375                // $offset = $per_page * ( $current_page - 1 );
     376                // } else {
     377                // $offset = 0;
     378                // }
     379
     380                $search_string = $parsed_args['search'];
     381                $site_id       = $parsed_args['site_id'];
     382
     383                if ( '' !== $search_string ) {
     384                    $search_sql = 'AND (id LIKE "%' . $wpdb->esc_like( $search_string ) . '%"';
     385                    foreach ( array_keys( WP_Mail_Entity::get_column_names_admin() ) as $value ) {
     386                        $search_sql .= ' OR ' . $value . ' LIKE "%' . esc_sql( $wpdb->esc_like( $search_string ) ) . '%" ';
     387                    }
     388                    $search_sql .= ') ';
     389                }
     390
     391                if ( '' !== $site_id && -1 !== (int) $site_id ) {
     392                    $search_sql .= ' AND blog_id = ' . (int) $site_id . ' ';
     393                } elseif ( ( '' === $site_id && -1 !== (int) $site_id ) && WP_Helper::is_multisite() && ! \is_main_site() ) {
     394                    $search_sql .= ' AND blog_id = ' . (int) \get_current_blog_id() . ' ';
     395                }
     396
     397                if ( ! empty( $parsed_args['type'] ) ) {
     398                    if ( 'successful' === $parsed_args['type'] ) {
     399                        $search_sql .= ' AND status = 1';
     400                    }
     401                    if ( 'unsuccessful' === $parsed_args['type'] ) {
     402                        $search_sql .= ' AND status = 0';
     403                    }
     404                    if ( 'html' === $parsed_args['type'] ) {
     405                        $search_sql .= ' AND is_html = 1';
     406                    }
     407                    if ( 'text' === $parsed_args['type'] ) {
     408                        $search_sql .= ' AND is_html != 1';
     409                    }
     410                    if ( 'attachments' === $parsed_args['type'] ) {
     411                        $search_sql .= ' AND attachments != "[]"';
     412                    }
     413                }
     414
     415                $query = 'SELECT
    410416                ' . implode( ', ', \array_keys( WP_Mail_Entity::get_fields() ) ) . '
    411417              FROM ' . $wpdb_table . '  WHERE 1=1 ' . $search_sql . ' ORDER BY ' . $orderby . ' ' . $order;
    412418
    413             if ( ! isset( $parsed_args['all'] ) ) {
    414                 $query .= $wpdb->prepare( ' LIMIT %d OFFSET %d;', $per_page, $offset );
     419                if ( ! isset( $parsed_args['all'] ) ) {
     420                    $query .= $wpdb->prepare( ' LIMIT %d OFFSET %d;', $per_page, $offset );
     421                }
     422            } else {
     423
     424                $query = 'SELECT
     425                ' . implode( ', ', \array_keys( WP_Mail_Entity::get_fields() ) ) . '
     426              FROM ' . $wpdb_table . '  WHERE 1=1 ' . $search_sql . ' ORDER BY ' . $orderby . ' ' . $order;
    415427            }
    416428
     
    10721084                    }
    10731085                }
     1086
     1087                $type = ! empty( $_GET['mail_type'] ) ? \sanitize_text_field( \wp_unslash( $_GET['mail_type'] ) ) : '';
     1088
     1089                if ( isset( $type ) && ! empty( $type ) ) {
     1090                    $site_id = -1;
     1091                }
    10741092                ?>
    10751093                <div class="alignleft actions bulkactions">
  • 0-day-analytics/tags/3.7.0/classes/lists/views/class-requests-view.php

    r3349349 r3367391  
    653653            }
    654654        }
     655
     656        /**
     657         * Responsible for filtering table by plugin.
     658         *
     659         * @return void
     660         *
     661         * @since latest
     662         */
     663        public static function plugin_filter_action() {
     664
     665            if ( isset( $_REQUEST['plugin_top'] ) || isset( $_REQUEST['plugin_filter_bottom'] ) ) {
     666
     667                if ( \check_admin_referer( Requests_List::PLUGIN_FILTER_ACTION, Requests_List::PLUGIN_FILTER_ACTION . 'nonce' ) ) {
     668                    $id = $_REQUEST['plugin_top']; // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
     669
     670                    \wp_safe_redirect(
     671                        \remove_query_arg(
     672                            array( 'deleted' ),
     673                            \add_query_arg(
     674                                array(
     675                                    'page'       => Requests_List::REQUESTS_MENU_SLUG,
     676                                    Requests_List::SEARCH_INPUT => Requests_List::escaped_search_input(),
     677                                    'plugin' => rawurlencode( $id ),
     678                                ),
     679                                \admin_url( 'admin.php' )
     680                            )
     681                        )
     682                    );
     683                    exit;
     684                }
     685            }
     686        }
    655687    }
    656688}
  • 0-day-analytics/tags/3.7.0/classes/migration/class-migration.php

    r3366891 r3367391  
    1313namespace ADVAN\Migration;
    1414
     15use ADVAN\Helpers\Settings;
    1516use ADVAN\Entities\Common_Table;
    16 use ADVAN\Helpers\Settings;
    1717use ADVAN\Entities\WP_Mail_Entity;
     18use ADVAN\Entities\Requests_Log_Entity;
    1819use ADVAN\Migration\Abstract_Migration;
    1920
     
    197198            }
    198199        }
     200        /**
     201         * Migrates the plugin up-to version 3.7.0
     202         *
     203         * @return void
     204         *
     205         * @since 3.7.0
     206         */
     207        public static function migrate_up_to_370() {
     208            if ( \class_exists( '\ADVAN\Entities\Requests_Log_Entity' ) ) {
     209                if ( Common_Table::check_table_exists( Requests_Log_Entity::get_table_name() ) && ! Common_Table::check_column( 'plugin', 'text', Requests_Log_Entity::get_table_name() ) ) {
     210                    Requests_Log_Entity::alter_table_370();
     211                }
     212            }
     213        }
    199214    }
    200215}
  • 0-day-analytics/tags/3.7.0/readme.txt

    r3366898 r3367391  
    44Tested up to: 6.8.2
    55Requires PHP: 7.4
    6 Stable tag: 3.6.4
     6Stable tag: 3.7.0
    77License: GPLv3 or later
    88License URI: http://www.gnu.org/licenses/gpl-3.0.txt
     
    108108== Changelog ==
    109109
     110= 3.7.0 =
     111Mail filtering fixes, added plugins filter to requests view, fixed HTML entities in the browser push notifications, bug fixes and improvements.
     112
    110113= 3.6.4 =
    111114Fixed problem when there are no blog details (multisite), thanks to @lucianwpwhite .
  • 0-day-analytics/trunk/advanced-analytics.php

    r3366898 r3367391  
    1313 * Plugin Name:     WP Control
    1414 * Description:     Take full control of error log, crons, transients, plugins, requests, mails and DB tables.
    15  * Version:         3.6.4
     15 * Version:         3.7.0
    1616 * Author:          Stoil Dobrev
    1717 * Author URI:      https://github.com/sdobreff/
     
    3939// Constants.
    4040if ( ! defined( 'ADVAN_VERSION' ) ) {
    41     define( 'ADVAN_VERSION', '3.6.4' );
     41    define( 'ADVAN_VERSION', '3.7.0' );
    4242    define( 'ADVAN_TEXTDOMAIN', '0-day-analytics' );
    4343    define( 'ADVAN_NAME', 'WP Control' );
  • 0-day-analytics/trunk/classes/controllers/class-requests-log.php

    r3343900 r3367391  
    1414use ADVAN\Helpers\Settings;
    1515use ADVAN\Helpers\Context_Helper;
     16use ADVAN\Helpers\Plugin_Theme_Helper;
    1617use ADVAN\Entities\Requests_Log_Entity;
    1718
     
    139140                'requests'       => self::$requests,
    140141                'trace'          => self::get_trace(),
     142                'plugin'         => ( isset( \json_decode( self::$trace, true )[7] ) && isset( \json_decode( self::$trace, true )[7]['file'] ) ) ? self::add_plugin_info_to_collected_item( \json_decode( self::$trace, true )[7]['file'] ) : '',
    141143            );
    142144
     
    326328                'requests'       => self::$requests,
    327329                'trace'          => self::get_trace(),
     330                'plugin'         => ( isset( \json_decode( self::$trace, true )[7] ) && isset( \json_decode( self::$trace, true )[7]['file'] ) ) ? self::add_plugin_info_to_collected_item( \json_decode( self::$trace, true )[7]['file'] ) : '',
    328331            );
    329332
     
    337340            return $response;
    338341        }
     342
     343        /**
     344         * Adds plugin info to the database using the file path collected from the trace.
     345         *
     346         * @param string $message - File path from the trace.
     347         *
     348         * @return string
     349         *
     350         * @since latest
     351         */
     352        private static function add_plugin_info_to_collected_item( string $message ) {
     353
     354            $plugins_dir_basename = basename( \WP_PLUGIN_DIR );
     355
     356            if ( false !== \mb_strpos( $message, $plugins_dir_basename . \DIRECTORY_SEPARATOR ) ) {
     357
     358                $split_plugin = explode( \DIRECTORY_SEPARATOR, $message );
     359
     360                $next        = false;
     361                $plugin_base = '';
     362                foreach ( $split_plugin as $part ) {
     363                    if ( $next ) {
     364                        $plugin_base = $part;
     365                        break;
     366                    }
     367                    if ( $plugins_dir_basename === $part ) {
     368                        $next = true;
     369                    }
     370                }
     371
     372                $plugin = Plugin_Theme_Helper::get_plugin_from_path( $plugin_base );
     373                if ( ! empty( $plugin ) ) {
     374
     375                    return $plugin_base;
     376                }
     377            }
     378
     379            return '';
     380        }
    339381    }
    340382}
  • 0-day-analytics/trunk/classes/entities/class-requests-log-entity.php

    r3334916 r3367391  
    1212namespace ADVAN\Entities;
    1313
     14use ADVAN\Helpers\Plugin_Theme_Helper;
     15
    1416// Exit if accessed directly.
    1517if ( ! defined( 'ABSPATH' ) ) {
     
    3234
    3335        /**
     36         * Inner class cache for rendered dorp down with of of the collected data from sites.
     37         *
     38         * @var string
     39         *
     40         * @since latest
     41         */
     42        private static $drop_down_sites_rendered = false;
     43
     44        /**
    3445         * Keeps the info about the columns of the table - name, type.
    3546         *
     
    4152            'id'             => 'int',
    4253            'type'           => 'string',
     54            'plugin'         => 'string',
    4355            'url'            => 'string',
    4456            'page_url'       => 'string',
     
    6678            'id'             => 0,
    6779            'type'           => '',
     80            'plugin'         => '',
    6881            'url'            => '',
    6982            'page_url'       => '',
     
    102115                    id BIGINT unsigned not null auto_increment,
    103116                    type VARCHAR(20) NOT NULL DEFAULT "",
     117                    plugin VARCHAR(200) NOT NULL DEFAULT "",
    104118                    url TEXT(2048),
    105119                    page_url TEXT(2048),
     
    124138
    125139        /**
     140         * Responsible for adding the plugin column to the table (version 3.7.0).
     141         *
     142         * @return array|bool
     143         *
     144         * @since 3.7.0
     145         */
     146        public static function alter_table_370() {
     147            $sql = 'ALTER TABLE `' . self::get_table_name() . '` ADD `plugin` TEXT DEFAULT "" AFTER `type`;';
     148
     149            return Common_Table::execute_query( $sql );
     150        }
     151
     152        /**
    126153         * Returns the table CMS admin fields
    127154         *
     
    134161                'date_added'     => __( 'Date', '0-day-analytics' ),
    135162                'type'           => __( 'Type', '0-day-analytics' ),
     163                'plugin'         => __( 'Plugin Name', '0-day-analytics' ),
    136164                'request_status' => __( 'Status', '0-day-analytics' ),
    137165                'url'            => __( 'URL', '0-day-analytics' ),
     
    142170            );
    143171        }
     172
     173        /**
     174         * Generates drop down with all the subsites that have mail logs.
     175         *
     176         * @param string $selected - The selected (if any) site ID.
     177         * @param string $which - Indicates position of the dropdown (top or bottom).
     178         *
     179         * @return string
     180         *
     181         * @since 3.6.3
     182         */
     183        public static function get_all_plugins_dropdown( $selected = '', $which = '' ): string {
     184
     185            if ( false === self::$drop_down_sites_rendered ) {
     186                $sql = 'SELECT plugin FROM ' . self::get_table_name() . ' GROUP BY plugin ORDER BY plugin DESC';
     187
     188                $results = self::get_results( $sql );
     189                $plugins   = array();
     190                $output  = '';
     191
     192                if ( $results ) {
     193                    foreach ( $results as $result ) {
     194                        if ( ! isset( $result['plugin'] ) || empty( trim( (string) $result['plugin'] ) ) ) {
     195                            continue;
     196                        }
     197                        $details = Plugin_Theme_Helper::get_plugin_from_path( $result['plugin'] );
     198                        $name    = ( $details ) ? $details['Name'] : \sprintf( /* translators: %s: Site ID */ __( '%s', '0-day-analytics' ), (int) $result['plugin'] );
     199                        $plugins[] = array(
     200                            'id'   => $result['plugin'],
     201                            'name' => $name,
     202                        );
     203                    }
     204                }
     205
     206                if ( ! empty( $plugins ) ) {
     207
     208                    $output  = '<select class="plugin_filter" name="plugin_' . \esc_attr( $which ) . '" id="plugin_' . \esc_attr( $which ) . '">';
     209                    $output .= '<option value="-1">' . __( 'All plugins', '0-day-analytics' ) . '</option>';
     210                    foreach ( $plugins as $plugin_info ) {
     211                        if ( isset( $selected ) && ! empty( trim( (string) $selected ) ) && (string) $selected === (string) $plugin_info['id'] ) {
     212                            $output .= '<option value="' . \esc_attr( $plugin_info['id'] ) . '" selected>' . \esc_html( $plugin_info['name'] ) . '</option>';
     213
     214                            continue;
     215                        }
     216                        $output .= '<option value="' . \esc_attr( $plugin_info['id'] ) . '">' . \esc_html( $plugin_info['name'] ) . '</option>';
     217                    }
     218
     219                    $output .= '</select>';
     220                }
     221                self::$drop_down_sites_rendered = $output;
     222            }
     223
     224            return self::$drop_down_sites_rendered;
     225        }
    144226    }
    145227}
  • 0-day-analytics/trunk/classes/entities/class-wp-mail-entity.php

    r3366898 r3367391  
    3232         */
    3333        protected static $table = ADVAN_PREFIX . 'wp_mail_log';
     34
     35        /**
     36         * Inner class cache for rendered dorp down with of of the collected data from sites.
     37         *
     38         * @var string
     39         *
     40         * @since latest
     41         */
     42        private static $drop_down_sites_rendered = false;
    3443
    3544        /**
     
    182191         */
    183192        public static function get_all_sites_dropdown( $selected = '', $which = '' ): string {
    184             $sql = 'SELECT blog_id FROM ' . self::get_table_name() . ' GROUP BY blog_id ORDER BY blog_id DESC';
    185 
    186             $results = self::get_results( $sql );
    187             $sites   = array();
    188             $output  = '';
    189 
    190             if ( $results ) {
    191                 foreach ( $results as $result ) {
    192                     $details = \get_blog_details( array( 'blog_id' => $result['blog_id'] ) );
    193                     $name    = ( $details ) ? $details->blogname : \sprintf( /* translators: %s: Site ID */ __( 'Site %s', '0-day-analytics' ), (int) $result['blog_id'] );
    194                     $sites[] = array(
    195                         'id'   => $result['blog_id'],
    196                         'name' => $name,
    197                     );
     193
     194            if ( false === self::$drop_down_sites_rendered ) {
     195                $sql = 'SELECT blog_id FROM ' . self::get_table_name() . ' GROUP BY blog_id ORDER BY blog_id DESC';
     196
     197                $results = self::get_results( $sql );
     198                $sites   = array();
     199                $output  = '';
     200
     201                if ( $results ) {
     202                    foreach ( $results as $result ) {
     203                        $details = \get_blog_details( array( 'blog_id' => $result['blog_id'] ) );
     204                        $name    = ( $details ) ? $details->blogname : \sprintf( /* translators: %s: Site ID */ __( 'Site %s', '0-day-analytics' ), (int) $result['blog_id'] );
     205                        $sites[] = array(
     206                            'id'   => $result['blog_id'],
     207                            'name' => $name,
     208                        );
     209                    }
    198210                }
     211
     212                if ( ! empty( $sites ) ) {
     213
     214                    $output  = '<select class="site_id_filter" name="site_id_' . \esc_attr( $which ) . '" id="site_id_' . \esc_attr( $which ) . '">';
     215                    $output .= '<option value="-1">' . __( 'All sites', '0-day-analytics' ) . '</option>';
     216                    foreach ( $sites as $site_info ) {
     217                        if ( isset( $selected ) && ! empty( trim( (string) $selected ) ) && (int) $selected === (int) $site_info['id'] ) {
     218                            $output .= '<option value="' . \esc_attr( $site_info['id'] ) . '" selected>' . \esc_html( $site_info['name'] ) . '</option>';
     219
     220                            continue;
     221                        }
     222                        $output .= '<option value="' . \esc_attr( $site_info['id'] ) . '">' . \esc_html( $site_info['name'] ) . '</option>';
     223                    }
     224
     225                    $output .= '</select>';
     226                }
     227                self::$drop_down_sites_rendered = $output;
    199228            }
    200229
    201             if ( ! empty( $sites ) ) {
    202 
    203                 $output  = '<select class="site_id_filter" name="site_id_' . \esc_attr( $which ) . '" id="site_id_' . \esc_attr( $which ) . '">';
    204                 $output .= '<option value="-1">' . __( 'All sites', '0-day-analytics' ) . '</option>';
    205                 foreach ( $sites as $site_info ) {
    206                     if ( isset( $selected ) && ! empty( trim( (string) $selected ) ) && (int) $selected === (int) $site_info['id'] ) {
    207                         $output .= '<option value="' . \esc_attr( $site_info['id'] ) . '" selected>' . \esc_html( $site_info['name'] ) . '</option>';
    208 
    209                         continue;
    210                     }
    211                     $output .= '<option value="' . \esc_attr( $site_info['id'] ) . '">' . \esc_html( $site_info['name'] ) . '</option>';
    212                 }
    213 
    214                 $output .= '</select>';
    215             }
    216 
    217             return $output;
     230            return self::$drop_down_sites_rendered;
    218231        }
    219232    }
  • 0-day-analytics/trunk/classes/helpers/class-plugin-theme-helper.php

    r3349349 r3367391  
    7979        public static function get_plugins(): array {
    8080            if ( empty( self::$plugins ) ) {
     81                if ( ! \function_exists( 'get_plugins' ) ) {
     82                    include_once ABSPATH . 'wp-admin/includes/plugin.php';
     83                }
    8184                self::$plugins = \get_plugins();
    8285            }
  • 0-day-analytics/trunk/classes/lists/class-logs-list.php

    r3363736 r3367391  
    18981898                    $base .= 'code';
    18991899
    1900                     $data['body']  = $event['severity'] . ' ' . $event['message'];
     1900                    $data['body']  = \esc_html( $event['severity'] ) . ' ' . \html_entity_decode( $event['message'] );
    19011901                    $data['title'] = $in;
    19021902                    $data['icon']  = 'data:image/svg+xml;base64,' . $base( file_get_contents( \ADVAN_PLUGIN_ROOT . 'assets/icon.svg' ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode, WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
  • 0-day-analytics/trunk/classes/lists/class-requests-list.php

    r3352278 r3367391  
    2222use ADVAN\ControllersApi\Endpoints;
    2323use ADVAN\Lists\Views\Requests_View;
     24use ADVAN\Helpers\Plugin_Theme_Helper;
    2425use ADVAN\Entities\Requests_Log_Entity;
    2526
     
    5253
    5354        public const REQUESTS_MENU_SLUG = 'advan_requests';
     55
     56        public const PLUGIN_FILTER_ACTION = 'filter_plugin';
    5457
    5558        /**
     
    123126        public static function init() {
    124127            \add_filter( 'advan_cron_hooks', array( __CLASS__, 'add_cron_job' ) );
     128            \add_action( 'admin_post_' . self::PLUGIN_FILTER_ACTION, array( Requests_View::class, 'plugin_filter_action' ) );
    125129        }
    126130
     
    297301            $search_string = self::escaped_search_input();
    298302
     303            if ( isset( $_REQUEST['plugin'] ) && ! empty( $_REQUEST['plugin'] ) ) {
     304                if ( -1 === (int) $_REQUEST['plugin'] ) {
     305                    $plugin = -1;
     306                } else {
     307                    $plugin = \sanitize_text_field( \wp_unslash( $_REQUEST['plugin'] ) );
     308                }
     309            } else {
     310                $plugin = '';
     311            }
     312
    299313            $search_sql = '';
    300314
     
    305319                }
    306320                $search_sql .= ') ';
     321            }
     322
     323            if ( '' !== $plugin && -1 !== (int) $plugin ) {
     324                $search_sql .= ' AND plugin = "' . (string) $plugin . '" ';
    307325            }
    308326
     
    524542                        $time,
    525543                    ) . $this->row_actions( $actions ) . $data;
     544
     545                case 'plugin':
     546                    if ( ! empty( $item['plugin'] ) ) {
     547                        $plugin = Plugin_Theme_Helper::get_plugin_from_path( $item['plugin'] );
     548                        if ( ! empty( $plugin ) ) {
     549
     550                            return __( 'Plugin: ', '0-day-analytics' ) . '<b>' . \esc_html( $plugin['Name'] ) . '</b><br>' . \__( 'Current version: ' ) . \esc_html( $plugin['Version'] );
     551                        }
     552                    } else {
     553                        return \esc_html__( 'Core or Unknown', '0-day-analytics' );
     554                    }
    526555            }
    527556        }
     
    706735         */
    707736        public function extra_tablenav( $which ) {
    708 
    709             if ( 'top' === $which ) {
    710                 ?>
     737            if ( isset( $_REQUEST['plugin'] ) && ! empty( $_REQUEST['plugin'] ) ) {
     738                if ( -1 === (int) $_REQUEST['plugin'] ) {
     739                    $plugin = -1;
     740                } else {
     741                    $plugin = \sanitize_text_field( \wp_unslash( $_REQUEST['plugin'] ) );
     742                }
     743            } else {
     744                $plugin = 0;
     745            }
     746            ?>
     747                <div class="alignleft actions bulkactions">
     748                   
     749                    <?php echo Requests_Log_Entity::get_all_plugins_dropdown( $plugin, $which ); ?>
     750                   
     751                </div>
     752                <script>
     753                    jQuery('form .plugin_filter').on('change', function(e) {
     754                        jQuery('form .plugin_filter').val(jQuery(this).val());
     755                        jQuery( this ).closest( 'form' ).attr( 'action', '<?php echo \esc_url( \admin_url( 'admin-post.php' ) ); ?>').append('<input type="hidden" name="action" value="<?php echo \esc_attr( self::PLUGIN_FILTER_ACTION ); ?>">').append('<?php \wp_nonce_field( self::PLUGIN_FILTER_ACTION, self::PLUGIN_FILTER_ACTION . 'nonce' ); ?>').submit();
     756                    });
     757                </script>
     758                <?php
     759
     760                if ( 'top' === $which ) {
     761                    ?>
    711762                <style>
    712763                    .flex {
     
    10751126            if ( json_last_error() === JSON_ERROR_NONE ) {
    10761127
     1128                if ( ! is_array( $encoded ) ) {
     1129                    return $encoded;
     1130                }
     1131
    10771132                foreach ( $encoded as $key => $value ) {
    10781133                    if ( ! empty( $value ) && is_string( $value ) && ! is_numeric( $value ) ) {
  • 0-day-analytics/trunk/classes/lists/class-wp-mail-list.php

    r3366898 r3367391  
    241241            } else {
    242242                $site_id = '';
     243            }
     244
     245            if ( isset( $type ) && ! empty( $type ) ) {
     246                $site_id = -1;
    243247            }
    244248
     
    352356            );
    353357
    354             $per_page = $parsed_args['number'];
    355             $offset   = $parsed_args['offset'];
    356 
    357             // $current_page = $this->get_pagenum();
    358             // if ( 1 < $current_page ) {
    359             // $offset = $per_page * ( $current_page - 1 );
    360             // } else {
    361             // $offset = 0;
    362             // }
    363 
    364             $search_string = $parsed_args['search'];
    365             $site_id       = $parsed_args['site_id'];
    366 
    367358            $search_sql = '';
    368 
    369             if ( '' !== $search_string ) {
    370                 $search_sql = 'AND (id LIKE "%' . $wpdb->esc_like( $search_string ) . '%"';
    371                 foreach ( array_keys( WP_Mail_Entity::get_column_names_admin() ) as $value ) {
    372                     $search_sql .= ' OR ' . $value . ' LIKE "%' . esc_sql( $wpdb->esc_like( $search_string ) ) . '%" ';
    373                 }
    374                 $search_sql .= ') ';
    375             }
    376 
    377             if ( '' !== $site_id && -1 !== (int) $site_id ) {
    378                 $search_sql .= ' AND blog_id = ' . (int) $site_id . ' ';
    379             } elseif ( ( '' === $site_id && -1 !== (int) $site_id ) && WP_Helper::is_multisite() && ! \is_main_site() ) {
    380                 $search_sql .= ' AND blog_id = ' . (int) \get_current_blog_id() . ' ';
    381             }
    382 
    383             if ( ! empty( $parsed_args['type'] ) ) {
    384                 if ( 'successful' === $parsed_args['type'] ) {
    385                     $search_sql .= ' AND status = 1';
    386                 }
    387                 if ( 'unsuccessful' === $parsed_args['type'] ) {
    388                     $search_sql .= ' AND status = 0';
    389                 }
    390                 if ( 'html' === $parsed_args['type'] ) {
    391                     $search_sql .= ' AND is_html = 1';
    392                 }
    393                 if ( 'text' === $parsed_args['type'] ) {
    394                     $search_sql .= ' AND is_html != 1';
    395                 }
    396                 if ( 'attachments' === $parsed_args['type'] ) {
    397                     $search_sql .= ' AND attachments != "[]"';
    398                 }
    399             }
    400359
    401360            $orderby = $parsed_args['orderby'];
     
    407366            $wpdb_table = $this->get_table_name();
    408367
    409             $query = 'SELECT
     368            if ( ! isset( $parsed_args['all'] ) ) {
     369
     370                $per_page = $parsed_args['number'];
     371                $offset   = $parsed_args['offset'];
     372
     373                // $current_page = $this->get_pagenum();
     374                // if ( 1 < $current_page ) {
     375                // $offset = $per_page * ( $current_page - 1 );
     376                // } else {
     377                // $offset = 0;
     378                // }
     379
     380                $search_string = $parsed_args['search'];
     381                $site_id       = $parsed_args['site_id'];
     382
     383                if ( '' !== $search_string ) {
     384                    $search_sql = 'AND (id LIKE "%' . $wpdb->esc_like( $search_string ) . '%"';
     385                    foreach ( array_keys( WP_Mail_Entity::get_column_names_admin() ) as $value ) {
     386                        $search_sql .= ' OR ' . $value . ' LIKE "%' . esc_sql( $wpdb->esc_like( $search_string ) ) . '%" ';
     387                    }
     388                    $search_sql .= ') ';
     389                }
     390
     391                if ( '' !== $site_id && -1 !== (int) $site_id ) {
     392                    $search_sql .= ' AND blog_id = ' . (int) $site_id . ' ';
     393                } elseif ( ( '' === $site_id && -1 !== (int) $site_id ) && WP_Helper::is_multisite() && ! \is_main_site() ) {
     394                    $search_sql .= ' AND blog_id = ' . (int) \get_current_blog_id() . ' ';
     395                }
     396
     397                if ( ! empty( $parsed_args['type'] ) ) {
     398                    if ( 'successful' === $parsed_args['type'] ) {
     399                        $search_sql .= ' AND status = 1';
     400                    }
     401                    if ( 'unsuccessful' === $parsed_args['type'] ) {
     402                        $search_sql .= ' AND status = 0';
     403                    }
     404                    if ( 'html' === $parsed_args['type'] ) {
     405                        $search_sql .= ' AND is_html = 1';
     406                    }
     407                    if ( 'text' === $parsed_args['type'] ) {
     408                        $search_sql .= ' AND is_html != 1';
     409                    }
     410                    if ( 'attachments' === $parsed_args['type'] ) {
     411                        $search_sql .= ' AND attachments != "[]"';
     412                    }
     413                }
     414
     415                $query = 'SELECT
    410416                ' . implode( ', ', \array_keys( WP_Mail_Entity::get_fields() ) ) . '
    411417              FROM ' . $wpdb_table . '  WHERE 1=1 ' . $search_sql . ' ORDER BY ' . $orderby . ' ' . $order;
    412418
    413             if ( ! isset( $parsed_args['all'] ) ) {
    414                 $query .= $wpdb->prepare( ' LIMIT %d OFFSET %d;', $per_page, $offset );
     419                if ( ! isset( $parsed_args['all'] ) ) {
     420                    $query .= $wpdb->prepare( ' LIMIT %d OFFSET %d;', $per_page, $offset );
     421                }
     422            } else {
     423
     424                $query = 'SELECT
     425                ' . implode( ', ', \array_keys( WP_Mail_Entity::get_fields() ) ) . '
     426              FROM ' . $wpdb_table . '  WHERE 1=1 ' . $search_sql . ' ORDER BY ' . $orderby . ' ' . $order;
    415427            }
    416428
     
    10721084                    }
    10731085                }
     1086
     1087                $type = ! empty( $_GET['mail_type'] ) ? \sanitize_text_field( \wp_unslash( $_GET['mail_type'] ) ) : '';
     1088
     1089                if ( isset( $type ) && ! empty( $type ) ) {
     1090                    $site_id = -1;
     1091                }
    10741092                ?>
    10751093                <div class="alignleft actions bulkactions">
  • 0-day-analytics/trunk/classes/lists/views/class-requests-view.php

    r3349349 r3367391  
    653653            }
    654654        }
     655
     656        /**
     657         * Responsible for filtering table by plugin.
     658         *
     659         * @return void
     660         *
     661         * @since latest
     662         */
     663        public static function plugin_filter_action() {
     664
     665            if ( isset( $_REQUEST['plugin_top'] ) || isset( $_REQUEST['plugin_filter_bottom'] ) ) {
     666
     667                if ( \check_admin_referer( Requests_List::PLUGIN_FILTER_ACTION, Requests_List::PLUGIN_FILTER_ACTION . 'nonce' ) ) {
     668                    $id = $_REQUEST['plugin_top']; // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
     669
     670                    \wp_safe_redirect(
     671                        \remove_query_arg(
     672                            array( 'deleted' ),
     673                            \add_query_arg(
     674                                array(
     675                                    'page'       => Requests_List::REQUESTS_MENU_SLUG,
     676                                    Requests_List::SEARCH_INPUT => Requests_List::escaped_search_input(),
     677                                    'plugin' => rawurlencode( $id ),
     678                                ),
     679                                \admin_url( 'admin.php' )
     680                            )
     681                        )
     682                    );
     683                    exit;
     684                }
     685            }
     686        }
    655687    }
    656688}
  • 0-day-analytics/trunk/classes/migration/class-migration.php

    r3366891 r3367391  
    1313namespace ADVAN\Migration;
    1414
     15use ADVAN\Helpers\Settings;
    1516use ADVAN\Entities\Common_Table;
    16 use ADVAN\Helpers\Settings;
    1717use ADVAN\Entities\WP_Mail_Entity;
     18use ADVAN\Entities\Requests_Log_Entity;
    1819use ADVAN\Migration\Abstract_Migration;
    1920
     
    197198            }
    198199        }
     200        /**
     201         * Migrates the plugin up-to version 3.7.0
     202         *
     203         * @return void
     204         *
     205         * @since 3.7.0
     206         */
     207        public static function migrate_up_to_370() {
     208            if ( \class_exists( '\ADVAN\Entities\Requests_Log_Entity' ) ) {
     209                if ( Common_Table::check_table_exists( Requests_Log_Entity::get_table_name() ) && ! Common_Table::check_column( 'plugin', 'text', Requests_Log_Entity::get_table_name() ) ) {
     210                    Requests_Log_Entity::alter_table_370();
     211                }
     212            }
     213        }
    199214    }
    200215}
  • 0-day-analytics/trunk/readme.txt

    r3366898 r3367391  
    44Tested up to: 6.8.2
    55Requires PHP: 7.4
    6 Stable tag: 3.6.4
     6Stable tag: 3.7.0
    77License: GPLv3 or later
    88License URI: http://www.gnu.org/licenses/gpl-3.0.txt
     
    108108== Changelog ==
    109109
     110= 3.7.0 =
     111Mail filtering fixes, added plugins filter to requests view, fixed HTML entities in the browser push notifications, bug fixes and improvements.
     112
    110113= 3.6.4 =
    111114Fixed problem when there are no blog details (multisite), thanks to @lucianwpwhite .
Note: See TracChangeset for help on using the changeset viewer.