Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'init', function () {
- // Remove the editor for the post type.
- remove_post_type_support( 'post', 'editor' ); // Change 'post' to your custom post type.
- } );
- add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' );
- function your_prefix_register_meta_boxes( $meta_boxes ) {
- $prefix = '';
- $post_id = filter_input( INPUT_GET, 'post', FILTER_SANITIZE_NUMBER_INT );
- $post_content = get_post_field( 'post_content', $post_id );
- $meta_boxes[] = array (
- 'title' => esc_html__( 'Code Snippet Before', 'text-domain' ),
- 'id' => 'code-snippet-before',
- 'post_types' => array(
- 0 => 'post',
- ),
- 'context' => 'after_title',
- 'priority' => 'high',
- 'fields' => array(
- array (
- 'id' => 'content',
- 'name' => esc_html__( 'Reason for snippet', 'text-domain' ),
- 'type' => 'wysiwyg',
- 'desc' => '###Why did I need to use this?
- This field is also used as the Excerpt for the post.###',
- 'class' => 'reason-for-snippet',
- 'std' => $post_content,
- ),
- array (
- 'id' => 'what-it-does',
- 'name' => esc_html__( 'What It Does', 'text-domain' ),
- 'type' => 'wysiwyg',
- ),
- array (
- 'id' => 'actual-code-snippet',
- 'name' => esc_html__( 'Actual Code Snippet', 'text-domain' ),
- 'type' => 'wysiwyg',
- 'sanitize_callback' => 'none',
- ),
- array (
- 'id' => 'before-the-snippet',
- 'type' => 'single_image',
- 'name' => esc_html__( 'Before the snippet', 'text-domain' ),
- ),
- array (
- 'id' => 'after-the-snippet',
- 'type' => 'single_image',
- 'name' => esc_html__( 'After the snippet', 'text-domain' ),
- ),
- array (
- 'id' => 'custom_html_sbvmvz193m',
- 'type' => 'custom_html',
- 'std' => '<style>#wp-content-editor-tools{background:none;padding-top:0;}</style>',
- ),
- ),
- 'style' => 'seamless',
- );
- return $meta_boxes;
- }
- // Set the value for the 'content' field.
- add_filter( 'rwmb_content_field_meta', function() {
- $post_id = filter_input( INPUT_GET, 'post', FILTER_SANITIZE_NUMBER_INT );
- return get_post_field( 'post_content', $post_id );
- } );
- // Do not save to post meta.
- add_filter( 'rwmb_content_value', '__return_empty_string' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement