Adds a block that lets users subscribe to newsletters. Integrates with newsletter providers. Currently supports:
Go to settings>teft>newsletter, pick your newsletter provider and provide any neccessary credentials.
NOTE: It is recommended to add the API key to your config files, instead of the database. You can define the constant based on your provider:
MAILCHIMP_API_KEY
ACTIVECAMPAIGN_API_KEY
GETYNET_API_KEY
APSIS_API_KEY
Add the “Newsletter”-block to a page. The block sidebar let’s you pick what list to subscribe to and what fields to include.
Uses --teft-theme-primary-color
, --teft-form-input-height
and --teft-form-input-padding-left
in addition to theme widths and teft typography.
Currently none
You can configure the available options using
wp.domReady( () => {
wp.hooks.addFilter( 'teft-newsletter-config', 'teft', ( config ) => {
config.controllers = {};
return config;
}, 1 );
} );
inside of your theme editor js.
Available controller options:
image: boolean (default: true)
name: boolean (default: true)
phone: boolean (default: true)
optin: boolean (default: true)
toggleInfo: boolean (default: true)
The Teft Options-wrapper
While the default method of adding the newsletter block to pages is via the Gutenberg block, it is possible to add in php templates if you configure the settings and content in settings>teft>newsletter. An example of this would be if you wanted to add it to an archive page or other template that does not use the block editor.
if ( function_exists( '\Teft\Newsletter\render' ) ) {
echo \Teft\Newsletter\render( [
'align' => 'wide',
'name' => true,
] );
}
The example above adds a wide newsletter block, which includes a name field in addition to the email field. The rest of the content is populated based on defaults from the teft settings page, but you could add extra arguments to override it.
Here is an overview of the available arguments: align: ‘wide’ or ‘full’ list: the list ID from MailChimp mediaPosition: ‘left’ or ‘right’ media: the url of an image you wish to include image: true or false, to show/hide image name: true of false, to show/hide the name field lastName: true of false, to show/hide the last name field (note: you need to set name to true as well) successMessage: the success message to display to the user toggleInfo: a paragraph of text that appears in an optional tooltip beside the submit button title: the form title p: text to appear above the form
Newsletter providers can be added by creating a new entry in the inc/provider
directory that extend the Teft\Newsletter\Provider\Newsletter_Base
class.
Once your class is ready, include it inside the teft-newsletter.php
file under the Newsletter providers section.