SOLVED: How to overwrite the "link_css_selector"?

Bricks Version: 1.5.3
Browser: Chrome 90
OS: macOS / Windows / Linux / etc.
URL: (a link to a page that illustrates the issue would be really helpful)

Hi there,
On the documentation, it says that the filter for css_link_selectors will either overwrite or extends CSS selectors. However looking at the code, it seems to only extend. It does not overwrite. (though I’m not an expert in code, I could be wrong here)

^ also note the documentation sample code snippet has a minor error the add filter is doing “/bricks/bricks” instead of “/bricks”

Have attached 3 images:

  • Parent Theme screenshot → joins hardcoded array with child theme array
  • Child Theme screenshot → i defined an existing value with the aim of overwriting
  • Onsite CSS → when published, i can see it joined but it did not overwrite the CSS

My original intent of trying to do this is to exclude other items from being classified as a link (in this case a plugin’s social icons).



Many thanks

Hi @valiant,

I’ve just fixed the typo in the Bricks Academy :slight_smile: … and extended the code example to showcase how to overwrite all link selectors.

If the filter overwrites or extends the selector array depends on the logic you run inside it.

In your example, you’ve added another selector to the list of existing selectors.

To overwrite the entire link selector array you need to set the array as shown in the following snippet, instead of pushing an item at the end of it.

add_filter( 'bricks/link_css_selectors', function( $link_css_selectors ) {
    // Return array of link selectors
    return ['.brxe-post-content a:not(.bricks-button):not(.nc_tweet.swp_share_link'];
} );
2 Likes

Hi Thomas, this is not working with 1.9.6.1, any thoughts on how to fix it? Thanks