Easy code troubleshooting in wordpressPrint WordPress template filename(s) for debuggingDebug 500 Internal...

Why does the author believe that the central mass that gas cloud HCN-0.009-0.044 orbits is smaller than our solar system?

What is a term for a function that when called repeatedly, has the same effect as calling once?

Make me a metasequence

Whom do I have to contact for a ticket refund in case of denied boarding (in the EU)?

"Murder!" The knight said

What to do when being responsible for data protection in your lab, yet advice is ignored?

It took me a lot of time to make this, pls like. (YouTube Comments #1)

What am I? I am in theaters and computer programs

Hacker Rank: Array left rotation

If nine coins are tossed, what is the probability that the number of heads is even?

How can I be pwned if I'm not registered on that site?

Does music exist in Panem? And if so, what kinds of music?

Easy code troubleshooting in wordpress

How to speed up a process

Can you use a beast's innate abilities while polymorphed?

How do I implement simple JS code to deploy a compiled smart contract to ganache-cli?

When was drinking water recognized as crucial in marathon running?

Can chords be played on the flute?

How do I construct an nxn matrix?

Why does Starman/Roadster have radial acceleration?

I am on the US no-fly list. What can I do in order to be allowed on flights which go through US airspace?

Pure Functions: Does "No Side Effects" Imply "Always Same Output, Given Same Input"?

Equivalent to "source" in OpenBSD?

How can atoms be electrically neutral when there is a difference in the positions of the charges?



Easy code troubleshooting in wordpress


Print WordPress template filename(s) for debuggingDebug 500 Internal Server Error on WordPress blogTroubleshooting white screen when editing specific postsHow to troubleshoot WordPress issues?How to debug a unit test for a WordPress plugin, which uses wordpress-test?WordPress Ajax ProblemsWordpress + Buddpyress - troubleshooting server overloadingIs it possible to display the admin bar while in the Theme Customizer?Always keep a parameter in URL?Finding which functions were called













1















Is there an easy and standard way to debug our code in wordpress plugins?
I want to print some variables in a function that runs when a certain things happen.
Is there a wordpress way to save this in a file or at least see it?










share|improve this question



























    1















    Is there an easy and standard way to debug our code in wordpress plugins?
    I want to print some variables in a function that runs when a certain things happen.
    Is there a wordpress way to save this in a file or at least see it?










    share|improve this question

























      1












      1








      1


      1






      Is there an easy and standard way to debug our code in wordpress plugins?
      I want to print some variables in a function that runs when a certain things happen.
      Is there a wordpress way to save this in a file or at least see it?










      share|improve this question














      Is there an easy and standard way to debug our code in wordpress plugins?
      I want to print some variables in a function that runs when a certain things happen.
      Is there a wordpress way to save this in a file or at least see it?







      debug troubleshooting






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 2 hours ago









      AmiritionAmirition

      548




      548






















          3 Answers
          3






          active

          oldest

          votes


















          1














          Just start with the following definitions in your config.php file:



          define('WP_DEBUG', true);
          define('WP_DEBUG_LOG', true);
          define('SCRIPT_DEBUG', true);
          define('SAVEQUERIES', true);


          The first one sets your system into debug mode, the second one writes every notice into a log file saved into your wp-content directory. Script debug enables WordPress to use the uncompressed CSS and JS files (Maybe also interesting for writing Plugins). And Savequeries writes HTML-Comments at the bottom of the rendered HTML Output and will be used by Plugins I suggest you next.



          See the WordPress Plugin Directory for Debug Bar and extensions. There are a lot and there's a great chance that some of them are providing exactly what you need.



          If nothing helps you can write everytime



          print_r( $var );
          die();


          and look into the HTML sourcecode.






          share|improve this answer































            1














            Unfortunately there isn't really a standard developer logging API in WordPress. If you want to output your own data to a debug file (to prevent "headers already sent" errors) then you can simply use the standard PHP error_log function. Something simple like this will record the variable $data to the file debug.log in your plugins directory:



            $debugline = '['.date('y m d H:i:s', time()).'] '.print_r($data,true);
            $debugfilepath = dirname(__FILE__).'/debug.log';
            error_log($debugline, 3, $debugfilepath);





            share|improve this answer































              1














              The best way to troubleshoot/debug your PHP code for WordPress is to use the XDEBUG debugger for PHP coupled with an IDE/editor that can leverage XDEBUG.



              By far my favorite IDE for PHP/XDEBUG is PhpStorm (best money I have ever spent), but you can use for free on the bleeding edge with their EAP (Early Access Program). You can also use the free VSCode with XDEBUG.



              Here is a great video showing what it looks like to use XDEBUG & PhpStorm. You can start at the 18:00 point because everything before that is talking and slides.



              You will also need a local development setup that supports XDEBUG. Several years ago I was frustrated with how difficult it was to get XDEBUG configured correctly so I had my team develop WPLib Box which pre-configures XDEBUG and thus makes using XDEBUG trivally easy. You can download WPLib Box from GitHub, use for free, and get help via our Slack.



              I like to say using PhpStorm/XDEBUG/WPlib Box gives me WordPress superpowers. How else do you think I answered all the questions here at WPSE that I have? :-)



              That said, there are also other local development solutions such as VVV, Trellis, Chassis, Desktop Server, MAMP, DevilBox, LaraDock, Kalabox, Kusanagi and others you might try. But I am not sure how difficult it is to set up XDEBUG to work with any of these others anymore and I know firsthand XDEBUG works without any fuss when using WPLib Box.



              Hope this helps.






              share|improve this answer

























                Your Answer








                StackExchange.ready(function() {
                var channelOptions = {
                tags: "".split(" "),
                id: "110"
                };
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function() {
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled) {
                StackExchange.using("snippets", function() {
                createEditor();
                });
                }
                else {
                createEditor();
                }
                });

                function createEditor() {
                StackExchange.prepareEditor({
                heartbeatType: 'answer',
                autoActivateHeartbeat: false,
                convertImagesToLinks: false,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: null,
                bindNavPrevention: true,
                postfix: "",
                imageUploader: {
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                },
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                });


                }
                });














                draft saved

                draft discarded


















                StackExchange.ready(
                function () {
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fwordpress.stackexchange.com%2fquestions%2f330654%2feasy-code-troubleshooting-in-wordpress%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                3 Answers
                3






                active

                oldest

                votes








                3 Answers
                3






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                1














                Just start with the following definitions in your config.php file:



                define('WP_DEBUG', true);
                define('WP_DEBUG_LOG', true);
                define('SCRIPT_DEBUG', true);
                define('SAVEQUERIES', true);


                The first one sets your system into debug mode, the second one writes every notice into a log file saved into your wp-content directory. Script debug enables WordPress to use the uncompressed CSS and JS files (Maybe also interesting for writing Plugins). And Savequeries writes HTML-Comments at the bottom of the rendered HTML Output and will be used by Plugins I suggest you next.



                See the WordPress Plugin Directory for Debug Bar and extensions. There are a lot and there's a great chance that some of them are providing exactly what you need.



                If nothing helps you can write everytime



                print_r( $var );
                die();


                and look into the HTML sourcecode.






                share|improve this answer




























                  1














                  Just start with the following definitions in your config.php file:



                  define('WP_DEBUG', true);
                  define('WP_DEBUG_LOG', true);
                  define('SCRIPT_DEBUG', true);
                  define('SAVEQUERIES', true);


                  The first one sets your system into debug mode, the second one writes every notice into a log file saved into your wp-content directory. Script debug enables WordPress to use the uncompressed CSS and JS files (Maybe also interesting for writing Plugins). And Savequeries writes HTML-Comments at the bottom of the rendered HTML Output and will be used by Plugins I suggest you next.



                  See the WordPress Plugin Directory for Debug Bar and extensions. There are a lot and there's a great chance that some of them are providing exactly what you need.



                  If nothing helps you can write everytime



                  print_r( $var );
                  die();


                  and look into the HTML sourcecode.






                  share|improve this answer


























                    1












                    1








                    1







                    Just start with the following definitions in your config.php file:



                    define('WP_DEBUG', true);
                    define('WP_DEBUG_LOG', true);
                    define('SCRIPT_DEBUG', true);
                    define('SAVEQUERIES', true);


                    The first one sets your system into debug mode, the second one writes every notice into a log file saved into your wp-content directory. Script debug enables WordPress to use the uncompressed CSS and JS files (Maybe also interesting for writing Plugins). And Savequeries writes HTML-Comments at the bottom of the rendered HTML Output and will be used by Plugins I suggest you next.



                    See the WordPress Plugin Directory for Debug Bar and extensions. There are a lot and there's a great chance that some of them are providing exactly what you need.



                    If nothing helps you can write everytime



                    print_r( $var );
                    die();


                    and look into the HTML sourcecode.






                    share|improve this answer













                    Just start with the following definitions in your config.php file:



                    define('WP_DEBUG', true);
                    define('WP_DEBUG_LOG', true);
                    define('SCRIPT_DEBUG', true);
                    define('SAVEQUERIES', true);


                    The first one sets your system into debug mode, the second one writes every notice into a log file saved into your wp-content directory. Script debug enables WordPress to use the uncompressed CSS and JS files (Maybe also interesting for writing Plugins). And Savequeries writes HTML-Comments at the bottom of the rendered HTML Output and will be used by Plugins I suggest you next.



                    See the WordPress Plugin Directory for Debug Bar and extensions. There are a lot and there's a great chance that some of them are providing exactly what you need.



                    If nothing helps you can write everytime



                    print_r( $var );
                    die();


                    and look into the HTML sourcecode.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered 1 hour ago









                    chrisbergrchrisbergr

                    535




                    535

























                        1














                        Unfortunately there isn't really a standard developer logging API in WordPress. If you want to output your own data to a debug file (to prevent "headers already sent" errors) then you can simply use the standard PHP error_log function. Something simple like this will record the variable $data to the file debug.log in your plugins directory:



                        $debugline = '['.date('y m d H:i:s', time()).'] '.print_r($data,true);
                        $debugfilepath = dirname(__FILE__).'/debug.log';
                        error_log($debugline, 3, $debugfilepath);





                        share|improve this answer




























                          1














                          Unfortunately there isn't really a standard developer logging API in WordPress. If you want to output your own data to a debug file (to prevent "headers already sent" errors) then you can simply use the standard PHP error_log function. Something simple like this will record the variable $data to the file debug.log in your plugins directory:



                          $debugline = '['.date('y m d H:i:s', time()).'] '.print_r($data,true);
                          $debugfilepath = dirname(__FILE__).'/debug.log';
                          error_log($debugline, 3, $debugfilepath);





                          share|improve this answer


























                            1












                            1








                            1







                            Unfortunately there isn't really a standard developer logging API in WordPress. If you want to output your own data to a debug file (to prevent "headers already sent" errors) then you can simply use the standard PHP error_log function. Something simple like this will record the variable $data to the file debug.log in your plugins directory:



                            $debugline = '['.date('y m d H:i:s', time()).'] '.print_r($data,true);
                            $debugfilepath = dirname(__FILE__).'/debug.log';
                            error_log($debugline, 3, $debugfilepath);





                            share|improve this answer













                            Unfortunately there isn't really a standard developer logging API in WordPress. If you want to output your own data to a debug file (to prevent "headers already sent" errors) then you can simply use the standard PHP error_log function. Something simple like this will record the variable $data to the file debug.log in your plugins directory:



                            $debugline = '['.date('y m d H:i:s', time()).'] '.print_r($data,true);
                            $debugfilepath = dirname(__FILE__).'/debug.log';
                            error_log($debugline, 3, $debugfilepath);






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered 1 hour ago









                            majickmajick

                            3,6991622




                            3,6991622























                                1














                                The best way to troubleshoot/debug your PHP code for WordPress is to use the XDEBUG debugger for PHP coupled with an IDE/editor that can leverage XDEBUG.



                                By far my favorite IDE for PHP/XDEBUG is PhpStorm (best money I have ever spent), but you can use for free on the bleeding edge with their EAP (Early Access Program). You can also use the free VSCode with XDEBUG.



                                Here is a great video showing what it looks like to use XDEBUG & PhpStorm. You can start at the 18:00 point because everything before that is talking and slides.



                                You will also need a local development setup that supports XDEBUG. Several years ago I was frustrated with how difficult it was to get XDEBUG configured correctly so I had my team develop WPLib Box which pre-configures XDEBUG and thus makes using XDEBUG trivally easy. You can download WPLib Box from GitHub, use for free, and get help via our Slack.



                                I like to say using PhpStorm/XDEBUG/WPlib Box gives me WordPress superpowers. How else do you think I answered all the questions here at WPSE that I have? :-)



                                That said, there are also other local development solutions such as VVV, Trellis, Chassis, Desktop Server, MAMP, DevilBox, LaraDock, Kalabox, Kusanagi and others you might try. But I am not sure how difficult it is to set up XDEBUG to work with any of these others anymore and I know firsthand XDEBUG works without any fuss when using WPLib Box.



                                Hope this helps.






                                share|improve this answer






























                                  1














                                  The best way to troubleshoot/debug your PHP code for WordPress is to use the XDEBUG debugger for PHP coupled with an IDE/editor that can leverage XDEBUG.



                                  By far my favorite IDE for PHP/XDEBUG is PhpStorm (best money I have ever spent), but you can use for free on the bleeding edge with their EAP (Early Access Program). You can also use the free VSCode with XDEBUG.



                                  Here is a great video showing what it looks like to use XDEBUG & PhpStorm. You can start at the 18:00 point because everything before that is talking and slides.



                                  You will also need a local development setup that supports XDEBUG. Several years ago I was frustrated with how difficult it was to get XDEBUG configured correctly so I had my team develop WPLib Box which pre-configures XDEBUG and thus makes using XDEBUG trivally easy. You can download WPLib Box from GitHub, use for free, and get help via our Slack.



                                  I like to say using PhpStorm/XDEBUG/WPlib Box gives me WordPress superpowers. How else do you think I answered all the questions here at WPSE that I have? :-)



                                  That said, there are also other local development solutions such as VVV, Trellis, Chassis, Desktop Server, MAMP, DevilBox, LaraDock, Kalabox, Kusanagi and others you might try. But I am not sure how difficult it is to set up XDEBUG to work with any of these others anymore and I know firsthand XDEBUG works without any fuss when using WPLib Box.



                                  Hope this helps.






                                  share|improve this answer




























                                    1












                                    1








                                    1







                                    The best way to troubleshoot/debug your PHP code for WordPress is to use the XDEBUG debugger for PHP coupled with an IDE/editor that can leverage XDEBUG.



                                    By far my favorite IDE for PHP/XDEBUG is PhpStorm (best money I have ever spent), but you can use for free on the bleeding edge with their EAP (Early Access Program). You can also use the free VSCode with XDEBUG.



                                    Here is a great video showing what it looks like to use XDEBUG & PhpStorm. You can start at the 18:00 point because everything before that is talking and slides.



                                    You will also need a local development setup that supports XDEBUG. Several years ago I was frustrated with how difficult it was to get XDEBUG configured correctly so I had my team develop WPLib Box which pre-configures XDEBUG and thus makes using XDEBUG trivally easy. You can download WPLib Box from GitHub, use for free, and get help via our Slack.



                                    I like to say using PhpStorm/XDEBUG/WPlib Box gives me WordPress superpowers. How else do you think I answered all the questions here at WPSE that I have? :-)



                                    That said, there are also other local development solutions such as VVV, Trellis, Chassis, Desktop Server, MAMP, DevilBox, LaraDock, Kalabox, Kusanagi and others you might try. But I am not sure how difficult it is to set up XDEBUG to work with any of these others anymore and I know firsthand XDEBUG works without any fuss when using WPLib Box.



                                    Hope this helps.






                                    share|improve this answer















                                    The best way to troubleshoot/debug your PHP code for WordPress is to use the XDEBUG debugger for PHP coupled with an IDE/editor that can leverage XDEBUG.



                                    By far my favorite IDE for PHP/XDEBUG is PhpStorm (best money I have ever spent), but you can use for free on the bleeding edge with their EAP (Early Access Program). You can also use the free VSCode with XDEBUG.



                                    Here is a great video showing what it looks like to use XDEBUG & PhpStorm. You can start at the 18:00 point because everything before that is talking and slides.



                                    You will also need a local development setup that supports XDEBUG. Several years ago I was frustrated with how difficult it was to get XDEBUG configured correctly so I had my team develop WPLib Box which pre-configures XDEBUG and thus makes using XDEBUG trivally easy. You can download WPLib Box from GitHub, use for free, and get help via our Slack.



                                    I like to say using PhpStorm/XDEBUG/WPlib Box gives me WordPress superpowers. How else do you think I answered all the questions here at WPSE that I have? :-)



                                    That said, there are also other local development solutions such as VVV, Trellis, Chassis, Desktop Server, MAMP, DevilBox, LaraDock, Kalabox, Kusanagi and others you might try. But I am not sure how difficult it is to set up XDEBUG to work with any of these others anymore and I know firsthand XDEBUG works without any fuss when using WPLib Box.



                                    Hope this helps.







                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited 58 mins ago

























                                    answered 1 hour ago









                                    MikeSchinkelMikeSchinkel

                                    34k14104126




                                    34k14104126






























                                        draft saved

                                        draft discarded




















































                                        Thanks for contributing an answer to WordPress Development Stack Exchange!


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid



                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.


                                        To learn more, see our tips on writing great answers.




                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function () {
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fwordpress.stackexchange.com%2fquestions%2f330654%2feasy-code-troubleshooting-in-wordpress%23new-answer', 'question_page');
                                        }
                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown







                                        Popular posts from this blog

                                        Щит и меч (фильм) Содержание Названия серий | Сюжет |...

                                        Венесуэла на летних Олимпийских играх 2000 Содержание Состав...

                                        Meter-Bus Содержание Параметры шины | Стандартизация |...