start_controls_section( 'avp_section', array( 'label' => __('Audio Player', CPMP_LANG) ) ); // Skins $skins = array(); $skin_dir = CPMP_PLUGIN_DIR.'/skins'; if(file_exists($skin_dir)) { $d = dir($skin_dir); while (false !== ($entry = $d->read())) { if($entry != '.' && $entry != '..' && is_dir($skin_dir.'/'.$entry)) { $this_skin = $skin_dir.'/'.$entry.'/'; if(file_exists($this_skin)) { $skin_data = parse_ini_file($this_skin.'config.ini', true); $skins[$skin_data['id'] ] = esc_html($skin_data['name']); } } } $d->close(); } $this->add_control( 'cpm_player_skin', array( 'label' => __("Player's skin", CPMP_LANG), 'type' => 'cpmskinselect', 'default' => 'classic-skin', 'options' => $skins, 'event' => esc_attr('cpm_select_skin("cpm_audio_player_shortcode");') ) ); $this->add_control( 'cpm_audio_player_shortcode', array( 'label' => __("Player's shortcode", CPMP_LANG), 'type' => Controls_Manager::TEXTAREA, 'rows' => 5, 'default' => '' ) ); $this->add_control( 'button', array( 'show_label' => false, 'text' => __('Select files', CPMP_LANG), 'type' => 'cpmmediabutton', 'event' => esc_attr('cpm_get_media("audio", "cpm_audio_player_shortcode");') ) ); $this->end_controls_section(); } // End _register_controls private function _get_shortcode() { $settings = $this->get_settings_for_display(); $shortcode = trim($settings['cpm_audio_player_shortcode']); if(!empty($shortcode)) $shortcode = preg_replace('/[\n\r]/', ' ', $shortcode); else $shortcode = '[cpm-player type="audio" /]'; return $shortcode; } // End _get_shortcode protected function render() { $shortcode = $this->_get_shortcode(); if( isset($_REQUEST['action']) && ( $_REQUEST['action'] == 'elementor' || $_REQUEST['action'] == 'elementor_ajax' ) ) { $url = get_home_url(get_current_blog_id(), '', is_ssl() ? 'https' : 'http'); $url .= ((strpos($url, '?') === false) ? '?' : '&').'cpmp-avp-preview='.urlencode($shortcode); ?>