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 | |
/** | |
* Plugin Name: Rebuild Netlify on Poem or Tag Update | |
* Description: Triggers Netlify build hook when a "poem" post or "tag" taxonomy is updated. | |
* Version: 1.0 | |
* Author: Elron Bucai & ChatGPT | |
* Author URI: https://www.elrons.co.il/ | |
*/ |
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 contains($str, array $arr) { | |
// Works in Hebrew and any other unicode characters | |
// Thanks https://medium.com/@shiba1014/regex-word-boundaries-with-unicode-207794f6e7ed | |
// Thanks https://www.phpliveregex.com/ | |
if (preg_match('/(?<=[\s,.:;"\']|^)' . $word . '(?=[\s,.:;"\']|$)/', $str)) return true; | |
} | |
// Works in English | |
contains('hello how are you', ['are']); // true |
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 | |
/** | |
* Wrap last word with span | |
* @author: Elron | |
* https://stackoverflow.com/questions/18612872/get-the-last-word-of-a-string | |
*/ | |
function wrap_last_word($string) { | |
// Breaks string to pieces | |
$pieces = explode(" ", $string); |