File: //proc/self/root/tmp/create-vff-page.php
<?php
/**
* Create Vermont Farm Fund page with donate-vff block content.
* Run via: wp eval-file create-vff-page.php
*/
// Check for existing page
$existing = get_page_by_path('support-cae/donate/vermont-farm-fund');
if ($existing) {
WP_CLI::warning("Page already exists (ID: {$existing->ID}). Updating content.");
$page_id = $existing->ID;
} else {
$page_id = null;
}
// Block content — hero + donate-vff + cta
$block_content = '<!-- wp:acf/hero {"name":"acf/hero","data":{"hero_heading":"VERMONT FARM FUND","_hero_heading":"field_hero_heading","hero_description":"Support Vermont farmers and food producers.","_hero_description":"field_hero_description"},"mode":"preview"} /-->
<!-- wp:acf/donate-vff {"name":"acf/donate-vff","data":{},"mode":"preview"} /-->
<!-- wp:acf/cta {"name":"acf/cta","data":{"cta_heading":"GET INVOLVED","_cta_heading":"field_cta_heading","cta_description":"Learn more about ways you can support CAE.","_cta_description":"field_cta_description"},"mode":"preview"} /-->';
$page_data = [
'post_title' => 'Vermont Farm Fund',
'post_name' => 'vermont-farm-fund',
'post_content' => $block_content,
'post_status' => 'publish',
'post_type' => 'page',
'post_parent' => 45, // Donate page
];
if ($page_id) {
$page_data['ID'] = $page_id;
wp_update_post($page_data);
WP_CLI::success("Updated page ID: $page_id");
} else {
$page_id = wp_insert_post($page_data);
if (is_wp_error($page_id)) {
WP_CLI::error("Failed to create page: " . $page_id->get_error_message());
}
WP_CLI::success("Created page ID: $page_id");
}
// Now populate ACF fields directly via update_field()
// This is more reliable than inline block JSON for complex data
// Tabs
$tabs = [
['tab_label' => 'Donate', 'tab_link' => ['url' => '/support-cae/donate/', 'title' => 'Donate', 'target' => ''], 'tab_active' => 1],
['tab_label' => 'The Different Ways to Give', 'tab_link' => ['url' => '/support-cae/', 'title' => 'Ways to Give', 'target' => ''], 'tab_active' => 0],
];
update_field('vff_tabs', $tabs, $page_id);
// Subtabs
$subtabs = [
['subtab_label' => 'General', 'subtab_link' => ['url' => '/support-cae/donate/', 'title' => 'General', 'target' => ''], 'subtab_active' => 0],
['subtab_label' => 'Vermont Farm Fund', 'subtab_link' => ['url' => '/support-cae/donate/vermont-farm-fund/', 'title' => 'Vermont Farm Fund', 'target' => ''], 'subtab_active' => 1],
];
update_field('vff_subtabs', $subtabs, $page_id);
// Content with Image
update_field('vff_content_image', 48, $page_id); // content-image.jpg
update_field('vff_content_heading', 'YOUR DONATION CAN SUPPORT MANY LOANS', $page_id);
update_field('vff_content_description', '<p>Giving to the <strong>Vermont Farm Fund</strong> presents a unique opportunity to watch your donation support multiple Vermont farmers and food producers, one after another. Your contribution can be bundled with funds from other donors to make an initial loan to help sustain and grow the Vermont agricultural economy. As that loan is repaid, monies go back into the pool to be lent back out again and again.</p>', $page_id);
// Donation Section
update_field('vff_donate_bg_image', 49, $page_id); // donate-bg.jpg
update_field('vff_donate_heading', 'SUPPORT THE FUND', $page_id);
update_field('vff_donate_tax_notice', 'All donations are tax deductible to the fullest extent allowed by law. Our federal Tax ID Number is 57-1201683.', $page_id);
// Donation Methods
$methods = [
[
'method_icon' => '',
'method_title' => 'Donate Online',
'method_description' => '<p>Make a tax-free donation today.</p>',
'method_button' => ['url' => '#donate-online', 'title' => 'Donate Now', 'target' => ''],
],
[
'method_icon' => '',
'method_title' => 'Donate via Your Charitable Fund',
'method_description' => '<p>You can also donate through your charitable fund <a href="https://www.dafdirect.org/DAFDirect/daflink?_dafdirect_settings=NTcxMjAxNjgzXzIxMTFfMTNjMTY0NzUtZDMyOC00YzNjLThhYTQtNzQ0MGY5OTQ1ODQy&designatedText=VmVybW9udCBGYXJtIEZ1bmQ=&amountValue=" target="_blank"><strong>via DAF Direct</strong></a>.</p>',
'method_button' => ['url' => 'https://www.dafdirect.org/DAFDirect/daflink?_dafdirect_settings=NTcxMjAxNjgzXzIxMTFfMTNjMTY0NzUtZDMyOC00YzNjLThhYTQtNzQ0MGY5OTQ1ODQy&designatedText=VmVybW9udCBGYXJtIEZ1bmQ=&amountValue=', 'title' => 'Donate Now', 'target' => '_blank'],
],
[
'method_icon' => '',
'method_title' => 'Mail a Check',
'method_description' => '<p>If you\'d prefer to send a check or make a large donation, please address it to <strong>Vermont Farm Fund</strong>. <strong>Mail to:</strong></p><p>Vermont Farm Fund, c/o Center for an Agricultural Economy, PO Box 422, 140 Junction Road, Hardwick, VT 05843.</p>',
'method_button' => ['url' => '#mail-check', 'title' => 'Donate Now', 'target' => ''],
],
];
update_field('vff_donate_methods', $methods, $page_id);
// Testimonial
update_field('vff_testimonial_image', 50, $page_id); // testimonial-image.jpg
update_field('vff_testimonial_quote', 'Knowing that my donation dollars support farmers to improve their operation gives me the satisfaction that I am a part of their success. Enhancing access to local food is what it is all about!', $page_id);
update_field('vff_testimonial_name', 'Joe Goldstein', $page_id);
update_field('vff_testimonial_title', 'Donor', $page_id);
WP_CLI::success("All ACF fields populated for page $page_id");
WP_CLI::log("URL: /support-cae/donate/vermont-farm-fund/");
WP_CLI::log("NOTE: Method icons (SVG) need manual upload — WordPress blocked SVG mime type.");