Skip to content

Instantly share code, notes, and snippets.

@infocities
infocities / README.md
Created May 10, 2024 01:52 — forked from Striffly/README.md
Gravity Forms with AJAX, conditional logic, pages transitions (compatible with Barba.js, Taxi.js, Highway.js, ...)

The following code enables the use of Gravity Forms (2.8.7 as of now) with the following features:

  • AJAX loading, 100% functional
  • Functional with page transitions (Barba.js, Taxi.js, Highway.js)
  • Enqueue Gravity Forms scripts used by each forms (including conditional logic scripts)
  • Works with recaptcha (with recent version of Gravity Forms reCAPTCHA Add-On, scripts are automaticaly enqueued)
  • Keep the form displayed after submission (optional)
  • Scripts moved to footer (optional)

The code was initially integrated into projects using roots/sage. I adapted the code for integration into "vanilla" WordPress projects but I have less feedback compared to the use I have with my stack, so feel free to let me know if there are any errors in the comments!

@infocities
infocities / bs5-navwalker.php
Created April 4, 2024 06:50 — forked from cdsaenz/bs5-navwalker.php
Wordpress Bootstrap 5 Nav Walker With Multiple Levels
<?php
/**
* CSDev - Bootstrap 5 wp_nav_menu walker
* Supports WP MultiLevel menus
* Based on https://github.com/AlexWebLab/bootstrap-5-wordpress-navbar-walker
* Requires additional CSS fixes
* CSS at https://gist.github.com/cdsaenz/d401330ba9705cfe7c18b19634c83004
* CHANGE: removed custom display_element. Just call the menu with a $depth of 3 or more.
*/
class bs5_Walker extends Walker_Nav_menu
@infocities
infocities / gravity-forms-confirmation-remain.php
Created April 1, 2024 06:26 — forked from davidwolfpaw/gravity-forms-confirmation-remain.php
Keep Gravity Forms Displayed After Submission
<?php
// Allow the Gravity form to stay on the page when confirmation displays.
add_filter( 'gform_pre_submission_filter', 'dw_show_confirmation_and_form' );
function dw_show_confirmation_and_form( $form ) {
// Inserts a shortcode for the form without title or description
$shortcode = '[gravityform id="' . $form['id'] . '" title="false" description="false"]';
// Ensures that new lines are not added to HTML Markup
ob_start();
@infocities
infocities / gist:0ed3def2019544c8cedfea82e5057586
Created April 1, 2024 02:49 — forked from 465media/gist:17664b045de75deafcb2b99695d22df9
Set default "From Email" for Gravity Forms notifications using WordPress domain.
/**
* Set default "From Email" for Gravity Forms notifications using WordPress domain.
*/
function override_gravityforms_from_email( $email, $notification ) {
// Get the WordPress site URL and extract the domain.
$site_url = get_site_url();
$parsed_url = parse_url( $site_url );
$domain = isset( $parsed_url['host'] ) ? $parsed_url['host'] : '';
if ( isset( $email['from'] ) && $email['from'] === '{admin_email}' ) {
$email['from'] = 'no-reply@' . $domain;
@infocities
infocities / reorder-admin-menu.php
Created March 10, 2024 13:24 — forked from RadGH/reorder-admin-menu.php
Reorganize a specific set of menu items in the WordPress admin dashboard. Also create a new separator and ACF options page, and move those too.
<?php
if ( !defined( 'ABSPATH' ) ) exit;
/**
* Add a menu separator to the admin dashboard. This will be positioned within axe_reorder_admin()
*/
function axe_admin_menu_separator() {
global $menu;
$menu[] = array(
@infocities
infocities / append-nav-items.php
Created March 5, 2024 04:26 — forked from wpscholar/append-nav-items.php
Add a custom link to the end of a menu that uses the wp_nav_menu() function
<?php
/**
* Add a custom link to the end of a specific menu that uses the wp_nav_menu() function
*/
add_filter('wp_nav_menu_items', 'add_admin_link', 10, 2);
function add_admin_link($items, $args){
if( $args->theme_location == 'footer_menu' ){
$items .= '<li><a title="Admin" href="'. esc_url( admin_url() ) .'">' . __( 'Admin' ) . '</a></li>';
}
@infocities
infocities / webpack.mix.js
Created September 22, 2023 07:46 — forked from dfravel/webpack.mix.js
Laravel Mix Webpack Setup for WordPress, Sage by Roots and Tailwind
const mix = require('laravel-mix');
const ImageminPlugin = require('imagemin-webpack-plugin').default;
require('laravel-mix-tailwind');
require('laravel-mix-purgecss');
const assetsPath = 'resources/assets';
const distPath = './dist';
const publicPath = '/wp-content/themes/THEME_NAME';
@infocities
infocities / _flickity.scss
Created September 22, 2023 07:45 — forked from moxdev/_flickity.scss
Home Page Carousel with Text - Flickity Based #wp #jsLibrary
/*! Flickity v2.1.2
https://flickity.metafizzy.co
---------------------------------------------- */
.flickity-enabled {
position: relative;
}
.flickity-enabled:focus {
outline: none;
@infocities
infocities / caculate_navbar_height.md
Created September 19, 2023 15:24 — forked from sanrandry/caculate_navbar_height.md
calculate navbar height
  • add this javascript
document.documentElement.style.setProperty('--nav-height', document.getElementById("navbar").offsetHeight);
  • use property iny css
:root {
    --nav-height: 70px; /*You HAVE To Give A Default Fallback Value*/
}
@infocities
infocities / index.html
Created September 11, 2023 05:21 — forked from rovria/index.html
Locomotive Scroll with ScrollTrigger overlay reveal - data-scroll-section
<div class="smooth-scroll">
<section class="red" data-scroll-section>
<div class="section-inner">Text</div>
</section>
<section class="blue" data-scroll-section>
<div class="section-inner">Text</div>
</section>