The following would port your option to LaTeX's built in key=val option handler.
\begin{filecontents}{foo.cls}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{foo}
\DeclareKeys[myoptions]
{
bibsize .store = \myoptions@bibsize,
unknown .code = \PassOptionsToClass{\CurrentOption}{article}
}
\SetKeys[myoptions]{bibsize=scriptsize}
\ProcessKeyOptions[myoptions]
\LoadClass[a4paper, twoside]{article}
\def\bibfont{\csname \myoptions@bibsize\endcsname}
\end{filecontents}
\documentclass[bibsize=footnotesize]{foo}
\begin{document}
Foo bar {\bibfont bibfont}
\end{document}
Alternative solution, just to show stuff using expkv-opt
(disclaimer: I'm the author of expkv-opt
).
\begin{filecontents}{foo.cls}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{foo}
\RequirePackage{expkv-opt, expkv-def}
\ekvdefinekeys{myoptions}
{
store bibsize = \myoptions@bibsize,
initial bibsize = scriptsize,
unknown code = \PassOptionsToClass{\CurrentOption}{article},
unknown noval = \PassOptionsToClass{\CurrentOption}{article}
}
\ekvoUseUnknownHandlers* % for the next ekvoProcess use set's unknown handlers
\ekvoProcessLocalOptions{myoptions} % these are forwarded to article
\ekvoProcessFutureOptions{myoptions} % these aren't, article doesn't support it
\LoadClass[a4paper, twoside]{article}
\def\bibfont{\csname \myoptions@bibsize\endcsname}
\end{filecontents}
\documentclass[bibsize=footnotesize]{foo}
\begin{document}
Foo bar {\bibfont bibfont}.
\end{document}
\DeclareKeys
or l3's\keys_define:nn
and\ProcessKeyOptions
. Seeclsguide.pdf
(current version) section 4.4 andinterface3.pdf
.clsguide.pdf
still a bit cryptic\ProcessKeyOptions
in thesty
andcls
files of your TeX distribution. I'm sure, there are several. Or see here on TeX.SX. Maybe start with tex.stackexchange.com/a/648001/277964 and if you have a new question about using it, please ask it.