<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_plugins(sites=None):
 """ Returns all GoScale plugins It ignored all other django-cms plugins """

    plugins = []
    # collect GoScale plugins
    for plugin in CMSPlugin.objects.all():
        if plugin:
            cl = plugin.get_plugin_class().model
            if 'posts' in cl._meta.get_all_field_names():
                instance = plugin.get_plugin_instance()[0]
                plugins.append(instance)
        # Filter by sites
    if sites and len(sites) > 0:
        onsite = []
        for plugin in plugins:
            try:
                if plugin.page.site in sites:
                    onsite.append(plugin)
            except AttributeError:
                continue
        return onsite
    return plugins