diff --git a/classes/controllers/FrmHooksController.php b/classes/controllers/FrmHooksController.php index 932cae769c..ee50affb10 100644 --- a/classes/controllers/FrmHooksController.php +++ b/classes/controllers/FrmHooksController.php @@ -86,7 +86,7 @@ public static function load_hooks() { add_action( 'wp_scheduled_delete', 'FrmForm::scheduled_delete' ); // Clear embed posts transient when posts are updated. - add_action( 'wp_insert_post', 'FrmFormsListHelper::maybe_clear_embed_posts_transient', 10, 2 ); + add_action( 'wp_insert_post', 'FrmFormsHelper::maybe_clear_embed_posts_transient', 10, 2 ); // Form Shortcodes. add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' ); diff --git a/classes/helpers/FrmAppHelper.php b/classes/helpers/FrmAppHelper.php index 7d1532ea75..22f54185c0 100644 --- a/classes/helpers/FrmAppHelper.php +++ b/classes/helpers/FrmAppHelper.php @@ -10,7 +10,7 @@ class FrmAppHelper { * * @var int */ - public static $db_version = 106; + public static $db_version = 107; /** * Used by the API add-on. diff --git a/classes/helpers/FrmFormsHelper.php b/classes/helpers/FrmFormsHelper.php index a4749e02a4..f958e31421 100644 --- a/classes/helpers/FrmFormsHelper.php +++ b/classes/helpers/FrmFormsHelper.php @@ -5,6 +5,19 @@ class FrmFormsHelper { + /** + * The transient name that stores data for which posts a form is embedded in. + * + * It lives here rather than in FrmFormsListHelper so the invalidation callback below can run + * without autoloading that admin list table on a front end post insert. + * + * @since 6.32 + * @since 6.35 Moved here from FrmFormsListHelper. + * + * @var string + */ + const EMBED_POSTS_TRANSIENT = 'frm_posts_contain_form'; + /** * Store and re-use field type data for the insert_opt_html function (to avoid multiple calls to FrmField::all_field_selection). * @@ -2205,4 +2218,40 @@ public static function get_form_name( $form, $length = 0 ) { return FrmAppHelper::truncate( $form_name, $length ); } + + /** + * Maybe clear the embed posts transient. + * + * @since 6.32 + * @since 6.35 Moved here from FrmFormsListHelper. + * + * @param int $post_id Post ID. + * @param WP_Post $post Post object. + * + * @return void + */ + public static function maybe_clear_embed_posts_transient( $post_id, $post ) { + if ( str_contains( $post->post_content, '[formidable ' ) || str_contains( $post->post_content, '