diff --git a/docs/reference/hooks.rst b/docs/reference/hooks.rst index 11515129c5..9c7a3f5f1f 100644 --- a/docs/reference/hooks.rst +++ b/docs/reference/hooks.rst @@ -46,9 +46,9 @@ The available hooks are: return HttpResponse("<h1>bad googlebot no cookie</h1>") -.. _construct_wagtail_edit_bird: +.. _construct_wagtail_userbar: -``construct_wagtail_edit_bird`` +``construct_wagtail_userbar`` Add or remove items from the wagtail userbar. Add, edit, and moderation tools are provided by default. The callable passed into the hook must take the ``request`` object and a list of menu objects, ``items``. The menu item objects must have a ``render`` method which can take a ``request`` object and return the HTML string representing the menu item. See the userbar templates and menu item classes for more information. .. code-block:: python @@ -60,7 +60,7 @@ The available hooks are: return '<li><a href="http://cuteoverload.com/tag/puppehs/" ' \ + 'target="_parent" class="action icon icon-wagtail">Puppies!</a></li>' - @hooks.register('construct_wagtail_edit_bird') + @hooks.register('construct_wagtail_userbar') def add_puppy_link_item(request, items): return items.append( UserbarPuppyLinkItem() ) diff --git a/wagtail/wagtailadmin/views/userbar.py b/wagtail/wagtailadmin/views/userbar.py index c41b5aed1d..d5689d2cad 100644 --- a/wagtail/wagtailadmin/views/userbar.py +++ b/wagtail/wagtailadmin/views/userbar.py @@ -1,3 +1,5 @@ +import warnings + from django.shortcuts import render from django.contrib.auth.decorators import permission_required @@ -5,6 +7,8 @@ from wagtail.wagtailadmin.userbar import EditPageItem, AddPageItem, ApproveModer from wagtail.wagtailcore import hooks from wagtail.wagtailcore.models import Page, PageRevision +from wagtail.utils.deprecation import RemovedInWagtail11Warning + @permission_required('wagtailadmin.access_admin', raise_exception=True) def for_frontend(request, page_id): @@ -16,6 +20,14 @@ def for_frontend(request, page_id): for fn in hooks.get_hooks('construct_wagtail_edit_bird'): fn(request, items) + warnings.warn( + "The 'construct_wagtail_edit_bird' hook has been renamed to 'construct_wagtail_userbar'." + "Please update function '%s' in '%s'." % (fn.__name__, fn.__module__), RemovedInWagtail11Warning + ) + + for fn in hooks.get_hooks('construct_wagtail_userbar'): + fn(request, items) + # Render the items rendered_items = [item.render(request) for item in items] @@ -40,6 +52,14 @@ def for_moderation(request, revision_id): for fn in hooks.get_hooks('construct_wagtail_edit_bird'): fn(request, items) + warnings.warn( + "The 'construct_wagtail_edit_bird' hook has been renamed to 'construct_wagtail_userbar'." + "Please update function '%s' in '%s'." % (fn.__name__, fn.__module__), RemovedInWagtail11Warning + ) + + for fn in hooks.get_hooks('construct_wagtail_userbar'): + fn(request, items) + # Render the items rendered_items = [item.render(request) for item in items]