Skip to content

Instantly share code, notes, and snippets.

Avatar
☺️
Be the reason someone smiles today.

Kevin Donnigan anythinggraphic

☺️
Be the reason someone smiles today.
View GitHub Profile
@anythinggraphic
anythinggraphic / functions.php
Created Aug 26, 2021
WordPress: Redirect the Plugins and Plugins > Add New pages to the WP Admin Dashboard.
View functions.php
<?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 Aug 25, 2021
WordPress: Hide plugins from displaying on the WP Admin > Plugins page.
View functions.php
<?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 Mar 16, 2021 — forked from feastdesignco/add_woocom_support
Adds back in woocommerce functionality removed from Feast themes 4.1.5+ - not tested
View add_woocom_support
// 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 Feb 27, 2021 — forked from spivurno/gw-gravity-forms-unrequire-required-fields-usage.php
Gravity Wiz // Gravity Forms Unrequire Required Fields for Speedy Testing
View gw-gravity-forms-unrequire-required-fields-usage.php
<?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 Feb 27, 2021
Remove widgets on the WP Admion Dashboard page.
View wp-cleanup.php
<?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 Jan 14, 2021 — forked from ryansechrest/php-style-guide.md
PHP style guide with coding standards and best practices.
View php-style-guide.md

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 Jan 3, 2021
Gravity Forms - Allow certain HTML tags, remove link (a, href) tags, and prevent http and https from being submitted during validation.
View functions.php
<?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 Mar 13, 2018
Gravity Forms: Change Stripe receipt description.
View functions.php
/* 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 Mar 6, 2021
Script to move elements around based on window width
View jquery.js
// @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 Oct 18, 2017
Within your custom loop, get all taxonmies for a custom post type (CPT) and display each post within those taxonomies.
View loop.php
<?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 )); ?>