Skip to content

Instantly share code, notes, and snippets.

Avatar
🐞
Debugging

Jon Fuller Garconis

🐞
Debugging
View GitHub Profile
@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
View gravity-forms-gclid-params-on-submit.js
// 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
View change-woocommerce-giftcard-button-cta-url-in-email.php
<?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
View asana-zapier-update-task-custom-fields.js
// 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
View zapier-code-to-create-asana-status-update-for-project-item.js
// 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
View divi-dynamic-circle-number-counter-shortcode.php
<?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
View gravity-forms-full-admin-access-for-role.php
<?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
View divi-titlebar-section-for-the-events-calendar.php
<?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
@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
View zapier-asana-batch-add-to-multiple-projects.js
// 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",
@Garconis
Garconis / woocommerce-subscriptions-redirect-active-subscriber-with-logging-in.php
Created March 29, 2022 15:07
WooCommerce Subscriptions | Redirect subscriber with active WC subscription when logging in
View woocommerce-subscriptions-redirect-active-subscriber-with-logging-in.php
<?php
function freshy_redirect_role($user_login, $user) {
//var_dump($user);
if( in_array( 'subscriber',$user->roles ) ){
//The next two lines are to check if the user has an active subscription
//in the Woocommerce Subscription plugin... if so redirect to custom path instead of WooCommerce default My Account page
if( function_exists( 'wcs_user_has_subscription' ) ) {
// Indicate whether a given user has a subscription to a given product with an optional status filter
// FYI: If the status filter is left empty, the function will see if the user has a subscription of any status
// check the user's ID, for any product ID, that has an active status ... if met returns true
@Garconis
Garconis / shortcode-team-member-schema-json.php
Created March 24, 2022 18:47
WordPress | Shortcode to output JSON-LD structured data for Person schema based on CPT + ACF fields
View shortcode-team-member-schema-json.php
<?php
/* take some of the fields from the Team Member and use it to make a shortcode that outputs JSON-LD structured data for Person schema */
add_shortcode( 'fs-team-schema', 'fs_team_show_json_schema_shortcode' );
function fs_team_show_json_schema_shortcode() {
// if within an admin page and its not doing Ajax request
if ( is_admin() AND ! wp_doing_ajax() ) {
// then don't return anything since we aren't using it here
return FALSE;