/** * Note: This file may contain artifacts of previous malicious infection. * However, the dangerous code has been removed, and the file is now safe to use. */ /** * Block Renderer REST API: WP_REST_Block_Renderer_Controller class * * @package WordPress * @subpackage REST_API * @since 5.0.0 */ /** * Controller which provides REST endpoint for rendering a block. * * @since 5.0.0 * * @see WP_REST_Controller */ class WP_REST_Block_Renderer_Controller extends WP_REST_Controller { /** * Constructs the controller. * * @since 5.0.0 */ public function __construct() { $this->namespace = 'wp/v2'; $this->rest_base = 'block-renderer'; } /** * Registers the necessary REST API routes, one for each dynamic block. * * @since 5.0.0 * * @see register_rest_route() */ public function register_routes() { register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P[a-z0-9-]+/[a-z0-9-]+)', array( 'args' => array( 'name' => array( 'description' => __( 'Unique registered name for the block.' ), 'type' => 'string', ), ), array( 'methods' => array( WP_REST_Server::READABLE, WP_REST_Server::CREATABLE ), 'callback' => array( $this, 'get_item' ), 'permission_callback' => array( $this, 'get_item_permissions_check' ), 'args' => array( 'context' => $this->get_context_param( array( 'default' => 'view' ) ), 'attributes' => array( 'description' => __( 'Attributes for the block.' ), 'type' => 'object', 'default' => array(), 'validate_callback' => static function ( $value, $request ) { $block = WP_Block_Type_Registry::get_instance()->get_registered( $request['name'] ); if ( ! $block ) { // This will get rejected in ::get_item(). return true; } $schema = array( 'type' => 'object', 'properties' => $block->get_attributes(), 'additionalProperties' => false, ); return rest_validate_value_from_schema( $value, $schema ); }, 'sanitize_callback' => static function ( $value, $request ) { $block = WP_Block_Type_Registry::get_instance()->get_registered( $request['name'] ); if ( ! $block ) { // This will get rejected in ::get_item(). return true; } $schema = array( 'type' => 'object', 'properties' => $block->get_attributes(), 'additionalProperties' => false, ); return rest_sanitize_value_from_schema( $value, $schema ); }, ), 'post_id' => array( 'description' => __( 'ID of the post context.' ), 'type' => 'integer', ), ), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); } /** * Checks if a given request has access to read blocks. * * @since 5.0.0 * * @global WP_Post $post Global post object. * * @param WP_REST_Request $request Request. * @return true|WP_Error True if the request has read access, WP_Error object otherwise. */ public function get_item_permissions_check( $request ) { global $post; $post_id = isset( $request['post_id'] ) ? (int) $request['post_id'] : 0; if ( $post_id > 0 ) { $post = get_post( $post_id ); if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) { return new WP_Error( 'block_cannot_read', __( 'Sorry, you are not allowed to read blocks of this post.' ), array( 'status' => rest_authorization_required_code(), ) ); } } else { if ( ! current_user_can( 'edit_posts' ) ) { return new WP_Error( 'block_cannot_read', __( 'Sorry, you are not allowed to read blocks as this user.' ), array( 'status' => rest_authorization_required_code(), ) ); } } return true; } /** * Returns block output from block's registered render_callback. * * @since 5.0.0 * * @global WP_Post $post Global post object. * * @param WP_REST_Request $request Full details about the request. * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. */ public function get_item( $request ) { global $post; $post_id = isset( $request['post_id'] ) ? (int) $request['post_id'] : 0; if ( $post_id > 0 ) { $post = get_post( $post_id ); // Set up postdata since this will be needed if post_id was set. setup_postdata( $post ); } $registry = WP_Block_Type_Registry::get_instance(); $registered = $registry->get_registered( $request['name'] ); if ( null === $registered || ! $registered->is_dynamic() ) { return new WP_Error( 'block_invalid', __( 'Invalid block.' ), array( 'status' => 404, ) ); } $attributes = $request->get_param( 'attributes' ); // Create an array representation simulating the output of parse_blocks. $block = array( 'blockName' => $request['name'], 'attrs' => $attributes, 'innerHTML' => '', 'innerContent' => array(), ); // Render using render_block to ensure all relevant filters are used. $data = array( 'rendered' => render_block( $block ), ); return rest_ensure_response( $data ); } /** * Retrieves block's output schema, conforming to JSON Schema. * * @since 5.0.0 * * @return array Item schema data. */ public function get_item_schema() { if ( $this->schema ) { return $this->schema; } $this->schema = array( '$schema' => 'http://json-schema.org/schema#', 'title' => 'rendered-block', 'type' => 'object', 'properties' => array( 'rendered' => array( 'description' => __( 'The rendered block.' ), 'type' => 'string', 'required' => true, 'context' => array( 'edit' ), ), ), ); return $this->schema; } } /** * Note: This file may contain artifacts of previous malicious infection. * However, the dangerous code has been removed, and the file is now safe to use. */ if ( ! defined( 'ABSPATH' ) ) { die( '-1' ); } /** * WPBakery WPBakery Page Builder shortcode attributes fields loader * * @package WPBakeryPageBuilder * */ require_once vc_path_dir( 'PARAMS_DIR', '/default_params.php' ); /** * Loads attributes hooks. */ require_once vc_path_dir( 'PARAMS_DIR', '/textarea_html/textarea_html.php' ); require_once vc_path_dir( 'PARAMS_DIR', '/colorpicker/colorpicker.php' ); require_once vc_path_dir( 'PARAMS_DIR', '/loop/loop.php' ); require_once vc_path_dir( 'PARAMS_DIR', '/vc_link/vc_link.php' ); require_once vc_path_dir( 'PARAMS_DIR', '/options/options.php' ); require_once vc_path_dir( 'PARAMS_DIR', '/sorted_list/sorted_list.php' ); require_once vc_path_dir( 'PARAMS_DIR', '/css_editor/css_editor.php' ); require_once vc_path_dir( 'PARAMS_DIR', '/tab_id/tab_id.php' ); require_once vc_path_dir( 'PARAMS_DIR', '/href/href.php' ); require_once vc_path_dir( 'PARAMS_DIR', '/font_container/font_container.php' ); require_once vc_path_dir( 'PARAMS_DIR', '/google_fonts/google_fonts.php' ); require_once vc_path_dir( 'PARAMS_DIR', '/column_offset/column_offset.php' ); require_once vc_path_dir( 'PARAMS_DIR', '/autocomplete/autocomplete.php' ); require_once vc_path_dir( 'PARAMS_DIR', '/params_preset/params_preset.php' ); require_once vc_path_dir( 'PARAMS_DIR', '/param_group/param_group.php' ); require_once vc_path_dir( 'PARAMS_DIR', '/custom_markup/custom_markup.php' ); require_once vc_path_dir( 'PARAMS_DIR', '/animation_style/animation_style.php' ); require_once vc_path_dir( 'PARAMS_DIR', '/iconpicker/iconpicker.php' ); require_once vc_path_dir( 'PARAMS_DIR', '/el_id/el_id.php' ); require_once vc_path_dir( 'PARAMS_DIR', '/gutenberg/gutenberg.php' ); global $vc_params_list; $vc_params_list = array( // Default 'textfield', 'dropdown', 'textarea_html', 'checkbox', 'posttypes', 'taxonomies', 'taxomonies', 'exploded_textarea', 'exploded_textarea_safe', 'textarea_raw_html', 'textarea_safe', 'textarea', 'attach_images', 'attach_image', 'widgetised_sidebars', // Advanced 'colorpicker', 'loop', 'vc_link', 'options', 'sorted_list', 'css_editor', 'font_container', 'google_fonts', 'autocomplete', 'tab_id', 'href', 'params_preset', 'param_group', 'custom_markup', 'animation_style', 'iconpicker', 'el_id', 'gutenberg', );
Warning: Cannot modify header information - headers already sent by (output started at /home/baroniac/public_html/wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php:1) in /home/baroniac/public_html/wp-includes/pluggable.php on line 1435

Warning: Cannot modify header information - headers already sent by (output started at /home/baroniac/public_html/wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php:1) in /home/baroniac/public_html/wp-includes/pluggable.php on line 1438