Usage

Component creation

In order to use this extension, first thing you need to do is to create a blog (you can change the name if you want)
component and configure it. Here is the example of minimal configuration (in your config/main.php):

Or create a new post with title "New post" and content "Hello world!":

$postID=Yii::$app->blog->newPost('New post', 'Hello world!');

Caching request results

Making API calls to an external application means delays.
If you don't want your users to wait for a Wordpress response each time, caching is a right thing to do:

// The user profile will be fetched from cache if available.// If not, the query will be made against XML-RPC API and cached for use next time.$profile=Yii::$app->blog->cache(function (Wordpress$blog) {return$blog->getProfile(); });

In case, if you need something more complex, you can disable caching for some requests:

List of available methods

Please note, that all those methods are throwing an exceptions in case of any errors.
While this extension is configured (by default), in case of errors, to return an empty array for any data retrial
methods and false for any create, update or delete methods. Please see $catchExceptions configuration option for details.

Errors logging

There are a lot of things that can go wrong (network problems, wrong Wordpress user permissions, etc.).
If $catchExceptions configuration option is set to true (default value), this extension will catch them and pass to
monitorbacklinks\yii2wp\Wordpress::* logging category.

In order to see them, you can configure your Yii2 log component to something similar to this: