PluginProbe
Elementor Website Builder – more than just a page builder / 3.8.0-beta1
Elementor Website Builder – more than just a page builder v3.8.0-beta1
4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 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 All 457 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.8.0-beta1, at core/kits/documents/tabs/settings-site-identity.php

168 lines 4.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\Base\Document;
7 use Elementor\Core\Files\Uploads_Manager;
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 esc_html__( '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 = ! Uploads_Manager::are_unfiltered_uploads_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' => esc_html__( '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' => esc_html__( 'Site Name', 'elementor' ),
66 'default' => get_option( 'blogname' ),
67 'placeholder' => esc_html__( 'Choose name', 'elementor' ),
68 'label_block' => true,
69 'export' => false,
70 ]
71 );
72
73 $this->add_control(
74 'site_description',
75 [
76 'label' => esc_html__( 'Site Description', 'elementor' ),
77 'default' => get_option( 'blogdescription' ),
78 'placeholder' => esc_html__( 'Choose description', 'elementor' ),
79 'label_block' => true,
80 'export' => false,
81 ]
82 );
83
84 $this->add_control(
85 'site_logo',
86 [
87 'label' => esc_html__( 'Site Logo', 'elementor' ),
88 'type' => Controls_Manager::MEDIA,
89 'should_include_svg_inline_option' => $should_include_svg_inline_option,
90 'default' => [
91 'id' => $custom_logo_id,
92 'url' => $custom_logo_src ? $custom_logo_src[0] : '',
93 ],
94 'description' => sprintf(
95 /* translators: 1: Width number pixel, 2: Height number pixel. */
96 esc_html__( 'Suggested image dimensions: %1$s × %2$s pixels.', 'elementor' ),
97 '350',
98 '100'
99 ),
100 'export' => false,
101 ]
102 );
103
104 $this->add_control(
105 'custom_logo_promotion',
106 [
107 'type' => Controls_Manager::RAW_HTML,
108 'raw' => '<p>' . esc_html__( 'Add a logo to display on your website. Don\'t have one yet? Create a professional logo with Fiverr\'s logo maker.', 'elementor' ) .
109 '</p>' .
110 sprintf(
111 '<a target="_blank" class="elementor-button e-logo-maker" href="%s">%s</a>',
112 'https://go.fiverr.com/visit/?bta=496327&brand=fiverrcpa&utm_campaign=SiteLogo&landingPage=https%3A%2F%2Fwww.fiverr.com%2Flogo-maker%2Felementor',
113 esc_html__( 'Create a Logo in Minutes', 'elementor' )
114 ),
115 'condition' => [
116 'site_logo[url]' => '',
117 ],
118 'content_classes' => 'elementor-panel-alert elementor-panel-alert-success',
119 ]
120 );
121
122 $this->add_control(
123 'site_favicon',
124 [
125 'label' => esc_html__( 'Site Favicon', 'elementor' ),
126 'type' => Controls_Manager::MEDIA,
127 'should_include_svg_inline_option' => $should_include_svg_inline_option,
128 'default' => [
129 'id' => $site_icon_id,
130 'url' => $site_icon_src ? $site_icon_src[0] : '',
131 ],
132 'description' => esc_html__( 'Suggested favicon dimensions: 512 × 512 pixels.', 'elementor' ),
133 'export' => false,
134 ]
135 );
136
137 $this->end_controls_section();
138 }
139
140 public function on_save( $data ) {
141 if (
142 ! isset( $data['settings']['post_status'] ) ||
143 Document::STATUS_PUBLISH !== $data['settings']['post_status'] ||
144 // Should check for the current action to avoid infinite loop
145 // when updating options like: "blogname" and "blogdescription".
146 strpos( current_action(), 'update_option_' ) === 0
147 ) {
148 return;
149 }
150
151 if ( isset( $data['settings']['site_name'] ) ) {
152 update_option( 'blogname', $data['settings']['site_name'] );
153 }
154
155 if ( isset( $data['settings']['site_description'] ) ) {
156 update_option( 'blogdescription', $data['settings']['site_description'] );
157 }
158
159 if ( isset( $data['settings']['site_logo'] ) ) {
160 set_theme_mod( 'custom_logo', $data['settings']['site_logo']['id'] );
161 }
162
163 if ( isset( $data['settings']['site_favicon'] ) ) {
164 update_option( 'site_icon', $data['settings']['site_favicon']['id'] );
165 }
166 }
167 }
168