Hey @fgelio,
For post lists, you could use the post_class
filter to conditionally add classes to the table rows:
add_filter('post_class', function ($classes, $class, $postId) {
global $postlockdown;
if ($postlockdown->is_post_locked($postId)) {
$classes[] = 'postlockdown-post-locked';
}
if ($postlockdown->is_post_protected($postId)) {
$classes[] = 'postlockdown-post-protected';
}
return $classes;
}, 10, 3);
For the post edit page, you could use the admin_body_class
filter to conditionally add classes to the body:
add_filter('admin_body_class', function ($classes) {
if (get_current_screen()->base === 'post') {
$post = get_post();
global $postlockdown;
if ($postlockdown->is_post_locked($post->ID)) {
$classes .= ' postlockdown-post-locked';
}
if ($postlockdown->is_post_protected($post->ID)) {
$classes .= ' postlockdown-post-protected';
}
}
return $classes;
});
Hope this helps!
Hi,
Many thanks for the quick answer!
Unfortunately it is to complicated for my poor level π
I will find another solution.
Best regards
Hi @fgelio,
If you know how to edit a theme’s code, you just need to place the two code snippets I provided into that theme’s functions.php file
I have also just found https://en-gb.wordpress.org/plugins/my-custom-functions/ – if you are able to install plugins you could install this one and add the code there instead π
Hi @andyexeter,
The first time I tried your code into my functions.php WordPress crashed. So I didn’t wanted to waste your time more.
It finally works like a charm, don’t know what I did wrong for the first attempt!
Thank you again!
Regards
Glad you got it working! π