Why is an array created in a function hooked to customize register populated when customizer is loaded but not when the front-end is loaded?

Couple points:

  • The customize_register action hook actually passes your function the $wp_customize variable, you don’t need to declare it as the global. Just put it as the first argument in your function declaration.

  • The reason your code doesn’t run on the front end of the site is that the customize_register action hook only runs when the customizer is being used. If you want to declare data somewhere that it will always be available, don’t put it in a function hooked to customize_register.