PluginProbe
Elementor Website Builder – more than just a page builder / 3.1.4
Elementor Website Builder – more than just a page builder v3.1.4
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 / core / kits / documents / tabs / settings-site-identity.php

settings-site-identity.php in Elementor Website Builder – more than just a page builder 3.1.4, at core/kits/documents/tabs/settings-site-identity.php

141 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Core\Kits\Documents\Tabs;
4
5 use Elementor\Controls_Manager;
6 use Elementor\Core\Files\Assets\Files_Upload_Handler;
7 use Elementor\Core\Base\Document;
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit; // Exit if accessed directly
11 }
12
13 class Settings_Site_Identity extends Tab_Base {
14
15 public function get_id() {
16 return 'settings-site-identity';
17 }
18
19 public function get_title() {
20 return __( 'Site Identity', 'elementor' );
21 }
22
23 public function get_group() {
24 return 'settings';
25 }
26
27 public function get_icon() {
28 return 'eicon-site-identity';
29 }
30
31 public function get_help_url() {
32 return 'https://go.elementor.com/global-site-identity';
33 }
34
35 protected function register_tab_controls() {
36 $custom_logo_id = get_theme_mod( 'custom_logo' );
37 $custom_logo_src = wp_get_attachment_image_src( $custom_logo_id, 'full' );
38
39 $site_icon_id = get_option( 'site_icon' );
40 $site_icon_src = wp_get_attachment_image_src( $site_icon_id, 'full' );
41
42 // If CANNOT upload svg normally, it will add a custom inline option to force svg upload if requested. (in logo and favicon)
43 $should_include_svg_inline_option = ! Files_Upload_Handler::is_enabled();
44
45 $this->start_controls_section(
46 'section_' . $this->get_id(),
47 [
48 'label' => $this->get_title(),
49 'tab' => $this->get_id(),
50 ]
51 );
52
53 $this->add_control(
54 $this->get_id() . '_refresh_notice',
55 [
56 'type' => Controls_Manager::RAW_HTML,
57 'raw' => __( 'Changes will be reflected in the preview only after the page reloads.', 'elementor' ),
58 'content_classes' => 'elementor-panel-alert elementor-panel-alert-info',
59 ]
60 );
61
62 $this->add_control(
63 'site_name',
64 [
65 'label' => __( 'Site Name', 'elementor' ),
66 'default' => get_option( 'blogname' ),
67 'placeholder' => __( 'Choose name', 'elementor' ),
68 'label_block' => true,
69 ]
70 );
71
72 $this->add_control(
73 'site_description',
74 [
75 'label' => __( 'Site Description', 'elementor' ),
76 'default' => get_option( 'blogdescription' ),
77 'placeholder' => __( 'Choose description', 'elementor' ),
78 'label_block' => true,
79 ]
80 );
81
82 $this->add_control(
83 'site_logo',
84 [
85 'label' => __( 'Site Logo', 'elementor' ),
86 'type' => Controls_Manager::MEDIA,
87 'should_include_svg_inline_option' => $should_include_svg_inline_option,
88 'default' => [
89 'id' => $custom_logo_id,
90 'url' => $custom_logo_src ? $custom_logo_src[0] : '',
91 ],
92 'description' => __( 'Suggested image dimensions: 350 × 100 pixels.', 'elementor' ),
93 ]
94 );
95
96 $this->add_control(
97 'site_favicon',
98 [
99 'label' => __( 'Site Favicon', 'elementor' ),
100 'type' => Controls_Manager::MEDIA,
101 'should_include_svg_inline_option' => $should_include_svg_inline_option,
102 'default' => [
103 'id' => $site_icon_id,
104 'url' => $site_icon_src ? $site_icon_src[0] : '',
105 ],
106 'description' => __( 'Suggested favicon dimensions: 512 × 512 pixels.', 'elementor' ),
107 ]
108 );
109
110 $this->end_controls_section();
111 }
112
113 public function on_save( $data ) {
114 if (
115 ! isset( $data['settings'] ) ||
116 Document::STATUS_PUBLISH !== $data['settings']['post_status'] ||
117 // Should check for the current action to avoid infinite loop
118 // when updating options like: "blogname" and "blogdescription".
119 strpos( current_action(), 'update_option_' ) === 0
120 ) {
121 return;
122 }
123
124 if ( isset( $data['settings']['site_name'] ) ) {
125 update_option( 'blogname', $data['settings']['site_name'] );
126 }
127
128 if ( isset( $data['settings']['site_description'] ) ) {
129 update_option( 'blogdescription', $data['settings']['site_description'] );
130 }
131
132 if ( isset( $data['settings']['site_logo'] ) ) {
133 set_theme_mod( 'custom_logo', $data['settings']['site_logo']['id'] );
134 }
135
136 if ( isset( $data['settings']['site_favicon'] ) ) {
137 update_option( 'site_icon', $data['settings']['site_favicon']['id'] );
138 }
139 }
140 }
141