Skip to content

Instantly share code, notes, and snippets.

View kprimdal's full-sized avatar

Kristian Primdal kprimdal

View GitHub Profile
var ownDomain = location.hostname,
referrerDomain = document.referrer.split('/')[2],
author = '';
if ( ownDomain != referrerDomain) {
var script = document.createElement('script');
script.src = '//javascript.mamp/json/?callback=setAuthorCookie';
document.getElementsByTagName('head')[0].appendChild(script);
}
// var author = getCookie( 'partnerOptimizerId' );
@kprimdal
kprimdal / gist:4129189
Created November 22, 2012 02:50
WP: Loop
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) :
while ( $the_query->have_posts() ) : $the_query->the_post();
endwhile;
endif;
wp_reset_postdata();
@kprimdal
kprimdal / widget-boilerplate.php
Created November 6, 2012 15:08
WP: Widget Boilerplate
<?php
class Foo_Widget extends WP_Widget {
public function __construct() {
parent::__construct(
'foo_widget', // Base ID
'Foo_Widget', // Name
array( 'description' => __( 'A Foo Widget', 'text_domain' ), ) // Args
);
@kprimdal
kprimdal / gist:3931379
Created October 22, 2012 12:57
WP: Ajax jQuery
$.ajax({
type: 'POST',
url: MyAjax.ajaxurl,
data: {
action: 'action_which_handle_request',
pid: $this.attr('data-id')
},
success: function(data, textStatus, XMLHttpRequest){
$this.empty().append(data);
},
@kprimdal
kprimdal / embed-gist.php
Created October 2, 2012 20:40 — forked from roborourke/embed-gist.php
WP: Adds autoembedding of gist urls in WordPress
<?php
/**
* Usage:
* Paste a gist link into a blog post or page and it will be embedded eg:
* https://gist.github.com/2926827
*
* If a gist has multiple files you can select one using a url in the following format:
* https://gist.github.com/2926827?file=embed-gist.php
*/
@kprimdal
kprimdal / gist:3818332
Created October 2, 2012 11:32
WP: jQuery
(function ($) {
"use strict";
$(function() {
});
}(jQuery));
@kprimdal
kprimdal / gist:3806328
Created September 30, 2012 09:29
WP: Plugin start
<?php
/*
Plugin Name: Primux XXXX
Plugin URI: http://primux.dk
Description: Plugin to Add functions to XXXX
Version: 1.0
Author: Primux Media
Author URI: http://primux.dk
*/
@kprimdal
kprimdal / wp-query-ref.php
Created September 29, 2012 14:57 — forked from luetkemj/wp-query-ref.php
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(