Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function my_acf_load_field( $field ) {
if ( ! empty ( $_GET[$field['name']] )) {
$field['default_value'] = $_GET[$field['name']];
}
return $field;
}
add_filter('acf/load_field', 'my_acf_load_field');
remove_filter( 'the_content', 'wpautop' );
function my_admin_script(){
if(get_post_type() === 'post'){
// 注意 JS内でダブルクオーテーションを使うとエラーになる
echo "<script>
document.addEventListener('DOMContentLoaded', function(event) {
const element = document.getElementById('acf-field-isbn');
if (element.value!=='') {
let a = document.createElement('a');
a.innerText = 'hontoで開く';
a.target = '_blank';
a.style = 'display:inline-block;margin-top:10px;';
a.href = 'http://honto.jp/redirect.html?bookno='+element.value.slice(0, -1);
element.parentNode.insertBefore(a, element.nextSibling);
}
});
</script>".PHP_EOL;
}
}
add_action("admin_print_scripts-post-new.php", "my_admin_script");
// コンテンツエディタのfontをリセット
function my_admin_style() {
echo '<style>
.wp-editor-area {
font-family: "" !important;
}
</style>'.PHP_EOL;
}
add_action('admin_print_styles', 'my_admin_style');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.