<?php
require_once plugin_dir_path( __FILE__ ) .'header/header-main.php';

global $wpdb;

$result_spinrewriter_email = get_option( 'wpch_spinrewriter_email' );
$result_spinrewriter_api = get_option( 'wpch_spinrewriter_api' );
$result_perfectapi_key = get_option('wpch_perfect_api_key');
$result_perfectapp_key = get_option('wpch_perfect_app_key');
$result_article_ezine_enable = get_option('wpch_articleezine_enable');
$result_ezine_article_key = get_option('wpch_ezinearticle_app_key');
$result_ezine_article_limit = get_option('wpch_articleezine_limit');
$result_ezine_article_categ_setting = get_option('wpch_articleezine_category_setting');
$result_article_forge_enable = get_option('wpch_articleforge_enable');
$result_article_forge_key = get_option('wpch_articleforge_app_key');
$result_article_forge_title = get_option('wpch_articleforge_title');
$result_article_forge_image = get_option('wpch_articleforge_image');
$result_article_forge_content_length = get_option('wpch_articleforge_length');
$result_article_forge_setting_keyword = get_option('wpch_articleforge_setting_keyword');
$result_article_forge_setting_sub_key = get_option('wpch_articleforge_setting_sub_key');
$result_ytube_key = get_option('wpch_ytube_api_key');
$result_ytube_enable = get_option('wpch_ytube_enable');
$result_article_builder_enable = get_option('wpch_articlebuilder_enable');
$result_articlebuilder_username = get_option('wpch_articlebuilder_username');
$result_articlebuilder_password = get_option('wpch_articlebuilder_passowrd');
$result_articlebuilder_limit = get_option('wpch_articlebuilder_limit');
$result_ab_cat = get_option('wpch_articlebuilder_category');


function ab_setting_curl_post($url, $data, &$info){

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, ab_setting_curl_postData($data));
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_REFERER, $url);
  $html = trim(curl_exec($ch));
  curl_close($ch);

  return $html;
}

function ab_setting_curl_postData($data){

  $fdata = "";
  foreach($data as $key => $val){
    $fdata .= "$key=" . urlencode($val) . "&";
  }

  return $fdata;

}
?>
<div>
<div class="container">
    <div class="row">
        <div class="col-md-12">				
			<div class="content-hero-header" style="display:flow-root;margin: 20px 0 20px;">
				<h1 style="float: left;margin-top:0px;">Settings</h1>
			</div>

			<div class="content_hero_tab">
				<div class="tab_container">

					
										
					<input id="tab5" type="radio" name="tabs" checked>
					<label for="tab5"><i class="fa fa-pencil-square-o"></i><span>YouTube API</span></label>
					
					
					<section id="content1" class="tab-content">
						<div id="spin_setting_div"></div>
						<div class="box-body">
							<div class="setting-form">					
							<h4>Note:- Try Spin Rewriter for free click here:  <a href="https://www.spinrewriter.com/?ref=2cb7d" style="text-decoration:underline;color:#000;" target="_blank">https://www.spinrewriter.com/?ref=2cb7d</a></h4>
							<table class="form-table">
							  <tbody>
								<form id="setting_form" action="#" method="post" onSubmit="return false;">
								<tr valign="top">
								<th scope="row" style="padding-top:25px;">Email</th>
								<td>
									<div id="wpblm2-posts-sel">
										<div class="wpbml2_url_sel">
											<input type="email" class="regular-text" name="post_spin_email"  id="post_spin_email_id" placeholder="enter your email address" value="<?php if(!empty($result_spinrewriter_email)) { echo $result_spinrewriter_email; } else { echo ""; } ?>" style="padding:6px;width:60%;border-radius:5px;display: block;" required><br>
										</div>
									</div>
								</td>
								<tr valign="top">
								<th scope="row" style="padding-top:25px;">Api</th>
								<td>
									<div id="wpblm2-posts-sel">
										<div class="wpbml2_url_sel">
											<input type="text" class="regular-text" name="post_spin_api_key"  id="post_spin_api_key_id" placeholder="enter your api_key" value="<?php if(!empty($result_spinrewriter_api)) { echo $result_spinrewriter_api; } else { echo ""; } ?>" style="padding:6px;width:60%;border-radius:5px;display: block;" required><br>
										</div>
									</div>
								</td>
								</tr>
								<tr valign="top">
								<td style="padding: 7px;width: 13%;">
									<input type="submit" class="btn btn-primary btn_spinrewriter_setting" value="Save" style="margin-top:15px;padding:5px 10px 5px 10px;"/>
								</td>
								</form>
								</tr>
								</tbody>   
							</table>    							
							</div>
						</div>
					</section>

					<section id="content2" class="tab-content">
						<div id="perfect_tense_setting_div"></div>
						<div class="box-body">
							<div class="setting-form">					
								<h4>Note:- Try Perfect Tense for free click here: &nbsp;&nbsp; <a href="https://www.perfecttense.com/?ref=d222b1" style="text-decoration:underline;color:#000;" target="_blank">https://www.perfecttense.com/?ref=d222b1</a></h4>
								<table class="form-table">
								  <tbody>
									<form id="setting_form" action="#" method="post" onSubmit="return false;">
									<tr valign="top">
									<th scope="row" style="padding-top:25px;">Api Key</th>
									<td>
										<div id="wpblm2-posts-sel">
											<div class="wpbml2_url_sel">
												<input type="text" class="regular-text post_perfect_api_key_cls" name="post_perfect_api_key"  id="post_perfect_api_key_id" placeholder="enter your api_key" value="<?php if(!empty($result_perfectapi_key)) { echo $result_perfectapi_key; } else { echo ""; } ?>" style="padding:6px;width:60%;border-radius:5px;display: block;" required><br>
											</div>
										</div>
									</td>
									</tr>
									<tr valign="top">
									<th scope="row" style="padding-top:25px;">App Key</th>
									<td>
										<div id="wpblm2-posts-sel">
											<div class="wpbml2_url_sel">
												<input type="text" class="regular-text post_perfect_app_key_cls" name="post_perfect_app_key"  id="post_perfect_app_key_id" placeholder="enter your app_key" value="<?php if(!empty($result_perfectapp_key)) { echo $result_perfectapp_key; } else { echo ""; } ?>" style="padding:6px;width:60%;border-radius:5px;display: block;" required><br>
											</div>
										</div>
									</td>
									</tr>
									<tr valign="top">
									<td style="padding: 7px;width: 13%;">
										<input type="submit" class="btn btn-primary btn_perfect_tense_setting" value="Save" style="margin-top:15px;padding:5px 10px 5px 10px;"/>
									</td>
									</form>
								  </tbody>   
								</table>    							
							</div>
						</div>
					</section>					
					
					<section id="content3" class="tab-content" style="display:none;">
						<div id="ezine_articles_setting_div"></div>
						<div class="box-body">
							<div class="setting-form">					
								<h4>Note:- Don't have a Ezine articles account? Click here to sign up :  <a href="https://api.ezinearticles.com/?get_api_key" target="_blank" style="text-decoration:underline;color:#000;">https://api.ezinearticles.com/?get_api_key</a></h4>
								<?php if(!empty($result_ezine_article_key)) { 								
								$category='';
								if(!empty($result_ezine_article_key)){
									$url='http://api.ezinearticles.com/api.php?search=categories&category=&response_format=json&key='.$result_ezine_article_key;            
									$ch = curl_init($url);
									curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
									curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
									curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
									curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
									$data = curl_exec($ch);
									curl_close($ch);
									$categories1 = json_decode($data);
									if(!empty($categories1->categories))
									{		
										$category = $categories1->categories;
									}
								}
								
								if(empty($category))
								{ ?>
								<div class="wrap" id="key_error_message_ezinearticle">
									<div class="error"><p>Key is not valid . Please check .</p></div>
								</div>	
								<?php }
								} 
								?>
								<form id="setting_form" action="#" method="post" onSubmit="return false;">
								<table class="form-table">
								  <tbody>
									<tr valign="top">
									<th scope="row" style="padding-top:25px;">Enable Ezine article</th>
									<td>
										<div id="wpblm2-posts-sel">
											<div class="wpbml2_url_sel">
												<input type="checkbox" class="article_ezine_enable_cls" name="article_ezine_enable"  id="article_ezine_enable_id" style="margin-top:13px;display: block;" <?php if(!empty($result_article_ezine_enable) && $result_article_ezine_enable == 'on') { echo "checked"; } ?>><br>
											</div>
										</div>
									</td>
									</tr>
									<tr valign="top">
									<th scope="row" style="padding-top:25px;">Api Key</th>
									<td>
										<div id="wpblm2-posts-sel">
											<div class="wpbml2_url_sel">
												<input type="text" class="regular-text ezine_articles_api_key_cls" name="ezine_articles_api_key"  id="ezine_articles_api_key_id" placeholder="enter your api_key" value="<?php if(!empty($result_ezine_article_key)) { echo $result_ezine_article_key; } else { echo ""; } ?>" style="padding:6px;width:60%;border-radius:5px;display: block;" required><br>
											</div>
										</div>
									</td>
									</tr>
									<?php 	
									$api_key = get_option('wpch_ezinearticle_app_key');
									$result_ezine_category_id_setting = get_option('wpch_articleezine_category_setting');
									$wpch_ezine_subcategory_id_setting = get_option('wpch_articleezine_subcategory_setting');
	
									$category='';

									if(!empty($api_key)){
										$url='http://api.ezinearticles.com/api.php?search=categories&category=&response_format=json&key='.$api_key;            
										$ch = curl_init($url);
										curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
										curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
										curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
										curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
										$data = curl_exec($ch);
										curl_close($ch);
										$categories1 = json_decode($data);
										if(!empty($categories1->categories))
										{		
											$channel_ezine_category = $categories1->categories;
										}
									}
									if(!empty($channel_ezine_category))
									{
									?>						
										<tr valign="top">
										<th scope="row" style="padding-top:25px;">Select Category</th>
										<td>
											<div id="wpblm2-posts-sel">
												<div class="wpbml2_url_sel">
													<select id="select_ezine_category_id_setting" name="select_ezine_category_name_setting">								
													  <option value="">Select Option</option>
													  <?php
														foreach($channel_ezine_category as $channel_ezine_category1)
														{
														?>															
														<option value="<?php echo str_replace(" ", "-", $channel_ezine_category1->category->name); ?>" <?php if(!empty($result_ezine_article_categ_setting) && $result_ezine_article_categ_setting == str_replace(" ", "-", $channel_ezine_category1->category->name)) { echo "selected"; } ?>><?php echo $channel_ezine_category1->category->name; ?></option>	
														<?php
														}		
													  ?>
													</select>
													<div id="afe_subcat_loader" style="display: flex;justify-content: center;"><img src="<?php echo plugins_url('MyContentCreatorPro-Free/includes/assets/images/loader_afe.gif'); ?>" id="afe_loader_categ_id" style="display:none;"> </div>
												</div>
											</div>
										</td>
										</tr>
										<tr valign="top" id="subcat_tr_updated">
										<th scope="row" style="padding-top:25px;">Sub Category</th>
										<td>
											<div id="wpblm2-posts-sel">
												<div class="wpbml2_url_sel">
												<?php
													if(!empty($api_key)){
														$url = 'https://api.ezinearticles.com/api.php?search=categories&response_format=json&key='.$api_key.'&category='.$result_ezine_category_id_setting;
														$ch = curl_init($url);
														curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
														curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
														curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
														curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
														$data = curl_exec($ch);
														curl_close($ch);
														$sub_category=json_decode($data);		
													}

													$subcateg = $sub_category->categories[0]->category->subcategory;
													if(!empty($subcateg)) {
													?>
													<select id="select_ezine_subcategory_id_settings" name="select_ezine_subcategory_name_settings">								
													  <?php
														foreach($subcateg as $subcateg1)
														{
														?>															
														<option value="<?php echo str_replace(" ", "-", $subcateg1); ?>" <?php if(!empty($wpch_ezine_subcategory_id_setting) && $wpch_ezine_subcategory_id_setting == str_replace(" ", "-", $subcateg1)) { echo "selected"; } ?> ><?php echo $subcateg1; ?></option>	
														<?php
														}		
													  ?>
													</select>
													<?php
													}
												?>
												</div>
											</div>
										</td>
										</tr>
										<tr valign="top" id="subcat_tr" style="display:none;">
										<th scope="row" style="padding-top:25px;">Sub Category</th>
										<td>
											<div id="wpblm2-posts-sel">
												<div class="wpbml2_url_sel">
													<div id="mych_subcat_result"></div>
												</div>
											</div>
										</td>
										</tr>
									<?php 
									} 
									?>
									<tr valign="top">
									<th scope="row" style="padding-top:25px;">EzineArticles Limit</th>
									<td>
										<div id="wpblm2-posts-sel">
											<div class="wpbml2_url_sel">
												<select class="ezine_article_limit_cls" id="ezine_article_limit_id" name="ezine_article_limit">
												  <option value="1" <?php if(!empty($result_ezine_article_limit) && $result_ezine_article_limit == '1') { echo "selected"; } ?>>1</option>
												  <option value="2" <?php if(!empty($result_ezine_article_limit) && $result_ezine_article_limit == '2') { echo "selected"; } ?>>2</option>
												  <option value="3" <?php if(!empty($result_ezine_article_limit) && $result_ezine_article_limit == '3') { echo "selected"; } ?>>3</option>
												  <option value="4" <?php if(!empty($result_ezine_article_limit) && $result_ezine_article_limit == '4') { echo "selected"; } ?>>4</option>
												  <option value="5" <?php if(!empty($result_ezine_article_limit) && $result_ezine_article_limit == '5') { echo "selected"; } ?>>5</option>
												  <option value="6" <?php if(!empty($result_ezine_article_limit) && $result_ezine_article_limit == '6') { echo "selected"; } ?>>6</option>
												  <option value="7" <?php if(!empty($result_ezine_article_limit) && $result_ezine_article_limit == '7') { echo "selected"; } ?>>7</option>
												  <option value="8" <?php if(!empty($result_ezine_article_limit) && $result_ezine_article_limit == '8') { echo "selected"; } ?>>8</option>
												  <option value="9" <?php if(!empty($result_ezine_article_limit) && $result_ezine_article_limit == '9') { echo "selected"; } ?>>9</option>
												  <option value="10" <?php if(!empty($result_ezine_article_limit) && $result_ezine_article_limit == '10') { echo "selected"; } ?>>10</option>
												  <option value="11" <?php if(!empty($result_ezine_article_limit) && $result_ezine_article_limit == '11') { echo "selected"; } ?>>11</option>
												  <option value="12" <?php if(!empty($result_ezine_article_limit) && $result_ezine_article_limit == '12') { echo "selected"; } ?>>12</option>
												  <option value="13" <?php if(!empty($result_ezine_article_limit) && $result_ezine_article_limit == '13') { echo "selected"; } ?>>13</option>
												  <option value="14" <?php if(!empty($result_ezine_article_limit) && $result_ezine_article_limit == '14') { echo "selected"; } ?>>14</option>
												  <option value="15" <?php if(!empty($result_ezine_article_limit) && $result_ezine_article_limit == '15') { echo "selected"; } ?>>15</option>
												</select>
											</div>
										</div>
									</td>
									</tr>
									<tr valign="top">
									<td style="padding: 7px;width: 13%;">
										<div class="form-group row content_hero_tab" style="display:flex;">
											<input type="submit" class="btn btn-primary btn_ezine_articles_setting" value="Save" style="margin-top:15px;padding:5px 10px 5px 10px;"/>
											<div id="afe_img_subcat_loader" style="display: flex;justify-content: center;">
												<img src="<?php echo plugins_url('MyContentCreatorPro-Free/includes/assets/images/loader_afe.gif'); ?>" id="loaders_ezine_setting" style="display:none;width:50px;height:50px;padding: 15px 10px 1px 5px;"> 
											</div>											
										</div>
									</td>
								  </tbody>   
								</table>    							
								</form>
								<div class="wrap"><div class="alert-warning" id="warning-message-ezine" style="background:#ffba006b;display:none;"><p style="padding:5px 10px;color:#000;">Note :- Please wait it will take around 1 minutes to save. </p></div></div>
							</div>
						</div>
					</section>										
					
					<section id="content4" class="tab-content">
						<div id="article_forge_setting_div"></div>
						<div class="box-body">
							<div class="setting-form">					
								<h4>Note:- Try Article Forge for free click here:&nbsp;&nbsp;  <a href="https://www.articleforge.com/?ref=f7b651" style="text-decoration:underline;color:#000;" target="_blank">https://www.articleforge.com/?ref=f7b651</a></h4>
								<div><span style="color:red;">Note:- Article Forge Posts Can Take 6 To 10 Minutes To Post Or Longer</span></div>
								<table class="form-table">
								  <tbody>
									<form id="setting_form" action="#" method="post" onSubmit="return false;">
									<tr valign="top">
									<th scope="row" style="padding-top:25px;">Enable Articleforge</th>
									<td>
										<div id="wpblm2-posts-sel">
											<div class="wpbml2_url_sel">
												<input type="checkbox" class="article_forge_enable_cls" name="article_forge_enable"  id="article_forge_enable_id" placeholder="enter your api_key" style="margin-top:13px;display: block;" <?php if(!empty($result_article_forge_enable) && $result_article_forge_enable == 'on') { echo "checked"; } ?>><br>
											</div>
										</div>
									</td>
									</tr>
									<tr valign="top">
									<th scope="row" style="padding-top:25px;">Keyword:</th>
									<td>
										<div id="wpblm2-posts-sel">
											<div class="wpbml2_url_sel">
												<input type="text" id="article_forge_setting_keyword_id" placeholder="Enter your keyword" value="<?php if(!empty($result_article_forge_setting_keyword)) { echo $result_article_forge_setting_keyword; } ?>" style="padding:6px;width:60%;border-radius:5px;display: block;" required/>
												<span style="font-size:12px;"><b>Note:-</b> keyword should not contain URLs, commas, parentheses, brackets, or too many single characters.</span>
											</div>
										</div>
									</td>
									</tr>
									<tr valign="top">
									<th scope="row" style="padding-top:25px;">Sub Keyword:</th>
									<td>
										<div id="wpblm2-posts-sel">
											<div class="wpbml2_url_sel">
												<input type="text" id="article_forge_setting_subkey_id" placeholder="Enter your sub keyword" value="<?php if(!empty($result_article_forge_setting_sub_key)) { echo $result_article_forge_setting_sub_key; } ?>" style="padding:6px;width:60%;border-radius:5px;display: block;"/>
												<span style="font-size:12px;"><u><b>Note:-</b></u> If you enter more than 5 sub keywords, Article Forge will select 5 . <br/>Sub keyword should be seperated by comma for eg :- "example1,example2,example3 " . <br/>Sub keyword should not contain URLs, parentheses, brackets, or too many single characters.</span>
											</div>
										</div>
									</td>
									</tr>
									<tr valign="top">
									<th scope="row" style="padding-top:25px;">Api Key</th>
									<td>
										<div id="wpblm2-posts-sel">
											<div class="wpbml2_url_sel">
												<input type="text" class="regular-text article_forge_api_key_cls" name="article_forge_api_key"  id="article_forge_api_key_id" placeholder="enter your api_key" value="<?php if(!empty($result_article_forge_key)) { echo $result_article_forge_key; } else { echo ""; } ?>" style="padding:6px;width:60%;border-radius:5px;display: block;" required><br>
											</div>
										</div>
									</td>
									</tr>
									<tr valign="top">
									<th scope="row" style="padding-top:25px;">Add Title	</th>
									<td>
										<div id="wpblm2-posts-sel">
											<div class="wpbml2_url_sel">
												<select class="article_forge_add_title_cls" id="article_forge_add_title_id" name="article_forge_add_title">
												  <option value="off" <?php if(!empty($result_article_forge_title) && $result_article_forge_title == 'off') { echo "selected"; } ?>>Off</option>
												  <option value="on" <?php if(!empty($result_article_forge_title) && $result_article_forge_title == 'on') { echo "selected"; } ?>>On</option>
												</select>
											</div>
										</div>
									</td>
									</tr>
									<tr valign="top">
									<th scope="row" style="padding-top:25px;">Add Image	</th>
									<td>
										<div id="wpblm2-posts-sel">
											<div class="wpbml2_url_sel">
												<select class="article_forge_add_image_cls" id="article_forge_add_image_id" name="article_forge_add_image">
												  <option value="off" <?php if(!empty($result_article_forge_image) && $result_article_forge_image == 'off') { echo "selected"; } ?>>Off</option>
												  <option value="on" <?php if(!empty($result_article_forge_image) && $result_article_forge_image == 'on') { echo "selected"; } ?>>On</option>
												</select>
											</div>
										</div>
									</td>
									</tr>
									<tr valign="top">
									<th scope="row" style="padding-top:25px;">Content Length</th>
									<td>
										<div id="wpblm2-posts-sel">
											<div class="wpbml2_url_sel">
												<select class="article_forge_content_length_cls" id="article_forge_content_length_id" name="article_forge_content_length">
												  <option value="very_short" <?php if(!empty($result_article_forge_content_length) && $result_article_forge_content_length == 'very_short') { echo "selected"; } ?>>Very short 50 Words</option>
												  <option value="short" <?php if(!empty($result_article_forge_content_length) && $result_article_forge_content_length == 'short') { echo "selected"; } ?>>Short 250 Words</option>
												  <option value="medium" <?php if(!empty($result_article_forge_content_length) && $result_article_forge_content_length == 'medium') { echo "selected"; } ?>>Medium 500 Words</option>
												  <option value="long" <?php if(!empty($result_article_forge_content_length) && $result_article_forge_content_length == 'long') { echo "selected"; } ?>>medium 750 Words</option>
												  <option value="very_long" <?php if(!empty($result_article_forge_content_length) && $result_article_forge_content_length == 'very_long') { echo "selected"; } ?>>Long 1500 Words</option>
												</select>
											</div>
										</div>
									</td>
									</tr>
									<tr valign="top">
									<td style="padding: 7px;width: 13%;">
										<input type="submit" class="btn btn-primary btn_article_forge_setting" value="Save" style="margin-top:15px;padding:5px 10px 5px 10px;"/>
									</td>
									</tr>
									</form>
								  </tbody>   
								</table>    							
							</div>
						</div>
					</section>	
					
					<section id="content5" class="tab-content">
						<div id="ytube_setting_div"></div>
						<div class="box-body">
							<div class="setting-form">					
							<h4>Note:- Don't have a YouTube API ? Click here to get your Google API key here :  <a href="https://console.cloud.google.com" style="text-decoration:underline;color:#000;" target="_blank">https://console.cloud.google.com</a></h4>
							<table class="form-table">
							  <tbody>
								<form id="setting_form" action="#" method="post" onSubmit="return false;">
								<tr valign="top">
								<th scope="row" style="padding-top:25px;">Api Key</th>
								<td>
									<div id="wpblm2-posts-sel">
										<div class="wpbml2_url_sel">
											<input type="text" class="regular-text ytube_api_key_cls" name="ytube_api_key"  id="ytube_api_key_id" placeholder="enter your api_key" value="<?php if(!empty($result_ytube_key)) { echo $result_ytube_key; } else { echo ""; } ?>" style="padding:6px;width:60%;border-radius:5px;display: block;" required><br>
										</div>
									</div>
								</td>
								</tr>
								<tr valign="top">
								<th scope="row" style="padding-top:25px;">Description</th>
								<td>
									<div id="wpblm2-posts-sel">
										<div class="wpbml2_url_sel">
											<div style="display:flex;"><input type="checkbox" class="ytube_desc_enable_cls" name="ytube_desc_enable"  id="ytube_desc_enable_id" style="margin-top:13px;display: block;" <?php if(!empty($result_ytube_enable) && $result_ytube_enable == 'on') { echo "checked"; } elseif($result_ytube_enable == 'off') { echo " "; } else { echo "checked"; }?>> <span style="margin:12px;">Enable YouTube Description</span></div><br>
										</div>
									</div>
								</td>
								</tr>
								<tr valign="top">
								<td style="padding: 7px;width: 13%;">
									<input type="submit" class="btn btn-primary btn_ytube_setting" value="Save" style="margin-top:15px;padding:5px 10px 5px 10px;"/>
								</td>								
								</tr>
								</form>
								</tbody>   
							</table>    							
							</div>
						</div>
					</section>
					
					<section id="content6" class="tab-content">
						<div id="builder_articles_setting_div"></div>
						<div class="box-body">
							<div class="setting-form">					
								<h4>Note:- Don't have a Article Builder account? Click here to sign up :  <a href="https://articlebuilder.net/order/" target="_blank" style="text-decoration:underline;color:#000;">https://articlebuilder.net/order/</a></h4>
								<form id="setting_form" action="#" method="post" onSubmit="return false;">
								<table class="form-table">
								  <tbody>
									<tr valign="top">
									<th scope="row" style="padding-top:25px;">Enable Articlebuilder</th>
									<td>
										<div id="wpblm2-posts-sel">
											<div class="wpbml2_url_sel">
												<input type="checkbox" class="article_builder_enable_cls" name="article_builder_enable"  id="article_builder_enable_id" style="margin-top:13px;display: block;" <?php if(!empty($result_article_builder_enable) && $result_article_builder_enable == 'on') { echo "checked"; } ?>><br>
											</div>
										</div>
									</td>
									</tr>
									<tr valign="top">
									<th scope="row" style="padding-top:25px;">Articlebuilder Username</th>
									<td>
										<div id="wpblm2-posts-sel">
											<div class="wpbml2_url_sel">
												<input type="text" class="regular-text articlebuilder_username_cls" name="articlebuilder_username"  id="articlebuilder_username_id" placeholder="enter your username" value="<?php if(!empty($result_articlebuilder_username)) { echo $result_articlebuilder_username; } else { echo ""; } ?>" style="padding:6px;width:60%;border-radius:5px;display: block;" required><br>
											</div>
										</div>
									</td>
									</tr>
									<tr valign="top">
									<th scope="row" style="padding-top:25px;">Articlebuilder Password</th>
									<td>
										<div id="wpblm2-posts-sel">
											<div class="wpbml2_url_sel">
												<input type="text" class="regular-text articlebuilder_password_cls" name="articlebuilder_password"  id="articlebuilder_password_id" placeholder="enter your password" value="<?php if(!empty($result_articlebuilder_password)) { echo $result_articlebuilder_password; } else { echo ""; } ?>" style="padding:6px;width:60%;border-radius:5px;display: block;" required><br>
											</div>
										</div>
									</td>
									</tr>
									<tr valign="top">
									<th scope="row" style="padding-top:25px;">Word Limit</th>
									<td>
										<div id="wpblm2-posts-sel">
											<div class="wpbml2_url_sel">
												<select class="articlebuilder_limit_cls" id="articlebuilder_limit_id" name="articlebuilder_limit">
												  <option value="250" <?php if(!empty($result_articlebuilder_limit) && $result_articlebuilder_limit == '250') { echo "selected"; } ?>>250</option>
												  <option value="300" <?php if(!empty($result_articlebuilder_limit) && $result_articlebuilder_limit == '300') { echo "selected"; } ?>>300</option>
												  <option value="400" <?php if(!empty($result_articlebuilder_limit) && $result_articlebuilder_limit == '400') { echo "selected"; } ?>>400</option>
												  <option value="500" <?php if(!empty($result_articlebuilder_limit) && $result_articlebuilder_limit == '500') { echo "selected"; } ?>>500</option>
												  <option value="600" <?php if(!empty($result_articlebuilder_limit) && $result_articlebuilder_limit == '600') { echo "selected"; } ?>>600</option>
												  <option value="700" <?php if(!empty($result_articlebuilder_limit) && $result_articlebuilder_limit == '700') { echo "selected"; } ?>>700</option>
												  <option value="800" <?php if(!empty($result_articlebuilder_limit) && $result_articlebuilder_limit == '800') { echo "selected"; } ?>>800</option>
												  <option value="900" <?php if(!empty($result_articlebuilder_limit) && $result_articlebuilder_limit == '900') { echo "selected"; } ?>>900</option>
												  <option value="1000" <?php if(!empty($result_articlebuilder_limit) && $result_articlebuilder_limit == '1000') { echo "selected"; } ?>>1000</option>
												</select>
											</div>
										</div>
									</td>
									</tr>
									<?php if(!empty($result_articlebuilder_username) && !empty($result_articlebuilder_password)) { ?>
									<tr valign="top">
									<th scope="row" style="padding-top:25px;">Category</th>
									<td>
										<div id="wpblm2-posts-sel">
											<div class="wpbml2_url_sel">
												<select class="articlebuilder_category_cls" id="articlebuilder_category_id" name="articlebuilder_category">
													<?php
													$url = 'http://articlebuilder.net/api.php';

													$testmethod = 'buildArticle';
													#$testmethod = 'injectContent';

													# Build the data array for authenticating.

													$data = array();
													$data['action'] = 'authenticate';
													$data['format'] = 'php'; # You can also specify 'xml' as the format.

													# Change to your own username/password.

													$data['username'] = $result_articlebuilder_username;
													$data['password'] = $result_articlebuilder_password;

													# Authenticate and get back the session id.
													# You only need to authenticate once per session.
													# A session is good for 24 hours.
													$output = unserialize(ab_setting_curl_post($url, $data, $info));

													if($output['success']=='true'){
													  # Success.
													  $session = $output['session'];
													  
													  # Build the data array for the example.
													  $data = array();
													  $data['session'] = $session;
													  $data['format'] = 'php'; # You can also specify 'xml' as the format.
													  $data['action'] = $testmethod;  
													  
													  # Post to API and get back results.
													  $output = ab_setting_curl_post($url, $data, $info);
													  $output = unserialize($output);
													  
													  $data['action'] = 'categories';
													  $cats = ab_setting_curl_post($url, $data, $info);
													  $cats = unserialize($cats); 

													  if($output['success']=='true'){
													    foreach($cats['output'] as $cat)
													    { ?>
													      <option value="<?php echo $cat; ?>" <?php if(!empty($result_ab_cat) && $result_ab_cat == $cat) { echo "selected"; } ?>><?php echo $cat; ?></option>
													    <?php 
														}
													  }
													}
													?>
												</select>
											</div>
										</div>
									</td>
									</tr>
								<?php } ?>
									<tr valign="top">
									<td style="padding: 7px;width: 13%;">
										<div class="form-group row content_hero_tab" style="display:flex;">
											<input type="submit" class="btn btn-primary btn_articlebuilder_setting" value="Save" style="margin-top:15px;padding:5px 10px 5px 10px;"/>
											<div id="afe_img_subcat_loader" style="display: flex;justify-content: center;">
												<img src="<?php echo plugins_url('MyContentCreatorPro-Free/includes/assets/images/loader_afe.gif'); ?>" id="loaders_articlebuilder_setting" style="display:none;width:50px;height:50px;padding: 15px 10px 1px 5px;"> 
											</div>											
										</div>
									</td>
								  </tbody>   
								</table>    							
								</form>
							</div>
						</div>
					</section>										
					

					
				</div>
			</div>	
        </div>
    </div>
