marlemiesz / wp-sdk
There is no license information available for the latest version (v0.1) of this package.
The WP API SDK for PHP is a client library that makes it easy to interact with the WordPress REST API from a PHP application. This SDK provides an easy-to-use interface for sending HTTP requests and handling the responses, and also includes convenient methods for accessing common API endpoints and d
v0.1
2023-02-06 16:22 UTC
Requires
- php: ^8.2
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- phpunit/phpunit: ^10.0.3
- vlucas/phpdotenv: ^5.3
This package is auto-updated.
Last update: 2025-05-08 23:06:54 UTC
README
Require this package in your composer.json
and update composer.
"marlemiesz/wp-sdk": "dev-master"
OR
composer require marlemiesz/wp-sdk: dev-master
Docs
Authentication
To use the SDK, you need to create an instance of the Wordpress
class and pass it your credentials.
use Marlemiesz\SdkWordpress\Wordpress; $wp = new Wordpress('http://example.com', 'username', 'password');
Categories
Api Reference: https://developer.wordpress.org/rest-api/reference/categories/
Get all categories
$categories = $wp->getCategories();
Posts
Api Reference: https://developer.wordpress.org/rest-api/reference/posts/
Get all posts
$posts = $wp->getPosts();
Add new post
$post = $wp->addPost( 'Post title', 'Post content', \Marlemiesz\WpSDK\Enum\PostStatuses::PUBLISH, [1, 2, 3], )?->getFirstItem();
Update post
$post = $wp->updatePost( 1, 'Post title', 'Post content', \Marlemiesz\WpSDK\Enum\PostStatuses::PUBLISH, [1, 2, 3], )?->getFirstItem();
Delete post
$wp->deletePost(1);