Skip to content

Commit

Permalink
minor fix, not going to assert status code any more
Browse files Browse the repository at this point in the history
  • Loading branch information
tybalex authored and thedadams committed Feb 4, 2025
1 parent 0017c5e commit 251c637
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
8 changes: 7 additions & 1 deletion wordpress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ services:
WORDPRESS_DB_USER: dbuser
WORDPRESS_DB_PASSWORD: dbpassword
WORDPRESS_DB_NAME: exampledb
WORDPRESS_CONFIG_EXTRA: |
define('WP_ENVIRONMENT_TYPE', 'local');
volumes:
- wordpress:/var/www/html

Expand All @@ -38,7 +40,11 @@ volumes:
```
and run `docker compose -f wordpress.yaml up`.

Navigate to localhost:8070. The first time you run the container, it will prompt you to register the site name and create a new user.

### CRITICAL: Configure Permalinks in Settings
Without configuring permalinks, the Wordpress API will not work, because the `/wp-json` endpoint will not be available.
1. Without configuring permalinks, the Wordpress API will not work, because the `/wp-json` endpoint will not be available.
To do this, go to your wordpress site dashboard, on the left sidebar, select `Settings` -> `Permalinks`, then select any non-plain Permalink structure.
2. You must create an application password to be able to create posts.
To do this, go to your wordpress site dashboard, on the left sidebar, select `Users`, edit your user profile and scroll down to the `Application Passwords` section, then select `Add New`.

2 changes: 1 addition & 1 deletion wordpress/tool.gpt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
Name: Wordpress
Description: Tools for interacting with User's self-hosted WordPress Site
Description: Tools for interacting with self-hosted and hosted Wordpress sites that support basic auth.
Metadata: bundle: true
Share Tools: List Users, Get User, List Posts, Retrieve Post, Create Post, Update Post, Delete Post, Get Site Settings

Expand Down
8 changes: 4 additions & 4 deletions wordpress/tools/posts.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def list_posts(client):
url += suffix

response = client.get(url)
if response.status_code == 200:
if response.status_code >= 200 and response.status_code < 300:
return [_format_posts_response(post) for post in response.json()]
else:
print(f"Failed to list posts. Error: {response.status_code}, {response.text}")
Expand Down Expand Up @@ -234,7 +234,7 @@ def create_post(client):
post_data["ping_status"] = ping_status

response = client.post(url, json=post_data)
if response.status_code == 201:
if response.status_code >= 200 and response.status_code < 300:
return _format_posts_response(response.json())
else:
print(f"Failed to create post. Error: {response.status_code}, {response.text}")
Expand All @@ -249,7 +249,7 @@ def delete_post(client):
url += "?force=true"

response = client.delete(url)
if response.status_code == 200:
if response.status_code >= 200 and response.status_code < 300:
return {"message": "Post deleted successfully"}
else:
print(f"Failed to delete post. Error: {response.status_code}, {response.text}")
Expand Down Expand Up @@ -350,7 +350,7 @@ def update_post(client):
post_data["ping_status"] = ping_status

response = client.post(url, json=post_data)
if response.status_code == 200:
if response.status_code >= 200 and response.status_code < 300:
return _format_posts_response(response.json())
else:
print(f"Failed to update post. Error: {response.status_code}, {response.text}")
2 changes: 1 addition & 1 deletion wordpress/tools/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
def get_site_settings(client):
url = f"{WORDPRESS_API_URL}/settings"
response = client.get(url)
if response.status_code == 200:
if response.status_code >= 200 and response.status_code < 300:
return response.json()
else:
print(f"Error: {response.status_code}, {response.text}")
4 changes: 2 additions & 2 deletions wordpress/tools/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def get_user(client):
user_id = os.environ["USER_ID"]
url = f"{WORDPRESS_API_URL}/users/{user_id}"
response = client.get(url)
if response.status_code == 200:
if response.status_code >= 200 and response.status_code < 300:
return _format_users_response(response.json())
else:
print(f"Error: {response.status_code}, {response.text}")
Expand All @@ -22,7 +22,7 @@ def get_user(client):
def list_users(client):
url = f"{WORDPRESS_API_URL}/users"
response = client.get(url)
if response.status_code == 200:
if response.status_code >= 200 and response.status_code < 300:
return [_format_users_response(user) for user in response.json()]
else:
print(f"Error: {response.status_code}, {response.text}")

0 comments on commit 251c637

Please sign in to comment.