Skip to content

Instantly share code, notes, and snippets.

@olance
Created March 24, 2021 16:38
Show Gist options
  • Save olance/38dc5309a76e98fd45c767628aa0be15 to your computer and use it in GitHub Desktop.
Save olance/38dc5309a76e98fd45c767628aa0be15 to your computer and use it in GitHub Desktop.
Enable Alma on WooCommerce for different locales
<?php
/**
* Enable Alma for locales other than fr_*
*
* INSTRUCTIONS:
* -> Edit the file to add locales you want Alma to be enabled for
* -> Add this file to a new wp-content/plugins/alma-locale-enabler/ folder
* -> Activate the "Alma Locale Enabler" in the WordPress admin
*
* @since 1.0.0
* @package Alma_Locale_Enabler
*
* @wordpress-plugin
* Plugin Name: Alma Locale Enabler
* Plugin URI: https://getalma.eu
* Description: This plugin allows enabling Alma for locales other than French
* Version: 1.0.0
* Author: Alma
* Author URI: http://getalma.eu/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: alma-locale-enabler
* Domain Path: /languages
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
function alma_locale_enabler_check_locale( $accepted, $locale ) {
// TODO: Adapt this part of the code to enable Alma for any locale you need
if ( "en_US" === $locale ) {
return true;
}
// This keeps Alma activated for french locales, since they are by default
// If you want to disable Alma for french locales, return false accordingly
return $accepted;
}
add_filter( 'alma_wc_enable_for_locale', 'alma_locale_enabler_check_locale', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment