Support custom login pages
- Add the button (and error messages) to every wp_login_form() form via login_form_top/login_form_bottom; in button-only mode the password fields are wrapped and hidden there. - New template functions m365_login_button() and m365_login_messages(); the shortcode gains divider and messages attributes. - New setting for the custom login page URL: failed sign-ins, the fallback link and the logout redirect point there instead of wp-login.php. Must be a same-site URL. - Button-only mode now blocks every interactive password sign-in through the authenticate filter, not only wp-login.php; XML-RPC, REST, WP-CLI and cron are exempt, plus a filter for trusted exceptions. - Fallback key accepted on any page (init) instead of login_init only. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JJxAHYdMfKPoN4koRc4Ci2
This commit is contained in:
parent
e5db0d49be
commit
701e85ab88
15 changed files with 804 additions and 300 deletions
49
includes/functions.php
Normal file
49
includes/functions.php
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
/**
|
||||
* Template functions.
|
||||
*
|
||||
* @package M365_Login
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( ! function_exists( 'm365_login_button' ) ) {
|
||||
/**
|
||||
* Outputs (or returns) the "Sign in with Microsoft" button for custom login templates.
|
||||
*
|
||||
* Usage in a theme template:
|
||||
* <?php m365_login_button( array( 'redirect' => home_url( '/dashboard/' ) ) ); ?>
|
||||
*
|
||||
* @param array $args {
|
||||
* @type string $redirect Destination after login. Default: admin dashboard.
|
||||
* @type bool $show_messages Show error/info messages from a previous attempt. Default true.
|
||||
* @type bool $show_divider Show the "or" divider above the button. Default false.
|
||||
* }
|
||||
* @param bool $display Echo (true) or return (false). Default true.
|
||||
* @return string
|
||||
*/
|
||||
function m365_login_button( $args = array(), $display = true ) {
|
||||
$plugin = M365_Login::instance();
|
||||
$html = $plugin->button->standalone( $args );
|
||||
if ( $display ) {
|
||||
echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- markup is escaped where it is built.
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'm365_login_messages' ) ) {
|
||||
/**
|
||||
* Outputs (or returns) the error/info messages of the last Microsoft sign-in attempt.
|
||||
*
|
||||
* @param bool $display Echo (true) or return (false). Default true.
|
||||
* @return string
|
||||
*/
|
||||
function m365_login_messages( $display = true ) {
|
||||
$html = M365_Login::instance()->button->messages_markup();
|
||||
if ( $display ) {
|
||||
echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- markup is escaped where it is built.
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue