PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.0-beta3
Elementor Website Builder – more than just a page builder v4.3.0-beta3
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
elementor / modules / atomic-widgets / utils / element-structure-title.php

element-structure-title.php in Elementor Website Builder – more than just a page builder 4.3.0-beta3, at modules/atomic-widgets/utils/element-structure-title.php

70 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Modules\AtomicWidgets\Utils;
4
5 use Elementor\Modules\GlobalClasses\Utils\Atomic_Elements_Utils;
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit;
9 }
10
11 class Element_Structure_Title {
12
13 public static function resolve( array $element ): ?string {
14 $editor_title = $element['editor_settings']['title'] ?? null;
15
16 if ( is_string( $editor_title ) && '' !== $editor_title ) {
17 return $editor_title;
18 }
19
20 $settings = $element['settings'] ?? [];
21
22 if ( is_array( $settings ) ) {
23 foreach ( [ '_title', 'presetTitle' ] as $key ) {
24 $plain = self::extract_plain_string( $settings[ $key ] ?? null );
25
26 if ( null !== $plain ) {
27 return $plain;
28 }
29 }
30 }
31
32 $type = $element['widgetType'] ?? $element['elType'] ?? null;
33
34 if ( ! $type ) {
35 return null;
36 }
37
38 $instance = Atomic_Elements_Utils::get_element_instance( (string) $type );
39
40 if ( ! $instance ) {
41 return null;
42 }
43
44 $label = $instance->get_title();
45
46 if ( ! is_string( $label ) || '' === $label ) {
47 return null;
48 }
49
50 return $label;
51 }
52
53 private static function extract_plain_string( $value ): ?string {
54 if ( is_string( $value ) && '' !== $value ) {
55 return $value;
56 }
57
58 if (
59 is_array( $value )
60 && isset( $value['value'] )
61 && is_string( $value['value'] )
62 && '' !== $value['value']
63 ) {
64 return $value['value'];
65 }
66
67 return null;
68 }
69 }
70