Skip to content

Instantly share code, notes, and snippets.

@solepixel
solepixel / notices.php
Last active December 25, 2015 15:49
Sample Usage of cgc_notices
<?php
function handle_notices(){
$updated = isset( $_GET['whatever-updated'] ) ? $_GET['whatever-updated'] : false;
if( $updated !== false ){
$type = $updated ? 'success' : 'error';
$message = $updated ? __( 'Your whatever was updated.', 'cgc' ) : __( 'There was a problem updating whatever.', 'cgc' );
cgc_add_notice( $message, $type );
}
}
add_action( 'cgc_notices', 'handle_notices' );
<?php
if( function_exists('cgc_ub_show_user_badges') ) {
$member = cgc_get_user_data();
cgc_ub_show_user_badges( $member->ID );
}
@solepixel
solepixel / dynamic-pricing-table.php
Last active April 20, 2018 19:11
dynamic pricing table
<?php
function display_dynamic_pricing_table(){
global $post;
# see line 42 of woocommerce_pricing_by_product.class.php
$pricing_rule_sets = get_option('_a_category_pricing_rules', array());
$found = false;
if(count($pricing_rule_sets)){
global $woocommerce_pricing;
foreach ($pricing_rule_sets as $pricing_rule_set) {
@solepixel
solepixel / st2-setup.txt
Last active December 26, 2015 18:49
sublime text 2 setup
Sublime Text 2 Setup:
Packages:
1. Package Control: https://sublime.wbond.net/installation - This will allow you easily install other packages
2. DocBlockr
3. Gist (You'll need to setup the config for this to work)
4. Goto Documentation (Customize this for super+click)
5. LiveReload
6. Prefixr
7. Sass
@solepixel
solepixel / company.php
Created February 17, 2014 05:44
iThemes Exchange attempts to create a custom customer/registration field.
<?php do_action( 'it_exchange_content_registration_before_company_element' ); ?>
<div class="it-exchange-registration-company">
<?php it_exchange( 'dichiara_registration', 'company' ); ?>
</div>
<?php do_action( 'it_exchange_content_registration_after_company_element' ); ?>
@solepixel
solepixel / helpers.php
Created March 11, 2014 22:25
Helpers file in MIni Loops Plugin
<?php
# ...
function miniloops_shortcoder( $input ) {
$input = wp_filter_post_kses( $input );
//give our shortcodes the correct prefix
$input = str_replace( '[', '[ml_', $input );
$input = str_replace( '[/', '[/ml_', $input );
//make sure we haven't doubled-up
@solepixel
solepixel / post.php
Last active August 29, 2015 14:01
wp_edit_posts_query function from wp-admin/includes/post.php line 849
<?php
/**
* Run the wp query to fetch the posts for listing on the edit posts page
*
* @since 2.5.0
*
* @param array|bool $q Array of query variables to use to build the query or false to use $_GET superglobal.
* @return array
*/
@solepixel
solepixel / class-wc-gateway-authorize-net.php
Last active August 29, 2015 14:01
woocommerce authorize.net payment gateway bug found in woocommerce-gateway-authorize-net-aim/classes
<?php
function process_payment( $order_id ) {
global $woocommerce;
$order = new WC_Order( $order_id );
// the meta for order_tax isn't available yet because of meta caching in wordpress, pull tax from cart tax_total
$order_tax = $order->order_tax ? $order->order_tax : WC()->cart->tax_total;
$testmode = ($this->testmode == 'yes') ? 'TRUE' : 'FALSE';
@solepixel
solepixel / my-virtual-merchant-submit.php
Created June 13, 2014 21:28
My Virtual Merchant Submission Button
<?php
/**
* My Virtual Merchant Submission Button
* Description: This button will allow users to send customers and clients to the My Virtual Merchant payment form
* Version: 1.0.0
* Author: Brian DiChiara
* Author URI: http://www.briandichiara.com
*/
$post_url = 'https://www.myvirtualmerchant.com/VirtualMerchant/process.do';
<?php get_header(); ?>
<div id="content" class="clearfix row">
<div id="main" class="col-sm-8 clearfix" role="main">
<div class="page-header">
<?php if (is_category()) { ?>
<h1 class="archive_title h2">
<span><?php _e("Posts Categorized:", "wpbootstrap"); ?></span> <?php single_cat_title(); ?>