PUM_Triggers::register_triggers()

Registers all known triggers when called.


Description Description


Source Source

File: classes/Triggers.php

	public function register_triggers() {
		$triggers = apply_filters(
			'pum_registered_triggers',
			array(
				'click_open'      => array(
					'name'            => __( 'Click Open', 'popup-maker' ),
					'modal_title'     => __( 'Click Trigger Settings', 'popup-maker' ),
					'settings_column' => sprintf( '<strong>%1$s</strong>: %2$s', __( 'Extra Selectors', 'popup-maker' ), '{{data.extra_selectors}}' ),
					'fields'          => array(
						'general'  => array(
							'click_info'      => array(
								'type'    => 'html',
								'content' => '<p>' . __( 'Adding the class "popmake-<span id="pum-default-click-trigger-class">{popup-ID}</span>" to an element will trigger it to be opened once clicked. Additionally you can add additional CSS selectors below.', 'popup-maker' ) . '</p>',
							),
							'extra_selectors' => array(
								'label'       => __( 'Extra CSS Selectors', 'popup-maker' ),
								'desc'        => __( 'For more than one selector, separate by comma (,)', 'popup-maker' ) . '<br /><strong>eg:  </strong>' . __( ' .class-here, .class-2-here, #button_id', 'popup-maker' ),
								'placeholder' => __( '.class-here', 'popup-maker' ),
								'doclink'     => 'https://docs.wppopupmaker.com/article/147-getting-css-selectors?utm_campaign=contextual-help&utm_medium=inline-doclink&utm_source=plugin-popup-editor&utm_content=extra-selectors',
							),
						),
						'advanced' => array(
							'do_default' => array(
								'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' ),
							),
						),
					),
				),
				'auto_open'       => array(
					'name'            => __( 'Time Delay / Auto Open', 'popup-maker' ),
					'modal_title'     => __( 'Time Delay Settings', 'popup-maker' ),
					'settings_column' => sprintf( '<strong>%1$s</strong>: %2$s', __( 'Delay', 'popup-maker' ), '{{data.delay}}' ),
					'fields'          => array(
						'general' => array(
							'delay' => array(
								'type'  => 'rangeslider',
								'label' => __( 'Delay', 'popup-maker' ),
								'desc'  => __( 'The delay before the popup will open in milliseconds.', 'popup-maker' ),
								'std'   => 500,
								'min'   => 0,
								'max'   => 10000,
								'step'  => 500,
								'unit'  => 'ms',
							),
						),
					),
				),
				'form_submission' => array(
					'name'   => __( 'Form Submission', 'popup-maker' ),
					//'settings_column' => sprintf( '<strong>%1$s</strong>: %2$s', __( 'Form', 'popup-maker' ), '' ),
					'fields' => array(
						'general' => array(
							'form'  => array(
								'type'    => 'select',
								'label'   => __( 'Form', 'popup-maker' ),
								'options' => $this->preload_posts ? array_merge(
									array(
										'any' => __( 'Any Supported Form*', 'popup-maker' ),
										__( 'Popup Maker', 'popup-maker' ) => array(
											'pumsubform' => __( 'Subscription Form', 'popup-maker' ),
										),
									),
									PUM_Integrations::get_integrated_forms_selectlist()
								) : array(),
								'std'     => 'any',
							),
							'delay' => array(
								'type'  => 'rangeslider',
								'label' => __( 'Delay', 'popup-maker' ),
								'desc'  => __( 'The delay before the popup will open in milliseconds.', 'popup-maker' ),
								'std'   => 0,
								'min'   => 0,
								'max'   => 10000,
								'step'  => 500,
								'unit'  => 'ms',
							),
						),
					),
				),
			)
		);

		foreach ( $triggers as $key => $trigger ) {
			$triggers[ $key ]['fields'] = PUM_Admin_Helpers::parse_tab_fields(
				$triggers[ $key ]['fields'],
				array(
					'has_subtabs' => false,
					'name'        => '%s',
				)
			);
		}

		// @deprecated filter.
		$old_triggers = apply_filters( 'pum_get_triggers', array() );

		foreach ( $old_triggers as $type => $trigger ) {
			if ( isset( $triggers[ $type ] ) ) {
				continue;
			}

			if ( ! empty( $trigger['fields'] ) ) {
				foreach ( $trigger['fields'] as $tab_id => $tab_fields ) {
					foreach ( $tab_fields as $field_id => $field ) {
						if ( ! empty( $field['options'] ) ) {
							$trigger['fields'][ $tab_id ][ $field_id ]['options'] = array_flip( $trigger['fields'][ $tab_id ][ $field_id ]['options'] );
						}
					}
				}
			}

			$triggers[ $type ] = $trigger;
		}

		$this->add_triggers( $triggers );
	}


Top ↑

User Contributed Notes User Contributed Notes

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