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 / prompt-loader.php

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

37 lines 1.2 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 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8
9 class Prompt_Loader {
10
11 protected static function get_core_path(): string {
12 return __DIR__ . '/../../static-resources/abilities/';
13 }
14
15 protected static function resolve_extra_path(): ?string {
16 if ( ! defined( 'ELEMENTOR_PRO_PATH' ) ) {
17 return null;
18 }
19
20 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound
21 return rtrim( constant( 'ELEMENTOR_PRO_PATH' ), '/' ) . '/modules/mcp/static-resources-extra/abilities/';
22 }
23
24 public static function load( string $name ): string {
25 $core_file = static::get_core_path() . $name . '.md';
26 $extra_path = static::resolve_extra_path();
27 $extra_file = null !== $extra_path ? $extra_path . $name . '.md' : null;
28
29 // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
30 $content = file_exists( $core_file ) ? rtrim( (string) file_get_contents( $core_file ) ) : '';
31 // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
32 $extra = ( null !== $extra_file && file_exists( $extra_file ) ) ? rtrim( (string) file_get_contents( $extra_file ) ) : '';
33
34 return implode( "\n\n", array_filter( [ $content, $extra ] ) );
35 }
36 }
37