2025-06-05 11:51:30 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2025-06-09 19:31:23 +01:00
|
|
|
* Configures FAIR hosted assets throughout WordPress.
|
2025-06-05 11:51:30 +02:00
|
|
|
*
|
|
|
|
* @package FAIR
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace FAIR\Assets;
|
|
|
|
|
|
|
|
const DEFAULT_EMOJI_BASE = 'https://cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Bootstrap.
|
|
|
|
*/
|
|
|
|
function bootstrap() {
|
2025-06-26 18:10:59 +01:00
|
|
|
add_filter( 'emoji_url', __NAMESPACE__ . '\\replace_emoji_url' );
|
|
|
|
add_filter( 'emoji_svg_url', __NAMESPACE__ . '\\replace_emoji_svg_url' );
|
2025-06-05 11:51:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the base URL for the emoji images.
|
|
|
|
*
|
|
|
|
* @return string The base URL for emoji images. Must be in Twemoji format.
|
|
|
|
*/
|
|
|
|
function get_emoji_base_url() : string {
|
|
|
|
if ( defined( 'FAIR_EMOJI_BASE_URL' ) ) {
|
|
|
|
return FAIR_EMOJI_BASE_URL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DEFAULT_EMOJI_BASE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2025-06-09 19:31:23 +01:00
|
|
|
* Configure the base URL for regular emoji images.
|
2025-06-05 11:51:30 +02:00
|
|
|
*
|
2025-06-09 19:31:23 +01:00
|
|
|
* @return string The base URL.
|
2025-06-05 11:51:30 +02:00
|
|
|
*/
|
|
|
|
function replace_emoji_url() {
|
2025-06-26 18:10:59 +01:00
|
|
|
return get_emoji_base_url() . '72x72/';
|
2025-06-05 11:51:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2025-06-09 19:31:23 +01:00
|
|
|
* Configure the base URL for SVG emoji images.
|
2025-06-05 11:51:30 +02:00
|
|
|
*
|
2025-06-09 19:31:23 +01:00
|
|
|
* @return string The base URL.
|
2025-06-05 11:51:30 +02:00
|
|
|
*/
|
|
|
|
function replace_emoji_svg_url() {
|
2025-06-26 18:10:59 +01:00
|
|
|
return get_emoji_base_url() . 'svg/';
|
2025-06-05 11:51:30 +02:00
|
|
|
}
|