Edit File by line
/home/zeestwma/ceyloniy.../wp-conte.../plugins/elemento.../modules/componen.../transfor...
File: component-instance-transformer.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Elementor\Modules\Components\Transformers;
[2] Fix | Delete
[3] Fix | Delete
use Elementor\Modules\AtomicWidgets\PropsResolver\Props_Resolver_Context;
[4] Fix | Delete
use Elementor\Modules\AtomicWidgets\PropsResolver\Transformer_Base;
[5] Fix | Delete
use Elementor\Plugin;
[6] Fix | Delete
use Elementor\Core\Base\Document as Component_Document;
[7] Fix | Delete
use Elementor\Modules\Components\Components_Repository;
[8] Fix | Delete
[9] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[10] Fix | Delete
exit; // Exit if accessed directly.
[11] Fix | Delete
}
[12] Fix | Delete
[13] Fix | Delete
class Component_Instance_Transformer extends Transformer_Base {
[14] Fix | Delete
private static array $rendering_stack = [];
[15] Fix | Delete
private static $repository;
[16] Fix | Delete
[17] Fix | Delete
public static function reset_rendering_stack(): void {
[18] Fix | Delete
self::$rendering_stack = [];
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
public function transform( $value, Props_Resolver_Context $context ) {
[22] Fix | Delete
$component_id = $value['component_id'];
[23] Fix | Delete
[24] Fix | Delete
if ( $this->is_circular_reference( $component_id ) ) {
[25] Fix | Delete
return '';
[26] Fix | Delete
}
[27] Fix | Delete
[28] Fix | Delete
self::$rendering_stack[] = $component_id;
[29] Fix | Delete
$content = $this->get_rendered_content( $component_id );
[30] Fix | Delete
array_pop( self::$rendering_stack );
[31] Fix | Delete
[32] Fix | Delete
return $content;
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
private function is_circular_reference( int $component_id ): bool {
[36] Fix | Delete
return in_array( $component_id, self::$rendering_stack, true );
[37] Fix | Delete
}
[38] Fix | Delete
[39] Fix | Delete
private function get_rendered_content( int $component_id ): string {
[40] Fix | Delete
$should_show_autosave = is_preview();
[41] Fix | Delete
$component = $this->get_repository()->get( $component_id, $should_show_autosave );
[42] Fix | Delete
[43] Fix | Delete
if ( ! $component || ! $this->should_render_content( $component ) ) {
[44] Fix | Delete
return '';
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
Plugin::$instance->documents->switch_to_document( $component );
[48] Fix | Delete
[49] Fix | Delete
$data = $component->get_elements_data();
[50] Fix | Delete
[51] Fix | Delete
$data = apply_filters( 'elementor/frontend/builder_content_data', $data, $component_id );
[52] Fix | Delete
[53] Fix | Delete
$content = '';
[54] Fix | Delete
[55] Fix | Delete
if ( ! empty( $data ) ) {
[56] Fix | Delete
ob_start();
[57] Fix | Delete
[58] Fix | Delete
$component->print_elements( $data );
[59] Fix | Delete
[60] Fix | Delete
$content = ob_get_clean();
[61] Fix | Delete
[62] Fix | Delete
$content = apply_filters( 'elementor/frontend/the_content', $content );
[63] Fix | Delete
}
[64] Fix | Delete
[65] Fix | Delete
Plugin::$instance->documents->restore_document();
[66] Fix | Delete
[67] Fix | Delete
return $content;
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
private function should_render_content( Component_Document $document ): bool {
[71] Fix | Delete
return ! $this->is_password_protected( $document ) &&
[72] Fix | Delete
$document->is_built_with_elementor();
[73] Fix | Delete
}
[74] Fix | Delete
[75] Fix | Delete
private function is_password_protected( $document ) {
[76] Fix | Delete
return post_password_required( $document->get_post()->ID );
[77] Fix | Delete
}
[78] Fix | Delete
[79] Fix | Delete
private function get_repository(): Components_Repository {
[80] Fix | Delete
if ( ! self::$repository ) {
[81] Fix | Delete
self::$repository = new Components_Repository();
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
return self::$repository;
[85] Fix | Delete
}
[86] Fix | Delete
}
[87] Fix | Delete
[88] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function