PUM_Admin_Templates::triggers_editor()


Description Description


Source Source

File: classes/Admin/Templates.php

	public static function triggers_editor() {
		?>
		<script type="text/html" id="tmpl-pum-field-triggers">
			<# print(PUM_Admin.triggers.template.editor({triggers: data.value, name: data.name})); #>
		</script>

		<script type="text/html" id="tmpl-pum-trigger-editor">
			<div class="pum-popup-trigger-editor  <# if (data.triggers && data.triggers.length) { print('has-list-items'); } #>" data-field_name="{{data.name}}">
				<button type="button" class="button button-primary pum-add-new no-button"><?php _e( 'Add New Trigger', 'popup-maker' ); ?></button>

				<p>
					<strong>
						<?php _e( 'Triggers cause a popup to open.', 'popup-maker' ); ?>
						<a href="<?php echo esc_url( 'https://docs.wppopupmaker.com/article/141-triggers?utm_campaign=contextual-help&utm_medium=inline-doclink&utm_source=plugin-popup-editor&utm_content=triggers-option-settings' ); ?>" target="_blank"
						   class="pum-doclink dashicons dashicons-editor-help" title="<?php esc_attr_e( sprintf( __( 'Learn more about %s', 'popup-maker' ), __( 'Triggers', 'popup-maker' ) ) ); ?>"></a>
					</strong>
				</p>

				<table class="list-table form-table">
					<thead>
					<tr>
						<th><?php _e( 'Type', 'popup-maker' ); ?></th>
						<th><?php _e( 'Cookie', 'popup-maker' ); ?></th>
						<th><?php _e( 'Settings', 'popup-maker' ); ?></th>
						<th><?php _e( 'Actions', 'popup-maker' ); ?></th>
					</tr>
					</thead>
					<tbody>
					<#
					_.each(data.triggers, function (trigger, index) {
					print(PUM_Admin.triggers.template.row({
					index: index,
					type: trigger.type,
					name: data.name,
					settings: trigger.settings || {}
					}));
					});
					#>
					</tbody>
				</table>

				<!--				<div class="no-triggers  no-list-items">-->
				<!--					<div class="pum-field pum-field-select pum-field-select2">-->
				<!--						<label for="pum-first-trigger">--><?php //_e( 'Choose a type of trigger to get started.', 'popup-maker' ); ?><!--</label>-->
				<!--						<# print(PUM_Admin.triggers.template.selectbox({id: 'pum-first-trigger', name: "", placeholder: "--><?php //_e( 'Select a trigger type.', 'popup-maker' ); ?><!--"})); #>-->
				<!--					</div>-->
				<!--				</div>-->
			</div>
		</script>

		<script type="text/html" id="tmpl-pum-trigger-row">
			<tr data-index="{{data.index}}">
				<td class="type-column">
					<button type="button" class="edit no-button link-button" aria-label="<?php _e( 'Edit this trigger', 'popup-maker' ); ?>">{{PUM_Admin.triggers.getLabel(data.type)}}</button>
					<input class="popup_triggers_field_type" type="hidden" name="{{data.name}}[{{data.index}}][type]" value="{{data.type}}"/>
					<input class="popup_triggers_field_settings" type="hidden" name="{{data.name}}[{{data.index}}][settings]" value="{{JSON.stringify(data.settings)}}"/>
				</td>
				<td class="cookie-column">
					<code>{{PUM_Admin.triggers.cookie_column_value(data.settings.cookie_name)}}</code>
				</td>
				<td class="settings-column">{{{PUM_Admin.triggers.getSettingsDesc(data.type, data.settings)}}}</td>
				<td class="list-item-actions">
					<button type="button" class="edit dashicons dashicons-edit no-button" aria-label="<?php _e( 'Edit this trigger', 'popup-maker' ); ?>"></button>
					<button type="button" class="remove dashicons dashicons-no no-button" aria-label="<?php _e( 'Delete this trigger', 'popup-maker' ); ?>"></button>
				</td>
			</tr>
		</script>

		<?php
		$presets = apply_filters( 'pum_click_selector_presets', array(
			'a[href="exact_url"]'    => __( 'Link: Exact Match', 'popup-maker' ),
			'a[href*="contains"]'    => __( 'Link: Containing', 'popup-maker' ),
			'a[href^="begins_with"]' => __( 'Link: Begins With', 'popup-maker' ),
			'a[href$="ends_with"]'   => __( 'Link: Ends With', 'popup-maker' ),
		) );
		?>

		<script type="text/html" id="tmpl-pum-click-selector-presets">
			<div class="pum-click-selector-presets">
				<span class="dashicons dashicons-arrow-left" title="<?php _e( 'Insert Preset', 'popup-maker' ); ?>"></span>
				<ul>
					<?php foreach ( $presets as $preset => $label ) : ?>
						<li data-preset='<?php echo $preset; ?>'>
							<span><?php echo $label; ?></span>
						</li>
					<?php endforeach; ?>
				</ul>
			</div>
		</script>

		<script type="text/html" id="tmpl-pum-trigger-add-type">
			<#
			var form_args = <?php echo PUM_Utils_Array::safe_json_encode( array(
				'id'     => 'pum-add-trigger',
				'fields' => array(
					'popup_trigger_add_type'         => array(
						'id'      => 'popup_trigger_add_type',
						'name'    => "",
						'label'   => __( 'What kind of trigger do you want?', 'popup-maker' ),
						'type'    => 'select',
						'options' => PUM_Triggers::instance()->dropdown_list(),
					),
					'popup_trigger_add_cookie'       => array(
						'id'    => 'popup_trigger_add_cookie',
						'name'  => "",
						'type'  => 'checkbox',
						'std'   => true,
						'label' => __( 'Prevent popup from showing to visitor again using a cookie?', 'popup-maker' ),
						'meta'  => array('checked' => 'checked')
					),
					'popup_trigger_add_cookie_event' => array(
						'id'           => 'popup_trigger_add_cookie_event',
						'name'         => "",
						'type'         => 'select',
						'label'        => __( 'Stop showing popup once visitor takes this action:', 'popup-maker' ),
						'options'      => PUM_Cookies::instance()->dropdown_list(),
						'dependencies' => array(
							'popup_trigger_add_cookie' => true,
						),
					),
					'popup_trigger_add_cookie_info' => array(
						'id'      => 'popup_trigger_add_cookie_info',
						'type'    => 'html',
						'content' => '<p>Learn more about <a href="https://docs.wppopupmaker.com/article/358-popup-settings-box-cookies-option-settings?utm_campaign=contextual-help&utm_medium=inline-doclink&utm_source=plugin-popup-editor&utm_content=new-trigger-cookie-info">how Popup Maker cookies work</a>.</p>'
					),
				),
			) ); ?>,
			content = PUM_Admin.forms.render(form_args, {});

			print(PUM_Admin.templates.modal({
			id: 'pum_trigger_add_type_modal',
			title: '<?php _e( 'New Trigger', 'popup-maker' ); ?>',
			content: content,
			save_button: pum_admin_vars.I10n.add || '<?php __( 'Add', 'popup-maker' ); ?>'
			}));
			#>
		</script>

		<?php

	}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.