Last active
August 10, 2017 01:12
-
-
Save deguchi/3ab8d3b6417b93126dd8a8b26cb22d1e to your computer and use it in GitHub Desktop.
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
| 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