Skip to content

Instantly share code, notes, and snippets.

View windyjonas's full-sized avatar
Changing the world, or getting coffee.

Jonas Nordström windyjonas

Changing the world, or getting coffee.
View GitHub Profile
@windyjonas
windyjonas / guest-shuffle.php
Created August 5, 2019 07:34
Shuffle the guest list
<?php
$names = [
'Jonas',
'Malin Degrenius',
'Myran',
'Sara Janmyr',
'Annika Sjölander',
'Jocke Sjölander',
'Erika Wildoer',
'Peter Wildoer',
@windyjonas
windyjonas / sanitize-filename.php
Created March 28, 2017 13:35
Sanitize decomposed filenames in WordPress
class Sanitize_Filename {
public function __construct() {
add_filter( 'wp_handle_upload_prefilter', [ $this, 'sanitize_decomposed_utf8_file' ] );
}
/**
* Sanitize the filename in a file object
*
* @param array $file In file
@windyjonas
windyjonas / jul.php
Created December 8, 2016 20:55
Generera julklappslista
<?php
$relations = array(
'malin' => array( 'jonas', 'jack' ),
'jonas' => array( 'malin', 'jack' ),
'anna' => array( 'mats', 'filippa' ),
'mats' => array( 'anna', 'filippa' ),
'filippa' => array( 'anna', 'mats' ),
'gussi' => array( 'stefan', 'emma' ),
'stefan' => array( 'gussi' ),
'emma' => array( 'gussi', 'ted' ),
@windyjonas
windyjonas / user-search-by-name.php
Created August 19, 2015 07:49
Full name search
/**
* Search users by first/last name in addition to the built-in nicename search
* @param string $wp_user_query User query
* @return string Modified user query
*/
function ws_user_search_by_name( $wp_user_query ) {
if ( false === strpos( $wp_user_query->query_where, '@' ) && ! empty( $_GET['s'] ) ) {
global $wpdb;
$uids = array();
@windyjonas
windyjonas / fix_page_lists_plus
Created February 9, 2015 12:40
Ta bort alla spår av page lists plus
CREATE TABLE `wp_posts_new` (
`ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`post_author` bigint(20) unsigned NOT NULL DEFAULT '0',
`post_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`post_date_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`post_content` longtext NOT NULL,
`post_title` text NOT NULL,
`post_excerpt` text NOT NULL,
`post_status` varchar(20) NOT NULL DEFAULT 'publish',
`comment_status` varchar(20) NOT NULL DEFAULT 'open',

Keybase proof

I hereby claim:

  • I am windyjonas on github.
  • I am windyjonas (https://keybase.io/windyjonas) on keybase.
  • I have a public key whose fingerprint is 5BF8 D812 4615 EA19 968F 1118 FE1A EA69 189F 5885

To claim this, I am signing this object:

@windyjonas
windyjonas / 0_reuse_code.js
Created May 20, 2014 13:29
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@windyjonas
windyjonas / wp.conf
Created September 12, 2013 22:07
nginx conf file included in all local WordPress dev sites.
fastcgi_intercept_errors on;
if ($http_user_agent ~* (HTTrack|HTMLParser|discobot|Exabot|Casper|kmccrew|plaNETWORK|RPT-HTTPClient)) {
return 444;
}
if ($http_referer ~* (sex|vigra|viagra) ) {
return 444;
}
###########################################
# Constants, set and forget
###########################################
# temp storage for the wordpress tarball
TMP_STORAGE=/home/USER/wptemp
# web root for the wordpress site
WWWROOT=/var/www
# Privileged db use/pwd for creating database and granting rights
@windyjonas
windyjonas / wordpress-escaping.md
Last active September 21, 2020 16:10
Most of the escaping functions in WordPress, with a short explanation and example.

WordPress escaping functions

By: Jonas Nordström, @windyjonas
Date: 2013-04-16

esc_attr( $text );
Encodes the <, >, &, " and ' (less than, greater than, ampersand, double quote and single quote) characters. Will never double encode entities.
Example: