public static function print_show_finished_experiments_field() { $field_name = 'show_finished_experiments'; printf('<select id="%1$s" name="nelioab_settings[%1$s]" %2$s>', $field_name, self::get_basic_details()); ?> <option value='<?php echo NelioABSettings::FINISHED_EXPERIMENTS_HIDE_ALL; ?> '><?php _e('Hide Finished Experiments', 'nelioab'); ?> </option> <option value='<?php echo NelioABSettings::FINISHED_EXPERIMENTS_SHOW_RECENT; ?> '<?php if (NelioABSettings::FINISHED_EXPERIMENTS_SHOW_RECENT == NelioABSettings::show_finished_experiments()) { echo ' selected="selected"'; } ?> ><?php _e('Show Recently Finished Experiments', 'nelioab'); ?> </option> <option value='<?php echo NelioABSettings::FINISHED_EXPERIMENTS_SHOW_ALL; ?> '<?php if (NelioABSettings::FINISHED_EXPERIMENTS_SHOW_ALL == NelioABSettings::show_finished_experiments()) { echo ' selected="selected"'; } ?> ><?php _e('Show All Finished Experiments', 'nelioab'); ?> </option> </select> <div class="the-descr" style="display:none;"><span class="description"><?php _e('By default, the list of experiments in our plugin shows all the experiments you defined. You may filter the experiments by status. When viewing all experiments, you can decide whether <em>finished</em> experiments should be visible or not.', 'nelioab'); ?> </span></div><?php }
private function filter_experiments($status = false) { if (!$status) { $result = array(); $filter_finished = NelioABSettings::show_finished_experiments(); foreach ($this->experiments as $exp) { if ($exp->get_status() == NelioABExperiment::STATUS_FINISHED) { if (NelioABSettings::FINISHED_EXPERIMENTS_HIDE_ALL == $filter_finished) { continue; } if (NelioABSettings::FINISHED_EXPERIMENTS_SHOW_RECENT == $filter_finished && $exp->get_days_since_finalization() > 7) { continue; } } if ($exp->get_status() != NelioABExperiment::STATUS_TRASH) { array_push($result, $exp); } } return $result; } else { $result = array(); foreach ($this->experiments as $exp) { if ($exp->get_status() == $status) { array_push($result, $exp); } } return $result; } }