time(), 'l' => $level, 'm' => $message, ); if ( count( $log ) > self::MAX ) { $log = array_slice( $log, -self::MAX ); } update_option( self::OPTION, $log, false ); if ( defined( 'WP_CLI' ) && WP_CLI ) { 'error' === $level ? WP_CLI::warning( $message ) : WP_CLI::log( $message ); } } public static function error( $message ) { self::log( $message, 'error' ); } public static function get( $limit = 100 ) { $log = get_option( self::OPTION, array() ); return array_slice( is_array( $log ) ? $log : array(), -$limit ); } public static function clear() { delete_option( self::OPTION ); } }