Skip to content

Instantly share code, notes, and snippets.

@johnalarcon
johnalarcon / functions.php
Last active January 7, 2019 01:33
Prevent username enumeration via WordPress / ClassicPress REST API.
/**
* Prevent username enumeration via REST API
*
* This function allows normal (anonymous) access to the REST API, but makes
* sure that site usernames are not exposed through it. This code can be added
* to your theme's functions.php file.
*
* Note: there has been a report that this code may interfere with JetPack's operation.
* See https://twitter.com/PrysmcatBooks/status/1082022370817261568
*/
@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active March 28, 2024 01:45
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
// Prevent Multi Submit on WPCF7 forms
add_action( 'wp_footer', 'mycustom_wp_footer' );
function mycustom_wp_footer() {
?>
<script type="text/javascript">
var disableSubmit = false;
jQuery('input.wpcf7-submit[type="submit"]').click(function() {
jQuery(':input[type="submit"]').attr('value',"Sending...")
@isotrope
isotrope / iso-get-resized-attachment-src.php
Last active August 29, 2015 14:14 — forked from kovshenin/image-shortcode.php
Force resizes and caches images without needing to add_image_size() and bloat the /upoads/ dir
<?php
/**
* Force resizes and caches images without needing to add_image_size() and bloat the /upoads/ dir
*
* Most code is completely based on Konstantin Kovshenin's image-shortcode.php
* https://gist.github.com/kovshenin/1984363
*
* Expects the params similar to wp_get_attachment_image_src()
* http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src
*
@jeremyjaymes
jeremyjaymes / filetype-extension.php
Last active October 4, 2021 06:38
WordPress Get Attachment File Type Extension
<?php
/**
* Get attachment file type extension
*
* Requires that you have the attachment id
* See this post http://jeremyjaymes.com/display-attach…ordpress-theme/ for more explanation
*/
//* Assumes we're in a loop and have our attachment id already
$file_url = wp_get_attachment_url( $file_id );
@astockwell
astockwell / README.md
Last active November 13, 2023 01:29
PHP Video Url Parser

Youtube/Vimeo Video Url Parser

Parses URLs from major cloud video providers. Capable of extracting keys from various video embed and link urls to manipulate and access videos in various ways.

Usage

VideoUrlParser::identify_service("https://www.youtube.com/watch?v=x_8kFbZf20I&amp;feature=youtu.be");
@tableless
tableless / gist:5571702
Created May 13, 2013 21:32
Esse código deixa o texto um pouco mais legível e bem acabado nos browsers, melhorando a leitura e a visualização de letras.
body {
-webkit-font-smoothing: antialiased;
-moz-font-smoothing: antialiased;
-ms-font-smoothing: antialiased;
font-smoothing: antialiased;
-moz-text-shadow: 0 0 1px rgba(0, 0, 0, 0.01);
-ms-text-shadow: 0 0 1px rgba(0, 0, 0, 0.01);
text-shadow: 0 0 1px rgba(0, 0, 0, 0.01);
@trepmal
trepmal / wpmandrill-ms.php
Last active December 10, 2018 20:56
Network-wide options for wpMandrill. Options in Network Admin > Settings > wpMandrill MS Overwrites any per-site settings. Removes Mandrill from each site's menu (does not prevent direct access via URL).
<?php
/*
* Plugin Name: wpMandrill MS
* Plugin URI: trepmal.com
* Description: Network-wide settings for wpMandrill.
* Version: 2013.04.01
* Author: Kailey Lampert
* Author URI: kaileylampert.com
* License: GPLv2 or later
* TextDomain: wpmandrill-ms
@Viper007Bond
Viper007Bond / whatissoslow.php
Last active October 29, 2023 14:23
WordPress: Times how long it takes each filter and action to run and displays results at the end of the page. Quick and dirty.
<?php
/**
* This little class records how long it takes each WordPress action or filter
* to execute which gives a good indicator of what hooks are being slow.
* You can then debug those hooks to see what hooked functions are causing problems.
*
* This class does NOT time the core WordPress code that is being run between hooks.
* You could use similar code to this that doesn't have an end processor to do that.
*
@DrewAPicture
DrewAPicture / clean_404_emails.php
Last active September 27, 2023 09:03
Original snippet by wp-mix.com at http://wp-mix.com/wordpress-404-email-alerts/ With the improved OOP style, implementation is a lot more straightforward, just add <?php new Clean_404_Email; to the top of your 404.php template.
<?php
// Just require() this class via your theme's functions.php file.
/* Then instantiate this at the top of your 404.php file with:
if ( class_exists( 'Clean_404_Email' ) )
new Clean_404_Email;
*/
class Clean_404_Email {
var $time, $request, $blog, $email, $theme, $theme_data, $site, $referer, $string, $address, $remote, $agent, $message;