Skip to content

Instantly share code, notes, and snippets.

@birgire
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save birgire/789a2964f4ccfe832b58 to your computer and use it in GitHub Desktop.
Save birgire/789a2964f4ccfe832b58 to your computer and use it in GitHub Desktop.
WooCommerce Product Attributes - Dump them in a metabox for debugging
<?php
/**
* Plugin Name: Product Attributes - Debug
* Description: Dump the product attributes in a metabox.
* Author: birgire
* Author URI: Https://github.com/birgire
* Version: 0.0.1
*/
// PHP 5.3.3+
/**
* Metabox to display debug info on product attributes
*/
add_action( 'add_meta_boxes',
function(){
add_meta_box(
'birgire_debug',
'Product Attributes - Debug',
'birgire_meta_box_callback',
'product'
);
}
);
/**
* Metabox callback
*/
function birgire_meta_box_callback( $post )
{
$product_attributes = (array) get_post_meta( $post->ID, '_product_attributes' );
printf( '<pre>%s</pre>',
print_r( $product_attributes, 1 )
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment