Skip to content

Instantly share code, notes, and snippets.

@galengidman
galengidman / data-placeholder.js
Last active Dec 10, 2015
Snippet for data-placeholder powered input and textarea placeholders.
View data-placeholder.js
$('[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');
View gforms-placeholder.php
/**
* 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 Dec 25, 2015
Returns the page title of the blog posts page as set in Settings → Reading.
View gist:7058364
function get_posts_page_title() {
if (get_option('show_on_front') == 'page') {
return get_the_title(get_option('page_for_posts'));
}
return false;
}
View scroll-if-offset.js
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 Mar 18, 2014
Elements to target to style text inputs.
View text-inputs.css
input[type="email"],
input[type="number"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="text"],
input[type="url"],
textarea {
/* styles */
}
View menu.html
<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 Nov 26, 2020
`display: table` sticky footer trick
View index.html
<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 Mar 28, 2014
.page-row markup for easy styling
View index.html
<header class="page-row">
<!-- apply your styles to me -->
<div class="header-inner">
<h1>Site Title</h1>
</div>
</header>
@galengidman
galengidman / index.php
Created Mar 28, 2014
get ACF image size URL by ID
View index.php
<?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 Mar 28, 2014
get ACF image size URL by image object
View index.php
<?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];