Skip to content

Instantly share code, notes, and snippets.

View Pushplaybang's full-sized avatar
:octocat:
0_0

Paul Pushplaybang

:octocat:
0_0
View GitHub Profile
<?php $custom_terms = get_terms('mytaxonomyname');
foreach($custom_terms as $custom_term) {
wp_reset_query();
$args = array('post_type' => 'myposttypename',
'mytaxonomyname' => 'taxonomyitem', // might be unneccessary - test this
'tax_query' => array(
array(
'taxonomy' => 'mytaxonomyname',
'field' => 'slug',
@Pushplaybang
Pushplaybang / reusable_functions.js
Last active September 19, 2016 14:12
A collection of useful functions and snippets gathered from current and past projects, many of which I often re use.
// Utilities
//---------------------------
// check if a function already exists
function function_exists (func_name) {
if (typeof func_name === 'string') {
func_name = this.window[func_name];
}
return typeof func_name === 'function';
}
@Pushplaybang
Pushplaybang / show_admin_hooks.php
Last active December 28, 2015 23:59
list WordPress admin page hooks in the contextual help, super useful - thanks tutsplus.
add_action( 'contextual_help', 'wptuts_screen_help', 10, 3 );
function wptuts_screen_help( $contextual_help, $screen_id, $screen ) {
// The add_help_tab function for screen was introduced in WordPress 3.3.
if ( ! method_exists( $screen, 'add_help_tab' ) )
return $contextual_help;
global $hook_suffix;
// List screen properties
@Pushplaybang
Pushplaybang / strpos_array.php
Created November 24, 2013 12:07
cool little utility to strpos array
<?php
// Utility function - allow us to strpos an array
if ( !function_exists( 'audio_strpos_arr' ) ) {
function audio_strpos_arr($haystack, $needle) {
if( !is_array($needle) ) $needle = array($needle);
foreach( $needle as $what ) {
if( ($pos = strpos($haystack, $what) ) !==false ) return $pos;
}
@Pushplaybang
Pushplaybang / getcomposer-and-laravel
Last active December 29, 2015 16:29
run these in the terminal in the project folder to install composer and laravel
curl -sS getcomposer.org/installer | php -d detect_unicode=Off
composer create-project laravel/laravel THE_PROJ_DIRECOTRY_NAME_YOU_WANT --prefer-dist
or using the new phar, copy it into usr/local/bin
run :
$ chmod +x /usr/local/bin/laravel
@Pushplaybang
Pushplaybang / woo-remove-pretty-photo.php
Created January 29, 2014 14:23
#WordPress #WooCommerce - remove shitty pretty photo lightbox
//Remove prettyPhoto lightbox
add_action( 'wp_enqueue_scripts', 'fc_remove_woo_lightbox', 99 );
function fc_remove_woo_lightbox() {
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
wp_dequeue_style( 'woocommerce_prettyPhoto_css' );
wp_dequeue_script( 'prettyPhoto' );
wp_dequeue_script( 'prettyPhoto-init' );
}
//Add fancyBox lightbox - if thats what you want.
@Pushplaybang
Pushplaybang / woo-basic-total-and-cart-count.php
Created February 1, 2014 14:48
very basic cart count / url / total
global $woocommerce; ?>
<a class="cart-contents" href="<?php echo $woocommerce->cart->get_cart_url(); ?>" title="<?php _e('View your shopping cart', 'woothemes'); ?>"><?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count);?> - <?php echo $woocommerce->cart->get_cart_total(); ?></a>
<?php
/* Register custom post types on the 'init' hook. */
add_action( 'init', 'my_register_post_types' );
/**
* Registers post types needed by the plugin.
*
* @since 0.1.0
* @access public
// Go to menue:
// find->find in files
// Switch on reg_ex button
// Find:
^(.*)$
// alt
^.*\S+.*$
// Where:
c:\your_folder\,*.php,*.phtml,*.js,*.inc,*.html, -*/folder_to_exclude/*
// Node.js CheatSheet.
// Download the Node.js source code or a pre-built installer for your platform, and start developing today.
// Download: http://nodejs.org/download/
// More: http://nodejs.org/api/all.html
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html