Skip to content

Instantly share code, notes, and snippets.

View MaximeCulea's full-sized avatar
🇨🇭
New life begining.

Maxime CULEA MaximeCulea

🇨🇭
New life begining.
View GitHub Profile
@MaximeCulea
MaximeCulea / git-clean-all-po-mo-backup
Last active April 19, 2024 09:36
Easily delete translations backups and json.
/**
* Easily delete locotranslate backup po/mo, while originals are gitted.
* No need to keep them.
*
* @author Maxime CULEA
*/
find ./ -type f -name "*.po~" -exec git clean -df {} +
find ./ -type f -name "*.mo~" -exec git clean -df {} +
find ./ -type f -name "*.pot~" -exec git clean -df {} +
find ./ -type f -name "*.json" -exec rm -rf {} +
@MaximeCulea
MaximeCulea / wp-cli-ms-cheatset.php
Last active January 9, 2024 19:29
A list of WordPress WP Cli commands when into Multisite usage.
#!/usr/bin/env bash
# Related to WP CLI as single site, check following link
# @see https://gist.github.com/MaximeCulea/dbd5835a01d2b4e6a6544919db3f26a0
# All wp cli comands will be declared both (as much as possible) :
# - with xargs (not all servers support xargs)
# - more native shell syntax "for in"
# WP Crons MS
@MaximeCulea
MaximeCulea / default-autoptimize.php
Last active January 3, 2024 14:48
Set default options for Autoptimize plugin (especially for MS).
<?php
/*
Plugin Name: Autoptimize - Default
Plugin URI: https://www.maximeculea.fr
Description: Set options for Autoptimize
Author: Maxime CULEA
Author URI: https://maximeculea.fr
Version: 1.0.0
*/
@MaximeCulea
MaximeCulea / clean-repo.sh
Last active October 30, 2023 14:26
Clean a cloned git repo to avoid conflicts between multiple OS
#!/bin/bash
# Clean a cloned git repo to avoid conflicts between multiple OS
# To install
## download the file clean-repo.sh and place it somewhere
## in bashrc or zhrc add an alias like so: alias cleangit="bash /path/to/clean-repo.sh"
## in the terminal into the project, simply lunch the alias: cleangit
@MaximeCulea
MaximeCulea / wp-unregister-post-type-post.php
Last active July 21, 2023 12:06
Unregister the post type "Post"
<?php
/**
* Unregister the post type "Post" or more
*
* @see unregister_post_type()
*
* @author Maxime CULEA
*/
add_action( 'init', function () {
global $wp_post_types;
@MaximeCulea
MaximeCulea / wp-cli-languages.sh
Last active January 31, 2023 13:36
Play with WordPress languages in cli.
#!/bin/bash
# Note the fifference between Install and Update
# Install : if the language doesn't exist, this is the first step to get the last asked language package. It is also needed, in order to update.
# Update : will get the last asked translation package, only if the language is already installed.
# Install core in french if not existing
wp language core install fr_FR
# Update all existing core languages
@MaximeCulea
MaximeCulea / wp-cli-cheatset.sh
Last active January 18, 2023 16:58
A list of WordPress WP Cli commands.
#!/usr/bin/env bash
# Related to WP CLI in Multisite check following link
# @see https://gist.github.com/MaximeCulea/575e493a061359edbb12cefc3aa4c770
# Update all post's thumnbail
wp post update $(wp post list --format=ids --post_type=post) --post_type=post --meta_input='{"_thumbnail_id":"160"}'
# Generate and add dummy thumbnails to a wanted post type : https://gist.github.com/MaximeCulea/c04e62c4b6e79b4e4e17b73dd023b6c4
# Search Replace with regex
@MaximeCulea
MaximeCulea / woo-optimize.php
Last active January 14, 2023 16:30
Gather tips to optimize WooCommerce sites.
# Optimize DB : WC action scheduler
DELETE FROM `wp_actionscheduler_actions` WHERE `status` = 'canceled' OR `status` = 'complete' OR `status` = 'failed';
# Optimize Action Scheduler queue
# See the WP Cli cron command: https://gist.github.com/MaximeCulea/df0766f9e17105f03717f206a22a2d39#single-site
@MaximeCulea
MaximeCulea / wp-cli-cron.md
Last active January 14, 2023 16:29
Cron for WP with WP-CLI.

Add a crontab

crontab -e

Crontab

WordPress Crons running with WP-CLI each 15 minutes with :

Var
@MaximeCulea
MaximeCulea / php-helpers.php
Created January 3, 2023 09:52
PHP Helpers
<?php
/**
* Delete a folder recursively
*
* @param $dir
*
* @author Maxime CULEA
*/
private function delete_folder( $dir ) {