Skip to content

Commit d0be2ff

Browse files
committed
Use both name and URL for search
1 parent 8818d30 commit d0be2ff

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

assets/js/admin-pull.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,18 @@ document.addEventListener( 'DOMContentLoaded', async function () {
143143
items.forEach( ( item ) => {
144144
const div = document.createElement( 'div' );
145145
div.classList.add( 'searchable-select__item' );
146-
div.textContent = item.name;
146+
// Display name and URL in the dropdown item
147+
div.textContent = `${item.name} (${item.url})`;
147148
div.setAttribute( 'data-url', item.url );
148149

149150
div.addEventListener( 'click', () => {
150-
input.value = item.name;
151+
// Display name and URL in the input field
152+
input.value = `${item.name} (${item.url})`;
153+
// But set only URL as the actual value
154+
input.setAttribute( 'data-url', item.url );
151155
input.setAttribute(
152156
'data-pull-url',
153157
htmlDecode( item.pull_url )
154-
// item.pull_url
155158
);
156159
document.location = getURL();
157160

@@ -171,9 +174,12 @@ document.addEventListener( 'DOMContentLoaded', async function () {
171174
}
172175

173176
function filterItems( searchTerm ) {
174-
const filteredItems = pullConnectionItems.filter( ( item ) =>
175-
item.toLowerCase().includes( searchTerm.toLowerCase() )
176-
);
177+
const searchTermLower = searchTerm.toLowerCase();
178+
const filteredItems = pullConnectionItems.filter( ( item ) => {
179+
// Search on both name and URL
180+
return item.name.toLowerCase().includes( searchTermLower ) ||
181+
item.url.toLowerCase().includes( searchTermLower );
182+
} );
177183
createDropdownItems( filteredItems );
178184
}
179185

includes/pull-ui.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ function get_connections() {
603603

604604
$connections[] = [
605605
'id' => $internal_connection->site->blog_id,
606-
'name' => untrailingslashit( $internal_connection->site->domain . $internal_connection->site->path ),
606+
'name' => untrailingslashit( $internal_connection->site->blogname ),
607607
'url' => untrailingslashit( preg_replace( '#(https?:\/\/|www\.)#i', '', get_site_url( $internal_connection->site->blog_id ) ) ),
608608
'pull_url' => esc_url( admin_url( 'admin.php?page=pull&connection_type=internal&connection_id=' . $internal_connection->site->blog_id ) ),
609609
'type' => 'internal',

0 commit comments

Comments
 (0)