| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Core\Kits\Documents\Tabs; |
| 4 |
|
| 5 |
use Elementor\Controls_Manager; |
| 6 |
use Elementor\DB; |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; // Exit if accessed directly |
| 10 |
} |
| 11 |
|
| 12 |
class Settings_Site_Identity extends Tab_Base { |
| 13 |
|
| 14 |
public function get_id() { |
| 15 |
return 'settings-site-identity'; |
| 16 |
} |
| 17 |
|
| 18 |
public function get_title() { |
| 19 |
return __( 'Site Identity', 'elementor' ); |
| 20 |
} |
| 21 |
|
| 22 |
protected function register_tab_controls() { |
| 23 |
$custom_logo_id = get_theme_mod( 'custom_logo' ); |
| 24 |
$custom_logo_src = wp_get_attachment_image_src( $custom_logo_id, 'full' ); |
| 25 |
|
| 26 |
$this->start_controls_section( |
| 27 |
'section_' . $this->get_id(), |
| 28 |
[ |
| 29 |
'label' => $this->get_title(), |
| 30 |
'tab' => $this->get_id(), |
| 31 |
] |
| 32 |
); |
| 33 |
|
| 34 |
$this->add_control( |
| 35 |
$this->get_id() . '_refresh_notice', |
| 36 |
[ |
| 37 |
'type' => Controls_Manager::RAW_HTML, |
| 38 |
'raw' => __( 'Changes will be reflected in the preview only after the page reloads.', 'elementor' ), |
| 39 |
'content_classes' => 'elementor-panel-alert elementor-panel-alert-info', |
| 40 |
] |
| 41 |
); |
| 42 |
|
| 43 |
$this->add_control( |
| 44 |
'site_name', |
| 45 |
[ |
| 46 |
'label' => __( 'Site Name', 'elementor' ), |
| 47 |
'default' => get_option( 'blogname' ), |
| 48 |
'placeholder' => __( 'Choose name', 'elementor' ), |
| 49 |
'label_block' => true, |
| 50 |
] |
| 51 |
); |
| 52 |
|
| 53 |
$this->add_control( |
| 54 |
'site_description', |
| 55 |
[ |
| 56 |
'label' => __( 'Site Description', 'elementor' ), |
| 57 |
'default' => get_option( 'blogdescription' ), |
| 58 |
'placeholder' => __( 'Choose description', 'elementor' ), |
| 59 |
'label_block' => true, |
| 60 |
] |
| 61 |
); |
| 62 |
|
| 63 |
$this->add_control( |
| 64 |
'site_logo', |
| 65 |
[ |
| 66 |
'label' => __( 'Site Logo', 'elementor' ), |
| 67 |
'type' => Controls_Manager::MEDIA, |
| 68 |
'default' => [ |
| 69 |
'id' => $custom_logo_id, |
| 70 |
'url' => $custom_logo_src ? $custom_logo_src[0] : '', |
| 71 |
], |
| 72 |
'description' => __( 'Suggested image dimensions: 350 × 100 pixels.', 'elementor' ), |
| 73 |
] |
| 74 |
); |
| 75 |
|
| 76 |
$this->add_control( |
| 77 |
'site_favicon', |
| 78 |
[ |
| 79 |
'label' => __( 'Site Favicon', 'elementor' ), |
| 80 |
'type' => Controls_Manager::MEDIA, |
| 81 |
'description' => __( 'Suggested favicon dimensions: 512 × 512 pixels.', 'elementor' ), |
| 82 |
] |
| 83 |
); |
| 84 |
|
| 85 |
$this->end_controls_section(); |
| 86 |
} |
| 87 |
|
| 88 |
public function on_save( $data ) { |
| 89 |
if ( ! isset( $data['settings'] ) || DB::STATUS_PUBLISH !== $data['settings']['post_status'] ) { |
| 90 |
return; |
| 91 |
} |
| 92 |
if ( isset( $data['settings']['site_name'] ) ) { |
| 93 |
update_option( 'blogname', $data['settings']['site_name'] ); |
| 94 |
} |
| 95 |
|
| 96 |
if ( isset( $data['settings']['site_description'] ) ) { |
| 97 |
update_option( 'blogdescription', $data['settings']['site_description'] ); |
| 98 |
} |
| 99 |
|
| 100 |
if ( isset( $data['settings']['site_logo'] ) ) { |
| 101 |
set_theme_mod( 'custom_logo', $data['settings']['site_logo']['id'] ); |
| 102 |
} |
| 103 |
|
| 104 |
if ( isset( $data['settings']['site_favicon'] ) ) { |
| 105 |
update_option( 'site_icon', $data['settings']['site_favicon']['id'] ); |
| 106 |
} |
| 107 |
} |
| 108 |
} |
| 109 |
|