Syntax error missing : after property id in custom tinymce

I am trying to develop a simple tinyMCE plugin in WordPress where on clicking the button, it will show menu items and then a submenu which will contain the posts.

I am receiving the error message

Syntax error missing : after property id

Here is the code:
tinymce-custom.js

    /* global tinymce, wp_shortcode_data */

(function () {
    if (typeof wp_shortcode_data != 'undefined') {
        tinymce.create('tinymce.plugins.wpsystem', {
            init: function (ed, url) {
                _wp_ed = ed;
                ed.addButton('login_register_shortcodes', {
                    type: 'menubutton',
                    menu: [
                        {text: 'Registration Form',
                            menu: [{
                                wp_shortcode_data[0]},
                            }],
                        {text: 'Login Form',
                            menu: [{
                                wp_shortcode_data[1]}
                            }]}
                    ],
                    image: url + '/../images/webinarv2.ico'
                });
            }
        });
        tinymce.PluginManager.add("wpsystem", tinymce.plugins.wpsystem);
    }
})();

In my custom.php file

    function shortcodeData() {
global $post;
query_posts(array('post_type' => 'abc', 'orderby' => 'date'));
?>
<script type="text/javascript">
    var wp_shortcode_data = [[
<?php
if (have_posts()) {
    while (have_posts()) {
    the_post();
    ?>
        text: '<?php echo html_entity_decode(get_the_title()) ?>', value: '<?php echo $post->ID ?>',
    <?php
    }
}
?>
    ],[ 
<?php
if (have_posts()) {
    while (have_posts()) {
    the_post();
    ?>
        text: '<?php echo html_entity_decode(get_the_title()) ?>', value: '<?php echo $post->ID ?>',
    <?php
    }
}
?>
    ];
</script>
<?php
wp_reset_query();
}

Please, can someone help me where I might be going wrong?

Read more here: Syntax error missing : after property id in custom tinymce

Leave a Reply

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