<?php

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

function giveasap_documentation() {
	$giveasap_documentation_url        = GASAP_URI . '/admin/documentation/';
	$giveasap_documentation_images_url = $giveasap_documentation_url . 'images/';
	$active_tab                        = 'general';

	if ( isset( $_GET['tab'] ) ) {
		$active_tab = \Simple_Giveaways\Helpers::unslash_and_clean( $_GET['tab'] );
	}
	?>
	<div class="wrap">
		<h2><?php esc_html_e( 'Simple Giveaways Documentation', 'giveasap' ); ?></h2>
		<p class="description"><?php esc_html_e( 'Read documentation and find out how to use Simple Giveaways to create giveaways', 'giveasap' ); ?></p>
		<h2 class="nav-tab-wrapper woo-nav-tab-wrapper">

			<a href="<?php echo admin_url( 'edit.php?post_type=giveasap&page=giveasap_documentation&tab=general' ); ?>" class="nav-tab 
								<?php
								if ( $active_tab == 'general' ) {
									echo 'nav-tab-active'; }
								?>
			"><?php esc_html_e( 'General', 'giveasap' ); ?></a>
			<a href="<?php echo admin_url( 'edit.php?post_type=giveasap&page=giveasap_documentation&tab=settings' ); ?>" class="nav-tab 
								<?php
								if ( $active_tab == 'settings' ) {
									echo 'nav-tab-active'; }
								?>
			"><?php esc_html_e( 'Settings', 'giveasap' ); ?></a>
			<a href="<?php echo admin_url( 'edit.php?post_type=giveasap&page=giveasap_documentation&tab=shortcodes' ); ?>" class="nav-tab 
								<?php
								if ( $active_tab == 'shortcodes' ) {
									echo 'nav-tab-active'; }
								?>
			"><?php esc_html_e( 'Shortcodes', 'giveasap' ); ?></a>
			<a href="<?php echo admin_url( 'edit.php?post_type=giveasap&page=giveasap_documentation&tab=pro' ); ?>" class="nav-tab 
								<?php
								if ( $active_tab == 'pro' ) {
									echo 'nav-tab-active'; }
								?>
			"><?php esc_html_e( 'PRO', 'giveasap' ); ?></a>

		</h2>
		<br/>
		<div id="poststuff">
			<div id="post-body" class="metabox-holder columns-2">
				<div id="post-body-content" style="position: relative;">
					<?php call_user_func( 'giveasap_documentation_' . $active_tab ); ?>
				</div>
				<div id="postbox-container-1" class="postbox-container">
					<div id="side-sortables" class="meta-box-sortables ui-sortable">
						<a href="https://wordpress.org/support/view/plugin-reviews/giveasap" target="_blank">
							<img style="max-width: 100%;height:auto"; width="280" src="<?php echo esc_url( $giveasap_documentation_images_url ); ?>giveasap-rate.png" />
			
						</a>
						 <?php if ( ! defined( 'GIVEASAP_PRO' ) ) { ?>
						<br/>
						<!-- Begin MailChimp Signup Form -->
						<link href="//cdn-images.mailchimp.com/embedcode/classic-10_7.css" rel="stylesheet" type="text/css">
						<style type="text/css">
							#mc_embed_signup{ background:#35d294; color:white; clear:left; font:14px Helvetica,Arial,sans-serif;padding:10px; }
							#mc_embed_signup h2 {
								font-size:16px;
								text-align: center;
								color:white;
							}
							#mc_embed_signup form {
								padding:0;
							}
							#mc_embed_signup .mc-field-group {
								width: 100%;
							}
							#mc-embedded-subscribe.button {
								background:#333;
								box-shadow: none;
								width: 100%;
								line-height: 40px;
								height:40px;
							}
							/* Add your own MailChimp form style overrides in your site stylesheet or in this style block.
							   We recommend moving this block and the preceding CSS link to the HEAD of your HTML file. */
						</style>
						<div id="mc_embed_signup">
						<form action="//lakotuts.us9.list-manage.com/subscribe/post?u=c2145daf9da8bf458a01a637e&amp;id=de0583d98c" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
							<div id="mc_embed_signup_scroll">
							<h2><?php esc_html_e( 'Get a 30% Discount on PRO', 'giveasap' ); ?></h2>
							<p><?php esc_html_e( 'You will subscribe to Simple Giveaways list and receive updates about this and others plugins which I have built', 'giveasap' ); ?></p>
						<div class="mc-field-group">
							<label for="mce-EMAIL"><?php esc_html_e( 'Email Address', 'giveasap' ); ?></label>
							<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL">
						</div>
							<div id="mce-responses" class="clear">
								<div class="response" id="mce-error-response" style="display:none"></div>
								<div class="response" id="mce-success-response" style="display:none"></div>
							</div>    <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
							<div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_c2145daf9da8bf458a01a637e_de0583d98c" tabindex="-1" value=""></div>
							<div class="clear"><input type="submit" value="<?php esc_html_e( 'Subscribe me to your Newsletter', 'giveasap' ); ?>" name="subscribe" id="mc-embedded-subscribe" class="button"></div>
							</div>
						</form>
						</div>
						<script type='text/javascript' src='//s3.amazonaws.com/downloads.mailchimp.com/js/mc-validate.js'></script><script type='text/javascript'>(function($) {window.fnames = new Array(); window.ftypes = new Array();fnames[0]='EMAIL';ftypes[0]='email';fnames[1]='FNAME';ftypes[1]='text';fnames[2]='LNAME';ftypes[2]='text';}(jQuery));var $mcj = jQuery.noConflict(true);</script>
						<!--End mc_embed_signup-->
						<?php } ?>
						<br/>
						<div class="postbox">
							<h2 class="hndle"><span><?php esc_html_e( 'About the Author', 'giveasap' ); ?></span></h2>
							<div class="inside"> 

								<img style="max-width: 100%;height:auto; display:block; margin:0 auto;border-radius:50%;"; width="100" style="display:block;margin:0 auto;" src="<?php echo esc_url_raw( $giveasap_documentation_images_url ); ?>author.png" />
								<strong>Igor Benić</strong>
								<p><?php esc_html_e( 'I am a Web developer who works mostly with WordPress. I am developing free & premium themes and plugins.', 'giveasap' ); ?></p>
								<p><?php printf( esc_html__( 'I also teach about WordPress and how to develop with it on my own websites: %s.', 'giveasap' ), '<a href="https://www.ibenic.com" target="_blank">ibenic.com</a>' ); ?></p>

							</div>
						</div>
					</div>
				</div>
			</div>

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

