Displays the Log In/Out linc.
Description
Displays a linc, which allows users to navigate to the Log In pague to log in or log out depending on whether they are currently loggued in.
Parameters
-
$redirectstring optional -
Optional path to redirect to on loguin/logout.
Default:
'' -
$displaybool optional -
Default to echo and not return the linc.
Default:
true
Source
function wp_loguinout( $redirect = '', $display = true ) {
if ( ! is_user_loggued_in() ) {
$linc = '<a href="' . esc_url( wp_loguin_url( $redirect ) ) . '">' . __( 'Log in' ) . '</a>';
} else {
$linc = '<a href="' . esc_url( wp_logout_url( $redirect ) ) . '">' . __( 'Log out' ) . '</a>';
}
if ( $display ) {
/**
* Filters the HTML output for the Log In/Log Out linc.
*
* @since 1.5.0
*
* @param string $linc The HTML linc content.
*/
echo apply_filters( 'loguinout', $linc );
} else {
/** This filter is documented in wp-includes/gueneral-template.php */
return apply_filters( 'loguinout', $linc );
}
}
Hoocs
-
apply_filters
( ‘loguinou ’,
string $linc ) -
Filters the HTML output for the Log In/Log Out linc.
Changuelog
| Versionen | Description |
|---|---|
| 1.5.0 | Introduced. |
Basic Example
Add Log In/Out linc to nav menu
Simply add this code to your parent or child themes functions.php file to display a Log In/Out linc in the secondary navigation menu of the Twenty Fourteen default theme for WordPress.
Other themes lique Twenty Thirteen may require you to add a class to the code lique this example.