# wp-ultimate-post-grid/2.8.2/helpers/giveaway.php

WP Ultimate Post Grid, version 2.8.2. 39 lines.

- Page: https://pluginprobe.com/plugins/wp-ultimate-post-grid/2.8.2/code/helpers/giveaway.php
- Raw: https://pluginprobe.com/plugins/wp-ultimate-post-grid/2.8.2/raw/helpers/giveaway.php
- Modified: 2018-11-13T10:14:52+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wp-ultimate-post-grid/2.8.2/code/helpers/giveaway.php#L10-L20`.

```php
<?php

class WPUPG_Giveaway {

    public function __construct()
    {
        $now = new DateTime();
		$giveaway_start = new DateTime( '2018-11-06 10:00:00', new DateTimeZone( 'Europe/Brussels' ) );
		$giveaway_end = new DateTime( '2018-11-22 10:00:00', new DateTimeZone( 'Europe/Brussels' ) );

		if ( $giveaway_start < $now && $now < $giveaway_end ) {
			add_action( 'admin_menu', array( $this, 'add_submenu_page' ), 99 );
            add_action( 'admin_notices',    array( $this, 'giveaway_notice' ) );
		}
    }

    public function add_submenu_page()
    {
        add_submenu_page( 'edit.php?post_type=' . WPUPG_POST_TYPE, 'Giveaway', '~ Plugin Giveaway! ~', 'manage_options', 'wpupg_giveaway', array( $this, 'page_template' ) );
	}

	public function page_template() {
		echo '<div class="wrap">';
		echo '<h1>Plugin Giveaway</h1>';
		echo '<script src="https://static.airtable.com/js/embed/embed_snippet_v1.js"></script><iframe class="airtable-embed airtable-dynamic-height" src="https://airtable.com/embed/shrJNq8xN0gOqfEiY?backgroundColor=green" frameborder="0" onmousewheel="" width="100%" height="1535" style="background: transparent; border: 1px solid #ccc;"></iframe>';
		echo '</div>';
	}

    public function giveaway_notice()
    {
        $screen = get_current_screen();

        if ( 'edit-wpupg_grid' === $screen->id ) {
            echo '<div class="updated" style="padding: 10px;">';
			echo '<strong>Feeling lucky?</strong> Win plugins in our <a href="' . esc_url( admin_url( 'edit.php?post_type=' . WPUPG_POST_TYPE . '&page=wpupg_giveaway' ) ) . '" target="_blank">Black Friday Giveaway</a>!';
			echo '</div>';
        }
    }
}
```
