Skip to content

Instantly share code, notes, and snippets.

View cameronjonesweb's full-sized avatar
👨‍👦

Cameron Jones cameronjonesweb

👨‍👦
View GitHub Profile
@davewarfel
davewarfel / default-wordpress-blocks-sass.scss
Last active November 8, 2023 11:31
WordPress Blocks Styles - Cleaned Up, Commented & Sassified
/**
* WordPress Blocks
*
* Default block styling included with WordPress core.
* Provides a better starting point for WordPress theme developers,
* especially when using Sass.
*
* @link https://github.com/WordPress/WordPress/blob/master/wp-includes/css/dist/block-library/style.css
*
* Most styles from the above file are included.
@EricBusch
EricBusch / deploy.sh
Last active April 15, 2023 13:10
Deploy your plugin to the WordPress.org SVN plugin repository from your GitHub Repository.
#! /bin/bash
#
# Script to deploy from Github to WordPress.org Plugin Repository
# A modification of a number of different sources:
# @link https://github.com/deanc/wordpress-plugin-git-svn
# @link https://github.com/GaryJones/wordpress-plugin-svn-deploy
# @link https://github.com/thenbrent/multisite-user-management/blob/master/deploy.sh
#
# Accompanying Tutorial Here:
# @link https://ericbusch.net/?p=106
@galbaras
galbaras / insert_ad_after_block.php
Last active November 22, 2017 01:55
Insert Google ad after specific top-level text block in WordPress post
/*
* This code is for WordPress and should be used in functions.php of the active theme.
*
* Before using it, replace "ADVERTISER ID" with your own advertiser ID and "SLOT ID" with your own slot ID
* (you can get both in Google AdSense). For best results, use a reponsive ad unit.
*
* If your posts contain "pre", "noscript" or some other type of HTML block, add them to $block_tags.
*
* You can change the insertion point by changing $after_block.
*
@pento
pento / rainbow-bar.php
Last active September 26, 2017 21:20
WordPress Rainbow Bar
<?php
/*
* Plugin Name: Rainbow Bar!
*/
function rainbow_bar() {
?>
<style type="text/css">
#wpadminbar {
@timothyjensen
timothyjensen / functions.php
Last active October 13, 2019 05:14
Retrieves all post meta data according to the structure in the $config array. Provides a convenient and more performant alternative to ACF's `get_field()`. This function is especially useful when working with ACF repeater and flexible content fields. See details at https://www.timjensen.us/acf-get-field-alternative.
<?php
/**
* Retrieves all post meta data according to the structure in the $config
* array.
*
* Provides a convenient and more performant alternative to ACF's
* `get_field()`.
*
* This function is especially useful when working with ACF repeater fields and
* flexible content layouts.
@OriginalEXE
OriginalEXE / pe-customize-controls.css
Last active June 26, 2023 05:07
Extending WordPress Customizer Panels and Sections to allow nesting
.in-sub-panel #customize-theme-controls .customize-pane-child.current-panel-parent,
#customize-theme-controls .customize-pane-child.current-section-parent {
-webkit-transform: translateX(-100%);
-ms-transform: translateX(-100%);
transform: translateX(-100%);
}
@scottbuscemi
scottbuscemi / woo-gist.php
Created July 13, 2016 17:34
WooCommerce minimum order amount for subtotal only (don't include shipping+tax)
// Add to your functions.php file
add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' );
add_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' );
function wc_minimum_order_amount() {
// Set this variable to specify a minimum order value
$minimum = 50;
if ( WC()->cart->subtotal < $minimum ) {
@irazasyed
irazasyed / weight-utility.php
Created January 8, 2016 09:21
PHP: Utility function for getting random values with weighting.
<?php
/**
* getRandomWeightedElement()
* Utility function for getting random values with weighting.
* Pass in an associative array, such as array('A'=>5, 'B'=>45, 'C'=>50)
* An array like this means that "A" has a 5% chance of being selected, "B" 45%, and "C" 50%.
* The return value is the array key, A, B, or C in this case. Note that the values assigned
* do not have to be percentages. The values are simply relative to each other. If one value
* weight was 2, and the other weight of 1, the value with the weight of 2 has about a 66%
* chance of being selected. Also note that weights should be integers.
@spivurno
spivurno / gw-gravity-forms-skip-registration-for-logged-in-users.php
Last active October 12, 2021 15:08
Gravity Wiz // Gravity Forms // Skip Registration for Logged in Users
<?php
/**
* Skip Registration for Logged In Users
* http://gravitywiz.com/2012/04/24/skip-user-registration-for-logged-in-users/
* Works for GF User Registration 3.0 and greater.
*/
add_filter( 'gform_is_delayed_pre_process_feed', 'maybe_delay_feeds', 10, 4 );
function maybe_delay_feeds( $is_delayed, $form, $entry, $slug ) {
if ( is_user_logged_in() && $slug == 'gravityformsuserregistration' ) {
return gf_user_registration()->has_feed_type( 'create', $form );
@johnbillion
johnbillion / wp_mail.md
Last active May 12, 2024 14:19
WordPress Emails

WordPress Emails

This document lists all the situations where WordPress sends an email, along with how to filter or disable each email.

This documentation has moved here: https://github.com/johnbillion/wp_mail