Login / Logout in Navi

add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2);
function add_login_logout_link($items, $args) {
        ob_start();
        wp_loginout('index.php');
        $loginoutlink = ob_get_contents();
        ob_end_clean();
        $items .= '<li>'. $loginoutlink .'</li>';
    return $items;
}

Current Year Shortcode

add_shortcode( 'current_year', 'mw_current_year' );
function mw_current_year() {
    ob_start();
    echo date('Y');
    return ob_get_clean();
}

Shortcode

[current_year]
2022

Color Palette for Gutenberg

add_action( 'after_setup_theme', function() {
    add_theme_support( 'editor-color-palette', array(
        array(
            'name'  => __( 'Blue' ),
            'slug'  => 'blue',
            'color' => '#59BACC',
        ),
        array(
            'name'  => __( 'Green' ),
            'slug'  => 'green',
            'color' => '#58AD69',
        ),
        array(
            'name'  => __( 'Orange' ),
            'slug'  => 'orange',
            'color' => '#FFBC49',
        ),
        array(
            'name'  => __( 'Red' ),
            'slug'  => 'red',
            'color' => '#E2574C',
        ),
    ) );
} );

Redirect after Login

For every user role except Admin

function my_login_redirect( $redirect_to, $request, $user ) {
    //is there a user to check?
    if ( isset( $user->roles ) && is_array( $user->roles ) ) {
        //check for admins
        if ( in_array( 'administrator', $user->roles ) ) {
            // redirect them to the default place
            return $redirect_to;
        } else {
            return home_url(); /* return home_url( '/members-only/' ); */
        }
    } else {
        return $redirect_to;
    }
}
 
add_filter( 'login_redirect', 'my_login_redirect', 10, 3 );

Weiterleitung zu Google bei falschem Login

// WEITERLEITUNG ZU GOOGLE //
if ( ! function_exists( 'ah_redirect_after_login_errors' ) ) :
/**
 * Redirect auf Google nach falscher Eingabe der WP-Zugangsdaten
 */
function ah_redirect_after_login_errors() {
    
  wp_redirect( 'https://google.de' );
  exit;
}
add_filter( 'login_errors', 'ah_redirect_after_login_errors' );
endif;

Open all external Links in new tab JS

window.onload = function(){
  var anchors = document.getElementsByTagName('a');
  for (var i=0; i<anchors.length; i++){
    if (anchors[i].hostname != window.location.hostname) {
        anchors[i].setAttribute('target', '_blank');
    }
  }
}

Generatepress Remove Google Fonts

add_action( 'wp_enqueue_scripts', function() {
    wp_dequeue_style( 'generate-fonts' );
} );

Remove Google Fonts from Customizer too

add_action( 'admin_init', function() {
    add_filter( 'generate_google_fonts_array', '__return_empty_array' );
} );

Elementor – disable Google Fonts, Font Awesome and Eicons

Disable Google Fonts

add_filter( 'elementor/frontend/print_google_fonts', '__return_false' );

Disable Font Awesome

add_action( 'elementor/frontend/after_register_styles',function() {
	foreach( [ 'solid', 'regular', 'brands' ] as $style ) {
		wp_deregister_style( 'elementor-icons-fa-' . $style );
	}
}, 20 );

Disable Eicons

add_action( 'wp_enqueue_scripts', 'remove_default_stylesheet', 20 ); 
function remove_default_stylesheet() { 
	wp_deregister_style( 'elementor-icons' ); 
}

Force https

# ----------------------------------------------------------------------
#  301 Redirekt von http auf https
# ----------------------------------------------------------------------

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]