Make WordPress Core

Ticket #52669: 52669.diff

File 52669.diff, 1.8 KB (added by tw2113, 6 years ago)
  • wp-admin/includes/bookmark.php

     
    342342        remove_filter( 'pre_option_link_manager_enabled', '__return_true', 100 );
    343343
    344344        if ( $really_can_manage_links && current_user_can( 'install_plugins' ) ) {
    345                 $link = network_admin_url( 'plugin-install.php?tab=search&s=Link+Manager' );
    346                 /* translators: %s: URL to install the Link Manager plugin. */
    347                 wp_die( sprintf( __( 'If you are looking to use the link manager, please install the <a href="%s">Link Manager</a> plugin.' ), $link ) );
     345
     346                require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
     347
     348                $link_manager_plugin = plugins_api( 'plugin_information', [ 'slug' => 'link-manager' ] );
     349                $plugin_status       = install_plugin_install_status( $link_manager_plugin );
     350
     351                if ( 'install' === $plugin_status['status'] ) {
     352                        $link = $plugin_status['url'];
     353
     354                        /* translators: %s: URL to install the Link Manager plugin. */
     355                        wp_die( sprintf( __( 'If you are looking to use the link manager, please install the <a href="%s">Link Manager</a> plugin.' ), $link ) );
     356                }
     357
     358                if ( 'latest_installed' === $plugin_status['status'] && ! is_plugin_active( $plugin_status['file'] ) ) {
     359                        $link = add_query_arg(
     360                                array(
     361                                        '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $plugin_status['file'] ),
     362                                        'action'   => 'activate',
     363                                        'plugin'   => $plugin_status['file'],
     364                                ),
     365                                network_admin_url( 'plugins.php' )
     366                        );
     367
     368                        /* translators: %s: URL to activate the Link Manager plugin. */
     369                        wp_die( sprintf( __( 'If you are looking to use the link manager, please activate the <a href="%s">Link Manager</a> plugin.' ), $link ) );
     370                }
     371
    348372        }
    349373
    350374        wp_die( __( 'Sorry, you are not allowed to edit the links for this site.' ) );