Skip to content

Instantly share code, notes, and snippets.

View MisterWP's full-sized avatar

Nicolas Laruelle MisterWP

View GitHub Profile
<?php
/* This script displays the disk space used on your Web Hosting storage, for the current directory and recursively for all its subfolders. Copyright https://www.easyhoster.com and https://www.mister-wp.com */
function getDirectorySize(string $directory): int {
$size = 0;
// Ouvre le répertoire
$files = scandir($directory);
if ($files === false) {
@MisterWP
MisterWP / contact-form-7-format-to-style-divi-theme.css
Created September 24, 2024 08:36 — forked from maykbrito/contact-form-7-format-to-style-divi-theme.css
Style a contact form 7 to seems like Divi Theme Contact style
/*contact form 7 like Divi theme */
/* fields. Note "assunto" field, is explained in Select section of this file */
.wpcf7-text, .wpcf7-textarea, .wpcf7-captchar, .assunto{
background-color: #eee !important;
border: none !important;
width: 100% !important;
-moz-border-radius: 0 !important;
-webkit-border-radius: 0 !important;
border-radius: 0 !important;
@MisterWP
MisterWP / README.md
Created May 1, 2024 07:44 — forked from tallesairan/README.md
How to unpack .wpress archive files created by the All-in-one-Wp-Migration Wordpress plugin

How to unpack .wpress archive files created by the All-in-one-Wp-Migration Wordpress plugin

Recently I needed to download some files from a Wordpress installation where the client only gave me access to the admin dashboard. Fortunately the All-in-One WP Migration plugin was already installed, so I could take a quick backup of the whole site by downloading the installed plugins, theme and database. To my surprise downloading the backup from the All-in-One WP Migration plugin only gave me a single compressed migration.wpress file that any unpack tool refused to extract. A little web search brought me to a five year old tool called Wpress-Extractor but the provided binaries for MacOS refused to work because the package was already too old.

So I decided to rewrite this little helpful tool in Node.js to make it cross-platform compatible for Windows, MacOS and Linux.

Ok here it is: A simple 2-step tutorial how to extract a file with the .wpress extension on your computer:

  1. Step
@MisterWP
MisterWP / fatal-errors-only.php
Created September 7, 2023 07:03
Display or log Fatal Errors Only : This mu-plugin attempts to set the level of the PHP function error_reporting to only display critical errors (fatal errors). But keep in mind that some other plugins or theme functions loaded later may still override our settings.
<?php
/**
* @package Fatal_Errors_Only
* @version 0.0.1
*/
/*
Plugin Name: Fatal Errors Only
Plugin URI: https://www.easyhoster.com/
Description: This mu-plugin attempts to set the level of the PHP function error_reporting to only display critical errors (fatal errors). But keep in mind that some other plugins or theme functions loaded later may still override our settings.
Author: EasyHoster
@MisterWP
MisterWP / .htaccess
Created April 28, 2023 08:09
Adding "Expires Headers" manually
# Ajout "Expires Headers" via htaccess
<IfModule mod_expires.c>
# Ajout des "content-type" corrects pour les fonts
AddType font/ttf .ttf
AddType font/otf .otf
AddType font/woff .woff
AddType font/woff2 .woff2
AddType image/svg+xml .svg
@MisterWP
MisterWP / .htaccess
Last active May 22, 2023 10:31
Basic PageSpeed Modules Config in French from EasyHoster.com
<IfModule pagespeed_module>
# Activation de mod_pagespeed (pour le désactiver, utiliser "off")
ModPagespeed on
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# Tutoriel détaillé disponible sur le blog EasyHoster.com,
# article sur les PageSpeed Modules :
# https://www.easyhoster.com/pagespeed-wp-rocket-alternatives/
@MisterWP
MisterWP / .htaccess
Last active April 23, 2023 05:40
How to enable Gzip Compression through .htaccess
# Gzip compression through htaccess by EasyHoster.com, src : https://www.easyhoster.com/aide/activer-compression-gzip-brotli/
<IfModule mod_deflate.c>
# Active compression
SetOutputFilter DEFLATE
# Force deflate for mangled headers
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
# Don't compress images and other uncompressible content
# Gzip compression
<IfModule mod_deflate.c>
# Active compression
SetOutputFilter DEFLATE
# Force deflate for mangled headers
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
# Don't compress images and other uncompressible content
@MisterWP
MisterWP / my.cnf
Created September 2, 2022 07:50 — forked from cristiroma/my.cnf
MySQL cnf configuration script for the power user's dev developer machine
[client]
user=root
password=root
socket=/var/mysql/mysql.sock
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
<?php
// CONFIG
$servers = array(
array('Local', '127.0.0.1', 6379),
);
// END CONFIG
$server = 0;
if (isset($_GET['s']) && intval($_GET['s']) < count($servers)) {
$server = intval($_GET['s']);