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 | |
// $start is option, but it will trim the HTML. Recommended to keep at 0 and use for start of strings only. | |
function substr_html( string $str, int $start = 0, int $end, array $replace_tags = array(), string $encoding = 'utf-8', bool $remove_body = true ){ | |
$max = strlen($str); | |
$out = $last_caret = ''; | |
for( $i = $characters = $gt = 0, $lt = -1; $characters < $end && $i < $max; $i++ ){ | |
$char = $str[$i]; | |
$entity = false; |
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
/*-----------------------------------*\ | |
Written with 💖 by @Xhynk | |
Donate: | |
https://xhynk.com/#donate | |
\*-----------------------------------*/ | |
// Example Google Sheets Timesheet: https://docs.google.com/spreadsheets/d/1D-YWjt_Zl8WrAuicmUKZsMzSpEOwv1vYL06dBdObyb4/ | |
function submitTimesheet(e){ |
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 | |
function get_stack_exchange_data( int $stack_exchange_id, bool $force_refresh = false, string $cache_dir = __DIR__ . '/stack-exchange' ){ | |
$max_age = 1800; | |
$api_url = sprintf( 'https://api.stackexchange.com/2.2/users/%d/associated', $stack_exchange_id ); | |
$cache_name = sprintf( '%s/%d.txt', $cache_dir, $stack_exchange_id ); | |
if( !is_dir($cache_dir) ) | |
mkdir( $cache_dir ); | |
if( !file_exists($cache_name) || (file_exists($cache_name) && filemtime($cache_name) < ( time() - $max_age )) ){ |
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 | |
// Start a Stripe Client for Live and Test | |
$stripe_live = new \Stripe\StripeClient( 'YOUR_LIVE_SECRET' ); | |
$stripe_test = new \Stripe\StripeClient( 'YOUR_TEST_SECRET' ); | |
// Fetch All Products | |
$live_products = $stripe_live->products->all(['limit' => 100]); | |
// Start an array to dump our results | |
$dump = array(); |
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
add_action( 'init', 'insert_content_masks' ); | |
function insert_content_masks(){ | |
$array_of_mask_urls = array( | |
'https://landing-page.com/page-1', | |
'https://landing-page.com/page-2', | |
'https://landing-page.com/page-3', | |
// … | |
'https://landing-page.com/page-xxx', | |
); |
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
04fba7cbe28b437ab8ff2a809eddb210e14a44be494d34ceeb2b1557d501c9405b4eb0869eb72a7428916e7a129072182ae097e07104321330f07e13fcae4b8815 |
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 | |
add_action( 'wp_head', 'trm_set_page_post_featured_image_as_header' ); | |
function trm_set_page_post_featured_image_as_header(){ | |
if( is_single() || is_page() ){ | |
if( has_post_thumbnail() ){ | |
$featured_image_url = get_the_post_thumbnail_url(); | |
echo '<!-- Feat. Img set in Appearance > Custom Functions --> | |
<style> | |
.front-page-header { |