Skip Navigation

[Resuelto] ability to add cs and js for the backend ?

This support ticket is created hace 7 años, 2 meses. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Este tema contiene 7 respuestas, tiene 2 mensajes.

Última actualización por Beda hace 7 años, 2 meses.

Asistido por: Beda.

Autor
Mensajes
#572395

Hi, currently we can add js and css from the front end . BUT this only used for front view display.
When editing the post, the js is not applied. this cause big confusion.

an example here:
i added js to check/auto select related checkboxes in the custom search form, i would like to use it at the backend as well but i cant .
is there any way of doing this ?

thanks.

#572429

I am not sure I can follow.

1. CSS and JS you add to a view, will be used solely when that View is seen in the FrontEnd.
2. The same is valid for Content Templates.
3. When you use Layouts, you can use the Layouts JS/CSS menu, where the code will be applied everywhere where a layout is used.
4. You cannot display Views or Content Templates in the backend, hence bringing it's CSS/JS to the backend is obsolete.
5. You can add Custom CSS to the Edit MetaBoxes of Types Fields, in the backend, but this is a deprecated method.
Nonetheless you can still do it by following this DOC:
https://toolset.com/documentation/user-guides/css-styling-for-fields/

Generally in WordPress CSS and JS is intended to be added in the Front End.

#572441

Hi Beda.

basially i have a simple script that auto select related checkboxes [ manually coded] . its for custom search purpose.
i am looking any way that i could have this script action running at the backend too so that its sync both way .

example custom field

Fruits -
- apple
-banana

Cars
-Lexus
-BMw

my script does this. once selected "fruits", apple and banana got selected - this is for search form.

i would like to have the same at the post edit at the both front end and backend,

pls let me know if you need more informations.

some links :https://stackoverflow.com/questions/3326967/how-to-add-custom-javascript-to-wordpress-admin

#572448

I understand.

Then you need to pass your Custom Code to the admin.
As in the StackOverflow you shared Tim explains, you need to use admin_enqueue_scripts().

This hook allows you to add your Custom Code to the admin - you need to do that in your Theme Files, this is not related to Toolset.

In the FrontEnd, I assume you will use Toolset CRED - hence you can add the script to the JS section of your CRED forms.

Please let me know if you have more doubts?

#573250

OK. thanks. ill try the admin enque and feedback soon.

#573577

Ok, thank you.

#574328
#574387

Thank you for sharing those.

Yes, this is the correct API to follow when you want to enqueue things in the backend.

But, this is not related to Toolset, per se, as you cannot enqueue the Content Template or Layouts CSS in the backend, natively.
Those are intended to be in the front end.

I do suggest that you create a separate sheet with the CSS and enqueue it from the Theme, as example.