Skip to content

Instantly share code, notes, and snippets.

Coding... Working on The WPOnion Framework with Varun

Trinity Branding trinitybranding

Coding... Working on The WPOnion Framework with Varun
View GitHub Profile
trinitybranding / how-not-to-use-wp-filter.php
Created Aug 30, 2020 — forked from damiencarbery/how-not-to-use-wp-filter.php
Use $wp_filter global to view functions attached to actions and filters
View how-not-to-use-wp-filter.php
Plugin Name: wp_filter functions
Plugin URI:
Description: List functions attached to all actions and filters. DON'T DO IT!
Author: Damien Carbery
Version: 0.1
add_action( 'wp_head', 'wp_filter_the_wrong_way' );
trinitybranding /
Created Jul 13, 2020 — forked from rahilwazir/
Change upload directory, async upload, handle upload in WordPress

Change upload directory

// Grabbed from edd plugin
function set_upload_dir() {

	// Override the year / month being based on the post publication date, if year/month organization is enabled
	if ( get_option( 'uploads_use_yearmonth_folders' ) ) {
		// Generate the yearly and monthly dirs
		$time = current_time( 'mysql' );
trinitybranding / custom-add-post-type-arg-to-admin-urls.php
Last active Jul 9, 2020
WP - Add post_type=name query arg to the admin urls, to distinguish which post type is being edited or viewed
View custom-add-post-type-arg-to-admin-urls.php
// Credits: honk31 @
// & EnterpriseBranding
// Add post_type=name query when clicking to edit or editing a post type,
// to help distinguish the post type currently being edited or viewed
add_filter('admin_url', function ($url, $path) {
trinitybranding /
Created May 14, 2020 — forked from ryansechrest/
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
trinitybranding / wpf-custom-contact-fields-filter.php
Created Apr 12, 2020
Custom Contact Fields Filter for WP Fusion
View wpf-custom-contact-fields-filter.php
// ----------------------------------------------------------------------------------------------------
// Name: Custom Contact Fields Filter for WP Fusion
// Description:
// Author:
// Version: 1.0.0
// Reference:
// ----------------------------------------------------------------------------------------------------
trinitybranding / 01-limit.php
Created Apr 8, 2020 — forked from davilera/01-limit.php
WordPress Image Size Limit
View 01-limit.php
function nelio_max_image_size( $file ) {
$size = $file['size'];
$size = $size / 1024;
$type = $file['type'];
$is_image = strpos( $type, 'image' ) !== false;
$limit = 250;
$limit_output = '250kb';
trinitybranding / wc_plugin_template_load.php
Created Mar 29, 2020 — forked from danchivz/wc_plugin_template_load.php
Override WooCommerce template files via a plugin.
View wc_plugin_template_load.php
* WooCommerce Plugin Template Loader
* Override WooCommerce template files within a custom plugin folder
* Licensed under the MIT license.
trinitybranding / oxygen-builder-defaults.json
Last active Apr 6, 2020
Oxygen Builder Defaults for Import Settings
View oxygen-builder-defaults.json
{"classes":{"body-content":{"key":"body-content","original":{"flex-grow":"1","flex-direction":"unset"}},"header-content":{"key":"header-content","original":{"height-unit":"px","container-padding-top":"0","container-padding-bottom":"0","container-padding-left":"0","container-padding-right":"0","width-unit":"%","width":"100"}},"footer-content":{"key":"footer-content","original":[]},"content":{"key":"content","original":[]},"site-content":{"key":"site-content","original":{"flex-direction":"column","display":"flex","min-height-unit":"vh","width-unit":"%","width":"100"}},"woocommerce-content":{"original":{"display":"flex"}},"body-container":{"original":{"flex-direction":"column","display":"flex","width-unit":"%","width":"100"}}},"custom_selectors":[],"style_sets":{"Uncategorized Custom Selectors":{"key":"Uncategorized Custom Selectors"}},"style_folders":[],"style_sheets":[[]],"global_settings":{"fonts":{"Text":"Poppins","Display":"Montserrat"},"scripts":{"scroll_to_hash":"true","scroll_to_hash_time":"500"},"indica
View wp-admin-modal-dialog.php
// enqueue these scripts and styles before admin_head
wp_enqueue_script( 'jquery-ui-dialog' ); // jquery and jquery-ui should be dependencies, didn't check though...
wp_enqueue_style( 'wp-jquery-ui-dialog' );
<!-- The modal / dialog box, hidden somewhere near the footer -->
<div id="my-dialog" class="hidden" style="max-width:800px">
<h3>Dialog content</h3>
<p>This is some terribly exciting content inside this dialog. Don't you agree?</p>
trinitybranding / autoconfirm-order-woocommerce.php
Created Jan 8, 2020 — forked from paaljoachim/autoconfirm-order-woocommerce.php
WooCommerce auto confirm order code snippet from Kathy. Any order marked for "processing" will be changed to complete without the need to manually click the complete button through the order screen in WooCommerce.
View autoconfirm-order-woocommerce.php
add_filter( 'woocommerce_payment_complete_order_status', 'kia_order_payment_complete_order_status', 10, 2 );
function kia_order_payment_complete_order_status( $order_status, $order_id ) {
$order = wc_get_order( $order_id );
if ( 'processing' == $order_status &&
( 'pending' == $order->status ) ) {
$order_status = 'completed';