spatie / wordpress-ray

Debug with Ray to fix problems faster in WordPress apps
https://myray.app
MIT License
73 stars 14 forks source link

Installing on Wordpress #21

Closed stanwarri closed 3 years ago

stanwarri commented 3 years ago

Great product.

So I have a wordpress plugin I'm working on, and no matter where I can ray() on the project it doesn't show any on the desktop.

Are there other requirement to get this working apart from adding ray.php config in the root of the project.

I'm on Mac and my website is serve using Valet

freekmurze commented 3 years ago

Thanks! Ray is disabled by default in production environments. Maybe your WordPress installation thinks it's running in production.

To manually enable ray, call ray()->enable().

jeffreyvr commented 3 years ago

@stanwarri I'm using Ray within WordPress on Valet as well, but did not need to create the ray.php config file for it to work. What do you have in your ray.php file, and have you tried running it without?

Also, make sure you are calling the function after the plugins_loaded hook is fired. Otherwise the function might not be available yet. But I guess you would have seen an error if that was the issue.

add_action( 'init', function() {
    ray( 'test' );
});

Edit:

This issue might be related to: https://github.com/spatie/wordpress-ray/issues/22

stanwarri commented 3 years ago

@jeffreyvr Thanks for the update. However, I'm getting call to undefined function ray() anywhere I call ray() Here is my sample code

function woocommerce_app_init() {

    require_once dirname( __FILE__ ) . '/includes/class-frontend.php';

}
add_action('plugins_loaded', 'woocommerce_app_init', 99);

Now anywhere I call ray() in class-frontend.php file throughs the undefined function error.

jeffreyvr commented 3 years ago

@stanwarri Just to be sure, can you run my example code that I posted earlier?

Also, are you on the latest version of the plugin (1.0.3)?

stanwarri commented 3 years ago

It's working now. I had to delete the ray.php file I added to the root directory of the project.