Home / Admin / Post-States
Duplicate Snippet

Embed Snippet on Your Site

Post-States

Code Preview
php
<?php
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" style="background-color:#fcd568; padding: 4px 6px;color:#444">' . $post_states['bricks'] . '</a>';
        } else {
            $post_states['bricks'] = '<span style="background-color:#fcd568; padding: 4px 6px">' . $post_states['bricks'] . '</span>';
        }
    }
    return $post_states;
}

Comments

Add a Comment