How can i get the title i specified in add_options_page for my header

i have

add_options_page('Post Products Settings', 'Post Products Settings', 'administrator', 'pp_settings', 'pp_settings_page');

anyway i can get whats specified in the 1st parameter for use in my page header? i know i can hard code it tho, but just curious

Related posts

Leave a Reply

2 comments

  1. There are a few ways you can do this. My preferred way of doing this is using Object Oriented Programming (OOP) to structure the plugin. For example, I might do this:

    class JPBTitle {
      var $page_title = "Post Products Settings";
    
      function __construct(){
        add_action( 'admin_menu', array( $this, 'admin_menu' ) );
      }
    
      function admin_menu(){
        add_options_page( $this->page_title, $this->page_title, 'administrator', 'pp_settings', array( $this, 'pp_settings' ) );
      }
    
      function pp_settings(){
        echo "<div class='wrap'>nt<h2>$this->page_title</h2></div>";
      }
    }
    
    $JPBTitle = new JPBTitle();
    

    There are many many advantages to using object oriented programming in plugins; however, if you don’t want to use OOP, I would suggest either setting a global variable or defining a constant with the value you want to use for that string.