| 1 | <?php |
||
| 11 | class Wordlift_User_Service { |
||
|
1 ignored issue
–
show
|
|||
| 12 | |||
| 13 | /** |
||
| 14 | * The meta key where the user's URI is stored. |
||
| 15 | * |
||
| 16 | * @since 3.1.7 |
||
| 17 | */ |
||
| 18 | const URI_META_KEY = '_wl_uri'; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * The Log service. |
||
| 22 | * |
||
| 23 | * @since 3.1.7 |
||
| 24 | * @access private |
||
| 25 | * @var \Wordlift_Log_Service $log_service The Log service. |
||
| 26 | */ |
||
| 27 | private $log_service; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * The singleton instance of the User service. |
||
| 31 | * |
||
| 32 | * @since 3.1.7 |
||
| 33 | * @access private |
||
| 34 | * @var \Wordlift_User_Service $user_service The singleton instance of the User service. |
||
| 35 | */ |
||
| 36 | private static $instance; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Create an instance of the User service. |
||
| 40 | * |
||
| 41 | * @since 3.1.7 |
||
| 42 | */ |
||
| 43 | public function __construct() { |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Get the singleton instance of the User service. |
||
| 53 | * |
||
| 54 | * @since 3.1.7 |
||
| 55 | * @return \Wordlift_User_Service The singleton instance of the User service. |
||
| 56 | */ |
||
| 57 | public static function get_instance() { |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Get the URI for a user. |
||
| 64 | * |
||
| 65 | * @since 3.1.7 |
||
| 66 | * |
||
| 67 | * @param int $user_id The user id |
||
| 68 | * |
||
| 69 | * @return false|string The user's URI or false in case of failure. |
||
| 70 | */ |
||
| 71 | public function get_uri( $user_id ) { |
||
| 88 | |||
| 89 | /** |
||
| 90 | * Receives wp_insert_post events. |
||
| 91 | * |
||
| 92 | * @since 3.1.7 |
||
| 93 | * |
||
| 94 | * @param int $post_id Post ID. |
||
| 95 | * @param WP_Post $post Post object. |
||
| 96 | * @param bool $update Whether this is an existing post being updated or not. |
||
| 97 | */ |
||
| 98 | public function wp_insert_post( $post_id, $post, $update ) { |
||
| 124 | |||
| 125 | /** |
||
| 126 | * Get the user's URI stored in the user's meta. |
||
| 127 | * |
||
| 128 | * @since 3.1.7 |
||
| 129 | * |
||
| 130 | * @param int $user_id The user id. |
||
| 131 | * |
||
| 132 | * @return false|string The user's URI or false if not found. |
||
| 133 | */ |
||
| 134 | private function _get_uri( $user_id ) { |
||
| 144 | |||
| 145 | /** |
||
| 146 | * Build an URI for a user. |
||
| 147 | * |
||
| 148 | * @since 3.1.7 |
||
| 149 | * |
||
| 150 | * @param int $user_id The user's id. |
||
| 151 | * |
||
| 152 | * @return false|string The user's URI or false in case of failure. |
||
| 153 | */ |
||
| 154 | private function _build_uri( $user_id ) { |
||
| 168 | |||
| 169 | /** |
||
| 170 | * Store the URI in user's meta. |
||
| 171 | * |
||
| 172 | * @since 3.1.7 |
||
| 173 | * |
||
| 174 | * @param int $user_id The user's id. |
||
| 175 | * @param string $user_uri The user's uri. |
||
| 176 | * |
||
| 177 | * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure. |
||
| 178 | */ |
||
| 179 | private function _set_uri( $user_id, $user_uri ) { |
||
| 183 | |||
| 184 | /** |
||
| 185 | * Get the delete query. |
||
| 186 | * |
||
| 187 | * @since 3.1.7 |
||
| 188 | * |
||
| 189 | * @param int $user_id The user id. |
||
| 190 | * |
||
| 191 | * @return false|string The delete query or false in case of failure. |
||
| 192 | */ |
||
| 193 | private function get_delete_query( $user_id ) { |
||
| 219 | |||
| 220 | /** |
||
| 221 | * Get the insert query. |
||
| 222 | * |
||
| 223 | * @since 3.1.7 |
||
| 224 | * |
||
| 225 | * @param int $user_id The user id. |
||
| 226 | * |
||
| 227 | * @return false|string The insert query or false in case of failure. |
||
| 228 | */ |
||
| 229 | private function get_insert_query( $user_id ) { |
||
| 253 | |||
| 254 | } |
||
|
1 ignored issue
–
show
|
|||
| 255 |