WC_Admin_Log_Table_List::get_sources()
Get the list of unique sources in the log table.
The query in this method can be slow when there are a high number of log entries. The list of sources also most likely doesn't change that often. So this indefinitely caches the list into the WP options table. The cache will get cleared by the log handler if a new source is being added. See WC_Log_Handler_DB::handle().
Метод класса: WC_Admin_Log_Table_List{}
Хуков нет.
Возвращает
Массив
.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_sources();
Код WC_Admin_Log_Table_List::get_sources() WC Admin Log Table List::get sources WC 9.8.1
protected function get_sources() { global $wpdb; $sources = get_option( self::SOURCE_CACHE_OPTION_KEY, null ); if ( is_array( $sources ) ) { return $sources; } $sql = " SELECT DISTINCT source FROM {$wpdb->prefix}woocommerce_log WHERE source != '' ORDER BY source ASC "; // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Not necessary. $sources = $wpdb->get_col( $sql ); // Autoload this option so that the log handler doesn't have to run another query when checking the source list. update_option( self::SOURCE_CACHE_OPTION_KEY, $sources, true ); return $sources; }