Created
June 3, 2022 23:19
-
-
Save thisbit/2d64d56d70e5d2f8ba23f5aea30c3e51 to your computer and use it in GitHub Desktop.
Various editors setup
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
<?php | |
/** | |
* This file provides differnt levels of formating ability per post type | |
* Posts are in plain classic editor | |
* Osoblje CPT have no formating controls, pure plain text | |
* The rest is more or less in gutenberg | |
* I may later add gutenberg for admins in posts ... perhaps | |
*/ | |
/** | |
* Dissable gutenberg on posts | |
*/ | |
function prefix_disable_gutenberg( $current_status, $post_type ) { | |
if ( $post_type === 'post' ) { | |
return false; | |
} | |
return $current_status; | |
} | |
add_filter('use_block_editor_for_post_type', 'prefix_disable_gutenberg', 10, 2); | |
/** | |
* Remove the media button where media is not permitted | |
*/ | |
function remove_all_media_buttons() { | |
if ( get_post_type() === 'apuri_osoblje' ) { | |
remove_all_actions( 'media_buttons' ); | |
} | |
} | |
add_action( 'wp_editor_settings', 'remove_all_media_buttons' ); | |
/** | |
* Remove rich text completely in classic, per post type | |
*/ | |
function apuri_remove_rich_text( $default ) { | |
if ( get_post_type() === 'apuri_osoblje' ) { | |
return false; | |
} | |
return $default; | |
} | |
add_filter('user_can_richedit', 'apuri_remove_rich_text' ); | |
/** | |
* Remove all quicktags in Classic Editor text mode | |
*/ | |
function my_editor_settings($settings) { | |
if ( get_post_type() === 'apuri_osoblje' ) { | |
$settings['quicktags'] = false; | |
return $settings; | |
} | |
} | |
add_filter('wp_editor_settings', 'my_editor_settings'); | |
/** | |
* Classic editor text mode has too small type. | |
*/ | |
function apuri_tinyMCE_typesize(){ ?> | |
<style id="tinytext"> | |
textarea.wp-editor-area#content { | |
font-size: 1.6rem; | |
font-family: 'Work Sans', Arial, sans-serif; | |
height: 40vh; | |
} | |
</style> | |
<?php | |
} | |
add_action( 'admin_print_footer_scripts', 'apuri_tinyMCE_typesize' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment