I'm passing variables from options to the front-end using wp_localize_script. Issue is that now I have 71 input fields in the options page with these ids: calc_m_transport_1, calc_m_transport_2 and so on till 71.

What would be the efficient way to pass this data to the front-end?

Right now this is how I'm doing it:

$phpValues = array(
        'value1' => get_option( 'plugin_name_value1'),
        wp_localize_script( $this->plugin_name, 'phpValues', $phpValues )

I think you are looking like :

$phpValues = array();
    $phpValues['value'.$i] = get_option('plugin_name_value'.$i);

wp_localize_script( $this->plugin_name, 'phpValues', $phpValues )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.