</div>    
</div>    
<script>
jQuery('#select_ezine_category_id_setting').change(function () 
{
    var mych_category_id = jQuery(this).val();
	
	console.log(mych_category_id);
	
    jQuery("#subcat_tr_updated").css("display","none"); 
    if(mych_category_id === '')
    {        
        jQuery("#mych_subcat_result").html(' '); 
        jQuery("#mych_subcat_result").hide();
    }
    else
    {
        jQuery("#afe_loader_categ_id").css("display","block");
        jQuery("#afe_loader_categ_id").css("height","100px");
        jQuery("#mych_subcat_result").css("display","none");
        var data = {
            action: 'mych_get_ezine_subcat',
            ajax_mych_category_id : mych_category_id
        };
        jQuery.post(ajaxurl, data, function(response) {
            jQuery("#mych_subcat_result").html(response);
            jQuery("#afe_loader_categ_id").css("display","none"); 
            jQuery("#mych_subcat_result").css("display","block");
            jQuery("#subcat_tr").css("display","table-row");
        });
    }
});
jQuery('.btn_spinrewriter_setting').click(function(e)
{
	var spinrewriter_email = jQuery("#post_spin_email_id").val();
	var spinrewriter_api_key = jQuery("#post_spin_api_key_id").val();
	
	if( spinrewriter_email.length != 0 && spinrewriter_api_key.length != 0) 
	{
		var wpch_spin_setting = {
			action: 'wpch_spinrewriter_setting',
			ajax_spinrewriter_email : spinrewriter_email,
			ajax_spinrewriter_api_key : spinrewriter_api_key,
		};

		jQuery.post(ajaxurl, wpch_spin_setting, function(wpch_spin_google_response) 
		{
			jQuery("#spin_setting_div").html(wpch_spin_google_response);
			
		});
	}
});

