/* global registerBackward, DataProviderFacade, BackwardUtility */

registerBackward('1.2.24', 'Theme', function (theme) {
    'use strict';

    if (DataProviderFacade.getCmsInfo().cmsName === 'WordPress') {
        for(var key in theme.controls) {
            if (theme.controls.hasOwnProperty(key) && theme.controls[key].constructorName === 'Blog') {
                var posts = theme.controls[key];
                var blogKeys = Object.keys(posts);
                var blog = $.extend({}, posts);
                for(var i = 0; i < blogKeys.length; i++)
                    delete posts[blogKeys[i]];

                posts.packageData = BackwardUtility.getControlObject('Posts').packageData;
                posts.constructorName = "Posts";
                posts.blog = blog;
            }
        }
    }
    return theme;
});