Skip to content

Instantly share code, notes, and snippets.

View anythinggraphic's full-sized avatar
☺️
Be the reason someone smiles today.

Kevin Donnigan anythinggraphic

☺️
Be the reason someone smiles today.
View GitHub Profile
@anythinggraphic
anythinggraphic / functions.php
Last active September 22, 2022 22:03
Give each Gravity Forms entry a unique ID
<?php
/* Put a unique ID on Gravity Form (single form ID) entries.
----------------------------------------------------------------------------------------*/
add_filter("gform_field_value_uuid", "get_unique");
function get_unique(){
$prefix = "SLP2017-"; // update the prefix here
do {
@anythinggraphic
anythinggraphic / functions.php
Created August 26, 2021 15:03
WordPress: Redirect the Plugins and Plugins > Add New pages to the WP Admin Dashboard.
<?php
/**
* WP Admin Page Redirects.
*
* Redirect the Plugins and Plugins > Add New pages to the WP Admin Dashboard in
* order to prevent the installation of plugins for overzealous editors.
*
* @since 1.0.0
*
@anythinggraphic
anythinggraphic / functions.php
Last active August 25, 2021 15:19
WordPress: Hide plugins from displaying on the WP Admin > Plugins page.
<?php
/**
* Hide Plugins.
*
* Removes plugin(s) from displaying on the list of installed plugins on
* the WP Admin > Plugins page.
*
* @param array $hidden_plugins Array of plugins to hide.
*
@anythinggraphic
anythinggraphic / add_woocom_support
Created March 16, 2021 16:11 — forked from feastdesignco/add_woocom_support
Adds back in woocommerce functionality removed from Feast themes 4.1.5+ - not tested
// Add support for WooCommerce features.
add_theme_support( 'woocommerce' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
add_theme_support( 'wc-product-gallery-zoom' );
if ( class_exists( 'WooCommerce', false ) ) {
require_once FEAST_DIR . 'lib/woocommerce.php'; // note: doesn't exist anymore
}
@anythinggraphic
anythinggraphic / jquery.js
Last active March 6, 2021 01:02
Script to move elements around based on window width
// @link https://mattrad.uk/move-elements-around-using-jquery/
// Script to move elements around based on window width
jQuery(function($) {
// Store the references outside the event handler:
var $window = $(window);
var $pane1 = $('#search-dropdown');
var $pane2 = $('.social-icons');
function checkWidth() {
@anythinggraphic
anythinggraphic / wp-cleanup.php
Last active February 27, 2021 21:40
Remove widgets on the WP Admion Dashboard page.
<?php
/**
* Remove widgets on the WP Admion Dashboard page.
*
* @see https://digwp.com/2014/02/disable-default-dashboard-widgets/
* @see https://anythinggraphic.net
* @since 1.0.0
*/
function anythinggraphic_unset_dashboard_widgets() {
@anythinggraphic
anythinggraphic / gw-gravity-forms-unrequire-required-fields-usage.php
Last active February 27, 2021 01:35 — forked from spivurno/gw-gravity-forms-unrequire-required-fields-usage.php
Gravity Wiz // Gravity Forms Unrequire Required Fields for Speedy Testing
<?php
# Basic Usage
# requires that the user be logged in as an administrator and that a 'gwunrequire' parameter be added to the query string
# http://youurl.com/your-form-page/?gwunrequire=1
new GWUnrequire();
# Enable for All Users (Including Visitors)
# still requires the 'gwunrequire' parameter be added to the query string
new GWUnrequire( array(
@anythinggraphic
anythinggraphic / php-style-guide.md
Created January 14, 2021 17:17 — forked from ryansechrest/php-style-guide.md
PHP style guide with coding standards and best practices.

PHP Style Guide

All rules and guidelines in this document apply to PHP files unless otherwise noted. References to PHP/HTML files can be interpreted as files that primarily contain HTML, but use PHP for templating purposes.

The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

Most sections are broken up into two parts:

  1. Overview of all rules with a quick example
  2. Each rule called out with examples of do's and don'ts
@anythinggraphic
anythinggraphic / functions.php
Last active January 3, 2021 21:02
Gravity Forms - Allow certain HTML tags, remove link (a, href) tags, and prevent http and https from being submitted during validation.
<?php
/**
* Gravity Forms: Allowable tags.
* By returning specific HTML tags, we can prevent link tags from being submitted.
* The links will simply be stripped out without a warning to the user.
*
* @author Anything Graphic
* @link https://anythinggraphic.net
* @link https://community.gravityforms.com/t/how-to-block-links-in-text-field-resolved/5865/5
@anythinggraphic
anythinggraphic / gravity-forms-notification-popup-keep-form.php
Last active November 27, 2020 21:30
Gravity Forms Notification Popup (Genesis Framework)
<?php
//* OPTIONAL STEP - Keep the form disappearing.
//* Gravity Forms notification popup instead of the page redirect or AJAX notification.
//* Props to @WilliamAlexander in the comments
//* @link https://anythinggraphic.net/gravity-forms-notification-popup
add_filter( 'gform_confirmation', 'ag_custom_confirmation', 10, 4 );
function ag_custom_confirmation( $confirmation, $form, $entry, $ajax ) {
add_filter( 'wp_footer', 'ag_overlay');