Skip to content

Instantly share code, notes, and snippets.

View micalexander's full-sized avatar

Michael Alexander micalexander

View GitHub Profile
@micalexander
micalexander / flexslider.css
Created June 11, 2014 02:08
wordpress:flexslider:snippet
/* -------------------------------------------------
** FLEXSLIDER CLEANUP
** ---------------------------------------------- */
.flexslider, .flexslider * { @include box-sizing('content-box'); }
.flexslider { margin: 0; background: #fff; border: none; -webkit-border-radius: none; -moz-border-radius: none; -o-border-radius: none; border-radius: none; box-shadow: none; -webkit-box-shadow: none; -moz-box-shadow: none; -o-box-shadow: none; z-index: 0; }
.flex-direction-nav {*height: 0;}
.flex-direction-nav a {width: 20px; height: 60px; margin: -23px 0 0 0; display: block; background: url(../img/bg_direction_nav.png) no-repeat 0 0; position: absolute; top: 160px; z-index: 10; cursor: pointer; text-indent: -9999px; opacity: 1; -webkit-transition: all .3s ease;}
.flex-direction-nav .flex-next {opacity: .7;background-position: 100% 0; right: 0; }
.flex-direction-nav .flex-prev {opacity: .7;left: 0;}
.flexslider:hover .flex-next {opacity: 1; right: 0;}
@micalexander
micalexander / flexslider.js
Created June 11, 2014 01:53
wordpress:flexslider:snippet
$(window).load(function() {
$('.flexslider-home').flexslider({
slideshowSpeed: 4000,
animationSpeed: 800,
// Primary Controls
controlNav: true,
directionNav: false,
prevText: "Previous",
nextText: "Next",
@micalexander
micalexander / flexslider.php
Created June 11, 2014 01:52
wordpress:flexslider:snippet
<?php $images = get_field('slider');
if( $images ): ?>
<div id="slider" class="flexslider flexslider-home ">
<ul class="slides">
<?php foreach( $images as $image ): ?>
<li>
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
</li>
<?php endforeach; ?>
</ul>
@micalexander
micalexander / mask.php
Last active August 29, 2015 14:01
wordpress:\mask:snippet
class Mask {
// get image and meta including title, alt, caption, and description
function get_image( $size = null, $post_id = null )
{
$img = wp_prepare_attachment_for_js(get_post_thumbnail_id($post_id));
if ($size != null)
{
if (!array_key_exists($size, $img['sizes']))
@micalexander
micalexander / custom-accordion.js
Last active August 29, 2015 14:01
wordpress:custom-accordion
// accordion
(function(){
$('.accordion-section').hide();
$('.accordion-heading').click(function(){
var clicks = $(this).data('clicks');
if (!clicks) {
$(this).addClass('selected');
$(this).next('.accordion-section').addClass('selected').slideDown();
$(this).parent().siblings().children('.accordion-heading').removeClass('selected').removeData('clicks');
$(this).parent().siblings().children().siblings().children().children().children('.accordion-heading').removeClass('selected').removeData('clicks');
@micalexander
micalexander / gravity-forms.js
Last active August 29, 2015 13:56
wordpress:gravity-forms:snippet:descriptions above fields
// place gravity form descriptions above the fields
$('.gfield_description').each(function(i,e){
$(e).css({'padding-bottom': '5px'});
sublabel = $('<label>').append($(e).clone()).remove().html();
$(e).siblings('label').after(sublabel);
$(e).remove();
});
@micalexander
micalexander / click-child.js
Last active January 4, 2016 21:29
jquery:snippet:click child when parent is clicked
$('.parent').click(function(){
if ($(this).has('click-child')) {
$(this).find('.child').click();
};
});
@micalexander
micalexander / post-type-admin.php
Last active December 28, 2015 13:29
wordpress:snippet:get current post type in admin area
<?php
/**
* gets the current post type in the WordPress Admin
*/
function get_current_post_type() {
global $post, $typenow, $current_screen;
//we have a post so we can just get the post type from that
if ( $post && $post->post_type )
@micalexander
micalexander / create_hash.js
Last active December 27, 2015 17:29
javascript:snippet:create hash from a string
String.prototype.hashCode = function(){
var hash = 0, i, char;
if (this.length == 0) return hash;
for (i = 0, l = this.length; i < l; i++) {
char = this.charCodeAt(i);
hash = ((hash<<5)-hash)+char;
hash |= 0; // Convert to 32bit integer
}
return hash;
};
@micalexander
micalexander / fixser.rb
Last active December 27, 2015 05:19
ruby:fixes php serialization
#!/usr/bin/env ruby
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
def fix_file file
text = File.read file
fixed = fix_serialization text