Premium add-on for Bricks Builder

Style Bricks Post State text

Someone asked this question in the Bricks Community FB group

Hi guys, is it possible to stylize “Bricks” in pages as in the picture? In the css there is only a generic class “post-state”. I have a site with several pages managed with both Gutenberg or Bricks and would like to make it more obvious where Bricks Builder is used.

Open the functions.php file of the Bricks child theme or add this small PHP code in 3rd party snippets plugin.

add_filter( 'display_post_states', 'bu_style_post_state_bricks', 15, 2 );
function bu_style_post_state_bricks ($post_states, $post) {
    if( isset( $post_states['bricks'] ) ) {
        if( current_user_can( 'edit_posts', $post->ID ) ) {
            $bricks_edit_link = get_permalink($post->ID) . '?bricks=run';
            $post_states['bricks'] = '<a href="' . $bricks_edit_link . '" rel="nofollow ugc">' . $post_states['bricks'] . '</a>';
        } else {
            $post_states['bricks'] = '' . $post_states['bricks'] . '';
        }
    }

    return $post_states;
}
Fills In: 

2 Comments

  • Modified version with a link to edit in bricks, and checking if the user has rights to edit posts :


    add_filter( 'display_post_states', 'bu_style_post_state_bricks', 15, 2 );
    function bu_style_post_state_bricks ($post_states, $post) {
    if( isset( $post_states['bricks'] ) ) {
    if( current_user_can( 'edit_posts', $post->ID ) ) {
    $bricks_edit_link = get_permalink($post->ID) . '?bricks=run';
    $post_states['bricks'] = '' . $post_states['bricks'] . '';
    } else {
    $post_states['bricks'] = '' . $post_states['bricks'] . '';
    }
    }

    return $post_states;
    }

Leave your comment

Search Tutorials

Request TutorialsFeatures Request