diff --git a/classes/controllers/FrmFormsController.php b/classes/controllers/FrmFormsController.php index 49de781bdc..f2ea29b285 100644 --- a/classes/controllers/FrmFormsController.php +++ b/classes/controllers/FrmFormsController.php @@ -1232,6 +1232,8 @@ public static function get_settings_vars( $id, $errors = array(), $args = array( global $frm_vars; + self::maybe_print_media_templates(); + if ( ! is_array( $args ) ) { // For reverse compatibility. $args = array( @@ -1269,6 +1271,27 @@ public static function get_settings_vars( $id, $errors = array(), $args = array( require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php'; } + /** + * Print WordPress media templates email actions does not trigger a "Uncaught Error: Template not found: #tmpl-media-selection" error when the media button is clicked. + * + * @since x.x + * + * @return void + */ + private static function maybe_print_media_templates() { + if ( FrmAppHelper::pro_is_included() ) { + // This issue does not exist when Pro is active so exit early. + return; + } + + add_action( + 'wp_enqueue_editor', + function () { + wp_print_media_templates(); + } + ); + } + /** * @since 4.0 */