Skip to content

Commit

Permalink
Merge pull request #1107 from RRZE-Webteam/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
xwolfde authored Apr 8, 2022
2 parents 6db9700 + f552620 commit c7dbeb1
Show file tree
Hide file tree
Showing 29 changed files with 316 additions and 253 deletions.
2 changes: 1 addition & 1 deletion css/fau-theme-admin.css

Large diffs are not rendered by default.

84 changes: 37 additions & 47 deletions footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,55 +9,45 @@
* @subpackage FAU
* @since FAU 1.0
*/

$website_type = get_theme_mod('website_type');
if (($website_type ==3 ) && ( is_active_sidebar( 'footer-block1' ) )) {
$logoclass = "other";
} else {
$logoclass = "fau";
}
$display_address = get_theme_mod("advanced_footer_display_address");
$contact_address_name = get_theme_mod("contact_address_name");
$contact_address_name2 = get_theme_mod("contact_address_name2");
$contact_address_street = get_theme_mod("contact_address_street");
$contact_address_plz = get_theme_mod("contact_address_plz");
$contact_address_ort = get_theme_mod("contact_address_ort");
$contact_address_country = get_theme_mod("contact_address_country");
$schemaname = $contact_address_name." ".$contact_address_name2;
?>


<footer id="footer">
<div class="container">
<div class="footer-row">
<?php
$website_type = get_theme_mod('website_type');
if (($website_type ==3 ) && ( is_active_sidebar( 'footer-block1' ) )) {
$logoclass = "other";
} else {
$logoclass = "fau";
}
?>
<div class="footer-logo <?php echo $logoclass; ?>">
<?php if (($website_type ==3 ) && ( is_active_sidebar( 'footer-block1' ) )) {
dynamic_sidebar( 'footer-block1' );
} else {
fau_use_svg("fau-logo-2021",144,55,'fau-logo-footer');
} ?>
</div>
<div class="footer-address">
<?php
if (($website_type ==3 ) && ( is_active_sidebar( 'footer-block2' ) )) {
dynamic_sidebar( 'footer-block2' );
} else {
$display_address = get_theme_mod("advanced_footer_display_address");
if ($display_address) { ?>
<address itemscope itemtype="http://schema.org/PostalAddress">
<?php
$contact_address_name = get_theme_mod("contact_address_name");
$contact_address_name2 = get_theme_mod("contact_address_name2");
$contact_address_street = get_theme_mod("contact_address_street");
$contact_address_plz = get_theme_mod("contact_address_plz");
$contact_address_ort = get_theme_mod("contact_address_ort");
$contact_address_country = get_theme_mod("contact_address_country");
$schemaname = $contact_address_name." ".$contact_address_name2; ?>
<meta itemprop="name" content="<?php echo esc_html($schemaname);?>">
<span><?php echo $contact_address_name;
if (!fau_empty($contact_address_name2)) { echo "<br>".$contact_address_name2; } ?></span><br>
<span itemprop="streetAddress"><?php echo $contact_address_street; ?></span><br>
<span itemprop="postalCode"><?php echo $contact_address_plz; ?></span> <span itemprop="addressLocality"><?php echo $contact_address_ort; ?></span><br>
<?php if (isset($contact_address_country)) { ?>
<span itemprop="addressCountry"><?php echo $contact_address_country; ?></span>
<?php } ?>
</address>
<?php }
} ?>
</div>
<div class="container">
<div class="footer-row">
<div class="footer-logo <?php echo $logoclass; ?>">
<?php if (($website_type == 3 ) && ( is_active_sidebar( 'footer-block1' ) )) {
dynamic_sidebar( 'footer-block1' );
} else {
fau_use_svg("fau-logo-2021",144,55,'fau-logo-footer');
} ?>
</div>
<div class="footer-address">
<?php if (($website_type ==3 ) && ( is_active_sidebar( 'footer-block2' ) )) {
dynamic_sidebar( 'footer-block2' );
} elseif ($display_address) { ?> <address itemscope itemtype="http://schema.org/PostalAddress">
<meta itemprop="name" content="<?php echo esc_html($schemaname);?>">
<span><?php echo $contact_address_name; if (!fau_empty($contact_address_name2)) { echo "<br>".$contact_address_name2; } ?></span><br>
<span itemprop="streetAddress"><?php echo $contact_address_street; ?></span><br>
<span itemprop="postalCode"><?php echo $contact_address_plz; ?></span> <span itemprop="addressLocality"><?php echo $contact_address_ort; ?></span><br>
<?php if (isset($contact_address_country)) { ?><span itemprop="addressCountry"><?php echo $contact_address_country; ?></span><?php } ?>
</address>
<?php } ?> </div>
<div class="footer-meta">
<nav aria-label="<?php echo __('Kontakt, Impressum und Zusatzinformationen','fau'); ?>">
<?php
Expand Down Expand Up @@ -90,6 +80,6 @@
<span class="screen-reader-text"><?php echo __('Nach oben','fau'); ?></span></a>
</footer>
</div>
<?php wp_footer(); ?>
</body>
<?php print_indented("wp_footer",2); ?>
</body>
</html>
109 changes: 53 additions & 56 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
require_once( get_template_directory() . '/functions/widgets.php' );
require_once( get_template_directory() . '/functions/gallery.php' );

