PluginProbe
Polylang / 3.8.4
Polylang v3.8.4
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
polylang / src / Capabilities / User / Creator.php

Creator.php in Polylang 3.8.4, at src/Capabilities/User/Creator.php

42 lines 802 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package Polylang
4 */
5
6 namespace WP_Syntex\Polylang\Capabilities\User;
7
8 use WP_User;
9
10 /**
11 * A class to create a decorated user.
12 * Always returns a `NOOP` instance so capabilities features are disabled by default.
13 *
14 * @since 3.8
15 */
16 class Creator implements Creator_Interface {
17 /**
18 * The user instance to be used for capability checks.
19 *
20 * @var NOOP
21 */
22 private ?NOOP $instance = null;
23
24 /**
25 * Creates and returns the user.
26 *
27 * @since 3.8
28 *
29 * @param WP_User $user The user to decorate.
30 * @return User_Interface Instance of `NOOP`.
31 */
32 public function get( WP_User $user ): User_Interface {
33 if ( $this->instance && $user->ID === $this->instance->get_id() ) {
34 return $this->instance;
35 }
36
37 $this->instance = new NOOP( $user );
38
39 return $this->instance;
40 }
41 }
42