errors[ $code ][] = $message; if ( $data ) { $this->error_data[ $code ] = $data; } } } public function get_error_code() { $codes = array_keys( $this->errors ); return $codes ? $codes[0] : ''; } public function get_error_message( $code = '' ) { if ( ! $code ) { $code = $this->get_error_code(); } return isset( $this->errors[ $code ] ) ? $this->errors[ $code ][0] : ''; } } } // ── Load plugin classes for testing ─────────────────────────────────── // Content filter can be loaded standalone (no WordPress runtime needed). require_once PEPTIDE_NEWS_PLUGIN_DIR . 'includes/class-peptide-news-content-filter.php'; // LLM class provides is_valid_model() used by Admin sanitize callbacks. require_once PEPTIDE_NEWS_PLUGIN_DIR . 'includes/class-peptide-news-llm.php'; // Stub WP_REST_Request for REST API tests. if ( ! class_exists( 'WP_REST_Request' ) ) { class WP_REST_Request { private $params = array(); private $method = 'GET'; public function __construct( $method = 'GET', $route = '' ) { $this->method = $method; } public function set_param( $key, $value ) { $this->params[ $key ] = $value; } public function get_param( $key ) { return isset( $this->params[ $key ] ) ? $this->params[ $key ] : null; } public function get_params() { return $this->params; } } }