Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am raideus on github.
  • I am raideus (https://keybase.io/raideus) on keybase.
  • I have a public key ASC2JzNRy56Iy5oA78fOYFdtBGxDtNbBZ3p3h3rrHhNnDAo

To claim this, I am signing this object:

Verifying my Blockstack ID is secured with the address 1BfsoDFqqraqgVYEBc3AMnmFJSbN2ZTJhM https://explorer.blockstack.org/address/1BfsoDFqqraqgVYEBc3AMnmFJSbN2ZTJhM
<?php
$args = array();
$args['wp_query'] = array( 'post_type' => array('page', 'field', 'param'),
'orderby' => 'title',
'order' => 'ASC' );
$args['fields'][] = array( 'type' => 'search',
'placeholder' => 'Enter search terms' );
$args['fields'][] = array( 'type' => 'post_type',
'format' => 'checkbox',
'label' => 'Search by post type',
@raideus
raideus / git-branch-in-prompt.sh
Last active August 29, 2015 14:03
Add current git branch to command prompt
# Add to bashrc file
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
PS1='[\u@\h \w\[\033[32m\]$(parse_git_branch)\[\033[00m\] \t] $' # Edit formatting to your liking
<?php
$args = array(
'orderby' => 'name',
'hide_emppty' => 1,
'hierarchical' => false,
'taxonomy' => 'gs_topics'
);
$topics = get_terms($args);
foreach ($topics as $topic) :
@raideus
raideus / selected-criteria.js
Last active December 27, 2015 00:29
Corresponding JS for gs_selected_criteria(). Allows the user to de-select current terms.
$('.selected-term').click(function() {
var rel = $(this).attr('rel');
$('input[value="'+rel+'"]').attr('checked',false);
$(this).remove();
$('#wp-advanced-search').submit();
});
@raideus
raideus / gs_selected_criteria.php
Created October 30, 2013 19:12
Function which generates a list of links corresponding to each selected term in a search query. Requires WP Advanced Search.
<?php
function gs_selected_criteria() {
$terms = array();
$search = new WP_Advanced_Search();
$taxonomies = $search->selected_taxonomies;
if ($taxonomies) {
$output = '<div class="selected-terms">SELECTED CRITERIA</div>';
foreach ($taxonomies as $taxonomy => $terms) {
@raideus
raideus / wp-anti-cache.php
Created May 16, 2013 15:15
Anti-caching tactic for stylesheets and scripts
<?php
function gs_scripts_styles() {
$version = '1';
if (defined('WP_DEBUG') && WP_DEBUG) $version = date('his');
elseif (defined('ENV_STAGING') && ENV_STAGING) $version = date('his');
wp_enqueue_style( 'gs-theme-styles', get_template_directory_uri() . '/style.css', array('gs-grid-styles'), $version, 'all' );
wp_enqueue_script( 'gs-scripts', get_template_directory_uri() . '/js/scripts.js', array( 'modernizr', 'jquery' ), $version, true );
<?php
/**
* Returns an array of dates in which content has been published
*
* @param string $date_type 'day', 'month', or 'year'
* @param string $format PHP date format string
* @param string $post_type Post type to get dates for
* @return array Array of dates in which content has been published
*/
@raideus
raideus / acf-auto-export.php
Created March 7, 2013 06:00
This collection of functions completely automates the "Export to PHP" feature of Advanced Custom Fields. No more manual copy + pasting! Simply specify an absolute file path (line 17) and the code will automatically write the ACF data to the file. The export is initiated whenever you publish a new field group or save changes to an existing field …
<?php
/**
* Automated PHP export for Advanced Custom Fields
*
* Export is initiated whenever an admin publishes a new field group
* or saves changes to an existing field group.
*
* Place this code in your theme's functions.php file.
*
*/