Skip to content

Instantly share code, notes, and snippets.

@adamharley
adamharley / gist:1165757
Created August 23, 2011 16:25
Disable all WordPress plugins with constant
<?php
if ( defined('SPECIAL_IMPORT') && SPECIAL_IMPORT )
add_filter( 'pre_option_active_plugins', '__return_empty_array' );
@adamharley
adamharley / random-image-widget.js
Created August 23, 2011 16:36
WP AJAX random image widget
jQuery(document).ready(function($) {
$.post(ajaxurl, {action:'random_image_widget'}, function(feedback){
image = jQuery.parseJSON(feedback);
img = $('<img src="'+image.thumb+'" />');
$('.widget_equesrandomimagewidget').append(img);
$(img).wrap('<a href="'+image.full[0]+'" width="'+image.full[1]+'" height="'+image.full[2]+'"></a>');
Shadowbox.setup(img.parent());
});
});
@adamharley
adamharley / gist:1165785
Created August 23, 2011 16:39
WP categories on home (blog) page
<?php
function category_homepage( $query ) {
if ( $GLOBALS['wp_the_query'] != $query || ! $query->is_home() ) // Only filter the main query on the blog page
return;
$categories = array( 1, 2, 3 );
$query->set('category__in', $categories);
}
@adamharley
adamharley / gist:1165812
Created August 23, 2011 16:46
SVN revision in WP admin footer version
<?php
function core_svn_update_footer( $msg = '' ) {
if ( !current_user_can('update_core') )
return $msg;
$cur = get_preferred_from_update_core();
if ( ! isset( $cur->response ) )
$cur->response = '';
@adamharley
adamharley / gist:1172734
Created August 26, 2011 04:57
It Was A Dark And Stormy Night by Snoopy (http://www.fivecentsplease.org/dpb/peantfaq.txt)
<?php
add_action('init', 'it_was_a_dark_and_stormy_night', 0);
function it_was_a_dark_and_stormy_night() {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="Robots" content="noindex,noarchive" />
@adamharley
adamharley / gist:1175828
Created August 27, 2011 20:20
Static content on WP posts page
<?php
$this_page = $wp_query->get_queried_object(); // Get the current page
$this_page_id = $wp_query->get_queried_object_id(); // Get the current page ID
$posts_page_id = get_option('page_for_posts'); // Get the posts page ID
if ( $this_page_id == $posts_page_id ) { // If the current page has an ID and is the posts page
$updated = 'Last updated: ' . get_the_time( $this_page->post_modified ); // $this_page is a standard post object
$content = apply_filters( 'the_content', $this_page->post_content ); // Apply ‘the_content’ filters
$content = str_replace( ']]>', ']]&gt;', $content );
@adamharley
adamharley / gist:5a77eef542d416393feb
Created November 12, 2014 17:14
send notification on OSX from command line
osascript -e 'display notification "foo" with title "bar"'
@adamharley
adamharley / tv.ahk
Created February 8, 2015 16:29
Media Remote to VLC
; Power
Browser_Home::Run, VLC\vlc.exe --intf dummy --play-and-exit pronto\power-on.wav pronto\power-off.wav, , hide
; Channel up
PgUp::Run, VLC\vlc.exe --intf dummy --play-and-exit pronto\channel-up.wav, , hide
; Channel down
PgDn::Run, VLC\vlc.exe --intf dummy --play-and-exit pronto\channel-down.wav, , hide
; TV
@adamharley
adamharley / manifest.json
Created March 7, 2015 14:31
4chan magnet links extension
{
"manifest_version": 2,
"name": "4chan magnet links",
"description": "",
"version": "0.1",
"content_scripts": [
{
"matches": [
@adamharley
adamharley / youtube-bulk-download.js
Created June 1, 2015 14:54
YouTube bulk source video download
[].forEach.call(document.querySelectorAll(".vm-download-mp4"), function(span) {
window.open(span.dataset.downloadUrl);
});