From 8f8f433b3c3d03cc0ae72f2db24fa39ad6782636 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 25 May 2021 20:14:59 +0000 Subject: [PATCH] Administration: Improve the message about installing the Link Manager plugin to use legacy Links screen. This provides direct links to install and activate the plugin, if the user has the capabilities to do so, instead of just linking to plugin search results. It also matches more closely the message about installing the Classic Editor plugin for meta boxes incompatible with the block editor. Follow-up to [22855], [44280], [45657]. Props tw2113, peterwilsoncc, SergeyBiryukov. Fixes #52669. Built from https://develop.svn.wordpress.org/trunk@51011 git-svn-id: http://core.svn.wordpress.org/trunk@50620 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/bookmark.php | 38 ++++++++++++++++++++++++++++++---- wp-admin/includes/template.php | 18 ++++++++++------ wp-includes/version.php | 2 +- 3 files changed, 47 insertions(+), 11 deletions(-) diff --git a/wp-admin/includes/bookmark.php b/wp-admin/includes/bookmark.php index 6cc6683f02..e3c10c54ea 100644 --- a/wp-admin/includes/bookmark.php +++ b/wp-admin/includes/bookmark.php @@ -341,10 +341,40 @@ function wp_link_manager_disabled_message() { $really_can_manage_links = current_user_can( 'manage_links' ); remove_filter( 'pre_option_link_manager_enabled', '__return_true', 100 ); - if ( $really_can_manage_links && current_user_can( 'install_plugins' ) ) { - $link = network_admin_url( 'plugin-install.php?tab=search&s=Link+Manager' ); - /* translators: %s: URL to install the Link Manager plugin. */ - wp_die( sprintf( __( 'If you are looking to use the link manager, please install the Link Manager plugin.' ), $link ) ); + if ( $really_can_manage_links ) { + $plugins = get_plugins(); + + if ( empty( $plugins['link-manager/link-manager.php'] ) ) { + if ( current_user_can( 'install_plugins' ) ) { + $install_url = wp_nonce_url( + self_admin_url( 'update.php?action=install-plugin&plugin=link-manager' ), + 'install-plugin_link-manager' + ); + + wp_die( + sprintf( + /* translators: %s: A link to install the Link Manager plugin. */ + __( 'If you are looking to use the link manager, please install the Link Manager plugin.' ), + esc_url( $install_url ) + ) + ); + } + } elseif ( is_plugin_inactive( 'link-manager/link-manager.php' ) ) { + if ( current_user_can( 'activate_plugins' ) ) { + $activate_url = wp_nonce_url( + self_admin_url( 'plugins.php?action=activate&plugin=link-manager/link-manager.php' ), + 'activate-plugin_link-manager/link-manager.php' + ); + + wp_die( + sprintf( + /* translators: %s: A link to activate the Link Manager plugin. */ + __( 'Please activate the Link Manager plugin to use the link manager.' ), + esc_url( $activate_url ) + ) + ); + } + } } wp_die( __( 'Sorry, you are not allowed to edit the links for this site.' ) ); diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index b8dfdcba1a..8e22630d6a 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -1148,17 +1148,23 @@ function do_block_editor_incompatible_meta_box( $object, $box ) { if ( empty( $plugins['classic-editor/classic-editor.php'] ) ) { if ( current_user_can( 'install_plugins' ) ) { - echo '

'; - printf( - /* translators: %s: A link to install the Classic Editor plugin. */ - __( 'Please install the Classic Editor plugin to use this meta box.' ), - esc_url( wp_nonce_url( self_admin_url( 'plugin-install.php?tab=favorites&user=wordpressdotorg&save=0' ), 'save_wporg_username_' . get_current_user_id() ) ) + $install_url = wp_nonce_url( + self_admin_url( 'plugin-install.php?tab=favorites&user=wordpressdotorg&save=0' ), + 'save_wporg_username_' . get_current_user_id() ); + + echo '

'; + /* translators: %s: A link to install the Classic Editor plugin. */ + printf( __( 'Please install the Classic Editor plugin to use this meta box.' ), esc_url( $install_url ) ); echo '

'; } } elseif ( is_plugin_inactive( 'classic-editor/classic-editor.php' ) ) { if ( current_user_can( 'activate_plugins' ) ) { - $activate_url = wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=classic-editor/classic-editor.php' ), 'activate-plugin_classic-editor/classic-editor.php' ); + $activate_url = wp_nonce_url( + self_admin_url( 'plugins.php?action=activate&plugin=classic-editor/classic-editor.php' ), + 'activate-plugin_classic-editor/classic-editor.php' + ); + echo '

'; /* translators: %s: A link to activate the Classic Editor plugin. */ printf( __( 'Please activate the Classic Editor plugin to use this meta box.' ), esc_url( $activate_url ) ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 4c3157d9f3..218b78ef3e 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.8-alpha-51010'; +$wp_version = '5.8-alpha-51011'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.