• I have a plugin that uses Custom Post Types, and I’d like to update my contextual help to use the add_help_tab function.

    I have spent hours searching and can’t find anyone else trying to do this and sharing how they did it.

    I’ve tried as many hooks as I could.

    Here’s one example of what I’ve got that’s not working:

    add_action('admin_head','wpd_help');
    
    function wpd_help( $contextual_help ) {
      $screen = get_current_screen();
      if ( $screen->id == 'dictionary' || $screen->id == 'edit-dictionary') {
        $screen->add_help_tab( array( '123', 'Title' ) );
      }
    }

    Here’s my old, working contextual help:

    // Add documentation to relevant pages
    add_filter( 'contextual_help', 'wpd_help', 10, 3 );
    
    function wpd_help( $contextual_help, $screen_id, $screen ) {
      if ( $screen_id == 'edit-dictionary' ) {
          // The main Dictionary edit screen (lists all entries)
         include( 'help/context-help.php' );
         $contextual_help = null;
       } elseif ( $screen_id == 'dictionary' ) {
          // The add/edit Dictionary screen (for single entry)
          include( 'help/add-edit.php' );
         $contextual_help = null;
       } elseif ( $screen_id == 'edit-types' ) {
          // The Type editing page
          include( 'help/entry-types.php' );
         $contextual_help = null;
       } elseif ( $screen_id == 'edit-sections' ) {
          // The Section editing page
          include( 'help/entry-sections.php' );
         $contextual_help = null;
       }
    	return $contextual_help;
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Anne Dorko

    (@annedorko)

    Okay, I think I figured it out – this finally is working for me.

    // LOADING POST.PHP HELP (single entry edit)
      add_action( 'load-post.php', 'wpd_help_post' );
      function wpd_help_post() {
      $screen = get_current_screen();
        if ( $screen->id == 'dictionary' || $screen->id == 'edit-dictionary' ) {
          $screen->add_help_tab( array(
          	'id'      => 'wpd-base',
          	'title'   => __('WordPress Dictionary', 'sfc'),
          	'content' => "HTML for help content",
          ));
        }
      }
    
      // LOADING EDIT.PHP HELP (main listing)
      add_action( 'load-edit.php', 'wpd_help_edit' );
      function wpd_help_edit() {
      $screen = get_current_screen();
        if ( $screen->id == 'dictionary' || $screen->id == 'edit-dictionary' ) {
          $screen->add_help_tab( array(
          	'id'      => 'wpd-base',
          	'title'   => __('WordPress Dictionary', 'sfc'),
          	'content' => "HTML for help content",
          ));
        }
      }
    
      // LOADING EDIT-TAGS.PHP HELP (taxonomies)
      add_action( 'load-edit-tags.php', 'wpd_help_edit_tags' );
      function wpd_help_edit_tags() {
      $screen = get_current_screen();
        if ( $screen->id == 'dictionary' || $screen->id == 'edit-types' ) {
          // TYPES HELP
          $screen->add_help_tab( array(
          	'id'      => 'wpd-base',
          	'title'   => __('WordPress Dictionary', 'sfc'),
          	'content' => "HTML for help content",
          ));
        } elseif ( $screen->id == 'dictionary' || $screen->id == 'edit-sections' ) {
          // SECTIONS HELP
          $screen->add_help_tab( array(
          	'id'      => 'wpd-base',
          	'title'   => __('WordPress Dictionary', 'sfc'),
          	'content' => "HTML for help content",
          ));
        }
      }
    Thread Starter Anne Dorko

    (@annedorko)

    I’ll leave this open for a little while to see if anyone else has a better solution, and will mark it resolved if not!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Is there a hook for add_help_tab and custom_post_types’ is closed to new replies.