Skip to content

Instantly share code, notes, and snippets.

View bratsun's full-sized avatar

Max Bratsun bratsun

View GitHub Profile
@bratsun
bratsun / git_commit
Created February 22, 2016 18:59
git commit
git add -A
git commit -a -m "My commit message"
@bratsun
bratsun / get_image_URL.php
Created January 29, 2016 14:11
Get image URL
$person = get_field('persona');
$thumb = get_field('photo', $person->ID)['id'];
$thumb = wp_get_attachment_image_src($thumb, 'small', true)[0];
@bratsun
bratsun / posts_loop.php
Created January 29, 2016 14:10
Loop through post objects
<?php
$post_objects = get_field('post_objects');
if( $post_objects ): ?>
<ul>
<?php foreach( $post_objects as $post_object): ?>
<li>
<a href="<?php echo get_permalink($post_object->ID); ?>"><?php echo get_the_title($post_object->ID); ?></a>
<span>Post Object Custom Field: <?php the_field('field_name', $post_object->ID); ?></span>
@bratsun
bratsun / label-to-placeholder.js
Created January 26, 2016 14:46 — forked from makeusabrew/label-to-placeholder.js
Simple jQuery snippet to convert form labels into inline placeholders
$("form :input").each(function(index, elem) {
var eId = $(elem).attr("id");
var label = null;
if (eId && (label = $(elem).parents("form").find("label[for="+eId+"]")).length == 1) {
$(elem).attr("placeholder", $(label).html());
$(label).remove();
}
});
@bratsun
bratsun / alter_breadcrumb.php
Created November 13, 2015 08:04
Alter breadcrumb
function tmplt_menu_breadcrumb_alter(&$active_trail, $item) {
// add menu item to array
$active_trail[] = array('title' => 'Topics', 'href' => 'taxonomy/term/1');
}*/
@bratsun
bratsun / fly_menu.css
Last active October 11, 2016 08:20
Fly out menu (Microsoft style)
/* new menu */
.mainmenu{
float: left;
width: 100%;
clear: both;
}
.mainmenu li.sf-depth-1 {
display: inline-block;
@bratsun
bratsun / zip
Last active January 4, 2017 14:29
Zip it all
zip -r drupal.zip *
@bratsun
bratsun / timeout.js
Created September 30, 2015 08:38
Simple timeout
function selectClass(){
$('.f-formstack select, .webform-client-form select').each(function(){
var t = $(this).parent();
if (!t.hasClass('has-select')){
t.addClass('has-select');
} else{
clearTimeout(startClass);
}
});
}
@bratsun
bratsun / responsive_video.js
Created September 24, 2015 20:12
Responsive video
$('.f-video .field-item').addClass('embed-responsive embed-responsive-16by9').find('iframe').addClass('embed-responsive-item');
@bratsun
bratsun / hover.js
Created September 17, 2015 14:03
Hover
$('.block').on({
mouseenter: function () {
var t = $(this);
$('.block:visible').not(t).addClass('hover');
},
mouseleave: function () {
var t = $(this);
$('.block:visible').not(t).removeClass('hover');
}
});