Skip to content

Instantly share code, notes, and snippets.

@galengidman
galengidman / search.php
Last active September 26, 2021 16:45
WordPress search form & results for custom post type
<?php
// check to see if there is a post type in the URL
if ( isset( $_GET['post_type'] ) && $_GET['post_type'] ) {
// save it for later
$post_type = $_GET['post_type'];
// check to see if a search template exists
if ( locate_template( 'search-' . $post_type . '.php' ) ) {
<?php
function var_dump_pre( $var ) {
$str = "<pre>$var</pre>";
echo $str;
}
@galengidman
galengidman / uicolors.less
Last active August 29, 2015 14:13
getuicolors.com LESS variables
@uico-plum: #913d88;
@uico-seance: #9a12b3;
@uico-medium-purple: #bf55ec;
@uico-light-wisteria: #be90d4;
@uico-studio: #8e44ad;
@uico-wisteria: #9b59b6;
@uico-new-york-pink: #e08283;
@uico-pomegranate: #f22613;
@uico-red: #ff0000;
@uico-sunglo: #e26a6a;
@galengidman
galengidman / mcd.less
Last active August 29, 2015 14:15
Material Design Color Varaibles
@mdc-red-50: #ffebee;
@mdc-red-100: #ffcdd2;
@mdc-red-200: #ef9a9a;
@mdc-red-300: #e57373;
@mdc-red-400: #ef5350;
@mdc-red-500: #f44336;
@mdc-red-600: #e53935;
@mdc-red-700: #d32f2f;
@mdc-red-800: #c62828;
@mdc-red-900: #b71c1c;
@galengidman
galengidman / .htaccess
Created March 27, 2015 20:27
http → https
# http to https
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
@galengidman
galengidman / functions.php
Created December 26, 2015 19:07
Convert wp_page_menu() to wp_nav_menu() markup
<?php
$html = wp_page_menu( array(
'echo' => false,
'depth' => 2
) );
$html = str_replace( ' page_item_has_children', ' menu-item-has-children', $html );
$html = str_replace( ' current_page_item', ' current-menu-item', $html );
$html = str_replace( ' page-item-', ' menu-item-', $html );
@galengidman
galengidman / youtube-id-from-url.php
Created January 23, 2017 22:31
Get a YouTube video ID from any format of YouTube URL.
<?php
function youtube_id_from_url( $url = null ) {
if ( ! $url || ( stripos( $url, 'youtube.com' ) === false && stripos( $url, 'youtu.be' ) === false ) ) {
return false;
}
$parsed_url = parse_url( $url );
<?php
function gg_asset_url( $path = '' ) {
return esc_url( get_template_directory_uri() . '/assets/' . $path );
}
function gg_asset_path( $path = '' ) {
return get_template_directory() . '/assets/' . $path;
}
@galengidman
galengidman / README.md
Last active June 22, 2017 17:50
Quick-and-dirty plugin that allows you to specify custom search results for specific search queries.

GG Custom Results

Quick-and-dirty plugin that allows you to specify custom search results for specific search queries.

Installation

Move gg-custom-results.php into either the /wp-content/plugins/ or /wp-content/mu-plugins/ directory. If you put it in plugins, you'll need to activate from Plugins menu in the WordPress admin. If you put in mu-plugins, it will be automatically active.

Configuration

You can define your custom search results in wp-config.php. Insert the following just above the line that reads /* That's all, stop editing! Happy blogging. */:

#!/bin/bash
set -e
repos=("repo-name" "another-repo")
for repo in ${repos[@]}; do
echo
echo "* Processing $repo..."
echo
git clone --bare git@bitbucket.org:ORG/$repo.git
cd $repo.git
echo