8889841cutil.clix.co.tz/wp-content/plugins/elementor-pro/modules/theme-builder/documents/theme-document.php 0000644 00000042350 15050705362 0032427 0 ustar 00 home/clixcotz static::get_type(), 'icon' => static::get_site_editor_icon(), 'title' => static::get_title(), 'page_title' => static::get_title(), 'page_layout' => static::get_site_editor_layout(), // Todo: Remove. Core plugin should use `urls.route`. 'url' => static::get_site_editor_route(), 'urls' => [ 'route' => static::get_site_editor_route(), 'create' => static::get_create_url(), 'thumbnail' => static::get_site_editor_thumbnail_url(), ], 'tooltip_data' => static::get_site_editor_tooltip_data(), 'show_instances' => true, ]; } public static function get_editor_panel_config() { $panel_config = parent::get_editor_panel_config(); $document_config = static::get_properties(); if ( true === $document_config['support_site_editor'] ) { $panel_config['messages']['publish_notification'] = esc_html__( 'Congrats! Your Site Part is Live', 'elementor-pro' ); } return $panel_config; } protected function get_have_a_look_url() { $document_config = static::get_properties(); if ( true === $document_config['support_site_editor'] ) { return ''; } return parent::get_have_a_look_url(); } public static function get_create_url() { $base_create_url = Plugin::elementor()->documents->get_create_new_post_url( Source_Local::CPT ); return add_query_arg( [ 'template_type' => static::get_type() ], $base_create_url ); } protected static function get_site_editor_tooltip_data() { return [ 'title' => '', 'content' => '', 'tip' => '', 'video_url' => '', ]; } public function get_name() { return static::get_type(); } public static function get_lock_behavior_v2() { return new Feature_Lock( [ 'type' => static::get_type(), ] ); } public function get_location_label() { $location = $this->get_location(); $locations_settings = Module::instance()->get_locations_manager()->get_location( $location ); $label = ''; $is_section_doc_type = 'section' === $this->get_name(); if ( $location ) { if ( $is_section_doc_type ) { $label .= isset( $locations_settings['label'] ) ? $locations_settings['label'] : $location; } } $supported = true; if ( $is_section_doc_type ) { if ( $location && ! $locations_settings ) { $supported = false; } } elseif ( ! $location || ! $locations_settings ) { $supported = false; } if ( ! $supported ) { $label .= ' (' . esc_html__( 'Unsupported', 'elementor-pro' ) . ')'; } return $label; } public function before_get_content() { $preview_manager = Module::instance()->get_preview_manager(); $preview_manager->switch_to_preview_query(); } public function after_get_content() { $preview_manager = Module::instance()->get_preview_manager(); $preview_manager->restore_current_query(); } public function get_content( $with_css = false ) { $this->before_get_content(); $content = parent::get_content( $with_css ); $this->after_get_content(); return $content; } public function print_content() { $plugin = Plugin::elementor(); if ( $plugin->preview->is_preview_mode( $this->get_main_id() ) ) { // PHPCS - the method builder_wrapper is safe. echo $plugin->preview->builder_wrapper( '' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } else { // PHPCS - the method get_content is safe. echo $this->get_content(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } } public static function get_preview_as_default() { return ''; } public static function get_preview_as_options() { return []; } public function get_container_attributes() { $attributes = parent::get_container_attributes(); $location = Module::instance()->get_locations_manager()->get_current_location(); if ( $location ) { $attributes['class'] .= ' elementor-location-' . $location; } return $attributes; } /** * @static * @since 2.0.0 * @access public * * @return string */ public function get_edit_url() { $url = parent::get_edit_url(); if ( isset( $_GET['action'] ) && 'elementor_new_post' === $_GET['action'] ) { $url .= '#library'; } return $url; } public function get_export_summary() { $summary = parent::get_export_summary(); $summary['location'] = $this->get_location(); $theme_builder = Plugin::instance()->modules_manager->get_modules( 'theme-builder' ); $conditions = $theme_builder->get_conditions_manager()->get_document_conditions( $this ); foreach ( $conditions as $condition ) { if ( 'include' === $condition['type'] && ! $condition['sub_id'] ) { $summary['conditions'][] = $condition; break; } } return $summary; } public function import( array $data ) { parent::import( $data ); /** @var Module $theme_builder */ $theme_builder = Plugin::instance()->modules_manager->get_modules( 'theme-builder' ); $conditions = isset( $data['import_settings']['conditions'] ) ? $data['import_settings']['conditions'] : []; if ( ! empty( $conditions ) ) { $condition = $conditions[0]; $condition = rtrim( implode( '/', $condition ), '/' ); $conflicts = $theme_builder->get_conditions_manager()->get_conditions_conflicts_by_location( $condition, $this->get_location() ); if ( $conflicts ) { /** @var Import_Export_Module $import_export_module */ $import_export_module = Plugin::elementor()->app->get_component( 'import-export' ); $override_conditions = $import_export_module->import->get_settings( 'overrideConditions' ); if ( ! $override_conditions || ! in_array( $data['id'], $override_conditions, true ) ) { return; } foreach ( $conflicts as $template ) { /** @var Theme_Document $template_document */ $template_document = Plugin::elementor()->documents->get( $template['template_id'] ); $template_conditions = $theme_builder->get_conditions_manager()->get_document_conditions( $template_document ); foreach ( $template_conditions as $index => $template_condition ) { if ( in_array( $template_condition, $conditions, true ) ) { unset( $template_conditions[ $index ] ); } } $theme_builder->get_conditions_manager()->save_conditions( $template_document->get_main_id(), $template_conditions ); } } } $theme_builder->get_conditions_manager()->save_conditions( $this->get_main_id(), $conditions ); } protected function register_controls() { parent::register_controls(); $this->start_controls_section( 'preview_settings', [ 'label' => esc_html__( 'Preview Settings', 'elementor-pro' ), 'tab' => Controls_Manager::TAB_SETTINGS, ] ); $this->add_control( 'preview_type', [ 'label' => esc_html__( 'Preview Dynamic Content as', 'elementor-pro' ), 'label_block' => true, 'type' => Controls_Manager::SELECT, 'default' => $this::get_preview_as_default(), 'groups' => $this::get_preview_as_options(), 'export' => false, ] ); $this->add_control( 'preview_id', [ 'type' => QueryModule::QUERY_CONTROL_ID, 'label_block' => true, 'autocomplete' => [ 'object' => QueryModule::QUERY_OBJECT_JS, ], 'separator' => 'none', 'export' => false, 'condition' => [ 'preview_type!' => [ '', 'search', ], ], ] ); $this->add_control( 'preview_search_term', [ 'label' => esc_html__( 'Search Term', 'elementor-pro' ), 'export' => false, 'condition' => [ 'preview_type' => 'search', ], ] ); $this->add_control( 'apply_preview', [ 'type' => Controls_Manager::BUTTON, 'label' => esc_html__( 'Apply & Preview', 'elementor-pro' ), 'label_block' => true, 'show_label' => false, 'text' => esc_html__( 'Apply & Preview', 'elementor-pro' ), 'separator' => 'none', 'event' => 'elementorThemeBuilder:ApplyPreview', ] ); $this->end_controls_section(); $this->inject_html_tag_control(); } /** * @since 2.9.0 * * If the implementing document uses optional wrapper HTML tags, this method injects the control to choose the tag */ private function inject_html_tag_control() { $wrapper_tags = $this->get_wrapper_tags(); // Only proceed if the implementing document has optional wrapper HTML tags to replace 'div' if ( ! $wrapper_tags ) { return; } // Add 'div' to the beginning of the list of wrapper tags array_unshift( $wrapper_tags, 'div' ); /** * Inject the control that sets the HTML tag for the header/footer wrapper element */ $this->start_injection( [ 'of' => 'post_status', 'fallback' => [ 'of' => 'post_title', ], ] ); $this->add_control( 'content_wrapper_html_tag', [ 'label' => esc_html__( 'HTML Tag', 'elementor-pro' ), 'type' => Controls_Manager::SELECT, 'default' => 'div', 'options' => array_combine( $wrapper_tags, $wrapper_tags ), ] ); $this->end_injection(); } /** * @param null $elements_data * @since 2.9.0 * @access public * * Overwrite method from document.php to check for user-selected tags to use as the document wrapper element */ public function print_elements_with_wrapper( $elements_data = null ) { // Check if the implementing document has optional wrapper tags $has_wrapper_tags = $this->get_wrapper_tags(); $settings = $this->get_settings_for_display(); $wrapper_tag = 'div'; // Only proceed if the inheriting document has optional wrapper HTML tags to replace 'div' if ( $has_wrapper_tags ) { $wrapper_tag = Utils::validate_html_tag( $settings['content_wrapper_html_tag'] ); } if ( ! $elements_data ) { $elements_data = $this->get_elements_data(); } $is_dom_optimization_active = Plugin::elementor()->experiments->is_feature_active( 'e_dom_optimization' ); ?> < get_container_attributes() ); ?>>