: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
// Return the modified content.
return $modified_content;
* Get the list of available email templates.
* Given a template name, this method will return the template data.
* If no template name is provided, all available templates will be returned.
* Templates will go through a conditional check to make sure they are available for the current plugin edition.
* @param string $template Template name. If empty, all available templates will be returned.
public static function get_available_templates( $template = '' ) {
$templates = self::get_all_templates();
// Filter the list of available email templates based on the edition of WPForms.
if ( ! wpforms()->is_pro() ) {
$templates = array_filter(
static function ( $instance ) {
return ! $instance['is_pro'];
return isset( $templates[ $template ] ) ? $templates[ $template ] : $templates;
* Get the list of all email templates.
* Given the name of a template, this method will return the template data.
* If the template is not found, all available templates will be returned.
* @param string $template Template name. If empty, all templates will be returned.
public static function get_all_templates( $template = '' ) {
'name' => esc_html__( 'Classic', 'wpforms-lite' ),
'path' => __NAMESPACE__ . '\Templates\Classic',
'name' => esc_html__( 'Compact', 'wpforms-lite' ),
'path' => __NAMESPACE__ . '\Templates\Compact',
'name' => esc_html__( 'Modern', 'wpforms-lite' ),
'path' => 'WPForms\Pro\Emails\Templates\Modern',
'name' => esc_html__( 'Elegant', 'wpforms-lite' ),
'path' => 'WPForms\Pro\Emails\Templates\Elegant',
'name' => esc_html__( 'Tech', 'wpforms-lite' ),
'path' => 'WPForms\Pro\Emails\Templates\Tech',
'name' => esc_html__( 'Plain Text', 'wpforms-lite' ),
'path' => __NAMESPACE__ . '\Templates\Plain',
// Make sure the current user can preview templates.
if ( wpforms_current_user_can() ) {
// Add a preview key to each template.
foreach ( $templates as $key => &$tmpl ) {
$tmpl['preview'] = wp_nonce_url(
'wpforms_email_preview' => '1',
'wpforms_email_template' => $key,
Preview::PREVIEW_NONCE_NAME
// Make sure to unset the reference to avoid unintended changes later.
return isset( $templates[ $template ] ) ? $templates[ $template ] : $templates;