Skip to content

Instantly share code, notes, and snippets.

View resarahman's full-sized avatar
🏠
Working from home

Resa Rahman resarahman

🏠
Working from home
View GitHub Profile
@resarahman
resarahman / scripts.js
Created June 11, 2016 02:37
Learn jQuery - Lesson 4
(function() {
var link = $('link');
$('button').on('click', function() {
var $this = $(this),
stylesheet = $this.data('file');
link.attr('href', stylesheet + '.css');
$this
.siblings('button')
.removeAttr('disabled')
@resarahman
resarahman / scripts.js
Created June 11, 2016 02:37
Learn jQuery - Lesson 4
(function() {
var link = $('link');
$('button').on('click', function() {
var $this = $(this),
stylesheet = $this.data('file');
link.attr('href', stylesheet + '.css');
$this
.siblings('button')
.removeAttr('disabled')
@resarahman
resarahman / scripts.js
Created June 11, 2016 02:37
Learn jQuery - Lesson 4
(function() {
var link = $('link');
$('button').on('click', function() {
var $this = $(this),
stylesheet = $this.data('file');
link.attr('href', stylesheet + '.css');
$this
.siblings('button')
.removeAttr('disabled')
@resarahman
resarahman / scripts.js
Created June 11, 2016 02:37
Learn jQuery - Lesson 4
(function() {
var link = $('link');
$('button').on('click', function() {
var $this = $(this),
stylesheet = $this.data('file');
link.attr('href', stylesheet + '.css');
$this
.siblings('button')
.removeAttr('disabled')
@resarahman
resarahman / scripts.js
Created June 11, 2016 02:37
Learn jQuery - Lesson 4
(function() {
var link = $('link');
$('button').on('click', function() {
var $this = $(this),
stylesheet = $this.data('file');
link.attr('href', stylesheet + '.css');
$this
.siblings('button')
.removeAttr('disabled')
@resarahman
resarahman / functions.php
Created November 3, 2015 10:25
Next/Prev post link based on meta_key value
<?php
function custom_next_prev_post_links( $join, $in_same_term, $excluded_terms, $taxonomy, $post ){
global $wpdb;
$join .= " INNER JOIN $wpdb->postmeta AS m ON p.ID = m.post_id AND m.meta_key = 'your_meta_key_name'";
return $join;
}
add_filter('get_next_post_join', 'custom_next_prev_post_links', 10, 5);
add_filter('get_previous_post_join', 'custom_next_prev_post_links', 10, 5);
@resarahman
resarahman / functions.php
Last active August 29, 2015 14:23
Determine if WordPress AJAX request is a backend of frontend request. original link http://snippets.khromov.se/determine-if-wordpress-ajax-request-is-a-backend-of-frontend-request/
/**
* Determine whether ajax request from frontend.
*
* @return boolean
*/
function request_is_frontend_ajax() {
$script_filename = isset($_SERVER['SCRIPT_FILENAME']) ? $_SERVER['SCRIPT_FILENAME'] : '';
//Try to figure out if frontend AJAX request... If we are DOING_AJAX; let's look closer