| @@ -1,12 +1,11 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Elementor\Core\Logger; |
| 3 | 3 | |
| 4 | 4 | use Elementor\Modules\System_Info\Reporters\Base; |
| 5 | -use Elementor\Utils; | |
| 6 | 5 | |
| 7 | 6 | if ( ! defined( 'ABSPATH' ) ) { |
| 8 | - exit; // Exit if accessed directly. | |
| 7 | + exit; // Exit if accessed directly | |
| 9 | 8 | } |
| 10 | 9 | |
| 11 | 10 | /** |
| 12 | 11 | * Elementor Log reporter. |
| @@ -21,21 +20,11 @@ | ||
| 21 | 20 | const MAX_ENTRIES = 20; |
| 22 | 21 | const CLEAR_LOG_ACTION = 'elementor-clear-log'; |
| 23 | 22 | |
| 24 | 23 | public function get_title() { |
| 25 | - return esc_html__( 'Log', 'elementor' ); | |
| 26 | - } | |
| 24 | + $title = 'Log'; | |
| 27 | 25 | |
| 28 | - public function get_fields() { | |
| 29 | - return [ | |
| 30 | - 'log_entries' => '', | |
| 31 | - ]; | |
| 32 | - } | |
| 33 | - | |
| 34 | - public function print_html_label( $log_label ) { | |
| 35 | - $title = $this->get_title(); | |
| 36 | - | |
| 37 | - if ( empty( $_GET[ self::CLEAR_LOG_ACTION ] ) ) { // phpcs:ignore -- nonce validation is not require here. | |
| 26 | + if ( 'html' === $this->_properties['format'] && empty( $_GET[ self::CLEAR_LOG_ACTION ] ) ) { // phpcs:ignore -- nonce validation is not require here. | |
| 38 | 27 | $nonce = wp_create_nonce( self::CLEAR_LOG_ACTION ); |
| 39 | 28 | $url = add_query_arg( [ |
| 40 | 29 | self::CLEAR_LOG_ACTION => 1, |
| 41 | 30 | '_wpnonce' => $nonce, |
| @@ -40,15 +29,21 @@ | ||
| 40 | 29 | self::CLEAR_LOG_ACTION => 1, |
| 41 | 30 | '_wpnonce' => $nonce, |
| 42 | 31 | ] ); |
| 43 | 32 | |
| 44 | - $title .= '<a href="' . esc_url( $url ) . '#elementor-clear-log" class="box-title-tool">' . esc_html__( 'Clear Log', 'elementor' ) . '</a>'; | |
| 33 | + $title .= '<a href="' . esc_url( $url ) . '#elementor-clear-log" class="box-title-tool">' . __( 'Clear Log', 'elementor' ) . '</a>'; | |
| 45 | 34 | $title .= '<span id="elementor-clear-log"></span>'; |
| 46 | 35 | } |
| 47 | 36 | |
| 48 | - parent::print_html_label( $title ); | |
| 37 | + return $title; | |
| 49 | 38 | } |
| 50 | 39 | |
| 40 | + public function get_fields() { | |
| 41 | + return [ | |
| 42 | + 'log_entries' => '', | |
| 43 | + ]; | |
| 44 | + } | |
| 45 | + | |
| 51 | 46 | public function get_log_entries() { |
| 52 | 47 | /** @var \Elementor\Core\Logger\Manager $manager */ |
| 53 | 48 | $manager = Manager::instance(); |
| 54 | 49 | |
| @@ -55,11 +50,9 @@ | ||
| 55 | 50 | /** @var \Elementor\Core\Logger\Loggers\Db $logger */ |
| 56 | 51 | $logger = $manager->get_logger( 'db' ); |
| 57 | 52 | |
| 58 | 53 | if ( ! empty( $_GET[ self::CLEAR_LOG_ACTION ] ) ) { |
| 59 | - $nonce = Utils::get_super_global_value( $_GET, '_wpnonce' ); | |
| 60 | - | |
| 61 | - if ( ! wp_verify_nonce( $nonce, self::CLEAR_LOG_ACTION ) ) { | |
| 54 | + if ( empty( $_GET['_wpnonce'] ) || ! wp_verify_nonce( $_GET['_wpnonce'], self::CLEAR_LOG_ACTION ) ) { | |
| 62 | 55 | wp_die( 'Invalid Nonce', 'Invalid Nonce', [ |
| 63 | 56 | 'back_link' => true, |
| 64 | 57 | ] ); |
| 65 | 58 | } |