Merge branch 'db-log-search' of https://github.com/seostudio/woocommerce into seostudio-db-log-search

This commit is contained in:
Claudio Sanches 2017-11-10 10:17:29 -02:00
commit fbf5117e05
2 changed files with 13 additions and 0 deletions

View File

@ -334,6 +334,10 @@ class WC_Admin_Log_Table_List extends WP_List_Table {
$where_conditions[] = 'source = %s';
$where_values[] = wc_clean( $_REQUEST['source'] );
}
if ( ! empty( $_REQUEST['s'] ) ) {
$where_conditions[] = 'message like %s';
$where_values[] = '%' . $wpdb->esc_like( wc_clean( wp_unslash( $_REQUEST['s'] ) ) ) . '%';
}
if ( ! empty( $where_conditions ) ) {
return $wpdb->prepare( 'WHERE 1 = 1 AND ' . implode( ' AND ', $where_conditions ), $where_values );

View File

@ -6,8 +6,17 @@
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$s = '';
if ( isset( $_REQUEST['s'] ) ) {
$s = wc_clean( wp_unslash( $_REQUEST['s'] ) );
}
?>
<form method="get" id="mainform" action="">
<p class="search-box">
<label class="screen-reader-text" for="post-search-input"><?php _e( 'Search logs', 'woocommerce' ); ?></label>
<input type="search" id="post-search-input" name="s" value="<?php echo esc_attr( $s ); ?>">
<input type="submit" id="search-submit" class="button" value="<?php _e( 'Search logs', 'woocommerce' ); ?>">
</p>
<?php $log_table_list->display(); ?>