start_controls_section( 'settings_section', array( 'label' => esc_html__('Settings', 'wpmf'), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT ) ); $this->add_control( 'wpmf_add_pdf', array( 'label' => esc_html__('Choose PDF', 'wpmf'), 'type' => \Elementor\Controls_Manager::BUTTON, 'text' => esc_html__('SELECT PDF', 'wpmf') ) ); $this->add_control( 'embed', array( 'label' => esc_html__('Embed', 'wpmf'), 'type' => \Elementor\Controls_Manager::SELECT, 'options' => array( 'on' => esc_html__('On', 'wpmf'), 'off' => esc_html__('Off', 'wpmf') ), 'default' => 'on' ) ); $this->add_control( 'target', array( 'label' => esc_html__('Target', 'wpmf'), 'type' => \Elementor\Controls_Manager::SELECT, 'options' => array( '_blank' => esc_html__('New Window', 'wpmf'), 'self' => esc_html__('Same Window', 'wpmf') ), 'default' => 'self' ) ); $this->add_control( 'wpmf_pdf_id', array( 'label' => esc_html__('PDF ID', 'wpmf'), 'type' => \Elementor\Controls_Manager::NUMBER, ) ); $this->end_controls_section(); } /** * Render PDF Embed widget output on the frontend. * * Written in PHP and used to generate the final HTML. * * @return void|string */ protected function render() { if (is_admin()) { require_once(WP_MEDIA_FOLDER_PLUGIN_DIR . 'class/class-pdf-embed.php'); $pdf = new WpmfPdfEmbed(); ?> get_settings_for_display(); $id = (isset($settings['wpmf_pdf_id']) && $settings['wpmf_pdf_id'] !== '') ? $settings['wpmf_pdf_id'] : 0; if (!empty($id)) { $embed = (isset($settings['embed']) && $settings['embed'] === 'on') ? 1 : 0; $target = (isset($settings['target'])) ? $settings['target'] : 'self'; echo do_shortcode('[wpmfpdf id="' . esc_attr($id) . '" embed="' . esc_attr($embed) . '" target="' . esc_attr($target) . '"]'); } else { ?>