Answer the question
In order to leave comments, you need to log in
How to create your own widget for someone else's site?
There is a site on wordpress, each user can add his company to the site, are there plugins or other methods so that the user can generate a code for the widget and insert it on the site, but you can do without a generator, but with ready-made code with a link to the company (you can insert a ready-made code on the company's page).
Answer the question
In order to leave comments, you need to log in
There are several options. I do not recommend frames because of the difficulties of placing internal content as your own.
For example, you can write a js file that the user inserts into the right place. When you run the script, first of all, we generate a temporary block in which we will stick the widget. God forbid, you will add a style tag (with styles like a , div, etc.) or, God forbid, include such a style file of your own. In short, be careful here. This can easily ruin the layout. Then we get a domain or some key (for example, you can make a script tag in the above with the definition of the id variable of the desired user).
Based on this, we send ourselves a cross-domain request (it is advisable to use native tools, because not everyone has ajax for themselves). The server will actually have 2 requests:
1) through the option method (if I'm not mistaken). Only the get data and where the request comes from will be transferred. In response, the browser waits for PERMISSION to send a second request. Otherwise, the request will throw an error.
2) already through the desired method with a full palette of data (I mean post, cookies, etc.). Here we already generate the desired answer (you can even spit html right away) and send it.
Here, on the basis of the necessary information, we assign everything and that's it.
It seems to have painted a very solid part. I have not worked with wp, but I do not think that there will be additional difficulties. At least I can easily do this.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question