Skip to content

Instantly share code, notes, and snippets.

View riceguitar's full-sized avatar

David Sudarma riceguitar

  • California
View GitHub Profile
<?php
/**
* Given a string containing any combination of YouTube and Vimeo video URLs in
* a variety of formats (iframe, shortened, etc), each separated by a line break,
* parse the video string and determine it's valid embeddable URL for usage in
* popular JavaScript lightbox plugins.
*
* In addition, this handler grabs both the maximize size and thumbnail versions
* of video images for your general consumption. In the case of Vimeo, you must
* have the ability to make remote calls using file_get_contents(), which may be
@riceguitar
riceguitar / gist:c5fc26f49ccb6cb7ff37
Last active August 29, 2015 14:21
Woo Commerce Disable Product reviews when product is out of stock
// Checks product quantity then removes review tabs if zero
add_filter( 'woocommerce_product_tabs', 'zero_tab_remove', 98);
function zero_tab_remove($tabs) {
if (!$product->get_stock_quantity() == 0) {
unset($tabs['reviews']);
return $tabs;
}
}
@riceguitar
riceguitar / gist:27f862ff9aacb60490f3
Created May 28, 2015 04:24
Image Crop with CSS
<div class="image_crop">
<img src="http://kenrockwell.com/nikon/d600/sample-images/600_0985.JPG" />
</div>
<style>
.image_crop {max-height: 400px; max-width: 400px; overflow: hidden;}
.image_crop img {width: 100%; height: auto;}
</style>
@riceguitar
riceguitar / vimeo-functions-wp.php
Last active August 29, 2015 14:22
Fully Unbaked Vimeo Functions
/*
These are Raw functions that have helped me when using vimeo.
Sample Usage:
<?php echo vimeo_id('https://vimeo.com/26434597'); // Will return 26434597 ?>
<?php echo vimeo_player('https://vimeo.com/26434597', 'yes'); // Returns the full Vimeo iFrame embed player ?>
<?php echo vimeo_thumb('https://vimeo.com/26434597'); // Returns thumbnail URL of the video using the thumbnail_url ?>
<?php echo vimeo_duration('https://vimeo.com/26434597'); // Returns the duration of the video in Time format ?>
*/
@riceguitar
riceguitar / genesis-child-five-col.css
Created May 31, 2015 15:11
Five Column - All the way across for Genesis Child Themes
.home-flexible .five-widgets .widget:first-child {
margin-left: 0% !important;
}
.home-flexible .five-widgets .widget {
width: 19.2% !important;
}
.home-flexible .five-widgets .widget:nth-of-type(3n+1) {
clear: none;
margin-left: 1%;
@riceguitar
riceguitar / functions.php
Last active August 29, 2015 14:23
Genesis Border above Footer
// Add these styles to your CSS.
<style>
.frockina_footer_border {
display: block;
background: url(/~frockina/wp-content/uploads/2015/06/watercolorbg4-bottom.png) bottom center repeat-x;
height: 45px;
}
</style>
// Add this part to your functions.php
@riceguitar
riceguitar / gist:634f0cec9259cdea9310
Last active August 29, 2015 14:24
Genesis - Reverse Post Order
/** Replace the standard loop with our custom loop */
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'child_do_custom_loop' );
function child_do_custom_loop() {
global $paged; // current paginated page
global $query_args; // grab the current wp_query() args
$args = array(
'order' => ASC, // exclude posts from this category
// Change Author URL Slug
add_filter( 'query_vars', 'wpleet_rewrite_add_var' );
function wpleet_rewrite_add_var( $vars )
{
$vars[] = 'user';
return $vars;
}
add_rewrite_tag( '%user%', '([^&]+)' );
add_rewrite_rule(
@riceguitar
riceguitar / walker-christmas.less
Last active October 16, 2015 22:37
Walker Christmas Less
// Media Query Shortcuts //
@tablet: ~"only screen and (min-width: 768px)";
@desktop: ~"only screen and (min-width: 992px)";
@large-desktop: ~"only screen and (min-width: 1200px)";
/* Video Area */
#wcc-tour-video {
@riceguitar
riceguitar / walker-christmas.html
Last active October 16, 2015 22:40
Walker Christmas HTML
<!-- Video Section -->
<section id="wcc-tour-video" class="section-video">
<div class="video-container">
<iframe
width="1280"
height="720"
frameborder="0"
allowfullscreen
src="https://www.youtube.com/embed/NxHzMP58fcM?showinfo=0&rel=0"
></iframe>