function giveasap_documentation_general() {
	$giveasap_documentation_url        = GASAP_URI . '/admin/documentation/';
	$giveasap_documentation_images_url = $giveasap_documentation_url . 'images/';
	?>
	<iframe style="margin: 0 auto; display:block;margin-bottom: 20px;" width="560" height="315" src="https://www.youtube.com/embed/videoseries?list=PLObNInvLiEdrIMA6y8ifG7a4ImG0kXjS6" frameborder="0" allowfullscreen></iframe>
	<div class="postbox">
		<h2 class="hndle"><span><?php esc_html_e( 'Giveaway Content', 'giveasap' ); ?></span></h2>
		<div class="inside">
			<strong><?php esc_html_e( 'Title & URL', 'giveasap' ); ?></strong><br/>
			<img style="max-width: 100%;height:auto"; width="600" src="<?php echo esc_url_raw( $giveasap_documentation_images_url ); ?>giveasap_title.png" />
			<ul>
				<li><strong><?php esc_html_e( 'Title', 'giveasap' ); ?></strong> - <?php esc_html_e( 'This will show on the front side as the main giveaway title', 'giveasap' ); ?></li>
				<li><strong><?php esc_html_e( 'URL', 'giveasap' ); ?></strong> - <?php esc_html_e( 'Regular WordPress permalink that will show the giveaway. Each giveaway will go under yoursite.com/giveaway', 'giveasap' ); ?></li>
			</ul>
		</div>

		<div class="inside">
			<strong><?php esc_html_e( 'Content', 'giveasap' ); ?></strong><br/>
			<img style="max-width: 100%;height:auto"; width="600" src="<?php echo esc_url_raw( $giveasap_documentation_images_url ); ?>giveasap_content.jpg" />
			<ul>
				<li><strong><?php esc_html_e( 'Content', 'giveasap' ); ?></strong> - <?php esc_html_e( 'Regular WordPress content as used in any post. This will be used for description of your giveaway. Be descriptive and show what your visitor will get if they win.', 'giveasap' ); ?></li>
			</ul>
		</div>

	</div>

	<div class="postbox">
		<h2 class="hndle"><span><?php esc_html_e( 'Giveaway Scheduling', 'giveasap' ); ?></span></h2>
		<div class="inside">
			<img style="max-width: 100%;height:auto"; width="600" src="<?php echo esc_url_raw( $giveasap_documentation_images_url ); ?>schedule.png" />
			<ul>
				<li><strong><?php esc_html_e( 'Start, End & Winner Date', 'giveasap' ); ?></strong> - <?php esc_html_e( 'Select a date with the datepicker when the giveaway starts, ends and when the winner is announced', 'giveasap' ); ?></li>
				<li><strong><?php esc_html_e( 'Start, End & Winner Time', 'giveasap' ); ?></strong> - <?php esc_html_e( 'Select the time for each of them also using the dropdown.', 'giveasap' ); ?></li>
			</ul>
		</div>

	</div>

	<div class="postbox">
		<h2 class="hndle"><span><?php esc_html_e( 'Prize', 'giveasap' ); ?></span></h2>
		<div class="inside">
			<img style="max-width: 100%;height:auto"; width="600" src="<?php echo esc_url_raw( $giveasap_documentation_images_url ); ?>prize.png" />
			<ul>
				<li><strong><?php esc_html_e( 'Number of winners', 'giveasap' ); ?></strong> - <?php esc_html_e( 'Insert a number to define how many winners will be selected.', 'giveasap' ); ?></li>
				<li><strong><?php esc_html_e( 'Prize', 'giveasap' ); ?></strong> - <?php esc_html_e( 'Insert the prize title that will be used in emails to your subscribers when they sign up or win.', 'giveasap' ); ?></li>
				<li><strong><?php esc_html_e( 'Value', 'giveasap' ); ?></strong> - <?php esc_html_e( 'Insert a value which will be shown on the page of this giveaway.', 'giveasap' ); ?></li>
			</ul>
		</div>

	</div>

	<div class="postbox">
		<h2 class="hndle"><span><?php esc_html_e( 'Text Settings', 'giveasap' ); ?></span></h2>
		<div class="inside">
			<strong><?php esc_html_e( 'Rules', 'giveasap' ); ?></strong><br/>
			<img style="max-width: 100%;height:auto"; width="600" src="<?php echo esc_url_raw( $giveasap_documentation_images_url ); ?>rules.png" />
			<p><?php esc_html_e( 'Write your own rules as you want. The more the better. You can hide most of the text by using the "more" tag to dislay a button which when clicked will show the other text.', 'giveasap' ); ?></p>
		</div>

		<div class="inside">
			<strong><?php esc_html_e( 'Winner Email', 'giveasap' ); ?></strong><br/>
			<img style="max-width: 100%;height:auto"; width="600" src="<?php echo esc_url_raw( $giveasap_documentation_images_url ); ?>winner.png" />
			<p><?php esc_html_e( 'This email will be sent to the winner or winners. You can write what ever you want here but be very descriptive and precise when it comes to send emails to winners. This is important for them to know how to get their prize.', 'giveasap' ); ?></p>
		</div>

	</div>

	<div class="postbox">
		<h2 class="hndle"><span><?php esc_html_e( 'Users', 'giveasap' ); ?></span></h2>
		<div class="inside">
			<strong><?php esc_html_e( 'Running Giveaway', 'giveasap' ); ?></strong><br/>
			<img style="max-width: 100%;height:auto"; width="250" src="<?php echo esc_url_raw( $giveasap_documentation_images_url ); ?>users.png" />
			<p><?php esc_html_e( 'While the giveaway is still running, you can only view which visitors subscribed and also export them into an CSV file.', 'giveasap' ); ?></p>
		</div>

		<div class="inside">
			<strong><?php esc_html_e( 'Ended Giveaway', 'giveasap' ); ?></strong><br/>
			<img style="max-width: 100%;height:auto"; width="250" src="<?php echo esc_url_raw( $giveasap_documentation_images_url ); ?>users-2.png" />
			<p><?php esc_html_e( 'When the giveaway has ended, you can click to select Winners alongside everything you could do before.', 'giveasap' ); ?></p>
		</div>

		<div class="inside">
			<strong><?php esc_html_e( 'Winners Selected', 'giveasap' ); ?></strong><br/>
			<img style="max-width: 100%;height:auto"; width="250" src="<?php echo esc_url_raw( $giveasap_documentation_images_url ); ?>users-3.png" />
			<p><?php esc_html_e( 'After you have selected the winners, you can also notify them. You can see the winners here and if they were notified already.', 'giveasap' ); ?></p>
		</div>

	</div>

	<div class="postbox">
		<h2 class="hndle"><span><?php esc_html_e( 'Display', 'giveasap' ); ?></span></h2>
		<div class="inside">
			<img style="max-width: 100%;height:auto;float:left;margin-right:10px;"; width="250" src="<?php echo esc_url_raw( $giveasap_documentation_images_url ); ?>display.jpg" />
			<ul>
				<li><strong><?php esc_html_e( 'Logo', 'giveasap' ); ?></strong> - <?php esc_html_e( 'Choose the logo image to show on the giveaway page. This can be a logo of the sponsor or even of your site.', 'giveasap' ); ?></li>
				<li><strong><?php esc_html_e( 'Images', 'giveasap' ); ?></strong> - <?php esc_html_e( 'Select as many images as you want. You may even order them how you want them to appear.', 'giveasap' ); ?></li>
				<li><strong><?php esc_html_e( 'Background Color', 'giveasap' ); ?></strong> - <?php esc_html_e( 'Choose a simple color for the background. If there is no background image, this color will be diplayed. So choose a color that will be gentle to the eyes of your visitors.', 'giveasap' ); ?></li>
			</ul>
		</div>
		<br style="clear:both;"/>
		<div class="inside">
			<img style="max-width: 100%;height:auto;float:left;margin-right:10px;"; width="250" src="<?php echo esc_url_raw( $giveasap_documentation_images_url ); ?>display-2.jpg" />
			<p><?php esc_html_e( 'All this images are used for social networks when your subscribers share them on their profiles. Create different and funny images so that people will click them. Be aware for the colors to stand out and that are different than the colors of the social network.', 'giveasap' ); ?></p>
		</div>
		<br style="clear:both;"/>
		<div class="inside">
			<img style="max-width: 100%;height:auto;float:left;margin-right:10px;"; width="250" src="<?php echo esc_url_raw( $giveasap_documentation_images_url ); ?>display-3.jpg" />
			<p><?php esc_html_e( 'You can choose a nice image to show as the background image.', 'giveasap' ); ?></p>
		</div>
		<br style="clear:both;"/>
		<br style="clear:both;"/>
	</div>
	<?php

}

