__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
namespace Elementor\Modules\GlobalClasses;
use Elementor\Plugin;
use Elementor\Modules\AtomicWidgets\Styles\Atomic_Styles_Manager;
class Atomic_Global_Styles {
const STYLES_KEY = 'global';
public function register_hooks() {
add_action(
'elementor/atomic-widgets/styles/register',
fn( Atomic_Styles_Manager $styles_manager ) => $this->register_styles( $styles_manager ),
20,
2
);
add_action( 'elementor/global_classes/update', fn( string $context ) => $this->invalidate_cache( $context ), 10, 1 );
add_action(
'deleted_post',
fn( $post_id ) => $this->on_post_delete( $post_id )
);
add_action(
'elementor/core/files/clear_cache',
fn() => $this->invalidate_cache(),
);
add_filter('elementor/atomic-widgets/settings/transformers/classes',
fn( $value ) => $this->transform_classes_names( $value )
);
}
private function register_styles( Atomic_Styles_Manager $styles_manager ) {
$context = is_preview() ? Global_Classes_Repository::CONTEXT_PREVIEW : Global_Classes_Repository::CONTEXT_FRONTEND;
$get_styles = function () use ( $context ) {
return Global_Classes_Repository::make()->context( $context )->all()->get_items()->map( function( $item ) {
$item['id'] = $item['label'];
return $item;
})->all();
};
$styles_manager->register(
[ self::STYLES_KEY, $context ],
$get_styles,
);
}
private function on_post_delete( $post_id ) {
if ( ! Plugin::$instance->kits_manager->is_kit( $post_id ) ) {
return;
}
$this->invalidate_cache();
}
private function invalidate_cache( ?string $context = null ) {
if ( empty( $context ) || Global_Classes_Repository::CONTEXT_FRONTEND === $context ) {
do_action( 'elementor/atomic-widgets/styles/clear', [ self::STYLES_KEY ] );
return;
}
do_action( 'elementor/atomic-widgets/styles/clear', [ self::STYLES_KEY, $context ] );
}
private function transform_classes_names( $ids ) {
$context = is_preview() ? Global_Classes_Repository::CONTEXT_PREVIEW : Global_Classes_Repository::CONTEXT_FRONTEND;
$classes = Global_Classes_Repository::make()
->context( $context )
->all()
->get_items();
return array_map(
function( $id ) use ( $classes ) {
$class = $classes->get( $id );
return $class ? $class['label'] : $id;
},
$ids
);
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| database | Folder | 0775 |
|
|
| import-export | Folder | 0775 |
|
|
| import-export-customization | Folder | 0775 |
|
|
| usage | Folder | 0775 |
|
|
| utils | Folder | 0775 |
|
|
| atomic-global-styles.php | File | 2.26 KB | 0664 |
|
| global-classes-changes-resolver.php | File | 1.67 KB | 0664 |
|
| global-classes-cleanup.php | File | 2.6 KB | 0664 |
|
| global-classes-parser.php | File | 3.35 KB | 0664 |
|
| global-classes-repository.php | File | 2.24 KB | 0664 |
|
| global-classes-rest-api.php | File | 9.12 KB | 0664 |
|
| global-classes.php | File | 691 B | 0664 |
|
| module.php | File | 2.71 KB | 0664 |
|