plugin updates
This commit is contained in:
@@ -124,12 +124,25 @@ class Loader {
|
||||
|
||||
$sections = self::get_embed_breadcrumbs();
|
||||
$sections = is_array( $sections ) ? $sections : array( $sections );
|
||||
|
||||
$page_title = '';
|
||||
$pages_with_tabs = array( 'Settings', 'Reports', 'Status' );
|
||||
|
||||
if (
|
||||
count( $sections ) > 2 &&
|
||||
is_array( $sections[1] ) &&
|
||||
in_array( $sections[1][1], $pages_with_tabs, true )
|
||||
) {
|
||||
$page_title = $sections[1][1];
|
||||
} else {
|
||||
$page_title = end( $sections );
|
||||
}
|
||||
?>
|
||||
<div id="woocommerce-embedded-root" class="is-embed-loading">
|
||||
<div class="woocommerce-layout">
|
||||
<div class="woocommerce-layout__header is-embed-loading">
|
||||
<h1 class="woocommerce-layout__header-heading">
|
||||
<?php self::output_heading( end( $sections ) ); ?>
|
||||
<?php self::output_heading( $page_title ); ?>
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
@@ -293,7 +306,7 @@ class Loader {
|
||||
$settings['orderStatuses'] = self::get_order_statuses( wc_get_order_statuses() );
|
||||
$settings['stockStatuses'] = self::get_order_statuses( wc_get_product_stock_status_options() );
|
||||
$settings['currency'] = self::get_currency_settings();
|
||||
$settings['locale'] = [
|
||||
$settings['locale'] = array(
|
||||
'siteLocale' => isset( $settings['siteLocale'] )
|
||||
? $settings['siteLocale']
|
||||
: get_locale(),
|
||||
@@ -303,7 +316,7 @@ class Loader {
|
||||
'weekdaysShort' => isset( $settings['l10n']['weekdaysShort'] )
|
||||
? $settings['l10n']['weekdaysShort']
|
||||
: array_values( $wp_locale->weekday_abbrev ),
|
||||
];
|
||||
);
|
||||
}
|
||||
|
||||
$preload_data_endpoints = apply_filters( 'woocommerce_component_settings_preload_endpoints', array() );
|
||||
@@ -327,7 +340,7 @@ class Loader {
|
||||
$setting_options = new \WC_REST_Setting_Options_V2_Controller();
|
||||
foreach ( $preload_settings as $group ) {
|
||||
$group_settings = $setting_options->get_group_settings( $group );
|
||||
$preload_settings = [];
|
||||
$preload_settings = array();
|
||||
foreach ( $group_settings as $option ) {
|
||||
if ( array_key_exists( 'id', $option ) && array_key_exists( 'value', $option ) ) {
|
||||
$preload_settings[ $option['id'] ] = $option['value'];
|
||||
@@ -374,7 +387,7 @@ class Loader {
|
||||
if ( ! empty( $preload_data_endpoints ) ) {
|
||||
$settings['dataEndpoints'] = isset( $settings['dataEndpoints'] )
|
||||
? $settings['dataEndpoints']
|
||||
: [];
|
||||
: array();
|
||||
foreach ( $preload_data_endpoints as $key => $endpoint ) {
|
||||
// Handle error case: rest_do_request() doesn't guarantee success.
|
||||
if ( empty( $preload_data[ $endpoint ] ) ) {
|
||||
|
||||
@@ -4,7 +4,8 @@ declare( strict_types = 1 );
|
||||
namespace Automattic\WooCommerce\Internal\Admin\Logging\FileV2;
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
use WP_Filesystem_Direct;
|
||||
use Automattic\WooCommerce\Internal\Utilities\FilesystemUtil;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* File class.
|
||||
@@ -60,14 +61,6 @@ class File {
|
||||
* @param string $path The absolute path of the file.
|
||||
*/
|
||||
public function __construct( $path ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/file.php';
|
||||
|
||||
global $wp_filesystem;
|
||||
|
||||
if ( ! $wp_filesystem instanceof WP_Filesystem_Direct ) {
|
||||
WP_Filesystem();
|
||||
}
|
||||
|
||||
$this->path = $path;
|
||||
$this->ingest_path();
|
||||
}
|
||||
@@ -237,27 +230,33 @@ class File {
|
||||
/**
|
||||
* Check if the file represented by the class instance is a file and is readable.
|
||||
*
|
||||
* @global WP_Filesystem_Direct $wp_filesystem
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_readable(): bool {
|
||||
global $wp_filesystem;
|
||||
try {
|
||||
$filesystem = FilesystemUtil::get_wp_filesystem();
|
||||
$is_readable = $filesystem->is_file( $this->path ) && $filesystem->is_readable( $this->path );
|
||||
} catch ( Exception $exception ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $wp_filesystem->is_file( $this->path ) && $wp_filesystem->is_readable( $this->path );
|
||||
return $is_readable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the file represented by the class instance is a file and is writable.
|
||||
*
|
||||
* @global WP_Filesystem_Direct $wp_filesystem
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_writable(): bool {
|
||||
global $wp_filesystem;
|
||||
try {
|
||||
$filesystem = FilesystemUtil::get_wp_filesystem();
|
||||
$is_writable = $filesystem->is_file( $this->path ) && $filesystem->is_writable( $this->path );
|
||||
} catch ( Exception $exception ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $wp_filesystem->is_file( $this->path ) && $wp_filesystem->is_writable( $this->path );
|
||||
return $is_writable;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -372,31 +371,38 @@ class File {
|
||||
/**
|
||||
* Get the time of the last modification of the file, as a Unix timestamp. Or false if the file isn't readable.
|
||||
*
|
||||
* @global WP_Filesystem_Direct $wp_filesystem
|
||||
*
|
||||
* @return int|false
|
||||
*/
|
||||
public function get_modified_timestamp() {
|
||||
global $wp_filesystem;
|
||||
try {
|
||||
$filesystem = FilesystemUtil::get_wp_filesystem();
|
||||
$timestamp = $filesystem->mtime( $this->path );
|
||||
} catch ( Exception $exception ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $wp_filesystem->mtime( $this->path );
|
||||
return $timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size of the file in bytes. Or false if the file isn't readable.
|
||||
*
|
||||
* @global WP_Filesystem_Direct $wp_filesystem
|
||||
*
|
||||
* @return int|false
|
||||
*/
|
||||
public function get_file_size() {
|
||||
global $wp_filesystem;
|
||||
try {
|
||||
$filesystem = FilesystemUtil::get_wp_filesystem();
|
||||
|
||||
if ( ! $wp_filesystem->is_readable( $this->path ) ) {
|
||||
if ( ! $filesystem->is_readable( $this->path ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$size = $filesystem->size( $this->path );
|
||||
} catch ( Exception $exception ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $wp_filesystem->size( $this->path );
|
||||
return $size;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -405,10 +411,13 @@ class File {
|
||||
* @return bool
|
||||
*/
|
||||
protected function create(): bool {
|
||||
global $wp_filesystem;
|
||||
|
||||
$created = $wp_filesystem->touch( $this->path );
|
||||
$modded = $wp_filesystem->chmod( $this->path );
|
||||
try {
|
||||
$filesystem = FilesystemUtil::get_wp_filesystem();
|
||||
$created = $filesystem->touch( $this->path );
|
||||
$modded = $filesystem->chmod( $this->path );
|
||||
} catch ( Exception $exception ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $created && $modded;
|
||||
}
|
||||
@@ -463,8 +472,6 @@ class File {
|
||||
return false;
|
||||
}
|
||||
|
||||
global $wp_filesystem;
|
||||
|
||||
$created = 0;
|
||||
if ( $this->has_standard_filename() ) {
|
||||
$created = $this->get_created_timestamp();
|
||||
@@ -489,7 +496,13 @@ class File {
|
||||
$new_filename = str_replace( $search, $replace, $old_filename );
|
||||
$new_path = str_replace( $old_filename, $new_filename, $this->path );
|
||||
|
||||
$moved = $wp_filesystem->move( $this->path, $new_path, true );
|
||||
try {
|
||||
$filesystem = FilesystemUtil::get_wp_filesystem();
|
||||
$moved = $filesystem->move( $this->path, $new_path, true );
|
||||
} catch ( Exception $exception ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! $moved ) {
|
||||
return false;
|
||||
}
|
||||
@@ -503,13 +516,16 @@ class File {
|
||||
/**
|
||||
* Delete the file from the filesystem.
|
||||
*
|
||||
* @global WP_Filesystem_Direct $wp_filesystem
|
||||
*
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function delete(): bool {
|
||||
global $wp_filesystem;
|
||||
try {
|
||||
$filesystem = FilesystemUtil::get_wp_filesystem();
|
||||
$deleted = $filesystem->delete( $this->path, false, 'f' );
|
||||
} catch ( Exception $exception ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $wp_filesystem->delete( $this->path, false, 'f' );
|
||||
return $deleted;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -481,10 +481,7 @@ class FileController {
|
||||
|
||||
$files = $this->get_files_by_id( $file_ids );
|
||||
foreach ( $files as $file ) {
|
||||
$result = false;
|
||||
if ( $file->is_writable() ) {
|
||||
$result = $file->delete();
|
||||
}
|
||||
$result = $file->delete();
|
||||
|
||||
if ( true === $result ) {
|
||||
$deleted ++;
|
||||
@@ -662,7 +659,7 @@ class FileController {
|
||||
$path = realpath( Settings::get_log_directory() );
|
||||
|
||||
if ( wp_is_writable( $path ) ) {
|
||||
$iterator = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( $path, \FilesystemIterator::SKIP_DOTS ) );
|
||||
$iterator = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( $path, \FilesystemIterator::SKIP_DOTS ), \RecursiveIteratorIterator::CATCH_GET_CHILD );
|
||||
|
||||
foreach ( $iterator as $file ) {
|
||||
$bytes += $file->getSize();
|
||||
|
||||
@@ -3,8 +3,9 @@ declare( strict_types=1 );
|
||||
|
||||
namespace Automattic\WooCommerce\Internal\Admin\Logging\FileV2;
|
||||
|
||||
use Automattic\WooCommerce\Internal\Utilities\FilesystemUtil;
|
||||
use Exception;
|
||||
use WP_Error;
|
||||
use WP_Filesystem_Direct;
|
||||
|
||||
/**
|
||||
* FileExport class.
|
||||
@@ -39,11 +40,6 @@ class FileExporter {
|
||||
* part of the path.
|
||||
*/
|
||||
public function __construct( string $path, string $alternate_filename = '' ) {
|
||||
global $wp_filesystem;
|
||||
if ( ! $wp_filesystem instanceof WP_Filesystem_Direct ) {
|
||||
WP_Filesystem();
|
||||
}
|
||||
|
||||
$this->path = $path;
|
||||
$this->alternate_filename = $alternate_filename;
|
||||
}
|
||||
@@ -54,8 +50,14 @@ class FileExporter {
|
||||
* @return WP_Error|void Only returns something if there is an error.
|
||||
*/
|
||||
public function emit_file() {
|
||||
global $wp_filesystem;
|
||||
if ( ! $wp_filesystem->is_file( $this->path ) || ! $wp_filesystem->is_readable( $this->path ) ) {
|
||||
try {
|
||||
$filesystem = FilesystemUtil::get_wp_filesystem();
|
||||
$is_readable = $filesystem->is_file( $this->path ) && $filesystem->is_readable( $this->path );
|
||||
} catch ( Exception $exception ) {
|
||||
$is_readable = false;
|
||||
}
|
||||
|
||||
if ( ! $is_readable ) {
|
||||
return new WP_Error(
|
||||
'wc_logs_invalid_file',
|
||||
__( 'Could not access file.', 'woocommerce' )
|
||||
@@ -104,11 +106,11 @@ class FileExporter {
|
||||
* @return void
|
||||
*/
|
||||
private function send_contents(): void {
|
||||
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fopen -- No suitable alternative.
|
||||
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fopen -- No suitable alternative.
|
||||
$stream = fopen( $this->path, 'rb' );
|
||||
|
||||
while ( is_resource( $stream ) && ! feof( $stream ) ) {
|
||||
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fread -- No suitable alternative.
|
||||
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fread -- No suitable alternative.
|
||||
$chunk = fread( $stream, self::CHUNK_SIZE );
|
||||
|
||||
if ( is_string( $chunk ) ) {
|
||||
@@ -117,7 +119,7 @@ class FileExporter {
|
||||
}
|
||||
}
|
||||
|
||||
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fclose -- No suitable alternative.
|
||||
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fclose -- No suitable alternative.
|
||||
fclose( $stream );
|
||||
}
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ class PageController {
|
||||
if ( ! $this->settings->logging_is_enabled() ) {
|
||||
add_action(
|
||||
'admin_notices',
|
||||
function() {
|
||||
function () {
|
||||
?>
|
||||
<div class="notice notice-warning">
|
||||
<p>
|
||||
@@ -395,7 +395,7 @@ class PageController {
|
||||
if ( is_string( $line ) ) {
|
||||
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- format_line does the escaping.
|
||||
echo $this->format_line( $line, $line_number );
|
||||
$line_number ++;
|
||||
++$line_number;
|
||||
}
|
||||
?>
|
||||
<?php endwhile; ?>
|
||||
@@ -464,7 +464,7 @@ class PageController {
|
||||
array(
|
||||
'file_id' => array(
|
||||
'filter' => FILTER_CALLBACK,
|
||||
'options' => function( $file_id ) {
|
||||
'options' => function ( $file_id ) {
|
||||
return sanitize_file_name( wp_unslash( $file_id ) );
|
||||
},
|
||||
),
|
||||
@@ -484,13 +484,13 @@ class PageController {
|
||||
),
|
||||
'search' => array(
|
||||
'filter' => FILTER_CALLBACK,
|
||||
'options' => function( $search ) {
|
||||
'options' => function ( $search ) {
|
||||
return esc_html( wp_unslash( $search ) );
|
||||
},
|
||||
),
|
||||
'source' => array(
|
||||
'filter' => FILTER_CALLBACK,
|
||||
'options' => function( $source ) {
|
||||
'options' => function ( $source ) {
|
||||
return File::sanitize_source( wp_unslash( $source ) );
|
||||
},
|
||||
),
|
||||
@@ -624,7 +624,7 @@ class PageController {
|
||||
}
|
||||
|
||||
if ( is_wp_error( $export_error ) ) {
|
||||
wp_die( wp_kses_post( $export_error ) );
|
||||
wp_die( wp_kses_post( $export_error->get_error_message() ) );
|
||||
}
|
||||
break;
|
||||
case 'delete':
|
||||
@@ -654,7 +654,7 @@ class PageController {
|
||||
if ( is_numeric( $deleted ) ) {
|
||||
add_action(
|
||||
'admin_notices',
|
||||
function() use ( $deleted ) {
|
||||
function () use ( $deleted ) {
|
||||
?>
|
||||
<div class="notice notice-info is-dismissible">
|
||||
<p>
|
||||
|
||||
@@ -8,10 +8,12 @@ use Automattic\WooCommerce\Internal\Admin\Logging\FileV2\File;
|
||||
use Automattic\WooCommerce\Internal\Admin\Logging\LogHandlerFileV2;
|
||||
use Automattic\WooCommerce\Internal\Admin\Logging\FileV2\FileController;
|
||||
use Automattic\WooCommerce\Internal\Traits\AccessiblePrivateMethods;
|
||||
use Automattic\WooCommerce\Internal\Utilities\FilesystemUtil;
|
||||
use Automattic\WooCommerce\Proxies\LegacyProxy;
|
||||
use Exception;
|
||||
use WC_Admin_Settings;
|
||||
use WC_Log_Handler_DB, WC_Log_Handler_File, WC_Log_Levels;
|
||||
use WP_Filesystem_Base;
|
||||
use WP_Filesystem_Direct;
|
||||
|
||||
/**
|
||||
* Settings class.
|
||||
@@ -78,14 +80,13 @@ class Settings {
|
||||
|
||||
if ( true === $result ) {
|
||||
// Create infrastructure to prevent listing contents of the logs directory.
|
||||
require_once ABSPATH . 'wp-admin/includes/file.php';
|
||||
global $wp_filesystem;
|
||||
if ( ! $wp_filesystem instanceof WP_Filesystem_Base ) {
|
||||
WP_Filesystem();
|
||||
try {
|
||||
$filesystem = FilesystemUtil::get_wp_filesystem();
|
||||
$filesystem->put_contents( $dir . '.htaccess', 'deny from all' );
|
||||
$filesystem->put_contents( $dir . 'index.html', '' );
|
||||
} catch ( Exception $exception ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch
|
||||
// Creation failed.
|
||||
}
|
||||
|
||||
$wp_filesystem->put_contents( $dir . '.htaccess', 'deny from all' );
|
||||
$wp_filesystem->put_contents( $dir . 'index.html', '' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,6 +293,20 @@ class Settings {
|
||||
$location_info = array();
|
||||
$directory = self::get_log_directory();
|
||||
|
||||
$status_info = array();
|
||||
try {
|
||||
$filesystem = FilesystemUtil::get_wp_filesystem();
|
||||
if ( $filesystem instanceof WP_Filesystem_Direct ) {
|
||||
$status_info[] = __( '✅ Ready', 'woocommerce' );
|
||||
} else {
|
||||
$status_info[] = __( '⚠️ The file system is not configured for direct writes. This could cause problems for the logger.', 'woocommerce' );
|
||||
$status_info[] = __( 'You may want to switch to the database for log storage.', 'woocommerce' );
|
||||
}
|
||||
} catch ( Exception $exception ) {
|
||||
$status_info[] = __( '⚠️ The file system connection could not be initialized.', 'woocommerce' );
|
||||
$status_info[] = __( 'You may want to switch to the database for log storage.', 'woocommerce' );
|
||||
}
|
||||
|
||||
$location_info[] = sprintf(
|
||||
// translators: %s is a location in the filesystem.
|
||||
__( 'Log files are stored in this directory: %s', 'woocommerce' ),
|
||||
@@ -317,6 +332,11 @@ class Settings {
|
||||
'id' => self::PREFIX . 'settings',
|
||||
'type' => 'title',
|
||||
),
|
||||
'file_status' => array(
|
||||
'title' => __( 'Status', 'woocommerce' ),
|
||||
'type' => 'info',
|
||||
'text' => implode( "\n\n", $status_info ),
|
||||
),
|
||||
'log_directory' => array(
|
||||
'title' => __( 'Location', 'woocommerce' ),
|
||||
'type' => 'info',
|
||||
@@ -340,7 +360,7 @@ class Settings {
|
||||
$table = "{$wpdb->prefix}woocommerce_log";
|
||||
|
||||
$location_info = sprintf(
|
||||
// translators: %s is a location in the filesystem.
|
||||
// translators: %s is the name of a table in the database.
|
||||
__( 'Log entries are stored in this database table: %s', 'woocommerce' ),
|
||||
"<code>$table</code>"
|
||||
);
|
||||
|
||||
@@ -221,6 +221,9 @@ class WooSubscriptionsNotes {
|
||||
* @return int|false
|
||||
*/
|
||||
public function get_product_id_from_subscription_note( &$note ) {
|
||||
if ( ! is_object( $note ) ) {
|
||||
return false;
|
||||
}
|
||||
$content_data = $note->get_content_data();
|
||||
|
||||
if ( property_exists( $content_data, 'product_id' ) ) {
|
||||
|
||||
@@ -982,7 +982,7 @@ class ListTable extends WP_List_Table {
|
||||
*
|
||||
* @return string Edit link for the order.
|
||||
*/
|
||||
private function get_order_edit_link( WC_Order $order ) : string {
|
||||
private function get_order_edit_link( WC_Order $order ): string {
|
||||
return $this->page_controller->get_edit_url( $order->get_id() );
|
||||
}
|
||||
|
||||
@@ -1352,7 +1352,7 @@ class ListTable extends WP_List_Table {
|
||||
}
|
||||
|
||||
do_action( 'woocommerce_remove_order_personal_data', $order ); // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
|
||||
$changed++;
|
||||
++$changed;
|
||||
}
|
||||
|
||||
return $changed;
|
||||
@@ -1380,7 +1380,7 @@ class ListTable extends WP_List_Table {
|
||||
|
||||
$order->update_status( $new_status, __( 'Order status changed by bulk edit.', 'woocommerce' ), true );
|
||||
do_action( 'woocommerce_order_edit_status', $id, $new_status ); // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
|
||||
$changed++;
|
||||
++$changed;
|
||||
}
|
||||
|
||||
return $changed;
|
||||
@@ -1403,7 +1403,7 @@ class ListTable extends WP_List_Table {
|
||||
$updated_order = wc_get_order( $id );
|
||||
|
||||
if ( ( $force_delete && false === $updated_order ) || ( ! $force_delete && $updated_order->get_status() === 'trash' ) ) {
|
||||
$changed++;
|
||||
++$changed;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1423,7 +1423,7 @@ class ListTable extends WP_List_Table {
|
||||
|
||||
foreach ( $ids as $id ) {
|
||||
if ( $orders_store->untrash_order( wc_get_order( $id ) ) ) {
|
||||
$changed++;
|
||||
++$changed;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1547,6 +1547,11 @@ class ListTable extends WP_List_Table {
|
||||
<a href="{{ data.shipping_address_map_url }}" target="_blank">{{{ data.formatted_shipping_address }}}</a>
|
||||
<# } #>
|
||||
|
||||
<# if ( data.data.shipping.phone ) { #>
|
||||
<strong><?php esc_html_e( 'Phone', 'woocommerce' ); ?></strong>
|
||||
<a href="tel:{{ data.data.shipping.phone }}">{{ data.data.shipping.phone }}</a>
|
||||
<# } #>
|
||||
|
||||
<# if ( data.shipping_via ) { #>
|
||||
<strong><?php esc_html_e( 'Shipping method', 'woocommerce' ); ?></strong>
|
||||
{{ data.shipping_via }}
|
||||
@@ -1629,10 +1634,25 @@ class ListTable extends WP_List_Table {
|
||||
'products' => __( 'Products', 'woocommerce' ),
|
||||
'all' => __( 'All', 'woocommerce' ),
|
||||
);
|
||||
|
||||
/**
|
||||
* Filters the search filters available in the admin order search. Can be used to add new or remove existing filters.
|
||||
* When adding new filters, `woocommerce_hpos_generate_where_for_search_filter` should also be used to generate the WHERE clause for the new filter
|
||||
*
|
||||
* @since 8.9.0.
|
||||
*
|
||||
* @param $options array List of available filters.
|
||||
*/
|
||||
$options = apply_filters( 'woocommerce_hpos_admin_search_filters', $options );
|
||||
$saved_setting = get_user_setting( 'wc-search-filter-hpos-admin', 'all' );
|
||||
$selected = sanitize_text_field( wp_unslash( $_REQUEST['search-filter'] ?? $saved_setting ) );
|
||||
if ( $saved_setting !== $selected ) {
|
||||
set_user_setting( 'wc-search-filter-hpos-admin', $selected );
|
||||
}
|
||||
?>
|
||||
<select name="search-filter" id="order-search-filter">
|
||||
<?php foreach ( $options as $value => $label ) { ?>
|
||||
<option value="<?php echo esc_attr( wp_unslash( sanitize_text_field( $value ) ) ); ?>" <?php selected( $value, sanitize_text_field( wp_unslash( $_REQUEST['search-filter'] ?? 'all' ) ) ); ?>><?php echo esc_html( $label ); ?></option>
|
||||
<option value="<?php echo esc_attr( wp_unslash( sanitize_text_field( $value ) ) ); ?>" <?php selected( $value, sanitize_text_field( wp_unslash( $selected ) ) ); ?>><?php echo esc_html( $label ); ?></option>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,12 +66,6 @@ class OrderAttribution {
|
||||
public function output( WC_Order $order ) {
|
||||
$meta = $this->filter_meta_data( $order->get_meta_data() );
|
||||
|
||||
// If we don't have any meta to show, return.
|
||||
if ( empty( $meta ) ) {
|
||||
esc_html_e( 'No order source data available.', 'woocommerce' );
|
||||
return;
|
||||
}
|
||||
|
||||
$this->format_meta_data( $meta );
|
||||
|
||||
// No more details if there is only the origin value - this is for unknown source types.
|
||||
|
||||
Reference in New Issue
Block a user