defined('MLSGRID_API_URL') ? MLSGRID_API_URL : 'https://api.mlsgrid.com/v2', 'originating_system' => 'northstar', 'auto_sync_enabled' => false, 'sync_interval' => 'hourly', 'sync_media' => true, ); $existing = get_option(MLS_Options::OPTION_KEY, array()); $merged = wp_parse_args($existing, $defaults); update_option(MLS_Options::OPTION_KEY, $merged); } /** * Schedule cron events */ private static function schedule_cron() { // Register custom cron intervals add_filter('cron_schedules', array(__CLASS__, 'add_cron_intervals')); // Only schedule if auto-sync is enabled $options = get_option(MLS_Options::OPTION_KEY, array()); if (empty($options['auto_sync_enabled'])) { return; } $interval = !empty($options['sync_interval']) ? $options['sync_interval'] : 'hourly'; if (!wp_next_scheduled('mls_sync_properties')) { wp_schedule_event(time(), $interval, 'mls_sync_properties'); } if (!wp_next_scheduled('mls_sync_media')) { wp_schedule_event(time() + 1800, $interval, 'mls_sync_media'); } } /** * Add custom cron intervals * * @param array $schedules Existing schedules * @return array Modified schedules */ public static function add_cron_intervals($schedules) { $schedules['every_30_minutes'] = array( 'interval' => 1800, 'display' => 'Every 30 Minutes', ); $schedules['every_2_hours'] = array( 'interval' => 7200, 'display' => 'Every 2 Hours', ); $schedules['every_6_hours'] = array( 'interval' => 21600, 'display' => 'Every 6 Hours', ); $schedules['every_12_hours'] = array( 'interval' => 43200, 'display' => 'Every 12 Hours', ); return $schedules; } /** * Create upload directory for MLS media */ private static function create_upload_dir() { $upload_dir = wp_upload_dir(); $mls_dir = $upload_dir['basedir'] . '/mls-listings'; if (!file_exists($mls_dir)) { wp_mkdir_p($mls_dir); // Create .htaccess to prevent directory listing $htaccess = $mls_dir . '/.htaccess'; if (!file_exists($htaccess)) { file_put_contents($htaccess, "Options -Indexes\n"); } // Create index.php for extra protection $index = $mls_dir . '/index.php'; if (!file_exists($index)) { file_put_contents($index, "