Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion admin/section/class-convertkit-admin-section-general.php
Original file line number Diff line number Diff line change
Expand Up @@ -695,8 +695,19 @@ public function maybe_initialize_and_refresh_resources() {
return;
}

// Also refresh Landing Pages, Tags and Posts. Whilst not displayed in the Plugin Settings, this ensures up to date
// Also refresh other resources. Whilst not displayed in the Plugin Settings, this ensures up to date
// lists are stored for when editing e.g. Pages.

// Refresh Custom Fields.
$custom_fields = new ConvertKit_Resource_Custom_Fields( 'settings' );
$result = $custom_fields->refresh();

// Bail if an error occured.
if ( is_wp_error( $result ) ) {
return;
}

// Refresh Landing Pages.
$landing_pages = new ConvertKit_Resource_Landing_Pages( 'settings' );
$result = $landing_pages->refresh();

Expand All @@ -705,6 +716,7 @@ public function maybe_initialize_and_refresh_resources() {
return;
}

// Refresh Posts.
remove_all_actions( 'convertkit_resource_refreshed_posts' );
$posts = new ConvertKit_Resource_Posts( 'settings' );
$result = $posts->refresh();
Expand All @@ -714,6 +726,7 @@ public function maybe_initialize_and_refresh_resources() {
return;
}

// Refresh Products.
$products = new ConvertKit_Resource_Products( 'settings' );
$result = $products->refresh();

Expand All @@ -722,6 +735,7 @@ public function maybe_initialize_and_refresh_resources() {
return;
}

// Refresh Sequences.
$sequences = new ConvertKit_Resource_Sequences( 'settings' );
$result = $sequences->refresh();

Expand All @@ -730,6 +744,7 @@ public function maybe_initialize_and_refresh_resources() {
return;
}

// Refresh Tags.
$tags = new ConvertKit_Resource_Tags( 'settings' );
$result = $tags->refresh();

Expand Down
59 changes: 59 additions & 0 deletions tests/Support/Helper/KitPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -511,12 +511,62 @@ public function setupKitPluginResources($I)
]
);

// Define Custom Fields.
$I->haveOptionInDatabase(
'convertkit_custom_fields',
[
1075083 => [
'id' => 1075083,
'name' => 'ck_field_1075083_url',
'key' => 'url',
'label' => 'URL',
],
276295 => [
'id' => 276295,
'name' => 'ck_field_276295_payment_method',
'key' => 'payment_method',
'label' => 'Payment Method',
],
276273 => [
'id' => 276273,
'name' => 'ck_field_276273_billing_address',
'key' => 'billing_address',
'label' => 'Billing Address',
],
276272 => [
'id' => 276272,
'name' => 'ck_field_276272_shipping_address',
'key' => 'shipping_address',
'label' => 'Shipping Address',
],
276271 => [
'id' => 276271,
'name' => 'ck_field_276271_phone_number',
'key' => 'phone_number',
'label' => 'Phone Number',
],
264073 => [
'id' => 264073,
'name' => 'ck_field_264073_last_name',
'key' => 'last_name',
'label' => 'Last Name',
],
258240 => [
'id' => 258240,
'name' => 'ck_field_258240_notes',
'key' => 'notes',
'label' => 'Notes',
],
]
);

// Define last queried to now for all resources, so they're not automatically immediately refreshed by the Plugin's logic.
$I->haveOptionInDatabase( 'convertkit_forms_last_queried', strtotime( 'now' ) );
$I->haveOptionInDatabase( 'convertkit_landing_pages_last_queried', strtotime( 'now' ) );
$I->haveOptionInDatabase( 'convertkit_posts_last_queried', strtotime( 'now' ) );
$I->haveOptionInDatabase( 'convertkit_products_last_queried', strtotime( 'now' ) );
$I->haveOptionInDatabase( 'convertkit_tags_last_queried', strtotime( 'now' ) );
$I->haveOptionInDatabase( 'convertkit_custom_fields_last_queried', strtotime( 'now' ) );
}

/**
Expand Down Expand Up @@ -560,12 +610,19 @@ public function setupKitPluginResourcesNoData($I)
[]
);

// Define Custom Fields.
$I->haveOptionInDatabase(
'convertkit_custom_fields',
[]
);

// Define last queried to now for all resources, so they're not automatically immediately refreshed by the Plugin's logic.
$I->haveOptionInDatabase( 'convertkit_forms_last_queried', strtotime( 'now' ) );
$I->haveOptionInDatabase( 'convertkit_landing_pages_last_queried', strtotime( 'now' ) );
$I->haveOptionInDatabase( 'convertkit_posts_last_queried', strtotime( 'now' ) );
$I->haveOptionInDatabase( 'convertkit_products_last_queried', strtotime( 'now' ) );
$I->haveOptionInDatabase( 'convertkit_tags_last_queried', strtotime( 'now' ) );
$I->haveOptionInDatabase( 'convertkit_custom_fields_last_queried', strtotime( 'now' ) );
}

/**
Expand Down Expand Up @@ -596,6 +653,8 @@ public function resetKitPlugin($I)
$I->dontHaveOptionInDatabase('convertkit_products_last_queried');
$I->dontHaveOptionInDatabase('convertkit_tags');
$I->dontHaveOptionInDatabase('convertkit_tags_last_queried');
$I->dontHaveOptionInDatabase('convertkit_custom_fields');
$I->dontHaveOptionInDatabase('convertkit_custom_fields_last_queried');

// Persistent notices.
$I->dontHaveOptionInDatabase('convertkit-admin-notices');
Expand Down