shortcode = new \Eproi\OneAeventure\Shortcode\AeventShortcode(); $this->meta = new \Eproi\OneAeventure\Meta\AeventMeta(); } /** * Registers all WordPress hooks required for the plugin. * * @return void */ public function run(): void { add_action('init', [$this, 'register_aevent_post_type']); add_action('admin_menu', [$this, 'add_admin_page']); add_action('admin_enqueue_scripts', [$this, 'enqueue_admin_assets']); $this->meta->register_hooks(); $this->shortcode->register(); } public function enqueue_admin_assets($hook): void { if ($hook !== 'toplevel_page_one-aeventure') { return; } wp_enqueue_script( 'oneaev-admin-js', ONEAEV_PLUGIN_ASSETS . 'js/admin.js', array(), '1.0.0', true ); } /** * Registers the Aevent custom post type. * * Note: * The block editor is intentionally disabled for this post type. * All event data is collected through a structured, guided form to ensure * that every field is provided in a consistent and validated format. * After submission, the plugin automatically generates the required * Gutenberg blocks based on these meta fields. * * This approach is chosen for two reasons: * 1) Maximum compatibility with the WordPress ecosystem by producing * standard Gutenberg output without exposing free-form editing. * 2) Performance: rendering does not require additional dynamic loops * or complex processing, since the block structure is generated once * and stored directly as post content. * * @return void */ public function register_aevent_post_type(): void { $icon = ONEAEV_PLUGIN_ASSETS . 'pics/icon.svg'; register_post_type('aevent', [ 'labels' => [ 'name' => __('Aevents', 'one-aeventure'), 'singular_name' => __('Aevent', 'one-aeventure'), ], 'public' => true, 'has_archive' => true, 'rewrite' => ['slug' => 'aevent'], 'supports' => ['title', 'thumbnail'], // Hide CPT from main admin menu as we will put it down under our adminmenue entry 'show_in_menu' => false, // Use plugin icon for CPT (for list table etc.) 'menu_icon' => $icon, ]); } /** * Registers the admin menu entry for the plugin. * * @return void */ public function add_admin_page(): void { $icon = ONEAEV_PLUGIN_ASSETS . 'pics/icon.svg'; add_menu_page( __('One-Aeventure', 'one-aeventure'), __('One-Aeventure', 'one-aeventure'), 'manage_options', 'edit.php?post_type=aevent', // taking slug of first submenu-entry avoiding a "third" submenupage '', $icon, 100 ); add_submenu_page( 'edit.php?post_type=aevent', __('AEvents', 'one-aeventure'), __('AEvents', 'one-aeventure'), 'manage_options', 'edit.php?post_type=aevent' ); add_submenu_page( 'edit.php?post_type=aevent', __('Einstellungen', 'one-aeventure'), __('Einstellungen', 'one-aeventure'), 'manage_options', 'one-aeventure-settings', [$this, 'render_admin_page'] ); } /** * Renders the plugin admin page. * * @return void */ public function render_admin_page(): void { if (!current_user_can('manage_options')) { return; } echo '
' . esc_html(__('This is the base version. Additional add-ons are available.', 'one-aeventure')) . '
'; echo '' . esc_html(__('Use the following shortcode to display all events:', 'one-aeventure')) . '
'; echo '[aevent_list]';
echo '';
echo '