I made a plugin and trying to install on wordpress.org but Wordpress is giving me error message that ## Calling core loading files directly is incorrect.

I am using a cron file in my plugin.This cron can be set via CPanel also. That's why I have to include 'wp-config.php' and I am including this as

include '../../../wp-config.php';

My cron file path is something like this


Please help me how to include wp-config file so wordpress.org allow my plugin to install on wordpress.

thanks in advance!

  • Are you trying to install the plugin via cron? – WisdmLabs Sep 25 '14 at 6:49
  • @WisdmLabs no I am not installing plugin via cron.I am using cron to make some queries.This cron can be set in Cpanel for particular time in a day. – Bhuvnesh Gupta Sep 25 '14 at 6:55

I think that is the wrong way. What you might consider to to is to create an wp_schedule_event and then run http://www.abc.de/wp-cron.php per cPanel-Cron, that should work and will be a better way in the "idea" of WordPress.


Create an cron.php (or whatever you would like to call that file) in you plugin. Than from the main php file include that cron.php file.

if (wp_next_scheduled('myActionRunCron') === FALSE) {
    wp_schedule_event(time(), 'hourly', 'myActionRunCron');

And then register an Action-Handler to that Action myActionRunCron


And in the cron.php-File, place an function named myCronAction. Thats it.

function myCronAction() {
    // do some stuff

Than this Action will be run through WP each Hour. You can modify that by modify the wp_schedule_event-Call.

How to configure the Cronjob in cPanel could be found here on Hostgator

| improve this answer | |
  • can you please give an example how to do this.I mean a file which will run with wp_schedule_event and cpanel cron.Also I am already setting wp_schedule_event and in this function I have given the path of same file – Bhuvnesh Gupta Sep 25 '14 at 7:26
  • I will edit my upper answer – lippoliv Sep 25 '14 at 8:42
  • @BhuvneshGupta now I updated my answer, that should give you many ideas :) – lippoliv Sep 25 '14 at 8:48
  1. you should never try to include wp-config.php or any other of the loaders files from the plugin

  2. your plugin should never be accessed by a direct url bypassing the WP initialization process.

The way you need to write your plugin is to check if there is a specific parameter to the URL, and only if it exists your code will do its thing.

Now you can setup your cron to wget the the specially crafted URL and you are done.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.