So I have this problem with inserting widget into a foreach(). I am creating my OWN PLUGIN and I found a problem that I cant have the same class that extends WP_widget more then once and name of the class needs to be string. I wanted to create multiple widgets by using data from my database but there is the problem with the class name.
Cant do it like that because I cant use a variable
global $wpdb;
$vypis = $wpdb->get_results ("SELECT * FROM hodnoceni", ARRAY_A);
foreach ($vypis as $film) {
class $film['nazev'] extends WP_Widget {
And this also doesnt work because I can only have one class with that name
global $wpdb;
$vypis = $wpdb->get_results ("SELECT * FROM hodnoceni", ARRAY_A);
foreach ($vypis as $film) {
class MovieWidget extends WP_Widget {
I would like to know if its even possible to do something like that.