/**
* Base64 decoding that does not need to be urldecode()-ed.
*
* Exactly the same as PHP base64 encode except it uses
* `-` instead of `+`
* `_` instead of `/`
* No padded =
*
* @param string $input Base64UrlEncoded() string
*
* @return string
*/
protected static function Base64UrlDecode( $input ) {
/**
* IMPORTANT NOTE:
* This is a hack suggested by @otto42 and @greenshady from
* the theme's review team. The usage of base64 for API
* signature encoding was approved in a Slack meeting
* held on Tue (10/25 2016).
*
* @todo Remove this hack once the base64 error is removed from the Theme Check.
*
* @since 1.2.2
* @author Vova Feldman (@svovaf)
*/
$fn = 'base64' . '_decode';
return $fn( strtr( $input, '-_', '+/' ) );
}
/**
* Base64 encoding that does not need to be urlencode()ed.
*
* Exactly the same as base64 encode except it uses
* `-` instead of `+
* `_` instead of `/`
*
* @param string $input string
*
* @return string Base64 encoded string
*/
protected static function Base64UrlEncode( $input ) {
/**
* IMPORTANT NOTE:
* This is a hack suggested by @otto42 and @greenshady from
* the theme's review team. The usage of base64 for API
* signature encoding was approved in a Slack meeting
* held on Tue (10/25 2016).
*
* @todo Remove this hack once the base64 error is removed from the Theme Check.
*
* @since 1.2.2
* @author Vova Feldman (@svovaf)
*/
$fn = 'base64' . '_encode';
$str = strtr( $fn( $input ), '+/', '-_' );
$str = str_replace( '=', '', $str );
return $str;
}
}