Created
July 15, 2021 06:44
-
-
Save alt-karate/5bf6776edf61aedbb647b9666b8dd929 to your computer and use it in GitHub Desktop.
This file contains 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_tiny_mce_before_init( $init_array ) { | |
$init_array['valid_elements'] = '*[*]'; | |
$init_array['extended_valid_elements'] = '*[*]'; | |
return $init_array; | |
} | |
add_filter( 'tiny_mce_before_init' , 'my_tiny_mce_before_init' ); | |
/** | |
* ビジュアルエディタに切り替えで、空の span タグや i タグが消されるのを防止 | |
*/ | |
if ( ! function_exists('tinymce_init') ) { | |
function tinymce_init( $init ) { | |
$init['verify_html'] = false; // 空タグや属性なしのタグを消させない | |
$initArray['valid_children'] = '+body[style], +div[div|span|a], +span[span]'; // 指定の子要素を消させない | |
return $init; | |
} | |
add_filter( 'tiny_mce_before_init', 'tinymce_init', 100 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment