Skip to content

Instantly share code, notes, and snippets.

@jeremyjaymes
jeremyjaymes / filetype-extension.php
Last active May 22, 2024 17:27
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 );
@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
*
// 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...")
@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active March 17, 2025 06:52
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 = () => {
@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
*/