Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/elemento.../modules/atomic-w.../utils
File: utils.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Elementor\Modules\AtomicWidgets\Utils;
[2] Fix | Delete
[3] Fix | Delete
use Elementor\Core\Base\Document;
[4] Fix | Delete
use Elementor\Modules\AtomicWidgets\Elements\Base\Atomic_Element_Base;
[5] Fix | Delete
use Elementor\Modules\AtomicWidgets\Elements\Base\Atomic_Widget_Base;
[6] Fix | Delete
use Elementor\Plugin;
[7] Fix | Delete
[8] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[9] Fix | Delete
exit; // Exit if accessed directly.
[10] Fix | Delete
}
[11] Fix | Delete
[12] Fix | Delete
class Utils {
[13] Fix | Delete
public static function is_atomic( $element_instance ): bool {
[14] Fix | Delete
return $element_instance instanceof Atomic_Element_Base ||
[15] Fix | Delete
$element_instance instanceof Atomic_Widget_Base;
[16] Fix | Delete
}
[17] Fix | Delete
[18] Fix | Delete
public static function generate_id( string $prefix = '', $existing_ids = [] ): string {
[19] Fix | Delete
do {
[20] Fix | Delete
$generated = substr(
[21] Fix | Delete
bin2hex( random_bytes( 4 ) ),
[22] Fix | Delete
0,
[23] Fix | Delete
7
[24] Fix | Delete
);
[25] Fix | Delete
[26] Fix | Delete
$id = "$prefix{$generated}";
[27] Fix | Delete
} while ( in_array( $id, $existing_ids, true ) );
[28] Fix | Delete
[29] Fix | Delete
return $id;
[30] Fix | Delete
}
[31] Fix | Delete
[32] Fix | Delete
public static function is_post_published( Document $document ): bool {
[33] Fix | Delete
return $document->get_post()->post_status === Document::STATUS_PUBLISH;
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
public static function traverse_post_elements( string $post_id, callable $callback ): void {
[37] Fix | Delete
$documents = Plugin::$instance->documents;
[38] Fix | Delete
$document = is_preview() ? $documents->get_doc_or_auto_save( $post_id, get_current_user_id() ) : $documents->get( $post_id );
[39] Fix | Delete
[40] Fix | Delete
if ( ! $document ) {
[41] Fix | Delete
return;
[42] Fix | Delete
}
[43] Fix | Delete
[44] Fix | Delete
$elements_data = $document->get_elements_data();
[45] Fix | Delete
[46] Fix | Delete
if ( empty( $elements_data ) ) {
[47] Fix | Delete
return;
[48] Fix | Delete
}
[49] Fix | Delete
[50] Fix | Delete
Plugin::$instance->db->iterate_data( $elements_data, function( $element_data ) use ( $callback ) {
[51] Fix | Delete
call_user_func( $callback, $element_data );
[52] Fix | Delete
} );
[53] Fix | Delete
}
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function