1

I have a plugin I am designing an admin page for, when I hit submit I get a white page with no errors or text of any kind.

Here is my code

add_action( 'admin_init', 'linc_plugin_settings' );
add_action('admin_menu', 'linc_plugin_menu');

function linc_plugin_settings() {
    $id = 1;
    $url;
    $input_value = $_POST['urlfield'];
    if(isset($_POST["urlfield"]) && is_array($_POST["urlfield"])){  
    foreach ($input_value as $url) {

    register_setting( 'linc-post-url-' . $id++, $url );
}
    }
}


function linc_plugin_menu() {
    add_menu_page('Linc Post Settings', 'Import Settings', 'administrator', 'linc-post-import-settings', 'linc_plugin_settings_page', 'dashicons-hammer');
}

function linc_plugin_settings_page() {
  ?>
  <div id="content"> 
  <h2 id="header-text" align='center'> Linc Post Importer </h2>
  <h3 id='instructions' align='center'> Enter the URL of the Linc City Site that you wish to import posts from. <br /> Use the import button to run the import function for the newly added URL's</h3>

<h2> Enter URL Below <br /> ex. http://www.linccity.com/</h2>

<form id="url-list">
    <input id="url-field-1" name="urlfield[]" type="text">

<button class="button" id="add-url"> + </button>
<script>
    jQuery(document).ready(function ($) {
        $("#add-url").click(function(){
            $( "#submit" ).before( "<br  /><input id='url-field-1' name='urlfield[]' type='text'><br  />" );
  });
    });
    </script>
    <?php submit_button(); ?> 
    </form>
  </div>
  <?php
}

I am trying to add a setting for each one of the boxes that has a url in it when I submit the form.

1
  • Your form is submitting to admin.php via GET method so you are getting white/ blank page on click of '+' button so update your script Jun 15 '17 at 8:49
1

Your button is submitting the form use this script

<script>
    jQuery(document).ready(function ($) {
        $("#add-url").click(function(e){
           e.preventDefault();
            $( "#submit" ).before( "<br  /><input id='url-field-1' name='urlfield[]' type='text'><br  />" );
  });
    });
    </script>
0

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.