Skip to content

Instantly share code, notes, and snippets.

View Garconis's full-sized avatar
🐞
Debugging

Jon Fuller Garconis

🐞
Debugging
View GitHub Profile
@melek
melek / gist:4bf187bfb85faf3864069777ea6d9cc3
Created March 13, 2023 23:01
Change CTA URL for WooCommerce Gift Card Emails
<?php
add_filter('woocommerce_gc_email_received_action_button_url', 'custom_giftcard_cta_url', 10, 1);
function custom_giftcard_cta_url($url) {
return get_home_url();
}
@Garconis
Garconis / zapier-asana-batch-add-to-multiple-projects.js
Created April 8, 2022 20:55
Asana API + Zapier | Add a task to multiple projects via Batch API
// get taskName from the custom fields above
var taskID = inputData.taskID;
// add the task to multiple projects
// notes: https://forum.asana.com/t/add-a-task-to-multiple-projects-via-api/160035/7
let body = {
"data": {
"actions": [
{
"method": "POST",
"relative_path": "/tasks/" + taskID + "/addProject",
@titodevera
titodevera / functions.php
Created December 27, 2021 19:30
Display WooCommerce product variations dropdown select on the shop, categories, catalog... pages
<?php
/**
* Display WooCommerce product variations dropdown select on the shop, categories, catalog... pages
* Tested on WordPress 5.8.2 + WooCommerce 5.9.0 + Storefront 3.9.1 + PHP 7.3.11
*
* Alberto de Vera Sevilla <hola@albertodevera.es>
*/
add_filter( 'woocommerce_loop_add_to_cart_link', function( $html, $product ) {
if ( $product->is_type( 'variable' ) ) {
@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') {
@kellenmace
kellenmace / km-remove-slug-from-custom-post-type.php
Last active March 26, 2024 00:49
Remove Slug from Custom Post Type URL in WordPress
<?php
/**
* Plugin Name: Remove Slug from Custom Post Type
* Description: Remove slug from custom post type URLs.
* Version: 0.1.0
* Author: Kellen Mace
* Author URI: https://kellenmace.com/
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
@Garconis
Garconis / translate-string-with-function.php
Last active November 21, 2023 12:38
WordPress | Translate string with PHP function
<?php
// option 1, to change text site wide
add_filter( 'gettext', 'fs_translate_strings_1', 20, 3 );
function fs_translate_strings_1( $translation, $text, $domain ) {
// STRING 1
$translation = str_ireplace( 'My Old Text', 'My New Text', $translation );
// STRING 2
$translation = str_ireplace( 'Old Text', 'New text', $translation );
return $translation;
@woogists
woogists / wc-show-cart-contents-total-ajax.php
Last active December 31, 2023 10:08
[Theming Snippets] Show cart contents / total Ajax
/**
* Show cart contents / total Ajax
*/
add_filter( 'woocommerce_add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment' );
function woocommerce_header_add_to_cart_fragment( $fragments ) {
global $woocommerce;
ob_start();
@woogists
woogists / wc-show-cart-contents-total.php
Last active October 26, 2021 20:29
[Theming Snippets] Show cart contents / total
// Use in conjunction with https://gist.github.com/woogists/c0a86397015b88f4ca722782a724ff6c
<a class="cart-customlocation" href="<?php echo wc_get_cart_url(); ?>" title="<?php _e( 'View your shopping cart' ); ?>"><?php echo sprintf ( _n( '%d item', '%d items', WC()->cart->get_cart_contents_count() ), WC()->cart->get_cart_contents_count() ); ?> - <?php echo WC()->cart->get_cart_total(); ?></a>
@Garconis
Garconis / divi-open-toggle-from-another-page.js
Last active September 14, 2020 16:39
Divi | Open toggle from another page (or same page) based on toggle ID and URL hash
// courtesy: https://bernadot.com/divi-theme-how-to-open-toggled-modules-with-a-url-hashtag/
(function($){
// open Toggle module if URL in address bar has same hash
$(window).load(function(){
var et_hash = window.location.hash;
if(window.location.hash) {
$( '.et_pb_toggle' + et_hash )
.removeClass('et_pb_toggle_close')
.addClass('et_pb_toggle_open')
}