$oldlinkname = 'sidebar_quicklinks_external_' . $c . '_sidebar_quicklinks_external_text'; $oldlinkurl = 'sidebar_quicklinks_external_' . $c . '_sidebar_quicklinks_external_link'; $oldurl = get_post_meta($post->ID, $oldlinkurl, true); $oldtitle = get_post_meta($post->ID, $oldlinkname, true); } } else { if (isset($oldpageid) && is_numeric($oldpageid) && $oldpageid > 0) { // Hole zur Sicherheit nochmal aktuelle URL $oldurl = get_permalink($oldpageid); } if (empty(trim($oldtitle))) { $oldtitle = get_the_title($oldpageid); } } if (!empty($oldurl) && !empty($oldtitle)) { $relativeurl = fau_make_link_relative($oldurl); $list2 .= "\t" . '<li class="tag"><a href="' . $relativeurl . '">' . $oldtitle . '</a></li>' . "\n"; } } } $output = ''; if (strlen(trim($list1)) > 0 || strlen(trim($list2)) > 0) { // Es gibt eine Liste $output .= '<aside class="widget quicklinks">' . "\n"; if (strlen(trim($titleblock2)) > 0 || strlen(trim($titleblock1) > 0)) { // Zwei Listen mit zwei Überschriften $output .= $titleblock1; $output .= '<ul class="tagcloud">' . "\n"; $output .= $list1; $output .= '</ul>' . "\n"; $output .= $titleblock2;
function fau_save_metabox_page_sidebar($post_id, $post) { global $options; if (!isset($_POST['fau_metabox_page_sidebar_nonce']) || !wp_verify_nonce($_POST['fau_metabox_page_sidebar_nonce'], basename(__FILE__))) { return $post_id; } /* Check if the current user has permission to edit the post. */ if (!current_user_can('edit_page', $post_id)) { return; } fau_save_standard('sidebar_title_above', $_POST['sidebar_title_above'], $post_id, 'page', 'text'); if ($options['advanced_page_sidebar_useeditor_textabove'] == false) { fau_save_standard('sidebar_text_above', $_POST['sidebar_text_above'], $post_id, 'page', 'textnohtml'); } else { fau_save_standard('sidebar_text_above', $_POST['sidebar_text_above'], $post_id, 'page', 'wpeditor'); } fau_save_standard('sidebar_title_below', $_POST['sidebar_title_below'], $post_id, 'page', 'text'); if ($options['advanced_page_sidebar_useeditor_textbelow'] == false) { fau_save_standard('sidebar_text_below', $_POST['sidebar_text_below'], $post_id, 'page', 'textnohtml'); } else { fau_save_standard('sidebar_text_below', $_POST['sidebar_text_below'], $post_id, 'page', 'wpeditor'); } $newval = intval($_POST['fauval_sidebar_order_personlinks']); $oldval = get_post_meta($post_id, 'fauval_sidebar_order_personlinks', true); if ($newval > 0) { if (isset($oldval) && $oldval != $newval) { update_post_meta($post_id, 'fauval_sidebar_order_personlinks', $newval); } else { add_post_meta($post_id, 'fauval_sidebar_order_personlinks', $newval, true); } } else { delete_post_meta($post_id, 'fauval_sidebar_order_personlinks', $oldval); } $newval = isset($_POST['sidebar_title_personen']) ? sanitize_text_field($_POST['sidebar_title_personen']) : 0; $oldval = get_post_meta($post_id, 'sidebar_title_personen', true); if (!empty(trim($newval))) { if (isset($oldval) && $oldval != $newval) { update_post_meta($post_id, 'sidebar_title_personen', $newval); } else { add_post_meta($post_id, 'sidebar_title_personen', $newval, true); } } elseif ($oldval) { delete_post_meta($post_id, 'sidebar_title_personen', $oldval); } $newval = isset($_POST['sidebar_personen']) ? $_POST['sidebar_personen'] : 0; $oldval = get_post_meta($post_id, 'sidebar_personen', true); $remove = 0; $found = 0; if (isset($newval)) { foreach ($newval as $i) { if ($i == -1) { $remove = 1; } elseif ($i > 0) { $found = 1; } } } if ($remove == 1 || $found == 0) { delete_post_meta($post_id, 'sidebar_personen'); } else { if (isset($oldval)) { update_post_meta($post_id, 'sidebar_personen', $newval); } else { add_post_meta($post_id, 'sidebar_personen', $newval, true); } } $newval = isset($_POST['fauval_sidebar_title_linkblock1']) ? sanitize_text_field($_POST['fauval_sidebar_title_linkblock1']) : 0; $oldval = get_post_meta($post_id, 'fauval_sidebar_title_linkblock1', true); if (!empty(trim($newval))) { if (isset($oldval) && $oldval != $newval) { update_post_meta($post_id, 'fauval_sidebar_title_linkblock1', $newval); } else { add_post_meta($post_id, 'fauval_sidebar_title_linkblock1', $newval, true); } } elseif ($oldval) { delete_post_meta($post_id, 'fauval_sidebar_title_linkblock1', $oldval); } $newval = isset($_POST['fauval_sidebar_title_linkblock2']) ? sanitize_text_field($_POST['fauval_sidebar_title_linkblock2']) : 0; $oldval = get_post_meta($post_id, 'fauval_sidebar_title_linkblock2', true); if (!empty(trim($newval))) { if (isset($oldval) && $oldval != $newval) { update_post_meta($post_id, 'fauval_sidebar_title_linkblock2', $newval); } else { add_post_meta($post_id, 'fauval_sidebar_title_linkblock2', $newval, true); } } elseif ($oldval) { delete_post_meta($post_id, 'fauval_sidebar_title_linkblock2', $oldval); } global $options; for ($i = 1; $i <= $options['advanced_page_sidebar_linkblock1_number']; $i++) { $name = 'fauval_linkblock1_link' . $i; $urlname = $name . '_url'; $titlename = $name . '_title'; $oldpageid = get_post_meta($post_id, $name, true); $oldurl = get_post_meta($post_id, $urlname, true); $oldtitle = get_post_meta($post_id, $titlename, true); $c = $i - 1; $newurl = isset($_POST[$urlname]) ? esc_url($_POST[$urlname]) : 0; $newid = isset($_POST[$name]) ? sanitize_key($_POST[$name]) : 0; $newtitle = isset($_POST[$titlename]) ? sanitize_text_field($_POST[$titlename]) : 0; if (!isset($newid) || $newid <= 0) { // Versuche aus der URL die ID zu ermitteln $relativeurl = fau_make_link_relative($newurl); if ($relativeurl != $newurl) { // Ist eine interne URL, also mnuss es eine ID geben $newid = url_to_postid($newurl); } } update_post_meta($post_id, $urlname, $newurl); update_post_meta($post_id, $titlename, $newtitle); update_post_meta($post_id, $name, $newid); } for ($i = 1; $i <= $options['advanced_page_sidebar_linkblock2_number']; $i++) { $name = 'fauval_linkblock2_link' . $i; $urlname = $name . '_url'; $titlename = $name . '_title'; $oldpageid = get_post_meta($post_id, $name, true); $oldurl = get_post_meta($post_id, $urlname, true); $oldtitle = get_post_meta($post_id, $titlename, true); $c = $i - 1; $newurl = isset($_POST[$urlname]) ? esc_url($_POST[$urlname]) : 0; $newid = isset($_POST[$name]) ? sanitize_key($_POST[$name]) : 0; $newtitle = isset($_POST[$titlename]) ? sanitize_text_field($_POST[$titlename]) : 0; if (!isset($newid) || $newid <= 0) { // Versuche aus der URL die ID zu ermitteln $relativeurl = fau_make_link_relative($newurl); if ($relativeurl != $newurl) { // Ist eine interne URL, also mnuss es eine ID geben $newid = url_to_postid($newurl); } } update_post_meta($post_id, $urlname, $newurl); update_post_meta($post_id, $titlename, $newtitle); update_post_meta($post_id, $name, $newid); } }
function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { global $options; $indent = $depth ? str_repeat("\t", $depth) : ''; $level = $depth + 1; $class_names = $value = ''; $force_cleanmenu = 0; $classes = empty($item->classes) ? array() : (array) $item->classes; if ($level < 2) { $classes[] = 'menu-item-' . $item->ID; $classes[] = 'level' . $level; } $rellink = fau_make_link_relative($item->url); if (substr($rellink, 0, 4) == 'http') { // absoluter Link auf externe Seite $classes[] = 'external'; $force_cleanmenu = 1; } elseif ($rellink == '/') { // Link auf Startseite $classes[] = 'homelink'; $force_cleanmenu = 2; } if ($options['advanced_forceclean_homelink'] && $force_cleanmenu == 1) { // Ignore homelink } elseif ($options['advanced_forceclean_externlink'] && $force_cleanmenu == 1) { // Ignore external link in Main menu } else { $id = apply_filters('nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args); $id = $id ? ' id="' . esc_attr($id) . '"' : ''; $class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item, $args)); $class_names = $class_names ? ' class="' . esc_attr($class_names) . '"' : ''; if ($level > 1) { $class_names = str_replace("has-sub", "", $class_names); } $output .= $indent . '<li' . $id . $value . $class_names . '>'; $atts = array(); $atts['title'] = !empty($item->attr_title) ? $item->attr_title : ''; $atts['target'] = !empty($item->target) ? $item->target : ''; $atts['rel'] = !empty($item->xfn) ? $item->xfn : ''; $atts['href'] = !empty($item->url) ? $item->url : ''; $atts = apply_filters('nav_menu_link_attributes', $atts, $item, $args); if ($level == 1) { $this->currentID = $item->object_id; } $attributes = ''; foreach ($atts as $attr => $value) { if (!empty($value)) { $value = 'href' === $attr ? esc_url($value) : esc_attr($value); $attributes .= ' ' . $attr . '="' . $value . '"'; } } $item_output = $args->before; $item_output .= '<a' . $attributes . '>'; $item_output .= $args->link_before . apply_filters('the_title', $item->title, $item->ID) . $args->link_after; $item_output .= '</a>'; $item_output .= $args->after; $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args); } }
function fau_display_search_resultitem($withsidebar = 1) { global $post; global $options; $output = ''; $withthumb = $options['search_display_post_thumbnails']; $withcats = $options['search_display_post_cats']; $withtypenote = $options['search_display_typenote']; $attachment = array(); if (isset($post) && isset($post->ID)) { $link = get_post_meta($post->ID, 'external_link', true); $external = 0; if (isset($link) && filter_var($link, FILTER_VALIDATE_URL)) { $external = 1; } else { $link = fau_make_link_relative(get_permalink($post->ID)); } $type = get_post_type(); $typeclass = "res-" . $type; $output .= '<article class="search-result ' . $typeclass . '">' . "\n"; $output .= "\t<h3><a "; if ($external == 1) { $output .= 'class="ext-link" '; } $output .= "href=\"" . $link . "\">" . get_the_title() . "</a></h3>\n"; $typeinfo = get_post_type_object($type); if ($type == 'post') { $typestr = '<div class="search-meta">'; if ($withtypenote == true) { $typestr .= '<span class="post-meta-news"> '; $typestr .= __('Beitrag', 'fau'); $typestr .= '</span>'; } $categories = get_the_category(); $separator = ', '; $thiscatstr = ''; if ($withcats == true && $categories) { $typestr .= '<span class="post-meta-category"> '; $typestr .= __('Kategorie', 'fau'); $typestr .= ': '; foreach ($categories as $category) { $thiscatstr .= '<a href="' . get_category_link($category->term_id) . '">' . $category->cat_name . '</a>' . $separator; } $typestr .= trim($thiscatstr, $separator); $typestr .= '</span> '; } $topevent_date = get_post_meta($post->ID, 'topevent_date', true); if ($topevent_date) { $typestr .= '<span class="post-meta-date"> '; $typestr .= date_i18n(get_option('date_format'), strtotime($topevent_date)); $typestr .= ' ('; $typestr .= __('Veranstaltungshinweis', 'fau'); $typestr .= ')'; $typestr .= '</span>'; } else { $typestr .= '<span class="post-meta-date"> '; $typestr .= get_the_date(); $typestr .= '</span>'; } $typestr .= '</div>' . "\n"; } elseif ($type == 'person') { $typestr = '<div class="search-meta">'; $typestr .= '<span class="post-meta-kontakt"> '; $typestr .= $typeinfo->labels->singular_name; $typestr .= '</span>'; $typestr .= '</div>' . "\n"; } elseif ($type == 'event') { $typestr = '<div class="search-meta">'; $typestr .= '<span class="post-meta-event"> '; $typestr .= __('Veranstaltungshinweis', 'fau'); $typestr .= '</span>'; $typestr .= '</div>' . "\n"; } elseif ($type == 'attachment') { $attachment = wp_prepare_attachment_for_js($post->ID); $filesize = isset($attachment['filesizeHumanReadable']) ? $attachment['filesizeHumanReadable'] : ''; $filesize = isset($attachment['filesize']) && !isset($filesize) ? $attachment['filesize'] : $filesize; $filesize = isset($attachment['filesizeInBytes']) && !isset($filesize) ? $attachment['filesizeInBytes'] . " Bytes" : $filesize; $filetype = wp_check_filetype($attachment['url']); $typestr = '<div class="search-meta">'; $typestr .= '<span class="post-meta-attachment">'; $typestr .= ' <span class="dateityp">' . $filetype['ext'] . '</span> '; $typestr .= __('Datei', 'fau'); $typestr .= '</span>'; $typestr .= ' <span class="post-meta-date"> '; $typestr .= get_the_date(); if (get_the_date() != get_the_modified_date()) { $typestr .= ' (' . __('Erstellungsdatum', 'fau') . ')'; $typestr .= '</span>'; $typestr .= ' <span class="post-meta-date"> '; $typestr .= get_the_modified_date(); $typestr .= ' (' . __('Letzte Änderung', 'fau') . ')'; } $typestr .= '</span>'; $typestr .= ' <span class="download">'; $typestr .= ' <a href="' . fau_esc_url($attachment['url']) . '">' . __('Download', 'fau') . '</a>'; $typestr .= ' <span class="filesize">(<span class="unsichtbar">'; $typestr .= __('Größe:', 'fau') . ' </span>' . $filesize; $typestr .= ')</span>'; $typestr .= '</span>'; $typestr .= '</div>' . "\n"; } elseif ($withtypenote == true) { $typestr = '<div class="search-meta">'; $typestr .= '<span class="post-meta-defaulttype"> '; $typestr .= $typeinfo->labels->singular_name; $typestr .= '</span>'; $typestr .= ' <span class="post-meta-date"> '; $typestr .= get_the_modified_date(); $typestr .= ' (' . __('Letzte Änderung', 'fau') . ')'; $typestr .= '</span>'; $typestr .= '</div>' . "\n"; } else { $typestr = ''; } if (!empty($typestr)) { $output .= "\t" . $typestr . "\n"; } $output .= "\t"; if ($type == 'person' && class_exists('FAU_Person_Shortcodes')) { if ($withthumb == true && has_post_thumbnail($post->ID)) { $output .= '<div class="row">' . "\n"; $output .= "\t\t" . '<div class="span3">' . "\n"; $output .= '<a href="' . $link . '" class="news-image"'; if ($external == 1) { $output .= ' ext-link'; } $output .= '">'; $post_thumbnail_id = get_post_thumbnail_id($post->ID, 'post-thumb'); $imagehtml = ''; $imgsrcset = ''; if ($post_thumbnail_id) { $sliderimage = wp_get_attachment_image_src($post_thumbnail_id, 'post-thumb'); $imgsrcset = wp_get_attachment_image_srcset($post_thumbnail_id, 'post-thumb'); $imageurl = $sliderimage[0]; } if (!isset($imageurl) || strlen(trim($imageurl)) < 4) { $imageurl = $options['default_postthumb_src']; } $output .= '<img src="' . fau_esc_url($imageurl) . '" width="' . $options['default_postthumb_width'] . '" height="' . $options['default_postthumb_height'] . '" alt=""'; if ($imgsrcset) { $output .= ' srcset="' . $imgsrcset . '"'; } $output .= '>'; $output .= '</a>'; $output .= "\t\t" . '</div>' . "\n"; if ($withsidebar) { $output .= "\t\t" . '<div class="span6">' . "\n"; } else { $output .= "\t\t" . '<div class="span9">' . "\n"; } } $output .= FAU_Person_Shortcodes::fau_person(array("id" => $post->ID, 'format' => 'kompakt', 'showlink' => 0, 'showlist' => 0, 'hide' => 'bild')); if ($withthumb == true && has_post_thumbnail($post->ID)) { $output .= "\t</div> <!-- /row -->\n"; } /* }elseif (($type == 'standort') && (function_exists('fau_standort'))) { $output .= fau_standort(array("id"=> $post->ID)); */ } elseif ($type == 'attachment') { if ($withthumb == true) { $output .= '<div class="row">' . "\n"; $output .= "\t\t" . '<div class="span1 span-small">' . "\n"; $output .= '<img src="' . fau_esc_url($attachment['icon']) . '" width="48" height="64" alt="">'; $output .= "\t\t" . '</div>' . "\n"; if ($withsidebar) { $output .= "\t\t" . '<div class="span7">' . "\n"; } else { $output .= "\t\t" . '<div class="span11">' . "\n"; } } $output .= "\t\t" . '<p><em>' . "\n"; $output .= "\t\t\t" . $attachment['caption']; $output .= "\t\t" . '</em></p>' . "\n"; $output .= "\t\t" . '<p>' . "\n"; $output .= "\t\t\t" . $attachment['description']; $output .= "\t\t" . '</p>' . "\n"; if ($withthumb == true) { $output .= "\t</div> <!-- /row -->\n"; } } else { if ($withthumb == true && has_post_thumbnail($post->ID)) { $output .= '<div class="row">' . "\n"; $output .= "\t\t" . '<div class="span3">' . "\n"; $output .= '<a href="' . $link . '" class="news-image"'; if ($external == 1) { $output .= ' ext-link'; } $output .= '">'; $post_thumbnail_id = get_post_thumbnail_id($post->ID, 'post-thumb'); $imagehtml = ''; $imgsrcset = ''; if ($post_thumbnail_id) { $sliderimage = wp_get_attachment_image_src($post_thumbnail_id, 'post-thumb'); $imgsrcset = wp_get_attachment_image_srcset($post_thumbnail_id, 'post-thumb'); $imageurl = $sliderimage[0]; } if (!isset($imageurl) || strlen(trim($imageurl)) < 4) { $imageurl = $options['default_postthumb_src']; } $output .= '<img src="' . fau_esc_url($imageurl) . '" width="' . $options['default_postthumb_width'] . '" height="' . $options['default_postthumb_height'] . '" alt=""'; if ($imgsrcset) { $output .= ' srcset="' . $imgsrcset . '"'; } $output .= '>'; $output .= '</a>'; $output .= "\t\t" . '</div>' . "\n"; if ($withsidebar) { $output .= "\t\t" . '<div class="span6">' . "\n"; } else { $output .= "\t\t" . '<div class="span9">' . "\n"; } } $output .= "\t\t" . '<p>' . "\n"; $output .= fau_custom_excerpt($post->ID, $options['default_search_excerpt_length'], false, '', true, $options['search_display_excerpt_morestring']); if ($options['search_display_continue_arrow']) { $output .= fau_create_readmore($link, '', $external, true); } $output .= "\t\t\t" . '</p>' . "\n"; if ($withthumb == true && has_post_thumbnail($post->ID)) { $output .= "\t</div> <!-- /row -->\n"; } } $output .= "</article>\n"; } else { $output .= "<!-- empty result -->\n"; } return $output; }