Edit File by line
/home/zeestwma/richards.../wp-inclu.../blocks
File: loginout.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Server-side rendering of the `core/loginout` block.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Renders the `core/loginout` block on server.
[8] Fix | Delete
*
[9] Fix | Delete
* @since 5.8.0
[10] Fix | Delete
*
[11] Fix | Delete
* @param array $attributes The block attributes.
[12] Fix | Delete
*
[13] Fix | Delete
* @return string Returns the login-out link or form.
[14] Fix | Delete
*/
[15] Fix | Delete
function render_block_core_loginout( $attributes ) {
[16] Fix | Delete
[17] Fix | Delete
/*
[18] Fix | Delete
* Build the redirect URL. This current url fetching logic matches with the core.
[19] Fix | Delete
*
[20] Fix | Delete
* @see https://github.com/WordPress/wordpress-develop/blob/6bf62e58d21739938f3bb3f9e16ba702baf9c2cc/src/wp-includes/general-template.php#L528.
[21] Fix | Delete
*/
[22] Fix | Delete
$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
[23] Fix | Delete
[24] Fix | Delete
$user_logged_in = is_user_logged_in();
[25] Fix | Delete
[26] Fix | Delete
$classes = $user_logged_in ? 'logged-in' : 'logged-out';
[27] Fix | Delete
$contents = wp_loginout(
[28] Fix | Delete
isset( $attributes['redirectToCurrent'] ) && $attributes['redirectToCurrent'] ? $current_url : '',
[29] Fix | Delete
false
[30] Fix | Delete
);
[31] Fix | Delete
[32] Fix | Delete
// If logged-out and displayLoginAsForm is true, show the login form.
[33] Fix | Delete
if ( ! $user_logged_in && ! empty( $attributes['displayLoginAsForm'] ) ) {
[34] Fix | Delete
// Add a class.
[35] Fix | Delete
$classes .= ' has-login-form';
[36] Fix | Delete
[37] Fix | Delete
// Get the form.
[38] Fix | Delete
$contents = wp_login_form( array( 'echo' => false ) );
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
[42] Fix | Delete
[43] Fix | Delete
return '<div ' . $wrapper_attributes . '>' . $contents . '</div>';
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
/**
[47] Fix | Delete
* Registers the `core/loginout` block on server.
[48] Fix | Delete
*
[49] Fix | Delete
* @since 5.8.0
[50] Fix | Delete
*/
[51] Fix | Delete
function register_block_core_loginout() {
[52] Fix | Delete
register_block_type_from_metadata(
[53] Fix | Delete
__DIR__ . '/loginout',
[54] Fix | Delete
array(
[55] Fix | Delete
'render_callback' => 'render_block_core_loginout',
[56] Fix | Delete
)
[57] Fix | Delete
);
[58] Fix | Delete
}
[59] Fix | Delete
add_action( 'init', 'register_block_core_loginout' );
[60] Fix | Delete
[61] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function