wp_create_nonce('wp_rest'), // Add other localized data if needed ]); } // Enqueue scripts for admin area only where needed (e.g., post/page edit screen) // add_action('wp_enqueue_scripts', 'story321_scripts'); // Likely not needed on frontend add_action('admin_enqueue_scripts', 'story321_scripts'); if (is_admin()) { // 添加设置菜单 add_action('admin_menu', function() { add_options_page( 'AI Generator Settings', 'AI Generator', // Shorter menu title 'manage_options', 'story321_settings', 'story321_setting_page' ); }); } function story321_register_settings() { // Register the API Key setting register_setting('story321-group', 'story321_api_key', array( 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', // Basic sanitization 'description' => __('Enter your API Key from Story321.com', 'ai-generator'), )); // Remove old settings registration /* register_setting('story321-group', 'story321_email', ...); register_setting('story321-group', 'story321_token', ...); register_setting('story321-group', 'story321_password', ...); register_setting('story321-group', 'story321_member_point', ...); register_setting('story321-group', 'story321_point', ...); register_setting('story321-group', 'story321_last_login', ...); */ } add_action( 'admin_init', 'story321_register_settings' ); // Remove login status check and auto-relogin functionality /* function story321_check_login_status() { ... } function story321_enqueue_auto_relogin() { ... } add_action('admin_init', 'story321_check_login_status'); add_action('wp_ajax_auto_relogin', function() { ... }); */ function story321_setting_page() { // Remove scripts related to cloud login/disconnect /* wp_enqueue_script( 'cloud-login', plugins_url('static/js/cloud-login.js', __FILE__), ... ); wp_localize_script('cloud-login', 'cloudLoginObj', ...); wp_localize_script('disconnect', 'disconnectObj', ...); */ $api_key = get_option('story321_api_key'); ?>