Popup Maker Shortcodes

Below, you’ll find a detailed guide on how to add the Popup Maker Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Popup Maker Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Popup Maker Plugin and the shortcodes it provides:

Plugin Icon
Popup Maker – Popup for opt-ins, lead gen, & more

"Popup Maker is a versatile WordPress plugin designed to create eye-catching popups for opt-ins, lead gen, and more. Easily customizable, it's the perfect tool to enhance your website's engagement."

★★★★☆ (4410) Active Installs: 700000+ Tested with: 6.3.0 PHP Version: 5.6
Included Shortcodes:
  • [popup]
  • [popup_close]
  • [popup_cookie]
  • [popup_trigger]
  • [pum_sub_form]

Popup Maker [popup] Shortcode

The Popup Maker shortcode is a powerful tool that generates a customizable popup on your WordPress site. It allows you to define the popup’s ID, title, theme, size, location, animation, and close settings.

Shortcode: [popup]

Parameters

Here is a list of all possible popup shortcode parameters and attributes:

  • id – Unique identifier for the popup
  • title – Title text to be displayed above the popup content
  • theme_id – ID of the theme to be used for the popup
  • overlay_disabled – Disables the overlay if set to 1
  • size – Sets the size of the popup, e.g. ‘small’
  • width – Sets the width of the popup
  • width_unit – Unit of measurement for the width, e.g. ‘px’
  • height – Sets the height of the popup
  • height_unit – Unit of measurement for the height, e.g. ‘px’
  • location – Sets the location of the popup on the screen
  • position_top – Distance from the top edge of the screen
  • position_left – Distance from the left edge of the screen
  • position_bottom – Distance from the bottom edge of the screen
  • position_right – Distance from the right edge of the screen
  • animation_type – Type of animation for the popup, e.g. ‘fade’
  • animation_speed – Speed of the animation in milliseconds
  • animation_origin – Origin point of the animation
  • overlay_click – Closes the popup when overlay is clicked if set to 1
  • esc_press – Closes the popup when escape key is pressed if set to 1

Examples and Usage

Basic example – Displaying a popup with a unique ID and title.

[popup id="uniqueID" title="My Popup Title"]

Advanced examples

Creating a popup with customized width and height, and disabling the overlay.

[popup id="uniqueID2" title="My Popup Title" width="500" width_unit="px" height="300" height_unit="px" overlay_disabled="1"]

Displaying a popup with a specific animation type and speed, and setting it to close when the user clicks on the overlay or presses the escape key.

[popup id="uniqueID3" title="Animated Popup" animation_type="fade" animation_speed="500" overlay_click="1" esc_press="1"]

Creating a popup with a custom location and position, and setting it to have a fixed position.

[popup id="uniqueID4" title="Fixed Position Popup" location="center top" position_top="100" position_left="0" position_bottom="0" position_right="0" position_fixed="1"]

PHP Function Code

In case you have difficulties debugging what causing issues with [popup] shortcode, check below the related PHP functions code.

Shortcode PHP function:

<?php
/**
 * Shortcode for Popup
 *
 * @package   PUM
 * @copyright Copyright (c) 2023, Code Atlantic LLC
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Class PUM_Shortcode_Popup
 *
 * Registers the popup_close shortcode.
 */
class PUM_Shortcode_Popup extends PUM_Shortcode {

	public $version = 2;

	public $has_content = true;

	public $inner_content_priority = 15;

	/**
	 * The shortcode tag.
	 */
	public function tag() {
		return 'popup';
	}

	public function label() {
		return __( 'Popup', 'popup-maker' );
	}

	public function description() {
		return __( 'Insert a popup inline rather. Great for simple popups used for supporting content.', 'popup-maker' );
	}

	public function inner_content_labels() {
		return [
			'label'       => __( 'Content', 'popup-maker' ),
			'description' => __( 'Can contain other shortcodes, images, text or html content.', 'popup-maker' ),
		];
	}

	public function post_types() {
		return [];
	}

	/**
	 * @return array
	 */
	public function tabs() {
		return [
			'general'   => __( 'General', 'popup-maker' ),
			'display'   => __( 'Display', 'popup-maker' ),
			'position'  => __( 'Position', 'popup-maker' ),
			'animation' => __( 'Animation', 'popup-maker' ),
			'close'     => __( 'Close', 'popup-maker' ),
		];
	}

	/**
	 * @return array
	 */
	public function subtabs() {
		return apply_filters(
			'pum_sub_form_shortcode_subtabs',
			[
				'general'   => [
					'main' => __( 'General', 'popup-maker' ),
				],
				'display'   => [
					'main' => __( 'Display', 'popup-maker' ),
				],
				'position'  => [
					'main' => __( 'Position', 'popup-maker' ),
				],
				'animation' => [
					'main' => __( 'Animation', 'popup-maker' ),
				],
				'close'     => [
					'main' => __( 'Close', 'popup-maker' ),
				],
			]
		);
	}

