File "partner.php"

Full Path: /home/flipjqml/onlinebetsolution.com/wp-content/plugins/cyarb-toolkit/widgets/partner.php
File size: 4.65 KB
MIME-type: text/x-php
Charset: utf-8

<?php
/**
 * Partner Logo Widget
 */

namespace Elementor;

// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class Cyarb_Partner_Logo extends Widget_Base {

	public function get_name() {
        return 'Partner_Logo';
    }

	public function get_title() {
        return __( 'Partner Logo', 'cyarb-toolkit' );
    }

	public function get_icon() {
        return 'eicon-logo';
    }

	public function get_categories() {
        return [ 'cyarb-elements' ];
    }

	protected function register_controls() {

        $this->start_controls_section(
			'partner_section',
			[
				'label' => __( 'Partner Logo Control', 'cyarb-toolkit' ),
				'tab'   => Controls_Manager::TAB_CONTENT,
			]
        );
			$this->add_control(
				'choose_style',
				[
					'label'   => __( 'Choose Style', 'cyarb-toolkit' ),
					'type'    => Controls_Manager::SELECT,
					'options' => [
						'1'         => __( 'Style One', 'cyarb-toolkit' ),
						'2'         => __( 'Style Two', 'cyarb-toolkit' ),
					],
					'default' => '1',
				]
			);
			$this->add_control(
				'title',
				[
					'label'     => esc_html__( 'Add Title', 'cyarb-toolkit' ),
					'type'      => Controls_Manager::TEXT,
					'condition' => [
                        'choose_style' => '1',
                    ] 
				]
			);
			$repeater = new Repeater();
            $repeater->add_control(
                'logo', [
					'type'    => Controls_Manager::MEDIA,
					'label'   => esc_html__( 'Logo', 'cyarb-toolkit' ),
                ]
            );
			$repeater->add_control(
				'logo_url',
				[
					'label'   => __( 'Logo URL', 'cyarb-toolkit' ),
					'type'    => Controls_Manager::TEXT,
					'default' => __('#', 'cyarb-toolkit'),
				]
			);
            $this->add_control(
                'logos',
                [
                    'label'  => esc_html__( 'Add Partner Logo', 'cyarb-toolkit' ),
                    'type'   => Controls_Manager::REPEATER,
                    'fields' => $repeater->get_controls(),
                ]
            );
        $this->end_controls_section();

		$this->start_controls_section(
			'section_style',
			[
				'label'     => esc_html__( 'Style', 'cyarb-toolkit' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => [
					'choose_style' => '1',
				] 
			]
        );
			$this->add_control(
				'title_color',
				[
					'label'     => esc_html__( 'Title Color', 'cyarb-toolkit' ),
					'type'      => Controls_Manager::COLOR,
					'selectors' => [
						'{{WRAPPER}} .partner-title h4' => 'color: {{VALUE}}',
					],
				]
			);
			$this->add_group_control(
				Group_Control_Typography::get_type(),
				[
					'name'     => 'title_typography',
					'label'    => __( 'Title Typography', 'cyarb-toolkit' ),
					'selector' => '{{WRAPPER}} .partner-title h4',
				]
			);
		$this->end_controls_section();

    }

	protected function render() {
        $settings = $this->get_settings_for_display();

        ?>
		<?php if( $settings['choose_style'] == '1' ): ?>
			<div class="partner-area">
				<div class="container">
					<div class="row align-items-center">
						<div class="col-lg-3 col-md-12">
							<div class="partner-title">
								<h4><?php echo esc_html( $settings['title'] ); ?></h4>
							</div>
						</div>
						<div class="col-lg-9 col-md-12">
							<div class="partners-list align-items-center">
								<div class="partner-carousel owl-carousel owl-theme">
									<?php foreach( $settings['logos'] as $item ): ?>
										<div class="partner-item">
											<a href="<?php echo esc_html( $item['logo_url'] ); ?>" target="_blank" class="d-inline-block">
												<img src="<?php echo esc_url( $item['logo']['url'] ); ?>" alt="<?php echo esc_attr__( 'Partner-Logo', 'cyarb-toolkit' ); ?>">
											</a>
										</div>
									<?php endforeach; ?>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		<?php else: ?>
			<div class="partner-style-two-area pb-100">
				<div class="container">
					<div class="partner-slides owl-carousel owl-theme">
						<?php foreach( $settings['logos'] as $item ): ?>
							<div class="partner-item-card">
								<a href="<?php echo esc_html( $item['logo_url'] ); ?>" target="_blank" class="d-inline-block">
									<img src="<?php echo esc_url( $item['logo']['url'] ); ?>" alt="<?php echo esc_attr__( 'Partner-Logo', 'cyarb-toolkit' ); ?>">
								</a>
							</div>
						<?php endforeach; ?>
					</div>
				</div>
			</div>
		<?php endif; ?>
        <?php
	}

}

Plugin::instance()->widgets_manager->register_widget_type( new Cyarb_Partner_Logo );