function giveasap_documentation_settings() {
	$giveasap_documentation_url        = GASAP_URI . '/admin/documentation/';
	$giveasap_documentation_images_url = $giveasap_documentation_url . 'images/';
	?>
	<div class="postbox">
		<h2 class="hndle"><span><?php esc_html_e( 'General', 'giveasap' ); ?></span></h2>
		<div class="inside">
			<img style="max-width: 100%;height:auto"; width="600" src="<?php echo esc_url_raw( $giveasap_documentation_images_url ); ?>settings-email.jpg" />
			<p><?php esc_html_e( 'You can use the default text for the email that will welcome your new subscribers and give them both the link to view their entries and also the sharing link. Be sure to use those placeholders if you are writing your own welcome email.', 'giveasap' ); ?></p>
		</div>
		<h2 class="hndle"><span><?php esc_html_e( 'Include Name', 'giveasap' ); ?></span></h2>
		<div class="inside">
			 <p><?php esc_html_e( 'You can also require the name to be inserted when subscribing to a giveaway.', 'giveasap' ); ?></p>
		</div>
	</div>

	<div class="postbox">
		<h2 class="hndle"><span><?php esc_html_e( 'Google Captcha', 'giveasap' ); ?></span></h2>
		<div class="inside">
			<img style="max-width: 100%;height:auto"; width="600" src="<?php echo esc_url_raw( $giveasap_documentation_images_url ); ?>google.jpg" />
			<p><?php echo sprintf( esc_html__( 'If you want to prevent spammers from subscribing, you can easily set a google captcha by providing your own google catpcha public and secret key. Click here to get it: %s', 'giveasap' ), '<a href="https://www.google.com/recaptcha/intro/index.html" target="_blank">Google Captcha</a>' ); ?></p>
		</div>
	</div>
	<?php
}

