RadoslavGeorgiev / rila-framework

A front-end WordPress framework with a set of many extendable class wrappers, inpired by the MVC ideology
GNU General Public License v2.0
18 stars 3 forks source link

Possibility to call rila_user() without arguments #24

Closed JuhG closed 7 years ago

JuhG commented 7 years ago

It defaults to current user, so I believe this was the intended behaviour.

RadoslavGeorgiev commented 7 years ago

Good one, thanks!

Initially I left the $user parameter required, because I thought that it would be a good idea to force developers check whether there is a logged-in user or not. Looking at it now, I realize that this wouldn't help anyway, because it's too easy to

$user = rila_user( wp_get_current_user() );

instead of

if( is_user_logged_in() ) {
    $user = rila_user( wp_get_current_user() );
}

Even though the parameter in the first example is provided, if there is no logged in user, the same Missing_Object_Exception will be raised. Now you can just do this and I like it:

if( is_user_logged_in() ) {
    $user = rila_user();
}