<?php

/**
 * Admin Screens
 */

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

add_filter( 'post_updated_messages', 'sg_updated_messages' );

/**
 * Adding customized messages
 *
 * @since 2.12.0
 *
 * @param array $messages
 *
 * @return array
 */
function sg_updated_messages( $messages ) {

	$messages['giveasap'] = array(
		0  => '', // Unused. Messages start at index 1.
		1  => $messages['post'][1],
		2  => $messages['post'][2],
		3  => $messages['post'][3],
		4  => $messages['post'][4],
		5  => $messages['post'][5],
		6  => $messages['post'][6],
		7  => $messages['post'][7],
		8  => $messages['post'][8],
		9  => $messages['post'][9],
		10 => $messages['post'][10],
		20 => __( 'Giveaway Ended.', 'giveasap' ),
		21 => __( 'Winners Selected. Check the right hand side "Users" box.', 'giveasap' ),
		22 => __( 'Winners notified. Check if all the winners were notified in the "Users" box.', 'giveasap' ),
        23 => __( 'Giveaway Cloned', 'giveasap' ),
        24 => __( 'Subscribers Reminded', 'giveasap' ),
	);

	return $messages;
}

add_action( 'admin_notices', 'sg_about_notice' );

function sg_about_notice() {
	if ( ! get_option( 'sg_about_page_was_read', false ) ) {
		?>
        <div class="update-nag sg-update-nag notice notice-success updated">
			<p><?php printf( __( 'Simple Giveaways was updated to version %s. Please read about the changes in the <a href="%s">About page</a>.', 'giveasap' ), gasap()->version(), admin_url( 'edit.php?post_type=giveasap&page=giveasap_about_page' ) ); ?></p>
        </div>
		<?php
	}
}

add_action( 'admin_init', 'sg_user_notify_by_email_from_user_list' );

function sg_user_notify_by_email_from_user_list() {
    if (
        isset( $_GET['resend_nonce'] )
        && isset( $_GET['post_type'] )
        && 'giveasap' === $_GET['post_type']
        && isset( $_GET['page'] )
        && 'giveasap-users' === $_GET['page']
        && isset( $_GET['action'] )
        && 'resend' === $_GET['action']
    ) {
	    $user = isset( $_GET['user'] ) ? absint( $_GET['user'] ) : 0;

	    if ( ! $user ) {
	        return;
        }

        if ( ! wp_verify_nonce( $_GET['resend_nonce'], 'giveasap_resend_email' ) ) {
            wp_die();
        }

	    $email = sg_send_registered_email( $user );

	    if ( $email->is_sent() ) {
	        $subscriber = $email->get_subscriber();
		    $redirect_link = admin_url( 'edit.php?post_type=giveasap&user_notified=' . $subscriber->email );

		    if ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] ) {
			    $redirect_link = add_query_arg( 'page', sanitize_text_field( $_REQUEST['page'] ), $redirect_link );
		    }

		    if ( isset( $_REQUEST['paged'] ) && $_REQUEST['paged'] ) {
			    $redirect_link = add_query_arg( 'paged', sanitize_text_field( $_REQUEST['paged'] ), $redirect_link );
		    }

		    if ( isset( $_REQUEST['id'] ) && absint( $_REQUEST['id'] ) ) {
			    $redirect_link = add_query_arg( 'id', absint( $_REQUEST['id'] ), $redirect_link );
		    }

		    wp_redirect( $redirect_link );
		    exit();
        }

    }
}

add_action( 'admin_init', 'sg_user_block_on_admin_request' );
function sg_user_block_on_admin_request() {
	if (
        isset( $_GET['post_type'] )
		&& 'giveasap' === $_GET['post_type']
		&& isset( $_GET['page'] )
		&& 'giveasap-users' === $_GET['page']
		&& isset( $_GET['action'] )
		&& 'block' === $_GET['action']
	) {

	    if ( ! current_user_can( 'manage_options' ) ) {
	        return;
        }

		$user = isset( $_GET['user'] ) ? absint( $_GET['user'] ) : 0;

		if ( ! $user ) {
			return;
		}

		$blocked = sg_block_subscriber( $user );

		if ( $blocked ) {
			$subscriber    = new SG_Subscriber( $user );
			$redirect_link = admin_url( 'edit.php?post_type=giveasap&user_blocked=' . $subscriber->get_email() );

			if ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] ) {
				$redirect_link = add_query_arg( 'page', sanitize_text_field( $_REQUEST['page'] ), $redirect_link );
			}

			if ( isset( $_REQUEST['paged'] ) && $_REQUEST['paged'] ) {
				$redirect_link = add_query_arg( 'paged', sanitize_text_field( $_REQUEST['paged'] ), $redirect_link );
			}

			if ( isset( $_REQUEST['id'] ) && absint( $_REQUEST['id'] ) ) {
				$redirect_link = add_query_arg( 'id', absint( $_REQUEST['id'] ), $redirect_link );
			}

			wp_redirect( $redirect_link );
			exit();
		}

	}
}

add_action( 'admin_init', 'sg_user_unblock_on_admin_request' );
function sg_user_unblock_on_admin_request() {
	if (
		isset( $_GET['post_type'] )
		&& 'giveasap' === $_GET['post_type']
		&& isset( $_GET['page'] )
		&& 'giveasap-users' === $_GET['page']
		&& isset( $_GET['action'] )
		&& 'unblock' === $_GET['action']
	) {

		if ( ! current_user_can( 'manage_options' ) ) {
			return;
		}

		$user = isset( $_GET['user'] ) ? absint( $_GET['user'] ) : 0;

		if ( ! $user ) {
			return;
		}

		$blocked = sg_unblock_subscriber( $user );

		if ( $blocked ) {
			$subscriber    = new SG_Subscriber( $user );
			$redirect_link = admin_url( 'edit.php?post_type=giveasap&user_unblocked=' . $subscriber->get_email() );

			if ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] ) {
				$redirect_link = add_query_arg( 'page', sanitize_text_field( $_REQUEST['page'] ), $redirect_link );
			}

			if ( isset( $_REQUEST['paged'] ) && $_REQUEST['paged'] ) {
				$redirect_link = add_query_arg( 'paged', sanitize_text_field( $_REQUEST['paged'] ), $redirect_link );
			}

			if ( isset( $_REQUEST['id'] ) && absint( $_REQUEST['id'] ) ) {
				$redirect_link = add_query_arg( 'id', absint( $_REQUEST['id'] ), $redirect_link );
			}

			wp_redirect( $redirect_link );
			exit();
		}

	}
}


