'Shows the add plugin form and saves it on POST.
Requires the following GET parameters:
- cms_path
- placeholder_id
- plugin_type
- plugin_language
- plugin_parent (optional)
- plugin_position (optional)'

@xframe_options_sameorigin
def add_plugin(self, request):

    form = PluginAddValidationForm(request.GET)
    if (not form.is_valid()):
        error = list(form.errors.values())[0][0]
        return HttpResponseBadRequest(force_text(error))
    plugin_data = form.cleaned_data
    placeholder = plugin_data['placeholder_id']
    plugin_type = plugin_data['plugin_type']
    if (not self.has_add_plugin_permission(request, placeholder, plugin_type)):
        message = force_text(_('You    do    not    have    permission    to    add    a    plugin'))
        return HttpResponseForbidden(message)
    parent = plugin_data.get('plugin_parent')
    if parent:
        position = parent.cmsplugin_set.count()
    else:
        position = CMSPlugin.objects.filter(parent__isnull=True, language=plugin_data['plugin_language'], placeholder=placeholder).count()
    plugin_data['position'] = position
    plugin_class = plugin_pool.get_plugin(plugin_type)
    plugin_instance = plugin_class(plugin_class.model, self.admin_site)
    plugin_instance._cms_initial_attributes = {'language': plugin_data['plugin_language'], 'placeholder': plugin_data['placeholder_id'], 'parent': plugin_data.get('plugin_parent', None), 'plugin_type': plugin_data['plugin_type'], 'position': plugin_data['position']}
    response = plugin_instance.add_view(request)
    plugin = getattr(plugin_instance, 'saved_object', None)
    uses_hook = _instance_overrides_method(PlaceholderAdminMixin, self, 'post_add_plugin')
    if (plugin_instance.object_successfully_changed and uses_hook):
        warnings.warn('The    post_add_plugin    hook    has    been    deprecated.    Please    use    placeholder    operation    signals    instead.', DeprecationWarning)
        self.post_add_plugin(request, plugin)
    if plugin_instance._operation_token:
        tree_order = placeholder.get_plugin_tree_order(plugin.parent_id)
        self._send_post_placeholder_operation(request, operation=operations.ADD_PLUGIN, token=plugin_instance._operation_token, plugin=plugin, placeholder=plugin.placeholder, tree_order=tree_order)
    return response
