Can I get Wordpress Plugin Data through Wordpress API? - wordpress

I am looking to build a wordpress website with GatsbyJS (so no PHP usage. Just using Wordpress API and react JSX on the front-end).
I know I can get any core wordpress data at /wp-json route, but I'm not sure about plugin data. I've tried to look up plugin data and it does not seem to be included in wp-json.
I found this "compatible plugins" page: https://v2.wp-api.org/guide/plugins/
Does this mean that for most other plugins data would not be present in the Wordpress API?

Correct. Unless these plugins expose their data via the REST API (either by extending the existing endpoints or by creating their own, like some plugins do), you won't be able to access it.
In such cases, you either ask the developers to expose their plugin's data via the REST API or you code some custom endpoints yourself to get the data you need from them.

Related

I'm trying to implement external REST APIs in my wordpress website. Can anybody have idea how to do it (whether with a plugin or with programming)

I tried to use one plugin called "WP Data Sync". I am also going through its documentation/ support for the same. I am also having wpbakery page builder in my website. So is there any way that we sync with that also?
Note - We have to sync data in the form of images, image gallery, events listing, and the blog posts.
Did you check out WP Data Syncs website at https://wpdatasync.com/ and create an account to check out an API key?
I'm not sure about all APIs, but the ones I've used in the past would require me to register with the API's website, get issued an API key and maybe even designate the key to a specific website (your WordPress site in this case) for security reasons. After that, you would then go to your WP site and setup the API there via WP DataSyncs plugin.
I hope I understood your question and that this helps.

Get recent wordpress posts in Laravel

I have a Wordpress site and a Laravel site and I want to display recent wordpress posts in the footer of Laravel site. How can I do this without having my wordpress database information in my config/database.php file and using it in the models? Can I get them using RSS?
Recent WordPress was released with a huge thing called REST API – earlier it was possible only with external plugins. So now we can query WordPress database from external projects. Including Laravel.
set up a local WordPress website, and after installation you got that usual dashboard.
we can already make API calls after installation. No need to configure anything, we just launch the URL in the browser:
we’ve received a JSON with a list of posts – by default, WordPress creates one dummy post.
Basically, URL structure for the API calls is simple:
/wp-json/wp/v2/[endpoint]?[parameters]
Yes, you’ve read it right, we can get posts, categories, tags and other things that are publicly available, so we don’t need any authentication here.
And we also can filter the data with GET parameters, like this:
/wp-json/wp/v2/posts?per_page=2&orderby=title
For more details open link:- Using WordPress REST API in Laravel
You can get the posts by calling an API endpoint:
yoursiteurl/wp-json/wp/v2/posts
It will return all the posts in a json format. You can also see the reference from here.

Mixing Wordpress eCommerce site with external login based Vue Frontend Best Practices

I am new to web development and and would like advice about what is the usual best practices to achieve what I am trying to do.
I am in charge of writing a frontend app using Vue. This frontend will require a login to access the app. The app will be hosted on Amazon.
However we are also wanting to build an eCommerce site in Wordpress or equivalent that sits on the root of the website, (eg www.mywebsite.com) with the app accessible through a "sign in" button. If the user presses the sign in button we want the location bar location to not change from the website they are on (www.mywebsite.com), even though the Wordpress site and Vue frontend may be stored on different locations/domains.
If the site is made in Wordpress, we can get another developer to do that webpage for us, while I work on the frontend. However we want the experience to be relatively seamless between connecting to the wordpress root site, clicking on the sign in button and being taken to the Vue frontend.
Is this possible? Do both sites have to be hosted on the same server for it to work (eg an Amazon EC2 server which hosts two webpages, the wordpress one and the vue one)?
Or can the wordpress put a link to the Vue frontend which doesn't change the web location to the user?
Or (worst case scenario) do we need to make both webpages in Vue as one Vue application, some pages requiring login to access and others not?
Thanks kindly for any assistance.
So in order to use Vue and WordPress together, you can either write 2 separate applications. One for the Frontend and one for the Backend, which is perfectly fine or you can simply write a WordPress Application with a Vue Theme.
This is how this could look like:
WordPress Backend
You can use a normal WordPress backend, where you can build the architecture you want to. In addition, you need to set up the REST-API Wordpress provides. So this also means, just use plugins which support it. Otherwise, you would need to write custom endpoints. For example, Woocommerce would be a good e-commerce plugin, since it supports the API.
Learn more about it here: https://v2.wp-api.org/
Of course, you can host your WordPress installation on Amazon. Here is a good guide for that: https://aws.amazon.com/de/getting-started/tutorials/launch-a-wordpress-website/
Notice: The REST-API is available in core since 4.7. If you are using an older version you would need to install a plugin.
WordPress Frontend
In order to create your Frontend, I'd recommend you to make a custom theme. Since you are just serving static files this can be done pretty easy. But still, you don't need to reinvent the wheel.
There's a really good starter theme out there: https://github.com/EvanAgee/vuejs-wordpress-theme-starter
It comes with all the stuff you need to get started and since it is just a theme, you can simply set up a usual WordPress hosting without handling Domains of multiple applications.
In order to get the data from the Backend, you would simply make calls to the REST-API. Here's an example: https://github.com/EvanAgee/vuejs-wordpress-theme-starter/blob/master/src/api/index.js

