public function enqueue_scripts($page)
 {
     // only enqueue for location pages
     if (preg_match('/hoo(-location)?/i', $page)) {
         wp_enqueue_style('location-admin');
         wp_enqueue_style('thickbox');
         wp_enqueue_script('location-image');
         if (Utils::check_user_role('administrator')) {
             // only enqueue if we need to
             wp_enqueue_script('location-visibility');
             wp_enqueue_script('location-delete');
             wp_enqueue_script('location-order');
         }
     }
 }
 public static function uninstall()
 {
     if (!Utils::check_user_role('administrator')) {
         return;
     }
     $instance = self::init();
     /*
       register enum as a type as some tables in wp use enums
       this is needed for http://www.doctrine-project.org/jira/browse/DDC-1273
       more info: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/cookbook/mysql-enums.html
     */
     $platform = $instance->entity_manager->getConnection()->getDatabasePlatform();
     $platform->registerDoctrineTypeMapping('enum', 'string');
     $schema_tool = new \Doctrine\ORM\Tools\SchemaTool($instance->entity_manager);
     $schema_manager = $instance->entity_manager->getConnection()->getSchemaManager();
     $classes = array_map(function ($class_name) use($instance) {
         return $instance->entity_manager->getClassMetadata($class_name);
     }, array_values($instance->tables));
     $schema_tool->dropSchema($classes);
 }
                <?php 
    echo $location_data['location']->name;
    ?>
            </a>
        </td>
        <td class="location-status">
            <?php 
    if (is_null($current_hours)) {
        ?>
                <span class="na">N/A</span>
            <?php 
    } elseif (is_object($current_hours)) {
        ?>
                <span class="open">Open</span>
                <span class="until">Until <?php 
        echo \Hoo\Utils::format_time($current_hours);
        ?>
 </span>
            <?php 
    } elseif (is_string($current_hours)) {
        ?>
                <span class="open">Open</span>
                <span class="all-day"><?php 
        echo $current_hours;
        ?>
</span>
            <?php 
    } else {
        ?>
                <span class="closed">Closed</span>
            <?php 
<span class="hoo-today">
    <?php 
if (is_null($this['current_hours'])) {
    ?>
        <span class="na">N/A</span>
    <?php 
} elseif (is_object($this['current_hours'])) {
    ?>
        <span class="open">Open</span>
        <span class="until">Until <?php 
    echo \Hoo\Utils::format_time($this['current_hours']);
    ?>
 </span>
    <?php 
} elseif (is_string($this['current_hours'])) {
    ?>
        <span class="open">Open</span>
        <span class="all-day"><?php 
    echo $this['current_hours'];
    ?>
</span>
    <?php 
} else {
    ?>
        <span class="closed">Closed</span>
    <?php 
}
?>
</span>
 public function column_is_visible($location)
 {
     $checked = $location->is_visible ? 'checked' : '';
     $enabled = Utils::check_user_role('administrator') ? '' : 'disabled';
     return sprintf('<input class="location_is_visible" type="checkbox" data-location-id="%s" %s %s/>', $location->id, $checked, $enabled);
 }
 public function get_fullcalendar_events($params, $entity_manager, $with_title = true)
 {
     // TODO: convert this to how the is_open/get_instances works
     $rrule_transformer = new RRuleTransformer();
     $cal_start = new \Datetime($params['start']);
     $cal_end = new \DateTime($params['end']);
     $event_instances = array();
     $event_dates = array();
     if (isset($params['event']['id']) && empty($params['event']['id'])) {
         $current_event = new Event();
         $this->events->add($current_event);
     }
     foreach ($this->events as $event) {
         if (isset($params['event']['id']) && $params['event']['id'] == $event->id) {
             $event->fromParams($params, $entity_manager);
         } else {
             if ($event->is_recurring) {
                 $event->recurrence_rule = new RRule($event->recurrence_rule, $event->start, $event->end);
             } else {
                 $event->recurrence_rule = new RRule(null, $event->start, $event->end);
             }
         }
         if (!$event->is_visible) {
             continue;
         }
         // get all recurrences
         $cal_range = new BetweenConstraint($cal_start, $cal_end, true);
         $recurrences = $rrule_transformer->transform($event->recurrence_rule, 60, $cal_range)->toArray();
         foreach ($recurrences as $recurrence) {
             $event_instances[] = array('event' => $event, 'recurrence' => $recurrence);
         }
     }
     $event_instances = Utils::remove_overlapping_events($event_instances);
     // TODO: refactor the 24 hours / formatting as it is gross
     $events = array();
     foreach ($event_instances as $instance) {
         $prev_all_day = Utils::prev_was_all_day($instance, $event_instances);
         $next_all_day = Utils::next_is_all_day($instance, $event_instances);
         if ($prev_all_day && $next_all_day) {
             $title = $with_title ? $instance['event']->title . "\n" : '';
             $title .= Utils::format_time($instance['recurrence']->getStart(), $instance['recurrence']->getEnd());
         } elseif ($prev_all_day) {
             $title = sprintf("%s24 Hours -\n%s", $with_title ? $instance['event']->title . "\n" : '', Utils::format_time($instance['recurrence']->getEnd()));
         } elseif ($next_all_day) {
             $title = sprintf("%s%s -\n24 Hours", $with_title ? $instance['event']->title . "\n" : '', Utils::format_time($instance['recurrence']->getStart()));
         } elseif ($instance['event']->is_all_day) {
             $title = sprintf("%sOpen\n24 Hours", $with_title ? $instance['event']->title . "\n" : '');
         } elseif ($instance['event']->is_closed) {
             $title = sprintf("%sClosed", $with_title ? $instance['event']->title . "\n" : '');
         } else {
             $title = $with_title ? $instance['event']->title . "\n" : '';
             $title .= Utils::format_time($instance['recurrence']->getStart(), $instance['recurrence']->getEnd());
         }
         $events[] = array('id' => $instance['event']->id, 'title' => $title, 'start' => $instance['recurrence']->getStart()->format(\DateTime::ISO8601), 'end' => $instance['recurrence']->getEnd()->format(\DateTime::ISO8601), 'color' => $instance['event']->category->color);
     }
     return $events;
 }