start_controls_section( 'button', [ 'label' => esc_html__( 'Thinkai Button', 'thinkai' ), ] ); $this->add_control( 'btn_style', [ 'label' => esc_html__( 'Choose Button Style', 'thinkai' ), 'label_block' => true, 'type' => Controls_Manager::SELECT, 'default' => '1', 'options' => array( '1' => esc_html__( 'Style One ', 'thinkai'), '2' => esc_html__( 'Style Two', 'thinkai' ), '3' => esc_html__( 'Style Three', 'thinkai' ), '4' => esc_html__( 'Style Four', 'thinkai' ), ), ] ); $this->add_control( 'btn_title', [ 'label' => __( 'Button Title', 'thinkai' ), 'type' => Controls_Manager::TEXT, 'label_block' => true, 'dynamic' => [ 'active' => true, ], 'placeholder' => __( 'Enter your Button Title Here', 'thinkai' ), ] ); $this->add_control( 'link_option', [ 'label' => esc_html__( 'Select link Option', 'thinkai' ), 'label_block' => true, 'type' => Controls_Manager::SELECT, 'default' => 'extranal', 'options' => array( 'extranal' => esc_html__( 'Extranal ', 'thinkai'), 'page' => esc_html__( 'Page ', 'thinkai'), ), ] ); $this->add_control( 'link', [ 'label' => __( 'External Link', 'thinkai' ), 'type' => Controls_Manager::URL, 'label_block' => true, 'placeholder' => __( 'https://your-link.com', 'thinkai' ), 'show_external' => true, 'default' => [ 'url' => '', 'is_external' => true, 'nofollow' => true, ], 'condition' => [ 'link_option' => 'extranal' ] ] ); $this->add_control( 'page_select', [ 'label' => esc_html__( 'Select Page', 'thinkai' ), 'label_block' => true, 'type' => Controls_Manager::SELECT2, 'default' => 'extranal', 'options' => thinkai_page_list(), 'condition' => [ 'link_option' => 'page' ] ] ); $this->end_controls_section(); /**Button Style**/ $this->start_controls_section( 'button_style', [ 'label' => esc_html__('Button Style Setting', 'thinkai'), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_responsive_control( 'general_align', [ 'label' => esc_html__( 'Alignment', 'thinkai' ), 'type' => Controls_Manager::CHOOSE, 'options' => [ 'left' => [ 'title' => esc_html__( 'Left', 'thinkai' ), 'icon' => 'eicon-text-align-left', ], 'center' => [ 'title' => esc_html__( 'Center', 'thinkai' ), 'icon' => 'eicon-text-align-center', ], 'right' => [ 'title' => esc_html__( 'Right', 'thinkai' ), 'icon' => 'eicon-text-align-right', ], ], 'default' => '', 'selectors' => [ '{{WRAPPER}} .yt-btn' => 'text-align: {{VALUE}}', ], ] ); $this->start_controls_tabs( 'thinkai_tabs_btn' ); $this->start_controls_tab( 'thinkai_tab_btn_normal', [ 'label' => __( 'Normal', 'thinkai' ), ] ); $this->add_responsive_control( 'btn_width_size', [ 'label' => __( 'Width', 'thinkai' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px', 'em', '%', 'custom' ], 'range' => [ 'px' => [ 'min' => 0, 'max' => 500, ], '%' => [ 'min' => 0, 'max' => 100, ], ], 'selectors' => [ '{{WRAPPER}} .thinkai-btn' => 'width: {{SIZE}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'btn_height_size', [ 'label' => __( 'Height', 'thinkai' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px', 'em', '%', 'custom' ], 'range' => [ 'px' => [ 'min' => 0, 'max' => 500, ], '%' => [ 'min' => 0, 'max' => 100, ], ], 'selectors' => [ '{{WRAPPER}} .thinkai-btn' => 'height: {{SIZE}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'btn_margin', [ 'label' => __( 'Margin', 'thinkai' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em', '%' ], 'selectors' => [ '{{WRAPPER}} .thinkai-btn' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;', ], 'frontend_available' => true, ] ); $this->add_responsive_control( 'btn_padding', [ 'label' => __( 'Padding', 'thinkai' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em', '%' ], 'selectors' => [ '{{WRAPPER}} .thinkai-btn' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;', ], 'frontend_available' => true, ] ); $this->add_group_control( Group_Control_Border::get_type(), [ 'name' => 'btn_border_type', 'selector' => '{{WRAPPER}} .thinkai-btn', 'separator' => 'before', ] ); $this->add_group_control( Group_Control_Box_Shadow::get_type(), [ 'name' => 'border_box_shadow', 'selector' => '{{WRAPPER}} .thinkai-btn', 'separator' => 'before', ] ); $this->add_control( 'btn_border_radius', [ 'label' => esc_html__('Border Radius', 'thinkai'), 'type' => Controls_Manager::DIMENSIONS, 'separator' => 'before', 'size_units' => ['px'], 'selectors' => [ '{{WRAPPER}} .thinkai-btn' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'btn_title_typography', 'label' => __('Button Text Typography', 'thinkai'), 'selector' => '{{WRAPPER}} .thinkai-btn', 'separator' => 'before', ] ); $this->add_group_control( Group_Control_Background::get_type(), [ 'name' => 'btn_title_bg_color', 'label' => __( 'Button Background Color', 'thinkai' ), 'types' => [ 'classic', 'gradient' ], 'selector' => '{{WRAPPER}} .thinkai-btn:before, {{WRAPPER}} .thinkai-btn', ] ); $this->add_control( 'btn_title_color', [ 'label' => __('Button Text Color', 'thinkai'), 'type' => Controls_Manager::COLOR, 'default' => '', 'selectors' => [ '{{WRAPPER}} .thinkai-btn' => 'color: {{VALUE}}!important', '{{WRAPPER}} .thinkai-btn span' => 'color: {{VALUE}}!important', ], 'separator' => 'before', ] ); $this->end_controls_tab(); $this->start_controls_tab( 'thinkai_tab_btn_hover', [ 'label' => __( 'Hover', 'thinkai' ), ] ); $this->add_group_control( Group_Control_Background::get_type(), [ 'name' => 'btn_hover_bg_bgtype', 'label' => __( 'Button Hover Background', 'thinkai' ), 'types' => [ 'classic', 'gradient' ], 'selector' => '{{WRAPPER}} .thinkai-btn:hover:before, {{WRAPPER}} .thinkai-btn:hover', ] ); $this->add_control( 'btn_border_color', [ 'label' => __('Button Border Color', 'thinkai'), 'type' => Controls_Manager::COLOR, 'default' => '', 'selectors' => [ '{{WRAPPER}} .thinkai-btn:hover' => 'border-color: {{VALUE}}!important', ], 'separator' => 'before', ] ); $this->add_control( 'btn_title_hover_color', [ 'label' => __('Button Text Hover Color', 'thinkai'), 'type' => Controls_Manager::COLOR, 'default' => '', 'selectors' => [ '{{WRAPPER}} .thinkai-btn:hover' => 'color: {{VALUE}} !important', '{{WRAPPER}} .thinkai-btn:hover span' => 'color: {{VALUE}} !important', ], 'separator' => 'before', ] ); $this->end_controls_tab(); $this->end_controls_tabs(); $this->end_controls_section(); } /** * Render button 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(); $allowed_tags = wp_kses_allowed_html('post'); $btn_style = $settings[ 'btn_style' ]; $page = $settings['link_option']; $page_select = $settings[ 'page_select' ]; $ext_url = $settings[ 'link' ]; if( $page == 'page' ){ $mount_link = get_page_link( $page_select ); }else{ $mount_link = $ext_url['url']; $target = $ext_url['is_external'] ? ' target="_blank"' : ''; $nofollow = $ext_url['nofollow'] ? ' rel="nofollow"' : ''; } ?>
>
class="thinkai-btn">
>
>