start_controls_section( 'content_section', array( 'label' => __( 'Settings', 'ultimate-post' ), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ) ); $this->add_control( 'saved_template', array( 'label' => __( 'Saved Template', 'ultimate-post' ), 'type' => \Elementor\Controls_Manager::SELECT, 'options' => ultimate_post()->get_all_lists( 'ultp_templates' ), ) ); $this->add_control( 'edit_template', array( 'type' => \Elementor\Controls_Manager::RAW_HTML, 'raw' => ' ' . __( 'Edit This Template', 'ultimate-post' ) . '', ) ); $this->add_control( 'add_new_template', array( 'type' => \Elementor\Controls_Manager::RAW_HTML, 'raw' => ' ' . __( 'Add New Template', 'ultimate-post' ) . '', ) ); $this->end_controls_section(); } protected function render() { $settings = $this->get_settings_for_display(); $id = $settings['saved_template']; if ( $id ) { if ( isset( $_GET['action'] ) || isset( $_POST['action'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Missing,WordPress.Security.NonceVerification.Recommended echo ultimate_post()->build_css_for_inline_print( $id, true ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } echo '
'; $args = array( 'p' => $id, 'post_type' => 'ultp_templates', ); $the_query = new \WP_Query( $args ); if ( $the_query->have_posts() ) { while ( $the_query->have_posts() ) { $the_query->the_post(); the_content(); } wp_reset_postdata(); } echo '
'; } elseif ( isset( $_GET['action'] ) && $_GET['action'] == 'elementor' ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing,WordPress.Security.NonceVerification.Recommended echo '

' . sprintf( esc_html__( 'Pick a Template from your saved ones. Or create a template from: %s.', 'ultimate-post' ) . ' ', '' . esc_html__( 'Dashboard > PostX > Saved Templates', 'ultimate-post' ) . '' ) . '

'; } } }