Skip to content

Instantly share code, notes, and snippets.

@zackkatz
zackkatz / EDD Admin-Only Test Payments
Last active July 24, 2018 04:51
Allow admins to use test payments in Easy Digital Downloads for a live store.
<?php
/*
Plugin Name: EDD Test Payments
Plugin URI: https://gist.github.com/zackkatz/7418620
Description: Allow admins to use Test Payment even when it's not enabled.
Author: Katz Web Services, Inc.
Version: 1.0
Author URI: http://katz.co
*/
@zackkatz
zackkatz / bc-texture-swatch
Created January 30, 2014 21:39
Force Bigcommerce to use larger images for texture swatches
/**
* Convert tiny thumbnails to larger previews for product texture swatches
* @group Product
*
*/
jQuery('.textureContainer .thumbnail').attr('style', function() {
return jQuery(this).attr('style').replace('.thumbnail.png', '.preview.png');
});
@zackkatz
zackkatz / add-plugin-link-to-admin-bar.php
Last active September 16, 2017 20:45
Add link to WordPress Plugins page in top-level Admin Bar and Site Name submenu.
@zackkatz
zackkatz / require-title.js
Created May 22, 2014 17:40
Require a title in the WordPress Edit Post screen
$('body').on( 'submit.edit-post', '#post', function () {
// If the title isn't set
if( $("#title").val().length === 0 ) {
// Show the alert
alert('A title is required.');
// Hide the spinner
$('#major-publishing-actions .spinner').hide();
@zackkatz
zackkatz / debug-bar-gravity-forms-noconflict.php
Created July 12, 2014 19:56
The Debug Bar plugin breaks on Gravity Forms admin pages when No Conflict Mode is turned on. This plugin fixes that issue.
<?php
/*
Plugin Name: Debug Bar for Gravity Forms No-Conflict Mode
Plugin URI: http://katz.co
Description: Enable debug bar when Gravity Forms has No Conflict Mode on.
Version: 1.0
Author: Katz Web Services, Inc.
Author URI: http://katz.co
*/
add_filter( 'gform_noconflict_scripts', 'debug_bar_add_gf_noconflict');
@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.
@zackkatz
zackkatz / edd-w3tc-fix-discount.php
Last active August 29, 2015 14:04
Prevent Easy Digital Downloads discounts from being cached by W3TC
<?php
/**
* Plugin Name: EDD W3TC Fix Discount Codes
* Plugin URI: http://gravityview.co
* Description: Fix discount code caching issues for Easy Digital Downloads when using W3 Total Cache
* Version: 1.1
*/
if( function_exists( 'wp_suspend_cache_addition' ) ) {
@zackkatz
zackkatz / get-readme-content
Created October 15, 2014 21:36
Get readme response from the readme.txt configuration in EDD Software Licensing
/**
* Get readme response from the readme.txt configuration in EDD Software Licensing
*
* @param int $id Download ID
* @return array|boolean Readme array if exists; NULL if not exists
*/
function get_edd_sl_readme( $id = NULL ) {
if( !empty( $id ) && function_exists('_edd_sl_get_readme_data') ) {
@zackkatz
zackkatz / plugin-activation-functions.php
Last active March 21, 2019 14:44
Functions to get plugin activation and deactivation links
<?php
/**
* Get the Activation URL for a plugin
* @param string $plugin_path Directory and file name of plugin, like: `hello-dolly/hello.php`
* @return string URL to activate the plugin
*/
function get_plugin_activation_link( $plugin_path = 'hello-dolly/hello.php' ) {
return wp_nonce_url(admin_url('plugins.php?action=activate&amp;plugin='.$plugin_path), 'activate-plugin_'.$plugin_path);
}
@zackkatz
zackkatz / gravityview-change-entry-creator-show-all-users.php
Last active August 29, 2015 14:07
Show all users in the Change Entry Creator dropdown (instead of just 300)
<?php
/*
Plugin Name: GravityView - Show All Users in Change Entry Creator
Plugin URI: http://gravityview.co
Description: Show all users in the Change Entry Creator dropdown (instead of just 300)
Version: 1.1
Author: Katz Web Services, Inc.
Author URI: http://www.katzwebservices.com
Text Domain: gravityview
License: GPLv2 or later