Skip to content

Instantly share code, notes, and snippets.

View lunaroja's full-sized avatar

Abraham Velazquez Tello lunaroja

View GitHub Profile
@lunaroja
lunaroja / link-helpers.js
Last active December 31, 2015 17:09
Clean Link Helpers
@lunaroja
lunaroja / wp-google-search.php
Created December 11, 2013 01:28
Switch out WordPress Search for Google Domain Search
if ( ! function_exists( 'google_search_form' ) ) :
function google_search_form( $form ) {
$form = '<form method="get" action="http://www.google.com/search" class="search">';
$form .= '<input type="hidden" name="domains" value="' . get_bloginfo('url') . '">';
$form .= '<input type="hidden" name="sitesearch" value="' . get_bloginfo('url') . '">';
$form .= '<input type="text" name="q" placeholder="Search" class="input">';
$form .= '<input type="submit" value="Submit" class="submit">';
$form .= '</form>';
return $form;
@lunaroja
lunaroja / wp-clean-header.php
Created December 9, 2013 18:57
Clean WordPress wp_head() output
<?php
if ( ! function_exists( 'clean_header' ) ):
/*
* Clean the WordPress Header
*/
function clean_header() {
@lunaroja
lunaroja / visibility-classe.scss
Created September 14, 2013 00:41
Foundation Visibility Classes
#visibility-classes {
position: fixed;
display: block;
top: 0;
left: 0px;
color: #FFF;
z-index: 1000;
font-size: 10px;
span {
padding: 5px;
{
"replacements": {
"nbsp": { "find": "&nbsp;", "replace": " ", "greedy": true, "case": false },
"remove_json_dangling_commas": {
"find": ",([\\r\\n\\s]*)(\\]|\\})",
"replace": "\\1\\2",
"greedy": true,
"scope_filter": ["-string", "-comment"]
@lunaroja
lunaroja / wp-query-events-orderby-date.php
Created August 14, 2013 06:10
Wordpress Query using custom fields with Meta Box (http://wordpress.org/plugins/meta-box/) date fields to sort.
<?php $query = "
SELECT * FROM $wpdb->posts
LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id)
WHERE ($wpdb->posts.post_status = 'publish') AND
($wpdb->postmeta.meta_key = 'event_start_time')
ORDER BY $wpdb->postmeta.meta_value ASC";
$events = $wpdb->get_results($query, OBJECT);
?>
<?php if ($events): foreach ($events as $post): ?>
<?php get_template_part( 'loop', 'event' ); ?>
@lunaroja
lunaroja / no-plugin-updates-notifications.php
Created July 23, 2013 19:21
WordPress: Do not show plugin update notifications
function run_chk_usr_lvl($matches) {
global $userdata;
if (!current_user_can('update_plugins')) {
remove_action('admin_notices', 'update_nag', 3);
remove_action( 'load-update-core.php', 'wp_update_plugins' );
}
}
add_filter('pre_site_transient_update_plugins', create_function( '$a', "return null;" ));
add_action('admin_init', 'run_chk_usr_lvl');
@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');
@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 / 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;
}