Skip to content

Instantly share code, notes, and snippets.

@elron
elron / gist:bd1726996731656c0056554f8c098dc4
Created October 19, 2024 14:20
Rebuild Netlify on WordPress Taxonomy Update
<?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/
*/
/*****
Code by: Elron
Initialy coded for: https://elrons.co.il/
Learn more about this code here: https://elrons.co.il/pagination/
*****/
nav.navigation.pagination {
div.nav-links {
text-align: center;
display: flex;
justify-content: center;
@elron
elron / contains.function.php
Created August 26, 2020 17:50
PHP function to check if a string contains a specific word(s)
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
<?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);