array( __CLASS__, 'render_block' ), ) ); } /** * Renders the block on the front end. * * @param array $attributes Block attributes. * @return string */ public static function render_block( $attributes ) { return self::render( array( 'redirect' => isset( $attributes['redirect'] ) ? (string) $attributes['redirect'] : '' ) ); } /** * Renders the form, or a short message for signed-in visitors. * * @param array|string $atts Shortcode attributes. * @return string */ public static function render( $atts ) { $atts = shortcode_atts( array( 'redirect' => '' ), is_array( $atts ) ? $atts : array(), self::TAG ); if ( is_user_logged_in() ) { return '
' . sprintf( /* translators: %s: link to log out. */ esc_html__( 'You are signed in. %s', 'aslansheed-login' ), '' . esc_html__( 'Log out', 'aslansheed-login' ) . '' ) . '
'; } $redirect = '' !== $atts['redirect'] ? $atts['redirect'] : ( isset( $_GET['redirect_to'] ) ? wp_unslash( $_GET['redirect_to'] ) : '' ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Validated by wp_validate_redirect() in Form::render(). return Form::render( array( 'redirect' => (string) $redirect ) ); } }