add_action( 'admin_init', 'sg_perform_subscriber_entries_actions' );
function sg_perform_subscriber_entries_actions() {
    global $wpdb;

	if (
		isset( $_GET['post_type'] )
		&& 'giveasap' === $_GET['post_type']
		&& isset( $_GET['page'] )
		&& 'giveasap-subscriber-entries' === $_GET['page']
		&& isset( $_GET['subscriber'] )
		&& isset( $_GET['action_id'] )
		&& isset( $_GET['action'] )
	) {

		if ( ! current_user_can( 'manage_options' ) ) {
			return;
		}

		$subscriber_id = isset( $_GET['subscriber'] ) ? absint( $_GET['subscriber'] ) : 0;

		if ( ! $subscriber_id ) {
			return;
		}

		$action_id = isset( $_GET['action_id'] ) ? absint( $_GET['action_id'] ) : 0;

		if ( ! $action_id ) {
		    return;
        }

        $action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : '';

		if ( ! $action ) {
		    return;
        }

        switch ( $action ) {
            case 'delete_action_entry':
                $action_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . $wpdb->giveasap_actions . " WHERE id=%d", $action_id ), ARRAY_A );
                $delete      = $wpdb->delete( $wpdb->giveasap_actions, array(
                    'id' => $action_id
                ));

                if ( false !== $delete ) {
                    $entries = intval( $action_data['entries'] );
                    $subscriber = sg_get_subscriber( $subscriber_id );
                    $subscriber->remove_entries( $entries );
	                $redirect_link = admin_url( 'edit.php?post_type=giveasap' );

	                if ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] ) {
		                $redirect_link = add_query_arg( 'page', sanitize_text_field( $_REQUEST['page'] ), $redirect_link );
	                }

	                if ( isset( $_REQUEST['paged'] ) && $_REQUEST['paged'] ) {
		                $redirect_link = add_query_arg( 'paged', sanitize_text_field( $_REQUEST['paged'] ), $redirect_link );
	                }

	                if ( isset( $_REQUEST['subscriber'] ) && absint( $_REQUEST['subscriber'] ) ) {
		                $redirect_link = add_query_arg( 'subscriber', absint( $_REQUEST['subscriber'] ), $redirect_link );
	                }

	                wp_redirect( $redirect_link );
	                exit();
                }
                break;
            case 'complete_action_entry':
	            $action_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . $wpdb->giveasap_actions . " WHERE id=%d", $action_id ), ARRAY_A );
                $update      = $wpdb->update( $wpdb->giveasap_actions, array( 'status' => 'completed' ), array( 'id' => $action_id ) );
                if ( false !== $update ) {
	                $entries    = intval( $action_data['entries'] );
	                $subscriber = sg_get_subscriber( $subscriber_id );
	                $subscriber->add_entries( $entries );

	                $redirect_link = admin_url( 'edit.php?post_type=giveasap' );

	                if ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] ) {
		                $redirect_link = add_query_arg( 'page', sanitize_text_field( $_REQUEST['page'] ), $redirect_link );
	                }

	                if ( isset( $_REQUEST['paged'] ) && $_REQUEST['paged'] ) {
		                $redirect_link = add_query_arg( 'paged', sanitize_text_field( $_REQUEST['paged'] ), $redirect_link );
	                }

	                if ( isset( $_REQUEST['subscriber'] ) && absint( $_REQUEST['subscriber'] ) ) {
		                $redirect_link = add_query_arg( 'subscriber', absint( $_REQUEST['subscriber'] ), $redirect_link );
	                }

	                wp_redirect( $redirect_link );
	                exit();
                }
	            break;
	        case 'invalid_action_entry':
		        $action_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . $wpdb->giveasap_actions . " WHERE id=%d", $action_id ), ARRAY_A );
		        $update      = $wpdb->update( $wpdb->giveasap_actions, array( 'status' => 'invalid' ), array( 'id' => $action_id ) );
		        if ( false !== $update ) {
			        $entries    = intval( $action_data['entries'] );
			        $subscriber = sg_get_subscriber( $subscriber_id );
			        $subscriber->remove_entries( $entries );

			        $redirect_link = admin_url( 'edit.php?post_type=giveasap' );

			        if ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] ) {
				        $redirect_link = add_query_arg( 'page', sanitize_text_field( $_REQUEST['page'] ), $redirect_link );
			        }

			        if ( isset( $_REQUEST['paged'] ) && $_REQUEST['paged'] ) {
				        $redirect_link = add_query_arg( 'paged', sanitize_text_field( $_REQUEST['paged'] ), $redirect_link );
			        }

			        if ( isset( $_REQUEST['subscriber'] ) && absint( $_REQUEST['subscriber'] ) ) {
				        $redirect_link = add_query_arg( 'subscriber', absint( $_REQUEST['subscriber'] ), $redirect_link );
			        }

			        wp_redirect( $redirect_link );
			        exit();
		        }
		        break;
        }

	}
}

/**
 * Showing the list of all users
 *
 * @return void
 */
function giveasap_user_list_screen() {

	if ( isset( $_GET['action'] ) && 'view' === $_GET['action'] ) {
		sg_admin_show_subscriber( isset( $_GET['user'] ) ? $_GET['user'] : 0 );
	} elseif ( isset( $_GET['action'] ) && 'sg_add_subscriber' === $_GET['action'] ) {
		sg_admin_add_subscriber();
	} else {

		$ga_id = isset( $_GET['id'] ) ? $_GET['id'] : false;

		$users_list = new GA_Users_Table();

		?>
        <div class="wrap">
            <h1 class="wp-heading-inline">
				<?php echo sprintf( __( 'Giveaway Subscribers: <strong>%s</strong>', 'giveasap' ), get_the_title( $ga_id ) ) ?>
                <a href="<?php echo admin_url( 'edit.php?post_type=giveasap&page=giveasap-users&action=sg_add_subscriber' ); ?>" class="page-title-action"><?php esc_html_e( 'Add Subscriber', 'giveasap' ); ?></a>
				<?php
				if ( $ga_id ) {
					?>
                    <a href="<?php echo admin_url( 'post.php?post=' . $ga_id . '&action=edit' ); ?>"
                       class="button button-default"><?php _e( 'Go back to the Giveaway', 'giveasap' ); ?></a>
				<?php } ?>
            </h1>
            <form method="post">
				<?php
				$users_list->prepare_items();
				$users_list->display(); ?>
            </form>
        </div>
		<?php
	}
}

/**
 * Showing the list of all entries for a subscriber
 *
 * @return void
 */
