Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Metabox Vendor Info 1

class sqpp_mb_vendor_info {

	public function __construct() {

		if ( is_admin() ) {
			add_action( 'load-post.php',     array( $this, 'init_metabox' ) );
			add_action( 'load-post-new.php', array( $this, 'init_metabox' ) );
		}

	}

	public function init_metabox() {

		add_action( 'add_meta_boxes',        array( $this, 'add_metabox' )         );
		add_action( 'save_post',             array( $this, 'save_metabox' ), 10, 2 );

	}

	public function add_metabox() {

		add_meta_box(
			'sqppmbvendorinfo',
			__( 'Vendor Info', 'sqppcptmeta' ),
			array( $this, 'render_sqppmbvendorinfo' ),
			'sqppvendorinfo',
			'advanced',
			'high'
		);

	}

	public function render_sqppmbvendorinfo( $post ) {

		// Add nonce for security and authentication.
		wp_nonce_field( 'nonce_action', 'nonce' );

		// Retrieve an existing value from the database.
		$sqppvisellerinfo = get_post_meta( $post->ID, 'sqppvisellerinfo', true );
		$sqppvishopdescription = get_post_meta( $post->ID, 'sqppvishopdescription', true );

		// Set default values.
		if( empty( $sqppvisellerinfo ) ) $sqppvisellerinfo = '';
		if( empty( $sqppvishopdescription ) ) $sqppvishopdescription = '';

		// Form fields.
		echo '<table class="form-table">';

		echo '	<tr>';
		echo '		<th><label for="sqppvisellerinfo" class="sqppvisellerinfo_label">' . __( 'Seller Info', 'sqppcptmeta' ) . '</label></th>';
		echo '		<td>';
		wp_editor( $sqppvisellerinfo, 'sqppvisellerinfo', array( 'media_buttons' => true ) );
		echo '			<p class="description">' . __( 'Loremipsum...sqpp', 'sqppcptmeta' ) . '</p>';
		echo '		</td>';
		echo '	</tr>';

		echo '	<tr>';
		echo '		<th><label for="sqppvishopdescription" class="sqppvishopdescription_label">' . __( 'Shop Description', 'sqppcptmeta' ) . '</label></th>';
		echo '		<td>';
		wp_editor( $sqppvishopdescription, 'sqppvishopdescription', array( 'media_buttons' => true ) );
		echo '			<p class="description">' . __( 'Loremipsum...sqpp', 'sqppcptmeta' ) . '</p>';
		echo '		</td>';
		echo '	</tr>';

		echo '</table>';

	}

	public function save_metabox( $post_id, $post ) {

		// Add nonce for security and authentication.
		$nonce_name   = isset( $_POST['nonce'] ) ? $_POST['nonce'] : '';
		$nonce_action = 'nonce_action';

		// Check if a nonce is set.
		if ( ! isset( $nonce_name ) )
			return;

		// Check if a nonce is valid.
		if ( ! wp_verify_nonce( $nonce_name, $nonce_action ) )
			return;

		// Check if the user has permissions to save data.
		if ( ! current_user_can( 'edit_post', $post_id ) )
			return;

		// Check if it's not an autosave.
		if ( wp_is_post_autosave( $post_id ) )
			return;

		// Check if it's not a revision.
		if ( wp_is_post_revision( $post_id ) )
			return;

		// Sanitize user input.
		$new_sqppvisellerinfo = isset( $_POST[ 'sqppvisellerinfo' ] ) ? wp_kses_post( $_POST[ 'sqppvisellerinfo' ] ) : '';
		$new_sqppvishopdescription = isset( $_POST[ 'sqppvishopdescription' ] ) ? wp_kses_post( $_POST[ 'sqppvishopdescription' ] ) : '';

		// Update the meta field in the database.
		update_post_meta( $post_id, 'sqppvisellerinfo', $new_sqppvisellerinfo );
		update_post_meta( $post_id, 'sqppvishopdescription', $new_sqppvishopdescription );

	}

}

new sqpp_mb_vendor_info;