Skip to content

Instantly share code, notes, and snippets.

View lunaroja's full-sized avatar

Abraham Velazquez Tello lunaroja

View GitHub Profile
@lunaroja
lunaroja / app.js
Created March 13, 2013 19:30
Simple object fire based on document body ID (Simplified version from Paul Irish)
var APP = APP || {};
APP.fire = {
init : function () {
},
index : function () {
},
@lunaroja
lunaroja / horizontalScroll.css
Created April 3, 2013 16:03
simple horizontal scrolling div with iOS touch support.
.horizontalScroll {
width: 100%;
height: 200px;
overflow: scroll;
overflow-y: hidden!important;
white-space: nowrap;
-webkit-overflow-scrolling: touch;
}
@lunaroja
lunaroja / Preferences.sublime-settings
Last active May 13, 2016 17:17
Sublime Text 3 User Preferences
{
"binary_file_patterns":
[
"*.jpg",
"*.jpeg",
"*.png",
"*.gif",
"*.ttf",
"*.tga",
"*.dds",
@lunaroja
lunaroja / checkall.js
Created April 17, 2013 00:57
check all checkboxes on page
var checkboxes = document.querySelectorAll("input.checkbox");
for (var i = 0; i < checkboxes.length; i++) { checkboxes[i].click(); };
@lunaroja
lunaroja / clean-text.js
Created April 18, 2013 22:57
quickly grab and array and log out a cleaned version of the text for urls or other sorts
for (var i = 0; i < copy.length; i++) {
console.log(copy[i].toLowerCase().replace(/[^\w\s]/gi, '').replace(/\s+/g, '-'));
};
@lunaroja
lunaroja / exclude-from-home.php
Created April 29, 2013 16:00
Wordpress Query: Hide posts from home page based on meta key and still allow pagination.
<?php
if ( is_home() ) {
global $wp_query;
$args = array_merge( $wp_query->query, array(
'meta_query' => array(
array(
'key' => 'hidefromhome',
'value' => 0
)
@lunaroja
lunaroja / jquery.getParam.js
Created May 2, 2013 05:57
Simple jQuery plugin that gets URL parameter by name for either address or specific url.
jQuery.extend({
getParam: function(n,u) {
if(!u) var u = window.location.search;
var match = RegExp('[?&]' + n + '=([^&]*)').exec(u);
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
}
});
@lunaroja
lunaroja / get_terms_chekboxes.php
Last active November 25, 2018 19:04
Wordpress: Get taxonomy terms as checkboxes with labels
<?php
function get_terms_chekboxes($taxonomies, $args) {
$terms = get_terms($taxonomies, $args);
foreach($terms as $term){
$output .= '<label for="'.$term->slug.'"><input type="checkbox" id="'.$term->slug.'" name="'.$term->taxonomy.'" value="'.$term->slug.'"> '.$term->name.'</label>';
}
return $output;
}
@lunaroja
lunaroja / post_thumbnail_data_attributes
Created July 4, 2013 04:26
Wordpress: Get post thumbnail URLs as data attributes
// use inside the loop
// <div <?php post_class() ?> <?php post_thumbnail_data_attributes(); ?>>
// data-thumbnail-large="http://url.com/wp-content/uploads/2013/07/chicago-1000x703.jpg"
// data-thumbnail-medium="http://url.com/wp-content/uploads/2013/07/chicago-500x351.jpg"
function post_thumbnail_data_attributes() {
$thumbnail_id = get_post_thumbnail_id();
$thumbnail_large = wp_get_attachment_image_src($thumbnail_id, 'large');
@lunaroja
lunaroja / div-shortcode.php
Created July 5, 2013 19:11
Wordpress: DIV short code with classes and IDs
function div_shortcode($atts, $content = null ) {
extract(shortcode_atts(array('class' => '', 'id' => '' ), $atts));
$return = '<div';
if (!empty($class)) $return .= ' class="'.$class.'"';
if (!empty($id)) $return .= ' id="'.$id.'"';
$return .= '>'. do_shortcode($content) . '</div>';
return $return;
}
add_shortcode('div', 'div_shortcode');