Skip to content

Instantly share code, notes, and snippets.

@csknk
csknk / 0_reuse_code.js
Created October 8, 2013 09:45
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
<?php
// fancy PHP 5.3+ style
add_action( 'template_redirect', function() {
if ( ! is_user_logged_in() ) {
wp_redirect( wp_login_url() );
exit;
}
} );
//********************************************************
// function for calculating heights
//********************************************************
function equalHeight(group) {
var tallest = 0;
group.each(function() {
var thisHeight = jQuery(this).height();
if(thisHeight > tallest) {
tallest = thisHeight;
http://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg
The first one in the list is a full size image and others are thumbnail images. The default thumbnail image (ie. one of 1.jpg, 2.jpg, 3.jpg) is:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/default.jpg
For the high quality version of the thumbnail use a url similar to this:
@csknk
csknk / gist:8012021
Last active December 31, 2015 16:09 — forked from thomasgriffin/gist:8011213
Add post title as a h1 straight after soliloquy slider (between slider & thumbnails)
<?php
/* Add heading to slider */
add_filter( 'tgmsp_after_slider', 'tgm_soliloquy_custom_title_after_slider', 10, 5 );
function tgm_soliloquy_custom_title_after_slider( $slider, $id, $images, $soliloquy_data, $soliloquy_count ) {
if ( '222' == $id ) { // if slider id ==222, don't do anything
return $slider;
}
<?php
/* Custom Excerpt */
// Remove default hellip
function carawebs_remove_hellip( $more ) {
return '';
}
add_filter('excerpt_more', 'carawebs_remove_hellip');
<?php
/* Register custom post types on the 'init' hook. */
add_action( 'init', 'my_register_post_types' );
/**
* Registers post types needed by the plugin.
*
* @since 0.1.0
* @access public
/*HTML Structure looks like this*/
<Body>
<img src = "http://conoregan.com/wp-content/uploads/2014/01/2013-12-04-08.50.18.jpg" class="background">
<div class="wrapper">
<p>The quick brown fox jumps over the lazy dog</p>
</div>
<style>
img.background {
/* Set rules to fill background */
html {
background: url(your-image-here) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}