Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

134
Visualizações
Wordpress plug-in setting not being saved if another setting is turned off

This is my very first plug-in so I'm going with trial & error, I have two fields a checkbox and a textbox, when I check the checkbox I have javascript that enable/disable the relative textbox.

What I do:

  1. Check the checkbox -> The textbox is enabled by javascript
  2. I enter a value in the textbox and save the settings — all good
  3. I remove the check from the checkbox -> The textbox is disabled by javascript
  4. At this point if I save, it strips the value of the textbox

Here are the fields definitions:

        add_settings_field(
            'stwc_ft_oosn_0', // id
            'Enable', // title
            array( $this, 'stwc_ft_oosn_0_callback' ), // callback
            'settings-admin', // page
            'stwc_ft_oosn_section' // section
        );

        add_settings_field(
            'stwc_ft_oosn_notice_1', // id
            'Text', // title
            array( $this, 'stwc_ft_oosn_notice_1_callback' ), // callback
            'settings-admin', // page
            'stwc_ft_oosn_section' // section
        );

While for the javascript it is disabling by jQuery adding disabled to the textbox, when disabled I can still see the text inside the textbox when I save the settings.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda