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
@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 / 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 / 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 / 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 / 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';
}
<?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 / wp-admin-bar-tweaks.php
Created August 9, 2013 23:34
wp-admin-bar-tweaks
Disable the WordPress Admin Bar for all Users and Visitors
Turn off the toolbar with one simple line.
view plain
/*
* Disable the WordPress Admin Bar for all Users and Visitors
*/
remove_action( 'init', '_wp_admin_bar_init' );
^ top
Enable the WordPress Admin Bar for admins only
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: T5 Silent Flush
* Description: Flushes rewrite rules whenever a custom post type or taxonomy is registered and not already part of these rules. This is a soft flush, the .htaccess will not be rewritten.
* Version: 2013.05.04
* Author: Thomas Scholz <info@toscho.de>
* Author URI: http://toscho.de
* License: MIT
* License URI: http://www.opensource.org/licenses/mit-license.php
*/
@Pushplaybang
Pushplaybang / wp-logout-redirect.php
Created July 1, 2013 11:34
WordPress Redirect to homepage after logout
<?php
/**
* @package Redirect to homepage after logout
* @version 0.1
*/
/*
Plugin Name: Redirect to homepage after logout
Plugin URI: http://daankortenbach.nl/wordpress/redirect-to-homepage-after-logout/
Description: Redirects the user to the homepage after logout
Author: Daan Kortenbach
@Pushplaybang
Pushplaybang / rgb_to_hex_to_rgb.php
Created April 22, 2013 06:35
php functions convert hex to rgb and rgb to hex
function hex2rgb($hex) {
$hex = str_replace("#", "", $hex);
if(strlen($hex) == 3) {
$r = hexdec(substr($hex,0,1).substr($hex,0,1));
$g = hexdec(substr($hex,1,1).substr($hex,1,1));
$b = hexdec(substr($hex,2,1).substr($hex,2,1));
} else {
$r = hexdec(substr($hex,0,2));
$g = hexdec(substr($hex,2,2));