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 / wp-all-import-hashed-passwords.php
Last active January 14, 2022 16:25 — forked from louisreingold/gist:1ef75e6b3623c5c66e4443dc762bfd52
WP All Import | Code to run in Function Editor during import, to add hashed password (from previous export) into password field
<?php
// https://www.youtube.com/watch?v=VEzAWMCwprQ
add_action( 'pmxi_saved_post', 'post_saved', 10, 1 );
function post_saved( $id ) {
global $wpdb;
$pass = get_user_meta( $id, 'xfer_user_pass', true );
$table = $wpdb->prefix . 'users';
$wpdb->query( $wpdb->prepare(
"
UPDATE `" . $table . "`
@Garconis
Garconis / prev-next-shortcode-nav-thunbnails.php
Created January 11, 2022 22:19
WordPress | Previous and next shortcode for post navigation on single posts
<?php
add_shortcode( 'fs_prev_next_thumbs', 'generate_faq_landing_link_shortcode' );
function generate_faq_landing_link_shortcode( $atts, $content ) {
global $post; // if outside the loop
$prev_next = '';
$prev_post = get_previous_post();
$next_post = get_next_post();
@Garconis
Garconis / gravity-forms-event-snippet-conversion-tracking.js
Created January 7, 2022 20:35
Gravity Forms | Track Google Ads conversion with Ajax successful submission
// run the event code if Gravity Form 6 was successfully submitted
jQuery(document).ready(function($){
// Google Ads conversion tracking when Contact Form is successfully submitted
jQuery(document).on('gform_confirmation_loaded', function(event, formId){
if(formId == 6) {
// Event snippet to log Google Ads conversion of Contact Form
gtag('event', 'conversion', {'send_to': 'AW-123456790/abcdefghijk'});
}
});
})
@Garconis
Garconis / wordpress-add_action-init-is_plugin_active.php
Created December 14, 2021 20:38
WordPress | Only run certain add_action init rules if related plugin is active
<?php
// only run if TML plugin is active
add_action( 'init', 'fs_remove_tml_profile_fields');
function fs_remove_tml_profile_fields() {
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
if ( is_plugin_active( 'theme-my-login/theme-my-login.php' ) ) {
// remove the password hint helper text from the register and password reset forms
tml_remove_form_field( 'register', 'indicator_hint' );
tml_remove_form_field( 'resetpass', 'indicator_hint' );
}
@Garconis
Garconis / divi-child-theme-enqueue-functions.php
Created December 1, 2021 17:05
WordPress | Divi child theme enqueue for use in functions.php
<?php // goes in functions.php
/* Enqueue necessary CSS and JS files for Child Theme */
function fs_theme_enqueue_stuff() {
// Divi assigns its style.css with this handle
$parent_handle = 'divi-style';
// Get the current child theme data
$current_theme = wp_get_theme();
// get the parent version number of the current child theme
$parent_version = $current_theme->parent()->get('Version');
// get the version number of the current child theme
@Garconis
Garconis / remove-wordpress-column-from-admin-plugin-list.php
Created November 29, 2021 21:00
WordPress | Hide (remove) a column in the in the admin plugin list
<?php
// Remove the Plugin Notes Plus column for all users other than the ones we approve below
// based on their user email domain, or their user ID
// manipulate the Plugins admin page columns
// https://www.role-editor.com/remove-column-from-wordpress-users-list/
add_filter('manage_plugins_columns','fs_remove_plugin_notes_columns_for_most_users');
function fs_remove_plugin_notes_columns_for_most_users($column_headers) {
// get current user data
$current_user = wp_get_current_user();
@Garconis
Garconis / zapier-code-check-field-value-exists.js
Created October 29, 2021 14:48
Zapier | Check if field exists or has value, then change the output value if it does or doesn't
// this is wrapped in an `async` function
// you can use await throughout the function
// just in case, initially we set the output of this object to be false
output = {clientIdResult: false};
// get the variable from the inputData we added to this Action
var clientid = inputData.clientId;
// check if the variable had data
@Garconis
Garconis / gravity-forms-google-analytics-client-id-field.js
Last active December 29, 2021 22:16
Google Analytics | Get GA Client ID cookie data and other GA data on Gravity Form submit via hidden fields
// get GA Client ID when using analytics.js
// set the tracker data via the ready callback
// https://developers.google.com/analytics/devguides/collection/analyticsjs/cookies-user-id#getting_the_client_id_from_the_cookie
// more info: https://developers.google.com/analytics/devguides/collection/analyticsjs/accessing-trackers#getting_data_stored_on_a_tracker
// fields we can get with a tracker: https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference
// helpers: https://www.simoahava.com/analytics/universal-analytics-plugins-explained/
// helpers: https://hevodata.com/learn/google-analytics-and-salesforce/
// check to see if the ID exists first
var gform_6_exists = document.getElementById('gform_6');
@Garconis
Garconis / create-new-asana-task-via-api-within-zapier.js
Last active May 17, 2021 20:48
Asana | Create new Asana task via API within Zapier
// 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 18:50
WordPress | Rewrite taxonomy term link URL to remove taxonomy slug
<?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