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 / 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 / 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 ) {
@MaximeCulea
MaximeCulea / wpcli_delete_empty_terms.php
Last active December 28, 2022 22:14
Delete empty terms in WP CLI
<?php
/**
* Delete all empty terms for the given $taxonomy
* PS: You can do the same in WP CLI or even plain WordPress php functions
*
* @param : string $tax : given taxonomy to work on
*
* @author Maxime CULEA
*/
@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 / linux-cheatset.sh
Created July 14, 2022 13:49
Linux Cheatset
# Find all wanted files by type and delete
find . -iname \*.pdf\* -exec rm -rf {} \;
find . -iname \*.zip\* -exec rm -rf {} \;
find . -iname \*.psd\* -exec rm -rf {} \;
find . -iname \*.pptx\* -exec rm -rf {} \;
find . -iname \*.mp4\* -exec rm -rf {} \;
# Top 10 heavy files
find . -printf '%s %p\n'| sort -nr | head -10
@MaximeCulea
MaximeCulea / wordpress-rest-api-tweeks.php
Last active March 1, 2022 13:29
Add WordPress REST API tweeks
<?php
/**
* Add other post types into the post rest api route to gather different contents type
*
* @link /wp-json/wp/v2/posts/
*
* @param $args
* @param $request
*
@MaximeCulea
MaximeCulea / cli-get-info.sh
Last active March 7, 2022 13:52
Get Info from a server with cli.
# https://www.cyberciti.biz/faq/how-to-find-my-public-ip-address-from-command-line-on-a-linux
echo $(dig +short myip.opendns.com @resolver1.opendns.com)
# @url https://www.tecmint.com/find-linux-server-public-ip-address
wget -qO- http://ipecho.net/plain | xargs echo
# Get PHP Version
https://www.thegeekdiary.com/how-to-check-the-php-version-on-linux
# Get Public server info
https://github.com/BeAPI/phpwpinfo
@MaximeCulea
MaximeCulea / load-theme-files.php
Last active November 24, 2020 22:24
Exemple on how load template's files.
<?php
$dependencies = [
'inc' => [
'assets',
'manage-plugins',
'options',
'languages',
],
'theme' => [
'wysiwyg',
@MaximeCulea
MaximeCulea / customizer-hide.php
Created August 5, 2020 11:03
Hide the customizer and all related features
// Hide the Customizer and related features
add_action( 'admin_print_footer_scripts', function () {
echo '<style type="text/css">.hide-if-no-customize{display: none}</style>';
} );
@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