Skip to content

Instantly share code, notes, and snippets.

@ivandoric
ivandoric / gist:11215120
Created April 23, 2014 13:26
wordpress: Remove width/height from featured images
<?php
/* Remove width/height from featured images */
add_filter( 'post_thumbnail_html', 'remove_thumbnail_dimensions', 10 );
add_filter( 'image_send_to_editor', 'remove_thumbnail_dimensions', 10 );
function remove_thumbnail_dimensions( $html ) {
$html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
return $html;
}
@ivandoric
ivandoric / gist:11215147
Created April 23, 2014 13:26
wordpress: Hide editor but leave "Add Media" button on post type
<?php
function hide_editor_leave_media_button() {
global $current_screen;
if( $current_screen->post_type == 'ENTER_POST_TYPE_HERE' ) {
$css = '<style type="text/css">';
$css .= '#wp-content-editor-container, #post-status-info, .wp-switch-editor { display: none; }';
$css .= '</style>';
echo $css;
@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:11215308
Created April 23, 2014 13:31
wordpress: debug
<?php // change these values in wp-config.php
define('WP_DEBUG', true);
define('WP_DEBUG', false);
@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