Skip to content

Instantly share code, notes, and snippets.

View milllan's full-sized avatar

Milan Petrović milllan

View GitHub Profile
@khoipro
khoipro / sample-lazyload-sections.php
Last active January 8, 2024 22:02
Sample section lazyload using <noscript> - DRAFTING
<?php
/** Drafting **/
add_filter('the_content', 'codetot_lazyload_home_sections', 1000);
function codetot_lazyload_home_sections( $content ) {
$front_page_id = get_option('page_on_front');
if ( ! is_page( $front_page_id ) ) {
return $content;
}
@seebeen
seebeen / basic-stuff.php
Created March 12, 2021 21:40
[WooCommerce Product Manipulation] WooCommerce Product manipulation basics #wordpress #woocommerce
<?php
$product_id = 202;
$product_sku = 'SIFRA-1245';
/*
This won't work because update_post_meta does not trigger necessary additions to product lookup tables and transients
*/
update_post_meta($product_id, '_sku', $product_sku);
@webtrainingwheels
webtrainingwheels / .htaccess
Created October 30, 2019 23:39
WP Rocket htaccess rules
# BEGIN WP Rocket v3.4.0.5
# Use UTF-8 encoding for anything served text/plain or text/html
AddDefaultCharset UTF-8
# Force UTF-8 for a number of file formats
<IfModule mod_mime.c>
AddCharset UTF-8 .atom .css .js .json .rss .vtt .xml
</IfModule>
# FileETag None is not enough for every server.
<IfModule mod_headers.c>
Header unset ETag
@CFranc111
CFranc111 / gist:ca7b7ab6108ce293365f380d5e99b6b2
Created August 22, 2019 16:51
Wordpress add lazy loading all content
function enzothecat_add_lazy_loading($content) {
$content = preg_replace('/src="/', 'loading="lazy" src="', $content);
return $content;
}
add_filter('the_content', 'enzothecat_add_lazy_loading');
@Inggo-inHomePortal
Inggo-inHomePortal / cleanup.sql
Created August 19, 2016 07:28
wp_options cleanup
DELETE FROM `wp_options` WHERE option_name IN (
'userpro_activity',
'wpmandrill-stats',
'_transient_RCWFeed_Ms_b22d9dad80577a8e66a230777d91cc6e',
'userpro_cached_results',
'userpro_fields_groups_default',
'userpro_fields_groups',
'era_googleFonts',
'suppamenu_skin_redow',
'suppamenu_skin_ubuntus',
@tripflex
tripflex / functions.php
Last active February 13, 2024 19:03
WordPress Remove Filter (remove_filter converted to remove_class_filter) to remove Filter/Action without Class Object access. Works with WordPress 1.2+ (4.7+ support added 9-19-2016)
<?php
/**
* Make sure the function does not exist before defining it
*/
if( ! function_exists( 'remove_class_filter' ) ){
/**
* Remove Class Filter Without Access to Class Object
*
* In order to use the core WordPress remove_filter() on a filter added with the callback
@ttscoff
ttscoff / font_grabber.rb
Last active May 13, 2021 06:14
Give it a <link> from Google fonts and get back CSS with fonts embedded
#!/usr/bin/ruby
# encoding: utf-8
# Grab google web fonts and embed them as base64 data URIs
# <http://brettterpstra.com/2015/03/14/embedding-google-web-fonts/>
require 'base64'
if ARGV.length > 0
input = ARGV
elsif STDIN.stat.size > 0
input = STDIN.read.strip.split(/\n+/)
@nghuuphuoc
nghuuphuoc / 1) Install
Last active September 4, 2023 09:29
Install Redis on Centos 6
// --- Compiling ---
$ wget http://download.redis.io/releases/redis-2.8.3.tar.gz
$ tar xzvf redis-2.8.3.tar.gz
$ cd redis-2.8.3
$ make
$ make install
// --- or using yum ---
$ rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
$ rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
@PaulKinlan
PaulKinlan / criticalcss-bookmarklet-devtool-snippet.js
Last active April 2, 2024 02:45
CriticalCSS Bookmarklet and Devtool Snippet.js
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");