Last active
August 29, 2015 14:01
-
-
Save jeremysexton/19bb23459fd2f914b6b0 to your computer and use it in GitHub Desktop.
Dummy Proof URLs for Statamic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Modifier_urldummy extends Modifier { | |
public function index($value) { | |
if (strpos($value, 'http') !== false) { | |
$output = $value; | |
} else { | |
$output = 'http://'.$value; | |
} | |
return $output; | |
} | |
} |
curtisblackwell
commented
Jun 6, 2014
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;
}
}
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