// Schedule cron (once) add_action('init', function () { if (! wp_next_scheduled('update_tablepress_from_sheets')) { wp_schedule_event(time(), 'hourly', 'update_tablepress_from_sheets'); } }); // Cron callback – NO CLOSURE function stator_update_tablepress_from_sheets() { $table_id = '3'; $csv_url = 'https://docs.google.com/spreadsheets/d/e/2PACX-1vThxWxuxVZIkrQKTy72jfe2dqI48SRq9cAO5it-rdhBjimLHPmhA04YfP9wR-Xq3FtZm2wMDZz507iz/pub?output=csv'; $response = wp_remote_get($csv_url); if (is_wp_error($response)) { error_log('TablePress Sync Error: ' . $response->get_error_message()); return; } $csv_data = wp_remote_retrieve_body($response); if (empty($csv_data)) { error_log('TablePress Sync Error: Empty CSV'); return; } $rows = array_map('str_getcsv', explode("\n", trim($csv_data))); if (class_exists('TablePress')) { $model_table = TablePress::$model_table; $model_table->save(array( 'id' => $table_id, 'data' => $rows, )); } } add_action('update_tablepress_from_sheets', 'stator_update_tablepress_from_sheets');
| 61 | Lamela 1 - Stan broj 61 - garsonjera 28,19m² | Prodat | ||
| 62 | Lamela 1 - Stan broj 62 - dvosoban 41,72m² | Prodat | ||
| 63 | Lamela 1 - Stan broj 63 - dvosoban 35,66m² | Za prodaju | ||
| 64 | Lamela 1 - Stan broj 64 - dvosoban 42,99m² | Prodat | ||
| 65 | Lamela 1 - Stan broj 65 - dvosoban 44,12m² | Za prodaju | ||
| 66 | Lamela 1 - Stan broj 66 - dvosoban 47,14m² | Za prodaju | ||
| 67 | Lamela 1 - Stan broj 67 - trosoban 58,40m² | Prodat | ||
| 68 | Lamela 1 - Stan broj 68 - dvosoban 45,08m² | Za prodaju | ||
| 69 | Lamela 1 - Stan broj 69 - dvosoban 37,55m² | Za prodaju | ||
| 70 | Lamela 1 - Stan broj 70 - dvosoban 34,89m² | Za prodaju |