Support » Plugin: WP Data Access » ERRO! (Solução Provisória) Cannot redeclare submit_button()

  • Resolved nmarlon

    (@nmarlon)


    ORIGINAL: Aparece para mim o erro: Fatal error: Cannot redeclare submit_button() (previously declared in /home/storage/2/c6/86/meusite/public_html/wp-content/plugins/wp-data-access/wp-data-access-diehard.php:50) in /home/storage/2/c6/86/meusite/public_html/wp-admin/includes/template.php on line 2342

    Eu consegui consertar substituindo a linha 2342 no arquivo: /meusite/public_html/wp-admin/includes/template.php que contém:

    function get_submit_button(…)
    {
    …/*O código da função*/

    }

    substituí por (coloquei um simples if):

    if ( !function_exists( ‘submit_button’ ) ) {function get_submit_button(…)
    {
    …/*O código da função*/
    }
    }

    Mas isso é algo PROVISÓRIO. Eu acho, que o desenvolvedor precisa mudar o nome do submit_button pra alguma outra coisa que não afete o próprio sistema padrão do WordPress.

    GOOGLE TRANSLATE:
    The error appears to me: Fatal error: Cannot redeclare submit_button () (previously declared in / home / storage / 2 / c6 / 86 / meuite / public_html / wp-content / plugins / wp-data-access / wp-data-access -diehard.php: 50) in /home/storage/2/c6/86/meusite/public_html/wp-admin/includes/template.php on line 2342

    I managed to fix it by replacing line 2342 in the file: /meusite/public_html/wp-admin/includes/template.php which contains:

      function get_submit_button (…)
        {
        … / * The function code * /

        }

    replaced by (I put a simple if):

    if (! function_exists (‘submit_button’)) {function get_submit_button (…)
       {
       … / * The function code * /
       }
    }

    But this is PROVISIONAL. I think, the developer needs to change the name of submit_button to something else that doesn’t affect the standard WordPress system itself.

    • This topic was modified 4 months ago by nmarlon. Reason: Faltou explicar o título melhor
Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Author Peter Schulz

    (@peterschulznl)

    Welcome Marlon! 🙂

    Wich version of WP Data Access are you using? This is an old message which was fixed in version 2.7.2. If you update to version 3.1.1 (actual release) you’ll see that we fixed it the same way! 😉

    Can you please update to version and let me know if this solves your problem?

    Thanks,
    Peter

    nmarlon

    (@nmarlon)

    I Install “WP Data Access 3.1.1” still not working.

    Plugin Author Peter Schulz

    (@peterschulznl)

    Strange! What message do you see? Can you add a screenshot?

    Thanks,
    Peter

    nmarlon

    (@nmarlon)

    nmarlon

    (@nmarlon)

    ORIGINAL: Eu consegui consertar sem dar erro na página de plugins (como eu tinha editado o template.php padrão do wordpress, a página de plugins do wordpress não abria), ao invés de mudar o submit_button no template.php, Eu fiz isso:

    1. Baixei a pasta do plugin /public_html/wp-content/plugins/wp-data-access toda no meu PC
    2. abri essa pasta no Sublime Text 3.
    3. Apertei Ctrl+Shift+F para pesquisar por referências do “submit_button” em TODOS os arquivos
    4. Substituí todos os “submit_button” por “submit_button_wpda” (No lugar de _wpda pode ser qualquer outro nome)
    Resumo do procedimento 3 e 4
    5. Enviei a pasta do plugin wp-data-access de volta para o servidor do meu site wordpress. Substituindo apenas os arquivos de tamanho diferentes.

    Agora tudo funciona normalmente

    Google Translate: I managed to fix the plug-ins page without error (as I had edited the standard wordpress template.php, there was no wordpress plug-in page), when I started changing or sending a button in the template.php , I made it:

    1. Download the plugin folder / public_html / wp-content / plugins / wp-data-access all on my PC
    2. I opened this folder in Sublime Text 3.
    3. Press Ctrl + Shift + F to use for “submit_button” references in ALL files
    4. Replace all “submit_button” with “submit_button_wpda” (no place in _wpda can be any other name)
    Summary of procedure 3 and 4
    5. Submit a wp-data-access plugin back to my wordpress website server. Replacing only files of different size.

    Now everything works normally

    • This reply was modified 4 months ago by nmarlon. Reason: The translated part
    nmarlon

    (@nmarlon)

    Mas não tinha visto que deu erro no http:/…/wp-admin/admin.php?page=wpda ou seja, não conseguia abrir nenhuma das páginas de edição do plugin WP Data Access no wordpress. Eu conseguia usar o Elementor, mas não criar uma nova tabela no WP-Data-Access do wordpress. Dava erro. Então, ao invés de substituir TODOS os “submit_button”, substituí só os que estavam dando erro, cada vez que eu substituía um, mostrava outro lugar que precisava da variável, assim fui descobrindo qual precisava do submit_button do template e qual usava à do próprio plugin. Dessa tudo mesmo está funcionando em normalmente. Cada uma das páginas, o Elementor e o plugin nas páginas funciona.

    O que eu alterei foi o arquivo:
    plugins\wp-data-access\wp-data-access-diehard.php – Line 49 e 50: “submit_button” para “submit_button2”
    -Line 57 e 58: “get_submit_button” para “get_submit_button2”

    Plugin Author Peter Schulz

    (@peterschulznl)

    Hi Marlon,

    Thank you for your feedback!

    The plugin uses class WP_List_Table in the front-end. That class needs a couple of functions that are only declared in the back-end. I know that some other developers are using these functions in the front-end as well. In WP Data Access I test if these functions are already declared. If so, I don’t declare them which prevents this error. But this prevents the error only if these functions have been declared before the WP Data Access is executed. This does not work for code executed after the WP Data Access code.

    Maybe you can find the source of that other declaration and ask that developer to put an if function_exists() around his declaration as well. That will fix it.

    I know there are some themes and plugins using the same functions. Which theme are you using? Have you tried another theme? It could also be another plugin. Maybe you find out which one and inform the developer.

    Please let me know if this does not work. Maybe I can find another solutions…

    Best regards,
    Peter

    Eu desconheço o motivo de if function_exists() não está funcionando, parece que ele não identifica o submit_button. Eu mudei no wp-data-access-diehard.php para if ( ! function_exists( 'submit_button2' ) ) { , function submit_button2( , if ( ! function_exists( 'get_submit_button2' ) ) { e function get_submit_button2( . depois começou a ter erro nas páginas do plugin no admin do wordpress, então coloquei isso:

    if (preg_match('/wpda/',$_GET['page'])){
        submit_button( $text, '', '', false, array( 'id' => 'search-submit' ) ); 
    }else{
        submit_button2( $text, '', '', false, array( 'id' => 'search-submit' ) );
    }
    

    E assim tem funcionado tudo perfeitamente até agora. Muitíssimo obrigado pela atenção e pelo ótimo plugin, tem atendido às minhas necessidades.

    Google Translated: I don’t know why if function_exists () isn’t working, it looks like it does not identify submit_button. I changed in wp-data-access-diehard.php to if (! Function_exists ('submit_button2')) {, function submit_button2 (, if (! Function_exists ('get_submit_button2')) { and function get_submit_button2 (. then there was an error in the plugin pages in the wordpress admin, so I put this:

    if (preg_match('/wpda/',$_GET['page'])){
        submit_button( $text, '', '', false, array( 'id' => 'search-submit' ) ); 
    }else{
        submit_button2( $text, '', '', false, array( 'id' => 'search-submit' ) );
    }
    

    And so everything has worked perfectly so far. Thank you very much for your attention and for the great plugin, it has met my needs.

    • This reply was modified 3 months, 3 weeks ago by nmarlon. Reason: The translator change the code
    Plugin Author Peter Schulz

    (@peterschulznl)

    Great you solved it! 😉 Hope you don’t have to edit your file on every update…

    Thanks,
    Peter

    Dear I’m facing the same issue,

    where did you place the code

    if (preg_match('/wpda/',$_GET['page'])){
        submit_button( $text, '', '', false, array( 'id' => 'search-submit' ) ); 
    }else{
        submit_button2( $text, '', '', false, array( 'id' => 'search-submit' ) );
    }

    you can ignore my above comment 🙂

    amgrays

    (@amgrays)

    I’m getting the same error – using Astra theme.

    Impressive plugin BTW 🙂

    Plugin Author Peter Schulz

    (@peterschulznl)

    Hi @amgrays,

    Welcome to the forum! 🙂 And thanks for the compliment.

    Can you switch to another thema? Editing the plugin or theme as @nmarlon proposed works as well, but you need to re-edit on every update.

    Best regards,
    Peter

    amgrays

    (@amgrays)

    Thanks – not really a feasible option to change the theme unfortunately. We have already invested quite a bit of time in learning/configuring website and also money for the Pro version. Astra hit 1 million installs the other day so apparently is widely used. I did wonder whether it might be another plugin – I have Supsystic Tables as well as a bunch of other plugins. I did try it on a page without anything else on it so does that rule out other plugins?

    Plugin Author Peter Schulz

    (@peterschulznl)

    Hi @amgrays,

    WP Data Access uses WordPress class WP_List_Table on web pages, and that class uses the submit_button function. Plugins that do not use class WP_List_Table do not necessarily run into this error. Do you need to update your data? If not, you can use the Data Publisher, which does not rely on class WP_List_Table and runs which your theme. You just cannot edit your table data with the Data Publisher as publications are read-only. Does that help?

    Thanks,
    Peter

Viewing 15 replies - 1 through 15 (of 16 total)
  • You must be logged in to reply to this topic.