← All changes
|
modules/global-classes/atomic-global-styles.php
+10
-17
4.1.2
→
4.1.0-beta1
View file →
| @@ -90,11 +90,9 @@ | ||
| 90 | 90 | if ( ! $item ) { |
| 91 | 91 | continue; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - $resolved_label = $global_order[ $class_id ] ?? $item['label']; | |
| 95 | - $item['id'] = $resolved_label; | |
| 96 | - $item['label'] = $resolved_label; | |
| 94 | + $item['id'] = $item['label']; | |
| 97 | 95 | $styles[] = $item; |
| 98 | 96 | } |
| 99 | 97 | |
| 100 | 98 | return $styles; |
| @@ -127,14 +125,8 @@ | ||
| 127 | 125 | |
| 128 | 126 | $document_ids = []; |
| 129 | 127 | $is_preview = Global_Classes_Repository::CONTEXT_PREVIEW === $context; |
| 130 | 128 | |
| 131 | - if ( ! empty( $changes['affected_post_ids'] ) ) { | |
| 132 | - foreach ( $changes['affected_post_ids'] as $post_id ) { | |
| 133 | - $document_ids[ (int) $post_id ] = true; | |
| 134 | - } | |
| 135 | - } | |
| 136 | - | |
| 137 | 129 | foreach ( $affected as $class_id ) { |
| 138 | 130 | foreach ( $this->relations->set_preview( $is_preview )->get_posts_by_style( $class_id ) as $doc_id ) { |
| 139 | 131 | $document_ids[ $doc_id ] = true; |
| 140 | 132 | } |
| @@ -167,13 +159,18 @@ | ||
| 167 | 159 | do_action( 'elementor/atomic-widgets/styles/clear', [ self::STYLES_KEY, $context ] ); |
| 168 | 160 | } |
| 169 | 161 | |
| 170 | 162 | private function transform_classes_names( $ids ) { |
| 163 | + $context = $this->get_context(); | |
| 171 | 164 | |
| 172 | - $labels = Global_Classes_Repository::make() | |
| 173 | - ->set_preview( $this->is_preview() ) | |
| 174 | - ->all_labels(); | |
| 165 | + $repository = Global_Classes_Repository::make(); | |
| 175 | 166 | |
| 167 | + if ( Global_Classes_Repository::CONTEXT_PREVIEW === $context ) { | |
| 168 | + $repository->set_preview( true ); | |
| 169 | + } | |
| 170 | + | |
| 171 | + $labels = $repository->all_labels(); | |
| 172 | + | |
| 176 | 173 | return array_map( |
| 177 | 174 | static function( $id ) use ( $labels ) { |
| 178 | 175 | return $labels[ $id ] ?? $id; |
| 179 | 176 | }, |
| @@ -181,13 +178,9 @@ | ||
| 181 | 178 | ); |
| 182 | 179 | } |
| 183 | 180 | |
| 184 | 181 | private function get_context(): string { |
| 185 | - return $this->is_preview() | |
| 182 | + return Plugin::$instance->preview->is_editor_or_preview() | |
| 186 | 183 | ? Global_Classes_Repository::CONTEXT_PREVIEW |
| 187 | 184 | : Global_Classes_Repository::CONTEXT_FRONTEND; |
| 188 | - } | |
| 189 | - | |
| 190 | - private function is_preview(): bool { | |
| 191 | - return Plugin::$instance->preview->is_editor_or_preview(); | |
| 192 | 185 | } |
| 193 | 186 | } |