Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/wordpres.../src/introduc.../infrastr...
File: wistia-embed-permission-repository.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Introductions\Infrastructure;
[2] Fix | Delete
[3] Fix | Delete
use Exception;
[4] Fix | Delete
use Yoast\WP\SEO\Helpers\User_Helper;
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Takes care of the get/set in the WP user meta.
[8] Fix | Delete
*
[9] Fix | Delete
* @makePublic
[10] Fix | Delete
*/
[11] Fix | Delete
class Wistia_Embed_Permission_Repository {
[12] Fix | Delete
[13] Fix | Delete
public const USER_META_KEY = '_yoast_wpseo_wistia_embed_permission';
[14] Fix | Delete
[15] Fix | Delete
public const DEFAULT_VALUE = false;
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* Holds the User_Helper instance.
[19] Fix | Delete
*
[20] Fix | Delete
* @var User_Helper
[21] Fix | Delete
*/
[22] Fix | Delete
private $user_helper;
[23] Fix | Delete
[24] Fix | Delete
/**
[25] Fix | Delete
* Constructs the class.
[26] Fix | Delete
*
[27] Fix | Delete
* @param User_Helper $user_helper The User_Helper.
[28] Fix | Delete
*/
[29] Fix | Delete
public function __construct( User_Helper $user_helper ) {
[30] Fix | Delete
$this->user_helper = $user_helper;
[31] Fix | Delete
}
[32] Fix | Delete
[33] Fix | Delete
/**
[34] Fix | Delete
* Retrieves the current value for a user.
[35] Fix | Delete
*
[36] Fix | Delete
* @param int $user_id User ID.
[37] Fix | Delete
*
[38] Fix | Delete
* @return bool The current value.
[39] Fix | Delete
*
[40] Fix | Delete
* @throws Exception If an invalid user ID is supplied.
[41] Fix | Delete
*/
[42] Fix | Delete
public function get_value_for_user( $user_id ) {
[43] Fix | Delete
$value = $this->user_helper->get_meta( $user_id, self::USER_META_KEY, true );
[44] Fix | Delete
if ( $value === false ) {
[45] Fix | Delete
throw new Exception( 'Invalid User ID' );
[46] Fix | Delete
}
[47] Fix | Delete
[48] Fix | Delete
if ( $value === '0' || $value === '1' ) {
[49] Fix | Delete
// The value is stored as a string because otherwise we can not see the difference between false and an invalid user ID.
[50] Fix | Delete
return $value === '1';
[51] Fix | Delete
}
[52] Fix | Delete
[53] Fix | Delete
/**
[54] Fix | Delete
* Why could $value be invalid?
[55] Fix | Delete
* - When the database row does not exist yet, $value can be an empty string.
[56] Fix | Delete
* - Faulty data was stored?
[57] Fix | Delete
*/
[58] Fix | Delete
return self::DEFAULT_VALUE;
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
/**
[62] Fix | Delete
* Sets the Wistia embed permission value for the current user.
[63] Fix | Delete
*
[64] Fix | Delete
* @param int $user_id The user ID.
[65] Fix | Delete
* @param bool $value The value.
[66] Fix | Delete
*
[67] Fix | Delete
* @return bool Whether the update was successful.
[68] Fix | Delete
*
[69] Fix | Delete
* @throws Exception If an invalid user ID is supplied.
[70] Fix | Delete
*/
[71] Fix | Delete
public function set_value_for_user( $user_id, $value ) {
[72] Fix | Delete
// The value is stored as a string because otherwise we can not see the difference between false and an invalid user ID.
[73] Fix | Delete
$value_as_string = ( $value === true ) ? '1' : '0';
[74] Fix | Delete
[75] Fix | Delete
// Checking for only false, not interested in not having to update.
[76] Fix | Delete
return $this->user_helper->update_meta( $user_id, self::USER_META_KEY, $value_as_string ) !== false;
[77] Fix | Delete
}
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function