Skip to content

Instantly share code, notes, and snippets.

Avatar
🐞
Debugging

Jon Fuller Garconis

🐞
Debugging
View GitHub Profile
@Garconis
Garconis / gravity-forms-full-admin-access-for-role.php
Created Oct 12, 2022
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 Sep 19, 2022
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 Apr 8, 2022
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 Mar 29, 2022
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 Mar 24, 2022
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;
@Garconis
Garconis / json-ld-person-schema.html
Created Mar 23, 2022
JSON-LD | Person schema structured data
View json-ld-person-schema.html
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "Person",
"@id": "https://freshysites.com/team/jon-fuller/#person",
"name": "Jon Fuller",
"jobTitle": "Lead Web Developer",
"Description": "Striving to solve issues and implement complex functionality — with creative user-friendly techniques and thorough constructive solutions.",
"worksFor":
{
@Garconis
Garconis / plugin-notes-plus-hide-data-based-on-user.php
Created Feb 25, 2022
WordPress | Hide the Plugin Notes Plus data for all users other than certain ones
View plugin-notes-plus-hide-data-based-on-user.php
<?php
// Remove the Plugin Notes Plus data for all users other than the ones we approve below
// based on their user email domain, or their user ID
// using their own filter, we hide its output
add_filter( 'plugin-notes-plus_hide_notes', 'fs_remove_plugin_notes_data_for_most_users' );
function fs_remove_plugin_notes_data_for_most_users( $hide_notes ) {
// get current user data
$current_user = wp_get_current_user();
@Garconis
Garconis / wp-all-import-hashed-passwords.php
Last active Jan 14, 2022 — 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
View wp-all-import-hashed-passwords.php
<?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 Jan 11, 2022
WordPress | Previous and next shortcode for post navigation on single posts
View prev-next-shortcode-nav-thunbnails.php
<?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 Jan 7, 2022
Gravity Forms | Track Google Ads conversion with Ajax successful submission
View gravity-forms-event-snippet-conversion-tracking.js
// 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'});
}
});
})