Current File : /home/bravrvjk/cepurhuye.rw/wp-content/plugins/bopea-function/block//ads-img.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_ads_img extends Widget_Base {
public function get_name() {
return 'bopea-section-ads-img';
}
public function get_title() {
return esc_html__( 'Ads image', 'bopea-function' );
}
public function get_icon() {
return 'eicon-elementor-circle jl-icons';
}
public function get_categories() {
return [ 'bopea-elements' ];
}
protected function register_controls() {
$this->start_controls_section(
'section_style_marker',
[
'label' => __( 'Ads image settings', 'bopea-function' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'ads_img',
[
'label' => esc_html__( 'Ads image', 'bopea-function' ),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => Utils::get_placeholder_image_src(),
],
]
);
$this->add_control(
'ads_title', [
'label' => esc_html__( 'Ads Title', 'bopea-function' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
'default' => '-Sponsored-',
]
);
$this->add_control(
'ads_url',
[
'label' =>esc_html__( 'Ads URL', 'bopea-function' ),
'label_block' => true,
'type' => Controls_Manager::URL,
]
);
$this->add_responsive_control(
'jl_ads_size',
[
'label' => __( 'Ads max width', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 1,
'max' => 3000,
],
],
'selectors' => [
'{{WRAPPER}}' => '--jl-ads-max: {{SIZE}}px',
],
]
);
$this->add_responsive_control(
'ads_align',
array(
'label' => __( 'Ads 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' => 'center',
'selectors' => array(
'{{WRAPPER}}' => '--jl-ads-algin: {{VALUE}};',
)
)
);
$this->add_control(
'jl_ads_title_color',
[
'label' => __( 'Title color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .jl_ads_title' => 'color: {{VALUE}};',
]
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'jl_cb_ads_typo',
'label' =>esc_html__( 'Typography', 'bopea-function' ),
'selector' => '{{WRAPPER}} .jl_ads_title',
]
);
$this->end_controls_section();
}
protected function render( ) {
$settings = $this->get_settings_for_display();
$ads_title = $settings['ads_title'];
?>
<div class="jl_ads_img_w">
<?php if(!empty($ads_title)){?>
<span class="jl_ads_title"><?php echo wp_kses_post($ads_title);?></span>
<?php }?>
<div class="jl_ads_inner">
<?php
$img_width = '';
$img_height = '';
$img_alt = 'ads image';
if ( ! empty( $settings['ads_img']['id'] ) ) {
$medata = wp_get_attachment_metadata( $settings['ads_img']['id'] );
if ( ! empty( $medata['width'] ) ) { $img_width = $medata['width']; }
if ( ! empty( $medata['height'] ) ) { $img_height = $medata['height']; }
if ( ! empty( $settings['ads_img']['alt'] ) ) { $img_alt = $settings['ads_img']['alt']; }
}
if ( ! empty( $settings['ads_url']['url'] ) ) {
$this->add_render_attribute( 'ads_url', 'class', 'ads_url', true );
$this->add_link_attributes( 'ads_url', $settings['ads_url'] ); ?><a <?php echo $this->get_render_attribute_string( 'ads_url' ); ?>><?php }?><?php if( !empty($settings['ads_img']['url']) ){?><img class="jl_ads_img" src="<?php echo esc_url($settings['ads_img']['url']); ?>"<?php if ( ! empty( $img_width ) ) { echo ' width="'.strip_tags($img_width).'"'; } if ( ! empty( $img_height ) ) { echo ' height="'.strip_tags($img_height).'"'; } if ( ! empty( $img_alt ) ) { echo ' alt="'.strip_tags($img_alt).'"'; }?>/><?php }?><?php if ( ! empty( $settings['ads_url']['url'] ) ) {?></a><?php }?>
</div>
</div>
<?php
}
}