Skip to content

Instantly share code, notes, and snippets.

View akmur's full-sized avatar

Alessandro Muraro akmur

View GitHub Profile
@akmur
akmur / touchstart.js
Last active August 29, 2015 14:00
Touchstart
var eventClick = (navigator.userAgent.match(/(iPad|iPhone|Android)/i)) ? "touchstart" : "click";
$('.myselector').bind(eventClick, function(event) {
// do stuff
});
@akmur
akmur / pagenavi - customloop
Last active August 29, 2015 14:01
Pagination of custom loops with pagenavi
$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
// WP_Query arguments
$args = array (
'post_status' => 'published',
'paged' => $paged,
'post_per_page' => 10
);
// The Query
@akmur
akmur / Get Image Field ACF
Last active August 29, 2015 14:08
Get Image Field ACF
<?php
// WP_Query arguments
$args = array (
'post_type' => 'page',
'posts_per_page' => '4',
'post_parent' => 9
);
// The Query
$query = new WP_Query( $args );
@akmur
akmur / removedata.js
Created November 3, 2014 10:35
Remove All Data Attributes
$('div').each(function(index, el) {
// Fetch an array of all the data
el = $(el);
var data = el.data(),
i;
// Fetch all the key-names and put them in a variable called keys
var keys = $.map(data , function(value, key) { return key; });
// Loop through the keys, remove the attribute if the key contains "lorem".
for(i = 0; i < keys.length; i++) {
@akmur
akmur / .gitignore
Last active August 29, 2015 14:08 — forked from salcode/.gitignore
# -----------------------------------------------------------------
# .gitignore for WordPress
# -----------------------------------------------------------------
# ignore everything in the root except the "wp-content" directory.
/*
!wp-content/
# ignore all files starting with .
.*
@akmur
akmur / social_manual_sharing.php
Last active August 29, 2015 14:11
Social Manual Sharing, goes in functions.php
function output_social_links() {
global $post;
$permalink = get_permalink($post->ID);
$title = get_the_title();
$content = '
<section class="sharing"
<ul>
<li>
<a href="http://www.facebook.com/share.php?u=' . urlencode($permalink) . '&title=' . urlencode($title) . '" class="icon-share_facebook_30x30 social-fb" target="_blank">FB</a>
</li>
<ul>
<li class="share-text">Share this>/li>
<li class="share-tw"><a href="http://twitter.com/share?text=[title]"><span></span></a></li>
<li class="share-fb"><a href="http://www.facebook.com/sharer.php?u=/node/[nid]&p=[title]"><span></span></a></li>
<li class="share-pinterest"><a href="http://pinterest.com/pin/create/button/?url=/node/[nid]&description=[title]"><span></span></a></li>
</ul>
if( function_exists('acf_add_options_page') ) {
acf_add_options_page(array(
'page_title' => 'Options',
'menu_title' => 'Options',
'menu_slug' => 'options',
'capability' => 'edit_posts',
'redirect' => false
));
@akmur
akmur / cookie-policy-checker.js
Last active August 29, 2015 14:22
Cookie Policy Checker
@akmur
akmur / Simple email validation.js
Last active December 11, 2015 10:09
Simple email validation
$('input#submit').click(function(){
var email = $('input#email').val();
var flag = true;
$('input.req').each(function(){
// if the input.req is empty...
if ($(this).val() == "") {
$(this).nextAll('span:first').fadeIn();
flag = false;
} else {
// if the input#email field has no @ sign...