Created
August 17, 2016 19:36
-
-
Save ChrisLTD/62465b5035d6ce9687b40caf6d777617 to your computer and use it in GitHub Desktop.
Put message in ACF interface to warn people to edit custom fields in the PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// put message in ACF interface to warn people to edit custom fields here | |
function acf_warning( $hook ) { | |
if ('edit.php' != $hook) { | |
return; | |
} | |
$javascript = " | |
var acfFieldGroupEl = document.getElementById('acf-field-group-wrap'); | |
if (acfFieldGroupEl) { | |
var warningEl = document.createElement('h3'); | |
warningEl.innerHTML = 'WARNING: Custom Field definitions are in " . basename(__FILE__) . "'; | |
warningEl.style.color = 'red'; | |
acfFieldGroupEl.insertBefore(warningEl, acfFieldGroupEl.firstChild); | |
} | |
"; | |
// needed because Wordpress is weird | |
wp_enqueue_script('acf-warning-js', '/iAmNotReal.js', array(), '1.0', true); | |
if(function_exists("wp_add_inline_script")){ | |
wp_add_inline_script('acf-warning-js', $javascript); | |
} | |
} | |
add_action('admin_enqueue_scripts', 'acf_warning'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment