Using WordPress ‘maybe_disable_link_manager()’ PHP function

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

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 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');

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');

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 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.