How Can I Update wp_enqueue_scripts () From WordPress Option Page Radio Buttons

by Mona Coder   Last Updated January 14, 2018 10:08 AM

Can you please take a look at this script and let me know how can I update the wp_enqueue_scripts () in theme functions.php based on radio select in custom option page?

what I have in function.php is

function theme_scripts() {
    wp_enqueue_script( 'script', get_template_directory_uri() . '/js/scripts.js');
    wp_enqueue_script( 'Map', get_template_directory_uri() . '/js/Google.js' );
}

add_action( 'wp_enqueue_scripts', 'theme_scripts');

Now I need to change the

wp_enqueue_script( 'Map', get_template_directory_uri() . '/js/Google.js' );

to

wp_enqueue_script( 'Map', get_template_directory_uri() . '/js/ESRI.js' );

Or the other way around on changing the Radio in

<?php

function map-settings()
{
    add_settings_section("section", "Section", null, "map");
    add_settings_field("style-radio", "Map Radio Buttons", "map_radio_display", "map", "section");  
    register_setting("section", "style-radio");
}

function map_radio_display()
{
   ?>
        <input type="radio" name="style-radio" value="1" <?php checked(1, get_option('style-radio'), true); ?>>ERSI Map
        <input type="radio" name="style-radio" value="2" <?php checked(2, get_option('style-radio'), true); ?>>Google Map
   <?php
}

add_action("admin_init", "map-settings");

function map_op_page()
{
  ?>
      <div class="wrap">
         <h1>Map Script</h1>

         <form method="post" action="options.php">
            <?php
               settings_fields("section");

               do_settings_sections("map");

               submit_button(); 
            ?>
         </form>
      </div>
   <?php
}

function menu_item()
{
  add_submenu_page("options-general.php", "Map", "Map", "manage_options", "map", "map_op_page"); 
}

add_action("admin_menu", "menu_item");


Related Questions


Category select options for plugin settings

Updated June 15, 2015 22:03 PM