	public function fields() {
		return [
			'general'   => [
				'main' => [
					'id'    => [
						'label'       => __( 'Unique Popup ID', 'popup-maker' ),
						'placeholder' => __( '`offer`, `more-info`', 'popup-maker' ),
						'desc'        => __( 'Used in popup triggers to target this popup', 'popup-maker' ),
						'priority'    => 5,
						'required'    => true,
					],
					'title' => [
						'label'       => __( 'Popup Title', 'popup-maker' ),
						'placeholder' => __( 'Enter popup title text,', 'popup-maker' ),
						'desc'        => __( 'This will be displayed above the content. Leave it empty to disable it.', 'popup-maker' ),
						'priority'    => 10,
					],
				],
			],
			'display'   => [
				'main' => [
					'theme_id'         => [
						'type'        => 'select',
						'label'       => __( 'Popup Theme', 'popup-maker' ),
						'placeholder' => __( 'Choose a theme,', 'popup-maker' ),
						'desc'        => __( 'Choose which popup theme will be used.', 'popup-maker' ),
						'std'         => pum_get_default_theme_id(),
						'select2'     => true,
						'options'     => pum_is_settings_page() ? PUM_Helpers::popup_theme_selectlist() : null,
						'required'    => true,
						'priority'    => 5,
					],
					'overlay_disabled' => [
						'label'       => __( 'Disable Overlay', 'popup-maker' ),
						'description' => __( 'Checking this will disable and hide the overlay for this popup.', 'popup-maker' ),
						'type'        => 'checkbox',
						'std'         => false,
						'priority'    => 10,
					],
					'size'             => [
						'label'       => __( 'Size', 'popup-maker' ),
						'description' => __( 'Select the size of the popup.', 'popup-maker' ),
						'type'        => 'select',
						'std'         => 'small',
						'options'     => array_flip( apply_filters( 'popmake_popup_display_size_options', [] ) ),
						'priority'    => 15,
					],
					'width'            => [
						'label'    => __( 'Width', 'popup-maker' ),
						'priority' => 20,
					],
					'width_unit'       => [
						'label'    => __( 'Width Unit', 'popup-maker' ),
						'type'     => 'select',
						'std'      => 'px',
						'options'  => array_flip( apply_filters( 'popmake_size_unit_options', [] ) ),
						'priority' => 25,
					],
					'height'           => [
						'label'    => __( 'Height', 'popup-maker' ),
						'priority' => 30,
					],
					'height_unit'      => [
						'label'    => __( 'Height Unit', 'popup-maker' ),
						'type'     => 'select',
						'std'      => 'px',
						'options'  => array_flip( apply_filters( 'popmake_size_unit_options', [] ) ),
						'priority' => 35,
					],
				],
			],
			'position'  => [
				'main' => [
					'location'        => [
						'label'       => __( 'Location', 'popup-maker' ),
						'description' => __( 'Choose where the popup will be displayed.', 'popup-maker' ),
						'type'        => 'select',
						'std'         => 'center top',
						'priority'    => 4,
						'options'     => array_flip( apply_filters( 'popmake_popup_display_location_options', [] ) ),
					],
					'position_top'    => [
						'label'       => __( 'Top', 'popup-maker' ),
						'description' => sprintf( _x( 'Distance from the %s edge of the screen.', 'Screen Edge: top, bottom', 'popup-maker' ), strtolower( __( 'Top', 'popup-maker' ) ) ),
						'type'        => 'rangeslider',
						'std'         => 100,
						'priority'    => 10,
						'step'        => 1,
						'min'         => 0,
						'max'         => 500,
						'unit'        => 'px',
					],
					'position_bottom' => [
						'label'       => __( 'Bottom', 'popup-maker' ),
						'description' => sprintf( _x( 'Distance from the %s edge of the screen.', 'Screen Edge: top, bottom', 'popup-maker' ), strtolower( __( 'Bottom', 'popup-maker' ) ) ),
						'type'        => 'rangeslider',
						'std'         => 0,
						'priority'    => 10,
						'step'        => 1,
						'min'         => 0,
						'max'         => 500,
						'unit'        => 'px',
					],
					'position_left'   => [
						'label'       => __( 'Left', 'popup-maker' ),
						'description' => sprintf( _x( 'Distance from the %s edge of the screen.', 'Screen Edge: top, bottom', 'popup-maker' ), strtolower( __( 'Left', 'popup-maker' ) ) ),
						'type'        => 'rangeslider',
						'std'         => 0,
						'priority'    => 10,
						'step'        => 1,
						'min'         => 0,
						'max'         => 500,
						'unit'        => 'px',
					],
					'position_right'  => [
						'label'       => __( 'Right', 'popup-maker' ),
						'description' => sprintf( _x( 'Distance from the %s edge of the screen.', 'Screen Edge: top, bottom', 'popup-maker' ), strtolower( __( 'Right', 'popup-maker' ) ) ),
						'type'        => 'rangeslider',
						'std'         => 0,
						'priority'    => 10,
						'step'        => 1,
						'min'         => 0,
						'max'         => 500,
						'unit'        => 'px',
					],
				],
			],
			'animation' => [
				'main' => [
					'animation_type'   => [
						'label'       => __( 'Animation Type', 'popup-maker' ),
						'description' => __( 'Select an animation type for your popup.', 'popup-maker' ),
						'type'        => 'select',
						'std'         => 'fade',
						'priority'    => 5,
						'options'     => array_flip( apply_filters( 'popmake_popup_display_animation_type_options', [] ) ),
					],
					'animation_speed'  => [
						'label'       => __( 'Animation Speed', 'popup-maker' ),
						'description' => __( 'Set the animation speed for the popup.', 'popup-maker' ),
						'type'        => 'rangeslider',
						'std'         => 350,
						'priority'    => 10,
						'step'        => 10,
						'min'         => 50,
						'max'         => 1000,
						'unit'        => __( 'ms', 'popup-maker' ),
					],
					'animation_origin' => [
						'label'       => __( 'Animation Origin', 'popup-maker' ),
						'description' => __( 'Choose where the animation will begin.', 'popup-maker' ),
						'type'        => 'select',
						'std'         => 'center top',
						'priority'    => 15,
						'options'     => array_flip( apply_filters( 'popmake_popup_display_animation_origin_options', [] ) ),
					],
				],
			],
			'close'     => [
				'main' => [
					'overlay_click' => [
						'label'       => __( 'Click Overlay to Close', 'popup-maker' ),
						'description' => __( 'Checking this will cause popup to close when user clicks on overlay.', 'popup-maker' ),
						'type'        => 'checkbox',
						'std'         => false,
						'priority'    => 5,
					],
				],
			],
		];
	}

	/**
	 * Shortcode handler
	 *
	 * @param  array  $atts    shortcode attributes
	 * @param  string $content shortcode content
	 *
	 * @return string
	 */
	public function handler( $atts, $content = null ) {
		global $popup;

		$atts = shortcode_atts(
			apply_filters(
				'pum_popup_shortcode_default_atts',
				[

					'id'               => '',
					'title'            => '',

					'theme_id'         => null,
					'theme'            => null,
					'overlay_disabled' => 0,
					'size'             => 'small',
					'width'            => '',
					'width_unit'       => 'px',
					'height'           => '',
					'height_unit'      => 'px',

					'location'         => 'center top',
					'position_top'     => 100,
					'position_left'    => 0,
					'position_bottom'  => 0,
					'position_right'   => 0,
					'position_fixed'   => 0,

					'animation_type'   => 'fade',
					'animation_speed'  => 1000,
					'animation_origin' => 'top',

					'overlay_click'    => 0,
					'esc_press'        => 1,
				]
			),
			$atts,
			'popup'
		);

		// We need to fake a popup using the PUM_Popup data model.
		$post_id              = rand( - 99999, - 1 ); // negative ID, to avoid clash with a valid post
		$post                 = new stdClass();
		$post->ID             = $post_id;
		$post->post_author    = 1;
		$post->post_date      = current_time( 'mysql' );
		$post->post_date_gmt  = current_time( 'mysql', 1 );
		$post->post_title     = $atts['title'];
		$post->post_content   = $content;
		$post->post_status    = 'publish';
		$post->comment_status = 'closed';
		$post->ping_status    = 'closed';
		$post->post_name      = $atts['id']; // append random number to avoid clash
		$post->post_type      = 'popup';
		$post->filter         = 'raw'; // important!
		$post->data_version   = 3;
		$post->mock           = true;

		// Convert to WP_Post object
		$wp_post = new WP_Post( $post );

		// Add the fake post to the cache
		wp_cache_add( $post_id, $wp_post, 'posts' );

		$popup = new PUM_Model_Popup( $wp_post );

		// Get Theme ID
		if ( ! $atts['theme_id'] ) {
			$atts['theme_id'] = $atts['theme'] ? $atts['theme'] : pum_get_default_theme_id();
		}

		$popup->title    = $atts['title'];
		$popup->settings = array_merge(
			PUM_Admin_Popups::defaults(),
			[
				'disable_analytics'      => true,
				'theme_id'               => $atts['theme_id'],
				'size'                   => $atts['size'],
				'overlay_disabled'       => $atts['overlay_disabled'],
				'custom_width'           => $atts['width'],
				'custom_width_unit'      => $atts['width_unit'],
				'custom_height'          => $atts['height'],
				'custom_height_unit'     => $atts['height_unit'],
				'custom_height_auto'     => $atts['width'] > 0 ? 0 : 1,
				'location'               => $atts['location'],
				'position_top'           => $atts['position_top'],
				'position_left'          => $atts['position_left'],
				'position_bottom'        => $atts['position_bottom'],
				'position_right'         => $atts['position_right'],
				'position_fixed'         => $atts['position_fixed'],
				'animation_type'         => $atts['animation_type'],
				'animation_speed'        => $atts['animation_speed'],
				'animation_origin'       => $atts['animation_origin'],
				'close_on_overlay_click' => $atts['overlay_click'],
				'close_on_esc_press'     => $atts['esc_press'],
				'triggers'               => [
					[
						'type'     => 'click_open',
						'settings' => [
							'extra_selectors' => '#popmake-' . $atts['id'],
						],
					],
				],
			]
		);

		$current_global_popup = pum()->current_popup;

		pum()->current_popup = $popup;

		$return = pum_get_template_part( 'popup' );

		// Small hack to move popup to body.
		$return .= "<script type='text/javascript' id='pum-move-popup-" . $post_id . "'>jQuery(document).ready(function () {
				 jQuery('#pum-" . $post_id . "').appendTo('body');
				 window.pum_vars.popups[ 'pum-" . $popup->ID . "' ] = " . PUM_Utils_Array::safe_json_encode( $popup->get_public_settings() ) . ";
				 window.pum_popups[ 'pum-" . $popup->ID . "' ] = " . PUM_Utils_Array::safe_json_encode( $popup->get_public_settings() ) . ";
				 jQuery('#pum-move-popup-" . $post_id . "').remove();
		});</script>";

		pum()->current_popup = $current_global_popup;

		return $return;
	}

	public function template() { ?>
		<p class="pum-sub-form-desc">
			<?php esc_html_e( 'Popup', 'popup-maker' ); ?>: ID "{{attrs.id}}"
		</p>
		<?php
	}

}

Popup Maker [popup_close] Shortcode

The Popup Maker’s ‘popup_close’ shortcode is a powerful tool that lets you create a close button for your popup. It allows customization of HTML tags, href value, target, CSS class, and default click functionality.

Shortcode: [popup_close]

Parameters

Here is a list of all possible popup_close shortcode parameters and attributes:

  • tag – Defines the HTML tag used for the element.
  • href – Sets the href value for the link, if applicable.
  • target – Specifies the target value for the link, if applicable.
  • classes – Adds additional CSS classes for styling the element.
  • do_default – If checked, doesn’t prevent the default click functionality.

Examples and Usage

Basic example – Display a popup close button with default settings.

[popup_close]Close[/popup_close]

Advanced examples

Utilize the shortcode to create a close button for the popup with custom HTML tag and additional CSS class.

[popup_close tag="button" classes="my-custom-class"]Close[/popup_close]

Employ the shortcode to generate a close link for the popup with href attribute and the target attribute set to “_blank”.

[popup_close tag="a" href="https://example.com" target="_blank"]Close and visit example.com[/popup_close]

Use the shortcode to create a close button for the popup that does not prevent the default click functionality.

[popup_close do_default="1"]Close[/popup_close]

PHP Function Code

In case you have difficulties debugging what causing issues with [popup_close] shortcode, check below the related PHP functions code.

Shortcode PHP function:

<?php
/**
 * Shortcode for PopupClose
 *
 * @package   PUM
 * @copyright Copyright (c) 2023, Code Atlantic LLC
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Class PUM_Shortcode_PopupClose
 *
 * Registers the popup_close shortcode.
 */
class PUM_Shortcode_PopupClose extends PUM_Shortcode {

	public $version = 2;

	public $has_content = true;

	/**
	 * The shortcode tag.
	 */
	public function tag() {
		return 'popup_close';
	}

	public function label() {
		return __( 'Popup Close Button', 'popup-maker' );
	}

	public function description() {
		return __( 'Make text or html a close trigger for your popup.', 'popup-maker' );
	}

	public function inner_content_labels() {
		return [
			'label'       => __( 'Content', 'popup-maker' ),
			'description' => __( 'Can contain other shortcodes, images, text or html content.' ),
		];
	}

	public function post_types() {
		return [ 'popup' ];
	}

	public function fields() {
		return [
			'general' => [
				'main' => [
					'tag'    => [
						'label'    => __( 'HTML Tag', 'popup-maker' ),
						'desc'     => __( 'The HTML tag used for this element.', 'popup-maker' ),
						'type'     => 'select',
						'options'  => [
							'a'      => 'a',
							'button' => 'button',
							'div'    => 'div',
							'img'    => 'img',
							'li'     => 'li',
							'p'      => 'p',
							'span'   => 'span',
						],
						'std'      => 'span',
						'required' => true,
					],
					'href'   => [
						'label'        => __( 'Value for href', 'popup-maker' ),
						'placeholder'  => '#',
						'desc'         => __( 'Enter the href value for your link. Leave blank if you do not want this link to take the visitor to a different page.', 'popup-maker' ),
						'type'         => 'text',
						'std'          => '',
						'dependencies' => [
							'tag' => [ 'a' ],
						],
					],
					'target' => [
						'label'        => __( 'Target for the element', 'popup-maker' ),
						'placeholder'  => '',
						'desc'         => __( 'Enter the target value for your link. Can be left blank.', 'popup-maker' ),
						'type'         => 'text',
						'std'          => '',
						'dependencies' => [
							'tag' => [ 'a' ],
						],
					],
				],
			],
			'options' => [
				'main' => [
					'classes'    => [
						'label'       => __( 'CSS Class', 'popup-maker' ),
						'placeholder' => 'my-custom-class',
						'type'        => 'text',
						'desc'        => __( 'Add additional classes for styling.', 'popup-maker' ),
						'std'         => '',
					],
					'do_default' => [
						'type'  => 'checkbox',
						'label' => __( 'Do not prevent the default click functionality.', 'popup-maker' ),
						'desc'  => __( 'This prevents us from disabling the browsers default action when a close button is clicked. It can be used to allow a link to a file to both close a popup and still download the file.', 'popup-maker' ),
					],
				],
			],
		];
	}

	/**
	 * Process shortcode attributes.
	 *
	 * Also remaps and cleans old ones.
	 *
	 * @param $atts
	 *
	 * @return array
	 */
	public function shortcode_atts( $atts ) {
		global $allowedtags;

		$atts = parent::shortcode_atts( $atts );

		// Add button to allowed tags.
		$tags_allowed = array_merge( array_keys( $allowedtags ), [ 'button' ] ) ;

		if ( empty( $atts['tag'] ) || ! in_array( $atts['tag'], $tags_allowed ) ) {
			$atts['tag'] = 'span';
		}

		if ( empty( $atts['href'] ) ) {
			$atts['href'] = '#';
		}

		if ( ! empty( $atts['class'] ) ) {
			$atts['classes'] .= ' ' . $atts['class'];
			unset( $atts['class'] );
		}

		return $atts;
	}

