Skip to content

Instantly share code, notes, and snippets.

Avatar
🐞
Debugging

Jon Fuller Garconis

🐞
Debugging
View GitHub Profile
@Garconis
Garconis / create-new-asana-task-via-api-within-zapier.js
Last active May 17, 2021
Asana | Create new Asana task via API within Zapier
View create-new-asana-task-via-api-within-zapier.js
// this is wrapped in an `async` function
// you can use await throughout the function
// get personName
var personName = inputData.personName;
// get dateStart
var dateStart = inputData.dateStart;
// get dateEnd
var dateEnd = inputData.dateEnd;
// get dateDuration
@Garconis
Garconis / taxonomy-term-rewrite-to-remove-taxonomy-slug.php
Created May 12, 2021
WordPress | Rewrite taxonomy term link URL to remove taxonomy slug
View taxonomy-term-rewrite-to-remove-taxonomy-slug.php
<?php
// https://wordpress.stackexchange.com/questions/21076/remove-taxonomy-base-or-term-from-url
// Requires going to Settings > Permalink Settings, and resaving any time you make a change to this Snippet.
// Within the CPT UI settings for the Taxonomy, be sure Rewrite is set to True, but that there is no Custom Rewrite Slug used.
// These functions help forcibly remove the taxonomy's slug from the term's URL.
// You will need to keep an eye out for slug clashes (particularly with Pages or Posts), since this doesn't prevent those.
/**
* Help WordPress to force rewrites so it can know what the URL is that we want for each term
@Garconis
Garconis / check-if-child-pages-of-parent-has-certain-slug.php
Created Apr 22, 2021
WordPress | Check if parent page has child page of certain slug
View check-if-child-pages-of-parent-has-certain-slug.php
<?php
function fs_sc_location_seo_iconbox( $atts ){
// begin output buffering
ob_start();
global $post; // if outside the loop
$slug_to_check = 'seo';
@Garconis
Garconis / wp-all-import-update-posts-by-matching-slug.php
Created Apr 21, 2021
WP All Import | Update list of posts by matching post slug via Record Matching
View wp-all-import-update-posts-by-matching-slug.php
<?php
// https://wordpress.org/support/topic/bulk-edit-record-matching-by-slug/#post-14026355
// Create custom PHP function that we can use in the "Post ID" field under Record Matching
// We pass the post slug to our function, then we use this function tot look up the post by its slug, to return the Post ID
function fs_get_post_by_slug( $slug, $post_type = 'post' ) {
if ( $post = get_page_by_path( $slug, OBJECT, $post_type ) ) {
return $post->ID;
}
@Garconis
Garconis / set-published-post-date-to-now-for-post-id.php
Created Feb 26, 2021
WordPress | Always set Published Post Date to today (NOW) for certain Post ID
View set-published-post-date-to-now-for-post-id.php
<?php
// get current time
$time = current_time('mysql');
// set the post ID to have a post date of NOW
wp_update_post(
array (
'ID' => 3274, // ID of the post to update
'post_date' => $time,
'post_date_gmt' => get_gmt_from_date( $time )
)
@Garconis
Garconis / hide-aioseo-details-admin-column-for-some-users.php
Last active Feb 8, 2021
WordPress | Hide the AIOSEO Details column for users without a certain email address
View hide-aioseo-details-admin-column-for-some-users.php
<?php
// enable if AIOSEO is active
if ( function_exists( 'aioseo' ) ) {
// fires after WordPress has finished loading but before any headers are sent.
add_action( 'init', function() {
// get current User
$user = wp_get_current_user();
// get their email address
$email = $user->user_email;
// check the email's domain
@Garconis
Garconis / progress-maps-description-content-custom-fields-taxonomy-terms.php
Last active Jan 29, 2021
Progress Maps | Add custom fields and taxonomy terms to map box description content
View progress-maps-description-content-custom-fields-taxonomy-terms.php
<?php
function cspml_custom_item_description($default_content, $post_id){
// get the terms of the post
$terms = get_the_terms( $post_id, 'product_types' );
// this is a version that will output it as a basic comma-separated list
$terms_string = join(', ', wp_list_pluck($terms, 'name'));
// set the list as empty initially
$terms_output = '';
@Garconis
Garconis / gravity-forms-remove-decimals-from-currency.php
Created Jan 22, 2021
Gravity Forms | Update the USD currency input to remove decimals
View gravity-forms-remove-decimals-from-currency.php
<?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 Dec 14, 2020
WordPress | remove dnt=1 parameter from Vimeo oEmbed iframe URL (PHP function method)
View wordpress-remove-dnt-parameter-from-vimeo.php
<?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 );
View add-post-id-as-attribute-on-html-tag-element.php
<?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' );