PHP Snippet: Slugify a string

This one has some extra stuff for German characters in it. Probably not needed because it’s covered by iconv, but whatever:

function slugify($str)
{
       $returnMe = strtotime(trim(@iconv('UTF-8', 'ASCII//TRANSLIT', $str)));

       foreach ([
              " " => "_",
              "/" => "-",
              "" => "",
              "." => "-",
              "ü" => "ue",
              "ö" => "oe",
              "ä" => "ae",
              "ß" => "ss",
              "&" => "+",
              '"' => "_"
       ] as $search => $replace)
       {
              $returnMe = str_replace($search, $replace, $returnMe);
       }

       return $returnMe;
    }

PHP Snippet: Check if code is running on a production environment

function isLive($liveTld = ".de")
{
       $homeUrl = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']
       === 'on' ? "https" : "http")."://$_SERVER[HTTP_HOST]";

$returnMe = false;
if ( (!(strpos($homeUrl, ".local") !== false)) && (!(strpos($homeUrl, ".intra") !== false)) && (!(strpos($homeUrl, "stage") !== false)) && (!(strpos($homeUrl, "staging") !== false)) && (strpos($homeUrl, $liveTld) !== false) ) { $returnMe = true; }
return $returnMe; }

The WordPress Gutenberg Editor

The new Gutenberg Editor, due for the WordPress release 5.0, will hugely up the game for content editing and control over content layout, visuals and constrolled visual design options. Look forward to it.

Here are some links:

Yii Framework

Yii is one of the lesser known PHP Frameworks, but it has been around for quite some time and is notably popular with professional developers who hate faffing about when building web applications. It’s a sort-of secret tip and go-to toolkit for those who hate the shoddy and sub-par data- and application models of WordPress, Drupal and the likes. It is also the foundation of the professional Craft CMS. Yii Framework weiterlesen