wp-activators / wordfence-activator

Wordfence Security Plugin Activator
45 stars 17 forks source link

Would you please explain this code? #4

Open bisnukundu opened 10 months ago

bisnukundu commented 10 months ago

'download_file'                => function ( $url, $file_path ) {
        $contents = file_get_contents( $url );
        if ( $contents ) {
            put_content:
            $put_contents = file_put_contents( $file_path, $contents );
            if ( $put_contents === false ) {
                unlink( $file_path );

                return false;
            }
        } else {
            $res = wp_remote_get( $url );
            if ( ! is_wp_error( $res ) && ( $res['response']['code'] == 200 ) ) {
                $contents = $res['body'];
                goto put_content;
            } else {
                return false;
            }
        }

        return true;
    },```
zerofluence commented 10 months ago

@mohamedhk2 I'm also curious to know about the function of the code above.

bisnukundu commented 10 months ago

image @mohamedhk2 This message i can't see here now, i don't know why and who deleted it. Would you please explain this?

We are talking about Wordfence, not Wp Cerber Security, Why WP Cerber Security deletes the Patcher.php since i am not using that plugin? I checked some activator plugins of yours where this download_file is common.

I have deleted this download_file function and it's still working. so why do i need this function? what is the purpose of this function? would you please explain?

faresmezrag commented 5 months ago

Can you explain how and where to upload the three files (main.php, functions.php, index.php ) for activation Wordfence plugin?

Thankx