'', 'planning_model' => 'google/gemini-2.0-flash-exp', 'execution_model' => 'anthropic/claude-sonnet-4-20250514', 'image_model' => 'openai/gpt-4o', 'web_search_enabled' => false, 'search_engine' => 'auto', 'search_depth' => 'medium', 'cost_tracking_enabled' => true, 'chat_history_limit' => 20, 'preferred_languages' => array( 'auto', 'English', 'Indonesian' ), 'custom_languages' => array(), ); add_option( 'wp_agentic_writer_settings', $default_options ); // Create cost tracking table. wp_agentic_writer_create_cost_table(); } /** * Create cost tracking table. * * @since 0.1.0 */ function wp_agentic_writer_create_cost_table() { global $wpdb; $table_name = $wpdb->prefix . 'wpaw_cost_tracking'; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE $table_name ( id bigint(20) NOT NULL AUTO_INCREMENT, post_id bigint(20) NOT NULL, model varchar(255) NOT NULL, action varchar(50) NOT NULL, input_tokens int(11) NOT NULL, output_tokens int(11) NOT NULL, cost decimal(10,6) NOT NULL, created_at datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, PRIMARY KEY (id), KEY post_id (post_id) ) $charset_collate;"; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta( $sql ); } // Deactivation hook. register_deactivation_hook( __FILE__, 'wp_agentic_writer_deactivate' ); /** * Plugin deactivation. * * @since 0.1.0 */ function wp_agentic_writer_deactivate() { // Cleanup if needed. } // Uninstall hook. register_uninstall_hook( __FILE__, 'wp_agentic_writer_uninstall' ); /** * Plugin uninstall. * * @since 0.1.0 */ function wp_agentic_writer_uninstall() { // Delete options. delete_option( 'wp_agentic_writer_settings' ); // Delete cost tracking table. global $wpdb; $table_name = $wpdb->prefix . 'wpaw_cost_tracking'; $wpdb->query( "DROP TABLE IF EXISTS $table_name" ); }