Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'd like to add my own button link next to these two. Is this possible?

enter image description here

share|improve this question
1  
Why was this downvoted? – kaiser Aug 15 '11 at 18:27
Any reason you can't just hook into contextual help (i.e. the Help tab)? – Chip Bennett Aug 15 '11 at 19:47

4 Answers

Not sure why this question was dismissed so quickly. It's actually a valid question, and would be really useful to be able to add a button up there, or even edit the content of each screen option.

I know this is an old question, but...

If you want it to just add a button up there that would link somewhere else. You could just add some jQuery to add the button.

jQuery("#screen-meta-links").append('<div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle" style=""><a href="link.html" id="contextual-help-link" class="show-settings">My New Button</a></div>');

Now if you actually want that button to work in the same way as the other buttons, you would need to dig into the admin files.

The file you are looking for is:

wordpress\wp-admin\includes\screen.php

share|improve this answer

The HTML

echo '<div id="screen-meta-links">';
echo ' <div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle">';
echo '  <a href="#" id="your-own-button" class="show-settings">Text for your button</a>';
echo ' </div>';
echo '</div>';
echo '<br style="clera:both" />';

echo '<div id="your-button-content" class="your-button-hide">';
// your content goes here
echo '</div>';

And you need some custom JavaScript

jQuery(document).ready( function($){

$( '.your-button-hide' ).each(
  function(e){
    $( this ).hide();
  }
);

$( '#your-own-button' ).click(
  function( e ){
    e.preventDefault();

    $( '#your-button-content' ).toggle();

    var hasclass = $( '#your-own-button' ).hasClass( 'screen-meta-active' );
    if( hasclass ){
      $( '#your-own-button' ).removeClass( 'screen-meta-active' );
    } else {
      $( '#your-own-button' ).addClass( 'screen-meta-active' );
    }
  }
);

});

The HTML part adds the button, the JavaScript adds the functionality.

The complete code could look like this:

add_action( 'admin_menu', 'register_backendpage', 10, 0 );

function register_backendpage() {
  $pagehook = add_management_page(
    'Your backend page',
    'Your backend page',
    'manage_options',
    'a-menu-slug-of-your-choice',
    'backendpage_callback',
    false,
    'bottom'
  );

  add_action( 'load-' . $pagehook, 'enqueue_button_script', 10, 0 );
}

function backendpage_callback() {

    // output your button here, see code above

    echo '<div class="wrap">';
    /*
     * the rest of your page content
     */
}

function enqueue_button_script() {
    // the js above
    wp_enqueue_script( 'your-button-script', ... );
}
share|improve this answer

Is this possible?

Not without some JavaScript.

Will it be possible?

Those two tabs will be converted into a menu in the admin bar in WP 3.3. Check out the beta.

share|improve this answer

Is this possible

Yes.

Take a look at the core file. Somthing with screen_options(); and like.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.