Skip to content

Instantly share code, notes, and snippets.

View nicomollet's full-sized avatar

Nico Mollet nicomollet

View GitHub Profile
@Kaapiii
Kaapiii / command-fix.md
Created August 4, 2020 13:33
PHPStorm mysqldump throws errors while dumping a database on MySQL server version >= 5.7.31

Fix errors while executing mysqldump (with PhpStorm) on a database running on MySQL 5.7.31 and above.

(Dump worked seamlessly with mysql version 5.7.30)

Errors

  • mysqldump: Error: 'Access denied; you need (at least one of) the PROCESS privilege(s) for this operation' when trying to dump tablespaces
  • mysqldump: Couldn't execute 'SELECT COLUMN_NAME, JSON_EXTRACT(HISTOGRAM, '$."number-of-buckets-specified"') FROM information_schema.COLUMN_STATISTICS WHERE SCHEMA_NAME = 'concrete5com' AND TABLE_NAME = 'AreaLayoutColumns';': Unknown table 'COLUMN_STATISTICS' in information_schema (1109)

Fix

Fix the errors by adding the two following flags to the mysqldump command in PhpStorm

@isaumya
isaumya / remove-woocommerce-bloat-marketing-hub.md
Last active March 1, 2025 15:05
Easily Remove WooCommerce Bloated Features like Marketing Hub from WordPress Admin Menu

Remove WooCommerce Bloated Features from WP Admin Menu

Recently WooCommerce has added a lot of improvements to the plugin which we really appriciate but at the same time a lot of bloated features has alos been added to the plugin like Marketing Hub, a completely useless menu taking extra space among the other important menu items. Now if you find Marketing Hub to be useful, you can keep it.

But just in case you are looking for a way to remove these features that you no longer need from your WordPress Admin menus, take a look at the following code snippets. Please note: though I will show you how you can remove the Marketing Hub from your WP Admin menu list completely and make sure WooCommerce doesn't execute codes for that feature you don't need, you can do the same for other WooCommerce features as well like Analytics.

How to remove Marketing Hub for WooCommerce <= v4.2

If you are using WooCommerce <= v4.2, you can simple add this one line of code in your theme's functions.php f

@jjpeleato
jjpeleato / .lando.yml
Last active June 29, 2021 03:29
Apache 2.* + PHP 7.3 + Maria DB + Node JS + Mailhog + PhpMyAdmin + WordPress CLI
# See: https://lando.dev/
name: starterboilerplate
# See: https://docs.devwithlando.io/tutorials/wordpress.html
recipe: wordpress
config:
php: "7.3"
webroot: public
database: mariadb
xdebug: true
@eoli3n
eoli3n / encryption.php
Last active May 28, 2024 02:47
Encrypt - Decrypt AES from/to Python PyCryptodome from/to PHP openssl
<?php
// use to generate key : 'openssl rand -hex 32'
function my_encrypt($data, $passphrase) {
$secret_key = hex2bin($passphrase);
$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-cbc'));
$encrypted_64 = openssl_encrypt($data, 'aes-256-cbc', $secret_key, 0, $iv);
$iv_64 = base64_encode($iv);
$json = new stdClass();
$json->iv = $iv_64;
@0aveRyan
0aveRyan / universal-lando-wp-config.php
Created January 4, 2019 16:51
Universal Lando wp-config.php file grabbing creds from the env variable
<?php
/**
* !!! PLEASE CYCLE YOUR SALTS !!!
*
* @package WordPress
*/
/**
* Locate & Decode Database Credentials from Lando Info
*/
class JM_Portfolio_Blocks {
protected $loader;
protected $directory_location;
public function __construct() {
$this->directory_location = str_replace( '/blocks/', '', dirname( __FILE__ ) );
}
public function jm_portfolio_add_scripts() {
@jessepearson
jessepearson / adding_new_webhook_topics.php
Last active February 10, 2025 22:56
How to add a new custom Webhook topic in WooCommerce, with example of order filtering.
<?php // do not copy this line
/**
* add_new_topic_hooks will add a new webhook topic hook.
* @param array $topic_hooks Esxisting topic hooks.
*/
function add_new_topic_hooks( $topic_hooks ) {
// Array that has the topic as resource.event with arrays of actions that call that topic.
@addyosmani
addyosmani / workbox.md
Last active January 20, 2024 16:14
Workbox recipes

Workbox runtime caching recipes

Your Service Worker script will need to import in Workbox and initialize it before calling any of the routes documented in this write-up, similar to the below:

importScripts('workbox-sw.prod.v1.3.0.js');
const workbox = new WorkboxSW();

// Placeholder array populated automatically by workboxBuild.injectManifest()
@digamber89
digamber89 / functions.php
Created July 19, 2017 09:04
Validating Custom Fields
<?php
add_action( 'wp_enqueue_scripts', 'child_enqueue_styles' );
function child_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
add_action('woocommerce_after_checkout_validation', 'digthis_two_step_checkout_validate', 9999, 2);
function digthis_two_step_checkout_validate($data, $errors) {
@zgordon
zgordon / update-woo-order-billing-when-user-saves-address.php
Last active May 12, 2021 18:46
Update WooCommerce Order Address Dynamically When Customer Updates Their Address
<?php
add_action( 'woocommerce_customer_save_address', 'jsforwp_update_address_for_orders', 10, 2 );
function jsforwp_update_address_for_orders( $user_id ) {
$customer_meta = get_user_meta( $user_id );
$customer_orders = get_posts( array(
'numberposts' => -1,
'meta_key' => '_customer_user',