Skip to content

Instantly share code, notes, and snippets.

View GaryJones's full-sized avatar

Gary Jones GaryJones

View GitHub Profile
<?php
// Fuzzy search
add_filter( 'jetpack_search_es_query_args', 'es_fuzzy_search', 10, 2);
function es_fuzzy_search( $es_query_args, $query ) {
$query = get_search_query();
$es_query_args['query']['function_score']['query']['bool'] = array(
'must' => array(
array(
'multi_match' => array(
@Rarst
Rarst / getpatch.cmd
Last active September 20, 2023 14:00
Download a patch file from a GitHub branch. Arguments: repo name, branch name (e.g. `getpatch Rarst/wp-date trac-38771`).
curl https://github.com/%1/compare/master...%2.diff > patches/%2.diff
@mathiasverraes
mathiasverraes / rollyourown.php
Created May 30, 2018 14:17
We don't need no DIC libs / we don't need no deps control
<?php
// Context: I'm trying to argue that DI (and DIC) are great, and DIC libs suck.
// Happy to be proven wrong!
final class Router {
private $dependencies;
public function __construct (Dependencies $dependencies) {
$this->dependencies = $dependencies;
// You might say that this is Service Locator, but it's not. This router is toplevel,
// and toplevel must have access to dependencies. After that it can all just bubble nicely using proper DI.
@robincornett
robincornett / update.txt
Last active May 31, 2018 14:45
Updated responsive, mobile first, accessible, navigation menus for Genesis child themes. Uses SVG icons, and submenu toggle buttons on all screens. Submenus open on click/keypress/hover, but can be bypassed. Do not include Genesis support for accessible menus. Accommodations for no-JS users.
now located at: https://github.com/robincornett/leaven-responsive-menu
@keesiemeijer
keesiemeijer / setup-phpunit.sh
Last active December 8, 2023 11:02
Setup PHPUnit for use in the Local by Flywheel app
#!/usr/bin/env bash
# ===============================================================================
# Script to install PHPUnit in the Local by Flywheel Mac app
# These packages are installed
#
# PHPUnit, curl wget, rsync, git, subversion and composer.
#
# WordPress is installed in the `/tmp/wordpress` directory for use by PHPUnit.
# The WordPress test suite is installed in the `/tmp/wordpress-tests-lib` directory.
@gilzow
gilzow / put-inside-functions.php
Created January 5, 2017 17:03
Removes user endpoints from WordPress REST API
<?php
/**
* Remove user list endpoint from rest api
*/
add_filter('rest_endpoints', function($aryEndpoints){
if(isset($aryEndpoints['/wp/v2/users'])){
unset($aryEndpoints['/wp/v2/users']);
}
if(isset($aryEndpoints['/wp/v2/users/(?P<id>[\d]+)'])){
unset($aryEndpoints['/wp/v2/users/(?P<id>[\d]+)']);
@danmaby
danmaby / .htaccess
Last active February 16, 2018 15:17
Site Security All Sites
#
<IfModule mod_headers.c>
# HSTS - force redirect to HTTPS at the browser level.
# Submit for Chrome preload list at https://hstspreload.appspot.com/
Header set Strict-Transport-Security: "max-age=31536000; includeSubDomains; preload"
# X-Xss-Protection
Header always set X-Xss-Protection "1; mode=block"
# Stop clickjacking by only allowing us to frame our own site
@GaryJones
GaryJones / phpbrew-notes.md
Last active September 28, 2018 14:13
phpbrew - my config

These are my instructions for compiling a new version of PHP via Phpbrew on Mac High Sierra, with the latest versions of cURL and OpenSSL that Composer seems to need.

Homebrew config

/usr/local/bin must come before /usr/bin in the PATH when using Homebrew.

export PATH=/usr/local/bin:$PATH
@jjeaton
jjeaton / .gitignore
Created August 5, 2015 01:54
WordPress root .gitignore. Ignore everything and then opt-in (exclude from the ignore) for your custom code.
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your
@GaryJones
GaryJones / gist:56938d30bb86cd1c078a
Last active March 18, 2018 14:02
Config Files list

Config Files

Development-related files that might be found in version-controlled projects. Doesn't include editor-specific files.

Files

  • .editorconfig - EditorConfig define and maintain consistent coding styles between different editors and IDEs.
  • .gitignore - ignore files from version control. Note, don't add system files - contributors should be globally ignoring these on their local machines. Only use for files created during project build, credentials files etc.