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 | |
/* | |
Template Name: Redirect | |
*/ | |
if(! empty($url = get_post_meta(get_the_id(), 'redirect', true))){ | |
header("HTTP/1.1 301 Moved Permanently"); | |
header("Location: ". $url); | |
die(); | |
} | |
?> |
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
function ob_local_dev($buffer){ | |
$old = "http://example.com"; | |
$new = "http://dev.example.com"; | |
return str_replace($old, $new, $buffer); | |
} | |
ob_start("ob_local_dev"); |
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
function generateSlug($phrase, $maxLength=50){ | |
$result = strtolower($phrase); | |
$result = preg_replace("/[^a-z0-9]/", "-", $result); | |
$result = trim(preg_replace("/-+/", "-", $result)); | |
$result = trim(substr($result, 0, $maxLength)); | |
$result = preg_replace("/^-/", "", $result); | |
$result = preg_replace("/-$/", "", $result); | |
return $result; | |
} | |
// Pretty simple: keeps numbers and letters and makes everything else dashes. Removes multiple dashes in a row. |
NewerOlder