Skip to content

Instantly share code, notes, and snippets.

<?php
class WPLazyLoadImages {
function __construct() {
// Add Our Filters and actions for the plugin
add_action('wp_enqueue_scripts', array($this, 'enqueue_lazyload'));
add_filter('the_content', array($this, 'filter_lazyload'));
add_action('wp_footer', array($this, 'footer_lazyload'));
@tacensi
tacensi / Create meta box
Created June 18, 2019 22:47
Create Meta Field
<?php
/**
* Plugin Name: Movie Review - Atores
* Plugin URI: https://example.com/plugins/the-basics/
* Description: Acrescenta uma metabox para preenchimento dos atores para um blog de review de cinema
* Version: 20190625
* Author: WP&etc
* Author URI: https://wp.etc.br/
* License: GPL2
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
#!/bin/bash
# Anh Nguyen <anh.ng8@gmail.com>
# 2016-04-30
# MIT License
# This script takes in images from a folder and make a crossfade video from the images using ffmpeg.
# Make sure you have ffmpeg installed before running.
# The output command looks something like the below, but for as many images as you have in the folder.
@tacensi
tacensi / Remove script tags from wp_content
Created May 21, 2019 19:12
Remove script tags from wp_content
UPDATE wp_posts
SET post_content = CONCAT(
SUBSTRING(
post_content, 1, INSTR(post_content, '<script') - 1
),
SUBSTRING(
post_content, INSTR(post_content, '</script>') + 9
)
)
WHERE post_content LIKE '%<script%'
@tacensi
tacensi / diceware.wordlist.pt.txt
Created April 22, 2019 19:09 — forked from patxipierce/diceware.wordlist.pt.txt
A diceware wordlist for the Portuguese language.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
11111 a
11112 aa
11113 aaa
11114 aaaa
11115 ab
11116 aba
11121 abaco
@tacensi
tacensi / getScript.js
Created April 22, 2019 18:33 — forked from kmonsoor/getScript.js
jquery $.getScript() replacement with vanilla JavaScript
"use strict";
// src: https://stackoverflow.com/a/28002292
const getScript = (source, callback) => {
var script = document.createElement('script');
var prior = document.getElementsByTagName('script')[0];
script.async = 1;
script.onload = script.onreadystatechange = (_, isAbort) => {
if (isAbort || !script.readyState || /loaded|complete/.test(script.readyState)) {
@tacensi
tacensi / WP empty trash sql query
Created April 4, 2019 18:29
WP empty trash sql query
DELETE wp_posts,wp_term_relationships,wp_postmeta,wp_term_taxonomy
FROM wp_posts
LEFT JOIN wp_term_relationships ON ( wp_posts.ID = wp_term_relationships.object_id )
LEFT JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id )
LEFT JOIN wp_term_taxonomy ON ( wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id )
WHERE wp_posts.post_status='trash';
@tacensi
tacensi / gist:e4c981b755eb7c703f86d819d8f59824
Created March 21, 2019 18:01
Rename multiple files in bash
for f in $(find ./ -name "*ã*")
do
mv -i "${f}" "${f/ã/ã}"
done
@tacensi
tacensi / .vimrc
Last active March 9, 2019 12:44
vimrc file
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Maintainer:
" Amir Salihefendic
" http://amix.dk - amix@amix.dk
"
" Version:
" 5.0 - 29/05/12 15:43:36
"
" Blog_post:
" http://amix.dk/blog/post/19691#The-ultimate-Vim-configuration-on-Github
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {