Skip to content

Instantly share code, notes, and snippets.

@meishern
meishern / gist:8970339
Created February 13, 2014 05:42
WooCommerce Check Cart Quantity
// check that cart items quantities totals are in multiples of 5
add_action( 'woocommerce_check_cart_items', 'woocommerce_check_cart_quantities' );
function woocommerce_check_cart_quantities() {
global $woocommerce;
$multiples = 5;
$total_products = 0;
foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values ) {
$total_products += $values['quantity'];
}
if ( ( $total_products % $multiples ) > 0 )
@meishern
meishern / gist:5856229
Created June 25, 2013 05:51
css effect to make 3d panels with curved corners and shadow . just needs height and width for .flex-column that set elsewhere.
.flex_column {
position: relative;
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
background-color: rgba(0,0,0,0.0);
box-shadow: 0 1px 5px rgba(0,0,0,0.25), 0 0 50px rgba(0,0,0,0.1) inset;
border: 2px solid #6640FF;
/*border-radius: 1% 1% 1% 1% / 1% 1% 1% 1%;*/
@meishern
meishern / remove title from images
Created June 7, 2013 14:44
remove title of images
<script type="text/javascript">
jQuery('document').ready(function($){
$('[title]').removeAttr('title');
});
</script>
@meishern
meishern / Cyrillic - Latin Wordpres - Avia Framework
Last active December 17, 2015 20:08
German + Cyrillic + Greek - Enfold Theme Function - /framework/php/function-set-avia-backend.php lines 89-128
if(!function_exists('avia_backend_safe_string'))
{
/**
* Create a lower case version of a string without spaces so we can use that string for database settings
*
* @param string $string to convert
* @return string the converted string
*/
function avia_backend_safe_string( $string , $replace = "_")
@meishern
meishern / gist:5351724
Created April 10, 2013 04:07
CASE / SWITCH - a faster and better way to do it with arrays
// used for $current_home = 'current';
$group1 = array(
'home' => True,
);
// used for $current_users = 'current';
$group2 = array(
'users.online' => True,
'users.location' => True,
'users.featured' => True,
@meishern
meishern / gist:5291418
Created April 2, 2013 10:53
fix serialized data in wordpress. i.e. if porting to new website and domain has dif number of characters
<?php
// This code is a serialised string fixer for WordPress (and probably other systems).
// Simply select the table you need to fix in $table, and the code will change the string lengths for you. Saves having to manually go through.
// Written 20090302 by David Coveney http://www.davecoveney.com and released under the WTFPL - ie, do what ever you want with the code, and I take no responsibility for it OK?
// To view the WTFPL go to http://sam.zoy.org/wtfpl/ (WARNING: it's a little rude, if you're sensitive)
//
// Thanks go to getmequick at gmail dot com who years ago posted up his preg_replace at http://uk2.php.net/unserialize and saved me trying to work it out.
//
// Before you start, do make a backup. A backup that you know works, because this code has the scope to really break your data if you're careless.
<?php
/*
Plugin Name: Remove All Feeds [for WPSE33072]
Description: Remove all feeds from WordPress
Author: Christopher Davis
Author URI: http://christopherdavis.me
License: GPL2
*/
@meishern
meishern / gist:5268905
Created March 29, 2013 05:19
Wodpress code to cleanup transients that pollute the database
add_action( 'wp_scheduled_delete', 'delete_expired_db_transients' );
function delete_expired_db_transients() {
global $wpdb, $_wp_using_ext_object_cache;
if( $_wp_using_ext_object_cache )
return;
$time = isset ( $_SERVER['REQUEST_TIME'] ) ? (int)$_SERVER['REQUEST_TIME'] : time() ;
@meishern
meishern / facebook-jq
Created December 15, 2012 22:38
jQuery Facebook Like Button XFBML Ajax parser
$(document).ajaxComplete(function(){
try{
FB.XFBML.parse();
}catch(ex){}
});
//ref: http://stackoverflow.com/questions/3548493/how-to-detect-when-facebooks-fb-init-is-complete