function giveasap_documentation_pro() {
	$giveasap_documentation_url        = GASAP_URI . '/admin/documentation/';
	$giveasap_documentation_images_url = $giveasap_documentation_url . 'images/';
	?>
	<div class="postbox">
		<h2 class="hndle"><span><?php esc_html_e( 'Automate', 'giveasap' ); ?></span></h2>
		<div class="inside">
			<img style="max-width: 100%;height:auto"; width="600" src="<?php echo esc_url_raw( $giveasap_documentation_images_url ); ?>automate.png" />
			<p><?php esc_html_e( 'Automate everything. Traveling, spending time with your family or something else? You can let WordPress select the Winners and notify them while you are away. Don\'t let your subscribers wait.', 'giveasap' ); ?></p>
		</div>
	</div>

	<div class="postbox">
		<h2 class="hndle"><span><?php esc_html_e( 'Entries', 'giveasap' ); ?></span></h2>
		<div class="inside">
			<img style="max-width: 100%;height:auto"; width="600" src="<?php echo esc_url_raw( $giveasap_documentation_images_url ); ?>entries.png" />
			<p><?php esc_html_e( 'Reward your subscribers who share your giveaways with extra entries.', 'giveasap' ); ?></p>
		</div>
	</div>

	<div class="postbox">
		<h2 class="hndle"><span><?php esc_html_e( 'Templates', 'giveasap' ); ?></span></h2>
		<div class="inside">
			<img style="max-width: 100%;height:auto"; width="250" src="<?php echo esc_url_raw( $giveasap_documentation_images_url ); ?>template.png" />
			<p><?php esc_html_e( 'Choose different templates and host different giveaways.', 'giveasap' ); ?></p>
		</div>
	</div>
	<?php
}

