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 / wordpress-impreza-accordion-shortcode-acf-repeater-field.php
Last active May 10, 2023 16:39
WordPress + Impreza | Create shortcode to output accordions based on ACF repeater fields
<?php
/* ACF Case Study Key Features accordion shortcode recreation, used within the Case Study page template */
// [fs_key_features_accordion]
function fs_sc_key_features_accordion( $atts ){
// begin output buffering
ob_start();
if( have_rows('cs_key_website_features') ) {
@Garconis
Garconis / zapier-asana-search-tasks.js
Created April 28, 2023 17:07
Asana API + Zapier | search for a task with criteria and return GID
const res = await fetch('https://app.asana.com/api/1.0/workspaces/9876543/tasks/search?projects.all=1204442834902858&sections.any=1204442834902861,1204442834902862&completed=false&text=' + inputData.foundText + '&opt_fields=gid', {
headers: {
'Authorization': 'Bearer 0/1234567'
}
});
// Sends a JSON response composed of the specified data
const body = await res.json();
// Grabs the "data" content of the response
const data = body.data;
@Garconis
Garconis / zapier-asana-duplicate-task.js
Created April 27, 2023 18:18
Asana API + Zapier | Duplicate a task via API
// Duplicate the Asana FS:Audit task template that we made (note, it's not a "real" Task Template, but just a straggling task that sits in the project) and set the name based on the task name of the CRM task that got completed earlier.
// get taskName from the custom fields above
var taskTitle = inputData.taskName;
var taskID = "555555555"; // task to duplicate
// notes: https://forum.asana.com/t/now-available-project-and-task-duplication/49371
let body = {
"data": {
"include": [
"assignee",
"attachments",
@Garconis
Garconis / gravity-forms-gclid-params-on-submit.js
Created March 20, 2023 17:38
Gravity Forms | Log a parameter value to local storage and send with Gravity Form entry, such as Google Ads GCLID or other params
// get parameters of URL
function getParam(p) {
var match = RegExp('[?&]' + p + '=([^&]*)').exec(window.location.search);
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
}
// set expiration date
function getExpiryRecord(value) {
var expiryPeriod = 90 * 24 * 60 * 60 * 1000; // 90 day expiry in milliseconds
var expiryDate = new Date().getTime() + expiryPeriod;
@Garconis
Garconis / change-woocommerce-giftcard-button-cta-url-in-email.php
Last active March 14, 2023 16:13 — forked from melek/gist:4bf187bfb85faf3864069777ea6d9cc3
WooCommerce | 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 / asana-zapier-update-task-custom-fields.js
Last active March 7, 2023 22:23
Asana | Update custom fields of a task when using Zapier code
// this is wrapped in an `async` function
// you can use await throughout the function
var adCampaign = inputData.adCampaign; // get the variable from the adCampaign
var adKeyword = inputData.adKeyword; // get the variable from the adKeyword
var taskID = inputData.taskID; // get the variable from the taskID
var finalAdKeyword = "";
if ( (adKeyword == 'None') || (adKeyword == 'No Terms') || (adKeyword == '[channeldrilldown3]')) {
var finalAdKeyword = "";
}
@Garconis
Garconis / zapier-code-to-create-asana-status-update-for-project-item.js
Created March 3, 2023 22:20
Asana | Create a Status Update to the Project/Portfolio item
// this is wrapped in an `async` function
// you can use await throughout the function
// https://developers.asana.com/reference/createstatusforobject
// get parentID (the ID of the unique project)
var parentID = inputData.parentID;
let body = {
"data": {
@Garconis
Garconis / divi-dynamic-circle-number-counter-shortcode.php
Last active March 3, 2023 17:05
Divi | Shortcode to create dynamic number counter with a custom field
<?php
// https://www.youtube.com/watch?v=y1hHhUT_mfM
// example usage: [fs_dynamic_number_counter number_field="counter_1" title="Counter 1" percent="" id="" class=""]
// set the number_field value to be whatever the custom field name is that has your counter number
// set the title value to be whatever you want the counter's title to be
// set the percent value to "off" if you don't want the percent sign, otherwise leave it blank/empty for it to show
// set the id or class values if you want either of those on your module
// e.g., if you add a class, you could use it to add $ or + before or after the number value via CSS (by adding these to your stylesheet)
// e.g., .counter-dollar-before .percent-value::before { content:'$'; }
// e.g., .counter-plus-after .percent-value::after { content:'+'; }
@Garconis
Garconis / gravity-forms-full-admin-access-for-role.php
Created October 12, 2022 15:06
Gravity Forms | Give the Editor role full access to Gravity Forms in the backend
<?php
// Give the Editor role full access to Gravity Forms
function fs_add_grav_forms(){
$role = get_role('editor');
$role->add_cap('gform_full_access');
}
add_action('admin_init','fs_add_grav_forms');
@Garconis
Garconis / divi-titlebar-section-for-the-events-calendar.php
Created September 19, 2022 21:35
WordPress | Function to check for certain The Events Calendar pages and Community template
<?php
// triggers on all Divi pages before the main content
add_action( 'et_before_main_content', 'fs_banner' );
function fs_banner(){
global $post_type;
// tribe_is_community_edit_event_page() Returns true only if the Community Events submission page is currently being viewed (Edit Event, Submit Event/Add New Group)
// tribe_is_community_my_events_page() Returns true only if the Community Events “My Events” page is currently being viewed (My Groups)
// need: Edit Venue/Location, Edit an Organizer
// see list in /the-events-calendar-community-events/src/functions/template-tags.php