Skip to content

Instantly share code, notes, and snippets.

Avatar

Clifford cliffordp

View GitHub Profile
@cliffordp
cliffordp / localwp-no-conflict.sh
Created Jul 20, 2022 — forked from nickpelton/localwp-no-conflict.sh
zsh avoid conflicts with localwp shell and custom php, mysql, or other custom binaries
View localwp-no-conflict.sh
# Don't load custom stuff if LocalWP shell
if [[ -z ${PHPRC+z} ]]
then
echo "Export custom binaries"
# Eg.
# export PATH="/opt/homebrew/opt/php@7.4/bin:$PATH"
# export PATH="/opt/homebrew/opt/mysql-client/bin:$PATH"
fi
@cliffordp
cliffordp / ifStringIsBlankOneElseZero.js
Last active Apr 9, 2022
Zoho Flow to check for blank value
View ifStringIsBlankOneElseZero.js
int ifStringIsBlankOneElseZero(string toCheck)
{
// This snippet: https://gist.github.com/cliffordp/9245df1dd6605a9f4ea3bda95d117a76
// https://www.zoho.com/deluge/help/functions/common/isnull-isblank-isempty-difference.html
// Unfortunately, isBlank() is not reliable.
if(isNull(toCheck) || isEmpty(toCheck))
{
// empty string, string of just spaces
return 1;
}
@cliffordp
cliffordp / zohoCrmClientScript.js
Last active Apr 9, 2022 — forked from jeznag/clientScript.js
Zoho CRM client script address verification via client script
View zohoCrmClientScript.js
// Demo: https://www.youtube.com/watch?v=oA2EV7Gz5NM
const street = ZDK.Page.getField('Street').getValue();
const city = ZDK.Page.getField('City').getValue();
const zipCode = ZDK.Page.getField('Zip_Code').getValue();
const country = ZDK.Page.getField('Country').getValue();
const state = ZDK.Page.getField('State').getValue();
const address = `${street} ${city} ${state} ${zipCode} ${country}`;
const url = `http://api.positionstack.com/v1/forward`
@cliffordp
cliffordp / zohoCRMUpdateNullEntry.js
Last active Apr 9, 2022
Zoho Flow - Zoho CRM - set 1+ Field(s) to an empty string value (within a single CRM Module)
View zohoCRMUpdateNullEntry.js
void zohoCRMUpdateNullEntry(string module, string entryId, string fieldNames)
{
// This gist: https://gist.github.com/cliffordp/c4590a50b3c8ad6f7add7220481e0082
// Based on https://help.zoho.com/portal/en/community/topic/how-can-i-clear-out-a-value-in-a-field-or-set-it-to-null-using-zoho-flow
// But this one allows blanking out multiple comma-separated fields at once
// Example module = "Leads" (without quotes in Zoho Flow)
// Example fieldNames = "Street,City,State,Zip_Code" (without quotes in Zoho Flow)
optionalFields = Map();
fields = fieldNames.toList(",");
for each field in fields
@cliffordp
cliffordp / addressToCoordinates.js
Created Apr 9, 2022
Zoho Flow custom function to get address from Google Maps geocoding
View addressToCoordinates.js
map addressToCoordinates(string addressString)
{
/**
* This snippet: https://gist.github.com/cliffordp/068b32913ba25d1cd998507398c950c8
*
* Get lat/long from Google.
* https://developers.google.com/maps/documentation/geocoding
*
* CRM limits Decimal Fields to 9 digits, which is sufficient:
* https://rapidlasso.com/2019/05/06/how-many-decimal-digits-for-storing-longitude-latitude/
@cliffordp
cliffordp / gmapsAddressLookup.js
Last active Apr 10, 2022
Zoho Flow custom function for Zoho CRM - Lookup full address (USA terminology)
View gmapsAddressLookup.js
map gmapsSingleAddressLookup(string fullAddress)
{
/**
*
* This snippet: https://gist.github.com/cliffordp/132f1940b6d90a31db60faae0e20dc5f
*
* Get lat/long and other details from Google.
* https://developers.google.com/maps/documentation/geocoding
*
* CRM limits Decimal Fields to 9 digits, which is sufficient:
View appsScript.js
// This code: https://gist.github.com/cliffordp/c953c2e4020935727948afe29bd0f192
// Could use YouTube Service instead: https://developers.google.com/apps-script/advanced/youtube
// https://developers.google.com/youtube/v3/docs
const YouTubeApiKey = '...';
// `=getChannelIdFromVideoId( A1 )`
// Could link if you wish: `="https://www.youtube.com/channel/"&B1`
function getChannelIdFromVideoId( videoId ) {
@cliffordp
cliffordp / functions.php
Last active Apr 5, 2022
Gravity Forms Zoho CRM Add-On -- Decode HTML when sending to Zoho CRM so links work, such as link to the entry
View functions.php
<?php
/**
* Gravity Forms Zoho CRM - Decode HTML for Task Description & Lead Description so links work, such as link to the entry.
*
* @link https://gist.github.com/cliffordp/0d45eae807c190fed0a95de66a655224 This snippet.
* @link https://docs.gravityforms.com/gform_merge_tag_filter/#9-decode-modifier Alternative is to use a modifier like {entry_url:decode}
*/
add_filter( 'gform_zohocrm_task', 'cliff_zoho_crm_task_decode_description', 10, 4 );
if(
@cliffordp
cliffordp / style.css
Created Jun 13, 2021
Vertical scroll snapping full height container blocks in GeneratePress on WordPress
View style.css
/* Reference: https://tourkick.com/?p=14005 */
html, body {
scroll-snap-type: y proximity;
}
@media (max-width: 1024px) {
html, body {
scroll-padding: 64px; /* Remove this if your mobile header nav hides upon scroll. */
}
}
@media (min-width: 1025px) {
View uploads.php
// put uploaded files into filetype based directories
add_filter('wp_handle_upload_prefilter', 'wpse_25894_handle_upload_prefilter');
add_filter('wp_handle_upload', 'wpse_25894_handle_upload');
function wpse_25894_handle_upload_prefilter( $file )
{
add_filter('upload_dir', 'wpse_25894_custom_upload_dir');
return $file;
}