I'm developing a Wordpress plugin to do a migration of data from a custom CMS.
Since the migration itself follows several steps and would take a while before being completed, I would like to have an admin page that would show the progress of backend script while it's importing the data.
I have read some articles online about such a communication between the backend and the client but there's nothing about the situation in which client and backend are inside the Wordpress framework (there are some constrains about setting the client properly).
Thank you,
Luca
In order to display the progress of a PHP process live, you will have to have the PHP script that is running update the state of a post that can be read from JavaScript such Angular over fixed intervals.
I would have the PHP create a post and store the process state using JSON, and have Angular using post and interval update the admin view.
Related
First, I am a Wordpress Noob. My company builds custom data dashboards. Our client wants to integrate our dashboard into Wordpress. They use plugins, mainly Gravity forms and WooCommerce, from which the dashboard needs to retrieve data.
The dashboard will be build as a custom page (HTML/JS/CSS) and we plan to served it as a Wordpress static item (like: https://qodeinteractive.com/magazine/add-custom-html-page-to-wordpress/).
Ideally, it would work like this:
the clients' user logs in into Wordpress.
Within the Wordpress environment the user can click a button to open our dashboard.
The dashboard fetches the data from Wordpress / a Wordpress API and displays it.
The complexity starts with the last step, how can we access the data from Wordpress/Gravity forms/WooCommerce. I would prefer it, if the user does not have to login separately into our dashboard, but that the credentials provided in Wordpress can be used.
There are API's available for Wordpress/Ggravity forms/WooCommerce, but I am unsure about the authentication part.
I found something about cookie authentication (https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/#cookie-authentication), but I am not sure if this would work or how this works. The information is related to PHP, while we will be using HTML/JS.
Are there other options available?
I know it is a broad question, but I hope to get some pointers to how to deal with this.
I have been exploring using Vue for wordpress frontend, and I came across so many different technologies, like Nuxt.js, Gridsome, VuePress, and they help to create sites into SPA, SSR, or static sites. I really like these ideas, because I want to move into modern frontends instead of using the WordPress default. So I am looking into headless WordPress.
After some research, I think I kind of like Gridsome with Wordpress, as Gridsome helps to build static site by compiling content from CMS and templates at build time.
So I have a very newbie question, CMS like wordpress gets updated everyday by users, to update pages, add new posts etc, does that mean you need to build the site every time people add some content to the CMS?
I'm going to build a sort of internal portal, with WordPress and I want to try out Vue, so with all these technologies out there, I am lost at what framework best suit my project with dynamic content.
Any suggestions or insights? Thanks.
So I have a very newbie question, CMS like wordpress gets updated everyday by > users, to update pages, add new posts etc, does that mean you need to build the > site every time people add some content to the CMS?
Yes that's the concept of a statically generated site.
Still it's a choice of how you design your application.
Normally when a new post is created there can be an event / webhook triggering a build job which would automatically build and deploy the page with the latest post.
Still you can have in your deployed application client side Vue components which call the API directly to retrieve data and display it. For example for the comments it could make sense to do this.
Netlify is a good example which has the whole static site generation eased up with a nice CI / CD which can be triggered automatically as soon as your site. They also have a CMS which works on top of markdown files. As soon as a changed / new markdown file is commited to the repository it triggers a build to deploy the latest version of the page.
I hope this helps.
Thanks and best regards,
ewatch
I am learning wordpress plugins and getting to know it fairly well.
now i think i need help doing small operation is fine but length operation how we do that. i guess AJAX or cron job
an example say i am trying to use content spinner api .so i have to send 100 post title and content to content spinner ,wait for response and update post title and content.
whats the best way to do that in wordpress plugin
Ajax where each post is sent to content spinner api and on result we update UI. please point good tutorial for that
or a cron job but i know wordpress cron job is limited
please please advise
If you do not want to keep the user locked until the API returns the result best option would be to use a cronjob that will run a PHP script which will update all your articles. Not necessarily Wordpress cronjob because that could cause delays if the site doesn't have any traffic, you could use a system cronjob.
With AJAX you will still lock the user, if the user closes the page the API call will not be finished and the title and content won't be updated.
Depends mostly on how the plugin is going to be used. If you want to spin the content on bulk articles (100 posts at once) go with cronjob, if you want to spin the content after the user has written the article do it with AJAX or hook your plugin on save_post action.
You may have seen WP plugins that allow guests to submit posts. Those submissions proceed to the WP posts area where the admin can edit/publish them.
I want to create a form like this that I can install on my (and other people's) computers, so they can fill out the form fields for a WP post, save offline, then send to my WP site when ready.
Can anyone tell me the steps involved, and, if there is a description for what type of thing this is, please let me know to aid my search.
I am learning code at present and want to learn while building tools.
Thanks
Hi hope I can give you some hints with this answer.
I don't know what programming language you would like to use, but for the communication with your Wordpress blog you could use the WP API to create a post over REST API. It offers a API to create and edit your Wordpress Posts over HTTP.
Your programm just have to check if an connection is possible and then execute the API calls.
You could use an database to store all created post and then call the Create Post Task with the POST Method over HTTP for each post saved offline.
When the creation was successful you could update your offline database, so that the post is marked as already created.
I run a website where I have both Wordpress and Cakephp installed in the same domain.
Cakephp is the administrative backend to maintain and create business listings (like the yellow pages).
Wordpress is the front end for the public website.
I'm creating custom Wordpress templates to display the business listings from Cakephp, but am not sure how Wordpress is going to retrieve data from Cakephp.
I already have a bunch of Controller Actions that return json array with data that I would like to call from Wordpress. I don't want to duplicate in Wordpress data retrieval code that I've already written in Cakephp. But i'm not sure how in Wordpres would i make calls to these Cakephp Controller / Actions.
What is the recommended / best way to have Wordpress retrieve data from the Cakephp backend given at they are on the same domain? What other options do i have?
What is the recommended / best way to have Wordpress retrieve data
from the Cakephp backend given at they are on the same domain? What
other options do i have?
Access the DB directly, I'm not sure how to do that with Wordpress fugly API and code, but I'm pretty sure you can instantiate a new DB object with a connection to the CakePHP apps database. The WP API documentation will tell you how to do it I guess, if not it sucks more than I thought.
An alternative would be to expose the data via a RESTful service and consume it from Wordpress. If you return JSON you could even simply use a JS widget on a WP page to retrieve and render the data with pure JS.
As burzum suggested you have 2 real options.
WordPress does have a class for interacting with a DB called WPDB and will give you access to a few ways of querying the data in your CakePHP app. WordPress WPDB Class. It is by no means perfect but will do the job.
However you much better creating a custom WordPress plugin to parse and format the JSON as burzum suggested interacting via your own API. You could then if needed make this a 2 way communication allowing your WordPress install to make changes as necessary to yoru Cake app.