Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter updates #21

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 39 additions & 18 deletions inc/sso.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}
?>
<html>
Expand Down Expand Up @@ -136,7 +151,13 @@ function loadComplete(){
printf( '<style type="text/css">%s</style>', 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' );
}
?>
</head>
<body class="<?php echo implode( ' ', $body_classes ); ?>">
Expand Down