Input JSON schema. * @since 1.2.0 */ protected function edit_input_schema(): array { $properties = $this->common_properties(); $properties['block'] = $this->block_property(); $properties['block']['description'] = trim( ( $properties['block']['description'] ?? '' ) . ' ' . self::KEEP_CHILDREN_NOTE ); return [ 'type' => 'object', 'properties' => $properties, 'required' => [ 'id', 'path', 'block' ], ]; } /** * Apply the edit to the tree. * * @param BlockTreeEditor $editor Tree editor. * @param array $tree Parsed block tree. * @param array $args Ability input. * @return array|WP_Error New tree, or an error. * @since 1.2.0 */ protected function apply( BlockTreeEditor $editor, array $tree, array $args ): array|WP_Error { $built = $this->build_block_or_error( $args ); if ( $built instanceof WP_Error ) { return $built; } $spec = $args['block'] ?? null; // Omitted innerBlocks means keep the target's children; an explicit array // (including []) is what the caller asked for and replaces them. $keep_children = is_array( $spec ) && ! array_key_exists( 'innerBlocks', $spec ); return $editor->edit( $tree, $this->read_path( $args ), $built, $this->read_expect( $args ), $keep_children ); } }