diff -r 34716fd837a4 -r be944660c56a wp/wp-admin/includes/bookmark.php --- a/wp/wp-admin/includes/bookmark.php Tue Dec 15 15:52:01 2020 +0100 +++ b/wp/wp-admin/includes/bookmark.php Wed Sep 21 18:19:35 2022 +0200 @@ -142,13 +142,34 @@ } /** - * Inserts/updates links into/in the database. + * Inserts a link into the database, or updates an existing link. + * + * Runs all the necessary sanitizing, provides default values if arguments are missing, + * and finally saves the link. * * @since 2.0.0 * * @global wpdb $wpdb WordPress database abstraction object. * - * @param array $linkdata Elements that make up the link to insert. + * @param array $linkdata { + * Elements that make up the link to insert. + * + * @type int $link_id Optional. The ID of the existing link if updating. + * @type string $link_url The URL the link points to. + * @type string $link_name The title of the link. + * @type string $link_image Optional. A URL of an image. + * @type string $link_target Optional. The target element for the anchor tag. + * @type string $link_description Optional. A short description of the link. + * @type string $link_visible Optional. 'Y' means visible, anything else means not. + * @type int $link_owner Optional. A user ID. + * @type int $link_rating Optional. A rating for the link. + * @type string $link_updated Optional. When the link was last updated. + * @type string $link_rel Optional. A relationship of the link to you. + * @type string $link_notes Optional. An extended description of or notes on the link. + * @type string $link_rss Optional. A URL of an associated RSS feed. + * @type int $link_category Optional. The term ID of the link category. + * If empty, uses default link category. + * } * @param bool $wp_error Optional. Whether to return a WP_Error object on failure. Default false. * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success. */ @@ -274,7 +295,7 @@ * * @since 2.0.0 * - * @param array $linkdata Link data to update. + * @param array $linkdata Link data to update. See wp_insert_link() for accepted arguments. * @return int|WP_Error Value 0 or WP_Error on failure. The updated link ID on success. */ function wp_update_link( $linkdata ) { @@ -320,10 +341,40 @@ $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.' ) );