Skip to content

Instantly share code, notes, and snippets.

@luetkemj
luetkemj / wp-query-ref.php
Last active September 14, 2024 13:06
WP: Query $args
// This gist is now maintained on github at https://github.com/luetkemj/wp-query-ref
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.github.io
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/4.9.4/src/wp-includes/query.php
*/
@jonathanmoore
jonathanmoore / gist:2640302
Created May 8, 2012 23:17
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@zourbuth
zourbuth / user_meta_key.php
Created October 17, 2012 07:39
Get All WordPress User Meta Keys
<?php
/**
* Returns all unique meta key from user meta database
*
* @param no parameter right now
* @retun std Class
* @todo do what you do for each meta key.
*/
function get_user_meta_key() {
@tinabeans
tinabeans / template.html
Last active February 13, 2024 09:18
A super-barebones single-column responsive email template, assuming a max-width of 540px. Read about it on the Fog Creek blog.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Single-Column Responsive Email Template</title>
<style>
@media only screen and (min-device-width: 541px) {
.content {
@ascottmccauley
ascottmccauley / gist:3c3ad4e1772059234be5
Created June 14, 2014 12:36
WordPress Honeypot Functions
/**
* Add a spam-trap to comment form and registration form
*
* Include a hidden field called name and set it to hidden. If it receives an input, we have a bot!
*/
function get_decoy_fields() {
$decoys = array( 'firstname', 'lastname', 'email2', 'address', 'address2', 'city', 'state', 'zipcode', 'telephone', 'phone');
return $decoys;
}
function get_dailyID() {
@sareiodata
sareiodata / empty-wp-plugin.php
Created July 2, 2014 08:45
Empty WordPress plugin
<?php
/**
* Plugin Name: Name Of The Plugin
* Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates
* Description: A brief description of the Plugin.
* Version: The Plugin's Version Number, e.g.: 1.0
* Author: Name Of The Plugin Author
* Author URI: http://URI_Of_The_Plugin_Author
* License: A "Slug" license name e.g. GPL2
*/
@zackkatz
zackkatz / gf-validate-edd-license-key.php
Last active May 3, 2021 09:10
Validate Easy Digital Downloads License Key Field in a Gravity Forms Submission
/**
* Validate a Gravity Forms license submission against EDD remote validation
*
* In Gravity Forms, for the text field you want to use as the license key entry,
* go to Advanced tab, check the "Allow field to be populated dynamically" checkbox,
* then enter the value as `edd-{download_id}`, where {download_id} is the, you guessed
* it, EDD Download ID.
*
* @param array $is_valid_and_form_array Gravity Forms passes an array with two keys: `is_valid` (boolean) and `form` (Gravity Forms form array)
* @return array Same format as incoming.
@sareiodata
sareiodata / gist:0d70d54e6167cddd7c44
Last active August 29, 2015 14:06
hide default edit profile fields in the backend
/*
* Hide Default Edit Profile Fields in the backend
*/
function wppb_hide_personal_options(){
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('form#your-profile > h3:first').hide();
$('form#your-profile > table:first').hide();
@TBD
TBD / ikea_price_check.bookmarklet
Created August 29, 2015 19:31
IKEA price check
javascript:(function(){var request=new XMLHttpRequest();request.open("GET",window.location.href.replace(/ro\//g,'hu/'),false);request.send(null);var hidden=document.body.appendChild(document.createElement("div"));hidden.style.display="none";hidden.innerHTML=request.responseText;price=hidden.querySelector('#schemaProductPrice');if(price){price=parseInt(hidden.querySelector('#schemaProductPrice').textContent.replace(/\./gm,''));price=(price*1.41/100).toFixed(2)+" lei ( "+price+" HUF )";}else{price="N/A";}price_hu=document.createElement("div");price_hu.innerHTML=price;refNode=document.querySelector('#price1');refNode.parentNode.insertBefore(price_hu,refNode.nextSibbling);})()
@octalmage
octalmage / roles.md
Last active May 14, 2023 17:43
Default WordPress user roles and capabilities.

WordPress v4.3.1

Admin wp_capabilities wp_user_level 10

a:1:{s:13:"administrator";b:1;}

Contributor wp_capabilities wp_user_level 1