Onclick event disappears due to plugin conflict

Plugin conflict occurs due to the TinyMCE-custom.js Onclick event. TinyMCE Onclick event overrides the default button event hence another Vital plugin stops responding the button click.

function __construct() {
    add_shortcode('wp_registration', array($this, 'registration'));

    add_filter('mce_buttons', array($this, 'register_tinymce_buttons'));
    add_filter('mce_external_plugins', array($this, 'register_tinymce_javascript'));

    add_action('admin_footer', array($this, 'shortcodeData'));
    }

 function register_tinymce_buttons($buttons) {
    array_push($buttons, 'separator', 'login_register_shortcodes');
    return $buttons;
    }

function register_tinymce_javascript($plugin_array) {
$plugin_array['wpcustomplugin'] = plugins_url('/js/tinymce-custom.js', __FILE__);
return $plugin_array;
}

function shortcodeData() {
global $post;
query_posts(array('post_type' => 'wscustom', 'orderby' => 'date'));
?>
<script type="text/javascript">
    var wpcustomplugin_shortcode_data = [[
<?php
if (have_posts()) {
    while (have_posts()) {
    the_post();
    ?>
        {text: '<?php echo html_entity_decode(get_the_title()) ?>', onclick: function () {
        tinyMCE.activeEditor.insertContent('[wpcustomplugin_registration id="<?php echo $post->ID ?>"] ');
        }},
    <?php
    }
}
?>
    ]];
</script>
<?php
wp_reset_query();
}

Please can someone suggest me to resolve this issue?

Read more here: Onclick event disappears due to plugin conflict

Leave a Reply

Your email address will not be published. Required fields are marked *