Q:

What is preventing progress bar in beamer from showing up?

I'd like to add a progress bar to my presentation (I got the idea from this question) but I believe something is preventing it from showing up in output and I can't seem to figure it out. 
Here is my MWE:
\documentclass[xcolor=dvipsnames]{beamer}
\usepackage[danish]{babel}
\usepackage{booktabs} % Allows the use of \toprule, \midrule and \bottomrule in tables
\usepackage{amsmath}
\usepackage{enumitem}
\usepackage{fontspec}
\usepackage{polyglossia}
\usepackage{url}
\usepackage{graphics,epsfig, subfigure}
\usepackage{fancybox}
\usepackage{extarrows}
\usepackage{enumerate}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{mathtools} 
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{picture}
\usepackage{fancybox}
\usepackage{xcolor}

\mode<presentation> {

\usetheme{CambridgeUS}

\setbeamertemplate{headline}
{
  \leavevmode%
  \hbox{%
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.65ex,dp=1.5ex,center]{section in head/foot}%
    \usebeamerfont{section in head/foot}\insertsectionhead\hspace*{2ex}
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.65ex,dp=1.5ex,center]{subsection in head/foot}%
    \usebeamerfont{subsection in head/foot}\hspace*{2ex}\insertsubsectionhead
  \end{beamercolorbox}}%
  \vskip0pt%
}

}
  \useinnertheme{circles}
  \usefonttheme[onlymath]{serif}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\definecolor{pbblue}{HTML}{0A75A8}% color for the progress bar and the circle

\makeatletter
\def\progressbar@progressbar{} % the progress bar
\newcount\progressbar@tmpcounta% auxiliary counter
\newcount\progressbar@tmpcountb% auxiliary counter
\newdimen\progressbar@pbht %progressbar height
\newdimen\progressbar@pbwd %progressbar width
\newdimen\progressbar@rcircle % radius for the circle
\newdimen\progressbar@tmpdim % auxiliary dimension

\progressbar@pbwd=\linewidth
\progressbar@pbht=1pt
\progressbar@rcircle=2.5pt

% the progress bar
\def\progressbar@progressbar{%

    \progressbar@tmpcounta=\insertframenumber
    \progressbar@tmpcountb=\inserttotalframenumber
    \progressbar@tmpdim=\progressbar@pbwd
    \multiply\progressbar@tmpdim by \progressbar@tmpcounta
    \divide\progressbar@tmpdim by \progressbar@tmpcountb

  \begin{tikzpicture}
    \draw[pbblue!30,line width=\progressbar@pbht]
      (0pt, 0pt) -- ++ (\progressbar@pbwd,0pt);

    \filldraw[pbblue!30] %
      (\the\dimexpr\progressbar@tmpdim-\progressbar@rcircle\relax, .5\progressbar@pbht) circle (\progressbar@rcircle);

    \node[draw=pbblue!30,text width=3.5em,align=center,inner sep=1pt,
      text=pbblue!70,anchor=east] at (0,0) {\insertframenumber/\inserttotalframenumber};
  \end{tikzpicture}%
}

\addtobeamertemplate{headline}{}
{%
  \begin{beamercolorbox}[wd=\paperwidth,ht=4ex,center,dp=1ex]{white}%
    \progressbar@progressbar%
  \end{beamercolorbox}%
}
\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
  \setbeamertemplate{blocks}[rounded][shadow=true]
\setbeamertemplate{frametitle}[default][right]% align the frametitle to the right
\setdefaultlanguage{english}
\setotherlanguage[calendar=gregorian,numerals=maghrib]{arabic}
\setbeamercolor{block title}{bg=green,fg=black}

\AtBeginEnvironment{exampleblock}{\setbeamercolor{item projected}{bg=gray}}

\newfontfamily\arabicfont[Script=Arabic,Scale=0.8]{IRNazli}
\newfontfamily\latinfontsf[Script=Latin,Scale=0.3]{Calibri}
\newfontfamily\arabicfontsf[Script=Arabic,Scale=0.8]{IRNazli}
\newfontfamily\digitfont[Script=Arabic,Scale=0.8]{IRNazli}
\newfontfamily{\F}{IRNazli} % Farsi
\newfontfamily{\I}{IranNastaliq} % Farsi
\newfontfamily{\C}{Calibri}
\setbeamercovered{transparent}

%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\newcommand{\myitemII}{\par\vspace{3pt}\hspace{5mm}\LR{\hspace*{3pt}%
\begin{pgfpicture}{-1ex}{-0.65ex}{1ex}{1ex}
\usebeamercolor[fg]{item projected}
{\pgftransformscale{2}\pgftext{\normalsize\pgfuseshading{\setbeamertemplate{enumerate items}[circle]}}}
\end{pgfpicture}%
\hspace{1pt}%
}}
% ======================================================
\makeatletter
\DeclareMathSizes{\f@size}{10}{7}{7}
\makeatother

