Files
wp-plugin-starter-template-…/includes/class-plugin.php
marcusquinn 40ebbce1cc Improve code quality to move from B to A grade
- Added proper type declarations to all properties and methods
- Fixed inconsistent variable naming (camelCase to snake_case)
- Improved path handling in admin class
- Added textdomain loading functionality
- Removed unused phpcs:ignore comment
- Implemented proper return type declarations
2025-04-21 16:52:56 +01:00

81 lines
1.5 KiB
PHP

<?php
/**
* Main plugin class
*
* @package WPALLSTARS\PluginStarterTemplate
*/
namespace WPALLSTARS\PluginStarterTemplate;
use WPALLSTARS\PluginStarterTemplate\Admin\Admin;
/**
* Plugin class
*/
class Plugin {
/**
* Core instance
*
* @var Core
*/
private Core $core;
/**
* Admin instance
*
* @var Admin
*/
private Admin $admin;
/**
* Plugin file path
*
* @var string
*/
private string $pluginFile;
/**
* Plugin version
*
* @var string
*/
private string $version;
/**
* Constructor
*
* @param string $pluginFile Main plugin file path.
* @param string $version Plugin version.
*/
public function __construct( string $pluginFile, string $version ) {
$this->pluginFile = $pluginFile;
$this->version = $version;
$this->core = new Core( $version );
$this->admin = new Admin( $this->core );
}
/**
* Initialize the plugin
*/
public function init(): void {
// Register hooks and filters.
add_action('plugins_loaded', array($this, 'load_textdomain'));
// Initialize any other plugin functionality.
}
/**
* Load plugin textdomain.
*
* @return void
*/
public function load_textdomain(): void {
load_plugin_textdomain(
'wp-plugin-starter-template',
false,
dirname(plugin_basename($this->pluginFile)) . '/languages/'
);
}
}