Instantly share code, notes, and snippets.


Edoardo Armandi M&B edoardo-mb

View GitHub Profile
View debug-console.php
//to debug php in console
<script>console.log(<?= json_encode($languages); ?>);</script>
View functions.php
* Redirect users to custom URL based on their role after login
* @param string $redirect
* @param object $user
* @return string
function wc_custom_user_redirect( $redirect, $user ) {
// Get the first of all the roles assigned to the user
View functions.php
// Add custom message to cart and checkout
add_action('woocommerce_before_cart', 'mb_add_cart_checkout_message');
add_action( 'woocommerce_before_checkout_form', 'mb_add_cart_checkout_message', 12 );
function mb_add_cart_checkout_message() {
echo '<div style="border-color: #000000;border-radius: 4px;border-width: 2px;border-style: solid;padding: 30px 20px 20px 20px;margin: 0 0 2em;background: #000;color: #fff;">
<h4 style=" text-align: center; font-weight: 700; color: #fff;">Gli ordini ricevuti dal 22 dicembre 2018 al 2 gennaio 2019 saranno spediti dal 3 gennaio 2019.</h4></div>';
View edit-woocommerce-checkout-template.php
* Each of these samples can be used - note that you should pick one rather than add them all.
* How to use WC notices:
* Tutorial:
* Add a content block after all notices, such as the login and coupon notices.

WordPress escaping functions

By: Jonas Nordström, @windyjonas
Date: 2013-04-16

esc_attr( $text );
Encodes the <, >, &, " and ' (less than, greater than, ampersand, double quote and single quote) characters. Will never double encode entities.

<div class="<?php echo esc_attr( $my_class ); ?>"></div>
View wordpress permissions
sudo find . -type f -exec chmod 644 {} +
sudo find . -type d -exec chmod 755 {} +
sudo chown -R testuser:testuser /var/www/test/public_html
sudo chmod -R 777 /var/www/test/public_html
# This script configures WordPress file permissions based on recommendations
# from
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=$1 # <-- wordpress root directory
View province.txt
Ascoli Piceno

#Introduction If you're a php developer on ubuntu, there comes the time where you have to install/reinstall your system. I did it already a few times and i decided to write down the steps for a typical web developer stack with php. This is for a developer machine and not for a live environment!

I hope it helps you too!

fyi @mheiniger and me started with an installer here: