Skip to content

Instantly share code, notes, and snippets.

View hmouhtar's full-sized avatar

Himad Mouhtar hmouhtar

  • Spain
View GitHub Profile
@hmouhtar
hmouhtar / functions.php
Last active May 5, 2024 21:24
Elementor - Make Nav Menu Toggle Animated
This snippet filters the content of the Elementor Nav Menu Widget to
add the required markup for the animated toggle (3 spans).
function replaceMenuToggleContent($html) {
// Wrap the HTML with a root element to prevent unexpected restructuring
$dom = new DOMDocument();
libxml_use_internal_errors(true);
$dom->loadHTML('<div>' . $html . '</div>', LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
libxml_clear_errors();
@hmouhtar
hmouhtar / gflow_redirect.php
Created June 3, 2022 16:51
Gravity Flow - Redirect based on current user step.
/*
The Collective Rising relies on Gravity Flow to automate the membership workflow. After a member applies, an admin from TCR
accepts/rejects the application. Accepted members must complete a form with information that will be used to create their profile
in the website, and they should be redirected to that form if they haven't finished it yet and try to navigate to their profile.
This code snippet, although short, required a lot of research on the methods Gravity Flow used to gather information of the user progress
in the workflow.
*/
function redirect_to_profile_builder() {
@hmouhtar
hmouhtar / price-quantity.php
Last active July 12, 2021 10:27
Link price to quantity - WooCommerce for Elementor
add_action( 'woocommerce_before_add_to_cart_quantity', function(){
global $woocommerce, $product;
if ( $product->is_type( 'variable' ) ) {
?>
<script>
jQuery(function ($) {
$(document).ready(function () {
var price,
currency = '<?php echo get_woocommerce_currency_symbol(); ?>';
@hmouhtar
hmouhtar / gulpfile.js
Last active February 3, 2019 14:29
A gulpfile to compile SASS, add necessary prefixes and minify the resulting css file. Also includes a function to compress images.
// Gulp components
const {
series,
src,
dest,
watch
} = require('gulp');
// Dependencies