.htaccess - wordpress plugin access file directly in browser -
I am trying to access a plugin file directly in the browser, so I can run the cron.
When I go to the right URL, I can not find a page.
By default WordPress prevents you from accessing it directly? Does it probably have something to do with .htaccess, or should I be able to see it directly?
I'm trying to use the file resides (just an example):
http://mywebsite.com/wp-content/plugins/ Askimet / askimet.php Any help would be appreciated!
WordPress can not stop you from accessing PHP files directly. However, PHP files usually do themselves. It basically ensures that WordPress is loaded.
In your example, the following akismet.php
// make sure we do not expose any information that may be added directly (! Function_exists ( 'add_action ')) {Echo' hi there! I'm just a plugin, not so much when I'm called directly. '; Go out; } You probably want to do want to load WordPress for your plugin, though. Instead, you should know your plugins to create a URL that you can locate and intercept. For example, the page's example.org/?my-plugin-action Go to init or template_redirect ) And if it is found, call your PHP script, then exit; Call; So WordPress does not try to load a page. function my_plugin_action () {if (! Isset ($ _gET [ 'my-plugin-action']) return; echo "Run cron job on 'Echo.'; Exit;} Add_action ( 'init', 'my_plugin_action'); to recap: straight do not call your plugin to create a URL that displays your content, then displays the default page by WordPress Exit the script before trying it.
Comments
Post a Comment