Skip to content

Instantly share code, notes, and snippets.

@jessepearson
jessepearson / woocommerce-notices.scss
Last active August 29, 2015 14:06
WooCommerce Notice CSS Classes
.woocommerce-info {
border-top: 3px solid #5b95a4;
&:before {
background-color: #5b95a4;
}
}
.woocommerce-message {
border-top: 3px solid #6b9e56;
<?php
// func to sort the columns
add_action( 'pre_get_posts', 'floorplan_order_columns', 9999 );
function floorplan_order_columns( $query ) {
// if we're not in the admin, or if it isn't the custom post type, exit
if( ! is_admin() || $query->get( 'post_type' ) !== 'floorplan' )
return;
// get the orderby, if it is not set, leave it blank
<?php
switch( $orderby ) {
case 'fp_sf_tot':
$query->set( 'meta_key', 'fp_sf_tot' );
$query->set( 'orderby', 'meta_value_num' );
break;
case 'fp_pdf':
$query->set( 'meta_key', 'fp_pdf' );
$query->set( 'orderby', 'meta_value' );
@jessepearson
jessepearson / wordpress_widget_api_example_1.php
Last active August 29, 2015 14:13
Example from WordPress Codex for the Widget API
<?php
/**
* Register widget with WordPress.
*/
function __construct() {
parent::__construct(
'foo_widget', // Base ID
__( 'Widget Title', 'text_domain' ), // Name
array( 'description' => __( 'A Foo Widget', 'text_domain' ), ) // Args
);
@jessepearson
jessepearson / wordpress_widget_api_example_2.php
Created January 8, 2015 17:52
Example from WordPress Codex for the Widget API with CSS classes
<?php
/**
* Register widget with WordPress.
*/
function __construct() {
parent::__construct(
'foo_widget', // Base ID
__( 'Widget Title', 'text_domain' ), // Name
array(
'classname' => 'YOUR WIDGET CLASSES',
@jessepearson
jessepearson / line-177-widgets.js
Created January 13, 2015 00:46
Line 177 from wp-admin/js/widgets.js
$( document ).trigger( 'widget-added', [ $widget ] );
@jessepearson
jessepearson / admin-media-uploader-init.js
Created January 13, 2015 00:49
Using WordPress jQuery widget added callback
// if a widget is added, then initialize the media_uploader in that widget
$( document ).on( 'widget-added', function( event, target ) {
init_media_uploader( target );
} );
stdClass Object
(
[id] =>
[packed] => Array
(
[0] => WC_Boxpack_Item Object
(
[weight] => 7.00
[height] => 2.50
[width] => 12.00
stdClass Object
(
[id] =>
[packed] => Array
(
[0] => WC_Boxpack_Item Object
(
[weight] => 7.00
[height] => 2.50
[width] => 12.00
@jessepearson
jessepearson / jp_address_field_filter.php
Created November 4, 2015 19:07
Function to modify/change the label and placeholder for address fields in WooCommerce
<?php
/**
* Removes "Town" from label/placeholder in checkout forms
*/
function jp_address_field_filter( $fields ) {
// fields we want to look for
$search = array(
'billing_city',
'shipping_city',