Skip to content

Commit 9b3d96a

Browse files
refactor: initNewPostActions
1 parent af6757c commit 9b3d96a

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

includes/views/js/import-metabox-edit.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,13 +1524,18 @@ function initRemoveFallbackImageBtn() {
15241524
});
15251525
}
15261526

1527+
/**
1528+
* Run actions when creating a new post.
1529+
*/
15271530
function initNewPostActions() {
1531+
if (-1 === window.location.href.indexOf('post-new.php')) {
1532+
return;
1533+
}
1534+
15281535
// Focus on the post title field when creating a new post.
1529-
if (window.location.href.indexOf('post-new.php') > -1) {
1530-
const postTitle = document.querySelector('#post_title');
1531-
if (postTitle) {
1532-
postTitle.focus();
1533-
postTitle.select();
1534-
}
1536+
const postTitle = document.querySelector('#post_title');
1537+
if (postTitle) {
1538+
postTitle.focus();
1539+
postTitle.select();
15351540
}
15361541
}

0 commit comments

Comments
 (0)