Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

gislef on "Add buttom - TinyMCE"

$
0
0

Hi

I am working with two plugins that use the Tinymce for text editing:

- WIRIS (editor of posts and pages adds button to mathematical formulas without entering codes such as latex)

- TinyMCE Visual Comment Editor (insert a small editor in the comment)

I want to add in Visual TinyMCE Comment editor the button wiris, so that the mathematical formulas button also appears in the comment editor.

Directory wp-include plugin wiris

wp-includes/js/tinymce/plugins/tiny_mce_wiris

Directory wp-content

/wp-content/plugins/tiny_mce_wiris.php

Content tiny_mce_wiris.php:

add_filter('mce_external_plugins', 'wrs_addPlugin');
add_filter('mce_buttons', 'wrs_addButtons');

function wrs_addPlugin($plugins) {
	$plugins['tiny_mce_wiris'] = get_option('home') . '/wp-includes/js/tinymce/plugins/tiny_mce_wiris/editor_plugin.js';
	return $plugins;
}

function wrs_addButtons($buttons) {
	array_push($buttons, 'separator', 'tiny_mce_wiris_formulaEditor', 'tiny_mce_wiris_CAS');
	return $buttons;
}
?>

Content code function of TinyMCE Visual Editor Comment:
/wp-content/plugins/tinymce-visual-editor-comment/function.php

<?php
require_once('setting.php');
$mobilesp = get_option('mobilesp');
if ($mobilesp=="mobilesp"){
	add_filter( 'comment_form_field_comment', 'comment_editor' );
}
else {
	if( !wp_is_mobile() )
		add_filter( 'comment_form_field_comment', 'comment_editor' );
}
function comment_editor() {
  global $post;
  ob_start();
  $rtl = get_option('ltr_rtf, tyny_mce_wiris');
  $mediabtn = get_option('mediabtn');
  if ($mediabtn=='mediabtn'){$mediabtn=true;}
  else{$mediabtn=false;}
  wp_editor( '', 'comment', array(
    'textarea_rows' => 15,
    'teeny' => true,
    'quicktags' => false,
	'media_buttons' => $mediabtn,
	'tinymce' => array('directionality' => $rtl),
  ) );

  $editor = ob_get_contents();

  ob_end_clean();

  //make sure comment media is attached to parent post
  $editor = str_replace( 'post_id=0', 'post_id='.get_the_ID(), $editor );

  return $editor;
}

// wp_editor doesn't work when clicking reply. Here is the fix.
add_action( 'wp_enqueue_scripts', '__THEME_PREFIX__scripts' );
function __THEME_PREFIX__scripts() {
    wp_enqueue_script('jquery');
}
add_filter( 'comment_reply_link', '__THEME_PREFIX__comment_reply_link' );
function __THEME_PREFIX__comment_reply_link($link) {
    return str_replace( 'onclick=', 'data-onclick=', $link );
}
add_action( 'wp_head', '__THEME_PREFIX__wp_head' );

function __THEME_PREFIX__wp_head() {
?>
<script type="text/javascript">
  jQuery(function($){
    $('.comment-reply-link').click(function(e){
      e.preventDefault();
      var args = $(this).data('onclick');
      args = args.replace(/.*\(|\)/gi, '').replace(/\"|\s+/g, '');
      args = args.split(',');
      tinymce.EditorManager.execCommand('mceRemoveEditor', true, 'comment');
      addComment.moveForm.apply( addComment, args );
      tinymce.EditorManager.execCommand('mceAddEditor', true, 'comment');
    });
  });
</script>
<?php }

function at_comment_css() {
	// This makes sure that the positioning is also good for right-to-left languages
	$x = is_rtl() ? 'left' : 'right';

	echo "
	<style type='text/css'>
	#wp-comment-editor-container {
		border: 2px solid #DFDFDF;
	}
	</style>
	";
}

add_action('wp_head', 'at_comment_css');

Please help me, how to add bottom wiris in the TinyMCE Visual Editor Comment?


Viewing all articles
Browse latest Browse all 8245

Trending Articles