WPIntell

Source evidence

Working with plugin debug

WP PHP Console · support · 2019-06-02T16:18:00+00:00

mixedsentiment
highseverity
0.94relevance
10replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

6 / 35 rows with source links

17.1% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

29 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
viter-z-bayraku resolved
Sorry, but FAQ section not helpful with not registered PC class problem inside new plugins. And I still can’t understand, how enable your cool plugin inside plugins development. Examples inside your answers in this topic https://wordpress.org/support/topic/support-for-plugin-debug/ not helped me. Thank you for help. This topic was modified 6 years, 12 months ago by viter-z-bayraku . This topic was modified 6 years, 12 months ago by viter-z-bayraku . This topic was modified 6 years, 12 months ago by viter-z-bayraku . There’s a FAQ. The PC class is used to print variables in your Chrome JavaScript console. For example <?php $foo = 'bar'; add_action( 'plugins_loaded', function () use ( $foo ) { if ( ! class_exists( 'PC', false ) ) { PhpConsole\Helper::register(); } PC::my_tag( $foo ); } ); This will output bar in your Chrome console. This reply was modified 6 years, 12 months ago by Fulvio Notarstefano . Thank you, Fulvio. I understand it. But this class working only in theme templates. But I can not understand, how it integrate for debugging new plugin.. In other plugin I have unavailable PC class error.. This reply was modified 6 years, 12 months ago by viter-z-bayraku . Are you able to use the other functions of the plugin, like the console terminal or the Google Chrome JavaScript console for variable and error dumping? I want to use your plugin to debug errors from other new plugin in Google Chrome Development Tool (Javascript Console) PC::debug("test"); inside this plugin returning Fatal error: Uncaught Error: Class 'PC' not found I’m sorry. Your code in previous messages is helpful. Thank you! One question. Can be your code used as a public function inside another class? Like: public function debug($foo){ add_action( 'plugins_loaded', function () use ( $foo ) { if ( ! class_exists( 'PC', false ) ) { PhpConsole\Helper::register(); } PC::my_tag( $foo ); } ); } I certainly believe so. Mind that this is intended for temporary debugging and you shouldn’t roll PHP Console on a production site. If you need to debug some variable in WordPress, another way of doing it is to store the data you want to output in the console in a WordPress option, e.g. update_option( 'my_test', $data ); Then in the console you’d do return get_option( 'my_test' ); from the terminal and check results. It’s only for temporary debugging. I’m looking for quick solution for plugin development, based on php classes. That is helpful for me.. Thank you 🙂 add_action( 'plugins_loaded', array( 'Test_Class', 'init' )); class Test_Class { public static function init() { $class = __CLASS__; new $class; } public function __construct() { Test_Class::my_debug(555777); //construct what you see fit here... } public function my_debug($foo) { if ( ! class_exists( 'PC', false ) ) { PhpConsole\Helper::register(); } PC::my_tag($foo); } //etc... }

Comments

10 shown
Fulvio Notarstefano 2019-06-03T03:25:00+00:00

There’s a FAQ. The PC class is used to print variables in your Chrome JavaScript console. For example <?php $foo = 'bar'; add_action( 'plugins_loaded', function () use ( $foo ) { if ( ! class_exists( 'PC', false ) ) { PhpConsole\Helper::register(); } PC::my_tag( $foo ); } ); This will output bar in your Chrome console. This reply was modified 6 years, 12 months ago by Fulvio Notarstefano .

viter-z-bayraku 2019-06-03T06:21:00+00:00

Thank you, Fulvio. I understand it. But this class working only in theme templates. But I can not understand, how it integrate for debugging new plugin.. In other plugin I have unavailable PC class error.. This reply was modified 6 years, 12 months ago by viter-z-bayraku .

Fulvio Notarstefano 2019-06-03T06:22:00+00:00

Are you able to use the other functions of the plugin, like the console terminal or the Google Chrome JavaScript console for variable and error dumping?

viter-z-bayraku 2019-06-03T06:26:00+00:00

I want to use your plugin to debug errors from other new plugin in Google Chrome Development Tool (Javascript Console)

viter-z-bayraku 2019-06-03T06:27:00+00:00

PC::debug("test"); inside this plugin returning Fatal error: Uncaught Error: Class 'PC' not found

viter-z-bayraku 2019-06-03T06:29:00+00:00

I’m sorry. Your code in previous messages is helpful. Thank you!

viter-z-bayraku 2019-06-03T06:39:00+00:00

One question. Can be your code used as a public function inside another class? Like: public function debug($foo){ add_action( 'plugins_loaded', function () use ( $foo ) { if ( ! class_exists( 'PC', false ) ) { PhpConsole\Helper::register(); } PC::my_tag( $foo ); } ); }

Fulvio Notarstefano 2019-06-03T07:13:00+00:00

I certainly believe so. Mind that this is intended for temporary debugging and you shouldn’t roll PHP Console on a production site. If you need to debug some variable in WordPress, another way of doing it is to store the data you want to output in the console in a WordPress option, e.g. update_option( 'my_test', $data ); Then in the console you’d do return get_option( 'my_test' ); from the terminal and check results.

viter-z-bayraku 2019-06-03T07:16:00+00:00

It’s only for temporary debugging. I’m looking for quick solution for plugin development, based on php classes.

viter-z-bayraku 2019-06-03T07:33:00+00:00

That is helpful for me.. Thank you 🙂 add_action( 'plugins_loaded', array( 'Test_Class', 'init' )); class Test_Class { public static function init() { $class = __CLASS__; new $class; } public function __construct() { Test_Class::my_debug(555777); //construct what you see fit here... } public function my_debug($foo) { if ( ! class_exists( 'PC', false ) ) { PhpConsole\Helper::register(); } PC::my_tag($foo); } //etc... }