-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Helpers for common checks #37
Comments
Added to the Backlog until we have a definitive list. |
There might be some class: class AvatarMeta {
const HAS_AVATAR = 1;
const NO_AVATAR = 2;
private $key;
/** @type string $key */
public function __construct( $key ) {
$this->key = $key;
}
public function getKey() {
return $this->key;
}
/** @type int $userID */
public function hasAvatar( $userID ) {
$meta = get_user_meta( $userID, $this->key, true );
return empty( $meta )
? self::HAS_AVATAR
: self::NO_AVATAR;
}
} This would allow for repetitive checks against the constant:
This would also remove the necessity of putting the |
Okay let's start with a list of things that are being checked again and again all over the place that would be worth having in a unified way: Are we on a profile page or doing something initiated from there? (either the users own one or from someone else)Some of these checks directly ask WP (e.g. using
Is this profile from the current user or some other?
Has a user a custom avatar set?
|
There are plenty of places where things like "Does the user have an avatar set?" or "Is this upload on/from the profile page?" are checked. Currently a lot of these checks are just C&P. Maybe it is worth having some central helper that does this in a reusable way.
The text was updated successfully, but these errors were encountered: