Edit File by line
/home/barbar84/www/wp-conte.../plugins/wordpres.../src/helpers
File: user-helper.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Helpers;
[2] Fix | Delete
[3] Fix | Delete
/**
[4] Fix | Delete
* A helper object for the user.
[5] Fix | Delete
*/
[6] Fix | Delete
class User_Helper {
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Retrieves user meta field for a user.
[10] Fix | Delete
*
[11] Fix | Delete
* @param int $user_id User ID.
[12] Fix | Delete
* @param string $key Optional. The meta key to retrieve. By default, returns data for all keys.
[13] Fix | Delete
* @param bool $single Whether to return a single value.
[14] Fix | Delete
*
[15] Fix | Delete
* @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true.
[16] Fix | Delete
*/
[17] Fix | Delete
public function get_meta( $user_id, $key = '', $single = false ) {
[18] Fix | Delete
return \get_user_meta( $user_id, $key, $single );
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
/**
[22] Fix | Delete
* Counts the number of posts the user has written in this post type.
[23] Fix | Delete
*
[24] Fix | Delete
* @param int $user_id User ID.
[25] Fix | Delete
* @param array|string $post_type Optional. Single post type or array of post types to count the number of posts
[26] Fix | Delete
* for. Default 'post'.
[27] Fix | Delete
*
[28] Fix | Delete
* @return int The number of posts the user has written in this post type.
[29] Fix | Delete
*/
[30] Fix | Delete
public function count_posts( $user_id, $post_type = 'post' ) {
[31] Fix | Delete
return (int) \count_user_posts( $user_id, $post_type, true );
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
/**
[35] Fix | Delete
* Retrieves the requested data of the author.
[36] Fix | Delete
*
[37] Fix | Delete
* @param string $field The user field to retrieve.
[38] Fix | Delete
* @param int|false $user_id User ID.
[39] Fix | Delete
*
[40] Fix | Delete
* @return string The author's field from the current author's DB object.
[41] Fix | Delete
*/
[42] Fix | Delete
public function get_the_author_meta( $field, $user_id ) {
[43] Fix | Delete
return \get_the_author_meta( $field, $user_id );
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
/**
[47] Fix | Delete
* Retrieves the archive url of the user.
[48] Fix | Delete
*
[49] Fix | Delete
* @param int|false $user_id User ID.
[50] Fix | Delete
*
[51] Fix | Delete
* @return string The author's archive url.
[52] Fix | Delete
*/
[53] Fix | Delete
public function get_the_author_posts_url( $user_id ) {
[54] Fix | Delete
return \get_author_posts_url( $user_id );
[55] Fix | Delete
}
[56] Fix | Delete
[57] Fix | Delete
/**
[58] Fix | Delete
* Retrieves the current user ID.
[59] Fix | Delete
*
[60] Fix | Delete
* @return int The current user's ID, or 0 if no user is logged in.
[61] Fix | Delete
*/
[62] Fix | Delete
public function get_current_user_id() {
[63] Fix | Delete
return \get_current_user_id();
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
/**
[67] Fix | Delete
* Updates user meta field for a user.
[68] Fix | Delete
*
[69] Fix | Delete
* Use the $prev_value parameter to differentiate between meta fields with the
[70] Fix | Delete
* same key and user ID.
[71] Fix | Delete
*
[72] Fix | Delete
* If the meta field for the user does not exist, it will be added.
[73] Fix | Delete
*
[74] Fix | Delete
* @param int $user_id User ID.
[75] Fix | Delete
* @param string $meta_key Metadata key.
[76] Fix | Delete
* @param mixed $meta_value Metadata value. Must be serializable if non-scalar.
[77] Fix | Delete
* @param mixed $prev_value Optional. Previous value to check before updating.
[78] Fix | Delete
* If specified, only update existing metadata entries with
[79] Fix | Delete
* this value. Otherwise, update all entries. Default empty.
[80] Fix | Delete
*
[81] Fix | Delete
* @return int|bool Meta ID if the key didn't exist, true on successful update,
[82] Fix | Delete
* false on failure or if the value passed to the function
[83] Fix | Delete
* is the same as the one that is already in the database.
[84] Fix | Delete
*/
[85] Fix | Delete
public function update_meta( $user_id, $meta_key, $meta_value, $prev_value = '' ) {
[86] Fix | Delete
return \update_user_meta( $user_id, $meta_key, $meta_value, $prev_value );
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
/**
[90] Fix | Delete
* Removes metadata matching criteria from a user.
[91] Fix | Delete
*
[92] Fix | Delete
* You can match based on the key, or key and value. Removing based on key and
[93] Fix | Delete
* value, will keep from removing duplicate metadata with the same key. It also
[94] Fix | Delete
* allows removing all metadata matching key, if needed.
[95] Fix | Delete
*
[96] Fix | Delete
* @param int $user_id User ID.
[97] Fix | Delete
* @param string $meta_key Metadata name.
[98] Fix | Delete
* @param mixed $meta_value Optional. Metadata value. If provided,
[99] Fix | Delete
* rows will only be removed that match the value.
[100] Fix | Delete
* Must be serializable if non-scalar. Default empty.
[101] Fix | Delete
*
[102] Fix | Delete
* @return bool True on success, false on failure.
[103] Fix | Delete
*/
[104] Fix | Delete
public function delete_meta( $user_id, $meta_key, $meta_value = '' ) {
[105] Fix | Delete
return \delete_user_meta( $user_id, $meta_key, $meta_value );
[106] Fix | Delete
}
[107] Fix | Delete
}
[108] Fix | Delete
[109] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function