WordPress.org

Ready to get started?Download WordPress

Forums

Add button to wordpress Upload/Insert section (2 posts)

  1. laurnicolae
    Member
    Posted 3 years ago #

    I am writing a WordPress plugin and I want to add a new button at Upload/Insert section (just above the editor, like Add an Image button) which will open a php file, generate some code and insert that code in the editor. How to do that?

  2. laurnicolae
    Member
    Posted 3 years ago #

    I found the solution.
    The code is:

    function plugin_media_button($context) {
    	$plugin_media_button = ' %s' . '<a href="media-upload.php?type=wp_myplugin&TB_iframe=true" class="thickbox">Insert something</a>';
    	return sprintf($context, $plugin_media_button);
      }
      add_filter('media_buttons_context', 'plugin_media_button');

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags