Skip to content

Instantly share code, notes, and snippets.

View R3V1Z3's full-sized avatar

R3V1Z3 R3V1Z3

  • Los Angeles, CA
View GitHub Profile
@R3V1Z3
R3V1Z3 / ugotsta_amazon_search_shortcode.php
Last active December 17, 2015 16:49
WordPress shortcode to easily link to Amazon search results with associate id. Includes security considerations as well as defaults to make it as simple as possible to use.
<?php
// Shortcode to easily link to Amazon search results with associate id.
// Use:
// [amazon-search search="WordPress"]WordPress[/amazon-search]
// [amazon-search search="WordPress"]
// [amazon-search search="WordPress" id="my-id"]WordPress Search on Amazon[/amazon-search]
function ugotsta_amazon_search_shortcode($search, $content = null ) {
// get attributes
extract(shortcode_atts(array(
@R3V1Z3
R3V1Z3 / clear-tape.css
Created June 3, 2013 05:51
Simple CSS to simulate slightly opaque, clear tape, using dotted borders for serrated edges.
.clear-tape {
/* Slightly opaque background */
background-color: rgba(255,255,255,0.5);
/* Dark, slightly opaque border */
border: 1px solid rgba(0,0,0,0.5);
/* Dotted side borders to simulate serrated edges */
border-left: 2px dotted rgba(0,0,0,0.2);
border-right: 2px dotted rgba(0,0,0,0.2);
/* Very slight shadow */
box-shadow: 0px 0px 4px rgba(0,0,0,0.2);
@R3V1Z3
R3V1Z3 / replace_first_occurrence.php
Last active December 18, 2015 10:59
WordPress snippet to replace first occurrence of a string with another within post content, relying on the_content filter and the PHP preg_replace function. In this example, the first occurence of "WordPress" is being replaced with a link to wordpress.org. The last parameter on line 4 restricts the replacement to only the first occurrence.
<?php
function replace_content($content)
{
$content = preg_replace('/WordPress/', '<a href="http://wordpress.org/">WordPress</a>', $content, 1);
return $content;
}
add_filter('the_content','replace_content');
?>
@R3V1Z3
R3V1Z3 / keypress.css
Created June 16, 2013 16:25
Simple way to highlight keypress or key combinations with CSS. Just add a <span> with a "keypress" class to the relevant text.
/*
Simple way to highlight keypress or key combinations with CSS.
Just add a <span> with a "keypress" class to the relevant text.
example: Press <span class="keypress">Ctrl-C</span> to copy.
*/
span.keypress {
/* for use with white background */
border: 1px solid #000;
@R3V1Z3
R3V1Z3 / change-tagline-daily.php
Created July 5, 2013 22:58
WordPress snippet to automatically change site tagline(blog description) once a day to a random item from an array. Relies on wp_schedule_event and WordPress action hooks.
<?
// create new schedule_change action hook
add_action('schedule_change', 'change_description');
// function to schedule event if it doesn't exist
function activate_change() {
// check if schedule_change action/event already exists
if ( !wp_next_scheduled( 'schedule_change' ) ) {
// schedule new event to trigger schedule_change daily
wp_schedule_event( time(), 'daily', 'schedule_change');
@R3V1Z3
R3V1Z3 / marketpress-global-product-grid.css
Created September 4, 2013 10:33
CSS for the MarketPress e-Commerce plugin for WordPress to display products in a 3-column grid format.
div#mp_product_list .product {
display: inline;
float: left;
width: 29%;
margin: 2%;
}
div#mp_product_list .product:nth-child(3n+1) {
clear: both;
}
@R3V1Z3
R3V1Z3 / rwpaint_scanlines.js
Created September 18, 2013 18:57
Simple scanline effect for RealWorld Paint, usable as a layer style or effect via the JavaScript layer style or custom operation effect. The effect can be horizontal, vertical or both using the scanline_x and scanline_y variables and the alpha value of the effect can be adjusted with scanline_alpha.
var img = Document.RasterImage;
var sizeX = img.sizeX;
var sizeY = img.sizeY;
var scanline_x = 2;
var scanline_y = 0;
var scanline_alpha = 0;
for (var x = 0; x < sizeX; x += 1) {
for (var y = 0; y < sizeY; y += 1) {
if (x%scanline_x === 0) {
@R3V1Z3
R3V1Z3 / future-pinball-video.ahk
Last active December 23, 2015 17:29
Autohotkey script to load and run user-selected Future Pinball tables for video recording and screen capture purposes. Designed to work alongside MSI Afterburner for video and screen captures.
;Autohotkey script to load and run user-selected Future Pinball tables
;for video recording and screen capture purposes
#NoEnv
CoordMode, Mouse, Window
SendMode Input
#SingleInstance Force
SetTitleMatchMode 2
DetectHiddenWindows On
#WinActivateForce
@R3V1Z3
R3V1Z3 / buddypress-exclude-category-slugs-from-activity-stream.php
Created October 21, 2013 03:42
Simple plugin for WordPress Multi-site and BuddyPress to restrict categories, by slug, from the Activity Stream. It's a Multi-site plugin, meant to be installed in wp-content/mu-plugins.
<?php
/*
Simple, Multi-site plugin for WordPress and BuddyPress to restrict categories, by slug, from the Activity Stream
Please note, his is a Multi-site plugin meant to be installed in wp-content/mu-plugins/ folder in a Multi-site WordPress install
code derivative of snippet by imath at:
http://buddypress.org/support/topic/possible-to-exclude-post-categories-in-activity-stream-and-make-a-user-profile-private-like-with-pri/
*/
function exclude_category_slugs_from_activity_stream( $post_id, $post ){
@R3V1Z3
R3V1Z3 / chat-template.php
Created July 21, 2014 18:43
Very simple, relatively empty page template for use with WPMU DEV Chat plugin to facilitate chats in popup window.
<?php
/**
Template Name: Chat Template
*/
?>
<html>
<head>
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
<style type="text/css">