-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathuseful-functions.php
55 lines (46 loc) · 1.56 KB
/
useful-functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/*
* Include this in your functions.php file to include empty taxonomies in the Yoast SEO Sitemap xml
*/
add_filter('wpseo_sitemap_exclude_empty_terms', '__return_false');
/*
* Hides WP Admin Dashboard for non-admins and redirects them to a front-end url like /member-account
*/
add_action( 'init', 'blockusers_init' );
function blockusers_init() {
if ( is_admin() && ! current_user_can( 'administrator' ) &&
! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
wp_redirect( home_url('/member-account') ); // you can change this url to whatever your sites front-end user-profile url is
exit;
}
}
/*
* Add custom logo to WP login screen
*/
function logo_filter_login_head() {
if ( has_custom_logo() ) :
$image = wp_get_attachment_image_src( get_theme_mod( 'custom_logo' ), 'full' );
?>
<style type="text/css">
.login h1 a {
background-image: url(<?php echo esc_url( $image[0] ); ?>);
background-size: contain;
height: 120px;
width: 320px;
}
</style>
<?php
endif;
}
add_action( 'login_head', 'logo_filter_login_head', 100 );
// Add home url to custom logo on login screen instead of WP url
add_filter( 'login_headerurl', 'my_login_logo_url', 10, 1 );
function my_login_logo_url( $url ){
return home_url();
}
// Add your blog site title to login logo instead of WP
add_filter( 'login_headertext', 'my_login_logo_url_title' );
function my_login_logo_url_title(){
return esc_html( get_bloginfo( 'name' ) );
}
?>