Skip to content

Instantly share code, notes, and snippets.

Jonathan Bardo jonathanbardo

View GitHub Profile
@jonathanbardo
jonathanbardo / __return.php
Last active Dec 11, 2016
If WordPress required PHP >= 5.3
View __return.php
<?php
if ( ! function_exists( '__return' ) ) {
function __return( $return ) {
return function() use ( $return ) {
return $return;
@jonathanbardo
jonathanbardo / dnsmasq
Last active Jul 13, 2016
dnsmasq setup on mac os x 10.11
View dnsmasq
# using .domain to 127.0.0.1
echo 'address=/.domain/127.0.0.1' >> /usr/local/etc/dnsmasq.conf
# make sure the file name in /etc/resolver is the same as your domain
sudo bash -c 'echo "nameserver 127.0.0.1" > /etc/resolver/domain'
# restart dnsmasq
sudo brew services restart dnsmasq
@jonathanbardo
jonathanbardo / reverse-wpautop.php
Last active Dec 29, 2018
Opposite of wpautop
View reverse-wpautop.php
<?php
/**
* Do the opposite of wpautop
*
* @param string $s
*
* @return string
*/
public static function reverse_wpautop( $s ) {
@jonathanbardo
jonathanbardo / mac_xwindows_x11_xvfb_headless_firefox_howto.md
Created Mar 15, 2016 — forked from textarcana/mac_xwindows_x11_xvfb_headless_firefox_howto.md
Headless Selenium on CentOS 6.3 (Mac XWindows / X11 / Xvfb / Headless Firefox / Selenium howto)
View mac_xwindows_x11_xvfb_headless_firefox_howto.md

XWindows for Headless Selenium

X Wing art by Paul Harckham

How to set up a Headless Selenium Testing environment for CentOS 6.3.

On your CentOS 6.3 host

Follow these steps to set up a CentOS 6.3 host to run headless Selenium tests with Firefox.

@jonathanbardo
jonathanbardo / email.php
Last active Aug 29, 2015
Send email using WordPress
View email.php
function smtp_mail( $phpmailer ) {
// Define that we are sending with SMTP
$phpmailer->isSMTP();
// The hostname of the mail server
$phpmailer->Host = YOURHOST;
// Use SMTP authentication (true|false)
$phpmailer->SMTPAuth = true;
// SMTP port number normally 25
$phpmailer->Port = '25';
// Username to use for SMTP authentication
View beforePS1.sh
#!/usr/bin/env bash
function BEFORE_PS1 {
printf "\e[32m[\e[0m$(whoami)\e[32m]@[\e[0mlocal\e[32m][\e[0m${PWD/#$HOME/~}\e[32m]$(gitPS1)\e[0m"
}
View .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteRule ^(.*\.(png|gif|jpg|jpeg)) http://example.com/$1 [NC,P,L]
</IfModule>
View install_elasticpress.sh
# Download from wordpress.org repository into your plugins folder
# https://wordpress.org/plugins/elasticpress/
# Make sure you have wp-cli installed (otherwise it won't work) http://wp-cli.org/
# Add config line to wp-config.php:
# define( 'EP_HOST', 'http://127.0.0.1:9200' );
# In your docroot (WordPress root folder)
wp plugin activate elasticpress --network
View install_elasticsearch.sh
# Install on ubuntu trusty tahr 14.04
# I do this with root user, but if you sudo access with your user it will work too!
sudo su
# Update apt-get
apt-get update
# Install java jdk 7 or java jdk 8 or oracle jdk
apt-get install openjdk-7-jre-headless
# Make sure java is installed
java -version
# This should output: java version "1.7.XX"
@jonathanbardo
jonathanbardo / plugin_extends.php
Last active Feb 11, 2016
Override/Extends a plugin
View plugin_extends.php
<?php
/**
* Plugin Name: Extend a plugin
* Version: 0.0.1
* Author: Jonathan Bardo
* License: GPLv2+
* Author URI: http://jonathanbardo.com
*/
if ( ! class_exists( 'Date_Range_Filter' ) ) {
You can’t perform that action at this time.