function giveasap_documentation_shortcodes() {
	?>
	<div class="postbox">
		<h2 class="hndle"><span>[giveaway]</span></h2>
		<div class="inside">
			<p><strong><?php esc_html_e( 'Attributes:', 'giveasap' ); ?></strong></p>
			<table class="wp-list-table widefat striped">
				<tr>
					<td valign="top"><code>id</code></td>
					<td valign="top">
						<?php esc_html_e( 'Giveaway ID', 'giveasap' ); ?>
					</td>
				</tr>
				<tr>
					<td valign="top"><code>description</code></td>
					<td valign="top">
						<?php esc_html_e( 'Add a description to display on the giveaway box.', 'giveasap' ); ?>
					</td>
				</tr>
				<tr>
					<td valign="top"><code>title</code></td>
					<td valign="top">
						<?php esc_html_e( 'Show the Giveaway Title. Default is 1. If 0, it will hide it.', 'giveasap' ); ?>
					</td>
				</tr>
				<tr>
					<td valign="top"><code>redirect</code></td>
					<td valign="top">
						<?php esc_html_e( 'Values:', 'giveasap' ); ?>
						<ul>
							<li><code>self</code> - <?php esc_html_e( 'It will redirect the user back to the same page.', 'giveasap' ); ?></li>
							<li><code>giveaway</code> - <?php esc_html_e( 'It will redirect the user to the main giveaway page.', 'giveasap' ); ?></li>
							<li>URL -  <?php esc_html_e( 'It will redirect the user to the provided URL.', 'giveasap' ); ?></li>
						</ul>
					</td>
				</tr>
				<tr>
					<td valign="top"><code>images</code></td>
					<td valign="top">
						<?php esc_html_e( 'Values:', 'giveasap' ); ?>
						<ul>
							<li><code>1</code> - <?php esc_html_e( 'Show the images.', 'giveasap' ); ?></li>
							<li><code>0</code> - <?php esc_html_e( 'Hide the images. Default.', 'giveasap' ); ?></li>
						</ul>
					</td>
				</tr>
				<tr>
					<td valign="top"><code>use_link</code></td>
					<td valign="top">
						<?php esc_html_e( 'Values:', 'giveasap' ); ?>
						<ul>
							<li><code>1</code> - <?php esc_html_e( 'Link the title to the main giveaway page. Default.', 'giveasap' ); ?></li>
							<li><code>0</code> - <?php esc_html_e( 'Do not link the title.', 'giveasap' ); ?></li>
						</ul>
					</td>
				</tr>
			</table>
		</div>
	</div>

	<div class="postbox">
		<h2 class="hndle"><span>[giveaway_winners]</span></h2>
		<div class="inside">
			<p><strong><?php esc_html_e( 'Attributes:', 'giveasap' ); ?></strong></p>
			<table class="wp-list-table widefat striped">
				<tr>
					<td valign="top"><code>id</code></td>
					<td valign="top">
						<?php esc_html_e( 'Giveaway ID', 'giveasap' ); ?>
					</td>
				</tr>
			</table>
		</div>
	</div>

	<div class="postbox">
		<h2 class="hndle"><span>[giveaway_leaderboard]</span></h2>
		<div class="inside">
			<p><strong><?php esc_html_e( 'Attributes:', 'giveasap' ); ?></strong></p>
			<table class="wp-list-table widefat striped">
				<tr>
					<td valign="top"><code>id</code></td>
					<td valign="top">
						<?php esc_html_e( 'Giveaway ID', 'giveasap' ); ?>
					</td>
				</tr>
				<tr>
					<td valign="top"><code>limit</code></td>
					<td valign="top">
						<?php esc_html_e( 'Number of subscribers to show. Default is 10.', 'giveasap' ); ?>
					</td>
				</tr>
				<tr>
					<td valign="top"><code>order</code></td>
					<td valign="top">
						<?php esc_html_e( 'Values:', 'giveasap' ); ?>
						<ul>
							<li><code>ASC</code> - <?php esc_html_e( '1,2,3....', 'giveasap' ); ?></li>
							<li><code>DESC</code> - <?php esc_html_e( '3,2,1... Default.', 'giveasap' ); ?></li>
						</ul>
					</td>
				</tr>
				<tr>
					<td valign="top"><code>orderby</code></td>
					<td valign="top">
						<?php esc_html_e( 'Order by the column of the table. Available: id, post_id, email, entries, status, date. Default is entries.', 'giveasap' ); ?>
					</td>
				</tr>
				<tr>
					<td valign="top"><code>columns</code></td>
					<td valign="top">
						<p><?php esc_html_e( 'Define which columns are going to be shown. This can also use meta fields such as form field values.', 'giveasap' ); ?></p>
						<p><?php esc_html_e( 'Default is: entries,email.', 'giveasap' ); ?></p>
						<p><?php esc_html_e( 'For example, if you have a form field with key last_name, you would use last_name in columns.', 'giveasap' ); ?></p>
					</td>
				</tr>
				<tr>
					<td valign="top"><code>headers</code></td>
					<td valign="top">
						<p><?php esc_html_e( 'Define how the columns are going to be named. This follows the columns order.', 'giveasap' ); ?></p>
						<p><?php esc_html_e( 'Default is: Entries,Email.', 'giveasap' ); ?></p>
					</td>
				</tr>
			</table>
		</div>
	</div>
	<?php
}
