Function
Register the admin pages.
tml_admin_add_menu_items( )
Source
function tml_admin_add_menu_items() {
// Bail if multisite and not in the network admin
if ( is_multisite() && ! is_network_admin() ) {
return;
}
// Add the main menu item
tml_admin_add_menu_item(
array(
'page_title' => esc_html__( 'Theme My Login Settings', 'theme-my-login' ),
'menu_title' => esc_html__( 'Theme My Login', 'theme-my-login' ),
'menu_slug' => 'theme-my-login',
// phpcs:disable WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents, WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode -- reading a local plugin asset and base64-encoding it into a data: URI for the admin menu icon, not a remote fetch or obfuscation.
'menu_icon' => 'data:image/svg+xml;base64,' . base64_encode(
file_get_contents( THEME_MY_LOGIN_PATH . 'admin/assets/images/logo.svg' )
),
// phpcs:enable WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents, WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
'parent_slug' => false,
)
);
// Add the submenu item
tml_admin_add_menu_item(
array(
'page_title' => esc_html__( 'Theme My Login Settings', 'theme-my-login' ),
'menu_title' => esc_html__( 'General', 'theme-my-login' ),
'menu_slug' => 'theme-my-login',
'parent_slug' => 'theme-my-login',
)
);
$has_licenses = false;
// Add the extension menu items
foreach ( tml_get_extensions() as $extension ) {
$args = $extension->get_settings_page_args();
if ( ! empty( $args ) ) {
tml_admin_add_menu_item( $args );
}
if ( $extension->get_license_key_option() ) {
$has_licenses = true;
}
}
if ( $has_licenses ) {
// Add the licenses menu item
tml_admin_add_menu_item(
array(
'page_title' => esc_html__( 'Theme My Login Licenses', 'theme-my-login' ),
'menu_title' => esc_html__( 'Licenses', 'theme-my-login' ),
'menu_slug' => 'theme-my-login-licenses',
'parent_slug' => 'theme-my-login',
)
);
add_settings_section( 'tml_settings_licenses', '', '__return_null', 'theme-my-login-licenses' );
}
// Add the extensions menu item
tml_admin_add_menu_item(
array(
'page_title' => esc_html__( 'Theme My Login Extensions', 'theme-my-login' ),
'menu_title' => esc_html__( 'Extensions', 'theme-my-login' ),
'menu_slug' => 'theme-my-login-extensions',
'parent_slug' => 'theme-my-login',
'function' => 'tml_admin_extensions_page',
)
);
}
Uses
Changelog
| Version | Description |
|---|---|
| 7.0 | Introduced. |