Plugin Author
icc0rz
(@icc0rz)
Ah, I see. The button is currently added through the media_buttons_contex action which is usually called by WordPress when displaying a text editor. However, H5P will only respond to this action if you’re in the admin dashboard. I’m not familiar with the ‘front-end for course creation’, but I assume that it’s used outside of the dashboard?
I know some other plugins that do this as well, so it might be that we have to move this part of the code from the ‘admin’ section to the ‘public’ section to make the button work for these plugins.
Thread Starter
mbri
(@mbri)
@icc0rz thanks for your reply!
Yes the frontend work outside the wpdashboard on a wp page. If you can make the button working outside the dashboard that would be awesome! If not any other advice is appreciated.
Cheers
Plugin Author
icc0rz
(@icc0rz)
Hm, then I can’t think of why the button doesn’t work. I guess that it should…
Thread Starter
mbri
(@mbri)
@icc0rz i think I did not explain myself well.
I would like to know if you plan to have your button functining outside the media_button_contex and/or if you had any tips on how to achieve that.
Thanks!
Plugin Author
icc0rz
(@icc0rz)
Ah… I don’t think it should be too difficult to get that working.
If you are inside the admin dashboard it should only be a matter of adding a button with the id ‘add-h5p’ and data-method set to ‘id’ or ‘slug’. E.g:
<a href="#" id="add-h5p" class="button" title="Insert H5P Content" data-method="id">Add H5P</a>
If you are outside the dashboard it may be more difficult as you have to trigger the insertion of the needed JavaScript – which is usally triggered by the ‘admin_foooter’:
add_action('admin_footer', array($this->content, 'print_insert_content_scripts'));
Also, WordPress’s Thickbox(TB) must be available and the AJAX endpoint must accessible: wp-admin/admin-ajax.php?action=h5p_insert_content
.
I hope this helps and please let me know if there are any changes required to the plugin for you to achieve what you want.