\makeatletter
\defbeamertemplate*{headline}{arabic split theme}
{

  \leavevmode%
    \@tempdimb=2.4375ex%
      \ifnum\beamer@subsectionmax<\beamer@sectionmax%
    \multiply\@tempdimb by\beamer@sectionmax%
  \else%
    \multiply\@tempdimb by\beamer@subsectionmax%
  \fi%
  \ifdim\@tempdimb>0pt%
    \advance\@tempdimb by 1.825ex%
    \begin{beamercolorbox}[wd=.5\paperwidth,ht=\@tempdimb]{subsection in head/foot}%
      \vbox to\@tempdimb{\vfil\insertsubsectionnavigation{.5\paperwidth}\vfil}%
      \usebeamerfont{subsection in head/foot}\hspace*{4ex}\insertsubsectionhead
    \end{beamercolorbox}%
    \begin{beamercolorbox}[wd=.5\paperwidth,ht=\@tempdimb]{section in head/foot}%
\vbox to\@tempdimb{\vfil\insertsectionnavigation{.5\paperwidth}\vfil}%
  \usebeamerfont{section in head/foot}\insertsectionhead\vfil%
    \end{beamercolorbox}%
  \fi%
}
\makeatother

%----------------------------------------------------------------------------------------
%   TITLE PAGE
%----------------------------------------------------------------------------------------

\title{\F \RL{\textbf{مسئله یادگیری دیکشنری }}} 

\author{{\setRTL \F \RL{\textbf{فلان الدین فلانی}}} }
\institute[] 
{
\F \RL{\textbf{\normalsize{ دانشگاه فلان}}} 
\medskip

}
\date{\F \RL{شهریور ۱۲۹۱}} 

\begin{document}

\begin{frame}
\end{frame}

\begin{frame}
\end{frame}

\begin{frame}
\end{frame}

\end{document}

But nothing shows up in the output as a progress bar. I'd like to know what is preventing it from showing up.
EDIT: I think I found the cause; when I remove this part from the code, the progress bar appears in the ouptput document. 
\makeatletter
\DeclareMathSizes{\f@size}{10}{7}{7}
\makeatother

\makeatletter
\defbeamertemplate*{headline}{arabic split theme}
{

  \leavevmode%
    \@tempdimb=2.4375ex%
      \ifnum\beamer@subsectionmax<\beamer@sectionmax%
    \multiply\@tempdimb by\beamer@sectionmax%
  \else%
    \multiply\@tempdimb by\beamer@subsectionmax%
  \fi%
  \ifdim\@tempdimb>0pt%
    \advance\@tempdimb by 1.825ex%
    \begin{beamercolorbox}[wd=.5\paperwidth,ht=\@tempdimb]{subsection in head/foot}%
      \vbox to\@tempdimb{\vfil\insertsubsectionnavigation{.5\paperwidth}\vfil}%
      \usebeamerfont{subsection in head/foot}\hspace*{4ex}\insertsubsectionhead
    \end{beamercolorbox}%
    \begin{beamercolorbox}[wd=.5\paperwidth,ht=\@tempdimb]{section in head/foot}%
\vbox to\@tempdimb{\vfil\insertsectionnavigation{.5\paperwidth}\vfil}%
  \usebeamerfont{section in head/foot}\insertsectionhead\vfil%
    \end{beamercolorbox}%
  \fi%
}
\makeatother

But I really don't have a clue what this part of the code is doing because the template was a ready-to-use beamer presentation template that the university recommends to use. So what do you suggest to do?

A:

This is too long for a comment.
Actually @samcarter figured out the problem: this is how things go wrong

You insert progress bar into the headline template by \addtobeamertemplate
You define a new headline template called arabic split theme by \defbeamertemplate*.
Since you are calling the starred version, BEAMER will define and then install this template.
The progress bar is erased.

To be more precise, the official description of \addtobeamertemplate reads:

This command adds the ⟨pre-text⟩ before the text that is currently installed as the template ⟨element name⟩ and the ⟨post-text⟩ after it. This allows you a limited form of modification of existing templates.
  ...
  If a new template is installed, any additions will be deleted. On the other hand, you can repeatedly use this command to add multiple things.

And the official description of \defbeamertemplate reads:

This command installs a prede ned option for the template ⟨element name⟩. Once this command has been used, users can access the prede ned template using the \setbeamertemplate command.
  ...
  The starred version of the command installs the predefined template option, but then immediately calls \setbeamertemplate for this option. This is useful for the default templates.

So you have several choices:

Delete * from \def..., so the new-defined style will not be installed and progress bar will remain.
Exchange the order of \add... and \def... so nothing can erase the progress bar.
Include the progress bar in the definition of a new template. 

