*/ private static $hook_suffixes = array(); /** * フック登録。 */ public static function boot(): void { require_once AILENS_PLUGIN_DIR . 'includes/admin/class-ailens-settings-page.php'; require_once AILENS_PLUGIN_DIR . 'includes/admin/class-ailens-import.php'; add_action( 'admin_menu', array( __CLASS__, 'register_menu' ) ); add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_assets' ) ); add_action( 'admin_init', array( 'Ailens_Settings_Page', 'register_settings' ) ); add_action( 'admin_post_ailens_import_upload', array( 'Ailens_Import', 'handle_upload' ) ); add_action( 'admin_post_ailens_import_process', array( 'Ailens_Import', 'handle_process' ) ); add_action( 'admin_post_ailens_import_cancel', array( 'Ailens_Import', 'handle_cancel' ) ); // ダッシュボードの週次レポートトグル(v0.1.7)。 add_action( 'admin_post_ailens_toggle_weekly', array( 'Ailens_Dashboard', 'handle_toggle_weekly' ) ); // 週次レポートのダッシュボードウィジェット(v0.1.2)。 add_action( 'wp_dashboard_setup', static function (): void { require_once AILENS_PLUGIN_DIR . 'includes/admin/class-ailens-dashboard-widget.php'; Ailens_Dashboard_Widget::register(); } ); } /** * トップレベルメニュー「AILYS Lens」。 */ public static function register_menu(): void { self::$hook_suffixes[] = add_menu_page( __( 'AILYS Lens', 'ailys-lens' ), __( 'AILYS Lens', 'ailys-lens' ), 'manage_options', 'ailys-lens', array( 'Ailens_Dashboard', 'render' ), 'dashicons-visibility' ); self::$hook_suffixes[] = add_submenu_page( 'ailys-lens', __( 'AILYS Lens Settings', 'ailys-lens' ), __( 'Settings', 'ailys-lens' ), 'manage_options', 'ailys-lens-settings', array( 'Ailens_Settings_Page', 'render' ) ); } /** * 自ページのみCSSを読み込む(外部CDN禁止・JSなし)。 * * @param string $hook 現在の管理ページフック。 */ public static function enqueue_assets( string $hook ): void { if ( ! in_array( $hook, self::$hook_suffixes, true ) ) { return; } wp_enqueue_style( 'ailys-lens-admin', plugins_url( 'assets/admin.css', AILENS_PLUGIN_FILE ), array(), AILENS_VERSION ); } /** * ページ見出し(

)用のロゴマークアップ。 * * ロゴはプラグイン同梱のSVGを自プラグインURLから読み込む(外部URL参照なし)。 * WordPressはadmin noticeを最初の

(または.wp-header-end)の直後に挿入する * ため、

要素自体は呼び出し側で維持すること(このメソッドは中身のみ返す)。 * * @param string $suffix_text 翻訳済みの追加テキスト(例: "Settings")。空なら付与しない。 */ public static function logo_html( string $suffix_text = '' ): string { $src = plugins_url( 'assets/images/ailys-lens-logo.svg', AILENS_PLUGIN_FILE ); $html = 'AILYS Lens'; if ( '' !== $suffix_text ) { $html .= ' ' . esc_html( $suffix_text ) . ''; } return $html; } }