Skip to content

Commit

Permalink
Merge branch 'master' into roles-test
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasPe committed Sep 22, 2024
2 parents 185ee16 + 54954c7 commit 0331eca
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Create dockerzied WordPress
run: |
cd dev
docker-compose up -d
docker compose up -d
docker ps
sleep 20s
curl --fail http://localhost:8080/wp-json
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ WordPressPCL is built on top of the [.NET Standard](https://docs.microsoft.com/e
// Client construction
//pass the Wordpress REST API base address as string
var client = new WordPressClient("http://demo.wp-api.org/wp-json/");
var client = new WordPressClient("https://demo.wp-api.org/wp-json/");

//or pass the base address as strongly typed Uri
const wpBaseAddress = new Uri("http://demo.wp-api.org/wp-json/");
const wpBaseAddress = new Uri("https://demo.wp-api.org/wp-json/");
var client = new WordPressClient(wpBaseAddress);

//or to reuse an HttpClient pass the HttpClient with base address set to api's base address
httpClient.BaseAddress = new Uri("http://demo.wp-api.org/wp-json/")
httpClient.BaseAddress = new Uri("https://demo.wp-api.org/wp-json/")
var client = new WordPressClient(httpClient);

// Posts
Expand Down Expand Up @@ -128,4 +128,4 @@ Second, please try to stick to the official C# coding guidelines. https://msdn.m

Also, make sure to write some tests covering your new or modified code.

In order to run the tests on local machine please refer to the **install.md** file in the dev directory of the repository. Docker along with docker-compose cli will be required to run the tests.
In order to run the tests on local machine please refer to the **install.md** file in the dev directory of the repository. Docker and Docker Compose will be required to run the tests.
4 changes: 2 additions & 2 deletions dev/install.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Run `docker-compose up` inside the `dev` folder and it will start a fully setup docker Wordpress instance on port 8080 to run tests.
Run `docker compose up` inside the `dev` folder and it will start a fully setup docker Wordpress instance on port 8080 to run tests.

- The Wordpress instance will have following already configured plugins:
- [JWT Auth – WordPress JSON Web Token Authentication](https://wordpress.org/plugins/jwt-auth/)
Expand All @@ -7,6 +7,6 @@ Run `docker-compose up` inside the `dev` folder and it will start a fully setup

- The "Permanlinks" link structure in Wordpress settings is set to "Post name"

To destroy the containers simply run `docker-compose down` in the terminal
To destroy the containers simply run `docker compose down` in the terminal

To run the tests in Visual Studio, make sure to use the `jwtauth.runsettings` test settings.
25 changes: 25 additions & 0 deletions docs/I version 2.x/entities/posts.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,31 @@ if (await client.IsValidJWTokenAsync())
}
```

## Update Custom Fields

```C#
var post = new Post
{
Id = 123,
Meta = new Dictionary<string, string>
{
["my-custom-key"] = "some value"
},
};

await client.Posts.UpdateAsync(post);
```

Please note that all meta keys need to be registered using [`register_post_meta()`](https://developer.wordpress.org/reference/functions/register_post_meta/) before you can use them, e.g. by using the following PHP snippet:

```php
register_post_meta('post', 'my-custom-key', [
'type' => 'string',
'single' => true,
'show_in_rest' => true,
]);
```

## Delete Post

```C#
Expand Down

0 comments on commit 0331eca

Please sign in to comment.