Skip to content

Instantly share code, notes, and snippets.

@adamcrampton
adamcrampton / wpAdminWidgetImageUploader.js
Last active May 3, 2019 01:10
WordPress - JS for uploading images to widget
/**
* Steps:
* 1. Pop this into your theme's assets/js directory, set the filename as widgets.js (or add JS to existing widgets.js)
* 2. See the other gist for widget PHP instructions if you haven't already
* 3. Profit++
*/
// ============================================
// Custom JavaScript used in Widgets (WP Admin)
// ============================================
// Image uploader
@adamcrampton
adamcrampton / sidebarBanner.php
Created May 3, 2019 00:55
WordPress widget - linked image for sidebar
<?php
/**
* Steps:
* 1. Pop this in your theme's functions.php file
* 2. See the other gist for JS instructions
* 3. Profit
*/
// Register widget area.
function sidebar_widgets_init() {
@grappler
grappler / hide-view.php
Last active February 6, 2023 03:24
Here is how to remove the "view" button from all three locations for a custom post type.
<?php
/**
* Hides the 'view' button in the post edit page
*
*/
function hv_hide_view_button() {
$current_screen = get_current_screen();
@pento
pento / commercial-client.php
Created July 2, 2013 12:29
Sample Commercial Plugin update server and client
<?php
/*
* Plugin Name: Commercial Client
* Plugin URI: http://pento.net/
* Description: A sample client plugin for showing updates for non-WordPress.org plugins
* Author: pento
* Version: 0.1
* Author URI: http://pento.net/
* License: GPL2+
*/
@thenbrent
thenbrent / wp_rewrite_rules.log
Created August 7, 2012 23:46
Default WordPress Rewrite Rules
[rules] => Array (
[category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2]
[category/(.+?)/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2]
[category/(.+?)/page/?([0-9]{1,})/?$] => index.php?category_name=$matches[1]&paged=$matches[2]
[category/(.+?)/?$] => index.php?category_name=$matches[1]
[tag/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?tag=$matches[1]&feed=$matches[2]
[tag/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?tag=$matches[1]&feed=$matches[2]
[tag/([^/]+)/page/?([0-9]{1,})/?$] => index.php?tag=$matches[1]&paged=$matches[2]
[tag/([^/]+)/?$] => index.php?tag=$matches[1]
[type/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?post_format=$matches[1]&feed=$matches[2]
@chrisjlee
chrisjlee / wp.sh
Created August 6, 2012 21:24 — forked from bgallagh3r/wp.sh
Wordpress: Bash Install Script
#!/bin/bash
echo “Database Name: ”
read -e dbname
echo “Database User: ”
read -e dbuser
echo “Database Password: ”
read -s dbpass
echo “run install? (y/n)”
read -e run
if [ "$run" == n ] ; then
@markjaquith
markjaquith / gist:2653957
Created May 10, 2012 15:36
WordPress Fragment Caching convenience wrapper
<?php
/*
Usage:
$frag = new CWS_Fragment_Cache( 'unique-key', 3600 ); // Second param is TTL
if ( !$frag->output() ) { // NOTE, testing for a return of false
functions_that_do_stuff_live();
these_should_echo();
// IMPORTANT
$frag->store();
// YOU CANNOT FORGET THIS. If you do, the site will break.
@ocean90
ocean90 / box-shadow.html
Last active April 11, 2024 13:54
CSS3 Box Shadow, only top/right/bottom/left and all
<!DOCTYPE html>
<html>
<head>
<title>Box Shadow</title>
<style>
.box {
height: 150px;
width: 300px;
margin: 20px;
@krishnakummar
krishnakummar / datedifference.php
Created June 29, 2011 12:34
Humanize date differences in PHP (like facebook - Eg: 2 days ago, 14 hours ago, few seconds ago).
#!/usr/bin/env php
# This function prints the difference between two php datetime objects
# in a more human readable form
# inputs should be like strtotime($date)
# Adapted from https://gist.github.com/207624 python version
function humanizeDateDiffference($now,$otherDate=null,$offset=null){
if($otherDate != null){
$offset = $now - $otherDate;
}