<?php
if ( ! defined( 'ABSPATH' ) ) exit; 
  
function rep_tools() { 
global $wpdb, $post, $opt_themes, $wp_query; 
?>  

<div class="appview-tools">
	<?php if(get_post_meta( get_the_ID(), 'wp_GP_ID', true )){ ?>
	<a class="btn btn-fill" href="<?php the_permalink(); ?>#download-now"><span class="btn-cont"><?php _e($opt_themes['sp_text_1j'], TEXT_DOMAIN); ?></span></a>
	<?php } ?>
	<div class="av-tool-list">
	
	<div class="av-tool dropdown sharefunc">
	<button type="button" id="share-btn" class="dropdown-btn" data-share-title="<?php the_title(); ?>" data-share-text="Look what I found!"><i class="im im-share"></i><span class="av-tool-cont"><?php _e($opt_themes['o_text_4a'], TEXT_DOMAIN); ?></span></button>
	<div class="dropdown-box" style="display: none;">
	<div class="share-list">
	<a class="share-btn share-tg" href="https://t.me/share/url?url=<?php the_permalink(); ?>&amp;text=<?php the_title(); ?>" target="_blank" rel="noopener nofollow" title="Share in Telegram"><i class="im im-share-tg"></i></a>
	<a class="share-btn share-wa" href="https://api.whatsapp.com/send?text=<?php the_title(); ?> <?php the_permalink(); ?>" target="_blank" rel="noopener nofollow" title="Share in WhatsApp"><i class="im im-share-wa"></i></a>
	<a class="share-btn share-vk" href="https://vk.com/share.php?url=<?php the_permalink(); ?>&amp;title=<?php the_title(); ?>" target="_blank" rel="noopener nofollow" title="Share in VK"><i class="im im-share-vk"></i></a>
	<a class="share-btn share-fb" href="https://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>" target="_blank" rel="noopener nofollow" title="Share in Facebook"><i class="im im-share-fb"></i></a>
	</div>
	</div>
	</div>	 
	
	<?php 
	if ( is_user_logged_in() ) { if( class_exists('Favorites')) { 
	echo '<div class="av-tool"><i class="im im-staroutline"></i>'.do_shortcode("[favorite_button]").'</div>'; 
	} } else { ?>		
	<div class="av-tool hlogin dialog-btn">	
	<a><i class="im im-staroutline"></i>
	<span class="av-tool-cont"><?php _e($opt_themes['sp_text_1la'], TEXT_DOMAIN); ?></span>
	</a>
	</div>	
	<?php } ?>
	
	</div>
	
</div>
<?php
}

function rep_form() { 
global $wpdb, $post, $opt_themes, $wp_query; 
?>  

<?php if ($_SERVER["REQUEST_METHOD"] == "POST") { 
    $post_name 		= $_POST['post_name'];
    $post_link	 	= $_POST['post_link'];
    $post_reason 	= $_POST['report_option'];
    $post_user	 	= $_POST['email_user'];
	
	$report_post_args = array(
		'post_title'    => 'Report on item " '.$post_name.' "',
		'post_content'  => 'Title : '.$post_name.PHP_EOL.'Permalink : '.$post_link.PHP_EOL.'Reason : '.$post_reason.PHP_EOL.'Email user Reported : '.$post_user,
		'post_status'   => 'draft',
		'post_type'     => 'report', // 'post' or 'page', or a custom post type
	);

	$post_id = wp_insert_post( $report_post_args );
} 
 
?>


<section class="sys-page-sect" >
		<div class="wrp" style="max-width: unset;"> 
		
		<div class="alert <?php if (!isset($_POST['email_user'])) { ?> sr-only<?php } ?>">
			<div class="desc">
				<?php _e($opt_themes['rep_text_4'], TEXT_DOMAIN); ?>
			</div>
		</div>

		<form method="post" action class="<?php if (isset($_POST['email_user']) && !is_wp_error($_POST['email_user'])) { ?> sr-only<?php } ?>">
			
		<div class="userpage-form form-list sect">
		<h2 class="title"><?php _e($opt_themes['rep_text_1'], TEXT_DOMAIN); ?> "<?php the_title(); ?>"</h2>
		 
		<div class="form-group" style="display:none" >
		<div class="form-group-label">
		<label for="post_name"><?php _e($opt_themes['rep_text_2'], TEXT_DOMAIN); ?> </label>	
		</div>		
		<input class="form-control" readonly type="text" name="post_name" id="post_name" maxlength="100" value="<?php the_title(); ?>" style="width: 100%;">		
		<input style="display:none" readonly type="text" name="post_link" id="post_link" maxlength="100" value="<?php the_permalink(); ?>" style="width: 100%;">
		</div>		
	
		<div class="form-group">
		<div class="form-group-label">
		<label for="email_user"><?php _e($opt_themes['rep_text_2a'], TEXT_DOMAIN); ?> </label>	
		</div>			
		<input class="form-control" required type="email" name="email_user" id="email_user" maxlength="100" placeholder="Your Emails">		
		</div> 	
	
		<div class="form-group">
		<div class="form-group-label">
		<label for="report_option"><?php _e($opt_themes['rep_text_3'], TEXT_DOMAIN); ?></label></label>	
		</div> 
		<select class="form-control" name="report_option" id="report_option" style="width: 100%;"> 
		<?php
		foreach ( (array) $opt_themes['reasons'] as $key => $val ) { 
		?>
		<option value="<?php echo $val; ?>"><?php echo $val; ?></option>
		<?php } ?>
		</select>
		</div> 	
		
		<div class="form-group btn-group form-submit">
		<button class="btn btn-fill btn-block" type="submit" name="submit" id="report_button" ><?php _e($opt_themes['rep_text_6'], TEXT_DOMAIN); ?></button>
		</div>
	
		
		</div>
 
		</form>
		</div>
</section>

<?php
}

function rep_() { 
global $wpdb, $post, $opt_themes, $wp_query; 
?>  

<?php
}
