codecreative Posted October 2, 2013 Share Posted October 2, 2013 Hi I have a script that is executed when wp-cron is executed, which is basically whenever my website loads. I tried placing //Disable internal Wp-Cron function define('DISABLE_WP_CRON', true); At the top and it still runs my script. I also downloaded, installed and ran this plugin called cron view which lets me see what is in the wp crons scheduled tasks http://wordpress.org/plugins/cron-view/ The results were Next due (GMT/UTC) Schedule Hook Arguments Oct 3, 2013 @ 1:54 (1380765280) Twice Daily wp_version_check Oct 3, 2013 @ 3:40 (1380771621) Twice Daily wprc_schedule_update_plugins Oct 3, 2013 @ 3:40 (1380771621) Twice Daily wprc_schedule_update_themes Oct 3, 2013 @ 8:30 (1380789001) Every 12 hours check_plugin_updates-newroyalslider Oct 3, 2013 @ 13:54 (1380808485) Once Daily wp_scheduled_delete Oct 3, 2013 @ 14:01 (1380808908) Once Daily wp_scheduled_auto_draft_delete Okay so the above to findings made me conclude that wp-cron is being used to call my script directly and doesn't in actual fact exist in the scheduld tasks. Okay so far so good. My next step is, how do I stop the script being called from wp-cron? Can anyone help The contents of my wp-cron file is can be seen at http://pastebin.com/uVfyAnNQ Anyone that could kindly give me a pointer on this would be really helpful to me and I would appreciate your help quite a lot, as well as helping me self educate. Thanks in advance Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted October 2, 2013 Share Posted October 2, 2013 there's no guarantee that the person who wrote this didn't just put in his own call to your script into one of the web site files. since it appears that it is being included (just a guess) you can use debug_backtrace() in the file to get information about how it is being executed. you could simply append the debug_backtrace() output to a log file of your making, using file_put_contents() with the FILE_APPEND attribute. Quote Link to comment Share on other sites More sharing options...
codecreative Posted October 3, 2013 Author Share Posted October 3, 2013 Hi could you if you don't mind give me a small snipet of code showing me this? Its a very good point you raise, it could be called from any file. I know wp-cron is one of the files that does. But when I call wp-cron from scheduled tasks it executes well. So there could be another rogue file calling it. This sounds like a great solution you've suggested I'm not too sure of the implementation Quote Link to comment Share on other sites More sharing options...
codecreative Posted October 3, 2013 Author Share Posted October 3, 2013 Would this do the trick? $file = "mydebugfile.txt"; $data = debug_backtrace(); file_put_contents($file, $data, FILE_APPEND | LOCK_EX); Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted October 3, 2013 Share Posted October 3, 2013 debug_backtrace returns an array, you would need to use print_r() with the second parameter set to true to get the output returned as a string that you could write to a file - file_put_contents($file,print_r($data,true),FILE_APPEND | LOCK_EX); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.