function register_custom_buttons($buttons)
{
    $customButtons = loadCustomButtons();
    for ($i = 0; $i < sizeof($customButtons); $i++) {
        array_push($buttons, $customButtons[$i]->buttonSeparator, $customButtons[$i]->shortCodeTag);
    }
    return $buttons;
}
function getShortCodeButton()
{
    global $customButtonName;
    $selectedButton = null;
    $buttonArr = loadCustomButtons();
    foreach ($buttonArr as $button) {
        if ($button->shortCodeTag == $customButtonName) {
            $selectedButton = $button;
            break;
        }
    }
    return $selectedButton;
}
<?php

require_once 'buttons.php';
require_once 'custombutton.php';
require_once 'formfield.php';
header('Content-type: text/javascript');
?>

(function() {
    tinymce.create('tinymce.plugins.shortCodeButtons', {
        init : function(ed, url) {
	
<?php 
$shortCodes = loadCustomButtons();
foreach ($shortCodes as $shortCode) {
    ?>
            ed.addButton('<?php 
    echo $shortCode->shortCodeTag;
    ?>
', {
                title : '<?php 
    echo $shortCode->title;
    ?>
',
                image : url + '<?php 
    echo $shortCode->icon;
    ?>
',
                onclick : function() {
		   <?php 
    if (count($shortCode->fields) > 0) {