76 lines
1.6 KiB
PHP
76 lines
1.6 KiB
PHP
<?php
|
|
/**
|
|
* Plugin bootstrap singleton.
|
|
*
|
|
* @package FontdelboscCombustible
|
|
*/
|
|
|
|
declare( strict_types=1 );
|
|
|
|
defined( 'ABSPATH' ) || exit;
|
|
|
|
/**
|
|
* Wires hooks and loads the textdomain.
|
|
*/
|
|
final class Fontdelbosc_Combustible_Plugin {
|
|
|
|
/**
|
|
* Singleton instance.
|
|
*
|
|
* @var self|null
|
|
*/
|
|
private static ?self $instance = null;
|
|
|
|
/**
|
|
* Returns the singleton.
|
|
*/
|
|
public static function instance(): self {
|
|
return self::$instance ??= new self();
|
|
}
|
|
|
|
/**
|
|
* Constructor: wires every hook.
|
|
*/
|
|
private function __construct() {
|
|
add_action( 'plugins_loaded', array( self::class, 'load_textdomain' ) );
|
|
add_action( 'wp_enqueue_scripts', array( self::class, 'register_assets' ) );
|
|
add_action( 'init', array( 'Fontdelbosc_Combustible_Shortcode', 'init' ) );
|
|
add_action( 'widgets_init', array( self::class, 'register_widget' ) );
|
|
|
|
if ( is_admin() ) {
|
|
Fontdelbosc_Combustible_Admin::init();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Loads the plugin textdomain.
|
|
*/
|
|
public static function load_textdomain(): void {
|
|
load_plugin_textdomain(
|
|
'fontdelbosc-combustible',
|
|
false,
|
|
dirname( plugin_basename( FONTDELBOSC_COMBUSTIBLE_FILE ) ) . '/languages/'
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Registers the public stylesheet.
|
|
*/
|
|
public static function register_assets(): void {
|
|
$css = FONTDELBOSC_COMBUSTIBLE_DIR . 'public/css/fdbc-fuel.css';
|
|
|
|
wp_register_style(
|
|
'fdbc-fuel',
|
|
plugin_dir_url( FONTDELBOSC_COMBUSTIBLE_FILE ) . 'public/css/fdbc-fuel.css',
|
|
array(),
|
|
(string) filemtime( $css )
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Registers the widget.
|
|
*/
|
|
public static function register_widget(): void {
|
|
register_widget( 'Fontdelbosc_Combustible_Widget' );
|
|
}
|
|
}
|