start_controls_section( 'boka_content_boxes_section', [ 'label' => __( 'Setting', 'boka' ), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'text_alignment', [ 'label' => __( 'Text Alignment', 'boka' ), 'type' => \Elementor\Controls_Manager::CHOOSE, 'options' => [ 'left' => [ 'title' => __( 'Left', 'boka' ), 'icon' => 'fa fa-align-left', ], 'center' => [ 'title' => __( 'Center', 'boka' ), 'icon' => 'fa fa-align-center', ], 'right' => [ 'title' => __( 'Right', 'boka' ), 'icon' => 'fa fa-align-right', ], ], 'default' => 'center', 'toggle' => true, ] ); $this->add_control( 'columns', [ 'type' => \Elementor\Controls_Manager::SELECT, 'label' => __( 'Columns', 'boka' ), 'default' => __( '4' , 'boka' ), 'options' => array( '6' => __( 'Six', 'boka' ), '4' => __( 'Three', 'boka' ), '3' => __( 'Four', 'boka' ) ), 'label_block' => true, ] ); $this->add_control( 'block_content_divider', [ 'label' => __( 'Block Content', 'boka' ), 'type' => \Elementor\Controls_Manager::HEADING, 'separator' => 'before', ] ); $repeater = new \Elementor\Repeater(); $repeater->add_control( 'media_icon', [ 'label' => __( 'Media or Icon?', 'boka' ), 'type' => \Elementor\Controls_Manager::CHOOSE, 'options' => [ 'media' => [ 'title' => __( 'Image', 'boka' ), 'icon' => 'fa fa-picture-o', ], 'icon' => [ 'title' => __( 'Icon', 'boka' ), 'icon' => 'fa fa-font', ] ], 'default' => 'media', 'toggle' => true, ] ); $repeater->add_control( 'image', [ 'label' => __( 'Choose Image', 'boka' ), 'type' => \Elementor\Controls_Manager::MEDIA, 'default' => [ 'url' => \Elementor\Utils::get_placeholder_image_src(), ], ] ); $repeater->add_control( 'icon', [ 'label' => __( 'Choose Icon', 'boka' ), 'type' => \Elementor\Controls_Manager::ICON, 'default' => '', ] ); $repeater->add_control( 'iconColor', [ 'label' => __( 'Icon Color', 'boka' ), 'type' => \Elementor\Controls_Manager::COLOR, 'scheme' => [ 'type' => \Elementor\Scheme_Color::get_type(), 'value' => \Elementor\Scheme_Color::COLOR_1, ], 'selectors' => [ '{{WRAPPER}} .content-box .fa' => 'color: {{VALUE}}', ], ] ); $repeater->add_control( 'title', [ 'label' => __( 'Title', 'boka' ), 'type' => \Elementor\Controls_Manager::TEXT ] ); $repeater->add_control( 'content', [ 'label' => __( 'Content', 'boka' ), 'type' => \Elementor\Controls_Manager::TEXTAREA ] ); $repeater->add_control( 'btn_text', [ 'label' => __( 'Button Text', 'boka' ), 'type' => \Elementor\Controls_Manager::TEXT ] ); $repeater->add_control( 'btn_url', [ 'label' => __( 'Button URL', 'boka' ), 'type' => \Elementor\Controls_Manager::URL, 'placeholder' => __( 'https://your-link.com', 'boka' ), 'show_external' => true, 'default' => [ 'url' => '#' ], ] ); $this->add_control( 'list', [ 'label' => __( 'Items', 'boka' ), 'type' => \Elementor\Controls_Manager::REPEATER, 'fields' => $repeater->get_controls(), 'default' => [ [ 'title' => __( 'Title', 'boka' ) ] ], 'title_field' => '{{{ title }}}', ] ); $this->end_controls_section(); } /** * Render oEmbed widget output on the frontend. * * Written in PHP and used to generate the final HTML. * * @since 1.0.0 * @access protected */ protected function render() { $settings = $this->get_settings_for_display(); ?>
$contentBox ) : ?>
<# if ( settings.list.length ) { #>
<# _.each( settings.list, function( item ) { #>
<# if ( item.media_icon == 'icon' ) { #>
<# } #> <# if ( item.media_icon == 'image' ) { #>
<# } #> <# if ( item.title ) { #>

{{{ item.title }}}

<# } #> <# if ( item.content ) { #>

{{{ item.content }}}

<# } #> <# if ( item.btn_text ) { #>

{{ item.btn_text }} →

<# } #>
<# }); #>
<# } #> widgets_manager->register_widget_type( new Boka_Content_Boxes() );