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">\n\t<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.
Related Posts:
- Is it ever okay to include inline CSS in plugins?
- Is it mandatory to use $wpdb->prefix in custom tables
- add_action hook for completely new post?
- How do I programatically insert a new menu item?
- When would I use either function for plugins?
- Test to see if jQuery or Prototype is queued by another plugin?
- Is there a hook for when you switch themes?
- Notice: _usort_terms_by_ID is deprecated since version 4.7.0! Use wp_list_sort instead
- How to add a new plugin page under desired Options page?
- Plugin screenshots not showing in the repository
- Multiple Parameters for a Shortcode
- Problems after wp_set_password() containing an apostrophe
- How to properly load text domain of custom mu plugin
- Post from front-end with post types, categories and taxonomies
- product-attribute-slug-is-too-long-28-characters-max
- Front-End Form Submission in Shortcode
- Multiple entries in get_option results? or why is _multiwidget set to 1?
- Check if I am in the Admin Panel (wp-admin)?
- Fully automated theme install and activation via a plugin
- Using Ajax call in jQuery doesn’t work in widget
- How to disable “Transform to” option in Gutenberg custom blocks
- Best practice for creating a custom archive template for a custom taxonomy which works on all themes?
- URL rewriting must be activated manually for my plugin
- Getting Details Of Uploaded Image
- how to activate plugin network-wide, and save setting across sites
- What is difference between blog id and site id?
- How to create a Tools menu on the Network Admin dashboard from a plugin
- wp_transition_post_status does not change the status of the post
- Add notification bubble notice in navigation using transients
- Initial help with official “create a block” tutorial
- Update/insert only a column of database table
- Execute Hook on the footer or header after activating a plugin
- Custom plugin – $post_id in wp_head
- Can wp_list_comments output into variable?
- WooCommerce registration password field not displaying
- wordpress plugin php file processing form
- SMS registration and login [closed]
- Enqueueing stylesheets on particular plugin admin pages using WordPress Plugin Boilerplate
- How To Change Post Author Default?
- Editing options pages?
- Logout users upon login, based on caps/role?
- Precaching WordPress posts with a ServiceWorker
- Shortcode returning localized HTML part
- wp-cron and execution of code in is_admin() included script
- use of do_action() without any functions attached
- Template directory in plugin
- WordPress Admin Login Custom Logo
- json_decode does not work on WordPress
- Woocommerce order empty items array
- esc_html__() and __() not working within arrays
- Uploaded attachment not set as featured image
- HowTo to add my rewrite rules at the beginning, redirect to the right page and flush the rules on plugin activation?
- Apply styles to blockquote element with the WYSIWYG editor
- WordPress – manually relate a post to page(s)?
- Do I need to create an endpoint?
- Styles don’t load correctly. Insecure content
- How to use apiFetch to get author information in Gutenberg properly?
- Gutenberg blocks error: Each child in a list should have a unique “key” prop
- How to display the specific post content by using POST ID
- How to find list of all functions bind to a particular hook from my plugin?
- Soap web service request from wordpress plugin
- How to list all images used on a specific page?
- Create fixed static pages
- Is there anything special required to make a plugin work in a multisite environment?
- How to exclude “uncategorized” from custom categories widget?
- How to create wordpress media library UI on plugin page
- Why my theme’s css not working on another site
- How to create dynamic content with get_post_meta?
- Override category archive page title (not the head title)
- get_queried_object_id combined with wp_redirect gets wrong id
- Using WordPress Boilerplate (WPBP) for WP Multisite Plugin
- WordPress5.2.3: Better File Download Plugin validation issue
- How do I make secure API calls from my WordPress plugin?
- esc_attr() on hard coded string
- WordPress Plugin Boilerplate – add actions and/or filters based on user’s role
- How to trigger WooCommerce user profile edit change?
- Return raw image proxy for wordpress plugin
- How to handle ajax Request in a complex-structured plugin?
- Stop unauthorised file access
- How to use functions from Woocommerce documentation?
- How to pass a more variable with page/subpage in Wordprees URL?
- Use a page as a template for a custom post type
- Dynamic sidebar areas not working on the Theme Customizer
- WP API users per page
- Merge Codes using redux framework
- Getting Plugin to read all script files
- How to use get_pages( ) correctly with ‘child_of’ to replace page with child page
- Problem with Poedit [closed]
- Insert plugin html content to a specific spot in the frontpage
- Is Explicit Versioning a better alternative to Semantic Versioning for wordpress?
- Checking if the query is empty does not work
- Remove default wordpress roles
- What is the meta_query key name for the woo product average rating? [closed]
- how to catch a data from a array in WordPress
- get the queried_object of an url
- Why my admin-ajax url returns 0 even after adding echo and die() at the end of function?
- External api call using wordpress
- Set link dialog to open in blank by default
- plugabble wp_authenticate function not works from wp-login.php
- How to get recent one post from each category on home page?