	/**
	 * Shortcode handler
	 *
	 * @param  array  $atts    shortcode attributes
	 * @param  string $content shortcode content
	 *
	 * @return string
	 */
	public function handler( $atts, $content = null ) {
		$atts = $this->shortcode_atts( $atts );

		$tag        = esc_attr( $atts['tag'] );
		$classes    = esc_attr( $atts['classes'] );
		$do_default = esc_attr( $atts['do_default'] ? " data-do-default='true'" : '' );
		// Escaped using notes here: https://wordpress.stackexchange.com/a/357349/63942.
		$esc_content = PUM_Helpers::do_shortcode( force_balance_tags( wp_kses_post( $content ) ) );

		// Sets up our href and target, if the tag is an `a`.
		$href   = 'a' === $atts['tag'] ? "href='" . esc_attr( $atts['href'] ) . "'" : '';
		$target = 'a' === $atts['tag'] && ! empty( $atts['target'] ) ? "target='" . esc_attr( $atts['target'] ) . "'" : '';

		$return = "<$tag $href $target class='pum-close popmake-close $classes' $do_default>$esc_content</$tag>";

		return $return;
	}

	/**
	 * NOTE: Data comes here already filtered through shortcode_atts above.
	 */
	public function template() {
		global $allowedtags;
		?>
		<#
			const allowedTags = <?php echo json_encode( array_keys( $allowedtags ) ); ?>;
			const tag = allowedTags.indexOf( attrs.tag ) >= 0 ? attrs.tag : 'span';
		#>
		<{{{tag}}} class="pum-close  popmake-close <# if (typeof attrs.classes !== 'undefined') print(attrs.classes); #>">{{{attrs._inner_content}}}</{{{tag}}}>
		<?php
	}

}

Popup Maker [popup_cookie] Shortcode

The PopupCookie shortcode from Popup Maker plugin is used to manually set cookies when users view content containing the code. It enables customization of cookie name, expiry time, and visibility settings. The shortcode also ensures the popup won’t trigger on all pages until the cookie expires.

Shortcode: [popup_cookie]

Parameters

Here is a list of all possible popup_cookie shortcode parameters and attributes:

  • name – Defines the name used when saving or checking the cookie
  • expires – Sets the duration before the cookie expires
  • sitewide – If checked, prevents the popup from triggering on all pages until the cookie expires
  • only_onscreen – If checked, stops the cookie from setting until the user scrolls it into the viewport

Examples and Usage

Basic example – Sets a cookie named ‘popmaker-123’ that lasts for 1 month, and is applicable site-wide

[popup_cookie name="popmaker-123" expires="1 month" sitewide="true" /]

Advanced examples

Setting a cookie that lasts for 1 year, is not applicable site-wide, and only sets when the user scrolls it into viewport:

[popup_cookie name="popmaker-456" expires="1 year" sitewide="false" only_onscreen="true" /]

Setting a cookie that lasts for 2 weeks, is applicable site-wide, and sets even if the user doesn’t scroll it into viewport:

