'title', 'videolink' => 'videolink', 'privacypage' => 'privacypage' ), vc_map_get_attributes('twoclickvideo', $atts) ) ); $video_div = '
'; return do_shortcode($video_div); } add_shortcode('twoclickvideo', 'twocv_vcContent'); add_action('vc_before_init', 'twocv_vcElement', 12); function twocv_vcElement() { if (!function_exists('vc_map')) { // Error message maybe? return; } $policyPageId = (int) get_option('wp_page_for_privacy_policy'); vc_map( array( "name" => __("2-Klick Video"), "base" => "twoclickvideo", "class" => "", "category" => __("Content"), "icon" => plugin_dir_url(__FILE__) . "/img/icon-128x128.png", "params" => array( array( "type" => "textfield", "heading" => __("Titel"), "param_name" => "title", "admin_label" => true, ), array( "type" => "textfield", "heading" => __("Videolink"), "param_name" => "videolink", "admin_label" => true, 'description' => __('z.B. https://www.youtube.com/embed/eBGIQ7ZuuiU') ), array( 'type' => 'dropdown', 'heading' => __('Datenschutzseite'), 'param_name' => 'privacypage', 'admin_label' => true, 'value' => twocv_vcPagesDropdown(), 'save_always' => true, 'std' => $policyPageId, // Your default value 'description' => __('Datenschutzseite auswählen um den Link zu generieren') ) ) ) ); } function twocv_vcPagesDropdown() { $pages = get_posts([ 'post_type' => 'page', 'posts_per_page' => -1, ]); $formattedPages = []; foreach ($pages as $page) { $formattedPages[esc_attr($page->post_title)] = esc_attr($page->ID); } return $formattedPages; }