PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.0-beta3
Elementor Website Builder – more than just a page builder v4.3.0-beta3
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
elementor / modules / mcp / abilities / utils / document-mutation-links.php

document-mutation-links.php in Elementor Website Builder – more than just a page builder 4.3.0-beta3, at modules/mcp/abilities/utils/document-mutation-links.php

44 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Modules\Mcp\Abilities\Utils;
4
5 use Elementor\Core\Base\Document;
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit;
9 }
10
11 class Document_Mutation_Links {
12
13 public static function preview_schema_property(): array {
14 return Document_Preview_Url::output_schema_property();
15 }
16
17 public static function llm_instructions_schema_property(): array {
18 return [
19 'type' => 'string',
20 'description' => 'Mandatory next step: include this text (with the preview link) in your reply to the user.',
21 ];
22 }
23
24 public static function for_document( Document $document, ?string $success_message = null ): array {
25 $preview_url = Document_Preview_Url::for_document( $document );
26
27 return [
28 'preview_url' => $preview_url,
29 'llm_instructions' => self::build_llm_instructions( $preview_url, $success_message ),
30 ];
31 }
32
33 private static function build_llm_instructions( string $preview_url, ?string $success_message = null ): string {
34 $prefix = $success_message ?? __( 'Change saved.', 'elementor' );
35
36 return sprintf(
37 /* translators: 1: Success message, 2: Preview URL the LLM must share with the user. */
38 __( '%1$s You MUST show the user this preview link in your reply (they must be logged into WordPress as an editor): %2$s', 'elementor' ),
39 $prefix,
40 $preview_url
41 );
42 }
43 }
44