پرش به محتویات

"Filter: bricks/element/maybe_set_aria_current_page"

مقدار بولی را فیلتر می‌کند که تعیین می‌کند آیا ویژگی aria-current="page" را به عنصر پیوند اضافه کنیم یا خیر. این برای نشان دادن اینکه یک پیوند به صفحه فعال فعلی اشاره می‌کند استفاده می‌شود.

پارامترها

  • $set_aria_current (bool): Whether the link matches the current page.
  • $url (string): The URL of the link being checked.

نمونه استفاده

add_filter( 'bricks/element/maybe_set_aria_current_page', function( $set_aria_current, $url ) {
    // Example: Consider a link active if it matches a specific query parameter
    if ( isset( $_GET['section'] ) && strpos( $url, 'section=' . $_GET['section'] ) !== false ) {
        return true;
    }

    return $set_aria_current;
}, 10, 2 );