Skip to content
Snippets Groups Projects

WIP: Initial release

Merged Erick Hitter requested to merge develop into master
1 file
+ 26
1
Compare changes
  • Side-by-side
  • Inline
+ 26
1
@@ -12,6 +12,31 @@ namespace Camo_Image_Proxy;
@@ -12,6 +12,31 @@ namespace Camo_Image_Proxy;
*
*
* @return object
* @return object
*/
*/
function Options() {
function Options() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid, Generic.Functions.OpeningFunctionBraceKernighanRitchie.ContentAfterBrace
return Options::instance();
return Options::instance();
}
}
 
 
/**
 
* Can URLs be rewritten to use Camo?
 
*
 
* @return bool
 
*/
 
function can_rewrite() : bool {
 
$host = Options()->get( 'host' );
 
$key = Options()->get( 'key' );
 
 
$can_rewrite = true;
 
 
// Validate host.
 
if ( empty( $host ) || ( ! filter_var( $host, FILTER_VALIDATE_URL ) && ! filter_var( $host, FILTER_VALIDATE_IP ) ) ) {
 
$can_rewrite = false;
 
}
 
 
// Validate key.
 
// TODO: make sure it's an HMAC or something?
 
if ( empty( $key ) || ! is_string( $key ) ) {
 
$can_rewrite = false;
 
}
 
 
return apply_filters( 'camo_image_proxy_can_rewrite', $can_rewrite, $host, $key );
 
}
Loading