Skip to content

Instantly share code, notes, and snippets.

@ivandoric
ivandoric / gist:11215207
Created April 23, 2014 13:28
jQuery: Clear input and textarea fields on click
jQuery(function(){
jQuery('input, textarea').each(function(){
var txtval = jQuery(this).val();
jQuery(this).focus(function(){
jQuery(this).val('')
});
jQuery(this).blur(function(){
if(jQuery(this).val() == ""){
jQuery(this).val(txtval);
}
@ivandoric
ivandoric / gist:11215233
Created April 23, 2014 13:29
woocommerce: Remove catalog ordering
<?php //Add to functions.php
remove_action('woocommerce_pagination', 'woocommerce_catalog_ordering', 20 );
@ivandoric
ivandoric / gist:11215261
Created April 23, 2014 13:30
woocommerce: Disable breadcrumbs
<?php //Add to functions.php
remove_action( 'woocommerce_before_main_content',
'woocommerce_breadcrumb', 20, 0);
@ivandoric
ivandoric / gist:11215273
Last active August 29, 2015 14:00
php: Show errors
//Put this in your root index.php file
<?php
error_reporting(E_ALL);
ini_set('display_errors','On');
@ivandoric
ivandoric / gist:11215326
Created April 23, 2014 13:32
drupal: user register form template
<?php
//Add this to template.php
function YOURTHEME_theme(&$existing, $type, $theme, $path){
$hooks = array();
// Make user-register.tpl.php available
$hooks['user_register_form'] = array (
'render element' => 'form',
@ivandoric
ivandoric / gist:11215366
Created April 23, 2014 13:33
wordpress: Add aditional text to wp_nav_menu using walker object
/* functions.php */
<?php
class description_walker extends Walker_Nav_Menu
{
function start_el(&$output, $item, $depth, $args)
{
global $wp_query;
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
$class_names = $value = '';
@ivandoric
ivandoric / gist:11215395
Created April 23, 2014 13:34
drupal: Add block to node
<?php
$block = block_load('module_name', 'block_name');
$output = drupal_render(_block_get_renderable_array(_block_render_blocks(array($block))));
print $output;
//module_name is the name of module that outputs the block, eg. webform
//block_name is the name of the block, you can find it out by hovering on configure link on block admin page, eg. client-block-19
@ivandoric
ivandoric / gist:11215483
Created April 23, 2014 13:37
drupal: Example of EntityFieldQuery to make Flex slider in Drupal
<?php
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
->propertyCondition('status', 1)
->propertyCondition('type', array('slider_gornji'))
->propertyOrderBy('created', 'DESC')
->range(0, 5);
$result = $query->execute();
$nodes = node_load_multiple(array_keys($result['node']));
@ivandoric
ivandoric / gist:11215515
Created April 23, 2014 13:38
php: Alternate rows
<?php $class = ($x%2 == 0)? 'odd': 'even'; ?>
@ivandoric
ivandoric / gist:11215573
Created April 23, 2014 13:40
wordpress: Filter on post types with custom taxonomy in admin
<?php
//Add this to functions PHP
function pippin_add_taxonomy_filters() {
global $typenow;
// an array of all the taxonomyies you want to display. Use the taxonomy name or slug
$taxonomies = array('product-category');
// must set this to the post type you want the filter(s) displayed on