Advertisement
Guest User

WP - Editor in Metabox - Error

a guest
Nov 11th, 2021
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.12 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Register a custom post type called "book".
  4.  *
  5.  * @see get_post_type_labels() for label keys.
  6.  */
  7. function wpdocs_codex_book_init() {
  8.     $labels = array(
  9.         'name'                  => _x( 'Books', 'Post type general name', 'textdomain' ),
  10.         'singular_name'         => _x( 'Book', 'Post type singular name', 'textdomain' ),
  11.         'menu_name'             => _x( 'Books', 'Admin Menu text', 'textdomain' ),
  12.         'name_admin_bar'        => _x( 'Book', 'Add New on Toolbar', 'textdomain' ),
  13.         'add_new'               => __( 'Add New', 'textdomain' ),
  14.         'add_new_item'          => __( 'Add New Book', 'textdomain' ),
  15.         'new_item'              => __( 'New Book', 'textdomain' ),
  16.         'edit_item'             => __( 'Edit Book', 'textdomain' ),
  17.         'view_item'             => __( 'View Book', 'textdomain' ),
  18.         'all_items'             => __( 'All Books', 'textdomain' ),
  19.         'search_items'          => __( 'Search Books', 'textdomain' ),
  20.         'parent_item_colon'     => __( 'Parent Books:', 'textdomain' ),
  21.         'not_found'             => __( 'No books found.', 'textdomain' ),
  22.         'not_found_in_trash'    => __( 'No books found in Trash.', 'textdomain' ),
  23.         'featured_image'        => _x( 'Book Cover Image', 'Overrides the “Featured Image” phrase for this post type. Added in 4.3', 'textdomain' ),
  24.         'set_featured_image'    => _x( 'Set cover image', 'Overrides the “Set featured image” phrase for this post type. Added in 4.3', 'textdomain' ),
  25.         'remove_featured_image' => _x( 'Remove cover image', 'Overrides the “Remove featured image” phrase for this post type. Added in 4.3', 'textdomain' ),
  26.         'use_featured_image'    => _x( 'Use as cover image', 'Overrides the “Use as featured image” phrase for this post type. Added in 4.3', 'textdomain' ),
  27.         'archives'              => _x( 'Book archives', 'The post type archive label used in nav menus. Default “Post Archives”. Added in 4.4', 'textdomain' ),
  28.         'insert_into_item'      => _x( 'Insert into book', 'Overrides the “Insert into post”/”Insert into page” phrase (used when inserting media into a post). Added in 4.4', 'textdomain' ),
  29.         'uploaded_to_this_item' => _x( 'Uploaded to this book', 'Overrides the “Uploaded to this post”/”Uploaded to this page” phrase (used when viewing media attached to a post). Added in 4.4', 'textdomain' ),
  30.         'filter_items_list'     => _x( 'Filter books list', 'Screen reader text for the filter links heading on the post type listing screen. Default “Filter posts list”/”Filter pages list”. Added in 4.4', 'textdomain' ),
  31.         'items_list_navigation' => _x( 'Books list navigation', 'Screen reader text for the pagination heading on the post type listing screen. Default “Posts list navigation”/”Pages list navigation”. Added in 4.4', 'textdomain' ),
  32.         'items_list'            => _x( 'Books list', 'Screen reader text for the items list heading on the post type listing screen. Default “Posts list”/”Pages list”. Added in 4.4', 'textdomain' ),
  33.     );
  34.  
  35.     $args = array(
  36.         'labels'             => $labels,
  37.         'public'             => true,
  38.         'publicly_queryable' => true,
  39.         'show_ui'            => true,
  40.         'show_in_menu'       => true,
  41.         'show_in_rest'       => true,
  42.         'query_var'          => true,
  43.         'rewrite'            => array( 'slug' => 'book' ),
  44.         'capability_type'    => 'post',
  45.         'has_archive'        => true,
  46.         'hierarchical'       => false,
  47.         'menu_position'      => null,
  48.         'supports'           => array( 'title', 'editor' ),
  49.     );
  50.  
  51.     register_post_type( 'book', $args );
  52. }
  53.  
  54. add_action( 'init', 'wpdocs_codex_book_init' );
  55.  
  56.  
  57. function meta_box_with_editor_callback()
  58. {
  59.     global $post;
  60.    
  61.     // Nonce field.
  62.     wp_nonce_field( 'wpdev_post_metabox_nonce_' . $post->ID, 'wpdev_post_metabox_nonce' );
  63.  
  64.     // Render editor metabox.
  65.     wp_editor('Testing...', 'wpdev_post_field_tinymce', array( 'textarea_rows' => '5' ) );
  66. }
  67.  
  68. add_action( 'add_meta_boxes', 'global_notice_meta_box' );
  69. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement