Skip to content

Instantly share code, notes, and snippets.

@j4ckth3r1pp3r
Last active September 6, 2016 12:21
Show Gist options
  • Save j4ckth3r1pp3r/37cafcbdfba4e09ce556fa1d45b0bd06 to your computer and use it in GitHub Desktop.
Save j4ckth3r1pp3r/37cafcbdfba4e09ce556fa1d45b0bd06 to your computer and use it in GitHub Desktop.
My functions for WP
/*
** Помечает указанное ACF поле в админке неактивным, при отмеченном выбранном ACF чекбоксе
*/
function disableField (check, field) {
//check - имя чекбокса ACF
//field - имя поле ACF, который будет отключаться
check = $('div[data-name="'+check+'"] input[type="checkbox"]');
field = $('div[data-name="'+field+'"] input');
if (check.prop('checked')) {
field.prop("disabled", true);
} else {
field.prop("disabled", false);
}
check.change(function(){
if (field.prop('disabled')) {
field.prop("disabled", false);
} else {
field.prop("disabled", true);
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment