Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the debug skills commonly used in WordPress development

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces what are the debug skills commonly used in WordPress development, which are introduced in great detail and have certain reference value. Friends who are interested must finish reading!

Turning on debug mode requires adding some constants to the root wp-config.php file, so all the code described below is added to the root wp-config.php file.

WP_DEBUG

WP_DEBUG is a constant of WordPress, and after setting it to True, WordPress enters developer mode and outputs all development tips to the screen.

I highly recommend enabling WP_DEBUG in the local development environment to facilitate development.

/ / enable developer mode define ('WP_DEBUG', true)

WP_DEBUG_LOG

If you want to record all the errors in the operation of WordPress, you can open WP_DEBUG_LOG, and when turned on, all errors will be recorded and stored in the wp-content/debug.log file.

The premise of recording errors is that you need to turn on WP_DEBUG mode, and only when WP_DEBUG is enabled will an error occur.

/ / enable error logging define ('WP_DEBUG_LOG', true)

WP_DEBUG_DISPLAY

If you want to record errors in WP_DEBUG mode only through WP_DEBUG_LOG instead of displaying them on the screen, you can turn on WP_DEBUG_DISPLAY when you turn on WP_DEBUG_LOG and WP_DEBUG.

/ / prevent errors from being displayed on the screen define ('WP_DEBUG_DISPLAY', true); SCRIPT_DEBUG

By default, the WordPress background uses compressed and merged JS and CSS files.

Sometimes for debugging purposes, we may not want to use compressed CSS and JS files in the background, so we can set SCRIPT_DEBUG to True.

/ / disable compressed CSS and JS files define ('SCRIPT_DEBUG', true)

SAVEQUERIES

If you want to optimize the number of database queries, SAVEQUERIES is a very important thing. Setting SAVEQUERIES to True,WordPress will record the Sql statement and time spent on each database query.

/ / record database query define ('SAVEQUERIES', true)

After opening the record, you can use the queries variable of $wpdb to get all the data queries. Put the following code in the footer.php file of the topic to see all the database queries.

The above is all the contents of the article "what are the debug skills commonly used in WordPress development". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report