Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

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>
@edoardo-mb
edoardo-mb / functions.php
Created Jan 22, 2019 — forked from lmartins/functions.php
By default WooCommerce redirects the user to the My Account page after a successful login. You may change this and use a custom URL based on the user role, like the Dashboard for admins and My Account page for customers. To do this, add this code at the end of the file functions.php located in wp-content/themes/your-theme-name/ https://support.w…
View functions.php
<?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
@edoardo-mb
edoardo-mb / functions.php
Created Dec 20, 2018
Add custom message to cart and checkout
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>';
}
@edoardo-mb
edoardo-mb / edit-woocommerce-checkout-template.php
Created Dec 6, 2018 — forked from bekarice/edit-woocommerce-checkout-template.php
Add content and notices to the WooCommerce checkout - sample code
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: https://github.com/woothemes/woocommerce/blob/master/includes/wc-notice-functions.php#L96
* Tutorial: http://www.skyverge.com/blog/edit-woocommerce-templates/
**/
/**
* Add a content block after all notices, such as the login and coupon notices.
*
@edoardo-mb
edoardo-mb / wordpress-escaping.md
Created Nov 5, 2018 — forked from windyjonas/wordpress-escaping.md
Most of the escaping functions in WordPress, with a short explanation and example.
View wordpress-escaping.md

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.
Example:

<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
View fix-wordpress-permissions.sh
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# 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
@edoardo-mb
edoardo-mb / province.txt
Created Mar 21, 2018 — forked from iamlucamilan/province.txt
Lista province italiane
View province.txt
Agrigento
Alessandria
Ancona
Aosta
Arezzo
Ascoli Piceno
Asti
Avellino
Bari
Barletta-Andria-Trani
View ubuntu-php-development-environment.md

#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: https://github.com/mheiniger/webdev-setup

You can’t perform that action at this time.