H
H
hitakiri2016-01-13 19:53:16
PHP
hitakiri, 2016-01-13 19:53:16

How to add a script to WordPress exclusions?

There is a script processing zip-files. You want it to run on a request like:

zip-file/filename/27

I made a plugin that checks the url and launches the script:
$path=$_SERVER['REQUEST_URI'];
$zippPath = parse_url($path, PHP_URL_PATH);
$zippPath = substr($zippPath, 1);
list($zippPathCheker, $zippPathName, $zippPathNum) = preg_split('[/]', $zippPath);
if($zippPathCheker == 'zip-file' && is_numeric($zippPathNum)){
    include_once (plugin_dir_path( __FILE__ ).'/pl_zip.php');
}

The script itself was inserted into this plugin. It is activated in the admin panel normally and starts too (defines the link). But wp starts changing headers and tries to insert data from the plugin into the default template. Is it possible to make pl_zip.php run clean without wp intervening?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrew B., 2016-01-15
@hitakiri

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !^zip-file/ #here your URI and '!' is required...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

M
Maxim Kudryavtsev, 2016-01-13
@kumaxim

Create a zip folder in the root of WP . This is where you put your php script. In the same zip folder you create a .htaccess file with the content
Then you access the script itself as wp-example-site.org/zip/zip-file/filename/27
Of course, as a plugin, you will no longer see it in WP, so some settings from it, if you need them, will have to be pulled by hand.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question