diff --git a/inc/sso.php b/inc/sso.php index 0731543..f4c9843 100644 --- a/inc/sso.php +++ b/inc/sso.php @@ -33,30 +33,45 @@ $custom_css = isset( $sso_options['loginout_css'] ) ? $sso_options['loginout_css'] : ''; $body_classes = array( 'sso-body', 'login', 'login-action-login', 'wp-core-ui', 'locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) ) ); -$body_classes = apply_filters( 'sso_login_logout_body_class', $body_classes, $action ); + +if ( has_filter( 'sso_login_logout_body_class' ) ) { + // Deprecated since 1.1 + _deprecated_function( 'The sso_login_logout_body_class filter', '1.1', 'wp_multisite_sso-login_logout_body_class' ); + $body_classes = apply_filters( 'sso_login_logout_body_class', $body_classes, $action ); +} else { + $body_classes = apply_filters( 'wp_multisite_sso-login_logout_body_class', $body_classes, $action ); +} $login_header_url = network_home_url(); $login_header_title = get_current_site()->site_name; $redirect = home_url(); -if ( WP_MultiSite_SSO::LOGIN_ACTION === $action ) { - /** - * Filter the redirect location after being logged in. - * - * @param string $redirect The redirect location. - * @param string $action The login or logout action being taken. - * @param object $user The current user. - */ - $redirect = apply_filters( 'wp_multisite_sso_login_redirect', $redirect, $action, $user ); +if ( has_filter( 'wp_multisite_sso_redirect' ) ) { + // Deprecated since 1.1 + _deprecated_function( 'The wp_multisite_sso_redirect filter', '1.1', 'wp_multisite_sso-login_redirect or wp_multisite_sso-logout_redirect' ); + // define a blank user if one is not set, this resolves a bug with the previous implementation + $user = empty( $user ) ? false : $user; + $redirect = apply_filters( 'wp_multisite_sso_redirect', $redirect, $action, $user ); } else { - /** - * Filter the redirect location after being logout. - * - * @param string $redirect The redirect location. - * @param string $action The login or logout action being taken. - */ - $redirect = apply_filters( 'wp_multisite_sso_logout_redirect', $redirect, $action ); + if ( WP_MultiSite_SSO::LOGIN_ACTION === $action ) { + /** + * Filter the redirect location after being logged in. + * + * @param string $redirect The redirect location. + * @param string $action The login or logout action being taken. + * @param object $user The current user. + */ + $redirect = apply_filters( 'wp_multisite_sso-login_redirect', $redirect, $action, $user ); + } else { + /** + * Filter the redirect location after being logout. + * + * @param string $redirect The redirect location. + * @param string $action The login or logout action being taken. + */ + $redirect = apply_filters( 'wp_multisite_sso-logout_redirect', $redirect, $action ); + } } ?> @@ -136,7 +151,13 @@ function loadComplete(){ printf( '', esc_attr( $custom_css ) ); // do any custom actions for the SSO login/logout page - do_action( 'sso_head' ); + if ( has_action( 'sso_head' ) ) { + // Deprecated since 1.1 + _deprecated_function( 'The sso_head action', '1.1', 'wp_multisite_sso-sso_head' ); + do_action( 'sso_head' ); + } else { + do_action( 'wp_multisite_sso-sso_head' ); + } ?>