Skip to content

Instantly share code, notes, and snippets.

View cklosowski's full-sized avatar

Chris Klosowski cklosowski

View GitHub Profile
@cklosowski
cklosowski / gist:4754835
Created February 11, 2013 14:50
Postmeta all the things!
<?php $meta_keys = get_post_meta( get_the_ID() ); ?>
<?php foreach( $meta_keys as $meta => $value ) : ?>
<?php if( ( '_' != $meta[0] ) && ( 'enclosure' != $meta ) ) : ?>
<span class="custom-meta"><strong><?php echo $meta; ?>:</strong> <?php echo $value[0]; ?></span>
<?php endif; ?>
<?php endforeach; ?>
@cklosowski
cklosowski / sublime_completion.php
Last active December 16, 2015 17:59
Tokenization file for PHP, just remove the functions: ck_generator_is_constant ck_generator_dump ck_generator_strip Generates both constants and functions. Put this somewhere in the web directory of your codebase (preferably 1 folder above the codebase) and provide the absolute path to the code as a query string parameter of 'path': (IE: http://…
<?php
$path = NULL;
if ( isset( $_GET['path'] ) ) {
$path = $_GET['path'];
}
// File types to search in
$extensions = array(
'php',
'inc',
@cklosowski
cklosowski / gist:5694193
Created June 2, 2013 17:15
Fix for Pinboard 1.0.8 JS errors
wp_register_script( 'jquery-migrate', get_template_directory_uri() . '/scripts/jquery-migrate.js', array( 'jquery' ), null );
@cklosowski
cklosowski / Preferences.sublime-settings
Created July 27, 2013 13:23
My Sublime Text 2 User Preferences File
// While you can edit this file, it's best to put your changes in
// "User/Preferences.sublime-settings", which overrides the settings in here.
//
// Settings may also be placed in file type specific options files, for
// example, in Packages/Python/Python.sublime-settings for python files.
{
// Sets the colors used within the text area
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
// Note that the font_face and font_size are overriden in the platform
@cklosowski
cklosowski / gist:8885994
Created February 8, 2014 16:09
Overview of error message improvements
<?php
// Example of adding an error to the edd_set_error
/**
* Checks whether a discount code is active.
*
* @since 1.0
* @param int $code_id
* @return bool
*/
function edd_is_discount_active( $code_id = null ) {
@cklosowski
cklosowski / gist:10011065
Created April 6, 2014 20:20
EDD - No Price on Free Download
<?php
add_filter( 'edd_purchase_link_defaults', 'ck_edd_edd_purchase_link_defaults', 10, 1 );
function ck_edd_edd_purchase_link_defaults( $args ) {
if ( edd_get_download_price( $args['download_id'] ) == '0.00' )
$args['price'] = false;
return $args;
}
@cklosowski
cklosowski / gist:10011096
Last active August 29, 2015 13:58
EDD - Remove Purchase Total
<?php
function ck_edd_hide_payment_icons() {
$cart_total = edd_get_cart_total();
if ( $cart_total )
return;
remove_action( 'edd_purchase_form_before_submit', 'edd_checkout_final_total', 999 );
// If you want to remove the payment options as well, you can uncomment these lines
@cklosowski
cklosowski / checkout_cart.php
Created April 18, 2014 05:14
EDD - Checkout Cart - If products are free, the price column states 'Complementary'. If the price of the cart is 0, it hides the cart total.
<?php global $post; ?>
<table id="edd_checkout_cart" <?php if ( edd_is_ajax_enabled() ) { echo 'class="ajaxed"'; } ?>>
<thead>
<tr class="edd_cart_header_row">
<?php do_action( 'edd_checkout_table_header_first' ); ?>
<th class="edd_cart_item_name"><?php _e( 'Item Name', 'edd' ); ?></th>
<th class="edd_cart_item_price"><?php _e( 'Item Price', 'edd' ); ?></th>
<th class="edd_cart_actions"><?php _e( 'Actions', 'edd' ); ?></th>
<?php do_action( 'edd_checkout_table_header_last' ); ?>
</tr>
@cklosowski
cklosowski / arrayToXMLExample.php
Last active January 5, 2017 22:09
Recursive Array to XML
<?php
$test_array = array (
'bla' => 'blub',
'another_array' => array('stack' => 'overflow'),
'foo' => 'bar',
'this' => array( 'this_item' => 'that' )
);
$xml = new SimpleXMLElement('<root/>');
foreach ( $test_array as $key => $value ) { // Itterate through the array and pass to our custom fucntion
<?php
/**
* Adds a 'Continue Shopping' button to the left of the Update and Save Cart Buttons on checkout
*/
add_action( 'edd_cart_footer_buttons', 'ck_edd_continue_shopping_button', 1 );
function ck_edd_continue_shopping_button() {
global $edd_options;
// Change the 'green' at the end to choose a different color that EDD supports
$color = isset( $edd_options[ 'checkout_color' ] ) ? $edd_options[ 'checkout_color' ] : 'green';