WordPress Developer Ukraine, Kyiv
MySQL Triggers for WordPress Database Audit Logging

MySQL Triggers for WordPress Database Audit Logging

MySQL triggers as an audit log for WordPress options Some changes in a WordPress database come from nowhere: the admin email is suddenly different, users_can_register is on, a plugin appears in active_plugins. A logging plugin records what happens through WordPress, but not what a script, a database tool or an attacker with database access changes…
Use MySQL Window Functions and CTEs for WordPress Analytics Queries

Use MySQL Window Functions and CTEs for WordPress Analytics Queries

MySQL window functions and CTEs for WordPress reports An editorial report often asks questions like “the top three posts of each category” or “the running total of comments per month”. With plain GROUP BY such questions need several queries and PHP loops. Window functions (ROW_NUMBER(), RANK(), SUM() OVER) and common table expressions (WITH) answer them…
Migrate WooCommerce Orders to High-Performance Order Storage (HPOS)

Migrate WooCommerce Orders to High-Performance Order Storage (HPOS)

Migrate WooCommerce orders to High-Performance Order Storage (HPOS) High-Performance Order Storage moves WooCommerce orders out of wp_posts and wp_postmeta into their own tables: wc_orders, wc_order_addresses, wc_order_operational_data and wc_orders_meta. It appeared as an opt-in feature in WooCommerce 7.1, and with WooCommerce 8.2 (October 2023) it becomes the default for new stores. The reason is performance: in…
Run Custom SQL Queries in WordPress with $wpdb->prepare and get_results

Run Custom SQL Queries in WordPress with $wpdb->prepare and get_results

Run custom SQL queries in WordPress with $wpdb->prepare() and get_results() WP_Query covers most needs, but some queries it cannot express or makes inefficient: aggregations with GROUP BY, joins across several tables, bulk updates. For those, WordPress gives the $wpdb object, a direct connection to the database, with $wpdb->prepare() for safe parameters.
Create a Custom Database Table in a WordPress Plugin with dbDelta

Create a Custom Database Table in a WordPress Plugin with dbDelta

Create a custom database table in a WordPress plugin with dbDelta wp_postmeta stores any key-value data, but for high-volume or relational plugin data (logs, statistics, bookings) it becomes a bottleneck: every value is a LONGTEXT in one huge table, and filtering by several values means several joins. A custom table gives you your own columns…