1'-'4'). return $this->map_scheme_to_global( 'typography', $scheme ); } public function register_controls() { $controls_manager = Plugin::$instance->controls_manager; $controls_manager->register( new Repeater() ); } public function is_custom_colors_enabled() { return ! get_option( 'elementor_disable_color_schemes' ); } public function is_custom_typography_enabled() { return ! get_option( 'elementor_disable_typography_schemes' ); } /** * Add kit wrapper body class. * * It should be added even for non Elementor pages, * in order to support embedded templates. */ private function add_body_class() { $kit = $this->get_kit_for_frontend(); if ( $kit ) { Plugin::$instance->frontend->add_body_class( 'elementor-kit-' . $kit->get_main_id() ); } } /** * Send a confirm message before move a kit to trash, or if delete permanently not for trash. * * @param $post_id * @param false $is_permanently_delete */ private function before_delete_kit( $post_id, $is_permanently_delete = false ) { $document = Plugin::$instance->documents->get( $post_id ); if ( ! $document || ! $this->is_kit( $post_id ) || isset( $_GET['force_delete_kit'] ) || // phpcs:ignore -- nonce validation is not require here. ( $is_permanently_delete && $document->is_trash() ) ) { return; } ob_start(); require __DIR__ . '/views/trash-kit-confirmation.php'; $confirmation_content = ob_get_clean(); // PHPCS - the content does not contain user input value. wp_die( new \WP_Error( 'cant_delete_kit', $confirmation_content ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } /** * Add 'Edit with elementor -> Site Settings' in admin bar. * * @param [] $admin_bar_config * * @return array $admin_bar_config */ private function add_menu_in_admin_bar( $admin_bar_config ) { $document = Plugin::$instance->documents->get( get_the_ID() ); if ( ! $document || ! $document->is_built_with_elementor() ) { $recent_edited_post = Utils::get_recently_edited_posts_query( [ 'posts_per_page' => 1, ] ); if ( $recent_edited_post->post_count ) { $posts = $recent_edited_post->get_posts(); $document = Plugin::$instance->documents->get( reset( $posts )->ID ); } } if ( $document ) { $admin_bar_config['elementor_edit_page']['children'][] = [ 'id' => 'elementor_site_settings', 'title' => esc_html__( 'Site Settings', 'elementor' ), 'sub_title' => esc_html__( 'Site', 'elementor' ), 'href' => $document->get_edit_url() . '#' . self::E_HASH_COMMAND_OPEN_SITE_SETTINGS, 'class' => 'elementor-site-settings', 'parent_class' => 'elementor-second-section', ]; } return $admin_bar_config; } public function __construct() { add_action( 'elementor/documents/register', [ $this, 'register_document' ] ); add_filter( 'elementor/editor/localize_settings', [ $this, 'localize_settings' ] ); add_filter( 'elementor/editor/footer', [ $this, 'render_panel_html' ] ); add_action( 'elementor/frontend/after_enqueue_styles', [ $this, 'frontend_before_enqueue_styles' ], 0 ); add_action( 'elementor/preview/enqueue_styles', [ $this, 'preview_enqueue_styles' ], 0 ); add_action( 'elementor/controls/register', [ $this, 'register_controls' ] ); add_action( 'wp_trash_post', function ( $post_id ) { $this->before_delete_kit( $post_id ); } ); add_action( 'before_delete_post', function ( $post_id ) { $this->before_delete_kit( $post_id, true ); } ); add_action( 'update_option_blogname', function ( $old_value, $value ) { $this->update_kit_settings_based_on_option( 'site_name', $value ); }, 10, 2 ); add_action( 'update_option_blogdescription', function ( $old_value, $value ) { $this->update_kit_settings_based_on_option( 'site_description', $value ); }, 10, 2 ); add_action( 'wp_head', function() { $this->add_body_class(); } ); add_filter( 'elementor/frontend/admin_bar/settings', function ( $admin_bar_config ) { return $this->add_menu_in_admin_bar( $admin_bar_config ); }, 9 /* Before site-editor (theme-builder) */ ); } }