Files

83 lines
2.3 KiB
PHP

<?php
// Theme setup.
function super_simple_theme_setup() {
add_theme_support("title-tag");
}
add_action("after_setup_theme", "super_simple_theme_setup");
// Register the theme's navigation menu.
function register_my_menu() {
register_nav_menu("header-menu", __("Header Menu", "super-simple-wp-theme"));
}
add_action("init", "register_my_menu");
/**
* Remove bbPress' own front-end stylesheet.
*
* bbPress ships css/bbpress.css and enqueues it on every forum page. It clashes
* with the theme's forum styling, so we drop it and let the theme control the
* forum look (as it did before wp_head() was added to the theme).
*
* Matched by file name rather than by handle, so this keeps working even if
* bbPress changes the style handle.
*/
function super_simple_remove_bbpress_styles() {
global $wp_styles;
if (empty($wp_styles->queue)) {
return;
}
foreach ($wp_styles->queue as $handle) {
$src = isset($wp_styles->registered[$handle]) ? (string) $wp_styles->registered[$handle]->src : "";
if (false !== strpos($src, "bbpress") && ".css" === substr($src, -4)) {
wp_dequeue_style($handle);
}
}
}
add_action("wp_enqueue_scripts", "super_simple_remove_bbpress_styles", 100);
// Redirect guests to the login page when they visit the forum.
function redirect_to_login_if_not_logged_in() {
if (function_exists("is_bbpress") && is_bbpress() && !is_user_logged_in()) {
wp_redirect(wp_login_url(get_permalink()));
exit;
}
}
add_action("template_redirect", "redirect_to_login_if_not_logged_in");
// Strip the "Privat: " prefix from private post titles (front end only).
function remove_private_title_prefix($title) {
if (is_admin()) {
return $title;
}
return str_replace("Privat: ", "", $title);
}
add_filter("the_title", "remove_private_title_prefix");
// Output a logout link for logged-in users.
function add_logout_button() {
if (is_user_logged_in()) {
echo '<a href="' . esc_url(wp_logout_url(home_url())) . '">Logg ut</a>';
}
}
// Override the default WordPress sender address.
function new_mail_from($old) {
return "info@taubaneforeningen.no";
}
add_filter("wp_mail_from", "new_mail_from");
function new_mail_from_name($old) {
return "Norske Tau- og Kabelbaners Forening";
}
add_filter("wp_mail_from_name", "new_mail_from_name");