ailed', [ $this, 'ajax_screenshot_failed' ] ); } /** * @param Render_Mode_Manager $manager * * @throws \Exception */ public function register_render_mode( Render_Mode_Manager $manager ) { $manager->register_render_mode( Render_Mode_Screenshot::class ); } /** * Check and validate proxy mode. * * @param array $query_params * * @return bool * @throws \Requests_Exception_HTTP_400 * @throws \Requests_Exception_HTTP_403 */ protected function is_screenshot_proxy_mode( array $query_params ) { $is_proxy = isset( $query_params['screenshot_proxy'] ); if ( $is_proxy ) { if ( ! wp_verify_nonce( $query_params['nonce'], self::SCREENSHOT_PROXY_NONCE_ACTION ) ) { throw new \Requests_Exception_HTTP_403(); } if ( ! $query_params['href'] ) { throw new \Requests_Exception_HTTP_400(); } } return $is_proxy; } /** * Module constructor. * * @throws \Requests_Exception_HTTP_400 * @throws \Requests_Exception_HTTP_403 */ public function __construct() { parent::__construct(); if ( $this->is_screenshot_proxy_mode( $_GET ) ) { // phpcs:ignore -- Checking nonce inside the method. echo $this->get_proxy_data( $_GET['href'] ); // phpcs:ignore -- Nonce was checked on the above method die; } add_action( 'elementor/frontend/render_mode/register', [ $this, 'register_render_mode' ] ); add_action( 'elementor/ajax/register_actions', [ $this, 'register_ajax_actions' ] ); add_action( 'parse_query', [ $this, 'filter_screenshots_from_attachments_query' ] ); add_filter( 'ajax_query_attachments_args', [ $this, 'filter_screenshots_from_ajax_attachments_query' ] ); add_filter( 'elementor-pro/site-editor/data/template', [ $this, 'extend_templates_json_structure' ] ); } }