Skip to content

Instantly share code, notes, and snippets.

@leepettijohn
leepettijohn / functions.php
Created April 11, 2015 04:47
Add image size to Media Insert
add_filter('image_size_names_choose', 'my_image_sizes');
function my_image_sizes($sizes) {
$addsizes = array(
"new-size" => __( "New Size")
);
$newsizes = array_merge($sizes, $addsizes);
return $newsizes;
}
@leepettijohn
leepettijohn / script.js
Created February 26, 2016 18:34
Revising all texts on a page in a certain selector
//Use correct selector
$('.your-selector').text(function(){
return $(this).text().substr($(this).text().indexOf('insert-your-break-point-here'));
});
@leepettijohn
leepettijohn / script.js
Created March 1, 2016 14:57
Select items not on the screen or only partially visible
// onScreen jQuery plugin v0.2.1
// (c) 2011-2013 Ben Pickles
//
// http://benpickles.github.io/onScreen
//
// Released under MIT license.
;(function($) {
$.expr[":"].onScreen = function(elem) {
var $window = $(window)
var viewport_top = $window.scrollTop()
@leepettijohn
leepettijohn / functions.php
Created April 25, 2016 20:30
Extract a CSV in Gravity Forms and put in a textarea
// Change the '9' at the end to the id of your form
add_action('gform_post_submission_9','pullcsv',10,2);
function pullcsv($entry, $form){
//Fields to change
$file_field = 3;
$text_field = 4;
$entry_id = $entry['id'];
$csv = $entry[$file_field]; //this returns a url string to the uploaded csv
$row = 1;
if (!empty($csv)){
@leepettijohn
leepettijohn / script.js
Created June 22, 2016 21:46
jQuery - Append to link href / url
var _href = $("a.variables").attr("href");
$("a.variables").attr("href", _href + '?id='+ $_GET["id"]);
@leepettijohn
leepettijohn / index.html
Created June 24, 2016 17:26
Middle floating div between two fixed divs
<div id="leftCol">Left</div>
<div id="rightCol">Right</div>
<div id="centerCol">Center</div>
@leepettijohn
leepettijohn / index.html
Last active July 22, 2016 18:44
Rollovers in CSS
<a href="#" class="rollover" title="Webvamp"><span class="displace">Webvamp</span></a>
@leepettijohn
leepettijohn / script.js
Last active August 27, 2016 16:04
Remove text before each selection
//remove everything (and including) before ":"
<script type="text/javascript">jQuery(document).ready(function($){
$('.ai1ec-event-time').each(function(){
var str = $(this).html();
str = str.split(":").pop();
$(this).html(str);
});
});
</script>
@leepettijohn
leepettijohn / center.html
Created September 29, 2016 17:43
Center div between two different sized divs
<style>
div{height:100px}
.left{float:left; width:100px;}
.right{float:right; width:300px;}
.middle-wrap{overflow:hidden}
.middle{margin:0 auto; width:50px}
</style>
<div class="left"></div>
<div class="right"></div>
<div class="middle-wrap">
@leepettijohn
leepettijohn / functions.php
Created October 3, 2016 10:12
Order Posts by order number
/* Also, add the plugin Simple Page Ordering to enable the ability to drag and drop posts to a specified order
add_action( 'genesis_before_loop', 'ntg_do_query' );
/** Changes the Query before the Loop */
function ntg_do_query() {
$posttype = get_post_type();
if( $posttype == 'portfolio'){
global $query_string;
query_posts( wp_parse_args( $query_string, array( 'orderby' => 'menu_order', 'order' => 'ASC' ) ) );