Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | import jetpackAnalytics from '@automattic/jetpack-analytics';
import { __ } from '@wordpress/i18n';
document.addEventListener( 'DOMContentLoaded', function () {
const addNewButton = document.querySelector( 'a.page-title-action' );
if ( addNewButton ) {
const buttonContainer = document.createElement( 'div' );
buttonContainer.className = 'wpcom-media-library-action-buttons';
const importButton = document.createElement( 'a' );
importButton.className = 'page-title-action';
importButton.role = 'button';
importButton.innerHTML = __( 'Import Media', 'jetpack-external-media' );
importButton.href = window.JETPACK_EXTERNAL_MEDIA_IMPORT_BUTTON?.href;
importButton.onclick = function () {
jetpackAnalytics.tracks.recordEvent( 'jetpack_external_media_import_media_button_click', {
page: 'media-library',
} );
};
const parentNode = addNewButton.parentNode;
const nextSibling = addNewButton.nextSibling;
buttonContainer.appendChild( addNewButton );
buttonContainer.appendChild( importButton );
parentNode.insertBefore( buttonContainer, nextSibling );
}
} );
|