Skip to content

Instantly share code, notes, and snippets.

View Garconis's full-sized avatar
🐞
Debugging

Jon Fuller Garconis

🐞
Debugging
View GitHub Profile
@Garconis
Garconis / gravity-forms-remove-decimals-from-currency.php
Created January 22, 2021 16:35
Gravity Forms | Update the USD currency input to remove decimals
<?php
// remove decimals (change) from Gravity Form's USD currency input
// reference: https://organicweb.com.au/wordpress/gravity-forms-price-rounding/
// useful info: https://docs.gravityforms.com/gform_currencies/
add_filter( 'gform_currencies', 'update_currency' );
function update_currency( $currencies ) {
$currencies['USD'] = array(
'name' => __( 'U.S. Dollar', 'gravityforms' ),
'symbol_left' => '$',
@Garconis
Garconis / wordpress-remove-dnt-parameter-from-vimeo.php
Last active October 19, 2022 20:39
WordPress | remove dnt=1 parameter from Vimeo oEmbed iframe URL (PHP function method)
<?php
// https://wordpress.org/support/topic/vimeo-oembed-now-has-dnt1-parameter/
// replace the dnt=1 parameter that WordPress adds to the Vimeo player when using oEmbed
function dl_oembed ( $provider, $url, $args ) {
if ( strpos( $provider, 'vimeo.com' ) !== false)
return add_query_arg( array('dnt' => false), $provider );
}
add_filter( 'oembed_fetch_url', 'dl_oembed', 10, 3 );
@Garconis
Garconis / add-post-id-as-attribute-on-html-tag-element.php
Created December 11, 2020 14:41
WordPress | Add post ID to HTML element
<?php
function add_id_to_html_element( $output ) {
global $post;
$output .= ' id="custom-id-' . $post->ID . '"';
return $output;
}
add_filter( 'language_attributes', 'add_id_to_html_element' );
@Garconis
Garconis / acf-relationship-field-posts-shortcode.php
Created October 1, 2020 17:30
ACF Relationship Field posts output with shortcode
<?php
// ACF Relationship Shortcode
function shortcode_acf_relationship_news( $atts ) {
// begin output buffering
ob_start();
// variable to check if it has any News posts chosen
$news_post_variable = get_field('news');
@Garconis
Garconis / remove-plugin-from-admin-sidebar-and-list.php
Last active February 4, 2021 21:20
WordPress | Remove WP Activity Log plugin from Admin list and Admin sidebar
<?php
/**
* Check if WP Activity Log plugin is active
**/
function hide_wp_security_audit_log(){
if ( is_plugin_active( 'wp-security-audit-log/wp-security-audit-log.php' ) ) {
// hide it from the Plugin list
add_filter('all_plugins', 'fs_remove_wp_activity_log_admin_plugin_list');
@Garconis
Garconis / date-shortcode-to-output-hours-per-day-of-week.php
Created September 8, 2020 19:42
WordPress | Shortcode to output hours based on day of week
<?php
// use examples: [nextdaytime day="+1 day"] [nextdaytime day="+2 day"]
function displaynextdaytime($atts){
$originalZone = date_default_timezone_get(); //save timezone
date_default_timezone_set(get_option('timezone_string')); //set it to your admin value
$time = strtotime($atts['day']); //time for the date() function based on our 'day' attribute
if (date('l', $time) == 'Sunday'){
$statusStr = 'Open';
$timeStr = 'Noon – 5PM';
}
@Garconis
Garconis / tracking-code-at-checkout.php
Created August 19, 2020 20:00 — forked from WPprodigy/tracking-code-at-checkout.php
Add analytics tracking to the WooCommerce order received / thank-you page
/**
* Add Tracking Code to the Order Recieved Page
*/
function wc_ninja_checkout_analytics( $order_id ) {
$order = new WC_Order( $order_id );
$currency = $order->get_order_currency();
$total = $order->get_total();
$date = $order->order_date;
?>
<!-- Paste Tracking Code Under Here -->
@Garconis
Garconis / divi-smooth-scroll-position.js
Created August 7, 2020 20:21
Divi | Adjust anchor Smooth Scroll top position based on Theme Builder fixed header height
jQuery(function($) {
window.et_pb_smooth_scroll = function($target, $top_section, speed, easing) {
var $window_width = $(window).width();
$menu_offset = -1;
var headerHeight = 143;
if ($('#wpadminbar').length && $window_width <= 980) {
@Garconis
Garconis / wordpress-remove-dnt-parameter-from-vimeo.js
Last active February 29, 2024 12:02
WordPress | remove dnt=1 parameter from Vimeo oEmbed iframe URL (jQuery method)
// https://wordpress.org/support/topic/vimeo-oembed-now-has-dnt1-parameter/
// replace the dnt=1 parameter that WordPress adds to the Vimeo player when using oEmbed
jQuery(document).ready(function($){
// find any Vimeo iframe
$('iframe[src*="player.vimeo.com"]').each(function(){
// get the src
var src = $(this).attr('src');
// replace parameter with nothing
$(this).attr('src',src.replace('dnt=1&', ''));
});
@Garconis
Garconis / acf-shortcode-check-if-value-is-set-or-exists.php
Created March 2, 2020 19:58
WordPress | ACF - Shortcode to differentiate between true and false value and if value exists at all
<?php
function fs_sc_author_byline( $atts ){
// begin output buffering
ob_start();
global $post; // if outside the loop
$byline = get_field('show_author');
if ( isset($byline) && $byline == '1') {