start_controls_section( 'post_type_section', [ 'label' => __( 'Setting', 'bring-back' ), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'pre_title', [ 'label' => __( 'Pre Title', 'bring-back' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => __( 'Pre Title', 'bring-back' ), 'placeholder' => __( 'Title', 'bring-back' ), ] ); $this->add_control( 'title', [ 'label' => __( 'Title', 'bring-back' ), 'type' => \Elementor\Controls_Manager::WYSIWYG, 'default' => __( 'Title', 'bring-back' ), 'placeholder' => __( 'Title', 'bring-back' ), ] ); $this->add_control( 'paragraph', [ 'label' => __( 'Paragraph', 'bring-back' ), 'type' => \Elementor\Controls_Manager::TEXTAREA, 'default' => __( 'Content Goes Here..', 'bring-back' ), 'placeholder' => __( 'Content', 'bring-back' ), ] ); $this->add_control( 'hr', [ 'type' => \Elementor\Controls_Manager::DIVIDER, 'style' => 'thick', ] ); $this->add_control( 'select_post_type', [ 'label' => __( 'Select Post Type', 'bring-back' ), 'type' => \Elementor\Controls_Manager::SELECT, 'options' => [ 'bb-services' => __( 'BB services', 'bring-back' ), 'bb-case-studies' => __( 'BB case studies', 'bring-back' ) ] ] ); $this->add_control( 'limit', [ 'label' => __( 'Post Limit', 'bring-back' ), 'type' => \Elementor\Controls_Manager::NUMBER, 'min' => absint(1), 'max' => absint(9), 'step' => absint(1), 'default' => absint(3) ] ); $this->add_control( 'hr2', [ 'type' => \Elementor\Controls_Manager::DIVIDER, 'style' => 'thick', ] ); $this->add_control( 'btn_txt', [ 'label' => __( 'Button Text', 'bring-back' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => __( 'Get Started', 'bring-back' ) ] ); $this->add_control( 'btn_url', [ 'label' => __( 'Button URL', 'bring-back' ), 'type' => \Elementor\Controls_Manager::URL, 'placeholder' => __( 'https://your-link.com', 'bring-back' ), 'show_external' => true, 'default' => [ 'url' => '#', 'is_external' => true, 'nofollow' => true, ], ] ); $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(); $post_type = $settings['select_post_type']; $post_limit = $settings['limit']; $pre_title = $settings['pre_title']; $title = $settings['title']; $paragraph = $settings['paragraph']; $target = $settings['btn_url']['is_external'] ? ' target="_blank"' : ''; $nofollow = $settings['btn_url']['nofollow'] ? ' rel="nofollow"' : ''; $query = new \WP_Query( array( 'post_type' => esc_attr( $post_type ), 'posts_per_page' => absint( $post_limit ), 'no_found_rows' => true, 'post_status' => 'publish' ) ); ?>

array( 'href' => array(), 'title' => array() ), 'p' => array(), 'br' => array() ) ); ?>

have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?>
widgets_manager->register_widget_type( new bring_back_Custom_Post_Type() );