Custom Fields – How to get the list of a specific active widget each time it rendered

I am trying to get a specific widget as a list in select input inside a meta box/custom fields.


I have created a meta box/custom fields in posts and pages. In which I have some input fields and one of them is select input. I want to get the name id of that specific widget each time it is activated.

For example:

Let’s take the latest post widget.

What I want to achieve is when every I activate the widget ( no matter how many times ) whether 1 time, 2 times, or 10 times

I want to get that widget unique ID name/custom title and each information inside that select option


Currently, I have code that gives all the widget names and ids

foreach ( $  GLOBALS['wp_widget_factory']->widgets as $  widget ) {     echo '<option value="' . $  widget->id_base .'" >' . $  widget->name. '</option>' . "<br/>"; }

How can I achieve this?