Archive for Uncategorized

Alt image loaded script

// $('img.photo',this).imagesLoaded(myFunction)
// execute a callback when all images have loaded.
// needed because .load() doesn't work on cached images

// mit license. paul irish. 2010.
// webkit fix from Oren Solomianik. thx!

// callback function is passed the last image to load
//   as an argument, and the collection as `this`


$.fn.imagesLoaded = function(callback){
  var elems = this.filter('img'),
      len   = elems.length;
      
  elems.bind('load',function(){
      if (--len <= 0){ callback.call(elems,this); }
  }).each(function(){
     // cached images don't fire load sometimes, so we reset src.
     if (this.complete || this.complete === undefined){
        var src = this.src;
        // webkit hack from <a href="http://groups.google.com/group/jquery-dev/browse_thread/thread/eee6ab7b2da50e1f" >http://groups.google.com/group/jquery-dev/browse_thread/thread/eee6ab7b2da50e1f</a>
        // data uri bypasses webkit log warning (thx doug jones)
        this.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
        this.src = src;
     }  
  }); 

  return this;
};

source

prototype check if element exists

if($('id_of_element') != undefined) {
    console.log('Object exists.');
}

source

random

<a href="http://wpcult.com/turn-your-rss-feed-into-a-shortcode/" >http://wpcult.com/turn-your-rss-feed-into-a-shortcode/</a>

<a href="http://www.jauhari.net/filter-caption-shortcode-in-wordpress.jsp" >http://www.jauhari.net/filter-caption-shortcode-in-wordpress.jsp</a>

<a href="http://savvyblogging.net/using-wordpress-shortcodes-to-memorize-links-and-save-time/" >http://savvyblogging.net/using-wordpress-shortcodes-to-memorize-links-and-save-time/</a>

<a href="http://www.tuttoaster.com/20-detailed-and-professional-branding-presentations/

" >http://www.tuttoaster.com/20-detailed-and-professional-branding-presentations/
source

Upcoming Posts

function upcom($atts, $content = null) {
       extract(shortcode_atts(array(
               "num" => '5'
               "tag" => 'series'
       ), $atts));
       global $post;
       $myposts = get_posts('numberposts='.$num.'&post_status=future&order=DESC&orderby=date&tag='.$tag);
       $retour='<ul class="upcoming">';
       foreach($myposts as $post) :
               setup_postdata($post);
            $retour.='<li><a href="'.get_permalink().'">'.the_title("","",false).'</a></li>';
       endforeach;
       $retour.='</ul> ';
       return $retour;
}
add_shortcode('upcoming', 'upcom');

source

moods

<a href="http://www.boosten.org/example-uses-of-custom-fields-in-wordpress/

" >http://www.boosten.org/example-uses-of-custom-fields-in-wordpress/
source

Includes shortcode

function digwp_includeContentShortcode($atts) {
  
  $thepostid = intval($atts[postidparam]);
  $output = '';

  query_posts("p=$thepostid&post_type=page");
  if (have_posts()) : while (have_posts()) : the_post();
    $output .= get_the_content($post->ID);
  endwhile; else:
    // failed, output nothing
  endif;
  wp_reset_query();

  return $output;

}

// USAGE
// In the post content, you can use [digwp_include postidparam="1234"]
// "1234" would be the WordPress ID of the Page you are trying to include

add_shortcode("digwp_include", "digwp_includeContentShortcode");

source

Multiple cloumns

function half($atts, $content = null) {
	return '
<div class="half">'.$content.'</div>
';
}
function half_last($atts, $content = null) {
	return '
<div class="half-last">'.$content.'</div>
<br style="clear: both;" />';
}
add_shortcode('half', 'half');
add_shortcode('half_last', 'half_last');





.half, .half-last {float:left;width:47%;margin:10px 0;margin-right:6%;}
.half-last {margin-right:0}




[half]Mauris ut lectus erat. In condimentum, turpis ...[/half]

[half_last]Mauris ut lectus erat. In condimentum, turpis ...[/half_last]

source

Create a download button

function download($atts, $content = null) {
	extract(shortcode_atts(array(
		"url" =&gt; ''
	), $atts));
	return '<a class="download" href="'.$url.'">'.$content.'</a>';
}
add_shortcode('download', 'download');

.download {
display: inline-block;color:#fff;
font-weight:bold;
font-size:1.2em;
background : -webkit-gradient(linear, left top, left bottom, from(#88c841), to(#73b338));
background : -moz-linear-gradient(center top, #88c841, #73b338);
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
padding: 5px 20px;
text-align: center;
-shadow: 0px 1px 0px #6c0909;
}

.download:hover {
background : -webkit-gradient(linear, left top, left bottom, from(#73b338), to(#88c841));
background : -moz-linear-gradient(center top, #73b338, #88c841);





[download url="<a href="http://www.google.com"]Download" >http://www.google.com"]Download</a> Google Chrome[/download]
}

source

custom list

function checklist($atts, $content = null) {
	return '
<div class="checklist">'.$content.'</div>
';
}
add_shortcode('checklist', 'checklist')




.checklist ul {
margin-left:50px;
list-style:none!important
}
.checklist ul li{
padding:5px 5px 5px 30px;
background:#fff url(images/check.png) no-repeat center left
}

source

Change Apple Screenshot to jpg

defaults write com.apple.screencapture type jpg
killall SystemUIServer

source