function giveasap_subscriber_entries_screen() {

    $subscriber_id = isset( $_GET['subscriber'] ) ? $_GET['subscriber'] : false;
    $giveaway_id   = isset( $_REQUEST['giveaway'] ) ? absint( $_REQUEST['giveaway'] ) : 0;
    $subscriber    = null;

    if ( $subscriber_id ) {
	    $subscriber = sg_get_subscriber( $subscriber_id );
	    $subscriber->get_data();
    }

    $table = new SG_Subscriber_Entries_Table();


    ?>
    <div class="wrap sg-subscriber-entries-table">
        <h1 class="wp-heading-inline">
            <?php echo __( 'Entries', 'giveasap' ) ?>
            <a href="<?php echo admin_url( 'edit.php?post_type=giveasap&page=giveasap-users' ); ?>" class="page-title-action"><?php esc_html_e( 'Back to Subscribers', 'giveasap' ); ?></a>
        </h1>
        <?php

	        if ( $giveaway_id ) {
		        ?>
                <h2><?php esc_html_e( 'Giveaway:', 'giveasap' ); ?> <strong><?php echo esc_html( get_the_title( $giveaway_id ) ); ?></strong></strong></h2>
	        <?php }

            if ( $subscriber ) {
	        ?>
            <p><?php esc_html_e( 'Subscriber:', 'giveasap' ); ?> <strong><?php echo esc_html( $subscriber->get_email() ); ?></strong> | <?php esc_html_e( 'Entries:', 'giveasap' ); ?> <strong><?php echo esc_html( $subscriber->get_entries() ); ?></strong></p>
            <?php } ?>
            <form method="post">
		        <?php
		        $table->prepare_items();
		        $table->display(); ?>
            </form>
	        <?php

            ?>
    </div>
    <?php

}

/**
 * Displaying the form to add the subscriber.
 *
 * @since 2.20.0
 */
function sg_admin_add_subscriber() {
    $giveaways = sg_get_giveaways();
    $errors    = array();
    $success   = array();
    if ( isset( $_POST['sg_add_subscriber_submit'] ) ) {
        $form = isset( $_POST['sg_form'] ) ? $_POST['sg_form'] : false;

        if ( false !== $form ) {
	        $giveaway_id = isset( $form['giveaway'] ) ? $form['giveaway'] : 0;
	        $email       = isset( $form['user_email'] ) ? $form['user_email'] : '';
	        if ( $giveaway_id && $email ) {
		        $giveaway = sg_get_giveaway( $giveaway_id );

		        if ( $giveaway->is_open_to_subscribe() ) {
			        $new_subscriber = $giveaway->add_subscriber( $form['user_email'] );
			        if ( is_wp_error( $new_subscriber ) ) {
				        $errors[] = $new_subscriber->get_error_message();
			        } else {
				        $success[] = __( 'Subscriber added.', 'giveasap' );
                    }
		        }
	        } else {
		        if ( ! $giveaway_id ) {
		            $errors[] = __( 'Please, select a giveaway.', 'giveasap' );
		        }

		        if ( ! $email ) {
			        $errors[] = __( 'Please, enter an email.', 'giveasap' );
                }
	        }
        }
    }
	?>
    <div class="wrap">
        <h1 class="wp-heading-inline">
            <?php echo __( 'New Giveaway Subscriber', 'giveasap' ); ?>
            <a href="<?php echo admin_url( 'edit.php?post_type=giveasap&page=giveasap-users' ); ?>" class="page-title-action"><?php esc_html_e( 'Back to Subscribers', 'giveasap' ); ?></a>
        </h1>
        <?php
            if ( $errors ) {
                foreach ( $errors as $error ) {
	                echo '<div class="notice error"><p>' . $error . '</p></div>';
                }
            }

        if ( $success ) {
	        foreach ( $success as $info ) {
		        echo '<div class="notice updated"><p>' . $info . '</p></div>';
	        }
        }
        ?>
        <?php
            if ( $giveaways ) {
                ?>
                <br/>
                <div class="postbox">
                    <form class="sg-admin-form" method="post" action="<?php echo admin_url( 'edit.php?post_type=giveasap&page=giveasap-users&action=sg_add_subscriber' ); ?>">
                        <div class="sg-form-field">

                            <label for="sg_giveaway_add_subscriber"><?php esc_html_e( 'Giveaway', 'giveasap' ); ?></label>

                            <select id="sg_giveaway_add_subscriber" name="sg_form[giveaway]">
                                <option value="0"><?php esc_html_e( 'Select a Giveaway', 'giveasap' ); ?></option>
                                <?php
                                foreach ( $giveaways as $giveaway ) {
                                    echo '<option value="' . $giveaway->ID . '">' . esc_html( $giveaway->post_title ) . '</option>';
                                }
                                ?>
                            </select>

                        </div>
                        <div id="sgGiveawayFields" class="form-table">
                            <?php
                            $fields = sg_get_form_fields( 0 );

                            if ( $fields ) {
                                foreach( $fields as $field ) {
                                    sg_render_form_field( $field );
                                }
                            }
                            ?>
                        </div>
                        <?php do_action( 'sg_add_subscriber_form_bottom' ); ?>
                        <input type="submit" class="button button-primary" name="sg_add_subscriber_submit" value="<?php esc_attr_e( 'Add Subscriber', 'giveasap' ); ?>">
                    </form>
                </div>
                <?php
            } else {
                echo '<p class="sg-notice">' . esc_html__( 'There are no active giveaways to add a subscriber to. Please create a new Giveaway.', 'giveasap' );
            }
        ?>
    </div>
	<?php
}

/**
 * Show subscriber
 *
 * @param $entry_id
 */
function sg_admin_show_subscriber( $entry_id ) {

	?>
    <div class="wrap">
        <h2><?php echo __( 'Giveaway Subscriber', 'giveasap' ); ?></h2>
		<?php
		if ( ! $entry_id ) {
			echo '<p class="description">' . esc_html( 'Please select a subscriber', 'giveasap' ) . '</p>';
		} else {
			include 'views/subscriber/view.php';
		}
		?>
    </div>
	<?php
}

/**
 * Showing Integrations
 *
 * @return void
 */
function giveasap_integrations() {

	$integrations        = giveasap_get_integrations();
	$active_integrations = get_option( 'giveasap_active_integrations', array() );
	$integration         = isset( $_GET['integration'] ) ? $_GET['integration'] : false;
	$integration_object  = false;

	if ( $integration && isset( $integrations[ $integration ] ) ) {
		$class              = $integrations[ $integration ];
		$integration_object = new $class();
		$integration_object->save_if_submit();
		$integration_object->init_settings();
	}
	?>
    <div class="wrap">
        <style>
            .plugin-icon {
                height: auto;
                top: 0;
                bottom: 0;
                margin: auto;
            }
        </style>
        <h1><?php echo get_admin_page_title(); ?></h1>
        <p><?php _e( 'All Simple Giveaways Integrations. Choose which to use and activate them.', 'giveasap' ); ?></p>

        <div class="wp-list-table widefat plugin-install">
            <div id="the-list">
				<?php
				if ( $integration_object ) {

					echo '<h2>' . $integration_object->title . '</h2>';
					echo '<a href="' . admin_url( 'edit.php?post_type=giveasap&page=giveasap_integrations' ) . '">' . __( 'Back to Integrations', 'giveasap' ) . '</a>';
					if ( isset( $_GET['section'] ) && 'documentation' == $_GET['section'] && $integration_object->has_documentation ) {
						$integration_object->documentation();
					} else {
						?>
                        <form id="<?php echo $integration_object->settings_id; ?>" method="POST" action="">

                            <table class="form-table">
								<?php
								$integration_object->render_fields();
								?>
                            </table>
                            <button type="submit" name="<?php echo $integration_object->settings_id; ?>_save"
                                    class="button button-primary">
								<?php _e( 'Save', 'textdomain' ); ?>
                            </button>
                        </form>
						<?php
					}

				} elseif ( $integrations ) {
					foreach ( $integrations as $slug => $class ) {
						$integration_object = new $class();
						?>
                        <div class="plugin-card plugin-card-<?php echo $slug; ?>">
                            <div class="plugin-card-top">
                                <div class="name column-name">
                                    <h3>
										<?php echo $integration_object->title; ?>
                                        <img src="<?php echo $integration_object->image; ?>" class="plugin-icon" alt="">

                                    </h3>
                                </div>
                                <div class="desc column-description">
                                    <p><?php echo $integration_object->desc; ?></p>
                                </div>
                            </div>
                            <div class="plugin-card-bottom">

								<?php $integration_object->buttons( $active_integrations ); ?>

                            </div>
                        </div>
						<?php
					}
				}
				?>
            </div>
        </div>
    </div>
	<?php
}

/**
 * About Page for showing all features
 */
