require_permission(); $this->read_query(); } protected function require_permission(): void { if ( ! current_user_can( 'inteltele_manage' ) ) { wp_die( esc_html__( 'You do not have permission to manage IntelTele.', 'inteltele' ), '', array( 'response' => 403 ) ); } } protected function read_query( string $action = 'inteltele_view', string $nonce_name = 'inteltele_view_nonce' ): void { $this->query = array(); $this->require_permission(); if ( ! isset( $_GET[ $nonce_name ] ) ) { return; } if ( ! is_string( $_GET[ $nonce_name ] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET[ $nonce_name ] ) ), $action ) ) { wp_die( esc_html__( 'Security check failed. Please reload the page and try again.', 'inteltele' ), '', array( 'response' => 403 ) ); } foreach ( array( 'tab', 'step', 'recipient_mode', 'recipient_type', 'order_status', 'scheme', 'role', 's', 'user_search', 'order_date_from', 'order_date_to', 'message', 'fallback_message', 'orders_preview', 'date_from', 'date_to', 'level', 'event', 'status', 'campaign_id', 'paged' ) as $key ) { if ( isset( $_GET[ $key ] ) && is_string( $_GET[ $key ] ) ) { $this->query[ $key ] = sanitize_textarea_field( wp_unslash( $_GET[ $key ] ) ); } } foreach ( array( 'user_ids', 'order_statuses', 'order_recipient_keys', 'columns' ) as $key ) { if ( isset( $_GET[ $key ] ) && is_array( $_GET[ $key ] ) ) { $this->query[ $key ] = array_map( 'sanitize_text_field', wp_unslash( $_GET[ $key ] ) ); } } } protected function get_page_url( array $args ): string { $args['inteltele_view_nonce'] = wp_create_nonce( 'inteltele_view' ); return add_query_arg( $args, admin_url( 'admin.php' ) ); } protected function render_view_nonce(): void { wp_nonce_field( 'inteltele_view', 'inteltele_view_nonce', false ); } protected function is_post_request(): bool { $method = isset( $_SERVER['REQUEST_METHOD'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_METHOD'] ) ) : ''; return 'POST' === $method; } /** * Render a page title wrapper. * * @param string $title Page title. */ protected function open_page( string $title ): void { echo '