SPA with content management

I would like to build Single Page Web Application (SPA) with React.js.
Application would need some Content Management System for back-end. I was thinking to use WordPress and their REST-API's but I don't know how to retrieve data from my wordpress installation.
Back-end and front-end would be in different domains so just building WP theme with React.js wouldn't work.
Basically, I don't know how to call and populate data from wordpress to my front-end.
I would need someone to point me to the right direction. And, maybe recommend easier CMS to use in this task.
Actually it is very easy to access your WordPress website data through HTTP REST API
Here you have the full documentation on WordPress REST APi
http://v2.wp-api.org/

Wordpress XMLRPC advice needed

I have been tasked with creating an API for retrieving and adding content to Wordpress from a flash application and legacy CMS (non-PHP). My plan is to utilise the existing default xmlrpc endpoint and add any additional functionality by creating a plugin which hooks into xmlrpc_methods.
A previous attempt had been made by another developer based on the following code:
http://blog.5ubliminal.com/posts/remote-control-wordpress-blog-xmlrpc-api/
This code looks unwieldy and poorly documented to me and my preference would be to use this approach:
http://kovshenin.com/archives/custom-xml-rpc-methods-in-wordpress/
I would be grateful if anyone with experience in this area could confirm that:
I will be able to distinguish between separate blogs in an MU installation when both retrieving and posting data via XMLRPC
I will be able to retrieve and post to custom fields
writing a plugin is the way to go.
We do not have the option of using Wordpress 3 as it is still in Beta and we are under time pressure.
I would greatly appreciate appreciate any input / advice.
Many thanks,
I've worked with WordPress' XMLRPC system before (using a WP-Hive installation with multiple separate blogs similar to a WPMU set-up). The new approach you're using is definitely simpler and easier to implement (I tried the 5ubliminal one as well the first time).
Whether or not you can distinguish between separate blogs in a MU installation depends entirely on how you build your handler function. You can build it to distinguish the separate blogs, to only function on specific blogs, or to treat the entire system as a single WordPress site. It's all up to you.
By "handler function" I mean a custom function you define to handle XMLRPC requests that call a specific, custom method (not necessarily the default WordPress methods). For example, I use XMLRPC in all my plug-ins to report back installation progress and errors -
each plug-in makes an XMLRPC call to a custom handler (method) on my server.
Yes, you can retrieve and post to custom fields.
Absolutely writing a plug-in is the way to go. The only other options are to change core files (BAD idea) or to build it into your theme, in which case it could ONLY be used on MU sites using that theme. Build it as a site-wide MU plug-in that can be controlled on a site-by-site basis by the global admin.
Wordpress XMLRPC offers various functionalities which can be harvested easily. I have used IXR_Library to parse the XML requests/responses. Currently with very small piece of code i can easily posts, fetch, edit and delete Posts in Wordpress based blogs either self hosted or on wordpress.com sites.
http://www.hurricanesoftwares.com/wordpress-xmlrpc-posting-content-from-outside-wordpress-admin-panel/ (reference)
When you have multiple blogs hosted via MU you will need site ID of all those blogs which will become the first parameter for $params (in our case 0 should be replaced with site_id).
In the reference i gave above you will see the option to fetch and post to all created custom fields (unfortunately, you can't create custom fields on the fly from my script)
You are welcome to write a WP plugin to do all of this, be my guest and let me know if you need my help. I have used the same technique to post to blogger, tumblr, Wordpress and Posterous using their API's. I hope this helps.

Resources