is_edit_mode_load()) { $this->enqueue_styles_scripts(); } parent::__construct($data, $args); } /** * Retrieve the widget name. * * @since 1.1.0 * * @access public * * @return string Widget name. */ public function get_name() { return 'wdk-implode-shortcode'; } /** * Retrieve the widget title. * * @since 1.1.0 * * @access public * * @return string Widget title. */ public function get_title() { return esc_html__('Wdk Implode Shortcode', 'wpdirectorykit'); } /** * Retrieve the widget icon. * * @since 1.1.0 * * @access public * * @return string Widget icon. */ public function get_icon() { return 'eicon-post-title'; } /** * Register the widget controls. * * Adds different input fields to allow the user to change and customize the widget settings. * * @since 1.1.0 * * @access protected */ protected function register_controls() { $this->generate_controls_conf(); $this->insert_pro_message('1'); parent::register_controls(); } /** * Render the widget output on the frontend. * * Written in PHP and used to generate the final HTML. * * @since 1.1.0 * * @access protected */ protected function render() { parent::render(); $this->data['id_element'] = $this->get_id(); $this->data['settings'] = $this->get_settings(); $shortcode = $this->data['settings']['shortcode']; $profile_id = wdk_get_profile_page_id(); if(stripos($shortcode, '{profile_id}') !== false && $profile_id){ $shortcode= str_replace('{profile_id}', $profile_id, $shortcode); } global $wdk_listing_id; if(stripos($shortcode, '{listing_id}') !== false && isset($wdk_listing_id)){ $shortcode= str_replace('{listing_id}', $wdk_listing_id, $shortcode); } $this->data['is_edit_mode']= false; if(Plugin::$instance->editor->is_edit_mode()){ echo $shortcode; } else { return do_shortcode($shortcode); } } private function generate_controls_conf() { $this->start_controls_section( 'tab_conf_main_section', [ 'label' => esc_html__('Main', 'wpdirectorykit'), 'tab' => '1', ] ); $this->add_control( 'shortcode', [ 'label' => __( 'Shortcode', 'wpdirectorykit' ), 'type' => \Elementor\Controls_Manager::TEXTAREA, 'description' => ''.__( 'Special vars:', 'wpdirectorykit' ). '
{profile_id} - replaced on profile id'. '
{listing_id} - replaced on listing id'. '
', ] ); $this->end_controls_section(); } }