Making WordPress.org

Changeset 13204


Ignore:
Timestamp:
02/12/2024 08:24:36 PM (16 months ago)
Author:
coffee2code
Message:

Photo Directory, Admin JS: Highlight post status specific admin menu link (e.g. 'Queue' and 'Flagged') if present and is the current page.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/assets/js/admin.js

    r12958 r13204  
    11document.addEventListener('DOMContentLoaded', function () {
     2    // Move the 'current' menu class to the link to a post status specific menu link if appropriate.
     3    const searchParams = new URLSearchParams(document.location.search);
     4    if (window.location.pathname.endsWith('edit.php') && searchParams.has('post_status')) {
     5        const linkToPostStatus = document.querySelector('.wp-submenu a[href="edit.php?post_type=' + searchParams.get('post_type') + '&post_status=' + searchParams.get('post_status') + '"]');
     6        if (linkToPostStatus) {
     7            // Remove existing 'current' classes.
     8            document.querySelectorAll('.wp-submenu .current').forEach( n => n.classList.remove('current') );
     9            // Assign 'current' class to new menu item and link.
     10            linkToPostStatus.classList.add('current');
     11            linkToPostStatus.parentElement?.classList.add('current');
     12        }
     13    }
     14
    215    // Convert Orientations taxonomy checkboxes to radio buttons.
    316    document.querySelectorAll('#photo_orientationchecklist input[type="checkbox"]').forEach((item) => {item.setAttribute('type', 'radio');});
Note: See TracChangeset for help on using the changeset viewer.