0

I´m writing a plugin that should show a modal popup with a form on a button click. Now the question is how/where to inject that modal and form HTML?

I can think of these options:

  1. Create it with JS. I could add the HTML with wp_add_inline_script() or wp_localize_script in a JS var and append it to the DOM.

  2. Create it with JS, but load the form HTML with AJAX from a html or php file.

CON: loading would take a little time

  1. echo out a div with display:none.

Question: Where in the document would I output it? I can´t rely on the theme to support wp_footer() and it doesn´t feel right to simply hook it into the_content(). What would be a good hook?

thanks

  • "I can´t rely on the theme to support wp_footer()" Yes, yes you can. It's absolutely mandatory, and any theme not using it deserves to break. – TheDeadMedic Dec 5 '16 at 10:16
0

You should put it inside 'the_content' hook. 1)Create first plugin which has the form that proccess simple form submission.

2)And then call that page in iframe window.Like this:

   <---YOU DIV STARTS HERE FOR POPUP WINDOW-->
    <div id="iframeclasses">
    <?php add_thickbox(); ?>

    //Your form link 

    <a  href="YOUR_LINK_GOES_HERE&KeepThis=true&TB_iframe=true" class="thickbox">
    </div>

3)iframe window open by following code.

     <input type="submit" name="submit"  class="button button-primary emailbtn" value="<?php _e('YOUR_BUTON_TEXT', 'TEXTDOMAIN')?>" >
     </div>
    //your div close here

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.