return value menu
This commit is contained in:
parent
eee14e08f1
commit
8de7485775
@ -262,7 +262,6 @@ class WPMenu:
|
||||
|
||||
|
||||
|
||||
exit(0)
|
||||
|
||||
def _createItemMenu(self, idMenu, itemMenu, parent):
|
||||
idItemMenu = 0
|
||||
@ -286,9 +285,16 @@ class WPMenu:
|
||||
objectt = "post_tag"
|
||||
data = {"title": itemMenu["title"], "status": "publish", "parent":parent, "menus":idMenu, "object":objectt, "object_id":itemMenu["id"]}
|
||||
page = self._request_wordpress.post(url, auth=self._basic, headers=self._headers_json, data=json.dumps(data))
|
||||
|
||||
if page.status_code == 201:
|
||||
result = page.json()
|
||||
idItemMenu = result["id"]
|
||||
self._logger.info("{0} : create item menu : {1}".format(self._name, itemMenu["title"]))
|
||||
elif page.status_code == 200:
|
||||
result = page.json()
|
||||
for i in result:
|
||||
if result["title"]["rendered"] == itemMenu["title"]:
|
||||
idItemMenu = i["id"]
|
||||
self._logger.info("{0} : update item menu : {1}".format(self._name, itemMenu["title"]))
|
||||
else:
|
||||
self._logger.error("{0} : Create menu items didn't get due status code : {1}".format(self._name, page.status_code))
|
||||
@ -356,3 +362,8 @@ class WPMenu:
|
||||
exit(1)
|
||||
except Exception as err:
|
||||
self._logger.error("{0} : Exception error for get menu {1} : {2}".format(self._name, "{1}://{0}/wp-json/wp/v2/menus".format(self._wordpress, self._protocol_wordpress), err))
|
||||
|
||||
|
||||
def addItemMenu(self, menu, idMenu):
|
||||
self._logger.info("{0} : add item to menu : {1}".format(self._name, idMenu))
|
||||
|
Loading…
x
Reference in New Issue
Block a user