[popup_cookie name="popmaker-789" expires="2 weeks" sitewide="true" only_onscreen="false" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [popup_cookie] shortcode, check below the related PHP functions code.

Shortcode PHP function:

<?php
/**
 * Shortcode for PopupCookie
 *
 * @package   PUM
 * @copyright Copyright (c) 2023, Code Atlantic LLC
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Class PUM_Shortcode_PopupCookie
 *
 * Registers the popup_cookie shortcode.
 */
class PUM_Shortcode_PopupCookie extends PUM_Shortcode {

	public $version = 2;

	public $has_content = false;

	/**
	 * The shortcode tag.
	 */
	public function tag() {
		return 'popup_cookie';
	}

	public function label() {
		return __( 'Popup Cookie', 'popup-maker' );
	}

	public function description() {
		return __( 'Insert this to manually set cookies when users view the content containing the code.', 'popup-maker' );
	}

	public function post_types() {
		return [ '*' ];
	}

	public function fields() {
		return [
			'general' => [
				'main' => [
					'name'          => [
						'label'       => __( 'Cookie Name', 'popup-maker' ),
						'placeholder' => __( 'Cookie Name ex. popmaker-123', 'popup-maker' ),
						'desc'        => __( 'The name that will be used when checking for or saving this cookie.', 'popup-maker' ),
						'std'         => '',
					],
					'expires'       => [
						'label'       => __( 'Cookie Time', 'popup-maker' ),
						'placeholder' => __( '364 days 23 hours 59 minutes 59 seconds', 'popup-maker' ),
						'desc'        => __( 'Enter a plain english time before cookie expires.', 'popup-maker' ),
						'std'         => '1 month',
					],
					'sitewide'      => [
						'label' => __( 'Sitewide Cookie', 'popup-maker' ),
						'desc'  => __( 'This will prevent the popup from triggering on all pages until the cookie expires.', 'popup-maker' ),
						'type'  => 'checkbox',
						'std'   => true,
					],
					'only_onscreen' => [
						'label' => __( 'Only when visible on-screen', 'popup-maker' ),
						'desc'  => __( 'This will prevent the cookie from getting set until the user scrolls it into viewport.', 'popup-maker' ),
						'type'  => 'checkbox',
						'std'   => false,
					],
				],
			],
		];
	}

	/**
	 * Shortcode handler
	 *
	 * @param array  $atts    shortcode attributes
	 * @param string $content shortcode content
	 *
	 * @return string
	 */
	public function handler( $atts, $content = null ) {
		$atts = $this->shortcode_atts( $atts );

		// This shortcode requires our scripts, but can be used on pages where no popups exist.
		wp_enqueue_script( 'popup-maker-site' );

		$onscreen = esc_attr( 'data-only-onscreen="' . ( $atts['only_onscreen'] ? 1 : 0 ) . '"' );
		$args     = esc_attr(
			wp_json_encode(
				[
					'name' => $atts['name'],
					'time' => $atts['expires'],
					'path' => $atts['sitewide'],
				]
			)
		);

		return "<div class='pum-cookie' data-cookie-args='$args' $onscreen></div>";
	}

	public function template() { ?>
		<div class="pum-cookie"><?php esc_html_e( 'Popup Cookie', 'popup-maker' ); ?></div>
		<?php
	}

}

Popup Maker [popup_trigger] Shortcode

The Popup Maker shortcode is a versatile tool that inserts a clickable popup trigger. It allows you to target specific popups, customize the HTML tag, add CSS classes, and even manage the default click functionality. The shortcode also supports rendering via AJAX and can contain other shortcodes, images, text, or HTML content. The PHP code provided outlines the structure and functionality of this shortcode, making it a powerful tool in your WordPress arsenal.

Shortcode: [popup_trigger]

Parameters

Here is a list of all possible popup_trigger shortcode parameters and attributes:

  • id – Identifier for the targeted popup to trigger.
  • custom_id – Custom identifier for the popup, used when id is ‘custom’.
  • tag – Specifies the HTML tag for the trigger, defaults to ‘span’.
  • classes – Additional CSS classes for styling the trigger.
  • do_default – If true, default browser action is not prevented on click.

Examples and Usage

Basic example – A simple popup trigger that activates a popup with the ID of 1 when clicked.

[popup_trigger id=1 tag="span" /]

Advanced examples

Creating a popup trigger using a custom HTML button tag, with additional CSS classes for styling. This will activate a popup with the ID of 2.

[popup_trigger id=2 tag="button" classes="btn btn-primary" /]

Using the shortcode to display a popup trigger that also allows the default click functionality. This can be useful for triggering a popup and also allowing a link to follow through to its destination.

[popup_trigger id=3 tag="a" classes="link-class" do_default=true /]

Creating a popup trigger using a custom popup ID. This will activate a popup with the custom ID of ‘my_custom_popup’.

[popup_trigger id="custom" custom_id="my_custom_popup" tag="span" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [popup_trigger] shortcode, check below the related PHP functions code.

Shortcode PHP function:

<?php
/**
 * Shortcode for PopupTrigger
 *
 * @package   PUM
 * @copyright Copyright (c) 2023, Code Atlantic LLC
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Class PUM_Shortcode
 *
 * This is a base class for all popup maker & extension shortcodes.
 */
class PUM_Shortcode_PopupTrigger extends PUM_Shortcode {

	/**
	 * @var int
	 */
	public $version = 2;

	/**
	 * @var bool
	 */
	public $has_content = true;

	public $ajax_rendering = true;

	/**
	 * The shortcode tag.
	 */
	public function tag() {
		return 'popup_trigger';
	}

	/**
	 * @return string
	 */
	public function label() {
		return __( 'Popup Trigger', 'popup-maker' );
	}

	/**
	 * @return string
	 */
	public function description() {
		return __( 'Inserts a click-able popup trigger.', 'popup-maker' );
	}

	/**
	 * @return array
	 */
	public function inner_content_labels() {
		return [
			'label'       => __( 'Trigger Content', 'popup-maker' ),
			'description' => __( 'Can contain other shortcodes, images, text or html content.' ),
		];
	}

	/**
	 * @return array
	 */
	public function post_types() {
		return [ 'post', 'page', 'popup' ];
	}

	/**
	 * @return array
	 */
	public function fields() {
		$select_args = [];

		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'] ] );
		}

		return [
			'general' => [
				'main' => [
					'id'        => [
						'label'       => __( 'Targeted Popup', 'popup-maker' ),
						'placeholder' => __( 'Choose a Popup', 'popup-maker' ),
						'desc'        => __( 'Choose which popup will be targeted by this trigger.', 'popup-maker' ),
						'type'        => 'select',
						'post_type'   => 'popup',
						'priority'    => 5,
						'required'    => true,
						'options'     => PUM_Helpers::popup_selectlist( $select_args ) + [
							'custom' => __( 'Custom', 'popup-maker' ),
						],
						'std'         => 0,
					],
					'custom_id' => [
						'label'        => __( 'Custom Popup ID', 'popup-maker' ),
						'type'         => 'text',
						'dependencies' => [
							'id' => 'custom',
						],
						'std'          => '',
					],
				],
			],
			'options' => [
				'main' => [
					'tag'        => [
						'label'       => __( 'HTML Tag', 'popup-maker' ),
						'placeholder' => __( 'HTML Tags: button, span etc.', 'popup-maker' ),
						'desc'        => __( 'The HTML tag used to generate the trigger and wrap your text.', 'popup-maker' ),
						'type'        => 'text',
						'std'         => '',
						'priority'    => 10,
						'required'    => true,
					],
					'classes'    => [
						'label'       => __( 'CSS Class', 'popup-maker' ),
						'placeholder' => __( 'CSS Class', 'popup-maker' ),
						'type'        => 'text',
						'desc'        => __( 'Add additional classes for styling.', 'popup-maker' ),
						'priority'    => 15,
						'std'         => '',
					],
					'class'      => [
						'type' => 'hidden',
					],
					'do_default' => [
						'type'     => 'checkbox',
						'label'    => __( 'Do not prevent the default click functionality.', 'popup-maker' ),
						'desc'     => __( 'This prevents us from disabling the browsers default action when a trigger is clicked. It can be used to allow a link to a file to both trigger a popup and still download the file.', 'popup-maker' ),
						'priority' => 20,
						'std'      => false,
					],

				],
			],
		];
	}

	/**
	 * Shortcode handler
	 *
	 * @param  array  $atts    shortcode attributes
	 * @param  string $content shortcode content
	 *
	 * @return string
	 */
	public function handler( $atts, $content = null ) {
		$atts = $this->shortcode_atts( $atts );

		$tag        = esc_attr( $atts['tag'] );
		$id         = esc_attr( $atts['id'] );
		$classes    = esc_attr( $atts['classes'] );
		$do_default = esc_attr( $atts['do_default'] );
		// Escaped using notes here: https://wordpress.stackexchange.com/a/357349/63942.
		$esc_content = PUM_Helpers::do_shortcode( force_balance_tags( wp_kses_post( $content ) ) );

		$return = "<$tag class='pum-trigger  popmake-$id  $classes' data-do-default='$do_default'>$esc_content</$tag>";

		PUM_Site_Popups::preload_popup_by_id_if_enabled( $atts['id'] );

		return $return;
	}

	/**
	 * Process shortcode attributes.
	 *
	 * Also remaps and cleans old ones.
	 *
	 * @param $atts
	 *
	 * @return array
	 */
	public function shortcode_atts( $atts ) {
		global $allowedtags;

		$atts = parent::shortcode_atts( $atts );

		// Add button to allowed tags.
		$tags_allowed = array_merge( array_keys( $allowedtags ), [ 'button' ] ) ;

		if ( empty( $atts['tag'] ) || ! in_array( $atts['tag'], $tags_allowed ) ) {
			$atts['tag'] = 'span';
		}

		if ( 'custom' === $atts['id'] ) {
			$atts['id'] = $atts['custom_id'];
		}

		if ( ! empty( $atts['class'] ) ) {
			$atts['classes'] .= ' ' . $atts['class'];
			unset( $atts['class'] );
		}

		return $atts;
	}

	public function template() {
		global $allowedtags;
		?>
		<#
			const allowedTags = <?php echo wp_json_encode( array_keys( $allowedtags ) ); ?>;
			const tag = allowedTags.indexOf( attrs.tag ) >= 0 ? attrs.tag : 'span';
		#>
		<{{{tag}}} class="pum-trigger  popmake-{{{attrs.id}}} {{{attrs.classes}}}">{{{attrs._inner_content}}}</{{{tag}}}>
		<?php
	}

}

Popup Maker [pum_sub_form] Shortcode

The Popup Maker shortcode is a powerful tool for embedding subscription forms in your WordPress site. It enables customization of form fields, labels, appearance, and privacy settings. This shortcode is particularly useful for GDPR compliance as it includes privacy consent options.

Shortcode: [pum_sub_form]

Parameters

Here is a list of all possible pum_sub_form shortcode parameters and attributes:

  • provider – specifies the service provider to submit to
  • name_field_type – defines the type of name field to be used in the form
  • name_optional – makes the name field optional
  • name_disabled – removes the name field from the form
  • disable_labels – disables the display of field labels
  • label_name – sets the label for the name field
  • label_fname – sets the label for the first name field
  • label_lname – sets the label for the last name field
  • label_email – sets the label for the email field
  • label_submit – sets the label for the submit button
  • form_layout – chooses the layout of the form
  • form_alignment – sets the alignment of the form
  • form_style – chooses the style of the form
  • privacy_consent_enabled – enables a privacy consent checkbox
  • privacy_consent_label – sets the label for the privacy consent checkbox
  • privacy_consent_required – makes the privacy consent checkbox mandatory
  • redirect_enabled – enables redirection after form submission
  • redirect – sets the URL for redirection after form submission

Examples and Usage

Basic example – Display a subscription form with default settings.

[pum_sub_form /]

Advanced examples

Display a subscription form with a specific service provider and with the name field disabled.

[pum_sub_form provider="mailchimp" name_field_type="disabled" /]

Display a subscription form with custom labels for the name and email fields, and a custom submit button label.

[pum_sub_form label_name="Full Name" label_email="Your Email" label_submit="Sign Up Now" /]

Display a subscription form with privacy consent enabled, and custom labels for the consent field.

[pum_sub_form privacy_consent_enabled="yes" privacy_consent_label="I agree to the terms and conditions" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [pum_sub_form] shortcode, check below the related PHP functions code.

Shortcode PHP function:

<?php
/**
 * Shortcode Subscribe
 *
 * @package   PUM
 * @copyright Copyright (c) 2023, Code Atlantic LLC
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Class PUM_Shortcode_Subscribe
 */
class PUM_Shortcode_Subscribe extends PUM_Shortcode {

	/**
	 * @var int
	 */
	public $version = 2;

	/**
	 * @var bool
	 */
	public $ajax_rendering = true;

	/**
	 * The shortcode tag.
	 *
	 * @return string
	 */
	public function tag() {
		return 'pum_sub_form';
	}

	/**
	 * @return array
	 */
	public function fields() {
		$select_args = [];

		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',
		];

		$fields = apply_filters(
			'pum_sub_form_shortcode_fields',
			[
				'general' => [
					'main' => [
						'provider' => [
							'label'   => __( 'Service Provider', 'popup-maker' ),
							'desc'    => __( 'Choose which service provider to submit to.', 'popup-maker' ),
							'type'    => 'select',
							'options' => array_merge( [ '' => __( 'Default', 'popup-maker' ) ], PUM_Newsletter_Providers::dropdown_list(), [ 'none' => __( 'None', 'popup-maker' ) ] ),
							'std'     => '',
						],
					],
				],
				'form'    => [
					'fields'       => [
						'name_field_type' => [
							'label'   => __( 'Name Field Type', 'popup-maker' ),
							'type'    => 'select',
							'options' => [
								'disabled'   => __( 'None', 'popup-maker' ),
								'fullname'   => __( 'Full', 'popup-maker' ),
								'first_only' => __( 'First Only', 'popup-maker' ),
								'first_last' => __( 'First & Last', 'popup-maker' ),
							],
							'std'     => 'fullname',
							'private' => true,
						],
						'name_optional'   => [
							'label'        => __( 'Name Optional', 'popup-maker' ),
							'desc'         => __( 'Makes the name field optional.', 'popup-maker' ),
							'type'         => 'checkbox',
							'dependencies' => [
								'name_field_type' => [ 'fullname', 'first_only', 'first_last' ],
							],
							'private'      => true,
						],
						'name_disabled'   => [
							'label'        => __( 'Name Disabled', 'popup-maker' ),
							'desc'         => __( 'Removes the name field.', 'popup-maker' ),
							'type'         => 'checkbox',
							'dependencies' => [
								'name_field_type' => false,
							],
							'private'      => true,
						],

					],
					'labels'       => [
						'disable_labels' => [
							'label'   => __( 'Disable Labels', 'popup-maker' ),
							'desc'    => __( 'Disables the display of field labels.', 'popup-maker' ),
							'type'    => 'checkbox',
							'private' => true,
						],
						'heading_labels' => [
							'label'   => __( 'Labels', 'popup-maker' ),
							'desc'    => __( 'Field label text', 'popup-maker' ),
							'type'    => 'heading',
							'private' => true,
						],
						'label_name'     => [
							'label'        => __( 'Full Name', 'popup-maker' ),
							'dependencies' => [
								'disable_labels'  => false,
								'name_field_type' => [ 'fullname' ],
							],
							'std'          => __( 'Name', 'popup-maker' ),
							'private'      => true,
						],
						'label_fname'    => [
							'label'        => __( 'First Name', 'popup-maker' ),
							'dependencies' => [
								'disable_labels'  => false,
								'name_field_type' => [ 'first_only', 'first_last' ],
							],
							'std'          => __( 'First Name', 'popup-maker' ),
							'private'      => true,
						],
						'label_lname'    => [
							'label'        => __( 'Last Name', 'popup-maker' ),
							'dependencies' => [
								'disable_labels'  => false,
								'name_field_type' => [ 'first_last' ],
							],
							'std'          => __( 'Last Name', 'popup-maker' ),
							'private'      => true,
						],
						'label_email'    => [
							'label'        => __( 'Email', 'popup-maker' ),
							'dependencies' => [
								'disable_labels' => false,
							],
							'std'          => __( 'Email', 'popup-maker' ),
							'private'      => true,
						],
						'label_submit'   => [
							'label'   => __( 'Submit Button', 'popup-maker' ),
							'std'     => __( 'Subscribe', 'popup-maker' ),
							'private' => true,
						],
						// Deprecated fields.
						'name_text'      => [
							'type'    => 'hidden',
							'private' => true,
						],
						'email_text'     => [
							'private' => true,
							'type'    => 'hidden',
						],
						'button_text'    => [
							'type'    => 'hidden',
							'private' => true,
						],
					],
					'placeholders' => [
						'placeholder_name'  => [
							'label'        => __( 'Full Name', 'popup-maker' ),
							'dependencies' => [
								'name_field_type' => [ 'fullname' ],
							],
							'std'          => __( 'Name', 'popup-maker' ),
							'private'      => true,
						],
						'placeholder_fname' => [
							'label'        => __( 'First Name', 'popup-maker' ),
							'dependencies' => [
								'name_field_type' => [ 'first_only', 'first_last' ],
							],
							'std'          => __( 'First Name', 'popup-maker' ),
							'private'      => true,
						],
						'placeholder_lname' => [
							'label'        => __( 'Last Name', 'popup-maker' ),
							'dependencies' => [
								'name_field_type' => [ 'first_last' ],
							],
							'std'          => __( 'Last Name', 'popup-maker' ),
							'private'      => true,
						],
						'placeholder_email' => [
							'label'   => __( 'Email', 'popup-maker' ),
							'std'     => __( 'Email', 'popup-maker' ),
							'private' => true,
						],

					],
					'appearance'   => [
						'form_layout'    => [
							'label'   => __( 'Form Layout', 'popup-maker' ),
							'desc'    => __( 'Choose a form layout.', 'popup-maker' ),
							'type'    => 'select',
							'options' => [
								'block'  => __( 'Block', 'popup-maker' ),
								'inline' => __( 'Inline', 'popup-maker' ),
							],
							'std'     => 'block',
							'private' => true,
						],
						'form_alignment' => [
							'label'   => __( 'Form Alignment', 'popup-maker' ),
							'desc'    => __( 'Choose a form alignment.', 'popup-maker' ),
							'type'    => 'select',
							'options' => [
								'left'   => __( 'Left', 'popup-maker' ),
								'center' => __( 'Center', 'popup-maker' ),
								'right'  => __( 'Right', 'popup-maker' ),
							],
							'std'     => 'center',
							'private' => true,
						],
						'form_style'     => [
							'label'   => __( 'Form Style', 'popup-maker' ),
							'desc'    => __( 'Choose how you want your form styled.', 'popup-maker' ),
							'type'    => 'select',
							'options' => [
								''        => __( 'None', 'popup-maker' ),
								'default' => __( 'Default', 'popup-maker' ),
							],
							'std'     => 'default',
						],
						'layout'         => [
							'type'    => 'hidden',
							'private' => true,
						],
						'style'          => [
							'type'    => 'hidden',
							'private' => true,
						],
					],
				],
				'privacy' => [
					'main' => [
						'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',
							'options' => [
								'yes' => __( 'Yes', 'popup-maker' ),
								'no'  => __( 'No', 'popup-maker' ),
							],
							'std'     => 'yes',
							'value'   => $privacy_always_enabled ? 'yes' : null,
							'private' => true,
						],
						'privacy_consent_label'        => [
							'label'        => __( 'Consent Field Label', 'popup-maker' ),
							'type'         => 'text',
							'std'          => pum_get_option( 'default_privacy_consent_label', __( 'Notify me about related content and special offers.', 'popup-maker' ) ),
							'private'      => true,
							'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' ),
							'type'         => 'checkbox',
							'std'          => pum_get_option( 'default_privacy_consent_required' ),
							'private'      => true,
							'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' ),
							'type'         => 'select',
							'options'      => [
								'radio'    => __( 'Radio', 'popup-maker' ),
								'checkbox' => __( 'Checkbox', 'popup-maker' ),
							],
							'std'          => pum_get_option( 'default_privacy_consent_type', 'radio' ),
							'private'      => true,
							'dependencies' => $privacy_enabled_dependency,
						],
						'privacy_consent_radio_layout' => [
							'label'        => __( 'Consent Radio Layout', 'popup-maker' ),
							'type'         => 'select',
							'options'      => [
								'inline'  => __( 'Inline', 'popup-maker' ),
								'stacked' => __( 'Stacked', 'popup-maker' ),
							],
							'std'          => pum_get_option( 'default_privacy_consent_radio_layout', 'inline' ),
							'private'      => true,
							'dependencies' => array_merge(
								$privacy_enabled_dependency,
								[
									'privacy_consent_type' => 'radio',
								]
							),
						],
						'privacy_consent_yes_label'    => [
							'label'        => __( 'Consent Yes Label', 'popup-maker' ),
							'type'         => 'text',
							'std'          => pum_get_option( 'default_privacy_consent_yes_label', __( 'Yes', 'popup-maker' ) ),
							'private'      => true,
							'dependencies' => array_merge(
								$privacy_enabled_dependency,
								[
									'privacy_consent_type' => 'radio',
								]
							),
						],
						'privacy_consent_no_label'     => [
							'label'        => __( 'Consent No Label', 'popup-maker' ),
							'type'         => 'text',
							'std'          => pum_get_option( 'default_privacy_consent_no_label', __( 'No', 'popup-maker' ) ),
							'private'      => true,
							'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', '}}' ) : '',
							'type'         => 'text',
							'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,
						],
					],
				],
				'actions' => [
					'popup'    => [
						'closepopup'   => [
							'label' => __( 'Close Popup', 'popup-maker' ),
							'type'  => 'checkbox',
						],
						'closedelay'   => [
							'label'        => __( 'Delay', 'popup-maker' ),
							'type'         => 'rangeslider',
							'min'          => 0,
							'max'          => 180,
							'step'         => 1,
							'unit'         => 's',
							'std'          => 0,
							'dependencies' => [
								'closepopup' => true,
							],
						],
						'openpopup'    => [
							'label' => __( 'Open Popup', 'popup-maker' ),
							'type'  => 'checkbox',
						],
						'openpopup_id' => [
							'label'        => __( 'Popup ID', 'popup-maker' ),
							'type'         => 'select',
							'options'      => [
								0 => __( 'Select a popup', 'popup-maker' ),
							] + PUM_Helpers::popup_selectlist( $select_args ),
							'std'          => 0,
							'dependencies' => [
								'openpopup' => true,
							],
						],
					],
					'redirect' => [
						'redirect_enabled' => [
							'label' => __( 'Redirect', 'popup-maker' ),
							'desc'  => __( 'Enable refreshing the page or redirecting after success.', 'popup-maker' ),
							'type'  => 'checkbox',
						],
						'redirect'         => [
							'label'        => __( 'Redirect URL', 'popup-maker' ),
							'desc'         => __( 'Leave blank to refresh, or enter a url that users will be taken to after success.', 'popup-maker' ),
							'std'          => '',
							'dependencies' => [
								'redirect_enabled' => true,
							],
						],
					],
				],
			]
		);

		return $this->resort_provider_tabs( $fields );
	}

	/**
	 * Shortcode handler
	 *
	 * @param  array  $atts    shortcode attributes
	 * @param  string $content shortcode content
	 *
	 * @return string
	 */
	public function handler( $atts, $content = null ) {
		$atts = $this->shortcode_atts( $atts );

		static $instance = 0;

		$instance ++;

		$atts['instance'] = $instance;

		ob_start();

		$data_attr = $this->data_attr( $atts );

		$classes = implode(
			' ',
			[
				'pum_sub_form',
				$atts['provider'],
				$atts['form_layout'],
				$atts['form_style'],
				'pum-sub-form',
				'pum-form',
				'pum-sub-form--provider-' . $atts['provider'],
				'pum-form--layout-' . $atts['form_layout'],
				'pum-form--style-' . $atts['form_style'],
				'pum-form--alignment-' . $atts['form_alignment'],
			]
		); ?>


		<form class="<?php echo esc_attr( $classes ); ?>" data-settings="<?php echo esc_attr( PUM_Utils_Array::safe_json_encode( $data_attr ) ); ?>">

			<?php do_action( 'pum_sub_form_before', $atts ); ?>

			<?php

			if ( 'disabled' !== $atts['name_field_type'] ) :

				$required = ! $atts['name_optional'] ? 'required' : '';

				switch ( $atts['name_field_type'] ) {
					case 'fullname':
						?>

						<div class="pum-form__field  pum-form__field--name  pum-sub-form-field  pum-sub-form-field--name">
							<?php if ( ! $atts['disable_labels'] ) : ?>
								<label class="pum-form__label  pum-sub-form-label"><?php echo esc_html( $atts['label_name'] ); ?></label>
							<?php endif; ?>
							<input type="text" name="name" <?php echo esc_attr( $required ); ?> placeholder="<?php echo esc_attr( $atts['placeholder_name'] ); ?>" />
						</div>

						<?php
						break;

					case 'first_only':
						?>

						<div class="pum-form__field  pum-form__field--fname  pum-sub-form-field  pum-sub-form-field--fname">
							<?php if ( ! $atts['disable_labels'] ) : ?>
								<label class="pum-form__label  pum-sub-form-label"><?php echo esc_html( $atts['label_fname'] ); ?></label>
							<?php endif; ?>
							<input type="text" name="fname" <?php echo esc_attr( $required ); ?> placeholder="<?php echo esc_attr( $atts['placeholder_fname'] ); ?>" />
						</div>

						<?php
						break;

					case 'first_last':
						?>

						<div class="pum-form__field  pum-form__field--fname  pum-sub-form-field  pum-sub-form-field--fname">
							<?php if ( ! $atts['disable_labels'] ) : ?>
								<label class="pum-form__label  pum-sub-form-label"><?php echo esc_html( $atts['label_fname'] ); ?></label>
							<?php endif; ?>
							<input type="text" name="fname" <?php echo esc_attr( $required ); ?> placeholder="<?php echo esc_attr( $atts['placeholder_fname'] ); ?>" />
						</div>

						<div class="pum-form__field  pum-form__field--lname  pum-sub-form-field  pum-sub-form-field--lname">
							<?php if ( ! $atts['disable_labels'] ) : ?>
								<label class="pum-form__label  pum-sub-form-label"><?php echo esc_html( $atts['label_lname'] ); ?></label>
							<?php endif; ?>
							<input type="text" name="lname" <?php echo esc_attr( $required ); ?> placeholder="<?php echo esc_attr( $atts['placeholder_lname'] ); ?>" />
						</div>

						<?php
						break;
				}
				?>

			<?php endif; ?>

			<div class="pum-form__field  pum-form__field--email  pum-sub-form-field  pum-sub-form-field--email">
				<?php if ( ! $atts['disable_labels'] ) : ?>
					<label class="pum-form__label  pum-sub-form-label"><?php echo esc_html( $atts['label_email'] ); ?></label>
				<?php endif; ?>
				<input type="email" name="email" required placeholder="<?php echo esc_attr( $atts['placeholder_email'] ); ?>" />
			</div>

			<?php do_action( 'pum_sub_form_fields', $atts ); ?>

			<?php do_action( 'pum_newsletter_fields', $atts ); ?>

			<input type="hidden" name="provider" value="<?php echo esc_attr( $atts['provider'] ); ?>" />

			<?php
			if ( 'yes' === $atts['privacy_consent_enabled'] ) :
				$consent_text = trim( $atts['privacy_consent_label'] );
				$consent_args = [
					'enabled'  => 'yes',
					'required' => isset( $atts['privacy_consent_required'] ) && $atts['privacy_consent_required'],
					'text'     => ! empty( $consent_text ) ? $consent_text : ( ! empty( $atts['privacy_consent_yes_label'] ) ? $atts['privacy_consent_yes_label'] : '' ),
				];
				?>

				<input type="hidden" name="consent_args" value="<?php echo esc_attr( PUM_Utils_Array::safe_json_encode( $consent_args ) ); ?>" />

				<div class="pum-form__field  pum-form__field--<?php echo esc_attr( $atts['privacy_consent_type'] ); ?>  pum-form__field--consent  pum-sub-form-field">
					<?php
					switch ( $atts['privacy_consent_type'] ) {
						case 'checkbox':
							?>
							<label class="pum-form__label  pum-sub-form-label">
								<input type="checkbox" value="yes" name="consent" <?php echo $consent_args['required'] ? 'required="required"' : ''; ?> /> <?php echo wp_kses( $consent_text, [] ); ?>
							</label>
							<?php
							break;
						case 'radio':
							?>
							<?php if ( ! empty( $consent_text ) ) : ?>
								<label class="pum-form__label  pum-sub-form-label"><?php echo esc_html( wp_kses( $consent_text, [] ) ); ?></label>
							<?php endif; ?>
							<div class="pum-form__consent-radios  pum-form__consent-radios--<?php echo esc_attr( $atts['privacy_consent_radio_layout'] ); ?>">
								<label class="pum-form__label  pum-sub-form-label">
									<input type="radio" value="yes" name="consent" <?php echo $consent_args['required'] ? 'required="required"' : ''; ?> /> <?php echo esc_html( wp_kses( $atts['privacy_consent_yes_label'], [] ) ); ?>
								</label>
								<label class="pum-form__label  pum-sub-form-label">
									<input type="radio" value="no" name="consent" /> <?php echo esc_html( wp_kses( $atts['privacy_consent_no_label'], [] ) ); ?>
								</label>
							</div>
							<?php
							break;
					}

					if ( ! empty( $atts['privacy_usage_text'] ) ) :
						$usage_text = trim( $atts['privacy_usage_text'] );

						if ( strpos( $usage_text, '{{privacy_link' ) !== false && function_exists( 'get_privacy_policy_url' ) && get_privacy_policy_url() !== '' ) {
							preg_match_all( '/{{privacy_link:?(.*)}}/', $usage_text, $matches );

							$link = '<a href="' . get_privacy_policy_url() . '" target="_blank">%s</a>';

							foreach ( $matches[0] as $key => $value ) {
								$usage_text = str_replace( $matches[0][ $key ], sprintf( $link, $matches[1][ $key ] ), $usage_text );
							}
						}
						?>
						<p>
							<small>
							<?php
							echo wp_kses(
								$usage_text,
								[
									'a' => [
										'target' => true,
										'href'   => true,
									],
								]
								);
							?>
							</small>
						</p>
					<?php endif; ?>
				</div>
			<?php endif; ?>

			<div class="pum-form__field  pum-form__field--submit  pum-sub-form-field  pum-sub-form-field--submit">
				<button class="pum-form__submit  pum-sub-form-submit"><?php echo esc_html( $atts['label_submit'] ); ?></button>
			</div>

			<?php do_action( 'pum_sub_form_after', $atts ); ?>
		</form>

		<?php

		// return content
		return ob_get_clean();
	}

Conclusion

Now that you’ve learned how to embed the Popup Maker Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *