Skip to content

Instantly share code, notes, and snippets.

View diegoliv's full-sized avatar

Diego de Oliveira diegoliv

View GitHub Profile
@diegoliv
diegoliv / webflow.html
Last active January 11, 2024 20:32
Webflow page transition - delay page load to allow interaction to play after clicking on a link
<script>
(function($) {
$(function(){
$('a').on('click', function(e) {
const href = this.href;
const url = new URL(href);
if (window.location.origin === url.origin) {
e.preventDefault();
@diegoliv
diegoliv / webflow.html
Last active April 28, 2024 16:09
Lenis + Webflow (with anchor links workaround)
<script src="https://cdn.jsdelivr.net/gh/studio-freight/lenis@v0.2.26/bundled/lenis.js"></script>
<script>
if (!document.querySelector("html").classList.contains('w-editor')){
const lenis = new Lenis({
duration: 1.2,
easing: (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)), // https://www.desmos.com/calculator/brs54l4xou
direction: 'vertical', // vertical, horizontal
gestureDirection: 'vertical', // vertical, horizontal, both
smooth: true,
@diegoliv
diegoliv / cycle-script.js
Created January 27, 2022 12:20
Symphony Cicle
// Building default object
var buildingObj = {
open: false,
uid: null,
address1: {
value: null,
rules: ['required'],
valid: true,
error: null
},
@diegoliv
diegoliv / pdf.php
Created October 9, 2018 19:24
PDFShift config
<?php
require_once('includes/vendor/pdfshift/init.php');
use \PDFShift\PDFShift;
$pdfshift = new PDFShift( array(
'sandbox' => true,
'viewport' => '768x1024',
'zoom' => 0.8,
'css' => $this->get_pdf_css(), // custom function to get a url for the css file
@diegoliv
diegoliv / functions.php
Created March 9, 2016 00:05
Rewrite Rules issue - how to make both work?
<?php
function rewrite_rules(){
add_rewrite_tag( '%course%', '([^&]+)' );
add_rewrite_tag( '%theme%', '([^&]+)' );
add_rewrite_rule("^app/course/([^/]+)/?",'index.php?page_id=3400&course=matches[1]', 'top' );
add_rewrite_rule('^app/course/([^/]+)/theme/([^/]+)/?','index.php?page_id=3400&course=$matches[1]&theme=$matches[2]', 'top' );
}
@diegoliv
diegoliv / meta-query.php
Last active January 7, 2016 21:31
Meta Query complexa
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$roi_min = (get_query_var('roi_min')) ? intval( get_query_var('roi_min') ) : false;
$roi_max = (get_query_var('roi_max')) ? intval( get_query_var('roi_max') ) : false;
$args = array(
'post_type' => 'post',
'tax_query' => array(...),
'posts_per_page' => 10,
<?php
function test_prevent_redirect( $redirect_url ) {
if ( is_single() && in_array( get_post_type( get_the_ID() ), array( 'cursos', 'videos', 'disciplinas' ) ) ) $redirect_url = false;
return $redirect_url;
}
add_filter('redirect_canonical', 'test_prevent_redirect' );
@diegoliv
diegoliv / single-cursos.php
Last active December 14, 2015 13:43
Custom loop pagination in single post type template
<?php get_header(); ?>
<div class="container">
<div class="row">
<?php
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$disciplinas = new WP_Query( array(
'post_type' => 'disciplinas',
@diegoliv
diegoliv / query.php
Last active December 3, 2015 13:39
WP_Query com múltiplos meta_query
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$roi_min = (get_query_var('roi_min')) ? intval( get_query_var('roi_min') ) : false;
$roi_max = (get_query_var('roi_max')) ? intval( get_query_var('roi_max') ) : false;
$args = array(
'post_type' => 'post',
'posts_per_page' => 10,
'paged' => $paged,
@diegoliv
diegoliv / gulpfile.js
Created May 14, 2015 17:31
gulpfile.js for building e-mail templates
var gulp = require( 'gulp' ),
sass = require( 'gulp-sass' ),
autoprefixer = require( 'gulp-autoprefixer' ),
minifycss = require( 'gulp-minify-css' ),
imagemin = require( 'gulp-imagemin' ),
rename = require( 'gulp-rename' ),
concat = require( 'gulp-concat' ),
plumber = require( 'gulp-plumber' ),
notify = require( 'gulp-notify' ),
inlineCss = require('gulp-inline-css'),