Skip to content

Instantly share code, notes, and snippets.

@johnbillion
johnbillion / wp_mail.md
Last active May 12, 2024 14:19
WordPress Emails

WordPress Emails

This document lists all the situations where WordPress sends an email, along with how to filter or disable each email.

This documentation has moved here: https://github.com/johnbillion/wp_mail

@devinsays
devinsays / woo-optimizely.php
Created September 11, 2015 21:13
Optimizely Integration with WooCommerce
<?php
// Loads Optimizely and sends revenue information on conversion page.
// Replace Optimizely script with your own ID.
function optimizely_revenue_tracking( $order_id ) {
// Lets grab the order
$order = new WC_Order( $order_id );
$price = $order->get_total();
?>
@jjeaton
jjeaton / .gitignore
Created August 5, 2015 01:54
WordPress root .gitignore. Ignore everything and then opt-in (exclude from the ignore) for your custom code.
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your
@richardbuff
richardbuff / gist:ca05441197668ae28b68
Last active August 29, 2015 14:22
Sublime Snippets For PHP echo of HTML opening and closing tags
// Save as: php-echo-open-html.sublime-snippet
<snippet>
<content><![CDATA[
echo '<${1:div} ${2:class}="${3:value}">';
]]></content>
<description>PHP echo statement with opening html tag with class</description>
<tabTrigger>phpechohtmlopen</tabTrigger>
<scope>source.php.embedded.block.html</scope>
</snippet>
@jdevalk
jdevalk / logging-helper.php
Last active December 9, 2021 16:25
This little hack enables fatal error logging for your site, without creating an error log that is insanely big.
<?php
/**
* This changes logging to only log fatal errors. This file should go in your mu-plugins directory.
*/
// Set the error logging to only log fatal errors
error_reporting( E_ERROR );
// Optional: change the location of your error log, it might be wise to put it outside your WP content dir.
// If you don't change it, the default place for this log is debug.log in your WP_CONTENT_DIR.
@Lewiscowles1986
Lewiscowles1986 / lc-svg-upload.php
Last active August 4, 2016 13:45
SVG Media Plugin for WordPress (Works since 4.1.2!)
<?php
// Please see https://github.com/Lewiscowles1986/WordPressSVGPlugin from now on
<?php
class WP_Metatags {
private static $tags = array();
public static function set_tag( $handle, $content, $type = 'name' ) {
if ( ! is_array( self::$tags ) ) {
return new WP_Error( 'metatags_already_printed', __( 'The HTML `meta` tags have already been printed.' ) );
}
@mathetos
mathetos / functions.php
Created January 23, 2015 06:18
User-Friendly Styled Content in the WordPress Editor
<?php
/*
* Add "Formats" dropdown to TinyMCE Editor
*/
function matt2015_mce_formats($buttons) {
array_unshift($buttons, 'styleselect');
return $buttons;
}
add_filter('mce_buttons_2', 'matt2015_mce_formats');
@daltonrooney
daltonrooney / get_stores_by_location.php
Last active June 29, 2023 14:14
Store locator with Advanced Custom Fields
<?php
function mbn_get_stores_by_location( $zip, $radius ) {
global $wpdb;
$radius = intval( $radius );
// we first need to get the source coordinates
$sql = "SELECT `latitude`, `longitude` FROM `wp_zip_codes` WHERE `zipcode` = '%s'";
$coords = $wpdb->get_row( $wpdb->prepare( $sql, $zip ) );
@thomasgriffin
thomasgriffin / gist:3fc79ee983329bd6c528
Last active February 13, 2017 19:05
Prevent Gravity Forms from storing entries in the database.
<?php
add_action( 'gform_after_submission', 'tgm_io_remove_form_entry' );
/**
* Prevents Gravity Form entries from being stored in the database.
*
* @global object $wpdb The WP database object.
* @param array $entry Array of entry data.
*/
function tgm_io_remove_form_entry( $entry ) {