function giveasap_about_page() {
	update_option( 'sg_about_page_was_read', true );
	$display_version = gasap()->version();

	?>
    <script>
        (function ($) {
            $('.sg-update-nag').hide();
        })(jQuery);
    </script>
    <div class="wrap about-wrap full-width-layout sg-about-page">
        <h1><?php printf( __( 'Simple Giveaways %s', 'giveasap' ), $display_version ); ?></h1>

        <p class="about-text"><?php _e( 'Thank you for updating to the latest version! You can check new features in this page.', 'giveasap' ); ?></p>
        <p class="about-text"><a target="_blank" href="http://www.wpsimplegiveaways.com/category/changelog/"><?php _e( 'Read about the latest versions here.', 'giveasap' ); ?></a></p>

       <?php /* <ul>
            <li><em>Minor Changes:</em></li>
            <li>
                <strong>2.28.2</strong>
                <ul>
                    <li>Fix: Redirect link was also used in emails. Now it only uses the correct one (shortcode or landing page).</li>
                    <li>Fix: Share Link could include reference parameter which might login another user.</li>
                    <li>Fix: Share link attribute for sharing could be encoded incorrectly.</li>
                    <li>Update: MailChimp Logo.</li>
                </ul>
            </li>
            <li>
                <strong>2.28.1</strong>
                <ul>
                    <li>Fix (Premium): Multiple Prizes test was included.</li>
                </ul>
            </li>

        </ul>*/?>

        <div class="floating-header-section">
            <div class="section-header">
                <h2><?php _e( 'New Features', 'giveasap' ); ?><em
                            style="font-size:0.5em;line-height: 1;display:block;color:#555d66;font-weight: 400;"><?php _e( 'This features are available in both free and premium.', 'giveasap' ); ?></em>
                </h2>
            </div>

            <div class="section-content has-2-columns feature-section two-col --fourth-col">
                <div class="section-item column col">
                    <div class="inline-svg section-image purple">
                        <i class="fal fa-comment fa-7x"></i>
                    </div>
                    <h3>Leave a Comment action</h3>
                    <p>You can now award a user for posting a comment. This is a manual verification action.</p>

                </div>

                <div class="section-item column col">
                    <div class="inline-svg section-image ">
                        <i class="fal fa-user fa-7x"></i>
                    </div>
                    <h3>Register on Website Action</h3>
                    <p>Award users for registering on your website and grow your membership/site.</p>

                </div>

                <div class="section-item column col">
                    <div class="inline-svg section-image purple">
                        <i class="fal fa-users fa-7x"></i>
                    </div>
                    <h3>Export Entries to CSV</h3>
                    <p>You can now export entries you find on Giveaways > Entries. It also uses the same filtering.</p>
                </div>

                <div class="section-item column col">
                    <div class="inline-svg   section-image ">
                        <i class="fal fa-sort fa-7x"></i>
                    </div>
                    <h3>Sort Entries by Email or Giveaway</h3>
                    <p>You can now sort entries on the Entries page by email and/or Giveaway.</p>
                </div>

                <div class="section-item column col">
                    <div class="inline-svg purple  section-image ">
                        <i class="fal fa-keyboard fa-7x"></i>
                    </div>
                    <h3>Form Fields Values in Emails</h3>
                    <p>You can now use placeholders for values from Form Fields in Emails: Subscribed, Winner and Reminder. Check the placeholder information.</p>
                </div>

                <div class="section-item column col">
                    <div class="inline-svg section-image">
                        <i class="fal fa-cog fa-7x"></i>
                    </div>
                    <h3>Fixes</h3>
                    <p>The "Show Content" button is now defined by the "more" tag in the editor.</p>
                    <p>Share link input is now fixed so the "copy" icon does not overlap the last few characters.</p>
                </div>
	            <?php /*
                <div class="section-item col">
                    <div class="inline-svg section-image">
                        <i class="fal fa-envelope fa-7x"></i>
                    </div>
                    <h3>Re-send Emails</h3>
                    <p>You can now send the subscription email from the Subscribers screen for each email. This feature is useful if your subscribers notify you about missing out the email.</p>
                </div>

                <div class="section-item col">
                    <div class="inline-svg section-image purple">
                        <i class="fal fa-pencil-paintbrush fa-7x"></i>
                    </div>
                    <h3>Email Template</h3>
                    <p>We've changed the email template for a more structured email layout. You can add your logo to emails and also change the colors.</p>
                </div>


	           <div class="section-item col">
                    <div class="inline-svg section-image">
                        <i class="fal fa-user fa-7x"></i>
                    </div>
                    <h3><?php _e( 'Subscriber Page', 'giveasap' ); ?></h3>
                    <p>You can now view all the information about a subscriber on their own pages.</p>
                </div>
				<div class="section-item">
                    <div class="inline-svg purple">
                        <i class="fal fa-eye-slash fa-7x"></i>
                    </div>
                    <h3><?php _e( 'Hidden Content', 'giveasap' ); ?></h3>
                    <p>Subscribers will now have the content of the giveaway hidden at first. They will see the sharing options much sooner :)</p>
                </div>
                <div class="section-item">
                    <div class="inline-svg purple">
                        <i class="fal fa-sitemap fa-7x"></i>
                    </div>
                    <h3><?php _e( 'Site Header & Footer', 'giveasap' ); ?></h3>
                    <p>You can now decide for each giveaway to include the header and the footer of your site.</p>
                </div>
                <div class="section-item">
                    <div class="inline-svg ">
                        <i class="fal fa-trophy-alt fa-7x"></i>
                    </div>
                    <h3><?php _e( 'Winner in Giveaway Columns', 'giveasap' ); ?></h3>
                    <p>When a winner is chosen, the winner will be shown in the list of all giveaways (in the admin).</p>
                </div>*/ ?>
            </div>
        </div>

        <?php /* Premium Section */ ?>
        <div class="floating-header-section">
            <div class="section-header">
                <h2><?php _e( 'Premium Features' ); ?>
					<?php
					if ( ! defined( 'GIVEASAP_PRO' ) ) {
						?>
                        <em style="display:block;">
                            <a href="<?php echo giv_fs()->get_upgrade_url(); ?>"
                               class="button button-primary"><?php _e( 'Upgrade to PRO', 'giveasap' ); ?></a>
                        </em>
						<?php
					}
					?>
                </h2>
            </div>

            <div class="section-content has-2-columns feature-section two-col --three-col">

                <div class="section-item col column">
                    <div class="inline-svg section-image" style="background: white;">
                        <img style="width:100px;" src="<?php echo untrailingslashit( GASAP_URI ) . '/includes/integrations/assets/fluentcrm.svg'; ?>" alt="">
                    </div>
                    <h3>FluentCRM Integration</h3>
                    <p>You can now send users to your lists in FluentCRM and grow your contact list.</p>
                </div>

                <div class="section-item col column">
                    <div class="inline-svg section-image purple" >
                        <i class="fab fa-youtube fa-7x"></i>
                    </div>
                    <h3>Watch a Youtube video action Fixes</h3>
                    <p>Video will be shown even if completed.</p>
                    <p>Video will be paused if we collapse the action.</p>
                </div>

	            <?php /*<div class="section-item col column">
                    <div class="inline-svg purple section-image">
                        <i class="fal fa-plus-square fa-7x"></i>
                    </div>
                    <h3>Extra Entries Actions (Premium)</h3>
                    <p>Old extra entries are now converted to new ones. The new actions are Facebook, Twitter, Instragram and YouTube visits.</p>
                </div>
	            <div class="section-item col">
                    <div class="inline-svg section-image purple">
                        <img src="<?php echo untrailingslashit( GASAP_URI ) . '/includes/integrations/assets/mailster-logo.png'; ?>" alt="">
                    </div>
                    <h3>Mailster</h3>
                    <p>You can connect your giveaways with Mailster.</p>
                </div>
	            <div class="section-item col">
                    <div class="inline-svg section-image ">
                        <img src="<?php echo untrailingslashit( GASAP_URI ) . '/includes/integrations/assets/convertkit-logo.png'; ?>" alt="">
                    </div>
                    <h3><?php _e( 'ConvertKit - Form Builder', 'giveasap' ); ?></h3>
                    <p>You can now connect custom fields from ConvertKit with custom fields.</p>
                </div>

                <div class="section-item col">
                    <div class="inline-svg purple section-image">
                        <i class="fal fa-palette fa-7x"></i>
                    </div>
                    <h3><?php _e( 'Fixes', 'giveasap' ); ?></h3>
                    <p>Fixed the error when trying to delete a single subscriber.</p>
                </div>
				<div class="section-item">
                    <div class="inline-svg section-image purple">
                        <img src="https://static.mailchimp.com/web/brand-assets/mc_freddie_color_web.png" alt="">
                    </div>
                    OR <div class="section-image">
                        <img src="<?php echo trailingslashit(GASAP_URI ); ?>admin/documentation/images/custom-share.png" />
                    </div>
                    <h3><?php _e( 'MailChimp - Double Opt-in', 'giveasap' ); ?></h3>
                    <p><?php _e( 'You can choose if your subscriber on MailChimp have to confirm before getting into the list. This will not change their entry in the giveaway.', 'giveasap' ); ?></p>
                </div>*/ ?>
            <?php /* Premium section */ ?>
            </div>
        </div>

	    <?php /* Business Section */ ?>
        <?php /* START */ ?>
        <div class="floating-header-section">
            <div class="section-header">
                <h2><?php _e( 'Business Features' ); ?>
				    <?php
				    if ( ! defined( 'GIVEASAP_PRO' ) || ! giv_fs()->is_plan('business') ) {
					    ?>
                        <em style="display:block;">
                            <a href="<?php echo giv_fs()->get_upgrade_url(); ?>"
                               class="button button-primary"><?php _e( 'Upgrade to Business', 'giveasap' ); ?></a>
                        </em>
					    <?php
				    }
				    ?>
                </h2>
            </div>

            <div class="section-content has-2-columns feature-section two-col --three-col ">

                <div class="section-item col column">
                    <div class="inline-svg section-image" style="background: white;">
                        <img src="<?php echo untrailingslashit( GASAP_URI ) . '/includes/integrations/assets/woocommerce_logo.svg'; ?>" alt="">
                    </div>
                    <h3>WooCommerce Follow-Up Emails Integration</h3>
                    <p>Send a delayed email after a user has subscribed to a Giveaway.</p>
                </div>

	            <?php /*<div class="section-item col column">
                    <div class="inline-svg section-image" style="background: white;">
                        <img src="<?php echo untrailingslashit( GASAP_URI ) . '/includes/integrations/assets/edd.svg'; ?>" alt="">
                    </div>
                    <h3>Easy Digital Downloads Integration</h3>
                    <p>Easy Digital Downloads Product can add extra entries when bought.</p>
                </div>



			    <div class="section-item col column">
                    <div class="inline-svg purple section-image">
                        <i class="fal fa-plus-square fa-7x"></i>
                    </div>
                    <h3>Extra Entries Actions (Premium)</h3>
                    <p>Old extra entries are now converted to new ones. The new actions are Facebook, Twitter, Instragram and YouTube visits.</p>
                </div>
	            <div class="section-item col">
                    <div class="inline-svg section-image purple">
                        <img src="<?php echo untrailingslashit( GASAP_URI ) . '/includes/integrations/assets/mailster-logo.png'; ?>" alt="">
                    </div>
                    <h3>Mailster</h3>
                    <p>You can connect your giveaways with Mailster.</p>
                </div>
	            <div class="section-item col">
                    <div class="inline-svg section-image ">
                        <img src="<?php echo untrailingslashit( GASAP_URI ) . '/includes/integrations/assets/convertkit-logo.png'; ?>" alt="">
                    </div>
                    <h3><?php _e( 'ConvertKit - Form Builder', 'giveasap' ); ?></h3>
                    <p>You can now connect custom fields from ConvertKit with custom fields.</p>
                </div>

                <div class="section-item col">
                    <div class="inline-svg purple section-image">
                        <i class="fal fa-palette fa-7x"></i>
                    </div>
                    <h3><?php _e( 'Fixes', 'giveasap' ); ?></h3>
                    <p>Fixed the error when trying to delete a single subscriber.</p>
                </div>
				<div class="section-item">
                    <div class="inline-svg section-image purple">
                        <img src="https://static.mailchimp.com/web/brand-assets/mc_freddie_color_web.png" alt="">
                    </div>
                    OR <div class="section-image">
                        <img src="<?php echo trailingslashit(GASAP_URI ); ?>admin/documentation/images/custom-share.png" />
                    </div>
                    <h3><?php _e( 'MailChimp - Double Opt-in', 'giveasap' ); ?></h3>
                    <p><?php _e( 'You can choose if your subscriber on MailChimp have to confirm before getting into the list. This will not change their entry in the giveaway.', 'giveasap' ); ?></p>
                </div>*/ ?>

        <?php /* BusinessEND: */ ?>
            </div>
        </div> <?php /*END */ ?>

        <hr/>

		<?php /*<div class="changelog">
            <h2>
                <?php
                _e( 'Changelog', 'giveasap' );

                ?>
            </h2>
            <p>If winner(s) field is empty, the giveaway template will not display winner meta information.</p>
            <p>Added customized admin notices when changing giveaway statuses.</p>


        </div>

        <hr />*/ ?>

        <div class="return-to-dashboard">
            <a href="<?php echo esc_url( self_admin_url() ); ?>"><?php is_blog_admin() ? _e( 'Go to Dashboard &rarr; Home' ) : _e( 'Go to Dashboard' ); ?></a>
        </div>
    </div>
	<?php
}