<?php 
	$payperpostarray = Dap_PayPerPost::load();
	$page_ids = get_all_page_ids();
?>
				<div class="live-links-outer pp-post-inner">
					<h3 class="pp--post-title"><i class="fa fa-files-o" aria-hidden="true"></i> Copy Pay-Per-Post Settings</h3>
					<div class="pp-bulk-card  align-items-start">
						<label for="" class="metabox_label">Select Main Post</label>
						<div class="pp-bulk-right-content">
							<select class="form-control source_post_id" style="margin-bottom: 20px;">
								<option value="0">Select URL</option>
								<?php
								$page_ids_ppp = array();
								foreach ($payperpostarray as $page) {
									if(get_post_status($page->getPostId()) === 'publish'){
									$postObj[$page->getPostId()]['post_id'] = $page->getPostId();
									$postObj[$page->getPostId()]['post_image'] = $page->getPostImage();
									$postObj[$page->getPostId()]['post_name'] = $page->getPostTitle();
									//$postObj[$page->getPostId()]['post_desc'] = $page->getTeaserContent();
									$postObj[$page->getPostId()]['permalink'] = get_permalink($page->getPostId());
									$page_ids_ppp[] = $page->getPostId();
									?>
									<option value="<?php echo $page->getPostId(); ?>"><?php echo get_permalink($page->getPostId()); ?></option>
									
									<?php
								} }?>
							</select>
							<div class="pp-or"><span>OR</span></div>
							<input type="text" class="form-control source_page_enter_url" placeholder="Enter URL Here">
						</div>
					</div>

					<div class="pp-bulk-card align-items-start">
						<label for="" class="metabox_label"> Select posts to which you want to copy </label>
						<div class="pp-bulk-right-content">
							<div class="row">
								<div class="col-sm-6">
									<a class="form-control"><span class="hida">Select Posts</span></a>
									<div class="mutliSelect">
										<ul class="form-control dapwp_selected_post_list">
											 <?php
											foreach ($page_ids as $page) {
												
												if(in_array($page,$page_ids_ppp)){
													continue;
												}
												
											  $page_name = get_page($page);
											  if ($page_name->post_status == 'publish') {
												$page_permalink = get_permalink($page);
												$find = array('http://', 'https://');
												$replace = 'https://';
												$pagelink = str_replace($find, $replace, $page_permalink);
												?>
												
												<li><input type="checkbox" data-post-id="<?= $page; ?>" class="mutliSelect all_productslist" name="all_products" value="<?php echo $pagelink; ?></li>">
													<?php echo $pagelink; ?></li>
												
												 <option value='<?php echo $pagelink; ?>' title="<?php echo get_the_title($page); ?>">
												
												 </option>
											  <?php }
											} ?>
											
											
										</ul>
									</div>
								</div>
								<div class="col-sm-6 selected_product_outer">
									<div class="selected_product_list">
										<h5>Selected Post(s)</h5>
										<ul class="allSelectedProductsPreview spc_checkout_template_drag_drop_parent">
											<li class="spc_checkout_template_drag_drop_item selectedProduct<?= $id; ?>" data-id="<?= $id ?>"><span class="mr-1"><?= $postObj[$id]['permalink']; ?></span></li>
										</ul>
									</div>
								</div>
							</div>
						</div>
					</div>

					<div class="pp-bulk-actions">
						<button type="button" class="pp-bulk-btn" onclick="dapwp_copy_post()">Copy</button>
					</div>
					<div class="pp-post-loader" style="display: none;">Please wait.. Copy in progress..</div>
				</div>
			
