Skip to content

Instantly share code, notes, and snippets.

View louisesalas's full-sized avatar
💭
I may be slow to respond.

Louise Salas louisesalas

💭
I may be slow to respond.
View GitHub Profile
@louisesalas
louisesalas / FormatPhone.js
Created October 18, 2023 15:34
Format phone input with country code
// pretty-format phone inputs
( function( $ ) {
$(function() {
$('.gform_wrapper').on('input','[type="tel"]' , function (){
var phoneNumber = $(this).val();
// Remove Non numeric input
var numericPhoneNumber = phoneNumber.replace(/\D/g, '');
@louisesalas
louisesalas / functions.php
Created September 20, 2023 12:46
Remove p wrapper on image tags in content - Wordpress
/**
* Remove p wrapper on image tags in content
*
*/
function filter_ptags_on_images($content) {
$content = preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
return preg_replace('/<p>\s*(<iframe .*>*.<\/iframe>)\s*<\/p>/iU', '\1', $content);
}
add_filter('acf_the_content', 'filter_ptags_on_images');
add_filter('the_content', 'filter_ptags_on_images');
@louisesalas
louisesalas / helper-function.php
Created August 11, 2023 21:47
Modify the URL structure of single posts with the slug "about-us/news" while keeping the original URLs for other post types.
function custom_about_us_news_rewrite_rule() {
add_rewrite_rule('^about-us/news/([^/]+)/?$', 'index.php?name=$matches[1]', 'top');
}
add_action('init', 'custom_about_us_news_rewrite_rule');
function custom_about_us_news_permalink($permalink, $post) {
if ($post->post_type == 'post') {
$permalink = home_url('about-us/news/' . $post->post_name);
}
return $permalink;
$(window).scroll(function(){
var a = 0;
var oTop = $(".counter-container").offset().top - window.innerHeight;
if (a == 0 && $(window).scrollTop() > oTop) {
$('.number-title').each(function () {
var $this = $(this);
jQuery({ Counter: 0 }).animate({ Counter: $this.attr("data-counter") }, {
<?php
/**
* Get youtube or vimeo video thumbnail from video url
*
*/
function fx_get_video_thumbnail($url) {
// Check if url is valid
$image_src = NULL ;
@louisesalas
louisesalas / functions.php
Created June 25, 2021 07:15
Hide other shipping options when free shipping is available
<?php
function hide_shipping_when_free_is_available( $rates ) {
$free = array();
foreach ( $rates as $rate_id => $rate ) {
if ( 'free_shipping' === $rate->method_id ) {
$free[ $rate_id ] = $rate;
break;
}
@louisesalas
louisesalas / breadcrumbs-list.php
Created June 2, 2021 07:06
Remove <span> in Yoast breadcrumbs before the <li> tags
<?php
/**
* Filter the output of Yoast breadcrumbs to remove <span> tags added by the plugin
* @param $output
*
* @return mixed
*/
function louise93_yoast_breadcrumb_output( $output ){