Skip to content

Commit

Permalink
Merge pull request #77 from RRZE-Webteam/dev
Browse files Browse the repository at this point in the history
Bugfix Release
  • Loading branch information
xwolfde authored May 31, 2023
2 parents 2d4f6a8 + b040789 commit 6074890
Show file tree
Hide file tree
Showing 22 changed files with 596 additions and 666 deletions.
2 changes: 1 addition & 1 deletion css/fau-theme-admin.css

Large diffs are not rendered by default.

23 changes: 10 additions & 13 deletions footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,16 @@
?>
</nav>
<?php
$display_socialmedia_footer = get_theme_mod("advanced_footer_display_socialmedia");
if ($display_socialmedia_footer) {
global $default_socialmedia_liste;
global $defaultoptions;

echo '<nav class="svg-socialmedia round hoverbg" aria-label="'.__('Social Media','fau').'">';
echo '<div itemscope itemtype="http://schema.org/Organization">';
echo fau_create_schema_publisher(false);
echo fau_get_socialmedia_menu($defaultoptions['socialmedia_menu_name'],'',true);
echo '</div>';
echo '</nav>';

} ?>
global $default_socialmedia_liste;
global $defaultoptions;

echo '<nav class="svg-socialmedia round hoverbg" aria-label="'.__('Social Media','fau').'">';
echo '<div itemscope itemtype="http://schema.org/Organization">';
echo fau_create_schema_publisher(false);
echo fau_get_socialmedia_menu($defaultoptions['socialmedia_menu_name'],'',true);
echo '</div>';
echo '</nav>';
?>
</div>
</div>
</div>
Expand Down
57 changes: 0 additions & 57 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,60 +396,3 @@ function fau_embedded_posts( $query ) {
require_once( get_template_directory() . '/functions/gutenberg.php');






// Move the following block to functions/custom-fields.php please...

/*-----------------------------------------------------------------------------------*/
/*Hide and show feutured image
/*-----------------------------------------------------------------------------------*/
function hide_featured_image_meta_box() {
add_meta_box( 'hide_featured_image', 'Featured Image', 'hide_featured_image_callback', 'post', 'side', 'low' );
}
add_action( 'add_meta_boxes', 'hide_featured_image_meta_box' );
function hide_featured_image_callback( $post ) {
$value = get_post_meta( $post->ID, '_hide_featured_image', true );
echo '<label for="hide-featured-image"><input type="checkbox" id="hide-featured-image" name="hide_featured_image" value="1"' . checked( $value, 1, false ) . '> Hide featured image from this post</label>';
}


function hide_featured_image_save_post( $post_id ) {
if ( isset( $_POST['hide_featured_image'] ) ) {
update_post_meta( $post_id, '_hide_featured_image', 1 );
} else {
delete_post_meta( $post_id, '_hide_featured_image' );
}

// Add the following code to set a cookie with the checkbox value
// setcookie( 'hide_featured_image', isset( $_POST['hide_featured_image'] ), time() + 86400, COOKIEPATH, COOKIE_DOMAIN );

// Rework this please. See: https://github.com/RRZE-Webteam/FAU-Einrichtungen/issues/1288
}
add_action( 'save_post', 'hide_featured_image_save_post' );


/*-----------------------------------------------------------------------------------*/
/* Outside-box image post block
*
* Note: Please move Block Editor stuff to functions/gutenberg.php
*/
/*-----------------------------------------------------------------------------------*/
function fau_custom_image_blocks() {
wp_register_script(
'my-custom-blocks',
get_template_directory_uri() . '/js/fau-costum-image-block.min.js',
array( 'wp-blocks', 'wp-editor' ),
true
);
register_block_type( 'my-blocks/full-width-image', array(
'editor_script' => 'my-custom-blocks',
) );
}
add_action( 'init', 'fau_custom_image_blocks' );


/*-----------------------------------------------------------------------------------*/
/* This is the end of the code as we know it
/*-----------------------------------------------------------------------------------*/
44 changes: 0 additions & 44 deletions functions/constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,6 @@
'default_logo_height' => 152,
'default_logo_width' => 400,

'socialmedia' => 0,
'active_socialmedia_footer' => array(0),
'socialmedia_buttons_title' => __('Social Media', 'fau'),

'socialmedia_menu_name' => __('Social Media Menu', 'fau'),
'socialmedia_menu_position' => 'FAU_SocialMedia_Menu_Footer',
'socialmedia_menu_position_title' => __('Social Media Bereich im Footer', 'fau'),
Expand Down Expand Up @@ -203,7 +199,6 @@
'title_hero_search' => __('Webauftritt durchsuchen', 'fau'),

'advanced_footer_display_address' => true,
'advanced_footer_display_socialmedia' => false,
'advanced_beitragsoptionen' => true,
'advanced_topevent' => true,
'default_display_thumbnail_3_2' => true,
Expand Down Expand Up @@ -752,45 +747,6 @@ function fau_get_searchable_fields($format = 'array')
'desc' => __('Einstellungen für den Fußteil des Webauftritts.', 'fau'),
),

'advanced_footer_display_socialmedia' => array(
'type' => 'toggle',
'title' => __('Social Media', 'fau'),
'label' => __('Zeigt die Social Media Icons im Footerbereich unterhalb des technischen Menüs an', 'fau'),
'default' => $defaultoptions['advanced_footer_display_socialmedia'],
'parent' => 'footer'
),
'active_socialmedia_footer' => array(
'type' => 'multiselectlist',
'title' => __('Widget aktivieren', 'fau'),
'label' => __('Auf welchen Seiten soll das Widget angezeigt werden.', 'fau'),
'liste' => array(
1 => __('Startseite', 'fau'),
2 => __('Portalseiten', 'fau'),
3 => __('Suche und Fehlerseiten', 'fau'),
4 => __('Inhaltsseite mit Navi', 'fau'),
5 => __('Standard Seiten', 'fau'),
6 => __('Beiträge', 'fau'),
-1 => __('Auf allen Seiten', 'fau'),
),
'default' => $defaultoptions['active_socialmedia_footer'],
'parent' => 'footer',
),
'socialmedia' => array(
'type' => 'toggle',
'title' => __('Social Media Buttons in der ersten Widgetspalte anzeigen', 'fau'),
'label' => __('Schaltet die Social Media Buttons in der Widgetspalte an oder aus. Bitte beachten Sie, daß die anzuzeigenden Icons selbst als Menü verwaltet werden. Rufen Sie hierzu die Menüeinstellungen auf und bearbeiten dort das Social Media Menü.', 'fau'),
'parent' => 'footer',
'default' => $defaultoptions['socialmedia'],
),

'socialmedia_buttons_title' => array(
'type' => 'text',
'title' => __('Titel', 'fau'),
'label' => __('Titel über den Social Media Icons in der ersten Spalte.', 'fau'),
'default' => $defaultoptions['socialmedia_buttons_title'],
'parent' => 'footer',
),

