Tidy functions.php: guards, escaping, English comments

This commit is contained in:
ai-bot committed 2026-10-14 09:05:45 +00:00
1 parent 9b29d3d672
commit 51faedbc32
1 file changed
+22 -29
+22 -29
View File
@@ -1,54 +1,47 @@
<?php
// Register the theme's navigation menu.
function register_my_menu() {
register_nav_menu("header-menu", __( "Header Menu" ));
register_nav_menu("header-menu", __("Header Menu", "super-simple-wp-theme"));
}
add_action("init", "register_my_menu");
// Vidaresend til innlogging viss ein ikkje er innlogga på forumet
// Redirect guests to the login page when they visit the forum.
function redirect_to_login_if_not_logged_in() {
if (is_bbpress() && !is_user_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');
// Ikkje vis profilsida
function remove_bbpress_profile_page() {
if (function_exists('bbp_is_single_user')) {
if (bbp_is_single_user()) {
//wp_redirect(home_url()); // Omdirigerer til hjemmesiden
wp_redirect(home_url('forums/')); // Omdirigerer til hjemmesiden
exit;
}
}
}
//add_action('template_redirect', 'remove_bbpress_profile_page');
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) {
// Fjern "Privat:" fra tittelen
$title = str_replace('Privat: ', '', $title);
if (is_admin()) {
return $title;
}
add_filter('the_title', 'remove_private_title_prefix');
return str_replace("Privat: ", "", $title);
}
add_filter("the_title", "remove_private_title_prefix");
// Logg-ut-knapp
// Output a logout link for logged-in users.
function add_logout_button() {
if (is_user_logged_in()) {
echo '<a href="' . wp_logout_url(home_url()) . '">Logg ut</a>';
echo '<a href="' . esc_url(wp_logout_url(home_url())) . '">Logg ut</a>';
}
}
// Change default WordPress email address
add_filter('wp_mail_from', 'new_mail_from');
add_filter('wp_mail_from_name', 'new_mail_from_name');
function new_mail_from($old) { return 'info@taubaneforeningen.no'; }
// 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'; }
//end: Change default WordPress email address
?>
function new_mail_from_name($old) {
return "Norske Tau- og Kabelbaners Forening";
}
add_filter("wp_mail_from_name", "new_mail_from_name");