0

Please, understand that I'm new to wordpress and php.

I added a media button to my media buttons in the admin by adding the following code to functions.php file:

function add_custom_media_button() {
    echo '<a href="#TB_inline?inlineId=custommedia_container" id="insert-my-media" class="button thickbox">Add custom media</a>';
}
add_action('media_buttons', 'add_custom_media_button', 15);

add_action( 'admin_footer',  'add_inline_popup_content' );
function add_inline_popup_content() {
    $cu = wp_get_current_user();
    $cusername = $cu->user_login;
    echo '<div id="custommedia_container" style="display:none;">';
    echo '<iframe class="mediaselectoriframe" title="Archivado" width="100%" height="99%" title="cosas" src="http://nephila.cloudapp.net/GAdEWeb/wpsearch.aspx?wpuser=' . $cusername . '&wplang=' . $clocale . '" frameborder="0"></iframe>';
    echo '</div>';
}

Now, this is working on Create Post page, but is not anywhere else.

I can see my button in Edit post, Create page and Edit page, but there's nothing inside the thickbox.

0

I ended up solving this by changing my two functions to only one, and setting the "button" to show the iframe directly, like this:

function add_custom_media_button() {
    $cu = wp_get_current_user();
    $cusername = $cu->user_login;
    $clocale = get_locale();
    echo '<a href="http://nephila.cloudapp.net/GAdEWeb/wpsearch.aspx?wpuser=' . $cusername . '&wplang=' . $clocale . '&TB_iframe=true&width=800&height=600" id="insert-my-media" class="button thickbox">Add custom media</a>';
}
add_action('media_buttons', 'add_custom_media_button', 15);

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.