'advanced_footer_display_address' => array(
'type' => 'toggle',
'title' => __('Adresse', 'fau'),
Expand Down
37 changes: 36 additions & 1 deletion functions/custom-fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ function fau_metabox_cf_setup() {
add_action('add_meta_boxes_page', 'fau_add_metabox_page');
add_action('add_meta_boxes_post', 'fau_add_metabox_post');


/* Save sidecontent */
add_action('save_post', 'fau_save_metabox_page_untertitel', 10, 2);

Expand Down Expand Up @@ -133,7 +132,19 @@ function fau_add_metabox_post() {
'fau_do_metabox_post_vidpod',
'post', 'side', 'low'
);

// Hide Featured Image meta box
add_meta_box(
'fau_metabox_post_teaser',
esc_html__('Beitragsoptionen', 'fau'),
'fau_do_metabox_post_teaser',
'post', 'normal', 'high'
);
}




/*-----------------------------------------------------------------------------------*/
/* Display Options for posts
/*-----------------------------------------------------------------------------------*/
Expand Down Expand Up @@ -180,6 +191,9 @@ function fau_do_metabox_post_teaser($object, $box) {
$sliderimage = get_post_meta($object->ID, 'fauval_slider_image', true);
fau_form_image('fauval_slider_image', $sliderimage, __('Bühnenbild', 'fau'), __('An dieser Stelle kann optional ein alternatives Bild für die Bühne der Startseite ausgewählt werden, falls das normale Beitragsbild hierzu nicht verwendet werden soll.', 'fau'), 540, 150);
}
$value = get_post_meta($object->ID, '_hide_featured_image', true);

echo '<label for="hide-featured-image"><input type="checkbox" id="hide-featured-image" name="hide_featured_image" value="1"' . checked($value, 1, false) . '> Hide featured image from this post</label>';
}
/*-----------------------------------------------------------------------------------*/
/* Save the meta box's post metadata.
Expand Down Expand Up @@ -239,7 +253,14 @@ function fau_save_post_teaser($post_id, $post) {
} else {
delete_post_meta($post_id, 'fauval_slider_image');
}
if (isset($_POST['hide_featured_image'])) {
update_post_meta($post_id, '_hide_featured_image', 1);
} else {
delete_post_meta($post_id, '_hide_featured_image');
}
}



/* Display Options for pages */
function fau_do_metabox_post_topevent($object, $box) {
Expand Down Expand Up @@ -525,6 +546,9 @@ function fau_do_metabox_page_portalmenu($object, $box) {

fau_form_select('fau_metabox_page_portalmenu_id', $thislist, $currentmenuid, __('Portalmenü', 'fau').' '.__('unten', 'fau'), __('Bei einer Portalseite wird unter dem Inhalt ein Menu ausgegeben. Bitte wählen Sie hier das Menü aus der Liste. Sollte das Menü noch nicht existieren, kann ein Administrator es anlegen.', 'fau'), 1, __('Kein Portalmenu zeigen', 'fau'));

$meganav = get_post_meta($object->ID, 'fauval_portalmenu_meganav', true) ? 1 : 0;
fau_form_onoff('fau_metabox_page_portalmenu_meganav', $meganav, __('Mega-Navigation', 'fau'));

$nothumbnails = get_post_meta($object->ID, 'fauval_portalmenu_thumbnailson', true) ? 1 : 0;
fau_form_onoff('fau_metabox_page_portalmenu_nothumbnails', $nothumbnails, __('Beitragsbilder', 'fau').' '.__('verbergen', 'fau'));

Expand Down Expand Up @@ -572,6 +596,17 @@ function fau_save_metabox_page_portalmenu($post_id, $post) {
delete_post_meta($post_id, 'portalmenu-slug');
}

$newval = !empty($_POST['fau_metabox_page_portalmenu_meganav']) ? 1 : 0;
$oldval = get_post_meta($post_id, 'fauval_portalmenu_meganav', true) ? 1 : 0;

if ($newval && !empty($oldval)) {
update_post_meta($post_id, 'fauval_portalmenu_meganav', $newval);
} elseif ($newval && empty($oldval)) {
add_post_meta($post_id, 'fauval_portalmenu_meganav', $newval, true);
} else {
delete_post_meta($post_id, 'fauval_portalmenu_meganav');
}

$newval = !empty($_POST['fau_metabox_page_portalmenu_nothumbnails']) ? 1 : 0;
$oldval = get_post_meta($post_id, 'fauval_portalmenu_thumbnailson', true) ? 1 : 0;

Expand Down
14 changes: 14 additions & 0 deletions functions/filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,3 +393,17 @@ function fau_remove_image_size_options($sizes) {
return $sizes;
}
add_filter('image_size_names_choose', 'fau_remove_image_size_options');


/*-----------------------------------------------------------------------------------*/
/* Remove the target in all links in content
/*-----------------------------------------------------------------------------------*/

function fau_change_link_targets($content) {
$pattern = '/<a(.*?)href=[\'"](.*?)[\'"](.*?)(target=[\'"](.*?)[\'"])?(.*?)>/i';
$replacement = '<a$1href="$2"$3$6>';
$content = preg_replace($pattern, $replacement, $content);
return $content;
}
add_filter('the_content', 'fau_change_link_targets');

25 changes: 25 additions & 0 deletions functions/gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,31 @@ function fau_is_newsletter_plugin_active() {
return false;
}



/*-----------------------------------------------------------------------------------*/
/* Outside-box image post block
/*-----------------------------------------------------------------------------------*/
function fau_custom_image_blocks() {
wp_register_script(
'my-custom-blocks',
get_template_directory_uri() . '/js/fau-costum-image-block.min.js',
array( 'wp-blocks', 'wp-editor' ),
true
);
register_block_type( 'my-blocks/full-width-image', array(
'editor_script' => 'my-custom-blocks',
) );
}
add_action( 'init', 'fau_custom_image_blocks' );


/*-----------------------------------------------------------------------------------*/
/* This is the end of the code as we know it
/*-----------------------------------------------------------------------------------*/



/*-----------------------------------------------------------------------------------*/
/* Defined allowed core block types if theme is used in Gutenberg Block Editor
/*-----------------------------------------------------------------------------------*/
Expand Down
10 changes: 6 additions & 4 deletions functions/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,19 +436,21 @@ class Walker_Content_Menu extends Walker_Nav_Menu {
private $element;
private $showsub = true;
private $listview = false;
private $meganav = false;

function __construct( $menu, $showsub = true, $maxsecondlevel = 0, $noshowthumb = false,$nothumbnailfallback = false, $thumbnail = 'rwd-480-2-1', $listview = false ) {
function __construct( $menu, $showsub = true, $maxsecondlevel = 0, $noshowthumb = false,$nothumbnailfallback = false, $thumbnail = 'rwd-480-2-1', $listview = false, $meganav = false ) {
$this->showsub = $showsub && !$listview;

if ($maxsecondlevel==0) {
$maxsecondlevel = get_theme_mod('default_submenu_entries');
}

$this->maxsecondlevel = $maxsecondlevel;
$this->nothumbnail = $noshowthumb || $listview;
$this->nothumbnail = $noshowthumb || $listview || $meganav;
$this->nothumbnailfallback = $nothumbnailfallback;
$this->thumbnail = $thumbnail;
$this->listview = $listview;
$this->meganav = $meganav;
}

function __destruct() {
Expand Down Expand Up @@ -612,11 +614,11 @@ function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) {
}

}
$item_output .= $this->listview ? '' : $args->link_before.'<span class="portaltop">';
$item_output .= $this->listview || $this->meganav ? '' : $args->link_before.'<span class="portaltop">';
$item_output .= $link;
$item_output .= apply_filters('the_title', $item->title, $item->ID);
$item_output .= '</a>';
$item_output .= $this->listview ? '' : '</span>'.$args->link_after;
$item_output .= $this->listview || $this->meganav ? '' : '</span>'.$args->link_after;
} else {
$item_output .= $link;
$item_output .= $args->link_before.apply_filters('the_title', $item->title,
Expand Down
2 changes: 1 addition & 1 deletion functions/sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function fau_sanitize_html_field($dateinput)
'ul' => array(),
'li' => array(),
'dl' => array(), 'dd' => array(), 'dt' => array(),
'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(),
'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(),
'table' => array(), 'tr' => array(), 'td' => array(), 'tbody' => array(), 'thead' => array(), 'tfooter' => array(),
);

Expand Down
13 changes: 9 additions & 4 deletions functions/shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ function add_shortcodes()
/*-----------------------------------------------------------------------------------*/
/* Portalmenus als Shortcode
/*-----------------------------------------------------------------------------------*/
function fau_portalmenu($atts, $content = null)
{
function fau_portalmenu($atts, $content = null) {
global $defaultoptions;
extract(shortcode_atts(
array(
'menu' => '',
'meganav' => false,
'showsubs' => true,
'nothumbs' => false,
'nofallback' => false,
Expand All @@ -59,10 +60,11 @@ function fau_portalmenu($atts, $content = null)
$global_hoverblur = get_theme_mod('portalmenus_hover_blur', $defaultoptions['portalmenus_hover_blur']);
$global_hoverblur = filter_var($global_hoverblur, FILTER_VALIDATE_BOOLEAN);

$meganav = filter_var($meganav, FILTER_VALIDATE_BOOLEAN);
$listview = filter_var($listview, FILTER_VALIDATE_BOOLEAN);
$showsubs = filter_var($showsubs, FILTER_VALIDATE_BOOLEAN);
$nothumbs = filter_var($nothumbs, FILTER_VALIDATE_BOOLEAN);
$nofallback = filter_var($nofallback, FILTER_VALIDATE_BOOLEAN);
$listview = filter_var($listview, FILTER_VALIDATE_BOOLEAN);
$hoverzoom = filter_var($hoverzoom, FILTER_VALIDATE_BOOLEAN);
$hoverblur = filter_var($hoverblur, FILTER_VALIDATE_BOOLEAN);

Expand Down Expand Up @@ -106,6 +108,9 @@ function fau_portalmenu($atts, $content = null)
break;
}

if ($meganav === true) {
$a_contentmenuclasses[] = 'meganav';
}
if ($showsubs === false) {
$a_contentmenuclasses[] = 'no-sub';
}
Expand Down Expand Up @@ -135,7 +140,7 @@ function fau_portalmenu($atts, $content = null)
'link_after' => '',
'item_spacing' => 'discard',

'walker' => new Walker_Content_Menu($slug, $showsubs, $subentries, $nothumbs, $nofallback, $thumbnail, $listview)
'walker' => new Walker_Content_Menu($slug, $showsubs, $subentries, $nothumbs, $nofallback, $thumbnail, $listview, $meganav)
)
);
if ($listview === true) {
Expand Down
7 changes: 5 additions & 2 deletions functions/template-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -632,11 +632,14 @@ function fau_display_news_teaser($id = 0, $withdate = false, $hstart = 2, $hidem
// get value for zig zag display format
$default_zig_zag_blogroll = get_theme_mod('default_zig_zag_blogroll');
$zigzag_class = $default_zig_zag_blogroll ? 'zigzag ' : '';

$articleclass = "news-item";
// add random key, due to the possible use of blogrolls of the news. The same article can be displayed
// more times on the same page. This would result in an wcag/html error, cause the uniq id would be used more as one time
$output .= '<article '; // class="news-item" ';
$output .= 'class="news-item ' . $zigzag_class . esc_attr(implode(' ', get_post_class('', $post->ID))) . '"';
if (is_sticky($post->ID)) {
$articleclass .= ' sticky';
}
$output .= 'class="'.$articleclass.' '.$zigzag_class . esc_attr(implode(' ', get_post_class('', $post->ID))) . '"';
$output .= ' aria-labelledby="' . $arialabelid . '" itemscope itemtype="http://schema.org/NewsArticle">';
$link = get_post_meta($post->ID, 'external_link', true);
$link = esc_url(trim($link));
Expand Down
2 changes: 1 addition & 1 deletion js/fau-theme.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 6074890

Please sign in to comment.