: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* @copyright Copyright (c) 2023, Code Atlantic LLC
if ( ! defined( 'ABSPATH' ) ) {
* Class PUM_Shortcode_Subscribe
class PUM_Shortcode_Subscribe extends PUM_Shortcode {
public $ajax_rendering = true;
public function label() {
return __( 'Subscription Form', 'popup-maker' );
public function description() {
return __( 'A customizable newsletter subscription form.', 'popup-maker' );
public function post_types() {
return [ 'page', 'post', 'popup' ];
'general' => __( 'General', 'popup-maker' ),
'form' => __( 'Form', 'popup-maker' ),
'privacy' => __( 'Privacy', 'popup-maker' ),
'actions' => __( 'Actions', 'popup-maker' ),
$tabs = apply_filters( 'pum_sub_form_shortcode_sections', $tabs );
$tabs = apply_filters( 'pum_sub_form_shortcode_tabs', $tabs );
return $this->resort_provider_tabs( $tabs );
public function subtabs() {
$subtabs = apply_filters(
'pum_sub_form_shortcode_subtabs',
'main' => __( 'General', 'popup-maker' ),
'main' => __( 'General', 'popup-maker' ),
'appearance' => __( 'Appearance', 'popup-maker' ),
'fields' => __( 'Fields', 'popup-maker' ),
'labels' => __( 'Labels', 'popup-maker' ),
'placeholders' => __( 'Placeholders', 'popup-maker' ),
'privacy' => __( 'Privacy', 'popup-maker' ),
'popup' => __( 'Popup', 'popup-maker' ),
'redirect' => __( 'Redirect', 'popup-maker' ),
return $this->resort_provider_tabs( $subtabs );
public function fields() {
if ( isset( $_GET['post'] ) && is_int( (int) $_GET['post'] ) && isset( $_GET['action'] ) && 'edit' === $_GET['action'] ) {
$select_args['post__not_in'] = wp_parse_id_list( [ get_the_ID(), $_GET['post'] ] );
$privacy_always_enabled = pum_get_option( 'privacy_consent_always_enabled', 'no' ) === 'yes';
$privacy_enabled_dependency = [
'privacy_consent_enabled' => 'yes',
'pum_sub_form_shortcode_fields',
'label' => __( 'Service Provider', 'popup-maker' ),
'desc' => __( 'Choose which service provider to submit to.', 'popup-maker' ),
'options' => array_merge( [ '' => __( 'Default', 'popup-maker' ) ], PUM_Newsletter_Providers::dropdown_list(), [ 'none' => __( 'None', 'popup-maker' ) ] ),
'label' => __( 'Name Field Type', 'popup-maker' ),
'disabled' => __( 'None', 'popup-maker' ),
'fullname' => __( 'Full', 'popup-maker' ),
'first_only' => __( 'First Only', 'popup-maker' ),
'first_last' => __( 'First & Last', 'popup-maker' ),
'label' => __( 'Name Optional', 'popup-maker' ),
'desc' => __( 'Makes the name field optional.', 'popup-maker' ),
'name_field_type' => [ 'fullname', 'first_only', 'first_last' ],
'label' => __( 'Name Disabled', 'popup-maker' ),
'desc' => __( 'Removes the name field.', 'popup-maker' ),
'name_field_type' => false,
'label' => __( 'Disable Labels', 'popup-maker' ),
'desc' => __( 'Disables the display of field labels.', 'popup-maker' ),
'label' => __( 'Labels', 'popup-maker' ),
'desc' => __( 'Field label text', 'popup-maker' ),
'label' => __( 'Full Name', 'popup-maker' ),
'disable_labels' => false,
'name_field_type' => [ 'fullname' ],
'std' => __( 'Name', 'popup-maker' ),
'label' => __( 'First Name', 'popup-maker' ),
'disable_labels' => false,
'name_field_type' => [ 'first_only', 'first_last' ],
'std' => __( 'First Name', 'popup-maker' ),
'label' => __( 'Last Name', 'popup-maker' ),
'disable_labels' => false,
'name_field_type' => [ 'first_last' ],
'std' => __( 'Last Name', 'popup-maker' ),
'label' => __( 'Email', 'popup-maker' ),
'disable_labels' => false,
'std' => __( 'Email', 'popup-maker' ),
'label' => __( 'Submit Button', 'popup-maker' ),
'std' => __( 'Subscribe', 'popup-maker' ),
'label' => __( 'Full Name', 'popup-maker' ),
'name_field_type' => [ 'fullname' ],
'std' => __( 'Name', 'popup-maker' ),
'label' => __( 'First Name', 'popup-maker' ),
'name_field_type' => [ 'first_only', 'first_last' ],
'std' => __( 'First Name', 'popup-maker' ),
'label' => __( 'Last Name', 'popup-maker' ),
'name_field_type' => [ 'first_last' ],
'std' => __( 'Last Name', 'popup-maker' ),
'label' => __( 'Email', 'popup-maker' ),
'std' => __( 'Email', 'popup-maker' ),
'label' => __( 'Form Layout', 'popup-maker' ),
'desc' => __( 'Choose a form layout.', 'popup-maker' ),
'block' => __( 'Block', 'popup-maker' ),
'inline' => __( 'Inline', 'popup-maker' ),
'label' => __( 'Form Alignment', 'popup-maker' ),
'desc' => __( 'Choose a form alignment.', 'popup-maker' ),
'left' => __( 'Left', 'popup-maker' ),
'center' => __( 'Center', 'popup-maker' ),
'right' => __( 'Right', 'popup-maker' ),
'label' => __( 'Form Style', 'popup-maker' ),
'desc' => __( 'Choose how you want your form styled.', 'popup-maker' ),
'' => __( 'None', 'popup-maker' ),
'default' => __( 'Default', 'popup-maker' ),
'privacy_consent_enabled' => [
'label' => __( 'Enabled', 'popup-maker' ),
'desc' => __( 'When enabled, the successful completion will result in normal success actions, but if they do not opt-in no records will be made.', 'popup-maker' ),
'type' => $privacy_always_enabled ? 'hidden' : 'select',
'yes' => __( 'Yes', 'popup-maker' ),
'no' => __( 'No', 'popup-maker' ),
'value' => $privacy_always_enabled ? 'yes' : null,
'privacy_consent_label' => [
'label' => __( 'Consent Field Label', 'popup-maker' ),
'std' => pum_get_option( 'default_privacy_consent_label', __( 'Notify me about related content and special offers.', 'popup-maker' ) ),
'dependencies' => $privacy_enabled_dependency,
'privacy_consent_required' => [
'label' => __( 'Consent Required', 'popup-maker' ),
'desc' => __( 'Note: Requiring consent may not be compliant with GDPR for all situations. Be sure to do your research or check with legal council.', 'popup-maker' ),
'std' => pum_get_option( 'default_privacy_consent_required' ),
'dependencies' => $privacy_enabled_dependency,
'privacy_consent_type' => [
'label' => __( 'Field Type', 'popup-maker' ),
'desc' => __( 'Radio forces the user to make a choice, often resulting in more optins.', 'popup-maker' ),
'radio' => __( 'Radio', 'popup-maker' ),
'checkbox' => __( 'Checkbox', 'popup-maker' ),
'std' => pum_get_option( 'default_privacy_consent_type', 'radio' ),
'dependencies' => $privacy_enabled_dependency,
'privacy_consent_radio_layout' => [
'label' => __( 'Consent Radio Layout', 'popup-maker' ),
'inline' => __( 'Inline', 'popup-maker' ),
'stacked' => __( 'Stacked', 'popup-maker' ),
'std' => pum_get_option( 'default_privacy_consent_radio_layout', 'inline' ),
'dependencies' => array_merge(
$privacy_enabled_dependency,
'privacy_consent_type' => 'radio',
'privacy_consent_yes_label' => [
'label' => __( 'Consent Yes Label', 'popup-maker' ),
'std' => pum_get_option( 'default_privacy_consent_yes_label', __( 'Yes', 'popup-maker' ) ),
'dependencies' => array_merge(
$privacy_enabled_dependency,
'privacy_consent_type' => 'radio',
'privacy_consent_no_label' => [
'label' => __( 'Consent No Label', 'popup-maker' ),
'std' => pum_get_option( 'default_privacy_consent_no_label', __( 'No', 'popup-maker' ) ),
'dependencies' => array_merge(
$privacy_enabled_dependency,
'privacy_consent_type' => 'radio',
'privacy_usage_text' => [
'label' => __( 'Consent Usage Text', 'popup-maker' ),
'desc' => function_exists( 'get_privacy_policy_url' ) ? sprintf( __( 'You can use %1$s%2$s to insert a link to your privacy policy. To customize the link text use %1$s:Link Text%2$s', 'popup-maker' ), '{{privacy_link', '}}' ) : '',
'std' => pum_get_option( 'default_privacy_usage_text', __( 'If you opt in above we use this information send related content, discounts and other special offers.', 'popup-maker' ) ),
'dependencies' => $privacy_enabled_dependency,
'label' => __( 'Close Popup', 'popup-maker' ),
'label' => __( 'Delay', 'popup-maker' ),
'label' => __( 'Open Popup', 'popup-maker' ),
'label' => __( 'Popup ID', 'popup-maker' ),
0 => __( 'Select a popup', 'popup-maker' ),
] + PUM_Helpers::popup_selectlist( $select_args ),
'label' => __( 'Redirect', 'popup-maker' ),
'desc' => __( 'Enable refreshing the page or redirecting after success.', 'popup-maker' ),
'label' => __( 'Redirect URL', 'popup-maker' ),
'desc' => __( 'Leave blank to refresh, or enter a url that users will be taken to after success.', 'popup-maker' ),
'redirect_enabled' => true,
return $this->resort_provider_tabs( $fields );
* Sorts tabs so that providers come first.
public function resort_provider_tabs( $tabs = [] ) {
foreach ( $tabs as $tab_id => $tab ) {
if ( strpos( $tab_id, 'provider_' ) === 0 ) {
PUM_Utils_Array::move_item( $sorted_tabs, $tab_id, 'down', 'general' );
* @param array $atts shortcode attributes
* @param string $content shortcode content
public function handler( $atts, $content = null ) {
$atts = $this->shortcode_atts( $atts );
$atts['instance'] = $instance;
$data_attr = $this->data_attr( $atts );