remove navigation
This commit is contained in:
parent
941776a7c1
commit
e17cace820
@ -260,64 +260,6 @@ class WPMenu:
|
||||
|
||||
self._createMenu(menu)
|
||||
exit(0)
|
||||
navigation = ''
|
||||
for i in menu:
|
||||
self._logger.info("{0} Menu parent {1} with id {2} and type {3} and link {4}".format(self._name, i["title"], i["id"], i["type"], i["link"]))
|
||||
if len(i["children"]) > 0:
|
||||
navigation = navigation + "<!-- wp:navigation-submenu {\"label\":\"label-string\" ,\"type\":\"kind-string\",\"id\":id-string,\"url\":\"url-string\",\"kind\":\"kind-string-type\"} --> \n\n".replace("label-string", i["title"]).replace("id-string", str(i["id"])).replace("url-string", i["link"]).replace("kind-string", i["type"])
|
||||
else:
|
||||
navigation = navigation + "<!-- wp:navigation-link {\"label\":\"label-string\",\"type\":\"kind-string\",\"id\":id-string,\"url\":\"url-string\",\"kind\":\"kind-string-type\"} /--> \n".replace("label-string", i["title"]).replace("id-string", str(i["id"])).replace("url-string", i["link"]).replace("kind-string", i["type"])
|
||||
for j in i["children"]:
|
||||
navigation = navigation + "<!-- wp:navigation-link {\"label\":\"label-string\",\"type\":\"kind-string\",\"id\":id-string,\"url\":\"url-string\",\"kind\":\"kind-string-type\"} /--> \n".replace("label-string", j["title"]).replace("id-string", str(j["id"])).replace("url-string", j["link"]).replace("kind-string", j["type"])
|
||||
|
||||
self._logger.info("{0} Menu children {1} with id {2} and type {3} and link {4}".format(self._name, j["title"], j["id"], j["type"], j["link"]))
|
||||
if len(i["children"]) > 0:
|
||||
navigation = navigation + "<!-- /wp:navigation-submenu --> \n"
|
||||
self._logger.info("{0} : {1}".format(self._name, navigation))
|
||||
|
||||
self._navigation(navigation)
|
||||
|
||||
|
||||
def _navigation(self, content):
|
||||
self._logger.info("{0} Get ID navigation from wordpress for {1}".format(self._name, self._wordpress))
|
||||
try:
|
||||
title = "Menu {0}".format(self._wordpress)
|
||||
exist = False
|
||||
page = self._request_wordpress.get("{1}://{0}/wp-json/wp/v2/navigation".format(self._wordpress, self._protocol_wordpress), auth=self._basic)
|
||||
if page.status_code == 200:
|
||||
result = page.json()
|
||||
self._logger.info("{0} : Get content navigation : {1}".format(self._name, len(result)))
|
||||
for i in result:
|
||||
self._logger.debug("{0} : Debug get item navigation : {1}".format(self._name, i))
|
||||
if i["title"]["rendered"] == title:
|
||||
exist = True
|
||||
self._logger.info("{0} : {1} is exist".format(self._name, title))
|
||||
if exist is False:
|
||||
try:
|
||||
self._logger.info("{0} Create navigation to wordpress for {1}".format(self._name, self._wordpress))
|
||||
data = {"title": title, "content": content}
|
||||
page = self._request_wordpress.post("{1}://{0}/wp-json/wp/v2/navigation".format(self._wordpress, self._protocol_wordpress), auth=self._basic, headers=self._headers_json, data=json.dumps(data))
|
||||
if page.status_code == 201:
|
||||
self._logger.info("{0} : Navigation Menu {1} is created".format(self._name, self._wordpress))
|
||||
self._logger.debug("{0} : Navigation Menu {1} create debug : ".format(self._name, page.content))
|
||||
|
||||
else:
|
||||
self._logger.error("{0} : Post navigation didn't get due status code : {1}".format(self._name, page.status_code))
|
||||
self._logger.debug("{0} : {1}".format(self._name, page.content))
|
||||
except ConnectionError as err:
|
||||
self._logger.error("{0} : Connection error for post naviguation url {1} : {2}".format(self._name, "{1}://{0}/wp-json/wp/v2/navigation".format(self._wordpress, self._protocol_wordpress), err))
|
||||
exit(1)
|
||||
except Exception as err:
|
||||
self._logger.error("{0} : Exception error for post navigation url {1} : {2}".format(self._name, "{1}://{0}/wp-json/wp/v2/navigation".format(self._wordpress, self._protocol_wordpress), err))
|
||||
|
||||
else:
|
||||
self._logger.error("{0} : Get navigation didn't get due status code : {1}".format(self._name, page.status_code))
|
||||
self._logger.debug("{0} : {1}".format(self._name, page.content))
|
||||
except ConnectionError as err:
|
||||
self._logger.error("{0} : Connection error for get url {1} : {2}".format(self._name, "{1}://{0}/wp-json/wp/v2/navigation".format(self._wordpress, self._protocol_wordpress), err))
|
||||
exit(1)
|
||||
except Exception as err:
|
||||
self._logger.error("{0} : Exception error for get url {1} : {2}".format(self._name, "{1}://{0}/wp-json/wp/v2/navigation".format(self._wordpress, self._protocol_wordpress), err))
|
||||
|
||||
def _createMenu(self, menu):
|
||||
title = "Menu {0}".format(self._wordpress)
|
||||
|
Loading…
x
Reference in New Issue
Block a user