Skip to content

Instantly share code, notes, and snippets.

View chrispian's full-sized avatar

Chrispian chrispian

View GitHub Profile
@chrispian
chrispian / wp-metabox-oop-example.php
Created March 26, 2021 21:46
Create WordPress metaboxes OOP style
<?php
/**
* Plugin Name: CHB Meta Box test
* Plugin URI: http://www.chrispian.com
* Description: Just testing out OOP Meta Boxes.
* Version: 0.0.1
* Requires at least: 5.3
* Requires PHP: 7.2
* Author: Chrispian H. Burks
* Author URI: http://chrispian.com
@chrispian
chrispian / xdebug-laravel
Created March 25, 2021 00:54
xdebug php.ini settings for Laravel
# If using artisan tinker you need to pause the listener then start artisan and then restart the listener.
# When finished, you need to pause and restart as well.
#Set PhpStorm to listen on port 9090, and turn on the listener
[xdebug]
xdebug.remote_enable=1
xdebug.remote_port=9090
xdebug.idekey=PHPSTORM
xdebug.remote_host=localhost
xdebug.remote_autostart=on
@chrispian
chrispian / xdebug-local
Created March 25, 2021 00:53
xdebug config for php.ini in Local by Flywheel
[Xdebug]
# Make sure to point to the correct php version for this local.
zend_extension = /opt/php/7.2.0/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so
xdebug.remote_enable=1
xdebug.remote_connect_back=On
xdebug.remote_port=9090
xdebug.profiler_enable=0
xdebug.remote_host=localhost
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
@chrispian
chrispian / cloudSettings
Last active September 9, 2020 01:47
VS Code Settings
{"lastUpload":"2020-09-09T01:47:02.847Z","extensionVersion":"v3.4.3"}
@chrispian
chrispian / filter-search.php
Created November 8, 2019 00:14
Limit WP Search to certain post types
function filter_search($query) {
if ($query->is_search) {
$query->set('post_type', array('post', 'tribe_events', 'page'));
};
return $query;
};
add_filter('pre_get_posts', 'filter_search');
@chrispian
chrispian / fdns
Created September 27, 2019 19:12
Shell script to flush DNS on mac
#!/bin/sh
`dscacheutil -flushcache`
echo Done. DNS Restarted.
@chrispian
chrispian / woocommerce-filter-related-categories-by-taxonmy-term.php
Last active February 26, 2022 16:01
Only shows related products from the primary category set by Yoast
@chrispian
chrispian / yoast-primary-category-permalinks.php
Created September 23, 2019 17:24
Set Yoast PRIMARY category as the peralink
@chrispian
chrispian / semaphore.php
Created August 6, 2019 20:36
Semaphore example
//Semaphore properties
$key = 1111; // Key can be any unique number
$max = 1; // Max number of connections
$permissions = 0666; // default permissions
$autoRelease = 1; // To keep from a deadlock
// Begin Semaphore locking
$semaphore = sem_get( $key, $max, $permissions, $autoRelease );
if( !$semaphore ) {
// Probably best to log vs. error message. But should exit or return to prevent execution if we can't get the semaphore.
@chrispian
chrispian / index.js
Created August 3, 2019 00:31
Gatsby + WordPress TypeError: Cannot read property 'source_url' of null
import React from "react"
import { Link, graphql } from "gatsby"
import Img from "gatsby-image"
import Layout from "../components/layout"
import SEO from "../components/seo"
export default ({ data }) => {
return (
<Layout>
<SEO title="home" />