Skip to content

Instantly share code, notes, and snippets.

Marco Almeida webdados

Block or report user

Report or block webdados

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
webdados / woocommerce_get_european_union_countries_after_wc4.php
Last active Apr 7, 2020
Workaround for WooCommerce get_european_union_countries( 'eu_vat' ) after WooCommerce 4.0.0
View woocommerce_get_european_union_countries_after_wc4.php
//See here why this is needed:
function woocommerce_get_european_union_countries_after_wc4( $type = '' ) {
$countries = WC()->countries->get_european_union_countries();
if ( 'eu_vat' === $type ) {
$countries[] = 'MC';
$countries[] = 'IM';
$countries[] = 'GB'; //Great Britain is still part of the EU VAT zone
return $countries;
webdados / remove_wp_54_favicon.php
Last active May 13, 2020
Do not show WordPress 5.4 default WP blue favicon
View remove_wp_54_favicon.php
add_action( 'do_faviconico', function() {
//Check for icon with no default value
if ( $icon = get_site_icon_url( 32 ) ) {
//Show the icon
wp_redirect( $icon );
} else {
//Show nothing
header( 'Content-Type: image/' );
webdados / woo_dpd_portugal_issue_label.php
Last active Mar 29, 2020
Create a DPD Portugal shipping label programmatically with the "DPD Portugal for WooCommerce" WordPress plugin
View woo_dpd_portugal_issue_label.php
//You need this plugin:
//Monitor the result and do whatver you want with it
add_action( 'woo_dpd_portugal_label_issued', function( $order_id ) {
$order = wc_get_order( $order_id );
echo 'Label issued for order '.$order_id.' on '.$order->get_meta( '_woo_dpd_portugal_label_issued' ).'<br/>';
echo 'Tracking number(s): '.implode( ' / ', $order->get_meta( '_woo_dpd_portugal_tracking_number' ) ).'<br/>';
echo 'Label PDF URL: '.$order->get_meta( '_woo_dpd_portugal_pdf_url' ).'<br/>';
webdados / remove_acores_madeira_pickup_points.php
Last active Feb 17, 2020
Remove Açores and Madeira pickup points from Portugal Chronopost Pickup network for WooCommerce and/or Portugal VASP Expresso Kios network for WooCommerce
View remove_acores_madeira_pickup_points.php
//Uncomment next line to activate for Chronopost
//add_filter( 'cppw_available_points', 'remove_acores_madeira_pickup_points', 10, 2 );
//Uncomment next line to activate for Chronopost
//add_filter( 'pvkw_available_points', 'remove_acores_madeira_pickup_points', 10, 2 );
//The filter function
function remove_acores_madeira_pickup_points( $points, $postcode ) {
foreach ( $points as $key => $point ) {
webdados / delete_all_comments.php
Created Feb 5, 2020
Delete all comments from a WordPress post
View delete_all_comments.php
- Save this PHP file to the root of your WordPress website
- Log in as Administrator
- Change the post ID on line 13
- Call the PHP file it directly on your borwser
webdados / woocommerce_email_customer_details.php
Created Jan 14, 2020
Remove addresses from WooCommerce emails
View woocommerce_email_customer_details.php
remove_action( 'woocommerce_email_customer_details', array( WC_Emails::instance() , 'email_addresses' ), 20 );
webdados / wc_customer_has_capability_override_pay_for_order.php
Created Jan 8, 2020
Allow any user (logged in or not) to pay for any other user (or guest) WooCommerce order
View wc_customer_has_capability_override_pay_for_order.php
add_filter( 'user_has_cap', 'wc_customer_has_capability_override_pay_for_order', 15, 3 );
function wc_customer_has_capability_override_pay_for_order( $allcaps, $caps, $args ) {
if ( isset( $caps[0] ) ) {
switch ( $caps[0] ) {
case 'pay_for_order':
$allcaps['pay_for_order'] = true;
webdados / shop_as_client_pro_search_order_statuses.php
Created Jan 7, 2020
Limit the order statuses where the customer is searched (if not found as a user) on Shop as Client PRO
View shop_as_client_pro_search_order_statuses.php
/* Add this to you (child-)theme functions.php file */
add_filter( 'shop_as_client_pro_search_order_statuses', 'my_shop_as_client_pro_search_order_statuses' );
function my_shop_as_client_pro_search_order_statuses( $statuses ) {
//Only for Processing and Completed orders
$statuses = array( 'processing', 'completed' );
return $statuses;
webdados / vcex_social_links_profiles.php
Last active Jan 7, 2020
Add new options to the Visual Composer Social Links module
View vcex_social_links_profiles.php
webdados / redirect_if_not_logged_in.php
Created Jan 6, 2020
Poor guy's Private WordPress Website - Redirect a user to the login form if he's not logged in
View redirect_if_not_logged_in.php
add_action( 'template_redirect', 'redirect_if_not_logged_in' );
function redirect_if_not_logged_in() {
if ( ! is_user_logged_in() ) wp_redirect( wp_login_url( $_SERVER['REQUEST_URI'] ) );
You can’t perform that action at this time.