feat(01-01): create main plugin file with bootstrap code
- WordPress plugin header with proper metadata - Plugin version constants and paths - Main Umzugsliste class with singleton pattern - Activation/deactivation hooks with flush_rewrite_rules - Autoloader for includes/ directory - Init hook to initialize plugin components
This commit is contained in:
106
umzugsliste.php
Normal file
106
umzugsliste.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: Umzugsliste
|
||||
* Description: Email-basiertes Möbelauswahlsystem für Siegel Umzüge
|
||||
* Version: 1.0.0
|
||||
* Author: Siegel Umzüge
|
||||
* Text Domain: umzugsliste
|
||||
* Domain Path: /languages
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Plugin version
|
||||
define( 'UMZUGSLISTE_VERSION', '1.0.0' );
|
||||
define( 'UMZUGSLISTE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
||||
define( 'UMZUGSLISTE_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
||||
|
||||
/**
|
||||
* Main plugin class
|
||||
*/
|
||||
class Umzugsliste {
|
||||
|
||||
/**
|
||||
* Single instance of the class
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* Get single instance
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
private function __construct() {
|
||||
$this->load_dependencies();
|
||||
$this->init_hooks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load required files
|
||||
*/
|
||||
private function load_dependencies() {
|
||||
require_once UMZUGSLISTE_PLUGIN_DIR . 'includes/class-cpt.php';
|
||||
require_once UMZUGSLISTE_PLUGIN_DIR . 'includes/class-admin-menu.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize WordPress hooks
|
||||
*/
|
||||
private function init_hooks() {
|
||||
add_action( 'init', array( $this, 'init' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize plugin components
|
||||
*/
|
||||
public function init() {
|
||||
// Initialize CPT
|
||||
Umzugsliste_CPT::get_instance();
|
||||
|
||||
// Initialize admin menu
|
||||
if ( is_admin() ) {
|
||||
Umzugsliste_Admin_Menu::get_instance();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Activation hook
|
||||
*/
|
||||
function umzugsliste_activate() {
|
||||
// Initialize CPT to register post type
|
||||
require_once UMZUGSLISTE_PLUGIN_DIR . 'includes/class-cpt.php';
|
||||
Umzugsliste_CPT::get_instance();
|
||||
|
||||
// Flush rewrite rules
|
||||
flush_rewrite_rules();
|
||||
}
|
||||
register_activation_hook( __FILE__, 'umzugsliste_activate' );
|
||||
|
||||
/**
|
||||
* Deactivation hook
|
||||
*/
|
||||
function umzugsliste_deactivate() {
|
||||
// Flush rewrite rules
|
||||
flush_rewrite_rules();
|
||||
}
|
||||
register_deactivation_hook( __FILE__, 'umzugsliste_deactivate' );
|
||||
|
||||
/**
|
||||
* Initialize plugin
|
||||
*/
|
||||
function umzugsliste_init() {
|
||||
return Umzugsliste::get_instance();
|
||||
}
|
||||
add_action( 'plugins_loaded', 'umzugsliste_init' );
|
||||
Reference in New Issue
Block a user