Skip to content

Instantly share code, notes, and snippets.

@marcwieland95
Last active January 9, 2023 03:49
Show Gist options
  • Save marcwieland95/f54ec87e95d494ac0f283c6c21f67e98 to your computer and use it in GitHub Desktop.
Save marcwieland95/f54ec87e95d494ac0f283c6c21f67e98 to your computer and use it in GitHub Desktop.
Style ACF fields as deprecated
class Admin
{
public function __construct()
{
add_action('admin_enqueue_scripts', [$this, 'acfDeprecationStyles'], 10, 2);
}
public function acfDeprecationStyles()
{
echo '<style type="text/css">';
echo $this->generateAcfDeprecationStylings();
echo '</style>';
}
private function generateAcfDeprecationStylings()
{
$style = '';
$style .= '.acf-field.deprecated {
opacity: .8;
}';
$style .= '.acf-field.deprecated .acf-label label {
color: red;
}';
return $style;
}
}
@marcwieland95
Copy link
Author

Simply add deprecated to the class setting in the ACF field (in the admin) and the field will be shown red and a bit transparent for the user.

CleanShot 2023-01-09 at 10 45 20@2x

CleanShot 2023-01-09 at 10 45 45@2x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment