Enable TinyMCE for listing description

When you want to add an ad, we have a description box which is a blank textarea html. I think would be awesome if you can implement a TinyMCE or whatever editor that support html as well so users can make lists, etc (beautiful descriptions for their ads).

Hi,

Use this php code snippet using code snippet by pro plugin.

add_filter( 
	'hivepress/v1/fields/textarea', 
	function ($field_args, $field){
		$html = hivepress()->helper->get_array_value($field_args, 'html');
		$field_args['editor'] = [
			'toolbar1'    => implode(
				',',
				[
					'bold',
					'italic',
					'underline',
					'strikethrough',
					'blockquote',
					'separator',
					'bullist',
					'numlist',
					'indent',
					'outdent',
					'justifyleft',
					'justifycenter',
					'justifyright',
					'cut',
					'copy',
					'paste',
					'forecolor',
					'insert',
					'undo',
					'redo',
				]
			),
			'toolbar2'    => '',
			'toolbar3'    => '',
			'toolbar4'    => '',
			'elementpath' => false,
		];
		return $field_args;
	}, 
	1000,
	2
);

Note: There is a bug that when you try to change the listing category, the editor is gone. Hivepress support advised they added it to the bug tracker and hopefully will fix it soon.

1 Like

Good day, here is a snippet code below for enabling TinyMCE text editor on the listing description field.

add_filter(
	'hivepress/v1/models/listing/fields',
	function( $fields ) {
		$fields['description']['html'] = true;
		$fields['description']['editor'] = true;
		return $fields;
	},
	1000,
	1
);
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.