Skip to content

Instantly share code, notes, and snippets.

View roborourke's full-sized avatar
🤠

Robert O'Rourke roborourke

🤠
View GitHub Profile
{
"type": "object",
"properties": {
"audience": {
"type": "object",
"properties": {
"include": {
"type": "string",
"enum": [
"any",
@roborourke
roborourke / ep-prefix-search.php
Created June 30, 2020 09:30
ElasticPress query using prefix match
<?php
/**
* Wrapper for WP_Query that performs a prefix search.
*
* @param string $url The URL string to search for.
* @param array $args Args to pass to WP_Query
* @return WP_Query
*/
function ep_url_prefix_search( string $url, array $args = [] ) : WP_Query {
@roborourke
roborourke / wp-packagist-stats.php
Last active February 20, 2020 11:06
Get stats from packagist for all WP related packages
#!/usr/bin/env php
<?php
$plugins = file_get_contents( 'https://packagist.org/packages/list.json?type=wordpress-plugin' );
$muplugins = file_get_contents( 'https://packagist.org/packages/list.json?type=wordpress-muplugin' );
$dropins = file_get_contents( 'https://packagist.org/packages/list.json?type=wordpress-dropin' );
$themes = file_get_contents( 'https://packagist.org/packages/list.json?type=wordpress-theme' );
$plugins_json = json_decode( $plugins, true )['packageNames'];
$muplugins_json = json_decode( $muplugins, true )['packageNames'];
@roborourke
roborourke / wp-react-dev.php
Last active May 17, 2020 13:50
Get the development version of react in WordPress without needing a dev version of WP
<?php
/**
* Enable dev mode vendor packages.
*/
if ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ) {
return;
}
add_action( 'init', function () {
@roborourke
roborourke / gutenberg-frontend-columns.php
Last active June 5, 2018 09:50
Fixes markup for <InnerBlocks.Content/> output
<?php
add_filter( 'the_content', function ( $content ) {
// Fix layouts HTML.
libxml_use_internal_errors( true );
$dom = new \DOMDocument( '1.0', 'UTF-8' );
$dom->loadHTML( utf8_decode( $content ) );
$xpath = new \DOMXPath( $dom );
@roborourke
roborourke / nf-gtm.js
Last active October 24, 2020 23:16
Ninja Forms Google Tag Manager Trigger
<script>
jQuery( document ).on( 'nfFormReady', function() {
nfRadio.channel('forms').on('submit:response', function(form) {
window.dataLayer = window.dataLayer||[];
dataLayer.push({
event: 'ninjaFormSubmission',
eventData: form.data,
formID: form.data.form_id,
formTitle: form.data.settings.title
})
@roborourke
roborourke / .kbaliases
Created May 17, 2016 13:36
Keybase aliases
### Keybase ###
function pb() {
echo "$@" | pbcopy
}
# Usage: kbm 'message' <usernames...>
alias kbm='pb keybase encrypt -m'
@roborourke
roborourke / ms-remove-permalink-blog-slug.php
Created May 12, 2015 14:09
Remove /blog slug from permalinks on WordPress multisite
@roborourke
roborourke / keybase.md
Last active July 20, 2016 19:35
Keybase verification

Keybase proof

I hereby claim:

  • I am roborourke on github.
  • I am robo (https://keybase.io/robo) on keybase.
  • I have a public key whose fingerprint is 779C 084C 30CA 91E6 4B0C 9242 ED5B EDB9 0BBA 458F

To claim this, I am signing this object:

@roborourke
roborourke / wp-sslverify-hack.php
Created April 11, 2015 11:36
Hack to work with external APIs that require ssl verification on a local install of WordPress
<?php
// include the following in your wp-config.php or any file that is run before WP is loaded
global $wp_filter;
function hm_kill_sslverify( $args, $url ) {
$args['sslverify'] = false;