/**
  * get the next cron run time formatted for the blog's timezone and date/time format. or 'n/a' if not available.
  *
  * * @return string date string or 'n/a'
  */
 public static function get_next_cron_time()
 {
     $date_format = sprintf('%s @ %s', get_option('date_format'), get_option('time_format'));
     $gmt_offset = 60 * 60 * get_option('gmt_offset');
     if ($next_cron_time_raw = wp_next_scheduled(self::BATCH_CRON_HOOK)) {
         return date($date_format, $next_cron_time_raw + $gmt_offset);
     } elseif (self::cron_enabled()) {
         return date($date_format, time() + Lift_Search::get_batch_interval() + $gmt_offset);
     } else {
         return 'n/a';
     }
 }
 public static function init()
 {
     if (self::error_logging_enabled() && !class_exists('Voce_Error_Logging') && file_exists(__DIR__ . '/lib/voce-error-logging/voce-error-logging.php')) {
         require_once __DIR__ . '/lib/voce-error-logging/voce-error-logging.php';
     }
     if (self::get_search_endpoint() && self::get_override_search()) {
         add_action('init', array('Lift_WP_Search', 'init'));
     }
     if (self::get_document_endpoint()) {
         add_action('init', array('Lift_Batch_Handler', 'init'), 9);
         add_action('lift_post_changes_to_data', array(__CLASS__, '_default_extended_post_data'), 10, 3);
     }
     if (is_admin()) {
         require_once __DIR__ . '/admin/admin.php';
         $admin = new Lift_Admin();
         $admin->init();
     }
     add_action('init', array(__CLASS__, '_upgrade_check'));
     //need cron hooks to be set prior to init
     add_action(Lift_Batch_Handler::BATCH_CRON_HOOK, array('Lift_Batch_Handler', 'send_next_batch'));
     add_action(Lift_Batch_Handler::QUEUE_ALL_CRON_HOOK, array('Lift_Batch_Handler', 'process_queue_all'));
     // @TODO only enqueue on search template or if someone calls the form
     add_action('wp_enqueue_scripts', function () {
         wp_enqueue_script('lift-search-form', plugins_url('js/lift-search-form.js', __FILE__), array('jquery'), '0.2', true);
         wp_enqueue_style('lift-search', plugins_url('css/style.css', __FILE__));
     });
     //default sdf filters
     add_filter('lift_document_fields_result', function ($fields, $post_id) {
         $taxonomies = array('post_tag', 'category');
         foreach ($taxonomies as $taxonomy) {
             if (array_key_exists('taxonomy_' . $taxonomy, $fields)) {
                 unset($fields['taxonomy_' . $taxonomy]);
                 $terms = get_the_terms($post_id, $taxonomy);
                 $fields['taxonomy_' . $taxonomy . '_id'] = array();
                 $fields['taxonomy_' . $taxonomy . '_label'] = array();
                 foreach ($terms as $term) {
                     $fields['taxonomy_' . $taxonomy . '_id'][] = $term->term_id;
                     $fields['taxonomy_' . $taxonomy . '_label'][] = $term->name;
                 }
             }
         }
         if (array_key_exists('post_author', $fields)) {
             $display_name = get_user_meta($fields['post_author'], 'display_name', true);
             if ($display_name) {
                 $fields['post_author_name'] = $display_name;
             }
         }
         return $fields;
     }, 10, 2);
     add_filter('cron_schedules', function ($schedules) {
         if (Lift_Search::get_batch_interval() > 0) {
             $interval = Lift_Search::get_batch_interval();
         } else {
             $interval = DAY_IN_SECONDS;
         }
         $schedules[Lift_Batch_Handler::CRON_INTERVAL] = array('interval' => $interval, 'display' => '');
         return $schedules;
     });
 }