jQuery('.btn_perfect_tense_setting').click(function(e)
{
	var perfect_api_key = jQuery("#post_perfect_api_key_id").val();
	var perfect_app_key = jQuery("#post_perfect_app_key_id").val();
	
	
	if( perfect_api_key.length != 0 && perfect_app_key.length != 0) 
	{
		var wpch_perfect_tense_setting = {
			action: 'wpch_perfect_tense_setting',
			ajax_perfect_api_key : perfect_api_key,
			ajax_perfect_app_key : perfect_app_key,
		};

		jQuery.post(ajaxurl, wpch_perfect_tense_setting, function(wpch_perfect_tense_response) 
		{
			jQuery("#perfect_tense_setting_div").html(wpch_perfect_tense_response);
			
		});
	}
});

jQuery('.btn_ezine_articles_setting').click(function(e)
{
	var ezine_articles_api = jQuery("#ezine_articles_api_key_id").val();	
	var ezine_article_limit_api = jQuery("#ezine_article_limit_id").val();	
	var ezine_category_id_setting = jQuery("#select_ezine_category_id_setting").val();	
	var ezine_subcategory_id_setting = jQuery("#select_ezine_subcategory_id_setting").val();	
	var ezine_subcategory_id_settings = jQuery("#select_ezine_subcategory_id_settings").val();	
	
	if(ezine_subcategory_id_setting === undefined)
	{
		var ez_scat = ezine_subcategory_id_settings;
	}
	else
	{
		var ez_scat = ezine_subcategory_id_setting;
	}
	
	jQuery("#key_error_message_ezinearticle").css("display","none"); 
	jQuery("#loaders_ezine_setting").css("display","block"); 
	jQuery("#warning-message-ezine").css("display","block"); 		
	
	if(jQuery('#article_ezine_enable_id').is(':checked')) 
	{
		var ezine_enable_articles = 'on';
	}
	else
	{
		var ezine_enable_articles = 'off';
	}
	
	if( ezine_articles_api.length != 0) 
	{
		var wpch_ezine_articles_setting = {
			action: 'wpch_ezine_articles_setting',
			ajax_ezine_articles_api_key : ezine_articles_api,
			ajax_ezine_enable_articles : ezine_enable_articles,
			ajax_ezine_article_limit : ezine_article_limit_api,
			ajax_ezine_category_id_setting : ezine_category_id_setting,
			ajax_ezine_subcategory_id_setting : ez_scat,
		};

		jQuery.post(ajaxurl, wpch_ezine_articles_setting, function(wpch_ezine_articles_response) 
		{
			jQuery("#ezine_articles_setting_div").html(wpch_ezine_articles_response);
			jQuery("#loaders_ezine_setting").css("display","none"); 					
			jQuery("#warning-message-ezine").css("display","none"); 		
		});
	}
	
});

jQuery('.btn_article_forge_setting').click(function(e)
{
	if(jQuery('#article_forge_enable_id').is(':checked')) 
	{
		var article_forge_enable = 'on';
	}
	else
	{
		var article_forge_enable = 'off';
	}
	//console.log(article_forge_enable);	
	
	var article_forge_api_key = jQuery("#article_forge_api_key_id").val();	
	var article_forge_add_title = jQuery("#article_forge_add_title_id").val();	
	var article_forge_add_image = jQuery("#article_forge_add_image_id").val();	
	var article_forge_content_length = jQuery("#article_forge_content_length_id").val();
	var article_forge_setting_keyword = jQuery("#article_forge_setting_keyword_id").val();
	var article_forge_setting_subkey = jQuery("#article_forge_setting_subkey_id").val();
	
	if( article_forge_api_key.length != 0) 
	{
		var wpch_article_forge_setting = {
			action: 'wpch_article_forge_setting',
			ajax_article_forge_enable : article_forge_enable,
			ajax_article_forge_api_key : article_forge_api_key,
			ajax_article_forge_add_title : article_forge_add_title,
			ajax_article_forge_add_image : article_forge_add_image,
			ajax_article_forge_content_length : article_forge_content_length,
			ajax_article_forge_setting_keyword : article_forge_setting_keyword,
			ajax_article_forge_setting_subkey : article_forge_setting_subkey,
		};

		jQuery.post(ajaxurl, wpch_article_forge_setting, function(wpch_article_forge_response) 
		{
			jQuery("#article_forge_setting_div").html(wpch_article_forge_response);
			
		});
	}
});


