function fau_get_glossar($id = 0, $cat = '', $color = '')
 {
     if (isset($id) && intval($id) > 0) {
         $title = get_the_title($id);
         $letter = remove_accents(get_the_title($id));
         $letter = mb_substr($letter, 0, 1);
         $letter = mb_strtoupper($letter, 'UTF-8');
         $content = apply_filters('the_content', get_post_field('post_content', $id));
         $content = str_replace(']]>', ']]>', $content);
         if (isset($content) && mb_strlen($content) > 1) {
             $desc = $content;
         } else {
             $desc = get_post_meta($id, 'description', true);
         }
         $result = '<article class="accordionbox fau-glossar" id="letter-' . $letter . '">' . "\n";
         if (isset($color) && strlen(fau_san($color)) > 0) {
             $addclass = fau_san($color);
             $result .= '<header class="' . $addclass . '"><h2>' . $title . '</h2></header>' . "\n";
         } else {
             $result .= '<header><h2>' . $title . '</h2></header>' . "\n";
         }
         $result .= '<div class="body">' . "\n";
         $result .= $desc . "\n";
         $result .= '</div>' . "\n";
         $result .= '</article>' . "\n";
         return $result;
     } else {
         $category = array();
         if ($cat) {
             $category = get_term_by('slug', $cat, 'glossary_category');
         }
         if ($category) {
             $catid = $category->term_id;
             $posts = get_posts(array('post_type' => 'glossary', 'post_status' => 'publish', 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC', 'tax_query' => array(array('taxonomy' => 'glossary_category', 'field' => 'id', 'terms' => $catid)), 'suppress_filters' => false));
         } else {
             $posts = get_posts(array('post_type' => 'glossary', 'post_status' => 'publish', 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC', 'suppress_filters' => false));
         }
         $return = '<div class="fau-glossar">';
         $current = "A";
         $letters = array();
         $accordion = '<div class="accordion">' . "\n";
         $i = 0;
         foreach ($posts as $post) {
             $letter = remove_accents(get_the_title($post->ID));
             $letter = mb_substr($letter, 0, 1);
             $letter = mb_strtoupper($letter, 'UTF-8');
             if ($i == 0 || $letter != $current) {
                 $accordion .= '<h2 id="letter-' . $letter . '">' . $letter . '</h2>' . "\n";
                 $current = $letter;
                 $letters[] = $letter;
             }
             $accordion .= '<div class="accordion-group white">' . "\n";
             $accordion .= '  <div class="accordion-heading">' . "\n";
             $accordion .= '     <a name="' . $post->post_name . '" class="accordion-toggle" data-toggle="collapse" data-parent="accordion-" href="#collapse_' . $post->ID . '000' . $i . '">' . get_the_title($post->ID) . '</a>' . "\n";
             $accordion .= '  </div>' . "\n";
             $accordion .= '  <div id="collapse_' . $post->ID . '000' . $i . '" class="accordion-body">' . "\n";
             $accordion .= '    <div class="accordion-inner">' . "\n";
             $content = apply_filters('the_content', get_post_field('post_content', $post->ID));
             $content = str_replace(']]>', ']]&gt;', $content);
             if (isset($content) && mb_strlen($content) > 1) {
                 $desc = $content;
             } else {
                 $desc = get_post_meta($post->ID, 'description', true);
             }
             $accordion .= $desc;
             $accordion .= '    </div>' . "\n";
             $accordion .= '  </div>' . "\n";
             $accordion .= '</div>' . "\n";
             $i++;
         }
         $accordion .= '</div>' . "\n";
         $return .= '<ul class="letters" aria-hidden="true">' . "\n";
         $alphabet = range('A', 'Z');
         foreach ($alphabet as $a) {
             if (in_array($a, $letters)) {
                 $return .= '<li class="filled"><a href="#letter-' . $a . '">' . $a . '</a></li>';
             } else {
                 $return .= '<li>' . $a . '</li>';
             }
         }
         $return .= '</ul>' . "\n";
         $return .= $accordion;
         $return .= '</div>' . "\n";
         return $return;
     }
 }
    function fau_form_link($name = '', $pretitle = '', $preurl = '', $labeltext = '', $howtotext = '', $types = '')
    {
        $name = fau_san($name);
        $labeltext = fau_san($labeltext);
        if (isset($name) && isset($labeltext)) {
            wp_enqueue_script('wp-link');
            echo '<div class="linkeingabe">';
            $rand = rand();
            echo '<h2 class="label">' . $labeltext . '</h2>';
            if (strlen(trim($howtotext))) {
                echo '<p class="howto">';
                echo $howtotext;
                echo "</p>\n";
            }
            echo '<div class="linkauswahl" id="container_' . $rand . '">';
            echo "<p>\n";
            echo '<label for="title_' . $rand . '_' . $name . '">' . __('Titel', 'fau');
            echo "</label><br />\n";
            echo '<input type="text" class="large-text" name="' . $name . '_title" id="title_' . $rand . '_' . $name . '" value="' . $pretitle . '">';
            echo "</p>\n";
            echo "<p>\n";
            echo '<label for="url_' . $rand . '_' . $name . '">' . __('URL', 'fau');
            echo "</label><br />\n";
            echo '<input type="url" class="large-text" name="' . $name . '_url" id="url_' . $rand . '_' . $name . '" value="' . $preurl . '" placeholder="https://">';
            echo "</p>";
            echo '<p><input class="button link_button_' . $name . '" name="link_button_' . $name . '" id="link_button_' . $name . '" type="button" value="' . __('Wähle Link', 'fau') . '"></p>';
            echo "</div>\n";
            ?>
	  <script>
	   
	      var link_btn_<?php 
            echo $name;
            ?>
 = (function ($) {
		  var link_val_container<?php 
            echo $rand;
            ?>
 = $('#url_<?php 
            echo $rand;
            ?>
_<?php 
            echo $name;
            ?>
');
		  var title_val_container<?php 
            echo $rand;
            ?>
 = $('#title_<?php 
            echo $rand;
            ?>
_<?php 
            echo $name;
            ?>
');

		  function _init() {
		      $('.link_button_<?php 
            echo $name;
            ?>
').on('click', function (event) {
			  activedialog = '<?php 
            echo $name;
            ?>
';
			  wpActiveEditor = true;
			  wpLink.open();
			  wpLink.textarea = $(link_val_container<?php 
            echo $rand;
            ?>
);	  
			  _addLinkListeners();
			  return false;
		      });
		  }

		  function _addLinkListeners() {
		      $('body').on('click', '#wp-link-submit', function (event) {
			  if (activedialog=='<?php 
            echo $name;
            ?>
') {
				var linkAtts = wpLink.getAttrs();
				$(link_val_container<?php 
            echo $rand;
            ?>
).val(linkAtts.href);
				var title = linkAtts.title;
				if (title) {
				    $(title_val_container<?php 
            echo $rand;
            ?>
).val(title);
				}  
				_removeLinkListeners(event);
				activedialog = '';
				return false;
			    } else {
				return false;
			    }
		      });

		      $('body').on('click', '#wp-link-cancel, #wp-link-close', function (event) {
			  _removeLinkListeners(event);
			  return false;
		      });

		  }

		  function _removeLinkListeners(event) {
		      wpLink.textarea = $(link_val_container<?php 
            echo $rand;
            ?>
);
		      wpLink.close();

		      event.preventDefault ? event.preventDefault() : event.returnValue = false;
		      event.stopPropagation();
		  }

		  return {
		      init: _init,
		  };

	      })(jQuery);

	      jQuery(document).ready(function ($) {
		  var activedialog = '';
		  link_btn_<?php 
            echo $name;
            ?>
.init();

	      });
	  </script> 		    	    
	  <?php 
            echo "</div>\n";
        } else {
            echo _('Ungültiger Aufruf von fau_form_link() - Name oder Label fehlt.', 'fau');
        }
    }