Current File : /home/bravrvjk/cepurhuye.rw/wp-content/plugins/bopea-function/block//logo.php
<?php
namespace bopeaElementor\Widgets;
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Image_Size;
use Elementor\Group_Control_Typography;
use Elementor\Schemes\Color;
use Elementor\Schemes\Typography;
use Elementor\Utils;
use Elementor\Control_Media;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Box_Shadow;
use Elementor\Group_Control_Text_Shadow;
use Elementor\Group_Control_Background;
use Elementor\Repeater;
use Elementor\Icons_Manager;
defined('ABSPATH') || die();
class bopea_section_logo extends Widget_Base {
public function get_name() {
return 'bopea-section-logo';
}
public function get_title() {
return esc_html__( 'Logo', 'bopea-function' );
}
public function get_icon() {
return 'eicon-logo jl-icons';
}
public function get_categories() {
return [ 'bopea-elements-head' ];
}
protected function register_controls() {
if(!empty(get_theme_mod('bopea_logo'))){
$logo_n = get_theme_mod('bopea_logo');
}else{
$logo_n = Utils::get_placeholder_image_src();
}
if(!empty(get_theme_mod('bopea_logow'))){
$logo_w = get_theme_mod('bopea_logow');
}else{
$logo_w = Utils::get_placeholder_image_src();
}
$this->start_controls_section(
'section_style_marker',
[
'label' => __( 'Logo Settings', 'bopea-function' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'logo_n',
[
'label' => esc_html__( 'Logo normal', 'bopea-function' ),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => $logo_n,
],
]
);
$this->add_control(
'logo_w',
[
'label' => esc_html__( 'Logo dark mode', 'bopea-function' ),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => $logo_w,
],
]
);
$this->add_responsive_control(
'jl_logo_size',
[
'label' => __( 'Logo size', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 1,
'max' => 2000,
],
],
'default' => [
'size' => '150',
'unit' => 'px'
],
'selectors' => [
'{{WRAPPER}} .logo_small_wrapper_table' => '--jl-logo-width: {{SIZE}}px',
],
]
);
$this->add_responsive_control(
'logo_align',
array(
'label' => __( 'Alignment', 'bopea-function' ),
'type' => Controls_Manager::CHOOSE,
'options' => array(
'flex-start' => array(
'title' => __( 'Left', 'bopea-function' ),
'icon' => 'eicon-text-align-left',
),
'center' => array(
'title' => __( 'Center', 'bopea-function' ),
'icon' => 'eicon-text-align-center',
),
'flex-end' => array(
'title' => __( 'Right', 'bopea-function' ),
'icon' => 'eicon-text-align-right',
),
),
'toggle' => false,
'default' => 'left',
'selectors' => array(
'{{WRAPPER}} .logo_small_wrapper_table' => 'justify-content: {{VALUE}};',
)
)
);
$this->add_control(
'logo_link',
[
'label' =>esc_html__( 'Logo custom URL', 'bopea-function' ),
'label_block' => true,
'type' => Controls_Manager::URL,
]
);
$this->add_control(
'enable_h1_logo',
[
'label' => esc_html__( 'Enable H1', 'bopea-function' ),
'type' => Controls_Manager::SWITCHER,
'return_value' => 'yes',
'default' => '',
]
);
$this->end_controls_section();
}
protected function render( ) {
$settings = $this->get_settings_for_display();
$enh1_logo = $settings['enable_h1_logo'];
$n_w = '';
$n_h = '';
$n_alt = esc_html( get_bloginfo( 'name' ));
$w_w = '';
$w_h = '';
$w_alt = esc_html( get_bloginfo( 'name' ));
if(empty($enh1_logo)){
$logo_tag = 'span';
}else{
$logo_tag = (is_front_page() ? 'h1' : 'span');
}
if ( ! empty( $settings['logo_n']['id'] ) ) {
$medata = wp_get_attachment_metadata( $settings['logo_n']['id'] );
if ( ! empty( $medata['width'] ) ) { $n_w = $medata['width']; }
if ( ! empty( $medata['height'] ) ) { $n_h = $medata['height']; }
if ( ! empty( $settings['logo_n']['alt'] ) ) { $n_alt = $settings['logo_n']['alt']; }
}
if ( ! empty( $settings['logo_w']['id'] ) ) {
$medata = wp_get_attachment_metadata( $settings['logo_w']['id'] );
if ( ! empty( $medata['width'] ) ) { $w_w = $medata['width']; }
if ( ! empty( $medata['height'] ) ) { $w_h = $medata['height']; }
if ( ! empty( $settings['logo_w']['alt'] ) ) { $w_alt = $settings['logo_w']['alt']; }
}
?>
<div class="logo_small_wrapper_table">
<div class="logo_small_wrapper">
<?php if ( ! empty( $settings['logo_link']['url'] ) ) {
$this->add_render_attribute( 'logo_link', 'class', 'logo_link', true );
$this->add_link_attributes( 'logo_link', $settings['logo_link'] ); ?>
<a <?php echo $this->get_render_attribute_string( 'logo_link' ); ?>>
<?php }else{?>
<a class="logo_link" href="<?php echo esc_url(home_url('/')); ?>" aria-label="<?php echo esc_html( get_bloginfo( 'name' ) );?>">
<?php }?>
<<?php echo esc_html($logo_tag); ?>>
<?php if( !empty($settings['logo_n']['url']) ){?>
<img class="jl_logo_n" src="<?php echo esc_url($settings['logo_n']['url']); ?>"<?php if(!empty($n_w)){echo ' width="'.strip_tags($n_w).'"';} if(!empty($n_h)){echo ' height="'.strip_tags($n_h).'"';} if(!empty($n_alt)){echo ' alt="'.strip_tags($n_alt).'"';}?> />
<?php }?>
<?php if( !empty($settings['logo_w']['url']) ){?>
<img class="jl_logo_w" src="<?php echo esc_url($settings['logo_w']['url']); ?>"<?php if(!empty($w_w)){echo ' width="'.strip_tags($w_w).'"';} if(!empty($w_h)){echo ' height="'.strip_tags($w_h).'"';} if(!empty($w_alt)){echo ' alt="'.strip_tags($w_alt).'"';}?> />
<?php } ?>
</<?php echo esc_html($logo_tag); ?>>
</a>
</div>
</div>
<?php
}
}