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
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 / 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 / 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 / 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 / functions.php
Last active March 13, 2018 17:52
Gravity Forms: Change Stripe receipt description.
/* Change the description of Gravity Forms/Stripe Form Stripe Receipt (product)
----------------------------------------------------------------------------------------*/
add_filter( 'gform_stripe_charge_description', 'ag_custom_product_receipt', 10, 4 );
function ag_custom_product_receipt( $description, $strings, $entry, $submission_data ) {
$payment_amount = rgar( $submission_data, 'payment_amount' );
$description = "Payment Amount: " . $payment_amount;
GFCommon::log_debug( __METHOD__ . "(): Custom description for the product: " . $description );
@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 / loop.php
Last active October 18, 2017 13:55
Within your custom loop, get all taxonmies for a custom post type (CPT) and display each post within those taxonomies.
<?php
/* @link TBA
/* Within your custom loop, get all taxonomies for a custom post type (CPT) and display each post within those taxonomies
----------------------------------------------------------------------------------------*/
$post_type = 'your_cpt_name';
// Get all of the taxonomies for this post type
$taxonomies = get_object_taxonomies((object) array( 'post_type' => $post_type )); ?>