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 / 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 Nov 13, 2017
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 )); ?>
@anythinggraphic
anythinggraphic / functions.php
Last active Aug 31, 2017
Add custom Twitter Social Share descriptions for Yoast SEO for Archive pages
View functions.php
<?php
/* @link https://anythinggraphic.net/yoast-seo-add-custom-social-share-images-for-archive-category-pages-in-wordpress
/* Add custom Twitter Social Share descriptions for Yoast SEO for Archive pages
----------------------------------------------------------------------------------------*/
add_filter( 'wpseo_metadesc', 'ag_yoast_seo_tw_share_descriptions', 10, 1 );
function ag_yoast_seo_tw_share_descriptions( $desc ) {
if( is_post_type_archive( 'portfolio' ) ) {
$desc = 'Design and development projects by Anything Graphic.';
}
if( is_category( 'categoryname' ) ) {
@anythinggraphic
anythinggraphic / functions.php
Last active Aug 31, 2017
Add custom Facebook Social Share descriptions for Yoast SEO for Archive pages
View functions.php
<?php
/* @link https://anythinggraphic.net/yoast-seo-add-custom-social-share-images-for-archive-category-pages-in-wordpress
/* Add custom Facebook Social Share descriptions for Yoast SEO for Archive pages
----------------------------------------------------------------------------------------*/
add_filter( 'wpseo_opengraph_desc', 'ag_yoast_seo_fb_share_descriptions' );
function ag_yoast_seo_fb_share_descriptions( $desc ) {
if( is_post_type_archive( 'posttypename' ) ) {
$desc = 'Design and development projects by Anything Graphic.';
}
if( is_category( 'categoryname' ) ) {
View functions.php
<?php
/* @link https://anythinggraphic.net/yoast-seo-add-custom-social-share-images-for-archive-category-pages-in-wordpress
/* Add custom Twitter Social Share images for Yoast SEO for Archive pages
----------------------------------------------------------------------------------------*/
add_filter( 'wpseo_twitter_image', 'ag_yoast_seo_tw_share_images', 10, 1 );
function ag_yoast_seo_tw_share_images( $img ) {
if( is_post_type_archive( 'archivename') ) {
$img = get_stylesheet_directory_uri().'/images/your-image-file.jpg';
}
if( is_category( 'categoryname') ) {{