51 lines
1.4 KiB
PHP
51 lines
1.4 KiB
PHP
<?php
|
|
|
|
$options = getopt("", ["candidates-files:", "lga-files:"]);
|
|
|
|
if (isset($options['candidates-files'])) {
|
|
$candidates_files = explode(" ", $options['candidates-files']);
|
|
} else {
|
|
error_log("Error: Missing required option '--candidates-files'.");
|
|
exit(1);
|
|
}
|
|
|
|
if (isset($options['lga-files'])) {
|
|
$lga_files = explode(" ", $options['lga-files']);
|
|
} else {
|
|
error_log("Error: Missing required option '--lga-files'.");
|
|
exit(1);
|
|
}
|
|
|
|
$lgas_with_data = [];
|
|
foreach ($candidates_files as $file) {
|
|
$lgas_with_data[] = basename(dirname($file));
|
|
}
|
|
|
|
print('<!-- wp:list --> <ul class="wp-block-list">' . "\n");
|
|
|
|
foreach ($lga_files as $config_file) {
|
|
$config_string = file_get_contents($config_file);
|
|
|
|
if ($config_string !== FALSE) {
|
|
$config = json_decode($config_string, true);
|
|
} else {
|
|
error_log("Error opening config.json.");
|
|
exit(1);
|
|
}
|
|
|
|
if (array_search($config['slug'], $lgas_with_data) === false)
|
|
$font_weight = 300;
|
|
else
|
|
$font_weight = 700;
|
|
|
|
print('<!-- wp:list-item {"style":{"typography":{"fontStyle":"normal","fontWeight":"');
|
|
print($font_weight . '"}}} -->' . "\n");
|
|
print('<li style="font-style:normal;font-weight:' . $font_weight . '">');
|
|
print('<a href="' . $config['slug'] . '">' . $config['divisionName'] . "</a></li>\n");
|
|
print('<!-- /wp:list-item -->' . "\n");
|
|
}
|
|
|
|
print('</ul> <!-- /wp:list -->');
|
|
|
|
exit(0);
|