Automattic\WooCommerce\Internal\EmailEditor\WCTransactionalEmails
WCEmailPostsCleanup::fetch_email_post_mappings
Fetch all email type → post ID option mappings straight from the database.
Bypasses the posts manager caches on purpose: this is a migration and must observe the persisted state.
Method of the class: WCEmailPostsCleanup{}
No Hooks.
Returns
\stdClass[]. Rows with option_name and option_value.
Usage
$result = WCEmailPostsCleanup::fetch_email_post_mappings(): array;
WCEmailPostsCleanup::fetch_email_post_mappings() WCEmailPostsCleanup::fetch email post mappings code WC 11.1.2
private static function fetch_email_post_mappings(): array {
global $wpdb;
// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
$rows = $wpdb->get_results(
$wpdb->prepare(
"SELECT option_name, option_value FROM {$wpdb->options} WHERE option_name LIKE %s ORDER BY option_name ASC",
WCTransactionalEmailPostsManager::WC_OPTION_NAME
)
);
// phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
return is_array( $rows ) ? $rows : array();
}