After looking through my messages table using phpMyAdmin I was able to locate the post record that contains my links. After inspecting the syntax of the post’s content, I was able to deduce the information that I needed.
For those facing a similar need in the future, I’ve put together this Python script. This script modifies the navigation block via the WordPress API.
import http.client
import json
# Create variables for the site you wish to appear
# in your navigation block.
link_label = "The Onion"
link_desc = "America's Finest News Source"
link_url = "www.theonion.com"
# Here I am building the code for the navigation link.
content = '<!-- wp:navigation-link {"label":"' + link_label + '","description":"' \
+ link_desc + \
'","opensInNewTab":true,"url":"' + link_url + '", "kind":"custom"} /-->'
# This translates the content variable above to JSON.
payload = json.dumps({
"content": content,
})
conn = http.client.HTTPSConnection("<your domain>")
headers = {
'Content-Type':'application/json',
'Authorization': '<your code here>'
}
conn.request("POST", "/wp-json/wp/v2/navigation/<id>", payload, headers)
# <id> is the ID of your navigation "post" ^^^^
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Perhaps the most valuable part of this code is building the string that I assign the to variable ‘content.’
Note that this code replaces any links that are already in the Navigation block, and it only creates one link. I leave it as an exercise to the reader to replace or add strings.
May you be blessed by the god of your choosing.
Don