i need to create a plugin that allows me to select any button or any part of the website and add extra css to it ,i have manages to consumer rest api within wp ,add menus and submit forms but i have no idea how to accomplish this task ,i would appreciate any suggestion thanks

  • Why can't you just add CSS using the Additional CSS section of the customiser? – Jacob Peattie Jan 28 '19 at 2:51
  • i don't want to add css classes,insted i need to add exta css to specific html button/ a tags and so on – Jawhar Jarrar Jan 28 '19 at 12:41
  • Why can’t you do that with regular CSS? – Jacob Peattie Jan 28 '19 at 13:14
  • sorry my bad i didn't explain the issue well , i don't need to add classes to css files but i need to add specfic css classes to tags regardless of their exsitance in a css file , so the task is to change the the html generated by wp and to trigger that i need to click on an item (button,rating....) and a css class to it – Jawhar Jarrar Jan 28 '19 at 13:24

I think it's worth studying how other plugins work, for example: Visual Composer.

The logic that came into my head, is to pick the element selector clicked with jQuery, and work on it. Read this that may help you: https://stackoverflow.com/questions/5706837/get-unique-selector-of-element-in-jquery

Following this logic, if each page element has the same class, it will be easier to work with

  • thanks Gabriel, studied various plugins,they only allow users to edit elements created with the same plugin so visual composer for instance won't regognize elements created with beaver – Jawhar Jarrar Jan 27 '19 at 16:32
  • @JawharJarrar I found this plugin gist.github.com/saarmstrong/5e8d2ac45dfd76a2574f In thesis this: $ ("*"). click (function () { var path = $ ('this) .getPath (); console.log (path); }); It should return something like: // html> body> div # bar> ul # abc.def.ghi> li # foo " Ai you just work css ... But I did not test, if it works, let me know! I think it can help with my projects too. – Gabriel Henrique Jan 27 '19 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.