diff --git a/lib/WPMenu.py b/lib/WPMenu.py index e8889de..b17be64 100644 --- a/lib/WPMenu.py +++ b/lib/WPMenu.py @@ -272,7 +272,7 @@ class WPMenu: if page.status_code == 200: result = page.json() for i in result: - if i["title"]["rendered"] == itemMenu["title"]: + if self._replaceCaracter(i["title"]["rendered"]) == itemMenu["title"]: idItemMenu = int(i["id"]) self._logger.info("{0} : Length of result for item menus : {1}".format(self._name, len(result))) url = "{1}://{0}/wp-json/wp/v2/menu-items".format(self._wordpress, self._protocol_wordpress) @@ -283,7 +283,9 @@ class WPMenu: objectt = itemMenu["type"] if objectt == "tag": objectt = "post_tag" - data = {"title": itemMenu["title"], "status": "publish", "parent":parent, "menus":idMenu, "url":"{0}://{1}".format(self._protocol_wordpress, self._wordpress)} + data = {"title": itemMenu["title"], "status": "publish", "parent":parent, "menus":idMenu, "url":"#"} + if itemMenu["title"] == "home": + data = {"title": itemMenu["title"], "status": "publish", "parent":parent, "menus":idMenu, "url":"{0}://{1}".format(self._protocol_wordpress, self._wordpress)} if type(itemMenu["id"]) is str: if len(itemMenu["id"]) > 0: data = {"title": itemMenu["title"], "status": "publish", "parent":parent, "url": itemMenu["link"], "menus":idMenu, "object":objectt, "object_id":int(itemMenu["id"])} @@ -369,6 +371,7 @@ class WPMenu: self._logger.info("{0} : add item to menu : {1}".format(self._name, idMenu)) parent = 0 for i in menu: + parent = 0 self._logger.debug("{0} : debug create item menu : {1}".format(self._name, i)) parent = self._createItemMenu(idMenu, i, parent) for j in i["children"]: