Skip to content

Instantly share code, notes, and snippets.

View LucaRosaldi's full-sized avatar

Luca Rosaldi LucaRosaldi

View GitHub Profile
@LucaRosaldi
LucaRosaldi / rem-mixin.scss
Created November 26, 2012 11:03
SASS: mixin rem()
// Thanks to Maykel Loomans
// http://miekd.com/articles/sizing-type-leading-and-vertical-dimensions-with-rem-units/
$baseFontSize: 16px;
@mixin rem($property, $px_values) {
$baseline_rem: ($baseFontSize / 1rem);
#{$property}: $px_values;
@if type-of($px_values) == 'number' {
#{$property}: $px_values / $baseline_rem;
}
@LucaRosaldi
LucaRosaldi / pin-it-button.php
Created November 28, 2012 11:24
WP: Pinterest Pin It Button
<a href="http://pinterest.com/pin/create/button/?url=<?php the_permalink(); ?>&media=<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail' ); echo $thumb['0']; ?>&description=<?php the_title(); ?>" class="pin-it-button" count-layout="horizontal">Pin It</a>
<!-- This goes in the footer -->
<script type="text/javascript" src="http://assets.pinterest.com/js/pinit.js"></script>
@LucaRosaldi
LucaRosaldi / functions.php
Created November 28, 2012 11:28
WP: Google +1 Button
add_filter('the_content', 'wpr_google_plusone');
function wpr_google_plusone($content) {
$content = $content.'<div class="plusone"><g:plusone size="tall" href="'.get_permalink().'"></g:plusone></div>';
return $content;
}
add_action ('wp_enqueue_scripts','wpr_google_plusone_script');
function wpr_google_plusone_script() {
wp_enqueue_script('google-plusone', 'https://apis.google.com/js/plusone.js', array(), null);
}
@LucaRosaldi
LucaRosaldi / functions.php
Created November 28, 2012 11:32
WP: Better User Contacts
function new_contactmethods( $contactmethods ) {
$contactmethods['twitter'] = 'Twitter'; // Add Twitter
$contactmethods['facebook'] = 'Facebook'; // Add Facebook
unset($contactmethods['yim']); // Remove YIM
unset($contactmethods['aim']); // Remove AIM
unset($contactmethods['jabber']); // Remove Jabber
return $contactmethods;
}
add_filter('user_contactmethods','new_contactmethods',10,1);
@LucaRosaldi
LucaRosaldi / functions.php
Created December 17, 2012 10:41 — forked from jmdodd/gist:1695468
WP: Add Custom Post types to main Query.
<?php
if ( ! function_exists( 'ucc_add_cpts_to_pre_get_posts' ) ) {
function ucc_add_cpts_to_pre_get_posts( $query ) {
if ( $query->is_main_query() && ! is_post_type_archive() && ! is_singular() && ! is_404() ) {
$my_post_type = get_query_var( 'post_type' );
if ( empty( $my_post_type ) ) {
$args = array(
'exclude_from_search' => false,
'public' => true,
@LucaRosaldi
LucaRosaldi / functions.php
Created December 17, 2012 11:00 — forked from jmdodd/gist:1139941
WP: Add human-readable classes to wp_nav_menu
<?php
if ( ! function_exists( 'ucc_nav_menu_css_class' ) ) {
function ucc_nav_menu_css_class( $classes, $item, $args ) {
$class = sanitize_title( $item->title );
$classes[] = 'menu-item-' . $class;
return $classes;
} }
add_filter( 'nav_menu_css_class', 'ucc_nav_menu_css_class', 10, 3 );
@LucaRosaldi
LucaRosaldi / pp.php
Created December 17, 2012 12:19
PHP: Pretty Print function (for debugging)
<?php
/**
* Pretty Print (for debugging)
* @param mixed value to print
*/
function pp($val = null) {
if ( $val === false ) {
echo '<pre>(boolean) 0</pre>';
}
@LucaRosaldi
LucaRosaldi / theme-framework.php
Last active December 9, 2015 19:49
WP: framework functions
<?php
/**
* Pretty Print (for debugging)
*
* @param mixed $val The value to print
*/
function pp($val = null) {
$ret = '<pre>';
@LucaRosaldi
LucaRosaldi / functions.php
Created January 3, 2013 08:33
WP: Change oEmbed Width and Height
<?php
/**
* Changes oEmbed defaults dinamically
*/
function lr_oembed_defaults($embed_size) {
if(is_front_page()) {
$embed_size['width'] = 940;
$embed_size['height'] = 600;
}
@LucaRosaldi
LucaRosaldi / coverflow.html
Last active December 10, 2015 18:18 — forked from anonymous/index.html
CSS: Cover Flow
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>CSS3 CoverFlow</title>
<link rel="stylesheet" href="css/coverflow.css">