private function filterTVprogramsByDay($programs) { $filtered = array(); $dt = new \DateTime(NULL, $this->tz); foreach ($programs as $day => &$program) { shuffle($program); shuffle($program); shuffle($program); $cnt = 0; foreach ($program as &$data) { if (isset($filtered[$data['post_id']])) { continue; } $dt->setTimestamp($data['date_time_ts']); $filtered[$data['post_id']] = array('name' => $data['name'], 'time' => $data['date_time_ts'], 'time_readable' => $dt->format('d.m.Y в H:i')); $cnt++; if ($cnt === Arr::get($this->options->time_options, 'max_count_per_day', 2)) { break; } } } return $filtered; }
public function form($instance) { $defaults = array('title' => 'Анонсы', 'text' => 1); $instance = wp_parse_args((array) $instance, $defaults); $title = Arr::get($instance, 'title', 'Анонсы'); $text = Arr::get($instance, 'text', 0); $title = strip_tags($title); ?> <p> <label for="<?php echo $this->get_field_id('title'); ?> ">Заголовок:</label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " type="text" value="<?php echo esc_attr($title); ?> " /> </p> <p> <input class="widefat" id="<?php echo $this->get_field_id('text'); ?> " name="<?php echo $this->get_field_name('text'); ?> " type="checkbox" value="1" <?php checked($text, 1); ?> /> <label for="<?php echo $this->get_field_id('text'); ?> ">Текст анонса</label> </p> <?php }