Automattic\WooCommerce\Admin\RemoteInboxNotifications

RemoteInboxNotificationsEngine::ajax_action_inbox_notification_search()private staticWC 1.0

Add ajax action for remote inbox notification search.

Метод класса: RemoteInboxNotificationsEngine{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$result = RemoteInboxNotificationsEngine::ajax_action_inbox_notification_search();

Код RemoteInboxNotificationsEngine::ajax_action_inbox_notification_search() WC 9.3.3

private static function ajax_action_inbox_notification_search() {
	global $wpdb;

	check_ajax_referer( 'search-products', 'security' );

	if ( ! isset( $_GET['term'] ) ) {
		wp_send_json( array() );
	}

	$search  = wc_clean( sanitize_text_field( wp_unslash( $_GET['term'] ) ) );
	$results = $wpdb->get_results(
		$wpdb->prepare(
			"SELECT note_id, name FROM {$wpdb->prefix}wc_admin_notes WHERE name LIKE %s",
			'%' . $wpdb->esc_like( $search ) . '%'
		)
	);
	$rows    = array();
	foreach ( $results as $result ) {
		$rows[ $result->note_id ] = $result->name;
	}
	wp_send_json( $rows );
}