Skip to content

Instantly share code, notes, and snippets.

View daviddegliame's full-sized avatar

Degliame David daviddegliame

View GitHub Profile
@daviddegliame
daviddegliame / wp-update.sh
Created May 5, 2017 13:51 — forked from bananana/wp-update.sh
Bash script to run automatic updates and backups using wp-cli
#!/bin/bash
#
# Backup and update WordPress using wp-cli
#
# Set the -e shell option so the script exits immediately if any command within
# it exits with a non-zero status.
set -e
# Set PATH environment variable
@MaximeCulea
MaximeCulea / bea-prefix-pages-slug.php
Last active September 6, 2017 09:10
Prefix page's slug like "/page/{slug}"
<?php
/**
* Change post type single slug
*/
add_filter( 'register_post_type_args', 'bea_edit_page', 20, 2 );
function bea_edit_page( $args, $post_type ) {
if ( 'page' !== $post_type ) {
return $args;
}
@willybahuaud
willybahuaud / filter-menu-item-by-user-status.php
Last active October 16, 2016 17:23
Filtrer les éléments d’un menu selon que l’utilisateur est connecté
<?php
add_filter( 'wp_nav_menu_objects', 'willy_filter_wp_nav_menu_object_by_user_status' );
function willy_filter_wp_nav_menu_object_by_user_status( $items ) {
if ( ! is_admin() ) {
foreach ( $items as $k => $item ) {
if ( is_array( $item->classes )
&& ( ( in_array( 'logged-only', $item->classes ) && ! is_user_logged_in() )
|| ( in_array( 'not-logged-only', $item->classes ) && is_user_logged_in() ) ) ) {
unset( $items[ $k ] );
@bananana
bananana / wp-update.sh
Last active March 26, 2025 18:13
Bash script to run automatic updates and backups using wp-cli
#!/bin/bash
#
# Backup and update WordPress using wp-cli
#
# Set the -e shell option so the script exits immediately if any command within
# it exits with a non-zero status.
set -e
# Set PATH environment variable
@johnbillion
johnbillion / wp_mail.md
Last active July 7, 2025 13:21
WordPress Emails

WordPress Emails

This document lists all the situations where WordPress sends an email, along with how to filter or disable each email.

This documentation has moved here: https://github.com/johnbillion/wp_mail

@wpchannel
wpchannel / mu-sanitize-filename.php
Last active April 21, 2024 14:51
Clean file name when uploading in WordPress
<?php if ( ! defined( 'ABSPATH' ) ) {
die( 'Restricted Area' );
}
/*
* Plugin Name: Sanitize File Name
* Description: Clean file name when uploading files in WordPress.
* Version: 20240103
* Author: Mickaël Gris (Saipafo) & Aurélien Denis (WP channel)
* Author URI: https://wpchannel.com/wordpress/tutoriels-wordpress/renommer-automatiquement-fichiers-accentues-wordpress/
INITIALISATION
==============
load wp-config.php
set up default constants
load wp-content/advanced-cache.php if it exists
load wp-content/db.php if it exists
connect to mysql, select db
load object cache (object-cache.php if it exists, or wp-include/cache.php if not)
load wp-content/sunrise.php if it exists (multisite only)
@herewithme
herewithme / sanitize-filename.php
Created November 29, 2013 11:15
WordPress - No french punctuation and accents for filename
<?php
/*
Plugin Name: No french punctuation and accents for filename
Description: Remove all french punctuation and accents from the filename of upload for client limitation (Safari Mac/IOS)
Plugin URI: http://www.beapi.fr
Version: 1.0
Author: BeAPI
Author URI: http://www.beapi.fr
/*
@DevinWalker
DevinWalker / woocommerce-optimize-scripts.php
Last active August 5, 2025 09:32
Only load WooCommerce scripts on shop pages and checkout + cart
/**
* Optimize WooCommerce Scripts
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
*/
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
function child_manage_woocommerce_styles() {
//remove generator meta tag
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );