Warning: This method has been deprecated.

PUM_Modules_Reviews::admin_notices()

Render admin notices if available.


Description Description


Source Source

File: includes/modules/reviews.php

	public static function admin_notices() {
		if ( self::hide_notices() ) {
			return;
		}

		$group   = self::get_trigger_group();
		$code    = self::get_trigger_code();
		$pri     = self::get_current_trigger( 'pri' );
		$trigger = self::get_current_trigger();

		// Used to anonymously distinguish unique site+user combinations in terms of effectiveness of each trigger.
		$uuid = wp_hash( home_url() . '-' . get_current_user_id() );

		?>

		<script type="text/javascript">
			(function ($) {
				var trigger = {
					group: '<?php echo $group; ?>',
					code: '<?php echo $code; ?>',
					pri: '<?php echo $pri; ?>'
				};

				function dismiss(reason) {
					$.ajax({
						method: "POST",
						dataType: "json",
						url: ajaxurl,
						data: {
							action: 'pum_review_action',
							nonce: '<?php echo wp_create_nonce( 'pum_review_action' ); ?>',
							group: trigger.group,
							code: trigger.code,
							pri: trigger.pri,
							reason: reason
						}
					});

					<?php if ( ! empty( self::$api_url ) ) : ?>
					$.ajax({
						method: "POST",
						dataType: "json",
						url: '<?php echo self::$api_url; ?>',
						data: {
							trigger_group: trigger.group,
							trigger_code: trigger.code,
							reason: reason,
							uuid: '<?php echo $uuid; ?>'
						}
					});
					<?php endif; ?>
				}

				$(document)
					.on('click', '.pum-notice .pum-dismiss', function (event) {
						var $this = $(this),
							reason = $this.data('reason'),
							notice = $this.parents('.pum-notice');

						notice.fadeTo(100, 0, function () {
							notice.slideUp(100, function () {
								notice.remove();
							});
						});

						dismiss(reason);
					})
					.ready(function () {
						setTimeout(function () {
							$('.pum-notice button.notice-dismiss').click(function (event) {
								dismiss('maybe_later');
							});
						}, 1000);
					});
			}(jQuery));
		</script>

		<style>
			.pum-notice p {
				margin-bottom: 0;
			}

			.pum-notice img.logo {
				float: right;
				margin-left: 10px;
				width: 128px;
				padding: 0.25em;
				border: 1px solid #ccc;
			}
		</style>

		<div class="notice notice-success is-dismissible pum-notice">

			<p>
				<img class="logo" src="<?php echo POPMAKE_URL; ?>/assets/images/icon-256x256.jpg" />
				<strong>
					<?php echo $trigger['message']; ?>
					<br />
					~ danieliser
				</strong>
			</p>
			<ul>
				<li>
					<a class="pum-dismiss" target="_blank" href="<?php echo $trigger['link']; ?>>" data-reason="am_now">
						<strong><?php _e( 'Ok, you deserve it', 'popup-maker' ); ?></strong>
					</a>
				</li>
				<li>
					<a href="#" class="pum-dismiss" data-reason="maybe_later">
						<?php _e( 'Nope, maybe later', 'popup-maker' ); ?>
					</a>
				</li>
				<li>
					<a href="#" class="pum-dismiss" data-reason="already_did">
						<?php _e( 'I already did', 'popup-maker' ); ?>
					</a>
				</li>
			</ul>

		</div>

		<?php
	}

Top ↑

Changelog Changelog

Changelog
Version Description
1.8.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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