← All changes
|
admin/class-convertkit-admin-legacy-resource-notice.php
+43
-0
3.3.8
→
3.4.4
View file →
| @@ -216,8 +216,51 @@ | ||
| 216 | 216 | |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | /** |
| 220 | + * Returns an array of warning strings for the Plugin's General Settings, | |
| 221 | + * when one or more Default Form settings reference Legacy Forms. | |
| 222 | + * | |
| 223 | + * @since 3.3.9 | |
| 224 | + * | |
| 225 | + * @param array $settings Plugin settings array. | |
| 226 | + * @return array | |
| 227 | + */ | |
| 228 | + public function get_legacy_warnings_for_plugin_settings( $settings ) { | |
| 229 | + | |
| 230 | + // Get Forms resource. | |
| 231 | + $forms = new ConvertKit_Resource_Forms(); | |
| 232 | + | |
| 233 | + // Initialize warnings array. | |
| 234 | + $warnings = array(); | |
| 235 | + | |
| 236 | + // Check each supported Post Type's Default Form setting. | |
| 237 | + foreach ( convertkit_get_supported_post_types() as $supported_post_type ) { | |
| 238 | + // Get Post Type object. | |
| 239 | + $post_type = get_post_type_object( $supported_post_type ); | |
| 240 | + if ( ! $post_type ) { | |
| 241 | + continue; | |
| 242 | + } | |
| 243 | + | |
| 244 | + // Get Default Form setting. | |
| 245 | + $setting_key = $supported_post_type . '_form'; | |
| 246 | + if ( empty( $settings[ $setting_key ] ) || ! $forms->is_legacy( $settings[ $setting_key ] ) ) { | |
| 247 | + continue; | |
| 248 | + } | |
| 249 | + | |
| 250 | + $warnings[] = sprintf( | |
| 251 | + /* translators: 1: Post Type name, plural; 2: Form name */ | |
| 252 | + __( 'Default Form (%1$s): %2$s', 'convertkit' ), | |
| 253 | + $post_type->label, | |
| 254 | + $this->get_form_display_name( $settings[ $setting_key ], $forms ) | |
| 255 | + ); | |
| 256 | + } | |
| 257 | + | |
| 258 | + return $warnings; | |
| 259 | + | |
| 260 | + } | |
| 261 | + | |
| 262 | + /** | |
| 220 | 263 | * Resolves the form ID to a human-readable "Form Name" string, falling |
| 221 | 264 | * back to "a Legacy Form" when the resource isn't cached. |
| 222 | 265 | * |
| 223 | 266 | * @since 3.3.7 |