Seems to be a pre-existing warning but I figured since I couldn’t bump the previous post about it, as it’s closed, I’d create a new one to let you know the warning persists. Seems to be a relatively easy fix. Here’s the warning for reference:
NOTICE: wp-content/plugins/woo-orders-date-range-filter/woo-orders-date-range-filter.php:169 – Undefined index: post_type
require_once(‘wp-admin/admin-header.php’), do_action(‘admin_enqueue_scripts’), WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, Woo_Orders_Filterby_Date_Range::woo_order_admin_menu_scripts
After installing plugin, it throws error(if DEBUG enabled):
Notice: Undefined index: post_type in /.../public_html/wp-content/plugins/woo-orders-date-range-filter/woo-orders-date-range-filter.php on line 169
This problem occurs on pages that doesn’t have GET[‘post_type’] in url, because code tries to compare(AND) with undefined($post_type) value:
$post_type = sanitize_text_field($_GET['post_type']);
if (!isset($_GET['post_type']) && $post_type !='shop_order') {
return false;
}
I have changed compare type to OR and problem solved when there’s no $post_type at all:
$post_type = sanitize_text_field($_GET['post_type']);
if (!isset($_GET['post_type']) || $post_type !='shop_order') { //changed from && to
return false;
}
Reply me if I’m not right ?? and of course thanks for great plugin!
]]>