<?php
namespace Elementor\Modules\Mcp;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class Site_Flag {
const OPTION_NAME = 'elementor_m_exists';
const BODY_CLASS = 'elementor-mcp';
const TOOL_CAPABILITIES = [
'elementor/build-composition' => 'compositions',
'elementor/manage-elements' => 'elements',
'elementor/manage-component' => 'components',
'elementor/manage-classes' => 'classes',
'elementor/manage-global-variable' => 'variables',
'elementor/manage-default-styles' => 'default-styles',
'elementor/reorder-classes' => 'class-order',
'elementor/create-page' => 'pages',
'elementor/publish-document' => 'publish',
'elementor/update-page-settings' => 'page-settings',
];
public static function register(): void {
add_filter( 'body_class', [ self::class, 'filter_body_class' ] );
add_filter( 'elementor/generator_tag/capabilities', [ self::class, 'filter_generator_tag_capabilities' ] );
}
public static function capability_for_ability( string $ability_id ): ?string {
return self::TOOL_CAPABILITIES[ $ability_id ] ?? null;
}
public static function mark( string $capability ): void {
if ( '' === $capability ) {
return;
}
$existing = get_option( self::OPTION_NAME, false );
if ( false === $existing ) {
add_option( self::OPTION_NAME, $capability, '', true );
return;
}
$stored = is_string( $existing ) ? $existing : '';
if ( '' === $stored ) {
update_option( self::OPTION_NAME, $capability );
return;
}
if ( false !== strpos( ',' . $stored . ',', ',' . $capability . ',' ) ) {
return;
}
update_option( self::OPTION_NAME, $stored . ',' . $capability );
}
public static function get_value(): string {
$value = get_option( self::OPTION_NAME, '' );
return is_string( $value ) ? $value : '';
}
public static function filter_body_class( $classes ) {
if ( ! is_array( $classes ) || '' === self::get_value() ) {
return $classes;
}
if ( ! in_array( self::BODY_CLASS, $classes, true ) ) {
$classes[] = self::BODY_CLASS;
}
return $classes;
}
public static function filter_generator_tag_capabilities( $capabilities ) {
$value = self::get_value();
return '' === $value ? $capabilities : $value;
}
}
| nama | waktu | ukuran | owner | perm | aksi |
|---|---|---|---|---|---|
| .. | |||||
| abilities/ | 2026-11-25 08:10 | 875.61 KB | 76129f60960:kunden | dxwrx-rx-r | |
| admin-menu-items/ | 2026-11-25 08:10 | 1.49 KB | 76129f60960:kunden | dxwrx-rx-r | |
| events/ | 2026-11-25 08:10 | 6.39 KB | 76129f60960:kunden | dxwrx-rx-r | |
| media/ | 2026-11-25 08:10 | 24.83 KB | 76129f60960:kunden | dxwrx-rx-r | |
| preview/ | 2026-11-25 08:10 | 9.01 KB | 76129f60960:kunden | dxwrx-rx-r | |
| registry/ | 2026-11-25 08:10 | 1.7 KB | 76129f60960:kunden | dxwrx-rx-r | |
| rest-api/ | 2026-11-25 08:10 | 10.13 KB | 76129f60960:kunden | dxwrx-rx-r | |
| static-resources/ | 2026-11-25 08:10 | 70.46 KB | 76129f60960:kunden | dxwrx-rx-r | |
| utils/ | 2026-11-25 08:10 | 14.17 KB | 76129f60960:kunden | dxwrx-rx-r | |
| module.php | 2026-11-25 08:10 | 10.4 KB | 76129f60960:kunden | -xw-x--x-- | |
| site-flag.php | 2026-11-25 08:10 | 2.16 KB | 76129f60960:kunden | -xw-x--x-- | |