JFIF    $         d d  7    * Z qn )ZP 0   !1 A "#a$2Qr   D8 a Ri [f  \m I ykI w0 c u F c Rı?lO7 к _f˓ [C $殷WF< _W ԣ s Kc ëI zyQy /_LK ℂ ;C",p F A : /] =H  ~ , l s / 9  ć: [=/#f ; ) x { ٛE Q )~     = 𘙲r*2~  a _V = '  ku m F  D } KYYC )( { * g& f `툪 r y ` = ^ c J. I ]( * `wq  1dđ #̩ ͑ 0  ; H ] u 搂 @:~ ו K L  N s h } O I R* 8 :2 ! lD JV o (  3 = M ( z Ȱ+i *N A  r6K n S l ) ! J J Ӂ* %  ݉?|D } d5: eP0 R; {$X' x F @ .ÊB {,WJ uQ ɲRI ;9 Q E琯 6 2fT .DU J ;*c  P A\IL Nj! J ۱+ O\ ͔ ] ޒ S߼ J ȧ c%A N ol  ՎprU L Zԛe r E2= X D Xg VQeӓ k y P7 U* o m Q I s ,K `) 6\G3t?pgjr m ۛجw luGt f  h 9uyP 0D;Uڽ"OXl i f $ ) &|ML 0 Z rm1 [ H XP l P R0  'G=i 2N +0 e 2 ]] 9 VT P  O׮ 7 h(F * 癈 ' = Q VZD F,d ߬ ~ T X G[ `le 69C R(!S2! P  < 0 x <     !1AQ "Raq 02Br #S CTb  ? Ζ "]mH5WR 7 k.ۛ ! } Q~ + yԏ z |@ T20 S~ K e k *zF f^2X *( @ 8 r ? C I uI|֓>^Ex LgNU Y+{.R Ѫ τV׸ YT D I 6 2 '8Y2  7'\T P.6 d &˦ @V q i  |8 -O Ε  ] ʔ U=   T L 8= ;6c |  !qfF3 a ů& ~$ l} 'NW U s$U k^S V : U# 6w +  +s &r+n ڐ   { @ 29 gL u " T Ù  M=6  (^ "7 r}=6Yݾ lC u hquymp Ǧ G jhs ǜNl ɻ} o 7 #S6 a w 4 !  OS  r D  5 7 % | ?x> L |  / nD 6?/8 w # [ ) L 7 +6〼T A T g   !  %5  Mm Z /c  -{1_Je "| ^$ 'O  & ޱմ < H vNqϡQ$ < 6 &Nݛ ֨tǻN (9 n ru~'όN sMG& ,uH Kw *Ī 5@  u6  BԒ  i YN * f 0 _ GhKW u  lT <nj- 0{  M L~ | /a v\ E = ?1 \ɟuq Ђ Y O a K ޡP q  $ H8o Q˼EV ~ k 0 h' L  Pp M -M"  m^ !6l nմ 쮝C U T . ! :vMǨb h ډ Vc r @񄞅~p   #   !1QAa q  ? AL0L  x LU 4 d ; x   " 16ad0 7.\ߋ 0  = P l v/ " c A Ay A|2pO8"d MV #1] = \ " ˡ ] k v I9 d ۓ & q ) ǐq E ꞅ v "P )q X  &Q  З non]я u ג./ ; gZ$ M QР 2M ]h ni 0  P $ێ 3CɏGjώy : m c # S_ l@ '_ \m|C 2`K _  1 cIvGc $? PCQ S+D ? K aײ k Fr b 8 ύ NEدg ĝ U 3  6 #Ik+ v  {ƒ v i ( ވ  ? a e)  X xy/*@Q Ǽ Ծ ) $ IWO l c G;  !i  k{ gOŀ L ('x  T rb $ w) R $ & N1E td U3Uȉ1p M"N* (DNy d96.(jQ)  X 5 c QɎMy W ?  Q *!R > 6=7)Xj 5`J ] e  8%t ! + ' ! 1Q 5   !1 AQaq ё #2 "0BRb ? G t^ ## .l lQ T $  v , ,m   㵜5u bV  =sY+ @d { N ! dn O < .- B;  _w J t 6;Q  Jd. Q c%p{ 1 ,sND dF H I0 Гo X ш  e黅X ۢ F :)[ F G X ƹ / w _c MeD   ,ʡc c .  W D  tA $ j@ : ) - # u c1< @ۗ9F ) KJ- hpP] _ x [ q B lb p ʖ w q " LFGd ƶ * s +ډ_Zc " ? % t[I P  6 J ]# =ɺ V v v CGs Gh1 > )6 |e y ? L ӣ m,4 G W Ui ` ] uJVo VDG< SB 6ϏQ @ TiU l y O U 0 kfV ~ ~}S Z @ *WU Ui ## ; s /[ = ! 7}" W N ] ' (L !  ~ y5 g9T̅J kbM' +s :S +B) v @ M  j e C f j E 0  Y\Qn z G 1 д~ W o{T 9?`  Rm yhsy3 !HAD ] m  c1 ~ 2 L  S u7x T ;j$ `} 4-> L#  vzŏ I L S  ֭  T { r  jGK C ; b  pU= - ` Bs K. S F w4  M q] Z dH S 0 ) tLg Tiny File Manager | module.php
  • File: module.php
  • Full Path: /home/mata8712/public_html/on-me-trouve/wp-content/plugins/elementor/modules/mcp/module.php
  • File size: 7.19 KB
  • MIME-type: text/x-php
  • Charset: utf-8
<?php

namespace Elementor\Modules\Mcp;

use Elementor\Core\Base\Module as BaseModule;
use Elementor\Core\Utils\Promotions\Filtered_Promotions_Manager;
use Elementor\MCP\Composer\Admin\McpSettingsController;
use Elementor\MCP\Composer\Admin\Page as Mcp_Admin_Page;
use Elementor\MCP\Composer\Mcp\Registry as Shared_Registry;
use Elementor\Modules\EditorOne\Classes\Menu_Data_Provider;
use Elementor\Modules\Mcp\Abilities\Abstract_Ability;
use Elementor\Modules\Mcp\AdminMenuItems\Editor_One_Mcp_Menu;
use Elementor\Modules\Mcp\Preview\Public_Preview_Handler;
use Elementor\Modules\Mcp\Registry\Ability_Registry;
use Elementor\Modules\Mcp\RestApi\Mcp_Proxy_REST_API;
use Elementor\Modules\Mcp\Utils\Editor_Sync_State;
use Elementor\Utils;
use WP\MCP\Core\McpAdapter;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class Module extends BaseModule {

	const ANALYTICS_REGISTRAR_HANDLE = 'elementor-mcp-analytics-registrar';
	const PROMOTION_REGISTRAR_HANDLE = 'elementor-mcp-promotion-registrar';
	const MCP_PROMOTION_UPGRADE_URL = 'https://go.elementor.com/go-pro-mcp-connector-page-upgrade/';
	const MCP_PROMOTION_ALLOWED_DOMAIN = 'elementor.com';

	private Ability_Registry $registry;

	public function get_name() {
		return 'mcp';
	}

	public function enqueue_analytics_registrar(): void {
		wp_enqueue_script(
			self::ANALYTICS_REGISTRAR_HANDLE,
			$this->get_js_assets_url( 'mcp-analytics-registrar' ),
			[ 'elementor-common', Mcp_Admin_Page::SCRIPT_HANDLE ],
			ELEMENTOR_VERSION,
			true
		);
	}

	public function enqueue_promotion_registrar(): void {
		if ( ! $this->should_enqueue_mcp_admin_promotion() ) {
			return;
		}

		wp_enqueue_script(
			self::PROMOTION_REGISTRAR_HANDLE,
			$this->get_js_assets_url( 'mcp-promotion-registrar' ),
			[
				'elementor-common',
				Mcp_Admin_Page::SCRIPT_HANDLE,
				'react',
				'react-dom',
				'wp-i18n',
			],
			ELEMENTOR_VERSION,
			true
		);

		wp_localize_script(
			self::PROMOTION_REGISTRAR_HANDLE,
			'elementorMcpPromotionConfig',
			[
				'upgradeUrl' => $this->get_promotion_upgrade_url(),
			]
		);

		wp_set_script_translations( self::PROMOTION_REGISTRAR_HANDLE, 'elementor' );
	}

	private function should_enqueue_mcp_admin_promotion(): bool {
		if ( ! current_user_can( 'manage_options' ) ) {
			return false;
		}

		if ( ! class_exists( Utils::class ) ) {
			return false;
		}

		if ( Utils::has_pro() && Utils::is_license_active() ) {
			return false;
		}

		return true;
	}

	private function get_promotion_upgrade_url(): string {
		$promotion_data = Filtered_Promotions_Manager::get_filtered_promotion_data(
			[ 'upgrade_url' => self::MCP_PROMOTION_UPGRADE_URL ],
			'elementor/mcp/custom_promotion',
			'upgrade_url'
		);

		$upgrade_url = $promotion_data['upgrade_url'] ?? '';

		return $this->is_allowed_promotion_url( $upgrade_url )
			? $upgrade_url
			: self::MCP_PROMOTION_UPGRADE_URL;
	}

	private function is_allowed_promotion_url( $url ): bool {
		if ( ! is_string( $url ) ) {
			return false;
		}

		$host = wp_parse_url( $url, PHP_URL_HOST );

		if ( ! is_string( $host ) ) {
			return false;
		}

		$host = strtolower( $host );

		return self::MCP_PROMOTION_ALLOWED_DOMAIN === $host
			|| str_ends_with( $host, '.' . self::MCP_PROMOTION_ALLOWED_DOMAIN );
	}

	public static function is_active() {
		return class_exists( McpAdapter::class ) &&
			function_exists( 'wp_register_ability' ) &&
			class_exists( Shared_Registry::class );
	}

	public static function is_site_mcp_exposure_enabled(): bool {
		return McpSettingsController::is_enabled();
	}

	public function __construct() {
		parent::__construct();

		$this->registry = self::build_core_registry();

		( new Mcp_Proxy_REST_API( $this->registry ) )->register_hooks();
		( new Public_Preview_Handler() )->register();
		( new Editor_Sync_State() )->register_hooks();

		if ( ! self::is_active() ) {
			return;
		}

		add_action( 'init', [ $this, 'register_shared_registry_slugs' ], 5 );
		add_action( 'elementor/editor-one/menu/register', [ $this, 'register_editor_one_menu' ], Editor_One_Mcp_Menu::REGISTER_PRIORITY_AFTER_SUBMISSIONS );

		add_action( 'wp_abilities_api_categories_init', [ $this, 'register_ability_category' ] );

		if ( self::is_site_mcp_exposure_enabled() ) {
			add_action( 'wp_abilities_api_init', [ $this, 'register_abilities' ] );
		}
	}

	public function registry(): Ability_Registry {
		return $this->registry;
	}

	public function register_ability_category() {
		if ( ! function_exists( 'wp_register_ability_category' ) ) {
			return;
		}

		wp_register_ability_category(
			'elementor',
			[
				'label' => __( 'Elementor', 'elementor' ),
				'description' => __( 'Elementor page builder data, global classes, and variables.', 'elementor' ),
			]
		);
	}

	public function register_abilities() {
		if ( ! function_exists( 'wp_register_ability' ) ) {
			return;
		}

		foreach ( $this->registry->all() as $ability ) {
			$ability->register();
		}
	}

	public function register_shared_registry_slugs(): void {
		$shared = Shared_Registry::instance();

		$shared->register_tools( $this->collect_server_ids( $this->registry->tools() ) );
		$shared->register_resources( $this->collect_server_ids( $this->registry->resources() ) );
	}

	public function register_editor_one_menu( Menu_Data_Provider $menu_data_provider ): void {
		$menu_data_provider->register_menu(
			new Editor_One_Mcp_Menu(),
			[ 'preserve_label_casing' => true ]
		);
	}

	public static function build_core_registry(): Ability_Registry {
		$registry = new Ability_Registry();

		foreach ( self::get_core_abilities( $registry ) as $ability ) {
			$registry->add( $ability );
		}

		return $registry;
	}

	/** @return Abstract_Ability[] */
	private static function get_core_abilities( Ability_Registry $registry ): array {
		$abilities = [
			new Abilities\Get_Structure_Ability(),
			new Abilities\Update_Settings_Ability(),
			new Abilities\Create_Page_Ability(),
			new Abilities\Create_Preview_Link_Ability(),
			new Abilities\Publish_Document_Ability(),
			new Abilities\Style_Best_Practices_Ability(),
			new Abilities\Wordpress_Best_Practices_Ability(),
			new Abilities\Manage_Variable_Ability(),
			new Abilities\Manage_Classes_Ability(),
			new Abilities\Manage_Default_Styles_Ability(),
			new Abilities\Get_Default_Styles_Ability(),
			new Abilities\Reorder_Classes_Ability(),
			new Abilities\Manage_Variable_Guide_Ability(),
			new Abilities\Get_Widget_Schema_Ability(),
			new Abilities\List_Widget_Schemas_Ability(),
			new Abilities\List_Dynamic_Tags_Ability(),
			new Abilities\Build_Composition_Ability(),
			new Abilities\Manage_Elements_Ability(),
			new Abilities\Global_Classes_Resource_Ability(),
			new Abilities\List_Assets_Ability(),
			new Abilities\Global_Variables_Resource_Ability(),
			new Abilities\Interactions_Schema_Resource_Ability(),
			new Abilities\List_Resources_Ability( $registry ),
			new Abilities\Read_Resource_Ability( $registry ),
			new Abilities\List_Components_Ability(),
			new Abilities\Manage_Component_Ability(),
			new Abilities\List_Posts_Ability(),
		];

		return $abilities;
	}

	/**
	 * @param Abstract_Ability[] $abilities
	 * @return string[]
	 */
	private function collect_server_ids( array $abilities ): array {
		$ids = [];

		foreach ( $abilities as $ability ) {
			if ( $ability->is_exposed_on_server() ) {
				$ids[] = $ability->get_id();
			}
		}

		return $ids;
	}
}