: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Check if API is temporary down.
* @author Vova Feldman (@svovaf)
static function is_temporary_down() {
$test = self::$_cache->get_valid( 'ping_test', null );
return ( false === $test );
* @author Vova Feldman (@svovaf)
private function get_temporary_unavailable_error() {
'error' => (object) array(
'type' => 'TemporaryUnavailable',
'message' => 'API is temporary unavailable, please retry in ' . ( self::$_cache->get_record_expiration( 'ping_test' ) - WP_FS__SCRIPT_START_TIME ) . ' sec.',
'code' => 'temporary_unavailable',
* Check if based on the API result we should try
* to re-run the same request with HTTP instead of HTTPS.
* @author Vova Feldman (@svovaf)
private static function should_try_with_http( $result ) {
if ( ! Freemius_Api_WordPress::IsHttps() ) {
return ( ! is_object( $result ) ||
! isset( $result->error ) ||
! isset( $result->error->code ) ||
! in_array( $result->error->code, array(
'cloudflare_ddos_protection',
function get_url( $path = '' ) {
return Freemius_Api_WordPress::GetUrl( $path, $this->_api->IsSandbox() );
* @author Vova Feldman (@svovaf)
static function clear_cache() {
self::$_cache = FS_Cache_Manager::get_manager( WP_FS__API_CACHE_OPTION_NAME );
* @author Leo Fajardo (@leorw)
static function clear_force_http_flag() {
self::$_options->unset_option( 'api_force_http' );
#----------------------------------------------------------------------------------
#----------------------------------------------------------------------------------
* @author Vova Feldman (@svovaf)
* @return bool Is API result contains an error.
static function is_api_error( $result ) {
return ( is_object( $result ) && isset( $result->error ) ) ||
* @author Vova Feldman (@svovaf)
* @param bool $ignore_message
* @return bool Is API result contains an error.
static function is_api_error_object( $result, $ignore_message = false ) {
isset( $result->error ) &&
( $ignore_message || isset( $result->error->message ) )
* @author Leo Fajardo (@leorw)
* @param WP_Error|object|string $response
static function is_ssl_error_response( $response ) {
if ( $response instanceof WP_Error ) {
isset( $response->errors ) &&
isset( $response->errors['http_request_failed'] )
$http_error = strtolower( $response->errors['http_request_failed'][0] );
self::is_api_error_object( $response ) &&
! empty( $response->error->message )
$http_error = $response->error->message;
! empty( $http_error ) &&
false !== strpos( $http_error, 'curl error 35' ) ||
false === strpos( $http_error, '</html>' ) &&
false !== strpos( $http_error, 'ssl' )
* Checks if given API result is a non-empty and not an error object.
* @author Vova Feldman (@svovaf)
* @param string|null $required_property Optional property we want to verify that is set.
static function is_api_result_object( $result, $required_property = null ) {
! isset( $result->error ) &&
( empty( $required_property ) || isset( $result->{$required_property} ) )
* Checks if given API result is a non-empty entity object with non-empty ID.
* @author Vova Feldman (@svovaf)
static function is_api_result_entity( $result ) {
return self::is_api_result_object( $result, 'id' ) &&
FS_Entity::is_valid_id( $result->id );
* Get API result error code. If failed to get code, returns an empty string.
* @author Vova Feldman (@svovaf)
static function get_error_code( $result ) {
if ( is_object( $result ) &&
isset( $result->error ) &&
is_object( $result->error ) &&
! empty( $result->error->code )
return $result->error->code;