{"id":26664426,"url":"https://github.com/madeitbelgium/wordpress-php-sdk","last_synced_at":"2025-04-09T06:13:02.176Z","repository":{"id":62521575,"uuid":"184545215","full_name":"madeITBelgium/WordPress-PHP-SDK","owner":"madeITBelgium","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-23T15:03:16.000Z","size":41,"stargazers_count":41,"open_issues_count":1,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-09T06:12:57.326Z","etag":null,"topics":["hacktoberfest","laravel","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/madeITBelgium.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["madeitbelgium"]}},"created_at":"2019-05-02T08:18:38.000Z","updated_at":"2025-04-05T23:03:21.000Z","dependencies_parsed_at":"2022-11-02T10:31:16.637Z","dependency_job_id":"8811e18c-17bc-456d-9007-d35e68c3cd4e","html_url":"https://github.com/madeITBelgium/WordPress-PHP-SDK","commit_stats":{"total_commits":35,"total_committers":2,"mean_commits":17.5,"dds":"0.11428571428571432","last_synced_commit":"0c02cbb4cd4204ab060e939cffa83ea40f3ec0f0"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madeITBelgium%2FWordPress-PHP-SDK","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madeITBelgium%2FWordPress-PHP-SDK/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madeITBelgium%2FWordPress-PHP-SDK/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madeITBelgium%2FWordPress-PHP-SDK/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/madeITBelgium","download_url":"https://codeload.github.com/madeITBelgium/WordPress-PHP-SDK/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247987285,"owners_count":21028895,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","laravel","php"],"created_at":"2025-03-25T16:28:17.131Z","updated_at":"2025-04-09T06:13:02.138Z","avatar_url":"https://github.com/madeITBelgium.png","language":"PHP","funding_links":["https://github.com/sponsors/madeitbelgium"],"categories":[],"sub_categories":[],"readme":"# WordPress API PHP SDK\n[![Build Status](https://travis-ci.org/madeITBelgium/WordPress-PHP-SDK.svg?branch=master)](https://travis-ci.org/madeITBelgium/WordPress-PHP-SDK)\n[![Coverage Status](https://coveralls.io/repos/github/madeITBelgium/WordPress-PHP-SDK/badge.svg?branch=master)](https://coveralls.io/github/madeITBelgium/WordPress-PHP-SDK?branch=master)\n[![Latest Stable Version](https://poser.pugx.org/madeITBelgium/WordPress-PHP-SDK/v/stable.svg)](https://packagist.org/packages/madeITBelgium/WordPress-PHP-SDK)\n[![Latest Unstable Version](https://poser.pugx.org/madeITBelgium/WordPress-PHP-SDK/v/unstable.svg)](https://packagist.org/packages/madeITBelgium/WordPress-PHP-SDK)\n[![Total Downloads](https://poser.pugx.org/madeITBelgium/WordPress-PHP-SDK/d/total.svg)](https://packagist.org/packages/madeITBelgium/WordPress-PHP-SDK)\n[![License](https://poser.pugx.org/madeITBelgium/WordPress-PHP-SDK/license.svg)](https://packagist.org/packages/madeITBelgium/WordPress-PHP-SDK)\n\n# Installation\n\nRequire this package in your `composer.json` and update composer.\n\n```php\ncomposer require madeitbelgium/wordpress-php-sdk\n```\n\nAfter updating composer, add the ServiceProvider to the providers array in `config/app.php`\n\n```php\nMadeITBelgium\\WordPress\\WordPressServiceProvider::class,\n```\n\nYou can use the facade for shorter code. Add this to your aliases:\n\n```php\n'WP' =\u003e MadeITBelgium\\WordPress\\WordPressFacade::class,\n```\n\nAdd the config files\n```php\nphp artisan vendor:publish --provider=\"MadeITBelgium\\WordPress\\WordPressServiceProvider\"\n```\n\n# Documentation\n## Authentication\nTo use authenticated requests you have to sign in to the WordPress website to generate a JWT token. WordPress doesn't support this by default, you have to install a JWT compatible plugin. This package is tested with: https://nl.wordpress.org/plugins/jwt-authentication-for-wp-rest-api/\n```php\nuse MadeITBelgium\\WordPress\\WordPressFacade as WordPress;\n$token = WordPress::login($request-\u003eget('email'), $request-\u003eget('password'));\n// {'token': '...'}\n```\nNow you can save the `$token-\u003etoken` to your database.\n```\nuse MadeITBelgium\\WordPress\\WordPressFacade as WordPress;\nWordPress::setAccessToken($token);\n```\n\n### Application Password\nYou can use the newly introduced Application Password (in WordPress 5.6).\n```\n$wp = WordPress::setServer('https://www.example.com')\n    -\u003esetUsername('username')\n    -\u003esetApplicationPassword('application password');\n```\n\n## Interact with objects\n### User\nWordPress Rest API documentation: https://developer.wordpress.org/rest-api/reference/users/\n\n```\nuse MadeITBelgium\\WordPress\\WordPressFacade as WordPress;\n$users = WordPress::user()-\u003elist();\n$result = WordPress::user()-\u003ecreate($data);\n$user = WordPress::user()-\u003eget($id);\n$result = WordPress::user()-\u003eupdate($id, $data);\n$result = WordPress::user()-\u003edelete($id);\n```\n\n### Post\nWordPress Rest API documentation: https://developer.wordpress.org/rest-api/reference/posts/\n\n```\nuse MadeITBelgium\\WordPress\\WordPressFacade as WordPress;\n$users = WordPress::post()-\u003elist();\n$result = WordPress::post()-\u003ecreate($data);\n$user = WordPress::post()-\u003eget($id);\n$result = WordPress::post()-\u003eupdate($id, $data);\n$result = WordPress::post()-\u003edelete($id);\n```\n\n### Post from custom post type\n\nWordPress Rest API documentation: https://developer.wordpress.org/rest-api/reference/posts/\n\n```\nuse MadeITBelgium\\WordPress\\WordPressFacade as WordPress;\n$users = WordPress::customPost('custom_post_type')-\u003elist();\n$result = WordPress::customPost('custom_post_type')-\u003ecreate($data);\n$user = WordPress::customPost('custom_post_type')-\u003eget($id);\n$result = WordPress::customPost('custom_post_type')-\u003eupdate($id, $data);\n$result = WordPress::customPost('custom_post_type')-\u003edelete($id);\n```\n\n### Tags\n\nWordPress Rest API documentation: https://developer.wordpress.org/rest-api/reference/tags/\n\n```\nuse MadeITBelgium\\WordPress\\WordPressFacade as WordPress;\n$users = WordPress::tag()-\u003elist();\n$result = WordPress::tag()-\u003ecreate($data);\n$user = WordPress::tag()-\u003eget($id);\n$result = WordPress::tag()-\u003eupdate($id, $data);\n$result = WordPress::tag()-\u003edelete($id);\n```\n\n### Create new post\n```\n$data = [\n    'title' =\u003e 'title',\n    'parent' =\u003e 0,\n    'slug' =\u003e Str::slug('title', '-'),\n    'content' =\u003e 'content',\n];\n$post = WordPress::post()-\u003ecreate($data);\n// {'id': ...}\n```\n\n### Uploading media\n```\nuse Illuminate\\Support\\Facades\\Storage;\nuse MadeITBelgium\\WordPress\\WordPressFacade as WordPress;\n\n$media = WordPress::postCall('/wp-json/wp/v2/media', [\n    'multipart' =\u003e [\n        [\n            'name' =\u003e 'file',\n            'contents' =\u003e Storage::disk('local')-\u003eget($fileLocation),\n            'filename' =\u003e 'filename.jpg',\n        ],\n        [\n            'name' =\u003e 'title',\n            'contents' =\u003e 'Title of attachment',\n        ],\n        [\n            'name' =\u003e 'alt_text',\n            'contents' =\u003e 'Alt text',\n        ],\n    ],\n]);\n```\n\n\n## Execute any request\nRead more about the WordPress rest API: https://developer.wordpress.org/rest-api/\n### Get\n```\n$url = \"\";\n$result = WordPress::getCall('/wp-json'.$url);\n```\n\n### Put\n```\n$result = WordPress::putCall('/wp-json'.$url, $data);\n```\n\n### Post\n```\n$result = WordPress::postCall('/wp-json'.$url, $data);\n```\n\n### Delete\n```\n$result = WordPress::deleteCall('/wp-json'.$url);\n```\n\n\nThe complete documentation can be found at: [https://www.tpweb.org/my-projects/wordpress-php-sdk/](https://www.tpweb.org/my-projects/wordpress-php-sdk/)\n\n# Support\n\nSupport github or mail: tjebbe.lievens@madeit.be\n\n# Contributing\n\nPlease try to follow the psr-2 coding style guide. http://www.php-fig.org/psr/psr-2/\n\n# License\n\nThis package is licensed under LGPL. You are free to use it in personal and commercial projects. The code can be forked and modified, but the original copyright author should always be included!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadeitbelgium%2Fwordpress-php-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmadeitbelgium%2Fwordpress-php-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadeitbelgium%2Fwordpress-php-sdk/lists"}