*/ /** * Elementor smart post show free shortcode Widget. * * @since 2.4.1 */ class Shortcode_Widget extends \Elementor\Widget_Base { /** * Get widget name. * * @since 2.4.1 * @access public * * @return string Widget name. */ public function get_name() { return 'smart_post_show_pro_shortcode'; } /** * Get widget title. * * @since 2.4.1 * @access public * * @return string Widget title. */ public function get_title() { return __( 'Smart Post Show', 'post-carousel' ); } /** * Get widget icon. * * @since 2.2.5 * @access public * * @return string Widget icon. */ public function get_icon() { return 'sps-icon-icon'; } /** * Get widget categories. * * @since 2.2.5 * @access public * * @return array Widget categories. */ public function get_categories() { return array( 'basic' ); } /** * Get all post list. * * @since 2.2.5 * @return array */ public function sp_pcp_post_list() { $post_list = array(); $sp_pcp_posts = new \WP_Query( array( 'post_type' => 'sp_post_carousel', 'post_status' => 'publish', 'posts_per_page' => 10000, ) ); $posts = $sp_pcp_posts->posts; foreach ( $posts as $post ) { $post_list[ $post->ID ] = $post->post_title; } krsort( $post_list ); return $post_list; } /** * Controls register. * * @return void */ protected function register_controls() { $this->start_controls_section( 'content_section', array( 'label' => __( 'Content', 'post-carousel' ), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ) ); $this->add_control( 'sp_smart_post_show_pro_shortcode', array( 'label' => __( 'Smart Post Show Shortcode(s)', 'post-carousel' ), 'type' => \Elementor\Controls_Manager::SELECT2, 'label_block' => true, 'default' => '', 'options' => $this->sp_pcp_post_list(), ) ); $this->end_controls_section(); } /** * Render smart post show free shortcode widget output on the frontend. * * @since 2.4.1 * @access protected */ protected function render() { $settings = $this->get_settings_for_display(); $sp_pcp_shortcode = $settings['sp_smart_post_show_pro_shortcode']; if ( '' === $sp_pcp_shortcode ) { echo '