jQuery('.btn_articlebuilder_setting').click(function(e)
{
	if(jQuery('#article_builder_enable_id').is(':checked')) 
	{
		var article_builder_enable = 'on';
	}
	else
	{
		var article_builder_enable = 'off';
	}


	var articlebuilder_username = jQuery("#articlebuilder_username_id").val();	
	var articlebuilder_password = jQuery("#articlebuilder_password_id").val();	
	var articlebuilder_limit = jQuery("#articlebuilder_limit_id").val();	
	var articlebuilder_category = jQuery("#articlebuilder_category_id").val();	
	
	var wpch_article_builder_setting = {
		action: 'wpch_article_builder_setting',
		ajax_article_builder_enable : article_builder_enable,
		ajax_articlebuilder_username : articlebuilder_username,
		ajax_articlebuilder_password : articlebuilder_password,
		ajax_articlebuilder_limit : articlebuilder_limit,
		ajax_articlebuilder_category : articlebuilder_category,
	};

	jQuery.post(ajaxurl, wpch_article_builder_setting, function(wpch_article_builder_response) 
	{
		jQuery("#builder_articles_setting_div").html(wpch_article_builder_response);
		
	});
});

jQuery('.btn_ytube_setting').click(function(e)
{
	if(jQuery('#ytube_desc_enable_id').is(':checked')) 
	{
		var ytube_enable = 'on';
	}
	else
	{
		var ytube_enable = 'off';
	}
	var ytube_api_key = jQuery("#ytube_api_key_id").val();	
	
	var wpch_ytube_enable_setting = {
		action: 'wpch_ytube_setting',
		ajax_ytube_enable : ytube_enable,
		ajax_ytube_api_key : ytube_api_key,
	};

	jQuery.post(ajaxurl, wpch_ytube_enable_setting, function(wpch_ytube_response) 
	{
		jQuery("#ytube_setting_div").html(wpch_ytube_response);
		
	});
});


</script>