- Update text domain from 'umzugsliste' to 'siegel-umzugsliste' in plugin header - Add siegel_umzugsliste_load_textdomain() function hooked on init priority 1 - Add change_locale hook to reload text domain (workaround for WP core bug #39210) - Text domain loading enables translation file support in languages/ directory
150 lines
3.5 KiB
PHP
150 lines
3.5 KiB
PHP
<?php
|
|
/**
|
|
* Plugin Name: Umzugsliste
|
|
* Description: Email-basiertes Möbelauswahlsystem für Siegel Umzüge
|
|
* Version: 1.0.0
|
|
* Author: Siegel Umzüge
|
|
* Text Domain: siegel-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__ ) );
|
|
|
|
/**
|
|
* Load plugin text domain for translations
|
|
*/
|
|
function siegel_umzugsliste_load_textdomain() {
|
|
load_plugin_textdomain(
|
|
'siegel-umzugsliste',
|
|
false,
|
|
dirname( plugin_basename( __FILE__ ) ) . '/languages'
|
|
);
|
|
}
|
|
add_action( 'init', 'siegel_umzugsliste_load_textdomain', 1 );
|
|
|
|
/**
|
|
* Reload text domain on locale change
|
|
* Workaround for WordPress core bug #39210 where switch_to_locale() doesn't reload plugin translations
|
|
*/
|
|
add_action( 'change_locale', function() {
|
|
unload_textdomain( 'siegel-umzugsliste' );
|
|
load_plugin_textdomain(
|
|
'siegel-umzugsliste',
|
|
false,
|
|
dirname( plugin_basename( __FILE__ ) ) . '/languages'
|
|
);
|
|
} );
|
|
|
|
/**
|
|
* 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';
|
|
require_once UMZUGSLISTE_PLUGIN_DIR . 'includes/class-settings.php';
|
|
require_once UMZUGSLISTE_PLUGIN_DIR . 'includes/class-furniture-data.php';
|
|
require_once UMZUGSLISTE_PLUGIN_DIR . 'includes/class-date-helpers.php';
|
|
require_once UMZUGSLISTE_PLUGIN_DIR . 'includes/class-captcha.php';
|
|
require_once UMZUGSLISTE_PLUGIN_DIR . 'includes/class-form-renderer.php';
|
|
require_once UMZUGSLISTE_PLUGIN_DIR . 'includes/class-shortcode.php';
|
|
require_once UMZUGSLISTE_PLUGIN_DIR . 'includes/class-email-generator.php';
|
|
require_once UMZUGSLISTE_PLUGIN_DIR . 'includes/class-form-handler.php';
|
|
}
|
|
|
|
/**
|
|
* Initialize WordPress hooks
|
|
*/
|
|
private function init_hooks() {
|
|
add_action( 'init', array( $this, 'init' ) );
|
|
}
|
|
|
|
/**
|
|
* Initialize plugin components
|
|
*/
|
|
public function init() {
|
|
// Initialize and register CPT
|
|
$cpt = Umzugsliste_CPT::get_instance();
|
|
$cpt->register_post_type();
|
|
|
|
// Initialize admin menu
|
|
if ( is_admin() ) {
|
|
Umzugsliste_Admin_Menu::get_instance();
|
|
}
|
|
|
|
// Initialize settings
|
|
Umzugsliste_Settings::get_instance();
|
|
|
|
// Initialize shortcode
|
|
Umzugsliste_Shortcode::get_instance();
|
|
|
|
// Initialize form handler
|
|
Umzugsliste_Form_Handler::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' );
|