The maybe_disable_link_manager() WordPress PHP function disables the Link Manager on upgrade if no links exist in the database at the time of the upgrade.
Usage
maybe_disable_link_manager();
Parameters
- No parameters required.
More information
See WordPress Developer Resources: maybe_disable_link_manager()
Examples
Disable Link Manager during theme setup
Add the following code to your theme’s functions.php
file to disable the Link Manager during the theme setup process.
function my_theme_setup() { // Disable Link Manager if no links are present maybe_disable_link_manager(); } add_action('after_setup_theme', 'my_theme_setup');
Disable Link Manager on plugin activation
Disable the Link Manager when a specific plugin is activated by adding the following code to your plugin’s main file.
function my_plugin_activation() { // Disable Link Manager if no links are present maybe_disable_link_manager(); } register_activation_hook(__FILE__, 'my_plugin_activation');
Disable Link Manager on custom action
Create a custom action that disables the Link Manager when triggered.
function my_custom_disable_link_manager() { // Disable Link Manager if no links are present maybe_disable_link_manager(); } add_action('my_custom_action', 'my_custom_disable_link_manager');
To trigger the custom action, use the following code:
do_action('my_custom_action');
Disable Link Manager using a shortcode
Create a shortcode that disables the Link Manager when the shortcode is used on a page or post.
function my_disable_link_manager_shortcode() { // Disable Link Manager if no links are present maybe_disable_link_manager(); } add_shortcode('disable_link_manager', 'my_disable_link_manager_shortcode');
To use the shortcode, simply insert [disable_link_manager]
into a page or post.
Disable Link Manager on admin notice dismissal
Disable the Link Manager when a user dismisses a specific admin notice.
function my_admin_notice_dismissed() { // Disable Link Manager if no links are present maybe_disable_link_manager(); } add_action('my_admin_notice_dismissed', 'my_admin_notice_dismissed');
To trigger the action when the notice is dismissed, use JavaScript to send an AJAX request with the action my_admin_notice_dismissed
.