Skip to content

Instantly share code, notes, and snippets.

@galengidman
galengidman / data-placeholder.js
Last active December 10, 2015 13:08
Snippet for data-placeholder powered input and textarea placeholders.
$('[data-placeholder]').focus(function() {
if ($(this).val() == $(this).attr('data-placeholder')) {
$(this).removeClass('inactive');
$(this).val('');
}
});
$('[data-placeholder]').blur(function() {
if ($(this).val() == '') {
$(this).addClass('inactive');
/**
* Add placeholder attributes to Gravity Form inputs.
*/
function my_standard_settings($position, $form_id) {
if ($position == 25) : ?>
<li class="admin_label_setting field_setting" style="display:list-item;">
<label for="field_placeholder">Placeholder Text
<a href="javascript:void(0);" class="tooltip tooltip_form_field_placeholder" tooltip="&lt;h6&gt;Placeholder&lt;/h6&gt;Enter the placeholder/default text for this field.">(?)</a>
</label>
@galengidman
galengidman / gist:7058364
Last active December 25, 2015 23:39
Returns the page title of the blog posts page as set in Settings → Reading.
function get_posts_page_title() {
if (get_option('show_on_front') == 'page') {
return get_the_title(get_option('page_for_posts'));
}
return false;
}
function classIfOffset(element, class, offset) {
var scroll = $(window).scrollTop();
if (scroll > offset) {
element.addClass(class);
} else {
element.removeClass(class);
}
}
@galengidman
galengidman / text-inputs.css
Created March 18, 2014 16:11
Elements to target to style text inputs.
input[type="email"],
input[type="number"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="text"],
input[type="url"],
textarea {
/* styles */
}
@galengidman
galengidman / menu.html
Created March 28, 2014 15:43
Statamic Menu
<ul id="menu" class="menu">
{{ if menu }}
{{ menu }}
<li{{ if submenu }} class="has-submenu"{{ endif }}>
<a href="{{ url }}"{{ if target }} target="{{ target }}"{{ endif }}>{{ name }}</a>
{{ if submenu }}
<ul class="submenu">
{{ submenu }}
<li><a href="{{ url }}"{{ if target }} target="{{ target }}"{{ endif }}>{{ name }}</a></li>
@galengidman
galengidman / index.html
Last active November 26, 2020 17:36
`display: table` sticky footer trick
<header class="page-row">
<h1>Site Title</h1>
</header>
<main class="page-row page-row-expanded">
<p>Page content goes here.</p>
</main>
<footer class="page-row">
<p>Copyright, blah blah blah.</p>
@galengidman
galengidman / index.html
Created March 28, 2014 18:56
.page-row markup for easy styling
<header class="page-row">
<!-- apply your styles to me -->
<div class="header-inner">
<h1>Site Title</h1>
</div>
</header>
@galengidman
galengidman / index.php
Created March 28, 2014 19:01
get ACF image size URL by ID
<?php
// first, get the image ID returned by ACF
$image_id = get_field('my_image_field');
// and the image size you want to return
$image_size = 'thumbnail';
// use wp_get_attachment_image_src to return an array containing the image
// we'll pass in the $image_id in the first parameter
@galengidman
galengidman / index.php
Created March 28, 2014 19:10
get ACF image size URL by image object
<?php
// first, get the image object returned by ACF
$image_object = get_field('my_image_field');
// and the image size you want to return
$image_size = 'thumbnail';
// now, we'll exctract the image URL from $image_object
$image_url = $image_object['sizes'][$image_size];