Skip to content

Instantly share code, notes, and snippets.

Phil Banks emirpprime

Block or report user

Report or block emirpprime

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
emirpprime /
Created Nov 28, 2019
Git merge conflict test generator
# No conflict, changes in branch time order.
mkdir merge-conflict1
cd merge-conflict1
git init
git add
echo $'Start\nOne\n\n\n\nTwo\n\n\n\nThree\n\n\n\nFour\n\n\n\nEnd' >
git commit -am 'initial commit on master'
emirpprime / social.php
Created Aug 2, 2019
Basic social OG tag generation for WordPress
View social.php
* Plugin Name: Social Test
* TODO: Output <meta name="twitter:site" content="@username" />? Needs custom option to read from.
* TODO: Custom option for social fallback image instead of core image?
* Adding the Open Graph schema definitions in the Language Attributes.
emirpprime /
Last active Dec 12, 2018
Sledgehammer removal of valet(+)
#!/usr/bin/env bash
valet stop
composer global remove laravel/valet
composer global remove weprovide/valet-plus
brew services stop --all
brew uninstall dnsmasq
sudo rm -rf /usr/local/etc/dnsmasq.conf
sudo rm -rf /usr/local/Cellar/dnsmasq
emirpprime / remove_post_type_breadcrumb.php
Created May 17, 2018
Remove post type from Breadcrumb NavXT breadcrumbs when viewing Tag archives.
View remove_post_type_breadcrumb.php
* Filter breadcrumbs to remove post archive when viewing Tag archives.
add_action( 'bcn_after_fill', function( $bcn_breadcrumb_trail ){
// Bail early if not a tag archive.
if ( ! is_tag() ) {
return $bcn_breadcrumb_trail;
emirpprime / exclude_posts_with_meta.php
Created Jan 31, 2018
Exclude posts with a custom meta value from search
View exclude_posts_with_meta.php
* Exclude posts with 'fruit' custom meta field value of 'bananas' from site Search
function cc_search_filter( $query ) {
if ( ! is_admin() && $query->is_main_query() ) {
if ( $query->is_search ) {
$query->set( 'meta_query',
'relation' => 'OR',
emirpprime / exclude_posts_with_term.php
Last active Jan 31, 2018
Exclude posts with a term in a taxonomy from search
View exclude_posts_with_term.php
* Exclude posts with term 'bananas' from Search.
function cc_search_filter( $query ) {
if ( ! is_admin() && $query->is_main_query() ) {
if ( $query->is_search ) {
emirpprime / products_with_category.sql
Last active Jan 24, 2020
Select Product name, SKU, price and category from WordPress / WooCommerce with MySQL query
View products_with_category.sql
wp_posts.post_title AS Product,
wp_postmeta1.meta_value AS SKU,
wp_postmeta2.meta_value AS Price,
FROM wp_posts
LEFT JOIN wp_postmeta wp_postmeta1
ON wp_postmeta1.post_id = wp_posts.ID
AND wp_postmeta1.meta_key = '_sku'
LEFT JOIN wp_postmeta wp_postmeta2
emirpprime / update_htaccess.php
Last active Jul 26, 2017
Example snippet showing how to update the WordPress .htaccess file programatically
View update_htaccess.php
* Update .htaccess to whitelist logo when modified in platform settings.
function cc_logo_htaccess() {
// Fire only on Platform Settings options page.
$screen = get_current_screen();
if ( 'cc-configurator_page_cc-settings' === $screen->id && ( $_POST['acf']['field_576c2a5137029'] || $_POST['acf']['field_576c2a9e3702a'] ) ) {
// Store files in an array.
emirpprime /
Created Jul 26, 2017
Bash script to help manage .htpasswd files
# Manage .htpasswd files
# Store script name for use in output.
me=$( basename $0 )
# Utility function for exiting.
#!/bin/bash -e
# Description:
# This will deploy WordPress in the current directory.
# Without modification it:
# - will configure basic security:
# - remove initial user created
# - deploy 6G firewall in .htaccess
# - attempt to prevent user enumeration in .htaccess
# - protect sensitive files and disallow executables in /wp-uploads
You can’t perform that action at this time.