Skip to content

Instantly share code, notes, and snippets.

@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.
*
*/

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
@raideus
raideus / wp-remove-admin-menus.php
Created May 22, 2012 22:54
Remove Unwanted Menu Items from the WordPress Dashboard
<?php
/* --------------------------------------------------------------------
Remove Unwanted Menu Items from the WordPress Dashboard
- Requires WordPress 3.1+
-------------------------------------------------------------------- */
function sb_remove_admin_menus (){
// Check that the built-in WordPress function remove_menu_page() exists in the current installation
if ( function_exists('remove_menu_page') ) {
@raideus
raideus / acf-wrapper-functions.php
Created September 3, 2012 19:29
Wrapper functions for Advanced Custom Fields
<?php
/**
* Return a custom field stored by the Advanced Custom Fields plugin
*
* @global $post
* @param str $key The key to look for
* @param mixed $id The post ID (int|str, defaults to $post->ID)
* @param mixed $default Value to return if get_field() returns nothing
* @return mixed
* @uses get_field()
@raideus
raideus / wp-admin-menu-reorder.php
Created July 16, 2012 13:33
Re-order WordPress Admin menu items
<?php
/**
* Re-orders tabs in the WordPress Admin menu. Include this in the functions.php file of your theme.
*/
function gs_custom_menu_order($menu_ord) {
if (!$menu_ord) return true;
return array(
'index.php',
<?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 );