db = new ACSIL_Database(); $this->scanner = new ACSIL_Scanner( $this->db ); $this->admin_page = new ACSIL_Admin_Page( $this->db, $this->scanner ); $this->meta_box = new ACSIL_Meta_Box( $this->db ); $this->dashboard = new ACSIL_Dashboard( $this->db ); $this->post_list = new ACSIL_Post_List( $this->db ); $this->rest_api = new ACSIL_REST_API( $this->db, $this->scanner ); $this->register_hooks(); } private function register_hooks(): void { // 投稿保存時に自動スキャン add_action( 'save_post', array( $this->scanner, 'on_save_post' ), 20, 2 ); // 投稿削除・ゴミ箱移動時にリンクデータ削除 add_action( 'before_delete_post', array( $this->db, 'delete_post_links' ) ); add_action( 'wp_trash_post', array( $this->db, 'delete_post_links' ) ); // 管理画面 add_action( 'admin_menu', array( $this->admin_page, 'register_menus' ) ); add_action( 'admin_enqueue_scripts', array( $this->admin_page, 'enqueue_scripts' ) ); add_action( 'admin_init', array( $this->admin_page, 'maybe_dismiss_review_notice' ) ); // 投稿編集サイドバー add_action( 'add_meta_boxes', array( $this->meta_box, 'register' ) ); // ダッシュボードウィジェット add_action( 'wp_dashboard_setup', array( $this->dashboard, 'register' ) ); // 投稿一覧カラム add_action( 'init', array( $this->post_list, 'register_column_hooks' ), 20 ); // REST API add_action( 'rest_api_init', array( $this->rest_api, 'register_routes' ) ); // Ajax add_action( 'wp_ajax_acsil_scan_batch', array( $this->scanner, 'ajax_scan_batch' ) ); add_action( 'wp_ajax_acsil_delete_data', array( $this->db, 'ajax_delete_data' ) ); // 初回スキャン案内 add_action( 'admin_notices', array( $this, 'maybe_show_scan_notice' ) ); } // ── 有効化・無効化 ───────────────────────────────────────────────────── public static function activate(): void { $db = new ACSIL_Database(); $db->create_table(); // デフォルト設定を保存 if ( false === get_option( 'acsil_settings' ) ) { update_option( 'acsil_settings', self::default_settings() ); } // 初回スキャン案内フラグ update_option( 'acsil_initial_scan_needed', '1' ); } public static function deactivate(): void { // 何もしない(データは保持) } // ── 初回スキャン案内 ─────────────────────────────────────────────────── public function maybe_show_scan_notice(): void { if ( ! current_user_can( 'manage_options' ) ) { return; } if ( ! get_option( 'acsil_initial_scan_needed' ) ) { return; } $scan_url = admin_url( 'admin.php?page=acsil-link-map' ); printf( '
%s %s