// require_once( get_template_directory() . '/functions/gutenberg.php');
require_once( get_template_directory() . '/functions/gutenberg.php');
// deaktiviert wegen Newsletter-Plugin
// brauchen noch ein andere Lösung

Expand All @@ -49,7 +49,6 @@ function fau_setup() {
if ( ! isset( $content_width ) ) $content_width = $defaultoptions['content-width'];


add_editor_style( array( 'css/fau-theme-editor-style.css' ) );
add_theme_support('html5');
add_theme_support('caption');
add_theme_support('title-tag');
Expand Down Expand Up @@ -116,12 +115,17 @@ function fau_custom_init() {
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );


// Remove Gutenbergs Userstyle and SVGs Duotone injections from 5.9.2
remove_action( 'wp_enqueue_scripts', 'wp_enqueue_global_styles' );
remove_action( 'wp_body_open', 'wp_global_styles_render_svg_filters' );

remove_filter( 'the_content', 'wpautop' );

// Declare Default Symbols from the start
fau_register_svg_symbol("fau-logo-text", false);
// fau_register_svg_symbol("fau-logo-text", false);
// fau_register_svg_symbol("fau-siegel", false);
fau_register_svg_symbol("fau-logo", false);
//fau_register_svg_symbol("fau-logo", false);


}
Expand Down Expand Up @@ -189,15 +193,37 @@ function fau_admin_header_style() {
add_action( 'admin_enqueue_scripts', 'fau_admin_header_style' );



/*-----------------------------------------------------------------------------------*/
/* Remove type-String from link-reference to follow W3C Validator
/* Change default DNS prefetch
/*-----------------------------------------------------------------------------------*/
function fau_remove_type_attr($tag, $handle) {
return preg_replace( "/type=['\"]text\/(javascript|css)['\"]/", '', $tag );
function fau_remove_default_dns_prefetch( $hints, $relation_type ) {
if ( 'dns-prefetch' === $relation_type ) {
return array_diff( wp_dependencies_unique_hosts(), $hints );
}

return $hints;
}
add_filter('style_loader_tag', 'fau_remove_type_attr', 10, 2);
add_filter('script_loader_tag', 'fau_remove_type_attr', 10, 2);
add_filter( 'wp_resource_hints', 'fau_remove_default_dns_prefetch', 10, 2 );

function fau_dns_prefetch() {
// List of domains to set prefetching for
$prefetchDomains = [ 'https://www.fau.de' ];
$mydomain = parse_url(get_home_url());
$prefetchDomains[] = $mydomain['host'];

$prefetchDomains = array_unique($prefetchDomains);
$result = '';

foreach ($prefetchDomains as $domain) {
$domain = esc_url($domain);
$result .= '<link rel="dns-prefetch" href="' . $domain . '" crossorigin>'."\n";
$result .= '<link rel="preconnect" href="' . $domain . '" crossorigin>'."\n";
}

echo $result;
}
add_action('wp_head', 'fau_dns_prefetch', 10);


/*-----------------------------------------------------------------------------------*/
/* Change default header
Expand All @@ -212,19 +238,19 @@ function fau_addmetatags() {

$googleverification = get_theme_mod('google-site-verification');
if ((isset( $googleverification )) && ( !fau_empty($googleverification) )) {
$output .= ' <meta name="google-site-verification" content="'.$googleverification.'">'."\n";
$output .= '<meta name="google-site-verification" content="'.$googleverification.'">'."\n";
}

if ( ! function_exists( 'has_site_icon' ) || ! has_site_icon() ) {
$output .= ' <link rel="shortcut icon" href="'.get_fau_template_uri().'/img/socialmedia/favicon.ico">'."\n";
$output .= ' <link rel="apple-touch-icon" sizes="180x180" href="'.get_fau_template_uri().'/img/socialmedia/favicon-180x180.png">'."\n";
$output .= '<link rel="shortcut icon" href="'.get_fau_template_uri().'/img/socialmedia/favicon.ico">'."\n";
$output .= '<link rel="apple-touch-icon" sizes="180x180" href="'.get_fau_template_uri().'/img/socialmedia/favicon-180x180.png">'."\n";
// $output .= ' <link rel="icon" type="image/png" sizes="32x32" href="'.get_fau_template_uri().'/img/socialmedia/favicon-32x32.png">'."\n";
$output .= ' <link rel="icon" type="image/png" sizes="180x180" href="'.get_fau_template_uri().'/img/socialmedia/favicon-180x180.png">'."\n";
$output .= ' <link rel="icon" type="image/svg+xml" href="'.get_fau_template_uri().'/img/socialmedia/favicon.svg" sizes="any">'."\n";
$output .= ' <link rel="mask-icon" type="image/svg+xml" href="'.get_fau_template_uri().'/img/socialmedia/favicon-mask.svg" color="'.$defaultoptions['default-social-media-color'].'">'."\n";
$output .= ' <meta name="msapplication-TileColor" content="'.$defaultoptions['default-social-media-color'].'">'."\n";
$output .= ' <meta name="msapplication-TileImage" content="'.get_fau_template_uri().'/img/socialmedia/favicon-180x180.png">'."\n";
$output .= ' <meta name="theme-color" content="'.$defaultoptions['default-social-media-color'].'">'."\n";
$output .= '<link rel="icon" type="image/png" sizes="180x180" href="'.get_fau_template_uri().'/img/socialmedia/favicon-180x180.png">'."\n";
$output .= '<link rel="icon" type="image/svg+xml" href="'.get_fau_template_uri().'/img/socialmedia/favicon.svg" sizes="any">'."\n";
$output .= '<link rel="mask-icon" type="image/svg+xml" href="'.get_fau_template_uri().'/img/socialmedia/favicon-mask.svg" color="'.$defaultoptions['default-social-media-color'].'">'."\n";
$output .= '<meta name="msapplication-TileColor" content="'.$defaultoptions['default-social-media-color'].'">'."\n";
$output .= '<meta name="msapplication-TileImage" content="'.get_fau_template_uri().'/img/socialmedia/favicon-180x180.png">'."\n";
$output .= '<meta name="theme-color" content="'.$defaultoptions['default-social-media-color'].'">'."\n";

}

Expand All @@ -233,51 +259,22 @@ function fau_addmetatags() {
// Will post both: feed and comment feed; To use only main rss feed, i have to add it manually in head

$title = sanitize_text_field(get_bloginfo( 'name' ));
$output .= ' <link rel="alternate" type="application/rss+xml" title="'.$title.' - RSS 2.0 Feed" href="'.get_bloginfo( 'rss2_url').'">'."\n";

if ($defaultoptions['default-sourcecode-notice']) {
$output .= ' <!-- '.$defaultoptions['default-sourcecode-notice-text'].' -->'."\n";
}


$output .= '<link rel="alternate" type="application/rss+xml" title="'.$title.' - RSS 2.0 Feed" href="'.get_bloginfo( 'rss2_url').'">'."\n";
echo $output;
}
add_action('wp_head', 'fau_addmetatags',1);


/*-----------------------------------------------------------------------------------*/
/* Change default DNS prefetch
/* Add FAU Jobs advertisement
/*-----------------------------------------------------------------------------------*/
function fau_remove_default_dns_prefetch( $hints, $relation_type ) {
if ( 'dns-prefetch' === $relation_type ) {
return array_diff( wp_dependencies_unique_hosts(), $hints );
}

return $hints;
}
add_filter( 'wp_resource_hints', 'fau_remove_default_dns_prefetch', 10, 2 );

function fau_dns_prefetch() {
// List of domains to set prefetching for
$prefetchDomains = [ 'https://www.fau.de' ];
$mydomain = parse_url(get_home_url());
$prefetchDomains[] = $mydomain['host'];


$prefetchDomains = array_unique($prefetchDomains);
$result = '';

foreach ($prefetchDomains as $domain) {
$domain = esc_url($domain);
$result .= ' <link rel="dns-prefetch" href="' . $domain . '" crossorigin />'."\n";
$result .= ' <link rel="preconnect" href="' . $domain . '" crossorigin />'."\n";
function fau_addmjobsad() {
global $defaultoptions;

if ($defaultoptions['default-sourcecode-notice']) {
echo '<!-- '.$defaultoptions['default-sourcecode-notice-text'].' -->'."\n";
}

echo $result;
}
add_action('wp_head', 'fau_dns_prefetch', 10);


add_action('wp_head', 'fau_addmjobsad',10);
/*-----------------------------------------------------------------------------------*/
/* Remove something out of the head
/*-----------------------------------------------------------------------------------*/
Expand Down
41 changes: 11 additions & 30 deletions functions/filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ function filter_media_comment_status( $open, $post_id ) {
return $open;
}
add_filter( 'comments_open', 'filter_media_comment_status', 10 , 2 );
/*-----------------------------------------------------------------------------------*/
/* Remove Inline Style for recent comments
/*-----------------------------------------------------------------------------------*/
add_filter( 'show_recent_comments_widget_style', '__return_false' );


/*-----------------------------------------------------------------------------------*/
Expand Down Expand Up @@ -354,35 +358,12 @@ function fau_img_caption_shortcode_filter($val, $attr, $content = null) {
. '>' . $caption . '</figcaption></figure>';
}
add_filter('img_caption_shortcode', 'fau_img_caption_shortcode_filter',10,3);

/*-----------------------------------------------------------------------------------*/
/* Defined allowed core block types if theme is used in Gutenberg Block Editor
/*-----------------------------------------------------------------------------------*/
function fau_allowed_block_types( $allowed_block_types, $post ) {
if ( ($post->post_type === 'post' ) || ( $post->post_type === 'page' )) {
return array(
'core/paragraph',
'core/image',
'core/list',
'core/file',
'core/gallery',
'core/heading',
'core/html',
'core/quote',
'core/shortcode',
'core/table'
);
}
return $allowed_block_types;
/* Remove type-String from link-reference to follow W3C Validator
/*-----------------------------------------------------------------------------------*/
function fau_remove_type_attr($tag, $handle) {
return preg_replace( "/type=['\"]text\/(javascript|css)['\"]/", '', $tag );
}

// add_filter( 'allowed_block_types', 'fau_allowed_block_types', 10, 2 );

/*
* TODO:
* Wir mussen das andersrum machen, da wir die Liste der erlaubten Typen nicht alle kennen:
* Es können durch Plugins andere hinzukommen, die wir bearbeitbar lassen wollen.
* Daher andersUm
* Array eingeben der Typen, die wir verbieten wollen.
* Diese gegen eine Liste matchen, die alle Typen enthält.
* Und von der Gesamatliste eben die verbotenenen Typen abziehen
*/
add_filter('style_loader_tag', 'fau_remove_type_attr', 10, 2);
add_filter('script_loader_tag', 'fau_remove_type_attr', 10, 2);
35 changes: 34 additions & 1 deletion functions/gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,37 @@ function fau_add_gutenberg_assets() {
// Load the theme styles within Gutenberg.
wp_enqueue_style( 'fau-gutenberg', get_theme_file_uri( '/css/fau-theme-gutenberg.css' ), false );
}
add_action( 'enqueue_block_editor_assets', 'fau_add_gutenberg_assets' );
add_action( 'enqueue_block_editor_assets', 'fau_add_gutenberg_assets' );

/*-----------------------------------------------------------------------------------*/
/* Defined allowed core block types if theme is used in Gutenberg Block Editor
/*-----------------------------------------------------------------------------------*/
function fau_allowed_block_types( $allowed_block_types, $post ) {
if ( ($post->post_type === 'post' ) || ( $post->post_type === 'page' )) {
return array(
'core/paragraph',
'core/image',
'core/list',
'core/file',
'core/gallery',
'core/heading',
'core/html',
'core/quote',
'core/shortcode',
'core/table'
);
}
return $allowed_block_types;
}

// add_filter( 'allowed_block_types', 'fau_allowed_block_types', 10, 2 );

/*
* TODO:
* Wir mussen das andersrum machen, da wir die Liste der erlaubten Typen nicht alle kennen:
* Es können durch Plugins andere hinzukommen, die wir bearbeitbar lassen wollen.
* Daher andersUm
* Array eingeben der Typen, die wir verbieten wollen.
* Diese gegen eine Liste matchen, die alle Typen enthält.
* Und von der Gesamatliste eben die verbotenenen Typen abziehen
*/
18 changes: 18 additions & 0 deletions functions/template-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1944,6 +1944,24 @@ function fau_get_the_taglist($before = '', $sep = '', $after = '') {
}
return $res;
}
/*-----------------------------------------------------------------------------------*/
/* Add tabs / intendens to default output functions
* Source/credits to: https://wordpress.stackexchange.com/questions/70901/indenting-tabbing-wp-head
*/
/*-----------------------------------------------------------------------------------*/
if (! function_exists("print_indented")) {
function print_indented($fn, $num_tabs=1, $params=null){
ob_start();
call_user_func($fn, $params);
$html = ob_get_contents();
ob_end_clean();
$tabs="";
for ($i=0 ; $i<$num_tabs ; $i++) $tabs.="\t";
echo preg_replace("/\n/", "\n" . $tabs, substr($html, 0, - 1));
echo "\n";
}
}

/*-----------------------------------------------------------------------------------*/
/* This is the end :)
/*-----------------------------------------------------------------------------------*/
Loading

0 comments on commit c7dbeb1

Please sign in to comment.