Support » Plugin: NinjaFirewall (WP Edition) - Advanced Security » Question about NinjaFirewall 3.8.x and editing theme PHP files

  • tomdkat

    (@tomdkat)


    Hi! A year ago, I started this thread:

    https://wordpress.org/support/topic/ninjafirewall-3-6-and-wordpress-4-9-2/

    I wanted to find out if there’s anything that can be done, with recent versions of NinjaFirewall or WordPress 5.0.x to better deal with the problem of not being able to edit theme PHP files using the WordPress theme editor. Or is this something that will persist, until WordPress core changes how it handles editing theme PHP files?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author nintechnet

    (@nintechnet)

    Hi,

    Unfortunately, the bug ticket has never been answered : https://core.trac.wordpress.org/ticket/43358

    So I think I’ll have to try to solve the problem myself.
    Try this:
    1. Download the NinjaFirewall /lib/utils.php script.
    2. Right below the if (! defined( 'NFW_ENGINE_VERSION' ) ) { die( 'Forbidden' ); } line, enter this code:

    // ---------------------------------------------------------------------
    // Fix bug introduced in WordPress 4.9.2 (https://core.trac.wordpress.org/ticket/43358).
    
    add_filter( 'pre_http_request', 'nf_pre_http_request', 10, 3 );
    
    function nf_pre_http_request( $preempt, $r, $url ) {
    
       if ( strpos( $url, '/wp-admin/plugin-editor.php' ) !== false ) {
          @session_write_close();
       }
       return false;
    }
    
    // ---------------------------------------------------------------------
    

    This will catch the call to wp_remote_get and if the requested URL is /wp-admin/plugin-editor.php, it will close the current session.

    Thanks! I’ll give this a try.

    Tom

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