How to use the Wordpress API to install plugins - php

How can I install and activate a predefined list of WP plugins using the WP API using Php please?

The REST API doesn't support plugin based actions yet. See the API handbook reference for information on what endpoints are currently available.
Posts /wp/v2/posts
Post Revisions /wp/v2/revisions
Categories /wp/v2/categories
Tags /wp/v2/tags
Pages /wp/v2/pages
Comments /wp/v2/comments
Taxonomies /wp/v2/taxonomies
Media /wp/v2/media
Users /wp/v2/users
Post Types /wp/v2/types
Post Statuses /wp/v2/statuses
Settings /wp/v2/settings
You can add custom endpoints though which would open this up for you, but due to the authentication methods available in the REST API at the moment (cookies), it does mean you have to be careful about who can access the endpoint.
A better approach to all of this is to use WP-CLI. It's an official WordPress project that lets you control the site from the command line. This is the best approach I think.

Related

Use Wordpress or another CMS within a web application?

Apologies for the broad question, but I don't know where to start. I have a php web application for members with various functions and features. On the dashboard, I need to implement some dynamic news - the kind of news that that non-developer can write and publish without any interference with the source code.
Can I implement Wordpress into my existing app so that authors can login, write then publish so that my dashboard can display the latest posts?
At its most basic level, I'm thinking:
a new subfolder for Wordpress with its own separate database.
a plugin to display the latest posts content only
an iframe on my dashboard to display the output of that plugin
But all that seems like a very hacky workaround. Is there a more native way of doing this? Or is there another CMS library that could achieve the same result?
I have a solution that I am running with. It's a separate Wordpress site with the latest posts accessed via the built-in API (https://developer.wordpress.org/rest-api/reference/posts/)
I will be getting all the posts in a category with:
curl https://example.com/wp-json/wp/v2/posts
Then storing the posts in array before looping through that array to display the title and content on my dashboard with:
curl https://example.com/wp-json/wp/v2/posts/<id>
where <id> is from the first call.
This is clean, native and serves the exact purpose I need. The member info, while secured doesn't need to be top-secret, so we're just using the Wordpress password-protection with the same password for all posts so as long as the API calls are server-side with https, the security works too :)
Looks like you want Dynamic News Feature in your existing PHP Web Application.
And you want to build that specific feature in Wordpress.
I don't think it's a good idea to use Wordpress CMS for small features like this.
IF you already have full functional PHP Web Application then I would recommend to use same Web Application to build Dynamic News Feature which will allow users on the site to post.
I don't think that's very complex.
IF you want to get into Wordpress ecosystem then you will need to convert your PHP Web Application into Wordpress and then you can build additional functionality.
I think that's the ideal way to go. Let me know if more questions. Thanks.

How to get list of categories of a wordpress blog using wordpress REST api

First of all i know it is a theoretical question and it contains no code but actually this time i don't have code, i need your suggestion on this issue.
Question:
Is it possible to fetch the name of all categories from a wordpress.com blog or a self-hosted blog connected through jetpack?
I tried finding it here https://developer.wordpress.com/docs/api/ but no luck.
So please suggest.
I've been looking for the same thing. I don't think this feature is available yet (As of 24th May 2013) on jetpack but available on hosted blogs (see the link below).
http://codex.wordpress.org/Function_Reference/get_categories
In case you are using JSON API plugin, you can use
http://yourdomain.com/?json=get_category_index to get the list of all categories.
PS: You can use this JSON API plugin in place of jetpack api as it is hosted on your own blog with greater control.

Good approach to adding a blog to my website

I've built a custom website on top of the codeigniter framework. I now want to implement a 'blog' section of my website and allow various non-technical people I work with to edit/create blog entries and post them. I don't want to create a backend for this from scratch.
Are there any good plugins for codeigniter that work with existing blog hosting services to perhaps download an xml-rss feed and construct this into a blog page? Not sure what the best approach is to offer this kind of functionality to nontechnical people I work with. Any suggestions?
If it's simply the admin interface you don't want to write again, I would:
Setup the blog on the same mysql server as your CodeIgniter app OR on a server with a static IP
Create another db connection from your app to the blog's database
Use CodeIgniter to handle data, routing and the frontend views
This will allow you to better integrate the frontend interface of the blog into your existing site while keeping the blog's backend.
If you don't (for some reason) want to create another connection, you could use the RSS feeds as an XML formatted API, or create an API layer on top of the blog. This option will definitely be slower than a direct connection, but you may prefer to do it this way.
Almost all blogs provide RSS. You could just consume that and cache it using an RSS Parser library.
I have a demo running right now using this method with Tumblr

CodeIgniter + Wordpress + phpBB + Facebook

I've been working on a home project using CodeIgniter Reactor, and have come to a point where I'm going to need to implement whole set of features that ideally will work via one single sign-on system for users. 2 of these features will be custom features that rely on user registration, the other 2 features are pretty standard feature requests. I could write these 2 new features myself, but that would take a while, and I feel like I'd be re-inventing the wheel, given the feature sets of the alternatives out there. I wonder if I'm better off using existing solutions, using their user registration/sign-on system, and hooking my new features into that system.
The key standards requirements are:
A blog system - obvious answer here is to use WordPress, and use the WP Pages for the more static content but updateable content. Users will be able to comment on blog posts.
A forum - In addition to commenting on individual blog posts, they will be able to start up their own discussions about subjects. The obvious thing here is 1) one user login for both the blog and the forum, and 2) Upon creating a blog entry, a forum thread is created, and all comments on the blog entry are actually posts on this thread.
Facebook integration - the user login/registration will allow the user to connect via facebook. (I may add twitter integration later), with any comments posted on a blog entry optionally being posted to their facebook wall.
I have been trying to look at http://www.wp-united.com, which supposedly integrates WP and PhpBB, but the site is down. I've also been looking at facebook plugins for wordpress, which would cpver the majority of my requirements. Integration with phpBB or some other forum could come later.
My question really is: has anyone had a go at doing this amount of integration/hacking of wordpress/phpbb and facebook before? Did it save time, or did you opt for a completely custom solution?
It's good not to re-invent the wheel, but in your case you are merging a heavyweight platform (Wordpress) with a library (CodeIgniter).
I really think there's little value in what you're doing. Here's why
Wordpress is more than just a blog; with plugins you can turn it into a full-fledge CMS. It's also very heavy.
Wordpress is coded as a stand-alone application. Incidentally, there are forum plugins for WordPress
My suggestion would be :
Use Wordpress, use the Pods plugin for routes and ORM functionality
Use CodeIgniter, find a lightweight blog plugin for CodeIgniter

Twitter List API (PHP)

I've recently used a php version of the twitter search API to display tweets on my website.
Now I'm looking to use an API to show tweets from a list I have created on twitter, but I can't seem to find any resources or examples.
Using List Widgets is an alternative. No need to write any PHP code. By overriding the CSS styles you can integrate the widget into your website theme.
http://twitter.com/about/resources/widgets/widget_list
PEAR has a nice twitter API package; http://pear.php.net/package/Services_Twitter/ - that's probably easier than writing your own adapter.

Categories