Hongmu Notes
Home Program Notes

Program Notes

In the final analysis, programmers taking notes is an efficient behavior of recording work experience. It can not only record the various technical problems encountered in the process of program development, but also record the beneficial experiences gained in learning technical knowledge. It can both help...

How to view all WP-Cache cached content in WordPress?

How to view all WP-Cache cached content in WordPress? Program Notes wordpress

In WordPress, you can use the `wp_cache_set()` function to store data in the cache; however, WordPress does not provide a direct way to view all cached data. Nevertheless, you can achieve this by using a WordPress plugin or by writing custom code. Here are some methods for your reference: Using plugins – Some WordPress caching plugins, such as WP-O...
👁 349
WordPress `wp_cache_set` function

WordPress `wp_cache_set` function Program Notes wordpress

`wp_cache_set()` is an built-in WordPress function used to store data in the cache. Its function prototype is as follows: `wp_cache_set($key, $data, $group = '', $expire = 0)`. Parameter descriptions: - `$key`: The key name for the data to be stored; typically a string. - `$data`: The data to be stored; can be...
👁 175
WordPress plugin development: Creating corresponding data tables

WordPress plugin development: Creating corresponding data tables Program Notes wordpress

Here is a simple WordPress plugin example that will create the corresponding database table when enabled: Create a folder named `my-database-plugin` and within it, create a file named `my-database-plugin.php`. Add the following code to the `my-database-plugin.php` file: <?...
👁 157
WordPress plugin comments – indicating developer information and descriptions.

WordPress plugin comments – indicating developer information and descriptions. Program Notes wordpress

When developing WordPress plugins, comments in the plugin files – such as the version number – should adhere to the format specified by WordPress to ensure that the plugin functions correctly and can be updated seamlessly. Specifically, the plugin files should contain comments similar to the example below, including fields such as Plugin Name, Plugin URI, Description, Author, Author URI, Ve...
👁 172
How to develop a WordPress plugin?

How to develop a WordPress plugin? Program Notes wordpress

To develop a WordPress plugin, follow these steps: First, create a new folder within the `wp-content/plugins` directory located in your WordPress installation directory to store your plugin code. Then, create a new PHP file in this folder; the file name should be the same as your plugin's name. For example, if your plugin's name is `MyPlugin`, then the file name should be...
👁 188
WordPress Hook: Create a new PHP file and then execute SQL query and update operations.

WordPress Hook: Create a new PHP file and then execute SQL query and update operations. Program Notes wordpress

In WordPress, using hooks allows you to execute custom code before or after specific actions are performed; this can be used to add additional functionality or modify existing functionality. There are two common types of hooks: action hooks and filter hooks. Below is an example PHP file that demonstrates how to use WordPress...
👁 160
WordPress Hook

WordPress Hook Program Notes wordpress

WordPress hooks define how custom code interacts with the core code in WordPress. These hooks allow developers to insert their own code into various events within WordPress in order to customize or modify its functionality in some way. WordPress hooks are divided into two categories: action hooks and filter hooks. Action hooks are used when WordPress performs a specific event...
👁 177
How can you commit a transaction after updating SQL data in WordPress?

How can you commit a transaction after updating SQL data in WordPress? Program Notes wordpress

In WordPress, you can use $wpdb->query('COMMIT') to commit a transaction. In your code, you can call $wpdb->query('COMMIT') after all SQL operations have been executed to commit the transaction. If an error occurs during execution, you can use $wpdb->query('ROLL...
👁 152
The WordPress database was successfully updated, but when a query is executed, the updated data reverts to its pre-update state – what could be the cause of this?

The WordPress database was successfully updated, but when a query is executed, the updated data reverts to its pre-update state – what could be the cause of this? Program Notes wordpress

This issue may be caused by the use of database transactions. A transaction is a group of SQL operations that can be committed or rolled back as a single logical unit. If your code uses transactions when executing SQL operations, this can sometimes lead to the behavior you are describing. When transactions are in use, all SQL operations are cached until you call the `COMMIT` statement to commit them to the database. If, during the execution of a transaction...
👁 179
The WordPress database was successfully updated, yet when a query is executed, the data still reverts to its state before the update – why is this happening?

The WordPress database was successfully updated, yet when a query is executed, the data still reverts to its state before the update – why is this happening? Program Notes wordpress

This issue is typically caused by the caching mechanism used in WordPress. When you perform an update operation in WordPress, the $wpdb object stores the data in memory; when the same data is queried again, it retrieves the data from memory instead of fetching it from the database. While this caching mechanism can improve query performance, it may also lead to the situation where data does not update immediately after an update is performed. To resolve this issue...
👁 204
1 6 7 8 9 10 23