• Resolved gregnowak

    (@gregnowak)


    Hello!

    I can see the wordfence API documentation: https://www.wordfence.com/help/advanced/wordfence-api/

    It has the function: wordfence::importSettings($token)

    If I make a php script “test.php” server side like this:

    <?php
    require_once 'wordfenceConstants.php';
    require_once 'wordfenceClass.php';
    
    wordfence::importSettings('MY_SECRET_TOKEN')
    
    ?>

    Then I get errors, any hints, tips or tricks? Thanks!:

    php test.php 
    PHP Fatal error:  Uncaught Error: Call to undefined function wp_cache_get() in /home/www/example.com/wp-content/plugins/wordfence/lib/wfConfig.php:285
    Stack trace:
    #0 /home/www/example.com/wp-content/plugins/wordfence/lib/wfConfig.php(368): wfConfig::loadAllOptions()
    #1 /home/www/example.com/wp-content/plugins/wordfence/lib/wfConfig.php(520): wfConfig::hasCachedOption()
    #2 /home/www/example.com/wp-content/plugins/wordfence/lib/wfCredentialsController.php(12): wfConfig::get()
    #3 /home/www/example.com/wp-content/plugins/wordfence/lib/wfCredentialsController.php(16): wfCredentialsController::allowLegacy2FA()
    #4 /home/www/example.com/wp-content/plugins/wordfence/lib/wordfenceClass.php(48): wfCredentialsController::useLegacy2FA()
    #5 /home/www/example.com/wp-content/plugins/wordfence/lib/test.php(3): require_once('/home/www/example...')
    #6 {main}
      thrown in /home/www/example.com/wp-content/plugins/wordfence/lib/wfConfig.php on line 285
Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter gregnowak

    (@gregnowak)

    Or is the wordfence-api only available for the paid version of the wordfence plugin?

    Plugin Support wfpeter

    (@wfpeter)

    Hi @gregnowak, thanks for getting in touch.

    The missing function wp_cache_get() can be fixed by also requiring wp-load.php at the stop of your page code.

    Thanks,

    Peter.

    Thread Starter gregnowak

    (@gregnowak)

    Hi @wfpeter!

    Thank you very much for the info about wp-load.php, this did the trick and import function works!

    Is there anywhere I can find this information in the documentation?

    Thanks again.

    /Greg

    Plugin Support wfpeter

    (@wfpeter)

    Hi @gregnowak,

    I have notified the development team that this may need to be made clearer. Thanks for getting back to me and I’m glad it’s working now for you.

    Peter.

    Thread Starter gregnowak

    (@gregnowak)

    Hi @wfpeter!

    Great, thank you!

    /Greg

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Import Wordfence Settings from php code’ is closed to new replies.