Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin
tommcfarlin / meta-data-serialization.php
Last active November 4, 2022 00:28
An example function used to demonstrate how meta data is typically saved in a WordPress theme or plugin. The gist is made public so that developers can contribute to the standard security boilerplate functionality in order to simplify, reduce, and improve our serialization functions.
<?php
/**
* An example function used to demonstrate how to use the `user_can_save` function
* that provides boilerplate security checks when saving custom post meta data.
*
* The ultimate goal is provide a simple helper function to be used in themes and
* plugins without the need to use a set of complex conditionals and constants.
*
* Instead, the aim is to have a simplified function that's easy to read and that uses
* WordPress APIs.
@jloosli
jloosli / gf_analytics.php
Created March 2, 2012 22:52
Google Analytics Ecommerce notification for Gravity Forms
<?php
function analytics_confirmation($confirmation, $form, $entry, $ajax = 0)
{
$isProduct = false;
foreach ($form['fields'] as $field) {
if ($field['type'] == 'product') {
$isProduct = true;
$fieldID = $field['id'];
$productSKU = $form['id'] . '-' . str_replace(" ", "_", $field['label']);
break;