Skip to content

Instantly share code, notes, and snippets.

View jasperfrontend's full-sized avatar
🏠
WFH

Jasper jasperfrontend

🏠
WFH
View GitHub Profile
<?php
// My time shortcode [mytime timezone="Europe/Amsterdam" format="h:i A"]
// You can also edit the defaults on lines 7 & 8, then you can just use [mytime] to show your current time
add_shortcode( 'mytime', 'imw_my_time' );
function imw_my_time( $atts ) {
$atts = shortcode_atts( array(
'timezone' => 'Europe/Amsterdam',
'format' => 'h:i A'
), $atts, 'mytime' );
<?php
/*
Usage: [mytime]
Edit the timezone on line 8 to reflect your actual timezone.
Find your timezone: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones */
add_shortcode( 'mytime', 'ims_my_time' );
function ims_my_time( $atts ) {
$timezone = new DateTimeZone( 'Europe/Amsterdam' ); // edit this
$return = wp_date("h:i A", null, $timezone );
return $return;
/*
* Warzone single headshot fix
* This fix will apply to the latest and any previous versions of Warzone
* Simply read this fix and apply accordingly
*/
Stop playing the game.
@jasperfrontend
jasperfrontend / readme.md
Created April 30, 2020 13:02
Download an entire website with wget
wget \
     --recursive \
     --no-clobber \
     --page-requisites \
     --html-extension \
     --convert-links \
     --restrict-file-names=windows \
     --domains WEBSITE.nl \
 --no-parent \
@jasperfrontend
jasperfrontend / sanitize.php
Last active April 15, 2020 20:27
sanitize user input but it's overdone
<?php
// clean up job for domain search input
function sanitize_user_input( $string ) {
$string = str_replace('-', ' ', $string); // save the hyphen!
$sclean = preg_replace('/[^\p{L}\p{N}\s]/u', '', $string); // murder the rest
$hyphen = str_replace(' ', '-', $sclean); // bring back the hyphen!
$ltrim = ltrim($hyphen, '-'); // hyphen can never be first
$return = rtrim($ltrim, '-'); // hyphen can never be last
return strtolower($return);
}