Skip to content

Instantly share code, notes, and snippets.

@jeremysexton
Last active August 29, 2015 14:01
Show Gist options
  • Save jeremysexton/19bb23459fd2f914b6b0 to your computer and use it in GitHub Desktop.
Save jeremysexton/19bb23459fd2f914b6b0 to your computer and use it in GitHub Desktop.
Dummy Proof URLs for Statamic
<?php
class Modifier_urldummy extends Modifier {
public function index($value) {
if (strpos($value, 'http') !== false) {
$output = $value;
} else {
$output = 'http://'.$value;
}
return $output;
}
}
@curtisblackwell
Copy link

Just realized there's an unnecessary condition in this. You can drop the https check, because the http check would return true even if the protocol in the url was https.

You can also drop the $parameters argument since it's unused.

<?php

class Modifier_urldummy extends Modifier {

  public function index($value) {

    if (strpos($value, 'http') !== false) {
      $output = $value;
    } else {
      $output = 'http://'.$value;
    }

    return $output;

  }
}

@jeremysexton
Copy link
Author

Thanks! Updated it to get it all streamlined-like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment