Skip to content

Instantly share code, notes, and snippets.

View nilsringersma's full-sized avatar

Nils Ringersma nilsringersma

View GitHub Profile
@nilsringersma
nilsringersma / my.cnf
Created July 30, 2020 08:43 — forked from fevangelou/my.cnf
Optimized my.cnf configuration for MySQL/MariaSQL (on Ubuntu, CentOS etc. servers)
# Optimized my.cnf configuration for MySQL/MariaSQL
#
# by Fotis Evangelou, developer of Engintron (engintron.com)
#
# ~ Updated January 2020 ~
#
#
# The settings provided below are a starting point for a 2GB - 4GB RAM server with 2-4 CPU cores.
# If you have different resources available you should adjust accordingly to save CPU, RAM & disk I/O usage.
#
@nilsringersma
nilsringersma / wp-query-ref.php
Created February 19, 2019 13:16 — forked from luetkemj/wp-query-ref.php
WP: Query $args
// This gist is now maintained on github at https://github.com/luetkemj/wp-query-ref
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.github.io
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/4.9.4/src/wp-includes/query.php
*/
function custom_query_shortcode($atts) {
// EXAMPLE USAGE:
// [loop the_query="showposts=100&post_type=page&post_parent=453"]
// Defaults
extract(shortcode_atts(array(
"the_query" => ''
), $atts));
@nilsringersma
nilsringersma / vcl-regex-cheat-sheet
Created February 5, 2019 13:11 — forked from dimsemenov/vcl-regex-cheat-sheet
Regular expression cheat sheet for Varnish (.vcl). Examples of vcl regexp. Found here http://kly.no/varnish/regex.txt (by Kristian Lyngstøl)
Regular expression cheat sheet for Varnish
Varnish regular expressions are NOT case sensitive. Varnish uses POSIX
regular expressions, for a complete guide, see: "man 7 regex"
Basic matching:
req.url ~ "searchterm"
True if req.url contains "searchterm" anywhere.
req.url == "searchterm"
@nilsringersma
nilsringersma / NF_multi_part_change_listener.js
Last active January 26, 2023 13:35
Listen for Ninja Forms multi part change jquery
jQuery(document).ready(function($){
// Execute after NF is loaded.
$(document).on( 'nfFormReady', function( e, layoutView ) {
nfRadio.channel( 'nfMP' ).on( 'change:part', function($) {
console.log('Part Change');
});
@nilsringersma
nilsringersma / ajax-handler.php
Created December 6, 2018 12:08 — forked from Jayfrown/ajax-handler.php
WordPress mu-plugin to filter active plugins for AJAX calls
<?php
/**
* ajax-handler.php
*
* This mu-plugin is loaded before any other plugin code.
* It attempts to recognize some API-ish calls (i.e.
* traditional admin-ajax.php, wc-ajax and hopefully some
* wp-json/wp-api things at a later stadium.
*
<?php
/**
* The Template for displaying all single posts.
*
*/
get_header(); ?>
<div id="main">
public function ijsje_single_template($single) {
global $post;
/* Checks for single template by post type */
if ( $post->post_type == 'ijsjes' ) {
if ( file_exists( plugin_dir_path( __FILE__ ) . 'partials/single-ijsje.php' ) ) {
return plugin_dir_path( __FILE__ ) . 'partials/single-ijsje.php';
}
}
private function define_public_hooks() {
$plugin_public = new Ijsjes_Public( $this->get_plugin_name(), $this->get_version() );
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
$this->loader->add_filter( 'single_template', $plugin_public, 'ijsje_single_template' );
}
private function define_admin_hooks() {
$plugin_admin = new Ijsjes_Admin( $this->get_plugin_name(), $this->get_version() );
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
$this->loader->add_action( 'init', $plugin_admin, 'register_ijsjes_post_type' );
}