HEX
Server: LiteSpeed
System: Linux atali.colombiahosting.com.co 5.14.0-570.12.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Tue May 13 06:11:55 EDT 2025 x86_64
User: coopserp (1713)
PHP: 8.2.29
Disabled: dl,exec,passthru,proc_open,proc_close,shell_exec,memory_limit,system,popen,curl_multi_exec,show_source,symlink,link,leak,listen,diskfreespace,tmpfile,ignore_user_abord,highlight_file,source,show_source,fpaththru,virtual,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setid,posix_times,posix_ttyname,posix_uname,proc_get_status,proc_nice,proc_terminate
Upload Files
File: /home/coopserp/public_html/main.zip
PKv�f\V�..	promo.phpnu�[���<?php

namespace SpeedyCache;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class Promo{
	static function update_notice(){
		if(defined('SOFTACULOUS_PLUGIN_UPDATE_NOTICE')){
			return;
		}

		$to_update_plugins = apply_filters('softaculous_plugin_update_notice', []);

		if(empty($to_update_plugins)){
			return;
		}

		/* translators: %1$s is replaced with a "string" of name of plugins, and %2$s is replaced with "string" which can be "is" or "are" based on the count of the plugin */
		$msg = sprintf(__('New versions of %1$s %2$s available. Updating ensures better performance, security, and access to the latest features.', 'speedycache'), '<b>'.esc_html(implode(', ', $to_update_plugins)).'</b>', (count($to_update_plugins) > 1 ? 'are' : 'is')) . ' <a class="button button-primary" href='.esc_url(admin_url('plugins.php?plugin_status=upgrade')).'>Update Now</a>';

		define('SOFTACULOUS_PLUGIN_UPDATE_NOTICE', true); // To make sure other plugins don't return a Notice
		echo '<div class="notice notice-info is-dismissible" id="speedycache-plugin-update-notice">
			<p>'.$msg. '</p>
		</div>';

		wp_register_script('speedycache-update-notice', '', ['jquery'], '', true);
		wp_enqueue_script('speedycache-update-notice');
		wp_add_inline_script('speedycache-update-notice', 'jQuery("#speedycache-plugin-update-notice").on("click", function(e){
			let target = jQuery(e.target);

			if(!target.hasClass("notice-dismiss")){
				return;
			}

			var data;
			
			// Hide it
			jQuery("#speedycache-plugin-update-notice").hide();
			
			// Save this preference
			jQuery.post("'.admin_url('admin-ajax.php?action=speedycache_close_update_notice').'&security='.wp_create_nonce('speedycache_promo_nonce').'", data, function(response) {
				//alert(response);
			});
		});');
	}
	
}PKv�f\�s?��K�K	admin.phpnu�[���<?php

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

// Show menu with error if speedy cache is installed but is older than 1.1.0
// as after that we dont short circuit the free version
if(!defined('SPEEDYCACHE_VERSION') || version_compare(SPEEDYCACHE_VERSION, '1.1.1') < 0){
	add_action('admin_menu', 'speedycachepro_add_menu');
	return; // Return else going forward will break things.
}

add_action('speedycache_license_tmpl', '\SpeedyCache\SettingsPage::license_tab');
add_action('speedycache_db_tmpl', '\SpeedyCache\SettingsPage::db_tab');
add_action('speedycache_pro_logs_tmpl', '\SpeedyCache\SettingsPage::logs');
add_action('speedycache_pro_stats_tmpl', '\SpeedyCache\SettingsPage::stats');
add_action('speedycache_image_optm_tmpl', '\SpeedyCache\SettingsPage::image_optm');
add_action('speedycache_bloat_tmpl', '\SpeedyCache\SettingsPage::bloat_tab');
add_action('speedycache_object_cache_tmpl', '\SpeedyCache\SettingsPage::object_tab');

include_once SPEEDYCACHE_PRO_DIR . '/main/premium.php';

if(defined('SPEEDYCACHE_PRO') && file_exists(SPEEDYCACHE_PRO_DIR . '/main/image.php')){
	\SpeedyCache\Image::init();
	add_action('wp_ajax_speedycache_download_cwebp', '\SpeedyCache\Image::download_cwebp');
	add_action('add_meta_boxes_attachment', 'speedycache_pro_media_metabox');
}

add_action('admin_init', 'speedycache_pro_schedule_test_event');
add_action('admin_notices', 'speedycache_pro_notices');
add_filter('softaculous_expired_licenses', 'speedycache_pro_plugins_expired');
add_action('admin_enqueue_scripts', 'speedycache_pro_enqueue_admin_scripts');

// ----- AJAX ACTIONS ----- //
add_action('wp_ajax_speedycache_statics_ajax_request', 'speedycache_pro_img_stats');
add_action('wp_ajax_speedycache_optimize_image_ajax_request', 'speedycache_pro_optimize_image');
add_action('wp_ajax_speedycache_update_image_settings', 'speedycache_pro_save_img_settings');
add_action('wp_ajax_speedycache_update_image_list_ajax_request', 'speedycache_pro_list_imgs');
add_action('wp_ajax_speedycache_revert_image_ajax_request', 'speedycache_pro_revert_img');
add_action('wp_ajax_speedycache_img_revert_all', 'speedycache_pro_revert_all_imgs');
add_action('wp_ajax_speedycache_verify_license', 'speedycache_pro_verify_license');
add_action('wp_ajax_speedycache_copy_test_settings', 'speedycache_pro_copy_test_settings');
add_action('wp_ajax_speedycache_dismiss_test_notice','speedycache_pro_dismiss_test_notice');
add_action('wp_ajax_speedycache_pro_dismiss_expired_licenses', 'speedycache_pro_dismiss_expired_licenses');

function speedycachepro_add_menu(){
	add_menu_page('SpeedyCache Settings', 'SpeedyCache', 'activate_plugins', 'speedycache', 'speedycachepro_menu_page');
}

function speedycachepro_menu_page(){
	echo '<div style="color: #333;padding: 50px;text-align: center;">
		<h1 style="font-size: 2em;margin-bottom: 10px;">Update Speedycache to Latest Version!</h>
		<p style=" font-size: 16px;margin-bottom: 20px; font-weight:400;">SpeedyCache Pro depends on the free version of SpeedyCache, so you need to update the free version to use SpeedyCache without any issue.</p>
		<a href="'.admin_url('plugin-install.php?s=speedycache&tab=search').'" style="text-decoration: none;font-size:16px;">Install Now</a>
	</div>';
}

function speedycache_pro_img_stats(){
	check_ajax_referer('speedycache_ajax_nonce', 'security');

	if(!current_user_can('manage_options')){
		wp_die('Must be admin');
	}
	
	if(!class_exists('\SpeedyCache\Image')){
		wp_send_json_error(__('The file required to Process Image optimization is not present', 'speedycache'));
	}

	$res = \SpeedyCache\Image::statics_data();
	wp_send_json($res);
}

function speedycache_pro_optimize_image(){
	check_ajax_referer('speedycache_ajax_nonce', 'security');

	if(!current_user_can('manage_options')){
		wp_die('Must be admin');
	}
	
	if(!class_exists('\SpeedyCache\Image')){
		wp_send_json_error(__('The file required to Process Image optimization is not present', 'speedycache'));
	}
	
	$id = null;
	if(!empty($_POST['img_id'])){
		$id = (int) sanitize_text_field(wp_unslash($_POST['img_id']));
		
		if(empty($id)){
			wp_send_json_error('Empty Image ID');
		}
	}
	

	$res = \SpeedyCache\Image::optimize_single($id);
	$res[1] = isset($res[1]) ? $res[1] : '';
	$res[2] = isset($res[2]) ? $res[2] : '';
	$res[3] = isset($res[3]) ? $res[3] : '';
	
	$response = array(
		'message' => $res[0],
		'success' => $res[1],
		'id' => $res[2],
		'percentage' => $res[3],
	);
	
	wp_send_json($response);
}

function speedycache_pro_save_img_settings(){
	check_ajax_referer('speedycache_ajax_nonce', 'security');
	
	if(!current_user_can('manage_options')){
		wp_die('Must be admin');
	}
	
	global $speedycache;

	$settings = speedycache_optpost('settings');
	
	foreach($settings as $key => $setting){		
		$new_key = str_replace('img_', '', $key);
		
		$settings[$new_key] = $setting;
		unset($settings[$key]);
	}

	$speedycache->image['settings'] = $settings;
	
	if(update_option('speedycache_img', $speedycache->image['settings'])){
		wp_send_json_success();
	}
	
	wp_send_json_error();
}

function speedycache_pro_list_imgs(){
	check_ajax_referer('speedycache_ajax_nonce', 'security');
	
	if(!current_user_can('manage_options')){
		wp_die('Must be admin');
	}
	
	$query_images_args = array();
	$query_images_args['offset'] = intval(speedycache_optget('page')) * intval(speedycache_optget('per_page'));
	$query_images_args['order'] = 'DESC';
	$query_images_args['orderby'] = 'ID';
	$query_images_args['post_type'] = 'attachment';
	$query_images_args['post_mime_type'] = array('image/jpeg', 'image/png', 'image/gif');
	$query_images_args['post_status'] = 'inherit';
	$query_images_args['posts_per_page'] = speedycache_optget('per_page');
	$query_images_args['meta_query'] = array(
								array(
									'key' => 'speedycache_optimisation',
									'compare' => 'EXISTS'
									)
								);

	$query_images_args['s'] = speedycache_optget('search');

	if(!empty($_GET['filter'])){
		if(speedycache_optget('filter') == 'error_code'){
			
			$filter = array(
				'key' => 'speedycache_optimisation',
				'value' => base64_encode('"error_code"'),
				'compare' => 'LIKE'
			);

			$filter_second = array(
				'key' => 'speedycache_optimisation',
				'compare' => 'NOT LIKE'
			);

			array_push($query_images_args['meta_query'], $filter);
			array_push($query_images_args['meta_query'], $filter_second);
		}
	}

	$result = array(
		'content' => \SpeedyCache\Image::list_content($query_images_args),
		'result_count' => \SpeedyCache\Image::count_query($query_images_args)
	);

	wp_send_json($result);
}

function speedycache_pro_revert_img(){
	check_ajax_referer('speedycache_ajax_nonce', 'security');

	if(!current_user_can('manage_options')){
		wp_die('Must Be admin');
	}

	global $speedycache;

	if(!empty($_GET['id'])){
		$speedycache->image['id'] = (int) speedycache_optget('id');
	}

	wp_send_json(\SpeedyCache\Image::revert());
}

function speedycache_pro_revert_all_imgs(){
	check_ajax_referer('speedycache_ajax_nonce', 'security');

	if(!current_user_can('manage_options')){
		wp_die('Must be admin');
	}
	
	\SpeedyCache\Image::revert_all();
}


function speedycache_pro_verify_license(){

	if(!wp_verify_nonce($_GET['security'], 'speedycache_license')){
		wp_send_json_error(__('Security Check Failed', 'speedycache'));
	}
	
	if(!current_user_can('manage_options')){
		wp_send_json_error(__('You do not have required permission.', 'speedycache'));
	}
	
	global $speedycache;

	$license = sanitize_key($_GET['license']);
	
	if(empty($license)){
		wp_send_json_error(__('The license key was not submitted', 'speedycache'));
	}
	
	$resp = wp_remote_get(SPEEDYCACHE_API.'license.php?license='.$license.'&url='.rawurlencode(site_url()), array('timeout' => 30));
	
	if(!is_array($resp)){
		wp_send_json_error(__('The response was malformed<br>'.var_export($resp, true), 'speedycache'));
	}

	$json = json_decode($resp['body'], true);

	// Save the License
	if(empty($json['license'])){
		wp_send_json_error(__('The license key is invalid', 'speedycache'));
	}
	
	$speedycache->license = $json;
	update_option('speedycache_license', $json, false);
	
	wp_send_json_success();
}

function speedycache_pro_enqueue_admin_scripts(){
	wp_enqueue_style('speedycache-admin-pro', SPEEDYCACHE_PRO_URL . '/assets/css/admin.css', [], SPEEDYCACHE_PRO_VERSION);
	wp_enqueue_script('speedycache-admin-pro', SPEEDYCACHE_PRO_URL . '/assets/js/admin.js', [], SPEEDYCACHE_PRO_VERSION);
	wp_localize_script('speedycache-admin-pro', 'speedycache_pro_ajax', [
		'url' => admin_url('admin-ajax.php'),
		'nonce' => wp_create_nonce('speedycache_pro_ajax_nonce'),
		'premium' => defined('SPEEDYCACHE_PRO'),
	]);
}

// Sets speedycache settings to our predefined defaults.
function speedycache_pro_copy_test_settings(){
	check_ajax_referer('speedycache_pro_ajax_nonce', 'security');

	if(!current_user_can('manage_options')){
		wp_die('Must be admin');
	}

	global $speedycache;

	$test_settings = ['minify_html' => true, 'delay_js' => true, 'render_blocking' => true, 'minify_js' => true, 'critical_images' => true, 'lazy_load' => true, 'delay_js_mode' => 'selected', 'delay_js_scripts' => ['fbevents.js', 'google-analytics.com', 'adsbygoogle.js', 'googletagmanager.com', 'fbq(', "ga( '", "ga('", '/gtm.js', '/gtag/js', 'gtag(', '/gtm-', '/gtm.']];
	
	$speedycache->options = array_merge($speedycache->options, $test_settings);
	
	update_option('speedycache_options', $speedycache->options);
	delete_option('speedycache_test_results');
	
	wp_send_json_success(__('Settings applied successfully.', 'speedycache-pro'));
}	

function speedycache_pro_dismiss_test_notice(){
	check_ajax_referer('speedycache_pro_ajax_nonce', 'security');

	if(!current_user_can('manage_options')){
		wp_die('Must be admin');
	}
	
	delete_option('speedycache_test_results');
}

function speedycache_pro_schedule_test_event() {
	$install_time = get_option('speedycache_free_installed', 0);
	$event_executed = get_option('speedycache_test_executed', 0);
	if($install_time && !$event_executed){
		if(($install_time + WEEK_IN_SECONDS) < time()){
			$event_time = time() + DAY_IN_SECONDS;
		} else {
			$event_time = $install_time + WEEK_IN_SECONDS;
		}

		if(!wp_next_scheduled('speedycache_test_event')){
			wp_schedule_single_event($event_time, 'speedycache_test_event');
		}
	}
}

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

	$current_screen = get_current_screen();
	if(!isset($current_screen->id) || strpos($current_screen->id, 'speedycache') === false){
		return;
	}

	$test_results = get_option('speedycache_test_results');

	if(empty($test_results)){
		return;
	}
	
	$old_score = $test_results['old_score'];
	$new_score = $test_results['new_score'];

	$stroke_old = !empty($old_score) ? 100 - $old_score : 0;
	$stroke_new = !empty($new_score) ? 100 - $new_score : 0;

	$old_color = speedycache_pro_get_score_color($old_score);
	$new_color = speedycache_pro_get_score_color($new_score);

	echo '<div class="notice notice-success is-dismissible speedycache-test-notice">
	<p class="speedycache-notice-title"><strong>'.esc_html__('Speed Test Results:', 'speedycache-pro').'</strong></p>

	<div class="speedycache-test-chart-wrap">
		<!-- Before Optimization -->
		<div class="speedycache-donut-wrap speedycache-before-optimization">
			<svg width="150" height="150" viewBox="0 0 40 40" class="speedycache-donut">
				<circle class="donut-hole" cx="20" cy="20" r="15.91549430918954" fill="'.esc_attr($old_color[1]).'"></circle>
				<circle class="speedycache-donut-segment" cx="20" cy="20" r="15.91549430918954" fill="transparent" stroke-width="3" stroke-linecap="round" stroke-dasharray="'.esc_attr($old_score).' '.esc_attr($stroke_old).'" stroke-dashoffset="25" style="stroke:'.esc_attr($old_color[0]).';"></circle>
				<g class="speedycache-test-donut-text">
					<text y="55%" transform="translate(0, 2)">
						<tspan x="50%" text-anchor="middle" class="speedycache-donut-percent" style="fill:'.esc_attr($old_color[2]).';">'.esc_attr($old_score).'</tspan>
					</text>
				</g>
			</svg>
			<p class="speedycache-donut-label">'.esc_html__('Before Optimization', 'speedycache-pro').'</p>
		</div>

		<!-- After Optimization -->
		<div class="speedycache-donut-wrap speedycache-after-optimization">
			<svg width="150" height="150" viewBox="0 0 40 40" class="speedycache-donut">
				<circle class="donut-hole" cx="20" cy="20" r="15.91549430918954" fill="'.esc_attr($new_color[1]).'"></circle>
				<circle class="speedycache-donut-segment" cx="20" cy="20" r="15.91549430918954" fill="transparent" stroke-width="3" stroke-linecap="round" stroke-dasharray="'.esc_attr($new_score).' '.esc_attr($stroke_new).'" stroke-dashoffset="25" style="stroke:'.esc_attr($new_color[0]).';"></circle>
				<g class="speedycache-test-donut-text">
					<text y="55%" transform="translate(0, 2)">
						<tspan x="50%" text-anchor="middle" class="speedycache-donut-percent" style="fill:'.esc_attr($new_color[2]).';">'.esc_attr($new_score).'</tspan>
					</text>
				</g>
			</svg>
			<p class="speedycache-donut-label">'.esc_html__('After Optimization', 'speedycache-pro').'</p>
		</div>
	</div>

	<div class="speedycache-test-action">
		'.esc_html__('Want to enable the SpeedyCache settings used for this test?', 'speedycache-pro').' 
		<button class="speedycache-enable-btn speedycache-copy-test-settings">'.esc_html__('Enable Now', 'speedycache-pro').'</button>
	</div>

	<button type="button" class="notice-dismiss speedycache-custom-dismiss">
		<span class="screen-reader-text">'.esc_html__('Dismiss this notice.', 'speedycache-pro').'</span>
	</button>
	</div>';
}

function speedycache_pro_plugins_expired($plugins){
	global $speedycache;
	
	if(!empty($speedycache->license) && empty($speedycache->license['active'])){
		$plugins[] = 'SpeedyCache';
	}

	return $plugins;
}

function speedycache_pro_notices(){
	global $speedycache;
	
	if(!current_user_can('activate_plugins')){
		return;
	}

	$current_screen = get_current_screen();
	
	// Test result notice
	if(isset($current_screen->id) && strpos($current_screen->id, 'speedycache') !== false){
		speedycache_pro_test_results_notice();
	}
	
	// If the license is active then we do not need to show any notice.
	if(!empty($speedycache->license) && empty($speedycache->license['active'])){
		speedycache_pro_expiry_notice();
	}
	
}

function speedycache_pro_expiry_notice(){
	global $speedycache;

	// The combined notice for all Softaculous plugin to show that the license has expired
	$dismissed_at = get_option('softaculous_expired_licenses', 0);
	$expired_plugins = apply_filters('softaculous_expired_licenses', []);
	if(
		!empty($expired_plugins) && 
		is_array($expired_plugins) && 
		!defined('SOFTACULOUS_EXPIRY_LICENSES') && 
		(empty($dismissed_at) || ($dismissed_at + WEEK_IN_SECONDS) < time())
	){

		define('SOFTACULOUS_EXPIRY_LICENSES', true); // To make sure other plugins don't return a Notice
		echo '<div class="notice notice-error is-dismissible" id="speedycache-pro-expiry-notice">
				<p>'.sprintf(__('Your %1$s plugin license has %2$sExpired%3$s. Please renew your license for uninterrupted updates and support.', 'speedycache-pro'), 
				esc_html(implode(', ', $expired_plugins)),
				'<font style="color:red;"><b>',
				'</b></font>'
				). '</p>
			</div>';

		wp_register_script('speedycache-pro-expiry-notice', '', array('jquery'), SPEEDYCACHE_PRO_VERSION, true );
		wp_enqueue_script('speedycache-pro-expiry-notice');
		wp_add_inline_script('speedycache-pro-expiry-notice', '
		jQuery(document).ready(function(){
			jQuery("#speedycache-pro-expiry-notice").on("click", ".notice-dismiss", function(e){
				e.preventDefault();
				let target = jQuery(e.target);

				let jEle = target.closest("#speedycache-pro-expiry-notice");
				jEle.slideUp();

				jQuery.post("'.admin_url('admin-ajax.php').'", {
					security : "'.wp_create_nonce('speedycache_expiry_notice').'",
					action: "speedycache_pro_dismiss_expired_licenses",
				}, function(res){
					if(!res["success"]){
						alert(res["data"]);
					}
				}).fail(function(data){
					alert("There seems to be some issue dismissing this alert");
				});
			});
		})');
	}
}

function speedycache_pro_get_score_color($score) {

	$score_color_map = [
		0   => ['#c00', '#c003', '#c00'], // Red
		50  => ['#fa3', '#ffa50036', '#fa3'], // Orange
		90  => ['#0c6', '#00cc663b', '#080'], // Green
	];

	if ($score >= 0 && $score < 50) {
		return $score_color_map[0];
	} elseif ($score >= 50 && $score < 90) {
		return $score_color_map[50];
	} else {
		return $score_color_map[90];
	}
}

function speedycache_pro_media_metabox($post){
	
	if(empty($post)){
		return;
	}
	
	$allowed_img_types = [
		'image/png',
		'image/jpg',
		'image/jpeg',
	];
	
	if(!in_array($post->post_mime_type, $allowed_img_types)){
		return;
	}

	add_meta_box( 
		'speedycache-optm-img',
		__('SpeedyCache Image Optimization', 'speedycache-pro'),
		'speedycache_pro_img_optm_metabox',
		'attachment',
		'side',
		'default'
		);
}

function speedycache_pro_img_optm_metabox($post){
	
	if(empty($post)){
		echo 'No Post data';
		return;
	}
	
	$optimized_data = get_post_meta($post->ID, 'speedycache_optimisation', true);
	
	if(!empty($optimized_data)){
		$optimized_data = base64_decode($optimized_data);
		$optimized_data = json_decode($optimized_data, true);
		
		if(!empty($optimized_data) && !empty($optimized_data[0]) && !empty($optimized_data[0]['file']) && file_exists($optimized_data[0]['file'])){
			esc_html_e('Image has already been optimized', 'speedycache-pro');
			return;
		}
	}

	echo '<button class="button" id="speedycache-optm-attachment" data-id="'.esc_attr($post->ID).'">'.esc_html__('Optimize this Image', 'speedycache-pro').'</button>';
	
	wp_register_script('speedycache-img-optm-meta-box', '', array('jquery'), '', true);
	wp_enqueue_script('speedycache-img-optm-meta-box');
	wp_add_inline_script('speedycache-img-optm-meta-box', 'jQuery(document).ready(function(){
		jQuery("#speedycache-optm-attachment").on("click", function(e){
			e.preventDefault();
			
			let attachment_id = jQuery(e.target).data("id"),
			nonce = "'.wp_create_nonce('speedycache_ajax_nonce').'";
			
			jQuery.ajax({
				url : "'.esc_url(admin_url('admin-ajax.php')).'",
				method : "POST",
				data : {
					"action":"speedycache_optimize_image_ajax_request",
					"security": nonce,
					"img_id": attachment_id,
				},
				success: function(res){
					if(res.success){
						window.location.reload();
					}
				}
			});
			
		})
	})');
}

function speedycache_pro_dismiss_expired_licenses(){
	check_admin_referer('speedycache_expiry_notice', 'security');

	if(!current_user_can('activate_plugins')){
		wp_send_json_error(__('You do not have required access to do this action', 'speedycache-pro'));
	}

	update_option('softaculous_expired_licenses', time());
	wp_send_json_success();
}PKv�f\�͂�"�"cdn.phpnu�[���<?php

namespace SpeedyCache;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class CDN{
	static $allowed_types = [];
	static $cdn_url = '';
	static $specific = [];
	static $excludes = [];
	
	static function rewrite(&$content){
		global $speedycache;

		self::$cdn_url = $speedycache->cdn['cdn_url'];
		self::$allowed_types = $speedycache->cdn['file_types'];
		self::$excludes = $speedycache->cdn['excludekeywords'];
		self::$specific = $speedycache->cdn['keywords'];

		if(empty(self::$cdn_url) || empty(self::$allowed_types)){
			return;
		}

		// Define the patterns to match specific URLs (e.g., images, CSS, JS)
		$base_dir = defined('SITEPAD') ? 'sitepad-data' : 'wp-content';

		if (defined('SITEPAD')){
			global $sitepad;
			$site_inc_url = $sitepad['url'] . '/site-inc';
		} else {
			$site_inc_url = home_url('/wp-includes/');
		}

		$patterns = [
			'/' . preg_quote(home_url("/{$base_dir}/uploads/"), '/') . '([^"\']+)/i',
			'/'.  preg_quote($site_inc_url, '/') . '([^"\']+)/i',
			'/' . preg_quote(home_url("/{$base_dir}/themes/"), '/') . '([^"\']+)/i',
			'/' . preg_quote(defined('SP_PLUGIN_URL') ? SP_PLUGIN_URL : home_url('/wp-content/plugins/'), '/') . '([^"\']+)/i',
			'/' . preg_quote(home_url("/{$base_dir}/cache/"), '/') . '([^"\']+)/i',
		];

		// Loop through each pattern and replace only URLs with the specified file types
		foreach($patterns as $pattern){
			$content = preg_replace_callback($pattern, '\SpeedyCache\CDN::replace_urls', $content);
		}
	}
	
	static function replace_urls($matches) {
		global $speedycache;

		// Get the file extension
		$file_url = preg_replace('/\?.*$/', '', $matches[0]);

		if(empty($file_url)){
			$file_url = $matches[0];
		}
		
		$file_url = trim($file_url, '/');

		if(self::is_excluded($file_url)){
			return $matches[0];
		}
		
		// To rewrite just some specific files only
		if(!empty(self::$specific) && is_array(self::$specific)){
			$is_specific = false;

			foreach(self::$specific as $required_source){
				if(preg_match('/'.preg_quote($required_source).'/i', $file_url)){
					$is_specific = true;
					break;
				}
			}

			if(empty($is_specific)){
				return $matches[0];
			}	
		}
		
		$file_extension = self::get_file_extension($file_url);
		
		// Check if the file extension is in the allowed list
		if(in_array(strtolower($file_extension), self::$allowed_types)){
			$home_url = home_url();

			// Rewrite the URL to use the CDN
			return str_replace($home_url, self::$cdn_url, $matches[0]);
		}

		// If not in the allowed list, return the original URL
		return $matches[0];
	}
	
	static function get_file_extension($url) {
		
		$url = strtok($url, ' ');
		$url = strtok($url, '?');
		
		return strtolower(pathinfo(parse_url($url, PHP_URL_PATH), PATHINFO_EXTENSION));
	}
	
	static function is_excluded($url){

		if(empty($url)){
			return false;
		}
		
		// array check if just to make sure things dont break for 1.2.0 in which we rewrote the plugin
		if(empty(self::$excludes) || !is_array(self::$excludes)){
			return false;
		}
		
		foreach(self::$excludes as $exclude){
			if(preg_match('/'.preg_quote($exclude).'/i', $url)){				
				return true;
			}
		}

		return false;	
	}
	
	static function purge(){
		global $speedycache;

		// Only cloudflare and Bunny can be purged, that too we only want that to happen if CDN is enabled.
		if(
			empty($speedycache->cdn['enabled']) || 
			empty($speedycache->cdn['cdn_key']) || 
			empty($speedycache->cdn['cdn_type']) || 
			$speedycache->cdn['cdn_type'] == 'other'
		){
			return;
		}

		if($speedycache->cdn['cdn_type'] == 'bunny'){
			self::purge_bunny($speedycache->cdn);
		}elseif($speedycache->cdn['cdn_type'] == 'cloudflare'){
			self::purge_cloudflare($speedycache->cdn);
		}
		
	}
	
	// Get unique pull ID to purge cache on CDN 
	static function bunny_get_pull_id(&$cdn){
		global $speedycache;

		$pull_zone = $cdn['cdn_url']; // bunny cdn calls it cdn url as pull zone
		$access_key = $cdn['cdn_key'];
		
		if(empty($access_key)){
			return array('success' => false, 'message' => __('Bunny CDN Access Key not found', 'speedycache'));
		}
		
		$options = array(
			'headers' => array(
				'AccessKey' => $access_key,
				'accept' => 'application/json'
			)
		);

		$res = wp_remote_get('https://api.bunny.net/pullzone', $options);

		if(is_wp_error($res) || empty($res)){
			if(empty($res)){
				return array('success' => false, 'message' => __('Bunny CDN retuned an empty response', 'speedycache'));
			}
			
			return array('success' => false, 'message' => 'Something Went Wrong: ' . $res->get_error_message());
		}
		
		$res_code = wp_remote_retrieve_response_code($res);
		
		if(substr($res_code, 0, 1) != 2){
			return array('success' => false, 'message' => __('Something Went Wrong: Getting Pull ID was unsuccessful ', 'speedycache') . $res_code);
		}
		
		$res_body = wp_remote_retrieve_body($res);
		
		if(empty($res_body)){
			return array('success' => false, 'message' => __('Bunny CDN pull ID response body is empty', 'speedycache'));
		}

		$res_body = json_decode($res_body, true);
		
		foreach($res_body as $pull_zones){
			if($pull_zones['OriginUrl'] == $cdn['origin_url']){
				return $pull_zones['Id'];
			}
		}

		return array('success' => false, 'message' => __('Bunny Pull Zone not found', 'speedycache'));
	}
	
	static function purge_bunny($cdn){

		if(empty($cdn['cdn_key']) || empty($cdn['cdn_url'])){
			return false;
		}

		$pull_zone = $cdn['cdn_url']; // bunny cdn calls it cdn url as pull zone
		$access_key = $cdn['cdn_key'];
		$pull_id = !empty($cdn['bunny_pull_id']) ? $cdn['bunny_pull_id'] : '';

		if(empty($access_key) || empty($pull_id)){
			return false;
		}

		$options = array(
			'headers' => array(
				'AccessKey' => $access_key,
				'content-type' => 'application/json'
			)
		);

		$res = wp_remote_post('https://api.bunny.net/pullzone/'.$pull_id.'/purgeCache', $options);
		
		if(is_wp_error($res) || empty($res)){
			if(empty($res)){
				return __('Bunny CDN retuned an empty response', 'speedycache');
			}
			
			return 'Something Went Wrong: ' . $res->get_error_message();
		}

		$res_code = wp_remote_retrieve_response_code($res);
		
		if($res_code != 204){
			return esc_html__('Something Went Wrong: Purge was unsuccessful with response code of ', 'speedycache') . $res_code;
		}

		return esc_html__('Success: Bunny CDN purged successfully', 'speedycache');

	}
	
	static function cloudflare_zone_id(&$cdn){
		
		if(empty($cdn['cdn_key'])){
			return false;
		}

		$api_token = $cdn['cdn_key'];
		$domain = parse_url(home_url(), PHP_URL_HOST);

		$url = 'https://api.cloudflare.com/client/v4/zones?name='.$domain;

		$args = [
			'headers' => [
				'Authorization' => 'Bearer ' . $api_token,
				'Content-Type' => 'application/json',
			],
		];

		$response = wp_remote_get($url, $args);

		if (is_wp_error($response)) {
			return 'Error: ' . $response->get_error_message();
		}

		$body = json_decode(wp_remote_retrieve_body($response), true);

		if($body && isset($body['result'][0]['id'])){
			return $body['result'][0]['id']; // This is the Zone ID
		}
		
		return false;
	}
	
	static function purge_cloudflare($cdn){
		
		if(empty($cdn['cloudflare_zone_id']) || empty($cdn['cdn_key'])){
			return;
		}
		
		$zone_id = $cdn['cloudflare_zone_id'];
		$api_token = $cdn['cdn_key'];

		$url = 'https://api.cloudflare.com/client/v4/zones/'.$zone_id.'/purge_cache';

		$args = [
			'headers' => [
				'Authorization' => 'Bearer ' . $api_token,
				'Content-Type'  => 'application/json',
			],
			'body' => json_encode([
				'purge_everything' => true, // Set to true to purge all cache
			]),
		];

		$response = wp_remote_post($url, $args);

		if (is_wp_error($response)) {
			return 'Error: ' . $response->get_error_message();
		}

		$body = json_decode(wp_remote_retrieve_body($response), true);

		if ($body && isset($body['success']) && $body['success'] === true) {
			return esc_html__('Cloudflare cache purged successfully.', 'speedycache');
		}

		return 'Failed to purge Cloudflare cache. ' . (isset($body['errors'][0]['message']) ? $body['errors'][0]['message'] : '');
	}

	// Users can add a custom CDN URL in Head Tag
	static function cdn_preconnect(){
		global $speedycache;

		if(empty($speedycache->options['status']) || empty($speedycache->cdn['enabled']) || empty($speedycache->cdn['cdn_url'])){
			return;
		}
		
		if($speedycache->cdn['cdn_type'] == 'other' || $speedycache->cdn['cdn_type'] == 'bunny'){
			echo '<link rel="preconnect" href="'. esc_url($speedycache->cdn['cdn_url']) .'" crossorigin="anonymous">';
		}
	}
	
}
PKv�f\�+�||js.phpnu�[���<?php

namespace SpeedyCache;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT');
}

use \SpeedyCache\Util;

class JS{
	
	// Depericated since 1.2.0
	// do not use it just to prevent site from breaking.
	static function init(){
		
	}
	static function minify(&$content){
		global $speedycache;
		
		if(!class_exists('\SpeedyCache\Enhanced')){
			return;
		}

		preg_match_all('/<script\s+([^>]+[\s"\'])?src\s*=\s*[\'"]\s*?(?<url>[^\'"]+\.js(?:\?[^\'"]*)?)\s*?[\'"]([^>]+)?\/?><\/script>/is', $content, $tags, PREG_SET_ORDER);

		if(empty($tags)){
			return;
		}

		if(empty($_SERVER['HTTP_HOST'])){
			return;
		}

		$site_host = str_replace('www.', '', sanitize_text_field(wp_unslash($_SERVER['HTTP_HOST'])));
		$site_url = site_url();

		foreach($tags as $tag){

			if(empty($tag['url'])){
				continue;
			}

			$url = $tag['url'];
			
			if(self::is_excluded($url)) continue;

			// We don't want to minify already minified js
			if(strpos($url, '.min.js') !== FALSE){
				continue;
			}

			// We wont process any css that is not present on this WordPress install
			if(strpos($url, $site_host) === FALSE){
				continue;
			}

			$file_path = Util::url_to_path($url);

			if(!file_exists($file_path)){
				continue;
			}

			$file_name = self::file_name($file_path);
			
			if(empty($speedycache->enhanced)){
				\SpeedyCache\Enhanced::init();
			}
			
			$js = file_get_contents($file_path);
			$js = \SpeedyCache\Enhanced::minify_js($js);

			$asset_path = Util::cache_path('assets');
			if(!is_dir($asset_path)){
				mkdir($asset_path, 0755, true);
				touch($asset_path . 'index.html');
			}

			$minified_path = $asset_path.$file_name;

			file_put_contents($minified_path, $js);

			$minified_url = Util::path_to_url($minified_path);
			$content = str_replace($tag['url'], $minified_url, $content);
			
			// TODO: check if there is a preload.
		}
	}
	
	static function combine_head(&$content){
		global $speedycache;

		if (preg_match('/<head.*?>(.*?)<\/head>/is', $content, $head_section)) {			
			$head = preg_replace( '/<!--(.*)-->/Uis', '', $head_section[1]);

			// Regex pattern to match script tags with src attribute in the head section
			preg_match_all('/<script\s+([^>]+[\s"\'])?src\s*=\s*[\'"]\s*?(?<url>[^\'"]+\.js(?:\?[^\'"]*)?)\s*?[\'"]([^>]+)?\/?><\/script>/is', $head, $tags, PREG_SET_ORDER);
			
			if(empty($tags)){
				return;
			}

			if(empty($_SERVER['HTTP_HOST'])){
				return;
			}
			
			$site_host = str_replace('www.', '', sanitize_text_field(wp_unslash($_SERVER['HTTP_HOST'])));
			$site_url = site_url();
			
			$tags = array_reverse($tags);
			
			// There is no sense in combinining just 2 files.
			if(count($tags) < 2){
				return;
			}
			
			$combined_js = '';
			$prev_tag = '';

			foreach($tags as $tag){

				if(empty($tag['url'])){
					continue;
				}
				
				// We wont combine modules.
				if(!empty($tag[1]) && strpos($tag[1], 'module')){
					continue;
				}

				$url = $tag['url'];

				if(self::is_excluded($url)) continue;
				
				// We wont process any js that is not present on this WordPress install
				if(strpos($url, $site_host) === FALSE){
					continue;
				}
				
				$file_path = Util::url_to_path($url);

				if(!file_exists($file_path) || !is_readable($file_path)){
					continue;
				}

				$combined_js = file_get_contents($file_path) . "\n" . $combined_js;
				
				// Removing the JS which has already been combined, as we will add the combined file at the top after title.
				if(!empty($prev_tag)){
					$content = str_replace($prev_tag, '', $content);
				}
				
				// We remove the previous tag, in current iteration, so at last we have a tag to replace wirh the combined script.
				$prev_tag = $tag[0];
			}
			
			if(empty($combined_js)){
				return;
			}
			
			if(class_exists('\SpeedyCache\Enhanced') && !empty($speedycache->options['minify_js'])){
				if(empty($speedycache->enhanced)){
					\SpeedyCache\Enhanced::init();
				}

				$combined_js = \SpeedyCache\Enhanced::minify_js($combined_js);
			}

			// Creating Combined file name
			$file_name = md5($combined_js);
			$file_name = substr($file_name, 0, 16) . '-combined.js';
			
			$asset_path = Util::cache_path('assets');
			if(!is_dir($asset_path)){
				mkdir($asset_path, 0755, true);
				touch($asset_path . 'index.html');
			}

			$combined_path = $asset_path.$file_name;

			file_put_contents($combined_path, $combined_js);
			$final_url = Util::path_to_url($combined_path);

			// Injecting the Combined JS
			if(!empty($prev_tag)){
				$content = str_replace($prev_tag, '<script src="'.esc_url($final_url).'" />', $content);
				return;
			}

			$content = str_replace('</title>', "</title>\n".'<script src="'.esc_url($final_url).'"/>', $content);
		
		}
	}
	
	static function file_name($path){
		$file_hash = md5_file($path);
		$file_name = substr($file_hash, 0, 16) . '-' . basename($path);

		return $file_name;
	}
	
	static function combine_body(&$content){
		global $speedycache;
		
		\SpeedyCache\Enhanced::init();
		\SpeedyCache\Enhanced::set_html($content);

		if(!empty($speedycache->options['minify_js'])){
			$content = \SpeedyCache\Enhanced::combine_js_in_footer(true);
		}else{
			$content = \SpeedyCache\Enhanced::combine_js_in_footer();
		}
	}
	
	static function is_excluded($url){
		$excludes = get_option('speedycache_exclude', []);
		
		// Combining JQUERY will mess up the site.
		if(strpos($url, 'jquery')){
			return true;
		}

		if(empty($excludes)){
			return false;
		}

		foreach($excludes as $exclude){
			if(empty($exclude['type'])){
				continue;
			}

			if($exclude['type'] !== 'js'){
				continue;
			}

			if(empty($exclude['content'])){
				continue;
			}

			if(preg_match('/'.preg_quote($exclude['content'], '/').'/', $url)){
				return true;
			}
		}

		return false;
	}
}
PKv�f\tdy�zzgravatar.phpnu�[���<?php

namespace SpeedyCache;

if(!defined('ABSPATH')){
	die('Hacking Attempt');
}

class Gravatar{
	
	// Gets gravatar data
	static function get_avatar_data($args, $id_or_email){

		if(empty($args) || empty($args['found_avatar'])){
			return $args;
		}
		
		if(empty($args['url'])){
			return $args;
		}
		
		// Path to Gravatars
		$path = \SpeedyCache\Util::cache_path('gravatars');

		if(!is_dir($path)){
			mkdir($path, 0755, true);
			touch($path . 'index.html');
		}

		$email_hash = self::get_email_hash($id_or_email);
		if(empty($email_hash)){
			$email_hash = 'default';
		}

		$file_name = $email_hash . 'x' . $args['size'] . '.jpg';
		$file = $path . $file_name;

		if(file_exists($file)){
			$url = self::convert_path_to_link($path) . $file_name;

			$args['url'] = esc_url($url);
			return $args;
		}

		$res = wp_remote_get($args['url']);

		if(empty($res) || is_wp_error($res)){
			return $args;
		}

		if(empty($res['body'])){
			return $args;
		}

		// If we fail to write return the same URL;
		if(!file_put_contents($file, $res['body'])){
			return $args;
		}

		$url = self::convert_path_to_link($path) . $file_name;

		$args['url'] = esc_url($url);

		return $args;
	}
	
	// Gets the Email hash which is used in the URL.
	static function get_email_hash($id_or_email){

		if(is_numeric($id_or_email)){
			$user = get_user_by('id', $id_or_email);

			if(empty($user) || !is_a($user, 'WP_User')){
				return false;
			}

		} elseif(is_a($id_or_email, 'WP_User')){
			$user = $id_or_email;
		} elseif(is_a($id_or_email, 'WP_Post')){
			$user = get_user_by('id', (int) $id_or_email->post_author);
		} elseif(is_a($id_or_email, 'WP_Comment')){
			if(!empty($id_or_email->user_id)){
				$user = get_user_by('id', (int) $id_or_email->user_id);
			}

			if(empty($user) && !empty($id_or_email->comment_author_email)){
				$id_or_email = $id_or_email->comment_author_email;
			}

			if(is_a($id_or_email, 'WP_Comment')){
				return false;
			}
		}
		
		if(!empty($user) && is_a($user, 'WP_User')){
			$id_or_email = $user->user_email;
		}
		
		// We need an email which should be a string if something else is being passed then just return
		if(!is_string($id_or_email)){
			return false;
		}

		$email_hash = md5(strtolower(trim($id_or_email)));
		
		return $email_hash;
	}
	
	// Deletes all the gravatar stored
	static function delete(){
		$path = \SpeedyCache\Util::cache_path('gravatars');
		
		if(!file_exists($path)){
			return;
		}

		$files = scandir($path);
		
		if(empty($files)){
			return __('No file present to delete', 'speedycache');
		}
		
		foreach($files as $file){
			// We dont want to delete index.html or any directory.
			if(file_exists($path . $file) && !is_dir($path . $file) && $file != 'index.html'){
				@unlink($path . $file);
			}
		}

		return __('Gravatar files deleted', 'speedycache');
	}
	
	static function convert_path_to_link($path){
		preg_match('/\/cache\/speedycache\/.+/', $path, $out);
		$prefix_link = str_replace(array('http:', 'https:'), '', content_url());

		return $prefix_link . $out[0];
	}

}
PKv�f\@��q��install.phpnu�[���<?php
/*
* SITESEO
* https://siteseo.io
* (c) SiteSEO Team
*/

namespace SiteSEO;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class Install{
	
	static function activate(){
		self::default_settings();
		update_option('siteseo_version', SITESEO_VERSION);
	}

	static function deactivate(){
		flush_rewrite_rules();
	}

	static function uninstall(){
		flush_rewrite_rules();
		delete_option('siteseo_version');
		delete_option('siteseo_toggle');
		delete_option('siteseo_titles_option_name');
		delete_option('siteseo_social_option_name');
		delete_option('siteseo_advanced_option_name');
		delete_option('siteseo_instant_indexing_option_name');
		delete_option('siteseo_xml_sitemap_option_name');
		delete_option('siteseo_google_analytics_option_name');
		delete_option('siteseo_dismiss_intro');
	}
	
	static function action_links($links, $file){
		
		if($file === plugin_basename(SITESEO_FILE)){
				
			$links['siteseo-settings'] = '<a href="'.admin_url('admin.php?page=siteseo').'">'. __('Settings', 'siteseo').'</a>';
			$links['siteseo-wizard'] = '<a href="'.admin_url('?page=siteseo-onboarding').'">'. __('Configuration Wizard', 'siteseo').'</a>';
			$links['siteseo-docs-link'] = '<a href="https://siteseo.io/docs/" target="_blank"">'. __('Docs', 'siteseo').'</a>';
		
		}
		
		return $links;	
	}

	static function default_settings(){
		// We do not need to set defaults if we just upgrading the plugin
		$current_version = get_option('siteseo_version');
		if(!empty($current_version)){
			return;
		}
		
		$titles_metas = get_option('siteseo_titles_option_name', []);
		$social_settings = get_option('siteseo_social_option_name', []);
		$advanced_settings = get_option('siteseo_advanced_option_name', []);
		$sitemap_settings = get_option('siteseo_xml_sitemap_option_name', []);
		
		$toggle_settings = [
			'toggle-titles' => true,
			'toggle-xml-sitemap' => true,
			'toggle-instant-indexing' => true,
			'toggle-advanced' => true,
			'toggle-social' => true,
			'toggle-google-analytics' => true
		];

		// Titles and Metas
		$titles_metas['titles_sep'] = '-';
		$titles_metas['titles_home_site_title'] = !isset($titles_metas['titles_home_site_title']) ? '%%sitetitle%%' : $titles_metas['titles_home_site_title'];
		$titles_metas['titles_home_site_desc'] = !isset($titles_metas['titles_home_site_desc']) ? '%%tagline%%' : $titles_metas['titles_home_site_desc'];
		
		$post_types = siteseo_post_types();
		if(!empty($post_types) && is_array($post_types)){
			$post_types = array_keys($post_types);

			foreach($post_types as $post_type){
				$titles_metas['titles_single_titles'][$post_type]['title'] = !isset($titles_metas['titles_single_titles'][$post_type]['title']) ? '%%post_title%% %%sep%% %%sitetitle%%' : $titles_metas['titles_single_titles'][$post_type]['title'];
				$titles_metas['titles_single_titles'][$post_type]['description'] = !isset($titles_metas['titles_single_titles'][$post_type]['description']) ? '%%post_excerpt%% ' : $titles_metas['titles_single_titles'][$post_type]['description'];
			}
		}
		
		$taxonomies = get_taxonomies(array('public' => true), 'objects');
		if(!empty($taxonomies) && is_array($taxonomies)){
			$taxonomies = array_keys($taxonomies);
			
			foreach($taxonomies as $taxonomy){
				$titles_metas['titles_tax_titles'][$taxonomy]['title'] = !isset($titles_metas['titles_tax_titles'][$taxonomy]['title']) ? '%%_category_title%% %%sep%% %%sitetitle%%' : $titles_metas['titles_tax_titles'][$taxonomy]['title'];
				$titles_metas['titles_tax_titles'][$taxonomy]['description'] = !isset($titles_metas['titles_tax_titles'][$taxonomy]['description']) ? '%%_category_description%%' : $titles_metas['titles_tax_titles'][$taxonomy]['description'];	
			}
		}

		$titles_metas['titles_archives_author_title'] = !isset($titles_metas['titles_archives_author_title']) ? '%%post_author%% %%sep%% %%sitetitle%%' : $titles_metas['titles_archives_author_title'];
		$titles_metas['titles_archives_author_noindex'] = !isset($titles_metas['titles_archives_author_noindex']) ? true : '';
		$titles_metas['titles_archives_date_title'] = !isset($titles_metas['titles_archives_date_title']) ? '%%archive_date%% %%sep%% %%sitetitle%%' : '';
		$titles_metas['titles_archives_date_noindex'] = !isset($titles_metas['titles_archives_date_noindex']) ? true : '';
		$titles_metas['titles_archives_search_title_noindex'] = !isset($titles_metas['titles_archives_search_title_noindex']) ? true : '';
		$titles_metas['titles_nositelinkssearchbox'] = !isset($titles_metas['titles_nositelinkssearchbox']) ? true : '';
		$titles_metas['titles_archives_search_title'] = !isset($titles_metas['titles_archives_search_title']) ? '%%search_keywords%% %%sep%% %%sitetitle%%' : '';
		$titles_metas['titles_archives_404_title'] = !isset($titles_metas['titles_archives_404_title']) ? '404 - Page not found %%sep%% %%sitetitle%%' : $titles_metas['titles_archives_404_title'];

		// Social	
		$social_settings['social_twitter_card'] = true;
		$social_settings['social_facebook_og'] = true;

		// Sitemap
		$sitemap_settings['xml_sitemap_general_enable'] = true;
		$sitemap_settings['xml_sitemap_post_types_list']['post']['include'] = true;
		$sitemap_settings['xml_sitemap_post_types_list']['page']['include'] = true;
		$sitemap_settings['xml_sitemap_taxonomies_list']['category']['include'] = true;
		$sitemap_settings['xml_sitemap_img_enable'] = true; 

		// Advanced
		$advanced_settings['advanced_attachments'] = true;
		$advanced_settings['appearance_universal_metabox'] = true;

		update_option('siteseo_toggle', $toggle_settings);
		update_option('siteseo_titles_option_name', $titles_metas);
		update_option('siteseo_social_option_name', $social_settings);
		update_option('siteseo_xml_sitemap_option_name', $sitemap_settings);
		update_option('siteseo_advanced_option_name', $advanced_settings);

	}

}
PKv�f\G[��TiTisettings.phpnu�[���<?php
/*
* GoSMTP
* https://gosmtp.net
* (c) Softaculous Team
*/

if(!defined('GOSMTP_VERSION')){
	die('Hacking Attempt!');
}
	
// The Gosmtp Header
function gosmtp_page_header($title = 'GoSMTP'){
	
    $promos = apply_filters('gosmtp_review_link', true);
	
	wp_enqueue_style( 'gosmtp-admin' );
	wp_enqueue_script( 'gosmtp-admin' );
	
	echo '
<div class="gosmtp-box-container" style="margin:0">
	<h2>
		<table cellpadding="2" cellspacing="1" width="100%" class="fixed" border="0">
			<tr>
				<td valign="top">
					<h1>'.esc_html($title).'</h1>
				</td>';
				
				if(!defined('SITEPAD')){
					echo ($promos ? '
					<td align="right"><a target="_blank" class="button button-primary" href="https://wordpress.org/support/view/plugin-reviews/gosmtp">Review GoSMTP</a></td>' : '').'
					<td align="right" width="40"><a target="_blank" href="https://twitter.com/gosmtp"><img src="'.GOSMTP_URL.'/images/twitter.png" /></a></td>
					<td align="right" width="40"><a target="_blank" href="https://www.facebook.com/gosmtp/"><img src="'.GOSMTP_URL.'/images/facebook.png" /></a></td>';
				}				
			echo '</tr>
		</table>
	</h2>
	'.gosmtp_show_notices().'
	<hr/>
	<!--Main Table-->
	<table cellpadding="8" cellspacing="1" width="100%" class="fixed">
	<tr>
		<td valign="top">';

}

// The Gosmtp Settings footer
function gosmtp_page_footer($no_twitter = 0){
	
	echo '</td>';
	
	$promos = apply_filters('pagelayer_right_bar_promos', true);

	if($promos){

		echo '
	<td width="200" valign="top" id="pagelayer-right-bar">
		<div class="gosmtp-promotion" style="width:100%;" >
			<div class="gosmtp-promotion-content" style="background:white; border:1px solid #c3c4c7; padding:10px 10px 20px 10px; border-radius:6px;">
				<h2 class="gosmtp-promotion-logo">
					<span><a target="_blank" href="https://pagelayer.com/?from=gosmtp-plugin"><img src="'. GOSMTP_URL.'/images/pagelayer_product.png" width="100%"></a></span>
				</h2>
				<div>
					<em>The Best WordPress <b>Site Builder</b> </em>:<br>
					<ul style="font-size:13px;">
						<li>Drag &amp; Drop Editor</li>
						<li>Widgets</li>
						<li>In-line Editing</li>
						<li>Styling Options</li>
						<li>Animations</li>
						<li>Easily customizable</li>
						<li>Real Time Design</li>
						<li>And many more ...</li>
					</ul>
					<center><a class="button button-primary" target="_blank" href="https://pagelayer.com/?from=gosmtp-plugin">Visit Pagelayer</a></center>
				</div>
			</div>

			<div class="gosmtp-promotion-content" style="margin-top: 20px; background:white; border:1px solid #c3c4c7; padding:10px 10px 20px 10px; border-radius:6px;">
				<h2 class="gosmtp-promotion-logo">
					<span><a target="_blank" href="https://loginizer.com/?from=gosmtp-plugin"><img src="'.GOSMTP_URL.'/images/loginizer_product.png" width="100%"></a></span>
				</h2>
				<div>
					<em>Protect your WordPress website from <b>unauthorized access and malware</b> </em>:<br>
					<ul style="font-size:13px;">
						<li>BruteForce Protection</li>
						<li>reCaptcha</li>
						<li>Two Factor Authentication</li>
						<li>Black/Whitelist IP</li>
						<li>Detailed Logs</li>
						<li>Extended Lockouts</li>
						<li>2FA via Email</li>
						<li>And many more ...</li>
					</ul>
					<center><a class="button button-primary" target="_blank" href="https://loginizer.com/?from=gosmtp-plugin">Visit Loginizer</a></center>
				</div>
			</div>
		</div>';
		
	}
	
	echo '</tr>
	</table>
	<br />';
	if(!defined('SITEPAD')){       
		if(empty($no_twitter)){
			echo '
				<div style="width:45%;background:#FFF;padding:15px; margin:20px auto; border:1px solid #c3c4c7;">
					<b>Let your followers know that you use GOSMTP to Sent mail on your website :</b>
					<form method="get" action="https://twitter.com/intent/tweet" id="tweet" onsubmit="return dotweet(this);">
						<textarea name="text" cols="45" row="3" style="resize:none;">I increased email deliverability of my #WordPress #site using @gosmtp</textarea>&nbsp; &nbsp; 
						<input type="submit" value="Tweet!" class="button button-primary" onsubmit="return false;" id="twitter-btn" style="margin-top:20px;"/>
					</form>	
				</div>
				<br/>

				<script>
						function dotweet(ele){
						window.open(jQuery("#"+ele.id).attr("action")+"?"+jQuery("#"+ele.id).serialize(), "_blank", "scrollbars=no, menubar=no, height=400, width=500, resizable=yes, toolbar=no, status=no");
						return false;
					}
				</script>
				
				<a href="'.GOSMTP_WWW_URL.'" target="_blank">GOSMTP</a><span> v'.GOSMTP_VERSION.' You can report any bugs </span><a href="http://wordpress.org/support/plugin/gosmtp" target="_blank">here</a>.
			</div>';
		
		}
	}
}

// GoSMTP Setting page
function gosmtp_settings_page(){

	$action = gosmtp_optget('auth');
	$state = gosmtp_optget('state');
	$code = gosmtp_optget('code');
	
	// For authentication of Gmail, Zoho and Outlook
	if(!empty($action) && !empty($state) && !empty($code)){
	
		$resp = explode('-',$state);

		$uri = admin_url().'admin.php?page=gosmtp&auth_code='.$code.'&auth='.$action;

		if(!empty($resp[1])){
			$uri.='&type=edit&&conn_id='.$resp[1].'#gosmtp-connections-settings';
		}
	
		echo '<script>window.location.href="'.$uri.'";</script>';
		return;
	}
	
	if(defined('GOSMTP_PREMIUM')){
		include_once GOSMTP_PRO_DIR .'/main/settings.php';
	}
	
	$all_mailers = gosmtp_load_mailer_list();
	$options = get_option('gosmtp_options', array());
	
	//do_action('gosmtp_before_settings_page_load');
	
	// Save SMTP details
	if (isset($_REQUEST['save'])) {
		
		// Check nonce
		check_admin_referer('gosmtp-options');

		$force_from_email = !empty($_REQUEST['force_from_email']) ? 1 : '';
		$force_from_name = !empty($_REQUEST['force_from_name']) ? 1 : '';
		$return_path = !empty($_REQUEST['return_path']) ? 1 : '';

		$save_mailer = gosmtp_optreq('mailer');
		$option['mail_type'] = $save_mailer;
		
		if(isset($_REQUEST['nickname'])){
			$option['nickname'] = gosmtp_optreq('nickname');
		}

		if(isset($_REQUEST['backup_mailer'])){
			$option['backup_connection'] = gosmtp_optreq('backup_mailer');
		}
		
		if(!isset($options['mailer'])){
			$options['mailer'] = [];
		}
		
		$mailer_id = 0;
		$redirect = false;
	
		// Update fields of mailer
		if(!empty($save_mailer) && !method_exists($all_mailers[$save_mailer], 'save_option')){
			
			// Set for primary email
			if(!isset($options['mailer'][0]) || (isset($_REQUEST['conn_id']) && is_numeric($_REQUEST['conn_id']) && $_REQUEST['conn_id'] == 0)){
				$options['from_email'] = gosmtp_optreq('from_email');
				$options['force_from_email'] = $force_from_email;
				$options['from_name'] = gosmtp_optreq('from_name');
				$options['force_from_name'] = $force_from_name;
				$options['return_path'] = $return_path;	
				$options['mailer'][0] = $all_mailers[$save_mailer]->save_options($option);
			}else{
			
				if(!empty($_REQUEST['conn_id'])){
					$mailer_id = $_REQUEST['conn_id'];
				}else{
					$redirect = true;
					$mailer_id = gosmtp_RandomId();
				}
				
				$option['from_email'] = gosmtp_optreq('from_email');
				$option['force_from_email'] = $force_from_email;
				$option['from_name'] = gosmtp_optreq('from_name');
				$option['force_from_name'] = $force_from_name;
				$option['return_path'] = $return_path;
				$options['mailer'][$mailer_id] = $all_mailers[$save_mailer]->save_options($option);
			}
		}

		$options = apply_filters( 'gosmtp_save_options', $options );
		
		if(update_option( 'gosmtp_options', $options )){
			$msg['success'] = 1;
			
			if($redirect){
				$uri = admin_url().'admin.php?page=gosmtp&type=edit&conn_id='.$mailer_id.'#gosmtp-connections-settings';
				echo '<script>window.location.href="'.$uri.'";</script>';
			}
		}
	}

	if(!empty($_REQUEST['delete_connection'])){
	
		// Check nonce
		check_admin_referer('gosmtp-options');

		$options = get_option('gosmtp_options', array());
		$conn_id = gosmtp_optreq('delete_connection');
		
		if(!empty($conn_id)){
			$backup_id = isset($options['mailer'][0]['backup_connection']) ? $options['mailer'][0]['backup_connection'] : '';

			if($backup_id == $conn_id){
				unset($options['mailer'][0]['backup_connection']);
			}

			// Remove connection
			unset($options['mailer'][$conn_id]);

			if(update_option( 'gosmtp_options', $options )){
				$msg['success'] = 1;
			}
		}
	}

	if(!empty($_REQUEST['make_backup_connection'])){
	
		// Check nonce
		check_admin_referer('gosmtp-options');

		$options = get_option('gosmtp_options', array());
		$conn_id = gosmtp_optreq('make_backup_connection');

		$options['mailer'][0]['backup_connection'] = $conn_id;

		if(update_option( 'gosmtp_options', $options )){
			$msg['success'] = 1;
		}
	}

	if(!empty($_REQUEST['clear_backup_connection'])){
	
		// Check nonce
		check_admin_referer('gosmtp-options');

		$options = get_option('gosmtp_options', array());
		$conn_id = gosmtp_optreq('clear_backup_connection');

		if(isset($options['mailer'][0]) && $options['mailer'][0]['backup_connection'] == $conn_id){
			unset($options['mailer'][0]['backup_connection']);
		}

		if(update_option( 'gosmtp_options', $options )){
			$msg['success'] = 1;
		}
	}

	// Save Notification Settings
	if(defined('GOSMTP_PRO_VERSION') && isset($_REQUEST['save_notification_settings'])){
		do_action('gosmtp_pro_save_notification_settings');
	}

	// SMTP Settings
	if(isset($_REQUEST['save_settings'])){

		// Check nonce
		check_admin_referer('gosmtp-settings');

		$enable_logs = '';
		if(!empty($_REQUEST['enable_logs'])){
			
			$enable_logs = 1;
			
			if(class_exists('\GOSMTP\Logger')){
				$logger = new \GOSMTP\Logger();
				$logger->create_table();
			}
			
		}
		
		$save_attach = '';
		if(!empty($_REQUEST['log_attachments'])){
			$save_attach = 1;
		}
		
		$ret_period = '';
		if(!empty($_REQUEST['retention_period'])){
			$ret_period = sanitize_text_field($_REQUEST['retention_period']);
			
			// Cron already scheduled?
			if( ! empty($_REQUEST['enable_logs']) && ! wp_next_scheduled( 'gosmtp_log_retention_cron' ) ){
				// Set cron schedule
				wp_schedule_event( time(), 'daily', 'gosmtp_log_retention_cron' );
			}
		}
		
		// Is log retention cron scheduled?
		if(wp_next_scheduled( 'gosmtp_log_retention_cron' ) && (empty($_REQUEST['enable_logs']) || empty($_REQUEST['retention_period']))){
			wp_clear_scheduled_hook('gosmtp_log_retention_cron');
		}
		
		$log_columns = '';
		if(!empty($_REQUEST['log_columns'])){
			$log_columns = maybe_serialize(($_REQUEST['log_columns']));
		}
		
		$enable_weekly_reports = '';
		if(!empty($_REQUEST['enable_weekly_reports'])){
			$enable_weekly_reports = 1;
			
			// Cron already scheduled?
			if(!wp_next_scheduled( 'gosmtp_weekly_email_reports_cron', array(true) ) ){
				// Set cron schedule
				wp_schedule_event( time(), 'daily', 'gosmtp_weekly_email_reports_cron', array(true));
			}
			
		// Is log weekly email cron scheduled?
		}elseif( wp_next_scheduled( 'gosmtp_weekly_email_reports_cron' , array(true) ) ){
			wp_clear_scheduled_hook('gosmtp_weekly_email_reports_cron', array(true));
		}

		$weekday = '';
		$timestamp = '';
		
		if(!empty($_REQUEST['weekday']) && $enable_weekly_reports){
			$weekday = $_REQUEST['weekday'];
			$timestamp = strtotime("next ".$weekday);
		}	
				
		$options['logs'] = [];
		$options['logs']['enable_logs'] = $enable_logs;
		$options['logs']['log_attachments'] = $save_attach;
		$options['logs']['retention_period'] = $ret_period;
		$options['logs']['log_columns'] = $log_columns;
		$options['weekly_reports'] = [];
		$options['weekly_reports']['enable_weekly_reports'] = $enable_weekly_reports;
		$options['weekly_reports']['weekday'] = $weekday;
		$options['weekly_reports']['timestamp'] = $timestamp;
		
		$options = apply_filters( 'gosmtp_save_logs_settings', $options );
		
		if(update_option( 'gosmtp_options', $options )){
			$msg['success'] = 1;
		}
		
	}
	
	$smtp_options = get_option('gosmtp_options', array());
	
	// Default mailer set mail
	if(!isset($smtp_options['mailer']) || !is_array($smtp_options['mailer']) || empty($smtp_options['mailer'][0])){
		$smtp_options['mailer'] = [];
		$smtp_options['mailer'][0]['mail_type'] = 'mail';
	} 
	
	// Used to show error / success message for the settings
	settings_errors();

	echo '<div class="wrap">';
	
	gosmtp_page_header();
	
	if(!empty($msg['success'])){
		echo '<div id="message" class="updated notice is-dismissible"><p>'.__('SMTP settings have been saved successfully!', 'gosmtp').'</p></div>';
	}

	if(!empty($send_mail['success'])){
		echo '<div id="message" class="updated notice is-dismissible"><p>'.__('Mail sent successfully!', 'gosmtp').'</p></div>';
	}else if(!empty($send_mail['error'])){
		echo '<div id="message" class="error notice is-dismissible">
		<p>'.( !empty($send_mail['error_msg']) ? wp_kses_post($send_mail['error_msg']) : __('Unable to send mail, Please check your SMTP details', 'gosmtp') ).'</p></div>';
	}
	
	$tabs_nav = array(
		'smtpsetting' => __('SMTP Settings', 'gosmtp'), 
		'test-mail' => __('Test Mail', 'gosmtp')	
	);

	if(!defined('SITEPAD')){
		$tabs_nav['support'] = __('Support', 'gosmtp');
	}
	
	$tabs_nav = apply_filters('gosmtp_settings_tabs_nav', $tabs_nav);
	?>
	<div class="gosmtp-setting-content">
		<div class="tabs-wrapper">
			<h2 class="nav-tab-wrapper gosmtp-wrapper">
				<?php
					foreach($tabs_nav as $id => $title){
						$classes = 'nav-tab';
						
						if($id == 'smtpsetting'){
							$classes .= ' nav-tab-active';
						}
						
						echo '<a href="#'. esc_attr($id) .'" class="'.esc_attr($classes).'">'.esc_html($title).'</a>';
					}
				?>
			</h2>
			<div class="gosmtp-tab-panel" id="smtpsetting">
				<form class="gosmtp-smtp-mail" name="smtp-details" method="post" action="">
					<?php  
						gosmtp_mailer_settings($smtp_options);
					?>
				</form>	
			</div>
			<div class="gosmtp-tab-panel" id="test-mail" style="display:none">
				<form class="gosmtp-smtp-mail" id="smtp-test-mail" name="test-mail" method="post" action="">
					<table class="form-table">
						<tr>
							<th scope="row"><?php _e('To', 'gosmtp'); ?>:</th>
							<td>
								<input type="email" name="reciever_test_email" class="regular-text" placeholder="example@example.com" required />
								<p class="description" id="tagline-description"><?php _e( 'Enter the recipient\'s email address.', 'gosmtp' ); ?></p>
							</td>
						</tr>
						<tr>
							<th scope="row"><?php _e('Subject', 'gosmtp'); ?>:</th>
							<td>
								<input type="text" name="smtp_test_subject" class="regular-text" placeholder="Enter Subject" value="Test Mail" required />
								<p class="description" id="tagline-description"><?php _e( 'Enter a subject for your message.', 'gosmtp' ); ?></p>
							</td>
						</tr>
						<tr class="gosmtp-test-message">
							<th scope="row"><?php _e('Message', 'gosmtp'); ?></th>
							<td>
								<textarea name="smtp_test_message" placeholder="Enter Message" class="regular-text" rows="10"required ><?php _e('This is a test mail!', 'gosmtp'); ?></textarea>
								<p class="description" id="tagline-description"><?php _e( 'Write your email message', 'gosmtp' ); ?> </p>
							</td>
						</tr>
						<?php
						do_action('gosmtp_pro_test_connection_and_template');
						?>
					</table>
					<p>
						<input type="submit" name="send_mail" id="send_mail" class="button button-primary" value="Send Mail">
					</p>
				</form>
			</div>
			<div class="gosmtp-tab-panel" id="support" style="display:none">
				<div style="width:70%; margin:20px auto; display:flex; justify-content:center; flex-direction:column; align-items:center; line-height:1.5;">
					<img src="<?php echo esc_url(GOSMTP_URL) .'/images/gosmtp-text.png'?>" width="200"/>
					<h2><?php esc_html_e('You can contact the GoSMTP Team via email. Our email address is', 'gosmtp'); ?> <a href="mailto:support@gosmtp.net">support@gosmtp.net</a> <?php esc_html_e('or through Our Premium Support Ticket System at', 'gosmtp'); ?> <a href="https://softaculous.deskuss.com" target="_blank"><?php _e('here', 'gosmtp'); ?></a></h2>
				</div>
			</div>
			
			<?php do_action('gosmtp_after_settings_tab_panel')?>
		</div>
	</div>
	<?php gosmtp_page_footer(); ?>
</div>

<script>
	// TODO: move this in init.php
	var gosmtp_ajaxurl = "<?php echo admin_url( 'admin-ajax.php' ) ?>?";
	var gosmtp_ajax_nonce = "<?php echo wp_create_nonce('gosmtp_ajax') ?>";
</script>

<?php

}

function gosmtp_mailer_settings($smtp_options, $is_new_connection = false){
	$all_mailers = gosmtp_load_mailer_list();

	// For default mailer
	$settings = !empty($smtp_options['mailer'][0]) ? $smtp_options['mailer'][0] : array();
	$settings['from_email'] = isset($smtp_options['from_email']) ? $smtp_options['from_email'] : '';
	$settings['force_from_email'] = isset($smtp_options['from_email']) ? $smtp_options['force_from_email'] : '';
	$settings['from_name'] = isset($smtp_options['from_name']) ? $smtp_options['from_name'] : '';
	$settings['force_from_name'] = isset($smtp_options['force_from_name']) ? $smtp_options['force_from_name'] : '';
	$settings['return_path'] = isset($smtp_options['return_path']) ? $smtp_options['return_path'] : '';
	$brand_name = !defined('SITEPAD') ? __('WordPress', 'gosmtp') : BRAND_SM;
	
	// Is new connection?
	if($is_new_connection){
	 	if(empty($smtp_options)){
	 		$smtp_options = [];
	 		$smtp_options['mail_type'] = 'mail';
	 	}

	 	// For backup mailer
		$settings = $smtp_options;
	}

	wp_nonce_field('gosmtp-options'); 
?>
	<table class="form-table">
		<?php
		if($is_new_connection){
		?>
		<tr>
			<th scope="row"><?php _e('Connection Nickname', 'gosmtp'); ?></th>
			<td>
				<input name="nickname" type="text" class="regular-text always_active" placeholder="Default Connection"  value="<?php if(!empty($settings['nickname'])){
					echo esc_attr($settings['nickname']);
				}?>"> 
			</td>
		</tr>
		<?php
		}
		?>
		<tr>
			<th scope="row"><?php _e('From Email', 'gosmtp'); ?></th>
			<td>
				<input name="from_email" type="text" class="regular-text always_active" placeholder="notifications@example.com"  value="<?php if(!empty($settings['from_email'])){
					echo esc_attr($settings['from_email']);
				}?>"> 
				<p class="description" id="tagline-description">
				<?php
					printf(
						__('Set the from email address for your %s emails. If you\'re using an email provider (Gmail, Outlook.com, etc.), this should be your email address for that account', 'gosmtp'),
						esc_html($brand_name)
					);
				?>
				</p>
				<p class="description" id="tagline-description"><i><?php _e("Please note, enable the below setting to apply this setting.", 'gosmtp'); ?></i></p>
				<br>
				<input name="force_from_email" type="checkbox" <?php if(!empty($settings['force_from_email'])){
					echo "checked";
				}?>>
				<label><?php _e('Force From Email', 'gosmtp');?></label>
				<p class="description" id="tagline-description"><?php _e( 'If checked, From email set by other plugins will be ignored and the above Form Email setting will be used.', 'gosmtp'); ?></p>
			
			</td>
		</tr>

		<tr>
			<th scope="row"><?php _e('From Name', 'gosmtp'); ?></th>
			<td>
				<input name="from_name" type="text" class="regular-text always_active" placeholder="My Website"  value="<?php if(!empty($settings['from_name'])){
					echo esc_attr($settings['from_name']);
				}?>"> 
				<p class="description" id="tagline-description"><?php _e( "Set the from name that emails are sent from.", 'gosmtp' ); ?></p>
				<br>
				<input name="force_from_name" type="checkbox" <?php if(!empty($settings['force_from_name'])){
					echo "checked";
				}?>>
				<label><?php _e('Force From Name', 'gosmtp');?></label>
				<p class="description" id="tagline-description"><?php _e( 'If checked, From name set by other plugins will be ignored and the above Form Name setting will be used.', 'gosmtp' ); ?></p>
			
			</td>
		</tr>

		<tr>
			<th scope="row"><?php _e('Return Path', 'gosmtp'); ?></th>
			<td>
				<input class="mail sendlayer mailgun smtp" name="return_path" type="checkbox" <?php if(!empty($settings['return_path'])){
					echo "checked";
				}?>>
				<label><?php _e('Set return-path', 'gosmtp');?></label>
				<p class="description" id="tagline-description"><?php _e( 'Set return-path to match the From Email, the return path indicates where non-delivery receipts or bounce messages are to be sent. If unchecked, non-delivery messages may be lost.', 'gosmtp' ); ?></p>
			</td>
		</tr>

		<tr>
			<th scope="row"><?php _e('Mailer', 'gosmtp'); ?></th>
			<td class="mailer_container">

			<?php
			$mailer_list = gosmtp_get_mailer_list();
			
			foreach($mailer_list as $key => $mailer){
				$is_pro = $disabled = $after_icon = '';
				$active_mailer = (isset($settings['mail_type']) && $settings['mail_type'] == $key) ? 'mail_active' : '';
				$icon = isset($mailer['icon']) ? $mailer['icon'] : GOSMTP_URL .'/images/'.$key.'.svg';

				if(!class_exists($mailer['class'])){
					$is_pro = 'pro';
					$disabled = 'disabled';
					$after_icon='<div class="lock_icon">
						<span class="dashicons dashicons-lock"></span>
					</div>';
				}
				
				echo '<div class="gosmtp-mailer-input always_active '.esc_attr($is_pro).'">
					<label class="label">'. esc_html($mailer['title']) .'</label>
					<div for="'.esc_attr($key).'" class="mailer_label '.esc_attr($active_mailer).'" data-name="'.esc_attr($key).'">
						<img src="'. esc_attr($icon) .'" class="mailer" >
						'.wp_kses_post($after_icon).'
					</div>
					<input id="'.esc_attr($key).'" class="mailer_check" data-name="'.esc_attr($key).'" name="mailer" type="radio" '.esc_attr($disabled).' value="'. esc_attr($key) .'" '. checked( $key, (isset($settings['mail_type'])  ? $settings['mail_type'] : ''),false ).'>
				</div>';
			}
			?>
			</td>
		</tr>
		<?php
		
			foreach($all_mailers as $key => $mailer){
				
				if(!method_exists($mailer, 'load_field')){
					continue;
				}

				echo '<tr>
					<td><h1 class="'.esc_attr($key).' smtp_heading">'. esc_html($mailer->title) .'</h1><td>
				</tr>';
				
				// Load current options
				$mailer->loadOptions();
				
				$conn_id = $is_new_connection ? '' : 0;

				if($is_new_connection){
					$conn_id = gosmtp_optget('conn_id');
				}

				// Set connection id
				$mailer->conn_id = $conn_id;

				echo gosmtp_create_field($mailer->load_field(), $mailer);
			}
		?>
		<?php 
		if(defined('GOSMTP_PREMIUM') && isset($smtp_options['mailer'][0])){
		?>
		<tr class="always_active">
			<th scope="row"><?php _e('Backup Connection', 'gosmtp'); ?></th>
			<td>
				<select name="backup_mailer" class="regular-text">
					<option value=""><?php _e('None', 'gosmtp'); ?></option>
			<?php
			if(count($smtp_options['mailer']) > 1){
			?>
				
				<?php foreach($smtp_options['mailer'] as $key => $mailer){
					if($key === 0){
						continue;
					}
					$con_id = !empty($settings['backup_connection']) ? $settings['backup_connection'] : '';
					$conn_name = !empty($mailer['nickname']) ? $mailer['nickname'] : __('(No Name)', 'gosmtp');
					$conn_type = !empty($mailer['mail_type']) ? ucfirst($mailer['mail_type']) : '';
					echo "<option value='".esc_attr($key)."' ".selected($con_id, $key, true).">".esc_html($conn_name).' - ['.esc_html($conn_type)."]</option>";
				}
			}?>
				</select>
				<p class="description" id="tagline-description"><?php 
					printf(
						'Set backup email address for your %s emails. If primary mailer fails then backup mailer will be used to send the mail.',
						esc_html($brand_name)
					);
				?>
				</p>
			</td>
		</tr>
		<?php
		}
		?>
	</table>
	<p>
		<?php
			if(!empty($smtp_options['mailer'][0]) || !empty($settings['conn_id'])){
		?>
			<input type="hidden" name="conn_id" value="<?php echo esc_attr($is_new_connection && !empty($settings['conn_id']) ? $settings['conn_id'] : 0); ?>">
		<?php
			}
		?>
		<input type="submit" name="save" class="button button-primary" value="Save Changes">
	</p>
<?php
}

function gosmtp_create_field($fields, $mailer){
	$html = '';
	
	if(!is_array($fields)){
		return $html;
	}
	
	foreach($fields as $key => $field){
		
		$attrs = '';
		
		if(!empty($field['attr'])){
			$attrs .= esc_attr($field['attr']);
		}
		
		// Added attributes
		if(!in_array($field['type'], array('button', 'notice'))){
			
			$_type = ($field['type'] == 'copy') ? 'text' : $field['type'];
			
			$attrs .= ' type="'.esc_attr($_type).'"';
			$attrs .= ' name="'.esc_attr($mailer->mailer.'['.$key.']').'"';
		}
		
		// Added Classes
		$classes = esc_attr($mailer->mailer);
		
		if(!empty($field['class'])){
			$classes .= ' '.esc_attr($field['class']);
		}
		
		// Get value
		$val = $mailer->getOption($key, $mailer->mailer);
		
		if(empty($val)){
			$val = isset($field['default']) ? $field['default'] : '';
		}
		
		$placeholder = empty($field['place_holder']) ? '' : esc_attr($field['place_holder']);
		$list = empty($field['list']) ? array() : $field['list'];
		
		$input_html = '';
		
		switch($field['type']){
			case 'radio':
			
				foreach($list as $list_key => $list_value){
					$input_html .= '<input class="'.$classes.'" value="'.esc_attr($list_key).'" '.$attrs.''.checked($list_key, $val, false).'>
					<label>'.esc_html($list_value).'</label>';
				}
				
				break;

			case 'checkbox':
				
				$input_html .= '<input value="1" class="regular-text '.$classes.'" '.$attrs.' '.checked('1', $val, false).'>';
				
				break;

			case 'button':
			
				$href = empty($field['href']) ? '#' : esc_url($field['href']);
				
				$input_html .= '<a href="'.$href.'"class="button '.$classes.'" '.$attrs.'>'.esc_html($val).'</a>';
				
				break;
				
			case 'notice':

				$input_html .= '<div id="message" class="notice_container '.$classes.'">'.esc_html($val).'</div>';
				
				break;

			case 'select':

				$input_html .='<select class="regular-text '.$classes.'" '.$attrs.'>';
				
				foreach($list as $list_key => $list_value){
					$input_html .= '<option value="'.esc_attr($list_key).'" '.selected($list_key, $val, false).'>'.esc_html($list_value).'</option>';
				}
				
				$input_html .='</select>';
				
				break;
			
			 case 'copy':
			 
				$id = empty($field['id']) ? '' : esc_attr($field['id']);
				
				$input_html .= '<input class="regular-text gosmtp_copy '.$classes.'" placeholder="'.$placeholder.'" id="'.$id.'" value="'.esc_attr($val).'" '.$attrs.'>
				<span class="dashicons dashicons-admin-page " title="Copy" onclick="gosmtp_copy_url(\''.$id.'\')"></span>
				<p class="gosmtp_copy_message '.$id.'">'. __('Message coppied Successfully', 'gosmtp') .'.</p>';
				
				break;


			default:
			
				$input_html .= '<input class="regular-text '.$classes.'" placeholder="'.$placeholder.'" value="'.esc_attr($val).'" '.$attrs.'>';
				break;
		}
		
		$description = empty($field['desc']) ? '' : wp_kses_post($field['desc']);
		
		$html .= '<tr class='.(empty($field['tr_class']) ? '' : esc_attr($field['tr_class'])).'>
			<th scope="row">'.esc_html($field['title']).'</th>
			<td>
				'.$input_html.'
				<p class="description" id="tagline-description">'.wp_kses_post($description).'</p>
			</td>
		</tr>';
	}
	
	return $html;
}PKv�f\�\j�	�	ajax.phpnu�[���<?php
/*
* GoSMTP
* https://gosmtp.net
* (c) Softaculous Team
*/

if(!defined('GOSMTP_VERSION')){
	die('Hacking Attempt!');
}

add_action('wp_ajax_gosmtp_test_mail', 'gosmtp_test_mail');
function gosmtp_test_mail(){
	
	global $phpmailer;

	if(!current_user_can('manage_options')){
		wp_send_json_error(__('You do not have required access to do this action', 'gosmtp'));
	}

	// Check nonce
	check_admin_referer( 'gosmtp_ajax' , 'gosmtp_nonce' );

	$to = gosmtp_optpost('reciever_test_email');
	$subject = gosmtp_optpost('smtp_test_subject');
	$body = gosmtp_optpost('smtp_test_message');
	$use_template = gosmtp_optpost('use_html_template');
	
	// TODO: send debug param
	if(isset($_GET['debug'])){
		// show wp_mail() errors
		add_action( 'wp_mail_failed', function( $wp_error ){
			echo "<pre>";
			print_r($wp_error);
			echo "</pre>";
		}, 10, 1 );
	}
	
	$msg = array();
	$headers = [];
	
	// TODO check for mailer
	if(!get_option('gosmtp_options')){
		$msg['error'] = __('You have not configured SMTP settings yet !', 'gosmtp');
	}else{
		
		if(!empty($use_template) && function_exists('gosmtp_pro_test_html_template')){
			$body = gosmtp_pro_test_html_template();
			$headers = ['Content-Type: text/html; charset=UTF-8'];
		}

		$result = wp_mail($to, $subject, $body, $headers);

		if(!$result){
			$msg['error'] = __('Unable to send mail !', 'gosmtp').(empty($phpmailer->ErrorInfo) ? '' : ' '.__('Error : ', 'gosmtp').$phpmailer->ErrorInfo);
		}else{
			$msg['response'] = __('Message sent successfully !', 'gosmtp');
		}
	}
	
	gosmtp_json_output($msg);
}

function gosmtp_close_update_notice(){

	if(!wp_verify_nonce($_GET['security'], 'gosmtp_promo_nonce')){
		wp_send_json_error('Security Check failed!');
	}

	if(!current_user_can('manage_options')){
		wp_send_json_error('You don\'t have privilege to close this notice!');
	}

	$plugin_update_notice = get_option('softaculous_plugin_update_notice', []);
	$available_update_list = get_site_transient('update_plugins');
	$to_update_plugins = apply_filters('softaculous_plugin_update_notice', []);

	if(empty($available_update_list) || empty($available_update_list->response)){
		return;
	}

	foreach($to_update_plugins as $plugin_path => $plugin_name){
		if(isset($available_update_list->response[$plugin_path])){
			$plugin_update_notice[$plugin_path] = $available_update_list->response[$plugin_path]->new_version;
		}
	}

	update_option('softaculous_plugin_update_notice', $plugin_update_notice);
}
add_action('wp_ajax_gosmtp_close_update_notice', 'gosmtp_close_update_notice');

PKv�f\�>J^�#�#util.phpnu�[���<?php

namespace SpeedyCache;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class Util{
	static function sanitize_get($name, $default = ''){
		if(empty($_GET[$name])){
			return $default;
		}
		
		if(is_array($_GET[$name]) || is_object($_GET[$name])){
			return map_deep(wp_unslash($_GET[$name]), 'sanitize_text_field');
		}

		return sanitize_text_field(wp_unslash($_GET[$name]));
	}

	static function sanitize_post($name, $default = ''){
		if(empty($_POST[$name])){
			return $default;
		}
		
		if(is_array($_POST[$name]) || is_object($_POST[$name])){
			return map_deep(wp_unslash($_POST[$name]), 'sanitize_text_field');
		}

		return sanitize_text_field(wp_unslash($_POST[$name]));
	}

	static function sanitize_request($name, $default = ''){
		if(empty($_REQUEST[$name])){
			return $default;
		}
		
		if(is_array($_REQUEST[$name]) || is_object($_REQUEST[$name])){
			return map_deep(wp_unslash($_REQUEST[$name]), 'sanitize_text_field');
		}

		return sanitize_text_field(wp_unslash($_REQUEST[$name]));
	}
	
	static function sanitize_server($name, $default = ''){
		if(empty($_SERVER[$name])){
			return $default;
		}

		return sanitize_text_field(wp_unslash($_SERVER[$name]));
	}
	
	static function pagespeed_color($score){

		// The structure of this array is 0 => [Stroke Color, Background Color, Text Color]
		$score_color_map = array(
			0 => ['#c00', '#c003', '#c00'], // Red
			50 => ['#fa3', '#ffa50036', '#fa3'],// Orange
			90 => ['#0c6', '#00cc663b', '#080']// Green
		);

		if($score >= 0 && $score < 50){
			return $score_color_map[0];
		}

		if($score >= 50  && $score < 90){
			return $score_color_map[50];
		}

		return $score_color_map[90];
	}
	
	static function url_to_path($url){
		$url = preg_replace('/\?.*/', '', $url); // Removing any query string
		$dir_slug = str_replace(site_url(), '', $url);
		if(defined('SITEPAD')){
			global $sitepad;
			$file_path = $sitepad['path'] . '/' .trim($dir_slug, '/');
		} else {
			$file_path = ABSPATH . trim($dir_slug, '/');
		}
		return wp_normalize_path($file_path);
	}
	
	static function path_to_url($path){
		$path = wp_normalize_path($path);
		if(defined('SITEPAD')){
			global $sitepad;
			$abs_path = wp_normalize_path($sitepad['path']);
		} else {
			$abs_path = wp_normalize_path(ABSPATH);
		}
		$path = str_replace($abs_path, '', $path);
		$url = site_url() . '/' . $path;

		return $url;
	}
	
	static function cache_path($loc = ''){

		if((defined('WP_CLI') && WP_CLI) || empty($_SERVER['HTTP_HOST'])){
			global $blog_id;

			$url = get_option('home');
	
			if(!empty($blog_id) && is_multisite()){
				switch_to_blog($blog_id);
				$url = get_option('home');
				restore_current_blog();
			}

			$url = wp_parse_url($url);			
			$host = $url['host'];

			return trailingslashit(SPEEDYCACHE_CACHE_DIR . '/'.$host.'/'.$loc);
		}
		
		$host = sanitize_text_field(wp_unslash($_SERVER['HTTP_HOST']));
		return trailingslashit(SPEEDYCACHE_CACHE_DIR . '/'.$host.'/'.$loc);
	}
	
	// Creates a config file based on the URL of the website
	static function set_config_file(){
		global $speedycache;
		
		$export_config['settings']['status'] = !empty($speedycache->options['status']);
		$export_config['settings']['gzip'] = !empty($speedycache->options['gzip']);
		$export_config['settings']['logged_in_user'] = !empty($speedycache->options['logged_in_user']);
		$export_config['settings']['mobile_theme'] = !empty($speedycache->options['mobile_theme']);
		$export_config['settings']['mobile'] = !empty($speedycache->options['mobile']);
		//$export_config['user_agents'] = speedycache_get_excluded_useragent();
		$export_config['excludes'] = get_option('speedycache_exclude', []);

		$config = var_export($export_config, true);

		$url = get_site_url();
		$file = parse_url(untrailingslashit($url));
		$file['path'] = (!empty($file['path'])) ? str_replace( '/', '.', untrailingslashit($file['path'])) : '';
		$config_file_path = WP_CONTENT_DIR .'/speedycache-config/'. strtolower($file['host']) . $file['path'] . '.php';
		
		if(!file_exists(WP_CONTENT_DIR .'/speedycache-config/')){
			if(mkdir(WP_CONTENT_DIR .'/speedycache-config/', 0755, true)){
				touch(WP_CONTENT_DIR .'/speedycache-config/index.html');
				file_put_contents(WP_CONTENT_DIR .'/speedycache-config/.htaccess', 'deny from all');
			}
		}

		$config_temp = file_get_contents(SPEEDYCACHE_DIR . '/assets/config-template.php');
		$config_content = str_replace("'REPLACE_CONFIG'", $config, $config_temp);
		file_put_contents($config_file_path, $config_content);
	}
	
	static function dir_size($dir){
		$size = 0;

		foreach(glob(rtrim($dir, '/').'/*', GLOB_NOSORT) as $file){
			$size += is_file($file) ? filesize($file) : self::dir_size($file);
		}

		return $size;
	}
	
	static function cache_lifespan(){
		global $speedycache;

		$schedule_time = 0;

		if(empty($speedycache->options['purge_interval'])){
			return $schedule_time;
		}

		if(!empty($speedycache->options['purge_enable_exact_time']) && !empty($speedycache->options['purge_exact_time'])){
			$schedule_time = DAY_IN_SECONDS;
		} elseif($speedycache->options['purge_interval_unit'] == 'hours'){
			$schedule_time = HOUR_IN_SECONDS * $speedycache->options['purge_interval'];
		} elseif($speedycache->options['purge_interval_unit'] == 'days'){
			$schedule_time = DAY_IN_SECONDS * $speedycache->options['purge_interval'];
		}

		return (int) $schedule_time;
	}
	
	static function lifespan_cron(){
		global $speedycache;
		
		if(empty($speedycache->options['purge_interval'])){
			return;
		}
		
		if(!empty(wp_next_scheduled('speedycache_purge_cache'))){
			return;
		}

		if(!empty($speedycache->options['purge_enable_exact_time']) && !empty($speedycache->options['purge_exact_time'])){
			// Getting the exact time of the user's timezone by using the offset and strtotime return gtm time.
			$future_timestamp = strtotime('today '.$speedycache->options['purge_exact_time']);
			$offset = get_option('gmt_offset') * HOUR_IN_SECONDS;
			$current_time = time() - $offset;
			$future_timestamp -= $offset;

			if(time() > $future_timestamp){
				$future_timestamp = strtotime('tomorrow '.$speedycache->options['purge_exact_time']);
				$future_timestamp -= $offset;
			}

			$schedule_time = $future_timestamp - time();
			
		} elseif($speedycache->options['purge_interval_unit'] == 'hours'){
			$schedule_time = HOUR_IN_SECONDS * $speedycache->options['purge_interval'];
		} elseif($speedycache->options['purge_interval_unit'] == 'days'){
			$schedule_time = DAY_IN_SECONDS * $speedycache->options['purge_interval'];
		}

		wp_schedule_event(time() + $schedule_time, 'speedycache_expired_cache_schedule', 'speedycache_purge_cache');

	}
	
	static function preload_cron(){
		global $speedycache;
		
		if(empty($speedycache->options['preload_interval']) || empty($speedycache->options['preload'])){
			return;
		}
		
		if(wp_next_scheduled('speedycache_preload')){
			return;
		}

		$schedule_time = HOUR_IN_SECONDS * (int) $speedycache->options['preload_interval'];

		wp_schedule_event(time() + $schedule_time, 'speedycache_preload_cache_schedule', 'speedycache_preload');

	}
	
	static function custom_expiry_cron($schedules){
		
		$cache_interval = self::cache_lifespan();
		if(empty($cache_interval)){
			return $schedules;
		}

		$schedules['speedycache_expired_cache_schedule'] = [
			'interval' => $cache_interval,
			'display' => __('SpeedyCache Cache Lifespan cron', 'speedycache'),
		];

		return $schedules;
	}
	
	static function custom_preload_cron($schedules){
		global $speedycache;

		if(empty($speedycache->options['preload_interval'])){
			return $schedules;
		}
		
		$cache_interval = $speedycache->options['preload_interval'] * HOUR_IN_SECONDS;
		if(empty($cache_interval)){
			return $schedules;
		}

		$schedules['speedycache_preload_cache_schedule'] = [
			'interval' => $cache_interval,
			'display' => __('SpeedyCache Cache Preload cron', 'speedycache'),
		];

		return $schedules;
	}
	
	static function custom_cron($schedules){

		// Every 14 days (Fortnight)
		$schedules['speedycache_fortnight'] = [
			'interval' => 14 * DAY_IN_SECONDS,
			'display' => __('Once Every Fortnight', 'speedycache'),
		];

		// Monthly (approx 30 days)
		$schedules['speedycache_monthly'] = [
			'interval' => 30 * DAY_IN_SECONDS,
			'display' => __('Once Monthly', 'speedycache'),
		];
		
		return $schedules;
	}
	
	// Deletes binaries
	static function delete_cwebp(){
		
		$binary_dir = wp_upload_dir()['basedir'] .'/speedycache-binary';
		
		if(!file_exists($binary_dir)){
			return;
		}

		$binaries = @scandir($binary_dir);
		$binaries = array_diff($binaries, ['.', '..']);
		
		if(empty($binaries)){
			@rmdir($binary_dir);
			return;
		}
		
		foreach($binaries as $binary){
			if(file_exists($binary_dir.'/'.$binary)){
				@unlink($binary_dir.'/'.$binary);
			}
		}
	}
}
PKv�f\Т k�<�<	cache.phpnu�[���<?php

namespace SpeedyCache;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

use \SpeedyCache\Util;

class Cache {
	static $cache_file_path = '';
	static $ignored_parameters = ['fbclid', 'utm_id', 'utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'utm_source_platform', 'gclid', 'dclid', 'msclkid', 'ref', 'fbaction_ids', 'fbc', 'fbp', 'clid', 'mc_cid', 'mc_eid', 'hsCtaTracking', 'hsa_cam', 'hsa_grp', 'hsa_mt', 'hsa_src', 'hsa_ad', 'hsa_acc', 'hsa_net', 'hsa_kw'];
	
	static $content = '';

	static function init(){
		global $speedycache;

		if(!defined('SPEEDYCACHE_SERVER_HOST')){
			define('SPEEDYCACHE_SERVER_HOST', Util::sanitize_server('HTTP_HOST'));
		}

		if(!defined('SITEPAD')){
			if(!empty($speedycache->options['dns_prefetch']) && !empty($speedycache->options['dns_urls'])){
				add_filter('wp_resource_hints', '\SpeedyCache\Cache::dns_prefetch_hint', 10, 2);
			}
		}
		
		// Filter for Gravatar cache. We are updating the URL of the gravatar here so the local hosted Gravatar URL will be cached.
		if(!empty($speedycache->options['gravatar_cache'])){
			add_filter('get_avatar_data', '\SpeedyCache\Gravatar::get_avatar_data', 10, 2);
		}

		// Loads Instant Page to improve load page speed by 1%
		if(defined('SPEEDYCACHE_PRO') && !empty($speedycache->options['instant_page'])){
			add_action('wp_enqueue_scripts', '\SpeedyCache\Cache::instant_page');
		}

		if(!empty($speedycache->options['disable_emojis'])){
			add_action('init', '\SpeedyCache\Cache::disable_emojis');
		}
		
		// Optimizes images when a page gets loaded and it finds no image optimized
		if(class_exists('\SpeedyCache\Image') && !empty($speedycache->image['settings']['automatic_optm'])){
			add_filter('the_content', '\SpeedyCache\Image::optimize_on_fly');
		}
		
		// Adds preconnect
		if(class_exists('\SpeedyCache\Enhanced')){
			if(!defined('SITEPAD')){
				if(!empty($speedycache->options['pre_connect']) && !empty($speedycache->options['pre_connect_list'])){
					add_filter('wp_resource_hints', '\SpeedyCache\Enhanced::pre_connect_hint', 10, 2);
				}
			}
		
			// Adds Preload link tag to the head
			if(!empty($speedycache->options['preload_resources'])){
				add_action('wp_head', '\SpeedyCache\Enhanced::preload_resource', 0);
			}
		}

		// Image URL rewrite
		if(class_exists('\SpeedyCache\Image') && !empty($speedycache->image['settings']['url_rewrite'])){
			add_filter('the_content', 'SpeedyCache\Image::rewrite_url_to_webp', 10);
		}

		ob_start('\SpeedyCache\Cache::optimize');
	}

	static function create(){
		global $speedycache;

		$cache_path = self::cache_path();

		if(!file_exists($cache_path)){
			mkdir($cache_path, 0755, true);
		}

		$cache_path .= '/' . self::cache_file_name();
		
		$mobile = '';
		if(strpos($cache_path, 'mobile-cache') !== FALSE){
			$mobile = 'Mobile: ';
		}
		
		$cache_path = wp_normalize_path($cache_path);

		file_put_contents($cache_path, self::$content . "\n<!-- ".esc_html($mobile)."Cache by SpeedyCache https://speedycache.com -->");

		if(function_exists('gzencode') && !empty($speedycache->options['gzip'])){
			$gzidded_content = gzencode(self::$content . "\n<!-- ".esc_html($mobile)."Cache by SpeedyCache https://speedycache.com -->");
			file_put_contents($cache_path . '.gz', $gzidded_content);
		}

		delete_option('speedycache_html_size');
		delete_option('speedycache_assets_size');
	}
	
	static function cache_file_name(){		
		$file_name = 'index';

		if(isset($_COOKIE['wcu_current_currency'])){
			$file_name .= '-'. strtolower(sanitize_file_name($_COOKIE['wcu_current_currency']));
		}

		return $file_name . '.html';
	}
	

	static function cache_path(){
		global $speedycache;
		
		if(!file_exists(SPEEDYCACHE_CACHE_DIR)){
			if(mkdir(SPEEDYCACHE_CACHE_DIR, 0755, true)){
				touch(SPEEDYCACHE_CACHE_DIR . '/index.html');
			}
		}

		$host = $_SERVER['HTTP_HOST'];
		$request_uri = urldecode(esc_url_raw(wp_unslash($_SERVER['REQUEST_URI'])));
		$request_uri = preg_replace('/\.{2,}/', '', $request_uri); // Cleaning the path
		$request_uri = remove_query_arg(self::$ignored_parameters, $request_uri); // Cleaning ignored query
		$parsed_uri = wp_parse_url($request_uri);

		$path = SPEEDYCACHE_CACHE_DIR;
		$path .= '/' . $host;

		if(wp_is_mobile() && !empty($speedycache->options['mobile_theme'])){
			$path .= '/mobile-cache';
		} else {
			$path .= '/all';
		}
			
		// Handling WeGlot
		if(function_exists('weglot_get_current_full_url')){
			$weglot_url = weglot_get_current_full_url();
			$weglot_path = parse_url($weglot_url, PHP_URL_PATH);
			
			$path .= $weglot_path;
		} else {
			$path .= $parsed_uri['path'];
		}

		self::$cache_file_path = $path;

		return $path;
	}

	static function can_cache(){
		global $speedycache;
		
		if(empty($speedycache->options['status'])) return false;

		if(empty($_SERVER['REQUEST_METHOD']) || $_SERVER['REQUEST_METHOD'] != 'GET') return false;
		
		if(defined('WP_CLI') && !empty(WP_CLI)) return false;

		if(defined('REST_REQUEST') && !empty(REST_REQUEST)) return false;

		if(function_exists('http_response_code') && (http_response_code() > 309)) return false;
		
		if(preg_match('/\./', $_SERVER['REQUEST_URI'])) return false;
		
		if (defined('SITEPAD')) {
			if (preg_match('/(site-admin|login|wp-register|wp-comments-post|cron|sp-json)/', $_SERVER['REQUEST_URI'])) {
				return false;
			}
		} else {
			if (preg_match('/(wp-(?:admin|login|register|comments-post|cron|json))/', $_SERVER['REQUEST_URI'])) {
				return false;
			}
		}
		
		if(preg_match('/html.*\s(amp|⚡)/', substr(self::$content, 0, 300))) return false;
		
		if(wp_is_mobile() && !empty($speedycache->options['mobile']) && empty($speedycache->options['mobile_theme'])) return false;

		if(is_admin()) return false;

		// Since: 1.2.8 we will only cache the page if user is not logged-in.
		if(is_user_logged_in()) return false;
		
		if(!preg_match( '/<\s*\/\s*html\s*>/i', self::$content)) return false;

		if(is_singular() && post_password_required()) return false;
		
		if(function_exists('is_404') && is_404()) return false;

		if(self::is_excluded()) return false;

		if(function_exists('is_cart') && is_cart()) return false;

		if(function_exists('is_checkout') && is_checkout()) return false;
		
		if(function_exists('is_account_page') && is_account_page()) return false;

		if(!self::can_handle_query()) return false;
	
		return true;
	}

	static function optimize($content){
		global $speedycache;
		
		self::$content = &$content;
		
		$start_time = microtime(TRUE);

		if(!self::can_cache()){
			return self::$content;
		}
		
		self::clean_html();

		// Minify HTML
		if(class_exists('\SpeedyCache\Enhanced') && !empty($speedycache->options['minify_html']) && (defined('SPEEDYCACHE_PRO_VERSION') && version_compare(SPEEDYCACHE_PRO_VERSION, '1.2.0', '>='))){
			\SpeedyCache\Enhanced::init();
			\SpeedyCache\Enhanced::minify_html(self::$content);
		}

		// ADD Font Rendering CSS
		if(!empty($speedycache->options['font_rendering'])){
			self::$content = str_replace('</head>', '<style>body{text-rendering: optimizeSpeed;}</style></head>', self::$content);
		}
		
		// Lazy Load HTML elements
		if(class_exists('\SpeedyCache\Enhanced') && !empty($speedycache->options['lazy_load_html']) && !empty($speedycache->options['lazy_load_html_elements'])){
			self::$content = \SpeedyCache\Enhanced::lazy_load_html(self::$content);
		}

		if(!empty($speedycache->options['combine_css'])){
			\SpeedyCache\CSS::combine(self::$content);
		}

		if(!empty($speedycache->options['minify_css'])){
			\SpeedyCache\CSS::minify(self::$content);
		}
		
		if(!empty($speedycache->options['combine_js'])){
			\SpeedyCache\JS::combine_head(self::$content);
		}
		
		// if(class_exists('\SpeedyCache\Enhanced') && !empty($speedycache->options['combine_js'])){
			// \SpeedyCache\JS::combine_body($content);
		// }
		
		if(!empty($speedycache->options['minify_js'])){
			\SpeedyCache\JS::minify(self::$content);
		}
		
		// Adds Image dimensions to the Image which does not have height or width
		if(class_exists('\SpeedyCache\Enhanced') && !empty($speedycache->options['image_dimensions'])){
			self::$content = \SpeedyCache\Enhanced::image_dimensions(self::$content);
		}

		// Google Fonts
		if(class_exists('\SpeedyCache\GoogleFonts') && !empty($speedycache->options['local_gfonts'])){
			\SpeedyCache\GoogleFonts::get($content);
			self::$content = \SpeedyCache\GoogleFonts::replace(self::$content);
			self::$content = \SpeedyCache\GoogleFonts::add_swap(self::$content);
		}

		// Preload Critical Images
		if(class_exists('\SpeedyCache\Enhanced') && !empty($speedycache->options['critical_images'])){
			self::$content = \SpeedyCache\Enhanced::preload_critical_images(self::$content);
		}

		// Delay JS
		if(!empty($speedycache->options['delay_js']) && class_exists('\SpeedyCache\ProOptimizations')){
			\SpeedyCache\ProOptimizations::delay_js(self::$content);
		}
		
		// Defer JS
		if(!empty($speedycache->options['render_blocking']) && class_exists('\SpeedyCache\ProOptimizations')){
			\SpeedyCache\ProOptimizations::defer_js(self::$content);
		}
		
		// IMG Lazy Load
		if(class_exists('\SpeedyCache\ProOptimizations') && !empty($speedycache->options['lazy_load'])){
			\SpeedyCache\ProOptimizations::img_lazy_load(self::$content);
		}
		
		// For other plugins to hook into.
		self::$content = (string) apply_filters('speedycache_content', self::$content);

		// ----- DO NOT DO ANY OPTIMIZATION BELOW THIS ------
		// Unused and Critical CSS
		if(
			!empty($_SERVER['HTTP_HOST']) && 
			!empty($_SERVER['REQUEST_URI']) && 
			!empty($_SERVER['HTTP_USER_AGENT']) && 
			class_exists('\SpeedyCache\ProOptimizations') && 
			speedycache_optserver('HTTP_USER_AGENT') !== 'SpeedyCacheCCSS' && 
			!(defined('SITEPAD'))
		){
			$post_meta = get_post_meta(get_the_ID(), 'speedycache_post_meta', true);
			
			if(!empty($speedycache->options['critical_css']) && empty($post_meta['disable_critical_css'])){
				\SpeedyCache\ProOptimizations::critical_css();
			}
			
			if(empty($post_meta['disable_unused_css']) && !empty($speedycache->options['unused_css'])){
				\SpeedyCache\ProOptimizations::unused_css();
			}
		}
		
		// Rewriting to a CDN
		if(
			!empty($speedycache->cdn) && 
			!empty($speedycache->cdn['enabled']) && 
			!empty($speedycache->cdn['cdn_url']) && 
			!empty($speedycache->cdn['cdn_type']) && 
			$speedycache->cdn['cdn_type'] !== 'cloudflare'
		){
			\SpeedyCache\CDN::rewrite(self::$content);
		}

		self::create();
		$end_time = microtime(TRUE);

		self::$content .= '<!-- Cached by SpeedyCache, it took '.($end_time - $start_time).'s-->';
		self::$content .= '<!-- Refresh to see the cached version -->';
		
		if(file_exists(self::$cache_file_path)){
			header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime(self::$cache_file_path)) . ' GMT');
		}
		return self::$content;
	}
	
	static function clean_html(){
		self::$content = str_replace("\r\n", "\n", trim(self::$content));
	}
	
	static function is_excluded(){
		global $speedycache;
		
		$excludes = get_option('speedycache_exclude', []);
		
		if(empty($excludes)){
			return false;
		}

		$is_excluded = false;

		foreach($excludes as $rule){
			switch($rule['type']){
				case 'page':
					$is_excluded = self::is_page_excluded($rule);
					break;

				case 'useragent':
					$is_excluded = self::is_useragent_excluded($rule);
					break;

				case 'cookie':
					$is_excluded = self::is_cookie_excluded($rule);
					break;
			}

			if(!empty($is_excluded)){
				return true;
			}
		}

		return false;
	}
	
	static function can_handle_query(){
		$uri = sanitize_text_field(wp_unslash($_SERVER['REQUEST_URI']));
		$uri = remove_query_arg(self::$ignored_parameters, $uri);
		$parsed_uri = wp_parse_url($uri);

		if(!empty($parsed_uri['query'])){
			return false;
		}

		return true;
	}
	
	static function is_page_excluded($rule){

		if(empty($rule['prefix'])){
			return false;
		}

		if($rule['prefix'] === 'homepage'){
			return is_front_page();
		}
		
		if($rule['prefix'] === 'page'){
			return is_page();
		}

		if($rule['prefix'] === 'post_id' && !empty($rule['content'])){
			$excluded_ids = is_array($rule['content']) ? $rule['content'] : explode(',', $rule['content']);
			return in_array(get_queried_object_id(), $excluded_ids);
		}
		
		// Excludes a page if it has the given shortcode.
		if($rule['prefix'] === 'shortcode' && !empty($rule['content'])){
			if(self::has_shortcode($rule['content'])){
				return true;
			}
		}

		if($rule['prefix'] === 'category'){
			return is_category();
		}
		
		if($rule['prefix'] === 'archive'){
			return is_archive();
		}
		
		if($rule['prefix'] === 'tag'){
			return is_tag();
		}
		
		if($rule['prefix'] === 'attachment'){
			return is_attachment();
		}
		
		if($rule['prefix'] === 'startwith' && !empty($rule['content'])){
			return (bool) preg_match('/^'.preg_quote($rule['content'], '/').'/', trim($_SERVER['REQUEST_URI'], '/'));
		}
		
		if($rule['prefix'] === 'contain' && !empty($rule['content'])){
			return (bool) preg_match('/'.preg_quote($rule['content'], '/').'/', trim($_SERVER['REQUEST_URI'], '/'));
		}
		
		if($rule['prefix'] === 'exact' && !empty($rule['content'])){
			return trim($rule['content'], '/') === trim($_SERVER['REQUEST_URI'], '/');
		}
		
		return false;
	}
	
	static function is_cookie_excluded($rule){
		if(!isset($_SERVER['HTTP_COOKIE'])){
			return false;
		}

		$cookie = sanitize_text_field(wp_unslash($_SERVER['HTTP_COOKIE']));

		return preg_match('/'.preg_quote($rule['content'], '/').'/i', $cookie);
	}
	
	static function is_useragent_excluded($rule){
		return preg_match('/'.preg_quote($rule['content'], '/').'/i', $_SERVER['HTTP_USER_AGENT']);
	}
	
	// Adds DNS prefetch
	static function dns_prefetch_hint($urls, $relation_type){
		global $speedycache;

		if($relation_type !== 'dns-prefetch'){
			return $urls;
		}

		foreach($speedycache->options['dns_urls'] as $url) {
			if(!empty($url)){
				$urls[] = $url;
			}
		}

		return $urls;
	}
	
	// Depricated since 1.2.0 do not use it
	// Just to prevent site from breaking
	static function create_dir($path, $content, $type = ''){
	}
	
	
	static function disable_emojis(){
		add_filter('emoji_svg_url', '__return_false');
		remove_action('wp_head', 'print_emoji_detection_script', 7);
		remove_action('admin_print_scripts', 'print_emoji_detection_script');
		remove_action('wp_print_styles', 'print_emoji_styles');
		remove_action('admin_print_styles', 'print_emoji_styles');
		remove_filter('the_content_feed', 'wp_staticize_emoji');
		remove_filter('comment_text_rss', 'wp_staticize_emoji'); 
		remove_filter('wp_mail', 'wp_staticize_emoji_for_email');
	}
	
	static function instant_page(){
		wp_enqueue_script('speedycache_instant_page', SPEEDYCACHE_PRO_URL . '/assets/js/instantpage.js', array(), SPEEDYCACHE_PRO_VERSION, ['strategy' => 'defer', 'in_footer' => true]);
	}
	
	/*
	* @param string $shortcode shortcode tag name.
	* @return bool.
	*/
	static function has_shortcode($shortcode){
		global $post;

		return \has_shortcode($post->post_content, $shortcode);
	}
}
PKv�f\B���!�!htaccess.phpnu�[���<?php

namespace SpeedyCache;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class Htaccess {

	static function init(){

		if(!empty($_SERVER['SERVER_SOFTWARE'])){
			$server_name = sanitize_text_field(wp_unslash($_SERVER['SERVER_SOFTWARE']));

			if(!empty($server_name) && (preg_match('/nginx/i', $server_name) || preg_match('/iis/i', $server_name))){
				return;
			}
		}

		if(defined('SITEPAD')){
			global $sitepad;
			$htaccess_file = $sitepad['path'] . '/.htaccess';
		}else{
			$htaccess_file = ABSPATH . '/.htaccess';
		}
		
		if(!file_exists($htaccess_file)){
			return false;
		}

		if(!is_writable($htaccess_file)){
			return;
		}

		$htaccess_content = file_get_contents($htaccess_file);

		$htaccess_rules = '';
		self::headers($htaccess_rules);
		self::gzip($htaccess_rules);
		self::browser_cache($htaccess_rules);
		self::webp($htaccess_rules);
		self::serving_rules($htaccess_rules);

		// TODO: Need to add modified time here.
		// Cleaning stuff
		$htaccess_content = preg_replace("/#\s?BEGIN\s?LBCspeedycache.*?#\s?END\s?LBCspeedycache/s", '', $htaccess_content);
		$htaccess_content = preg_replace("/#\s?BEGIN\s?WEBPspeedycache.*?#\s?END\s?WEBPspeedycache/s", '', $htaccess_content);
		$htaccess_content = preg_replace("/#\s?BEGIN\s?Gzipspeedycache.*?#\s?END\s?Gzipspeedycache/s", '', $htaccess_content);
		$htaccess_content = preg_replace("/#\s?BEGIN\s?SpeedyCacheheaders.*?#\s?END\s?SpeedyCacheheaders/s", '', $htaccess_content);
		$htaccess_content = preg_replace("/#\s?BEGIN\s?speedycache.*?#\s?END\s?speedycache/s", '', $htaccess_content);
		$htaccess_content = $htaccess_rules ."\n" . trim($htaccess_content);

		file_put_contents($htaccess_file, $htaccess_content);

	}
	
	static function serving_rules(&$htaccess_rules){
		global $speedycache;
		$base_cache_path = defined('SITEPAD') ? 'sitepad-data' : 'wp-content';
		$platform_excludes = defined('SITEPAD') ?
		'RewriteCond %{REQUEST_URI} !^/(site-admin|login|wp-register|wp-comments-post|cron|sp-json)/ [NC]' :
		'RewriteCond %{REQUEST_URI} !^/(wp-(?:admin|login|register|comments-post|cron|json))/ [NC]';

		$htaccess_rules .= '# BEGIN speedycache
<IfModule mod_rewrite.c>
RewriteEngine On';
		if(!defined('SITEPAD')){
			$htaccess_rules .= "\n".'RewriteBase /';
		}

		if(!empty($speedycache->options['mobile']) && !empty($speedycache->options['mobile_theme'])){
			$htaccess_rules .= '
	RewriteCond %{REQUEST_METHOD} GET
	RewriteCond %{HTTP_USER_AGENT} !(Mediatoolkitbot|facebookexternalhit|SpeedyCacheCCSS)
	RewriteCond %{HTTP_USER_AGENT} (Mobile|Android|Silk\/|Kindle|Opera\sMini|BlackBerry|Opera\sMobi) [NC]
	RewriteCond %{QUERY_STRING} =""
	'.self::cookie_excludes().'
	RewriteCond %{REQUEST_URI} !(\/){2}$
	'.$platform_excludes.'
	RewriteCond %{DOCUMENT_ROOT}/'.$base_cache_path.'/cache/speedycache/%{HTTP_HOST}/mobile-cache%{REQUEST_URI}/index.html -f
	RewriteRule ^(.*) /'.$base_cache_path.'/cache/speedycache/%{HTTP_HOST}/mobile-cache%{REQUEST_URI}/index.html [L]'."\n";
		}

$htaccess_rules .= '
	RewriteCond %{REQUEST_METHOD} GET
	RewriteCond %{HTTP_USER_AGENT} !(Mediatoolkitbot|facebookexternalhit|SpeedyCacheCCSS)
	RewriteCond %{QUERY_STRING} =""
	'.self::cookie_excludes()."\n";

	if(!empty($speedycache->options['mobile'])){
		$htaccess_rules .= '
	RewriteCond %{HTTP_USER_AGENT} !(Mobile|Android|Silk\/|Kindle|Opera\sMini|BlackBerry|Opera\sMobi) [NC]' . "\n";
	}

	$htaccess_rules .= '
	RewriteCond %{REQUEST_URI} !(\/){2}$
	'.$platform_excludes.'
	RewriteCond %{DOCUMENT_ROOT}/'.$base_cache_path.'/cache/speedycache/%{HTTP_HOST}/all%{REQUEST_URI}/index.html -f
	RewriteRule ^(.*) /'.$base_cache_path.'/cache/speedycache/%{HTTP_HOST}/all%{REQUEST_URI}/index.html [L]
</IfModule>
# END speedycache' . PHP_EOL;
	}
	
	static function browser_cache(&$htaccess_rules){
		global $speedycache;

		if(empty($speedycache->options['lbc'])){
			return;
		}

		$htaccess_rules .= '# BEGIN LBCspeedycache
<IfModule mod_expires.c>
	ExpiresActive on
	ExpiresDefault A0
	ExpiresByType text/css A31536000
	ExpiresByType text/javascript A31536000
	ExpiresByType font/ttf A31536000
	ExpiresByType font/otf A31536000
	ExpiresByType font/woff A31536000
	ExpiresByType font/woff2 A31536000
	ExpiresByType image/jpg A31536000
	ExpiresByType image/jpeg A31536000
	ExpiresByType image/png A31536000
	ExpiresByType image/gif A31536000
	ExpiresByType image/webp A31536000
	ExpiresByType image/x-icon A31536000
	ExpiresByType image/svg+xml A31536000
	ExpiresByType image/vnd.microsoft.icon A31536000
	ExpiresByType video/ogg A31536000
	ExpiresByType video/mp4 A31536000
	ExpiresByType video/webm A31536000
	ExpiresByType audio/ogg A31536000
	ExpiresByType application/pdf A31536000
	ExpiresByType application/javascript A31536000
	ExpiresByType application/x-javascript A31536000
	ExpiresByType application/x-font-ttf A31536000
	ExpiresByType application/x-font-woff A31536000
	ExpiresByType application/font-woff A31536000
	ExpiresByType application/font-woff2 A31536000
	ExpiresByType application/vnd.ms-fontobject A31536000
</IfModule>
# END LBCspeedycache' . PHP_EOL;
	}

	static function webp(&$htaccess_rules){
		$htaccess_rules .= '# BEGIN WEBPspeedycache
<IfModule mod_rewrite.c>
	RewriteEngine On
	RewriteCond %{HTTP_ACCEPT} image/webp
	RewriteCond %{REQUEST_FILENAME} \.(jpe?g|png|gif)$
	RewriteCond %{DOCUMENT_ROOT}/$1.webp -f
	RewriteRule ^(.+)\.(jpe?g|png|gif)$ $1.webp [T=image/webp,L]
</IfModule>
<IfModule mod_headers.c>
  Header append Vary Accept env=REDIRECT_accept
</IfModule>
AddType image/webp .webp
# END WEBPspeedycache' . PHP_EOL;
	}
	
	static function gzip(&$htaccess_rules){
		global $speedycache;

		if(empty($speedycache->options['gzip'])){
			return;
		}

		$htaccess_rules .= '# BEGIN Gzipspeedycache
<IfModule mod_deflate.c>
	AddOutputFilterByType DEFLATE font/opentype
	AddOutputFilterByType DEFLATE font/otf
	AddOutputFilterByType DEFLATE font/ttf
	AddOutputFilterByType DEFLATE font/woff
	AddOutputFilterByType DEFLATE font/woff2
	AddOutputFilterByType DEFLATE text/js
	AddOutputFilterByType DEFLATE text/css
	AddOutputFilterByType DEFLATE text/html
	AddOutputFilterByType DEFLATE text/javascript
	AddOutputFilterByType DEFLATE text/plain
	AddOutputFilterByType DEFLATE text/xml
	AddOutputFilterByType DEFLATE image/svg+xml
	AddOutputFilterByType DEFLATE image/x-icon
	AddOutputFilterByType DEFLATE application/javascript
	AddOutputFilterByType DEFLATE application/x-javascript
	AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
	AddOutputFilterByType DEFLATE application/x-font
	AddOutputFilterByType DEFLATE application/x-font-opentype
	AddOutputFilterByType DEFLATE application/x-font-otf
	AddOutputFilterByType DEFLATE application/x-font-truetype
	AddOutputFilterByType DEFLATE application/x-font-ttf
	AddOutputFilterByType DEFLATE application/font-woff2
	AddOutputFilterByType DEFLATE application/xhtml+xml
	AddOutputFilterByType DEFLATE application/xml
	AddOutputFilterByType DEFLATE application/rss+xml
</IfModule>
# END Gzipspeedycache'. PHP_EOL;
	}
	
	static function headers(&$htaccess_rules){
		$url = site_url();
		$parsed_url = wp_parse_url($url);

		$htaccess_rules .= '# BEGIN SpeedyCacheheaders
FileETag None
<IfModule mod_headers.c>
	Header unset ETag
</IfModule>
<FilesMatch "\.(html)$">
<IfModule mod_headers.c>
	Header set x-speedycache-source "Server"
	Header set Cache-Tag "'.$parsed_url['host'].'"
	Header set CDN-Cache-Control "max-age=1296000"
	Header set Cache-Control "public"
	Header unset Pragma
	Header unset Last-Modified
</IfModule>
</FilesMatch>

<FilesMatch "\.(css|htc|js|asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip)$">
	<IfModule mod_headers.c>
		Header unset Pragma
		Header set Cache-Control "public"
	</IfModule>
</FilesMatch>
# END SpeedyCacheheaders'. PHP_EOL;
	}
	
	static function cookie_excludes(){
		$cookies = [];

		$cookies[] = 'comment_author_';
		$cookies[] = 'wordpress_logged_in_';
		if(!defined('SITEPAD')){
			if(is_plugin_active('woo-currency/wcu.php')){
				$cookies[] = 'wcu_current_currency';
			}
		}
		$cookies_to_exclude = implode('|', $cookies);
		$cookies_to_exclude = preg_replace("/\s/", "\s", $cookies_to_exclude);

		return 'RewriteCond %{HTTP:Cookie} !('.$cookies_to_exclude.')';
	}

}
PKv�f\�	���advanced-cache.phpnu�[���<?php
/*
* SPEEDYCACHE
* https://speedycache.com/
* (c) SpeedyCache Team
*/

if(!defined('ABSPATH')) exit;

// Check request method is Head or get 
if(!isset($_SERVER['REQUEST_METHOD']) || $_SERVER['REQUEST_METHOD'] !== 'GET'){
	return;
}

if(defined('WP_INSTALLING') && WP_INSTALLING){
	return;
}

if(defined('WP_CLI') && WP_CLI){
	return;
}

if(empty($_SERVER['REQUEST_URI']) || empty($_SERVER['HTTP_HOST']) || empty($_SERVER['HTTP_USER_AGENT'])){
    return false;
}

if(preg_match('/(\/){2}$/', $_SERVER['REQUEST_URI'])){
	return false;
}

function speedycache_ac_serve_cache(){

	$ignored_parameters = ['fbclid', 'utm_id', 'utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'utm_source_platform', 'gclid', 'dclid', 'msclkid', 'ref', 'fbaction_ids', 'fbc', 'fbp', 'clid', 'mc_cid', 'mc_eid', 'hsCtaTracking', 'hsa_cam', 'hsa_grp', 'hsa_mt', 'hsa_src', 'hsa_ad', 'hsa_acc', 'hsa_net', 'hsa_kw', 'test_speedycache'];

	$uri = '';
	$parsed_uri = [];
	$uri = $_SERVER['REQUEST_URI'];
	$uri = urldecode($uri); // Users use other languages to write as well
	$uri = preg_replace('/\.{2,}/', '', $uri); // Cleaning the path

	$parsed_uri = parse_url($uri);
	if(!empty($parsed_uri) && !empty($parsed_uri['query'])){
		parse_str($parsed_uri['query'], $parsed_query);

		foreach($parsed_query as $query => $value){
			if(in_array($query, $ignored_parameters)){
				unset($parsed_query[$query]);
				continue;
			}
		}

		$uri = $parsed_uri['path'] . (!empty($parsed_query) ? '?'.http_build_query($parsed_query) : '');
	}
	
	// We dont know if the site is a /directory based so we just hit and try
	$site_dir = '';

	$path = '';
	if(!empty($parsed_uri['path'])){
		$path = trim($parsed_uri['path'], '/');
	}

	if(strpos($path, '/') !== FALSE){
		$parsed_path = explode('/', $path);
		$site_dir = $parsed_path[0];
	} elseif(!empty($path)){
		$site_dir = $path;
	}

	$config_file = WP_CONTENT_DIR . '/speedycache-config/' . basename($_SERVER['HTTP_HOST']) . '.php';

	if(!file_exists($config_file)){
		$config_file = WP_CONTENT_DIR . '/speedycache-config/' . basename($_SERVER['HTTP_HOST']) . '.'. $site_dir . '.php';
		if(!file_exists($config_file)){
			return;
		}
	}

	if(!file_exists($config_file)){
		return;
	}

	// Accessing the config file
	include_once $config_file;
	
	if(empty($speedycache_ac_config) || !is_array($speedycache_ac_config)){
		return;
	}

	if(empty($speedycache_ac_config['settings']['status'])){
		return;
	}
	
	// Exclude pages|useragent|cookie
	if(speedycache_ac_excludes($speedycache_ac_config)){
		return;
	}

	if(!empty($speedycache_ac_config['user_agents']) && preg_match('/'.preg_quote($speedycache_ac_config['user_agents']).'/', $_SERVER['HTTP_USER_AGENT'])){
		return;
	}
	
	if(empty($speedycache_ac_config['settings']['logged_in_user']) && preg_grep('/^wordpress_logged_in_/i', array_keys($_COOKIE))){
		return false;
	}

	// check comment author
	if(preg_grep('/comment_author_/i', array_keys($_COOKIE))){
		return false;
	}

	$cache_path = WP_CONTENT_DIR.'/cache/speedycache/' . basename($_SERVER['HTTP_HOST']);

	// For the test cache
	if(isset($_GET['test_speedycache'])){
		$cache_path = '/test'. $uri;
	} else if(!empty($speedycache_ac_config['settings']['mobile']) && preg_match('/Mobile|Android|Silk\/|Kindle|BlackBerry|Opera (Mini|Mobi)/i', $_SERVER['HTTP_USER_AGENT'])) {
		// Check for Mobile
		if(!empty($speedycache_ac_config['settings']['mobile_theme'])){
			$cache_path .= '/mobile-cache' . $uri;
		} else {
			return; // If just mobile is enabled then we don't want to show desktop verison of cache on mobile.
		}
	} else {
		// get path of file
		$cache_path .= '/all'. $uri;
	}
	
	$file_name = 'index';
	if(isset($_COOKIE['wcu_current_currency'])){
		$file_name .= '-' . strtolower($_COOKIE['wcu_current_currency']);
		$file_name = preg_replace('/\.{2,}/', '', $file_name); // Cleaning the path
	}
	$file_name .= '.html';

	//check file extension
	$serving_gz = '';
	if(isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE && !empty($speedycache_ac_config['settings']['gzip']) && @file_exists($cache_path . '/'. $file_name.'.gz')){
		$serving_gz = '.gz';
		
		// We do not want output compression to be enabled if we are gzipping the page.
		if(function_exists('ini_set')){
			ini_set('zlib.output_compression', 0);
		}

		header('Content-Encoding: gzip');
	}

	if(!file_exists($cache_path . '/'.$file_name . $serving_gz)){
		$serving_gz = '';
	}
	
	if(!file_exists($cache_path . '/'.$file_name . $serving_gz)){
		return;
	}

	if(!headers_sent()){
		header('x-speedycache-source: PHP');
	}

	$cache_created_at = filemtime($cache_path. '/'.$file_name . $serving_gz);
	header('Last-Modified: ' . gmdate( 'D, d M Y H:i:s', $cache_created_at) . ' GMT');

	$if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) : 0;

	if($if_modified_since === $cache_created_at){
		header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified', true, 304);
		header('Cache-Control: no-cache, must-revalidate');
		header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
		exit();
	}

	readfile($cache_path. '/'.$file_name . $serving_gz);
	exit();
}

function speedycache_ac_excludes($excludes){
	if(empty($excludes) || !is_array($excludes)){
		return false;
	}

	$preg_match_rule = '';
	$request_url = !empty($_SERVER['REQUEST_URI']) ? urldecode(trim($_SERVER['REQUEST_URI'], '/')) : '';

	foreach($excludes as $key => $value){
		$value['type'] = !empty($value['type']) ? $value['type'] : 'page';

		if(!empty($value['prefix']) && $value['type'] == 'page'){
			$value['content'] = trim($value['content']);
			$value['content'] = trim($value['content'], '/');
			
			if($value['prefix'] == 'exact' && strtolower($value['content']) == strtolower($request_url)){
				return true;
			}else{
				$preg_match_rule = preg_quote($value['content'], '/');

				if($preg_match_rule){
					if(preg_match('/'.$preg_match_rule.'/i', $request_url)){
						return true;
					}
				}
			}
		}else if($value['type'] == 'useragent'){
			if(preg_match('/'.preg_quote($value['content'], '/').'/i', $_SERVER['HTTP_USER_AGENT'])){
				return true;
			}
		}else if($value['type'] == 'cookie'){
			if(isset($_SERVER['HTTP_COOKIE'])){
				if(preg_match('/'.preg_quote($value['content'], '/').'/i', $_SERVER['HTTP_COOKIE'])){
					return true;
				}
			}
		}
	}
}

speedycache_ac_serve_cache();PKv�f\��.]6]6
delete.phpnu�[���<?php

namespace SpeedyCache;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT');
}

use \SpeedyCache\Util;

class Delete{
	
	static $cache_lifespan = 0;

	static function run($actions){
		global $speedycache;
		
		// Even if the actions are empty, the cache will be deleted.
		self::all_cache();
		self::purge_varnish();
		\SpeedyCache\CDN::purge();
		delete_option('speedycache_html_size');
		delete_option('speedycache_assets_size');

		if(empty($actions)){
			return;
		}
		
		if(!empty($actions['minified'])){
			self::minified();
		}
		
		if(!empty($actions['font'])){
			self::local_fonts();
		}
		
		if(!empty($actions['gravatars'])){
			self::gravatar();
		}
		
		if(!empty($actions['domain'])){
			self::all_for_domain();
		}
		
		if(!empty($actions['preload'])){
			if(!empty($speedycache->options['preload'])){
				\SpeedyCache\Preload::build_preload_list();
			}
		}
	}
	
	/**
	 * Deletes cache of a single page
	 * @param int $post_id
	 */
	static function cache($post_id = false){
		global $speedycache;

		if(!isset($post_id) || $post_id === FALSE || !is_numeric($post_id)){
			return;
		}

		$link = get_permalink($post_id);

		// If its 0 then it's a homepage
		if($post_id == 0){
			$link = home_url();
		}

		if(empty($link)){
			return;
		}

		self::url($link);

		if(class_exists('\SpeedyCache\Logs')){
			\SpeedyCache\Logs::log('delete');
			\SpeedyCache\Logs::action();
		}
		
		if(!empty($speedycache->options['preload'])){
			\SpeedyCache\Preload::url($link);
		}

		delete_option('speedycache_html_size');
		delete_option('speedycache_assets_size');
	}

	/**
	* Deletes cache of a URL
	* Parses and converts a URL to cache path and purges it
	* @param array|string $urls
	*/
	static function url($urls){
		global $speedycache;

		$urls = (array) $urls;
		$cache_paths = [];

		foreach($urls as $url){
			$parsed_url = wp_parse_url($url);
			$path = !empty($parsed_url['path']) ? $parsed_url['path'] : '';
			
			// Path to be used in glob so that we can get all the variations of file created like for language or currency
			$file = (empty($path) || $path == '/') ? 'index*html' : trim($path, '/') . '/index*html';

			// Cache path for desktop cache
			$all_path = glob(Util::cache_path('all') . $file);
			$gz_path = glob(Util::cache_path('all') . $file .'.gz');
			
			$all_path = array_merge(
				is_array($all_path) ? $all_path : [], 
				is_array($gz_path) ? $gz_path : []
			);

			if(!empty($all_path)){
				$cache_paths = array_merge($cache_paths, $all_path);
			}

			// Cache path for Mobile cache
			if(!empty($speedycache->options['mobile_theme'])){
				$mobile_path = glob(Util::cache_path('mobile-cache') . $file);

				if(!empty($mobile_path)){
					$cache_paths = array_merge($cache_paths, $mobile_path);
				}
			}
		}

		foreach($cache_paths as $cache_path){
			if(!file_exists($cache_path)){
				continue;
			}

			if(is_dir($cache_path)){
				self::rmdir($cache_path);
				continue;
			}

			unlink($cache_path);
		}
	}

	// Delete cache of whole site
	static function all_cache(){

		// Our cache is saved in 2 file, /all and /mobile-cache
		// We also need to delete Critical CSS too as it gets injected in the HTML
		$deletable_dirs = ['all', 'mobile-cache', 'critical-css'];
		
		foreach($deletable_dirs as $dir){
			$path = Util::cache_path($dir);
			self::rmdir($path);
		}

		if(class_exists('\SpeedyCache\Logs')){
			\SpeedyCache\Logs::log('delete');
			\SpeedyCache\Logs::action();
		}
	}

	// Delete minified and Critical css content.
	static function minified(){
		$assets_cache_path = Util::cache_path('assets');

		if(!file_exists($assets_cache_path)){
			return;
		}

		self::rmdir($assets_cache_path);

		if(class_exists('\SpeedyCache\Logs')){
			\SpeedyCache\Logs::log('delete');
			\SpeedyCache\Logs::action();
		}
	}

	// Delete local fonts
	static function local_fonts(){
		$fonts_path = Util::cache_path('fonts');

		if(!file_exists($fonts_path)){
			return;
		}

		self::rmdir($fonts_path);
		
		if(class_exists('\SpeedyCache\Logs')){
			\SpeedyCache\Logs::log('delete');
			\SpeedyCache\Logs::action();
		}
	}

	static function gravatar(){
		$gravatar_path = Util::cache_path('gravatars');
		
		if(!file_exists($gravatar_path)){
			return;
		}

		self::rmdir($gravatar_path);
		
		if(class_exists('\SpeedyCache\Logs')){
			\SpeedyCache\Logs::log('delete');
			\SpeedyCache\Logs::action();
		}
	}
	
	// Delete everything of the current domain, like minfied, cache, gravatar and fonts.
	static function all_for_domain(){
		
	}

	static function rmdir($dir){

		if(!file_exists($dir)){
			return;
		}

		$files = array_diff(scandir($dir), ['..', '.']);

		foreach($files as $file){
			if(is_dir($dir.'/'.$file)){
				self::rmdir($dir.'/'.$file);
				continue;
			}

			unlink($dir.'/'.$file);
		}

		rmdir($dir);
	}
	
	static function purge_varnish(){
		global $speedycache;

		if(empty($speedycache->options['purge_varnish'])){
			return;
		}

		$server = !empty($speedycache->options['varniship']) ? $speedycache->options['varniship'] : '127.0.0.1';
		
		
		$url = home_url();
		$url = parse_url($url);

		if($url == FALSE){
			return;
		}
		
		$sslverify = ($url['scheme'] === 'https') ? true : false;
		$request_url = $url['scheme'] .'://'. $server . '/.*';

		$request_args = array(
			'method'    => 'PURGE',
			'headers'   => array(
				'Host'       => $url['host'],
			),
			'sslverify' => $sslverify,
		);

		$res = wp_remote_request($request_url, $request_args);

		if(is_wp_error($res)){
			$msg = $res->get_error_message();
			return array($msg, 'error');
		}

		if(is_array($res) && !empty($res['response']['code']) && '200' != $res['response']['code']){
			$msg = 'Something Went Wrong Unable to Purge Varnish';
			
			if(empty($res['response']['code']) && '501' == $res['response']['code']){
				$msg = 'Your server dosen\'t allows PURGE request';

				if(!empty($res['headers']['allow'])){
					$msg .= 'The accepted HTTP methods are' . $res['headers']['allow'];
				}
				
				$msg = __('Please contact your hosting provider if, Varnish is enabled and still getting this error', 'speedycache');
			}
			
			return array($msg, 'error');
		}
		
		if(class_exists('\SpeedyCache\Logs')){
			\SpeedyCache\Logs::log('delete');
			\SpeedyCache\Logs::action();
		}
		
		return array(__('Purged Varnish Cache Succesfully', 'speedycache'), 'success');
	}

	static function expired_cache(){
		global $speedycache;

		self::$cache_lifespan = Util::cache_lifespan();
		
		// We don't want to clean cache if cache is disabled
		if(empty($speedycache->options['status']) || empty(self::$cache_lifespan)){
			wp_clear_scheduled_hook('speedycache_purge_cache');
			return;
		}

		$cache_path = [];
		$cache_path[] = Util::cache_path('all');
		$cache_path[] = Util::cache_path('mobile-cache');
		
		foreach($cache_path as $path){		
			if(!file_exists($path)){
				continue;
			}

			self::rec_clean_expired($path);
		}

		// Assets are deleted only if the lifetime is more than 10 hours,  
		// because only then is the entire cache deleted.  
		// Cached assets may be used on multiple pages,  
		// so we must ensure they are not deleted unless all cached pages are removed.
		if(self::$cache_lifespan > 10 * HOUR_IN_SECONDS){
			self::minified();

			if(!empty($speedycache->options['auto_purge_fonts'])){
				self::local_fonts();
			}

			if(!empty($speedycache->options['auto_purge_gravatar'])){
				self::gravatar();
			}
		}
		
		// We will delete it even if the cache does not gets deleted
		delete_option('speedycache_html_size');
		delete_option('speedycache_assets_size');
		
		if(class_exists('\SpeedyCache\Logs')){
			\SpeedyCache\Logs::log('delete');
			\SpeedyCache\Logs::action();
		}
		
		// Preload the cached
		if(self::$cache_lifespan > 10 * HOUR_IN_SECONDS && !empty($speedycache->options['preload'])){
			\SpeedyCache\Preload::build_preload_list();
		}
	}
	
	// Recursively deletes expired cache
	static function rec_clean_expired($path){
		$files = array_diff(scandir($path), array('..', '.'));

		if(empty($files)){
			return;
		}

		foreach($files as $file){
			$file_path = $path . '/'. $file;

			if(is_dir($file_path)){
				self::rec_clean_expired($file_path);
				continue;
			}

			// We will delete all cache if the lifespan is greater than 10 hours to prevent nonce issues,
			// We could delete all the cache for lifespan above 10 hrs, but for larger sites deleting 
			// everything colud be a overhead.
			if((self::$cache_lifespan >= 10 * HOUR_IN_SECONDS) || ((filemtime($file_path) + self::$cache_lifespan) < time())){
				unlink($file_path);
			}
		}
	}

	// Deletes the cache of the post whose status got changed,
	// only deletes when the post transitions in our out of published mode
	static function on_status_change($new_status, $old_status, $post){
		global $speedycache;

		if($old_status == $new_status && $old_status !== 'publish') return;

		if($old_status !== 'publish' && $new_status !== 'publish'){
			return;
		}

		if(empty($speedycache->options['status'])){
			return;
		}

		if(!empty(wp_is_post_revision($post->ID))){
			return;
		}

		// Current post should not be deleted when its anything other than publish,
		// As in some states its URL changes to ?page_id=
		if($new_status == 'publish'){
			self::cache($post->ID);
		}

		// Deleting the cache of home page and blog page
		$home_page_id = get_option('page_on_front');
		self::cache($home_page_id);

		// For some sites home page and blog page could be same
		$blog_page_id = get_option('page_for_posts');
		if($home_page_id !== $blog_page_id){
			self::cache($blog_page_id);
		}

		// Deleting the author page cache
		$author_page_url = get_author_posts_url($post->post_author);
		self::url($author_page_url);

		// Deleting cache of related terms
		self::terms($post->ID);
		
		// Delete shop page when product status changes.
		if(function_exists('wc_get_page_id')){
			$shop_page_id = wc_get_page_id('shop');
			
			if($home_page_id !== $shop_page_id){
				self::cache($shop_page_id);
			}
		}

		// This is used to delete post which may have the current post as the related post / product in them
		self::adjacent_posts_urls();
	}

	// Deletes cache of the page where a comments status got change.
	static function on_comment_status($new_status, $old_status, $comment){
		global $speedycache;

		if($old_status == $new_status && $old_status !== 'approved') return;

		if($old_status !== 'approved' && $new_status !== 'approved'){
			return;
		}

		if(empty($speedycache->options['status'])){
			return;
		}

		self::cache($comment->comment_parent);
		
	}

	static function terms($post_id){
		global $speedycache;
		
		if(empty($post_id) || !is_numeric($post_id)){
			return;
		}

		$post_type = get_post_type($post_id);
    
		if(empty($post_type)){
			return;
		}

		// Get all taxonomies for the post type
		$taxonomies = get_object_taxonomies($post_type, 'objects');

		// Filter to keep only public taxonomies
		$public_taxonomies = [];
		foreach($taxonomies as $taxonomy){
			if($taxonomy->public){
				$public_taxonomies[] = $taxonomy->name;
			}
		}

		if(empty($public_taxonomies)){
			return;
		}

		$terms = wp_get_post_terms($post_id, $public_taxonomies);

		if(empty($terms) || is_wp_error($terms)){
			return;
		}

		$deletable_links = [];
		foreach($terms as $term){
			$link = get_term_link($term->term_id);
			
			if(is_wp_error($link) || empty($link)){
				continue;
			}

			$deletable_links[] = $link;

			$ancestors = get_ancestors($term->term_id, $term->taxonomy);
			if(!empty($ancestors)){
				foreach($ancestors as $ancestor){
					$ancestor_link = get_term_link($ancestor);

					if(is_wp_error($ancestor_link) || empty($ancestor_link)){
						continue;
					}

					$deletable_links[] = $ancestor_link;
				}
			}
		}

		if(empty($deletable_links)){
			return;
		}
		
		$deletable_links = array_unique($deletable_links);
		
		self::url($deletable_links);
		
		if(!empty($speedycache->options['preload'])){
			\SpeedyCache\Preload::url($deletable_links);
		}
	}
	
	static function adjacent_posts_urls(){
		$post_urls = [];
		
		$prev_post = get_adjacent_post();
		$prev_post_term = get_adjacent_post(true, '');
		$next_post = get_adjacent_post(false, '', true);
		$next_post_term = get_adjacent_post(true, '', true);
		
		if(!empty($prev_post)){
			$post_urls[] = get_permalink($prev_post);
		}

		if(!empty($prev_post_term)){
			$post_urls[] = get_permalink($prev_post_term);
		}
		
		if(!empty($next_post)){
			$post_urls[] = get_permalink($next_post);
		}
		
		if(!empty($next_post_term)){
			$post_urls[] = get_permalink($next_post_term);
		}

		if(!empty($post_urls)){
			self::url($post_urls);
		}
	}

	// Deletes cache of product page and its related pages when a order is made
	static function order($order_id){
		global $speedycache;

		if(empty($speedycache->options['status'])){
			return;
		}

		if(!function_exists('wc_get_order')){
			return;
		}

		$order = wc_get_order($order_id);
		$items = $order->get_items();

		foreach($items as $item){
			$product_id = $item->get_product_id();
			
			if(empty($product_id)){
				continue;
			}

			self::cache($product_id);
			
			$categories = wp_get_post_terms($product_id, 'product_cat', array('fields' => 'ids'));

			foreach($categories as $category){
				self::cache($category);
			}
		}

		$shop_page_id = wc_get_page_id('shop');
		self::cache($shop_page_id);
	}
}
PKv�f\w�%���css.phpnu�[���<?php

namespace SpeedyCache;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

use \SpeedyCache\lib\Minify;
use \SpeedyCache\Util;

class CSS{
	
	static function minify(&$content){
		global $speedycache;
		
		if(empty($content)){
			return;
		}

		preg_match_all('/<link\s+([^>]+[\s"\'])?href\s*=\s*[\'"]\s*?(?<url>[^\'"]+\.css(?:\?[^\'"]*)?)\s*?[\'"]([^>]+)?\/?>/Umsi', $content, $tags, PREG_SET_ORDER);

		if(empty($tags)){
			return;
		}

		if(empty($_SERVER['HTTP_HOST'])){
			return;
		}

		$site_host = str_replace('www.', '', sanitize_text_field(wp_unslash($_SERVER['HTTP_HOST'])));
		$site_url = site_url();

		foreach($tags as $tag){

			if(empty($tag['url'])){
				continue;
			}

			$url = $tag['url'];
			
			if(self::is_excluded($url)) continue;

			// We don't want to minify already minified css
			if(strpos($url, '.min.css') !== FALSE){
				continue;
			}

			// We wont process any css that is not present on this WordPress install
			if(strpos($url, $site_host) === FALSE){
				continue;
			}

			$file_path = Util::url_to_path($url);

			if(!file_exists($file_path)){
				continue;
			}

			$file_name = self::file_name($file_path);
			$asset_path = Util::cache_path('assets');
			if(!is_dir($asset_path)){
				mkdir($asset_path, 0755, true);
				touch($asset_path . 'index.html');
			}

			$minified_path = $asset_path.$file_name;

			// If we already have a minified file then we dont need to process it again.
			if(!file_exists($minified_path)){
				$minified = new Minify\CSS($file_path);
				$minified = $minified->minify();

				$minified = self::fix_relative_path($minified, $url);
				file_put_contents($minified_path, $minified);
			}

			$minified_url = Util::path_to_url($minified_path);
			$content = str_replace($tag['url'], $minified_url, $content);
			
			// TODO: check if there is a preload.
		}
		
	}

	static function file_name($path){
		$file_hash = md5_file($path);
		$file_name = substr($file_hash, 0, 16) . '-' . basename($path);

		return $file_name;
	}
	
	static function combine(&$content){
		if(empty($content)){
			return;
		}

		preg_match_all('/<link\s+([^>]+[\s"\'])?href\s*=\s*[\'"]\s*?(?<url>[^\'"]+\.css(?:\?[^\'"]*)?)\s*?[\'"]([^>]+)?\/?>/Umsi', $content, $tags, PREG_SET_ORDER);
		
		if(empty($tags)){
			return;
		}

		if(empty($_SERVER['HTTP_HOST'])){
			return;
		}

		$site_host = str_replace('www.', '', sanitize_text_field(wp_unslash($_SERVER['HTTP_HOST'])));
		$site_url = site_url();

		$combined_css = '';
		$prev_tag = '';
		
		$tags = array_reverse($tags);

		foreach($tags as $tag){

			if(empty($tag['url'])){
				continue;
			}

			$url = $tag['url'];
			
			if(self::is_excluded($url)) continue;

			// We wont process any css that is not present on this WordPress install
			if(strpos($url, $site_host) === FALSE){
				continue;
			}

			$file_path = Util::url_to_path($url);

			if(!file_exists($file_path) || !is_readable($file_path)){
				continue;
			}
			
			$new_css = file_get_contents($file_path);
			$new_css = self::fix_relative_path($new_css, $url);

			$combined_css = $new_css . "\n" . $combined_css;

			// Removing the CSS which has already been combined, as we will add the combined file at the top after title.
			if(!empty($prev_tag)){
				$content = str_replace($prev_tag, '', $content);
			}

			// We remove the previous tag, in current iteration, so at last we have a tag to replace wirh the combined script.
			$prev_tag = $tag[0];
			
			//TODO: Need to remove any preload added by any plugin or a theme.
		}

		if(empty($combined_css)){
			return;
		}

		// Creating Combined file name
		$file_name = md5($combined_css);
		$file_name = substr($file_name, 0, 16) . '-combined.css';
		
		$asset_path = Util::cache_path('assets');
		if(!is_dir($asset_path)){
			mkdir($asset_path, 0755, true);
			touch($asset_path . 'index.html');
		}

		$combined_path = $asset_path.$file_name;

		file_put_contents($combined_path, $combined_css);
		$final_url = Util::path_to_url($combined_path);

		// Injecting the Combined CSS
		if(!empty($prev_tag)){
			$content = str_replace($prev_tag, '<link rel="stylesheet" href="'.esc_url($final_url).'" />', $content);
			return;
		}

		$content = str_replace('</title>', "</title>\n".'<link rel="stylesheet" href="'.esc_url($final_url).'" />', $content);
	}
	
	static function is_excluded($url){
		$excludes = get_option('speedycache_exclude', []);

		if(empty($excludes)){
			return false;
		}

		foreach($excludes as $exclude){
			if(empty($exclude['type'])){
				continue;
			}

			if($exclude['type'] !== 'css'){
				continue;
			}

			if(empty($exclude['content'])){
				continue;
			}

			if(preg_match('/'.preg_quote($exclude['content'], '/').'/', $url)){
				return true;
			}
		}

		return false;
	}
	
	static function fix_relative_path($content, $base_url){
		
		// We need base url as the relative url file will be in the same folder as file at the base url or will be relative to path of the base url
		$content = preg_replace_callback('/url\(\s*["\']?(?!http|https|\/\/)([^"\')]+)["\']?\s*\)/i', function($matches) use ($base_url) {
			$relative_path = $matches[1];
			$relative_path = trim($relative_path, '/');
			$base_path = Util::url_to_path($base_url);

			if(strpos($relative_path, '..') === 0 || strpos($relative_path, './') === 0){
				$parameter = '';
				// Some URL's had query parameters, that were breaking when using realpath
				if(strpos($relative_path, '?') !== FALSE){
					$parsed_path = explode('?', $relative_path);
					$parameter = $parsed_path[1];
					$relative_path = $parsed_path[0];
					$parsed_path = null;
				}

				$absolute_path = realpath(dirname($base_path) . '/' . $relative_path);
				$absolute_url = Util::path_to_url($absolute_path);
				
				// Appending the parameter again
				if(!empty($parameter)){
					$absolute_url .= '?'. $parameter;
				}
			} else if(strpos($relative_path, 'wp-content') === 0){
				$absolute_url = site_url() . '/'. $relative_path;
			}

			if(empty($absolute_url)){
				$absolute_url = $relative_path;
			}
			
			return 'url("' . $absolute_url . '")';
			
		}, $content);
		
		return $content;
	}
}
PKv�f\�Acy
y
preload.phpnu�[���<?php

namespace SpeedyCache;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class Preload{
	
	static function build_preload_list(){
		global $wp_rewrite;

		delete_transient('speedycache_preload_transient');

		if(!isset($wp_rewrite)){
			$wp_rewrite = new \WP_Rewrite();
		}

		$preload_urls = [];
		$preload_urls[] = home_url();

		$args = [
			'fields' => 'ids',
			'post_type' => ['post', 'page', 'product', 'docs'],
			'posts_per_page' => 80,
			'post_status' => 'publish',
			'orderby' => 'date',
			'order' => 'DESC',
			'has_password' => false,
		];
		
		$query = new \WP_Query($args);
		if($query->have_posts()){
			$posts = $query->get_posts();
			foreach($posts as $post_id){
				$preload_urls[] = get_permalink($post_id);
			}
		}

		$query = null;
		
		$args = [
			'fields' => 'ids',
			'post_type' => 'page',
			'posts_per_page' => 10,
			'post_status' => 'publish',
			'orderby' => 'date',
			'order' => 'DESC',
			'has_password' => false
		];

		$query = new \WP_Query($args);
		if($query->have_posts()){
			$posts = $query->get_posts();
			foreach($posts as $post_id){
				$preload_urls[] = get_permalink($post_id);
			}
		}

		$preload_urls = array_unique($preload_urls);

		set_transient('speedycache_preload_transient', $preload_urls, HOUR_IN_SECONDS);
		wp_schedule_single_event(time(), 'speedycache_preload_split');
	}

	static function cache(){
		global $speedycache;

		$preload_urls = get_transient('speedycache_preload_transient');
		$cache_urls = 0;

		if(empty($preload_urls) || !is_array($preload_urls)){
			return;
		}

		foreach($preload_urls as $key => $url){
			if($cache_urls >= 10){
				break;
			}

			wp_remote_get($url, [
				'headers' => [
					'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36'
				],
				'timeout' => 0.01,
				'blocking' => false,
				'sslverify' => false,
			]);

			// Preload mobile version too
			if(!empty($speedycache->options['mobile_theme'])){
				wp_remote_get($url, [
					'headers' => [
						'User-Agent' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/114.0.5735.99 Mobile/15E148 Safari/604.1'
					],
					'timeout' => 0.01,
					'blocking' => false,
					'sslverify' => false,
				]);
			}

			unset($preload_urls[$key]); // We remove from the list to be preloaded
			$cache_urls++;
		}
		
		if(empty($preload_urls)){
			set_transient('speedycache_preload_transient', [], HOUR_IN_SECONDS);
			return;
		}

		wp_schedule_single_event(time() + 60, 'speedycache_preload_split');
		set_transient('speedycache_preload_transient', $preload_urls, HOUR_IN_SECONDS);
	}
	
	// This will push a request to preload URLS
	// TODO: need to add a lock here
	static function url($urls){

		if(!is_array($urls)){
			$urls = [$urls];
		}

		$preload_urls = get_transient('speedycache_preload_transient');
		if(empty($preload_urls) || !is_array($preload_urls)){
			$preload_urls = [];
		}

		$preload_urls = array_merge($preload_urls, $urls);
		$preload_urls = array_unique($preload_urls);

		set_transient('speedycache_preload_transient', $preload_urls, HOUR_IN_SECONDS);

		if(!wp_next_scheduled('speedycache_preload_split')){
			wp_schedule_single_event(time() + 60, 'speedycache_preload_split');
		}
	}
}
PK��f\xh�wwlicense.phpnu�[���<?php

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

include_once SPEEDYCACHE_DIR . '/main/settings.php';

function speedycache_license_page(){
	global $speedycache;
	
	if(isset($_REQUEST['save_speedycache_license'])){
		speedycache_license();
	}
	
	speedycache_add_javascript();
	settings_errors('speedycache-notice');
	
	?>
	
	<div class="speedycache-setting-content">
		<div class="speedycache-tab-group" style="width:78%">
			<table class="wp-list-table fixed striped users speedycache-license-table" cellspacing="1" border="0" width="78%" cellpadding="10" align="center">
				<tbody>
					<tr>				
						<th align="left" width="25%"><?php esc_html_e('SpeedyCache Version', 'speedycache'); ?></th>
						<td><?php
							echo SPEEDYCACHE_PRO_VERSION.(defined('SPEEDYCACHE_PRO') ? ' (Pro Version)' : '');
						?>
						</td>
					</tr>
					<tr>			
						<th align="left" valign="top"><?php esc_html_e('SpeedyCache License', 'speedycache'); ?></th>
						<td align="left">
							<form method="post" action="">
								<span style="color:var(--speedycache-red)">
									<?php echo (defined('SPEEDYCACHE_PRO') && empty($speedycache->license) ? '<span style="color:var(--speedycache-red)">Unlicensed</span> &nbsp; &nbsp;' : '')?>
								</span>
								<input type="hidden" name="speedycache_license_nonce" value="<?php echo wp_create_nonce('speedycache_license');?>"/>
								<input type="text" name="speedycache_license" value="<?php echo (empty($speedycache->license) ? empty($_POST['speedycache_license']) ? '' : speedycache_optpost('speedycache_license') : $speedycache->license['license'])?>" size="30" placeholder="e.g. SPDFY-11111-22222-33333-44444" style="width:300px;"> &nbsp; 
								<input name="save_speedycache_license" class="speedycache-btn speedycache-btn-primary" value="Update License" type="submit">
							</form>
							<?php if(!empty($speedycache->license)){
								
								$expires = $speedycache->license['expires'];
								$expires = substr($expires, 0, 4).'/'.substr($expires, 4, 2).'/'.substr($expires, 6);
								
								echo '<div style="margin-top:10px;">License Status : '.(empty($speedycache->license['status_txt']) ? 'N.A.' : wp_kses_post($speedycache->license['status_txt'])).' &nbsp; &nbsp; &nbsp; 
								'.($speedycache->license['expires'] <= date('Ymd') ? 'License Expires : <span style="color:var(--speedycache-red)">'.esc_attr($expires).'</span>' : (empty($speedycache->license['has_plid']) ? 'License Expires : ' . esc_html($expires) : '')).'
								</div>';
								
							}?>
						</td>
					</tr>
					<tr>
						<th align="left">URL</th>
						<td><?php echo get_site_url(); ?></td>
					</tr>
					<tr>				
						<th align="left">Path</th>
						<td><?php echo ABSPATH; ?></td>
					</tr>
					<tr>				
						<th align="left">Server's IP Address</th>
						<td><?php echo esc_html($_SERVER['SERVER_ADDR']); ?></td>
					</tr>
					<tr>				
						<th align="left">.htaccess is writable</th>
						<td><?php echo (is_writable(ABSPATH.'/.htaccess') ? '<span style="color:var(--speedycache-red)">Yes</span>' : '<span style="color:green">No</span>');?></td>
					</tr>		
				</tbody>
			</table>
		</div>
	<?php speedycache_promotion_tmpl(); ?>
	</div>
<?php
	speedycache_page_footer(true);
}

function speedycache_license(){
	global $speedycache, $lic_resp;

	if(!wp_verify_nonce($_POST['speedycache_license_nonce'], 'speedycache_license')){
		speedycache_notify(array(__('Security Check Failed', 'speedycache'),'error'));
		return;
	}

	$license = sanitize_key($_POST['speedycache_license']);
	
	if(empty($license)){
		speedycache_notify(array(__('The license key was not submitted', 'speedycache'),'error'));
		return;
	}
	
	speedycache_pro_load_license($license);
	
	if(!is_array($lic_resp)){
		speedycache_notify(array(__('The response was malformed<br>'.var_export($lic_resp, true), 'speedycache'), 'error'));
		return;
	}

	$json = json_decode($lic_resp['body'], true);
	
	// Save the License
	if(empty($json['license'])){
		speedycache_notify(array(__('The license key is invalid', 'speedycache'), 'error'));
		return;
		
	}
	
}
PK��f\�Z>P%P%email-reports.phpnu�[���
<?php
// We need the ABSPATH

if (!defined('ABSPATH')) exit;

// Styles and Scripts
wp_enqueue_style( 'gosmtp-admin' );
wp_enqueue_script( 'gosmtp-admin' );

function gosmtp_reports_table(){
	global $gosmtp;
	
	if(empty($gosmtp->options['logs']['enable_logs']) ){
		echo '<h1>Email report is disabled</h1>
			<div class="error is-dismissiable notice">
			<p>'.__('To view email reports, please enable email logs from GoSMTP').' <a href="'.admin_url('admin.php?page=gosmtp#logs-settings').'">'.__('settings').'</a>.</p>
		</div>';
		return;
	}

	$date = gosmtp_optget('date');
	$custom_start = gosmtp_optget('start-date');
	$custom_end = gosmtp_optget('end-date');
	$search = gosmtp_optget('search_email_reports');
	$multiselect = gosmtp_optget('multiselect');
	$all_data = array();

	$logger = new GOSMTP\Logger();
		
	// Appropriate date setup
	if($date == 'custom_date'){
		$start = $custom_start;
		$end = $custom_end;
	
		if($start != '' && $end == ''){
			$end = date("Y-m-d");
		}
	}else if($date == 'all' || $date == ''){
		$start = '';
		$end = '';
	}else{
		$start = date('Y-m-d', strtotime('-'.$date.' days'));
		$end = date("Y-m-d");
	}

	// Assign all data in option array
	$options = array(
		'interval' => array(
			'start' => $start,
			'end' => $end
		), 
		'search' => $search,
		'multiselect' => $multiselect,
		'pagination' => false,
	);

	$email_logs = $logger->get_logs('records', 0, $options);

	// TODO: Get only records as paged
	$mails = gosmtp_group_by($email_logs);

	// Pagination
	$perpage = 10;
	$curpage = (int) gosmtp_optget('paged', 1);
	$records_ct = count($mails);
	$tpages = ceil($records_ct / $perpage);
	$offset = ($curpage - 1) * $perpage;

	$args = array(
		'base' => '%_%',
		'format' => '?paged=%#%',
		'total' => $tpages,
		'current' => $curpage,
		'show_all' => false,
		'end_size' => 1,
		'mid_size' => 2,
		'prev_next' => true,
		'type' => 'array',
		'add_args' => false
	);

	// Set limit value
	$limit = array(
		'perpage' => $perpage,
		'offset' => $offset,
	);

	$pages = paginate_links( $args );

	$table_cols = array(
		'subject' => __('Subject'),
		'from' => __('From'),
		'to' => __('To'),
		'resent_count' => __('Resent'),
		'retries' => __('Retry'),
		'sent' => __('Sent'),
		'failed' => __('Failed'),
		'total' => __('Total')
	);
?>

<div class="wrap">
	<div class="wrap_header gosmtp-relative">
		<h1><?php _e('Email Reports') ?></h1>
	</div>
	<div class="gosmtp-upper-elements-container">
		<form action="<?php echo admin_url('admin.php'); ?>" method="get">
			<input type="hidden" name="page" value="email_reports">
			<div class="gosmtp-element-container">
				<div class=" gosmtp-report-search-container">
					<div class="gosmtp-search-report-list-icon">
						<span class="dashicons dashicons-search"></span>
						<input type="search" id="gosmtp-search_email" placeholder="Search" name="search_email_reports"/>
					</div>
				</div>
				<div class="gosmtp-fiter-main-container">
					<div class="gosmtp-fiter-container">
						<span class="multiselect"><?php _e('Select Filter') ?></span>
						<ul class="multiselect-options">
							<li><input type='checkbox' class="multiselect-checkbox" id="all" value='all'><label for="all"><?php _e('Select all') ?></label></li>
							<li><input type='checkbox' class="multiselect-checkbox" id="subject" value='subject' name="multiselect[]"><label for="subject"><?php _e('Subject') ?></label></li>
							<li><input type='checkbox' class="multiselect-checkbox" id="from" value='from' name="multiselect[]"><label for="from"><?php _e('From') ?></label></li> 
							<li><input type='checkbox' class="multiselect-checkbox" id="to" value='to' name="multiselect[]"><label for="to"><?php _e('To') ?></label></li>
						</ul>
						<span class="dropdown dashicons dashicons-arrow-down-alt2"></span>
					</div>
				</div>
				<div class="gosmtp-date-option-container">
					<select id="gosmtp-date-option-filter" name='date'>
						<option value="all" selected disabled><?php _e('Select date') ?></option>
						<option value="7"><?php _e('Last 7 days') ?></option>
						<option value="14"><?php _e('Last 14 days') ?></option>
						<option value="30"><?php _e('Last 30 days') ?></option>
						<option value="custom_date"><?php _e('Custom date') ?></option>
					</select>
					<div class='gosmtp-report-date-container'>
						<input type="date" name="start-date" id="gosmtp-start-date" placeholder="Start date" /> 
						<input type="date" name="end-date" id="gosmtp-end-date" placeholder="End date" />
					</div>
				</div>
				<div class=" gosmtp-report-submit-container">
					<input type="submit" class="button button-primary submit-email-reports" id="submit-email-reports" name="submit-email-reports" value="Search"/>
				</div>
			</div>	
		</form>
		<!-- <div class="graph-container">
			<canvas id="myChart"></canvas>
		</div> -->
	</div>	
	<table cellspacing="0" cellpadding="8" border="0" width="100%" class="gosmtp-email-report" id="gosmtp-email-reports">
		<tr>
			<td colspan="9">
				<h2><?php _e('Email Reports') ?></h2>
			</td>
		</tr>
		<tr>
		<?php
		foreach($table_cols as $col){
			echo '<th>'.$col.'</th>';
		}
		?>
			<!-- <th><?php _e('Graph') ?></th> -->
		</tr>
		<?php
		// Mail list array
		$mail_list = gosmtp_group_by($email_logs, $limit);
		
		// Append HTML value
		if(!empty($mail_list)){

			$all_data = array();
			foreach($mail_list as $main_key => $mail){
				
				$mail_array = $mail['total'];
					
				echo "<tr>";
				
				foreach($table_cols as $ck => $col){
					echo '<td>'.$mail_array[$ck].'</td>';
				}
				
				echo '<!-- <td>
						<span class ="dashicons dashicons-chart-area email_report_icon" data-data="'.$main_key.'" onclick="gosmtp_load_graph([\"'.$main_key.'\"])"></span>
					</td> -->
				</tr>';

				// Add by date data in all data
				array_push($all_data, $mail['by_dates']);
			}
		}else{
			// Empty all data when no result found 
			$all_data = array();
		?>
		<tr>
			<td colspan="9" class="gosmtp-empty-row"><?php _e('Records not found!'); ?></td>
		</tr>
		<?php 
		}
	?>
	</table>
	
	<?php 
	// Render pagination HTML
	if( is_array( $pages ) ){
		echo '<div class="gosmtp-pagination"><ul class="gosmtp-pagination-wrap">';
		
		foreach ( $pages as $page ) {
			echo '<li class="gosmtp-pagination-links">'.$page.'</li>';
		}
		
		echo '</ul></div>';
	} 
	?>
</div>
<script>
	var gosmtp_ajaxurl = "<?php echo admin_url( 'admin-ajax.php' ); ?>?";
	var gosmtp_ajax_nonce = "<?php echo wp_create_nonce('gosmtp_ajax'); ?>";
</script>

<?php
}

// Set Custom array
function gosmtp_set_custom_array($val){

	$return = array();

	foreach($val as $kk => $vv){
		
		switch($kk){
			case 'to':
				$tos = maybe_unserialize($vv);
				$to_list = [];
				
				foreach($tos as $keys => $to){
					$to_list[] = $to[0];
				}
				
				$return['total']['to'] = implode(',', $to_list);
				break;
			case 'status':
				if($vv == 'sent'){
					$return['total']['sent'] = 1;
					$return['total']['failed'] = 0;
				}elseif($vv == 'failed'){
					$return['total']['sent'] = 0;
					$return['total']['failed'] = 1;
				}
				break;
			case 'subject': 
				$return['total'][$kk] = empty($vv) ? '[No Subject]' : $vv;
	    			break;
			default:
				$return['total'][$kk] = $vv;
		}
		
	}
	
	$return['total']['total'] = $return['total']['sent'] + $return['total']['failed'];

	$return['by_dates'][$val->created_at] = array(
		'sent' => $return['total']['sent'],
		'failed' => $return['total']['failed'],
		'retries' => $return['total']['retries'],
		'resent_count' => $return['total']['resent_count'],
		'total' => $return['total']['total'],
	);
	
	return $return;

}

// Generate Array with group by
function gosmtp_group_by($logs, $limit = array(), $multiselect = array('subject', 'from', 'to')){
	
	$groups = array();
	$i = 0;
	$key_array = array();

	if(empty($logs)){
		return array();
	}
	
	foreach($logs as $val){
		
		$val = gosmtp_set_custom_array($val);
		$total = $val['total'];
		
		$groups_val = array();
		foreach($multiselect as $multi_val){
			array_push($groups_val, $total[$multi_val]);
		}

		// Add new group
		if(!in_array($groups_val, $key_array)){
			
			$key_array[$i] = $groups_val;
			
			$groups[$i]['total'] = $val['total'];
			$groups[$i]['by_dates'] = $val['by_dates'];
			$i++;
		
		}else{
			foreach($key_array as $kk => $vv){
				
				if($groups_val != $vv){
					continue;
				}
				
				$group_total = $groups[$kk]['total'];
				
				$total['sent'] = $group_total['sent'] + $total['sent'];
				$total['failed'] = $group_total['failed'] + $total['failed'];
				$total['retries'] = $group_total['retries'] + $total['retries'];
				$total['resent_count'] = $group_total['resent_count'] + $total['resent_count'];
				$total['total'] = $group_total['total'] + $total['total'];
				
				$groups[$kk]['total'] = $total;
				$groups[$kk]['by_dates'][array_keys($val['by_dates'])[0]] = $val['by_dates'][array_keys($val['by_dates'])[0]];
			}
		}
	}

	// Set limit for Pagination
	if(!empty($limit)){
		
		$limit_res = array();
		
		for($i = 0; $i< $limit['perpage']; $i++){
			$j = $i+$limit['offset'];	

			if(isset($groups[$j])){
				array_push($limit_res, $groups[$j] );
			}
		}
		
		$groups = $limit_res;
	}
	
	return $groups;		   
}
PK��f\��P*P*
export.phpnu�[���<?php
/*
* GoSMTP Export Logs
* https://gosmtp.net
* (c) Softaculous Team
*/

if(!defined('ABSPATH')){
	die('Hacking Attempt!');
}

// Filter HTML data
function gosmtp_filterData(&$str){ 
    $str = preg_replace("/\t/", "\\t", $str); 
    $str = preg_replace("/\r?\n/", "\\n", $str);
	
    if(strstr($str, '"')){
		$str = '"' . str_replace('"', '""', $str) . '"';
	}
}

// Export CSV files
function gosmtp_export_csv($data){
	
	$fileName = "gosmtp_export_".date('Y_m_d') . ".csv";
	
	header('Content-Type: text/csv; charset=utf-8');
	header("Content-Disposition: attachment; filename=$fileName");
	header("Content-Description: File Transfer");
	
	$file = fopen('php://output', 'w');
	
	// We have all the field sequences in the first line
	// Get the key of attachments form the sequences
	$attachment_key = array_search('attachments', $data[0], true);

	foreach($data as $kk => $val){
		
		// Skip attachment explode for first row
		if( $kk != 0 && $attachment_key !== false && !empty($val[$attachment_key]) ){
			
			$attachment = explode(',', $val[$attachment_key]);
			$attach = ''; 
			
			foreach($attachment as $attach_val){
				$attach .= explode('*', $attach_val)[2].', ';
			}
			
			$val[$attachment_key] = rtrim($attach, ', ');
		}
		
		fputcsv($file, array_values($val));
	}
	
	fclose($file);
	wp_die();
}

// Export XML files
function gosmtp_export_xls($data){
	
	$filename = "gosmtp_export_".date('Ymd') . ".xls";
	
	header("Content-Type: application/vnd.ms-excel");
	header("Content-Disposition: attachment; filename=\"$filename\"");
	
	// We have all the field sequences in the first line
	// Get the key of attachments form the sequences
	$attachment_key =  array_search('attachments', $data[0], true);

	foreach($data as $kk => $val) {
		
		array_walk($val, 'gosmtp_filterData');
		
		// Skip attachment explode for first row
		if( $kk != 0 && $attachment_key !== false && !empty($val[$attachment_key]) ){
			$attachment = explode(',', $val[$attachment_key]);
			$attach ="";
			
			foreach($attachment as $attach_val){
				$attach .= explode('*', $attach_val)[2].', ';
			}
			
			$val[$attachment_key] = rtrim($attach, ", ");
		}
		
		echo esc_html(implode("\t", array_values($val)) . "\n");
	}

	wp_die();
}

// Export EML files
function gosmtp_export_eml($data){
	
	$files = array();
	$first_row = $data[0];
	
	// Replace key with value
	$fields = array_flip($data[0]);
	
	$attachment_key = $fields['attachments'];
	
	foreach($data as $key => $value){
		
		// Skip for first row
		if($key == 0){
			continue;
		}
		
		$files[$key] = "gosmtp_export_".$key."_".date('Ymd') . ".eml";	
		
		header("Content-Type: application/application/eml");
		header("Content-Disposition: attachment; filename=\"$files[$key]\"");
		
		$output_buffer = fopen('php://output', 'w');
		$boundary = md5(uniqid(mt_rand()));
		
		$output_buffer = 
'MIME-Version: 1.0
Date: '.date_format( date_create( $value[$fields['created_at']] ), 'd-m-y H:i:s').' +0100
From: '.$value[$fields['from']].'
To: '.$value[$fields['to']].'
Cc: '.$value[$fields['cc']].'
Ccc: '.$value[$fields['bcc']].'
Subject: '.$value[$fields['subject']].'
Content-Type: multipart/mixed; boundary="'.$boundary.'"

This is a message with multiple parts in MIME format.

--'.$boundary.'
Content-Type: '.$value[$fields['content-type']].' 

'.$value[$fields['body']];
		
		// Added attachment if any
		if(isset($value[$attachment_key]) && !empty($value[$attachment_key])){
			
			$attachment = explode(',', $value[$attachment_key]);
			
			foreach($attachment as $attach){

				$all_attach = explode('*', $attach);
				$attachment_file = file_get_contents(trim($all_attach[0]));
				
				if(empty($attachment_file)){
					continue;
				}
				
				$encoded_attach = base64_encode($attachment_file);
				$type = $all_attach[4];
				$base_name = $all_attach[2];
				
				$output_buffer .=
'
--'.$boundary.'
Content-Type: '.$type.';name="'.$base_name.'"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;filename="'.$base_name.'"


'.$encoded_attach;
			}
		}
		
		file_put_contents($files[$key], $output_buffer);  
	}
		
	$zipname = "gosmtp_export_".date('Ymd') . ".zip";		
	$zip = new ZipArchive;
	$zip->open($zipname, ZipArchive::CREATE);
	
	foreach($files as $file){
		$zip->addFile($file);
	}
	
	$zip->close();
	
	header('Content-Type: application/zip');
	header('Content-disposition: attachment; filename='.$zipname);
	header('Content-Length: ' . filesize($zipname));
	
	readfile($zipname);
	unlink($zipname);
	
	wp_die();
}

// Export page HTML
function gosmtp_export_page(){

	// Styles and Scripts
	wp_enqueue_style( 'gosmtp-admin' );
	wp_enqueue_script( 'gosmtp-admin' );

	$common_field = array(
		'to' => __('To Address'),
		'from' => __('From Address'),
		'subject' => __('Subject'),
		'body' => __('Body'),
		'created_at' => __('Created At'),
		'attachments' => __('Attachments'),
	);

	$addtition_field = array(
		'status' => __('Status'),
		'reply-to' => __('Reply To'),
		'cc' => __('Carbon Copy (CC)'),
		'bcc' => __('Blind Carbon Copy (BCC)'),
		'provider' => __('Provider'),
		'response' => __('Response'),
		'source' => __('Source'),
		'content-type' => __('Content Type')
	);

	$search_field = array(
		'from' => __('from'),
		'to' => __('To'),
		'subject' => __('Subject'),
		'body' => __('Body'),
	);

	$all_field = array_merge(array_keys($common_field), array_keys($addtition_field));
	?>

	<div class="gosmtp-row gosmtp-export-container">
		<form action="" method="post" id="gosmtp_export">
			<input type="hidden" name="page" value="export">
			<input type="hidden" name="all_field" value="<?php echo implode(',', $all_field)?>">
			<div class="gosmtp-row">
				<div class="gosmtp-col-12">
					<h1> <span class="dashicons dashicons-media-archive"></span><?php _e('Export Settings'); ?></h1>
				</div>
			</div>
			<hr>
			<div class="gosmtp-row">
				<div class="gosmtp-col-3">
					<h3><?php _e('Format'); ?></h3>
				</div>
				<div class="gosmtp-col-6">
					<div class="gosmtp-radio-list">
						<input type="radio" name="format" value="csv" id="csv" checked> <label for="csv" class="active_radio_tab"><?php echo __('CSV').'(.csv)'; ?></label>
						<input type="radio" name="format" value="xls" id ="xls"> <label for="xls"><?php echo __('Microsoft Excel').'(.xls)'; ?></label>
						<input type="radio" name="format" value="eml" id="eml"> <label for="eml"><?php echo __('EML').'(.eml)'; ?> </label>
					</div>
				</div>
			</div>
			<div class="gosmtp-row ">
				<div class="gosmtp-col-3">
					<h3><?php _e('Export Custom Field'); ?></h3>
				</div>
				<div class="gosmtp-col-9">
					<label class="gosmtp-switch">
					<input type="checkbox" name="custom-field"  id="custom-field" checked>
						<span class="gosmtp-slider gosmtp-round"></span>
					</label>
				</div>
			</div>
			<div class="gosmtp-row can-hidden">
				<div class="gosmtp-col-3">
					<h3><?php _e('Common Information'); ?></h3>
				</div>
				<div class="gosmtp-col-6">
					<div class="gosmtp-fiter-container">
						<span class="multiselect"><?php _e('Select common field'); ?></span>
						<ul class="multiselect-options">
							<li><input type="checkbox" class="multiselect-checkbox" id="all" value="all" checked><label for="all"><?php _e('All'); ?></label></li>
						<?php
							foreach($common_field as $key => $val){
								echo"<li><input type='checkbox' checked class='multiselect-checkbox' name ='common_information[]'  id='$key' value='$key'><label for='$key'>$val</label></li>";
							}	
						?>
						</ul>
						<span class="dropdown dashicons dashicons-arrow-down-alt2"></span>
					</div>
				</div>
			</div>
			<div class="gosmtp-row can-hidden">
				<div class="gosmtp-col-3">
					<h3><?php _e('Additional Information'); ?></h3>
				</div>
				<div class="gosmtp-col-6">
					<div class="gosmtp-fiter-container">
						<span class="multiselect"><?php _e('Select common field'); ?></span>
						<ul class="multiselect-options">
							<li><input type="checkbox" class="multiselect-checkbox" id="all" value="all"><label for="all"><?php _e('All'); ?></label></li>
						<?php
							foreach($addtition_field as $key => $val){
								echo "<li><input type='checkbox' name='addtional_information[]' class='multiselect-checkbox' id='$key' value='$key'><label for='$key' checked>$val</label></li>";
							}	
						?>
						</ul>
						<span class="dropdown dashicons dashicons-arrow-down-alt2"></span>
					</div>
				</div>
			</div>
			<div class="gosmtp-row ">
				<div class="gosmtp-col-3">
					<h3><?php _e('Custom Date Range'); ?></h3>
				</div>
				<div class="gosmtp-col-6">
					<div class="gosmtp-date-container">
						<input type="date" name="start-date" id="gosmtp-start-date" placeholder="Start date" /> 
						<input type="date" name="end-date" id="gosmtp-end-date" placeholder="End date" />
					</div>
				</div>
			</div>
			<div class="gosmtp-row ">
				<div class="gosmtp-col-3">
					<h3><?php _e('Search In'); ?></h3>
				</div>
				<div class="gosmtp-col-6">
					<div class="gosmtp-inner-row ">
						<div class="gosmtp-col-8">
							<div class="gosmtp-fiter-container ">
								<span class="multiselect"><?php _e('Select addtitional field'); ?></span>
								<ul class="multiselect-options">
									<li><input type="checkbox" class="multiselect-checkbox" id="all" value="all" ><label for="all"><?php _e('All'); ?></label></li>
								<?php
									foreach($search_field as $key => $val){
										echo "<li><input type='checkbox' name='search_type[]' class='multiselect-checkbox' id='$key' value='$key'><label for='$key'>$val</label></li>";
									}	
								?>
								</ul>
								<span class="dropdown dashicons dashicons-arrow-down-alt2"></span>
							</div>
						</div>
						<div class="gosmtp-col-4">
							<div class="gosmtp-search-report-list-icon">
								<span class="dashicons dashicons-search"></span>
								<input type="search" id="gosmtp-search_email" placeholder="Search" name="search">
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="gosmtp-row ">
				<div class="gosmtp-col-3">
					<button class="button button-primary gosmtp-loading-button">
						<span class="dashicons dashicons-image-rotate"></span>
						<input type="submit" name="export" value="Export" >
					</button>
				</div>
			</div>
		</form>
	</div>

	<script>
		var gosmtp_ajaxurl="<?php echo admin_url( 'admin-ajax.php' ) ?>?";
		var gosmtp_ajax_nonce="<?php echo wp_create_nonce('gosmtp_ajax') ?>"; 
	</script>
<?php
}PK��f\�_��wwgosmtp-init.phpnu�[���<?php
/*
* GoSMTP
* https://gosmtp.net
* (c) Softaculous Team
*/

// Are we being accessed directly ?
if(!defined('GOSMTP_PRO_VERSION')) {
	exit('Hacking Attempt !');
}

// Prevent update of gosmtp free
// This also work for auto update
add_filter('site_transient_update_plugins', 'gosmtp_pro_disable_manual_update_for_plugin');
add_filter('pre_site_transient_update_plugins', 'gosmtp_pro_disable_manual_update_for_plugin');

// Auto update free version after update pro version
add_action('upgrader_process_complete', 'gosmtp_pro_update_free_after_pro', 10, 2);

add_action('plugins_loaded', 'gosmtp_pro_load_plugin');
function gosmtp_pro_load_plugin(){
	global $gosmtp;
	
	if(empty($gosmtp)){
		$gosmtp = new stdClass();
	}

	// Load license
	gosmtp_pro_load_license();
	
	gosmtp_pro_update_checker();
	
	// Check for updates
	include_once(GOSMTP_PRO_DIR.'/main/plugin-update-checker.php');
	$gosmtp_updater = Gosmtp_PucFactory::buildUpdateChecker(gosmtp_pro_api_url().'updates.php?version='.GOSMTP_PRO_VERSION, GOSMTP_PRO_FILE);
	
	// Add the license key to query arguments
	$gosmtp_updater->addQueryArgFilter('gosmtp_pro_updater_filter_args');
	
	// Show the text to install the license key
	add_filter('puc_manual_final_check_link-gosmtp-pro', 'gosmtp_pro_updater_check_link', 10, 1);
	
	// Nag informing the user to install the free version.
	if(current_user_can('activate_plugins')){
		add_action('admin_notices', 'gosmtp_pro_free_version_nag', 9);
		add_action('admin_menu', 'gosmtp_pro_add_menu', 9);
	}

	$is_network_wide = gosmtp_pro_is_network_active('gosmtp-pro');
	$_do_version = get_option('gosmtp_version');
	$req_free_update = !empty($_do_version) && version_compare($_do_version, '1.0.7', '<');
	
	if($is_network_wide){
		$free_installed = get_site_option('gosmtp_free_installed');
	}else{
		$free_installed = get_option('gosmtp_free_installed');
	}
	
	if(!empty($free_installed)){
		return;
	}
	
	// Include the necessary stuff
	include_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
	include_once(ABSPATH . 'wp-admin/includes/plugin.php');
	include_once(ABSPATH . 'wp-admin/includes/file.php');
	
	if(file_exists(WP_PLUGIN_DIR . '/gosmtp/gosmtp.php') && is_plugin_inactive('/gosmtp/gosmtp.php') && empty($req_free_update)) {
		
		if($is_network_wide){
			update_site_option('gosmtp_free_installed', time());
		}else{
			update_option('gosmtp_free_installed', time());
		}
		
		activate_plugin('/gosmtp/gosmtp.php', '', $is_network_wide);
		remove_action('admin_notices', 'gosmtp_pro_free_version_nag', 9);
		remove_action('admin_menu', 'gosmtp_pro_add_menu', 9);
		return;
	}
	
	// Includes necessary for Plugin_Upgrader and Plugin_Installer_Skin
	include_once(ABSPATH . 'wp-admin/includes/misc.php');
	include_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');

	// Filter to prevent the activate text
	add_filter('install_plugin_complete_actions', 'gosmtp_pro_prevent_activation_text', 10, 3);
	 
	$upgrader = new Plugin_Upgrader(new WP_Ajax_Upgrader_Skin());
	
	// Upgrade the plugin to the latest version of free already installed.
	if(!empty($req_free_update)){
		$installed = $upgrader->upgrade('gosmtp/gosmtp.php');
	}else{
		$installed = $upgrader->install('https://downloads.wordpress.org/plugin/gosmtp.zip');
	}
	
	if(!is_wp_error($installed) && $installed){
		
		if($is_network_wide){
			update_site_option('gosmtp_free_installed', time());
		}else{
			update_option('gosmtp_free_installed', time());
		}
		
		activate_plugin('gosmtp/gosmtp.php', '', $is_network_wide);
		remove_action('admin_notices', 'gosmtp_pro_free_version_nag', 9);
		remove_action('admin_menu', 'gosmtp_pro_add_menu', 9);
	}
}

// Do not shows the activation text if 
function gosmtp_pro_prevent_activation_text($install_actions, $api, $plugin_file){
	if($plugin_file == 'gosmtp/gosmtp.php'){
		return array();
	}

	return $install_actions;
}

function gosmtp_pro_free_version_nag(){
	
	$go_version = get_option('gosmtp_version');
	
	$lower_version = __('You have not installed the free version of GoSMTP. GoSMTP Pro depends on the free version, so you must install it first in order to use GoSMTP Pro.');
	
	if(!empty($go_version) && version_compare($go_version, '1.0.7', '<')){
		$lower_version = __('You are using an older version of the free version of GoSMTP, please update GoSMTP to work without any issues');
	}

	echo '<div class="notice notice-error">
		<p style="font-size:16px;">'.esc_html($lower_version).' <a href="'.admin_url('plugin-install.php?s=gosmtp&tab=search').'" class="button button-primary">Install/Update Now</a></p>
	</div>';
}

function gosmtp_pro_add_menu(){
	add_menu_page('GoSMTP Settings', 'GoSMTP', 'activate_plugins', 'gosmtp', 'gosmtp_pro_menu_page');
}

function gosmtp_pro_menu_page(){
	echo '<div style="color: #333;padding: 50px;text-align: center;">
		<h1 style="font-size: 2em;margin-bottom: 10px;">GoSMTP Free version is not installed / outdated!</h>
		<p style=" font-size: 16px;margin-bottom: 20px; font-weight:400;">GoSMTP Pro depends on the free version of GoSMTP, so you need to install / update the free version first.</p>
		<a href="'.admin_url('plugin-install.php?s=gosmtp&tab=search').'" style="text-decoration: none;font-size:16px;">Install/Update Now</a>
	</div>';
}PK��f\����%!%!weekly_email_reports.phpnu�[���<?php

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

// defining function
function gosmtp_cal_percentage($num_amount, $num_total) {
	
	if($num_total == 0){
		return '0%';
	}
	
	$count = ($num_amount / $num_total) * 100;
	$count = number_format($count, 0);
	
	return $count.'%';
}

// Weekly Report HTML
function gosmtp_send_email_reports($send_email = false){
    global $gosmtp;

    if(!($gosmtp->options['weekly_reports']['timestamp'] <= time()) && $send_email){
        return;
    }
	
    if(!function_exists('gosmtp_group_by')){
        include_once GOSMTP_PRO_DIR .'/main/email-reports.php';
    }
    	
	$logger = new GOSMTP\Logger();
	$week = $gosmtp->options['weekly_reports']['weekday'];
	$last_week = date("Y-m-d", strtotime('last '.$week, strtotime('tomorrow')));
	$start = date('Y-m-d', strtotime($last_week. ' -7 days'));
	$end = $last_week;
	$multiselect = array('subject');
	
	$options = array(
		'interval' => array(
			'start' => $start,
			'end' => $end
		),
		'pagination' => false,
	);
	
	$email_logs = $logger->get_logs('records', '', $options);
    $mails = gosmtp_group_by($email_logs, array(), $multiselect);
	
	$sent = $failed = $total = 0;
	
	foreach($mails as $key =>$val){
		$sent = $sent + $val['total']['sent'];
		$failed = $failed + $val['total']['failed'];
		$total = $total + $val['total']['total'];
	}   
	
	echo'<div style="padding:0px 180px">"';
	$email = '<html>
<head>
	<meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8""/>
	<meta name=""viewport"" content=""width=device-width, initial-scale=1.0""/>
	<!--[if !mso]><!-->
	<meta http-equiv=""X-UA-Compatible"" content=""IE=edge""/>
	<!--<![endif]-->
	<meta name=""color-scheme"" content=""light dark"">
	<meta name=""supported-color-schemes"" content=""light dark"">
	<title>GOSMTP Weekly Email Summary</title>
	<style type=""text/css"">
	/* General styles. */
	*{
		box-sizing: border-box;
	}

	@media only screen and (max-width: 600px) {
		.total-container div h4{
			font-size:13px;
		}
		.total-container div h1{
			font-size:15px;
		}
		.total-container div h1{
			font-size:15px;
		}
		.total-container{
		border:1px solid #bdbdbd;
			
		}
		.total-container div{
			border: none !important;
			padding: 5px 3px !important;
			margin:0px !important;
			border-radius:5px
		}
		.total-container div .mail-icon *{
			width:25px !important;
		}
		.inner-table{
			padding:10px !important;
			width:100% !important;
		}
		.outer-table{
			padding:20px;
		}
		.list_mail div{
			padding:5px 3px !important;
		}
		.inner-table{
			border-spacing:10px !important;
		}
		td{
			padding:5px!important;
		}
		}
	}
</style>
</head>
<body>
	<table style="width:100%; background:#f1f1f1; padding:50px 0px" class="outer-table">
	<tr style="text-align: center;"><td><img src="https://gosmtp.net/sitepad-data/uploads/2023/02/gosmtp-text.png" style="width:250px;text-align: center;"></td></tr>
	<tr><td>
	<table class="inner-table" style="background:white;border-radius:5px;width:70%; padding:30px; table-layout: fixed !important;border-spacing:20px;border: 1px solid #dcdcdc;  margin: 20px auto;border:1px solid #bdbdbd;" >
	<tr>
		<td colspan="3">
			<h3>Hi there,</h3>
		</td>
	</tr>
	<tr>
		<td colspan="3">
			<b>Let\'s take a look at how your emails performed over the last week.</b>
		</td>
	</tr>
	<tr >
		<td colspan="3" style="text-align:center">
		<div class="total-container"> 
			<div style="box-sizing: border-box; padding:20px; height:100%; width:30%; text-align: center; border-radius:5px; display:inline-block; margin:2% 1%;border:1px solid #bdbdbd;">
				<div class="mail-icon" style=" font-size:40px; color:#454545; width:100%; margin:5px 0px;">&#9993;</div>
				<h4 style="color:#454545;margin:5px 0px;">Total Emails</h4>
				<h1 style="margin:5px 0px;">'.$total.'</h1>
				<h2 style="color:#454545;margin:5px 0px;" > &#9650;'.gosmtp_cal_percentage($total, $total).'</h2>
			</div>
			<div style="box-sizing: border-box; padding:20px; height:100%; width:30%; text-align: center; border-radius:5px;display:inline-block;margin:2% 1%;border:1px solid #bdbdbd;">
				<div class="mail-icon" style="font-size:40px; color:#228b22  !important; width:100%;margin:5px 0px;">&#10004;</div>
				<h4 style="color:#228b22 ;margin:5px 0px;">Sent</h4>
				<h1 style="margin:5px 0px;">'.$sent.'</h1>
				<h2 style="color:#228b22 ;margin:5px 0px;"> &#9650;'.gosmtp_cal_percentage($sent, $total).'</h2>
			</div>
			<div style="box-sizing: border-box; padding:20px; height:100%; width:30%; text-align: center; border-radius:5px; display:inline-block;margin:2% 1%;border:1px solid #bdbdbd;">
				<div class="mail-icon" style="font-size:40px; color:red; width:100%;margin:5px 0px;">&#10006;</div>
				<h4 style="color:red;margin:5px 0px;">Failed</h4>
				<h1 style="margin:5px 0px;">'.$failed.'</h1>
				<h2 style="color:red;margin:5px 0px;"> &#9660;'.gosmtp_cal_percentage($failed, $total).'</h2>
			</div>
		</div>   
		</td>
	</tr>
	<tr>
		<td colspan="2">
			<h2>Last Weeks Emails</h2>
		</td>
		<td colspan="1" style="text-align:right">
			<a href="'.admin_url().'/admin.php?page=email_reports&date=custom_date&start-date='.$start.'&end-date='.$end.'">View all Emails</a>
		</td>
	</tr>
	<tr>
		<td colspan="3">
			<hr>
		</td>
	</tr>';
	
	if(!empty($mails)){
		foreach($mails as $key => $val){
			$email .= "<tr><td colspan='3' ><b>".$val['total']['subject']."</b></td></tr>
				<tr style='background:#f1f1f1;'>
				<td colspan='3'class='list_mail'>
					<div style='padding:7px; display:inline-block; width:32%; box-sizing:border-box;'><span style='color:#454545;font-weight:bold;font-size:16px;margin-right:5px;'>&#9993;</span>".$val['total']['total']."</div>
					<div style='padding:7px; display:inline-block; width:32%; box-sizing:border-box;'><span style='color:#228b22; font-weight:bold;font: size 16px;margin-right:5px;'>&#10004;</span>".$val['total']['sent']."(".gosmtp_cal_percentage($val['total']['sent'], $val['total']['total']).")"."</div>
					<div style='padding:7px; display:inline-block; width:32%; box-sizing:border-box;'><span style='color:red;font-weight:bold;font-size:16px;margin-right:5px;'>&#10006;</span>".$val['total']['failed']."(".gosmtp_cal_percentage($val['total']['failed'], $val['total']['total']).")"."</div>
				</td>
			</tr>";
			
			// Print Only 5 Rows
			if($key == 4){
				break;
			}
		}
	}else{
		$email .="<tr >
		<td colspan='3' style='text-align:center'>
			<h4>Email Records were not found this week!</h4>
		</td>
	   </tr>";
	}

	$email .='</table></td></tr></table>
		</body>
	</html>';

	if($send_email || isset($_GET['test_reports'])){
		
		$headers = array( 'Content-Type: text/html; charset=UTF-8' );
		$admin_email = get_option('admin_email');
		
		if(!empty($admin_email)){
			$title = 'Weekly Report';
		    
			if(wp_mail($admin_email, $title, $email, $headers)){
			
				echo '<div class="updated notice is-dismissible">
					<p>'.__('Email Sent successfully to ').' <a href="mailto:'.$admin_email.'">'.$admin_email.'</a>.</p>
				</div>
				<div class="updated notice is-dismissible">
					<p>'.__('Weekly email reports were sent from: '.$start.' to: '.$end.'').' </p>
				</div>';
			}else{
				echo '<div class="error notice is-dismissible">
					<p>'.__('Failed to send email to ').' <a href="mailto:'.$admin_email.'">'.__($admin_email).'</a>'.__('. Plesae check ').'<a href="'.admin_url('admin.php?page=gosmtp-logs').'">'. __(' Email logs ').'</a>'.__('for more info.').'</p>
				</div>';
			}
		    
		}else{
		   echo "<script>alert('Admin email has not yet been set up. Please first configure the admin email.')</script>";
		}
	}
	
	// Update Timestamp
	if($send_email){
		$gosmtp->options['weekly_reports']['timestamp'] = strtotime("next ".$gosmtp->options['weekly_reports']['weekday']);
		
		update_option( 'gosmtp_options', $gosmtp->options );
		
		return;
	}
	
	$email.= '<form style="text-align:center">
		<input type="hidden" name="page"  value="weekly_email_reports">
		<input type="submit" name="test_reports" value = "Send Test Weekly Reports" style="background:var(--blue);color:var(--white);padding:9px 10px;border:none;border-radius:3px;">
		<p>'. __('Note: Test weekly report will be sent to admin email') .'</p>
	</form></div>';
	
	echo $email;
}

?>
PK��f\k�~..mailer/outlook/auth.phpnu�[���<?php
namespace GOSMTP\mailer\outlook;

class Auth{
		
	private $clientId;
	private $clientSecret;
	private $options;
	private $state;
	private $accessTokenMethod = 'POST';

	public function __construct($clientId = '', $clientSecret = '', $state = ''){
		$this->clientId = $clientId;
		$this->clientSecret = $clientSecret;
		$this->state = $state;

		//$this->assertRequiredOptions($this->getConfig());

		$this->options = $this->getConfig();
	}

	public function getAuthUrl(){
		return $this->getAuthorizationUrl();
	}

	public function generateToken($authCode){
		return $this->sendTokenRequest('authorization_code', [
			'code' => $authCode
		]);
	}

	public function sendTokenRequest($type, $params){
		try {
			$tokens = $this->getAccessToken($type, $params);
			return $tokens;
		} catch (\Exception $exception) {
			return new \WP_Error(423, $exception->getMessage());
		}
	}

	public function getRedirectUrl(){
		return rest_url('gosmtp-smtp/outlook_callback');
	}

	private function getConfig(){
		return array(
			'clientId' => $this->clientId,
			'clientSecret' => $this->clientSecret,
			'redirectUri' => $this->getRedirectUrl(),
			'urlAuthorize' => 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize',
			'urlAccessToken' => 'https://login.microsoftonline.com/common/oauth2/v2.0/token',
			'urlResourceOwnerDetails' => '',
			'scopes' => 'offline_access user.read Mail.Send'
		);
	}

	public function getAuthorizationUrl($options = []){
		$base = $this->options['urlAuthorize'];

		$params = $this->getAuthorizationParameters($options);
		$query  = $this->getAuthorizationQuery($params);

		return $this->appendQuery($base, $query);
	}

	private function getAuthorizationParameters($options){
		if(empty($options['state'])){
			$options['state'] = $this->getRandomState().$this->state;
			update_option('_gosmtp_last_generated_state', $options['state']);
		}

		if(empty($options['scope'])){
			$options['scope'] = $this->options['scopes'];
		}

		$options += [
			'response_type'   => 'code',
			'approval_prompt' => 'auto'
		];

		if(is_array($options['scope'])){
			$separator = ',';
			$options['scope'] = implode($separator, $options['scope']);
		}

		// Store the state as it may need to be accessed later on.
		$this->options['state'] = $options['state'];

		// Business code layer might set a different redirect_uri parameter
		// depending on the context, leave it as-is
		if(!isset($options['redirect_uri'])){
			$options['redirect_uri'] = $this->options['redirectUri'];
		}

		$options['client_id'] = $this->options['clientId'];

		return $options;
	}

	/**
	* Appends a query string to a URL.
	*
	* @param  string $url The URL to append the query to
	* @param  string $query The HTTP query string
	* @return string The resulting URL
	*/
	protected function appendQuery($url, $query){
		$query = trim($query, '?&');

		if($query){
			$glue = strstr($url, '?') === false ? '?' : '&';
			return $url . $glue . $query;
		}

		return $url;
	}

	/**
	* Builds the authorization URL's query string.
	*
	* @param  array $params Query parameters
	* @return string Query string
	*/
	protected function getAuthorizationQuery(array $params){
		return $this->buildQueryString($params);
	}

	/**
	* Build a query string from an array.
	*
	* @param array $params
	*
	* @return string
	*/
	protected function buildQueryString(array $params){
		return http_build_query($params, null, '&', \PHP_QUERY_RFC3986);
	}

	/**
	* Verifies that all required options have been passed.
	*
	* @param  array $options
	* @return void
	* @throws \InvalidArgumentException
	*/
	private function assertRequiredOptions(array $options){
		$missing = array_diff_key(array_flip($this->getRequiredOptions()), $options);

		if (!empty($missing)) {
			throw new \InvalidArgumentException(
				'Required options not defined: ' . implode(', ', array_keys($missing))
			);
		}
	}

	/**
	* Returns all options that are required.
	*
	* @return array
	*/
	protected function getRequiredOptions(){
		return [
			'urlAuthorize',
			'urlAccessToken',
			'urlResourceOwnerDetails',
		];
	}

	/**
	* Returns a new random string to use as the state parameter in an
	* authorization flow.
	*
	* @param  int $length Length of the random string to be generated.
	* @return string
	*/
	protected function getRandomState($length = 32){
		// Converting bytes to hex will always double length. Hence, we can reduce
		// the amount of bytes by half to produce the correct length. 
		$state = bin2hex(random_bytes($length / 2));

		update_option('_gosmtp_last_generated_state', $state);

		return $state;
	}

	/**
	* Requests an access token using a specified grant and option set.
	*
	* @param  mixed $grant
	* @param  array $options
	* @throws \Exception
	* @return array tokens
	*/
	public function getAccessToken($grant, array $options = []){
		$params = [
			'client_id' => $this->options['clientId'],
			'client_secret' => $this->options['clientSecret'],
			'redirect_uri'  => $this->options['redirectUri'],
			'grant_type' => $grant,
		];

		$params += $options;

		$requestData = $this->getAccessTokenRequestDetails($params);

		$response = wp_remote_request($requestData['url'], $requestData['params']);

		if(is_wp_error($response)) {
			throw new \Exception(
				$response->get_error_message()
			);
		}

		$responseBody = wp_remote_retrieve_body($response);

		if(false === is_array($response)){
			throw new \Exception(
				'Invalid response received from Authorization Server. Expected JSON.'
			);
		}

		if(empty(['access_token'])){
			throw new \Exception(
				'Invalid response received from Authorization Server.'
			);
		}

		return \json_decode($responseBody, true);
	}

	/**
	* Returns a prepared request for requesting an access token.
	*
	* @param array $params Query string parameters
	* @return array $requestDetails
	*/
	protected function getAccessTokenRequestDetails($params){
		$method  = $this->accessTokenMethod;
		$url     = $this->getAccessTokenUrl($params);
		$options = $this->buildQueryString($params);

		return [
			'url' => $url,
			'params' => [
				'method' => $method,
				'body' => $options,
				'headers' => [
					'content-type' => 'application/x-www-form-urlencoded'
				]
			]
		];
	}

	/**
	* Returns the full URL to use when requesting an access token.
	*
	* @param array $params Query parameters
	* @return string
	*/
	protected function getAccessTokenUrl($params){
		$url = $this->options['urlAccessToken'];

		if($this->accessTokenMethod === 'GET'){
			$query = $this->getAccessTokenQuery($params);
			return $this->appendQuery($url, $query);
		}

		return $url;
	}

	protected function getAccessTokenQuery(array $params){
		return $this->buildQueryString($params);
	}

}
PK��f\����$�$mailer/outlook/outlook.phpnu�[���<?php
/**
 * Class GOSMTP_Mailer_Outlook.
 *
 * @since 1.0.0
 */

namespace GOSMTP\Mailer\Outlook;
 
use GOSMTP\Mailer\Loader;

class Outlook extends Loader{

	var $title = 'Outlook';
	var $mailer = 'outlook';
	var $url = 'https://graph.microsoft.com/v1.0/me/sendMail';
	
	public function send(){
		global $phpmailer;
		
		$phpmailer->isMail();
		$phpmailer->Encoding = 'base64';
		
		if ($phpmailer->preSend()) {
			$response = $this->postSend();
			return $this->handle_response( $response );
		}

		return $this->handle_response(new \WP_Error(400, 'Unable to send mail for some reason!', []));
	}
	
	public function postSend(){
		global $phpmailer;
		
		try{
			$access_token = $this->getAccessToken($this->getMailerOption());
			
			if(is_wp_error($access_token)){ 
				return $access_token->get_error_message();
			}
			
			$mime = chunk_split(base64_encode($phpmailer->getSentMIMEMessage()), 76, "\n");
			
			$params = array(
				'method' => 'POST',
				'headers' => [
					'Authorization' => 'Bearer '. $access_token,
					'Content-Type' => 'text/plain'
				],
				'body' => $mime
			);
			
			$response = wp_remote_request($this->url, $params);
			
			if(is_wp_error($response)){
				$return_response = new \WP_Error($response->get_error_code(), $response->get_error_message(), $response->get_error_messages());
			}else{
				$resp_body = wp_remote_retrieve_body($response);
				$resp_code = wp_remote_retrieve_response_code($response);
				$resp_body = \json_decode($resp_body, true);
				
				if(202 == $resp_code){
					$msgId = isset( $response['headers']['request-id'] ) ? $response['headers']['request-id'] : '';
					$status = __('Email sent successfully');
					$return_response = [
						'status' => true,
						'code' => $resp_code,
						'messageId' => $msgId,
						'message' => $status
					];	
				}else{
					$err_code = $resp_code;
					$error_text = [''];
					if(!empty( $resp_body['error']) && is_array($resp_body['error'])){
						$message = $resp_body['error']['message'];
						$code = !empty( $resp_body['error']['code'] ) ? $resp_body['error']['code'] : '';
						$desc = '';

						if($code === 'ErrorAccessDenied'){
							$desc = esc_html__( 'Note: This issue can also be caused by exceeding the total message size limit. If you are using large attachments, please remove the existing Outlook Mailer OAuth connection in WP Mail SMTP settings and reconnect it. We recently added support for large attachments, but oAuth re-connection is required.');
						}
						
						$error_text[] = $this->message_formatting( $message, $code, $desc );
						
					}else{
						$error_text[] = $this->get_response_error_message($response);
					}
        			
					$error_msg = implode( '\r\n', array_map( 'esc_textarea', array_filter( $error_text ) ) );
					$return_response = new \WP_Error($err_code, $error_msg, $resp_body);
				}
			}
			
		}catch(\Exception $e){
			$return_response = new \WP_Error(423, $e->getMessage(), []);
		}

		return $return_response;
	}

	public function getRedirectUrl($query = ''){

		// TODO check and change this
		return admin_url().'admin.php?page=gosmtp'.$query;
	}

	private function getAccessToken($options){
		$accessToken = $options['access_token'];
		
		// check if expired or will be expired in 300 seconds
		if( ($options['expire_stamp'] - 300) < time()){
			
			$api = new \GOSMTP\mailer\outlook\Auth($options['client_id'], $options['client_secret']);

			$tokens = $api->sendTokenRequest('refresh_token', [
				'refresh_token' => $options['refresh_token']
			]);

			if(is_wp_error($tokens)) {
				return false;
			}

			$this->saveNewTokens($options, $tokens);

			$accessToken = $tokens['access_token'];
		}

		return $accessToken;
	}
	
	private function saveNewTokens($data, $tokens){
		
		if (empty($tokens['access_token']) || empty($tokens['refresh_token'])) {
			return false;
		}

		$this->update_option('access_token', $tokens['access_token'], $this->mailer);
		$this->update_option('refresh_token', $tokens['refresh_token'], $this->mailer);
		$this->update_option('expire_stamp', $tokens['expires_in'] + time(), $this->mailer);
	}
	
	public function load_field(){
		
		$this->outlook_init();
		
		$client_id = $this->getOption('client_id', $this->mailer);
		$client_secret = $this->getOption('client_secret', $this->mailer);
		$access_token = $this->getOption('access_token', $this->mailer);
		$refresh_token = $this->getOption('refresh_token', $this->mailer);
		$mail_type = $this->getOption('mail_type', $this->mailer);
		
		$activate = !empty($client_id) && !empty($client_secret)  && empty($access_token) && empty($refresh_token);
		$deactivate = !empty($refresh_token) && !empty($access_token) && $this->mailer == $mail_type;
		
		$readonly = $deactivate ? 'readonly' : '';

		$state = ($this->conn_id === 0 ? '' : '-'.$this->conn_id);

		$api = new \GOSMTP\mailer\outlook\Auth($client_id, $client_secret, $state);

		$fields = array(
			'client_id' => array(
				'title' => __('Application Client ID'),
				'type' => 'text',
				'attr' => $readonly,
			),
			'client_secret' => array(
				'title' => __('Application Client Secret'),
				'type' => 'password',
				'attr' => $readonly,
				'desc' => __( 'Follow this link to get a Application Client Secret from Outlook: <a href="https://learn.microsoft.com/en-us/azure/industry/training-services/microsoft-community-training/frequently-asked-questions/generate-new-clientsecret-link-to-key-vault" target="_blank">Application Client Secret.</a>' ),
			),
			'redirect_uri' => array(
				'title' => __('Outlook Callback URL'),
				'type' => 'copy', 
				'id' => 'outlook_redirect_uri',
				'attr'=>'readonly',
				'default' => $api->getRedirectUrl(),
				'desc' => __('Use this URL to your APP as Redirect URI.')
			)
		);

		if($activate){
			$fields['get_access_token'] = array(
				'title' => __('Get Access Token'),
				'type' => 'button',
				'class'=>'access_token',
				'default' => __('Authenticate with outlook/Office365 & Get Access Token'),
				'href' => $api->getAuthUrl(),
				'attr' => 'data-field=auth',
			);

		}elseif($deactivate){
			$fields['get_access_token'] = array(
					'title' => __('Deactivate Access Token'),
					'type' => 'button',
					'class'=>'deactivate_token',
					'default' => 'Deactivate Access Token',
					'href' => $this->getRedirectUrl().($this->conn_id !== 0 ? '&type=edit&conn_id='.$this->conn_id.'&act=deactivate_token#gosmtp-connections-settings' : '&act=deactivate_token'),
					'attr' => 'data-field=auth',
				);

		}else{
			$fields['get_access_token'] = array(
				'title' => __('Get Access Token'),
				'type' => 'notice',
				'default' => __('You need to save settings with Client ID and Client Secret before you can proceed.'),
			);
		}
		
		return $fields;
	}

	// Generate access token and refresh token and update in data base.
	public function set_token(){
		$errors = [];
		
		$options = $this->getMailerOption();

		if(empty($options['access_token']) && !empty($options['auth_token'])){
			
			$api = new \GOSMTP\mailer\outlook\Auth($options['client_id'], $options['client_secret']);

			$tokens = $api->generateToken($options['auth_token']);

			if(is_wp_error($tokens) || (is_array($tokens) && isset($tokens['error']))) {
				$err = is_wp_error($tokens) ? $tokens->get_error_message() : __('Mailer Authentication failed!');
				return new \WP_Error(423,  $err);
			}

			$this->saveNewTokens($options, $tokens);

		}elseif(!$authToken && !$accessToken){
				return new \WP_Error(423,  __('Please Provide Auth Token.', 'GOSMTP'));
		}

		return true;
	}

	public function outlook_init(){
		$options = $this->getMailerOption();
		
		// Update auth URl when user succesfull regirect our page
		if( empty($options['access_token']) && empty($options['refresh_token']) && isset( $_GET['auth_code'] ) && isset( $_GET['auth'] ) && $this->mailer == $_GET['auth'] && strlen($this->conn_id) > 0 ){

			if( !empty(gosmtp_optget('conn_id')) && $this->conn_id === 0 ){
				return;
			}

			$auth_code = gosmtp_optget('auth_code');
			$this->update_option('auth_token', $auth_code, $this->mailer);
			$resp = '';
			
			$set_token = $this->set_token();
		
			if(is_wp_error($set_token)){
				$resp = $set_token->get_error_message();
			}else{
				$resp = __('Mailer successfully configured!');
			}

			$query = '';
			if( !is_numeric($this->conn_id) ){
				$query = '&type=edit&conn_id='.$this->conn_id.$query.'#gosmtp-connections-settings';
			}

			echo '<script>
				alert("'.$resp.'");
				var url = "'.$this->getRedirectUrl($query).'";
				history.pushState({urlPath:url},"",url);
			</script>';
		}

		// Delete all the tokens or expire stamp when user click deactivate access token
		if(isset($_GET['act']) && $_GET['act'] == 'deactivate_token'){
			
			if(!empty(gosmtp_optget('conn_id')) && $this->conn_id === 0){
				return;
			}
	
			$this->delete_option('refresh_token', $this->mailer);
			$this->delete_option('expire_stamp', $this->mailer);
			$this->delete_option('expires_in', $this->mailer);
			$this->delete_option('version', $this->mailer);
			$this->delete_option('access_token', $this->mailer);
	
			$query = '';
			if(!is_numeric($this->conn_id)){
				$query = '&type=edit&conn_id='.$this->conn_id.$query.'#gosmtp-connections-settings';
			}

			if(isset($_GET['conn_id'])){
				echo '<script>
					var url = "'.$this->getRedirectUrl($query).'";
					history.pushState({urlPath:url},"",url);
				</script>';
			}
		}
	}
}PK��f\q���]�]!mailer/amazonses/emailservice.phpnu�[���<?php

namespace GOSMTP\mailer\amazonses;

use GOSMTP\mailer\amazonses\EmailServiceRequest;

/**
 *
 * Copyright (c) 2014, Daniel Zahariev.
 * Copyright (c) 2011, Dan Myers.
 * Parts copyright (c) 2008, Donovan Schonknecht.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * - Redistributions of source code must retain the above copyright notice,
 *   this list of conditions and the following disclaimer.
 * - Redistributions in binary form must reproduce the above copyright
 *   notice, this list of conditions and the following disclaimer in the
 *   documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 * This is a modified BSD license (the third clause has been removed).
 * The BSD license may be found here:
 * http://www.opensource.org/licenses/bsd-license.php
 *
 * Amazon Simple Email Service is a trademark of Amazon.com, Inc. or its affiliates.
 *
 * EmailService is based on Donovan Schonknecht's Amazon S3 PHP class, found here:
 * http://undesigned.org.za/2007/10/22/amazon-s3-php-class
 *
 * @copyright 2014 Daniel Zahariev
 * @copyright 2011 Dan Myers
 * @copyright 2008 Donovan Schonknecht
 */

/**
 * EmailService PHP class
 *
 * @link https://github.com/daniel-zahariev/php-aws-ses
 * @package AmazonEmailService
 * @version v0.9.1
 */
class EmailService
{
    /**
     * @link(AWS SES regions, http://docs.aws.amazon.com/ses/latest/DeveloperGuide/regions.html)
     */
    const AWS_US_EAST_1 = 'email.us-east-1.amazonaws.com';
    const AWS_US_WEST_2 = 'email.us-west-2.amazonaws.com';
    const AWS_EU_WEST1 = 'email.eu-west-1.amazonaws.com';

    const REQUEST_SIGNATURE_V3 = 'v3';
    const REQUEST_SIGNATURE_V4 = 'v4';

    /**
     * AWS SES Target host of region
     */
    protected $__host;

    /**
     * AWS SES Access key
     */
    protected $__accessKey;

    /**
     * AWS Secret key
     */
    protected $__secretKey;

    /**
     * Enable/disable
     */
    protected $__trigger_errors;

    /**
     * Controls the reuse of CURL hander for sending a bulk of messages
     * @deprecated
     */
    protected $__bulk_sending_mode = false;

    /**
     * Optionally reusable EmailServiceRequest instance
     */
    protected $__ses_request = null;

    /**
     * Controls CURLOPT_SSL_VERIFYHOST setting for EmailServiceRequest's curl handler
     */
    protected $__verifyHost = true;

    /**
     * Controls CURLOPT_SSL_VERIFYPEER setting for EmailServiceRequest's curl handler
     */
    protected $__verifyPeer = true;

    /**
     * @var string HTTP Request signature version
     */
    protected $__requestSignatureVersion;

    /**
     * Constructor
     *
     * @param string $accessKey Access key
     * @param string $secretKey Secret key
     * @param string $host Amazon Host through which to send the emails
     * @param boolean $trigger_errors Trigger PHP errors when AWS SES API returns an error
     * @param string $requestSignatureVersion Version of the request signature
     */
    public function __construct($accessKey = null, $secretKey = null, $host = self::AWS_US_EAST_1, $trigger_errors = true, $requestSignatureVersion = self::REQUEST_SIGNATURE_V4)
    {
        if ($accessKey !== null && $secretKey !== null) {
            $this->setAuth($accessKey, $secretKey);
        }
        $this->__host = $host;
        $this->__trigger_errors = $trigger_errors;
        $this->__requestSignatureVersion = $requestSignatureVersion;
    }

    /**
     * Set the request signature version
     *
     * @param string $requestSignatureVersion
     * @return EmailService $this
     */
    public function setRequestSignatureVersion($requestSignatureVersion)
    {
        $this->__requestSignatureVersion = $requestSignatureVersion;

        return $this;
    }

    /**
     * @return string
     */
    public function getRequestSignatureVersion()
    {
        return $this->__requestSignatureVersion;
    }

    /**
     * Set AWS access key and secret key
     *
     * @param string $accessKey Access key
     * @param string $secretKey Secret key
     * @return EmailService $this
     */
    public function setAuth($accessKey, $secretKey)
    {
        $this->__accessKey = $accessKey;
        $this->__secretKey = $secretKey;

        return $this;
    }

    /**
     * Set AWS Host
     * @param string $host AWS Host
     */
    public function setHost($host = self::AWS_US_EAST_1)
    {
        $this->__host = $host;

        return $this;
    }

    /**
     * @deprecated
     */
    public function enableVerifyHost($enable = true)
    {
        $this->__verifyHost = (bool)$enable;

        return $this;
    }

    /**
     * @deprecated
     */
    public function enableVerifyPeer($enable = true)
    {
        $this->__verifyPeer = (bool)$enable;

        return $this;
    }

    /**
     * @deprecated
     */
    public function verifyHost()
    {
        return $this->__verifyHost;
    }

    /**
     * @deprecated
     */
    public function verifyPeer()
    {
        return $this->__verifyPeer;
    }


    /**
     * Get AWS target host
     * @return boolean
     */
    public function getHost()
    {
        return $this->__host;
    }

    /**
     * Get AWS SES auth access key
     * @return string
     */
    public function getAccessKey()
    {
        return $this->__accessKey;
    }

    /**
     * Get AWS SES auth secret key
     * @return string
     */
    public function getSecretKey()
    {
        return $this->__secretKey;
    }

    /**
     * Get the verify peer CURL mode
     * @return boolean
     */
    public function getVerifyPeer()
    {
        return $this->__verifyPeer;
    }

    /**
     * Get the verify host CURL mode
     * @return boolean
     */
    public function getVerifyHost()
    {
        return $this->__verifyHost;
    }

    /**
     * Get bulk email sending mode
     * @return boolean
     * @deprecated
     */
    public function getBulkMode()
    {
        return $this->__bulk_sending_mode;
    }


    /**
     * Enable/disable CURLOPT_SSL_VERIFYHOST for EmailServiceRequest's curl handler
     * verifyHost and verifyPeer determine whether curl verifies ssl certificates.
     * It may be necessary to disable these checks on certain systems.
     * These only have an effect if SSL is enabled.
     *
     * @param boolean $enable New status for the mode
     * @return EmailService $this
     */
    public function setVerifyHost($enable = true)
    {
        $this->__verifyHost = (bool)$enable;
        return $this;
    }

    /**
     * Enable/disable CURLOPT_SSL_VERIFYPEER for EmailServiceRequest's curl handler
     * verifyHost and verifyPeer determine whether curl verifies ssl certificates.
     * It may be necessary to disable these checks on certain systems.
     * These only have an effect if SSL is enabled.
     *
     * @param boolean $enable New status for the mode
     * @return EmailService $this
     */
    public function setVerifyPeer($enable = true)
    {
        $this->__verifyPeer = (bool)$enable;
        return $this;
    }

    /**
     * Enable/disable bulk email sending mode
     *
     * @param boolean $enable New status for the mode
     * @return EmailService $this
     * @deprecated
     */
    public function setBulkMode($enable = true)
    {
        $this->__bulk_sending_mode = (bool)$enable;
        return $this;
    }

    /**
     * Lists the email addresses that have been verified and can be used as the 'From' address
     *
     * @return array An array containing two items: a list of verified email addresses, and the request id.
     */
    public function listVerifiedEmailAddresses()
    {
        $ses_request = $this->getRequestHandler('GET');
        $ses_request->setParameter('Action', 'ListIdentities');

        $ses_response = $ses_request->getResponse();

        if ($ses_response->error === false && $ses_response->code !== 200) {
            $ses_response->error = array('code' => $ses_response->code, 'message' => 'Unexpected HTTP status');
        }
        if ($ses_response->error !== false) {
            $this->__triggerError('ListIdentities', $ses_response->error);
            return [];
        }

        $response = array();
        if (!isset($ses_response->body)) {
            return $response;
        }

        $addresses = array();
        foreach ($ses_response->body->ListIdentitiesResult->Identities->member as $address) {
            if(is_email($address)) {
                $addresses[] = (string)$address;
            }
        }

        $response['Addresses'] = $addresses;
        $response['RequestId'] = (string)$ses_response->body->ResponseMetadata->RequestId;

        return $response;
    }

    /**
     * Requests verification of the provided email address, so it can be used
     * as the 'From' address when sending emails through EmailService.
     *
     * After submitting this request, you should receive a verification email
     * from Amazon at the specified address containing instructions to follow.
     *
     * @param string $email The email address to get verified
     * @return array The request id for this request.
     */
    public function verifyEmailAddress($email)
    {
        $ses_request = $this->getRequestHandler('POST');
        $ses_request->setParameter('Action', 'VerifyEmailAddress');
        $ses_request->setParameter('EmailAddress', $email);

        $ses_response = $ses_request->getResponse();
        if ($ses_response->error === false && $ses_response->code !== 200) {
            $ses_response->error = array('code' => $ses_response->code, 'message' => 'Unexpected HTTP status');
        }
        if ($ses_response->error !== false) {
            $this->__triggerError('verifyEmailAddress', $ses_response->error);
            return false;
        }

        $response['RequestId'] = (string)$ses_response->body->ResponseMetadata->RequestId;
        return $response;
    }

    /**
     * Removes the specified email address from the list of verified addresses.
     *
     * @param string $email The email address to remove
     * @return array The request id for this request.
     */
    public function deleteVerifiedEmailAddress($email)
    {
        $ses_request = $this->getRequestHandler('DELETE');
        $ses_request->setParameter('Action', 'DeleteVerifiedEmailAddress');
        $ses_request->setParameter('EmailAddress', $email);

        $ses_response = $ses_request->getResponse();
        if ($ses_response->error === false && $ses_response->code !== 200) {
            $ses_response->error = array('code' => $ses_response->code, 'message' => 'Unexpected HTTP status');
        }
        if ($ses_response->error !== false) {
            $this->__triggerError('deleteVerifiedEmailAddress', $ses_response->error);
            return false;
        }

        $response['RequestId'] = (string)$ses_response->body->ResponseMetadata->RequestId;
        return $response;
    }

    /**
     * Retrieves information on the current activity limits for this account.
     * See http://docs.amazonwebservices.com/ses/latest/APIReference/API_GetSendQuota.html
     *
     * @return array An array containing information on this account's activity limits.
     */
    public function getSendQuota()
    {
        $ses_request = $this->getRequestHandler('GET');
        $ses_request->setParameter('Action', 'GetSendQuota');

        $ses_response = $ses_request->getResponse();
        if ($ses_response->error === false && $ses_response->code !== 200) {
            $ses_response->error = array('code' => $ses_response->code, 'message' => 'Unexpected HTTP status');
        }
        if ($ses_response->error !== false) {
            $this->__triggerError('getSendQuota', $ses_response->error);
            return false;
        }

        $response = array();
        if (!isset($ses_response->body)) {
            return $response;
        }

        $response['Max24HourSend'] = (string)$ses_response->body->GetSendQuotaResult->Max24HourSend;
        $response['MaxSendRate'] = (string)$ses_response->body->GetSendQuotaResult->MaxSendRate;
        $response['SentLast24Hours'] = (string)$ses_response->body->GetSendQuotaResult->SentLast24Hours;
        $response['RequestId'] = (string)$ses_response->body->ResponseMetadata->RequestId;

        return $response;
    }

    /**
     * Retrieves statistics for the last two weeks of activity on this account.
     * See http://docs.amazonwebservices.com/ses/latest/APIReference/API_GetSendStatistics.html
     *
     * @return array An array of activity statistics.  Each array item covers a 15-minute period.
     */
    public function getSendStatistics()
    {
        $ses_request = $this->getRequestHandler('GET');
        $ses_request->setParameter('Action', 'GetSendStatistics');

        $ses_response = $ses_request->getResponse();
        if ($ses_response->error === false && $ses_response->code !== 200) {
            $ses_response->error = array('code' => $ses_response->code, 'message' => 'Unexpected HTTP status');
        }
        if ($ses_response->error !== false) {
            $this->__triggerError('getSendStatistics', $ses_response->error);
            return false;
        }

        $response = array();
        if (!isset($ses_response->body)) {
            return $response;
        }

        $datapoints = array();
        foreach ($ses_response->body->GetSendStatisticsResult->SendDataPoints->member as $datapoint) {
            $p = array();
            $p['Bounces'] = (string)$datapoint->Bounces;
            $p['Complaints'] = (string)$datapoint->Complaints;
            $p['DeliveryAttempts'] = (string)$datapoint->DeliveryAttempts;
            $p['Rejects'] = (string)$datapoint->Rejects;
            $p['Timestamp'] = (string)$datapoint->Timestamp;

            $datapoints[] = $p;
        }

        $response['SendDataPoints'] = $datapoints;
        $response['RequestId'] = (string)$ses_response->body->ResponseMetadata->RequestId;

        return $response;
    }


    /**
     * Given a EmailServiceMessage object, submits the message to the service for sending.
     *
     * @param EmailServiceMessage $sesMessage An instance of the message class
     * @param boolean $use_raw_request If this is true or there are attachments to the email `SendRawEmail` call will be used
     * @param boolean $trigger_error Optionally overwrite the class setting for triggering an error (with type check to true/false)
     * @return array An array containing the unique identifier for this message and a separate request id.
     *         Returns false if the provided message is missing any required fields.
     * @link(AWS SES Response formats, http://docs.aws.amazon.com/ses/latest/DeveloperGuide/query-interface-responses.html)
     */
    public function sendEmail($sesMessage, $use_raw_request = false, $trigger_error = null)
    {
        if (!$sesMessage->validate()) {
            $this->__triggerError('sendEmail', 'Message failed validation.');
            return false;
        }

        $ses_request = $this->getRequestHandler('POST');
        $action = !empty($sesMessage->attachments) || $use_raw_request ? 'SendRawEmail' : 'SendEmail';
        $ses_request->setParameter('Action', $action);

        // Works with both calls
        if (!is_null($sesMessage->configuration_set)) {
            $ses_request->setParameter('ConfigurationSetName', $sesMessage->configuration_set);
        }

        if ($action == 'SendRawEmail') {
            // https://docs.aws.amazon.com/ses/latest/APIReference/API_SendRawEmail.html
            $ses_request->setParameter('RawMessage.Data', $sesMessage->mime);
        } else {
            $i = 1;
            foreach ($sesMessage->to as $to) {
                $ses_request->setParameter('Destination.ToAddresses.member.' . $i, $sesMessage->encodeRecipients($to));
                $i++;
            }

            if (is_array($sesMessage->cc)) {
                $i = 1;
                foreach ($sesMessage->cc as $cc) {
                    $ses_request->setParameter('Destination.CcAddresses.member.' . $i, $sesMessage->encodeRecipients($cc));
                    $i++;
                }
            }

            if (is_array($sesMessage->bcc)) {
                $i = 1;
                foreach ($sesMessage->bcc as $bcc) {
                    $ses_request->setParameter('Destination.BccAddresses.member.' . $i, $sesMessage->encodeRecipients($bcc));
                    $i++;
                }
            }

            if (is_array($sesMessage->replyto)) {
                $i = 1;
                foreach ($sesMessage->replyto as $replyto) {
                    $ses_request->setParameter('ReplyToAddresses.member.' . $i, $sesMessage->encodeRecipients($replyto));
                    $i++;
                }
            }

            $ses_request->setParameter('Source', $sesMessage->encodeRecipients($sesMessage->from));

            if ($sesMessage->returnpath != null) {
                $ses_request->setParameter('ReturnPath', $sesMessage->returnpath);
            }

            if ($sesMessage->subject != null && strlen($sesMessage->subject) > 0) {
                $ses_request->setParameter('Message.Subject.Data', $sesMessage->subject);
                if ($sesMessage->subjectCharset != null && strlen($sesMessage->subjectCharset) > 0) {
                    $ses_request->setParameter('Message.Subject.Charset', $sesMessage->subjectCharset);
                }
            }


            if ($sesMessage->messagetext != null && strlen($sesMessage->messagetext) > 0) {
                $ses_request->setParameter('Message.Body.Text.Data', $sesMessage->messagetext);
                if ($sesMessage->messageTextCharset != null && strlen($sesMessage->messageTextCharset) > 0) {
                    $ses_request->setParameter('Message.Body.Text.Charset', $sesMessage->messageTextCharset);
                }
            }

            if ($sesMessage->messagehtml != null && strlen($sesMessage->messagehtml) > 0) {
                $ses_request->setParameter('Message.Body.Html.Data', $sesMessage->messagehtml);
                if ($sesMessage->messageHtmlCharset != null && strlen($sesMessage->messageHtmlCharset) > 0) {
                    $ses_request->setParameter('Message.Body.Html.Charset', $sesMessage->messageHtmlCharset);
                }
            }

            $i = 1;
            foreach ($sesMessage->message_tags as $key => $value) {
                $ses_request->setParameter('Tags.member.' . $i . '.Name', $key);
                $ses_request->setParameter('Tags.member.' . $i . '.Value', $value);
                $i++;
            }
        }

        $ses_response = $ses_request->getResponse();
        if ($ses_response->error === false && $ses_response->code !== 200) {
            $response = array(
                'code'  => $ses_response->code,
                'error' => array('Error' => array('message' => 'Unexpected HTTP status')),
            );
            return $response;
        }
        if ($ses_response->error !== false) {
            if (($this->__trigger_errors && ($trigger_error !== false)) || $trigger_error === true) {
                $this->__triggerError('sendEmail', $ses_response->error);
                return false;
            }
            return $ses_response;
        }

        $response = array(
            'MessageId' => (string)$ses_response->body->{"{$action}Result"}->MessageId,
            'RequestId' => (string)$ses_response->body->ResponseMetadata->RequestId,
        );
        return $response;
    }


    public function sendRawEmail($sesMessage)
    {
        $ses_request = $this->getRequestHandler('POST');
        $ses_request->setParameter('Action', 'SendRawEmail');

        // https://docs.aws.amazon.com/ses/latest/APIReference/API_SendRawEmail.html
        $ses_request->setParameter('RawMessage.Data', $sesMessage);

        $ses_response = $ses_request->getResponse();
        if (($ses_response->error === false && $ses_response->code !== 200) || $ses_response->error !== false) {
            return new \WP_Error($ses_response->code, $this->getErrorMessage('sendRawEmail', $ses_response->error), $ses_response->error);
        }

        return array(
            'MessageId' => (string)$ses_response->body->SendRawEmailResult->MessageId,
            'RequestId' => (string)$ses_response->body->ResponseMetadata->RequestId,
        );
    }

    /**
     * Trigger an error message
     *
     * {@internal Used by member functions to output errors}
     * @param string $functionname The name of the function that failed
     * @param array $error Array containing error information
     * @return  void
     */
    public function __triggerError($functionname, $error)
    {
        trigger_error($this->getErrorMessage($functionname, $error), E_USER_WARNING);
    }

    public function getErrorMessage($functionname, $error)
    {
        if ($error == false) {
            return sprintf("EmailService::%s(): Encountered an error, but no description given", $functionname);
        } else if (isset($error['curl']) && $error['curl']) {
            return sprintf("EmailService::%s(): %s %s", $functionname, $error['code'], $error['message']);
        } else if (isset($error['Error'])) {
            $e = $error['Error'];
            return sprintf("EmailService::%s(): %s - %s: %s\nRequest Id: %s\n", $functionname, $e['Type'], $e['Code'], $e['Message'], $error['RequestId']);
        }

        return sprintf("EmailService::%s(): Encountered an error: %s", $functionname, $error);
    }

    /**
     * Set SES Request
     *
     * @param EmailServiceRequest $ses_request description
     * @return EmailService $this
     */
    public function setRequestHandler(EmailServiceRequest $ses_request = null)
    {
        if (!is_null($ses_request)) {
            $ses_request->setSES($this);
        }

        $this->__ses_request = $ses_request;

        return $this;
    }

    /**
     * Get SES Request
     *
     * @param string $verb HTTP Verb: GET, POST, DELETE
     * @return EmailServiceRequest SES Request
     */
    public function getRequestHandler($verb)
    {
        if (empty($this->__ses_request)) {
            $this->__ses_request = new EmailServiceRequest($this, $verb);
        } else {
            $this->__ses_request->setVerb($verb);
        }

        return $this->__ses_request;
    }
}
PK��f\He�n+n+(mailer/amazonses/emailservicerequest.phpnu�[���<?php

namespace GOSMTP\mailer\amazonses;

/**
* EmailServiceRequest PHP class
*
* @link https://github.com/daniel-zahariev/php-aws-ses
* @package AmazonEmailService
* @version v0.9.1
*/
class EmailServiceRequest
{
	private $ses, $verb, $parameters = array();

	// CURL request handler that can be reused
	protected $curl_handler = null;

	// Holds the response from calling AWS's API
	protected $response;

	//
	public static $curlOptions = array();

	/**
	* Constructor
	*
	* @param EmailService $ses The EmailService object making this request
	* @param string $verb HTTP verb
	* @return void
	*/
	public function __construct(EmailService $ses = null, $verb = 'GET') {
		$this->ses = $ses;
		$this->verb = $verb;
		$this->response = (object) array('body' => '', 'code' => 0, 'error' => false);
	}


	/**
	* Set SES class
	*
	* @param EmailService $ses
	* @return EmailServiceRequest $this
	*/
	public function setSES(EmailService $ses) {
		$this->ses = $ses;

		return $this;
	}

	/**
	* Set HTTP method
	*
	* @param string $verb
	* @return EmailServiceRequest $this
	*/
	public function setVerb($verb) {
		$this->verb = $verb;

		return $this;
	}

	/**
	* Set request parameter
	*
	* @param string  $key Key
	* @param string  $value Value
	* @param boolean $replace Whether to replace the key if it already exists (default true)
	* @return EmailServiceRequest $this
	*/
	public function setParameter($key, $value, $replace = true) {
		if(!$replace && isset($this->parameters[$key])) {
			$temp = (array)($this->parameters[$key]);
			$temp[] = $value;
			$this->parameters[$key] = $temp;
		} else {
			$this->parameters[$key] = $value;
		}

		return $this;
	}

	/**
	* Get the params for the request
	*
	* @return array $params
	*/
	public function getParametersEncoded() {
		$params = array();

		foreach ($this->parameters as $var => $value) {
			if(is_array($value)) {
				foreach($value as $v) {
					$params[] = $var.'='.$this->__customUrlEncode($v);
				}
			} else {
				$params[] = $var.'='.$this->__customUrlEncode($value);
			}
		}

		sort($params, SORT_STRING);

		return $params;
	}

	/**
	* Clear the request parameters
	* @return EmailServiceRequest $this
	*/
	public function clearParameters() {
		$this->parameters = array();
		return $this;
	}

	/**
	* Instantiate and setup CURL handler for sending requests.
	* Instance is cashed in `$this->curl_handler`
	*
	* @return resource $curl_handler
	*/
	protected function getCurlHandler() {
		if (!empty($this->curl_handler))
			return $this->curl_handler;

		$curl = curl_init();
		curl_setopt($curl, CURLOPT_USERAGENT, 'EmailService/php');

		curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, ($this->ses->verifyHost() ? 2 : 0));
		curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, ($this->ses->verifyPeer() ? 1 : 0));
		curl_setopt($curl, CURLOPT_HEADER, false);
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, false);
		curl_setopt($curl, CURLOPT_WRITEFUNCTION, array(&$this, '__responseWriteCallback'));
		curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);

		foreach(self::$curlOptions as $option => $value) {
			curl_setopt($curl, $option, $value);
		}

		$this->curl_handler = $curl;

		return $this->curl_handler;
	}

	/**
	* Get the response
	*
	* @return object | false
	*/
	public function getResponse() {

        $url = 'https://'.$this->ses->getHost().'/';
        $query = implode('&', $this->getParametersEncoded());
        $headers = $this->getHeaders($query);

		$curl_handler = $this->getCurlHandler();
		curl_setopt($curl_handler, CURLOPT_CUSTOMREQUEST, $this->verb);

		// Request types
		switch ($this->verb) {
			case 'GET':
			case 'DELETE':
				$url .= '?'.$query;
				break;

			case 'POST':
				curl_setopt($curl_handler, CURLOPT_POSTFIELDS, $query);
				$headers[] = 'Content-Type: application/x-www-form-urlencoded';
				break;
		}
		curl_setopt($curl_handler, CURLOPT_HTTPHEADER, $headers);
		curl_setopt($curl_handler, CURLOPT_URL, $url);


		// Execute, grab errors
		if (curl_exec($curl_handler)) {
			$this->response->code = curl_getinfo($curl_handler, CURLINFO_HTTP_CODE);
		} else {
			$this->response->error = array(
				'curl' => true,
				'code' => curl_errno($curl_handler),
				'message' => curl_error($curl_handler),
			);
		}

		// cleanup for reusing the current instance for multiple requests
		curl_setopt($curl_handler, CURLOPT_POSTFIELDS, '');
		$this->parameters = array();

		// Parse body into XML
		if ($this->response->error === false && !empty($this->response->body)) {
			$this->response->body = simplexml_load_string($this->response->body);

			// Grab SES errors
			if (!in_array($this->response->code, array(200, 201, 202, 204))
				&& isset($this->response->body->Error)) {
				$error = $this->response->body->Error;
				$output = array();
				$output['curl'] = false;
				$output['Error'] = array();
				$output['Error']['Type'] = (string)$error->Type;
				$output['Error']['Code'] = (string)$error->Code;
				$output['Error']['Message'] = (string)$error->Message;
				$output['RequestId'] = (string)$this->response->body->RequestId;

				$this->response->error = $output;
				unset($this->response->body);
			}
		}

		$response = $this->response;
		$this->response = (object) array('body' => '', 'code' => 0, 'error' => false);

		return $response;
	}

    /**
     * Get request headers
     * @param string $query
     * @return array
     */
	protected function getHeaders($query) {
        $headers = array();

	    if ($this->ses->getRequestSignatureVersion() == EmailService::REQUEST_SIGNATURE_V4) {
            $date = (new \DateTime('now', new \DateTimeZone('UTC')))->format('Ymd\THis\Z');
            $headers[] = 'X-Amz-Date: ' . $date;
            $headers[] = 'Host: ' . $this->ses->getHost();
            $headers[] = 'Authorization: ' . $this->__getAuthHeaderV4($date, $query);

        } else {
            // must be in format 'Sun, 06 Nov 1994 08:49:37 GMT'
            $date = gmdate('D, d M Y H:i:s e');
            $auth = 'AWS3-HTTPS AWSAccessKeyId='.$this->ses->getAccessKey();
            $auth .= ',Algorithm=HmacSHA256,Signature='.$this->__getSignature($date);

            $headers[] = 'Date: ' . $date;
            $headers[] = 'Host: ' . $this->ses->getHost();
            $headers[] = 'X-Amzn-Authorization: ' . $auth;
        }

        return $headers;
    }

	/**
	* Destroy any leftover handlers
	*/
	public function __destruct() {
		if (!empty($this->curl_handler))
			@curl_close($this->curl_handler);
	}

	/**
	* CURL write callback
	*
	* @param resource $curl CURL resource
	* @param string $data Data
	* @return integer
	*/
	private function __responseWriteCallback($curl, $data) {
		if (!isset($this->response->body)) {
			$this->response->body = $data;
		} else {
			$this->response->body .= $data;
		}

		return strlen($data);
	}

	/**
	* Contributed by afx114
	* URL encode the parameters as per http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/index.html?Query_QueryAuth.html
	* PHP's rawurlencode() follows RFC 1738, not RFC 3986 as required by Amazon. The only difference is the tilde (~), so convert it back after rawurlencode
	* See: http://www.morganney.com/blog/API/AWS-Product-Advertising-API-Requires-a-Signed-Request.php
	*
	* @param string $var String to encode
	* @return string
	*/
	private function __customUrlEncode($var) {
		return str_replace('%7E', '~', rawurlencode($var));
	}

	/**
	* Generate the auth string using Hmac-SHA256
	*
	* @internal Used by EmailServiceRequest::getResponse()
	* @param string $string String to sign
	* @return string
	*/
	private function __getSignature($string) {
		return base64_encode(hash_hmac('sha256', $string, $this->ses->getSecretKey(), true));
	}

	/**
     * @param string $key
     * @param string $dateStamp
     * @param string $regionName
     * @param string $serviceName
     * @param string $algo
     * @return string
     */
    private function __getSigningKey($key, $dateStamp, $regionName, $serviceName, $algo) {
        $kDate = hash_hmac($algo, $dateStamp, 'AWS4' . $key, true);
        $kRegion = hash_hmac($algo, $regionName, $kDate, true);
        $kService = hash_hmac($algo, $serviceName, $kRegion, true);

        return hash_hmac($algo,'aws4_request', $kService, true);
    }

    /**
     * Implementation of AWS Signature Version 4
     * @see https://docs.aws.amazon.com/general/latest/gr/sigv4_signing.html
     * @param string $amz_datetime
     * @param string $query
     * @return string
     */
    private function __getAuthHeaderV4($amz_datetime, $query) {
        $amz_date = substr($amz_datetime, 0, 8);
        $algo = 'sha256';
        $aws_algo = 'AWS4-HMAC-' . strtoupper($algo);

        $host_parts = explode('.', $this->ses->getHost());
        $service = $host_parts[0];
        $region = $host_parts[1];

        $canonical_uri = '/';
        if($this->verb === 'POST') {
            $canonical_querystring = '';
            $payload_data = $query;
        } else {
            $canonical_querystring = $query;
            $payload_data = '';
        }

        // ************* TASK 1: CREATE A CANONICAL REQUEST *************
        $canonical_headers_list = [
            'host:' . $this->ses->getHost(),
            'x-amz-date:' . $amz_datetime
        ];

        $canonical_headers = implode("\n", $canonical_headers_list) . "\n";
        $signed_headers = 'host;x-amz-date';
        $payload_hash = hash($algo, $payload_data, false);

        $canonical_request = implode("\n", array(
            $this->verb,
            $canonical_uri,
            $canonical_querystring,
            $canonical_headers,
            $signed_headers,
            $payload_hash
        ));

        // ************* TASK 2: CREATE THE STRING TO SIGN*************
        $credential_scope = $amz_date. '/' . $region . '/' . $service . '/' . 'aws4_request';
        $string_to_sign = implode("\n", array(
            $aws_algo,
            $amz_datetime,
            $credential_scope,
            hash($algo, $canonical_request, false)
        ));

        // ************* TASK 3: CALCULATE THE SIGNATURE *************
        // Create the signing key using the function defined above.
        $signing_key = $this->__getSigningKey($this->ses->getSecretKey(), $amz_date, $region, $service, $algo);

        // Sign the string_to_sign using the signing_key
        $signature = hash_hmac($algo, $string_to_sign, $signing_key, false);

        // ************* TASK 4: ADD SIGNING INFORMATION TO THE REQUEST *************
        return $aws_algo . ' ' . implode(', ', array(
                'Credential=' . $this->ses->getAccessKey() . '/' . $credential_scope,
                'SignedHeaders=' . $signed_headers ,
                'Signature=' . $signature
            ));
    }
}
PK��f\��Dw�K�K(mailer/amazonses/emailservicemessage.phpnu�[���<?php

namespace GOSMTP\mailer\amazonses;

/**
 * EmailServiceMessage PHP class
 *
 * @link https://github.com/daniel-zahariev/php-aws-ses
 * @package AmazonEmailService
 * @version v0.9.1
 */
final class EmailServiceMessage {

    // these are public for convenience only
    // these are not to be used outside of the EmailService class!
    public $to, $cc, $bcc, $replyto, $recipientsCharset;
    public $from, $returnpath;
    public $subject, $messagetext, $messagehtml;
    public $subjectCharset, $messageTextCharset, $messageHtmlCharset;
    public $attachments, $customHeaders, $configuration_set, $message_tags;
    public $is_clean, $raw_message;
    public $mime;

    public function __construct() {
        $this->to = array();
        $this->cc = array();
        $this->bcc = array();
        $this->replyto = array();
        $this->recipientsCharset = 'UTF-8';

        $this->from = null;
        $this->returnpath = null;

        $this->subject = null;
        $this->messagetext = null;
        $this->messagehtml = null;

        $this->subjectCharset = 'UTF-8';
        $this->messageTextCharset = 'UTF-8';
        $this->messageHtmlCharset = 'UTF-8';

        $this->attachments = array();
        $this->customHeaders = array();
        $this->configuration_set = null;
        $this->message_tags = array();

        $this->is_clean = true;
        $this->raw_message = null;
    }

    /**
     * addTo, addCC, addBCC, and addReplyTo have the following behavior:
     * If a single address is passed, it is appended to the current list of addresses.
     * If an array of addresses is passed, that array is merged into the current list.
     *
     * @return EmailServiceMessage $this
     * @link http://docs.aws.amazon.com/ses/latest/APIReference/API_Destination.html
     */
    public function addTo($to) {
        if (!is_array($to)) {
            $this->to[] = $to;
        } else {
            $this->to = array_unique(array_merge($this->to, $to));
        }

        $this->is_clean = false;

        return $this;
    }
    
    /**
     * @return EmailServiceMessage $this
     */
    public function setTo($to) {
        $this->to = (array) $to;
            
        $this->is_clean = false;
        
        return $this;
    }

    /**
     * Clear the To: email address(es) for the message
     *
     * @return EmailServiceMessage $this
     */
    public function clearTo() {
        $this->to = array();

        $this->is_clean = false;

        return $this;
    }

    /**
     * @return EmailServiceMessage $this
     * @see addTo()
     */
    public function addCC($cc) {
        if (!is_array($cc)) {
            $this->cc[] = $cc;
        } else {
            $this->cc = array_merge($this->cc, $cc);
        }

        $this->is_clean = false;

        return $this;
    }

    /**
     * Clear the CC: email address(es) for the message
     *
     * @return EmailServiceMessage $this
     */
    public function clearCC() {
        $this->cc = array();

        $this->is_clean = false;

        return $this;
    }

    /**
     * @return EmailServiceMessage $this
     * @see addTo()
     */
    public function addBCC($bcc) {
        if (!is_array($bcc)) {
            $this->bcc[] = $bcc;
        } else {
            $this->bcc = array_merge($this->bcc, $bcc);
        }

        $this->is_clean = false;

        return $this;
    }

    /**
     * Clear the BCC: email address(es) for the message
     *
     * @return EmailServiceMessage $this
     */
    public function clearBCC() {
        $this->bcc = array();

        $this->is_clean = false;

        return $this;
    }

    /**
     * @return EmailServiceMessage $this
     * @see addTo()
     */
    public function addReplyTo($replyto) {
        if (!is_array($replyto)) {
            $this->replyto[] = $replyto;
        } else {
            $this->replyto = array_merge($this->replyto, $replyto);
        }

        $this->is_clean = false;

        return $this;
    }

    /**
     * Clear the Reply-To: email address(es) for the message
     *
     * @return EmailServiceMessage $this
     */
    public function clearReplyTo() {
        $this->replyto = array();

        $this->is_clean = false;

        return $this;
    }

    /**
     * Clear all of the message recipients in one go
     *
     * @return EmailServiceMessage $this
     * @uses clearTo()
     * @uses clearCC()
     * @uses clearBCC()
     * @uses clearReplyTo()
     */
    public function clearRecipients() {
        $this->clearTo();
        $this->clearCC();
        $this->clearBCC();
        $this->clearReplyTo();

        $this->is_clean = false;

        return $this;
    }

    /**
     * @return EmailServiceMessage $this
     */
    public function setFrom($from) {
        $this->from = $from;

        $this->is_clean = false;

        return $this;
    }

    /**
     * @return EmailServiceMessage $this
     */
    public function setReturnPath($returnpath) {
        $this->returnpath = $returnpath;

        $this->is_clean = false;

        return $this;
    }

    /**
     * @return EmailServiceMessage $this
     */
    public function setRecipientsCharset($charset) {
        $this->recipientsCharset = $charset;

        $this->is_clean = false;

        return $this;
    }

    /**
     * @return EmailServiceMessage $this
     */
    public function setSubject($subject) {
        $this->subject = $subject;

        $this->is_clean = false;

        return $this;
    }

    /**
     * @return EmailServiceMessage $this
     */
    public function setSubjectCharset($charset) {
        $this->subjectCharset = $charset;

        $this->is_clean = false;

        return $this;
    }

    /**
     * @return EmailServiceMessage $this
     * @link http://docs.aws.amazon.com/ses/latest/APIReference/API_Message.html
     */
    public function setMessageFromString($text, $html = null) {
        $this->messagetext = $text;
        $this->messagehtml = $html;

        $this->is_clean = false;

        return $this;
    }

    /**
     * @return EmailServiceMessage $this
     */
    public function setMessageFromFile($textfile, $htmlfile = null) {
        if (file_exists($textfile) && is_file($textfile) && is_readable($textfile)) {
            $this->messagetext = file_get_contents($textfile);
        } else {
            $this->messagetext = null;
        }
        if (file_exists($htmlfile) && is_file($htmlfile) && is_readable($htmlfile)) {
            $this->messagehtml = file_get_contents($htmlfile);
        } else {
            $this->messagehtml = null;
        }

        $this->is_clean = false;

        return $this;
    }

    /**
     * @return EmailServiceMessage $this
     */
    public function setMessageFromURL($texturl, $htmlurl = null) {
        if ($texturl !== null) {
            $this->messagetext = file_get_contents($texturl);
        } else {
            $this->messagetext = null;
        }
        if ($htmlurl !== null) {
            $this->messagehtml = file_get_contents($htmlurl);
        } else {
            $this->messagehtml = null;
        }

        $this->is_clean = false;

        return $this;
    }

    /**
     * @return EmailServiceMessage $this
     */
    public function setMessageCharset($textCharset, $htmlCharset = null) {
        $this->messageTextCharset = $textCharset;
        $this->messageHtmlCharset = $htmlCharset;

        $this->is_clean = false;

        return $this;
    }

    /**
     * @return EmailServiceMessage $this
     */
    public function setConfigurationSet($configuration_set = null) {
        $this->configuration_set = $configuration_set;

        $this->is_clean = false;

        return $this;
    }

    /**
     * @return array $message_tags
     */
    public function getMessageTags() {
        return $this->message_tags;
    }

    /**
     * @return null|mixed $message_tag
     */
    public function getMessageTag($key) {
        return isset($this->message_tags[$key]) ? $this->message_tags[$key] : null;
    }

    /**
     * Add Message tag
     *
     * Both key and value can contain only ASCII letters (a-z, A-Z), numbers (0-9), underscores (_), or dashes (-) and be less than 256 characters.
     *
     * @param string $key
     * @param mixed $value
     * @return EmailServiceMessage $this
     * @link https://docs.aws.amazon.com/ses/latest/DeveloperGuide/event-publishing-send-email.html
     * @link https://docs.aws.amazon.com/ses/latest/APIReference/API_MessageTag.html
     */
    public function setMessageTag($key, $value) {
        $this->message_tags[$key] = $value;

        $this->is_clean = false;

        return $this;
    }

    /**
     * @param string $key The key of the tag to be removed
     * @return EmailServiceMessage $this
     */
    public function removeMessageTag($key) {
        unset($this->message_tags[$key]);

        $this->is_clean = false;

        return $this;
    }

    /**
     * @param array $message_tags
     * @return EmailServiceMessage $this
     */
    public function setMessageTags($message_tags = array()) {
        $this->message_tags = array_merge($this->message_tags, $message_tags);

        $this->is_clean = false;

        return $this;
    }

    /**
     * @return EmailServiceMessage $this
     */
    public function removeMessageTags() {
        $this->message_tags = array();

        $this->is_clean = false;

        return $this;
    }

    /**
     * Add custom header - this works only with SendRawEmail
     *
     * @param string $header Your custom header
     * @return EmailServiceMessage $this
     * @link( Restrictions on headers, http://docs.aws.amazon.com/ses/latest/DeveloperGuide/header-fields.html)
     */
    public function addCustomHeader($header) {
        $this->customHeaders[] = $header;

        $this->is_clean = false;

        return $this;
    }

    /**
     * Add email attachment by directly passing the content
     *
     * @param string $name      The name of the file attachment as it will appear in the email
     * @param string $data      The contents of the attachment file
     * @param string $mimeType  Specify custom MIME type
     * @param string $contentId Content ID of the attachment for inclusion in the mail message
     * @param string $attachmentType    Attachment type: attachment or inline
     * @return EmailServiceMessage $this
     */
    public function addAttachmentFromData($name, $data, $mimeType = 'application/octet-stream', $contentId = null, $attachmentType = 'attachment') {
        $this->attachments[$name] = array(
            'name' => $name,
            'mimeType' => $mimeType,
            'data' => $data,
            'contentId' => $contentId,
            'attachmentType' => ($attachmentType == 'inline' ? 'inline; filename="' . $name . '"' : $attachmentType),
        );

        $this->is_clean = false;

        return $this;
    }

    /**
     * Add email attachment by passing file path
     *
     * @param string $name      The name of the file attachment as it will appear in the email
     * @param string $path      Path to the attachment file
     * @param string $mimeType  Specify custom MIME type
     * @param string $contentId Content ID of the attachment for inclusion in the mail message
     * @param string $attachmentType    Attachment type: attachment or inline
     * @return boolean Status of the operation
     */
    public function addAttachmentFromFile($name, $path, $mimeType = 'application/octet-stream', $contentId = null, $attachmentType = 'attachment') {
        if (file_exists($path) && is_file($path) && is_readable($path)) {
            $this->addAttachmentFromData($name, file_get_contents($path), $mimeType, $contentId, $attachmentType);
            return true;
        }

        $this->is_clean = false;

        return false;
    }

    /**
     * Add email attachment by passing file path
     *
     * @param string $name      The name of the file attachment as it will appear in the email
     * @param string $url      URL to the attachment file
     * @param string $mimeType  Specify custom MIME type
     * @param string $contentId Content ID of the attachment for inclusion in the mail message
     * @param string $attachmentType    Attachment type: attachment or inline
     * @return boolean Status of the operation
     */
    public function addAttachmentFromUrl($name, $url, $mimeType = 'application/octet-stream', $contentId = null, $attachmentType = 'attachment') {
        $data = file_get_contents($url);
        if ($data !== false) {
            $this->addAttachmentFromData($name, $data, $mimeType, $contentId, $attachmentType);
            return true;
        }

        $this->is_clean = false;

        return false;
    }

    /**
     * Get the existence of attached inline messages
     *
     * @return boolean
     */
    public function hasInlineAttachments() {
        foreach ($this->attachments as $attachment) {
            if ($attachment['attachmentType'] != 'attachment') {
                return true;
            }

        }
        return false;
    }

    /**
     * Get the raw mail message
     *
     * @return string
     */
    public function getRawMessage($encode = true) {
        if ($this->is_clean && !is_null($this->raw_message) && $encode) {
            return $this->raw_message;
        }

        $this->is_clean = true;

        $boundary = uniqid(rand(), true);
        $raw_message = count($this->customHeaders) > 0 ? join("\n", $this->customHeaders) . "\n" : '';

        if (!empty($this->message_tags)) {
            $message_tags = array();
            foreach ($this->message_tags as $key => $value) {
                $message_tags[] = "{$key}={$value}";
            }

            $raw_message .= 'X-SES-MESSAGE-TAGS: ' . join(', ', $message_tags) . "\n";
        }

        if (!is_null($this->configuration_set)) {
            $raw_message .= 'X-SES-CONFIGURATION-SET: ' . $this->configuration_set . "\n";
        }

        $raw_message .= count($this->to) > 0 ? 'To: ' . $this->encodeRecipients($this->to) . "\n" : '';
        $raw_message .= 'From: ' . $this->encodeRecipients($this->from) . "\n";
        if (!empty($this->replyto)) {
            $raw_message .= 'Reply-To: ' . $this->encodeRecipients($this->replyto) . "\n";
        }

        if (!empty($this->cc)) {
            $raw_message .= 'CC: ' . $this->encodeRecipients($this->cc) . "\n";
        }
        if (!empty($this->bcc)) {
            $raw_message .= 'BCC: ' . $this->encodeRecipients($this->bcc) . "\n";
        }

        if ($this->subject != null && strlen($this->subject) > 0) {
            $raw_message .= 'Subject: =?' . $this->subjectCharset . '?B?' . base64_encode($this->subject) . "?=\n";
        }

        $raw_message .= 'MIME-Version: 1.0' . "\n";
        $raw_message .= 'Content-type: ' . ($this->hasInlineAttachments() ? 'multipart/related' : 'Multipart/Mixed') . '; boundary="' . $boundary . '"' . "\n";
        $raw_message .= "\n--{$boundary}\n";
        $raw_message .= 'Content-type: Multipart/Alternative; boundary="alt-' . $boundary . '"' . "\n";

        if ($this->messagetext != null && strlen($this->messagetext) > 0) {
            $charset = empty($this->messageTextCharset) ? '' : "; charset=\"{$this->messageTextCharset}\"";
            $raw_message .= "\n--alt-{$boundary}\n";
            $raw_message .= 'Content-Type: text/plain' . $charset . "\n\n";
            $raw_message .= $this->messagetext . "\n";
        }


        if ($this->messagehtml != null && strlen($this->messagehtml) > 0) {
            $charset = empty($this->messageHtmlCharset) ? '' : "; charset=\"{$this->messageHtmlCharset}\"";
            $raw_message .= "\n--alt-{$boundary}\n";
            $raw_message .= 'Content-Type: text/html' . $charset . "\n\n";
            $raw_message .= $this->messagehtml . "\n";
        }
        $raw_message .= "\n--alt-{$boundary}--\n";

        foreach ($this->attachments as $attachment) {
            $raw_message .= "\n--{$boundary}\n";
            $raw_message .= 'Content-Type: ' . $attachment['mimeType'] . '; name="' . $attachment['name'] . '"' . "\n";
            $raw_message .= 'Content-Disposition: ' . $attachment['attachmentType'] . "\n";
            if (!empty($attachment['contentId'])) {
                $raw_message .= 'Content-ID: ' . $attachment['contentId'] . '' . "\n";
            }
            $raw_message .= 'Content-Transfer-Encoding: base64' . "\n";
            $raw_message .= "\n" . chunk_split(base64_encode($attachment['data']), 76, "\n") . "\n";
        }

        $raw_message .= "\n--{$boundary}--\n";

        if (!$encode) {
            return $raw_message;
        }

        $this->raw_message = base64_encode($raw_message);

        return $this->raw_message;
    }

    /**
     * Encode recipient with the specified charset in `recipientsCharset`
     *
     * @return string Encoded recipients joined with comma
     */
    public function encodeRecipients($recipient) {
        if (is_array($recipient)) {
            return join(', ', array_map(array($this, 'encodeRecipients'), $recipient));
        }

        if (preg_match("/(.*)<(.*)>/", $recipient, $regs)) {
            $recipient = '=?' . $this->recipientsCharset . '?B?' . base64_encode($regs[1]) . '?= <' . $regs[2] . '>';
        }

        return $recipient;
    }

    /**
     * Validates whether the message object has sufficient information to submit a request to SES.
     *
     * This does not guarantee the message will arrive, nor that the request will succeed;
     * instead, it makes sure that no required fields are missing.
     *
     * This is used internally before attempting a SendEmail or SendRawEmail request,
     * but it can be used outside of this file if verification is desired.
     * May be useful if e.g. the data is being populated from a form; developers can generally
     * use this function to verify completeness instead of writing custom logic.
     *
     * @return boolean
     */
    public function validate() {
        // at least one destination is required
        if (count($this->to) == 0 && count($this->cc) == 0 && count($this->bcc) == 0) {
            return false;
        }

        // sender is required
        if ($this->from == null || strlen($this->from) == 0) {
            return false;
        }

        // subject is required
        if (($this->subject == null || strlen($this->subject) == 0)) {
            return false;
        }

        // message is required
        if ((empty($this->messagetext) || strlen((string) $this->messagetext) == 0)
            && (empty($this->messagehtml) || strlen((string) $this->messagehtml) == 0)) {
            return false;
        }

        return true;
    }
}
PK��f\
��"��mailer/amazonses/amazonses.phpnu�[���<?php
/**
 * Class GOSMTP_Mailer_AmazonSES.
 *
 * @since 1.0.0
 */

namespace GOSMTP\Mailer\AmazonSES;
 
use GOSMTP\Mailer\Loader;
use GOSMTP\mailer\amazonses\EmailService;
use GOSMTP\mailer\amazonses\EmailServiceMessage;

class AmazonSES extends Loader{

	var $title = 'AmazonSES';
	var $mailer = 'amazonses';
	var $client = null;
	
	public function send(){
		global $phpmailer;

		if ($phpmailer->preSend()) {
	
		 	$response = $this->postSend();
		 	return $this->handle_response( $response );
		}	
		
		return $this->handle_response(new \WP_Error(400, 'Unable to send mail for some reason!', []));
	}

	public function postSend(){
		global $phpmailer;
			
		$mime = chunk_split(base64_encode($phpmailer->getSentMIMEMessage()), 76, "\n");
		
		$options = $this->getMailerOption();
		
		$region = 'email.' . $options['region'] . '.amazonaws.com';

		$ses = new EmailService($options['access_key'], $options['secret_key'], $region, false);
		
		$response = $ses->sendRawEmail($mime); 
		
		if(is_wp_error($response)){
			$return_response = new \WP_Error($response->get_error_code(), $response->get_error_message(), $response->get_error_messages());
		}else{
			$resp_body = wp_remote_retrieve_body($response);
			$resp_code = wp_remote_retrieve_response_code($response);
			$resp_body = \json_decode($resp_body, true);
				
			if(!empty($response['MessageId'])){
				$msgId = $response['MessageId'];
				$status = __('Email sent successfully');
				$return_response = [
					'status' => true,
					'code' => 200,
					'messageId' => $msgId,
					'message' => $status
				];	
			}else{
				$err_code = $resp_code;
				$error_text = [''];
				if( ! empty( $resp_body['error'] ) && is_array( $resp_body['error'] ) ){
					
					$message = $resp_body['error']['message'];
						
					$error_text[] = $this->message_formatting( $message, $code );
				}else{
					$error_text[] = $this->get_response_error_message($response);
				}
    			
				$error_msg = implode( '\r\n', array_map( 'esc_textarea', array_filter( $error_text ) ) );
				$return_response = new \WP_Error($err_code, $error_msg, $resp_body);
			}
		}
			
		return $return_response;
		
	}

	public function email_checker($data){
		
		$region= 'email.' . $data['amazonses']['region'] . '.amazonaws.com';

		set_error_handler(function ($errno, $errstr, $errfile, $errline) {
			throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
		});
			
		$ses = new EmailService($data['amazonses']['access_key'], $data['amazonses']['secret_key'], $region, false);

		try{
			$ses->listVerifiedEmailAddresses();
		}catch(\Exception $e) {
			return new \WP_Error(423, $e->getMessage());
		}

		return false;
	}
	
	public function load_field(){
		
		$fields = array(
			'access_key' => array(
				'title' => __('Access Key'),
				'type' => 'password',
			),
			'secret_key' => array(
				'title' => __('Secret Key'),
				'type' => 'password',
				'desc' => __( 'Follow this link to get a Secret Key from AmazonSES: <a href="https://aws.amazon.com/blogs/security/wheres-my-secret-access-key/" target="_blank">Secret Key.</a>' ),
			),
			'region' => array(
				'title' => __('Region'),
				'type' => 'select',
				'list' => array(
					'us-east-1'	  => __('US East (N. Virginia)', 'gosmtp'),
					'us-east-2'	  => __('US East (Ohio)', 'gosmtp'),
					'us-west-1'	  => __('US West (N. California)', 'gosmtp'),
					'us-west-2'	  => __('US West (Oregon)', 'gosmtp'),
					'ca-central-1'   => __('Canada (Central)', 'gosmtp'),
					'eu-west-1'	  => __('EU (Ireland)', 'gosmtp'),
					'eu-west-2'	  => __('EU (London)', 'gosmtp'),
					'eu-west-3'	  => __('Europe (Paris)', 'gosmtp'),
					'eu-central-1'   => __('EU (Frankfurt)', 'gosmtp'),
					'eu-south-1'	 => __('Europe (Milan)', 'gosmtp'),
					'eu-north-1'	 => __('Europe (Stockholm)', 'gosmtp'),
					'ap-south-1'	 => __('Asia Pacific (Mumbai)', 'gosmtp'),
					'ap-northeast-2' => __('Asia Pacific (Seoul)', 'gosmtp'),
					'ap-southeast-1' => __('Asia Pacific (Singapore)', 'gosmtp'),
					'ap-southeast-2' => __('Asia Pacific (Sydney)', 'gosmtp'),
					'ap-northeast-1' => __('Asia Pacific (Tokyo)', 'gosmtp'),
					'sa-east-1'	  => __('South America (Sao Paulo)', 'gosmtp'),
					'me-south-1'	 => __('Middle East (Bahrain)', 'gosmtp'),
					'us-gov-west-1'  => __('AWS GovCloud (US)', 'gosmtp'),
					'af-south-1'	 => __('Africa (Cape Town)', 'gosmtp'),
					'cn-northwest-1' => __('China (Ningxia)', 'gosmtp')
				),
				'desc' => __( 'Define which endpoint you want to use for sending messages.<br>If you are operating under EU laws, you may be required to use EU region. <a href="https://aws.amazon.com/about-aws/global-infrastructure/regions_az/" target="_blank">More information</a> on aws.amazon.com.' ),
			)
		);
		
		return $fields;
	}
}
PK��f\(ގ8�+�+mailer/gmail/gmail.phpnu�[���<?php

/**
 * Class GOSMTP_Mailer_Gmail.
 *
 * @since 1.0.0
 */

namespace GOSMTP\Mailer\Gmail;
 
use GOSMTP\Mailer\Loader;

class Gmail extends Loader{

	var $title = 'Gmail';
	var $mailer = 'gmail';
	var $isOk = 200;
	var $url = 'https://gmail.googleapis.com/gmail/v1/users/me/messages/send';
	
	public function getRedirectUrl($query = ''){

		// TODO check and change this
		return admin_url().'admin.php?page=gosmtp'.$query;
	}

	public function send(){
		global $phpmailer;
		
		if($phpmailer->preSend()){
			$response = $this->postSend();
			return $this->handle_response( $response );
		}
		
		return $this->handle_response(new \WP_Error(400, 'Unable to send mail for some reason!', []));
	}

	protected function postSend(){
		global $phpmailer;

		try{
			$access_token = $this->getAccessToken($this->getMailerOption());
			
			if(is_wp_error($access_token)){ 
				return $access_token->get_error_message();
			}
			
			$mime = base64_encode($phpmailer->getSentMIMEMessage());
	
			$body = array(
				"raw" =>$mime,
			);

			$params = array(
				'method' => 'POST',
				'headers' => [
					'Authorization' => 'Bearer '. $access_token,
					'Content-Type' =>  'application/json',
					'Accept' => 'application/json',
				],
				'body' => wp_json_encode($body)
			);

			$response = wp_remote_request($this->url, $params);

			if(is_wp_error($response)){
				$return_response = new \WP_Error($response->get_error_code(), $response->get_error_message(), $response->get_error_messages());
			}else{
				$resp_body = wp_remote_retrieve_body($response);
				$resp_code = wp_remote_retrieve_response_code($response);
				$resp_body = \json_decode($resp_body, true);
				
				if($this->isOk == $resp_code){
					$msgId = isset( $resp_body['id'] ) ? $resp_body['id'] : '';
					$status = 'Email sent successfully';
					$return_response = [
						'status' => true,
						'code' => $resp_code,
						'messageId' => $msgId,
						'message' => $status
					];	
				}else{
					$err_code = $resp_code;
					$error_text = [''];
					if( ! empty( $resp_body['error'] ) && is_array( $resp_body['error'] ) ){
						$message = $resp_body['error']['message'];
						$code = !empty( $resp_body['error']['code'] ) ? $resp_body['error']['code'] : '';
						
						$error_text[] = $this->message_formatting( $message, $code );
					}else{
						$error_text[] = $this->get_response_error_message($response);
					}
        			
					$error_msg = implode( '\r\n', array_map( 'esc_textarea', array_filter( $error_text ) ) );
					$return_response = new \WP_Error($err_code, $error_msg, $resp_body);
				}
			}
			
		}catch(\Exception $e){
			$return_Response = new \WP_Error(423, $e->getMessage(), []);
		}

		return $return_response;
	}

	// get access token
	private function getAccessToken($options){
		
		$accessToken = $options['access_token'];
		
		// check if expired or will be expired in 300 seconds
		if( ($options['expire_stamp'] - 300) < time()){

			$state = ($this->conn_id === 0 ? '' : '-'.$this->conn_id);
			$client_id = $this->getOption('client_id', $this->mailer);
			$client_secret = $this->getOption('client_secret', $this->mailer);
			$redirect_url = $this->getRedirectUrl('&auth=gmail');
			$google_client = new \GOSMTP\mailer\gmail\Auth($client_id, $client_secret, $redirect_url, $state);

			$tokens = $google_client->sendTokenRequest('refresh_token', [
				'refresh_token' => $options['refresh_token']
			]);

			if(is_wp_error($tokens)) {
				return $tokens->get_error_message();
			}

			$this->saveNewTokens($tokens);

			$accessToken = $tokens['access_token'];
		}

		return $accessToken;
	}

	//save new token when expire time exeed
	private function saveNewTokens($tokens){

		$tokens['refresh_token'] = empty($tokens['refresh_token']) ? $this->getOption('refresh_token', $this->mailer) : $tokens['refresh_token'];

		if(empty($tokens['access_token']) || empty($tokens['refresh_token'])){
			return false;
		}

		$this->update_option('access_token', $tokens['access_token'], $this->mailer);
		$this->update_option('refresh_token', $tokens['refresh_token'], $this->mailer);
		$this->update_option('expire_stamp', $tokens['expires_in'] + time(), $this->mailer);
		$this->update_option('expires_in', $tokens['expires_in'], $this->mailer);

		return true;
	}

	//generate access token and refresh token and update in data base.
	public function set_token(){
		$errors = [];
		
		$clientId = $this->getOption('client_id', $this->mailer);
		$clientSecret = $this->getOption('client_secret', $this->mailer);

		$accessToken = $this->getOption('access_token', $this->mailer);
		$authToken = $this->getOption('auth_token', $this->mailer);
	   
		if(!$accessToken && $authToken ){
			
			$body = [
				'code'		  => $authToken,
				'grant_type'	=> 'authorization_code',
				'redirect_uri'  => $this->getRedirectUrl('&auth=gmail'),
				'client_id'	 => $clientId,
				'client_secret' => $clientSecret
			];
			
			$tokens = $this->makeRequest('https://accounts.google.com/o/oauth2/token', $body, 'POST');

			if(is_wp_error($tokens)){
				return new \WP_Error(423, $tokens->get_error_message());
			}else{
				$this->update_option('access_token', $tokens['access_token'], $this->mailer);
				$this->update_option('refresh_token', $tokens['refresh_token'], $this->mailer);
				$this->update_option('auth_token', '', $this->mailer);
				$this->update_option('expire_stamp', time() + $tokens['expires_in'], $this->mailer);
				$this->update_option('expires_in', $tokens['expires_in'], $this->mailer);
				$this->update_option('version', 2, $this->mailer);
			}
		}elseif(!$authToken && !$accessToken){
				return new \WP_Error(423,  __('Please Provide Auth Token.', 'GOSMTP'));
		}
		return true;
	}

	private function makeRequest($url, $bodyArgs, $type = 'GET', $headers = false){
		
		if(!$headers){
			$headers = array(
				'Content-Type' => 'application/http',
				'Content-Transfer-Encoding' => 'binary',
				'MIME-Version' => '1.0',
			);
		}

		$args = array(
			'headers' => $headers
		);
		
		if($bodyArgs){
			$args['body'] = json_encode($bodyArgs);
		}

		$args['method'] = $type;
		$request = wp_remote_request($url, $args);

		if(is_wp_error($request)){
			$message = $request->get_error_message();
			return new \WP_Error(423, $message);
		}

		$body = json_decode(wp_remote_retrieve_body($request), true);
		
		if(!empty($body['error'])){
			$error = 'Unknown Error';
			
			if(isset($body['error_description'])){
				$error = $body['error_description'];
			}elseif(!empty($body['error']['message'])){
				$error = $body['error']['message'];
			}
			
			return new \WP_Error(423, $error);
		}

		return $body;
	}


	public function get_auth_url() {
		
		$state = ($this->conn_id === 0 ? '' : '-'.$this->conn_id);
		$client_id = $this->getOption('client_id', $this->mailer);
		$client_secret = $this->getOption('client_secret', $this->mailer);
		$redirect_url = $this->getRedirectUrl('&auth=gmail');
		
		$google_client = new \GOSMTP\mailer\gmail\Auth($client_id, $client_secret, $redirect_url, $state);

		if($google_client->getAuthUrl()){
			return  $google_client->getAuthUrl();
		}
		
	}

	public function load_field(){
				
		$this->gmail_init();

		$access_token = $this->getOption('access_token', $this->mailer);
		$client_id = $this->getOption('client_id', $this->mailer);
		$client_secret = $this->getOption('client_secret', $this->mailer);
		$refresh_token = $this->getOption('refresh_token', $this->mailer);
		$mail_type = $this->getOption('mail_type', $this->mailer);

		$deactivate = !empty($refresh_token) && !empty($access_token) && $this->mailer == $mail_type;
		
		$activate = !empty($client_id) && !empty($client_secret)  && empty($access_token) && empty($refresh_token);

		$readonly = $deactivate ? 'readonly' : '';

		$fields = array(
			'client_id' => array(
				'title' => __('Client ID'),
				'type' => 'text',
				'desc' => '',
				'attr'=> $readonly,
			),
			'client_secret' => array(
				'title' => __('Client Secret'),
				'type' => 'password',
				'desc' => '',
				'attr'=> $readonly,
			),
			'authorized_redirect_uri' => array(
				'title' => __('Authorized redirect URI'),
				'type' => 'copy', 
				'id' => 'gmail_redirect_uri',
                		'attr'=>'readonly',
				'default' => $this->getRedirectUrl('&auth=gmail'),
				'desc' => __('Please copy this URL into the "Authorized redirect URIs" field of your Google web application.')
			),
		);
		
		if($activate){
			$fields['get_acces_token'] = array(
					'title' => __('Get Access Token'),
					'type' => 'button',
					'class'=>'access_token',
					'default' => 'Get Access Token',
					'href' => $this->get_auth_url(),
					'attr' => 'data-field=auth',
			);
		}elseif($deactivate){
			$fields['get_acces_token'] = array(
					'title' => __('Deactivate Access Token'),
					'type' => 'button',
					'class'=>'deactivate_token',
					'default' => 'Deactivate Access Token',
					'href' => $this->getRedirectUrl().($this->conn_id !== 0 ? '&type=edit&conn_id='.$this->conn_id.'&act=deactivate_token#gosmtp-connections-settings' : '&act=deactivate_token'),
					'attr' => 'data-field=auth',
				);
		}else{
			$fields['get_acces_token'] = array(
				'title' => __('Get Access Token'),
				'type' => 'notice',
				'default' => __('You need to save settings with Client ID and Client Secret before you can proceed.'),
			);
		}
		
		return $fields;
	}

	public function gmail_init(){
		$options = $this->getMailerOption();
		
		// Update auth URl when user succesfull regirect our page
		if( empty($options['access_token']) && empty($options['refresh_token']) && isset( $_GET['auth_code'] ) && isset( $_GET['auth'] ) && $this->mailer == $_GET['auth'] && strlen($this->conn_id) > 0 ){

			if( !empty(gosmtp_optget('conn_id')) && $this->conn_id === 0 ){
				return;
			}

			$auth_code = gosmtp_optget('auth_code');
			$this->update_option('auth_token', $auth_code, $this->mailer);
			$resp = '';
			
			if($this->set_token()){                
				$resp = __('Token Updated Sucessfully');
			}elseif(is_wp_error($this->set_token())){
				$resp = $this->set_token()->get_error_message();
			};

			$query = '';
			if( !is_numeric($this->conn_id) ){
				$query = '&type=edit&conn_id='.$this->conn_id.$query.'#gosmtp-connections-settings';
			}

			echo '<script>
				alert("'.$resp.'");
				var url = "'.$this->getRedirectUrl($query).'";
				history.pushState({urlPath:url},"",url);
			</script>';
		}

		// Delete all the tokens or expire stamp when user click deactivate access token
		if(isset($_GET['act']) && $_GET['act'] == 'deactivate_token'){
			
			if(!empty(gosmtp_optget('conn_id')) && $this->conn_id === 0){
				return;
			}
	
			$this->delete_option('refresh_token', $this->mailer);
			$this->delete_option('expire_stamp', $this->mailer);
			$this->delete_option('expires_in', $this->mailer);
			$this->delete_option('version', $this->mailer);
			$this->delete_option('access_token', $this->mailer);
	
			$query = '';
			if(!is_numeric($this->conn_id)){
				$query = '&type=edit&conn_id='.$this->conn_id.$query.'#gosmtp-connections-settings';
			}

			if(isset($_GET['conn_id'])){
				echo '<script>
					var url = "'.$this->getRedirectUrl($query).'";
					history.pushState({urlPath:url},"",url);
				</script>';
			}
		}
	}
}

PK��f\_�[  mailer/gmail/auth.phpnu�[���<?php

namespace GOSMTP\mailer\gmail;

class Auth{
	
	private $client_id;
	private $client_secret;
	private $redirect_uri;
	private $state;
	private $options;
	private $accessTokenMethod = 'POST';
	
	public function __construct($client_id = '', $client_secret = '', $redirect_uri = '', $state = ''){
		$this->client_id = $client_id;
		$this->client_secret = $client_secret;
		$this->redirect_uri = $redirect_uri;
		$this->state = $state;
		$this->options = $this->getConfig();
	}
 
	private function getConfig(){
		return array(
			'client_id' => $this->client_id,
			'client_secret' => $this->client_secret,
			'redirect_uri' => $this->redirect_uri,
			'urlAuthorize' => 'https://accounts.google.com/o/oauth2/auth',
			'urlAccessToken' => 'https://www.googleapis.com/oauth2/v4/token',
			'urlResourceOwnerDetails' => '',
			'scopes' => 'https://www.googleapis.com/auth/gmail.compose',
			'access_type' => 'offline',
			'include_granted_scopes' => 'true',
			'approval_prompt' => 'force',
			'state' => $this->state,
		);
	}
	
	public function setClientId($client_id){
		$this->client_id= $client_id;
		return true;
	}

	public function setClientSecret($client_secret){
		$this->client_secret = $client_secret;
		return true;
	}

	public function add_scope($scope){
		if(is_array($scope)){
			$separator = ',';
			$this->options['scope'] = implode($separator, $scope);
			return true;
		}
		$this->options['scope'] = $scope;
		return true;
	}

	public function set_access_type($access_type){
		$this->options['access_type'] = $access_type;
		return true;
	}
	
	public function set_approval_prompt($approval_prompt){
		$this->options['approval_prompt'] = $approval_prompt;
		return true;
	}
	
	public function getAuthUrl(){
		return $this->getAuthorizationUrl();
	}
	
	public function getAuthorizationUrl($options = []){
		$base = $this->options['urlAuthorize'];

		$params = $this->getAuthorizationParameters($options);
		$query  = http_build_query($params, null, '&', \PHP_QUERY_RFC3986);

		return $this->appendQuery($base, $query);
	}

	private function getAuthorizationParameters($options){

		if(empty($options['scope'])){
			$options['scope'] = $this->options['scopes'];
		}

		$options += [
			'access_type' => $this->options['access_type'],
			'include_granted_scopes' => $this->options['include_granted_scopes'],
			'response_type'   => 'code',
			'state' => $this->getRandomState().$this->options['state'],
			'approval_prompt' => $this->options['approval_prompt'],
			
		];

		if(is_array($options['scope'])){
			$separator = ',';
			$options['scope'] = implode($separator, $options['scope']);
		}

		// Store the state as it may need to be accessed later on.
		$this->options['state'] = $options['state'];

		// Business code layer might set a different redirect_uri parameter
		// depending on the context, leave it as-is
		if(!isset($options['redirect_uri'])){
			$options['redirect_uri'] = $this->options['redirect_uri'];
		}

		$options['client_id'] = $this->options['client_id'];

		return $options;
	}
	
	protected function getRandomState($length = 32){
		// Converting bytes to hex will always double length. Hence, we can reduce
		// the amount of bytes by half to produce the correct length. 
		$state = bin2hex(random_bytes($length / 2));

		update_option('_gosmtp_last_generated_state', $state);

		return $state;
	}
	
	protected function appendQuery($url, $query){
		$query = trim($query, '?&');

		if($query){
			$glue = strstr($url, '?') === false ? '?' : '&';
			return $url . $glue . $query;
		}

		return $url;
	}
	
	public function sendTokenRequest($type, $params){
		try {
			$tokens = $this->getAccessToken($type, $params);
			return $tokens;
		} catch (\Exception $exception) {
			return new \WP_Error(423, $exception->getMessage());
		}
	}
	
	/**
	* Requests an access token using a specified grant and option set.
	*
	* @param  mixed $grant
	* @param  array $options
	* @throws \Exception
	* @return array tokens
	*/
	public function getAccessToken($grant, array $options = []){
		$params = [
			'client_id' => $this->options['client_id'],
			'client_secret' => $this->options['client_secret'],
			'redirect_uri'  => $this->options['redirect_uri'],
			'grant_type' => $grant,
		];

		$params += $options;

		$requestData = $this->getAccessTokenRequestDetails($params);


		$response = wp_remote_request($requestData['url'], $requestData['params']);

		if(is_wp_error($response)) {
			throw new \Exception(
				$response->get_error_message()
			);
			return $response;
		}

		$responseBody = wp_remote_retrieve_body($response);
	

		if(false === is_array($response)){
			throw new \Exception(
				'Invalid response received from Authorization Server. Expected JSON.'
			);
		}

		if(empty(['access_token'])){
			throw new \Exception(
				'Invalid response received from Authorization Server.'
			);
		}

		return \json_decode($responseBody, true);
	}

	/**
	* Returns a prepared request for requesting an access token.
	*
	* @param array $params Query string parameters
	* @return array $requestDetails
	*/
	protected function getAccessTokenRequestDetails($params){
		$method  = $this->accessTokenMethod;
		$url	 = $this->options['urlAccessToken'];
		$options = http_build_query($params, null, '&', \PHP_QUERY_RFC3986);

		return [
			'url' => $url,
			'params' => [
				'method' => $method,
				'body' => $options,
				'headers' => [
					'content-type' => 'application/x-www-form-urlencoded'
				]
			]
		];
	}

}PK��f\Gt�OR>R>mailer/zoho.phpnu�[���<?php
/**
 * TODO: need to cleen code and properer arrange
 * Class GOSMTP_Mailer_Zoho.
 *
 * @since 1.0.0
 */

namespace GOSMTP\Mailer;
 
use GOSMTP\Mailer\Loader;

class Zoho extends Loader{
	
	var $title = 'Zoho';
	
	var $mailer = 'zoho';

	var $scope = 'VirtualOffice.messages.CREATE,VirtualOffice.accounts.READ';

	var $send_code = 200;
	var $api_url = '';
	var $oauth_url = '';

	var $body = [];
	var $lang = [];

	private $allowed_exts = array('xlsx', 'xls', 'ods', 'docx', 'docm', 'doc', 'csv', 'pdf', 'txt', 'gif', 'jpg', 'jpeg', 'png', 'tif', 'tiff', 'rtf', 'bmp', 'cgm', 'css', 'shtml', 'html', 'htm', 'zip', 'xml', 'ppt', 'pptx', 'tar', 'ez', 'ics', 'mobi', 'msg', 'pub', 'eps', 'odt', 'mp3', 'm4a', 'm4v', 'wma', 'ogg', 'flac', 'wav', 'aif', 'aifc', 'aiff', 'mp4', 'mov', 'avi', 'mkv', 'mpeg', 'mpg', 'wmv');

	public function getLang($str = ''){
		
		$this->lang = array(
			'OK' => __('Mailer successfully configured!'),
			'unauthorized_client' => __('OAuth Client is Invalid'),
			'invalid_client' => __('Invalid Client ID (or) client Credentials did not match.'),
			'invalid_code' => __('Code Expired (or) Invalid Refresh Token.'),
			'invalid_redirect_uri' => __('Invalid Redirect Url configured'),
			'invalid_client_secret' => __('Client Secret did not match.'),
			'INVALID_TICKET' => __('Invalid Client Secret'),
			'INVALID_OAUTHTOKEN' => __('Authtoken invalidated'),
			'access_denied' => __('Multiple requests failed with same Refresh Token.'),
			'general_error' => __('Something went wrong'),
			'remote_token_error' => __('Error when getting the remote token.'),
			'no_user' => __('No User present.'),
			'token_limit_reached' => __('Refresh token limit reached.'),
			'refresh_token_limit_reached' => __('The limit for refresh token reached.'),
			'access_token_limit_reached' => __('The limit for access token reached.'),
			'invalid_client_type' => __('Invalid client type'),
			'invalid_authtoken' => __('Authtoken invalidated'),
			'invalid_operation_type' => __('The scope has an invalid operation.'),
			'URL_RULE_NOT_CONFIGURED' => __('Please configure zoho api.'),
			'invalid_from' => __('Your zoho account does not match with the from mail.'),
		);
		
		if(!isset($this->lang[$str])){
			return $str;
		}
		
		return $this->lang[$str];
	}

	public function getRedirectUrl($query = ''){

		// TODO check and change this
		return admin_url().'admin.php?page=gosmtp'.$query;
	}

	public function send(){

		global $phpmailer;

		$phpmailer->isMail();
		
		$this->setConfig();

		if($phpmailer->preSend()){
			return $this->handle_response( $this->postSend() );
		}
		
		return $this->handle_response(new \WP_Error(400, 'Unable to send mail for some reason!', []));
	}

	public function setConfig(){
		
		$domain_name = $this->getOption('domain_name', $this->mailer, 'com');
	
		$this->api_url = 'https://mail.zoho.'.$domain_name.'/api/accounts';
		$this->oauth_url = 'https://accounts.zoho.'.$domain_name.'/oauth/v2/';
		
	}
	
	public function postSend(){

		global $phpmailer;
		

		$options = $this->getMailerOption();

		$options['access_token'] = $this->getAccessToken($options);

		$this->body['fromAddress'] = $phpmailer->FromName.'<'.$phpmailer->From.'>';

		$this->body['subject'] = $phpmailer->Subject;

		$this->set_content($phpmailer->Body);

		$this->set_recipients(
			array(
				'toAddress'  => $phpmailer->getToAddresses(),
				'ccAddress'  => $phpmailer->getCcAddresses(),
				'bccAddress' => $phpmailer->getBccAddresses(),
				'replyTo'    => $phpmailer->getReplyToAddresses()
			)
		);

		$attachments = $phpmailer->getAttachments();
		
		if(!empty($attachments)){
			$this->set_attachments($attachments);
		}

		$headers = [
			'Authorization' => 'Zoho-oauthtoken '.$options['access_token'],
			'Content-Type' => 'application/json'
		];

		$params = array(
			'headers' => $headers,
			'body' => wp_json_encode($this->body)
		);

		$accId = !empty($options['account_id']) ? $options['account_id'] : '';
		$url = $this->api_url.'/'.$accId.'/messages';

		// print_r(json_encode($this->body, JSON_PRETTY_PRINT));

		$response = wp_safe_remote_post($url, $params);

		if(is_wp_error($response)){
			$return_response = new \WP_Error($response->get_error_code(), $response->get_error_message(), $response->get_error_messages());
		}else{
			$resp_body = wp_remote_retrieve_body($response);
			$resp_code = wp_remote_retrieve_response_code($response);

			$isOk = $resp_code == $this->send_code;

			$resp_body = \json_decode($resp_body, true);
            
			if($isOk) {
				$msgId = isset( $resp_body['data']['messageId'] ) ? $resp_body['data']['messageId'] : '';
				$status = isset($resp_body['status']['description']) ? $resp_body['status']['description'] : '';
				$return_response = [
					'status' => true,
					'code' => $resp_code,
					'messageId' => $msgId,
					'message' => $status
				];    
			}else{
				$msg = ($resp_code == 500 ) ? $resp_body['data']['moreInfo'] : $this->getLang($resp_body['data']['errorCode']);
				$return_response = new \WP_Error($resp_code, $msg , $resp_body);  
			}

		}

		return $return_response;
	}
    
	public function set_content( $content ){
		global $phpmailer;

		if( empty( $content ) ){
			return;
		}

		if( is_array( $content ) ){

			if( ! empty( $content['text'] ) ){
				$this->body['mailFormat'] = 'plaintext';
			}

			if( ! empty( $content['html'] ) ){
				$this->body['mailFormat'] = 'html';
			}

			$this->body['content'] = $content['text'];

		}else{
			if( $phpmailer->ContentType === 'text/plain' ){
				$this->body['mailFormat'] = 'plaintext';
			}else{
				$this->body['mailFormat'] = 'html';
			}
		}

		$this->body['content'] = $content;
	}

	public function set_recipients( $recipients ) { 

		global $phpmailer;

		if( empty( $recipients ) ){
			return;
		}

		foreach( $recipients as $type => $emails ){

			$tmp = '';
			foreach( $emails as $key => $email ){

				$tmp .= $type == 'replyTo' ? '<'.$email[0].'>' : ( empty($email[1]) ? $email[0] : $email[1].'<'.$email[0].'>' );

				if( ( count($emails) - 1 ) != $key ){
					$tmp .= ',';
				}
			}
			
			if(empty($tmp)){
				continue;
			}

			$this->body[$type] = $tmp;
		}
	}

	public function set_attachments( $attachments = []){

		$attachment_data = [];
		$count = 0;
		$ext = '';
		foreach($attachments as $attachment){

			if(!is_file($attachment[0]) || !is_readable($attachment[0])){
				continue;
			}

			if(!empty($attachment[4])){
				$ext = explode("/",$attachment[4])[1];
			}

			$header = array(
				'Authorization' => 'Zoho-oauthtoken '. $this->getOption('access_token', $this->mailer),
				'Content-Type' => 'application/octet-stream'
			);

			if(in_array($ext, $this->allowed_exts, true)){
				$file_name = $attachment[2];
				$content = file_get_contents($attachment[0]);
				$options = $this->getMailerOption();
				
				$url = $this->api_url.'/'.$options['account_id'].'/messages/attachments'.'?fileName='.$file_name;

				$args = array(
					'body' => $content,
					'headers' => $header,
					'method' => 'POST'
				);

				$response = wp_remote_post($url, $args);
				$response_body = wp_remote_retrieve_body($response);
				$http_code = wp_remote_retrieve_response_code($response);
				$response_ = json_decode($response_body, true); 

				if( isset($response_['data']['errorCode']) ){
					$error = $response_['data']['errorCode'];
				}

				$attachments_ = array();

				if($http_code == '200') {
					$attachments_['storeName'] = $response_['data']['storeName'];
					$attachments_['attachmentPath'] = $response_['data']['attachmentPath'];
					$attachments_['attachmentName'] = $response_['data']['attachmentName'];

					$attachment_data[$count] = $attachments_;

					$count = $count + 1;
				}
			}
		}

		if( count($attachment_data) > 0 ){
			$this->body['attachments'] = $attachment_data;
		}
	}

	private function is_authorized(){
		$options = $this->getMailerOption();
		
		if(empty($options['refresh_token']) || empty($options['access_token']) || empty($options['account_id'])){
			return false;
		}

		return true;
	}

	public function authentication_process(){
		global $phpmailer;

		$options = $this->getMailerOption();
		
		$response = $this->generate_tokens($options);    
		
		if( !isset($response['access_token']) || !isset($response['refresh_token']) ){
			return $response;
		}
		
		$access_token = $response['access_token'];
		$refresh_token = $response['refresh_token'];
	

		if( empty($options['account_id']) ){

			$response = $this->zoho_account_id($access_token);    

			if(!$response != true){
				return $response;
			}
		}

		$this->delete_option('auth_code', $this->mailer);

		return 'OK';
	}

	private function get_authcode_link($options){

		$state = wp_create_nonce('redirect_url').($this->conn_id === 0 ? '' : '-'.$this->conn_id);
				
		$auth_url = $this->oauth_url ."auth?response_type=code&client_id=". $options['client_id'] ."&scope=". $this->scope ."&redirect_uri=".urlencode($this->getRedirectUrl('&auth=zoho'))."&prompt=consent&access_type=offline&state=". $state; 

		return $auth_url;
	}

	public function generate_tokens($options){

		$state = wp_create_nonce('redirect_url').($this->conn_id === 0 ? '' : '-'.$this->conn_id);

		$url = $this->oauth_url ."token?code=". $options['auth_code'] ."&client_id=". $options['client_id'] ."&client_secret=". $options['client_secret'] ."&redirect_uri=".urlencode($this->getRedirectUrl('&auth=zoho'))."&scope=".$this->scope."&grant_type=authorization_code&state=".$state;

		$response = wp_remote_retrieve_body(wp_remote_post( $url));
		$response = json_decode($response, true);

		if(isset($response['error'])){
			
			if($response['error'] == 'invalid_code'){
				$this->delete_option('auth_code', $this->mailer);
			}
			
			return $response['error'];
		}

		$access_token = $response['access_token'];
		$refresh_token = $response['refresh_token'];   

		$this->update_option('access_token', $access_token , $this->mailer);
		$this->update_option('refresh_token', $refresh_token, $this->mailer);

		return array(
			'access_token' => $access_token,
			'refresh_token' => $refresh_token
		);
	}

	public function zoho_account_id($access_token = ''){
        
		$from_email = $this->conn_id === 0 ? $this->getOption('from_email') : $this->getOption('from_email', $this->mailer,'');
		$accId = $this->getOption('account_id', $this->mailer, '');
		
		if(!empty($accId)){ 
			return;
		}

		$args = [
			'headers' => [
				'Authorization' => 'Zoho-oauthtoken '.$access_token
			]
		];

		$response = wp_remote_retrieve_body(wp_remote_get( $this->api_url, $args));
		$response = json_decode($response, true);

		if(empty($response)){
			return 'general_error';
		}

		if( isset($response['data']['errorCode']) ){
			return $response['data']['errorCode'];
		}

		for($i=0; $i<count($response['data']); $i++){
			for($j=0; $j<count($response['data'][$i]['sendMailDetails']); $j++) {
				if(strcmp($response['data'][$i]['sendMailDetails'][$j]['fromAddress'], $from_email) == 0){
					$this->update_option('account_id', $response['data'][0]['accountId'], $this->mailer);
				}else{
					return 'invalid_from';
				}
			}
		}
	}

	public function getAccessToken(	$options ){
		
		$setup_time = $options['setup_timestamp'];
		$access_token = $options['access_token'];

		if(empty($setup_time) || time() - $setup_time > 3000){

			$this->update_option('setup_timestamp', time(), $this->mailer);

			$url = $this->oauth_url.'token?refresh_token='.$options['refresh_token'].'&grant_type=refresh_token&client_id='.$options['client_id'].'&client_secret='.$options['client_secret'].'&redirect_uri='.urlencode($this->getRedirectUrl('&auth=zoho')).'&scope='.$this->scope;

			$response = wp_remote_retrieve_body( wp_remote_post( $url ) );
			$response = json_decode($response);
			
			$access_token = $response->access_token;
			
			$this->update_option('access_token', $access_token, $this->mailer);
		}
		
		return $access_token;
	}

	public function load_field(){
		
		$fields = array();
		$options = $this->getMailerOption();
		$client_id = $this->getOption('client_id', $this->mailer);
		$client_secret = $this->getOption('client_secret', $this->mailer);
		$opt_text = __('You need to save settings with Client ID and Client Secret before you can proceed.');
		$opt_type = 'notice';
		$opt_url = '';
		$readonly = '';

		$this->zoho_init();
		$_button = '';
		if(!empty($client_id) && !empty($client_secret) ){

			$opt_type = $_button = 'button';

			if(!$this->is_authorized()){
				$opt_url = $this->get_authcode_link($options);
				$opt_text = __('Authorize Zoho Account');
			}else{
				$query = '&zoho-deactivate=1';
				if(!is_numeric($this->conn_id)){
					$query = '&type=edit&conn_id='.$this->conn_id.$query.'#gosmtp-connections-settings';
				}
				$readonly = 'readonly=""';
				$opt_url = $this->getRedirectUrl($query);
				$opt_text = 'Deactivate Access Token';		        
			}
		}

		$fields = array(
			'domain_name' => array(
				'title' => __('Select domain name'),
				'type' => 'select',
				'list' => array(
					'com' => '.com',
					'eu' => '.eu',
					'in' => '.in',
					'com.cn' => '.com.cn',
					'com.au' => '.com.au',
					'jp' => '.jp',
				),
				'desc' => __( 'The name of the region the account is configured' ),
			),
			'client_id' => array(
				'title' => __('Client Id'),
				'type' => 'text',
				'class'=>'zoho_client_id',
				'desc' => __( 'Created in the developer console' ),
				'attr' => $readonly
			),
			'client_secret' => array(
				'title' => __('Client Secret'),
				'type' => 'password',
				'class'=>'zoho_client_secret',
				'desc' => __( 'Created in the developer console' ),
				'attr' => $readonly
			),
			'redirect_uri' => array(
				'title' => __('Authorization Redirect URI'),
				'type' => 'copy',
				'id' => 'zoho_redirect_uri',
				'attr' =>'readonly=""',
				'default' => $this->getRedirectUrl('&auth=zoho'),
				'desc' => __( 'Copy this URL into Redirect URI field of your Client Id creation' ),
			),
			'authorize' => array(
				'title' => __('Authorize'),
				'type' => $opt_type,
				'default' => $opt_text,
				'href' => $opt_url,
				'class' => 'auth_class gosmtp-auto-width '.$_button,
				'attr' => 'data-field=auth'
			)
		);

		return $fields;
	}
	
	public function zoho_deregister(){

		if(!empty(gosmtp_optget('conn_id')) && $this->conn_id === 0){
			return;
		}
		
		$this->delete_option('access_token', $this->mailer);
		$this->delete_option('refresh_token', $this->mailer);
		$this->delete_option('auth_code', $this->mailer);
		$this->delete_option('account_id', $this->mailer);
		$this->delete_option('setup_timestamp', $this->mailer);

		$query = '';
		if(!is_numeric($this->conn_id)){
			$query = '&type=edit&conn_id='.$this->conn_id.$query.'#gosmtp-connections-settings';
		}

		if(isset($_GET['conn_id'])){
			echo '<script>
				var url = "'.$this->getRedirectUrl($query).'";
				history.pushState({urlPath:url},"",url);
			</script>';
		}
		
	}

	public function zoho_init(){

		$this->setConfig();
		if(isset( $_GET['zoho-deactivate'] )){
			$this->zoho_deregister();
			return;
		}

		if( !$this->is_authorized() && isset( $_GET['auth_code'] ) && isset( $_GET['auth'] ) && $this->mailer == $_GET['auth'] && strlen($this->conn_id) > 0){
			
			if( !empty(gosmtp_optget('conn_id')) && $this->conn_id === 0 ){
				return;
			}
			
			// TODO sanitize  $_GET['code']
			$this->update_option('auth_code', gosmtp_optget('auth_code'), $this->mailer);

			$response = $this->authentication_process();
			// var_dump($response);
			
			if( $response ){
				$msg = is_array($this->getLang($response)) ? $this->getLang('general_error') : $this->getLang($response);
			}
			
			$query = '';
			if(!is_numeric($this->conn_id)){
				$query = '&type=edit&conn_id='.$this->conn_id.$query.'#gosmtp-connections-settings';
			}
			
			echo '<script>
				alert("'.$msg.'")					
				var url = "'.$this->getRedirectUrl($query).'";
				history.pushState({urlPath:url},"",url);
			</script>';
		}
	}
    
}PK��f\p��s�s�plugin-update-checker.phpnu�[���<?php
/**
 * Plugin Update Checker Library 3.2
 * http://w-shadow.com/
 * 
 * Copyright 2016 Janis Elsts
 * Released under the MIT license. See license.txt for details.
 */

if ( !class_exists('SpeedyCacheUpdateChecker_3_2', false) ):

/**
 * A custom plugin update checker. 
 * 
 * @author Janis Elsts
 * @copyright 2016
 * @version 3.2
 * @access public
 */
#[\AllowDynamicProperties]
class SpeedyCacheUpdateChecker_3_2 {
	public $metadataUrl = ''; //The URL of the plugin's metadata file.
	public $pluginAbsolutePath = ''; //Full path of the main plugin file.
	public $pluginFile = '';  //Plugin filename relative to the plugins directory. Many WP APIs use this to identify plugins.
	public $slug = '';        //Plugin slug.
	public $optionName = '';  //Where to store the update info.
	public $muPluginFile = ''; //For MU plugins, the plugin filename relative to the mu-plugins directory.

	public $debugMode = false; //Set to TRUE to enable error reporting. Errors are raised using trigger_error()
                               //and should be logged to the standard PHP error log.
	public $scheduler;

	protected $upgraderStatus;

	private $debugBarPlugin = null;
	private $cachedInstalledVersion = null;

	private $metadataHost = ''; //The host component of $metadataUrl.

	/**
	 * Class constructor.
	 *
	 * @param string $metadataUrl The URL of the plugin's metadata file.
	 * @param string $pluginFile Fully qualified path to the main plugin file.
	 * @param string $slug The plugin's 'slug'. If not specified, the filename part of $pluginFile sans '.php' will be used as the slug.
	 * @param integer $checkPeriod How often to check for updates (in hours). Defaults to checking every 12 hours. Set to 0 to disable automatic update checks.
	 * @param string $optionName Where to store book-keeping info about update checks. Defaults to 'external_updates-$slug'.
	 * @param string $muPluginFile Optional. The plugin filename relative to the mu-plugins directory.
	 */
	public function __construct($metadataUrl, $pluginFile, $slug = '', $checkPeriod = 12, $optionName = '', $muPluginFile = ''){
		$this->metadataUrl = $metadataUrl;
		$this->pluginAbsolutePath = $pluginFile;
		$this->pluginFile = plugin_basename($this->pluginAbsolutePath);
		$this->muPluginFile = $muPluginFile;
		$this->slug = $slug;
		$this->optionName = $optionName;
		$this->debugMode = (bool)(constant('WP_DEBUG'));

		//If no slug is specified, use the name of the main plugin file as the slug.
		//For example, 'my-cool-plugin/cool-plugin.php' becomes 'cool-plugin'.
		if ( empty($this->slug) ){
			$this->slug = basename($this->pluginFile, '.php');
		}

		//Plugin slugs must be unique.
		$slugCheckFilter = 'puc_is_slug_in_use-' . $this->slug;
		$slugUsedBy = apply_filters($slugCheckFilter, false);
		if ( $slugUsedBy ) {
			$this->triggerError(sprintf(
				'Plugin slug "%s" is already in use by %s. Slugs must be unique.',
				htmlentities($this->slug),
				htmlentities($slugUsedBy)
			), E_USER_ERROR);
		}
		add_filter($slugCheckFilter, array($this, 'getAbsolutePath'));

		
		if ( empty($this->optionName) ){
			$this->optionName = 'external_updates-' . $this->slug;
		}

		//Backwards compatibility: If the plugin is a mu-plugin but no $muPluginFile is specified, assume
		//it's the same as $pluginFile given that it's not in a subdirectory (WP only looks in the base dir).
		if ( (strpbrk($this->pluginFile, '/\\') === false) && $this->isUnknownMuPlugin() ) {
			$this->muPluginFile = $this->pluginFile;
		}

		$this->scheduler = $this->createScheduler($checkPeriod);
		$this->upgraderStatus = new SpeedyCache_PucUpgraderStatus_3_2();

		$this->installHooks();
	}

	/**
	 * Create an instance of the scheduler.
	 *
	 * This is implemented as a method to make it possible for plugins to subclass the update checker
	 * and substitute their own scheduler.
	 *
	 * @param int $checkPeriod
	 * @return SpeedyCache_PucScheduler_3_2
	 */
	protected function createScheduler($checkPeriod) {
		return new SpeedyCache_PucScheduler_3_2($this, $checkPeriod);
	}
	
	/**
	 * Install the hooks required to run periodic update checks and inject update info 
	 * into WP data structures. 
	 * 
	 * @return void
	 */
	protected function installHooks(){
		//Override requests for plugin information
		add_filter('plugins_api', array($this, 'injectInfo'), 20, 3);
		
		//Insert our update info into the update array maintained by WP.
		add_filter('site_transient_update_plugins', array($this,'injectUpdate')); //WP 3.0+
		add_filter('transient_update_plugins', array($this,'injectUpdate')); //WP 2.8+
		add_filter('site_transient_update_plugins', array($this, 'injectTranslationUpdates'));

		add_filter('plugin_row_meta', array($this, 'addCheckForUpdatesLink'), 10, 2);
		add_action('admin_init', array($this, 'handleManualCheck'));
		add_action('all_admin_notices', array($this, 'displayManualCheckResult'));

		//Clear the version number cache when something - anything - is upgraded or WP clears the update cache.
		add_filter('upgrader_post_install', array($this, 'clearCachedVersion'));
		add_action('delete_site_transient_update_plugins', array($this, 'clearCachedVersion'));
		//Clear translation updates when WP clears the update cache.
		//This needs to be done directly because the library doesn't actually remove obsolete plugin updates,
		//it just hides them (see getUpdate()). We can't do that with translations - too much disk I/O.
		add_action('delete_site_transient_update_plugins', array($this, 'clearCachedTranslationUpdates'));

		if ( did_action('plugins_loaded') ) {
			$this->initDebugBarPanel();
		} else {
			add_action('plugins_loaded', array($this, 'initDebugBarPanel'));
		}

		//Rename the update directory to be the same as the existing directory.
		add_filter('upgrader_source_selection', array($this, 'fixDirectoryName'), 10, 3);

		//Enable language support (i18n).
		load_plugin_textdomain('plugin-update-checker', false, plugin_basename(dirname(__FILE__)) . '/languages');

		//Allow HTTP requests to the metadata URL even if it's on a local host.
		$this->metadataHost = @parse_url($this->metadataUrl, PHP_URL_HOST);
		add_filter('http_request_host_is_external', array($this, 'allowMetadataHost'), 10, 2);
	}
	
	/**
	 * Explicitly allow HTTP requests to the metadata URL.
	 *
	 * WordPress has a security feature where the HTTP API will reject all requests that are sent to
	 * another site hosted on the same server as the current site (IP match), a local host, or a local
	 * IP, unless the host exactly matches the current site.
	 *
	 * This feature is opt-in (at least in WP 4.4). Apparently some people enable it.
	 *
	 * That can be a problem when you're developing your plugin and you decide to host the update information
	 * on the same server as your test site. Update requests will mysteriously fail.
	 *
	 * We fix that by adding an exception for the metadata host.
	 *
	 * @param bool $allow
	 * @param string $host
	 * @return bool
	 */
	public function allowMetadataHost($allow, $host) {
		if ( strtolower($host) === strtolower($this->metadataHost) ) {
			return true;
		}
		return $allow;
	}

	/**
	 * Retrieve plugin info from the configured API endpoint.
	 * 
	 * @uses wp_remote_get()
	 * 
	 * @param array $queryArgs Additional query arguments to append to the request. Optional.
	 * @return SpeedyCacheInfo_3_2
	 */
	public function requestInfo($queryArgs = array()){
		//Query args to append to the URL. Plugins can add their own by using a filter callback (see addQueryArgFilter()).
		$installedVersion = $this->getInstalledVersion();
		$queryArgs['installed_version'] = ($installedVersion !== null) ? $installedVersion : '';
		$queryArgs = apply_filters('puc_request_info_query_args-'.$this->slug, $queryArgs);
		
		//Various options for the wp_remote_get() call. Plugins can filter these, too.
		$options = array(
			'timeout' => 10, //seconds
			'headers' => array(
				'Accept' => 'application/json'
			),
		);
		$options = apply_filters('puc_request_info_options-'.$this->slug, $options);
		
		//The plugin info should be at 'http://your-api.com/url/here/$slug/info.json'
		$url = $this->metadataUrl; 
		if ( !empty($queryArgs) ){
			$url = add_query_arg($queryArgs, $url);
		}
		
		$result = wp_remote_get(
			$url,
			$options
		);

		//Try to parse the response
		$status = $this->validateApiResponse($result);
		$pluginInfo = null;
		if ( !is_wp_error($status) ){
			$pluginInfo = SpeedyCacheInfo_3_2::fromJson($result['body']);
			if ( $pluginInfo !== null ) {
				$pluginInfo->filename = $this->pluginFile;
				$pluginInfo->slug = $this->slug;
			}
		} else {
			$this->triggerError(
				sprintf('The URL %s does not point to a valid plugin metadata file. ', $url)
					. $status->get_error_message(),
				E_USER_WARNING
			);
		}

		$pluginInfo = apply_filters('puc_request_info_result-'.$this->slug, $pluginInfo, $result);
		return $pluginInfo;
	}

	/**
	 * Check if $result is a successful update API response.
	 *
	 * @param array|WP_Error $result
	 * @return true|WP_Error
	 */
	private function validateApiResponse($result) {
		if ( is_wp_error($result) ) { /** @var WP_Error $result */
			return new WP_Error($result->get_error_code(), 'WP HTTP Error: ' . $result->get_error_message());
		}

		if ( !isset($result['response']['code']) ) {
			return new WP_Error('puc_no_response_code', 'wp_remote_get() returned an unexpected result.');
		}

		if ( $result['response']['code'] !== 200 ) {
			return new WP_Error(
				'puc_unexpected_response_code',
				'HTTP response code is ' . $result['response']['code'] . ' (expected: 200)'
			);
		}

		if ( empty($result['body']) ) {
			return new WP_Error('puc_empty_response', 'The metadata file appears to be empty.');
		}

		return true;
	}

	/**
	 * Retrieve the latest update (if any) from the configured API endpoint.
	 *
	 * @uses SpeedyCacheUpdateChecker::requestInfo()
	 *
	 * @return SpeedyCacheUpdate_3_2 An instance of SpeedyCacheUpdate, or NULL when no updates are available.
	 */
	public function requestUpdate(){
		//For the sake of simplicity, this function just calls requestInfo() 
		//and transforms the result accordingly.
		$pluginInfo = $this->requestInfo(array('checking_for_updates' => '1'));
		if ( $pluginInfo == null ){
			return null;
		}
		$update = SpeedyCacheUpdate_3_2::fromSpeedyCacheInfo($pluginInfo);

		//Keep only those translation updates that apply to this site.
		$update->translations = $this->filterApplicableTranslations($update->translations);

		return $update;
	}

	/**
	 * Filter a list of translation updates and return a new list that contains only updates
	 * that apply to the current site.
	 *
	 * @param array $translations
	 * @return array
	 */
	private function filterApplicableTranslations($translations) {
		$languages = array_flip(array_values(get_available_languages()));
		$installedTranslations = wp_get_installed_translations('plugins');
		if ( isset($installedTranslations[$this->slug]) ) {
			$installedTranslations = $installedTranslations[$this->slug];
		} else {
			$installedTranslations = array();
		}

		$applicableTranslations = array();
		foreach($translations as $translation) {
			//Does it match one of the available core languages?
			$isApplicable = array_key_exists($translation->language, $languages);
			//Is it more recent than an already-installed translation?
			if ( isset($installedTranslations[$translation->language]) ) {
				$updateTimestamp = strtotime($translation->updated);
				$installedTimestamp = strtotime($installedTranslations[$translation->language]['PO-Revision-Date']);
				$isApplicable = $updateTimestamp > $installedTimestamp;
			}

			if ( $isApplicable ) {
				$applicableTranslations[] = $translation;
			}
		}

		return $applicableTranslations;
	}
	
	/**
	 * Get the currently installed version of the plugin.
	 * 
	 * @return string Version number.
	 */
	public function getInstalledVersion(){
		if ( isset($this->cachedInstalledVersion) ) {
			return $this->cachedInstalledVersion;
		}

		$pluginHeader = $this->getPluginHeader();
		if ( isset($pluginHeader['Version']) ) {
			$this->cachedInstalledVersion = $pluginHeader['Version'];
			return $pluginHeader['Version'];
		} else {
			//This can happen if the filename points to something that is not a plugin.
			$this->triggerError(
				sprintf(
					"Can't to read the Version header for '%s'. The filename is incorrect or is not a plugin.",
					$this->pluginFile
				),
				E_USER_WARNING
			);
			return null;
		}
	}

	/**
	 * Get plugin's metadata from its file header.
	 *
	 * @return array
	 */
	protected function getPluginHeader() {
		if ( !is_file($this->pluginAbsolutePath) ) {
			//This can happen if the plugin filename is wrong.
			$this->triggerError(
				sprintf(
					"Can't to read the plugin header for '%s'. The file does not exist.",
					$this->pluginFile
				),
				E_USER_WARNING
			);
			return array();
		}

		if ( !function_exists('get_plugin_data') ){
			/** @noinspection PhpIncludeInspection */
			require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
		}
		return get_plugin_data($this->pluginAbsolutePath, false, false);
	}

	/**
	 * Check for plugin updates.
	 * The results are stored in the DB option specified in $optionName.
	 *
	 * @return SpeedyCacheUpdate_3_2|null
	 */
	public function checkForUpdates(){
		$installedVersion = $this->getInstalledVersion();
		//Fail silently if we can't find the plugin or read its header.
		if ( $installedVersion === null ) {
			$this->triggerError(
				sprintf('Skipping update check for %s - installed version unknown.', $this->pluginFile),
				E_USER_WARNING
			);
			return null;
		}

		$state = $this->getUpdateState();
		if ( empty($state) ){
			$state = new stdClass;
			$state->lastCheck = 0;
			$state->checkedVersion = '';
			$state->update = null;
		}
		
		$state->lastCheck = time();
		$state->checkedVersion = $installedVersion;
		$this->setUpdateState($state); //Save before checking in case something goes wrong 
		
		$state->update = $this->requestUpdate();
		$this->setUpdateState($state);

		return $this->getUpdate();
	}
	
	/**
	 * Load the update checker state from the DB.
	 *  
	 * @return stdClass|null
	 */
	public function getUpdateState() {
		$state = get_site_option($this->optionName, null);
		if ( empty($state) || !is_object($state)) {
			$state = null;
		}

		if ( isset($state, $state->update) && is_object($state->update) ) {
			$state->update = SpeedyCacheUpdate_3_2::fromObject($state->update);
		}
		return $state;
	}
	
	
	/**
	 * Persist the update checker state to the DB.
	 * 
	 * @param StdClass $state
	 * @return void
	 */
	private function setUpdateState($state) {
		if ( isset($state->update) && is_object($state->update) && method_exists($state->update, 'toStdClass') ) {
			$update = $state->update; /** @var SpeedyCacheUpdate_3_2 $update */
			$state->update = $update->toStdClass();
		}
		update_site_option($this->optionName, $state);
	}

	/**
	 * Reset update checker state - i.e. last check time, cached update data and so on.
	 *
	 * Call this when your plugin is being uninstalled, or if you want to
	 * clear the update cache.
	 */
	public function resetUpdateState() {
		delete_site_option($this->optionName);
	}
	
	/**
	 * Intercept plugins_api() calls that request information about our plugin and 
	 * use the configured API endpoint to satisfy them. 
	 * 
	 * @see plugins_api()
	 * 
	 * @param mixed $result
	 * @param string $action
	 * @param array|object $args
	 * @return mixed
	 */
	public function injectInfo($result, $action = null, $args = null){
    	$relevant = ($action == 'plugin_information') && isset($args->slug) && (
			($args->slug == $this->slug) || ($args->slug == dirname($this->pluginFile))
		);
		if ( !$relevant ) {
			return $result;
		}
		
		$pluginInfo = $this->requestInfo();
		$pluginInfo = apply_filters('puc_pre_inject_info-' . $this->slug, $pluginInfo);
		if ( $pluginInfo ) {
			return $pluginInfo->toWpFormat();
		}
				
		return $result;
	}
	
	/**
	 * Insert the latest update (if any) into the update list maintained by WP.
	 * 
	 * @param StdClass $updates Update list.
	 * @return StdClass Modified update list.
	 */
	public function injectUpdate($updates){
		//Is there an update to insert?
		$update = $this->getUpdate();

		//No update notifications for mu-plugins unless explicitly enabled. The MU plugin file
		//is usually different from the main plugin file so the update wouldn't show up properly anyway.
		if ( $this->isUnknownMuPlugin() ) {
			$update = null;
		}

		if ( !empty($update) ) {
			//Let plugins filter the update info before it's passed on to WordPress.
			$update = apply_filters('puc_pre_inject_update-' . $this->slug, $update);
			$updates = $this->addUpdateToList($updates, $update);
		} else {
			//Clean up any stale update info.
			$updates = $this->removeUpdateFromList($updates);
		}

		return $updates;
	}

	/**
	 * @param StdClass|null $updates
	 * @param SpeedyCacheUpdate_3_2 $updateToAdd
	 * @return StdClass
	 */
	private function addUpdateToList($updates, $updateToAdd) {
		if ( !is_object($updates) ) {
			$updates = new stdClass();
			$updates->response = array();
		}

		$wpUpdate = $updateToAdd->toWpFormat();
		$pluginFile = $this->pluginFile;

		if ( $this->isMuPlugin() ) {
			//WP does not support automatic update installation for mu-plugins, but we can still display a notice.
			$wpUpdate->package = null;
			$pluginFile = $this->muPluginFile;
		}
		$updates->response[$pluginFile] = $wpUpdate;
		return $updates;
	}

	/**
	 * @param stdClass|null $updates
	 * @return stdClass|null
	 */
	private function removeUpdateFromList($updates) {
		if ( isset($updates, $updates->response) ) {
			unset($updates->response[$this->pluginFile]);
			if ( !empty($this->muPluginFile) ) {
				unset($updates->response[$this->muPluginFile]);
			}
		}
		return $updates;
	}

	/**
	 * Insert translation updates into the list maintained by WordPress.
	 *
	 * @param stdClass $updates
	 * @return stdClass
	 */
	public function injectTranslationUpdates($updates) {
		$translationUpdates = $this->getTranslationUpdates();
		if ( empty($translationUpdates) ) {
			return $updates;
		}

		//Being defensive.
		if ( !is_object($updates) ) {
			$updates = new stdClass();
		}
		if ( !isset($updates->translations) ) {
			$updates->translations = array();
		}

		//In case there's a name collision with a plugin hosted on wordpress.org,
		//remove any preexisting updates that match our plugin.
		$translationType = 'plugin';
		$filteredTranslations = array();
		foreach($updates->translations as $translation) {
			if ( ($translation['type'] === $translationType) && ($translation['slug'] === $this->slug) ) {
				continue;
			}
			$filteredTranslations[] = $translation;
		}
		$updates->translations = $filteredTranslations;

		//Add our updates to the list.
		foreach($translationUpdates as $update) {
			$convertedUpdate = array_merge(
				array(
					'type' => $translationType,
					'slug' => $this->slug,
					'autoupdate' => 0,
					//AFAICT, WordPress doesn't actually use the "version" field for anything.
					//But lets make sure it's there, just in case.
					'version' => isset($update->version) ? $update->version : ('1.' . strtotime($update->updated)),
				),
				(array)$update
			);

			$updates->translations[] = $convertedUpdate;
		}

		return $updates;
	}

	/**
	 * Rename the update directory to match the existing plugin directory.
	 *
	 * When WordPress installs a plugin or theme update, it assumes that the ZIP file will contain
	 * exactly one directory, and that the directory name will be the same as the directory where
	 * the plugin/theme is currently installed.
	 *
	 * GitHub and other repositories provide ZIP downloads, but they often use directory names like
	 * "project-branch" or "project-tag-hash". We need to change the name to the actual plugin folder.
	 *
	 * This is a hook callback. Don't call it from a plugin.
	 *
	 * @param string $source The directory to copy to /wp-content/plugins. Usually a subdirectory of $remoteSource.
	 * @param string $remoteSource WordPress has extracted the update to this directory.
	 * @param WP_Upgrader $upgrader
	 * @return string|WP_Error
	 */
	public function fixDirectoryName($source, $remoteSource, $upgrader) {
		global $wp_filesystem; /** @var WP_Filesystem_Base $wp_filesystem */

		//Basic sanity checks.
		if ( !isset($source, $remoteSource, $upgrader, $upgrader->skin, $wp_filesystem) ) {
			return $source;
		}

		//If WordPress is upgrading anything other than our plugin, leave the directory name unchanged.
		if ( !$this->isPluginBeingUpgraded($upgrader) ) {
			return $source;
		}

		//Rename the source to match the existing plugin directory.
		$pluginDirectoryName = dirname($this->pluginFile);
		if ( $pluginDirectoryName === '.' ) {
			return $source;
		}
		$correctedSource = trailingslashit($remoteSource) . $pluginDirectoryName . '/';
		if ( $source !== $correctedSource ) {
			//The update archive should contain a single directory that contains the rest of plugin files. Otherwise,
			//WordPress will try to copy the entire working directory ($source == $remoteSource). We can't rename
			//$remoteSource because that would break WordPress code that cleans up temporary files after update.
			if ( $this->isBadDirectoryStructure($remoteSource) ) {
				return new WP_Error(
					'puc-incorrect-directory-structure',
					sprintf(
						'The directory structure of the update is incorrect. All plugin files should be inside ' .
						'a directory named <span class="code">%s</span>, not at the root of the ZIP file.',
						htmlentities($this->slug)
					)
				);
			}

			/** @var WP_Upgrader_Skin $upgrader->skin */
			$upgrader->skin->feedback(sprintf(
				'Renaming %s to %s&#8230;',
				'<span class="code">' . basename($source) . '</span>',
				'<span class="code">' . $pluginDirectoryName . '</span>'
			));

			if ( $wp_filesystem->move($source, $correctedSource, true) ) {
				$upgrader->skin->feedback('Plugin directory successfully renamed.');
				return $correctedSource;
			} else {
				return new WP_Error(
					'puc-rename-failed',
					'Unable to rename the update to match the existing plugin directory.'
				);
			}
		}

		return $source;
	}

	/**
	 * Check for incorrect update directory structure. An update must contain a single directory,
	 * all other files should be inside that directory.
	 *
	 * @param string $remoteSource Directory path.
	 * @return bool
	 */
	private function isBadDirectoryStructure($remoteSource) {
		global $wp_filesystem; /** @var WP_Filesystem_Base $wp_filesystem */

		$sourceFiles = $wp_filesystem->dirlist($remoteSource);
		if ( is_array($sourceFiles) ) {
			$sourceFiles = array_keys($sourceFiles);
			$firstFilePath = trailingslashit($remoteSource) . $sourceFiles[0];
			return (count($sourceFiles) > 1) || (!$wp_filesystem->is_dir($firstFilePath));
		}

		//Assume it's fine.
		return false;
	}

	/**
	 * Is there and update being installed RIGHT NOW, for this specific plugin?
	 *
	 * @param WP_Upgrader|null $upgrader The upgrader that's performing the current update.
	 * @return bool
	 */
	public function isPluginBeingUpgraded($upgrader = null) {
		return $this->upgraderStatus->isPluginBeingUpgraded($this->pluginFile, $upgrader);
	}

	/**
	 * Get the details of the currently available update, if any.
	 *
	 * If no updates are available, or if the last known update version is below or equal
	 * to the currently installed version, this method will return NULL.
	 *
	 * Uses cached update data. To retrieve update information straight from
	 * the metadata URL, call requestUpdate() instead.
	 *
	 * @return SpeedyCacheUpdate_3_2|null
	 */
	public function getUpdate() {
		$state = $this->getUpdateState(); /** @var StdClass $state */

		//Is there an update available?
		if ( isset($state, $state->update) ) {
			$update = $state->update;
			//Check if the update is actually newer than the currently installed version.
			$installedVersion = $this->getInstalledVersion();
			if ( ($installedVersion !== null) && version_compare($update->version, $installedVersion, '>') ){
				$update->filename = $this->pluginFile;
				return $update;
			}
		}
		return null;
	}

	/**
	 * Get a list of available translation updates.
	 *
	 * This method will return an empty array if there are no updates.
	 * Uses cached update data.
	 *
	 * @return array
	 */
	public function getTranslationUpdates() {
		$state = $this->getUpdateState();
		if ( isset($state, $state->update, $state->update->translations) ) {
			return $state->update->translations;
		}
		return array();
	}

	/**
	 * Remove all cached translation updates.
	 *
	 * @see wp_clean_update_cache
	 */
	public function clearCachedTranslationUpdates() {
		$state = $this->getUpdateState();
		if ( isset($state, $state->update, $state->update->translations) ) {
			$state->update->translations = array();
			$this->setUpdateState($state);
		}
	}

	/**
	 * Add a "Check for updates" link to the plugin row in the "Plugins" page. By default,
	 * the new link will appear after the "Visit plugin site" link.
	 *
	 * You can change the link text by using the "puc_manual_check_link-$slug" filter.
	 * Returning an empty string from the filter will disable the link.
	 *
	 * @param array $pluginMeta Array of meta links.
	 * @param string $pluginFile
	 * @return array
	 */
	public function addCheckForUpdatesLink($pluginMeta, $pluginFile) {
		$isRelevant = ($pluginFile == $this->pluginFile)
		              || (!empty($this->muPluginFile) && $pluginFile == $this->muPluginFile);

		if ( $isRelevant && current_user_can('update_plugins') ) {
			$linkUrl = wp_nonce_url(
				add_query_arg(
					array(
						'puc_check_for_updates' => 1,
						'puc_slug' => $this->slug,
					),
					self_admin_url('plugins.php')
				),
				'puc_check_for_updates'
			);

			$linkText = apply_filters('puc_manual_check_link-' . $this->slug, __('Check for updates', 'plugin-update-checker'));
			if ( !empty($linkText) ) {
				$final_link = sprintf('<a href="%s">%s</a>', esc_attr($linkUrl), $linkText);
				$pluginMeta[] = apply_filters('puc_manual_final_check_link-' . $this->slug, $final_link);
			}
		}
		return $pluginMeta;
	}

	/**
	 * Check for updates when the user clicks the "Check for updates" link.
	 * @see self::addCheckForUpdatesLink()
	 *
	 * @return void
	 */
	public function handleManualCheck() {
		$shouldCheck =
			   isset($_GET['puc_check_for_updates'], $_GET['puc_slug'])
			&& $_GET['puc_slug'] == $this->slug
			&& current_user_can('update_plugins')
			&& check_admin_referer('puc_check_for_updates');

		if ( $shouldCheck ) {
			$update = $this->checkForUpdates();
			$status = ($update === null) ? 'no_update' : 'update_available';
			wp_redirect(add_query_arg(
				array(
					'puc_update_check_result' => $status,
					'puc_slug' => $this->slug,
				),
				self_admin_url('plugins.php')
			));
		}
	}

	/**
	 * Display the results of a manual update check.
	 * @see self::handleManualCheck()
	 *
	 * You can change the result message by using the "puc_manual_check_message-$slug" filter.
	 */
	public function displayManualCheckResult() {
		if ( isset($_GET['puc_update_check_result'], $_GET['puc_slug']) && ($_GET['puc_slug'] == $this->slug) ) {
			$status = strval($_GET['puc_update_check_result']);
			if ( $status == 'no_update' ) {
				$message = __('This plugin is up to date.', 'plugin-update-checker');
			} else if ( $status == 'update_available' ) {
				$message = __('A new version of this plugin is available.', 'plugin-update-checker');
			} else {
				$message = sprintf(__('Unknown update checker status "%s"', 'plugin-update-checker'), htmlentities($status));
			}
			printf(
				'<div class="updated notice is-dismissible"><p>%s</p></div>',
				apply_filters('puc_manual_check_message-' . $this->slug, $message, $status)
			);
		}
	}

	/**
	 * Check if the plugin file is inside the mu-plugins directory.
	 *
	 * @return bool
	 */
	protected function isMuPlugin() {
		static $cachedResult = null;

		if ( $cachedResult === null ) {
			//Convert both paths to the canonical form before comparison.
			$muPluginDir = realpath(WPMU_PLUGIN_DIR);
			$pluginPath  = realpath($this->pluginAbsolutePath);
			
			if(!empty($muPluginDir)){
				$cachedResult = (strpos($pluginPath, $muPluginDir) === 0);
			}else{
				$cachedResult = false;
			}
		}

		return $cachedResult;
	}

	/**
	 * MU plugins are partially supported, but only when we know which file in mu-plugins
	 * corresponds to this plugin.
	 *
	 * @return bool
	 */
	protected function isUnknownMuPlugin() {
		return empty($this->muPluginFile) && $this->isMuPlugin();
	}

	/**
	 * Clear the cached plugin version. This method can be set up as a filter (hook) and will
	 * return the filter argument unmodified.
	 *
	 * @param mixed $filterArgument
	 * @return mixed
	 */
	public function clearCachedVersion($filterArgument = null) {
		$this->cachedInstalledVersion = null;
		return $filterArgument;
	}

	/**
	 * Get absolute path to the main plugin file.
	 *
	 * @return string
	 */
	public function getAbsolutePath() {
		return $this->pluginAbsolutePath;
	}

	/**
	 * Register a callback for filtering query arguments. 
	 * 
	 * The callback function should take one argument - an associative array of query arguments.
	 * It should return a modified array of query arguments.
	 * 
	 * @uses add_filter() This method is a convenience wrapper for add_filter().
	 * 
	 * @param callable $callback
	 * @return void
	 */
	public function addQueryArgFilter($callback){
		add_filter('puc_request_info_query_args-'.$this->slug, $callback);
	}
	
	/**
	 * Register a callback for filtering arguments passed to wp_remote_get().
	 * 
	 * The callback function should take one argument - an associative array of arguments -
	 * and return a modified array or arguments. See the WP documentation on wp_remote_get()
	 * for details on what arguments are available and how they work. 
	 * 
	 * @uses add_filter() This method is a convenience wrapper for add_filter().
	 * 
	 * @param callable $callback
	 * @return void
	 */
	public function addHttpRequestArgFilter($callback){
		add_filter('puc_request_info_options-'.$this->slug, $callback);
	}
	
	/**
	 * Register a callback for filtering the plugin info retrieved from the external API.
	 * 
	 * The callback function should take two arguments. If the plugin info was retrieved 
	 * successfully, the first argument passed will be an instance of  SpeedyCacheInfo. Otherwise, 
	 * it will be NULL. The second argument will be the corresponding return value of 
	 * wp_remote_get (see WP docs for details).
	 *  
	 * The callback function should return a new or modified instance of SpeedyCacheInfo or NULL.
	 * 
	 * @uses add_filter() This method is a convenience wrapper for add_filter().
	 * 
	 * @param callable $callback
	 * @return void
	 */
	public function addResultFilter($callback){
		add_filter('puc_request_info_result-'.$this->slug, $callback, 10, 2);
	}

	/**
	 * Register a callback for one of the update checker filters.
	 *
	 * Identical to add_filter(), except it automatically adds the "puc_" prefix
	 * and the "-$plugin_slug" suffix to the filter name. For example, "request_info_result"
	 * becomes "puc_request_info_result-your_plugin_slug".
	 *
	 * @param string $tag
	 * @param callable $callback
	 * @param int $priority
	 * @param int $acceptedArgs
	 */
	public function addFilter($tag, $callback, $priority = 10, $acceptedArgs = 1) {
		add_filter('puc_' . $tag . '-' . $this->slug, $callback, $priority, $acceptedArgs);
	}

	/**
	 * Initialize the update checker Debug Bar plugin/add-on thingy.
	 */
	public function initDebugBarPanel() {
		$debugBarPlugin = dirname(__FILE__) . '/debug-bar-plugin.php';
		if ( class_exists('Debug_Bar', false) && file_exists($debugBarPlugin) ) {
			/** @noinspection PhpIncludeInspection */
			require_once $debugBarPlugin;
			$this->debugBarPlugin = new SpeedyCache_PucDebugBarPlugin_3_2($this);
		}
	}

	/**
	 * Trigger a PHP error, but only when $debugMode is enabled.
	 *
	 * @param string $message
	 * @param int $errorType
	 */
	protected function triggerError($message, $errorType) {
		if ( $this->debugMode ) {
			trigger_error($message, $errorType);
		}
	}
}

endif;

if ( !class_exists('SpeedyCacheInfo_3_2', false) ):

/**
 * A container class for holding and transforming various plugin metadata.
 * 
 * @author Janis Elsts
 * @copyright 2016
 * @version 3.2
 * @access public
 */
#[\AllowDynamicProperties]
class SpeedyCacheInfo_3_2 {
	//Most fields map directly to the contents of the plugin's info.json file.
	//See the relevant docs for a description of their meaning.  
	public $name;
	public $slug;
	public $version;
	public $homepage;
	public $sections = array();
	public $banners;
	public $translations = array();
	public $download_url;

	public $author;
	public $author_homepage;
	
	public $requires;
	public $tested;
	public $upgrade_notice;
	
	public $rating;
	public $num_ratings;
	public $downloaded;
	public $active_installs;
	public $last_updated;
	
	public $id = 0; //The native WP.org API returns numeric plugin IDs, but they're not used for anything.

	public $filename; //Plugin filename relative to the plugins directory.
		
	/**
	 * Create a new instance of SpeedyCacheInfo from JSON-encoded plugin info 
	 * returned by an external update API.
	 * 
	 * @param string $json Valid JSON string representing plugin info.
	 * @return SpeedyCacheInfo_3_2|null New instance of SpeedyCacheInfo, or NULL on error.
	 */
	public static function fromJson($json){
		/** @var StdClass $apiResponse */
		$apiResponse = json_decode($json);
		if ( empty($apiResponse) || !is_object($apiResponse) ){
			trigger_error(
				"Failed to parse plugin metadata. Try validating your .json file with http://jsonlint.com/",
				E_USER_NOTICE
			);
			return null;
		}
		
		$valid = self::validateMetadata($apiResponse);
		if ( is_wp_error($valid) ){
			trigger_error($valid->get_error_message(), E_USER_NOTICE);
			return null;
		}
		
		$info = new self();
		foreach(get_object_vars($apiResponse) as $key => $value){
			$info->$key = $value;
		}

		//json_decode decodes assoc. arrays as objects. We want it as an array.
		$info->sections = (array)$info->sections;
		
		return $info;		
	}

	/**
	 * Very, very basic validation.
	 *
	 * @param StdClass $apiResponse
	 * @return bool|WP_Error
	 */
	protected static function validateMetadata($apiResponse) {
		if (
			!isset($apiResponse->name, $apiResponse->version)
			|| empty($apiResponse->name)
			|| empty($apiResponse->version)
		) {
			return new WP_Error(
				'puc-invalid-metadata',
				"The plugin metadata file does not contain the required 'name' and/or 'version' keys."
			);
		}
		return true;
	}

	
	/**
	 * Transform plugin info into the format used by the native WordPress.org API
	 * 
	 * @return object
	 */
	public function toWpFormat(){
		$info = new stdClass;
		
		//The custom update API is built so that many fields have the same name and format
		//as those returned by the native WordPress.org API. These can be assigned directly. 
		$sameFormat = array(
			'name', 'slug', 'version', 'requires', 'tested', 'rating', 'upgrade_notice',
			'num_ratings', 'downloaded', 'active_installs', 'homepage', 'last_updated',
		);
		foreach($sameFormat as $field){
			if ( isset($this->$field) ) {
				$info->$field = $this->$field;
			} else {
				$info->$field = null;
			}
		}

		//Other fields need to be renamed and/or transformed.
		$info->download_link = $this->download_url;
		$info->author = $this->getFormattedAuthor();
		$info->sections = array_merge(array('description' => ''), $this->sections);

		if ( !empty($this->banners) ) {
			//WP expects an array with two keys: "high" and "low". Both are optional.
			//Docs: https://wordpress.org/plugins/about/faq/#banners
			$info->banners = is_object($this->banners) ? get_object_vars($this->banners) : $this->banners;
			$info->banners = array_intersect_key($info->banners, array('high' => true, 'low' => true));
		}

		return $info;
	}

	protected function getFormattedAuthor() {
		if ( !empty($this->author_homepage) ){
			return sprintf('<a href="%s">%s</a>', $this->author_homepage, $this->author);
		}
		return $this->author;
	}
}
	
endif;

if ( !class_exists('SpeedyCacheUpdate_3_2', false) ):

/**
 * A simple container class for holding information about an available update.
 * 
 * @author Janis Elsts
 * @copyright 2016
 * @version 3.2
 * @access public
 */
#[\AllowDynamicProperties]
class SpeedyCacheUpdate_3_2 {
	public $id = 0;
	public $slug;
	public $version;
	public $homepage;
	public $download_url;
	public $upgrade_notice;
	public $tested;
	public $translations = array();
	public $filename; //Plugin filename relative to the plugins directory.

	private static $fields = array(
		'id', 'slug', 'version', 'homepage', 'tested',
		'download_url', 'upgrade_notice', 'filename',
		'translations'
	);
	
	/**
	 * Create a new instance of SpeedyCacheUpdate from its JSON-encoded representation.
	 * 
	 * @param string $json
	 * @return SpeedyCacheUpdate_3_2|null
	 */
	public static function fromJson($json){
		//Since update-related information is simply a subset of the full plugin info,
		//we can parse the update JSON as if it was a plugin info string, then copy over
		//the parts that we care about.
		$pluginInfo = SpeedyCacheInfo_3_2::fromJson($json);
		if ( $pluginInfo != null ) {
			return self::fromSpeedyCacheInfo($pluginInfo);
		} else {
			return null;
		}
	}

	/**
	 * Create a new instance of SpeedyCacheUpdate based on an instance of SpeedyCacheInfo.
	 * Basically, this just copies a subset of fields from one object to another.
	 * 
	 * @param SpeedyCacheInfo_3_2 $info
	 * @return SpeedyCacheUpdate_3_2
	 */
	public static function fromSpeedyCacheInfo($info){
		return self::fromObject($info);
	}
	
	/**
	 * Create a new instance of SpeedyCacheUpdate by copying the necessary fields from 
	 * another object.
	 *  
	 * @param StdClass|SpeedyCacheInfo_3_2|SpeedyCacheUpdate_3_2 $object The source object.
	 * @return SpeedyCacheUpdate_3_2 The new copy.
	 */
	public static function fromObject($object) {
		$update = new self();
		$fields = self::$fields;
		if ( !empty($object->slug) ) {
			$fields = apply_filters('puc_retain_fields-' . $object->slug, $fields);
		}
		foreach($fields as $field){
			if (property_exists($object, $field)) {
				$update->$field = $object->$field;
			}
		}
		return $update;
	}
	
	/**
	 * Create an instance of StdClass that can later be converted back to 
	 * a SpeedyCacheUpdate. Useful for serialization and caching, as it avoids
	 * the "incomplete object" problem if the cached value is loaded before
	 * this class.
	 * 
	 * @return StdClass
	 */
	public function toStdClass() {
		$object = new stdClass();
		$fields = self::$fields;
		if ( !empty($this->slug) ) {
			$fields = apply_filters('puc_retain_fields-' . $this->slug, $fields);
		}
		foreach($fields as $field){
			if (property_exists($this, $field)) {
				$object->$field = $this->$field;
			}
		}
		return $object;
	}
	
	
	/**
	 * Transform the update into the format used by WordPress native plugin API.
	 * 
	 * @return object
	 */
	public function toWpFormat(){
		$update = new stdClass;

		$update->id = $this->id;
		$update->slug = $this->slug;
		$update->new_version = $this->version;
		$update->url = $this->homepage;
		$update->package = $this->download_url;
		$update->tested = $this->tested;
		$update->plugin = $this->filename;

		if ( !empty($this->upgrade_notice) ){
			$update->upgrade_notice = $this->upgrade_notice;
		}
		
		return $update;
	}
}
	
endif;

if ( !class_exists('SpeedyCache_PucScheduler_3_2', false) ):

/**
 * The scheduler decides when and how often to check for updates.
 * It calls @see SpeedyCacheUpdateChecker::checkForUpdates() to perform the actual checks.
 *
 * @version 3.2
 */
#[\AllowDynamicProperties]
class SpeedyCache_PucScheduler_3_2 {
	public $checkPeriod = 12; //How often to check for updates (in hours).
	public $throttleRedundantChecks = false; //Check less often if we already know that an update is available.
	public $throttledCheckPeriod = 72;

	/**
	 * @var SpeedyCacheUpdateChecker_3_2
	 */
	protected $updateChecker;

	private $cronHook = null;

	/**
	 * Scheduler constructor.
	 *
	 * @param SpeedyCacheUpdateChecker_3_2 $updateChecker
	 * @param int $checkPeriod How often to check for updates (in hours).
	 */
	public function __construct($updateChecker, $checkPeriod) {
		$this->updateChecker = $updateChecker;
		$this->checkPeriod = $checkPeriod;

		//Set up the periodic update checks
		$this->cronHook = 'check_plugin_updates-' . $this->updateChecker->slug;
		if ( $this->checkPeriod > 0 ){

			//Trigger the check via Cron.
			//Try to use one of the default schedules if possible as it's less likely to conflict
			//with other plugins and their custom schedules.
			$defaultSchedules = array(
				1  => 'hourly',
				12 => 'twicedaily',
				24 => 'daily',
			);
			if ( array_key_exists($this->checkPeriod, $defaultSchedules) ) {
				$scheduleName = $defaultSchedules[$this->checkPeriod];
			} else {
				//Use a custom cron schedule.
				$scheduleName = 'every' . $this->checkPeriod . 'hours';
				add_filter('cron_schedules', array($this, '_addCustomSchedule'));
			}

			if ( !wp_next_scheduled($this->cronHook) && !defined('WP_INSTALLING') ) {
				wp_schedule_event(time(), $scheduleName, $this->cronHook);
			}
			add_action($this->cronHook, array($this, 'maybeCheckForUpdates'));

			register_deactivation_hook($this->updateChecker->pluginFile, array($this, '_removeUpdaterCron'));

			//In case Cron is disabled or unreliable, we also manually trigger
			//the periodic checks while the user is browsing the Dashboard.
			add_action( 'admin_init', array($this, 'maybeCheckForUpdates') );

			//Like WordPress itself, we check more often on certain pages.
			/** @see wp_update_plugins */
			add_action('load-update-core.php', array($this, 'maybeCheckForUpdates'));
			add_action('load-plugins.php', array($this, 'maybeCheckForUpdates'));
			add_action('load-update.php', array($this, 'maybeCheckForUpdates'));
			//This hook fires after a bulk update is complete.
			add_action('upgrader_process_complete', array($this, 'maybeCheckForUpdates'), 11, 0);

		} else {
			//Periodic checks are disabled.
			wp_clear_scheduled_hook($this->cronHook);
		}
	}

	/**
	 * Check for updates if the configured check interval has already elapsed.
	 * Will use a shorter check interval on certain admin pages like "Dashboard -> Updates" or when doing cron.
	 *
	 * You can override the default behaviour by using the "puc_check_now-$slug" filter.
	 * The filter callback will be passed three parameters:
	 *     - Current decision. TRUE = check updates now, FALSE = don't check now.
	 *     - Last check time as a Unix timestamp.
	 *     - Configured check period in hours.
	 * Return TRUE to check for updates immediately, or FALSE to cancel.
	 *
	 * This method is declared public because it's a hook callback. Calling it directly is not recommended.
	 */
	public function maybeCheckForUpdates(){
		if ( empty($this->checkPeriod) ){
			return;
		}

		$state = $this->updateChecker->getUpdateState();
		$shouldCheck =
			empty($state) ||
			!isset($state->lastCheck) ||
			( (time() - $state->lastCheck) >= $this->getEffectiveCheckPeriod() );

		//Let plugin authors substitute their own algorithm.
		$shouldCheck = apply_filters(
			'puc_check_now-' . $this->updateChecker->slug,
			$shouldCheck,
			(!empty($state) && isset($state->lastCheck)) ? $state->lastCheck : 0,
			$this->checkPeriod
		);

		if ( $shouldCheck ) {
			$this->updateChecker->checkForUpdates();
		}
	}

	/**
	 * Calculate the actual check period based on the current status and environment.
	 *
	 * @return int Check period in seconds.
	 */
	protected function getEffectiveCheckPeriod() {
		$currentFilter = current_filter();
		if ( in_array($currentFilter, array('load-update-core.php', 'upgrader_process_complete')) ) {
			//Check more often when the user visits "Dashboard -> Updates" or does a bulk update.
			$period = 60;
		} else if ( in_array($currentFilter, array('load-plugins.php', 'load-update.php')) ) {
			//Also check more often on the "Plugins" page and /wp-admin/update.php.
			$period = 3600;
		} else if ( $this->throttleRedundantChecks && ($this->updateChecker->getUpdate() !== null) ) {
			//Check less frequently if it's already known that an update is available.
			$period = $this->throttledCheckPeriod * 3600;
		} else if ( defined('DOING_CRON') && constant('DOING_CRON') ) {
			//WordPress cron schedules are not exact, so lets do an update check even
			//if slightly less than $checkPeriod hours have elapsed since the last check.
			$cronFuzziness = 20 * 60;
			$period = $this->checkPeriod * 3600 - $cronFuzziness;
		} else {
			$period = $this->checkPeriod * 3600;
		}

		return $period;
	}

	/**
	 * Add our custom schedule to the array of Cron schedules used by WP.
	 *
	 * @param array $schedules
	 * @return array
	 */
	public function _addCustomSchedule($schedules){
		if ( $this->checkPeriod && ($this->checkPeriod > 0) ){
			$scheduleName = 'every' . $this->checkPeriod . 'hours';
			$schedules[$scheduleName] = array(
				'interval' => $this->checkPeriod * 3600,
				'display' => sprintf('Every %d hours', $this->checkPeriod),
			);
		}
		return $schedules;
	}

	/**
	 * Remove the scheduled cron event that the library uses to check for updates.
	 *
	 * @return void
	 */
	public function _removeUpdaterCron(){
		wp_clear_scheduled_hook($this->cronHook);
	}

	/**
	 * Get the name of the update checker's WP-cron hook. Mostly useful for debugging.
	 *
	 * @return string
	 */
	public function getCronHookName() {
		return $this->cronHook;
	}
}

endif;


if ( !class_exists('SpeedyCache_PucUpgraderStatus_3_2', false) ):

/**
 * A utility class that helps figure out which plugin WordPress is upgrading.
 *
 * It may seem strange to have an separate class just for that, but the task is surprisingly complicated.
 * Core classes like Plugin_Upgrader don't expose the plugin file name during an in-progress update (AFAICT).
 * This class uses a few workarounds and heuristics to get the file name.
 */
#[\AllowDynamicProperties]
class SpeedyCache_PucUpgraderStatus_3_2 {
	private $upgradedPluginFile = null; //The plugin that is currently being upgraded by WordPress.

	public function __construct() {
		//Keep track of which plugin WordPress is currently upgrading.
		add_filter('upgrader_pre_install', array($this, 'setUpgradedPlugin'), 10, 2);
		add_filter('upgrader_package_options', array($this, 'setUpgradedPluginFromOptions'), 10, 1);
		add_filter('upgrader_post_install', array($this, 'clearUpgradedPlugin'), 10, 1);
		add_action('upgrader_process_complete', array($this, 'clearUpgradedPlugin'), 10, 1);
	}

	/**
	 * Is there and update being installed RIGHT NOW, for a specific plugin?
	 *
	 * Caution: This method is unreliable. WordPress doesn't make it easy to figure out what it is upgrading,
	 * and upgrader implementations are liable to change without notice.
	 *
	 * @param string $pluginFile The plugin to check.
	 * @param WP_Upgrader|null $upgrader The upgrader that's performing the current update.
	 * @return bool True if the plugin identified by $pluginFile is being upgraded.
	 */
	public function isPluginBeingUpgraded($pluginFile, $upgrader = null) {
		if ( isset($upgrader) ) {
			$upgradedPluginFile = $this->getPluginBeingUpgradedBy($upgrader);
			if ( !empty($upgradedPluginFile) ) {
				$this->upgradedPluginFile = $upgradedPluginFile;
			}
		}
		return ( !empty($this->upgradedPluginFile) && ($this->upgradedPluginFile === $pluginFile) );
	}

	/**
	 * Get the file name of the plugin that's currently being upgraded.
	 *
	 * @param Plugin_Upgrader|WP_Upgrader $upgrader
	 * @return string|null
	 */
	private function getPluginBeingUpgradedBy($upgrader) {
		if ( !isset($upgrader, $upgrader->skin) ) {
			return null;
		}

		//Figure out which plugin is being upgraded.
		$pluginFile = null;
		$skin = $upgrader->skin;
		if ( $skin instanceof Plugin_Upgrader_Skin ) {
			if ( isset($skin->plugin) && is_string($skin->plugin) && ($skin->plugin !== '') ) {
				$pluginFile = $skin->plugin;
			}
		} elseif ( isset($skin->plugin_info) && is_array($skin->plugin_info) ) {
			//This case is tricky because Bulk_Plugin_Upgrader_Skin (etc) doesn't actually store the plugin
			//filename anywhere. Instead, it has the plugin headers in $plugin_info. So the best we can
			//do is compare those headers to the headers of installed plugins.
			$pluginFile = $this->identifyPluginByHeaders($skin->plugin_info);
		}

		return $pluginFile;
	}

	/**
	 * Identify an installed plugin based on its headers.
	 *
	 * @param array $searchHeaders The plugin file header to look for.
	 * @return string|null Plugin basename ("foo/bar.php"), or NULL if we can't identify the plugin.
	 */
	private function identifyPluginByHeaders($searchHeaders) {
		if ( !function_exists('get_plugins') ){
			/** @noinspection PhpIncludeInspection */
			require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
		}

		$installedPlugins = get_plugins();
		$matches = array();
		foreach($installedPlugins as $pluginBasename => $headers) {
			$diff1 = array_diff_assoc($headers, $searchHeaders);
			$diff2 = array_diff_assoc($searchHeaders, $headers);
			if ( empty($diff1) && empty($diff2) ) {
				$matches[] = $pluginBasename;
			}
		}

		//It's possible (though very unlikely) that there could be two plugins with identical
		//headers. In that case, we can't unambiguously identify the plugin that's being upgraded.
		if ( count($matches) !== 1 ) {
			return null;
		}

		return reset($matches);
	}

	/**
	 * @access private
	 *
	 * @param mixed $input
	 * @param array $hookExtra
	 * @return mixed Returns $input unaltered.
	 */
	public function setUpgradedPlugin($input, $hookExtra) {
		if (!empty($hookExtra['plugin']) && is_string($hookExtra['plugin'])) {
			$this->upgradedPluginFile = $hookExtra['plugin'];
		} else {
			$this->upgradedPluginFile = null;
		}
		return $input;
	}

	/**
	 * @access private
	 *
	 * @param array $options
	 * @return array
	 */
	public function setUpgradedPluginFromOptions($options) {
		if (isset($options['hook_extra']['plugin']) && is_string($options['hook_extra']['plugin'])) {
			$this->upgradedPluginFile = $options['hook_extra']['plugin'];
		} else {
			$this->upgradedPluginFile = null;
		}
		return $options;
	}

	/**
	 * @access private
	 *
	 * @param mixed $input
	 * @return mixed Returns $input unaltered.
	 */
	public function clearUpgradedPlugin($input = null) {
		$this->upgradedPluginFile = null;
		return $input;
	}
}

endif;


if ( !class_exists('SpeedyCache_PucFactory', false) ):

/**
 * A factory that builds instances of other classes from this library.
 *
 * When multiple versions of the same class have been loaded (e.g. SpeedyCacheUpdateChecker 1.2
 * and 1.3), this factory will always use the latest available version. Register class
 * versions by calling {@link SpeedyCache_PucFactory::addVersion()}.
 *
 * At the moment it can only build instances of the SpeedyCacheUpdateChecker class. Other classes
 * are intended mainly for internal use and refer directly to specific implementations. If you
 * want to instantiate one of them anyway, you can use {@link SpeedyCache_PucFactory::getLatestClassVersion()}
 * to get the class name and then create it with <code>new $class(...)</code>.
 */
#[\AllowDynamicProperties]
class SpeedyCache_PucFactory {
	protected static $classVersions = array();
	protected static $sorted = false;

	/**
	 * Create a new instance of SpeedyCacheUpdateChecker.
	 *
	 * @see SpeedyCacheUpdateChecker::__construct()
	 *
	 * @param $metadataUrl
	 * @param $pluginFile
	 * @param string $slug
	 * @param int $checkPeriod
	 * @param string $optionName
	 * @param string $muPluginFile
	 * @return SpeedyCacheUpdateChecker_3_2
	 */
	public static function buildUpdateChecker($metadataUrl, $pluginFile, $slug = '', $checkPeriod = 12, $optionName = '', $muPluginFile = '') {
		$class = self::getLatestClassVersion('SpeedyCacheUpdateChecker');
		return new $class($metadataUrl, $pluginFile, $slug, $checkPeriod, $optionName, $muPluginFile);
	}

	/**
	 * Get the specific class name for the latest available version of a class.
	 *
	 * @param string $class
	 * @return string|null
	 */
	public static function getLatestClassVersion($class) {
		if ( !self::$sorted ) {
			self::sortVersions();
		}

		if ( isset(self::$classVersions[$class]) ) {
			return reset(self::$classVersions[$class]);
		} else {
			return null;
		}
	}

	/**
	 * Sort available class versions in descending order (i.e. newest first).
	 */
	protected static function sortVersions() {
		foreach ( self::$classVersions as $class => $versions ) {
			uksort($versions, array(__CLASS__, 'compareVersions'));
			self::$classVersions[$class] = $versions;
		}
		self::$sorted = true;
	}

	protected static function compareVersions($a, $b) {
		return -version_compare($a, $b);
	}

	/**
	 * Register a version of a class.
	 *
	 * @access private This method is only for internal use by the library.
	 *
	 * @param string $generalClass Class name without version numbers, e.g. 'SpeedyCacheUpdateChecker'.
	 * @param string $versionedClass Actual class name, e.g. 'SpeedyCacheUpdateChecker_1_2'.
	 * @param string $version Version number, e.g. '1.2'.
	 */
	public static function addVersion($generalClass, $versionedClass, $version) {
		if ( !isset(self::$classVersions[$generalClass]) ) {
			self::$classVersions[$generalClass] = array();
		}
		self::$classVersions[$generalClass][$version] = $versionedClass;
		self::$sorted = false;
	}
}

endif;

//Register classes defined in this file with the factory.
SpeedyCache_PucFactory::addVersion('SpeedyCacheUpdateChecker', 'SpeedyCacheUpdateChecker_3_2', '3.2');
SpeedyCache_PucFactory::addVersion('SpeedyCacheUpdate', 'SpeedyCacheUpdate_3_2', '3.2');
SpeedyCache_PucFactory::addVersion('SpeedyCacheInfo', 'SpeedyCacheInfo_3_2', '3.2');
SpeedyCache_PucFactory::addVersion('SpeedyCache_PucGitHubChecker', 'SpeedyCache_PucGitHubChecker_3_2', '3.2');
PK��f\� !_g:g:
smtp-logs.phpnu�[���<?php
// We need the ABSPATH
if (!defined('ABSPATH')) exit;

global $gosmtp;

if(empty($gosmtp->options['logs']['enable_logs']) ){

	echo '<h1>'.__('Email logs is disabled').'</h1>
	<div class="error notice">
		<p >'.__('To store and view email logs, please enable email logs from GoSMTP').' <a href="'.admin_url('admin.php?page=gosmtp#logs-settings').'">'.__('settings').'</a>.</p>
	</div>';
	
	return;
}

// Styles and Scripts
wp_enqueue_style( 'gosmtp-admin' );
wp_enqueue_script( 'gosmtp-admin' );

$filter = gosmtp_optget('filter');
$start = gosmtp_optget('from');
$end = gosmtp_optget('to');
$search = gosmtp_optget('search');

$default = array(
	'subject' => 'on',
	'date_send' => 'on',
	'action' => 'on'
);

$columns = !empty( $gosmtp->options['logs']['log_columns'] ) ?  maybe_unserialize($gosmtp->options['logs']['log_columns']) : array();

$columns = array_merge($default, $columns);

?>

<div class="wrap">
    <div class="wrap_header gosmtp-relative">
    	<h1><?php _e('SMTP LOGS') ?></h1>
    	<button id="gosmtp-testmail-btn" class="button button-primary">
		<i class="dashicons-before dashicons-email-alt" aria-hidden="true"></i>
		<span><?php _e('Test Mail') ?></span>
	</button>
    </div>
    <div style="width:100%;margin-top:20px;">
		<form action="<?php echo admin_url('admin.php') ?>">
			<input type="hidden" name="page" value="gosmtp-logs">
			<div class="gosmtp-search-wrap">
				<div class="gosmtp-search-container">
					<h3><?php _e('What are you searching for') ?></h3>
					<div class="gosmtp-search-list-icon">
						<span class="dashicons dashicons-search"></span>
						<input type="text" id="gosmtp-search-box" name="search" value="<?php echo esc_attr($search); ?>" placeholder="Search" />
					</div>
				</div>
				<div class="gosmtp-date-container">
					<h3><?php _e('Select date') ?></h3>
					<div class='gosmtp-flex gosmtp-margin-auto'>
						<input type="date" name="from" id="gosmtp-filter-start" min="2023-01-01" value="<?php echo esc_attr($start); ?>" max="<?php echo date('Y-m-d') ?>" /> 
						<input type="date" name="to" id="gosmtp-filter-end" min="2023-01-01" value="<?php echo esc_attr($end); ?>" max="<?php echo date('Y-m-d') ?>" />
					</div>
				</div>
				<div class="gosmtp-filter-container">
					<h3><?php _e('Status') ?></h3>
					<select id="gosmtp-search-filter" name="filter">
						<option value="all" <?php selected( $filter , 'all'); ?> ><?php _e('All') ?></option>
						<option value="success" <?php selected( $filter , 'success'); ?> ><?php _e('Success') ?></option>
						<option value="failed" <?php selected( $filter , 'failed'); ?> ><?php _e('Failed') ?></option>
					</select>
				</div>
				<input type="submit" class="gosmtp-search-trigger" id="gosmtp-search" value="Search" /> 
			</div>
			<table cellspacing="0" cellpadding="8" border="0" width="100%" class="wp-list-table widefat striped gosmtp-log-table" id="gosmtp-logs-table">
				<tr class="gomtp-logs_tr">
					<th width="10"><input type="checkbox" class="gosmtp-multi-check"></th>
					<?php
					
						$logs_th = array(
							'subject' => '<th class="subject_th">'.__('Subject').'</th>',
							'from' => '<th class="from_th">'.__('From').'</th>',
							'to' => '<th class="to_th">'.__('To').'</th>',
							'source' => '<th class="source_th">'.__('Source').'</th>',
							'provider' => '<th class="provider_th">'.__('Provider').'</th>',
							'date_send' => '<th>'.__('Date Send').'</th>',
							'action' => '<th>'.__('Actions').'</th>',
						);	
						
						foreach($logs_th as $key => $col ){
							if(!empty($columns) && array_key_exists($key,$columns)){
								echo $col;
							}
						}
						
					?>
				</tr>
				<?php
				
					$logger = new GOSMTP\Logger();
					$curpage = (int) gosmtp_optget('paged', 1);
					
					$options = array(
						'filter' => !empty($filter) && $filter != 'all' ? ($filter == 'success' ? 'sent' : 'failed') : '',
						'interval' => array(
							'start' => $start,
							'end' => $end
						), 
						'search' => $search,
					);

					// Pagination
					$perpage = 10;
					$records_ct = (int) $logger->get_logs('count', '', $options)->records;
					$tpages = ceil($records_ct / $perpage);
					$offset = ($curpage - 1) * $perpage;

					$options['limit'] = $perpage;
					$options['offset'] = $offset;
							
					$args = array(
						'base' => '%_%',
						'format' => '?paged=%#%',
						'total' => $tpages,
						'current' => $curpage,
						'show_all' => false,
						'end_size' => 1,
						'mid_size' => 2,
						'prev_next' => true,
						'type' => 'array',
						'add_args' => false
					);

					$pagination = null;
					$pages = paginate_links( $args );
					
					if( is_array( $pages ) ){
						$paged = ( get_query_var('paged') == 0 ) ? 1 : get_query_var('paged');
						$pagination .= '<div class="gosmtp-pagination"><ul class="gosmtp-pagination-wrap">';
						
						foreach ( $pages as $page ) {
							$pagination .=  '<li class="gosmtp-pagination-links">'.$page.'</li>';
						}
						
						$pagination .=  '</ul></div>';
					}

					$mails = $logger->get_logs('records', 0, $options);
					
					if(!empty($mails)){
						foreach($mails as $key => $mail){
							
							$id = $mail->id;
							$tos = maybe_unserialize($mail->to);
							$to_list = [];
							
							if(is_array($tos)){
								foreach($tos as $key => $to){
									$to_list[] = $to[0];
								}
								
								$to_list = implode(',',$to_list);
							}else{
								$to_list = $tos;
							}

							$created_at =  date("M d, Y", strtotime($mail->created_at)).' at '. date('h:i A', strtotime($mail->created_at));
							$status = $mail->status == 'sent' ? __('Sent') : __('Failed');
							$resend_retry = $mail->status == 'sent' ? __('Resend') : __('Retry');
							$backup_text = !empty($mail->parent_id) ? __('(Backup)') : '';

							$logs_td = array(
								'subject' => '<td class="gosmtp-flex">
									<span class="dashicons '.( $status == 'Sent' ? 'dashicons-yes-alt' : 'dashicons-warning').' gosmtp-mail-status '.esc_attr(strtolower($status)).'"></span>
									<span>'. (!empty($mail->subject) ? esc_attr($mail->subject) : __('[No Subject]')) .'</span>
								</td>',
								'from' => '<td>'.(!empty($mail->from) ? esc_html($mail->from) : __('NA')).'</td>',
								'to' =>  '<td>'.esc_html($to_list).'</td>',
								'source' => '<td>'.(!empty($mail->source) ? esc_html($mail->source) : __('NA')).'</td>',
								'provider' => '<td>'.(!empty($mail->provider) ? ucwords(esc_html($mail->provider)).' '.$backup_text : __('NA')).'</td>',
								'date_send' => '<td>'.esc_html($created_at).'</td>',
								'action' => '<td class="gosmtp-mail-actions">
									<button type="button" data-id="'. esc_attr($id).'" class="gosmtp-'. esc_attr(strtolower($resend_retry)).'">
										<i class="dashicons '.($resend_retry == 'Retry' ? 'dashicons-update-alt' : 'dashicons-image-rotate' ).'"></i>
										<span>'.esc_html($resend_retry).'</span>
									</button>
									<button type="button" data-id="'. esc_attr($id).'" class="gosmtp-forward">
										<i class="dashicons dashicons-share-alt2"></i>
									</button>
									<button class="gosmtp-mail-delete" type="button" data-id="'.esc_attr($id).'">
										<i class="dashicons dashicons-trash"></i>
									</button>
								</td>'
							);
							?>
							<tr data-id="<?php echo esc_attr($id); ?>" class="gosmtp-mail-details">
								<td>
									<input type="checkbox" value="<?php echo esc_attr($id); ?>" class="gosmtp-checkbox" />
								</td>
								<?php
								
								foreach($logs_td as $key => $col ){
									if(!empty($columns) && array_key_exists($key,$columns)){
										echo $col;
									}
								}

								?>
								
							</tr>
						<?php
						}
					}else{
						?>
						<tr>
							<td  colspan="8" class="gosmtp-empty-row"><?php _e('Logs not found!'); ?></td>
						</tr>
						<?php
					}
				
				?>
			</table>
			<div class="gosmtp-table-footer">
				<div class="gosmtp-log-options-wrap">
					<div class="gosmtp-log-options">
						<select id="gosmtp-table-options">
							<option value="delete"><?php _e('Delete'); ?></option>
						</select>&nbsp;&nbsp;
						<button id="gosmtp-table-opt-btn" type="button" class="button button-primary"><?php _e('Go'); ?></button>
					</div>
				</div>
				<?php echo $pagination; ?>
			</div>
		</div>	
	</form>
</div>
<div class="gosmtp-dialog" id="gosmtp-logs-dialog">
	<div class="gosmtp-dialog-wrap">
		<div class="gosmtp-dialog-container">
			<div class="gosmtp-dialog-header">
				<div class="gosmtp-dialog-header-content">
				<div class="gosmtp-dialog-title"><div class="gosmtp-status-icon"></div><span><?php _e('GOSMTP LOGS') ?></span></div>
				<div class="gosmtp-dialog-actions"></div>
				<div class="gosmtp-forward-dialog"></div>
				<button type="button" class="gosmtp-dialog-close"><span class="dashicons dashicons-no-alt"></span></button>
				</div>
			</div>
			
			<div class="gosmtp-dialog-content">
				<div class="gosmtp-log-details">
					<div class="gosmtp-row">
						<div class="gosmtp-col  gosmtp-col-6">
							<label><?php _e('Mailer / Source') ?>:</label><span class="gosmtp-message-mailer"></span>
						</div>
						<div class="gosmtp-col gosmtp-col-6">
							<label><?php _e('Created') ?>:</label>
							<span class="gosmtp-message-created"></span>
						</div>
					</div>

					<div class="gosmtp-row">
						<div class="gosmtp-col gosmtp-col-6">
							<label><?php _e('From') ?>:</label>
							<span class="gosmtp-message-from"></span>
						</div>
						<div class="gosmtp-col  gosmtp-col-6">
							<label><?php _e('To') ?>:</label>
							<span class="gosmtp-message-tos"></span>
						</div>
					</div>
					<div class="gosmtp-row">
						<div class="gosmtp-col gosmtp-col-12">
							<label><?php _e('Subject') ?>:</label><span class="gosmtp-message-subject"></span>
						</div>
					</div>
					
					<div class="gosmtp-row">
						<div class="gosmtp-col gosmtp-col-12">
							<label><?php _e('Body') ?>:</label>
						</div>
						<div class="gosmtp-col gosmtp-col-12 gosmtp-message-body"></div>
					</div>
				</div>
			</div>
			
			<div class="gosmtp-accordion">
				<div class="gosmtp-accordion-item">
					<div class="gosmtp-accordion-header">
						<strong><?php _e('Headers') ?></strong>
						<i class="dashicons dashicons-arrow-down-alt2"></i>
					</div>
					<div class="gosmtp-accordion-content">
						<div class="gosmtp-log-headers"></div>
					</div>    
				</div>
				
				<div class="gosmtp-accordion-item">
					<div class="gosmtp-accordion-header">
						<strong><?php _e('Attachments') ?> <span class="gosmtp-attachment-count"></span></strong>
						<i class="dashicons dashicons-arrow-down-alt2"></i>
					</div>
					<div class="gosmtp-accordion-content">
						<div class="gosmtp-log-attachments"></div>
					</div>    
				</div>
				
				<div class="gosmtp-accordion-item">
					<div class="gosmtp-accordion-header">
						<strong><?php _e('Response') ?></strong>
						<i class="dashicons dashicons-arrow-down-alt2"></i>
					</div>
					<div class="gosmtp-accordion-content">
						<div class="gosmtp-log-response"></div>
					</div>    
				</div>
			</div>
		</div>
	</div>
</div>
<div class="gosmtp-dialog" id="gosmtp-testmail-dialog">
	<div class="gosmtp-dialog-wrap">
		<div class="gosmtp-dialog-container">
			<div class="gosmtp-dialog-header">
				<div class="gosmtp-dialog-header-content">
				<div class="gosmtp-dialog-title"><div class="gosmtp-status-icon"></div><span><?php _e('GOSMTP Test Mail') ?></span></div>
				<button type="button" class="gosmtp-dialog-close"><span class="dashicons dashicons-no-alt"></span></button>
				</div>
			</div>
			
			<div class="gosmtp-dialog-content">
				<!--start -->
				<form class="gosmtp-smtp-mail" id="smtp-test-mail" name="test-mail" method="post" action="">
					<div class="gosmtp-row">
						<div class="gosmtp-col gosmtp-col-12 gosmtp-borderless">
							<label><?php _e('Recipient Email') ?>:</label>
						</div>
						<div class="gosmtp-col gosmtp-col-12 gosmtp-borderless">
							<input type="email" name="reciever_test_email" class="regular-text gosmtp-full-width" placeholder="<?php _e('example@example.com') ?>" required />
						</div>
					</div>
					<div class="gosmtp-row">
						<div class="gosmtp-col gosmtp-col-12 gosmtp-borderless">
							<label><?php _e('Subject') ?>:</label>
						</div>
						<div class="gosmtp-col gosmtp-col-12 gosmtp-borderless">
							<input type="text" name="smtp_test_subject" class="regular-text gosmtp-full-width" placeholder="<?php _e('Enter Subject') ?>" value="Test Mail" required />
						</div>
					</div>
					<div class="gosmtp-row">
						<div class="gosmtp-col gosmtp-col-12 gosmtp-borderless">
							<label><?php _e('Message') ?>:</label>
						</div>
						<div class="gosmtp-col gosmtp-col-12 gosmtp-borderless">
							<textarea name="smtp_test_message" placeholder="Enter Message" class="regular-text gosmtp-full-width" rows="10"required >This is a test mail!</textarea>
						</div>
					</div>
					<div class="gosmtp-row">
						<div class="gosmtp-col gosmtp-col-12 gosmtp-borderless gosmtp-text-right">
							<button type="submit" name="send_mail" id="send_mail" class="button button-primary"><?php  _e("Send Mail") ?></button>
						</div>
					</div>
				</form>
			<!--end -->
			</div>
		</div>
	</div>
</div>
<div class="gosmtp-dialog" id="gosmtp-forward-dialog">
	<div class="gosmtp-dialog-wrap">
		<div class="gosmtp-dialog-container">
			<div class="gosmtp-dialog-header">
				<div class="gosmtp-dialog-header-content">
				<div class="gosmtp-dialog-title"><div class="gosmtp-status-icon"></div><span><?php _e('GOSMTP FORWARD EMAIL') ?></span></div>
				<button type="button" class="gosmtp-dialog-close"><span class="dashicons dashicons-no-alt"></span></button>
				</div>
			</div>
			
			<div class="gosmtp-dialog-content">
				<div class="gosmtp-log-details">
					<div class="gosmtp-row">
						<div class="gosmtp-col  gosmtp-col-12">
							<form class = "gosmtp-forward-form" id= "gosmtp-forward-form">
								<h2><?php _e('Enter Recipient Email') ?>:</h2>
								<b><?php _e('Note: Use coma(,) for separate two emails') ?></b>
								<div class='gosmtp-forward-email'>
									<span class="dashicons dashicons-email"></span>
									<input type='email' required class="gosmtp-recipient-email" placeholder = "example@example.com" multiple>
								</div>
								<input type='submit' name='forward-mail' value = "Send" class="button forward-mail">
								<input type='button' name='cancel' value = "Cancel" class="button cancel-button">
							</form>

						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<div class="gosmtp-loader">
	<div class="gosmtp-loader-circle"></div>
</div>
<script>
    var gosmtp_ajaxurl = "<?php echo admin_url( 'admin-ajax.php' ) ?>?";
    var gosmtp_ajax_nonce = "<?php echo wp_create_nonce('gosmtp_ajax') ?>";
    
</script>
PK��f\����{{
logger.phpnu�[���<?php
namespace GOSMTP;

/**
* Class Logger.
*
* @since 1.0.0
*/
class Logger{
	
	public $table;

	public function __construct(){
		global $wpdb;
		
		$this->table = $wpdb->prefix . GOSMTP_DB_PREFIX .'email_logs';
	}

	public function create_table(){
		global $wpdb;
		
		$charsetCollate = $wpdb->get_charset_collate();

		if($wpdb->get_var("SHOW TABLES LIKE '$this->table'") == $this->table){
			return;
		}

		$sql = "CREATE TABLE $this->table (
		`id` INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
		`site_id` INT UNSIGNED NULL,
		`message_id` VARCHAR(255) NULL,
		`to` VARCHAR(255),
		`from` VARCHAR(255),
		`subject` VARCHAR(255),
		`body` LONGTEXT NULL,
		`headers` LONGTEXT NULL,
		`attachments` LONGTEXT NULL,
		`status` VARCHAR(20) DEFAULT 'pending',
		`response` TEXT NULL,
		`extra` TEXT NULL,
		`retries` INT UNSIGNED NULL DEFAULT 0,
		`resent_count` INT UNSIGNED NULL DEFAULT 0,
		`provider`  TEXT NULL,
		`source` VARCHAR(255) NULL,
		`created_at` TIMESTAMP NULL,
		`updated_at` TIMESTAMP NULL,
		`parent_id` INT UNSIGNED NULL DEFAULT 0
		) $charsetCollate;";
		
		// Make Sitepad compatible 
		$upgrade = ABSPATH . 'site-admin/includes/upgrade.php';
		$upgrade = file_exists($upgrade) ? $upgrade : ABSPATH . 'wp-admin/includes/upgrade.php';
		require_once( $upgrade );

		dbDelta($sql);
	}

	public function add_logs($data){
		global $wpdb;

		if(empty($data)){
			return false;
		}

		$result = $wpdb->insert($this->table, $data);
		
		if($result){
			return $wpdb->insert_id;
		}
		
		return false;
	}

	public function update_logs($data, $id){
		global $wpdb;
		
		if(empty($data) || empty($id)){
			return false;
		}
		
		$result = $wpdb->update( $this->table, $data, array( 'id' => $id ) );
		
		if($result){
			return true;
		}
		
		return false;
	}


	public function delete_log($id){
		global $wpdb;

		$data['id'] = $id;
		$result = $wpdb->delete($this->table, $data);
		
		if(!empty($result)){
			return true;
		}
		
		return false;
	}

	public function get_logs($for = 'records', $id = '', $args = array()){
		global $wpdb;
		
		$defaults = array(
			'interval' => array(),
			'limit' => 10,
			'offset' => 0,
			'pagination' => true,
			'multiselect' => array(),
		);
		
		$args = wp_parse_args( $args, $defaults );

		$query = '';
		$start = '';
		$end = date('y-m-d').' 23:59:59';
		
		if(!empty($args['filter'])){
			$query .= 'status="'.$args['filter'].'"';
		}
		
		if(!empty($args['interval']) && !empty($args['interval']['start'])){
			
			$start = $args['interval']['start'].' 00:00:00';
			
			if(!empty($args['interval']['end'])){
				$end = $args['interval']['end'].' 23:59:59';
			}
			
			$query .= (!empty($query) ? ' and (' : '').'`created_at` between "'.$start.'" and "'.$end.'" '.(!empty($query) ? ') ' : ' ');
		}

		if(!empty($args['search']) && empty($args['multiselect'])){
			$query .=  (!empty($query) ? ' and ' : '').' (
				`from` like "%'. $args['search'] .'%" or 
				`subject` like "%'. $args['search'] .'%" or 
				`to` like "%'. $args['search'] .'%" or 
				`body` like "%'. $args['search'] .'%" )';
		}else if(!empty($args['search'])){
			$search_qry ='';
			
			foreach($args['multiselect'] as $key => $value){
				$search_qry .= '`'.$value.'` like "%'.$args['search'].'%"';
				
				if(count($args['multiselect']) - 1 > $key){
					$search_qry .= ' or ';
				}	
			}
			
			$query .= (!empty($query) ? ' and ' : '').' ('.$search_qry.')';
		}

		if(!empty($query)){
			$query = ' where '.$query;
		}

		if(!empty($id)){
			$query = ' where id='.$id;
		}else if(!empty($args['pagination'])){
			$query .= $for != 'count' ? ' order by id desc LIMIT '.$args['limit'].' OFFSET '.$args['offset'] : ' ';
		}
		
		// echo "SELECT * FROM ".$this->table. $query;

		try{
			if($for == 'count'){
				$result = $wpdb->get_results("SELECT count(*) as records FROM ".$this->table. $query)[0];
			}else{
				$result = $wpdb->get_results("SELECT * FROM ".$this->table. $query);
				if( count($result) == 0 ){
					return false;
				}
			}
			
			return $result;
		}catch(\Exception $e){}
		
		return false;
	}

	public function clear_records( $period = 0 ){
		
		if( empty($period) || $period == 0 ) return;
		
		global $wpdb;
		
		$date = ( new \DateTime( '-'.$period.' seconds' ))->format('Y-m-d H:i:s');
		$query = 'DELETE FROM `'.$this->table.'` WHERE created_at < %s';
		if( $period == -1 ){
			$query = 'TRUNCATE TABLE '.$this->table;
			$date = '';
		}
		
		$wpdb->query(
			$wpdb->prepare( $query , $date)
		);
	}
	
	public static function retention_logs(){
		global $gosmtp;
		
		if(empty($gosmtp->options['logs']['retention_period'])){
			return;
		}

		$logger = new Logger();
		
		// Clear logs
		$logger->clear_records($gosmtp->options['logs']['retention_period']);
	}
}PK�f\����(b(bwebsite.phpnu�[���<?php

//////////////////////////////////////////////////////////////
//===========================================================
// license.php
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date:	   23rd Jan 2017
// Time:	   23:00 hrs
// Site:	   http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////

// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
	exit('Hacking Attempt !');
}

include_once(PAGELAYER_DIR.'/main/settings.php');

function pagelayer_clear_empty_r(&$r){
	
	foreach($r as $a => $b){
		if(empty($b)){
			unset($r[$a]);
			continue;
		}
		
		if(is_array($b)){
			pagelayer_clear_empty_r($r[$a]);
		}
	}
	
	return $r;
	
}

// The License Page
function pagelayer_website_settings(){
	
	global $pagelayer, $pl_error;
	
	pagelayer_load_font_options();
	
	if(!empty($_POST)){
		check_admin_referer('pagelayer-options');
	}
	
	if(isset($_POST['submit'])){
		
		foreach($pagelayer->css_settings as $set => $params){
			
			foreach($pagelayer->screens as $sk => $sv){
				
				$suffix = (!empty($sv) ? '_'.$sv : '');
				$key = $set.$suffix;
				$setting = empty($params['key']) ? 'pagelayer_'.$set.'_css' : $params['key'];
					
				if(isset($_POST[$key])){
					
					foreach($_POST[$key] as $k => $v){
						if($v == 'Default' || empty($v)){
							unset($_POST[$key][$k]);
						}
					
						// For sidebar, width default should not be saved
						if($set == 'sidebar' && $k == 'width' && $v == 20){
							unset($_POST[$key][$k]);
						}
					}
					
					// Padding and Margins or any array based setting
					if(!empty($_POST[$key]) && is_array($_POST[$key])){
						pagelayer_clear_empty_r($_POST[$key]);
						//pagelayer_print($_POST[$key]);
					}
					
					// Are we to save ?
					if(!empty($_POST[$key])){
						update_option($setting.$suffix, (!empty($_POST[$key]) ? $_POST[$key] : []));
					}else{
						delete_option($setting.$suffix);
					}
					
				}else{
					delete_option($setting.$suffix);
				}
				
			}
			
		}
		
		// Blank the old color values
		delete_option('pagelayer_color');
			
		// Blank the old Body font
		if(!empty($_POST['body']['font-family'])){
			update_option('pagelayer_body_font', '');
		}
		
		//pagelayer_print($_POST);		
	
		// Content Width
		if(isset($_REQUEST['pagelayer_content_width'])){
			update_option( 'pagelayer_content_width', absint($_REQUEST['pagelayer_content_width']));
		}

		// Tablet breakpoint 
		if(isset($_REQUEST['pagelayer_tablet_breakpoint'])){	
			update_option( 'pagelayer_tablet_breakpoint', absint($_REQUEST['pagelayer_tablet_breakpoint']));			
		}

		// Mobile breakpoint 
		if(isset($_REQUEST['pagelayer_mobile_breakpoint'])){
			update_option( 'pagelayer_mobile_breakpoint', absint($_REQUEST['pagelayer_mobile_breakpoint']));
		}
		
		// Widget Space
		if(isset($_REQUEST['pagelayer_between_widgets'])){
			update_option( 'pagelayer_between_widgets', absint($_REQUEST['pagelayer_between_widgets']));
		}
		
		if(defined('PAGELAYER_PREMIUM')){
		
			// Save Header code
			if(isset($_REQUEST['pagelayer_header_code'])){	
				$header_code = wp_unslash($_REQUEST['pagelayer_header_code']);
				if(!pagelayer_user_can_add_js_content()){
					$header_code = sanitize_textarea_field($header_code);
				}
				
				update_option( 'pagelayer_header_code', $header_code);
			}else{
				delete_option('pagelayer_header_code');
			}

			// Save Body open code
			if(isset($_REQUEST['pagelayer_body_open_code'])){	
				$body_code = wp_unslash($_REQUEST['pagelayer_body_open_code']);
				if(!pagelayer_user_can_add_js_content()){
					$body_code = sanitize_textarea_field($body_code);
				}
				
				update_option( 'pagelayer_body_open_code', $body_code);
			}else{
				delete_option('pagelayer_body_open_code');
			}

			// Save Footer code
			if(isset($_REQUEST['pagelayer_footer_code'])){
				$footer_code = wp_unslash($_REQUEST['pagelayer_footer_code']);
				if(!pagelayer_user_can_add_js_content()){
					$footer_code = sanitize_textarea_field($footer_code);
				}
				
				update_option( 'pagelayer_footer_code', $footer_code);
			}else{
				delete_option('pagelayer_footer_code');
			}
		
		}
		
		$GLOBALS['pl_saved'] = true;
		
	}
	
	pagelayer_website_settings_T();
	
}

// The License Page - THEME
function pagelayer_website_settings_T(){
	
	global $pagelayer, $pl_error;

	pagelayer_page_header('Pagelayer Website Settings');

	// Saved ?
	if(!empty($GLOBALS['pl_saved'])){
		echo '<div class="notice notice-success"><p>'. __('The settings were saved successfully', 'pagelayer'). '</p></div><br />';
	}

	// Any errors ?
	if(!empty($pl_error)){
		pagelayer_report_error($pl_error);echo '<br />';
	}
	
	// Reduce load
	echo '<select id="skeleton_of_fonts" style="display:none">';
	foreach($pagelayer->fonts as $subType => $fontType){
		if($subType != 'default'){
			echo '<optgroup style="text-transform: capitalize" label="'.$subType.'">';
		}
		foreach($fontType as $k => $font){
			echo '<option value="'.esc_html(is_numeric($k) ? $font : $k).'">'. esc_html(empty($font) ? 'Default': $font) .'</option>';
		}		
	}
	echo '</select>';
	
	?>
	
<form class="pagelayer-setting-form" method="post" action="">
	<?php wp_nonce_field('pagelayer-options'); ?>
	<script src="https://unpkg.com/vanilla-picker@2.10.1/dist/vanilla-picker.min.js"></script>
	<div class="tabs-wrapper">
		<h2 class="nav-tab-wrapper pagelayer-wrapper">
			<a href="#headings" class="nav-tab "><?php echo __pl('elem_styles');?></a>
			<a href="#website_container" class="nav-tab"><?php echo __pl('container');?></a>
			<!--<a href="#pagelayer-sidebar" class="nav-tab">Sidebar</a>-->
			<a href="#hf" class="nav-tab "><?php echo __pl('hf');?></a>
		</h2>
		
		<div class="pagelayer-tab-panel" id="headings">
			
			<?php
			
			echo '<div style="display:inline-block;vertical-align: top;">
			<ul class="nav-tab-wrapper pagelayer-wrapper pagelayer-heading-wrapper">';
				
			foreach($pagelayer->css_settings as $k => $v){
				echo '<li><a href="#tab_'.$k.'" class="nav-tab pagelayer-heading-tab" tab-class="pagelayer-heading-tab-panel">'.$v['name'].' Style</a></li>';				
			}
			
			echo '</ul>
			</div>
			
			<div style="display:inline-block;vertical-align: top;">';
			
			foreach($pagelayer->css_settings as $k => $v){
				
				echo '<div class="pagelayer-heading-tab-panel" id="tab_'.$k.'">
				<center><h2>'.$v['name'].' Style</h2></center>
				
				<div style="vertical-align: top;">
				<ul class="nav-tab-wrapper pagelayer-wrapper pagelayer-styles-screens">';
				
				foreach($pagelayer->screens as $sk => $sv){
					echo '<li><a href="#tab_'.$k.'_'.$sk.'" class="nav-tab pagelayer-styles-screen-tab" tab-class="pagelayer-styles-screen-panel">'.ucfirst($sk).'</a></li>';					
				}
				
				echo '</ul>
				</div>';
				
				foreach($pagelayer->screens as $sk => $sv){
					echo '<div class="pagelayer-styles-screen-panel" id="tab_'.$k.'_'.$sk.'">';
					pagelayer_website_font_settings($k.(!empty($sv) ? '_'.$sv : ''));
					echo '</div>';
				}
				
				echo '</div>';
			}
			
			echo '</div>';
			
			?>
		
		</div>
	
		<div class="pagelayer-tab-panel" id="website_container">
		
			<table>	
			
				<tr>
					<th><?php echo __('Content Width') ?></th>
					<td>
						<input name="pagelayer_content_width" type="number" step="1" min="320" max="5000" placeholder="1170" <?php if(get_option('pagelayer_content_width')){
							echo 'value="'.absint(get_option('pagelayer_content_width')).'"';
						}?>>
						<p><?php echo __('Set the custom width of the content area. The default width set is 1170px.') ?></p>
					</td>
				<tr>
				<tr>
					<th><?php echo __('Tablet Breakpoint') ?></th>
					<td>
						<input name="pagelayer_tablet_breakpoint" type="number" step="1" min="320" max="5000" placeholder="780" <?php if(get_option('pagelayer_tablet_breakpoint')){
							echo 'value="'.absint(get_option('pagelayer_tablet_breakpoint')).'"';
						}?>>
						<p><?php echo __('Set the breakpoint for tablet devices. The default breakpoint for tablet layout is 768px.') ?></p>
					</td>
				</tr>
				<tr>
					<th><?php echo __('Mobile Breakpoint') ?></th>
					<td>
						<input name="pagelayer_mobile_breakpoint" type="number" step="1" min="320" max="5000" placeholder="480" <?php if(get_option('pagelayer_mobile_breakpoint')){
							echo 'value="'.absint(get_option('pagelayer_mobile_breakpoint')).'"';
						}?>>
						<p><?php echo __('Set the breakpoint for mobile devices. The default breakpoint for mobile layout is 480px.') ?></p>
					</td>
				</tr>
				<tr>
					<th><?php echo __('Space Between Widgets') ?></th>
					<td>
						<input name="pagelayer_between_widgets" type="number" step="1" min="0" max="500" placeholder="15" <?php if(get_option('pagelayer_between_widgets')){
							echo 'value="'.absint(get_option('pagelayer_between_widgets')).'"';
						}?>>
						<p><?php echo __('Set the Space Between Widgets. The default Space set is 15px.') ?></p>
					</td>
				<tr>
		
			</table>
		
		</div>
	
		<div class="pagelayer-tab-panel" id="pagelayer-sidebar">
		
			<table width="100%">
				<tr>
					<td colspan="2">
						<b><?php echo __('Sidebar Preferences');?> :</b>
						<p><?php echo __('By default, the themes sidebar will be shown. But you can customize the settings here as per your preference. Note : This will work only if your theme uses the get_sidebar() function. Also the main content element and sidebar element should be siblings. If they are not siblings, then only the <b>No Sidebar</b> option will be usable.');?></p>
					</td>
				</tr>
				<tr>
					<th valign="top"><?php echo __('Default');?> : </th>
					<td>
						<?php pagelayer_sidebar_select('default');?>
						<p> <?php echo __('Default layout for the Sidebar throughout the site', 'pagelayer') ?> </p>
					</td>
				</tr>
				<tr>
					<th valign="top"><?php echo __('For Pages');?> : </th>
					<td>
						<?php pagelayer_sidebar_select('page');?>
					</td>
				</tr>
				<tr>
					<th valign="top"><?php echo __('For Posts');?> : </th>
					<td>
						<?php pagelayer_sidebar_select('post');?>
					</td>
				</tr>
				<tr>
					<th valign="top"><?php echo __('For Archives');?> : </th>
					<td>
						<?php pagelayer_sidebar_select('archives');?>
					</td>
				</tr>
				<tr>
					<th valign="top"><?php echo __('Width');?> : </th>
					<td>
						<input type="number" name="sidebar[width]" min="1" step="1" value="<?php echo (!empty($_POST) ? esc_html($_POST['sidebar']['width']) : (!empty($pagelayer->css['sidebar']['width']) ? esc_html($pagelayer->css['sidebar']['width']) : '20') );?>" /><span>%</span>
					</td>
				</tr>
			</table>
			
		</div>
		
		<div class="pagelayer-tab-panel" id="hf">
			<?php pagelayer_show_pro_notice();?>
			<table width="100%">
				<tr>
					<td colspan="2">
						<b><?php echo __('Header, Body and Footer code');?> :</b>
						<p><?php echo __('You can add custom code like HTML, JavaScript, CSS etc. which will be inserted throughout your site.');?></p>
					</td>
				</tr>
				<tr>
					<th valign="top"><?php echo __('Header Code');?> : </th>
					<td>
						<textarea name="pagelayer_header_code" style="width:80%;" rows="6"><?php echo get_option( 'pagelayer_header_code' ); ?></textarea>
						<p> <?php echo __('This code will be printed in <code>&lt;head&gt;</code> Section.') ?> </p>
					</td>
				</tr>
				<tr>
					<th valign="top"><?php echo __('Body Open Code');?> : </th>
					<td>
						<textarea name="pagelayer_body_open_code" style="width:80%;" rows="10"><?php echo  get_option( 'pagelayer_body_open_code' ); ?></textarea>
						<p> <?php echo __('This code will be printed from begning of the <code>&lt;body&gt;</code> Section.') ?> </p>
					</td>
				</tr>
				<tr>
				<tr>
					<th valign="top"><?php echo __('Footer Code');?> : </th>
					<td>
						<textarea name="pagelayer_footer_code" style="width:80%;" rows="6"><?php echo  get_option( 'pagelayer_footer_code' ); ?></textarea>
						<p> <?php echo __('This code will be printed before closing the <code>&lt;/body&gt;</code> Section.') ?> </p>
					</td>
				</tr>
			</table>
		</div>
		
	</div>
			
	<?php echo __pl('color_notice');?>
	<br><br>
	<center><input type="submit" name="submit" class="button button-primary button-submit" value="Save Changes" onclick="pagelayer_handle_website_submit(this)"></center>
	<br /><br />
</form>

<script>

function pagelayer_handle_website_submit(ele){
	
	var jEle = jQuery(ele);
	jEle.closest('form').find('input, select, textarea').each(function(){
		var j = jQuery(this);
		if(jEle.is(j)){
			return;
		}
		
		if(j.val().length == 0){
			j.prop("disabled", true);
		}
	});
	
	return true;
}
	
// Show the vanilla selector
function pagelayer_show_vanilla(){
	jQuery('.pagelayer-show-vanilla').each(function(){
		var jEle = jQuery(this);
		var par = jEle.parent();
		var input = par.find('input');
		var sColor = '';
		
		if(input.val().length > 0){
			sColor = input.val();
			jEle.find('.pagelayer-color-div').css('background', sColor);
			jEle.find('.pagelayer-color-div').removeClass('pagelayer-color-none');
		}
		
		var picker = new Picker({
			parent : jEle[0],
			color : sColor,
		});
		
		// You can do what you want with the chosen color using two callbacks: onChange and onDone.
		picker.onChange = function(color) {
			jEle.find('.pagelayer-color-div').css('background', color.rgbaString);
			jEle.find('.pagelayer-color-div').removeClass('pagelayer-color-none');
			input.val(color.hex);
		};
		
		jEle.find('.dashicons').on('click', function(event){
			event.preventDefault();
			event.stopPropagation();
			jEle.find('.pagelayer-color-div').addClass('pagelayer-color-none');
			input.val('');
		});
	});
}

function pagelayer_handle_custom(ele){
	jEle = jQuery(ele);
	if(jEle.val().length > 1){
		jEle.siblings().show();
	}else{
		jEle.siblings().hide();
		jEle.siblings('input').val('');
		jEle.siblings().children().val('');
	}
}

// Handle the font family
function pagelayer_handle_font_family(ele){
	jEle = jQuery(ele);
	if(jEle.children().length <= 1){
		var val = jEle.val();
		jEle.html(jQuery('#skeleton_of_fonts').html());
		jEle.val(val);
	}
}

function pagelayer_handle_textdecor(ele){
	jEle = jQuery(ele);
	if(jEle.val().length > 1 && jEle.val() !== 'none'){
		jEle.siblings().show();
	}else{
		jEle.siblings().hide();
		jEle.siblings().val('');
	}
}

jQuery(document).ready(function(){
	pagelayer_show_vanilla();
	jQuery('.pagelayer-show-custom').each(function(){
		pagelayer_handle_custom(jQuery(this));
	});
	
});
</script>

<?php
	
	pagelayer_page_footer();

}

function pagelayer_website_padding_field($name, $val){
?>
	<input type="number" name="<?php echo $name;?>[0]" step="1" class="pagelayer-website-padding" <?php echo (!empty($val[0]) ? 'value="'.esc_html($val[0]).'"' : '');?> />
	<input type="number" name="<?php echo $name;?>[1]" step="1" class="pagelayer-website-padding" <?php echo (!empty($val[1]) ? 'value="'.esc_html($val[1]).'"' : '');?> />
	<input type="number" name="<?php echo $name;?>[2]" step="1" class="pagelayer-website-padding" <?php echo (!empty($val[2]) ? 'value="'.esc_html($val[2]).'"' : '');?> />
	<input type="number" name="<?php echo $name;?>[3]" step="1" class="pagelayer-website-padding" <?php echo (!empty($val[3]) ? 'value="'.esc_html($val[3]).'"' : '');?> /><span>px</span>
<?php	
}

// Shows the font settings
function pagelayer_website_font_settings($prefix){
	
	global $pagelayer, $pl_error;
	
	// load css from settings
	pagelayer_load_global_css();
	
	if(!empty($_POST)){
		$vals = $_POST;
	}else{
		$vals = $pagelayer->css;
	}
	
	?>
	
	<table>
		
		<tr>
			<th scope="row"><?php echo __pl('padding');?></th>
			<td>
				<label>
					<select class="pagelayer-show-custom" onchange="pagelayer_handle_custom(this)">
						<option value="" <?php echo (empty($vals[$prefix]['padding']) ? 'selected="seleted"' : '');?>>Default</option>
						<option value="custom" <?php echo (!empty($vals[$prefix]['padding']) ? 'selected="seleted"' : '');?>>Custom</option>
					</select>
					<span>
					<?php pagelayer_website_padding_field($prefix.'[padding]', @$vals[$prefix]['padding']);?>
					</span>
				</label>
			</td>
		</tr>
		
		<tr>
			<th scope="row"><?php echo __pl('margin');?></th>
			<td>
				<label>
					<select class="pagelayer-show-custom" onchange="pagelayer_handle_custom(this)">
						<option value="" <?php echo (empty($vals[$prefix]['margin']) ? 'selected="seleted"' : '');?>>Default</option>
						<option value="custom" <?php echo (!empty($vals[$prefix]['margin']) ? 'selected="seleted"' : '');?>>Custom</option>
					</select>
					<span>
					<?php pagelayer_website_padding_field($prefix.'[margin]', @$vals[$prefix]['margin']);?>
					</span>
				</label>
			</td>
		</tr>
		
		<tr>
			<th scope="row"><?php echo __pl('font_family'); ?></th>
			<td>
				<label>
					<select name="<?php echo $prefix;?>[font-family]" onclick="pagelayer_handle_font_family(this)">
					<?php
						echo '<option value="'.esc_html(empty($vals[$prefix]['font-family']) ? 'Default': @$vals[$prefix]['font-family']).'">'.esc_html(empty($vals[$prefix]['font-family']) ? 'Default': @$vals[$prefix]['font-family']).'</option>';
					?>
					</select>
				</label>
			</td>
		</tr>
		
		<tr>
			<th scope="row"><?php echo __pl('font_size'); ?></th>
			<td>
				<label>
					<select class="pagelayer-show-custom" onchange="pagelayer_handle_custom(this)">
						<option value="" <?php echo (empty($vals[$prefix]['font-size']) ? 'selected="seleted"' : '');?>>Default</option>
						<option value="custom" <?php echo (!empty($vals[$prefix]['font-size']) ? 'selected="seleted"' : '');?>>Custom</option>
					</select>
					<input type="number" name="<?php echo $prefix;?>[font-size]" <?php echo (!empty($vals[$prefix]['font-size']) ? 'value="'.esc_html($vals[$prefix]['font-size']).'"' : '');?> /><span>px</span>
				</label>
			</td>
		</tr>
		
		<tr>
			<th scope="row"><?php echo __pl('font_style'); ?></th>
			<td>
				<label>
					<select name="<?php echo $prefix;?>[font-style]">
					<?php
						foreach($pagelayer->font_style as $k => $var){							
							echo '<option value="'.esc_html($k).'" '.(@$vals[$prefix]['font-style'] == $k ? 'selected' : '').'>'.esc_html($var).'</option>';
						}
					?>
					</select>
				</label>
			</td>
		</tr>
		
		<tr>
			<th scope="row"><?php echo __pl('font_weight');?></th>
			<td>
				<label>
					<select name="<?php echo $prefix;?>[font-weight]">
					<?php
						foreach($pagelayer->font_weight as $k => $var){							
							echo '<option value="'.esc_html($k).'" '.(@$vals[$prefix]['font-weight'] == $k ? 'selected' : '').'>'.esc_html($var).'</option>';
						}
					?>
					</select>
				</label>
			</td>
		</tr>
		
		<tr>
			<th scope="row"><?php echo __pl('text_transform');?></th>
			<td>
				<label>
					<select name="<?php echo $prefix;?>[text-transform]">
					<?php
						foreach($pagelayer->text_transform as $k => $var){							
							echo '<option value="'.esc_html($k).'" '.(@$vals[$prefix]['text-transform'] == $k ? 'selected' : '').'>'.esc_html($var).'</option>';
						}
					?>
					</select>
				</label>
			</td>
		</tr>
		
		<tr>
			<th scope="row"><?php echo __pl('line_height');?></th>
			<td>
				<label>
					<select class="pagelayer-show-custom" onchange="pagelayer_handle_custom(this)">
						<option value="" <?php echo (empty($vals[$prefix]['line-height']) ? 'selected="seleted"' : '');?>>Default</option>
						<option value="custom" <?php echo (!empty($vals[$prefix]['line-height']) ? 'selected="seleted"' : '');?>>Custom</option>
					</select>
					<input type="number" name="<?php echo $prefix;?>[line-height]" min="0.1" step="0.1" <?php echo (!empty($vals[$prefix]['line-height']) ? 'value="'.esc_html($vals[$prefix]['line-height']).'"' : '');?> />
				</label>
			</td>
		</tr>
		
		<tr>
			<th scope="row"><?php echo __pl('text_spacing');?></th>
			<td>
				<label>
					<select class="pagelayer-show-custom" onchange="pagelayer_handle_custom(this)">
						<option value="" <?php echo (empty($vals[$prefix]['letter-spacing']) ? 'selected="seleted"' : '');?>>Default</option>
						<option value="custom" <?php echo (!empty($vals[$prefix]['letter-spacing']) ? 'selected="seleted"' : '');?>>Custom</option>
					</select>
					<input type="number" name="<?php echo $prefix;?>[letter-spacing]" min="1" step="1" <?php echo (!empty($vals[$prefix]['letter-spacing']) ? 'value="'.esc_html($vals[$prefix]['letter-spacing']).'"' : '');?> /><span>px</span>
				</label>
			</td>
		</tr>
		
		<tr>
			<th scope="row"><?php echo __pl('word_spacing');?></th>
			<td>
				<label>
					<select class="pagelayer-show-custom" onchange="pagelayer_handle_custom(this)">
						<option value="" <?php echo (empty($vals[$prefix]['word-spacing']) ? 'selected="seleted"' : '');?>>Default</option>
						<option value="custom" <?php echo (!empty($vals[$prefix]['word-spacing']) ? 'selected="seleted"' : '');?>>Custom</option>
					</select>
					<input type="number" name="<?php echo $prefix;?>[word-spacing]" min="1" step="1" <?php echo (!empty($vals[$prefix]['word-spacing']) ? 'value="'.esc_html($vals[$prefix]['word-spacing']).'"' : '');?> /><span>px</span>
				</label>
			</td>
		</tr>
		
		<tr>
			<th scope="row"><?php echo __pl('text_decoration');?></th>
			<td>
				<label>
					<table class="pagelayer-internal-table">
						<tr>
						<td>
							<select name="<?php echo $prefix;?>[text-decoration-line]" onchange="pagelayer_handle_textdecor(this)">
							<?php
								foreach($pagelayer->text_decoration_line as $k => $var){							
									echo '<option value="'.esc_html($k).'" '.(@$vals[$prefix]['text-decoration-line'] == $k ? 'selected' : '').'>'.esc_html($var).'</option>';
								}
							?>
							</select>
						</td>
						<td>
							<select name="<?php echo $prefix;?>[text-decoration-style]">
							<?php
								foreach($pagelayer->text_decoration_style as $k => $var){							
									echo '<option value="'.esc_html($k).'" '.(@$vals[$prefix]['text-decoration-style'] == $k ? 'selected' : '').'>'.esc_html($var).'</option>';
								}
							?>
							</select>
						</td>
						</tr>
						<tr>
							<td>Line</td>
							<td>Style</td>
						</tr>
					</table>
				</label>
			</td>
		</tr>
		
		<tr>
			<th scope="row">Background Color</th>
			<td>
				<a href="#" class="pagelayer-show-vanilla"><div class="pagelayer-color-div pagelayer-color-none"></div><span class="dashicons dashicons-no"></span></a><input type="hidden" name="<?php echo $prefix;?>[background-color]" <?php echo (!empty($vals[$prefix]['background-color']) ? 'value="'.esc_html($vals[$prefix]['background-color']).'"' : '');?>>
			</td>
		</tr>
		
		<tr>
			<th scope="row">Text Color</th>
			<td>
				<a href="#" class="pagelayer-show-vanilla"><div class="pagelayer-color-div pagelayer-color-none"></div><span class="dashicons dashicons-no"></span></a><input type="hidden" name="<?php echo $prefix;?>[color]" <?php echo (!empty($vals[$prefix]['color']) ? 'value="'.esc_html($vals[$prefix]['color']).'"' : '');?>>
			</td>
		</tr>
	</table>
	
<?php
	
}

function pagelayer_sidebar_select($name){
	
	global $pagelayer;
	
	$val = isset($pagelayer->settings['sidebar'][$name]) ? $pagelayer->settings['sidebar'][$name] : 'default';
	$val = !empty($_POST) ? @$_POST['sidebar'][$name] : $val;
	
	// We dont save the value "Default" (note case sensitivity), but the theme customizer saves "default"
	// We need to keep all values blank if user is submitting values as Default
	
	echo '
	<select class="pagelayer-show-custom" name="sidebar['.$name.']">
		<option value="Default" '.($val == 'default' ? 'selected="seleted"' : '').'>Default</option>
		<option value="no" '.($val == 'no' ? 'selected="seleted"' : '').'>No Sidebar</option>
		<option value="left" '.($val == 'left' ? 'selected="seleted"' : '').'>Left Sidebar</option>
		<option value="right" '.($val == 'right' ? 'selected="seleted"' : '').'>Right Sidebar</option>
	</select>
	';
}PK�f\�nx����shortcode_functions.phpnu�[���<?php

//////////////////////////////////////////////////////////////
//===========================================================
// class.php
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date:	   23rd Jan 2017
// Time:	   23:00 hrs
// Site:	   http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////

// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
	exit('Hacking Attempt !');
}

// Is there a block ?
function pagelayer_render_blocks($pre_render, $parsed_block){
	
	global $pagelayer;
	
	if(empty($parsed_block)){
		return $pre_render;
	}
	
	$block_name = $parsed_block['blockName'];
	$tag = '';
	$content = $parsed_block['innerHTML'];
	$inner_blocks = array(
		'blocks' => $parsed_block['innerBlocks'],
		'content' => $parsed_block['innerContent']
	);
	$atts = $parsed_block['attrs'];
	$atts['is_not_sc'] = 1;
	
	if ( is_string( $block_name ) && 0 === strpos( $block_name, 'pagelayer/' ) ) {
		$tag = substr( $block_name, 10 );
	}
	
	$allowed_tags = ['pl_inner_row', 'pl_inner_col'];
	
	if( (empty($tag) || !array_key_exists($tag, $pagelayer->shortcodes) ) && ! in_array( $tag, $allowed_tags) ){
		return $pre_render;
	}
	
	return pagelayer_render_shortcode($atts, $content, $tag, $inner_blocks);
}

// Is there a tag ?
function pagelayer_render_shortcode($atts, $content = '', $tag = '', $inner_blocks = array()){

	global $pagelayer;
	
	$is_block = 0;
	$el = [];
	
	// Is block ?
	if(!empty($atts['is_not_sc'])){
		$is_block = 1;
		unset($atts['is_not_sc']);
	}
	
	$_tag = $class = $tag;
	$final_tag = $tag;
	
	// Check if the tag is inner row and col then change it to row and col tag
	if($tag == 'pl_inner_row'){
		$tag = 'pl_row';
	}elseif($tag == 'pl_inner_col'){
		$tag = 'pl_col';
		$final_tag = $tag;
	}
	
	// Clear the pagelayer tags
	if(substr($tag, 0, 3) == 'pl_'){
		$_tag = str_replace('pl_', '', $final_tag);
		$class = 'pagelayer-'.$_tag;
	}
	
	if(empty($atts)){
		$atts = array();
	}else{
		$atts = (array) $atts;
	}
	
	// If global - > Get the post and replace $atts
	if(!empty($atts['global_id'])){
		
		if(!empty($pagelayer->global_widgets[$atts['global_id']])){
			$content = $pagelayer->global_widgets[$atts['global_id']]['$'];
			return pagelayer_change_id($content);
		}
		
		if(!empty($pagelayer->global_sections[$atts['global_id']])){
			$content = $pagelayer->global_sections[$atts['global_id']]['$'];
			return pagelayer_change_id($content);
		}
		
		// Set the global id as attr
		$el['attr'][] = 'pagelayer-global-id="'.$atts['global_id'].'"';
	}
	
	// Is there any function ?
	$func = pagelayer_isset($pagelayer->shortcodes[$tag], 'func');
	
	// If not, we will search for a default func if prefix of tag is pl_
	if(empty($func) && substr($tag, 0, 3) == 'pl_'){
		$func = 'pagelayer_sc_'.substr($tag, 3);
	}
	
	// UnescapeHTML for the attributes, Fix for old shortcode method
	if(empty($is_block)){
		$atts = array_map('pagelayer_unescapeHTML', $atts);
	}

	// Create the element array. NOTE : This is similar to the JS el and is temporary
	$el['atts'] = $atts;
	$el['oAtts'] = $atts;
	$el['id'] =  !empty($atts['pagelayer-id']) ? $atts['pagelayer-id'] : pagelayer_create_id();
	$el['tmp'] = [];
	$el['tag'] = $final_tag;
	$el['content'] = $content;
	$el['inner_blocks'] = $inner_blocks;
	$el['selector'] = '[pagelayer-id="'.$el['id'].'"]';
	$el['cssSel'] = '.p-'.$el['id'];
	$el['wrap'] = '[pagelayer-wrap-id="'.$el['id'].'"]';
	
	// Remove pagelayer-id from attr
	if( !empty($atts['pagelayer-id']) ){
		unset($el['atts']['pagelayer-id']);
		unset($el['oAtts']['pagelayer-id']);
	}
	
	$innerHTML = pagelayer_isset($pagelayer->shortcodes[$tag], 'innerHTML');
	if(!empty($innerHTML) && !empty($content)){
		$el['oAtts'][$innerHTML] = $content;
		$el['atts'][$innerHTML] = $content;
	}
	
	// The default class
	$el['classes'][] = 'p-'.$el['id'];
	$el['classes'][] = $class;
	
	// Register hook to filter $el
	$el = apply_filters('pagelayer_do_shortcode_el', $el);
	
	//pagelayer_print($el);
	
	// Lets create the CSS, Classes, Attr. Also clean the dependent atts
	foreach($pagelayer->tabs as $tab){
		
		if(empty($pagelayer->shortcodes[$tag][$tab])){
			continue;
		}
		
		foreach($pagelayer->shortcodes[$tag][$tab] as $section => $Lsection){
			
			$props = empty($pagelayer->shortcodes[$tag][$section]) ? @$pagelayer->styles[$section] : @$pagelayer->shortcodes[$tag][$section];
			
			//echo $tab.' - '.$section.' - <br>';
			
			if(empty($props)){
				continue;
			}
			
			foreach($props as $prop => $param){
			
				//echo $tab.' - '.$section.' - '.$prop.'<br>';
				
				// Handle the edit fields
				if(!empty($param['edit'])){
					$el['edit'][$prop] = $param['edit'];
				}
				
				// No value set
				if(empty($el['atts'][$prop]) && empty($el['atts'][$prop.'_tablet']) && empty($el['atts'][$prop.'_mobile'])){
					continue;
				}
				
				// Clean the not required atts
				if(!empty($param['req'])){
					
					$set = true;
					
					foreach($param['req'] as $rk => $reqval){
						$except = $rk[0] == '!' ? true : false;
						$rk = $except ? substr($rk, 1) : $rk;
						$val = pagelayer_isset($el['atts'], $rk);
						
						//echo $prop.' - '.$rk.' : '.$reqval.' == '.$val.'<br>';
						
						// The value should not be there
						if($except){
							
							if(!is_array($reqval) && $reqval == $val){
								$set = false;
								break;
							}
							
							// Its an array and a value is found, then dont show
							if(is_array($reqval) && in_array($val, $reqval)){
								$set = false;
								break;
							}
							
						// The value must be equal
						}else{
							
							 if(!is_array($reqval) && $reqval != $val){
								$set = false;
								break;
							 }
							
							// Its an array and no value is found, then dont show
							if(is_array($reqval) && !in_array($val, $reqval)){
								$set = false;
								break;
							}
						}
						
					}
					
					// Unset as we dont need
					if(empty($set)){
						unset($el['atts'][$prop]);
						unset($el['atts'][$prop.'_tablet']);
						unset($el['atts'][$prop.'_mobile']);
						unset($el['tmp'][$prop]);
						unset($el['tmp'][$prop.'_tablet']);
						unset($el['tmp'][$prop.'_mobile']);
					}
					
				}
				
				// We could have unset the value above, so we need to check again if the value is there
				if(empty($el['atts'][$prop]) && empty($el['atts'][$prop.'_tablet']) && empty($el['atts'][$prop.'_mobile'])){
					continue;
				}
				
				// Load any attachment values - This should go on top in the newer version @TODO
				if( pagelayer_is_comment_mode() && !empty($param['edit']) && !(isset($param['ai']) && $param['ai'] === false) && !empty($el['atts'][$prop])){
					$el['atts'][$prop] = $el['oAtts'][$prop] = !empty($el['atts']['comment_atts'][$prop]) ? $el['atts']['comment_atts'][$prop] : $el['atts'][$prop];
				}
				
				// Any image are skipped
				if( pagelayer_is_comment_mode() && $param['type'] == 'image' && isset($el['atts']['comment_atts'][$prop])){
					$el['atts'][$prop.'_ai'] = $el['oAtts'][$prop.'_ai'] = $el['atts']['comment_atts'][$prop];
				}
				
				if(in_array($param['type'], ['image', 'video', 'audio', 'media'])){
					
					$attachment = ($param['type'] == 'image') ? pagelayer_image(@$el['atts'][$prop]) : pagelayer_attachment(@$el['atts'][$prop]);
					
					if(!empty($attachment)){
						foreach($attachment as $k => $v){
							$el['tmp'][$prop.'-'.$k] = $v;
						}						
					}
					
				}
				
				// Load any attachment values - This should go on top in the newer version @TODO
				if($param['type'] == 'multi_image'){
					
					$img_ids = pagelayer_maybe_explode(',', $el['atts'][$prop]);					
					$img_urls = [];
					
					// Make the image URL
					foreach($img_ids as $k => $v){
						$image = pagelayer_image($v);
						$img_urls['i'.$v] = @$image['url'];
					}
					
					$el['tmp'][$prop.'-urls'] = json_encode($img_urls);
				}
				
				// Backward compatibility of row
				if($el['tag'] == 'pl_row' && $prop == 'content_pos' && !empty($el['atts'][$prop])){
					if($el['atts'][$prop] == 'baseline'){
						$el['atts'][$prop] = $el['oAtts'][$prop] = 'flex-start';
					}else if($el['atts'][$prop] == 'end'){
						$el['atts'][$prop] = $el['oAtts'][$prop] = 'flex-end';
					}
				}
				
				// Backward compatibility of Icons
				if($param['type'] == 'icon' && !empty($el['atts'][$prop]) && !preg_match('/\s/', $el['atts'][$prop])){
					$el['atts'][$prop] = $el['oAtts'][$prop] = 'fa fa-'.$el['atts'][$prop];
				}
				
				// Backward compatibility of Box Shadow
				if($param['type'] == 'box_shadow' && !empty($el['atts'][$prop])){
					$shadow_atts = pagelayer_maybe_explode(',', $el['atts'][$prop]);
					if(count($shadow_atts) == 4){
						$shadow_atts[] = '0';
						$shadow_atts[] = '';
						$el['atts'][$prop] = $el['oAtts'][$prop] = $shadow_atts;
					}
				}
				
				// Backward compatibility of units. And also for the default set value if it is numeric
				if(!empty($param['units']) && isset($el['atts'][$prop]) && is_numeric($el['atts'][$prop])){
					$el['atts'][$prop] = $el['oAtts'][$prop] = $el['atts'][$prop].$param['units'][0];
				}
				
				// Load permalink values
				if($param['type'] == 'link'){
					
					$link = $el['atts'][$prop];
					
					if( is_array($el['atts'][$prop]) ){
						
						// Link is required for check IF and IF-EXT in html
						if(!isset($el['atts'][$prop]['link']) || strlen(trim($el['atts'][$prop]['link'])) < 1){
							$link = '';
							unset($el['atts'][$prop]);
							continue;
						}
						
						$link = $el['atts'][$prop]['link'];
						
						if(!empty($el['atts'][$prop]['target'])){
							$el['attr'][][$param['selector']] = 'target="_blank"';
						}
						
						if(!empty($el['atts'][$prop]['rel'])){
							$el['attr'][][$param['selector']] = 'rel="nofollow"';
						}
						
						if(!empty($el['atts'][$prop]['attrs'])){

							$atts_ar = pagelayer_string_to_attributes($el['atts'][$prop]['attrs']);

							if(!empty($atts_ar)){
								foreach($atts_ar as $att => $value){
									$el['attr'][][$param['selector']] = $att.'="'.$value.'"';							
								}
							}
						}
					}
					
					$el['tmp'][$prop] = esc_url(pagelayer_permalink($link));
				}
				
				// Handle the AddClasses
				if(!empty($param['addClass']) && !empty($el['atts'][$prop])){
					
					// Convert to an array
					if(!is_array($param['addClass'])){
						$param['addClass'] = array($param['addClass']);
					}
					
					// Loop through
					foreach($param['addClass'] as $k => $v){
						$k = str_replace('{{element}}', '', $k);
						$el['classes'][] = [trim($k) => str_replace('{{val}}', $el['atts'][$prop], $v)];
					}
					
				}
				
				// Handle the AddAttributes
				if(!empty($param['addAttr']) && !empty($el['atts'][$prop])){
					
					// Convert to an array
					if(!is_array($param['addAttr'])){
						$param['addAttr'] = array($param['addAttr']);
					}
					
					// Loop through
					foreach($param['addAttr'] as $k => $v){
						$k = str_replace('{{element}}', '', $k);
						$el['attr'][] = [trim($k) => $v];
					}
					
				}				
				
				$modes = [
					'desktop' => '',
					'tablet' => '_tablet',
					'mobile' => '_mobile'
				];
				
				$global_typo = ($param['type'] == 'typography') ? pagelayer_is_global_typo(@$el['atts'][$prop]) : '';
				
				// Handle the CSS
				if(!empty($param['css'])){
					//echo $prop.'<br>';
					// Convert to an array
					if(!is_array($param['css'])){
						$param['css'] = array($param['css']);
					}
					
					// Loop the modes and check for values
					foreach($modes as $mk => $mv){
						
						$M_prop = $prop.$mv;
						
						$prop_val = pagelayer_isset($el['atts'], $M_prop);
						
						// If is global font
						if( $param['type'] == 'typography' && (!empty($prop_val) || !empty($global_typo)) ){
							$prop_val = pagelayer_parse_typo($prop_val, $global_typo, $mk);
						}
						
						// Any value ?
						if(empty($prop_val)){
							continue;
						}
						
						// Global color handler
						if($param['type'] == 'color'){
							$prop_val = pagelayer_parse_color($prop_val);
						}
						
						// If there is global gradient color
						if($param['type'] == 'gradient'){
							
							$prop_val = pagelayer_maybe_explode(',', $prop_val);
							
							foreach($prop_val as $grad_key => $grad_val){
								
								if($grad_val[0] != '$'){
									continue;
								}
								
								$prop_val[$grad_key] = pagelayer_parse_color($grad_val);
								
							}
							
						}

						// Loop through
						foreach($param['css'] as $k => $v){
							
							// Make the selector
							$selector = (!is_numeric($k) ? $k : $el['cssSel']);
							$selector = pagelayer_parse_el_vars($selector, $el);
							
							if($mk == 'tablet'){
								$selector = '|pl_tablet|'.$selector;
							}
							
							if($mk == 'mobile'){
								$selector = '|pl_mobile|'.$selector;
							}
							
							// Make the CSS
							if(!empty($selector)){
								$el['css'][$selector][] = rtrim( trim( pagelayer_css_render($v, $prop_val, pagelayer_isset($param, 'sep')) ), ';' );
							}else{
								$el['css'][][] = pagelayer_parse_el_vars($el['atts'][$M_prop],$el);
							}
						}
						
					}
					
				}
				
				$font_cache = '';
				// Loop the modes and check for values
				foreach($modes as $mk => $mv){
					
					$M_prop = $prop.$mv;

					if($param['type'] == 'typography' && !empty($el['atts'][$M_prop])){
						
						$prop_val = pagelayer_parse_typo($el['atts'][$M_prop], $global_typo, $mk);
						
						$val = pagelayer_maybe_explode(',', $prop_val);
												
						//For backward comaptibility
						if($mk == 'desktop'){
							$font_cache = $val[0];
						}

						$val[0] = empty($val[0]) ? $font_cache : $val[0];
						
						if(!empty($val[0])){
							pagelayer_load_font_family($val[0], pagelayer_isset($val, 3), pagelayer_isset($val, 2));
														
							//pagelayer_print($pagelayer->runtime_fonts);
						}
					}
					
					if($prop == 'font_family' && !empty($el['atts'][$M_prop])){
						$val = $el['atts'][$M_prop];
						if(!empty($val)){							
							pagelayer_load_font_family($val, pagelayer_isset($el['atts'], 'font_weight'.$mv), pagelayer_isset($el['atts'], 'font_style'.$mv));
						}
					}
				}
			}
			
		}
		
	}
	
	//@pagelayer_print($el['css']);
	
	// Is there a function of the tag ?
	if(function_exists($func)){
		call_user_func_array($func, array(&$el));
	}
	
	// Create the default atts and tmp atts
	if(pagelayer_is_live()){
		pagelayer_create_sc($el, $is_block);
	}
	
	$div = '<div pagelayer-id="'.$el['id'].'">
<style pagelayer-style-id="'.$el['id'].'"></style>';
	
	$is_group = !empty($pagelayer->shortcodes[$tag]['has_group']) ? true : false;
	
	// If there is an HTML AND you are not a GROUP, then make use of it, or append the real content
	if(!empty($pagelayer->shortcodes[$tag]['html'])){
		
		// Create the HTML object
		$node = pagelayerQuery::parseStr($pagelayer->shortcodes[$tag]['html']);
		
		// Remove the if-ext
		foreach($node('[if-ext]') as $v){
			$reqvar = pagelayer_var($v->attr('if-ext'));
			$v->removeAttr('if-ext');
			
			// Is the element there ?
			if(empty($el['atts'][$reqvar])){
				$ext_html = $v->html();
				if(strlen($ext_html) > 0){
					$v->after($ext_html);
				}
				$v->remove();
			}
		}
		
		// Remove the if
		foreach($node('[if]') as $v){
			$reqvar = pagelayer_var($v->attr('if'));
			$v->removeAttr('if');
			
			// Is the element there ?
			if(empty($el['atts'][$reqvar])){
				$v->remove();
			}
		}
		
		//die($node->html());
		
		// Do we have a holder ? Mainly for groups
		if(!empty($pagelayer->shortcodes[$tag]['holder'])){
			$node->query($pagelayer->shortcodes[$tag]['holder'])->html('{{pagelayer_do_shortcode}}');
			$do_shortcode = 1;
		}
		
		$html = pagelayer_parse_vars($node->html(), $el);
		
		// Append to the DIV
		$div .= $html;
		
	// Is it a widget ?
	}elseif(!empty($pagelayer->shortcodes[$tag]['widget'])){
		
		$class = $pagelayer->shortcodes[$tag]['widget'];
		$instance = [];
		
		// Is there any existing data ?
		if(!empty($el['atts']['widget_data'])){		
			$json = trim($el['atts']['widget_data']);
			$json = json_decode($json, true);
			//pagelayer_print($json);die();
			if(!empty($json)){
				$instance = $json;
			}
		}
		
		ob_start();
		the_widget($class, $instance, array('widget_id'=>'arbitrary-instance-'.$el['id'],
			'before_widget' => '',
			'after_widget' => '',
			'before_title' => '',
			'after_title' => ''
		));
		
		$div .= ob_get_contents();
		ob_end_clean();
		
	}else{
		$div .= '{{pagelayer_do_shortcode}}';
		$do_shortcode = 1;
	}
	
	// End the tag
	$div .= '</div>';
	
	// Add classes and attributes
	if(!empty($el['classes']) || !empty($el['attr']) || !empty($el['atts']['ele_attributes'])){
	
		// Create the HTML object
		$node = pagelayerQuery::parseStr($div);
		
		// Add the editable values
		if(!empty($el['edit']) && pagelayer_is_live()){
			
			foreach($el['edit'] as $k => $v){
				$node->query($v)->attr('pagelayer-editable', $k);
			}
			
		}
		
		// Add the post data editable 
		if(pagelayer_is_live() && !empty($pagelayer->shortcodes[$tag]['edit_props']) && is_array($pagelayer->shortcodes[$tag]['edit_props'])){
			
			$edit_props = $pagelayer->shortcodes[$tag]['edit_props'];				

			foreach($edit_props as $k => $v){
				$node->query($k)->attr('pagelayer-props-editable', $v);
			}
			
		}
		
		// Add the classes
		if(!empty($el['classes'])){
			
			//pagelayer_print($el['classes']);
			
			foreach($el['classes'] as $k => $v){
				
				if(!is_array($v)){
					$v = [$v];
				}
				
				foreach($v as $kk => $vv){
					//echo $kk.' - '.$vv."\n";
					if(is_numeric($kk)){
						$node->query($el['selector'])->addClass($vv);
					}else{
						$node->query($kk)->addClass($vv);
					}
					
				}
				
			}
			
			//echo $node->html();
			//die();
			
		}
	
		// Add the attributes		
		if(!empty($el['attr'])){
			
			//pagelayer_print($el['attr']);
			
			foreach($el['attr'] as $k => $v){
				
				if(!is_array($v)){
					$v = [$v];
				}
				
				foreach($v as $kk => $vv){
					
					$att = explode('=', $vv, 2);
					$att[1] = pagelayer_parse_vars($att[1], $el);
					$att[1] = trim($att[1], '"');
					
					if(is_numeric($kk)){
						$node->query($el['selector'])->attr($att[0], $att[1]);
					}else{
						$node->query($kk)->attr($att[0], $att[1]);
					}
					
				}
				
			}
			
		}
	
		// Adding Custom Attributes
		if(!empty($el['atts']['ele_attributes'])){
			
			$val = pagelayer_string_to_attributes($el['atts']['ele_attributes']);
			if(!empty($val)){
				foreach($val as $att => $value ){
					$node->query($el['selector'])->attr($att, $value);
				}
			}
			
		}
				
		// Get font family form inline style
		foreach($node->query('[style]') as $snode){
			$ss = $snode->attr('style');
			
			if(strpos($ss, 'font-family') === false){
				continue;
			}
			
			$ss = explode(';', html_entity_decode($snode->attr('style')));
			foreach($ss as $sss){
				
				if(strpos($sss, 'font-family') === false){
					continue;
				}
				
				$ff = explode(':', $sss);
				$val = trim( trim($ff[1]), '"' );
				$fw = array('100', '100i', '200', '200i', '300', '300i', '400', '400i', '500', '500i', '600', '600i', '700', '700i', '800', '800i', '900', '900i');
				
				foreach($fw as $ww){
					$pagelayer->runtime_fonts[$val][$ww] = $ww;
				}
			}
		}
		
		$div = $node->html();
		//die($div);
	
	}
		
	// Add the CSS if any or remove it
	$style = '';
	if(!empty($el['css'])){
		
		$screen_style = array('tablet' => '', 'mobile' => '');
		$style = '<style pagelayer-style-id="'.$el['id'].'">';
		foreach($el['css'] as $ck => $cv){
			preg_match('/\|pl_(mobile|tablet)\|/is', $ck, $screen_matches);
			$ck = str_replace(['|pl_mobile|', '|pl_tablet|'], '', $ck);
			$media = pagelayer_isset($screen_matches, 1);
			
			$merge_css = implode(';', $cv);
			$combine_css = (!is_numeric($ck) ? $ck.'{'.$merge_css.'}' : $merge_css ).PHP_EOL;
			
			// Mobile or tablet ?
			if(!empty($media)){
				$screen_style[$media] .= $combine_css;
				continue;
			}
			
			$style .= $combine_css;
		}
		
		if(!empty($screen_style['tablet'])){
			$style .= '@media (max-width: '.$pagelayer->settings['tablet_breakpoint'].'px) and (min-width: '.($pagelayer->settings['mobile_breakpoint'] + 1).'px){'.$screen_style['tablet'].'}'.PHP_EOL;
		}
		
		if(!empty($screen_style['mobile'])){		
			$style .= '@media (max-width: '.$pagelayer->settings['mobile_breakpoint'].'px){'.$screen_style['mobile'].'}'.PHP_EOL;
		}
		
		$style .= '</style>';
		$style = pagelayer_parse_vars($style, $el);
	
		if(!empty($pagelayer->shortcodes[$tag]['overide_css_selector'])){
			$overide_css_selector = pagelayer_parse_el_vars($pagelayer->shortcodes[$tag]['overide_css_selector'], $el);
			$style = str_replace($el['cssSel'], $overide_css_selector, $style);
			$style = str_replace($el['wrap'], $overide_css_selector, $style);
		}
		
		$style = pagelayer_unescapeHTML($style);
	}
	
	$div = str_replace('<style pagelayer-style-id="'.$el['id'].'"></style>', $style, $div);
	
	// Is there an inner content which requires a SHORTCODE ?
	if(!empty($do_shortcode)){
		
		$inner_content =  pagelayer_render_inner_content($el);
		
		$div = str_replace('{{pagelayer_do_shortcode}}', $inner_content, $div);
	}
	
	// Sanitize the content
	$div = apply_filters( 'pagelayer_sanitize_do_shortcode', $div );
	
	return $div;
	
}

// Render inner content
function pagelayer_render_inner_content(&$el){
	
	$inner_content = '';
	
	// Is block code?
	if( !empty($el['inner_blocks']) ){
		
		$index = 0;

		foreach ( $el['inner_blocks']['content'] as $chunk ) {
			if ( is_string( $chunk ) ) {
				
				// If any string in Column the conver this is text widget in pagelayer live
				if(!empty(trim($chunk)) && pagelayer_is_live() && $el['tag'] == 'pl_col'){
					$parsed_block['blockName'] = 'pagelayer/pl_text';
					$parsed_block['innerHTML'] = $chunk;
					$parsed_block['attrs'] = [];
					$inner_content .= render_block($parsed_block);
					continue;
				}
				
				$inner_content .= $chunk;
				continue;
			}
			
			$inner_block  = $el['inner_blocks']['blocks'][ $index ];
			$inner_content .= render_block($inner_block);
			++$index;
		}
	}else{
		$inner_content .=  do_shortcode($el['content']);
	}
	
	return $inner_content;
}

// Change pagelayer id in html
function pagelayer_change_id($content){
	global $pagelayer;
	
	preg_match_all('/pagelayer-id="(.*?)"/', $content, $matches);
	$matches = array_unique($matches[1]);
	
	foreach($matches as $val){
		$id = pagelayer_create_id();
		$content = str_replace($val, $id, $content);
	}
	
	return $content;
}

// Creates the shortcode and returns a base64 encoded files
function pagelayer_create_sc(&$el, $is_block = 0){
	
	global $pagelayer;
	
	$a = $tmp = array();
	
	$pagelayer->data_attr[$el['id']] = ['attr' => $el['oAtts'], 'tmp' => $el['tmp']];
	
	/*if(!empty($el['oAtts'])){
		
		foreach($el['oAtts'] as $k => $v){
			$v = str_replace('&', '&amp;', $v);
			if($is_block){
				$v = pagelayer_escapeHTML($v);
			}
			$el['attr'][] = 'pagelayer-a-'.$k.'="'.$v.'"';
		}
		
	}
	
	// Tmp atts
	if(!empty($el['tmp'])){
		
		foreach($el['tmp'] as $k => $v){
			$v = str_replace('&', '&amp;', $v);
			if($is_block){
				$v = pagelayer_escapeHTML($v);
			}
			$el['attr'][] = 'pagelayer-tmp-'.$k.'="'.$v.'"';
		}
		
	}*/
	
	// Add the tag
	$el['attr'][] = 'pagelayer-tag="'.$el['tag'].'"';
	
	// Make it a Pagelayer element for editing
	$el['classes'][] = 'pagelayer-ele';
	
}

// Converts {{val}} to val
function pagelayer_var($var){
	return substr($var, 2, -2);
}

// Is the given global color
function pagelayer_is_global_typo($value){
	global $pagelayer;

	$typo_key = '';
	
	// Backward compatibility
	if(is_string($value) && $value[0] == '$'){
		$typo_key = substr($value, 1);
	}
	
	if(is_array($value) && isset($value['global-font'])){
		$typo_key = $value['global-font'];
	}
		
	// If global color not exist
	if(!empty($typo_key)){
		$typo_key = isset($pagelayer->global_fonts[$typo_key]) ? $typo_key : 'primary';
	}
	
	return $typo_key;
	
}

// Parse typography and handle Backward compatibility
function pagelayer_parse_typo($value, $desk_global = '', $mk = 'desktop'){
	global $pagelayer;
	
	$value = empty($value)? [] : $value;
	
	// Backward compatibility for comma seperated val
	if(!is_array($value) && $value[0] != '$'){
		return $value;
	}
	
	$val = ['','','','','','','','','','',''];
	$global_typo = pagelayer_is_global_typo($value);
	$_desk_global = false;
	
	if( empty($global_typo) ){
		$global_typo = $desk_global;
		$_desk_global = true;
	}
	
	// Apply global typo
	foreach($pagelayer->typo_props as $typo => $typo_key){
		
		// Backspace compatibility for normal array and if is set global in '$' format like $primary
		if(is_array($value) && !empty($value[$typo])){
			$val[$typo] = $value[$typo];
		}
		
		if(!empty($value[$typo_key])){
			$val[$typo] = $value[$typo_key];
		}
		
		if(!empty($val[$typo]) || empty($global_typo)){
			continue;
		}
		
		$global_val = $pagelayer->global_fonts[$global_typo]['value'];
		
		if( empty($global_val[$typo_key]) || (is_array($global_val[$typo_key]) && empty($global_val[$typo_key][$mk])) || (!is_array($global_val[$typo_key]) && !empty($_desk_global) && $mk != 'desktop') ){
			continue;
		}
		
		$val[$typo] = 'var(--pagelayer-font-'.$global_typo.'-'.$typo_key.')';
	}
	
	return $val;	
}

// Parse color for global color
function pagelayer_parse_color($value, $var = true){
	global $pagelayer;
		
	// Global color handler
	if($value[0] != '$' ){
		return $value;
	}
	
	$gkey = substr($value, 1);
	$gkey = isset($pagelayer->global_colors[$gkey]) ? $gkey : 'primary';
	
	if(empty($var)){
		return @$pagelayer->global_colors[$gkey]['value'];
	}
	
	return 'var(--pagelayer-color-'.$gkey.')';
}

// Replace the variables
function pagelayer_parse_el_vars($str, &$el){
	
	global $pagelayer, $post;
	
	// if is 404 then @$post->ID
	if(!empty( $pagelayer->rendering_template_id ) && @$post->ID != $pagelayer->rendering_template_id){
		$is_editable = false;
	}else{
		$is_editable = true;
	}
	
	$str = str_replace('{{element}}', $el['cssSel'], $str);
	$is_live = pagelayer_is_live();
	if(!empty($is_live) && $is_editable){
		$str = str_replace('{{wrap}}', $el['wrap'], $str);
	}else{
		$str = str_replace('{{wrap}}', $el['cssSel'], $str);
	}
	$str = str_replace('{{ele_id}}', $el['id'], $str);
	
	return $str;

}

// Parse the variables
function pagelayer_parse_vars($str, &$el){

	if(empty($str)){
		return $str;
	}
	
	//pagelayer_print($el);
	if(!empty($el['tmp']) && is_array($el['tmp'])){
		foreach($el['tmp'] as $k => $v){
			$str = str_replace('{{{'.$k.'}}}', pagelayer_maybe_implode($el['tmp'][$k]), $str);
		}
	}
	
	if(is_array($el['atts'])){
		foreach($el['atts'] as $k => $v){
			$str = str_replace('{{'.$k.'}}', pagelayer_maybe_implode($el['atts'][$k]), $str);
		}
	}
	
	return $str;
}

// Make the rule
function pagelayer_css_render($rule, $val, $sep = ','){
	
	// Seperator
	$sep = empty($sep) ? ',' : $sep;
	
	if(is_array($val)){
		$val = implode($sep, $val);
	}
	
	// Replace the val
	$rule = pagelayer_css_val_replace('{{val}}', pagelayer_hex8_to_rgba($val), $rule);
	
	// If there is an array
	if(preg_match('/\{val\[\d/is', $rule)){
		$val = explode($sep, $val);
		foreach($val as $k => $v){
			$rule = pagelayer_css_val_replace('{{val['.$k.']}}', pagelayer_hex8_to_rgba($v), $rule);
		}
	}
	
	return $rule;
}

// Make the rule
function pagelayer_css_val_replace($val, $v, $rule){
	
	// If value has css var then we remove units
	if(strripos($v, 'var(') !== false){
		$pattern = '/'.preg_quote($val, '/').'?[^\s|;]+/is';
		$rule = preg_replace($pattern, $v, $rule);
		return $rule;
	}
	
	$rule = str_replace($val, $v, $rule);
	return $rule;
}

// Post Property Handler
function pagelayer_sc_post_props(&$el){
	
	global $post;
	
	if(empty($post)){
		return;
	}
	
	$el['oAtts']['post_title'] = $post->post_title;
	$el['oAtts']['post_name'] = $post->post_name;
	$el['oAtts']['post_excerpt'] = $post->post_excerpt;
	$el['oAtts']['post_status'] = (empty($post->post_password)) ? $post->post_status : 'pass_protected';
	$el['oAtts']['post_password'] = $post->post_password;
	$el['oAtts']['featured_image'] = get_post_thumbnail_id($post);
	$el['oAtts']['comment_status'] = ($post->comment_status == 'open') ? 'true' : '';
	$el['oAtts']['ping_status'] = ($post->ping_status == 'open') ? 'true' : '';
	$el['oAtts']['post_date'] = $post->post_date;
	$el['oAtts']['post_sticky'] = is_sticky($post->ID) ? 'true' : '';
	$el['oAtts']['post_parent'] = $post->post_parent;
	$el['oAtts']['menu_order'] = $post->menu_order;
	$el['oAtts']['post_author'] = $post->post_author;
	$el['oAtts']['post_category'] = '';
	$el['oAtts']['post_tags'] = '';
	
	$tag_name = pagelayer_post_type_tag($post->post_type);
	if(!empty($tag_name)){
		$postTags = wp_get_post_terms( $post->ID, $tag_name );
		$el['oAtts']['post_tags'] = array_column((array)$postTags, 'name');
	}

	$cat_name = pagelayer_post_type_category($post->post_type);	
	if(!empty($cat_name)){
		$category = get_the_terms( $post->ID, $cat_name );  
		$el['oAtts']['post_category'] = array_column((array)$category, 'term_id');
	}	
	
	// Load featured image details
	if(!empty($el['oAtts']['featured_image'])){
		
		$attachment = pagelayer_image($el['oAtts']['featured_image']);

		if(!empty($attachment)){
			foreach($attachment as $k => $v){
				$el['tmp']['featured_image-'.$k] = $v;
			}
		}
	
	}
	
}

// ROW Handler
function pagelayer_sc_row(&$el){
	
	pagelayer_bg_video($el);
	
	if(!empty($el['atts']['row_shape_type_top'])){
		$path_top = PAGELAYER_DIR.'/images/shapes/'.$el['atts']['row_shape_type_top'].'-top.svg';
		$el['atts']['svg_top'] = file_get_contents($path_top);
	}
	
	if(!empty($el['atts']['row_shape_type_bottom'])){
		$path_bottom = PAGELAYER_DIR.'/images/shapes/'.$el['atts']['row_shape_type_bottom'].'-bottom.svg';
		$el['atts']['svg_bottom'] = file_get_contents($path_bottom);
	}
	
	// Row background slider
	if(!empty($el['atts']['bg_slider'])){
		$ids = pagelayer_maybe_explode(',', $el['atts']['bg_slider']);
		$urls = [];
		$el['atts']['slider'] = '';
		
		// Make the image URL
		foreach($ids as $k => $v){
			
			$image = pagelayer_image($v);
			$urls['i'.$v] = @$image['url'];
			
			$el['atts']['slider'] .= '<div class="pagelayer-bgimg-slide" style="background-image:url(\''.$image['url'].'\')"></div>';
			
		}
		
		if(!empty($urls)){
			$el['tmp']['bg_slider-urls'] = json_encode($urls);
		}
		
	}
	
	// Row background parallax image.
	if(!empty($el['atts']['parallax_img'])){
		$img_size = @$el['tmp']['parallax_img-'.$el['atts']['parallax_id_size'].'-url'];
		$el['atts']['parallax_img_src'] = empty($img_size) ? @$el['tmp']['parallax_img-url'] : $img_size;
	}
	
}

// Column Handler
function pagelayer_sc_col(&$el){
	
	// Add the default col class
	$el['classes'][] = 'pagelayer-col';
	
	//return do_shortcode($el['content']);
	
	pagelayer_bg_video($el);
	
	// Column background slider
	if(!empty($el['atts']['bg_slider'])){
		$ids = pagelayer_maybe_explode(',', $el['atts']['bg_slider']);
		$urls = [];
		$el['atts']['slider'] = '';
		
		// Make the image URL
		foreach($ids as $k => $v){
			
			$image = pagelayer_image($v);
			$urls['i'.$v] = @$image['url'];
			
			$el['atts']['slider'] .= '<div class="pagelayer-bgimg-slide" style="background-image:url(\''.$image['url'].'\')"></div>';
			
		}
		
		if(!empty($urls)){
			$el['tmp']['bg_slider-urls'] = json_encode($urls);
		}
		
	}
	
	// Col background parallax image.
	if(!empty($el['atts']['parallax_img'])){
		$img_size = @$el['tmp']['parallax_img-'.$el['atts']['parallax_id_size'].'-url'];
		$el['atts']['parallax_img_src'] = empty($img_size) ? @$el['tmp']['parallax_img-url'] : $img_size;
	}
	
}

// Just for BG handling
function pagelayer_bg_video(&$el){
	
	if(empty($el['tmp']['bg_video_src-url'])){
		return false;
	}
	
	// Get the video URL for the iframe
	$iframe_atts = pagelayer_video_url($el['tmp']['bg_video_src-url'], true);
	
	$source = esc_url( $el['tmp']['bg_video_src-url'] );
	$source = str_replace('&amp;', '&', $source);
	$url = parse_url($source);
	
	$iframe_atts['src'] .= substr_count($iframe_atts['src'], '?') > 0 ? '' : '?';
	
	if(!empty($el['atts']['mute'])){
		$iframe_atts['src'] .= "&mute=1";
		$el['atts']['mute'] = " muted ";
	}else{
		$iframe_atts['src'] .= "&mute=0";
		$el['atts']['mute'] = "";
	}

	if(empty($el['atts']['stop_loop'])){
		$iframe_atts['src'] .= "&loop=1";	
		$el['atts']['stop_loop'] = " loop ";
	}else{
		$iframe_atts['src'] .= "&loop=0";	
		$el['atts']['stop_loop'] = "";
	}
	
	if (!empty($source)) {
		
		if ($iframe_atts['type'] == 'youtube') {
		
			$settings = ' data-loop="'.( !empty($el['atts']['stop_loop']) ? 1 : 0 ).'" data-mute="'.( !empty($el['atts']['mute']) ? 1 : 0 ).'" data-videoid = "'.( $iframe_atts['id'] ).'"';
						
			$el['atts']['vid_src'] = '<div class = "pagelayer-youtube-video" '. $settings .'></div>';
			
		} else if ($iframe_atts['type'] == 'vimeo') {
			
			$el['atts']['vid_src'] = '<iframe src="'.$iframe_atts['src'].'&background=1&autoplay=1&byline=0&title=0" allowfullscreen="1" webkitallowfullscreen="1" mozallowfullscreen="1" frameborder="0"></iframe>';
			
		}else{
			
			$el['atts']['vid_src'] = '<video autoplay playsinline '.$el['atts']['mute'].$el['atts']['stop_loop'].'>'.
				'<source src="'.$iframe_atts['src'].'" type="video/mp4">'.
			'</video>';
			
		}
	}
}

// Heading Handler
function pagelayer_sc_heading(&$el){
	//Backward compatibility for new link props
	pagelayer_add_link_backward($el, array('rel' => '', 'selector' => '.pagelayer-link-sel'));
}

// Heading Handler
function pagelayer_sc_icon(&$el){
	//Backward compatibility for new link props
	pagelayer_add_link_backward($el, array('rel' => '', 'selector' => '.pagelayer-ele-link'));
}

// Heading Handler
function pagelayer_sc_badge(&$el){
	//Backward compatibility for new link props
	pagelayer_add_link_backward($el, array(
		'link' => 'badge_url',
		'rel' => '',
		'target' => 'badge_target',
		'selector' => '.pagelayer-ele-link'
	));
}

// Heading Handler
function pagelayer_sc_btn(&$el){
	//Backward compatibility for new link props
	pagelayer_add_link_backward($el, array('selector' => '.pagelayer-btn-holder'));
}

// Image Handler
function pagelayer_sc_social(&$el){
	
	//Backward compatibility for new link props
	pagelayer_add_link_backward($el, array(
		'link' => 'social_url',
		'rel' => '',
		'selector' => '.pagelayer-ele-link'
	));
	
	if(empty($el['atts']['icon'])) return;
	$icon = explode(' fa-', $el['atts']['icon']);
	$el['classes'][] = ['.pagelayer-icon-holder' => 'pagelayer-'.$icon[1]];
}

// Image Handler
function pagelayer_sc_image(&$el){
	
	// Decide the image URL
	$el['atts']['func_id'] = @$el['tmp']['id-'.$el['atts']['id-size'].'-url'];
	$el['atts']['func_id'] = empty($el['atts']['func_id']) ? @$el['tmp']['id-url'] : $el['atts']['func_id'];
	$el['atts']['pagelayer-srcset'] = $el['atts']['func_id'].', '.$el['atts']['func_id'].' 1x, ';
	
	$image_atts = array(
		'name' => 'id',
		'size' => 'id-size'
	);
	
	pagelayer_get_img_srcset($el, $image_atts);
		
	// What is the link ?
	if(!empty($el['atts']['link_type'])){
		
		// Custom url
		if($el['atts']['link_type'] == 'custom_url'){
			
			// Backward compatibility for new link props
			pagelayer_add_link_backward($el, array( 'rel' => '', 'selector' => '.pagelayer-ele-link'));
			
			$el['atts']['func_link'] = @$el['tmp']['link'];
		}
		
		// Link to the media file itself
		if($el['atts']['link_type'] == 'media_file'){
			$el['atts']['func_link'] = $el['atts']['func_id'];
		}
		
		// Lightbox
		if($el['atts']['link_type'] == 'lightbox'){
			$el['atts']['func_link'] = $el['atts']['func_id'];
		}
		
	}
	
	//pagelayer_print($el);
	
}

// Image Slider Handler
function pagelayer_sc_image_slider(&$el){
	
	// Backward compatibility for new link props
	if( !empty($el['atts']['link_type']) && $el['atts']['link_type'] == 'custom_url' ){
		pagelayer_add_link_backward($el, array( 'rel' => '', 'selector' => '.pagelayer-link-sel'));
	}
	
	if(empty($el['atts']['ids'])){
		$el['atts']['ids'] = '';
	}
	
	$ids = pagelayer_maybe_explode(',', $el['atts']['ids']);
	$urls = [];
	$all_urls = [];
	$final_urls = [];
	$ul = [];
	$size = $el['atts']['size'];
	
	// Make the image URL
	foreach($ids as $k => $v){
		
		$image = pagelayer_image($v);
		
		$final_urls[$v] = empty($image[$size.'-url']) ? @$image['url'] : $image[$size.'-url'];
		
		$urls['i'.$v] = @$image['url'];
		
		foreach($image as $kk => $vv){
			$si = strstr($kk, '-url', true);
			if(!empty($si)){
				$all_urls['i'.$v][$si] = $vv;
			}
		}
		
		$li = '<li class="pagelayer-slider-item">';
		
		// Any Link ?
		if(!empty($el['atts']['link_type'])){
			$link = ($el['atts']['link_type'] == 'media_file' ? (!empty($image['url']) ? $image['url'] : $final_urls[$v]) : @$el['tmp']['link']);
			$li .= '<a href="'.$link.'" class="pagelayer-link-sel">';
		}
		
		// The Image
		$li .= '<img class="pagelayer-img" src="'.$final_urls[$v].'" title="'.$image['title'].'" alt="'.$image['alt'].'">';
		
		if(!empty($el['atts']['link_type'])){
			$li .= '</a>';
		}
		
		$li .= '</li>';
		
		$ul[] = $li;
		
	}
	
	//pagelayer_print($urls);
	//pagelayer_print($final_urls);
	//pagelayer_print($all_urls);
	
	// Make the TMP vars
	if(!empty($urls)){
		$el['tmp']['ids-urls'] = json_encode($urls);
		$el['tmp']['ids-all-urls'] = json_encode($all_urls);
		$el['atts']['ul'] = implode('', $ul);
	
		// Which arrows to show
		if(in_array(@$el['atts']['controls'], ['arrows', 'none'])){
			$el['attr'][] = ['.pagelayer-image-slider-ul' => 'data-pager="false"'];
		}
		
		if(in_array(@$el['atts']['controls'], ['pager', 'none'])){
			$el['attr'][] = ['.pagelayer-image-slider-ul' => 'data-controls="false"'];
		}
	}
	
};

//Grid Gallery Handler
function pagelayer_sc_grid_gallery(&$el){
	
	if(empty($el['atts']['ids'])){
		$el['atts']['ids'] = '';
	}
	
	$ids = pagelayer_maybe_explode(',', $el['atts']['ids']);
	$urls = [];
	$all_urls = [];
	$final_urls = [];
	$ul = [];
	$pagin = '<li class="pagelayer-grid-page-item active">1</li>';
	$size = $el['atts']['size'];
	$i = 0;
	$j = 1;
	$img_Page = $el['atts']['images_no'];
	$gallery_rand = 'gallery-id-'.floor((rand() * 100) + 1);
	
	$ul[] = '<ul class="pagelayer-grid-gallery-ul">';
	// Make the image URL
	foreach($ids as $k => $v){
		
		$image = pagelayer_image($v);
		
		$final_urls[$v] = empty($image[$size.'-url']) ? @$image['url'] : $image[$size.'-url'];
		
		$urls['i'.$v] = @$image['url'];
		$links['i'.$v] = @$image['link'];
		$titles['i'.$v] = @$image['title'];
		$captions['i'.$v] = @$image['caption'];
		
		foreach($image as $kk => $vv){
			$si = strstr($kk, '-url', true);
			if(!empty($si)){
				$all_urls['i'.$v][$si] = $vv;
			}
		}
		
		if($img_Page != 0 && ($i % $img_Page) == 0 && $i != 0 ){
			$ul[] = '</ul><ul class="pagelayer-grid-gallery-ul">';
			$j++;
			$pagin .= '<li class="pagelayer-grid-page-item">'.$j.'</li>';
		}
		
		$li = '<li class="pagelayer-gallery-item" >';
		
		if(empty($el['atts']['link_to'])){
			$li .= '<div>';
		}
		
		// Any Link ?
		if(!empty($el['atts']['link_to']) &&  $el['atts']['link_to'] == 'media_file'){
			$link = ($el['atts']['link_to'] == 'media_file' ? $final_urls[$v] : @$el['atts']['link']);
			$li .= '<a href="'.$link.'" class="pagelayer-ele-link">';
		}
		
		// Any Link ?
		if(!empty($el['atts']['link_to']) &&  $el['atts']['link_to'] == 'attachment' ){
			$link = $image['link'];
			$li .= '<a href="'.$link.'" class="pagelayer-ele-link">';
		}
		
		if(!empty($el['atts']['link_to']) && $el['atts']['link_to'] == 'lightbox'){			
			$li .= '<a href="'.$image['url'].'" data-lightbox-gallery="'.$gallery_rand.'" alt="'.$image['alt'].'" class="pagelayer-ele-link" pagelayer-grid-gallery-type="'.$el['atts']['link_to'].'">';
		}
		// The Image
		$li .= '<img class="pagelayer-img" src="'.$final_urls[$v].'" title="'.$image['title'].'" alt="'.$image['alt'].'">';
		
		if(!empty($el['atts']['caption'])){
			$li .= '<span class="pagelayer-grid-gallery-caption">'.$image['caption'].'</span>';
		}
		
		if(!empty($el['atts']['link_to'])){
			$li .= '</a>';
		}
		
		if(empty($el['atts']['link_to'])){
			$li .= '</div>';
		}
		
		$li .= '</li>';
		
		$ul[] = $li;
		$i++;
	}
	
	$ul[] = '</ul>';
	
	$pagiComplete[] = '<div class="pagelayer-grid-gallery-pagination"><ul class="pagelayer-grid-page-ul">'.'<li class="pagelayer-grid-page-item">&laquo;</li>'.$pagin.'<li class="pagelayer-grid-page-item">&raquo;</li>'.'</ul></div>';
	//pagelayer_print($urls);
	//pagelayer_print($final_urls);
	//pagelayer_print($all_urls);
	
	// Make the TMP vars
	if(!empty($urls)){
		$el['tmp']['ids-urls'] = json_encode($urls);
		$el['tmp']['ids-all-urls'] = json_encode($all_urls);
		$el['tmp']['ids-all-links'] = json_encode($links);
		$el['tmp']['ids-all-titles'] = json_encode($titles);
		$el['tmp']['ids-all-captions'] = json_encode($captions);
		$el['atts']['ul'] = implode('', $ul);
		$el['atts']['pagin'] = ($j>1) ? implode('', $pagiComplete) : '';	
		$el['tmp']['gallery-random-id'] = $gallery_rand;
	
	}
}

// Testimonial Handler
function pagelayer_sc_testimonial(&$el){
	
	if(empty($el['atts']['avatar']) || !empty($el['tmp']['avatar-no-image-set'])){
		$el['atts']['avatar'] = '';
	}
	
	$custom_size = empty($el['atts']['custom_size']) ? '' : @$el['tmp']['avatar-'.$el['atts']['custom_size'].'-url'];
	$el['atts']['func_image'] = empty($custom_size) ? @$el['tmp']['avatar-url'] : $custom_size;
	
}

// Video Handler
function pagelayer_sc_video(&$el){
	
	$el['atts']['custom_size'] = empty($el['atts']['custom_size']) ? '' : $el['atts']['custom_size'];
	$el['tmp']['video_overlay_image-url'] = empty($el['tmp']['video_overlay_image-url']) ? '' : $el['tmp']['video_overlay_image-url'];
	$el['atts']['video_overlay_image'] = empty($el['atts']['video_overlay_image']) ? '' : $el['atts']['video_overlay_image'];
	
	$el['atts']['video_overlay_image-url'] = empty($el['tmp']['video_overlay_image-'.$el['atts']['custom_size'].'-url']) ? $el['tmp']['video_overlay_image-url'] : $el['tmp']['video_overlay_image-'.$el['atts']['custom_size'].'-url'];
	$el['atts']['video_overlay_image-url'] = empty($el['atts']['video_overlay_image-url']) ? $el['atts']['video_overlay_image'] : $el['atts']['video_overlay_image-url'];
	
	// Get the video URL for the iframe
	$vid_atts = pagelayer_video_url($el['tmp']['src-url'], true);
	
	$vid_atts['src'] .= substr_count($vid_atts['src'], '?') > 0 ? '' : '?';
	
	$vid_atts['src'] .= !empty($el['atts']['autoplay']) ? '&autoplay=1' : '&autoplay=0' ;

	$mute = !empty($el['atts']['mute']) ? 1 : 0;
	$vid_atts['src'] .='&'.($vid_atts['type'] == 'vimeo' ? 'muted' : 'mute').'='.$mute;
  
	$vid_atts['src'] .= !empty($el['atts']['loop']) == 'true' ? '&loop=1' : '&loop=0' ;
	
	$el['atts']['vid_src'] = $vid_atts['src'].($vid_atts['type'] == 'youtube' ? '&playlist='.$vid_atts['id'] : '');
	
	$el['tmp']['ele_id'] = $el['id'];
	
}

// Shortcodes Handler
function pagelayer_sc_shortcodes(&$el){
	$is_live = pagelayer_is_live();
	if(empty($is_live)){
		$el['tmp']['shortcode'] = pagelayer_the_content($el['atts']['data']);
	}
}

// Missing Handler
function pagelayer_sc_missing(&$el){
	if(pagelayer_is_live()){
		$el['tmp']['missing_msg'] = __('The pagelayer doesn’t support this content. You can leave this block intact or remove it completely.');
	}
}

// Shortcodes Handler
function pagelayer_sc_wp_widgets(&$el){
	
	global $wp_registered_sidebars;
	
	$data = '';	
	foreach($wp_registered_sidebars as $v){
		if($el['atts']['sidebar'] == $v['id']){
			ob_start();
			dynamic_sidebar($v['id']);
			$data = ob_get_clean();
		}
	}
	
	$el['tmp']['data'] = $data;
}

// Service Handler
function pagelayer_sc_service(&$el){
	
	//Backward compatibility for new link props
	pagelayer_add_link_backward($el, array(
		'link' => 'box_url',
		'rel' => '',
		'target' => 'box_target',
		'selector' => '.pagelayer-box-link'
	));
	
	//Backward compatibility for new link props
	pagelayer_add_link_backward($el, array(
		'link' => 'heading_url',
		'rel' => '',
		'target' => 'heading_target',
		'selector' => '.pagelayer-service-heading-link'
	));
	
	//Backward compatibility for new link props
	pagelayer_add_link_backward($el, array(
		'link' => 'service_button_url',
		'rel' => '',
		'target' => 'service_button_target',
		'selector' => '.pagelayer-service-btn'
	));
	
	if(!empty($el['atts']['service_image'])){
		
		// Decide the image URL
		$el['atts']['func_image'] = @$el['tmp']['service_image-'.$el['atts']['service_image_size'].'-url'];
		$el['atts']['func_image'] = empty($el['atts']['func_image']) ? @$el['tmp']['service_image-url'] : $el['atts']['func_image'];
		$el['atts']['pagelayer-srcset'] = $el['atts']['func_image'].', '.$el['atts']['func_image'].' 1x, ';
		
		$image_atts = array(
			'name' => 'service_image',
			'size' => 'service_image_size'
		);
	
		pagelayer_get_img_srcset($el, $image_atts);
		
	}
}

// Icon box Handler
function pagelayer_sc_iconbox(&$el){
	
	//Backward compatibility for new link props
	pagelayer_add_link_backward($el, array(
		'link' => 'box_url',
		'rel' => '',
		'target' => 'box_target',
		'selector' => '.pagelayer-box-link'
	));
	
	//Backward compatibility for new link props
	pagelayer_add_link_backward($el, array(
		'link' => 'heading_url',
		'rel' => '',
		'target' => 'heading_target',
		'selector' => '.pagelayer-service-heading-link',
	));
	
}

function pagelayer_sc_google_maps(&$el){
	
	$el['atts']['show_v2'] = true;
	
	if(empty($el['atts']['api_version'])){
		$el['atts']['src_code'] = '';
		return;
	}
	
	$el['atts']['show_v2'] = false;
	$api_key = @$el['atts']['api_key'];
	
	$gmaps_api = get_option('pagelayer-gmaps-api-key');
	
	if( empty($api_key) && !empty($gmaps_api) ){
		$api_key = $gmaps_api;
	}
	
	if($el['atts']['map_modes'] == 'view'){
		$el['atts']['center'] = empty($el['atts']['center']) ? '-33.8569,151.2152' : $el['atts']['center'];
	}
	
	$src_code = (empty($el['atts']['center']) ? '' : '&center='.$el['atts']['center']).($el['atts']['map_modes'] == 'streetview' ? '' : '&maptype='.$el['atts']['map_type'].'&zoom='.$el['atts']['zoom']);
	
	switch($el['atts']['map_modes']){
		case 'place':
			$src_code .= '&q='.(empty($el['atts']['address']) ? 'New York, New York, USA' : urlencode($el['atts']['address']) );
			break;
			
		case 'directions':
			$src_code .= '&origin='.(empty($el['atts']['direction_origin']) ? 'Oslow Norway' : urlencode($el['atts']['direction_origin']) );
			$src_code .= '&destination='.(empty($el['atts']['direction_destination']) ? 'Telemark Norway' : urlencode($el['atts']['direction_destination']) );
			$src_code .= (empty($el['atts']['direction_waypoints']) ? '' : '&waypoints='.join('|', explode(' ', trim($el['atts']['direction_waypoints']))) );
			$src_code .= (empty($el['atts']['direction_modes']) ? '' : '&mode='.$el['atts']['direction_modes'] );
			$src_code .= (empty($el['atts']['direction_avoid']) ? '' : '&avoid='.join('|', explode(',', $el['atts']['direction_avoid'])) );
			$src_code .= (empty($el['atts']['direction_units']) ? '' : '&units='.$el['atts']['direction_units'] );
			break;
			
		case 'streetview':
			$src_code .= '&pano='.(empty($el['atts']['streetview_pano']) ? 'eTnPNGoy4bxR9LpjjfFuOw' : $el['atts']['streetview_pano'] );
			$src_code .= '&location='.(empty($el['atts']['streetview_location']) ? '46.414382,10.013988' : $el['atts']['streetview_location'] );
			$src_code .= (empty($el['atts']['streetview_heading']) ? '' : '&heading='.$el['atts']['streetview_heading'] );
			$src_code .= (empty($el['atts']['streetview_pitch']) ? '' : '&pitch='.$el['atts']['streetview_pitch'] );
			$src_code .= (empty($el['atts']['streetview_fov']) ? '' : '&fov='.$el['atts']['streetview_fov'] );
			break;
			
		case 'search':
			$src_code .= '&q='.(empty($el['atts']['search_term']) ? 'Record stores in Seattle' : urlencode($el['atts']['search_term']) );
			break;
			
	}
	
	$src_iframe = 'https://www.google.com/maps/embed/v1/'.$el['atts']['map_modes'].'?key='.$api_key.$src_code;
	
	$el['atts']['src_code'] = '<iframe width="600" height="450" style="border:0" loading="lazy" allowfullscreen src="'.$src_iframe.'"></iframe>';
	
}

/*pagelayer_print($atts);
pagelayer_print($content);
die();*/

/////////////////////////////////////
// Miscellaneous Shortcode Functions
/////////////////////////////////////

// The font family list
function pagelayer_font_family(){
	return array(
		'arial' => 'Arial',				
		'terminal' => 'Terminal'
	);
}

// Supported Icons
function pagelayer_icon_class_list(){
	return array();
}

// Function to convert string into set of attributes and their corresponding values.
function pagelayer_string_to_attributes($val){
	
	$final_att = [];
	$semi_arr = explode(';', $val);
	
	foreach($semi_arr as $att){
		
		$attrs = preg_split("/=/", trim($att), 2);

		if(empty($attrs[0]) || !preg_match("/^[a-z_]+[\w:.-]*$/i", $attrs[0]) ){
			continue;
		}	
		
		if(!isset( $attrs[1])){
			$final_att[$attrs[0]] = '';
			continue;
		}
		
		$final_att[$attrs[0]] = $attrs[1];
	}
	
	return $final_att;
	
}

// Retina image setting attribute.
function pagelayer_get_img_srcset(&$el, $image_atts){

	// Check if retina images is set
	if(isset($el['tmp'][$image_atts['name'].'-retina-url']) && strpos($el['tmp'][$image_atts['name'].'-retina-url'],'default-image') == false){
		$retina_image = @$el['tmp'][$image_atts['name'].'-retina-'.$el['atts'][$image_atts['size']].'-url'];
		$retina_image = empty($retina_image) ? @$el['tmp'][$image_atts['name'].'-retina-url'] : $retina_image;
		$el['atts']['pagelayer-srcset'] .= $retina_image.' 2x, ';			
	}
	
	// Check if retina mobile images is set
	if(isset($el['tmp'][$image_atts['name'].'-retina-mobile-url']) && strpos($el['tmp'][$image_atts['name'].'-retina-mobile-url'],'default-image') == false){			
		$retina_image_mobile = @$el['tmp'][$image_atts['name'].'-retina-mobile-'.$el['atts'][$image_atts['size']].'-url'];
		$retina_image_mobile = empty($retina_image_mobile) ? @$el['tmp'][$image_atts['name'].'-retina-mobile-url'] : $retina_image_mobile;		
		$el['atts']['pagelayer-srcset'] .= $retina_image_mobile.' 3x';
	}
}

// Backward compatibility of target and rel attrs for link
function pagelayer_add_link_backward(&$el, $atts = array()){
	global $pagelayer;
	
	$defaults = array(
		'link' => 'link',
		'target' => 'target',
		'rel' => 'rel',
		'selector' => 0,
	);
	
	$_atts = wp_parse_args( $atts, $defaults );
	
	if(empty($el['atts'][$_atts['link']])){
		return;
	}

	$link = array();
	
	if(!empty($_atts['target']) && !empty($el['atts'][$_atts['target']]) ){
		$link['target'] = true;
		unset($el['oAtts'][$_atts['target']]);
	}
	
	if(!empty($_atts['rel']) && !empty($el['atts'][$_atts['rel']]) ){
		$link['attrs'] = 'rel='.$el['atts'][$_atts['rel']]; 
		unset($el['oAtts'][$_atts['rel']]);
	}
	
	if(empty($link)){
		return;
	}
	
	// Set Attributes for backward compatibility
	if(!empty($link['target'])){
		$el['attr'][][$_atts['selector']] = 'target="_blank"';
	}
	
	// Set Attributes for backward compatibility
	if(!empty($link['attrs']) ){
		$el['attr'][][$_atts['selector']] = $link['attrs'];
	}
	
	if(!is_array($el['atts'][$_atts['link']])){
		$link['link'] = @$el['atts'][$_atts['link']];
	}
	
	$el['oAtts'][$_atts['link']] = $link;
	$el['atts'][$_atts['link']] = $link;
}
PK�f\�SL�'='=post_metas.phpnu�[���<?php

//////////////////////////////////////////////////////////////
//===========================================================
// post_metas.php
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date:	   23rd Jan 2017
// Time:	   23:00 hrs
// Site:	   http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////

// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
	exit('Hacking Attempt !');
}

// Show the post props
function pagelayer_meta_page(){
	global $post_type, $post_type_object, $post, $wp_meta_boxes, $current_screen, $user_ID, $post_ID;
	
	$post_ID = (int) @$_GET['post'];
	
	if(empty($post_ID)){
		return;
	}
	
	$post = get_post($post_ID);
	
	if(empty($post)){
		return;
	}
	
	if ( ! current_user_can( 'edit_post', $post_ID ) ) {
		wp_die( __( 'Sorry, you are not allowed to edit this item.' ) );
	}

	$post_type = $post->post_type;
	$post_type_object = get_post_type_object( $post_type );
	$user_ID = get_current_user_id();
	
	// Set current screen
	set_current_screen($post_type);
	
	// Flag that we're not loading the block editor.
	$current_screen = get_current_screen();
	$current_screen->is_block_editor = 0;
	
	$form_extra = '';
	$form_action  = 'editpost';
	$nonce_action = 'update-post_' . $post_ID;
	$form_extra  .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr( $post_ID ) . "' />";

	// All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action).
	$lib = ABSPATH . 'site-admin/includes/meta-boxes.php';
	$lib = file_exists($lib) ? $lib : ABSPATH . 'wp-admin/includes/meta-boxes.php';
	require_once $lib;

	register_and_do_post_meta_boxes( $post );
	
	$locations = array( 'side', 'normal', 'advanced' );
	$priorities = array( 'high', 'sorted', 'core', 'default', 'low' );
	$to_remove_box = array('submitdiv', 'categorydiv', 'tagsdiv-post_tag', 'pageparentdiv', 'postimagediv', 'revisionsdiv', 'commentsdiv', 'formatdiv', 'postexcerpt', 'commentstatusdiv', 'slugdiv', 'authordiv');
	
	// Remove meta boxes from pagelayer settings
	$to_remove_box = apply_filters('pagelayer_remove_meta_boxes', $to_remove_box);
	
	// Remove Meta Boxes
	foreach( $locations as $location ){
		foreach( $priorities as $priority ){
			if( isset( $wp_meta_boxes[ $current_screen->id ][ $location ][ $priority ] ) ){
				foreach( $to_remove_box as $to_remove ) {
					if(array_key_exists($to_remove, $wp_meta_boxes[ $current_screen->id ][ $location ][ $priority ])){
						remove_meta_box($to_remove, $current_screen, $location);
					}
				}
			}
		}
	}
	
	// Add format div again to change the position
	if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) ) {
		add_meta_box( 'formatdiv', _x( 'Format', 'post format' ), 'post_format_meta_box', null, 'normal', 'default', array( '__back_compat_meta_box' => true ) );
	}
	
	// TO show all hidden meta boxes
	add_filter( 'hidden_meta_boxes',  function( $hidden, $screen, $use_defaults ){
		return array();
	}, 999, 3);
	
	$props_tabs = array(
		'advanced_props' => array(
			'label' =>  __('Advanced'),
			'icon' =>  'dashicons dashicons-welcome-add-page',
			'class' =>  'pagelayer-active-item',
		),
		'hf_code' => array(
			'label' =>  __('Header, Body and Footer'),
			'icon' =>  'dashicons dashicons-editor-code',
		),
	);
	
	$props_tabs = apply_filters('pagelayer_post_props_tabs', $props_tabs);
	
	?>
<style type="text/css">
body{
height: 100vh;
}

#wpcontent,
#wpbody-content,
html.wp-toolbar{
padding:0;
}

.postbox .handle-order-higher, .postbox .handle-order-lower,
#minor-publishing-actions,
.site-menu-header{
display:none;	
}

.postbox{
border: 0;
border-bottom: 1px solid #ccd0d4;
}

.pagelayer-side-meta .meta-box-sortables{
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-gap: 10px;
grid-auto-rows: auto;
}

.pagelayer-side-meta .postbox.closed{
height:max-content;	
}

#major-publishing-actions{
display:none;	
}

@media screen and (max-width: 1170px) {
.pagelayer-side-meta .meta-box-sortables{
grid-template-columns: repeat(2, 1fr);
}
}

@media screen and (max-width: 782px){
.auto-fold #wpcontent {
padding-left:4px;
}
.pagelayer-side-meta .meta-box-sortables{
grid-template-columns: auto;
}
}

.pagelayer-modal{
overflow: hidden;
position: fixed;
top:0;
left:0;
display: flex;
-ms-flex-direction: column;
flex-direction: column;
width: 100%;
height: 100vh;
pointer-events: auto;
background-color: #292e37;
background-clip: padding-box;
font-size: 14px;
font-weight: 600;
color : 333;
z-index: 999999;
}

.pagelayer-tab-wrap,
.pagelayer-modal-holder{
position: relative;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
height: calc(100% - 60px);	
}

.pagelayer-tab-wrap{
flex-wrap: nowrap;
}

.pagelayer-modal-sidebar{
max-width: 256px;
min-width: 200px;
width: 100%;
position: relative;
color: #fff;
padding: 30px 20px;
height: calc(100% + 40px);
overflow:auto;
}

.pagelayer-sidebar-items{
padding: 10px;
}

.pagelayer-active-item,
.pagelayer-sidebar-items:hover{
background-color: #474c54;
transition:300ms;
}

.pagelayer-modal-content{
-webkit-box-flex: 1;
-ms-flex: 1 1 auto;
flex: 1 1 auto;
height: 100%;
background-color: #ffffff;
position: relative;
}

.pagelayer-form{
height:100%;
flex-grow:1;
}

.pagelayer-modal-holder{
flex-wrap: nowrap !important;
}

.pagelayer-modal-header{
padding: 20px 40px 20px 20px;
border-bottom: 1px solid #f1f1f1;
}

.pagelayer-modal-header h2{
margin:0;
}

.pagelayer-modal-body{
background-color: #f1f1f1;
height:100%;
}

.pagelayer-inner-body{
overflow:auto;
padding:20px;
height:calc(100% - 90px);
}

.pagelayer-inner-footer{
padding: 20px;
background-color: #ffffff;
position:absolute;
bottom:-65px;
left:0;
max-height:65px;
width:100%;
border-top: 1px solid #f1f1f1;
}

.pagelayer-meta-tabs{
display: flex;
align-items: center;
justify-content: center;
}

.pagelayer-tab-items{
cursor:pointer;
}

.pagelayer-meta-tabs .pagelayer-tab-items{
padding:20px 10px;
}

.pagelayer-meta-tabs .pagelayer-active-item,
.pagelayer-meta-tabs .pagelayer-tab-items:hover{
background-color: #f1f1f1;
transform: scale(1.02);
color: #3e8ef7;
}

.pagelayer-hidden{
display:none;
}

.pagelayer-show{
display:block;
}

.pagelayer-save-btn{
border: #398439 1px solid;
color: #fff;
background: #449d44;
padding: 5px 10px;
cursor: pointer;
}

.pagelayer-block{
display:block;
}

.pagelayer-textarea{
width:70%;
}

.pagelayer-h-full{
height: 100%;
}

.pagelayer-post-title{
margin-bottom: 20px;
}
</style>

<script type="text/javascript">
jQuery(document).ready(function(){
	
	// Prevent the click Inside the meta pages
	pagelayer_prevent_click_metas();
	
	jQuery('.pagelayer-modal .pagelayer-tab-items').on('click', function(){
		var jEle = jQuery(this);
		var show_panel = jEle.attr('data-tab');
		var holder = jEle.closest('.pagelayer-tab-wrap');
		
		// Hide all tab panels
		holder.find('[tab-panel]').hide();
		jEle.closest('.pagelayer-tab-holder').find('.pagelayer-tab-items').removeClass('pagelayer-active-item');
		
		// Show and active the click panel
		jEle.addClass('pagelayer-active-item');
		holder.find('[tab-panel="'+show_panel+'"]').first().show();
	});
	
	// Do active tab
	jQuery('.pagelayer-modal .pagelayer-tab-items.pagelayer-active-item').first().click();
	
});

// Prevent the click Inside the meta pages
function pagelayer_prevent_click_metas(){
	jQuery(document).on("submit", function(event){
		event.preventDefault();
	});
	
	jQuery(document).on("click", function(event){
		var target = jQuery(event.target);
		if (target.closest("a").length > 0) {
			event.preventDefault();
			var href = target.closest("a").attr("href");
			
			if(!href.match(/(http|https):\/\//g)){
				return;
			}
			
			var exp = new RegExp("(http|https):\/\/"+window.location.hostname, "g");
			
			// Open new window
			if(href.match(exp)){
				
				// Reload same window
				window.parent.location.assign(href);
			}else{
				window.open(href, "_blank");
			}
			
		}
	});
}
</script>

<div class="pagelayer-modal">
	<div class="pagelayer-modal-holder">
		<form name="post" action="post.php" method="post" onsubmit="return pagelayer_post_edit(this, event)" id="post" class="pagelayer-form pagelayer-tab-wrap" <?php $referer = wp_get_referer(); ?>>
				
			<?php wp_nonce_field( $nonce_action ); ?>
			<input type="hidden" name="is_pagelayer_editor" value="1" />
			<input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID; ?>" />
			<input type="hidden" id="hiddenaction" name="action1" value="<?php echo esc_attr( $form_action ); ?>" />
			<input type="hidden" id="originalaction" name="originalaction" value="<?php echo esc_attr( $form_action ); ?>" />
			<input type="hidden" id="post_author" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" />
			<input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr( $post_type ); ?>" />
			<input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr( $post->post_status ); ?>" />
			<input type="hidden" id="referredby" name="referredby" value="<?php echo $referer ? esc_url( $referer ) : ''; ?>" />
			<?php if ( ! empty( $active_post_lock ) ) { ?>
			<input type="hidden" id="active_post_lock" value="<?php echo esc_attr( implode( ':', $active_post_lock ) ); ?>" />
				<?php
			}
			if ( 'draft' !== get_post_status( $post ) ) {
				wp_original_referer_field( true, 'previous' );
			}

			echo $form_extra;

			wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
			wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );

			?>
			<!-- Start Tabs-->
			<div class="pagelayer-modal-sidebar pagelayer-tab-holder">
			
				<?php foreach($props_tabs as $key => $props_tab){?>
					<div class="pagelayer-sidebar-items pagelayer-tab-items <?php echo ( !empty($props_tab['class']) ? $props_tab['class'] : '' );?>" data-tab="<?php echo $key; ?>" <?php echo ( !empty($props_tab['attr']) ? $props_tab['attr'] : '' );?>>
						<span class="<?php echo $props_tab['icon']; ?>"></span> <?php echo $props_tab['label']; ?>
					</div>
				<?php } ?>
				
			</div>
			<!-- End Tabs-->
			<div class="pagelayer-modal-content" tab-panel="advanced_props">
				<div class="pagelayer-modal-header">
					<h2><?php _e('Advanced Props') ?></h2>
				</div>
				<div class="pagelayer-modal-body">
					<div class="pagelayer-inner-body metabox-holder">
						<?php 
							do_meta_boxes( $post_type, 'side', $post );
							do_meta_boxes( $post_type, 'normal', $post );
							do_meta_boxes( $post_type, 'advanced', $post ); 
						?>
					</div>
					<div class="pagelayer-inner-footer">
						<input type="submit" class="pagelayer-save-btn" name="pagelayer_submit2" value="<?php _e('Save Changes'); ?>">
					</div>
				</div>
			</div>
			<div class="pagelayer-modal-content pagelayer-hidden" tab-panel="hf_code">
				<?php pagelayer_post_hf_code(); ?>
			</div>
			
			<?php apply_filters('pagelayer_post_props_tabs_panel', '');?>
			<!-- End Tab panels -->
		</form>
	</div>
</div>
	<?php
	
}

// Post Title
function pagelayer_post_title(){
	global $post_type, $post_type_object, $post, $wp_meta_boxes, $current_screen, $user_ID, $post_ID;

	if ( !post_type_supports( $post_type, 'title' ) ) { 
		return ''; 
	}
?>
<div id="titlediv">
	<label for="title"><?php _e('Post Title') ?></label>
	<div id="titlewrap">
		<?php
		$title_placeholder = apply_filters( 'enter_title_here', __( 'Add title' ), $post );
		?>
		<label class="screen-reader-text" id="title-prompt-text" for="title"><?php echo $title_placeholder; ?></label>
		<input type="text" name="post_title" size="30" value="<?php echo esc_attr( $post->post_title ); ?>" id="title" spellcheck="true" autocomplete="off" />
	</div>
	<?php
	//do_action( 'edit_form_before_permalink', $post );
	?>
	<div class="inside">
		<?php
		$viewable = is_post_type_viewable( $post_type_object );

		if ( $viewable ) :
			$sample_permalink_html = $post_type_object->public ? get_sample_permalink_html( $post->ID ) : '';

			// As of 4.4, the Get Shortlink button is hidden by default.
			if ( has_filter( 'pre_get_shortlink' ) || has_filter( 'get_shortlink' ) ) {
				$shortlink = wp_get_shortlink( $post->ID, 'post' );

				if ( ! empty( $shortlink ) && $shortlink !== $permalink && home_url( '?page_id=' . $post->ID ) !== $permalink ) {
					$sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr( $shortlink ) . '" />' .
						'<button type="button" class="button button-small" onclick="prompt(&#39;URL:&#39;, jQuery(\'#shortlink\').val());">' .
						__( 'Get Shortlink' ) .
						'</button>';
				}
			}

			if ( $post_type_object->public
				&& ! ( 'pending' === get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) )
			) {
				$has_sample_permalink = $sample_permalink_html && 'auto-draft' !== $post->post_status;
				?>
		<div id="edit-slug-box" class="hide-if-no-js">
				<?php
				if ( $has_sample_permalink ) {
					echo $sample_permalink_html;
				}
				?>
		</div>
				<?php
			}
	endif;
		?>
	</div>
	<?php
	wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false );
	?>
</div><!-- /titlediv -->
	<?php
}

// Header body and footer code
function pagelayer_post_hf_code(){
	global $post_type, $post_type_object, $post, $wp_meta_boxes, $current_screen, $user_ID, $post_ID;
	
	?>
	<div class="pagelayer-modal-header">
		<h2><?php _e('Header, Body and Footer Code') ?></h2>
	</div>
	<div class="pagelayer-modal-body">
		<div class="pagelayer-inner-body">
			<p> <?php _e('You can add custom code like HTML, JavaScript, CSS etc. for the current post.') ?> </p>
			
			<!-- Header Code-->
			<label class="pagelayer-block"><?php _e('Header Code'); ?> :- </label>
			<textarea name="pagelayer_header_code" placeholder="Enter your code to add in header" rows="10" class="pagelayer-textarea"><?php echo get_post_meta( $post_ID, 'pagelayer_header_code', true ); ?></textarea>
			<p> <?php echo __('This code will be printed in <code>&lt;head&gt;</code> Section.') ?> </p>
			
			<!-- Body Open Code-->
			<label class="pagelayer-block"><?php _e('Body Open Code'); ?> :- </label>
			<textarea name="pagelayer_body_open_code" placeholder="Enter your code to add in body open" rows="10" class="pagelayer-textarea"><?php echo get_post_meta( $post_ID, 'pagelayer_body_open_code', true ); ?></textarea>
			<p> <?php echo __('This code will be printed begning of the <code>&lt;body&gt;</code> Section.') ?> </p>

			<!-- Header Code-->
			<label class="pagelayer-block"><?php _e('Footer Code'); ?> :- </label>
			<textarea name="pagelayer_footer_code" placeholder="Enter your code to add in Footer" rows="10" class="pagelayer-textarea"><?php echo get_post_meta( $post_ID, 'pagelayer_footer_code', true ); ?></textarea>
			<p> <?php echo __('This code will be printed before closing the <code>&lt;/body&gt;</code> Section.') ?> </p>
		</div>
		<div class="pagelayer-inner-footer">
			<input type="submit" class="pagelayer-save-btn" name="pagelayer_submit" value="<?php _e('Save Codes'); ?>">
		</div>
	</div>
	<?php

}
PK�f\ag~l''getting_started.phpnu�[���<?php

//////////////////////////////////////////////////////////////
//===========================================================
// getting_started.php
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date:	   23rd Jan 2017
// Time:	   23:00 hrs
// Site:	   http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////

// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
	exit('Hacking Attempt !');
}

$app = (!defined('SITEPAD') ? 'Pagelayer' : BRAND_SM);
?>

<link rel="stylesheet" href="<?php echo PAGELAYER_CSS.'/font-awesome5.min.css';?>">

<div class="pagelayer-getting-started">
	<div class="pagelayer-getting-started-container">
		<div class="pagelayer-getting-started-block">
			<div class="pagelayer-getting-started-logo">
				<?php echo (!defined('SITEPAD')) ? '<img src="'.PAGELAYER_URL.'/images/pagelayer-logo-256.png'.'"/>' : '<img src="'.BRAND_SM_LOGO.'" style="width:auto"/>' ?>
			</div>
			<div class="pagelayer-getting-started-desc">
				<h1><?php echo __pl('welcome_to').$app;?></h1>
				<h6><?php echo (!defined('SITEPAD')) ? __pl('choose_pagelayer') : __pl('choose_sitepad');?></h6>
			</div>
			<div class="pagelayer-getting-started-video">
				<?php echo (!defined('SITEPAD')) ? '<iframe width="700" height="400" src="https://www.youtube.com/embed/t8Iz-v-qce8" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>' : '<iframe height="400" width="700" src="https://www.youtube.com/embed/8e3ROkKoFwA" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>';?>
			</div>
			<div class="pagelayer-getting-started-desc">
				<h6><?php echo (!defined('SITEPAD')) ? __pl('pagelayer_desc') : __pl('sitepad_desc');?></h6>
				<div class="pagelayer-getting-started-btn">
					<a href="<?php echo admin_url('/post-new.php?post_type=page')?>" class="button button-primary btn-sc"><?php echo __pl('first_page');?></a>
					<a href="<?php echo (!defined('SITEPAD')) ? PAGELAYER_WWW_URL.'getting-started' : "https://sitepad.com/docs/getting-started/"; ?>" class="button button-secondary btn-sc" target="_blank"><?php echo __pl('watch_guide');?></a>
				</div>
			</div>
		</div>
		<div class="pagelayer-features">
			<div class="pagelayer-getting-started-desc">
				<h1><?php echo $app.' '.__pl('feature_style');?></h1>
				<h6><?php echo $app.__pl('brand_feature_text');?></h6>
				<div class="pagelayer-features-list">
				<?php $style = (defined('SITEPAD')) ? 'style="width:30%; height: 265px"' : ''; ?>
					<div class="feature-block-card" <?php echo $style; ?>>
						<div class="feature-block">
							<?php echo (!defined('SITEPAD')) ? '<i class="fas fa-mouse-pointer" aria-hidden="true">' : '<i class="fas fa-paper-plane" aria-hidden="true">' ?></i>
						</div>
						<div class="feature-block-content">
							<h5><?php echo (!defined('SITEPAD')) ? __pl('dragdrop') : __pl('oneclick')?></h5>
							<p><?php echo (!defined('SITEPAD')) ? __pl('dragdrop_desc') : __pl('oneclick_desc');?></p>
						</div>
					</div>
					<div class="feature-block-card" <?php echo $style; ?>>
						<div class="feature-block">
							<?php echo (!defined('SITEPAD')) ? '<i class="fa fa-th-list" aria-hidden="true">' : '<i class="fas fa-random" aria-hidden="true">' ?></i>
						</div>
						<div class="feature-block-content">
							<h5><?php echo (!defined('SITEPAD')) ? __pl('widgets') : __pl('static_pages')?></h5>
							<p><?php echo (!defined('SITEPAD')) ? __pl('widgets_desc') : __pl('static_pages_desc');?></p>
						</div>
					</div>
					<div class="feature-block-card" <?php echo $style; ?>>
						<div class="feature-block">
							<?php echo (!defined('SITEPAD')) ? '<i class="fa fa-pencil" aria-hidden="true">' : '<i class="fas fa-mobile-alt" aria-hidden="true">' ?></i>
						</div>
						<div class="feature-block-content">
							<h5><?php echo (!defined('SITEPAD')) ? __pl('inline_edit') : __pl('responsive_styles')?></h5>
							<p><?php echo (!defined('SITEPAD')) ? __pl('inline_edit_desc') : __pl('responsive_desc');?></p>
						</div>
					</div>
					<div class="feature-block-card" <?php echo $style; ?>>
						<div class="feature-block">
							<?php echo (!defined('SITEPAD')) ? '<i class="fa fa-clone" aria-hidden="true">' : '<i class="fas fa-share-square" aria-hidden="true">' ?></i>
						</div>
						<div class="feature-block-content">
							<h5><?php echo (!defined('SITEPAD')) ? __pl('duplicate') : __pl('social_media')?></h5>
							<p><?php echo (!defined('SITEPAD')) ? __pl('duplicate_desc') : __pl('social_media_desc');?></p>
						</div>
					</div>
					<div class="feature-block-card" <?php echo $style; ?>>
						<div class="feature-block">
							<?php echo (!defined('SITEPAD')) ? '<i class="fa fa-snowflake-o fa-spin" aria-hidden="true">' : '<i class="fas fa-check" aria-hidden="true">' ?></i>
						</div>
						<div class="feature-block-content">
							<h5><?php echo (!defined('SITEPAD')) ? __pl('animation') : __pl('easy_use')?></h5>
							<p><?php echo (!defined('SITEPAD')) ? __pl('animation_desc') : __pl('easy_use_desc');?></p>
						</div>
					</div>
					<div class="feature-block-card" <?php echo $style; ?>>
						<div class="feature-block">
							<?php echo (!defined('SITEPAD')) ? '<i class="fa fa-text-width" aria-hidden="true">' : '<i class="fas fa-cog" aria-hidden="true">' ?></i>
						</div>
						<div class="feature-block-content">
							<h5><?php echo (!defined('SITEPAD')) ? __pl('style_option') : __pl('cpanel_integrate')?></h5>
							<p><?php echo (!defined('SITEPAD')) ? __pl('style_option_desc') : __pl('cpanel_integrate_desc');?></p>
						</div>
					</div>
					<div class="feature-block-card" <?php echo $style; ?>>
						<div class="feature-block">
							<?php echo (!defined('SITEPAD')) ? '<i class="fa fa-paint-brush" aria-hidden="true">' : '<i class="fas fa-th-large" aria-hidden="true">' ?></i>
						</div>
						<div class="feature-block-content">
							<h5><?php echo (!defined('SITEPAD')) ? __pl('real_design') : __pl('multisites')?></h5>
							<p><?php echo (!defined('SITEPAD')) ? __pl('real_design_desc') : __pl('multisites_desc');?></p>
						</div>
					</div>
					<div class="feature-block-card" <?php echo $style; ?>>
						<div class="feature-block">
							<?php echo (!defined('SITEPAD')) ? '<i class="fa fa-font" aria-hidden="true">' : '<i class="fas fa-copy" aria-hidden="true">' ?></i>
						</div>
						<div class="feature-block-content">
							<h5><?php echo (!defined('SITEPAD')) ? __pl('typography') : __pl('replicate_obj')?></h5>
							<p><?php echo (!defined('SITEPAD')) ? __pl('typography_desc') : __pl('replicate_obj_desc');?></p>
						</div>
					</div>
					<div class="feature-block-card" <?php echo $style; ?>>
						<div class="feature-block">
							<?php echo (!defined('SITEPAD')) ? '<i class="fa fa-cubes" aria-hidden="true">' : '<i class="fas fa-shopping-cart" aria-hidden="true">' ?></i>
						</div>
						<div class="feature-block-content">
							<h5><?php echo (!defined('SITEPAD')) ? __pl('easy_customize') : __pl('whmcs')?></h5>
							<p><?php echo (!defined('SITEPAD')) ? __pl('easy_customize_desc') : __pl('whmcs_desc');?></p>
						</div>
					</div>
				<div class="pagelayer-getting-started-btn">
					<a href=" <?php echo (!defined('SITEPAD')) ? PAGELAYER_WWW_URL : "http://sitepad.com/"?>" class="button button-secondary btn-sc" target="_blank" style="margin-top:20px;"><?php echo __pl('why').' '.$app.'?';?></a>
				</div>
			</div>
		</div>
	</div>
</div>

<style>

.pagelayer-getting-started{
	padding-top: 50px;
}

.pagelayer-getting-started-container{
	margin: 0 auto;
	max-width: 1000px;
	padding: 0;
	text-align: center;
}

.pagelayer-getting-started-block{
	background-color: #fff;
	border: 2px solid #e1e1e1;
	border-radius: 2px;
	margin-bottom: 30px;
	position: relative;
	padding-top: 40px;
}

.pagelayer-getting-started-logo img{
	width: 10%;
	height: auto;
}

.pagelayer-getting-started-desc{
	padding: 40px;
}

.pagelayer-getting-started-desc h1{
	color: #222;
	font-size: 24px;
	margin: 0 0 24px 0;
}

.pagelayer-getting-started-desc h6{
	font-size: 16px;
	font-weight: 400;
	line-height: 1.6;
	margin: 0 85px 0 85px;
}

.pagelayer-getting-started-btn{
	max-width: 600px;
	margin: 0 auto 0 auto;
	margin-top: 36px !important;
}

.btn-sc{
	font-size: 14px !important;
	min-height: 46px !important;
	line-height: 3.14285714 ! important;
	padding: 0px 36px !important;
}

.button-primary{
	margin-right: 20px !important;
	border-radius: 3px !important;
}

.pagelayer-features{
	background-color: #fff;
	border: 2px solid #e1e1e1;
	border-radius: 2px 2px 0 0;
	position: relative;
}

.feature-block-card{
	width: 25%;
	display: inline-block;
	margin: 60px 10px 0 10px;
	vertical-align: top;
	box-shadow: 0px 0px 20px 0px rgba(0,0,0,.1);
	padding: 20px;
	height: 220px;
}

.feature-block{
	background: linear-gradient(to right, rgb(116, 116, 191), rgb(52, 138, 199));
	border-radius: 50%;
	width: 54px;
	height: 54px;
	position: relative;
	display: inline-block;
}

.feature-block i{
	font-size: 30px;
	color: #fff;
	position: absolute;
	top: 13px;
	left: 0;
	right: 0;
}

.feature-block-content h5{
	color: #222;
	font-size: 20px;
	margin: 10px 0 0 0;
}

.feature-block-content p{
	color: #222;
	font-size: 16px;
	margin-top: 10px;
}

.fa-spin{
	-webkit-animation: fa-spin 2s infinite linear;
	animation: fa-spin 2s infinite linear;
}
</style>PK�f\X�;kk
functions.phpnu�[���<?php

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

$softaculous_pro_settings = get_option('softaculous_pro_settings', array());

if(!empty($softaculous_pro_settings['disable_comments'])){
	include_once SOFTACULOUS_PRO_PLUGIN_PATH . '/main/disable-comments.php';
}

if(is_admin() && empty($softaculous_pro_settings['disable_ai'])){
	add_action('enqueue_block_editor_assets', '\SoftWP\AI::enqueue_scripts');

	// AJAX ACTIONS
	add_action('wp_ajax_softaculous_ai_generation', '\SoftWP\AI::generate');
	add_action('wp_ajax_softaculous_ai_history', '\SoftWP\AI::load_history');
}

$spro_page = softaculous_pro_optGET('page');
if(is_admin() && !empty($spro_page) && $spro_page == 'assistant'){
	$spro_act = softaculous_pro_optGET('act');
	if(!empty($spro_act) && $spro_act == 'onboarding'){
		include_once(SOFTACULOUS_PRO_PLUGIN_PATH . '/main/onboarding.php');
	}
}

function softaculous_pro_activation_hook(){
	softaculous_pro_update_check();
}

function softaculous_pro_deactivation_hook() {
	
}

function softaculous_pro_uninstall_hook() {
	delete_option('softaculous_pro_version');
	delete_option('softaculous_pro_settings');
	delete_option('softaculous_pro_onboarding_notice_dismiss');
	delete_option('softaculous_pro_ai_notice_dismiss');
	delete_option('softaculous_pro_onboarding_done');
	delete_option('softaculous_pro_onboarding_dismiss');
	delete_option('softaculous_pro_setup_info');
	delete_option('softaculous_pro_onboarding_shown');
	
	wp_clear_scheduled_hook('softaculous_pro_ai_history_cron');
}

function softaculous_pro_load_plugin(){
	
	global $softaculous_pro, $softaculous_pro_settings, $spro_tours;
	
	
	add_action('softaculous_pro_ai_history_cron', '\SoftWP\AI::delete_history'); // Cron for AI History deletion
	if(!is_admin()){
		return false;
	}
	
	// Do we have to redirect the user to onboarding ? 
	if(is_admin() && current_user_can('administrator') && !wp_doing_ajax() && (empty($_GET['act']) || ($_GET['act'] != 'onboarding' && $_GET['act'] != 'license'))){
		
		$spro_is_dismissed = get_option('softaculous_pro_onboarding_dismiss');
		$spro_is_done = get_option('softaculous_pro_onboarding_done');
		$spro_is_shown = get_option('softaculous_pro_onboarding_shown');
		
		if(empty($spro_is_dismissed) && empty($spro_is_done) && empty($spro_is_shown)){
			wp_safe_redirect(admin_url('admin.php?page=assistant&act=onboarding'));
			exit(0);
		}
	}

	softaculous_pro_load_license();
	
	softaculous_pro_rebranding();
	
	// Show key details in Plugins data
	add_filter('plugin_row_meta', 'softaculous_pro_add_plugin_row_links', 10, 2);
	
	// Check for updates
	include_once(SOFTACULOUS_PRO_PLUGIN_PATH.'/lib/plugin-update-checker.php');
	$softaculous_pro_updater = SoftaculousPro_PucFactory::buildUpdateChecker(softaculous_pro_api_url().'updates.php?version='.SOFTACULOUS_PRO_VERSION.'&url='.rawurlencode(site_url()), SOFTACULOUS_PRO_FILE);
	
	// Add the license key to query arguments
	$softaculous_pro_updater->addQueryArgFilter('softaculous_pro_updater_filter_args');
	
	// Show the text to install the license key
	add_filter('puc_manual_final_check_link-softaculous-pro', 'softaculous_pro_updater_check_link', 10, 1);
	
	softaculous_pro_update_check();
	
	// Register AI Post type
	add_action('init', 'softaculous_pro_register_post_type');
	
	$spro_tours = array('assistant' => 'admin.php?page=assistant', 'sidebar' => 'admin.php?page=assistant', 'dashboard' => 'index.php', 'plugins' => 'plugins.php', 'themes' => 'themes.php', 'users' => 'users.php', 'pages' => 'edit.php?post_type=page', 'posts' => 'edit.php');
	
	// Enqueues scripts and styles
	if(softaculous_pro_can_enqueue_assets()){
		add_action('admin_init', 'softaculous_pro_admin');
		add_action('admin_enqueue_scripts', 'softaculous_pro_enqueue_scripts');
	}
	
	if(is_admin() && !empty($_GET['page']) && $_GET['page'] == 'assistant'){
		add_filter('screen_options_show_screen', '__return_false');
	}
	
	add_action('admin_notices', 'softaculous_pro_license_notice');
	
	// Are you the Admin ?
	if(current_user_can('administrator')){
	
		if(softaculous_pro_is_display_notice()){
			add_action('admin_notices', 'softaculous_pro_admin_notice');
		}
		
		add_action('wp_ajax_softaculous_pro_dismissnotice', 'softaculous_pro_dismiss_notice');
		
		// This adds the left menu in WordPress Admin page
		add_action('admin_menu', 'softaculous_pro_admin_menu', 5);
	
		include_once SOFTACULOUS_PRO_PLUGIN_PATH . '/main/admin.php';
		add_action('admin_print_footer_scripts', 'softaculous_pro_assistant', 5);
		
		add_action('wp_ajax_softaculous_pro_wp_ajax', 'softaculous_pro_wp_ajax');
		
		add_action('admin_menu', 'softaculous_pro_remove_admin_elements');

		// Template Installation related ajax calls
		add_action('wp_ajax_softaculous_pro_template_info', 'softaculous_pro_templates_ajax');
		add_action('wp_ajax_softaculous_pro_start_install_template', 'softaculous_pro_templates_ajax');
		add_action('wp_ajax_softaculous_pro_selected_plugin_install', 'softaculous_pro_templates_ajax');
		add_action('wp_ajax_softaculous_pro_download_template', 'softaculous_pro_templates_ajax');
		add_action('wp_ajax_softaculous_pro_import_template', 'softaculous_pro_templates_ajax');
		
		// Setup information
		add_action('wp_ajax_softaculous_pro_setup_info', 'softaculous_pro_templates_ajax');
		
		// dismiss
		add_action('wp_ajax_softaculous_pro_onboarding_dismiss', 'softaculous_pro_templates_ajax');
		
		add_action('wp_ajax_softaculous_pro_option_value', 'softaculous_pro_templates_ajax');
		
	}
	
	// Manage Media hooks
	if(is_admin() && empty($softaculous_pro_settings['disable_manage_media']) && current_user_can('upload_files') /* && !empty($post) && !empty($post->post_type) && $post->post_type == 'attachment' */){
		
		add_action('add_meta_boxes_attachment', '\SoftWP\Media::register_meta_box');
		add_filter('media_row_actions', '\SoftWP\Media::add_media_row_action', 11, 2);
		
		// ajax calls
		add_action('wp_ajax_softaculous_pro_upload_photopea_image', '\SoftWP\Media::upload_photopea_image');
		add_action('wp_ajax_softaculous_pro_calculate_compressed_size', '\SoftWP\Media::calculate_compressed_size');
		add_action('wp_ajax_softaculous_pro_replace_compressed_image', '\SoftWP\Media::replace_compressed_image');
	}
}

function softaculous_pro_templates_ajax() {
	
	if(!current_user_can('administrator')){
		return false;
	}

	include_once(dirname(__FILE__).'/onboarding.php');
	
	if($_REQUEST['action'] == 'softaculous_pro_template_info'){
		softaculous_pro_ajax_template_info();
	}
	
	if($_REQUEST['action'] == 'softaculous_pro_selected_plugin_install'){
		softaculous_pro_ajax_selected_plugin();
	}
	
	if($_REQUEST['action'] == 'softaculous_pro_start_install_template'){
		softaculous_pro_ajax_start_install_template();
	}
	
	if($_REQUEST['action'] == 'softaculous_pro_download_template'){
		softaculous_pro_ajax_download_template();
	}
	
	if($_REQUEST['action'] == 'softaculous_pro_import_template'){
		softaculous_pro_ajax_import_template();
	}
	
	if($_REQUEST['action'] == 'softaculous_pro_setup_info'){
		softaculous_pro_save_setup_info();
	}
	
	if($_REQUEST['action'] == 'softaculous_pro_option_value'){
		softaculous_pro_get_options();
	}
	
	if($_REQUEST['action'] == 'softaculous_pro_onboarding_dismiss'){
		softaculous_pro_onboarding_dismiss();
	}

}

function softaculous_pro_remove_admin_elements(){
	
	if(!empty($_GET['page']) && $_GET['page'] === 'assistant'){
		remove_all_actions('admin_notices');
		remove_all_actions('all_admin_notices');
	}
}

// Update check
function softaculous_pro_update_check(){
	global $softaculous_pro_settings;

	$current_version = get_option('softaculous_pro_version', 0);
	$version = (int) str_replace('.', '', $current_version);

	if($current_version == SOFTACULOUS_PRO_VERSION){
		return true;
	}
	
	// AI is enabled by default so the cron to delete AI history should be added at activation.
	wp_schedule_event(time(), 'daily', 'softaculous_pro_ai_history_cron');
	
	if(empty($softaculous_pro_settings) || !isset($softaculous_pro_settings['ai_history_duration'])){
		$softaculous_pro_settings['ai_history_duration'] = 90; // Setting default AI history duration.
		update_option('softaculous_pro_settings', $softaculous_pro_settings);
	}

	// Save the new Version
	update_option('softaculous_pro_version', SOFTACULOUS_PRO_VERSION);
}

function softaculous_pro_admin(){
	
	global $spro_tours;
	
	include_once SOFTACULOUS_PRO_PLUGIN_PATH . '/main/admin.php';
	
}

// Shows the admin menu of Softaculous
function softaculous_pro_admin_menu() {
	
	$capability = 'activate_plugins';// TODO : Capability for accessing this page

	// Add the menu page
	add_menu_page(__('Assistant'), __('Assistant', 'softaculous-pro'), $capability, 'assistant', 'softaculous_pro_page_handler', 'dashicons-businessperson', 1);
	
}

// The Softaculous Settings Page
function softaculous_pro_page_handler(){
	
	global $softaculous_pro;

	if(!current_user_can('manage_options')){
		wp_die(__('Sorry, but you do not have permissions to change settings.', 'softaculous-pro'));
	}
	
	$act = softaculous_pro_optGET('act');
	
	switch($act){
		
		case 'onboarding':
		include_once(SOFTACULOUS_PRO_PLUGIN_PATH . '/main/setup.php');
		break;
		
		case 'license':
		include_once(SOFTACULOUS_PRO_PLUGIN_PATH . '/main/license.php');
		softaculous_pro_license();
		break;
		
		case 'manage-plugins':
		include_once(SOFTACULOUS_PRO_PLUGIN_PATH . '/main/manage-plugins.php');
		softaculous_pro_manage_plugins();
		break;
		
		case 'media-replace':
		\SoftWP\Media::replace_media_page();
		break;
		
		default:
		include_once(dirname(__FILE__).'/admin.php');
		softaculous_pro_page_settings();
	}

}

function softaculous_pro_can_enqueue_assets(){
	
	global $spro_tours;
	
	if(!is_admin()){
		return false;
	}
	
	$current_page = basename($_SERVER['REQUEST_URI'], PHP_URL_PATH);
	
	if(!empty($_COOKIE['spro-load-tour']) && (!empty($spro_tours)) && array_key_exists($_COOKIE['spro-load-tour'], $spro_tours) && $current_page == $spro_tours[$_COOKIE['spro-load-tour']]){
		return $_COOKIE['spro-load-tour'];
	}
	
	$is_admin_page = basename(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
	if(!empty($_GET['page']) && $_GET['page'] == 'assistant' && $is_admin_page == 'admin.php'){
		return true;
	}
	
	return false;
	
}

function softaculous_pro_enqueue_scripts(){
	
	wp_enqueue_style('softaculous-pro-style-admin', SOFTACULOUS_PRO_PLUGIN_URL . '/assets/css/admin.css', [], SOFTACULOUS_PRO_VERSION);

	wp_enqueue_style('softaculous-pro-style-intro', SOFTACULOUS_PRO_PLUGIN_URL . '/assets/css/intro.css', [], SOFTACULOUS_PRO_VERSION);
	
	wp_enqueue_style( 'softaculous-pro-style-font-awesome', SOFTACULOUS_PRO_PLUGIN_URL . '/assets/font-awesome/css/all.min.css', [], SOFTACULOUS_PRO_VERSION, 'all' );

	wp_enqueue_script('softaculous-pro-script-admin', SOFTACULOUS_PRO_PLUGIN_URL . '/assets/js/admin.js', [], SOFTACULOUS_PRO_VERSION, true);

	wp_enqueue_script('softaculous-pro-script-intro', SOFTACULOUS_PRO_PLUGIN_URL . '/assets/js/intro.js', [], SOFTACULOUS_PRO_VERSION, false);
	
	wp_localize_script('softaculous-pro-script-admin', 'soft_pro_obj', array(
		'admin_url' => esc_url(admin_url()),
		'site_url' => esc_url(site_url()),
		'nonce' => wp_create_nonce('softaculous_pro_js_nonce'),
		'ajax_url' => admin_url('admin-ajax.php')
	));
}

/**
 * Display Softaculous notice on the basis of last dismiss date. When user manually dismisses the notice, it remains for 1 month
 *
 * @since		1.0
 */
function softaculous_pro_is_display_notice(){
	
	$soft_dismissable_notice_date = get_option('softaculous_pro_dismiss_notice_date');
	
	if(empty($soft_dismissable_notice_date)){
		return true;
	}
	
	$soft_dismissable_notice_date2 = new DateTime($soft_dismissable_notice_date);
	$current_date = new DateTime(date('Y-m-d'));
	$date_diff_month = $soft_dismissable_notice_date2->diff($current_date);

	//Do not display notice again for a month
	if($date_diff_month->m < 1){
		return false;
	}
	
	return true;
}

/**
 * Display Softaculous notice in dashboard
 *
 * @since		1.0
 */
function softaculous_pro_admin_notice($force = 0){
	
	if(!empty($_GET['page']) && $_GET['page'] == 'softaculous' && empty($force)){
		return '';
	}
	
	return '';
}

function softaculous_pro_license_notice(){
	
	global $softaculous_pro;
	
	if(is_admin() && current_user_can('activate_plugins') && !wp_doing_ajax()){
		
		$spro_add_nonce_vars = 0;
		
		if(empty($softaculous_pro['license']['license'])){
			$msg = sprintf(__('Your SoftWP plugin is %1$sUnlicensed%2$s. Please enter the license key %3$s here%4$s.', 'softaculous-pro'), 
						'<font style="color:red;"><b>',
						'</b></font>',
						'<a href="'.admin_url('admin.php?page=assistant&act=license').'">',
						'</a>'
						);
		}else{
			
			if(!empty($softaculous_pro['license']['url_mismatch'])){
				$msg = sprintf(__('Your SoftWP plugin license is %1$snot authorized%2$s to be used on  %3$s. You can generate a new license for your domain from the %4$s panel.', 'softaculous-pro'), 
							'<b><font style="color:red;">',
							'</font></b>',
							'<b><i>'.site_url().'</i></b>',
							'<b>'.($softaculous_pro['branding']['sn'] == 'SoftWP' ? 'Softaculous' : $softaculous_pro['branding']['sn']).'</b>'
							);
			}elseif(empty($softaculous_pro['license']['active'])){
				$msg = sprintf(__('Your SoftWP plugin license has %1$sExpired%2$s. Please renew your license for uninterrupted updates and support.', 'softaculous-pro'), 
							'<font style="color:red;"><b>',
							'</b></font>'
							);
			}
		}
		
		if(!empty($msg)){
			echo '
			<div class="notice notice-error is-dismissible">
				<p>'.$msg.'</p>
			</div>';
		}
		
		// The notice to complete onboarding
		//$spro_is_shown = get_option('softaculous_pro_onboarding_shown');
		$spro_is_done = get_option('softaculous_pro_onboarding_done');
		$spro_is_dismissed = get_option('softaculous_pro_onboarding_notice_dismiss');
		
		if(empty($spro_is_done) && empty($spro_is_dismissed)){
			echo '
			<div class="notice notice-error is-dismissible" id="softaculous-onboarding-notice">
				<p>'.sprintf(__('Your Onboarding process is not completed yet! %1$sClick here%2$s to complete the simple setup process and build your site in a few steps.', 'softaculous-pro'),
							'<a href="'.admin_url('admin.php?page=assistant&act=onboarding').'" target="_blank">',
							'</a>').'</p>
			</div>
			<script type="text/javascript">
				jQuery(document).ready(function($){
					$("#softaculous-onboarding-notice").on("click", ".notice-dismiss", function() {
						// Send an AJAX request to the server to dismiss the notice
						jQuery.ajax({
							type: "post",
							url: softwp_obj.ajax_url,
							data: {
								action: "softaculous_pro_wp_ajax",
								softaculous_pro_onboarding_notice_dismiss: 1,
								softaculous_pro_security: softwp_obj.nonce,
								data: [],
							},
						});
					});
				});
			</script>
			';
			
			$spro_add_nonce_vars = 1;
		}
		
		$softwp_ai_is_dismissed = get_option('softaculous_pro_ai_notice_dismiss');
		
		if(empty($softwp_ai_is_dismissed) && !empty($_GET['page']) && $_GET['page'] == 'assistant'){
			echo '
			<div class="notice notice-info is-dismissible" id="softaculous-ai-notice">
				<h3 style="margin: 0.5em 0;">'.__('Enhance Content Writing with AI Assistant', 'softaculous-pro').'
				</h3>
				<p>'.__('Use cutting-edge AI to write blog posts or content for your pages. Create a table, write a paragraph, change tone, translate, fix spelling & grammar and so much more.', 'softaculous-pro').' <br />
				<b>'.__('Start Exploring', 'softaculous-pro').'</b> : 
				<a href="'.admin_url('post-new.php?post_type=page').'" target="_blank" style="text-decoration:none;">'.__('New Page', 'softaculous-pro').'</a>&nbsp; &#9679; &nbsp;
				<a href="'.admin_url('post-new.php').'" target="_blank" style="text-decoration:none;">'.__('New Post', 'softaculous-pro').'</a>&nbsp; &#9679; &nbsp;
				<a href="'.admin_url('edit.php?post_type=page').'" target="_blank" style="text-decoration:none;">'.__('Existing Page', 'softaculous-pro').'</a>&nbsp; &#9679; &nbsp;
				<a href="'.admin_url('edit.php').'" target="_blank" style="text-decoration:none;">'.__('Existing Post', 'softaculous-pro').'</a> 
				</p>
			</div>
			
			<script type="text/javascript">
				jQuery(document).ready(function($){
					$("#softaculous-ai-notice").on("click", ".notice-dismiss", function() {
						// Send an AJAX request to the server to dismiss the notice
						jQuery.ajax({
							type: "post",
							url: softwp_obj.ajax_url,
							data: {
								action: "softaculous_pro_wp_ajax",
								softaculous_pro_ai_notice_dismiss: 1,
								softaculous_pro_security: softwp_obj.nonce,
								data: [],
							},
						});
					});
				});
			</script>
			';
			
			$spro_add_nonce_vars = 1;
		}
		
		if(!empty($spro_add_nonce_vars)){
			
			echo '<script type="text/javascript">
			var softwp_obj = {
			  admin_url: "'.esc_url(admin_url()).'",
			  site_url: "'.esc_url(site_url()).'",
			  nonce: "'.wp_create_nonce('softaculous_pro_js_nonce').'",
			  ajax_url: "'.admin_url('admin-ajax.php').'"
			};
			</script>';
			
		}
		
	}
	
	return '';
}

function softaculous_pro_get_option($option_name, $default_value = false, $site_id = null){
	
    if($site_id !== null && is_multisite()){
        return get_site_option($option_name, $default_value);
    }
    return get_option($option_name, $default_value);
}

/**
 * Takes care of Slashes
 *
 * @param		string $string The string that will be processed
 * @return		string A string that is safe to use for Database Queries, etc
 * @since		1.0
 */
function softaculous_pro_inputsec($string){

	//get_magic_quotes_gpc is deprecated in php 7.4
	if(version_compare(PHP_VERSION, '7.4', '<')){
		if(!get_magic_quotes_gpc()){
		
			$string = addslashes($string);
		
		}else{
		
			$string = stripslashes($string);
			$string = addslashes($string);
		
		}
	}else{
		$string = addslashes($string);
	}
	
	// This is to replace ` which can cause the command to be executed in exec()
	$string = str_replace('`', '\`', $string);
	
	return $string;

}

/**
 * Converts Special characters to html entities
 *
 * @param        string $string The string containing special characters
 * @return       string A string containing special characters replaced by html entities of the format &#ASCIICODE;
 * @since     	 1.0
 */
function softaculous_pro_htmlizer($string){

	$string = htmlentities($string, ENT_QUOTES, 'UTF-8');
	
	preg_match_all('/(&amp;#(\d{1,7}|x[0-9a-fA-F]{1,6});)/', $string, $matches);
	
	foreach($matches[1] as $mk => $mv){		
		$tmp_m = softaculous_pro_entity_check($matches[2][$mk]);
		$string = str_replace($matches[1][$mk], $tmp_m, $string);
	}
	
	return $string;
	
}

/**
 * Used in function htmlizer()
 *
 * @param        string $string
 * @return       string
 * @since     	 1.0
 */
function softaculous_pro_entity_check($string){
	
	//Convert Hexadecimal to Decimal
	$num = ((substr($string, 0, 1) === 'x') ? hexdec(substr($string, 1)) : (int) $string);
	
	//Squares and Spaces - return nothing 
	$string = (($num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num < 0x20) ? '' : '&#'.$num.';');
	
	return $string;
			
}

/**
 * OPTIONAL REQUEST of the given REQUEST Key
 *
 * @param        string $name The key of the $_REQUEST array i.e. the name of the input / textarea text 
 * @param        string $default The value to return if the $_REQUEST[$name] is NOT SET
 * @return       string Returns the string if the REQUEST is there otherwise the default value given.
 * @since     	 1.0
 */
function softaculous_pro_optREQ($name, $default = ''){

global $softaculous_error;

	//Check the POSTED NAME was posted
	if(isset($_REQUEST[$name])){
	
		return trim(sanitize_text_field($_REQUEST[$name]));
		
	}else{
		return $default;
	}
}

/**
 * OPTIONAL POST of the given POST Key
 *
 * @param        string $name The key of the $_POST array i.e. the name of the input / textarea text 
 * @param        string $default The value to return if the $_POST[$name] is NOT SET
 * @return       string Returns the string if the POST is there otherwise the default value given.
 * @since		1.4.6
 */
function softaculous_pro_optPOST($name, $default = ''){

global $softaculous_error;

	//Check the POSTED NAME was posted
	if(isset($_POST[$name])){
		
		if(is_array($_POST[$name])){
			$values = array_map('trim', $_POST[$name]);
			return array_map('sanitize_text_field', $values);
		}
	
		return trim(sanitize_text_field($_POST[$name]));
		
	}else{
		return $default;
	}

}

/**
 * OPTIONAL GET of the given GET Key i.e. dont throw a error if not there
 *
 * @param        string $name The key of the $_GET array i.e. the name of the input / textarea text 
 * @param        string $default The value to return if the $_GET[$name] is NOT SET
 * @return       string Returns the string if the GET is there otherwise the default value given.
 * @since     	 1.0
 */
function softaculous_pro_optGET($name, $default = ''){

global $softaculous_error;

	//Check the GETED NAME was GETed
	if(isset($_GET[$name])){
	
		return trim(sanitize_text_field($_GET[$name]));
		
	}else{
		return $default;
	}

}
	
function softaculous_pro_sp_api_url($main_server = 0){
	
	global $softaculous_pro;
	
	return softaculous_pro_api_url($main_server, 'sitepad');
	
}
	
function softaculous_pro_pfx_api_url($main_server = 0){
	
	global $softaculous_pro;
	
	return softaculous_pro_api_url($main_server, 'popularfx');
	
}
	
function softaculous_pro_api_url($main_server = 0, $suffix = ''){
	
	global $softaculous_pro;
	
	$r = array(
		'https://s0.softaculous.com/a/softwp/',
		'https://s1.softaculous.com/a/softwp/',
		'https://s2.softaculous.com/a/softwp/',
		'https://s3.softaculous.com/a/softwp/',
		'https://s4.softaculous.com/a/softwp/',
		'https://s5.softaculous.com/a/softwp/',
		'https://s7.softaculous.com/a/softwp/',
		'https://s8.softaculous.com/a/softwp/'
	);
	
	$mirror = $r[array_rand($r)];
	
	// If the license is newly issued, we need to fetch from API only
	if(!empty($main_server) || empty($softaculous_pro['license']['last_edit']) || 
		(!empty($softaculous_pro['license']['last_edit']) && (time() - 3600) < $softaculous_pro['license']['last_edit'])
	){
		$mirror = 'https://a.softaculous.com/softwp/';
	}
	
	// -1 indicates that we need to force the mirror server used for rendering static files e.g. screenshots
	if(!empty($main_server) && $main_server == '-1'){
		$mirror = $r[array_rand($r)];
	}
	
	if(!empty($suffix)){
		$mirror = str_replace('/softwp', '/'.$suffix, $mirror);
	}
	
	return $mirror;
	
}

// Load license data
function softaculous_pro_load_license(){
	
	global $softaculous_pro;

	// Load license
	$softaculous_pro['license'] = get_option('softaculous_pro_license', array());
	
	if(empty($softaculous_pro['license'])){
		return false;
	}
	
	$prods = apply_filters('softaculous_pro_products', []);
	
	// Update license details as well
	if(empty($softaculous_pro['license']['last_update']) || 
		(!empty($softaculous_pro['license']['last_update']) && (time() - $softaculous_pro['license']['last_update']) >= 86400)
	){
		
		$resp = wp_remote_get(softaculous_pro_api_url(1).'license.php?license='.$softaculous_pro['license']['license'].'&prods='.implode(',', $prods).'&url='.rawurlencode(site_url()));
		
		// Did we get a response ?
		if(is_array($resp)){
			
			$tosave = json_decode($resp['body'], true);
			
			// Is it the license ?
			if(!empty($tosave['license'])){
				$softaculous_pro['license'] = $tosave;
			}
			
		}
		
		// Save the old data only
		if(empty($tosave['license'])){
			$tosave = get_option('softaculous_pro_license', array());
		}
		
		$tosave['last_update'] = time();
		update_option('softaculous_pro_license', $tosave);
		
	}
	
	return $softaculous_pro['license'];
}

add_filter('softaculous_pro_products', 'softaculous_softwp_pro_products', 10, 1);
function softaculous_softwp_pro_products($r = []){
	$r['softwp'] = 'softwp';
	return $r;
}

// Load Softaculous rebranding settings
function softaculous_pro_rebranding(){
	
	global $softaculous_pro;
	
	$softaculous_pro['branding']['sn'] = 'SoftWP';
	$softaculous_pro['branding']['logo_url'] = SOFTACULOUS_PRO_PLUGIN_URL.'assets/images/logo-white.png';
	$softaculous_pro['branding']['rebranded'] = 0;

	//Getting info if Softaculous rebranding done or not?
	$soft_rebranding = get_option('softaculous_pro_rebranding', '[]');
	
	if(!empty($soft_rebranding['logo_url'])){
		$softaculous_pro['branding']['logo_url'] = $soft_rebranding['logo_url'];
	}
	
	if(!empty($soft_rebranding['sn']) && $soft_rebranding['sn'] != 'Softaculous'){
		$softaculous_pro['branding']['sn'] = $soft_rebranding['sn'];
		$softaculous_pro['branding']['rebranded'] = 1;
	}
	
	if(!empty($soft_rebranding['default_hf_bg'])){
		$softaculous_pro['branding']['default_hf_bg'] = $soft_rebranding['default_hf_bg'];
	}
	
	if(!empty($soft_rebranding['default_hf_text'])){
		$softaculous_pro['branding']['default_hf_text'] = $soft_rebranding['default_hf_text'];
	}
	
	return true;
}

// Add our license key if ANY
function softaculous_pro_updater_filter_args($queryArgs) {
	
	global $softaculous_pro;
	
	if ( !empty($softaculous_pro['license']['license']) ) {
		$queryArgs['license'] = $softaculous_pro['license']['license'];
	}
	
	return $queryArgs;
}

// Handle the Check for update link and ask to install license key
function softaculous_pro_updater_check_link($final_link){
	
	global $softaculous_pro;
	
	if(empty($softaculous_pro['license']['license'])){
		return '<a href="'.admin_url('admin.php?page=assistant&act=license').'">'.__('Enter Pro License Key', 'softaculous-pro').'</a>';
	}
	
	return $final_link;
}

function softaculous_pro_report_error($error = array()) {
	
	if(empty($error)){
		return true;
	}
	
	$error_string = '<b>' . esc_html__('Please fix the below error(s):', 'softaculous-pro') . '</b><br />';
	
	foreach($error as $ev){
		$error_string .= '* ' . esc_html($ev) . '<br />';
	}
	
	echo '<div id="message" class="error"><p>' . $error_string . '</p></div>';
}

function softaculous_pro_add_plugin_row_links($links, $slug) {

	if(is_multisite() && is_network_admin()){
		return $links;
	}

	if ($slug !== SOFTACULOUS_PRO_BASE) {
		return $links;
	}

	if(!current_user_can('activate_plugins')){
		return $links;
	}
	
	$new_links = array(
		'plugins' => '<a href="admin.php?page=assistant&act=manage-plugins"><font style="color:green;">'.__('Explore Pro Plugins', 'softaculous-pro').'</font></a>',
		'tours' => '<a href="admin.php?page=assistant#tours">'.__('Tour', 'softaculous-pro').'</a>',
		'ai' => '<a href="admin.php?page=assistant#ai"><font style="color:green;">'.__('AI', 'softaculous-pro').'</font></a>',
	);

	$links = array_merge($links, $new_links);

	return $links;
}

function softaculous_pro_add_params($link){
	
	global $softaculous_pro;
	
	$link = rtrim($link, '?&');

	$query = parse_url($link, PHP_URL_QUERY);

	if ($query) {
		$link .= '&';
	} else {
		$link .= '?';
	}

	$link .= 'version=latest&license='.$softaculous_pro['license']['license'].'&url='.site_url();
	
	return $link;
}

function softaculous_pro_register_post_type(){
	register_post_type(
		'spro_ai_history',
		[
			'labels' => [
				'name' => __('AI History', 'softaculous-pro'),
				'singular_name' => __('AI History', 'softaculous-pro'),
			],
			'public' => false,
			'map_meta_cap' => true,
			'hierarchical' => false,
			'rewrite' => false,
			'query_var' => false,
			'can_export' => false,
			'delete_with_user' => true,
			'supports' => array('author'),
		]
	);
}
PK�f\���bbcustomizer-controls.phpnu�[���<?php

//////////////////////////////////////////////////////////////
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date:	   23rd Jan 2017
// Time:	   23:00 hrs
// Site:	   http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////

// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
	exit('Hacking Attempt !');
}

/**
 * Override customize controls class
 *
 */
class Pagelayer_Customize_Control extends WP_Customize_Control{
	
	public $show_filter = '';
	public $li_class = '';
	
	/**
	 * Refresh the parameters passed to the JavaScript via JSON.
	 *
	 * @see WP_Customize_Control::to_json()
	 */
	public function to_json() {

		parent::to_json();
		
		if(!empty($this->show_filter)){
			$this->json['show_filter'] = $this->show_filter;
		}
	}
	
	protected function render() {
		$id    = 'customize-control-' . str_replace( array( '[', ']' ), array( '-', '' ), $this->id );
		$class = 'pagelayer-customize-control customize-control customize-control-' . $this->type;
		
		$class .= ' '.$this->li_class;

		printf( '<li id="%s" class="%s">', esc_attr( $id ), esc_attr( $class ) );
		$this->render_content();
		echo '</li>';
	}
}

/**
 * Padding control to separate general and style controls
 *
 */
class Pagelayer_Padding_Control extends Pagelayer_Customize_Control {
		
	/**
	 * The type of control being rendered
	 */
	public $type = 'pagelayer-padding-control';
	public $responsive;
	public $units;
	
	/**
	 * Constructor
	 */
	public function __construct( $manager, $id, $args = array(), $options = array() ) {
		parent::__construct( $manager, $id, $args );
		
	}

	/**
	 * Render the control in the customizer
	 */
	public function render_content() {
		
		$units = (array) $this->units;
		
		// Output the label and description if they were passed in.
		if ( isset( $this->label ) && '' !== $this->label ) {
			echo '<span class="customize-control-title pagelayer-customize-control-title">' . sanitize_text_field( $this->label );
			
			if(!empty($this->responsive )){
				echo '<span class="pagelayer-devices">
					<button type="button" class="active-device" aria-pressed="true" data-device="desktop">
					<i class="dashicons dashicons-desktop"></i>
					</button>
					<button type="button"aria-pressed="false" data-device="tablet">
					<i class="dashicons dashicons-tablet"></i>
					</button>
					<button type="button" aria-pressed="false" data-device="mobile">
					<i class="dashicons dashicons-smartphone"></i>
					</button>
				</span>';
			}
			
			if(!empty($units)){
				?>
				<span class="pagelayer-units">
					<input type="hidden" class="pagelayer-unit-input" value="<?php echo esc_attr($this->value('unit')); ?>" <?php $this->link('unit'); ?>></input>
					<?php 
					foreach($units as $unit){
						echo '<span data-unit="'.$unit.'"> '.$unit.' </span>';
					}
					?>
				</span>
				<?php
			}
				
			echo '</span>';
		}
		
		$settings = array();
		
		foreach ( $this->settings as $key => $setting ){
			$key = str_replace(['_mobile', '_tablet'], '', $key);
			
			if(in_array($key, $settings)){
				continue;
			}
			
			$settings[] = $key;
		}		
		
		$screens = array('');
		
		if(!empty($this->responsive)){
			$screens = array('', '_tablet', '_mobile');
		}
		
		echo '<div class="pagelayer-paddings-holder">';
		
		foreach($screens as $screen){
			
			$show_device = '';
			if(count($screens) > 1){
				$show_device =  'data-show-device="'.(empty($screen) ? '_desktop' : $screen).'"';
			}
			
			echo '<div class="pagelayer-control-padding" '.$show_device.'>';
			foreach($settings as $setting){
				
				// Skip units for responsive
				if($setting == 'unit'){
					continue;
				}
				
				$setting_name = $setting.$screen;
	?>
		<input type="number" class="pagelayer-padding-input" value="<?php echo esc_attr($this->value($setting_name)); ?>" <?php $this->link($setting_name); ?>></input>
	<?php
			}
			
			echo '<i class="dashicons dashicons-admin-links"></i></div>';
		}
		
		echo '</div>';
	}
}

/**
 * Typography control controls
 *
 */
class Pagelayer_typo_Control extends Pagelayer_Customize_Control {
		
	/**
	 * The type of control being rendered
	 */
	public $type = 'pagelayer-typo-control';
	public $responsive;
	public $style;
	
	/**
	 * Constructor
	 */
	public function __construct( $manager, $id, $args = array(), $options = array() ) {
		parent::__construct( $manager, $id, $args );
	}
	
	/**
	 * Render the control in the customizer
	 */
	public function render_content() {
		global $pagelayer;
		 
		// Output the label and description if they were passed in.
		if ( isset( $this->label ) && '' !== $this->label ) {
			echo '<span class="customize-control-title">' . sanitize_text_field( $this->label ) .'</span>';
		}
		
		$settings = $pagelayer->font_settings;
		
		echo '<div class="pagelayer-typography-holder">';			
			
			$global_font = $this->value('global-font');
			
			if(!empty($global_font) && !isset($pagelayer->global_fonts[$global_font])){
				$global_font = 'primary';
			}
				
			echo '<div class="pagelayer-control-typography">';
	?>
	<div class="pagelayer-control-typo-holder <?php echo (!empty($global_font) ? 'pagelayer-global-on' : ''); ?>">
		<div class="pagelayer-control-typo-icons-holder">
			<span class="pagelayer-control-typo-icon dashicons dashicons-edit"></span>
		</div>
		<div class="pagelayer-control-typo">
			<div class="pagelayer-global-setting-font">
				<b><?php _e('Global Fonts'); ?></b>
				<span class="pagelayer-control-global-typo-icon dashicons dashicons-admin-site-alt3"></span>
				<span class="dashicons dashicons-admin-generic"></span>
				<input class="pagelayer-global-font-input" type="hidden" <?php $this->link('global-font'); ?> value="<?php echo esc_attr($global_font); ?>" data-key="<?php echo esc_attr($global_font); ?>">
				
				<div class="pagelayer-global-font-list"></div>		
			</div>		
			<?php foreach($settings as $sk => $sval){ ?>
				<div class="pagelayer-control-typo-fields">
					<label class="pagelayer-control-typo-fields-label"><?php echo $sval['label']?>
					<?php 
					$screens = array('');
					if(!empty($sval['responsive'])){
						
						$screens = array('desktop', 'tablet', 'mobile');
						
						?>
						<span class="pagelayer-devices">
							<button type="button" class="active-device" aria-pressed="true" data-device="desktop">
							<i class="dashicons dashicons-desktop"></i>
							</button>
							<button type="button"aria-pressed="false" data-device="tablet">
							<i class="dashicons dashicons-tablet"></i>
							</button>
							<button type="button" aria-pressed="false" data-device="mobile">
							<i class="dashicons dashicons-smartphone"></i>
							</button>
						</span>
					<?php } ?>
					<span class="pagelayer-typo-global-default dashicons dashicons-undo" title="<?php _e('Restore Global'); ?>"></span>
					</label>
					<?php
					foreach($screens as $screen){
		
						$show_device = '';
						$field_name = $sk;
						
						if(count($screens) > 1){
							$show_device = 'data-show-device="_'.$screen.'"';
							$field_name = $sk.($screen == 'desktop' ? '' : '_'.$screen);
						}
						
						$field_val = esc_attr($this->value($field_name));
						
						if(isset($sval['choices'])){ ?>
							
							<select name="<?php echo $field_name; ?>" <?php $this->link($field_name); ?> data-font-key="<?php echo $sk;?>" data-default-value="<?php echo $field_val; ?>" <?php echo $show_device; ?>>
								<?php
								// This add using js
								//echo pagelayer_create_font_options($sval['choices'], $this->value($field_name));
								?>
							</select>
						<?php } else { ?>
							<input name="<?php echo $field_name; ?>" type="number" <?php $this->link($field_name); ?> <?php echo $show_device; ?>>
						<?php } 
					}
					?>
				</div>
			<?php }?>
		</div>
	</div>
		<?php			
		echo '</div></div>';
	}
}

/**
 * Alpha Color Picker Custom Control
 *
 * @author Braad Martin <http://braadmartin.com>
 * @license http://www.gnu.org/licenses/gpl-3.0.html
 * @link https://github.com/BraadMartin/components/tree/master/customizer/alpha-color-picker
 */
class Pagelayer_Customize_Alpha_Color_Control extends Pagelayer_Customize_Control {
	/**
	 * The type of control being rendered
	 */
	public $type = 'pagelayer-alpha-color';
	/**
	 * Add support for palettes to be passed in.
	 *
	 * Supported palette values are true, false, or an array of RGBa and Hex colors.
	 */
	public $palette;
	/**
	 * Add support for showing the opacity value on the slider handle.
	 */
	public $show_opacity;
	/**
	 * Enqueue our scripts and styles
	 */
	public function enqueue() {
		wp_enqueue_script( 'wp-color-picker' );
		wp_enqueue_style( 'wp-color-picker' );
	}
	/**
	 * Render the control in the customizer
	 */
	public function render_content() {
		global $pagelayer;
		
		$setvalue = $this->value();
		
		// Process the palette
		if ( is_array( $this->palette ) ) {
			$palette = implode( '|', $this->palette );
		} else {
			// Default to true.
			$palette = ( false === $this->palette || 'false' === $this->palette ) ? 'false' : 'true';
		}

		// Support passing show_opacity as string or boolean. Default to true.
		$show_opacity = ( false === $this->show_opacity || 'false' === $this->show_opacity ) ? 'false' : 'true';

		// Output the label and description if they were passed in.
		if ( isset( $this->label ) && '' !== $this->label ) {
			echo '<span class="customize-control-title">' . sanitize_text_field( $this->label ) . '</span>';
		}
		if ( isset( $this->description ) && '' !== $this->description ) {
			echo '<span class="description pagelayer-customize-description">' . sanitize_text_field( $this->description ) . '</span>';
		} ?>
		
			<span class="pagelayer-control-global-color-icon dashicons dashicons-admin-site-alt3"></span>
			<div class="pagelayer-global-color-list">
			<div class="pagelayer-global-setting-color">
			<b>Global Colors</b>
			<span class="dashicons dashicons-admin-generic"></span></div>
			<?php
				$gkey = '';
				if( !empty($setvalue) && $setvalue[0] == '$'){
					$gkey = substr($setvalue, 1);
					$gkey = isset($pagelayer->global_colors[$gkey]) ? $gkey : 'primary';
				}
				
				foreach($pagelayer->global_colors as $cid => $color){
				
				$active_class = '';
				if($cid == $gkey){
					$active_class = 'pagelayer-global-selected';
				}
			?>
				<div class="pagelayer-global-color-list-item <?php echo $active_class; ?>" data-global-id="<?php echo $cid; ?>">
					<span class="pagelayer-global-color-pre" style="background:<?php echo $color['value']; ?>;"></span>
					<span class="pagelayer-global-color-title"><?php echo $color['title'];?></span>
					<span class="pagelayer-global-color-code"><?php echo $color['value']; ?></span>
				</div>
			<?php }?>
			</div>
			<input class="pagelayer-alpha-color-control" type="text" data-show-opacity="<?php echo $show_opacity; ?>" data-palette="<?php echo esc_attr( $palette ); ?>" data-default-color="<?php echo esc_attr( $this->settings['default']->default ); ?>" <?php $this->link(); ?>  />
		<?php

	}
}

// Global color palette control
class Pagelayer_Color_Repeater_Control extends Pagelayer_Customize_Control {
	/**
	 * The type of control being rendered
	 */
	public $type = 'pagelayer-alpha-color';
	/**
	 * Button labels
	 */
	public $button_label = '';
	/**
	 * Constructor
	 */
	public function __construct( $manager, $id, $args = array(), $options = array() ) {
		parent::__construct( $manager, $id, $args );
		
		if(empty($this->button_label)){
			$this->button_label = __( 'Add New Color', 'pagelayer' );
		}
	}
	
	/**
	 * Render the control in the customizer
	 */
	public function render_content() {
		
		$values = $this->value();
		
		$decode_values = json_decode($values, true);
		
		$skip_keys = array('primary', 'secondary', 'text', 'accent');
	?>
	  <div class="pagelayer-color-palette-control">
			<?php if( !empty( $this->label ) ) { ?>
				<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
			<?php } ?>
			<?php if( !empty( $this->description ) ) { ?>
				<span class="customize-control-description"><?php echo esc_html( $this->description ); ?></span>
			<?php } ?>
			<input type="hidden" class="pagelayer-color-palette-data" <?php $this->link(); ?>>			
			<?php
			foreach( $decode_values as $kk => $val){ ?>
			
			<div class="pagelayer-color-holder">
				<span class="pagelayer-color-title" contenteditable="true"><?php _e($val['title']); ?></span>
				<span class="pagelayer-color-controls <?php echo (in_array($kk, $skip_keys)? 'pagelayer-prevent-delete' : ''); ?>">
					<?php echo esc_attr($val['value']) ?> 
				</span>
				<?php if(!in_array($kk, $skip_keys)){ ?>
					<span class="customize-control-color-repeater-delete"><span class="dashicons dashicons-no-alt"></span></span>
				<?php }?>
				<input class="pagelayer-alpha-color-control" type="text" data-show-opacity="true" data-palette="true" data-default-color="<?php echo esc_attr($val['value']); ?>" data-id="<?php echo esc_attr($kk); ?>"  data-title="<?php echo esc_attr($val['title']); ?>" value="<?php echo esc_attr($val['value']); ?>" />
			</div>
			
			<?php }?>
			<button class="button customize-control-color-repeater-add" type="button"><?php echo $this->button_label; ?></button>
		</div>
	<?php
	}
}

// Global color palette control
class Pagelayer_Font_Repeater_Control extends Pagelayer_Customize_Control {
	/**
	 * The type of control being rendered
	 */
	public $type = 'pagelayer-global-font';
	/**
	 * Button labels
	 */
	public $button_label = '';
	
	/**
	 * Constructor
	 */
	public function __construct( $manager, $id, $args = array(), $options = array() ) {
		parent::__construct( $manager, $id, $args );
		
		if(empty($this->button_label)){
			$this->button_label = __( 'Add New Font', 'pagelayer' );
		}
	}
	
	/**
	 * Render the control in the customizer
	 */
	public function render_content() {
		global $pagelayer;
		
		$values = $this->value();
		
		$decode_values = (array) json_decode($values, true);
		
		$settings = $pagelayer->font_settings;
		
		$skip_keys = array('primary', 'secondary', 'text', 'accent');
	?>
	  <div class="pagelayer-font-palette-control">
			<?php if( !empty( $this->label ) ) { ?>
				<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
			<?php } ?>
			<?php if( !empty( $this->description ) ) { ?>
				<span class="customize-control-description"><?php echo esc_html( $this->description ); ?></span>
			<?php } ?>
			<input type="hidden" class="pagelayer-font-palette-data" <?php $this->link(); ?>>			
			<?php
			foreach( $decode_values as $kk => $val){ ?>
			
			<div class="pagelayer-font-holder" data-id="<?php echo $kk; ?>">
				<span class="pagelayer-font-title" contenteditable="true"><?php _e($val['title']); ?></span>
				<?php if(!in_array($kk, $skip_keys)){ ?>
					<span class="customize-control-font-repeater-delete"><span class="dashicons dashicons-no-alt"></span></span>
				<?php }?>
				
				<!-- Font Start -->
				<div class="pagelayer-control-typo-holder">
					<span class="pagelayer-control-typo-icon dashicons dashicons-edit"></span>
					<div class="pagelayer-control-typo">
					
					<?php foreach($settings as $sk => $sval){ ?>
						<div class="pagelayer-control-typo-fields">
							<label class="pagelayer-control-typo-fields-label"><?php echo $sval['label']?>
							
							<?php 
							$screens = array('');
							if(!empty($sval['responsive'])){
								
								$screens = array('desktop', 'tablet', 'mobile');
								
								?>
								<span class="pagelayer-devices">
									<button type="button" class="active-device" aria-pressed="true" data-device="desktop">
									<i class="dashicons dashicons-desktop"></i>
									</button>
									<button type="button"aria-pressed="false" data-device="tablet">
									<i class="dashicons dashicons-tablet"></i>
									</button>
									<button type="button" aria-pressed="false" data-device="mobile">
									<i class="dashicons dashicons-smartphone"></i>
									</button>
								</span>
							<?php } ?>
							</label>
							
							<?php
						foreach($screens as $screen){
		
							$show_device = '';
							$field_name = $sk;
							$field_val = (empty($val['value'][$sk]) ? '' : $val['value'][$sk]);
							
							if(count($screens) > 1){
								$field_name = $sk.'['.$screen.']';
								$show_device = 'data-show-device="_'.$screen.'"';
								
								if(is_array($field_val)){
									$field_val = (empty($field_val[$screen]) ? '' : $field_val[$screen]);
								}
							}
							
							if(isset($sval['choices'])){ ?>
								<select name="<?php echo $field_name; ?>" data-font-key="<?php echo $sk;?>" data-default-value="<?php  echo $field_val; ?>" <?php echo $show_device;?>>
									<?php
									// This add using js
									//echo pagelayer_create_font_options($sval['choices'], $val['value'][$sk]);
									?>
								</select>
							<?php } else { ?>
								<input type="number" name="<?php echo $field_name; ?>" value="<?php  echo $field_val; ?>" <?php echo $show_device;?>>
							<?php 
							}
						}
						?>
						</div>
					<?php } ?>
						
					</div>
				</div>
				<!-- Font End -->
			</div>
			
			<?php }?>
			<button class="button customize-control-font-repeater-add" type="button"><?php echo $this->button_label; ?></button>
		</div>
	<?php
	}
}

/**
 * Customize control
 *
 */
class Pagelayer_Custom_Control extends Pagelayer_Customize_Control {
		
	/**
	 * The type of control being rendered
	 */
	public $type = 'pagelayer-customize-control';
	public $responsive;
	public $units;

	/**
	 * Constructor
	 */
	public function __construct( $manager, $id, $args = array(), $options = array() ) {
		parent::__construct( $manager, $id, $args );
	}

	/**
	 * Render the control in the customizer
	 */
	public function render_content() {
		
		$units = $this->units;
		$input_id         = '_customize-input-' . $this->id;
		$description_id   = '_customize-description-' . $this->id;
		$describedby_attr = ( ! empty( $this->description ) ) ? ' aria-describedby="' . esc_attr( $description_id ) . '" ' : '';
		switch ( $this->type ) {
			case 'checkbox':
				?>
				<span class="pagelayer-customize-inside-control-row">
					<label for="<?php echo esc_attr( $input_id ); ?>"><?php echo esc_html( $this->label ); ?></label>
					<input
						id="<?php echo esc_attr( $input_id ); ?>"
						class="pagelayer-customize-checkbox"
						<?php echo $describedby_attr; ?>
						type="checkbox"
						value="<?php echo esc_attr( $this->value() ); ?>"
						<?php $this->link(); ?>
						<?php checked( $this->value() ); ?>
					/>
					<?php if ( ! empty( $this->description ) ) : ?>
						<span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span>
					<?php endif; ?>
				</span>
				<?php
				break;
			case 'radio':
				if ( empty( $this->choices ) ) {
					return;
				}

				$name = '_customize-radio-' . $this->id;
				?>
				<?php if ( ! empty( $this->label ) ) : ?>
					<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
				<?php endif; ?>
				<?php if ( ! empty( $this->description ) ) : ?>
					<span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span>
				<?php endif; ?>
				<span class="pagelayer-customize-inside-control-row">
				<?php foreach ( $this->choices as $value => $label ) : ?>
					
						<input
							id="<?php echo esc_attr( $input_id . '-radio-' . $value ); ?>"
							class="pagelayer-customize-radio"
							type="radio"
							<?php echo $describedby_attr; ?>
							value="<?php echo esc_attr( $value ); ?>"
							name="<?php echo esc_attr( $name ); ?>"
							<?php $this->link(); ?>
							<?php checked( $this->value(), $value ); ?>
							data-label="<?php echo esc_html( $label ); ?>"
							/>
				<?php endforeach; ?>
				</span>
				<?php
				break;
			case 'divider':
				echo '<hr class="pagelayer-customize-divider">';
				break;
			case 'pl_slider':
			?>
				<div class="pagelayer-slider-custom-control">
					<span class="customize-control-title"><?php echo esc_html( $this->label ); ?>
					<?php if(!empty($this->responsive )){?>
						<span class="pagelayer-devices">
							<button type="button" class="active-device" aria-pressed="true" data-device="desktop">
							<i class="dashicons dashicons-desktop"></i>
							</button>
							<button type="button"aria-pressed="false" data-device="tablet">
							<i class="dashicons dashicons-tablet"></i>
							</button>
							<button type="button" aria-pressed="false" data-device="mobile">
							<i class="dashicons dashicons-smartphone"></i>
							</button>
						</span>
					<?php } ?>
					</span>
					<?php 
						if(!empty($units)){
					?>
						<span class="pagelayer-units">
							<input type="hidden" class="pagelayer-unit-input" value="<?php echo esc_attr($this->value('unit')); ?>" <?php $this->link('unit'); ?>></input>
							<?php 
							foreach($units as $unit){
								echo '<span data-unit="'.$unit.'"> '.$unit.' </span>';
							}
							?>
						</span>
					<?php }
					
						$screens = array('');
						$set_link = 'slider';
		
						if(!empty($this->responsive)){
							$screens = array('desktop' => '_desktop', 'tablet' => '_tablet', 'mobile' => '_mobile');
						}
										
						foreach($screens as $screen => $_screen){
							
							$show_device = empty($_screen)? '' : 'data-show-device="'.$_screen.'"';
							
							echo '<div class="pagelayer-control-typography" '.$show_device.'>';
					?>
						<input class="pagelayer-slider" type="range" min="<?php echo esc_attr( $this->input_attrs['min'] ); ?>" max="<?php echo esc_attr( $this->input_attrs['max'] ); ?>" step="<?php echo esc_attr( $this->input_attrs['step'] ); ?>" value="<?php echo esc_attr( $this->value($set_link.$_screen) ); ?>" />
						<input type="number" id="<?php echo esc_attr( $this->id ); ?>" name="<?php echo esc_attr( $this->id ); ?>" value="<?php echo esc_attr( $this->value($set_link.$_screen) ); ?>" class="customize-control-slider-value" <?php $this->link($set_link.$_screen); ?> min="<?php echo esc_attr( $this->input_attrs['min'] ); ?>" max="<?php echo esc_attr( $this->input_attrs['max'] ); ?>" step="<?php echo esc_attr( $this->input_attrs['step'] ); ?>"/>
					
						</div>
						<?php } ?>
				</div>
			<?php
				break;
		}
	}
}

/**
 * Switch sanitization
 *
 * @param  string   Switch value
 * @return integer	Sanitized value
 */
if ( ! function_exists( 'pagelayer_switch_sanitization' ) ) {
	function pagelayer_switch_sanitization( $input ) {
		if ( true === $input ) {
			return 1;
		} else {
			return 0;
		}
	}
}

/**
 * Alpha Color (Hex & RGBa) sanitization
 *
 * @param  string	Input to be sanitized
 * @return string	Sanitized input
 */
if ( ! function_exists( 'pagelayer_hex_rgba_sanitization' ) ) {
	function pagelayer_hex_rgba_sanitization( $input, $setting ) {
		if ( empty( $input ) || is_array( $input ) ) {
			return $setting->default;
		}

		if ( false === strpos( $input, 'rgba' ) ) {
			// If string doesn't start with 'rgba' then santize as hex color
			$input = sanitize_hex_color( $input );
		} else {
			// Sanitize as RGBa color
			$input = str_replace( ' ', '', $input );
			sscanf( $input, 'rgba(%d,%d,%d,%f)', $red, $green, $blue, $alpha );
			$input = 'rgba(' . pagelayer_in_range( $red, 0, 255 ) . ',' . pagelayer_in_range( $green, 0, 255 ) . ',' . pagelayer_in_range( $blue, 0, 255 ) . ',' . pagelayer_in_range( $alpha, 0, 1 ) . ')';
		}
		return $input;
	}
}

/**
 * Only allow values between a certain minimum & maxmium range
 *
 * @param  number	Input to be sanitized
 * @return number	Sanitized input
 */
if ( ! function_exists( 'pagelayer_in_range' ) ) {
	function pagelayer_in_range( $input, $min, $max ){
		if ( $input < $min ) {
			$input = $min;
		}
		if ( $input > $max ) {
			$input = $max;
		}
		return $input;
	}
}

// Create font options
function pagelayer_create_font_options( $args, $set ){
	$options = '';
	foreach( $args as $value => $label ){
		$_value = $value;
		
		if(is_numeric($value)){
			$_value = $label;
		}
		
		// Single item
		if(is_string($label)){
			$options .= pagelayer_sel_option( $_value, $label, $set);
			continue;
		}
		if( $value == 'default'){
			$options .= pagelayer_sel_option( '', $value, $set);
			continue;
		}
		
		$options .= '<optgroup label="'. $value .'">';
		$options .= pagelayer_create_font_options($label,  $set);
		$options .= '</optgroup>';
	}
	
	return $options;
}
PK�f\~y�Y�Ywoocommerce.phpnu�[���<?php

//////////////////////////////////////////////////////////////
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date:	   23rd Jan 2017
// Time:	   23:00 hrs
// Site:	   http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////

// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
	exit('Hacking Attempt !');
}

add_action( 'wp', 'pagelayer_wc_customization' );
function pagelayer_wc_customization(){
	
	$options = pagelayer_get_customize_options();
	
	if(!empty($options['woo_disable_cross_sells'])){
		remove_action( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display' );
	}
	
	if(is_product()){
		// Disable Breadcrumb.
		if(!empty($options['woo_disable_breadcrumb'])){
			remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
		}
	}

	// Checkout customization
	if(!is_checkout()){
		return;
	}
		
	// Disable order notes.
	if(!empty( $options['woo_disable_order_note'] )){
		add_filter( 'woocommerce_enable_order_notes_field', '__return_false' );
	}
	
	// Disable coupon.
	if(!empty( $options['woo_disable_coupon_field'] )){
		remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
	}
}

add_filter('wp_nav_menu_items', 'pagelayer_add_woo_cart', 10, 2);
add_filter('wp_page_menu', 'pagelayer_add_woo_cart', 10, 2);
function pagelayer_add_woo_cart($items, $args) {
		
	$menu_id = isset($args->menu->term_id) ? $args->menu->term_id : '';
	$locations = get_nav_menu_locations();
	
	//pagelayer_print($locations);
	if(empty($locations) || !isset($locations['primary']) || $locations['primary'] != $menu_id) {
		return $items;
	}
	
	$options = pagelayer_get_customize_options();
	
	if(!empty($options['woo_enable_menu_cart'])) {
		$items .= '<li class="page-item pagelayer-menu-cart cart-customlocation menu-item menu-item-type-post_type menu-item-object-page"><a href=""><span class="dashicons dashicons-cart"></span><sup></sup></a></li>';
	}
	
	return $items;
}

add_action( 'customize_controls_print_scripts', 'pagelayer_wc_add_scripts'  );
function pagelayer_wc_add_scripts(){
?>
<script>

// Script to load Shop page when user click woocommerce customizer
jQuery( function( $ ) {
	wp.customize.panel( 'pgl_woocommerce', function( panel ) {
		panel.expanded.bind( function( isExpanded ) {
			if ( isExpanded ) {
				wp.customize.previewer.previewUrl.set( "<?php echo esc_js( wc_get_page_permalink( 'shop' ) ); ?>" );
			}
		} );
	} );
	wp.customize.section( 'pgl_woo_cart_page', function( section ) {
		section.expanded.bind( function( isExpanded ) {
			if( isExpanded ){
				wp.customize.previewer.previewUrl.set( "<?php echo esc_js( wc_get_page_permalink( 'cart' ) ); ?>" );
			}
		} );
	} );
	wp.customize.section( 'pgl_woo_checkout', function( section ) {
		section.expanded.bind( function( isExpanded ) {
			if ( isExpanded ) {
				wp.customize.previewer.previewUrl.set( "<?php echo esc_js( wc_get_page_permalink( 'checkout' ) ); ?>" );
			}
		} );
	} );
	wp.customize.section( 'pgl_woo_myaccount_page', function( section ) {
		section.expanded.bind( function( isExpanded ) {
			if ( isExpanded ) {
				wp.customize.previewer.previewUrl.set( "<?php echo esc_js( wc_get_page_permalink( 'myaccount' ) ); ?>" );
			}
		} );
	} );
	wp.customize.section( 'pgl_woo_product_catalog', function( section ) {
		section.expanded.bind( function( isExpanded ) {
			if ( isExpanded ) {
				wp.customize.previewer.previewUrl.set( "<?php echo esc_js( wc_get_page_permalink( 'shop' ) ); ?>" );
			}
		} );
	} );
	wp.customize.section( 'pgl_woo_general', function( section ) {
		section.expanded.bind( function( isExpanded ) {
			if ( isExpanded ) {
				wp.customize.previewer.previewUrl.set( "<?php echo esc_js( wc_get_page_permalink( 'shop' ) ); ?>" );
			}
		} );
	} );
});
</script>
<?php
}
function pagelayer_parse_customize_styles($val, $rule, $unit = 'px'){
	
	$parse = str_replace(array('{{val}}', '{{color}}', '{{unit}}'), array($val, pagelayer_sanitize_global_color($val), $unit), $rule);
	$parse = rtrim( trim($parse), ';' );
	
	return $parse;
}

add_action( 'wp_head', 'pagelayer_woocommerce_styles', 1000 );
function pagelayer_woocommerce_styles(){
	global $pagelayer;
	
	// Get the option defaults
	$options = pagelayer_get_customize_options();
	$modes = array('desktop', 'tablet', 'mobile');
	$css = array();
	
	$woo_styles = array(
		'woo_notice_bg_color' => array(
			'.woocommerce-store-notice.demo_store' => 'background-color: {{color}}',
		),
		'woo_notice_color' => array(
			'.woocommerce-store-notice.demo_store' => 'color: {{color}}',
		),
		'woo_notice_a_color' => array(
			'.woocommerce-store-notice.demo_store a' => 'color: {{color}}',
		),
		'woo_notice_a_hover_color' => array(
			'.woocommerce-store-notice.demo_store a:hover' => 'color: {{color}}',
		),
		'woo_myaccount_padding' => array(
			'body.woocommerce-account main.site-main' => array(
				'top' => 'padding-top: {{val}}{{unit}};',
				'right' => 'padding-right: {{val}}{{unit}};',
				'bottom' => 'padding-bottom: {{val}}{{unit}};',
				'left' => 'padding-left: {{val}}{{unit}};'
			)
		),
		'woo_checkout_padding' => array(
			'body.woocommerce-checkout main.site-main' => array(
				'top' => 'padding-top: {{val}}{{unit}};',
				'right' => 'padding-right: {{val}}{{unit}};',
				'bottom' => 'padding-bottom: {{val}}{{unit}};',
				'left' => 'padding-left: {{val}}{{unit}};'
			)
		),
		'woo_cart_padding' => array(
			'body.woocommerce-cart main.site-main' => array(
				'top' => 'padding-top: {{val}}{{unit}};',
				'right' => 'padding-right: {{val}}{{unit}};',
				'bottom' => 'padding-bottom: {{val}}{{unit}};',
				'left' => 'padding-left: {{val}}{{unit}};'
			)
		),
		'woo_product_padding' => array(
			'body.single-product main.site-main' => array(
				'top' => 'padding-top: {{val}}{{unit}};',
				'right' => 'padding-right: {{val}}{{unit}};',
				'bottom' => 'padding-bottom: {{val}}{{unit}};',
				'left' => 'padding-left: {{val}}{{unit}};'
			)
		),
		'woo_product_cat_padding' => array(
			'body.post-type-archive-product .site-main' => array(
				'top' => 'padding-top: {{val}}{{unit}};',
				'right' => 'padding-right: {{val}}{{unit}};',
				'bottom' => 'padding-bottom: {{val}}{{unit}};',
				'left' => 'padding-left: {{val}}{{unit}};'
			)
		),
		'woo_menu_cart_color' => array(
			'li.cart-customlocation span.dashicons-cart' => 'color: {{color}};',
		),
		'woo_menu_cart_number_color' => array(
			'li.cart-customlocation span.dashicons-cart + sup' => 'color: {{color}};',
		)
	);
	
	$woo_styles = apply_filters('pagelayer_wc_styles_array', $woo_styles);

	// Apply customizer css
	foreach($woo_styles as $key => $rules){
		
		$value = pagelayer_isset($options, $key);
		
		if(empty($value) && $value != '0'){
			continue;
		}
		
		foreach($rules as $sel => $rule){
			
			// Is not reponsive or not variable value?
			if(!is_array($value)){
				$css['desktop'][$sel][] = pagelayer_parse_customize_styles($value, $rule);
				continue;
			}
			
			// If unit exists
			$unit = !empty($value['unit'])? $value['unit'] : 'px';
			
			// Parse in array if responsive rule in string
			$rule = (array) $rule;
			
			foreach($rule as $kk => $_rule){
				
				// Is not reponsive or not variable value?
				if(isset($value[$kk]) && !is_array($value[$kk])){
					
					if(empty($value[$kk]) && $value[$kk] != '0'){
						continue;
					}
					
					$css['desktop'][$sel][] = pagelayer_parse_customize_styles($value[$kk], $_rule, $unit);					
				}
				
				foreach($modes as $mode){
					
					// First level responsive key
					if(isset($value[$mode])){
						
						// Responsive without variable
						$mode_val = is_numeric($kk) ? $value[$mode] : $value[$mode][$kk] ;
							
						if(empty($mode_val) && $mode_val != '0'){
							continue;
						}
						
						$css[$mode][$sel][] = pagelayer_parse_customize_styles($mode_val, $_rule, $unit);
						
						// We are already in responsive mode
						continue;						
					}
					
					// Second level responsive key like font size
					if(!isset($value[$kk][$mode]) || empty($value[$kk][$mode]) && $value[$kk][$mode] != '0'){
						continue;
					}
					
					$css[$mode][$sel][] = pagelayer_parse_customize_styles($value[$kk][$mode], $_rule, $unit);
				}
			}
		}
	}
	
	// Create css
	$screen_css = array('desktop' => '', 'tablet' => '', 'mobile' => '');
	foreach($css as $mode => $_css){
		foreach($_css as $selector => $val){
			$parsr_style = $selector.'{'.implode(';', $val)."}\n";
			$screen_css[$mode] .= $parsr_style;
		}
	}
	
	$styles = '<style id="pagelayer-woocommerce-styles" type="text/css">'.PHP_EOL;
	$styles .= $screen_css['desktop'];
	
	if(!empty($screen_css['woo_product_image_width'])){
		$styles .= '@media(min-width: 902px) {.woocommerce #content div.product div.images, .woocommerce div.product div.images, .woocommerce-page #content div.product div.images, .woocommerce-page div.product div.images{
			width: '.$options['woo_product_image_width'].'% !important;
		}
		.woocommerce #content div.product div.summary, .woocommerce div.product div.summary, .woocommerce-page #content div.product div.summary, .woocommerce-page div.product div.summary{
			width: calc(96% - '.$options['woo_product_image_width'].'%) !important;
		}}';
	}
	
	if(!empty($screen_css['tablet'])){
		$styles .= '@media(max-width: ' . $pagelayer->settings['tablet_breakpoint'] . 'px) {'.$screen_css['tablet'].'}'.PHP_EOL;
	}
	
	if(!empty($screen_css['mobile'])){
		$styles .= '@media(max-width: ' . $pagelayer->settings['mobile_breakpoint'] . 'px) {'.$screen_css['mobile'].'}';
	}
	
	$styles .= '</style>';
	
	echo $styles;
}

// Get Option Values
function pagelayer_get_customize_options(){
	return get_option('pagelayer_customizer_options', array());
}

add_action( 'customize_register', 'pagelayer_woo_customize_register', 11 );
function pagelayer_woo_customize_register( $wp_customize ) {
	
	//Pagelayer + WooCommerce Panel
	$wp_customize->add_panel( 'pgl_woocommerce', array(
		'priority'       => 10,
		'title'          => __('Pagelayer + WooCommerce'),
	) );
	
	// Add Store Notice Section
	$wp_customize->get_section( 'woocommerce_store_notice' )->description = '<strong><a href="customize.php?autofocus[section]=pgl_woo_store_notice">'.__('Click here') .'</a> '. __('to change color scheme of store notice') .'</strong>';
			
	// Add Store Notice Section
	$wp_customize->add_section( 'pgl_woo_store_notice', array(
			'panel'    => 'pgl_woocommerce',
			'priority' => 1,
			'title' => __('Store Notice'),
			'description' => '<strong><a href="customize.php?autofocus[section]=woocommerce_store_notice">'.__('Click here') .'</a> '. __('to enable the store notice') .'</strong>',
		)
	);
	
	// Adds Customizer settings
	$wp_customize->add_setting( 'pagelayer_customizer_options[woo_notice_bg_color]', array(
			'type' => 'option',
			'capability' => 'edit_theme_options',
			'transport' => 'refresh',
		)
	);
	
	$wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control( $wp_customize, 'pagelayer_customizer_options[woo_notice_bg_color]', array(
			'label' => __('Background Color'),
			'section' => 'pgl_woo_store_notice',
			'priority' => 1
		) )
	);
	
	// Adds Customizer settings
	$wp_customize->add_setting( 'pagelayer_customizer_options[woo_notice_color]', array(
			'type' => 'option',
			'capability' => 'edit_theme_options',
			'transport' => 'refresh',
		)
	);
	
	$wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control( $wp_customize, 'pagelayer_customizer_options[woo_notice_color]', array(
			'label' => __('Text Color'),
			'section' => 'pgl_woo_store_notice',
			'priority' => 1
		) )
	);	
	
	// Adds Customizer settings
	$wp_customize->add_setting( 'pagelayer_customizer_options[woo_notice_a_color]', array(
			'type' => 'option',
			'capability' => 'edit_theme_options',
			'transport' => 'refresh',
		)
	);
	
	$wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control( $wp_customize, 'pagelayer_customizer_options[woo_notice_a_color]', array(
			'label' => __('Link Color'),
			'section' => 'pgl_woo_store_notice',
			'priority' => 1
		) )
	);	
	
	// Adds Customizer settings
	$wp_customize->add_setting( 'pagelayer_customizer_options[woo_notice_a_hover_color]', array(
			'type' => 'option',
			'capability' => 'edit_theme_options',
			'transport' => 'refresh',
		)
	);
	
	$wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control( $wp_customize, 'pagelayer_customizer_options[woo_notice_a_hover_color]', array(
			'label' => __('Link Hover Color'),
			'section' => 'pgl_woo_store_notice',
			'priority' => 1
		) )
	);	
	
	// Add Store Notice Section
	$wp_customize->add_section( 'pgl_woo_general', array(
			'panel'    => 'pgl_woocommerce',
			'title' => __('General'),
			'priority' => 2,
		)
	);
	
	// Adds Customizer settings
	$wp_customize->add_setting( 'pagelayer_customizer_options[woo_star_rating_color]', array(
			'type' => 'option',
			'capability' => 'edit_theme_options',
			'transport' => 'refresh',
		)
	);
	
	$wp_customize->add_setting( 'pagelayer_lable_menu_cart', array(
		'capability' => 'edit_theme_options',
	));

	$wp_customize->add_control( new Pagelayer_Customize_Control(
		$wp_customize, 'pagelayer_lable_menu_cart', array(
			'type' => 'hidden',
			'section' => 'pgl_woo_general',
			'description' => __('<div class="pagelayer-customize-heading"><div>Cart Icon on Menu</div></div>', 'pagelayer'),
			'li_class' => 'pagelayer-accordion-tab',
			'priority' => 9
		)
	));
	
	// Adds Customizer settings
	$wp_customize->add_setting( 'pagelayer_customizer_options[woo_enable_menu_cart]', array(
			'type' => 'option',
			'capability' => 'edit_theme_options',
			'transport' => 'refresh',
		)
	);
	
	$wp_customize->add_control( new Pagelayer_Custom_Control( $wp_customize, 'pagelayer_customizer_options[woo_enable_menu_cart]', array(
			'type' => 'checkbox',
			'label' => __('Show Cart Icon On Primary Menu'),
			'section' => 'pgl_woo_general',
			'priority' => 9
		))
	);
	
	// Adds Customizer settings
	$wp_customize->add_setting( 'pagelayer_customizer_options[woo_menu_cart_color]', array(
			'type' => 'option',
			'capability' => 'edit_theme_options',
			'transport' => 'refresh'
		)
	);
	
	$wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control( $wp_customize, 'pagelayer_customizer_options[woo_menu_cart_color]', array(
			'label' => __('Icon Color'),
			'section' => 'pgl_woo_general',
			'priority' => 10,
		) )
	);
	
	// Adds Customizer settings
	$wp_customize->add_setting( 'pagelayer_customizer_options[woo_menu_cart_number_color]', array(
			'type' => 'option',
			'capability' => 'edit_theme_options',
			'transport' => 'refresh'
		)
	);
	
	$wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control( $wp_customize, 'pagelayer_customizer_options[woo_menu_cart_number_color]', array(
			'label' => __('Cart Numbers Color'),
			'section' => 'pgl_woo_general',
			'priority' => 10,
		) )
	);
	
	// Shop Page Section
	$wp_customize->add_section( 'pgl_woo_product_catalog', array(
			'panel'    => 'pgl_woocommerce',
			'title' => __('Product Catalog'),
			'priority' => 4,
		)
	);
	
	// Register the WooCommerce Default Padding
	pagelayer_register_padding_customizer_control($wp_customize, array(
		'control' => 'pagelayer_customizer_options',
		'control_array_sufix' => 'woo_product_cat_padding',
		'section' => 'pgl_woo_product_catalog',
		'label' => __( 'Padding', 'pagelayer' ),
		'capability' => 'edit_theme_options',
		'setting_type' => 'option',
		'transport' => 'refresh',
		'default' => '',
		'units' => ['px', 'em', '%'],
		'responsive' => 1,
		'priority' => 1
	), true);
	
	// Single Product Page Sections
	$wp_customize->add_section( 'pgl_woo_single_product', array(
			'panel'    => 'pgl_woocommerce',
			'title' => __('Single Product'),
			'priority' => 5,
		)
	);
	
	// Register the WooCommerce single page Padding
	pagelayer_register_padding_customizer_control($wp_customize, array(
		'control' => 'pagelayer_customizer_options',
		'control_array_sufix' => 'woo_product_padding',
		'section' => 'pgl_woo_single_product',
		'label' => __( 'Padding', 'pagelayer' ),
		'capability' => 'edit_theme_options',
		'setting_type' => 'option',
		'transport' => 'refresh',
		'default' => '',
		'units' => ['px', 'em', '%'],
		'responsive' => 1,
		'priority' => 1
	), true);
	
	// Single Product Page Breadcrumb Enabler
	$wp_customize->add_setting( 'pagelayer_customizer_options[woo_disable_breadcrumb]', array(
			'type' => 'option',
			'capability' => 'edit_theme_options',
			'transport' => 'refresh',						
		)
	);
	
	$wp_customize->add_control( new Pagelayer_Custom_Control( $wp_customize, 'pagelayer_customizer_options[woo_disable_breadcrumb]', array(
			'type' => 'checkbox',
			'label' => __('Disable Breadcrumb'),
			'section' => 'pgl_woo_single_product',
			'priority' => 5
		))
	);
	
	// Cart page settings
	$wp_customize->add_section( 'pgl_woo_cart_page', array(
			'panel'    => 'pgl_woocommerce',
			'title' => __('Cart'),
			'priority' => 7,
		)
	);
	
	pagelayer_register_padding_customizer_control($wp_customize, array(
		'control' => 'pagelayer_customizer_options',
		'control_array_sufix' => 'woo_cart_padding',
		'section' => 'pgl_woo_cart_page',
		'label' => __( 'Padding', 'pagelayer' ),
		'capability' => 'edit_theme_options',
		'setting_type' => 'option',
		'transport' => 'refresh',
		'default' => '',
		'units' => ['px', 'em', '%'],
		'responsive' => 1,
		'priority' => 1
	), true);
	
	// cross-sells disable
	$wp_customize->add_setting( 'pagelayer_customizer_options[woo_disable_cross_sells]', array(
			'type' => 'option',
			'capability' => 'edit_theme_options',
			'transport' => 'refresh',						
		)
	);
	
	$wp_customize->add_control( new Pagelayer_Custom_Control( $wp_customize,  'pagelayer_customizer_options[woo_disable_cross_sells]', array(
			'type' => 'checkbox',
			'label' => __('Disable Cross-sells'),
			'section' => 'pgl_woo_cart_page',
			'priority' => 2
		))
	);
	
	// Checkout Page Section
	$wp_customize->add_section( 'pgl_woo_checkout', array(
			'panel'    => 'pgl_woocommerce',
			'title' => __('Checkout'),
			'priority' => 9,
		)
	);
	
	// Checkout page settings
	pagelayer_register_padding_customizer_control($wp_customize, array(
		'control' => 'pagelayer_customizer_options',
		'control_array_sufix' => 'woo_checkout_padding',
		'section' => 'pgl_woo_checkout',
		'label' => __( 'Padding', 'pagelayer' ),
		'capability' => 'edit_theme_options',
		'setting_type' => 'option',
		'transport' => 'refresh',
		'default' => '',
		'units' => ['px', 'em', '%'],
		'responsive' => 1,
		'priority' => 1
	), true);
	
	$wp_customize->add_setting( 'pagelayer_customizer_options[woo_disable_order_note]', array(
			'type' => 'option',
			'capability' => 'edit_theme_options',
			'transport' => 'refresh',						
		)
	);
	
	$wp_customize->add_control( new Pagelayer_Custom_Control( $wp_customize, 'pagelayer_customizer_options[woo_disable_order_note]', array(
			'type' => 'checkbox',
			'label' => __('Disable Order Note'),
			'section' => 'pgl_woo_checkout',
			'priority' => 2
		))
	);
	
	$wp_customize->add_setting( 'pagelayer_customizer_options[woo_disable_coupon_field]', array(
			'type' => 'option',
			'capability' => 'edit_theme_options',
			'transport' => 'refresh',						
		)
	);
	
	$wp_customize->add_control( new Pagelayer_Custom_Control( $wp_customize, 'pagelayer_customizer_options[woo_disable_coupon_field]', array(
			'type' => 'checkbox',
			'label' => __('Disable Coupon Field'),
			'section' => 'pgl_woo_checkout',
			'priority' => 3
		))
	);
	
	// My Account Page Section
	$wp_customize->add_section( 'pgl_woo_myaccount_page', array(
			'panel'    => 'pgl_woocommerce',
			'title' => __('My Account'),
			'priority' => 10,
		)
	);
	
	// My Account page settings
	pagelayer_register_padding_customizer_control($wp_customize, array(
		'control' => 'pagelayer_customizer_options',
		'control_array_sufix' => 'woo_myaccount_padding',
		'section' => 'pgl_woo_myaccount_page',
		'label' => __( 'Padding', 'pagelayer' ),
		'capability' => 'edit_theme_options',
		'setting_type' => 'option',
		'transport' => 'refresh',
		'default' => '',
		'units' => ['px', 'em', '%'],
		'responsive' => 1,
		'priority' => 1
	), true);
}

// Get product
function pagelayer_get_product(){
	
	$_product = wc_get_product();
	
	if(!empty($_product)){
		return $_product;
	}
	
	$post = $GLOBALS['post'];
	
	if( !wp_doing_ajax() && $post->post_type != 'pagelayer-template'){
		return false;
	}
	
	$products = get_posts([
		'post_type' => 'product',
		'numberposts' => '1',
	]);
	
	if(empty($products)){
		return false;
	}
	
	$_product = wc_get_product($products[0]->ID);
	
	return $_product;
}

// Load Product configurations to edit the product template
add_action( 'template_redirect', 'pagelayer_load_product_template');
function pagelayer_load_product_template($post = []){
	global $pagelayer, $product;
	
	if(!$post){
		$post = $GLOBALS['post'];
	}
	
	if(!class_exists('woocommerce') || empty($post->post_type) || $post->post_type != 'pagelayer-template' || !isset($pagelayer->builder['singular_templates']['Products']) ){
		return false;
	}
	
	$products = array_keys($pagelayer->builder['singular_templates']['Products']);
	$conditions = get_post_meta( $post->ID, 'pagelayer_template_conditions', true );
	
	$is_product_temp = false;
	
	foreach( $conditions as $condi ){				
		if(in_array($condi['sub_template'], $products)){
			$is_product_temp = true;
		}
	}
	
	if(!$is_product_temp){
		return false;
	}
	
	// Add WooCommerce Class to body 
	add_filter('body_class', function($classes){
		$classes[] = 'woocommerce';
		return $classes;
	});
	
	$product = pagelayer_get_product();
	
	//pagelayer_print($product);
	
	wp_enqueue_script( 'wc-single-product' );
	wp_enqueue_style( 'wc-single-product' );
	
	// Load woocomerce css and js
	if ( current_theme_supports( 'wc-product-gallery-zoom' ) ) {
		wp_enqueue_script( 'zoom' );
	}

	if ( current_theme_supports( 'wc-product-gallery-slider' ) ) {
		wp_enqueue_script( 'flexslider' );
	}

	if ( current_theme_supports( 'wc-product-gallery-lightbox' ) ) {
		wp_enqueue_script( 'photoswipe-ui-default' );
		wp_enqueue_style( 'photoswipe-default-skin' );
		add_action( 'wp_footer', 'woocommerce_photoswipe' );
	}
	
	wp_enqueue_style( 'photoswipe' );
	wp_enqueue_style( 'photoswipe-default-skin' );
	wp_enqueue_style( 'photoswipe-default-skin' );
	wp_enqueue_style( 'woocommerce_prettyPhoto_css' );
}

// Apply filter to load extra woocommerce settings
do_action('pagelayer_after_wc_customization');
PK�f\�e_bbparse-shortcodes.phpnu�[���<?php

//////////////////////////////////////////////////////////////
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date:	   23rd Jan 2017
// Time:	   23:00 hrs
// Site:	   http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////

// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
	exit('Hacking Attempt !');
}

function pagelayer_do_shortcode_to_block( $content, $ignore_html = false ) {
	global $shortcode_tags;
	
	if ( false === strpos( $content, '[' ) ) {
		return $content;
	}
	
	// Find all registered tag names in $content.
	preg_match_all( '@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches );
	$tagnames = array_intersect( array_keys( $shortcode_tags ), $matches[1] );

	if( empty( $tagnames ) ){
		return $content;
	}

	$content = do_shortcodes_in_html_tags( $content, $ignore_html, $tagnames );
	
	$pattern = get_shortcode_regex( $tagnames );
	$content = preg_replace_callback( "/$pattern/", 'pagelayer_do_shortcode_tag', $content );
	
	return $content;
}

function pagelayer_do_shortcode_tag($m){
	
	// Allow [[foo]] syntax for escaping a tag.
	if ( '[' === $m[1] && ']' === $m[6] ) {
		return substr( $m[0], 1, -1 );
	}

	$tag  = $m[2];
	$attr = shortcode_parse_atts( $m[3] );
	$content = isset( $m[5] ) ? $m[5] : null;

	$output = $m[1] . pagelayer_shortcode_to_block( $attr, $content, $tag ) . $m[6];
	
	return $output;
}

function pagelayer_shortcode_to_block($attr, $content, $tag){
	
	if($tag == 'pl_post_props'){
		return '';
	}
	
	if($tag == 'pl_inner_col'){
		$tag = 'pl_col';
	}
	
	if($tag == 'pl_inner_row'){
		$tag = 'pl_row';
	}
	
	$block_name = 'pagelayer/'.str_replace('_', '-', $tag);
	
	$func = 'pagelayer_fix_block_'.$tag;
	
	// Is there a function of the tag ?
	if(function_exists($func)){
		call_user_func_array($func, array(&$block_name, &$attr, &$content));
	}
	
	$content = pagelayer_do_shortcode_to_block($content);
	
	return get_comment_delimited_block_content( $block_name, $attr, $content );
}

function pagelayer_fix_block_pl_accordion_item(&$block_name, &$attr, &$content){
	
	if(pagelayer_has_blocks($content) || false !== strpos( $content, '[pl_' )){
		return;
	}
	
	pagelayer_content_to_block($content);
}

function pagelayer_content_to_block(&$content){

	$content = '<!-- '.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl-row {"stretch":"auto"} -->
<!-- '.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl-col {"overlay_hover_delay":"400"} -->
<!-- '.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl-text -->'.$content.'<!-- /'.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl-text -->
<!-- /'.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl-col -->
<!-- /'.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl-row -->';
}PK�f\X�Ն;�;
blocks.phpnu�[���<?php

//////////////////////////////////////////////////////////////
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date:	   23rd Jan 2017
// Time:	   23:00 hrs
// Site:	   http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////

// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
	exit('Hacking Attempt !');
}

if( version_compare( get_bloginfo( 'version' ), '5.8', '>=' ) ){
	add_filter( 'block_categories_all', 'pagelayer_block_category', 999999999);
}else{
	add_filter( 'block_categories', 'pagelayer_block_category', 999999999 );
}

function pagelayer_block_category( $categories ) {
	
	// Create a custom category and add it at the beginning of the list
	array_unshift($categories, array(
		'slug'  => 'pagelayer',
		'title' => 'Pagelayer',
	));

	return $categories;
}

function pagelayer_block_name_by_tag($tag){
	return 'pagelayer/' . str_replace('_', '-', $tag);
}

add_action('template_redirect', 'pagelayer_block_init');
function pagelayer_block_init(){
	global $pagelayer;
	
	// Not load for gutenberg
	if(!function_exists('register_block_type') || !pagelayer_has_blocks() || pagelayer_is_gutenberg_editor()){
		return;
	}
	
	// Load shortcodes
	pagelayer_load_shortcodes();
	
	$pl_blocks_styles = $pagelayer->styles;

	foreach ($pagelayer->shortcodes as $block => $pl_props) {
		
		// Skip blocks not meant for Gutenberg
		if(!empty($pl_props['no_gt']) || $pl_props['group'] == 'woocommerce'){
			continue;
		}
		
		// Create attribute Object
		$attributes = [];
		$pagelayer_tabs = ['settings', 'options'];

		foreach($pagelayer_tabs as $tab){

			if (empty($pl_props[$tab]) || !is_array($pl_props[$tab])) continue;

			foreach($pl_props[$tab] as $section => $props){
				$props = array_key_exists($section, $pl_props) ? $pl_props[$section] : $pl_blocks_styles[$section];

				// Reset / Create the cache
				foreach($props as $x => $prop){
					$attributes[$x] = [
						'type' => $prop['type']
					];

					if ($prop['type'] === 'image') {
						$attributes['pagelayer-srcset'] = [
							'type' => 'string'
						];
					}

					// Are we to set this value?
					if (isset($prop['default']) && !empty($prop['default'])) {
						$tmp_val = $prop['default'];

						// If there is a unit and there is no unit suffix in atts value
						if(isset($prop['units'])){
							if (is_numeric($tmp_val)) {
								$tmp_val = $tmp_val . $prop['units'][0];
							} else {
								$sep = isset($prop['sep']) ? $prop['sep'] : ',';
								$tmp2 = explode($sep, $tmp_val);
								foreach ($tmp2 as $k => $value) {
									if (is_numeric($value)) {
										$tmp2[$k] = $value . $prop['units'][0];
									}
								}
								$tmp_val = implode($sep, $tmp2);
							}
						}

						$attributes[$x]['default'] = $tmp_val;
					}

					$modes = ['tablet', 'mobile'];

					// Do we have screen?
					if (array_key_exists('screen', $prop)) {
						foreach ($modes as $m) {
							$prop_name = $x . '_' . $m;

							$attributes[$prop_name] = [
								'type' => $prop['type']
							];

							// TODO: 
							// if (array_key_exists('default', $props[$prop_name])) {
							//     $attributes[$prop_name]['default'] = $props[$x]['default'];
							// }
						}
					}
				}
			}
		}
		
		// Register blocks
		register_block_type(
			pagelayer_block_name_by_tag($block),
			array(
				'attributes' => $attributes,
				'render_callback' => 'pagelayer_block_renderer',
			)
		);
	}
}

function pagelayer_block_renderer($attributes, $content, $_this){
	global $pagelayer;
	
	$parsed_block = $_this->parsed_block;
	$block_name = $parsed_block['blockName'];
	$tag = '';
	$inner_blocks = array(
		'blocks' => $parsed_block['innerBlocks'],
		'content' => $parsed_block['innerContent']
	);
	$attributes['is_not_sc'] = 1;
	
	if ( is_string( $block_name ) && 0 === strpos( $block_name, 'pagelayer/' ) ) {
		$tag = substr( $block_name, 10 );
	}
	
	// Convert as pagelayer shortcode
	$tag = str_replace('-', '_', $tag);
		
	if( empty($tag) || !array_key_exists($tag, $pagelayer->shortcodes) ){
		return '';
	}

	return pagelayer_render_shortcode($attributes, $content, $tag, $inner_blocks);
}

add_action('enqueue_block_editor_assets', 'pagelayer_enqueue_block_assets');
function pagelayer_enqueue_block_assets(){
	global $pagelayer;
	
	// For gutenberg
	if(!pagelayer_is_gutenberg_editor()){	
		return;
	}

	wp_enqueue_style( 'pagelayer-block-icon', PAGELAYER_CSS . '/pagelayer-icons.css', array('wp-edit-blocks'), PAGELAYER_VERSION );

	// Load styles and javascript
	pagelayer_enqueue_frontend(true);
	
	wp_enqueue_style( 'pagelayer-block-editor', PAGELAYER_CSS . '/pagelayer-blocks.css', array('wp-edit-blocks'), PAGELAYER_VERSION );
	
	// Components
	wp_enqueue_script( 'pagelayer-blocks', PAGELAYER_JS . '/blocks/index.js', [ 'wp-blob', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-html-entities', 'wp-i18n' ], PAGELAYER_VERSION, true );

	// Load shortcode
	pagelayer_load_shortcodes();
	
	// Load fonts
	pagelayer_load_font_options();
	
	$shortcodes = array();
	
	foreach($pagelayer->shortcodes as $block => $pl_props) {
		
		if(!empty($pl_props['no_gt']) || $pl_props['group'] == 'woocommerce'){
			continue;
		}
		
		$shortcodes[$block] = $pl_props;
	}
	
	wp_localize_script( 'pagelayer-blocks', 'pagelayer_config',
		array( 
			'pagelayer_shortcodes' => $shortcodes,
			'pagelayer_styles' => $pagelayer->styles,
			'pagelayer_groups' => $pagelayer->groups,
			'internal_linking_nonce' => wp_create_nonce('internal-linking'),
			'pagelayer_fonts' =>  $pagelayer->fonts,
		)
	);
}

// Load global JS
add_action( 'admin_print_scripts', 'pagelayer_block_global_js');
function pagelayer_block_global_js(){
	global $pagelayer, $post;
	
	// For gutenberg
	if(!pagelayer_is_gutenberg_editor()){	
		return;
	}
	
	// Load global colors and fonts
	pagelayer_load_global_palette();
		
	$pagelayer_recaptch_lang = get_option('pagelayer_google_captcha_lang');
	$pagelayer_recaptch_version = get_option('pagelayer_recaptcha_version', '');
	
	$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
	
	// Get CAPTCHA site key
	$pagelayer_recaptch_site_key = get_option('pagelayer_google_captcha');
	$pro_url = defined('POPULARFX_PRO_URL') ? POPULARFX_PRO_URL : PAGELAYER_PRO_PRICE_URL;
	$pro_txt = defined('POPULARFX_PRO_URL') ? 'PopularFX Pro' : 'Pagelayer Pro';
	
	echo '<script type="text/javascript" id="pagelayer-block-global-js">
pagelayer_ajax_url = "'.admin_url( 'admin-ajax.php' ).'?";
pagelayer_url = "'.PAGELAYER_URL.'";
pagelayer_ver = "'.PAGELAYER_VERSION.'";
pagelayer_global_nonce = "'.wp_create_nonce('pagelayer_global').'";
pagelayer_server_time = '.time().';
pagelayer_pro = '.(int)defined('PAGELAYER_PREMIUM').';
pagelayer_is_live = 1;
pagelayer_pro_url = "'. $pro_url .'";
pagelayer_pro_txt = "'. $pro_txt .'";
pagelayer_facebook_id = "'.get_option('pagelayer-fbapp-id').'";
pagelayer_settings = '.json_encode($pagelayer->settings).';
pagelayer_recaptch_lang = "'.(!empty($pagelayer_recaptch_lang) ? $pagelayer_recaptch_lang : '').'";
pagelayer_recaptch_version = "'.(!empty($pagelayer_recaptch_version) ? $pagelayer_recaptch_version : '').'";
pagelayer_global_colors = '.json_encode($pagelayer->global_colors).';
pagelayer_global_fonts = '.json_encode($pagelayer->global_fonts).';
pagelayer_ajax_nonce = "'.wp_create_nonce('pagelayer_ajax').'";
pagelayer_post_permalink = "'.get_permalink($post->ID).'";
pagelayer_author = '.json_encode(pagelayer_author_data($post->ID)).';
pagelayer_postID = "'.$post->ID.'";
pagelayer_site_logo = '.json_encode(pagelayer_site_logo()).';
pagelayer_recaptch_site_key = "'.(!empty($pagelayer_recaptch_site_key) ? $pagelayer_recaptch_site_key : '').'";
pagelayer_global_colors = '.json_encode($pagelayer->global_colors).';
pagelayer_global_fonts = '.json_encode($pagelayer->global_fonts).';
pagelayer_loaded_icons =  '.json_encode(pagelayer_enabled_icons()).';
pagelayer_customizer_url = "'.admin_url("/customize.php?return=").urlencode($referer).'";
pagelayerCacheBlockTags = {};
</script>';

		echo '<style id="pagelayer-block-global-style">
@media (min-width: '.($pagelayer->settings['tablet_breakpoint'] + 1).'px){
.pagelayer-hide-desktop{
filter:blur(3px);
}
.pagelayer-hide-desktop *{
filter:blur(2px);
}
}

@media (max-width: '.$pagelayer->settings['tablet_breakpoint'].'px) and (min-width: '.($pagelayer->settings['mobile_breakpoint'] + 1).'px){
.pagelayer-hide-tablet{
filter:blur(3px);
}
.pagelayer-hide-tablet *{
filter:blur(2px);
}
}

@media (max-width: '.$pagelayer->settings['mobile_breakpoint'].'px){
.pagelayer-hide-mobile{
filter:blur(3px);
}

.pagelayer-hide-mobile *{
filter:blur(2px);
}
}
</style>';

}

// Schema for save contact form template via react
add_action( 'init', 'pagelayer_register_metadata' );
function pagelayer_register_metadata() {
	
	register_meta(
		'post',
		'pagelayer_contact_templates',
		array(
			'type' => 'object',
			'description' => 'Contacts Data',
			'single' => true,
			'show_in_rest' => array(
				'schema' => array(
					'additionalProperties' => true,
					'items' => array(
						'type' => 'array',
						'items' => array(
							'type' => 'array',
							'items' => array(
								'type' => 'string',
							),
						),
					),
				),
			),
			'auth_callback' => function() {
				return current_user_can('edit_posts');
			}
		)
	);
	
	register_meta(
		'post',
		'_pagelayer_content',
		array(
			'type' => 'string',
			'description' => 'Menu Content',
			'single' => true,
			'show_in_rest' => true,
			'auth_callback' => function() {
				return current_user_can('edit_posts');
			}
		)
	);
}

add_filter( 'the_post', 'pagelayer_blocks_the_post' );
function pagelayer_blocks_the_post( $post ) {
	
	if(!pagelayer_is_gutenberg_editor() || !has_blocks( $post ) ){
		return;
	}
	
	// call block register
	// It is being used to load the runtime font family
	pagelayer_block_init();
	
    $post->post_content = pagelayer_add_tmp_atts($post->post_content);
}

// Add tmp attribute to block code
function pagelayer_add_tmp_atts($content){
	
	$blocks = parse_blocks( $content );
	$output = '';
	
	foreach ( $blocks as $block ) {
		$block_name = $block['blockName'];
		
		// Is pagelayer block
		if ( is_string( $block_name ) && 0 === strpos( $block_name, 'pagelayer/' ) ) {
			$_block = pagelayer_serialize_block($block);
			$output .= serialize_block($_block);
			continue;
		}
		
		$output .= serialize_block($block);
	}
		
	return $output;
}

function pagelayer_serialize_block($block){
	global $pagelayer;
	
	// Load shortcode
	pagelayer_load_shortcodes();
	
	// If block saved by Pagelayer Editor
	if(in_array( $block['blockName'], ['pagelayer/pl_inner_col', 'pagelayer/pl_inner_row'])){
		$block['blockName'] = str_replace('inner_', '', $block['blockName']);
	}
	
	$tag = substr( $block['blockName'], 10 );
	$pl_tag = str_replace('-', '_', $tag);
	
	if(isset($pagelayer->shortcodes[$pl_tag])){
	
		// Create attribute Object
		$pl_props = $pagelayer->shortcodes[$pl_tag];
		$el = array(
			'atts' => $block['attrs'],
			'tmp' => []
		);

		foreach($pagelayer->tabs as $tab){
			
			if(empty($pl_props[$tab])){
				continue;
			}
			
			foreach($pl_props[$tab] as $section => $_props){
				
				$props = !empty($pl_props[$section]) ? $pl_props[$section] : $pagelayer->styles[$section];
				
				if(empty($props)){
					continue;
				}
				
				// Reset / Create the cache
				foreach($props as $prop => $param){
					
					// No value set
					if(empty($el['atts'][$prop])){
						continue;
					}
				
					// Load any attachment values - This should go on top in the newer version @TODO
					if(in_array($param['type'], ['image', 'video', 'audio', 'media'])){
						$attachment = ($param['type'] == 'image') ? pagelayer_image(@$el['atts'][$prop]) : pagelayer_attachment(@$el['atts'][$prop]);
						
						if(!empty($attachment)){
							foreach($attachment as $k => $v){
								$el['tmp'][$prop.'-'.$k] = $v;
							}						
						}
						
					}
				
					// Load any attachment values - This should go on top in the newer version @TODO
					if($param['type'] == 'multi_image'){
						
						$img_ids = pagelayer_maybe_explode(',', $el['atts'][$prop]);					
						$img_urls = [];
						
						// Make the image URL
						foreach($img_ids as $k => $v){
							$image = pagelayer_image($v);
							$img_urls['i'.$v] = @$image['url'];
						}
						
						$el['tmp'][$prop.'-urls'] = json_encode($img_urls);
					}
					
					// Load permalink values
					if($param['type'] == 'link'){
						
						$link = $el['atts'][$prop];
						
						if( is_array($el['atts'][$prop]) ){
							
							// Link is required for check IF and IF-EXT in html
							if(!isset($el['atts'][$prop]['link']) || strlen(trim($el['atts'][$prop]['link'])) < 1){
								$link = '';
								unset($el['atts'][$prop]);
								continue;
							}
							
							$link = $el['atts'][$prop]['link'];
						}
						
						$el['tmp'][$prop] = pagelayer_permalink($link);
					}
				}
			}
		}
		
		$func = null;
		
		if(substr($pl_tag, 0, 3) == 'pl_'){
			$func = 'pagelayer_sc_block_'.substr($pl_tag, 3);
		}
		
		if(function_exists($func)){
			call_user_func_array($func, array(&$el));
		}
		
		if(!empty($el['tmp'])){
			$_tmp = $el['tmp'];
			$block['attrs']['tmpAtts'] = array_filter($_tmp);
		}
		
		// If block saved by Pagelayer Editor
		if(strpos($block['blockName'], '_') !== false){
			$block['blockName'] = str_replace('_', '-', $block['blockName']);
		}
	}
		
	// This have innerBlocks
	if(!empty($block['innerBlocks'])){
		foreach($block['innerBlocks'] as $key => $inner_block){
			$block['innerBlocks'][$key] = pagelayer_serialize_block($inner_block);
		}
	}
	
	return $block;
}

// TODO: create a seprate file or use all the functions from pagelayer editor files
//Grid Gallery Handler
function pagelayer_sc_block_grid_gallery(&$el){
	
	if(empty($el['atts']['ids'])){
		$el['atts']['ids'] = '';
	}
	
	$ids = pagelayer_maybe_explode(',', $el['atts']['ids']);
	$urls = [];
	$all_urls = [];
	$size = $el['atts']['size'];
	
	// Make the image URL
	foreach($ids as $k => $v){
		
		$image = pagelayer_image($v);
				
		$urls['i'.$v] = @$image['url'];
		$links['i'.$v] = @$image['link'];
		$titles['i'.$v] = @$image['title'];
		$captions['i'.$v] = @$image['caption'];
		
		foreach($image as $kk => $vv){
			$si = strstr($kk, '-url', true);
			if(!empty($si)){
				$all_urls['i'.$v][$si] = $vv;
			}
		}
		
	}
	
	// Make the TMP vars
	if(!empty($urls)){
		$el['tmp']['ids-urls'] = json_encode($urls);
		$el['tmp']['ids-all-urls'] = json_encode($all_urls);
		$el['tmp']['ids-all-links'] = json_encode($links);
		$el['tmp']['ids-all-titles'] = json_encode($titles);
		$el['tmp']['ids-all-captions'] = json_encode($captions);
	}
}PK�f\��;�D�D�template.phpnu�[���<?php

//////////////////////////////////////////////////////////////
//===========================================================
// template.php
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date:       23rd Jan 2017
// Time:       23:00 hrs
// Site:       http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////

// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
	exit('Hacking Attempt !');
}

// Define our array
function pagelayer_builder_array(){

global $pagelayer;

	// Array for custom post type data
	$pagelayer->builder = array(
		'name' => 'pagelayer-template',
		'type_slug' => 'pagelayer_template_type',
		'type'=> [
			'' => __('Select'),
			'header' => __('Header'),
			'footer' => __('Footer'),
			'single' => array(
				'label' => __('Single'),
				'need_selection' => 'singular', // To select the value in template select and hide it
			),
			'archive' => array(
				'label' => __('Archive'),
				'need_selection' => 'archives', // To select the value in template select and hide it
			),
			'popup' => __('Popup'),
			'section' => array(
				'label' => __('Section'),
				'no_condition' => 1, // To hide the conditions options
			),
			'global_section' => array(
				'label' => __('Global Section'),
				'no_condition' => 1, // To hide the conditions options
				'hide_drop' => 1,
			),
			'global_widget' => array(
				'label' => __('Global Widget'),
				'no_condition' => 1, // To hide the conditions options
				'hide_drop' => 1,
			),
		],
		'action' => [
			'include' => __('Include'),
			'exclude' => __('Exclude'),
		],
		'dispay_on' => [
			'' => __('Full Site'),
			'archives' => array(
				'label' => __('Archives'),
				'check_conditions' => function ( $args = null ){ 
					return is_archive() || is_home() || is_search();
				},
			),
			'singular' => array(
				'label' => __('Singular'),
				'check_conditions' => function ( $args = null ){
					return ( is_singular() && ! is_embed() ) || is_404();
				},
			),
		],
		// NOTE: Templates list array name should be dispay_on name with suffix _templates
		'archives_templates'=> [ 
			'' => __('All Archives / Posts Archive'),
			'author' => array(
				'label' => __('Author Archives'),
				'check_conditions' => function ( $args = null ){
					return is_author($args['id']);
				},
				'filter_type' => 'author', // should be (author, taxonomy and post type)
			),
			'date' => array(
				'label' => __('Date Archives'),
				'check_conditions' => function ( $args = null ){
					return is_date();
				},
				'no_id_section' => 1, // ID select section not required
			),
			'search' => array(
				'label' => __('Search Results'),
				'check_conditions' => function ( $args = null ){
					return is_search();
				},
				'no_id_section' => 1, // Id select section not required
			),
		],
		// NOTE: Templates list array name should be dispay_on name with suffix _templates
		'singular_templates'=> [
			'' => __('All Singular'), // singular.php
			'by_author' =>  array(
				'label' => __('By Author'),
				'check_conditions' => function ( $args = null ){
					return is_singular() && get_post_field( 'post_author' ) === $args['id'];
				},
				'filter_type' => 'author',
			),
			'front_page' =>  array(
				'label' => __('Front Page'),
				'check_conditions' => function ( $args = null ){
					return is_front_page();
				},
				'no_id_section' => 1, // Id select section not required
			),
			'404' => array(
				'label' => __('404'),
				'check_conditions' => function ( $args = null ){
					return is_404();
				},
				'no_id_section' => 1, // Id select section not required
			),
			//'direct_child_of' =>  __('Direct Child Of'),
			//'any_child_of' =>  __('Any Child Of'),
		], // conditions by post type
		
	);
	
	add_shortcode($pagelayer->builder['name'], 'pagelayer_builder_posts_shortcode');
	
	add_filter( 'manage_'. $pagelayer->builder['name'] .'_posts_columns', 'pagelayer_builder_add_columns' );
	
	add_action( 'manage_'. $pagelayer->builder['name'] .'_posts_custom_column' , 'pagelayer_builder_columns', 10, 2 );
	
	add_filter( 'views_edit-' . $pagelayer->builder['name'], 'pagelayer_builder_template_tabs' );

}

// Create template builder conditions for singular by post type
function pagelayer_builder_singular_conditions($post_types = []){
	$condition = [];
	
	if(empty($post_types)){
		$post_types = pagelayer_get_public_post_types();
		//unset( $post_types['product'] ); // WooCommerce related
		$post_types['attachment'] = get_post_type_object( 'attachment' )->label;
	}
	
	foreach ( $post_types as $post_type => $label ) {
		//$post_type_object = get_post_type_object( $post_type );
		
		if(array_key_exists($label, $condition)){
			continue;
		}
		
		$condition[$label] = [ //TC: Need to change the name of variable 
			$post_type =>  array(
				'label' => $label,
				'check_conditions' => function ( $args = null ) use ($post_type){
					if ( isset($args['id']) && !empty($args['id']) ) {
						$id = (int) $args['id'];
						if ( $id ) {
							return is_singular($post_type) && get_queried_object_id() === $id;
						}
					}

					return is_singular( $post_type );
				},
				'filter_type' => 'post',
				'object_type' => $post_type,
			),
		];
			
		$taxonomies = get_object_taxonomies( $post_type, 'objects' );
		$post_taxonomies = wp_filter_object_list( $taxonomies, [
			'public' => true,
			'show_in_nav_menus' => true,
		] );
		
		foreach ( $post_taxonomies as $slug => $object ) {
			
			$condition[$label] += [
				$object->name =>  array(
					'label' => sprintf( __( 'In %s' ), $object->labels->singular_name ),
					'check_conditions' => function ( $args = null ) use ($object){
						return is_singular() && has_term( (int) $args['id'], $object->name );
					},
					'filter_type' => 'taxonomy',
					'object_type' => $object->name,
				),
			];
			
			if ( $object->hierarchical ) {
				$condition[$label] += [
					'in_' . $object->name . '_children' =>  array(
						'label' => sprintf( __( 'In Child %s' ), $object->labels->name ),
						'check_conditions' => function ( $args = null ) use ($object){
							$id = (int) $args['id'];
							if ( ! is_singular() || ! $id ) {
								return false;
							}
							$child_terms = get_term_children( $id, $object->name );

							return ! empty( $child_terms ) && has_term( $child_terms, $object->name );
						},
						'filter_type' => 'taxonomy',
						'object_type' => $object->name,
					),
				];
			}

		}

		$condition[$label] += [
			$object->name . '_by_author' =>  array(
				'label' => sprintf( __( '%s By Author' ), $label ),
				'check_conditions' => function ( $args = null ) use ($post_type){
					return is_singular($post_type) && get_post_field( 'post_author' ) === $args['id'];
				},
				'filter_type' => 'author',
				'object_type' => $post_type . '_by_author',
			),
		];

	}
	
	return $condition;
}

// Create template builder conditions for archives by  post type
function pagelayer_builder_archives_conditions($post_types = []){
	
	$condition = [];
	
	if(empty($post_types)){
		$post_types = pagelayer_get_public_post_types();
		//unset( $post_types['product'] );
	}
	
	foreach ( $post_types as $post_type => $label ) {
		
		//$post_type_object = get_post_type_object( $post_type );
		if ( ! get_post_type_archive_link( $post_type ) ) {
			continue;
		}
		
		$condition[$label] = [ //TC: Need to change the name of variable 
			$post_type =>  array(
				'label' => $label,
				'check_conditions' => function ( $args = null ) use ($post_type){
					return is_post_type_archive( $post_type ) || ( 'post' === $post_type && is_home() );
				},
				'no_id_section' => 1, // Id select section not required
			),
		];
			
		$taxonomies = get_object_taxonomies( $post_type, 'objects' );
		$post_taxonomies = wp_filter_object_list( $taxonomies, [
			'public' => true,
			'show_in_nav_menus' => true,
		] );
		
		foreach ( $post_taxonomies as $slug => $object ) {
			
			$condition[$label] += [
				$object->name =>  array(
					'label' => sprintf( __( '%s' ), $object->label ),
					'check_conditions' => function ( $args = null ) use ($object){
						$taxonomy = $object->name;
						$id = (int) $args['id'];

						if ( 'category' === $taxonomy ) {
							return is_category( $id );
						}

						if ( 'post_tag' === $taxonomy ) {
							return is_tag( $id );
						}

						return is_tax( $taxonomy, $id );
					},
					'filter_type' => 'taxonomy',
					'object_type' => $object->name,
				),
			];

		}
		
		$all = 'pagelayer_all_'.$post_type;
		
		$condition[$label] += [
			$all => array(
				'label' => 'All '.$label.' Archive',
				'check_conditions' => function ( $args = null ) use ($post_type, $condition, $all, $label){
					
					foreach($condition[$label] as $k => $v){
						if($all == $k){
							continue;
						}
						
						$ret = $v['check_conditions']($args);
						
						if(!empty($ret)){
							return $ret;
						}
						
					}
					
				},
				'no_id_section' => 1, // Id select section not required
			),
		];

	}
	
	return $condition;
}

// Handle the links for the add URL
add_action('admin_head', 'pagelayer_builder_admin_head', 9999);
function pagelayer_builder_admin_head(){
	global $pagelayer, $post_type;
	
	if(!isset($pagelayer->builder) || $post_type != $pagelayer->builder['name']){
		return;
	}
	
	
		echo '<script type="text/javascript">

jQuery(document).ready(function(){
	var but = jQuery(".page-title-action");
	
	if(but.length < 1){
		return;
	}
	
	but.attr("href", "'.esc_url(admin_url('admin.php?page=pagelayer_template_wizard')).'");
	
	var export_but = jQuery(but[0].outerHTML);
	export_but.html("'.__pl('export_template').'");
	export_but.addClass("pagelayer-temp-export-but");
	export_but.attr("href", "'.esc_url(admin_url('admin.php?page=pagelayer_template_export')).'");
	//console.log(export_but[0].outerHTML);
	
	but.after(export_but);
});

</script>';
	
}

// This function will handle the Template Builder pages in Pagelayer 
add_action('init', 'pagelayer_builder_post_type', 9999);
function pagelayer_builder_post_type() {
	global $pagelayer;
	
	if(!isset($pagelayer->builder)){
		return;
	}
	
	// Add Template Post Supports
	$supports = array(
		'title', // post title
		'editor', // post content
		'author', // post author
		'custom-fields', // custom fields
		'revisions', // post revisions
	);
	
	// Add Template Post lables
	$labels = array(
		'name' => _x('Pagelayer Templates', 'plural'),
		'singular_name' => _x('Pagelayer Template', 'singular'),
		'menu_name' => _x('Pagelayer Templates', 'admin menu'),
		'name_admin_bar' => _x('Pagelayer Templates', 'admin bar'),
		'add_new' => _x('Add New', 'add templates'),
		'add_new_item' => __('Add New'),
		'new_item' => __('New Template'),
		'edit_item' => __('Edit Template'),
		'view_item' => __('View Template'),
		'all_items' => __('All Templates'),
		'search_items' => __('Search Templates'),
		'not_found' => __('No Pagelayer templates found'),
	);
		
	$args = array(
		'supports' => $supports,
		'labels' => $labels,
		'menu_icon' => PAGELAYER_URL.'/images/pagelayer-logo-19.png',
		'public' => true,
		'show_in_menu' => false,
		'publicly_queryable' => true,
		'query_var' => true,
		'rewrite' => false,
		'has_archive' => true,
		'hierarchical' => false,
		'exclude_from_search' => true,		
	);
	
	// Register custom post type
	register_post_type($pagelayer->builder['name'] , $args);
	
	// Add any other templates as well
	$pagelayer->builder['archives_templates'] += pagelayer_builder_archives_conditions();	
	$pagelayer->builder['singular_templates'] += pagelayer_builder_singular_conditions();
	
}

// Register shortcode for custom post type
function pagelayer_builder_posts_shortcode($atts){

	global $pagelayer;
	
	// If id not exist
	if( !isset($atts['id']) ){return '';}
	
	// Get the post data
	$post = get_post((int) $atts['id']);
	
	// If post is not empty
	if(empty($post) || $post->post_type != 'pagelayer-template' || ($post->post_status === 'private' && !current_user_can('read_private_posts'))){
		return '';
	}	
	
	$cached_editable = $pagelayer->dont_make_editable;
	$pagelayer->dont_make_editable = true;
	$content = $post->post_content;
	$content = apply_filters( 'the_content', $content );
	$pagelayer->dont_make_editable = $cached_editable;
	
	return $content;
		
}

// Handle edit link of the post type
add_filter('get_edit_post_link', 'pagelayer_builder_edit_link', 1000, 3);
function pagelayer_builder_edit_link($link, $postID, $context){
	global $pagelayer;

	$post = get_post($postID);

	if($post->post_type != $pagelayer->builder['name']){
		return $link;
	}
	
	return admin_url('admin.php?page=pagelayer_template_wizard&post='.$post->ID);

}

// Handle row actions for pagelayer-template
add_filter('post_row_actions', 'pagelayer_builder_row_actions', 10, 2);
function pagelayer_builder_row_actions($actions, $post){
	global $pagelayer;
	
	if($post->post_type != $pagelayer->builder['name']){
		return $actions;
	}
	
	$actions['pagelayer'] = '<a href="'.esc_url( pagelayer_shortlink($post->ID).'&pagelayer-live=1' ).'">'.__pl('edit_using').'</a>';

	return $actions;
}

// Add the custom columns to the pagelayer-template post type:
function pagelayer_builder_add_columns($columns) {
	
	// unset for re-setup
	unset( $columns['taxonomy-pagelayer_template_type'] );
	
	$offset = 2;
	$type = array(
		'pagelayer_template_type' => __( 'Type' ),
		'pagelayer_template_conditions' => __( 'Display On' ),
		'pagelayer_template_shortcode' => __( 'Shortcode' )
	);
	
	// Add the $type array in 2 position of $columns;
	$columns = array_slice( $columns, 0, $offset, true ) + $type  + array_slice( $columns, $offset, null, true );

	//print_r($columns);die();

	return $columns;
	
}

// Add the data to the custom columns for the pagelayer-template post type:
function pagelayer_builder_columns( $column, $post_id ) {
	global $pagelayer;
	
	switch ( $column ) {
		case 'pagelayer_template_type' :
			$type = get_post_meta( $post_id, 'pagelayer_template_type', true );
			
			if(!empty($type)){
				$type = pagelayer_multi_array_search($pagelayer->builder['type'], $type);
						
				if(is_array($type) && array_key_exists('label', $type)){
					$type = $type['label'];
				}
				
				echo '<span>' . $type . '</span>';
			}else{
				echo __('None');
			}
			
		break;
		
		case 'pagelayer_template_conditions' :
			$dis_conditions = get_post_meta( $post_id, 'pagelayer_template_conditions', true );
			if( !empty($dis_conditions) && is_array($dis_conditions)){
				$dis_html = '';
				foreach($dis_conditions as $condi){
					$dis_html .= '<span>';
					
					if(isset($condi['template'])){
						$template = pagelayer_multi_array_search($pagelayer->builder['dispay_on'], $condi['template']);
						
						if(is_array($template) && array_key_exists('label', $template)){
							$template = $template['label'];
						}
						
						$dis_html .= $template;
					}
					
					if(isset($condi['sub_template'])){
						$sub_template = pagelayer_multi_array_search($pagelayer->builder[$condi['template'].'_templates'], $condi['sub_template']);
						
						if(is_array($sub_template) && array_key_exists('label', $sub_template)){
							$sub_template = $sub_template['label'];
						}
						
						if(!empty($sub_template)){
							$dis_html .= ' > '. $sub_template;
						}
					}
					
					if(!empty($condi['id'])){
						$dis_html .= ' > #'. $condi['id'];
					}
					
					$dis_html .= '</span></br>';
				}
			}
			
			if(!empty($dis_html)){
				echo  $dis_html;
			}else{
				echo __('None');
			}
			
		break;
		
		case 'pagelayer_template_shortcode' :
			
			echo '[pagelayer-template id="'.$post_id.'"]';
			
		break;
		
	}
}

// Print template tabs.
function pagelayer_builder_template_tabs( $views ) {
	global $pagelayer;
	
	$current_type = '';
	$active_class = ' nav-tab-active';

	if ( ! empty( $_REQUEST[$pagelayer->builder['type_slug']] ) ) {
		$current_type = $_REQUEST[$pagelayer->builder['type_slug']];
		$active_class = '';
	}

	$url_args = [
		'post_type' => $pagelayer->builder['name'],
	];

	$baseurl = add_query_arg( $url_args, admin_url( 'edit.php' ) );

	$template_types = $pagelayer->builder['type'];

	if ( 1 >= count( $template_types ) ) {
		return $views;
	}

	// If any pre define title
	$all_title = ''; 
	if ( ! $all_title ) {
		$all_title = __( 'All' );
	}
	
	echo '<div id="pagelayer-template-tabs-wrapper" class="nav-tab-wrapper" style="margin-bottom:15px">
		<a class="nav-tab'. $active_class .'" href="'. $baseurl .'"> '. $all_title .'</a>';
		
		foreach ( $template_types as $type  => $class_name ) {
			$active_class = '';
			
			// If type is empty
			if( empty($type) ) continue;
			
			if ( $current_type === $type ) {
				$active_class = ' nav-tab-active';
			}

			$type_url = add_query_arg( $pagelayer->builder['type_slug'], $type, $baseurl );
			$type_label = is_array($class_name) && array_key_exists( 'label', $class_name) ? $class_name['label'] : $class_name;

			echo "<a class='nav-tab{$active_class}' href='{$type_url}'>{$type_label}</a>";
		}
		
	echo '</div>';	
	
	return $views;
}

// Add filter for pagelayer template
add_action( 'parse_query', 'pagelayer_builder_query_filter_types' );
function pagelayer_builder_query_filter_types( \WP_Query $query ) {
	global $pagenow, $typenow, $pagelayer;

	if ( ! ('edit.php' === $pagenow && $pagelayer->builder['name'] === $typenow) || ! empty( $query->query_vars['meta_key'] ) ) {
		return;
	}

	if ( empty($_REQUEST[$pagelayer->builder['type_slug']]) ){
		return;
	}
	
	$current_tab = $_REQUEST[$pagelayer->builder['type_slug']];

	$template_types = $pagelayer->builder['type'];
	
	if( !array_key_exists($current_tab , $template_types )){
		return;
	}

	$query->query_vars['meta_key'] = 'pagelayer_template_type';
	$query->query_vars['meta_value'] = $current_tab;
}

// Add the button for choose template type - Remove
add_action('edit_form_after_title', 'pagelayer_builder_editor_button', 11);
function pagelayer_builder_editor_button(){
	
	global $pagelayer, $post;
	
	if($post->post_type != $pagelayer->builder['name']){
		return;
	}
	
	// Get the current screen
	$current_screen = get_current_screen();
	
	// For gutenberg - Add the code in the footer
	if(method_exists($current_screen, 'is_block_editor') && $current_screen->is_block_editor()){
		add_action('admin_footer', 'pagelayer_builder_gutenberg');
		return;
	}

	echo '
<div style="margin-top:15px;display:inline-block;">
	<a href="'.esc_url(admin_url('admin.php?page=pagelayer_template_wizard&post='.$post->ID)).'" class="button button-primary button-large" style="height:auto; padding:6px; font-size:15px;">
		<img src="'.PAGELAYER_URL.'/images/pagelayer-logo-40.png" align="top" width="24" /> <span>'.__('Edit Template Options').'</span>
	</a>
</div>';

}

// For gutenberg editor
function pagelayer_builder_gutenberg(){
	
	global $pagelayer, $post;
	
	echo '
<div id="pagelayer-editor-template-edit" style="margin-left:15px; display:none">
	<a href="'.esc_url(admin_url('admin.php?page=pagelayer_template_wizard&post='.$post->ID)).'" class="button button-primary button-large" style="height:auto; padding:6px; font-size:15px;">
		<img src="'.PAGELAYER_URL.'/images/pagelayer-logo-40.png" align="top" width="24" /> <span>'.__('Edit Template Options').'</span>
	</a>
</div>

<script type="text/javascript">
jQuery(document).ready(function(){
	
	var pagelayer_timer;
	var pagelayer_button = function(){
		var button = jQuery("#pagelayer-editor-template-edit");
		var g = jQuery(".edit-post-header-toolbar");
		if(g.length < 1){
			return;
		}
		button.detach();
		//console.log(button);
		g.append(button);
		button.show();
		clearInterval(pagelayer_timer);
	}
	pagelayer_timer = setInterval(pagelayer_button, 100);
});
</script>';
}

// Load all templates
function pagelayer_builder_load_templates(){
	
	global $pagelayer;
	
	// Load all post types that are pagelayer-template
	$args = [
		'post_type' => $pagelayer->builder['name'],
		'status' => 'publish',
		'meta_key' => 'pagelayer_template_conditions',
		'posts_per_page' => -1 // For get all posts
	];
	
	$query = new WP_Query($args);
	//print_r($query->posts);die();
	
	// Cache the same
	$pagelayer->templates = $query->posts;

}

// Load all our templates
add_action( 'template_redirect', 'pagelayer_builder_template_redirect');
function pagelayer_builder_template_redirect(){
	
	global $pagelayer, $post;
	
	// Load all post types that are pagelayer-template
	pagelayer_builder_load_templates();
	
	// If there is a match for a header
	$pagelayer->template_header = pagelayer_builder_try_to_apply('header');
	
	// Singular style posts
	if ( is_singular() || is_404() ) {
		$pagelayer->template_post = pagelayer_builder_try_to_apply('single');
	
	// Archive style posts
	} elseif ( is_archive() || is_home() || is_search() ) {
		$pagelayer->template_post = pagelayer_builder_try_to_apply('archive');
	}
	
	// If there is a match for a footer
	$pagelayer->template_footer = pagelayer_builder_try_to_apply('footer');
		
	// If the post type is pagelayer-template, then we are viewing i.e. EDITING PAGELAYER
	if(!empty($post) && $post->post_type == $pagelayer->builder['name']){
		
		// Turn on template editor and default it to pagelayer-content
		$pagelayer->template_editor = 'pagelayer-content';
		$pagelayer->template_post = $post->ID;
		
		// The type
		$pagelayer_template_type = get_post_meta($post->ID, 'pagelayer_template_type', true);
		
		// If the type is header
		if( $pagelayer_template_type == 'header' ){
			
			$pagelayer->template_editor = 'pagelayer-header';
			$pagelayer->template_header = $post->ID;// Fill in that we are rendering the header we want to edit
			$pagelayer->template_post = 0;
			$pagelayer->template_footer = 0;
		
		// If the type is footer
		}elseif( $pagelayer_template_type == 'footer' ){
			
			$pagelayer->template_editor = 'pagelayer-footer';
			$pagelayer->template_header = 0;
			$pagelayer->template_post = 0;
			$pagelayer->template_footer = $post->ID;// Fill in that we are rendering the footer we want to edit
			
		}
		
	}
	
	// If there is a match for a popup, get all ids with priority
	$pagelayer->template_popup_ids = pagelayer_builder_try_to_apply('popup', true);
		
	// Return all the posts
	//return $query['posts'];
	
	// Remove the filter first because it was added by 
	remove_filter('template_include', 'pagelayer_template_include', 1000);
	
	// Add the filter again
	add_filter('template_include', 'pagelayer_template_include', 1000, 1);
	
	do_action('pagelayer_builder_template_redirect');

}

// For check which template will be applied
function pagelayer_builder_try_to_apply($type , $return_all = false){
	
	global $pagelayer;
	
	// Get templates id by type
	$ids = pagelayer_builder_template_ids($type);
	$sel_id = pagelayer_template_check_conditons($ids, false, $return_all);
	
	if( !empty($ids) && !empty($sel_id) ){
		return $sel_id;
	}
	
	return false;
	
}

// Get template post ids and conditions by type
function pagelayer_builder_template_ids($type){
	
	global $pagelayer;
	
	// No templates
	if(empty($pagelayer->templates)){
		return [];
	}
	
	// List of templates to return
	$id_list = array();
	foreach($pagelayer->templates as $template){
		
		// The type
		$pagelayer_template_type = get_post_meta($template->ID, 'pagelayer_template_type', true);
		
		if($type == $pagelayer_template_type){
			$id_list[] = $template->ID;
		}
		
	}
	
	return $id_list;
}

add_action('plugins_loaded', 'pagelayer_free_templ_wizards', 1);
function pagelayer_free_templ_wizards(){
// Its Free
if(!defined('PAGELAYER_PREMIUM')){
	
	// Wizard to create / edit templates
	function pagelayer_builder_template_wizard(){
		pagelayer_show_pro_div('Theme Template Creator', 'With the Pagelayer Theme Templates wizard you can create Headers, Footers, Singular, Archives and WooCommerce Templates. It allows you to control each and every aspect of your theme. You can also set conditions for these templates !');
	}
	
	// Wizard to export theme
	function pagelayer_builder_export(){
		pagelayer_show_pro_div('Export Templates', 'With the Pagelayer Export wizard you can export your Headers, Footers, Singular, Archives and WooCommerce Templates. These templates can then be imported in any other WordPress site.');
	}
	
}
}

// Fix the default blog template we insert for woocommerce
function pagelayer_template_product_fix(){

	global $pagelayer;
	
	// Have we already fixed
	$fixed = get_option('pagelayer_template_product_fix');
	if(!empty($fixed)){
		return;
	}
	
	// Make sure we have templates
	pagelayer_builder_load_templates();
	
	
	if(empty($pagelayer->templates)){
		return;
	}
	
	foreach($pagelayer->templates as $k => $v){
		if($v->post_name == 'blog-template'){
			$blog = $v;
		}
	}
		
	if(empty($blog)){
		return;
	}
	
	// Get meta
	$dis_conditions = get_post_meta( $blog->ID, 'pagelayer_template_conditions', true );
	//print_r($dis_conditions);
	
	foreach($dis_conditions as $k => $v){
		if(!empty($v['sub_template']) && $v['sub_template'] == 'pagelayer_all_product'){
			$found = 1;
		}
	}
	//echo $found;return;
	
	// We need to add conditions
	if(empty($found)){
		
		$dis_conditions[] = ['type' => 'exclude',
					'template' => 'archives',
					'sub_template' => 'pagelayer_all_product',
					'id' => ''];
		
		update_post_meta( $blog->ID, 'pagelayer_template_conditions', $dis_conditions );
		
	}
	
	update_option('pagelayer_template_product_fix', time());
	
}

// Pagelayer Template Loading Mechanism
add_action('setup_theme', 'pagelayer_template_setup_theme', 5);
function pagelayer_template_setup_theme(){
	
	global $pagelayer;
	
	//$theme = wp_get_theme();	
	//$theme_tags = $theme->get('Tags');
	//print_r($theme);
	//echo $theme->get('Tags').' Get option';
	
	$theme_dir = get_stylesheet_directory();
	$conf = $theme_dir.'/pagelayer.conf';
	//echo get_template_directory();
	
	// Pagelayer based template ?
	if(file_exists($conf)){
		
		$pagelayer->cache['template'] = 1;
		$pagelayer->template_conf = @json_decode(file_get_contents($conf), true);
		
	// Not a pagelayer theme
	}else{
		return;
	}
	
	// ORDER of preference of every template
	// 1) POST ID as per conditions - Only Premium
	// 2) TPL file if there - Free and Premium when pagelayer.conf
	// 3) PHP file if no Posts - Free and Premium
	
	// Filter to finally INCLUDE and render our template
	add_filter('template_include', 'pagelayer_template_include', 1000, 1);
	
}

// Handle the template files if any
// NOTE : This has a priority of 100 while the posts based pagelayer_builder_template_redirect has a priority of 10
// If there are any post based templates, then that is given priority
add_action( 'template_redirect', 'pagelayer_template_redirect', 100);
function pagelayer_template_redirect(){
	
	global $pagelayer, $post;
	
	// If no conf, then we dont have to do anything
	if(empty($pagelayer->template_conf)){
		return;
	}
	
	// If post template was not there, search for a header PGL file
	// Also when we are editing, we can render header only when its a pagelayer-content edit
	if(	
		(empty($pagelayer->template_editor) || @$pagelayer->template_editor == 'pagelayer-content')
		 && empty($pagelayer->template_header)
	){
		$pagelayer->template_header = pagelayer_template_try_to_apply('header');
	}
	
	// If post template was not there, search for a header PGL file
	// Also when we are editing, we cannot render the template file as post is being rendered
	if(empty($pagelayer->template_editor) && empty($pagelayer->template_post)){
	
		// Singular style posts
		if ( is_singular() || is_404() ) {
			$pagelayer->template_post = pagelayer_template_try_to_apply('single');
		
		// Archive style posts
		} elseif ( is_archive() || is_home() || is_search() ) {
			$pagelayer->template_post = pagelayer_template_try_to_apply('archive');
		}
	
	}
	
	// If post template was not there, search for a footer PGL file
	// Also when we are editing, we can render footer only when its a pagelayer-content edit
	if(	
		(empty($pagelayer->template_editor) || @$pagelayer->template_editor == 'pagelayer-content')
		 && empty($pagelayer->template_footer)
	){
		$pagelayer->template_footer = pagelayer_template_try_to_apply('footer');
	}
	
}

// Is our template being rendered
function pagelayer_template_include($template){
	
	global $pagelayer;
	
	$pagelayer_enqueue_frontend = false;
	
	// If we do have a header but not the footer or we have the footer and no header,
	// then we need to make sure to blank the other
	if(!empty($pagelayer->template_header) || !empty($pagelayer->template_footer)){
		$pagelayer_enqueue_frontend = true;
		
		// Disable AIOSEO for pagelayer post types
		if(!empty($GLOBALS['post']) && $GLOBALS['post']->post_type == $pagelayer->builder['name']){
			add_filter( 'aioseo_disable', '__return_true' );
		}
		
		add_action('get_header', 'pagelayer_get_header');
		add_action('get_footer', 'pagelayer_get_footer');
	}
	
	// Handle the sidebar settings !
	//add_action('get_sidebar', 'pagelayer_get_sidebar');
	
	// If we do have Popup templates, then append it in body
	if(!empty($pagelayer->template_popup_ids) && empty($pagelayer->template_editor)){
		$pagelayer_enqueue_frontend = true;
		add_action('wp_body_open', 'pagelayer_builder_popup_append');
		add_action('wp_footer', 'pagelayer_builder_popup_append');
	}
	
	// If the post being shown to the user is not a Pagelayer post, then we need to enqueue forcefully
	if(empty($pagelayer->cache['enqueue_frontend']) && $pagelayer_enqueue_frontend){
		pagelayer_enqueue_frontend(true);
	}
	
	// Is there any post templates OR are we editing a pagelayer-template ?
	if(!empty($pagelayer->template_post) || !empty($pagelayer->template_editor)){
		$template = $pagelayer->template_post;
	}
	
	// Its our template OR are we editing a pagelayer-template, then render it
	if(pathinfo($template, PATHINFO_EXTENSION) == 'pgl' || !empty($pagelayer->template_post) || !empty($pagelayer->template_editor)){
		
		// We rendered from header to footer
		$pagelayer->from_header_to_footer = true;
		
		get_header();
		echo '<div class="pagelayer-content">';
		pagelayer_template_render($template);
		echo '</div>';
		
		// If a template needs to call the sidebar !
		if(!empty($pagelayer->template_call_sidebar)){
			get_sidebar();
		}
		get_footer();
		
		return false;
	}
	
	// Just return the original template if its not our file
	return $template;
	
}

// Expects the file to include or the POST ID
function pagelayer_template_render($template){
	
	global $pagelayer;
	
	// $template can be blank, e.g. blank header / footer
	if(empty($template)){
		return;
	}
	
	if(is_numeric($template)){
		echo pagelayer_get_post_content($template);
	}else{
		echo pagelayer_the_content(file_get_contents(get_stylesheet_directory().'/'.$template.'.pgl'));
	}
}

// For check which template will be applied
function pagelayer_template_try_to_apply($type){
	
	global $pagelayer;
	
	// Get templates id by type
	$ids = [];
	
	// Find the templates by type
	foreach($pagelayer->template_conf as $k => $v){
		if($v['type'] == $type){
			$ids[] = $k;
		}
	}
	
	$file = pagelayer_template_check_conditons($ids, true);
	
	if( !empty($ids) && !empty($file) ){
		return $file;
	}
	
	return false;
	
}

// Check conditions of template post ids / template files
function pagelayer_template_check_conditons($ids = [], $file = false, $return_all = false){
	
	global $pagelayer;
	
	$selected_templs = [];
	
	foreach( $ids as $id ){
		
		$priority  = 0;	
		$selected_template = 0;
		$exclude_check = 1;
		
		// File based
		if($file){
			$pagelayer_template_conditions = $pagelayer->template_conf[$id]['conditions'];
		
		// Post Template based
		}else{
			$pagelayer_template_conditions = get_post_meta( $id, 'pagelayer_template_conditions', true );
		}
		
		if( !empty($pagelayer_template_conditions) ){
			foreach( $pagelayer_template_conditions as $condi ){
				
				$check = 0;
				
				// Get template array
				$tmpl_array = (array) pagelayer_multi_array_search( $pagelayer->builder['dispay_on'], $condi['template'] );
				
				// Get sub_template array
				$sub_tmpl_array = (array) pagelayer_multi_array_search( $pagelayer->builder[$condi['template'].'_templates'], $condi['sub_template']);
				
				// If the condition name is general priority
				if(empty($condi['template'])){
					
					$check = 1;
					$set_prio = 1;  // Set General Property 1
					
				// If the condition name is singular
				}elseif( array_key_exists('check_conditions', $tmpl_array) ){
					
					// If the condition callback is false, continue the loop
					if( is_callable($tmpl_array['check_conditions']) ){
						if( empty($tmpl_array['check_conditions']($condi)) ){
							continue;
						}
					}elseif( empty($tmpl_array['check_conditions']) ){
						continue;
					}
					
					// Check sub_template conditions
					if( empty($condi['sub_template']) ){
						$check = 1;
						$set_prio = 2;  // Set all sub_template Property 2
					}elseif( array_key_exists('check_conditions', $sub_tmpl_array ) ){
						
						// If the condition callback is false, continue the loop 
						if( is_callable($sub_tmpl_array['check_conditions']) ){
							if( empty($sub_tmpl_array['check_conditions']($condi)) ){
								continue;
							}
						}elseif( empty($sub_tmpl_array['check_conditions']) ){
							continue;
						}
						
						$check = 1;
						
						if( !empty($condi['id']) ){
							$set_prio = 4; // Set id Property 4
						}else{
							$set_prio = 3;// Set sub_template Property 3
							// If no id section then Property 
							if(!empty($sub_tmpl_array['no_id_section'])){ $set_prio = 4; } 
						}
					}
				}
				
				// IF is set to the exclude then
				if($condi['type'] == 'exclude' && $check){
					$exclude_check = 0;
				}
				
				if($check){
					// If the template is valid for apply 
					$selected_template = $check;
					
					// Set priority
					if($priority < $set_prio){ $priority = $set_prio; }
				}
			}
		}
		
		// Set priority to template id
		if( $selected_template && $exclude_check ){
			$selected_templs[$id] = $priority;
		}
	}
	
	// Return all ids with priority
	if($return_all){
		return $selected_templs;
	}
	
	$gprior = 0; 
	$sel_id = '';
	foreach( $selected_templs as $id => $prior ){
		if($gprior <= $prior){
			$gprior = $prior;
			$sel_id = $id;
		}
	}
	
	return $sel_id;
}

// The header to substitute
function pagelayer_get_header($name) {
	
	global $pagelayer;
	
	// Output default header always if we have a header or footer
	?>
	<!DOCTYPE html>
	<html <?php language_attributes(); ?>>
	<head>
		<meta charset="<?php bloginfo( 'charset' ); ?>" />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<link rel="profile" href="https://gmpg.org/xfn/11">
		<?php wp_head(); ?>
	</head>

	<body <?php body_class(); ?>>
	<?php if(function_exists('wp_body_open')) { wp_body_open(); } ?>
	<?php
	
	// Output our content
	if(!empty($pagelayer->template_header)){
		
		echo '
	<header class="pagelayer-header">';
		
		// Render the content
		pagelayer_template_render($pagelayer->template_header);
		
		echo '
	</header>';
		
	}
		
	// Avoid running wp_head hooks again
	remove_all_actions('wp_head');

	$templates = [];
	$name = (string) $name;
	if ($name !== '') {
		$templates[] = 'header-'.$name.'.php';
	}

	$templates[] = 'header.php';
	
	// Since, we already outputted our header, we need to do a locate_template for the existing theme
	// This is because, locate_template has the 3rd param as require once, so in the get_header 
	// the header.php will not load again
	ob_start();
	locate_template( $templates, true );
	ob_get_clean();
	
}

// The footer to load
function pagelayer_get_footer($name) {
	
	global $pagelayer;
	
	// Output our content
	if(!empty($pagelayer->template_footer)){
		
		echo '
	<footer class="pagelayer-footer">';
	
		pagelayer_template_render($pagelayer->template_footer);
		
		echo '
	</footer>';
	
	}
	
	// Output default footer always if we have a header or footer		
	wp_footer();
	echo '</body>
	</html>';
	
	// Avoid running wp_footer hooks again
	remove_all_actions( 'wp_footer' );

	$templates = [];
	$name = (string) $name;
	if ($name !== '') {
		$templates[] = 'footer-'.$name.'.php';
	}

	$templates[] = 'footer.php';
	
	// Since, we already outputted our footer, we need to do a locate_template for the existing theme
	// This is because, locate_template has the 3rd param as require once, so in the get_footer 
	// the footer.php will not load again
	ob_start();
	locate_template( $templates, true );
	ob_get_clean();
	
}

// Any sidebar to load ?
function pagelayer_get_sidebar($name = '') {
	
	global $pagelayer;
	
	// If any of our setting has been set, then only we apply. Otherwise we return !
	if(is_customize_preview()){
		$pagelayer->settings['sidebar'] = get_option('pagelayer_sidebar');
	}
	
	if(is_array($pagelayer->settings['sidebar'])){
		foreach($pagelayer->settings['sidebar'] as $k => $v){
			$set = 1;
			break;
		}
	}
	
	// If no settings were saved for pagelayer, let the default persist
	// BUT if we are from_header_to_footer then we want default as no header and hence, we will render ours !
	if(empty($set) && empty($pagelayer->from_header_to_footer)){
		return;
	}
	
	// Output our content
	if(!empty($pagelayer->template_sidebar)){
		pagelayer_template_render($pagelayer->template_sidebar);
	}

	$templates = [];
	$name = (string) $name;
	if ($name !== '') {
		$templates[] = 'sidebar-'.$name.'.php';
	}

	$templates[] = 'sidebar.php';
	
	// Since, we already outputted our sidebar, we need to do a locate_template for the existing theme
	// This is because, locate_template has the 3rd param as require once, so in the get_sidebar
	// the sidebar.php will not load again
	ob_start();
	locate_template( $templates, true );
	$sidebar = ob_get_clean();	
	
	// Lets see what are settings are ?
	$set = !empty($pagelayer->settings['sidebar']) ? $pagelayer->settings['sidebar'] : [];
	
	// For page
	if(is_page()){
		$enabled = isset($set['page']) ? $set['page'] : 'default';
	
	// For post
	}elseif(is_single()){
		$enabled = isset($set['post']) ? $set['post'] : 'default';
	
	// For Archives
	}elseif(is_archive() || is_home()){
		$enabled = isset($set['archives']) ? $set['archives'] : 'default';
	}

	// Load the default
	if(@$enabled == 'default' || is_front_page()){
		$enabled = @$set['default'];
	}

	// If its not right or left, then its disabled. Disabled values can be stored as "no" or "0"
	if(!in_array($enabled, ['left', 'right'])){
		return;
	}

	$width = (int) (empty($set['width']) ? 20 : $set['width']);	
	
	if(empty($sidebar)){
		return;
	}
	
	echo $sidebar;
	
?><style>
aside, #sidebar {
width: <?php echo $width;?>%;
float: <?php echo $enabled;?>;
}

main, .pagelayer-content{
width: <?php echo round(99 - $width);?>% !important;
display: inline-block;
}

#wp-calendar{
min-width: 100%;
}
</style>

<?php

}

// Get the custom post content by id
function pagelayer_get_post_content($id){
	global $pagelayer;
	
	// Need to set post ID in Pagelayer boject, so we can get it while do shortcode
	$pagelayer->rendering_template_id = $id;
	
	// Get the content
	$post = get_post($id);
	
	if(is_attachment()){
		remove_filter( 'the_content', 'prepend_attachment' );
	}
	
	$content = $post->post_content;
	pagelayer_load_shortcodes();
	
	$cached_editable = $pagelayer->dont_make_editable;
	$pagelayer->dont_make_editable = true;
	$content = apply_filters( 'the_content', $content );
	$content = str_replace( ']]>', ']]&gt;', $content );
	$pagelayer->dont_make_editable = $cached_editable;
	
	// Reset the id
	$pagelayer->rendering_template_id = 0;
	
	return $content;

}

// Vars that can be used in template files
function pagelayer_template_vars(){
	
	$replacers['{{theme_url}}'] = get_stylesheet_directory_uri();
	$replacers['{{theme_images}}'] = get_stylesheet_directory_uri().'/images/';
	$replacers['{{themes_dir}}'] = dirname(get_stylesheet_directory_uri());
	$replacers['{{content_url}}'] = dirname(dirname(dirname(get_stylesheet_directory_uri())));
	$replacers['{{pl_site_url}}'] = home_url();
	$replacers['{{pl_plugin_url}}'] = PAGELAYER_URL;
	
	return $replacers;
	
}PK�f\�jd��	class.phpnu�[���<?php

//////////////////////////////////////////////////////////////
//===========================================================
// class.php
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date:       23rd Jan 2017
// Time:       23:00 hrs
// Site:       http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////

// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
	exit('Hacking Attempt !');
}

// Pagelayer Class
class PageLayer{
	
	var $BRAND_TEXT;
	var $LOGO;
	var $action;
	var $license;
	var $allowed_mime_type;
	var $template_call_sidebar;
	var $shortcode_loaded;
	var $anim_in_options;
	var $anim_out_options;
	var $slider_arrow_styles;
	var $slider_pager_styles;
	var $slider_options;
	var $templates;
	var $template_header;
	var $template_post;
	var $template_footer;
	var $template_popup_ids;
	var $load_live_errors;
	var $rendering_template_id;
	var $dont_make_editable;

	// All Settings
	var $settings = array();

	// Cache
	var $cache = array();

	// Common Styles Params
	var $styles = array();

	// All Shortcodes
	var $shortcodes = array();

	// All Shortcodes Groups
	var $groups = array();

	// Builder definition
	var $builder = array();

	// The Lang Strings
	var $l = array();
	
	// Runtime fonts
	var $fonts = array();
	var $runtime_fonts = array();
	var $fonts_sent = array();
	var $system_fonts = array();
	var $typo_props = array();

	// Array of all the template paths
	var $all_template_paths = array();

	// Tabs visible in the left panel
	var $tabs = ['settings', 'options'];

	// Tabs visible in the left panel
	var $screens = ['desktop' => '', 'tablet' => 'tablet', 'mobile' => 'mobile'];

	// Icons set
	var $icons = ['font-awesome5'];
	
	// For exporting templates
	var $media_to_export = array();
	
	// For global widget
	var $global_widgets = array();
	
	// For global section
	var $global_sections = array();
	
	// For saved sections
	var $saved_sections = array();
	
	// For saved default params
	var $default_params = array();

	// Youtube API 
	var $append_yt_api = false;
	
	var $css = array();
	var $css_settings = array();
	
	// Customizer options
	var $customizer_mods = array();	
	var $customizer_params = array();
	
	var $data_attr = array();
	var $sc_audio_enqueued = 0;
	
	var $support = 'http://pagelayer.deskuss.com';
	
	// Global colors and typographies
	var $global_colors = array();
	var $global_fonts = array();

	function __construct() {

		// Load the langs
		$this->l = @file_get_contents(PAGELAYER_DIR.'/languages/en.json');
		$this->l = @json_decode($this->l, true);
		
		// Load the langs hook
		$this->l = apply_filters('pagelayer_load_languages', $this->l);
		
		// Add after plugins_loaded
		add_action('plugins_loaded', [ $this, 'load_extra_languages' ], 11);
		
		// Array of font options
		$this->css_settings = ['body' => ['name' => 'Body', 'key' => 'pagelayer_body_typography'],
			'header' => ['name' => 'Site Header', 'sel' => '> header'],
			'main' => ['name' => 'Site Main', 'sel' => '.site-main'],
			'footer' => ['name' => 'Site Footer', 'sel' => '> footer'],
			'entry-header' => ['name' => 'Content Header', 'sel' => '.entry-header'],
			'entry-content' => ['name' => 'Content', 'sel' => '.entry-content'],
			'entry-footer' => ['name' => 'Content Footer', 'sel' => '.entry-footer'],
			'p' => ['name' => 'Paragraph'],
			'aside' => ['name' => 'Sidebar'],
			'a' => ['name' => 'Link'],
			'a-hover' => ['name' => 'Link Hover', 'sel' => 'a:hover'],
			'h1' => ['name' => 'H1', 'key' => 'pagelayer_h1_typography'],
			'h2' => ['name' => 'H2', 'key' => 'pagelayer_h2_typography'],
			'h3' => ['name' => 'H3', 'key' => 'pagelayer_h3_typography'],
			'h4' => ['name' => 'H4', 'key' => 'pagelayer_h4_typography'],
			'h5' => ['name' => 'H5', 'key' => 'pagelayer_h5_typography'],
			'h6' => ['name' => 'H6', 'key' => 'pagelayer_h6_typography'],
			'b' => ['name' => 'Bold', 'sel' => 'strong, body.pagelayer-body b'],
			'i' => ['name' => 'Italics', 'sel' => 'em, body.pagelayer-body i:not(.fa, .fas, .far, .fab)'],
		];
		
		$this->system_fonts = ['Arial', 'Arial Black', 'Courier', 'Georgia', 'Helvetica', 'impact', 'Tahoma', 'Times New Roman', 'Trebuchet MS', 'Verdana'];
		$this->customizer_mods = get_option('pagelayer_customizer_mods', []);
		$this->support = (defined('SITEPAD') ? 'http://sitepad.deskuss.com' : $this->support);
		$this->typo_props = ['font-family', 'font-size', 'font-style', 'font-weight', 'font-variant', 'text-decoration-line', 'text-decoration-style', 'line-height', 'text-transform', 'letter-spacing', 'word-spacing'];
		
	}
	
	function default_font_styles( $args = array()){
		
		$default_font_styles = [
			'font-family' => 'Open Sans',
			'font-size' => '',
			'font-style' => '',
			'font-variant' => '',
			'font-weight' => '',
			'letter-spacing' => '',
			'line-height' => '',
			'text-decoration-line' => '',
			'text-decoration-style' => '',
			'text-transform' => '',
			'word-spacing' => ''
		];
		
		return array_merge($default_font_styles, $args);
	}
	
	function load_extra_languages(){
		
		if(defined('SITEPAD')){
			$this->l['email_desc'] = 'To change the email, visit your '.BRAND_SM.' Dashboard -> Settings -> Editor Settings';
			$this->l['CMA_desc'] = 'To change text, visit your '.BRAND_SM.' Dashboard -> Settings -> Editor Settings';
		}
		
	}

}PK�f\ff��shortcodes.phpnu�[���<?php

//////////////////////////////////////////////////////////////
//===========================================================
// class.php
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date:	   23rd Jan 2017
// Time:	   23:00 hrs
// Site:	   http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////

// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
	exit('Hacking Attempt !');
}

// NOTE :
// 1) There can be a holder or innterHTML for a tag. NOT BOTH
// 2) Groups can have 'html' but need the holder as well then
// 3) innerHTML defines the param to be saved in the shortcode as inner content

// Example of 'show' and 'req' prop attr
// NOTE : There can be only REQ or show
// First preference given to REQ
/*

// Single value
'show' => ['border_hover' => 'normal'],

// Two value i.e. when both the values are true
'show' => ['border_hover' => 'normal',
	'border_type' => 'solid',
],

// Exception i.e. prefix the param name with ! (exclamation)
'show' => ['!border_hover' => 'normal',
	'border_type' => 'solid',
],

// Support for MULTIPLE values of ONE parameter. 
// NOTE : This will be treated as OR for that parameter i.e. if the current value of that parameter is any ONE of the array given
'show' => ['border_hover' => ['normal', 'hover']],

*/

// Example of 'css' prop attr
/*

// Set the value to the parent element
'css' => 'background-color: {{val}}',

// Multiple vals
'css' => [
	'background-color: {{val}}',
	'-webkit-background-color: {{val}}',
	'-moz-background-color: {{val}}',
],

// Multiple vals with some selectors or direct element val
'css' => [
	'{{element}} .class' => 'background-color: {{val}}',
	'-webkit-background-color: {{val}}',
	'-moz-background-color: {{val}}',
],

*/

// Example of 'addAttr' or 'addClass'
/*

// Set the value to the parent element
'addAttr' => 'target="_blank"',

// Multiple vals
'addAttr' => [
	'target="_blank"',
	'href="/"',
	'rel="{{rel}}"',
],

// Multiple vals with some selectors or direct element val
'addAttr' => [
	'{{element}} .class' => 'target="_blank"',
	'href="/"',
	'rel="{{rel}}"',
],

// Define group and set default content if it has inner_row child
'has_group' => [
			'section' => 'params', 
			'prop' => 'elements',
		],
*/

////////////////////////
// Default Styles
////////////////////////
global $pagelayer;

$pagelayer->anim_in_options = array(
	'' => __pl('none'),
	__pl('fading') => [
		'fadeIn' => __pl('fadein'),
		'fadeInDown' => __pl('fadeindown'),
		'fadeInUp' => __pl('fadeinup'),
		'fadeInLeft' => __pl('fadeinleft'),
		'fadeInRight' => __pl('fadeinright'),
	],
	__pl('zooming') => [
		'zoomIn' => __pl('zoomin'),
		'zoomInDown' => __pl('zoomindown'),
		'zoomInUp' => __pl('zoominup'),
		'zoomInLeft' => __pl('zoominleft'),
		'zoomInRight' => __pl('zoominright'),
	],
	__pl('bounceing') => [
		'bounceIn' => __pl('bouncein'),
		'bounceInDown' => __pl('bounceindown'),
		'bounceInUp' => __pl('bounceinup'),
		'bounceInLeft' => __pl('bounceinleft'),
		'bounceInRight' => __pl('bounceinright'),
	],
	__pl('sliding') => [
		'slideInDown' => __pl('slideindown'),
		'slideInUp' => __pl('slideinup'),
		'slideInLeft' => __pl('slideinleft'),
		'slideInRight' => __pl('slideinright'),
	],
	__pl('rotating') => [
		'rotateIn' => __pl('rotatein'),
		'rotateInDown' => __pl('rotateindown'),
		'rotateInUp' => __pl('rotateinup'),
		'rotateInLeft' => __pl('rotateinleft'),
		'rotateInRight' => __pl('rotateinright'),
	],
	__pl('effects') => [
		'lightSpeedIn' => __pl('lightspeedin'),
		'bounce' => __pl('bounce'),
		'pulse' => __pl('pulse'),
		'rubberBand' => __pl('rubberband'),
		'flash' => __pl('flash'),
		'swing' => __pl('swing'),
		'jello' => __pl('jello'),
		'tada' => __pl('tada'),
		'wobble' => __pl('wobble'),
		'rollin' => __pl('rollin'),
		'headShake' => __pl('headshake'),
		'shake' => __pl('shake'),
	],
);

$pagelayer->anim_out_options = array(
	'' => __pl('none'),
	__pl('fading') => [
		'fadeOut' => __pl('fadeout'),
		'fadeOutDown' => __pl('fadeoutdown'),
		'fadeOutUp' => __pl('fadeoutup'),
		'fadeOutLeft' => __pl('fadeoutleft'),
		'fadeOutRight' => __pl('fadeoutright'),
	],
	__pl('zooming') => [
		'zoomOut' => __pl('zoomout'),
		'zoomOutDown' => __pl('zoomoutdown'),
		'zoomOutUp' => __pl('zoomoutup'),
		'zoomOutLeft' => __pl('zoomoutleft'),
		'zoomOutRight' => __pl('zoomoutright'),
	],
	__pl('bounceing') => [
		'bounceOut' => __pl('bounceout'),
		'bounceOutDown' => __pl('bounceoutdown'),
		'bounceOutUp' => __pl('bounceoutup'),
		'bounceOutLeft' => __pl('bounceoutleft'),
		'bounceOutRight' => __pl('bounceoutright'),
	],
	__pl('sliding') => [
		'slideOutDown' => __pl('slideoutdown'),
		'slideOutUp' => __pl('slideoutup'),
		'slideOutLeft' => __pl('slideoutleft'),
		'slideOutRight' => __pl('slideoutright'),
	],
	__pl('rotating') => [
		'rotateOut' => __pl('rotateout'),
		'rotateOutDown' => __pl('rotateoutdown'),
		'rotateOutUp' => __pl('rotateoutup'),
		'rotateOutLeft' => __pl('rotateoutleft'),
		'rotateOutRight' => __pl('rotateoutright'),
	],
	__pl('effects') => [
		'lightSpeedIn' => __pl('lightspeedin'),
		'bounce' => __pl('bounce'),
		'pulse' => __pl('pulse'),
		'rubberBand' => __pl('rubberband'),
		'flash' => __pl('flash'),
		'swing' => __pl('swing'),
		'jello' => __pl('jello'),
		'tada' => __pl('tada'),
		'wobble' => __pl('wobble'),
		'rollin' => __pl('rollin'),
		'headShake' => __pl('headshake'),
		'shake' => __pl('shake'),
	],
);

$pagelayer->slider_arrow_styles = [
	'arrows_bg' => array(
		'type' => 'color',
		'label' => __pl('bg_color'),
		'default' => '#6a6969',
		'css' => [
			'{{element}} .pagelayer-owl-prev' => 'background-color: {{val}} !important',
			'{{element}} .pagelayer-owl-next' => 'background-color: {{val}} !important',
		]
	),
	'arraow_color' => array(
		'type' => 'color',
		'label' => __pl('color'),
		'default' => '#ffffff',
		'css' => [
			'{{element}} .pagelayer-owl-prev' => 'color: {{val}} !important',
			'{{element}} .pagelayer-owl-next' => 'color: {{val}} !important',
		]
	),
	'nav_size' => array(
		'type' => 'slider',
		'label' => __pl('arraow_size'),
		'min' => 0,
		'step' => 1,
		'max' => 200,
		'screen' => 1,
		'css' => [
			'{{element}} .pagelayer-owl-prev span' => 'font-size: {{val}}px !important;',
			'{{element}} .pagelayer-owl-next span' => 'font-size: {{val}}px !important;'
		]
	),
	'arraow_bg_size' => array(
		'type' => 'spinner',
		'label' => __pl('background_size'),
		'min' => 0,
		'step' => 1,
		'max' => 500,
		'default' => 20,
		'screen' => 1,
		'css' => [
			'{{element}} .pagelayer-owl-prev' => 'width: {{val}}px; height: {{val}}px',
			'{{element}} .pagelayer-owl-next' => 'width: {{val}}px; height: {{val}}px'
		]
	),
	'arraow_bg_shape' => array(
		'type' => 'spinner',
		'label' => __pl('background_shape'),
		'min' => 0,
		'step' => 1,
		'max' => 100,
		'default' => 20,
		'screen' => 1,
		'css' => [
			'{{element}} .pagelayer-owl-prev' => 'border-radius: {{val}}% !important;',
			'{{element}} .pagelayer-owl-next' => 'border-radius: {{val}}% !important;',
		]
	),
	'arrow_pos_type' => array(
		'type' => 'select',
		'label' => __pl('position'),
		'list' => array(
			'' => __pl('default'),
			'custom' => __pl('custom'),
			'top' => __pl('top'),
			'bottom' => __pl('bottom')
		),
	),
	'arrow_pos_top' => array(
		'label' => __pl('alignment'),
		'type' => 'radio',
		'list' => array(
			'left' => __pl('left'),
			'center' => __pl('center'),
			'right' => __pl('right'),
		),
		'default' => 'center',
		'req' => [ 'arrow_pos_type' => 'top'],
		'addClass' => ['pagelayer-slide-arrow-pos-top'],
		'css' => ['{{element}} .pagelayer-owl-nav' => 'justify-content:{{arrow_pos_top}}']
	),
	'arrow_pos_bottom' => array(
			'label' => __pl('alignment'),
			'type' => 'radio',
			'list' => array(
				'left' => __pl('left'),
				'center' => __pl('center'),
				'right' => __pl('right'),
			),
			'default' => 'center',
			'req' => ['arrow_pos_type' => 'bottom'],
			'addClass' => ['pagelayer-slide-arrow-pos-bottom'],
			'css' => [
				'{{element}} .pagelayer-owl-nav' => 'justify-content:{{arrow_pos_bottom}}'
			]
	),
	'arrow_icon_type' => array(
		'type' => 'select',
		'label' => __pl('icon_type'),
		'list' => array(
			'' => __pl('default'),
			'custom' => __pl('custom'),
		),
	), 
	'arrow_icon' => array(
		'type' => 'icon',
		'label' => __pl('list_icon_label'),
		'show' => ['arrow_icon_style' => ''],
		'default' => 'fas fa-angle-left',
		'addAttr' => ['{{element}} .pagelayer-owl-holder' => 'data-slides-navText="{{arrow_icon}}"'],
		'list' => ['angle-double-left', 'arrow-alt-circle-left', 'arrow-circle-left', 'arrow-left', 'long-arrow-alt-left', 'arrow-alt-circle-left', 'angle-double-left', 'angle-left'],
		'css' => [
			'{{element}} .pagelayer-owl-prev i' => 'font-size: {{nav_size}}px !important;',
			'{{element}} .pagelayer-owl-next i' => 'font-size: {{nav_size}}px !important;' 
		],
		'req' => ['!arrow_icon_type' => '']
	),
	'arrow_pos_style' => array(
		'type' => 'radio',
		'label' => __pl('arrow_pos'),
		'list' => array(
			'' => __pl('left_arrow'),
			'right' => __pl('right_arrow'),
		),
		'show' => ['arrow_pos_type' => 'custom']
	),
	'arrow_left_horizontal_pos' => array(
		'type' => 'slider',
		'label' => __pl('horizontal_pos'),
		'min' => 0,
		'step' => 1,
		'max' => 100,
		'screen' => 1,
		'css' => [
			'{{element}} .pagelayer-owl-prev' => 'left: {{val}}% !important;',
		],
		'req' => ['arrow_pos_type' => 'custom'],
		'show' => ['arrow_pos_style' => ''],
	),
	'arrow_right_horizontal_pos' => array(
		'type' => 'slider',
		'label' => __pl('horizontal_pos'),
		'min' => 0,
		'step' => 1,
		'max' => 100,
		'screen' => 1,
		'css' => [
			'{{element}} .pagelayer-owl-next' => 'right: {{val}}% !important;',
		],
		'req' => ['arrow_pos_type' => 'custom'],
		'show' => ['!arrow_pos_style' => ''],
	),
	'arrow_vertical_pos' => array(
		'type' => 'slider',
		'label' => __pl('vertical_pos'),
		'min' => 0,
		'step' => 1,
		'max' => 100,
		'screen' => 1,
		'css' => [
			'{{element}} .pagelayer-owl-prev' => 'top: {{val}}% !important;',
			'{{element}} .pagelayer-owl-next' => 'top: {{val}}% !important;',
		],
		'req' => ['arrow_pos_type' => 'custom'],
	),
];

$pagelayer->slider_pager_styles = [
	'show_num' => array(
		'type' => 'checkbox',
		'label' => __pl('show_num'),
		'addClass' => ['pagelayer-slide-dot-number'],
		'css' => ['{{element}} .pagelayer-owl-dot span::before' => 'line-height: {{dot_height}}px;'],
	),
	'dot_state' => array(
		'type' => 'radio',
		'label' => __pl('dot_state'),
		'list' => array(
			'' => __pl('normal'),
			'active' => __pl('active'),
		),
	),
	'pager_color' => array(
		'type' => 'color',
		'label' => __pl('color'),
		'css' => ['{{element}} .pagelayer-owl-dot span' => 'background-color: {{val}} !important'],
		'show' => ['dot_state' => ''],
	),
	'dot_num_color' => array(
		'type' => 'color',
		'label' => __pl('number_color'),
		'css' => ['{{element}} .pagelayer-owl-dot span::before' => 'color:{{val}}'],
		'req' => ['!show_num' => ''],
		'show' => ['dot_state' => ''],
	),
	'dot_size' => array(
		'type' => 'slider',
		'label' => __pl('dot_size'),
		'min' => 0,
		'step' => 1,
		'max' => 200,
		'screen' => 1,
		'css' => [
			'{{element}} .pagelayer-owl-dot span' => 'width: {{val}}px !important; height: {{val}}px !important;'
		],
		'show' => ['dot_state' => ''],
	),
	'dot_width' => array(
		'type' => 'slider',
		'label' => __pl('dot_width'),
		'min' => 0,
		'step' => 1,
		'max' => 200,
		'screen' => 1,
		'css' => [
			'{{element}} .pagelayer-owl-dot span' => 'width: {{val}}px !important;'
		],
		'show' => ['dot_state' => ''],
	),
	'dot_height' => array(
		'type' => 'slider',
		'label' => __pl('dot_height'),
		'min' => 0,
		'step' => 1,
		'max' => 200,
		'screen' => 1,
		'css' => [
			'{{element}} .pagelayer-owl-dot span' => 'height: {{val}}px !important;'
		],
		'show' => ['dot_state' => ''],
	),
	'dot_radius' => array(
		'type' => 'padding',
		'label' => __pl('dot_radius'),
		'min' => 0,
		'step' => 1,
		'max' => 200,
		'screen' => 1,
		'css' => [
			'{{element}} .pagelayer-owl-dot span' => 'border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px !important;'
		],
		'show' => ['dot_state' => ''],
	),
	'active_pager_color' => array(
		'type' => 'color',
		'label' => __pl('active_pager_color'),
		'css' => ['{{element}} .pagelayer-owl-dot.active span' => 'background-color: {{val}} !important'],
		'show' => ['!dot_state' => ''],
	),
	'active_dot_num_color' => array(
		'type' => 'color',
		'label' => __pl('number_color'),
		'css' => ['{{element}} .pagelayer-owl-dot.active span::before' => 'color:{{val}}'],
		'req' => ['!show_num' => ''],
		'show' => ['!dot_state' => ''],
	),
	'active_dot_size' => array(
		'type' => 'slider',
		'label' => __pl('active_dot_size'),
		'min' => 0,
		'step' => 1,
		'max' => 200,
		'screen' => 1,
		'css' => [
			'{{element}} .pagelayer-owl-dot.active span' => 'width: {{val}}px !important; height: {{val}}px !important;'
		],
		'show' => ['!dot_state' => ''],
	),
	'active_dot_width' => array(
		'type' => 'slider',
		'label' => __pl('dot_width'),
		'min' => 0,
		'step' => 1,
		'max' => 200,
		'screen' => 1,
		'css' => [
			'{{element}} .pagelayer-owl-dot.active span' => 'width: {{val}}px !important;'
		],
		'show' => ['!dot_state' => ''],
	),
	'active_dot_height' => array(
		'type' => 'slider',
		'label' => __pl('dot_height'),
		'min' => 0,
		'step' => 1,
		'max' => 200,
		'screen' => 1,
		'css' => [
			'{{element}} .pagelayer-owl-dot.active span' => 'height: {{val}}px !important;'
		],
		'show' => ['!dot_state' => ''],
	),
	'active_dot_radius' => array(
		'type' => 'padding',
		'label' => __pl('dot_radius'),
		'min' => 0,
		'step' => 1,
		'max' => 200,
		'screen' => 1,
		'css' => [
			'{{element}} .pagelayer-owl-dot.active span' => 'border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px !important;'
		],
		'show' => ['!dot_state' => ''],
	),
	'dot_border_type' => array(
		'type' => 'select',
		'label' => __pl('border_type'),
		'list' => [
			'' => __pl('none'),
			'solid' => __pl('solid'),
			'double' => __pl('double'),
			'dotted' => __pl('dotted'),
			'dashed' => __pl('dashed'),
			'groove' => __pl('groove'),
		],
		'css' => [ '{{element}} .pagelayer-owl-dot span' => 'border-style: {{val}};' ],
	),
	'dot_border_width' => array(
		'type' => 'padding',
		'label' => __pl('border_width'),
		'screen' => 1,
		'css' => [ '{{element}} .pagelayer-owl-dot span' => 'border-width: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px;' ],
		'req' => ['!dot_border_type' => ''],
	),
	'dot_border_color' => array(
		'type' => 'color',
		'label' => __pl('border_color'),
		'css' => [ '{{element}} .pagelayer-owl-dot span' => 'border-color: {{val}};' ],
		'req' => ['!dot_border_type' => ''],
	),
	'dot_pos' => array(
		'type' => 'select',
		'label' => __pl('position'),
		'list' => array(
			'' => __pl('bottom'),
			'top' => __pl('top'),
			'right' => __pl('right'),
			'left' => __pl('left'),
		),
		'addClass' => ['pagelayer-slide-dot-pos-{{val}}'],
		'css' => ['{{element}} .pagelayer-owl-dots' => '{{val}}: 10px'],
	),
	'pager_top_space' => array(
		'type' => 'slider',
		'label' => __pl('service_btn_spacing'),
		'min' => 0,
		'step' => 1,
		'max' => 200,
		'screen' => 1,
		'css' => [
			'{{element}} .pagelayer-owl-dots' => 'margin-top: {{val}}px !important;'
		]
	)
];

$pagelayer->slider_options = [
	'slide_items' => array(
		'type' => 'spinner',
		'label' => __pl('number_of_items'),
		'np' => 1,
		'min' => 1,
		'step' => 1,
		'max' => 10,
		'default' => 1,
		'addAttr' => ['{{element}} .pagelayer-owl-holder' => 'data-slides-items="{{slide_items}}"'],
	),
	'slidein_anim' => array(
		'type' => 'select',
		'label' => __pl('animation_in'),
		'addAttr' => ['{{element}} .pagelayer-owl-holder' => 'data-slides-animate-in="{{slidein_anim}}"'],
		'list' => $pagelayer->anim_in_options,
		'req' => ['slide_items' => '1']
	),
	'slideout_anim' => array(
		'type' => 'select',
		'label' => __pl('animation_out'),
		'addAttr' => ['{{element}} .pagelayer-owl-holder' => 'data-slides-animate-out="{{slideout_anim}}"'],
		'list' => $pagelayer->anim_out_options,
		'req' => ['slide_items' => '1']
	),
	'slide_margin' => array(
		'type' => 'slider',
		'label' => __pl('space_between'),
		'min' => 0,
		'step' => 1,
		'max' => 100,
		'default' => 10,
		'addAttr' => ['{{element}} .pagelayer-owl-holder' => 'data-slides-margin="{{slide_margin}}"'],
		'req' => ['!slide_items' => '1']
	),
	'slide_loop' => array(
		'type' => 'checkbox',
		'label' => __pl('loop'),
		'addAttr' => ['{{element}} .pagelayer-owl-holder' => 'data-slides-loop="{{slide_loop}}"'],
	),
	'slide_controls' => array(
		'type' => 'select',
		'label' => __pl('slider_controls'),
		'addAttr' => ['{{element}} .pagelayer-owl-holder' => 'data-slides-controls="{{slide_controls}}"'],
		'list' => array(
			'' => __pl('Arrows and Pager'),
			'arrows' => __pl('Arrows'),
			'pager' => __pl('Pager'),
			'none' => __pl('none'),
		)
	),
	'slide_autoplay' => array(
		'type' => 'checkbox',
		'label' => __pl('autoplay'),
		'addAttr' => ['{{element}} .pagelayer-owl-holder' => 'data-slides-autoplay="{{slide_autoplay}}"'],
	),
	'slide_timeout' => array(
		'type' => 'spinner',
		'label' => __pl('autoplay_timeout'),
		'min' => 1000,
		'step' => 200,
		'max' => 10000,
		'addAttr' => ['{{element}} .pagelayer-owl-holder' => 'data-slides-autoplay-timeout="{{slide_timeout}}"'],
		'req' => ['slide_autoplay' => 'true']
	),
	'slide_hoverpause' => array(
		'type' => 'checkbox',
		'label' => __pl('autoplay_hover_pause'),
		'addAttr' => ['{{element}} .pagelayer-owl-holder' => 'data-slides-autoplay-hover-pause="{{slide_hoverpause}}"'],
		'req' => ['slide_autoplay' => 'true']
	),
];

$pagelayer->styles['ele_bg_styles'] = [
	'ele_bg_hover' => [
		'type' => 'radio',
		'label' => __pl('Background'),
		'default' => '',
		//'no_val' => 1,// Dont set any value to element
		'list' => [
			'' => __pl('normal'),
			'hover' => __pl('hover'),
		],
	],
	'ele_bg_type' => [
		'type' => 'radio',
		'label' => __pl('Background Type'),
		'default' => '',
		'list' => [
			'' => __pl('none'),
			'color' => __pl('color'),
			'gradient' => __pl('gradient'),
			'image' => __pl('image'),
		],
		'show' => ['ele_bg_hover' => '']
	],
	'ele_bg_color' => [
		'type' => 'color',
		'label' => __pl('color'),
		'css' => 'background: {{val}};',
		'show' => ['ele_bg_hover' => ''],
		'req' => ['ele_bg_type' => 'color']
	],
	'ele_bg_gradient' => [
		'type' => 'gradient',
		'label' => '',
		'default' => '150,#44d3f6,23,#72e584,45,#2ca4eb,100',
		'css' => 'background: linear-gradient({{val[0]}}deg, {{val[1]}} {{val[2]}}%, {{val[3]}} {{val[4]}}%, {{val[5]}} {{val[6]}}%);',
		'show' => ['ele_bg_hover' => ''],
		'req' => ['ele_bg_type' => 'gradient']
	],
	'ele_img_color' => [
		'type' => 'color',
		'label' => __pl('color'),
		'default' => '',
		'desc' => __pl('fallback_color'),
		'css' => 'background-color: {{val}};',
		'show' => ['ele_bg_hover' => ''],
		'req' => ['ele_bg_type' => 'image']
	],
	'ele_bg_img' => [
		'type' => 'image',
		'label' => __pl('Image'),
		'css' => 'background-image: url("{{{ele_bg_img-url}}}");',
		'show' => ['ele_bg_hover' => ''],
		'req' => ['ele_bg_type' => 'image']
	],
	'ele_bg_attachment' => [
		'type' => 'select',
		'label' => __pl('ele_bg_attachment'),
		'list' => [
			'' => __pl('default'),
			'scroll' => __pl('scroll'),
			'fixed' => __pl('fixed')
		],
		'show' => ['ele_bg_hover' => ''],
		'css' => 'background-attachment: {{val}};',
		'req' => ['ele_bg_type' => 'image']
	],
	'ele_bg_posx' => [
		'type' => 'select',
		'label' => __pl('ele_bg_posx'),
		'list' => [
			'' => __pl('default'),
			'center' => __pl('center'),
			'left' => __pl('left'),
			'right' => __pl('right'),
			'custom' => __pl('custom')
		],
		'show' => ['ele_bg_hover' => ''],
		'css' => 'background-position-x: {{val}};',
		'req' => ['ele_bg_type' => 'image']
	],
	'ele_bg_posx_custom' => array(
		'label' => __pl('custom_x'),
		'type' => 'slider',
		'step' => 1,
		'min' => -5000,
		'max' => 5000,
		'screen' => 1,
		'units' => ['px', 'em', '%'],
		'css' => 'background-position-x: {{val}};',
		'req' => array(
			'ele_bg_posx' => 'custom'
		),
	),	
	'ele_bg_posy' => [
		'type' => 'select',
		'label' => __pl('ele_bg_posy'),
		'list' => [
			'' => __pl('default'),
			'center' => __pl('center'),
			'top' => __pl('top'),
			'bottom' => __pl('bottom'),
			'custom' => __pl('custom')
		],
		'show' => ['ele_bg_hover' => ''],
		'css' => 'background-position-y: {{val}};',
		'req' => ['ele_bg_type' => 'image']
	],
	'ele_bg_posy_custom' => array(
		'label' => __pl('custom_y'),
		'type' => 'slider',
		'step' => 1,
		'min' => -5000,
		'max' => 5000,
		'screen' => 1,
		'units' => ['px', 'em', '%'],
		'css' => 'background-position-y: {{val}};',
		'req' => array(
			'ele_bg_posy' => 'custom'
		),
	),
	'ele_bg_repeat' => [
		'type' => 'select',
		'label' => __pl('ele_bg_repeat'),
		'css' => 'background-repeat: {{val}};',
		'list' => [
			'' => __pl('default'),
			'repeat' => __pl('repeat'),
			'no-repeat' => __pl('no-repeat'),
			'repeat-x' => __pl('repeat-x'),
			'repeat-y' => __pl('repeat-y'),
		],
		'show' => ['ele_bg_hover' => ''],
		'req' => ['ele_bg_type' => 'image']
	],
	'ele_bg_size' => [
		'type' => 'select',
		'label' => __pl('ele_bg_size'),
		'css' => 'background-size: {{val}};',
		'list' => [
			'' => __pl('default'),
			'cover' => __pl('cover'),
			'contain' => __pl('contain')
		],
		'show' => ['ele_bg_hover' => ''],
		'req' => ['ele_bg_type' => 'image']
	],
	'ele_bg_type_hover' => [
		'type' => 'radio',
		'label' => __pl('background_type'),
		'default' => '',
		'list' => [
			'' => __pl('none'),
			'color' => __pl('color'),
			'gradient' => __pl('gradient'),
			'image' => __pl('image'),
		],
		'show' => ['ele_bg_hover' => 'hover']
	],
	'ele_bg_hover_delay' => [
		'type' => 'spinner',
		'label' => __pl('ele_bg_hover_delay'),
		'min' => 0,
		'step' => 100,
		'max' => 5000,
		'default' => 400,
		'css' => '-webkit-transition: all {{val}}ms !important; transition: all {{val}}ms !important;',
		'req' => ['ele_bg_hover' => 'hover',
				'!ele_bg_type_hover' => '']
	],
	'ele_bg_color_hover' => [
		'type' => 'color',
		'label' => __pl('color_hover'),
		'css' => ['{{element}}:hover' => 'background: {{val}};'],
		'show' => ['ele_bg_hover' => 'hover'],
		'req' => ['ele_bg_type_hover' => 'color']
	],
	'ele_bg_gradient_hover' => [
		'type' => 'gradient',
		'label' => '',
		'default' => '150,#44d3f6,25,#72e584,75,#2ca4eb,100',
		'css' => ['{{element}}:hover' => 'background: linear-gradient({{val[0]}}deg, {{val[1]}} {{val[2]}}%, {{val[3]}} {{val[4]}}%, {{val[5]}} {{val[6]}}%);'],
		'show' => ['ele_bg_hover' => 'hover'],
		'req' => ['ele_bg_type_hover' => 'gradient']
	],
	'ele_bg_img_hover' => [
		'type' => 'image',
		'label' => __pl('Image Hover'),
		'css' => ['{{element}}:hover' => 'background: url("{{{ele_bg_img_hover-url}}}");'],
		'show' => ['ele_bg_hover' => 'hover'],
		'req' => ['ele_bg_type_hover' => 'image']
	],
	'ele_bg_attachment_hover' => [
		'type' => 'select',
		'label' => __pl('ele_bg_attachment_hover'),
		'list' => [
			'' => __pl('default'),
			'scroll' => __pl('scroll'),
			'fixed' => __pl('fixed')
		],
		'show' => ['ele_bg_hover' => 'hover'],
		'css' => ['{{element}}:hover' => 'background-attachment: {{val}};'],
		'req' => ['ele_bg_type_hover' => 'image']
	],
	'ele_bg_posx_hover' => [
		'type' => 'select',
		'label' => __pl('ele_bg_posx_hover'),
		'list' => [
			'' => __pl('default'),
			'center' => __pl('center'),
			'left' => __pl('left'),
			'right' => __pl('right')
		],
		'show' => ['ele_bg_hover' => 'hover'],
		'css' => ['{{element}}:hover' => 'background-position-x: {{val}};'],
		'req' => ['ele_bg_type_hover' => 'image']
	],
	'ele_bg_posy_hover' => [
		'type' => 'select',
		'label' => __pl('ele_bg_posy_hover'),
		'list' => [
			'' => __pl('default'),
			'center' => __pl('center'),
			'top' => __pl('top'),
			'bottom' => __pl('bottom')
		],
		'show' => ['ele_bg_hover' => 'hover'],
		'css' => ['{{element}}:hover' => 'background-position-y: {{val}};'],
		'req' => ['ele_bg_type_hover' => 'image']
	],
	'ele_bg_repeat_hover' => [
		'type' => 'select',
		'label' => __pl('ele_bg_repeat_hover'),
		'css' => ['{{element}}:hover' => 'background-repeat: {{val}};'],
		'list' => [
			'' => __pl('default'),
			'repeat' => __pl('repeat'),
			'no-repeat' => __pl('no-repeat'),
			'repeat-x' => __pl('repeat-x'),
			'repeat-y' => __pl('repeat-y'),
		],
		'show' => ['ele_bg_hover' => 'hover'],
		'req' => ['ele_bg_type_hover' => 'image']
	],
	'ele_bg_size_hover' => [
		'type' => 'select',
		'label' => __pl('ele_bg_size_hover'),
		'css' => ['{{element}}:hover' => 'background-size: {{val}};'],
		'list' => [
			'' => __pl('default'),
			'cover' => __pl('cover'),
			'contain' => __pl('contain')
		],
		'show' => ['ele_bg_hover' => 'hover'],
		'req' => ['ele_bg_type_hover' => 'image']
	]
];

$pagelayer->styles['ele_styles'] = [
	'ele_margin' => [
		'type' => 'padding',
		'label' => __pl('margin'),
		'screen' => 1,
		'units' => ['px', 'em', '%'],
		'css' => 'margin-top: {{val[0]}}; margin-right: {{val[1]}}; margin-bottom: {{val[2]}}; margin-left: {{val[3]}}',
	],
	'ele_padding' => [
		'type' => 'padding',
		'label' => __pl('padding'),
		'screen' => 1,
		'units' => ['px', 'em', '%'],
		'css' => 'padding-top: {{val[0]}}; padding-right: {{val[1]}}; padding-bottom: {{val[2]}}; padding-left: {{val[3]}}',
	],
	'ele_zindex' => [
		'type' => 'slider',
		'label' => __pl('z-index'),
		'css' => ['{{wrap}}' => 'z-index: {{val}} !important; position: relative;'],
	],
	'ele_shadow' => [
		'type' => 'box_shadow',
		'label' => __pl('shadow'),
		'css' => 'box-shadow: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[4]}}px {{val[3]}} {{val[5]}} !important;',
	],
	'border_shadow_hover' => [ // This is actually box shadow hover
		'type' => 'box_shadow',
		'label' => __pl('box_shadow_hover'),
		'css' => ['{{element}}:hover' => 'box-shadow: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[4]}}px {{val[3]}} {{val[5]}} !important;'],
	],
];

$pagelayer->styles['border_styles'] = [
	'border_hover' => [
		'type' => 'radio',
		'label' => '',
		'default' => '',
		//'no_val' => 1,// Dont set any value to element
		'list' => [
			'' => __pl('normal'),
			'hover' => __pl('hover'),
		],
	],
	'border_type' => [
		'type' => 'select',
		'label' => __pl('border_type'),
		'screen' => 1,
		'list' => [
			'' => __pl('none'),
			'solid' => __pl('solid'),
			'double' => __pl('double'),
			'dotted' => __pl('dotted'),
			'dashed' => __pl('dashed'),
			'groove' => __pl('groove'),
		],
		'show' => ['border_hover' => ''],
		'css' => 'border-style: {{val}}',
	],
	'border_width' => [
		'type' => 'padding',
		'label' => __pl('border_width'),
		'default' => '1,1,1,1',
		'units' => ['px', 'em'],
		'screen' => 1,
		'show' => [
			'border_hover' => ''
		],
		'req' => [
			'!border_type' => ''
		],
		'css' => 'border-top-width: {{val[0]}}; border-right-width: {{val[1]}}; border-bottom-width: {{val[2]}}; border-left-width: {{val[3]}}',
	],
	'border_color' => [
		'type' => 'color',
		'label' => __pl('border_color'),
		'default' => '#CCC',
		'screen' => 1,
		'show' => [
			'border_hover' => ''
		],
		'req' => [
			'!border_type' => ''
		],
		'css' => 'border-color: {{val}}',
	],
	'border_radius' => [
		'type' => 'padding',
		'label' => __pl('border_radius'),
		'units' => ['px', 'em'],
		'screen' => 1,
		'show' => ['border_hover' => ''],
		'css' => 'border-radius: {{val[0]}} {{val[1]}} {{val[2]}} {{val[3]}}; -webkit-border-radius: {{val[0]}} {{val[1]}} {{val[2]}} {{val[3]}};-moz-border-radius: {{val[0]}} {{val[1]}} {{val[2]}} {{val[3]}};',
	],
	'border_type_hover' => [
		'type' => 'select',
		'label' => __pl('border_type'),
		'screen' => 1,
		'list' => [
			'' => __pl('none'),
			'solid' => __pl('solid'),
			'double' => __pl('double'),
			'dotted' => __pl('dotted'),
			'dashed' => __pl('dashed'),
			'groove' => __pl('groove'),
		],
		'show' => ['border_hover' => 'hover'],
		'css' => ['{{element}}:hover' => 'border-style: {{val}}'],
	],
	'border_width_hover' => [
		'type' => 'padding',
		'label' => __pl('border_width'),
		'units' => ['px', 'em'],
		'screen' => 1,
		'show' => [
			'border_hover' => 'hover'
		],
		'req' => [
			'!border_type_hover' => ''
		],
		'css' => ['{{element}}:hover' => 'border-top-width: {{val[0]}}; border-right-width: {{val[1]}}; border-bottom-width: {{val[2]}}; border-left-width: {{val[3]}}'],
	],
	'border_color_hover' => [
		'type' => 'color',
		'label' => __pl('border_color'),
		'screen' => 1,
		'show' => [
			'border_hover' => 'hover'
		],
		'req' => [
			'!border_type_hover' => ''
		],
		'css' => ['{{element}}:hover' => 'border-color: {{val}}'],
	],
	'border_radius_hover' => [
		'type' => 'padding',
		'label' => __pl('border_radius'),
		'screen' => 1,
		'units' => ['px', 'em'],
		'show' => ['border_hover' => 'hover'],
		'css' => ['{{element}}:hover' => 'border-radius: {{val[0]}} {{val[1]}} {{val[2]}} {{val[3]}}; -webkit-border-radius:  {{val[0]}} {{val[1]}} {{val[2]}} {{val[3]}};-moz-border-radius: {{val[0]}} {{val[1]}} {{val[2]}} {{val[3]}};'],
	],
];

$pagelayer->styles['font_style'] = [
	'font_family' => [
		'type'=> 'font_family',
		'label' => __pl('font_family'),
		'screen' => 1,
		'css' => ['{{element}}' => 'font-family: {{val}} !important;'],
	],
	'font_size' => [
		'type' => 'spinner',
		'label' => __pl('font_size'),
		'screen' => 1,
		'min' => 0,
		'step' => 1,
		'max' => 200,
		'css' => ['{{element}}' => 'font-size: {{val}}px !important;'],
	],
	'font_style' => [
		'type' => 'select',
		'label' => __pl('font_style'),
		'screen' => 1,
		'css' => ['{{element}}' => 'font-style: {{val}} !important'],
		'list' => [
			'' => 'Default',
			'Normal' => 'Normal',
			'Italic' => 'Italic',
			'Oblique' => 'Oblique',
		],
	],
	'font_weight' => [
		'type' => 'select',
		'label' => __pl('font_weight'),
		'screen' => 1,
		'css' => ['{{element}}' => 'font-weight: {{val}} !important'],
		'list' => [
			'0' => 'Default',
			'100' => '100',
			'200' => '200',
			'300' => '300',
			'400' => '400',
			'500' => '500',
			'600' => '600',
			'700' => '700',
			'800' => '800',
			'900' => '900',
			'normal' => 'Normal',
			'lighter' => 'Lighter',
			'bold' => 'Bold',
			'bolder' => 'Bolder',
			'unset' => 'Unset',
		],
	],
	'font_variant' => [
		'type' => 'select',
		'label' => __pl('font_variant'),
		'screen' => 1,
		'css' => ['{{element}}' => 'font-variant: {{val}} !important'],
		'list' => [
			'' => 'Default',
			'Normal' => 'Normal',
			'Small-caps' => 'Small Caps',
		],
	],
	'font_decoration_line' => [
		'type' => 'select',
		'label' => __pl('decoration_line'),
		'screen' => 1,
		'css' => ['{{element}}' => 'text-decoration-line: {{val}} !important'],
		'list' => [
			'none' => 'None',
			'Overline' => 'Overline',
			'Line-through' => 'Line Through',
			'Underline' => 'Underline',
			'Underline Overline' => 'Underline Overline',
		],
	],
	'font_decoration_style' => [
		'type' => 'select',
		'label' => __pl('decoration_style'),
		'screen' => 1,
		'css' => ['{{element}}' => 'text-decoration-style: {{val}} !important'],
		'list' => [
			'' => __pl('none'),
			'solid' => __pl('solid'),
			'double' => __pl('double'),
			'dotted' => __pl('dotted'),
			'dashed' => __pl('dashed'),
			'wavy' => __pl('Wavy'),
		],
		'req' => [
			'!ele_font_decoration_line' => 'none',
		],
	],
	'line_height' => [
		'type' => 'spinner',
		'label' => __pl('line_height'),
		'screen' => 1,
		'min' => 0,
		'step' => 0.1,
		'max' => 15,
		'css' => ['{{element}}' => 'line-height: {{val}}em !important;'],
	],
	'text_transform' => [
		'type' => 'select',
		'label' => __pl('text_transform'),
		'screen' => 1,
		'css' => ['{{element}}' => 'text-transform: {{val}} !important'],
		'list' => [
			'' => 'Default',
			'Capitalize' => 'Capitalize',
			'Uppercase' => 'Uppercase',
			'Lowercase' => 'Lowercase',
		],
	],
	'text_spacing' => [
		'type' => 'spinner',
		'label' => __pl('text_spacing'),
		'screen' => 1,
		'min' => -10,
		'step' => 0.1,
		'max' => 10,
		'css' => ['{{element}}' => 'letter-spacing: {{val}}px !important;'],
	],
	'word_spacing' => [
		'type' => 'spinner',
		'label' => __pl('word_spacing'),
		'screen' => 1,
		'min' => 0,
		'step' => 1,
		'max' => 50,
		'css' => ['{{element}}' => 'word-spacing: {{val}}px !important;'],
	],
];

$pagelayer->styles['position_styles'] = [
	'ele_custom_pos' => array(
		'type' => 'checkbox',
		'label' => __pl('enable'),
	),
	'ele_width' => [
		'type' => 'select',
		'label' => __pl('width'),
		'screen' => 1,
		'css' => ['{{wrap}}' => 'width:{{val}} !important;'],
		'list' => [
			'initial' => __pl('default'),
			'100%' => __pl('full'),
			'' => __pl('custom'),
		],
		'req' => ['ele_custom_pos' => 'true']
	],
	'ele_custom_width' => [
		'type' => 'slider',
		'label' => __pl('custom_width'),
		'screen' => 1,
		'units' => ['px','%','vw'],
		'css' => ['{{wrap}}' => 'width:{{val}} !important;'],
		'min' => 0,
		'max' => 1000,
		'step' => 1,
		'req' => [
			'ele_width' => '',
			'ele_custom_pos' => 'true'
		]
	],
	'ele_align' => [
		'type' => 'select',
		'label' => __pl('alignment'),
		'default' => 'margin',
		'screen' => 1,
		'css' => ['{{wrap}}' => 'position:relative; left:{{val}}; transform:translateX(-{{val}});'],
		'list' => [
			'0%' => __pl('left'),
			'50%' => __pl('center'),
			'100%' => __pl('right'),
		],
		'req' => [
			'ele_width' => '',
			'ele_custom_pos' => 'true'
		]
	],
	'ele_height' => [
		'type' => 'select',
		'label' => __pl('height'),
		'screen' => 1,
		'default' => 'auto',
		'css' => ['{{wrap}}' => 'height:{{val}};'],
		'list' => [
			'auto' => __pl('default'),
			'100%' => __pl('full'),
			'' => __pl('custom'),
		],
		'req' => ['ele_custom_pos' => 'true']
	],
	'ele_custom_height' => [
		'type' => 'slider',
		'label' => __pl('custom_height'),
		'screen' => 1,
		'units' => ['px','%','vh'],
		'css' => ['{{wrap}}' => 'height:{{val}};'],
		'min' => 0,
		'max' => 1000,
		'step' => 1,
		'req' => [
			'ele_height' => '',
			'ele_custom_pos' => 'true'
		]
	],
	'ele_position' => [
		'type' => 'select',
		'label' => __pl('position'),
		'default' => '',
		'screen' => 1,
		'css' => ['{{wrap}}' => 'position:{{val}} !important; z-index: 1; transform: translateX(-0%);'],
		'list' => [
			'' => __pl('default'),
			'absolute' => __pl('absolute'),
			'fixed' => __pl('fixed'),
			'relative' => __pl('relative'),
		],
		'req' => ['ele_custom_pos' => 'true']
	],
	'ele_vposition' => [
		'type' => 'select',
		'label' => __pl('verticle_pos'),
		'screen' => 1,
		'css' => ['{{wrap}}' => '{{val}}:0;'],
		'list' => [
			'' => __pl('default'),
			'top' => __pl('top'),
			'bottom' => __pl('bottom')
		],
		'req' => [
			'!ele_position' => '',
			'ele_custom_pos' => 'true'
		]
	],
	'ele_vposition_offset' => [
		'type' => 'slider',
		'label' => __pl('ver_offset'),
		'screen' => 1,
		'units' => ['px','%','em'],
		'css' => ['{{wrap}}' => '{{ele_vposition}}:{{val}};'],
		'default' => 0,
		'min' => -1000,
		'max' => 1000,
		'step' => 1,
		'req' => [
			'!ele_vposition' => '',
			'!ele_position' => '',
			'ele_custom_pos' => 'true'
		]
	],
	'ele_hposition' => [
		'type' => 'select',
		'label' => __pl('horizontal_pos'),
		'screen' => 1,
		'css' => ['{{wrap}}' => '{{val}}:0;'],
		'list' => [
			'' => __pl('default'),
			'left' => __pl('left'),
			'right' => __pl('right')
		],
		'req' => [
			'!ele_position' => '',
			'ele_custom_pos' => 'true'
		]
	],
	'ele_hposition_offset' => [
		'type' => 'slider',
		'label' => __pl('hor_offset'),
		'screen' => 1,
		'units' => ['px','%','em'],
		'css' => ['{{wrap}}' => '{{ele_hposition}}:{{val}};'],
		'default' => 0,
		'min' => -1000,
		'max' => 1000,
		'step' => 1,
		'req' => [
			'!ele_hposition' => '',
			'!ele_position' => '',
			'ele_custom_pos' => 'true'
		]
	]
];

$pagelayer->styles['animation_styles'] = [
	'animation' => [
		'type' => 'select',
		'label' => __pl('animation'),
		'default' => '',
		'addClass' => ['{{val}}',( !pagelayer_is_live() ? 'pagelayer-wow' : '' )],
		'list' => $pagelayer->anim_in_options
	],
	'animation_speed' => [
		'type' => 'select',
		'label' => __pl('animate_speed'),
		'default' => '',
		'addClass' => 'pagelayer-anim-{{val}}',
		'list' => [
			'' => __pl('normal'),
			'fast' => __pl('fast'),
			'slow' => __pl('slow'),
			'fastest' => __pl('fastest'),
			'slowest' => __pl('slowest'),
		],
		'req' => [
			'!animation' => ''
		]
	],
	'animation_delay' => [
		'type' => 'spinner',
		'label' => __pl('animation_delay'),
		'css' => '-webkit-animation-delay: {{val}}ms; animation-delay: {{val}}ms;',
		'default' => 600,
		'min' => 0,
		'max' => 90000,
		'step' => 100,
		'req' => [
			'!animation' => ''
		]
	],
	'ele_hover_anim' => array(
		'type' => 'select',
		'label' => __pl('cta_hover_anim_label'),
		'addClass' => 'pagelayer-animation-{{val}}',
		'list' => [
			'' => __pl('none'),
			'grow' => __pl('Grow'),
			'shrink' => __pl('Shrink'),
			'pulse' => __pl('Pulse'),
			'pulse-grow' => __pl('Pulse Grow'),
			'pulse-shrink' => __pl('Pulse Shrink'),
			'push' => __pl('Push'),
			'pop' => __pl('Pop'),
			'buzz' => __pl('Buzz'),
			'buzz-out' => __pl('Buzz Out'),
			'float' => __pl('Float'),
			'sink' => __pl('Sink'),
			'bob' => __pl('Bob'),
			'hang' => __pl('Hang'),
			'bounce-in' => __pl('Bounce In'),
			'bounce-out' => __pl('Bounce Out'),
			'rotate' => __pl('Rotate'),
			'grow-rotate' => __pl('Grow Rotate'),
			'skew-forward' => __pl('Skew Forward'),
			'skew-backward' => __pl('Skew Backward'),
			'wobble-vertical' => __pl('Wobble Vertical'),
			'wobble-horizontal' => __pl('Wobble Horizontal'),
			'wobble-bottom-to-right' => __pl('Wobble Bottom To Right'),
			'wobble-top-to-right' => __pl('Wobble Top To Right'),
			'wobble-top' => __pl('Wobble Top'),
			'wobble-bottom' => __pl('Wobble Bottom'),
			'wobble-skew' => __pl('Wobble Skew'),
		],
		'pro' => 1,
	),
	'ele_sticky_pos' => array(
		'type' => 'select',
		'label' => __pl('scroll_sticky'),
		'addClass' => 'pagelayer-sticky-ele',
		'addAttr' => 'data-sticky-position="{{ele_sticky_pos}}"',
		'list' => array(
			'' => __pl('none'),
			'top' => __pl('top'),
			'bottom' => __pl('bottom'),
		),
		'pro' => 1,
	),
	'ele_sticky_on' => array(
		'type' => 'multiselect',
		'label' => __pl('sticky_on'),
		'default' => 'desktop,tablet,mobile',
		'addAttr' => 'data-sticky-on="{{ele_sticky_on}}"',
		'list' => array(
			'desktop' => __pl('desktop'),
			'tablet' => __pl('tablet'),
			'mobile' => __pl('mobile'),
		),
		'req' => [ '!ele_sticky_pos' => ''],
		'pro' => 1,
	),
	'ele_sticky_offset' => array(
		'type' => 'slider',
		'label' => __pl('offset'),
		'addAttr' => 'data-sticky-offset="{{ele_sticky_offset}}"',
		'req' => [ '!ele_sticky_pos' => ''],
		'pro' => 1,
	),
	'ele_sticky_in_col' => array(
		'type' => 'checkbox',
		'label' => __pl('sticky_in_col'),
		'addAttr' => 'data-sticky_in_col="{{ele_sticky_in_col}}"',
		'req' => [ '!ele_sticky_pos' => ''],
		'pro' => 1,
	),
];

$pagelayer->styles['motion_effects'] = [
	'ele_motion_effects' => [
		'type' => 'radio',
		'label' => '',
		'list' => [
			'' => __pl('Scrolling'),
			'mouse' => __pl('Mouse'),
		],
	],
	'ele_scrolling_effects' => array(
		'type' => 'checkbox',
		'label' => __pl('Scrolling Effects'),
		'addClass' => 'pagelayer-scrolling-effects',
		'show' => ['ele_motion_effects' => ''],
		'pro' => 1
	),
	// Vertical Scroll Group
	'ele_vertical_scroll_group' => array(
		'type' => 'access',
		'label' => __pl('Vertical Scroll'),
		'show_group' => 'scrolling_v',
		'req' => ['!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	// Vertical Scroll Settings
	'ele_vertical_scroll' => array(
		'type' => 'checkbox',
		'label' => __pl('Enable'),
		'group' => 'scrolling_v',
		'addAttr' => 'ele_vertical_scroll="{{ele_vertical_scroll}}"',
		'req' => ['!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	'ele_v_sc_direction' => array(
		'type' => 'select',
		'label' => __pl('Direction'),
		'group' => 'scrolling_v',
		'default' => 'opposite',
		'list' => array(
			'opposite' => __pl('Opposite'),
			'similar' => __pl('Similar'),
		),
		'addAttr' => 'ele_v_sc_direction="{{ele_v_sc_direction}}"',
		'req' => ['!ele_vertical_scroll' => '', '!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	'ele_v_sc_speed' => array(
		'type' => 'slider',
		'label' => __pl('speed'),
		'group' => 'scrolling_v',
		'min' => 0,
		'step' => 0.1,
		'max' => 10,
		'default' => 5,
		'addAttr' => 'ele_v_sc_speed="{{ele_v_sc_speed}}"',
		'req' => [ '!ele_vertical_scroll' => '', '!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	'ele_v_sc_top_viewport' => array(
		'type' => 'slider',
		'label' => __pl('Top'),
		'group' => 'scrolling_v',
		'min' => 0,
		'step' => 1,
		'max' => 100,
		'default' => 100,
		'screen' => 1,
		'addAttr' => 'ele_v_sc_top_viewport="{{ele_v_sc_top_viewport}}"',
		'req' => [ '!ele_vertical_scroll' => '', '!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	'ele_v_sc_bottom_viewport' => array(
		'type' => 'slider',
		'label' => __pl('bottom'),
		'group' => 'scrolling_v',
		'min' => 0,
		'step' => 1,
		'max' => 100,
		'default' => 100,
		'screen' => 1,	
		'addAttr' => 'ele_v_sc_bottom_viewport="{{ele_v_sc_bottom_viewport}}"',
		'req' => [ '!ele_vertical_scroll' => '', '!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	//Horizontal Group
	'ele_horizontal_scroll_group' => array(
		'type' => 'access',
		'label' => __pl('Horizontal Scroll'),
		'show_group' => 'scrolling_h',
		'req' => ['!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	// Horizontal Scroll
	'ele_horizontal_scroll' => array(
		'type' => 'checkbox',
		'label' => __pl('Enable'),
		'group' => 'scrolling_h',
		'css' => 'transform:translateX(var(--transX));',
		'addAttr' => 'ele_horizontal_scroll="{{ele_horizontal_scroll}}"',
		'req' => ['!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	'ele_h_sc_direction' => array(
		'type' => 'select',
		'label' => __pl('Direction'),
		'group' => 'scrolling_h',
		'default' => 'toleft',
		'list' => array(
			'toleft' => __pl('Toleft'),
			'toright' => __pl('Toright'),
		),
		'addAttr' => 'ele_h_sc_direction="{{ele_h_sc_direction}}"',
		'req' => ['!ele_horizontal_scroll' => '', '!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	'ele_h_sc_speed' => array(
		'type' => 'slider',
		'label' => __pl('speed'),
		'group' => 'scrolling_h',
		'min' => 0,
		'step' => 0.1,
		'max' => 10,
		'default' => 5,
		'addAttr' => 'ele_h_sc_speed="{{ele_h_sc_speed}}"',
		'req' => [ '!ele_horizontal_scroll' => '', '!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	'ele_h_sc_left_viewport' => array(
		'type' => 'slider',
		'label' => __pl('Left'),
		'group' => 'scrolling_h',
		'min' => 0,
		'step' => 1,
		'max' => 100,
		'default' => 100,
		'screen' => 1,
		'addAttr' => 'ele_h_sc_left_viewport="{{ele_h_sc_left_viewport}}"',
		'req' => [ '!ele_horizontal_scroll' => '', '!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	'ele_h_sc_right_viewport' => array(
		'type' => 'slider',
		'label' => __pl('Right'),
		'group' => 'scrolling_h',
		'min' => 0,
		'step' => 1,
		'max' => 100,
		'default' => 100,
		'screen' => 1,	
		'addAttr' => 'ele_h_sc_right_viewport="{{ele_h_sc_right_viewport}}"',
		'req' => [ '!ele_horizontal_scroll' => '', '!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	// Transparency Group
	'ele_transparency_group' => array(
		'type' => 'access',
		'label' => __pl('Transparency'),
		'show_group' => 'scrolling_trans',
		'req' => ['!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	// Transparency Settings
	'ele_transparency' => array(
		'type' => 'checkbox',
		'label' => __pl('Enable'),
		'group' => 'scrolling_trans',
		'addAttr' => 'ele_transparency="{{ele_transparency}}"',
		'req' => ['!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	'ele_transp_type' => array(
		'type' => 'select',
		'label' => __pl('Type'),
		'group' => 'scrolling_trans',
		'default' => 'fadein',
		'list' => array(
			'fadein' => __pl('Fade In'),
			'fadeout' => __pl('Fade Out'),
			'fadeinout' => __pl('Fade In Out'),
			'fadeoutin' => __pl('Fade Out In')
		),
		'addAttr' => 'ele_transp_type="{{ele_transp_type}}"',
		'req' => ['!ele_transparency' => '', '!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	'ele_transp_level' => array(
		'type' => 'slider',
		'label' => __pl('Level'),
		'group' => 'scrolling_trans',
		'min' => 1,
		'step' => 0.1,
		'max' => 10,
		'default' => 5,
		'addAttr' => 'ele_transp_level="{{ele_transp_level}}"',
		'req' => [ '!ele_transparency' => '', '!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	'ele_transp_top_viewport' => array(
		'type' => 'slider',
		'label' => __pl('top'),
		'group' => 'scrolling_trans',
		'min' => 0,
		'step' => 1,
		'max' => 100,
		'default' => 100,
		'screen' => 1,
		'addAttr' => 'ele_transp_top_viewport="{{ele_transp_top_viewport}}"',
		'req' => [ '!ele_transparency' => '', '!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	'ele_transp_bottom_viewport' => array(
		'type' => 'slider',
		'label' => __pl('bottom'),
		'group' => 'scrolling_trans',
		'min' => 0,
		'step' => 1,
		'max' => 100,
		'default' => 100,
		'screen' => 1,	
		'addAttr' => 'ele_transp_bottom_viewport="{{ele_transp_bottom_viewport}}"',
		'req' => [ '!ele_transparency' => '', '!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	// Blur Group
	'ele_blur_group' => array(
		'type' => 'access',
		'label' => __pl('Blur'),
		'show_group' => 'scrolling_blur',
		'req' => ['!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	// Blur Setting
	'ele_blur' => array(
		'type' => 'checkbox',
		'label' => __pl('Enable'),
		'group' => 'scrolling_blur',
		'addAttr' => 'ele_blur="{{ele_blur}}"',
		'req' => ['!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	'ele_blur_type' => array(
		'type' => 'select',
		'label' => __pl('Type'),
		'group' => 'scrolling_blur',
		'default' => 'blurin',
		'list' => array(
			'blurin' => __pl('Blur In'),
			'blurout' => __pl('Blur Out'),
			'blurinout' => __pl('Blur In Out'),
			'bluroutin' => __pl('Blur Out In')
		),
		'addAttr' => 'ele_blur_type="{{ele_blur_type}}"',
		'req' => ['!ele_blur' => '', '!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	'ele_blur_level' => array(
		'type' => 'slider',
		'label' => __pl('Level'),
		'group' => 'scrolling_blur',
		'min' => 1,
		'step' => 0.1,
		'max' => 10,
		'default' => 5,
		'addAttr' => 'ele_blur_level="{{ele_blur_level}}"',
		'req' => [ '!ele_blur' => '', '!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	'ele_blur_top_viewport' => array(
		'type' => 'slider',
		'label' => __pl('top'),
		'group' => 'scrolling_blur',
		'min' => 0,
		'step' => 1,
		'max' => 100,
		'default' => 100,
		'screen' => 1,
		'addAttr' => 'ele_blur_top_viewport="{{ele_blur_top_viewport}}"',
		'req' => [ '!ele_blur' => '', '!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	'ele_blur_bottom_viewport' => array(
		'type' => 'slider',
		'label' => __pl('bottom'),
		'group' => 'scrolling_blur',
		'min' => 0,
		'step' => 1,
		'max' => 100,
		'default' => 100,
		'screen' => 1,	
		'addAttr' => 'ele_blur_bottom_viewport="{{ele_blur_bottom_viewport}}"',
		'req' => [ '!ele_blur' => '', '!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	// Rotate Group
	'ele_rotate_group' => array(
		'type' => 'access',
		'label' => __pl('Rotate'),
		'show_group' => 'scrolling_rotate',
		'req' => ['!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	// Rotate Setting
	'ele_rotate' => array(
		'type' => 'checkbox',
		'label' => __pl('Enable'),
		'group' => 'scrolling_rotate',
		'addAttr' => 'ele_rotate="{{ele_rotate}}"',
		'req' => ['!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	'ele_rot_direction' => array(
		'type' => 'select',
		'label' => __pl('Direction'),
		'group' => 'scrolling_rotate',
		'default' => 'clockwise',
		'list' => array(
			'clockwise' => __pl('Clockwise'),
			'anticlockwise' => __pl('Anticlockwise')
		),
		'addAttr' => 'ele_rot_direction="{{ele_rot_direction}}"',
		'req' => ['!ele_rotate' => '', '!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	'ele_rot_speed' => array(
		'type' => 'slider',
		'label' => __pl('Speed'),
		'group' => 'scrolling_rotate',
		'min' => 1,
		'step' => 0.1,
		'max' => 10,
		'default' => 5,
		'addAttr' => 'ele_rot_speed="{{ele_rot_speed}}"',
		'req' => [ '!ele_rotate' => '', '!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	'ele_rot_top_viewport' => array(
		'type' => 'slider',
		'label' => __pl('top'),
		'group' => 'scrolling_rotate',
		'min' => 0,
		'step' => 1,
		'max' => 100,
		'default' => 100,
		'screen' => 1,
		'addAttr' => 'ele_rot_top_viewport="{{ele_rot_top_viewport}}"',
		'req' => [ '!ele_rotate' => '', '!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	'ele_rot_bottom_viewport' => array(
		'type' => 'slider',
		'label' => __pl('bottom'),
		'group' => 'scrolling_rotate',
		'min' => 0,
		'step' => 1,
		'max' => 100,
		'default' => 100,
		'screen' => 1,	
		'addAttr' => 'ele_rot_bottom_viewport="{{ele_rot_bottom_viewport}}"',
		'req' => [ '!ele_rotate' => '', '!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	'ele_rot_x_anc_point' => array(
		'type' => 'select',
		'label' => __pl('X Anchor Point'),
		'group' => 'scrolling_rotate',
		'default' => 'center',
		'list' => array(
			'left' => __pl('Left'),
			'center' => __pl('Center'),
			'right' => __pl('Right')
		),
		'req' => ['!ele_rotate' => '', '!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	'ele_rot_y_anc_point' => array(
		'type' => 'select',
		'label' => __pl('Y Anchor Point'),
		'group' => 'scrolling_rotate',
		'default' => 'center',
		'list' => array(
			'top' => __pl('Top'),
			'center' => __pl('Center'),
			'bottom' => __pl('Bottom')
		),
		'css' => 'transform-origin:{{val}} {{ele_rot_x_anc_point}}',
		'req' => ['!ele_rotate' => '', '!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	// Scale Group
	'ele_scale_group' => array(
		'type' => 'access',
		'label' => __pl('Scale'),
		'show_group' => 'scrolling_scale',
		'req' => ['!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	// Scale Setting
	'ele_scale' => array(
		'type' => 'checkbox',
		'label' => __pl('Enable'),
		'group' => 'scrolling_scale',
		'addAttr' => 'ele_scale="{{ele_scale}}"',
		'req' => ['!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	'ele_scl_direction' => array(
		'type' => 'select',
		'label' => __pl('Direction'),
		'group' => 'scrolling_scale',
		'default' => 'scaleup',
		'list' => array(
			'scaleup' => __pl('Scale Up'),
			'scaledown' => __pl('Scale Down'),
			'scaleupdown' => __pl('Scale Up Down'),
			'scaledownup' => __pl('Scale Down Up')
		),
		'addAttr' => 'ele_scl_direction="{{ele_scl_direction}}"',
		'req' => ['!ele_scale' => '', '!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	'ele_scl_level' => array(
		'type' => 'slider',
		'label' => __pl('Level'),
		'group' => 'scrolling_scale',
		'min' => 1,
		'step' => 0.1,
		'max' => 10,
		'default' => 5,
		'addAttr' => 'ele_scl_level="{{ele_scl_level}}"',
		'req' => [ '!ele_scale' => '', '!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	'ele_scl_top_viewport' => array(
		'type' => 'slider',
		'label' => __pl('top'),
		'group' => 'scrolling_scale',
		'min' => 0,
		'step' => 1,
		'max' => 100,
		'default' => 100,
		'screen' => 1,
		'addAttr' => 'ele_scl_top_viewport="{{ele_scl_top_viewport}}"',
		'req' => [ '!ele_scale' => '', '!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	'ele_scl_bottom_viewport' => array(
		'type' => 'slider',
		'label' => __pl('bottom'),
		'group' => 'scrolling_scale',
		'min' => 0,
		'step' => 1,
		'max' => 100,
		'default' => 100,
		'screen' => 1,	
		'addAttr' => 'ele_scl_bottom_viewport="{{ele_scl_bottom_viewport}}"',
		'req' => [ '!ele_scale' => '', '!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	'ele_scl_x_anc_point' => array(
		'type' => 'select',
		'label' => __pl('X Anchor Point'),
		'group' => 'scrolling_scale',
		'default' => 'center',
		'list' => array(
			'left' => __pl('Left'),
			'center' => __pl('Center'),
			'right' => __pl('Right')
		),
		'req' => ['!ele_scale' => '', '!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	'ele_scl_y_anc_point' => array(
		'type' => 'select',
		'label' => __pl('Y Anchor Point'),
		'group' => 'scrolling_scale',
		'default' => 'center',
		'list' => array(
			'top' => __pl('Top'),
			'center' => __pl('Center'),
			'bottom' => __pl('Bottom')
		),
		'css' => 'transform-origin:{{val}} {{ele_scl_x_anc_point}}',
		'req' => ['!ele_scale' => '', '!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	// Motion Area Selection
	'motion_area' => array(
		'type' => 'select',
		'label' => __pl('Effect Relative To'),
		'default' => 'viewport',
		'list' => array(
			'viewport' => __pl('Viewport'),
			'entire_page' => __pl('Entire Page'),
		),
		'addAttr' => 'motion_area="{{motion_area}}"',
		'req' => ['!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => '']
	),
	// Motion Effect Screen Selection
	'ele_motion_effect_on' => array(
		'type' => 'multiselect',
		'label' => __pl('Apply Effects On'),
		'default' => 'desktop,tablet,mobile',
		'addAttr' => 'ele_motion_effect_on="{{ele_motion_effect_on}}"',
		'list' => array(
			'desktop' => __pl('desktop'),
			'tablet' => __pl('tablet'),
			'mobile' => __pl('mobile'),
		),
		'req' => ['!ele_scrolling_effects' => ''],
		'show' => ['ele_motion_effects' => ''],
		'pro' => 1,
	),
	// Mouse Effect
	'ele_mouse_effects' => array(
		'type' => 'checkbox',
		'label' => __pl('Mouse Effects'),
		'addClass' => 'pagelayer-mouse-effects',
		'show' => ['ele_motion_effects' => 'mouse'],
		'pro' => 1
	),
	// Mouse Track Group
	'ele_m_track_group' => array(
		'type' => 'access',
		'label' => __pl('Mouse Track'),
		'show_group' => 'mouse_track',
		'req' => ['!ele_mouse_effects' => ''],
		'show' => ['ele_motion_effects' => 'mouse']
	),
	// Mouse Track Setting
	'ele_m_track' => array(
		'type' => 'checkbox',
		'label' => __pl('Enable'),
		'group' => 'mouse_track',
		'addAttr' => 'ele_m_track="{{ele_m_track}}"',
		'req' => ['!ele_mouse_effects' => ''],
		'show' => ['ele_motion_effects' => 'mouse']
	),
	'ele_m_tr_direction' => array(
		'type' => 'select',
		'label' => __pl('Direction'),
		'group' => 'mouse_track',
		'default' => 'opposite',
		'list' => array(
			'opposite' => __pl('Opposite'),
			'same' => __pl('Same')
		),
		'addAttr' => 'ele_m_tr_direction="{{ele_m_tr_direction}}"',
		'req' => ['!ele_m_track' => '', '!ele_mouse_effects' => ''],
		'show' => ['ele_motion_effects' => 'mouse']
	),
	'ele_m_tr_level' => array(
		'type' => 'slider',
		'label' => __pl('Level'),
		'group' => 'mouse_track',
		'min' => 1,
		'step' => 0.1,
		'max' => 10,
		'default' => 5,
		'addAttr' => 'ele_m_tr_level="{{ele_m_tr_level}}"',
		'req' => [ '!ele_m_track' => '', '!ele_mouse_effects' => ''],
		'show' => ['ele_motion_effects' => 'mouse']
	),
	// 3D Tilt Group
	'ele_3d_tilt_group' => array(
		'type' => 'access',
		'label' => __pl('3D Tilt'),
		'show_group' => 'mouse_3d',
		'req' => ['!ele_mouse_effects' => ''],
		'show' => ['ele_motion_effects' => 'mouse']
	),
	// 3D Tilt Setting
	'ele_3d_tilt' => array(
		'type' => 'checkbox',
		'label' => __pl('Enable'),
		'group' => 'mouse_3d',
		'addAttr' => 'ele_3d_tilt="{{ele_3d_tilt}}"',
		'css' => 'will-change:transform; transform-style:preserve-3d;',
		'req' => ['!ele_mouse_effects' => ''],
		'show' => ['ele_motion_effects' => 'mouse']
	),
	'ele_3d_tilt_direction' => array(
		'type' => 'select',
		'label' => __pl('Direction'),
		'group' => 'mouse_3d',
		'default' => 'opposite',
		'list' => array(
			'opposite' => __pl('Opposite'),
			'same' => __pl('Same')
		),
		'addAttr' => 'ele_3d_tilt_direction="{{ele_3d_tilt_direction}}"',
		'req' => ['!ele_3d_tilt' => '', '!ele_mouse_effects' => ''],
		'show' => ['ele_motion_effects' => 'mouse']
	),
	'ele_3d_tilt_level' => array(
		'type' => 'slider',
		'label' => __pl('Level'),
		'group' => 'mouse_3d',
		'min' => 1,
		'step' => 0.1,
		'max' => 10,
		'default' => 5,
		'addAttr' => 'ele_3d_tilt_level="{{ele_3d_tilt_level}}"',
		'req' => [ '!ele_3d_tilt' => '', '!ele_mouse_effects' => ''],
		'show' => ['ele_motion_effects' => 'mouse']
	)
];

// Resposive stuff
$pagelayer->styles['responsive_styles'] = [
	'hide_desktop' => [
		'type' => 'checkbox',
		'label' => __pl('hide_desktop'),
		'addClass' => 'pagelayer-hide-desktop'
	],
	'hide_tablet' => [
		'type' => 'checkbox',
		'label' => __pl('hide_tablet'),
		'addClass' => 'pagelayer-hide-tablet'
	],
	'hide_mobile' => [
		'type' => 'checkbox',
		'label' => __pl('hide_mobile'),
		'addClass' => 'pagelayer-hide-mobile'
	],
];

// Custom attributes
$pagelayer->styles['attributes'] = [
	'ele_attributes' => [
		'type' => 'textarea',
		'label' => __pl('custom_attributes'),
		'rows' => 5,
		'pro' => 1,
		'desc' => __pl('attribute_desc')
	],
];

// Custom stuff
$pagelayer->styles['custom_styles'] = [
	'ele_id' => [
		'type' => 'text',
		'label' => __pl('ele_id'),
		'desc' => __pl('ele_id_desc'),
		'addAttr' => 'id="{{ele_id}}"',
	],
	'ele_classes' => [
		'type' => 'text',
		'label' => __pl('ele_classes'),
		'desc' => __pl('ele_classes_desc'),
		'addClass' => '{{val}}',
	],
	'ele_css' => [
		'type' => 'textarea',
		'label' => __pl('custom_styles'),
		'desc' => __pl('ele_css_desc'),
		'rows' => 5,
		'css' => ['' => '{{val}}'],
		'pro' => 1
	],
];


////////////////////////
// GRID Group
////////////////////////

// ROW object
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_row', array(
		'name' => __pl('row'),
		'group' => 'grid',
		'skip_props_cat' => ['position_styles'],
		'skip_props' => ['ele_sticky_in_container'],
		'html' => '<div if="{{bg_video_src}}" class="pagelayer-background-video">{{vid_src}}</div>
			<div if="{{bg_slider}}" class="pagelayer-bgimg-slider">
				{{slider}}
			</div>
			<div if="{{parallax_img}}" class="pagelayer-parallax-window">
				<img class="pagelayer-img" src="{{parallax_img_src}}" title="{{{parallax_img-title}}}" alt="{{{parallax_img-alt}}}">
			</div>
			<div if="{{row_shape_position}}" class="pagelayer-row-shape">
				<div class="pagelayer-row-svg">
					<svg if="{{row_shape_type_top}}" class="pagelayer-svg-top">{{svg_top}}</svg>
					<svg if="{{row_shape_type_bottom}}" class="pagelayer-svg-bottom">{{svg_bottom}}</svg>						
				</div>
			</div>
			<div if="{{overlay_type}}" class="pagelayer-background-overlay"></div>
			<div class="pagelayer-row-holder pagelayer-row pagelayer-auto pagelayer-width-{{width_content}}"></div>',
		'holder' => '.pagelayer-row-holder',
		'params' => array(
			'stretch' => array(
				'type' => 'select',
				'label' => __pl('con_width'),
				'default' => 'auto',
				'list' => array(
					'auto' => __pl('auto'),
					'full' => __pl('full_width'),
					'fixed' => __pl('fixed_width')
				),
				'addClass' => 'pagelayer-row-stretch-{{val}}'
			),
			'row_width' => array(
				'type' => 'slider',
				'label' => __pl('row_width'),
				'default' => 500,
				'min' => 300,
				'max' => 3000,
				'step' => 1,
				'units' => [ 'px', '%', 'vw' ],
				'css' => ['{{element}}' => 'max-width: {{val}}; margin-left: auto !important; margin-right: auto !important;'],
				'req' => array(
					'stretch' => 'fixed'
				)
			),
			'col_gap' => array(
				'type' => 'spinner',
				'label' => __pl('col_gap'),
				'default' => 10,
				'min' => 0,
				'step' => 1,
				'screen' => 1,
				'max' => 1000,
				'css' => ['{{element}} .pagelayer-col-holder' => 'padding: {{val}}px;'],
			),
			'width_content' => array(
				'type' => 'radio',
				'label' => __pl('Content Width'),
				'default' => 'auto',
				'list' => array(
					'auto' => __pl('auto_width'),
					'fixed' => __pl('fixed_width'),
					'full' => __pl('full_width')
				)
			),
			'fixed_width' => array(
				'type' => 'slider',
				'label' => __pl('fixed_con_width'),
				'default' => 500,
				'min' => 1,
				'max' => 3000,
				'screen' => 1,
				'units' => [ 'px', '%', 'vw' ],
				'css' => ['{{element}}>.pagelayer-row-holder' => 'max-width: {{val}}; margin-left: auto; margin-right: auto;'],
				'req' => array(
					'width_content' => 'fixed'
				)
			),
			'row_height' => array(
				'type' => 'radio',
				'label' => __pl('row_height'),
				'default' => 'default',
				'addClass' => 'pagelayer-height-{{val}}',
				'list' => array(
					'default' => __pl('default'),
					'fit' => __pl('fit_to_screen'),
					'custom' => __pl('min_height')
				),
			),
			'min_height' => array(
				'type' => 'slider',
				'label' => __pl('min_height'),
				'min' => 0,
				'max' => 2000,
				'screen' => 1,
				'units' => ['px', 'vh', 'vw'],
				'css' => 'min-height: {{val}};',
				'req' => array(
					'row_height' => 'custom'
				)
			),
			'content_pos' => array(
				'type' => 'select',
				'label' => __pl('content_pos'),
				'css' => ['{{element}}>.pagelayer-row-holder .pagelayer-col' => 'align-content: {{val}};'],
				'list' => array(
					'' => __pl('default'),
					'flex-start' => __pl('top'),
					'center' => __pl('center'),
					'flex-end' => __pl('bottom'),
				),
			),
		),
		'row_bg_styles' => [
			'row_bg_type' => array(
				'type' => 'radio',
				'label' => __pl('row_bg_type'),
				'list' => array(
					'' => __pl('none'),
					'video' => __pl('video'),
					'parallax' => __pl('parallax'),
					'slider' => __pl('slider'),
				),
			),
			'bg_video_src' => array(
				'type' => 'video',
				'label' => __pl('video_src_label'),
				'desc' => __pl('video_src_desc'),
				'req' => ['row_bg_type' => 'video']
			),
			'mute' => array(
				'type' => 'checkbox',
				'label' => __pl('mute'),
				'req' => ['row_bg_type' => 'video']				
			),			
			'stop_loop' => array(
				'type' => 'checkbox',
				'label' => __pl('stop_loop'),
				'req' => ['row_bg_type' => 'video']
			),
			'parallax_img' => array(
				'type' => 'image',
				'label' => __pl('Image'),
				'req' => ['row_bg_type' => 'parallax']
			),
			'parallax_align' => array(
				'type' => 'radio',
				'label' => __pl('obj_align_label'),
				'screen' => 1,
				'default' => 'center',
				'css' => ['{{element}} .pagelayer-parallax-window' => 'text-align: {{val}}'],
				'list' => array(
					'left' => __pl('left'),
					'center' => __pl('center'),
					'right' => __pl('right')
				),
				'req' => ['row_bg_type' => 'parallax']
			),
			'parallax_id_size' => array(
				'label' => __pl('obj_image_size_label'),
				'type' => 'select',
				'default' => 'full',
				'list' => array(
					'full' => __pl('full'),
					'large' => __pl('large'),
					'medium' => __pl('medium'),
					'thumbnail' => __pl('thumbnail'),
					'custom' => __pl('custom')
				),
				'req' => ['row_bg_type' => 'parallax']
			),
			'parallax_custom_size' => array(
				'type' => 'dimension',
				'label' => __pl('image_custom_size_label'),
				'css' => ['{{element}} .pagelayer-parallax-window img' => 'width: {{val[0]}}px; height: {{val[1]}}px;'],
				'req' => [
					'parallax_id_size' => 'custom',
					'row_bg_type' => 'parallax'
				],
			),
			'parallax_max_width' => array(
				'label' => __pl('max-width-percent'),
				'type' => 'slider',
				'min' => 0,
				'max' => 100,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-parallax-window img' => 'max-width: {{val}}%'],
				'req' => ['row_bg_type' => 'parallax']
			),
			'bg_slider' => array(
				'type' => 'multi_image',
				'label' => __pl('image_slider_ids_label'),
				'req' => ['row_bg_type' => 'slider'],
				'pro' => 1
			),
			'bg_slider_speed' => array(
				'type' => 'spinner',
				'label' => __pl('speed_ms'),
				'default' => 2000,
				'min' => 200,
				'max' => 50000,
				'step' => 100,
				'addAttr' => ['{{element}} .pagelayer-bgimg-slider' => 'data-speed="{{bg_slider_speed}}"'],
				'req' => [
					'row_bg_type' => 'slider'
				],
				'pro' => 1
			),
		],
		'row_bg_overlay' => [
			'overlay_state' => array(
				'type' => 'radio',
				'label' => __pl('Overlay'),
				'list' => array(
					'' => __pl('normal'),
					'hover' => __pl('hover'),
				),
			),
			'overlay_type' => array(
				'type' => 'radio',
				'label' => __pl('overlay_type'),
				'list' => array(
					'' => __pl('none'),
					'color' => __pl('color'),
					'image' => __pl('image'),
					'gradient' => __pl('gradient')
				),
				'show' => ['overlay_state' => ''],
			),
			'overlay_color' => array(
				'type' => 'color',
				'label' => __pl('color'),
				'css' => ['{{element}} > .pagelayer-background-overlay' => 'background-color: {{val}};'],
				'req' => ['overlay_type' => 'color'],
				'show' => ['overlay_state' => ''],
			),
			'overlay_gradient' => array(
				'type' => 'gradient',
				'label' => '',
				'default' => '150,#44d3f6,23,#72e584,45,#2ca4eb,100',
				'css' => ['{{element}} > .pagelayer-background-overlay' => 'background: linear-gradient({{val[0]}}deg, {{val[1]}} {{val[2]}}%, {{val[3]}} {{val[4]}}%, {{val[5]}} {{val[6]}}%);'],
				'show' => ['overlay_state' => ''],
				'req' => ['overlay_type' => 'gradient']
			),
			'overlay_img' => array(
				'type' => 'image',
				'label' => __pl('Image'),
				'css' => ['{{element}} > .pagelayer-background-overlay' => 'background: url("{{{overlay_img-url}}}");'],
				'show' => ['overlay_state' => ''],
				'req' => ['overlay_type' => 'image']
			),
			'overlay_img_attachment' => array(
				'type' => 'select',
				'label' => __pl('overlay_img_attachment'),
				'list' => [
					'' => __pl('default'),
					'scroll' => __pl('scroll'),
					'fixed' => __pl('fixed')
				],
				'show' => ['overlay_state' => ''],
				'css' => ['{{element}} > .pagelayer-background-overlay' => 'background-attachment: {{val}};'],
				'req' => ['overlay_type' => 'image']
			),
			'overlay_bg_posx' => array(
				'type' => 'select',
				'label' => __pl('overlay_bg_posx'),
				'list' => [
					'' => __pl('default'),
					'center' => __pl('center'),
					'left' => __pl('left'),
					'right' => __pl('right')
				],
				'show' => ['overlay_state' => ''],
				'css' => ['{{element}} > .pagelayer-background-overlay' => 'background-position-x: {{val}};'],
				'req' => ['overlay_type' => 'image']
			),
			'overlay_bg_posy' => array(
				'type' => 'select',
				'label' => __pl('overlay_bg_posy'),
				'list' => [
					'' => __pl('default'),
					'center' => __pl('center'),
					'top' => __pl('top'),
					'bottom' => __pl('bottom')
				],
				'show' => ['overlay_state' => ''],
				'css' => ['{{element}} > .pagelayer-background-overlay' => 'background-position-y: {{val}};'],
				'req' => ['overlay_type' => 'image']
			),
			'overlay_bg_repeat' => array(
				'type' => 'select',
				'label' => __pl('overlay_bg_repeat'),
				'css' => ['{{element}} > .pagelayer-background-overlay' => 'background-repeat: {{val}};'],
				'list' => [
					'' => __pl('default'),
					'repeat' => __pl('repeat'),
					'no-repeat' => __pl('no-repeat'),
					'repeat-x' => __pl('repeat-x'),
					'repeat-y' => __pl('repeat-y'),
				],
				'show' => ['overlay_state' => ''],
				'req' => ['overlay_type' => 'image']
			),
			'overlay_bg_size' => array(
				'type' => 'select',
				'label' => __pl('overlay_bg_size'),
				'css' => ['{{element}} > .pagelayer-background-overlay' => 'background-size: {{val}};'],
				'list' => [
					'' => __pl('default'),
					'cover' => __pl('cover'),
					'contain' => __pl('contain')
				],
				'show' => ['overlay_state' => ''],
				'req' => ['overlay_type' => 'image']
			),
			'overlay_transperancy' => array(
				'type' => 'slider',
				'label' => __pl('overlay_transperancy'),
				'default' => 0.5,
				'min' => 0,
				'max' => 1,
				'step' => 0.1,
				'css' => ['{{element}} > .pagelayer-background-overlay' => 'opacity: {{val}};'],
				'req' => array(
					'!overlay_type' => '',
				),
				'show' => ['overlay_state' => ''],
			),
			'overlay_hover_delay' => array(
				'type' => 'spinner',
				'label' => __pl('overlay_hover_delay'),
				'min' => 0,
				'step' => 100,
				'max' => 5000,
				'default' => 400,
				'css' => ['{{element}} > .pagelayer-background-overlay' => '-webkit-transition: all {{val}}ms !important; transition: all {{val}}ms !important;'],
				'show' => array(
					'overlay_state' => 'hover'
				),
			),
			'overlay_type_hover' => array(
				'type' => 'radio',
				'label' => __pl('overlay_type_hover'),
				'list' => array(
					'' => __pl('none'),
					'color' => __pl('color'),
					'gradient' => __pl('gradient'),
					'image' => __pl('image'),
				),
				'show' => ['overlay_state' => 'hover'],
			),
			'overlay_color_hover' => array(
				'type' => 'color',
				'label' => __pl('color'),
				//'desc' => __pl('video_src_desc'),
				'css' => ['{{element}}:hover > .pagelayer-background-overlay' => 'background: {{val}};'],
				'req' => ['overlay_type_hover' => 'color'],
				'show' => ['overlay_state' => 'hover'],
			),
			'overlay_gradient_hover' => array(
				'type' => 'gradient',
				'label' => '',
				'default' => '150,#44d3f6,23,#72e584,45,#2ca4eb,100',
				'css' => ['{{element}}:hover > .pagelayer-background-overlay' => 'background: linear-gradient({{val[0]}}deg, {{val[1]}} {{val[2]}}%, {{val[3]}} {{val[4]}}%, {{val[5]}} {{val[6]}}%);'],
				'show' => ['overlay_state' => 'hover'],
				'req' => ['overlay_type_hover' => 'gradient']
			),
			'overlay_img_hover' => array(
				'type' => 'image',
				'label' => __pl('Image'),
				'css' => ['{{element}}:hover > .pagelayer-background-overlay' => 'background: url("{{{overlay_img_hover-url}}}");'],
				'show' => ['overlay_state' => 'hover'],
				'req' => ['overlay_type_hover' => 'image']
			),
			'overlay_img_attachment_hover' => array(
				'type' => 'select',
				'label' => __pl('overlay_img_attachment_hover'),
				'list' => [
					'' => __pl('default'),
					'scroll' => __pl('scroll'),
					'fixed' => __pl('fixed')
				],
				'show' => ['overlay_state' => 'hover'],
				'css' => ['{{element}}:hover > .pagelayer-background-overlay' => 'background-attachment: {{val}};'],
				'req' => ['overlay_type_hover' => 'image']
			),
			'overlay_bg_posx_hover' => array(
				'type' => 'select',
				'label' => __pl('overlay_bg_posx_hover'),
				'list' => [
					'' => __pl('default'),
					'center' => __pl('center'),
					'left' => __pl('left'),
					'right' => __pl('right')
				],
				'show' => ['overlay_state' => 'hover'],
				'css' => ['{{element}}:hover > .pagelayer-background-overlay' => 'background-position-x: {{val}};'],
				'req' => ['overlay_type_hover' => 'image']
			),
			'overlay_bg_posy_hover' => array(
				'type' => 'select',
				'label' => __pl('overlay_bg_posy_hover'),
				'list' => [
					'' => __pl('default'),
					'center' => __pl('center'),
					'top' => __pl('top'),
					'bottom' => __pl('bottom')
				],
				'show' => ['overlay_state' => 'hover'],
				'css' => ['{{element}}:hover > .pagelayer-background-overlay' => 'background-position-y: {{val}};'],
				'req' => ['overlay_type_hover' => 'image']
			),
			'overlay_bg_repeat_hover' => array(
				'type' => 'select',
				'label' => __pl('overlay_bg_repeat_hover'),
				'css' => ['{{element}}:hover > .pagelayer-background-overlay' => 'background-repeat: {{val}};'],
				'list' => [
					'' => __pl('default'),
					'repeat' => __pl('repeat'),
					'no-repeat' => __pl('no-repeat'),
					'repeat-x' => __pl('repeat-x'),
					'repeat-y' => __pl('repeat-y'),
				],
				'show' => ['overlay_state' => 'hover'],
				'req' => ['overlay_type_hover' => 'image']
			),
			'overlay_bg_size_hover' => array(
				'type' => 'select',
				'label' => __pl('overlay_bg_size_hover'),
				'css' => ['{{element}}:hover > .pagelayer-background-overlay' => 'background-size: {{val}};'],
				'list' => [
					'' => __pl('default'),
					'cover' => __pl('cover'),
					'contain' => __pl('contain')
				],
				'show' => ['overlay_state' => 'hover'],
				'req' => ['overlay_type_hover' => 'image']
			),
			'overlay_transperancy_hover' => array(
				'type' => 'slider',
				'label' => __pl('overlay_transperancy_hover'),
				'min' => 0,
				'max' => 1,
				'step' => 0.1,
				'css' => ['{{element}}:hover > .pagelayer-background-overlay' => 'opacity: {{val}};'],
				'req' => array(
					'overlay_type' => 'image',
					'overlay_type' => 'color'
				),
				'show' => ['overlay_state' => 'hover'],
			),
		],
		'shape_styles' => [
			'row_shape_position' => array(
				'type' => 'radio',
				'label' => __pl('shape_position'),
				'list' => array(
					'top' => __pl('Top'),
					'bottom' => __pl('Bottom'),
				),
			),
			'row_shape_type_top' => array(
				'type' => 'select',
				'label' => __pl('shape_type'),
				'default' => '',
				'list' => array(
					'' => __pl('none'),
					'arrow' => __pl('Arrow'),
					'bigTriangle' => __pl('BigTriangle'),
					'bigTriangleShadow' => __pl('BigTriangle Shadow'),
					'curve' => __pl('Curve'),
					'clouds' => __pl('Clouds'),
					'mountains' => __pl('Mountains'),
					'pyramids' => __pl('Pyramids'),
					'stamp' => __pl('Stamp'),
					'slit' => __pl('Slit'),
					'split' => __pl('Split'),
					'tilt' => __pl('Tilt'),
					'tiltOpacity' => __pl('Tilt Opacity'),
					'waves' => __pl('Waves'),
					'zigzag' => __pl('Zigzag'),
				),
				'show' => ['row_shape_position' => 'top'],
			),
			'row_shape_top_color' => array(
				'type' => 'color',
				'label' => __pl('shape_bg_color'),
				'default' => '#227bc3',
				'css' => ['{{element}} .pagelayer-svg-top .pagelayer-shape-fill' => 'fill:{{val}}'],
				'show' => ['row_shape_position' => 'top'],
			),
			'row_shape_top_width' => array(
				'type' => 'slider',
				'label' => __pl('shape_width'),
				'screen' => 1,
				'default' => 100,
				'min' => 100,
				'max' => 500,
				'css' => ['{{element}} .pagelayer-row-svg .pagelayer-svg-top' => 'width:{{val}}%'],
				'show' => ['row_shape_position' => 'top'],
			),
			'row_shape_top_height' => array(
				'type' => 'slider',
				'label' => __pl('shape_height'),
				'screen' => 1,
				'default' => 100,
				'min' => 10,
				'max' => 500,
				'css' => ['{{element}} .pagelayer-row-svg .pagelayer-svg-top' => 'height:{{val}}px'],
				'show' => ['row_shape_position' => 'top'],
			),
			'row_shape_top_flip' => array(
				'type' => 'checkbox',
				'label' => __pl('shape_flip'),
				'css' => ['{{element}} .pagelayer-row-svg .pagelayer-svg-top' => 'transform: rotateY(180deg);'],
				'show' => ['row_shape_position' => 'top'],
			),
			'row_shape_type_bottom' => array(
				'type' => 'select',
				'label' => __pl('shape_type'),
				'default' => '',
				'list' => array(
					'' => __pl('none'),
					'arrow' => __pl('Arrow'),
					'bigTriangle' => __pl('BigTriangle'),
					'bigTriangleShadow' => __pl('BigTriangle Shadow'),
					'curve' => __pl('Curve'),
					'clouds' => __pl('Clouds'),
					'mountains' => __pl('Mountains'),
					'pyramids' => __pl('Pyramids'),
					'stamp' => __pl('Stamp'),
					'slit' => __pl('Slit'),
					'split' => __pl('Split'),
					'tilt' => __pl('Tilt'),
					'tiltOpacity' => __pl('Tilt Opacity'),
					'waves' => __pl('Waves'),
					'zigzag' => __pl('Zigzag'),
				),
				'show' => ['row_shape_position' => 'bottom'],
			),
			'row_shape_bottom_color' => array(
				'type' => 'color',
				'label' => __pl('shape_bg_color'),
				'default' => '#e44993',
				'css' => ['{{element}} .pagelayer-svg-bottom .pagelayer-shape-fill' => 'fill:{{val}}'],
				'show' => ['row_shape_position' => 'bottom'],
			),
			'row_shape_bottom_width' => array(
				'type' => 'slider',
				'label' => __pl('shape_width'),
				'screen' => 1,
				'default' => 100,
				'min' => 100,
				'max' => 500,
				'css' => ['{{element}} .pagelayer-row-svg .pagelayer-svg-bottom' => 'width:{{val}}%'],
				'show' => ['row_shape_position' => 'bottom'],
			),
			'row_shape_bottom_height' => array(
				'type' => 'slider',
				'label' => __pl('shape_height'),
				'screen' => 1,
				'default' => 100,
				'min' => 10,
				'max' => 500,
				'css' => ['{{element}} .pagelayer-row-svg .pagelayer-svg-bottom' => 'height:{{val}}px'],
				'show' => ['row_shape_position' => 'bottom'],
			),
			'row_shape_bottom_flip' => array(
				'type' => 'checkbox',
				'label' => __pl('shape_flip'),
				'css' => ['{{element}} .pagelayer-row-svg .pagelayer-svg-bottom' => 'transform: rotateY(180deg);'],
				'show' => ['row_shape_position' => 'bottom'],
			),
			
		],
		'styles' => [
			'row_bg_styles' => __pl('row_bg_styles'),
			'row_bg_overlay' => __pl('row_bg_overlay'),
			'shape_styles' => __pl('shape_styles'),
		],
	)
);

// Column object
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_col', array(
		'name' => __pl('column'),
		'group' => 'grid',
		'skip_props_cat' => ['position_styles'],
		'skip_props' => ['ele_sticky_in_container'],
		'html' => '<div if="{{bg_video_src}}" class="pagelayer-background-video">{{vid_src}}</div>
				<div if="{{bg_slider}}" class="pagelayer-bgimg-slider">
					{{slider}}
				</div>
				<div if="{{parallax_img}}" class="pagelayer-parallax-window">
					<img class="pagelayer-img" src="{{parallax_img_src}}" title="{{{parallax_img-title}}}" alt="{{{parallax_img-alt}}}">
				</div>
				<div if="{{overlay_type}}" class="pagelayer-background-overlay"></div>
				<div class="pagelayer-col-holder"></div>',
		'holder' => '.pagelayer-col-holder',
		'params' => array(
			'content_pos' => array(
				'type' => 'select',
				'label' => __pl('content_pos'),
				'css' => ['{{element}}' => 'align-content: {{val}} !important;'],
				'list' => array(
					'' => __pl('default'),
					'flex-start' => __pl('top'),
					'center' => __pl('center'),
					'flex-end' => __pl('bottom')
				)
			),
			'widget_space' => array(
				'type' => 'spinner',
				'label' => __pl('widget_space'),
				'default' => get_option('pagelayer_between_widgets', 15),
				'min' => -1000,
				'step' => 1,
				'max' => 1000,
				'css' => ['{{element}} .pagelayer-col-holder > div:not(:last-child)' => 'margin-bottom: {{val}}px;'],
			),
			'col' => array(
				'type' => 'select',
				'label' => __pl('col_width'),
				'addClass' => 'pagelayer-col-{{val}}',
				'list' => array(
					'1' => __pl('1'),
					'2' => __pl('2'),
					'3' => __pl('3'),
					'4' => __pl('4'),
					'5' => __pl('5'),
					'6' => __pl('6'),
					'7' => __pl('7'),
					'8' => __pl('8'),
					'9' => __pl('9'),
					'10' => __pl('10'),
					'11' => __pl('11'),
					'12' => __pl('12'),
					'' => __pl('custom'),
				)
			),
			'col_width' => array(
				'type' => 'spinner',
				'label' => __pl('width_custom'),
				'min' => 0,
				'step' => 1,
				'max' => 100,
				'screen' => 1,
				'css' =>['.pagelayer-row-holder {{wrap}}' => 'width: {{val}}%;'],
				'req' => ['col' => ''],
			),
		),
		'col_bg_styles' => [
			'col_bg_type' => array(
				'type' => 'radio',
				'label' => __pl('col_bg_type'),
				'list' => array(
					'' => __pl('none'),
					'video' => __pl('video'),
					'parallax' => __pl('parallax'),
					'slider' => __pl('slider'),
				),
			),
			'bg_video_src' => array(
				'type' => 'video',
				'label' => __pl('video_src_label'),
				'desc' => __pl('video_src_desc'),
				'req' => ['col_bg_type' => 'video']
			),
			'mute' => array(
				'type' => 'checkbox',
				'label' => __pl('mute'),
				'req' => ['col_bg_type' => 'video']				
			),			
			'stop_loop' => array(
				'type' => 'checkbox',
				'label' => __pl('stop_loop'),
				'req' => ['col_bg_type' => 'video']
			),
			'parallax_img' => array(
				'type' => 'image',
				'label' => __pl('Image'),
				'req' => ['col_bg_type' => 'parallax']
			),
			'parallax_align' => array(
				'type' => 'radio',
				'label' => __pl('obj_align_label'),
				'screen' => 1,
				'default' => 'center',
				'css' => ['{{element}} .pagelayer-parallax-window' => 'text-align: {{val}}'],
				'list' => array(
					'left' => __pl('left'),
					'center' => __pl('center'),
					'right' => __pl('right')
				),
				'req' => ['col_bg_type' => 'parallax']
			),
			'parallax_id_size' => array(
				'label' => __pl('obj_image_size_label'),
				'type' => 'select',
				'default' => 'full',
				'list' => array(
					'full' => __pl('full'),
					'large' => __pl('large'),
					'medium' => __pl('medium'),
					'thumbnail' => __pl('thumbnail'),
					'custom' => __pl('custom')
				),
				'req' => ['col_bg_type' => 'parallax']
			),
			'parallax_custom_size' => array(
				'type' => 'dimension',
				'label' => __pl('image_custom_size_label'),
				'css' => ['{{element}} .pagelayer-parallax-window img' => 'width: {{val[0]}}px; height: {{val[1]}}px;'],
				'req' => array(
					'parallax_id_size' => 'custom',
					'col_bg_type' => 'parallax'
				),
			),
			'parallax_max_width' => array(
				'label' => __pl('max-width-percent'),
				'type' => 'slider',
				'min' => 0,
				'max' => 100,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-parallax-window img' => 'max-width: {{val}}%'],
				'req' => ['col_bg_type' => 'parallax']
			),
			'bg_slider' => array(
				'type' => 'multi_image',
				'label' => __pl('image_slider_ids_label'),
				'req' => ['col_bg_type' => 'slider'],
				'pro' => 1
			),
			'bg_slider_speed' => array(
				'type' => 'spinner',
				'label' => __pl('speed_ms'),
				'default' => 2000,
				'min' => 200,
				'max' => 50000,
				'step' => 100,
				'addAttr' => ['{{element}} .pagelayer-bgimg-slider' => 'data-speed="{{bg_slider_speed}}"'],
				'req' => [
					'col_bg_type' => 'slider'
				],
				'pro' => 1
			),
		],
		'col_bg_overlay' => [
			'overlay_state' => array(
				'type' => 'radio',
				'label' => '',
				'list' => array(
					'' => __pl('normal'),
					'hover' => __pl('hover'),
				),
			),
			'overlay_type' => array(
				'type' => 'radio',
				'label' => __pl('overlay_type'),
				'list' => array(
					'' => __pl('none'),
					'color' => __pl('color'),
					'image' => __pl('image'),
					'gradient' => __pl('gradient')
				),
				'show' => ['overlay_state' => ''],
			),
			'overlay_color' => array(
				'type' => 'color',
				'label' => __pl('color'),
				//'desc' => __pl('video_src_desc'),
				'css' => ['{{element}} > .pagelayer-background-overlay' => 'background-color: {{val}};'],
				'req' => ['overlay_type' => 'color'],
				'show' => ['overlay_state' => ''],
			),
			'overlay_gradient' => array(
				'type' => 'gradient',
				'label' => '',
				'default' => '150,#44d3f6,23,#72e584,45,#2ca4eb,100',
				'css' => ['{{element}} > .pagelayer-background-overlay' => 'background: linear-gradient({{val[0]}}deg, {{val[1]}} {{val[2]}}%, {{val[3]}} {{val[4]}}%, {{val[5]}} {{val[6]}}%);'],
				'show' => ['overlay_state' => ''],
				'req' => ['overlay_type' => 'gradient']
			),
			'overlay_img' => array(
				'type' => 'image',
				'label' => __pl('Image'),
				'css' => ['{{element}} > .pagelayer-background-overlay' => 'background: url("{{{overlay_img-url}}}");'],
				'show' => ['overlay_state' => ''],
				'req' => ['overlay_type' => 'image']
			),
			'overlay_img_attachment' => array(
				'type' => 'select',
				'label' => __pl('overlay_img_attachment'),
				'list' => [
					'' => __pl('default'),
					'scroll' => __pl('scroll'),
					'fixed' => __pl('fixed')
				],
				'show' => ['overlay_state' => ''],
				'css' => ['{{element}} > .pagelayer-background-overlay' => 'background-attachment: {{val}};'],
				'req' => ['overlay_type' => 'image']
			),
			'overlay_bg_posx' => array(
				'type' => 'select',
				'label' => __pl('overlay_bg_posx'),
				'list' => [
					'' => __pl('default'),
					'center' => __pl('center'),
					'left' => __pl('left'),
					'right' => __pl('right')
				],
				'show' => ['overlay_state' => ''],
				'css' => ['{{element}} > .pagelayer-background-overlay' => 'background-position-x: {{val}};'],
				'req' => ['overlay_type' => 'image']
			),
			'overlay_bg_posy' => array(
				'type' => 'select',
				'label' => __pl('overlay_bg_posy'),
				'list' => [
					'' => __pl('default'),
					'center' => __pl('center'),
					'top' => __pl('top'),
					'bottom' => __pl('bottom')
				],
				'show' => ['overlay_state' => ''],
				'css' => ['{{element}} > .pagelayer-background-overlay' => 'background-position-y: {{val}};'],
				'req' => ['overlay_type' => 'image']
			),
			'overlay_bg_repeat' => array(
				'type' => 'select',
				'label' => __pl('overlay_bg_repeat'),
				'css' => ['{{element}} > .pagelayer-background-overlay' => 'background-repeat: {{val}};'],
				'list' => [
					'' => __pl('default'),
					'repeat' => __pl('repeat'),
					'no-repeat' => __pl('no-repeat'),
					'repeat-x' => __pl('repeat-x'),
					'repeat-y' => __pl('repeat-y'),
				],
				'show' => ['overlay_state' => ''],
				'req' => ['overlay_type' => 'image']
			),
			'overlay_bg_size' => array(
				'type' => 'select',
				'label' => __pl('overlay_bg_size'),
				'css' => ['{{element}} > .pagelayer-background-overlay' => 'background-size: {{val}};'],
				'list' => [
					'' => __pl('default'),
					'cover' => __pl('cover'),
					'contain' => __pl('contain')
				],
				'show' => ['overlay_state' => ''],
				'req' => ['overlay_type' => 'image']
			),
			'overlay_transperancy' => array(
				'type' => 'slider',
				'label' => __pl('overlay_transperancy'),
				'default' => 0.5,
				'min' => 0,
				'max' => 1,
				'step' => 0.1,
				'css' => ['{{element}} > .pagelayer-background-overlay' => 'opacity: {{val}};'],
				'req' => array(
					'!overlay_type' => '',
				),
				'show' => ['overlay_state' => ''],
			),
			'overlay_hover_delay' => array(
				'type' => 'spinner',
				'label' => __pl('overlay_hover_delay'),
				'min' => 0,
				'step' => 100,
				'max' => 5000,
				'default' => 400,
				'css' => ['{{element}} > .pagelayer-background-overlay' => '-webkit-transition: all {{val}}ms !important; transition: all {{val}}ms !important;'],
				'show' => array(
					'overlay_state' => 'hover'
				),
			),
			'overlay_type_hover' => array(
				'type' => 'radio',
				'label' => __pl('overlay_type_hover'),
				'list' => array(
					'' => __pl('none'),
					'color' => __pl('color'),
					'gradient' => __pl('gradient'),
					'image' => __pl('image'),
				),
				'show' => ['overlay_state' => 'hover'],
			),
			'overlay_color_hover' => array(
				'type' => 'color',
				'label' => __pl('color'),
				//'desc' => __pl('video_src_desc'),
				'css' => ['{{element}}:hover  > .pagelayer-background-overlay' => 'background: {{val}};'],
				'req' => ['overlay_type_hover' => 'color'],
				'show' => ['overlay_state' => 'hover'],
			),
			'overlay_gradient_hover' => array(
				'type' => 'gradient',
				'label' => '',
				'default' => '150,#44d3f6,23,#72e584,45,#2ca4eb,100',
				'css' => ['{{element}}:hover > .pagelayer-background-overlay' => 'background: linear-gradient({{val[0]}}deg, {{val[1]}} {{val[2]}}%, {{val[3]}} {{val[4]}}%, {{val[5]}} {{val[6]}}%);'],
				'show' => ['overlay_state' => 'hover'],
				'req' => ['overlay_type_hover' => 'gradient']
			),
			'overlay_img_hover' => array(
				'type' => 'image',
				'label' => __pl('Image'),
				'css' => ['{{element}}:hover > .pagelayer-background-overlay' => 'background: url("{{{overlay_img_hover-url}}}");'],
				'show' => ['overlay_state' => 'hover'],
				'req' => ['overlay_type_hover' => 'image']
			),
			'overlay_img_attachment_hover' => array(
				'type' => 'select',
				'label' => __pl('overlay_img_attachment_hover'),
				'list' => [
					'' => __pl('default'),
					'scroll' => __pl('scroll'),
					'fixed' => __pl('fixed')
				],
				'show' => ['overlay_state' => 'hover'],
				'css' => ['{{element}}:hover > .pagelayer-background-overlay' => 'background-attachment: {{val}};'],
				'req' => ['overlay_type_hover' => 'image']
			),
			'overlay_bg_posx_hover' => array(
				'type' => 'select',
				'label' => __pl('overlay_bg_posx_hover'),
				'list' => [
					'' => __pl('default'),
					'center' => __pl('center'),
					'left' => __pl('left'),
					'right' => __pl('right')
				],
				'show' => ['overlay_state' => 'hover'],
				'css' => ['{{element}}:hover > .pagelayer-background-overlay' => 'background-position-x: {{val}};'],
				'req' => ['overlay_type_hover' => 'image']
			),
			'overlay_bg_posy_hover' => array(
				'type' => 'select',
				'label' => __pl('overlay_bg_posy_hover'),
				'list' => [
					'' => __pl('default'),
					'center' => __pl('center'),
					'top' => __pl('top'),
					'bottom' => __pl('bottom')
				],
				'show' => ['overlay_state' => 'hover'],
				'css' => ['{{element}}:hover > .pagelayer-background-overlay' => 'background-position-y: {{val}};'],
				'req' => ['overlay_type_hover' => 'image']
			),
			'overlay_bg_repeat_hover' => array(
				'type' => 'select',
				'label' => __pl('overlay_bg_repeat_hover'),
				'css' => ['{{element}}:hover > .pagelayer-background-overlay' => 'background-repeat: {{val}};'],
				'list' => [
					'' => __pl('default'),
					'repeat' => __pl('repeat'),
					'no-repeat' => __pl('no-repeat'),
					'repeat-x' => __pl('repeat-x'),
					'repeat-y' => __pl('repeat-y'),
				],
				'show' => ['overlay_state' => 'hover'],
				'req' => ['overlay_type_hover' => 'image']
			),
			'overlay_bg_size_hover' => array(
				'type' => 'select',
				'label' => __pl('overlay_bg_size_hover'),
				'css' => ['{{element}}:hover > .pagelayer-background-overlay' => 'background-size: {{val}};'],
				'list' => [
					'' => __pl('default'),
					'cover' => __pl('cover'),
					'contain' => __pl('contain')
				],
				'show' => ['overlay_state' => 'hover'],
				'req' => ['overlay_type_hover' => 'image']
			),
			'overlay_transperancy_hover' => array(
				'type' => 'slider',
				'label' => __pl('overlay_transperancy_hover'),
				'default' => 0.5,
				'min' => 0,
				'max' => 1,
				'step' => 0.1,
				'css' => ['{{element}}:hover > .pagelayer-background-overlay' => 'opacity: {{val}};'],
				'req' => array(
					'!overlay_type_hover' => '',
				),
				'show' => ['overlay_state' => 'hover'],
			),
		],
		'styles' => [
			'col_bg_styles' => __pl('col_bg_styles'),
			'col_bg_overlay' => __pl('col_bg_overlay'),
		],
	)
);

////////////////////////
// TEXT Group
////////////////////////

// Heading object
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_heading', array(
		'name' => __pl('title'),
		'group' => 'text',
		'innerHTML' => 'text',
		'html' => '<a if-ext="{{link}}" href="{{{link}}}" class="pagelayer-link-sel">
			<div if={{text}} class="pagelayer-heading-holder">{{text}}</div>
		</a>',
		'params' => array(
			'text' => array(
				'type' => 'textarea',
				'label' => __pl('Edit Title'),
				'default' => '<h2>Your Heading</h2>',
				'desc' => __pl('Edit the heading here'),
				'e' => [ 'v', 'h', 'f', 'c', 'r'],
				'edit' => '.pagelayer-heading-holder', // Edit the text and also mirror the same
			),
			'link' => array(
				'type' => 'link',
				'label' => __pl('image_link_label'),
				'selector' => '.pagelayer-link-sel'
			),
			'align' => array(
				'label' => __pl('obj_align_label'),
				'type' => 'radio',
				'addAttr' => 'align="{{align}}"',
				'screen' => 1,
				'css' => ['{{element}}' => 'text-align: {{val}}'],
				'list' => array(
					'left' => __pl('left'),
					'center' => __pl('center'),
					'right' => __pl('right')
				)
			),
		),
		'heading_styles' => [
			'heading_state' => array(
				'type' => 'radio',
				'label' => __pl('state'),
				'default' => 'normal',
				'list' => array(
					'normal' => __pl('normal'),
					'hover' => __pl('hover'),
				)
			),
			'color' => array(
				'type' => 'color',
				'label' => __pl('color'),
				'css' => ['{{element}} .pagelayer-heading-holder *' => 'color:{{val}}', '{{element}} .pagelayer-heading-holder' => 'color:{{val}}'],
				'show' => ['heading_state' => 'normal']
			),
			'heading_typo' => array(
				'type' => 'typography',
				'label' => __pl('typography'),
				'css' => ['{{element}} .pagelayer-heading-holder *' => 'font-family: {{val[0]}} !important; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;',
				'{{element}} .pagelayer-heading-holder' => 'font-family: {{val[0]}} !important; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'],
				'show' => ['heading_state' => 'normal']
			),
			'heading_text_shadow' => array(
				'type' => 'shadow',
				'label' => __pl('text_shadow'),
				'css' => ['{{element}} .pagelayer-heading-holder, {{element}} .pagelayer-heading-holder *' => 'text-shadow: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}} !important;'],
				'show' => ['heading_state' => 'normal']
			),
			'color_hover' => array(
				'type' => 'color',
				'label' => __pl('color'),
				'css' => ['{{element}} .pagelayer-heading-holder:hover *' => 'color:{{val}}', '{{element}} .pagelayer-heading-holder:hover' => 'color:{{val}}'],
				'show' => ['heading_state' => 'hover']
			),
			'heading_typo_hover' => array(
				'type' => 'typography',
				'label' => __pl('typography'),
				'css' => ['{{element}} .pagelayer-heading-holder:hover *' => 'font-family: {{val[0]}} !important; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;',
				'{{element}} .pagelayer-heading-holder:hover' => 'font-family: {{val[0]}} !important; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'],
				'show' => ['heading_state' => 'hover']
			),
			'heading_text_shadow_hover' => array(
				'type' => 'shadow',
				'label' => __pl('text_shadow'),
				'css' => ['{{element}} .pagelayer-heading-holder:hover, {{element}} .pagelayer-heading-holder:hover *' => 'text-shadow: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}} !important;'],
				'show' => ['heading_state' => 'hover']
			),
		],
		'styles' => [
			'heading_styles' => __pl('heading_styles')
		],
	)
);

// Rich Text object
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_text', array(
		'name' => __pl('Rich Text'),
		'group' => 'text',
		'innerHTML' => 'text',
		'html' => '<div class="pagelayer-text-holder">{{text}}</div>',
		'params' => array(
			'text' => array(
				'type' => 'editor',
				'label' => __pl('Edit Rich Text'),
				'default' => pagelayer_is_gutenberg_editor() ? '' : '<p><br></p>',
				'rows' => '15',
				'desc' => __pl('Edit the content by clicking on the content you want to edit on the website'),
				'edit' => '.pagelayer-text-holder', // Edit the text and also mirror the same
			)
		)
	)
);

// Quote
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_quote', array(
		'name' => __pl('quote'),
		'group' => 'text',
		'innerHTML' => 'quote_content',
		'html' => '<div class="pagelayer-quote-holder pagelayer-quote-{{quote_style}}">
				<i if="{{quotation_pos}}" class="fa fa-quote-left pagelayer-quotation-{{quotation_pos}}"></i>
				<div if="{{quote_content}}" class="pagelayer-quote-content">
					<i if="{{double_indent}}" class="fa fa-quote-left"></i>
					{{quote_content}}
					<i if="{{double_indent}}" class="fa fa-quote-right"></i>
				</div>
				<div if="{{cite}}" class="pagelayer-quote-cite">
					<a if-ext="{{cite_url}}" href="{{{cite_url}}}" class="pagelayer-link-sel">
						<span class="pagelayer-cite-holder">{{cite}}</span>
					</a>
				</div>
			</div>',
		'params' => array(		
			'quote_content' => array(
				'type' => 'textarea',
				'label' => __pl('quotes_content_label'),
				'default' => 'Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet, Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet.',
				'edit' => '.pagelayer-quote-content',
			),
			'quote_background_color' => array(
				'type' => 'color',
				'label' => __pl('bg_color'),
				'default' => '#eeeeee',
				'css' => ['{{element}} .pagelayer-quote-holder' => 'background-color: {{val}}']
			),
			'quote_content_color' => array(
				'type' => 'color',
				'label' => __pl('quotes_content_color_label'),
				'default' => '#050505',
				'css' => ['{{element}} .pagelayer-quote-content' => 'color:{{val}}'],
			),
			'quote_content_space' => array(
				'type' => 'dimension',
				'label' => __pl('space_between'),
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-quote-content' => 'margin-top:{{val[0]}}px;margin-bottom:{{val[1]}}px;'],
			),
			'quote_content_typo' => array(
				'type' => 'typography',
				'label' => __pl('quote_content_typo'),
				'css' => ['{{element}} .pagelayer-quote-content' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'],
			),
		),
		'qoute_styles' => [		
			'quote_style' => array(
				'type' => 'select',
				'label' => __pl('style'),
				'default' => 'quotation',
				'list' => array(
					'default' => __pl('default'),
					'quotation' => __pl('quotation'),
					'double' => __pl('double_quotation')
				)
			),
			'quotation_pos' => array(
				'type' => 'radio',
				'label' => __pl('quotation_pos_label'),
				'default' => 'default',
				'css' => ['{{element}} .pagelayer-quote-holder' => 'position: relative;',
					'{{element}} .pagelayer-quote-content' => 'position: relative; z-index:1;',
					'{{element}} .pagelayer-quote-cite' => 'position: relative; z-index:1;'],
				'list' => array(
					'default' => __pl('default'),
					'overlay' => __pl('overlay')
				),
				'req' => array(
					'quote_style' => 'quotation'
				),
			),
			'quotation_size' => array(
				'type' => 'slider',
				'label' => __pl('quotation_size_label'),
				'min' => 1,
				'step' => 1,
				'max' => 1000,
				'default' => 70,
				'screen' => 1,
				'css' => ['{{element}} .fa' => 'font-size: {{val}}px;'],
				'req' => array(
					'quote_style' => ['quotation','double']
				)
			),
			'quotation_color' => array(
				'type' => 'color',
				'label' => __pl('quotation_color_label'),
				'default' => '#dadada',
				'css' => ['{{element}} .fa' => 'color:{{val}}'],
				'req' => array(
					'quote_style' => ['quotation','double']
				)
			),
			'quotation_top' => array(
				'type' => 'slider',
				'label' => __pl('quotation_top_label'),
				'min' => 0,
				'step' => 1,
				'max' => 100,
				'default' => 0,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-quotation-overlay' => 'top: {{val}}%;'],
				'req' => array(
					'quote_style' => 'quotation',
					'quotation_pos' => 'overlay'
				)
			),
			'quotation_left' => array(
				'type' => 'slider',
				'label' => __pl('quotation_left_label'),
				'min' => 0,
				'step' => 1,
				'max' => 100,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-quotation-overlay' => 'left: {{val}}%;'],
				'req' => array(
					'quote_style' => 'quotation',
					'quotation_pos' => 'overlay'
				)
			),
			'double_indent' => array(
				'type' => 'slider',
				'label' => __pl('quotation_double_indent_label'),
				'min' => 1,
				'step' => 1,
				'max' => 500,
				'default' => 10,
				'screen' => 1,
				'css' => ['{{element}} .fa-quote-right' => 'padding-left: {{val}}px;',
					'{{element}} .fa-quote-left' => 'padding-right: {{val}}px;'],
				'req' => array(
					'quote_style' => 'double'
				)
			),
			'align' => array(
				'label' => __pl('obj_align_label'),
				'type' => 'radio',
				'default' => 'left',
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-quote-holder' => 'text-align: {{val}};'],
				'list' => array(
					'left' => __pl('left'),
					'center' => __pl('center'),
					'right' => __pl('right')
				)
			)				
		],
		'cite_styles' => [
			'cite' => array(
				'type' => 'text',
				'label' => __pl('quotes_cite_label'),
				'default' => '- John Smith',
				'desc' => __pl('quotes_cite_desc'),
				'edit' => '.pagelayer-cite-holder',
			),
			'cite_url' => array(
				'type' => 'link',
				'label' => __pl('quotes_url_label'),
				'selector' => '.pagelayer-link-sel',
				'desc' => __pl('quotes_url_desc'),
			),
			'cite_text_color' => array(
				'type' => 'color',
				'label' => __pl('quotes_cite_color_label'),
				'default' => '#3f3f3f',
				'css' => ['{{element}} .pagelayer-quote-cite span' => 'color:{{val}}']
			),
			'cite_text_align' => array(
				'label' => __pl('obj_align_label'),
				'type' => 'radio',
				'default' => 'left',
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-quote-cite' => 'text-align: {{val}};'],
				'list' => array(
					'left' => __pl('left'),
					'center' => __pl('center'),
					'right' => __pl('right'),
				)
			),
			'cite_typo' => array(
				'type' => 'typography',
				'label' => __pl('cite_typo'),
				'default' => ',16,italic,,,,solid,,,,',
				'css' => ['{{element}} .pagelayer-quote-cite' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'],
			)
		],
		'border_style' => [
			'quote_border_width' => array(
				'type' => 'spinner',
				'label' => __pl('quote_left_border_width'),
				'min' => 0,
				'step' => 1,
				'max' => 100,
				'default' => 5,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-quote-holder' => 'border-left-width: {{val}}px; border-left-style: solid;']
			), 
			'quote_border_color' => array(
				'type' => 'color',
				'label' => __pl('quote_border_color'),
				'default' => '#02CC90',
				'css' => ['{{element}} .pagelayer-quote-holder' => 'border-left-color: {{val}}']
			),
			'quote_lpadding' => array(
				'type' => 'spinner',
				'label' => __pl('quote_left_padding'),
				'min' => 1,
				'step' => 1,
				'max' => 100,
				'default' => 30,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-quote-holder' => 'padding-left: {{val}}px; padding-right: 10px;']
			),
			'quote_vpadding' => array(
				'type' => 'spinner',
				'label' => __pl('quote_vertical_padding'),
				'min' => 1,
				'step' => 1,
				'max' => 100,
				'default' => 20,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-quote-holder' => 'padding-top: {{val}}px; padding-bottom: {{val}}px;']
			)
		],
		'styles' => [
			'qoute_styles' => __pl('qoute_styles'),
			'cite_styles' => __pl('cite_styles'),
			'border_style' => __pl('left_border'),
		],
	)
);

pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_list_item', array(
		'name' => __pl('list_item'),
		'group' => 'text',
		'not_visible' => 1,
		'parent' => [PAGELAYER_SC_PREFIX.'_list'],
		'innerHTML' => 'item',
		'html' => '<li if="{{item}}" class="pagelayer-list-li">
				<a if-ext="{{item_url}}" class="pagelayer-list-url pagelayer-ele-link" href="{{{item_url}}}">
					<span class="pagelayer-list-icon-holder">
						<i if="{{show_icon}}" class="pagelayer-list-icon {{icon}}"></i>
						<span if="{{item}}" class="pagelayer-list-item">{{item}}</span>
					</span>
				</a>
			</li>',
		'params' => array(
			'item' => array(
				'type' => 'text',
				'label' => __pl('list_items_label'),
				'default' => __pl('list_items_default'),
				'edit' => '.pagelayer-list-item',
			),
			'item_url' => array(
				'type' => 'link',
				'label' => __pl('list_item_url_label'),
				'selector' => '.pagelayer-list-url',
			),
			'show_icon' => array(
				'type' => 'checkbox',
				'label' => __pl('list_show_icon'),
				'default' => 'true'
			),
			'icon' => array(
				'type' => 'icon',
				'label' => __pl('list_icon_label'),
				'default' => 'fas fa-star',
				'req' => array(
					'show_icon' => 'true'
				)
			)
		)
	)
);

// List
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_list', array(
		'name' => __pl('list'),
		'group' => 'text',
		'has_group' => [
			'section' => 'params', 
			'prop' => 'elements'
		],
		'holder' => '.pagelayer-list-ul',
		'html' => '<ul class="pagelayer-list-ul pagelayer-list-type-{{list_type}}">
			</ul>',
		'params' => array(
			'elements' => array(
				'type' => 'group',
				'label' => __pl('List Item'),
				'sc' => PAGELAYER_SC_PREFIX.'_list_item',
				'item_label' => array(
					'default' => __pl('List Item'),
					'param' => 'item'
				),
				'count' => 2,
				'text' => __pl('Add List Item'),
			),
			'list_type' => array(
				'type' => 'select',
				'label' => __pl('style'),
				'default' => 'none',
				'css' => ['{{element}} li' => 'list-style-type: {{val}};'],
				'list' => array(
					'none' => __pl('none'),
					'circle' => __pl('list_list_type_circle'),
					'disc' => __pl('list_list_type_disc'),
					'square' => __pl('list_list_type_square'),
					'armenian' => __pl('list_list_type_armenian'),
					'georgian' => __pl('list_list_type_georgian'),
					'decimal' => '1, 2, 3, 4',
					'decimal-leading-zero' => '01, 02, 03, 04',
					'lower-latin' => 'a, b, c, d',
					'lower-roman' => 'i, ii, iii, iv',
					'lower-greek' => 'α, β, γ, δ',
					'upper-latin' => 'A, B, C, D',
					'upper-roman' => 'I, II, III, IV'
				)
			),
			'spacing' => array(
				'type' => 'slider',
				'label' => __pl('list_spacing_label'),
				'min' => 0,
				'step' => 1,
				'max' => 100,
				'default' => 10,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-list-icon-holder' => 'padding-bottom: calc({{val}}px/2); padding-top: calc({{val}}px/2);'],
			),
			'side_spacing' => array(
				'type' => 'slider',
				'label' => __pl('list_side_spacing_label'),
				'min' => 0,
				'step' => 1,
				'max' => 100,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-list_item' => 'padding-left: {{val}}px; padding-right: {{val}}px;'],
			),
		),
		'text_style' => [
			'list_text_state' => array(
				'type' => 'radio',
				'label' => __pl('state'),
				'default' => 'normal',
				'list' => [
					'normal' => __pl('normal'),
					'hover' => __pl('hover')
				],
			),
			'list_color' => array(
				'type' => 'color',
				'label' => __pl('list_color_label'),
				'css' => ['{{element}} .pagelayer-list-item' => 'color:{{val}}'],
				'show' =>['list_text_state' => 'normal']
			),
			'list_bg' => array(
				'type' => 'color',
				'label' => __pl('bg_color'),
				'css' => ['{{element}} .pagelayer-list-ul > div' => 'background-color:{{val}}'],
				'show' =>['list_text_state' => 'normal']
			),
			'list_typo' => array(
				'type' => 'typography',
				'label' => __pl('list_typo'),
				'css' => [
					'{{element}} li' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;',
					'{{element}} li > a' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'
				],
				'show' =>['list_text_state' => 'normal']
			),
			'item_indent' => array(
				'type' => 'slider',
				'label' => __pl('list_item_indent_label'),
				'min' => 0,
				'step' => 1,
				'max' => 100,
				'default' => 10,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-list-item' => 'margin-left: {{val}}px;'],
				'show' =>['list_text_state' => 'normal']
			),
			'list_hover_delay' => array(
				'type' => 'spinner',
				'label' => __pl('delay'),
				'min' => 0,
				'step' => 100,
				'max' => 5000,
				'css' => ['{{element}} .pagelayer-list-item, {{element}} .pagelayer-list-ul > div' => 'transition: all {{val}}ms;'],
				'show' =>['list_text_state' => 'hover']
			),
			'list_color_hover' => array(
				'type' => 'color',
				'label' => __pl('list_color_label'),
				'css' => ['{{element}} .pagelayer-list-ul > div:hover .pagelayer-list-item' => 'color:{{val}}'],
				'show' =>['list_text_state' => 'hover']
			),
			'list_bg_hover' => array(
				'type' => 'color',
				'label' => __pl('bg_color'),
				'css' => ['{{element}} .pagelayer-list-ul > div:hover' => 'background-color:{{val}}'],
				'show' =>['list_text_state' => 'hover']
			),
			'list_typo_hover' => array(
				'type' => 'typography',
				'label' => __pl('list_typo'),
				'css' => [
					'{{element}} .pagelayer-list-ul > div:hover li' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;',
					'{{element}} .pagelayer-list-ul > div:hover li > a' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'
				],
				'show' =>['list_text_state' => 'hover']
			),
		],
		'icon_style' => [
			'list_icon_state' => array(
				'type' => 'radio',
				'label' => __pl('state'),
				'default' => 'normal',
				'list' => [
					'normal' => __pl('normal'),
					'hover' => __pl('hover')
				],
			),
			'icon_color' => array(
				'type' => 'color',
				'label' => __pl('list_icon_color_label'),
				'default' => '#0986c0',
				'css' => ['{{element}} .pagelayer-list-icon' => 'color:{{val}}'],
				'show' => ['list_icon_state' => 'normal'],
			),
			'icon_size' => array(
				'type' => 'slider',
				'label' => __pl('list_icon_size_label'),
				'min' => 0,
				'step' => 1,
				'max' => 150,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-list-icon' => 'font-size: {{val}}px'],
				'show' => ['list_icon_state' => 'normal'],
			),
			'icon_hover_delay' => array(
				'type' => 'spinner',
				'label' => __pl('delay'),
				'min' => 0,
				'step' => 100,
				'max' => 5000,
				'css' => ['{{element}} .pagelayer-list-icon' => 'transition: all {{val}}ms;'],
				'show' =>['list_icon_state' => 'hover']
			),
			'icon_color_hover' => array(
				'type' => 'color',
				'label' => __pl('list_icon_color_label'),
				'css' => ['{{element}} .pagelayer-list-ul > div:hover .pagelayer-list-icon' => 'color:{{val}}'],
				'show' => ['list_icon_state' => 'hover'],
			),
			'icon_size_hover' => array(
				'type' => 'slider',
				'label' => __pl('list_icon_size_label'),
				'min' => 0,
				'step' => 1,
				'max' => 150,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-list-ul > div:hover .pagelayer-list-icon' => 'font-size: {{val}}px'],
				'show' => ['list_icon_state' => 'hover'],
			),
		],
		'divider' => [
			'icon_border_type' => array(
				'type' => 'select',
				'label' => __pl('type'),
				'css' => ['{{element}} .pagelayer-list-ul > div:not(:last-child)' => 'border-bottom-style: {{val}};'],
				'default' => 'solid',
				'list' => [
					'' => __pl('none'),
					'solid' => __pl('solid'),
					'double' => __pl('double'),
					'dotted' => __pl('dotted'),
					'dashed' => __pl('dashed'),
					'groove' => __pl('groove'),
				],
			),
			'icon_border_color' => array(
				'type' => 'color',
				'label' => __pl('color'),
				'default' => '#cbd2dc78',
				'css' => ['{{element}} .pagelayer-list-ul > div' => 'border-bottom-color: {{val}};'],
				'req' => array(
					'!icon_border_type' => ''
				),
			),
			'icon_border_width' => array(
				'type' => 'slider',
				'label' => __pl('border_width'),
				'min' => 0,
				'step' => 1,
				'max' => 100,
				'default' => 3,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-list-ul > div' => 'border-bottom-width: {{val}}px;'],
				'req' => [
					'!icon_border_type' => ''
				]
			),
		],
		'styles' => [
			'text_style' => __pl('text_style'),
			'icon_style' => __pl('icon_style'),
			'divider' => __pl('divider'),
		]
	)
);

// Icon
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_icon', array(
		'name' => __pl('icon'),
		'group' => 'text',
		'html' => '<div class="pagelayer-icon-holder">
					<a if-ext="{{link}}" class="pagelayer-ele-link" href="{{{link}}}">
						<i class="{{icon}} {{bg_shape}} {{icon_size}} pagelayer-animation-{{anim_hover}}"></i>
					</a>
				</div>',
		'params' => array(
			'icon' => array(
				'type' => 'icon',
				'label' => __pl('list_icon_label'),
				'default' => 'fas fa-star',
			),
			'icon_background_size' => array(
				'type' => 'spinner',
				'label' => __pl('service_box_icon_background_size'),
				'default' => 10,
				'screen' => 1,
				'css' => ['{{element}} i' => 'padding: calc(0.5em + {{val}}px);'],
				'min' => 1,
				'max' => 500,
				'step' => 1,
			),
			'link' => array(
				'type' => 'link',
				'label' => __pl('icon_link_field_label'),
				'selector' => '.pagelayer-ele-link'
			),
			'icon_alignment' => array(
				'type' => 'radio',
				'label' => __pl('alignment'),
				'default' => 'center',
				'screen' => 1,
				'css' => 'text-align: {{val}}',
				'list' => array(
					'left' => __pl('left'),
					'center' => __pl('center'),
					'right' => __pl('right'),
				),
			),
		),
		'icon_style' => [
			'icon_hover' => array(
				'type' => 'radio',
				'label' => '',
				'default' => '',
				'list' => array(
					'' => __pl('normal'),
					'hover' => __pl('hover'),
				),
			),
			'icon_color_style' => array(
				'type' => 'color',
				'label' => __pl('service_box_icon_color_label'),
				'css' => ['{{element}} i' => 'height: 1em; width: 1em; position: relative; color: {{val}};',
					'{{element}} i:before' => 'position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);'],
				'default' => '#0986c0',
				'show' => array(
					'icon_hover' => ''
				),
			),
			'bg_shape' => array(
				'type' => 'select',
				'label' => __pl('icon_background_shape'),
				'default' => '',
				'list' => array(
					'' => __pl('icon_shape_none'),
					'pagelayer-icon-circle' => __pl('icon_shape_circle'),
					'pagelayer-icon-square' => __pl('icon_shape_square'),
					'pagelayer-icon-rounded' => __pl('icon_shape_rounded')
				),
				'show' => array(
					'icon_hover' => ''
				),
			),
			'icon_size' => array(
				'type' => 'select',
				'label' => __pl('obj_size_label'),
				'default' => 'pagelayer-icon-large',
				'list' => array(
					'pagelayer-icon-mini' => __pl('mini'),
					'pagelayer-icon-small' => __pl('small'),
					'pagelayer-icon-large' => __pl('large'),
					'pagelayer-icon-extra-large' => __pl('extra_large'),
					'pagelayer-icon-double-large' => __pl('double_large'),
					'pagelayer-icon-custom' => __pl('custom'),
				),
				'show' => array(
					'icon_hover' => ''
				),
			),
			'icon_size_custom' => array(
				'type' => 'spinner',
				'label' => __pl('service_box_icon_custom_size_label'),
				'desc' => __pl('service_box_icon_custom_size_desc'),
				'min' => 1,
				'step' => 1,
				'max' => 500,
				'default' => 26,
				'screen' => 1,
				'css' => ['{{element}} i' => 'font-size: {{val}}px'],
				'req' => array(
					'icon_size' => 'pagelayer-icon-custom'
				),
				'show' => array(
					'icon_hover' => ''
				),
			),
			'icon_rotate' => array(
				'type' => 'spinner',
				'label' => __pl('service_box_icon_rotate'),
				'default' => 0,
				'css' => ['{{element}} i' => 'transform: rotate({{val}}deg)'],
				'min' => -360,
				'max' => 360,
				'step' => 1,
				'screen' => 1,
				'show' => array(
					'icon_hover' => ''
				),
			),
			'icon_bg_rotate' => array(
				'type' => 'spinner',
				'label' => __pl('rotate_icon'),
				'default' => 0,
				'css' => ['{{element}} i:before' => 'transform: translate(-50%, -50%) rotate({{val}}deg)'],
				'min' => -360,
				'max' => 360,
				'step' => 1,
				'screen' => 1,
				'show' => array(
					'icon_hover' => ''
				),
				'req' => [ '!bg_shape' => '']
			),
			'bg_color' => array(
				'type' => 'color',
				'label' => __pl('service_box_icon_background_color_label'),
				'default' => '#42414f',
				'css' => ['{{element}} i' => 'background-color: {{val}};'],
				'req' => array(
					'!bg_shape' => ''
				),
				'show' => array(
					'icon_hover' => ''
				),
			),
			'icon_hover_delay' => array(
				'type' => 'spinner',
				'label' => __pl('animation_delay'),
				'min' => 0,
				'step' => 100,
				'max' => 5000,
				'default' => 400,
				'screen' => 1,
				'css' => ['{{element}} i' => '-webkit-transition: all {{val}}ms; transition: all {{val}}ms;',
				'{{element}} i:hover:before' => '-webkit-transition: all {{val}}ms; transition: all {{val}}ms;'],
				'show' => array(
					'icon_hover' => 'hover'
				),
			),
			'icon_color_style_hover' => array(
				'type' => 'color',
				'label' => __pl('service_box_icon_color_label'),
				'css' => ['{{element}} i:hover' => 'height: 1em; width: 1em; position: relative; color: {{val}}',
					'{{element}} i:before' => 'position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);'],
				'show' => array(
					'icon_hover' => 'hover'
				),
			),
			'icon_size_custom_hover' => array(
				'type' => 'spinner',
				'label' => __pl('service_box_icon_custom_size_label'),
				'desc' => __pl('service_box_icon_custom_size_desc'),
				'min' => 1,
				'step' => 1,
				'max' => 500,
				'screen' => 1,
				'css' => ['{{element}} i:hover' => 'font-size: {{val}}px'],
				'req' => array(
					'icon_size' => 'pagelayer-icon-custom'
				),
				'show' => array(
					'icon_hover' => 'hover'
				),
			),
			'anim_hover' => array(
				'type' => 'select',
				'label' => __pl('icon_animation'),
				'list' => [
					'' => __pl('none'),
					'grow' => __pl('Grow'),
					'shrink' => __pl('Shrink'),
					'pulse' => __pl('Pulse'),
					'pulse-grow' => __pl('Pulse Grow'),
					'pulse-shrink' => __pl('Pulse Shrink'),
					'push' => __pl('Push'),
					'pop' => __pl('Pop'),
					'buzz' => __pl('Buzz'),
					'buzz-out' => __pl('Buzz Out'),
					'float' => __pl('Float'),
					'sink' => __pl('Sink'),
					'bob' => __pl('Bob'),
					'hang' => __pl('Hang'),
					'bounce-in' => __pl('Bounce In'),
					'bounce-out' => __pl('Bounce Out'),
					'rotate' => __pl('Rotate'),
					'grow-rotate' => __pl('Grow Rotate'),
					'skew-forward' => __pl('Skew Forward'),
					'skew-backward' => __pl('Skew Backward'),
					'wobble-vertical' => __pl('Wobble Vertical'),
					'wobble-horizontal' => __pl('Wobble Horizontal'),
					'wobble-bottom-to-right' => __pl('Wobble Bottom To Right'),
					'wobble-top-to-right' => __pl('Wobble Top To Right'),
					'wobble-top' => __pl('Wobble Top'),
					'wobble-bottom' => __pl('Wobble Bottom'),
					'wobble-skew' => __pl('Wobble Skew'),
				],
				'show' => array(
					'icon_hover' => 'hover',
				),
			),
			'icon_rotate_hover' => array(
				'type' => 'spinner',
				'label' => __pl('service_box_icon_rotate'),
				'default' => 0,
				'css' => ['{{element}} i:hover' => 'transform: rotate({{val}}deg)'],
				'min' => 0,
				'max' => 360,
				'step' => 1,
				'screen' => 1,
				'show' => array(
					'icon_hover' => 'hover'
				),
				'req' => [ '!bg_shape' => '']
			),
			'icon_bg_rotate_hover' => array(
				'type' => 'spinner',
				'label' => __pl('rotate_icon'),
				'default' => 0,
				'css' => ['{{element}} i:hover:before' => 'transform: translate(-50%, -50%) rotate({{val}}deg)'],
				'min' => 0,
				'max' => 360,
				'step' => 1,
				'screen' => 1,
				'show' => array(
					'icon_hover' => 'hover'
				),
			),
			'bg_color_hover' => array(
				'type' => 'color',
				'label' => __pl('service_box_icon_background_color_label'),
				'css' => ['{{element}} i:hover' => 'background-color: {{val}};'],
				'req' => array(
					'!bg_shape' => ''
				),
				'show' => array(
					'icon_hover' => 'hover'
				),
			),
			'icon_background_size_hover' => array(
				'type' => 'spinner',
				'label' => __pl('service_box_icon_background_size'),
				'css' => ['{{element}} i:hover' => 'padding: calc(0.5em + {{val}}px)'],
				'min' => 1,
				'max' => 500,
				'step' => 1,
				'screen' => 1,
				'req' => array(
					'!bg_shape' => ''
				),
				'show' => array(
					'icon_hover' => 'hover'
				),
			)
		],
		'border_style' => [
			'icon_border_hover' => array(
				'type' => 'radio',
				'label' => '',
				'default' => '',
				'list' => array(
					'' => __pl('normal'),
					'hover' => __pl('hover'),
				),
			),
			'icon_border_type' => array(
				'type' => 'select',
				'label' => __pl('border_type'),
				'css' => ['{{element}} i' => 'border-style: {{val}}'],
				'list' => [
					'' => __pl('none'),
					'solid' => __pl('solid'),
					'double' => __pl('double'),
					'dotted' => __pl('dotted'),
					'dashed' => __pl('dashed'),
					'groove' => __pl('groove'),
				],
				'show' => array(
					'icon_border_hover' => ''
				),
			),
			'icon_border_color' => array(
				'type' => 'color',
				'label' => __pl('service_box_icon_border_color_label'),
				'default' => '#0986c0',
				'css' => ['{{element}} i' => 'border-color: {{val}};'],
				'req' => array(
					'!icon_border_type' => ''
				),
				'show' => array(
					'icon_border_hover' => ''
				),
			),
			'icon_border_width' => array(
				'type' => 'padding',
				'label' => __pl('border_width'),
				'screen' => 1,
				'css' => ['{{element}} i' => 'border-top-width: {{val[0]}}px; border-right-width: {{val[1]}}px; border-bottom-width: {{val[2]}}px; border-left-width: {{val[3]}}px'],
				'req' => [
					'!icon_border_type' => ''
				],
				'show' => array(
					'icon_border_hover' => ''
				),
			),
			'icon_border_radius' => array(
				'type' => 'padding',
				'label' => __pl('border_radius'),
				'screen' => 1,
				'css' => ['{{element}} i' => 'border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px; -webkit-border-radius:  {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px;-moz-border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px;'],
				'req' => array(
					'!icon_border_type' => ''
				),
				'show' => array(
					'icon_border_hover' => ''
				),
			),
			'icon_border_type_hover' => array(
				'type' => 'select',
				'label' => __pl('border_type'),
				'css' => ['{{element}} i:hover' => 'border-style: {{val}}'],
				'list' => [
					'' => __pl('none'),
					'solid' => __pl('solid'),
					'double' => __pl('double'),
					'dotted' => __pl('dotted'),
					'dashed' => __pl('dashed'),
					'groove' => __pl('groove'),
				],
				'show' => array(
					'icon_border_hover' => 'hover'
				),
			),
			'icon_border_color_hover' => array(
				'type' => 'color',
				'label' => __pl('service_box_icon_border_color_label'),
				'css' => ['{{element}} i:hover' => 'border-color: {{val}};'],
				'default' => '#0986c0',
				'req' => array(
					'!icon_border_type_hover' => ''
				),
				'show' => array(
					'icon_border_hover' => 'hover'
				),
			),
			'icon_border_width_hover' => array(
				'type' => 'padding',
				'label' => __pl('border_width'),
				'screen' => 1,
				'css' => ['{{element}} i:hover' => 'border-top-width: {{val[0]}}px; border-right-width: {{val[1]}}px; border-bottom-width: {{val[2]}}px; border-left-width: {{val[3]}}px'],
				'req' => [
					'!icon_border_type_hover' => ''
				],
				'show' => array(
					'icon_border_hover' => 'hover'
				),
			),
			'icon_border_radius_hover' => array(
				'type' => 'padding',
				'label' => __pl('border_radius'),
				'screen' => 1,
				'css' => ['{{element}} i:hover' => 'border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px; -webkit-border-radius:  {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px;-moz-border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px;'],
				'req' => array(
					'!icon_border_type_hover' => ''
				),
				'show' => array(
					'icon_border_hover' => 'hover'
				),
			),
		],
		'styles' => [
			'icon_style' => __pl('icon_style_hover'),
			'border_style' => __pl('border'),
		]
	)
);

// Badge
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_badge', array(
		'name' => __pl('Badge'),
		'group' => 'text',
		'innerHTML' => 'title',
		'html' => '<div class="pagelayer-badge-span">
					<span if="{{text}}" class="pagelayer-badge-text">{{text}}</span>
					<a if-ext="{{badge_url}}" class="pagelayer-ele-link" href="{{{badge_url}}}">
						<span if="{{badge_text}}" class="pagelayer-badge-title pagelayer-badge-details pagelayer-badge-{{badge_notification_type}} pagelayer-badge-{{badge_style_type}}">{{badge_text}}</span>
					</a>
				</div>
				<a if-ext="{{badge_url}}" class="pagelayer-ele-link" href="{{{badge_url}}}">
					<button class="pagelayer-badge-btn pagelayer-btn-{{badge_btn_type}}">
						<span if="{{text}}" class="pagelayer-badge-text">{{text}}</span>
						<span if="{{badge_text}}" class="pagelayer-badge-title pagelayer-badge-details pagelayer-badge-{{badge_notification_type}} pagelayer-badge-{{badge_style_type}}">{{badge_text}}</span>
					</button>
				</a>',
		'params' => array(
			'badge_text' => array(
				'type' => 'text',
				'label' => __pl('badge_text'),
				'default' => 'Badge',
				'edit' => '.pagelayer-badge-title',
			),
			'badge_url' => array(
				'type' => 'link',
				'label' => __pl('badge_url_label'),
				'selector' => '.pagelayer-ele-link',
			),
			'badge_notification_type' => array(
				'type' => 'select',
				'label' => __pl('badge_notification_type'),
				'default' => 'primary',
				'list' => [					
					'primary' => __pl('Primary'),
					'secondary' => __pl('Secondary'),
					'success' => __pl('Success'),
					'warning' => __pl('Warning'),
					'danger' => __pl('Danger'),
					'info' => __pl('Info'),
					'light' => __pl('Light'),
					'dark' => __pl('Dark'),
					'custom' => __pl('Custom'),
				],				
			),
			'custom_badge_state' => array(
				'type' => 'radio',
				'label' => __pl('state'),
				'default' => '',
				'list' => array(
					'' => __pl('normal'),
					'hover' => __pl('hover'),
				),
				'req' => ['badge_notification_type' => 'custom'],
			),
			'custom_badge_text_color' => array(
				'type' => 'color',
				'label' => __pl('badge_text_color_label'),
				'css' => ['{{element}} .pagelayer-badge-title' => 'color:{{val}} !important;'],		
				'show' => ['custom_badge_state' => ''],				
				'req' => ['badge_notification_type' => 'custom'],				
			),
			'custom_badge_bg_color' => array(
				'type' => 'color',
				'label' => __pl('bg_color'),
				'css' => ['{{element}} .pagelayer-badge-title' => 'background-color:{{val}} !important;'],		
				'show' => ['custom_badge_state' => ''],				
				'req' => ['badge_notification_type' => 'custom'],				
			),
			'custom_badge_text_color_hover' => array(
				'type' => 'color',
				'label' => __pl('badge_text_color_label'),
				'css' => ['{{element}} .pagelayer-badge-title:hover' => 'color:{{val}} !important;'],		
				'show' => ['custom_badge_state' => 'hover'],
				'req' => ['badge_notification_type' => 'custom'],
			),
			'custom_badge_bg_color_hover' => array(
				'type' => 'color',
				'label' => __pl('bg_color'),
				'css' => ['{{element}} .pagelayer-badge-title:hover' => 'background-color:{{val}} !important;'],		
				'show' => ['custom_badge_state' => 'hover'],
				'req' => ['badge_notification_type' => 'custom'],
			),
			'badge_style_type' => array(
				'type' => 'select',
				'label' => __pl('badge_style'),
				'default' => 'normal',
				'list' => [					
					'normal' => __pl('Normal'),
					'pills' => __pl('Pills'),					
				],				
			),
			'badge_vertical_align' => array(
				'type' => 'select',
				'label' => __pl('badge_vertical_align'),
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-badge-details' => 'vertical-align:{{val}};'],
				'list' => [
					'' => __pl('none'),
					'top' => __pl('Top'),					
					'bottom' => __pl('Bottom'),
				],
				'req' => array(
					'badge_button' => '',
				)							
			),
		),
		'text_style' => [
			'text' => array(
				'type' => 'text',
				'label' => __pl('text'),
				'default' => 'Your custom text',
				'edit' => '.pagelayer-badge-text',
			),
			'text_state' => array(
				'type' => 'radio',
				'label' => __pl('state'),
				'default' => '',
				'list' => array(
					'' => __pl('normal'),
					'hover' => __pl('hover'),
				)
			),
			'text_color' => array(
				'type' => 'color',
				'label' => __pl('badge_text_color_label'),
				'default' => '#000000',
				'css' => ['{{element}} .pagelayer-badge-text' => 'color:{{val}};'],		
				'show' => ['text_state' => '']				
			),
			'text_color_hover' => array(
				'type' => 'color',
				'label' => __pl('badge_text_color_label'),
				'css' => ['{{element}} .pagelayer-badge-text:hover' => 'color:{{val}};'],		
				'show' => ['text_state' => 'hover']				
			),
			'text_style' => array(
				'type' => 'typography',
				'label' => __pl('text_size'),
				'default' => ',25,,400,,,,,,,',
				'css' => ['{{element}} .pagelayer-badge-text' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'],
			),
		],
		'badge_style' => [
			'badge_text_color' => array(
				'type' => 'color',
				'label' => __pl('badge_text_color_label'),
				'default' => '#ffffff',
				'css' => ['{{element}} .pagelayer-badge-custom' => 'color:{{val}};'],				
				'req' => ['badge_notification_type' => 'custom'],
			),
			'badge_spacing' => array(
				'type' => 'slider',
				'label' => __pl('badge_spacing'),
				'default' => 2,
				'min' => 1,
				'max' => 100,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-badge-details' => 'margin-left:{{val}}px;'],
			),
			'badge_background_color' => array(
				'type' => 'color',
				'label' => __pl('badge_text_background_label'),
				'default' => '#4982ee',
				'css' => ['{{element}} .pagelayer-badge-custom' => 'background-color:{{val}};'],
				'req' => ['badge_notification_type' => 'custom'],
			),
			'badge_vspacing' => array(
				'type' => 'slider',
				'label' => __pl('quote_vertical_padding'),
				'default' => 2,
				'min' => 0,
				'max' => 100,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-badge-details' => 'padding-top:{{val}}px; padding-bottom:{{val}}px;'],
			),
			'badge_hspacing' => array(
				'type' => 'slider',
				'label' => __pl('horizontal_spacing'),
				'default' => 2,
				'min' => 0,
				'max' => 100,
				'screen' => 1,				
				'css' => ['{{element}} .pagelayer-badge-details' => 'padding-left:{{val}}px; padding-right:{{val}}px;'],
			),
			'badge_text_style' => array(
				'type' => 'typography',
				'label' => __pl('badge_text_size'),
				'default' => ',16,,400,,,,,,,',
				'css' => ['{{element}} .pagelayer-badge-details' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'],
			),									
		],
		'btn_badge' => [
			'badge_button' => array(
				'type' => 'checkbox',
				'label' => __pl('button_badge'),
				'css' => ['{{element}} .pagelayer-badge-btn '=> 'display : block;',
					'{{element}} .pagelayer-badge-span'=> 'display : none;',
				],						
			),
			'badge_btn_type' => array(
				'type' => 'select',
				'label' => __pl('badge_btn_type'),
				'default' => 'warning',
				'list' => [					
					'primary' => __pl('Primary'),
					'secondary' => __pl('Secondary'),
					'success' => __pl('Success'),
					'warning' => __pl('Warning'),
					'danger' => __pl('Danger'),
					'info' => __pl('Info'),
					'light' => __pl('Light'),
					'dark' => __pl('Dark'),
					'custom' => __pl('Custom'),
				],
				'req' => array(
					'badge_button' => 'true',
				)				
			),
			'badge_btn_hover' => array(
				'type' => 'radio',
				'label' => '',
				'default' => '',
				'list' => array(
					'' => __pl('normal'),
					'hover' => __pl('hover'),
				),
				'req' => array(
					'badge_button' => 'true',
					'badge_btn_type' => 'custom',
				),
			),						
			'badge_btn_background_color' => array(
				'type' => 'color',
				'label' => __pl('badge_btn_background_label'),
				'default' => '#4982ee',
				'css' => ['{{element}} .pagelayer-badge-btn' => 'background-color:{{val}};'],
				'req' => [
					'badge_btn_type' => 'custom',
					'badge_button' => 'true',
				],
				'show' => ['badge_btn_hover' => ''],
			),					
			'badge_btn_background_color_hover' => array(
				'type' => 'color',
				'label' => __pl('badge_btn_background_label'),
				'default' => '#4982ee',
				'css' => ['{{element}} .pagelayer-badge-btn:hover' => 'background-color:{{val}};'],			
				'show' => ['badge_btn_hover' => 'hover'],
			),
		],
		'styles' => [
			'text_style' => __pl('text'),
			'badge_style' => __pl('badge_style'),
			'btn_badge' => __pl('btn_badge'),
		]
	)
);

// Tooltip
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_tooltip', array(
		'name' => __pl('Tooltip'),
		'group' => 'text',
		'innerHTML' => 'tooltip_text',
		'html' => '<div class="pagelayer-tooltip-container">
					<span if="{{tooltip_icon}}" class="pagelayer-tooltip-icon"><i class="{{tooltip_icon}}"></i></span>
					<span if="{{text}}" class="pagelayer-tooltip-title">{{text}}</span>
					<div if="{{tooltip_text}}" class="pagelayer-tooltip-text pagelayer-tooltip-{{tooltip_position}}">
						{{tooltip_text}}
					</div>
				</div>',
		'params' => array(
			'text' => array(
				'type' => 'text',
				'label' => __pl('text'),
				'default' => __pl('hover_me'),
				'edit' => '.pagelayer-tooltip-title',
			),
			'tooltip_text' => array(
				'type' => 'editor',
				'label' => __pl('tooltip_text'),
				'default' => 'Hey there, I have an amazing tooltip !',
				'edit' => '.pagelayer-tooltip-text',
			),
		),
		'text_style' => [
			'tooltip_align' => array(
				'label' => __pl('tooltip_align'),
				'type' => 'select',
				'default' => 'center',
				'screen' => 1,
				'css' => 'text-align: {{val}};',
				'list' => array(
					'left' => __pl('left'),
					'center' => __pl('center'),
					'right' => __pl('right'),
				)
			),
			'text_color' => array(
				'type' => 'color',
				'label' => __pl('tooltip_title_color'),
				'css' => ['{{element}} .pagelayer-tooltip-title' => 'color:{{val}};'],				
			),
			'text_size' => array(
				'type' => 'typography',
				'label' => __pl('tooltip_title_size'),
				'default' => ',25,,400,,,,,,,',
				'css' => ['{{element}} .pagelayer-tooltip-title' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;',
				'{{element}} .pagelayer-tooltip-icon i' => 'font-size: {{val[1]}}px !important;'],
			),
			'tooltip_text_shadow' => array(
				'type' => 'shadow',
				'label' => __pl('tooltip_text_shadow'),
				'css' => ['{{element}} .pagelayer-tooltip-title' => 'text-shadow: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}};',
				'{{element}} .pagelayer-tooltip-icon i' => 'text-shadow: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}};'],
			),
		],
		'tooltip_style' => [
			'tooltip_position' => array(
				'type' => 'select',
				'label' => __pl('tooltip_positon'),
				'default' => 'top',
				'list' => [
					'top' => __pl('Top'),					
					'right' => __pl('Right'),
					'bottom' => __pl('Bottom'),
					'left' => __pl('Left'),
				],											
			),
			'tooltip_width' => array(
				'label' => __pl('tooltip-width'),
				'type' => 'slider',
				'min' => 100,
				'max' => 500,
				'default' => 200,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-tooltip-text' => 'width:{{val}}px;'],
			),
			'tooltip_spacing' => array(
				'label' => __pl('tooltip_spacing'),
				'type' => 'slider',
				'min' => 0,
				'max' => 100,
				'default' => 10,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-tooltip-text' => 'padding:{{val}}px;'],
			),
			'tooltip_background' => array(
				'type' => 'color',
				'label' => __pl('tooltip_background_color'),
				'default' => '#333333',
				'css' => ['{{element}} .pagelayer-tooltip-text' => 'background-color:{{val}};',
					'{{element}} .pagelayer-tooltip-top:after' => 'border-top-color:{{val}};',
					'{{element}} .pagelayer-tooltip-right:after' => 'border-right-color:{{val}};',
					'{{element}} .pagelayer-tooltip-bottom:after' => 'border-bottom-color:{{val}};',
					'{{element}} .pagelayer-tooltip-left:after' => 'border-left-color:{{val}};',
				],				
			),
			'tooltip_color' => array(
				'type' => 'color',
				'label' => __pl('tooltip_text_color'),
				'default' => '#ffffff',
				'css' => ['{{element}} .pagelayer-tooltip-text' => 'color:{{val}};'],				
			),
			'tooltip_text_size' => array(
				'type' => 'typography',
				'label' => __pl('tooltip_text_size'),
				'default' => ',18,,400,,,,,,,',
				'css' => ['{{element}} .pagelayer-tooltip-text' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'],
			),
			'tooltip_shadow' => array(
				'type' => 'box_shadow',
				'label' => __pl('tooltip_shadow'),
				'css' => ['{{element}} .pagelayer-tooltip-text' => 'box-shadow: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[4]}}px {{val[3]}} {{val[5]}};'],
			),
		],
		'icon_style' => [
			'show_icon' => array(
				'type' => 'checkbox',
				'label' => __pl('show_icon'),										
			),
			'tooltip_icon' => array(
				'type' => 'icon',
				'label' => __pl('tooltip_icon'),
				'default' => 'fas fa-exclamation-circle',
				'req' => array(
					'show_icon' => 'true',
				)	
			),
			'icon_color' => array(
				'type' => 'color',
				'label' => __pl('tooltip_icon_color'),
				'default' => '#0986c0',
				'css' => ['{{element}} .pagelayer-tooltip-icon' => 'color:{{val}};'],
				'req' => array(
					'show_icon' => 'true',
				)
			),
			'icon_spacing' => array(
				'label' => __pl('icon_space'),
				'type' => 'slider',
				'min' => 0,
				'max' => 100,
				'default' => 4,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-tooltip-icon' => 'margin-left:{{val}}px; margin-right:{{val}}px;'],
				'req' => array(
					'show_icon' => 'true',
				)
			),
			'tooltip_icon_alignment' => array(
				'label' => __pl('tooltip_icon_alignment'),
				'type' => 'radio',
				'default' => 'right',
				'css' => ['{{element}} .pagelayer-tooltip-icon' => 'float: {{val}};'],
				'list' => array(
					'left' => __pl('left'),
					'right' => __pl('right'),
				),
				'req' => array(
					'show_icon' => 'true',
				)
			)
		],
		'styles' => [
			'icon_style' => __pl('icon'),
			'text_style' => __pl('text_style'),
			'tooltip_style' => __pl('tooltip_style'),
		]
	)
);


////////////////////////
// Image Group
////////////////////////

// Image
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_image', array(
		'name' => __pl('image'),
		'group' => 'image',
		'innerHTML' => 'text',
		'html' => '<div class="pagelayer-image-holder pagelayer-anim-par">
			<a if-ext="{{link_type}}" class="pagelayer-ele-link" href="{{func_link}}" pagelayer-image-link-type="{{link_type}}">
				<img class="pagelayer-img pagelayer-animation-{{anim_hover}}" src="{{func_id}}" title="{{{id-title}}}" alt="{{{id-alt}}}" srcset="{{pagelayer-srcset}}" />
				<div if="{{overlay}}" class="pagelayer-image-overlay {{content_position}}">
					<div class="pagelayer-image-overlay-content">
						<i if="{{icon}}" class="pagelayer-image-overlay-icon {{icon}}"></i>
						<div if="{{text}}" class="pagelayer-image-overlay-text">{{text}}</div>
					</div>
				</div>
			</a>
		</div>
		<p if="{{caption}}" class="pagelayer-image-caption">{{caption}}</p>',
		'params' => array(
			'id' => array(
				'label' => __pl('image_src_label'),
				'desc' => __pl('image_src_desc'),
				'type' => 'image',
				'default' => PAGELAYER_URL.'/images/default-image.png',
				'retina' => 1,
			),
			'id-size' => array(
				'label' => __pl('obj_image_size_label'),
				'type' => 'select',
				'default' => 'full',
				'list' => array(
					'full' => __pl('full'),
					'large' => __pl('large'),
					'medium' => __pl('medium'),
					'thumbnail' => __pl('thumbnail'),
					'custom' => __pl('custom')
				)
			),
			'custom_size' => array(
				'label' => __pl('image_custom_size_label'),
				'type' => 'text',
				'screen' => 1,
				'default' => '100x100',
				'sep' => 'x',
				'css' => ['{{element}} img' => 'width: {{val[0]}}px; height: {{val[1]}}px;'],
				'req' => array(
					'id-size' => 'custom'
				),
			),
			'align' => array(
				'label' => __pl('obj_align_label'),
				'type' => 'radio',
				'default' => 'center',
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-image-holder' => 'text-align: {{val}}', '{{element}} .pagelayer-image-holder .pagelayer-image-overlay-content' => 'text-align: {{val}}'],
				'list' => array(
					'left' => __pl('left'),
					'center' => __pl('center'),
					'right' => __pl('right')
				)
			),
			'max-width' => array(
				'label' => __pl('max-width-percent'),
				'type' => 'slider',
				'min' => 0,
				'max' => 100,
				'screen' => 1,
				'css' => ['{{element}} img' => 'max-width: {{val}}%'],
			),
			'img_hover' => array(
				'type' => 'radio',
				'label' => __pl('state'),
				'default' => 'normal',
				'list' => array(
					'normal' => __pl('normal'),
					'hover' => __pl('hover'),
				),
			),
			'img_filter' => array(
				'type' => 'filter',
				'label' => __pl('filter'),
				//'default' => '0,100,100,0,0,100,100',
				'css' => ['{{element}} img' => 'filter: blur({{val[0]}}px) brightness({{val[1]}}%) contrast({{val[2]}}%) grayscale({{val[3]}}%) hue-rotate({{val[4]}}deg) opacity({{val[5]}}%) saturate({{val[6]}}%)'],
				'show' => ['img_hover' => 'normal']
			),
			'img_shadow' => array(
				'type' => 'box_shadow',
				'label' => __pl('shadow'),
				'screen' => 1,
				'css' => ['{{element}} img' => 'box-shadow: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[4]}}px {{val[3]}} {{val[5]}} !important;'],
				'show' => ['img_hover' => 'normal']
			),
			'img_rotate' => array(
				'type' => 'spinner',
				'label' => __pl('Rotate'),
				'min' => 0,
				'max' => 360,
				'step' => 1,
				'screen' => 1,
				'css' => ['{{element}} img' => 'transform: rotate({{val}}deg)'],
				'show' => ['img_hover' => 'normal'],
				'pro' => 1
			),
			'img_hover_delay' => array(
				'type' => 'spinner',
				'label' => __pl('btn_hover_delay_label'),
				'desc' => __pl('btn_hover_delay_desc'),
				'min' => 0,
				'step' => 100,
				'max' => 5000,
				'default' => 400,
				'css' => ['{{element}} .pagelayer-img' => '-webkit-transition: all {{val}}ms; transition: all {{val}}ms;',],
				'show' => ['img_hover' => 'hover']
			),
			'img_filter_hover' => array(
				'type' => 'filter',
				'label' => __pl('filter'),
				//'default' => '0,100,100,0,0,100,100',
				'css' => ['{{element}} img:hover' => 'filter: blur({{val[0]}}px) brightness({{val[1]}}%) contrast({{val[2]}}%) grayscale({{val[3]}}%) hue-rotate({{val[4]}}deg) opacity({{val[5]}}%) saturate({{val[6]}}%)'],
				'show' => ['img_hover' => 'hover']
			),
			'img_shadow_hover' => array(
				'type' => 'box_shadow',
				'label' => __pl('shadow'),
				'screen' => 1,
				'css' => ['{{element}} img:hover' => 'box-shadow: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[4]}}px {{val[3]}} {{val[5]}} !important;'],
				'show' => ['img_hover' => 'hover']
			),
			'img_rotate_hover' => array(
				'type' => 'spinner',
				'label' => __pl('Rotate'),
				'min' => 0,
				'max' => 360,
				'step' => 1,
				'screen' => 1,
				'css' => ['{{element}} img:hover' => 'transform: rotate({{val}}deg)'],
				'show' => ['img_hover' => 'hover'],
				'pro' => 1
			),
			'anim_hover' => array(
				'type' => 'select',
				'label' => __pl('icon_animation'),
				'list' => [
					'' => __pl('none'),
					'grow' => __pl('Grow'),
					'shrink' => __pl('Shrink'),
					'pulse' => __pl('Pulse'),
					'pulse-grow' => __pl('Pulse Grow'),
					'pulse-shrink' => __pl('Pulse Shrink'),
					'push' => __pl('Push'),
					'pop' => __pl('Pop'),
					'buzz' => __pl('Buzz'),
					'buzz-out' => __pl('Buzz Out'),
					'float' => __pl('Float'),
					'sink' => __pl('Sink'),
					'bob' => __pl('Bob'),
					'hang' => __pl('Hang'),
					'bounce-in' => __pl('Bounce In'),
					'bounce-out' => __pl('Bounce Out'),
					'rotate' => __pl('Rotate'),
					'grow-rotate' => __pl('Grow Rotate'),
					'skew-forward' => __pl('Skew Forward'),
					'skew-backward' => __pl('Skew Backward'),
					'wobble-vertical' => __pl('Wobble Vertical'),
					'wobble-horizontal' => __pl('Wobble Horizontal'),
					'wobble-bottom-to-right' => __pl('Wobble Bottom To Right'),
					'wobble-top-to-right' => __pl('Wobble Top To Right'),
					'wobble-top' => __pl('Wobble Top'),
					'wobble-bottom' => __pl('Wobble Bottom'),
					'wobble-skew' => __pl('Wobble Skew'),
				],
				'show' => ['img_hover' => 'hover'],
				'pro' => 1
			),
		),
		// Image related Styles
		'link_settings' => [
			'link_type' => array(
				'type' => 'select',
				'label' => __pl('image_link_label'),
				'default' => '',
				'list' => array(
					'' => __pl('none'),
					'custom_url' => __pl('custom_url'),
					'media_file' => __pl('media_file'),
					'lightbox' => __pl('lightbox')
				)
			),
			'link' => array(
				'type' => 'link',
				'label' => __pl('image_link_label'),
				'desc' => __pl('image_link_desc'),
				'selector' => '.pagelayer-ele-link',
				'req' => array(
					'link_type' => 'custom_url'
				)
			),
			'rel' => array(
				'type' => 'text',
				'label' => __pl('image_rel_label'),
				'default' => '',
				'addAttr' => ['{{element}} a' => 'rel="{{rel}}"'],
				'req' => array(
					'link_type' => 'media_file'
				)
			),
			'target' => array(
				'label' => __pl('open_link_in_new_window'),
				'type' => 'checkbox',
				'addAttr' => ['{{element}} a' => 'target="_blank"'],
				'req' => array(
					'link_type' => ['custom_url', 'media_file']
				),
				'show' => ['link_type' => 'media_file']
			),
		],
		// Caption related Styles
		'caption_style' => [
			'caption' => array(
				'label' => __pl('gallery_grid_caption_label'),
				'desc' => __pl('gallery_grid_caption_desc'),
				'type' => 'text',
				'edit' => '.pagelayer-image-caption'
			),
			'caption_color' => array(
				'label' => __pl('Caption Color'),
				'type' => 'color',
				'default' => '#0986c0',
				'css' => ['{{element}} .pagelayer-image-caption' => 'color: {{val}}'],
			),
			'caption_typo' => array(
				'type' => 'typography',
				'label' => __pl('typography'),
				'css' => ['{{element}} .pagelayer-image-caption' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'],
			)
		],
		'overlay_style' => [
			'overlay' => array(
				'label' => __pl('image_overlay_effect_label'),
				'desc' => __pl('image_overlay_effect_desc'),
				'type' => 'checkbox',
			),
			'icon' => array(
				'label' => __pl('icon'),
				'type' => 'icon',
				'default' => 'fas fa-star',
				'req' => array(
					'overlay' => 'true'
				)
			),
			'icon_color' => array(
				'label' => __pl('icon_color'),
				'type' => 'color',
				'default' => '#e6cf03',
				'css' => ['{{element}} .pagelayer-image-overlay-icon' => 'color: {{val}}'],
				'req' => array(
					'overlay' => 'true'
				)
			),
			'icon_size' => array(
				'label' => __pl('icon_custom_size'),
				'desc' => __pl('icon_custom_size_desc'),
				'type' => 'spinner',
				'min' => 0,
				'step' => 1,
				'max' => 500,
				'default' => 50,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-image-overlay-icon' => 'font-size: {{val}}px'],
				'req' => array(
					'overlay' => 'true'
				)
			),
			'text' => array(
				'label' => __pl('content'),
				'type' => 'editor',
				'default' => '<p>Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s.</p>',
				'edit' => '.pagelayer-image-overlay-text',
				'req' => array(
					'overlay' => 'true'
				)
			),
			'overlay_bg_type' => array(
				'label' => __pl('background_type'),
				'type' => 'radio',
				'default' => 'color',
				'list' => array(
					'color' => __pl('color'),
					'gradient' => __pl('gradient')
				),
				'req' => array(
					'overlay' => 'true'
				)
			),
			'overlay_bg' => array(
				'label' => __pl('image_overlay_background'),
				'type' => 'color',
				'default' => 'rgba(0,0,0,.6)',
				'css' => ['{{element}} .pagelayer-image-overlay' => 'background: {{val}}'],
				'req' => array(
					'overlay' => 'true',
					'!overlay_bg_type' => 'gradient'
				)
			),
			'overlay_gradient' => [
				'type' => 'gradient',
				'label' => '',
				'css' => ['{{element}} .pagelayer-image-overlay' => 'background: linear-gradient({{val[0]}}deg, {{val[1]}} {{val[2]}}%, {{val[3]}} {{val[4]}}%, {{val[5]}} {{val[6]}}%);'],
				'req' => array(
					'overlay' => 'true',
					'overlay_bg_type' => 'gradient'
				)
			],
			'content_position' => array(
				'label' => __pl('Overlay Content Position'),
				'type' => 'radio',
				'default' => 'center',
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-image-overlay' => 'display:-webkit-flex;display:flex;-webkit-align-items:{{val}}; align-items:{{val}};'],
				'list' => array(
					'flex-start' => __pl('Top'),
					'center' => __pl('Middle'),
					'flex-end' => __pl('Bottom'),
				),
				'req' => array(
					'overlay' => 'true'
				)
			),
			'show_always' => array(
				'label' => __pl('image_show_always'),
				'type' => 'checkbox',
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-image-overlay' => 'opacity:1;'],
				'req' => array(
					'overlay' => 'true'
				)
			)
		],
		'styles' => [
			'link_settings' => __pl('link_settings'),
			'caption_style' => __pl('caption_style'),
			'overlay_style' => __pl('overlay_style')
		],
	)
);

// Image Slider
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_image_slider', array(
		'name' => __pl('Image Slider'),
		'group' => 'image',
		'prevent_inside' => ['pl_slides'],
		'html' => '<div class="pagelayer-image-slider-div">
			<ul class="pagelayer-image-slider-ul pagelayer-owl-holder pagelayer-owl-carousel pagelayer-owl-theme">{{ul}}</ul>
		</div>',
		'settings' => [
			'params' => __pl('Image Slider'),
			'slider_options' => __pl('slider_options'),
		],
		'params' => array(
			'ids' => array(
				'type' => 'multi_image',
				'label' => __pl('image_slider_ids_label'),
				'desc' => __pl('media_library_images_ids_desc'),
			),
			'size' => array(
				'type' => 'select',
				'label' => __pl('obj_image_size_label'),
				'default' => 'full',
				'list' => array(
					'full' => __pl('full'),
					'large' => __pl('large'),
					'medium' => __pl('medium'),
					'thumbnail' => __pl('thumbnail'),
					'custom' => __pl('custom')
				)
			),
			'custom_size' => array(
				'type' => 'dimension',
				'label' => __pl('image_custom_size_label'),
				'default' => '200,200',
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-image-slider-ul' => 'width: {{val[0]}}px; height: {{val[1]}}px;'],
				'req' => array(
					'size' => 'custom'
				),
			),
			'link_type' => array(
				'label' => __pl('image_link_label'),
				'type' => 'select',
				'list' => array(
					'' => __pl('none'),
					'custom_url' => __pl('custom_url'),
					'media_file' => __pl('media_file'),
				)
			),
			'link' => array(
				'type' => 'link',
				'label' => __pl('image_link_url'),
				'desc' => __pl('image_link_desc'),
				'selector' => '.pagelayer-link-sel',
				'req' => array(
					'link_type' => 'custom_url'
				)
			),
			'target' => array(
				'label' => __pl('open_link_in_new_window'),
				'type' => 'checkbox',
				'addAttr' => ['{{element}} a' => 'target="_blank"'],
				'req' => array(
					'link_type' => ['custom_url', 'media_file']
				),
				'show' => ['link_type' => 'media_file'] // Backward compatibility of link props
			),
			'slider_img_gap' => array(
				'type' => 'dimension',
				'label' => __pl('space_between'),
				'min' => 0,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-slider-item' => 'padding: {{val[0]}}px {{val[1]}}px;'],
			),
		),
		'slider_options' => [
			'slide_items' => array(
				'type' => 'spinner',
				'label' => __pl('number_of_items'),
				'min' => 1,
				'step' => 1,
				'max' => 10,
				'default' => 1,
				'addAttr' => ['{{element}} .pagelayer-owl-holder' => 'data-slides-items="{{slide_items}}"'],
			),
			'slider_animation' => array(
				'type' => 'select',
				'label' => __pl('animation_in'),
				'addAttr' => ['{{element}} .pagelayer-owl-holder' => 'data-slides-animate-in="{{slider_animation}}"'],
				'list' => $pagelayer->anim_in_options,
				'req' => ['slide_items' => '1']
			),
			'slideout_anim' => array(
				'type' => 'select',
				'label' => __pl('animation_out'),
				'addAttr' => ['{{element}} .pagelayer-owl-holder' => 'data-slides-animate-out="{{slideout_anim}}"'],
				'list' => $pagelayer->anim_out_options,
				'req' => ['slide_items' => '1']
			),
			'controls' => array(
				'type' => 'select',
				'label' => __pl('slider_controls'),
				'addAttr' => ['{{element}} .pagelayer-owl-holder' => 'data-slides-controls="{{controls}}"'],
				'list' => array(
					'' => __pl('Arrows and Pager'),
					'arrows' => __pl('Arrows'),
					'pager' => __pl('Pager'),
					'none' => __pl('none'),
				)
			),
			'pause' => array(
				'type' => 'slider',
				'label' => __pl('image_slider_slideshow_speed_label'),
				'default' => 5000,
				'min' => 200,
				'max' => 20000,
				'step' => 100,
				'addAttr' => ['{{element}} .pagelayer-owl-holder' => 'data-slides-autoplay-timeout="{{pause}}"'],
			),
			'speed' => array(
				'type' => 'slider',
				'label' => __pl('slider_animation_speed'),
				'addAttr' => ['.pagelayer-image-slider-ul' => 'data-slides-smart-speed="{{speed}}"'],
				'default' => 800,
				'min' => 200,
				'max' => 10000,
				'step' => 100
			),
			'loop' => array(
				'type' => 'checkbox',
				'label' => __pl('image_slider_loop'),
				'desc' => __pl('image_slider_loop_desc'),
				'default' => 'true',
				'addAttr' => ['{{element}} .pagelayer-owl-holder' => 'data-slides-loop="{{loop}}"'],
			),
			'adaptive_height' => array(
				'type' => 'checkbox',
				'label' => __pl('slider_height'),
				'desc' => __pl('slider_height_desc'),
				'addAttr' => ['{{element}} .pagelayer-owl-holder' => 'data-slides-auto-height="{{adaptive_height}}"'],
			),
			'auto' => array(
				'type' => 'checkbox',
				'label' => __pl('image_slider_auto'),
				'desc' => __pl('image_slider_auto_desc'),
				'default' => 'true',
				'addAttr' => ['{{element}} .pagelayer-owl-holder' => 'data-slides-autoplay="{{auto}}"'],
			),
			'auto_hover' => [
				'type' => 'checkbox',
				'label' => __pl('auto_hover'),
				'desc' => __pl('auto_hover_desc'),
				'default' => 'true',
				'addAttr' => ['{{element}} .pagelayer-owl-holder' => 'data-slides-autoplay-hover-pause="{{auto_hover}}"'],
			],
		],
		'arrow_styles' => $pagelayer->slider_arrow_styles,
		'pager_styles' => $pagelayer->slider_pager_styles,
		'styles' => [
			'slider_options' => __pl('slider_options'),
			'arrow_styles' => __pl('arrow_styles'),
			'pager_styles' => __pl('pager_styles'),
		],
	)
);

// Grid Gallery
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_grid_gallery', array(
		'name' => __pl('Grid Gallery'),
		'group' => 'image',
		'html' =>	'<div class="pagelayer-grid-gallery-container">
						{{ul}}
					</div>
					{{pagin}}',
		'params' => array(
			'ids' => array(
				'type' => 'multi_image',
				'label' => __pl('grid_gallery_images'),
				'desc' => __pl('media_library_images_ids_desc'),
			),
			'columns' => array(
				'type' => 'select',
				'label' => __pl('columns_count'),
				'default' => 3,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-grid-gallery-ul' => 'display: grid; grid-template-columns: repeat({{val}},1fr);'],
				'list' => array(
					1 => __pl('1'),
					2 => __pl('2'),
					3 => __pl('3'),
					4 => __pl('4'),
					5 => __pl('5'),
					6 => __pl('6'),
					7=> __pl('7'),
					8 => __pl('8'),
					9 => __pl('9'),
					10 => __pl('10')
				)
			),
			'col_gap' => array(
				'type' => 'slider',
				'label' => __pl('col_gap'),
				'min' => 0,
				'step' => 1,
				'max' => 100,
				'default' => 0,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-grid-gallery-ul' => 'grid-column-gap: {{val}}px;'],
			),
			'row_gap' => array(
				'type' => 'slider',
				'label' => __pl('row_gap'),
				'min' => 0,
				'step' => 1,
				'max' => 100,
				'default' => 0,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-grid-gallery-ul' => 'grid-row-gap: {{val}}px;'],
			),
			'size' => array(
				'type' => 'select',
				'label' => __pl('obj_image_size_label'),
				'default' => 'thumbnail',
				'list' => array(
					'full' => __pl('full'),
					'large' => __pl('large'),
					'medium' => __pl('medium'),
					'thumbnail' => __pl('thumbnail'),
					'custom' => __pl('custom')
				)
			),
			'custom_size' => array(
				'type' => 'dimension',
				'label' => __pl('image_custom_size_label'),
				'req' => array(
					'size' => 'custom'
				),
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-gallery-item img' => 'height: {{val[0]}}px; width: {{val[1]}}px;'],
			),
			'link_to' => array(
				'type' => 'select',
				'label' => __pl('image_link_label'),
				'default' => 'lightbox',
				'list' => array(
					'' => __pl('none'),
					'media_file' => __pl('media_file'),
					'attachment' => __pl('attachment_page'),
					'lightbox' => __pl('lightbox'),
				)
			),
			'rel' => array(
				'type' => 'text',
				'label' => __pl('image_rel_label'),
				'default' => '',
				'addAttr' => ['{{element}} a' => 'rel="{{rel}}"'],
				'req' => array(
					'link_to' => 'media_file'
				)
			),
			'target' => array(
				'type' => 'checkbox',
				'label' => __pl('open_link_in_new_window'),
				'addAttr' => ['{{element}} a' => 'target="_blank"'],
				'req' => array(
					'!link_to' => ['lightbox', '']
				)
			),
			'caption' => array(
				'type' => 'checkbox',
				'label' => __pl('gallery_grid_caption_label'),
				'desc' => __pl('gallery_grid_caption_desc'),
				'default' => '',
			),
			'align' => array(
				'label' => __pl('obj_align_label'),
				'type' => 'radio',
				'default' => 'left',
				'addAttr' => 'align="{{align}}"',
				'css' => ['{{element}} .pagelayer-grid-gallery-container' => 'text-align: {{val}}', '{{element}} .pagelayer-grid-gallery-container .pagelayer-grid-gallery-ul' => 'text-align: {{val}}'],
				'list' => array(
					'left' => __pl('left'),
					'center' => __pl('center'),
					'right' => __pl('right')
				),
				'req' => array(
					'caption' => 'true'
				)
			),
			'caption_color' => array(
				'label' => __pl('Caption Color'),
				'type' => 'color',
				'default' => '#e6cf03',
				'css' => ['{{element}} .pagelayer-grid-gallery-caption' => 'color: {{val}}'],
				'req' => array(
					'caption' => 'true'
				)
			),
			'images_no' => array(
				'type' => 'spinner',
				'label' => __pl('num_images'),
				'desc' => __pl('images_in_page'),
				'min' => 0,
				'step' => 1,
				'max' => 1000,
				'default' => 30
			)
		)
	)
);



////////////////////////
// Button Group
////////////////////////

// Button
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_btn', array(
		'name' => __pl('button'),
		'group' => 'button',
		'html' => '<a class="pagelayer-btn-holder pagelayer-ele-link {{type}} {{size}} {{icon_position}}">
					<i if="{{icon}}" class="{{icon}} pagelayer-btn-icon"></i>
					<span if="{{text}}" class="pagelayer-btn-text">{{text}}</span>
					<i if="{{icon}}" class="{{icon}} pagelayer-btn-icon"></i>
				</a>',
		'params' => array(
			'text' => array(
				'type' => 'text',
				'label' => __pl('button_text_label'),
				'default' => __pl('button_name'),
				'edit' => '.pagelayer-btn-text',
			),
			'link' => array(
				'type' => 'link',
				'label' => __pl('button_link_label'),
				'desc' => __pl('button_link_desc'),
				'selector' => '.pagelayer-btn-holder',
				'addAttr' => ['{{element}} .pagelayer-btn-holder' => 'href="{{{link}}}"'],
				'req' => ['ele_scrollto' => '']
			),
			'full_width' => array(
				'type' => 'checkbox',
				'label' => __pl('stretch'),
				'screen' => 1,
				'css' => ['{{element}} a' => 'width: 100%; text-align: center;']
			),
			'btn_typo' => array(
				'type' => 'typography',
				'label' => __pl('quote_content_typo'),
				'css' => [
					'{{element}} .pagelayer-btn-text' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;',
					'{{element}} .pagelayer-btn-holder' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;',
				],
			),
			'align' => array(
				'type' => 'radio',
				'label' => __pl('obj_align_label'),
				'default' => 'left',
				'screen' => 1,
				'css' => 'text-align: {{val}}',
				'list' => array(
					'left' => __pl('left'),
					'center' => __pl('center'),
					'right' => __pl('right')
				),
				'req' => array(
					'full_width' => ''
				)
			),
		),
		'icon_style' => [
			'icon' => array(
				'type' => 'icon',
				'label' => __pl('service_box_font_icon_label'),
				'default' => '',
			),
			'icon_position' => array(
				'type' => 'radio',
				'label' => __pl('alignment'),
				'default' => 'pagelayer-btn-icon-left',
				'list' => array(
					'pagelayer-btn-icon-left' => __pl('left'),
					'pagelayer-btn-icon-right' => __pl('right')
				),
				'req' => array(
					'!icon' => ''
				),
			),
			'icon_spacing' => array(
				'type' => 'slider',
				'label' => __pl('icon_spacing'),
				'min' => 1,
				'step' => 1,
				'max' => 100,
				'default' => 5,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-btn-icon' => 'padding: 0 {{val}}px;'],
				'req' => array(
					'!icon' => ''
				),
			),
		],
		'btn_style' => [
			'type' => array(
				'type' => 'select',
				'label' => __pl('button_type_label'),
				'default' => 'pagelayer-btn-default',
				//'addClass' => ['{{element}} .pagelayer-btn-holder' => '{{val}}'],
				'list' => array(
					'pagelayer-btn-default' => __pl('btn_type_default'),
					'pagelayer-btn-primary' => __pl('btn_type_primary'),
					'pagelayer-btn-secondary' => __pl('btn_type_secondary'),
					'pagelayer-btn-success' => __pl('btn_type_success'),
					'pagelayer-btn-info' => __pl('btn_type_info'),
					'pagelayer-btn-warning' => __pl('btn_type_warning'),
					'pagelayer-btn-danger' => __pl('btn_type_danger'),
					'pagelayer-btn-dark' => __pl('btn_type_dark'),
					'pagelayer-btn-light' => __pl('btn_type_light'),
					'pagelayer-btn-link' => __pl('btn_type_link'),
					'pagelayer-btn-anim' => __pl('btn_type_anim'),
					'pagelayer-btn-custom' => __pl('btn_type_custom')
				),
			),
			'anim_type' => array(
				'type' => 'select',
				'label' => __pl('type'),
				'default' => 'glow',
				'addClass' => ['{{element}} .pagelayer-btn-holder' => 'pagelayer-btn-anim-{{val}}'],
				'list' => array(
					'glow' => __pl('glow_button'),
					'thin' => __pl('thin_button'),
					'slide' => __pl('slide_button')
				),
				'req' => array(
					'type' => 'pagelayer-btn-anim'
				),
			),
			'direction' => array(
				'type' => 'select',
				'label' => __pl('animation_direction'),
				'default' => 'pagelayer-btn-anim-left',
				'addClass' =>  ['{{element}} .pagelayer-btn-holder' => '{{val}}'],
				'list' => array(
					'pagelayer-btn-anim-left' => __pl('left'),
					'pagelayer-btn-anim-right' => __pl('right'),
				),
				'req' => array(
					'anim_type' => 'slide',
					'type' => 'pagelayer-btn-anim',
				),
			),
			'size' => array(
				'type' => 'select',
				'label' => __pl('button_size_label'),
				'default' => 'pagelayer-btn-large',
				'list' => array(
					'pagelayer-btn-mini' => __pl('mini'),
					'pagelayer-btn-small' => __pl('small'),
					'pagelayer-btn-large' => __pl('large'),
					'pagelayer-btn-extra-large' => __pl('extra_large'),
					'pagelayer-btn-double-large' => __pl('double_large'),
					'pagelayer-btn-custom' => __pl('custom'),
				)
			),
			'btn_custom_size' => array(
				'type' => 'spinner',
				'label' => __pl('btn_custom_size'),
				'min' => 1,
				'step' => 1,
				'max' => 100,
				'default' => 5,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-btn-holder' => 'padding: calc({{val}}px / 2) {{val}}px;'],
				'req' => array(
					'size' => ['pagelayer-btn-custom','pagelayer-btn-anim'],
				),
			),
			'btn_hover' => array(
				'type' => 'radio',
				'label' => __pl('state'),
				'default' => '',
				//'no_val' => 1,// Dont set any value to element
				'list' => array(
					'' => __pl('normal'),
					'hover' => __pl('hover'),
				),
				'req' => array(
					'type' => ['pagelayer-btn-custom','pagelayer-btn-anim'],
				),
			),
			'btn_bg_color' => array(
				'type' => 'color',
				'label' => __pl('btn_bg_color_label'),
				'default' => '#818a91',
				'css' => [
					'{{element}} .pagelayer-btn-holder' => 'background-color: {{val}};',
					'{{element}} .pagelayer-btn-anim-thin' => 'background-color: unset !important;',
					'{{element}} .pagelayer-btn-anim-thin::before' => 'background-color: {{val}};',
					'{{element}} .pagelayer-btn-anim-thin::after' => 'background-color: {{val}};',
				],
				'req' => array(
					'type' => ['pagelayer-btn-custom','pagelayer-btn-anim'],
				),
				'show' => array(
					'btn_hover' => ''
				),
			),
			'btn_color' => array(
				'type' => 'color',
				'label' => __pl('btn_color_label'),
				'default' => '#ffffff',
				'css' => ['{{element}} .pagelayer-btn-holder' => 'color: {{val}};'],
				'req' => array(
					'type' => ['pagelayer-btn-custom','pagelayer-btn-anim'],
				),
				'show' => array(
					'btn_hover' => ''
				),
			),
			'btn_hover_delay' => array(
				'type' => 'spinner',
				'label' => __pl('btn_hover_delay_label'),
				'desc' => __pl('btn_hover_delay_desc'),
				'min' => 0,
				'step' => 100,
				'max' => 5000,
				'default' => 400,
				'css' => ['{{element}} .pagelayer-btn-holder' => '-webkit-transition: all {{val}}ms !important; transition: all {{val}}ms !important;'],
				'show' => array(
					'type' => ['pagelayer-btn-custom','pagelayer-btn-anim'],
					'btn_hover' => 'hover'
				),
			),
			'btn_bg_color_hover' => array(
				'type' => 'color',
				'label' => __pl('btn_bg_color_hover_label'),
				'default' => '',
				'css' => [
					'{{element}} .pagelayer-btn-custom:hover, {{element}} .pagelayer-btn-anim-slide:after' => 'background-color: {{val}};',
				],
				'req' => array(
					'type' => ['pagelayer-btn-custom','pagelayer-btn-anim'],
					'!anim_type' => ['glow','thin'],
				),
				'show' => array(
					'btn_hover' => 'hover',
					'!anim_type' => ['glow','thin'],
				),
			),
			'btn_color_hover' => array(
				'type' => 'color',
				'label' => __pl('btn_color_hover_label'),
				'default' => '',
				'css' => ['{{element}} .pagelayer-btn-holder:hover' => 'color: {{val}};'],
				'req' => array(
					'type' => ['pagelayer-btn-custom','pagelayer-btn-anim'],
				),
				'show' => array(
					'btn_hover' => 'hover'
				),
			),
			'btn_shadow' => [
				'type' => 'box_shadow',
				'label' => __pl('shadow'),
				'css' => ['{{element}} .pagelayer-btn-holder' => 'box-shadow: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[4]}}px {{val[3]}} {{val[5]}} !important;'],
			],
			'btn_shadow_hover' => [ // This is actually box shadow hover
				'type' => 'box_shadow',
				'label' => __pl('box_shadow_hover'),
				'css' => ['{{element}} .pagelayer-btn-holder:hover' => 'box-shadow: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[4]}}px {{val[3]}} {{val[5]}} !important;'],
			],
		],
		'border_style' => [
			'btn_bor_hover' => array(
				'type' => 'radio',
				'label' => __pl('state'),
				'default' => '',
				//'no_val' => 1,// Dont set any value to element
				'list' => array(
					'' => __pl('normal'),
					'hover' => __pl('hover'),
				)
			),	
			'btn_border_type' => array(
				'type' => 'select',
				'label' => __pl('border_type'),
				'css' => [
					'{{element}} .pagelayer-btn-holder, {{element}} .pagelayer-btn-anim-thin:after, {{element}} .pagelayer-btn-anim-thin:before' => 'border-style: {{val}};',
					'{{element}} .pagelayer-btn-anim-thin' => 'border-style: unset !important;',
					],
				'list' => [
					'' => __pl('none'),
					'solid' => __pl('solid'),
					'double' => __pl('double'),
					'dotted' => __pl('dotted'),
					'dashed' => __pl('dashed'),
					'groove' => __pl('groove'),
				],
				'show' => array(
					'btn_bor_hover' => ''
				),
			),
			'btn_border_color' => array(
				'type' => 'color',
				'label' => __pl('border_color_label'),
				'default' => '#42414f',
				'css' => ['{{element}} .pagelayer-btn-holder' => 'border-color: {{val}};'],
				'req' => array(
					'!btn_border_type' => ''
				),
				'show' => array(
					'btn_bor_hover' => ''
				),
			),
			'btn_border_width' => array(
				'type' => 'padding',
				'label' => __pl('border_width'),
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-btn-holder, {{element}} .pagelayer-btn-anim-thin:after, {{element}} .pagelayer-btn-anim-thin:before' => 'border-top-width: {{val[0]}}px; border-right-width: {{val[1]}}px; border-bottom-width: {{val[2]}}px; border-left-width: {{val[3]}}px'],
				'req' => [
					'!btn_border_type' => ''
				],
				'show' => array(
					'btn_bor_hover' => ''
				),
			),
			'btn_border_radius' => array(
				'type' => 'padding',
				'label' => __pl('border_radius'),
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-btn-holder, {{element}} .pagelayer-btn-anim-glow:before' => 'border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px; -webkit-border-radius:  {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px;-moz-border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px;'],
				'req' => array(
					'!btn_border_type' => '',
					'!anim_type' => 'slide'
				),
				'show' => array(
					'btn_bor_hover' => '',
					'!anim_type' => 'slide'
				),
			),
			'btn_border_type_hover' => array(
				'type' => 'select',
				'label' => __pl('border_type'),
				'css' => [
					'{{element}} .pagelayer-btn-holder:hover, {{element}} .pagelayer-btn-anim-thin:hover:after, {{element}} .pagelayer-btn-anim-thin:hover:before' => 'border-style: {{val}}',
					'{{element}} .pagelayer-btn-anim-thin:hover' => 'border-style: unset !important;',
				],
				'list' => [
					'' => __pl('none'),
					'solid' => __pl('solid'),
					'double' => __pl('double'),
					'dotted' => __pl('dotted'),
					'dashed' => __pl('dashed'),
					'groove' => __pl('groove'),
				],
				'show' => array(
					'btn_bor_hover' => 'hover'
				),
			),
			'btn_border_color_hover' => array(
				'type' => 'color',
				'label' => __pl('border_color_hover_label'),
				'default' => '#42414f',
				'css' => ['{{element}} .pagelayer-btn-holder:hover' => 'border-color: {{val}};'],
				'req' => array(
					'!btn_border_type_hover' => ''
				),
				'show' => array(
					'btn_bor_hover' => 'hover'
				),
			),
			'btn_border_width_hover' => array(
				'type' => 'padding',
				'label' => __pl('border_width_hover'),
				'screen' => 1,
				'css' => [
					'{{element}} .pagelayer-btn-holder:hover, {{element}} .pagelayer-btn-anim-thin:hover:after, {{element}} .pagelayer-btn-anim-thin:hover:before' => 'border-top-width: {{val[0]}}px; border-right-width: {{val[1]}}px; border-bottom-width: {{val[2]}}px; border-left-width: {{val[3]}}px;'
				],
				'req' => [
					'!btn_border_type_hover' => ''
				],
				'show' => array(
					'btn_bor_hover' => 'hover'
				),
			),
			'btn_border_radius_hover' => array(
				'type' => 'padding',
				'label' => __pl('border_radius_hover'),
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-btn-holder:hover, {{element}} .pagelayer-btn-anim-glow:before' => 'border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px; -webkit-border-radius:  {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px;-moz-border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px;'],
				'req' => array(
					'!btn_border_type_hover' => '',
					'!anim_type' => 'slide'
				),
				'show' => array(
					'btn_bor_hover' => 'hover',
					'!anim_type' => 'slide'
				),
			),
		],
		'scroll_to_element' => [
			'ele_scrollto' => array(
				'type' => 'checkbox',
				'label' => __pl('Enable'),
				'addClass' => 'pagelayer-scroll-to-element',
			),
			'ele_scrollto_type' => array(
				'type' => 'select',
				'label' => __pl('scroll_to'),
				'default' => 'totop',
				'list' => array(
					'toid' => __pl('Element'),
					'totop' => __pl('Top'),
				),
				'addAttr' => 'pagelayer_scrollto_type="{{ele_scrollto_type}}"',
				'req' => ['!ele_scrollto' => ''],
			),
			'ele_scrollto_id' => array(
				'type' => 'text',
				'label' => __pl('ele_id'),
				'default' => '',
				'desc' => __pl('ele_scroll_id_desc'),
				'addAttr' => 'pagelayer_scrollto_id="{{ele_scrollto_id}}"',
				'req' => [ '!ele_scrollto' => '', 'ele_scrollto_type' => 'toid'],
			),
			'ele_scrollto_id_viewport' => array(
				'type' => 'slider',
				'label' => __pl('spacing_from_id'),
				'min' => -200,
				'step' => 1,
				'max' => 200,
				'default' => 0,
				'addAttr' => 'pagelayer_scrollto_id_viewport="{{ele_scrollto_id_viewport}}"',
				'req' => [ '!ele_scrollto' => '', 'ele_scrollto_type' => 'toid'],
			),
			'ele_scrollto_speed' => array(
				'type' => 'slider',
				'label' => __pl('slider_animation_speed'),
				'min' => 0,
				'step' => 0.1,
				'max' => 10,
				'default' => 0.4,
				'screen' => 1,
				'desc' => __pl('ele_scroll_speed'),
				'addAttr' => 'pagelayer_scrollto_speed="{{ele_scrollto_speed}}"',
				'req' => [ '!ele_scrollto' => ''],
			),
		],
		'styles' => [
			'btn_style' => __pl('btn_style'),
			'icon_style' => __pl('icon'),
			'border_style' => __pl('border_style'),
			'scroll_to_element' => __pl('scroll_to_element'),
		]
	)
);

// Social Profile Item
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_social', array(
		'name' => __pl('Social Profile'),
		'group' => 'button',
		'not_visible' => 1,
		'parent' => [PAGELAYER_SC_PREFIX.'_social_grp'],
		'html' => '<div class="pagelayer-icon-holder">
					<a if-ext="{{social_url}}" class="pagelayer-ele-link" href="{{{social_url}}}">
						<i class="pagelayer-social-fa {{icon}}"></i>
					</a>
				</div>',
		'params' => array(
			'icon' => array(
				'type' => 'icon',
				'label' => __pl('list_icon_label'),
				'default' => 'fab fa-facebook-square',
				'addAttr' => ['{{element}} .pagelayer-icon-holder' => 'data-icon="{{icon}}"'],
				'list' => ['facebook', 'facebook-f', 'facebook-square', 'facebook-messenger', 'twitter', 'twitter-square', 'x-twitter', 'x-twitter-square', 'google-plus', 'google-plus-g', 'google-plus-square', 'instagram', 'linkedin', 'linkedin-in', 'behance', 'behance-square', 'pinterest', 'pinterest-p', 'pinterest-square', 'reddit-alien', 'reddit-square', 'reddit', 'rss', 'rss-square', 'skype', 'slideshare', 'snapchat', 'snapchat-ghost', 'snapchat-square', 'soundcloud', 'spotify', 'stack-overflow', 'steam', 'steam-symbol', 'steam-square', 'stumbleupon', 'stumbleupon-circle', 'telegram', 'telegram-plane', 'thumbtack', 'tripadvisor', 'tumblr', 'tumblr-square', 'twitch', 'vimeo-v', 'vimeo', 'vimeo-square', 'vk', 'weibo', 'weixin', 'whatsapp', 'whatsapp-square', 'wordpress', 'wordpress-simple', 'xing', 'xing-square', 'yelp', 'youtube', 'youtube-square', '500px', 'flickr', 'android', 'github', 'github-alt', 'github-square', 'gitlab', 'apple', 'jsfiddle', 'houzz', 'bitbucket', 'codepen', 'delicious', 'medium', 'medium-m', 'meetup', 'mixcloud', 'dribbble', 'dribbble-square', 'foursquare', 'get-pocket', 'tiktok'],
				'onchange' => 'pagelayer_social_icon_onchange'
			),
			'social_url' => array(
				'type' => 'link',
				'label' => __pl('social_url_label'),
				'selector' => '.pagelayer-ele-link',
				'default' => get_option('pagelayer-facebook-url'),
			),
		)
	)
);

// Social Profile
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_social_grp', array(
		'name' => __pl('Social Profile'),
		'group' => 'button',
		'has_group' => [
			'section' => 'params', 
			'prop' => 'elements'
		],
		'params' => array(
			'elements' => array(
				'type' => 'group',
				'label' => __pl('social'),
				'sc' => PAGELAYER_SC_PREFIX.'_social',
				'item_label' => array(
					'default' => __pl('social'),
					'param' => 'icon'
				),
				'count' => 3,
				'text' => strtr(__pl('add_new_item'), array('%name%' => __pl('social_name'))),
			),
		),
		'layout_style' => [
			'bg_shape' => array(
				'type' => 'select',
				'label' => __pl('icon_background_shape'),
				'default' => '',
				'css' => ['{{element}} i' => 'height:1em; width:1em; position: absolute; top: 50%; left: 50%; transform: translate(-50% , -50%);',
				'{{element}} .pagelayer-icon-holder' => 'position: relative; min-height: 1em; min-width: 1em;'],
				'addClass' => '{{val}}',
				'list' => array(
					'' => __pl('icon_shape_none'),
					'pagelayer-social-shape-circle' => __pl('icon_shape_circle'),
					'pagelayer-social-shape-square' => __pl('icon_shape_square'),
					'pagelayer-social-shape-rounded' => __pl('icon_shape_rounded')
				),
			),
			'bg_size' => array(
				'type' => 'spinner',
				'label' => __pl('social_grp_size_label'),
				'css' => ['{{element}} .pagelayer-icon-holder' => 'padding: calc(0.5em + {{val}}px);'],
				'min' => 1,
				'step' => 1,
				'max' => 500,
				'default' => 10,
				'screen' => 1,
				'req' => array(
					'!bg_shape' => ''
				)
			),
			'align' => array(
				'type' => 'radio',
				'label' => __pl('obj_align_label'),
				'default' => 'center',
				'css' => 'text-align: {{val}}',
				'screen' => 1,
				'list' => array(
					'left' => __pl('left'),
					'center' => __pl('center'),
					'right' => __pl('right')
				)
			),
			'group_layout' => array(
				'type' => 'radio',
				'label' => __pl('layout'),
				'default' => 'pagelayer-btn-grp-horizontal',
				'screen' => 1,
				'css' => ['{{element}} > div' => 'display: inline-block;'],
				'list' => array(
					'pagelayer-btn-grp-horizontal' => __pl('horizontal'),
					'' => __pl('vertical')
				)
			),
			'icon_spacing' => array(
				'type' => 'spinner',
				'label' => __pl('icon_spacing'),
				'css' => ['{{element}} .pagelayer-social' => 'padding: {{val}}px;'],
				'min' => 0,
				'step' => 1,
				'max' => 100,
				'default' => 3,
				'screen' => 1,
			)
		],
		'icon_style' => [
			'icon_size' => array(
				'type' => 'spinner',
				'label' => __pl('social_grp_size_label'),
				'css' => ['{{element}} .pagelayer-social-fa' => 'font-size: {{val}}px;',
					'{{element}} .pagelayer-icon-holder' => 'font-size: {{val}}px;'],
				'min' => 1,
				'step' => 1,
				'max' => 500,
				'default' => 40,
				'screen' => 1,
			),
			'color_scheme' => array(
				'type' => 'select',
				'label' => __pl('color'),
				'default' => 'pagelayer-scheme-official',
				'addClass' => '{{val}}',
				'list' => array(
					'' => __pl('custom'),
					'pagelayer-scheme-official' => __pl('official')
				)
			),
			'social_hover' => array(
				'type' => 'radio',
				'label' => __pl('state'),
				'default' => '',
				//'no_val' => 1,// Dont set any value to element
				'list' => array(
					'' => __pl('normal'),
					'hover' => __pl('hover'),
				)
			),
			'icon_color' => array(
				'type' => 'color',
				'label' => __pl('social_color_label'),
				'default' => '#333333',
				'css' => ['{{element}} .pagelayer-social-fa' => 'color: {{val}} !important;'],
				'req' => array(
					'color_scheme' => ''
				),
				'show' => ['social_hover' => '']
			),
			'icon_bg_color' => array(
				'type' => 'color',
				'label' => __pl('social_bg_color_label'),
				'default' => '#0986c0',
				'css' => ['{{element}} .pagelayer-icon-holder' => 'background-color: {{val}} !important;'],
				'req' => array(
					'!bg_shape' => '',
					'color_scheme' => ''
				),
				'show' => ['social_hover' => '']
			),
			'icon_color_hover' => array(
				'type' => 'color',
				'label' => __pl('social_color_label'),
				'default' => '#ffffff',
				'css' => ['{{element}} .pagelayer-icon-holder:hover .pagelayer-social-fa' => 'color: {{val}} !important;'],
				'req' => array(
					'color_scheme' => ''
				),
				'show' => ['social_hover' => 'hover']
			),
			'icon_bg_color_hover' => array(
				'type' => 'color',
				'label' => __pl('social_bg_color_label'),
				'default' => '#0986c0',
				'css' => ['{{element}} .pagelayer-icon-holder:hover' => 'background-color: {{val}} !important;'],
				'req' => array(
					'!bg_shape' => '',
					'color_scheme' => ''
				),
				'show' => ['social_hover' => 'hover']
			),
			'anim_hover' => array(
				'type' => 'select',
				'label' => __pl('icon_animation'),
				'list' => [
					'' => __pl('none'),
					'grow' => __pl('Grow'),
					'shrink' => __pl('Shrink'),
					'pulse' => __pl('Pulse'),
					'pulse-grow' => __pl('Pulse Grow'),
					'pulse-shrink' => __pl('Pulse Shrink'),
					'push' => __pl('Push'),
					'pop' => __pl('Pop'),
					'buzz' => __pl('Buzz'),
					'buzz-out' => __pl('Buzz Out'),
					'float' => __pl('Float'),
					'sink' => __pl('Sink'),
					'bob' => __pl('Bob'),
					'hang' => __pl('Hang'),
					'bounce-in' => __pl('Bounce In'),
					'bounce-out' => __pl('Bounce Out'),
					'rotate' => __pl('Rotate'),
					'grow-rotate' => __pl('Grow Rotate'),
					'skew-forward' => __pl('Skew Forward'),
					'skew-backward' => __pl('Skew Backward'),
					'wobble-vertical' => __pl('Wobble Vertical'),
					'wobble-horizontal' => __pl('Wobble Horizontal'),
					'wobble-bottom-to-right' => __pl('Wobble Bottom To Right'),
					'wobble-top-to-right' => __pl('Wobble Top To Right'),
					'wobble-top' => __pl('Wobble Top'),
					'wobble-bottom' => __pl('Wobble Bottom'),
					'wobble-skew' => __pl('Wobble Skew'),
				],
				'addAttr' => 'pagelayer-animation="{{anim_hover}}"',
				'show' => ['social_hover' => 'hover']
			),
			'icon_border_type' => array(
				'type' => 'select',
				'label' => __pl('border_type'),
				'css' => ['{{element}} .pagelayer-icon-holder' => 'border-style: {{val}}'],
				'list' => [
					'' => __pl('none'),
					'solid' => __pl('solid'),
					'double' => __pl('double'),
					'dotted' => __pl('dotted'),
					'dashed' => __pl('dashed'),
					'groove' => __pl('groove'),
				],
				'show' => ['social_hover' => '']
			),
			'icon_border_color' => array(
				'type' => 'color',
				'label' => __pl('service_box_icon_border_color_label'),
				'default' => '#42414f',
				'css' => ['{{element}} .pagelayer-icon-holder' => 'border-color: {{val}};'],
				'req' => array(
					'!icon_border_type' => ''
				),
				'show' => ['social_hover' => '']
			),
			'icon_border_width' => array(
				'type' => 'padding',
				'label' => __pl('border_width'),
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-icon-holder' => 'border-top-width: {{val[0]}}px; border-right-width: {{val[1]}}px; border-bottom-width: {{val[2]}}px; border-left-width: {{val[3]}}px'],
				'req' => [
					'!icon_border_type' => ''
				],
				'show' => ['social_hover' => '']
			),
			'icon_border_radius' => array(
				'type' => 'padding',
				'label' => __pl('border_radius'),
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-icon-holder' => 'border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px; -webkit-border-radius:  {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px;-moz-border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px;'],
				'req' => array(
					'!icon_border_type' => ''
				),
				'show' => ['social_hover' => '']
			),
			'social_hover_delay' => array(
				'type' => 'spinner',
				'label' => __pl('btn_hover_delay_label'),
				'desc' => __pl('btn_hover_delay_desc'),
				'min' => 0,
				'step' => 100,
				'max' => 5000,
				'default' => 400,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-icon-holder' => '-webkit-transition: all {{val}}ms; transition: all {{val}}ms;',
				'{{element}} .pagelayer-social-fa' => '-webkit-transition: all {{val}}ms; transition: all {{val}}ms;'],
				'show' => array(
					'social_hover' => 'hover'
				),
			),
			'icon_border_type_hover' => array(
				'type' => 'select',
				'label' => __pl('border_type'),
				'css' => ['{{element}} .pagelayer-icon-holder:hover' => 'border-style: {{val}}'],
				'list' => [
					'' => __pl('none'),
					'solid' => __pl('solid'),
					'double' => __pl('double'),
					'dotted' => __pl('dotted'),
					'dashed' => __pl('dashed'),
					'groove' => __pl('groove'),
				],
				'show' => ['social_hover' => 'hover']
			),
			'icon_border_color_hover' => array(
				'type' => 'color',
				'label' => __pl('border_color_hover_label'),
				'default' => '#42414f',
				'css' => ['{{element}} .pagelayer-icon-holder:hover' => 'border-color: {{val}};'],
				'req' => array(
					'!icon_border_type_hover' => ''
				),
				'show' => ['social_hover' => 'hover']
			),
			'icon_border_width_hover' => array(
				'type' => 'padding',
				'label' => __pl('border_width_hover'),
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-icon-holder:hover' => 'border-top-width: {{val[0]}}px; border-right-width: {{val[1]}}px; border-bottom-width: {{val[2]}}px; border-left-width: {{val[3]}}px'],
				'req' => [
					'!icon_border_type_hover' => ''
				],
				'show' => ['social_hover' => 'hover']
			),
			'icon_border_radius_hover' => array(
				'type' => 'padding',
				'label' => __pl('border_radius_hover'),
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-icon-holder:hover' => 'border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px; -webkit-border-radius:  {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px;-moz-border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px;'],
				'req' => array(
					'!icon_border_type_hover' => ''
				),
				'show' => ['social_hover' => 'hover']
			),
		],
		'styles' => [
			'layout_style' => __pl('layout_style'),
			'icon_style' => __pl('icon'),
		]
	)
);

////////////////////////
// Media Group
////////////////////////

// Video
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_video', array(
		'name' => __pl('video'),
		'group' => 'media',
		'html' => '<div class="pagelayer-video-holder pagelayer-video-{{video_ratio}}">
			<iframe if="{{src}}" id="embed_video" class="pagelayer-video-iframe" width="100%" height="auto" src="{{vid_src}}" frameborder="0"></iframe>
			<a if-ext={{lightbox}} href="{{{src-url}}}">
				<div if={{overlay}} class="pagelayer-video-overlay" style="background-image:url({{video_overlay_image-url}});">
					<i class="{{play_icon}}" aria-hidden="true"></i>
				</div>
			</a>
		</div>',
		'params' => array(
			'src' => array(
				'type' => 'video',
				'label' => __pl('video_src_label'),
				'default' => 'https://www.youtube.com/watch?v=t8Iz-v-qce8',
				'desc' => __pl('video_src_desc'),				
			),
			'lightbox' => array(
				'type' => 'checkbox',
				'label' => __pl('Lightbox'),
				'desc' => __pl('Open the video on Lightbox'),
				'default' => '',
			),
			'autoplay' => array(
				'type' => 'checkbox',
				'label' => __pl('Autoplay'),
				'req' => [
					'!overlay' => 'true',
					'!lightbox' => 'true',
				],						
			),
			'mute' => array(
				'type' => 'checkbox',
				'label' => __pl('mute'),						
			),			
			'loop' => array(
				'type' => 'checkbox',
				'label' => __pl('loop'),						
			),
			'video_ratio' => array(
				'type' => 'select',
				'label' => __pl('aspect_ratio'),
				'default' => 'aspect-8-5',
				'list' => array(
					'aspect-1-1' => __pl('1:1'),
					'aspect-3-2' => __pl('3:2'),
					'aspect-4-3' => __pl('4:3'),
					'aspect-8-5' => __pl('8:5'),
					'aspect-16-9' => __pl('16:9'),
				),				
			),
		),
		'overlay_style' =>[
			'overlay' => array(
				'type' => 'checkbox',
				'label' => __pl('Overlay'),
				'desc' => __pl('Enable this option to set the picture as overlay'),
				'default' => '',
			),
			'video_overlay_image' => array(
				'type' => 'image',
				'label' =>  __pl('Custom thumbnail'),
				'default' => PAGELAYER_URL.'/images/default-image.png',
				'desc' => __pl('Use this option to set a picture from the media library'),
				'req' => array(
					'overlay' => 'true',
				),
			),
			'play_icon' => array(
				'type' => 'icon',
				'label' => __pl('list_icon_label'),
				'default' => 'fas fa-play-circle',
				'req' => array(
					'overlay' => 'true'
				)
			),
			'icon_color' => array(
				'type' => 'color',
				'label' => __pl('service_heading_color'),
				'default' => '#0986c0',
				'css' => ['{{element}} .pagelayer-video-overlay i' => 'color:{{val}}'],
				'req' => array(
					'overlay' => 'true'
				)
			),
			'icon_size' => array(
				'type' => 'spinner',
				'label' => __pl('size'),
				'min' => '0',
				'max' => '700',
				'screen' => 1,
				'default' => '80',
				'css' => ['{{element}} .pagelayer-video-overlay i' => 'font-size:{{val}}px;'],
				'req' => array(
					'overlay' => 'true'
				)
			),
			'tooltip_text_shadow' => array(
				'type' => 'shadow',
				'label' => __pl('shadow'),
				'css' => ['{{element}} .pagelayer-video-overlay i' => 'text-shadow: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}};'],
				'req' => array(
					'overlay' => 'true'
				)
			),
		],
		'styles' => [
			'overlay_style' => __pl('overlay_style'),
		],
	)
);


////////////////////////
// Other Group
////////////////////////

// Service Box
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_service', array(
		'name' => __pl('Image Box'),
		'group' => 'other',
		'innerHTML' => 'service_text',
		'html' => '<div class="pagelayer-service-container pagelayer-service-align-{{service_alignment}} pagelayer-service-vertical-{{service_vertical_alignment}}">
			<div if="{{service_image}}" class="pagelayer-service-image">
				<img class="pagelayer-img pagelayer-animation-{{anim_hover}}" src="{{func_image}}" title="{{{service_image-title}}}" alt="{{{service_image-alt}}}" srcset="{{pagelayer-srcset}}" />
			</div>
			<div class="pagelayer-service-details">
				<a if-ext={{heading_url}} href="{{{heading_url}}}" class="pagelayer-ele-link pagelayer-service-heading-link" >
					<div if={{service_heading}} class="pagelayer-service-heading">{{service_heading}}</div>
				</a>
				<div if={{service_text}} class="pagelayer-service-text">{{service_text}}</div>
				<a if="{{service_button}}" href="{{{service_button_url}}}" class="pagelayer-service-btn {{service_button_type}} pagelayer-ele-link pagelayer-button {{service_button_size}}">{{service_button_text}}</a>
			</div>
			<a if-ext={{box_url}} href="{{{box_url}}}" class="pagelayer-ele-link pagelayer-box-link"> </a>
		</div>',
		'params' => [
			'service_image' => array(
				'type' => 'image',
				'label' => __pl('service_box_image_icon_label'),
				'default' => PAGELAYER_URL.'/images/default-image.png',
				'retina' => 1,
			),
			'service_image_size' => array(
				'type' => 'radio',
				'label' => __pl('service_box_image_icon_size_label'),
				'default' => 'full',
				'list' => array(
					'full' => __pl('full'),
					'thumbnail' => __pl('thumbnail'),
					'custom' => __pl('custom'),
				)
			),
			'service_image_custom_size' => array(
				'type' => 'slider',
				'label' => __pl('service_img_custom_size_label'),
				'min' => '0',
				'max' => '2000',
				'screen' => 1,
				'default' => '200',
				'css' => ['{{element}} .pagelayer-service-image img' => 'width:{{val}}px;'],
				'req' => array(
					'service_image_size' => 'custom',
				)
			),
			'box_url' => array(
				'type' => 'link',
				'label' => __pl('url'),
				'selector' => '.pagelayer-box-link',
			),
			'anim_hover' => array(
				'type' => 'select',
				'label' => __pl('icon_animation'),
				'list' => [
					'' => __pl('none'),
					'grow' => __pl('Grow'),
					'shrink' => __pl('Shrink'),
					'pulse' => __pl('Pulse'),
					'pulse-grow' => __pl('Pulse Grow'),
					'pulse-shrink' => __pl('Pulse Shrink'),
					'push' => __pl('Push'),
					'pop' => __pl('Pop'),
					'buzz' => __pl('Buzz'),
					'buzz-out' => __pl('Buzz Out'),
					'float' => __pl('Float'),
					'sink' => __pl('Sink'),
					'bob' => __pl('Bob'),
					'hang' => __pl('Hang'),
					'bounce-in' => __pl('Bounce In'),
					'bounce-out' => __pl('Bounce Out'),
					'rotate' => __pl('Rotate'),
					'grow-rotate' => __pl('Grow Rotate'),
					'skew-forward' => __pl('Skew Forward'),
					'skew-backward' => __pl('Skew Backward'),
					'wobble-vertical' => __pl('Wobble Vertical'),
					'wobble-horizontal' => __pl('Wobble Horizontal'),
					'wobble-bottom-to-right' => __pl('Wobble Bottom To Right'),
					'wobble-top-to-right' => __pl('Wobble Top To Right'),
					'wobble-top' => __pl('Wobble Top'),
					'wobble-bottom' => __pl('Wobble Bottom'),
					'wobble-skew' => __pl('Wobble Skew'),
				],
				'addClass' => 'pagelayer-anim-par'
			)
		],
		'service_img_style' => [
			'service_alignment' => array(
				'type' => 'radio',
				'label' => __pl('service_box_media_alignment'),
				'default' => 'top',
				'list' => array(
					'left' => __pl('left'),
					'top' => __pl('top'),
					'right' => __pl('right'),
				),
			),
			'service_vertical_alignment' => array(
				'type' => 'radio',
				'label' => __pl('service_box_media_vertical_alignment'),
				'default' => 'top',
				'list' => array(
					'top' => __pl('top'),
					'middle' => __pl('middle'),
					'bottom' => __pl('bottom'),
				),
				'req' => ['!service_alignment' => 'top']
			),
			'service_image_height' => array(
				'type' => 'slider',
				'label' => __pl('img_height'),
				'min' => '0',
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-service-image img' => 'height:{{val}}px;'],
			),
			'service_image_object_fit' => array(
				'type' => 'select',
				'label' => __pl('object_fit'),
				'screen' => 1,
				'list' => array(
					'' => __pl('none'),
					'contain' => __pl('contain'),
					'cover' => __pl('cover'),
					'fill' => __pl('fill'),
					'scale-down' => __pl('scale_down'),
				),
				'css' => ['{{element}} .pagelayer-service-image img' => 'object-fit:{{val}};'],
			),
			'service_image_object_pos' => array(
				'type' => 'select',
				'label' => __pl('object_pos'),
				'screen' => 1,
				'list' => array(
					'' => __pl('none'),
					'top' => __pl('top'),
					'bottom' => __pl('bottom'),
					'center' => __pl('center'),
					'left' => __pl('left'),
					'right' => __pl('right'),
				),
				'css' => ['{{element}} .pagelayer-service-image img' => 'object-position:{{val}};'],
				'req' => [ '!service_image_object_fit' => ''],
			),
			'service_img_alignment' => array(
				'type' => 'radio',
				'label' => __pl('horizontal_pos'),
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-service-image' => 'text-align: {{val}};,'],
				'list' => array(
					'left' => __pl('left'),
					'center' => __pl('center'),
					'right' => __pl('right'),
				),
				'req' => ['service_alignment' => 'top']
			),
			'service_image_spacing' => array(
				'type' => 'padding',
				'label' => __pl('service_image_spacing'),
				'css' => ['{{element}} .pagelayer-service-image' => 'padding-top:{{val[0]}}px; padding-right:{{val[1]}}px; padding-bottom:{{val[2]}}px; padding-left:{{val[3]}}px;'],
			),
			'img_bor_state' => array(
				'type' => 'radio',
				'label' => __pl('icon_state'),
				'default' => 'normal',
				'list' => array(
					'normal' => __pl('Normal'),
					'hover' => __pl('Hover'),
				),
			),
			'img_filter' => array(
				'type' => 'filter',
				'label' => __pl('filter'),
				'default' => '0,100,100,0,0,100,100',
				'css' => ['{{element}} img' => 'filter: blur({{val[0]}}px) brightness({{val[1]}}%) contrast({{val[2]}}%) grayscale({{val[3]}}%) hue-rotate({{val[4]}}deg) opacity({{val[5]}}%) saturate({{val[6]}}%)'],
				'show' => ['img_bor_state' => 'normal'],
			),
			'img_border_type' => array(
				'type' => 'select',
				'label' => __pl('icon_border_type'),
				'css' => ['{{element}} .pagelayer-service-image img' =>'border-style: {{val}};'],
				'list' => [
					'' => __pl('none'),
					'solid' => __pl('solid'),
					'double' => __pl('double'),
					'dotted' => __pl('dotted'),
					'dashed' => __pl('dashed'),
					'groove' => __pl('groove'),
				],
				'show' => ['img_bor_state' => 'normal'],
			),
			'img_border_color' => array(
				'type' => 'color',
				'label' => __pl('icon_border_color_label'),
				'default' => '#0986c0',
				'css' => ['{{element}} .pagelayer-service-image img' => 'border-color: {{val}};'],
				'req' => [
					'!img_border_type' => '',
				],
				'show' => ['img_bor_state' => 'normal'],
			),
			'img_border_width' => array(
				'type' => 'padding',
				'label' => __pl('icon_border_width'),
				'screen' => 1,
				'css' =>  ['{{element}} .pagelayer-service-image img' =>'border-top-width: {{val[0]}}px; border-right-width: {{val[1]}}px; border-bottom-width: {{val[2]}}px; border-left-width: {{val[3]}}px;'],
				'req' => [
					'!img_border_type' => '',
				],
				'show' => ['img_bor_state' => 'normal'],
			),
			'img_border_radius' => array(
				'type' => 'padding',
				'label' => __pl('border_radius'),
				'screen' => 1,
				'units' => ['px', 'em', '%'],
				'css' =>  ['{{element}} .pagelayer-service-image img' => 'border-radius: {{val[0]}} {{val[1]}} {{val[2]}} {{val[3]}}; -webkit-border-radius:  {{val[0]}} {{val[1]}} {{val[2]}} {{val[3]}}; -moz-border-radius: {{val[0]}} {{val[1]}} {{val[2]}} {{val[3]}};'],
				'req' => [
					'!img_border_type' => '',
				],
				'show' => ['img_bor_state' => 'normal'],
			),
			'img_transition' => array(
				'type' => 'spinner',
				'label' => __pl('ele_bg_hover_delay'),
				'min' => 0,
				'step' => 100,
				'max' => 5000,
				'default' => 400,
				'css' => ['{{element}} .pagelayer-service-image img' =>'-webkit-transition: all {{val}}ms !important; transition: all {{val}}ms !important;'],
				'show' => ['img_bor_state' => 'hover'],
			),
			'img_filter_hover' => array(
				'type' => 'filter',
				'label' => __pl('filter'),
				'default' => '0,100,100,0,0,100,100',
				'css' => ['{{element}}:hover img' => 'filter: blur({{val[0]}}px) brightness({{val[1]}}%) contrast({{val[2]}}%) grayscale({{val[3]}}%) hue-rotate({{val[4]}}deg) opacity({{val[5]}}%) saturate({{val[6]}}%)'],
				'show' => ['img_bor_state' => 'hover'],
			),
			'img_border_type_hover' => array(
				'type' => 'select',
				'label' => __pl('icon_border_type_hover'),
				'css' => ['{{element}}:hover .pagelayer-service-image img' =>'border-style: {{val}};'],
				'list' => [
					'' => __pl('none'),
					'solid' => __pl('solid'),
					'double' => __pl('double'),
					'dotted' => __pl('dotted'),
					'dashed' => __pl('dashed'),
					'groove' => __pl('groove'),
				],
				'show' => ['img_bor_state' => 'hover'],
			),
			'img_border_color_hover' => array(
				'type' => 'color',
				'label' => __pl('icon_border_color_hover_label'),
				'default' => '#0986c0',
				'css' => ['{{element}}:hover .pagelayer-service-image img' => 'border-color: {{val}};'],
				'req' => [
					'!img_border_type_hover' => '',
				],
				'show' => ['img_bor_state' => 'hover'],
			),
			'img_border_width_hover' => array(
				'type' => 'padding',
				'label' => __pl('icon_border_width_hover'),
				'screen' => 1,
				'css' =>  ['{{element}}:hover .pagelayer-service-image img' =>'border-top-width: {{val[0]}}px; border-right-width: {{val[1]}}px; border-bottom-width: {{val[2]}}px; border-left-width: {{val[3]}}px;'],
				'req' => [
					'!img_border_type_hover' => '',
				],
				'show' => ['img_bor_state' => 'hover'],
			),
			'img_border_radius_hover' => array(
				'type' => 'padding',
				'label' => __pl('border_radius'),
				'screen' => 1,
				'units' => ['px', 'em', '%'],
				'css' =>  ['{{element}}:hover .pagelayer-service-image img' => 'border-radius: {{val[0]}} {{val[1]}} {{val[2]}} {{val[3]}}; -webkit-border-radius:  {{val[0]}} {{val[1]}} {{val[2]}} {{val[3]}}; -moz-border-radius: {{val[0]}} {{val[1]}} {{val[2]}} {{val[3]}};'],
				'req' => [
					'!img_border_type_hover' => '',
				],
				'show' => ['img_bor_state' => 'hover'],
			),
		],
		'service_heading_style' => [
			'service_heading' => array(
				'type' => 'textarea',
				'label' => __pl('service_box_heading_label'),
				'default' => 'This is an Image Box',
				'edit' => '.pagelayer-service-heading',
			),
			'heading_url' => array(
				'type' => 'link',
				'label' => __pl('url'),
				'selector' => '.pagelayer-service-heading-link',
				'req' => ['!service_heading' => '', 'box_url' => '']
			),
			'heading_alignment' => array(
				'type' => 'radio',
				'label' => __pl('service_box_heading_alignment'),
				'default' => 'center',
				'screen' => 1,
				'list' => array(
					'left' => __pl('left'),
					'center' => __pl('center'),
					'right' => __pl('right'),
				),
				'css' => ['{{element}} .pagelayer-service-heading' => 'text-align:{{val}};'],
			),
			'service_title_spacing' => array(
				'type' => 'padding',
				'label' => __pl('spacing'),
				'screen' => 1,
				'default' => ',,10,',
				'css' => ['{{element}} .pagelayer-service-heading' => 'padding-top:{{val[0]}}px; padding-right:{{val[1]}}px; padding-bottom:{{val[2]}}px; padding-left:{{val[3]}}px;']
			),
			'heading_state' => array(
				'type' => 'radio',
				'label' => __pl('icon_state'),
				'default' => 'normal',
				'list' => array(
					'normal' => __pl('Normal'),
					'hover' => __pl('Hover'),
				),
			),
			'service_heading_color' => array(
				'type' => 'color',
				'label' => __pl('service_heading_color'),
				'default' => '#0986c0',
				'css' => ['{{element}} .pagelayer-service-heading' => 'color:{{val}}'],
				'show' => ['heading_state' => 'normal'],
			),
			'service_heading_typo' => array(
				'type' => 'typography',
				'label' => __pl('service_heading_typo'),
				'default' => ',28,,600,,,,,,,',
				'css' => ['{{element}} .pagelayer-service-heading' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'],
				'show' => ['heading_state' => 'normal'],
			),
			'heading_transition' => array(
				'type' => 'spinner',
				'label' => __pl('ele_bg_hover_delay'),
				'min' => 0,
				'step' => 100,
				'max' => 5000,
				'default' => 400,
				'css' => ['{{element}} .pagelayer-service-heading' =>'-webkit-transition: all {{val}}ms !important; transition: all {{val}}ms !important;'],
				'show' => ['heading_state' => 'hover'],
			),
			'heading_color_hover' => array(
				'type' => 'color',
				'label' => __pl('service_heading_color'),
				'css' => ['{{element}}:hover .pagelayer-service-heading' => 'color:{{val}}'],
				'show' => ['heading_state' => 'hover'],
			),
			'heading_typo_hover' => array(
				'type' => 'typography',
				'label' => __pl('service_heading_typo'),
				'css' => ['{{element}}:hover .pagelayer-service-heading' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'],
				'show' => ['heading_state' => 'hover'],
			),
		],
		//service content style
		'service_content_style' =>[
			'service_text_alignment' => array(
				'type' => 'radio',
				'label' => __pl('service_box_text_alignment'),
				'default' => 'center',
				'screen' => 1,
				'list' => array(
					'left' => __pl('left'),
					'center' => __pl('center'),
					'right' => __pl('right'),
					'justify' => __pl('justify'),
				),
				'css' => ['{{element}} .pagelayer-service-details' => 'text-align:{{val}};'],
			),
			'service_content_spacing' => array(
				'type' => 'padding',
				'label' => __pl('spacing'),
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-service-text' => 'padding-top:{{val[0]}}px; padding-right:{{val[1]}}px; padding-bottom:{{val[2]}}px; padding-left:{{val[3]}}px;'],
			),
			'service_text' => array(
				'type' => 'editor',
				'label' => __pl('service_box_text_label'),
				'default' => 'Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.',
				'edit' => '.pagelayer-service-text',
			)
		],
		//service button style
		'service_btn_style' =>[
			'service_button' => array(
				'type' => 'checkbox',
				'label' => __pl('show_btn')
			),
			'service_button_type' => array(
				'type' => 'select',
				'label' => __pl('type'),
				'default' => 'pagelayer-btn-default',
				'list' => array(
					'pagelayer-btn-default' => __pl('btn_type_default'),
					'pagelayer-btn-primary' => __pl('btn_type_primary'),
					'pagelayer-btn-secondary' => __pl('btn_type_secondary'),
					'pagelayer-btn-success' => __pl('btn_type_success'),
					'pagelayer-btn-info' => __pl('btn_type_info'),
					'pagelayer-btn-warning' => __pl('btn_type_warning'),
					'pagelayer-btn-danger' => __pl('btn_type_danger'),
					'pagelayer-btn-dark' => __pl('btn_type_dark'),
					'pagelayer-btn-light' => __pl('btn_type_light'),
					'pagelayer-btn-link' => __pl('btn_type_link'),
					'pagelayer-btn-custom' => __pl('btn_type_custom')
				),
				'req' => array(
					'service_button' => 'true'
				),
			),
			'service_button_size' => array(
				'type' => 'select',
				'label' => __pl('button_size_label'),
				'default' => 'pagelayer-btn-small',
				'list' => array(
					'pagelayer-btn-mini' => __pl('mini'),
					'pagelayer-btn-small' => __pl('small'),
					'pagelayer-btn-large' => __pl('large'),
					'pagelayer-btn-extra-large' => __pl('extra_large'),
					'pagelayer-btn-double-large' => __pl('double_large'),
					'pagelayer-btn-custom' => __pl('custom'),
				),
				'req' => array(
					'service_button' => 'true'
				)
			),
			'service_btn_dim' => array(
				'type' => 'dimension',
				'label' => __pl('service_btn_dim'),
				'default' => '10,15',
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-service-btn' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[0]}}px;padding-left:{{val[1]}}px;'],
				'req' => [
					'service_button' => 'true',
					'service_button_size' => 'pagelayer-btn-custom',
				]
			),
			'service_btn_stretch' => array(
				'type' => 'checkbox',
				'label' => __pl('stretch'),
				'css' => ['{{element}} .pagelayer-service-btn' => 'width:100%;'],
				'req' => array(
					'service_button' => 'true'
				),
			),
			'service_button_url' => array(
				'type' => 'link',
				'label' => __pl('service_btn_url_label'),
				'selector' => '.pagelayer-service-btn',
				'req' => array(
					'service_button' => 'true'
				),
			),
			'service_button_text' => array(
				'type' => 'text',
				'label' => __pl('service_button_text_label'),
				'default' => 'Click Here!',
				'edit' => '.pagelayer-service-btn',
				'req' => array(
					'service_button' => 'true'
				),
			),
			'service_button_typo' => array(
				'type' => 'typography',
				'label' => __pl('typography'),
				'css' => ['{{element}} .pagelayer-service-btn' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'],
				'req' => ['service_button' => 'true']
			),
			'service_btn_spacing' => array(
				'type' => 'padding',
				'label' => __pl('spacing'),
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-service-btn' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
				'req' => ['service_button' => 'true']
			),
			'service_button_font_size' => array(
				'type' => 'slider',
				'label' => __pl('iconbox_btn_text_size'),
				'min' => '0',
				'max' => '50',
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-service-btn' => 'font-size:{{val}}px;'],
				'req' => [
					'service_button' => 'true',
					'iconbox_button_type' => 'pagelayer-btn-custom',
				]
			),
			'service_btn_state' => array(
				'type' => 'radio',
				'label' => __pl('button_state'),
				'default' => 'normal',
				'list' => array(
					'normal' => __pl('Normal'),
					'hover' => __pl('Hover'),
				),
				'req' => array(
					'service_button' => 'true',
					'service_button_type' => 'pagelayer-btn-custom'
				),
			),
			'service_button_color' => array(
				'type' => 'color',
				'label' => __pl('iconbox_button_color'),
				'default' => '#ffffff',
				'css' => ['{{element}} .pagelayer-service-btn' => 'color:{{val}};'],
				'req' => [
					'service_button' => 'true',
					'service_button_type' => 'pagelayer-btn-custom',
				],
				'show' => ['service_btn_state' => 'normal']
			),
			'service_button_bg_color' => array(
				'type' => 'color',
				'label' => __pl('service_button_bg_color'),
				'default' => '#0986c0',
				'css' => ['{{element}} .pagelayer-service-btn' => 'background-color:{{val}};'],
				'req' => [
					'service_button' => 'true',
					'service_button_type' => 'pagelayer-btn-custom',
				],
				'show' => ['service_btn_state' => 'normal']
			),
			'service_btn_hover_delay' => array(
				'type' => 'spinner',
				'label' => __pl('service_btn_hover_delay'),
				'min' => 0,
				'step' => 100,
				'max' => 5000,
				'default' => 400,
				'css' => ['{{element}} .pagelayer-service-btn' => '-webkit-transition: all {{val}}ms; transition: all {{val}}ms;'],
				'show' => ['service_btn_state' => 'hover'],
			),
			'service_button_color_hover' => array(
				'type' => 'color',
				'label' => __pl('iconbox_button_color'),
				'default' => '',
				'css' => ['{{element}} .pagelayer-service-btn:hover' => 'color:{{val}};'],
				'show' => ['service_btn_state' => 'hover'],
			),
			'service_button_bg_color_hover' => array(
				'type' => 'color',
				'label' => __pl('service_button_bg_color_hover'),
				'default' => '',
				'css' => ['{{element}} .pagelayer-service-btn:hover' => 'background-color:{{val}};'],
				'show' => ['service_btn_state' => 'hover'],
			),
		],
		'border_style' => [
			'btn_bor_hover' => array(
				'type' => 'radio',
				'label' => __pl('state'),
				'list' => array(
					'' => __pl('normal'),
					'hover' => __pl('hover'),
				)
			),	
			'btn_border_type' => array(
				'type' => 'select',
				'label' => __pl('border_type'),
				'css' => ['{{element}} .pagelayer-service-btn' => 'border-style: {{val}}'],
				'list' => [
					'' => __pl('none'),
					'solid' => __pl('solid'),
					'double' => __pl('double'),
					'dotted' => __pl('dotted'),
					'dashed' => __pl('dashed'),
					'groove' => __pl('groove'),
				],
				'show' => array(
					'btn_bor_hover' => ''
				),
			),
			'btn_border_color' => array(
				'type' => 'color',
				'label' => __pl('border_color_label'),
				'css' => ['{{element}} .pagelayer-service-btn' => 'border-color: {{val}};'],
				'req' => array(
					'!btn_border_type' => ''
				),
				'show' => array(
					'btn_bor_hover' => ''
				),
			),
			'btn_border_width' => array(
				'type' => 'padding',
				'label' => __pl('border_width'),
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-service-btn' => 'border-top-width: {{val[0]}}px; border-right-width: {{val[1]}}px; border-bottom-width: {{val[2]}}px; border-left-width: {{val[3]}}px'],
				'req' => [
					'!btn_border_type' => ''
				],
				'show' => array(
					'btn_bor_hover' => ''
				),
			),
			'btn_border_radius' => array(
				'type' => 'padding',
				'label' => __pl('border_radius'),
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-service-btn' => 'border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px; -webkit-border-radius:  {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px;-moz-border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px;'],
				'req' => array(
					'!btn_border_type' => ''
				),
				'show' => array(
					'btn_bor_hover' => ''
				),
			),
			'btn_border_type_hover' => array(
				'type' => 'select',
				'label' => __pl('border_type'),
				'css' => ['{{element}} .pagelayer-service-btn:hover' => 'border-style: {{val}}'],
				'list' => [
					'' => __pl('none'),
					'solid' => __pl('solid'),
					'double' => __pl('double'),
					'dotted' => __pl('dotted'),
					'dashed' => __pl('dashed'),
					'groove' => __pl('groove'),
				],
				'show' => array(
					'btn_bor_hover' => 'hover'
				),
			),
			'btn_border_color_hover' => array(
				'type' => 'color',
				'label' => __pl('border_color_hover_label'),
				'css' => ['{{element}} .pagelayer-service-btn:hover' => 'border-color: {{val}};'],
				'req' => array(
					'!btn_border_type_hover' => ''
				),
				'show' => array(
					'btn_bor_hover' => 'hover'
				),
			),
			'btn_border_width_hover' => array(
				'type' => 'padding',
				'label' => __pl('border_width_hover'),
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-service-btn:hover' => 'border-top-width: {{val[0]}}px; border-right-width: {{val[1]}}px; border-bottom-width: {{val[2]}}px; border-left-width: {{val[3]}}px'],
				'req' => [
					'!btn_border_type_hover' => ''
				],
				'show' => array(
					'btn_bor_hover' => 'hover'
				),
			),
			'btn_border_radius_hover' => array(
				'type' => 'padding',
				'label' => __pl('border_radius_hover'),
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-service-btn:hover' => 'border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px; -webkit-border-radius:  {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px;-moz-border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px;'],
				'req' => array(
					'!btn_border_type_hover' => ''
				),
				'show' => array(
					'btn_bor_hover' => 'hover'
				),
			),
		],
		'styles' => [
			'service_img_style' => __pl('service_img_style'),
			'service_heading_style' => __pl('service_heading_style'),
			'service_content_style' => __pl('service_content_style'),
			'service_btn_style' => __pl('service_btn_style'),
			'border_style' => __pl('btn_border_style'),
		],
	)
);

// Icon Box
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_iconbox', array(
		'name' => __pl('Icon Box'),
		'group' => 'other',
		'innerHTML' => 'service_text',
		'html' => '<div class="pagelayer-service-container pagelayer-service-align-{{service_alignment}} pagelayer-service-vertical-{{service_vertical_alignment}}">
			<div class="pagelayer-service-icon pagelayer-service-{{service_icon_view}}">
				<i class="{{service_icon}} pagelayer-icon-{{service_icon_shape_type}} pagelayer-animation-{{anim_hover}}" aria-hidden="true"></i>
			</div>
			<div class="pagelayer-service-details">
				<a if-ext={{heading_url}} href="{{{heading_url}}}" class="pagelayer-ele-link pagelayer-service-heading-link" >
					<div if="{{service_heading}}" class="pagelayer-service-heading">{{service_heading}}</div>
				</a>
				<div if="{{service_text}}" class="pagelayer-service-text">{{service_text}}</div>
				<a if="{{service_button}}" href="{{{service_button_url}}}" class="pagelayer-service-btn pagelayer-button pagelayer-ele-link {{iconbox_button_type}} {{service_button_size}}">
					<span if="{{service_button_text}}">{{service_button_text}}</span>
				</a>
			</div>
			<a if-ext={{box_url}} href="{{{box_url}}}" class="pagelayer-ele-link pagelayer-box-link"> </a>
		</div>',
		'params' => array(
			'service_icon' => array(
				'type' => 'icon',
				'label' => __pl('iconbox_font_icon_label'),
				'default' => 'fas fa-exclamation-circle',
			),
			'service_alignment' => array(
				'type' => 'radio',
				'label' => __pl('iconbox_box_media_alignment'),
				'default' => 'top',
				'list' => array(
					'left' => __pl('left'),
					'top' => __pl('top'),
					'right' => __pl('right'),
				),
			),
			'service_vertical_alignment' => array(
				'type' => 'radio',
				'label' => __pl('iconbox_box_media_vertical_alignment'),
				'default' => 'middle',
				'list' => array(
					'top' => __pl('top'),
					'middle' => __pl('middle'),
					'bottom' => __pl('bottom'),
				),
				'req' => array(
					'!service_alignment' => 'top'
				)
			),
			'service_icon_alignment' => array(
				'type' => 'radio',
				'label' => __pl('horizontal_pos'),
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-service-icon' => 'text-align: {{val}};,'],
				'list' => array(
					'left' => __pl('left'),
					'center' => __pl('center'),
					'right' => __pl('right'),
				),
				'req' => ['service_alignment' => 'top']
			),
			'box_url' => array(
				'type' => 'link',
				'label' => __pl('url'),
				'selector' => '.pagelayer-box-link',
			),
		),
		// icon style
		'service_icon_style' => [
			'service_icon_view' => array(
				'type' => 'select',
				'label' => __pl('iconbox_icon_view'),
				'default' => 'default',
				'list' =>array(
					'default' => __pl('Default'),
					'stacked' => __pl('Stacked'),
					'framed' => __pl('Framed'),
				),
			),
			'service_icon_shape_type' => array(
				'type' => 'select',
				'label' => __pl('iconbox_icon_shape_label'),
				'default' => '',
				'list' =>array(
					'square' => __pl('Square'),
					'circle' => __pl('Circle'),
				),
				'req' => ['!service_icon_view' => 'default'],
			),
			'service_icon_padding' => array(
				'type' => 'slider',
				'label' => __pl('service_icon_padding'),
				'min' => '0',
				'max' => '200',
				'default' => '15',
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-service-icon i' => 'padding: calc(0.5em + {{val}}px);'],
				'req' => ['!service_icon_view' => 'default'],
			),
			'service_icon_spacing' => array(
				'type' => 'padding',
				'screen' => 1,
				'label' => __pl('service_icon_spacing'),
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-service-icon' => 'padding-top:{{val[0]}}px; padding-right:{{val[1]}}px; padding-bottom:{{val[2]}}px; padding-left:{{val[3]}}px;'],
			),			
			'anim_hover' => array(
				'type' => 'select',
				'label' => __pl('icon_animation'),
				'list' => [
					'' => __pl('none'),
					'grow' => __pl('Grow'),
					'shrink' => __pl('Shrink'),
					'pulse' => __pl('Pulse'),
					'pulse-grow' => __pl('Pulse Grow'),
					'pulse-shrink' => __pl('Pulse Shrink'),
					'push' => __pl('Push'),
					'pop' => __pl('Pop'),
					'buzz' => __pl('Buzz'),
					'buzz-out' => __pl('Buzz Out'),
					'float' => __pl('Float'),
					'sink' => __pl('Sink'),
					'bob' => __pl('Bob'),
					'hang' => __pl('Hang'),
					'bounce-in' => __pl('Bounce In'),
					'bounce-out' => __pl('Bounce Out'),
					'rotate' => __pl('Rotate'),
					'grow-rotate' => __pl('Grow Rotate'),
					'skew-forward' => __pl('Skew Forward'),
					'skew-backward' => __pl('Skew Backward'),
					'wobble-vertical' => __pl('Wobble Vertical'),
					'wobble-horizontal' => __pl('Wobble Horizontal'),
					'wobble-bottom-to-right' => __pl('Wobble Bottom To Right'),
					'wobble-top-to-right' => __pl('Wobble Top To Right'),
					'wobble-top' => __pl('Wobble Top'),
					'wobble-bottom' => __pl('Wobble Bottom'),
					'wobble-skew' => __pl('Wobble Skew'),
				],
				'addClass' => 'pagelayer-anim-par'
			),
			'service_icon_state' => array(
				'type' => 'radio',
				'label' => __pl('icon_state'),
				'default' => 'normal',
				'list' => array(
					'normal' => __pl('Normal'),
					'hover' => __pl('Hover'),
				),
			),
			'service_icon_color' => array(
				'type' => 'color',
				'label' => __pl('iconbox_icon_color'),
				'default' => '#0986c0',
				'css' => ['{{element}} .pagelayer-service-icon i' => 'color:{{val}};'],
				'show' => ['service_icon_state' => 'normal'],
			),
			'service_icon_background_color' => array(
				'type' => 'color',
				'label' => __pl('service_icon_background_color'),
				'default' => '#eff0f0',
				'css' => ['{{element}} .pagelayer-service-icon.pagelayer-service-stacked i' => 'background-color:{{val}};'],
				'show' => ['service_icon_state' => 'normal'],
				'req' => ['service_icon_view' => 'stacked']
			),
			'service_icon_font_size' => array(
				'type' => 'slider',
				'label' => __pl('service_icon_size'),
				'min' => '0',
				'max' => '300',
				'default' => '75',
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-service-icon' => 'font-size:{{val}}px;'],
				'show' => ['service_icon_state' => 'normal'],
			),
			'service_rotate' => array(
				'type' => 'slider',
				'label' => __pl('service_icon_rotate'),
				'min' => '0',
				'max' => '360',
				'default' => '0',
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-service-icon i' => 'transform: rotate({{val}}deg);'],
				'show' => ['service_icon_state' => 'normal'],
			),
			'service_icon_hover_delay' => array(
				'type' => 'spinner',
				'label' => __pl('service_icon_hover_delay'),
				'min' => 0,
				'step' => 100,
				'max' => 5000,
				'default' => 400,
				'css' => ['{{element}} .pagelayer-service-icon i' => '-webkit-transition: all {{val}}ms; transition: all {{val}}ms;'],
				'show' => ['service_icon_state' => 'hover'],
			),
			'service_icon_color_hover' => array(
				'type' => 'color',
				'label' => __pl('service_icon_color_hover'),
				'css' => ['{{element}}:hover .pagelayer-service-icon i' => 'color:{{val}};'],
				'show' => ['service_icon_state' => 'hover'],
			),
			'service_icon_background_color_hover' => array(
				'type' => 'color',
				'label' => __pl('service_icon_background_color_hover'),
				'default' => '',
				'css' => ['{{element}}:hover .pagelayer-service-icon.pagelayer-service-stacked i' => 'background-color:{{val}};'],
				'show' => ['service_icon_state' => 'hover'],
				'req' => ['service_icon_view' => 'stacked']
			),
			'service_icon_size_hover' => array(
				'type' => 'slider',
				'label' => __pl('service_icon_size_hover'),
				'min' => '0',
				'max' => '300',
				'screen' => 1,
				'css' => ['{{element}}:hover .pagelayer-service-icon' => 'font-size:{{val}}px;'],
				'show' => ['service_icon_state' => 'hover'],
			),
			'service_rotate_hover' => array(
				'type' => 'slider',
				'label' => __pl('service_rotate_hover'),
				'min' => '0',
				'max' => '360',
				'screen' => 1,
				'css' => ['{{element}}:hover .pagelayer-service-icon i' => 'transform: rotate({{val}}deg);'],
				'show' => ['service_icon_state' => 'hover'],
			),
		],
		'service_icon_border' => [
			'service_bor_state' => array(
				'type' => 'radio',
				'label' => __pl('icon_state'),
				'default' => 'normal',
				'list' => array(
					'normal' => __pl('Normal'),
					'hover' => __pl('Hover'),
				),
			),
			'service_icon_border_type' => array(
				'type' => 'select',
				'label' => __pl('icon_border_type'),
				'css' => ['{{element}} .pagelayer-service-icon i' =>'border-style: {{val}};'],
				'list' => [
					'' => __pl('none'),
					'solid' => __pl('solid'),
					'double' => __pl('double'),
					'dotted' => __pl('dotted'),
					'dashed' => __pl('dashed'),
					'groove' => __pl('groove'),
				],
				'show' => ['service_bor_state' => 'normal'],
			),
			'service_icon_border_color' => array(
				'type' => 'color',
				'label' => __pl('icon_border_color_label'),
				'default' => '#0986c0',
				'css' => ['{{element}} .pagelayer-service-icon i' => 'border-color: {{val}};'],
				'req' => [
					'!service_icon_border_type' => '',
				],
				'show' => ['service_bor_state' => 'normal'],
			),
			'service_icon_border_width' => array(
				'type' => 'padding',
				'label' => __pl('icon_border_width'),
				'screen' => 1,
				'css' =>  ['{{element}} .pagelayer-service-icon i' =>'border-top-width: {{val[0]}}px; border-right-width: {{val[1]}}px; border-bottom-width: {{val[2]}}px; border-left-width: {{val[3]}}px;'],
				'req' => [
					'!service_icon_border_type' => '',
				],
				'show' => ['service_bor_state' => 'normal'],
			),
			'service_icon_border_radius' => array(
				'type' => 'padding',
				'label' => __pl('border_radius'),
				'screen' => 1,
				'css' =>  ['{{element}} .pagelayer-service-icon i ' => 'border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px; -webkit-border-radius:  {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px;-moz-border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px;'],
				'req' => [
					'!service_icon_border_type' => '',
				],
				'show' => ['service_bor_state' => 'normal'],
			),
			'service_icon_border_type_hover' => array(
				'type' => 'select',
				'label' => __pl('icon_border_type_hover'),
				'css' => ['{{element}}:hover .pagelayer-service-icon i' =>'border-style: {{val}};'],
				'list' => [
					'' => __pl('none'),
					'solid' => __pl('solid'),
					'double' => __pl('double'),
					'dotted' => __pl('dotted'),
					'dashed' => __pl('dashed'),
					'groove' => __pl('groove'),
				],
				'show' => ['service_bor_state' => 'hover'],
			),
			'service_icon_border_color_hover' => array(
				'type' => 'color',
				'label' => __pl('icon_border_color_hover_label'),
				'default' => '#0986c0',
				'css' => ['{{element}}:hover .pagelayer-service-icon i' => 'border-color: {{val}};'],
				'req' => [
					'!service_icon_border_type_hover' => '',
				],
				'show' => ['service_bor_state' => 'hover'],
			),
			'service_icon_border_width_hover' => array(
				'type' => 'padding',
				'label' => __pl('icon_border_width_hover'),
				'screen' => 1,
				'css' =>  ['{{element}}:hover .pagelayer-service-icon i' =>'border-top-width: {{val[0]}}px; border-right-width: {{val[1]}}px; border-bottom-width: {{val[2]}}px; border-left-width: {{val[3]}}px;'],
				'req' => [
					'!service_icon_border_type_hover' => '',
				],
				'show' => ['service_bor_state' => 'hover'],
			),
			'service_icon_border_radius_hover' => array(
				'type' => 'padding',
				'label' => __pl('border_radius'),
				'screen' => 1,
				'css' =>  ['{{element}}:hover .pagelayer-service-icon i' => 'border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px; -webkit-border-radius:  {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px;-moz-border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px;'],
				'req' => [
					'!service_icon_border_type_hover' => '',
				],
				'show' => ['service_bor_state' => 'hover'],
			),
		],		
		'service_heading_style' =>[
			'service_heading' => array(
				'type' => 'textarea',
				'label' => __pl('iconbox_box_heading_label'),
				'default' => 'This is Icon Box',
				'edit' => '.pagelayer-service-heading',
			),
			'heading_url' => array(
				'type' => 'link',
				'label' => __pl('url'),
				'selector' => '.pagelayer-service-heading-link',
				'req' => ['!service_heading' => '', 'box_url' => '']
			),
			'heading_alignment' => array(
				'type' => 'radio',
				'label' => __pl('service_box_heading_alignment'),
				'default' => 'center',
				'screen' => 1,
				'list' => array(
					'left' => __pl('left'),
					'center' => __pl('center'),
					'right' => __pl('right'),
				),
				'css' => ['{{element}} .pagelayer-service-heading' => 'text-align:{{val}};'],
			),
			'service_title_spacing' => array(
				'type' => 'padding',
				'label' => __pl('spacing'),
				'screen' => 1,
				'default' => ',,10,',
				'css' => ['{{element}} .pagelayer-service-heading' => 'padding-top:{{val[0]}}px; padding-right:{{val[1]}}px; padding-bottom:{{val[2]}}px; padding-left:{{val[3]}}px;']
			),
			'heading_state' => array(
				'type' => 'radio',
				'label' => __pl('icon_state'),
				'default' => 'normal',
				'list' => array(
					'normal' => __pl('Normal'),
					'hover' => __pl('Hover'),
				),
			),
			'service_heading_color' => array(
				'type' => 'color',
				'label' => __pl('service_heading_color'),
				'default' => '#0986c0',
				'css' => ['{{element}} .pagelayer-service-heading' => 'color:{{val}}'],
				'show' => ['heading_state' => 'normal']
			),
			'service_heading_typo' => array(
				'type' => 'typography',
				'label' => __pl('service_heading_typo'),
				'default' => ',28,,600,,,,,,,',
				'css' => ['{{element}} .pagelayer-service-heading' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'],
				'show' => ['heading_state' => 'normal']
			),
			'heading_delay' => array(
				'type' => 'spinner',
				'label' => __pl('service_icon_hover_delay'),
				'min' => 0,
				'step' => 100,
				'max' => 5000,
				'default' => 400,
				'css' => ['{{element}} .pagelayer-service-heading' => '-webkit-transition: all {{val}}ms; transition: all {{val}}ms;'],
				'show' => ['heading_state' => 'hover']
			),
			'heading_color_hover' => array(
				'type' => 'color',
				'label' => __pl('service_heading_color'),
				'css' => ['{{element}}:hover .pagelayer-service-heading' => 'color:{{val}}'],
				'show' => ['heading_state' => 'hover']
			),
			'heading_typo_hover' => array(
				'type' => 'typography',
				'label' => __pl('service_heading_typo'),
				'css' => ['{{element}}:hover .pagelayer-service-heading' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'],
				'show' => ['heading_state' => 'hover']
			),
		],
		//service content style
		'service_content_style' =>[
			'service_text_alignment' => array(
				'type' => 'radio',
				'label' => __pl('alignment'),
				'default' => 'center',
				'screen' => 1,
				'list' => array(
					'left' => __pl('left'),
					'center' => __pl('center'),
					'right' => __pl('right'),
					'justify' => __pl('justify'),
				),
				'css' => ['{{element}} .pagelayer-service-details' => 'text-align:{{val}};'],
			),
			'service_content_spacing' => array(
				'type' => 'padding',
				'label' => __pl('spacing'),
				'css' => ['{{element}} .pagelayer-service-text' => 'padding-top:{{val[0]}}px; padding-right:{{val[1]}}px; padding-bottom:{{val[2]}}px; padding-left:{{val[3]}}px;'],
			),
			'service_text' => array(
				'type' => 'editor',
				'label' => __pl('iconbox_box_text_label'),
				'default' => 'Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.',
				'edit' => '.pagelayer-service-text',
			),
		],
		//service button style
		'service_btn_style' =>[
			'service_button' => array(
				'type' => 'checkbox',
				'label' => __pl('show_btn'),
			),
			'iconbox_button_type' => array(
				'type' => 'select',
				'label' => __pl('Button Type'),
				'default' => 'pagelayer-btn-primary',
				'list' => array(
					'pagelayer-btn-default' => __pl('btn_type_default'),
					'pagelayer-btn-primary' => __pl('btn_type_primary'),
					'pagelayer-btn-secondary' => __pl('btn_type_secondary'),
					'pagelayer-btn-success' => __pl('btn_type_success'),
					'pagelayer-btn-info' => __pl('btn_type_info'),
					'pagelayer-btn-warning' => __pl('btn_type_warning'),
					'pagelayer-btn-danger' => __pl('btn_type_danger'),
					'pagelayer-btn-dark' => __pl('btn_type_dark'),
					'pagelayer-btn-light' => __pl('btn_type_light'),
					'pagelayer-btn-link' => __pl('btn_type_link'),
					'pagelayer-btn-custom' => __pl('btn_type_custom')
				),
				'req' => ['service_button' => 'true']
			),
			'service_button_size' => array(
				'type' => 'select',
				'label' => __pl('button_size_label'),
				'default' => 'pagelayer-btn-small',
				'list' => array(
					'pagelayer-btn-mini' => __pl('mini'),
					'pagelayer-btn-small' => __pl('small'),
					'pagelayer-btn-large' => __pl('large'),
					'pagelayer-btn-extra-large' => __pl('extra_large'),
					'pagelayer-btn-double-large' => __pl('double_large'),
					'pagelayer-btn-custom' => __pl('custom'),
				),
				'req' => ['service_button' => 'true']
			),
			'service_btn_dim' => array(
				'type' => 'dimension',
				'label' => __pl('service_btn_dim'),
				'default' => '10,15',
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-service-btn' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[0]}}px;padding-left:{{val[1]}}px;'],
				'req' => [
					'service_button' => 'true',
					'service_button_size' => 'pagelayer-btn-custom',
				]
			),
			'service_btn_stretch' => array(
				'type' => 'checkbox',
				'label' => __pl('stretch'),
				'css' => ['{{element}} .pagelayer-service-btn' => 'width:100%;'],
				'req' => ['service_button' => 'true']
			),
			'service_button_url' => array(
				'type' => 'link',
				'label' => __pl('iconbox_btn_url_label'),
				'selector' => '.pagelayer-service-btn',
				'req' => ['service_button' => 'true']
			),
			'service_button_text' => array(
				'type' => 'text',
				'label' => __pl('iconbox_button_text_label'),
				'edit' => '.pagelayer-service-btn',
				'default' => 'Click Here!',
				'req' => ['service_button' => 'true']
			),
			'service_button_typo' => array(
				'type' => 'typography',
				'label' => __pl('typography'),
				'css' => ['{{element}} .pagelayer-service-btn' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'],
				'req' => ['service_button' => 'true']
			),
			'service_btn_spacing' => array(
				'type' => 'padding',
				'label' => __pl('spacing'),
				'css' => ['{{element}} .pagelayer-service-btn' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
				'req' => ['service_button' => 'true']
			),
			'service_button_font_size' => array(
				'type' => 'slider',
				'label' => __pl('iconbox_btn_text_size'),
				'min' => '0',
				'max' => '50',
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-service-btn' => 'font-size:{{val}}px;'],
				'req' => [
					'service_button' => 'true',
					'iconbox_button_type' => 'pagelayer-btn-custom',
				]
			),
			'service_btn_state' => array(
				'type' => 'radio',
				'label' => __pl('button_state'),
				'default' => 'normal',
				'list' => array(
					'normal' => __pl('Normal'),
					'hover' => __pl('Hover'),
				),
				'req' => array(
					'service_button' => 'true',
					'iconbox_button_type' => 'pagelayer-btn-custom'
				),
			),
			'service_button_color' => array(
				'type' => 'color',
				'label' => __pl('iconbox_button_color'),
				'default' => '#ffffff',
				'css' => ['{{element}} .pagelayer-service-btn' => 'color:{{val}};'],
				'req' => [
					'service_button' => 'true',
					'iconbox_button_type' => 'pagelayer-btn-custom',
				],
				'show' => ['service_btn_state' => 'normal']
			),
			'service_button_bg_color' => array(
				'type' => 'color',
				'label' => __pl('service_button_bg_color'),
				'default' => '#0986c0',
				'css' => ['{{element}} .pagelayer-service-btn' => 'background-color:{{val}};'],
				'req' => [
					'service_button' => 'true',
					'iconbox_button_type' => 'pagelayer-btn-custom',
				],
				'show' => ['service_btn_state' => 'normal']
			),
			'service_btn_hover_delay' => array(
				'type' => 'spinner',
				'label' => __pl('service_btn_hover_delay'),
				'min' => 0,
				'step' => 100,
				'max' => 5000,
				'default' => 400,
				'css' => ['{{element}} .pagelayer-service-btn' => '-webkit-transition: all {{val}}ms; transition: all {{val}}ms;'],
				'show' => ['service_btn_state' => 'hover'],
			),
			'service_button_color_hover' => array(
				'type' => 'color',
				'label' => __pl('iconbox_button_color'),
				'default' => '',
				'css' => ['{{element}} .pagelayer-service-btn:hover' => 'color:{{val}};'],
				'show' => ['service_btn_state' => 'hover'],
			),
			'service_button_bg_color_hover' => array(
				'type' => 'color',
				'label' => __pl('service_button_bg_color_hover'),
				'default' => '',
				'css' => ['{{element}} .pagelayer-service-btn:hover' => 'background-color:{{val}};'],
				'show' => ['service_btn_state' => 'hover'],
			),
		],
		'border_style' => [
			'btn_bor_hover' => array(
				'type' => 'radio',
				'label' => __pl('state'),
				'list' => array(
					'' => __pl('normal'),
					'hover' => __pl('hover'),
				)
			),	
			'btn_border_type' => array(
				'type' => 'select',
				'label' => __pl('border_type'),
				'css' => ['{{element}} .pagelayer-service-btn' => 'border-style: {{val}}'],
				'list' => [
					'' => __pl('none'),
					'solid' => __pl('solid'),
					'double' => __pl('double'),
					'dotted' => __pl('dotted'),
					'dashed' => __pl('dashed'),
					'groove' => __pl('groove'),
				],
				'show' => array(
					'btn_bor_hover' => ''
				),
			),
			'btn_border_color' => array(
				'type' => 'color',
				'label' => __pl('border_color_label'),
				'css' => ['{{element}} .pagelayer-service-btn' => 'border-color: {{val}};'],
				'req' => array(
					'!btn_border_type' => ''
				),
				'show' => array(
					'btn_bor_hover' => ''
				),
			),
			'btn_border_width' => array(
				'type' => 'padding',
				'label' => __pl('border_width'),
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-service-btn' => 'border-top-width: {{val[0]}}px; border-right-width: {{val[1]}}px; border-bottom-width: {{val[2]}}px; border-left-width: {{val[3]}}px'],
				'req' => [
					'!btn_border_type' => ''
				],
				'show' => array(
					'btn_bor_hover' => ''
				),
			),
			'btn_border_radius' => array(
				'type' => 'padding',
				'label' => __pl('border_radius'),
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-service-btn' => 'border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px; -webkit-border-radius:  {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px;-moz-border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px;'],
				'req' => array(
					'!btn_border_type' => ''
				),
				'show' => array(
					'btn_bor_hover' => ''
				),
			),
			'btn_border_type_hover' => array(
				'type' => 'select',
				'label' => __pl('border_type'),
				'css' => ['{{element}} .pagelayer-service-btn:hover' => 'border-style: {{val}}'],
				'list' => [
					'' => __pl('none'),
					'solid' => __pl('solid'),
					'double' => __pl('double'),
					'dotted' => __pl('dotted'),
					'dashed' => __pl('dashed'),
					'groove' => __pl('groove'),
				],
				'show' => array(
					'btn_bor_hover' => 'hover'
				),
			),
			'btn_border_color_hover' => array(
				'type' => 'color',
				'label' => __pl('border_color_hover_label'),
				'css' => ['{{element}} .pagelayer-service-btn:hover' => 'border-color: {{val}};'],
				'req' => array(
					'!btn_border_type_hover' => ''
				),
				'show' => array(
					'btn_bor_hover' => 'hover'
				),
			),
			'btn_border_width_hover' => array(
				'type' => 'padding',
				'label' => __pl('border_width_hover'),
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-service-btn:hover' => 'border-top-width: {{val[0]}}px; border-right-width: {{val[1]}}px; border-bottom-width: {{val[2]}}px; border-left-width: {{val[3]}}px'],
				'req' => [
					'!btn_border_type_hover' => ''
				],
				'show' => array(
					'btn_bor_hover' => 'hover'
				),
			),
			'btn_border_radius_hover' => array(
				'type' => 'padding',
				'label' => __pl('border_radius_hover'),
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-service-btn:hover' => 'border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px; -webkit-border-radius:  {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px;-moz-border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px;'],
				'req' => array(
					'!btn_border_type_hover' => ''
				),
				'show' => array(
					'btn_bor_hover' => 'hover'
				),
			),
		],
		'styles' => [
			'service_icon_style' => __pl('service_icon_style'),
			'service_icon_border' => __pl('service_icon_border'),
			'service_heading_style' => __pl('service_heading_style'),
			'service_content_style' => __pl('service_content_style'),
			'service_btn_style' => __pl('service_btn_style'),
			'border_style' => __pl('btn_border_style'),
		],
	)
);

// Tabs
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_tabs', array(
		'name' => __pl('tabs'),
		'group' => 'other',
		'has_group' => [
			'section' => 'params', 
			'prop' => 'elements'
		],
		'holder' => '.pagelayer-tabcontainer',
		'html' => '<div class="pagelayer-tabs-holder"></div>
			<div class="pagelayer-tabcontainer"></div>',
		'params' => array(
			'elements' => array(
				'type' => 'group',
				'label' => __pl('Tabs list'),
				'sc' => PAGELAYER_SC_PREFIX.'_tab',
				'item_label' => array(
					'default' => __pl('tab'),
					'param' => 'title',
				),
				'count' => 2,
				'text' => strtr(__pl('add_new_item'), array('%name%' => __pl('tab_name'))),
			),
			'vertical' => array(
				'type' => 'checkbox',
				'label' => __pl('tabs_vertical'),
			),
			'vertical_width' => array(
				'type' => 'slider',
				'label' => __pl('Tabs container width'),
				'default' => 30,
				'min' => 0,
				'max' => 70,
				'step' => 1,
				'screen' => 1,
				'css' => ['{{element}}' => 'width:100%; display: -webkit-flex;
				display: flex;', '{{element}} .pagelayer-tabs-holder' => '-webkit-flex-basis: {{val}}%; flex-basis:{{val}}%', '{{element}} .pagelayer-tabcontainer' => '-webkit-flex-basis: calc(100% - {{val}}%); flex-basis:calc(100% - {{val}}%)', '{{element}} .pagelayer-tabs-holder .pagelayer-tablinks' => 'width: 100%;'],
				'req' => array(
					'vertical' => 'true',
				)
			),
			'rotate' => array(
				'type' => 'radio',
				'label' => __pl('tabs_rotate'),
				'list' => array(
					'' => __pl('disable'),
					'3000' => '3',
					'5000' => '5',
					'10000' => '10',
					'15000' => '15',
				),
				'addAttr' => 'pagelayer-tabs-rotate="{{rotate}}"'
			)
		),
		'tabs_holder_styles' => [
			'tabs_holder_bg_color' => array(
				'type' => 'color',
				'label' => __pl('Background color'),
				'default' => '#f1f1f1',
				'css' => ['{{element}} .pagelayer-tabs-holder' => 'background-color:{{val}}'],
			),
			'tabs_border_type' => array(
				'type' => 'select',
				'label' => __pl('border_type'),
				'default' => 'solid',
				'list' => [
					'' => __pl('none'),
					'solid' => __pl('solid'),
					'double' => __pl('double'),
					'dotted' => __pl('dotted'),
					'dashed' => __pl('dashed'),
					'groove' => __pl('groove'),
				],
				'css' => ['{{element}} .pagelayer-tabcontainer' => 'border-style: {{val}}', '{{element}} .pagelayer-tabs-holder' =>'border-style: {{val}}'],
			),
			'tabs_border_color' => array(
				'type' => 'color',
				'label' => __pl('border_color'),
				'default' => '#cccccc',
				'req' => [
					'!tabs_border_type' => ''
				],
				'css' => ['{{element}} .pagelayer-tabcontainer' => 'border-color: {{val}}','{{element}} .pagelayer-tabs-holder' => 'border-color: {{val}}'],
			),
			'tabs_holder_border_width' => array(
				'type' => 'padding',
				'label' => __pl('Border Width'),
				'default' => '1,1,0,1',
				'screen' => 1,
				'req' => [
					'!tabs_border_type' => ''
				],
				'css' => ['{{element}} .pagelayer-tabs-holder' => 'border-top-width: {{val[0]}}px; border-right-width: {{val[1]}}px; border-bottom-width: {{val[2]}}px; border-left-width: {{val[3]}}px'],
			),
			'tabs_holder_border_radius' => array(
				'type' => 'padding',
				'label' => __pl('Border Radius'),
				'default' => '1,1,0,1',
				'screen' => 1,
				'req' => [
					'!tabs_border_type' => ''
				],
				'css' => ['{{element}} .pagelayer-tabs-holder' => 'border-top-left-radius: {{val[0]}}px; border-top-right-radius: {{val[1]}}px; border-bottom-right-radius: {{val[2]}}px; border-bottom-left-radius: {{val[3]}}px'],
			),
		],
		'tabs_styles' => [
			'tabs_holder_align' => array(
				'type' => 'radio',
				'label' => __pl('alignment'),
				'default' => 'left',
				'screen' => 1,
				'list' => array(
					'left' => __pl('Left'),
					'center' => __pl('Center'),
					'right' => __pl('Right'),
				),
				'css' => ['{{element}} .pagelayer-tabs-holder' => 'text-align:{{val}}'],
			),
			'tabs_color' => array(
				'type' => 'color',
				'label' => __pl('Color '),
				'default' => '#444',
				'css' => ['{{element}} .pagelayer-tabs-holder .pagelayer-tablinks' => 'color:{{val}}'],
			),
			'tabs_bg_color' => array(
				'type' => 'color',
				'label' => __pl('Background color'),
				'default' => '#f1f1f1',
				'css' => ['{{element}} .pagelayer-tabs-holder .pagelayer-tablinks' => 'background-color:{{val}}'],
			),
			'tabs_active_color' => array(
				'type' => 'color',
				'label' => __pl('Active Tab Color'),
				'default' => '#fff',
				'css' => ['{{element}} .pagelayer-tabs-holder .pagelayer-tablinks.active' => 'color:{{val}}', '{{element}} .pagelayer-tabs-holder .pagelayer-tablinks:hover' => 'color:{{val}}'],
			),
			'tabs_active_bg_color' => array(
				'type' => 'color',
				'label' => __pl('Active Tab Background Color'),
				'default' => '#0986c0',
				'css' => ['{{element}} .pagelayer-tabs-holder .pagelayer-tablinks.active'=> 'background-color:{{val}}', '{{element}} .pagelayer-tabs-holder .pagelayer-tablinks:hover' => 'background-color:{{val}}'],
			),
			'tab_title_typo' => array(
				'type' => 'typography',
				'label' => __pl('tab_title_typo'),
				'css' => ['{{element}} .pagelayer-tabs-holder .pagelayer-tablinks' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'],
			),
			'tabs_icon_align' => array(
				'type' => 'radio',
				'label' => __pl('Icon Position'),
				'default' => 'left',
				'list' => array(
					'left' => __pl('Left'),
					'right' => __pl('Right'),
				),
				'css' => ['{{element}} .pagelayer-tabs-holder .pagelayer-tablinks i'=> 'float:{{val}};'],
			),
			'tabs_icon_spacing' => array(
				'type' => 'slider',
				'label' => __pl('tabs_icon_spacing'),
				'default' => 10,
				'max' => 50,
				'min' => 0,
				'steps' => 1,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-tabs-holder .pagelayer-tablinks i'=> 'padding:0px {{val}}px;padding-{{tabs_icon_align}}:0px;'],
			),
		],
		'content_styles' => [
			'tabs_content_typo' => array(
				'type' => 'typography',
				'label' => __pl('tab_content_typo'),
				'css' => ['{{element}} .pagelayer-tabcontainer' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'],
			),
			'tabs_content_color' => array(
				'type' => 'color',
				'label' => __pl('Color'),
				'default' => '#000000',
				'css' => ['{{element}} .pagelayer-tab' => 'color:{{val}}'],
			),
			'tabs_content_bg_color' => array(
				'type' => 'color',
				'label' => __pl('Background Color'),
				'default' => '#fff',
				'css' => ['{{element}} .pagelayer-tab'=> 'background-color:{{val}}'],
			),
			'tab_padding' => array(
				'type' => 'slider',
				'label' => __pl('tabs_padding_label'),
				'default' => 15,
				'min' => 0,
				'max' => 50,
				'step' => 1,
				'screen' => 1,
				'css' => ['{{element}}.pagelayer-tabs .pagelayer-tabcontainer .pagelayer-tab' => 'padding: {{val}}px;'],
			),
			'tabs_content_border_width' => array(
				'type' => 'padding',
				'label' => __pl('border_width'),
				'default' => '1,1,1,1',
				'screen' => 1,
				'req' => [
					'!tabs_border_type' => ''
				],
				'css' => ['{{element}} .pagelayer-tabcontainer' => 'border-top-width: {{val[0]}}px; border-right-width: {{val[1]}}px; border-bottom-width: {{val[2]}}px; border-left-width: {{val[3]}}px'],
			),
			'tabs_content_border_radius' => array(
				'type' => 'padding',
				'label' => __pl('border_radius'),
				'screen' => 1,
				'req' => [
					'!tabs_border_type' => ''
				],
				'css' => ['{{element}} .pagelayer-tabcontainer' => 'border-top-left-radius: {{val[0]}}px; border-top-right-radius: {{val[1]}}px; border-bottom-right-radius: {{val[2]}}px; border-bottom-left-radius: {{val[3]}}px'],
			),
		],
		'styles' => [
			'tabs_holder_styles' => __pl('tabs_holder_styles'),
			'tabs_styles' => __pl('Tabs'),
			'content_styles' => __pl('content'),
		],
	)
);


// Tab
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_tab', array(
		'name' => __pl('tab'),
		'group' => 'other',
		'not_visible' => 1,
		'parent' => [PAGELAYER_SC_PREFIX.'_tabs'],
		'has_group' => [
			'section' => 'params', 
			'prop' => 'elements',
		],
		'holder' => '.pagelayer-tabcontent',
		'html' => '<div class="pagelayer-tabcontent"></div>',
		'params' => array(
			'elements' => array(
				'type' => 'group',
				'label' => __pl('Inner Row'),
				'sc' => PAGELAYER_SC_PREFIX.'_inner_row', // a.k.a the item being multiplied by the count
				'count' => 1,
				'item_label' => array(
					'default' => __pl('Inner Row'),
				),
				'item_atts' => [], // orderwise array of attrbutes to be set as per the count given 
				'inner_content' => [ // This is the content within each item which is going to the created i.e. within each SC. This only use for inner rows
					['pl_col' => [
						'inner_content' => [
							['pl_text' => [ 'atts' => ['text' => 'This is the default Tab content. Feel free to delete it.']]]
						]]
					]
				],
				'hide' => 1,
			),
			'default_active' => array(
				'type' => 'checkbox',
				'label' => __pl('Default active tab'),
				'addAttr' => 'pagelayer-default_active="1"'
			),
			'tab_icon' => array(
				'type' => 'icon',
				'label' => __pl('icon'),
				'addAttr' => 'pagelayer-tab-icon="{{tab_icon}}"',
			),
			'anchor_id' => array(
				'type' => 'text',
				'label' => __pl('ele_id'),
				'addAttr' => 'id="{{anchor_id}}"'
			),
			'title' => array(
				'type' => 'text',
				'label' => __pl('title'),
				'default' => 'Lorem',
				'addAttr' => 'pagelayer-tab-title="{{title}}"'
			),
		)
	)
);

// Accordion
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_accordion', array(
		'name' => __pl('accordion'),
		'group' => 'other',
		'has_group' => [
			'section' => 'params', 
			'prop' => 'elements'
		],
		'holder' => '.pagelayer-accordion-holder',
		'html' => '<div class="pagelayer-accordion-holder" data-icon="{{icon}}" data-active_icon="{{active_icon}}"></div>',
		'params' => array(
			'elements' => array(
				'type' => 'group',
				'label' => __pl('Accordions'),
				'sc' => PAGELAYER_SC_PREFIX.'_accordion_item',
				'item_label' => array(
					'default' => __pl('accordion_item_title_label'),
					'param' => 'title'
				),
				'count' => 2,
				'text' => strtr(__pl('add_new_item'), array('%name%' => __pl('accordion_name'))),				
			),		
			'acc_space' => array(
				'type' => 'slider',
				'label' => __pl('Space Between'),
				'default' => 0,
				'min' => 0,
				'max' => 50,
				'step' => 1,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-accordion_item' => 'margin-bottom:{{val}}px;'],
			),	
		),
		'icon_styles' => [
			'icon' => array(
				'type' => 'icon',
				'label' => __pl('list_icon_label'),
				'default' => 'fas fa-plus',
			),
			'active_icon' => array(
				'type' => 'icon',
				'label' => __pl('Active Icon'),
				'default' => 'fas fa-minus',
			),
			'icon_align' => array(
				'type' => 'radio',
				'label' => __pl('Alignment'),
				'default' => 'left',
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-accordion-tabs .pagelayer-accordion-icon' => 'float:{{val}}'],
				'list' => array(
					'left' => __pl('left'),
					'right' => __pl('right'),
				)
			
			),
			'icon_padding' => array(
				'type' => 'slider',
				'label' => __pl('Spacing'),
				'default' => 10,
				'min' => 0,
				'max' => 50,
				'step' => 1,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-accordion-tabs .pagelayer-accordion-icon' => 'padding:0px {{val}}px; padding-{{icon_align}}:0px;'],
			),	
		],
		'tabs_styles' => [
			'tabs_color' => array(
				'type' => 'color',
				'label' => __pl('Color '),
				'default' => '#444444',
				'css' => ['{{element}} .pagelayer-accordion-tabs' => 'color:{{val}}'],
			),
			'tabs_bg_color' => array(
				'type' => 'color',
				'label' => __pl('Background Color '),
				'default' => '#eeeeee',
				'css' => ['{{element}} .pagelayer-accordion-tabs' => 'background-color:{{val}}'],
			),
			'tabs_active_color' => array(
				'type' => 'color',
				'label' => __pl('Active Tab Color '),
				'default' => '#ffffff',
				'css' => ['{{element}} .active .pagelayer-accordion-tabs' => 'color:{{val}}', '{{element}} .pagelayer-accordion-tabs:hover' => 'color:{{val}}'],
			),
			'tabs_active_bg_color' => array(
				'type' => 'color',
				'label' => __pl('Active Tab Background Color '),
				'default' => '#0986c0',
				'css' => ['{{element}} .active .pagelayer-accordion-tabs'=> 'background-color:{{val}}', '{{element}} .pagelayer-accordion-tabs:hover' => 'background-color:{{val}}'],
			),
			'tab_padding' => array(
				'type' => 'slider',
				'label' => __pl('tabs_padding_label'),
				'default' => 15,
				'min' => 0,
				'max' => 50,
				'step' => 1,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-accordion-tabs' => 'padding: {{val}}px;'],
			),
			'accordion_title_typo' => array(
				'type' => 'typography',
				'label' => __pl('accordion_title_typo'),
				'css' => ['{{element}} .pagelayer-accordion-tabs' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'],
			),
		],
		'content_styles' => [
			'tabs_content_bg_color' => array(
				'type' => 'color',
				'label' => __pl('Background Color'),
				'default' => '#fff',
				'css' => ['{{element}} .pagelayer-accordion_item .pagelayer-accordion-panel'=> 'background-color:{{val}}'],
			),
			'acc_content_typo' => array(
				'type' => 'typography',
				'label' => __pl('accordion_content_typo'),
				'css' => ['{{element}} .pagelayer-accordion-panel' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'],
			),
			'acc_content_padding' => array(
				'type' => 'padding',
				'label' => __pl('padding'),
				'units' => ['px', '%', 'em'],
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-accordion-panel' => 'padding: {{val[0]}} {{val[1]}} {{val[2]}} {{val[3]}}'],
			),
			'acc_border_type' => array(
				'type' => 'select',
				'label' => __pl('border_type'),
				'list' => [
					'' => __pl('none'),
					'solid' => __pl('solid'),
					'double' => __pl('double'),
					'dotted' => __pl('dotted'),
					'dashed' => __pl('dashed'),
					'groove' => __pl('groove'),
				],
				'css' => ['{{element}} .pagelayer-accordion_item' => 'border-style: {{val}}', '{{element}} .pagelayer-accordion_item .pagelayer-accordion-panel' =>'border-style: {{val}}'],
			),
			'acc_border_color' => array(
				'type' => 'color',
				'label' => __pl('border_color'),
				'default' => '#cccccc',
				'req' => [
					'!acc_border_type' => ''
				],
				'css' => ['{{element}} .pagelayer-accordion_item' => 'border-color: {{val}}', '{{element}} .pagelayer-accordion_item .pagelayer-accordion-panel' =>'border-color: {{val}}'],
			),
			'acc_border_width' => array(
				'type' => 'padding',
				'label' => __pl('border_width'),
				'default' => '1,1,1,1',
				'screen' => 1,
				'req' => [
					'!acc_border_type' => ''
				],
				'css' => ['{{element}} .pagelayer-accordion_item' => 'border-top-width: {{val[0]}}px; border-right-width: {{val[1]}}px; border-bottom-width: {{val[2]}}px; border-left-width: {{val[3]}}px', '{{element}} .pagelayer-accordion_item .pagelayer-accordion-panel' => 'border-width: {{val[0]}}px 0 0 0'],
			),
			'acc_border_radius' => array(
				'type' => 'padding',
				'label' => __pl('border_radius'),
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-accordion_item' => 'border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px '],
			)
		],
		'styles' => [
			'icon_styles' => __pl('icon'),
			'tabs_styles' => __pl('Tabs'),
			'content_styles' => __pl('Content'),
		],
	)
);

// Accordion item
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_accordion_item', array(
		'name' => __pl('Accordion item'),
		'group' => 'other',
		'not_visible' => 1,
		'parent' => [PAGELAYER_SC_PREFIX.'_accordion', PAGELAYER_SC_PREFIX.'_collapse'],
		'has_group' => [
			'section' => 'params', 
			'prop' => 'elements'
		],
		'holder' => '.pagelayer-accordion-panel',
		'html' => '<a if="{{title}}" class="pagelayer-accordion-tabs"><label class="pagelayer-accordion-title">{{title}}</label><span class="pagelayer-accordion-icon"><i></i></span></a>
		<div class="pagelayer-accordion-panel"></div>',
		'params' => array(
			'elements' => array(
				'type' => 'group',
				'label' => __pl('Inner Row'),
				'sc' => PAGELAYER_SC_PREFIX.'_inner_row',
				'count' => 1,
				'item_label' => array(
					'default' => __pl('Inner Row'),
				),
				'hide' => 1,
			),
			'default_active' => array(
				'type' => 'checkbox',
				'label' => __pl('Default active tab'),
				'addClass' => 'active'
			),
			'scroll_id' => array(
				'type' => 'text',
				'label' => __pl('ele_id'),
				'addAttr' => ['{{element}} .pagelayer-accordion-tabs' => 'id={{scroll_id}}']
			),
			'title' => array(
				'type' => 'text',
				'label' => __pl('title'),
				'default' => 'Lorem',
				'edit' => '.pagelayer-accordion-title',
			),
		)
	)
);

// Toggle / Collapse
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_collapse', array(
		'name' => __pl('Collapse'),
		'group' => 'other',
		'has_group' => [
			'section' => 'params', 
			'prop' => 'elements'
		],
		'holder' => '.pagelayer-collapse-holder',
		'html' => '<div class="pagelayer-collapse-holder" data-icon="{{icon}}" data-active_icon="{{active_icon}}"></div>',
		'params' => array(
			'elements' => array(
				'type' => 'group',
				'label' => __pl('Collapse Items'),
				'sc' => PAGELAYER_SC_PREFIX.'_accordion_item',
				'item_label' => array(
					'default' => __pl('tab'),
					'param' => 'title',
				),
				'count' => 2,
				'text' => strtr(__pl('add_new_item'), array('%name%' => __pl('tab_name'))),
			),
			'acc_space' => array(
				'type' => 'slider',
				'label' => __pl('Space Between'),
				'default' => 0,
				'min' => 0,
				'max' => 50,
				'step' => 1,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-accordion_item' => 'margin-bottom:{{val}}px;'],
			),
			
		),
		'icon_style' => [
			'icon' => array(
				'type' => 'icon',
				'label' => __pl('list_icon_label'),
				'default' => 'fas fa-plus',
			),
			'active_icon' => array(
				'type' => 'icon',
				'label' => __pl('Active icon'),
				'default' => 'fas fa-minus'
			),
			'icon_align' => array(
				'type' => 'radio',
				'label' => __pl('Alignment'),
				'default' => 'left',
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-accordion-tabs .pagelayer-accordion-icon' => 'float:{{val}}'],
				'list' => array(
					'left' => __pl('left'),
					'right' => __pl('right'),
				)
			
			),
			'icon_padding' => array(
				'type' => 'slider',
				'label' => __pl('Spacing'),
				'default' => 10,
				'min' => 0,
				'max' => 50,
				'step' => 1,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-accordion-tabs .pagelayer-accordion-icon' => 'padding:0px {{val}}px; padding-{{icon_align}}:0px;'],
			),
		],
		'tabs_styles' => [
			'tabs_color' => array(
				'type' => 'color',
				'label' => __pl('Color '),
				'default' => '#444',
				'css' => ['{{element}} .pagelayer-accordion-tabs' => 'color:{{val}}'],
			),
			'tabs_bg_color' => array(
				'type' => 'color',
				'label' => __pl('Background Color '),
				'default' => '#eee',
				'css' => ['{{element}} .pagelayer-accordion-tabs' => 'background-color:{{val}}'],
			),
			'tabs_active_color' => array(
				'type' => 'color',
				'label' => __pl('Active Tab Color '),
				'default' => '#fff',
				'css' => ['{{element}} .active .pagelayer-accordion-tabs' => 'color:{{val}}', '{{element}} .pagelayer-accordion-tabs:hover' => 'color:{{val}}'],
			),
			'tabs_active_bg_color' => array(
				'type' => 'color',
				'label' => __pl('Active Tab Background Color '),
				'default' => '#0986c0',
				'css' => ['{{element}} .active .pagelayer-accordion-tabs'=> 'background-color:{{val}}', '{{element}} .pagelayer-accordion-tabs:hover' => 'background-color:{{val}}'],
			),
			'tab_padding' => array(
				'type' => 'slider',
				'label' => __pl('tabs_padding_label'),
				'default' => 15,
				'min' => 0,
				'max' => 50,
				'step' => 1,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-accordion-tabs' => 'padding: {{val}}px;'],
			),
			'collapse_title_typo' => array(
				'type' => 'typography',
				'label' => __pl('collapsse_title_typo'),
				'css' => ['{{element}} .pagelayer-accordion-tabs' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'],
			),
		],
		'content_styles' => [
			'tabs_content_bg_color' => array(
				'type' => 'color',
				'label' => __pl('Background Color '),
				'default' => '#ffffff',
				'css' => ['{{element}} .pagelayer-accordion_item .pagelayer-accordion-panel'=> 'background-color:{{val}}'],
			),
			'acc_content_padding' => array(
				'type' => 'padding',
				'label' => __pl('padding'),
				'units' => ['px', '%', 'em'],
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-accordion_item .pagelayer-accordion-panel' => 'padding: {{val[0]}} {{val[1]}} {{val[2]}} {{val[3]}}'],
			),
			'acc_border_type' => array(
				'type' => 'select',
				'label' => __pl('border_type'),
				'list' => [
					'' => __pl('none'),
					'solid' => __pl('solid'),
					'double' => __pl('double'),
					'dotted' => __pl('dotted'),
					'dashed' => __pl('dashed'),
					'groove' => __pl('groove'),
				],
				'show' => ['border_hover' => ''],
				'css' => ['{{element}} .pagelayer-accordion_item' => 'border-style: {{val}}', '{{element}} .pagelayer-accordion_item .pagelayer-accordion-panel' =>'border-style: {{val}}'],
			),
			'acc_border_width' => array(
				'type' => 'padding',
				'label' => __pl('border_width'),
				'default' => '1,1,1,1',
				'screen' => 1,
				'req' => [
					'!acc_border_type' => ''
				],
				'css' => ['{{element}} .pagelayer-accordion_item' => 'border-top-width: {{val[0]}}px; border-right-width: {{val[1]}}px; border-bottom-width: {{val[2]}}px; border-left-width: {{val[3]}}px', '{{element}} .pagelayer-accordion_item .pagelayer-accordion-panel' => 'border-width: {{val[0]}}px 0 0 0'],
			),
			'acc_border_color' => array(
				'type' => 'color',
				'label' => __pl('border_color'),
				'default' => '#cccccc',
				'req' => [
					'!acc_border_type' => ''
				],
				'css' => ['{{element}} .pagelayer-accordion_item' => 'border-color: {{val}}', '{{element}} .pagelayer-accordion_item .pagelayer-accordion-panel' =>'border-color: {{val}}'],
			),
			'acc_border_radius' => array(
				'type' => 'padding',
				'label' => __pl('border_radius'),
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-accordion_item' => 'border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px '],
				'req' => array(
					'!acc_border_type' => ''
				),
			)
		],
		'styles' => [
			'icon_style' => __pl('icon'),
			'tabs_styles' => __pl('Tabs'),
			'content_styles' => __pl('Content'),
		],
	)
);

// Space
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_space', array(
		'name' => __pl('space'),
		'group' => 'other',
		'html' => '<div class="pagelayer-space-holder"></div>',
		'params' => array(
			'height' => array(
				'type' => 'slider',
				'label' => __pl('Space Height'),
				'screen' => 1,
				'units' => ['px', 'em'],
				'css' => ['{{element}} .pagelayer-space-holder' => 'height: {{val}};'],
				'default' => '10',
				'min' => 0,
				'max' => 1000,
				'step' => 1
			)
		)
	)
);

// Embed
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_embed', array(
		'name' => __pl('embed'),
		'group' => 'other',
		'innerHTML' => 'data',
		'html' => '<div if={{data}} class="pagelayer-embed-container">{{data}}</div>',
		'params' => array(
			'data' => array(
				'type' => 'textarea',
				'label' => __pl('embed_paste_code'),
				'default' => '<p>Paste HTML code here...</p>',
				'desc' => '',
			),
		)
	)
);

// Shortcodes
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_shortcodes', array(
		'name' => __pl('shortcodes'),
		'group' => 'other',
		'no_gt' => 1,
		'innerHTML' => 'data',
		'holder' => '.pagelayer-shortcodes-container',
		'html' => '<div class="pagelayer-shortcodes-container">{{{shortcode}}}</div>',
		'params' => array(
			'data' => array(
				'type' => 'textarea',
				'label' => __pl('shortcodes_paste_code'),
				'desc' => 'Paste short codes here',
			),
		)
	)
);

// Shortcodes
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_missing', array(
		'name' => __pl('missing_content'),
		'group' => 'other',
		'no_gt' => 1,
		'not_visible' => 1,
		'innerHTML' => 'data',
		'holder' => '.pagelayer-missing-container',
		'html' => '<div class="pagelayer-missing-message">
			<i class="fas fa-exclamation"></i> 
			{{{missing_msg}}}
		</div>
		<div class="pagelayer-missing-container">{{data}}</div>',
		'params' => array(
			'data' => array(
				'type' => 'textarea',
				'label' => __pl('Incompatible Content'),
				'no_val' => 1,
				'desc' => __('This code will be saved exactly as it is with the post!'),
			),
		)
	)
);

// Google Maps
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_google_maps', array(
		'name' => __pl('google_maps'),
		'group' => 'other',
		'innerHTML' => 'address',
		'html' => '<div class="pagelayer-google-maps-holder">
			<iframe if="{{show_v2}}" marginheight="0" scrolling="no" marginwidth="0" frameborder="0" src="https://maps.google.com/maps?q={{address}}&t=m&z={{zoom}}&output=embed&iwloc=near" aria-label="{{address}}"></iframe>
			{{src_code}}
		</div>',
		'params' => array(
			'api_version' => array(
				'type' => 'select',
				'label' => __pl('api_version'),
				'default' => 'v3',
				'list' =>array(
					'' => __pl('version2'),
					'v3' => __pl('version3')
				),
				'desc' => __pl('api_version_desc')
			),
			'api_key' => array(
				'type' => 'text',
				'label' => __pl('api_key'),
				'desc' => __pl('google_api_key_desc'),
				'req' => ['api_version' => 'v3']
			),
			'map_modes' => array(
				'type' => 'select',
				'label' => __pl('map_modes'),
				'default' => 'place',
				'list' =>array(
					'place' => __pl('place'),
					'view' => __pl('view'),
					'directions' => __pl('directions'),
					'streetview' => __pl('streetview'),
					'search' => __pl('search')
				),
				'req' => ['api_version' => 'v3']
			),
			'address' => array(
				'type' => 'text',
				'label' => __pl('google_map_address_label'),
				'default' => 'New York, New York, USA',
				'desc' => __pl('google_map_address_desc'),
				'req' => ['!map_modes' => 'search']
			),
			'direction_origin' => array(
				'type' => 'text',
				'label' => __pl('origin'),
				'default' => 'Oslow Norway',
				'req' => [
					'api_version' => 'v3', 
					'map_modes' => 'directions'
				]
			),
			'direction_destination' => array(
				'type' => 'text',
				'label' => __pl('destination'),
				'default' => 'Telemark Norway',
				'req' => [
					'api_version' => 'v3', 
					'map_modes' => 'directions'
				]
			),
			'direction_waypoints' => array(
				'type' => 'text',
				'label' => __pl('waypoints'),
				'desc' => __pl('waypoints_desc'),
				'req' => [
					'api_version' => 'v3', 
					'map_modes' => 'directions'
				]
			),
			'direction_modes' => array(
				'type' => 'select',
				'label' => __pl('modes'),
				'default' => 'driving',
				'list' =>array(
					'driving' => __pl('driving'),
					'walking' => __pl('walking'),
					'bicycling' => __pl('bicycling'),
					'flying' => __pl('flying')
				),
				'req' => [
					'api_version' => 'v3', 
					'map_modes' => 'directions'
				]
			),
			'direction_avoid' => array(
				'type' => 'multiselect',
				'label' => __pl('avoid'),
				'list' => array(
					'tolls' => __pl('tolls'),
					'ferries' => __pl('ferries'),
					'highways' => __pl('highways'),
				),
				'desc' => __pl('direc_avoid_desc'),
				'req' => [
					'api_version' => 'v3', 
					'map_modes' => 'directions'
				]
			),
			'direction_units' => array(
				'type' => 'select',
				'label' => __pl('units'),
				'default' => 'metric',
				'list' =>array(
					'metric' => __pl('metric'),
					'imperial' => __pl('imperial'),
				),
				'req' => [
					'api_version' => 'v3', 
					'map_modes' => 'directions'
				]
			),			
			'streetview_pano' => array(
				'type' => 'text',
				'label' => __pl('pano'),
				'default' => 'eTnPNGoy4bxR9LpjjfFuOw',
				'desc' => __pl('pano_desc'),
				'req' => [
					'api_version' => 'v3', 
					'map_modes' => 'streetview'
				]
			),
			'streetview_location' => array(
				'type' => 'text',
				'label' => __pl('location'),
				'default' => '46.414382,10.013988',
				'desc' => __pl('center_desc'),
				'req' => [
					'api_version' => 'v3', 
					'map_modes' => 'streetview'
				]
			),
			'streetview_heading' => array(
				'type' => 'slider',
				'label' => __pl('heading'),
				'min' => -180,
				'max' => 360,
				'desc' => __pl('heading_desc'),
				'req' => [
					'api_version' => 'v3', 
					'map_modes' => 'streetview'
				]
			),
			'streetview_pitch' => array(
				'type' => 'slider',
				'label' => __pl('pitch'),
				'min' => -90,
				'max' => 90,
				'desc' => __pl('pitch_desc'),
				'req' => [
					'api_version' => 'v3', 
					'map_modes' => 'streetview'
				]
			),
			'streetview_fov' => array(
				'type' => 'slider',
				'label' => __pl('fov'),
				'min' => 10,
				'max' => 100,
				'desc' => __pl('fov_desc'),
				'req' => [
					'api_version' => 'v3', 
					'map_modes' => 'streetview'
				]
			),
			'search_term' => array(
				'type' => 'text',
				'label' => __pl('google_search_term'),
				'default' => 'Record stores in Seattle',
				'desc' => __pl('google_search_desc'),
				'req' => [
					'api_version' => 'v3', 
					'map_modes' => 'search'
				]
			),
			'center' => array(
				'type' => 'text',
				'label' => __pl('center'),
				'desc' => __pl('center_desc'),
				'req' => [
					'api_version' => 'v3',
					'!map_modes' => 'streetview'
				]
			),
			'map_type' => array(
				'type' => 'select',
				'label' => __pl('map_type'),
				'default' => 'roadmap',
				'list' =>array(
					'roadmap' => __pl('roadmap'),
					'satellite' => __pl('satellite')
				),
				'req' => [
					'api_version' => 'v3',
					'!map_modes' => 'streetview'
				]
			),
			'noscroll' => array(
				'type' => 'checkbox',
				'label' => __pl('google_map_noscroll'),
				'css' => ['{{element}} iframe' => 'pointer-events: none;'],
			),
			'zoom' => array(
				'type' => 'slider',
				'label' => __pl('google_map_zoom_label'),
				'default' => 10,
				'min' => 0,
				'max' => 21
			),
			'height' => array(
				'type' => 'slider',
				'label' => __pl('google_map_height'),
				'screen' => 1,
				'default' => 300,
				'min' => 100,
				'max' => 1000,
				'css' => ['{{element}} iframe' => 'height: {{val}}px'],
			),
		)
	)
);

// Testimonial
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_testimonial', array(
		'name' => __pl('testimonial'),
		'group' => 'other',
		'innerHTML' => 'quote_content',
		'html' => '<div if="{{quote_content}}" class="pagelayer-testimonial-content">{{quote_content}}</div>
		<div class="pagelayer-testimonial-author-details">
			<div if="{{avatar}}" class="pagelayer-{{image_position}}">
				<img class="pagelayer-img pagelayer-testimonial-image pagelayer-testimonial-{{img_shape}}" src="{{func_image}}" title="{{{avatar-title}}}" alt="{{{avatar-alt}}}"/>
			</div>
			<div class="pagelayer-{{image_position}}">
				<div if="{{cite}}" class="pagelayer-testimonial-cite">
					<a if-ext="{{cite_url}}" class="pagelayer-ele-link" href="{{{cite_url}}}">
						<span class="pagelayer-testimonial-author">{{cite}}</span>
					</a>
					<span if="{{designation}}" class="pagelayer-testimonial-author-title">
						{{designation}}
					</span>
				</div>
			</div>
		</div>',
		'params' => array(
			'image_position' => array(
				'type' => 'select',
				'label' => __pl('position'),
				'default' => 'aside-position',
				'list' =>array(
					'aside-position' => __pl('aside'),
					'top-position' => __pl('top')
				),
			),
			'alignment' => array(
				'type' => 'radio',
				'label' => __pl('testimonial_alignment_label'),
				'default' => 'center',
				'css' =>'text-align:{{val}};',
				'screen' => 1,
				'list' => array(
					'left' => __pl('left'),
					'center' => __pl('center'),
					'right' => __pl('right'),
				),
			),
			'author-spacing' => array(
				'type' => 'slider',
				'label' => __pl('author_spacing'),
				'min' => '0',
				'max' => '100',
				'default' => '20',
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-testimonial-author-details' => 'margin-top:{{val}}px;'],
			),
		),
		// Styles
		'content_style' => [
			'quote_content' => array(
				'type' => 'editor',
				'label' => __pl('testimonial_content_label'),
				'edit' => '.pagelayer-testimonial-content',
				'default' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.'
			)
		],
		'avatar_style' => [
			'avatar' => array(
				'type' => 'image',
				'label' => __pl('testimonial_image_label'),
				'default' => PAGELAYER_URL.'/images/default-image.png',
				'desc' => __pl('testimonial_image_desc'),
				'ai' => false,
			),
			'testimonial_image_size' => array(
				'label' => __pl('testimonial_image_sizes'),
				'type' => 'slider',
				'min' => 0,
				'max' => 500,
				'default' => 100,
				'screen' => 1,
				'css' => ['{{element}}  .pagelayer-testimonial-image' => 'width:{{val}}px !important; height:{{val}}px !important;'],
			),
			'img_shape' => array(
				'type' => 'select',
				'label' => __pl('image_shape'),
				'default' => 'circle',
				'list' =>array(
					'square' => __pl('square'),
					'circle' => __pl('circle'),
				),
			),
			'testimonial_border_type' => array(
				'type' => 'select',
				'label' => __pl('border_type'),
				'css' => ['{{element}} .pagelayer-testimonial-image' =>'border-style: {{val}};'],
				'list' => [
					'' => __pl('none'),
					'solid' => __pl('solid'),
					'double' => __pl('double'),
					'dotted' => __pl('dotted'),
					'dashed' => __pl('dashed'),
					'groove' => __pl('groove'),
				]
			),
			'testimonial_border_color' => array(
				'type' => 'color',
				'label' => __pl('testimonial_border_color_label'),
				'default' => '#42414f',
				'css' => ['{{element}} .pagelayer-testimonial-image' => 'border-color: {{val}};'],
				'req' => ['!testimonial_border_type' => '']
			),
			'testimonial_border_width' => array(
				'type' => 'padding',
				'label' => __pl('border_width'),
				'screen' => 1,
				'css' =>  ['{{element}} .pagelayer-testimonial-image' =>'border-top-width: {{val[0]}}px; border-right-width: {{val[1]}}px; border-bottom-width: {{val[2]}}px; border-left-width: {{val[3]}}px;'],
				'req' => ['!testimonial_border_type' => '']
			),
			'testimonial_border_radius' => array(
				'type' => 'padding',
				'label' => __pl('border_radius'),
				'screen' => 1,
				'css' =>  ['{{element}} .pagelayer-testimonial-image' => 'border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px; -webkit-border-radius:  {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px;-moz-border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px;'],
				'req' => ['!testimonial_border_type' => '']
			),
		],
		'cite_style' => [
			'cite' => array(
				'type' => 'text',
				'label' => __pl('testimonial_cite_label'),
				'default' => 'John Smith',
				'desc' => __pl('testimonial_cite_desc'),
				'edit' => '.pagelayer-testimonial-author',
				'ai' => false,
			),
			'cite_color' => array(
				'type' => 'color',
				'label' => __pl('testimonial_name_color_label'),
				'default' => '#426870',
				'css' => ['{{element}}  .pagelayer-testimonial-author ' => 'color:{{val}}'],
			),
			'cite_style' => array(
				'type' => 'typography',
				'label' => __pl('cite_style'),
				'default' => ',20,,100,,none,,,,,',
				'css' => ['{{element}} .pagelayer-testimonial-author' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'],			
			),			
			'cite_url' => array(
				'type' => 'link',
				'label' => __pl('testimonial_url_label'),
				'selector' => '.pagelayer-ele-link',
				'desc' => __pl('testimonial_url_desc'),
			),
			'cite_spacing' => array(
				'type' => 'padding',
				'label' => __pl('cite_spacing'),
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-testimonial-cite' => 'margin-top: {{val[0]}}px; margin-right: {{val[1]}}px; margin-bottom: {{val[2]}}px; margin-left: {{val[3]}}px'],
			),
		],
		'designation_style' => [
			'designation' => array(
				'type' => 'text',
				'label' => __pl('testimonial_designation_label'),
				'default' => 'Web Developer',
				'desc' => __pl('testimonial_cite_title_size_desc'),
				'edit' => '.pagelayer-testimonial-author-title',
			),
			'designation_color' => array(
				'type' => 'color',
				'label' => __pl('testimonial_title_color_label'),
				'default' => '#9cafc0',
				'css' => ['{{element}} .pagelayer-testimonial-author-title' => 'color:{{val}}'],
			),
			'cite_designation_style' => array(
				'type' => 'typography',
				'label' => __pl('cite_designation_style'),
				'default' => ',16,,100,,,,,,,',
				'css' => ['{{element}} .pagelayer-testimonial-author-title' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'],			
			),
		],
		'styles' => [
			'avatar_style' => __pl('avatar_style'),
			'cite_style' => __pl('cite'),
			'designation_style' => __pl('designation'),
			'content_style' => __pl('content_style'),
		],

	)
);

// Progress object - Make a group
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_progress', array(
		'name' => __pl('Progress Bars'),
		'group' => 'other',
		'innerHTML' => 'progress_text',
		'html' =>'<div if="{{title}}" class="pagelayer-progress-title">{{title}}</div>
			<div if="{{progress_pre_suf}}" class="pagelayer-progress-goal">
				<div if="{{prefix}}" class="pagelayer-progress-prefix">{{prefix}}</div>
				<div if="{{suffix}}" class="pagelayer-progress-suffix">{{suffix}}</div>
			</div>
			<div class="pagelayer-progress-container">					
				<div if="{{progress_percentage}}" class="pagelayer-progress-bar pagelayer-progress-{{progress_type}}" style="width:{{progress_percentage}}%;">
					<span if="{{progress_text}}" class="pagelayer-progress-text">{{progress_text}}</span>
					<span if="{{progress_percentage}}" class="pagelayer-progress-percent"></span>
				</div>					
			</div>',
		'params' => array(
			'progress_type' => array(
				'type' => 'select',
				'label' => __pl('progress_type'),
				'default' => 'primary',
				'list' => [
					'primary' => __pl('Primary'),
					'secondary' => __pl('Secondary'),
					'success' => __pl('Success'),
					'warning' => __pl('Warning'),
					'danger' => __pl('Danger'),
					'' => __pl('custom')
				],
			),
			'progress_color' => array(
				'type' => 'color',
				'label' => __pl('progress_bar_color'),
				'default' => '#0986c0',
				'css' => ['{{element}} .pagelayer-progress-bar' => 'background-color:{{val}};'],
				'req' => ['progress_type' => '']
			),
			'progress_bg_color' => array(
				'type' => 'color',
				'label' => __pl('bg_color'),
				'css' => ['{{element}} .pagelayer-progress-container' => 'background-color:{{val}};'],
				'req' => ['progress_type' => '']
			),
			'progress_height' => array(
				'type' => 'slider',
				'label' => __pl('progress_height'),
				'min' => 0,
				'max' => 100,
				'step' => 1,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-progress-bar' => 'height:{{val}}px;',
					'{{element}} .pagelayer-progress-percent' => 'line-height:{{val}}px; font-size: calc({{val}}px / 2);',
					'{{element}} .pagelayer-progress-text' => 'line-height:{{val}}px; font-size: calc({{val}}px / 2);',
				],
				'default' => 40,
			),
			'progress_radius' => array(
				'type' => 'padding',
				'label' => __pl('radius'),
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-progress-bar, {{element}} .pagelayer-progress-container' => 'border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px; -webkit-border-radius:  {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px;-moz-border-radius: {{val[0]}}px {{val[1]}}px {{val[2]}}px {{val[3]}}px;'],
			),
			'progress_border_type' => array(
				'type' => 'select',
				'label' => __pl('border_type'),
				'css' => ['{{element}} .pagelayer-progress-container' => 'border-style: {{val}}'],
				'list' => [
					'' => __pl('none'),
					'solid' => __pl('solid'),
					'double' => __pl('double'),
					'dotted' => __pl('dotted'),
					'dashed' => __pl('dashed'),
					'groove' => __pl('groove'),
				],
			),
			'progress_border_color' => array(
				'type' => 'color',
				'label' => __pl('border_color_label'),
				'default' => '#42414f',
				'css' => ['{{element}} .pagelayer-progress-container' => 'border-color: {{val}};'],
				'req' => ['!progress_border_type' => ''],
			),
			'progress_border_width' => array(
				'type' => 'padding',
				'label' => __pl('border_width'),
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-progress-container' => 'border-top-width: {{val[0]}}px; border-right-width: {{val[1]}}px; border-bottom-width: {{val[2]}}px; border-left-width: {{val[3]}}px'],
				'req' => ['!progress_border_type' => ''],
			)
		),
		// Styles
		'heading_style' => [
			'title' => array(
				'type' => 'text',
				'label' => __pl('progress_title'),
				'default' => 'Progress',
				'edit' => '.pagelayer-progress-title',
			),
			'title_color' => array(
				'type' => 'color',
				'label' => __pl('title_color'),
				'default' => '#768589',
				'css' => ['{{element}} .pagelayer-progress-title' => 'color:{{val}};'],
			),
			'title_align' => array(
				'type' => 'radio',
				'label' => __pl('alignment'),
				'css' => ['{{element}} .pagelayer-progress-title' => 'text-align: {{val}}'],
				'screen' => 1,
				'list' => array(
					'left' => 'Left',
					'center' => 'Center',
					'right' => 'Right'
				),				
			),
			'title_style' => array(
				'type' => 'typography',
				'label' => __pl('title_size'),
				'default' => ',25,,100,,,,,,,',
				'css' => ['{{element}} .pagelayer-progress-title' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'],
			),
		],
		'percentage_style' => [
			'progress_text'=> array(
				'type' => 'text',
				'label' => __pl('progress_text'),
				'default' => 'Designing',
				'edit' => '.pagelayer-progress-text',
			),
			'progress_text_color' => array(
				'type' => 'color',
				'label' => __pl('progress_text_color'),
				'default' => '#ffffff',
				'css' => ['{{element}} .pagelayer-progress-text' => 'color:{{val}};'],
			),
			'progress_percentage' => array(
				'type' => 'slider',
				'label' => __pl('percentage'),
				'min' => 0,
				'max' => 100,
				'css' => ['{{element}} .pagelayer-progress-container > .pagelayer-progress-bar:after' => 'width:{{val}}%;',],
				'addAttr' => ['{{element}} .pagelayer-progress-bar' => 'pagelayer-progress-width="{{progress_percentage}}"'],
				'default' => 75,
			),
			'progress_percent_color' => array(
				'type' => 'color',
				'label' => __pl('progress_percent_color'),
				'default' => '#ffffff',
				'css' => ['{{element}} .pagelayer-progress-percent' => 'color:{{val}};'],
			),
			'hide_percentage' => array(
				'type' => 'checkbox',
				'label' => __pl('hide_percentage'),
				'screen' => 1,
				'default' => '',
				'css' => ['{{element}} .pagelayer-progress-percent' => 'display: none;']
			),
		],
		'progress_prefix_suffix' =>[
			'progress_pre_suf' => array(
				'type' => 'checkbox',
				'label' => __pl('prefix_suffix'),
			),
			'prefix' => array(
				'type' => 'text',
				'label' => __pl('prefix_name'),
				'default' => 'Reached: $1000',
				'edit' => '.pagelayer-progress-prefix',
				'req' => ['progress_pre_suf' => 'true'],
			),
			'suffix' => array(
				'type' => 'text',
				'label' => __pl('suffix_name'),
				'default' => 'Goal: $5000',
				'edit' => '.pagelayer-progress-suffix',
				'req' => ['progress_pre_suf' => 'true'],
			),
			'prefix_suffix_color' => array(
				'type' => 'color',
				'label' => __pl('color'),
				'default' => '#444444',
				'css' => ['{{element}} .pagelayer-progress-prefix, {{element}} .pagelayer-progress-suffix' => 'color:{{val}};'],
				'req' => ['progress_pre_suf' => 'true'],
			)
		],
		'styles' => [
			'heading_style' => __pl('heading_style'),
			'percentage_style' => __pl('percentage'),
			'progress_prefix_suffix' => __pl('prefix_suffix'),
		]
	)
);

// Color Block
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_block', array(
		'name' => __pl('Color Block'),
		'group' => 'other',
		'params' => array(
			'block_color' => array(
				'type' => 'color',
				'label' => __pl('block_color'),
				'default' => '#CCC',
				'css' => ['{{element}}' => 'background:{{val}}'],
			),
			'block_height' => array(
				'type' => 'spinner',
				'label' => __pl('block_height'),
				'default' => '200',
				'screen' => 1,
				'min' => 1,
				'max' => 1000,
				'step' => 1,
				'css' => ['{{element}}' => 'height:{{val}}px'],
			),
		)
	)
);

// Alert
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_alert', array(
		'name' => __pl('Alert'),
		'group' => 'other',
		'innerHTML' => 'alert_content',
		'html' => '<div class="pagelayer-alert-content">
				<i if="{{alert_icon}}" class="pagelayer-alert-icon {{alert_icon}}"></i>
				<div if="{{alert_title}}" class="pagelayer-alert-title">{{alert_title}}</div>
				<div if="{{is_dismissible}}" class="pagelayer-alert-close" onclick="pagelayer_dismiss_alert(event.target);"></div>
			</div>
			<span if="{{alert_content}}" class="pagelayer-alert-text">{{alert_content}}</span>',
		'params' => array(
			'alert_type' => array(
				'type' => 'select',
				'label' => __pl('Type'),
				'default' => 'alert-primary',
				'addClass' => 'pagelayer-{{val}}',
				'list' => array(
					'alert-primary' => __pl('alert_type_primary'),
					'alert-secondary' => __pl('alert_type_secondary'),
					'alert-success' => __pl('alert_type_success'),
					'alert-info' => __pl('alert_type_info'),
					'alert-warning' => __pl('alert_type_warning'),
					'alert-danger' => __pl('alert_type_danger'),
					'alert-dark' => __pl('alert_type_dark'),
					'alert-custom' => __pl('alert_type_custom'),
				)
			),
			'alert_bg_color' => array(
				'type' => 'color',
				'label' => __pl('alert_bg_color'),
				'css' => 'background-color: {{val}}',
				'req' => ['alert_type' => 'alert-custom']
			),
			'is_dismissible' => array(
				'type' => 'checkbox',
				'label' => __pl('is_dismissible'),
				'default' => 'true',
				'addClass' => 'pagelayer-alert-dismissible'
			)
		),
		'icon_style' => [
			'alert_icon' => array(
				'type' => 'icon',
				'label' => __pl('alert_icon'),
				'default' => 'fas fa-exclamation',
			),
			'alert_icon_color' => array(
				'type' => 'color',
				'label' => __pl('alert_icon_color'),
				'css' => ['{{element}} .pagelayer-alert-icon' => 'color: {{val}}'],
			),
			'alert_font_size' => array(
				'label' => __pl('alert_font_size'),
				'type' => 'slider',
				'min' => 0,
				'max' => 500,
				'default' => 20,
				'screen' => 1,
				'css' => ['{{element}}  .pagelayer-alert-icon' => 'font-size:{{val}}px;'],
			),
			'alert_icon_spacing' => array(
				'label' => __pl('alert_icon_spacing'),
				'type' => 'slider',
				'min' => 0,
				'max' => 200,
				'default' => 5,
				'screen' => 1,
				'css' => ['{{element}}  .pagelayer-alert-icon' => 'margin-right:{{val}}px;'],
			),
		],
		'title_style' => [
			'alert_title' => array(
				'type' => 'text',
				'label' => __pl('alert_title'),
				'default' => 'This is an Alert',
				'edit' => '.pagelayer-alert-title',
			),
			'alert_title_color' => array(
				'type' => 'color',
				'label' => __pl('alert_title_color'),
				'default' => '',
				'css' => ['{{element}}  .pagelayer-alert-title' => 'color:{{val}}'],
			),
			'title_typo' => array(
				'type' => 'typography',
				'label' => __pl('title_typo'),
				'default' => ',22,,600,,,,,,,',
				'css' => ['{{element}} .pagelayer-alert-title' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'],
			),
		],
		'content_style' => [
			'alert_content' => array(
				'type' => 'textarea',
				'label' => __pl('alert_content'),
				'default' => 'Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet, Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet.',
				'edit' => '.pagelayer-alert-text',
			),
			'alert_content_color' => array(
				'type' => 'color',
				'label' => __pl('alert_content_color'),
				'default' => '',
				'css' => ['{{element}} .pagelayer-alert-text' => 'color:{{val}}',
					'{{element}} .pagelayer-alert-text *' => 'color:{{val}}'],
				'req' => ['!alert_content' => ''],
			),
			'content_typo' => array(
				'type' => 'typography',
				'label' => __pl('title_typo'),
				'default' => ',13,,,,,,,,,',
				'css' => ['{{element}} .pagelayer-alert-text' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'],
			),
		],
		'styles' => [
			'icon_style' => __pl('icon'),
			'title_style' => __pl('title_style'),
			'content_style' => __pl('content_style'),
		],
	)
);

// Anchor
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_anchor', array(
		'name' => __pl('Anchor'),
		'group' => 'other',
		'html' => '<div id="{{title}}" class="pagelayer-anchor-holder"></div>',
		'params' => array(
			'title' => array(
				'type' => 'text',
				'label' => __pl('Anchor ID'),
				'desc' => __pl('Note : Please enter the name of Unique ID that you want to use as an Anchor (Without #)'),
			),
		)
	)
);

// Star object
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_stars', array(
		'name' => __pl('Stars'),
		'group' => 'other',
		'html' => '<span if="{{rating_title}}" class="pagelayer-stars-title">{{rating_title}}</span>
					<div class="pagelayer-stars-container" title="{{number_of_ratings}}/{{number_of_stars}}" pagelayer-stars-value="{{number_of_ratings}}" pagelayer-stars-count="{{number_of_stars}}">					
					</div>',
		'params' => array(
			'number_of_stars' => array(
				'type' => 'spinner',
				'label' => __pl('stars_count'),
				'min' => 0,
				'max' => 10,
				'step' => 1,
				'default' => 5,
			),
			'number_of_ratings' => array(
				'type' => 'spinner',
				'label' => __pl('stars_rating'),
				'min' => 0,
				'max' => 10,
				'step' => .1,
				'default' => 2.5,				
			),
			'ratings_align' => array(
				'type' => 'radio',
				'label' => __pl('alignment'),
				'css' => ['{{element}}' => 'text-align: {{val}}'],
				'screen' => 1,
				'list' => array(
					'left' => 'Left',
					'center' => 'Center',
					'right' => 'Right'
				),				
			),								
		),
		'title_style' => [
			'rating_title' => array(
				'type' => 'text',
				'label' => __pl('rating_title'),
				'default' => 'Rate us',
				'edit' => '.pagelayer-stars-title',
			),
			'title_color' => array(
				'type' => 'color',
				'label' => __pl('title_color'),
				'default' => '#0986c0',
				'css' => ['{{element}} .pagelayer-stars-title' => 'color: {{val}}'],
			),
			'title_style' => array(
				'type' => 'typography',
				'label' => __pl('counter_number_size'),
				'default' => ',25,,600,,,solid,,,,',
				'css' => ['{{element}} .pagelayer-stars-title' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'],					
			),
		],
		'stars_style' => [
			'stars_color' => array(
				'type' => 'color',
				'label' => __pl('stars_color'),
				'default' => '#0986c0',
				'css' => ['{{element}} .pagelayer-stars-icon:before' => 'color: {{val}}'],
			),
			'unmarked_stars_color' => array(
				'type' => 'color',
				'label' => __pl('unmarked_star_color'),
				'default' => '#ccd6df',
				'css' => ['{{element}} .pagelayer-stars-container' => 'color: {{val}}'],
			),
			'stars_font_size' => array(
				'label' => __pl('stars_font_size'),
				'type' => 'slider',
				'min' => 0,
				'max' => 100,
				'default' => 30,
				'screen' => 1,
				'css' => ['{{element}}  .pagelayer-stars-container' => 'font-size:{{val}}px;'],
			),
			'stars_spacing' => array(
				'label' => __pl('stars_spacing'),
				'type' => 'slider',
				'min' => 0,
				'max' => 100,
				'default' => 10,
				'screen' => 1,
				'css' => ['{{element}}  .pagelayer-stars-icon' => 'margin-left:{{val}}px;'],
			),
		],		
		'styles' => [
			'title_style' => __pl('title'),
			'stars_style' => __pl('stars_style'),
		],		
	)
);

// Divider
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_divider', array(
		'name' => __pl('Divider'),
		'group' => 'other',
		'html' => '<div class="pagelayer-divider-holder">
			<span class="pagelayer-divider-seperator"></span>
		</div>',
		'params' => array(
			'divider_style' => array(
				'type' => 'select',
				'label' => __pl('divider_border_type'),
				'css' => ['{{element}} .pagelayer-divider-seperator' =>'border-top-style: {{val}};'],
				'default' => 'solid',
				'list' => [
					'solid' => __pl('solid'),
					'double' => __pl('double'),
					'dotted' => __pl('dotted'),
					'dashed' => __pl('dashed'),
					'groove' => __pl('groove'),
				],
			),
			'divider_color' => array(
				'type' => 'color',
				'label' => __pl('divider_color'),
				'default' => '#999',
				'css' => ['{{element}} .pagelayer-divider-seperator' => 'border-top-color: {{val}};'],
			),
			'divider_weight' => array(
				'type' => 'slider',
				'label' => __pl('divider_border_weight'),
				'min' => 1,
				'max' => 30,
				'default' => 1,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-divider-seperator' =>'border-top-width: {{val}}px;'],
			),
			'divider_widht' => array(
				'type' => 'slider',
				'label' => __pl('divider_border_width'),
				'min' => 1,
				'max' => 100,
				'default' => 100,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-divider-seperator' =>'width: {{val}}%;'],
			),
			'divider_gap' => array(
				'type' => 'slider',
				'label' => __pl('divider_gap'),
				'min' => 1,
				'max' => 100,
				'default' => 10,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-divider-holder' =>'padding-top: {{val}}px; padding-bottom: {{val}}px;'],
			),
			'divider_alignment' => array(
				'type' => 'radio',
				'label' => __pl('divider_alignment'),
				'default' => 'center',
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-divider-holder' => 'text-align: {{val}};'],
				'list' => array(
					'left' => __pl('left'),
					'center' => __pl('center'),
					'right' => __pl('right'),
				)
			),
		),
	)
);

// Counter
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_counter', array(
		'name' => __pl('Counter'),
		'group' => 'other',
		'html' => '<div class="pagelayer-counter-holder">
			<div if="{{counter_start_number}}" class="pagelayer-counter-content">
				<span if="{{number_prefix}}">{{number_prefix}}</span><span class="pagelayer-counter-display">{{counter_start_number}}</span><span if="{{number_suffix}}">{{number_suffix}}</span>
			</div>
			<span if="{{counter_text}}" class="pagelayer-counter-info">{{counter_text}}</span>
		</div>',
		'params' => array(
			'counter_start_number' => array(
				'type' => 'spinner',
				'label' => __pl('starting_number'),
				'min' => '0',
				'default' => '1',
				'addAttr' => ['{{element}} .pagelayer-counter-display' => 'pagelayer-counter-initial-value="{{counter_start_number}}"'],
			),
			'counter_end_number' => array(
				'type' => 'spinner',
				'label' => __pl('Ending_number'),
				'min' => '0',
				'default' => '200',
				'addAttr' => ['{{element}} .pagelayer-counter-display' => 'pagelayer-counter-last-value="{{counter_end_number}}"'],	
			),
			'animation_duration' => array(
				'type' => 'spinner',
				'label' => __pl('counter_animation_duration'),
				'min' => '500',
				'max' => '500000',
				'default' =>'2000',
				'addAttr' => ['{{element}} .pagelayer-counter-display' => 'pagelayer-counter-animation-duration="{{animation_duration}}"'],
			),
			'counter_align' => array(
				'type' => 'radio',
				'label' => __pl('counter_align'),
				'default' => 'center',
				'css' => 'text-align: {{val}};',
				'screen' => 1,
				'list' => [
					'left' => __pl('left'),
					'center' => __pl('center'),
					'right' => __pl('right'),
				]			
			),
		),
		// Styles
		'counter_style' => [
			'counter_number_color' => array(
				'type' => 'color',
				'label' => __pl('counter_number_color_label'),
				'default' => '#0986c0',
				'css' => ['{{element}} .pagelayer-counter-content' => 'color:{{val}};'],
			),
			'number_prefix' => array(
				'type' => 'text',
				'label' => __pl('number_prefix'),
			),
			'number_suffix' => array(
				'type' => 'text',
				'label' => __pl('number_suffix'),
			),
			'thousand_seperator' => array(
				'type' => 'checkbox',
				'label' => __pl('thousand_seperator'),
				'addAttr' => ['{{element}} .pagelayer-counter-display' => 'pagelayer-counter-seperator="{{thousand_seperator}}"'],
			),
			'thousand_seperator_type' => array(
				'type' => 'select',
				'label' => __pl('thousand_seperator_type'),
				'default' => ',',
				'list' => [
					',' => __pl('Default'),
					'.' => __pl('Dot'),
					'&nbsp;' => __pl('Space'),
				],
				'addAttr' => ['{{element}} .pagelayer-counter-display' => 'pagelayer-counter-seperator-type="{{thousand_seperator_type}}"'],
				'req' => array(
					'thousand_seperator' => 'true',
				),
			),
			'counter_number_style' => array(
				'type' => 'typography',
				'label' => __pl('counter_number_size'),
				'default' => ',60,,600,,,solid,,,,',
				'css' => ['{{element}} .pagelayer-counter-content' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'],					
			),
		],
		'counter_label_style' => [
			'counter_text' => array(
				'type' => 'text',
				'label' => __pl('counter_text'),
				'default' => 'Counter',
				'edit' => '.pagelayer-counter-info'
			),
			'counter_text_color' => array(
				'type' => 'color',
				'label' => __pl('counter_text_color_label'),
				'default' => '#333333',
				'css' => ['{{element}} .pagelayer-counter-info' => 'color:{{val}};'],
			),
			'counter_text_style' => array(
				'type' => 'typography',
				'label' => __pl('counter_text_style'),
				'default' => ',25,,400,,,solid,,,,',
				'css' => ['{{element}} .pagelayer-counter-info' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'],					
			),			
		],		
		'styles' => [
			'counter_label_style' => __pl('counter_label_style'),
			'counter_style' => __pl('counter_style'),
		],
	)			
);

// Address
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_address', array(
		'name' => __pl('address'),
		'group' => 'other',
		'icon' => 'fas fa-map-marker-alt',
		'html' => '<div class="pagelayer-address-holder">
			<span class="pagelayer-address-icon"><i class="{{icon}}"></i></span>
			<span class="pagelayer-address">'.pagelayer_get_option('pagelayer-address').'</span>
		</div>',
		'params' => array(
			'color' => array(
				'type' => 'color',
				'label' => __pl('color'),
				'css' => ['{{element}} .pagelayer-address *, {{element}} .pagelayer-address' => 'color:{{val}}'],
				'desc' => __pl('CMA_desc')
			),
			'typography' => array(
				'type' => 'typography',
				'label' => __pl('typography'),
				'css' => ['{{element}} .pagelayer-address *, {{element}} .pagelayer-address' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'],
			),
			'align' => array(
				'type' => 'radio',
				'label' => __pl('alignment'),
				'screen' => 1,
				'list' => [
					'flex-start' => __pl('left'),
					'center' => __pl('center'),
					'flex-end' => __pl('right'),
				],
				'css' => ['{{element}} .pagelayer-address-holder' => 'justify-content: {{val}}'],
			),
			'space' => array(
				'type' => 'slider',
				'label' => __pl('space'),
				'min' => 0,
				'max' => 100,
				'step' => 1,
				'screen' => 1,
				'css' => ['body:not(.rtl) {{element}} .pagelayer-address-icon' => 'margin-right: {{val}}px;', 'body.rtl {{element}} .pagelayer-address-icon' => 'margin-left:{{val}}px']
			),
		),
		'icon_style' =>[
			'icon' => array(
				'type' => 'icon',
				'label' => __pl('icon'),
				'default' => 'fas fa-map-marker-alt'
			),
			'icon_color' => array(
				'type' => 'color',
				'label' => __pl('color'),
				'css' => ['{{element}} .pagelayer-address-icon i' => 'color:{{val}}'],
			),
			'icon_size' => array(
				'type' => 'slider',
				'label' => __pl('size'),
				'min' => 0,
				'max' => 100,
				'step' => 1,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-address-icon i' => 'font-size: {{val}}px;']
			),
		],
		'styles' => [
			'icon_style' => __pl('icon_style')
		]
	)
);

// Email
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_email', array(
		'name' => __pl('email'),
		'group' => 'other',
		'icon' => 'fas fa-envelope',
		'html' => '<div class="pagelayer-email-holder">
			<span class="pagelayer-email-icon"><i class="{{icon}}"></i></span>
			<a if-ext="{{linked}}" href="mailto:'.pagelayer_get_option('pagelayer_cf_to_email').'">
				<span class="pagelayer-email">'.pagelayer_get_option('pagelayer_cf_to_email').'</span></div>
			</a>
			</div>',
		'params' => array(
			'linked' => array(
				'type' => 'checkbox',
				'label' => __pl('make_link'),
				'desc' => __pl('email_desc')
			),
			'color' => array(
				'type' => 'color',
				'label' => __pl('color'),
				'css' => ['{{element}} .pagelayer-email *, {{element}} .pagelayer-email' => 'color:{{val}}'],
			),
			'typography' => array(
				'type' => 'typography',
				'label' => __pl('typography'),
				'css' => ['{{element}} .pagelayer-email *, {{element}} .pagelayer-email' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'],
			),
			'align' => array(
				'type' => 'radio',
				'label' => __pl('alignment'),
				'screen' => 1,
				'list' => [
					'flex-start' => __pl('left'),
					'center' => __pl('center'),
					'flex-end' => __pl('right'),
				],
				'css' => ['{{element}} .pagelayer-email-holder' => 'justify-content: {{val}}'],
			),
			'space' => array(
				'type' => 'slider',
				'label' => __pl('space'),
				'min' => 0,
				'max' => 100,
				'step' => 1,
				'screen' => 1,
				'css' => ['body:not(.rtl) {{element}} .pagelayer-email-icon' => 'margin-right: {{val}}px;', 'body.rtl {{element}} .pagelayer-email-icon' => 'margin-left:{{val}}px']
			),
		),
		'icon_style' =>[
			'icon' => array(
				'type' => 'icon',
				'label' => __pl('icon'),
				'default' => 'fas fa-envelope'
			),
			'icon_color' => array(
				'type' => 'color',
				'label' => __pl('color'),
				'css' => ['{{element}} .pagelayer-email-icon i' => 'color:{{val}}'],
			),
			'icon_size' => array(
				'type' => 'slider',
				'label' => __pl('size'),
				'min' => 0,
				'max' => 100,
				'step' => 1,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-email-icon i' => 'font-size: {{val}}px;']
			),
		],
		'styles' => [
			'icon_style' => __pl('icon_style')
		]
	)
);

// Phone
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_phone', array(
		'name' => __pl('phone'),
		'group' => 'other',
		'icon' => 'fas fa-phone-alt',
		'html' => '<div class="pagelayer-phone-holder">
			<span class="pagelayer-phone-icon"><i class="{{icon}}"></i></span>
			<a if-ext="{{linked}}" href="tel:'.pagelayer_get_option('pagelayer-phone').'">
				<span class="pagelayer-phone">'.pagelayer_get_option('pagelayer-phone').'</span>
			</a>
			</div>',
		'params' => array(
			'linked' => array(
				'type' => 'checkbox',
				'label' => __pl('make_link'),
				'desc' => __pl('CMA_desc')
			),
			'color' => array(
				'type' => 'color',
				'label' => __pl('color'),
				'css' => ['{{element}} .pagelayer-phone *, {{element}} .pagelayer-phone' => 'color:{{val}}'],
			),
			'typography' => array(
				'type' => 'typography',
				'label' => __pl('typography'),
				'css' => ['{{element}} .pagelayer-phone *, {{element}} .pagelayer-phone' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px !important; font-style: {{val[2]}} !important; font-weight: {{val[3]}} !important; font-variant: {{val[4]}} !important; text-decoration-line: {{val[5]}} !important; text-decoration-style: {{val[6]}} !important; line-height: {{val[7]}}em !important; text-transform: {{val[8]}} !important; letter-spacing: {{val[9]}}px !important; word-spacing: {{val[10]}}px !important;'],
			),
			'align' => array(
				'type' => 'radio',
				'label' => __pl('alignment'),
				'screen' => 1,
				'list' => [
					'flex-start' => __pl('left'),
					'center' => __pl('center'),
					'flex-end' => __pl('right'),
				],
				'css' => ['{{element}} .pagelayer-phone-holder' => 'justify-content: {{val}}'],
			),
			'space' => array(
				'type' => 'slider',
				'label' => __pl('space'),
				'min' => 0,
				'max' => 100,
				'step' => 1,
				'screen' => 1,
				'css' => ['body:not(.rtl) {{element}} .pagelayer-phone-icon' => 'margin-right: {{val}}px;', 'body.rtl {{element}} .pagelayer-phone-icon' => 'margin-left:{{val}}px']
			),
		),
		'icon_style' =>[
			'icon' => array(
				'type' => 'icon',
				'label' => __pl('icon'),
				'default' => 'fas fa-phone-alt'
			),
			'icon_color' => array(
				'type' => 'color',
				'label' => __pl('color'),
				'css' => ['{{element}} .pagelayer-phone-icon i' => 'color:{{val}}'],
			),
			'icon_size' => array(
				'type' => 'slider',
				'label' => __pl('size'),
				'min' => 0,
				'max' => 100,
				'step' => 1,
				'screen' => 1,
				'css' => ['{{element}} .pagelayer-phone-icon i' => 'font-size: {{val}}px;']
			),
		],
		'styles' => [
			'icon_style' => __pl('icon_style')
		]
	)
);

// Body Settings
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_post_props', array(
		'name' => __pl('Body and Post Props'),
		'group' => 'other',
		'not_visible' => 1,
		'parent' => [], // To hide on left panel block list
		'overide_css_selector' => pagelayer_is_gutenberg_editor() ? '{{element}}' : 'body', // To prevent apply style in gutenberg, we use .pagelayer-body class, that is not exists in gutenberg edit.
		'hide_active' => 1,
		'skip_props_cat_type' => ['product' => ['custom_hf_code']],
		'skip_props_cat' => ['position_styles', 'animation_styles', 'responsive_styles', 'motion_effects'],
		'skip_props' => ['ele_zindex',
						'ele_shadow', 'border_shadow_hover',
						'hide_desktop',	'hide_tablet', 'hide_mobile'],
		'params' => array(
			'post_title' => array(
				'type' => 'text',
				'label' => __pl('post_title'),
				'default' => (empty($post->post_title) ? 'No Title' : $post->post_title),
				'export-def' => 1,
			),
			'post_status' => array(
				'type' => 'select',
				'label' => __pl('visibility'),
				'default' => (empty($post->post_status) ? 'draft' : $post->post_status),
				'export-def' => 1,
				'list' => [
					'publish' => __pl('Published'),
					'future' => __pl('Scheduled'),
					'private' => __pl('private'),
					'pass_protected' => __pl('password_protected'),
					'draft' => __pl('Draft')
				],
			),
			'post_password' => array(
				'type' => 'text',
				'label' => __pl('password'),
				'export-def' => 1,
				'req' => ['post_status' => 'pass_protected']
			),
			'post_date' => array(
				'type' => 'postDate',
				'label' => __pl('publish_date'),
				'default' => (empty($post->post_date) ? current_time( 'mysql' ) : $post->post_date),
				'export-def' => 1,
			),
			'post_sticky' => array(
				'type' => 'checkbox',
				'label' => __pl('sticky_post'),
				'default' => (!empty($post->ID) && is_sticky($post->ID) ? 'true' : ''),
				'export-def' => 1,
			),
			'post_author' => array(
				'type' => 'select',
				'label' => __pl('author'),
				'default' => (empty($post->post_author) ? 0 : $post->post_author),
				'list' => [],
				'export-def' => 1,
			),
			'post_trash' => array(
				'type' => 'trashButton',
				'label' => '',
			),
		),
		'postPermalink' => array(
			'post_name' => array(
				'type' => 'permalink',
				'label' => __pl('url_slug'),
				'desc' => __pl('perma_desc'),
				'default' => (empty($post->post_name) ? '' : $post->post_name),
				'export-def' => 1,
			),
		),
		'postCategory' => array(
			'post_category' => array(
				'type' => 'postCategory',
				'label' => ''
			)
		), 
		'postTags' => array(
			'post_tags' => array(
				'type' => 'postTags',
				'label' => __pl('add_new_tag'),
				'desc' => __pl('post_tag_desc')
			)
		),
		'postFeaturedImage' => array(
			'featured_image' => array(
				'type' => 'image',
				'label' => '',
				'default' => ( get_post_thumbnail_id($post) ? get_post_thumbnail_id($post) : PAGELAYER_URL.'/images/default-image.png' ),
				'export-def' => 1,
			),
		),
		'postExcerpt' => array(
			'post_excerpt' => array(
				'type' => 'textarea',
				'default' => ( empty($post->post_excerpt) ? '' : $post->post_excerpt),
				'export-def' => 1,
				'label' => __pl('write_an_excerpt'),
			)
		),
		'postDiscussion' => array(
			'comment_status' => array(
				'type' => 'checkbox',
				'label' => __pl('allow_comments'),
			),
			'ping_status' => array(
				'type' => 'checkbox',
				'label' => __pl('allow_p_and_t'),
			)
		),
		'pageParent' => array(			
			'post_parent' => array(
				'type' => 'select',
				'label' => __pl('post_parent'),
				'list' =>  []
			),
			'menu_order' => array(
				'type' => 'spinner',
				'label' => __pl('order'),
			)
		),
		'styles' => array(
			'params' => __pl('status_visibility'),
			'postPermalink' => __pl('post_name'),
			'postCategory' => __pl('wp_categories'),
			'postTags' => __pl('tags'),
			'postFeaturedImage' => __pl('featured_image'),
			'postExcerpt' => __pl('excerpt'),
			'postDiscussion' => __pl('discussion'),
			'pageParent' => __pl('page_attributes'),
		),
	)			
);
/*
$pagelayer->customizer_styles_options = array(
'params' => __pl('Site Identity'),
'breakpoint' => __pl('BreakPoints'),
'global' => __pl('Global Settings'),
'post_global' => __pl('Current Post Type Settings'),
'global_background' => __pl('Global Background'),
'global_button' => __pl('Global Buttons Style'),
);

if(class_exists('WooCommerce')){
	$pagelayer->customizer_styles_options['woocommerce'] = __pl('woocommerce');
}

// Customizer Settings
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_customizer', array(
		'name' => __pl('Customizer'),
		'group' => 'other',
		'overide_css_selector' => 'body',
		'hide_active' => 1,
		'skip_save' => 1,
		'skip_props_cat_type' => ['product' => ['custom_hf_code']],
		'skip_props_cat' => ['ele_bg_styles','ele_styles','border_styles','font_style','animation_styles','motion_effects','responsive_styles','attributes','custom_styles','position_styles', 'animation_styles', 'responsive_styles', 'motion_effects'],
		'skip_props' => ['ele_zindex', 'font_family', 'ele_shadow', 'border_shadow_hover', 'hide_desktop',	'hide_tablet', 'hide_mobile'],
		'params' => array(
			'site_name' => array(
				'type' => 'text',
				'label' => __pl('Site Name'),
				'option' => 'blogname',
			),
			'site_description' => array(
				'type' => 'text',
				'label' => __pl('Site Description'),
				'option' => 'blogdescription',
			),
			'site_logo' => array(
				'type' => 'image',
				'label' => __pl('Site Logo'),
				'option' => 'site_logo',
			),
			'site_icon' => array(
				'type' => 'image',
				'label' => __pl('Site Fav Icon'),
				'option' => 'site_icon',
			),
		),
		'breakpoint' => array(
			'content_width' => array(
				'type' => 'slider',
				'label' => __pl('Content Width'),
				'option' => 'pagelayer_content_width',
				'min' => 320,
				'max' => 2000,
				'css' =>['.pagelayer-row-stretch-auto > .pagelayer-row-holder'=>'max-width:{{val}}px;margin-left:auto;margin-right:auto'],
			),
			'widgets_space' => array(
				'type' => 'slider',
				'label' => __pl('Widgets Space'),
				'option' => 'pagelayer_between_widgets',
				'min' => 0,
				'max' => 2000,
			),
			'mobile_breakpoint' => array(
				'type' => 'slider',
				'label' => __pl('Mobile Breakpoint'),
				'option' => 'pagelayer_mobile_breakpoint',
				'min' => 0,
				'max' => 2000,
			),
			'tablet_breakpoint' => array(
				'type' => 'slider',
				'label' => __pl('Tablet Breakpoint'),
				'option' => 'pagelayer_tablet_breakpoint',
				'min' => 0,
				'max' => 2000,
			),
		),
		'global' => array(
			'ele_body_group' => array(
				'type' => 'access',
				'label' => __pl('Body Settings'),
				'show_group' => 'body_group',
			),
			'ele_header_group' => array(
				'type' => 'access',
				'label' => __pl('Header Settings'),
				'show_group' => 'header_group',
			),
			'ele_h1_group' => array(
				'type' => 'access',
				'label' => __pl('H1 Settings'),
				'show_group' => 'h1_group',
			),
			'ele_h2_group' => array(
				'type' => 'access',
				'label' => __pl('H2 Settings'),
				'show_group' => 'h2_group',
			),
			'ele_h3_group' => array(
				'type' => 'access',
				'label' => __pl('H3 Settings'),
				'show_group' => 'h3_group',
			),
			'ele_h4_group' => array(
				'type' => 'access',
				'label' => __pl('H4 Group'),
				'show_group' => 'h4_group',
			),
			'ele_h5_group' => array(
				'type' => 'access',
				'label' => __pl('H5 Settings'),
				'show_group' => 'h5_group',
			),
			'ele_h6_group' => array(
				'type' => 'access',
				'label' => __pl('H6 Settings'),
				'show_group' => 'h6_group',
			),
			'ele_b_group' => array(
				'type' => 'access',
				'label' => __pl('B Settings'),
				'show_group' => 'b_group',
			),
			'ele_i_group' => array(
				'type' => 'access',
				'label' => __pl('I Settings'),
				'show_group' => 'i_group',
			),
			'ele_a_group' => array(
				'type' => 'access',
				'label' => __pl('A Settings'),
				'show_group' => 'a_group',
			),
			'ele_a_hover_group' => array(
				'type' => 'access',
				'label' => __pl('A Hover Settings'),
				'show_group' => 'a_hover_group',
			),
			'ele_aside_group' => array(
				'type' => 'access',
				'label' => __pl('Aside Settings'),
				'show_group' => 'aside_group',
			),
			'ele_p_group' => array(
				'type' => 'access',
				'label' => __pl('P Settings'),
				'show_group' => 'p_group',
			),
			'ele_entry_header_group' => array(
				'type' => 'access',
				'label' => __pl('Header Settings'),
				'show_group' => 'entry_header_group',
			),
			'ele_entry_content_group' => array(
				'type' => 'access',
				'label' => __pl('Content Settings'),
				'show_group' => 'content_group',
			),
			'ele_entry_footer_group' => array(
				'type' => 'access',
				'label' => __pl('Footer Settings'),
				'show_group' => 'footer_group',
			),
			'body' => array(
				'type' => 'typography',
				'label' => __pl('body'),
				'group' => 'body_group',
				'css' => ['body.pagelayer-body' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'header' => array(
				'type' => 'typography',
				'label' => __pl('header'),
				'group' => 'header_group',
				'css' => ['body.pagelayer-body header' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'h1' => array(
				'type' => 'typography',
				'label' => __pl('h1'),
				'group' => 'h1_group',
				'css' => ['body.pagelayer-body h1' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'h2' => array(
				'type' => 'typography',
				'label' => __pl('h2'),
				'group' => 'h2_group',
				'css' => ['body.pagelayer-body h2' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'h3' => array(
				'type' => 'typography',
				'label' => __pl('h3'),
				'group' => 'h3_group',
				'css' => ['body.pagelayer-body h3' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'h4' => array(
				'type' => 'typography',
				'label' => __pl('h4'),
				'group' => 'h4_group',
				'css' => ['body.pagelayer-body h4' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'h5' => array(
				'type' => 'typography',
				'label' => __pl('h5'),
				'group' => 'h5_group',
				'css' => ['body.pagelayer-body h5' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'h6' => array(
				'type' => 'typography',
				'label' => __pl('h6'),
				'group' => 'h6_group',
				'css' => ['body.pagelayer-body h6' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'b' => array(
				'type' => 'typography',
				'label' => __pl('b'),
				'group' => 'b_group',
				'css' => ['body.pagelayer-body b' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'i' => array(
				'type' => 'typography',
				'label' => __pl('i'),
				'group' => 'i_group',
				'css' => ['body.pagelayer-body i' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'a' => array(
				'type' => 'typography',
				'label' => __pl('a'),
				'group' => 'a_group',
				'css' => ['body.pagelayer-body a' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'a_hover' => array(
				'type' => 'typography',
				'label' => __pl('a-hover'),
				'group' => 'a_hover_group',
				'css' => ['body.pagelayer-body a:hover' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'aside' => array(
				'type' => 'typography',
				'label' => __pl('aside'),
				'group' => 'aside_group',
				'css' => ['body.pagelayer-body p' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'p' => array(
				'type' => 'typography',
				'label' => __pl('p'),
				'group' => 'p_group',
				'css' => ['body.pagelayer-body p' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'entry-header' => array(
				'type' => 'typography',
				'label' => __pl('entry-header'),
				'group' => 'entry_header_group',
				'css' => ['body.pagelayer-body .entry-header' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'entry_content' => array(
				'type' => 'typography',
				'label' => __pl('entry-content'),
				'group' => 'content_group',
				'css' => ['body.pagelayer-body .entry-content' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'entry_footer' => array(
				'type' => 'typography',
				'label' => __pl('entry-footer'),
				'group' => 'footer_group',
				'css' => ['body.pagelayer-body .entry-footer' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'body_color' => array(
				'type' => 'color',
				'screen' => 1,
				'label' => __pl('body_color'),
				'group' => 'body_group',
				'css' => ['body.pagelayer-body' => 'color:{{val}};'],
			),
			'header_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'header_group',
				'label' => __pl('header_color'),
				'css' => ['body.pagelayer-body header' => 'color:{{val}};'],
			),
			'h1_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'h1_group',
				'label' => __pl('h1_color'),
				'css' => ['body.pagelayer-body h1' => 'color:{{val}};'],
			),
			'h2_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'h2_group',
				'label' => __pl('h2_color'),
				'css' => ['body.pagelayer-body h2' => 'color:{{val}};'],
			),
			'h3_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'h3_group',
				'label' => __pl('h3_color'),
				'css' => ['body.pagelayer-body h3' => 'color:{{val}};'],
			),
			'h4_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'h4_group',
				'label' => __pl('h4_color'),
				'css' => ['body.pagelayer-body h4' => 'color:{{val}};'],
			),
			'h5_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'h5_group',
				'label' => __pl('h5_color'),
				'css' => ['body.pagelayer-body h5' => 'color:{{val}};'],
			),
			'h6_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'h6_group',
				'label' => __pl('h6_color'),
				'css' => ['body.pagelayer-body h6' => 'color:{{val}};'],
			),
			'b_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'b_group',
				'label' => __pl('b_color'),
				'css' => ['body.pagelayer-body b' => 'color:{{val}};'],
			),
			'i_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'i_group',
				'label' => __pl('i_color'),
				'css' => ['body.pagelayer-body i' => 'color:{{val}};'],
			),
			'a_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'a_group',
				'label' => __pl('a_color'),
				'css' => ['body.pagelayer-body a' => 'color:{{val}};'],
			),
			'a-hover_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'a_hover_group',
				'label' => __pl('a_hover_color'),
				'css' => ['body.pagelayer-body a:hover' => 'color:{{val}};'],
			),
			'aside_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'aside_group',
				'label' => __pl('aside_color'),
				'css' => ['body.pagelayer-body aside' => 'color:{{val}};'],
			),
			'p_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'p_group',
				'label' => __pl('p_color'),
				'css' => ['body.pagelayer-body p' => 'color:{{val}};'],
			),
			'entry-header_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'entry_header_group',
				'label' => __pl('entry_header_color'),
				'css' => ['body.pagelayer-body .entry-header' => 'color:{{val}};'],
			),
			'entry-content_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'content_group',
				'label' => __pl('entry_content_color'),
				'css' => ['body.pagelayer-body .entry-content' => 'color:{{val}};'],
			),
			'entry-footer_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'footer_group',
				'label' => __pl('entry_footer_color'),
				'css' => ['body.pagelayer-body .entry-footer' => 'color:{{val}};'],
			),
			'body_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'body_group',
				'label' => __pl('body_background_color'),
				'css' => ['body.pagelayer-body' => 'background-color:{{val}};'],
			),
			'header_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'header_group',
				'label' => __pl('header_background_color'),
				'css' => ['body.pagelayer-body header' => 'background-color:{{val}};'],
			),
			'h1_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'h1_group',
				'label' => __pl('h1_background_color'),
				'css' => ['body.pagelayer-body h1' => 'background-color:{{val}};'],
			),
			'h2_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'h2_group',
				'label' => __pl('h2_background_color'),
				'css' => ['body.pagelayer-body h2' => 'background-color:{{val}};'],
			),
			'h3_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'h3_group',
				'label' => __pl('h3_background_color'),
				'css' => ['body.pagelayer-body h3' => 'background-color:{{val}};'],
			),
			'h4_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'h4_group',
				'label' => __pl('h4_background_color'),
				'css' => ['body.pagelayer-body h4' => 'background-color:{{val}};'],
			),
			'h5_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'h5_group',
				'label' => __pl('h5_background_color'),
				'css' => ['body.pagelayer-body h5' => 'background-color:{{val}};'],
			),
			'h6_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'h6_group',
				'label' => __pl('h6_background_color'),
				'css' => ['body.pagelayer-body h6' => 'background-color:{{val}};'],
			),
			'b_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'b_group',
				'label' => __pl('b_background_color'),
				'css' => ['body.pagelayer-body b' => 'background-color:{{val}};'],
			),
			'i_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'i_group',
				'label' => __pl('i_background_color'),
				'css' => ['body.pagelayer-body i' => 'background-color:{{val}};'],
			),
			'a_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'a_group',
				'label' => __pl('a_background_color'),
				'css' => ['body.pagelayer-body a' => 'background-color:{{val}};'],
			),
			'a-hover_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'a_hover_group',
				'label' => __pl('a_hover_background_color'),
				'css' => ['body.pagelayer-body a:hover' => 'background-color:{{val}};'],
			),
			'aside_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'aside_group',
				'label' => __pl('aside_background_color'),
				'css' => ['body.pagelayer-body aside' => 'background-color:{{val}};'],
			),
			'p_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'p_group',
				'label' => __pl('p_background_color'),
				'css' => ['body.pagelayer-body p' => 'background-color:{{val}};'],
			),
			'entry-header_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'entry_header_group',
				'label' => __pl('entry_header_background_color'),
				'css' => ['body.pagelayer-body .entry-header' => 'background-color:{{val}};'],
			),
			'entry-content_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'content_group',
				'label' => __pl('entry_content_background_color'),
				'css' => ['body.pagelayer-body .entry-content' => 'background-color:{{val}};'],
			),
			'entry-footer_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'footer_group',
				'label' => __pl('entry_footer_background_color'),
				'css' => ['body.pagelayer-body .entry-footer' => 'background-color:{{val}};'],
			),
			'body_padding' => array(
				'type' => 'padding',
				'label' => __pl('body_padding'),
				'screen' => 1,
				'group' => 'body_group',
				'css' => ['body.pagelayer-body' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'body_margin' => array(
				'type' => 'padding',
				'label' => __pl('body_margin'),
				'screen' => 1,
				'group' => 'body_group',
				'css' => ['body.pagelayer-body' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),
			'header_padding' => array(
				'type' => 'padding',
				'label' => __pl('header_padding'),
				'screen' => 1,
				'group' => 'header_group',
				'css' => ['body.pagelayer-body header' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'header_margin' => array(
				'type' => 'padding',
				'label' => __pl('header_margin'),
				'screen' => 1,
				'group' => 'header_group',
				'css' => ['body.pagelayer-body header' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),
			'h1_padding' => array(
				'type' => 'padding',
				'label' => __pl('h1_padding'),
				'screen' => 1,
				'group' => 'h1_group',
				'css' => ['body.pagelayer-body h1' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'h1_margin' => array(
				'type' => 'padding',
				'label' => __pl('h1_margin'),
				'screen' => 1,
				'group' => 'h1_group',
				'css' => ['body.pagelayer-body h1' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),
			'h2_padding' => array(
				'type' => 'padding',
				'label' => __pl('h2_padding'),
				'screen' => 1,
				'group' => 'h2_group',
				'css' => ['body.pagelayer-body h2' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'h2_margin' => array(
				'type' => 'padding',
				'label' => __pl('h2_margin'),
				'screen' => 1,
				'group' => 'h2_group',
				'css' => ['body.pagelayer-body h2' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),
			'h3_padding' => array(
				'type' => 'padding',
				'label' => __pl('h3_padding'),
				'screen' => 1,
				'group' => 'h3_group',
				'css' => ['body.pagelayer-body h3' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'h3_margin' => array(
				'type' => 'padding',
				'label' => __pl('h3_margin'),
				'screen' => 1,
				'group' => 'h3_group',
				'css' => ['body.pagelayer-body h3' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),
			'h4_padding' => array(
				'type' => 'padding',
				'label' => __pl('h4_padding'),
				'screen' => 1,
				'group' => 'h4_group',
				'css' => ['body.pagelayer-body h4' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'h4_margin' => array(
				'type' => 'padding',
				'label' => __pl('h4_margin'),
				'screen' => 1,
				'group' => 'h4_group',
				'css' => ['body.pagelayer-body h4' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),
			'h5_padding' => array(
				'type' => 'padding',
				'label' => __pl('h5_padding'),
				'screen' => 1,
				'group' => 'h5_group',
				'css' => ['body.pagelayer-body h5' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'h5_margin' => array(
				'type' => 'padding',
				'label' => __pl('h5_margin'),
				'screen' => 1,
				'group' => 'h5_group',
				'css' => ['body.pagelayer-body h5' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),		
			'h6_padding' => array(
				'type' => 'padding',
				'label' => __pl('h6_padding'),
				'screen' => 1,
				'group' => 'h6_group',
				'css' => ['body.pagelayer-body h6' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'h6_margin' => array(
				'type' => 'padding',
				'label' => __pl('h6_margin'),
				'screen' => 1,
				'group' => 'h6_group',
				'css' => ['body.pagelayer-body h6' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),
			'b_padding' => array(
				'type' => 'padding',
				'label' => __pl('b_padding'),
				'screen' => 1,
				'group' => 'b_group',
				'css' => ['body.pagelayer-body b' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'b_margin' => array(
				'type' => 'padding',
				'label' => __pl('b_margin'),
				'screen' => 1,
				'group' => 'b_group',
				'css' => ['body.pagelayer-body b' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),
			'i_padding' => array(
				'type' => 'padding',
				'label' => __pl('i_padding'),
				'screen' => 1,
				'group' => 'i_group',
				'css' => ['body.pagelayer-body i' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'i_margin' => array(
				'type' => 'padding',
				'label' => __pl('i_margin'),
				'screen' => 1,
				'group' => 'i_group',
				'css' => ['body.pagelayer-body i' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),		
			'a_padding' => array(
				'type' => 'padding',
				'label' => __pl('a_padding'),
				'screen' => 1,
				'group' => 'a_group',
				'css' => ['body.pagelayer-body a' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'a_margin' => array(
				'type' => 'padding',
				'label' => __pl('a_margin'),
				'screen' => 1,
				'group' => 'a_group',
				'css' => ['body.pagelayer-body a' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),
			'a-hover_padding' => array(
				'type' => 'padding',
				'label' => __pl('_-hover_padding'),
				'screen' => 1,
				'group' => 'a_hover_group',
				'css' => ['body.pagelayer-body a:hover' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'a-hover_margin' => array(
				'type' => 'padding',
				'label' => __pl('a_hover_margin'),
				'screen' => 1,
				'group' => 'a_hover_group',
				'css' => ['body.pagelayer-body a:hover' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),		
			'aside_padding' => array(
				'type' => 'padding',
				'label' => __pl('aside_padding'),
				'screen' => 1,
				'group' => 'aside_group',
				'css' => ['body.pagelayer-body aside' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'aside_margin' => array(
				'type' => 'padding',
				'label' => __pl('aside_margin'),
				'screen' => 1,
				'group' => 'aside_group',
				'css' => ['body.pagelayer-body aside' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),		
			'p_padding' => array(
				'type' => 'padding',
				'label' => __pl('p_padding'),
				'screen' => 1,
				'group' => 'p_group',
				'css' => ['body.pagelayer-body p' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'p_margin' => array(
				'type' => 'padding',
				'label' => __pl('p_margin'),
				'screen' => 1,
				'group' => 'p_group',
				'css' => ['body.pagelayer-body p' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),		
			'entry-header_padding' => array(
				'type' => 'padding',
				'label' => __pl('entry_header_padding'),
				'screen' => 1,
				'group' => 'entry_header_group',
				'css' => ['body.pagelayer-body .entry-header' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'entry-header_margin' => array(
				'type' => 'padding',
				'label' => __pl('entry_header_margin'),
				'screen' => 1,
				'group' => 'entry_header_group',
				'css' => ['body.pagelayer-body .entry-header' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),		
			'entry-content_padding' => array(
				'type' => 'padding',
				'label' => __pl('entry_content_padding'),
				'screen' => 1,
				'group' => 'content_group',
				'css' => ['body.pagelayer-body .entry-content' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'entry-content_margin' => array(
				'type' => 'padding',
				'label' => __pl('entry_content_margin'),
				'screen' => 1,
				'group' => 'content_group',
				'css' => ['body.pagelayer-body .entry-content' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),		
			'entry-footer_padding' => array(
				'type' => 'padding',
				'label' => __pl('entry_footer_padding'),
				'screen' => 1,
				'group' => 'footer_group',
				'css' => ['body.pagelayer-body .entry-footer' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'entry-footer_margin' => array(
				'type' => 'padding',
				'label' => __pl('entry_footer_margin'),
				'screen' => 1,
				'group' => 'footer_group',
				'css' => ['body.pagelayer-body .entry-footer' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),
		),
		'post_global' => array(
			'post_body_group' => array(
				'type' => 'access',
				'label' => __pl('Body Settings'),
				'show_group' => 'post_body_group',
			),
			'post_header_group' => array(
				'type' => 'access',
				'label' => __pl('Header Settings'),
				'show_group' => 'post_header_group',
			),
			'post_h1_group' => array(
				'type' => 'access',
				'label' => __pl('H1 Settings'),
				'show_group' => 'post_h1_group',
			),
			'post_h2_group' => array(
				'type' => 'access',
				'label' => __pl('H2 Settings'),
				'show_group' => 'post_h2_group',
			),
			'post_h3_group' => array(
				'type' => 'access',
				'label' => __pl('H3 Settings'),
				'show_group' => 'post_h3_group',
			),
			'post_h4_group' => array(
				'type' => 'access',
				'label' => __pl('H4 Group'),
				'show_group' => 'post_h4_group',
			),
			'post_h5_group' => array(
				'type' => 'access',
				'label' => __pl('H5 Settings'),
				'show_group' => 'post_h5_group',
			),
			'post_h6_group' => array(
				'type' => 'access',
				'label' => __pl('H6 Settings'),
				'show_group' => 'post_h6_group',
			),
			'post_b_group' => array(
				'type' => 'access',
				'label' => __pl('B Settings'),
				'show_group' => 'post_b_group',
			),
			'post_i_group' => array(
				'type' => 'access',
				'label' => __pl('I Settings'),
				'show_group' => 'post_i_group',
			),
			'post_a_group' => array(
				'type' => 'access',
				'label' => __pl('A Settings'),
				'show_group' => 'post_a_group',
			),
			'post_a_hover_group' => array(
				'type' => 'access',
				'label' => __pl('A Hover Settings'),
				'show_group' => 'post_a_hover_group',
			),
			'post_aside_group' => array(
				'type' => 'access',
				'label' => __pl('Aside Settings'),
				'show_group' => 'post_aside_group',
			),
			'post_p_group' => array(
				'type' => 'access',
				'label' => __pl('P Settings'),
				'show_group' => 'post_p_group',
			),
			'post_entry_header_group' => array(
				'type' => 'access',
				'label' => __pl('Header Settings'),
				'show_group' => 'post_entry_header_group',
			),
			'post_entry_content_group' => array(
				'type' => 'access',
				'label' => __pl('Content Settings'),
				'show_group' => 'post_content_group',
			),
			'post_entry_footer_group' => array(
				'type' => 'access',
				'label' => __pl('Footer Settings'),
				'show_group' => 'post_footer_group',
			),
			'current_body' => array(
				'type' => 'typography',
				'label' => __pl('current_body'),
				'group' => 'post_body_group',
				'customizer_mods' => 'pagelayer_body_typography_{{post_type}}',
				'customizer_css' => 1,
				'css' => ['body.pagelayer-body ' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'current_header' => array(
				'type' => 'typography',
				'label' => __pl('current_header'),
				'group' => 'post_header_group',
				'css' => ['body.pagelayer-body header' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'current_h1' => array(
				'type' => 'typography',
				'label' => __pl('current_h1'),
				'group' => 'post_h1_group',
				'css' => ['body.pagelayer-body h1' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'current_h2' => array(
				'type' => 'typography',
				'label' => __pl('current_h2'),
				'group' => 'post_h2_group',
				'css' => ['body.pagelayer-body h2' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'current_h3' => array(
				'type' => 'typography',
				'label' => __pl('current_h3'),
				'group' => 'post_h3_group',
				'css' => ['body.pagelayer-body h3' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'current_h4' => array(
				'type' => 'typography',
				'label' => __pl('current_h4'),
				'group' => 'post_h4_group',
				'css' => ['body.pagelayer-body h4' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'current_h5' => array(
				'type' => 'typography',
				'label' => __pl('current_h5'),
				'group' => 'post_h5_group',
				'css' => ['body.pagelayer-body h5' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'current_h6' => array(
				'type' => 'typography',
				'label' => __pl('current_h6'),
				'group' => 'post_h6_group',
				'css' => ['body.pagelayer-body h6' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'current_b' => array(
				'type' => 'typography',
				'label' => __pl('current_b'),
				'group' => 'post_b_group',
				'css' => ['body.pagelayer-body b' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'current_i' => array(
				'type' => 'typography',
				'label' => __pl('current_i'),
				'group' => 'post_i_group',
				'css' => ['body.pagelayer-body i' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'current_a' => array(
				'type' => 'typography',
				'label' => __pl('current_a'),
				'group' => 'post_a_group',
				'css' => ['body.pagelayer-body a' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'current_a-hover' => array(
				'type' => 'typography',
				'label' => __pl('current_a_hover'),
				'group' => 'post_a_hover_group',
				'css' => ['body.pagelayer-body a:hover' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'current_aside' => array(
				'type' => 'typography',
				'label' => __pl('current_aside'),
				'group' => 'post_aside_group',
				'css' => ['body.pagelayer-body p' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'current_p' => array(
				'type' => 'typography',
				'label' => __pl('p'),
				'group' => 'post_p_group',
				'css' => ['body.pagelayer-body p' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'current_entry-header' => array(
				'type' => 'typography',
				'label' => __pl('current_entry_header'),
				'group' => 'post_entry_header_group',
				'css' => ['body.pagelayer-body .entry-header' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'current_entry-content' => array(
				'type' => 'typography',
				'label' => __pl('current_entry_content'),
				'group' => 'post_content_group',
				'css' => ['body.pagelayer-body .entry-content' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'current_entry-footer' => array(
				'type' => 'typography',
				'label' => __pl('current_entry_footer'),
				'group' => 'post_footer_group',
				'css' => ['body.pagelayer-body .entry-footer' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'current_body_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_body_group',
				'label' => __pl('current_body_color'),
				'css' => ['body.pagelayer-body ' => 'color:{{val}};'],
			),
			'current_header_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_header_group',
				'label' => __pl('current_header_color'),
				'css' => ['body.pagelayer-body header' => 'color:{{val}};'],
			),
			'current_h1_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_h1_group',
				'label' => __pl('current_h1_color'),
				'css' => ['body.pagelayer-body h1' => 'color:{{val}};'],
			),
			'current_h2_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_h2_group',
				'label' => __pl('current_h2_color'),
				'css' => ['body.pagelayer-body h2' => 'color:{{val}};'],
			),
			'current_h3_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_h3_group',
				'label' => __pl('current_h3_color'),
				'css' => ['body.pagelayer-body h3' => 'color:{{val}};'],
			),
			'current_h4_color' => array(
				'type' => 'color',
				'screen' => 1,
				'label' => __pl('current_h4_color'),
				'group' => 'post_h4_group',
				'css' => ['body.pagelayer-body h4' => 'color:{{val}};'],
			),
			'current_h5_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_h5_group',
				'label' => __pl('current_h5_color'),
				'css' => ['body.pagelayer-body h5' => 'color:{{val}};'],
			),
			'current_h6_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_h6_group',
				'label' => __pl('current_h6_color'),
				'css' => ['body.pagelayer-body h6' => 'color:{{val}};'],
			),
			'current_b_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_b_group',
				'label' => __pl('current_b_color'),
				'css' => ['body.pagelayer-body b' => 'color:{{val}};'],
			),
			'current_i_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_i_group',
				'label' => __pl('current_i_color'),
				'css' => ['body.pagelayer-body i' => 'color:{{val}};'],
			),
			'current_a_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_a_group',
				'label' => __pl('current_a_color'),
				'css' => ['body.pagelayer-body a' => 'color:{{val}};'],
			),
			'current_a-hover_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_a_hover_group',
				'label' => __pl('current_a_hover_color'),
				'css' => ['body.pagelayer-body a:hover' => 'color:{{val}};'],
			),
			'current_aside_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_aside_group',
				'label' => __pl('current_aside_color'),
				'css' => ['body.pagelayer-body aside' => 'color:{{val}};'],
			),
			'current_p_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_p_group',
				'label' => __pl('current_p_color'),
				'css' => ['body.pagelayer-body p' => 'color:{{val}};'],
			),
			'current_entry-header_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_entry_header_group',
				'label' => __pl('current_entry_header_color'),
				'css' => ['body.pagelayer-body .entry-header' => 'color:{{val}};'],
			),
			'current_entry-content_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_content_group',
				'label' => __pl('current_entry_content_color'),
				'css' => ['body.pagelayer-body .entry-content' => 'color:{{val}};'],
			),
			'current_entry-footer_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_footer_group',
				'label' => __pl('current_entry_footer_color'),
				'css' => ['body.pagelayer-body .entry-footer' => 'color:{{val}};'],
			),
			'current_body_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_body_group',
				'label' => __pl('current_body_background_color'),
				'css' => ['body.pagelayer-body ' => 'background-color:{{val}};'],
			),
			'current_header_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_header_group',
				'label' => __pl('current_header_background_color'),
				'css' => ['body.pagelayer-body header' => 'background-color:{{val}};'],
			),
			'current_h1_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_h1_group',
				'label' => __pl('current_h1_background_color'),
				'css' => ['body.pagelayer-body h1' => 'background-color:{{val}};'],
			),
			'current_h2_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_h2_group',
				'label' => __pl('current_h2_background_color'),
				'css' => ['body.pagelayer-body h2' => 'background-color:{{val}};'],
			),
			'current_h3_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_h3_group',
				'label' => __pl('current_h3_background_color'),
				'css' => ['body.pagelayer-body h3' => 'background-color:{{val}};'],
			),
			'current_h4_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'label' => __pl('current_h4_background_color'),
				'group' => 'post_h4_group',
				'css' => ['body.pagelayer-body h4' => 'background-color:{{val}};'],
			),
			'current_h5_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_h5_group',
				'label' => __pl('current_h5_background_color'),
				'css' => ['body.pagelayer-body h5' => 'background-color:{{val}};'],
			),
			'current_h6_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_h6_group',
				'label' => __pl('current_h6_background_color'),
				'css' => ['body.pagelayer-body h6' => 'background-color:{{val}};'],
			),
			'current_b_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_b_group',
				'label' => __pl('current_b_background_color'),
				'css' => ['body.pagelayer-body b' => 'background-color:{{val}};'],
			),
			'current_i_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_i_group',
				'label' => __pl('current_i_background_color'),
				'css' => ['body.pagelayer-body i' => 'background-color:{{val}};'],
			),
			'current_a_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_a_group',
				'label' => __pl('current_a_background_color'),
				'css' => ['body.pagelayer-body a' => 'background-color:{{val}};'],
			),
			'current_a-hover_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_a_hover_group',
				'label' => __pl('current_a_hover_background_color'),
				'css' => ['body.pagelayer-body a:hover' => 'background-color:{{val}};'],
			),
			'current_aside_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_aside_group',
				'label' => __pl('current_aside_background_color'),
				'css' => ['body.pagelayer-body aside' => 'background-color:{{val}};'],
			),
			'current_p_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_p_group',
				'label' => __pl('current_p_background_color'),
				'css' => ['body.pagelayer-body p' => 'background-color:{{val}};'],
			),
			'current_entry-header_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_entry_header_group',
				'label' => __pl('current_entry_header_background_color'),
				'css' => ['body.pagelayer-body .entry-header' => 'background-color:{{val}};'],
			),
			'current_entry-content_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_content_group',
				'label' => __pl('current_entry_content_background_color'),
				'css' => ['body.pagelayer-body .entry-content' => 'background-color:{{val}};'],
			),
			'current_entry-footer_background_color' => array(
				'type' => 'color',
				'screen' => 1,
				'group' => 'post_footer_group',
				'label' => __pl('current_entry_footer_background_color'),
				'css' => ['body.pagelayer-body .entry-footer' => 'background-color:{{val}};'],
			),
			'current_body_padding' => array(
				'type' => 'padding',
				'label' => __pl('current_body_padding'),
				'screen' => 1,
				'group' => 'post_body_group',
				'css' => ['body.pagelayer-body' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'current_body_margin' => array(
				'type' => 'padding',
				'label' => __pl('current_body_margin'),
				'screen' => 1,
				'group' => 'post_body_group',
				'css' => ['body.pagelayer-body' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),
			'current_header_padding' => array(
				'type' => 'padding',
				'label' => __pl('current_header_padding'),
				'screen' => 1,
				'group' => 'post_header_group',
				'css' => ['body.pagelayer-body header' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'current_header_margin' => array(
				'type' => 'padding',
				'label' => __pl('current_header_margin'),
				'screen' => 1,
				'group' => 'post_header_group',
				'css' => ['body.pagelayer-body header' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),
			'current_h1_padding' => array(
				'type' => 'padding',
				'label' => __pl('current_h1_padding'),
				'screen' => 1,
				'group' => 'post_h1_group',
				'css' => ['body.pagelayer-body h1' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'current_h1_margin' => array(
				'type' => 'padding',
				'label' => __pl('current_h1_margin'),
				'screen' => 1,
				'group' => 'post_h1_group',
				'css' => ['body.pagelayer-body h1' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),
			'current_h2_padding' => array(
				'type' => 'padding',
				'label' => __pl('current_h2_padding'),
				'screen' => 1,
				'group' => 'post_h2_group',
				'css' => ['body.pagelayer-body h2' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'current_h2_margin' => array(
				'type' => 'padding',
				'label' => __pl('current_h2_margin'),
				'screen' => 1,
				'group' => 'post_h2_group',
				'css' => ['body.pagelayer-body h2' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),
			'current_h3_padding' => array(
				'type' => 'padding',
				'label' => __pl('current_h3_padding'),
				'screen' => 1,
				'group' => 'post_h3_group',
				'css' => ['body.pagelayer-body h3' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'current_h3_margin' => array(
				'type' => 'padding',
				'label' => __pl('current_h3_margin'),
				'screen' => 1,
				'group' => 'post_h3_group',
				'css' => ['body.pagelayer-body h3' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),
			'current_h4_padding' => array(
				'type' => 'padding',
				'label' => __pl('current_h4_padding'),
				'screen' => 1,
				'group' => 'post_h4_group',
				'css' => ['body.pagelayer-body h4' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'current_h4_margin' => array(
				'type' => 'padding',
				'label' => __pl('current_h4_margin'),
				'screen' => 1,
				'group' => 'post_h4_group',
				'css' => ['body.pagelayer-body h4' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),
			'current_h5_padding' => array(
				'type' => 'padding',
				'label' => __pl('current_h5_padding'),
				'screen' => 1,
				'group' => 'post_h5_group',
				'css' => ['body.pagelayer-body h5' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'current_h5_margin' => array(
				'type' => 'padding',
				'label' => __pl('current_h5_margin'),
				'screen' => 1,
				'group' => 'post_h5_group',
				'css' => ['body.pagelayer-body h5' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),		
			'current_h6_padding' => array(
				'type' => 'padding',
				'label' => __pl('current_h6_padding'),
				'screen' => 1,
				'group' => 'post_h6_group',
				'css' => ['body.pagelayer-body h6' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'current_h6_margin' => array(
				'type' => 'padding',
				'label' => __pl('current_h6_margin'),
				'screen' => 1,
				'group' => 'post_h6_group',
				'css' => ['body.pagelayer-body h6' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),
			'current_b_padding' => array(
				'type' => 'padding',
				'label' => __pl('current_b_padding'),
				'screen' => 1,
				'group' => 'post_b_group',
				'css' => ['body.pagelayer-body b' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'current_b_margin' => array(
				'type' => 'padding',
				'label' => __pl('current_b_margin'),
				'screen' => 1,
				'group' => 'post_b_group',
				'css' => ['body.pagelayer-body b' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),
			'current_i_padding' => array(
				'type' => 'padding',
				'label' => __pl('current_i_padding'),
				'screen' => 1,
				'group' => 'post_i_group',
				'css' => ['body.pagelayer-body i' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'current_i_margin' => array(
				'type' => 'padding',
				'label' => __pl('current_i_margin'),
				'screen' => 1,
				'group' => 'post_i_group',
				'css' => ['body.pagelayer-body i' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),		
			'current_a_padding' => array(
				'type' => 'padding',
				'label' => __pl('current_a_padding'),
				'screen' => 1,
				'group' => 'post_a_group',
				'css' => ['body.pagelayer-body a' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'current_a_margin' => array(
				'type' => 'padding',
				'label' => __pl('current_a_margin'),
				'screen' => 1,
				'group' => 'post_a_group',
				'css' => ['body.pagelayer-body a' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),
			'current_a-hover_padding' => array(
				'type' => 'padding',
				'label' => __pl('current_a_hover_padding'),
				'screen' => 1,
				'group' => 'post_a_hover_group',
				'css' => ['body.pagelayer-body a:hover' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'current_a-hover_margin' => array(
				'type' => 'padding',
				'label' => __pl('current_a_hover_margin'),
				'screen' => 1,
				'group' => 'post_a_hover_group',
				'css' => ['body.pagelayer-body a:hover' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),		
			'current_aside_padding' => array(
				'type' => 'padding',
				'label' => __pl('current_aside_padding'),
				'screen' => 1,
				'group' => 'post_aside_group',
				'css' => ['body.pagelayer-body aside' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'current_aside_margin' => array(
				'type' => 'padding',
				'label' => __pl('current_aside_margin'),
				'screen' => 1,
				'group' => 'post_aside_group',
				'css' => ['body.pagelayer-body aside' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),		
			'current_p_padding' => array(
				'type' => 'padding',
				'label' => __pl('current_p_padding'),
				'screen' => 1,
				'group' => 'post_p_group',
				'css' => ['body.pagelayer-body p' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'current_p_margin' => array(
				'type' => 'padding',
				'label' => __pl('current_p_margin'),
				'screen' => 1,
				'group' => 'post_p_group',
				'css' => ['body.pagelayer-body p' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),		
			'current_entry-header_padding' => array(
				'type' => 'padding',
				'label' => __pl('current_entry_header_padding'),
				'screen' => 1,
				'group' => 'post_entry_header_group',
				'css' => ['body.pagelayer-body .entry-header' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'current_entry-header_margin' => array(
				'type' => 'padding',
				'label' => __pl('current_entry_header_margin'),
				'screen' => 1,
				'group' => 'post_entry_header_group',
				'css' => ['body.pagelayer-body .entry-header' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),		
			'current_entry-content_padding' => array(
				'type' => 'padding',
				'label' => __pl('current_entry_content_padding'),
				'screen' => 1,
				'group' => 'post_content_group',
				'css' => ['body.pagelayer-body .entry-content' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'current_entry-content_margin' => array(
				'type' => 'padding',
				'label' => __pl('current_entry_content_margin'),
				'screen' => 1,
				'group' => 'post_content_group',
				'css' => ['body.pagelayer-body .entry-content' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),		
			'current_entry-footer_padding' => array(
				'type' => 'padding',
				'label' => __pl('current_entry_footer_padding'),
				'screen' => 1,
				'group' => 'post_footer_group',
				'css' => ['body.pagelayer-body .entry-footer' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[3]}}px;padding-left:{{val[4]}}px;'],
			),
			'current_entry-footer_margin' => array(
				'type' => 'padding',
				'label' => __pl('current_entry_footer_margin'),
				'screen' => 1,
				'group' => 'post_footer_group',
				'css' => ['body.pagelayer-body .entry-footer' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),
		),
		'global_background' => array(
			'ele_bg_type' => array(
				'type' => 'radio',
				'label' => __pl('Background Type'),
				'list' => array(
					'' => __pl('none'),
					'color' => __pl('color'),
					'gradient' => __pl('gradient'),
					'image' => __pl('image'),
				),
			),
			'ele_bg_color' => array(
				'type' => 'color',
				'label' => __pl('color'),
				'customizer_css' => 1,
				'css' =>  ['body.pagelayer-body' => 'background: {{val}};'],			
				'req' => ['ele_bg_type' => 'color']
			),
			'ele_bg_gradient' => array(
				'type' => 'gradient',
				'label' => '',
				'default' => '150,#44d3f6,23,#72e584,45,#2ca4eb,100',
				'customizer_css' => 1,
				'css' =>  ['body.pagelayer-body' => 'background: linear-gradient({{val[0]}}deg, {{val[1]}} {{val[2]}}%, {{val[3]}} {{val[4]}}%, {{val[5]}} {{val[6]}}%);'],	
				'req' => ['ele_bg_type' => 'gradient']
			),
			'ele_img_color' => array(
				'type' => 'color',
				'label' => __pl('color'),
				'desc' => __pl('fallback_color'),
				'customizer_css' => 1,
				'css' =>  ['body.pagelayer-body' => 'background-color: {{val}};'],
				'req' => ['ele_bg_type' => 'image']
			),
			'ele_bg_img' => array(
				'type' => 'image',
				'label' => __pl('Image'),
				'customizer_css' => 1,
				'css' => ['body.pagelayer-body' => 'background-image: url("{{{ele_bg_img-url}}}");'],
				'req' => ['ele_bg_type' => 'image']
			),
			'ele_bg_attachment' => array(
				'type' => 'select',
				'label' => __pl('ele_bg_attachment'),
				'list' => array(
					'' => __pl('default'),
					'scroll' => __pl('scroll'),
					'fixed' => __pl('fixed')
				),
				'customizer_css' => 1,
				'css' => ['body.pagelayer-body' => 'background-attachment: {{val}};'],
				'req' => ['ele_bg_type' => 'image']
			),
			'ele_bg_posx' => array(
				'type' => 'select',
				'label' => __pl('ele_bg_posx'),
				'list' => array(
					'' => __pl('default'),
					'center' => __pl('center'),
					'left' => __pl('left'),
					'right' => __pl('right'),
					'custom' => __pl('custom')
				),
				'customizer_css' => 1,
				'css' => ['body.pagelayer-body' => 'background-position-x: {{val}};'],
				'req' => ['ele_bg_type' => 'image']
			),
			'ele_bg_posx_custom' => array(
				'label' => __pl('custom_x'),
				'type' => 'slider',
				'step' => 1,
				'min' => -5000,
				'max' => 5000,
				'screen' => 1,
				'units' => ['px', 'em', '%'],
				'customizer_css' => 1,
				'css' => ['body.pagelayer-body' => 'background-position-x: {{val}};'],
				'req' => array(
					'ele_bg_posx' => 'custom'
				),
			),	
			'ele_bg_posy' => array(
				'type' => 'select',
				'label' => __pl('ele_bg_posy'),
				'list' => array(
					'' => __pl('default'),
					'center' => __pl('center'),
					'top' => __pl('top'),
					'bottom' => __pl('bottom'),
					'custom' => __pl('custom')
				),
				'customizer_css' => 1,
				'css' => ['body.pagelayer-body' => 'background-position-y: {{val}};'],
				'req' => ['ele_bg_type' => 'image']
			),
			'ele_bg_posy_custom' => array(
				'label' => __pl('custom_y'),
				'type' => 'slider',
				'step' => 1,
				'min' => -5000,
				'max' => 5000,
				'screen' => 1,
				'units' => ['px', 'em', '%'],
				'customizer_css' => 1,
				'css' => ['body.pagelayer-body' => 'background-position-y: {{val}};'],
				'req' => array(
					'ele_bg_posy' => 'custom'
				),
			),
			'ele_bg_repeat' => array(
				'type' => 'select',
				'label' => __pl('ele_bg_repeat'),
				'customizer_css' => 1,
				'css' => ['body.pagelayer-body' => 'background-repeat: {{val}};'],
				'list' => array(
					'' => __pl('default'),
					'repeat' => __pl('repeat'),
					'no-repeat' => __pl('no-repeat'),
					'repeat-x' => __pl('repeat-x'),
					'repeat-y' => __pl('repeat-y'),
				),			
				'req' => ['ele_bg_type' => 'image']
			),
			'ele_bg_size' => array(
				'type' => 'select',
				'label' => __pl('ele_bg_size'),
				'customizer_css' => 1,
				'css' =>  ['body.pagelayer-body' => 'background-size: {{val}};'],
				'list' => array(
					'' => __pl('default'),
					'cover' => __pl('cover'),
					'contain' => __pl('contain')
				),			
				'req' => ['ele_bg_type' => 'image']
			),
		),
		'global_button' => array(
			'button' => array(
				'type' => 'typography',
				'label' => __pl('Typography'),
				'customizer_css' => 1,
				'css' => ['body.pagelayer-body .pagelayer-btn-holder' => 'font-family: {{val[0]}}; font-size: {{val[1]}}px; font-style: {{val[2]}}; font-weight: {{val[3]}}; font-variant: {{val[4]}}; text-decoration-line: {{val[5]}}; text-decoration-style: {{val[6]}}; line-height: {{val[7]}}em; text-transform: {{val[8]}}; letter-spacing: {{val[9]}}px; word-spacing: {{val[10]}}px;'],
			),
			'button_padding' => array(
				'type' => 'padding',
				'label' => __pl('global_btn_dim'),
				'screen' => 1,
				'customizer_css' => 1,
				'css' => ['body.pagelayer-body .pagelayer-btn-holder' => 'padding-top:{{val[0]}}px;padding-right:{{val[1]}}px;padding-bottom:{{val[2]}}px;padding-left:{{val[3]}}px;'],
			),
			'button_margin' => array(
				'type' => 'padding',
				'label' => __pl('spacing'),
				'customizer_css' => 1,
				'css' => ['body.pagelayer-body .pagelayer-btn-holder' => 'margin-top:{{val[0]}}px; margin-right:{{val[1]}}px; margin-bottom:{{val[2]}}px; margin-left:{{val[3]}}px;'],
			),
			'global_btn_state' => array(
				'type' => 'radio',
				'label' => __pl('button_state'),
				'default' => 'normal',
				'list' => array(
					'normal' => __pl('Normal'),
					'hover' => __pl('Hover'),
				),
			),
			'button_color' => array(
				'type' => 'color',
				'label' => __pl('iconbox_button_color'),
				'customizer_css' => 1,
				'css' => ['body.pagelayer-body .pagelayer-btn-holder' => 'color:{{val}};'],
				'show' => ['global_btn_state' => 'normal']
			),
			'button_background_color' => array(
				'type' => 'color',
				'label' => __pl('global_button_bg_color'),
				'customizer_css' => 1,
				'css' => ['body.pagelayer-body .pagelayer-btn-holder' => 'background-color:{{val}};'],
				'show' => ['global_btn_state' => 'normal']
			),
			'button_hover_color' => array(
				'type' => 'color',
				'label' => __pl('iconbox_button_color'),
				'customizer_css' => 1,
				'css' => ['body.pagelayer-body .pagelayer-btn-holder:hover' => 'color:{{val}};'],
				'show' => ['global_btn_state' => 'hover'],
			),
			'button_hover_background_color' => array(
				'type' => 'color',
				'label' => __pl('global_button_bg_color_hover'),
				'customizer_css' => 1,
				'css' => ['body.pagelayer-body .pagelayer-btn-holder:hover' => 'background-color:{{val}};'],
				'show' => ['global_btn_state' => 'hover'],
			),
		),
		'woocommerce' =>  array(
			'shop' => array(
				'type' => 'select',
				'label' => __pl('shop'),
				'option' => 'woocommerce_shop_page_id',
				'list' => pagelayer_get_posts(array('page')),
			),
			'cart' => array(
				'type' => 'select',
				'label' => __pl('cart'),
				'option' => 'woocommerce_cart_page_id',
				'list' => pagelayer_get_posts(array('page')),
			),
			'checkout' => array(
				'type' => 'select',
				'label' => __pl('checkout'),
				'option' => 'woocommerce_checkout_page_id',
				'list' => pagelayer_get_posts(array('page')),
			),
			'my_account' => array(
				'type' => 'select',
				'label' => __pl('my_account'),
				'option' => 'woocommerce_myaccount_page_id',
				'list' => pagelayer_get_posts(array('page')),
			),
			't_&c' => array(
				'type' => 'select',
				'label' => __pl('t_&c'),
				'option' => 'woocommerce_terms_page_id',
				'list' => pagelayer_get_posts(array('page')),
			),
		),
		'styles' => $pagelayer->customizer_styles_options,
	)

);
*/

////////////////////////
// WordPress Group
////////////////////////

// Make a list of Widget Items
global $wp_registered_sidebars;
$pagelayer_wp_widgets = array();
$pagelayer_wp_widget_default = '';

if(!empty($wp_registered_sidebars)){
	foreach($wp_registered_sidebars as $v){
		if(empty($pagelayer_wp_widget_default)){
			$pagelayer_wp_widget_default = $v['id'];
		}
		$pagelayer_wp_widgets[$v['id']] = $v['name'];
	}
}else{
	$pagelayer_wp_widgets['no'] = __pl('wp_widgets_area_no_sidebars');
}

// Widgets Area
pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_wp_widgets', array(
		'name' => __pl('Sidebars / Widget Area'),
		'group' => 'wordpress',
		'no_gt' => 1,
		'html' => '<div class="pagelayer-wp-sidebar-title">{{title}}</div>
			<div class="pagelayer-wp-sidebar-holder">{{{data}}}</div>',
		'params' => array(
			'title' => array(
				'type' => 'text',
				'label' => __pl('parameters_title'),
				'default' => 'Title',
				'desc' => __pl('wp_widgets_area_description'),
				'edit' => '.pagelayer-wp-sidebar-title',
			),
			'sidebar' => array(
				'type' => 'select',
				'label' => __pl('wp_widgets_area_select'),
				'default' => $pagelayer_wp_widget_default,
				'list' => $pagelayer_wp_widgets
			)
		)
	)
);

// Load the wordpress widgets, IF ALLOWED !
//if(current_user_can('edit_theme_options')){
	
	// Include the widgets
	//include_once(ABSPATH . 'wp-admin/includes/widgets.php');
	
	//pagelayer_print($GLOBALS['wp_widget_factory']->widgets);die();

$wp_hidden_shortcode = array('media_audio', 'media_gallery', 'media_image', 'media_video');

foreach($GLOBALS['wp_widget_factory']->widgets as $widget_key => $widget){
	
	$wp_shortcode = array(
		'name' => $widget->name,
		'group' => 'wordpress',
		'no_gt' => 1,
		'func' => 'pagelayer_does_not_exist',
		'innerHTML' => 'widget_data',
		'widget' => $widget_key,
		'params'=>array(
			'widget_data' => array(
				'type' => 'text',
				'not_visible' => 1,
			)
		)
	);
	
	if(in_array($widget->id_base, $wp_hidden_shortcode)){
		$wp_shortcode['not_visible'] = 1;
	}
	
	pagelayer_add_shortcode(PAGELAYER_SC_PREFIX.'_wp_'.$widget->id_base, $wp_shortcode);
	
}
//}

// Apply filter to load custom widgets after shortcodes
do_action('pagelayer_after_add_shortcode');
PK�f\E 3m#m#nav_walker.phpnu�[���<?php

//////////////////////////////////////////////////////////////
//===========================================================
// nav_walker.php
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date:	   23rd Jan 2017
// Time:	   23:00 hrs
// Site:	   http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////

// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
	exit('Hacking Attempt !');
}

if ( ! class_exists( 'Pagelayer_Walker_Nav_Menu' ) ) {

class Pagelayer_Walker_Nav_Menu extends Walker_Nav_Menu{
	

	// Starts the list before the elements are added.
	public function start_lvl( &$output, $depth = 0, $args = null ) {
		if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
			$t = '';
			$n = '';
		} else {
			$t = "\t";
			$n = "\n";
		}
		$indent = str_repeat( $t, $depth );

		// Default class.
		$classes = array( 'sub-menu' );

		// Filters the CSS class(es) applied to a menu list element.
		$class_names = implode( ' ', apply_filters( 'nav_menu_submenu_css_class', $classes, $args, $depth ) );
		$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';

		$output .= "{$n}{$indent}<ul$class_names>{$n}";
	}

	// Ends the list of after the elements are added.
	public function end_lvl( &$output, $depth = 0, $args = null ) {
		if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
			$t = '';
			$n = '';
		} else {
			$t = "\t";
			$n = "\n";
		}
		$indent  = str_repeat( $t, $depth );
		$output .= "$indent</ul>{$n}";
	}

	// Starts the element output.
	public function start_el( &$output, $item, $depth = 0, $args = null, $id = 0 ) {
		if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
			$t = '';
			$n = '';
		} else {
			$t = "\t";
			$n = "\n";
		}
		$indent = ( $depth ) ? str_repeat( $t, $depth ) : '';
		
		// Menu setting keys
		$keys = array('_pagelayer_content');
		
		foreach($keys as $key){
			$menu_item_setting = get_post_meta( $item->ID, $key, true );
			
			if(!empty($menu_item_setting)){
				$item->$key = $menu_item_setting;
			}
		}
		
		$classes   = empty( $item->classes ) ? array() : (array) $item->classes;
		$classes[] = 'menu-item-' . $item->ID;
		
		// Get custom setting data
		$item_content = $this->get_item_data($item, '_pagelayer_content');
		
		$settings = array();
		$pagelayer_has_content = 0;
		
		if(!empty($item_content) && has_blocks($item_content)){
			
			$blocks = parse_blocks($item_content);
			
			$attrs = array();
			
			foreach($blocks as $index => $block){
				if($block['blockName'] != 'pagelayer/pl_nav_menu_item'){
					continue;
				}
								
				// Overrig the menu ID to apply css and others
				foreach($item as $kk => $vv){
					if($kk == '_pagelayer_content'){
						continue;
					}
				
					$block['attrs'][$kk] = $vv;
				}
				
				$settings = $block['attrs'];
				
				// Add settings to $item
				foreach($settings as $skey => $sval){
			
					if(isset($item->$skey)){
						continue;
					}
			
					$item->$skey = $sval;
				}	
							
				if(!empty($block['innerBlocks'])){
					$pagelayer_has_content = $this->has_block_content($block['innerBlocks']);
				}
				
				$blocks[$index] = $block;
			}
			
			$item_content = serialize_blocks($blocks);
		}
		
		$pagelayer_has_content = pagelayer_is_live() ? 1 : $pagelayer_has_content;
		
		// Get menu type
		$menu_type = $this->get_item_data($item, 'menu_type');
		
		if(!empty($menu_type) && $menu_type == 'mega' && $depth == 0 && !empty($pagelayer_has_content)){
			$classes[] = 'pagelayer-mega-menu-item';
		}
		
		if(!empty($menu_type) && $menu_type == 'column' && $depth == 0){
			$classes[] = 'pagelayer-mega-column-item';
		}
		
		$menu_icon_class = $this->get_item_data($item, 'icon_position');
		if(!empty($menu_icon_class)){
			$classes[] = 'pagelayer-nav-menu-icon-'.$menu_icon_class;
		}

		// Filters the arguments for a single nav menu item.
		$args = apply_filters( 'nav_menu_item_args', $args, $item, $depth );

		// Filters the CSS classes applied to a menu item's list item element.
		$class_names = implode( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args, $depth ) );
		$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';

		// Filters the ID applied to a menu item's list item element.
		$id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args, $depth );
		$id = $id ? ' id="' . esc_attr( $id ) . '"' : '';

		$output .= $indent . '<li' . $id . $class_names . '>';

		$atts           = array();
		$atts['title']  = ! empty( $item->attr_title ) ? $item->attr_title : '';
		$atts['target'] = ! empty( $item->target ) ? $item->target : '';
		if ( '_blank' === $item->target && empty( $item->xfn ) ) {
			$atts['rel'] = 'noopener';
		} else {
			$atts['rel'] = $item->xfn;
		}
		$atts['href']         = ! empty( $item->url ) ? $item->url : '';
		$atts['aria-current'] = $item->current ? 'page' : '';
		
		// Filters the HTML attributes applied to a menu item's anchor element.
		$atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth );

		$attributes = '';
		foreach ( $atts as $attr => $value ) {
			if ( is_scalar( $value ) && '' !== $value && false !== $value ) {
				$value       = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
				
				// Get disable links
				$disable_link = $this->get_item_data($item, 'disable_link');
				if ( 'href' === $attr && !empty($disable_link) ) {
					$value = 'javascript:void(0)';
				}
				$attributes .= ' ' . $attr . '="' . $value . '"';
			}
		}

		/** This filter is documented in wp-includes/post-template.php */
		$title = $this->get_item_data($item, 'title');
		$title = apply_filters( 'the_title', $title, $item->ID );

		// Filters a menu item's title.
		$title = apply_filters( 'nav_menu_item_title', $title, $item, $args, $depth );
		
		$item_output  = $args->before;
		$item_output .= '<a' . $attributes . '>';
		
		// Add menu icon
		$menu_icon = $this->get_item_data($item, 'menu_icon');
		if (!empty($menu_icon)) {
			$item_output .= '<i class="pagelayer-menu-icon '.$menu_icon.'"></i>';
		}
		
		$item_output .= '<span class="pagelayer-nav-menu-title">' . $args->link_before . $title . $args->link_after .'</span>';

		// Add highlight lable
		$highlight_label = $this->get_item_data($item, 'highlight_label');
		if (!empty($highlight_label)) {
			$item_output .= '<span class="pagelayer-menu-highlight">'.$highlight_label.'</span>';
		}
		
		$item_output .= '</a>';
		$item_output .= $args->after;
		
		$mega_class = 'pagelayer-mega-editor-'.$item->ID;
				
		$item_output .= '<div class="pagelayer-mega-menu '.$mega_class.'">';
		
		// Add mega menu
		if(!empty($item_content)){
			$item_content =  pagelayer_the_content($item_content, true);
			
			// Change the pagelayer ID
			$item_output .= pagelayer_change_id($item_content);
		}
		
		$item_output .= '</div>';

		// Filters a menu item's starting output.
		$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
	}

	// Ends the element output, if needed.
	public function end_el( &$output, $item, $depth = 0, $args = null ) {
		if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
			$t = '';
			$n = '';
		} else {
			$t = "\t";
			$n = "\n";
		}
		$output .= "</li>{$n}";
	}
	
	// Get the post value
	public function get_item_data( $item, $name ) {
		
		if(pagelayer_is_live() && isset($_REQUEST['pagelayer_nav_items']) && isset($_REQUEST['pagelayer_nav_items'][$item->ID][$name]) ){
			$data = $_REQUEST['pagelayer_nav_items'][$item->ID][$name];
			
			// If Title is empty
			if(empty($data) && $name == 'title'){
				$_item = clone $item;
				$_item->post_title = '';
				$_item = wp_setup_nav_menu_item($_item);				
				return $_item->title;
			}
			
			if(!empty($data) && $name == '_pagelayer_content'){
				$data = base64_decode($data);
			}
			
			return stripslashes_deep($data);
		}
		
		return @$item->$name;
	}
	
	// Check the block has inner block
	public function has_block_content( $blocks ) {
		
		$tags = array('pagelayer/pl_row', 'pagelayer/pl_inner_row', 'pagelayer/pl_col', 'pagelayer/pl_inner_col');
		$has_content = 0;
		
		foreach($blocks as $block){
			if(!in_array( $block['blockName'], $tags) || !empty($has_content)){
				$has_content = 1;
				break;
			}
			
			if(empty($block['innerBlocks']) ){
				continue;
			}
			
			$has_content = $this->has_block_content($block['innerBlocks']);
		}
		
		return $has_content;
	}

}

}PK�f\�[����
import.phpnu�[���<?php
/*
* SITESEO
* https://siteseo.io
* (c) SiteSEO Team
*/

namespace SiteSEO;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class Import{

	static function rank_math(){
		$imported_count = 0;
		$log = [];
		
		$posts = get_posts(['posts_per_page' => -1, 'post_type' => 'any', 'post_status' => 'any']);
		foreach($posts as $post){
	 
			$robots = get_post_meta($post->ID, 'rank_math_robots', true);
			$robots_array = is_array($robots) ? $robots : [];

			$meta_mapping = [
				'_siteseo_titles_title' => self::replace_snippet_vars(get_post_meta($post->ID, 'rank_math_title', true),'rank_math'),
				'_siteseo_titles_desc' => self::replace_snippet_vars(get_post_meta($post->ID, 'rank_math_description', true),'rank_math'),
				'_siteseo_social_fb_title' => self::replace_snippet_vars(get_post_meta($post->ID, 'rank_math_facebook_title', true),'rank_math'),
				'_siteseo_social_fb_desc' => self::replace_snippet_vars(get_post_meta($post->ID, 'rank_math_facebook_description', true),'rank_math'),
				'_siteseo_social_fb_img' => get_post_meta($post->ID, 'rank_math_facebook_image', true),
				'_siteseo_social_twitter_title' => self::replace_snippet_vars(get_post_meta($post->ID, 'rank_math_twitter_title', true),'rank_math'),
				'_siteseo_social_twitter_desc' => self::replace_snippet_vars(get_post_meta($post->ID, 'rank_math_twitter_description', true),'rank_math'),
				'_siteseo_social_twitter_img' => get_post_meta($post->ID, 'rank_math_twitter_image', true),
				'_siteseo_robots_index' => in_array('noindex', $robots_array) ? '1' : '',
				'_siteseo_robots_follow' => in_array('nofollow', $robots_array) ? '1' : '',
				'_siteseo_robots_imageindex' => in_array('noimageindex', $robots_array) ? '1' : '',
				'_siteseo_robots_archive' => in_array('noarchive', $robots_array) ? '1' : '',
				'_siteseo_robots_snippet' => in_array('nosnippet', $robots_array) ? '1' : '',
				'_siteseo_robots_canonical' => get_post_meta($post->ID, 'rank_math_canonical_url', true),
				'_siteseo_analysis_target_kw' => get_post_meta($post->ID, 'rank_math_focus_keyword', true),
				'_siteseo_robots_primary_cat' => get_post_meta($post->ID, 'rank_math_primary_category', true)
			];
				
			foreach($meta_mapping as $siteseo_key => $value){
				if(!empty($value)){
					update_post_meta($post->ID, $siteseo_key, $value);
					$imported_count++;
				}
			}
			$log[] = "Imported post ID: {$post->ID}";
		}
		
		$taxonomies = get_taxonomies();
		
		foreach($taxonomies as $taxonomy){
			$terms = get_terms([
				'taxonomy' => $taxonomy,
				'hide_empty' => false,
			]);
			
			foreach($terms as $term){
				$term_robots = get_term_meta($term->term_id, 'rank_math_robots', true);
				$term_robots_array = is_array($term_robots) ? $term_robots : [];

				$meta_mapping = [
					'_siteseo_titles_title' => self::replace_snippet_vars(get_term_meta($term->term_id, 'rank_math_title', true),'rank_math'),
					'_siteseo_titles_desc' => self::replace_snippet_vars(get_term_meta($term->term_id, 'rank_math_description', true),'rank_math'),
					'_siteseo_social_fb_title' => self::replace_snippet_vars(get_term_meta($term->term_id, 'rank_math_facebook_title', true),'rank_math'),
					'_siteseo_social_fb_desc' => self::replace_snippet_vars(get_term_meta($term->term_id, 'rank_math_facebook_description', true),'rank_math'),
					'_siteseo_social_fb_img' => get_term_meta($term->term_id, 'rank_math_facebook_image', true),
					'_siteseo_social_twitter_title' => self::replace_snippet_vars(get_term_meta($term->term_id, 'rank_math_twitter_title', true),'rank_math'),
					'_siteseo_social_twitter_desc' => self::replace_snippet_vars(get_term_meta($term->term_id, 'rank_math_twitter_description', true),'rank_math'),
					'_siteseo_social_twitter_img' => get_term_meta($term->term_id, 'rank_math_twitter_image', true),
					'_siteseo_robots_index' => in_array('noindex', $term_robots_array) ? '1' : '',
					'_siteseo_robots_follow' => in_array('nofollow', $term_robots_array) ? '1' : '',
					'_siteseo_robots_imageindex' => in_array('noimageindex', $term_robots_array) ? '1' : '',
					'_siteseo_robots_archive' => in_array('noarchive', $term_robots_array) ? '1' : '',
					'_siteseo_robots_snippet' => in_array('nosnippet', $term_robots_array) ? '1' : '',
					'_siteseo_robots_canonical' => get_term_meta($term->term_id, 'rank_math_canonical_url', true),
					'_siteseo_analysis_target_kw' => get_term_meta($term->term_id, 'rank_math_focus_keyword', true)
				];
				
				foreach($meta_mapping as $siteseo_key => $value){
					if(!empty($value)){
						update_term_meta($term->term_id, $siteseo_key, $value);
						$imported_count++;
					}
				}
				
				$log[] = "Imported term ID: {$term->term_id}";
			}
		}
		
		return [
			'count' => $imported_count,
			'log' => $log,
			/* translators: %d count of items imported */
			'message' => sprintf(__('Rank Math import completed. Imported %d items.', 'siteseo'), $imported_count)
		];
	}

	static function yoast_seo(){
		$imported_count = 0;
		$log = [];
    
		$posts = get_posts(['posts_per_page' => -1, 'post_type' => 'any', 'post_status' => 'any']);
		foreach($posts as $post){
			$yoast_robots = get_post_meta($post->ID, '_yoast_wpseo_meta-robots-adv', true);
			$robots_array = $yoast_robots ? explode(',', $yoast_robots) : [];
			
			$meta_mapping = [
				'_siteseo_titles_title' => self::replace_snippet_vars(get_post_meta($post->ID, '_yoast_wpseo_title', true),'yoast_seo'),
				'_siteseo_titles_desc' => self::replace_snippet_vars(get_post_meta($post->ID, '_yoast_wpseo_metadesc', true),'yoast_seo'),
				'_siteseo_social_fb_title' => self::replace_snippet_vars(get_post_meta($post->ID, '_yoast_wpseo_opengraph-title', true),'yoast_seo'),
				'_siteseo_social_fb_desc' => self::replace_snippet_vars(get_post_meta($post->ID, '_yoast_wpseo_opengraph-description', true),'yoast_seo'),
				'_siteseo_social_fb_img' => get_post_meta($post->ID, '_yoast_wpseo_opengraph-image', true),
				'_siteseo_social_twitter_title' => self::replace_snippet_vars(get_post_meta($post->ID, '_yoast_wpseo_twitter-title', true),'yoast_seo'),
				'_siteseo_social_twitter_desc' => self::replace_snippet_vars(get_post_meta($post->ID, '_yoast_wpseo_twitter-description', true),'yoast_seo'),
				'_siteseo_social_twitter_img' => get_post_meta($post->ID, '_yoast_wpseo_twitter-image', true),
				'_siteseo_robots_index' => get_post_meta($post->ID, '_yoast_wpseo_meta-robots-noindex', true) ? '1' : '',
				'_siteseo_robots_follow' => get_post_meta($post->ID, '_yoast_wpseo_meta-robots-nofollow', true) ? '1' : '',
				'_siteseo_robots_imageindex' => in_array('noimageindex', $robots_array) ? '1' : '',
				'_siteseo_robots_archive' => in_array('noarchive', $robots_array) ? '1' : '',
				'_siteseo_robots_snippet' => in_array('nosnippet', $robots_array) ? '1' : '',
				'_siteseo_robots_canonical' => get_post_meta($post->ID, '_yoast_wpseo_canonical', true),
				'_siteseo_analysis_target_kw' => get_post_meta($post->ID, '_yoast_wpseo_focuskw', true),
				'_siteseo_robots_primary_cat' => get_post_meta($post->ID, '_yoast_wpseo_primary_category', true)
			];
			
			foreach($meta_mapping as $siteseo_key => $value){
				if(!empty($value)){
					update_post_meta($post->ID, $siteseo_key, $value);
					$imported_count++;
				}
			}
			$log[] = "Imported post ID: {$post->ID}";
		}
		
		$yoastseo_term_meta = get_option('wpseo_taxonomy_meta');
		
		foreach($yoastseo_term_meta as $taxonomy){
			
			if(!is_array($taxonomy)){
				continue;
			}
			
			foreach($taxonomy as $term_id => $term){
				$meta_mapping = [
					'_siteseo_titles_title' => self::replace_snippet_vars((!empty($term['wpseo_title']) ? $term['wpseo_title'] : ''),'yoast_seo'),
					'_siteseo_titles_desc' => self::replace_snippet_vars((!empty($term['wpseo_desc']) ? $term['wpseo_desc'] : ''),'yoast_seo'),
					'_siteseo_social_fb_title' => self::replace_snippet_vars((!empty($term['wpseo_opengraph-title']) ? $term['wpseo_opengraph-title'] : ''),'yoast_seo'),
					'_siteseo_social_fb_desc' => self::replace_snippet_vars((!empty($term['wpseo_opengraph-description']) ? $term['wpseo_opengraph-description'] : ''),'yoast_seo'),
					'_siteseo_social_fb_img' => !empty($term['wpseo_opengraph-image']) ? $term['wpseo_opengraph-image'] : '',
					'_siteseo_social_twitter_title' => self::replace_snippet_vars((!empty($term['wpseo_twitter-title']) ? $term['wpseo_twitter-title'] : ''),'yoast_seo'),
					'_siteseo_social_twitter_desc' => self::replace_snippet_vars((!empty($term['wpseo_twitter-description']) ? $term['wpseo_twitter-description'] : ''),'yoast_seo'),
					'_siteseo_social_twitter_img' => !empty($term['wpseo_twitter-image']) ? $term['wpseo_twitter-image'] : '',
					'_siteseo_robots_index' => !empty($term['wpseo_noindex']) ? 'yes' : '',
					'_siteseo_robots_follow' => !empty($term['wpseo_nofollow']) ? 'yes' : '',
					'_siteseo_robots_imageindex' => !empty($term['wpseo_noimageindex']) ? 'yes' : '',
					'_siteseo_robots_archive' => !empty($term['wpseo_noarchive']) ? 'yes' : '',
					'_siteseo_robots_snippet' => !empty($term['wpseo_nosnippet']) ? 'yes' : '',
					'_siteseo_analysis_target_kw' => !empty($term['wpseo_focuskw']) ? $term['wpseo_focuskw'] : '',
					'_siteseo_robots_primary_cat' => !empty($term['wpseo_primary_category']) ? $term['wpseo_primary_category'] : '',
					'_siteseo_robots_canonical' => !empty($term['wpseo_canonical']) ? $term['wpseo_canonical'] : '',
				];
				
				foreach($meta_mapping as $siteseo_key => $value){
					if(!empty($value)){
						update_term_meta($term_id, $siteseo_key, $value);
						$imported_count++;
					}
				}
				
				$log[] = "Imported term ID: {$term_id}";
			}
		}
		
		return [
			'count' => $imported_count,
			'log' => $log,
			/* translators: %d count of items imported */
			'message' => sprintf(__('Yoast SEO import completed. Imported %d items.', 'siteseo'), $imported_count)
		];
	}

	static function aio_seo(){
		$imported_count = 0;
		$log = [];
		
		$posts = get_posts(['posts_per_page' => -1, 'post_type' => 'any', 'post_status' => 'any']);
		foreach($posts as $post){

			$meta_mapping = [
				'_siteseo_titles_title' => self::replace_snippet_vars((get_post_meta($post->ID, '_aioseo_title', true)),'aio_seo'),
				'_siteseo_titles_desc' => self::replace_snippet_vars((get_post_meta($post->ID, '_aioseo_description', true)),'aio_seo'),
				'_siteseo_social_fb_title' => self::replace_snippet_vars((get_post_meta($post->ID, '_aioseo_og_title', true)),'aio_seo'),
				'_siteseo_social_fb_desc' => self::replace_snippet_vars((get_post_meta($post->ID, '_aioseo_og_description', true)),'aio_seo'),
				'_siteseo_social_fb_img' => get_post_meta($post->ID, '_aioseo_og_image', true),
				'_siteseo_social_twitter_title' => self::replace_snippet_vars((get_post_meta($post->ID, '_aioseo_twitter_title', true)),'aio_seo'),
				'_siteseo_social_twitter_desc' => self::replace_snippet_vars((get_post_meta($post->ID, '_aioseo_twitter_description', true)),'aio_seo'),
				'_siteseo_social_twitter_img' => get_post_meta($post->ID, '_aioseo_twitter_image', true),
				'_siteseo_robots_index' => get_post_meta($post->ID, '_aioseo_noindex', true) ? '1' : '',
				'_siteseo_robots_follow' => get_post_meta($post->ID, '_aioseo_nofollow', true) ? '1' : '',
				'_siteseo_robots_imageindex' => '1',
				'_siteseo_robots_archive' => '1',
				'_siteseo_robots_snippet' => '1', // Default to 1 if not specified
				'_siteseo_robots_canonical' => get_post_meta($post->ID, '_aioseo_canonical_url', true),
				'_siteseo_analysis_target_kw' => get_post_meta($post->ID, '_aioseo_keywords', true)
			];

			foreach($meta_mapping as $siteseo_key => $value){
				if(!empty($value)){
					update_post_meta($post->ID, $siteseo_key, $value);
					$imported_count++;
				}
			}
			
			$log[] = "Imported post ID: {$post->ID}";
		}
		
		$taxonomies = get_taxonomies();
		
		foreach($taxonomies as $taxonomy){
			$terms = get_terms([
				'taxonomy' => $taxonomy,
				'hide_empty' => false,
			]);
			
			foreach($terms as $term){
				
				$meta_mapping = [
					'_siteseo_titles_title' => self::replace_snippet_vars((get_term_meta($term->term_id, '_aioseo_title', true)),'aio_seo'),
					'_siteseo_titles_desc' => self::replace_snippet_vars((get_term_meta($term->term_id, '_aioseo_description', true)),'aio_seo'),
					'_siteseo_social_fb_title' => self::replace_snippet_vars((get_term_meta($term->term_id, '_aioseo_og_title', true)),'aio_seo'),
					'_siteseo_social_fb_desc' => self::replace_snippet_vars((get_term_meta($term->term_id, '_aioseo_og_description', true)),'aio_seo'),
					'_siteseo_social_fb_img' => get_term_meta($term->term_id, '_aioseo_og_image', true),
					'_siteseo_social_twitter_title' => self::replace_snippet_vars((get_term_meta($term->term_id, '_aioseo_twitter_title', true)),'aio_seo'),
					'_siteseo_social_twitter_desc' => self::replace_snippet_vars((get_term_meta($term->term_id, '_aioseo_twitter_description', true)),'aio_seo'),
					'_siteseo_social_twitter_img' => get_term_meta($term->term_id, '_aioseo_twitter_image', true),
					'_siteseo_robots_index' => get_term_meta($term->term_id, '_aioseo_noindex', true) ? '1' : '',
					'_siteseo_robots_follow' => get_term_meta($term->term_id, '_aioseo_nofollow', true) ? '1' : '',
					'_siteseo_robots_canonical' => get_term_meta($term->term_id, '_aioseo_canonical_url', true),
					'_siteseo_analysis_target_kw' => get_term_meta($term->term_id, '_aioseo_keywords', true)
				];
				
			
				foreach($meta_mapping as $siteseo_key => $value){
					if(!empty($value)){
						update_term_meta($term->term_id, $siteseo_key, $value);
						$imported_count++;
					}
				}
				
				$log[] = "Imported term ID: {$term->term_id}";
			}
			
		}
		
		return	[
			'count' => $imported_count,
			'log' => $log,
			/* translators: %d count of items imported */
			'message' => sprintf(__('All In One SEO import completed. Imported %d items.', 'siteseo'), $imported_count)
		];
	}

	static function seo_framework(){
		$imported_count = 0;
		$log = [];

		$posts = get_posts(['posts_per_page' => -1, 'post_type' => 'any', 'post_status' => 'any']);
		foreach($posts as $post){
			$meta_mapping = [
				'_siteseo_titles_title' => get_post_meta($post->ID, '_genesis_title', true),
				'_siteseo_titles_desc' => get_post_meta($post->ID, '_genesis_description', true),
				'_siteseo_social_fb_title' => get_post_meta($post->ID, '_open_graph_title', true),
				'_siteseo_social_fb_desc' => get_post_meta($post->ID, '_open_graph_description', true),
				'_siteseo_social_fb_img' => get_post_meta($post->ID, '_social_image_url', true),
				'_siteseo_social_twitter_title' => get_post_meta($post->ID, '_twitter_title', true),
				'_siteseo_social_twitter_desc' => get_post_meta($post->ID, '_twitter_description', true),
				'_siteseo_social_twitter_img' => get_post_meta($post->ID, '_twitter_image', true),
				'_siteseo_robots_index' => get_post_meta($post->ID, '_genesis_noindex', true) ? '1' : '',
				'_siteseo_robots_follow' => get_post_meta($post->ID, '_genesis_nofollow', true) ? '1' : '',
				'_siteseo_robots_imageindex' => '1',
				'_siteseo_robots_archive' => '1',
				'_siteseo_robots_snippet' => '1',
				'_siteseo_robots_canonical' => get_post_meta($post->ID, '_genesis_canonical_uri', true),
				'_siteseo_analysis_target_kw' => get_post_meta($post->ID, '_genesis_keywords', true)
			];
			
			foreach($meta_mapping as $siteseo_key => $value){
				if(!empty($value)){
					update_post_meta($post->ID, $siteseo_key, $value);
					$imported_count++;
				}
			}
			$log[] = "Imported post ID: {$post->ID}";
		}
		
		$taxonomies = get_taxonomies();
		
		foreach($taxonomies as $taxonomy){
			$terms = get_terms([
				'taxonomy' => $taxonomy,
				'hide_empty' => false,
			]);
			
			foreach($terms as $term){
				$term_data = get_term_meta($term->term_id, 'autodescription-term-settings', true);
				
				if(empty($term_data) || !is_array($term_data)){
					continue;
				}
				
				$meta_mapping = [
					'_siteseo_titles_title' => !empty($term_data['doctitle']) ? $term_data['doctitle'] : '',
					'_siteseo_titles_desc' => !empty($term_data['description']) ? $term_data['description'] : '',
					'_siteseo_social_fb_title' => !empty($term_data['og_title']) ? $term_data['og_title'] : '',
					'_siteseo_social_fb_desc' => !empty($term_data['og_description']) ? $term_data['og_description'] : '',
					'_siteseo_social_fb_img' => !empty($term_data['social_image_url']) ? $term_data['social_image_url'] : '',
					'_siteseo_social_twitter_title' => !empty($term_data['tw_title']) ? $term_data['tw_title'] : '',
					'_siteseo_social_twitter_desc' => !empty($term_data['tw_description']) ? $term_data['tw_description'] : '',
					'_siteseo_social_twitter_img' => !empty($term_data['social_image_url']) ? $term_data['social_image_url'] : '',
					'_siteseo_robots_index' => !empty($term_data['noindex']) ? true : '',
					'_siteseo_robots_follow' => !empty($term_data['nofollow'] ) ? true : '',
					'_siteseo_robots_archive' => !empty($term_data['noarchive']) ? true : '',
					'_siteseo_robots_canonical' => !empty($term_data['canonical']) ? $term_data['canonical'] : '',
					'_siteseo_analysis_target_kw' => !empty($term_data['keywords']) ? $term_data['keywords'] : '',
				];
			
				foreach($meta_mapping as $siteseo_key => $value){
					if(!empty($value)){
						update_term_meta($term->term_id, $siteseo_key, $value);
						$imported_count++;
					}
				}
				
				$log[] = "Imported term ID: {$term->term_id}";
			}
		}

		return [
			'count' => $imported_count,
			'log' => $log,
			/* translators: %d count of items imported */
			'message' => sprintf(__('SEO Framework import completed. Imported %d items.', 'siteseo'), $imported_count)
		];
	}

	static function seo_press(){
		$imported_count = 0;
		$log = [];

		$posts = get_posts(['posts_per_page' => -1, 'post_type' => 'any', 'post_status' => 'any']);
		foreach($posts as $post){
			
			$robots_index = get_post_meta($post->ID, '_seopress_robots_index', true);
			$robots_follow = get_post_meta($post->ID, '_seopress_robots_follow', true);
			$robots_imageindex = get_post_meta($post->ID, '_seopress_robots_imageindex', true);
			$robots_archive = get_post_meta($post->ID, '_seopress_robots_archive', true);
			
			$meta_mapping = [
				'_siteseo_titles_title' => str_replace('%%wc_single_price_exc_tax%%', '%%wc_single_price_exe_tax%%', get_post_meta($post->ID, '_seopress_titles_title', true)),
				'_siteseo_titles_desc' => str_replace('%%wc_single_price_exc_tax%%', '%%wc_single_price_exe_tax%%', get_term_meta($post->ID, '_seopress_titles_desc', true)),
				'_siteseo_social_fb_title' => str_replace('%%wc_single_price_exc_tax%%', '%%wc_single_price_exe_tax%%', get_term_meta($post->ID, '_seopress_social_fb_title', true)),
				'_siteseo_social_fb_desc' => str_replace('%%wc_single_price_exc_tax%%', '%%wc_single_price_exe_tax%%', get_term_meta($post->ID, '_seopress_social_fb_desc', true)),
				'_siteseo_social_fb_img' => get_post_meta($post->ID,'_seopress_social_fb_img',true),
				'_siteseo_social_twitter_title' => str_replace('%%wc_single_price_exc_tax%%', '%%wc_single_price_exe_tax%%', get_term_meta($post->ID, '_seopress_social_twitter_title', true)),
				'_siteseo_social_twitter_desc' => str_replace('%%wc_single_price_exc_tax%%', '%%wc_single_price_exe_tax%%', get_term_meta($post->ID, '_seopress_social_twitter_desc', true)),
				'_siteseo_social_twitter_img' => get_post_meta($post->ID, '_seopress_social_twitter_img', true),
				'_siteseo_robots_index' => (!empty($robots_index) && $robots_index === 'yes') ? '1' : '0',
				'_siteseo_robots_follow' => (!empty($robots_follow) && $robots_follow === 'yes') ? '1' : '0',
				'_siteseo_robots_imageindex' => (!empty($robots_imageindex) && $robots_imageindex === 'yes') ? '1' : '0',
				'_siteseo_robots_archive' => (!empty($robots_archive) && $robots_archive === 'yes') ? '1' : '0',
				'_siteseo_robots_snippet' => get_post_meta($post->ID, '_seopress_robots_snippet', true),
				'_siteseo_robots_canonical' => get_post_meta($post->ID, '_seopress_robots_canonical', true),
				'_siteseo_analysis_target_kw' => get_post_meta($post->ID, '_seopress_analysis_target_kw', true),
				'_siteseo_redirections_enabled' => get_post_meta($post->ID, '_seopress_redirections_enabled', true) ? '1' : '0',
				'_siteseo_redirections_value' => get_post_meta($post->ID, '_seopress_redirections_value', true),
				'_siteseo_redirections_type' => get_post_meta($post->ID, '_seopress_redirections_type', true),
				'_siteseo_redirections_param' => get_post_meta($post->ID, '_seopress_redirections_param', true),
				'_siteseo_redirections_logged_status' => get_post_meta($post->ID, '_seopress_redirections_logged_status', true),
				'_siteseo_redirections_enabled_regex' => get_post_meta($post->ID, '_seopress_redirections_enabled_regex', true),
	
			];

			foreach($meta_mapping as $siteseo_key => $value){
				if(!empty($value)){
					update_post_meta($post->ID, $siteseo_key, $value);
					$imported_count++;
				}
			}
			$log[] = "Imported post ID: {$post->ID}";
		}
		
		$taxonomies = get_taxonomies();
		
		foreach($taxonomies as $taxonomy){
			$terms = get_terms([
				'taxonomy' => $taxonomy,
				'hide_empty' => false,
			]);
			
			foreach($terms as $term){
				
				$robots_index = get_term_meta($term->term_id, '_seopress_robots_index', true);
				$robots_follow = get_term_meta($term->term_id, '_seopress_robots_follow', true);
				$robots_imageindex = get_term_meta($term->term_id, '_seopress_robots_imageindex', true);
				$robots_archive = get_term_meta($term->term_id, '_seopress_robots_archive', true);
				
				$meta_mapping = [
					'_siteseo_titles_title' => str_replace('%%wc_single_price_exc_tax%%', '%%wc_single_price_exe_tax%%', get_term_meta($term->term_id, '_seopress_titles_title', true)),
					'_siteseo_titles_desc' => str_replace('%%wc_single_price_exc_tax%%', '%%wc_single_price_exe_tax%%', get_term_meta($term->term_id, '_seopress_titles_desc', true)),
					'_siteseo_social_fb_title' => str_replace('%%wc_single_price_exc_tax%%', '%%wc_single_price_exe_tax%%', get_term_meta($term->term_id, '_seopress_social_fb_title', true)),
					'_siteseo_social_fb_desc' => str_replace('%%wc_single_price_exc_tax%%', '%%wc_single_price_exe_tax%%', get_term_meta($term->term_id, '_seopress_social_fb_desc', true)),
					'_siteseo_social_fb_img' => get_term_meta($term->term_id,'_seopress_social_fb_img',true),
					'_siteseo_social_twitter_title' => str_replace('%%wc_single_price_exc_tax%%', '%%wc_single_price_exe_tax%%', get_term_meta($term->term_id, '_seopress_social_twitter_title', true)),
					'_siteseo_social_twitter_desc' => str_replace('%%wc_single_price_exc_tax%%', '%%wc_single_price_exe_tax%%', get_term_meta($term->term_id, '_seopress_social_twitter_desc', true)),
					'_siteseo_social_twitter_img' => get_term_meta($term->term_id, '_seopress_social_twitter_img', true),
					'_siteseo_robots_index' => (!empty($robots_index) && $robots_index === 'yes') ? '1' : '0',
					'_siteseo_robots_follow' => (!empty($robots_follow) && $robots_follow === 'yes') ? '1' : '0',
					'_siteseo_robots_imageindex' => (!empty($robots_imageindex) && $robots_imageindex === 'yes') ? '1' : '0',
					'_siteseo_robots_archive' => (!empty($robots_archive) && $robots_archive === 'yes') ? '1' : '0',
					'_siteseo_robots_snippet' => get_term_meta($term->term_id, '_seopress_robots_snippet', true),
					'_siteseo_robots_canonical' => get_term_meta($term->term_id, '_seopress_robots_canonical', true),
					'_siteseo_analysis_target_kw' => get_term_meta($term->term_id, '_seopress_analysis_target_kw', true),
					'_siteseo_redirections_enabled' => get_term_meta($term->term_id, '_seopress_redirections_enabled', true) ? '1' : '0',
					'_siteseo_redirections_value' => get_term_meta($term->term_id, '_seopress_redirections_value', true),
					'_siteseo_redirections_type' => get_term_meta($term->term_id, '_seopress_redirections_type', true),
					'_siteseo_redirections_param' => get_term_meta($term->term_id, '_seopress_redirections_param', true),
					'_siteseo_redirections_logged_status' => get_term_meta($term->term_id, '_seopress_redirections_logged_status', true),
					'_siteseo_redirections_enabled_regex' => get_term_meta($term->term_id, '_seopress_redirections_enabled_regex', true),
		
				];
				
				foreach($meta_mapping as $siteseo_key => $value){
					if(!empty($value)){
						update_term_meta($term->term_id, $siteseo_key, $value);
						$imported_count++;
					}
				}
				
				$log[] = "Imported term ID: {$term->term_id}";
			}
		}

		return [
			'count' => $imported_count,
			'log' => $log,
			/* translators: %d count of items imported */
			'message' => sprintf(__('SEOPress migration completed. Imported %d items.', 'siteseo'), $imported_count)
		];
	}
	
	static function slim_seo(){
		$imported_count = 0;
		$log = [];
		
		$posts = get_posts(['posts_per_page' => -1, 'post_type' => 'any', 'post_status' => 'any']);
		
		$taxonomies = get_taxonomies(array('public' => true), 'objects');
		
		foreach($posts as $post){
			$post_data = get_post_meta($post->ID, 'slim_seo', true);
			
			if(empty($post_data) || !is_array($post_data)){
				continue;
			}
			
			$meta_mapping = [
				'_siteseo_titles_title' => self::replace_snippet_vars((!empty($post_data['title']) ? $post_data['title'] : ''),'slim_seo'),
				'_siteseo_titles_desc' => self::replace_snippet_vars((!empty($post_data['description']) ? $post_data['description'] : ''),'slim_seo'),
				'_siteseo_social_fb_img' => !empty($post_data['facebook_image']) ? $post_data['facebook_image'] : '',
				'_siteseo_social_twitter_img' => !empty($post_data['twitter_image']) ? $post_data['twitter_image'] : '',
				'_siteseo_robots_index'         => isset($post_data['noindex']) && $post_data['noindex'] ? '1' : '',
				'_siteseo_robots_canonical' => !empty($post_data['canonical']) ? $post_data['canonical'] : '',
			];
			
			foreach($meta_mapping as $siteseo_key => $value){
				if(!empty($value)){
					update_post_meta($post->ID, $siteseo_key, $value);
					$imported_count++;
				}
			}
			
			$log[] = "Imported post ID: {$post->ID}";
		}
		
		$taxonomies = get_taxonomies();
		
		foreach($taxonomies as $taxonomy){
			
			$terms = get_terms([
				'taxonomy' => $taxonomy,
				'hide_empty' => false,
			]);
        
			foreach($terms as $term){
				$term_data = get_term_meta($term->term_id, 'slim_seo', true);
				
				if(empty($term_data) || !is_array($term_data)){
					continue;
				}
				
				$meta_mapping = [
					'_siteseo_titles_title' => self::replace_snippet_vars((!empty($term_data['title']) ? $term_data['title'] : ''),'slim_seo'),
					'_siteseo_titles_desc' => self::replace_snippet_vars((!empty($term_data['description']) ? $term_data['description'] : ''),'slim_seo'),
					'_siteseo_social_fb_img' => !empty($term_data['facebook_image']) ? $term_data['facebook_image'] : '',
					'_siteseo_social_twitter_img' => !empty($term_data['twitter_image']) ? $term_data['twitter_image'] : '',
					'_siteseo_robots_index' => !empty($term_data['noindex']) ? true : '',
					'_siteseo_robots_canonical' => !empty($term_data['canonical']) ? $term_data['canonical'] : '',
				];
				
				foreach($meta_mapping as $siteseo_key => $value){
					if(!empty($value)){
						update_term_meta($term->term_id, $siteseo_key, $value);
						$imported_count++;
					}
				}
				
				$log[] = "Imported term ID: {$term->term_id}";
			}
		}
		
		return [
			'count' => $imported_count,
			'log' => $log,
			/* translators: %d count of items imported */
			'message' => sprintf(__('Slim SEO import completed. Imported %d items.', 'siteseo'), $imported_count)
		];
	}

	static function replace_snippet_vars($string, $plugin){
		if(empty($string)) return $string;
		
		// We should not process the string if it does not have a variable
		if(!preg_match('/%|{|#/', $string)){
			return $string;
		}

		static $plugins = [
			'rank_math' => [
				'%sep%' => '%%sep%%',
				'%sitename%' => '%%sitetitle%%',
				'%sitedesc%' => '%%tagline%%',
				'%title%' => '%%post_title%%',
				'%excerpt%' => '%%post_excerpt%%',
				'%excerpt_only%' => '%%post_excerpt%%',
				'%post_thumbnail%' => '%%post_thumbnail_url%%',
				'%url%' => '%%post_url%%',
				'%date%' => '%%post_date%%',
				'%modified%' => '%%post_modified_date%%',
				'%name%' => '%%post_author%%',
				'%category%' => '%%post_category%%',
				'%tag%' => '%%post_tag%%',
				'%term%' => '%%term_title%%',
				'%term_description%' => '%%term_description%%',
				'%search_query%' => '%%search_keywords%%',
				'%pagenumber%' => '%%current_pagination%%',
				'%page%' => '%%page%%',
				'%archive_title%' => '%%archive_title%%',
				'%sitename_with_sep%' => '%%sep%%%%sitetitle%%',
				'%pt_plural%' => '%%cpt_plural%%',
				'%wc_shortdesc%' => '%%wc_single_short_desc%%',
				'%wc_price%' => '%%wc_single_price%%',
				'%wc_sku%' => '%%wc_sku%%',
				'%currentday%' => '%%currentday%%',
				'%currentmonth%' => '%%currentmonth%%',
				'%currentyear%' => '%%currentyear%%',
				'%currentdate%' => '%%currentdate%%',
				'%currenttime%' => '%%currenttime%%',
				'%user_description%' => '%%author_bio%%',
				'%focuskw%' => '%%target_keyword%%'
			],
			'yoast_seo' => [
				'%%sitename%%' => '%%sitetitle%%',
				'%%sitedesc%%' => '%%tagline%%',
				'%%title%%' => '%%post_title%%',
				'%%excerpt%%' => '%%post_excerpt%%',
				'%%excerpt_only%%' => '%%post_excerpt%%',
				'%%content%%' => '%%post_content%%',
				'%%thumbnail%%' => '%%post_thumbnail_url%%',
				'%%url%%' => '%%post_url%%',
				'%%date%%' => '%%post_date%%',
				'%%modified%%' => '%%post_modified_date%%',
				'%%author%%' => '%%post_author%%',
				'%%category%%' => '%%post_category%%',
				'%%primary_category%%' => '%%post_category%%',
				'%%tag%%' => '%%post_tag%%',
				'%%category_description%%' => '%%_category_description%%',
				'%%searchphrase%%' => '%%search_keywords%%',
				'%%pagenumber%%' => '%%current_pagination%%',
				'%%year%%' => '%%currentyear%%',
				'%%month%%' => '%%currentmonth%%',
				'%%day%%' => '%%currentday%%',
				'%%author_firstname%%' => '%%author_first_name%%',
				'%%author_lastname%%' => '%%author_last_name%%',
				'%%author_description%%' => '%%author_bio%%',
				'%%product_sku%%' => '%%wc_sku%%',
				'%%product_price%%' => '%%wc_single_price%%',
				'%%product_shortdesc%%' => '%%wc_single_short_desc%%',
				'%%product_category%%' => '%%wc_single_cat%%',
				'%%product_tag%%' => '%%wc_single_tag%%'
			],
			'aio_seo' => [
				'#separator_sa' => '%%sep%%',
				'#site_title' => '%%sitetitle%%',
				'#tagline' => '%%tagline%%',
				'#post_title' => '%%post_title%%',
				'#post_excerpt' => '%%post_excerpt%%',
				'#post_content' => '%%post_content%%',
				'#post_thumbnail' => '%%post_thumbnail_url%%',
				'#post_url' => '%%post_url%%',
				'#post_date' => '%%post_date%%',
				'#post_modified_date' => '%%post_modified_date%%',
				'#categories' => '%%post_category%%',
				'#post_tags' => '%%post_tag%%',
				'#author_name' => '%%post_author%%',
				'#taxonomy_title' => '%%post_category%%',
				'#tag_title' => '%%post_tag%%',
				'#term_name' => '%%term_title%%',
				'#term_description' => '%%term_description%%',
				'#search_query' => '%%search_keywords%%',
				'#page_number' => '%%page%%',
				'#pt_plural' => '%%cpt_plural%%',
				'#wc_short_description' => '%%wc_single_short_desc%%',
				'#wc_price' => '%%wc_single_price%%',
				'#wc_sku' => '%%wc_sku%%',
				'#current_day' => '%%currentday%%',
				'#current_month' => '%%currentmonth%%',
				'#current_year' => '%%currentyear%%',
				'#current_date' => '%%currentdate%%',
				'#current_time' => '%%currenttime%%',
				'#author_first_name' => '%%author_first_name%%',
				'#author_last_name' => '%%author_last_name%%',
				'#author_description' => '%%author_bio%%',
				'#focus_keyword' => '%%target_keyword%%',
				'#custom_field' => '%%_cf_your_custom_field_name%%'
			],
			'slim_seo' => [
				'{{ sep }}' => '%%sep%%',
				'{{ site.title }}' => '%%sitetitle%%',
				'{{ post.title }}' => '%%post_title%%',
				'{{ post.excerpt }}' => '%%post_excerpt%%',
				'{{ post.content }}' => '%%post_content%%',
				'{{ post_type.plural }}' => '%%cpt_plural%%',
				'{{ post.thumbnail }}' => '%%post_thumbnail_url%%',
				'{{ post.url }}' => '%%post_url%%',
				'{{ post.date }}' => '%%post_date%%',
				'{{ post.modified_date }}' => '%%post_modified_date%%',
				'{{ author.display_name }}' => '%%post_author%%',
				'{{ post.categories }}' => '%%post_category%%',
				'{{ post.tags }}' => '%%post_tag%%',
				'{{ term.name }}' => '%%term_title%%',
				'{{ term.description }}' => '%%term_description%%',
				'{{ page }}' => '%%page%%',
				'{{ current.month }}' => '%%currentmonth%%',
				'{{ current.day }}' => '%%currentday%%',
				'{{ current.year }}' => '%%currentyear%%',
				'{{ author.first_name }}' => '%%author_first_name%%',
				'{{ author.last_name }}' => '%%author_last_name%%',
				'{{ author.website_url }}' => '%%author_website%%',
				'{{ author.nickname }}' => '%%author_nickname%%',
				'{{ author.description }}' => '%%author_bio%%'
			],
			'surerank' => [
				'%site_name%'=> '%%sitetitle%%',
				'%title%' => '%%post_title%%',
				'%tagline%' => '%%tagline%%',
				'%post_url%' => '%%post_url%%',
				'%content%' => '%%post_content%%',
				'%sep%' => '%%sep%%',
				'%excerpt%' => '%%post_excerpt%%',
				'%author_name%' => '%%post_author%%',
				'%category%' => '%%post_category%%',
				'%tag%' => '%%post_tag%%',
				'%term_title%' => '%%term_title%%',
				'%term_description%' => '%%term_description%%',
				'%modified%' => '%%post_modified_date%%',
				'%currentdate%' => '%%currentday%%',
				'%currentmonth%' => '%%currentmonth%%',
				'%currentyear%' => '%%currentyear%%',
				
			]
		];

		if(!empty($plugins[$plugin])){
			return str_replace(array_keys($plugins[$plugin]), array_values($plugins[$plugin]), $string);
		}

		return $string;
	}

	static function surerank(){

		$imported_count = 0;
		$log = [];

		$posts = get_posts(['posts_per_page' => -1, 'post_type' => 'any', 'post_status' => 'any']);
		foreach($posts as $post){

			$general = get_post_meta($post->ID, 'surerank_settings_general', true);
			$general = is_array($general) ? $general : [];
			$social = get_post_meta($post->ID, 'surerank_settings_social', true);
			$social = is_array($social) ? $social : [];
			$noindex = get_post_meta($post->ID, 'surerank_settings_post_no_index', true);
			$nofollow = get_post_meta($post->ID, 'surerank_settings_post_no_follow', true);
			$noarchive = get_post_meta($post->ID, 'surerank_settings_post_no_archive', true);

			$meta_mapping = [

				'_siteseo_titles_title' => !empty($general['page_title']) ? self::replace_snippet_vars($general['page_title'], 'surerank') : '',
				'_siteseo_titles_desc' => !empty($general['page_description']) ? self::replace_snippet_vars($general['page_description'], 'surerank') : '',
				'_siteseo_robots_canonical' => !empty($general['canonical_url']) ? $general['canonical_url'] : '',
				'_siteseo_social_fb_title' => !empty($social['facebook_title']) ? self::replace_snippet_vars($social['facebook_title'], 'surerank') : '',
				'_siteseo_social_fb_desc' => !empty($social['facebook_description']) ? self::replace_snippet_vars($social['facebook_description'], 'surerank') : '',			
				'_siteseo_social_twitter_title' => !empty($social['twitter_title']) ? self::replace_snippet_vars($social['twitter_title'], 'surerank') : '',
				'_siteseo_social_twitter_desc' => !empty($social['twitter_description']) ? self::replace_snippet_vars($social['twitter_description'], 'surerank') : '',
				'_siteseo_social_fb_img' => !empty($social['facebook_image_url']) ? $social['facebook_image_url'] : '',
				'_siteseo_social_twitter_img' => !empty($social['twitter_image_url']) ? $social['twitter_image_url'] : '',

				// Robots
				'_siteseo_robots_index' => ($noindex === 'yes')   ? '1' : '',
				'_siteseo_robots_follow' => ($nofollow === 'yes')  ? '1' : '',
				'_siteseo_robots_archive' => ($noarchive === 'yes') ? '1' : '',
			];

			foreach($meta_mapping as $key => $value){
				if(!empty($value)){
					update_post_meta($post->ID, $key, $value);
					$imported_count++;
				}
			}

			$log[] = "Imported SureRank post ID: {$post->ID}";
		}
		
		$taxonomies = get_taxonomies();

		foreach($taxonomies as $taxonomy){

			$terms = get_terms([
				'taxonomy'   => $taxonomy,
				'hide_empty' => false,
			]);

			if(is_wp_error($terms) || empty($terms)){
				continue;
			}

			foreach($terms as $term){

				$general = get_term_meta($term->term_id, 'surerank_settings_general', true);
				$general = is_array($general) ? $general : [];
				$social = get_term_meta($term->term_id, 'surerank_settings_social', true);
				$social = is_array($social) ? $social : [];
				$noindex = get_term_meta($term->term_id, 'surerank_settings_term_no_index', true);
				$nofollow = get_term_meta($term->term_id, 'surerank_settings_term_no_follow', true);
				$noarchive = get_term_meta($term->term_id, 'surerank_settings_term_no_archive', true);

				$meta_mapping = [

					// Titles
					'_siteseo_titles_title' => !empty($general['page_title']) ? self::replace_snippet_vars($general['page_title'], 'surerank') : '',
					'_siteseo_titles_desc' => !empty($general['page_description']) ? self::replace_snippet_vars($general['page_description'], 'surerank') : '',
					'_siteseo_robots_canonical' => !empty($general['canonical_url']) ? $general['canonical_url'] : '',
					'_siteseo_social_fb_title' => !empty($social['facebook_title']) ? self::replace_snippet_vars($social['facebook_title'], 'surerank') : '',
					'_siteseo_social_fb_desc' => !empty($social['facebook_description']) ? self::replace_snippet_vars($social['facebook_description'], 'surerank') : '',
					'_siteseo_social_twitter_title' => !empty($social['twitter_title']) ? self::replace_snippet_vars($social['twitter_title'], 'surerank') : '',
					'_siteseo_social_twitter_desc' => !empty($social['twitter_description']) ? self::replace_snippet_vars($social['twitter_description'], 'surerank') : '',
					'_siteseo_social_fb_img' => !empty($social['facebook_image_url']) ? $social['facebook_image_url'] : '',
					'_siteseo_social_twitter_img' => !empty($social['twitter_image_url']) ? $social['twitter_image_url'] : '',

					// Robots
					'_siteseo_robots_index'   => ($noindex === 'yes')   ? '1' : '',
					'_siteseo_robots_follow'  => ($nofollow === 'yes')  ? '1' : '',
					'_siteseo_robots_archive' => ($noarchive === 'yes') ? '1' : '',
				];

				foreach($meta_mapping as $key => $value){
					if(!empty($value)){
						update_term_meta($term->term_id, $key, $value);
						$imported_count++;
					}
				}

				$log[] = "Imported SureRank term ID: {$term->term_id}";
			}
		}

		return [
			'count' => $imported_count,
			'log' => $log,
			'message' => sprintf(__('SureRank import completed. Imported %d items.', 'siteseo'), $imported_count),
		];
	}
}
PK�f\�4�??customizer.phpnu�[���<?php

//////////////////////////////////////////////////////////////
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date:	   23rd Jan 2017
// Time:	   23:00 hrs
// Site:	   http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////

// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
	exit('Hacking Attempt !');
}

// Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
add_action( 'customize_preview_init', 'pagelayer_customize_preview_js' );
function pagelayer_customize_preview_js() {
	//wp_enqueue_script( 'pagelayer-customizer-preview', get_template_directory_uri() . '/js/customizer-preview.js', array( 'jquery', 'customize-preview' ), PAGELAYER_VERSION, true );
}

// JS handlers for controls.
add_action( 'customize_controls_enqueue_scripts', 'pagelayer_customize_scripts' );
function pagelayer_customize_scripts(){
	wp_enqueue_script( 'wp-color-picker' );
	wp_enqueue_style( 'wp-color-picker' );
	wp_enqueue_script( 'pagelayer-customizer', PAGELAYER_JS.'/customizer.js', array( 'customize-controls' ), PAGELAYER_VERSION, true );
}

// Print global Style.
add_action( 'customize_controls_print_styles', 'pagelayer_customize_controls_print_styles' );
function pagelayer_customize_controls_print_styles(){
	global $pagelayer;
	
	$font_family = (array) $pagelayer->fonts;
	$style = array('' => 'Default', 'normal' => 'Normal', 'italic' => 'Italic', 'oblique' => 'Oblique');
	$weight = array('' => 'Default', '100' => '100', '200' => '200', '300' => '300', '400' => '400', '500' => '500', '600' => '600', '700' => '700', '800' => '800', '900' => '900', 'normal' => 'Normal', 'lighter' => 'Lighter', 'bold' => 'Bold', 'bolder' => 'Bolder', 'unset' => 'Unset');
	$variant = array('' => 'Default', 'normal' => 'Normal', 'small-caps' => 'Small Caps');
	$decoration = array('' => 'Default', 'none' => 'None', 'overline' => 'Overline', 'line-through' => 'Line-through', 'underline' => 'Underline', 'underline overline' => 'Underline Overline');
	$decoration_style = array('' => 'None', 'solid' => 'Solid', 'double' => 'Double', 'dotted' => 'Dotted', 'dashed' => 'Dashed', 'wavy' => 'Wavy');
	$transform = array('' => 'Default', 'capitalize' => 'Capitalize', 'uppercase' => 'Uppercase', 'lowercase' => 'Lowercase');
	
	$pagelayer->font_settings = array(
		'font-family' => array(
			'label' => __('Family', 'pagelayer'), 
			'choices' => $font_family
		),
		'font-size' => array(
			'label' => __('Size', 'pagelayer'),
			'responsive' => 1,
		),
		'font-style' => array(
			'label' => __('Style', 'pagelayer'), 
			'choices' => $style,
		),
		'font-weight' => array(
			'label' => __('Weight', 'pagelayer'), 
			'choices' => $weight,
			'responsive' => 1,
		),
		'font-variant' => array(
			'label' => __('Variant', 'pagelayer'), 
			'choices' => $variant,
		),
		'text-decoration-line' => array(
			'label' => __('Decoration', 'pagelayer'), 
			'choices' => $decoration,
		),
		'text-decoration-style' => array(
			'label' => __('Decoration Style', 'pagelayer'), 
			'choices' => $decoration_style,
		),
		'line-height' => array(
			'label' => __('Line Height', 'pagelayer'),
			'responsive' => 1,
		),
		'text-transform' => array(
			'label' => __('Transform', 'pagelayer'),
			'choices' => $transform,
		),
		'letter-spacing' => array(
			'label' => __('Text Spacing', 'pagelayer'),
			'responsive' => 1,
		),
		'word-spacing' => array(
			'label' => __('Word Spacing', 'pagelayer'),
			'responsive' => 1,
		),
	);
	
	$styles = '<style id="pagelayer-customize-global-style">:root{';
	
	// Set global colors styles
	foreach($pagelayer->global_colors as $gk => $gv){
		$styles .= '--pagelayer-color-'.$gk.':'.$gv['value'].';';
	}

	$styles .= '}
	</style>'.PHP_EOL;
	
	// Added global JavaSript variables
	$styles .= '<script id="pagelayer-customize-global-js">
		var pagelayer_global_colors = '.json_encode($pagelayer->global_colors).';
		var pagelayer_global_fonts = '.json_encode($pagelayer->global_fonts).';
		var pagelayer_global_font_settings = '.json_encode($pagelayer->font_settings).';
	</script>'.PHP_EOL;
	
	echo $styles;
}

add_action( 'customize_register', 'pagelayer_customize_register', 11 );
function pagelayer_customize_register( $wp_customize ) {
	global $pagelayer;
	
	// CSS for the custom controls
	wp_register_style('pagelayer-customizer', PAGELAYER_CSS.'/customizer.css', PAGELAYER_VERSION);
	wp_enqueue_style('pagelayer-customizer');
	
	// Load fonts
	pagelayer_load_font_options();
	
	// Load global colors and fonts
	pagelayer_load_global_palette();
	
	// Add custom controls
	include_once(PAGELAYER_DIR . '/main/customizer-controls.php');
	
	$post_types = array('' => __('Global'));
	$exclude = [ 'attachment', 'pagelayer-template' ];
	$pt_objects = get_post_types(['public' => true,], 'objects');

	foreach ( $pt_objects as $pt_slug => $type ) {
		
		if ( in_array( $pt_slug, $exclude ) ) {
			continue;
		}
		
		$post_types[$pt_slug] = $type->labels->name;
	}
	
	// Pagelayer Panel
	$wp_customize->add_panel( 'pagelayer_settings', array(
		'priority'       => 10,
		'title'          => 'Pagelayer',
	));
	
	// Global colors section
	$wp_customize->add_section( 'pagelayer_global_colors_sec', array(
		'capability' => 'edit_theme_options',
		'priority' => 10,
		'title' => __('Colors'),
		'panel' => 'pagelayer_settings',
	));
	
	$wp_customize->add_setting( 'pagelayer_global_colors', array(
		'type' => 'option',
		'capability' => 'edit_theme_options',
		'transport' => 'refresh',
		'default' => json_encode( $pagelayer->global_colors )
	));
	
	$wp_customize->add_control( new Pagelayer_Color_Repeater_Control($wp_customize, 'pagelayer_global_colors', array(
		'priority' => 10,
		'section' => 'pagelayer_global_colors_sec',
	)));
	
	// Global fonts section
	$wp_customize->add_section( 'pagelayer_global_fonts_sec', array(
		'capability' => 'edit_theme_options',
		'priority' => 10,
		'title' => __('Typography'),
		'panel' => 'pagelayer_settings',
	));
	
	$wp_customize->add_setting( 'pagelayer_global_fonts', array(
		'type' => 'option',
		'capability' => 'edit_theme_options',
		'transport' => 'refresh',
		'default' => json_encode($pagelayer->global_fonts),
	));
	
	$wp_customize->add_control( new Pagelayer_Font_Repeater_Control($wp_customize, 'pagelayer_global_fonts', array(
		'priority' => 10,
		'section' => 'pagelayer_global_fonts_sec',
	)));
	
	foreach($post_types as $sk => $sv){
		
		$post_type = empty($sk) ? '' : '_'.$sk;
		$global_section = 'pagelayer_global_sec'.$post_type;
		$global_text = empty($sk) ? '' : __('Global');
				
		// Global section
		$wp_customize->add_section( $global_section, array(
			'capability' => 'edit_theme_options',
			'priority' => 10,
			'title' => sprintf( __('%s %s Styles', 'pagelayer'), $sv, $global_text),
			'panel' => 'pagelayer_settings',
		));
		
		foreach($pagelayer->css_settings as $set => $setv){
			
			$setting_name = $set.$sk;
			$setting = empty($setv['key']) ? 'pagelayer_'.$set.'_css'.$post_type : $setv['key'].$post_type;
			
			$wp_customize->add_setting( 'pagelayer_lable_'.$setting_name, array(
				'capability' => 'edit_theme_options',
			));
			
			$wp_customize->add_control( new Pagelayer_Customize_Control(
				$wp_customize, 'pagelayer_lable_'.$setting_name, array(
					'type' => 'hidden',
					'section' => $global_section,
					'description' => sprintf( __('<div class="pagelayer-customize-heading"><div>%s</div><span class="dashicons dashicons-arrow-right-alt2"></span></div>', 'pagelayer'), $sv.' '.$setv['name']),
					'li_class' => 'pagelayer-accordion-tab',
				)
			));
			
			// Register the typography control for body
			pagelayer_register_typo_customizer_control($wp_customize, array(
				'control' => $setting,
				'section' => $global_section,
				'label' => __( 'Typography', 'pagelayer' ),
				'capability' => 'edit_theme_options',
				'setting_type' => 'option',
				'transport' => 'refresh',
				'default' => '',
				'units' => ['px', 'em', '%'],
				'responsive' => 1,
			));

			$wp_customize->add_setting( $setting.'[color]', array(
				'type' => 'option',
				'capability' => 'edit_theme_options',
				'transport' => 'refresh',
			));
			
			$wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control(
				$wp_customize, $setting.'[color]', array(
					'section' => $global_section,
					'label' => __( 'Color', 'pagelayer' ),
				)
			));

			$wp_customize->add_setting( $setting.'[background-color]', array(
				'type' => 'option',
				'capability' => 'edit_theme_options',
				'transport' => 'refresh',
			));
			
			$wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control(
				$wp_customize, $setting.'[background-color]', array(
					'section' => $global_section,
					'label' => __( 'Background Color', 'pagelayer' ),
				)
			));
			
			// Register the padding control for scroll to top
			pagelayer_register_padding_customizer_control($wp_customize, array(
				'control' => $setting,
				'control_array_sufix' => 'padding',
				'section' => $global_section,
				'label' => __( 'Padding', 'pagelayer' ),
				'capability' => 'edit_theme_options',
				'setting_type' => 'option',
				'transport' => 'refresh',
				'default' => '',
				'units' => ['px', 'em', '%'],
				'setting_parts' => array('0', '1', '2', '3', 'unit'),
				'responsive' => 1,
			));
			
			// Register the padding control for scroll to top
			pagelayer_register_padding_customizer_control($wp_customize, array(
				'control' => $setting,
				'control_array_sufix' => 'margin',
				'section' => $global_section,
				'label' => __( 'Margin', 'pagelayer' ),
				'capability' => 'edit_theme_options',
				'setting_type' => 'option',
				'transport' => 'refresh',
				'default' => '',
				'units' => ['px', 'em', '%'],
				'setting_parts' => array('0', '1', '2', '3', 'unit'),
				'responsive' => 1,
			));
			
		}
	}
}

/**
 * Register the Typography control.
 *
 * @return void
 */
function pagelayer_register_typo_customizer_control($wp_customize, $args, $screen_array = false){
			
	$settings_for_control = array();
	$settings = array('font-family', 'font-size', 'font-style', 'font-weight', 'font-variant', 'text-decoration-line', 'text-decoration-style', 'line-height', 'text-transform', 'letter-spacing', 'word-spacing', 'global-font');
	$screens = array('');
	$control_array_sufix = '';
	
	if(!empty($args['responsive'])){
		$screens = array('desktop' => '', 'tablet' => '_tablet', 'mobile' => '_mobile');
	}
	
	if(!empty($args['control_array_sufix'])){
		$control_array_sufix = '['.$args['control_array_sufix'].']';
	}
	
	// Register settings
	foreach($screens as $_screen => $screen){
		foreach($settings as $setting){
			
			// Skip units for responsive
			if($setting == 'unit' && !empty($screen)){
				continue;
			}
				
			$setting_name = $args['control'];
			
			if($screen_array && count($screens) > 1){
				$setting_name .= $control_array_sufix.'['.$_screen.']';
			}else{
				$setting_name .= $screen.$control_array_sufix;
			}

			$setting_name .= '['.$setting.']';
			$settings_for_control[$setting.$screen] = $setting_name;
			
			$setting_args = array(
				'capability' => $args['capability'],
				'transport' => $args['transport'],
			);
			
			if(!empty($args['setting_type'])){
				$setting_args['type'] = $args['setting_type'];
			}
			
			if(!empty($args['default'])){
				$setting_args['default'] = $args['default'];
			}
			
			$wp_customize->add_setting( $setting_name, $setting_args);
		}
	}
	
	$args['settings'] = $settings_for_control;
	
	$wp_customize->add_control( new Pagelayer_typo_Control(
		$wp_customize, $args['control']. @$args['control_array_sufix'], $args
	));
}

/**
 * Register the padding control.
 *
 * @return void
 */
function pagelayer_register_padding_customizer_control($wp_customize, $args, $screen_array = false){
			
	$settings_for_control = array();
	$screens = array('');
	$control_array_sufix = '';
	
	if(empty($args['setting_parts'])){
		$settings = array('top', 'right', 'bottom', 'left', 'unit');
	}else{
		$settings = $args['setting_parts'];
	}
	
	if(!empty($args['responsive'])){
		$screens = array('desktop' => '', 'tablet' => '_tablet', 'mobile' => '_mobile');
	}
	
	if(!empty($args['control_array_sufix'])){
		$control_array_sufix = '['.$args['control_array_sufix'].']';
	}
	
	// Register settings
	foreach($screens as $_screen => $screen){
		foreach($settings as $setting){
			
			// Skip units for responsive
			if($setting == 'unit' && (!empty($screen) || $screen_array)){
				continue;
			}
			
			$setting_name = $args['control'];
			
			if($screen_array && count($screens) > 1){
				$setting_name .= $control_array_sufix.'['.$_screen.']';
			}else{
				$setting_name .= $screen.$control_array_sufix;
			}
			
			$setting_name .= '['.$setting.']';
			$settings_for_control[$setting.$screen] = $setting_name;
			
			$setting_args = array(
				'capability' => $args['capability'],
				'transport' => $args['transport'],
			);
			
			if(!empty($args['default'])){
				$setting_args['default'] = $args['default'];
			}
			
			if(!empty($args['setting_type'])){
				$setting_args['type'] = $args['setting_type'];
			}
			
			if(!empty($args['sanitize_callback'])){
				$setting_args['sanitize_callback'] = $args['sanitize_callback'];
			}
			
			$wp_customize->add_setting( $setting_name, $setting_args);
		}
	}
	
	// If we save responsive values in same variables
	if($screen_array && !empty($args['units'])){
		$setting_name = $args['control'].$control_array_sufix.'[unit]';
		$settings_for_control['unit'] = $setting_name;
		$setting_args = array(
			'capability' => $args['capability'],
			'transport' => $args['transport'],
		);
			
		if(!empty($args['setting_type'])){
			$setting_args['type'] = $args['setting_type'];
		}
		
		$wp_customize->add_setting( $setting_name, $setting_args);
	}
	
	$args['settings'] = $settings_for_control;
	$wp_customize->add_control( new Pagelayer_Padding_Control(
		$wp_customize, $args['control']. @$args['control_array_sufix'], $args
	));
}

/**
 * Register the slider control.
 *
 * @return void
 */
function pagelayer_register_slider_custoze_control($wp_customize, $args){
			
	$settings_for_control = array();
	$setting = 'slider';
	$screens = array('');
	
	if(!empty($args['responsive'])){
		$screens = array('desktop' => '_desktop', 'tablet' => '_tablet', 'mobile' => '_mobile');
	}
	
	// Register settings
	foreach($screens as $screen => $_screen){
		
		$setting_name = $args['control'];
		
		if(count($screens) > 1){
			$setting_name .= '['.$screen.']';
		}
			
		$settings_for_control[$setting.$_screen] = $setting_name;
			
		$setting_args = array(
			'capability' => $args['capability'],
			'transport' => $args['transport'],
		);

		if(!empty($args['default'])){
			$setting_args['default'] = $args['default'];
		}
			
		if(!empty($args['setting_type'])){
			$setting_args['type'] = $args['setting_type'];
		}
		
		if(!empty($args['sanitize_callback'])){
			$setting_args['sanitize_callback'] = $args['sanitize_callback'];
		}

		$wp_customize->add_setting($setting_name, $setting_args);
	}
	
	// Register setting for units
	if(!empty($args['units'])){
		$setting_name = $args['control'].'[unit]';
		$settings_for_control['unit'] = $setting_name;
		$setting_args = array(
			'capability' => $args['capability'],
			'transport' => $args['transport'],
		);
		
		if(!empty($args['setting_type'])){
			$setting_args['type'] = $args['setting_type'];
		}
		
		$wp_customize->add_setting( $setting_name, $setting_args);
	}
	
	$args['settings'] = $settings_for_control;
	$args['type'] = 'pl_slider';
	
	$wp_customize->add_control( new Pagelayer_Custom_Control( $wp_customize, $args['control'], $args ));
}PK�f\��?��replace-media.phpnu�[���<?php

//////////////////////////////////////////////////////////////
//===========================================================
// template.php
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date:       23rd Jan 2017
// Time:       23:00 hrs
// Site:       http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////

// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
	exit('Hacking Attempt !');
}

//function is called first to select the route 
function pagelayer_replace_page(){
	
	global $pl_error;

	if(!current_user_can('upload_files')){
		wp_die(esc_html__('You do not have permission to upload files.', 'pagelayer'));
	}
	
	$post_id = (int) $_GET['id'];
	
	if(empty($post_id)){
		wp_die(esc_html__('ID not found .', 'pagelayer'));
	}
	
	// Load the attachment
	$post = get_post($post_id);
	
	if(empty($post) || is_wp_error($post)){
		wp_die(esc_html__('ID not found .', 'pagelayer'));
	}
	
	// Authorization check
	if(!current_user_can('edit_post', $post_id)){
		wp_die(esc_html__('You do not have permission to edit this attachment.', 'pagelayer'));
	}
	
	// Process the POST !
	if(isset($_FILES['userfile'])){
	
		if(!check_admin_referer()){
			wp_die('Invalid Nonce');
		}
		
		/** Check if file is uploaded properly **/
		if(!is_uploaded_file($_FILES['userfile']['tmp_name'])){
			$pl_error['upload_error'] = __('No file was uploaded ! Please try again.');
			pagelayer_media_replace_theme();
			return;
		}
		
		if(isset($_FILES['userfile']['error']) && $_FILES['userfile']['error'] > 0){
			$pl_error['upload_error'] = __('There was some error uploading the file ! Please try again.');
			pagelayer_media_replace_theme();
			return;
		}
		
		$filedata = wp_check_filetype_and_ext($_FILES['userfile']['tmp_name'], $_FILES['userfile']['name']);
		
		if ($filedata['ext'] == false){
			$pl_error['ext_error'] = __('The File type could not be determined. Please upload a permitted file type.');
			pagelayer_media_replace_theme();
			return;
		}
		
		$result = pagelayer_replace_attachment($_FILES['userfile']['tmp_name'], $post_id, $err);
		
		if(empty($result)){
			$pl_error['replace_error'] = $err;
			pagelayer_media_replace_theme();
			return;
		}
		
		$redirect_success = admin_url('post.php');
		$redirect_success = add_query_arg(array(
			'action' => 'edit', 
			'post' => $post_id,
		), $redirect_success);
		
		echo '<meta http-equiv="refresh" content="0;url='.$redirect_success.'" />';
	
	}
	
	// Show the theme
	pagelayer_media_replace_theme();
	
}

// Theme of the page
function pagelayer_media_replace_theme(){
	
	global $pl_error;
	
	pagelayer_report_error($pl_error);echo '<br />';
	
	$id = (int) $_GET['id'];
	
	// Authorization check
	if(!current_user_can('edit_post', $id)){
		wp_die(esc_html__('You do not have permission to edit this attachment.', 'pagelayer'));
	}
?>
<div class="wrap">
<h1><?php echo esc_html__("Replace Media File", 'pagelayer'); ?></h1>
<form enctype="multipart/form-data" method="POST">
	<div class="editor-wrapper">
		<section class="image_chooser wrapper">
			<input type="hidden" name="ID" id="ID" value="<?php echo $id ?>" />
			<p><?php echo esc_html__("Choose a file to upload from your computer", 'pagelayer'); ?></p>
			<div class="drop-wrapper">
				<p><input type="file" name="userfile" id="userfile" /></p>
				<?php wp_nonce_field(); ?>
			</div>
		</section>
		<section class="form_controls wrapper">
			<input id="submit" type="submit" class="button button-primary" name="submit" value="<?php echo esc_attr__("Upload", 'pagelayer');?>" />
		</section>
	</div>
</form>
<?php

}

// Replace the uploaded media with the new one
function pagelayer_replace_attachment($file, $post_id, &$error = ''){

	if(function_exists('wp_get_original_image_path')){
		$targetFile = wp_get_original_image_path($post_id);
	}else{
		$targetFile = trim(get_attached_file($post_id, apply_filters( 'pagelayer_unfiltered_get_attached_file', true )));
	}
	
	$fileparts = pathinfo($targetFile);
	$filePath = isset($fileparts['dirname']) ? trailingslashit($fileparts['dirname']) : '';
	$fileName = isset($fileparts['basename']) ? $fileparts['basename'] : '';
	$filedata = wp_check_filetype_and_ext($targetFile, $fileName);
	$fileMime = (isset($filedata['type'])) ? $filedata['type'] : false;
	
	if(empty($targetFile)){
		return false;
	}
	
	if(empty($filePath)){
		$error = 'No folder for the target found !';
		return false;
	}
	
	// Remove the files of the original attachment
	pagelayer_remove_attahment_files($post_id);
	
	$result_moved = move_uploaded_file($file, $targetFile);
	
	if (false === $result_moved){
		$error = sprintf( esc_html__('The uploaded file could not be moved to %1$s. This is most likely an issue with permissions, or upload failed.', 'pagelayer'), $targetFile );
		return false;
	}
	
	$permissions = fileperms($targetFile) & 0777;
	if ($permissions > 0){
		chmod( $targetFile, $permissions ); // restore permissions
	}
	
	$updated = update_attached_file($post_id, $targetFile);
	
	$target_url = wp_get_attachment_url($post_id);
	
	// Run the filter, so other plugins can hook if needed.
	$filtered = apply_filters( 'wp_handle_upload', array(
		'file' => $targetFile,
		'url'  => $target_url,
		'type' => $fileMime,
	), 'sideload');
	
	// Check if file changed during filter. Set changed to attached file meta properly.
	if (isset($filtered['file']) && $filtered['file'] != $targetFile ){
		update_attached_file($post_id, $filtered['file']);
	}

	$metadata = wp_generate_attachment_metadata($post_id, $targetFile);
	wp_update_attachment_metadata($post_id, $metadata);

	return true;
	
}

function pagelayer_remove_attahment_files($post_id){
	
	$meta = wp_get_attachment_metadata( $post_id );

	if (function_exists('wp_get_original_image_path')){ // WP 5.3+
		$fullfilepath = wp_get_original_image_path($post_id);
	}else{
		$fullFilePath = trim(get_attached_file($post_id, apply_filters( 'pagelayer_unfiltered_get_attached_file', true )));
	}

	$backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true );
	$file = $fullFilePath;
	$result = wp_delete_attachment_files($post_id, $meta, $backup_sizes, $file );

	// If attached file is not the same path as file, this indicates a -scaled images is in play.
	$attached_file = get_attached_file($post_id);
	
	if ($file !== $attached_file && file_exists($attached_file)){
		@unlink($attached_file);
	}
}
PK�f\ 	��V�Vfont-options.phpnu�[���<?php

//////////////////////////////////////////////////////////////
//===========================================================
// license.php
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date:	   23rd Jan 2017
// Time:	   23:00 hrs
// Site:	   http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////

// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
	exit('Hacking Attempt !');
}

global $pagelayer, $pl_error;

$pagelayer->fonts['default'] = [''];
	
$query = get_posts([
	'post_type' => PAGELAYER_FONT_POST_TYPE,
	'status' => 'publish',
	'posts_per_page' => -1 // For get all posts
]);

if(!empty($query)){
	$pagelayer->fonts['custom'] = array();
	foreach($query as $key){
		if(!empty($key->post_title)){
			$pagelayer->fonts['custom'][$key->post_name.'_plf'] = $key->post_title;
		}
	}
}

// System fonts
$pagelayer->fonts['system'] = $pagelayer->system_fonts;

// Fonts
$pagelayer->fonts['google'] = ['ABeeZee', 'Abel', 'Abhaya Libre', 'Abril Fatface', 'Aclonica', 'Acme', 'Actor', 'Adamina', 'Advent Pro', 'Aguafina Script', 'Akaya Kanadaka', 'Akaya Telivigala', 'Akronim', 'Aladin', 'Alata', 'Alatsi', 'Aldrich', 'Alef', 'Alegreya', 'Alegreya Sans', 'Alegreya Sans SC', 'Alegreya SC', 'Aleo', 'Alex Brush', 'Alfa Slab One', 'Alice', 'Alike', 'Alike Angular', 'Allan', 'Allerta', 'Allerta Stencil', 'Allison', 'Allura', 'Almarai', 'Almendra', 'Almendra Display', 'Almendra SC', 'Alumni Sans', 'Amarante', 'Amaranth', 'Amatic SC', 'Amethysta', 'Amiko', 'Amiri', 'Amita', 'Anaheim', 'Andada Pro', 'Andika', 'Andika New Basic', 'Angkor', 'Annie Use Your Telescope', 'Anonymous Pro', 'Antic', 'Antic Didone', 'Antic Slab', 'Anton', 'Antonio', 'Arapey', 'Arbutus', 'Arbutus Slab', 'Architects Daughter', 'Archivo', 'Archivo Black', 'Archivo Narrow', 'Are You Serious', 'Aref Ruqaa', 'Arima Madurai', 'Arimo', 'Arizonia', 'Armata', 'Arsenal', 'Artifika', 'Arvo', 'Arya', 'Asap', 'Asap Condensed', 'Asar', 'Asset', 'Assistant', 'Astloch', 'Asul', 'Athiti', 'Atkinson Hyperlegible', 'Atma', 'Atomic Age', 'Aubrey', 'Audiowide', 'Autour One', 'Average', 'Average Sans', 'Averia Gruesa Libre', 'Averia Libre', 'Averia Sans Libre', 'Averia Serif Libre', 'Azeret Mono', 'B612', 'B612 Mono', 'Bad Script', 'Bahiana', 'Bahianita', 'Bai Jamjuree', 'Ballet', 'Baloo 2', 'Baloo Bhai 2', 'Baloo Bhaina 2', 'Baloo Chettan 2', 'Baloo Da 2', 'Baloo Paaji 2', 'Baloo Tamma 2', 'Baloo Tammudu 2', 'Baloo Thambi 2', 'Balsamiq Sans', 'Balthazar', 'Bangers', 'Barlow', 'Barlow Condensed', 'Barlow Semi Condensed', 'Barriecito', 'Barrio', 'Basic', 'Baskervville', 'Battambang', 'Baumans', 'Bayon', 'Be Vietnam', 'Be Vietnam Pro', 'Bebas Neue', 'Belgrano', 'Bellefair', 'Belleza', 'Bellota', 'Bellota Text', 'BenchNine', 'Benne', 'Bentham', 'Berkshire Swash', 'Besley', 'Beth Ellen', 'Bevan', 'Big Shoulders Display', 'Big Shoulders Inline Display', 'Big Shoulders Inline Text', 'Big Shoulders Stencil Display', 'Big Shoulders Stencil Text', 'Big Shoulders Text', 'Bigelow Rules', 'Bigshot One', 'Bilbo', 'Bilbo Swash Caps', 'BioRhyme', 'BioRhyme Expanded', 'Birthstone', 'Birthstone Bounce', 'Biryani', 'Bitter', 'Black And White Picture', 'Black Han Sans', 'Black Ops One', 'Blinker', 'Bodoni Moda', 'Bokor', 'Bona Nova', 'Bonbon', 'Bonheur Royale', 'Boogaloo', 'Bowlby One', 'Bowlby One SC', 'Brawler', 'Bree Serif', 'Brygada 1918', 'Bubblegum Sans', 'Bubbler One', 'Buda', 'Buenard', 'Bungee', 'Bungee Hairline', 'Bungee Inline', 'Bungee Outline', 'Bungee Shade', 'Butcherman', 'Butterfly Kids', 'Cabin', 'Cabin Condensed', 'Cabin Sketch', 'Caesar Dressing', 'Cagliostro', 'Cairo', 'Caladea', 'Calistoga', 'Calligraffitti', 'Cambay', 'Cambo', 'Candal', 'Cantarell', 'Cantata One', 'Cantora One', 'Capriola', 'Caramel', 'Carattere', 'Cardo', 'Carme', 'Carrois Gothic', 'Carrois Gothic SC', 'Carter One', 'Castoro', 'Catamaran', 'Caudex', 'Caveat', 'Caveat Brush', 'Cedarville Cursive', 'Ceviche One', 'Chakra Petch', 'Changa', 'Changa One', 'Chango', 'Charm', 'Charmonman', 'Chathura', 'Chau Philomene One', 'Chela One', 'Chelsea Market', 'Chenla', 'Cherish', 'Cherry Cream Soda', 'Cherry Swash', 'Chewy', 'Chicle', 'Chilanka', 'Chivo', 'Chonburi', 'Cinzel', 'Cinzel Decorative', 'Clicker Script', 'Coda', 'Coda Caption', 'Codystar', 'Coiny', 'Combo', 'Comfortaa', 'Comic Neue', 'Coming Soon', 'Commissioner', 'Concert One', 'Condiment', 'Content', 'Contrail One', 'Convergence', 'Cookie', 'Copse', 'Corben', 'Cormorant', 'Cormorant Garamond', 'Cormorant Infant', 'Cormorant SC', 'Cormorant Unicase', 'Cormorant Upright', 'Courgette', 'Courier Prime', 'Cousine', 'Coustard', 'Covered By Your Grace', 'Crafty Girls', 'Creepster', 'Crete Round', 'Crimson Pro', 'Crimson Text', 'Croissant One', 'Crushed', 'Cuprum', 'Cute Font', 'Cutive', 'Cutive Mono', 'Damion', 'Dancing Script', 'Dangrek', 'Darker Grotesque', 'David Libre', 'Dawning of a New Day', 'Days One', 'Dekko', 'Dela Gothic One', 'Delius', 'Delius Swash Caps', 'Delius Unicase', 'Della Respira', 'Denk One', 'Devonshire', 'Dhurjati', 'Didact Gothic', 'Diplomata', 'Diplomata SC', 'DM Mono', 'DM Sans', 'DM Serif Display', 'DM Serif Text', 'Do Hyeon', 'Dokdo', 'Domine', 'Donegal One', 'Doppio One', 'Dorsa', 'Dosis', 'DotGothic16', 'Dr Sugiyama', 'Duru Sans', 'Dynalight', 'Eagle Lake', 'East Sea Dokdo', 'Eater', 'EB Garamond', 'Economica', 'Eczar', 'El Messiri', 'Electrolize', 'Elsie', 'Elsie Swash Caps', 'Emblema One', 'Emilys Candy', 'Encode Sans', 'Encode Sans Condensed', 'Encode Sans Expanded', 'Encode Sans SC', 'Encode Sans Semi Condensed', 'Encode Sans Semi Expanded', 'Engagement', 'Englebert', 'Enriqueta', 'Ephesis', 'Epilogue', 'Erica One', 'Esteban', 'Euphoria Script', 'Ewert', 'Exo', 'Exo 2', 'Expletus Sans', 'Explora', 'Fahkwang', 'Fanwood Text', 'Farro', 'Farsan', 'Fascinate', 'Fascinate Inline', 'Faster One', 'Fasthand', 'Fauna One', 'Faustina', 'Federant', 'Federo', 'Felipa', 'Fenix', 'Festive', 'Finger Paint', 'Fira Code', 'Fira Mono', 'Fira Sans', 'Fira Sans Condensed', 'Fira Sans Extra Condensed', 'Fjalla One', 'Fjord One', 'Flamenco', 'Flavors', 'Fleur De Leah', 'Fondamento', 'Fontdiner Swanky', 'Forum', 'Francois One', 'Frank Ruhl Libre', 'Fraunces', 'Freckle Face', 'Fredericka the Great', 'Fredoka One', 'Freehand', 'Fresca', 'Frijole', 'Fruktur', 'Fugaz One', 'Fuggles', 'Gabriela', 'Gaegu', 'Gafata', 'Galada', 'Galdeano', 'Galindo', 'Gamja Flower', 'Gayathri', 'Gelasio', 'Gemunu Libre', 'Gentium Basic', 'Gentium Book Basic', 'Geo', 'Georama', 'Geostar', 'Geostar Fill', 'Germania One', 'GFS Didot', 'GFS Neohellenic', 'Gideon Roman', 'Gidugu', 'Gilda Display', 'Girassol', 'Give You Glory', 'Glass Antiqua', 'Glegoo', 'Gloria Hallelujah', 'Glory', 'Gluten', 'Goblin One', 'Gochi Hand', 'Goldman', 'Gorditas', 'Gothic A1', 'Gotu', 'Goudy Bookletter 1911', 'Gowun Batang', 'Gowun Dodum', 'Graduate', 'Grand Hotel', 'Grandstander', 'Gravitas One', 'Great Vibes', 'Grechen Fuemen', 'Grenze', 'Grenze Gotisch', 'Grey Qo', 'Griffy', 'Gruppo', 'Gudea', 'Gugi', 'Gupter', 'Gurajada', 'Habibi', 'Hachi Maru Pop', 'Hahmlet', 'Halant', 'Hammersmith One', 'Hanalei', 'Hanalei Fill', 'Handlee', 'Hanuman', 'Happy Monkey', 'Harmattan', 'Headland One', 'Heebo', 'Henny Penny', 'Hepta Slab', 'Herr Von Muellerhoff', 'Hi Melody', 'Hina Mincho', 'Hind', 'Hind Guntur', 'Hind Madurai', 'Hind Siliguri', 'Hind Vadodara', 'Holtwood One SC', 'Homemade Apple', 'Homenaje', 'Ibarra Real Nova', 'IBM Plex Mono', 'IBM Plex Sans', 'IBM Plex Sans Arabic', 'IBM Plex Sans Condensed', 'IBM Plex Sans Devanagari', 'IBM Plex Sans Hebrew', 'IBM Plex Sans KR', 'IBM Plex Sans Thai', 'IBM Plex Sans Thai Looped', 'IBM Plex Serif', 'Iceberg', 'Iceland', 'IM Fell Double Pica', 'IM Fell Double Pica SC', 'IM Fell DW Pica', 'IM Fell DW Pica SC', 'IM Fell English', 'IM Fell English SC', 'IM Fell French Canon', 'IM Fell French Canon SC', 'IM Fell Great Primer', 'IM Fell Great Primer SC', 'Imbue', 'Imprima', 'Inconsolata', 'Inder', 'Indie Flower', 'Inika', 'Inknut Antiqua', 'Inria Sans', 'Inria Serif', 'Inter', 'Irish Grover', 'Istok Web', 'Italiana', 'Italianno', 'Itim', 'Jacques Francois', 'Jacques Francois Shadow', 'Jaldi', 'JetBrains Mono', 'Jim Nightshade', 'Jockey One', 'Jolly Lodger', 'Jomhuria', 'Jomolhari', 'Josefin Sans', 'Josefin Slab', 'Jost', 'Joti One', 'Jua', 'Judson', 'Julee', 'Julius Sans One', 'Junge', 'Jura', 'Just Another Hand', 'Just Me Again Down Here', 'K2D', 'Kadwa', 'Kaisei Decol', 'Kaisei HarunoUmi', 'Kaisei Opti', 'Kaisei Tokumin', 'Kalam', 'Kameron', 'Kanit', 'Kantumruy', 'Karantina', 'Karla', 'Karma', 'Katibeh', 'Kaushan Script', 'Kavivanar', 'Kavoon', 'Kdam Thmor', 'Keania One', 'Kelly Slab', 'Kenia', 'Khand', 'Khmer', 'Khula', 'Kirang Haerang', 'Kite One', 'Kiwi Maru', 'Klee One', 'Knewave', 'Kodchasan', 'Koh Santepheap', 'KoHo', 'Kosugi', 'Kosugi Maru', 'Kotta One', 'Koulen', 'Kranky', 'Kreon', 'Kristi', 'Krona One', 'Krub', 'Kufam', 'Kulim Park', 'Kumar One', 'Kumar One Outline', 'Kumbh Sans', 'Kurale', 'La Belle Aurore', 'Lacquer', 'Laila', 'Lakki Reddy', 'Lalezar', 'Lancelot', 'Langar', 'Lateef', 'Lato', 'League Script', 'Leckerli One', 'Ledger', 'Lekton', 'Lemon', 'Lemonada', 'Lexend', 'Lexend Deca', 'Lexend Exa', 'Lexend Giga', 'Lexend Mega', 'Lexend Peta', 'Lexend Tera', 'Lexend Zetta', 'Libre Barcode 128', 'Libre Barcode 128 Text', 'Libre Barcode 39', 'Libre Barcode 39 Extended', 'Libre Barcode 39 Extended Text', 'Libre Barcode 39 Text', 'Libre Barcode EAN13 Text', 'Libre Baskerville', 'Libre Caslon Display', 'Libre Caslon Text', 'Libre Franklin', 'Life Savers', 'Lilita One', 'Lily Script One', 'Limelight', 'Linden Hill', 'Literata', 'Liu Jian Mao Cao', 'Livvic', 'Lobster', 'Lobster Two', 'Londrina Outline', 'Londrina Shadow', 'Londrina Sketch', 'Londrina Solid', 'Long Cang', 'Lora', 'Love Ya Like A Sister', 'Loved by the King', 'Lovers Quarrel', 'Luckiest Guy', 'Lusitana', 'Lustria', 'M PLUS 1p', 'M PLUS Rounded 1c', 'Ma Shan Zheng', 'Macondo', 'Macondo Swash Caps', 'Mada', 'Magra', 'Maiden Orange', 'Maitree', 'Major Mono Display', 'Mako', 'Mali', 'Mallanna', 'Mandali', 'Manjari', 'Manrope', 'Mansalva', 'Manuale', 'Marcellus', 'Marcellus SC', 'Marck Script', 'Margarine', 'Markazi Text', 'Marko One', 'Marmelad', 'Martel', 'Martel Sans', 'Marvel', 'Mate', 'Mate SC', 'Maven Pro', 'McLaren', 'Meddon', 'MedievalSharp', 'Medula One', 'Meera Inimai', 'Megrim', 'Meie Script', 'Merienda', 'Merienda One', 'Merriweather', 'Merriweather Sans', 'Metal', 'Metal Mania', 'Metamorphous', 'Metrophobic', 'Michroma', 'Milonga', 'Miltonian', 'Miltonian Tattoo', 'Mina', 'Miniver', 'Miriam Libre', 'Mirza', 'Miss Fajardose', 'Mitr', 'Modak', 'Modern Antiqua', 'Mogra', 'Molengo', 'Molle', 'Monda', 'Monofett', 'Monoton', 'Monsieur La Doulaise', 'Montaga', 'MonteCarlo', 'Montez', 'Montserrat', 'Montserrat Alternates', 'Montserrat Subrayada', 'Moul', 'Moulpali', 'Mountains of Christmas', 'Mouse Memoirs', 'Mr Bedfort', 'Mr Dafoe', 'Mr De Haviland', 'Mrs Saint Delafield', 'Mrs Sheppards', 'Mukta', 'Mukta Mahee', 'Mukta Malar', 'Mukta Vaani', 'Mulish', 'MuseoModerno', 'Mystery Quest', 'Nanum Brush Script', 'Nanum Gothic', 'Nanum Gothic Coding', 'Nanum Myeongjo', 'Nanum Pen Script', 'Nerko One', 'Neucha', 'Neuton', 'New Rocker', 'New Tegomin', 'News Cycle', 'Newsreader', 'Niconne', 'Niramit', 'Nixie One', 'Nobile', 'Nokora', 'Norican', 'Nosifer', 'Notable', 'Nothing You Could Do', 'Noticia Text', 'Noto Kufi Arabic', 'Noto Music', 'Noto Naskh Arabic', 'Noto Nastaliq Urdu', 'Noto Rashi Hebrew', 'Noto Sans', 'Noto Sans Adlam', 'Noto Sans Adlam Unjoined', 'Noto Sans Anatolian Hieroglyphs', 'Noto Sans Arabic', 'Noto Sans Armenian', 'Noto Sans Avestan', 'Noto Sans Balinese', 'Noto Sans Bamum', 'Noto Sans Bassa Vah', 'Noto Sans Batak', 'Noto Sans Bengali', 'Noto Sans Bhaiksuki', 'Noto Sans Brahmi', 'Noto Sans Buginese', 'Noto Sans Buhid', 'Noto Sans Canadian Aboriginal', 'Noto Sans Carian', 'Noto Sans Caucasian Albanian', 'Noto Sans Chakma', 'Noto Sans Cham', 'Noto Sans Cherokee', 'Noto Sans Coptic', 'Noto Sans Cuneiform', 'Noto Sans Cypriot', 'Noto Sans Deseret', 'Noto Sans Devanagari', 'Noto Sans Display', 'Noto Sans Duployan', 'Noto Sans Egyptian Hieroglyphs', 'Noto Sans Elbasan', 'Noto Sans Elymaic', 'Noto Sans Georgian', 'Noto Sans Glagolitic', 'Noto Sans Gothic', 'Noto Sans Grantha', 'Noto Sans Gujarati', 'Noto Sans Gunjala Gondi', 'Noto Sans Gurmukhi', 'Noto Sans Hanifi Rohingya', 'Noto Sans Hanunoo', 'Noto Sans Hatran', 'Noto Sans Hebrew', 'Noto Sans Hong Kong', 'Noto Sans Imperial Aramaic', 'Noto Sans Indic Siyaq Numbers', 'Noto Sans Inscriptional Pahlavi', 'Noto Sans Inscriptional Parthian', 'Noto Sans Japanese', 'Noto Sans Javanese', 'Noto Sans Kaithi', 'Noto Sans Kannada', 'Noto Sans Kayah Li', 'Noto Sans Kharoshthi', 'Noto Sans Khmer', 'Noto Sans Khojki', 'Noto Sans Khudawadi', 'Noto Sans Korean', 'Noto Sans Lao', 'Noto Sans Lepcha', 'Noto Sans Limbu', 'Noto Sans Linear A', 'Noto Sans Linear B', 'Noto Sans Lisu', 'Noto Sans Lycian', 'Noto Sans Lydian', 'Noto Sans Mahajani', 'Noto Sans Malayalam', 'Noto Sans Mandaic', 'Noto Sans Manichaean', 'Noto Sans Marchen', 'Noto Sans Masaram Gondi', 'Noto Sans Math', 'Noto Sans Mayan Numerals', 'Noto Sans Medefaidrin', 'Noto Sans Meroitic', 'Noto Sans Miao', 'Noto Sans Modi', 'Noto Sans Mongolian', 'Noto Sans Mono', 'Noto Sans Mro', 'Noto Sans Multani', 'Noto Sans Myanmar', 'Noto Sans Nabataean', 'Noto Sans New Tai Lue', 'Noto Sans Newa', 'Noto Sans Nüshu', 'Noto Sans Ogham', 'Noto Sans Ol Chiki', 'Noto Sans Old Hungarian', 'Noto Sans Old Italic', 'Noto Sans Old North Arabian', 'Noto Sans Old Permic', 'Noto Sans Old Persian', 'Noto Sans Old Sogdian', 'Noto Sans Old South Arabian', 'Noto Sans Old Turkic', 'Noto Sans Oriya', 'Noto Sans Osage', 'Noto Sans Osmanya', 'Noto Sans Pahawh Hmong', 'Noto Sans Palmyrene', 'Noto Sans Pau Cin Hau', 'Noto Sans Phags Pa', 'Noto Sans Phoenician', 'Noto Sans Psalter Pahlavi', 'Noto Sans Rejang', 'Noto Sans Runic', 'Noto Sans Samaritan', 'Noto Sans Saurashtra', 'Noto Sans Sharada', 'Noto Sans Shavian', 'Noto Sans Siddham', 'Noto Sans Simplified Chinese', 'Noto Sans Sinhala', 'Noto Sans Sogdian', 'Noto Sans Sora Sompeng', 'Noto Sans Soyombo', 'Noto Sans Sundanese', 'Noto Sans Syloti Nagri', 'Noto Sans Symbols', 'Noto Sans Symbols 2', 'Noto Sans Syriac', 'Noto Sans Tagalog', 'Noto Sans Tagbanwa', 'Noto Sans Tai Le', 'Noto Sans Tai Tham', 'Noto Sans Tai Viet', 'Noto Sans Takri', 'Noto Sans Tamil', 'Noto Sans Tamil Supplement', 'Noto Sans Telugu', 'Noto Sans Thaana', 'Noto Sans Thai', 'Noto Sans Thai Looped', 'Noto Sans Tifinagh', 'Noto Sans Tirhuta', 'Noto Sans Traditional Chinese', 'Noto Sans Ugaritic', 'Noto Sans Vai', 'Noto Sans Wancho', 'Noto Sans Warang Citi', 'Noto Sans Yi', 'Noto Sans Zanabazar Square', 'Noto Serif', 'Noto Serif Ahom', 'Noto Serif Armenian', 'Noto Serif Balinese', 'Noto Serif Bengali', 'Noto Serif Devanagari', 'Noto Serif Display', 'Noto Serif Dogra', 'Noto Serif Ethiopic', 'Noto Serif Georgian', 'Noto Serif Grantha', 'Noto Serif Gujarati', 'Noto Serif Gurmukhi', 'Noto Serif Hebrew', 'Noto Serif Japanese', 'Noto Serif Kannada', 'Noto Serif Khmer', 'Noto Serif KR', 'Noto Serif Lao', 'Noto Serif Malayalam', 'Noto Serif Myanmar', 'Noto Serif Nyiakeng Puachue Hmong', 'Noto Serif Simplified Chinese', 'Noto Serif Sinhala', 'Noto Serif Tamil', 'Noto Serif Tangut', 'Noto Serif Telugu', 'Noto Serif Thai', 'Noto Serif Tibetan', 'Noto Serif Traditional Chinese', 'Noto Serif Yezidi', 'Noto Traditional Nüshu', 'Nova Cut', 'Nova Flat', 'Nova Mono', 'Nova Oval', 'Nova Round', 'Nova Script', 'Nova Slim', 'Nova Square', 'NTR', 'Numans', 'Nunito', 'Nunito Sans', 'Odibee Sans', 'Odor Mean Chey', 'Offside', 'Oi', 'Old Standard TT', 'Oldenburg', 'Oleo Script', 'Oleo Script Swash Caps', 'Open Sans', 'Open Sans Condensed', 'Oranienbaum', 'Orbitron', 'Oregano', 'Orelega One', 'Orienta', 'Original Surfer', 'Oswald', 'Otomanopee One', 'Over the Rainbow', 'Overlock', 'Overlock SC', 'Overpass', 'Overpass Mono', 'Ovo', 'Oxanium', 'Oxygen', 'Oxygen Mono', 'Pacifico', 'Padauk', 'Palanquin', 'Palanquin Dark', 'Palette Mosaic', 'Pangolin', 'Paprika', 'Parisienne', 'Passero One', 'Passion One', 'Pathway Gothic One', 'Patrick Hand', 'Patrick Hand SC', 'Pattaya', 'Patua One', 'Pavanam', 'Paytone One', 'Peddana', 'Peralta', 'Permanent Marker', 'Petit Formal Script', 'Petrona', 'Philosopher', 'Piazzolla', 'Piedra', 'Pinyon Script', 'Pirata One', 'Plaster', 'Play', 'Playball', 'Playfair Display', 'Playfair Display SC', 'Podkova', 'Poiret One', 'Poller One', 'Poly', 'Pompiere', 'Pontano Sans', 'Poor Story', 'Poppins', 'Port Lligat Sans', 'Port Lligat Slab', 'Potta One', 'Pragati Narrow', 'Prata', 'Preahvihear', 'Press Start 2P', 'Pridi', 'Princess Sofia', 'Prociono', 'Prompt', 'Prosto One', 'Proza Libre', 'PT Mono', 'PT Sans', 'PT Sans Caption', 'PT Sans Narrow', 'PT Serif', 'PT Serif Caption', 'Public Sans', 'Puritan', 'Purple Purse', 'Qahiri', 'Quando', 'Quantico', 'Quattrocento', 'Quattrocento Sans', 'Questrial', 'Quicksand', 'Quintessential', 'Qwigley', 'Racing Sans One', 'Radley', 'Rajdhani', 'Rakkas', 'Raleway', 'Raleway Dots', 'Ramabhadra', 'Ramaraja', 'Rambla', 'Rammetto One', 'Rampart One', 'Ranchers', 'Rancho', 'Ranga', 'Rasa', 'Rationale', 'Ravi Prakash', 'Recursive', 'Red Hat Display', 'Red Hat Text', 'Red Rose', 'Redressed', 'Reem Kufi', 'Reenie Beanie', 'Reggae One', 'Revalia', 'Rhodium Libre', 'Ribeye', 'Ribeye Marrow', 'Righteous', 'Risque', 'Roboto', 'Roboto Condensed', 'Roboto Mono', 'Roboto Slab', 'Rochester', 'Rock Salt', 'RocknRoll One', 'Rokkitt', 'Romanesco', 'Ropa Sans', 'Rosario', 'Rosarivo', 'Rouge Script', 'Rowdies', 'Rozha One', 'Rubik', 'Rubik Beastly', 'Rubik Mono One', 'Ruda', 'Rufina', 'Ruge Boogie', 'Ruluko', 'Rum Raisin', 'Ruslan Display', 'Russo One', 'Ruthie', 'Rye', 'Sacramento', 'Sahitya', 'Sail', 'Saira', 'Saira Condensed', 'Saira Extra Condensed', 'Saira Semi Condensed', 'Saira Stencil One', 'Salsa', 'Sanchez', 'Sancreek', 'Sansita', 'Sansita Swashed', 'Sarabun', 'Sarala', 'Sarina', 'Sarpanch', 'Satisfy', 'Sawarabi Gothic', 'Sawarabi Mincho', 'Scada', 'Scheherazade', 'Scheherazade New', 'Schoolbell', 'Scope One', 'Seaweed Script', 'Secular One', 'Sedgwick Ave', 'Sedgwick Ave Display', 'Sen', 'Sevillana', 'Seymour One', 'Shadows Into Light', 'Shadows Into Light Two', 'Shanti', 'Share', 'Share Tech', 'Share Tech Mono', 'Shippori Mincho', 'Shippori Mincho B1', 'Shojumaru', 'Short Stack', 'Shrikhand', 'Siemreap', 'Sigmar One', 'Signika', 'Signika Negative', 'Simonetta', 'Single Day', 'Sintony', 'Sirin Stencil', 'Six Caps', 'Skranji', 'Slabo 13px', 'Slabo 27px', 'Slackey', 'Smokum', 'Smythe', 'Sniglet', 'Snippet', 'Snowburst One', 'Sofadi One', 'Sofia', 'Solway', 'Song Myung', 'Sonsie One', 'Sora', 'Sorts Mill Goudy', 'Source Code Pro', 'Source Sans Pro', 'Source Serif Pro', 'Space Grotesk', 'Space Mono', 'Spartan', 'Special Elite', 'Spectral', 'Spectral SC', 'Spicy Rice', 'Spinnaker', 'Spirax', 'Squada One', 'Sree Krushnadevaraya', 'Sriracha', 'Srisakdi', 'Staatliches', 'Stalemate', 'Stalinist One', 'Stardos Stencil', 'Stick', 'Stick No Bills', 'Stint Ultra Condensed', 'Stint Ultra Expanded', 'STIX Two Text', 'Stoke', 'Strait', 'Style Script', 'Stylish', 'Sue Ellen Francisco', 'Suez One', 'Sulphur Point', 'Sumana', 'Sunflower', 'Sunshiney', 'Supermercado One', 'Sura', 'Suranna', 'Suravaram', 'Suwannaphum', 'Swanky and Moo Moo', 'Syncopate', 'Syne', 'Syne Mono', 'Syne Tactile', 'Tajawal', 'Tangerine', 'Taprom', 'Tauri', 'Taviraj', 'Teko', 'Telex', 'Tenali Ramakrishna', 'Tenor Sans', 'Text Me One', 'Texturina', 'Thasadith', 'The Girl Next Door', 'Tienne', 'Tillana', 'Timmana', 'Tinos', 'Titan One', 'Titillium Web', 'Tomorrow', 'Tourney', 'Trade Winds', 'Train One', 'Trirong', 'Trispace', 'Trocchi', 'Trochut', 'Truculenta', 'Trykker', 'Tulpen One', 'Turret Road', 'Ubuntu', 'Ubuntu Condensed', 'Ubuntu Mono', 'Uchen', 'Ultra', 'Uncial Antiqua', 'Underdog', 'Unica One', 'UnifrakturCook', 'UnifrakturMaguntia', 'Unkempt', 'Unlock', 'Unna', 'Urbanist', 'Vampiro One', 'Varela', 'Varela Round', 'Varta', 'Vast Shadow', 'Vesper Libre', 'Viaoda Libre', 'Vibes', 'Vibur', 'Vidaloka', 'Viga', 'Voces', 'Volkhov', 'Vollkorn', 'Vollkorn SC', 'Voltaire', 'VT323', 'Waiting for the Sunrise', 'Wallpoet', 'Walter Turncoat', 'Warnes', 'Wellfleet', 'Wendy One', 'WindSong', 'Wire One', 'Work Sans', 'Xanh Mono', 'Yaldevi', 'Yanone Kaffeesatz', 'Yantramanav', 'Yatra One', 'Yellowtail', 'Yeon Sung', 'Yeseva One', 'Yesteryear', 'Yomogi', 'Yrsa', 'Yusei Magic', 'ZCOOL KuaiLe', 'ZCOOL QingKe HuangYou', 'ZCOOL XiaoWei', 'Zen Dots', 'Zen Loop', 'Zen Tokyo Zoo', 'Zeyada', 'Zhi Mang Xing', 'Zilla Slab', 'Zilla Slab Highlight'];
	
$pagelayer->font_style = ['' => 'Default',
						'normal' => 'Normal',
						'italic' => 'Italic',
						'oblique' => 'Oblique'];
	
$pagelayer->text_transform = ['' => 'Default',
						'none' => 'None',
						'capitalize' => 'Capitalize',
						'lowercase' => 'Lowercase',
						'uppercase' => 'Uppercase'];
	
$pagelayer->font_weight = ['' => 'Default',
						'100' => '100 Thin',
						'200' => '200 Extra Light',
						'300' => '300 Light',
						'400' => '400 Normal',
						'500' => '500 Medium',
						'600' => '600 Semi Bold',
						'700' => '700 Bold',
						'800' => '800 Extra Bold',
						'900' => '900 Ultra Bold'];
	
$pagelayer->text_decoration_line = ['' => 'Default',
						'none' => 'None',
						'overline' => 'Overline',
						'line-through' => 'Line-through',
						'underline' => 'Underline',
						'underline overline' => 'Underline and Overline',
						];
	
$pagelayer->text_decoration_style = ['' => 'Default',
						'solid' => 'Solid',
						'double' => 'Double',
						'dotted' => 'Dotted',
						'dashed' => 'Dashed',
						'wavy' => 'Wavy',
						];PK�f\�I�v#v#
live-body.phpnu�[���<?php

//////////////////////////////////////////////////////////////
//===========================================================
// live.php
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date:       23rd Jan 2017
// Time:       23:00 hrs
// Site:       http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////

// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
	exit('Hacking Attempt !');
}


function pagelayer_live_body(){

global $post, $pagelayer;
	
	$icons = pagelayer_enabled_icons();
	$icons_list = array();
	
	// Load all icons
	foreach($icons as $icon){
		$icons_list[] = $icon.'.min.css';
	}
	
	$css_url = admin_url('admin-ajax.php?action=pagelayer_givecss&pagelayer_nonce=1&');
	if(pagelayer_enable_giver()){
		$css_url = PAGELAYER_CSS.'/givecss.php?';
	}
	
	$dark_mode = get_option('pagelayer_enable_dark_mode');
	$body_class = '';
	if(!empty($dark_mode)){
		$body_class = 'pagelayer-dark';
	};
	
	if(defined('SITEPAD')){
		$body_class .= ' sitepad-body';
	}
	
	$shortcut_groups = [
		'general_shortcuts' => [
			'undo' => 'Ctrl+Z',
			'redo' => 'Ctrl+Y',
			'save_post' => 'Ctrl+S',
			'copy_widget' => 'Ctrl+C',
			'paste_widget' => 'Ctrl+V',
			'duplicate_widget' => 'Ctrl+D',
			'delete_widget' => 'Delete'
		]
	];
	
	echo '
<html>
<head>
	<link href="https://fonts.googleapis.com/css?family=Roboto&display=swap" rel="stylesheet"> 
	<link rel="stylesheet" href="'.$css_url.'give=pagelayer-editor.css,trumbowyg.min.css,pagelayer-icons.css,'.implode(',' ,$icons_list).'&ver='.PAGELAYER_VERSION.'">';
	
	do_action('pagelayer_live_body_head');
	
	// Brand Name
	$brand = strtoupper($pagelayer->BRAND_TEXT);
	$brand = str_split($brand);
	
	echo '
<style>
/*Set responsive variables*/
.pagelayer-screen-tablet{
width: '. $pagelayer->settings['tablet_breakpoint'] .'px;
}
.pagelayer-screen-mobile{
width: '. $pagelayer->settings['mobile_breakpoint'] .'px;
}
.pagelayer-errorBox-support{
text-decoration:none;
}
</style>
</head>

	<body class="pagelayer-normalize pagelayer-body '.$body_class.'">
<div class="pagelayer-errorBox">
	<div class="pagelayer-errorBox-close"><i class="fas fa-times"></i></div>
	<div class="pagelayer-errorBox-main">
		<h2><i class="fas fa-times"></i>'.__pl('error').'</h2>
		<div class="pagelayer-errorBox-content"></div>
	</div>
	<div class="pagelayer-errorBox-resolve">
		<p>'.__pl('error_submitting').'</p>
		<button type="button" class="pagelayer-errorBox-copy" onclick="pagelayer_copy_error(event)">'.__pl('copy').'</button>
		<a type="button" class="pagelayer-errorBox-support"  href="'. $pagelayer->support .'" target="_bank">'.__pl('support').'</a>
	</div>
</div>
<div id="pagelayer-loader-wrapper">
	<div class="pagelayer-animation-section">
		<div class="pagelayer-loader">
			<div class="pagelayer-percent-parent">
				<div class="pagelayer-percent">10<sup>%</sup></div>
			</div>
		</div>
		<div class="pagelayer-txt-loading">';
			
			foreach($brand as $k => $v){
				echo '<span data-text-preloader="'.$v.'" class="letters-loading">'.$v.'</span>';
			}
			
		echo '</div>
	</div>
</div>

<table class="pagelayer-normalize pagelayer-body-table" cellpadding="0" cellspacing="0">
<tr>
	<td valign="top" width="270" class="pagelayer-leftbar-table">
		<table class="pagelayer-normalize" cellpadding="0" cellspacing="0">
			<tr class="pagelayer-close-bar">
				<td>
					<div class="pagelayer-close-bar-icons">
						<i class="pagelayer-leftbar-minimize fa fa-minus"></i>
						<i class="pagelayer-leftbar-close fa fa-close"></i>
					</div>
				</td>
			</tr>
			<tr height="45">
				<td class="pagelayer-topbar-holder" valign="middle" align="center">
					<span class="pagelayer-options-icon pli pli-menu"></span>
					<div class="pagelayer-elpd-header" style="display:none">
						<div class="pagelayer-elpd-close"><i class="pli pli-cross" aria-hidden="true"></i></div>
						<div class="pagelayer-elpd-title pagelayer-topbar-mover">Edit</div>
					</div>
					<div class="pagelayer-logo">
						<img src="'.$pagelayer->LOGO.'" width="28" /><span class="pagelayer-logo-text pagelayer-topbar-mover">'.$pagelayer->BRAND_TEXT.(defined('PAGELAYER_PREMIUM') && strtolower($pagelayer->BRAND_TEXT) == 'pagelayer' ? '<sup style="margin: 3px; font-size: 12px; letter-spacing: 1px; font-family: "Roboto";">Pro</sup>' : '').'</span>
						<span class="pagelayer-settings-icon pli pli-service" aria-hidden="true"></span>
					</div>
				</td>
			</tr>
			<tr height="*" valign="top">
				<td style="position: relative;"><div class="pagelayer-leftbar-holder"></div></td>
			</tr>
			<tr height="35" class="pagelayer-bottombar-row">
				<td><div class="pagelayer-bottombar-holder"></div></td>
			</tr>
		</table>
		<div class="pagelayer-leftbar-toggle">&lsaquo;</div>
	</td>
	<td class="pagelayer-iframe" valign="top">
		<div class="pagelayer-iframe-top-bar">';
		do_action('pagelayer_iframe_top_bar');
echo '
		</div>
		<div class="pagelayer-iframe-holder">
			<iframe src="'.(pagelayer_shortlink(0).'&pagelayer-iframe=1&'.$_SERVER['QUERY_STRING']).'" class="pagelayer-normalize skip-lazy" id="pagelayer-iframe"></iframe>
		</div>
	</td>
</tr>
</table>

<div class="pagelayer-pro-notice">';
	pagelayer_show_pro_div('Premium Feature<span class="pli pli-cross pagelayer-pro-x"></span>', '', 0);
echo '</div>
<div class="pagelayer-editor-notice"></div>
<div class="pagelayer-props-modal">
	<div class="pagelayer-props-holder">
		<div class="pagelayer-props-wrap">
			<div class="pagelayer-props-loading-screen"></div>
			<i class="pagelayer-props-modal-close pli pli-cross" aria-hidden="true"></i>
		</div>
	</div>
</div>
<script>
var pagelayer_iframe_cw = document.getElementById("pagelayer-iframe").contentWindow;
var start_time = new Date().getTime();

// Show loading progress
function loader(ran) {
	var inner = document.getElementsByClassName("pagelayer-percent")[0];
	var w = 0;
	var t = setInterval(function() {
		w = w + 1;
		inner.innerHTML = (w+"<sup>%</sup>");
		if (w === ran || inner.getAttribute("loaded") == "1"){
			clearInterval(t);
			w = 0;
		}
	}, 50);
}
loader(90);

function $p(sel){
	return pagelayer_iframe_cw.pagelayer.$$(sel);
}

// Load the window if necessary i.e. an error in the JS of the iframe
function onIframeLoad(){
	setTimeout(function(){
		force_pagelayer_start();
	}, 5000);
}

function force_pagelayer_start(){
try{
	if(pagelayer_iframe_cw.pagelayer.loaded == 1){
		return;
	}
	pagelayer_iframe_cw.pagelayer_start();
	var end_time = new Date().getTime();
	var diff = (end_time - start_time) / 1000;
	console.log("['.$pagelayer->BRAND_TEXT.'] Live Body had to load after : "+diff+" seconds");

// If this fails, lets just hide the loader
}catch(e){
	alert("Fatal error within the '.$pagelayer->BRAND_TEXT.' iFrame as pagelayer object not found ! Please contact '.$pagelayer->BRAND_TEXT.' support");
	document.getElementById("pagelayer-loader-wrapper").remove();
}
}

document.getElementById("pagelayer-iframe").onload = onIframeLoad;

// ErrorBox content copy function
function pagelayer_copy_error(){
	var tempInput = document.createElement("textarea");
	tempInput.value = document.querySelector(".pagelayer-errorBox-content").innerText;
	document.body.appendChild(tempInput);
	tempInput.select();
	document.execCommand("copy");
	document.body.removeChild(tempInput);
	alert("'.__pl('copy_success').'");
}

</script>

<div class="pagelayer-editor-modal pagelayer-shortcuts-modal">
	<div class="pagelayer-editor-modal-wrap">
		<div class="pagelayer-editor-modal-header">
			<h2>'.__pl('keyboard_shortcuts').'</h2>
			<span class="pagelayer-editor-modal-close-icon"><i class="fas fa-times"></i></span>
		</div>
		<div class="pagelayer-editor-modal-body">';
			foreach($shortcut_groups as $grp_name => $group){
			
				if(empty($group)) {
					return;
				}
				
				echo '<div class="pagelayer-edt-modal-block">'. (!empty($grp_name)  ? '<h3>'.__pl($grp_name).'</h3>' :'' ) .'<ul>';
				
				foreach($group as $desc => $shortcut) {
					echo '<li><span class="pagelayer-keyboard-shortcut-desc">'.__pl($desc).'</span>
					<span class="pagelayer-keyboard-shortcut-keys">';
					
					//Considering the whole shortcut as a single key
					$key = '<span>'.$shortcut.'</span>';
					
					//replacing "+" and "," from the string to put it inside <span>
					$key = preg_replace('/\+/', '</span> + <span>', $key);
					$key = preg_replace('/\,/', '</span><span style="display:block; margin-top:10px;">', $key);
						
					echo $key.'</span></li>';
				}
				
				echo '</ul></div>';
			}
			
		echo '</div>
	</div>
</div>
</body>';

die();

}PK�f\��66live.phpnu�[���<?php

//////////////////////////////////////////////////////////////
//===========================================================
// live.php
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date:       23rd Jan 2017
// Time:       23:00 hrs
// Site:       http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////

// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
	exit('Hacking Attempt !');
}


class PageLayer_LiveEditor{

	// The constructor
	function __construct() {

		global $pagelayer;
		
		// Convert the post to a Pagelayer Post first
		$this->check_post();

		// Add the shortcodes
		// TODO : Make a json file
		add_action('wp_head', array($this, 'wp_head'), 999);

		// Add the Body Class Filter
		//add_filter('body_class', array($this, 'body_class'));

		// Add the content handler
		add_filter('the_content', array($this, 'the_content'), 999999);
		
		// Skip do_blocks for invalid blocks
		add_filter( 'pre_render_block', array($this, 'pre_do_render_block'), 10, 3 );
		
		// Skip do_shortcode for invalid shortcodes
		add_filter( 'pre_do_shortcode_tag',  array($this, 'pre_do_shortcode_tag'), 10, 4 );
		
		// Build the Shortcodes MD5 for cache
		$scmd5 = md5(json_encode($pagelayer->shortcodes).json_encode($pagelayer->groups).json_encode($pagelayer->styles));
		
		$premium_js = apply_filters('pagelayer_editor_give_js', '');
		$premium_css = apply_filters('pagelayer_editor_give_css', '');
		
		// Enqueue our Editor's JS
		wp_register_script('pagelayer-editor', admin_url( 'admin-ajax.php?action=pagelayer_givejs' ).'&give=pagelayer-editor.js,widgets.js,properties.js,base-64.min.js,slimscroll.js,vanilla-picker.min.js,trumbowyg.js,trumbowyg.fontfamily.js,trumbowyg-pagelayer.js,tlite.min.js,pagelayer-pen.js'.$premium_js.'&pagelayer_nonce=1&scmd5='.$scmd5, array('jquery'), PAGELAYER_VERSION);
		
		wp_enqueue_script('pagelayer-editor');

		$css_url = admin_url('admin-ajax.php?action=pagelayer_givecss&pagelayer_nonce=1&');
		if(pagelayer_enable_giver()){
			$css_url = PAGELAYER_CSS.'/givecss.php?';
		}

		// Enqueue the Editor's CSS
		wp_register_style('pagelayer-editor', $css_url.'give=pagelayer-editor-frontend.css,pagelayer-pen.css,'.(defined('PAGELAYER_PREMIUM') ? ',owl.theme.default.min.css,owl.carousel.min.css' : '').$premium_css, array(), PAGELAYER_VERSION);
		wp_enqueue_style('pagelayer-editor');

		// Enqueue the DateTime picker CSS
		/* wp_register_style('datetime-picker', PAGELAYER_CSS.'/datetime-picker.css', array(), PAGELAYER_VERSION);
		wp_enqueue_style('datetime-picker'); */

		// Enqueue the media library
		if(!did_action('wp_enqueue_media')){
			wp_enqueue_media();
		}

		// Force the Frontend CSS and JS if not already loaded
		pagelayer_enqueue_frontend(true);

		// Hide Admin Bar
		show_admin_bar(false);
		remove_action('wp_head', '_admin_bar_bump_cb');
		
		// Load custom widgets
		do_action('pagelayer_custom_editor_enqueue');

		// Add the footer scripts
		add_action('wp_footer', array($this, 'wp_footer'), 1);

	}

	// Add our body class
	function body_class($classes){
		return array_merge($classes, array('pagelayer-body'));
	}

	// Header function to add certain things
	function wp_head(){

		global $pagelayer, $post, $wp_query, $_wp_post_type_features;
		
		// Export the post props
		$_post = clone $post;
		
		unset($_post->post_content);
		
		// Add template type
		if(!empty($pagelayer->template_editor)){
			$_post->pagelayer_template_type = get_post_meta($_post->ID, 'pagelayer_template_type', true); 	
		}
		
		$returnURL = ($_post->post_type == 'post' ? admin_url('edit.php') : admin_url('edit.php?post_type='.$_post->post_type) );
		
		// Get CAPTCHA site key
		$pagelayer_recaptch_site_key = get_option('pagelayer_google_captcha');
		
		$pro_url = defined('POPULARFX_PRO_URL') ? POPULARFX_PRO_URL : PAGELAYER_PRO_PRICE_URL;
		$pro_txt = defined('POPULARFX_PRO_URL') ? 'PopularFX Pro' : 'Pagelayer Pro';
		$post_type = get_post_type_object($post->post_type);
		$post_type_name = (!empty($post_type->labels->singular_name)) ? $post_type->labels->singular_name : ucfirst($post_type->name);
		
		// Create list of nav menus and it's items list
		$pagelayer_menus_items_list = array();
		$menus = wp_get_nav_menus();
		
		$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
		
		foreach($menus as $menu){
			
			if(!is_nav_menu($menu)){
				continue;
			}

			$pagelayer_menus_items_list[$menu->term_id] = wp_get_nav_menu_items($menu->term_id, array('post_status' => 'any'));
		}
		
		echo '
<script type="text/javascript">
pagelayer_ver = "'.PAGELAYER_VERSION.'";
pagelayer_block_prefix = "'.PAGELAYER_BLOCK_PREFIX.'";
pagelayer_pro = '.(int)defined('PAGELAYER_PREMIUM').';
pagelayer_pro_url = "'.PAGELAYER_PRO_PRICE_URL.'";
pagelayer_pro_txt = "'.addslashes('This feature is a part of <a href="'.$pro_url.'" target="_blank">'.$pro_txt.'</a>. You will need purchase <a href="'.$pro_url.'" target="_blank">'.$pro_txt.'</a> to use this feature.').'";
pagelayer_api_url = "'.PAGELAYER_API.'";
pagelayer_ajax_url = "'.admin_url( 'admin-ajax.php' ).'?&";
pagelayer_post_props = "'.admin_url( 'admin.php?page=pagelayer_meta_setting&post=' ).$post->ID.'";
pagelayer_ajax_nonce = "'.wp_create_nonce('pagelayer_ajax').'";
pagelayer_media_ajax_nonce = "'.wp_create_nonce('media-form').'";
pagelayer_internal_linking_nonce = "'.wp_create_nonce('internal-linking').'";
pagelayer_preview_nonce = "'. wp_create_nonce( 'post_preview_' . $post->ID ).'";
pagelayer_url = "'.PAGELAYER_URL.'";
pagelayer_postID = "'.$post->ID.'";
pagelayer_permalink_structure = "'.(empty(get_option('permalink_structure')) ? 0 : 1).'";
pagelayer_post_permalink = "'.get_permalink($post->ID).'";
pagelayer_tabs = '.json_encode($pagelayer->tabs).';
pagelayer_isDirty = false;
pagelayer_returnURL = "'.$returnURL.'";
pagelayer_theme_vars = '.json_encode( pagelayer_template_vars() ).';
pagelayer_revision_obj = '.json_encode( pagelayer_get_post_revision_by_id( $post->ID ) ).';
pagelayer_author = '.json_encode(pagelayer_author_data($post->ID)).';
pagelayer_site_logo = '.json_encode(pagelayer_site_logo()).';
pagelayer_support_FI = "'. ( current_theme_supports('post-thumbnails') )  .'";	
pagelayer_editable = ".'.(!empty($pagelayer->template_editor) ? $pagelayer->template_editor : 'pagelayer-editable-area').'";
pagelayer_recaptch_site_key = "'.(!empty($pagelayer_recaptch_site_key) ? $pagelayer_recaptch_site_key : '').'";
pagelayer_post = '. @json_encode($_post) .';
pagelayer_loaded_icons =  '.json_encode(pagelayer_enabled_icons()).';
pagelayer_social_urls =  '.json_encode(pagelayer_get_social_urls()).';
pagelayer_global_widgets = '.json_encode($pagelayer->global_widgets).';
pagelayer_saved_sections = '.json_encode($pagelayer->saved_sections).';
pagelayer_global_sections = '.json_encode($pagelayer->global_sections).';
pagelayer_brand = "'.addslashes($pagelayer->BRAND_TEXT).'";
pagelayer_post_type_features = '.json_encode(@$_wp_post_type_features[$post->post_type]).';
pagelayer_post_categories = '.json_encode(pagelayer_post_cats($post)).';
pagelayer_post_tags = '.json_encode(pagelayer_post_tags($post)).';
pagelayer_shortcodes.pl_post_props.name = "'.ucfirst($post_type_name).' '. __pl('Settings').'";
pagelayer_shortcodes.pl_post_props.params.post_author.list = '.json_encode(pagelayer_post_authors_by_type($post->post_type)).';
pagelayer_shortcodes.pl_post_props.pageParent.post_parent.list = '.json_encode(pagelayer_parent_post_prop($post)).';
pagelayer_gmaps_key = "'.get_option('pagelayer-gmaps-api-key').'";
pagelayer_ajax_post_data = {};
pagelayer_menus_items_list = '.json_encode($pagelayer_menus_items_list).';
pagelayer_customizer_values = '.json_encode(pagelayer_get_customizer_options()).';
pagelayer_global_colors = '.json_encode($pagelayer->global_colors).';
pagelayer_global_fonts = '.json_encode($pagelayer->global_fonts).';
pagelayer_customizer_url = "'.admin_url("/customize.php?return=").urlencode($referer).'";
pagelayer_support_url = "'.$pagelayer->support .'";';

if(defined('PAGELAYER_PREMIUM')){
	echo 'pagelayer_shortcodes.pl_popup.advance_options.popup_cookie_name.default = "popup_cookie_'.rand(100, 999).'";';
}

// Detect JS via givejs for better performance
if(empty($pagelayer->settings['enable_giver'])){
	echo '
jQuery(document).ready(function(){	
	var test_giver = -1;
	
	return jQuery.ajax({
		url: "'.PAGELAYER_JS.'/givejs.php?test=1",
		type: "GET",
		dataType: "text",
		success:function(data){
			
			if(data !== "1"){
				return;
			}
			
			test_giver = 1;
		},
		complete:function(data){
			jQuery.ajax({
				type: "POST",
				url: pagelayer_ajax_url+"&action=pagelayer_set_jscss_giver",
				data: { 
					pagelayer_nonce: pagelayer_ajax_nonce,
					set : test_giver
				},
				error: function(errorThrown){
					console.log("Error saving giver data");
					console.log(errorThrown);
				}
			});
			
		}
	});
});
';
}

echo '
</script>';

		echo '<style>
@media (min-width: '.($pagelayer->settings['tablet_breakpoint'] + 1).'px){
.pagelayer-hide-desktop{
display:initial;
filter:blur(3px);
}
.pagelayer-hide-desktop *{
filter:blur(2px);
}
}

@media (max-width: '.$pagelayer->settings['tablet_breakpoint'].'px) and (min-width: '.($pagelayer->settings['mobile_breakpoint'] + 1).'px){
.pagelayer-hide-tablet{
display:initial;
filter:blur(3px);
}
.pagelayer-hide-tablet *{
filter:blur(2px);
}
}

@media (max-width: '.$pagelayer->settings['mobile_breakpoint'].'px){
.pagelayer-hide-mobile{
display:initial;
filter:blur(3px);
}

.pagelayer-hide-mobile *{
filter:blur(2px);
}
}
</style>';
		do_action('pagelayer_editor_wp_head');

	}

	// Footer function to add certain things
	function wp_footer(){
		
		global $pagelayer;
		
		echo '<script>
pagelayer_default_params = '.json_encode($pagelayer->default_params, JSON_FORCE_OBJECT).';
pagelayer.el = '.json_encode($pagelayer->data_attr, JSON_FORCE_OBJECT).';
</script>';
		
		wp_enqueue_script('heartbeat');
		_wp_footer_scripts();
	}

	// Convert to Pagelayer post
	function check_post(){

		global $post;

		// Is this a Pagelayer post
		$data = get_post_meta($post->ID, 'pagelayer-data', true);

		if(empty($data)){

			// Is it a Gutenburg Post ?
			if(!empty($post->post_content)){
				
				// Add our surrounding tag
				$post->post_content = '<!-- '.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl_row -->
<!-- '.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl_col {col=12} -->
'.$post->post_content.'
<!-- /'.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl_col -->
<!-- /'.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl_row -->';

			// Regular post, but its empty so we will add our blocks !
			}else{

				// Add our surrounding tag
				$post->post_content = '<!-- '.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl_row {"stretch":"auto","col_gap":"10","width_content":"auto","row_height":"default","overlay_hover_delay":"400","row_shape_top_color":"#227bc3","row_shape_top_width":"100","row_shape_top_height":"100","row_shape_bottom_color":"#e44993","row_shape_bottom_width":"100","row_shape_bottom_height":"100","pagelayer-id":""} -->
<!-- '.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl_col {"overlay_hover_delay":"400","pagelayer-id":""} -->
<!-- /'.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl_col -->
<!-- /'.PAGELAYER_BLOCK_PREFIX.':pagelayer/pl_row -->';
			
				// Update the post
				$new_post = array(
							'ID' => $post->ID,
							'post_content' => $post->post_content,
						);

				// Update the post into the database
				wp_update_post($new_post);

				// Convert to pagelayer accessed post
				if(!add_post_meta($post->ID, 'pagelayer-data', time(), true)){
					update_post_meta($post->ID, 'pagelayer-data', time());
				}

			}
		}

	}

	// Add certain things
	function the_content($content) {

		global $post, $pagelayer;
		
		if(empty($pagelayer->dont_make_editable)){
			$content = '<div class="pagelayer-editable-area">'.$content.'</div>';
		}
		
		// Check if we're inside the main loop in a single post page.
		if ( is_single() && in_the_loop() && is_main_query() ) {
			return $content;
		}
	 
		return $content;

	}
	
	// Skip do_shortcode for invalid shortcodes
	function pre_do_shortcode_tag($return, $tag, $attr, $m){
		
		if(!empty($pagelayer->dont_make_editable) || ! doing_filter('the_content')){
			return $return;
		}
		
		$prefixes = ['pl_'];
		
		$prefixes = apply_filters( 'pagelayer_valid_shortcode_tag', $prefixes);
		
		$vailid = false;

		foreach($prefixes as $prefix) {
			if (strpos($tag, $prefix) === 0) {
				$vailid = true;
				break;
			}
		}
		
		if($vailid){
			return $return;
		}
		
		return $m[0];
	}

	// Skip do_blocks for invalid blocks
	function pre_do_render_block($return, $parsed_block = [], $parent_block = null){
		
		if(!empty($pagelayer->dont_make_editable) ||  ! doing_filter('the_content') || empty($parsed_block['blockName'])){
			return $return;
		}
		
		$prefixes = ['pagelayer/'];
		
		$prefixes = apply_filters( 'pagelayer_valid_block_tag', $prefixes);
		
		$vailid = false;

		foreach($prefixes as $prefix) {
			if (strpos($parsed_block['blockName'], $prefix) === 0) {
				$vailid = true;
				break;
			}
		}
		
		if($vailid){
			return $return;
		}
		
		$serialize_block = serialize_block($parsed_block);
			
		$parsed_block['blockName'] = 'pagelayer/pl_missing';
		$parsed_block['innerHTML'] = $serialize_block;
		$parsed_block['attrs'] = [];
		
		return render_block($parsed_block);
	}

}PKv�f\����**imageseo.phpnu�[���<?php
/*
* SITESEO
* https://siteseo.io
* (c) SiteSEO Team
*/

namespace SiteSEO;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class ImageSeo{

	static function init(){
		global $siteseo;
		
		if(empty($siteseo->setting_enabled['toggle-advanced'])){
			return; // toggle disable
		}
		
		if(!empty($siteseo->advanced_settings['advanced_attachments'])){
			add_action('template_redirect', '\SiteSEO\ImageSeo::redirect_attachment_to_parent');
		}

		if(!empty($siteseo->advanced_settings['advanced_clean_filename'])){
			add_filter('sanitize_file_name', '\SiteSEO\ImageSeo::clean_media_filename', 10, 1);
		}

		if(!empty($siteseo->advanced_settings['advanced_image_auto_alt_editor']) ||
			!empty($siteseo->advanced_settings['advanced_image_auto_caption_editor']) ||
			!empty($siteseo->advanced_settings['advanced_image_auto_desc_editor']) || 
			!empty($siteseo->advanced_settings['advanced_image_auto_title_editor'])
		){
			add_action('add_attachment', '\SiteSEO\ImageSeo::set_image_content');
		}
	}
	
	static function set_image_content($attachment_id){
		global $siteseo;

		if(!wp_attachment_is_image($attachment_id)){
			return;
		}
		
		$attachment = get_post($attachment_id);
		$file_name = pathinfo($attachment->guid, PATHINFO_FILENAME);
		$file_name = sanitize_file_name($file_name);
		$file_name = ucwords(str_replace(['-', '_'], ' ', $file_name));
		
		// WooCommerce product img
		$is_woocommerce_product_image = false;
		$product_title = '';
		
		$parent_id = $attachment->post_parent;
		if(!empty($parent_id)){
			$parent_post = get_post($parent_id);
			if(!empty($parent_post) && $parent_post->post_type === 'product'){
				$is_woocommerce_product_image = true;
				$product_title = get_the_title($parent_id);
			}
		}
		
		$file_name = $is_woocommerce_product_image ? $product_title : $file_name;
		
		// Adding alt text to the image
		if(!empty($siteseo->advanced_settings['advanced_image_auto_alt_editor'])){
			update_post_meta($attachment_id, '_wp_attachment_image_alt', $file_name);
		}

		$options = [];
		$options['ID'] = $attachment_id;

		// Adding Title to the image
		if(!empty($siteseo->advanced_settings['advanced_image_auto_title_editor'])){
			$options['post_title'] = $file_name;
		}

		// Adding Img Caption
		if(!empty($siteseo->advanced_settings['advanced_image_auto_caption_editor'])){
			$options['post_content'] = $file_name;
		}

		// Adding Img Caption
		if(!empty($siteseo->advanced_settings['advanced_image_auto_desc_editor'])){
			$options['post_excerpt'] = $file_name;
		}

		if(count($options) > 1){
			wp_update_post($options);
		}
	}
	
	static function clean_media_filename($filename){
		$filename = strtolower($filename);		
		$filename = preg_replace('/[^a-z0-9-._]+/', '-', $filename);
		$filename = trim($filename, '-.');

		return $filename;
	}

	static function redirect_attachment_to_parent(){

		if(is_attachment()){
 
			$attachment_id = get_queried_object_id();
			$parent_id = wp_get_post_parent_id($attachment_id);

			if($parent_id){
				wp_redirect(get_permalink($parent_id));

			}else{
				wp_redirect(home_url());
			}

			exit; 
		}
	}
}
PKv�f\�6�%	�	�settings/statistics.phpnu�[���<?php
/*
* SITESEO
* https://siteseo.io
* (c) SiteSEO Team
*/

namespace SiteSEO\Settings;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class Statistics{

	static function init(){
		global $siteseo;

		$current_tab = isset($_GET['tab']) ? sanitize_key(wp_unslash($_GET['tab'])) : 'tab_dashbord';

		wp_enqueue_script('siteseo-chart-js', SITESEO_ASSETS_URL . '/js/chart.umd.min.js', [], SITESEO_VERSION, ['strategy' => 'defer', 'in_footer' => true]);
		wp_enqueue_script('siteseo-gsc-charts', SITESEO_ASSETS_URL . '/js/gsc-charts.js', ['jquery', 'siteseo-chart-js'], SITESEO_VERSION, ['strategy' => 'defer', 'in_footer' => true]);

		$saved_data = get_option('siteseo_search_console_data', []);
		wp_localize_script('siteseo-gsc-charts', 'siteseo_chart_data', $saved_data);

		if(isset($_GET['siteseo_auth_code']) && class_exists('\SiteSEOPro\GoogleConsole') && method_exists('\SiteSEOPro\GoogleConsole', 'generate_tokens')){
			\SiteSEOPro\GoogleConsole::generate_tokens();
		}

		if(isset($_GET['siteseo_auth_code']) && class_exists('\SiteSEOPro\GoogleConsole')){
			add_action('admin_footer', '\SiteSEO\Settings\Statistics::connect_site_dialogbox');
		}

		$site_connected = false;
		if(class_exists('\SiteSEOPro\GoogleConsole') && method_exists('\SiteSEOPro\GoogleConsole', 'is_connected')){
			$site_connected = \SiteSEOPro\GoogleConsole::is_connected();
		}

		$statistics_subtabs = [
			'tab_dashbord' => esc_html__('Dashboard', 'siteseo'),
			'tab_seo_statistics' => esc_html__('Site Search Traffic', 'siteseo'),
			'tab_keyword_rank' => esc_html__('Keyword Rank Tracker', 'siteseo'),
			'tab_content_ranking' => esc_html__('Content Ranking', 'siteseo'),
			'tab_audience' => esc_html__('Audience Overview', 'siteseo'),
		];

		echo'<div id="siteseo-root" class="siteseo-search-console">';
		Util::admin_header();

		$show_sample_data = isset($_GET['sample_data']) && $_GET['sample_data'] === '1';

		if(!class_exists('\SiteSEOPro\GoogleConsole') && !$show_sample_data){
			echo'<div class="siteseo-blur-overlay"></div>
			<div class="siteseo-pro-notice-center">
				<div class="siteseo-pro-notice-content">
					<span class="dashicons dashicons-lock siteseo-lock-icon"></span>
					<h2>'.esc_html__('Search Console Pro Feature', 'siteseo').'</h2>
					<p>'.esc_html__('Upgrade to PRO to unlock Google Search Console integration and access real-time search analytics data.', 'siteseo').'</p>
					<div class="siteseo-option siteseo-pro-notice-buttons">
					<a href="https://siteseo.io/pricing" class="siteseo-option btnPrimary" target="_blank">' . esc_html__('Buy Pro', 'siteseo') . '</a>
					<a href="'.esc_url(add_query_arg('sample_data', '1')).'" class="siteseo-option btnSecondary">'.esc_html__('Explore Sample Data', 'siteseo').'</a>
				</div>
			</div>
			</div>';
		} elseif(class_exists('\SiteSEOPro\GoogleConsole') && !$show_sample_data && empty($site_connected)){
			echo'<div class="siteseo-blur-overlay"></div>
			<div class="siteseo-pro-notice-center">
				<div class="siteseo-pro-notice-content">
					<span class="dashicons dashicons-admin-links siteseo-link-icon"></span>
					<h2>'.esc_html__('Search Console statistics', 'siteseo').'</h2>
					<p>'.esc_html__('Please connect your Google Search Console account to unlock real-time search analytics data.', 'siteseo').'</p>
					<div class="siteseo-option siteseo-pro-notice-buttons">
					<form method="post">';
					wp_nonce_field('siteseo_pro_connect_google');
					echo '<input type="hidden" name="redirect_type" value="settings">
						<button type="submit" name="siteseo_pro_connect_btn" class="siteseo-option btnPrimary siteseo-connect-btn">'.esc_html__('Connect Search Console', 'siteseo') .'</button>
					</form>
					<a href="'.esc_url(add_query_arg('sample_data', '1')).'" class="siteseo-option btnSecondary">'.esc_html__('Explore Sample Data', 'siteseo').'</a>
				</div>
			</div>
			</div>';
		}

		echo'<form method="post" id="siteseo-form" class="siteseo-option" name="siteseo-flush">
		<div class="siteseo-toggle-cnt"><span id="siteseo-tab-title"><strong>'.esc_html__('Google Search Console Statistics', 'siteseo').'</strong></span></div>';

		if(!empty($site_connected)){

			if(class_exists('\SiteSEOPro\GoogleConsole') && method_exists('\SiteSEOPro\GoogleConsole', 'get_site_url')){
				$site_url = \SiteSEOPro\GoogleConsole::get_site_url();
			}

			if(!empty($site_url)){
				echo'<div class="siteseo-statistics-wrapper">
					<span class="siteseo-statistics-sites">Site: '.(strpos($site_url, 'sc-domain:') === 0 ? sanitize_text_field($site_url) : esc_url($site_url)).' <span id="siteseo-refresh-search-stats" class="dashicons dashicons-update" title="'.esc_attr__('Update Stats', 'siteseo').'"></span></span>
					<span class="siteseo-statistics-disconnect"><span class="dashicons dashicons-migrate"></span>'.esc_html__('Disconnect', 'siteseo').'</span>
					<span class="siteseo-statistics-data-range">'.esc_html__('[Last 90 days data]', 'siteseo').'</span>
				</div>';
			}
		}

		echo'<div id="siteseo-tabs" class="wrap">
		<div class="siteseo-nav-tab-wrapper">';

		foreach($statistics_subtabs as $tab_key => $tab_caption){
			$active_class = ($current_tab === $tab_key) ? ' siteseo-nav-tab-active' : '';
			echo'<a id="' . esc_attr($tab_key) . '-tab" class="siteseo-nav-tab' . esc_attr($active_class) . '" data-tab="' . esc_attr($tab_key) . '">' . esc_html($tab_caption) . '</a>';
		}

		echo'</div>
		<div class="tab-content-wrapper">
		<div class="siteseo-tab' .($current_tab == 'tab_dashbord' ? ' active' : '').'" id="tab_dashbord" style="display: none;">';
		self::dashbord_tab();
		echo'</div>
		<div class="siteseo-tab' .($current_tab == 'tab_seo_statistics' ? ' active' : '').'" id="tab_seo_statistics" style="display: none;">';
		self::seo_statistics_tab();
		echo'</div>
		<div class="siteseo-tab' .($current_tab == 'tab_keyword_rank' ? ' active' : '').'" id="tab_keyword_rank" style="display: none;">';
		self::keyword_ranking_tab();
		echo'</div>
		<div class="siteseo-tab' .($current_tab == 'tab_content_ranking' ? ' active' : '').'" id="tab_content_ranking" style="display: none;">';
		self::content_ranking_tab();
		echo'</div>
		<div class="siteseo-tab '.($current_tab =='tab_audience' ? ' active' : '').'" id="tab_audience" style="display:none;">';
		self::audience_tab();
		echo'</div>
		</div>';
		echo'</form></div>';
	}

	static function fetch_data(){
		$is_connected = '';

		if(class_exists('\SiteSEOPro\GoogleConsole') && method_exists('\SiteSEOPro\GoogleConsole', 'is_connected')){
			$is_connected = \SiteSEOPro\GoogleConsole::is_connected();
		}

		$analytics_data = get_option('siteseo_search_console_data', []);

		if(empty($analytics_data) && empty($is_connected)){
			// Show sample data when not connected
			return [
				'metrics' => self::sample_metrics_data(),
				'top_pages' => self::sample_top_pages(),
				'top_loss_pages' => array_slice(self::sample_top_pages(), 0, 3), // Sample loss pages
				'top_winning_pages' => array_slice(self::sample_top_pages(), 3, 3), // Sample winning pages
				'keywords' => self::sample_keywords(),
				'top_winning_keywords' => array_slice(self::sample_keywords(), 0, 3), // Sample winning keywords
				'top_loss_keywords' => array_slice(self::sample_keywords(), 3, 2), // Sample loss keywords
				'content_ranking' => self::sample_content_ranking(),
				'country_data' => self::sample_country_data(), 
				'device_data' => self::sample_device_data(),
				'is_sample' => true
			];
		}
		
		return [
			'metrics' => isset($analytics_data['metrics']) ? $analytics_data['metrics'] : [
				'impressions' => [
					'current' => '0',
					'change' => '0',
					'trend' => 'neutral',
					'chart_data' => []
				],
				'clicks' => [
					'current' => '0',
					'change' => '0',
					'trend' => 'neutral',
					'chart_data' => []
				],
				'ctr' => [
					'current' => '0%',
					'change' => '0',
					'trend' => 'neutral',
					'chart_data' => []
				],
				'position' => [
					'current' => '0',
					'change' => '0',
					'trend' => 'neutral',
					'chart_data' => []
				]
			],
			'top_pages' => isset($analytics_data['top_pages']) ? array_slice($analytics_data['top_pages'], 0, 5) : [],
			'top_loss_pages' => isset($analytics_data['top_loss_pages']) ? array_slice($analytics_data['top_loss_pages'], 0, 5) : [],
			'top_winning_pages' => isset($analytics_data['top_winning_pages']) ? array_slice($analytics_data['top_winning_pages'], 0, 5) : [],
			'keywords' => isset($analytics_data['top_keywords']) ? array_slice($analytics_data['top_keywords'], 0, 5) : [],
			'top_winning_keywords' => isset($analytics_data['top_winning_keywords']) ? array_slice($analytics_data['top_winning_keywords'], 0, 5) : [],
			'top_loss_keywords' => isset($analytics_data['top_loss_keywords']) ? array_slice($analytics_data['top_loss_keywords'], 0, 5) : [],
			'content_ranking' => isset($analytics_data['content_ranking']) ? $analytics_data['content_ranking'] : [],
			'country_data' => isset($analytics_data['country_audience']) ? $analytics_data['country_audience'] : [],
			'device_data' => isset($analytics_data['device_audience']) ? $analytics_data['device_audience'] : [],
			'is_sample' => false
		];
	}

	static function dashbord_tab(){	
		self::connect_notices();

		$data = self::fetch_data();
		$metrics = $data['metrics'];
		$top_pages = $data['top_pages'];
		$top_loss_pages = $data['top_loss_pages'];
		$top_winning_pages = $data['top_winning_pages'];
		$keywords = $data['keywords'];
		$top_winning_keywords = $data['top_winning_keywords'];
		$top_loss_keywords = $data['top_loss_keywords'];

		echo'<div class="siteseo-stats-container">
			<h2 class="siteseo-stats-title">'.esc_html__('Search Performance', 'siteseo').'</h2>
			<hr class="siteseo-stats-separator">

			<div class="siteseo-dashboard-grid">
				<div class="siteseo-metric-card">
					<div class="siteseo-metric-header">
						<span class="siteseo-metric-title">'.esc_html__('Search Impressions', 'siteseo').'</span>
					</div>
					
					<div class="siteseo-metric-value-row">
						<span class="siteseo-metric-value">'.esc_html($metrics['impressions']['current']).'</span>
							<span class="siteseo-metric-change '.($metrics['impressions']['trend'] == 'negative' ? 'siteseo-change-negative' : ($metrics['impressions']['trend'] == 'positive' ? 'siteseo-change-positive' : '')).'">
								'.($metrics['impressions']['trend'] != 'neutral' ? '<span class="dashicons dashicons-arrow-'.($metrics['impressions']['trend'] == 'negative' ? 'down' : 'up').'"></span>' : '').'
								'.esc_html($metrics['impressions']['change']).'
							</span>
					</div>
						
					<div class="siteseo-chart-container">
						<canvas id="siteseo_impressions_chart" data-sample="'.($data['is_sample'] ? '1' : '0').'"></canvas>
					</div>
				</div>

					<div class="siteseo-metric-card">
						<div class="siteseo-metric-header">
							<span class="siteseo-metric-title">'.esc_html__('Total Clicks', 'siteseo').'</span>
						</div>
						
						<div class="siteseo-metric-value-row">
							<span class="siteseo-metric-value">'.esc_html($metrics['clicks']['current']).'</span>
							<span class="siteseo-metric-change '.($metrics['clicks']['trend'] == 'negative' ? 'siteseo-change-negative' : ($metrics['clicks']['trend'] == 'positive' ? 'siteseo-change-positive' : '')).'">
								'.($metrics['clicks']['trend'] != 'neutral' ? '<span class="dashicons dashicons-arrow-'.($metrics['clicks']['trend'] == 'negative' ? 'down' : 'up').'"></span>' : '').'
								'.esc_html($metrics['clicks']['change']).'
							</span>
						</div>
						
						<div class="siteseo-chart-container">
							<canvas id="siteseo_clicks_chart" data-sample="'.($data['is_sample'] ? '1' : '0').'"></canvas>
						</div>
					</div>

					<div class="siteseo-metric-card">
						<div class="siteseo-metric-header">
							<span class="siteseo-metric-title">'.esc_html__('Avg. CTR', 'siteseo').'</span>
						</div>
						<div class="siteseo-metric-value-row">
							<span class="siteseo-metric-value">'.esc_html($metrics['ctr']['current']).'</span>
							<span class="siteseo-metric-change '.($metrics['ctr']['trend'] == 'negative' ? 'siteseo-change-negative' : ($metrics['ctr']['trend'] == 'positive' ? 'siteseo-change-positive' : '')).'">
								'.($metrics['ctr']['trend'] != 'neutral' ? '<span class="dashicons dashicons-arrow-'.($metrics['ctr']['trend'] == 'negative' ? 'down' : 'up').'"></span>' : '').'
								'.esc_html($metrics['ctr']['change']).'
							</span>
						</div>
						<div class="siteseo-chart-container">
							<canvas id="siteseo_ctr_chart" data-sample="'.($data['is_sample'] ? '1' : '0').'"></canvas>
						</div>
					</div>

					<div class="siteseo-metric-card">
						<div class="siteseo-metric-header">
							<span class="siteseo-metric-title">'.esc_html__('Avg. Position', 'siteseo').'</span>
						</div>
						<div class="siteseo-metric-value-row">
							<span class="siteseo-metric-value">'.esc_html($metrics['position']['current']).'</span>
							<span class="siteseo-metric-change '.($metrics['position']['trend'] == 'negative' ? 'siteseo-change-negative' : ($metrics['position']['trend'] == 'positive' ? 'siteseo-change-positive' : '')).'">
								'.($metrics['position']['trend'] != 'neutral' ? '<span class="dashicons dashicons-arrow-'.($metrics['position']['trend'] == 'negative' ? 'down' : 'up').'"></span>' : '').'
								'.esc_html($metrics['position']['change']).'
							</span>
						</div>
						<div class="siteseo-chart-container">
							<canvas id="siteseo_position_chart" data-sample="'.($data['is_sample'] ? '1' : '0').'"></canvas>
						</div>
					</div>
				</div>
			</div>';
		
		if(!empty($top_pages) || $data['is_sample']){

			echo'<div class="siteseo-stats-container">
				<h2 class="siteseo-stats-title">'.esc_html__('Content Performance ( Top 5 )', 'siteseo').'</h2>
				<div class="siteseo-inner-tabs-wrap">
					<input type="radio" id="siteseo-statistics-top-page" name="siteseo-inner-tabs-pages" checked>
					<input type="radio" id="siteseo-statistics-top-loss" name="siteseo-inner-tabs-pages">
					<input type="radio" id="siteseo-statistics-top-winning" name="siteseo-inner-tabs-pages">
					
					<ul class="siteseo-inner-tabs">
						<li class="siteseo-inner-tab"><label for="siteseo-statistics-top-page">'.esc_html__('Top Pages', 'siteseo').'</label></li>
						<li class="siteseo-inner-tab"><label for="siteseo-statistics-top-loss">'.esc_html__('Top loss', 'siteseo').'</label></li>
						<li class="siteseo-inner-tab"><label for="siteseo-statistics-top-winning">'.esc_html__('Top winning', 'siteseo').'</label></li>
					</ul>
						
					<div class="siteseo-inner-tab-content">	
						<table class="wp-list-table widefat fixed striped siteseo-history-table">
							<thead><tr>
								<th>'.esc_html__('Title', 'siteseo').'</th>
								<th>'.esc_html__('Score', 'siteseo').'</th>
								<th>'.esc_html__('Indexed', 'siteseo').'</th>
								<th>'.esc_html__('Clicks', 'siteseo').'</th>
								<th>'.esc_html__('Impressions', 'siteseo').'</th>
								<th>'.esc_html__('Position', 'siteseo').'</th>
								<th>'.esc_html__('Diff', 'siteseo').'</th>
							</tr>
							</thead>
						<tbody>';

						foreach($top_pages as $page){
							
							$score = $page['truseo_score'];
							
							if($score >= 80){
								$badge_class = 'siteseo-gsc-score-good';
							} elseif ($score >= 50){
								$badge_class = 'siteseo-gsc-score-avg';
							} else{
								$badge_class = 'siteseo-gsc-score-bad';
							}
							
							echo'<tr>
								<td>'.esc_html($page['title']).'</td>
								<td><span class="'.esc_attr($badge_class).'">'.esc_html($page['truseo_score']).'/100</span></td>
								<td><span class="dashicons '.($page['indexed'] ? 'dashicons-yes-alt siteseo-statistics-index-icon' : 'dashicons-dismiss siteseo-statistics-noindex-icon').'"></span></td>
								<td>'.esc_html($page['clicks']).'</td>
								<td>'.esc_html($page['impressions']).'</td>
								<td>'.esc_html($page['position']).'</td>
								<td style="color:'.(isset($page['diff']) && strpos($page['diff'], '+') === 0 ? '#28a745' : '#dc3545').';">'.esc_html($page['diff']).'</td>
							</tr>';
						}
						
						if(empty($top_pages) && !$data['is_sample']){
							echo '<tr><td colspan="7" style="text-align:center;">'.esc_html__('No data available yet', 'siteseo').'</td></tr>';
						}
						
						echo'</tbody></table>
					</div>
					
					<div class="siteseo-inner-tab-content">
						 <table class="wp-list-table widefat fixed striped siteseo-history-table">
							<thead><tr>
								<th>'.esc_html__('Title', 'siteseo').'</th>
								<th>'.esc_html__('Score', 'siteseo').'</th>
								<th>'.esc_html__('Indexed', 'siteseo').'</th>
								<th>'.esc_html__('Clicks', 'siteseo').'</th>
								<th>'.esc_html__('Impressions', 'siteseo').'</th>
								<th>'.esc_html__('Position', 'siteseo').'</th>
								<th>'.esc_html__('Diff', 'siteseo').'</th>
							</tr>
							</thead>
						<tbody>';

						// Use top_loss_pages instead of top_pages
						foreach($top_loss_pages as $page){
							
							$score = $page['truseo_score'];
							
							if($score >= 80){
								$badge_class = 'siteseo-gsc-score-good';
							} elseif($score >= 50){
								$badge_class = 'siteseo-gsc-score-avg';
							} else{
								$badge_class = 'siteseo-gsc-score-bad';
							}
							
							echo'<tr>
								<td>'.esc_html($page['title']).'</td>
								<td><span class="'.esc_attr($badge_class).'">'.esc_html($page['truseo_score']).'/100</span></td>
								<td><span class="dashicons '.($page['indexed'] ? 'dashicons-yes-alt siteseo-statistics-index-icon' : 'dashicons-dismiss siteseo-statistics-noindex-icon').'"></span></td>
								<td>'.esc_html($page['clicks']).'</td>
								<td>'.esc_html($page['impressions']).'</td>
								<td>'.esc_html($page['position']).'</td>
								<td style="color:#dc3545;">'.esc_html($page['diff']).'</td>
							</tr>';
						}
						
						if(empty($top_loss_pages) && !$data['is_sample']){
							echo '<tr><td colspan="7" style="text-align:center;">'.esc_html__('No loss pages data available', 'siteseo').'</td></tr>';
						}

						echo'</tbody></table>
					</div>
					
					<div class="siteseo-inner-tab-content">
						 <table class="wp-list-table widefat fixed striped siteseo-history-table">
							<thead><tr>
								<th>'.esc_html__('Title', 'siteseo').'</th>
								<th>'.esc_html__('Score', 'siteseo').'</th>
								<th>'.esc_html__('Indexed', 'siteseo').'</th>
								<th>'.esc_html__('Clicks', 'siteseo').'</th>
								<th>'.esc_html__('Impressions', 'siteseo').'</th>
								<th>'.esc_html__('Position', 'siteseo').'</th>
								<th>'.esc_html__('Diff', 'siteseo').'</th>
							</tr>
							</thead>
						<tbody>';

						// Use top_winning_pages instead of top_pages
						foreach($top_winning_pages as $page){
							$score = $page['truseo_score'];
							if($score >= 80){
								$badge_class = 'siteseo-gsc-score-good';
							} elseif($score >= 50){
								$badge_class = 'siteseo-gsc-score-avg';
							} else{
								$badge_class = 'siteseo-gsc-score-bad';
							}
							
							echo'<tr>
								<td>'.esc_html($page['title']).'</td>
								<td><span class="'.esc_attr($badge_class).'">'.esc_html($page['truseo_score']).'/100</span></td>
								<td><span class="dashicons '.($page['indexed'] ? 'dashicons-yes-alt siteseo-statistics-index-icon' : 'dashicons-dismiss siteseo-statistics-noindex-icon').'"></span></td>
								<td>'.esc_html($page['clicks']).'</td>
								<td>'.esc_html($page['impressions']).'</td>
								<td>'.esc_html($page['position']).'</td>
								<td style="color:#28a745;">'.esc_html($page['diff']).'</td>
							</tr>';
						}
						
						if(empty($top_winning_pages) && !$data['is_sample']){
							echo '<tr><td colspan="7" style="text-align:center;">'.esc_html__('No winning pages data available', 'siteseo').'</td></tr>';
						}
						
						echo'</tbody></table>
					</div>
				</div>
			</div>';
		}
		
		if(!empty($keywords) || $data['is_sample']){
			echo'<div class="siteseo-stats-container">
				<h2 class="siteseo-stats-title">'.esc_html__('Keyword Rankings ( Top 5 )', 'siteseo').'</h2>

				<div class="siteseo-inner-tabs-wrap">
					<input type="radio" id="siteseo-statistics-top-keywords" name="siteseo-inner-tabs-keywords" checked>
					<input type="radio" id="siteseo-statistics-winning-keywords" name="siteseo-inner-tabs-keywords">
					<input type="radio" id="siteseo-statistics-loss-keywords" name="siteseo-inner-tabs-keywords">

					<ul class="siteseo-inner-tabs">
						<li class="siteseo-inner-tab"><label for="siteseo-statistics-top-keywords">'.esc_html__('Top Keywords', 'siteseo').'</label></li>
						<li class="siteseo-inner-tab"><label for="siteseo-statistics-winning-keywords">'.esc_html__('Top Winning', 'siteseo').'</label></li>
						<li class="siteseo-inner-tab"><label for="siteseo-statistics-loss-keywords">'.esc_html__('Top LOSS', 'siteseo').'</label></li>
					</ul>
						
				<div class="siteseo-inner-tab-content">	

					<table class="wp-list-table widefat fixed striped siteseo-history-table">
						<thead>
							<tr>
								<th>'.esc_html__('Keyword', 'siteseo').'</th>
								<th>'.esc_html__('Clicks', 'siteseo').'</th>
								<th>'.esc_html__('Impressions', 'siteseo').'</th>
								<th>'.esc_html__('CTR', 'siteseo').'</th>
								<th>'.esc_html__('Position', 'siteseo').'</th>
							</tr>
						</thead>
						<tbody>';
						
						foreach($keywords as $keyword){
							echo'<tr>
								<td class="siteseo-table-row">'.esc_html($keyword['keyword']).'</td>
								<td style="font-weight:bold;">'.esc_html($keyword['clicks']).'</td>
								<td>'.esc_html($keyword['impressions']).'</td>
								<td>'.esc_html($keyword['ctr']).'</td>
								<td>'.esc_html($keyword['position']).'</td>
							</tr>';
						}
						
						if(empty($keywords) && !$data['is_sample']){
							echo'<tr><td colspan="5" style="text-align:center;">'.esc_html__('No data available yet', 'siteseo').'</td></tr>';
						}
						
						echo'</tbody>
					</table>
				</div>
				<div class="siteseo-inner-tab-content">
					<table class="wp-list-table widefat fixed striped siteseo-history-table">
						<thead>
							<tr>
								<th>'.esc_html__('Keyword', 'siteseo').'</th>
								<th>'.esc_html__('Points', 'siteseo').'</th>
								<th>'.esc_html__('Clicks', 'siteseo').'</th>
								<th>'.esc_html__('Position', 'siteseo').'</th>
							</tr>
						</thead>
						<tbody>';
						
						// Use top_winning_keywords instead of keywords
						foreach($top_winning_keywords as $keyword){
							echo'<tr>
								<td class="siteseo-table-row">'.esc_html($keyword['keyword']).'</td>
								<td style="color:#28a745;font-weight:bold;">'.esc_html($keyword['points']).'</td>
								<td>'.esc_html($keyword['clicks']).'</td>
								<td>'.esc_html($keyword['position']).'</td>
							</tr>';
						}
						
						if(empty($top_winning_keywords) && !$data['is_sample']){
							echo'<tr><td colspan="4" style="text-align:center;">'.esc_html__('No winning keywords data available', 'siteseo').'</td></tr>';
						}

						echo'</tbody>
					</table>
				</div>

				<div class="siteseo-inner-tab-content">
					<table class="wp-list-table widefat fixed striped siteseo-history-table">
						<thead>
							<tr>
								<th>'.esc_html__('Keyword', 'siteseo').'</th>
								<th>'.esc_html__('Points', 'siteseo').'</th>
								<th>'.esc_html__('Clicks', 'siteseo').'</th>
								<th>'.esc_html__('Position', 'siteseo').'</th>	   
							</tr>
						</thead>
						<tbody>';

						// Use top_loss_keywords instead of keywords
						foreach($top_loss_keywords as $keyword){
							echo'<tr>
								<td class="siteseo-table-row">'.esc_html($keyword['keyword']).'</td>
								<td style="color:#dc3545;font-weight:bold;">'.esc_html($keyword['points']).'</td>
								<td>'.esc_html($keyword['clicks']).'</td>
								<td>'.esc_html($keyword['position']).'</td>
							</tr>';
						}

						if(empty($top_loss_keywords) && !$data['is_sample']){
							echo'<tr><td colspan="4" style="text-align:center;">'.esc_html__('No loss keywords data available', 'siteseo').'</td></tr>';
						}

						echo'</tbody>
					</table>
				</div>
				</div>
			</div>';
		}
	}

	static function seo_statistics_tab(){
		self::connect_notices();

		$data = self::fetch_data();
		$metrics = $data['metrics'];
		$top_pages = $data['top_pages'];
		
		echo'<div class="siteseo-stats-container">
			<h2 class="siteseo-stats-title">'.esc_html__('Site Search Traffic', 'siteseo').'</h2>
			<hr class="siteseo-stats-separator">
			<ul class="siteseo-stats-list">
				<li class="siteseo-stat-item">
					<div class="siteseo-stat-header">
						<span class="siteseo-stat-label">'.esc_html__('Search Impressions', 'siteseo').'</span>
					</div>
					<div class="siteseo-stat-value-group">
						<span class="siteseo-stat-value">'.esc_html($metrics['impressions']['current']).'</span>
						<span class="siteseo-stat-change '.($metrics['impressions']['trend'] == 'negative' ? 'negative' : ($metrics['impressions']['trend'] == 'positive' ? 'positive' : '')).'">
							'.($metrics['impressions']['trend'] != 'neutral' ? '<span class="dashicons dashicons-arrow-'.($metrics['impressions']['trend'] == 'negative' ? 'down' : 'up').'"></span>' : '').'
							'.esc_html($metrics['impressions']['change']).'
						</span>
					</div>
				</li>
				<li class="siteseo-stat-item">
					<div class="siteseo-stat-header">
						<span class="siteseo-stat-label">'.esc_html__('Total Clicks', 'siteseo').'</span>
					</div>
					<div class="siteseo-stat-value-group">
						<span class="siteseo-stat-value">'.esc_html($metrics['clicks']['current']).'</span>
						<span class="siteseo-stat-change '.($metrics['clicks']['trend'] == 'negative' ? 'negative' : ($metrics['clicks']['trend'] == 'positive' ? 'positive' : '')).'">
							'.($metrics['clicks']['trend'] != 'neutral' ? '<span class="dashicons dashicons-arrow-'.($metrics['clicks']['trend'] == 'negative' ? 'down' : 'up').'"></span>' : '').'
							'.esc_html($metrics['clicks']['change']).'
						</span>
					</div>
				</li>
				<li class="siteseo-stat-item">
					<div class="siteseo-stat-header">
						<span class="siteseo-stat-label">'.esc_html__('Avg. CTR', 'siteseo').'</span>
					</div>
					<div class="siteseo-stat-value-group">
						<span class="siteseo-stat-value">'.esc_html($metrics['ctr']['current']).'</span>
						<span class="siteseo-stat-change '.($metrics['ctr']['trend'] == 'negative' ? 'negative' : ($metrics['ctr']['trend'] == 'positive' ? 'positive' : '')).'">
							'.($metrics['ctr']['trend'] != 'neutral' ? '<span class="dashicons dashicons-arrow-'.($metrics['ctr']['trend'] == 'negative' ? 'down' : 'up').'"></span>' : '').'
							'.esc_html($metrics['ctr']['change']).'
						</span>
					</div>
				</li>
				<li class="siteseo-stat-item">
					<div class="siteseo-stat-header">
						<span class="siteseo-stat-label">'.esc_html__('Avg. Position.', 'siteseo').'</span>
					</div>
					<div class="siteseo-stat-value-group">
						<span class="siteseo-stat-value">'.esc_html($metrics['position']['current']).'</span>
						<span class="siteseo-stat-change '.($metrics['position']['trend'] == 'negative' ? 'negative' : ($metrics['position']['trend'] == 'positive' ? 'positive' : '')) . '">
						'.($metrics['position']['trend'] != 'neutral' ? '<span class="dashicons dashicons-arrow-' . ($metrics['position']['trend'] == 'negative' ? 'down' : 'up') . '"></span>' : ''
							) . '
							'.esc_html($metrics['position']['change']).'
						</span>
					</div>
				</li>
			</ul>
		   <canvas id="seo_statistics" width="950" height="250" data-sample="'.($data['is_sample'] ? '1' : '0').'"></canvas>
		</div>';
		
		if(!empty($top_pages) || $data['is_sample']){
			echo'<div class="siteseo-stats-container">
				<h2 class="siteseo-stats-title">'.esc_html__('Content Analysis ( Top 5 )', 'siteseo').'</h2>	
				<table class="wp-list-table widefat fixed striped siteseo-history-table">
					<thead><tr>
						<th>'.esc_html__('Page', 'siteseo').'</th>
						<th>'.esc_html__('Status', 'siteseo').'</th>
						<th>'.esc_html__('Clicks', 'siteseo').'</th>
						<th>'.esc_html__('Avg position', 'siteseo').'</th>
						<th>'.esc_html__('Impressions', 'siteseo').'</th>
						<th>'.esc_html__('Content Score', 'siteseo').'</th>
					</tr>
					</thead>
				<tbody>';
				
				foreach($top_pages as $page){
					
					$score = $page['truseo_score'];
					if($score >= 80){
						$badge_class = 'siteseo-gsc-score-good';
					} elseif ($score >= 50){
						$badge_class = 'siteseo-gsc-score-avg';
					} else{
						$badge_class = 'siteseo-gsc-score-bad';
					}
						
					echo'<tr>
						<td>'.esc_html($page['title']).'</td>
						<td>'.(isset($page['indexed']) ? ($page['indexed'] ? '<span class="dashicons dashicons-yes-alt" style="color:#28a745;"></span>' : '<span class="dashicons dashicons-dismiss" style="color:#dc3545;"></span>') : '<span class="dashicons dashicons-editor-help" style="color:#6c757d;"></span>').'</td>
						<td>'.esc_html($page['clicks']).'</td>
						<td>'.esc_html($page['position']).'</td>
						<td>'.esc_html($page['impressions']).'</td>
						<td><span class="'.esc_attr($badge_class).'">'.esc_html($page['truseo_score']).'/100</span></td>
					</tr>';
				}
				
				if(empty($top_pages) && !$data['is_sample']){
					echo'<tr><td colspan="6" style="text-align:center;">'.esc_html__('No data available yet', 'siteseo').'</td></tr>';
				}
				
				echo'</tbody></table>
			</div>';
		}
	}
		
	static function keyword_ranking_tab(){
		self::connect_notices();
	
		$data = self::fetch_data();
		$keywords = $data['keywords'];

		// Get actual analytics data if available
		$analytics_data = get_option('siteseo_search_console_data', []);
		$has_actual_data = !empty($analytics_data) && !isset($analytics_data['error']);
	
		// Prepare values based on actual data or sample
		if($has_actual_data && !$data['is_sample']){
			// Use actual data
			$total_keywords = isset($analytics_data['top_keywords']) ? count($analytics_data['top_keywords']) : 0;
			$total_impressions = isset($analytics_data['metrics']['impressions']['current']) ? $analytics_data['metrics']['impressions']['current'] : '0';
			$avg_ctr = isset($analytics_data['metrics']['ctr']['current']) ? $analytics_data['metrics']['ctr']['current'] : '0%';
			
			$impression_change = isset($analytics_data['metrics']['impressions']['change']) ? $analytics_data['metrics']['impressions']['change'] : '0';
			$impression_trend = isset($analytics_data['metrics']['impressions']['trend']) ? $analytics_data['metrics']['impressions']['trend'] : 'neutral';
			
			$ctr_change = '0';
			$ctr_trend = 'neutral';
			
		} else{
			// Use sample data or zeros
			$total_keywords = $data['is_sample'] ? '19K' : '0';
			$total_impressions = $data['is_sample'] ? '15M' : '0';
			$avg_ctr = $data['is_sample'] ? '48.25%' : '0%';
			$impression_change = $data['is_sample'] ? '475.7K' : '0';
			$impression_trend = $data['is_sample'] ? 'negative' : 'neutral';
			$ctr_change = $data['is_sample'] ? '1' : '0';
			$ctr_trend = $data['is_sample'] ? 'negative' : 'neutral';
		}
	
		echo'<div class="siteseo-stats-container">
			<h2 class="siteseo-stats-title">'.esc_html__('Keyword Positions', 'siteseo').'</h2>
			<hr class="siteseo-stats-separator">
			<ul class="siteseo-stats-list">
				<li class="siteseo-stat-item">
					<div class="siteseo-stat-header">
						<span class="siteseo-stat-label">'.esc_html__('Total Keyword', 'siteseo').'</span>
					</div>
					<div class="siteseo-stat-value-group">
						<span class="siteseo-stat-value">'.esc_html($total_keywords).'</span>
						'.($data['is_sample'] ? '<span class="siteseo-stat-change positive">
							<span class="dashicons dashicons-arrow-up"></span>2.9K
						</span>' : '').'
					</div>
				</li>
			
				<li class="siteseo-stat-item">
					<div class="siteseo-stat-header">
						<span class="siteseo-stat-label">'.esc_html__('Search Impressions', 'siteseo').'</span>
					</div>
					<div class="siteseo-stat-value-group">
						<span class="siteseo-stat-value">'.esc_html($total_impressions).'</span>
						'.((!$data['is_sample'] && $has_actual_data) ? 
						'<span class="siteseo-stat-change '.esc_attr($impression_trend).'">
							<span class="dashicons dashicons-arrow-'.($impression_trend === 'positive' ? 'up' : 'down').'"></span>'
							.esc_html($impression_change).'
						</span>' : 
						($data['is_sample'] ? 
						'<span class="siteseo-stat-change negative">
							<span class="dashicons dashicons-arrow-down"></span>475.7K
						</span>' : '')).'
					</div>
				</li>
			
				<li class="siteseo-stat-item">
					<div class="siteseo-stat-header">
						<span class="siteseo-stat-label">'.esc_html__('Avg. CTR', 'siteseo').'</span>
					</div>
					<div class="siteseo-stat-value-group">
						<span class="siteseo-stat-value">'.esc_html($avg_ctr).'</span>
						'.($data['is_sample'] ? 
						'<span class="siteseo-stat-change negative">
							<span class="dashicons dashicons-arrow-down"></span>1
						</span>' : '').'
					</div>
				</li>
			</ul>
		
			<div style="display:flex; gap:20px; flex-wrap:wrap;">
				<div style="flex:1; min-width:280px; max-width:50%;">
					<canvas id="siteseo_keyword_muti_line_chart" data-sample="'.($data['is_sample'] ? '1' : '0').'" data-actual="'.($has_actual_data ? '1' : '0').'"></canvas>
				</div>
				<div style="flex:1; min-width:280px; max-width:50%;">
					<canvas id="siteseo_keyword_bar_chart" data-sample="'.($data['is_sample'] ? '1' : '0').'" data-actual="'.($has_actual_data ? '1' : '0').'"></canvas>
				</div>
			</div>
		</div>';
		
		if(!empty($keywords) || $data['is_sample']){
			echo'<div class="siteseo-stats-container">
				<h2 class="siteseo-stats-title">'.esc_html__('Content Analysis ( Top 5 )', 'siteseo').'</h2>
				<table class="wp-list-table widefat fixed striped siteseo-history-table">
					<thead><tr>
						<th>'.esc_html__('Keywords', 'siteseo').'</th>
						<th>'.esc_html__('Clicks', 'siteseo').'</th>
						<th>'.esc_html__('Avg. CTR', 'siteseo').'</th>
						<th>'.esc_html__('Impressions', 'siteseo').'</th>
						<th>'.esc_html__('Position', 'siteseo').'</th>
					</tr>
					</thead>
				<tbody>';
				
				foreach($keywords as $keyword){
					echo'<tr>
						<td class="siteseo-table-row">'.esc_html($keyword['keyword']).'</td>
						<td>'.esc_html($keyword['clicks']).'</td>
						<td>'.esc_html($keyword['ctr']).'</td>
						<td>'.esc_html($keyword['impressions']).'</td>
						<td>'.esc_html($keyword['position']).'</td>
					</tr>';
				}
				
				if(empty($keywords) && !$data['is_sample']){
					echo'<tr><td colspan="6" style="text-align:center;">'.esc_html__('No data available yet', 'siteseo').'</td></tr>';
				}
				
				echo'</tbody></table>
			</div>';
		}
	}

	static function content_ranking_tab(){
		self::connect_notices();
		
		$data = self::fetch_data();
		$content_ranking = $data['content_ranking'];

		if(!empty($content_ranking) || $data['is_sample']){
			// Pagination setup
			$items_per_page = 10;
			$total_items = count($content_ranking);
			$total_pages = ceil($total_items / $items_per_page);
			
			$current_page = isset($_GET['cr_page']) ? max(1, intval($_GET['cr_page'])) : 1;

			$offset = ($current_page - 1) * $items_per_page;
			
			$paged_items = array_slice($content_ranking, $offset, $items_per_page);
			
			echo'<div class="siteseo-stats-container">
				<h2 class="siteseo-stats-title">'.esc_html__('Content Analysis (Top 30)', 'siteseo').'</h2>
				<table class="wp-list-table widefat fixed striped siteseo-history-table">
					<thead><tr>
						<th>'.esc_html__('Title', 'siteseo').'</th>
						<th>'.esc_html__('Indexed', 'siteseo').'</th>
						<th>'.esc_html__('Last Update on', 'siteseo').'</th>
						<th>'.esc_html__('Loss', 'siteseo').'</th>
						<th>'.esc_html__('Drop (%)', 'siteseo').'</th>
						<th>'.esc_html__('Performance Score', 'siteseo').'</th>
					</tr>
					</thead>
				<tbody>';

				foreach($paged_items as $content){
					$score = (int) explode('/', $content['performance_score'])[0];
					
					if($score >= 80){
						$badge_class = 'siteseo-gsc-score-good';
					} elseif($score >= 50){
						$badge_class = 'siteseo-gsc-score-avg';
					} else{
						$badge_class = 'siteseo-gsc-score-bad';
					}
					
					echo'<tr>
						<td>'.esc_html($content['title']).'</td> 
						<td><span class="dashicons '.($content['indexed'] === 'Yes' ? 'dashicons-yes-alt siteseo-statistics-index-icon' : 'dashicons-dismiss siteseo-statistics-noindex-icon').'"></span></td>
						<td>'.esc_html($content['last_update']).'</td>
						<td style="color:#dc3545;">'.esc_html($content['loss']).'</td>
						<td style="color:#dc3545;">'.esc_html($content['drop_percent']).'</td>
						<td><span class="'.esc_attr($badge_class).'">'.esc_html($content['performance_score']).'</span></td>
					</tr>';
				}
				
				if(empty($content_ranking) && !$data['is_sample']){
					echo'<tr><td colspan="6" style="text-align:center;">'.esc_html__('No data available yet', 'siteseo').'</td></tr>';
				}
				
				echo'</tbody></table>';
			
			// Pagination controls
			if($total_pages > 1){
				echo'<div class="siteseo-pagination" style="margin-top: 20px; text-align: center;">';
				
				// Previous btn
				if($current_page > 1){
					echo'<a href="'.esc_url(add_query_arg('cr_page', $current_page - 1)).'" class="siteseo-option btnSecondary">'.esc_html__('Previous', 'siteseo').'</a> ';
				}
				
				// Page numbers
				for($i = 1; $i <= $total_pages; $i++){
					if($i == $current_page){
						echo'<span class="siteseo-option btnSecondary" style="margin: 0 2px;">'.esc_html($i).'</span> ';
					} else{
						echo'<a href="'.esc_url(add_query_arg('cr_page', $i)).'" class="siteseo-option btnSecondary" style="margin: 0 2px;">'.esc_html($i).'</a> ';
					}
				}
				
				// Next btn
				if($current_page < $total_pages){
					echo'<a href="'.esc_url(add_query_arg('cr_page', $current_page + 1)).'" class="siteseo-option btnSecondary">'.esc_html__('Next', 'siteseo').'</a>';
				}
				
				echo'</div>';
			}
			
			echo'</div>';
		}
	}

	static function audience_tab(){
		self::connect_notices();
		$data = self::fetch_data();
		$country_data = $data['country_data'];
		$device_data = $data['device_data'];

		echo'<div class="siteseo-audience-statisc">
			<div class="siteseo-stats-container">
				<h2 class="siteseo-stat-title">'.esc_html__('Device breakdown', 'siteseo').'</h2>
				 <hr class="siteseo-stats-separator">
				 <canvas id="siteseo_device_statics" height="250px" width="520px" data-sample="'.($data['is_sample'] ? '1' : '0').'"></canvas>
			</div>
			
			<div class="siteseo-stats-container">
				<h2 class="siteseo-stats-title">'.esc_html__('Top countries by click ( Top 5 )', 'siteseo').'</h2>
				<hr class="siteseo-stats-separator">
				<canvas id="siteseo_country_statics" height="300px" width="520px" data-sample="'.($data['is_sample'] ? '1' : '0').'"></canvas>
			</div>
		</div>';

		if(!empty($device_data) || $data['is_sample']){
			echo'<div class="siteseo-stats-container">
				<h2 class="siteseo-stats-title">'.esc_html__('Device Performance', 'siteseo').'</h2>
					<table class="wp-list-table widefat fixed striped siteseo-history-table">
						<thead><tr>
							<th>'.esc_html__('Device', 'siteseo').'</th>
							<th>'.esc_html__('Clicks', 'siteseo').'</th>
							<th>'.esc_html__('Impressions', 'siteseo').'</th>
						</tr>
						</thead>
					<tbody>';
					
					foreach($device_data as $data){
						echo'<tr>
							<td style="font-weight:bold;">'.esc_html( is_array($data['device']) ? implode(', ', $data['device']) : $data['device']).'</td>
							<td>'.esc_html($data['clicks']).'</td>
							<td>'.esc_html($data['impressions']).'</td>
						</tr>';
					}
					
				echo'</tbody></table>
			</div>';
		}

		if(!empty($country_data) || $data['is_sample']){
			echo'<div class="siteseo-stats-container">
				<h2 class="siteseo-stats-title">'.esc_html__('Country Performance ( Top 5 )', 'siteseo').'</h2>
					<table class="wp-list-table widefat fixed striped siteseo-history-table">
						<thead><tr>
							<th>'.esc_html__('Country', 'siteseo').'</th>
							<th>'.esc_html__('Clicks', 'siteseo').'</th>
							<th>'.esc_html__('Impressions', 'siteseo').'</th>
						</tr>
						</thead>
					<tbody>';
					
					foreach($country_data as $data){
						echo '<tr>
							<td style="font-weight:bold;">'.esc_html($data['country']).'</td>
							<td>'.esc_html($data['clicks']).'</td>
							<td>'.esc_html($data['impressions']).'</td>
						</tr>';
					}
					
					echo'</tbody></table>
				</div>';
		}
	}
	
	static function connect_notices(){
		
		$analytics_data = '';
		$gsc_connected = '';
		
		if(class_exists('\SiteSEOPro\GoogleConsole') && method_exists('\SiteSEOPro\GoogleConsole', 'is_connected')){
			$analytics_data = get_option('siteseo_search_console_data', []);

			$gsc_connected = \SiteSEOPro\GoogleConsole::is_connected();
		}
		
		 if(empty($gsc_connected)){
			
			echo'<div class="siteseo-notice is-warning"><p>'.wp_kses_post(__('The data shown here is only a <strong> sample from Google Analytics</strong> how SiteSEO will display your site\'s analytics once connected.', 'siteseo')).'</p>';

			if(class_exists('\SiteSEOPro\GoogleConsole')){
				echo'<form method="post">';
						wp_nonce_field('siteseo_pro_connect_google');
						echo '<input type="hidden" name="redirect_type" value="settings">
						<button type="submit" name="siteseo_pro_connect_btn" class="siteseo-statistics-connect-btn">'.esc_html__('Connect Search Console', 'siteseo') .'</button>
					</form>';
			} else{
				  echo'<a href="https://siteseo.io/pricing" class="siteseo-statistics-connect-btn" target="_blank">'.esc_html__('Buy Pro', 'siteseo').'</a>';
			}
			
			echo'</div>';
		} elseif(empty($analytics_data['top_pages']) && !empty($gsc_connected)){
			echo '<div class="siteseo-notice is-info"><p>'.wp_kses_post(__('Connected to Google Search Console. If this is your first time connecting the site and data doesn’t appear yet, please wait—Google may take a few days to populate the data. You can also try refreshing.', 'siteseo')).'</p></div>';
		}
	}

	static function sample_device_data(){
		 return [
			[
				'device' => 'Mobile',
				'clicks' => '48k',
				'impressions' => '285k',
				'ctr' => '5.2%',
			],
			[
				'device' => 'Desktop',
				'clicks' => '70k',
				'impressions' => '196k',
				'ctr' => '3.8%',
			],
			[
			
				'device' => 'Tablet',
				'clicks' => '10k',
				'impressions' => '185k',
				'ctr' => '8.1%',
			],
		];
	}

	static function sample_country_data(){
		
		 return [
			[
				'country' => 'India',
				'clicks' => '8K',
				'impressions' => '154K',
				'ctr' => '5.2%',
			],
			[
				'country' => 'Poland',
				'clicks' => '5K',
				'impressions' => '132K',
				'ctr' => '3.8%',
			],
			[
			
				'country' => 'South Africa',
				'clicks' => '15K',
				'impressions' => '185k',
				'ctr' => '8.1%',
			],
			[
				'country' => 'Russia',
				'clicks' => '19K',
				'impressions' => '200k',
				'ctr' => '9.5%',
			],
			[
				'country' => 'United kingdom',
				'clicks' => '12K',
				'impressions' => '150k',
				'ctr' => '5.5%',
			],
		];
		
	}
	
	static function sample_metrics_data(){
		return [
			'impressions' => [
				'current' => '15M',
				'change' => '-475.7K',
				'trend' => 'negative',
				'chart_data' => [12, 19, 3, 5, 2, 3, 10, 8, 12, 14, 13, 15]
			],
			'clicks' => [
				'current' => '111.5K',
				'change' => '+1.7K',
				'trend' => 'positive',
				'chart_data' => [7, 11, 5, 8, 3, 7, 4, 5, 6, 7, 6, 8]
			],
			'ctr' => [
				'current' => '0.74%',
				'change' => '+0.03%',
				'trend' => 'positive',
				'chart_data' => [0.5, 0.6, 0.7, 0.65, 0.75, 0.7, 0.6, 0.7, 0.72, 0.74, 0.73, 0.75]
			],
			'position' => [
				'current' => '49',
				'change' => '+1',
				'trend' => 'negative',
				'chart_data' => [55, 50, 45, 50, 48, 52, 55, 50, 49, 47, 48, 49]
			]
		];
	}

	static function sample_top_pages(){
		return [
			[
				'title' => '/blog/',
				'truseo_score' => '95',
				'indexed' => true,
				'clicks' => '4.5K',
				'impressions' => '57.2K',
				'position' => '23',
				'diff' => '+2'
			],
			[
				'title' => '/contact-us/',
				'truseo_score' => '88',
				'indexed' => false,
				'clicks' => '1.2K',
				'impressions' => '1.2M',
				'position' => '40',
				'diff' => '-5'
			],
			[
				'title' => '/support/',
				'truseo_score' => '92',
				'indexed' => false,
				'clicks' => '15K',
				'impressions' => '1.9M',
				'position' => '16',
				'diff' => '+3'
			],
			[
				'title' => '/pricing/',
				'truseo_score' => '85',
				'indexed' => true,
				'clicks' => '8.7K',
				'impressions' => '890K',
				'position' => '12',
				'diff' => '+1'
			],
			[
				'title' => '/features/',
				'truseo_score' => '90',
				'indexed' => true,
				'clicks' => '12.3K',
				'impressions' => '1.5M',
				'position' => '8',
				'diff' => '+4'
			]
		];
	}

	static function sample_keywords(){
		return [
			[
				'keyword' => 'One click seo plugin',
				'clicks' => '8K',
				'ctr' => '5.2%',
				'impressions' => '154K',
				'position' => '3',
				'trend' => 'up',
				'points' => '90'
			],
			[
				'keyword' => 'wordpress seo',
				'clicks' => '5K',
				'ctr' => '3.8%',
				'impressions' => '132K',
				'position' => '7',
				'trend' => 'up',
				'points' => '80'
			],
			[
				'keyword' => 'best seo plugin plugin',
				'clicks' => '15K',
				'ctr' => '8.1%',
				'impressions' => '185K',
				'position' => '2',
				'trend' => 'up',
				'points' => '85'
			],
			[
				'keyword' => 'seo optimization',
				'clicks' => '3.2K',
				'ctr' => '2.1%',
				'impressions' => '152K',
				'position' => '15',
				'trend' => 'down',
				'points' => '88'
			],
			[
				'keyword' => 'website ranking',
				'clicks' => '6.8K',
				'ctr' => '4.5%',
				'impressions' => '151K',
				'position' => '5',
				'trend' => 'up',
				'points' => '70'
			]
		];
	}
	
	static function sample_content_ranking(){
		return [
			[
				'title' => 'Ultimate SEO Guide 2024',
				'indexed' => 'Yes',
				'last_update' => '2024-01-15',
				'loss' => '2.1K',
				'drop_percent' => '5.2%',
				'performance_score' => '88'
			],
			[
				'title' => 'WordPress Optimization Tips',
				'indexed' => 'Yes',
				'last_update' => '2024-01-10',
				'loss' => '1.5K',
				'drop_percent' => '3.8%',
				'performance_score' => '92'
			],
			[
				'title' => 'Mobile SEO Strategies',
				'indexed' => 'No',
				'last_update' => '2024-01-08',
				'loss' => '3.2K',
				'drop_percent' => '8.1%',
				'performance_score' => '75'
			],
			[
				'title' => 'Content Marketing Guide',
				'indexed' => 'Yes',
				'last_update' => '2024-01-12',
				'loss' => '0.8K',
				'drop_percent' => '2.1%',
				'performance_score' => '95'
			]
		];
	}

	static function connect_site_dialogbox(){

		$gsc_sites = '';
		$current_site_url = trailingslashit(get_site_url());

		if(class_exists('\SiteSEOPro\GSCSetup') && method_exists('\SiteSEOPro\GSCSetup', 'get_pre_connected_sites')){
			$gsc_sites = \SiteSEOPro\GSCSetup::get_pre_connected_sites();
		}

		$current_site_exists = false;
		if(!empty($gsc_sites) && !isset($gsc_sites['error'])){
			foreach($gsc_sites as $site){
				if($site['siteUrl'] === $current_site_url){
					$current_site_exists = true;
					break;
				}
			}
		}

		echo'<div id="siteseo-site-connection-dialog" title="'.esc_attr__('Connect site search console', 'siteseo').'" style="display:none;">
			<div class="siteseo-dialog-content">';

		echo'<div id="siteseo-main-section">';

		if($current_site_exists){
			// Tab: Current Site
			echo'<div class="siteseo-option-primary" style="margin-bottom:20px;">
				<p style="color:#1d2327;font-weight:400;font-size:14px;">'.esc_html__('This site is already in your Google Search Console account.', 'siteseo').'</p>
				<div class="siteseo-form-group">
					<input type="text" id="siteseo-site-url" value="' . esc_attr($current_site_url) . '" class="regular-text" readonly
						style="width:100%;padding:8px;background:#f6f7f7;border:1px solid #8c8f94;color:#666;cursor:not-allowed;" />
				</div>
				<div class="siteseo-dialog-actions">
					<button type="button" class="button button-primary siteseo-action-btn" id="siteseo-connect-existing">'.esc_html__('Connect', 'siteseo').'</button>
					<span class="spinner"></span>
				</div>
			</div>';
			if(!empty($gsc_sites)){
				echo '<div class="siteseo-option-secondary">
					<button type="button" class="button button-link" id="siteseo-show-existing-properties" style="width:100%;text-decoration:none;">'.esc_html__('Select from existing sites', 'siteseo').'</button>
				</div>';
			}
		} else{
			// Not connected yet
			echo'<div class="siteseo-option-primary" style="margin-bottom:20px;">
				<p style="color:#1d2327;font-weight:400;font-size:14px;">'.esc_html__('This domain isn\'t yet connected to Google Search Console.', 'siteseo').'</p>
				<div class="siteseo-form-group">
					<input type="text" id="siteseo-new-domain-url" value="' . esc_attr($current_site_url) . '" class="regular-text" readonly
						style="width:100%;padding:8px;background:#f6f7f7;border:1px solid #8c8f94;color:#666;cursor:not-allowed;" />
				</div>
				<button type="button" class="button button-primary siteseo-action-btn siteseo-create-btn" id="siteseo-create-gsc-property" style="margin-bottom:10px;">'.esc_html__('Connect New Domain', 'siteseo').'</button>
				<span class="spinner"></span>
			</div>';

			if(!empty($gsc_sites)){
				echo'<div class="siteseo-option-secondary">
					<button type="button" class="button button-link" id="siteseo-show-existing-properties" style="width:100%;text-decoration:none;">'.esc_html__('Connect with existing properties', 'siteseo').'</button>
				</div>';
			}
		}

		echo'</div>';

		if(!empty($gsc_sites) && !isset($gsc_sites['error'])){
			echo'<div id="siteseo-existing-properties-section" style="display:none;">
				<p style="color:#1d2327;font-weight:400;font-size:14px;">'. esc_html__('Select an existing site from your Google Search Console account.', 'siteseo').'</p>
				<div class="siteseo-form-group">
					<select id="siteseo-site-url" name="existing_site_url" class="siteseo-select-box">';

						foreach($gsc_sites as $site){
							echo'<option value="'.esc_attr($site['siteUrl']).'">'.esc_html($site['siteUrl']).'</option>';
						}

			echo'</select>
				</div>
				<div class="siteseo-dialog-actions">
					<button type="button" class="button button-secondary siteseo-action-btn" id="siteseo-back-to-main">'.esc_html__('Back', 'siteseo').'</button>
					<button type="button" class="button button-primary siteseo-action-btn" id="siteseo-connect-existing">'.esc_html__('Connect', 'siteseo').'</button>
					<span class="spinner" style="margin-top:7px;"></span>
				</div>
			</div>';
		}

		echo'</div></div>'; // End dialog content + wrapper
	}
}
PKv�f\�O������settings/titles.phpnu�[���<?php
/*
* SITESEO
* https://siteseo.io
* (c) SiteSEO Team
*/

namespace SiteSEO\Settings;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class Titles{

	static function menu(){
		global $siteseo;

		$current_tab = isset($_GET['tab']) ? sanitize_key($_GET['tab']) : 'tab_siteseo_home'; // Default tab

		$titles_meta_subtabs = [
			'tab_siteseo_home' => esc_html__('Home', 'siteseo'),
			'tab_siteseo_post_types' => esc_html__('Post types', 'siteseo'),
			'tab_siteseo_archives' => esc_html__('Archives', 'siteseo'),
			'tab_siteseo_taxonomies' => esc_html__('Taxonomies', 'siteseo'),
			'tab_siteseo_advanced' => esc_html__('Advanced','siteseo')
		];

		echo '<div id="siteseo-root">';
		Util::admin_header();

		echo '<form method="post" id="siteseo-form" class="siteseo-option" name="siteseo-flush">';

		wp_nonce_field('siteseo_title_settings');

		$titles_meta_toggle = isset($siteseo->setting_enabled['toggle-titles']) ? $siteseo->setting_enabled['toggle-titles'] : '';
		$nonce = wp_create_nonce('siteseo_toggle_nonce');

		Util::render_toggle('Titles & Metas - SiteSEO', 'titles_meta_toggle', $titles_meta_toggle, $nonce);

		echo '<div id="siteseo-tabs" class="wrap">
		<div class="siteseo-nav-tab-wrapper">';
		
		foreach($titles_meta_subtabs as $tab_key => $tab_caption) {
			$active_class = ($current_tab === $tab_key) ? ' siteseo-nav-tab-active' : '';
			echo '<a id="' . esc_attr($tab_key) . '-tab" class="siteseo-nav-tab' . esc_attr($active_class) . '" data-tab="' . esc_attr($tab_key) . '">' . esc_html($tab_caption) . '</a>';
		}

		echo '</div>     
		<div class="tab-content-wrapper">
		<div class="siteseo-tab '.($current_tab == 'tab_siteseo_home' ? ' active' : '').'" id="tab_siteseo_home" style="display: none;">';
		self::home();
		echo '</div>
		<div class="siteseo-tab '.($current_tab == 'tab_siteseo_post_types' ? ' active' : '').'" id="tab_siteseo_post_types" style="display: none;">';
		self::post_types();
		echo '</div>
		<div class="siteseo-tab '.($current_tab == 'tab_siteseo_archives' ? ' active' : '').'" id="tab_siteseo_archives" style="display: none;">';
		self::archives();
		echo '</div>
		<div class="siteseo-tab '.($current_tab == 'tab_siteseo_taxonomies' ? ' active' : '').'" id="tab_siteseo_taxonomies" style="display: none;" style="display: none;">';
		self::taxonomies();
		echo '</div>
		<div class="siteseo-tab '.($current_tab == 'tab_siteseo_advanced' ? ' active' : '').'" id="tab_siteseo_advanced">';
		self::advanced(); 
		echo '</div>
		</div>';
		Util::submit_btn();
		echo '</form></div>';

	}

    static function home(){
		global $siteseo;

		if(!empty($_POST['submit'])){
			self::save_settings();
		}

		$options = get_option('siteseo_titles_option_name');
		//$options = $siteseo->titles_settings;

		$option_separator = !empty($options['titles_sep']) ? $options['titles_sep'] : '';
		$option_site_title = !empty($options['titles_home_site_title']) ? $options['titles_home_site_title'] : '';
		$option_site_title_alt = !empty($options['titles_home_site_title_alt']) ? $options['titles_home_site_title_alt'] : '';
		$option_site_desc = !empty($options['titles_home_site_desc']) ? $options['titles_home_site_desc'] : '';

		if(get_option('show_on_front') === 'page'){
			$front_page_id = get_option('page_on_front');
			$edit_link = get_edit_post_link($front_page_id, '');
			
			echo'<div class="siteseo_wrap_label">
				<div class="siteseo-notice is-warning">
					<span id="dashicons-warning" class="dashicons dashicons-info"></span>&nbsp;
					<p>'. // translators: %s is the platform name
					wp_kses_post(sprintf(__('A static page is set as your site front page <strong>(%s Dashboard > Settings > Reading)</strong>. To add an SEO title, description, and meta tags for the homepage, please click here -', 'siteseo'), !defined('SITEPAD') ? 'WP' : 'Sitepad')) . '</p>
					<div>
						<a href="'.esc_url($edit_link).'" target="_blank">'.esc_html__('Edit Home Page', 'siteseo').'</a>
					</div>
				</div>
			</div>';
			return;
		}

		echo '<h3 class="siteseo-tabs">'.esc_html__('HOME','siteseo').'</h3>
		<div class="siteseo-notice">
			<span id="siteseo-dash-icon" class="dashicons dashicons-info"></span>&nbsp;
			<p>'.esc_html__('Search engines use the title and meta description to create a snippet of your site for the search results page.', 'siteseo').'</p>
		</div>

		<p>'.esc_html__('Personalize the title and meta description for your homepage.','siteseo').'</p>

		<span class="dashicons dashicons-external"></span>
		<a href="'.esc_attr('https://siteseo.io/docs/meta/google-uses-the-wrong-meta-title-meta-description-in-search-results/').'" target="_blank">'.esc_html__('Incorrect meta title or description appearing in search results?', 'siteseo').'</a>

		<table class="form-table">
			<tbody>
                <tr>
                    <th scope="row" style="user-select:auto;">'.esc_html__('Separator','siteseo').'</th>
                    <td>
                        <input type="text" name="siteseo_options[separator]" placeholder="'.esc_attr__('Specify your separator, e.g:-','siteseo').'" value="'.esc_attr($option_separator).'">
                        <p class="description">'.esc_attr__('Include this separator using %%sep%% in your title and meta description.','siteseo').'</p>
                    </td>
                </tr>

                <td colspan="2"><span class="dashed-line"></span></td>

                <tr>
                    <th scope="row" style="user-select:auto;">'.esc_html__('Site title','siteseo').'</th>
                    <td>
                        <input type="text" name="siteseo_options[site_title]" value="'.esc_attr($option_site_title).'" placeholder="'.esc_html__('My fantastic site','siteseo').'">
                        <div class="wrap-tags">
                            <button class="tag-title-btn" id="btn-site-title" data-tag="%%sitetitle%%"><span id="icon" class="dashicons dashicons-insert"></span>'.
							esc_html__('SITE TITLE','siteseo').'</button>
                            <button class="tag-title-btn" id="btn-separator" data-tag="%%sep%%"><span id="icon" class="dashicons dashicons-insert"></span>'.
							esc_html__('SEPARATOR','siteseo').'</button>
                            <button class="tag-title-btn" id="btn-tagline" data-tag="%%tagline%%"><span id="icon" class="dashicons dashicons-insert"></span>'.
							esc_html__('TAGLINE','siteseo').'</button>';
							siteseo_suggestion_button();
                        echo '</div>
                    </td>
                </tr>

                <td colspan="2"><span class="dashed-line"></span></td>

                <tr>
                    <th scope="row" style="user-select:auto;">'.esc_html__('Alternative site title','siteseo').'</th>
                    <td>
                        <input type="text" value="'.esc_attr($option_site_title_alt).'"  name="siteseo_options[alt_site_title]" placeholder="'.esc_html__('Alternative website title','siteseo').'">
                        <p class="description">'.esc_html__('The alternative name of the website (e.g., a commonly recognized acronym or shorter name, if applicable). Ensure the name meets the criteria.', 'siteseo').'</p>
                    </td>
                </tr>

                <td colspan="2"><span class="dashed-line"></span></td>

                <tr>
                    <th scope="row" style="user-select:auto;">'.esc_html__('Meta description','siteseo').'</th>
                    <td>
                        <textarea type="text" name="siteseo_options[media_desc]" placeholder="'.esc_html__('This is an awesome website about galactic creatures.','siteseo').'">'.esc_html($option_site_desc).'</textarea>
                        <div class="wrap-tags">
                            <button class="tag-title-btn" id="btn-tagline-meta" data-tag="%%tagline%%"><span id="icon" class="dashicons dashicons-insert"></span>'.
							esc_html__('TAGLINE','siteseo').'</button>';
                            siteseo_suggestion_button();  
                       echo '</div>
                    </td>
                </tr>
            </tbody>
        </table>
		<input type="hidden" name="siteseo_options[home_tab]" value="1"/>';
    }

    static function advanced(){
		global $siteseo;

		if(!empty($_POST['submit'])){
			self::save_settings();
		}

        //$options = $siteseo->titles_settings;
		$options = get_option('siteseo_titles_option_name');

		$option_noindex = !empty($options['titles_noindex']) ? $options['titles_noindex'] : '';
		$option_nofollow = !empty($options['titles_nofollow']) ? $options['titles_nofollow'] : '';
		$option_noimage = !empty($options['titles_noimageindex']) ? $options['titles_noimageindex'] : '';
		$option_noarchive = !empty($options['titles_noarchive']) ? $options['titles_noarchive'] : '';
		$option_nosnippet = !empty($options['titles_nosnippet']) ? $options['titles_nosnippet'] : '';
		$option_nositelinkssearchbox = !empty($options['titles_nositelinkssearchbox']) ? $options['titles_nositelinkssearchbox'] : '';
		$option_page_rel = !empty($options['titles_paged_rel']) ? $options['titles_paged_rel'] : '';
		$option_paged_noindex = !empty($options['titles_paged_noindex']) ? $options['titles_paged_noindex'] : '';
		$option_attachments_noindex = !empty($options['titles_attachments_noindex']) ? $options['titles_attachments_noindex'] : '';

		echo '<h3 class="siteseo-tabs">'.esc_html__('Advanced','siteseo').'</h3>
		<p>'.esc_html__('Customize your metas for all pages','siteseo').'</p>

		<table class="form-table">
			<tbody>
				<tr>
					<th scope="row" style="user-select:auto;">'.esc_html__('noindex','siteseo').'</th>
					<td>
						<label>
						<input name="siteseo_options[noindex]" type="checkbox" '.(!empty($option_noindex) ? 'checked="yes"' : '') . ' value="1"/>' . esc_html__('noindex', 'siteseo') . 
						'</label>
						<p class="description">'.esc_attr__('Do not show all pages of the site in Google search results and avoid displaying "Cached" links in search results.','siteseo').'</p>
						'.wp_kses_post('<p class="description">Check also the<strong>"Search engine visibility"</strong> setting from the <a href="%s">WordPress Reading page</a></p>').'
					</td>
				</tr>

				<td colspan="2"><span class="dashed-line"></span></td>

				<tr>
					<th scope="row" style="user-select:auto;">'.esc_html__('nofollow','siteseo').'</th>
					<td>
						<label>
							<input name="siteseo_options[no_follow]" type="checkbox"'.(!empty($option_nofollow) ? 'checked="yes"' : '') . ' value="1"/>'. esc_html__('nofollow', 'siteseo'). 
						'</label>
						<p class="description">'.esc_html__('Do not follow links on all pages.','siteseo').'</p>
					</td>
				<tr>

				<td colspan="2"><span class="dashed-line"></span></td>
					
					<tr>
						<th scope="row" style="user-select:auto;">'.esc_html__('noimageindex','siteseo').'</th>
						<td>
							<label>
								<input name="siteseo_options[no_image]" type="checkbox"'.(!empty($option_noimage) ? 'checked="yes"' : '').' value="1"/>'. esc_html__('noimageindex', 'siteseo'). 
							'</label>
							<p class="description">'.esc_html__('Do not follow links on any pages.','siteseo').'</p>
						</td>
					<tr>

				<td colspan="2"><span class="dashed-line"></span></td>

					<tr>
						<th scope="row" style="user-select:auto;">'.esc_html__('noarchive','siteseo').'</th>
						<td>
							<label>
								<input name="siteseo_options[no_archive]" type="checkbox"'.(!empty($option_noarchive) ? 'checked="yes"' : '').' value="1"/>' . esc_html__('noarchive', 'siteseo'). 
							'</label>
							<p class="description">'.esc_html__('Do not show a "Cached" link in Google search results.','siteseo').'</p>
						</td>
					</tr>

				<td colspan="2"><span class="dashed-line"></span></td>

						<tr>
							<th scope="row" style="user-select:auto;">'.esc_html__('nosnippet','siteseo').'</th>
							<td>
								<label>
									<input name="siteseo_options[no_snippet]" type="checkbox"'.(!empty($option_nosnippet) ? 'checked="yes"' : '').' value="1"/>' . esc_html__('nosnippet', 'siteseo'). 
								'</label>
								<p class="description">'.esc_html__('Do not show a description in the Google search results for any pages.','siteseo').'</p>
							</td>
						</tr>

				<td colspan="2"><span class="dashed-line"></span></td>

						<tr>
							<th scope="row" style="user-select:auto;">'.esc_html__('nositelinkssearchbox','siteseo').'</th>
							<td>
								<label>
									<input name="siteseo_options[no_site_links_searchbox]" type="checkbox"'.(!empty($option_nositelinkssearchbox) ? 'checked="yes"' : ''). ' value="1"/>' . esc_html__('nositelinkssearchbox', 'siteseo') . 
								'</label>
								<p class="description">'.esc_html__('Prevents Google from displaying a sitelinks search box in search results. Enabling this option will remove the "Website" schema from your source code.','siteseo') .'</p>
							</td>
						</tr>

                <td colspan="2"><span class="dashed-line"></span></td>

                 <tr>
                    <th scope="row" style="user-select:auto;">'.esc_html__('Indicate paginated content to Google','siteseo').'</th>
                    <td>
                        <label>
                            <input name="siteseo_options[page_rel]" type="checkbox"' . (!empty($option_page_rel) ? 'checked="yes"' : '') . ' value="1"/>' . esc_html__('Add rel next/prev link in head of paginated archive pages', 'siteseo') . 
                        '</label>
                        <p class="description">'.esc_html__('eg: https://example.com/category/my-category/page/2/.','siteseo').'</p>
                    </td>
                </tr>

                <td colspan="2"><span class="dashed-line"></span></td>

                 <tr>
                    <th scope="row" style="user-select:auto;">'.esc_html__('noindex on paged archives','siteseo').'</th>
                    <td>
                        <label>
                            <input name="siteseo_options[titles_paged_noindex]" type="checkbox" '. (!empty($option_paged_noindex) ? 'checked="yes"' : '') . ' value="1"/>'.esc_html__('Add a "noindex" meta robots for all paginated archive pages', 'siteseo'). 
                        '</label>
                        <p class="description">'.esc_html__('eg: https://example.com/category/my-category/page/2/.','siteseo').'</p>
                    </td>
                </tr>

                <td colspan="2"><span class="dashed-line"></span></td>

                <tr>
                    <th scope="row" style="user-select:auto;">'.esc_html__('noindex on attachment pages','siteseo').'</th>
                    <td>
                        <label>
                            <input name="siteseo_options[attachments_noindex]" type="checkbox"' . (!empty($option_attachments_noindex) ? 'checked="yes"' : '').' value="1"/>'.esc_html__(' Add a "noindex" meta robots for all attachment pages', 'siteseo') . 
                        '</label>
                        <p class="description">'.esc_html__('eg: https://example.com/my-media-attachment-page.','siteseo').'</p>
                    </td>
                </tr>
            </tbody>
        </table><input type="hidden" name="siteseo_options[advanced_tab]" value="1"/>';
    }

	static function archives(){
		global $siteseo;

		if(!empty($_POST['submit'])){
			self::save_settings();
		}

        	// $options = $siteseo->titles_settings;
		$options = get_option('siteseo_titles_option_name');

        	// Load settings
		$option_author_title = !empty($options['titles_archives_author_title']) ? $options['titles_archives_author_title'] : '';
		$option_author_desc = !empty($options['titles_archives_author_desc']) ? $options['titles_archives_author_desc'] : '';
		$option_author_noindex = !empty($options['titles_archives_author_noindex']) ? $options['titles_archives_author_noindex'] : '';
		$option_author_disabled = !empty($options['titles_archives_author_disable']) ? $options['titles_archives_author_disable'] : '';
		$option_date_title = !empty($options['titles_archives_date_title']) ? $options['titles_archives_date_title'] : '';
		$option_date_desc = !empty($options['titles_archives_date_desc']) ? $options['titles_archives_date_desc'] : '';
		$option_date_noindex = !empty($options['titles_archives_date_noindex']) ? $options['titles_archives_date_noindex'] : '';
		$option_date_disabled = !empty($options['titles_archives_date_disable']) ? $options['titles_archives_date_disable'] : '';
		$option_search_title = !empty($options['titles_archives_search_title']) ? $options['titles_archives_search_title'] : '';
		$option_search_desc = !empty($options['titles_archives_search_desc']) ? $options['titles_archives_search_desc'] : '';
		$option_search_noindex = !empty($options['titles_archives_search_title_noindex']) ? $options['titles_archives_search_title_noindex'] : '';
		$option_404_title = !empty($options['titles_archives_404_title']) ? $options['titles_archives_404_title'] : '';
		$option_404_desc = !empty($options['titles_archives_404_desc']) ? $options['titles_archives_404_desc'] : '';
		$author_base_url = !empty($options['author_base_url']) ? $options['author_base_url'] : 'author';

		$archives_fields = [
			'author-archives' => 'Author archives',
			'date-archives'   => 'Date archives',
			'search-archives' => 'Search archives',
			'404-archives'    => '404 archives'
		];
		
		$post_types = siteseo_post_types();

		echo'<table class="form-table">
			<tbody>
				<tr>
					<th scope="row">
					<div class="siteseo-container">';
					$is_first = true;
					foreach($archives_fields as $post_key => $post_val){
						$active_class = $is_first ? 'active' : '';
						echo '<a href="-' . esc_attr($post_key) . '" class="' . esc_attr($active_class) . '">' . esc_html($post_val) . '</a>';
						$is_first = false;
					}

					foreach($post_types as $post_name => $post_type){
						if($post_type->has_archive){
							$active_class = $is_first ? 'active' : '';
							echo '<a href="-' . esc_attr($post_name) . '" class="' . esc_attr($active_class) . '">' . esc_html($post_type->label) . '</a>';
							$is_first = false;
						}
					}

					echo '</div>
					</th>
					<td>
					<div id="author-archives">
						<h3>'.esc_html__('Archives', 'siteseo').'</h3>
						<div class="siteseo_wrap_label">
							<p class="description">'.esc_html__('Personalize your meta descriptions for all archives.','siteseo').'</p>
						</div>
						<span class="line"></span>
						<h3>'.esc_html__('Author archives', 'siteseo').'</h3>
						<div class="siteseo_wrap_label"><p>'.esc_html__('Title template', 'siteseo').'</p></div>
						<input type="text" name="siteseo_options[author_title]" value="'. esc_attr($option_author_title) . '">
    
						<div class="wrap-tags">
							<button class="tag-title-btn" id="btn-author-acrhive-title" data-tag="%%post_author%%">
								<span id="icon" class="dashicons dashicons-insert"></span>'.esc_html__('POST AUTHOR','siteseo').'
							</button>
							<button class="tag-title-btn" id="btn-author-acrhive-separator" data-tag="%%sep%%">
								<span id="icon" class="dashicons dashicons-insert"></span>'.esc_html__('SEPARATOR','siteseo').'
							</button>
							<button class="tag-title-btn" id="btn-author-acrhive-sitetitle" data-tag="%%sitetitle%%">
								<span id="icon" class="dashicons dashicons-insert"></span>'.esc_html__('SITE TITLE','siteseo').'
							</button>';
							siteseo_suggestion_button();
						echo '</div>
    
						<div class="siteseo_wrap_label"><p>Meta description template</p></div>
						<textarea name="siteseo_options[author_desc]">'.esc_html($option_author_desc) . '</textarea><br>
						<div class="siteseo_wrap_label">
							<label>
							<input name="siteseo_options[author_noindex]" type="checkbox" '.(!empty($option_author_noindex) ? 'checked="yes"' : '').' value="1"/>' . wp_kses_post('Do not display author archives in search engine results <strong>(noindex)</strong>') .'
							</label>
    
							<label>
							<input name="siteseo_options[author_disable]" type="checkbox" '.(!empty($option_author_disabled) ? 'checked="yes"' : '').' value="1"/>
							' . esc_html__('Disable author archives', 'siteseo') . '
							</label>
						</div>

						<div class="siteseo_wrap_label"><p style="font-weight: 500;">'.esc_html__('Author base', 'siteseo');
						if(!defined('SITESEO_PRO_VERSION')){
							echo'<span class="siteseo-pro-tag">Pro</span>';
						}

						echo'</p></div>
						<input type="text" name="siteseo_options[author_base]" value="' . esc_attr($author_base_url) . '" ' .(!defined('SITESEO_PRO_VERSION') ? 'disabled="disabled" style="cursor:not-allowed;"' : '').'>
						<div class="siteseo_wrap_label"><p>'.esc_html__('Change the /author/ slug used in author archive URLs.', 'siteseo').'</p>

					</div>
    
					<div id="date-archives">
						<h3>'.esc_html__('Date archives', 'siteseo').'</h3>
						<div class="siteseo_wrap_label"><p>'.esc_html__('Title template','siteseo').'</p></div>
							<input type="text" name="siteseo_options[date_title]" value="'. esc_attr($option_date_title) .'">
							<div class="wrap-tags">
								<button class="tag-title-btn" id="btn-date-archive" data-tag="%%archive_date%%">
									<span id="icon" class="dashicons dashicons-insert"></span>'.esc_html__('DATE ARCHIVES','siteseo').'
								</button>
								<button class="tag-title-btn" id="btn-date-separator" data-tag="%%sep%%">
									<span id="icon" class="dashicons dashicons-insert"></span>'.esc_html__('SEPARATOR','siteseo').'
								</button>
								<button class="tag-title-btn" id="btn-date-sitetitle" data-tag="%%sitetitle%%">
									<span id="icon" class="dashicons dashicons-insert"></span>'.esc_html__('SITE TITLE','siteseo').'
								</button>';
								siteseo_suggestion_button();
							echo '</div>
    
						<div class="siteseo_wrap_label"><p>'.esc_html__('Meta description template','siteseo').'</p></div>
						<textarea name="siteseo_options[date_desc]">'.esc_attr($option_date_desc).'</textarea><br>
						<div class="siteseo_wrap_label">
							<label>
							<input name="siteseo_options[date_noindex]" type="checkbox" '.(!empty($option_date_noindex) ? 'checked="yes"' : '').' value="1"/>' . wp_kses_post('Do not display date archives in search engine results <strong>(noindex)</strong>') . '
							</label>

							<label>
							<input name="siteseo_options[date_disable]" type="checkbox" '.(!empty($option_date_disabled) ? 'checked="yes"' : '').' value="1"/>
							' . esc_html__('Disable date archives', 'siteseo') . '
							</label>
						</div>
						<span class="line"><span>
					</div>
						
					<div id="search-archives">
						<h3>Search archives</h3>
						<div class="siteseo_wrap_label"><p>'.esc_html__('Title template','siteseo').'</p></div>
						<input type="text" name="siteseo_options[search_title]" value="'.esc_attr($option_search_title).'">

						<div class="wrap-tags">
							<button class="tag-title-btn" id="btn-search-keyword" data-tag="%%search_keywords%%">
							<span id="icon" class="dashicons dashicons-insert"></span>'.esc_html__('SEARCH KEYWORDS','siteseo').'
							</button>
							<button class="tag-title-btn"  id="btn-search-separator" data-tag="%%sep%%">
							<span id="icon" class="dashicons dashicons-insert"></span>'.esc_html__('SEPARATOR','siteseo').'
							</button>
							<button class="tag-title-btn" id="btn-search-sitetitle" data-tag="%%sitetitle%%">
							<span id="icon" class="dashicons dashicons-insert"></span>'.esc_html__('SITE TITLE','siteseo').'
							</button>';
							siteseo_suggestion_button();
						echo '</div>

						<div class="siteseo_wrap_label"><p>'.esc_html__('Meta description template','siteseo').'</p></div>
						<textarea name="siteseo_options[search_desc]">'.esc_attr($option_search_desc).'</textarea><br>
						<div class="siteseo_wrap_label">
							<label>
							<input name="siteseo_options[search_noindex]" type="checkbox" '.(!empty($option_search_noindex) ? 'checked="yes"' : '').' value="1"/>
							' . wp_kses_post('Do not display date archives in search engine results <strong>(noindex)</strong>') . '
							</label>
						</div>
						<span class="line"><span>
					</div>
						
					<div id="404-archives">
						<h3>404 archives</h3>
						<div class="siteseo_wrap_label"><p>'.esc_html__('Title template','siteseo').'</p></div>
						<input type="text" name="siteseo_options[title_404]" value="'.esc_attr($option_404_title).'">

						<div class="wrap-tags">
							<button class="tag-title-btn" id="btn-404-sitetitle" data-tag="%%sep%%">
								<span id="icon" class="dashicons dashicons-insert"></span>'.esc_html__('SEPARATOR','siteseo').'
							</button>
							<button class="tag-title-btn" id="btn-404-separator" data-tag="%%sitetitle%%">
								<span id="icon" class="dashicons dashicons-insert"></span>'.esc_html__('SITE TITLE','siteseo').'
							</button>';
						siteseo_suggestion_button();
						echo '</div>

						<div class="siteseo_wrap_label"><p>'.esc_html__('Meta description template','siteseo').'</p></div>
						<textarea name="siteseo_options[desc_404]">'.esc_attr($option_404_desc).'</textarea><br>
					</div>
					<br/><br/>
					<span class="line"></span>';

				foreach($post_types as $post_name => $post_type){
					if(empty($post_type->has_archive)){
						continue;
					}

					$post_data = isset($options['titles_archive_titles'][$post_name]) ? $options['titles_archive_titles'][$post_name] : '';

					$archive_title = !empty($post_data['archive_title'])? $post_data['archive_title'] : '';
					$archive_description = !empty($post_data['archive_desc']) ? $post_data['archive_desc'] : '';
					$archive_noindex = !empty($post_data['archive_noindex']) ? $post_data['archive_noindex'] : '';
					$archive_nofollow = !empty($post_data['archive_nofollow']) ? $post_data['archive_nofollow'] : '';

					$value_check = !empty($options['titles_archive_titles'][$post_name]['archive_title']) ? $options['titles_archive_titles'][$post_name]['archive_title'] : '';

					echo'<div id="'.esc_attr($post_name).'">
						<h3>'.esc_html($post_type->label).'</h3>
						<div class="siteseo_wrap_label"><p>'.esc_html__('Title template','siteseo').'</p></div>
						<input type="text" name="siteseo_options['.esc_attr($post_name).'][archive_title]" value="'.esc_attr($archive_title).'">

						<div class="wrap-tags">
							<button class="tag-title-btn" data-tag="%%cpt_plural%%">
								<span id="icon" class="dashicons dashicons-insert"></span>'.esc_html__('POST TYPE ARCHIVE NAME','siteseo').'
							</button>
							<button class="tag-title-btn" data-tag="%%sep%%">
								<span id="icon" class="dashicons dashicons-insert"></span>'.esc_html__('SEPARATOR','siteseo').'
							</button>
							<button class="tag-title-btn" data-tag="%%sitetitle%%">
								<span id="icon" class="dashicons dashicons-insert"></span>'.esc_html__('SITE TITLE','siteseo').'
							</button>';
						   siteseo_suggestion_button();
						echo'</div>

						<div class="siteseo_wrap_label"><p>'.esc_html__('Meta description template','siteseo').'</p></div>
						<textarea name="siteseo_options['.esc_attr($post_name).'][archive_desc]">'.esc_attr($archive_description).'</textarea><div class="wrap-tags">';
						siteseo_suggestion_button();
					echo'</div></div><br>
					<div class="siteseo_wrap_label">
						<label>
						<input name="siteseo_options['.esc_attr($post_name).'][archive_noindex]" type="checkbox" '.(!empty($archive_noindex) ? 'checked="yes"' : '').' value="1"/>
						' . wp_kses_post('Do not display author archives in search engine results <strong>(noindex)</strong>') .'
						</label><br/><br/>
						<label>
						<input name="siteseo_options['.esc_attr($post_name).'][archive_nofollow]" type="checkbox" '.(!empty($archive_nofollow) ? 'checked="yes"' : 'value="1"').' />'.wp_kses_post(__('Do not follow links for this taxonomy archive<strong>(nofollow)</strong>', 'siteseo')).'
						</label>
					</div><span class="line"><span>';
				}
	                    echo'</td>
	                </tr>
	            </tbody>
	        </table>
	        <input type="hidden" name="siteseo_options[archives_tab]" value="1"/>';
	}
    

    static function post_types(){
        global $siteseo;

		if(!empty($_POST['submit'])){
			self::save_settings();
		}

		$options = get_option('siteseo_titles_option_name');
		$post_types = siteseo_post_types();

        echo '<table class="form-table">
                <tbody>
                    <tr>
                        <th scope="row">
                            <div class="siteseo-container">';
                                $is_first = true;
                                foreach($post_types as $post_type => $post_arr){
                                    $active_class = $is_first ? 'active' : '';
                                    echo '<a href="#'.esc_attr($post_type).'-types" class="'.esc_attr($active_class).'">'.esc_html($post_arr->labels->name).'</a>';
                                    $is_first = false;
                                }
                        echo '</div>
                        </th><td>
						<div>
							<h3>'.esc_html__('Post Types', 'siteseo').'</h3>
						   <div class="siteseo_wrap_label"><p class="description">'.esc_html__('Personalize your titles and meta descriptions for single custom post types.', 'siteseo').'</p></div>
						</div>';

		foreach($post_types as $post_type => $post_arr){
			// Load array
			$post_data = isset($options['titles_single_titles'][$post_type]) ? $options['titles_single_titles'][$post_type] : '';

			// Load settings
			$option_post_disabled = !empty($post_data['disabled']) ? true : false;
			$option_post_title = !empty($post_data['title']) ? $post_data['title'] : '';
			$option_post_desc = !empty($post_data['description']) ? $post_data['description'] : '';
			$option_noindex = !empty($post_data['noindex']) ? $post_data['noindex'] : '';
			$option_nofollow = !empty($post_data['nofollow']) ? $post_data['nofollow'] : '';
			$option_date = !empty($post_data['date']) ? $post_data['date'] : '';
			$option_thumb_gcs = !empty($post_data['thumb_gcs']) ? $post_data['thumb_gcs'] : '';

			echo '<div id="'.esc_attr($post_type).'-types">';
				echo '<div class="siteseo-toggle-cnt">
						<h3>'.esc_html($post_arr->labels->name.' ['.$post_type.']').'</h3>&nbsp;&nbsp;
						<div class="siteseo-toggle-meta '.($option_post_disabled ? '' : 'active').'" id="siteseo-toggle-meta-'.esc_attr($post_type).'"></div>
						<span id="siteseo-arrow-icon" class="dashicons dashicons-arrow-left-alt siteseo-arrow-icon"></span>
						<p class="toggle_state_posts" id="toggle_state_'.esc_attr($post_type).'">'.(!$option_post_disabled ? ' Click to hide any SEO metaboxes / columns for this post type' : ' Click to show any SEO metaboxes / columns for this post type').'</p>
						<input type="hidden" name="siteseo_options['.esc_attr($post_type).'][disabled]" id="enable_'.esc_attr($post_type).'_toggle" value="'.esc_attr($option_post_disabled).'" class="siteseo-suboption-toggle">
					</div>
					
					<div class="siteseo_wrap_label"><p>'.esc_html__('Title template', 'siteseo').'</p></div>
					<input type="text" name="siteseo_options['.esc_attr($post_type).'][title]" value="'.esc_attr($option_post_title).'">
					<div class="wrap-tags">
						<button class="tag-title-btn" id="btn-post-title" data-tag="%%post_title%%">
							<span id="icon" class="dashicons dashicons-insert"></span>'.esc_html__('POST TITLE', 'siteseo').'
						</button>
						<button class="tag-title-btn" id="btn-post-separator" data-tag="%%sep%%">
							<span id="icon" class="dashicons dashicons-insert"></span>'.esc_html__('SEPARATOR', 'siteseo').'
						</button>
						<button class="tag-title-btn" id="btn-post-site-title" data-tag="%%sitetitle%%">
							<span id="icon" class="dashicons dashicons-insert"></span>'.esc_html__('SITE TITLE', 'siteseo').'
						</button>';
						siteseo_suggestion_button();
					echo '</div>
					<div class="siteseo_wrap_label"><p class="description">'.esc_html__('Meta description template', 'siteseo').'</p></div>
					<textarea name="siteseo_options['.esc_attr($post_type).'][desc]">'.esc_attr($option_post_desc).'</textarea>
					<div class="wrap-tags">
						<button class="tag-title-btn" id="btn-'.esc_attr($post_type).'-meta" data-tag="%%post_excerpt%%">
							<span id="icon" class="dashicons dashicons-insert"></span>'.esc_html__('POST EXCERPT', 'siteseo').'
						</button>';
						siteseo_suggestion_button();
					echo '</div>
					<div class="siteseo_wrap_label">
						<label>
							<input name="siteseo_options['.esc_attr($post_type).'][noindex]" type="checkbox" '.(!empty($option_noindex) ? 'checked="yes"' : 'value="1"').' />
							'.wp_kses_post(__('Do not display this single post type in search engine results <strong>(noindex)</strong>', 'siteseo')).'
						</label>
					</div>';
					
					if(!empty($option_noindex)){
						echo '<div class="siteseo_wrap_label">
							<div class="siteseo-notice is-error">
								<p>'.wp_kses_post(__('This custom post type is <strong>NOT</strong> excluded from your XML sitemaps despite the fact that it is set to <strong>NOINDEX</strong>.', 'siteseo')).'
								</p>
							</div>
						</div>';
					}
					
					echo '<div class="siteseo_wrap_label">
						<label>
							<input name="siteseo_options['.esc_attr($post_type).'][nofollow]" type="checkbox" '.(!empty($option_nofollow) ? 'checked="yes"' : 'value="1"').' />
							'.wp_kses_post(__('Do not follow links for this single post type <strong>nofollow</strong>', 'siteseo')).'
						</label>
					</div>
					<div class="siteseo_wrap_label">
						<label>
							<input name="siteseo_options['.esc_attr($post_type).'][date]" type="checkbox" '.(!empty($option_date) ? 'checked="yes"' : 'value="1"').' />
							'.esc_html__('Display date in Google search results by adding article:published_time and article:modified_time meta?', 'siteseo').'
						</label>
						<p class="description">'. esc_html__('Unchecking this does not prevent Google from displaying the post date in search results.', 'siteseo').'</p>
					</div>
					<div class="siteseo_wrap_label">
						<label>
							<input name="siteseo_options['.esc_attr($post_type).'][thumb_gcs]" type="checkbox" '.(!empty($option_thumb_gcs) ? 'checked="yes"' : 'value="1"').' />
							'.esc_html__('Display post thumbnail in Google Custom Search results?', 'siteseo').'
						</label>
						<p class="description">'.esc_html__('This option does not apply to traditional search results.', 'siteseo').'</p>
					</div>
				</div>';
		}
                    echo '</td></tr>
                </tbody>
            </table>
			<input type="hidden" name="siteseo_options[post_types_tab]" value="1"/>';
    }
    
    static function taxonomies(){
        global $siteseo;
 
        if(!empty($_POST['submit'])){
            self::save_settings();
        }

        // $options = $siteseo->titles_setting;
        $options = get_option('siteseo_titles_option_name');
		$taxonomies = get_taxonomies(['show_ui' => true, 'public'  => true], 'objects', 'and');

		echo '<table class="form-table">
			<tbody>
				<tr>
					<th scope="row">
						<div class="siteseo-container">';
							$is_first = true;
							foreach($taxonomies as $fields_key => $fields_val){
								$active_class = $is_first ? 'active' : '';
								echo '<a href="#'.esc_attr($fields_key).'-types" class="'.esc_attr($active_class).'">'.esc_html($fields_val->label).'</a>';
								$is_first = false;
							}
            echo '</th>
                    <td>
                        <h3>'.esc_html__('Taxonomies','siteseo').'</h3>
						<div class="siteseo_wrap_label">
                        <p class="description">'.esc_html__('Personalize your meta descriptions for all taxonomy archives.','siteseo').'</p>
						</div>';
		
		foreach($taxonomies as $taxonomy => $_tax){
			// Load array
			$options_tax = isset($options['titles_tax_titles'][$taxonomy]) ? $options['titles_tax_titles'][$taxonomy] : '';
			
			// Load settings
			$option_disabled_category = !empty($options_tax['disabled']) ? $options_tax['disabled'] : '';
			$option_cat_title = !empty($options_tax['title']) ? $options_tax['title'] : '';
			$option_cat_desc = !empty($options_tax['description']) ? $options_tax['description'] : '';
			$option_cat_noindex = !empty($options_tax['noindex']) ? $options_tax['noindex'] : '';
			$option_cat_nofollow = !empty($options_tax['nofollow']) ? $options_tax['nofollow'] : '';
	 
			$taxonomies_fields = [
				'categories-types' => 'Categories',
				'tags-types' => 'Tags',
			];

			echo '<div id="'.esc_attr($taxonomy).'-types"><h3>'.esc_html($_tax->label.'['.$taxonomy.']').'</h3>
				<div class="siteseo-toggle-cnt">
					<div class="siteseo-toggle-meta '.($option_disabled_category ? '' : 'active').'" id="siteseo-toggle-meta-category"></div>
					<span id="siteseo-arrow-icon" class="dashicons dashicons-arrow-left-alt siteseo-arrow-icon"></span>
					<p class="toggle_state_category" id="toggle_state_category">' .($option_disabled_category ? 'Enable' : 'Disable'). '</p>
					<input type="hidden" name="siteseo_options['.esc_attr($taxonomy).'][disabled]" id="enable_'.esc_attr($taxonomy).'" value="'.esc_attr($option_disabled_category).'" class="siteseo-suboption-toggle">
				</div>

				<div class="siteseo_wrap_label">
					<p class="description">'.esc_html__('Title template','siteseo').'</p>
				</div>
				<input type="text" value="'.esc_attr($option_cat_title).'" name="siteseo_options['.esc_attr($taxonomy).'][title]">
				<div class="wrap-tags">
					<button class="tag-title-btn" data-tag="%%_category_title%%">
						<span id="icon" class="dashicons dashicons-insert"></span>'.esc_html__('CATEGORY TITLE','siteseo').'
					</button>
					<button class="tag-title-btn"  data-tag="%%sep%%">
						<span id="icon" class="dashicons dashicons-insert"></span>'.esc_html__('SEPARATOR','siteseo').'
					</button>
					<button class="tag-title-btn"  data-tag="%%sitetitle%%">
						<span id="icon" class="dashicons dashicons-insert"></span>'.esc_html__('SITE TITLE','siteseo').'
					</button>';
						siteseo_suggestion_button(); 
				echo '</div>
				<div class="siteseo_wrap_label">
					<p class="description">Meta description template</p>
				</div>
				<textarea name="siteseo_options['.esc_attr($taxonomy).'][desc]">'.esc_attr($option_cat_desc).'</textarea>
				<div class="wrap-tags">
					<button class="tag-title-btn" data-tag="%%_category_description%%">
						<span id="icon" class="dashicons dashicons-insert"></span>'.esc_html__('CATEGORY DESCRIPTION','siteseo').'
					</button>';
					siteseo_suggestion_button();
				echo '</div>
				<div class="siteseo_wrap_label">
					<label>
						<input name="siteseo_options['.esc_attr($taxonomy).'][noindex]" type="checkbox" '.(!empty($option_cat_noindex) ? 'checked="yes"' : 'value="1"').' />
						'.wp_kses_post(__('Do not display this taxonomy archive in search engine results<strong>(noindex)</strong>', 'siteseo')).'
					</label>
				</div>';
				
				if(!empty($option_cat_noindex)){
					echo '<div class="siteseo_wrap_label">
						<div class="siteseo-notice is-error">
							<p>'.wp_kses_post(__('This custom taxonomy is <strong>NOT</strong> excluded from your XML sitemaps despite the fact that it is set to <strong>NOINDEX</strong>. We recommend that you check this out.', 'siteseo')).'
							</p>
						</div>
					</div>';
				}
				
				echo '<div class="siteseo_wrap_label">
					<label>
						<input name="siteseo_options['.esc_attr($taxonomy).'][nofollow]" type="checkbox" '.(!empty($option_cat_nofollow) ? 'checked="yes"' : 'value="1"').' />
						'.wp_kses_post(__('Do not follow links for this taxonomy archive<strong>(nofollow)</strong>', 'siteseo')).'
					</label>
				</div>
			</div>';
		}
                    echo '</td>
                </tr>
            </tbody>
        </table>
        <input type="hidden" name="siteseo_options[taxonomies_tab]" value="1"/>';
    }
    

    static function save_settings(){
        global $siteseo;
		
		check_admin_referer('siteseo_title_settings');

		if(!siteseo_user_can('manage_title') || !is_admin()){
			return;
		}

		$options = [];

		if(empty($_POST['siteseo_options'])){
			return;
		}

        if(isset($_POST['siteseo_options']['home_tab'])){
            
            $options['titles_sep'] = isset($_POST['siteseo_options']['separator']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['separator'])) : '';
			$options['titles_home_site_title'] = isset($_POST['siteseo_options']['site_title']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['site_title'])) : '';
			$options['titles_home_site_title_alt'] = isset($_POST['siteseo_options']['alt_site_title']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['alt_site_title'])) : '';
			$options['titles_home_site_desc'] = isset($_POST['siteseo_options']['media_desc']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['media_desc'])) : '';
        }

        if(isset($_POST['siteseo_options']['advanced_tab'])){

            $options['titles_noindex'] = isset($_POST['siteseo_options']['noindex']);
			$options['titles_nofollow'] = isset($_POST['siteseo_options']['no_follow']);
			$options['titles_noimageindex'] = isset($_POST['siteseo_options']['no_image']);
			$options['titles_noarchive'] = isset($_POST['siteseo_options']['no_archive']);
            $options['titles_nosnippet'] = isset($_POST['siteseo_options']['no_snippet']);
            $options['titles_nositelinkssearchbox'] = isset($_POST['siteseo_options']['no_site_links_searchbox']);
            $options['titles_paged_rel'] = isset($_POST['siteseo_options']['page_rel']);
            $options['titles_paged_noindex'] = isset($_POST['siteseo_options']['titles_paged_noindex']);
            $options['titles_attachments_noindex'] = isset($_POST['siteseo_options']['attachments_noindex']);

        }

        if(isset($_POST['siteseo_options']['post_types_tab'])){
			
			$post_types = siteseo_post_types();
			$post_types = array_keys($post_types);

			// Saving Posts
			foreach($post_types as $post_type){
				$options['titles_single_titles'][$post_type]['disabled'] = !empty($_POST['siteseo_options'][$post_type]['disabled']) ? true : false;
				$options['titles_single_titles'][$post_type]['title'] = isset($_POST['siteseo_options'][$post_type]['title']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options'][$post_type]['title'])) : '';
				$options['titles_single_titles'][$post_type]['description'] = isset($_POST['siteseo_options'][$post_type]['desc']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options'][$post_type]['desc'])) : '';
				$options['titles_single_titles'][$post_type]['noindex'] = isset($_POST['siteseo_options'][$post_type]['noindex']);
				$options['titles_single_titles'][$post_type]['nofollow'] = isset($_POST['siteseo_options'][$post_type]['nofollow']);
				$options['titles_single_titles'][$post_type]['date'] = isset($_POST['siteseo_options'][$post_type]['date']);
				$options['titles_single_titles'][$post_type]['thumb_gcs'] = isset($_POST['siteseo_options'][$post_type]['thumb_gcs']);
			}
        }

        if(isset($_POST['siteseo_options']['archives_tab'])){
			
			$post_types = siteseo_post_types();
			$post_types = array_keys($post_types);
			
            $options['titles_archives_author_title'] = isset($_POST['siteseo_options']['author_title']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['author_title'])) : '';
			$options['titles_archives_author_desc'] = isset($_POST['siteseo_options']['author_desc']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['author_desc'])) : '';
			$options['titles_archives_author_noindex'] = isset($_POST['siteseo_options']['author_noindex']);
			$options['titles_archives_author_disable'] = isset($_POST['siteseo_options']['author_disable']);
            
			$options['titles_archives_date_title'] = isset($_POST['siteseo_options']['date_title']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['date_title'])) : '';
			$options['titles_archives_date_desc'] = isset($_POST['siteseo_options']['date_desc']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['date_desc'])) : '';
			$options['titles_archives_date_noindex'] = isset($_POST['siteseo_options']['date_noindex']);
			$options['titles_archives_date_disable'] = isset($_POST['siteseo_options']['date_disable']);
            
			$options['titles_archives_search_title'] = isset($_POST['siteseo_options']['search_title']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['search_title'])) : '';
			$options['titles_archives_search_desc'] = isset($_POST['siteseo_options']['search_desc']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['search_desc'])) : '';
			$options['titles_archives_search_title_noindex'] = isset($_POST['siteseo_options']['search_noindex']);
            
			$options['titles_archives_404_title'] = isset($_POST['siteseo_options']['title_404']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['title_404'])) : '';
			$options['titles_archives_404_desc'] = isset($_POST['siteseo_options']['desc_404'])  ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['desc_404'])) : '';
			
			foreach($post_types as $post_type){					
				$options['titles_archive_titles'][$post_type]['archive_title'] = isset($_POST['siteseo_options'][$post_type]['archive_title']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options'][$post_type]['archive_title'])) : '';
				$options['titles_archive_titles'][$post_type]['archive_desc'] = isset($_POST['siteseo_options'][$post_type]['archive_desc']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options'][$post_type]['archive_desc'])) : '';
				$options['titles_archive_titles'][$post_type]['archive_noindex'] = isset($_POST['siteseo_options'][$post_type]['archive_noindex']);
				$options['titles_archive_titles'][$post_type]['archive_nofollow'] = isset($_POST['siteseo_options'][$post_type]['archive_nofollow']);
			}

        }

        if(isset($_POST['siteseo_options']['taxonomies_tab'])){
			$taxonomies = get_taxonomies(['show_ui' => true, 'public'  => true], 'objects', 'and');
			$taxonomies = array_keys($taxonomies);

			foreach($taxonomies as $taxonomy){
				$options['titles_tax_titles'][$taxonomy]['disabled'] = !empty($_POST['siteseo_options'][$taxonomy]['disabled']) ? true : false;
				$options['titles_tax_titles'][$taxonomy]['title'] = isset($_POST['siteseo_options'][$taxonomy]['title']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options'][$taxonomy]['title'])) : '';
				$options['titles_tax_titles'][$taxonomy]['description'] = isset($_POST['siteseo_options'][$taxonomy]['desc']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options'][$taxonomy]['desc'])) : '';
				$options['titles_tax_titles'][$taxonomy]['noindex'] = isset($_POST['siteseo_options'][$taxonomy]['noindex']);
				$options['titles_tax_titles'][$taxonomy]['nofollow'] = isset($_POST['siteseo_options'][$taxonomy]['nofollow']);
			}
        }

        $options = apply_filters('siteseo_titles_save_settings', $options);

        update_option('siteseo_titles_option_name', $options);
    }
 }
PKv�f\��1����settings/analytics.phpnu�[���<?php
/*
* SITESEO
* https://siteseo.io
* (c) SiteSEO Team
*/

namespace SiteSEO\Settings;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class Analytics{

	static function menu(){
		global $siteseo;

		$analytics_toggle = isset($siteseo->setting_enabled['toggle-google-analytics']) ? $siteseo->setting_enabled['toggle-google-analytics'] : '';
		$nonce = wp_create_nonce('siteseo_toggle_nonce');

		$current_tab = isset($_GET['tab']) ? sanitize_key($_GET['tab']) : 'tab_google_analytics';

		$analytics_sub_tags = [
			'tab_google_analytics' => esc_html__('Google Analytics', 'siteseo'),
			'tab_matomo' => esc_html__('Matomo', 'siteseo'),
			'tab_clarity' => esc_html__('Clarity', 'siteseo'),
			'tab_advanced' => esc_html__('Advanced', 'siteseo'),
			'tab_cookie' => esc_html__('Cookie bar / GDPR', 'siteseo'),
			'tab_custom_tracking' => esc_html__('Custom Tracking', 'siteseo'),
		];
		
		echo '<div id="siteseo-root">';
		
		Util::admin_header();

		echo '<form method="post" id="siteseo-form" class="siteseo-option" name="siteseo-flush">';
		wp_nonce_field('siteseo_analytics_settings');

		Util::render_toggle('Analytics - SiteSEO', 'analytics_toggle', $analytics_toggle, $nonce);
        
		echo '<div id="siteseo-tabs" class="wrap">
			<div class="siteseo-nav-tab-wrapper">';

		foreach($analytics_sub_tags as $tab_key => $tab_caption){
			$active_class = ($current_tab === $tab_key) ? ' siteseo-nav-tab-active' : '';
			echo '<a id="'.esc_attr($tab_key).'-tab" class="siteseo-nav-tab'.esc_attr($active_class).'" data-tab="'.esc_attr($tab_key).'">'.esc_html($tab_caption).'</a>';
		}

		echo '</div>
		<div class="tab-content-wrapper">
		<div class="siteseo-tab'.($current_tab == 'tab_google_analytics' ? ' active' : '').'" id="tab_google_analytics" style="display: none;">';
		self::google_anlytics();
		echo '</div>     
		<div class="siteseo-tab'.($current_tab == 'tab_matomo' ? ' active' : '') . '" id="tab_matomo" style="display: none;">';
		self::matomo();
		echo '</div>     
		<div class="siteseo-tab'.($current_tab == 'tab_clarity' ? ' active' : '').'" id="tab_clarity" style="display: none;">';
		self::clarity();
		echo '</div>     
		<div class="siteseo-tab'.($current_tab == 'tab_advanced' ? ' active' : '').'" id="tab_advanced" style="display: none;">';
		self::advanced();
		echo '</div>     
		<div class="siteseo-tab'.($current_tab == 'tab_cookie' ? ' active' : '').'" id="tab_cookie" style="display: none;">';
		self::cookies();
		echo '</div>  
		<div class="siteseo-tab'.($current_tab == 'tab_custom_tracking' ? 'active' : '').'" id="tab_custom_tracking" style="display: none;">';
		self::custom_tracking();
		echo '</div>
		</div>';
		Util::submit_btn();
		echo '</form></div>';
	}
	
	static function custom_tracking(){
		global $siteseo;

		if(!empty($_POST['submit'])){
			self::save_settings();
		}
		
		//$options = $siteseo->analaytics_settings;
		$options = get_option('siteseo_google_analytics_option_name');

		$option_head_tracking = !empty($options['google_analytics_other_tracking']) ? $options['google_analytics_other_tracking'] : '';
		$option_body_tracking = !empty($options['google_analytics_other_tracking_body']) ? $options['google_analytics_other_tracking_body'] : '';
		$option_footer_tracking = !empty($options['google_analytics_other_tracking_footer']) ? $options['google_analytics_other_tracking_footer'] : '';
		
		echo '<h3 class="siteseo-tabs">'.esc_html__('Custom Tracking','siteseo').'</h3>
			<P class="description">'.esc_html__('Add custom scripts like GTM or Facebook Pixel by copying and pasting the provided code into the HEAD, BODY, or FOOTER sections.','siteseo').'</p>
			<table class="form-table">
				<tbody>

					<tr>
						<th scope="row">'.esc_html__('[HEAD] Add an additional tracking code (like Facebook Pixel, Hotjar...)','siteseo').'</th>
						<td>
							<textarea name="siteseo_options[head_tracking]" rows="16" placeholder="'.esc_html__('Paste your tracking code here, such as Google Tag Manager (head). Do NOT paste GA4 or Universal Analytics codes, as they are automatically included in your source code.','siteseo').'">'.esc_html($option_head_tracking).'</textarea>
							<p class="description">'.esc_html__('This code will be added in the head section of your page','siteseo').'</p>
						</td>
					</tr>

					<tr>
						<th scope="row">'.esc_html__('[BODY] Add an additional tracking code (like Google Tag Manager...)','siteseo').'</th>
						<td>
							<textarea name="siteseo_options[body_tracking]" rows="16" placeholder="'.esc_html__('This code will be added just after the opening body tag of your page','siteseo').'">'.esc_html($option_body_tracking).'</textarea>
							<p>'.esc_html__('This code will be added just after the opening body tag of your page','siteseo').'</p>
							<p>'.esc_html__('You don‘t see your code? Make sure to call wp_body_open(); just after the opening body tag in your theme.','siteseo').'</p>
						</td>
					</tr>

					<tr>
						<th scope="row">'.esc_html__('[BODY (FOOTER)] Add an additional tracking code (like Google Tag Manager...)', 'siteseo').'</th>
						<td>
							<textarea name="siteseo_options[footer_tracking]" rows="16" placeholder="'.esc_html__('Paste your tracking code here(footer)','siteseo').'">'.esc_html($option_footer_tracking).'</textarea> 
							<p>'.esc_html__('This code will be added just after the closing body tag of your page','siteseo').'</P>
						</td>
					</tr>
				</tbody>
			</table><input type="hidden" name="siteseo_options[custom_tracking_tab]" value="1"/>';
		
	}

	static function cookies(){
		global $siteseo;

		if(!empty($_POST['submit'])){
			self::save_settings();
		}

		//$options = $siteseo->analaytics_settings;
		$options = get_option('siteseo_google_analytics_option_name');

		$option_cookies_postion = !empty($options['google_analytics_hook']) ? $options['google_analytics_hook'] : '';
		$option_tracking_opt = !empty($options['google_analytics_disable']) ? $options['google_analytics_disable'] : '';
		$option_half_disable = !empty($options['google_analytics_half_disable']) ? $options['google_analytics_half_disable'] : '';
		$option_opt_choices = !empty($options['google_analytics_opt_out_edit_choice']) ? $options['google_analytics_opt_out_edit_choice'] : '';
		$option_opt_msg = !empty($options['google_analytics_opt_out_msg']) ? $options['google_analytics_opt_out_msg'] : '';
		$option_opt_msg_ok = !empty($options['google_analytics_opt_out_msg_ok']) ? $options['google_analytics_opt_out_msg_ok'] : '';
		$option_opt_msg_close = !empty($options['google_analytics_opt_out_msg_close']) ? $options['google_analytics_opt_out_msg_close'] : '';
		$option_opt_msg_edit = !empty($options['google_analytics_opt_out_msg_edit']) ? $options['google_analytics_opt_out_msg_edit'] : '';
		$option_cd_exp_date = !empty($options['google_analytics_cb_exp_date']) ? $options['google_analytics_cb_exp_date'] : '30';
		$option_cd_pos = !empty($options['google_analytics_cb_pos']) ? $options['google_analytics_cb_pos'] : '';
		$option_cd_txt_align = !empty($options['google_analytics_cb_txt_align']) ? $options['google_analytics_cb_txt_align'] : '';
		$option_cd_width = !empty($options['google_analytics_cb_width']) ? $options['google_analytics_cb_width'] : '';
		$option_cd_backdrop = !empty($options['google_analytics_cb_backdrop']) ? $options['google_analytics_cb_backdrop'] : '';
		$option_cd_scheme = !empty($options['google_analytics_cb_scheme']) ? $options['google_analytics_cb_scheme'] : '';

		//colors load
		$option_backdrop_bg = !empty($options['google_analytics_cb_backdrop_bg']) ? $options['google_analytics_cb_backdrop_bg'] : '';
		$option_cookiebar_bg = !empty($options['google_analytics_cb_bg']) ? $options['google_analytics_cb_bg'] : '#ffffff';
		$option_cookiebar_txt = !empty($options['google_analytics_cb_txt_col']) ? $options['google_analytics_cb_txt_col'] : '#000000';
		$option_cookiebar_lk = !empty($options['google_analytics_cb_lk_col']) ? $options['google_analytics_cb_lk_col'] : '#0000ff';
		$option_primarybtn_bg = !empty($options['google_analytics_cb_btn_bg']) ? $options['google_analytics_cb_btn_bg'] : '#0073aa';
		$option_primarybtn_bg_hov = !empty($options['google_analytics_cb_btn_bg_hov']) ? $options['google_analytics_cb_btn_bg_hov'] : '#005f8b';
		$option_primarybtn_txt = !empty($options['google_analytics_cb_btn_col']) ? $options['google_analytics_cb_btn_col'] : '#ffffff';
		$option_primarybtn_txt_hov = !empty($options['google_analytics_cb_btn_col_hov']) ? $options['google_analytics_cb_btn_col_hov'] : '#ffffff';
		$option_sec_bg = !empty($options['google_analytics_cb_btn_sec_bg']) ? $options['google_analytics_cb_btn_sec_bg'] : '#cccccc';
		$option_sec_bg_hov = !empty($options['google_analytics_cb_btn_sec_bg_hov']) ? $options['google_analytics_cb_btn_sec_bg_hov'] : '#aaaaaa';
		$option_sec_bg_txt = !empty($options['google_analytics_cb_btn_sec_col']) ? $options['google_analytics_cb_btn_sec_col'] : '#000000';
		$option_sec_bg_txt_hov = !empty($options['google_analytics_cb_btn_sec_col_hov']) ? $options['google_analytics_cb_btn_sec_col_hov'] : '#000000';

		echo '<h3 class="siteseo-tabs">'.esc_html__('Cookies','siteseo').'</h3>
		<p class="description">'.esc_html__('Easily manage user consent for GDPR and customize your cookie bar.','siteseo').'</p>
		<p class="description">'.esc_html__('Compatible with Google Analytics and Matomo.','siteseo').'</p>
		<table>
			<tbody class="form-table">
				<tr>
					<div class="siteseo-notice" id="custom-dimensions">
						<span class="dashicons dashicons-info"></span>
						<p>'.
						/* translators: placeholders are just <strong> tag */ 
						wp_kses_post(sprintf(__('%1$s Note : %2$s This feature applies only to cookies added through SiteSEO analytics and tracking.', 'siteseo'), '<strong>', '</strong>')).'</p>
					</div>
				</tr>
				
				<tr>
					<th scope="row" style="user-select:auto;">'.esc_html__('Where to load the cookie bar?','siteseo').'</th>
					<td>
						<select name="siteseo_options[cookie_pos]">
							<option value="wp_body_open" '.selected($option_cookies_postion, 'wp_body_open', false).'>'.esc_html__('After the opening body tag (recommended)', 'siteseo').'</option>
							<option value="wp_footer" '.selected($option_cookies_postion, 'wp_footer', false).'>'.esc_html__('Footer', 'siteseo') .'</option>
							<option value="wp_head" '.selected($option_cookies_postion, 'wp_head', false).'>'.esc_html__('Header (not recommended)', 'siteseo').'</option>
						</select>
					</td>
				</tr>

				<tr>
					<th scope"user-select:auto">'.esc_html__('Analytics tracking opt-in','siteseo').'</th>
					<td>
						<label>
							<input name="siteseo_options[opt_tracking]" type="checkbox" '.(!empty($option_tracking_opt) ? 'checked="yes"' : 'value="1"').' />
								'.esc_html__('Obtain user consent for analytics tracking, as required by GDPR.', 'siteseo').'
                        </label><br/><br/>
						<label>
						<input type="checkbox" name="siteseo_options[half_disable]" '.(!empty($option_half_disable) ? 'checked="yes"' : 'value="1"').' />
							'.esc_html__('Display and automatically accept if user does not accept or reject within 10 seconds.','siteseo').'
						</label>
					</td>
				</tr>

				<tr>
					<th scope="row" style="user-select:auto:">'.esc_html__('Allow user to change its choice','siteseo').'</th>
					<td>
						<label>
							<input name="siteseo_options[opt_edit_choices]" type="checkbox" '.(!empty($option_opt_choices) ? 'checked="yes"' : 'value="1"').' />
							Allow user to change its choice about cookies'.esc_html__('Request user consent for analytics tracking (required by GDPR)', 'siteseo').'
                        </label>
					</td>
				</tr>

				<tr>
					<th scope="row" style="user-select:auto;">'.esc_html__('Consent message for user tracking','siteseo').'</th>
					<td>
						<textarea placeholder="'.esc_html__('Enter your message (HTML allowed)','siteseo').'" name="siteseo_options[opt_msg]" >'.esc_attr($option_opt_msg).'</textarea>
					</td>
				</tr>

				<tr>
					<th scope="row" style="user-select:auto;">'.esc_html__('Accept button for user tracking','siteseo').'</th>
					<td>
						<input type="text" name="siteseo_options[opt_msg_ok]" value="'.esc_attr($option_opt_msg_ok).'" placeholder="'.esc_html__('Accept','siteseo').'"> 
					</td>
				</tr>

				<tr>
					<th scope="row" style="user-select:auto;">'.esc_html__('Close button','siteseo').'</th>
					<td>
						<input type="text" name="siteseo_options[opt_close]" value="'.esc_attr($option_opt_msg_close).'" placeholder="'.esc_attr__('default:X', 'siteseo').'">
					</td>
				</tr>

				<tr>
					<th scope="row" style="user-select:auto;" >'.esc_html__('Edit cookies button','siteseo').'</th>
					<td>
						<input type="text" name="siteseo_options[opt_edit_btn]" value="'.esc_attr($option_opt_msg_edit).'" placeholder="'.esc_attr__('default:Manage cookie', 'siteseo').'">
					</td>
				</tr>
				
				<tr>
					<th scope="row" style="user-select:auto;">'.esc_html__('User consent cookie expiration date','siteseo').'</th>
					<td>
						<input type="number"  name="siteseo_options[cd_exp_date]" value="'.esc_attr($option_cd_exp_date).'" >
					</td>
				</tr>
				
				<tr>
					<th scope="row" style="user-select:auto;">'.esc_html__('Cookie bar position','siteseo').'</th>
					<td>
						<select name="siteseo_options[cd_pos]">
							<option value="bottom" '.selected($option_cd_pos, 'bottom', false).'>'.esc_html__('Bottom (default)','siteseo').'</option>
							<option value="middle" '.selected($option_cd_pos, 'middle', false).'>'.esc_html__('Middle','siteseo').'</option>
							<option value="top" '.selected($option_cd_pos, 'top', false).'>'.esc_html__('Top','siteseo').'</option>
						</select>
					</td>
				</tr>
				
				<tr>
					<th scope="row" style="use-select:auto;">'.esc_html__('Text alignment','siteseo').'</th>
					<td>
						<select name="siteseo_options[cd_txt_align]">
							<option value="center" '.selected($option_cd_txt_align, 'center', false).'>'.esc_html__('Center (default)', 'siteseo').'</option>
							<option value="left" '.selected($option_cd_txt_align, 'left', false).'>'.esc_html__('Left', 'siteseo').'</option>
							<option value="right" '.selected($option_cd_txt_align, 'right', false).'>'.esc_html__('Right', 'siteseo').'</option>
						</select>
					</td>
				</tr>

				<tr>
					<th scope="row" style="user-select:auto;">'.esc_html__('Cookie bar width', 'siteseo').'</th>
					<td>
						<input type="text" name="siteseo_options[cd_width]"  value="'.esc_attr($option_cd_width).'"/>
						<p class="description">'.esc_html__('The default unit is Pixels. To use percentages, simply add % after your custom value (e.g., 80%).', 'siteseo').'</p>
						<br/>
						<span class="line"></span>
					</td>
				</tr>
				
				<tr>
					<th scope="row" style="user-select:auto;"></th>
					<td>
						<h3>'.esc_html__('Backdrop', 'siteseo').'</h3>
						<p>'.esc_html__('Customize the backdrop of the cookie bar.', 'siteseo').'</p><br/>
						<label>
							<input type="checkbox" name="siteseo_options[cd_backdrop]" '.(!empty($option_cd_backdrop) ? 'checked="yes"' : 'value="1"').'>'. esc_html__('Display a backdrop with the cookie bar', 'siteseo') .'
						</label>
						<br/><br/>
						<p>'.esc_html__('Background color:','siteseo').'</p><br/>
						<input type="color" placeholder="Select color" name="siteseo_options[backdrop_bg]" value="'.esc_attr($option_backdrop_bg).'"/>
						<br/></br/>
						<span class="line"></span>
					</td>
				</tr>
				
				<tr>
					<th scope="row" style="user-select:auto;"></th>
					<td>
						<h3>'.esc_html__('Main settings', 'siteseo').'</h3>
						<p>'.esc_html__('Customize the general settings of the cookie bar', 'siteseo').'</p>
						<p>'.esc_html__('Background color:', 'siteseo').'</p><br/>
						<input type="color"  placeholder="'.esc_html__('Select color', 'siteseo').'" name="siteseo_options[cookiesbar_bg]" value="'.esc_attr($option_cookiebar_bg).'"/>
						<p>'.esc_html__('Text color:', 'siteseo').'</p><br/>
						<input type="color"  placeholder="'.esc_html__('Select color', 'siteseo').'" name="siteseo_options[cookiebar_txt]" value="'.esc_attr($option_cookiebar_txt).'"/>
						<p>'.esc_html__('Link color: ','siteseo').'</p></br>
						<input type="color"  placeholder="'.esc_html__('Select color', 'siteseo').'" name="siteseo_options[line_co]" value="'.esc_attr($option_cookiebar_lk).'"/><br/></br>
						<span class="line"></span>
					</td>
				</tr>
				
				<tr>
					<th scope="row" style="use-select:auto"></th>
					<td>
						<h3>'.esc_html__('Primary button', 'siteseo').'</h3>
						<p>'.esc_html__('Customize the Accept button', 'siteseo').'</p><br/>
						<p>'.esc_html__('Background color:', 'siteseo').'</p>
						<input type="color"  placeholder="'.esc_html__('Select color', 'siteseo').'" name="siteseo_options[primary_btn_bg]" value="'.esc_attr($option_primarybtn_bg).'"/><br/><br/>
						<p>'.esc_html__('Background color on hover:','siteseo').'</p>
						<input type="color" name="siteseo_options[primary_btn_bg_hov]" value="'.esc_attr($option_primarybtn_bg_hov).'" /><br/><br/>
						<p>'.esc_html__('Text color:', 'siteseo').'</p>
						<input type="color" name="siteseo_options[primary_btn_txt]" value="'.esc_attr($option_primarybtn_txt).'"/>
						<p>'. esc_html__('Text color on hover:', 'siteseo') .'</p>
						<input type="color" name="siteseo_options[primary_btn_txt_hov]" value="'.esc_attr($option_primarybtn_txt_hov).'"/><br/><br/>
						<span class="line"></span>
					</td>
				</tr>
				
				<tr>
					<th scope="row" style="user-select:auto"></th>
					<td>
						<h3>'.esc_html__('Secondary button', 'siteseo').'</h3>
						<p>'.esc_html__('Customize the Accept button', 'siteseo').'</p><br/>
						<p>'.esc_html__('Background color:', 'siteseo').'</p>
						<input type="color"  placeholder="'.esc_html__('Select color','siteseo').'" name="siteseo_options[sec_btn_bg]" value="'.esc_attr($option_sec_bg).'"/><br/><br/>
						<p>'.esc_html__('Background color on hover:', 'siteseo').'</p>
						<input type="color" name="siteseo_options[sec_btn_bg_hov]" value="'.esc_attr($option_sec_bg_hov).'"/><br/><br/>
						<p>'.esc_html__('Text color:', 'siteseo').'</p>
						<input type="color" name="siteseo_options[sec_btn_txt]" value="'.esc_attr($option_sec_bg_txt).'"/>
						<p>'.esc_html__('Text color on hover:', 'siteseo').'</p>
						<input type="color" name="siteseo_options[sec_btn_txt_hov]" value="'.esc_attr($option_sec_bg_txt_hov).'"/>
					</td>
				</tr>
			</tbody>
		</table><input type="hidden" name="siteseo_options[cookies_tab]" value="1"/>'; 

	}
	

	static function matomo(){
		global $siteseo;

        if(!empty($_POST['submit'])){
            self::save_settings();
        }

		//$options = $siteseo->analaytics_settings;
		$options = get_option('siteseo_google_analytics_option_name');

		$option_enable_matomo = !empty($options['google_analytics_matomo_enable']) ? $options['google_analytics_matomo_enable'] : '';
		$option_self_hosted = !empty($options['google_analytics_matomo_self_hosted']) ? $options['google_analytics_matomo_self_hosted'] : '';
		$option_matomo_id = !empty($options['google_analytics_matomo_id']) ? $options['google_analytics_matomo_id'] : '';
		$option_site_id = !empty($options['google_analytics_matomo_site_id']) ? $options['google_analytics_matomo_site_id'] : '';
		$option_sub_domain = !empty($options['google_analytics_matomo_subdomains']) ? $options['google_analytics_matomo_subdomains'] : '';
		$option_site_domain = !empty($options['google_analytics_matomo_site_domain']) ? $options['google_analytics_matomo_site_domain'] : '';
		$option_enable_corss_domain = !empty($options['google_analytics_matomo_cross_domain']) ? $options['google_analytics_matomo_cross_domain'] : '';
		$option_no_js = !empty($options['google_analytics_matomo_no_js']) ? $options['google_analytics_matomo_no_js'] : '';
		$option_cross_domain_sites = !empty($options['google_analytics_matomo_cross_domain_sites']) ? $options['google_analytics_matomo_cross_domain_sites'] : '';
		$option_no_cookies = !empty($options['google_analytics_matomo_no_cookies']) ? $options['google_analytics_matomo_no_cookies'] : '';
		$options_link_tracking = !empty($options['google_analytics_matomo_link_tracking']) ? $options['google_analytics_matomo_link_tracking'] : '';
		$options_no_heatmaps = !empty($options['google_analytics_matomo_no_heatmaps']) ? $options['google_analytics_matomo_no_heatmaps'] : '';
		$options_matomo_dtn = !empty($options['google_analytics_matomo_dnt']) ? $options['google_analytics_matomo_dnt'] : '';

		$matomo_subtabs = [
			'tracking' => 'Tracking',
		];

		echo '<table class="form-table">
			<tbody>
				<tr>
					<th scope="row">
						<div class="siteseo-container">';
								$is_first = true;
								foreach($matomo_subtabs as $post_key => $post_val){
									$active_class = $is_first ? 'active' : '';
									echo '<a href="#'.esc_attr($post_key).'" class="'.esc_attr($active_class).'">'.esc_html($post_val).'</a>';
									$is_first = false;
								}
							echo '</div>
					</th>
					<td>
						<h3>'.esc_html__('Matomo', 'siteseo').'</h3>
						<div class="siteseo_wrap_label" id="tracking">
						<p class="description">'.esc_html__('Track your users with privacy in mind using Matomo. We support both On-Premise and Cloud installations.', 'siteseo').'</p>
						</div>
						<span class="line"></span>
						<h3>'.esc_html__('Tracking', 'siteseo').'</h3>
						<table class="form-table">
							<tbody>
								<tr>
									<th scope="row">'.esc_html__('Enable Matomo tracking.', 'siteseo').'</th>
									<td>
										<label>
											<input type="checkbox" name="siteseo_options[enable_matomo]" '.(!empty($option_enable_matomo) ? 'checked="yes"' : '').' value="1"/>
											'.esc_html__('Enable Matomo tracking', 'siteseo') .'
										</label>
										<p class="description">'.esc_html__('A Matomo Cloud account or a self-hosted Matomo installation is necessary.', 'siteseo').'</p>
									</td>
								</tr>

								<tr>
									<th scope="row">'.esc_html__('Self hosted Matomo installation.', 'siteseo').'</th>
									<td>
										<label>
											<input type="checkbox" name="siteseo_options[self_hosted]" '.(!empty($option_self_hosted) ? 'checked="yes"' : '').' value="1" "/>
											'.esc_html__('Yes, self-hosted installation', 'siteseo').'
										</label>
										
									</td>
								</tr>
								
								<tr>
									<th scope="row">'.esc_html__('Enter your tracking ID', 'siteseo').'</th>
									<td>
										<input type="text" placeholder="'.esc_html__('Enter "example" if you Matomo account URL is "example.matomo.cloud', 'siteseo').'" name="siteseo_options[tracking_id]" value="'.esc_attr($option_matomo_id).'"/>
										'.wp_kses_post('<p class="description">Enter only the host without quotes, such as "example.matomo.cloud" </br> (Cloud) or "matomo.example.com" (self-hosted).</p>').'
									</td>
								</tr>

								<tr>
									<th scope="row">'.esc_html__('Enter your site ID.', 'siteseo').'</th>
									<td>
										<input type="text" placeholder="'.esc_html__('Enter your site ID', 'siteseo').'" name="siteseo_options[site_id]" value="'.esc_attr($option_site_id).'"/>
										<p class="description">'.
										/* translators: placeholders are just <strong> tag */ 
										wp_kses_post(sprintf(__('To find your site ID, visit your %1$s Matomo Cloud %2$s account, go to Websites, and click Manage. The <br/>"Site ID" will be displayed on the right side.', 'siteseo'), '<strong>', '</strong>')).'</p>
										<p class="description">'.
										/* translators: placeholder is just <br> tag */ 
										wp_kses_post(sprintf(__('For self-hosted installations, navigate to your Matomo administration, then go to Settings, Websites, %1$s and Manage. From the list of websites, locate the "ID" line.', 'siteseo'), '<br/>')).'<p>
									</td>
								</tr>

								<tr>
									<th scope="row">'.esc_html__('Track visitors across all subdomains', 'siteseo').'</th>
									<td>
										<label>
										<input type="checkbox" name="siteseo_options[track_visitors]" '.(!empty($option_sub_domain) ? 'checked="yes"' : '').' value="1"/>
										'.esc_html__('Monitor one domain along with its subdomains on the same website.','siteseo') .'
										<p class=description">'.esc_html__('If a visitor visits x.example.com and y.example.com, they will be counted as a single unique visitor.', 'siteseo').'</p>
										</label>
									</td>
								</tr>

								<tr>
									<th scope="row">'.esc_html__('Prepend the site domain.', 'siteseo').'</th>
									<td>
										<label>
											<input type="checkbox" name="siteseo_options[site_domain]" '.(!empty($option_site_domain) ? 'checked="yes"' : '').' value="1" />
											'.esc_html__('Add the site domain before the page title when tracking', 'siteseo').'
											<p class="description">For example, if someone visits the About page on blog.example.com, it will be recorded as "blog / About".<br/> This provides a simple way to get an overview of your traffic by subdomain.</p>`
										</label>
									</td>
								</tr>

								<tr>
									<th scope="row">'.esc_html__('Track users with JavaScript disabled.', 'siteseo').'</th>
									<td>
										<label>
											<input type="checkbox" name="siteseo_options[track_users]" '.(!empty($option_no_js) ? 'checked="yes"' : '').' value="1" />
											'. esc_html__('Track users with JavaScript disabled', 'siteseo').'
										</label>
									</td>
								</tr>

								<tr>
									<th scope="row">'.esc_html__('Enables cross domain linking', 'siteseo').'</th>
									<td>
										<label>
											<input type="checkbox" name="siteseo_options[enable_cross_domains]" '.(!empty($option_enable_corss_domain) ? 'checked="yes"' : '').' value="1" />
											'.esc_html__('Enables cross domain linking', 'siteseo').'
										</label>
										<p class="description">'.esc_html__('By default, the visitor ID, which uniquely identifies each visitor, is stored in the browser first-party cookies. These cookies can only be accessed by pages on the same domain.', 'siteseo').'</p> 
										<p class="description">'.esc_html__('Enabling cross-domain tracking allows you to monitor all actions and pageviews of a specific visitor within the same session, even when they visit pages across different domains.', 'siteseo').'</p> 
										<p class="description">'.esc_html__('When a user clicks on a link to one of your site alias URLs, a URL parameter, <code>pk_vid</code>, will be appended, forwarding the Visitor ID.', 'siteseo').'</p>
									</td>
								</tr>

								<tr>
									<th scope="row">'.esc_html__('Cross domain', 'siteseo').'</th>
									<td>
										<input type="text" name="siteseo_options[corss_domains]" value="'.esc_attr($option_cross_domain_sites).'" placeholder="'.esc_attr('Enter your domains: siteseo.io,sub.siteseo.io,sub2.siteseo.io').'"/>
									</td>
								</tr>
								
								<tr>
									<th scope="row">'.esc_html__('Enable DoNotTrack detection', 'siteseo').'</th>
									<td>
										<input type="checkbox" name="siteseo_options[enable_donottack]" '.(!empty($options_matomo_dtn) ? 'checked="yes"' : '').' value="1"/>
										'.esc_html__('Activate client-side Do Not Track detection.', 'siteseo').'
										<p class="description">'.esc_html__('Tracking requests will be blocked if visitors opt out of being tracked.', 'siteseo').'</p>
									</td>
								</tr>

								<tr>
									<th scope="row">'.esc_html__('Disable all tracking cookies.', 'siteseo').'</th>
									<td>
										<input type="checkbox" name="siteseo_options[disabled_cookies]" '.(!empty($option_no_cookies) ? 'checked="yes"' : '').' value="1" />
										'.esc_html__('Disables all first-party cookies. Any existing Matomo cookies for this site will be deleted on the next page view.', 'siteseo').'
									</td>
								</tr>

								<tr>
									<th scope="row">'.esc_html__('Download & Outlink tracking.', 'siteseo').'</th>	
									<td>
										<input type="checkbox" name="siteseo_options[outlink_tracking]" '.(!empty($options_link_tracking) ? 'checked="yes"' : '').' value="1" />
										'.esc_html__('Enabling Download & Outlink tracking','siteseo').'
										<p class="description">By default, files with any of these extensions will be treated as a "download" in the Matomo interface.<p>
										<div class="siteseo-styles pre"><pre>7z|aac|arc|arj|apk|asf|asx|avi|bin|bz|bz2|csv|deb|dmg|doc|exe|flv|gif|gz|gzip|hqx|jar|jpg|jpeg|js|mp2|mp3|mp4|mpg|mpeg|mov|movie|msi|msp|odb|odf|odg|odp|ods|odt|ogg|ogv| pdf|phps|png|ppt|qt|qtm|ra|ram|rar|rpm|sea|sit|tar|tbz|tbz2|tgz|torrent|txt|wav|wma|wmv|wpd|xls|xml|z|zip</pre></div>
									</td>
								</tr>

								<tr>
									<th scope="row">'.esc_html__('Disable all heatmaps and session recordings.', 'siteseo').'</th>
									<td>
										<input type="checkbox" '.(!empty($options_no_heatmaps) ? 'checked="yes"' : '').' value="1" name="siteseo_options[disabled_heatmaps]" />
										'.esc_html__('Turns off all heatmaps and session recordings.', 'siteseo').'
									</td>
								</tr>
							</tbody>
						</table>
					</td>
				</tr>
			</tbody>
		</table><input type="hidden" name="siteseo_options[matomo_tab]" value="1"/>';
	}

	static function advanced(){
		global $siteseo,$wp_roles;

        if(!empty($_POST['submit'])){
            self::save_settings();
        }

		if(!isset($wp_roles)){
			$wp_roles = new \WP_Roles();
		}

		//$options = $siteseo->analaytics_settings;
		$options = get_option('siteseo_google_analytics_option_name');

		$option_track_authors = !empty($options['google_analytics_cd_author']) ? $options['google_analytics_cd_author'] : '';
		$option_track_categories = !empty($options['google_analytics_cd_category']) ? $options['google_analytics_cd_category'] : '';
		$option_track_tag = !empty($options['google_analytics_cd_tag']) ? $options['google_analytics_cd_tag'] : '';
		$option_track_post_types = !empty($options['google_analytics_cd_post_type']) ? $options['google_analytics_cd_post_type'] : '';
		$option_logged_user = !empty($options['google_analytics_cd_logged_in_user']) ? $options['google_analytics_cd_logged_in_user'] : '';

		$adavnced_subtabs =[
			'custom-dimensions' => 'Custom Dimensions',
			'Misc' => 'Misc',
		];

		echo '<table class="form-table">
				<tbody>
					<tr>
						<th scope="row">
							<div class="siteseo-container">';
								$is_first = true;
								foreach($adavnced_subtabs as $post_key => $post_val){
									$active_class = $is_first ? 'active' : '';
									echo '<a href="#'.esc_attr($post_key).'" class="'.esc_attr($active_class).'">'.esc_html($post_val).'</a>';
									$is_first = false;
								}
							echo '</div>
						</th>

						<td>
							<h3>'.esc_html__('Advanced settings', 'siteseo').'</h3>
							<div class="siteseo-notice" id="custom-dimensions">
								<span class="dashicons dashicons-info"></span>
								<p>'.esc_html__('All advanced settings are compatible with both Google Analytics and Matomo tracking codes.', 'siteseo').'</p>
							</div>

							<br/>

							<span class="line"></span>
							<h3>'.esc_html__('Custom Dimensions', 'siteseo').'</h3>
							<div class="siteseo_wrap_label"><p class="description">'.esc_html__('Set up your Google Analytics custom dimensions.', 'siteseo').'</p></div>
							<div class="siteseo_wrap_label"><p class="description">'.esc_html__('Custom dimensions and metrics are similar to the default ones in Google Analytics, but you have the flexibility to create your own.', 'siteseo').'</p></div>
							<div class="description"><p class="description">'.esc_html__('Utilize custom dimensions to gather and analyze data that Google Analytics does not track automatically.', 'siteseo').'</p></div>
							<div class="description"><p class="description">'.esc_html__('Remember, you must also configure your custom dimensions in your Google Analytics account. Click the help icon for more information.', 'siteseo').'</p></div>

							<table class="form-table">
								<tbody>
									<tr>
										<th scope="row">'.esc_html__('Track Authors', 'siteseo').'</th>
										<td>
											<select name="siteseo_options[track_authors]">
												<option value="none" '.selected($option_track_authors, 'none', false).'>'.esc_html__('None','siteseo').'</option>';
												for($i = 1; $i <= 20; ++$i){
													/* translators: %d represents the custom dimension */
													echo '<option '.selected($option_track_authors, 'dimension' . $i, false).' value="dimension'.esc_attr($i).'">'.sprintf(esc_html__('Custom Dimension #%d', 'siteseo'), esc_html($i)).'</option>';
												}
											echo '</select>
										</td>
									</tr>

									<tr>
										<th scope="row">'.esc_html__('Track Categories', 'siteseo').'</th>
										<td>
											<select name="siteseo_options[track_categories]">
												<option value="none" '.selected($option_track_categories, 'none', false).'>'.esc_html__('None','siteseo').'</option>';
												for($i = 1; $i <= 20; ++$i){
													/* translators: %d represents the custom dimension */
													echo '<option '.selected($option_track_categories, 'dimension' . $i, false).' value="dimension'.esc_attr($i).'">'.sprintf(esc_html__('Custom Dimension #%d', 'siteseo'), esc_html($i)).'</option>';
												}
											echo '</select>
										</td>
									</tr>

									<tr>
										<th scope="row">'.esc_html__('Track Tags', 'siteseo').'</th>
										<td>
											<select name="siteseo_options[track_tags]">
												<option value="none" '.selected($option_track_tag, 'none', false).'>'.esc_html__('None','siteseo').'</option>';
												for($i = 1; $i <= 20; ++$i){
													/* translators: %d represents the custom dimension */
													echo '<option '.selected($option_track_tag, 'dimension' . $i, false).' value="dimension'.esc_attr($i).'">'.sprintf(esc_html__('Custom Dimension #%d', 'siteseo'), esc_html($i)).'</option>';
												}
											echo '</select>
										</td>
									</tr>

									<tr>
										<th scope="row">'.esc_html__('Track Post Types','siteseo').'</th>
										<td>
											<select name="siteseo_options[track_post_types]">
												<option value="none" '.selected($option_track_post_types, 'none', false).'>'.esc_html__('None','siteseo').'</option>';
												for($i = 1; $i <= 20; ++$i){
													/* translators: %d represents the custom dimension */
													echo '<option '.selected($option_track_post_types, 'dimension' . $i, false).' value="dimension'.esc_attr($i).'">'.sprintf(esc_html__('Custom Dimension #%d', 'siteseo'), esc_html($i)).'</option>';
												}
											echo '</select>
										</td>
									</tr>

									<tr>
										<th scope="row">'.esc_html__('Track Logged In Users','siteseo').'</th>
										<td>
											<select name="siteseo_options[track_user]">
												<option value="none" '.selected($option_logged_user, 'none', false).'>'.esc_html__('None','siteseo').'</option>';
												for($i = 1; $i <= 20; ++$i){
													/* translators: %d represents the custom dimension */
													echo '<option '.selected($option_logged_user, 'dimension' . $i, false).' value="dimension'.esc_attr($i).'">'. sprintf(esc_html__('Custom Dimension #%d', 'siteseo'), esc_html($i)).'</option>';
												}
											echo '</select>
										</td>
									</tr>

								</tbody>
							</table>

							<div class="description" id="Misc"><span class="line"></span>
							<h3>'.esc_html__('Misc','siteseo').'</h3>
							<table>
								<tbody class="form-table">
									<tr>
										<th scope="row">'.esc_html__('Exclude user roles from tracking (Google Analytics and Matomo)','siteseo').'</th>
										<td>';
										foreach($wp_roles->get_names() as $key => $value){
											$select = isset($options['google_analytics_roles'][$key]);

											echo '<p>
												<label>
													<input name="siteseo_options[misc_roles]['.esc_attr($key).']" type="checkbox" '.(!empty($select) ? 'checked="yes"' : 'value="1"').'/>
													<strong>'. esc_html($value) .'</strong> (<em> '. esc_html(translate_user_role($value,  'default')) .'</em>)
												</label>
											</p>';	
										}
										echo '</td>
									</tr>
								</tbody>
							</table>
							</div>
						</td>
					</tr>
				</tbody>
			</table><input type="hidden" name="siteseo_options[advanced_tab]" value="1"/>';
	}
	
	static function clarity(){
		global $siteseo;

        if(!empty($_POST['submit'])){
            self::save_settings();
        }

		//$options = $siteseo->analaytics_settings;
		$options = get_option('siteseo_google_analytics_option_name');

		$option_enable_clarity = !empty($options['google_analytics_clarity_enable']) ? $options['google_analytics_clarity_enable'] : '';
		$option_project_id = !empty($options['google_analytics_clarity_project_id']) ? $options['google_analytics_clarity_project_id'] : '';

		echo '<h3 class="siteseo-tabs">'.esc_html__('Microsoft Clarity', 'siteseo').'</h3>
		<p class="description">'.esc_html__('Use Microsoft Clarity to capture session recordings, access instant heatmaps, and gain powerful insights for free. Understand how users interact with your site to enhance the user experience and boost conversions.', 'siteseo').'</p>

		<div class="siteseo-notice">
            		<span class="dashicons dashicons-info"></span>
           		 <p>'. 
				 /* translators: %s represents the microsoft clarity api url */
				 wp_kses_post(sprintf(__('Create your first Microsoft Clarity project %1$shere%2$s.', 'siteseo'), '<a href="https://clarity.microsoft.com/" target="_blank">', '</a>')) .'</p>
		</div>

		<table class="form-table">
			<tbody>
				<tr>
					<th scope="row" style="user-select:auto;">'.esc_html__('Enable Microsoft Clarity','siteseo').'</th>
					<td>
						<input type="checkbox" name="siteseo_options[microsoft_clarity]" '.(!empty($option_enable_clarity) ? 'checked="yes"' : ''). ' value="1">
					</td>
				</tr>

				<tr>
					<th scope="row" style="user-select:auto;">'.esc_html__('Enter your Clarity project ID', 'siteseo').'</th>
					<td>
						<input type="text" name="siteseo_options[project_id]" placeholder="'.esc_attr__('Enter your Project Id', 'siteseo').'" value="'.esc_attr($option_project_id).'" >
						<p><span class="dashicons dashicons-external"></span>
							<a href="https://siteseo.io/docs/analytics/find-my-microsoft-clarity-project-id/" target="_blank">
								'.esc_html__('Find your project ID', 'siteseo').'
							</a>
							</span>
						</p>
					</td>
				</tr>

			</tbody>
		</table><input type="hidden" name="siteseo_options[clarity_tab]" value="1" />';

	}

	static function google_anlytics(){
		global $siteseo;
		
        if(!empty($_POST['submit'])){
            self::save_settings();
        }

		$options = get_option('siteseo_google_analytics_option_name');
		//$options = $siteseo->analaytics_settings;

		$option_enable_anaytics = !empty($options['google_analytics_enable']) ? $options['google_analytics_enable'] : '';
		$option_anaytics_id = !empty($options['google_analytics_ga4']) ? $options['google_analytics_ga4'] : '';
		$option_enable_optimize = !empty($options['google_analytics_link_tracking_enable']) ? $options['google_analytics_link_tracking_enable'] : '';
		$option_enable_download_tracking= !empty($options['google_analytics_download_tracking_enable']) ? $options['google_analytics_download_tracking_enable'] : '';
 		$option_download_tracking = !empty($options['google_analytics_download_tracking']) ? $options['google_analytics_download_tracking'] : '';
		$option_affiliate_tracking_enable = !empty($options['google_analytics_affiliate_tracking_enable']) ? $options['google_analytics_affiliate_tracking_enable'] : '';
		$option_affiliate_tracking = !empty($options['google_analytics_affiliate_tracking']) ? $options['google_analytics_affiliate_tracking'] : '';
		$option_phone_tracking = !empty($options['google_analytics_phone_tracking']) ? $options['google_analytics_phone_tracking'] : '';

		$option_container_id = !empty($options['google_analytics_optimize']) ? $options['google_analytics_optimize'] : '';
		$option_conversion_id = !empty($options['google_analytics_ads']) ? $options['google_analytics_ads'] : '';
		$option_ip_anonymization = !empty($options['google_analytics_ip_anonymization']) ? $options['google_analytics_ip_anonymization'] : '';
		$option_links_attribution = !empty($options['google_analytics_link_attribution']) ? $options['google_analytics_link_attribution'] : '';
		$option_domain_tracking = !empty($options['google_analytics_cross_enable']) ? $options['google_analytics_cross_enable'] : '';
		$option_cross_domain = !empty($options['google_analytics_cross_domain']) ? $options['google_analytics_cross_domain'] : '';
		$option_enable_remarketing = !empty($options['google_analytics_remarketing']) ? $options['google_analytics_remarketing'] : '';
 		
		$google_analytics_fileds = [
			'general-settings' =>'General',
			'tracking-settings'=>'Tracking',
			'events-settings' => 'Events'
		];

		echo '<table class="form-table">
			<tbody>
				<tr>
					<th scope="row">
					<div class="siteseo-container">';
						$is_first = true;
						foreach($google_analytics_fileds as $post_key => $post_val){
							$active_class = $is_first ? 'active' : '';
							echo '<a href="#'.esc_attr($post_key).'" class="'.esc_attr($active_class).'">'.esc_html($post_val).'</a>';
							$is_first = false;
						}
				echo '</div></th>
				<td>
					<div id="general-settings">
						<h3>'.esc_html__('Google Anlytics', 'siteseo').'</h3>
						<div class="siteseo_wrap_label"><p class="description">'.esc_html__('Connect your Google Analytics to your website. The tracking code will be automatically added to your site.', 'siteseo') .'</p></div>
						<span class="line"></span>
						<div class="siteseo_wrap_label"><p class="'.esc_html__('description">Link your Google Analytics to your website. The tracking code will be automatically added to your site', 'siteseo').'</p></div>
						<span class="line"></span>
						<table class="form-table">
								<tbody>
									<tr>
										<th scope="row">'.esc_html__('General', 'siteseo').'</th>
										<td></td>
									</tr>

									<tr>
										<th scope="row">'.esc_html__('Enable Google Analytics tracking', 'siteseo').'</th>
										<td>
											<label><input type="checkbox" name="siteseo_options[google_anlytics_tracking]" '.(!empty($option_enable_anaytics) ? 'checked="yes"' : '') . ' value="1"/> ' . esc_html__('Activate Google Analytics tracking using the Global Site Tag (gtag.js).', 'siteseo') . '</label>
										</td>
									</tr>

									<tr>
										<th scope="row">'.esc_html__('Enter your measurement ID (GA4)', 'siteseo').'</th>
										<td>
											<input type="text" placeholder="'.esc_attr__('Enter your measurement ID (G-XXXXXXXXXX)','siteseo').'" name="siteseo_options[anlytics_measurement_id]" value="'.esc_attr($option_anaytics_id).'">
											<p>
												<span class="dashicons dashicons-external"></span>
												<a href="https://support.google.com/analytics/answer/9539598?hl=en&ref_topic=9303319" target="_blank">'.esc_html__('Find your measurement ID', 'siteseo').'</a>
											</p>
										</td>
									</tr>
								</tbody>
						</table>
					</div></div>
					
					<div id="tracking-settings">
						<span class="line"></span>
						<h3>'.esc_html__('Tracking','siteseo').'</h3>
						<p class="description">'.esc_html__('Set up your Google Analytics tracking code.', 'siteseo').'</P>
						<table class="form-table">
							<tbody>
								<tr>
									<th scope="row">'.esc_html__('Enable Google Optimize.', 'siteseo').'</th>
									<td>
										<label>
											<input type="text" name="siteseo_options[container_id]" placeholder="'.esc_attr__('Enter your Google Optimize container ID.', 'siteseo').'" value="'.esc_attr($option_container_id).'"/>
										</label>
									</td>
								</tr>

								<tr>
									<th scope="row">'.esc_html__('Enable Google Ads','siteseo').'</th>	
									<td>
										<label>
											<input type="text" placeholder="'.esc_attr__('Enter your Google Ads conversion ID (eg: AW-123456789).', 'siteseo').'" name="siteseo_options[conversion_id]" value="'.esc_attr($option_conversion_id).'"/>
										</label>
									</td>
								</tr>

								<tr>
									<th scope="row">'.esc_html__('Enable remarketing, demographics, and interests reporting', 'siteseo').'</th>
									<td>
										<label>
											<input type="checkbox" name="siteseo_options[enable_remarketing]" '.(!empty($option_enable_remarketing) ? 'checked="yes"' : '').' value="1"/>
											'. esc_html__('Enable remarketing, demographics, and interests reporting', 'siteseo').'
										</label>
									</td>
								</tr>

								<tr>
									<th scope="row">'.esc_html__('Enable IP Anonymization', 'siteseo').'</th>
									<td>
										<label>
											<input type="checkbox" name="siteseo_options[ip_anonymiza]" '.(!empty($option_ip_anonymization) ? 'checked="yes"' : '').'/>
											'. esc_html__('Enable IP Anonymization', 'siteseo') .'
										</label>
									</td>
								</tr>

								<tr>
									<th scope="row">'.esc_html__('Enhanced Link Attribution', 'siteseo').'</th>
									<td>
										<label>
											<input type="checkbox" name="siteseo_options[link_attribution]" '.(!empty($option_links_attribution) ? 'checked="yes"' : '').'/>
											'. esc_html__('Enhanced Link Attribution', 'siteseo').'
										</label>
									</td>
								</tr>

								<tr>
									<th scope="row">'.esc_html__('Enable cross-domain tracking', 'siteseo').'</th>
									<td>
										<label>
											<input type="checkbox" name="siteseo_options[domain_tracking]" '.(!empty($option_domain_tracking) ? 'checked="yes"' : '').' />
											'. esc_html__('Enable cross-domain tracking', 'siteseo').'
										</label>
									</td>
								</tr>

								<tr>
									<th scope="row">'.esc_html__('Cross domains', 'siteseo').'</th>
									<td>
										<input type="text" placeholder="Enter your domains: siteseo.io,sub.siteseo.io,sub2.siteseo.io" name="siteseo_options[cross_domain]" value="'.esc_attr($option_cross_domain).'" />
									</td>
								</tr>

							</tbody>
						<table>
					</div>
					
					<div id="events-settings">
						<span class="line"></span>
						<h3>'.esc_html__('Events', 'siteseo').'</h3>
						<P class="description">'.esc_html__('Track events in Google Analytics', 'siteseo').'</p>
						<table class="form-table">
							<tbody>
								<tr>
									<th scope="row">'.esc_html__('Enable Google Optimize', 'siteseo').'</th>
									<td>
										<label>
											<input type="checkbox" name="siteseo_options[google_optimize]" '.(!empty($option_enable_optimize) ? 'checked="yes"' : ''). ' value="1">' . esc_html__(' Enable external links tracking', 'siteseo') . '
										</label>
									</td>
								</tr>
								
								<tr>
									<th scope="row">'.esc_html__('Enable downloads tracking (eg: PDF, XLSX, DOCX...)', 'siteseo').'</th>
									<td>
										<label>
											<input type="checkbox" name="siteseo_options[enable_download_tracking]" '.(!empty($option_enable_download_tracking) ? 'checked="yes"' : '').' value="1"> '.esc_html__('Enable download tracking', 'siteseo').'
										</label>
									</td>
								</tr>
								
								<tr>
									<th scope="row">'.esc_html__('Track downloads clicks', 'siteseo').'</th>
									<td>
										<input type="text" placeholder="pdf|docs|pptx|zip" name="siteseo_options[track_downlaods]" value="'.esc_attr($option_download_tracking).'"/>
										<p class="description">'.esc_html__('Separate each file type extensions with a pipe "|"','siteseo').'</p>
									</td>
								</tr>

								<tr>
									<th scope="row">'.esc_html__('Enable affiliate/outbound links tracking (eg: aff, go, out, recommends)', 'siteseo').'</th>
									<td>
										<label>
										<input type="checkbox" name="siteseo_options[aff_tracking_enable]" '.(!empty($option_affiliate_tracking_enable ) ? 'checked="yes"' : '').' value="1"/>
										'. esc_html__('Enable affiliate/outbound tracking','siteseo') .'</label>
									</td>
								</tr>

								<tr>
									<th scope="row">'.esc_html__('Track affiliate/outbound links','siteseo').'</th>
									<td>
										<input type="text" name="siteseo_options[aff_tracking]" placeholder="aff|go|out" value="'.esc_attr($option_affiliate_tracking).'"/>
										<p class="description">'.esc_html__('Separate each keyword with a pipe "|"', 'siteseo').'</p>
									</td>
								</tr>

								<tr>
									<th scope="row">'.esc_html__('Track phone links','siteseo').'</th>
									<td>
										<input type="checkbox" name="siteseo_options[track_phones]" '.(!empty($option_phone_tracking ) ? 'checked="yes"' : '') . ' value="1"/>
										'.esc_html__(' Enable tracking of "tel:" links' , 'siteseo'). '
										<div class="siteseo-styles pre"><pre>'.esc_html('<a href="tel:+33123456789">').'</pre></div>
									</td>
								</tr>
							</tbody>
						</table
					</div>
				</td>
			</tbody>
		</table>
		<input type="hidden" name="siteseo_options[analytics_tab]" value="1"/>';

	}

	static function save_settings(){

		global $siteseo;

		check_admin_referer('siteseo_analytics_settings');

		if(!siteseo_user_can('manage_analytics') || !is_admin()){
			return;
		}

		$options = [];
		
		if(empty($_POST['siteseo_options'])){
			return;
		}
		
		if(isset($_POST['siteseo_options']['analytics_tab'])){
			$options['google_analytics_enable'] = isset($_POST['siteseo_options']['google_anlytics_tracking']);
			$options['google_analytics_ga4'] = isset($_POST['siteseo_options']['anlytics_measurement_id']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['anlytics_measurement_id'])) : '';
			$options['google_analytics_link_tracking_enable'] = isset($_POST['siteseo_options']['google_optimize']);
			$options['google_analytics_download_tracking_enable'] = isset($_POST['siteseo_options']['enable_download_tracking']);
			$options['google_analytics_download_tracking'] = isset($_POST['siteseo_options']['track_downlaods']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['track_downlaods'])) : '';
			$options['google_analytics_affiliate_tracking_enable'] = isset($_POST['siteseo_options']['aff_tracking_enable']);
			$options['google_analytics_affiliate_tracking'] = isset($_POST['siteseo_options']['aff_tracking']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['aff_tracking'])) : '';
			$options['google_analytics_phone_tracking'] = isset($_POST['siteseo_options']['track_phones']);
			$options['google_analytics_optimize'] = isset($_POST['siteseo_options']['container_id']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['container_id'])) : '';
			$options['google_analytics_ads'] = isset($_POST['siteseo_options']['conversion_id']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['conversion_id'])) : '';
			$options['google_analytics_remarketing'] = isset($_POST['siteseo_options']['enable_remarketing']);
			$options['google_analytics_ip_anonymization'] = isset($_POST['siteseo_options']['ip_anonymiza']);
			$options['google_analytics_link_attribution'] = isset($_POST['siteseo_options']['link_attribution']);
			$options['google_analytics_cross_enable'] = isset($_POST['siteseo_options']['domain_tracking']);
			$options['google_analytics_cross_domain'] = isset($_POST['siteseo_options']['cross_domain']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['cross_domain'])) : '';
		}
		
		if(isset($_POST['siteseo_options']['clarity_tab'])){
			$options['google_analytics_clarity_enable'] = isset($_POST['siteseo_options']['microsoft_clarity']);
			$options['google_analytics_clarity_project_id'] = isset($_POST['siteseo_options']['project_id']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['project_id'])) : '';
		}
		
		if(isset($_POST['siteseo_options']['matomo_tab'])){
			$options['google_analytics_matomo_enable'] = isset($_POST['siteseo_options']['enable_matomo']);
			$options['google_analytics_matomo_self_hosted'] = isset($_POST['siteseo_options']['self_hosted']);
			$options['google_analytics_matomo_id'] = isset($_POST['siteseo_options']['tracking_id']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['tracking_id'])) : '';
			$options['google_analytics_matomo_site_id'] = isset($_POST['siteseo_options']['site_id']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['site_id'])) : '';
			$options['google_analytics_matomo_subdomains'] = isset($_POST['siteseo_options']['track_visitors']);
			$options['google_analytics_matomo_site_domain'] = isset($_POST['siteseo_options']['site_domain']);
			$options['google_analytics_matomo_cross_domain'] = isset($_POST['siteseo_options']['enable_cross_domains']);
			$options['google_analytics_matomo_no_js'] = isset($_POST['siteseo_options']['track_users']);
			$options['google_analytics_matomo_cross_domain_sites'] = isset($_POST['siteseo_options']['corss_domains']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['corss_domains'])) : '';
			$options['google_analytics_matomo_no_cookies'] = isset($_POST['siteseo_options']['disabled_cookies']);
			$options['google_analytics_matomo_link_tracking'] = isset($_POST['siteseo_options']['outlink_tracking']);
			$options['google_analytics_matomo_no_heatmaps'] = isset($_POST['siteseo_options']['disabled_heatmaps']);
			$options['google_analytics_matomo_dnt'] = isset($_POST['siteseo_options']['enable_donottack']);
		}
		
		if(isset($_POST['siteseo_options']['advanced_tab'])){
		
			$options['google_analytics_cd_author'] = isset($_POST['siteseo_options']['track_authors']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['track_authors'])) : '';
			$options['google_analytics_cd_category'] = isset($_POST['siteseo_options']['track_categories']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['track_categories'])) : '';
			$options['google_analytics_cd_tag'] = isset($_POST['siteseo_options']['track_tags']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['track_tags'])) : '';
			$options['google_analytics_cd_post_type'] = isset($_POST['siteseo_options']['track_post_types']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['track_post_types'])) : '';
			$options['google_analytics_cd_logged_in_user'] = isset($_POST['siteseo_options']['track_user']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['track_user'])) : '';
			
			// mics roles
			if(isset($_POST['siteseo_options']['misc_roles'])){
				$options['google_analytics_roles'] = map_deep(wp_unslash($_POST['siteseo_options']['misc_roles']), 'sanitize_text_field');
			}
		}
		
		if(isset($_POST['siteseo_options']['custom_tracking_tab']) && current_user_can('unfiltered_html')){
			// NOTE: These options can not be sanitized as we need user to be able to add some JS code, so we have added a capability check which only a super admin can have.
			$options['google_analytics_other_tracking'] = isset($_POST['siteseo_options']['head_tracking']) ? wp_unslash($_POST['siteseo_options']['head_tracking']) : '';
			$options['google_analytics_other_tracking_body'] = isset($_POST['siteseo_options']['body_tracking']) ? wp_unslash($_POST['siteseo_options']['body_tracking']) : '';
			$options['google_analytics_other_tracking_footer'] = isset($_POST['siteseo_options']['footer_tracking']) ? wp_unslash($_POST['siteseo_options']['footer_tracking']) : '';
		}
		
		if(isset($_POST['siteseo_options']['cookies_tab'])){
			
			$options['google_analytics_hook'] = isset($_POST['siteseo_options']['cookie_pos']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['cookie_pos'])) : '';
			$options['google_analytics_disable'] = isset($_POST['siteseo_options']['opt_tracking']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['opt_tracking'])) : '';
			$options['google_analytics_half_disable'] = isset($_POST['siteseo_options']['half_disable']);
			$options['google_analytics_opt_out_edit_choice'] = isset($_POST['siteseo_options']['opt_edit_choices']);
			$options['google_analytics_opt_out_msg'] = isset($_POST['siteseo_options']['opt_msg']) ? wp_kses_post(wp_unslash($_POST['siteseo_options']['opt_msg'])) : 'We use cookies to enhance your experience.';
			$options['google_analytics_opt_out_msg_ok'] = isset($_POST['siteseo_options']['opt_msg_ok']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['opt_msg_ok'])) : 'Accept';
			$options['google_analytics_opt_out_msg_edit'] = isset($_POST['siteseo_options']['opt_edit_btn']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['opt_edit_btn'])) : 'Manage cookies';
			$options['google_analytics_opt_out_msg_close'] = isset($_POST['siteseo_options']['opt_close']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['opt_close'])) : 'X';
			$options['google_analytics_cb_exp_date'] = isset($_POST['siteseo_options']['cd_exp_date']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['cd_exp_date'])) : '30';
			$options['google_analytics_cb_pos'] = isset($_POST['siteseo_options']['cd_pos']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['cd_pos'])) : 'center';
			$options['google_analytics_cb_txt_align'] = isset($_POST['siteseo_options']['cd_txt_align']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['cd_txt_align'])) : 'center';
			$options['google_analytics_cb_width'] = isset($_POST['siteseo_options']['cd_width']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['cd_width'])) : '100%';
			$options['google_analytics_cb_scheme'] = isset($_POST['siteseo_options']['google_analytics_cb_scheme']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['google_analytics_cb_scheme'])) : '';

			// Colors
			$options['google_analytics_cb_backdrop'] = isset($_POST['siteseo_options']['cd_backdrop']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['cd_backdrop'])) : '';
			$options['google_analytics_cb_backdrop_bg'] = isset($_POST['siteseo_options']['backdrop_bg']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['backdrop_bg'])) : '';
			$options['google_analytics_cb_bg'] = isset($_POST['siteseo_options']['cookiesbar_bg']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['cookiesbar_bg'])) : '';
			$options['google_analytics_cb_txt_col'] = isset($_POST['siteseo_options']['cookiebar_txt']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['cookiebar_txt'])) : '';
			$options['google_analytics_cb_lk_col'] = isset($_POST['siteseo_options']['line_co']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['line_co'])) : '';
			$options['google_analytics_cb_btn_bg'] = isset($_POST['siteseo_options']['primary_btn_bg']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['primary_btn_bg'])) : '';
			$options['google_analytics_cb_btn_bg_hov'] = isset($_POST['siteseo_options']['primary_btn_bg_hov']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['primary_btn_bg_hov'])) : '';
			$options['google_analytics_cb_btn_col'] = isset($_POST['siteseo_options']['primary_btn_txt']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['primary_btn_txt'])) : '';
			$options['google_analytics_cb_btn_col_hov'] = isset($_POST['siteseo_options']['primary_btn_txt_hov']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['primary_btn_txt_hov'])) : '';
			$options['google_analytics_cb_btn_sec_bg'] = isset($_POST['siteseo_options']['sec_btn_bg']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['sec_btn_bg'])) : '';
			$options['google_analytics_cb_btn_sec_bg_hov'] = isset($_POST['siteseo_options']['sec_btn_bg_hov']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['sec_btn_bg_hov'])) : '';
			$options['google_analytics_cb_btn_sec_col'] = isset($_POST['siteseo_options']['sec_btn_txt']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['sec_btn_txt'])) : '';
			$options['google_analytics_cb_btn_sec_col_hov'] = isset($_POST['siteseo_options']['sec_btn_txt_hov']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['sec_btn_txt_hov'])) : '';
		}

		update_option('siteseo_google_analytics_option_name', $options);
	}

}
PKv�f\�4+�EEsettings/dashboard.phpnu�[���<?php
/*
* SITESEO
* https://siteseo.io
* (c) SiteSEO Team
*/

namespace SiteSEO\Settings;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class Dashboard{

	static function dashboard_tab(){
		global $siteseo;
		
		$pro = get_option('siteseo_pro_options');
		$options = $siteseo->setting_enabled;

		$titles_meta_toggle = isset($options['toggle-titles']) ? $options['toggle-titles'] : '';
		$sitemap_toggle = isset($options['toggle-xml-sitemap']) ? $options['toggle-xml-sitemap'] : '';
		$social_toggle = isset($options['toggle-social']) ? $options['toggle-social'] : '';
		$advanced_toggle = isset($options['toggle-advanced']) ? $options['toggle-advanced'] : '';
		$analytics_toggle = isset($options['toggle-google-analytics']) ? $options['toggle-google-analytics'] : '';
		$indexing_toggle = isset($options['toggle-instant-indexing']) ? $options['toggle-instant-indexing'] : '';

		//pro-features
		$toggle_localBusiness = isset($pro['toggle_state_local_buz']) ? $pro['toggle_state_local_buz'] : '';
		$toggle_easy_digital = isset($pro['toggle_state_easy_digital']) ? $pro['toggle_state_easy_digital'] : '';
		$toggle_woocommerce  = isset($pro['toggle_state_woocommerce']) ? $pro['toggle_state_woocommerce'] : '';
		$toggle_structured_data = isset($pro['toggle_state_stru_data']) ? $pro['toggle_state_stru_data'] : '';
		$toggle_state_redirect = isset($pro['toggle_state_redirect_monitoring']) ? $pro['toggle_state_redirect_monitoring'] : '';
		$toggle_state_google_news = isset($pro['toggle_state_google_news']) ? $pro['toggle_state_google_news'] : '';
		$toggle_state_video_sitemap = isset($pro['toggle_state_video_sitemap']) ? $pro['toggle_state_video_sitemap'] : '';
		$toggle_state_llm_txt = isset($pro['toggle_state_llm_txt']) ? $pro['toggle_state_llm_txt'] : '';

		$nonce = wp_create_nonce('siteseo_toggle_nonce');

		$pro_nonce = wp_create_nonce('siteseo_pro_toggle_nonce');

		$siteseo_dashboard_img = SITESEO_ASSETS_URL.'/img/seo-get-started.jpg';
		$siteseo_loginizer_product = SITESEO_ASSETS_URL.'/img/loginizer_product.png';
		
		echo'<div id="siteseo-root">';

		Util::admin_header();
		$dismissed_intro = get_option('siteseo_dismiss_intro', 0);

		echo'<div id="siteseo-dashbord">';
		
		if(empty($dismissed_intro) && !defined('SITEPAD')){
			echo '<div class="siteseo-dashbord-intro">
			   <div class="siteseo-text-content">
					<h2>'.esc_html__('HOW-TO GET STARTED', 'siteseo').'</h2><h1>'.esc_html__('Welcome to SiteSEO!', 'siteseo').'</h1>
					<p>'.esc_html__('Launch our installation wizard to quickly and easily configure the basic SEO settings for your site. Cant find the answers to your questions? Write us at support@siteseo.io. A happiness engineer will be happy to help you.', 'siteseo').'</p>
					<div class="siteseo-buttons">
					<a class="get-started" href="?page=siteseo-onboarding">'.esc_html__('Get started', 'siteseo').'</a>
					<a class="dismiss" id="siteseo-dismiss-get-started" href="#">'.esc_html__('Dismiss', 'siteseo').'</a>
					</div>
				</div>
				<div class="siteseo-image-content"><img alt="'.esc_html__('Illustration of a megaphone with various icons representing SEO and digital marketing', 'siteseo').'" height="470" src="'.esc_url($siteseo_dashboard_img).'" width="470"/>
				</div>
			</div>';
		}

			echo '<div class="siteseo-dashbord-content">
				<section class="siteseo-dashboard-features">
					<h2>'.esc_html__('Manage SiteSEO Features', 'siteseo').'</h2></br/>
					<div class="siteseo-dashbord-container">
						<div class="siteseo-card">
							<div class="siteseo-card-body">
								<span class="dashicons dashicons-edit-large siteseo-card-icon"></span>
								<h3>'.esc_html__('Titles &amp; Metas', 'siteseo').'</h3>
								<p>'.esc_html__('Manage all your titles and metas for post types, taxonomies more...', 'siteseo').'</p>
							</div>
							<div class="siteseo-card-footer">
								<a href="admin.php?page=siteseo-titles">'.esc_html__('Settings', 'siteseo').'</a>';
								Util::render_toggle('Titles & Metas -SiteSEO', 'titles_meta_toggle', $titles_meta_toggle, $nonce, true);
						   echo'</div>
						</div>

			<div class="siteseo-card">
				<div class="siteseo-card-body">
					<span class="dashicons dashicons-networking siteseo-card-icon"></span>
					<h3>'.esc_html__('XML & HTML Sitemaps', 'siteseo').'</h3>
					<p>'.esc_html__('Manage your XML - Image - Video- Taxonomies - HTML Sitemap more...', 'siteseo').'</p>
				</div>
				<div class="siteseo-card-footer">
					<a href="admin.php?page=siteseo-sitemaps">'.esc_html__('Settings', 'siteseo').'</a>';
					Util::render_toggle('Sitemaps - SiteSEO', 'sitemap_toggle', $sitemap_toggle, $nonce,true);
				echo'</div>
			</div>

			<div class="siteseo-card">
				<div class="siteseo-card-body">
					<span class="dashicons dashicons-share siteseo-card-icon"></span>
					<h3>'.esc_html__('Social Networks', 'siteseo').'</h3>
					<p>'.esc_html__('Open Graph, X Card, Google Knowledge Graph and more...', 'siteseo').'</p>
				</div>
				<div class="siteseo-card-footer">
					<a href="admin.php?page=siteseo-social">'.esc_html__('Settings','siteseo').'</a>';
					Util::render_toggle('Social - SiteSEO', 'social_toggle', $social_toggle, $nonce,true);
				echo'</div>
			</div>

			<div class="siteseo-card">
				<div class="siteseo-card-body">
					<span class="dashicons dashicons-performance siteseo-card-icon"></span>
					<h3>'.esc_html__('Analytics', 'siteseo').'</h3>
					<p>'.esc_html__('Track everything about your visitors with Analytics/Matomo more...', 'siteseo').'</p>
				</div>
				<div class="siteseo-card-footer">
					<a href="admin.php?page=siteseo-analytics">'.esc_html__('Settings','siteseo').'</a>';
					Util::render_toggle('Analytics - SiteSEO', 'analytics_toggle', $analytics_toggle, $nonce,true);
				echo'</div>
			</div>

			<div class="siteseo-card">
				<div class="siteseo-card-body">
					<span class="dashicons dashicons-superhero siteseo-card-icon"></span>
					<h3>'.esc_html__('Instant Indexing','siteseo').'</h3>
					<p>'.esc_html__('Ping Google & Bing to quickly index your content. Updated and  remove submit URLs','siteseo').'</p>
				</div>
				<div class="siteseo-card-footer">
					<a href="admin.php?page=siteseo-instant-indexing">'.esc_html__('Settings','siteseo').'</a>';
					Util::render_toggle('Instant indexing - SiteSEO', 'indexing_toggle', $indexing_toggle, $nonce,true);
				echo'</div>
			</div>

			<div class="siteseo-card">
				<div class="siteseo-card-body">
					<span class="dashicons dashicons-format-gallery siteseo-card-icon"></span>
					<h3>'.esc_html__('Image SEO','siteseo').'</h3>
					<p>'.esc_html__('Optimize your images for SEO. Configure advanced settings more...','siteseo').'</p>
				</div>
				<div class="siteseo-card-footer">
					<a href="admin.php?page=siteseo-advanced">'.esc_html__('Settings','siteseo').'</a>';
					Util::render_toggle('Advanced - SiteSEO', 'advanced_toggle', $advanced_toggle, $nonce,true);
				echo'</div>
			</div>

			<div class="siteseo-card">
				<div class="siteseo-card-body">
					<span class="dashicons dashicons-upload siteseo-card-icon"></span>
					<h3>'.esc_html__('Tools', 'siteseo').'</h3>
					<p>'.esc_html__('Import/Export plugin settings from site to site. Reset settings more...', 'siteseo').'</p>
				</div>
				<div class="siteseo-card-footer">
					<a href="admin.php?page=siteseo-tools">'.esc_html__('Settings', 'siteseo').'</a>
					<div class="siteseo-toggle-container">
					</div>
				</div>
			</div>';
			if(!defined('SITEPAD')){
				echo'<div class="siteseo-card">
					<div class="siteseo-card-body">
						<span class="dashicons dashicons-cart siteseo-card-icon"></span>
						<h3>'.esc_html__('WooCommerces SEO','siteseo'),'</h3>
						<p>'.esc_html__('Add meta tags required for WooCommerce SEO','siteseo').'</p>
					</div>
					<div class="siteseo-card-footer">';
						if(defined('SITESEO_PRO_VERSION')){
							echo'<a href="admin.php?page=siteseo-pro-page">'.esc_html__('Settings','siteseo').'</a>';
						} else{
							echo'<div class="siteseo-pro-badge">Pro</div>';
						}
						
						if(class_exists('\SiteSEOPro\Settings\Util') && method_exists('\SiteSEOPro\Settings\Util', 'render_toggle')){
							\SiteSEOPro\Settings\Util::render_toggle('woocommerce', $toggle_woocommerce, $pro_nonce, true);
						} 
					echo'</div></div>';
			

			echo '<div class="siteseo-card">
				<div class="siteseo-card-body">
					<span class="dashicons dashicons-money-alt siteseo-card-icon"></span>
					<h3>'.esc_html__('Easy Digital Downloads', 'siteseo').'</h3>
					<p>'.esc_html__('Add meta tags required for Easy Digitial Downloads SEO', 'siteseo').'</p>
				</div>
				<div class="siteseo-card-footer">';
					if(defined('SITESEO_PRO_VERSION')){
						echo'<a href="admin.php?page=siteseo-pro-page">'.esc_html__('Settings','siteseo').'</a>';
					} else{
						echo'<div class="siteseo-pro-badge">Pro</div>';
					}
					
					if(class_exists('\SiteSEOPro\Settings\Util') && method_exists('\SiteSEOPro\Settings\Util', 'render_toggle')){
						\SiteSEOPro\Settings\Util::render_toggle('edd', $toggle_easy_digital, $pro_nonce,true);
					}
				echo'</div></div>';
			}
			echo '<div class="siteseo-card">
				<div class="siteseo-card-body">
					<span class="dashicons dashicons-code-standards siteseo-card-icon"></span>
					<h3>'.esc_html__('Page Speed', 'siteseo').'</h3>
					<p>'.esc_html__('Enhance Your Website Performance with PageSpeed Insights','siteseo').'</p>
				</div>
				<div class="siteseo-card-footer">';
					if(defined('SITESEO_PRO_VERSION')){
						echo'<a href="admin.php?page=siteseo-pro-page">'.esc_html__('Settings', 'siteseo').'</a>';
					} else {
						echo'<div class="siteseo-pro-badge">Pro</div>';
					}
				echo'</div>
			</div>

			<div class="siteseo-card">
				'.((time() < strtotime('30 November 2025')) ? '<span class="siteseo-feature-update-badge">Updated</span>' : '') .'
				<div class="siteseo-card-body">
					<span class="dashicons dashicons-list-view siteseo-card-icon"></span>
					<h3>'.esc_html__('Structured Data','siteseo').'</h3>
					<p>'.esc_html__('Enhance Search Visibility with Structured Data Optimization','siteseo').'</p>
				</div>
				<div class="siteseo-card-footer">';
					if(defined('SITESEO_PRO_VERSION')){
						echo'<a href="admin.php?page=siteseo-pro-page">'.esc_html__('Settings', 'siteseo').'</a>';
					} else{
						echo'<div class="siteseo-pro-badge">Pro</div>';
					}
					
					if(class_exists('\SiteSEOPro\Settings\Util') && method_exists('\SiteSEOPro\Settings\Util', 'render_toggle')){
						\SiteSEOPro\Settings\Util::render_toggle('structured', $toggle_structured_data, $pro_nonce,true);
					}
				echo'</div>
			</div>

			<div class="siteseo-card">
				<div class="siteseo-card-body">
					<span class="dashicons dashicons-location siteseo-card-icon"></span>
					<h3>'.esc_html__('Local Business', 'siteseo').'</h3>
					<p>'.esc_html__('Optimize Your Online Presence for Local Business Success', 'siteseo').'</p>
				</div>
				<div class="siteseo-card-footer">';
					if(defined('SITESEO_PRO_VERSION')){
						echo '<a href="admin.php?page=siteseo-pro-page">'.esc_html__('Settings', 'siteseo').'</a>';
					} else{
						echo'<div class="siteseo-pro-badge">Pro</div>';
					}
					
					if(class_exists('\SiteSEOPro\Settings\Util') && method_exists('\SiteSEOPro\Settings\Util', 'render_toggle')){
						\SiteSEOPro\Settings\Util::render_toggle('local', $toggle_localBusiness, $pro_nonce, true);
					}
				echo'</div>
			</div>
			
			<div class="siteseo-card">
				<div class="siteseo-card-body">
					<span class="dashicons dashicons-editor-unlink siteseo-card-icon"></span>
					<h3>'.esc_html__('Redirections / 404 monitoring','siteseo').'</h3>
					<p>'.esc_html__('Track 404 errors and set up redirects to improve user experience and SEO.','siteseo').'</p>
				</div>
				<div class="siteseo-card-footer">';
					if(defined('SITESEO_PRO_VERSION')){
						echo'<a href="admin.php?page=siteseo-pro-page">'.esc_html__('Settings', 'siteseo').'</a>';
					} else{
						echo'<div class="siteseo-pro-badge">Pro</div>';
					}
					
					if(class_exists('\SiteSEOPro\Settings\Util') && method_exists('\SiteSEOPro\Settings\Util', 'render_toggle')){
						\SiteSEOPro\Settings\Util::render_toggle('404_monitoring', $toggle_state_redirect, $pro_nonce, true);
					}
				echo'</div>
			</div>
			
			<div class="siteseo-card">
				<div class="siteseo-card-body">
					<span class="dashicons dashicons-index-card siteseo-card-icon"></span>
					<h3>'.esc_html__('Google News','siteseo').'</h3>
					<p>'.esc_html__('Generate and manage a Google News sitemap to ensure your news articles get indexed quickly.','siteseo').'</p>
				</div>
				<div class="siteseo-card-footer">';
					if(defined('SITESEO_PRO_VERSION')){
						echo'<a href="admin.php?page=siteseo-pro-page">'.esc_html__('Settings', 'siteseo').'</a>';
					} else{
						echo'<div class="siteseo-pro-badge">Pro</div>';
					}
					
					if(class_exists('\SiteSEOPro\Settings\Util') && method_exists('\SiteSEOPro\Settings\Util', 'render_toggle')){
						\SiteSEOPro\Settings\Util::render_toggle('google_news', $toggle_state_google_news, $pro_nonce, true);
					}
				echo'</div>
			</div>
			
			<div class="siteseo-card">
				<div class="siteseo-card-body">
					<span class="dashicons dashicons-format-video siteseo-card-icon"></span>
					<h3>'.esc_html__('Video Sitemap','siteseo').'</h3>
					<p>'.esc_html__('Create and manage a video sitemap to help search engines index your video content efficiently.','siteseo').'</p>
				</div>
				<div class="siteseo-card-footer">';
					if(defined('SITESEO_PRO_VERSION')){
						echo'<a href="admin.php?page=siteseo-pro-page">'.esc_html__('Settings', 'siteseo').'</a>';
					} else{
						echo'<div class="siteseo-pro-badge">Pro</div>';
					}
					
					if(class_exists('\SiteSEOPro\Settings\Util') && method_exists('\SiteSEOPro\Settings\Util', 'render_toggle')){
						\SiteSEOPro\Settings\Util::render_toggle('video_sitemap', $toggle_state_video_sitemap, $pro_nonce, true);
					}
				echo'</div>
			</div>

			<div class="siteseo-card">
				'.((time() < strtotime('30 November 2025')) ? '<span class="siteseo-feature-new-badge">New</span>' : '') .'
				<div class="siteseo-card-body">
					<span class="dashicons dashicons-media-text siteseo-card-icon"></span>
					<h3>'.esc_html__('LLMs txt', 'siteseo').'</h3>
					<p>'.esc_html__('Generate an llms.txt file with a single click to help AI crawlers better understand, index, and represent your business accurately.', 'siteseo').'</p>
				</div>
				<div class="siteseo-card-footer">';
					if(defined('SITESEO_PRO_VERSION')){
						echo'<a href="admin.php?page=siteseo-pro-page">'.esc_html__('Settings', 'siteseo').'</a>';
					} else{
						echo'<div class="siteseo-pro-badge">Pro</div>';
					}
					
					if(class_exists('\SiteSEOPro\Settings\Util') && method_exists('\SiteSEOPro\Settings\Util', 'render_toggle')){
						\SiteSEOPro\Settings\Util::render_toggle('llm_txt', $toggle_state_llm_txt, $pro_nonce, true);
					}
				echo'</div>
			</div>';

	echo'</div></section>';
	
	if(!defined('SITEPAD')){
		echo'<section class="siteseo-dashboard-extras">';
			if(defined('SITESEO_PRO_VERSION') && defined('SITESEO_PRO_AI_BUY')){
				do_action('siteseo_pro_show_ai_tokens_sidebar');
			}
			echo '<div class="siteseo-need-help">
				<p>Quick Access</p>
				<div class="siteseo-quick-links">
					<div class="siteseo-quick-access-item">
						<span class="dashicons dashicons-format-status"></span>
						<a href="https://softaculous.deskuss.com/open.php?topicId=22" target="_blank">Support</a>
					</div>
					<div class="siteseo-quick-access-item">
						<span class="dashicons dashicons-media-document"></span>
						<a href="https://siteseo.io/docs/" target="_blank">Documentation</a>
					</div>
					<div class="siteseo-quick-access-item">
						<span class="dashicons dashicons-feedback"></span>
						<a href="https://softaculous.deskuss.com/open.php?topicId=22" target="_blank">Feedback</a>
					</div>
					<div class="siteseo-quick-access-item">
						<span class="dashicons dashicons-star-filled" style="color:#FFD700;"></span><a href="https://wordpress.org/support/plugin/siteseo/reviews/?rate=5#new-post" target="_blank">Rate Us</a>
					</div>
				</div>
			</div>
			<div class="siteseo-admin-softaculous-branding">SiteSEO - A Softaculous Product</div>';

			if(!defined('SITEPAD') && !defined('SITESEO_PRO_VERSION')){
				self::pro_upsell();
			}

			echo '</section>';
	}

	echo '</div></div></div>';
	}

	static function pro_upsell(){

		$features = [
			'Search Statistics',
			'Advanced Sitemaps',
			'Redirection Management',
			'AI-Generations Titles & Descriptions',
			'LLMs.txt Support',
			'and More…',
		];

		echo '<div class="siteseo-promo-modern-card">
			<div class="siteseo-promo-header-group">
			<h3 class="siteseo-promo-title">SiteSEO</h3>
			<span class="siteseo-promo-badge-pro">Pro</span>
			</div>

			<p class="siteseo-promo-desc">'.esc_html__('Unlock advanced performance features.', 'siteseo').'</p>

			<ul class="siteseo-promo-feature-list">';
			foreach($features as $feature){
				echo '<li class="siteseo-promo-feature-item">
					<div class="siteseo-promo-check-circle">
						<div class="siteseo-promo-check-icon"></div>
					</div>
					'.esc_html($feature).'
				</li>';
			}
			echo '</ul>

			<a href="https://siteseo.io/pricing/?utm_source=plugin_settings" class="siteseo-promo-btn-main" target="_blank">
				<span class="siteseo-promo-btn-text">'.esc_html__('Upgrade to Pro', 'siteseo').'</span>
				<span class="siteseo-promo-arrow">&rarr;</span>
			</a>
		</div>';
	}

}
PKv�f\HrҰ��settings/tools.phpnu�[���<?php
/*
* SITESEO
* https://siteseo.io
* (c) SiteSEO Team
*/

namespace SiteSEO\Settings;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class Tools{

	static function menu(){

		echo '<div id="siteseo-root">';
		
		Util::admin_header();

		$plugins = Util::importable_plugins();

		echo '<form method="post" id="siteseo-form" class="siteseo-option" name="siteseo-flush">
				<span id="siteseo-tab-title"><strong>'.esc_html__('Tools - SiteSEO','siteseo').'</strong></span><br/><br/>
				<span class="line"></span>
				<div style="siteseo-tools-page">';
					if(!defined('SITEPAD')){
						echo '<h3>'.esc_html__('Import Settings From Other Plugins','siteseo').'</h3>
						<div class="siteseo_wrap_label">
							<p class="description">'.esc_html__('Import posts and terms metadata from the specified source', 'siteseo').'</p>
						</div>

						<p><select id="siteseo-plugin-selector">
							<option value="none">'.esc_html__('Select an option', 'siteseo').'</option>';
							foreach($plugins as $plugin => $name){
								$plugin_slug = explode('/', $plugin);
								$plugin = $plugin_slug[0];

								echo '<option value="'. esc_attr($plugin) . '-migration-tool">'.esc_html($name).'</option>';
							}

						echo '</select></p>
						<p class="description">' . esc_html__('You don\'t need to enable the selected SEO plugin to run the import.', 'siteseo').'</p>';
					
						foreach($plugins as $plugin =>$name){
							self::display_plugins($plugin, $name);
						}

						echo '<span class="line"></span>';
					}
					
					echo '<h3>'.esc_html__('Export plugin settings','siteseo').'</h3>
					<div class="siteseo_wrap_label">
						<p class="description">'.esc_html__('Export the plugin settings for this site as a .json file, making it easy to import the configuration into another site.', 'siteseo').'</p>
					</div>

					<div class="siteseo_wrap_label">
						<button class="btn btnSecondary" id="siteseo-export-btn">'.esc_html__('Export', 'siteseo').'</button>
					</div>
					<span class="line"></span>
					
					<h3>'.esc_html__('Import plugin settings', 'siteseo').'</h3>
					<div class="siteseo_wrap_label">
						<p class="description">'.esc_html__('Import the plugin settings from a .json file. You can obtain this file by exporting the settings from another site using the form above.','siteseo').'</p>
					</div>
							
					<div class=siteseo_wrap_label>
						<input type="file" id="siteseo-import-file" accept=".json" />
					</div>

					<div class="siteseo_wrap_label">
						<button class="brn btnSecondary" id="siteseo-import-btn">'. esc_html__('Import', 'siteseo') .'</button>
					</div>
					
					<span class="line"></span>
					
					<h3>'.esc_html__('Reset All Settings', 'siteseo').'</h3>
					<div class="siteseo_wrap_label"><div class="siteseo-notice is-warning">
						<span id="dashicons-warning" class="dashicons dashicons-info"></span>&nbsp;
						<div><p>'.
						/* translators: placeholders are just <strong> tag */ 
						wp_kses_post(sprintf(__('%1$s WARNING: %2$s Delete all options related to this plugin in your database.','siteseo'), '<strong>', '</strong>')).'</p></div>
					</div></div>
					<button class="btn btnSecondary" id="siteseo-reset-settings">'.esc_html__('Reset settings', 'siteseo').'</button>
	
			</div>
			</form></div>';
	}
	
	static function display_plugins($plugin,$name){
		$seo_title = 'SiteSEO';
		$plugin_slug = explode('/', $plugin);
		$plugin = $plugin_slug[0];
		
		echo '<div id="'.esc_attr($plugin).'-migration-tool" class="postbox siteseo-section-tool">
		<div class="inside">
		<h3>'. /* translators: %s represents the import posts and terms */ 
		sprintf(esc_html__('Import posts and terms (if available) metadata from %s', 'siteseo'), esc_html($name)).'</h3>
		<p>'. esc_html__('By clicking Migrate, we\'ll import:', 'siteseo').'</p>
		<ul>
			<li>'. esc_html__('Title tags', 'siteseo') .'</li>
			<li>'. esc_html__('Meta description', 'siteseo') .'</li>
			<li>'. esc_html__('Facebook Open Graph tags (title, description and image thumbnail)', 'siteseo') .'</li>
			<li>'. esc_html__('Twitter tags (title, description and image thumbnail)', 'siteseo') .'</li>
			<li>'. esc_html__('Meta Robots (noindex, nofollow...)', 'siteseo') .'</li>
			<li>'.esc_html__('Canonical URL', 'siteseo').'</li>';

			if($plugin !='slim-seo' && $plugin != 'surerank'){
				echo '<li>'. esc_html__('Focus / target keywords', 'siteseo') .'<li>';
			}
			
			if($plugin != 'all-in-one-seo-pack' && $plugin !='slim-seo' && $plugin != 'surerank'){
				echo '<li>'. esc_html__('Primary category', 'siteseo') .'</li>';
			}
			
			if('autodescription' == $plugin || 'all-in-one-seo-pack' == $plugin || 'wp-seopress' == $plugin){
				echo '<li>'. esc_html__('Redirect URL', 'siteseo') .'</li>';
			}

			echo '</ul>
					<div class="siteseo_wrap_label">						
						<div class="siteseo-notice is-warning">
							<span id="dashicons-warning" class="dashicons dashicons-warning"></span>&nbsp;
								<p>'. 
								/* translators: %s represents the degree of severity */ 
								wp_kses_post(sprintf(__('<strong>WARNING:</strong> Migration will delete / update all <strong>%1$s posts and terms metadata</strong>. Some dynamic variables will not be interpreted. We do <strong>NOT delete any %2$s data</strong>.', 'siteseo'), esc_html($seo_title), esc_html($name))). '
								</p>
						</div>
					</div>
						
					<button id="siteseo-'.esc_attr($plugin).'-migrate" type="button" class="btn btnSecondary">' 
						. esc_html__('Import now', 'siteseo').'</button><span class="spinner"></span><div class="log"></div>
					</div>
				</div>';
		}

}
PKv�f\Gjqβ
�
settings/util.phpnu�[���<?php
/*
* SITESEO
* https://siteseo.io
* (c) SiteSEO Team
*/

namespace SiteSEO\Settings;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class Util{

	static function clean_text($text){
		return sanitize_text_field(wp_unslash($text));
	}

	static function clean_url($url){
		if(is_array($url)){
			return map_deep(wp_unslash($url), 'sanitize_url');
		}

		return sanitize_url(wp_unslash($url));
	}

	static function render_toggle($title, $toggle_key, $toggle_state, $nonce, $label = false){
		$is_active = $toggle_state ? 'active' : '';
		$state_text = $toggle_state ? 'Disable' : 'Enable';

		// for dashbord screen
		if(!empty($label)){
			echo '<div class="siteseo-toggle-cnt">
				<div class="siteseo-toggle-Sw '.esc_attr($is_active).'" id="siteseo-toggleSw-' . esc_attr($toggle_key) . '" data-nonce="'.esc_attr($nonce).'" data-toggle-key="'.esc_attr($toggle_key).'" data-action="siteseo_save_'.esc_attr($toggle_key).'"></div>
				<input type="hidden" name="siteseo_options['.esc_attr($toggle_key) . ']" id="'.esc_attr($toggle_key).'" value="'.esc_attr($toggle_state).'">
			</div>';
		}else{

			echo '<div class="siteseo-toggle-cnt">
				<span id="siteseo-tab-title"><strong>'.esc_html($title).'</strong></span>
				<div class="siteseo-toggle-Sw '.esc_attr($is_active).'" id="siteseo-toggleSw-'.esc_attr($toggle_key).'" data-nonce="' . esc_attr($nonce) . '" data-toggle-key="'.esc_attr($toggle_key).'" data-action="siteseo_save_'.esc_attr($toggle_key).'"></div>
				<span id="siteseo-arrow-icon" class="dashicons dashicons-arrow-left-alt siteseo-arrow-icon"></span>
				<p class="toggle_state_'.esc_attr($toggle_key).'">'.esc_html($state_text).'</p>
				<input type="hidden" name="siteseo_options['.esc_attr($toggle_key).']" id="'.esc_attr($toggle_key).'" value="'.esc_attr($toggle_state).'">
			</div>';
		}
	}
	
	static function admin_header(){
		echo '<div class="siteseo-navbar">
			<div class="logo">
				<img alt="'.esc_html__('siteseo logo', 'siteseo').'" height="30" src="'. esc_url(SITESEO_ASSETS_URL).'/img/logo-24.svg'.'" width="40"/>
				<div class="siteseo-breadcrumb">
					<a href="#">'.esc_html__('Home', 'siteseo').'</a>
					<span>/</span>
					<a class="active" href="">'.esc_html(get_admin_page_title()).'</a>
				</div>
			</div>';
			
			echo'<div class="links">
					<span class="siteseo-header-version-badge">v'.esc_html(SITESEO_VERSION).'</span>
					<a target="_blank" href="https://siteseo.io/docs/">'.esc_html__('Docs', 'siteseo').'</a>';
					
					if(!defined('SITEPAD')){
						echo'<a target="_blank" class="support" href="https://softaculous.deskuss.com/open.php?topicId=22">'.esc_html__('Support', 'siteseo').'</a>';
					}
				echo'</div>
			</div>';
	}
	
	static function importable_plugins(){
		return [
			'wordpress-seo/wp-seo.php' => 'Yoast SEO',
			'all-in-one-seo-pack/all_in_one_seo_pack.php' => 'All In One SEO',
			'autodescription/autodescription.php' => 'The SEO Framework',
			'seo-by-rank-math/rank-math.php' => 'Rank Math',
			'wp-seopress/seopress.php' => 'SEOPress',
			'slim-seo/slim-seo.php' => 'Slim SEO',
			'surerank/surerank.php' => 'Surerank'
		];
	}

	static function submit_btn($value = ''){
		echo '<div class="siteseo-submit-button"><input type="submit" id="submit" name="submit" value="'.esc_attr($value ?: 'Save changes') . '" class="submit-button"></div>';
	}
	
	static function extract_content($input){

		if(preg_match('/content=["\']([^"\']+)["\']/', $input, $matches)){
			return $matches[1];
		}
		
		return $input;
	}
}PKv�f\�^-�O�Osettings/onboarding.phpnu�[���<?php
/*
* SITESEO
* https://siteseo.io
* (c) SiteSEO Team
*/

namespace SiteSEO\Settings;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class OnBoarding{
	
	static $current_step = '';
	static $import_options = [];
	static $steps = [];
	static $current_step_no = 1;

	static function init(){
		if(wp_doing_ajax()){
			return;
		}
		
		self::$steps = [
			'your-site' => [
				'title' => 'Your Site',
				'desc' => 'Your site and social data',
				'fn' => '\SiteSEO\Settings\OnBoarding::site_page',
			],
			'indexing' => [
				'title' => 'Indexing',
				'desc' => 'Select post type indexing',
				'fn' => '\SiteSEO\Settings\OnBoarding::indexing_page',
			],
			'advanced' => [
				'title' => 'Advanced',
				'desc' => 'URL configuration',
				'fn' => '\SiteSEO\Settings\OnBoarding::advanced_page',
			],
			'ready' => [
				'title' => 'Ready',
				'desc' => 'All set now!',
				'fn' => '\SiteSEO\Settings\OnBoarding::ready_page',
			],
		];
		
		$active_plugins = get_option('active_plugins', []);
		$importable_plugins = Util::importable_plugins();
		$importable_plugins = array_keys($importable_plugins);
		
		$importable_found = array_intersect($active_plugins, $importable_plugins);
		
		if(!empty($importable_found)){
			$import_step = [
				'import' => [
					'title' => 'Import',
					'desc' => 'Importing meta data',
					'fn' => '\SiteSEO\Settings\OnBoarding::import_page',
				]
			];
			
			self::$steps = array_merge($import_step, self::$steps);
			self::$import_options = $importable_found;
		}
		
		self::$current_step = !empty($_REQUEST['step']) ? sanitize_text_field(wp_unslash($_REQUEST['step'])) : '';

		remove_all_actions('admin_notices');
		remove_all_actions('all_admin_notices');
		remove_all_actions('network_admin_notices');
		add_action('admin_menu', '\SiteSEO\Settings\OnBoarding::add_to_menu');
		add_action('admin_init', '\SiteSEO\Settings\OnBoarding::page');
	}

	static function enqueue_assets(){
		wp_enqueue_media();
		wp_enqueue_script('siteseo-onboarding', SITESEO_ASSETS_URL . '/js/onboarding.js', ['jquery'], SITESEO_VERSION, true);
		wp_enqueue_style('siteseo-onboarding' , SITESEO_ASSETS_URL . '/css/onboarding.css', [], SITESEO_VERSION);
		wp_add_inline_script('siteseo-onboarding', "let siteseo_onboarding = ".wp_json_encode([
			'nonce' => wp_create_nonce('siteseo_admin_nonce'),
			'ajax_url' => admin_url('admin-ajax.php'),
		]));
	}
	
	static function add_to_menu(){
		add_submenu_page('', __('SiteSEO Onboarding', 'siteseo'), 'Onboarding', 'manage_options', 'siteseo-onboarding', 'SiteSEO\Settings\Onboarding::wizard');
	}
	
	static function page(){
		self::enqueue_assets();
		
		ob_start();

	?><!DOCTYPE html>
<html <?php language_attributes();?>>
<?php echo'<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>'.esc_html__('SiteSEO OnBoarding', 'siteseo').'</title>';
wp_print_head_scripts();
wp_print_styles('siteseo-onboarding');
	
echo '</head>
<body>';
	self::wizard();
	if(function_exists('wp_print_media_templates')){
		wp_print_media_templates();
	}
	wp_print_footer_scripts();
	wp_print_scripts('siteseo-onboarding');
	echo '</body>
</html>';
		die();
	}
	
	static function wizard(){

		echo '<div id="siteseo-onboarding-root">
	<div class="siteseo-onboarding-nav-wrapper">
	<nav>
		<div class="content">
		<div class="header">
			<img src="'.esc_url(SITESEO_ASSETS_URL) .'/img/siteseo-white.png" height="40"/>
			<a href="'.esc_url(admin_url('?page=siteseo')).'" title="'.esc_attr__('Exit to SiteSEO Dashboard', 'siteseo').'"><svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#fff"><path d="M200-120q-33 0-56.5-23.5T120-200v-160h80v160h560v-560H200v160h-80v-160q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm220-160-56-58 102-102H120v-80h346L364-622l56-58 200 200-200 200Z"/></svg></a>
		</div>';

		$step_count = 1;
		echo '<div class="steps">';
		foreach(self::$steps as $step_slug => $step){
			echo '<div class="step">
				<div class="step-milestone" data-step="'.esc_attr($step_count).'" data-step-slug="'.esc_attr($step_slug).'"></div>
				<div class="step-info"><span>'.esc_html($step['title']).'</span><span class="description">'.esc_html($step['desc']).'</span></div>
			</div>';
			$step_count++;
		}
		echo '
		</div>
		</div>
		<div class="footer">A Softaculous Product</div>
	</nav>
	</div>
	<main>
		<div class="siteseo-onboarding-content">';
		self::welcome_page();
		
		foreach(self::$steps as $step){
			call_user_func($step['fn']);
			self::$current_step_no++; // increasing the step number after we have rendered the step page.
		}

		echo '</div>
	
	</main>
</div>';

	}

	static function welcome_page(){
		
		$is_active = empty(self::$current_step) ? 'siteseo-step-active' : '';
		
		echo '<div class="siteseo-step-page siteseo-step-is-welcome '.esc_attr($is_active).'" data-step="welcome">
			<h1>'.esc_html__('Welcome to the SiteSEO Setup Wizard', 'siteseo').'</h1>
			<p>'.esc_html__('This wizard will guide you through setting up SiteSEO and help you get started in no time.', 'siteseo').'</p>
			<button class="siteseo-btn primary" id="siteseo-onboarding-begin" style="margin-top:20px">'.esc_html__('Let\'s begin!', 'siteseo').'</button>
		</div>';
		
	}
	
	static function import_page(){
		$is_active = !empty(self::$current_step) && self::$current_step == 'import' ? 'siteseo-step-active' : '';

		echo '<div class="siteseo-step-page '.esc_attr($is_active).'" data-step="import">
		<span>Step '.esc_html(self::$current_step_no).' of '.count(self::$steps).'</span>
		<h1>'.esc_html__('Import data from your current SEO plugin', 'siteseo').'</h1>
		<p>'.esc_html__('SiteSEO has detected the presence of other SEO plugins. To ensure a smooth transition, please select the plugins you wish to import SEO data from', 'siteseo').'</p>
		<div class="siteseo-onboarding-import-plugins">';
			$importable_plugins = Util::importable_plugins();

			echo '<form><div class="siteseo-radio-input">';
			foreach(self::$import_options as $plugin){
				$id = strtolower(str_replace(' ', '-', $plugin));
				echo '<input type="radio" name="plugin_name" value="'.esc_attr($id).'" id="'.esc_attr($id).'"/>
				<label for="'.esc_attr($id).'">'.esc_html($importable_plugins[$plugin]).'</label>';
			}
			echo '</div>
			<div class="siteseo-onboarding-import-info">
				<details>
					<summary>'.esc_html__('What will be imported?', 'siteseo').'</summary>
					<ul>
						<li>'. esc_html__('Title tags', 'siteseo') .'</li>
						<li>'. esc_html__('Meta description', 'siteseo') .'</li>
						<li>'. esc_html__('Facebook Open Graph tags (title, description and image thumbnail)', 'siteseo') .'</li>
						<li>'. esc_html__('Twitter tags (title, description and image thumbnail)', 'siteseo') .'</li>
						<li>'. esc_html__('Meta Robots (noindex, nofollow...)', 'siteseo') .'</li>
						<li>'. esc_html__('Canonical URL', 'siteseo').'</li>
						<li>'. esc_html__('Focus / target keywords', 'siteseo') .'</li>
					</ul>
				</details>
				<button class="siteseo-btn primary" id="siteseo-do-import">Import</button>
				<p class="siteseo-onboarding-msg"></p>
			</div>
			</form>
			<div class="siteseo-onboarding-content-footer">
			<button class="siteseo-skip-step siteseo-btn secondary">'.esc_html__('Skip Step', 'siteseo').'</button><button class="siteseo-btn primary siteseo-skip-step">'.esc_html__('Next Step', 'siteseo').'</button>
			</div>
		</div>
		</div>';
	}
	
	static function site_page(){
		$title_options = get_option('siteseo_titles_option_name', []);
		$social_options = get_option('siteseo_social_option_name', []);

		$site_name = !empty($title_options['titles_home_site_title']) ? $title_options['titles_home_site_title'] : '%%sitetitle%%';
		$alt_site_name = !empty($title_options['titles_home_site_title_alt']) ? $title_options['titles_home_site_title_alt'] : '';
		$site_type = !empty($social_options['social_knowledge_type']) ? $social_options['social_knowledge_type'] : '';
		$org_name = !empty($social_options['social_knowledge_name']) ? $social_options['social_knowledge_name'] : '';
		$org_img = !empty($social_options['social_knowledge_img']) ? $social_options['social_knowledge_img'] : '';
		$fb_url	= !empty($social_options['social_accounts_facebook']) ? $social_options['social_accounts_facebook'] : '';
		$x_account = !empty($social_options['social_accounts_twitter']) ? $social_options['social_accounts_twitter'] : '';
		$additional_url = !empty($social_options['social_accounts_additional']) ? implode("\n", $social_options['social_accounts_additional']) : '';
		
		$is_active = !empty(self::$current_step) && self::$current_step == 'your-site' ? 'siteseo-step-active' : '';
		echo '<div class="siteseo-step-page '.esc_attr($is_active).'" data-step="your-site">
		<span>Step '.esc_html(self::$current_step_no).' of '.count(self::$steps).'</span>
		<h1>Your Site: '.esc_html(get_bloginfo('name')).'</h1>
		<p>'.esc_html__('We need some basic information about your site, so we can built up the knowledge graph', 'siteseo').'</p>
		<form>
			<div class="siteseo-input-block">
				<label>'.esc_html__('Website Name', 'siteseo').'</label>
				<input type="text" name="website_name" value="'.esc_attr($site_name).'"/>
				<p class="siteseo-input-description">'.esc_html__('Enter the name of your site as it should appear in search results, %%sitetitle%% is a dynamic variable for your site title', 'siteseo').'</p>
			</div>
			<div class="siteseo-input-block">
				<label>'.esc_html__('Altername sitename', 'siteseo').'</label>
				<input type="text" name="alternate_site_name" value="'.esc_attr($alt_site_name).'" placeholder="Alternate site name"/>
				<p class="siteseo-input-description">'.esc_html__('The website\'s alternate name, like a common acronym or shorter version, if applicable.', 'siteseo').'</p>
			</div>
			<div class="siteseo-input-block">
				<label>'.esc_html__('Is your site about an Organization or a Person?', 'siteseo').'</label>
				<select type="text" name="site_type">
					<option value="Person" '.selected($site_type, 'Person', false).'>Person</option>
					<option value="Organization" '.selected($site_type, 'Organization', false).'>Organization</option>
				</select>
			</div>
			<div class="siteseo-input-block">
				<label>'.esc_html__('Your/Organization name', 'siteseo').'</label>
				<input type="text" name="organization_name" placeholder="eg:. My Company Name" value="'.esc_attr($org_name).'"/>
			</div>
			<div class="siteseo-input-block">
				<label>'.esc_html__('Organization Logo', 'siteseo').'</label>
				<button id="siteseo-onboarding-img-holder">
				<img src="'.esc_url($org_img).'"/>
				<svg xmlns="http://www.w3.org/2000/svg" height="50px" viewBox="0 -960 960 960" width="50px" fill="#5f6368" style="'.(!empty($org_img) ? 'display:none;' : '').'"><path d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm40-80h480L570-480 450-320l-90-120-120 160Zm-40 80v-560 560Z"/></svg></button>
				<p class="siteseo-input-description">'.esc_html__('A square image is preferred, with a minimum size of 112x112 pixels.', 'siteseo').'</p>
				<input type="hidden" name="organization_logo" value="'.esc_url($org_img).'"/>
				<button class="siteseo-btn primary" id="siteseo-upload-org-img" style="align-self:flex-start">'.esc_html__('Select Image', 'siteseo').'</button>
			</div>
			<h4>Social Details</h4>
			<div class="siteseo-input-block">
				<label>'.esc_html__('Facebook page URL', 'siteseo').'</label>
				<input type="text" name="social_fb" value="'.esc_url($fb_url).'" placeholder="eg: https://facebook.com/my-page-url"/>
			</div>
			<div class="siteseo-input-block">
				<label>'.esc_html__('X Username', 'siteseo').'</label>
				<input type="text" name="social_x" value="'.esc_attr($x_account).'" placeholder="eg: @x_account"/>
			</div>
			<div class="siteseo-input-block">
				<label>'.esc_html__('Additional Accounts', 'siteseo').'</label>
				<textarea rows="3" name="social_additional" placeholder="eg:https://somesocial.com/my-page">'.esc_textarea($additional_url).'</textarea>
				<p class="siteseo-input-description">'.esc_html__('Enter 1 URL per line.', 'siteseo').'</p>
			</div>
			
			<div class="siteseo-onboarding-content-footer">
				<button class="siteseo-skip-step siteseo-btn secondary">'.esc_html__('Skip Step', 'siteseo').'</button><button class="siteseo-btn primary siteseo-save-n-continue">'.esc_html__('Save and Continue', 'siteseo').'<span class="siteseo-spinner"></span></button>
			</div>
		</form>
		</div>';
	}
	
	static function indexing_page(){
		$is_active = !empty(self::$current_step) && self::$current_step == 'indexing' ? 'siteseo-step-active' : '';
		$post_types = get_post_types(['public' =>  true, 'show_ui' => true], 'objects', 'and');
		unset($post_types['attachment']);
		
		$taxonomies = get_taxonomies(['public' =>  true, 'show_ui' => true], 'objects', 'and');

		echo '<div class="siteseo-step-page '.esc_attr($is_active).'" data-step="indexing">
		<span>Step '.esc_html(self::$current_step_no).' of '.count(self::$steps).'</span>
		<h1>Indexing</h1>
		<p>'.esc_html__('Let us know which parts of your website you’d like to be crawled.', 'siteseo').'</p>
		<form method="POST">
		<div class="siteseo-input-block">
			<label>'.esc_html__('Is your site under construction or live?', 'siteseo').'</label>
			<div class="siteseo-radiogroup">
				<label><input type="radio" name="site_status" value="underconstruction"/>Under Construction</label>
				<label><input type="radio" name="site_status" value="live" checked/>Live</label>
			</div>
			<p class="siteseo-input-description">'.esc_html__('If your site is under construction then Search Engines will be discouraged to crawl your site by adding noindex metatag attribute and sitemap will be disabled.', 'siteseo').'</p>
		</div>
		<div class="siteseo-live-site-options" style="margin-top:35px;">
			<p>'.esc_html__('Choose items to exclude from search results', 'siteseo').'</p>
			<div class="siteseo-input-block">
				<label>'.esc_html__('Post Types', 'siteseo').'</label>
				<div class="siteseo-radiogroup">';
				if(!empty($post_types)){
				foreach($post_types as $post){
					echo '<div><input type="checkbox" name="post_types" value="'.esc_attr($post->name).'" id="post_type_'.esc_attr($post->name).'"/>
					<label for="post_type_'.esc_attr($post->name).'">'.esc_html($post->label).'</label>
					</div>';
				}

				echo '<p class="siteseo-input-description">'.esc_html__('Discourage search engines from indexing these post types.', 'siteseo').'</p>';
			} else {
				echo '<p class="siteseo-input-description">'.esc_html__('No post type found.', 'siteseo').'</p>';
			}
			
			//TODO:: Will need to add options for Archive as well
			echo '</div>
			</div>
			<div class="siteseo-input-block">
				<label>'.esc_html__('Taxonomies', 'siteseo').'</label>
				<div class="siteseo-radiogroup">';
				if(!empty($taxonomies)){
					foreach($taxonomies as $taxonomy){
						echo '<div><input type="checkbox" name="taxonomies" value="'.esc_attr($taxonomy->name).'" id="taxonomy_'.esc_attr($taxonomy->name).'"/>
						<label for="taxonomy_'.esc_attr($taxonomy->name).'">'.esc_html($taxonomy->label).'</label>
						</div>';
					}

					echo '<p class="siteseo-input-description">'.esc_html__('Discourage search engines from indexing these taxonomies.', 'siteseo').'</p>
					<p class="siteseo-input-description">'.esc_html__('Note: We strongly recommend disabling the indexing of tags to avoid potential duplicate content issues that could negatively impact your site\'s SEO.', 'siteseo').'</p>';
				} else {
					echo '<p class="siteseo-input-description">'.esc_html__('No taxonomy found.', 'siteseo').'</p>';
				}
			echo '</div>
			</div>
		</div>
		<div class="siteseo-onboarding-content-footer">
			<button class="siteseo-skip-step siteseo-btn secondary">'.esc_html__('Skip Step', 'siteseo').'</button><button class="siteseo-btn primary siteseo-save-n-continue">'.esc_html__('Save and Continue', 'siteseo').'<span class="siteseo-spinner"></span></button>
		</div>
		</form>
		</div>';
	}
	
	static function advanced_page(){
		$is_active = !empty(self::$current_step) && self::$current_step == 'advanced' ? 'siteseo-step-active' : '';
		echo '<div class="siteseo-step-page '.esc_attr($is_active).'" data-step="advanced">
		<span>Step '.esc_html(self::$current_step_no).' of '.count(self::$steps).'</span>
		<h1>Advanced Options</h1>
		<p>'.esc_html__('We\'re nearly there—just a few final optimizations left!', 'siteseo').'</p>
		<form method="POST">
			<div class="siteseo-input-block">
				<div class="siteseo-radiogroup">
					<label><input type="checkbox" name="universal_metabox" checked/>Enable Universal Metabox</label>
				</div>
				<p class="siteseo-input-description">'.esc_html__('Universal metabox makes SiteSEO on page content SEO helper compatible with every Page Builder, so if you are not using Gutenberg then this is a must.', 'siteseo').'</p>
			</div>
			<div class="siteseo-input-block">
				<div class="siteseo-radiogroup">
					<label><input type="checkbox" name="author_noindex"/>'.esc_html__('Don\'t let search engines index author archive pages', 'siteseo').'</label>
				</div>
				<p class="siteseo-input-description">'.esc_html__('Recommended: Enable this option if you are the sole author of the site to prevent duplicate content on author archive pages.', 'siteseo').'</p>
			</div>
			<div class="siteseo-input-block">
				<div class="siteseo-radiogroup">
					<label><input type="checkbox" name="redirect_attachment"/>'.esc_html__('Redirect attachment pages to the file itself', 'siteseo').'</label>
				</div>
				<p class="siteseo-input-description">'.esc_html__('By default SiteSEO redirects to the parent post.', 'siteseo').'</p>
			</div>
			<div class="siteseo-input-block">
				<div class="siteseo-radiogroup">
					<label><input type="checkbox" name="category_url"/>'.esc_html__('Remove /category/ in your permalinks', 'siteseo').'</label>
				</div>
				<p class="siteseo-input-description">'.esc_html__('This reduces the length of the URL.', 'siteseo').'</p>
			</div>';

			do_action('siteseo_gsc_onboarding');

			echo '<div class="siteseo-onboarding-content-footer">
				<button class="siteseo-skip-step siteseo-btn secondary">'.esc_html__('Skip Step', 'siteseo').'</button><button class="siteseo-btn primary siteseo-save-n-continue">'.esc_html__('Save and Continue', 'siteseo').'<span class="siteseo-spinner"></span></button>
			</div>
		</form>
		</div>';
	}
	
	static function ready_page(){
		$is_active = !empty(self::$current_step) && self::$current_step == 'ready' ? 'siteseo-step-active' : '';
		echo '<div class="siteseo-step-page '.esc_attr($is_active).'" data-step="ready">
		<span>Step '.esc_html(self::$current_step_no).' of '.count(self::$steps).'</span>
		<h1>Done! 🎉</h1>
		<p>'.esc_html__('We are done with the setup, now you can start making content and submit the Sitemap to the search engines.', 'siteseo').'</p>
		<h4>'.esc_html__('What Next?', 'siteseo').'</h4>
		<ol style="margin:0">
			<li><a href="?page=siteseo-sitemaps" target="_blank">'.esc_html__('Configure your Sitemap', 'siteseo').'</a></li>
			<li>'.esc_html__('Submit yours sitemap to search engines', 'siteseo').'</li>
		</ol>
		
		<h4>'.esc_html__('You can also, subscribe to our newletter', 'siteseo').'</h4>
		'.esc_html__('You will get', 'siteseo').'
		<ul style="list-style-type:none">
			<li><span class="dashicons dashicons-minus"></span> '.esc_html__('Alerted about Google Algorithm changes.', 'siteseo').'</li>
			<li><span class="dashicons dashicons-minus"></span> '.esc_html__('Updates about our products.', 'siteseo').'</li>
			<li><span class="dashicons dashicons-minus"></span> '.esc_html__('Improve SEO of your website with our resourceful blogs.', 'siteseo').'</li>
		</ul>
		<a class="siteseo-btn secondary" href="https://siteseo.io/subscribe/" style="align-self:flex-start;" target="_blank">'.esc_html__('Subscribe', 'siteseo').'</a>
		<div class="siteseo-onboarding-content-footer">
			<a href="'.esc_url(admin_url()).'"class="siteseo-btn primary">Go to Dashboard</a>
			<a href="?page=siteseo"class="siteseo-btn primary">Review Settings</a>
			<a href="https://siteseo.io/docs/" class="siteseo-btn primary" target="_blank">Knowledge Base</a>
		</div>
		</div>';
	}
}

PKv�f\��ֽ8�8settings/instant.phpnu�[���<?php
/*
* SITESEO
* https://siteseo.io
* (c) SiteSEO Team
*/

namespace SiteSEO\Settings;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class Instant{

	static function menu(){
		global $siteseo;

		$indexing_toggle = isset($siteseo->setting_enabled['toggle-instant-indexing']) ? $siteseo->setting_enabled['toggle-instant-indexing'] : '';
		$nonce = wp_create_nonce('siteseo_toggle_nonce');

		$current_tab = isset($_GET['tab']) ? sanitize_key($_GET['tab']) : 'tab_siteseo_general';

		$instant_subtabs = [
			'tab_siteseo_general' => esc_html__('General', 'siteseo'),
			'tab_siteseo_settings' => esc_html__('Settings', 'siteseo'),
			'tab_siteseo_history' => esc_html__('History', 'siteseo'),
		];

		echo '<div id="siteseo-root">';
		Util::admin_header();

		echo '<form method="post" id="siteseo-form" class="siteseo-option" name="siteseo-flush">';
		wp_nonce_field('siteseo_instant_indexing');

		Util::render_toggle('Instant Indexing - SiteSEO', 'indexing_toggle', $indexing_toggle, $nonce);

		echo '<div id="siteseo-tabs" class="wrap">
		<div class="siteseo-nav-tab-wrapper">';

		foreach($instant_subtabs as $tab_key => $tab_caption){
			$active_class = ($current_tab === $tab_key) ? ' siteseo-nav-tab-active' : '';
			echo '<a id="'.esc_attr($tab_key).'-tab" class="siteseo-nav-tab'.esc_attr($active_class).'" data-tab="'.esc_attr($tab_key).'">'.esc_html($tab_caption).'</a>';
		}

		echo '</div>
		<div class"tab-content-wrapper">
		<div class="siteseo-tab'.($current_tab == 'tab_siteseo_general' ? ' active' : '').'" id="tab_siteseo_general" style="display: none;">';
		self::general();
		echo '</div>     
		<div class="siteseo-tab'.($current_tab == 'tab_siteseo_settings' ? ' active' : '').'" id="tab_siteseo_settings" style="display: none;">';
		self::settings();
		echo '</div>
		<div class="siteseo-tab'.($current_tab == 'tab_siteseo_history' ? 'active' : '').'" id="tab_siteseo_history" style="display : none;">';
		self::history();
		echo '</div>
		</div>';
		Util::submit_btn();
		echo '</form></div>';

	}

	static function general(){
		global $siteseo;

		if(!empty($_POST['submit'])){
			self::save_settings();
		}

		$options = get_option('siteseo_instant_indexing_option_name');
		//$options = $siteseo->instant_settings;

		$option_engines = !empty($options['engines']) ? $options['engines'] : '';
		$option_search_engine_google = !empty($option_engines['google']) ? $option_engines['google'] : '';
		$option_search_engine_bing = !empty($option_engines['bing']) ? $option_engines['bing'] : '';
		$option_action = !empty($options['instant_indexing_google_action']) ? $options['instant_indexing_google_action'] : '';
		$option_manual_batch = !empty($options['instant_indexing_manual_batch']) ? $options['instant_indexing_manual_batch'] : '';

		echo '<h3 class="siteseo-tabs">'.esc_html__('Instant Indexing','siteseo').'</h3>
		<div class="siteseo_wrap_label">
			<p class="description">'.esc_html__('Utilize the Indexing API to inform Google and Bing about updates or removals of pages from their indexes. The process may take a few minutes. You can submit URLs in batches of up to 100 (maximum 200 requests per day for Google).','siteseo').'</p>
		</div>

		<div class="siteseo-notice">
			<span class="dashicons dashicons-info"></span>
		    <div><h3>'.esc_html__('How does this work?', 'siteseo').'</h3>
			<ol>
			<li>'.
			/* translators: placeholders are just <strong> tag */ 
			wp_kses_post(sprintf(__('Setup your Google / Bing API keys from the %1$s Settings %2$s tab', 'siteseo'), '<strong>', '</strong>')).'</li>
			<li>'.
			/* translators: placeholders are just <strong> tag */ 
			wp_kses_post(sprintf(__('%1$s Enter the URLs %2$s you want to index in the field below.', 'siteseo'), '<strong>', '</strong>')).'</li>
				<li><strong>'.wp_kses_post(__('Save changes', 'siteseo')).'</strong></li>
			<li>'.
			/* translators: placeholders are just <strong> tag */ 
			wp_kses_post(sprintf(__('Click %1$s Submit URLs to Google & Bing  %2$s', 'siteseo'), '<strong>', '</strong>')).'</li>
			</ol>
			</div>
		</div>

		<table class="form-table">
		    <tbody>

		    	<tr>
				<th scope="row">'.esc_html__('select search engines','siteseo').'</th>
				<td> 
					<div class="siteseo_wrap_label"><label for="siteseo_search_engines">
						<input id="siteseo_search_engines" name="siteseo_options[search_engine_google]" type="checkbox"' . (!empty($option_search_engine_google) ? 'checked="yes"' : '') . ' value="1"/>'.esc_html__('Google', 'siteseo') . 
				            '</label></div>
					    <label for="siteseo_search_engines">
					    	<input id="siteseo_search_engines" name="siteseo_options[search_engine_bing]" type="checkbox"' . (!empty($option_search_engine_bing) ? 'checked="yes"' : '') . ' value="1"/>'.esc_html__('Bing', 'siteseo') . 
					    '</label>
				</td>
			</tr>

			<tr>
				<th scope="row">'.esc_html__('Which action to run for Google?', 'siteseo') .'</th>
				<td>
					<div class="siteseo_wrap_label">
						<label>
							<input id="siteseo_update_urls" name="siteseo_options[instant_indexing_actions]" type="radio" value="update_urls" '.checked($option_action, 'update_urls', false).'/>
							'.esc_html__('Update URLs', 'siteseo').'
						</label>
					</div>
					<div class="siteseo_wrap_label">
						<label>
							<input id="siteseo_remove_urls" name="siteseo_options[instant_indexing_actions]" type="radio" value="remove_urls" '.checked($option_action, 'remove_urls', false).'/>
							'.esc_html__('Remove URLs (the URL must return a 404 or 410 status code, or the page must include the <meta name="robots" content="noindex" /> meta tag).', 'siteseo').'
						</label>
					</div>
				</td>
			</tr>

			<tr>
				<th scope="row">'.esc_html__('Submit URLs for indexing','siteseo').'</th>
				<td>
					<textarea rows="20" name="siteseo_options[instant_indexing_batch]" placeholder="'.esc_html__('Submit one URL per line for search engine submission (maximum of 100 URLs).','siteseo').'">'.esc_attr($option_manual_batch).'</textarea>
				</td>
			</tr>

			<tr>
				<th scope="row"></th>
				<td>
					<button id="siteseo-submit-urls-button" class="btn btnSecondary">'.esc_html__('Submits URLs to Google & Bing', 'siteseo').'</button>
				</td><div style="position:absolute;margin-top:52.5%;margin-left:38%;" class="spinner"></div>
			</tr>
				
			<tr>
				<th scope="row"></th>
				<td>
					<div id="url-submitter-response"></div>
				</td>
			</tr>

		</tbody>
		</table><input type="hidden" name="siteseo_options[general]" value="1"/>';
	}

	static function settings(){
		global $siteseo,$docs;

		if(!empty($_POST['submit'])){
			self::save_settings();
		}

		$docs['instant_indexing']['api'] = 'https://console.cloud.google.com/apis/library/indexing.googleapis.com?hl=en';
		$docs['instant_indexing']['google'] = 'https://siteseo.io/docs/api-cli-dev/use-google-instant-indexing-api-with-siteseo-pro/';

		//$options = $siteseo->instant_settings;
		$options = get_option('siteseo_instant_indexing_option_name');

		$option_google_api_key = !empty($options['instant_indexing_google_api_key']) ? $options['instant_indexing_google_api_key'] : '';
		$option_bing_api_key = !empty($options['instant_indexing_bing_api_key']) ? $options['instant_indexing_bing_api_key'] : '';
		$option_auto_url_submission = !empty($options['instant_indexing_automate_submission']) ? $options['instant_indexing_automate_submission'] : '';

		echo '<h3 class="siteseo-tabs">'.esc_html__('Settings','siteseo').'</h3>
		<table class="form-table">
		<tbody>
		<tr>
		    <th scope="row">'.esc_html__('Instant Indexing Google API Key','siteseo').'</th>
		    <td>    
		        <textarea name="siteseo_options[google_api_key]" rows="12" placeholder="'.esc_html__('Paste your Google Json key file here','siteseo').'">'.esc_html($option_google_api_key).'</textarea>
		    </td>
		</tr>

		<tr>
			<th scope="row">'.esc_html__('Instant Indexing Bing API Key', 'siteseo').'</th>
			<td>
				<input type="text" id="bing-api-key" name="siteseo_options[bing_api_key]" placeholder="'.esc_html__('Enter your Bing Instant Indexing API', 'siteseo').'" value="'.esc_attr($option_bing_api_key).'">
				<button type="button" id="siteseo-generate-api-key-btn" class="btn btnSecondary">'.esc_html__('Generate key', 'siteseo').'</button>
				<p class="description">'.esc_html__('The Bing Indexing API key is generated automatically. Click Generate Key if you need to recreate it or if it missing.', 'siteseo') .'</p>
				<p class="description">'.esc_html__('A key should look like this: YjI4MGQxZmU0NWM1NGY2ZGIxMDk5M2VlYTAxMTUyODI=', 'siteseo') .'</p>
			</td>
		</tr>

		<tr>
		    <th scope="row">'.esc_html__('Automate URL Submission','siteseo').'</th>
		    <td> 
		        <label for="siteseo_search_engines">
		            <input id="siteseo_search_engines" name="siteseo_options[auto_submission]" type="checkbox"'.(!empty($option_auto_url_submission) ? 'checked="yes"' : '').' value="1"/>'.esc_html__('Activate automatic URL submission for the IndexNow API.', 'siteseo') . 
		        '</label>
		        <div class="siteseo_wrap_label">
		            <p class="description">'.esc_html__('Inform search engines via the IndexNow protocol whenever a post is created, updated, or removed.','siteseo').'</p>
		        </div>
		    </td>
		</tr>

		</tbody>
		</table><input type="hidden" name="siteseo_options[setting_tab]" value="1"/>';
	}
	
	static function history(){
		global $siteseo;
		
		$options = get_option('siteseo_instant_indexing_option_name');
		$indexing_history = !empty($options['indexing_history']) ? $options['indexing_history'] : '';
		
		echo'<h3 class="siteseo-tabs">'.esc_html__('History', 'siteseo').'</h3>
		<div class="siteseo_wrap_label">
			<p class="description">'.esc_html__('Most Recent 10 Indexing API Requests.', 'siteseo').'</p>
		</div>
		
		<table class="wp-list-table widefat fixed striped siteseo-history-table">
			<thead><tr>
				<th>'.esc_html__('Time & Date', 'siteseo').'</th>
				<th>'.esc_html__('URLs', 'siteseo').'</th>
				<th>'.esc_html__('Google Response', 'siteseo').'</th>
				<th>'.esc_html__('Bing Response', 'siteseo').'</th>
			</tr></thead>
			<tbody>';
			
			if(empty($indexing_history)){
				echo'<tr>
					<td>'.esc_html__('No submissions yet.', 'siteseo').'</td>
				</tr></tbody></table><br/><br/>';
				
				return;
			}
			
			foreach($indexing_history as $history){
				echo'<tr>
					<td>'.esc_html(date_i18n('Y-m-d H:i:s', $history['time'])).'</td>
					<td>'.esc_html(implode(', ', $history['urls'])).'</td>
					<td>'.(isset($history['google_status_code']) ? esc_html($history['google_status_code']) : 'N/A') . (isset($history['source']) && $history['source'] === 'auto' ? esc_html(' ( Auto )') : '') .'</td>
					<td>'.(isset($history['bing_status_code']) ? esc_html($history['bing_status_code']) : 'N/A') . (isset($history['source']) && $history['source'] === 'auto' ? esc_html(' ( Auto )') : '') . 
					'</td>

				</tr>';
			}
			
			echo'</tr>
			</tbody></table><br/>
			
			<tr>
				<td>
					<button id="siteseo-clear-history" class="btn btnSecondary">'.esc_html__('Clean History', 'siteseo').'</button>
				</td>
			</tr><br/><br/>
			
			<a class="siteseo-show-details">'.esc_html__('Response code guide', 'siteseo').'<span class="dash-icon dashicons dashicons-arrow-down-alt2"></span></a>
			<div class="siteseo-response-code-table">
			<table class="wp-list-table widefat fixed striped siteseo-history-table">
				<thead>
					<tr>
					<th>'.esc_html__('Response Code', 'siteseo').'</th>
					<th>'.esc_html__('Response Message', 'siteseo').'</th>
					<th>'.esc_html__('Reason', 'siteseo').'</th>
					</tr>
				</thead>
				
				<tr>
					<td>'.esc_html__('200', 'siteseo').'</td>
					<td>'.esc_html__('Ok', 'siteseo').'</td>
					<td>'.esc_html__('URLs submitted successfully.', 'siteseo').'</td>
				</tr>
				
				<tr>
					<td>'.esc_html__('202', 'siteseo').'</td>
					<td>'.esc_html__('Accepted', 'siteseo').'</td>
					<td>'.esc_html__('URL received. IndexNow key validation pending.', 'siteseo').'</td>
				</tr>
				
				<tr>
					<td>'.esc_html__('400', 'siteseo').'</td>
					<td>'.esc_html__('Bad Request', 'siteseo').'</td>
					<td>'.esc_html__('Request Invalid format.', 'siteseo').'</td>
				</tr>
				
				<tr>
					<td>'.esc_html__('403', 'siteseo').'</td>
					<td>'.esc_html__('Forbidden', 'siteseo').'</td>
					<td>'.esc_html__('Key not valid.', 'siteseo').'</td>
				</tr>
				
				<tr>
					<td>'.esc_html__('422', 'siteseo').'</td>
					<td>'.esc_html__('Unprocessable Entity', 'siteseo').'</td>
					<td>'.esc_html__('URLs don\'t belong to the host.', 'siteseo').'</td>
				</tr>
				
				<tr>
					<td>'.esc_html__('429', 'siteseo').'</td>
					<td>'.esc_html__('Too Many Requests', 'siteseo').'</td>
					<td>'.esc_html__('Too Many Requests: Potential Spam.', 'siteseo').'</td>
				</tr>
				<tbody>
			</table></div><br/><br/>';
		
	}

	static function save_settings(){
		global $siteseo;

		check_admin_referer('siteseo_instant_indexing');

		if(!siteseo_user_can('manage_instant_indexing')|| !is_admin()){
			return;
		}

		$options = $siteseo->instant_settings;
		
		if(!is_array($options)){
			$options = [];
		}

		if(empty($_POST['siteseo_options'])){
			return;
		}

		if(isset($_POST['siteseo_options']['general'])){
			// general tab
			$options['engines']['bing'] = isset($_POST['siteseo_options']['search_engine_bing']);
			$options['engines']['google'] = isset($_POST['siteseo_options']['search_engine_google']);
			$options['instant_indexing_google_action'] = isset($_POST['siteseo_options']['instant_indexing_actions']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['instant_indexing_actions'])) : 'URL_UPDATED';
			$options['instant_indexing_manual_batch'] = isset($_POST['siteseo_options']['instant_indexing_batch']) ? sanitize_textarea_field(wp_unslash($_POST['siteseo_options']['instant_indexing_batch'])) : '';
		}

		if(isset($_POST['siteseo_options']['setting_tab'])){
			// setting tab
			$options['instant_indexing_google_api_key'] = isset($_POST['siteseo_options']['google_api_key']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['google_api_key'])) : '';
			$options['instant_indexing_bing_api_key'] = isset($_POST['siteseo_options']['bing_api_key']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['bing_api_key'])) : '';
			$options['instant_indexing_automate_submission'] = isset($_POST['siteseo_options']['auto_submission']);
		}

		update_option('siteseo_instant_indexing_option_name', $options);
	}
}
PKv�f\��̹�N�Nsettings/sitemap.phpnu�[���<?php
/*
* SITESEO
* https://siteseo.io
* (c) SiteSEO Team
*/

namespace SiteSEO\Settings;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class Sitemap{

    static function menu(){
		global $siteseo;

		$sitemap_toggle = isset($siteseo->setting_enabled['toggle-xml-sitemap']) ? $siteseo->setting_enabled['toggle-xml-sitemap'] : '';
		$nonce = wp_create_nonce('siteseo_toggle_nonce');

		$current_tab = isset($_GET['tab']) ? sanitize_key($_GET['tab']) : 'tab_sitemap_general'; // Default tab

		$titles_meta_subtabs = [
			'tab_sitemap_general' => esc_html__('Home', 'siteseo'),
			'tab_sitemap_post_types' => esc_html__('Post types', 'siteseo'),
			'tab_sitemap_taxonomy ' => esc_html__('Taxonomy', 'siteseo'),
			'tab_sitmap_html' => esc_html__('HTML Sitemap', 'siteseo')
		];
		
		echo '<div id="siteseo-root">';
		Util::admin_header();

		echo '<form method="post" id="siteseo-form" class="siteseo-option" name="siteseo-flush">';

		wp_nonce_field('siteseo_sitemap_settings');

		Util::render_toggle('Sitemaps - SiteSEO', 'sitemap_toggle', $sitemap_toggle, $nonce);

		echo '<div id="siteseo-tabs" class="wrap">
		<div class="siteseo-nav-tab-wrapper">';

		foreach($titles_meta_subtabs as $tab_key => $tab_caption){
			$active_class = ($current_tab === $tab_key) ? ' siteseo-nav-tab-active' : '';
			echo '<a id="' . esc_attr($tab_key) . '-tab" class="siteseo-nav-tab' . esc_attr($active_class) . '" data-tab="' . esc_attr($tab_key) . '">' . esc_html($tab_caption) . '</a>';
		}

		echo '</div>
		<div class="tab-content-wrapper">
		<div class="siteseo-tab' .($current_tab == 'tab_sitemap_general' ? ' active' : '').'" id="tab_sitemap_general" style="display: none;">';
		self::general_sitemaps();
		echo '</div>  
		<div class="siteseo-tab' .($current_tab == 'tab_sitemap_post_types' ? ' active' : '').'" id="tab_sitemap_post_types" style="display: none;">';
		self::post_types_sitemaps();
		echo '</div>
		<div class="siteseo-tab' .($current_tab == 'tab_sitemap_taxonomy' ? ' active' : '').'" id="tab_sitemap_taxonomy" style="display: none;">';
		self::taxonomy_sitemap();
		echo '</div>  
		<div class="siteseo-tab' .($current_tab == 'tab_sitmap_html' ? ' active' : '').'" id="tab_sitmap_html" style="display: none;">';
		self::html_sitemap();
		echo '</div>
		</div>';

		Util::submit_btn();
		echo '</form></div>';
	}

    static function general_sitemaps(){
        global $siteseo;

        if(!empty($_POST['submit'])){
            self::save_settings();
        }

		//$options = $siteseo->sitemap_settings;
		$options = get_option('siteseo_xml_sitemap_option_name', []);

		$xml_sitemap = !empty($options['xml_sitemap_general_enable']) ? $options['xml_sitemap_general_enable'] : '';
		$img_sitemap = !empty($options['xml_sitemap_img_enable']) ? $options['xml_sitemap_img_enable'] : '';
		$author_sitemap = !empty($options['xml_sitemap_author_enable']) ? $options['xml_sitemap_author_enable'] : '';
		$html_sitemap = !empty($options['xml_sitemap_html_enable']) ? $options['xml_sitemap_html_enable'] : '';

		echo '<h3 class="siteseo-tabs">'.esc_html__('General','siteseo').'</h3>
		<p>'.esc_html__('Sitemaps are pages which help search engine, know your site better and makes it easier for them to index the pages.','siteseo').'</p>
		<p>'.esc_html__('Not having a sitemap does not mean search engines won\'t be able to crawl your website, but sitemaps make it easier for them to discover all the URLs which are needed to be indexed.','siteseo').'</p>
		 <div class="siteseo-styles pre"><pre><span class="dashicons dashicons-external"></span><a href="'.esc_url(get_option('home')).'/sitemaps.xml" target="_blank">' . esc_url(get_option('home')) . '/sitemaps.xml</a></pre></div>
	        <div class="siteseo-notice">
			<span id="siteseo-dash-icon" class="dashicons dashicons-info"></span>
	        	<p>'.
			/* translators: placeholders are just <strong> tag */ 
			wp_kses_post(sprintf(__('To view your sitemap, %1$s enable permalinks %2$s (other than the default one) and save the settings to flush them.', 'siteseo'), '<strong>', '</strong>')).'</p>
	        </div>

	        <table class="form-table">
	            <tbody>
	                <tr>
	                    <th scope="row">'.esc_html__('Enable XML Sitemap','siteseo').'</th>
	                    <td>
	                     <label><input id="siteseo_enable_sitemap" name="siteseo_options[enable_xml_sitemap]" type="checkbox" '.(!empty($xml_sitemap) ? 'checked' : '').' value="1"/>'. esc_html__('Enable XML Sitemap', 'siteseo').'</label>
	                    </td>
	                </tr>

	                <tr>
	                    <th scope="row">'.esc_html__('Enable Image Sitemap','siteseo').'</th>
	                    <td>
	                        <label><input id="siteseo_image_sitemap" name="siteseo_options[enable_img_sitemap]" type="checkbox" '.(!empty($img_sitemap) ? 'checked' : '').' value="1"/>'. esc_html__('Enable Image Sitemap for standard images, image galleries, featured images, and WooCommerce / Kkart product images.)', 'siteseo').'</label>
	                        <p class="description">'.esc_html__('Images in XML sitemaps are only visible from the source code.', 'siteseo').'</p>
	                    </td>
	                </tr>

	                <tr>
	                    <th scope="row">'.esc_html__('Enable Author Sitemap','siteseo').'</th>
	                    <td>
	                        <label><input id="siteseo_author_sitemap" name="siteseo_options[enable_author_sitemap]" type="checkbox" '.(!empty($author_sitemap) ? 'checked' : '').' value="1"/>' . esc_html__('Enable Author Sitemap', 'siteseo').'</label>
	                        <p class="description">'.esc_html__('Ensure that you enable the author archive from SEO, under the Titles & Metas section, in the Archives tab.','siteseo').'</p>
	                    </td>
	                </tr> 

	                  <tr>
	                    <th scope="row">'.esc_html__('Enable HTML Sitemap','siteseo').'</th>
	                    <td>
	                        <label><input id="siteseo_html_sitemap" name="siteseo_options[enable_html_sitemap]" type="checkbox" '.(!empty($html_sitemap) ? 'checked' : ''). ' value="1"/>' . esc_html__('Enable HTML Sitemap', 'siteseo').'</label>
	                    </td>
	                </tr> 
				</tbody>
	        </table>
		<input type="hidden" name="siteseo_options[general_sitemaps] value="1"/>';

    }

	static function post_types_sitemaps(){
		global $siteseo;

		if(!empty($_POST['submit'])){
			self::save_settings();
		}

		//$options = $siteseo->sitemap_settings;
		$options = get_option('siteseo_xml_sitemap_option_name', []);
		
		$option_sitemap_posts = !empty($options['xml_sitemap_post_types_list']['post']['include']) ? $options['xml_sitemap_post_types_list']['post']['include'] : '';
		$option_sitemap_pages = !empty($options['xml_sitemap_post_types_list']['page']['include']) ? $options['xml_sitemap_post_types_list']['page']['include'] : '';
		$option_sitemap_media = !empty($options['xml_sitemap_post_types_list']['media']['include']) ? $options['xml_sitemap_post_types_list']['media']['include'] : '';

		$post_types = siteseo_post_types();

		echo '<h3 class="siteseo-tabs">'.esc_html__('Post Types', 'siteseo').'</h3>
			<p>'.esc_html__('Select Post Types to Include or Exclude', 'siteseo').'</p>
				<table class="form-table">
					<tbody>';

						foreach($post_types as $post_type){
							$post_type_name = $post_type->name;
							$post_type_label = $post_type->labels->singular_name;
							$option_sitemap_custom = !empty($options['xml_sitemap_post_types_list'][$post_type_name]['include']) ? 'checked="yes"' : '';

							echo '<tr>
									<th></th>
									<td>
										<label for="sitemap_post_types_'.esc_attr($post_type_name).'">
											<h4>'.esc_html($post_type_label).' <em>(['.esc_html($post_type_name).'])</em></h4>
											<input id="sitemap_post_types_'.esc_attr($post_type_name).'" name="siteseo_options[xml_sitemap_post_types_list]['.esc_attr($post_type_name).'][include]" type="checkbox" '.esc_attr($option_sitemap_custom).' value="1"/>
											'.esc_html__('Include', 'siteseo').'
										</label>
									</td>
								</tr>';
						}

					echo '</tbody>
				</table>
				<input type="hidden" name= siteseo_options[post_types_tab] value="1"/>';
	}

    static function taxonomy_sitemap(){
        global $siteseo;
		
        if(!empty($_POST['submit'])){
            self::save_settings();
        }
		
		//$options = $siteseo->sitemap_settings;
		$get_taxonomies = get_taxonomies(['public' => true, 'show_ui' => true], 'objects');
		$check_taxonomies = apply_filters('siteseo_sitemaps_tax', $get_taxonomies);
	
		$options = get_option('siteseo_xml_sitemap_option_name');
		$option_category = isset($options['xml_sitemap_taxonomies_list']['category']['include']) ? $options['xml_sitemap_taxonomies_list']['category']['include'] : '';
		$option_post_tags = isset($options['xml_sitemap_taxonomies_list']['post_tag']['include']) ? $options['xml_sitemap_taxonomies_list']['post_tag']['include'] : '';
		
		$get_taxonomies = get_taxonomies();
		$check_taxomies = apply_filters('siteseo_sitemaps_tax', $get_taxonomies);
		
		$excluded_taxonomies = ['post_format', 'category', 'post_tag'];

        echo '<h3 class="siteseo-tabs">'.esc_html__('Taxonomies', 'siteseo').'</h3>
			<p>'.esc_html__('Select Taxonomies to Include or Exclude', 'siteseo').'</p>
            <table class="form-table">
                <tr scope="row">
                    <th>'.esc_html__('Select to INCLUDE Taxonomies', 'siteseo').'</th>
					
					<td><br/><br/>
						<label for="sitemap_post_types_pages">
							<h4>'.esc_html__('Categories ', 'siteseo').' <em>[categories]</em></h4>
							<input id="sitemap_post_types_pages" name="siteseo_options[xml_sitemap_taxonomies_list][category][include]" type="checkbox" '.(!empty($option_category) ? 'checked' : 'value="1"').'/>
							'.esc_html__('Include', 'siteseo').'
						</label>	
					</td>
                </tr>
            
				<tr>
					<th></th>
					<td>
						<label for="sitemap_post_types_pages">
							<h4>'.esc_html__('Tags', 'siteseo').' <em>[post_tag]</em></h4>
							<input id="sitemap_post_types_pages" name="siteseo_options[xml_sitemap_taxonomies_list][post_tag][include]" type="checkbox" '.(!empty($option_post_tags) ? 'checked' : 'value="1"').'/>
							'.esc_html__('Include', 'siteseo').'
						</label>
					</td>
				</tr>';
				
				foreach($check_taxonomies as $taxonomy_name => $taxonomy_obj){

					if(in_array($taxonomy_name, $excluded_taxonomies)){
						continue;
					}

					//check selected
					$is_included = !empty($options['xml_sitemap_taxonomies_list'][$taxonomy_name]['include']);

					// Generate a row for the taxonomy
					echo '<tr scope="row">
							<th></th>
							<td>
								<label for="sitemap_taxonomy_'.esc_attr($taxonomy_name).'">
									<h4>'.esc_html($taxonomy_obj->labels->name).' <em>[' . esc_html($taxonomy_name).']</em></h4>
									<input id="sitemap_taxonomy_' . esc_attr($taxonomy_name) . '" 
										   name="siteseo_options[xml_sitemap_taxonomies_list][' . esc_attr($taxonomy_name).'][include]" 
										   type="checkbox" '.($is_included ? 'checked' : '').' value="1" />
									' . esc_html__('Include', 'siteseo') . '
								</label>
							</td>
						  </tr>';
				}

            echo '</table><input type="hidden" name="siteseo_options[taxonomy_sitemap_tabs]" value="1">';

    }

    static function html_sitemap(){

        if(!empty($_POST['submit'])){
            self::save_settings();
        }

	//$options = $siteseo->$sitemap_settings;
	$options = get_option('siteseo_xml_sitemap_option_name', []);
		
	$include_pages = !empty($options['xml_sitemap_html_mapping']) ? $options['xml_sitemap_html_mapping'] : '';
	$exclude_page = !empty($options['xml_sitemap_html_exclude']) ? $options['xml_sitemap_html_exclude'] : '';
	$order = !empty($options['xml_sitemap_html_order']) ? $options['xml_sitemap_html_order'] : '';
	$order_by = !empty($options['xml_sitemap_html_orderby']) ? $options['xml_sitemap_html_orderby'] : '';
	$disable_date = !empty($options['xml_sitemap_html_date']) ? $options['xml_sitemap_html_date'] : '';
	$remove_archive = !empty($options['xml_sitemap_html_archive_links']) ? $options['xml_sitemap_html_archive_links'] : '';
		

        echo '<h3 class="siteseo-tabs">'.esc_html__('HTML Sitemap', 'siteseo').'</h3>
        <p>'.esc_html__('Generate an HTML sitemap for your visitors to improve your SEO.','siteseo').'</p>
        <p>'.esc_html__('Restricted to 1,000 posts per post type. You can change the order and sorting settings below.','siteseo').'</p>

        <div class="siteseo-notice"><span class="dashicons dashicons-info"></span>
        <div>
            <h3>'.esc_html__('How to make use of the HTML Sitemap?', 'siteseo').'</h3>
            <h4>'.esc_html__('Block Editor', 'siteseo').'</h4>
		<p>'.
		/* translators: placeholders are just <strong> tag */ 
		wp_kses_post(sprintf(__('Insert the HTML sitemap block via the %1$s Block Editor %2$s.', 'siteseo'), '<strong>', '</strong>')).'</p>
            <h4>'.esc_html__('Shortcode', 'siteseo').'</h4>
            <p>'.esc_html__('You can also insert this shortcode into your content (post, page, custom post type, etc.):', 'siteseo').'</p>
            <div class="siteseo-styles pre"><pre>'.esc_attr('[siteseo_html_sitemap]').'</div></pre>
            <p>'.esc_html__('To include specific custom post types, use the CPT attribute:', 'siteseo') .'</p>
            <div class="siteseo-styles pre"><pre>'.esc_attr('[siteseo_html_sitemap cpt="post,product"]').'</div></pre>
            <h4>'.esc_html__('Other', 'siteseo').'</h4>
            <p>'.esc_html__('Display the sitemap dynamically by entering an ID in the first field below.', 'siteseo').'</p>
			</div>
		</div>
        
        <table class="form-table">
             <tr scope="row">
                <th>'.esc_html__('Post, Page, or Custom Post Type IDs to display:','siteseo').'</th>
                <td>
                    <input type="text" value="'.esc_html($include_pages).'" name="siteseo_options[page_numbers]" placeholder="'.esc_html__('eg:2, 28, 68','siteseo').'">
                </td>
            </tr>

            <tr scope="row">
                <th>'.esc_html__('Exclude Posts, Pages, Custom Post Types or Terms IDs:','siteseo').'</th>
                <td>
                    <input type="text" value="'.esc_html($exclude_page).'" name="siteseo_options[exclude_page]" placeholder="'.esc_html__('eg: 13 ,8 ,28','siteseo').'">
                </td>
            </tr>

            <tr scope="row">
                <th>'.esc_html__('Order:','siteseo').'</th>
                <td>
                    <select name="siteseo_options[order]">
                        <option value="DESC" '.selected($order, 'DESC', false).'>'.esc_html__('DESC (descending order from highest to lowest values (3, 2, 1; c, b, a))','siteseo').'</option>
                         <option value="ASC" '.selected($order, 'ASC', false).'>'.esc_html__('ASC (ascending order from lowest to highest values (1, 2, 3; a, b, c))','siteseo').'</option>
                    </select>
                </td>
            </tr>

            <tr scope="row">
                <th>'.esc_html__('Order By:','siteseo').'</th>
                <td>
                    <select name="siteseo_options[order_by]">
                        <option value="date" '.selected($order_by, 'date', false).'>'.esc_html__('Deafult (date)','siteseo').'</option>
                        <option value="post_title" '.selected($order_by, 'post_title', false).'>'.esc_html__('Post Title','siteseo').'</option>
                        <option value="modified_date" '.selected($order_by, 'modified_date', false).'>'.esc_html__('Modified date','siteseo').'</option>
                        <option value="post_id" '.selected($order_by, 'post_id', false).'>'.esc_html__('POST ID','siteseo').'</option>
                        <option value="menu_order" '.selected($order_by, 'menu_order', false).'>'.esc_html__('Menu Order','siteseo').'</option>
                    </select>
                </td>
            </tr>
            <tr scope="row">
                <th>'.esc_html__('Disable Date:','siteseo').'</th>
                <td>
                    <label for="sitemap_html_date">
                        <input id="sitemap_html_date" name="siteseo_options[disable_date]" type="checkbox" '.(!empty($disable_date) ? 'checked="yes"' : '').' value="1"/>'.esc_html__('Disable the date display after each post, page, or post type?', 'siteseo'). 
                    '</label>
                </td>
            </tr>

            <tr scope="row">
                <th>'.esc_html__('Remove Archive Links:','siteseo').'</th>
                <td>
                    <label for="sitemap_remove_link">
                        <input id="sitemap_remove_link" name="siteseo_options[remove_links]" type="checkbox" '.(!empty($remove_archive) ? 'checked="yes"' : '').' value="1"/>'.esc_html__('Remove links from archive pages (e.g., Products).', 'siteseo'). 
                    '</label>
                </td>
            </tr>
        </table><input type="hidden" name="siteseo_options[html_sitemap]" value="1"/>';
    }

    static function save_settings(){
		global $siteseo;

		check_admin_referer('siteseo_sitemap_settings');

		if(!siteseo_user_can('manage_sitemap') || !is_admin()){
			return;
		}

		$options = [];

		if(empty($_POST['siteseo_options'])){
			return;
		}
		
		if(isset($_POST['siteseo_options']['general_sitemaps'])){
			$options['xml_sitemap_general_enable'] = isset($_POST['siteseo_options']['enable_xml_sitemap']);
			$options['xml_sitemap_img_enable'] = isset($_POST['siteseo_options']['enable_img_sitemap']);
			$options['xml_sitemap_author_enable'] = isset($_POST['siteseo_options']['enable_author_sitemap']);
			$options['xml_sitemap_html_enable'] = isset($_POST['siteseo_options']['enable_html_sitemap']);

			flush_rewrite_rules();
		}

		if(isset($_POST['siteseo_options']['html_sitemap'])){
			
			$options['xml_sitemap_html_mapping'] = isset($_POST['siteseo_options']['page_numbers']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['page_numbers'])) : '';
			$options['xml_sitemap_html_exclude'] = isset($_POST['siteseo_options']['exclude_page']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['exclude_page'])) : '';
			$options['xml_sitemap_html_order'] = isset($_POST['siteseo_options']['order'])? sanitize_text_field(wp_unslash($_POST['siteseo_options']['order'])) : '';
			$options['xml_sitemap_html_orderby'] = isset($_POST['siteseo_options']['order_by']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['order_by'])) : '';
			$options['xml_sitemap_html_date'] = isset($_POST['siteseo_options']['disable_date']);
			$options['xml_sitemap_html_archive_links'] = isset($_POST['siteseo_options']['remove_links']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['remove_links'])) : '';
		}

		// posts 
		if(isset($_POST['siteseo_options']['post_types_tab'])){
			if(isset($_POST['siteseo_options']['xml_sitemap_post_types_list'])){
				$xml_post_types = map_deep(wp_unslash($_POST['siteseo_options']['xml_sitemap_post_types_list']), 'sanitize_text_field');
				foreach($xml_post_types as $posttypes_key => $posttypes_value) {
					if(isset($posttypes_value['include'])) {
						$options['xml_sitemap_post_types_list'][$posttypes_key]['include'] = $posttypes_value['include'];
					}
				}
			}
		}

		// Taxonomies
		if(isset($_POST['siteseo_options']['taxonomy_sitemap_tabs'])){
			if(isset($_POST['siteseo_options']['xml_sitemap_taxonomies_list'])){
				$xml_tax_list = map_deep(wp_unslash($_POST['siteseo_options']['xml_sitemap_taxonomies_list']), 'sanitize_text_field');
				foreach($xml_tax_list as $taxonomy_key => $taxonomy_value){
						if(isset($taxonomy_value['include'])){
							$options['xml_sitemap_taxonomies_list'][$taxonomy_key]['include'] = $taxonomy_value['include'];
						}
				}
			}
		}

		update_option('siteseo_xml_sitemap_option_name',$options);
    }
}
PKv�f\s����settings/advanced.phpnu�[���<?php
/*
* SITESEO
* https://siteseo.io
* (c) SiteSEO Team
*/

namespace SiteSEO\Settings;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class Advanced{

	static function menu(){
		global $siteseo;

		$current_tab = isset($_GET['tab']) ? sanitize_key($_GET['tab']) : 'tab_image_seo'; // Default tab

		$titles_meta_subtabs = [
			'tab_image_seo' => esc_html__('Image SEO', 'siteseo'),
			'tab_advanced' => esc_html__('Advanced', 'siteseo'),
			'tab_appearance' => esc_html__('Appearance', 'siteseo'),
			'tab_security' => esc_html__('Security', 'siteseo'),
			'tab_toc' => esc_html__('Table of content', 'siteseo')
		];
		
		
		echo '<div id="siteseo-root">';
		Util::admin_header();

		echo '<form method="post" id="siteseo-form" class="siteseo-option" name="siteseo-flush">';

		wp_nonce_field('siteseo_advance_settings');

		$advanced_toggle = isset($siteseo->setting_enabled['toggle-advanced']) ? $siteseo->setting_enabled['toggle-advanced'] : '';
		$nonce = wp_create_nonce('siteseo_toggle_nonce');

		Util::render_toggle('Image SEO & Advanced Settings - SiteSEO', 'advanced_toggle', $advanced_toggle, $nonce);

		echo '<div id="siteseo-tabs" class="wrap">
			<div class="siteseo-nav-tab-wrapper">';

		foreach($titles_meta_subtabs as $tab_key => $tab_caption){

			$active_class = ($current_tab === $tab_key) ? ' siteseo-nav-tab-active' : '';
			echo '<a id="' . esc_attr($tab_key) . '-tab" class="siteseo-nav-tab' . esc_attr($active_class) . '" data-tab="' . esc_attr($tab_key) . '">' . esc_html($tab_caption) . '</a>';
		}

		echo '</div>		
		<div class="tab-content-wrapper">
		<div class="siteseo-tab '.($current_tab == 'tab_image_seo' ? ' active' : '').'" id="tab_image_seo" style="display: none;">';
		self::image_seo();
		echo '</div>
		<div class="siteseo-tab '.($current_tab == 'tab_advanced' ? ' active' : '').'" id="tab_advanced" style="display: none;">';
		self::advanced();
		echo '</div>
		<div class="siteseo-tab '.($current_tab == 'tab_appearance' ? ' active' : '').'" id="tab_appearance" style="display: none;">';
		self::appearance();
		echo '</div>
		<div class="siteseo-tab '.($current_tab == 'tab_security' ? ' active' : '').'" id="tab_security" style="display: none;">';
		self::security(); 
		echo '</div>
		<div class="siteseo-tab '.($current_tab == 'tab_toc' ? ' active' : '').'" id="tab_toc" style="display: none;">';
		self::toc(); 
		echo '</div>
		</div>';

		Util::submit_btn();
		echo '</form></div>';

	}

	static function image_seo(){
		global $siteseo;

		if(!empty($_POST['submit'])){
			self::save_settings();
		}

		//$options = $siteseo->$advanced_settings;
		$options = get_option('siteseo_advanced_option_name');

		$option_attachment = isset($options['advanced_attachments']) ? $options['advanced_attachments'] : '';
		$option_attachment_file = isset($options['advanced_attachments_file']) ? $options['advanced_attachments_file'] : '';
		$option_clean_filename = isset($options['advanced_clean_filename']) ? $options['advanced_clean_filename'] : '';
		$option_img_title = isset($options['advanced_image_auto_title_editor']) ? $options['advanced_image_auto_title_editor'] : '';
		$option_img_alt = isset($options['advanced_image_auto_alt_editor']) ? $options['advanced_image_auto_alt_editor'] : '';
		$option_target_key = isset($options['advanced_image_auto_alt_target_kw']) ? $options['advanced_image_auto_alt_target_kw'] : '';
		$option_cap_img = isset($options['advanced_image_auto_caption_editor']) ? $options['advanced_image_auto_caption_editor'] : '';
		$option_desc_img = isset($options['advanced_image_auto_desc_editor']) ? $options['advanced_image_auto_desc_editor'] : '';

		echo '<h3 class="siteseo-tabs">'.esc_html__('Image SEO','siteseo').'</h3>
        <p>'.esc_html__('Images can drive significant traffic to your site. Be sure to always add alt text, optimize file sizes, and properly name the files, among other best practices.','siteseo').'</p>

        <table class="form-table">
            <tbody class="siteseo_tbody">
                <tr>
                    <th scope="row" style="user-select:auto;">'.esc_html__('Redirect attachment pages to the post parent page.','siteseo').'</th>
                    <td>
                        <label>
				        <input name="siteseo_options[attachment]" type="checkbox"'.(!empty($option_attachment) ? 'checked="yes"' : '').' value="1"/>'.esc_html__('Redirect attachment pages to the post parent, or to the homepage if no parent exists.', 'siteseo'). 
			            '</label>
                    </td>
                </tr>

                <tr>
                    <th scope="row" style="user-select:auto;">'.esc_html__('Redirect attachment pages to their file URL','siteseo').'</th>
                    <td>
                        <label>
                            <input name="siteseo_options[attachment_file]" type="checkbox"'.(!empty($option_attachment_file) ? 'checked="yes"' : '').' value="1"/>'.esc_html__('Redirect attachment pages to their respective file URLs (e.g., https://www.example.com/my-image-file.jpg).', 'siteseo'). 
                        '</label>
                        <p class="description">'.esc_html__('If this option is enabled, it will override the redirection of attachment pages to the post parent.','siteseo').'</p>
                    </td>
                <tr>

				<tr>
                    <th scope="row" style="user-select:auto;">'.esc_html__('Cleaning media filename','siteseo').'</th>
                    <td>
                        <label>
                            <input name="siteseo_options[clean_filename]" type="checkbox"'.(!empty($option_clean_filename) ? 'checked="yes"' : '').' value="1"/>'.esc_html__('When uploading media, remove accents, spaces, and capital letters, and enforce UTF-8 encoding.', 'siteseo'). 
                        '</label>
                        <p class="description">'.esc_html__('e.g. "ExãMple 1 cópy!.jpg" => "example-1-copy.jpg"','siteseo').'</p>
                    </td>
                <tr>

				<tr>
                    <th scope="row" style="user-select:auto;">'.esc_html__('Automatically set the image Title','siteseo').'</th>
                    <td>
                        <label>
                            <input name="siteseo_options[auto_img_title]" type="checkbox"'.(!empty($option_img_title) ? 'checked="yes"' : '').' value="1"/>'.esc_html__('When uploading an image file, automatically set the title to match the filename.', 'siteseo'). 
                        '</label>
                        <p class="description">' . esc_html__('We use the product title for ', 'siteseo') . esc_html(!defined('SITEPAD') ? 'WooCommerce' : 'Kkart') . esc_html__(' items.', 'siteseo') . '</p>
                    </td>
                <tr>

				<tr>
                    <th scope="row" style="user-select:auto;">'.esc_html__('Automatically set the image Alt txt','siteseo').'</th>
                    <td>
                        <label><input name="siteseo_options[auto_img_alt]" type="checkbox"'.(!empty($option_img_alt) ? 'checked="yes"' : '').' value="1"/>'.esc_html__('When uploading an image file, automatically set the alt text to match the filename.', 'siteseo'). 
                        '</label>
                    </td>
                <tr>

				<tr>
                    <th scope="row" style="user-select:auto;">'.esc_html__('Automatically set the image alt text using target keywords..','siteseo').'</th>
                    <td>
                        <label>
                            <input name="siteseo_options[auto_target_keyword]" type="checkbox"'.(!empty($option_target_key) ? 'checked="yes"' : '').' value="1"/>'.esc_html__('Use the target keywords if no alt text is set for the image.', 'siteseo'). 
                        '</label>
                        <p class="description">'.esc_html__('This setting will apply only to images without alt text on the frontend. It is retroactive, meaning if you disable it, images that previously had empty alt text will revert to being empty.','siteseo').'</p>
                    </td>
                <tr>

				<tr>
                    <th scope="row" style="user-select:auto;">'.esc_html__('Automatically set the image Caption','siteseo').'</th>
                    <td>
                        <label>
                            <input name="siteseo_options[caption_image]" type="checkbox"'.(!empty($option_cap_img) ? 'checked="yes"' : '') . ' value="1"/>'.esc_html__('When uploading an image file, automatically set the caption to match the filename.', 'siteseo') . 
                        '</label>
                    </td>
                <tr>

				<tr>
                    <th scope="row" style="user-select:auto;">'.esc_html__('Automatically set the image Description','siteseo').'</th>
                    <td>
                        <label>
                            <input name="siteseo_options[description_img]" type="checkbox"'.(!empty($option_desc_img) ? 'checked="yes"' : ''). ' value="1"/>'.esc_html__('When uploading an image file, automatically set the description to match the filename.', 'siteseo'). 
                        '</label>
                    </td>
                <tr>

			</tbody>
		</table><input type="hidden" name="siteseo_options[image_seo]" value="1"/>';
	}
	
	static function advanced(){
		global $siteseo, $wp_version;

		if(!empty($_POST['submit'])){
			self::save_settings();
		}

		//$options = $siteseo->advanced_settings;
		$options = get_option('siteseo_advanced_option_name');
		
		$platform_name = defined('SITEPAD') ? 'SitePad' : 'WordPress';

		$option_taxonomy_desc = isset($options['advanced_tax_desc_editor']) ? $options['advanced_tax_desc_editor'] : '';
		$option_category_url = isset($options['advanced_category_url']) ? $options['advanced_category_url'] : '';
		$option_noreferrer_link = isset($options['advanced_noreferrer']) ? $options['advanced_noreferrer'] : '';
		$option_wp_generator = isset($options['advanced_wp_generator']) ? $options['advanced_wp_generator'] : '';
		$option_hentry_post = isset($options['advanced_hentry']) ? $options['advanced_hentry'] : '';
		$option_author_url = isset($options['advanced_comments_author_url']) ? $options['advanced_comments_author_url'] : '';
		$option_site_fileds = isset($options['advanced_comments_website']) ? $options['advanced_comments_website'] : '';
		$option_rel_attributes = isset($options['advanced_comments_form_link']) ? $options['advanced_comments_form_link'] : '';
		$option_shortlink = isset($options['advanced_wp_shortlink']) ? $options['advanced_wp_shortlink'] : '';
		$option_wlw_meta_tag = isset($options['advanced_wp_wlw']) ? $options['advanced_wp_wlw'] : '';
		$option_rsd_meta_tag = isset($options['advanced_wp_rsd']) ? $options['advanced_wp_rsd'] : '';
		$option_google_meta_value = isset($options['advanced_google']) ? $options['advanced_google'] : '';
		$option_bing_meta_value = isset($options['advanced_bing']) ? $options['advanced_bing'] : '';
		$option_pinterest_meta_value = isset($options['advanced_pinterest']) ? $options['advanced_pinterest'] : '';
		$option_yandex_meta_value = isset($options['advanced_yandex']) ? $options['advanced_yandex'] : '';
		$option_remove_wocommerce_cat_url = isset($options['advanced_product_cat_url']) ? $options['advanced_product_cat_url'] : '';
		
		echo '<h3 class="siteseo-tabs">'.esc_html__('Advanced','siteseo').'</h3>
		<p class="description">'.esc_html__('Advanced SEO options for advanced users.','siteseo').'</p>
		<table class="form-table"/>
			<tbody>
				<tr>
					<th scope="row" style="user-select:auto;">'.esc_html__('Add WP Editor to taxonomy description textarea','siteseo').'</th>
					<td>
						<label>
							<input name="siteseo_options[taxonomy_desc]" type="checkbox"'.(!empty($option_taxonomy_desc) ? 'checked="yes"' : '').' value="1"/>'.esc_html__('Add the TINYMCE editor to the term description field to enable rich text formatting.', 'siteseo'). 
			            '</label>
					</td>
				</tr>
				
				<tr>
					<th scope="row" style="user-select:auto;">'.esc_html__('Remove /category/ in URL','siteseo').'</th>
					<td>
						<label>
							<input name="siteseo_options[category_url]" type="checkbox"'.(!empty($option_category_url) ? 'checked="yes"' : '').' value="1"/>'.esc_html__('Remove /category/ in your permalinks', 'siteseo'). 
			            '</label>
						<p class="description">'.esc_html('e.g. "https://example.com/category/my-post-category/" => "https://example.com/my-post-category/"').'</p>
					</td>
				</tr>
				
				<tr>
					<th scope="row">'.esc_html__('Remove category base from product permalinks', 'siteseo').'</th>
					<td>
						<label>
							<input type="checkbox" name="siteseo_options[remove_cate_woocommerce]" '.(!empty($option_remove_wocommerce_cat_url) ? 'checked="yes"' : '').' value="1"/>
							'.
							/* translators: placeholders are just html tags */ 
							wp_kses_post(sprintf(__('Remove %1$s product-category %2$s in your permalinks', 'siteseo'), '<strong>','</strong>')).'
							</label>
						</div>
					</td>
				</tr>
				
				<tr>
					<th scope="row" style="user-select:auto;">'.esc_html__('Remove noreferrer link attribute in post content','siteseo').'</th>
					<td>
						<label>
				        <input name="siteseo_options[noreferrer_link]" type="checkbox"'.(!empty($option_noreferrer_link) ? 'checked="yes"' : '').' value="1"/>'.esc_html__('Remove the noreferrer link attribute from the source code.', 'siteseo'). 
			            '</label>
						<p class="description">'.esc_html__('Useful for affiliate links (eg: Amazon)','siteseo').'</p>
					</td>
				</tr>
				
				<tr>
					<th scope="row" style="user-select:auto;">'.
					// translators: %s is the platform name
					sprintf(esc_html__('Remove %s meta generator tag', 'siteseo'), esc_html( $platform_name )).'</th>
					<td>
						<label>
							<input name="siteseo_options[wp_generator_meta]" type="checkbox"'.(!empty($option_wp_generator) ? 'checked="yes"' : '').' value="1"/>'. // translators: %s is the platform name
							sprintf(esc_html__('Remove %s meta generator in source code', 'siteseo'), esc_html( $platform_name)). 
						'</label>
						<div class="siteseo-styles pre"><pre>'.esc_html('<meta name="generator" content="WordPress '.(!empty($wp_version) ? $wp_version : '6.8.2').'" />').'</pre></div>
					</td>
				</tr>
				
				<tr>
					<th scope="row" style="user-select:auto;">'.esc_html__('Remove hentry post class','siteseo').'</th>
					<td>
						<label>
							<input name="siteseo_options[hentry_post]" type="checkbox"' . (!empty($option_hentry_post) ? 'checked="yes"' : '') . ' value="1"/>' . esc_html__('Remove the `hentry` post class to prevent Google from treating it as structured data (schema)', 'siteseo') . 
						'</label>
					</td>
				</tr>
				
				<tr>
					<th scope="row" style="user-select:auto;">'.esc_html__('Remove author URL','siteseo').'</th>
					<td>
						<label>
							<input name="siteseo_options[comments_author_url]" type="checkbox"'.(!empty($option_author_url) ? 'checked="yes"' : '').' value="1"/>'.esc_html__('Remove the comment author URL in comments if the website field is filled in the profile page.', 'siteseo'). 
						'</label>
					</td>
				</tr>
				
				<tr>
					<th scope="row" style="user-select:auto;">'.esc_html__('Remove website field from comment form','siteseo').'</th>
					<td>
						<label>
							<input name="siteseo_options[website_filed]" type="checkbox"'.(!empty($option_site_fileds) ? 'checked="yes"' : '').' value="1"/>'.esc_html__('Remove the website field from the comment form to reduce spam.', 'siteseo'). 
						'</label>
					</td>
				</tr>
				
				<tr>
					<th scope="row" style="user-select:auto;">'.esc_html__('Add the "nofollow", "noopener", and "noreferrer" rel attributes to the links in the comment form.','siteseo').'</th>
					<td>
						<label>
							<input name="siteseo_options[comment_form_link]" type="checkbox"'.(!empty($option_rel_attributes) ? 'checked="yes"' : '').' value="1"/>'.esc_html__('Prevent search engines from following or indexing the link to the comment form by adding a "noindex", "nofollow" directive.', 'siteseo'). 
						'</label>
						
						<div class="siteseo-styles pre"><pre>'.esc_url('https://www.example.com/my-blog-post/#respond').'</pre></div>
					</td>
				</tr>
				
				<tr>
					<th scope="row" style="user-select:auto;">'.
						// translators: %s is the platform name
					    sprintf(esc_html__('Remove %s shortlink meta tag', 'siteseo'), esc_html( $platform_name)).
					'</th>
					<td>
						<label>
							<input name="siteseo_options[shortlink]" type="checkbox"'.(!empty($option_shortlink) ? 'checked="yes"' : '') .' value="1"/>'. // translators: %s is the platform name
							sprintf(esc_html__('Remove %s shortlink meta tag in source.', 'siteseo'), esc_html( $platform_name )).
						'</label>
						
						<div class="siteseo-styles pre"><pre>'.esc_html('<link rel="shortlink" href="https://www.example.com/"/>').'</pre></div>
					</td>
				</tr>
				
				<tr>
					<th scope="row" style="user-select:auto;">'.esc_html__('Remove Windows Live Writer meta tag','siteseo').'</th>
					<td>
						<label>
							<input name="siteseo_options[wlw_meta]" type="checkbox"'.(!empty($option_wlw_meta_tag) ? 'checked="yes"' : '').' value="1"/>'.esc_html__('Remove the Windows Live Writer meta tag from the source code.', 'siteseo') . 
						'</label>
						
						<div class="siteseo-styles pre"><pre>'.esc_html('<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="https://www.example.com/wp-includes/wlwmanifest.xml" />').'</pre></div>
					</td>
				</tr>
				
				<tr>
					<th scope="row" style="user-select:auto;">'.esc_html__('Remove RSD meta tag','siteseo').'</th>
					<td>
						<label>
							<input name="siteseo_options[rsd_meta]" type="checkbox"'.(!empty($option_rsd_meta_tag) ? 'checked="yes"' : ''). ' value="1"/>'. esc_html__('Remove the Really Simple Discovery (RSD) meta tag from the source code.', 'siteseo'). 
						'</label>
						<p class="description">'.
						// translators: %s is the platform name
						sprintf(esc_html__('The %s Site Health feature will display an HTTPS warning if you enable this option. However, this is a false positive.', 'siteseo'), esc_html($platform_name)).'</p>
						<div class="siteseo-styles pre"><pre>' . esc_html('<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="https://www.example.com/wp-includes/wlwmanifest.xml" />') . '</pre></div>
					</td>
				</tr>
				
				<tr>
					<th scope="row" style="user-select:auto;">'.esc_html__('Google site verification','siteseo').'</th>
					<td>
						<input name="siteseo_options[google_meta_value]" type="text" placeholder="'.esc_html__('Enter Google meta value site verification','siteseo').'" value="'.esc_attr($option_google_meta_value).'"/>
						<p class="description">'.
						/* translators: placeholders are just <strong> tag */ 
						wp_kses_post(sprintf(__('If your site is already verified in %1$s Google Search Console %2$s, you can leave this field blank.', 'siteseo'), '<strong>', '</strong>')).'
					</td>
				</tr>
				
				<tr>
					<th scope="row" style="user-select:auto;">'.esc_html__('Bing site verification','siteseo').'</th>
					<td>
						<input name="siteseo_options[bing_meta_value]" type="text" placeholder="'.esc_html__('Enter Bing meta value site verification','siteseo').'" value="'.esc_attr($option_bing_meta_value).'"/>
						<p class="description">'.
						/* translators: placeholders are just <strong> tag */ 
						wp_kses_post(sprintf(__('If your site is already verified in %1$s Bing Webmaster Tools %2$s, you can leave this field blank.', 'siteseo'), '<strong>', '</strong>')).'</p>
					</td>
				</tr>
				
				<tr>
					<th scope="row" style="user-select:auto;">'.esc_html__('Pinterest site verification','siteseo').'</th>
					<td>
						<input name="siteseo_options[pinterest_meta_value]" type="text" placeholder="'.esc_html__('Enter the Pinterest meta value for site verification.','siteseo').'" value="'.esc_attr($option_pinterest_meta_value).'"/>
					</td>
				</tr>
				
				<tr>
					<th scope="row" style="user-select:auto;">'.esc_html__('Yandex site verification','siteseo').'</th>
					<td>
						<input name="siteseo_options[yandex_meta_value]" type="text" placeholder="'.esc_html__('Enter the Yandex meta value for site verification.','siteseo').'" value="'.esc_attr($option_yandex_meta_value).'"/>
					</td>
				</tr>
			</tbody>
		</table><input type="hidden" name="siteseo_options[advanced_tab]" value="1"/>';

	}

	static function appearance(){
		
		global $siteseo;

		if(!empty($_POST['submit'])){
			self::save_settings();
		}

		//$options = $siteseo->advanced_settings;
		$options = get_option('siteseo_advanced_option_name');

		$option_enable_universal_metabox = isset($options['appearance_universal_metabox']) ? $options['appearance_universal_metabox'] : '';
		$option_disable_universal_metabox = isset($options['appearance_universal_metabox_disable']) ? $options['appearance_universal_metabox_disable'] : '';
		$option_content_analysis_metabox = isset($options['appearance_ca_metaboxe']) ? $options['appearance_ca_metaboxe'] : '';
		$option_hide_genesis_metabox = isset($options['appearance_genesis_seo_metaboxe']) ? $options['appearance_genesis_seo_metaboxe'] : ''; 
		$option_structured_type_metabox = isset($options['appearance_advice_schema']) ? $options['appearance_advice_schema'] : '';
		$option_admin_bar = isset($options['appearance_adminbar']) ? $options['appearance_adminbar'] : '';
		$option_noindex_admin_bar = isset($options['appearance_adminbar_noindex']) ? $options['appearance_adminbar_noindex'] : '';
		$option_column_title = isset($options['appearance_title_col']) ? $options['appearance_title_col'] : '';
		$option_column_desc = isset($options['appearance_meta_desc_col']) ? $options['appearance_meta_desc_col'] : '';
		$option_column_redirect = isset($options['appearance_redirect_enable_col']) ? $options['appearance_redirect_enable_col'] : '';
		$option_column_post_type = isset($options['appearance_redirect_url_col']) ? $options['appearance_redirect_url_col'] : '';
		$option_column_canonical_post_ty = isset($options['appearance_canonical']) ? $options['appearance_canonical'] : '';
		$option_column_target_key = isset($options['appearance_target_kw_col']) ? $options['appearance_target_kw_col'] : '';
		$option_column_noindex = isset($options['appearance_noindex_col']) ? $options['appearance_noindex_col'] : '';
		$option_column_nofollow = isset($options['appearance_nofollow_col']) ? $options['appearance_nofollow_col'] : '';
		$option_column_words_no = isset($options['appearance_words_col']) ? $options['appearance_words_col'] : '';
		$option_column_score = isset($options['appearance_score_col']) ? $options['appearance_score_col'] : '';
		$option_misc_genesis_metabox = isset($options['appearance_genesis_seo_menu']) ? $options['appearance_genesis_seo_menu'] : '';

		$appearance_fields =[
			'metaboxes'=>'Metaboxes',
			'Columns' => 'Columns',
			'Misc' =>'Misc',
		];
		
		if(!defined('SITEPAD')){
			$appearance_fields['admin-bar'] = 'Admin bar';
		}
		
		echo '<table class="form-table">
				<tbody>
					<tr>
						<th scope="row">
						 <div class="siteseo-container">';
							$is_first = true;
							foreach($appearance_fields as $post_key => $post_val){
								$active_class = $is_first ? 'active' : '';
								echo '<a href="#'.esc_attr($post_key).'" class="'.esc_attr($active_class).'">'.esc_html($post_val).'</a>';
								$is_first = false;
							}
						echo '</div>
						</th>
						<td>
							<div>
								<h3>'.esc_html__('Appearance','siteseo').'</h3>
								<div class="siteseo_wrap_label">
									<p class="description">'.esc_html__('Customize the plugin to fit your needs','siteseo').'</p>
								</div>
								<span class="line"></span>
								<h3>'.esc_html__('Metaboxes','siteseo').'</h3>
								<p>'.esc_html__('Edit your SEO metadata directly from your favorite page builder.','siteseo').'</p>
								<table class="form-table" id="metaboxes">
									<tbody>';
									if(!defined('SITEPAD')){
										echo '<tr>
											<th scope="row">'.esc_html__('Universal Metabox (Gutenberg)','siteseo').'</th>
											<td>
												<label><input type="checkbox" name="siteseo_options[enable_universal_metabox]" '.(!empty($option_enable_universal_metabox) ? 'checked="yes"' : 'value="1"').' "/> ' . esc_html__('Enable the universal SEO metabox for the Block Editor (Gutenberg)', 'siteseo') . '<label>
											</td>
										</tr>';
									}
										echo '<tr>
											<th scope="row">'.esc_html__('Disable Universal Metabox','siteseo').'</th>
											<td>
												</label><input type="checkbox" name="siteseo_options[disable_universal_metabox]" '.(!empty($option_disable_universal_metabox) ? 'checked="yes"' : 'value="1"').' "/>'.esc_html__('Disable the universal SEO metabox','siteseo').'
											</td>
										</tr>
										
										<tr>
											<th scope="row">'.esc_html__('Remove Content Analysis Metabox','siteseo').'</th>
											<td>
												<label><input type="checkbox" '.(!empty($option_content_analysis_metabox) ? 'checked="yes"' : 'value="1"').'  name="siteseo_options[remove_content_analysis]"> '.esc_html__(' Remove Content Analysis Metabox','siteseo').'</label>
												<p class="description">'.esc_html__('By checking this option, we will no longer track the significant keywords','siteseo').'</p>
											</td>
										</tr>
										
										
										<tr>
											<th scope=row">'.esc_html__('Hide Genesis SEO Metabox','siteseo').'</th>
											<td>
												<label><input type="checkbox" '.(!empty($option_hide_genesis_metabox) ? 'checked="yes"' : 'value="1"').' name="siteseo_options[genesis_metabox]"> '.esc_html__(' Remove Genesis SEO Metabox', 'siteseo').'</label>
											</td>
										</tr>
										
										<tr>
											<th scope="row">'.esc_html__('Hide advice in Structured Data Types metabox','siteseo').'</th>
											<td>
												<label><input type="checkbox" '.(!empty($option_structured_type_metabox) ? 'checked="yes"' : 'value="1"').'    name="siteseo_options[structured_data_types_metabox]">'.esc_html__(' Remove the advice if None schema selected', 'siteseo').'</label>
											</td>
										</tr>
									</tbody>
									</table>';
									
									if(!defined('SITEPAD')){
										echo'<div id="Admin-bar">
										<span class="line"></span>
										<h3>'.esc_html__('Admin bar','siteseo').'</h3>
										<p class="description">'.esc_html__('The admin bar appears on the top of your pages when logged in to your WP admin','siteseo').'</p>
										<table>
										<tbody>
											<tr>
												<th scope="row">'.esc_html__('SEO in admin bar','siteseo').'</th>
												<td>
													<label><input type="checkbox" '.(!empty($option_admin_bar) ? 'checked="yes"' : 'value="1"').' name="siteseo_options[admin_bar]"> '.esc_html__('Remove SEO from Admin Bar in backend and frontend', 'siteseo').'</label>
												</td>
											</tr>
											
											<tr>
												<th scope="row">'.esc_html__('Noindex in admin bar','siteseo').'</th>
												<td>
													<label><input type="checkbox" '.(!empty($option_noindex_admin_bar) ? 'checked="yes"' : 'value="1"').' name="siteseo_options[noindex_admin_bar]"> '.esc_html__('Remove noindex item from Admin Bar in backend and frontend', 'siteseo').'</label>
												</td>
											</tr>
											
										</tbody>
										</table>
										</div>';
									}
									
									echo'<div id="Columns">
									<span class="line"></span>
									<h3>'.esc_html__('Columns','siteseo').'</h3>
									<p>'.esc_html__('Customize the SEO columns displayed in the posts/pages list.','siteseo').'</p>
									<table>
										<tbody>
											<tr>
												<th scope="row">'.esc_html__('Show Title tag column in post types','siteseo').'</th>
												<td>
													<label><input type="checkbox" '.(!empty($option_column_title) ? 'checked="yes"' : 'value="1"').' name="siteseo_options[title_post_types]"> '.esc_html__('Add title column', 'siteseo').'</label>
												</td>
											</tr>
											
											<tr>
												<th scope="row">'.esc_html__('Show Meta description column in post types','siteseo').'</th>
												<td>
													<label><input type="checkbox" '.(!empty($option_column_desc) ? 'checked="yes"' : 'value="1"').' name="siteseo_options[desc_post_types]"> '.esc_html__('Add meta description column','siteseo').'</label>
												</td>
											</tr>
											
											<tr>
												<th scope="row">'.esc_html__('Show Redirection Enable column in post types','siteseo').'</th>
												<td>
													<label><input type="checkbox" '.(!empty($option_column_redirect) ? 'checked="yes"' : 'value="1"').' name="siteseo_options[redirect_post_types]"> '.esc_html__('Add redirection enable column', 'siteseo').'</label>
												</td>
											</tr>
											
											<tr>
												<th scope="row">'.esc_html__('Show Redirect URL column in post types','siteseo').'</th>
												<td>
													<label><input type="checkbox" '.(!empty($option_column_post_type) ? 'checked="yes"' : 'value="1"').' name="siteseo_options[redirect_url_post_types]"> '.esc_html__('Add redirection URL column', 'siteseo').'</label>
												</td>
											</tr>
											
											<tr>
												<th scope="row">'.esc_html__('Show canonical URL column in post types','siteseo').'</th>
												<td>
													<label><input type="checkbox" '.(!empty($option_column_canonical_post_ty) ? 'checked="yes"' : 'value="1"').' name="siteseo_options[url_column_post_types]"> '.esc_html__('Add canonical URL column', 'siteseo').'</label>
												</td>
											</tr>
											
											<tr>
												<th scope="row">'.esc_html__('Show Target Keyword column in post types','siteseo').'</th>
												<td>
													<label><input type="checkbox" '.(!empty($option_column_target_key) ? 'checked="yes"' : 'value="1"').' name="siteseo_options[keyword_column_post_types]"> '.esc_html__('Add target keyword column', 'siteseo').'</label>
												</td>
											</tr>
											
											<tr>
												<th scope="row">'.esc_html__('Show noindex column in post types','siteseo').'</th>
												<td>
													<label><input type="checkbox" '.(!empty($option_column_noindex) ? 'checked="yes"' : 'value="1"').' name="siteseo_options[noindex_column_post_types]"> '.esc_html__('Display noindex status', 'siteseo').'</label>
												</td>
											</tr>
											
											<tr>
												<th scope="row">'.esc_html__('Show nofollow column in post types','siteseo').'</th>
													<td>
														<label><input type="checkbox" '.(!empty($option_column_nofollow) ? 'checked="yes"' : 'value="1"').'    name="siteseo_options[nofollow_column_post_types]"> '.esc_html__('Display nofollow status', 'siteseo').'</label>
													</td>
											</tr>											
											
											<th scope="row">'.esc_html__('Show total number of words column in post types','siteseo').'</th>
												<td>
													<label><input type="checkbox" '.(!empty($option_column_words_no) ? 'checked="yes"' : 'value="1"').' name="siteseo_options[words_column_post_types]"> '.esc_html__('Display total number of words in content', 'siteseo').'</label>
												</td>
											</tr>
											
											<th scope="row">'.esc_html__('Show content analysis score column in post types','siteseo').'</th>
												<td>
													<label><input type="checkbox" '.(!empty($option_column_score) ? 'checked="yes"' : 'value="1"').' name="siteseo_options[score_column_post_types]"> '.esc_html__('Display Content Analysis results column ("Good" or "Should be improved")', 'siteseo').'</label>
												</td>
											</tr>
											
										</tbody>
									</table>
									</div>
									<div id="Misc">
										<span class="line"></span>
										<h3>'.esc_html__('Misc','siteseo').'</h3>
										<div class="siteseo_wrap_label"><p>'.esc_html__('Miscellaneous settings for the SEO plugin.','siteseo').'</p></div>
										<table class="form-table">
											<tbody>
												<tr>
													<th scope="row">'.esc_html__('Hide Genesis SEO Settings link','siteseo').'</th>
													<td>
														<label><input type="checkbox" '.(!empty($option_misc_genesis_metabox) ? 'checked="yes"' : 'value="1"').' name="siteseo_options[genesis_seo_settings]">'.esc_html__('Remove Genesis SEO link in WP Admin Menu', 'siteseo') .'</label>
													</td>
												</tr>
											</tbody>
										</table>
									</div>
							</div>
						</td>
					</tr>
				</tbody>
			</table>
			<input type="hidden" name="siteseo_options[appearance_tab]"  value="1"/>';
	}
	
	static function security(){
		global $siteseo, $wp_roles, $submenu;
		
		if(!current_user_can('administrator')){
			echo '<div class="siteseo_wrap_label">
				<div class="siteseo-notice is-warning">
					<span id="dashicons-warning" class="dashicons dashicons-info"></span>&nbsp;
					<p>Only Admin can change security settings</p>
				</div>
			</div>';
			return;
		}

		if(!empty($_POST['submit'])){
			self::save_settings();
		}
		
		$options = get_option('siteseo_advanced_option_name');
		$menus_check = $submenu['siteseo'];
		$security_fields = [
			'siteseo-metaboxes' => 'SiteSEO Metaboxes',
			'siteseo-settings-pages' => 'SiteSEO setting pages',
		];
		
		$roles = get_editable_roles();

		if(empty($roles)){
			return;
		}

		wp_nonce_field('siteseo_advance_settings');

		echo '<table class="form-table">
			<tbody>
				<tr>
					<th scope="row">
						<div class="siteseo-container">';
						$is_first = true;
						foreach($security_fields as $post_key => $post_val){
							$active_class = $is_first ? 'active' : '';
							echo '<a href="#' . esc_attr($post_key) . '" class="' . esc_attr($active_class) . '">' . esc_html($post_val) . '</a>';
							$is_first = false;
						}
						echo '</div>
					</th>
					<td>
						<div>
							<h3 class="siteseo-tabs">'.esc_html__('Security', 'siteseo').'</h3>
							<div class="siteseo_wrap_label">
								<p class="description">'.esc_html__('Control access to SEO settings and metaboxes by user roles.', 'siteseo').'</p>
							</div>
							
							<h3 class="siteseo-tabs">'.esc_html__('SiteSEO metaboxes', 'siteseo').'</h3>
							<div class="siteseo_wrap_label">
								<p>'.esc_html__('Check a user role to prevent it from editing a specific metabox.', 'siteseo').'</p>
							</div>
							
							<table class="form-table" id="siteseo-metaboxes">
								<tbody>
									<tr>
										<th scope="row">'.esc_html__('Block SEO metabox to user roles', 'siteseo').'</th>
										<td>';
										foreach($roles as $key => $role){
											if(empty($role['capabilities']) || !is_array($role['capabilities']) || !array_key_exists('publish_posts' , $role['capabilities'])){
												continue;
											}

											$checked = isset($options['security_metaboxe_role'][$key]) ? 'checked' : '';
											echo '<label>
												<input type="checkbox" name="siteseo_options[security_metaboxe_role]['.esc_attr($key).']" value="1" '.esc_attr($checked).'/>
												<strong>'.esc_html($role['name']).'</strong>
											</label><br/><br/>';
										}
										echo '</td>
									</tr>
									
									<tr>
										<th scope="row">'.esc_html__('Block Content analysis metabox to user roles', 'siteseo').'</th>
										<td>';
										foreach($roles as $key => $role){
											if(empty($role['capabilities']) || !is_array($role['capabilities']) || !array_key_exists('publish_posts' , $role['capabilities'])){
												continue;
											}

											$checked = isset($options['security_metaboxe_ca_role'][$key]) ? 'checked' : '';
										echo '<label>
											<input type="checkbox" name="siteseo_options[security_metaboxe_ca_role]['.esc_attr($key).']" value="1" '.esc_attr($checked).'/><strong>'.esc_html($role['name']).'</strong>
											</label><br/><br/>';
										}
										echo '</td>
									</tr>
								</tbody>
							</table>
							
							<span class="line"></span>
							
							<h3 class="siteseo-tabs">'.esc_html__('SiteSEO settings pages', 'siteseo').'</h3>
							<p class="description">'.esc_html__('Check a user role to allow it to edit a specific settings page', 'siteseo').'</p>
							
							<table class="form-table" id="siteseo-settings-pages">
								<tbody>';
								
								$settings_pages = [
									'titles' => esc_html__('Titles & Metas', 'siteseo'),
									'xml-sitemap' => esc_html__('Sitemaps', 'siteseo'),
									'social' => esc_html__('Social Networks', 'siteseo'),
									'google-analytics' => esc_html__('Analytics', 'siteseo'),
									'instant-indexing' => esc_html__('Instant Indexing', 'siteseo'),
									'advanced' => esc_html__('Advanced', 'siteseo'),
								];
								
								foreach($settings_pages as $page_key => $page_title){
									echo '<tr>
										<th scope="row">' . esc_html($page_title) . '</th>
										<td>';
										foreach($roles as $role_key => $role){
											if(empty($role['capabilities']) || !is_array($role['capabilities']) || !array_key_exists('publish_posts' , $role['capabilities']) || $role_key == 'administrator'){
												continue;
											}
											
											$checked = isset($options['siteseo_advanced_security_metaboxe_siteseo-' . $page_key][$role_key]) ? 'checked' : '';
											echo '<label>
												<input type="checkbox" name="siteseo_options[siteseo_advanced_security_metaboxe_siteseo-' . esc_attr($page_key) . '][' . esc_attr($role_key) . ']" value="1" ' . esc_attr($checked) . '/>
												<strong>' . esc_html($role['name']) . '</strong>
											</label><br/><br/>';
										}
										echo '</td>
									</tr>';
								}

								//Pro 
								if(is_plugin_active('siteseo-pro/siteseo.php') && !defined('SITEPAD')){
									echo '<tr>
										<th scope="row">' . esc_html__('Pro Features', 'siteseo') . '</th>
										<td>';
										foreach($roles as $key => $role){
											if(empty($role['capabilities']) || !is_array($role['capabilities']) || !array_key_exists('publish_posts' , $role['capabilities']) || $key == 'administrator'){
												continue;
											}
											
											$checked = isset($options['siteseo_advanced_security_page_pro'][$key]) ? 'checked' : '';
											echo '<label>
												<input type="checkbox" name="siteseo_options[siteseo_advanced_security_page_pro][' . esc_attr($key) . ']" value="1" ' . esc_attr($checked) . '/>
												<strong>'.esc_html($role['name']).'</strong>
											</label><br/><br/>';
										}
										echo '</td>
									</tr>';
								}

								echo '</tbody>
							</table>
						</div>
					</td>
				</tr>
			</tbody></table><input type="hidden" name="siteseo_options[security_tab]" value="1"/>';
	}
	
	static function toc(){
		global $siteseo;
		
		if(!empty($_POST['submit'])){
			self::save_settings();
		}
		
		$options = get_option('siteseo_advanced_option_name');

		$option_toc_enable = isset($options['toc_enable']) ? $options['toc_enable'] : '';
		$option_toc_label = isset($options['toc_label']) ? $options['toc_label'] : '';
		$option_headings = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
		$option_list_types = [
			'ol' => __('Ordered List', 'siteseo'),
			'ul' => __('Unordered List', 'siteseo')
		];

		echo'<h3 class="siteseo-tabs">'.esc_html__('Table of Contents', 'siteseo').'</h3>
		<p>'.esc_html__('A table of content works as an index section for your post or page. It helps search engines understand your page structure and users find specific sections quickly, which might help SEO, as it helps search engines better understand the structure of your content and also improves user experience.', 'siteseo').'</p>
		<p>'.esc_html__('To use Table of Content on your pages, you can use this shortcode', 'siteseo').' <code>[siteseo_toc]</code></p>

		<table class="form-table">
			<tr>
				<th scope="row">'.esc_html__('Enable TOC', 'siteseo').'</th>
				<td>
					<label>
						<input type="checkbox" value="1" id="siteseo_toc_enable" name="siteseo_options[toc_enable]" '.checked($option_toc_enable, true, false).'/>
					</label>
				</td>
			</tr>
			<tr>
				<th scope="row">'.esc_html__('TOC Label', 'siteseo').'</th>
				<td>
					<label>
						<input type="text" value="'.esc_attr($option_toc_label).'" name="siteseo_options[toc_label]" placeholder="'.esc_attr__('Table of content', 'siteseo').'"/>
					</label>
				</td>
			</tr>
			<tr>
				<th scope="row">'.esc_html__('Exclude Headings', 'siteseo').'</th>
				<td>
					<div style="display:flex; gap: 20px;">';
					foreach($option_headings as $heading){
						$checked = !empty($options) && !empty($options['toc_excluded_headings']) && is_array($options['toc_excluded_headings']) && in_array($heading, $options['toc_excluded_headings']);
						echo '<label>
							<input type="checkbox" value="'.esc_attr($heading).'" name="siteseo_options[toc_excluded_headings][]" '.checked($checked, true, false).'/>'.esc_html(strtoupper($heading)).'
						</label>';
					}
					echo '</div>
				</td>
			</tr>
			<tr>
				<th scope="row">'.esc_html__('List Type', 'siteseo').'</th>
				<td>
					<div>
						<label>
							<select name="siteseo_options[toc_heading_type]">';
								foreach($option_list_types as $list_type => $list_title){
									$selected = !empty($options['toc_heading_type']) && $options['toc_heading_type'] == $list_type ? 'selected' : '';
									echo '<option value="'.esc_attr($list_type).'" '.esc_attr($selected).'>'.esc_html($list_title).'</option>';
								}
							echo '</select>
						</label>
					</div>
				</td>
			</tr>
		</table><input type="hidden" name="siteseo_options[toc_tab]" value="1" />';
	}

	static function save_settings(){
		global $siteseo;
		
		check_admin_referer('siteseo_advance_settings');
		
		if(!siteseo_user_can('manage_advanced') || !is_admin()){
			return;
		}
		
		$options = [];
		
		if(empty($_POST['siteseo_options'])){
			return;
		}
		
		if(isset($_POST['siteseo_options']['image_seo'])){
			$options['advanced_attachments'] = isset($_POST['siteseo_options']['attachment']);
			$options['advanced_attachments_file'] = isset($_POST['siteseo_options']['attachment_file']);
			$options['advanced_clean_filename'] = isset($_POST['siteseo_options']['clean_filename']);
			$options['advanced_image_auto_title_editor'] = isset($_POST['siteseo_options']['auto_img_title']);
			$options['advanced_image_auto_alt_editor'] = isset($_POST['siteseo_options']['auto_img_alt']);
			$options['advanced_image_auto_alt_target_kw'] = isset($_POST['siteseo_options']['auto_target_keyword']);
			$options['advanced_image_auto_caption_editor'] = isset($_POST['siteseo_options']['caption_image']);
			$options['advanced_image_auto_desc_editor'] = isset($_POST['siteseo_options']['description_img']);

		}
		
		if(isset($_POST['siteseo_options']['advanced_tab'])){
			
			$options['advanced_product_cat_url'] = isset($_POST['siteseo_options']['remove_cate_woocommerce']);
			$options['advanced_tax_desc_editor'] = isset($_POST['siteseo_options']['taxonomy_desc']);
			$options['advanced_category_url'] = isset($_POST['siteseo_options']['category_url']);
			$options['advanced_noreferrer'] = isset($_POST['siteseo_options']['noreferrer_link']);
			$options['advanced_wp_generator'] = isset($_POST['siteseo_options']['wp_generator_meta']);
			$options['advanced_hentry'] = isset($_POST['siteseo_options']['hentry_post']);
			$options['advanced_comments_author_url'] = isset($_POST['siteseo_options']['comments_author_url']);
			$options['advanced_comments_website'] = isset($_POST['siteseo_options']['website_filed']);
			$options['advanced_comments_form_link'] = isset($_POST['siteseo_options']['comment_form_link']);
			$options['advanced_wp_shortlink'] = isset($_POST['siteseo_options']['shortlink']);
			$options['advanced_wp_rsd'] = isset($_POST['siteseo_options']['rsd_meta']);
			$options['advanced_wp_wlw'] = isset($_POST['siteseo_options']['wlw_meta']);
			$options['advanced_google'] = isset($_POST['siteseo_options']['google_meta_value']) ? sanitize_text_field(Util::extract_content(wp_unslash($_POST['siteseo_options']['google_meta_value']))) : '';
			$options['advanced_bing'] = isset($_POST['siteseo_options']['bing_meta_value']) ? sanitize_text_field(Util::extract_content(wp_unslash($_POST['siteseo_options']['bing_meta_value']))) : '';
			$options['advanced_pinterest'] = isset($_POST['siteseo_options']['pinterest_meta_value']) ? sanitize_text_field(Util::extract_content(wp_unslash($_POST['siteseo_options']['pinterest_meta_value']))) : '';
			$options['advanced_yandex'] = isset($_POST['siteseo_options']['yandex_meta_value']) ? sanitize_text_field(Util::extract_content(wp_unslash($_POST['siteseo_options']['yandex_meta_value']))) : '';

		}
		
		if(isset($_POST['siteseo_options']['appearance_tab'])){
			
			$options['appearance_universal_metabox'] = isset($_POST['siteseo_options']['enable_universal_metabox']);
			$options['appearance_universal_metabox_disable'] = isset($_POST['siteseo_options']['disable_universal_metabox']);
			$options['appearance_ca_metaboxe'] = isset($_POST['siteseo_options']['remove_content_analysis']);
			$options['appearance_genesis_seo_metaboxe'] = isset($_POST['siteseo_options']['genesis_metabox']);
			$options['appearance_advice_schema'] = isset($_POST['siteseo_options']['structured_data_types_metabox']);
			$options['appearance_adminbar'] = isset($_POST['siteseo_options']['admin_bar']);
			$options['appearance_adminbar_noindex'] = isset($_POST['siteseo_options']['noindex_admin_bar']);
			$options['appearance_title_col'] = isset($_POST['siteseo_options']['title_post_types']);
			$options['appearance_meta_desc_col'] = isset($_POST['siteseo_options']['desc_post_types']);
			$options['appearance_redirect_enable_col'] = isset($_POST['siteseo_options']['redirect_post_types']);
			$options['appearance_redirect_url_col'] = isset($_POST['siteseo_options']['redirect_url_post_types']);
			$options['appearance_canonical'] = isset($_POST['siteseo_options']['url_column_post_types']);
			$options['appearance_target_kw_col'] = isset($_POST['siteseo_options']['keyword_column_post_types']);
			$options['appearance_noindex_col'] = isset($_POST['siteseo_options']['noindex_column_post_types']);
			$options['appearance_nofollow_col'] = isset($_POST['siteseo_options']['nofollow_column_post_types']);
			$options['appearance_words_col'] = isset($_POST['siteseo_options']['words_column_post_types']);
			$options['appearance_score_col'] = isset($_POST['siteseo_options']['score_column_post_types']);
			$options['appearance_genesis_seo_menu'] = isset($_POST['siteseo_options']['genesis_seo_settings']);
			
		}
		
		if(isset($_POST['siteseo_options']['toc_tab'])){

			$options['toc_enable'] = isset($_POST['siteseo_options']['toc_enable']);
			$options['toc_label'] = isset($_POST['siteseo_options']['toc_label']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['toc_label'])) : '';
			$options['toc_heading_type'] = isset($_POST['siteseo_options']['toc_heading_type']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['toc_heading_type'])) : '';

			//toc_excluded_headings
			if(isset($_POST['siteseo_options']['toc_excluded_headings'])){
				$options['toc_excluded_headings'] = map_deep(wp_unslash($_POST['siteseo_options']['toc_excluded_headings']), 'sanitize_text_field');
			}
			
		}
		
		
		if(isset($_POST['siteseo_options']['security_tab']) && current_user_can('manage_options')){
			
			$has_admin = ['security_metaboxe_role', 'security_metaboxe_ca_role'];
			
			$settings = [
				'security_metaboxe_role',
				'security_metaboxe_ca_role',
				'siteseo_advanced_security_metaboxe_siteseo-titles',
				'siteseo_advanced_security_metaboxe_siteseo-xml-sitemap',
				'siteseo_advanced_security_metaboxe_siteseo-social',
				'siteseo_advanced_security_metaboxe_siteseo-google-analytics',
				'siteseo_advanced_security_metaboxe_siteseo-instant-indexing',
				'siteseo_advanced_security_metaboxe_siteseo-advanced',
				'siteseo_advanced_security_metaboxe_siteseo-import-export'
			];

			$advanced_options = map_deep($_POST['siteseo_options'], function($value){
				
				if(!empty($value)){
					if(is_string($value)){
						return true;
					}

					return sanitize_text_field(wp_unslash($value));
				}

				return '';
			});
			
			$filtered_options = [];
			$roles = get_editable_roles();
			foreach($settings as $setting){
				$accepted_roles = [];
				foreach($roles as $key => $role){
					// We will skip, admin if the setting does not require it.
					if(!in_array($setting, $has_admin) && $key ==  'administrator'){
						continue;
					}
					
					// We only accept roles which has capability to 'publish_posts', as giving access to anyone less does not makes sense.
					if(empty($role['capabilities']) || !is_array($role['capabilities']) || !array_key_exists('publish_posts' , $role['capabilities'])){
						continue;
					}

					array_push($accepted_roles, $key);
				}
				
				// Making sure the roles being pushed are the once we want.
				if(isset($advanced_options[$setting])){
					$filtered_options[$setting] = array_intersect(
						$advanced_options[$setting],
						array_flip($accepted_roles)
					);
				}
			}

			$options = array_merge($options, $filtered_options);
		}

		update_option('siteseo_advanced_option_name', $options);
	}

}
PKv�f\���1�f�fsettings/social.phpnu�[���<?php
/*
* SITESEO
* https://siteseo.io
* (c) SiteSEO Team
*/

namespace SiteSEO\Settings;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class Social{

    static function menu(){
        global $siteseo;

		$social_toggle = isset($siteseo->setting_enabled['toggle-social']) ? $siteseo->setting_enabled['toggle-social'] : '';
		$nonce = wp_create_nonce('siteseo_toggle_nonce');

        $current_tab = isset($_GET['tab']) ? sanitize_key($_GET['tab']) : 'tab_knowledge_graph';

        $social_subtabs = [
            'tab_knowledge_graph' => esc_html__('Knowledge Graph', 'siteseo'),
            'tab_social_accounts' => esc_html__('Your social accounts', 'siteseo'),
            'tab_facebook' => esc_html__('Facebook (Open Graph) ', 'siteseo'),
            'tab_twitter' => esc_html__('X Card', 'siteseo')
        ];
		
		echo '<div id="siteseo-root">';
		
		Util::admin_header();

        echo '<form method="post" id="siteseo-form" class="siteseo-option" name="siteseo-flush">';

        wp_nonce_field('siteseo_social_settings');

		Util::render_toggle('Social Networks - SiteSEO', 'social_toggle', $social_toggle, $nonce);

        echo '<div id="siteseo-tabs" class="wrap">
        <div class="siteseo-nav-tab-wrapper">';

        foreach($social_subtabs as $tab_key => $tab_caption){
			$active_class = ($current_tab === $tab_key) ? ' siteseo-nav-tab-active' : '';
			echo '<a id="' . esc_attr($tab_key) . '-tab" class="siteseo-nav-tab' . esc_attr($active_class) . '" data-tab="' . esc_attr($tab_key) . '">' . esc_html($tab_caption) . '</a>';
        }

        echo '</div>
		<div class="tab-content-wrapper">
        <div class="siteseo-tab' .($current_tab == 'tab_knowledge_graph' ? ' active' : '').'" id="tab_knowledge_graph" style="display: none;">';
        self::knowledge_graph();
        echo '</div>
        <div class="siteseo-tab' .($current_tab == 'tab_social_accounts' ? ' active' : '').'" id="tab_social_accounts" style="display: none;">';
        self::social_accouts();
        echo '</div>
        <div class="siteseo-tab' .($current_tab == 'tab_twitter' ? ' active' : '').'" id="tab_twitter" style="display: none;">';
        self::twitter();
        echo '</div>
        <div class="siteseo-tab' .($current_tab == 'tab_facebook' ? ' active' : '').'" id="tab_facebook" style="display: none;">';
        self::facebook();
        echo '</div>
		</div>'; 

        Util::submit_btn();
        echo '</form></div>';
 
    }

    static function knowledge_graph(){
        global $siteseo;

        if(!empty($_POST['submit'])){
            self::save_settings();
        }

        $options = get_option('siteseo_social_option_name');

        //load data
        $option_org_type = !empty($options['social_knowledge_type']) ? $options['social_knowledge_type'] : '';
        $option_org_name = !empty($options['social_knowledge_name']) ? $options['social_knowledge_name'] : '';
        $option_org_logo = !empty($options['social_knowledge_img']) ? $options['social_knowledge_img'] : '';
        $option_org_number = !empty($options['social_knowledge_phone']) ? $options['social_knowledge_phone'] : '';
        $option_org_contact_type = !empty($options['social_knowledge_contact_type']) ? $options['social_knowledge_contact_type'] : '';
        $option_org_contact_option = !empty($options['social_knowledge_contact_option']) ? $options['social_knowledge_contact_option'] : '';

        echo '<h3 class="siteseo-tabs">'.esc_html__('Knowledge Graph','siteseo').'</h3>
        <p class="description">'.esc_html__('Set up Google Knowledge Graph.','siteseo').'</p>
        <table class="form-table">
            <tbody>
                <tr>
                    <th scope="row" style="user-select:auto;">'.esc_html__('Person or organization','siteseo').'</th>
                    <td>
                        <select name="siteseo_options[org_type]">
                            <option value="none" '.selected($option_org_type, 'none', false).'>'.esc_html__('None','siteseo').'</option>
                            <option value="Person" '.selected($option_org_type, 'Person', false).'>'.esc_html__('Person','siteseo').'</option>
                            <option value="Organization" '.selected($option_org_type, 'Organization', false).'>'.esc_html__('Organization','siteseo').'</option>
                        </select>
                    </td>
                </tr>

                <tr>
                    <th scope="row" style="user-select:auto;">'.esc_html__('Your name/organization','siteseo').'</th>
                    <td>
                        <input type="text" name="siteseo_options[org_name]" value="'.esc_attr($option_org_name).'" placeholder="'.esc_html__('eg.Miremont','siteseo').'">
                    </td>
                </tr>

                <tr>
                    <th scope="row" style="user-select:auto;">'.esc_html__('Your photo/organization logo','siteseo').'</th>
                    <td>
                        <input id="knowledge_org_logo_url" autocomplete="off" type="text" name="siteseo_options[org_logo]" value="'.esc_url($option_org_logo).'" placeholder="'.esc_html__('select your logo','siteseo').'">
                        <button id="knowledge_org_logo" class="btn btnSecondary">'.esc_html__('Upload an image','siteseo').'</button>
 			<p class="description">'.esc_html__('JPG, PNG, WebP and GIF allowed.','siteseo').'</p><br />		
 			<img style="width:300px;max-height:400px;" src="'.esc_url($option_org_logo).'" />
                    </td>
                </tr>

                <tr>
                    <th scope="row" style="user-select:auto;">'.esc_html__('Organizations phone number (only for Organizations)','siteseo').'</th>
                    <td>
                        <input type="text" name="siteseo_options[org_contact_number]" value="'.esc_attr($option_org_number).'" placeholder="'.esc_html__('eg: +33123456789 (internationlized version required)','siteseo').'">
                    </td>
                </tr>

                <tr>
                    <th scope="row" style="user-select:auto;">'.esc_html__('Contact type (only for Organizations)','siteseo').'</th>
                    <td>
                        <select name="siteseo_options[org_contact_type]">
                            <option value="Customer support" '.selected($option_org_contact_type, 'Customer support', false).'>'.esc_html__('Customer support','siteseo').'</option>
                            <option value="Technical support" '.selected($option_org_contact_type, 'Technical support', false).'>'.esc_html__('Technical support','siteseo').'</option>
                            <option value="Billing support" '.selected($option_org_contact_type, 'Billing support', false).'>'.esc_html__('Billing support','siteseo').'</option>
                            <option value="Bill payment" '.selected($option_org_contact_type, 'Bill payment', false).'>'.esc_html__('Bill payment','siteseo').'</option>
                            <option value="Sales payment" '.selected($option_org_contact_type, 'Sales payment', false).'>'.esc_html__('Sales payment','siteseo').'</option>
                            <option value="Credit card support" '.selected($option_org_contact_type, 'Credit card support', false).'>'.esc_html__('Credit card support','siteseo').'</option>
                            <option value="Emergency support" '.selected($option_org_contact_type, 'Emergency support', false).'>'.esc_html__('Emergency support','siteseo').'</option>
                            <option value="Baggage tracking" '.selected($option_org_contact_type, 'Baggage tracking', false).'>'.esc_html__('Baggage tracking','siteseo').'</option>
                            <option value="Roadside assistance" '.selected($option_org_contact_type, 'Roadside assistance', false).'>'.esc_html__('Roadside assistance','siteseo').'</option>
                            <option value="Package tracking" '.selected($option_org_contact_type, 'Package tracking', false).'>'.esc_html__('Package tracking','siteseo').'</option>
                        </select>
                    </td>
                </tr>

                <tr>
                    <th scope="row" style="user-select:auto;">'.esc_html__('Contact option (only for Organizations)','siteseo').'</th>
                    <td>
                        <select name="siteseo_options[org_contact_option]">
                            <option value="None" '.selected($option_org_contact_option, 'None', false).'>'.esc_html__('None','siteseo').'</option>
                            <option value="TollFree" '.selected($option_org_contact_option, 'TollFree', false).'>'.esc_html__('TollFree', 'siteseo').'</option>
                            <option value="HearingImpairedSupported" '.selected($option_org_contact_option, 'HearingImpairedSupported', false).'>'.esc_html__('Hearing Impaired Supported','siteseo').'</option>
                        </select>
                    </td>
                </tr>        
            </tbody>
        </table><input type="hidden" name="siteseo_options[knowledge_graph_tab]" value="1" >';
    }

    static function social_accouts(){
        global $siteseo;

        if(!empty($_POST['submit'])){
            self::save_settings();
        }

		//$options = $siteseo->social_settings;
        $options = get_option('siteseo_social_option_name');

        //load settings
        $facebook_acct = !empty($options['social_accounts_facebook']) ? $options['social_accounts_facebook'] : '';
        $twitter_acct = !empty($options['social_accounts_twitter']) ? $options['social_accounts_twitter'] : '';
        $instagram_acct = !empty($options['social_accounts_instagram']) ? $options['social_accounts_instagram'] : '';
        $youtube_acct = !empty($options['social_accounts_youtube']) ? $options['social_accounts_youtube'] : '';
        $pinterest_acct = !empty($options['social_accounts_pinterest']) ? $options['social_accounts_pinterest'] : '';
        $additional_acct = !empty($options['social_accounts_additional']) ? implode("\n", $options['social_accounts_additional']) : '';

        echo '<h3 class="siteseo-tabs">'.esc_html__('Your social accouts', 'siteseo').'</h3>
         <table class="form-table">
            <tbody>
                <tr>
                    <th scope="row" style="user-select:auto;">'.esc_html__('Facebook', 'siteseo').'</th>
                    <td>
                        <input type="text" name="siteseo_options[facebook]" placeholder="'.esc_html__('eg: https://facebook.com/my-page-url','siteseo').'" value="'.esc_url($facebook_acct).'">
                    </td>
                </tr>

				<tr>
					<th scope="row" style="user-select:auto;">'.esc_html__('X Username', 'siteseo').'</th>
					<td>
						<input type="text" name="siteseo_options[twitter]" placeholder="'.esc_html__('eg : x_username','siteseo').'" value="'.esc_attr($twitter_acct).'">
					</td>
				</tr>

				<tr>
					<th scope="row" style="user-select:auto;">'.esc_html__('Pinterest URL', 'siteseo').'</th>
					<td>
						<input type="text" name="siteseo_options[pinterest]" placeholder="'.esc_html__('eg : https://pinterest.com/my-page-url/','siteseo').'" value="'.esc_url($pinterest_acct).'">
					</td>
				</tr>

				<tr>
					<th scope="row" style="user-select:auto;">'.esc_html__('Instagram URL', 'siteseo').'</th>
					<td>
						<input type="text" name="siteseo_options[instagram]" placeholder="'.esc_html__('eg : https://www.instagram.com/my-page-url/','siteseo').'" value="'.esc_url($instagram_acct).'">
					</td>   
				</tr>

				<tr>
					<th scope="row" style="user-select:auto;">'.esc_html__('YouTube URL', 'siteseo').'</th>
					<td>
						<input type="text" name="siteseo_options[youtube]" placeholder="'.esc_html__('eg : https://www.youtube.com/my-channel-url/','siteseo').'" value="'.esc_url($youtube_acct).'">
					</td>   
				</tr>
				<tr>
					<th scope="row" style="user-select:auto;">'.esc_html__('Additional Accounts', 'siteseo').'</th>
					<td>
						<textarea name="siteseo_options[additional]" placeholder="'.esc_html__('eg : https://somesite.com/my-channel-url/','siteseo').'">'.esc_textarea($additional_acct).'</textarea>
						<p class="description">'.esc_html__('Enter 1 URL per line.', 'siteseo').'</p>
					</td>
				</tr>
 
            </tbody>
        </table><input type="hidden" name="siteseo_options[social_account_tab]" value="1">';
    }

    static function twitter(){
        global $siteseo;

        if(!empty($_POST['submit'])){
            self::save_settings();
        }

		//$options = $siteseo->social_settings;
        $options = get_option('siteseo_social_option_name');

        //load data
        $option_enable_card = !empty($options['social_twitter_card']) ? $options['social_twitter_card'] : '';
	$option_image_size = !empty($options['social_twitter_card_img_size']) ? $options['social_twitter_card_img_size'] : '';
	$option_twitter_img = !empty($options['social_twitter_card_img']) ? $options['social_twitter_card_img'] : '';

        echo '<h3 class="siteseo-tabs">'.esc_html__('X Card','siteseo').'</h3>
        <p class="description">'.esc_html__('Manage your X card','siteseo').'</p>

        <div class="siteseo-notice">
            <span class="dashicons dashicons-info"></span>
            <div>
                <p>'.
		/* translators: placeholders are just <strong> tag */ 
		wp_kses_post(sprintf(__('We generate the %1$s og:image %2$s meta in the following order:', 'siteseo'), '<strong>', '</strong>')).'</p>
                <ol>
                    <li>'.esc_html__('Custom OG Image from the SEO metabox', 'siteseo').'</li>
                    <li>'.esc_html__('Post thumbnail / Product category thumbnail (Featured image)', 'siteseo').'</li>
                    <li>'.esc_html__('First image of your post content', 'siteseo').'</li>
                    <li>'.esc_html__('Global OG Image set in SEO > Social > Open Graph', 'siteseo').'</li>
                    <li>'.esc_html__('Site icon from the Customizer', 'siteseo').'</li>
                </ol>
            </div>
        </div>
        
        <table class="form-table">
            <tbody>
                <tr>
                    <th scope="row" style="user:select-auto;">'.esc_html__('X Card','siteseo').'</th>
                    <td>'.esc_html__('Manage your X Card','siteseo').'</td>
                </tr>

                <tr>
                    <th scope="row" style="user:select-auto;">'.esc_html__('Enable X Card','siteseo').'</th>
                    <td>
                       <label for="enable_twitter_card"><input id="enable_twitter_card" type="checkbox" name="siteseo_options[enable_twitter_card]" '.(!empty($option_enable_card) ? 'checked="checked"' : 'value="1"') . '>'.esc_html__('Enable X card', 'siteseo') .'</label>
                    </td>
                </tr>
				
                <tr>
                    <th scope="row" style="user:select-auto;">'.esc_html__('Default X Image','siteseo').'</th>
                    <td>
                        <input type="text" id="twitter_logo_url" autocomplete="off" name="siteseo_options[twitter_img]" value="'.esc_url($option_twitter_img).'" placeholder="'.esc_html__('Choose your default thumbnail.','siteseo').'">
						<button id="twitter_logo" class="btn btnSecondary">'.esc_html__('Upload a image','siteseo').'</button>
						<p class="description">'.esc_html__('Minimum size: 144x144px (300x157px with large card), recommended aspect ratio 1:1 (2:1 for large card), maximum file size 5MB.','siteseo').'</p>
                    </td>
                </tr>

                <tr>
                    <th scope="row" style="user:select-auto;">'.esc_html__('X Card Image Size','siteseo').'</th>
                    <td>
                        <select name="siteseo_options[image_size]">
                            <option value="Default" '.selected($option_image_size, 'Default', false).'>'.esc_html__('Default','siteseo').'</option>
                            <option value="Large" '.selected($option_image_size, 'Large', false).'>'.esc_html__('Large','siteseo').'</option>
                        </select>
                    </td>
                </tr>
				
            </tbody>
        </table><input type="hidden" name="siteseo_options[twitter_tab]" value="1">';
    }

    static function facebook(){
        global $siteseo;

        if(!empty($_POST['submit'])){
            self::save_settings();
        }

        // load seetings
		//$options = $siteseo->social_settings;
        $options = get_option('siteseo_social_option_name');

        $option_fb_enable_og = !empty($options['social_facebook_og']) ? $options['social_facebook_og'] : '';
        $option_fb_img = !empty($options['social_facebook_img']) ? $options['social_facebook_img'] : '';
        $option_fb_defult_img = !empty($options['social_facebook_img_default']) ? $options['social_facebook_img_default'] : '';
        $option_fb_ownership = !empty($options['social_facebook_link_ownership_id']) ? $options['social_facebook_link_ownership_id'] : '';
        $option_fb_admin_id = !empty($options['social_facebook_admin_id']) ? $options['social_facebook_admin_id'] : '';

        echo '<h3 class="siteseo-tabs">'.esc_html__('Facebook (Open Graph)','siteseo').'</h3>
        <p class="description">'.esc_html__('Manage Open Graph data to enhance how your links appear on platforms like Facebook, Pinterest, LinkedIn, and WhatsApp when shared. Improve your click-through rate by including relevant details, such as an attention-grabbing image.','siteseo').'<p>
        
        <div class="siteseo-notice">
            <span class="dashicons dashicons-info"></span>
            <div>
                <p> '.
		/* translators: placeholders are just <strong> tag */ 
		wp_kses_post(sprintf(__('We generate the %1$s OG:image %2$s meta in the following sequence:', 'siteseo'), '<strong>', '</strong>')).'</p>
                <ol>
                    <li>'.esc_html__('Custom OG image from the SEO metabox', 'siteseo').'</li>
                    <li>'.esc_html__('Post thumbnail / Product category thumbnail (Featured image)', 'siteseo').'</li>
                    <li>'.esc_html__('First image in your post content', 'siteseo').'</li>
                    <li>'.esc_html__('Global OG:image set in SEO > Social > OG Card', 'siteseo').'</li>
                </ol>
            </div>
        </div>

        <table class="form-table">
            <tbody>
                <tr>
                    <th scope="row" style="user-select:auto;">'.esc_html__('Enable OG date','siteseo').'</th>
                    <td>
                        <label for="facebook_graph_enable">
                        <input id="facebook_graph_enable" type="checkbox" name="siteseo_options[enable_fb_og]" '.(!empty($option_fb_enable_og) ? 'checked="yes"' : 'value="1"').'>'. esc_html__('Enable OG data','siteseo') .'
                        </label>
                    </td>
                </tr>

                <tr>
                    <th scope="row" style="user-select:auto;">'.esc_html__('Default Image','siteseo').'</th>
                    <td>
                        <input id="facebook_org_image_url" autocomplete="off" type="text" name="siteseo_options[fb_image]" value="'.esc_url($option_fb_img).'" palceholder="'.esc_html__('Select your default thumbnail','siteseo').'">
                        <button id="facebook_upload_logo" class="btn btnSecondary">'.esc_html__('Upload a image','siteseo').'</button>
						<p class="description">'.esc_html__('Minimum size: 200x200px, ideal ratio 1.91:1, 8MB max. (e.g., 1640x856px or 3280x1712px for retina screens).','siteseo').'</p>
                        <p class="description">'.esc_html__('If no default image is set, we will use your site icon defined in the Customizer.','siteseo').'</p>
                    </td>
                </tr>

                <tr>
                    <th scope="row" style="user-select:auto;">'.esc_html__('Override Default Image','siteseo').'</th>
                    <td>
                        <div class="siteseo_wrap_label">
                            <label for="override_image_tag">
                            <input id="override_image_tag" type="checkbox" name="siteseo_options[fb_default_img]" '.(!empty($option_fb_defult_img) ? 'checked="yes"' : 'value="1"').' >'.esc_html__('Override all og:image tags with this default image, unless a custom og:image has been set in the SEO metabox.','siteseo').'
                            </label>
                        </div>
			<br /><div class="siteseo-notice is-warning"><p>'.
			/* translators: placeholders are just <strong> tag */ 
			wp_kses_post(sprintf(__('Please define a default %1$s OG image %2$s using the field above.', 'siteseo'), '<strong>','</strong>')).'<p></div>
                    </td>
                </tr>

                <tr>
                    <th scope="row" style="user-select:auto">'.esc_html__('Link Ownership ID','siteseo').'</th>
                    <td>
                        <input type="text" placeholder="0123456789" name="siteseo_options[fb_owership_id]" value="'.esc_attr($option_fb_ownership).'">
                        <p class="description">'.esc_html__('Enter one or more Facebook Page IDs linked to a URL to enable link editing and instant article publishing.','siteseo').'</p>
                        <div class="siteseo-styles pre"><pre>'.esc_html('<meta property="fb:pages" content="page ID"/>').'</pre></div>
                    </td>
                </tr>

                <tr>
                    <th scope="row" style="user-select:auto">'.esc_html__('Admin ID','siteseo').'</th>
                    <td>
                        <input type="text" placeholder="0123456789" name="siteseo_options[fb_admin_id]" value="'.esc_attr($option_fb_admin_id).'">
                        <p class="description">'.esc_html__('The ID (or a comma-separated list for properties that support multiple IDs) of an app, user of the app, or Page Graph API object.', 'siteseo').'</p>
                        <div class="siteseo-styles pre"><pre>'.esc_html('<meta property="fb:admins" content="admins ID"/>').'</pre></div>
                    </td>
                </tr>

            </tbody>
        </table><input type="hidden" name="siteseo_options[facebook_tab]" value="1">';

    }

    static function save_settings(){
        global $siteseo;

		check_admin_referer('siteseo_social_settings');

		if(!siteseo_user_can('manage_social') || !is_admin()){
			return;
		}

		$options = [];

		if(empty($_POST['siteseo_options'])){
			return;
		}

		if(isset($_POST['siteseo_options']['knowledge_graph_tab'])){

			$options['social_knowledge_type'] = isset($_POST['siteseo_options']['org_type']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['org_type'])) : '';
			$options['social_knowledge_name'] = isset($_POST['siteseo_options']['org_name']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['org_name'])) : '';
			$options['social_knowledge_img'] = isset($_POST['siteseo_options']['org_logo']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['org_logo'])) : '';
			$options['social_knowledge_phone'] = isset($_POST['siteseo_options']['org_contact_number']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['org_contact_number'])) : '';
			$options['social_knowledge_contact_type'] = isset($_POST['siteseo_options']['org_contact_type']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['org_contact_type'])) : '';
			$options['social_knowledge_contact_option'] = isset($_POST['siteseo_options']['org_contact_option']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['org_contact_option'])) : '';
		}

		if(isset($_POST['siteseo_options']['social_account_tab'])){
			$options['social_accounts_facebook'] = isset($_POST['siteseo_options']['facebook']) ? sanitize_url(wp_unslash($_POST['siteseo_options']['facebook'])) : '';
			$options['social_accounts_twitter'] = isset($_POST['siteseo_options']['twitter']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['twitter'])) : '';
			$options['social_accounts_instagram'] = isset($_POST['siteseo_options']['instagram']) ? sanitize_url(wp_unslash($_POST['siteseo_options']['instagram'])) : '';
			$options['social_accounts_youtube'] = isset($_POST['siteseo_options']['youtube']) ? sanitize_url(wp_unslash($_POST['siteseo_options']['youtube'])) : '';
			$options['social_accounts_pinterest'] = isset($_POST['siteseo_options']['pinterest']) ? sanitize_url(wp_unslash($_POST['siteseo_options']['pinterest'])) : '';
			$options['social_accounts_additional'] = isset($_POST['siteseo_options']['additional']) ? explode("\n", sanitize_textarea_field(wp_unslash($_POST['siteseo_options']['additional']))) : '';
			$options['social_accounts_additional'] = Util::clean_url($options['social_accounts_additional']); // We accept 1 url per line.
		}

		if(isset($_POST['siteseo_options']['facebook_tab'])){
			$options['social_facebook_og'] = isset($_POST['siteseo_options']['enable_fb_og']);
			$options['social_facebook_img'] = isset($_POST['siteseo_options']['fb_image']) ? sanitize_url(wp_unslash($_POST['siteseo_options']['fb_image'])) : '';
			$options['social_facebook_img_default'] = isset($_POST['siteseo_options']['fb_default_img']);
			$options['social_facebook_link_ownership_id'] = isset($_POST['siteseo_options']['fb_owership_id']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['fb_owership_id'])) : '';
			$options['social_facebook_admin_id'] = isset($_POST['siteseo_options']['fb_admin_id']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['fb_admin_id'])) : '';
		}

		if(isset($_POST['siteseo_options']['twitter_tab'])){
			$options['social_twitter_card'] = isset($_POST['siteseo_options']['enable_twitter_card']);
			$options['social_twitter_card_img'] = isset($_POST['siteseo_options']['twitter_img']) ? sanitize_url(wp_unslash($_POST['siteseo_options']['twitter_img'])) : '';
			$options['social_twitter_card_img_size'] = isset($_POST['siteseo_options']['image_size']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['image_size'])) : '';
		}

        update_option('siteseo_social_option_name' , $options);
    }
}
PKv�f\;�4rrsocialmetas.phpnu�[���<?php
/*
* SITESEO
* https://siteseo.io
* (c) SiteSEO Team
*/

namespace SiteSEO;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class SocialMetas{

	static function add_social_graph(){
		global $siteseo;

		if(empty($siteseo->setting_enabled['toggle-social'])){
			return;
		}

		$org_type = !empty($siteseo->social_settings['social_knowledge_type']) && $siteseo->social_settings['social_knowledge_type'] !== 'none' ? $siteseo->social_settings['social_knowledge_type'] : '';
		$org_name = !empty($siteseo->social_settings['social_knowledge_name']) ? $siteseo->social_settings['social_knowledge_name'] : ''; 
		$org_logo = !empty($siteseo->social_settings['social_knowledge_img']) ? $siteseo->social_settings['social_knowledge_img'] : '';
		$org_number = !empty($siteseo->social_settings['social_knowledge_phone']) ? $siteseo->social_settings['social_knowledge_phone'] : '';
		$org_contact_type = !empty($siteseo->social_settings['social_knowledge_contact_type']) ? $siteseo->social_settings['social_knowledge_contact_type'] : '';
		$org_contact_option = !empty($siteseo->social_settings['social_knowledge_contact_option']) ? $siteseo->social_settings['social_knowledge_contact_option'] : '';

		$fb_account = !empty($siteseo->social_settings['social_accounts_facebook']) ? $siteseo->social_settings['social_accounts_facebook'] : '';
		$twitter_account = !empty($siteseo->social_settings['social_accounts_twitter']) ? $siteseo->social_settings['social_accounts_twitter'] : '';
		$insta_account = !empty($siteseo->social_settings['social_accounts_instagram']) ? $siteseo->social_settings['social_accounts_instagram'] : '';
		$yt_account = !empty($siteseo->social_settings['social_accounts_youtube']) ? $siteseo->social_settings['social_accounts_youtube'] : '';
		$pt_account = !empty($siteseo->social_settings['social_accounts_pinterest']) ? $siteseo->social_settings['social_accounts_pinterest'] : '';

		//description
		$site_url = get_site_url();
		$site_description = get_bloginfo('name');
		$site_language = get_bloginfo('language');

		// logo
		$logo_id = attachment_url_to_postid($org_logo);

		// Defaults
		$logo_width  = '';
		$logo_height = '';

		// Get image dimensions if attachment exists
		if(!empty($logo_id)){
			$image_data = wp_get_attachment_image_src($logo_id, 'full');
			if(!empty($image_data)){
				$logo_width = $image_data[1];
				$logo_height = $image_data[2];
			}
		}

		//JSON-LD data
		$json_ld = [
			'@context' => 'https://schema.org',
			'@type' => $org_type ? esc_html($org_type) : 'Organization',
			'@id' => esc_url(trailingslashit($site_url) . '#' . $org_type),
			'name' => esc_html($org_name),
			'url' => esc_url($site_url),
			'logo' => array_filter([
				'@type' => 'ImageObject',
				'@id' => esc_url(trailingslashit($site_url) . '#logo'),
				'url' => esc_url($org_logo),
				'contentUrl' => esc_url($org_logo),
				'caption' => esc_html($org_name),
				'inLanguage' => esc_html($site_language),
				'width' => $logo_width,
				'height' => $logo_height,
			]),
			'description' => esc_html($site_description),
		];

		//contact point
		if(!empty($org_contact_type) && !empty($org_number)){
			$json_ld['contactPoint'] = [
				'@type' => 'ContactPoint',
				'contactType' => esc_html($org_contact_type),
				'telephone' => esc_html($org_number),
			];

			if(!empty($org_contact_option) && $org_contact_option !== 'None'){
				$contact_point['contactOption'] = esc_html($org_contact_option);
			}
		}

		$x_url = 'https://x.com/'.$twitter_account;

		$same_as = array_filter([
			esc_url($fb_account), 
			esc_url($x_url), 
			esc_url($insta_account), 
			esc_url($yt_account), 
			esc_url($pt_account)
		]);

		if(!empty($same_as)){
			$json_ld['sameAs'] = array_values($same_as);
		}

		// Output JSON-LD script
		echo '<script type="application/ld+json">';
		echo wp_json_encode($json_ld, JSON_UNESCAPED_SLASHES);
		echo '</script>';
	}

	static function fb_graph(){
		global $siteseo, $post;

		if(empty($siteseo->setting_enabled['toggle-social']) || empty($siteseo->social_settings['social_facebook_og'])){
			return;
		}

		$fb_page_id = !empty($siteseo->social_settings['social_facebook_link_ownership_id']) ? $siteseo->social_settings['social_facebook_link_ownership_id'] : '';
		$fb_link_owership = !empty($siteseo->social_settings['social_facebook_admin_id']) ? $siteseo->social_settings['social_facebook_admin_id'] : '';
		$og_url = get_home_url();
		$og_sitename = get_bloginfo('name');
		
		// Check
		$post_id = isset($post) && is_object($post) ? $post->ID : '';
		$og_title = get_the_title();
		$og_description = get_bloginfo('description');
		$og_img = !empty($siteseo->social_settings['social_facebook_img']) ? $siteseo->social_settings['social_facebook_img'] : '';

		// Get post types and taxonomies
		$post_types = siteseo_post_types();
		$taxonomies = get_taxonomies(array('public' => true), 'objects');
		
		// home site page
		if(is_home() && is_front_page()){
			$og_title = !empty($siteseo->titles_settings['titles_home_site_title']) ? $siteseo->titles_settings['titles_home_site_title'] : $og_title;
			$og_description = !empty($siteseo->titles_settings['titles_home_site_desc']) ? $siteseo->titles_settings['titles_home_site_desc'] : $og_description;
		}
		
		// single post types
		foreach($post_types as $post_type){
			
			// shop page woocommerces
			if(function_exists('is_shop') && is_shop()){
				$shop_page_id = !defined('SITEPAD') ? wc_get_page_id('shop') : kkart_get_page_id('shop');
				
				$archive_title = '';
				$archive_desc = '';
				
				if(is_post_type_archive()){
					$obj = get_queried_object();
					
					if(!empty($obj) && isset($obj->name)){
						$archive_title = !empty($obj->labels->name) ? $obj->labels->name : '';
						$archive_desc  = !empty($obj->description) ? $obj->description : '';
					}
				}
				
				if(!empty(get_post_meta($shop_page_id, '_siteseo_social_fb_title', true))){
					$og_title = get_post_meta($shop_page_id, '_siteseo_social_fb_title', true);
				} elseif(!empty(get_post_meta($shop_page_id, '_siteseo_titles_title', true))){
					$og_title = get_post_meta($shop_page_id, '_siteseo_titles_title', true);
				} elseif(!empty($siteseo->titles_settings['titles_archive_titles']['product']['archive_title'])){
					$og_title = $siteseo->titles_settings['titles_archive_titles']['product']['archive_title'];
				} else {
					$og_title = $archive_title;
				}
				
				
				$og_description = !empty(get_post_meta($shop_page_id, '_siteseo_social_fb_desc', true)) ? get_post_meta($shop_page_id, '_siteseo_social_fb_desc', true) : $og_description;
							
				if(!empty(get_post_meta($shop_page_id, '_siteseo_social_fb_desc', true))){
					$og_description = get_post_meta($shop_page_id, '_siteseo_social_fb_desc', true);
				} elseif(!empty(get_post_meta($shop_page_id, '_siteseo_titles_desc', true))){
					$og_description = get_post_meta($shop_page_id, '_siteseo_titles_desc', true);
				} elseif(!empty($siteseo->titles_settings['titles_archive_titles']['product']['archive_desc'])){
					$og_description = $siteseo->titles_settings['titles_archive_titles']['product']['archive_desc'];
				} else {
					$og_description = $archive_desc;
				}
				
				$og_description = esc_attr(\SiteSEO\TitlesMetas::replace_variables($og_description));
				
				// OG:IMG
				if(!empty(get_post_meta($shop_page_id, '_siteseo_social_fb_img', true))){
					$og_img = get_post_meta($shop_page_id, '_siteseo_social_fb_img', true);
				} else if(get_the_post_thumbnail_url($post, 'full')){
					$og_img = get_the_post_thumbnail_url($post, 'full');
				} else {
					$og_img = !empty($siteseo->social_settings['social_facebook_img']) ? $siteseo->social_settings['social_facebook_img'] : '';
				}
				
				$og_url = urldecode(get_permalink($shop_page_id));
				break;
			}
			
			// archive page
			if($post_type->has_archive && is_post_type_archive($post_type->name)){
				
				$archive_title = '';
				$archive_desc = '';
				
				if(is_post_type_archive()){
					$obj = get_queried_object();
					
					if(!empty($obj) && isset($obj->name)){
						$archive_title = !empty($obj->labels->name) ? $obj->labels->name : '';
						$archive_desc  = !empty($obj->description) ? $obj->description : '';
					}
				}
				
				$og_title = !empty($siteseo->titles_settings['titles_archive_titles'][$post_type->name]['archive_title']) ? $siteseo->titles_settings['titles_archive_titles'][$post_type->name]['archive_title'] : $archive_title;
				$og_description = !empty($siteseo->titles_settings['titles_archive_titles'][$post_type->name]['archive_desc']) ? $siteseo->titles_settings['titles_archive_titles'][$post_type->name]['archive_desc'] : $archive_desc;
				
			}
			
			// blog page
			if(is_home() && !is_front_page()){
				$post_id = get_option('page_for_posts');
				
				//OG:title
				if(!empty(get_post_meta($post_id, '_siteseo_social_fb_title', true))){
					$og_title = get_post_meta($post_id, '_siteseo_social_fb_title', true);
				} elseif(!empty(get_post_meta($post_id, '_siteseo_titles_title', true))){
					$og_title = get_post_meta($post_id, '_siteseo_titles_title', true);
				} elseif(!empty($siteseo->titles_settings['titles_single_titles'][$post_type->name]['title'])){
					$og_title = $siteseo->titles_settings['titles_single_titles'][$post_type->name]['title'];
				} else{
					$og_title = $og_title;
				}

				// og:description
				if(!empty(get_post_meta($post_id, '_siteseo_social_fb_desc', true))){
					$og_description = get_post_meta($post_id, '_siteseo_social_fb_desc', true);
				} elseif(!empty(get_post_meta($post_id, '_siteseo_titles_desc', true))){
					$og_description = get_post_meta($post_id, '_siteseo_titles_desc', true);
				} elseif(!empty($siteseo->titles_settings['titles_single_titles'][$post_type->name]['description'])){
					$og_description = $siteseo->titles_settings['titles_single_titles'][$post_type->name]['description'];
				} elseif(get_the_excerpt($post_id)){
					$og_description = wp_trim_words(get_the_excerpt($post_id), 50);
				}
			}
			
			if(is_singular($post_type->name)){
				
				if(!empty(get_post_meta($post_id, '_siteseo_social_fb_title', true))){
					$og_title = get_post_meta($post_id, '_siteseo_social_fb_title', true);
				} elseif(!empty(get_post_meta($post_id, '_siteseo_titles_title', true))){
					$og_title = get_post_meta($post_id, '_siteseo_titles_title', true);
				} elseif(!empty($siteseo->titles_settings['titles_single_titles'][$post_type->name]['title'])){
					$og_title = $siteseo->titles_settings['titles_single_titles'][$post_type->name]['title'];
				} else{
					$og_title = $og_title;
				}
				
				
				// og:description
				if(!empty(get_post_meta($post_id, '_siteseo_social_fb_desc', true))){
					$og_description = get_post_meta($post_id, '_siteseo_social_fb_desc', true);
				} elseif(!empty(get_post_meta($post_id, '_siteseo_titles_desc', true))){
					$og_description = get_post_meta($post_id, '_siteseo_titles_desc', true);
				} elseif(!empty($siteseo->titles_settings['titles_single_titles'][$post_type->name]['description'])){
					$og_description = $siteseo->titles_settings['titles_single_titles'][$post_type->name]['description'];
				} elseif(get_the_excerpt($post_id)){
					$og_description = wp_trim_words(get_the_excerpt($post_id), 50);
				}
				
				// OG:IMG
				if(!empty(get_post_meta($post_id, '_siteseo_social_fb_img', true))){
					$og_img = get_post_meta($post_id, '_siteseo_social_fb_img', true);
				} else if(get_the_post_thumbnail_url($post, 'full')){
					$og_img = get_the_post_thumbnail_url($post, 'full');
				} else {
					$og_img = !empty($siteseo->social_settings['social_facebook_img']) ? $siteseo->social_settings['social_facebook_img'] : '';
				}

				$og_url = urldecode(get_permalink($post_id));
				break;
			}
		}

		//  taxonomies
		foreach($taxonomies as $taxonomy){
			if(is_tax($taxonomy->name) || is_category() || is_tag()){
				$term = get_queried_object();
				$term_id = $term->term_id;	
				
				// og:title
				if(!empty(get_term_meta($term_id, '_siteseo_social_fb_title', true))){
					$og_title = get_term_meta($term_id, '_siteseo_social_fb_title', true);
				} elseif(!empty(get_term_meta($term_id, '_siteseo_titles_title', true))){
					$og_title = get_term_meta($term_id, '_siteseo_titles_title', true);
				} elseif(!empty($siteseo->titles_settings['titles_tax_titles'][$taxonomy->name]['title'])){
					$og_title = $siteseo->titles_settings['titles_tax_titles'][$taxonomy->name]['title'];
				} else{
					$og_title = $og_title;
				}
								
				// og:description
				if(!empty(get_term_meta($term_id, '_siteseo_social_fb_desc', true))){
					$og_description = get_term_meta($term_id, '_siteseo_social_fb_desc', true);
				} elseif(!empty(get_term_meta($term_id, '_siteseo_titles_desc', true))){
					$og_description = get_term_meta($term_id, '_siteseo_titles_desc', true);
				} elseif(!empty($siteseo->titles_settings['titles_tax_titles'][$taxonomy->name]['description'])){
					$og_description = $siteseo->titles_settings['titles_tax_titles'][$taxonomy->name]['description'];
				} else{
					$og_description = wp_strip_all_tags(term_description($term_id));
				}
				
				$og_img = !empty(get_term_meta($term_id, '_siteseo_social_fb_img', true)) ? get_term_meta($term_id, '_siteseo_social_fb_img', true) : $og_img;
				$og_url = urldecode(get_term_link($term_id));
				break;
			}
		}
		
		$og_title = esc_attr(\SiteSEO\TitlesMetas::replace_variables($og_title));
		$og_description = esc_attr(\SiteSEO\TitlesMetas::replace_variables($og_description));

		if(!empty($og_img)){
			$og_img = sanitize_url($og_img);
			$og_img_width = 0;
			$og_img_height = 0;

			if(!empty($og_img)){
				$image_info = @getimagesize($og_img);

				if($image_info !== false){
					$og_img_width = $image_info[0];
					$og_img_height = $image_info[1];
				}
			}
		}

		// Setting og:type
		if(is_home() || is_front_page()){
			$og_type = 'website'; // default website
		} elseif(is_singular('product') || is_singular('download')){
			$og_type = 'product';
		} elseif(is_singular()){
			$og_type = 'article';
		} elseif(is_search() || is_archive() || is_404()){
			$og_type = 'object';
		}

		if(!empty($og_url)){
			echo '<meta property="og:url" content="'.esc_html($og_url).'" />';
		}

		if(!empty($og_sitename)){
			echo '<meta property="og:site_name" content="'.esc_html($og_sitename).'" />';
		}

		if(function_exists('get_locale')){
			echo '<meta property="og:locale" content="'.esc_html(get_locale()).'" />';
		}

		if(!empty($og_type)){
			echo '<meta property="og:type" content="'.esc_attr($og_type).'" />';
		}

		if(!empty($og_title)){
			echo '<meta property="og:title" content="'.esc_html($og_title).'" />';
		}

		if(!empty($og_description)){
			echo '<meta property="og:description" content="'.esc_html($og_description).'" />';
		}

		if(!empty($og_img)){
			echo '<meta property="og:image" content="'.esc_html($og_img).'" />';

			if(is_ssl()){
				echo '<meta property="og:secure_url" content="'.esc_html($og_img).'" />';
			}
		}

		if(!empty($og_img_height)){
			echo '<meta property="og:image:height" content="'.esc_attr($og_img_height).'" />';
		}

		if(!empty($og_img_width)){
			echo '<meta property="og:image:width" content="'.esc_attr($og_img_width).'" />';
		}

		if(!empty($fb_page_id)){
			echo '<meta property="fb:pages" content="'.esc_html($fb_page_id) .'" />';
		}

		if(!empty($fb_link_owership)){
			echo '<meta property="fb:admins" content="'. esc_html($fb_link_owership).'" />';
		}
	}

	static function twitter_card(){
		global $siteseo, $post;

		if(empty($siteseo->setting_enabled['toggle-social']) || empty($siteseo->social_settings['social_twitter_card'])){
			return;
		}

		$site_url = get_home_url();
		$twitter_user_name = !empty($siteseo->social_settings['social_accounts_twitter']) ? $siteseo->social_settings['social_accounts_twitter'] : '';

		$post_id = isset($post) && is_object($post) ? $post->ID : '';
		$site_title = get_the_title();
		$site_description = get_bloginfo('description');
		$twitter_img = !empty($siteseo->social_settings['social_twitter_card_img']) ? $siteseo->social_settings['social_twitter_card_img'] : '';
		
		if(empty($twitter_img)){
			$twitter_img = !empty($siteseo->social_settings['social_facebook_img']) ? $siteseo->social_settings['social_facebook_img'] : '';
		}
		
		// home site page
		if(is_home() && is_front_page()){
			$site_title = !empty($siteseo->titles_settings['titles_home_site_title']) ? $siteseo->titles_settings['titles_home_site_title'] : $site_title;
			$site_description = !empty($siteseo->titles_settings['titles_home_site_desc']) ? $siteseo->titles_settings['titles_home_site_desc'] : $site_description;
		}

		// types and taxonomies
		$post_types = siteseo_post_types();
		$taxonomies = get_taxonomies(array('public' => true), 'objects');
		// single post types
		foreach($post_types as $post_type){
			
			// woocommerce
			if(function_exists('is_shop') && is_shop()){
				$shop_page_id = !defined('SITEPAD') ? wc_get_page_id('shop') : kkart_get_page_id('shop');
				
				$archive_title = '';
				$archive_desc = '';
				
				// if all x-meta tags empty then use og option is enabled
				$use_og = (empty(get_post_meta($post_id, '_siteseo_social_twitter_title', true)) && empty(get_post_meta($post_id, '_siteseo_social_twitter_desc', true)) && empty(get_post_meta($post_id, '_siteseo_social_twitter_img', true)));
				
				if(is_post_type_archive()){
					$obj = get_queried_object();
					
					if(!empty($obj) && isset($obj->name)){
						$archive_title = !empty($obj->labels->name) ? $obj->labels->name : '';
						$archive_desc  = !empty($obj->description) ? $obj->description : '';
					}
				}
				
				// twitter:title
				if(!empty(get_post_meta($shop_page_id, '_siteseo_social_twitter_title', true))){
					$site_title = get_post_meta($shop_page_id, '_siteseo_social_twitter_title', true);
				} elseif(!empty($use_og) && !empty(get_post_meta($shop_page_id, '_siteseo_social_fb_title', true))){ 
					$site_title = get_post_meta($shop_page_id, '_siteseo_social_fb_title', true);
				} elseif(!empty(get_post_meta($shop_page_id, '_siteseo_titles_title', true))){
					$site_title = get_post_meta($shop_page_id, '_siteseo_titles_title', true);
				} elseif(!empty($siteseo->titles_settings['titles_archive_titles']['product']['archive_title'])){
					$site_title = $siteseo->titles_settings['titles_archive_titles']['product']['archive_title'];
				} else {
					$site_title = $archive_title;
				}
							
				
				// twitter:description
				if(!empty(get_post_meta($shop_page_id, '_siteseo_social_twitter_desc', true))){
					$site_description = get_post_meta($shop_page_id, '_siteseo_social_twitter_desc', true);
				} elseif(!empty($use_og) && !empty(get_post_meta($shop_page_id, '_siteseo_social_fb_desc', true))){ 
					$site_description = get_post_meta($shop_page_id, '_siteseo_social_fb_desc', true);
				} elseif(!empty(get_post_meta($shop_page_id, '_siteseo_titles_desc', true))){
					$site_description = get_post_meta($shop_page_id, '_siteseo_titles_desc', true);
				} elseif(!empty($siteseo->titles_settings['titles_archive_titles']['product']['archive_desc'])){
					$site_description = $siteseo->titles_settings['titles_archive_titles']['product']['archive_desc'];
				} else {
					$site_description = $archive_desc;
				}
				
				// twitter:image
				if(!empty(get_post_meta($shop_page_id, '_siteseo_social_twitter_img', true))){
					$twitter_img = get_post_meta($shop_page_id, '_siteseo_social_twitter_img', true);
				} elseif(!empty($use_og) && !empty(get_post_meta($shop_page_id, '_siteseo_social_fb_img', true))){ 
					$twitter_img = get_post_meta($shop_page_id, '_siteseo_social_fb_img', true);
				}  elseif(get_the_post_thumbnail_url($post, 'full')){
					$twitter_img = get_the_post_thumbnail_url($post, 'full');
				} else {
					$twitter_img = isset($siteseo->social_settings['social_twitter_card_img']) ? $siteseo->social_settings['social_twitter_card_img'] : '';
				}

				$site_url = urldecode(get_permalink($shop_page_id));
				break;
			}
			
			// archive page
			if($post_type->has_archive && is_post_type_archive($post_type->name)){
				
				$archive_title = '';
				$archive_desc = '';
				
				if(is_post_type_archive()){
					$obj = get_queried_object();
					
					if(!empty($obj) && isset($obj->name)){
						$archive_title = !empty($obj->labels->name) ? $obj->labels->name : '';
						$archive_desc  = !empty($obj->description) ? $obj->description : '';
					}
				}
				
				$site_title = !empty($siteseo->titles_settings['titles_archive_titles'][$post_type->name]['archive_title']) ? $siteseo->titles_settings['titles_archive_titles'][$post_type->name]['archive_title'] : $archive_title;
				$site_description = !empty($siteseo->titles_settings['titles_archive_titles'][$post_type->name]['archive_desc']) ? $siteseo->titles_settings['titles_archive_titles'][$post_type->name]['archive_desc'] : $archive_desc;
				
			}
			
			// blog page
			if(is_home() && !is_front_page()){
				$post_id = get_option('page_for_posts');
				$use_og = (empty(get_post_meta($post_id, '_siteseo_social_twitter_title', true)) && empty(get_post_meta($post_id, '_siteseo_social_twitter_desc', true)) && empty(get_post_meta($post_id, '_siteseo_social_twitter_img', true)));
				
				// twitter:title
				if(!empty(get_post_meta($post_id, '_siteseo_social_twitter_title', true))){
					$site_title = get_post_meta($post_id, '_siteseo_social_twitter_title', true);
				} elseif(!empty($use_og) && !empty(get_post_meta($post_id, '_siteseo_social_fb_title', true))){ 
					$site_title = get_post_meta($post_id, '_siteseo_social_fb_title', true);
				} elseif(!empty(get_post_meta($post_id, '_siteseo_titles_title', true))){
					$site_title = get_post_meta($post_id, '_siteseo_titles_title', true);
				} elseif(!empty($siteseo->titles_settings['titles_single_titles'][$post_type->name]['title'])){
					$site_title = $siteseo->titles_settings['titles_single_titles'][$post_type->name]['title'];
				} else{
					$site_title = $site_title;
				}
				
				// twitter:description
				if(!empty(get_post_meta($post_id, '_siteseo_social_twitter_desc', true))){
					$site_description = get_post_meta($post_id, '_siteseo_social_twitter_desc', true);
				} elseif(!empty($use_og) && !empty(get_post_meta($post_id, '_siteseo_social_fb_desc', true))){ 
					$site_description = get_post_meta($post_id, '_siteseo_social_fb_desc', true);
				} elseif(!empty(get_post_meta($post_id, '_siteseo_titles_desc', true))){
					$site_description = get_post_meta($post_id, '_siteseo_titles_desc', true);
				} elseif(!empty($siteseo->titles_settings['titles_single_titles'][$post_type->name]['description'])){
					$site_description = $siteseo->titles_settings['titles_single_titles'][$post_type->name]['description'];
				} elseif(!empty(get_the_excerpt($post_id))){
					$site_description = wp_trim_words(get_the_excerpt($post_id), 50);
				}
			}
			
			if(is_singular($post_type->name)){
				
				$use_og = (empty(get_post_meta($post_id, '_siteseo_social_twitter_title', true)) && empty(get_post_meta($post_id, '_siteseo_social_twitter_desc', true)) && empty(get_post_meta($post_id, '_siteseo_social_twitter_img', true)));
				
				// twitter:title
				if(!empty(get_post_meta($post_id, '_siteseo_social_twitter_title', true))){
					$site_title = get_post_meta($post_id, '_siteseo_social_twitter_title', true);
				} elseif(!empty($use_og) && !empty(get_post_meta($post_id, '_siteseo_social_fb_title', true))){ 
					$site_title = get_post_meta($post_id, '_siteseo_social_fb_title', true);
				} elseif(!empty(get_post_meta($post_id, '_siteseo_titles_title', true))){
					$site_title = get_post_meta($post_id, '_siteseo_titles_title', true);
				} elseif(!empty($siteseo->titles_settings['titles_single_titles'][$post_type->name]['title'])){
					$site_title = $siteseo->titles_settings['titles_single_titles'][$post_type->name]['title'];
				} else{
					$site_title = $site_title;
				}
				
				
				// twitter:description
				if(!empty(get_post_meta($post_id, '_siteseo_social_twitter_desc', true))){
					$site_description = get_post_meta($post_id, '_siteseo_social_twitter_desc', true);
				} elseif(!empty($use_og) && !empty(get_post_meta($post_id, '_siteseo_social_fb_desc', true))){ 
					$site_description = get_post_meta($post_id, '_siteseo_social_fb_desc', true);
				} elseif(!empty(get_post_meta($post_id, '_siteseo_titles_desc', true))){
					$site_description = get_post_meta($post_id, '_siteseo_titles_desc', true);
				} elseif(!empty($siteseo->titles_settings['titles_single_titles'][$post_type->name]['description'])){
					$site_description = $siteseo->titles_settings['titles_single_titles'][$post_type->name]['description'];
				} else{
					$site_description = wp_trim_words(get_the_excerpt($post_id), 50);
				}

				// twitter:image
				if(!empty(get_post_meta($post_id, '_siteseo_social_twitter_img', true))){
					$twitter_img = get_post_meta($post_id, '_siteseo_social_twitter_img', true);
				} elseif(!empty($use_og) && !empty(get_post_meta($post_id, '_siteseo_social_fb_img', true))){ 
					$twitter_img = get_post_meta($post_id, '_siteseo_social_fb_img', true);
				} else if(get_the_post_thumbnail_url($post, 'full')){
					$twitter_img = get_the_post_thumbnail_url($post, 'full');
				} else {
					$twitter_img = isset($siteseo->social_settings['social_twitter_card_img']) ? $siteseo->social_settings['social_twitter_card_img'] : '';
				}

				$site_url = urldecode(get_permalink($post_id));
				break;
			}
		}

		//taxonomies
		foreach($taxonomies as $taxonomy){
			
			if(is_tax($taxonomy->name) || is_category() || is_tag()){
				$term = get_queried_object();
				$term_id = $term->term_id;
				
				$use_og = (empty(get_post_meta($post_id, '_siteseo_social_twitter_title', true)) && empty(get_post_meta($post_id, '_siteseo_social_twitter_desc', true)) && empty(get_post_meta($post_id, '_siteseo_social_twitter_img', true)));
				//twitter:title
				if(!empty(get_term_meta($term_id, '_siteseo_social_twitter_title', true))){
					$site_title = get_term_meta($term_id, '_siteseo_social_twitter_title', true);
				} elseif(!empty($use_og) && !empty(get_term_meta($term_id, '_siteseo_social_fb_title', true))){ 
					$site_title = get_term_meta($term_id, '_siteseo_social_fb_title', true);
				} elseif(!empty(get_term_meta($term_id, '_siteseo_titles_title', true))){
					$site_title = get_term_meta($term_id, '_siteseo_titles_title', true);
				} elseif(!empty($siteseo->titles_settings['titles_tax_titles'][$taxonomy->name]['title'])){
					$site_title = $siteseo->titles_settings['titles_tax_titles'][$taxonomy->name]['title'];
				} else{
					$site_title = $site_title;
				}
				
				// twitter description
				if(!empty(get_term_meta($term_id, '_siteseo_social_twitter_desc', true))){
					$site_description = get_term_meta($term_id, '_siteseo_social_twitter_desc', true);
				} elseif(!empty($use_og) && !empty(get_term_meta($term_id, '_siteseo_social_fb_desc', true))){ 
					$site_description = get_term_meta($term_id, '_siteseo_social_fb_desc', true);
				} elseif(!empty(get_term_meta($term_id, '_siteseo_titles_desc', true))){
					$site_description = get_term_meta($term_id, '_siteseo_titles_desc', true);
				} elseif(!empty($siteseo->titles_settings['titles_tax_titles'][$taxonomy->name]['description'])){
					$site_description = $siteseo->titles_settings['titles_tax_titles'][$taxonomy->name]['description'];
				} else{
					$site_description = wp_strip_all_tags(term_description($term_id));
				}
								
				$twitter_img = !empty(get_term_meta($term_id, '_siteseo_social_twitter_img', true)) ? get_term_meta($term_id, '_siteseo_social_twitter_img', true) : '';
				
				if(empty($twitter_img) && !empty($use_og) && !empty(get_term_meta($term_id, '_siteseo_social_fb_img', true))){
					$twitter_img = get_term_meta($term_id, '_siteseo_social_fb_img', true);
				} else{
					$twitter_img = $twitter_img;
				}
				
				$site_url = urldecode(get_term_link($term_id));
				break;
			}
		}
		
		$site_title = esc_attr(\SiteSEO\TitlesMetas::replace_variables($site_title));
		$site_description = esc_attr(\SiteSEO\TitlesMetas::replace_variables($site_description));
		$x_image_size = 'summary';
		if(!empty($siteseo->social_settings['social_twitter_card_img_size']) && $siteseo->social_settings['social_twitter_card_img_size'] == 'Large'){
			$x_image_size = 'summary_large_image';
		}
		echo '<meta name="twitter:card" content="'.esc_attr($x_image_size).'"/>';
		
		echo '<meta name="twitter:locale" content="'.esc_html(get_locale()).'"/>';
		
		if(!empty($site_title)){
			echo '<meta name="twitter:title"  content="'.esc_html($site_title).'"/>';
		}
		
		if(!empty($site_description)){
			echo '<meta name="twitter:description" content="'.esc_html($site_description).'"/>';
		}
		
		if(!empty($site_url)){
			echo '<meta name="twitter:url" content="'.esc_html($site_url).'"/>';
		}
		
		if(!empty($twitter_user_name)){
			$twitter_user_name = trim($twitter_user_name, '@');
			echo '<meta name="twitter:site" content="@'.esc_html($twitter_user_name).'"/>';
		}
		
		if(!empty($twitter_img)){
			echo '<meta name="twitter:image" content="'.esc_html($twitter_img).'"/>';
		}
	}
}
PKv�f\'��tableofcontent.phpnu�[���<?php
/*
* SITESEO
* https://siteseo.io
* (c) SiteSEO Team
*/

namespace SiteSEO;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

use DOMDocument;
use DOMXPath;

class TableofContent{
	
	static function enable_toc(){
        global $siteseo;

        if(empty($siteseo->setting_enabled['toggle-advanced']) || empty($siteseo->advanced_settings['toc_enable'])){
            return;
        }

        add_filter('the_content', '\SiteSEO\TableofContent::add_ids_to_headings');
    }

	static function render_toc(){
		global $siteseo;
		
		if(empty($siteseo->setting_enabled['toggle-advanced']) || empty($siteseo->advanced_settings['toc_enable'])){
			return;
		}

		static $siteseo_toc_run = false;

		if(!empty($siteseo_toc_run)){
			return '<p style="padding: 1rem; background-color:#fff3cd; color:#664d03; border:1px solid #ffe69c; border-radius: 0.375rem">'.esc_html__('Table of content shortcode can be used only once on a page, this page is using the shortcode more than once. Please remove the extra table of content shortcodes for this warning to go away.', 'siteseo').'</p>';
		}

		$options = get_option('siteseo_advanced_option_name');
		//$options = $siteseo->advanced_settings;
		
		$content = get_the_content();

		if(empty($content)){
			return;
		}

		$heading_type = (!empty($options['toc_heading_type']) ? $options['toc_heading_type'] : 'ul');

		$dom = new DOMDocument();
		$internalErrors = libxml_use_internal_errors(true);
		$dom->preserveWhiteSpace = false;

		$html = '';

		if($dom->loadHTML('<?xml encoding="utf-8" ?>' . $content)){
			$xpath = new DOMXPath($dom);

			$heading_list = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
			
			$headings_to_scan = [];
			foreach($heading_list as $h){
				if(!empty($options['toc_excluded_headings']) && is_array($options['toc_excluded_headings']) && in_array($h, $options['toc_excluded_headings'])){
					continue;
				}

				$headings_to_scan[] = '//'.$h;
			}

			if(empty($headings_to_scan)){
				return;
			}

			$headings_to_scan = implode('|', $headings_to_scan);
			
			// The imploded string will look like this //h1|//h2|//h3|//h4|//h5|//h6 
			$headings = $xpath->query($headings_to_scan);

			if(empty($headings)){
				return;
			}

			$last_h = 0;
			$open_ul = 0;
			
			$html .= '<style>.siteseo-toc-wrapper { padding: 20px; border: 1px solid #a2a9b1; background-color: #f8f9fa;}.siteseo-toc-wrapper p { display:flex; align-items:center; gap: 10px; font-size: 1.5rem; font-weight: 500; margin: 0 0 10px 0;}.siteseo-toc-wrapper > '.esc_html($heading_type).' { margin: 0; padding: 0;}.siteseo-toc-wrapper p>label { font-weight: 400; font-size: 0.9rem;}#siteseo-toc-toggle~span { cursor: pointer;}#siteseo-toc-toggle:checked~.siteseo-toc-hide,p:has(#siteseo-toc-toggle:checked) ~ '.esc_html($heading_type).' { display: none;}#siteseo-toc-toggle:not(:checked) ~ .siteseo-toc-hide{ display: inline;}#siteseo-toc-toggle:not(:checked) ~ .siteseo-toc-show { display: none;}</style>
			<div class="siteseo-toc-wrapper">
			<p>'.(!empty($options['toc_label']) ? esc_html($options['toc_label']) : esc_html__('Table of Content', 'siteseo')).' <label for="siteseo-toc-toggle">
			<input type="checkbox" style="display:none;" id="siteseo-toc-toggle" name="siteseo-toc-toggle"/>
			[<span class="siteseo-toc-hide">hide</span><span class="siteseo-toc-show">show</span>]</label></p>
			<'.esc_html($heading_type).'>';

			foreach($headings as $heading){
				$title = trim(wp_strip_all_tags($heading->nodeValue));
				$id = $heading->getAttribute('id');
				$current_h = (int) substr($heading->tagName, 1);
				
				if(empty($id)){
					$id = '#'.self::title_to_id($title);
				}else{
					$id = '#'.$id;
				}

				if($current_h > $last_h){				
					$html .= '<'.esc_html($heading_type).'>';
					$open_ul++;
				}else{
					while($current_h <= $open_ul){
						$html .= '</'.esc_html($heading_type).'>';
						$open_ul--;
					}
				}

				$html .= '<li><a href="'.esc_attr($id).'">'.esc_html($title).'</a></li>';
				$last_h = $current_h;
			}

			$html .= '</'.esc_html($heading_type).'></div>';
			
			$siteseo_toc_run = true;
		}

		return $html;
	}

	// Converts heading text content to ID to be used as link
	static function title_to_id($title){
		
		$id = trim(wp_strip_all_tags($title));
		$id = remove_accents($title);
		$id = sanitize_title_with_dashes($id);
		$id = urlencode($id);

		return $id;
	}

	static function add_ids_to_headings($content){

		if(empty($content)){
			return $content;
		}

		// If the page does not have the shortcode then we don't need to update the id's in the heading.
		if(!has_shortcode($content, 'siteseo_toc')){
			return $content;
		}
		
		$dom = new DOMDocument();
		$internalErrors = libxml_use_internal_errors(true);
		$dom->preserveWhiteSpace = false;

		$html = '';

		if($dom->loadHTML('<?xml encoding="utf-8" ?>' . $content)){
			$xpath = new DOMXPath($dom);

			$headings = $xpath->query('//h1|//h2|//h3|//h4|//h5|//h6');

			if(empty($headings)){
				return;
			}

			foreach($headings as $heading){
				$title = trim(wp_strip_all_tags($heading->nodeValue));
				$id = $heading->getAttribute('id');
				
				if(!empty($id)){
					continue;
				}
				
				if(empty($title)){
					continue;
				}
				
				$id = self::title_to_id($title);

				$heading->setAttribute('id', $id);
			}

			$content = $dom->saveHTML($dom->documentElement);
		}

		return $content;

	}

}PKv�f\D�q�l#l#instantindexing.phpnu�[���<?php
/*
* SITESEO
* https://siteseo.io
* (c) SiteSEO Team
*/

namespace SiteSEO;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class InstantIndexing{
	
	static function bing_txt_file(){
		global $wp, $siteseo;
		
		$request = home_url($wp->request);
		if(empty($request)){
			return;
		}

		$api_key = $siteseo->instant_settings['instant_indexing_bing_api_key'];
		$api_url = trailingslashit(home_url()) . $api_key . '.txt';
		
		if($request == $api_url){
			header('X-Robots-Tag: noindex');
			header('Content-Type: text/plain');
			status_header(200);

			echo esc_html($api_key);
			die();
		}
	}
	
	static function submit_urls_to_google($urls){
		$access_token = self::get_google_auth_token();

		if(empty($access_token)){
			return;
		}

		$boundary = wp_rand();
		$batch_body = '';
		$options = get_option('siteseo_instant_indexing_option_name');
		$type = !empty($options['instant_indexing_google_action']) ? $options['instant_indexing_google_action'] : 'URL_UPDATED';
		
		switch($type){
			case 'remove_urls':
				$type = 'URL_DELETED';
				break;
			
			case 'update_urls':
				$type = 'URL_UPDATED';
				break;
		}
		
		// Creating a batch request
		foreach($urls as $url){
			$post_data = wp_json_encode(['url' => $url, 'type' => $type]);

			$batch_body .= '--'.$boundary.PHP_EOL;
			$batch_body .= 'Content-Type: application/http'.PHP_EOL;
			$batch_body .= 'Content-Transfer-Encoding: binary'.PHP_EOL;
			$batch_body .= 'Content-ID: <'.esc_url($url).'>'.PHP_EOL.PHP_EOL;
			$batch_body .= 'POST /v3/urlNotifications:publish HTTP/1.1'.PHP_EOL;
			$batch_body .= 'Content-Type: application/json' . PHP_EOL;
			$batch_body .= 'accept: application/json'.PHP_EOL;
			$batch_body .= 'content-length: '.strlen($post_data).PHP_EOL.PHP_EOL;
			$batch_body .= $post_data.PHP_EOL;
		}

		$batch_body .= '--'.$boundary.'--';

		$response = wp_remote_post('https://indexing.googleapis.com/batch', [
			'body' => $batch_body,
			'headers' => [
				'Content-Type' => 'multipart/mixed; boundary='.$boundary,
				'Authorization' => 'Bearer ' . $access_token
			],
			'timeout' => 30
		]);
		
		if(is_wp_error($response)){
			$response = ['error' => $response->get_error_message()];
			return;
		}
		
		$res_code = wp_remote_retrieve_response_code($response);

		if($res_code > 299){
			return $response;
		}
		
		$batch_response = self::parse_batch_response($response);

		$response = [
			'status_code' => wp_remote_retrieve_response_code($response),
			'urls' => $batch_response,
			'error' => is_wp_error($response) ? $response->get_error_message() : null
		];

		return $response;
	}

	static function parse_batch_response(&$response){
		$response_headers = wp_remote_retrieve_headers($response);
		$response_headers = $response_headers->getAll();

		$content_type = $response_headers['content-type'];

		$urls = [];

		$content_type = explode(';', $content_type);
		$boundary = false;
		foreach($content_type as $part){
			$part = explode('=', $part, 2);
			if (isset($part[0]) && 'boundary' == trim($part[0])) {
				$boundary = $part[1];
			}
		}

		$res_body = wp_remote_retrieve_body($response);
		$res_body = str_replace('--'.$boundary.'--', '--'.$boundary, $res_body);
		$batch_responses = explode('--'.$boundary, $res_body);
		$batch_responses = array_filter($batch_responses);

		foreach($batch_responses as $batch_response){
			$batch_response = trim($batch_response);
			if(empty($batch_response)){
				continue;
			}

			$batch_response = explode("\r\n\r\n", $batch_response);

			if(empty($batch_response[2])){
				continue;
			}

			$batch_body = json_decode($batch_response[2], true);

			if(empty($batch_body)){
				continue;
			}

			if(!empty($batch_body['urlNotificationMetadata']) && !empty($batch_body['urlNotificationMetadata']['url'])){
				$urls[] = sanitize_url($batch_body['urlNotificationMetadata']['url']);
			}
		}

		return $urls;
	}
	
	static function get_google_auth_token(){
		global $siteseo;
		
		$endpoint = 'https://oauth2.googleapis.com/token';
		$scope = 'https://www.googleapis.com/auth/indexing';
		
		if(!function_exists('openssl_sign')){
			return false;
		}

		$google_api_data = isset($siteseo->instant_settings['instant_indexing_google_api_key']) ? $siteseo->instant_settings['instant_indexing_google_api_key'] : '';
		
		if(empty($google_api_data)){
			return false;
		}

		$google_api_data = json_decode($google_api_data, true);
		if(empty($google_api_data)){
			return;
		}

		// Header
		$headers = wp_json_encode(['alg' => 'RS256', 'typ' => 'JWT']);
		$headers = base64_encode($headers);

		// Claim Set
		$now = time();
		$claims = wp_json_encode([
			'iss' => $google_api_data['client_email'],
			'scope' => 'https://www.googleapis.com/auth/indexing',
			'aud' => 'https://oauth2.googleapis.com/token',
			'exp' => $now + 3600,
			'iat' => $now
		]);

		$claims = base64_encode($claims);

		// Make sure base64 encoding is URL-safe
		$headers = str_replace(['+', '/', '='], ['-', '_', ''], $headers);
		$claim = str_replace(['+', '/', '='], ['-', '_', ''], $claims);

		// Sign the JWT with the private key
		$signature_input = "$headers.$claim";
		openssl_sign($signature_input, $signature, $google_api_data['private_key'], OPENSSL_ALGO_SHA256);

		$signature = base64_encode($signature);
		$signature = str_replace(['+', '/', '='], ['-', '_', ''], $signature);

		// JWT Token
		$jwt_assertion = "$signature_input.$signature";

		// OAuth2 Request
		$post_data = http_build_query([
			'grant_type' => 'urn:ietf:params:oauth:grant-type:jwt-bearer',
			'assertion' => $jwt_assertion
		]);

		$response = wp_remote_post($endpoint, [
			'body' => $post_data,
			'headers' => [
				'Content-Type' => 'application/x-www-form-urlencoded',
			]
		]);

		if(is_wp_error($response)){
			return false;
		}

		$body = json_decode(wp_remote_retrieve_body($response), true);
		return isset($body['access_token']) ? $body['access_token'] : false;

	}

	/**
	 * Sends request to index now api with list of urls and key and key location.
	 *
	 * Key location is just the URL to a file which has the same name as the Key
	 * as key.txt and the content in it is the key as well. This is a virtual file.
	 *
	 * @param array $urls List of URLs to submit.
	 * @param string $api_key bing key.
	 *
	 * @return array with 'status_code' and response 'body'
	 */
	static function submit_urls_to_bing($urls, $api_key){
        	$host = wp_parse_url(home_url(), PHP_URL_HOST);
		$key_location = trailingslashit(home_url()) . $api_key . '.txt';

		$endpoint = 'https://api.indexnow.org/indexnow/';
		$body = wp_json_encode([
		    'host' => $host, 
		    'key' => $api_key,
				'keyLocation' => $key_location,
		    'urlList' => $urls
		]);

		$response = wp_remote_post($endpoint, [
		    'body' => $body,
		    'headers' => [
		        'Content-Type' => 'application/json',
		        'Accept' => 'application/json'
		    ],
		    'timeout' => 30
		]);

		return [
		    'status_code' => wp_remote_retrieve_response_code($response),
		    'body' => wp_remote_retrieve_body($response)
		];
	}
	
	// Sends request to bing when the status of post changes
	// We will only do it only if the post is published.
	static function on_status_change($new_status, $old_status, $post){

		if($new_status == $old_status){
			return;
		}
		
		if($new_status != 'publish'){
			return;
		}
		
		if(empty($post) || empty($post->post_type)){
			return;
		}
		
		$post_type_object = get_post_type_object($post->post_type);
		
		// Need to make sure we submit posts whos post type is public
		if(empty($post_type_object) || empty($post_type_object->public)){
			return;
		}

		$options = get_option('siteseo_instant_indexing_option_name', []);

		$bing_api_key = !empty($options['instant_indexing_bing_api_key']) ? $options['instant_indexing_bing_api_key'] : '';
		$google_api_key = !empty($options['instant_indexing_google_api_key']) ? $options['instant_indexing_google_api_key'] : '';
		$url = get_permalink($post);

		$url_list = [$url];
		$res_google = null;
		$res_bing   = null;
		
		if(!empty($bing_api_key)){
			$res_bing = self::submit_urls_to_bing($url_list, $bing_api_key);
		}
		
		if(!empty($google_api_key)){
			$res_google = self::submit_urls_to_google($url_list);
		}
		
		self::save_index_history($url_list, $res_google, $res_bing , 'auto');
				
	}
	
	static function save_index_history($urls, $google_response, $bing_response, $source){
		global $siteseo;
		
		$history = $siteseo->instant_settings;

		if(!isset($history['indexing_history'])){
			$history['indexing_history'] = [];
		}

		array_unshift($history['indexing_history'], [
			'time' => time(),
			'urls' => $urls,
			'google_status_code' => !empty($google_response['status_code']) ? $google_response['status_code'] : null,
			'bing_status_code' => !empty($bing_response['status_code']) ? $bing_response['status_code'] : null,
			'source' => !empty($source) ? $source : 'manual', // 'manual' or 'auto'
		]);
		
		$history['indexing_history'] = array_slice($history['indexing_history'], 0, 10);

		update_option('siteseo_instant_indexing_option_name', $history);
	}	
}
PKv�f\u���f�fgoogleanalytics.phpnu�[���<?php
/*
* SITESEO
* https://siteseo.io
* (c) SiteSEO Team
*/

namespace SiteSEO;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class GoogleAnalytics{

	static function ga_render(){
		global $siteseo;
		
		if(empty($siteseo->setting_enabled['toggle-google-analytics'])){
			return;
		}

		if(!empty($siteseo->analaytics_settings['google_analytics_clarity_enable']) && !empty($siteseo->analaytics_settings['google_analytics_clarity_project_id'])){
			add_action('wp_head', '\SiteSEO\GoogleAnalytics::microsoft_clarity');
		}

		if(!empty($siteseo->analaytics_settings['google_analytics_enable']) && !empty($siteseo->analaytics_settings['google_analytics_ga4'])){
			add_action('wp_head', '\SiteSEO\GoogleAnalytics::ga_tracking_code');
		}

		if(!empty($siteseo->analaytics_settings['google_analytics_enable'])){
			add_action('wp_footer', '\SiteSEO\GoogleAnalytics::tracking');
		}

		if(!empty($siteseo->analaytics_settings['google_analytics_link_tracking_enable'])){
			add_action('wp_footer', '\SiteSEO\GoogleAnalytics::add_tracking_script');
		}

		if(!empty($siteseo->analaytics_settings['google_analytics_matomo_enable']) && !empty($siteseo->analaytics_settings['google_analytics_matomo_site_id'])){
			add_action('wp_footer', '\SiteSEO\GoogleAnalytics::matomo_tracking_code');
		}

		if(!empty($siteseo->analaytics_settings['google_analytics_other_tracking'])){
			add_action('wp_head', '\SiteSEO\GoogleAnalytics::add_custom_head_script');
		}

		if(!empty($siteseo->analaytics_settings['google_analytics_other_tracking_body'])){
			add_action('wp_body_open', '\SiteSEO\GoogleAnalytics::add_custom_body_script');
		}

		if(!empty($siteseo->analaytics_settings['google_analytics_other_tracking_footer'])){
			add_action('wp_footer', '\SiteSEO\GoogleAnalytics::add_custom_footer_script');
		}

		if(!empty($siteseo->analaytics_settings['google_analytics_opt_out_edit_choice'])){
			$load_cookies_bar = $siteseo->analaytics_settings['google_analytics_hook'];
			add_action($load_cookies_bar, '\SiteSEO\GoogleAnalytics::render_cookie_bar');
		}
		
	}

	static function render_cookie_bar(){
		global $siteseo;

		if(empty($siteseo->setting_enabled['toggle-google-analytics']) || empty($siteseo->analaytics_settings['google_analytics_disable'])){
			return;
		}

		// Plugin edit pages on which we should not show the cookie notice.
		$page_builders = ['fl_builder', 'elementor-preview', 'ct_builder', 'vc_editable', 'brizy_edit', 'tve', 'pagelayer-live'];

		foreach($page_builders as $builder){
			if(isset($_GET[$builder])){
				return;
			}
		}

		// load setting
		$auto_accept_cookies = !empty($siteseo->analaytics_settings['google_analytics_half_disable']) ? $siteseo->analaytics_settings['google_analytics_half_disable'] : '';
		$cookies_msg = !empty($siteseo->analaytics_settings['google_analytics_opt_out_msg']) ? $siteseo->analaytics_settings['google_analytics_opt_out_msg'] : 'By visiting our site, you agree to our privacy policy regarding cookies, tracking statistics, etc.';
		$accept_btn_msg = !empty($siteseo->analaytics_settings['google_analytics_opt_out_msg_ok']) ? $siteseo->analaytics_settings['google_analytics_opt_out_msg_ok'] : 'Accept';
		$close_btn_msg = !empty($siteseo->analaytics_settings['google_analytics_opt_out_msg_close']) ? $siteseo->analaytics_settings['google_analytics_opt_out_msg_close'] : 'X';
		$edit_btn_msg = !empty($siteseo->analaytics_settings['google_analytics_opt_out_msg_edit']) ? $siteseo->analaytics_settings['google_analytics_opt_out_msg_edit'] : 'Manage cookies';
		$cookies_expir = !empty($siteseo->analaytics_settings['google_analytics_cb_exp_date']) ? $siteseo->analaytics_settings['google_analytics_cb_exp_date'] : '';
		$bar_postion = !empty($siteseo->analaytics_settings['google_analytics_cb_pos']) ? $siteseo->analaytics_settings['google_analytics_cb_pos'] : '' ;
		$bar_width = !empty($siteseo->analaytics_settings['google_analytics_cb_width']) ? $siteseo->analaytics_settings['google_analytics_cb_width'] : '';
		$display_backrop = !empty($siteseo->analaytics_settings['google_analytics_cb_backdrop']) ? true : '';

		// colors load 
		$backdrop_bg = !empty($siteseo->analaytics_settings['google_analytics_cb_backdrop_bg']) ? $siteseo->analaytics_settings['google_analytics_cb_backdrop_bg'] : '';
		$cookiebar_bg = !empty($siteseo->analaytics_settings['google_analytics_cb_bg']) ? $siteseo->analaytics_settings['google_analytics_cb_bg'] : '#ffffff';
		$cookiebar_bg_txt = !empty($siteseo->analaytics_settings['google_analytics_cb_txt_col']) ? $siteseo->analaytics_settings['google_analytics_cb_txt_col'] : '#000000';
		$cookiesbar_bg_lk = !empty($siteseo->analaytics_settings['google_analytics_cb_lk_col']) ? $siteseo->analaytics_settings['google_analytics_cb_lk_col'] : '#0073aa';
		$primary_btn_bg = !empty($siteseo->analaytics_settings['google_analytics_cb_btn_bg']) ? $siteseo->analaytics_settings['google_analytics_cb_btn_bg'] : '#0073aa';
		$primary_btn_bg_hov = !empty($siteseo->analaytics_settings['google_analytics_cb_btn_bg']) ? $siteseo->analaytics_settings['google_analytics_cb_btn_bg'] : '#ffffff';
		$primary_btn_txt = !empty($siteseo->analaytics_settings['google_analytics_cb_btn_col']) ? $siteseo->analaytics_settings['google_analytics_cb_btn_col'] : '#005177';
		$primary_btn_txt_hov = !empty($siteseo->analaytics_settings['google_analytics_cb_btn_col']) ? $siteseo->analaytics_settings['google_analytics_cb_btn_col'] : '#ffffff';
		$sec_btn_bg = !empty($siteseo->analaytics_settings['google_analytics_cb_btn_sec_bg']) ? $siteseo->analaytics_settings['google_analytics_cb_btn_sec_bg'] : '#cccccc';
		$sec_btn_bg_txt = !empty($siteseo->analaytics_settings['google_analytics_cb_btn_sec_col']) ? $siteseo->analaytics_settings['google_analytics_cb_btn_sec_col'] : '#000000';
		$sec_btn_bg_hov = !empty($siteseo->analaytics_settings['google_analytics_cb_btn_sec_bg_hov']) ? $siteseo->analaytics_settings['google_analytics_cb_btn_sec_bg_hov'] : '#aaaaaa';
		$sec_btn_txt_hov = !empty($siteseo->analaytics_settings['google_analytics_cb_btn_sec_col_hov']) ? $siteseo->analaytics_settings['google_analytics_cb_btn_sec_col_hov'] : '#000000';

		//position
		$position_class = '';
		$backdrop = false;
		switch(strtolower($bar_postion)){
			case 'middle':
				$position_class = 'siteseo-cookie-bar-middle';
				$backdrop = true;
				break;
			case 'top':
				$position_class = 'siteseo-cookie-bar-top';
				$backdrop = false;
				break;
			default:
				$position_class = 'siteseo-cookie-bar-bottom';
				$backdrop = false;
		}

		/* Translators: %s is the background color */
		$bar_styles = sprintf(
			'background-color: %s; color: %s;',
			esc_attr($cookiebar_bg),
			esc_attr($cookiebar_bg_txt)
		);

		
		$backdrop_html = '';
		if(!empty($display_backrop) && $backdrop){
			$backdrop_html = '<div id="siteseo-cookie-bar-backdrop" style="background-color:'.esc_attr($backdrop_bg).'" class="siteseo-cookie-bar-backdrop"></div>';
		}

		$css = '<style>
			#siteseo-cookie-bar-accept{
				--primary-btn-bg: '.esc_attr($primary_btn_bg).';
				--primary-btn-text: '.esc_attr($primary_btn_txt).';
				--primary-btn-hover-bg: '.esc_attr($primary_btn_bg_hov).';
				--primary-btn-hover-text: '.esc_attr($primary_btn_txt_hov).';
			}
			#siteseo-cookie-bar-close{
				--secondary-btn-bg: '.esc_attr($sec_btn_bg).';
				--secondary-btn-text: '.esc_attr($sec_btn_bg_txt).';
				--secondary-btn-hover-bg: '.esc_attr($sec_btn_bg_hov).';
				--secondary-btn-hover-text: '.esc_attr($sec_btn_txt_hov).';
			}
		</style>';
		
		$html = $backdrop_html;
		$html .= '<div id="siteseo-cookie-bar" class="siteseo-cookie-bar '.esc_attr($position_class).'" style="'.esc_attr($bar_styles).'" data-half-disable="'.esc_attr($auto_accept_cookies).'">
			<div class="siteseo-cookie-bar-content">
				<span>'.wp_kses_post($cookies_msg).'</span>
				<div class="siteseo-cookie-bar-buttons">
					<button id="siteseo-cookie-bar-accept" class="siteseo-cookie-bar-button siteseo-cookie-bar-primary-btn" style="background-color: '.esc_attr($primary_btn_bg).'; color: '.esc_attr($primary_btn_txt).'">
						'.esc_html($accept_btn_msg).'
					</button>
					<button id="siteseo-cookie-bar-close" class="siteseo-cookie-bar-button siteseo-cookie-bar-secondary-btn" style="background-color: '.esc_attr($sec_btn_bg).'; color: '.esc_attr($sec_btn_bg_txt).'">
						'.esc_html($close_btn_msg).'
					</button>
				</div>
			</div>
		</div>
		<button id="siteseo-cookie-bar-manage-btn" class="siteseo-cookie-bar-button siteseo-cookie-bar-primary-btn" style="background-color: '.$primary_btn_bg.'; color: '.esc_attr($primary_btn_txt).'">
			'.esc_html($edit_btn_msg).'
		</button>';
		
		echo wp_kses_post($html);
	}
	
	static function update_src_tag($tag, $handle, $src){
		global $siteseo;
		
		$tracking_handles = [
			'siteseo-gtag',
			'siteseo-matomo-tracking',
			'siteseo-microsoft-clarity',
			'siteseo-microsoft-clarity-js-after',
			'siteseo-ga-tracking'
		];
		
		if(!in_array($handle, $tracking_handles)){
			return $tag;
		}
		
		if(!empty($siteseo->analaytics_settings['google_analytics_disable']) && !isset($_COOKIE['siteseo-user-consent-accept']) && !isset($_COOKIE['siteseo-user-consent-close'])){
			$tag = str_replace(' src=', ' data-src-siteseo=', $tag);
		}
		
		return $tag;
	}
		
	static function process_script_src($scripts){
		global $siteseo;
		
		if(!empty($siteseo->analaytics_settings['google_analytics_disable']) && !isset($_COOKIE['siteseo-user-consent-accept']) && !isset($_COOKIE['siteseo-user-consent-close'])){
			$scripts = preg_replace('/(<script[^>]*) src=(["\'])(.*?)\\2/i', '$1 data-src-siteseo=$2$3$2', $scripts);
		}
    
		return $scripts;
	}
	
	static function add_custom_head_script(){
		global $siteseo;
        
		$scripts = $siteseo->analaytics_settings['google_analytics_other_tracking'];
       
		$scripts = self::process_script_src($scripts);
        
		echo wp_kses($scripts, [
			'script' => [
				'async' => [],
				'src' => [],
				'data-src-siteseo' => [],
				'type' => []
			]
		]);
	}
	
	static function add_custom_body_script(){
		global $siteseo;
		
		$scripts = $siteseo->analaytics_settings['google_analytics_other_tracking_body'];
		
		$scripts = self::process_script_src($scripts);
		
		echo wp_kses($scripts, [
			'script' => [
				'async' => [],
				'src' => [],
				'data-src-siteseo' => [],
				'type' => []
			]
		]);	
	}
	
	static function add_custom_footer_script(){
		global $siteseo;
		
		$scripts = $siteseo->analaytics_settings['google_analytics_other_tracking_footer'];
		
		$scripts = self::process_script_src($scripts);
		
		echo wp_kses($scripts, [
			'script' => [
				'async' => [],
				'src' => [],
				'data-src-siteseo' => [],
				'type' => []
			]
		]);
	}
	
	static function exclude_user_tracking(){
		global $siteseo;
	
		if(!is_user_logged_in()){
			return false;
		}

		$current_user = wp_get_current_user();
		if(!$current_user){
			return false;
		}

		$excluded_roles = isset($siteseo->analaytics_settings['google_analytics_roles']) ? $siteseo->analaytics_settings['google_analytics_roles'] : [];

		if(empty($excluded_roles)){
			return false;
		}

		foreach($current_user->roles as $user_role){
			if(isset($excluded_roles[$user_role])){
				return true;
			}
		}

		return false;
	}
	
	static function custom_dimensions(){
		global $siteseo;
		$dimensions = [];
		$settings = $siteseo->analaytics_settings;

		// Track Authors
		if(!empty($settings['track_authors']) && $settings['track_authors'] !== 'none'){
			if(is_singular()){
				$author_id = get_post_field('post_author', get_the_ID());
				$author_name = get_the_author_meta('display_name', $author_id);
				$dimensions[$settings['track_authors']] = $author_name;
			}
		}

		// Track Categories
		if(!empty($settings['track_categories']) && $settings['track_categories'] !== 'none'){
			if(is_singular()){
				$categories = get_the_category();
				if(!empty($categories)){
					$category_names = array_map(function($cat){
						return $cat->name;
					}, $categories);
					$dimensions[$settings['track_categories']] = implode(', ', $category_names);
				}
			}
		}

		// Track Tags
		if(!empty($settings['track_tags']) && $settings['track_tags'] !== 'none'){
			if(is_singular()){
				$tags = get_the_tags();
				if(!empty($tags)){
					$tag_names = array_map(function($tag){
						return $tag->name;
					}, $tags);
					$dimensions[$settings['track_tags']] = implode(', ', $tag_names);
				}
			}
		}

		// Track Post Types
		if(!empty($settings['track_post_types']) && $settings['track_post_types'] !== 'none'){
			if(is_singular()){
				$dimensions[$settings['track_post_types']] = get_post_type();
			}
		}

		// Track Logged In Users
		if(!empty($settings['track_user']) && $settings['track_user'] !== 'none'){
			if(is_user_logged_in()){
				$current_user = wp_get_current_user();
				$dimensions[$settings['track_user']] = $current_user->roles[0];
			}
		}

		return $dimensions;
		
	}
	
	static function matomo_tracking_code(){
		global $siteseo;
		
		if(self::exclude_user_tracking()){
			return;
		}
		
		$settings = $siteseo->analaytics_settings;
		
		$tracking_url = !empty($settings['google_analytics_matomo_id']) ? $settings['google_analytics_matomo_id'] : '';
		$site_id = !empty($settings['google_analytics_matomo_site_id']) ? $settings['google_analytics_matomo_site_id'] : '';
		$cross_domain = !empty($settings['google_analytics_matomo_cross_domain']) ? $settings['google_analytics_matomo_cross_domain'] : '';
		$do_not_track = !empty($settings['google_analytics_matomo_dnt']) ? $settings['google_analytics_matomo_dnt'] : '';
		$disable_cookies = !empty($settings['google_analytics_matomo_no_cookies']) ? $settings['google_analytics_matomo_no_cookies'] : '';
		$disable_heatmaps = !empty($settings['google_analytics_matomo_no_heatmaps']) ? $settings['google_analytics_matomo_no_heatmaps'] : '';
		$track_subdomains = !empty($settings['google_analytics_matomo_subdomains']) ? $settings['google_analytics_matomo_subdomains'] : '';
		$track_js_disabled = !empty($settings['google_analytics_matomo_no_js']) ? $settings['google_analytics_matomo_no_js'] : '';
		
		wp_register_script('siteseo-matomo-tracking', false, [], null, [
			'strategy' => true,
			'in_footer' => true,
		]);
		wp_enqueue_script('siteseo-matomo-tracking');
		
		add_filter('script_loader_tag', '\SiteSEO\GoogleAnalytics::update_src_tag', 10, 3);
			wp_add_inline_script('siteseo-matomo-tracking', "var _paq = _paq || [];
			_paq.push(['setSiteId', '".esc_html($site_id)."']);
			_paq.push(['setTrackerUrl', '".esc_html($tracking_url)."']);
            
		    if(".esc_html($cross_domain).") _paq.push(['enableCrossDomainLinking']);
		    if(".esc_html($do_not_track).") _paq.push(['setDoNotTrack', true]);
		    if(".esc_html($disable_cookies).") _paq.push(['disableCookies']);
		    if(".esc_html($disable_heatmaps).") _paq.push(['disableAllHeatmaps']);
		    if(".esc_html($track_subdomains).") _paq.push(['setDocumentTitle', document.domain + '/' + document.title]);

		    _paq.push(['trackPageView']);
		    _paq.push(['enableLinkTracking']);
            
		    (function(){
				var u=\"".esc_html($tracking_url)."\";
		        _paq.push(['setTrackerUrl', u + 'matomo.php']);
				_paq.push(['setSiteId', '".esc_html($site_id)."']);
		        var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
		        g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
		    })();");

		if($track_js_disabled){
			echo '<noscript><img src="'.esc_url($tracking_url.'/matomo.php?idsite='.$site_id.'&rec=1').'" style="border:0" alt="" /></noscript>';
		}
	}
	
	
	static function add_tracking_script(){
		global $siteseo;
		
		if(self::exclude_user_tracking()){
			return;
		}

		echo '<script>
		document.addEventListener("DOMContentLoaded", function() {';

		if(!empty($siteseo->analaytics_settings['google_analytics_link_tracking_enable'])){
			echo 'document.querySelectorAll("a").forEach(function(link){
				if(link.hostname !== location.hostname){
					link.addEventListener("click", function(){
						gtag("event", "click", { "event_category": "External Link", "event_label": link.href });
					});
				}
			});';
		}

		if(!empty($siteseo->analaytics_settings['google_analytics_download_tracking_enable']) && !empty($siteseo->analaytics_settings['google_analytics_download_tracking'])) {

			$fileExtensions = preg_replace('/\s+/', '', $siteseo->analaytics_settings['google_analytics_download_tracking']);
			$fileExtensionsPattern = str_replace('|', '|\\.', $fileExtensions); 

			echo 'document.querySelectorAll("a[href$=\'.' .esc_js(str_replace('|', '\'], a[href$=\'.', $fileExtensions)) . '\']").forEach(function(link) {
				link.addEventListener("click", function() {
					gtag("event", "download", { "event_category": "Download", "event_label": link.href });
				});
			});';
		}

		if(!empty($siteseo->analaytics_settings['google_analytics_affiliate_tracking_enable']) && ! empty($siteseo->analaytics_settings['google_analytics_affiliate_tracking'])){
			$keywords = wp_json_encode( explode( ',', $siteseo->analaytics_settings['google_analytics_affiliate_tracking']));
			echo 'const keywords = '.esc_attr($keywords).';
			document.querySelectorAll("a").forEach(function(link){
				keywords.forEach(function(keyword){
					if(link.href.includes(keyword.trim())){
						link.addEventListener("click", function(){
							gtag("event", "click", { "event_category": "Affiliate/Outbound Link", "event_label": link.href });
						});
					}
				});
			});';
		}

		if(!empty($siteseo->analaytics_settings['google_analytics_phone_tracking'])){
			echo 'document.querySelectorAll("a[href^=\'tel:\']").forEach(function(link){
				link.addEventListener("click", function() {
					gtag("event", "click", { "event_category": "Telephone Link", "event_label": link.href });
				});
			});';
		}

		echo '});
		</script>';
	}
	
	static function tracking(){
		global $siteseo;
		
		if(self::exclude_user_tracking()){
			return;
		}
		
		$settings = $siteseo->analaytics_settings;

		$ga_id = !empty($settings['google_analytics_optimize']) ? $settings['google_analytics_optimize'] : '';
		$conversion_id = !empty($settings['google_analytics_ads']) ? $settings['google_analytics_ads'] : '';
		$optimize_id = !empty($settings['google_analytics_ads']) ? $settings['google_analytics_ads'] : '';
		$remarketing = !empty($settings['google_analytics_remarketing']) ? $settings['google_analytics_remarketing'] : '';
		$anonymize_ip = !empty($settings['google_analytics_ip_anonymization']) ? $settings['google_analytics_ip_anonymization'] : '';
		$enhanced_link = !empty($settings['google_analytics_link_attribution']) ? $settings['google_analytics_link_attribution'] : '';
		$cross_domain = !empty($settings['google_analytics_cross_domain']) ? $settings['google_analytics_cross_domain'] : '';
		$cross_domain_name = !empty($settings['google_analytics_remarketing']) ? $settings['google_analytics_remarketing'] : '';

		//custom dimensions
		$get_custom_dimensions = self::custom_dimensions();
		
		wp_enqueue_script('siteseo-gtag', 'https://www.googletagmanager.com/gtag/js?id=' . esc_attr($ga_id), [], SITESEO_VERSION, [
			'strategy' => 'async',
		]);
		
		add_filter('script_loader_tag', '\SiteSEO\GoogleAnalytics::update_src_tag', 10, 3);
		
		$gtag_config = [
			'anonymize_ip' => $anonymize_ip ? true : false,
			'link_attribution' => $enhanced_link ? true : false,
		];

		if($cross_domain && $cross_domain_name){
			$gtag_config['linker'] = [
				'domains' => [$cross_domain_name]
			];
		}

		// config
		foreach($get_custom_dimensions as $dimension => $value){
			$gtag_config[$dimension] = $value;
		}

		$inline_script = 'window.dataLayer = window.dataLayer || [];
		function gtag(){dataLayer.push(arguments);}
		gtag("js", new Date());

		window.addEventListener("load", function (){
			var links = document.querySelectorAll("a");
			for(let i = 0; i < links.length; i++){
				links[i].addEventListener("click", function(e) {
					var n = this.href.includes("' . wp_parse_url(home_url(), PHP_URL_HOST) . '");
					if (n == false) {
						gtag("event", "click", {"event_category": "external links","event_label" : this.href});
					}
				});
			}
		});

		gtag("config", "'.esc_js($ga_id).'", '.wp_json_encode($gtag_config).');';

		if($optimize_id){
			$inline_script .= 'gtag("config", "'.esc_js($optimize_id).'");';
		}
		
		if($conversion_id){
			$inline_script .= 'gtag("config", "'.esc_js($conversion_id).'");';
		}
		
		if($remarketing){
			$inline_script .= 'gtag("set", "allow_google_signals", true);';
		}

		wp_add_inline_script('siteseo-gtag', $inline_script);
	}
	
	static function microsoft_clarity(){
		global $siteseo;

		if(self::exclude_user_tracking()){
			return;
		}

		$project_id = !empty($siteseo->analaytics_settings['google_analytics_clarity_project_id']) ? $siteseo->analaytics_settings['google_analytics_clarity_project_id'] : '';

		if(empty($project_id)){
			return;
		}
		
		wp_register_script('siteseo-microsoft-clarity', '', [], SITESEO_VERSION, true);
		
		wp_enqueue_script('siteseo-microsoft-clarity');

		$inline_script = "(function(c,l,a,r,i,t,y){ 
			c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
			t=l.createElement(r);t.async=1;t.src='https://www.clarity.ms/tag/'+i;
			y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
			})(window, document, 'clarity', 'script', '".esc_js($project_id)."');";

		wp_add_inline_script('siteseo-microsoft-clarity', $inline_script);
		
		add_filter('script_loader_tag', '\SiteSEO\GoogleAnalytics::update_src_tag', 10, 3);
		
	}

	static function ga_tracking_code(){
		global $siteseo;
		
		if(self::exclude_user_tracking()){
			return;
		}

		$ga_id = isset($siteseo->analaytics_settings['google_analytics_ga4']) ? esc_attr($siteseo->analaytics_settings['google_analytics_ga4']) : '';
		
		if(empty($ga_id)){
			return;
		}

		wp_enqueue_script('siteseo-ga-tracking', 'https://www.googletagmanager.com/gtag/js?id=' . $ga_id, [], SITESEO_VERSION, true);
		
		add_filter('script_loader_tag', '\SiteSEO\GoogleAnalytics::add_async_attribute', 10, 2);
		
		$inline_script = "
			window.dataLayer = window.dataLayer || [];
			function gtag(){dataLayer.push(arguments);}
			gtag('js', new Date());
			gtag('config', '{$ga_id}');
		";
		
		wp_add_inline_script('siteseo-ga-tracking', $inline_script);

	}
	
	static function add_async_attribute($tag, $handle){
		global $siteseo;
		if('siteseo-ga-tracking' === $handle){
       			
			if(!empty($siteseo->analaytics_settings['google_analytics_disable'])){
				if(isset($_COOKIE['siteseo-user-consent-accept']) && $_COOKIE['siteseo-user-consent-accept'] === 'true'){
					return str_replace(' src', ' async src', $tag);
				} else{
					return str_replace(' src', ' data-src-siteseo', $tag);
				}
			}
		}
		
		return $tag;
	}
	
	/** TODO:: temporary in this file*/	
	 static function handle_custom_redirect(){
		global $post;

		// post types and taxonomies
		$post_types = siteseo_post_types();
		$taxonomies = get_taxonomies(array('public' => true), 'objects');


		$is_singular = false;
		foreach($post_types as $post_type){
			if(is_singular($post_type->name)){
				$is_singular = true;
				break;
			}
		}

		$is_taxonomy = false;
		foreach($taxonomies as $taxonomy){
			if(is_tax($taxonomy->name)){
				$is_taxonomy = true;
				break;
			}
		}

		if($is_singular || is_404() || $is_taxonomy || is_category() || is_tag()){
			if(is_404()){
				$args = array(
					'post_type' => 'siteseo_404',
					'posts_per_page' => 1,
					'meta_query' => array(
						array(
							'key' => '_siteseo_redirections_enabled',
							'value' => 'yes',
							'compare' => '='
						)
					)
				);
				$redirect_posts = get_posts($args);

				if(empty($redirect_posts)){
					return;
				}
				$post = $redirect_posts[0];
			}

			// Taxonomy archives
			if($is_taxonomy || is_category() || is_tag()){
				$term = get_queried_object();
				$term_id = $term->term_id;

				// Check redirection is enabled
				$enable_redirect = get_term_meta($term_id, '_siteseo_redirections_enabled', true);

				if(empty($enable_redirect)){
					return;
				}

				$login_status = get_term_meta($term_id, '_siteseo_redirections_logged_status', true);
				$redirect_type = get_term_meta($term_id, '_siteseo_redirections_type', true);
				$redirect_url = get_term_meta($term_id, '_siteseo_redirections_value', true);
				$param_handling = get_term_meta($term_id, '_siteseo_redirections_param', true);
			}
			// Singular posts, pages, and products
			else{
				$enable_redirect = get_post_meta($post->ID, '_siteseo_redirections_enabled', true);

				if(empty($enable_redirect)){
					return;
				}

				$login_status = get_post_meta($post->ID, '_siteseo_redirections_logged_status', true);
				$redirect_type = get_post_meta($post->ID, '_siteseo_redirections_type', true);
				$redirect_url = get_post_meta($post->ID, '_siteseo_redirections_value', true);
				$param_handling = get_post_meta($post->ID, '_siteseo_redirections_param', true);
			}

			if($login_status === 'only_logged_in' && !is_user_logged_in()){
				return;
			}

			if($login_status === 'only_not_logged_in' && is_user_logged_in()){
				return;
			}

			if(!empty($redirect_url)){
				$final_url = $redirect_url;
				
				if(is_404() && !empty($_SERVER['QUERY_STRING'])){
					switch($param_handling){
						case 'exact_match':
							$current_params = sanitize_text_field(wp_unslash($_SERVER['QUERY_STRING']));
							$redirect_params = wp_parse_url($redirect_url, PHP_URL_QUERY);
							if($current_params !== $redirect_params){
								return;
							}
							break;
							
						case 'without_param':
							$final_url = strtok($redirect_url, '?');
							break;
							
						case 'with_ignored_param':
							$query_string = sanitize_text_field(wp_unslash($_SERVER['QUERY_STRING']));
							$final_url = $redirect_url;
							if(!empty($query_string)){
								$final_url .= (strpos($redirect_url, '?') !== false ? '&' : '?') . $query_string;
							}
							break;
					}
				}

				$status_code = !empty($redirect_type) ? intval($redirect_type) : 301;
				
				if(in_array($status_code, [410, 451]) && is_404()){
					status_header($status_code);
					nocache_headers();
					include(get_query_template('404'));
					exit;
				}

				wp_redirect($final_url, $status_code);
				exit;
			}
		}
	}
}
PKv�f\wNg6�c�cgeneratesitemap.phpnu�[���<?php
/*
* SITESEO
* https://siteseo.io
* (c) SiteSEO Team
*/

namespace SiteSEO;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class GenerateSitemap{
	
	private static $paged = 1;

	static function settings(){
		global $siteseo;

		if(empty($siteseo->setting_enabled['toggle-xml-sitemap'])){
			return;	
		}
		
		if(!empty($siteseo->sitemap_settings['xml_sitemap_html_enable'])){
			add_shortcode('siteseo_html_sitemap', '\SiteSEO\GenerateSitemap::html_sitemap');
		}

		if(!empty($siteseo->sitemap_settings['xml_sitemap_general_enable'])){
			self::xml_sitemap();
		}
	}

	static function xml_sitemap(){
		add_filter('query_vars', function($vars){
			$vars[] = 'sitemap_type';
			$vars[] = 'paged';
			$vars[] = 'sitemap-stylesheet';
			return $vars;
		});
	}

	static function add_rewrite_rules(){
		global $siteseo;
		
		add_rewrite_rule('^sitemaps\.xsl$', 'index.php?sitemap-stylesheet=sitemap', 'top');
		add_rewrite_rule('^sitemaps\.xml$', 'index.php?sitemap_type=general', 'top');
		add_rewrite_rule('^author.xml$', 'index.php?sitemap_type=author', 'top');
		add_rewrite_rule('^media-sitemap([0-9]+)?.xml$', 'index.php?sitemap_type=media&paged=$matches[1]', 'top');
		add_rewrite_rule('^news([0-9]+)?.xml$', 'index.php?sitemap_type=news&paged=$matches[1]', 'top');
		add_rewrite_rule('^video-sitemap([0-9]+)?.xml$', 'index.php?sitemap_type=video&paged=$matches[1]', 'top');
		
		if(isset($siteseo->sitemap_settings['xml_sitemap_post_types_list'])){
            foreach($siteseo->sitemap_settings['xml_sitemap_post_types_list'] as $post_type => $settings){
                if(!empty($settings['include'])){
                    add_rewrite_rule('^'.$post_type.'-sitemap([0-9]+)?\.xml$', 'index.php?sitemap_type='.$post_type.'&paged=$matches[1]', 'top');
                }
            }
        }

        if(isset($siteseo->sitemap_settings['xml_sitemap_taxonomies_list'])){
            foreach($siteseo->sitemap_settings['xml_sitemap_taxonomies_list'] as $taxonomy => $settings){
                if(!empty($settings['include'])){
                    add_rewrite_rule('^'.$taxonomy.'-sitemap([0-9]+)?\.xml$', 'index.php?sitemap_type='.$taxonomy.'&paged=$matches[1]', 'top');
                }
            }
        }

		flush_rewrite_rules();
    }


	static function handle_sitemap_requests(){
		global $siteseo;

		$pro_settings = isset($siteseo->pro) ? $siteseo->pro : '';
		self::maybe_redirect();

		// Output the Sitemap style
		if(get_query_var('sitemap-stylesheet') === 'sitemap'){
			self::sitemap_xsl();
			exit;
		}
		
		if(get_query_var('paged')){
			self::$paged = get_query_var('paged');
		}
		
		$type = get_query_var('sitemap_type');
		if(!empty($type)){
			
			if($type === 'news' && !empty($pro_settings['google_news']) && !empty($pro_settings['toggle_state_google_news'])){
				
				self::generate_google_news_sitemap();
				exit;
			}
			
			if($type === 'video' && !empty($pro_settings['toggle_state_video_sitemap']) && !empty($pro_settings['enable_video_sitemap'])){
				self::generate_video_sitemap();
				exit;
			}

			// Custom post type
			if(isset($siteseo->sitemap_settings['xml_sitemap_post_types_list'][$type]) && !empty($siteseo->sitemap_settings['xml_sitemap_post_types_list'][$type]['include'])){
				self::generateSitemap($type);
				exit;
			}

			//custom taxomies type
			if(isset($siteseo->sitemap_settings['xml_sitemap_taxonomies_list'][$type]) && !empty($siteseo->sitemap_settings['xml_sitemap_taxonomies_list'][$type]['include'])){
				self::generate_term_sitemap($type);
				exit;
			}
 
			switch($type){
				case 'general':
					self::generate_index_sitemap();
					break;
				case 'post':
					self::generateSitemap('post');
					break;
				case 'page':
					self::generateSitemap('page');
					break;
				case 'category':
					self::generate_term_sitemap('category');
					break;
				case 'post_tag':
					self::generate_term_sitemap('post_tag');
					break;
				case 'author':
					self::generate_author_sitemap();
					break;
				case 'news':
					self::generate_google_news_sitemap();
					break;
				case 'video':
					self::generate_video_sitemap();
					break;
				default:
					wp_die(esc_html__('Invalid sitemap type.', 'siteseo'));
 			}
 		}
	}
	
	static function generate_index_sitemap(){
		global $siteseo;
		
		$pro_settings = isset($siteseo->pro) ? $siteseo->pro : '';

		header('Content-Type: application/xml; charset=UTF-8');
		
		if(get_option('permalink_structure')){
			$xsl_url = home_url('/sitemaps.xsl');
		} else {
			$xsl_url = home_url('/?sitemaps-stylesheet=sitemap');
		}

		echo '<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="' . esc_url($xsl_url) . '" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';

		// Post types
		if(isset($siteseo->sitemap_settings['xml_sitemap_post_types_list'])){
			foreach($siteseo->sitemap_settings['xml_sitemap_post_types_list'] as $post_type => $settings){
				$posts = get_posts(
					[
						'post_type' => $post_type,
						'fields'=> 'ids',
						'numberposts' => -1,
						'post_status' => 'publish',
						'has_password' => false,
						'no_found_rows' => true,
						'ignore_sticky_posts' => true,
						'update_post_term_cache' => false,
					]
				);

				if(empty($posts)){
					continue;
				}

				$total_pages = (int) ceil(count($posts) / 1000);

				if(!empty($settings['include']) && !empty($total_pages)){
					$last_post = get_posts([
						'post_type' => $post_type,
						'numberposts' => 1,
						'post_status' => 'publish',
						'orderby' => 'modified',
						'order' => 'DESC',
						'fields' => 'ids',
					]);
					
					$lastmod = !empty($last_post) ? get_post_modified_time('c', true, $last_post[0]) : current_time('c');
					
					for($page = 1; $page <= $total_pages; $page++){					
						echo '<sitemap>
							<loc>'.esc_url(home_url("/$post_type-sitemap$page.xml")).'</loc>
							<lastmod>'.esc_xml($lastmod).'</lastmod>
						</sitemap>';
					}
				}
			}
		}

		// Taxonomies
		if(isset($siteseo->sitemap_settings['xml_sitemap_taxonomies_list'])){
			foreach($siteseo->sitemap_settings['xml_sitemap_taxonomies_list'] as $taxonomy => $settings){
				
				$args = [
					'taxonomy' => $taxonomy,
					'hide_empty' => true,
					'fields' => 'count',
					'hierarchical' => false,
					'update_term_meta_cache' => false,
				];
				
				$tax_count = get_terms($args);

				if(is_wp_error($tax_count) || $tax_count == 0){
					continue;
				}

				$total_pages = (int) ceil($tax_count/2000);
				
				if(!empty($settings['include']) && $total_pages > 0){
					$terms = get_terms([
						'taxonomy' => $taxonomy,
						'number' => 1,
						'orderby' => 'term_order',
						'order' => 'DESC',
						'fields' => 'ids',
					]);
					
					$lastmod = !empty($terms) ? current_time('c') : current_time('c'); // taxonomy terms don't have modified, fallback
					
					for($page = 1; $page <= $total_pages; $page++){
						echo '<sitemap>	
							<loc>'.esc_url(home_url("/$taxonomy-sitemap$page.xml")).'</loc>
							<lastmod>'.esc_xml($lastmod).'</lastmod>
						</sitemap>';
					}
				}
			}
		}

		// Author
		if(!empty($siteseo->sitemap_settings['xml_sitemap_author_enable'])){
			echo '<sitemap>
				<loc>'.esc_url(home_url('/author.xml')).'</loc>
				<lastmod>'.esc_xml(current_time('c')).'</lastmod>
			</sitemap>';
		}
		
		// Google News
		if(!empty($pro_settings['google_news']) && !empty($pro_settings['toggle_state_google_news'])){
			echo '<sitemap>
				<loc>'.esc_url(home_url('/news.xml')).'</loc>
				<lastmod>'.esc_xml(current_time('c')).'</lastmod>
			</sitemap>';
		}
		
		// Video
		if(!empty($pro_settings['toggle_state_video_sitemap']) && !empty($pro_settings['enable_video_sitemap'])){
			$video_posts = get_posts([
				'post_type' => $pro_settings['video_sitemap_posts'],
				'fields' => 'ids',
				'numberposts' => 1,
				'orderby' => 'modified',
				'order' => 'DESC',
				'fields' => 'ids',
				'meta_query' => [
					[
						'key' => '_siteseo_video_disabled',
						'compare' => 'NOT EXISTS'
					]
				]
			]);
				
				
			$lastmod = !empty($video_posts) ? get_post_modified_time('c', true, $video_posts[0]) : current_time('c');
			
				for($page = 1; $page <= $total_pages; $page++){
					echo '<sitemap>
						<loc>'.esc_url(home_url("/video-sitemap$page.xml")).'</loc>
						<lastmod>'.esc_xml($lastmod).'</lastmod>
					</sitemap>';
				}

		}
		
		echo '</sitemapindex>';
		exit;
	}

	// post
	static function generate_post_sitemap(){
		self::generateSitemap('post');
	}

	// page
	static function generate_page_sitemap(){
		self::generateSitemap('page');
	}

	// category 
	static function generate_category_sitemap(){
		self::generate_term_sitemap('category');
	}

	//post tag
	static function generate_post_tag_sitemap(){
		self::generate_term_sitemap('post_tag');
	}

	// taxonomy
	static function generate_taxonomy_sitemap(){
		self::generate_term_sitemap('taxonomy');
	}

	// google news pro feature
	static function generate_google_news_sitemap(){
		
		if(class_exists('\SiteSEOPro\GoogleNews') && method_exists('\SiteSEOPro\GoogleNews', 'google_news_sitemap')){
			\SiteSEOPro\GoogleNews::google_news_sitemap();
		}
	}
	
	// video sitemap pro feature
	static function generate_video_sitemap(){
		if(class_exists('\SiteSEOPro\VideoSitemap') && method_exists('\SiteSEOPro\VideoSitemap', 'render_sitemap')){
			\SiteSEOPro\VideoSitemap::render_sitemap();
		}
	}

	static function generateSitemap($post_type){
		global $siteseo;
		
		header('Content-Type: application/xml; charset=utf-8');
		
		$offset = (1000*(self::$paged - 1));

		$posts = get_posts(
		[
			'post_type' => $post_type,
			'post_status' => 'publish',
			'numberposts' => 1000,
			'offset' => $offset,
			'order' => 'DESC',
			'orderby' => 'modified',
			'has_password' => false,
			'no_found_rows' => true,
			'lang' => 'all',
			'meta_query' => [
			[
				'key' => '_siteseo_robots_index',
				'compare' => 'NOT EXISTS'
			]]
		]);

		if(get_option('permalink_structure')){
			$xsl_url = home_url('/sitemaps.xsl');
		} else {
			$xsl_url = home_url('/?sitemaps-stylesheet=sitemap');
		}

		echo '<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="' . esc_url($xsl_url) . '" ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" '.((!empty($siteseo->sitemap_settings['xml_sitemap_img_enable'])) ? 'xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"' : '').'>';

		if(self::$paged == 1){
			if(get_option('show_on_front') === 'page' && get_option('page_on_front')){
				echo "\t".'<url>
				<loc>'.esc_url(trailingslashit(home_url())).'</loc>
				<lastmod>'.esc_html(get_the_modified_date('c', get_option('page_on_front'))).'</lastmod>
				</url>';
			} else{
				echo "\t".'<url>
				<loc>'.esc_url(trailingslashit(home_url())).'</loc>
				</url>';
			}
		}

		foreach($posts as $post){
				
			if($post->ID == get_option('page_on_front')){
				continue;
			}
			
			$image_xml = '';
			if(!empty($siteseo->sitemap_settings['xml_sitemap_img_enable'])){
				$images = self::get_page_images($post);
				if(!empty($images)){
					foreach($images as $image){
						$image_xml .= "<image:image>\n";
						$image_xml .= "\t\t\t<image:loc>".esc_url($image)."</image:loc>\n";
						$image_xml .= "\t\t</image:image>";
					}
				}
			}

			echo "\t<url>
				<loc>".esc_url(get_permalink($post->ID))."</loc>
				<lastmod>".esc_html(get_the_modified_date('c', $post->ID))."</lastmod>
				".$image_xml."
			</url>";
		}

		echo '</urlset>';
		exit;
	}

	static function generate_term_sitemap($taxonomy){
		header('Content-Type: application/xml; charset=utf-8');
		
		$offset = (2000*(self::$paged - 1));

		if(get_option('permalink_structure')){
			$xsl_url = home_url('/sitemaps.xsl');
		} else {
			$xsl_url = home_url('/?sitemaps-stylesheet=sitemap');
		}

		echo '<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="' . esc_url($xsl_url) . '" ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
		$terms = get_terms([
			'taxonomy' => $taxonomy,
			'hide_empty' => false,
			'number' => 2000,
			'offset' => $offset,
			'hierarchical' => false,
			'update_term_meta_cache' => false,
			'lang' => 'all',
			'meta_query' => [
			[
				'key' => '_siteseo_robots_index',
				'compare' => 'NOT EXISTS'
			]]
		]);

		foreach($terms as $term){
			
			// most recent post in this term to determine lastmod date
			$recent_posts = get_posts([
				'tax_query' => [
					[
						'taxonomy' => $taxonomy,
						'field' => 'term_id',
						'terms' => $term->term_id,
					]
				],
				'numberposts' => 1,
				'orderby' => 'modified',
				'order' => 'DESC',
				'post_status' => 'publish'
			]);

			$last_mod = '';
			if(!empty($recent_posts)){
				$last_mod = "\n\t\t".'<lastmod>'.esc_html(get_the_modified_date('c', $recent_posts[0]->ID)).'</lastmod>';
			}
			
			echo "\t". '<url>
			<loc>'.esc_url(get_term_link($term)).'</loc>'.$last_mod.'
			</url>';
		}

		echo '</urlset>';
		exit;
	}

	static function generate_author_sitemap(){
		header('Content-Type: application/xml; charset=utf-8');

		if(get_option('permalink_structure')){
			$xsl_url = home_url('/sitemaps.xsl');
		} else {
			$xsl_url = home_url('/?sitemaps-stylesheet=sitemap');
		}

		echo '<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="' . esc_url($xsl_url) . '" ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';

		// Fetch all authors
 		$authors = get_users(
			['capability' => ['publish_posts']]
		);

		foreach($authors as $author){
			// get the last modified date of the author's most recent post
			$last_post = get_posts([
				'author' => $author->ID,
				'numberposts' => 1,
				'orderby' => 'modified',
				'order' => 'DESC',
				'post_status' => 'publish'
			]);
			
			$lastmod_date = '';
			if(!empty($last_post)){
				$lastmod_date = get_the_modified_date('c', $last_post[0]->ID);
			} else{
				// user registration date if no posts
				$lastmod_date = gmdate('c', strtotime($author->user_registered));
			}

			echo "\t".'<url>
			<loc>'.esc_url(get_author_posts_url($author->ID)).'</loc>
			<lastmod>'.esc_html($lastmod_date).'</lastmod>
		</url>';
		}

		echo '</urlset>';
		exit;
	}

	static function html_sitemap($atts = []){
		global $siteseo;

		$atts = shortcode_atts(
			[
				'cpt' => '', // Default
			],
			$atts,
			'siteseo_html_sitemap'
		);

		$disable_date = !empty($siteseo->sitemap_settings['xml_sitemap_html_date']);
		$order_by = !empty($siteseo->sitemap_settings['xml_sitemap_html_orderby']) ? $siteseo->sitemap_settings['xml_sitemap_html_orderby']  : 'date';
		$order = !empty($siteseo->sitemap_settings['xml_sitemap_html_order']) ? $siteseo->sitemap_settings['xml_sitemap_html_order'] : 'DESC';		
		$exclude_string = isset($siteseo->sitemap_settings['xml_sitemap_html_exclude']) ? $siteseo->sitemap_settings['xml_sitemap_html_exclude'] : '';
		$exclude_pages = [];
		if(!empty($exclude_string)){
			$exclude_pages = array_map('trim', explode(',', $exclude_string));
		}

		$output = '';

		if($order !== 'ASC' && $order !== 'DESC'){
			$order = 'DESC';
		}

		$orderby_map = [
			'post_title' => 'title',
			'modified_date' => 'modified',
			'post_id' => 'ID',
			'menu_order' => 'menu_order',
			'date' => 'date', // Default
		];

		$orderby = !empty($orderby_map[$order_by]) ? $orderby_map[$order_by] : 'date';
		$cpt_list = !empty($atts['cpt']) ? explode(',', $atts['cpt']) : [];

		if(!empty($siteseo->sitemap_settings['xml_sitemap_post_types_list'])){ 
			foreach($siteseo->sitemap_settings['xml_sitemap_post_types_list'] as $post_type => $settings){
				if(!empty($settings['include']) && (empty($cpt_list) || in_array($post_type, $cpt_list))){

					$output .= '<h2>'.esc_html(ucfirst($post_type)).'</h2>';

					$args = [
						'post_type' => $post_type,
						'post_status' => 'publish',
						'numberposts' => -1,
						'orderby' => $orderby,
						'order' => $order,
					];

					$posts = get_posts($args);

					if(!empty($posts)){
						$output .= '<ul>';
						foreach($posts as $post){
							if(in_array($post->ID, $exclude_pages)){
								continue;
							}

							$post_title = get_the_title($post->ID) ?: $post->ID;

							$output .= '<li><a href="'.esc_url(get_permalink($post->ID)).'">'.esc_html($post_title).'</a>';

							if(!$disable_date){
								$output .= '<span class="post-date"> - '.esc_html(get_the_modified_date('j F Y', $post->ID)).'</span>';
							}

							$output .= '</li>';
						}
						$output .= '</ul>';
					}else{
						$output .= '';
					}
				}
			}
		}

		return $output;
	}
	
	static function sitemap_xsl(){
		global $siteseo;
		
		$pro_settings = isset($siteseo->pro) ? $siteseo->pro : '';
		$title = __('XML Sitemap', 'siteseo');
		$generated_by = __('Generated by SiteSEO', 'siteseo');
		$sitemap_index_txt = __('This XML Sitemap Index file contains', 'siteseo');
		$sitemap_count_txt = __('This XML Sitemap contains', 'siteseo');
		$image_count_txt = __('Images', 'siteseo');
		$last_modified_txt = __('Last Modified', 'siteseo');
		$index_sitemap_url = home_url('/sitemaps.xml');
		
		$image_sitemap_enabled = !empty($siteseo->sitemap_settings['xml_sitemap_img_enable']) ? true : false; 
		$video_sitemap_enabled = !empty($pro_settings['toggle_state_video_sitemap']) && !empty($pro_settings['enable_video_sitemap']) ? true : false;
		
		header('Content-Type: application/xml; charset=UTF-8');

		echo '<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
	xmlns:html="http://www.w3.org/TR/REC-html40"
	xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"';
	
	if(!empty($pro_settings['toggle_state_google_news']) && !empty($pro_settings['google_news'])){
		echo "\t" .'xmlns:news="https://www.google.com/schemas/sitemap-news/0.9/"';
	}
    
	if(!empty($pro_settings['toggle_state_video_sitemap']) && !empty($pro_settings['enable_video_sitemap'])){
			echo "\t" .'xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"';
    	}
    
	echo "\t" .'xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
	<xsl:template match="/">
		<html xmlns="http://www.w3.org/1999/xhtml">
			<head>
				<title>'.esc_xml($title).'</title>
				<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
				<style>
					* {
						box-sizing: border-box;
					}
					body{
						font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
						background-color: #f0f2f5;
						margin: 0;
						padding: 0;
						overflow-x: hidden;
					}
					header{
						background: linear-gradient(135deg, #022448, #034f84);
						padding: 20px;
						color: #ffffff;
						text-align: center;
						width: 100%;
						margin-bottom:15px;
					}
					header h1{
						font-size: 32px;
						margin: 0;
					}
					header p{
						margin: 5px 0 0;
						font-size: 16px;
						text-decoration: underline;
					}
					header .siteseo-index-link a{
						color: #ffffff;
						text-decoration: none;
					}
					header .siteseo-index-link a:hover{
						text-decoration: underline;
					}
					.siteseo-sitemap-container{
						width: 60%;
						margin: 0 auto;
						margin-bottom: 10px;
					}
					.siteseo-sitemap-container a{
						color:#007bff;
						text-decoration: none;
					}

					.siteseo-sitemap-table-wrap{
						background-color: #ffffff;
						box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
						border-radius: 8px;
						margin-top:10px;
						overflow:auto;
					}

					table{
						width: 100%;
						border-collapse: collapse;
					}
					table thead tr{
						background-color: #034f84;
						color: #ffffff;
					}
					table th, table td{
						padding: 10px;
						text-align: left;
					}
					table tbody tr:nth-child(even){
						background-color: #f9f9f9;
					}
					.siteseo-video-thumbnail{
					        max-width: 160px;
					        max-height: 120px;
					        border-radius: 4px;
					}
					.siteseo-video-info{
						margin-left: 15px;
					}
					.siteseo-video-container{
						display: flex;
						align-items: center;
						margin: 10px 0;
					}
					.siteseo-video-title{
						font-weight: bold;
						margin-bottom: 5px;
					}
					.siteseo-video-description{
						color: #555;
						font-size: 14px;
						margin-bottom: 5px;
					}
					.siteseo-video-meta{
						font-size: 13px;
						color: #777;
					}
					.siteseo-video-url{
						word-break: break-all;
						font-size: 13px;
						color: #007bff;
					}
				</style>
			</head>
			<body>
				<header>
					<h1>'.esc_xml($title).'</h1>
					<span>'.esc_xml($generated_by).'</span>
					<xsl:if test="count(sitemap:sitemapindex/sitemap:sitemap) &gt; 0">
						<div class="siteseo-description" style="text-align:center;">'.esc_xml($sitemap_index_txt).' <xsl:value-of select="count(sitemap:sitemapindex/sitemap:sitemap)"/> sitemaps</div>
					</xsl:if>
					
					<xsl:if test="count(sitemap:sitemapindex/sitemap:sitemap) &lt; 1">
						<div class="siteseo-description" style="text-align:center;">'.esc_xml($sitemap_count_txt).' <xsl:value-of select="count(sitemap:urlset/sitemap:url)"/> URLs</div>
					</xsl:if>
				</header>
				<div class="siteseo-sitemap-container">
					<xsl:if test="count(sitemap:sitemapindex/sitemap:sitemap) &lt; 1">
					<a href="'.esc_url($index_sitemap_url).'">Index Sitemap</a>
					</xsl:if>
					<div class="siteseo-sitemap-table-wrap">
						<table>
						<xsl:if test="count(sitemap:sitemapindex/sitemap:sitemap) &gt; 0">
						<thead>
							<tr>
								<th>URL</th>
								<th>Last Modified</th>
							</tr>
						</thead>
						<tbody>
							<xsl:for-each select="sitemap:sitemapindex/sitemap:sitemap">
								<tr>
									<td><a href="{sitemap:loc}"><xsl:value-of select="sitemap:loc"/></a></td>
									<td>
										<xsl:value-of select="sitemap:lastmod"/>
										<xsl:if test="not(sitemap:lastmod)">-</xsl:if>
									</td>
								</tr>
							</xsl:for-each>
						</tbody>
						</xsl:if>
						
						<xsl:if test="count(sitemap:sitemapindex/sitemap:sitemap) &lt; 1">';
						
						if($video_sitemap_enabled && class_exists('\SiteSEOPro\VideoSitemap') && method_exists('\SiteSEOPro\VideoSitemap', 'render_video_xsl')){
							 echo'<xsl:if test="sitemap:urlset/sitemap:url/video:video">'
									. \SiteSEOPro\VideoSitemap::render_video_xsl() .
								'</xsl:if>
								<xsl:if test="not(sitemap:urlset/sitemap:url/video:video)">
									<thead>
										<tr>
											<th>URL</th>';
											if(!empty($image_sitemap_enabled)){
												echo'<th>'.esc_xml($image_count_txt).'</th>';
											}
											
										echo'<th>'.esc_xml($last_modified_txt).'</th>
										</tr>
									</thead>
									<tbody>
										<xsl:for-each select="sitemap:urlset/sitemap:url">
											<tr>
												<td><a href="{sitemap:loc}"><xsl:value-of select="sitemap:loc"/></a></td>';
												
												if(!empty($image_sitemap_enabled)){
													echo'<td>
														<xsl:value-of select="count(image:image)"/>
													</td>';
												}
												
												echo'<td><xsl:value-of select="sitemap:lastmod"/></td>
											</tr>
										</xsl:for-each>
									</tbody>
								</xsl:if>';
						} else {
							echo'<xsl:if test="count(sitemap:sitemapindex/sitemap:sitemap) &lt; 1">
								<thead>
									<tr>
										<th>URL</th>';
										
										if(!empty($image_sitemap_enabled)){
											echo'<th>'.esc_xml($image_count_txt).'</th>';
										}
										
										echo'<th>'.esc_xml($last_modified_txt).'</th>
									</tr>
								</thead>
								<tbody>
									<xsl:for-each select="sitemap:urlset/sitemap:url">
										<tr>
											<td><a href="{sitemap:loc}"><xsl:value-of select="sitemap:loc"/></a></td>';
											
											if(!empty($image_sitemap_enabled)){
												echo'<td>
													<xsl:value-of select="count(image:image)"/>
												</td>';
											}
											
											echo'<td><xsl:value-of select="sitemap:lastmod"/></td>
										</tr>
									</xsl:for-each>
								</tbody>
							  </xsl:if>';
						}
						
						echo'</xsl:if>
						</table>
					</div>
				</div>
			</body>
		</html>

</xsl:template>
</xsl:stylesheet>';
	}
	
	static function get_page_images($post){

		$images = [];
		$thumb = get_the_post_thumbnail_url($post->ID);
		
		if(!empty($thumb)){
			$images[] = $thumb;
		}
		
		if(!class_exists('DOMDocument') || empty($post->post_content)){
			return $images;
		}

		libxml_use_internal_errors(true);
		
		$dom = new \DOMDocument();
		
		$dom->loadHTML('<?xml encoding="utf-8" ?>' . $post->post_content);
		$dom->preserveWhiteSpace = false;

		libxml_clear_errors();
		
		$img_tags = $dom->getElementsByTagName('img');
		
		if(empty($img_tags)){
			return;
		}
		
		foreach($img_tags as $img_tag){
			$url = $img_tag->getAttribute('src');

			if(empty($url)){
				continue;
			}

			$url = sanitize_url($url);
			
			// The Image has some different URL which means it does not belongs to our site.
			if(strpos($url, untrailingslashit(home_url())) === FALSE){
				continue;
			}
			
			$images[] = $url;
		}

		return $images;
	}

	static function maybe_redirect(){
		global $wp;

		if(empty($wp) || empty($wp->request)){
			return;
		}
		
		$redirects = ['sitemap.xml', 'wp-sitemap.xml', 'sitemap_index.xml'];

		if(in_array($wp->request, $redirects)){
			wp_safe_redirect(home_url('sitemaps.xml'), 301);
			die();
		}
	}
	
}
PKv�f\��� ��columns.phpnu�[���<?php
/*
* SITESEO
* https://siteseo.io
* (c) SiteSEO Team
*/

namespace SiteSEO;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class Columns{

	static function add_columns($colums){
		global $siteseo;
		
		if(empty($siteseo->setting_enabled['toggle-advanced'])){
			return $colums;  // toggle disable
		}

		$options = $siteseo->advanced_settings;
		
		if(!empty($options['appearance_title_col'])){
			$colums['seo_title'] = __('Title tag', 'siteseo');
		}
		
		if(!empty($options['appearance_meta_desc_col'])){
			$colums['meta_description'] = __('Meta Desc' , 'siteseo');
		}
		
		if(!empty($options['appearance_redirect_enable_col'])){
			$colums['redirect_enabled'] = __('Redirect?', 'siteseo');
		}
		
		if(!empty($options['appearance_redirect_url_col'])){
			$colums['redirect_url'] = __('Redirect URL', 'siteseo');
		}
		
		if(!empty($options['appearance_canonical'])){
			$colums['canonical_url'] = __('Canonical', 'siteseo');
		}
		
		if(!empty($options['appearance_target_kw_col'])){
			$colums['target_keyword'] = __('Target Kw', 'siteseo');
		}
		
		if(!empty($options['appearance_noindex_col'])){
			$colums['noindex'] = __('noindex?', 'siteseo');
		}
		
		if(!empty($options['appearance_nofollow_col'])){
			$colums['nofollow'] = __('nofollow?', 'siteseo');
		}
		
		if(!empty($options['appearance_words_col'])){
			$colums['word_count'] = __('Words', 'siteseo');
		}
		
		if(!empty($options['appearance_score_col'])){
			$colums['seo_score'] = __('Score', 'siteseo');
		}
		
		return $colums;
	}
	
	static function populate_custom_seo_columns($column, $post_id){
		global $siteseo;
		
		if(empty($siteseo->setting_enabled['toggle-advanced'])){
			return;  // toggle disable
		}
		
		$options = $siteseo->advanced_settings;

		switch($column){
			
			case 'seo_title':				
				if(!empty($options['appearance_title_col'])){
					$title = get_post_meta($post_id, '_siteseo_titles_title', true);
					echo esc_html(\SiteSEO\TitlesMetas::replace_variables($title));
				}
				break;

			case 'meta_description':
				if(!empty($options['appearance_meta_desc_col'])){
					$desc = get_post_meta($post_id, '_siteseo_titles_desc', true);
					$replaced_desc = \SiteSEO\TitlesMetas::replace_variables($desc);
					echo esc_html($replaced_desc);
				}
				break;

			case 'redirect_enabled':
				if(!empty($options['appearance_meta_desc_col'])){
					$redirect_enabled = get_post_meta($post_id, 'siteseo_redirections_enabled', true);
					echo $redirect_enabled ? esc_html__('Yes', 'siteseo') : esc_html__('No', 'siteseo');
				}
				break;
				
			case 'redirect_url':
				if(!empty($options['appearance_redirect_enable_col'])){
					echo esc_url(get_post_meta($post_id, '_siteseo_redirections_value', true));
				}
				break;

			case 'canonical_url':
				if(!empty($options['appearance_redirect_url_col'])){
					echo esc_url(get_post_meta($post_id, '_siteseo_robots_canonical', true));
				}
				break;

			case 'target_keyword':
				if(!empty($options['appearance_canonical'])){
					$keywords = esc_html(get_post_meta($post_id, '_siteseo_analysis_target_kw', true));
					echo !empty($keywords) ? esc_html($keywords) : '';
				}
				break;
				
			case 'noindex':
				if(!empty($options['appearance_noindex_col'])){
					$noindex = get_post_meta($post_id, '_siteseo_robots_index', true);
					echo $noindex ? esc_html__('Yes', 'siteseo') : esc_html__('No', 'siteseo');
				}
				break;

			case 'nofollow':
				if(!empty($options['appearance_nofollow_col'])){
					$nofollow = get_post_meta($post_id, '_siteseo_robots_follow', true);
					echo $nofollow ? esc_html__('Yes', 'siteseo') : esc_html__('No', 'siteseo');
				}
				break;

			case 'word_count':
				if(!empty($options['appearance_words_col'])){
					$content = get_post_field('post_content', $post_id);
					echo esc_html(str_word_count(wp_strip_all_tags($content)));
				}
				break;

			case 'seo_score':
				if(!empty($options['appearance_score_col'])){
					$score = get_post_meta($post_id, '_siteseo_score', true);
					echo !empty($score) ? esc_html($score) : '';
				}
				break;
		}
		
	}

	static function make_seo_columns_sortable($columns){
		global $siteseo;
		
		if(empty($siteseo->setting_enabled['toggle-advanced'])){
			return $columns;  // toggle disable
		}
		
		$options = $siteseo->advanced_settings;
		
		if(!empty($options['appearance_title_col'])){
			$columns['seo_title'] = 'seo_title';
		}
		
		if(!empty($options['appearance_meta_desc_col'])){
			$columns['meta_description'] = 'meta_description';
		}
		
		if(!empty($options['appearance_target_kw_col'])){
			$columns['target_keyword'] = 'target_keyword';
		}
		
		if(!empty($options['appearance_words_col'])){
			$columns['word_count'] = 'word_count';
		}

		if(!empty($options['appearance_score_col'])){
			$columns['seo_score'] = 'seo_score';
		}

		return $columns;
		
	}
	
	static function hide_genesis_seo(){
		global $siteseo;
		
		if(empty($siteseo->setting_enabled['toggle-advanced'])){
			return; // toggle disable
		}
		
		$options = $siteseo->advanced_settings;

		if(!empty($options['appearance_genesis_seo_menu'])){
			remove_theme_support('genesis-seo-settings-menu');
		}
		
		if(!empty($options['appearance_genesis_seo_metaboxe'])){
			remove_action('admin_menu', 'genesis_add_inpost_seo_box');
		}
	}
}PKv�f\������metaboxes/analysis.phpnu�[���<?php
/*
* SITESEO
* https://siteseo.io
* (c) SiteSEO Team
*/

namespace SiteSEO\Metaboxes;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class Analysis{
	
	static function display_content_readibility($metabox_data){
		
		if(empty($metabox_data) || !isset($metabox_data['post_id'])){
			return; // Safeguard in case $metabox_data is incomplete or invalid.
		}

		$post_id = $metabox_data['post_id'];
		$readability_data = get_post_meta($post_id, '_siteseo_readibility_data', true);

		// Fetch and analyze readability data
		$analyzes = self::analyze_content($readability_data);

		// Render the readability data
		self::render_readibility($analyzes, $readability_data);
	}
	
	static function analyze_content($data){
		$analyzes = [];

		// Analyze different aspects
		$analyzes = self::analyze_power_word($analyzes, $data);
		$analyzes = self::analyze_title_number($analyzes, $data);
		$analyzes = self::analyze_passive_voice($analyzes, $data);
		$analyzes = self::analyze_paragraph_length($analyzes, $data);

		return $analyzes;
	}

	static function analyze_power_word($analyzes, $data){
		
		if(!empty($data['power_words'])){
			$analyzes['power_words'] = [
				'desc' => '<p>'.__('Good: You have power words in your title.', 'siteseo').'</p>',
				'impact' => 'good',
				'title'=>'Power Word in title'
			];
		} else{
			$analyzes['power_words'] = [
				'desc' => '<p>'.__('Consider adding power words to your title for better impact.', 'siteseo').'</p>',
				'impact' => 'low',
				'title'=> __('Power Word in title', 'siteseo')
			];
		}
		return $analyzes;
	}

	static function analyze_title_number($analyzes, $data){
		
		if(!empty($data['number_found'])){
			$analyzes['number_found'] = [
				/* translators: %s is the number found in the title */
				'desc' => '<p>'.sprintf(__('Good: Your title contains the number "%s".', 'siteseo'), $data['number_found']).'</p>',
				'impact' => 'good',
				'title' => 'Number in title'
			];
		} else{
			$analyzes['number_found'] = [
				'desc' => '<p>'.__('Consider adding a number to your title to improve CTR.', 'siteseo').'</p>',
				'impact' => 'low',
				'title' => 'Number in title'
			];
		}
		
		return $analyzes;
	}

	static function analyze_passive_voice($analyzes, $data){

		//$analyzes['title'] ='Passive Voice';
		if(empty($data['passive_voice'])){
			$analyzes['passive_voice'] = [
				'desc' => '<p>'.__('Great: No passive voice detected.', 'siteseo').'</p>',
				'impact' => 'good',
				'title' => 'Passive Voice'
			];
		} else {
		    $percentage = round(($data['passive_voice']['passive_sentences'] * 100) / $data['passive_voice']['total_sentences']);
		    if($percentage <= 10){
			$analyzes['passive_voice'] = [
				/* translators: %s is the number found in the title */
				'desc' => '<p>'.sprintf(__('Good: Only %s%% of sentences use passive voice.', 'siteseo'), $percentage).'</p>',
				'impact' => 'good',
				'title' => 'Passive Voice'
			];
		    } elseif($percentage < 20){
			$analyzes['passive_voice'] = [
				/* translators: %s is the percentage of sentences using passive voice */
				'desc' => '<p>'.sprintf(__('Okay: %s%% of sentences use passive voice. Try to reduce it.', 'siteseo'), $percentage).'</p>',
				'impact' => 'medium',
				'title' => 'Passive Voice'
			];
		    } else{
		        $analyzes['passive_voice'] = [
				/* translators: %s is the percentage of sentences using passive voice */
				'desc' => '<p>'.sprintf(__('High: %s%% of sentences use passive voice. Consider revising.', 'siteseo'), $percentage).'</p>',
				'impact' => 'high',
				'title' => 'Passive Voice'
		        ];
		    }
		}
		return $analyzes;
	}

	static function analyze_paragraph_length($analyzes, $data){

		if(empty($data['paragraph_length']) || $data['paragraph_length'] < 150){
		    $analyzes['paragraph_length'] = [
		        'desc' => '<p>Good: Your paragraphs are concise.</p>',
		        'impact' => 'good',
					'title' => 'Paragraph Length'
		    ];
		} else{
		    $analyzes['paragraph_length'] = [
			/* translators: %s is the current paragraph length in words */
		        'desc' => '<p>'.sprintf(__('Consider reducing paragraph length. Current length: %s words.', 'siteseo'), $data['paragraph_length']) . '</p>',
		        'impact' => 'low',
					'title' => 'Paragraph Length'
		    ];
		}
		return $analyzes;
	}

	static function render_readibility($analyzes, $analysis_data, $echo = true){
		$acceptable_svg = [
			'svg' => [
				'role' => true,
				'aria-hidden' => true,
				'focusable' => true,
				'width' => true,
				'height' => true,
				'viewbox' => true,
				'version' => true,
				'xmlns' => true,
				'fill' => true,
			],
			'path' => ['fill' => true, 'd' => true]
		];

		if(!empty($analyzes)){
			$order = ['1' => 'high', '2' => 'medium', '3' => 'low', '4' => 'good'];
			usort($analyzes, function ($a, $b) use ($order) {
				return array_search($a['impact'], $order) - array_search($b['impact'], $order);
			});

			// Define SVG icons
			$high_icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM175 175c9.4-9.4 24.6-9.4 33.9 0l47 47 47-47c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-47 47 47 47c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-47-47-47 47c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l47-47-47-47c-9.4-9.4-9.4-24.6 0-33.9z"/></svg>';
			$medium_icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"/></svg>';
			$good_icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM369 209L241 337c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L335 175c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z"/></svg>';

			// Generate HTML
			$html = '<div id="siteseo-readibility-tabs">';
			foreach($analyzes as $key => $value){
				$impact_icon = '';
				switch ($value['impact']) {
					case 'high': $impact_icon = $high_icon; break;
					case 'medium': case 'low': $impact_icon = $medium_icon; break;
					case 'good': $impact_icon = $good_icon; break;
				}
				$html .= '<div class="siteseo-analysis-block">';
				$html .= '<div class="siteseo-analysis-block-title">';
				$html .= '<div><span class="impact ' . esc_attr($value['impact']) .'" aria-hidden="true">' . $impact_icon . '</span>' .
				/* translators: %s represents the degree of severity */
				'<span class="screen-reader-text">'. sprintf(esc_html__('Degree of severity: %s','siteseo'), esc_html($value['impact'])).'</span>' .
				esc_html($value['title']) . '</div>';
				$html .= '<span class="siteseo-arrow" aria-hidden="true"></span></div>';
				$html .= '<div class="siteseo-analysis-block-content">' . wp_kses_post($value['desc']) . '</div>';
				$html .= '</div>';
			}
			$html .= '</div>';
			
			if($echo){
				$allowed_html = array_merge(wp_kses_allowed_html('post'), $acceptable_svg);
				echo wp_kses($html, $allowed_html);
				return;
			}
			return $html;
		}
	}

	// Analaysis
	static function display_seo_analysis($post){
		$seo_analysis = self::perform_seo_analysis($post);
		
		echo '<div id="siteseo-analysis-tabs">
			<div id="siteseo-analysis-tabs-1">
				<div class="siteseo-analysis-summary">';
					if(!empty($seo_analysis)){
						// grp
						usort($seo_analysis['checks'], function ($a, $b) {
							$order = ['error' => 0, 'warning' => 1, 'good' => 2];
							
							$a_status_class = isset($a['status_class']) ? $a['status_class'] : '';
							$b_status_class = isset($b['status_class']) ? $b['status_class'] : '';
							
							$a_order = isset($order[$a_status_class]) ? $order[$a_status_class] : 3;
							$b_order = isset($order[$b_status_class]) ? $order[$b_status_class] : 3;
							
							return $a_order - $b_order;
						});

						echo '<div class="siteseo-analysis-summary-pill">';
							// counts logic
							if(!empty($seo_analysis['error_count'])){
								echo '<span><svg fill="#f33" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M24 22h-24l12-20z"/></svg>'.esc_html($seo_analysis['error_count']). ' Errors</span>';
							}
						
							if(!empty($seo_analysis['warning_count'])){
								echo '<span><svg xmlns="http://www.w3.org/2000/svg" fill="#fa3" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M0 96C0 60.7 28.7 32 64 32H384c35.3 0 64 28.7 64 64V416c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V96z"/></svg>'.esc_html($seo_analysis['warning_count']). ' Warnings</span>';
							}
							
							if(!empty($seo_analysis['good_count'])){
								echo '<span><svg xmlns="http://www.w3.org/2000/svg" fill="#0c6" viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512z"/></svg><span>'.esc_html($seo_analysis['good_count']). ' Good</span></span>';
							}
					
						echo '</div>
					</div><!-- .analysis-score -->';

				 // A triangle with exclamation in it.
				$medium_icon_svg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"/></svg>';

				 // A check inside a solid circle
				$good_icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM369 209L241 337c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L335 175c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z"/></svg>';
				
				$high_icon_svg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM175 175c9.4-9.4 24.6-9.4 33.9 0l47 47 47-47c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-47 47 47 47c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-47-47-47 47c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l47-47-47-47c-9.4-9.4-9.4-24.6 0-33.9z"/></svg>';
				
				$allowed_svg_tags = ['svg' => ['xmlns' => true, 'viewbox' => true, 'width' => true, 'height' => true, 'class' => true, 'fill' => true, 'stroke' => true, 'stroke-width' => true], 'path' => ['d' => true, 'fill' => true, 'stroke' => true, 'stroke-width' => true]];

			   foreach($seo_analysis['checks'] as $check){

						echo '<div class="siteseo-analysis-block">';
							if(isset($check['label'])){
								echo'<div class="siteseo-analysis-block-title">';
									if(isset($check['status_class'])){
										$impact_icon = '';
										switch($check['status_class']){
											case 'good':
												$impact_icon = $good_icon;
												break;
											case 'warning':
												$impact_icon = $medium_icon_svg;
												break;
											case 'error':
												$impact_icon = $high_icon_svg;
												break;
										}

										echo '<div><span class="impact '.esc_attr($check['status_class']).'" aria-hidden="true">'.wp_kses($impact_icon, $allowed_svg_tags).'</span>
										
										<span class="screen-reader-text">'.
										/* translators: %s represents the degree of severity */
										sprintf(esc_html__('Degree of severity: %s','siteseo'), esc_html($check['status_class'])).'</span>';
									}

									echo esc_html($check['label']).'</div>
									<span class="siteseo-arrow" aria-hidden="true"></span>
								</div>';
							}
							if(isset($check['details'])){
								echo '<div class="siteseo-analysis-block-content" aria-hidden="true">'.wp_kses_post($check['details']).'</div>';
							}
						echo '</div><!-- .siteseo-analysis-block -->';
					}

				echo '</div><!-- #siteseo-analysis-tabs-1 -->
				</div><!-- #siteseo-analysis-tabs -->';
			}

	}

	static function perform_seo_analysis($post){
		
		$content = $post->post_content;
		$title = $post->post_title;
		$title = !empty(get_post_meta($post->ID, '_siteseo_titles_title',true)) ? get_post_meta($post->ID, '_siteseo_titles_title', true) : $title;
		$permalink = get_permalink($post->ID);
		$keywords = get_post_meta($post->ID, '_siteseo_analysis_target_kw', true);
		$meta_desc = get_post_meta($post->ID, '_siteseo_titles_desc', true);
		
		// Bricks
		if(defined('BRICKS_DB_PAGE_CONTENT')){
			$is_bricks_page = get_post_meta($post->ID, BRICKS_DB_PAGE_CONTENT, true);

			if(!empty($is_bricks_page) && is_array($is_bricks_page)){
				$content = self::get_bricks_page_content($is_bricks_page);
			}
		}
			
		if(empty($meta_desc)){
			$meta_desc = '';
		}

		$analysis = [
			'good_count' => 0,
			'warning_count' => 0,
			'error_count' => 0,
			'checks' => []
		];

		$canonical_check = self::check_canonical_url($permalink);
		$analysis['checks'][] = $canonical_check;
		self::update_analysis_score($analysis, $canonical_check);

		$word_count_check = self::check_word_count($content);
		$analysis['checks'][] = $word_count_check;
		self::update_analysis_score($analysis, $word_count_check);

		$keywords_density_check = self::check_keywords_density($content, $keywords);
		$analysis['checks'][] = $keywords_density_check;
		self::update_analysis_score($analysis, $keywords_density_check);

		$meta_title_check = self::check_meta_title($title);
		$analysis['checks'][] = $meta_title_check;
		self::update_analysis_score($analysis, $meta_title_check);

		$meta_description_check = self::check_meta_description($content, $meta_desc);
		$analysis['checks'][] = $meta_description_check;
		self::update_analysis_score($analysis, $meta_description_check);

		$image_alt_check = self::check_image_alt_texts($content);
		$analysis['checks'][] = $image_alt_check;
		self::update_analysis_score($analysis, $image_alt_check);

		$links_outbound_check = self::analyze_outbound_links($content);
		$analysis['checks'][] = $links_outbound_check;
		self::update_analysis_score($analysis, $links_outbound_check);

		$links_internal_check = self::analyze_internal_links($content);
		$analysis['checks'][] = $links_internal_check;
		self::update_analysis_score($analysis, $links_internal_check);

		$headings_check = self::check_headings($content);
		$analysis['checks'][] = $headings_check;
		self::update_analysis_score($analysis, $headings_check);

		$social_tags_check = self::check_social_meta_tags($post);
		$analysis['checks'][] = $social_tags_check;
		self::update_analysis_score($analysis, $social_tags_check);

		$structured_data_check = self::check_structured_data($post);
		$analysis['checks'][] = $structured_data_check;
		self::update_analysis_score($analysis, $structured_data_check);

		$permalink_keywords_check = self::check_keywords_in_permalink($permalink, $keywords);
		$analysis['checks'][] = $permalink_keywords_check;
		self::update_analysis_score($analysis, $permalink_keywords_check);

		$meta_robots_check = self::check_meta_robots($post);
		$analysis['checks'][] = $meta_robots_check;
		self::update_analysis_score($analysis, $meta_robots_check);

		$last_modified_check = self::check_last_modified_date($post);
		$analysis['checks'][] = $last_modified_check;
		self::update_analysis_score($analysis, $last_modified_check);

		$nofollow_links_check = self::analyze_nofollow_links($content);
		$analysis['checks'][] = $nofollow_links_check;
		self::update_analysis_score($analysis, $nofollow_links_check);
		
		$readability_data = [];
		$readability_data = self::analyze_readability($content, $title);
		update_post_meta($post->ID, '_siteseo_readibility_data', $readability_data);
		$analysis['checks'][] = $readability_data;

		return $analysis;
	}
	
	static function update_analysis_score(&$analysis, $check){
		switch($check['status']){
		    case 'Good':
		        $analysis['good_count']++;
		        break;
		    case 'Warning':
		        $analysis['warning_count']++;
		        break;
		    case 'Error':
		        $analysis['error_count']++;
		        break;
		}
	}
	
	static function check_canonical_url($permalink){
		$response = wp_remote_get($permalink);
		if(is_wp_error($response)){
			return [
				'label' => 'Canonical URL',
				'status' => 'Error',
				'status_class' => 'error',
				'details' => '<p>' . __('Unable to check canonical URL.', 'siteseo') . '</p>'
			];
		}
		
		$content = wp_remote_retrieve_body($response);
		
		preg_match_all('/<link[^>]+rel=[\'"](canonical)[\'"][^>]+href=[\'"]([^\'"]+)[\'"][^>]*>/i', $content, $matches);
		
		$canonical_urls = !empty($matches[2]) ? array_unique($matches[2]) : [];
		$count = count($canonical_urls);
		
		$details = '';
		$status = 'Warning';
		
		$details .= '<p>'. __('A canonical URL is required by search engines to handle duplicate content.', 'siteseo') .'</p>';
		
		if($count > 0){
			
			$details .= '<p>' .
			
			sprintf(
				/* translators: %s represents the degree of severity */
				_n(
					'We found %s canonical URL in your source code. Below, the list:',
					'We found %s canonical URLs in your source code. Below, the list:',
					$count,
					'siteseo'
				),
				number_format_i18n($count)
			) . '</p>';
			
			$details .= '<ul>';
			foreach($canonical_urls as $link){
				$details .= '<li>' .
					'<span class="dashicons dashicons-arrow-right"></span>' .
					'<a href="' . esc_url($link) . '" target="_blank">' . 
					esc_url($link) . 
					'</a>' .
					'<span class="dashicons dashicons-external"></span>' .
					'</li>';
			}
			$details .= '</ul>';
			
			if($count > 1){
				$status = 'Error';
				$details .= '<p><span class="dashicons dashicons-thumbs-down"></span>' . 
					__('You must fix this. Canonical URL duplication is bad for SEO.', 'siteseo') . '</p>';
			} else{
				$status = 'Good';
			}
		} else{
			if(get_post_meta(get_the_ID(), '_siteseo_robots_index', true)){
				$status = 'Good';
				$details .= '<p><span class="dashicons dashicons-thumbs-up"></span>' . 
					__('This page doesn\'t have any canonical URL because your post is set to <strong>noindex</strong>. This is normal.', 'siteseo') . '</p>';
			} else{
				$details .= '<p><span class="dashicons dashicons-thumbs-down"></span>' . 
					__('This page doesn\'t have any canonical URL.', 'siteseo') . '</p>';
			}
		}
		
		return [
			'label' => 'Canonical URL',
			'status' => $status,
			'status_class' => strtolower($status),
			'details' => $details
		];
	}
	
	static function check_word_count($content){
		$word_count = str_word_count(wp_strip_all_tags($content));
		$unique_words = count(array_unique(str_word_count(wp_strip_all_tags($content), 1)));
		
		$details = '';
		
		if($word_count != 0){
			
			$details = '<p>'. __('Word count isn\'t a direct ranking factor, but it\'s important for your content to be high-quality, relevant, and unique. To meet these criteria, your article should include a sufficient number of paragraphs to ensure adequate word count.', 'siteseo') .'</p>';
		
			$details .= '<ul>';
			/* translators: %d represents the words found */
			$details .= '<li>'. sprintf(__('%d words found', 'siteseo'), $word_count) .'</li>';
			/* translators: %d represents the unique words found */
			$details .= '<li>'. sprintf(__('%d unique words found', 'siteseo'), $unique_words) .'</li>';
			$details .= '</ul>';
				
		}
		
		if($word_count == 0){
			$status = 'Error';
			$details .= '<p><span class="dashicons dashicons-thumbs-down"></span>' . __('No content? Try adding a few more paragraphs.!', 'siteseo') . '</p>';
		} elseif($word_count > 300){
			$status = 'Good';
			$details .= '<li><span class="dashicons dashicons-thumbs-up"></span>' . __('Your content contains over 300 words, which meets the minimum requirement for a post', 'siteseo') .'</li>';
		} else{
			$status = 'Error';
			$details .= '<li><span class="dashicons dashicons-thumbs-down"></span>' . __('Your content is too brief. Consider adding a few more paragraphs!', 'siteseo') .'</li>';
		}

		return [
			'label' => __('Word Count', 'siteseo'),
			'status' => $status,
			'status_class' => strtolower($status),
			'details' => $details
		];
	}

	static function check_keywords_density($content, $keywords){
		$content = mb_strtolower(wp_strip_all_tags($content), 'UTF-8');
		$keywords = array_filter(explode(',', trim($keywords)));
		$content_words = str_word_count($content, 1);
		$count_words = count($content_words);
		$details = '';

		if(empty($keywords) || empty($content_words)){
			$details .= '<p>' . __('We couldn\'t calculate the keyword density. This may be because you haven\'t added any content or your target keywords are missing from the post.', 'siteseo') . '</p>';
			
			return [
				'label' => __('Keyword Density', 'siteseo'),
				'status' => 'Error',
				'status_class' => 'error',
				'details' => $details
			];
		}

		// calulate
		$density_details = [];
		$all_density = [];
    
		foreach($keywords as $keyword){
			$keyword_occurrence = 0;

			$keyword = mb_strtolower(trim($keyword), 'UTF-8');

			$keyword_words = preg_split('/\s+/u', $keyword, -1, PREG_SPLIT_NO_EMPTY);
			$keyword_word_count = count($keyword_words);

			// Count occurrences
			if($keyword_word_count > 1){

				$pattern = '/' . preg_quote($keyword, '/') . '/iu';
				preg_match_all($pattern, $content, $matches);
				$keyword_occurrence = count($matches[0]);
			} else {
				$word_counts = array_count_values($content_words);
				$keyword_occurrence = isset($word_counts[$keyword]) ? $word_counts[$keyword] : 0;

			}

			// Calculate density
			if($count_words > 0){
				$kw_density = ($keyword_occurrence * $keyword_word_count * 100) / $count_words;
			} else {
				$kw_density = 0;
			}

			$all_density[] = number_format($kw_density, 2);
			
			$density_details[] = 
			/* translators: %s represents the degree of severity */ 
			sprintf(
				'<ul><li><span class="dashicons dashicons-arrow-right"></span>%s</li></ul>',
				sprintf(
					/* translators: %s represents a keyword density of */
					esc_html__('%1$s was found %2$d times in your content, a keyword density of %3$s%%', 'siteseo'),
					esc_html($keyword),
					$keyword_occurrence,
					number_format($kw_density, 2)
				)
			);
		}

		$details .= implode('', $density_details);

		$details .= '<p class="description">'.
			sprintf(
				__('Find out more about <a href="%s" target="_blank">keywords stuffing</a>', 'siteseo'),
				'https://www.youtube.com/watch?v=Rk4qgQdp2UA'
			) .
		'</p>';

		if(count($all_density) === 0){
			return [
				'label' => __('Keyword Density', 'siteseo'),
				'status' => 'Error',
				'status_class' => 'error',
				'details' => $details
			];
		}

		//avg density
		$avg_density = array_sum($all_density)/count($all_density);

		$status = ($avg_density > 1) ? 'Good' : 'Warning';

		return [
			'label' => __('Keyword Density', 'siteseo'),
			'status' => $status,
			'status_class' => strtolower($status),
			'details' => $details
		];
	}
	
	static function check_meta_title($title, $keywords = []){
		$details = '';
		$status = 'Good';
		$status_class = 'good';
		
		$title = \SiteSEO\TitlesMetas::replace_variables($title);

		// mb_strlen for correct UTF-8
		$title_length = mb_strlen($title, 'UTF-8');

		// length
		if(empty($title)){
			$details .= '<p><span class="dashicons dashicons-thumbs-down"></span>' . 
			__('A custom title has not been set for this post. If the global meta title works for you, you can disregard this recommendation.', 'siteseo') . '</p>';
			$status = 'Warning';
			$status_class = 'warning';
		} elseif($title_length > 60){
			$details .= '<p><span class="dashicons dashicons-thumbs-down"></span>' .
			__('Your custom title is too lengthy.', 'siteseo') . '</p>';
			$status = 'Warning';
			$status_class = 'warning';
		} elseif($title_length >= 10 && $title_length <= 60){
			$details .= '<p><span class="dashicons dashicons-thumbs-up"></span>' .
			__('The length of your title is appropriate.', 'siteseo') . '</p>';
		} else{
			$details .= '<p><span class="dashicons dashicons-thumbs-down"></span>' . 
			__('Your custom title is too short.', 'siteseo') . '</p>';
			$status = 'Warning';
			$status_class = 'warning';
			
		}

		if(!empty($keywords)){
			$keyword_counts = [];
			foreach($keywords as $kw_name){
				$kw_count = substr_count(strtolower($title), strtolower($kw_name));
				if($kw_count > 0){
					$keyword_counts[] = $kw_count;
					/* translators: %s represents the degree of severity */
					$details .= '<ul><li><span class="dashicons dashicons-arrow-right"></span>'. sprintf(esc_html__('%1$s was found %2$d times.', 'siteseo'), $kw_name, $kw_count) . '</li></ul>';
				}
			}

			if(!empty($keyword_counts)){
				$details .= '<p><span class="dashicons dashicons-thumbs-up"></span>'.__('The target keywords are included in the Meta Title', 'siteseo').'</p>';
			} else {
				$details .= '<p><span class="dashicons dashicons-thumbs-down"></span>'.__('None of your target keywords are present in the Meta Title.', 'siteseo').'</p>';
				$status = $status === 'Good' ? 'Warning' : $status;
				$status_class = $status_class === 'good' ? 'warning' : $status_class;
			}
		}

		return [
			'label' => __('Meta Title', 'siteseo'),
			'status' => $status,
			'status_class' => $status_class,
			'details' => $details
		];
	}

	static function check_meta_description($content, $meta_description = '', $keywords = []){
		$details = '';
		$status = 'Good';
		$status_class = 'good';

		$desc = !empty($meta_description) ? $meta_description : wp_trim_words($content, 20);
		$description = \SiteSEO\TitlesMetas::replace_variables($desc);

		// UTF-8
		$description_length = mb_strlen($description, 'UTF-8');

		// desc length
		if(empty($meta_description)){
			$details .= '<p><span class="dashicons dashicons-thumbs-down"></span>' . 
				__('A custom meta description has not been set for this post. If the global meta description works for you, you can ignore this recommendation.', 'siteseo') . '</p>';
				
			$status = 'Warning';
			$status_class = 'warning';
		} elseif($description_length > 160){
			$details .= '<p><span class="dashicons dashicons-thumbs-down"></span>' . __('Your custom meta description is too lengthy', 'siteseo') .'</p>';
			$status = 'Warning';
			$status_class = 'warning';
		} elseif($description_length >= 50 && $description_length <= 160){
			$details .= '<p><span class="dashicons dashicons-thumbs-up"></span>'. __('The length of your meta description is appropriate.', 'siteseo').'</p>';
		} else{
			$details .= '<p><span class="dashicons dashicons-thumbs-up"></span>'. __('The description has been set properly.', 'siteseo').'</p>';
		}

		if(!empty($keywords)){
			$keyword_counts = [];
			foreach($keywords as $kw_name){
				$kw_count = substr_count(strtolower($description), strtolower($kw_name));
				if($kw_count > 0){
					$keyword_counts[] = $kw_count;
					$details .= '<li><span class="dashicons dashicons-arrow-right"></span>' . 
						/* translators: %s represents the key word count */
						sprintf(esc_html__('%1$s was found %2$d times.', 'siteseo'), $kw_name, $kw_count) . '</li>';
				}
			}

			if(!empty($keyword_counts)){
				$details .= '<p><span class="dashicons dashicons-thumbs-up"></span>'. __('The target keywords are included in the Meta description.', 'siteseo') . '</p>';
			} else{
				$details .= '<p><span class="dashicons dashicons-thumbs-down"></span>'. __('None of your target keywords are included in the Meta description.', 'siteseo') . '</p>';
				$status = $status === 'Good' ? 'Warning' : $status;
				$status_class = $status_class === 'good' ? 'warning' : $status_class;
			}
		}

		return [
			'label' => 'Meta Description',
			'status' => $status,
			'status_class' => $status_class,
			'details' => $details
		];
	}
	
	static function check_image_alt_texts($content){

			$result = [
				'label' => __('Alternative texts of images', 'siteseo'),
				'status' => 'Good',
				'status_class' => 'good',
				'details' => ''
			];

			if(empty($content)){
				$result['status'] = 'Warning';
				$result['status_class'] = 'warning';
				$result['details'] = '<p><span class="dashicons dashicons-thumbs-down"></span>' . 
					__('No content found to analyze. Please add some content to check for images and alt texts.', 'siteseo') . '</p>';
				return $result;
			}

			preg_match_all('/<img[^>]+src=[\'"]([^\'"]+)[\'"][^>]*>/i', $content, $image_matches);
			preg_match_all('/<img[^>]+alt=[\'"]([^\'"]+)[\'"][^>]*>/i', $content, $alt_matches);

			$images_count = count($image_matches[0]);
			$alt_text_count = count(array_filter($alt_matches[1], 'strlen'));

			if($images_count === 0){
				$result['status'] = 'Warning';
				$result['status_class'] = 'warning';
				$result['details'] = '<p><span class="dashicons dashicons-thumbs-down"></span>' .
					__('We couldn\'t find any images in your content. Adding media can boost your SEO.', 'siteseo') . '</p>';
				return $result;
			}

			if($images_count !== $alt_text_count){
				$result['status'] = ($alt_text_count > 0) ? 'Warning' : 'Error';
				$result['status_class'] = strtolower($result['status']);
				
				$result['details'] = '<p><span class="dashicons dashicons-thumbs-down"></span>' . 
					esc_html__('No alternative text has been found for these images. Alt tags are essential for SEO and accessibility. Please edit your images in the media library or using your preferred page builder, and provide alternative text.', 'siteseo') . '</p>';
				
	
				if(!empty($image_matches[1])){
					$result['details'] .= '<ul class="attachments">';
					foreach($image_matches[1] as $index => $img){
						if(empty($alt_matches[1][$index])){
							$result['details'] .= '<li class="attachment"><figure>' .
								'<img src="' . esc_url($img) . '"/>' .
								'<figcaption style="word-break: break-all;">' . esc_html($img) . '</figcaption>' .
								'</figure></li>';
						}
					}
					$result['details'] .= '</ul>';
				}
				
				$result['details'] .= '<p>'. __('Please note that we scan all your source code, which means some missing alternative text for images may be found in your header, sidebar, or footer.', 'siteseo') .'</p>';
			} else{
    
				$result['details'] = '<p><span class="dashicons dashicons-thumbs-up"></span>' . 
					__('All alternative tags have been completed. Great job!', 'siteseo') .'</p>';
			}

			return $result;
    	}
	

	static function analyze_outbound_links($content){

		preg_match_all('/<a[^>]+href=([\'"])(?!#)([^\'"]+)[\'"][^>]*>/i', $content, $links);

		$outbound_links = array_filter($links[2], function($link){
			return strpos($link, get_site_url()) === false;
		});
		
		$total_outbound = count($outbound_links);
		$nofollow_count = preg_match_all('/rel=[\'"]nofollow[\'"]/', implode(' ', $links[0]));
		
		$status = $total_outbound > 0 ? 'Good' : 'Warning';
		
		$details = '';
		
		$details .= '<p>'. __('The internet is based on the concept of hyperlinks, so linking to different websites is completely natural. However, avoid linking to low-quality or spammy sites. If youre uncertain about a site quality, add the "nofollow" attribute to your link.', 'siteseo') .'</p>';
		
		if($total_outbound > 0){
			/* translators: %s represents the detected outbound links on page  */
			$details .= '<p>'.sprintf(__('We detected %s outbound links on your page. Below is the list.', 'siteseo'), $total_outbound) .'</p>';
			$details .= '<ul>';
			
			foreach($outbound_links as $link){
				$details .= '<li><span class="dashicons dashicons-arrow-right"></span>';
				$details .= '<a href="'.esc_url($link).'" target="_blank">'.esc_url($link).'</a></li>';
			}
			
			$details .= '</ul>';
		} else{
			$details .= '<p><span class="dashicons dashicons-thumbs-down"></span>' . 
				__('This page does not contain any outbound links.', 'siteseo') . '</p>';
		}
		
		return [
			'label' => __('Outbound Links', 'siteseo'),
			'status' => $status,
			'status_class' => strtolower($status),
			'details' => $details
		];
	}
	
	static function analyze_internal_links($content){

		preg_match_all('/<a[^>]+href=([\'"])(?!#)([^\'"]+)[\'"][^>]*>(.*?)<\/a>/i', $content, $links, PREG_SET_ORDER);

		$internal_links = array_filter($links, function($link) {
			return strpos($link[2], get_site_url()) !== false;
		});
		
		$total_internal = count($internal_links);

		$status = $total_internal > 0 ? 'Good' : 'Warning';
		
		$details = '';

		$details .= '<p>'. __('Internal links are crucial for both SEO and user experience. Always aim to interconnect your content using meaningful and relevant anchor text.', 'siteseo') .'</p>';
		
		if($total_internal > 0){
			/* translators: %s represents the internal links pointing to page */
			$details .= '<p>'. sprintf(__('We identified %s internal links pointing to this page.', 'siteseo'), $total_internal) .'</p>';
			$details .= '<ul>';
	
			foreach($internal_links as $link){
				$url = $link[2];
				$post_id = url_to_postid($url);
				
				$details .= '<li><span class="dashicons dashicons-arrow-right"></span>';
				$details .= '<a href="'.esc_url($url) .'" target="_blank">'. esc_html($url) . '</a>';
				
				if($post_id){
					$details .= '<a class="nounderline" href="' . get_edit_post_link($post_id) . '" ' .
							   'title="' . 
							   /* translators: %s represents the degree of severity */
							   sprintf(__('edit %s', 'siteseo'), esc_html(get_the_title($post_id))) . '">' .
							   '<span class="dashicons dashicons-edit-large"></span></a>';
				}
				
				$details .= '</li>';
			}
			
			$details .= '</ul>';
		} else{
			$details .= '<p><span class="dashicons dashicons-thumbs-down"></span>' . 
				__('This page has no internal links from other content. Links from archive pages are not counted as internal links because they lack contextual relevance.', 'siteseo') . '</p>';
		}
		
		return [
			'label' => __('Internal Links', 'siteseo'),
			'status' => $status,
			'status_class' => strtolower($status),
			'details' => $details
		];
	}
	
	static function analyze_nofollow_links($content){
	
		preg_match_all('/<a[^>]+href=([\'"])([^\'"]+)[\'"][^>]*>(.*?)<\/a>/i', $content, $all_links, PREG_SET_ORDER);
		
		$nofollow_links = array_filter($all_links, function($link){
			return preg_match('/rel=[\'"][^\'"]*nofollow[^\'"]*[\'"]/', $link[0]);
		});
		
		$total_nofollow = count($nofollow_links);

		$status = $total_nofollow > 0 ? 'Warning' : 'Good';
		
		$details = '';
		
		if($total_nofollow > 0){
			
			$details .= '<p>' .
			/* translators: %d represents the number nofollow attribute */ 
			sprintf( esc_html__('We found %d links with the nofollow attribute on your page. Avoid overusing the nofollow attribute in links. Below is the list:', 'siteseo'),
				$total_nofollow
			) . '</p>';
			
			$details .= '<ul>';
			
			foreach($nofollow_links as $link){
				$href = $link[2];
				$link_text = $link[3];
				
				$details .= '<li>'.
					'<span class="dashicons dashicons-arrow-right"></span>'.
					'<a href="' . esc_url($href) . '" target="_blank">'.esc_html($link_text).'</a>'.
					'<span class="dashicons dashicons-external"></span>'.
					'</li>';
			}
			
			$details .= '</ul>';
		} else{
			$details .= '<p><span class="dashicons dashicons-thumbs-up"></span>' . 
				__('This page does not contain any nofollow links.', 'siteseo') . '</p>';
		}
		
		return [
			'label' => __('Nofollow Links', 'siteseo'),
			'status' => $status,
			'status_class' => strtolower($status),
			'details' => $details
		];
	}

	static function check_headings($content, $keywords = []) {
		$details = '';
		$status = 'Good';
		$status_class = 'good';
		if(empty(trim($content))){
			return [
				'label' => 'Headings',
				'status' => 'Warning',
				'status_class' => 'warning',
				'details' => '<p><span class="dashicons dashicons-thumbs-down"></span>' . __('No content available to check headings.', 'siteseo') . '</p>'
			];
		}

		preg_match_all('/<h([1-6])([^>]*)>(.*?)<\/h\1>/is', $content, $heading_matches);
		
		if(empty($heading_matches[0])){
			return [
				'label' => 'Headings',
				'status' => 'Error',
				'status_class' => 'error',
				'details' => '<p><span class="dashicons dashicons-thumbs-down"></span>' . __('No headings found in the content. Using headings is essential for both SEO and accessibility!', 'siteseo') . '</p>'
			];
		}

		$heading_counts = array_count_values($heading_matches[1]);
		$total_headings = count($heading_matches[0]);

		
		$h1_count = isset($heading_counts[1]) ? $heading_counts[1] : 0;
		if($h1_count > 0){
			$details .= '<p><span class="dashicons dashicons-thumbs-down"></span>' . 
				/* translators: %d represents the number of h1 tags */
				sprintf(esc_html__('We found %d Heading 1 (H1) tags in your content.', 'siteseo'), $h1_count+1) . '</p>';

			$details .= '<p>' . __('You should avoid using more than one H1 heading in your post content. The rule is simple: each web page should have only one H1, which benefits both SEO and accessibility. Below is the list:', 'siteseo') . '</p>';

			$details .= '<ul>';
			foreach(array_keys($heading_matches[1], '1') as $index){
				$details .= '<li><span class="dashicons dashicons-arrow-right"></span>' . 
					wp_strip_all_tags($heading_matches[0][$index]) . '</li>';
			}
			$details .= '</ul>';
			$status = 'Warning';
			$status_class = 'warning';
		}
		foreach([2, 3] as $level){
			$level_count = isset($heading_counts[$level]) ? $heading_counts[$level] : 0;
			$details .= '<p><span class="dashicons dashicons-info"></span>' .
				/* translators: %d represents the heading */ 
				sprintf(__('Found %1$d H%2$d heading(s)', 'siteseo'), $level_count, $level) . '</p>';

			if($level_count > 0){
				$details .= '<ul>';
				foreach(array_keys($heading_matches[1], (string)$level) as $index){
					$details .= '<li><span class="dashicons dashicons-arrow-right"></span>'. 
						wp_strip_all_tags($heading_matches[0][$index]) .'</li>';
				}
				$details .= '</ul>';
			}

			if(!empty($keywords) && $level_count > 0){
				$keyword_found = false;
				$keyword_details = '<ul>';
				
				foreach($keywords as $kw_name){
					$kw_count = 0;
					foreach(array_keys($heading_matches[1], (string)$level) as $index){
						$kw_count += substr_count(
							strtolower(wp_strip_all_tags($heading_matches[0][$index])), 
							strtolower($kw_name)
						);
					}
					
					if($kw_count > 0){
						$keyword_found = true;
						$keyword_details .= '<li><span class="dashicons dashicons-arrow-right"></span>' .
							/* translators: %s represents the degree of severity */ 
							sprintf(esc_html__('%1$s was found %2$d times.', 'siteseo'), $kw_name, $kw_count) . '</li>';
					}
				}
				$keyword_details .= '</ul>';

				if($keyword_found){
					$details .= '<p><span class="dashicons dashicons-thumbs-up"></span>' .
						/* translators: %s represents the target keywords  */ 
						sprintf(__('Target keywords were found in Heading %1$d (H%2$d).', 'siteseo'), $level, $level) . '</p>' . 
						$keyword_details;
				} else{
					$details .= '<p><span class="dashicons dashicons-thumbs-down"></span>' .
						/* translators: %d represents the target keywords */ 
						sprintf(__('None of your target keywords were found in Heading %1$d (H%2$d).', 'siteseo'), $level, $level) . '</p>';
					if($status === 'Good'){
						$status = 'Warning';
						$status_class = 'warning';
					}
				}
			}
		}

		return [
			'label' => 'Headings',
			'status' => $status,
			'status_class' => $status_class,
			'details' => $details
		];
	}
	
	static function check_social_meta_tags($post = null){
		if(!$post){
			$post = get_queried_object();
		}
		
		$details = '';
		$status = 'Good';
		$status_class = 'good';
		
		$og_titles = get_post_meta($post->ID, '_siteseo_social_fb_title', true);
		$og_title = $og_titles ? $og_titles : '';
		
		if(empty($og_title)){
			$details .= '<p><span class="dashicons dashicons-thumbs-down"></span>'. __('Your Open Graph Title tag has not been set!', 'siteseo') .'</p>';
			$details .= '<p><span class="dashicons dashicons-thumbs-down"></span>'. __('Your Open Graph Title is missing!', 'siteseo') .'</p>';
			$status = 'Error';
			$status_class = 'error';
		} else{
			$details .= '<h4>'. __('Open Graph Title', 'siteseo') . '</h4>';
			$details .= '<p><span class="dashicons dashicons-thumbs-up"></span>'. __('An Open Graph Title tag was found in your source code.', 'siteseo') . '</p>';
			$details .= '<ul><li><span class="dashicons dashicons-arrow-right"></span>' . esc_html($og_title) . '</li></ul>';
		}

		$og_descriptions = get_post_meta($post->ID, '_siteseo_social_fb_desc', true);
		$og_description = $og_descriptions ? $og_descriptions : '';

		if(empty($og_description)){
			$details .= '<h4>'. __('Open Graph Description', 'siteseo') .'</h4>';
			$details .= '<p><span class="dashicons dashicons-thumbs-down"></span>'. __('Your Open Graph Description has not been set!','siteseo').'</p>';
			$status = $status === 'Good' ? 'Warning' : $status;
			$status_class = $status_class === 'good' ? 'warning' : $status_class;
		} else {
			$details .= '<p><span class="dashicons dashicons-thumbs-up"></span>' .
				/* translators: %s represents the og description */
				sprintf(esc_html__('We found %s og:description in your content.', 'siteseo'), $og_descriptions) . '</p>';
		}

		// OG Check
		$og_images = get_post_meta($post->ID, '_siteseo_social_fb_img', true);
		$og_image = $og_images ? $og_images : '';
		
		if(empty($og_image)){
			$details .= '<h4>'. __('Open Graph Image', 'siteseo') .'</h4>';
			$details .= '<p><span class="dashicons dashicons-thumbs-down"></span>'. __('Your Open Graph Image has not been set!' ,'siteseo') .'</p>';
			$status = $status === 'Good' ? 'Warning' : $status;
			$status_class = $status_class === 'good' ? 'warning' : $status_class;
		} else{
			/* translators: %s represents the og images */
			$details .= '<p><span class="dashicons dashicons-thumbs-up"></span>'. sprintf(esc_html__('We found %s og:image in your content.', 'siteseo'), $og_images) . '</p>';
		}

		// Open Graph
		$og_site_name = get_bloginfo('name');
		if(empty($og_site_name)){
			$details .= '<h4>'. __('Open Graph Site Name', 'siteseo') .'</h4>';
			$details .= '<p><span class="dashicons dashicons-thumbs-down"></span>'. __('Your Open Graph Site Name has not been set!' ,'siteseo') .'</p>';
			$status = $status === 'Good' ? 'Warning' : $status;
			$status_class = ($status_class === 'good') ? 'warning' : $status_class;
		}

		// Twitter
		$twitter_title = get_post_meta($post->ID, '_siteseo_social_twitter_title', true);
		if(empty($twitter_title)){
			$details .= '<h4>'. __('X Title', 'siteseo').'</h4>';
			$details .= '<p><span class="dashicons dashicons-thumbs-down"></span>'. __('Your X Title has not been set!', 'siteseo').'</p>';
			$status = $status === 'Good' ? 'Warning' : $status;
			$status_class = $status_class === 'good' ? 'warning' : $status_class;
		}

		$twitter_description = get_post_meta($post->ID, '_siteseo_social_twitter_desc', true);
		if(empty($twitter_description)){
			$details .= '<h4>'. __('X Description','siteseo').'</h4>';
			$details .= '<p><span class="dashicons dashicons-thumbs-down"></span>'. __('Your X Description has not been set!','siteseo') .'</p>';
			$status = $status === 'Good' ? 'Warning' : $status;
			$status_class = $status_class === 'good' ? 'warning' : $status_class;
		}

		$twitter_image = get_post_meta($post->ID, '_siteseo_social_twitter_img', true);
		if(empty($twitter_image)){
			$details .= '<h4>'. __('X Image', 'siteseo') .'</h4>';
			$details .= '<p><span class="dashicons dashicons-thumbs-down"></span>'. __('Your X Image has not been set!', 'siteseo').'</p>';
			$status = $status === 'Good' ? 'Warning' : $status;
			$status_class = ($status_class === 'good') ? 'warning' : $status_class;
		}

		return [
			'label' => __('Social Meta Tags', 'siteseo'),
			'status' => $status,
			'status_class' => $status_class,
			'details' => $details
		];

	}

    static function check_structured_data($post){
        $schema_type = get_post_meta($post->ID, '_siteseo_structured_data_type', true);
        $status = !empty($schema_type) ? 'Good' : 'Warning';

        return [
            'label' => 'Structured Data',
            'status' => $status,
            'status_class' => strtolower($status),
            'details' => !empty($schema_type) ? 'Schema Type: '.$schema_type : 'No schema defined'
        ];
    }

	static function check_keywords_in_permalink($permalink, $keywords){
		$keywords = array_filter(explode(',', trim($keywords)));
		$permalink = str_replace('-', ' ', strtolower(basename($permalink)));
		$content_words = str_word_count($permalink, 1);
		$count_words = count($content_words);


		$kw_density = [];
		$matching_keywords = [];
		
		foreach($keywords as $keyword){
			$keyword_occurrence = 0;
			$keyword = strtolower(trim($keyword));
			
			// If keyword has multiple words
			if(str_word_count($keyword) > 1){
				$pattern = '/\b' . preg_quote($keyword, '/') . '\b/i';
				preg_match_all($pattern, $permalink, $matches);
				$keyword_occurrence = count($matches[0]);
			} else {
				$word_counts = array_count_values($content_words);
				$keyword_occurrence = isset($word_counts[$keyword]) ? $word_counts[$keyword] : 0;
			}
		
			// Calculate density as percentage
			$kw_density[] = ($keyword_occurrence * str_word_count($keyword) * 100)/$count_words;
			if(count($kw_density) > 0){
				$matching_keywords[] = $keyword;
				break;
			}
		}

		$status = !empty($kw_density) ? 'Good' : 'Error';

		$details = '';
		if($status === 'Good'){	
			$details .= '<p><span class="dashicons dashicons-thumbs-up"></span>'. __('Great! One of your target keywords is included in your permalink.', 'siteseo') .'</p>';
			$details .= '<ul><li><span class="dashicons dashicons-arrow-right"></span>' . implode(', ', $matching_keywords) . '</li></ul>';
		} elseif($permalink === get_home_url() || $permalink === home_url()){
			$details .= '<p><span class="dashicons dashicons-thumbs-up"></span>'. __('This is your homepage, so this check doesn\'t apply as there is no slug.', 'siteseo') . '</p>';
		} else{
			$details .= '<p><span class="dashicons dashicons-thumbs-down"></span>'. __('You should include one of your target keywords in your permalink.', 'siteseo') . '</p>';
		}

		return [
			'label' => __('Keywords in Permalink', 'siteseo'),
			'status' => $status,
			'status_class' => strtolower($status),
			'details' => $details
		];
		
	}
	
	static function check_meta_robots($post){

		$noindex = get_post_meta($post->ID, '_siteseo_robots_index', true);
		$nofollow = get_post_meta($post->ID, '_siteseo_robots_follow', true);
		$noimageindex = get_post_meta($post->ID, '_siteseo_robots_imageindex', true);
		$noarchive = get_post_meta($post->ID, '_siteseo_robots_archive', true);
		$nosnippet = get_post_meta($post->ID, '_siteseo_robots_snippet', true);

		$count_meta_robots = 0;
		$details = '';

		$meta_robots_checks = [
			'noindex' => $noindex,
			'nofollow' => $nofollow,
			'noimageindex' => $noimageindex,
			'noarchive' => $noarchive,
			'nosnippet' => $nosnippet,
		];

		foreach($meta_robots_checks as $robot => $value){
			if($value !== 'yes'){
				continue;
			}

			$count_meta_robots++;
			switch($robot){
				case 'noindex':
					$details .= '<p data-robots="noindex"><span class="dashicons dashicons-thumbs-down"></span>' . __('<strong>noindex</strong> is enabled! Search engines cannot index this page', 'siteseo') . '</p>';
					break;
				case 'nofollow':
					$details .= '<p><span class="dashicons dashicons-thumbs-down"></span>' . __('<strong>nofollow</strong> is on! Search engines can\'t follow your links on this page.', 'siteseo') . '</p>';
					break;
				case 'noimageindex':
					$details .= '<p><span class="dashicons dashicons-thumbs-down"></span>' . __('<strong>nofollow</strong> is enabled! Search engines cannot follow the links on this page.', 'siteseo').'</p>';
					break;
				case 'noarchive':
					$details .= '<p><span class="dashicons dashicons-thumbs-down"></span>' . __('<strong>noarchive</strong> is enabled! Search engines will not cache your page.', 'siteseo') .'</p>';
					break;
				case 'nosnippet':
					$details .= '<p><span class="dashicons dashicons-thumbs-down"></span>' . __('<strong>nosnippet</strong> is enabled! Search engines will not display a snippet of this page in the search results.', 'siteseo') .'</p>';
					break;
			}
		}

		if($count_meta_robots > 0){
			/* translators: %s represents the robots tags */ 
			$details .= '<p><span class="dashicons dashicons-thumbs-down"></span>'. sprintf(esc_html__('We found %s meta robots tags on your page. There may be an issue with your theme!', 'siteseo'), $count_meta_robots) .'</p>';
		}
		
		if($noindex !== 'yes'){
			$details .= '<p data-robots="index"><span class="dashicons dashicons-thumbs-up"></span>'. __('<strong>noindex</strong> is disabled. Search engines will index this page.', 'siteseo') .'</p>';
		}
		if($nofollow !== 'yes'){
			$details .= '<p><span class="dashicons dashicons-thumbs-up"></span>'. __('<strong>nofollow</strong> is disabled. Search engines will follow links on this page.', 'siteseo') .'</p>';
		}
		
		if($noimageindex !== 'yes'){
			$details .= '<p><span class="dashicons dashicons-thumbs-up"></span>'. __('<strong>noimageindex</strong> is disabled. Google will index the images on this page.', 'siteseo') .'</p>';
		}
		if($noarchive !== 'yes'){
			$details .= '<p><span class="dashicons dashicons-thumbs-up"></span>'. __('<strong>noarchive</strong> is disabled. Search engines will probably cache your page.', 'siteseo') .'</p>';
		}
		if($nosnippet !== 'yes'){
			$details .= '<p><span class="dashicons dashicons-thumbs-up"></span>'. __('<strong>nosnippet</strong> is disabled. Search engines will display a snippet of this page in search results.', 'siteseo') .'</p>';
		}
		
		if($count_meta_robots === 0){
			$details .= '<p><span class="dashicons dashicons-thumbs-up"></span>' . __('We found no meta robots on this page. It means, your page is index,follow. Search engines will index it, and follow links. ', 'siteseo') . '</p>';
		}

		$status = ($count_meta_robots === 0) ? 'Good' : 
				  (($count_meta_robots <= 2) ? 'Warning' : 'Error');

		return [
			'label' => 'Meta Robots',
			'status' => $status,
			'status_class' => strtolower($status),
			'details' => $details
		];
	}

    static function check_last_modified_date($post){
        $last_modified = get_the_modified_date('Y-m-d', $post);
        $days_since_modified = round((time() - strtotime($last_modified)) / (60 * 60 * 24));

        $status = $days_since_modified < 30 ? 'Good' : 
                  ($days_since_modified < 90 ? 'Warning' : 'Error');
				  
		$details = '';
		
		if($status == 'Error'){
			$details .= '<p><span class="dashicons dashicons-thumbs-down"></span>'. __('This post is a little old!', 'siteseo') .'</p>';
		}
		
		if($days_since_modified < 365){
			$details .='<p><span class="dashicons dashicons-thumbs-up"></span>'.__('The last modified date of this article is less than 1 year. Cool', 'siteseo') .'</p>';
		}
		
		$details .= '<p>'.__('Search engines love fresh content. Update regularly your articles without entirely rewriting your content and give them a boost in search rankings. SiteSEO takes care of the technical part', 'siteseo').'</p>';

        return [
            'label' => 'Last Modified Date',
            'status' => $status,
            'status_class' => strtolower($status),
			'details' => $details
        ];
    }
	
	static function analyze_readability($post, $title){
		$data = [];

		// These are power words specifically for headlines.
		// These are not hard rules, but they are perceived to have a higher CTR if used in the heading.
		$power_words = ['exclusive', 'revealed', 'secrets', 'ultimate', 'proven', 'unleashed', 'discover', 'breakthrough', 'shocking', 'insider', 'elite', 'uncovered', 'powerful', 'guaranteed', 'transformative', 'instant', 'revolutionary', 'unbelievable', 'top', 'best', 'must-have', 'limited', 'rare', 'unique', 'unprecedented', 'premium', 'urgent', 'today', 'now', 'latest', 'new', 'free', 'bonus', 'offer', 'sensational', 'astonishing', 'incredible', 'jaw-dropping', 'unmissable', 'essential', 'critical', 'vital', 'pivotal', 'game-changer', 'spotlight', 'trending', 'hot', 'popular', 'featured', 'special', 'limited-time', 'hurry', 'last chance', 'countdown'];
		
		if(!empty($title)){
			// Checking power words.
			$title_words = explode(' ', strtolower($title));

			$present_power_words = array_intersect($title_words, $power_words);

			if(!empty($present_power_words)){
				$data['power_words'] = $present_power_words;
			}

			// Checking number in the Title
			if(preg_match('/\s?\d+\s/', preg_quote($title), $number)){
				$data['number_found'] = $number[0];
			}
		}
		
		// We are checking paragarph length too.
		if(!isset($data['paragraph_length'])){
			$data['paragraph_length'] = 0;
		}
		
		if(!empty($post)){
			preg_match_all('/<p>.*<\/p>/U', $post, $paragraphs);

			foreach($paragraphs[0] as $paragraph){
				$paragraph = normalize_whitespace(wp_strip_all_tags($paragraph));
				
				$data['paragraph_length'] += substr_count($paragraph, ' ') + 1; // updating paragraph length
				self::analyse_passive_voice($paragraph, $data);
			}
		}

		return $data;
	}
	
	static function analyse_passive_voice($paragraph, &$data){

		if(empty($paragraph)){
			return;
		}

		$sentences = explode('.', $paragraph);
		$passive_count = 0;

		if(!isset($data['passive_voice']['passive_sentences'])){
			$data['passive_voice']['passive_sentences'] = 0;
		}
		
		if(!isset($data['passive_voice']['total_sentences'])){
			$data['passive_voice']['total_sentences'] = 0;
		}

		if(count($sentences) === 0){
			return;
		}

		foreach($sentences as $sentence){
			if(empty($sentence)){
				continue;
			}

			$sentence = normalize_whitespace($sentence);
			$is_passive = self::sentence_is_passive($sentence);
			
			if($is_passive == true){
				$passive_count++;
			}
		}

		$data['passive_voice']['passive_sentences'] += $passive_count;
		$data['passive_voice']['total_sentences'] += count($sentences);
	}

	static function sentence_is_passive($sentence){
		$be_words = ['am', 'is', 'are', 'was', 'were', 'be', 'being', 'been'];

		// TODO: We can check if "en" ending words are a comman pattern too, then we will remove the en ending words too from here.
		$past_particles = ['gone' ,'done' ,'seen' ,'taken' ,'eaten' ,'written' ,'driven' ,'spoken' ,'broken' ,'chosen' ,'fallen' ,'forgotten' ,'forgiven' ,'hidden' ,'known' ,'grown' ,'drawn' ,'flown' ,'thrown' ,'blown' ,'shown' ,'worn' ,'sworn' ,'torn' ,'woken' ,'begun' ,'sung' ,'run' ,'swum' ,'shaken' ,'given' ,'proven' ,'ridden' ,'risen' ,'shone' ,'shot' ,'fought' ,'thought' ,'bought' ,'brought' ,'caught' ,'taught' ,'built' ,'felt' ,'kept' ,'slept' ,'left' ,'lost' ,'meant' ,'met' ,'read' ,'sold' ,'sent' ,'spent' ,'stood' ,'understood' ,'won' ,'held' ,'told' ,'heard' ,'paid' ,'laid' ,'said' ,'found' ,'made' ,'learned' ,'put'];
		
		if(empty($sentence)){
			return false;
		}
		
		$words = explode(' ', $sentence);

		for($i = 0; $i < count($words); $i++){
			// Checking if we have a be word
			if(!in_array($words[$i], $be_words)){
				continue;
			}

			// If be word is there then need to check if next one is past particle with mostly ends with ed.
			if(strpos($words[$i+1], 'ed') != strlen($words[$i+1]) - 2){
				if(!in_array($words[$i+1], $past_particles)){
					continue;
				}
			}

			return true;
		}

		return false;
	}

	static function get_bricks_page_content($bricks_page){

		if(empty($bricks_page) || !is_array($bricks_page)){
			return;
		}

		$content = \Bricks\Frontend::render_data($bricks_page);

		$content = strip_shortcodes($content); // remove shortcodes
		$content = wp_strip_all_tags($content); // remove HTML tags

		return $content;
	}

}
PKv�f\+mzzmetaboxes/settings.phpnu�[���<?php
/*
* SITESEO
* https://siteseo.io
* (c) SiteSEO Team
*/

namespace SiteSEO\Metaboxes;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class Settings{

	static function render_metabox(){
		global $siteseo;

		$metabox_data = [];
		
		$show_content_analysis = true;
		
		if(is_user_logged_in()){
			
			if(is_super_admin()){
				
				$siteseo->display_ca_metaboxe = 1;
				$show_content_analysis = true;
			} else{
				$user = wp_get_current_user();
				$siteseo_user_role = current($user->roles);
				$siteseo_options = get_option('siteseo_advanced_option_name');
				
				$ca_metabox_roles = !empty($siteseo_options['security_metaboxe_ca_role']) ? $siteseo_options['security_metaboxe_ca_role'] : [];
				
				if(array_key_exists($siteseo_user_role, $ca_metabox_roles)){
					$siteseo->display_ca_metaboxe = 1;
					$show_content_analysis = false;
				}
			}
		}
		
		$metabox_data = self::metabox_data();
		self::metabox_form_html($metabox_data, $show_content_analysis);
	}
	
	static function metabox_data(){
		global $post, $siteseo;

		$metabox_data = [];
		$metabox_data['title'] = $post->post_title;
		$metabox_data['excerpt'] = $post->post_excerpt;

		// Getting the first paragraph of the post
		if(empty($metabox_data['excerpt'])){
			$post_seperated = get_extended($post->post_content);

			if(!empty($post_seperated['main'])){
				$metabox_data['excerpt'] = wp_strip_all_tags($post_seperated['main']);
			}
		}

		$metabox_data['keywords'] = get_post_meta($post->ID, 'siteseo_analysis_target_kw',true);
		$metabox_data['meta_title'] = get_post_meta($post->ID, '_siteseo_titles_title', true);
		$metabox_data['meta_desc'] = get_post_meta($post->ID, '_siteseo_titles_desc', true);
		$metabox_data['robots_canonical'] = get_post_meta($post->ID, '_siteseo_robots_canonical', true);
		$metabox_data['robots_primary_cat'] = get_post_meta($post->ID, '_siteseo_robots_primary_cat', true);
		$metabox_data['fb_title'] = get_post_meta($post->ID, '_siteseo_social_fb_title', true);
		$metabox_data['fb_desc'] = get_post_meta($post->ID, '_siteseo_social_fb_desc', true);
		$metabox_data['fb_img'] = get_post_meta($post->ID, '_siteseo_social_fb_img', true);
		$siteseo_social_fb_img_attachment_id = get_post_meta($post->ID, '_siteseo_social_fb_img_attachment_id', true);
		$siteseo_social_fb_img_width = get_post_meta($post->ID, '_siteseo_social_fb_img_width', true);
		$siteseo_social_fb_img_height = get_post_meta($post->ID, '_siteseo_social_fb_img_height', true);
		$metabox_data['x_title'] = get_post_meta($post->ID, '_siteseo_social_twitter_title', true);
		$metabox_data['x_desc'] = get_post_meta($post->ID, '_siteseo_social_twitter_desc', true);
		$metabox_data['x_img'] = get_post_meta($post->ID, '_siteseo_social_twitter_img', true);
		$siteseo_social_twitter_img_attachment_id = get_post_meta($post->ID, '_siteseo_social_twitter_img_attachment_id', true);
		$siteseo_social_twitter_img_width	= get_post_meta($post->ID, '_siteseo_social_twitter_img_width', true);
		$siteseo_social_twitter_img_height	= get_post_meta($post->ID, '_siteseo_social_twitter_img_height', true);
		$metabox_data['redirections_enabled'] = get_post_meta($post->ID, '_siteseo_redirections_enabled', true);
		$metabox_data['redirections_enabled_regex']	= get_post_meta($post->ID, '_siteseo_redirections_enabled_regex', true);
		$metabox_data['redirections_logged_status']	= get_post_meta($post->ID, '_siteseo_redirections_logged_status', true);
		$metabox_data['redirections_type'] = get_post_meta($post->ID, '_siteseo_redirections_type', true);
		$metabox_data['redirections_value'] = get_post_meta($post->ID, '_siteseo_redirections_value', true);
		$metabox_data['redirections_param'] = get_post_meta($post->ID, '_siteseo_redirections_param', true);

		$title_options = get_option('siteseo_titles_option_name', []);
		$metabox_data['disabled_robots'] = [
			'robots_index' => '',
			'robots_follow' => '',
			'archive' => '',
			'snippet' => '',
			'imageindex' => '',
		];

		if(post_password_required($post->ID) === true || !empty($title_options['titles_noindex'])){
			$metabox_data['robots_index'] = 'yes';
			$metabox_data['disabled_robots']['robots_index'] = 'disabled';
		} else{
			$metabox_data['robots_index'] = get_post_meta($post->ID, '_siteseo_robots_index', true);
		}
		
		if(!empty($title_options['titles_nofollow'])){
			$metabox_data['robots_follow'] = 'yes';
			$metabox_data['disabled_robots']['robots_follow'] = 'disabled';
		} else{
			$metabox_data['robots_follow'] = get_post_meta($post->ID, '_siteseo_robots_follow', true);
		}
		
		if(!empty($title_options['titles_noarchive'])){
			$metabox_data['robots_archive'] = 'yes';
			$metabox_data['disabled_robots']['archive'] = 'disabled';
		} else{
			$metabox_data['robots_archive'] = get_post_meta($post->ID, '_siteseo_robots_archive', true);
		}

		if(!empty($title_options['titles_nosnippet'])){
			$metabox_data['robots_snippet'] = 'yes';
			$metabox_data['disabled_robots']['snippet'] = 'disabled';
		} else{
			$metabox_data['robots_snippet'] = get_post_meta($post->ID, '_siteseo_robots_snippet', true);
		}

		if(!empty($title_options['titles_noimageindex'])){
			$metabox_data['robots_imageindex'] = 'yes';
			$metabox_data['disabled_robots']['imageindex'] = 'disabled';
		} else{
			$metabox_data['robots_imageindex'] = get_post_meta($post->ID, '_siteseo_robots_imageindex', true);
		}

		return $metabox_data;
	}
	
	static function metabox_term_data($term){
		global $tag;

		$metabox_data = [];

		$metabox_data['title'] = $tag->name;
		$metabox_data['excerpt'] = $tag->description;
		$metabox_data['meta_title'] = get_term_meta($term->term_id, '_siteseo_titles_title', true);
		$metabox_data['meta_desc'] = get_term_meta($term->term_id, '_siteseo_titles_desc', true);

		// Social Fields
		$metabox_data['fb_title'] = get_term_meta($term->term_id, '_siteseo_social_fb_title', true);
		$metabox_data['fb_desc'] = get_term_meta($term->term_id, '_siteseo_social_fb_desc', true);
		$metabox_data['fb_img'] = get_term_meta($term->term_id, '_siteseo_social_fb_img', true);
		$metabox_data['x_title'] = get_term_meta($term->term_id, '_siteseo_social_twitter_title', true);
		$metabox_data['x_desc'] = get_term_meta($term->term_id, '_siteseo_social_twitter_desc', true);
		$metabox_data['x_img'] = get_term_meta($term->term_id, '_siteseo_social_twitter_img', true);
		
		// Social Dimensions
		$fb_img_id = get_term_meta($term->term_id, '_siteseo_social_fb_img_attachment_id', true);
		$fb_img_width = get_term_meta($term->term_id, '_siteseo_social_fb_img_width', true);
		$fb_img_height = get_term_meta($term->term_id, '_siteseo_social_fb_img_height', true);
		$x_img_id = get_term_meta($term->term_id, '_siteseo_social_twitter_img_attachment_id', true);
		$x_img_width = get_term_meta($term->term_id, '_siteseo_social_twitter_img_width', true);
		$x_img_height = get_term_meta($term->term_id, '_siteseo_social_twitter_img_height', true);

		// Redirection fields
		$metabox_data['redirections_enabled'] = get_term_meta($term->term_id, '_siteseo_redirections_enabled', true);
		$metabox_data['redirections_logged_status']	= get_term_meta($term->term_id, '_siteseo_redirections_logged_status', true);
		$metabox_data['redirections_type'] = get_term_meta($term->term_id, '_siteseo_redirections_type', true);
		$metabox_data['redirections_value'] = get_term_meta($term->term_id, '_siteseo_redirections_value', true);
		$metabox_data['robots_canonical']= get_term_meta($term->term_id, '_siteseo_robots_canonical', true);

		$title_options = get_option('siteseo_titles_option_name', []);
		$metabox_data['disabled_robots'] = [
			'robots_index' => '',
			'robots_follow' => '',
			'archive' => '',
			'snippet' => '',
			'imageindex' => '',
		];

		if(!empty($title_options['titles_noindex'])){
			$metabox_data['robots_index'] = 'yes';
			$metabox_data['disabled_robots']['robots_index'] = 'disabled';
		} else {
			$metabox_data['robots_index'] = get_term_meta($term->term_id, '_siteseo_robots_index', true);
		}

		if(!empty($title_options['titles_nofollow'])){
			$metabox_data['robots_follow'] = 'yes';
			$metabox_data['disabled_robots']['robots_follow'] = 'disabled';
		} else {
			$metabox_data['robots_follow'] = get_term_meta($term->term_id, '_siteseo_robots_follow', true);
		}

		if(!empty($title_options['titles_noarchive'])){
			$metabox_data['robots_archive'] = 'yes';
			$metabox_data['disabled_robots']['archive'] = 'disabled';
		} else {
			$metabox_data['robots_archive'] = get_term_meta($term->term_id, '_siteseo_robots_archive', true);
		}

		if(!empty($title_options['titles_nosnippet'])){
			$metabox_data['robots_snippet'] = 'yes';
			$metabox_data['disabled_robots']['snippet'] = 'disabled';
		} else {
			$metabox_data['robots_snippet'] = get_term_meta($term->term_id, '_siteseo_robots_snippet', true);
		}

		if(!empty($title_options['titles_noimageindex'])){
			$metabox_data['robots_imageindex'] = 'yes';
			$metabox_data['disabled_robots']['imageindex'] = 'disabled';
		} else {
			$metabox_data['robots_imageindex'] = get_term_meta($term->term_id, '_siteseo_robots_imageindex', true);
		}

		return $metabox_data;
	}
		
	static function metabox_form_html(&$metabox_data, $show_content_analysis = false){
		global $siteseo, $post, $pagenow, $typenow;
		
		$pro_settings = isset($siteseo->pro) ? $siteseo->pro : '';
		
		// Checked x is enabled global settings
		$enable_x_card = !empty($siteseo->social_settings['social_twitter_card']);
		
		$data_attr = [];
		$data_attr['data_tax'] = '';
		$data_attr['termId'] = '';

		if('post-new.php' == $pagenow || 'post.php' == $pagenow){
			$data_attr['current_id'] = $post->ID;
			$data_attr['origin'] = 'post';
			$data_attr['title'] = get_the_title($data_attr['current_id']);
		} elseif('term.php' == $pagenow || 'edit-tags.php' == $pagenow){
			global $tag;
			$data_attr['current_id'] = $tag->term_id;
			$data_attr['termId'] = $tag->term_id;
			$data_attr['origin'] = 'term';
			$data_attr['data_tax'] = $tag->taxonomy;
			$data_attr['title'] = $tag->name;
		}

		$data_attr['isHomeId'] = get_option('page_on_front');
		if($data_attr['isHomeId'] === '0'){
			$data_attr['isHomeId'] = '';
		}

		// Static Data
		$home_url = home_url();
		$parsed_url = wp_parse_url($home_url);
		$host_uri = $parsed_url['host'];
		$social_placeholder = SITESEO_ASSETS_URL . '/img/social-placeholder.png';

		$metabox_tag_drop_kses = [
			'button' => [
				'class' => true,
				'type' => true,
			],
			'span' => [
				'class' => true,
			],
			'div' => [
				'class' => true,
				'style' => true,
			],
			'input' => [
				'type' => true,
				'class' => true,
				'name' => true,
				'spellcheck' => true,
				'placeholder' => true,
			],
			'ul' => true,
			'li' => [
				'class' => true,
				'data-*' => true,
				'tabindex' => true,
			]
		];
		
		// Preview of social title and description
		$current_screen = get_current_screen();

		if(!empty($current_screen) && $current_screen->base === 'term'){
			$term_id = isset($_GET['tag_ID']) ? (int)$_GET['tag_ID'] : 0;
			$taxonomy = $current_screen->taxonomy;
		} else{
			$post_type = $current_screen->post_type;
		}

		$site_title_placeholder = '';
		$site_desc_placeholder = '';
		$social_preview_title = '';
		$social_preview_desc = '';
		
		if(!empty($post_type) && !empty($siteseo->titles_settings['titles_single_titles'][$post_type]['title'])){
			$site_title_placeholder = $siteseo->titles_settings['titles_single_titles'][$post_type]['title'];
		} elseif(!empty($taxonomy) && !empty($siteseo->titles_settings['titles_tax_titles'][$taxonomy]['title'])){
			$site_title_placeholder = $siteseo->titles_settings['titles_tax_titles'][$taxonomy]['title'];
		} else{
			$site_title_placeholder = $metabox_data['title'];
		}
		
		if(!empty($post_type) && !empty($siteseo->titles_settings['titles_single_titles'][$post_type]['description'])){
			$site_desc_placeholder = $siteseo->titles_settings['titles_single_titles'][$post_type]['description'];
		} elseif(!empty($taxonomy) && !empty($siteseo->titles_settings['titles_tax_titles'][$taxonomy]['description'])){
			$site_desc_placeholder =  $siteseo->titles_settings['titles_tax_titles'][$taxonomy]['description'];
		} else{
			$site_desc_placeholder = $metabox_data['excerpt'];
		}

		if(!empty($metabox_data['meta_title'])){
			$social_preview_title = $metabox_data['meta_title'];
		} elseif(!empty($post_type) && !empty($siteseo->titles_settings['titles_single_titles'][$post_type]['title'])){
			$social_preview_title = $siteseo->titles_settings['titles_single_titles'][$post_type]['title'];
		} elseif(!empty($taxonomy) && !empty($siteseo->titles_settings['titles_tax_titles'][$taxonomy]['title'])){
			$social_preview_title = $siteseo->titles_settings['titles_tax_titles'][$taxonomy]['title'];
		} else{
			$social_preview_title = get_the_title();
		}
		
		
		if(!empty($metabox_data['meta_desc'])){
			$social_preview_desc = $metabox_data['meta_desc'];
		} elseif(!empty($post_type) && !empty($siteseo->titles_settings['titles_single_titles'][$post_type]['description'])){
			$social_preview_desc = $siteseo->titles_settings['titles_single_titles'][$post_type]['description'];
		} elseif(!empty($taxonomy) && !empty($siteseo->titles_settings['titles_tax_titles'][$taxonomy]['description'])){
			$social_preview_desc = $siteseo->titles_settings['titles_tax_titles'][$taxonomy]['description'];
		} else{
			$social_preview_desc = get_bloginfo('description');
		}
		
		if(empty($siteseo->advanced_settings['appearance_ca_metaboxe']) && !empty($show_content_analysis)){
			$siteseo_metabox_tabs = [
				'content-analysis' => __('Content Analysis', 'siteseo')
			];
		}

		$siteseo_metabox_tabs['title-settings'] = __('Title', 'siteseo');
		$siteseo_metabox_tabs['social-settings'] = __('Social', 'siteseo');
		$siteseo_metabox_tabs['advanced-settings'] = __('Advanced', 'siteseo');

		$siteseo_metabox_tabs['redirect'] = __('Redirects', 'siteseo');
		
		if(!empty($pro_settings['enable_structured_data']) && !empty($pro_settings['toggle_state_stru_data']) && !empty($show_content_analysis)){
			$siteseo_metabox_tabs['structured-data-types'] = __('Structured Data Types', 'siteseo');
		}
		
		if(!empty($pro_settings['toggle_state_video_sitemap']) && !empty($pro_settings['enable_video_sitemap']) && !empty($show_content_analysis)){
			$siteseo_metabox_tabs['video-sitemap'] = __('Video Sitemap', 'siteseo');
		}
		
		if(!empty($pro_settings['toggle_state_google_news']) && !empty($pro_settings['google_news']) && !empty($show_content_analysis)){
			$siteseo_metabox_tabs['google-news'] = __('Google News', 'siteseo');
		}

		echo'<div id="siteseo-metabox-wrapper" class="siteseo-metabox-wrapper">
		<div class="siteseo-metabox-tabs" data-home-id="'.esc_attr($data_attr['isHomeId']).'" data-term-id="'.esc_attr($data_attr['termId']).'" data_id="'.esc_attr($data_attr['current_id']).'" data_origin="'.esc_attr($data_attr['origin']).'" data_tax="'.esc_attr($data_attr['data_tax']).'">';
		
		wp_nonce_field('siteseo_metabox_nonce', 'siteseo_metabox_nonce');

		foreach($siteseo_metabox_tabs as $siteseo_metabox_tab => $siteseo_metabox_tab_title){
			$selected_metabox_tab = '';

			if($siteseo_metabox_tab === 'content-analysis'){
				$selected_metabox_tab = 'siteseo-metabox-tab-label-active';
			}

			if(empty($siteseo->display_ca_metaboxe) && $siteseo_metabox_tab === 'title-settings'){
				$selected_metabox_tab = 'siteseo-metabox-tab-label-active';
			}			
			
			echo'<div class="siteseo-metabox-tab-label '.esc_attr($selected_metabox_tab).'" data-tab="siteseo-metabox-tab-'.esc_attr($siteseo_metabox_tab).'">';
			
			if($siteseo_metabox_tab === 'advanced-settings' && !empty($metabox_data['robots_index'])){
				echo'<span class="dashicons dashicons-hidden siteseo-noindex-warning"></span>';
			}
			
			echo esc_html($siteseo_metabox_tab_title).'</div>';
		}
			
		$home_url = home_url();
		$parsed_home_url = wp_parse_url($home_url);
		
		$ai_logo = SITESEO_ASSETS_URL . '/img/siteseo-ai.svg';
		
		$meta_desc_percentage = '1';
		if(!empty($metabox_data['meta_desc'])){
			$meta_desc_percentage = (strlen($metabox_data['meta_desc'])/160)*100;
		} elseif(!empty($metabox_data['excerpt'])){
			$meta_desc_percentage = (strlen($metabox_data['excerpt'])/160)*100;
		}

		if(intval($meta_desc_percentage) > 100){
			$meta_desc_percentage = '100';
		}

		$meta_title_percentage = '1';
		if(!empty($metabox_data['meta_title'])){
			$meta_title_percentage = (strlen($metabox_data['meta_title'])/60)*100;
		} else if(!empty($metabox_data['title'])){
			$meta_title_percentage = (strlen($metabox_data['title'])/60)*100;
		}

		if(intval($meta_title_percentage) > 100){
			$meta_title_percentage = '100';
		}

		echo'</div>';
		if(empty($siteseo->advanced_settings['appearance_ca_metaboxe']) && $show_content_analysis){
			echo'<div class="siteseo-sidebar-tabs siteseo-sidebar-tabs-opened"><span>'.esc_html__('Content Analysis', 'siteseo').'</span><span class="siteseo-sidebar-tabs-arrow"><span class="dashicons dashicons-arrow-down-alt2"></span></span></div>
			<div class="siteseo-metabox-tab-content-analysis siteseo-metabox-tab" style="display:block;">';
				self::content_analysis($post);
			echo'</div>';
		}
		
		$allowed_suggestion_tags = array(
			'button' => array(
				'class' => array(),
				'type' => array(),
			),
			'span' => array(
				'id' => array(),
				'class' => array(),
			),
			'div' => array(
				'class' => array(),
				'style' => array(),
			),
			'input' => array(
				'type' => array(),
				'class' => true,
				'placeholder' => true,
			)
		);
		
		// if all x-settings empty then use same as og option enabled
		$use_og_settings = (empty($metabox_data['x_title']) && empty($metabox_data['x_desc']) && empty($metabox_data['x_img']));
		
		// show image in preview
		if(!empty($metabox_data['x_img'])){
			$x_image = $metabox_data['x_img'];
		} else if(!empty($metabox_data['fb_img']) && !empty($use_og_settings)){ // use og enabled
			$x_image = $metabox_data['fb_img'];
		} else{
			$x_image = $social_placeholder;
		}
		
		// x preview title
		if(!empty($metabox_data['x_title'])){
			$x_title_preview = $metabox_data['x_title'];
		} else if($metabox_data['fb_title'] &&  !empty($use_og_settings)){
			$x_title_preview = $metabox_data['fb_title'];
		} else {
			$x_title_preview = $social_preview_title;
		}
		
		echo'<div class="siteseo-sidebar-tabs '.(empty($siteseo->display_ca_metaboxe) ? 'siteseo-sidebar-tabs-opened' : '').'"><span>'.esc_html__('Title', 'siteseo').'</span><span class="siteseo-sidebar-tabs-arrow"><span class="dashicons dashicons-arrow-down-alt2"></span></span></div>
		<div class="siteseo-metabox-tab-title-settings siteseo-metabox-tab" style="'.(empty($siteseo->display_ca_metaboxe) ? 'display:block;' : '').'">
		<div class="siteseo-metabox-option-wrap">
			<div class="siteseo-metabox-label-wrap">
				<label>'.esc_html__('Search Preview','siteseo').'</label>
			</div>
			<div class="siteseo-metabox-search-preview">
				<div class="siteseo-search-preview-toggle">
					<span id="siteseo-metabox-search-pc" style="display:none">'.esc_html__('Show Desktop version', 'siteseo').'</span>
					<span id="siteseo-metabox-search-mobile">'.esc_html__('Show Mobile version', 'siteseo').'</span>
				</div>
				<div class="siteseo-search-preview-desktop">
					<div class="siteseo-search-preview-metadata">
						<div style="background-color: #e2eeff; border: 1px solid #e2eeff; height:28px; width:28px; padding: 3px; border-radius: 50px; display:flex; align-items:center; justify-content:center;">
						<svg focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#0060f0"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z"></path></svg>
						</div>
						<div class="siteseo-search-preview-metadata-link">
							<div>'.esc_url($parsed_home_url['host']).'</div>
							<div><cite>'.esc_url(home_url()).'</cite></div>
						</div>
						<div>
						<svg focusable="false" xmlns="http://www.w3.org/2000/svg" width="20" viewBox="0 0 24 24"><path d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"></path></svg>
						</div>
					</div>
					<h3>'.(!empty($metabox_data['meta_title']) ? esc_html(\SiteSEO\TitlesMetas::replace_variables($metabox_data['meta_title'], true)) : (!empty($site_title_placeholder) ? esc_html(\SiteSEO\TitlesMetas::replace_variables($site_title_placeholder, true)) : 'Post Title here')).'</h3>
					<div class="siteseo-search-preview-description">
					'.(!empty($metabox_data['meta_desc']) ? esc_html(\SiteSEO\TitlesMetas::replace_variables($metabox_data['meta_desc'], true)) : (!empty($site_desc_placeholder) ? esc_html(substr(\SiteSEO\TitlesMetas::replace_variables($site_desc_placeholder, true), 0, 160)) : 'Post description')).'
					</div>
					
				</div>
			</div>
		</div>
		<div class="siteseo-metabox-option-wrap">
			<div class="siteseo-metabox-label-wrap">
				<label for="siteseo_titles_title_meta">'.esc_html__('Title', 'siteseo').'</label>
			</div>
			<div class="siteseo-metabox-input-wrap">
				<div class="siteseo-metabox-tags">
					<button type="button" class="siteseo-metabox-tag" data-tag="%%post_title%%"><span class="dashicons dashicons-plus"></span> Post Title</button>
					<button type="button" class="siteseo-metabox-tag" data-tag="%%sitetitle%%"><span class="dashicons dashicons-plus"></span> Site Title</button>
					<button type="button" class="siteseo-metabox-tag" data-tag="%%sep%%"><span class="dashicons dashicons-plus"></span>Seperator</button>'.wp_kses(siteseo_suggestion_button_metabox(), $allowed_suggestion_tags);
					if(defined('SITESEO_PRO_VERSION') && !defined('SITEPAD')){
						echo'<span class="siteseo-ai-modal-open" data-context="site-page" title="SiteSEO AI Assistant"><img src="'.esc_url($ai_logo).'" alt="AI Assistant Icon">'.'<label class="siteseo-ai-modal-label">'.esc_html__('Ask AI', 'siteseo').'</label></span>';
					}
				echo'</div>
				<input type="text" id="siteseo_titles_title_meta" class="siteseo_titles_title_meta" name="siteseo_titles_title" placeholder="'.(!empty($site_title_placeholder) ? esc_attr(\SiteSEO\TitlesMetas::replace_variables($site_title_placeholder, true)) : esc_html__('Enter title for this post', 'siteseo')).'" value="'.(!empty($metabox_data['meta_title']) ? esc_html($metabox_data['meta_title']) : '').'"/>
				<div class="siteseo-metabox-limits">
					<span class="siteseo-metabox-limits-meter"><span style="width:'.esc_attr($meta_title_percentage).'%"></span></span>
					<span class="siteseo-metabox-limits-numbers"><em>'.esc_html(strlen($metabox_data['meta_title'])).'</em> out of 60 max recommended characters</span>
				</div>
			</div>
		</div>
		<div class="siteseo-metabox-option-wrap">
			<div class="siteseo-metabox-label-wrap">
				<label for="siteseo_titles_desc_meta">'.esc_html__('Meta Description', 'siteseo').'</label>
			</div>
			<div class="siteseo-metabox-input-wrap">
				<div class="siteseo-metabox-tags">
					<button type="button" class="siteseo-metabox-tag" data-tag="%%post_excerpt%%"><span class="dashicons dashicons-plus"></span> Post Excerpt</button>'.wp_kses(siteseo_suggestion_button_metabox(), $allowed_suggestion_tags);
					if(defined('SITESEO_PRO_VERSION') && !defined('SITEPAD')){
						echo'<span class="siteseo-ai-modal-open" data-context="site-page" title="SiteSEO AI Assistant"><img src="'.esc_url($ai_logo).'" alt="AI Assistant Icon">'.'<label class="siteseo-ai-modal-label">'.esc_html__('Ask AI', 'siteseo').'</label></span>';
					}
				echo'</div>
				<textarea id="siteseo_titles_desc_meta" class="siteseo_titles_desc_meta" name="siteseo_titles_desc" rows="2" placeholder="'.(!empty($site_desc_placeholder) ? esc_attr(substr(\SiteSEO\TitlesMetas::replace_variables($site_desc_placeholder, true), 0, 160)) : esc_html__('Enter description for this post', 'siteseo')).'">'.(!empty($metabox_data['meta_desc']) ? esc_html($metabox_data['meta_desc']) : '').'</textarea>
				<div class="siteseo-metabox-limits">
					<span class="siteseo-metabox-limits-meter"><span style="width:'.esc_attr($meta_desc_percentage).'%"></span></span>
					<span class="siteseo-metabox-limits-numbers"><em>'.esc_html(strlen($metabox_data['meta_desc'])).'</em> out of 160 max recommended characters</span>
				</div>
			</div>
		</div>
		</div>

		<div class="siteseo-sidebar-tabs"><span>'.esc_html__('Social', 'siteseo').'</span><span class="siteseo-sidebar-tabs-arrow"><span class="dashicons dashicons-arrow-down-alt2"></span></span></div>
		<div class="siteseo-metabox-tab-social-settings siteseo-metabox-tab">
			<div class="siteseo-metabox-subtabs">
				<div class="siteseo-metabox-tab-label siteseo-metabox-tab-label-active" data-tab="siteseo-metabox-tab-fb-settings">Facebook</div>
				<div class="siteseo-metabox-tab-label" data-tab="siteseo-metabox-tab-x-settings">X(Twitter)</div>
			</div>
			<div class="siteseo-metabox-tab-fb-settings siteseo-metabox-tab" style="display:block;">
			<div class="siteseo-metabox-option-wrap">
				<div class="siteseo-metabox-label-wrap">
					<label>'.esc_html__('Preview', 'siteseo').'</label>
				</div>
				<div class="siteseo-metabox-fb-preview">
					<div class="siteseo-metabox-fb-image">
						<img src="'.(!empty($metabox_data['fb_img']) ? esc_url($metabox_data['fb_img']) : esc_url($social_placeholder)).'" alt="Facebook preview"/>
					</div>
					<div class="siteseo-metabox-fb-data">
						<div class="siteseo-metabox-fb-host">'.(!empty($host_uri) ? esc_html($host_uri) : '').'</div>
						<div class="siteseo-metabox-fb-title">'.(!empty($metabox_data['fb_title']) ? esc_html(\SiteSEO\TitlesMetas::replace_variables($metabox_data['fb_title'], true)) : esc_html(\SiteSEO\TitlesMetas::replace_variables($social_preview_title, true))).'</div>
						<div class="siteseo-metabox-fb-desc">'.(!empty($metabox_data['fb_desc']) ? esc_html(\SiteSEO\TitlesMetas::replace_variables($metabox_data['fb_desc'], true)) : esc_html(\SiteSEO\TitlesMetas::replace_variables($social_preview_desc, true))).'</div>
					</div>
				</div>
			</div>
			<div class="siteseo-metabox-option-wrap">
				<div class="siteseo-metabox-label-wrap">
					<label for="siteseo_social_fb_title_meta">'.esc_html__('Facebook Title', 'siteseo').'</label>
				</div>
				<div class="siteseo-metabox-input-wrap">
					<input type="text" id="siteseo_social_fb_title_meta" class="siteseo_social_fb_title_meta" name="siteseo_social_fb_title" placeholder="'.(!empty($social_preview_title) ? esc_html(\SiteSEO\TitlesMetas::replace_variables($social_preview_title, true)) : '').'" value="'.(!empty($metabox_data['fb_title']) ? esc_attr($metabox_data['fb_title']) : '').'" />
					<div class="siteseo-metabox-tags">
						<button type="button" class="siteseo-facebook-title" data-tag="%%post_title%%"><span class="dashicons dashicons-plus"></span> Post Title</button>
						<button type="button" class="siteseo-facebook-title" data-tag="%%sitetitle%%"><span class="dashicons dashicons-plus"></span> Site Title</button>
						<button type="button" class="siteseo-facebook-title" data-tag="%%sep%%"><span class="dashicons dashicons-plus"></span>Seperator</button>'.wp_kses(siteseo_suggestion_button_metabox(), $allowed_suggestion_tags);
						if(defined('SITESEO_PRO_VERSION') && !defined('SITEPAD')){
							echo'<span class="siteseo-ai-modal-open" data-context="og" title="SiteSEO AI Assistant"><img src="'.esc_url($ai_logo).'" alt="AI Assistant Icon">'.'<label class="siteseo-ai-modal-label">'.esc_html__('Ask AI', 'siteseo').'</label></span>';
						}
					echo'</div>
				</div>
			</div>

			<div class="siteseo-metabox-option-wrap">
				<div class="siteseo-metabox-label-wrap">
					<label for="siteseo_social_fb_desc_meta">'.esc_html__('Facebook description', 'siteseo').'</label>
				</div>
				<div class="siteseo-metabox-input-wrap">
					<textarea id="siteseo_social_fb_desc_meta" class="siteseo_social_fb_desc_meta" name="siteseo_social_fb_desc" rows="2" placeholder="'.(!empty($social_preview_desc) ? esc_html(\SiteSEO\TitlesMetas::replace_variables($social_preview_desc, true)) : '').'">'.(!empty($metabox_data['fb_desc']) ? esc_html($metabox_data['fb_desc']) : '').'</textarea>
					<div class="siteseo-metabox-tags">
						<button type="button" class="siteseo-facebook-desc" data-tag="%%post_excerpt%%"><span class="dashicons dashicons-plus"></span> Post Excerpt</button>'.wp_kses(siteseo_suggestion_button_metabox(), $allowed_suggestion_tags);
						if(defined('SITESEO_PRO_VERSION') && !defined('SITEPAD')){
							echo'<span class="siteseo-ai-modal-open" data-context="og" title="SiteSEO AI Assistant"><img src="'.esc_url($ai_logo).'" alt="AI Assistant Icon">'.'<label class="siteseo-ai-modal-label">'.esc_html__('Ask AI', 'siteseo').'</label></span>';
						}
					echo'</div>
				</div>
			</div>

			<div class="siteseo-metabox-option-wrap">
				<div class="siteseo-metabox-label-wrap">
					<label for="siteseo_social_fb_img_meta">'.esc_html__('Facebook Thumbnail', 'siteseo').'</label>
				</div>
				<div class="siteseo-metabox-input-wrap">
					<span style="color:red; font-weight:bold; display:none;"></span>
					<input type="text" id="siteseo_social_fb_img_meta" name="siteseo_social_fb_img" class="siteseo_social_fb_img_meta" placeholder="'.esc_html__('Enter URL of the Image you want to be shown as the Facebook image', 'siteseo').'" value="'.(!empty($metabox_data['fb_img']) ? esc_url($metabox_data['fb_img']) : '').'"/>
					<p class="description">'.esc_html__('Minimum size: 200x200px, ideal ratio 1.91:1, 8Mb max. (eg: 1640x856px or 3280x1712px for retina screens).', 'siteseo').'</p>
					<input type="hidden" name="siteseo_social_fb_img_attachment_id" id="siteseo_social_fb_img_attachment_id" class="siteseo_social_fb_img_attachment_id" value="">
					<input type="hidden" name="siteseo_social_fb_img_width" id="siteseo_social_fb_img_width" class="siteseo_social_fb_img_width" value="">
					<input type="hidden" name="siteseo_social_fb_img_height" id="siteseo_social_fb_img_height" class="siteseo_social_fb_img_height" value="">
					<button class="components-button is-secondary" id="siteseo_social_fb_img_upload">Upload Image</button>
				</div>
			</div>
			</div>

			<div class="siteseo-metabox-tab-x-settings siteseo-metabox-tab">
			<div class="siteseo-metabox-option-wrap">
				<div class="siteseo-metabox-label-wrap">
					<label>'.esc_html__('Preview','siteseo').'</label>
				</div>
				<div>
				<div class="siteseo-metabox-x-preview">
					<div class="siteseo-metabox-x-image">
						<img src="'.($x_image ? esc_url($x_image) : '').'" alt="X preview"/>
					</div>
					<div class="siteseo-metabox-x-data">
						<div class="siteseo-metabox-x-title">'.(!empty($x_title_preview) ? esc_html(\SiteSEO\TitlesMetas::replace_variables($x_title_preview, true)) : '').'</div>
					</div>
				</div>
				<div class="siteseo-metabox-x-host">From '.(!empty($host_uri) ? esc_html($host_uri) : '').'</div>
				</div>
			</div>';
			
			if(!empty($enable_x_card)){
				
				echo'<div class="siteseo-metabox-option-wrap">
					<div class="siteseo-metabox-label-wrap">
						<label>'.esc_html__('Use same as Facebook settings', 'siteseo').'</label>
					</div>
					<div class="siteseo-metabox-input-wrap">
						<label class="siteseo-x-toggle-switch">';
							$checked = !empty($metabox_data['x_title'] || $metabox_data['x_desc'] || $metabox_data['x_img']) ? '' : "checked=checked";
							
							echo'<input name="siteseo_social_use_og_settings" type="checkbox" '.esc_html($checked).'/>
							<span class="siteseo-x-slider"></span>
						</label>
					</div>
				</div>';
			}
			
			if(!empty($enable_x_card)){
				echo'<div class="siteseo-x-settings" '.(!empty($use_og_settings) ? 'style="display:none;"' : '').'>';
			}
			
			echo'<div class="siteseo-metabox-option-wrap">
				<div class="siteseo-metabox-label-wrap">
					<label for="siteseo_social_twitter_title_meta">'.esc_html__('X Title', 'siteseo').'</label>
				</div>
				<div class="siteseo-metabox-input-wrap">
					<input type="text" id="siteseo_social_twitter_title_meta" class="siteseo_social_twitter_title_meta" name="siteseo_social_twitter_title" placeholder="'.(!empty($social_preview_title) ? esc_html(\SiteSEO\TitlesMetas::replace_variables($social_preview_title, true)) : '').'" value="'.(!empty($metabox_data['x_title']) ? esc_attr($metabox_data['x_title']) : '').'" />
					<div class="siteseo-metabox-tags">
						<button type="button" class="siteseo-x-title" data-tag="%%post_title%%"><span class="dashicons dashicons-plus"></span> Post Title</button>
						<button type="button" class="siteseo-x-title" data-tag="%%sitetitle%%"><span class="dashicons dashicons-plus"></span> Site Title</button>
						<button type="button" class="siteseo-x-title" data-tag="%%sep%%"><span class="dashicons dashicons-plus"></span>Seperator</button>'.wp_kses(siteseo_suggestion_button_metabox(), $allowed_suggestion_tags);
						if(defined('SITESEO_PRO_VERSION') && !defined('SITEPAD')){
							echo'<span class="siteseo-ai-modal-open" data-context="twitter" title="SiteSEO AI Assistant"><img src="'.esc_url($ai_logo).'" alt="AI Assistant Icon">'.'<label class="siteseo-ai-modal-label">'.esc_html__('Ask AI', 'siteseo').'</label></span>';
						}
					echo'</div>
				</div>
			</div>
			
			<div class="siteseo-metabox-option-wrap">
				<div class="siteseo-metabox-label-wrap">
					<label for="siteseo_social_twitter_desc_meta">'.esc_html__('X description', 'siteseo').'</label>
				</div>
				<div class="siteseo-metabox-input-wrap">
					<textarea id="siteseo_social_twitter_desc_meta" class="siteseo_social_twitter_desc_meta" name="siteseo_social_twitter_desc" rows="2" placeholder="'.(!empty($social_preview_desc) ? esc_html(\SiteSEO\TitlesMetas::replace_variables($social_preview_desc, true)) : '').'">'.(!empty($metabox_data['x_desc']) ? esc_attr($metabox_data['x_desc']) : '').'</textarea>
					<div class="siteseo-metabox-tags">
						<button type="button" class="siteseo-x-desc" data-tag="%%post_excerpt%%"><span class="dashicons dashicons-plus"></span> Post Excerpt</button>'.wp_kses(siteseo_suggestion_button_metabox(), $allowed_suggestion_tags);
						if(defined('SITESEO_PRO_VERSION') && !defined('SITEPAD')){
							echo'<span class="siteseo-ai-modal-open" data-context="twitter" title="SiteSEO AI Assistant"><img src="'.esc_url($ai_logo).'" alt="AI Assistant Icon">'.'<label class="siteseo-ai-modal-label">'.esc_html__('Ask AI', 'siteseo').'</label></span>';
						}
					echo'</div>
				</div>
			</div>
			
			<div class="siteseo-metabox-option-wrap">
				<div class="siteseo-metabox-label-wrap">
					<label for="siteseo_social_twitter_img_meta">'.esc_html__('X Thumbnail', 'siteseo').'</label>
				</div>
				<div class="siteseo-metabox-input-wrap">
					<span style="color:red; font-weight:bold; display:none;"></span>
					<input type="text" id="siteseo_social_twitter_img_meta" class="siteseo_social_twitter_img_meta" name="siteseo_social_twitter_img" placeholder="'.esc_html__('Enter URL of the Image you want to be shown as the X image', 'siteseo').'" value="'.(!empty($metabox_data['x_img']) ? esc_attr($metabox_data['x_img']) : '').'" />
					<p class="description">'.esc_html__('Minimum size: 144x144px (300x157px with large card enabled), ideal ratio 1:1 (2:1 with large card), 5Mb max.', 'siteseo').'</p>
					<input type="hidden" name="siteseo_social_twitter_img_attachment_id" id="siteseo_social_twitter_img_attachment_id" class="siteseo_social_twitter_img_attachment_id" value="">
					<input type="hidden" name="siteseo_social_twitter_img_width" id="siteseo_social_twitter_img_width" class="siteseo_social_twitter_img_width" value="">
					<input type="hidden" name="siteseo_social_twitter_img_height" id="siteseo_social_twitter_img_height" class="siteseo_social_twitter_img_height" value="">
					<button class="components-button is-secondary" id="siteseo_social_twitter_img_upload">Upload Image</button>
				</div>
			</div>';

			if(!empty($enable_x_card)){
				echo'</div>';
			}
			
			echo'</div>
		</div>';
		
		if(!empty($pro_settings['enable_structured_data']) && !empty($pro_settings['toggle_state_stru_data']) && !empty($show_content_analysis)){
			echo'<div class="siteseo-sidebar-tabs"><span>'.esc_html__('Structured Data Types', 'siteseo').'</span><span class="siteseo-sidebar-tabs-arrow"><span class="dashicons dashicons-arrow-down-alt2"></span></span></div>
			<div class="siteseo-metabox-tab-structured-data-types siteseo-metabox-tab">';
				// Pro fearure
				do_action('siteseo_display_structured_data_types');
			echo'</div>';
		}
		
		// video sitemap
		if(!empty($pro_settings['toggle_state_video_sitemap']) && !empty($pro_settings['enable_video_sitemap']) && !empty($show_content_analysis)){
			echo'<div class="siteseo-sidebar-tabs"><span>'.esc_html__('Video Sitemap', 'siteseo').'</span><span class="siteseo-sidebar-tabs-arrow"><span class="dashicons dashicons-arrow-down-alt2"></span></span></div>
			<div class="siteseo-metabox-tab-video-sitemap siteseo-metabox-tab">';
				do_action('siteseo_display_video_sitemap');
			echo'</div>';
		}
		
		// gooogle news exclude 
		if(!empty($pro_settings['toggle_state_google_news']) && !empty($pro_settings['google_news']) && !empty($show_content_analysis)){
			echo'<div class="siteseo-sidebar-tabs"><span>'.esc_html__('Google News', 'siteseo').'</span><span class="siteseo-sidebar-tabs-arrow"><span class="dashicons dashicons-arrow-down-alt2"></span></span></div>
			<div class="siteseo-metabox-tab-google-news siteseo-metabox-tab">';
				do_action('siteseo_display_google_news');
			echo'</div>';
		}
		
		echo'<div class="siteseo-sidebar-tabs"><span>';

		if(!empty($metabox_data['robots_index'])){
			echo'<span class="dashicons dashicons-hidden siteseo-noindex-warning"></span>';
		}
		
		echo esc_html__('Advanced', 'siteseo').'</span><span class="siteseo-sidebar-tabs-arrow"><span class="dashicons dashicons-arrow-down-alt2"></span></span></div>
		
		<div class="siteseo-metabox-tab-advanced-settings siteseo-metabox-tab">
		<div class="siteseo-metabox-option-wrap">
			<div class="siteseo-metabox-label-wrap">
				<label for="siteseo_social_twitter_img_meta">'.esc_html__('Meta Robots Settings', 'siteseo').'</label>
				<p class="description">'.
				/* translators: %s represents the degree of severity */
				wp_kses_post(sprintf(__('You cannot uncheck a checkbox? This is normal, and it\'s most likely defined in the <a href="%s">global settings of the plugin.</a>', 'siteseo'), esc_url(admin_url('admin.php?page=siteseo-titles#tab=tab_siteseo_titles_single')))).'</p>
			</div>
			<div class="siteseo-metabox-input-wrap">';
				
			$robots_options = [
				'siteseo_robots_index_meta' => [
					'desc' => __('Do not display this page in search engine results / Sitemaps', 'siteseo'),
					'short' => 'noindex',
					'name' => 'siteseo_robots_index',
					'checked' => $metabox_data['robots_index'],
					'disabled' => $metabox_data['disabled_robots']['robots_index']
				],
				'siteseo_robots_follow_meta' => [
					'desc' => __('Do not follow links for this page', 'siteseo'),
					'short' => 'nofollow',
					'name' => 'siteseo_robots_follow',
					'checked' => $metabox_data['robots_follow'],
					'disabled' => $metabox_data['disabled_robots']['robots_follow']
				],
				'siteseo_robots_imageindex_meta' => [
					'desc' => __('Do not index images for this page', 'siteseo'),
					'short' => 'noimageindex',
					'name' => 'siteseo_robots_imageindex',
					'checked' => $metabox_data['robots_imageindex'],
					'disabled' => $metabox_data['disabled_robots']['imageindex']
				],
				'siteseo_robots_archive_meta' => [
					'desc' => __('Do not display a "Cached" link in the Google search results', 'siteseo'),
					'short' => 'noarchive',
					'name' => 'siteseo_robots_archive',
					'checked' => $metabox_data['robots_archive'],
					'disabled' => $metabox_data['disabled_robots']['archive']
				],
				'siteseo_robots_snippet_meta' => [
					'desc' => __('Do not display a description in search results for this page', 'siteseo'),
					'short' => 'nosnippet',
					'name' => 'siteseo_robots_snippet',
					'checked' => $metabox_data['robots_snippet'],
					'disabled' => $metabox_data['disabled_robots']['snippet']
				]
			];

			foreach($robots_options as $robots_id => $robots_option){
				$checked = '';
				if(!empty($robots_option['checked'])){
					$checked = 'checked';
				}
				
				$disabled = '';
				if(!empty($robots_option['disabled'])){
					$disabled = 'disabled';
					$robots_option['name'] = '';
				}

				echo'<label for="'.esc_attr($robots_id).'" style="display:block; margin-bottom:5px;">
					<input type="checkbox" value="yes" id="'.esc_attr($robots_id).'" class="siteseo-metabox-robots-options" name="'.esc_attr($robots_option['name']).'" '.esc_attr($checked).' '.esc_attr($disabled).'/>
					'.esc_html($robots_option['desc']).' ('.esc_html($robots_option['short']).')
				</label>';
			}
			
			echo'</div>
		</div>
		<div class="siteseo-metabox-option-wrap">
			<div class="siteseo-metabox-label-wrap">
				<label for="siteseo_robots_canonical_meta">'.esc_html__('Canonical URL', 'siteseo').'</label>
			</div>
			<div class="siteseo-metabox-input-wrap">
				<input id="siteseo_robots_canonical_meta" type="text" name="siteseo_robots_canonical" placeholder="'.esc_url(get_the_permalink()).'" value="'.(!empty($metabox_data['robots_canonical']) ? esc_html($metabox_data['robots_canonical']) : '').'">
			</div>
		</div>';

		if(!empty($pagenow) && !empty($typenow) && ($pagenow == 'post.php' || $pagenow == 'post-new.php') && ($typenow == 'post' || $typenow == 'product')){

			$categories = (object)[];
			if($typenow == 'product'){
				$categories = get_the_terms($post, 'product_cat');
			} else{
				$categories = get_categories();
			}
			
			if(!empty($categories) && !is_wp_error($categories)){
				echo'<div class="siteseo-metabox-option-wrap">
				<div class="siteseo-metabox-label-wrap">
					<label for="siteseo_robots_canonical_meta">'.esc_html__('Select a primary category', 'siteseo').'</label>
				</div>
				<div class="siteseo-metabox-input-wrap">
					<select id="siteseo_robots_primary_cat" name="siteseo_robots_primary_cat">';
						foreach($categories as $category){
							$selected = '';
							if(!empty($metabox_data['robots_primary_cat']) && $metabox_data['robots_primary_cat'] == $category->term_id){
								$selected = 'selected';
							}

							echo'<option value="'.esc_attr($category->term_id).'" '.esc_attr($selected).'>'.esc_html($category->name).'</option>'; 
						}
					echo'</select>
				</div>
			</div>';
			}
		}
		echo'</div>

		<div class="siteseo-sidebar-tabs"><span>'.esc_html__('Redirects', 'siteseo').'</span>
			<span class="siteseo-sidebar-tabs-arrow"><span class="dashicons dashicons-arrow-down-alt2"></span>
		</span></div>
		
		<div class="siteseo-metabox-tab-redirect siteseo-metabox-tab">
			<div class="siteseo-metabox-option-wrap">
				<div class="siteseo-metabox-label-wrap">
					<label for="siteseo_redirections_enabled_meta">'.esc_html__('Enable redirection', 'siteseo').'</label>
				</div>
				<div class="siteseo-metabox-input-wrap">
					<input id="siteseo_redirections_enabled_meta" type="checkbox" name="siteseo_redirections_enabled" value="1" '.(!empty($metabox_data['redirections_enabled']) ? 'checked' : '').'>
				</div>
			</div>
			<div class="siteseo-metabox-option-wrap">
				<div class="siteseo-metabox-label-wrap">
					<label for="siteseo_redirections_enabled_meta">'.esc_html__('Login status', 'siteseo').'</label>
				</div>
				<div class="siteseo-metabox-input-wrap">
					<select name="siteseo_redirections_logged_status" id="siteseo_redirections_logged_status">
						<option value="both" '.(!empty($metabox_data['redirections_logged_status']) && $metabox_data['redirections_logged_status'] == 'both' ? 'selected' : '').'>'.esc_html__('All', 'siteseo').'</option>
						<option value="only_logged_in" '.(!empty($metabox_data['redirections_logged_status']) && $metabox_data['redirections_logged_status'] == 'only_logged_in' ? 'selected' : '').'>'.esc_html__('Only when logged In', 'siteseo').'</option>
						<option value="only_not_logged_in" '.(!empty($metabox_data['redirections_logged_status']) && $metabox_data['redirections_logged_status'] == 'only_not_logged_in' ? 'selected' : '').'>'.esc_html__('Only when not logged in', 'siteseo').'</option>
					</select>
				</div>
			</div>
			<div class="siteseo-metabox-option-wrap">
				<div class="siteseo-metabox-label-wrap">
					<label for="siteseo_redirections_type">'.esc_html__('Redirection Type', 'siteseo').'</label>
				</div>
				<div class="siteseo-metabox-input-wrap">
					<select name="siteseo_redirections_type" id="siteseo_redirections_type">
						<option value="301" '.(!empty($metabox_data['redirections_type']) && $metabox_data['redirections_type'] == '301' ? 'selected' : '').'>'.esc_html__('301 Moved Permanently', 'siteseo').'</option>
						<option value="302" '.(!empty($metabox_data['redirections_type']) && $metabox_data['redirections_type'] == '302' ? 'selected' : '').'>'.esc_html__('302 Found / Moved Temporarily', 'siteseo').'</option>
						<option value="307" '.(!empty($metabox_data['redirections_type']) && $metabox_data['redirections_type'] == '307' ? 'selected' : '').'>'.esc_html__('307 Moved Temporarily', 'siteseo').'</option>';
						if($typenow === 'siteseo_404'){
							echo'<option value="410" '.(!empty($metabox_data['redirections_type']) && $metabox_data['redirections_type'] == '410' ? 'selected' : '').'>'.esc_html__('410 Gone', 'siteseo').'</option>
							<option value="451" '.(!empty($metabox_data['redirections_type']) && $metabox_data['redirections_type'] == '451' ? 'selected' : '').'>'. esc_html__('451 Unavailable For Legal Reasons', 'siteseo').'</option>';
						}
					echo'</select>
				</div>
		</div>
		<div class="siteseo-metabox-option-wrap">
			<div class="siteseo-metabox-label-wrap">
				<label for="siteseo_redirections_value_meta">'.esc_html__('Redirection URL', 'siteseo').'</label>
			</div>
			<div class="siteseo-metabox-input-wrap">
				<input id="siteseo_redirections_value_meta" type="text" name="siteseo_redirections_value" value="'.(!empty($metabox_data['redirections_value']) ? esc_attr($metabox_data['redirections_value']): '').'">
			</div>
			<input type="hidden" id="analysis_tabs" name="analysis_tabs" value="'.esc_html(wp_json_encode(array_keys($siteseo_metabox_tabs))).'">
		</div>';
		// Note
		if($typenow === 'siteseo_404'){
			echo'<div class="siteseo-metabox-option-wrap">
				<div class="siteseo-metabox-label-wrap">
					<label for="siteseo_redirections_param">'.esc_html__('Query parameters', 'siteseo').'</label>
				</div>
				<div class="siteseo-metabox-input-wrap">
					<select name="siteseo_redirections_param" id="siteseo_redirections_param">
						<option value="exact_match" '.(!empty($metabox_data['redirections_param']) && $metabox_data['redirections_param'] == 'exact_match' ? 'selected' : '').'>'.esc_html__('Exactly parameters with exact match', 'siteseo').'</option>
						<option value="without_param" '.(!empty($metabox_data['redirections_param']) && $metabox_data['redirections_param'] == 'without_param' ? 'selected' : '').'>'.esc_html__('Exclude all parameters', 'siteseo').'</option>
						<option value="with_ignored_param" '.(!empty($metabox_data['redirections_param']) && $metabox_data['redirections_param'] == 'with_ignored_param' ? 'selected' : '').'>'.esc_html__('Exclude all parameters and pass them to the redirection', 'siteseo').'</option>
					</select>
				</div>
			</div>';
		}

		echo'</div>
		</div>';

	}

	static function content_analysis($post){
		
		wp_nonce_field('siteseo_ca_nonce', 'siteseo_content_analysis_nonce');

		$siteseo_real_preview = [
			'siteseo_nonce' => wp_create_nonce('siteseo_real_preview_nonce'),
			'siteseo_real_preview' => admin_url('admin-ajax.php'),
			'i18n' => ['progress' => __('Analysis in progress...', 'siteseo')],
			'ajax_url' => admin_url('admin-ajax.php'),
			'get_preview_meta_title' => wp_create_nonce('get_preview_meta_title'),
			'realtime_nonce' => wp_create_nonce('siteseo_realtime_nonce'),
		];

		$metabox_data = [];

		$metabox_data['analysis_target_kw'] = get_post_meta($post->ID, '_siteseo_analysis_target_kw', true);
		$metabox_data['analysis_data'] = get_post_meta($post->ID, '_siteseo_analysis_data', true);
		$metabox_data['readibility_data'] = get_post_meta($post->ID, '_siteseo_readibility_data', true);
		$metabox_data['meta_title'] = get_post_meta($post->ID, '_siteseo_titles_title', true);
		$metabox_data['meta_desc'] = get_post_meta($post->ID, '_siteseo_titles_desc', true);
		
		$title_options = get_option('siteseo_titles_option_name', []);

		if(self::titles_single_cpt_noindex_option() || !empty($title_options['titles_noindex']) || true === post_password_required($post->ID)){
			$metabox_data['robots_index'] = 'yes';
		} else {
			$metabox_data['robots_index'] = get_post_meta($post->ID, '_siteseo_robots_index', true);
		}

		if(post_password_required($post->ID) === true || !empty($title_options['titles_noindex']) || self::titles_single_cpt_noindex_option()){
			$metabox_data['robots_index'] = 'yes';
		} else{
			$metabox_data['robots_index'] = get_post_meta($post->ID, '_siteseo_robots_index', true);
		}

		if(!empty($title_options['titles_nofollow']) || self::titles_single_cpt_nofollow_option()){
			$metabox_data['robots_follow'] = 'yes';
		} else{
			$metabox_data['robots_follow'] = get_post_meta($post->ID, '_siteseo_robots_follow', true);
		}

		if(!empty($title_options['titles_noarchive'])){
			$metabox_data['robots_archive'] = 'yes';
		} else{
			$metabox_data['robots_archive'] = get_post_meta($post->ID, '_siteseo_robots_archive', true);
		}

		if(!empty($title_options['titles_nosnippet'])){
			$metabox_data['robots_snippet'] = 'yes';
		} else{
			$metabox_data['robots_snippet'] = get_post_meta($post->ID, '_siteseo_robots_snippet', true);
		}

		if(!empty($title_options['titles_noimageindex'])){
			$metabox_data['robots_imageindex'] = 'yes';
		} else{
			$metabox_data['robots_imageindex'] = get_post_meta($post->ID, '_siteseo_robots_imageindex', true);
		}

		$metabox_data['post_id'] = $post->ID;
		$metabox_data['readibility_data'] = get_post_meta($post->ID, '_siteseo_readibility_data', true);
		
		self::siteseo_content_analysis_tab($metabox_data);
	}
	
	
	static function titles_single_cpt_nofollow_option(){
		$siteseo_get_current_cpt = get_post_type();

		$options = get_option('siteseo_titles_option_name');
		if(!empty($options) && isset($options['titles_single_titles'][$siteseo_get_current_cpt]['nofollow'])){
			return $options['titles_single_titles'][$siteseo_get_current_cpt]['nofollow'];
		}
	}
	
	static function btn_secondary_classes() {
		//Classic Editor compatibility
		global $pagenow;
		
		$current_screen = null;
		
		if(function_exists('get_current_screen')){
			$current_screen = get_current_screen();
		}
		
		if(!empty($current_screen) && method_exists($current_screen, 'is_block_editor') && true === $current_screen->is_block_editor()){
			$btn_classes_secondary = 'components-button is-secondary';
		} elseif(isset($pagenow) && ($pagenow === 'term.php' || $pagenow === 'post.php' || $pagenow === 'post-new.php')){
			$btn_classes_secondary = 'button button-secondary';
		} else{
			$btn_classes_secondary = 'btn btnSecondary';
		}

		return $btn_classes_secondary;
	}
	
	static function siteseo_content_analysis_tab(&$metabox_data){
		global $post;
		
		echo '<div class="siteseo-metabox-option-wrap">
			<div class="siteseo-metabox-label-wrap">
				<label for="siteseo_titles_title_meta">' . esc_html__('Focus Keywords', 'siteseo') . '</label>
			</div>
			<div class="siteseo-metabox-input-wrap">
				<div id="siteseo_tags_wrapper" style="display: flex; flex-wrap: wrap; gap: 5px; padding: 5px; border: 1px solid #ccc; border-radius: 5px;">';
					if(!empty($metabox_data['analysis_target_kw'])){
						$tags_arr = explode(',', $metabox_data['analysis_target_kw']);
						
						if(count($tags_arr) > 0){
							foreach($tags_arr as $tag_name){
								echo '<span class="siteseo-tag">'.esc_html($tag_name).'<span class="siteseo-remove-tag">×</span></span>';
							}
						}
					}

					echo '<input id="siteseo_analysis_target_kw_meta" class="siteseo_analysis_target_kw_meta" type="text" placeholder="' . esc_html__('Enter your target keywords', 'siteseo') . '" style="border: none; outline: none; flex: 1; min-width: 150px;" />
					<input type="hidden" id="siteseo_tags_hidden" name="siteseo_analysis_target_kw" value="' . (!empty($metabox_data['analysis_target_kw']) ? esc_attr($metabox_data['analysis_target_kw']) : '') . '" />
				</div>
				<p class="description">Press <kbd>Enter</kbd> key on your keyboard to add keyword</p>
				<button id="siteseo_refresh_seo_analysis" type="button" style="margin-top:10px;" class="'.esc_attr(self::btn_secondary_classes()).'" data_id="'.esc_attr(get_the_ID()).'" data_post_type="'.esc_attr(get_current_screen()->post_type).'"> '.esc_html__('Refresh analysis', 'siteseo').'</button>
				<p class="description">'.esc_html__('Refresh analysis after saving the post to improve the accuracy of the analysis', 'siteseo').'</p>
			</div>
		</div>
		<div id="siteseo-metabox-content-analysis">
			<div id="siteseo-metabox-tabs-container">
				<div class="siteseo-metabox-subtabs">
				<div class="siteseo-metabox-tab-label siteseo-metabox-tab-label-active" data-tab="siteseo-metabox-seo-analysis-tab">'. esc_html__('SEO Analysis', 'siteseo').'</div>
					<div class="siteseo-metabox-tab-label" data-tab="siteseo-metabox-readibility-analysis-tab">'.esc_html__('Content Readability', 'siteseo').'</div>
				</div>
				<div id="siteseo-metabox-tab-content">
					<div class="siteseo-metabox-seo-analysis-tab siteseo-metabox-tab" style="display:block;">';
					
					$post_id = isset($_POST['post_id']) ? intval($_POST['post_id']) : 0;
					$post = get_post($post_id);
					Analysis::display_seo_analysis($post);
			echo'</div>
			<div class="siteseo-metabox-readibility-analysis-tab siteseo-metabox-tab">
				<p class="description">' . 
					esc_html__('This section works as a guide to help you write, better content for your user, this do not have a direct affect on SEO, but it will help you write better content for your users which will help user stay on your site longer, or will improve the Click Through rate.
					Which will signal search engines about the userfulness and likeleyness of your content by your user which indirectly improve SEO of the page.', 'siteseo') . 
				'</p>';
				Analysis::display_content_readibility($metabox_data);
			echo'</div>
					</div>
				</div>
			</div>';
	}

	
	static function titles_single_cpt_noindex_option(){
		$siteseo_get_current_cpt = get_post_type();

		$options = get_option('siteseo_titles_option_name');
		
		if(!empty($options) && isset($options['titles_single_titles'][$siteseo_get_current_cpt]['noindex'])){
			return $options['titles_single_titles'][$siteseo_get_current_cpt]['noindex'];
		}
	}

	static function save_ca_metabox($post_id, $post){

		if(!isset($_POST['siteseo_content_analysis_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['siteseo_content_analysis_nonce'])), 'siteseo_ca_nonce')){
			return $post_id;
		}

		// Post type object
		$post_type = get_post_type_object($post->post_type);

		//Check permission
		if(!current_user_can($post_type->cap->edit_post, $post_id) || !siteseo_user_can_metabox()){
			return $post_id;
		}

		if('attachment' !== get_post_type($post_id)){
			if(isset($_POST['siteseo_analysis_target_kw'])){
				update_post_meta($post_id, '_siteseo_analysis_target_kw', self::clean_post('siteseo_analysis_target_kw'));
			} else{
				delete_post_meta($post_id, '_siteseo_analysis_target_kw');
			}
		}
	}
	
	
	static function save_metabox($post_id, $post){
		
		global $siteseo;
		
		// Security Check
		if(!isset($_POST['siteseo_metabox_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['siteseo_metabox_nonce'])), 'siteseo_metabox_nonce')){
			return $post_id;
		}

		//Post type object
		$post_type = get_post_type_object($post->post_type);
		
		//Check permission
		if(!current_user_can($post_type->cap->edit_post, $post_id) || !siteseo_user_can_metabox()){
			return $post_id;
		}
		
		if('attachment' !== get_post_type($post_id)){
			$analysis_tabs = [];
			$analysis_tabs = json_decode(self::clean_post('analysis_tabs'), true);
			
			if(!empty($analysis_tabs) && is_array($analysis_tabs) && in_array('content-analysis', $analysis_tabs)){
				if(!empty($_POST['siteseo_analysis_target_kw'])){
					update_post_meta($post_id, '_siteseo_analysis_target_kw', self::clean_post('siteseo_analysis_target_kw'));
				} else{
					delete_post_meta($post_id, '_siteseo_analysis_target_kw');
				}
			}
			
			if(!empty($analysis_tabs) && is_array($analysis_tabs) && in_array('title-settings', $analysis_tabs)){
				if(!empty($_POST['siteseo_titles_title'])){
					update_post_meta($post_id, '_siteseo_titles_title', self::clean_post('siteseo_titles_title'));
				} else{
					delete_post_meta($post_id, '_siteseo_titles_title');
				}
				if(!empty($_POST['siteseo_titles_desc'])){
					update_post_meta($post_id, '_siteseo_titles_desc', self::clean_post('siteseo_titles_desc'));
				} else{
					delete_post_meta($post_id, '_siteseo_titles_desc');
				}
			}
			if(!empty($analysis_tabs) && is_array($analysis_tabs) && in_array('advanced-settings', $analysis_tabs)){
				
				if(isset($_POST['siteseo_robots_index'])){
					update_post_meta($post_id, '_siteseo_robots_index', 'yes');
				} else{
					delete_post_meta($post_id, '_siteseo_robots_index');
				}
				
				if(isset($_POST['siteseo_robots_follow'])){
					update_post_meta($post_id, '_siteseo_robots_follow', 'yes');
				} else{
					delete_post_meta($post_id, '_siteseo_robots_follow');
				}
				
				if(isset($_POST['siteseo_robots_imageindex'])){
					update_post_meta($post_id, '_siteseo_robots_imageindex', 'yes');
				} else{
					delete_post_meta($post_id, '_siteseo_robots_imageindex');
				}
				
				if(isset($_POST['siteseo_robots_archive'])){
					update_post_meta($post_id, '_siteseo_robots_archive', 'yes');
				} else{
					delete_post_meta($post_id, '_siteseo_robots_archive');
				}
				
				if(isset($_POST['siteseo_robots_snippet'])){
					update_post_meta($post_id, '_siteseo_robots_snippet', 'yes');
				} else{
					delete_post_meta($post_id, '_siteseo_robots_snippet');
				}
				
				if(!empty($_POST['siteseo_robots_canonical'])){
					update_post_meta($post_id, '_siteseo_robots_canonical', self::clean_post('siteseo_robots_canonical'));
				} else{
					delete_post_meta($post_id, '_siteseo_robots_canonical');
				}
				
				if(!empty($_POST['siteseo_robots_primary_cat'])){
					update_post_meta($post_id, '_siteseo_robots_primary_cat', self::clean_post('siteseo_robots_primary_cat'));
				} else{
					delete_post_meta($post_id, '_siteseo_robots_primary_cat');
				}
			}

			if(!empty($analysis_tabs) && is_array($analysis_tabs) && in_array('social-settings', $analysis_tabs)){
				//Facebook
				if(!empty($_POST['siteseo_social_fb_title'])){
					update_post_meta($post_id, '_siteseo_social_fb_title', self::clean_post('siteseo_social_fb_title'));
				} else{
					delete_post_meta($post_id, '_siteseo_social_fb_title');
				}
				
				if(!empty($_POST['siteseo_social_fb_desc'])){
					update_post_meta($post_id, '_siteseo_social_fb_desc', self::clean_post('siteseo_social_fb_desc'));
				} else{
					delete_post_meta($post_id, '_siteseo_social_fb_desc');
				}
				
				if(!empty($_POST['siteseo_social_fb_img'])){
					update_post_meta($post_id, '_siteseo_social_fb_img', self::clean_post('siteseo_social_fb_img'));
				} else{
					delete_post_meta($post_id, '_siteseo_social_fb_img');
				}
				
				if(!empty($_POST['siteseo_social_fb_img_attachment_id']) && !empty($_POST['siteseo_social_fb_img'])){
					update_post_meta($post_id, '_siteseo_social_fb_img_attachment_id', self::clean_post('siteseo_social_fb_img_attachment_id'));
				} else{
					delete_post_meta($post_id, '_siteseo_social_fb_img_attachment_id');
				}
				
				if(!empty($_POST['siteseo_social_fb_img_width']) && !empty($_POST['siteseo_social_fb_img'])){
					update_post_meta($post_id, '_siteseo_social_fb_img_width', self::clean_post('siteseo_social_fb_img_width'));
				} else{
					delete_post_meta($post_id, '_siteseo_social_fb_img_width');
				}
				
				if(!empty($_POST['siteseo_social_fb_img_height']) && !empty($_POST['siteseo_social_fb_img'])){
					update_post_meta($post_id, '_siteseo_social_fb_img_height', self::clean_post('siteseo_social_fb_img_height'));
				} else{
					delete_post_meta($post_id, '_siteseo_social_fb_img_height');
				}

				//Twitter
				if(!empty($_POST['siteseo_social_twitter_title'])){
					update_post_meta($post_id, '_siteseo_social_twitter_title', self::clean_post('siteseo_social_twitter_title'));
				} else{
					delete_post_meta($post_id, '_siteseo_social_twitter_title');
				}
				
				if(!empty($_POST['siteseo_social_twitter_desc'])){
					update_post_meta($post_id, '_siteseo_social_twitter_desc', self::clean_post('siteseo_social_twitter_desc'));
				} else{
					delete_post_meta($post_id, '_siteseo_social_twitter_desc');
				}
				
				if(!empty($_POST['siteseo_social_twitter_img'])){
					update_post_meta($post_id, '_siteseo_social_twitter_img', self::clean_post('siteseo_social_twitter_img'));
				} else{
					delete_post_meta($post_id, '_siteseo_social_twitter_img');
				}
				
				if(!empty($_POST['siteseo_social_twitter_img_attachment_id']) && !empty($_POST['siteseo_social_twitter_img'])){
					update_post_meta($post_id, '_siteseo_social_twitter_img_attachment_id', self::clean_post('siteseo_social_twitter_img_attachment_id'));
				} else{
					delete_post_meta($post_id, '_siteseo_social_twitter_img_attachment_id');
				}
				
				if(!empty($_POST['siteseo_social_twitter_img_width']) && !empty($_POST['siteseo_social_twitter_img'])){
					update_post_meta($post_id, '_siteseo_social_twitter_img_width', self::clean_post('siteseo_social_twitter_img_width'));
				} else{
					delete_post_meta($post_id, '_siteseo_social_twitter_img_width');
				}
				
				if(!empty($_POST['siteseo_social_twitter_img_height']) && !empty($_POST['siteseo_social_twitter_img'])){
					update_post_meta($post_id, '_siteseo_social_twitter_img_height', self::clean_post('siteseo_social_twitter_img_height'));
				} else{
					delete_post_meta($post_id, '_siteseo_social_twitter_img_height');
				}
			}

			if(!empty($analysis_tabs) && is_array($analysis_tabs) && in_array('redirect', $analysis_tabs)){
				if(isset($_POST['siteseo_redirections_type'])){
					update_post_meta($post_id, '_siteseo_redirections_type', self::clean_post('siteseo_redirections_type'));
				}
				
				if(!empty($_POST['siteseo_redirections_value'])){
					update_post_meta($post_id, '_siteseo_redirections_value', self::clean_post('siteseo_redirections_value'));
				} else{
					delete_post_meta($post_id, '_siteseo_redirections_value');
				}
				
				if(isset($_POST['siteseo_redirections_param'])){
					update_post_meta($post_id, '_siteseo_redirections_param', self::clean_post('siteseo_redirections_param'));
				}
				
				if(isset($_POST['siteseo_redirections_enabled'])){
					update_post_meta($post_id, '_siteseo_redirections_enabled', 'yes');
				} else{
					delete_post_meta($post_id, '_siteseo_redirections_enabled', '');
				}
				
				if(isset($_POST['siteseo_redirections_enabled_regex'])){
					update_post_meta($post_id, '_siteseo_redirections_enabled_regex', 'yes');
				} else{
					delete_post_meta($post_id, '_siteseo_redirections_enabled_regex');
				}
				
				if(isset($_POST['siteseo_redirections_logged_status'])){
					update_post_meta($post_id, '_siteseo_redirections_logged_status', self::clean_post('siteseo_redirections_logged_status'));
				} else{
					delete_post_meta($post_id, '_siteseo_redirections_logged_status');
				}
			}
			
			if(!empty($analysis_tabs) && is_array($analysis_tabs) && in_array('structured-data-types', $analysis_tabs)){
				if(class_exists('\SiteSEOPro\StructuredData') && method_exists('\SiteSEOPro\StructuredData', 'save_metabox')){
					\SiteSEOPro\StructuredData::save_metabox($post_id, $post);
				}
			}
			
			if(!empty($analysis_tabs) && is_array($analysis_tabs) && in_array('video-sitemap', $analysis_tabs)){
				if(class_exists('\SiteSEOPro\VideoSitemap') && method_exists('\SiteSEOPro\VideoSitemap', 'save_video_sitemap')){
					\SiteSEOPro\VideoSitemap::save_video_sitemap($post_id, $post);
				}
			}
			
			if(!empty($analysis_tabs) && is_array($analysis_tabs) && in_array('google-news', $analysis_tabs)){
				if(class_exists('\SiteSEOPro\GoogleNews') && method_exists('\SiteSEOPro\GoogleNews', 'save_google_news')){
					\SiteSEOPro\GoogleNews::save_google_news($post_id, $post);
				}
			}
		}
	}

	static function clean_post($name){
		return self::clean_post_req($name);
	}
	
	static function clean_get($name){
		return self::clean_post_req($name);
	}
	
	static function clean_post_req($name){
		if(empty($name)){
			return '';
		}
	
		if(!isset($_REQUEST[$name])){
			return '';
		}
	
		if(is_array($_REQUEST[$name]) || is_object($_REQUEST[$name])){
			return map_deep(wp_unslash($_REQUEST[$name]), 'sanitize_text_field');
		}

		return sanitize_text_field(wp_unslash($_REQUEST[$name]));
	}
	
	static function universal(){
		global $siteseo, $pagenow, $post;
		
		$post_id = !empty($_REQUEST['post']) ? (int) sanitize_text_field(wp_unslash($_REQUEST['post'])) : 0;
		
		if(empty($post_id)){
			return;
		}
		
		if(!current_user_can('edit_post', $post_id)){
			wp_die(esc_html__('You do not have access to edit this post', 'siteseo'));
		}
		
		$tmp_post = $post;
		$post = get_post($post_id);
		$tmp_pagenow = $pagenow;
		$pagenow = 'post.php';

		if(empty($post)){
			$post = $tmp_post;
			return;
		}
		
		set_current_screen($post->post_type);

		echo '<style>body{height: 100vh;} #wpcontent,#wpbody-content,html.wp-toolbar{padding:0;} .postbox .handle-order-higher, .postbox .handle-order-lower,#minor-publishing-actions,.site-menu-header{display:none !important;} #adminmenumain, #wpfooter, #wpadminbar, #wpwrap > :first-child,  #wpwrap > :nth-child(2) .lnav-col{display:none;} #wpcontent{margin:auto;} #wpbody-content{position:relative;} .siteseo-metabox-tab{background-color:white;} .siteseo-meta-submit-container{position:fixed;bottom: 20px;right : 20px;}  #siteseo_cpt form {position:relative;}.siteseo-btn{display: inline-flex;padding: 0.5rem 1rem;gap: 0.5rem;justify-content: center;align-items: center;border-radius: 0.375rem;font-size: 0.875rem;line-height: 1.25rem;font-weight: 500;white-space: nowrap;cursor:pointer;box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);border:none;text-decoration:none; text-align:center;}.siteseo-btn.primary{background-color:#141b38;color:white;} #wpwrap > :nth-child(2) > div:nth-child(2){max-width:100%}
		.siteseo-spinner{display:none;border-radius:50%;animation: siteseo-spinner 1s linear infinite;height: 0.9375rem;width: 0.9375rem;border: 2px solid #dddcdc80;border-left-color: #e3e3e3;} .siteseo-spinner-active{display:inline-block;} @keyframes siteseo-spinner{ 0% { transform: rotate(0deg);} 100% {transform: rotate(360deg);}} .components-button{align-items: center; -webkit-appearance: none; background: none; border: 0; border-radius: 2px; box-sizing: border-box; color:#1e1e1e; cursor: pointer;display: inline-flex; font-family: inherit; font-size: 13px; font-weight: 400; height: 36px; margin: 0; padding: 6px 12px; text-decoration: none; transition: box-shadow .1s linear;}.components-button.is-secondary {background: #0000; box-shadow: inset 0 0 0 1px #3858e9; color:#3858e9; outline: 1px solid #0000; white-space: nowrap;}.siteseo-sidebar-tabs{display:none;} .notice, .update-nag{ display: none !important;}</style>
		<div id="siteseo_cpt"><form id="siteseo-universal-post" action="post.php" method="post">
		<input type="hidden" name="post_id" value="'.esc_attr($post_id).'"/>';
		wp_nonce_field('siteseo_universal_nonce', 'security');
		self::render_metabox();
		
		echo '<div class="siteseo-meta-submit-container">
			<button type="submit" class="siteseo-btn primary">'.esc_html__('Save Changes', 'siteseo').'<span class="siteseo-spinner"></span></button>
		</div></form></div>
		<script>
		jQuery(document).ready(function(){
			jQuery("#siteseo-universal-post").on("submit", function(event){
				event.preventDefault();
				let jEle = jQuery(event.target),
				spinner = jEle.find(".siteseo-spinner"),
				formData = {};

				jQuery(this).serializeArray().forEach(field => {
					formData[field.name] = field.value;
				});

				formData["action"] = "siteseo_save_universal_metabox";
				
				spinner.addClass("siteseo-spinner-active");

				jQuery.ajax({
					method : "POST",
					url : "'.esc_url(admin_url('admin-ajax.php')).'",
					data : formData,
					success : function(res){
						//console.log(res);
					}
				}).always(function(){
					spinner.removeClass("siteseo-spinner-active");
				})
			});
		});
		</script>';

		$post = $tmp_post;
		$pagenow = $tmp_pagenow;

		global $wp_version;

		if(!empty($wp_version) && version_compare($wp_version, '6.4', '>')){
			remove_action('wp_footer', 'the_block_template_skip_link');
		}

		wp_footer();
		exit;
	}
	
	static function render_term_metabox($term, $taxonomy_name = ''){
		$metabox_data = self::metabox_term_data($term);
		self::metabox_form_html($metabox_data);
	}
	
	static function save_meta_terms($term_id, $post_id = 0){

		// Security Check
		if(!isset($_POST['siteseo_metabox_nonce']) || !wp_verify_nonce(self::clean_post('siteseo_metabox_nonce'), 'siteseo_metabox_nonce') ){
			return $term_id;
		}
		
		// Getting taxonomy
		$term = get_term($term_id);
		$taxonomy = get_taxonomy($term->taxonomy);

		// Is this user allowed to make these changes
		if(!current_user_can($taxonomy->cap->edit_terms, $term_id)) {
			return $term_id;
		}

		$analysis_tabs = [];
		$analysis_tabs = json_decode(self::clean_post('analysis_tabs'), true);
		
		if(empty($analysis_tabs) || !is_array($analysis_tabs)){
			return $term_id;
		}

		$tabs = [
			'title-settings' => [
				'siteseo_titles_title' => '_siteseo_titles_title',
				'siteseo_titles_desc' => '_siteseo_titles_desc',
			],
			'advanced-settings' => [
				'siteseo_robots_index' => '_siteseo_robots_index',
				'siteseo_robots_follow' => '_siteseo_robots_follow',
				'siteseo_robots_imageindex'=> '_siteseo_robots_imageindex',
				'siteseo_robots_archive' => '_siteseo_robots_archive',
				'siteseo_robots_snippet' => '_siteseo_robots_snippet',
				'siteseo_robots_canonical' => '_siteseo_robots_canonical',
			],
			'social-settings' => [
				'siteseo_social_fb_title' => '_siteseo_social_fb_title',
				'siteseo_social_fb_desc' => '_siteseo_social_fb_desc',
				'siteseo_social_fb_img' => '_siteseo_social_fb_img',
				'siteseo_social_fb_img_attachment_id' => '_siteseo_social_fb_img_attachment_id',
				'siteseo_social_fb_img_width' => '_siteseo_social_fb_img_width',
				'siteseo_social_fb_img_height' => '_siteseo_social_fb_img_height',
				'siteseo_social_twitter_title' => '_siteseo_social_twitter_title',
				'siteseo_social_twitter_desc' => '_siteseo_social_twitter_desc',
				'siteseo_social_twitter_img' => '_siteseo_social_twitter_img',
			],
			'redirect' => [
				'siteseo_redirections_type' => '_siteseo_redirections_type',
				'siteseo_redirections_logged_status' => '_siteseo_redirections_logged_status',
				'siteseo_redirections_value' => '_siteseo_redirections_value',
				'siteseo_redirections_enabled' => '_siteseo_redirections_enabled',
			]
		];
		
		// Save the key for all the options which are checkboxes
		$is_checkboxes = [
			'siteseo_robots_index',
			'siteseo_robots_follow',
			'siteseo_robots_imageindex',
			'siteseo_robots_archive',
			'siteseo_robots_snippet',
			'siteseo_redirections_enabled',
		];

		foreach($tabs as $tab => $fields){
			if(!in_array($tab, $analysis_tabs)){
				continue;
			}

			foreach($fields as $post_key => $meta_key){
				if(!empty($_POST[$post_key])){
					$value = in_array($post_key, $is_checkboxes) ? 'yes' : self::clean_post($post_key);
					update_term_meta($term_id, $meta_key, $value);
				} else {
					delete_term_meta($term_id, $meta_key);
				}
			}
		}

		return $term_id;
	}
}

PKv�f\��i
i
primarycategory.phpnu�[���<?php
/*
* SITESEO
* https://siteseo.io
* (c) SiteSEO Team
*/

namespace SiteSEO;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class PrimaryCategory{
	
	static function wc_primary_category($none_terms, $terms, $post){
		$primary_cat = null;

		if(!empty($post)){
			$wc_primary_cat = get_post_meta($post->ID, '_siteseo_robots_primary_cat', true);
			if(isset($wc_primary_cat) && '' != $wc_primary_cat && 'none' != $wc_primary_cat){
				
				if(null != $post->post_type && 'product' == $post->post_type){
					$primary_cat = get_term($wc_primary_cat, 'product_cat');
				}
				
				if(!is_wp_error($primary_cat) && null != $primary_cat){
					return $primary_cat;
				}
			} else{
				return $none_terms;
			}
		} else{
			return $none_terms;
		}
	}

	static function add_primary_category($none_cate, $cats, $post){
		$primary_cat = null;

		if(!empty($post)){
			$robots_primary_cat = get_post_meta($post->ID, '_siteseo_robots_primary_cat', true);
			if(isset($robots_primary_cat) && '' != $robots_primary_cat && 'none' != $robots_primary_cat){
				
				if(null != $post->post_type && 'post' == $post->post_type){
					$primary_cat = get_category($robots_primary_cat);
				}
				
				if(!is_wp_error($primary_cat) && null != $primary_cat){
					return $primary_cat;
				}
			} else{
				return $none_cate;
			}
		} else{
			return $none_cate;
		}
	}
	
	static function replace_breadcrumb_categories($crumbs, $breadcrumb){
		if(!is_product()){
			return $crumbs;
		}

		global $post;
		$primary_cat_id = get_post_meta($post->ID, '_siteseo_robots_primary_cat', true);
		
		if(!empty($primary_cat_id) && $primary_cat_id !== 'none'){
			$primary_cat = get_term($primary_cat_id, 'product_cat');
			
			if(!empty($primary_cat) && !is_wp_error($primary_cat)){
				
				$new_crumbs = [];
				foreach($crumbs as $key => $crumb){
					
					if($key === 0 || (isset($crumb[1]) && strpos($crumb[1], '?post_type=product') !== false)){
						$new_crumbs[] = $crumb;
					}
				}
				
				$ancestors = get_ancestors($primary_cat->term_id, 'product_cat');
				$ancestors = array_reverse($ancestors);
				
				foreach($ancestors as $ancestor_id){
					$ancestor = get_term($ancestor_id, 'product_cat');
					if(!empty($ancestor) && !is_wp_error($ancestor)){
						$new_crumbs[] = [
							$ancestor->name,
							get_term_link($ancestor)
						];
					}
				}
				
				if(!empty($primary_cat) && !is_wp_error($primary_cat)){
					$new_crumbs[] = [
						$primary_cat->name,
						get_term_link($primary_cat)
					];
				}
				
				if(count($crumbs) > 0){
					$new_crumbs[] = $crumbs[count($crumbs) - 1];
				}
				
				return $new_crumbs;
			}
		}

		return $crumbs;
	}
}PKv�f\X��xlladvanced.phpnu�[���<?php
/*
* SITESEO
* https://siteseo.io
* (c) SiteSEO Team
*/

namespace SiteSEO;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class Advanced{
	
	static function tags(){
		global $siteseo;

		if(empty($siteseo->setting_enabled['toggle-advanced'])){
			return; // toggle disable
		}
		// meta tags
		if(!empty($siteseo->advanced_settings['advanced_google'])){
			echo '<meta name="google-site-verification" content="'.esc_attr($siteseo->advanced_settings['advanced_google']).'" />' . "\n";
		}

		if(!empty($siteseo->advanced_settings['advanced_bing'])){
			echo '<meta name="msvalidate.01" content="'.esc_attr($siteseo->advanced_settings['advanced_bing']).'" />' . "\n";
		}

		if(!empty($siteseo->advanced_settings['advanced_pinterest'])){
			echo '<meta name="p:domain_verify" content="'.esc_attr($siteseo->advanced_settings['advanced_pinterest']).'" />';
		}

		if(!empty($siteseo->advanced_settings['advanced_yandex'])){
			echo '<meta name="yandex-verification" content="'.esc_attr($siteseo->advanced_settings['advanced_yandex']).'" />';
		}

		if(!empty($siteseo->advanced_settings['advanced_wp_rsd'])){
			remove_action('wp_head', 'rsd_link');
		}

	}
	
	static function remove_links(){
		global $siteseo;

		if(empty($siteseo->setting_enabled['toggle-advanced'])){
			return; // toggle disable
		}

		if(!empty($siteseo->advanced_settings['advanced_wp_rsd'])){
			remove_action('wp_head', 'rsd_link');
		}

		if(!empty($siteseo->advanced_settings['advanced_wp_wlw'])){
			remove_action('wp_head', 'wlwmanifest_link');
		}

		if(!empty($siteseo->advanced_settings['advanced_wp_shortlink'])){
			remove_action('wp_head', 'wp_shortlink_wp_head');
		}

		if(!empty($siteseo->advanced_settings['advanced_wp_generator'])){
			remove_action('wp_head', 'wp_generator');
		}

		if(!empty($siteseo->advanced_settings['advanced_comments_form_link'])){
			add_filter('comment_form_default_fields', '\SiteSEO\Advanced::remove_comment_url_field');
		}

		if(!empty($siteseo->advanced_settings['advanced_comments_author_url'])){
			add_filter('get_comment_author_link', '\SiteSEO\Advanced::remove_author_link_if_profile_url');
		}

		if(!empty($siteseo->advanced_settings['advanced_hentry'])){
			add_filter('post_class', '\SiteSEO\Advanced::remove_hentry_post_class');
		}

		if(!empty($siteseo->advanced_settings['advanced_noreferrer'])){
			add_filter('the_content', '\SiteSEO\Advanced::remove_noreferrer_from_post_content');
		}

		if(!empty($siteseo->advanced_settings['advanced_tax_desc_editor'])){
			add_action('edit_term', '\SiteSEO\Advanced::add_wp_editor_to_taxonomy_description', 10, 2);
		}
		
		if(!empty($siteseo->advanced_settings['advanced_category_url'])){
			add_action('init', '\SiteSEO\Advanced::remove_category_base', 111);
			add_action('template_redirect', '\SiteSEO\Advanced::redirect_category');
		}
	}
	
	static function add_wp_editor_to_taxonomy_description($tag, $tt_id = 0){

		if('edit' !== get_current_screen()->base || 'edit-tags' !== get_current_screen()->id){
			return;
		}

		if(isset($tag->description)){
			$editor_settings = array(
				'textarea_name' => 'description',
				'textarea_rows' => 10,
				'editor_class' => 'wp-editor-area',
				'media_buttons' => true,
				'tinymce' => true,
				'quicktags' => true,
			);

			wp_editor($tag->description, 'description', $editor_settings);
		}
	}

	static function remove_noreferrer_from_post_content($content){
		$content = preg_replace('/(<a\s+[^>]*rel=["\'][^"\']*?)(\s*\bnoreferrer\b\s*)([^"\']*["\'][^>]*>)/i', '$1$3', $content);
		return $content;
	}

	static function remove_hentry_post_class($classes){
		$classes = array_diff($classes, array('hentry'));
		return $classes;
	}

	static function remove_comment_url_field($fields){
		if(isset($fields['url'])){
			unset($fields['url']);
		}

		return $fields;
	}

	static function remove_author_link_if_profile_url($comment_author_link = '', $comment_author = '', $comment_id = 0){
		if(empty($comment_id)){
			return $comment_author;
		}

		$comment = get_comment($comment_id);
		
		if(empty($comment) || !is_object($comment)){
			return $comment_author;
		}

		$user_id = $comment->user_id;

		if(!empty($user_id)){
			$user_website = get_the_author_meta('user_url', $user_id);

			if($user_website){
				return get_comment_author($comment_id);
			}
		}

		return $comment_author;
	}
	
	static function remove_category_base(){
		
		$categories = get_categories(array('hide_empty' => false));
		$category_slugs = wp_list_pluck($categories, 'slug');

		if(empty($category_slugs)){
			return;
		}
    
		$category_pattern = '(' . implode('|', $category_slugs) .')';
    
		add_rewrite_rule(
			'^'.$category_pattern.'/?$',
			'index.php?category_name=$matches[1]',
			'top'
		);
		
		// Add rule for handle pagination  
		add_rewrite_rule(
			'^'.$category_pattern.'/page/([0-9]+)/?$',
			'index.php?category_name=$matches[1]&paged=$matches[2]',
			'top'
		);
	}
	
	static function redirect_category(){
		if(is_category() && !is_admin()){
			$category = get_query_var('category_name');
			$category_base = get_option('category_base');
			$base_to_check = !empty($category_base) ? $category_base : 'category';

			if(!empty($category) && strpos(sanitize_url($_SERVER['REQUEST_URI']), '/'.$base_to_check.'/') !== false){
				wp_safe_redirect(home_url('/' . $category . '/'), 301);
				exit;
			}
		}
	}
		
	static function remove_wc_category_base(){
		global $siteseo;

		if(empty($siteseo->advanced_settings['advanced_product_cat_url']) || empty($siteseo->setting_enabled['toggle-advanced'])){
			return;
		}
		
		if(!in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))){
			return;
		}
		
		add_filter('term_link', '\SiteSEO\Advanced::remove_category_base_woo', 10, 3);
		add_filter('request', '\SiteSEO\Advanced::category_url_request');
		add_action('created_product_cat', 'flush_rewrite_rules');
		add_action('delete_product_cat', 'flush_rewrite_rules');
		add_action('edited_product_cat', 'flush_rewrite_rules');
		add_action('parse_request', '\SiteSEO\Advanced::old_category_url_request');
		
	}
	
	static function remove_category_base_woo($termlink, $term, $taxonomy){
		if($taxonomy === 'product_cat'){
			$category_base = '/product-category/';
			return str_replace($category_base, '/', $termlink);
		}

		return $termlink;
	}
	
	static function category_url_request($query_vars){
		if(!isset($query_vars['product_cat']) && isset($query_vars['pagename'])){
			$pagename = $query_vars['pagename'];
			$term = get_term_by('slug', $pagename, 'product_cat');

			if($term){
				$query_vars['product_cat'] = $term->slug;
				unset($query_vars['pagename']);
			}
		}

		return $query_vars;
	}
	
	static function old_category_url_request($wp){
		
		if(!isset($wp->query_vars['pagename'])){
			return;
		}
		
		$pagename = $wp->query_vars['pagename'];
		$term = get_term_by('slug', $pagename, 'product_cat');
		
		if($term){
			$wp->query_vars['product_cat'] = $term->slug;
			unset($wp->query_vars['pagename']);
		}
		
	}
}
PKv�f\ON��R�R�titlesmetas.phpnu�[���<?php
/*
* SITESEO
* https://siteseo.io
* (c) SiteSEO Team
*/

namespace SiteSEO;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class TitlesMetas{
	
	static function advanced_metas($robots){
		global $siteseo, $post;
		
		$disable_noindex = !empty($siteseo->advanced_settings['appearance_adminbar_noindex']) ? true : '';

		if(empty($siteseo->setting_enabled['toggle-titles']) || !empty($disable_noindex)){
			return $robots;
		}
		
		$settings = $siteseo->titles_settings;
		
		//all  post types and taxonomies
		$post_types = siteseo_post_types();
		$taxonomies = get_taxonomies(array('public' => true), 'objects');
    
		$post_id = isset($post) && is_object($post) ? $post->ID : 0;
		
		$index_extras = [
			'max-snippet' => '-1',
			'max-image-preview' => 'large',
			'max-video-preview' => '-1'
		];
		
		
		$robots = [
			'noindex' => !empty($settings['titles_noindex']),
			'nofollow' => !empty($settings['titles_nofollow']),
			'nosnippet' => !empty($settings['titles_nosnippet']),
			'noarchive' => !empty($settings['titles_noarchive']),
			'noimageindex' => !empty($settings['titles_noimageindex'])
		];

		if(!empty($post_id) && !empty($post->post_password)){
			$robots['noindex'] = true;
		}
		
		foreach($taxonomies as $taxonomy){
			// taxonomies
			$term_id = 0;
			if(is_tax() || is_category() || is_tag()){
				$queried_object = get_queried_object();
				$term_id = $queried_object->term_id ? $queried_object->term_id : 0;
				
				if($term_id){
					$robots['noindex'] = !empty(get_term_meta($term_id, '_siteseo_robots_index', true)) || $robots['noindex'];
					$robots['nofollow'] = !empty(get_term_meta($term_id, '_siteseo_robots_follow', true)) || $robots['nofollow'];
					$robots['nosnippet'] = !empty(get_term_meta($term_id, '_siteseo_robots_snippet', true)) || $robots['nosnippet'];
					$robots['noarchive'] = !empty(get_term_meta($term_id, '_siteseo_robots_archive', true)) || $robots['noarchive'];
					$robots['noimageindex'] = !empty(get_term_meta($term_id, '_siteseo_robots_imageindex', true)) || $robots['noimageindex'];
				}
				
				
				if(!empty($settings['titles_tax_titles'][$taxonomy->name]['noindex'])){
					
					if(isset($robots['index'])){
						unset($robots['index']);
					}
					
					$robots['noindex'] = true;
				}
								
				if(!empty($settings['titles_tax_titles'][$taxonomy->name]['nofollow'])){
					
					if(isset($robots['follow'])){
						unset($robots['follow']);
					}
					
					$robots['nofollow'] = true;
				}

				if(!$robots['noindex']){
					$robots['index'] = true;
					$robots = array_merge($robots, $index_extras);
				}

				if(!$robots['nofollow']){
					$robots['follow'] = true;
				}

				return array_filter($robots);
			}
		}
		
		// single post types
		foreach($post_types as $post_type){
			
			if($post_type->has_archive && is_post_type_archive($post_type->name)){
				
				if(function_exists('is_shop') && is_shop()){
					$post_id = !defined('SITEPAD') ? wc_get_page_id('shop') : kkart_get_page_id('shop');
				}
				
				if($post_id){
					$robots['noindex'] = !empty(get_post_meta($post_id, '_siteseo_robots_index', true)) || $robots['noindex'];
					$robots['nofollow'] = !empty(get_post_meta($post_id, '_siteseo_robots_follow', true)) || $robots['nofollow'];
					$robots['nosnippet'] = !empty(get_post_meta($post_id, '_siteseo_robots_snippet', true)) || $robots['nosnippet'];
					$robots['noarchive'] = !empty(get_post_meta($post_id, '_siteseo_robots_archive', true)) || $robots['noarchive'];
					$robots['noimageindex'] = !empty(get_post_meta($post_id, '_siteseo_robots_imageindex', true)) || $robots['noimageindex'];
				}
							
				if(!empty($settings['titles_archive_titles'][$post_type->name]['archive_noindex'])){
					
					if(isset($robots['index'])){
						unset($robots['index']);	
					}
					
					$robots['noindex'] = true;
				}
								
				if(!empty($settings['titles_archive_titles'][$post_type->name]['archive_nofollow'])){
					
					if(isset($robots['follow'])){
						unset($robots['follow']);
					}
					
					$robots['nofollow'] = true;
				}


				if(!$robots['noindex']){
					$robots['index'] = true;
					$robots = array_merge($robots, $index_extras);
				}

				if(!$robots['nofollow']){
					$robots['follow'] = true;
				}

				return array_filter($robots);
				
			}
			
			if(is_singular($post_type->name)){
				
				if($post_id){
					$robots['noindex'] = !empty(get_post_meta($post_id, '_siteseo_robots_index', true)) || $robots['noindex'];
					$robots['nofollow'] = !empty(get_post_meta($post_id, '_siteseo_robots_follow', true)) || $robots['nofollow'];
					$robots['nosnippet'] = !empty(get_post_meta($post_id, '_siteseo_robots_snippet', true)) || $robots['nosnippet'];
					$robots['noarchive'] = !empty(get_post_meta($post_id, '_siteseo_robots_archive', true)) || $robots['noarchive'];
					$robots['noimageindex'] = !empty(get_post_meta($post_id, '_siteseo_robots_imageindex', true)) || $robots['noimageindex'];
				}
							
				if(!empty($settings['titles_single_titles'][$post_type->name]['noindex'])){
					
					if(isset($robots['index'])){
						unset($robots['index']);	
					}
					
					$robots['noindex'] = true;
				}
								
				if(!empty($settings['titles_single_titles'][$post_type->name]['nofollow'])){
					
					if(isset($robots['follow'])){
						unset($robots['follow']);
					}
					
					$robots['nofollow'] = true;
				}


				if(!$robots['noindex']){
					$robots['index'] = true;
					$robots = array_merge($robots, $index_extras);
				}

				if(!$robots['nofollow']){
					$robots['follow'] = true;
				}
				
				// woocommerce pages, cart page
				if(function_exists('is_cart') && is_cart()){
					unset($robots['index']);
					$robots['noindex'] = true;
				}
				
				// checkout page
				if(function_exists('is_checkout') && is_checkout()){
					unset($robots['index']);
					$robots['noindex'] = true;
				}
				
				// account page 
				if(function_exists('is_account_page') && is_account_page()){
					unset($robots['index']);
					$robots['noindex'] = true;
				}

				return array_filter($robots);
			}
		}
		
		//archive pages
		if(is_author()){
			$robots['noindex'] = !empty($settings['titles_archives_author_noindex']);
			
			if(!$robots['noindex']){
				$robots['index'] = true;
				$robots = array_merge($robots, $index_extras);
			}
		}
		
		if(is_date()){
			$robots['noindex'] = !empty($settings['titles_archives_date_noindex']);
			
			if(!$robots['noindex']){
				$robots['index'] = true;
				$robots = array_merge($robots, $index_extras);
			}
		}
		
		if(is_search()){
			$robots['noindex'] = !empty($settings['titles_archives_search_title_noindex']);
			
			if(!$robots['noindex']){
				$robots['index'] = true;
				$robots = array_merge($robots, $index_extras);
			}
		}

		// default home page
		if(is_front_page() && is_home()){

			$robots = [
				'index' => true,
				'follow' => true
			];

			if(!empty($settings['titles_noindex'])){
				$robots['noindex'] = true;
				unset($robots['index']);
			}

			if(!empty($settings['titles_nofollow'])){
				$robots['nofollow'] = true;
				unset($robots['follow']);
			}

			if(!empty($settings['titles_nosnippet'])){
				$robots['nosnippet'] = true;
			}

			if(!empty($settings['titles_noarchive'])){
				$robots['noarchive'] = true;
			}

			if(!empty($settings['titles_noimageindex'])){
				$robots['noimageindex'] = true;
			}

			$robots = array_merge($robots, $index_extras);
		}
		
		// static set posts page
		if(is_home() && !is_front_page()){
			$blog_page_id = get_option('page_for_posts');
			
			$robots = [
				'index' => true,
				'follow' => true
			];
			
			if($blog_page_id){
				// Check blog page specific meta settings
				$robots['noindex'] = !empty(get_post_meta($blog_page_id, '_siteseo_robots_index', true));
				$robots['nofollow'] = !empty(get_post_meta($blog_page_id, '_siteseo_robots_follow', true));
				$robots['nosnippet'] = !empty(get_post_meta($blog_page_id, '_siteseo_robots_snippet', true));
				$robots['noarchive'] = !empty(get_post_meta($blog_page_id, '_siteseo_robots_archive', true));
				$robots['noimageindex'] = !empty(get_post_meta($blog_page_id, '_siteseo_robots_imageindex', true));
			}
			
			// Apply global settings as fallback
			if(!empty($settings['titles_noindex'])){
				$robots['noindex'] = true;
			}

			if(!empty($settings['titles_nofollow'])){
				$robots['nofollow'] = true;
			}

			if(!empty($settings['titles_nosnippet'])){
				$robots['nosnippet'] = true;
			}

			if(!empty($settings['titles_noarchive'])){
				$robots['noarchive'] = true;
			}

			if(!empty($settings['titles_noimageindex'])){
				$robots['noimageindex'] = true;
			}
			
			// Clean up conflicting directives
			if(!empty($robots['noindex'])){
				unset($robots['index']);
			}
			
			if(!empty($robots['nofollow'])){
				unset($robots['follow']);
			}
			
			if(empty($robots['noindex'])){
				$robots = array_merge($robots, $index_extras);
			}
		}
		
		return array_filter($robots);
	}
	
	static function add_nositelinkssearchbox(){
		global $siteseo;
		
		if(empty($siteseo->setting_enabled['toggle-titles'])){
			return;
		}
	
		if(!empty($siteseo->titles_settings['titles_nositelinkssearchbox'])){
			echo '<meta name="google" content="nositelinkssearchbox" >';
		}
		
	}
	
	static function add_canonical_url(){	
		$post_types = siteseo_post_types();
		
		foreach($post_types as $post_type){
			
			if($post_type->has_archive && is_post_type_archive($post_type->name)){
				$post_id = get_the_ID();
				$archive_url = get_post_type_archive_link($post_type->name);
				$canonical_meta = get_post_meta($post_id, '_siteseo_robots_canonical', true);
				$canonical = !empty($canonical_meta) ? $canonical_meta : $archive_url;
				
				if($archive_url){
					echo '<link rel="canonical" href="'.esc_url($archive_url).'" />' . "\n";
				}
			}
			
			if(is_singular($post_type->name)){
				$post_id = get_the_ID();
				$canonical_meta = get_post_meta($post_id, '_siteseo_robots_canonical', true);
				$canonical = !empty($canonical_meta) ? $canonical_meta : urldecode(get_permalink($post_id));
				
				if($canonical){
					echo '<link rel="canonical" href="'.esc_url($canonical).'" />' . "\n";
				}
			}
		}

		//taxonomies
		$taxonomies = get_taxonomies(array('public' => true), 'objects');
		
		if(is_tag() || is_category() || is_tax()){
			$term = get_queried_object();
			if($term && isset($term->term_id, $term->taxonomy)){
				$term_id = $term->term_id;
				$taxonomy_name = $term->taxonomy;
				
				$canonical_meta = get_term_meta($term_id, '_siteseo_robots_canonical', true);
				$canonical = !empty($canonical_meta) ? $canonical_meta : urldecode(get_term_link($term_id, $taxonomy_name));
				
				if($canonical){
					echo '<link rel="canonical" href="'.esc_url($canonical).'" />' . "\n";
				}
			}
		}
		
		// default home page
		if(is_front_page() && is_home()){
			$canonical = trailingslashit(home_url());
			echo '<link rel="canonical" href="'.esc_url($canonical).'" />' . "\n";				
		}
		
		// if static posts set
		if(is_home() && !is_front_page()){ 
			$blog_page_id = get_option('page_for_posts');
			if($blog_page_id){
				$canonical_meta = get_post_meta($blog_page_id, '_siteseo_robots_canonical', true);
				$canonical = !empty($canonical_meta) ? $canonical_meta : urldecode(get_permalink($blog_page_id));
				
				if($canonical){
					echo '<link rel="canonical" href="'.esc_url($canonical).'" />' . "\n";
				}
			} else{
				$canonical = trailingslashit(home_url());
				echo '<link rel="canonical" href="'.esc_url($canonical).'" />' . "\n";
			}
		}
		 
	}
	
	static function replace_variables($content, $in_editor = false){
		global $post, $siteseo, $wp_query, $term;
		
		// Site info
		$site_title = get_bloginfo('name');
		$site_tagline = get_bloginfo('description');
		$site_sep = !empty($siteseo->titles_settings['titles_sep']) ? $siteseo->titles_settings['titles_sep'] : '-';

		$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
		$page = get_query_var('page') ? get_query_var('page') : 1;
		
		// Date info
		$current_time = current_time('timestamp');
		$archive_date = get_the_date('d');
		$archive_month = get_the_date('M');
		$archive_month_name = get_the_date('F');
		$archive_year = get_the_date('Y');
		
		// Author
		$author_id = isset($post->post_author) ? $post->post_author : get_current_user_id();
		$author_first_name = get_the_author_meta('first_name', $author_id);
		$author_last_name = get_the_author_meta('last_name', $author_id);
		$author_website = get_the_author_meta('url', $author_id);
		$author_nickname = get_the_author_meta('nickname', $author_id);
		$author_bio = get_the_author_meta('description', $author_id);
		
		// WooCommerce
		$wc_variables = [];
		if(function_exists('wc_get_product') && is_singular('product')){
			$product = wc_get_product($post->ID);
			if($product){
				$wc_variables = array(
					'%%wc_single_cat%%' => wp_strip_all_tags(wc_get_product_category_list($post->ID)),
					'%%wc_single_tag%%' => wp_strip_all_tags(wc_get_product_tag_list($post->ID)),
					'%%wc_single_short_desc%%' => $product->get_short_description(),
					'%%wc_single_price%%' => $product->get_price(),
					'%%wc_single_price_exe_tax%%' => wc_get_price_excluding_tax($product),
					'%%wc_sku%%' => $product->get_sku(),
					'%%wc_parent_cat%%' => self::get_parent_category_name($post->ID),
				);
			}
		}
		
		//KKART
		$kkart_variables = [];
		if(function_exists('kkart_get_product') && is_singular('product')){
			$product = kkart_get_product($post->ID);
			if($product){
				$kkart_variables = array(
					'%%wc_single_cat%%' => wp_strip_all_tags(kkart_get_product_category_list($post->ID)),
					'%%wc_single_tag%%' => wp_strip_all_tags(kkart_get_product_tag_list($post->ID)),
					'%%wc_single_short_desc%%' => $product->get_short_description(),
					'%%wc_single_price%%' => $product->get_price(),
					'%%wc_single_price_exe_tax%%' => kkart_get_price_excluding_tax($product),
					'%%wc_sku%%' => $product->get_sku(),
					'%%wc_parent_cat%%' => self::get_parent_category_name($post->ID),
				);
			}
		}

		$replacements = array(
			'%%sep%%' => $site_sep,
			'%%sitetitle%%' => $site_title,
			'%%tagline%%' => $site_tagline,
			'%%post_title%%' => (is_singular() || $in_editor === TRUE) ? get_the_title() : (is_home() ? get_the_title(get_option('page_for_posts')) : ''),
			'%%post_excerpt%%' => (is_singular() || $in_editor === TRUE) ? get_the_excerpt() : '',
			'%%post_content%%' => (is_singular() || $in_editor === TRUE) ? wp_strip_all_tags(get_the_content()) : '',
			'%%post_thumbnail_url%%' => get_the_post_thumbnail_url($post),
			'%%post_url%%' => urldecode(get_permalink()),
			'%%post_date%%' => get_the_date(),
			'%%post_modified_date%%' => get_the_modified_date(),
			'%%post_author%%' => get_the_author(),
			'%%post_category%%' => wp_strip_all_tags(get_the_category_list(', ')),
			'%%post_tag%%' => wp_strip_all_tags(get_the_tag_list('', ', ', '')),
			'%%_category_title%%' => single_cat_title('', false),
			'%%_category_description%%' => category_description(),
			'%%tag_title%%' => single_tag_title('', false),
			'%%tag_description%%' => tag_description(),
			'%%term_title%%' => single_term_title('', false),
			'%%term_description%%' => term_description(),
			'%%search_keywords%%' => get_search_query(),
			'%%current_pagination%%' => $paged,
			'%%page%%' => $page,
			'%%cpt_plural%%' => post_type_archive_title('', false),
			'%%archive_title%%' => get_the_archive_title(),
			'%%archive_date%%' => $archive_date,
			'%%archive_date_day%%' => $archive_date,
			'%%archive_date_month%%' => $archive_month,
			'%%archive_date_month_name%%' => $archive_month_name,
			'%%archive_date_year%%' => $archive_year,
			'%%currentday%%' => date_i18n('j', $current_time),
			'%%currentmonth%%' => date_i18n('F', $current_time),
			'%%currentmonth_short%%' => date_i18n('M', $current_time),
			'%%currentmonth_num%%' => date_i18n('n', $current_time),
			'%%currentyear%%' => date_i18n('Y', $current_time),
			'%%currentdate%%' => date_i18n(get_option('date_format'), $current_time),
			'%%currenttime%%' => date_i18n(get_option('time_format'), $current_time),
			'%%author_first_name%%' => $author_first_name,
			'%%author_last_name%%' => $author_last_name,
			'%%author_website%%' => $author_website,
			'%%author_nickname%%' => $author_nickname,
			'%%author_bio%%' => $author_bio,
		);
		
		//WooCommerces
		if(!empty($wc_variables)){
			$replacements = array_merge($replacements, $wc_variables);
		}

		//Kkart
		if(!empty($kkart_variables)){
			$replacements = array_merge($replacements, $kkart_variables);
		}

		$safe_list = [
			'_siteseo_titles_title',
			'_siteseo_titles_desc',
			'_siteseo_social_fb_title',
			'_siteseo_social_fb_desc',
			'_siteseo_social_fb_img',
			'_siteseo_social_twitter_title',
			'_siteseo_social_twitter_desc',
			'_siteseo_social_twitter_img',

			// WooCommerce 
			'_price',
			'_regular_price',
			'_sale_price',
			'_stock',
			'_stock_status',
			'_sku',
			'_weight',
			'_length',
			'width',
			'_height',
			'total_sales',
		];

		if(preg_match_all('/%%_cf_(.*?)%%/', $content, $matches)){
			foreach ($matches[1] as $custom_field) {

				if(!in_array($custom_field, $safe_list, true)){
					continue;
				}

				$meta_value = get_post_meta($post->ID, $custom_field, true);
				$replacements["%%_cf_{$custom_field}%%"] = $meta_value;
			}
		}

		if(preg_match_all('/%%_ct_(.*?)%%/', $content, $matches)){
			foreach($matches[1] as $taxonomy){

				if(!in_array($taxonomy, $safe_list, true)){
					continue;
				}

				$terms = get_the_terms($post->ID, $taxonomy);
				$term_names = is_array($terms) ? wp_list_pluck($terms, 'name') : [];
				$replacements["%%_ct_{$taxonomy}%%"] = implode(', ', $term_names);
			}
		}

		if(preg_match_all('/%%_ucf_(.*?)%%/', $content, $matches)){
			foreach($matches[1] as $user_meta){

				if(!in_array($user_meta, $safe_list, true)){
					continue;
				}

				$meta_value = get_user_meta($author_id, $user_meta, true);
				$replacements["%%_ucf_{$user_meta}%%"] = $meta_value;
			}
		}

		$target_keywords = isset($siteseo->keywords_settings['tempory_set']) ? $siteseo->keywords_settings['tempory_set'] : '';
		$replacements['%%target_keyword%%'] = $target_keywords;

		$replacements = array_map(function($value){
			if(is_array($value) || is_object($value)){
				return '';
			}

			return is_null($value) ? '' : wp_strip_all_tags($value);
		}, $replacements);

		return str_replace(
			array_keys($replacements),
			array_values($replacements),
			$content
		);
	}

	static function get_parent_category_name($product_id){
		if(!class_exists('WooCommerce') && !class_exists('KKART')){
			return;
		}

		$terms = get_the_terms($product_id, 'product_cat');

		if(empty($terms) || is_wp_error($terms)){
			return '';
		}

		// Find the parent category (the one with parent = 0)
		foreach($terms as $term){
			if($term->parent == 0){
				return $term->name;
			}
		}

	}
	
	static function modify_site_title($title, $sep = ''){
		global $siteseo, $post;

		// Check enabled
		if(empty($siteseo->setting_enabled['toggle-titles'])){
			return $title;
		}

		$settings = $siteseo->titles_settings;

		// post types and taxonomies
		$post_types = siteseo_post_types();
		$taxonomies = get_taxonomies(array('public' => true), 'objects');
		
		// Check set by meta
		$post_id = isset($post) && is_object($post) ? $post->ID : '';
		$post_meta_title = !empty(get_post_meta($post_id, '_siteseo_titles_title', true)) ? get_post_meta($post_id, '_siteseo_titles_title', true) : '';
		
		// default home page
		if(is_front_page() && is_home()){
			
			if(!empty($settings['titles_home_site_title'])){
				$new_title = $settings['titles_home_site_title'];
			}
			
			if(!empty($new_title)){
				$new_title = esc_attr(self::replace_variables($new_title));
				if(!empty($sep)){
					$new_title .= " $sep " . get_bloginfo('name');
				}
				
				return $new_title;
			}
		}
		
		// static posts pages
		if(is_home() && !is_front_page()){
			$blog_page_id = get_option('page_for_posts');
			
			if($blog_page_id){
				$blog_meta_title = get_post_meta($blog_page_id, '_siteseo_titles_title', true);
				$default_title = !empty($settings['titles_single_titles']['page']['title']) ? $settings['titles_single_titles']['page']['title'] : '';
				
				$new_title = !empty($blog_meta_title) ? $blog_meta_title : $default_title;
				
				if(!empty($new_title)){
					$new_title = esc_attr(self::replace_variables($new_title));

					if(!empty($sep)){
						$new_title .= " $sep " . get_bloginfo('name');
					}

					return $new_title;
				}
			}
		}

		// single post types
		foreach($post_types as $post_type){
			
			if($post_type->has_archive && is_post_type_archive($post_type->name)){
				
				$post_meta_title = '';
				
				if(function_exists('is_shop') && is_shop()){
					$shop_page_id = !defined('SITEPAD') ? wc_get_page_id('shop') : kkart_get_page_id('shop') ;
					$post_meta_title = get_post_meta($shop_page_id, '_siteseo_titles_title', true);
				}
				
				$default_title = isset($settings['titles_archive_titles'][$post_type->name]['archive_title']) ? $settings['titles_archive_titles'][$post_type->name]['archive_title'] : '';
				
				$new_title = !empty($post_meta_title) ? $post_meta_title : $default_title;

				if(!empty($new_title)){
					$new_title = esc_attr(self::replace_variables($new_title));

					if(!empty($sep)){
						$new_title .= " $sep " . get_bloginfo('name');
					}

					return $new_title;
				}
				
			}
			
			if(is_singular($post_type->name)){
				$default_title = isset($settings['titles_single_titles'][$post_type->name]['title']) ? $settings['titles_single_titles'][$post_type->name]['title'] : '';
				$new_title = !empty($post_meta_title) ? $post_meta_title : $default_title;

				if(!empty($new_title)){
					$new_title = esc_attr(self::replace_variables($new_title));

					if(!empty($sep)){
						$new_title .= " $sep " . get_bloginfo('name');
					}

					return $new_title;
				}
			}
		}

		//taxonomies
		foreach($taxonomies as $taxonomy){
			if(is_category()){
				$term = get_queried_object();
				$term_id = $term->term_id;
				$term_meta_title = get_term_meta($term_id, '_siteseo_titles_title', true);
				$default_title = isset($settings['titles_tax_titles']['category']['title']) ? $settings['titles_tax_titles']['category']['title'] : '';
				$disabled = !empty($settings['titles_tax_titles']['category']['disabled']);
				$new_title = !empty($term_meta_title) ? $term_meta_title : $default_title;

				if(!empty($new_title) && !$disabled){
					$new_title = esc_attr(self::replace_variables($new_title));
					
					if(!empty($sep)){
						$new_title .= " $sep " . get_bloginfo('name');
					}

					return $new_title;
				}
			} elseif(is_tag()) {
				$term = get_queried_object();
				$term_id = $term->term_id;
				$term_meta_title = get_term_meta($term_id, '_siteseo_titles_title', true);
				$default_title = isset($settings['titles_tax_titles']['post_tag']['title']) ? $settings['titles_tax_titles']['post_tag']['title'] : '';
				$disabled = !empty($settings['titles_tax_titles']['post_tag']['disabled']);

				$new_title = !empty($term_meta_title) ? $term_meta_title : $default_title;

				if(!empty($new_title) && !$disabled){
					$new_title = esc_attr(self::replace_variables($new_title));

					
					if(!empty($sep)){
						$new_title .= " $sep " . get_bloginfo('name');
					}

					return $new_title;
				}
			} elseif(is_tax($taxonomy->name)) {
				$term = get_queried_object();
				$term_id = $term->term_id;
				$term_meta_title = get_term_meta($term_id, '_siteseo_titles_title', true);
				$default_title = isset($settings['titles_tax_titles'][$taxonomy->name]['title']) ? $settings['titles_tax_titles'][$taxonomy->name]['title'] : '';
				$disabled = !empty($settings['titles_tax_titles'][$taxonomy->name]['disabled']);

				$new_title = !empty($term_meta_title) ? $term_meta_title : $default_title;

				if(!empty($new_title) && !$disabled){
					$new_title = esc_attr(self::replace_variables($new_title));

					if(!empty($sep)){
						$new_title .= " $sep " . get_bloginfo('name');
					}

					return $new_title;
				}
			}
		}
		
		// author archive
		if(is_author() && !empty($settings['titles_archives_author_title']) && empty($settings['titles_archives_author_disable'])) {
			$new_title = esc_attr(self::replace_variables($settings['titles_archives_author_title']));

			if(!empty($sep)){
				$new_title .= " $sep " . get_bloginfo('name');
			}

			return $new_title;
		}

		//Date archive
		if(is_date() && !empty($settings['titles_archives_date_title']) && empty($settings['titles_archives_date_disable'])){
			$new_title = esc_attr(self::replace_variables($settings['titles_archives_date_title']));

			if(!empty($sep)){
				$new_title .= " $sep " . get_bloginfo('name');
			}

			return $new_title;
		}
		
		// Search archive
		if(is_search() && !empty($settings['titles_archives_search_title'])){

			$new_title = esc_attr(self::replace_variables($settings['titles_archives_search_title']));

			if(!empty($sep)){
				$new_title .= " $sep " . get_bloginfo('name');
			}

			return $new_title;
		}
		
		// 404 archive
		if(is_404() && !empty($settings['titles_archives_404_title'])){

			$new_title = esc_attr(self::replace_variables($settings['titles_archives_404_title']));

			if(!empty($sep)){
				$new_title .= " $sep " . get_bloginfo('name');
			}

			return $new_title;
		}

		return $title;
	}
	
	static function add_meta_description(){
		global $siteseo, $post;

		if(empty($siteseo->setting_enabled['toggle-titles'])){
			return;
		}

		$settings = $siteseo->titles_settings;

		// Get all registered post types
		$post_types = siteseo_post_types();
		$taxonomies = get_taxonomies(array('public' => true), 'objects');

		$post_id = isset($post) && is_object($post) ? $post->ID : '';
		
		// default home page
		if(is_front_page() && is_home()){
			
			if(!empty($settings['titles_home_site_desc'])){
				$processed_desc = self::replace_variables($settings['titles_home_site_desc']);
				echo '<meta name="description" content="' . esc_attr(self::truncate_desc($processed_desc)) . '">';
			} else{
				$description = get_bloginfo('description');
				if(!empty($description)){
					echo '<meta name="description" content="' . esc_attr($description) . '">';
				}
			}
		}
		
		// if set static posts page
		if(is_home() && !is_front_page()){
			$blog_page_id = get_option('page_for_posts');
			if($blog_page_id){
				$meta_desc = get_post_meta($blog_page_id, '_siteseo_titles_desc', true);
				if(!empty($meta_desc)){
					$processed_desc = esc_attr(self::replace_variables($meta_desc));
					echo '<meta name="description" content="' . esc_attr(self::truncate_desc($processed_desc)) . '">';
				} elseif(!empty($settings['titles_single_titles']['page']['description'])){
					$processed_desc = self::replace_variables($settings['titles_single_titles']['page']['description']);
				
					echo '<meta name="description" content="' . esc_attr(self::truncate_desc($processed_desc)) . '">';
				} else{
					$description = get_bloginfo('description'); 
					if(!empty($description)){ 
						echo '<meta name="description" content="' . esc_attr(self::truncate_desc($description)) . '">'; 
					} 
				}
			}
		}
		
		// single post types
		foreach($post_types as $post_type){
			
			if($post_type->has_archive && is_post_type_archive($post_type->name)){
				
				$archive_desc = '';
				if(is_post_type_archive()){
					$obj = get_queried_object();
					
					if(!empty($obj) && isset($obj->name)){
						$archive_desc  = !empty($obj->description) ? $obj->description : '';
					}
				}
				
				$meta_desc = '';
				
				if(function_exists('is_shop') && is_shop()){
					$shop_page_id = !defined('SITEPAD') ? wc_get_page_id('shop') : kkart_get_page_id('shop');
					$meta_desc = get_post_meta($shop_page_id, '_siteseo_titles_desc', true);
				}
				
				$description = !empty($settings['titles_archive_titles'][$post_type->name]['archive_desc']) ? $settings['titles_archive_titles'][$post_type->name]['archive_desc'] : $archive_desc;
				
				$description = !empty($meta_desc) ? $meta_desc : $description;

				if(!empty($description)){
					$description = self::replace_variables($description);
					echo '<meta name="description" content="' . esc_attr(self::truncate_desc($description)) . '">';
				}
				
			}
			
			if(is_singular($post_type->name)){
				$meta_desc = get_post_meta($post_id, '_siteseo_titles_desc', true);
				$default_desc = isset($settings['titles_single_titles'][$post_type->name]['description']) ? $settings['titles_single_titles'][$post_type->name]['description'] : '';

				$description = !empty($meta_desc) ? $meta_desc : $default_desc;

				if(!empty($description)){
					$description = self::replace_variables($description);
					echo '<meta name="description" content="' . esc_attr(self::truncate_desc($description)) . '">';
				}
			}
		}
		
		if(is_category() || is_tag() || is_tax()){
			$term = get_queried_object();
			if($term){
				$term_id = $term->term_id;
				$term_meta_desc = get_term_meta($term_id, '_siteseo_titles_desc', true);
				$default_desc = '';
				$taxonomy_name = '';

				if(is_category()){
					$default_desc = isset($settings['titles_tax_titles']['category']['description']) ? $settings['titles_tax_titles']['category']['description'] : '';
					$taxonomy_name = 'category';
				} elseif(is_tag()){
					$default_desc = isset($settings['titles_tax_titles']['post_tag']['description']) ? $settings['titles_tax_titles']['post_tag']['description'] : '';
					$taxonomy_name = 'post_tag';
				} else{
					$taxonomy_name = $term->taxonomy;
					$default_desc = isset($settings['titles_tax_titles'][$taxonomy_name]['description']) ? $settings['titles_tax_titles'][$taxonomy_name]['description'] : '';
				}

				$disabled = isset($settings['titles_tax_titles'][$taxonomy_name]['disabled']);

				$description = !empty($term_meta_desc) ? $term_meta_desc : $default_desc;

				if(!empty($disabled)){
					$description = self::replace_variables($description);
					echo '<meta name="description" content="' . esc_attr(self::truncate_desc($description)) . '">';
				}
			}
		}
		
		// Author archive
		if(is_author() && !empty($settings['titles_archives_author_desc']) && empty($settings['titles_archives_author_disable'])){
			$description = self::replace_variables($settings['titles_archives_author_desc']);
			echo '<meta name="description" content="'.esc_attr(self::truncate_desc($description)).'" >';
		}
		
		// Date archive
		if(is_date() && !empty($settings['titles_archives_date_desc']) && empty($settings['titles_archives_date_disable'])){
			$description = self::replace_variables($settings['titles_archives_date_desc']);
			echo '<meta name="description" content="'.esc_attr(self::truncate_desc($description)).'" >';
		}
		
		// Search archive
		if(is_search() && !empty($settings['titles_archives_search_desc'])){
			$description = self::replace_variables($settings['titles_archives_search_desc']);
			echo '<meta name="description" content="'.esc_attr(self::truncate_desc($description)).'" >';
		}
		
		// 404 archives
		if(is_404() && !empty($settings['titles_archives_404_desc'])){
			$description = self::replace_variables($settings['titles_archives_404_desc']);
			echo '<meta name="description" content="'.esc_attr(self::truncate_desc($description)).'" >';
		}
	}
	
	static function add_rel_link_pages(){
		global $siteseo, $paged;

		if(empty($siteseo->setting_enabled['toggle-titles'])){
			return;
		}

		if(!empty($siteseo->titles_settings['titles_paged_rel'])){

			if(get_previous_posts_link()){

				echo '<link rel="prev" href="'.esc_url(get_pagenum_link($paged - 1)).'" />';
			}
			if(get_next_posts_link()){

				echo '<link rel="next" href="'.esc_url(get_pagenum_link($paged + 1)).'" />';
			}
		}
	}

	static function date_time_publish(){
		global $siteseo;
		
		if(empty($siteseo->setting_enabled['toggle-titles'])){
			return;
		}
		
		if(!is_singular()){
			return;
		}
		
		
		$current_post_type = get_post_type();
		
		$type_settings = isset($siteseo->titles_settings['titles_single_titles'][$current_post_type]) ? $siteseo->titles_settings['titles_single_titles'][$current_post_type] : '';
		
		// post type
		if(!empty($type_settings['date'])){
			$published_time = get_the_date('c');
			$modified_time = get_the_modified_date('c');
			echo '<meta property="article:published_time" content="'. esc_attr($published_time) .'">';
			echo '<meta property="article:modified_time" content="'. esc_attr($modified_time) .'">';
		}
		
		// thumbnails
		if(!empty($type_settings['thumb_gcs'])){
			if(get_the_post_thumbnail_url(get_the_ID())){
				echo '<meta name="thumbnail" content="'.esc_url(get_the_post_thumbnail_url(get_the_ID())).'">';
			}
		}

	}

	static function truncate_desc($desc){
		return trim($desc);
	}
}
PK��f\B�AZ��mailer/sparkpost.phpnu�[���<?php
/**
 * Class GOSMTP_Mailer_Sparkpost.
 *
 * @since 1.0.0
 */

namespace GOSMTP\Mailer;
 
use GOSMTP\Mailer\Loader;

class Sparkpost extends Loader{
	
	var $title = 'Sparkpost';
	
	var $mailer = 'sparkpost';
	
	const API_URL_US = 'https://api.sparkpost.com/api/v1';
	
	const API_URL_EU = 'https://api.eu.sparkpost.com/api/v1';
	
	var $url = '';

	public function send(){
		global $phpmailer;
		
		$phpmailer->isMail();
		
		if($phpmailer->preSend()){
			$this->set_API_Url();
			$response = $this->postSend();
		 	return $this->handle_response( $response );
		}
		
		return $this->handle_response(new \WP_Error(400, 'Unable to send mail for some reason!', []));
	}

	public function postSend(){
		global $phpmailer;
		
		$body = [
			'options' => [
				'open_tracking'  => false,
				'click_tracking' => false,
				'transactional'  => true,
			],
			'content' => [
				'from' => [
					'name' => $phpmailer->FromName,
					'email' => $phpmailer->From
				],
				'subject' => $phpmailer->Subject,
				'headers' => [],
			],
			'recipients' => $this->get_recipients()
		];
		
		$body['content']['headers']['CC'] = implode( ',', array_map( [$phpmailer, 'addrFormat'], $phpmailer->getCcAddresses() ) );
		
		if( $phpmailer->ContentType === 'text/plain' ){
			$body['content']['text'] = $phpmailer->AltBody;
		}else{
			$body['content']['html'] = $phpmailer->Body;
		}
		
		$replyTo = $phpmailer->getReplyToAddresses();	
		
		if(!empty($replyTo)){
			$body['content']['reply_to'] = implode( ',', array_map( [ $phpmailer, 'addrFormat' ], $replyTo ) );
		}
		
		$attachments = $phpmailer->getAttachments();
		
		if(!empty($attachments)){ 
			$body['Content']['Attachments'] = $this->getAttachments($attachments);
		}

		$params = [
			'body' => json_encode($body),
			'headers' => [
				'Content-Type' => 'application/json',
				'Authorization' => $this->getOption('api_key', $this->mailer)
			]
		];

		$params = array_merge($params, $this->getDefaultParams());

		$response = wp_safe_remote_post($this->url, $params);

		if(is_wp_error($response)){
			$returnResponse = new \WP_Error($response->get_error_code(), $response->get_error_message(), $response->get_error_messages());
		}else{
			$responseBody = wp_remote_retrieve_body($response);
			$responseCode = wp_remote_retrieve_response_code($response);

			$isOKCode = $responseCode < 300;

			$responseBody = \json_decode($responseBody, true);

			if($isOKCode){
				$returnResponse = [
					'status' => true,
					'code' => $responseCode,
					'messageId' => $responseBody['id'],
					'message' => $responseBody['message'],
				];
								
			}else{
				$error_text = [''];
				
				if(!empty($responseBody['errors'] ) && is_array( $responseBody['errors'])){

					foreach($responseBody['errors'] as $error){

						if(empty($error['message'])){
							continue;
						}
						
						$code = !empty($error['code']) ? $error['code'] : '';
						$desc = !empty($error['description']) ? $error['description'] : '';
						
						$error_text[] = $this->message_formatting($error['message'], $code, $desc);
					}
				}else{
					$error_text[] = $this->get_response_error_message($response);
				}
			
				$error_message = implode( '\r\n', array_map( 'esc_textarea', array_filter( $error_text ) ) );
				$returnResponse = new \WP_Error($responseCode, $error_message, $responseBody);
			}
		}

		return $returnResponse;

	}

	public function set_API_Url(){

		$url = self::API_URL_US;

		if($this->getOption('region', $this->mailer) == 'eu'){
			$url = self::API_URL_EU;
		}
		
		$url .='/transmissions';
		
		return $this->url = $url;
	}
	
	public function get_recipients(){
		global $phpmailer;
		
		$data = [];
				
		$recipients = [
			'to' => $phpmailer->getToAddresses(),
			'cc' => $phpmailer->getCcAddresses(),
			'bcc' => $phpmailer->getBccAddresses(),
		];
		
		$recipients_to = isset( $recipients['to'] ) && is_array( $recipients['to'] ) ? $recipients['to'] : [];
		$header_to = implode( ',', array_map( [$phpmailer, 'addrFormat'], $recipients_to ) );
				
		foreach( $recipients as $key => $emails ){
			
			if(empty($emails)){
				continue;
			}
			
			foreach( $emails as $email ){
				$holder = [];
				
				$holder['email'] = $email[0];

				if( ! empty( $email[1] ) ){
					$holder['name'] = $email[1];
				}

				if(!empty($header_to) && $key != 'to'){
					$holder['header_to'] = $header_to;
				}

				$data[] = [ 'address' => $holder ];
			}
		}
		
		return $data;
	}
	
	protected function getAttachments($attachments){
		
		$data = [];

		foreach($attachments as $attachment){
			$file = false;

			try{
				if (is_file($attachment[0]) && is_readable($attachment[0])) {
					$fileName = basename($attachment[0]);
					$file = file_get_contents($attachment[0]);
					$mimeType = mime_content_type($attachment[0]);
					$filetype = str_replace(';', '', trim($mimeType));
				}
			} catch (\Exception $e) {
				$file = false;
			}

			if ($file === false) {
				continue;
			}

			$data[] = [
				'name' => $fileName,
				'type' => $filetype,
				'content' => base64_encode($file)
			];
		}

		return $data;
	}

	public function load_field(){
		$fields = array(
			'api_key' => array(
				'title' => __('API Key', 'gosmtp'),
				'type' => 'password',
				'desc' => __( 'Follow this link to get an API Key from SparkPost: <a href="https://app.sparkpost.com/account/api-keys" target="_blank">Get API Key.</a>', 'gosmtp' ),
			),
			'region' => array(
				'title' => __('Region', 'gosmtp'),
				'type' => 'radio',
				'class'=>'regular-text',
				'list'=>array(
					'Us'=>'US',
					'EU'=>'EU',
				),
				'desc' => __( 'Select your SparkPost account region. <a href="https://support.sparkpost.com/docs/getting-started/getting-started-sparkpost" target="_blank">More information </a>on SparkPost.', 'gosmtp' ),
			),
		);
		
		return $fields;
	}
}

PK��f\�!:FFmailer/mail.phpnu�[���<?php
/**
 * Class GOSMTP_Mailer_Mail.
 *
 * @since 1.0.0
 */
 
namespace GOSMTP\Mailer;
 
use GOSMTP\Mailer\Loader;

class Mail extends Loader{
	
	var $title = 'Default';
	var $mailer = 'mail';
	
	/**
	 * Override default mail send function.
	 * @since 1.0.0
	 */
	public function send() {
		global $phpmailer;
		
		$phpmailer->isMail();

		if($phpmailer->preSend()){
		    
			try{
				if($phpmailer->postSend()){
					$response = [
						'status' => true,
						'code' => 200,
						'messageId' => '',
						'message' => 'Mail sent successfully',
					];
					
					return $this->handle_response($response);
				}
			}catch( \Exception $e ){
				return $this->handle_response(new \WP_Error(400,  $e->getMessage(), []));
			}

		}
		
		return $this->handle_response(new \WP_Error(400, 'Unable to send mail for some reason!', []));
	}
}
PK��f\
IC-��mailer/smtpcom.phpnu�[���<?php
/**
 * Class GOSMTP_Mailer_SMTPcom.
 *
 * @since 1.0.0
 */

namespace GOSMTP\Mailer;
 
use GOSMTP\Mailer\Loader;

class SMTPcom extends Loader{
	
	var $title = 'SMTP.com';

	var $mailer = 'smtpcom';

	var $url = 'https://api.smtp.com/v4/messages';
	
	public function send(){
		global $phpmailer;

		$phpmailer->isMail();

		if($phpmailer->preSend()){
			$response = $this->postSend();
		 	return $this->handle_response( $response );
		}
		
		return $this->handle_response(new \WP_Error(400, 'Unable to send mail for some reason!', []));
	}

	public function postSend(){		
		global $phpmailer;

		$sender = array(
			'address' => $phpmailer->From,
		);
		
		if(!empty($phpmailer->FromName)){
			$sender['name'] = $phpmailer->FromName;
		}

		$body = array(
			'originator' => [
				'from' => $sender,
			],
			'subject' => $phpmailer->Subject,
			'channel' => $this->getOption('channel', $this->mailer),
			'body' => array(
				'parts' => $this->set_content($phpmailer->Body)
			)
		);
		
		$reply_to = $this->filterRecipientsArray($phpmailer->getReplyToAddresses());
		
		if(!empty($reply_to)){
			$body['originator']['reply_to'] = $reply_to;
		}
		
		$recipients = array(
			'to'  => $this->filterRecipientsArray($phpmailer->getToAddresses()),
			'cc'  => $this->filterRecipientsArray($phpmailer->getCcAddresses()),
			'bcc' => $this->filterRecipientsArray($phpmailer->getBccAddresses())
		);
		
		$body['recipients'] = array_filter($recipients);
		
		$attachments = $phpmailer->getAttachments();
		
		if(!empty($attachments)){
			$body['body']['attachments'] = $this->getAttachments($attachments);
		}
		
		$timeout = (int) ini_get( 'max_execution_time' );

		$api_key = $this->getOption('api_key', $this->mailer);		

		$headers = [
			'Authorization' => 'Bearer ' .$api_key,
			'content-type' => 'application/json',
			'Accept' => 'application/json'
		];

		$custom_headers = $phpmailer->getCustomHeaders();
		$body['custom_headers'] = array_merge($custom_headers,['X-Mailer' => 'GOSMTPMailer - SMTPCom']);

		$params = array(
			'headers' => $headers,
			'body' => wp_json_encode($body),
			'timeout' => $timeout ? $timeout : 30
		);

		// print_r(json_encode($body, JSON_PRETTY_PRINT));

		$response = wp_safe_remote_post($this->url, $params);

		if(is_wp_error($response)){
			$returnResponse = new \WP_Error($response->get_error_code(), $response->get_error_message(), $response->get_error_messages());
		}else{
			$responseBody = wp_remote_retrieve_body($response);
			$responseCode = wp_remote_retrieve_response_code($response);

			$responseBody = \json_decode($responseBody, true);
			
			// TODO: check aginf for error
			if($responseCode == 200) {
				$returnResponse = [
					'status' => true,
					'code' => 200,
					'messageId' => $responseBody['id'],
					'message' => $responseBody['message'], 
				];
			}else{
				$error_text = [''];
				if(!empty($responseBody['data']) ){
					foreach( (array) $responseBody['data'] as $error_key => $error_message ) {
						$error_text[] = $this->message_formatting( $error_message );
					}
				}else{
					$error_text[] = $this->get_response_error_message($response);
				}
				
				$error_msg = implode( '\r\n', array_map( 'esc_textarea', array_filter( $error_text ) ) );
				$returnResponse = new \WP_Error($responseCode, $error_msg, $responseBody);

			}
		}
		
		return $returnResponse;
	}

	public function set_content( $content ){
		global $phpmailer;

		if( empty( $content ) ){
			return;
		}

		$parts = [];

		if( is_array( $content ) ){
			$allowed = [ 'text', 'html' ];

			foreach( $content as $type => $body ){
				if( ! in_array( $type, $allowed, true ) || empty( $body ) ){
					continue;
				}

				$content_type  = 'text/plain';
				$content_value = $body;

				if( $type === 'html' ){
					$content_type = 'text/html';
				}

				$parts[] = [
					'type' => $content_type,
					'content' => $content_value,
					'charset' => $phpmailer->CharSet,
				];
			}
		}else{
			$content_type  = 'text/html';
			$content_value = $content;

			if( $this->phpmailer->ContentType === 'text/plain' ){
				$content_type = 'text/plain';
			}

			$parts[] = [
				'type'    => $content_type,
				'content' => $content_value,
				'charset' => $this->phpmailer->CharSet,
			];
		}
		
		return $parts;

	}

	protected function filterRecipientsArray($args){
		$recipients = [];

		foreach($args as $key => $recip){
			
			$recip = array_filter($recip);

			if(empty($recip) || ! filter_var( $recip[0], FILTER_VALIDATE_EMAIL ) ){
				continue;
			}

			$recipients[$key] = array(
				'address' => $recip[0]
			);

			if(!empty($recip[1])){
				$recipients[$key]['name'] = $recip[1];
			}
		}

		return $recipients;
	}

	public function getAttachments( $attachments ){

		if( empty( $attachments ) ){
			return;
		}

		$data = [];

		foreach( $attachments as $attachment ){
			$file = false;

			try{
				if( $attachment[5] === true ){
					$file = $attachment[0];
				}elseif( is_file( $attachment[0] ) && is_readable( $attachment[0] ) ){
					$file = file_get_contents( $attachment[0] );
				}
			}catch( \Exception $e ){
				$file = false;
			}

			if( $file === false ){
				continue;
			}

			$filetype = str_replace( ';', '', trim( $attachment[4] ) );

			$data[] = [
				'content' => chunk_split( base64_encode( $file ) ),
				'type' => $filetype,
				'encoding' => 'base64',
				'filename' => empty( $attachment[2] ) ? 'file-' . wp_hash( microtime() ) . '.' . $filetype : trim( $attachment[2] ),
				'disposition' => in_array( $attachment[6], [ 'inline', 'attachment' ], true ) ? $attachment[6] : 'attachment',
				'cid' => empty( $attachment[7] ) ? '' : trim( (string) $attachment[7] ),
			];
		}

		return $data;
	}
	
	public function load_field(){

		$fields = array(
			'api_key' => array(
				'title' => __('API Key', 'gosmtp'),
				'type' => 'password',
				'desc' => __( 'Follow this link to get an API Key from SMTP.com: <a href="https://my.smtp.com/settings/api" target="_blank">Get API Key.</a>', 'gosmtp' ),
			),
			'channel' => array(
				'title' => __('Sender Name', 'gosmtp'),
				'type' => 'text',
				'desc' => __( 'Follow this link to get a Sender Name from SMTP.com: <a href="https://my.smtp.com/senders/" target="_blank">Get Sender Name.</a>', 'gosmtp' ),
			),
		);
		
		return $fields;
	}
}
PK��f\W�q]��mailer/smtp.phpnu�[���<?php
/**
 * Class GOSMTP_Mailer_SMTP.
 *
 * @since 1.0.0
 */
 
namespace GOSMTP\Mailer;
 
use GOSMTP\Mailer\Loader;

class SMTP extends Loader{
	
	var $title = 'Other SMTP';
	var $mailer = 'smtp';
	
	/**
	 * Override default mail send function.
	 * @since 1.0.0
	 */
	public function send(){
		global $phpmailer;
		
		$phpmailer->isSMTP();
		
		$encryption = $this->getOption('encryption', $this->mailer);
		
		if ( !empty($encryption) && 'none' !== $encryption) {
			$phpmailer->SMTPSecure = $encryption;
		}

		// Set the other options
		$phpmailer->Host = $this->getOption('smtp_host', $this->mailer);
		$phpmailer->Port = $this->getOption('smtp_port', $this->mailer);

		// If we're using smtp auth, set the username & password
		$smtp_auth = $this->getOption('smtp_auth', $this->mailer);
		if(!empty($smtp_auth) && $smtp_auth == 'Yes'){
			$phpmailer->SMTPAuth = true;
			$phpmailer->Username = $this->getOption('smtp_username', $this->mailer);
			$phpmailer->Password = $this->getOption('smtp_password', $this->mailer);
		}
		
		//PHPMailer 5.2.10 introduced this option. However, this might cause issues if the server is advertising TLS with an invalid certificate.
		$phpmailer->SMTPAutoTLS = false;
		
		$ssl_verification = $this->getOption('disable_ssl_verification', $this->mailer);
		
		if(!empty( $ssl_verification )) {
			// Insecure SSL option enabled
			$phpmailer->SMTPOptions = array(
				'ssl' => array(
					'verify_peer'       => false,
					'verify_peer_name'  => false,
					'allow_self_signed' => true,
				),
			);
		}

		//set reasonable timeout
		$phpmailer->Timeout = 10;
		
		if($phpmailer->preSend()){
			try{
				if($phpmailer->postSend()){
					$response = [
						'status' => true,
						'code' => 200,
						'messageId' => '',
						'message' => 'Mail sent successfully',
					];
					return $this->handle_response($response);
				}
			}catch( \Exception $e ){
				return $this->handle_response(new \WP_Error(400,  $e->getMessage(), []));
			}
		}
		return $this->handle_response(new \WP_Error(400, 'Unable to send mail for some reason!', []));
	}
	
	public function load_field(){
		
		$fields = array(
			'smtp_host' => array(
				'title' => __('SMTP Host', 'gosmtp'),
				'type' => 'text',
				'place_holder' => 'smtp.example.com',
				'desc' => __( 'Your mail server', 'gosmtp' ),
			),
			'encryption' => array(
				'title' => __('Type of Encryption', 'gosmtp'),
				'type' => 'radio',
				'desc' => __( 'For most servers TLS is the recommended option. If your SMTP provider offers both SSL and TLS options, we recommend using TLS.', 'gosmtp' ),
				'list' => array(
					'none' => 'None',
					'ssl' => 'SSL',
					'tls' => 'TLS',	
				),
			),
			'smtp_port' => array(
				'title' => __('SMTP Port', 'gosmtp'),
				'type' => 'text',
				'place_holder' => '465',
				'desc' => __( 'The port to your mail server', 'gosmtp' ),
			),
			'smtp_auth' => array(
				'title' => __('SMTP Authentication', 'gosmtp'),
				'type' => 'radio',
				'desc' => __( 'This options should always be checked Yes', 'gosmtp' ),
				'list' => array(
					'No' => 'No',
					'Yes' => 'Yes',
				),
			),
			'smtp_username' => array(
				'title' => __('SMTP Username', 'gosmtp'),
				'type' => 'text',
				'place_holder' => 'admin',
				'tr_class' => 'smtp-authentication',
				'desc' => __( 'The username to login to your mail server', 'gosmtp'),
			),
			'smtp_password' => array(
				'title' => __('SMTP Password', 'gosmtp'),
				'type' => 'password',
				'place_holder' => 'Password',
				'tr_class' => 'smtp-authentication',
				'desc' => __( 'The SMTP Password to login to your mail server. The saved password is not shown for security reasons. You need enter it every time you update the settings.', 'gosmtp'),
			),
			'disable_ssl_verification' => array(
				'title' => __('Disable SSL Certificate Verification', 'gosmtp'),
				'type' => 'checkbox',
				'desc' => __( 'As of PHP 5.6 you will get a warning/error if the SSL certificate on the server is not properly configured. You can check this option to disable that default behaviour. Please note that PHP 5.6 made this change for a good reason. So you should get your host to fix the SSL configurations instead of bypassing it', 'gosmtp'),
			),
		);
		
		return $fields;
	}
}
PK��f\.ԃ�ttmailer/sendgrid.phpnu�[���<?php
/**
 * Class GOSMTP_Mailer_Sendgrid.
 *
 * @since 1.0.0
 */
 
namespace GOSMTP\Mailer;
 
use GOSMTP\Mailer\Loader;

class Sendgrid extends Loader{

	var $title = 'Sendgrid';
	var $mailer = 'sendgrid';
	var $url = 'https://api.sendgrid.com/v3/mail/send';

	public function send(){
		global $phpmailer;
		
		$phpmailer->isMail();
		
		if ($phpmailer->preSend() ) {
			$response = $this->postSend();
		 	return $this->handle_response( $response );
		}
		
		return $this->handle_response(new \WP_Error(400, 'Unable to send mail for some reason!', []));
	}

	public function postSend(){
		global $phpmailer;
						
		$body = [
			'from' => $this->getFrom(),
			'personalizations' => $this->getRecipients(),
			'subject' => $phpmailer->Subject,
			'content' => $this->getBody() 
		];
		
		if($replyTo = $this->filterRecipientsArray($phpmailer->getReplyToAddresses())){
			$body['ReplyTo'] = $replyTo;
		}

		if(!empty($this->getAttachments())){ 
			$body['Attachments'] = $this->getAttachments();
		}
		
		$params = [
			'body' => json_encode($body),
			'headers' => $this->getRequestHeaders()
		];

		$params = array_merge($params, $this->getDefaultParams());

		$response = wp_safe_remote_post($this->url, $params);

		if(is_wp_error($response)){
			$returnResponse = new \WP_Error($response->get_error_code(), $response->get_error_message(), $response->get_error_messages());
		}else{
			$responseBody = wp_remote_retrieve_body($response);
			$responseCode = wp_remote_retrieve_response_code($response);
			$responseBody = !empty($responseBody) ? \json_decode($responseBody, true) : '';
			$responseHeaders = wp_remote_retrieve_headers($response);
			$messageId = isset($responseHeaders['x-message-id']) ?  $responseHeaders['x-message-id'] : '';
			
			if($responseCode == 202) {

				$returnResponse = [
					'status' => true,
					'code' => 202,
					'messageId' => $messageId,
					'message' => __('Mail Sent successfully', 'gosmtp'),
				];
				
			}else{
				$error_text = [''];
				if(!empty( $responseBody['errors'] ) && is_array( $responseBody['errors'] )){
					foreach ( $responseBody['errors'] as $error ) {
						
						if(empty( $error['message'] )){
							continue;
						}
						
						$message = $error['message'];
						$code = ! empty( $error['field'] ) ? $error['field'] : '';
						$description = ! empty( $error['help'] ) ? $error['help'] : '';
						
						$error_text[] = $this->message_formatting( $message, $code, $description );
					}
				}else{
					$error_text[] = $this->get_response_error_message($response);
				}
			
				$error_msg = implode( '\r\n', array_map( 'esc_textarea', array_filter( $error_text ) ) );
				$returnResponse = new \WP_Error($responseCode, $error_msg, $responseBody);
			}
		}
		
		return $returnResponse;
	}

	protected function getRequestHeaders(){
		return array(
			'Content-Type' => 'application/json',
			'Authorization' => 'Bearer ' . $this->getOption('api_key', $this->mailer)
		);
	}

	protected function getFrom(){
		global $phpmailer;
		
		$from = [
			'email' => $phpmailer->From,
			'name' => $phpmailer->FromName
		];

		return $from;
	}

	protected function getAttachments(){
		global $phpmailer;
		
		$data = [];
		
		foreach ($phpmailer->getAttachments() as $attachment){
			$file = false;
			
			try{
				if (is_file($attachment[0]) && is_readable($attachment[0])) {
					$fileName = basename($attachment[0]);
					$contentId = wp_hash($attachment[0]);
					$file = file_get_contents($attachment[0]);
					$mimeType = mime_content_type($attachment[0]);
					$filetype = str_replace(';', '', trim($mimeType));
				}
			} catch (\Exception $e) {
				$file = false;
			}

			if ($file === false) {
				continue;
			}

			$data[] = [
				'type' => $filetype,
				'filename' => $fileName,
				'disposition' => 'attachment',
				'content_id'  => $contentId,
				'content' => base64_encode($file)
			];
		}

		return $data;
	}

	public function getRecipients(){
		global $phpmailer;
		
		$recipients = [
			'to' => $this->filterRecipientsArray($phpmailer->getToAddresses()),
			'cc' => $this->filterRecipientsArray($phpmailer->getCcAddresses()),
			'bcc' => $this->filterRecipientsArray($phpmailer->getBccAddresses()),
		];

		return array(array_filter($recipients));
	}
	
	protected function filterRecipientsArray($args){
		$recipients = [];
		foreach($args as $key => $recip){
			
			$recip = array_filter($recip);

			if(empty($recip) || ! filter_var( $recip[0], FILTER_VALIDATE_EMAIL ) ){
				continue;
			}

			$_recip = array(
				'email' => $recip[0]
			);

			if(!empty($recip[1])){
				$_recip['name'] = $recip[1];
			}
			
			$recipients[] = $_recip;
		}

		return $recipients;
	}
	
	protected function getBody(){
		global $phpmailer;
		
		$content = array(
			'value' => $phpmailer->Body,
			'type' => $phpmailer->ContentType
		);
		
		if($phpmailer->ContentType !== 'text/plain'){
			$content['type'] = 'text/html';
		}
		
		if(!empty($phpmailer->AltBody)){
			$content[] = [
				'value' => $phpmailer->AltBody,
				'type' => 'text/plain',
			];
		}

		return [$content];
	}

	public function load_field(){

		$fields = array(
			'api_key' => array(
				'title' => __('API Key', 'gosmtp'),
				'type' => 'password',
			),
		);
		
		return $fields;	
	}
}
PK��f\!Gkaamailer/sendinblue.phpnu�[���<?php
/**
 * Class GOSMTP_Mailer_Sendinblue.
 *
 * @since 1.0.0
 */
 
namespace GOSMTP\Mailer;
 
use GOSMTP\Mailer\Loader;

class Sendinblue extends Loader{

	var $title = 'Brevo';
	
	var $mailer = 'sendinblue';

	var $url = 'https://api.brevo.com/v3/smtp/email';
	
	
	private $allowed_exts = [ 'xlsx', 'xls', 'ods', 'docx', 'docm', 'doc', 'csv', 'pdf', 'txt', 'gif', 'jpg', 'jpeg', 'png', 'tif', 'tiff', 'rtf', 'bmp', 'cgm', 'css', 'shtml', 'html', 'htm', 'zip', 'xml', 'ppt', 'pptx', 'tar', 'ez', 'ics', 'mobi', 'msg', 'pub', 'eps', 'odt', 'mp3', 'm4a', 'm4v', 'wma', 'ogg', 'flac', 'wav', 'aif', 'aifc', 'aiff', 'mp4', 'mov', 'avi', 'mkv', 'mpeg', 'mpg', 'wmv'];

	public function send(){
		global $phpmailer;

		$phpmailer->isMail();

		if($phpmailer->preSend()){
			$response = $this->postSend();
		 	return $this->handle_response( $response );
		}
		
		return $this->handle_response(new \WP_Error(400, 'Unable to send mail for some reason!', []));
	}

	public function postSend(){
		global $phpmailer;

		$sender = [
			'name' => $phpmailer->FromName,
			'email' => $phpmailer->From
		];

		$body = [
			'sender' => $sender,
			'subject' => $phpmailer->Subject,
			'to' => $this->filterRecipientsArray($phpmailer->getToAddresses()),
			'cc' => $this->filterRecipientsArray($phpmailer->getCcAddresses()),
			'bcc' => $this->filterRecipientsArray($phpmailer->getBccAddresses())
		];
		
		$body = array_filter($body);
			
		$content = $phpmailer->Body;
		
		if(!empty($content)){
			if( is_array( $content ) ){

				if(!empty( $content['text'])){
					$body['textContent'] = $content['text'];
				}

				if(!empty( $content['html'])){
					$body['htmlContent'] = $content['html'];
				}
			}else{
				if($phpmailer->ContentType === 'text/plain' ){
					$body['textContent'] = $content;
				}else{
					$body['htmlContent'] = $content;
				}
			}
		}

		$body = $this->set_replyto( $phpmailer->getReplyToAddresses(), $body );

		$attachments = $phpmailer->getAttachments();
		
		if(!empty($attachments)){
			$body['attachment'] = $this->getAttachments($attachments);
		}

		$timeout = (int) ini_get( 'max_execution_time' );

		$api_key = $this->getOption('api_key', $this->mailer);

		$headers = [ 'Api-Key' => $api_key,
			'Content-Type' => 'application/json',
			'Accept' => 'application/json'
		];

		$params = array(
			'headers' => $headers,
			'body' => json_encode($body),
			'timeout' => $timeout ? $timeout : 30
		);

		$response = wp_safe_remote_post($this->url, $params);

		if(is_wp_error($response)){
			$returnResponse = new \WP_Error($response->get_error_code(), $response->get_error_message(), $response->get_error_messages());
		}else{
			$responseBody = wp_remote_retrieve_body($response);
			$responseCode = wp_remote_retrieve_response_code($response);
			$responseBody = \json_decode($responseBody, true);
			
			// TODO: check the responseCode is 200 is correct
			if($responseCode == 201){
				$returnResponse = [
					'status' => true,
					'code' => $responseCode,
					'messageId' => $responseBody['messageId'],
					'message' => __('Mail Sent successfully', 'gosmtp'),

				];
				
			}else{
				$error_text = [''];
				if(!empty( $responseBody['message'])){
					$error_text[] = $this->message_formatting( $responseBody['message'] );
				}else{
					$error_text[] = $this->get_response_error_message($response);
				}
				
				$error_msg = implode( '\r\n', array_map( 'esc_textarea', array_filter( $error_text ) ) );
				$returnResponse = new \WP_Error($responseCode, $error_msg, $responseBody);
			}
		}
		
		return $returnResponse;
	}

	public function set_replyto( $emails,  $body) {
		
		$data = $this->filterRecipientsArray( $emails );
		
		if(!empty( $data )){
			$body['replyTo'] = $data[0];
		}
		
		return $body;
	}
	
	protected function filterRecipientsArray($args){
		$recipients = [];
		foreach($args as $key => $recip){
			
			$recip = array_filter($recip);

			if(empty($recip) || ! filter_var( $recip[0], FILTER_VALIDATE_EMAIL ) ){
				continue;
			}

			$_recip = array(
				'email' => $recip[0]
			);

			if(!empty($recip[1])){
				$_recip['name'] = $recip[1];
			}
			
			$recipients[] = $_recip;
		}

		return $recipients;
	}

	public function getAttachments($attachments = []){
		$files = [];

		foreach($attachments as $attachment){
			if(is_file($attachment[0]) && is_readable($attachment[0])){
				$ext = pathinfo($attachment[0], PATHINFO_EXTENSION);

				if(in_array($ext, $this->allowed_exts, true)){
					$files[] = [
						'name' => basename($attachment[0]),
						'content' => base64_encode(file_get_contents($attachment[0]))
					];
				}
			}
		}

		return $files;
	}
	
	public function load_field(){

		$fields = array(
			'api_key' => array(
				'title' => __('API Key', 'gosmtp'),
				'type' => 'password',
				'desc' => __( 'Follow this link to get an API Key: <a href="https://app.brevo.com/settings/keys/api" target="_blank">Get v3 API Key.</a>', 'gosmtp' ),
			)
		);
		
		return $fields;
	}
}

PK��f\��+��mailer/maileroo.phpnu�[���<?php
/**
 * Class GOSMTP_Mailer_Maileroo.
 *
 * @since 1.1.5
 */

namespace GOSMTP\Mailer;

use GOSMTP\Mailer\Loader;

class Maileroo extends Loader{

	var $title = 'Maileroo';
	var $mailer = 'maileroo';
	var $url = 'https://smtp.maileroo.com/api/v2/emails';

	public function send(){
		global $phpmailer;

		if($phpmailer->preSend()){
			$response = $this->postSend();
			return $this->handle_response($response);
		}

		return $this->handle_response(new \WP_Error(400, 'Unable to send mail for some reason!', []));
	}

	protected function postSend(){
		global $phpmailer;

		try{
			$api_key = $this->getOption('api_key', $this->mailer);

			if(empty($api_key)){
				return new \WP_Error(401, 'Maileroo Sending Key is missing');
			}

			// Maileroo requires subject to be passed
			$subject = $phpmailer->Subject;
			if(empty($subject)){
				$subject = 'Mail sent from: '. site_url();
			}

			//Prepare Maileroo v2 API JSON Payload
			$payload = [
				'from' => [
					'address' => $phpmailer->From,
					'display_name' => $phpmailer->FromName,
				],
				'to' => [],
				'subject' => $subject,
				'text' => '',
				'html' => '',
				'attachments' => $this->getAttachments(),
			];

			foreach($this->filterRecipientsArray($phpmailer->getToAddresses()) as $to){
				$payload['to'][] = ['address' => $to];
			}

			foreach($this->filterRecipientsArray($phpmailer->getCcAddresses()) as $cc){
				$payload['cc'][] = ['address' => $cc];
			}

			foreach($this->filterRecipientsArray($phpmailer->getBccAddresses()) as $bcc){
				$payload['bcc'][] = ['address' => $bcc];
			}

			foreach($this->filterRecipientsArray($phpmailer->getReplyToAddresses()) as $replyTo){
				$payload['reply_to'][] = ['address' => $replyTo];
			}
    
			if(!empty($phpmailer->AltBody)){
				$payload['text'] = $phpmailer->AltBody;
			}

			if(!empty($phpmailer->Body)){
				$payload['html'] = $phpmailer->Body;
			}

			$params = [
				'method'  => 'POST',
				'headers' => $this->getRequestHeaders(),
				'body' => wp_json_encode($payload)
			];

			$response = wp_safe_remote_request($this->url, $params);

			if(is_wp_error($response)){
				return new \WP_Error($response->get_error_code(), $response->get_error_message(), $response->get_error_messages());
			}

			$resp_body = wp_remote_retrieve_body($response);
			$resp_code = wp_remote_retrieve_response_code($response);
			$resp_body = \json_decode($resp_body, true);

			if(200 === $resp_code){
				$msgId = isset($resp_body['data']['reference_id']) ? $resp_body['data']['reference_id'] : '';
				$status = 'Email sent successfully';
				$return_response = [
					'status' => true,
					'code' => $resp_code,
					'messageId' => $msgId,
					'message' => $status
				];
			} else{
				$err_code = $resp_code;
				$error_text = [''];

				if(!empty($resp_body['Error']) && is_array($resp_body['Error'])){
					$message = $resp_body['Error'];
					$code = isset($resp_body['Code']) ? $resp_body['Code'] : '';

					$error_text[] = $this->message_formatting($message, $code);
				} else{
					$error_text[] = $this->get_response_error_message($response);
				}

				$error_msg = implode('\r\n', array_map('esc_textarea', array_filter($error_text)));
				$return_response = new \WP_Error($err_code, $error_msg, $resp_body);
			}
		} catch(\Exception $e){
			return new \WP_Error(423, $e->getMessage(), []);
		}

		return $return_response;
	}

	protected function getRequestHeaders(){
		return [
			'X-Api-Key' => $this->getOption('api_key', $this->mailer),
			'Content-Type'  => 'application/json',
			'Accept' => 'application/json'
		];
	}

	protected function getAttachments(){
		global $phpmailer;

		$attachments_raw = $phpmailer->getAttachments();
		$attachments = [];

		if(!empty($attachments_raw)){
			// Handles multiple filenames
			foreach($attachments_raw as $attachment){
				$file_path = $attachment[0];
				if(file_exists($file_path) && is_file($file_path) && is_readable($file_path)){
					$file_content = file_get_contents($file_path);
					if(empty($file_content)){
						continue;
					}

					$attachments[] = [
						'file_name' => basename($file_path),
						'content_type' => $this->determineMimeContentType($file_path),
						'content' => base64_encode($file_content)
					];
				}
			}
		}

		return $attachments;
	}
	
	protected function filterRecipientsArray($args){
		$recipients = [];
		foreach($args as $key => $recip){
			
			$recip = array_filter($recip);

			if(empty($recip) || ! filter_var($recip[0], FILTER_VALIDATE_EMAIL)){
				continue;
			}
			
			$recipients[] = $recip[0];
		}

		return $recipients;
	}

	protected function determineMimeContentType($filename){

		if(function_exists('mime_content_type')){
			return mime_content_type($filename);
		} elseif(function_exists('finfo_open')){
			$finfo = finfo_open(FILEINFO_MIME_TYPE);
			$mime_type = finfo_file($finfo, $filename);
			finfo_close($finfo);
			return $mime_type;
		}

		return 'application/octet-stream';
	}

	public function load_field(){
		$options = $this->getMailerOption();

		$fields = [
			'api_key' => [
				'title' => __('Sending Key', 'gosmtp'),
				'type' => 'password',
				'desc' => sprintf(__('Follow this link to get a Sending Key from Maileroo: %1$sGet Sending Key%2$s%3$s
						Special Offer: Get 7,000 emails/month for first 4 months! %4$sClaim Offer%5$s', 'gosmtp'),
						'<a href="https://app.maileroo.com/domains/" target="_blank">', '</a>', '<br>', '<a href="https://maileroo.com/?r=gosmtp" target="_blank">', '</a>'
					),
			]
		];

		return $fields;
	}
}PK��f\�(�|MMmailer/mailgun.phpnu�[���<?php
/**
 * Class GOSMTP_Mailer_Mailgun.
 *
 * @since 1.0.0
 */

namespace GOSMTP\Mailer;
 
use GOSMTP\Mailer\Loader;

class Mailgun extends Loader{

	var $title = 'Mailgun';
	
	const API_URL_US = 'https://api.mailgun.net/v3/';
	
	const API_URL_EU = 'https://api.eu.mailgun.net/v3/';
	
	var $url = '';
	
	var $mailer = 'mailgun';
	
	public function send(){
		global $phpmailer;
		
		$phpmailer->isMail();
		
		if ($phpmailer->preSend()) {
			$this->set_API_Url();
			$response = $this->postSend();
			return $this->handle_response( $response );
		}

		return $this->handle_response(new \WP_Error(400, 'Unable to send mail for some reason!', []));
	}
	
	public function postSend(){
		global $phpmailer;
		
		$content_type = $phpmailer->ContentType;
		$reply_to = $phpmailer->getReplyToAddresses();
		
		$body = [
			'from'           => $phpmailer->From,
			'subject'        => $phpmailer->Subject,
			'h:X-Mailer'     => 'GOSMTPMailer - Mailgun',
			'h:Content-Type' => $content_type
		];
		
		if(stripos($content_type, 'html') === false){
			$body['text'] = $phpmailer->Body;
		}else{
			$body['html'] = $phpmailer->Body;
		}

		if(!empty($reply_to)){
			$body['h:Reply-To'] = $reply_to;
		}
			
		$recipients = [
			'to'  => $this->getRecipients($phpmailer->getToAddresses()),
			'cc'  => $this->getRecipients($phpmailer->getCcAddresses()),
			'bcc' => $this->getRecipients($phpmailer->getBccAddresses())
		];

		if ($recipients = array_filter($recipients)) {
			$body = array_merge($body, $recipients);
		}
		
		$timeout = (int) ini_get( 'max_execution_time' );

		$params = array(
				'headers' => array(
					'Authorization' => 'Basic ' . base64_encode('api:' . $this->getOption('api_key', $this->mailer))
				),
				'body' => $body,
				'timeout' => $timeout ? $timeout : 30,
				'httpversion' => '1.1',
				'blocking'    => true
		);

		$attachments = $phpmailer->getAttachments();
		
		if(!empty($attachments)){
			$params = $this->getAttachments($params);
		}

		$response = wp_safe_remote_post($this->url, $params);

		if (is_wp_error($response)) {
			$returnResponse = new \WP_Error($response->get_error_code(), $response->get_error_message(), $response->get_error_messages());
		} else {
			$responseBody = wp_remote_retrieve_body($response);
			$responseCode = wp_remote_retrieve_response_code($response);

			$isOKCode = $responseCode == 200;

			if($isOKCode) {
				$responseBody = \json_decode($responseBody, true);
			}

			if($isOKCode && isset($responseBody['id'])) {
				$returnResponse = [
					'status' => true,
					'code' => $responseCode,
					'messageId' => $responseBody['id'],
					'message' => $responseBody['message'],
				];
			}else{
				if(!empty( $responseBody['message'])){
					$error_text[] = $this->message_formatting( $responseBody['message'] );
				} else {
					$error_text[] = $this->get_response_error_message($response);
				}
				
				$error_msg = implode( '\r\n', array_map( 'esc_textarea', array_filter( $error_text ) ) );
				$returnResponse = new \WP_Error($responseCode, $error_msg, $responseBody);
			}
		}

		return $returnResponse;
	}

	public function getRecipients($recipient){
		$recipients = $this->filterRecipientsArray($recipient);
		
		$array = array_map(function($recipient){
			return isset($recipient['name'])
			? $recipient['name'] . ' <' . $recipient['address'] . '>'
			: $recipient['address'];
		}, $recipients);

		return implode(', ', $array);
	}
	
	public function getAttachments($params){
		global $phpmailer;
		
		$data = [];
		$payload = '';
		$attachments = $phpmailer->getAttachments();

		foreach($attachments as $attachment){
			$file = false;

			try{
				if (is_file($attachment[0]) && is_readable($attachment[0])) {
					$fileName = basename($attachment[0]);
					$file = file_get_contents($attachment[0]);
				}
			}catch(\Exception $e){
				$file = false;
			}

			if($file === false){
				continue;
			}

			$data[] = [
				'content' => $file,
				'name'    => $fileName,
			];
		}

		if(!empty($data)){
			$boundary = hash('sha256', uniqid('', true));

			foreach($params['body'] as $key => $value){
				if(is_array($value)){
					foreach($value as $child_key => $child_value){
						$payload .= '--' . $boundary;
						$payload .= "\r\n";
						$payload .= 'Content-Disposition: form-data; name="' . $key . "\"\r\n\r\n";
						$payload .= $child_value;
						$payload .= "\r\n";
					}
				}else{
					$payload .= '--' . $boundary;
					$payload .= "\r\n";
					$payload .= 'Content-Disposition: form-data; name="' . $key . '"' . "\r\n\r\n";
					$payload .= $value;
					$payload .= "\r\n";
				}
			}

			foreach($data as $key => $attachment){
				$payload .= '--' . $boundary;
				$payload .= "\r\n";
				$payload .= 'Content-Disposition: form-data; name="attachment[' . $key . ']"; filename="' . $attachment['name'] . '"' . "\r\n\r\n";
				$payload .= $attachment['content'];
				$payload .= "\r\n";
			}

			$payload .= '--' . $boundary . '--';

			$params['body'] = $payload;
			$params['headers']['Content-Type'] = 'multipart/form-data; boundary=' . $boundary;

		}

		return $params;
	}
	
	public function set_API_Url(){
		
		$url = self::API_URL_US;
		
		if($this->getOption('region', $this->mailer) == 'eu'){
			$url = self::API_URL_EU;
		}

		$url .= sanitize_text_field($this->getOption('domain_name', $this->mailer) . '/messages');

		return $this->url = $url;
	}

	public function load_field(){
		
		$fields = array(
			'api_key' => array(
				'title' => __('Private API Key', 'gosmtp'),
				'type' => 'password',
				'desc' => __( 'Follow this link to get a Private API Key from Mailgun: <a href="https://app.mailgun.com/app/account/security/api_keys" target="_blank">Get a Private API Key.</a>', 'gosmtp' ),
			),
			'domain_name' => array(
				'title' => __('Domain Name', 'gosmtp'),
				'type' => 'text',
				'desc' => __( 'Follow this link to get a Domain Name from Mailgun: <a href="https://app.mailgun.com/app/domains" target="_blank">Get a Domain Name.</a>', 'gosmtp' ),
			),
			'region' => array(
				'title' => __('Region', 'gosmtp'),
				'type' => 'radio',
				'class' => 'regular-text',
				'list' => array(
					'us' => 'US',
					'eu' => 'EU',
				),
				'desc' => __( 'Define which endpoint you want to use for sending messages.<br>If you are operating under EU laws, you may be required to use EU region. <a href="https://www.mailgun.com/about/regions/" target="_blank">More information</a> on Mailgun.com.', 'gosmtp' ),
			),
		);
		
		return $fields;
	}
}


PK��f\[�N�::mailer/postmark.phpnu�[���<?php
/**
 * Class GOSMTP_Mailer_Postmark.
 *
 * @since 1.0.0
 */
 
namespace GOSMTP\Mailer;
 
use GOSMTP\Mailer\Loader;

class Postmark extends Loader{

	var $title = 'Postmark';
	var $mailer = 'postmark';
	var $url = 'https://api.postmarkapp.com/email';

	public function send(){
		global $phpmailer;

		$phpmailer->isMail();

		if ($phpmailer->preSend()) {
			$return_response = $this->postSend();
			return $this->handle_response( $return_response );
		}

		return $this->handle_response(new \WP_Error(400, 'Unable to send mail for some reason!', []));
	}

	public function postSend(){
		global $phpmailer;

		$body = array(
			'From' => $phpmailer->From,
			'To' => $this->getRecipients($phpmailer->getToAddresses()),
			'Subject' => $phpmailer->Subject,
		);
		
		$message_id = $this->getOption('message_stream_id', $this->mailer);
		
		if(!empty($message_id)){
			$body['MessageStream'] = $message_id;
		}
		
		if($replyTo = $this->getRecipients($phpmailer->getReplyToAddresses())){
			$body['ReplyTo'] = $replyTo;
		}

		if($bcc = $this->getRecipients($phpmailer->getBccAddresses())){
			$body['Bcc'] = $bcc;
		}

		if($cc = $this->getRecipients($phpmailer->getCcAddresses())){
			$body['Cc'] = $cc;
		}

		if($phpmailer->ContentType == 'text/plain'){
			$body['TextBody'] = $phpmailer->Body;
		} else {
			$body['HtmlBody'] = $phpmailer->Body;

			// TODO: create stting and if is true then set this to true
			$body['TrackOpens'] = true;

			// TODO: create stting and if is true then set this to HtmlOnly
			$body['TrackLinks'] = 'HtmlOnly';
		}

		if(!empty($phpmailer->AltBody)){
			$body['TextBody'] = $phpmailer->AltBody;
		}

		if(!empty($phpmailer->getAttachments())){
			$body['Attachments'] = $this->getAttachments();
		}

		// Handle apostrophes in email address From names by escaping them for the Postmark API.
		$from_regex = "/(\"From\": \"[a-zA-Z\\d]+)*[\\\\]{2,}'/";

		$args = array(
			'headers' => $this->getRequestHeaders(),
			'body' => preg_replace($from_regex, "'", wp_json_encode($body), 1),
		);

		$response = wp_remote_post($this->url, $args);

		if(is_wp_error($response)){
			$return_response = new \WP_Error($response->get_error_code(), $response->get_error_message(), $response->get_error_messages());
		}else{
			$responseBody = wp_remote_retrieve_body($response);
			$responseCode = wp_remote_retrieve_response_code($response);

			$responseBody = \json_decode($responseBody, true);

			if($responseCode == 200){
				$return_response = [
					'status' => true,
					'code' => $responseCode,
					'id' => $responseBody['MessageID'],
					'message' => $responseBody['Message'],
				];
			}else{
				$error_text = [''];
				if(!empty( $responseBody['Message'])){
					$message = $responseBody['Message'];
					$code = ! empty( $responseBody['ErrorCode'] ) ? $responseBody['ErrorCode'] : '';
					
					$error_text[] = $this->message_formatting( $message, $code );
				}else{
					$error_text[] = $this->get_response_error_message($response);
				}
				
				$error_msg = implode( '\r\n', array_map( 'esc_textarea', array_filter( $error_text ) ) );
				$return_response = new \WP_Error($responseCode, $error_msg, $responseBody);
			}
		}

		return $return_response ;
	}

	public function getRecipients($recipient){
		$recipients = $this->filterRecipientsArray($recipient);

		$array = array_map(function($recipient){
			return isset($recipient['name'])
			? $recipient['name'] . ' <' . $recipient['address'] . '>'
			: $recipient['address'];
			},
			$recipients
		);

		return implode(', ', $array);
	}

	function getRequestHeaders(){
		return array(
			'Accept' => 'application/json',
			'Content-Type' => 'application/json',
			'X-Postmark-Server-Token' => $this->getOption('server_api_token', $this->mailer),
		);
	}

	protected function getAttachments(){
		global $phpmailer;

		$data = [];
		$attachments = $phpmailer->getAttachments();

		foreach($attachments as $attachment){
			$file = false;

			try{
				if(is_file($attachment[0]) && is_readable($attachment[0])){
					$fileName = basename($attachment[0]);
					$file = file_get_contents($attachment[0]);
				}
			}catch(\Exception $e){
				$file = false;
			}

			if($file === false){
				continue;
			}

			$data[] = array(
				'Name'        => $fileName,
				'Content'     => base64_encode($file),
				'ContentType' => $this->determineMimeContentRype($attachment[0])
			);
		}

		return $data;
	}

	protected function determineMimeContentRype($filename){

		if(function_exists('mime_content_type')){
			return mime_content_type($filename);
		}elseif(function_exists('finfo_open')){
			$finfo = finfo_open(FILEINFO_MIME_TYPE);
			$mime_type = finfo_file($finfo, $filename);
			finfo_close($finfo);
			return $mime_type;
		}

		return 'application/octet-stream';
	}

	public function load_field(){

		$fields = array(
			'server_api_token' => array(
				'title' => __('Server API Token', 'gosmtp'),
				'type' => 'password',
				'desc' => __( 'Follow this link to get a Server API Token from Postmark: <a href="https://account.postmarkapp.com/login" target="_blank">Get Server API Token.</a>', 'gosmtp' ),
			),
			'message_stream_id' => array(
				'title' => __('Message Stream ID', 'gosmtp'),
				'type' => 'text',
				'desc' => __( 'Follow this link to get a Server API Token from Postmark: <a href="https://account.postmarkapp.com/login" target="_blank">Get Server API Token.</a>', 'gosmtp' ),
			),
		);
		
		return $fields;
	}
}PK��f\ '�<ppmailer/sendlayer.phpnu�[���<?php
/**
 * Class GOSMTP_Mailer_Sendlayer
 *
 * @since 1.0.0
 */
 
namespace GOSMTP\Mailer;
 
use GOSMTP\Mailer\Loader;

class Sendlayer extends Loader{
	
	var $title = 'Sendlayer';
	var $mailer = 'sendlayer';
	var $url = 'https://console.sendlayer.com/api/v1/email';

	public function send(){
		global $phpmailer;
		
		$phpmailer->isMail();
		
		if ($phpmailer->preSend()) {
			$response = $this->postSend();
		 	return $this->handle_response( $response );
		}
		
		return $this->handle_response(new \WP_Error(400, 'Unable to send mail for some reason!', []));
	}

	public function postSend(){		
		global $phpmailer;
		
		$sender = array(
			'name' => $phpmailer->FromName,
			'email' => $phpmailer->From
		);

		$body = array(
			'From' => $sender,
			'subject' => $phpmailer->Subject,
			'to' => $this->filterRecipientsArray($phpmailer->getToAddresses()),
			'cc' => $this->filterRecipientsArray($phpmailer->getCcAddresses()),
			'bcc' => $this->filterRecipientsArray($phpmailer->getBccAddresses())
		);
		
		$body['ReplyTo'] = $this->filterRecipientsArray($phpmailer->getReplyToAddresses());
		
		// Remove empty array values
		$body = array_filter($body);
		
		$content = $phpmailer->Body;
		
		if(!empty($content)){
			if( is_array( $content ) ){
				if( ! empty( $content['text'] ) ){
					$body['ContentType'] = 'plain';
					$body['PlainContent'] = $content['text'];
				}

				if( ! empty( $content['html'] ) ){
					$body['ContentType'] = 'html';
					$body['HTMLContent'] = $content['html'];
				}
			}else{
				if( $phpmailer->ContentType === 'text/plain' ){
					$body['ContentType'] = 'plain';
					$body['PlainContent'] = $content;
				}else{
					$body['ContentType'] = 'html';
					$body['HTMLContent'] = $content;
				}
			}
		}

		$attachments = $phpmailer->getAttachments();
		
		if(!empty($attachments)){
			$body['attachment'] = $this->getAttachments($attachments);
		}

		$custom_headers = $phpmailer->getCustomHeaders();
		
		$body['Headers'] = array_merge($custom_headers, ['X-Mailer' => 'GOSMTPMailer - Sendlayer']);

		$timeout = (int) ini_get( 'max_execution_time' );

		$api_key = $this->getOption('api_key', $this->mailer);

		$headers = array(
			'Authorization' => 'Bearer ' .$api_key,
			'Content-Type' => 'application/json',
			'Accept' => 'application/json'
		);

		$params = array(
			'headers' => $headers,
			'body' => wp_json_encode($body),
			'timeout' => $timeout ? $timeout : 30
		);

		// print_r(json_encode($body, JSON_PRETTY_PRINT));

		$response = wp_safe_remote_post($this->url, $params);

		if(is_wp_error($response)){
			$returnResponse = new \WP_Error($response->get_error_code(), $response->get_error_message(), $response->get_error_messages());
		}else{
			$responseBody = wp_remote_retrieve_body($response);
			$responseCode = wp_remote_retrieve_response_code($response);
			$responseBody = \json_decode($responseBody, true);
			
			if($responseCode == 200){
				$returnResponse = [
					'status' => true,
					'code' => 200,
					'messageId' => $responseBody['id'],
					'message' => $responseBody['message'], 
				];
				
			}else{
				
				$error_text = [''];
				if(!empty($responseBody['Errors']) ){
					foreach ( $responseBody['Errors'] as $error ) {
    					
						if(empty( $error['Message'] )) {
							continue;
						}
						
						$message = $error['Message'];
						$code = !empty($error['Code']) ? $error['Code'] : '';
						
						$error_text[] = $this->message_formatting( $message, $code );
					}
				}else{
					$error_text[] = $this->get_response_error_message($response);
				}
				
				$error_msg = implode( '\r\n', array_map( 'esc_textarea', array_filter( $error_text ) ) );
				$returnResponse = new \WP_Error($responseCode, $error_msg, $responseBody);
			}
		}
		
		return $returnResponse;
	}

	protected function filterRecipientsArray($args){
		$recipients = [];
		foreach($args as $key => $recip){
			
			$recip = array_filter($recip);

			if(empty($recip) || ! filter_var( $recip[0], FILTER_VALIDATE_EMAIL ) ){
				continue;
			}

			$_recip = array(
				'email' => $recip[0]
			);

			if(!empty($recip[1])){
				$_recip['name'] = $recip[1];
			}
			
			$recipients[] = $_recip;
		}

		return $recipients;
	}
	
	private function getAttachments( $attachments ) {

		$data = [];

		foreach( $attachments as $attachment ){
			
			$file = false;

			try{
				if( $attachment[5] === true ){
					$file = $attachment[0];
				}elseif( is_file( $attachment[0] ) && is_readable( $attachment[0] ) ){
					$file = file_get_contents( $attachment[0] );
				}
			}catch( \Exception $e ){ 
				$file = false;
			}
			
			if(false === $file){
				continue;
			}

			$filetype = str_replace( ';', '', trim( $attachment[4] ) );

			$data[] = array(
				'Filename' => empty( $attachment[2] ) ? 'file-' . wp_hash( microtime() ) . '.' . $filetype : trim( $attachment[2] ),
				'Content' => base64_encode( $content ),
				'Type' => $attachment[4],
				'Disposition' => in_array( $attachment[6], [ 'inline', 'attachment' ], true ) ? $attachment[6] : 'attachment',
				'ContentId' => empty( $attachment[7] ) ? '' : trim( (string) $attachment[7] ),
			);
		}

		return $data;
	}
	
	public function load_field(){
		
		$fields = array(
			'api_key' => array(
				'title' => __('API Key', 'gosmtp'),
				'type' => 'password',
				'desc' => __( 'Follow this link to get an API Key from SendLayer: <a href="https://app.sendlayer.com/settings/api/" target="_blank">Get API Key.</a>', 'gosmtp' ),
			),

		);
		
		return $fields;
	}
}PK��f\%����2�2mailer/loader.phpnu�[���<?php

namespace GOSMTP\Mailer;

class Loader{
	
	var $options;
	var $mailer = '';
	var $url = '';
	var $conn_id = 0;
	var $parent_log = 0;
	var $last_log = 0;
	var $headers = array();
	
	public function __construct(){
		
		// Load options
		$this->loadOptions();
		
	}
	
	public function loadOptions(){
		$options = get_option('gosmtp_options', array());
		
		$this->options = $options;
	}
	
	public function getMailerOption(){
		
		$mailer = $this->mailer;
		
		if(empty($mailer) || !isset($this->options['mailer'][$this->conn_id])){
			return array();
		}
		
		return $this->options['mailer'][$this->conn_id];
	}
	
	public function getActiveMailer(){
		
		if(!isset($this->options['mailer'][$this->conn_id]) || !isset($this->options['mailer'][$this->conn_id]['mail_type'])){
			return 'mail';
		}
		
		return $this->options['mailer'][$this->conn_id]['mail_type'];
	}
	
	public function getOption($key, $mailer = '', $default = ''){
		
		$options = $this->options;
		
		if(!empty($mailer) && $mailer == $this->getActiveMailer()){
			$options = $this->options['mailer'][$this->conn_id];
		}
		
		if(isset($options[$key])){
			return $options[$key];
		}
		
		return $default;	
	}
	
	public function save_options($options){
		
		if(!method_exists($this, 'load_field')){
			return $options;
		}
		
		$fields = $this->load_field();
		
		foreach($fields as $key => $field){
			
			$val = '';
			
			if(!empty($_REQUEST[$this->mailer]) && isset($_REQUEST[$this->mailer][$key])){
				$val = sanitize_text_field($_REQUEST[$this->mailer][$key]);
			}
			
			$options[$key] = $val;
		}

		$conn_id = isset($_REQUEST['conn_id']) ? sanitize_text_field(wp_unslash($_REQUEST['conn_id'])) : '';

		$saved_options = get_option('gosmtp_options', []);
		
		// Mailer and connection id should not be empty
		if(empty($saved_options['mailer']) || empty($saved_options['mailer'][$conn_id])){
			return $options; 
		}

		$mailer_data = $saved_options['mailer'][$conn_id];
		$mailer_type = !empty($mailer_data['mail_type']) ? $mailer_data['mail_type'] : '';
		
		// Client id and Client secret only present in Outlook, Gmail and Zoho mailer
		if(!in_array($mailer_type, ['outlook', 'gmail', 'zoho'])){
			return $options;
		}
		
		$credential_keys = ['client_id', 'client_secret'];
		$cred_change = false;
		
		// Map seperate keys for each mailer
		$map = [
			'outlook' => ['auth_token', 'access_token', 'refresh_token', 'expire_stamp'],
			'gmail' => ['auth_token', 'access_token', 'refresh_token', 'expire_stamp', 'expires_in', 'version'],
			'zoho' => ['authorize', 'access_token', 'refresh_token', 'account_id']
		];

		$token_keys = isset($map[$mailer_type]) ? $map[$mailer_type] : [];

		foreach($credential_keys as $key){
			$new_val = isset($options[$key]) ? trim((string) $options[$key]) : '';
			$old_val = isset($mailer_data[$key]) ? trim((string) $mailer_data[$key]) : '';
			
			// Check if Client Id or Client Secret is changed
			if($new_val !== $old_val){
				$cred_change = true;
				break;
			}
		}
		
		// If credentials are not changed add the previous tokens
		if(!$cred_change){
			foreach($token_keys as $token){
				if(isset($mailer_data[$token])){
					$options[$token] = $mailer_data[$token];
				}
			}
		}
		
		return $options;
	}
	
	public function delete_option($key, $mailer = ''){

		if(!empty($mailer) && isset($this->options['mailer'][$this->conn_id][$key])){
			unset($this->options['mailer'][$this->conn_id][$key]);
		}elseif(isset($this->options[$key])){
			unset($this->options[$key]);
		}

		update_option( 'gosmtp_options', $this->options );
	}
	
	public function update_option($key, $val, $mailer=''){
		
		if(!empty($mailer)){
			
			if(!is_array($this->options['mailer'][$this->conn_id])){
				$this->options['mailer'][$this->conn_id] = array();
			}
			
			$this->options['mailer'][$this->conn_id][$key] = $val;
			
		}else{
			$this->options[$key] = $val;
		}
		
		update_option( 'gosmtp_options', $this->options);
	}
	
	protected function filterRecipientsArray($args){
		$recipients = [];

		foreach($args as $key => $recip){
			
			$recip = array_filter($recip);

			if(empty($recip) || ! filter_var( $recip[0], FILTER_VALIDATE_EMAIL ) ){
				continue;
			}

			$recipients[$key] = array(
				'address' => $recip[0]
			);

			if(!empty($recip[1])){
				$recipients[$key]['name'] = $recip[1];
			}
		}

		return $recipients;
	}

	public function setHeaders($headers){

		foreach($headers as $header){
			$name = isset($header[0]) ? $header[0] : false;
			$value = isset($header[1]) ? $header[1] : false;

			if(empty($name) || empty($value)){
				continue;
			}

			$this->setHeader($name, $val);
		}
		
	}

	public function setHeader($name, $val){
		
		$name = sanitize_text_field($name);
		
		$this->headers[$name] = WP::sanitize_value($val);
		
	}

	protected function getDefaultParams(){
		$timeout = (int)ini_get('max_execution_time');

		return [
			'timeout'     => $timeout ?: 30,
			'httpversion' => '1.1',
			'blocking'    => true,
		];
	}

	public function set_from(){
		global $phpmailer, $gosmtp;
		
		$conn_id = $gosmtp->mailer->conn_id;
		
		$from_email = $phpmailer->From;
		$from_name = $phpmailer->FromName;
		
		// Check for force set
		if($conn_id === 0){
			$options = $this->options;
		}else{
			$options = $this->options['mailer'][$conn_id];
		}	
		
		if(!empty($options['force_from_email']) && !empty($options['from_email'])){
			$from_email = $options['from_email'];
		}
		
		if(!empty($options['force_from_name']) && !empty($options['from_name'])){
			$from_name = $options['from_name'];
		}
		
		try {
			$phpmailer->setFrom($from_email, $from_name, false);
		}catch( PHPMailer\PHPMailer\Exception $e ) {
			throw new WP_Error( 'wp_mail_failed', $e->getMessage());
		}
		
	}

	public function get_from($from = ''){
		global $phpmailer, $gosmtp;
		
		$conn_id = $gosmtp->mailer->conn_id;
		
		// Check for force set
		if($conn_id === 0){
			$options = $this->options;
		}else{
			$options = $this->options['mailer'][$conn_id];
		}	
		
		if(!empty($options['force_from_email']) && !empty($options['from_email'])){
			$from = $options['from_email'];
		}
		
		return $from;
	}
	
	public function handle_response($response){
		
		$status = false;
		$message = array();

		if(is_wp_error($response)){

			$code = $response->get_error_code();

			if(!is_numeric($code)) {
				$code = 400;
			}

			$msg = $response->get_error_message();

			$message = array(
				'code'    => $code,
				'message' => $msg
			);
			
			$this->process_response($message, $status);
			
			throw new \PHPMailer\PHPMailer\Exception($msg, $code);
			
			return;
			
		}elseif($response['status'] == true){
			
			unset($response['status']);
			
			$message = $response;
			$status = true;
		
		}else{
			$message = array(
				'code'    => $code,
				'message' => __('Unable to send mail, Please check your SMTP details', 'gosmtp')
			);
		}
		
		return $this->process_response($message, $status);
		
	}
	
	public function get_mailer_source(){
		
		$result = [];
		$backtrace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS );

		if(empty($backtrace)){
			return false;
		}

		foreach( $backtrace as $i => $item ){
			if( $item['function'] == 'wp_mail' ) {
				$result[] = $backtrace[$i];
			}
		}
		
		if(!isset($result[0]['file'])){
			return false;
		}
		
		return $this->get_plugin_name($result[0]['file']);
	}

	public function process_response($message, $status){
		global $phpmailer, $gosmtp;
		
		if(empty($gosmtp->options['logs']['enable_logs']) || !class_exists('\GOSMTP\Logger')){
			return $status;
		}
		
		$logger = new \GOSMTP\Logger();
		
		$source = $this->get_mailer_source();
		
		if(empty($source)){
			$source = __('NA', 'gosmtp');
		}
		
		$headers = array(
			'Reply-To' => $phpmailer->getReplyToAddresses(),
			'Cc' => $phpmailer->getCcAddresses(),
			'Bcc' => $phpmailer->getBccAddresses(),
			'Content-Type' => $phpmailer->ContentType,
		);
		
		$attachments = $phpmailer->getAttachments();

		if(!empty($gosmtp->options['logs']['log_attachments'])){
			
			$uploads_dir = wp_upload_dir();
			$path = $uploads_dir['basedir'].'/gosmtp-attachments';
			
			if( !file_exists($path) ){
				mkdir($path);
			}

			if(!file_exists($path.'/index.html')){
				file_put_contents($path.'/index.html', '');
			}

			if( count($attachments) > 0 ){

				foreach( $attachments as $key => $file ){
					$name = $file[2];
					$location = $path.'/'.$name;
		
					if(file_exists($file[0])){
						// TODO check the copy function use correct
						if(copy($file[0], $location)){
							$file[0] = $location;
						}	
					}
					
					$attachments[$key] = $file;
				}
			}
		}
		
		$data = array(
			'site_id' => get_current_blog_id(),
			'to' => maybe_serialize($this->sanitize_response($phpmailer->getToAddresses(), 'email')),
			'message_id' => $this->RandomString(16),
			'from' => sanitize_email($phpmailer->From),
			'subject' => sanitize_text_field($phpmailer->Subject),
			'body' => $phpmailer->Body,
			'attachments' => maybe_serialize($this->sanitize_response($attachments)),
			'status' => $status ? 'sent' : 'failed',
			'response' => maybe_serialize($this->sanitize_response($message)),
			'headers' => maybe_serialize($this->sanitize_response($headers)),
			'provider' => sanitize_text_field($this->mailer),
			'source' => sanitize_text_field($source),
			'created_at' => current_time( 'mysql' )
		);
		
		if($gosmtp->mailer->conn_id !== 0 && !empty($gosmtp->mailer->parent_log)){
			$data['parent_id'] = $gosmtp->mailer->parent_log;
			$data['source'] = __('GoSMTP Pro', 'gosmtp');
		}

		if(isset($_POST['gostmp_id'])){
			$id = (int)gosmtp_optpost('gostmp_id');
			$result = $logger->get_logs('records', $id);
			$operation = isset($_POST['operation']) ? gosmtp_optpost('operation') : false;
			
			if(!empty($operation) && !empty($result)){
				
				if($operation == 'resend'){
					$data['resent_count'] = $result[0]->resent_count + 1;
				}else{
					$data['retries'] = $result[0]->retries + 1;
				}
				
				$logger->update_logs($data, $id);
			}
		}else{
			$gosmtp->mailer->last_log = $logger->add_logs($data);
		}

		return $status;
	}

	protected function sanitize_response($data, $field_type = ''){
		if(empty($data)){
			return $data;
		}

		if($field_type == 'email'){
			return map_deep($data, 'sanitize_email');
		}

		foreach($data as $key => $item){
			if(is_array($item)){
				$data[$key] = $this->sanitize_response($item);
			}

			if(is_object($item) || is_resource($item)){
				continue;
			}

			if(is_string($item)){
				if(filter_var($item, FILTER_VALIDATE_EMAIL)){
					$data[$key] = sanitize_email($item);
				} elseif(filter_var($item, FILTER_VALIDATE_URL)){
					$data[$key] = esc_url_raw($item);
				} else{
					$data[$key] = sanitize_text_field($item);
				}
			}
		}
		return $data;
	}

	public function message_formatting($msg, $key = '', $desc = ''){

		$message = '';

		if(!empty($key)){
			$message .= $key.': ';
		}

		if(is_string($msg)){
			$message .= $msg;
		}else{
			$message .= wp_json_encode($msg);
		}

		if(!empty($desc)){
			$message .= PHP_EOL .$desc;
		}

		return $message;
	}
	
	public function get_response_error_message($response){

		if(is_wp_error($response)){
			return '';
		}

		$body = wp_remote_retrieve_body( $response );
		$message = wp_remote_retrieve_response_message( $response );
		$code = wp_remote_retrieve_response_code( $response );
		$desc = '';

		if(!empty($body)){
			$desc = is_string($body) ? $body : wp_json_encode($body);
		}

		return $this->message_formatting( $message, $code, $desc );
	}
		
	// Generate a random string
	public function RandomString($length = 10){
		$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
		$charactersLength = strlen($characters);
		$randomString = '';
		for($i = 0; $i < $length; $i++){
			$randomString .= $characters[rand(0, $charactersLength - 1)];
		}
		return $randomString;
	}

	public function get_plugin_name($file_path = ''){

		if( empty( $file_path ) ){
			return false;
		}
		
		if(!function_exists( 'get_plugins')){
			$plugin_file = ABSPATH . 'site-admin/includes/plugin.php';
			$plugin_file = file_exists($plugin_file) ? $plugin_file : ABSPATH . 'wp-admin/includes/plugin.php';
			require_once( $plugin_file );
		}
		
		$plugins = get_plugins();
		$content_dir = basename( WP_PLUGIN_DIR );
		$separator = defined( 'DIRECTORY_SEPARATOR' ) ? '\\' . DIRECTORY_SEPARATOR : '\/';
		
		preg_match( "/$separator$content_dir$separator(.[^$separator]+)($separator|\.php)/", $file_path , $match );
		
		if(empty($plugins) || empty($match[1])){
			return false;
		}
		
		$slug = $match[1];

		foreach( $plugins as $plugin => $data ){
			if( preg_match( "/^$slug(\/|\.php)/", $plugin ) === 1 && isset( $data['Name'] )) {
				return $data['Name'];
			}
		}
		
		return false;
	}

	public function get_backup_connection(){

		// Is Primary email?
		if($this->conn_id !== 0 || empty($this->options['mailer'][0]['backup_connection'])){
			return false;
		}
		
		return $this->options['mailer'][0]['backup_connection'];
	}
	
	
}
PK��f\5w��o_o_	media.phpnu�[���<?php

namespace SoftWP;

// Are we being accessed directly ?
if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class Media{
	
	static $compress_content_types = ['image/jpeg', 'image/jpg', 'image/png', 'image/webp'];
	
	static $edit_content_types = [
							'image/jpeg', 'image/png', 'image/gif', 'image/svg+xml', 
							'image/x-ms-bmp', 'image/tiff', 'image/webp', 
							'image/vnd.adobe.photoshop', 'application/pdf', 
							'image/x-portable-pixmap', 'image/x-icon', 'image/vnd-ms.dds'
							];
							
	static $edit_quality_content_types = ['image/jpeg', 'image/png', 'image/webp'];

	static function can_manage_media(){
		
		global $post;
		
		if(!is_admin() || !current_user_can('upload_files') || empty($post) || empty($post->ID) || $post->post_type != 'attachment'){
			define('SOFTACULOUS_PRO_CAN_PHOTOPEA_EDIT', 0);
			define('SOFTACULOUS_PRO_CAN_COMPRESS', 0);
			define('SOFTACULOUS_PRO_CAN_REPLACE_MEDIA', 0);
			return false;
		}
		
		define('SOFTACULOUS_PRO_CAN_REPLACE_MEDIA', 1);
		
		$attachment_path = get_attached_file($post->ID);
		$original_size = filesize($attachment_path);
		$original_size_kb = round($original_size / 1024);
		$attachment_mime_type = mime_content_type($attachment_path);

		// The action buttons
		if(in_array($attachment_mime_type, \SoftWP\Media::$edit_content_types)){
			add_action('admin_enqueue_scripts', '\SoftWP\Media::enqueue_photopea_scripts');
			define('SOFTACULOUS_PRO_CAN_PHOTOPEA_EDIT', 1);
		}else{
			define('SOFTACULOUS_PRO_CAN_PHOTOPEA_EDIT', 0);
		}
		
		if(0 && in_array($attachment_mime_type, \SoftWP\Media::$compress_content_types)){
			add_action('admin_enqueue_scripts', '\SoftWP\Media::enqueue_compress_scripts');
			define('SOFTACULOUS_PRO_CAN_COMPRESS', 1);
		}else{
			define('SOFTACULOUS_PRO_CAN_COMPRESS', 0);
		}
		
		return true;
	}

	static function can_photopea_edit(){
		
		if(!defined('SOFTACULOUS_PRO_CAN_PHOTOPEA_EDIT')){
			\SoftWP\Media::can_manage_media();
		}
		
		return SOFTACULOUS_PRO_CAN_PHOTOPEA_EDIT;
	}

	static function can_compress(){
		
		if(!defined('SOFTACULOUS_PRO_CAN_COMPRESS')){
			\SoftWP\Media::can_manage_media();
		}
		
		return SOFTACULOUS_PRO_CAN_COMPRESS;
	}

	static function can_replace_media(){
		
		if(!defined('SOFTACULOUS_PRO_CAN_REPLACE_MEDIA')){
			\SoftWP\Media::can_manage_media();
		}
		
		return SOFTACULOUS_PRO_CAN_REPLACE_MEDIA;
	}

	// Register the meta box
	static function register_meta_box(){
		
		if(!\SoftWP\Media::can_manage_media()){
			return false;
		}
		
		add_meta_box(
			'softaculous_pro_media_meta_box',
			__('Action Buttons', 'softaculous-pro'),
			'\SoftWP\Media::meta_box_callback',
			'attachment',
			'side',
			'low'
		);
	}

	// Callback function to render the meta box
	static function meta_box_callback($post){
		
		// Nonce field for security
		//wp_nonce_field('softaculous_pro_media_meta_box_nonce', 'custom_nonce');

		// The action buttons
		if(\SoftWP\Media::can_photopea_edit()){
			echo '<button type="button" class="button" id="edit_with_photopea" data-image-url="' . esc_url(wp_get_attachment_url($post->ID)) . '" data-original-image-url="' . esc_url(wp_get_attachment_url($post->ID)) . '" style="margin-right: 5px; margin-top: 10px;">'.__('Edit with Photopea', 'softaculous-pro').'</button>';
		}
		
		if(\SoftWP\Media::can_compress()){
		
			$attachment_path = get_attached_file($post->ID);
			$original_size = filesize($attachment_path);
			$original_size_kb = round($original_size / 1024);
			
			echo '<button type="button" class="button compress-image-button" data-image-id="' . $post->ID . '" data-original-size="' . $original_size_kb . '" data-image-type="' . esc_attr(get_post_mime_type($post)) . '"  style="margin-right: 5px; margin-top: 10px;">'.__('Compress Image', 'softaculous-pro').'</button>';
		}
		
		if(\SoftWP\Media::can_replace_media()){
		
			echo '<a href="' . esc_url(admin_url('upload.php?page=assistant&act=media-replace&id=' . $post->ID)) . '" class="button replace-media-button" style="margin-right: 5px; margin-top: 10px; display: inline-block;">'.__('Replace Media', 'softaculous-pro').'</a>';
			
		}
		
	}

	//////////////////////////////////
	// Edit with Photopea 
	//////////////////////////////////

	// Function to enqueue scripts and styles for the Photopea modal
	static function enqueue_photopea_scripts(){
		
		if(!\SoftWP\Media::can_photopea_edit()){
			return false;
		}
		
		add_action('admin_footer', '\SoftWP\Media::enqueue_photopea_button_script');
		
		wp_enqueue_script('softaculous-pro-photopea-edit', SOFTACULOUS_PRO_PLUGIN_URL . 'assets/js/photopea_edit.js', ['jquery'], SOFTACULOUS_PRO_VERSION, true);

		wp_localize_script('softaculous-pro-photopea-edit', 'spro_photopea', array('ajax_url' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('softaculous_pro_js_nonce')));
		
	}

	// Enqueue the Photopea modal and button script in WordPress
	static function enqueue_photopea_button_script(){
		
		global $post;
		
		if(!\SoftWP\Media::can_photopea_edit()){
			return false;
		}
		
	?>
	<style>
	#softaculous-pro-photopea-modal {
		display: none;
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background: rgba(0, 0, 0, 0.8);
		z-index: 999999;
		pointer-events: auto; 
	}
	#softaculous-pro-photopea-white-bar {
		position: relative;
		top: 0;
		left: 0;
		width: 100%;
		height: 30px;
		background-color: white;
		z-index: 1000; 
	}
	#softaculous-pro-photopea-iframe {
		width: 100%;
		height: calc(100% - 80px); 
		border: none;
		z-index: 9999; 
		pointer-events: auto; 
	}
	#softaculous-pro-photopea-actions {
		position: absolute;
		bottom: 0;
		left: 0;
		width: 100%;
		height: 50px;
		background: #fff;
		display: flex;
		justify-content: flex-end; 
		align-items: center;
		box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
	}
	#softaculous-pro-photopea-actions .softaculous-pro-quality-section {
		display: flex;
		align-items: center;
		margin-right: auto;
		margin-left: 10px;
	}
	#softaculous-pro-photopea-actions .softaculous-pro-quality-section label {
		margin-right: 5px;
		font-size: 15px;
		font-weight: bold;
		color: black;
		cursor:pointer;
	}
	#softaculous-pro-photopea-actions .softaculous-pro-quality-section input {
		width: 70px;
		padding: 3px;
		text-align: center;
		border: 1px solid #9fa1a6;
		border-radius: 3px;
		color:black;
	}
	#softaculous-pro-photopea-actions button {
		padding: 8px 15px;
		background-color: #0073aa;
		color: white;
		border: none;
		border-radius: 3px;
		cursor: pointer;
		margin-left: 3px; 
	}
	#softaculous-pro-photopea-actions button:hover {
		background-color: #005177;
	}
	</style>

	<div id="softaculous-pro-photopea-modal">
		<div id="softaculous-pro-photopea-white-bar"></div>
		<iframe id="softaculous-pro-photopea-iframe" src=""></iframe>
		<div id="softaculous-pro-photopea-actions">
			<div class="softaculous-pro-quality-section" id="softaculous-pro-quality-input-container" style="display: none;">
				<label for="softaculous-pro-quality-input"><?php _e('Quality', 'softaculous-pro');?>: </label>
				<input type="number" id="softaculous-pro-quality-input" value="100" min="1" max="100" />
			</div>
			<button id="softaculous-pro-save-photopea"><?php _e('Save', 'softaculous-pro');?></button>
			<button id="softaculous-pro-save-close-photopea"><?php _e('Save & Close', 'softaculous-pro');?></button>
			<button id="softaculous-pro-save-as-photopea"><?php _e('Save As', 'softaculous-pro');?></button>
			<button id="softaculous-pro-cancel-photopea"><?php _e('Cancel', 'softaculous-pro');?></button>
		</div>
	</div>
	<?php
	}
	
	static function upload_photopea_image() {
		
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
			
			$jsonData = file_get_contents('php://input');
			$p = json_decode($jsonData);
			
			if(!is_admin() || !current_user_can('upload_files') || !isset($p->softaculous_pro_security) || !wp_verify_nonce(sanitize_text_field(wp_unslash($p->softaculous_pro_security)), 'softaculous_pro_js_nonce')){
				wp_send_json_error(__('Security Check Failed!', 'softaculous-pro'));
			}

			// Check if a quality parameter is provided, defaulting to 100
			$quality = isset($p->quality) ? intval($p->quality) : 100;
			$quality = max(1, min($quality, 100));

			$base64ImageData = $p->source;
			$save_as_new = (isset($p->save_as_new) ? 1 : 0);
			
			if(empty($save_as_new)){
				$originalImageUrl = $p->original_image_url;
				$attachment_id = attachment_url_to_postid($originalImageUrl);
				if (!$attachment_id) {
					wp_send_json_error(__("Original image attachment not found", 'softaculous-pro'));
					return;
				}

				$filePath = get_attached_file($attachment_id);
				if (!$filePath) {
					wp_send_json_error(__("Original image path not found", 'softaculous-pro'));
					return;
				}
			}else{

				$newImageName = sanitize_file_name($p->new_image_name);  

				$extension = pathinfo($newImageName, PATHINFO_EXTENSION);
				$baseFileName = pathinfo($newImageName, PATHINFO_FILENAME);

				// Sanitize and create a proper path to save the new image in the uploads directory
				$upload_dir = wp_upload_dir();
				$filePath = $upload_dir['path'] . '/' . $newImageName;
				
				$newFileName = basename($filePath);
				
				if(file_exists($filePath)){
					wp_send_json_error(__("File already exists. Please choose another file name", 'softaculous-pro'));
					return;
				}
			}

			// Decode the base64 image data
			$imageData = base64_decode(preg_replace('/^data:image\/(jpeg|png);base64,/', '', $base64ImageData));

			if ($imageData === false) {
				wp_send_json_error(__("Failed to decode base64 image data", 'softaculous-pro'));
				return;
			}
			
			if(empty($quality) || $quality > 99){
				$saved = file_put_contents($filePath, $imageData);
			}else{

				// Create an image resource from the decoded data
				$image = imagecreatefromstring($imageData);
				if ($image === false) {
					wp_send_json_error(__("Failed to create image from data", 'softaculous-pro'));
					return;
				}

				$saved = false;
				if (strpos($filePath, '.jpg') !== false || strpos($filePath, '.jpeg') !== false) {
					
					$saved = imagejpeg($image, $filePath, $quality);

				}elseif (strpos($filePath, '.png') !== false) {
					
					$paletteImage = imagecreatetruecolor(imagesx($image), imagesy($image));
					
					imagesavealpha($paletteImage, true);
					imagealphablending($paletteImage, false);
					$transparency = imagecolorallocatealpha($paletteImage, 0, 0, 0, 127);
					imagecolortransparent($paletteImage, $transparency);
					imagecopyresampled($paletteImage, $image, 0, 0, 0, 0, imagesx($image), imagesy($image), imagesx($image), imagesy($image));

					// Reduce to a set number of colors to save space
					$maxColors = ($quality < 100) ? max((int)($quality / 10), 20) : 256;
					imagetruecolortopalette($paletteImage, true, $maxColors);

					// Set compression level based on quality (0 = no compression, 9 = max compression)
					$compressionLevel = round((100 - $quality) / 100 * 9);
					
					// Don't pass 0 otherwise it will create image larger in size than the original one
					if(empty($compressionLevel)){
						$compressionLevel = 1;
					}
					
					$saved = imagepng($paletteImage, $filePath, $compressionLevel);

				}elseif (strpos($filePath, '.webp') !== false) {
					
					$saved = imagewebp($image, $filePath, $quality);

				}else{
					wp_send_json_error(__("Unsupported image format", 'softaculous-pro'));
					return;
				}

				imagedestroy($image);
			}

			if (!$saved) {
				wp_send_json_error(__("Failed to save the image", 'softaculous-pro'));
				return;
			}
			
			if(!empty($save_as_new)){

				// Attach the new file to the WordPress media library
				$attachment = array(
						'guid'           => $upload_dir['url'] . '/' . basename($filePath),
						'post_mime_type' => mime_content_type($filePath),
						'post_title'     => preg_replace('/\.[^.]+$/', '', basename($filePath)),
						'post_content'   => '',
						'post_status'    => 'inherit'
					);

				$attachment_id = wp_insert_attachment($attachment, $filePath);
				
				if(is_wp_error($attachment_id)) {
					wp_send_json_error(__("Failed to insert the new image as attachment", 'softaculous-pro'));
				}
			}
			
			$metadata = wp_generate_attachment_metadata($attachment_id, $filePath);
			if (is_wp_error($metadata)) {
				wp_send_json_error(__("Failed to regenerate image sub-sizes", 'softaculous-pro'));
			}

			wp_update_attachment_metadata($attachment_id, $metadata);
			$new_image_url = wp_get_attachment_url($attachment_id);

			wp_send_json_success(array(
				'new_image_url' => $new_image_url,
				'message' => __('Image saved successfully', 'softaculous-pro'),
				));
		}
	}

	//////////////////////////////////
	// Compress Image 
	//////////////////////////////////

	static function enqueue_compress_scripts(){
		
		if(!\SoftWP\Media::can_compress()){
			return false;
		}
		
		wp_enqueue_script('softaculous_pro_enqueue_compress_scripts', SOFTACULOUS_PRO_PLUGIN_URL .  '/assets/js/compress_image.js', ['jquery'], SOFTACULOUS_PRO_VERSION, true);
		wp_localize_script('softaculous_pro_enqueue_compress_scripts', 'spro_compress', array(
			'ajax_url' => admin_url('admin-ajax.php'),
			'nonce' => wp_create_nonce('softaculous_pro_js_nonce')
			));
		
	}
	
	static function calculate_compressed_size() {

		if(!is_admin() || !current_user_can('upload_files') || !isset($_POST['softaculous_pro_security']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['softaculous_pro_security'])), 'softaculous_pro_js_nonce')){
			wp_send_json_error(__('Security Check Failed!', 'softaculous-pro'));
		}

		if (isset($_POST['image_id'])) {
			$image_id = intval($_POST['image_id']);
			$image_path = get_attached_file($image_id);

			if ($image_path) {
				$compressed_image_path = \SoftWP\Media::compress_image($image_path, 40, false);
				$compressed_size = round(filesize($compressed_image_path) / 1024);

				wp_send_json_success(array('compressed_size' => $compressed_size));
			}else {
				wp_send_json_error(__('Invalid image path.', 'softaculous-pro'));
			}
		}else {
			wp_send_json_error(__('No image ID provided.', 'softaculous-pro'));
		}
	}

	static function compress_image($image_path, $quality, $save_image = true) {
		$info = getimagesize($image_path);
		$compressed_image_path = '';

		if ($info['mime'] == 'image/jpeg') {
	  $image = imagecreatefromjpeg($image_path);
	  $compressed_image_path = $save_image ? $image_path : str_replace('.jpg', '-temp.jpg', $image_path);
	  imagejpeg($image, $compressed_image_path, $quality);

		}elseif ($info['mime'] == 'image/png') {
				$image = imagecreatefrompng($image_path);
				$compressed_image_path = $save_image ? $image_path : str_replace('.png', '-temp.png', $image_path);

				// Convert to a palette-based image to reduce bit depth
				$paletteImage = imagecreatetruecolor(imagesx($image), imagesy($image));
				imagecopy($paletteImage, $image, 0, 0, 0, 0, imagesx($image), imagesy($image));

				// Reduce to a set number of colors to save space
				$maxColors = ($quality < 100) ? max((int)($quality / 10), 20) : 256;
				imagetruecolortopalette($paletteImage, true, $maxColors);

				// Set compression level based on quality (0 = no compression, 9 = max compression)
				$compressionLevel = ($quality < 100) ? 9 - (int)($quality / 10) : 9;

				imagepng($paletteImage, $compressed_image_path, $compressionLevel);

		}elseif ($info['mime'] == 'image/webp') {
				$image = imagecreatefromwebp($image_path);
				$compressed_image_path = $save_image ? $image_path : str_replace('.webp', '-temp.webp', $image_path);
				imagewebp($image, $compressed_image_path, $quality);
		}else {
				return __('Unsupported image type.', 'softaculous-pro');
		}

		return $compressed_image_path;
	}
	
	static function replace_compressed_image() {

		if(!is_admin() || !current_user_can('upload_files') || !isset($_POST['softaculous_pro_security']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['softaculous_pro_security'])), 'softaculous_pro_js_nonce')){
			wp_send_json_error(__('Security Check Failed!', 'softaculous-pro'));
		}

		if (isset($_POST['image_id'])) {
			$image_id = intval($_POST['image_id']);
			$image_path = get_attached_file($image_id);

			if ($image_path) {
				$compressed_image_path = \SoftWP\Media::compress_image($image_path, 40, true);
				if ($compressed_image_path) {
					require_once(ABSPATH . 'wp-admin/includes/image.php');
					$attach_data = wp_generate_attachment_metadata($image_id, $compressed_image_path);
					wp_update_attachment_metadata($image_id, $attach_data);

					$new_image_url = wp_get_attachment_url($image_id);

					wp_send_json_success(array('message' => __('Image has been successfully compressed and replaced.', 'softaculous-pro'), 'new_image_url' => $new_image_url));
				}else {
					wp_send_json_error(__('Compression and replacement failed.', 'softaculous-pro'));
				}
			}else {
				wp_send_json_error(__('Invalid image path.', 'softaculous-pro'));
			}
		}else {
			wp_send_json_error(__('No image ID provided.', 'softaculous-pro'));
		}
	}

	//////////////////////////////////
	// Replace Media 
	//////////////////////////////////
	
	// Add Replace Media link on Media page in List Mode
	static function add_media_row_action($actions, $post){
		
		if(!\SoftWP\Media::can_replace_media()){
			return $actions;
		}
		
		$url = admin_url('upload.php');
		
		$url = add_query_arg(array(
			'page' => 'assistant',
			'act' => 'media-replace',
			'id' => $post->ID,
		), $url);
		
		$actions['softaculous_pro_replace_media'] = '<a href="'.esc_url($url).'" rel="permalink">'.esc_html__('Replace Media', 'softaculous_pro').'</a>';
		
		// Remove it from Pagelayer as we are adding our own
		if(isset($actions['pagelayer_replace_media'])){
			unset($actions['pagelayer_replace_media']);
		}
		
		return $actions;
		
	}

	//function is called first to select the route 
	static function replace_media_page(){
		
		global $pl_error;

		if(!current_user_can('upload_files')){
			wp_die(esc_html__('You do not have permission to upload files.', 'softaculous-pro'));
		}
		
		$post_id = (int) $_GET['id'];
		
		if(empty($post_id)){
			wp_die(esc_html__('Invalid Media ID', 'softaculous-pro'));
		}
		
		// Load the attachment
		$post = get_post($post_id);
		
		if(empty($post) || is_wp_error($post)){
			wp_die(esc_html__('Media not found', 'softaculous-pro'));
		}
		
		// Process the POST !
		if(isset($_FILES['userfile'])){
		
			if(!check_admin_referer('softaculous-pro-media')){
				wp_die('Invalid Nonce');
			}
			
			/** Check if file is uploaded properly **/
			if(!is_uploaded_file($_FILES['userfile']['tmp_name'])){
				$pl_error['upload_error'] = __('No file was uploaded ! Please try again.', 'softaculous-pro');
				\SoftWP\Media::replace_media_theme();
				return;
			}
			
			if(isset($_FILES['userfile']['error']) && $_FILES['userfile']['error'] > 0){
				$pl_error['upload_error'] = __('There was some error uploading the file ! Please try again.', 'softaculous-pro');
				\SoftWP\Media::replace_media_theme();
				return;
			}
			
			$filedata = wp_check_filetype_and_ext($_FILES['userfile']['tmp_name'], $_FILES['userfile']['name']);
			
			if ($filedata['ext'] == false){
				$pl_error['ext_error'] = __('The File type could not be determined. Please upload a permitted file type.', 'softaculous-pro');
				\SoftWP\Media::replace_media_theme();
				return;
			}
			
			$result = \SoftWP\Media::replace_attachment($_FILES['userfile']['tmp_name'], $post_id, $err);
			
			if(empty($result)){
				$pl_error['replace_error'] = $err;
				\SoftWP\Media::replace_media_theme();
				return;
			}
			
			$redirect_success = admin_url('post.php');
			$redirect_success = add_query_arg(array(
				'action' => 'edit', 
				'post' => $post_id,
			), $redirect_success);
			
			echo '<meta http-equiv="refresh" content="0;url='.$redirect_success.'" />';
		
		}
		
		// Show the theme
		\SoftWP\Media::replace_media_theme();
		
	}

	// Report an error
	static function report_error($error = array()){

		if(empty($error)){
			return true;
		}

		$error_string = '<b>'.__('Please fix the below errors', 'softaculous-pro').' :</b> <br />';

		foreach($error as $ek => $ev){
			$error_string .= '* '.$ev.'<br />';
		}

		echo '<div id="message" class="error"><p>'
						. __($error_string, 'softaculous-pro')
						. '</p></div>';
	}


	// Theme of the page
	static function replace_media_theme(){
		
		global $pl_error;
		
		\SoftWP\Media::report_error($pl_error);echo '<br />';
		
		$id = (int) $_GET['id'];
		
	?>
	<div class="wrap">
	<h1><?php echo esc_html__("Replace Media File", 'softaculous-pro'); ?></h1>
	<form enctype="multipart/form-data" method="POST">
		<div class="editor-wrapper">
			<section class="image_chooser wrapper">
				<input type="hidden" name="ID" id="ID" value="<?php echo $id ?>" />
				<p><?php echo esc_html__("Choose a file to upload from your computer", 'softaculous-pro'); ?></p>
				<div class="drop-wrapper">
					<p><input type="file" name="userfile" id="userfile" /></p>
					<?php wp_nonce_field('softaculous-pro-media'); ?>
				</div>
			</section>
			<section class="form_controls wrapper">
				<input id="submit" type="submit" class="button button-primary" name="submit" value="<?php echo esc_attr__("Upload", 'softaculous-pro');?>" />
			</section>
		</div>
	</form>
	<?php

	}

	// Replace the uploaded media with the new one
	static function replace_attachment($file, $post_id, &$error = ''){

		if(!current_user_can('upload_files')){
			wp_die(esc_html__('You do not have permission to upload files.', 'softaculous-pro'));
		}

		if(function_exists('wp_get_original_image_path')){
			$targetFile = wp_get_original_image_path($post_id);
		}else{
			$targetFile = trim(get_attached_file($post_id));
		}
		
		$fileparts = pathinfo($targetFile);
		$filePath = isset($fileparts['dirname']) ? trailingslashit($fileparts['dirname']) : '';
		$fileName = isset($fileparts['basename']) ? $fileparts['basename'] : '';
		$filedata = wp_check_filetype_and_ext($targetFile, $fileName);
		$fileMime = (isset($filedata['type'])) ? $filedata['type'] : false;
		$permissions = fileperms($targetFile) & 0644;
		
		if(empty($targetFile)){
			$error = __('Failed to determine the media file path !', 'softaculous-pro');
			return false;
		}
		
		if(empty($filePath)){
			$error = __('No folder for the target found !', 'softaculous-pro');
			return false;
		}
		
		// Remove the files of the original attachment
		\SoftWP\Media::remove_attachment_files($post_id);
		
		$result_moved = move_uploaded_file($file, $targetFile);
		
		if (false === $result_moved){
			$error = sprintf( esc_html__('The uploaded file could not be moved to %1$s. This is most likely an issue with permissions, or upload failed.', 'softaculous-pro'), $targetFile );
			return false;
		}
		
		if ($permissions > 0){
			chmod( $targetFile, $permissions ); // restore permissions
		}
		
		$updated = update_attached_file($post_id, $targetFile);
		
		$target_url = wp_get_attachment_url($post_id);
		
		// Run the filter, so other plugins can hook if needed.
		$filtered = apply_filters( 'wp_handle_upload', array(
			'file' => $targetFile,
			'url'  => $target_url,
			'type' => $fileMime,
		), 'sideload');
		
		// Check if file changed during filter. Set changed to attached file meta properly.
		if (isset($filtered['file']) && $filtered['file'] != $targetFile ){
			update_attached_file($post_id, $filtered['file']);
		}

		$metadata = wp_generate_attachment_metadata($post_id, $targetFile);
		wp_update_attachment_metadata($post_id, $metadata);

		return true;
		
	}

	static function remove_attachment_files($post_id){

		if(!current_user_can('upload_files')){
			wp_die(esc_html__('You do not have permission to upload files.', 'softaculous-pro'));
		}
		
		$meta = wp_get_attachment_metadata( $post_id );

		if (function_exists('wp_get_original_image_path')){ // WP 5.3+
			$fullFilePath = wp_get_original_image_path($post_id);
		}else{
			$fullFilePath = trim(get_attached_file($post_id));
		}

		$backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true );
		
		$file = $fullFilePath;
		
		$result = wp_delete_attachment_files($post_id, $meta, $backup_sizes, $file);

		// If attached file is not the same path as file, this indicates a -scaled images is in play.
		$attached_file = get_attached_file($post_id);
		
		if ($file !== $attached_file && file_exists($attached_file)){
			@unlink($attached_file);
		}
	}
	
}
PK��f\�Sg''	setup.phpnu�[���<?php

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

$steps = array(
	'welcome' => __('Welcome', 'softaculous-pro'),
	'type' => __('Business Type','softaculous-pro'),
	'title' => __('Site Title','softaculous-pro'),
	'features' => __('Goals','softaculous-pro'),
	'import_theme' => __('Choose Template','softaculous-pro'),
);

$active_step = isset($_GET['step']) && array_key_exists($_GET['step'], $steps) ? $_GET['step'] : 'welcome';

include_once(dirname(__FILE__).'/onboarding.php');
$softaculous_pro['templates'] = softaculous_pro_get_templates_list();
$spro_setup_info = get_option('softaculous_pro_setup_info');
$spro_onboarding_done = get_option('softaculous_pro_onboarding_done');

update_option('softaculous_pro_onboarding_shown', time());

require_once ABSPATH . 'wp-admin/includes/plugin.php';
$installed_plugins = get_plugins();

if(!empty($softaculous_pro['branding']['default_hf_bg'])){
	echo '
	<style>
	.softaculous-pro-wizard-sidebar {
		background-color:'.$softaculous_pro['branding']['default_hf_bg'].' !important;
	}
	</style>';
}

if(!empty($softaculous_pro['branding']['default_hf_text'])){
	echo '
	<style>
	.softaculous-pro-wizard-steps li, .softaculous-pro-wizard-steps li::before {
		color:'.$softaculous_pro['branding']['default_hf_text'].' !important;
		border-color:'.$softaculous_pro['branding']['default_hf_text'].' !important;
	}
	.softaculous_pro_return_btn span, .dashicons-exit::before {
		color:'.$softaculous_pro['branding']['default_hf_text'].' !important;
	}
	</style>';
}

?>
<style>
*,
*::before,
*::after {
	box-sizing: content-box;
}
</style>

<div class="softaculous-pro-wizard">
	<div class="softaculous-pro-wizard-sidebar">
		<div class="softaculous-pro-setup-logo">
			<a href="<?php echo admin_url('admin.php?page=assistant&act=onboarding'); ?>">
				<img src="<?php echo esc_attr($softaculous_pro['branding']['logo_url']);?>" style="max-width:200px;" />
			</a>
		</div>
		<div class="softaculous-pro-steps-holder">
			<ol class="softaculous-pro-wizard-steps">
				<?php foreach ($steps as $key => $name) : ?>
                <a href="admin.php?page=assistant&act=onboarding&step=<?php echo $key; ?>"><li class="<?php echo ($key == $active_step ? 'active_step' : ''); ?>"><span
                        data-step="<?php echo $key; ?>"><?php echo $name; ?></span></li>
				</a>
				<?php endforeach; ?>
			</ol>
		</div>
		<a class="softaculous_pro_return_btn" style="cursor:pointer;" onclick="return softaculous_pro_onboarding_dismiss(event);">
		<span class="dashicons dashicons-exit"></span><span><?php _e('Exit', 'softaculous-pro'); ?></span></a>
	</div>
	
	<div class="softaculous-pro-wizard-content" data-active-panel="<?php echo $active_step; ?>">
		<!-- Step Welcome -->
		<div class="softaculous-pro-wizard-inner" data-panel="welcome">
			<div class="softaculous-pro-wizard-inner-content">
				<h1><?php _e('Welcome to the Onboarding process!', 'softaculous-pro'); ?></h1>
				<p><?php _e('This process will help you choose a professional template for your website and install plugins that you might need to achieve your goal for creating this website', 'softaculous-pro'); ?>
				</p>
				<?php if (!empty($spro_onboarding_done)): ?>
				<div class="softaculous-pro-wizard-buttons">
					<input type="checkbox" id="onboarding_done_confirm" name="onboarding_done_confirm" style="margin:0px;" /> &nbsp;&nbsp;
					<label for="onboarding_done_confirm" style="cursor:pointer;"><?php _e('It looks like you have already completed the onboarding process. You might lose data if you run the onboarding process again. Select this checkbox to confirm that you agree.', 'softaculous-pro'); ?></label>
				</div>
				<?php endif; ?>
				<div class="softaculous-pro-wizard-buttons">
                    <button class="step_btn step_next_btn" data-step="type"
                        onclick="softaculous_pro_next_handler(this)"><?php _e('Get Started', 'softaculous-pro'); ?><span
                            class="dashicons dashicons-arrow-right-alt"></span></button>
		
                    <button class="step_btn step_next_btn step_dismiss_btn" data-step="type"
                        onclick="softaculous_pro_onboarding_dismiss(event);"><?php _e('No, I don\'t want to try an easy setup process', 'softaculous-pro'); ?><span
                            class="dashicons dashicons-no-alt"></span></button>
				</div>
			</div>
		</div>
		<!-- Step Type -->
		<div class="softaculous-pro-wizard-inner" data-panel="type">
			<div class="softaculous-pro-wizard-inner-content">
				<h1><?php _e('How would you categorize your website ?', 'softaculous-pro'); ?></h1>
				<p><?php _e('This helps us recommend design and functionalities for your website', 'softaculous-pro'); ?></p>
			</div>
			<div class="softaculous-pro-category-input">
                <input type="text" class="softaculous_pro_input" id="cat_input" placeholder="<?php _e('Search for a category', 'softaculous-pro'); ?>" />
			</div>
			<div class="softaculous-pro-category-holder">
				<div class="softaculous-pro-categories-list">
					<?php foreach ($softaculous_pro['templates']['categories'] as $cslug => $cdata) : ?>
                    <div class="category_btn">
						<input type="button" id="cat_button_<?php echo $cslug; ?>" value= <?php echo esc_html($cdata['en']); ?> data-target=<?php echo $cslug; ?> />
					</div>
					<?php endforeach; ?>
                    <div id="spro_no_cat_results" style="display:none;">
						<h3><i><?php echo __('No results match your search criteria', 'softaculous-pro'); ?></i></h3>
					</div>
				</div>
			</div>
			<br /><br />
			<div class="softaculous-pro-wizard-buttons">
                <button onclick="softaculous_pro_prev_handler(this)" data-step="welcome"
                    class="step_btn step_prev_btn"><?php _e('Previous Step', 'softaculous-pro'); ?></button>
                <button class="step_btn step_next_btn" data-step="title"
                    onclick="softaculous_pro_next_handler(this)"><?php _e('Continue', 'softaculous-pro'); ?> <span
                        class="dashicons dashicons-arrow-right-alt"></span></button>
            </div>
		</div>
		<!-- Step Title -->
		<div class="softaculous-pro-wizard-inner" data-panel="title">
			<div class="softaculous-pro-wizard-inner-content">
				<h1><?php _e('Enter the title of your new site', 'softaculous-pro'); ?></h1>
				<p><?php _e('Can be changed later', 'softaculous-pro'); ?></p>
			</div>
			<div class="softaculous-pro-title-input">
				<input type="text" class="softaculous_pro_input" placeholder="<?php _e('Enter a title for your website', 'softaculous-pro'); ?>" value="<?php echo esc_html(get_bloginfo('name')); ?>" autocomplete="off"/>
			</div>
            <div class="softaculous-pro-wizard-buttons">
                <button onclick="softaculous_pro_prev_handler(this)" data-step="type"
                    class="step_btn step_prev_btn"><?php _e('Previous Step', 'softaculous-pro'); ?></button>
                <button class="step_btn step_next_btn" data-step="features"
                    onclick="softaculous_pro_next_handler(this)"><?php _e('Continue', 'softaculous-pro'); ?><span
                        class="dashicons dashicons-arrow-right-alt"></span></button>
            </div>
		</div>
		<!-- Step Features -->
		<div class="softaculous-pro-wizard-inner" data-panel="features">
			<div class="softaculous-pro-wizard-inner-content">
				<h1><?php _e('What are you looking to achieve with your new site ?', 'softaculous-pro'); ?></h1>
				<p><?php _e('We will install the appropriate plugins that will add the required functionality to your website', 'softaculous-pro'); ?></p>
			</div>
            <div class="softaculous-pro-features-container">
                <?php foreach(spro_get_features_list() as $slug => $feature):?>
                <label for="<?php echo $slug;?>_input" style="cursor:pointer;">
		<div class="softaculous-pro-features" data-slug="<?php echo $slug; ?>">
                    <div class="softaculous-pro-features-icon">
                        <span class="<?php echo $feature['icon']; ?>"></span>
                    </div>
                    <div class="softaculous-pro-features-text">
                        <h3><?php echo $feature['name']; ?></h3>
                        <p><?php echo $feature['info']; ?></p>
                    </div>
                    <div class="softaculous-pro-features-input">
                        <input type="checkbox" onclick="softaculous_pro_selected_features(this)" id="<?php echo $slug;?>_input" <?php echo (!empty($spro_setup_info) && !empty($spro_setup_info['features']) && in_array($slug, $spro_setup_info['features']) ? 'checked="checked"' : '') ;
						
				foreach($feature['plugin'] as $info){
					if (!empty($info['requires_php']) && version_compare(PHP_VERSION, $info['requires_php'], '<')) {
						echo ' disabled';
						echo ' spro-erro="'.sprintf(__('Requires PHP version %1$s or higher', 'softaculous-pro'), $info['requires_php']).'"';
						break;
					}
					echo (!empty($installed_plugins[$info['plugin_init']]) ? 'checked="checked"' : '');
				} ?>/>
                    </div>
                </div>
	    	</label>
                <?php endforeach; ?>
            </div>
            <div class="softaculous-pro-wizard-buttons">
                <button onclick="softaculous_pro_prev_handler(this)" data-step="title"
                    class="step_btn step_prev_btn"><?php _e('Previous Step', 'softaculous-pro'); ?> </button>
                <button class="step_btn step_next_btn" data-step="import_theme"
                    onclick="softaculous_pro_next_handler(this)"><?php _e('Continue', 'softaculous-pro'); ?> <span
                        class="dashicons dashicons-arrow-right-alt"></span></button>
            </div>
        </div>
        <!-- Step Import theme -->
        <div class="softaculous-pro-wizard-inner" data-panel="import_theme">
            <?php
				softaculous_pro_templates();
			?>
        </div>
	</div>
</div>
PK��f\�f���T�T
intros.phpnu�[���<?php

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

$spro_tour_content = array();

////////////////////////////
// Assistant Tour
////////////////////////////

$spro_tour_content['assistant']['.spro-header-menu'] = array(
    "title" => __("Assistant", "softaculous-pro"),  
    "intro" => __("Assistant adds AI to your site building process and lets you create content with just a few clicks (look for the AI option while editing your posts/pages).", "softaculous-pro")
	.'<br /><br />'.
	__("Assistant also helps you with several aspects of building and maintaning your WordPress website.", "softaculous-pro"),  
    "position" => "bottom", 
);

$spro_tour_content['assistant']['#spro-tours'] = array(
    "title" => __("Tours", "softaculous-pro"),  
    "intro" => __("Tours highlights and explains important options in WordPress that you will need while managing your site.", "softaculous-pro")
	.'<br /><br />'.
	__("You can replay the tours when needed.", "softaculous-pro"),  
    "position" => "right", 
);

$spro_tour_content['assistant']['#spro-features'] = array(
    "title" => __("Recommended Features", "softaculous-pro"),  
    "intro" => __("A recommended list of plugins to improve performace and extend functionalties for your site.", "softaculous-pro"),
    "position" => "right", 
);

$spro_tour_content['assistant']['#spro-quick-links'] = array(
    "title" => __("Quick Links", "softaculous-pro"),  
    "intro" => __("Here you will find important links compiled in a single section which can sometimes be difficult to find in WordPress.", "softaculous-pro"),  
    "position" => "left", 
);

$spro_tour_content['assistant']['#spro-settings'] = array(
    "title" => __("Settings", "softaculous-pro"),  
    "intro" => __("We have simplified complex WordPress settings that you can now manage with just a click via the Assistant.", "softaculous-pro"),  
    "position" => "left", 
);

$spro_tour_content['assistant']['#spro-ai'] = array(
    "title" => __("AI", "softaculous-pro"),  
    "intro" => __("Experience hassle-free site building with inbuilt AI in Assistant.", "softaculous-pro"),
    "position" => "left", 
);

$spro_tour_content['assistant']['#toplevel_page_assistant'] = array(
    "title" => __("Your Assistant", "softaculous-pro"),  
    "intro" => __("Assistant resides here, when you are unable to find something or having a hard time understanding a feature in WordPress we should be able to help you.", "softaculous-pro")
	.'<br /><br />'.
	__("Visit this page anytime.", "softaculous-pro"),  
    "position" => "right", 
);

///////////////////////////////////
// WordPress Sidebar
///////////////////////////////////

$spro_tour_content['sidebar']['#toplevel_page_assistant'] = array(
    "title" => __("Your Assistant", "softaculous-pro"),  
    "intro" => __("Assistant resides here, when you are unable to find something or having a hard time understanding a feature in WordPress we should be able to help you.", "softaculous-pro")
	.'<br /><br />'.
	__("Visit this page anytime.", "softaculous-pro"),  
    "position" => "right", 
);

$spro_tour_content['sidebar']['#wp-admin-bar-view-site'] = array(
    "title" => __("Preview Site", "softaculous-pro"),  
    "intro" => __("You can use this link to preview your site as a visitor.", "softaculous-pro"),  
    "position" => "right",
    "hover" => "true",
    "hover_selector" => "#wp-admin-bar-site-name",
);

$spro_tour_content['sidebar']['#menu-dashboard'] = array(
    "title" => __("Dashboard", "softaculous-pro"),  
    "intro" => __("The Dashboard is your website's command center, providing a concise summary of its activity, such as site health, recent updates, comments, and statistics.", "softaculous-pro")
	.'<br /><br />'.
	__("Several plugins also display quick summary like orders, products, etc within the dashboard.", "softaculous-pro")
	.'<br /><br />'.
	__("You can also check for Updates from the sub-menu.", "softaculous-pro"),  
    "position" => "right", 
);

$spro_tour_content['sidebar']['#menu-posts'] = array(
    "title" => __("Posts", "softaculous-pro"),  
    "intro" => __("Manage your blog posts here.", "softaculous-pro")
	.'<br /><br />'.
	__("Posts are typically utilized for blog posts, news updates, or articles, organized in a chronological order.", "softaculous-pro"),
    "position" => "right", 
); 

$spro_tour_content['sidebar']['#menu-media'] = array(
    "title" => __("Media Library", "softaculous-pro"),  
    "intro" => __("Manage media files like images, audio, videos, etc. here.", "softaculous-pro")
	.'<br /><br />'.
	__("Media uploaded from anywhere on your site can be managed here.", "softaculous-pro"),  
    "position" => "right", 
);

$spro_tour_content['sidebar']['#menu-pages'] = array(
    "title" => __("Pages", "softaculous-pro"),
    "intro" => __("Pages are static content sections such as Home, About Us, Contact, Services, etc.", "softaculous-pro")
	.'<br /><br />'.
	__("Use this menu to add, edit, delete your pages.", "softaculous-pro"),
    "position" => "right", 
); 

$spro_tour_content['sidebar']['#menu-comments'] = array(
    "title" => __("Comments", "softaculous-pro"),  
    "intro" => __("Here you can moderate comments posted by visitors on your posts.", "softaculous-pro")
	.'<br /><br />'.
	__("You can one click disable comments for your entire site from the Assistant dashboard.", "softaculous-pro"),
    "position" => "right", 
); 

$spro_tour_content['sidebar']['#menu-appearance'] = array(
    "title" => __("Appearance", "softaculous-pro"),
    "intro" => __("Personalize your site's appearance effortlessly.", "softaculous-pro")
	.'<br /><br />'.
	__("Explore themes, customize headers, background, colors, manage widgets and menus to customize your site's look and feel.", "softaculous-pro"),  
    "position" => "right", 
); 

$spro_tour_content['sidebar']['#menu-plugins'] = array(
    "title" => __("Plugins", "softaculous-pro"),
    "intro" => __("Unlock endless possibilities for your website with plugins.", "softaculous-pro")
	.'<br /><br />'.
	__("Easily search, add or delete plugins to enhance your site's functionality.", "softaculous-pro"),  
    "position" => "right", 
); 

$spro_tour_content['sidebar']['#menu-users'] = array(
    "title" => __("Users", "softaculous-pro"),
    "intro" => __("Add or manage users to ensure smooth operation and collaboration.", "softaculous-pro"),  
    "position" => "right", 
);

$spro_tour_content['sidebar']['#menu-tools'] = array(
    "title" => __("Tools", "softaculous-pro"),
    "intro" => __("Import/Export site data, check site health or edit plugin/theme files from the Tools menu.", "softaculous-pro"),  
    "position" => "right", 
);

$spro_tour_content['sidebar']['#menu-settings'] = array(
    "title" => __("Settings", "softaculous-pro"),
    "intro" => __("Advanced settings for your site can be managed here.", "softaculous-pro")
	.'<br /><br />'.
	__("These settings include site title, tagline, site url, writing, reading, discussion, media, permalinks and more.", "softaculous-pro")
	.'<br /><br />'.
	__("Some plugins also add their settings page in this menu.", "softaculous-pro"),
    "position" => "right", 
);

$spro_tour_content['sidebar']['#collapse-menu'] = array(
    "title" => __("Toggle Menu", "softaculous-pro"),
    "intro" => __("Expand or Collapse the sidebar menu using this option.", "softaculous-pro"),
    "position" => "right", 
);

$spro_tour_content['sidebar']['#wp-admin-bar-user-info'] = array(
    "title" => __("Edit Profile", "softaculous-pro"),  
    "intro" => __("Here you can edit your profile information like name, email, password, bio, profile picture and more.", "softaculous-pro"),  
    "position" => "left",
    "hover" => "true",
    "hover_selector" => "#wp-admin-bar-my-account",
);

$spro_tour_content['sidebar']['#wp-admin-bar-logout'] = array(
    "title" => __("Log Out", "softaculous-pro"),  
    "intro" => __("Use this link to securely log out from your site.", "softaculous-pro"),
    "position" => "left",
    "hover" => "true",
    "hover_selector" => "#wp-admin-bar-my-account",
);

////////////////////////////
// Plugins Page
////////////////////////////

$spro_tour_content['plugins']['#menu-plugins'] = array(
    "title" => __("Plugins", "softaculous-pro"),  
    "intro" => __("Click here to add or manage plugins on your site.", "softaculous-pro"),  
    "position" => "right", 
);

$spro_tour_content['plugins']['.page-title-action'] = array(
    "title" => __("Add New Plugin", "softaculous-pro"),  
    "intro" => __("Here you can search wordpress.org plugins library or upload a custom plugin file to install a new plugin on your site.", "softaculous-pro"),
    "position" => "bottom",
);

$spro_tour_content['plugins']['tr[data-plugin]'] = array(
    "title" => __("Installed Plugins List", "softaculous-pro"),  
    "intro" => __("All your installed plugins active as well as inactive will be listed here.", "softaculous-pro"),  
    "position" => "bottom", 
);

$spro_tour_content['plugins']['td.plugin-title'] = array(
    "title" => __("Plugin Actions", "softaculous-pro"),  
    "intro" => __("You can perform actions for your plugins like Activate, Deactivate, Update, Delete, Plugin Settings and more..", "softaculous-pro")
	.'<br /><br />'.
	__("It is recommended to delete plugins that you do not plan to use and keep all your plugins up to date.", "softaculous-pro"),  
    "position" => "bottom",
);

$spro_tour_content['plugins']['#bulk-action-selector-top'] = array(
    "title" => __("Bulk Actions", "softaculous-pro"),  
    "intro" => __("Choose bulk action for selected plugins: Activate, Deactivate, Update, Delete, toggle auto updates and more", "softaculous-pro"), 
    "position" => "bottom", 
);

$spro_tour_content['plugins']['.subsubsub'] = array(
    "title" => __("Filter Installed Plugins", "softaculous-pro"),  
    "intro" => __("Filter your installed plugins list with Active, Inactive, Auto Updates Enabled or Disabled options", "softaculous-pro"),
    "position" => "bottom",
);

$spro_tour_content['plugins']['#plugin-search-input'] = array(
    "title" => __("Search Installed Plugins", "softaculous-pro"),  
    "intro" => __("Search a plugin from the installed plugins list.", "softaculous-pro"),
    "position" => "bottom",
);

////////////////////////////
// Themes Page
//////////////////////////// 

$spro_tour_content['themes']['#menu-appearance'] = array(
    "title" => __("Themes", "softaculous-pro"),
    "intro" => __("Click here to add or manage themes on your site.", "softaculous-pro"),  
    "position" => "right", 
);

$spro_tour_content['themes']['.page-title-action'] = array(
    "title" => __("Add New Theme", "softaculous-pro"),  
    "intro" => __("Here you can search wordpress.org themes library or upload a custom theme file to install a new theme on your site.", "softaculous-pro"),
    "position" => "bottom", 
);

$spro_tour_content['themes']['.theme-browser'] = array(
    "title" => __("Installed Themes List", "softaculous-pro"),  
    "intro" => __("All your installed themes active as well as inactive will be listed here.", "softaculous-pro"),  
    "position" => "right", 
);

$spro_tour_content['themes']['.theme.active[data-slug]'] = array(
    "title" => __("Active Theme", "softaculous-pro"),  
    "intro" => __("Your active theme will be listed here.", "softaculous-pro"),  
    "position" => "right", 
);

$spro_tour_content['themes']['.theme-actions'] = array(
    "title" => __("Theme Actions", "softaculous-pro"),  
    "intro" => __("You can perform actions for your theme like Activate, Live Preview, Customize and more", "softaculous-pro")
	.'<br /><br />'.
	__("It is recommended to delete themes that you do not plan to use and keep all your themes up to date.", "softaculous-pro"),  
    "position" => "bottom",
);

$spro_tour_content['themes']['.search-box'] = array(
    "title" => __("Search Installed Themes", "softaculous-pro"),  
    "intro" => __("Search a theme from the installed themes list.", "softaculous-pro"),
    "position" => "bottom",
);

////////////////////////////
// WordPress Dashboard Page
////////////////////////////

$spro_tour_content['dashboard']['#menu-dashboard'] = array(
    "title" => __("Dashboard", "softaculous-pro"),  
    "intro" => __("The Dashboard is your website's command center, providing a concise summary of its activity, such as site health, recent updates, comments, and statistics.", "softaculous-pro")
	.'<br /><br />'.
	__("Several plugins also display quick summary like orders, products, etc within the dashboard.", "softaculous-pro"),  
    "position" => "right", 
);

$spro_tour_content['dashboard']['#dashboard_site_health'] = array(
    "title" => __("Site Health", "softaculous-pro"),  
    "intro" => __("Here you can get insights on the overall performance and security of your website.", "softaculous-pro")
	.'<br /><br />'.
	__("It offers recommendations and troubleshooting tools to help you maintain an efficient and secure site.", "softaculous-pro"),  
    "position" => "right", 
);

$spro_tour_content['dashboard']['#dashboard_right_now'] = array(
    "title" => __("Info at a Glance", "softaculous-pro"),  
    "intro" => __("Here you will get the number of posts, pages, comments, current version of WordPress and theme that you are running.", "softaculous-pro"),
    "position" => "right", 
);

$spro_tour_content['dashboard']['#dashboard_activity'] = array(
    "title" => __("Activity", "softaculous-pro"),  
    "intro" => __("Here you will get a quick summary of recent activity like published posts and comments received on your site.", "softaculous-pro"),  
    "position" => "right", 
);


$spro_tour_content['dashboard']['#dashboard_quick_press'] = array(
    "title" => __("Quick Draft", "softaculous-pro"),  
    "intro" => __("Use this section for capturing ideas as they come to you, quickly jot down the ideas for new posts.", "softaculous-pro")
	.'<br /><br />'.
	__("You can later access these drafts from the Posts section and continue editing them in the full post editor.", "softaculous-pro"),
    "position" => "left", 
);


$spro_tour_content['dashboard']['#dashboard_primary'] = array(
    "title" => __("Events and News", "softaculous-pro"),  
    "intro" => __("This widget is a valuable resource for staying informed about the latest happenings in the WordPress community and connecting with other WordPress enthusiasts.", "softaculous-pro")
	.'<br /><br />'.
	__("Here you will find updates on new releases, upcoming features, security updates, and general news about the WordPress community.", "softaculous-pro")
	.'<br /><br />'.
	__("This section also shows upcoming WordPress events such as WordCamps, local meetups, and other community gatherings.", "softaculous-pro"),
    "position" => "left", 
);


$spro_tour_content['dashboard']['#screen-options-link-wrap'] = array(
    "title" => __("Screen Options", "softaculous-pro"),  
    "intro" => __("This useful feature allows you to select the screen elements that you would like to show or hide by using the checkboxes.", "softaculous-pro")
	.'<br /><br />'.
	__("You will find this option on several pages across your site.", "softaculous-pro"),
    "position" => "bottom", 
);

////////////////////////////
// Users Page
////////////////////////////

$spro_tour_content['users']['#menu-users'] = array(
    "title" => __("Users", "softaculous-pro"),  
    "intro" => __("Click here to add or manage users on your site.", "softaculous-pro"),  
    "position" => "right", 
);

$spro_tour_content['users']['.page-title-action'] = array(
    "title" => __("Add New User", "softaculous-pro"),  
    "intro" => __("Add a new user for your site. You can enter user details, password, role, etc.", "softaculous-pro"),
    "position" => "bottom",
);

$spro_tour_content['users']['tbody > tr'] = array(
    "title" => __("Users List", "softaculous-pro"),  
    "intro" => __("All your users with admin role as well as other roles will be listed here.", "softaculous-pro"),  
    "position" => "bottom", 
);

$spro_tour_content['users']['tbody > tr > td'] = array(
	"title" => __("Edit User", "softaculous-pro"),
	"intro" => __("You can edit the user information, change password, change role and much more with the Edit link here.", "softaculous-pro"),
	"position" => "bottom",
	"hover" => "true",
	"hover_selector" => ".row-actions",
	"hover_class" => "visible",
);

$spro_tour_content['users']['#bulk-action-selector-top'] = array(
    "title" => __("Bulk Actions", "softaculous-pro"),  
    "intro" => __("Choose bulk action for selected users: Delete or send password reset link", "softaculous-pro"), 
    "position" => "bottom", 
);

$spro_tour_content['users']['#new_role'] = array(
    "title" => __("Change Role", "softaculous-pro"),  
    "intro" => __("Here you can bulk change role for the selected users", "softaculous-pro"),  
    "position" => "bottom", 
);

$spro_tour_content['users']['.subsubsub'] = array(
    "title" => __("Filter Users", "softaculous-pro"),  
    "intro" => __("Filter your users list with their roles", "softaculous-pro"),
    "position" => "bottom",
);

$spro_tour_content['users']['.search-box'] = array(
    "title" => __("Search Users", "softaculous-pro"),  
    "intro" => __("Search a user from the users list.", "softaculous-pro"),
    "position" => "bottom",
);

////////////////////////////
// Posts Page
////////////////////////////

$spro_tour_content['posts']['#menu-posts'] = array(
    "title" => __("Posts", "softaculous-pro"),  
    "intro" => __("Click here to add or manage blog posts on your site.", "softaculous-pro"),  
    "position" => "right", 
);

$spro_tour_content['posts']['.page-title-action'] = array(
    "title" => __("Add New Post", "softaculous-pro"),  
    "intro" => __("Start writing a new blog post for your site.", "softaculous-pro"),
    "position" => "bottom",
);

$spro_tour_content['posts']['tbody > tr'] = array(
    "title" => __("Posts List", "softaculous-pro"),  
    "intro" => __("All the posts owned by all the users on your site will be listed here.", "softaculous-pro"),  
    "position" => "bottom", 
);

$spro_tour_content['posts']['tbody > tr > td'] = array(
    "title" => __("Manage Post", "softaculous-pro"),  
    "intro" => __("You can view, edit or delete the posts with the links here.", "softaculous-pro"),
    "position" => "bottom",
    "hover" => "true",
    "hover_selector" => ".row-actions",
    "hover_class" => "visible"
);

$spro_tour_content['posts']['#bulk-action-selector-top'] = array(
    "title" => __("Bulk Actions", "softaculous-pro"),  
    "intro" => __("Choose bulk action for selected posts: Quick Edit or Move to Trash.", "softaculous-pro"), 
    "position" => "bottom", 
);

$spro_tour_content['posts']['#filter-by-date'] = array(
    "title" => __("Filter Posts by Date", "softaculous-pro"),  
    "intro" => __("Here you can filter the posts by date.", "softaculous-pro"),  
    "position" => "bottom", 
);

$spro_tour_content['posts']['#cat'] = array(
    "title" => __("Filter Posts by Category", "softaculous-pro"),  
    "intro" => __("Here you can filter the posts by category.", "softaculous-pro"),  
    "position" => "bottom", 
);

$spro_tour_content['posts']['.subsubsub'] = array(
    "title" => __("Filter Posts", "softaculous-pro"),  
    "intro" => __("Filter your posts list by their status like published, drafts, trash, etc.", "softaculous-pro"),
    "position" => "bottom",
);

$spro_tour_content['posts']['.search-box'] = array(
    "title" => __("Search Posts", "softaculous-pro"),  
    "intro" => __("Search a post from the posts list.", "softaculous-pro"),
    "position" => "bottom",
);

////////////////////////////
// Pages Page
////////////////////////////

$spro_tour_content['pages']['#menu-pages'] = array(
    "title" => __("Pages", "softaculous-pro"),  
    "intro" => __("Click here to add or manage pages on your site.", "softaculous-pro"),  
    "position" => "right", 
);

$spro_tour_content['pages']['.page-title-action'] = array(
    "title" => __("Add New Page", "softaculous-pro"),  
    "intro" => __("Start creating a new page for your site.", "softaculous-pro"),
    "position" => "bottom",
);

$spro_tour_content['pages']['tbody > tr'] = array(
    "title" => __("Pages List", "softaculous-pro"),  
    "intro" => __("All the pages on your site will be listed here.", "softaculous-pro"),
    "position" => "bottom", 
);

$spro_tour_content['pages']['tbody > tr > td'] = array(
    "title" => __("Manage Page", "softaculous-pro"),  
    "intro" => __("You can view, edit or delete the pages with the links here.", "softaculous-pro"),
    "position" => "bottom",
    "hover" => "true",
    "hover_selector" => ".row-actions",
    "hover_class" => "visible"
);

$spro_tour_content['pages']['#bulk-action-selector-top'] = array(
    "title" => __("Bulk Actions", "softaculous-pro"),  
    "intro" => __("Choose bulk action for selected pages: Quick Edit or Move to Trash.", "softaculous-pro"), 
    "position" => "bottom", 
);

$spro_tour_content['pages']['#filter-by-date'] = array(
    "title" => __("Filter Pages by Date", "softaculous-pro"),  
    "intro" => __("Here you can filter the pages by date.", "softaculous-pro"),  
    "position" => "bottom", 
);

$spro_tour_content['pages']['.subsubsub'] = array(
    "title" => __("Filter Pages", "softaculous-pro"),  
    "intro" => __("Filter your pages list by their status like published, drafts, trash, etc.", "softaculous-pro"),
    "position" => "bottom",
);

$spro_tour_content['pages']['.search-box'] = array(
    "title" => __("Search Pages", "softaculous-pro"),  
    "intro" => __("Search a page from the pages list.", "softaculous-pro"),
    "position" => "bottom",
);

PK��f\ku��[#[#ai.phpnu�[���<?php

namespace SoftWP;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT');
}

class AI{

	static function enqueue_scripts(){
		
		global $softaculous_pro;

		wp_enqueue_style('softaculous-pro-ai', SOFTACULOUS_PRO_PLUGIN_URL . '/assets/css/ai.css', [], SOFTACULOUS_PRO_VERSION);

		wp_enqueue_script('softaculous_ai_base', SOFTACULOUS_PRO_PLUGIN_URL . 'assets/js/ai/ai.js', ['jquery'], SOFTACULOUS_PRO_VERSION, ['strategy' => 'defer']);

		$soft_ai = [
			'i18n' => [],
			'nonce' => wp_create_nonce('softaculous_ai_nonce'),
			'ajax_url' => admin_url('admin-ajax.php'),
			'ai_icon_url' => SOFTACULOUS_PRO_PLUGIN_URL .'/assets/images/softaculous-ai.svg',
			'buy' => esc_url(SOFTACULOUS_PRO_AI_BUY.'&softwp_lic='.$softaculous_pro['license']['license'])
		];
		
		$tokens = get_option('softaculous_ai_tokens', []);
		if(!empty($tokens)){
			$soft_ai['tokens'] = $tokens;
		}

		wp_localize_script('softaculous_ai_base', 'soft_ai', $soft_ai);
		
		// Loading the assets data
		$asset_file = [];
		$asset_file = include_once(SOFTACULOUS_PRO_PLUGIN_PATH . 'assets/js/ai/build/index.asset.php');
		if(is_array($asset_file)){
			array_push($asset_file['dependencies'], 'softaculous_ai_base'); // Adding the ai base js dep
		}

		wp_enqueue_script(
			'softaculous_ai_gb',
			SOFTACULOUS_PRO_PLUGIN_URL . 'assets/js/ai/build/index.js', // Load from the build directory
			$asset_file['dependencies'],
			$asset_file['version'],
			['strategy' => 'defer']
		);	
		
		// The API provides better output as markdown compared to html, thats why we need this markdown library to convert the markdown to html.
		wp_enqueue_script(
			'softaculous_ai_marked',
			SOFTACULOUS_PRO_PLUGIN_URL . 'assets/js/marked.min.js',
			array('softaculous_ai_base'),
			SOFTACULOUS_PRO_VERSION,
			['strategy' => 'defer']
		);
	}
	
	static function generate(){
		global $softaculous_pro, $softaculous_pro_settings;
		
		check_admin_referer('softaculous_ai_nonce', 'nonce');
		
		if(!current_user_can('manage_options')){
			wp_send_json_error(__('You do not have required privilege', 'softaculous-pro'));
		}
		
		set_time_limit(100);
		
		$content = !empty($_REQUEST['content']) ? wp_kses_post(wp_unslash($_REQUEST['content'])) : '';
		$prompt = !empty($_REQUEST['prompt']) ? wp_kses_post(wp_unslash($_REQUEST['prompt'])) : '';
		$shortcut = !empty($_REQUEST['shortcut']) ? sanitize_text_field(wp_unslash($_REQUEST['shortcut'])) : '';
		$license = !empty($softaculous_pro['license']['license']) ? $softaculous_pro['license']['license'] : '';

		if(empty($license)){
			wp_send_json_error(__('Please link a license to keep using the AI feature', 'softaculous-pro'));
		}
		
		// We need atleast a prompt or a shortcut
		if(empty($prompt) && empty($shortcut)){
			wp_send_json_error(__('Please write a Prompt, for the AI to generate content', 'softaculous-pro'));
		}
		
		// Shortcut requires content, but a prompt does not,
		// shortcuts are meant to be used to process content,
		// where as a Prompt can be used to process as well as generate content.
		if(!empty($shortcut) && empty($content)){
			wp_send_json_error(__('AI shortcut can not be applied without any content.', 'softaculous-pro'));
		}

		$res = wp_remote_post(SOFTACULOUS_PRO_AI_API, [
			'timeout' => 90,
			'body' => [
				'prompt' => $prompt,
				'shortcut' => $shortcut,
				'content' => $content,
				'license' => $license,
				'url' => site_url()
			]
		]);

		if(empty($res)){
			wp_send_json_error(__('Unable to complete this request', 'softaculous-pro'));
		}
		
		if(is_wp_error($res)){
			$error_string = $res->get_error_message();
			wp_send_json_error($error_string);
		}

		$res_code = wp_remote_retrieve_response_code($res);
		$body = wp_remote_retrieve_body($res);
		
		if(empty($body)){
			wp_send_json_error(__('The AI API responsed with empty response, Response Code:', 'softaculous-pro') . $res_code);
		}

		$ai_content = json_decode($body, true);

		if($res_code > 299){
			$error = !empty($ai_content['error']) ? sanitize_text_field($ai_content['error']) : __('Unexpected response code returned from AI API: ', 'softaculous-pro') . $res_code;
			
			wp_send_json_error($error);
		}

		// Building the history data
		if(!isset($ai_content['error']) && isset($softaculous_pro_settings['ai_history_duration']) && $softaculous_pro_settings['ai_history_duration'] > 0 && !empty($ai_content['ai'])){
			$history_data = [];
			if(!empty($content)){
				$history['content'] = wp_kses_post(wp_unslash($content));
				$title = (strlen($content) > 100 ? substr($content, 100) : $content);
			}

			if(!empty($prompt)){
				$history['prompt'] = wp_kses_post(wp_unslash($prompt));
				$title = (strlen($prompt) > 100 ? substr($prompt, 100) : $prompt);
			}

			if(empty($prompt) && !empty($shortcut)){
				$history['shortcut'] = sanitize_text_field($shortcut);
				$title = self::parse_shortcuts($shortcut);
			}

			if(!empty($ai_content['ai'])){
				$history['assistant'] = wp_kses_post(wp_unslash($ai_content['ai']));
			}
			
			if(!empty($ai_content['total_tokens'])){
				$title .= '|||'.$ai_content['total_tokens'];
			}

			// Saving the history
			wp_insert_post([
				'post_title' => sanitize_text_field($title),
				'post_type' => 'spro_ai_history',
				'post_content' => serialize($history),
			]);
		}

		// Saving token data
		if(!empty($ai_content['remaining_tokens'])){
			update_option('softaculous_ai_tokens', [
				'remaining_tokens' => sanitize_text_field($ai_content['remaining_tokens'])
			], false);
		}
		
		wp_send_json_success($ai_content);

	}
	
	static function load_history(){
		check_admin_referer('softaculous_ai_nonce', 'nonce');

		if(!current_user_can('manage_options')){
			wp_send_json_error(__('You do not have required privilege', 'softaculous-pro'));
		}
		
		$history_id = !empty($_POST['history_id']) ? sanitize_text_field(wp_unslash($_POST['history_id'])) : 0;
		$offset = !empty($_POST['offset']) ? (int) sanitize_text_field(wp_unslash($_POST['offset'])) : 0;
		$history = [];
		
		if(!empty($history_id)){
			$query = new \WP_Query([
				'post_type' => ['spro_ai_history'],
				'page_id' => $history_id,
			]);
			
			if($query->have_posts()){
				while($query->have_posts()){
					$query->the_post();
					$history = unserialize(get_the_content());
				}
			}
			
			// Restore to original post
			wp_reset_postdata();
			wp_send_json_success($history);
			
		} else {
			$query = new \WP_Query([
				'post_type' => ['spro_ai_history'],
				'posts_per_page' => 20,
				'offset' => $offset,
				'orderby' => 'date',
				'order' => 'DESC',
			]);
		}

		if($query->have_posts()){
			while($query->have_posts()){
				$query->the_post();
				$single['token_used'] = 0;
				$single['title'] = get_the_title();
				$single['date'] = get_the_date();
				$single['id'] = get_the_ID();
				
				if(strpos($single['title'], '|||') !== FALSE) {
					$get_count = explode('|||', $single['title']);
					$single['title'] = $get_count[0];
					$single['token_used'] = $get_count[1];
				}

				array_push($history, $single);
			}
		}
		
		// Restore to original post
		wp_reset_postdata();
		
		$total_count = wp_count_posts('spro_ai_history')->draft; // Getting the total count
		wp_send_json_success(['history' => $history , 'total' => $total_count]);
	}
	
	static function parse_shortcuts($shortcut){
		$supported_languages = ['arabic', 'chinese', 'czech', 'danish', 'dutch', 'english', 'finnish', 'french', 'german', 'greek', 'hindi', 'hebrew', 'hungarian', 'indonesian', 'italian', 'japanese', 'korean', 'marathi', 'punjabi', 'persian', 'polish', 'portuguese', 'russian', 'spanish', 'swedish', 'thai', 'turkish', 'vietnamese'];
		$supported_tones = ['casual', 'confidence', 'formal', 'friendly', 'inspirational', 'motivational', 'nostalgic', 'playful', 'professional', 'scientific', 'straightforward', 'witty'];
		$other_shortcuts = ['shorter' => 'Make it shorter', 'longer' => 'Make it longer', 'simplify' => 'Simplify the language', 'grammar' => 'Fix Spelling and Grammar'];
		
		if(in_array($shortcut, $supported_languages)){
			return 'Translate to ' . ucfirst($shortcut);
		}
		
		if(in_array($shortcut, $supported_tones)){
			return 'Change the tone of the content to ' . ucfirst($shortcut);
		}
		
		if(array_key_exists($shortcut, $other_shortcuts)){
			return $other_shortcuts[$shortcut];
		}

		return $shortcut;
	}
	
	static function delete_history($delete_all = false){

		$settings = get_option('softaculous_pro_settings', []);
		$history_duration = (int) $settings['ai_history_duration'];

		// If it is off then we wont delete the history.
		if($history_duration < 1){
			return;
		}

		$x_days_ago = date('Y-m-d', strtotime('-'.$history_duration.' days'));

		$query = new \WP_Query([
			'post_type' => 'spro_ai_history',
			'post_status' => 'draft',
			'date_query'=> [
				[
					'column' => 'post_date',
					'before' => $x_days_ago,
				],
			],
			'posts_per_page' => 100,
		]);

		if($query->have_posts()){
			while($query->have_posts()){
				$query->the_post();
				wp_delete_post(get_the_ID(), true);
			}

			wp_reset_postdata();
		}
	}
	
}
PK��f\Y����manage-plugins.phpnu�[���<?php

//////////////////////////////////////////////////////////////
//===========================================================
// license.php
//===========================================================
// softaculous-pro
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date:	   12 Sep 2024
// Time:	   23:00 hrs
// Site:	   https://www.softaculous.com/
// ----------------------------------------------------------
// Please Read the Terms of use at http://softaculous.com/
// ----------------------------------------------------------
//===========================================================
// (c)softaculous Team
//===========================================================
//////////////////////////////////////////////////////////////

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

if(defined('SOFTACULOUS_PRO_VERSION')) {
	return;
}

function softaculous_pro_manage_plugins(){
	
	global $spro_error;
	
	softaculous_pro_header(0);
	
	include_once(SOFTACULOUS_PRO_PLUGIN_PATH.'main/onboarding.php');
	$spro_manage_features = spro_get_features_list();
	
	$manage_installed_plugins = get_plugins();
	
	if(!empty($softaculous_pro_error)){
		echo '<div id="message" class="error"><p>'.esc_html($softaculous_pro_error).'</p></div>';
	}
	
	if(!empty($softaculous_pro_msg)){
		echo '<div id="message" class="updated"><p>'.esc_html($softaculous_pro_msg).'</p></div>';
	}
	
	echo '
	<div class="spro-box-heading"><h3 class="smb-2 spb-1 sml-2">
		'.__('Manage Plugins', 'softaculous-pro').'</h3>
		<hr />
		<br />
	</div>
	
	<div class="spro-container">
	<div class="srow">';
		foreach($spro_manage_features as $feature => $info){
			foreach($info['plugin'] as $pslug => $data){
				
				if(empty($data['featured'])) continue;
				
				$disabled = '';
				if (!empty($data['requires_php']) && version_compare(PHP_VERSION, $data['requires_php'], '<')) {
					$data['plugin_desc'] .= '<br><span style="color: red;">'.sprintf(__('Requires PHP version %1$s or higher', 'softaculous-pro'), $data['requires_php']).'</span>';
					$disabled ='disabled';
				}
				
				echo '
				<div class="scol-6 spro-box-holder">
				<div class="spro-mng-plugin-header spx-2">
					<img src="'.(!empty($data['plugin_img']) ? $data['plugin_img'] : SOFTACULOUS_PRO_PLUGIN_URL.'/assets/images/plugins/'.$pslug.'.png').'" width="50" />
					<div class="spro-plugin-info-con sp-2">
						<div class="spro-manage-plugin-title spx-2">'.$data['plugin_name'].'</div>
						<div class="sp-2 spro-manage-plugin-desc">'.$data['plugin_desc'].'</div>
					</div>
				</div>
				<div class="spro-rec-plugin spx-2 smy-1">';
				
				$i_pending = $a_pending = 0;
				if(!empty($data['plugin_init'])){
				
					if(empty($manage_installed_plugins[$data['plugin_init']])){
						$status_free = __('Not Installed', 'softaculous-pro');
						$i_pending = 1;
					}elseif(!is_plugin_active($data['plugin_init'])){
						$status_free = __('Installed', 'softaculous-pro');
						$a_pending = 1;
					}else{
						$status_free = __('Active', 'softaculous-pro');
					}
				
					echo '<span class="spro-status"><b>'.__('Free', 'softaculous-pro').'</b>: '.$status_free.'</span>';
					
				}
				
				if(!empty($data['plugin_init_pro'])){
				
					if(empty($manage_installed_plugins[$data['plugin_init_pro']])){
						$status_pro = __('Not Installed', 'softaculous-pro');
						$i_pending = 1;
					}elseif(!is_plugin_active($data['plugin_init_pro'])){
						$status_pro = __('Installed', 'softaculous-pro');
						$a_pending = 1;
					}else{
						$status_pro = __('Active', 'softaculous-pro');
					}
				
					echo '<br /><span class="spro-status"><b>'.__('Pro', 'softaculous-pro').'</b>: '.$status_pro.'</span>';
				}
				
				echo '<span style="float:right;">';
				if(!empty($i_pending)){
					echo '<input type="button" name="'.$pslug.'" class="spro-plugin-install-btn sp-2" value="'.__('Install for Free', 'softaculous-pro').'" '.$disabled.'>';
				}elseif(!empty($a_pending)){
					echo '<input type="submit" name="'.$pslug.'" class="spro-plugin-install-btn spro-active-plugin sp-2" value="'.__('Activate', 'softaculous-pro').'" '.$disabled.'>';
				}else{
					echo '<p class="spro-plugin-active"><i class="fa-solid fa-check"></i>&nbsp;'.__('Active', 'softaculous-pro').'</p>';
				}
				echo '</span>';
				
				
				echo '
				</div>
				<i style="color:green;" class="spl-2">'.__('Pro included with your subscription', 'softaculous-pro').'</i>
				</div>';
			}
	}
	echo '
	</div>
	</div>';
	softaculous_pro_footer();
	
}
PK��f\5?3&����onboarding.phpnu�[���<?php

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

add_action('admin_print_styles', 'softaculous_pro_admin_print_styles');
function softaculous_pro_admin_print_styles() {
	
	$act = softaculous_pro_optGET('act');
	$page = softaculous_pro_optGET('page');
	
	// Check if the current page is the onboarding wizard
	if($page == 'assistant' && $act == 'onboarding'){
		echo '<style>
			#adminmenuback, #adminmenuwrap, #wpadminbar  { display: none !important; }
		</style>';
	}
}

add_action('admin_menu', 'softaculous_pro_onboarding_admin_menu', 6);
function softaculous_pro_onboarding_admin_menu() {

	$capability = 'activate_plugins';
	
	// Onboarding
	//add_submenu_page('assistant', __('Onboarding', 'softaculous-pro'), __('Onboarding', 'softaculous-pro'), $capability, 'softaculous_pro_onboarding', 'softaculous_pro_page_handler');
	
	$act = softaculous_pro_optGET('act');
	$page = softaculous_pro_optGET('page');
	
	// Check if the current page is the onboarding wizard
	if($page == 'assistant' && $act == 'onboarding'){
		// Remove admin menu
		remove_menu_page('index.php'); // Dashboard
		remove_menu_page('edit.php'); // Posts
		remove_menu_page('upload.php'); // Media
		remove_menu_page('edit.php?post_type=page'); // Pages
		remove_menu_page('edit-comments.php'); // Comments
		remove_menu_page('themes.php'); // Appearance
		remove_menu_page('plugins.php'); // Plugins
		remove_menu_page('users.php'); // Users
		remove_menu_page('tools.php'); // Tools
		remove_menu_page('options-general.php'); // Settings
		add_filter('show_admin_bar', '__return_false');
		remove_filter('update_footer', 'core_update_footer');
		add_filter('screen_options_show_screen', '__return_false');
		add_filter('admin_footer_text', '__return_empty_string');
		remove_all_actions( 'admin_notices' );
		remove_all_actions( 'all_admin_notices');
	}

}

// Add the action to load the plugin 
add_action('plugins_loaded', 'softaculous_pro_onboarding_load_plugin');

// The function that will be called when the plugin is loaded
function softaculous_pro_onboarding_load_plugin(){

	global $pagelayer, $softaculous_pro;
	
	add_action('admin_enqueue_scripts', 'softaculous_pro_onboarding_enqueue_scripts');

	/* // Load the freemium widgets
	if(!defined('PAGELAYER_PREMIUM')){
		add_action('pagelayer_load_custom_widgets', 'spro_freemium_shortcodes');
	} */
	
	// Are we to setup a template ?
	$slug = get_option('softaculous_pro_setup_template');
	if(!empty($slug)){
		add_action('after_setup_theme', 'spro_setup_template_import');
	}

}

function softaculous_pro_onboarding_enqueue_scripts(){	
			
	$softwp_onboarding_lang = array(
		'conf_data_loss' => __( 'Please confirm that you accept data loss since you have already run the onboarding process previously', 'softaculous-pro' ),
		'select_atleast_one' => __( 'Please select atleast one page to import', 'softaculous-pro' ),
		'downloading_installing_plugins' => __( "Downloading and installing required plugins", 'softaculous-pro' ),
		'wordpress_require_ftp' => __( "WordPress requires FTP details, without them you won't be able to install a plugin/theme", 'softaculous-pro' ),		
		'downloading_template' => __( "Downloading the template", 'softaculous-pro' ),
		'buildWebsite' => __( 'Building your website...', 'softaculous-pro' ),
		'checkRequirements' => __( 'Checking the requirements ...', 'softaculous-pro' ),
		'importTemplate' => __( 'Importing the template', 'softaculous-pro' ),
		'setupCompleted' => __( 'Your website setup is completed', 'softaculous-pro' ),
		'congratulations' => __( 'Congratulations', 'softaculous-pro'),
	);

	if(!empty($_GET['act']) && $_GET['act'] === 'onboarding') {
		
		wp_enqueue_script('softaculous-pro-script-onboarding', SOFTACULOUS_PRO_PLUGIN_URL . '/assets/js/onboarding.js', array('jquery'), SOFTACULOUS_PRO_VERSION, false);
		wp_localize_script('softaculous-pro-script-onboarding', 'softwp_onboarding_lang', $softwp_onboarding_lang);
		
		wp_enqueue_style( 'softaculous-pro-style-onboarding', SOFTACULOUS_PRO_PLUGIN_URL . '/assets/css/onboarding.css', [], SOFTACULOUS_PRO_VERSION, 'all' );
		
		wp_enqueue_style( 'softaculous-pro-style-font-awesome', SOFTACULOUS_PRO_PLUGIN_URL . '/assets/font-awesome/css/all.min.css', [], SOFTACULOUS_PRO_VERSION, 'all' );
	}
}

function spro_get_features_list(){
	
    $features_list = array(
        
		"seo" => array(
		"name" => __('Increase Website Traffic (SEO)','softaculous-pro'),
		"info" => __("Improve your site's ranking on search engines","softaculous-pro"),
		"icon" => 'dashicons dashicons-chart-bar',
		"plugin"=> array(
			"siteseo" => array(
				"plugin_name" => __("SiteSEO – One Click SEO for WordPress","softaculous-pro"),
				"plugin_url"=> "https://siteseo.io/",
				'plugin_init' => 'siteseo/siteseo.php',
				'plugin_download_url' => softaculous_pro_api_url(0, 'siteseo').'files/versions/latest-stable-free.zip',
				'plugin_init_pro' => 'siteseo-pro/siteseo-pro.php',
				'plugin_download_url_pro' => softaculous_pro_api_url(0, 'siteseo').'download.php',
				'plugin_desc' => __('Boost your website\'s search rankings today with the most powerful WordPress SEO plugin. Its lightweight, optimized, and delivers exceptional performance.', 'softaculous-pro'),
				'pro' => 1,
				'featured' => 1,
				'requires_php' => 7.2,
                ),
            )
        ),
		
        "speedycache" => array(
            "name" => __("Improve Page Speed","softaculous-pro"),
            "info" => __("Improve speed by cache, minify, compress", 'softaculous-pro'),
            "icon" => "fa-solid fa-gauge-high",
            "plugin"=> array(
                "speedycache" => array(
                    "plugin_name" => __("SpeedyCache – Cache, Optimization, Performance","softaculous-pro"),
                    "plugin_url"=> "https://wordpress.org/plugins/speedycache/",
					'plugin_init' => 'speedycache/speedycache.php',
					'plugin_init_pro' => 'speedycache-pro/speedycache-pro.php',
					'plugin_download_url_pro' => softaculous_pro_api_url(0, 'speedycache').'download.php',
					'plugin_desc' => __('SpeedyCache is an easy to use and powerful WordPress Cache Plugin, it helps you reduce page load time improving User Experience and boosting your Google PageSpeed.', 'softaculous-pro'),
					'pro' => 1,
					'featured' => 1,
					'requires_php' => 7.3,
                ),
            )
        ),
		
        "backuply" => array(
            "name" => __("Schedule Backups","softaculous-pro"),
            "info" => __("Backup your site on local or remote servers","softaculous-pro"),
            "icon" => "fa-regular fa-file-zipper",
            "plugin"=> array(
                "backuply" => array(
                    "plugin_name" => __("Backuply – Backup, Restore, Migrate and Clone","softaculous-pro"),
                    "plugin_url"=> "https://wordpress.org/plugins/backuply/",
					'plugin_init' => 'backuply/backuply.php',
					'plugin_init_pro' => 'backuply-pro/backuply-pro.php',
					'plugin_download_url_pro' => softaculous_pro_api_url(0, 'backuply').'download.php',
					'plugin_desc' => __('Backuply is a WordPress backup plugin that helps you backup your WordPress website, saving you from loss of data because of server crashes, hacks, dodgy updates, or bad plugins.', 'softaculous-pro'),
					'pro' => 1,
					'featured' => 1,
					'requires_php' => 5.5,
                ),
            )
        ),
        
		"sell_products" => array(
            "name" => __("Sell Products","softaculous-pro"),
            "info" => __("Sell physical or digital products","softaculous-pro"),
            "icon" => "fa-solid fa-tag",
            "plugin"=> array(
                "woocommerce" => array(
                    "plugin_name" => __("WooCommerce","softaculous-pro"),
                    "plugin_url"=> "https://wordpress.org/plugins/woocommerce/",
					'plugin_init' => 'woocommerce/woocommerce.php',
                ),
            )
        ),
		
        "loginizer" => array(
            "name" => __("Limit Login Attempts","softaculous-pro"),
            "info" => __("Brute force protection, 2FA, login captcha", 'softaculous-pro'),
            "icon" => "fa-solid fa-user-lock",
            "plugin"=> array(
                "loginizer" => array(
                    "plugin_name" => __("Loginizer","softaculous-pro"),
                    "plugin_url"=> "https://wordpress.org/plugins/loginizer/",
					'plugin_init' => 'loginizer/loginizer.php',
					'plugin_init_pro' => 'loginizer-security/loginizer-security.php',
					'plugin_download_url_pro' => softaculous_pro_api_url(0, 'loginizer').'download.php',
					'plugin_desc' => __('Loginizer is a simple and effortless solution that takes care of all your security problems. It comes with default optimal configuration to protect your site from Brute Force attacks.', 'softaculous-pro'),
					'pro' => 1,
					'featured' => 1,
					'requires_php' => 5.5,
                ),
            )
        ),
		
        "pagelayer" => array(
            "name" => __("Page Builder","softaculous-pro"),
            "info" => __("Page Builder, Drag and Drop website builder", 'softaculous-pro'),
            "icon" => "fa-solid fa-paintbrush",
            "plugin"=> array(
                "pagelayer" => array(
                    "plugin_name" => __("Pagelayer","softaculous-pro"),
                    "plugin_url"=> "https://wordpress.org/plugins/pagelayer/",
					'plugin_init' => 'pagelayer/pagelayer.php',
					'plugin_init_pro' => 'pagelayer-pro/pagelayer-pro.php',
					'plugin_download_url_pro' => softaculous_pro_api_url(0, 'pagelayer').'download.php',
					'plugin_desc' => __('Pagelayer is an awesome page builder that allows you to create and design your website instantly in the simplest way possible. Take control over your page content with the most advanced page builder plugin available.', 'softaculous-pro'),
					'pro' => 1,
					'featured' => 1,
					'requires_php' => 5.5,
                ),
            )
        ),
		
        "gosmtp" => array(
            "name" => __("Send Email with SMTP","softaculous-pro"),
            "info" => __("Providers: Gmail, Outlook, AWS SES & more", 'softaculous-pro'),
            "icon" => "fa-solid fa-envelope-circle-check",
            "plugin"=> array(
                "gosmtp" => array(
                    "plugin_name" => __("GoSMTP – SMTP for WordPress","softaculous-pro"),
                    "plugin_url"=> "https://wordpress.org/plugins/gosmtp/",
					'plugin_init' => 'gosmtp/gosmtp.php',
					'plugin_init_pro' => 'gosmtp-pro/gosmtp-pro.php',
					'plugin_download_url_pro' => softaculous_pro_api_url(0, 'gosmtp').'download.php',
					'plugin_desc' => __('GoSMTP allows you to send emails from your WordPress over SMTP or many popular outgoing email service providers. Using these improves your email deliverability.', 'softaculous-pro'),
					'pro' => 1,
					'featured' => 1,
					'requires_php' => 5.5,
                ),
            )
        ),
		
        "fileorganizer" => array(
            "name" => __("File Manager","softaculous-pro"),
            "info" => __("Manage files with drag & drop editor", 'softaculous-pro'),
            "icon" => "fa-regular fa-folder-open",
            "plugin"=> array(
                "fileorganizer" => array(
                    "plugin_name" => __("FileOrganizer – Manage WordPress and Website Files","softaculous-pro"),
                    "plugin_url"=> "https://wordpress.org/plugins/fileorganizer/",
					'plugin_init' => 'fileorganizer/fileorganizer.php',
					'plugin_init_pro' => 'fileorganizer-pro/fileorganizer-pro.php',
					'plugin_download_url_pro' => softaculous_pro_api_url(0, 'fileorganizer').'download.php',
					'plugin_desc' => __('FileOrganizer is a lightweight and easy-to-use file management plugin for WordPress. Organize and manage your WordPress files with FileOrganizer without any control panel or FTP access. ', 'softaculous-pro'),
					'pro' => 1,
					'featured' => 1,
					'requires_php' => 5.5,
                ),
            )
        ),
    );
	
	$features_list = apply_filters('softaculous_pro_features_list', $features_list);
	
	return $features_list;
}


function softaculous_pro_ajax_output($data){
	
	echo json_encode($data);
	
	wp_die();
	
}

function softaculous_pro_ajax_output_xmlwrap($data){
	
	echo '<softaculous-pro-xmlwrap>'.json_encode($data).'</softaculous-pro-xmlwrap>';
	
	wp_die();
}

function softaculous_pro_import_template($slug, $items = array()){
	global $pl_error;

	$data = [];
	
	$destination = popularfx_templates_dir(false).'/'.$slug;
	
	include_once(PAGELAYER_DIR.'/main/import.php');
	
	// Our function needs to efficiently replace the variables
	$GLOBALS['softaculous_pro_template_import_slug'] = $slug;	
	add_filter('pagelayer_start_insert_content', 'softaculous_pro_pagelayer_start_insert_content', 10);
	
	// Now import the template
	if(!pagelayer_import_theme($slug, $destination, $items)){
		$data['error']['import_err'] = __('Could not import the template !', 'softaculous-pro');
		$data['error'] = array_merge($data['error'], $pl_error);
		return $data;
	}
	
	// Save the name of the slug
	set_theme_mod('popularfx_template', $slug);
	
	// onboarding done
	update_option('softaculous_pro_onboarding_done', time());
	
	// Set default left menu folded
	//set_user_setting('mfold', 'f');
	
	$data['done'] = 1;
	
	return $data;
	
}

// Download the template
function softaculous_pro_download_template($slug){
	
	global $softaculous_pro, $pl_error;	

	set_time_limit(300);
	
	$data = [];

	// Now lets download the templates
	if(!function_exists( 'download_url' ) ) {
		require_once ABSPATH . 'wp-admin/includes/file.php';
	}
	
	$spro_setup_info = get_option('softaculous_pro_setup_info');
	
	$url = softaculous_pro_pfx_api_url().'/givetemplate.php?slug='.$spro_setup_info['theme_slug'].'&license='.@$softaculous_pro['license']['license'].'&url='.site_url();
	//echo $url;
	
	$popular_fx_dir = popularfx_templates_dir(false);
	$destination = $popular_fx_dir.'/'.$slug;

	// Check if FTP is required
	ob_start();
	$credentials = request_filesystem_credentials('');
	ob_end_clean();

	if(false === $credentials || !WP_Filesystem($credentials)){
		$data['error']['download'] = __('Theme template can only be uploaded using FTP !', 'softaculous-pro');
		return $data;
	}
	
	global $wp_filesystem;
	
	// For FTP have to use relative paths
	if(is_array($credentials)){
		$abspath_relative = $wp_filesystem->find_folder(ABSPATH);
		$replacer = str_replace($abspath_relative, '', ABSPATH);
		if($replacer !== ABSPATH){
			$popular_fx_dir = str_replace($replacer, '', $popular_fx_dir);
			$destination = str_replace($replacer, '', $destination);
		}
	}

	$tmp_file = download_url($url);
	//echo filesize($tmp_file);
	//var_dump($tmp_file);
	
	// Error downloading
	if(is_wp_error($tmp_file) || filesize($tmp_file) < 1){
		if(!empty($tmp_file->errors)){			
			$data['error']['download_err'] = __('Could not download the theme !', 'softaculous-pro').var_export($tmp_file->errors, true);
			return $data;
		}
	}
	
	$wp_filesystem->mkdir($popular_fx_dir);
	$wp_filesystem->mkdir($destination);
	//echo $destination;

	$ret = unzip_file($tmp_file, $destination);
	//r_print($ret);
	
	// Try to delete
	@unlink($tmp_file);
	
	// Error downloading
	if(is_wp_error($ret) || !file_exists($destination.'/style.css')){
		if(!empty($ret->errors)){
			$data['error']['download'] = __('Could not extract the template !', 'softaculous-pro').var_export($ret->errors, true);
			return $data;
		}
	}

	return $data;

}

// Get list of templates
function softaculous_pro_get_templates_list(){
	
	$data = get_transient('softaculous_pro_templates');

	// Get any existing copy of our transient data
	if(false === $data){
	
		// Start checking for an update
		$send_for_check = array(
			'timeout' => 90,
			'user-agent' => 'WordPress'		
		);
		
		$raw_response = wp_remote_post( softaculous_pro_pfx_api_url().'templates.json', $send_for_check );
		//pagelayer_print($raw_response);die();
	
		// Is the response valid ?
		if ( !is_wp_error( $raw_response ) && ( $raw_response['response']['code'] == 200 ) ){		
			$data = json_decode($raw_response['body'], true);
		}
		//pagelayer_print($data);die();
	
		// Feed the updated data into the transient
		if(!empty($data['list']) && count($data['list']) > 10){
			set_transient('softaculous_pro_templates', $data, 2 * HOUR_IN_SECONDS);
		}
		
	}
	
	return $data;
	
}

// Get the template info from our servers
function softaculous_pro_onboarding_dismiss(){

	// Some AJAX security
	check_ajax_referer('softaculous_pro_ajax', 'softaculous_pro_nonce');
	
	if(isset($_REQUEST['dismiss'])){
		update_option('softaculous_pro_onboarding_dismiss', time());
	}
	
	$data['done'] = 1;
	
	softaculous_pro_ajax_output($data);
	
}

// Get the template info from our servers
function softaculous_pro_ajax_template_info(){

	// Some AJAX security
	check_ajax_referer('softaculous_pro_ajax', 'softaculous_pro_nonce');
	
	$data = [];
	
	if(isset($_REQUEST['slug'])){		
		$resp = wp_remote_get(softaculous_pro_pfx_api_url().'template-info.php?slug='.$_REQUEST['slug'], array('timeout' => 30));
	
		// Is the response valid ?
		if ( !is_wp_error( $resp ) && ( $resp['response']['code'] == 200 ) ){		
			$data = json_decode($resp['body'], true);
		}
	}
		
	$setup_info = get_option('softaculous_pro_setup_info');
	$setup_info = !empty($setup_info) ? $setup_info : array();
	$setup_info['theme_slug'] = $_REQUEST['slug'];

	update_option('softaculous_pro_setup_info',$setup_info);
	
	softaculous_pro_ajax_output($data);
	
}

// Start the installation of the template
function softaculous_pro_ajax_start_install_template(){
	
	global $softaculous_pro;
	
	// Some AJAX security
	check_ajax_referer('softaculous_pro_ajax', 'softaculous_pro_nonce');

	set_time_limit(300);
	
	// Handling Access through FTP
	ob_start();
	// Check if FTP is required
	$have_credentials = request_filesystem_credentials('');

	if(false === $have_credentials){
		$form_html = ob_get_clean();
		$ftp_modal = '<div id="request-filesystem-credentials-dialog" class="notification-dialog-wrap request-filesystem-credentials-dialog">
		<div class="notification-dialog-background"></div>
		<div class="notification-dialog" role="dialog" aria-labelledby="request-filesystem-credentials-title" tabindex="0">
		<div class="request-filesystem-credentials-dialog-content">'. $form_html . '</div></div></div>';

		wp_send_json_error(['form' => $ftp_modal]);
	}

	ob_end_clean(); // Just in case there was any output till now it will be cleaned.

	$data = [];
	
	//pagelayer_print($_POST);die();
	$license = softaculous_pro_optPOST('softaculous_pro_license');
	
	// Check if its a valid license
	if(!empty($license)){
	
		$resp = wp_remote_get(softaculous_pro_api_url(1).'license.php?license='.$license.'&url='.rawurlencode(site_url()), array('timeout' => 30));
	
		if(is_array($resp)){
			$json = json_decode($resp['body'], true);
			//print_r($json);
		}else{
		
			$data['error']['resp_invalid'] = __('The response from the server was malformed. Please try again in sometime !', 'softaculous-pro').var_export($resp, true);
			softaculous_pro_ajax_output($data);
			
		}
	
		// Save the License
		if(empty($json['license'])){
		
			$data['error']['lic_invalid'] = __('The license key is invalid', 'softaculous-pro');
			softaculous_pro_ajax_output($data);
			
		}else{
			
			update_option('softaculous_pro_license', $json);
	
			// Load license
			spro_load_license();
			
		}
		
	}
	
	// Load templates
	$softaculous_pro['templates'] = softaculous_pro_get_templates_list();
	
	$slug = softaculous_pro_optPOST('theme');
	
	if(!defined('PAGELAYER_VERSION')){
		
		$res = spro_install_required_plugin('pagelayer', array('plugin_init' => 'pagelayer/pagelayer.php'));
		
		if(empty($res['success'])){
			$data['error']['pl_req'] = __('Pagelayer is required to use the templates !', 'softaculous-pro');
			softaculous_pro_ajax_output($data);
		}
	}
	
	if(!defined('PFX_VERSION')){
		
		$res = spro_install_required_plugin('popularfx-templates', array('plugin_init' => 'popularfx-templates/popularfx-templates.php', 'plugin_download_url' => softaculous_pro_api_url(0, 'popularfx').'update2.php?give=1'));
		
		if(empty($res['success'])){
			$data['error']['pl_req'] = __('PopularFX plugin is required to use the templates !', 'softaculous-pro');
			softaculous_pro_ajax_output($data);
		}
	}
	
	if(!function_exists('popularfx_templates_dir')){

		$res = spro_install_required_theme('popularfx');
		
		if(empty($res['success'])){
			$data['error']['pfx_req'] = __('PopularFX theme is required to use the templates !', 'softaculous-pro');
			softaculous_pro_ajax_output($data);
		}
		
	}
	
	if(empty($softaculous_pro['templates']['list'][$slug])){
		$data['error']['template_invalid'] = __('The template you submitted is invalid !', 'softaculous-pro');
		softaculous_pro_ajax_output($data);
	}
	
	$template = $softaculous_pro['templates']['list'][$slug];
	
	// Do we have the req PL version ?
	if(!empty($template['pl_ver']) && version_compare(PAGELAYER_VERSION, $template['pl_ver'], '<')){
		$data['error']['pl_ver'] = sprintf(__('Your Pagelayer version is %1$s while the template requires Pagelayer version higher than or equal to %2$s ', 'softaculous-pro'), PAGELAYER_VERSION, $template['pl_ver']);
		softaculous_pro_ajax_output($data);
	}
	
	// Do we have the req PL version ?
	if(version_compare(PAGELAYER_VERSION, '1.8.9', '<')){
		$data['error']['pl_ver'] = sprintf(__('Your Pagelayer version is %1$s while the onboarding requires Pagelayer version higher than or equal to 1.8.9', 'softaculous-pro'), PAGELAYER_VERSION);
		softaculous_pro_ajax_output($data);
	}
	
	// Do we have the req PFX Plugin version ?
	if(!empty($template['pfx_ver']) && version_compare(PFX_VERSION, $template['pfx_ver'], '<')){
		$data['error']['pfx_ver'] = sprintf(__('Your PopularFX Plugin version is %1$s while the template requires PopularFX version higher than or equal to %2$s', 'softaculous-pro'), PFX_VERSION, $template['pfx_ver']);
		softaculous_pro_ajax_output($data);
	}
	
	// Is it a pro template ?
	if($template['type'] > 1 && empty($softaculous_pro['license']['active'])){
		$data['error']['template_pro'] = sprintf(__('The selected template is a Pro template and you have a free or expired license. Please enter your license key %1$shere%2$s.', 'softaculous-pro'), 
			'<a href="'.admin_url('admin.php?page=assistant&act=license').'" target="_blank" style="color:blue;">',
			'</a>'
			);
		softaculous_pro_ajax_output($data);
	}
	
	$do_we_have_pro = defined('PAGELAYER_PREMIUM');
	
	// Do we need to install Pagelayer or Pagelayer PRO ?
	if(!function_exists('pagelayer_theme_import_notices') || (empty($do_we_have_pro) && $template['type'] > 1)){
		if($template['type'] > 1){
			$download_url = SOFTACULOUS_PRO_PAGELAYER_API.'download.php?version=latest&license='.$softaculous_pro['license']['license'].'&url='.rawurlencode(site_url());
			$installed = spro_install_required_plugin('pagelayer-pro', array('plugin_init' => 'pagelayer-pro/pagelayer-pro.php', 'plugin_download_url' => $download_url));
		}else{
			$installed = spro_install_required_plugin('pagelayer', array('plugin_init' => 'pagelayer/pagelayer.php'));
		}
		
		// Did we fail to install ?
		if(is_wp_error($installed) || empty($installed)){
			$install_url = admin_url('admin.php?page=softaculous_pro_install_pagelayer&license=').@$softaculous_pro['license']['license'];
			$data['error']['pagelayer'] = sprintf(__('There was an error in installing Pagelayer which is required by this template. Please install Pagelayer manually by clicking %1$shere%2$s and then install the template !', 'softaculous-pro'), '<a href="%1$s" target="_blank">'.$install_url, '</a>');
			if(!empty($installed->errors)){
				$data['error']['pagelayer_logs'] = var_export($installed->errors, true);
			}
			softaculous_pro_ajax_output_xmlwrap($data);
		}
		
	}
	
	// Lets notify to download
	// $data['download'] = 1;
	$data['sel_plugin'] = 1;
	
	softaculous_pro_ajax_output_xmlwrap($data);
	
}

function softaculous_pro_ajax_selected_plugin (){
    
	check_ajax_referer('softaculous_pro_ajax', 'softaculous_pro_nonce');
    
	if ( ! current_user_can( 'edit_posts' ) ) {    
        wp_send_json_error();
    }
	
    $results = array();
    $options = get_option('softaculous_pro_setup_info');
    $sel_features = $options['features'];
    if(!empty($sel_features)){
        $feature_list = spro_get_features_list();
        foreach($feature_list as $slug => $features){
            if (in_array($slug, $sel_features)) {
                foreach($features['plugin'] as $plugin_slug => $plugin_data){
					$res = spro_install_required_plugin($plugin_slug, $plugin_data);
					$results[] = array(
						'plugin_slug' => $plugin_slug,
						'status' => $res,
					);
                }
            }
        }
        foreach ($results as $item) {
            if (isset($item['status']['error'])) {
                $data['failed_plugin'][$item['plugin_slug']] = $item['status']['error'];
            }
        }
        $data['download'] = 1;
        softaculous_pro_ajax_output($data);
    }
}

// Download template
function softaculous_pro_ajax_download_template(){
	
	global $softaculous_pro;
	
	// Some AJAX security
	check_ajax_referer('softaculous_pro_ajax', 'softaculous_pro_nonce');
	
	$slug = softaculous_pro_optPOST('theme');
	
	// Do the download
	$data = softaculous_pro_download_template($slug);
	
	// Any error ?
	if(!empty($data['error'])){
		softaculous_pro_ajax_output($data);
	}
	
	// Lets import then
	$data['import'] = 1;
	
	softaculous_pro_ajax_output($data);
	
}

// Import template
function softaculous_pro_ajax_import_template(){ 
	
	global $softaculous_pro, $pl_error;

	// Some AJAX security
	check_ajax_referer('softaculous_pro_ajax', 'softaculous_pro_nonce');
	
	$slug = softaculous_pro_optPOST('theme');
	$to_import = softaculous_pro_optPOST('to_import');
	$_POST['set_home_page'] = 1;
	
	if(!empty($to_import)){
		$to_import[] = 'blog';
		$items = ['page' => $to_import];
	}else{
		$items = [];
	}
	
	// Import the template
	$data = softaculous_pro_import_template($slug, $items);
	
	softaculous_pro_ajax_output($data);
	
}

function softaculous_pro_save_setup_info(){
	// Some AJAX security
	check_ajax_referer('softaculous_pro_ajax', 'softaculous_pro_nonce');
	
	$step = $_POST['step'];
	$post_data = wp_unslash($_POST['data']);
	$setup_info = get_option('softaculous_pro_setup_info');
	
	$setup_info = !empty($setup_info) ? $setup_info : array();

	if($step === 'type' && !empty($post_data) ){
		$setup_info['type'] = strtolower(str_replace(" ", "", $post_data));
	}
	
	if($step === 'title' && !empty($post_data)){
		update_option('blogname', $post_data);
	}
	
	if($step === 'features' && !empty($post_data)){
		$setup_info['features'] = $post_data;
	}
	
	$steps = array( 'type', 'title', 'features', 'import');
	update_option('softaculous_pro_setup_info', $setup_info);
}

function softaculous_pro_get_options(){
	check_ajax_referer('softaculous_pro_ajax', 'softaculous_pro_nonce');
	$options = get_option('softaculous_pro_setup_info');
	wp_send_json($options);
}

function spro_install_required_plugin($slug, $plugin, $pro = 0){
	
	require_once ABSPATH . 'wp-admin/includes/plugin.php';
	require_once ABSPATH . 'wp-admin/includes/update.php';	
	include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
	include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
	$res = array();
	
	try{
		if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin['plugin_init'] ) && is_plugin_inactive( $plugin['plugin_init'] ) ) {
			activate_plugin($plugin['plugin_init']);
			$res['success'] = __("Plugin activated successfully.", 'softaculous-pro');
		}
		elseif ( ! file_exists( WP_PLUGIN_DIR . '/' . $plugin['plugin_init'] ) ){
			
			if (!empty($plugin['requires_php']) && version_compare(PHP_VERSION, $plugin['requires_php'], '<')) {
				throw new Exception(sprintf(__('Plugin installation failed. %1$s requires PHP version %2$s or higher. Your PHP version is %3$s.', 'softaculous-pro'),
					$plugin['plugin_name'],
					$plugin->requires_php,
					PHP_VERSION
				));
			}
			
			if(!empty($plugin['plugin_download_url'])){
				$download_url = $plugin['plugin_download_url'];
			}else{
				$api = plugins_api(
					'plugin_information',
					array(
							'slug'   => sanitize_key( wp_unslash( $slug ) ),
							'fields' => array(
								'sections' => false,
							),
						)
					);
				$download_url = $api->download_link;
			}
			
			$skin = new WP_Ajax_Upgrader_Skin();
			$upgrader = new Plugin_Upgrader( $skin );
			$result   = $upgrader->install($download_url);
				
			if ( is_wp_error($result) ) {
				throw new Exception(sprintf(__("Plugin installation failed. %1$s", 'softaculous-pro'), $result->get_error_message()));
			}
			elseif ( is_wp_error( $skin->result ) ) {
				throw new Exception(sprintf(__("Plugin installation failed. %1$s", 'softaculous-pro'), $skin->result->get_error_message()));
			} 
			elseif ( $skin->get_errors()->has_errors() ) {
				throw new Exception(sprintf(__("Plugin installation failed. %1$s", 'softaculous-pro'), $skin->get_error_messages()));
			} else {
				activate_plugin($plugin['plugin_init']);
				$res['success'] = __("Plugin installed and activated successfully.", 'softaculous-pro');
			}
		}else{
			$res['success'] = __("Plugin already installed.", 'softaculous-pro');
		}
	}
	catch( Exception $e){
		$res['error']  = $e->getMessage();
	}
	
	// Do we need to install the pro plugin as well ?
	if(empty($pro)){
		if(!empty($plugin['pro']) && !empty($plugin['plugin_download_url_pro'])){
			$plugin['plugin_download_url'] = softaculous_pro_add_params($plugin['plugin_download_url_pro']);
			$plugin['plugin_init'] = $plugin['plugin_init_pro'];
			$res['pro'] = spro_install_required_plugin($slug, $plugin, 1);
		}
	}
	
	return $res;
}

function spro_install_required_theme($slug, $theme = array()){
	
	$res = [];
	
	try {

		// Check if user is an admin and has appropriate permissions
		if(!current_user_can('install_themes')){
			throw new Exception(__("You do not have enough permissions to install theme", 'softaculous-pro'));
			return [];
		}

		if(!empty($theme['theme_download_url'])){
			$download_url = $theme['theme_download_url'];
		}else{
			$api = themes_api(
				'theme_information',
				array(
						'slug'   => sanitize_key( wp_unslash( $slug ) ),
						'fields' => array(
							'sections' => false,
							'downloadlink' => true,
						),
					)
				);
			$download_url = $api->download_link;
		}

		$theme_name = $slug;

		if(wp_get_theme($theme_name)->exists()){
			
			// Activate the theme
			switch_theme($theme_name);
			$res['success'] = __("Theme activated successfully.", 'softaculous-pro');
			
			return $res;
		}

		// Use WP Filesystem API to manage theme installation
		if(!function_exists('WP_Filesystem')){
			require_once(ABSPATH . 'wp-admin/includes/file.php');
		}

		// Check if FTP is required
		ob_start();
		$credentials = request_filesystem_credentials('');
		ob_end_clean();

		if(false === $credentials || !WP_Filesystem($credentials)){
			$res['error'] = __('The filesystem could not write files to the server!', 'softaculous-pro');
			return $res;
		}

		global $wp_filesystem;

		// The directory where themes are installed
		$theme_dir = $wp_filesystem->wp_themes_dir();

		// Download the theme zip file
		$theme_zip = download_url($download_url);

		// Check for errors during download
		if(is_wp_error($theme_zip)){
			throw new Exception(sprintf(__('Error downloading theme: %1$s', 'softaculous-pro'), $theme_zip->get_error_message()));
		}

		// Unzip the downloaded theme file
		$unzip_result = unzip_file($theme_zip, $theme_dir);

		// Check for errors during unzip
		if(is_wp_error($unzip_result)){
			throw new Exception(sprintf(__('Error unzipping theme: ', 'softaculous-pro'), $unzip_result->get_error_message()));
		}

		// Delete the temporary zip file
		unlink($theme_zip);

		// Activate the theme after installation
		switch_theme($theme_name);
	}catch(\Exception $e){
		$res['error'] = __('Theme installation failed ', 'softaculous-pro') . $e->getMessage();
		return $res;
	}

	$res['success'] = __("Theme installed and activated successfully.", 'softaculous-pro');

	return $res;
}

// This is to replace the image variables for the template URL
function softaculous_pro_pagelayer_start_insert_content($post){
	
	$url = popularfx_templates_dir_url().'/'.$GLOBALS['softaculous_pro_template_import_slug'].'/';
	
	$replacers['{{theme_url}}/images/'] = $url.'images/';
	$replacers['{{theme_url}}'] = $url;
	$replacers['{{theme_images}}'] = $url.'images/';
	$replacers['{{themes_dir}}'] = dirname(get_stylesheet_directory_uri());
	
	foreach($replacers as $key => $val){
		$post['post_content'] = str_replace($key, $val, $post['post_content']);
	}
		
	return $post;
	
}

if(!function_exists('softaculous_pro_templates')){

// The Templates Page
function softaculous_pro_templates(){

	global $softaculous_pro, $pl_error, $spro_setup_info;
	
	$softaculous_pro['templates'] = softaculous_pro_get_templates_list();

	$spro_setup_info = get_option('softaculous_pro_setup_info');
	
	if(isset($_REQUEST['install'])){
		check_admin_referer('softaculous-pro-template');
	}

	// Is there a license key ?
	if(isset($_POST['install'])){
		
		$done = 1;
		
	}
	
	softaculous_pro_templates_T();
	
}

// The License Page - THEME
function softaculous_pro_templates_T(){
	
	global $softaculous_pro, $pagelayer, $pl_error, $spro_setup_info;
	
	// Any errors ?
	if(!empty($pl_error)){
		pagelayer_report_error($pl_error);echo '<br />';
	}
	
?>
<div id="softaculous_pro_theme_title">
	<h1 style="text-align:center;"><?php _e('Choose a design', 'softaculous-pro'); ?></h1><br /><br />
</div>
<div id="softaculous_pro_search" class="softaculous-pro-row">
	<div class="softaculous-pro-search">
		<input type="text" class="softaculous-pro-search-field" placeholder="<?php _e('Search for theme', 'softaculous-pro'); ?>" />    
		<div id="softaculous-pro-suggestion"></div>
	</div>
    <div class="softaculous-pro-dropdown softaculous-pro-categories">
		<div class="softaculous-pro-current-cat"><?php _e('All', 'softaculous-pro'); ?></div><span class="dashicons dashicons-arrow-down-alt2"></span>
		<div class="softaculous-pro-dropdown-content"><div class="softaculous-pro-cat-holder softaculous-pro-row" style="justify-content:flex-start;"></div></div>
	</div>
</div>
<div class="softaculous-pro-page" id="softaculous-pro-templates-holder">
	<div id="softaculous-pro-pagination"></div>
	<div id="softaculous-pro-templates" class="softaculous-pro-row" style="justify-content:flex-start"></div>
	<div id="softaculous-pro-single-template">
		<div style="margin-bottom: 20px; margin-top: 10px;  text-align: left;">
			<h1 style="display: inline-block;margin: 0px;vertical-align: middle;" id="softaculous-pro-template-name"></h1>
			<?php if (empty($softaculous_pro['branding']['rebranded'])): ?>
				<a href="" id="softaculous-pro-demo" class="button softaculous-pro-demo-btn" target="_blank"><?php _e('Demo', 'softaculous-pro'); ?></a>
			<?php endif; ?>
		</div>
		<div style="margin: 0px; vertical-align: top;" class="single-template-div">
			<div style="text-align: center;  position:relative; width:80%;">
				<div style="width: 100%; max-height: 500px; overflow: auto; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);" class="single-templates-content">
				<div class="loader-container" >
					<div class="loader" style="display:none"></div>
				</div>
					<img id="softaculous_pro_display_image" src="" width="100%" style="position:relative; z-index:2;">
				</div>
			</div>
			<div class="softaculous_pro_single_content">
				<h1 style="font-size:16px;"><?php _e('Select pages to import', 'softaculous-pro'); ?></h1><br />
				<div id="softaculous_pro_screenshots"></div>
			<div class="softaculous_pro_import_img_notice">
				<form id="softaculous-pro-import-form" method="post" enctype="multipart/form-data">
					<?php wp_nonce_field('softaculous-pro-template');?>
					<input name="theme" id="softaculous-pro-template-install" value="" type="hidden" />
					<input type="checkbox" name="download_imgs" id="download_imgs" value="1" checked/> <label for="download_imgs" class="spro-tool-tip" style="cursor:pointer;"><?php _e('Import stock images ?', 'softaculous-pro'); ?></label><br />
					<i>
						<?php _e('We try our best to use images that are free to use from legal perspectives. However, we are not liable for any copyright infringement for your site.', 'softaculous-pro'); ?>
					</i>
					<input name="install" value="1" type="hidden" />
				</form>
			</div>
			</div>
		</div>

		<div style="position:fixed; bottom: 15px; right: 20px; z-index: 10;">
			<div class="button button-softaculous-pro softaculous-pro-back"  style="display:none;"><?php _e('Go Back', 'softaculous-pro'); ?></div>&nbsp;
			<input name="import_theme" class="button button-softaculous-pro" id="spro_import_content" value="<?php _e('Import Theme Content', 'softaculous-pro'); ?>" type="button" onclick="softaculous_pro_modal('#SproTemplatesModal')" style="display:none;"/> &nbsp;
		</div>	
	
	</div>
</div>

<!-- The Modal -->
<div id="SproTemplatesModal" class="softaculous-pro-modal">

	<!-- Modal holder -->
	<div class="softaculous-pro-modal-holder">

		<!-- Modal header -->
		<div class="softaculous-pro-modal-header">
			<h1><?php _e('Import Theme Contents', 'softaculous-pro'); ?></h1> 
			<!-- <span class="softaculous-pro-modal-close">&times;</span> -->
		</div>
		<!-- Modal content -->
		<div class="softaculous-pro-modal-content">
			<div class="softaculous-pro-import">
				<div id="softaculous-pro-error-template"></div>
				<div id="softaculous-pro-progress-template">
					<img src="<?php echo esc_attr(SOFTACULOUS_PRO_PLUGIN_URL) .'assets/images/progress.svg';?>" width="20" /> <span id="softaculous-pro-progress-txt"></span>
				</div>
			</div>
			<div class="softaculous-pro-done" style="display: block;">
				<h3 style="margin-top: 0px;"><?php _e('Congratulations, the template was imported successfully !', 'softaculous-pro'); ?></h3>
				<?php _e('You can now customize the website as per your requirements with the help of Pagelayer or the Customizer.', 'softaculous-pro')
				.'<br /><br />
				<b>Note</b> : '.
				_e('We strongly recommend you change all images and media. We try our best to use images which are copyright free or are allowed under their licensing. However, we take no responsibilities for the same and recommend you change all media and images !', 'softaculous-pro'); ?>
			</div>
		</div>
		
		<!-- Modal footer -->
		<div class="softaculous-pro-modal-footer">
			<div class="softaculous-pro-done">
				<a class="button softaculous-pro-demo-btn" href="<?php echo site_url();?>" target="_blank"><?php _e('Visit Website', 'softaculous-pro'); ?></a> &nbsp;&nbsp;
				<a class="button softaculous-pro-demo-btn" href="<?php echo admin_url();?>" target="_blank"><?php _e('WordPress Dashboard', 'softaculous-pro'); ?></a> &nbsp;&nbsp;
				<a class="button softaculous-pro-demo-btn" href="<?php echo admin_url('admin.php?page=assistant');?>" target="_blank"><?php _e('Assistant', 'softaculous-pro'); ?></a>
			</div>
		</div>
	</div>

</div>

<script>

var softaculous_pro_setup_info = JSON.parse('<?php echo json_encode((!empty($spro_setup_info) ? $spro_setup_info : array())); ?>');

// Add to tabs override
jQuery(document).ready(function(){
	softaculous_pro_templates_fn(jQuery);
	if(softaculous_pro_setup_info && softaculous_pro_setup_info.type){
		softaculous_pro_setup_info.type = softaculous_pro_setup_info.type.replace("-", "");
		jQuery('#cat_button_'+softaculous_pro_setup_info.type).trigger("click");
	}
});

var softaculous_pro_ajax_nonce = '<?php echo wp_create_nonce('softaculous_pro_ajax');?>';
var softaculous_pro_ajax_url = '<?php echo admin_url( 'admin-ajax.php' );?>?&';
var softaculous_pro_demo = 'https://demos.popularfx.com/';

softaculous_pro_templates = <?php echo json_encode($softaculous_pro['templates']);?>;
var themes = softaculous_pro_templates['list'];
var categories = softaculous_pro_templates['categories'];
var mirror = '<?php echo softaculous_pro_sp_api_url("-1");?>files/themes/';

function softaculous_pro_update_cat_input(other_cat){
	jQuery('#cat_input').val(other_cat);
}

function softaculous_pro_templates_fn($){

// Back button handler
jQuery('.softaculous-pro-back').click(function(){
	softaculous_pro_show_themes(softaculous_pro_setup_info.type !== undefined ? softaculous_pro_setup_info.type.toLowerCase() : '');
	jQuery("#spro_import_content").hide();
	jQuery(".softaculous-pro-back").hide();
});

jQuery('.softaculous-pro-back-theme').click(function(){
	jQuery('#softaculous-pro-templates-holder').show();
	jQuery(this).parent().hide();
	jQuery('#SproTemplatesModal').hide();
});

jQuery('#cat_input').keyup(function() {
	
	var query = jQuery(this).val().toLowerCase();
	var cat_displayed = 0;
	
	jQuery(".category_btn").each(function( index ){
		var cslug = jQuery(this).find("input").attr("data-target");
		if(cslug.toLowerCase().includes(query)){
			jQuery(this).show();
			cat_displayed++;
		}else{
			jQuery(this).hide();
		}
		
		if(cat_displayed > 0){
			jQuery("#spro_no_cat_results").hide();
		}else{
			jQuery("#spro_no_cat_results").show();
		}
	});
	
});

// Fill the categories
var chtml = '<div class="softaculous-pro-md-4 softaculous-pro-cat" data-cat="">All</div>';
for(var x in categories){
	chtml += '<div class="softaculous-pro-md-4 softaculous-pro-cat" data-cat="'+x+'">'+categories[x]['en']+'</div>';
}

jQuery('.softaculous-pro-cat-holder').html(chtml);
jQuery('.softaculous-pro-cat-holder').find('.softaculous-pro-cat').click(function(){
	softaculous_pro_show_themes(jQuery(this).data('cat'));
});

jQuery('.softaculous-pro-categories-list').find('.category_btn').click(function(){
	var childEle = jQuery(this).children('input');
	var jEle_parent =  jQuery(this).parent().find(".active_category");
	var real_val = jQuery(this).children('input').val();
	var val = jQuery(this).children('input').val().toLowerCase();
	var inputSection = jQuery(".softaculous-pro-category-input");


	if (jQuery(this).hasClass("active_category")) {
		jQuery(this).removeClass("active_category");
		inputSection.find('input').val('')
		return;
	}
	
	jEle_parent.removeClass("active_category");
	jQuery(this).addClass("active_category");
	
	if(real_val){
		inputSection.find('input').val(real_val)
	}
	
	softaculous_pro_show_themes(val);
});

// Search Clear
jQuery('.softaculous-pro-sf-empty').click(function(){
	jQuery('.softaculous-pro-search-field').val('');
	softaculous_pro_show_themes();
});

// Search
jQuery('.softaculous-pro-search-field').on('keyup', function(e){
	softaculous_pro_show_themes('', jQuery(this).val());
});

// Sort themes
jQuery('.softaculous-pro-sortby').change(function(){
	softaculous_pro_show_themes(jQuery('.softaculous-pro-current-cat').data('cat'), jQuery('.softaculous-pro-search-field').val());
});

};

// Show the themes
function softaculous_pro_show_themes(cat, search, page){
	
	softaculous_pro_show_themes_loaded = 1;
	
	var sortby = 'latest';
	jQuery("#softaculous_pro_search").show();	
	jQuery("#softaculous_pro_theme_title").show();	
	jQuery("#softaculous-pro-suggestion").hide();	
	jQuery("#softaculous-pro-single-template").hide();
	jQuery("#softaculous-pro-pagination").show();
	jQuery("#softaculous-pro-templates").show();
	
	// Blank html
	jQuery('#softaculous-pro-templates').html('');
	jQuery('#softaculous-pro-pagination').html('');

	var search = search || "";
	var cat =   cat || softaculous_pro_setup_info.type || "";
	var cat = cat.replace("-", "");
	softaculous_pro_setup_info.type = cat;
	var cat = (categories[cat] === undefined && (cat && cat.length) > 0 ? 'others' : cat) || "" ;

	var num = 60;
	var page = page || 1;
	var start = num * (page - 1);
	var end = num + start;
	var i = 0;
	var cat_appender = categories[cat] === undefined ? 'Others' : categories[cat]['en']

	if(cat.length > 0){
		jQuery('.softaculous-pro-current-cat').html(cat_appender);
		jQuery('.softaculous-pro-current-cat').data('cat', cat);
	}else{
		jQuery('.softaculous-pro-current-cat').html('All');
		jQuery('.softaculous-pro-current-cat').data('cat', '');
	}
	
	var allowed_list = [];
	
	if(search.length > 0){
		search = search.toLowerCase();
		
		for(var x in softaculous_pro_templates['tags']){
			if(x.toLowerCase().indexOf(search) >= 0){
				allowed_list = allowed_list.concat(softaculous_pro_templates['tags'][x]);
			}
		}
	}
	
	if(allowed_list.length > 0){
		allowed_list = Array.from(new Set(allowed_list));
	}
	
	var themeids = [];
	var sorted = {};
	var rsorted = {};
	
	for(var x in themes){
		themeids.push(parseInt(themes[x].thid));
	}	
	
	if(sortby == "latest"){
		var datatheme = Object.values(themes);
		var rsorted_ids = themeids.sort().reverse();
		for(var x of rsorted_ids){
			for( var y in datatheme){
				if(datatheme[y].thid == x){
					rsorted[datatheme[y].slug] = datatheme[y];
				}
			}
		}
		themes = rsorted;
	
	}else if(sortby == "oldest"){
		var datatheme = Object.values(themes);
		var sorted_ids = themeids.sort();
		for(var x of sorted_ids){
			for( var y in datatheme){
				if(datatheme[y].thid == x){
					sorted[datatheme[y].slug] = datatheme[y];
				}
			}
		}
		
		themes = sorted;
		
	}else{
		themes = softaculous_pro_templates['list'];		
	}	
	
	for(var x in themes){
		
		// Is it same category
		if(cat.length > 0 && cat != themes[x].category){
			continue;
		}
		
		// Is it a searched item
		if(search.length > 0 && themes[x].name.toLowerCase().indexOf(search) === -1 && allowed_list.indexOf(themes[x].thid) === -1){
			continue;
		}
		
		if(i >= start && i < end){
			//console.log(x+' '+i+' '+start+' '+end);
			softaculous_pro_show_theme_tile(themes[x], x);
		}
		
		i++;
		
	}
	
	jQuery('.softaculous-pro-theme-details').click(function(){
		var jEle = jQuery(this);
		softaculous_pro_show_theme_details(jEle.attr('slug'));
	});
	
	var pages = Math.ceil(i/num);
	
	if(pages > 1){
		
		var html = '<ul class="pagination">';
		
		for(var p = 1; p <= pages; p++){
			html += '<li class="page-item '+(page == p ? 'active' : '')+'"><a class="page-link" href="#" data-cat="'+cat+'" data-search="'+search+'" data-page="'+p+'">'+p+'</a></li>';
		}
		
		html += '</ul>';
		
		jQuery('#softaculous-pro-pagination').html(html);
		
		jQuery('#softaculous-pro-pagination').find('.page-link').click(function(){
			var j = jQuery(this);
			softaculous_pro_show_themes(j.data('cat'), j.data('search'), j.data('page'));
		});
		
	}
	
}

function softaculous_pro_show_theme_tile(theme, x){
	var html = '<div class="softaculous-pro-md-4">'+
		'<div class="softaculous-pro-theme-details" slug="'+theme['slug']+'" thid="'+theme['thid']+'">'+
			'<div class="softaculous-pro-theme-screenshot">'+
				'<img src="'+mirror+'/'+theme['slug']+'/screenshot.jpg" loading="lazy" alt="" />'+
			'</div>'+
			'<div class="softaculous-pro-theme-name">'+theme['name']+'</div>'+
		'</div>'+
	'</div>';
	jQuery('#softaculous-pro-templates').append(html);
}

function softaculous_pro_strip_extension(str){
    return str.substr(0,str.lastIndexOf('.'));
}

// Show the theme details
function softaculous_pro_show_theme_details(slug){
	
	var theme = themes[slug];
	
	jQuery("#softaculous-pro-suggestion").hide();	
	jQuery("#softaculous_pro_search").hide();	
	jQuery("#softaculous_pro_theme_title").hide();	
	jQuery("#softaculous-pro-single-template").show();
	jQuery("#softaculous-pro-pagination").hide();
	jQuery("#softaculous-pro-templates").hide();
	
	// Set install value
	jQuery('#softaculous-pro-template-install').val(slug);
			
	// Set name
	jQuery("#softaculous-pro-template-name").html(theme['name']);
			
	// Demo URL
	jQuery("#softaculous-pro-demo").attr("href", softaculous_pro_demo+(theme['name'].replace(' ', '_')));
	
	// Blank screenshots
	jQuery("#softaculous_pro_screenshots").html('');
	
	// Is the license PRO ?
	if(theme['type'] >= 2){
		jQuery('#softaculous_pro_license_div').css('display', 'inline-block');
	}else{
		jQuery('#softaculous_pro_license_div').hide();
	}
	
	var url = mirror+'/'+theme['slug'];
	
	// Show home image
	jQuery("#softaculous_pro_display_image").attr("src", "");
	jQuery("#softaculous_pro_display_image").attr("src", url+'/screenshots/home.jpg');
	jQuery("#softaculous_pro_display_image").parent().scrollTop(0);
	
	// Make the call
	jQuery.ajax({
		url: softaculous_pro_ajax_url+'action=softaculous_pro_template_info',
		type: 'POST',
		data: {
			softaculous_pro_nonce: softaculous_pro_ajax_nonce,
			slug: slug
		},
		dataType: 'json',
		success:function(theme) {
			
			jQuery("#spro_import_single").addClass("hidden");
			
			var sc = '';
			// var test= '';
			// Show the screenshots
			for(var x in theme['screenshots']){
				var page_name = softaculous_pro_strip_extension(theme['screenshots'][x]);
				sc += '<div class="softaculous_pro_img_screen" page="'+x+'" page-name="'+page_name+'">'+
				'<div class="spro_page_selector"><input type="checkbox" checked="checked" class="checkbox" id="'+page_name+'">'+
				'<label for="'+page_name+'" class="softaculous_pro_img_name">'+page_name+'</label></div>'+
				'<a href="'+url+'/screenshots/'+theme['screenshots'][x] +'" class="softaculous_pro_img_views view-'+page_name+' dashicons dashicons-visibility"></a>'+
				'</div>';
				
			}
			
			jQuery("#softaculous_pro_screenshots").html(sc);
			jQuery("#spro_import_content").show();
			jQuery(".softaculous-pro-back").show();
			jQuery('.softaculous_pro_img_screen:first').children('a').addClass('spro_img_inview');


			jQuery("#softaculous_pro_screenshots").find('.softaculous_pro_img_views').click(function(e){
				e.preventDefault();
				var jEle = jQuery(this);
				jQuery("#softaculous_pro_display_image").hide();
				jQuery(".loader").show();
				
				if(jQuery('.softaculous_pro_img_screen .softaculous_pro_img_views').hasClass('spro_img_inview')){
					jQuery('.softaculous_pro_img_screen .softaculous_pro_img_views').removeClass('spro_img_inview');
				}
				
				var newImageSrc = jEle.attr("href");
				jQuery("#softaculous_pro_display_image").attr("src", newImageSrc);

				// Handle image load event
				jQuery("#softaculous_pro_display_image").on('load', function() {
					jQuery(".loader").hide(); // Hide loader
					jQuery(this).show(); // Show image
				});

				// In case the image is cached and loads immediately
				if (jQuery("#softaculous_pro_display_image")[0].complete) {
					jQuery(".loader").hide(); // Hide loader
					jQuery("#softaculous_pro_display_image").show(); // Show image
				}

				jQuery("#softaculous_pro_display_image").parent().scrollTop(0);
				jEle.addClass('spro_img_inview');
			});

			// need to refactor it its create multiple in html
			jQuery("#softaculous_pro_screenshots").find('.softaculous_pro_img_views').on('mouseenter',function(e){
				var imgUrl = jQuery(this).attr('href');
				if(!jQuery(this).attr('loaded')){
					jQuery('<img>').attr('src', imgUrl).on('load', function() {}).appendTo('body').css('display', 'none');
				}
				jQuery(this).attr('loaded',true);
			});

			jQuery("#softaculous_pro_screenshots").find('.spro_page_selector').click(function(event){
				var jEle = jQuery(this);
				jQuery("#softaculous_pro_display_image").hide();
				jQuery(".loader").show();

				var checkbox = jQuery(this).find('.checkbox');
				if (jQuery(event.target).is('.checkbox') || jQuery(event.target).is('.softaculous_pro_img_name')) {
					return;
				}
				jEle.siblings('.softaculous_pro_img_views').trigger('click');
				
				
			});
			 // Change event on the checkbox
			 jQuery("#softaculous_pro_screenshots").find('.checkbox').change(function() {
				var checked_div = jQuery(this).siblings('.softaculous_pro_img_name');

				if(jQuery('.softaculous_pro_img_screen .softaculous_pro_img_views').hasClass('spro_img_inview')){
					jQuery('.softaculous_pro_img_screen .softaculous_pro_img_views').removeClass('spro_img_inview');
				}
				var newImageSrc = jQuery(this).parent().siblings('.softaculous_pro_img_views').attr("href");

				jQuery(this).parent().siblings('.softaculous_pro_img_views').addClass('spro_img_inview');
				jQuery("#softaculous_pro_display_image").attr("src", newImageSrc);

				jQuery("#softaculous_pro_display_image").on('load', function() {
					jQuery(".loader").hide(); // Hide loader
					jQuery(this).show(); // Show image
				});

				if (jQuery(this).is(':checked')) {
					checked_div.addClass("softaculous_pro_img_selected");
				} else {
					checked_div.removeClass("softaculous_pro_img_selected");
				}
			});
			
		}
	});
	
}

function softaculous_pro_onboarding_dismiss(e){
	
	jQuery.ajax({
		type: 'post',
		url: soft_pro_obj.ajax_url,
		data: {
			action: 'softaculous_pro_onboarding_dismiss',
			dismiss: 1,
			softaculous_pro_nonce: softaculous_pro_ajax_nonce,
			data: [],
		},
		complete: function (response) {
			window.location = soft_pro_obj.admin_url+"admin.php?page=assistant";
		},
	});
	
}

</script>

<?php


}

}PK��f\&3���disable-comments.phpnu�[���<?php

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

add_action('admin_init', function () {
    // Redirect any user trying to access comments page
    global $pagenow;
     
    if ($pagenow === 'edit-comments.php') {
        wp_safe_redirect(admin_url());
        exit;
    }
 
    // Disable support for comments and trackbacks in post types
    foreach (get_post_types() as $post_type) {
        if (post_type_supports($post_type, 'comments')) {
            remove_post_type_support($post_type, 'comments');
            remove_post_type_support($post_type, 'trackbacks');
        }
    }
});

// Return 0 comments
add_filter('the_comments', 'softaculous_pro_the_comments', 10, 1);
function softaculous_pro_the_comments( $comments ) {
	return array();
}

// Return 0 comments number
add_filter('get_comments_number', 'softaculous_pro_get_comments_number', 10, 1);
function softaculous_pro_get_comments_number( $comments_number ) {
	return 0;
}
 
// Close comments on the front-end
add_filter('comments_open', '__return_false', 20, 2);
add_filter('pings_open', '__return_false', 20, 2);
 
// Hide existing comments
add_filter('comments_array', '__return_empty_array', 10, 2);
 
// Remove comments page in menu
add_action('admin_menu', function () {
    remove_menu_page('edit-comments.php');
});
 
// Remove comments links from admin bar
add_action('add_admin_bar_menus', function () {
    if (is_admin_bar_showing()) {
        remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60);
    }
});PK��f\��i��(�(	bloat.phpnu�[���<?php

namespace SpeedyCache;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class Bloat{

	static function actions(){
		global $speedycache;
		
		// Add the filters / actions
		if(!empty($speedycache->bloat['disable_xmlrpc'])){
			add_filter('xmlrpc_enabled', '__return_null');
			add_filter('bloginfo_url', '\SpeedyCache\Bloat::xmlrpc_remove_pingback_url', 10000, 2);
			add_action('wp_loaded', '\SpeedyCache\Bloat::xmlrpc_disable');
		}
		
		// Disable DashIcons
		if(!empty($speedycache->bloat['disable_dashicons'])){
			add_action('wp_print_styles', '\SpeedyCache\Bloat::disable_dashicons');
		}
		
		if(!is_admin()){
			// Remove jQuery migrate
			if(!empty($speedycache->bloat['disable_jmigrate'])){
				add_action('wp_default_scripts', '\SpeedyCache\Bloat::remove_jquery_migrate');
			}
			
			// Remove Block CSS
			if(!empty($speedycache->bloat['disable_block_css'])){
				add_action('wp_enqueue_scripts', '\SpeedyCache\Bloat::disable_block_editor_css');
			}

			// Disable Cart Fragment
			if(!empty($speedycache->bloat['disable_cart_fragment'])){
				add_action('wp_enqueue_scripts', '\SpeedyCache\Bloat::disable_cart_fragment', 11);
			}
			
			// Disable WooCommerce Assets
			if(!empty($speedycache->bloat['disable_woo_assets'])){
				add_action('wp_enqueue_scripts', '\SpeedyCache\Bloat::disable_woocommerce_assets', 99);
			}
			
			// Disale RSS Feeds
			if(!empty($speedycache->bloat['disable_rss'])){
				add_action('do_feed_rdf', '\SpeedyCache\Bloat::disable_wp_feeds', 1);
				add_action('do_feed_rss', '\SpeedyCache\Bloat::disable_wp_feeds', 1);
				add_action('do_feed_rss2', '\SpeedyCache\Bloat::disable_wp_feeds', 1);
				add_action('do_feed_atom', '\SpeedyCache\Bloat::disable_wp_feeds', 1);
				add_action('do_feed_rss2_comments', '\SpeedyCache\Bloat::disable_wp_feeds', 1);
				add_action('do_feed_atom_comments', '\SpeedyCache\Bloat::disable_wp_feeds', 1);
				
				// Remove links
				remove_action( 'wp_head', 'feed_links_extra', 3 );
				remove_action( 'wp_head', 'feed_links', 2 );
			}
		}

		// Disable OEmbeds
		if(!empty($speedycache->bloat['disable_oembeds'])){
			add_action('init', '\SpeedyCache\Bloat::disable_oembeds');
		}
		
		if(!empty($speedycache->bloat['disable_gutenberg'])){
			add_filter('use_block_editor_for_post_type', '__return_false', 100);
			add_filter('after_setup_theme', '\SpeedyCache\Bloat::disable_gutenberg_hooks');
		}
		
		// Limit Post revisions
		if(!empty($speedycache->bloat['limit_post_revision'])){
			add_filter('wp_revisions_to_keep', '\SpeedyCache\Bloat::limit_post_revisions');
		}

		// Update Heartbeat
		if(!empty($speedycache->bloat['update_heartbeat'])){
			add_action('init', '\SpeedyCache\Bloat::disable_heartbeat');
			add_action('wp_enqueue_scripts', '\SpeedyCache\Bloat::disable_heartbeat');
			add_action('admin_enqueue_scripts', '\SpeedyCache\Bloat::disable_heartbeat');
			add_filter('heartbeat_settings', '\SpeedyCache\Bloat::change_heartbeat_interval', 100);
		}
	}

	// Disbale XML request
	static function xmlrpc_disable(){
		global $pagenow;

		// Is it xmlrpc.php ?
		if ($pagenow === 'xmlrpc.php'){	
			echo 'XML-RPC is disabled';
			exit();
		}	
	}
	
	// Disables the XML-RPC functionality
	static function xmlrpc_remove_pingback_url($output, $show) {

		if($show == 'pingback_url'){
			$output = '';
		}

		return $output;
	}
	
	// Disable Dashicons
	static function disable_dashicons(){
		if(!is_admin_bar_showing() && !is_customize_preview()){
			wp_dequeue_style('dashicons');
			wp_deregister_style('dashicons');
		}
	}
	
	// Remove jQuery Migrate
	static function remove_jquery_migrate($scripts){
		
		if(!is_admin() && isset($scripts->registered['jquery'])){
			$script = $scripts->registered['jquery'];

			if($script->deps){
				$script->deps = array_diff($script->deps, array('jquery-migrate'));
			}
		}
	}
	
	// Disable OEmbeds
	static function disable_oembeds(){
		// Remove oEmbed REST API endpoint
		remove_action('rest_api_init', 'wp_oembed_register_route');

		// Disable oEmbed auto-discovery links
		remove_action('wp_head', 'wp_oembed_add_discovery_links');

		// Disable oEmbed-specific JavaScript from the front-end and back-end
		remove_action('wp_head', 'wp_oembed_add_host_js');

		// Remove oEmbed provider fetch URL rewriting
		remove_filter('oembed_fetch_url', 'wp_oembed_rewrite_url');

		// Disable oEmbed in TinyMCE editor
		add_filter('tiny_mce_plugins', '\SpeedyCache\Bloat::disable_tiny_mce_oembed');
	}

	static function disable_tiny_mce_oembed($plugins){
		return array_diff($plugins, array('wpembed'));
	}

	// Remove Block Editor CSS
	static function disable_block_editor_css(){
		wp_dequeue_style('wp-block-library');
		wp_dequeue_style('wp-block-library-theme');
		wp_dequeue_style('wp-block-style');
	}
	
	// Updates the count of number of post revesions.
	static function limit_post_revisions($num){
		global $speedycache;
		
		if(!empty($speedycache->bloat['post_revision_count']) && $speedycache->bloat['post_revision_count'] === 'disable'){
			$num = 0;
		} elseif(!empty($speedycache->bloat['post_revision_count']) && is_numeric($speedycache->bloat['post_revision_count'])){
			$num = intval($speedycache->bloat['post_revision_count']);
		}

		return $num;
	}
	
	// Updating the Heartbeat interval.
	static function change_heartbeat_interval($settings){
		global $speedycache;

		if(!empty($speedycache->bloat['heartbeat_frequency'])){
			$settings['interval'] = $speedycache->bloat['heartbeat_frequency'];
			$settings['minimalInterval'] = $speedycache->bloat['heartbeat_frequency'];
		}

		return $settings;
	}
	
	static function disable_cart_fragment(){
		if(function_exists('is_woocommerce')){
			if(!is_woocommerce() && !is_cart() && !is_checkout() && !is_account_page() && !is_product() && !is_product_category() && !is_shop()){
				wp_dequeue_script('wc-cart-fragments');
			}
		}
	}
	
	static function disable_woocommerce_assets(){
		if(!class_exists('WooCommerce')){
			return;
		}
		
		if(!is_woocommerce() && !is_cart() && !is_checkout() && !is_account_page() && !is_product() && !is_product_category() && !is_shop()){
			// Disable WooCommerce stylesheets
			wp_dequeue_style('woocommerce-general');
			wp_dequeue_style('woocommerce-layout');
			wp_dequeue_style('woocommerce-smallscreen');
			wp_dequeue_style('woocommerce_frontend_styles');
			wp_dequeue_style('woocommerce_fancybox_styles');
			wp_dequeue_style('woocommerce_chosen_styles');
			wp_dequeue_style('woocommerce_prettyPhoto_css');

			// Disable WooCommerce scripts
			wp_dequeue_script('wc_price_slider');
			wp_dequeue_script('wc-single-product');
			wp_dequeue_script('wc-add-to-cart');
			wp_dequeue_script('wc-checkout');
			wp_dequeue_script('wc-add-to-cart-variation');
			wp_dequeue_script('wc-single-product');
			wp_dequeue_script('wc-cart');
			wp_dequeue_script('wc-chosen');
			wp_dequeue_script('woocommerce');
			wp_dequeue_script('prettyPhoto');
			wp_dequeue_script('prettyPhoto-init');
			wp_dequeue_script('jquery-blockui');
			wp_dequeue_script('jquery-placeholder');
			wp_dequeue_script('fancybox');
			wp_dequeue_script('jqueryui');
		}
	}
	
	static function disable_wp_feeds(){
		 wp_die(sprintf(esc_html__('No feed available, please visit our %1$shomepage%2$s!'),
            ' <a href="' . esc_url( home_url( '/' ) ) . '">',
            '</a>'));
	}
	
	static function disable_heartbeat(){
		global $speedycache, $pagenow;

		if(empty($speedycache->bloat['disable_heartbeat'])) {
			return;
		}

		$remove_heartbeat = false;

		switch($speedycache->bloat['disable_heartbeat']){
			case 'disable':
				$remove_heartbeat = true;
				break;
				
			case 'editor':
				if($pagenow != 'post.php' && $pagenow != 'post-new.php'){
					$remove_heartbeat = true;
				}
		}
		
		if(!empty($remove_heartbeat)){
			wp_deregister_script('heartbeat');
		
			//We have replaced heartbeat with an empty heartbeat to prevent any errors
			wp_enqueue_script('heartbeat', SPEEDYCACHE_PRO_URL . '/assets/js/heartbeat.js', null, SPEEDYCACHE_PRO_VERSION, true);
		}
	}

	// Disable Gutenberg
	static function disable_gutenberg_hooks(){
		remove_action('admin_menu', 'gutenberg_menu');
		remove_action('admin_init', 'gutenberg_redirect_demo');

		remove_filter('wp_refresh_nonces', 'gutenberg_add_rest_nonce_to_heartbeat_response_headers');
		remove_filter('get_edit_post_link', 'gutenberg_revisions_link_to_editor');
		remove_filter('wp_prepare_revision_for_js', 'gutenberg_revisions_restore');

		remove_action('rest_api_init', 'gutenberg_register_rest_routes');
		remove_action('rest_api_init', 'gutenberg_add_taxonomy_visibility_field');
		remove_filter('rest_request_after_callbacks', 'gutenberg_filter_oembed_result');
		remove_filter('registered_post_type', 'gutenberg_register_post_prepare_functions');

		remove_action('do_meta_boxes', 'gutenberg_meta_box_save', 1000);
		remove_action('submitpost_box', 'gutenberg_intercept_meta_box_render');
		remove_action('submitpage_box', 'gutenberg_intercept_meta_box_render');
		remove_action('edit_page_form', 'gutenberg_intercept_meta_box_render');
		remove_action('edit_form_advanced', 'gutenberg_intercept_meta_box_render');
		remove_filter('redirect_post_location', 'gutenberg_meta_box_save_redirect');
		remove_filter('filter_gutenberg_meta_boxes', 'gutenberg_filter_meta_boxes');

		remove_action('admin_notices', 'gutenberg_build_files_notice');
		remove_filter('body_class', 'gutenberg_add_responsive_body_class');
		remove_filter('admin_url', 'gutenberg_modify_add_new_button_url'); // old
		remove_action('admin_enqueue_scripts', 'gutenberg_check_if_classic_needs_warning_about_blocks');
		remove_filter('register_post_type_args', 'gutenberg_filter_post_type_labels');

		remove_action('admin_init', 'gutenberg_add_edit_link_filters');
		remove_action('admin_print_scripts-edit.php', 'gutenberg_replace_default_add_new_button');
		remove_filter('redirect_post_location', 'gutenberg_redirect_to_classic_editor_when_saving_posts');
		remove_filter('display_post_states', 'gutenberg_add_gutenberg_post_state');
		remove_action('edit_form_top', 'gutenberg_remember_classic_editor_when_saving_posts');
	}
}
PK��f\_YзJJgooglefonts.phpnu�[���<?php

/*
* SPEEDYCACHE
* https://speedycache.com/
* (c) SpeedyCache Team
*/

namespace SpeedyCache;

if(!defined('ABSPATH')){
	die('Hacking Attempt');
}

class GoogleFonts{

	// Plucks out the google font urls from the content
	static function get($content){

		preg_match_all('/<link.*href=(["\'])(.*fonts\.googleapis\.com\/css.*?)\1/m', $content, $font_rels);

		//We just need the index 2
		if(empty($font_rels[2])){
			return $content;
		}
		
		$fonts = array();
		
		for($i = 0; $i < count($font_rels[2]); $i++){
			if(empty($font_rels[2][$i])){
				continue;
			}
		
			$fonts[md5($font_rels[2][$i])] = $font_rels[2][$i];
		}
		
		if(empty($fonts)){
			return;
		}

		self::fetch($fonts);
	}

	// Reads the font css and saves it to /speedycache/fonts/font-name/
	static function fetch($fonts){
		
		$html = '<!DOCTYPE html>
<html>
<body>
<a href="https://speedycache.com">SpeedyCache</a>
</body>
</html>';
		

		foreach($fonts as $font_name => $url){
			$url = esc_url($url);

			if(substr($url, 0, 2) === '//'){
				$url = 'https:' . $url;
			}

			$response = wp_remote_get($url, array('user-agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36'));
			
			if(is_wp_error($response) || !is_array($response)){
				continue;
			}
			
			$css = wp_remote_retrieve_body($response);
			
			if(is_wp_error($css) || empty($css)){
				continue;
			}
			
			if(!file_exists(speedycache_cache_path('fonts'))){
				@mkdir(speedycache_cache_path('fonts'));
			}
			
			if(!file_exists(speedycache_cache_path('fonts/index.html'))){
				file_put_contents(speedycache_cache_path('fonts/index.html'), $html);
			}

			if(!file_exists(speedycache_cache_path('fonts/').$font_name)){
				@mkdir(speedycache_cache_path('fonts/').$font_name);
			}
			
			if(!file_exists(speedycache_cache_path('fonts/').$font_name . '/index.html')){
				file_put_contents(speedycache_cache_path('fonts/').$font_name . '/index.html', $html);
			}

			preg_match_all('/url\((.*?)\)/m', $response['body'], $urls); // Get URL from the CSS we got

			if(empty($urls) || empty($urls[1])){
				continue;
			}
			
			foreach($urls[1] as $url){
				$file_name = basename($url);
				
				if(file_exists(speedycache_cache_path('fonts/') . $font_name . '/' . $file_name)){
					continue;
				}

				if(strpos($url, 'display=swap') === FALSE){
					$url_to_hit = add_query_arg(array('display' => 'swap'), $url);
				}

				$response = wp_remote_get($url_to_hit);

				if(is_wp_error($response) || !is_array($response)){
					continue;
				}
				
				$font = wp_remote_retrieve_body($response);

				if(is_wp_error($font) || empty($font)){
					continue;
				}

				file_put_contents(speedycache_cache_path('fonts/').$font_name.'/'.$file_name, $font); // Creating the font file
				$css = str_replace($url, SPEEDYCACHE_CACHE_URL .'/'. SPEEDYCACHE_SERVER_HOST . '/fonts/'. $font_name .'/'. $file_name, $css);
			}

			if(file_exists(speedycache_cache_path('fonts/').$font_name.'/'.$font_name . '.css')){
				return;
			}

			//If we need to add swap then either we failed to add display=swap to the url or it didnt return what we expected.
			if(strpos($css, 'swap') === FALSE){
				$css = preg_replace('/(^@font-face\s{)/m', "$1\n  font-display: swap;", $css);
			}
			
			file_put_contents(speedycache_cache_path('fonts/').$font_name.'/'.$font_name . '.css', $css);
		}
	}

	// Replaces font url to the local font url
	static function replace($content){
		
		$cache_dir = speedycache_cache_path();
		
		if(!is_dir($cache_dir . '/fonts')){
			@mkdir($cache_dir . '/fonts', 0755, true);
		}

		$fonts = array_diff(@scandir($cache_dir . 'fonts'), array('..', '.'));
		
		if(empty($fonts)){
			return $content;
		}

		// To remove any preload or dns-fetch or preconnect for google fonts
		preg_match_all('/<link(?:[^>]+)?href=(["\'])([^>]*?fonts\.(gstatic|googleapis)\.com.*?)\1.*?>/i', $content, $google_links, PREG_SET_ORDER);
			
		if(!empty($google_links)){
			foreach($google_links as $google_link){

				preg_match('/rel=(["\'])(.*?(preload|preconnect|dns-fetch).*?)\1/i', $google_link[2], $removeable_link);

				if(!empty($removeable_link)){
					$content = str_replace($google, '', $html);
				}
			}
		}
		
		/**
		  * Our Font css name is in md5(created from the font URL) and we dont have URL in this function to get
		  * all the google fonts url to replace the fonts .
		*/
		preg_match_all('/<link.*href=(["\'])(.*fonts\.googleapis\.com\/css.*?)\1/m', $content, $font_rels);
		
		if(empty($font_rels[2])){
			return $content;
		}
		
		foreach($font_rels[2] as $url){
			foreach($fonts as $font){

				if(in_array($font, array('.', '..'))){
					continue;
				}
				
				if(!file_exists($cache_dir . 'fonts/' . $font . '/' . $font . '.css')){
					continue;
				}
				
				$css_url = SPEEDYCACHE_CACHE_URL .'/'. SPEEDYCACHE_SERVER_HOST . '/fonts/' . $font . '/' . $font . '.css';
				
				if(md5($url) === $font){
					$content = preg_replace('/<link(.*)href=(["\'])(.*fonts\.googleapis\.com\/css.*?)\2/m', '<link$1 href="'.$css_url .'" ', $content);
				}
			}
		}
		
		return $content;
	}
	
	static function add_swap($content){	
		$content = str_replace('&#038;display=swap', '', $content);
		$content = str_replace('&display=swap', '', $content);

		// Add font-display=swap as a querty parameter to Google fonts
		$content = str_replace('googleapis.com/css?family', 'googleapis.com/css?display=swap&family', $content);
		
		return $content;
	}

}
PK��f\�|7ll
commoncss.phpnu�[���<?php 

/*
* SPEEDYCACHE
* https://speedycache.com/
* (c) SpeedyCache Team
*/

namespace SpeedyCache;

if(!defined('ABSPATH')){
	die('Hacking Attempt!');
}

class CommonCss{
	
	static function get_endpoint($is_unusedcss = false){
		global $speedycache;

		$endpoints = get_transient('speedycache_ccss_endpoint');

		$target_file = empty($is_unusedcss) ? 'index.php' : 'ucss.php';

		$mirror = 'https://s4.softaculous.com/a/speedycache/critical-css/' . $target_file;		
		$license = strpos($speedycache->license['license'], 'SPDFY') !== 0 ? '' : $speedycache->license['license'];

		if(empty($endpoints)){
			$res = wp_remote_get(SPEEDYCACHE_API.'license.php?license='.$license.'&url='.rawurlencode(site_url()));

			// Did we get a response ?
			if(!is_array($res)){
				return $mirror;
			}
			
			if(empty($res['body'])){
				return $mirror;
			}

			$body = json_decode($res['body'], true);

			if(empty($body['fast_mirrors'])){
				return $mirror;
			}
			
			$endpoints = $body['fast_mirrors'];
			
			if(empty($endpoints) || !is_array($endpoints)){
				return $mirror;
			}
		}
		
		$index = floor(rand(0, count($endpoints) - 1));

		if(empty($endpoints[$index])){
			return $mirror;
		}

		set_transient('speedycache_ccss_endpoint', $endpoints, 180);

		$mirror = str_replace('a/softaculous', 'a/speedycache/critical-css/'.$target_file, $endpoints[$index]);
		
		return $mirror;
		
	}
	
	static function schedule($schedule_name, $urls){

		$scheduled = self::get_schedule(array($schedule_name));
		$time = time();
		
		if(!empty($scheduled) && isset(end($scheduled)['time'])){
			// getting the last index to get the last scheduled event
			$time = end($scheduled)['time'] + 10;
		}
		
		$final_schd_time = $time;
	
		if(!wp_next_scheduled($schedule_name, array('urls' => $urls))){
			wp_schedule_single_event($final_schd_time, $schedule_name, array('urls' => $urls));
		}
	}
	
	// Returns an array of cron event "speedycache_unused_css"
	static function get_schedule($event_name){
		$cron = _get_cron_array();
		
		if(empty($cron)){
			return false;
		}
		
		$scheduled = array();
		
		foreach($cron as $key => $crn){
			foreach($crn as $e_key => $event){
				if(!in_array($e_key, $event_name)){
					continue;
				}

				$args = [];

				foreach($event as $evt){
					if(!empty($evt['args'][0])){
						$args = $evt['args'][0];
					}
				}
				
				array_push($scheduled, array('name' => get_the_title($args), 'time' => $key));
			}
		}
		
		return $scheduled;
	}
	
	// Adds the Critical CSS to the cache file
	static function update_cached($file, $css){
		global $speedycache;

		if(!file_exists($file)){
			return;
		}

		$content = file_get_contents($file);
		
		if(empty($content)){
			return;
		}
		
		$content = static::update_content($content, $css);

		// Updates the .html.gz file
		if(!empty($speedycache->options['gzip'])){
			self::update_gzip($file, $content);
		}
		
		// Updates the .html file
		file_put_contents($file, $content);
	}

	static function update_gzip($file, $content){
		
		$gz_file = str_replace('.html', '.html.gz', $file);
		
		if(file_exists($gz_file)){
			unlink($gz_file);
		}
		
		$content = gzencode($content, 6);
		
		if(!empty($content)){
			file_put_contents($gz_file, $content);
		}
	}
	
	static function log($log_name, $message, $url = '-'){
		$ccss_logs = get_option($log_name, []);
		
		if(count($ccss_logs) > 10){
			array_shift($ccss_logs);
		}
		
		$ccss_logs[$url] = array('time' => date('h:i:s'), 'message' => $message);
		update_option($log_name, $ccss_logs);
	}
	
	
}PK��f\��f�)	)	youtube.htmlnu�[���<html>
<head>
	<style type="text/css">
body{background-color:#000;color:#fff;font:12px Roboto,Arial,sans-serif;height:100%;margin:0;overflow:hidden;padding:0;position:absolute;width:100%}
.y{background-position:center center;background-repeat:no-repeat;background-size:cover;height:100%;position:absolute;width:100%}
.yb{position:absolute;cursor:pointer;width:90px;height:60px;background-color:#333;box-shadow:0 0 30px rgba(0,0,0,0.6);z-index:1;opacity:.8;border-radius:6px}
.yb:before{content:"";border-style:solid;border-width:15px 0 15px 26px;border-color:transparent transparent transparent #fff}
.yb, .yb:before{position:absolute;top:50%;left:50%;transform:translate3d(-50%,-50%,0)}
.yb:hover{background-color:#ff0000;}
iframe{position:absolute;height:100%;width:100%;top:0;left:0;}
	</style>
	<script type="text/javascript">
var i=location.hash.match(/\#([^\?]+)/);
function img(){
	var q = window.innerWidth < 321 ? "mqdefault" : (window.innerWidth > 320 && window.innerWidth < 481 ? "hqdefault" : (window.innerWidth > 480 && window.innerWidth < 750 ? "sddefault" : "maxresdefault"));
	var img = document.createElement("IMG");
	img.setAttribute( "src", 'https://i.ytimg.com/vi/' + i[1] + '/' + q + '.webp');
	img.addEventListener('load', function(e){
		if(e.target.width == 120 && e.target.height == 90 && window.innerWidth > 320){
			e.target.setAttribute( 'src', 'https://i.ytimg.com/vi/' + i[1] + '/' + "hqdefault" + '.jpg');
		}
		document.getElementById("d").style['background-image'] = 'url(' + e.target.src + ')';
	});
	
	
	document.getElementById('d').addEventListener('click', function(){
		var start = window.location.hash.match(/[^a-zA-Z\d\s:](start\=\d+)/i);
		var hash = ["rel=0", "showinfo=0", "autoplay=1"];
		var ifrm = document.createElement("iframe");
		if(start){hash.push(start[1]);}
		ifrm.setAttribute("frameborder", "0");
		ifrm.setAttribute("allowfullscreen", "");
		ifrm.setAttribute("allow", "autoplay");
		ifrm.setAttribute( "src", "https://www.youtube.com/embed/"+ i[1] +"?" + hash.join("&"));
		this.innerHTML = "";
		this.appendChild(ifrm);
	});
};

window.addEventListener('resize', function(){img();});
window.addEventListener('load', function(){img();});


	</script>
</head>
<body>
	<div id="d" class="y">
		<div class="yb"></div>
	</div>
</body>
</html>PK��f\���j��cli.phpnu�[���<?php
/*
* SPEEDYCACHE
* https://speedycache.com/
* (c) SpeedyCache Team
*/

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

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

class speedycache_cli extends \WP_CLI_Command{


	/**
	  * Purges/Cleares cache or minified files
	  * ## OPTIONS
	  * <type>
	  * : Purges cache or minified
	  * ---
	  * options:
	  *  - cache
	  *  - and minified
	  *
	  * ## EXAMPLES
	  * # Purge Cache
	  * $ wp speedycache purge cache
	  *
	  * # Purge cache and minfied
	  * $ wp speedycache purge cache and minified
	*/
	public function purge($args, $args_assoc){
		global $speedycache;

		if(!isset($speedycache)){
			WP_CLI::error('speedycache has not been defined!');
		}

		if(!function_exists('speedycache_delete_cache')){
			WP_CLI::error('speedycache_delete_cache() does not exist!');
		}

		if(empty($args[0]) || $args[0] !== 'cache'){
			self::wrong_usage();
		}
		
		if(empty($args[1]) || empty($args[2])){
			$this->delete_cache();
			return;
		}
		
		if($args[1] == 'and' && $args[2] == 'minified'){
			$this->delete_cache(true);
			return;
		}
	
		self::wrong_usage();
	}
	
	private function delete_cache($minified_too = false){
		if(function_exists('speedycache_delete_cache')){
			WP_CLI::error('Somethinng Went Wrong: Unable to delete cache');
		}

		WP_CLI::line('Clearing the ALL cache...');
		
		if(defined('SPEEDYCACHE_VERSION') && version_compare(SPEEDYCACHE_VERSION, '1.2.0', '>=')){
			$delete['minified'] = $minified_too;
			\SpeedyCache\Delete::run($delete);
		} else {
			speedycache_delete_cache($minified_too);
		}

		WP_CLI::success('The cache has been cleared!');
	}
}

WP_CLI::add_command('speedycache', 'speedycache_cli');PK��f\`J�*��metaboxpro.phpnu�[���<?php

/*
* SPEEDYCACHE
* https://speedycache.com/
* (c) SpeedyCache Team
*/

namespace SpeedyCache;

if(!defined('ABSPATH')){
	die('Hacking Attempt');
}

class MetaboxPro{

	static function html($content, $post_id){
		global $speedycache;
		
		if(empty($speedycache->options['critical_css'])){
			return '';
		}

		$post_meta = get_post_meta($post_id, 'speedycache_post_meta', true);

		$html = '<div class="speedycache-option-wrap">
	<div class="speedycache-option-info">
		<span class="speedycache-option-name">'.esc_html__('Disable CriticalCSS', 'speedycache').'</span>
	</div>
	<label for="speedycache-disable-critical-css" class="speedycache-custom-checkbox">
		<input type="checkbox" id="speedycache-disable-critical-css" name="speedycache_disable_critical_css" '. (!empty($post_meta['disable_critical_css']) ? ' checked' : ''). '/>
		<div class="speedycache-input-slider"></div>
	</label>
</div>

<h3>Critical CSS</h3>
<p>Create Crtical CSS for this page</p>
<button class="button" id="speedycache-generate-specific-cache">Generate CriticalCSS</button>
';

		return $html;

	}

	static function enqueue_scripts(){
		global $speedycache, $post;

		if(empty($speedycache->options['critical_css'])){
			return;
		}

		wp_enqueue_script('speedycache_metabox', SPEEDYCACHE_PRO_URL . '/assets/js/metabox.js', array('jquery'), SPEEDYCACHE_PRO_VERSION, true);
		
		wp_localize_script('speedycache_metabox', 'speedycache_metabox', array(
			'nonce' => wp_create_nonce('speedycache_nonce'),
			'post_id' => !empty($post->ID) ? $post->ID : '',
			'url' => admin_url('admin-ajax.php')
		));
	}
	
	// Filter to sets options to be saved for post meta
	static function options($options){
		global $speedycache;
		
		if(empty($options)){
			$options = [];
		}
		
		if(!is_array($options)){
			$options = [$options]; 
		}
		
		if(!empty($speedycache->options['critical_css'])){
			$options[] = 'disable_critical_css';
		}
		
		return $options;
	}
}
PK��f\���=��db.phpnu�[���<?php
/*
* SPEEDYCACHE
* https://speedycache.com/
* (c) SpeedyCache Team
*/

namespace SpeedyCache;

if( !defined('SPEEDYCACHE_PRO_VERSION') ){
	die('HACKING ATTEMPT!');
}

class DB{

	static function clean($type){
		global $wpdb;

		if($type === 'transient_options'){
			$wpdb->query("DELETE FROM `$wpdb->options` WHERE option_name LIKE '%\_transient\_%' ;");
			wp_send_json(array('success' => true));
		}
		
		if($type === 'expired_transient'){
			$wpdb->query("DELETE FROM `$wpdb->options` WHERE option_name LIKE '_transient_timeout%' AND option_value < " . time());
			
			wp_send_json(array('success' => true));
		}
		
		if($type === 'trackback_pingback'){
			$wpdb->query("DELETE FROM `$wpdb->comments` WHERE comment_type = 'trackback' OR comment_type = 'pingback' ;");
			wp_send_json(array('success' => true));
		}
		
		if($type === 'trashed_spam_comments'){
			$wpdb->query("DELETE FROM `$wpdb->comments` WHERE comment_approved = 'spam' OR comment_approved = 'trash' ;");
			wp_send_json(array('success' => true));
		}
		
		if($type === 'trashed_contents'){
			$wpdb->query("DELETE FROM `$wpdb->posts` WHERE post_status = 'trash';");
			wp_send_json(array('success' => true));
		}
		
		if($type === 'post_revisions'){
			$wpdb->query("DELETE FROM `$wpdb->posts` WHERE post_type = 'revision';");
			wp_send_json(array('success' => true));
		}
		
		if($type === 'all_warnings'){
			$wpdb->query("DELETE FROM `$wpdb->posts` WHERE post_type = 'revision';");
			$wpdb->query("DELETE FROM `$wpdb->posts` WHERE post_status = 'trash';");
			$wpdb->query("DELETE FROM `$wpdb->comments` WHERE comment_approved = 'spam' OR comment_approved = 'trash' ;");
			$wpdb->query("DELETE FROM `$wpdb->comments` WHERE comment_type = 'trackback' OR comment_type = 'pingback' ;");
			$wpdb->query("DELETE FROM `$wpdb->options` WHERE option_name LIKE '%\_transient\_%' ;");
			$wpdb->query("DELETE FROM `$wpdb->options` WHERE option_name LIKE '_transient_timeout%' AND option_value < " . time());

			wp_send_json(array('success' => true));
		}
	}

}

PK��f\�,Z�����renderblocking.phpnu�[���<?php

namespace SpeedyCache;

if( !defined('SPEEDYCACHE_PRO_VERSION') ){
	die('HACKING ATTEMPT!');
}

class RenderBlocking {

	static function init($html){
		global $speedycache;
		
		$speedycache->render_blocking = array();
		$speedycache->render_blocking['except'] = '';
		$speedycache->render_blocking['tags'] = array();
		$speedycache->render_blocking['header_start_index'] = 0;
		$speedycache->render_blocking['js_tags_text'] = '';
		$speedycache->render_blocking['html'] = $html;
		
		self::set_header_start_index();
		self::set_tags();
		
		$speedycache->render_blocking['tags'] = self::reorder_tags($speedycache->render_blocking['tags']);
	}

	static function set_tags(){
		self::set_comments();
		self::set_js();
		self::set_css();
	}

	static function set_comments(){
		global $speedycache;
		
		$comment_tags = self::find_tags('<!--', '-->');

		self::set_except($comment_tags);

		foreach($comment_tags as $key => $value){
			if(preg_match("/\<\!--\s*\[if/i", $value['text'])){
				if(preg_match("/data-speedycache-render\=[\"\']false[\"\']/i", $value['text'])){
					continue;
				}

				array_push($speedycache->render_blocking['tags'], $value);
			}
		}
	}

	static function set_css(){
		global $speedycache;
		
		$style_tags = self::find_tags('<style', '</style>');

		foreach($style_tags as $key => $value){
			// <script>var xxx ={"id":"4", "html":"<style>\n\t\t\t.container{color:#CCCCCC;}\n\t\t<\/style>"};</script>
			if(!preg_match("/<\/script>/i", $value['text'])){
				array_push($speedycache->render_blocking['tags'], $value);
			}
		}

		$link_tags = self::find_tags('<link', '>');

		foreach($link_tags as $key => $value){
			if(preg_match("/href\s*\=/i", $value['text'])){
				if(preg_match("/rel\s*\=\s*[\'\"]\s*stylesheet\s*[\'\"]/i", $value['text'])){
					array_push($speedycache->render_blocking['tags'], $value);
				}
			}
		}
	}

	static function set_js(){
		global $speedycache;
		
		// Creating regex to exclude js from RenderBlocking
		if(!empty($speedycache->options['render_blocking_excludes'])){
			$exclude_script_list = array_map('preg_quote', $speedycache->options['render_blocking_excludes'], array_fill(0, count($speedycache->options['render_blocking_excludes']), '/'));
			$exclude_user_script = '/\b(?:' . implode('|', $exclude_script_list) . ')\b/';
		}
		
		$script_tag = self::find_tags('<script', '</script>');
		
		foreach($script_tag as $key => $value){
			
			if(self::exclude_scripts($value['text'])){
				continue;
			}
			
			// Excludes the user specified scripts
			if(!empty($exclude_user_script) && preg_match($exclude_user_script, $value['text'])){
				continue;
			}
			
			// Import map should always load at the same place as it is meant to be loaded before other scripts.
			if(preg_match("/importmap/i", $value['text'])){
			    continue;
			}

			//<script type='text/javascript' src='http://partner.googleadservices.com/gampad/google_service.js'></script>
			if(preg_match("/partner\.googleadservices\.com\/gampad\/google_service\.js/i", $value['text'])){
				continue;
			}

			// <script type='text/javascript'>
			// GS_googleAddAdSenseService("ca-pub-1059380037");
			// GS_googleEnableAllServices();
			// </script>
			if(preg_match("/<script[^\>]*>\s*GS_googleAddAdSenseService\([\"\'][^\"\']+[\"\']\)\;\s*GS_googleEnableAllServices\(\)\;\s*<\/script>/i", $value['text'])){
				continue;
			}

			// <script type='text/javascript'>
			// GA_googleAddSlot("ca-pub-1059380037", "viajablog-300-250");
			// </script>
			if(preg_match("/<script[^\>]*>\s*GA_googleAddSlot\([^\)]+\)\;\s*<\/script>/i", $value['text'])){
				continue;
			}

			// <script type='text/javascript'>
			// GA_googleFetchAds();
			// </script>
			if(preg_match("/<script[^\>]*>\s*GA_googleFetchAds\(\)\;\s*<\/script>/i", $value['text'])){
				continue;
			}

			// <script>
			//   (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
			//   (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
			//   m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
			//   })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

			//   ga('create', 'UA-9999-9', 'auto');
			//   ga('send', 'pageview');
			// </script>
			if(preg_match("/<script[^\>]*>\s*\(function\(i,s,o,g,r,a,m\)\{i\[\'GoogleAnalyticsObject\'\]/i", $value['text'])){
				if(preg_match("/ga\(\'send\',\s*\'pageview\'\)\;\s*<\/script>/i", $value['text'])){
					continue;
				}
			}

			// <script async src="https://www.googletagmanager.com/gtag/js?id=AW-123456789"></script>
			// <script>window.dataLayer=window.dataLayer||[];
			// function gtag(){
			// dataLayer.push(arguments);
			// }
			// gtag('js', new Date());
			// gtag('config', 'AW-123456789');</script>
			// <script type="text/javascript">
			// gtag('event', 'page_view', {
			// 'send_to': 'AW-123456789',
			// 'ecomm_pagetype': 'home'
			// });
			//</script>
			if(preg_match("/<script[^\>]+googletagmanager\.com\/gtag\/js[^\>]+>/i", $value['text'])){
				continue;
			}
			
			if(preg_match("/^<script>\s*window\.dataLayer\s*=\s*window\.dataLayer/i", $value['text']) && 
				preg_match("/gtag\([^\)]+\)\s*\;\s*<\/script>$/i", $value['text'])){
				continue;
			}

			/*
			<script id="bx24_form_inline" data-skip-moving="true">
				(function(w,d,u,b){w['Bitrix24FormObject']=b;w[b] = w[b] || function(){arguments[0].ref=u;
						(w[b].forms=w[b].forms||[]).push(arguments[0])};
						if(w[b]['forms']) return;
						var s=d.createElement('script');s.async=1;s.src=u+'?'+(1*new Date());
						var h=d.getElementsByTagName('script')[0];h.parentNode.insertBefore(s,h);
				})(window,document,'https://speedycache.bitrix24.com/bitrix/js/crm/form_loader.js','b24form');

				b24form({"id":"1","lang":"en","sec":"yesxbh","type":"inline"});
			</script>
			*/
			if(preg_match("/data-skip-moving\=[\"\']true[\"\']/i", $value['text'])){
				continue;
			}

			if(preg_match('/amzn_assoc_placement/i', $value['text'])){
				// <script>amzn_assoc_placement="adunit0";
				// amzn_assoc_search_bar="false";
				// amzn_assoc_tracking_id="3d0f1f-20";
				// amzn_assoc_ad_mode="search";
				// amzn_assoc_ad_type="smart";
				// amzn_assoc_marketplace="amazon";
				// amzn_assoc_region="US";
				// amzn_assoc_title="";
				// amzn_assoc_default_search_phrase="Spray Paint ";
				// amzn_assoc_default_category="All";
				// amzn_assoc_linkid="949bfb847147d654e679d4876a8e2b77";</script>
				continue;
			}
			
			//<script type="text/javascript">document.write("<div data-role=\"amazonjs\" data-asin=\"1234567890\" data-locale=\"JP\" data-tmpl=\"\" data-img-size=\"\" class=\"asin_1234567890_JP_ amazonjs_item\"><div class=\"amazonjs_indicator\"><span class=\"amazonjs_indicator_img\"></span><a class=\"amazonjs_indicator_title\" href=\"https://www.amazon.co.jp/%E5%B8%8%E5%AF%BF/dp/1234567890?SubscriptionId=AKIAIQGSXT2U7QVCQGHA&tag=hiyokoweb06-22&linkCode=xm2&camp=2025&creative=165953&creativeASIN=4335787\">希望難民ご一行様 ピースボートと「承認の共同体」幻想 (光文社新書)</a><span class=\"amazonjs_indicator_footer\"></span></div></div>")</script>
			if(preg_match("/^<script[^\>]*>\s*document.write\([\"\']\s*<div/i", $value['text'])){
				if(preg_match("/\s*<\/div>[\"\']\)\s*<\/script>$/i", $value['text'])){
					if(preg_match("/amazonjs/i", $value['text'])){
						continue;
					}
				}
			}

			if(preg_match('/reklamstore/i', $value['text'])){
				if(preg_match("/reklamstore_region_id/i", $value['text'])){
					continue;
				}else if(preg_match("/reklamstore\.com\/reklamstore\.js/i", $value['text'])){
					continue;
				}
			}

			//<script>document.write ('<iframe id="g2324_1" src="http://site.com/index.php?display_gallery_iframe&amp;gal_id=2324_1&amp;gal_type=2&amp;gal_cap=OFF&amp;gal_page=false"></iframe>');</script>
			if(preg_match("/document\.write\s*\(/i", $value['text'])){
				if(preg_match("/<iframe/i", $value['text'])){
					continue;
				}
			}

			//Yandex.Metrika counter
			if(preg_match("/mc\.yandex\.ru\/metrika\/watch\.js/i", $value['text'])){
				if(preg_match("/yandex_metrika_callbacks/i", $value['text'])){
					continue;
				}
			}

			//<script type="text/javascript" src="https://seal.thawte.com/getthawteseal?host_name=www.site.co.za&amp;size=S&amp;lang=en"></script>
			if(preg_match("/seal\.thawte\.com/i", $value['text'])){
				continue;
			}
			
			//<script type= "text/javascript">var RecaptchaOptions = {custom_translations : { instructions_visual : "This is my text:" }};</script>
			if(preg_match("/var\s+RecaptchaOptions\s*=\s*\{/i", $value['text'])){
				continue;
			}

			/*
			<script src='https://www.google.com/recaptcha/api.js?render=12356o4hLx1PTv7yszALlb5F_M&#038;ver=3.0'></script>
			<script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=88a7E&amp;hl=en"></script>
			*/
			if(preg_match("/google\.com\/recaptcha\/api/i", $value['text'])){
				continue;
			}

			// <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
			// new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
			// j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
			// 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
			// })(window,document,'script','dataLayer','GTM-5NRFSPW');</script>
			if(preg_match("/googletagmanager\.com\/gtm\.js/i", $value['text']) && preg_match("/parentNode\.insertBefore/i", $value['text'])){
				continue;
			}

			//<script src="https://gist.github.com/name/89964fb23055f8d45f12345befd4d024.js"></script>
			if(preg_match("/gist\.github\.com\//i", $value['text'])){
				continue;
			}

			//<script async="asnyc" type="text/javascript" src="https://a-ssl.ligatus.com/?ids=11111&t=js&s=1"></script>
			if(preg_match("/a-ssl\.ligatus\.com/i", $value['text'])){
				continue;
			}

			//<script type="text/javascript" src="https://sealserver.trustwave.com/seal.js?style=invert&code=89999"></script>
			if(preg_match("/sealserver\.trustwave\.com\/seal\.js/i", $value['text'])){
				continue;
			}

			//<script language="javascript" src="//inviocare.us13.list-manage.com/generate-js/?u=f3707cdf398370b05&fid=4301&show=10" type="text/javascript"></script>
			if(preg_match("/inviocare\.us13\.list\-manage\.com\/generate\-js/i", $value['text'])){
				continue;
			}

			//<script type="text/javascript" src="https://form.jotform.co/jsform/60138856"></script>
			if(preg_match("/jotform[^\/]+\/jsform\/\d+/i", $value['text'])){
				continue;
			}

			//<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/shell.js"></script>
			//<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"></script>
			if(preg_match("/js\.hsforms\.net\/forms\//i", $value['text'])){
				continue;
			}

			/*
			<script>hbspt.forms.create({
			portalId: 5102205,
			formId: "c11016e5-6a9a-4361-a358-a2ac92b8399e",
			shortcode: "wp"
			});</script>
			*/
			if(preg_match("/<script>\s*hbspt\.forms\.create\([^\)]+\)\;\s*<\/script>/i", $value['text'])){
				continue;
			}

			//<script type="application/json" class="wp-playlist-script">
			if(preg_match("/<script[^\>]+application\/json[^\>]+/i", $value['text'])){
				// if(preg_match("/<script[^\>]+wp-playlist-script[^\>]+/i", $value['text'])){
				// 	continue;
				// }

				continue;
			}

			//<script type='application/ld+json' class='yoast-schema-graph yoast-schema-graph--main'></script>
			if(preg_match("/<script[^\>]+application\/ld\+json[^\>]+>/i", $value['text'])){
				continue;
			}

			//<script id='tmpl-nf-field-input' type='text/template'>
			//<script type='text/html' class='av-video-tmpl'>
			if(preg_match("/<script[^\>]+text\/(template|html)[^\>]+/i", $value['text'])){
				continue;
			}

			//<script type="text/css" id="tmpl-tribe_customizer_css">
			if(preg_match("/<script[^\>]+text\/css[^\>]+/i", $value['text'])){
				continue;
			}

			// <script src='https://snapppt.com/widgets/widget_loader/979939cd-504c-4b59-9dcc-9e9f39dc1d09/grid.js' class='snapppt-widget'></script>
			if(preg_match("/snapppt\.com\/widgets\/widget_loader/i", $value['text'])){
				continue;
			}

			// <script src="/plugins/smart-cookie-kit/res/empty.js" data-blocked="http://maps.googleapis.com/maps/api/js" data-sck_type="2" data-sck_unlock="profiling" data-sck_ref="Google Maps" data-sck_index="1" class="BlockedBySmartCookieKit"></script>
			if(preg_match("/class\s*\=\s*[\'\"]BlockedBySmartCookieKit[\'\"]/i", $value['text'])){
				continue;
			}

			/*
			<script src="//platform.linkedin.com/in.js" type="text/javascript">lang: en_US</script>
			<script type="IN/Share" data-counter="top" data-onSuccess="share" data-url="https://helenstock.com/product/romantic-fashion/"></script>
			*/
			if(preg_match("/platform\.linkedin\.com\/in\.js/i", $value['text']) || preg_match("/type=[\"\']IN\/Share[\"\']/i", $value['text'])){
				continue;
			}

			/*
			<script id="mNCC" language="javascript">
			medianet_width="336";
			medianet_height="280";
			medianet_crid="656555462";
			medianet_versionId="3111299";
			</script>
			<script src="//contextual.media.net/nmedianet.js?cid=8CU33LCO0"></script>
			*/
			if((preg_match('/medianet_width/i', $value['text']) && preg_match('/medianet_height/i', $value['text'])) || preg_match("/contextual\.media\.net\/nmedianet\.js/i", $value['text'])){
				continue;
			}

			/*
			<script class="cmplz-stats">(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||fu);</script>
			<script class="cmplz-native">function complianz_enable_cookies(){console.log("enabling cookies");}</script>
			https://wordpress.org/plugins/complianz-gdpr/
			*/
			if(preg_match("/class\s*\=\s*[\"\']cmplz-(stats|native)\s*[\"\']/i", $value['text'])){
				continue;
			}

			/*
			Advanced noCaptcha & invisible Captcha
			var anr_onloadCallback=function(){
			};
			*/
			if(preg_match('/anr_onloadCallback/i', $value['text'])){
				continue;
			}

			$speedycache->render_blocking['js_tags_text'] = $speedycache->render_blocking['js_tags_text'].$value['text'];

			array_push($speedycache->render_blocking['tags'], $value);
		}
	}

	static function set_header_start_index(){
		global $speedycache;
		
		$head_tag = self::find_tags('<head', '>');
		
		$speedycache->render_blocking['header_start_index'] = 0;
		if(!empty($head_tag[0]) && !empty($head_tag[0]['start'])){
			$speedycache->render_blocking['header_start_index'] = $head_tag[0]['start'];
		}

	}

	static function reorder_tags($tags){
		// <script>jQuery('head').append('<style>' + arr_splits[i] + '</style>');</script>
		// <script>document.getElementById("id").innerHTML='<div> <span> <!--[if !IE]>--> xxx <!--<![endif]--> </span></div>';</script>
		$list = array();
		
		for ($i=0; $i < count($tags); $i++){
			for ($j=0; $j < count($tags); $j++){ 
				if($tags[$i]['start'] > $tags[$j]['start']){
					if($tags[$i]['end'] < $tags[$j]['end']){
						array_push($list, $i);
					}
				}
			}
		}

		foreach($list as $key => $value){
			unset($tags[$value]);
		}

		$sorter = array();
		$ret = array();

		foreach($tags as $ii => $va){
			$sorter[$ii] = $va['start'];
		}

		asort($sorter);

		foreach($sorter as $ii => $va){
			$ret[$ii] = $tags[$ii];
		}

		$tags = $ret;

		return $tags;
	}

	static function exclude_scripts($text){

		$excludeables = array(
			'/google_ad_client/',
			'/googlesyndication\.com/',
			'/app\.getresponse\.com/i',
			'/adsbygoogle/i',
			'/^<script[^\>]*>\s*gtag\([^\)]+\)\s*\;\s*<\/script>$/i',
			'/smarticon\.geotrust\.com\/si\.js/i',
			'/veedi\.com\/player\/embed\/veediEmbed\.js/i',
			'/cdn\.ampproject\.org/i',
			'/data-speedycache-render\=[\"\']false[\"\']/i',
			'/adserver\.adtechjp\.com/i',
			'/ib\.3lift\.com/i',
			'/adtradradservices\.com/i',
			'/static.clickpapa.com\/c\.js/i',
			'/clickpapa_ad_client/i',
			'/cts\.tradepub\.com/i',
			'/_areklam_target|ad\.arklm\.com/i',
			'/admatic\.com\.tr/i',
			'/ca\.cubecdn\.net/i',
			'/amazon-adsystem\.com\/widgets\/onejs/i',
			'/cdn\.playwire\.com\/bolt\/js\/zeus\/embed\.js/i',
			'/static\.mailerlite\.com/i',
		);
		
		$is_excludeable = false;

		foreach($excludeables as $excludeable){
			if(preg_match($excludeable, $text)){
				$is_excludeable = true;
				break;
			}
		}

		
		return $is_excludeable;
	}

	static function set_except($tags){
		global $speedycache;
		
		foreach($tags as $key => $value){
			$speedycache->render_blocking['except'] = $value['text'].$speedycache->render_blocking['except'];
		}
	}

	static function find_tags($start_string, $end_string, $html = false){
		global $speedycache;
		
		$data = $speedycache->render_blocking['html'];
		if(!empty($html)){
			$data = $html;
		}

		$list = array();
		$start_index = false;
		$end_index = false;

		for($i = 0; $i < strlen($data); $i++){
			if(substr($data, $i, strlen($start_string)) == $start_string){
				if(!$start_index && !$end_index){
					$start_index = $i;
				}
			}

			if(empty($start_index) || $i < $start_index){
				continue;
			}

			if(substr($data, $i, strlen($end_string)) !== $end_string){
				continue;
			}
			
			$end_index = $i + strlen($end_string) - 1;
			$text = substr($data, $start_index, ($end_index - $start_index + 1));

			if($html === false){
				$tag = self::get_tags($start_index, $text, $end_index);

				if($tag !== FALSE){
					array_push($list, $tag);
				}
			}else{
				array_push($list, array('start' => $start_index, 'end' => $end_index, 'text' => $text));
			}

			$start_index = false;
			$end_index = false;
		}

		return $list;
	}

	static function get_tags($start_index, $text, $end_index){
		global $speedycache;
		
		if($start_index <= $speedycache->render_blocking['header_start_index']){
			return false;
		}
		
		if($speedycache->render_blocking['except']){
			if(strpos($speedycache->render_blocking['except'], $text) === false){
				return array('start' => $start_index, 'end' => $end_index, 'text' => $text);
			}
			
			return false;
		}
		
		return array('start' => $start_index, 'end' => $end_index, 'text' => $text);
	}

	static function split_html_condition($tag){
		if(substr_count($tag, '<!--') !== substr_count($tag, '-->')){
			return false;
		}

		if(!preg_match("/\<\!--\s*\[if[^\>]+>/i", $tag, $start_cond)){
			return false;
		}

		if(!preg_match("/<\!\[endif\]-->/i", $tag, $end_cond)){
			return false;
		}
				
		$all = array();

		$script_tag = self::find_tags('<script', '</script>', $tag);
		$style_tags = self::find_tags('<style', '</style>', $tag);
		$link_tags = self::find_tags('<link', '>', $tag);

		$all = array_merge($script_tag, $style_tags, $link_tags);

		$all = self::reorder_tags($all);

		foreach($all as $key => &$value){
			$value['text'] = $start_cond[0].$value['text'].$end_cond[0];
		}

		return $all;
	}

	static function add_defer_attr($tags){
		$external_start = false;

		foreach($tags as $key => &$value){

			if(preg_match("/^<script/i", $value['text'])){
				if(preg_match("/var\s+[^\=\;\s\"\']+\s*\=\s*new\s+[^\(\)]+\(/i", $value['text'])){
					//var block_td_uid_2_58aab3b5b4eb1=new tdBlock()
					break;
				}else if(preg_match("/jQuery\(\s*window\s*\)\.load\(/i", $value['text']) || preg_match("/\\$\(\s*window\s*\)\.load\(/i", $value['text'])){
					//jQuery(window).load(function(){
					//$(window).load(function(){
					break;
				}else if(preg_match("/^<script[^\>]*>\s*jQuery\([^\)\(]+\)\.[a-z]+\(/i", $value['text']) && strpos($value['text'], "\n") === FALSE){
					//<script>jQuery("div").append("");</script>

					$value['text'] = self::defer_load_inline_js($value['text']);
				}else if(preg_match("/^<script[^\>]*>\s*\(function\(\\$\)\{[^\}\n]+\}\)\(jQuery\)\;\s*<\/script>/", $value['text'])){
					//<script>(function($){"use strict";$("html").removeClass("ut-no-js").addClass("ut-js js");})(jQuery);</script>

					$value['text'] = self::defer_load_inline_js($value['text']);
				}else if(preg_match("/^<script[^\>]+src=[\'\"][^\>]+>/i", $value['text'])){
					if(preg_match("/data-cfasync\=/i", $value['text'])){
						break;
					}

					if(preg_match("/googletagmanager\.com/i", $value['text'])){
						continue;
					}

					if(!preg_match("/\s+defer\s+/i", $value['text'])){
						$value['text'] = preg_replace("/<script\s+/", '<script defer ', $value['text']);
					}

					$external_start = true;
				}else{
					//inline js

					if(preg_match("/connect\.facebook\.net/i", $value['text']) && preg_match("/parentNode\.insertBefore/i", $value['text'])){
						// <script>(function(d, s, id){
						// var js, fjs=d.getElementsByTagName(s)[0];
						// if(d.getElementById(id)) return;
						// js=d.createElement(s); js.id=id;
						// js.async=true;
						// js.src="//connect.facebook.net/nl_NL/sdk.js#xfbml=1&version=v2.8&appId=1126044540802926";
						// fjs.parentNode.insertBefore(js, fjs);
						// }(document, 'script', 'facebook-jssdk'));</script>

						continue;
					}else if(preg_match("/<script[^\>]*>\s*_stq\s*\=\s*window\._stq/i", $value['text']) && preg_match("/_stq\.push\s*\([^\)]+\)\s*\;\s*<\/script>/i", $value['text'])){
						// <script type='text/javascript'>
						// _stq = window._stq || [];
						// _stq.push([ 'view', {v:'ext',j:'1:5.5',blog:'121052134',post:'88',tz:'3',srv:'www.bibersa.com'} ]);
						// _stq.push([ 'clickTrackerInit', '121052134', '88' ]);
						// </script>

						continue;
					}else{
						if($external_start){
							break;
						}else{
							if(preg_match("/var\s+wpforms(_settings|RecaptchaLoad|RecaptchaCallback)\s*\=/i", $value['text'])){
								// WPForms Lite
								// var wpforms_settings = {variable}
								// var wpformsRecaptchaLoad=function(){
								// var wpformsRecaptchaCallback=function
								continue;
							}

							if(preg_match("/window\.TL_Const/i", $value['text']) && preg_match("/var\s+TL_Const/i", $value['text'])){
								// Thrive Leads
								// if(!window.TL_Const){var TL_Const=
								continue;
							}

							if(preg_match("/<script[^\>]+application\/ld\+json[^\>]+>/i", $value['text'])){
								// <script type="application/ld+json">
								// {
								// "@context": "http://schema.org/",
								// "@type": "Product",
								// "name": "Product Name",
								// "image": "/default.png",
								// "aggregateRating": {
								// "@type": "AggregateRating",
								// "ratingValue": "5",
								// "reviewCount": "81"
								// }
								// }
								// </script>
								continue;
							}

							if(preg_match("/_translator_revolution_dropdown/i", $value['text'])){
								// <script>var _translator_revolution_dropdown=_translator_revolution_dropdown||{languages: ["en","fr","de"],excludeSelector: "code, #wpadminbar",locationWidget: false};</script>

								continue;
							}

							$value['text'] = self::defer_load_inline_js($value['text']);
						}
					}
				}
			}else if(preg_match("/^<(link|style)/i", $value['text'])){
				continue;
			}else if(preg_match("/<\!--\s*\[if/i", $value['text'])){
				preg_match_all("/<script[^\>]+src=[\'\"][^\>]+>/i", $value['text'], $src_number);
				preg_match_all("/<script[^\>]*/i", $value['text'], $script_tag_number);

				if(count($script_tag_number[0]) != count($src_number[0])){
					break;
				}

				if(preg_match("/<link|<style/i", $value['text'])){
					break;
				}

				if(!preg_match("/<script[^\>]+src=[\'\"][^\>]+>/i", $value['text'])){
					break;
				}

				if(preg_match("/data-cfasync\=/i", $value['text'])){
					break;
				}

				if(!preg_match("/<script[^\>]+defer[^\>]+>/i", $value['text'])){
					$value['text'] = preg_replace("/<script\s+/", '<script defer ', $value['text']);
				}
			}else{
				break;
			}
		}

		return $tags;
	}

	static function action($render_blocking_css = false, $make_defer = false){
		global $speedycache;
		
		$wpemojiSettings = '';
		$google_fonts = '';
		$bootstrapcdn = '';
		$inline_js = '';
		$document_ready_js = '';
		$third_part_js = '';
		$script = '';
		$style = '';
		
		//to remove tags
		$speedycache->render_blocking['tags'] = array_reverse($speedycache->render_blocking['tags']);
		
		foreach($speedycache->render_blocking['tags'] as $key => &$value){
			if(preg_match("/\<\!--\s*\[if[^\>]+>/i", $value['text'])){
				if($arr = self::split_html_condition($value['text'])){
					$style = '';
					$script = '';

					foreach($arr as $arr_key => $arr_value){
						if(preg_match("/\<\!--\s*\[if[^\>]+>(<link|<style)/i", $arr_value['text'])){
							$style = $style."\n".$arr_value['text'];
						}else if(preg_match("/\<\!--\s*\[if[^\>]+><script/i", $arr_value['text'])){
							$script = $script."\n".$arr_value['text'];
						}
					}
				}

				$value['text'] = $script;
				$speedycache->render_blocking['html'] = substr_replace($speedycache->render_blocking['html'], $style, $value['start'], ($value['end'] - $value['start'] + 1));
			}else if(preg_match("/^<script/i", $value['text'])){
				$speedycache->render_blocking['html'] = substr_replace($speedycache->render_blocking['html'], '', $value['start'], ($value['end'] - $value['start'] + 1));
			}else if(preg_match("/^<link[^\>]+(fonts|ajax)\.googleapis\.com[^\>]+>/", $value['text'])){
				if(!empty($speedycache->options['google_fonts'])){
					$speedycache->render_blocking['html'] = substr_replace($speedycache->render_blocking['html'], '', $value['start'], ($value['end'] - $value['start'] + 1));

					$google_fonts = $value['text']."\n".$google_fonts;
				}
			}else if(preg_match("/^<link[^\>]+(maxcdn)\.bootstrapcdn\.com[^\>]+>/", $value['text'])){
				$speedycache->render_blocking['html'] = substr_replace($speedycache->render_blocking['html'], '', $value['start'], ($value['end'] - $value['start'] + 1));

				$bootstrapcdn = $value['text']."\n".$bootstrapcdn;
			}
		}
		
		foreach($speedycache->render_blocking['tags'] as $key => &$value){
			
			if($value['text'] && preg_match("/^<script/i", $value['text'])){
				if(preg_match("/gravatar\.com\/js\/gprofiles\.js/i", $value['text']) || 
					preg_match("/use\.fontawesome\.com/i", $value['text']) || 
					preg_match("/s0\.wp\.com\/".SPEEDYCACHE_WP_CONTENT_DIR."\/js\/devicepx-jetpack\.js/i", $value['text'])){
					//<script type='text/javascript' src='http://s.gravatar.com/js/gprofiles.js?ver=2023Janaa'></script>
					//<script type='text/javascript' src='http://s0.wp.com/site-data/js/devicepx-jetpack.js?ver=201701'></script>
					//<script defer src="https://use.fontawesome.com/123456789.js"></script>

					if(!preg_match("/\sdefer\s/i", $value['text'])){
						$value['text'] = preg_replace("/<script\s+/", '<script defer ', $value['text']);
					}

					if(!preg_match("/\sasync\s/i", $value['text'])){
						$value['text'] = preg_replace("/<script\s+/", '<script async ', $value['text']);
					}

					unset($speedycache->render_blocking['tags'][$key]);
					$third_part_js = $value['text']."\n".$third_part_js;
				}else if(preg_match("/document\.addEventListener\(\s*[\"\']\s*DOMContentLoaded\s*[\"\']\s*,\s*function\s*\([^\)]*\)\s*\{/i", $value['text'])){
					//to remove jQuery(document) which contains window.attachEvent
					unset($speedycache->render_blocking['tags'][$key]);
					$document_ready_js = $value['text']."\n".$document_ready_js;
				}else if(preg_match("/^<script[^\>]*>\s*jQuery\(\s*document\s*\)\.ready\(/i", $value['text'])){
					// <script>
					// 	jQuery(document).ready(function($){
					// 	});
					// </script>

					if(preg_match("/jQuery\(\s*window\s*\)\.load\(/i", $value['text'])){
						//jQuery(window).load(function(){
						continue;
					}

					if(preg_match("/\\$\(\s*window\s*\)\.load\(/i", $value['text'])){
						//$(window).load(function(){
						continue;
					}

					if(preg_match("/var owl\s*=\s*\\$\([\'\"]\.products-carousels-/i", $value['text'])){
						//to exclude carousel of Master Slider
						//https://codecanyon.net/item/master-slider-wordpress-responsive-touch-slider
						//var owl=$('.products-carousels-99056136 #products');
						continue;
					}
					
					if(preg_match("/\}\s*\)\s*\;\s*<\/script>$/i", $value['text'])){
						$jqIsReady_func_name = 'jqIsReady_'.rand(100,999);
						$value['text'] = preg_replace("/(<script[^\>]*>)/i", "$1"."(function ".$jqIsReady_func_name."(){if(typeof jQuery === \"undefined\"){".$jqIsReady_func_name."();}else{", $value['text']);
						$value['text'] = preg_replace("/\s*(<\/script>)/i", "}})();"."$1", $value['text']);

						unset($speedycache->render_blocking['tags'][$key]);
						$document_ready_js = $value['text']."\n".$document_ready_js;
					}
				}else if(preg_match("/^<script[^\>]*>\s*window\.\_wpemojiSettings/", $value['text'])){
					//to remove window._wpemojiSettings from tags
					unset($speedycache->render_blocking['tags'][$key]);
					$wpemojiSettings = $wpemojiSettings."\n".$value['text'];
				}else if(!preg_match("/^<script[^\>]+src=[\'\"][^\>]+>/", $value['text'])){
					//to remove inline js which do not contain any function
					//<script>var _wpcf7={"loaderUrl":"sample"};</script>
					$tmp = $value['text'];

					// <script>/*<![CDATA[*/var THO_Front = THO_Front || {}; THO_Front.data = {"end_of_content_id":"tho-end","const":{"_e_click":1,"_engagement":2}}/*]]> */</script>
					$tmp = preg_replace("/<script[^\>]+>\s*\/\*\s*<\!\[CDATA\[\s*\*\//", "", $tmp);
					$tmp = preg_replace("/\/\*\s*\]\]>\s*\*\/\s*<\/script>/", "", $tmp);

					// to remove multi-line comments but it removes everything. it does not work properly
					$tmp = preg_replace("/\s*\/\*(.+)\*\/\s*/", '', $tmp);

					//var themifyScript causes "fixed header" issue on thepurplepumpkinblog.co.uk
					if(preg_match("/var\sthemifyScript/i", $tmp)){
						continue;
					}

					//<script data-cfasync="false" type="text/javascript">var lsjQuery = jQuery;</script>
					if(preg_match("/data-cfasync\=[\"\']false[\"\']/i", $tmp)){
						continue;
					}

					if(preg_match("/(function|jQuery|if)\s*\([^\)\(]+\)/i", $tmp)){
						if(!preg_match("/<script[^\>]*>\s*function heateorSssLoadEvent/i", $tmp)){
							//https://plugins.trac.wordpress.org/browser/sassy-social-share/trunk/includes/class-sassy-social-share-widgets.php#L72
							//https://plugins.trac.wordpress.org/browser/sassy-social-share/trunk/public/class-sassy-social-share-public.php#L104

							continue;
						}
					}

					//var block_td_uid_2_58aab3b5b4eb1=new tdBlock()
					if(preg_match("/var\s+[^\=\;\s\"\']+\s*\=\s*new\s+[^\(\)]+\(/i", $tmp)){
						continue;
					}

					//<script>var lsjQuery = jQuery;</script>
					if(preg_match("/var\s+[^\=\s]+\s*\=\s*jQuery\s*\;/i", $value['text'])){
						continue;
					}

					//<script>Abtf.css();</script>
					//<script>dtGlobals.logoEnabled=1;</script>
					//if var does not exist
					if(!preg_match("/var\s*[a-z0-9_]+\s*\=\s*[^\;]+\s*\;/i", $tmp)){
						continue;
					}

					//$=jQuery.noConflict()
					//var joblistin_caned_msgs=jQuery.parseJSON('[{\"title\":\"jobs description 1\",
					if(preg_match("/\=\s*jQuery\.(noConflict|parseJSON)\(/i", $tmp)){
						continue;
					}

					//$(".menu-item-has-children a")
					if(preg_match("/\\\$\s*\(\s*[\"\']/", $tmp)){
						continue;
					}

					/*
					<script>
					jQ_nxs(document).on('nxs_event_resizeend.menu_mini_expand', function(){
						//something
					});
					</script>
					*/
					if(preg_match("/\([^\)]+\)\.on\(\s*[\'\"][^\'\"]+[\'\"]\s*\,\s*function\(\)\{/", $tmp)){
						continue;
					}

					/*
					<script>
					videojs("vid1").videoJsResolutionSwitcher();
					var my_video_id = videojs("vid1");
					my_video_id.watermark({ file: "/site-data/uploads/2019/05/logo.png", xpos: 0, ypos: 0, xrepeat: 0, opacity: 1,clickable: true,url: "https://www.site.net"  });
					</script>
					*/
					if(preg_match("/videojs\([^\)\(]+\)\.videoJsResolutionSwitcher/", $tmp)){
						continue;
					}

					unset($speedycache->render_blocking['tags'][$key]);
					$inline_js = $value['text']."\n".$inline_js;

				}
			}
		}

		//to add Google Fonts at the end of page before js sources
		if(!empty($google_fonts)){
			//$google_fonts = self::combine_google_fonts($google_fonts);

			if(!empty($speedycache->options['google_fonts'])){
				
				if(preg_match('/speedycache-google-fonts/', $speedycache->render_blocking['html'])){
					$speedycache->render_blocking['html'] = str_replace('<noscript id="speedycache-google-fonts">', '<noscript id="speedycache-google-fonts">'.$google_fonts, $speedycache->render_blocking['html']);
				}else{
					$google_fonts = self::async_google_fonts($google_fonts);
					$speedycache->render_blocking['html'] = str_replace('</body>', $google_fonts."\n".'</body>', $speedycache->render_blocking['html']);
				}

			}
		}
		
		//to add BootstrapCDN at the end of page before js sources
		if(!empty($bootstrapcdn)){
			$speedycache->render_blocking['html'] = str_replace('</body>', $bootstrapcdn."\n".'</body>', $speedycache->render_blocking['html']);
		}

		//to add Inline Js before at the end of page before js sources
		if(!empty($inline_js)){
			$speedycache->render_blocking['html'] = str_replace('</body>', $inline_js."\n".'</body>', $speedycache->render_blocking['html']);
		}

		//to add third_part_js at the end of page
		if(!empty($third_part_js)){
			$speedycache->render_blocking['html'] = str_replace('</body>', $third_part_js."\n".'</body>', $speedycache->render_blocking['html']);
		}

		//to add defer and async attribute
		if(!empty($make_defer) || empty($speedycache->options['combine_js_enhanced'])){
			$speedycache->render_blocking['tags'] = self::add_defer_attr($speedycache->render_blocking['tags']);
		}

		//to add tags into footer
		$speedycache->render_blocking['tags'] = array_reverse($speedycache->render_blocking['tags']);
		foreach($speedycache->render_blocking['tags'] as $key => $value){
			if(preg_match("/^<script/i", $value['text'])){
				$speedycache->render_blocking['html'] = str_replace('</body>', $value['text']."\n".'</body>', $speedycache->render_blocking['html']);
			}else if(preg_match("/\<\!--\s*\[if[^\>]+>/i", $value['text'])){
				$speedycache->render_blocking['html'] = str_replace('</body>', $value['text']."\n".'</body>', $speedycache->render_blocking['html']);
			}
		}

		//to add document_ready_js at the end of page
		if(!empty($document_ready_js)){
			$speedycache->render_blocking['html'] = str_replace('</body>', $document_ready_js."\n".'</body>', $speedycache->render_blocking['html']);
		}

		//to add wpemojiSettings at the end of page
		if(!empty($wpemojiSettings)){
			$speedycache->render_blocking['html'] = str_replace('</body>', $wpemojiSettings."\n".'</body>', $speedycache->render_blocking['html']);
		}
		
		return preg_replace("/^\s+/m", '', $speedycache->render_blocking['html']);
	}

	static function async_google_fonts($fonts){
		if(preg_match("/\shref\=/", $fonts)){
			$fonts = '<noscript id="speedycache-google-fonts">'.$fonts.'</noscript>';
			$onload = "<script>document.addEventListener('DOMContentLoaded',function(){function speedycachegl(){var wgh=document.querySelector('noscript#speedycache-google-fonts').innerText, wgha=wgh.match(/<link[^\>]+>/gi);var i=0;for(i=0;i<wgha.length;i++){var wrpr=document.createElement('div');wrpr.innerHTML=wgha[i];document.body.appendChild(wrpr.firstChild);}}speedycachegl();});</script>";
			
			return $fonts."\n".$onload;
		}
		
		return $fonts;
	}

	static function combine_google_fonts($fonts){
		$family = '';
		$subset = '';

		preg_match_all("/fonts\.googleapis\.com\/css\?family\=([^\'\"]+)/si", $fonts, $arr);

		if(empty($arr[0])){
			return $fonts;
		}

		foreach($arr[0] as $key => $value){
			//to remove special chars
			$value = htmlspecialchars_decode($value);

			$parts = parse_url($value);
			parse_str($parts['query'], $query);

			$family = $query['family'];
			if(!empty($family)){
				$family = $family.'|'.$query['family'];
			}

			if(isset($query['subset']) && $query['subset']){
				
				$subset = $query['subset'];
				if(!empty($subset)){
					$subset = $subset.','.$query['subset'];
				}
			}
		}

		$family = str_replace(' ', '+', $family);
		if(!empty($subset)){
			$family.'&subset='.$subset;
		}

		return "<!--\n".$fonts."\n-->\n"."<link rel='stylesheet' id='speedycache-google-combined' href='http://fonts.googleapis.com/css?family=".$family."' type='text/css' media='all'/>";
	}

	static function defer_load_inline_js($script){
		if(preg_match("/<script[^\>]*>\s*\/\/\<\!\[CDATA\[\s*/", $script) && preg_match("/\/\/\]\]\>\s*<\/script>/", $script)){
			$script = preg_replace("/(<script[^\>]*>)\s*\/\/\<\!\[CDATA\[\s*/", "$1\n", $script);
			$script = preg_replace("/\/\/\]\]\>\s*(<\/script>)/", "\n$1", $script);
		}

		if(preg_match("/var\s+wpforms_conditional_logic/i", $script)){
			// to exclude the conditions of wpforms
			// <script type='text/javascript'>
			// /* <![CDATA[ */
			// var wpforms_conditional_logic = {"5616":{"17"}]],"action":"show"}}}
			// /* ]]> */
			// </script>
			return $script;
		}

		if(preg_match("/var\s+recaptchaWidgets/i", $script)){
			if(preg_match("/var\s+recaptchaCallback/i", $script)){
				// to exclude
				// https://github.com/IQComputing/wpcf7-recaptcha/blob/master/recaptcha-v2.php#L94
				return $script;
			}
		}

		if(preg_match('/function jqIsReady/i', $script)){
			return $script;
		}

		if(preg_match("/^<script[^\>]+>\s*<\/script>/i", $script)){
			// to exclude empty inline source
			// <script type="text/javascript" id="speedycachep-script-frontend"></script>
			return $script;
		}

		$script = preg_replace("/^(<script[^\>]*>)/i", "$1"."document.addEventListener('DOMContentLoaded',function(){", $script);
		$script = preg_replace("/\s*(<\/script>)/i", "});"."$1", $script);

		return $script;
	}
}PK��f\��statistics.phpnu�[���<?php

/*
* SPEEDYCACHE
* https://speedycache.com/
* (c) SpeedyCache Team
*/

namespace SpeedyCache;

if( !defined('SPEEDYCACHE_PRO_VERSION') ){
	die('HACKING ATTEMPT!');
}

class Statistics{

	static function init($extension = false, $size = false){
		global $speedycache;
		$speedycache->settings['static_extension'] = $extension ? $extension : false;
		$speedycache->settings['static_size'] = $size ? $size : false;
	}

	static function get(){
		
		$desktop_files = get_option('speedycache_html');
		$desktop_size = round(get_option('speedycache_html_size')/1000, 2);
		$mobile_files = get_option('speedycache_mobile');
		$mobile_size = round(get_option('speedycache_mobile_size')/1000, 2);
		$js_files = get_option('speedycache_js');
		$js_size = round(get_option('speedycache_js_size')/1000, 2);
		$css_files = get_option('speedycache_css');
		$css_size = round(get_option('speedycache_css_size')/1000, 2);
		
		$stats = array();
		$stats['desktop'] = array('size' => $desktop_size, 'file' => $desktop_files);
		$stats['mobile'] = array('size' => $mobile_size, 'file' => $mobile_files);
		$stats['js'] = array('size' => $js_size, 'file' => $js_files);
		$stats['css'] = array('size' => $css_size, 'file' => $css_files);

		return $stats;
	}

	static function update_db(){
		global $speedycache;
		
		// We do not need stats if its a test
		if(!empty($_GET['test_speedycache'])){
			return;
		}

		$option_name = 'speedycache_' . $speedycache->settings['static_extension'];
		$option_name_for_size = $option_name . '_size';
		
		$current_opt = get_option($option_name);
		
		if(!empty($current_opt)){
			$current_opt = $current_opt + 1;
			update_option($option_name, $current_opt);
		}else{
			update_option($option_name, 1, null, 'yes');
		}

		$size_current_opt = get_option($option_name_for_size);

		if(!empty($size_current_opt)){
			$size_current_opt = $size_current_opt + $speedycache->settings['static_size'];
			update_option($option_name_for_size, $size_current_opt);
			return;
		}
		
		update_option($option_name_for_size, $speedycache->settings['static_size'], null, 'yes');

	}

	static function statics(){
		?>
		<div class="speedycache-block">
			<div class="speedycache-block-title">
				<h2 id="cache-statics-h2"><?php _e('Cache Statistics', 'speedycache'); ?></h2>
			</div>
			<div id="speedycache-cache-statics">
				<div id="speedycache-cache-statics-desktop" class="speedycache-card">
					<div class="speedycache-card-body">
						<div class="speedycache-stats-info">
							<span>Desktop Cache</span>
							<p id="speedycache-cache-statics-desktop-data">
								<span class="speedycache-size">0Kb</span><br/>
								<span class="speedycache-files">of 0 Items</span>
							</p>
						</div>
						<div class="speedycache-stat-icon">
							<i class="fas fa-desktop"></i>
							<!--<span class="dashicons dashicons-desktop"></span>-->
						</div>
					</div>
				</div>
				<div id="speedycache-cache-statics-mobile" class="speedycache-card">
					<div class="speedycache-card-body">
						<div class="speedycache-stats-info">
							<span>Mobile Cache</span>
							<p id="speedycache-cache-statics-mobile-data">
								<span class="speedycache-size">0Kb</span><br/>
								<span class="speedycache-files">of 0 Items</span></p>
						</div>
						<div class="speedycache-stat-icon">
							<i class="fas fa-mobile"></i>
						</div>
					</div>
				</div>
				<div id="speedycache-cache-statics-css" class="speedycache-card">
					<div class="speedycache-card-body">
						<div class="speedycache-stats-info">
							<span>Minified CSS</span>
							<p id="speedycache-cache-statics-css-data">
								<span class="speedycache-size">0Kb</span><br/>
								<span class="speedycache-files">of 0 Items</span>
							</p>
						</div>
						<div class="speedycache-stat-icon"><i class="fab fa-css3-alt"></i></div>
					</div>
				</div>
				<div id="speedycache-cache-statics-js" class="speedycache-card">
					<div class="speedycache-card-body">	
						<div class="speedycache-stats-info">
							<span>Minified JS</span>
							<p id="speedycache-cache-statics-js-data">
								<span class="speedycache-size">0Kb</span><br/>
								<span class="speedycache-files">of 0 Items</span>
							</p>
						</div>
						<div class="speedycache-stat-icon"><i class="fab fa-js-square"></i></div>
					</div>
				</div>
			</div>
		</div>
	<?php }

}

PK��f\�ddprooptimizations.phpnu�[���<?php

namespace SpeedyCache;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT');
}

class ProOptimizations{
	static $content = '';

	// function init(&$content){
		// self::$content = $content;
	// }
	
	static function defer_js(&$content){
		global $speedycache;

		\SpeedyCache\Enhanced::init();
		$content = \SpeedyCache\Enhanced::render_blocking($content);
	}
	
	static function delay_js(&$content){
		global $speedycache;

		\SpeedyCache\Enhanced::init();
		if(empty($speedycache->enhanced)){
			$speedycache->enhanced['html'] = $content;
		}

		$content = \SpeedyCache\Enhanced::delay_js($content);
	}
	
	static function unused_css(){
		$url = esc_url(speedycache_optserver('HTTP_HOST'). speedycache_optserver('REQUEST_URI'));

		if(strpos($url, '?test_speedycache') !== FALSE){
			\SpeedyCache\UnusedCss::generate(array($url));
		} else {
			\SpeedyCache\UnusedCss::schedule('speedycache_unused_css', array($url));
		}
	}
	
	static function critical_css(){
		$url = esc_url(speedycache_optserver('HTTP_HOST'). speedycache_optserver('REQUEST_URI'));

		if(strpos($url, '?test_speedycache') !== FALSE){
			\SpeedyCache\CriticalCss::generate(array($url));
		} else {
			\SpeedyCache\CriticalCss::schedule('speedycache_generate_ccss', array($url));
		}
	}
	
	static function img_lazy_load(&$content){

		// to disable for Ajax Load More on the pages
		if(speedycache_is_plugin_active('ajax-load-more/ajax-load-more.php') && !empty($_SERVER['REQUEST_URI']) && preg_match("/\/page\/\d+\//", sanitize_url(wp_unslash($_SERVER['REQUEST_URI'])))){
			return;
		}

		$content = \SpeedyCache\Enhanced::lazy_load($content);
		$lazy_load_js = '';
		
		if(file_exists(SPEEDYCACHE_PRO_DIR . '/main/lazyload.php')){
			$lazy_load_js = \SpeedyCache\LazyLoad::get_js_source();
		}

		$content = preg_replace("/\s*<\/head\s*>/i", $lazy_load_js.'</head>', $content, 1);
	}
	
	static function remove_gfonts(&$content){
		if(!empty($speedycache->bloat['remove_gfonts'])){
			$content = preg_replace('/<link[^<>]*\/\/fonts\.(googleapis|google|gstatic)\.com[^<>]*>/i', '', $content);
		}
	}
}PK��f\��ڨFF
mobile.phpnu�[���<?php

/*
* SPEEDYCACHE
* https://speedycache.com/
* (c) SpeedyCache Team
*/

namespace SpeedyCache;

if( !defined('SPEEDYCACHE_PRO_VERSION') ){
	die('HACKING ATTEMPT!');
}

class Mobile{

	static function cache(){
		global $speedycache;
		
		$speedycache->mobile_cache = array();
		$speedycache->mobile_cache['folder_name'] = 'mobile-cache';
		$speedycache->mobile_cache['wptouch'] = false;
	}

	static function update_htaccess($data){
		global $speedycache;
		
		preg_match("/RewriteEngine\sOn(.+)/is", $data, $out);
		$htaccess = "\n##### Start: Mobile Cache Rules #####\n";
		$htaccess .= $out[0];

		// Updates the moble cache htaccess rule according to wptouch
		if($speedycache->mobile_cache['wptouch']){
			$wptouch_rule = "RewriteCond %{HTTP:Cookie} !wptouch-pro-view=desktop";
			$htaccess = str_replace("RewriteCond %{HTTP:Profile}", $wptouch_rule."\n"."RewriteCond %{HTTP:Profile}", $htaccess);
		}

		/**
		* Structure of this array is
		*	searchable => replacer
		*/
		$rules = array(
			'RewriteCond %{HTTP:Cookie} !safirmobilswitcher=mobil' => 'RewriteCond %{HTTP:Cookie} !safirmobilswitcher=masaustu',
			'RewriteCond %{HTTP_USER_AGENT} !^.*' => 'RewriteCond %{HTTP_USER_AGENT} ^.*',
		);
		
		foreach($rules as $search => $replacement){
			$htaccess = str_replace($search, $replacement, $htaccess);
		}

		$htaccess = preg_replace('/\/speedycache\/'.preg_quote(SPEEDYCACHE_SERVER_HOST).'\/all\//', '/speedycache/'.SPEEDYCACHE_SERVER_HOST .'/'. $speedycache->mobile_cache['folder_name']."/", $htaccess);
		$htaccess .= "\n##### End: Mobile Cache Rules #####\n";

		return $htaccess;
	}

}
PK��f\V���pp	image.phpnu�[���<?php
/*
* SPEEDYCACHE
* https://speedycache.com/
* (c) SpeedyCache Team
*/

namespace SpeedyCache;

class Image{

	static function init(){
		global $speedycache, $speedycache_optm_method;
		
		$speedycache->image = array();
		$speedycache->image['upload_dir'] = wp_upload_dir();
		$speedycache->image['id'] = false;
		$speedycache->image['metadata'] = array();
		$speedycache->image['name'] = '';
		$speedycache->image['path'] = '';
		$speedycache->image['url'] = '';
		$speedycache->image['images'] = array();
		$speedycache->image['images_clone'] = array();
		$speedycache->image['disabled_method'] = 0;
		
		// Default settings for img optimization
		$speedycache->image['settings'] = array(
			'on_upload' => false,
			'automatic_optm' => false,
			'url_rewrite' => false,
			'compression_method' => 'gd',
			'compression_quality' => '70'
		);
		
		$speedycache_optm_method = array(
			'gd' => array(
				'title' => 'GD',
				'desc' => 'Compress using PHP\'s native Extension for compression and conversion.'
			),
			'imagick' => array(
				'title' => 'Imagick',
				'desc' => 'Imagick outputs better image quality after compression at the cost of a little bigger file size compared to GD.'
			),
			'cwebp' => array(
				'title' => 'cWebP',
				'desc' => 'cwebp is a utility which can be downloaded on your server and its fast and light on you server.'
			)
		);
		
		// Binaries for cwebp
		$speedycache->image['binaries'] = array(
			'WINNT' => ['cwebp-122-windows-x64.exe', 'gif2webp-122-windows-x64.exe'],
			'Linux' => ['cwebp-122-linux-x86-64', 'gif2webp-122-linux-x86-64']
		);
		
		if(array_key_exists(PHP_OS, $speedycache->image['binaries'])){
			$speedycache->image['cwebp_binary'] = $speedycache->image['binaries'][PHP_OS][0];
			$speedycache->image['cwebp_gif'] = $speedycache->image['binaries'][PHP_OS][1];
		}

		if($img_settings = get_option('speedycache_img')){
			$speedycache->image['settings'] = array_merge($speedycache->image['settings'], $img_settings);
			self::compression_method_checks();

			return;
		}
		
		self::compression_method_checks();
		update_option('speedycache_img', $speedycache->image['settings']);

	}

	static function total_reduction(){
		global $wpdb;
		
		$query = "SELECT sum(`meta_value`) as total FROM `".$wpdb->prefix."postmeta` WHERE `meta_key`= 'speedycache_optimisation_reduction'";
		$result = $wpdb->get_row( $query );
		
		if(!empty($result->total)){
			$reduced = ($result->total && $result->total > 0) ? $result->total : 0;
			
			return $reduced > 10000 ? $reduced/1000 : $reduced;	
		}
		
		return 0;
	}

	static function optimized_file_count(){
		global $wpdb;
		
		$query = "SELECT count(`meta_value`) as optimized FROM `".$wpdb->prefix."postmeta` WHERE `meta_key`= 'speedycache_optimisation'";
		$result = $wpdb->get_row($query);
		
		if($result->optimized && $result->optimized > 0){
			return $result->optimized;
		}
		
		return 0;
	}

	static function optm_img_count(){

		return self::count_query(array(
			'post_type' => 'attachment',
			'post_mime_type' => array('image/jpeg', 'image/png', 'image/gif'),
			'post_status' => 'inherit',
			'posts_per_page' => -1,
			'meta_query' => array(
				array(
					'key' => 'speedycache_optimisation',
					'compare' => 'EXISTS'
				),
				array(
					'key' => 'speedycache_optimisation',
					'value' => base64_encode('"destination_path"'),
					'compare' => 'LIKE'
				)
			)
		));
	}

	static function error_count(){

		return self::count_query(array(
			'post_type' => 'attachment',
			'post_mime_type' => array('image/jpeg', 'image/png', 'image/gif'),
			'post_status' => 'inherit',
			'posts_per_page' => -1,
			'meta_query' => array(
				array(
					'key' => 'speedycache_optimisation',
					'compare' => 'EXISTS'
				),
				array(
					'key' => 'speedycache_optimisation',
					'value' => base64_encode('"error_code"'),
					'compare' => 'LIKE'
				)
			)
		));
	}

	static function null_posts_groupby(){
		return '';
	}

	static function count_posts_fields(){
		return 'COUNT(*) as post_count_speedycache';
	}

	static function count_query($query_images_args){
		add_filter('posts_fields', '\SpeedyCache\Image::count_posts_fields');
		add_filter('posts_groupby', '\SpeedyCache\Image::null_posts_groupby');

		unset($query_images_args['offset']);
		unset($query_images_args['order']);
		unset($query_images_args['orderby']);

		$query_images_args['posts_per_page'] = -1;

		$query_image = new \WP_Query( $query_images_args );

		return $query_image->posts[0]->post_count_speedycache;
	}

	static function image_count(){

		return self::count_query(array(
			'post_type' => 'attachment',
			'post_mime_type' => array('image/jpeg', 'image/png', 'image/gif'),
			'post_status' => 'inherit',
			'posts_per_page' => -1,
			'meta_query' => array(
				array(
					'key' => '_wp_attachment_metadata',
					'compare' => 'EXISTS'
				)
			)
		));
	}

	static function uncompressed_count(){

		return self::count_query(array(
			'post_type' => 'attachment',
			'post_mime_type' => array('image/jpeg', 'image/png', 'image/gif'),
			'post_status' => 'inherit',
			'posts_per_page' => -1,
			'meta_query' => array(
				array(
					'key' => 'speedycache_optimisation',
					'compare' => 'NOT EXISTS'
				)
			)
		));
	}

	static function unoptimized(){
		global $speedycache;
		
		$tmp_image = array();

		$optimization_data = get_post_meta($speedycache->image['id'], 'speedycache_optimisation', true);
		$optm_json = base64_decode($optimization_data);
		
		if(empty($optm_json)){
			$percentage = 100 / count($speedycache->image['images']);
			
			return array('meta_optimized' => array(), 'images' => $speedycache->image['images'], 'total_reduction' => 0, 'percentage' => $percentage);
		}

		$optm_json = json_decode($optm_json, true);
		$meta_optimized = self::object_to_array($optm_json);
		$percentage = count($meta_optimized) * 100/count($speedycache->image['images']);
		
		foreach($speedycache->image['images'] as $key => $value){
			$exist = false;

			foreach($meta_optimized as $meta_key => $meta_value){
				if($value['file'] == $meta_value['file']){
					$exist = true;
					//break;
				}
			}

			if(empty($exist)){
				array_push($tmp_image, $value);
			}
		}

		//START: total reduction
		$total_reduction = 0;
		
		foreach($meta_optimized as $m_key => $m_value){
			$m_value['reduction'] = isset($m_value['reduction']) ? $m_value['reduction'] : 0;
			
			if($m_key == 0){
				$reduction = $m_value['reduction'];
			}
			
			$total_reduction += $m_value['reduction'];
		}
		//END: total reduction

		if(count($tmp_image) <= 0){
			return array('meta_optimized' => array(), 'images' => array(), 'total_reduction' => 0);
		}

		$last = speedycache_optget('last');
		if(!empty($last)){
			if(preg_match('/last-(\d+)/', $last, $last_number)){
				if(count($tmp_image) > 5){
					$tmp_image = array_slice($tmp_image, $last_number[1]*-1, 1);
				}
			}
		}

		return array('meta_optimized' => $meta_optimized, 'images' => array_slice($tmp_image, 0, 1), 'total_reduction' => $total_reduction, 'percentage' => $percentage);
	}

	static function object_to_array($obj){
		if(is_object($obj)){
			$obj = (array) $obj;
		}
		
		if(!is_array($obj)){
			$new = $obj;
			return $new;
		}
		
		$new = array();
		foreach($obj as $key => $val){
			$new[$key] = self::object_to_array($val);
		}
		return $new;
	}

	static function reorder_by_dimensions(){
		global $speedycache;
		
		$tmp = $speedycache->image['images'];

		foreach($tmp as $key => $value){
			$width_list[$key] = $value['width'];
		}

		array_multisort($width_list, SORT_DESC, $tmp);
		
		return $tmp;
	}

	static function optimize_single($id = null){
		global $speedycache;

		if(!empty($id)){
			self::init();
		}

		self::set_id($id);
		self::set_meta_data();

		if(wp_next_scheduled('speedycache_auto_optm', array($speedycache->image['id']))){
			wp_clear_scheduled_hook('speedycache_auto_optm' , array($speedycache->image['id']));
		}

		if(empty($speedycache->image['id'])){
			return array('finish', 'success'); 
		}

		if(!isset($speedycache->image['metadata']['file']) && !empty($speedycache->image['id'])){
			$meta_optimized = array();
			$meta_optimized[0]['time'] = time();
			$meta_optimized[0]['id'] = $speedycache->image['id'];
			$meta_optimized[0]['error_code'] = 17;

			update_post_meta($speedycache->image['id'], 'speedycache_optimisation_reduction', 0);
			update_post_meta($speedycache->image['id'], 'speedycache_optimisation', base64_encode(json_encode($meta_optimized)));

			return array('Image has been optimized', 'success', $speedycache->image['id'], 100);
		}

		self::set_name();
		self::set_path();
		self::set_url();
		self::set_images();

		if(!empty($speedycache->image['id']) && count($speedycache->image['images']) == 0){
			$meta_optimized = array();
			$meta_optimized[0]['time'] = time();
			$meta_optimized[0]['id'] = $speedycache->image['id'];
			$meta_optimized[0]['error_code'] = 18;

			update_post_meta($speedycache->image['id'], 'speedycache_optimisation_reduction', 0);
			update_post_meta($speedycache->image['id'], 'speedycache_optimisation', base64_encode(json_encode($meta_optimized)));

			return array('Image has been optimized', 'success', $speedycache->image['id'], 100);
		}

		$error_exist = false;
		$meta_optimized = array();
		$total_reduction = 0;
		
		$speedycache->image['images'] = self::unique_array($speedycache->image['images']);
		$speedycache->image['images'] = self::reorder_by_dimensions();

		$speedycache->image['images_clone'] = $speedycache->image['images'];

		$unoptimized = self::unoptimized();
		$speedycache->image['images'] = $unoptimized['images'];
		$meta_optimized = $unoptimized['meta_optimized'];
		$total_reduction = $unoptimized['total_reduction'];
		$percentage = isset($unoptimized['percentage']) && $unoptimized['percentage'] ? $unoptimized['percentage'] : 0;

		if(count($speedycache->image['images']) == 0){
			return array('Image has been optimized', 'success', '', 100);
		}

		foreach($speedycache->image['images'] as $key => $value){
		
			$res = self::compress($value);
			
			if(!empty($res['success'])){
				$value['destination_path'] = $res['destination_path'];
				$value['reduction'] = $res['reduction'];

				$total_reduction += $value['reduction'];

				$value['time'] = time();
				$value['id'] = $speedycache->image['id'];
				
				array_push($meta_optimized, $value);
			}else{
				if(!isset($res['error_code']) && isset($res['error_message'])){
					return array($res['error_message'], 'error');
					break;
				}

				if(in_array($res['error_code'] , array(2, 6, 7, 11, 19, 20, 22, 23))){
					return array($res['error_message'], 'error');
					break;
				}

				$value['error_code'] = $res['error_code'];
				$error_exist = true;
			}

			$value['time'] = time();
			$value['id'] = $speedycache->image['id'];

			if(!empty($value['error_code'])){
				if($value['error_code'] != 8 || ($value['error_code'] == 8 && $key === 0)){
					array_push($meta_optimized, $value);
				}
			}
		}
		
		$percentage = self::update_meta($total_reduction, $meta_optimized);

		return array('Image has been optimized', 'success', $speedycache->image['id'], $percentage, $total_reduction);
	}

	static function update_meta($total_reduction, $meta_optimized){
		global $speedycache;
		
		if(isset($meta_optimized[0]) && isset($meta_optimized[0]['error_code']) && $meta_optimized[0]['error_code']){

			update_post_meta($speedycache->image['id'], 'speedycache_optimisation', base64_encode(json_encode($meta_optimized)));
			update_post_meta($speedycache->image['id'], 'speedycache_optimisation_reduction', 0);

			return 100;
		}

		$percentage = 0;
		$meta_temp = array();
		
		foreach($speedycache->image['images_clone'] as $key => $value){
			$backup_file = $value['file'];
			
			$value['file'] = preg_replace('/.(jpg|jpeg|png|gif)$/', '.webp', $value['file']);
			
			if(!file_exists($value['file']) || !file_exists($backup_file)){
				continue;
			}

			$diff = filesize($backup_file) - filesize($value['file']);
			$diff = $diff > 0 ? $diff : 0;

			$value['destination_path'] = $backup_file;
			$value['reduction'] = $diff;
			$value['time'] = time();
			$value['id'] = $speedycache->image['id'];

			array_push($meta_temp, $value);
		}

		foreach($meta_optimized as $m_key => $m_value){
			if(empty($m_value['error_code'])){
				continue;
			}

			$exist = false;

			for($i=0; $i < count($meta_temp); $i++){
				if($meta_temp['file'] == $m_value['file']){
					$exist = true;
				}
			}

			if(empty($exist)){
				$m_value['destination_path'] = '';
				$m_value['reduction'] = 0;
				$m_value['time'] = time();
				$m_value['id'] = $speedycache->image['id'];

				array_push($meta_temp, $m_value);
			}
		}
		
		if(count($meta_temp) > 0){
			$percentage = count($meta_temp)*100/count($speedycache->image['images_clone']);
		}else{
			$percentage = 0;
		}

		update_post_meta($speedycache->image['id'], 'speedycache_optimisation_reduction', $total_reduction);
		update_post_meta($speedycache->image['id'], 'speedycache_optimisation', base64_encode(json_encode($meta_temp)));

		return $percentage;
	}

	static function compress($source_image){
		global $speedycache;

		/*
			Error Codes
			2 = in backup folder parent folder not writable
			3 = no need to optimize
			4 = source is not writable
			5 = destination is not writable
			6 = ImageMagick library is not avaliable
			7 = Error via api
			8 = Source file does not exist
			9 = Image size exceed 5mb limit while processing
		   11 = Empty Name
		   12 = Forbidden
		   13 = CloudFlare to restrict access
		   14 = No Extension
		   15 = Image size is 0Kb
		   16 = Corrupted Image
		   17 = Empty Metadata
		   18 = No Image
		   19 = webp is not saved
		   20 = file size of destination_move_source_path is zero
		   21 = Unacceptable file type
		   22 = Unable to Convert Image using cwebp.
		   23 = The URL of the image has webp extension.
		*/

		// if the url starts with /wp-content
		if(preg_match('/^\/' . SPEEDYCACHE_WP_CONTENT_DIR . '/i', $source_image['url'])){
			$source_image['url'] = home_url().$source_image['url'];
		}

		$source_path = $source_image['file'];
		$res_backup = array('success' => true, 'error_message' => '');
		$webp_path = preg_replace('/.(jpe?g|png|gif)$/', '.webp', $source_path);

		if(strlen($speedycache->image['name']) === 0){
			return array('success' => false, 'error_code' => 11);
		}

		if(!file_exists($source_path)){
			return array('success' => false, 'error_code' => 8);
		}

		if(!pathinfo($source_image['url'], PATHINFO_EXTENSION)){
			return array('success' => false, 'error_code' => 14);
		}

		// If the URL of the image is a webp
		if(pathinfo($source_image['url'], PATHINFO_EXTENSION) == 'webp' && file_exists($webp_path)){
			return array('success' => false, 'error_code' => 23);
		}

		if(@filesize($source_path) > 5000000){
			return array("success" => false, 'error_code' => 9);
		}

		if(!self::allowed_mime($source_path)){
			return array('success' => false, 'error_code' => 21);
		}

		if(!self::path_is_image($source_path)){
			return array('success' => false, 'error_code' => 16);
		}

		if(filesize($source_path) == 0){
			return array('success' => false, 'error_code' => 15);
		}

		if(@rename($source_path, $source_path.'_writabletest')){
			rename($source_path.'_writabletest', $source_path);
		}else{
			return array('success' => false, 'error_message' => $source_path . ' is not writable', 'error_code' => 4);
		}

		$optm_result = self::start_optimization($source_path); // here we need to plugin compression static function
		
		if(empty($optm_result['success'])){
			//NOTE:Place some error Message here.
			return $optm_result;
		}

		if(!file_exists($webp_path)){
			return array('success' => false, 'error_code' => 19, 'error_message' => $webp_path . ' destination_path is not saved');
		}
		
		if(filesize($webp_path) <= 0){
			return array('success' => false, 'error_code' => 20, 'error_message' => $webp_path . ' file size of destination_path is zero');
		}

		$diff = self::compare_sizes($source_path, $webp_path);
		return array('success' => true, 'destination_path' => $webp_path, 'reduction' => $diff);
	}


	static function start_optimization($img){
		global $speedycache;

		switch($speedycache->image['settings']['compression_method']){
			case 'gd': 
				return self::gd_webp($img);
				
			case 'imagick':
				return self::imagick_webp($img);
				
			case 'cwebp':
				if(defined('SPEEDYCACHE_PRO')){					
					return \SpeedyCache\Image::cwebp_convert($img);
				}
				
				return array('success' => false, 'error_message' => 'SpeedyCache cwebp is a Pro feature');
				
			default:
				return array('success' => false,  'error_message' => 'The provided conversion method is not valid');
		}
	}

	static function path_is_image($source_path){
		$size = getimagesize($source_path);

		if(empty($size)){
			return false;
		}

		return true;
	}

	static function get_quality($img){
		$dimensions = $img->getImageGeometry();
		
		if($dimensions['width'] < 200 && $dimensions['height'] < 200){
			return 85;
		}

		return 90;
	}

	static function compare_sizes($source_path, $destination_path){
		$diff = filesize($source_path) - filesize($destination_path);

		return ($diff > 0) ? $diff : 1;
	}


	//TODO:: Will need it when we will add non webp compression
	static function create_backup_folder($destination_path){
		global $speedycache;
		
		$destination_path = str_replace($speedycache->image['upload_dir']['basedir'], '', $destination_path);
		$path_arr = explode('/', $destination_path);

		$path = $speedycache->image['upload_dir']['basedir'];

		for ($i=1; $i < count($path_arr) - 1; $i++){
			$parent_path = $path;
			$path = $path.'/'.$path_arr[$i];

			if(is_dir($path)){
				continue;
			}
			
			if(@mkdir($path, 0755, true)){
				//
			}else{
				//warning
				if($path_arr[$i] == 'speedycache-backup'){
					//toDO: to stop cron job and warn the user
				}

				return array('success' => false, 'error_message' => $parent_path.' is not writable', 'error_code' => 2);
			}
		}

		return array('success' => true, 'error_message' => '');
	}

	static function set_id($id = null){
		global $speedycache;
		
		$get_id = speedycache_optget('id');
		
		if(!empty($get_id)){
			$speedycache->image['id'] = intval($get_id);
		}elseif(!empty($id)){
			$speedycache->image['id'] = intval($id);
		}else{
			$speedycache->image['id'] = self::get_first_id();
		}
	}

	static function set_images(){
		global $speedycache;
		
		if(empty($speedycache->image['metadata']['file'])){
			return;
		}

		$arr = array(
			'file' => $speedycache->image['upload_dir']['basedir'].'/'.$speedycache->image['metadata']['file'],
			'url' => $speedycache->image['upload_dir']['baseurl'].'/'.$speedycache->image['metadata']['file'],
			'width' => $speedycache->image['metadata']['width'],
			'height' => $speedycache->image['metadata']['height'],
			'mime_type' => ''
		);
		
		array_push($speedycache->image['images'], $arr);

		$i = 0;
		$image_error = false;

		if(!is_array($speedycache->image['metadata']['sizes'])){
			if(empty($image_error)){
				self::not_in_metadata();
			}
		}

		foreach((array)$speedycache->image['metadata']['sizes'] as $key => $value){
			$value['url'] = $speedycache->image['url'].$value['file'];
			$value['file'] = $speedycache->image['path'].$value['file'];
			$value['mime_type'] = isset($value['mime-type']) ? $value['mime-type'] : '';

			unset($value['mime-type']);

			if($i == 0){
				if(self::not_found(self::get_correct_url($speedycache->image['upload_dir']['baseurl'].'/'.$speedycache->image['metadata']['file']))){
					$image_error = true;
					break;
				}
			}

			if(!self::not_found(self::get_correct_url($value['url'])) && self::allowed_mime($value['file'])){
				array_push($speedycache->image['images'], $value);
			}

			$i++;
		}

		if(empty($image_error)){
			self::not_in_metadata();
		}
	}

	static function get_correct_url($path){
		if(preg_match('/^\/'.SPEEDYCACHE_WP_CONTENT_DIR.'/i', $path)){
			
			// content_url() must return HTTP but it return /wp-content so we need to check
			if(content_url() == '/'.SPEEDYCACHE_WP_CONTENT_DIR && home_url() == site_url()){
				$path = home_url().$path;
			}
		}

		return $path;
	}

	static function not_in_metadata(){
		global $speedycache;
		
		$paths = array();

		foreach($speedycache->image['images'] as $key => $value){
			array_push($paths, $value['file']);
		}
		
		$files = glob($speedycache->image['path'].$speedycache->image['name'].'-'.'*');

		foreach((array)$files as $file){
			if(@filesize($file) > 1000000){
				continue;
			}

			if(!preg_match('/\.(jpg|jpeg|jpe|png|gif)$/i', $file)){
				continue;
			}

			$exp_dos = explode('/',$file);
			$basename = end($exp_dos);

			if(in_array($file, $paths)){
				continue;
			}
			
			if(!preg_match('/'.preg_quote($speedycache->image['name'], '/').'-(\d+)x(\d+)\..+/', $basename, $dimensions)){
				continue;
			}
			
			$value = array(
				'url' => $speedycache->image['url'].$basename,
				'file' => $file,
				'width' => $dimensions[1],
				'height' => $dimensions[2],
			);

			if(!self::not_found($value['url'])){
				array_push($speedycache->image['images'], $value);
			}
		}
	}

	static function set_path(){
		global $speedycache;
		
		$speedycache->image['path'] = $speedycache->image['upload_dir']['basedir'].'/'.preg_replace('/'.preg_quote($speedycache->image['name'], '/').'.+/', '', $speedycache->image['metadata']['file']);
	}

	static function set_url(){
		global $speedycache;
		
		$speedycache->image['url'] = $speedycache->image['upload_dir']['baseurl'].'/'.preg_replace('/'.preg_quote($speedycache->image['name'], '/').'.+/', '', $speedycache->image['metadata']['file']);
	}

	static function set_name(){
		global $speedycache;
		
		if(empty($speedycache->image['metadata'])){
			return;
		}

		if(isset($speedycache->image['metadata']['sizes']) && count($speedycache->image['metadata']['sizes']) > 0){
			$array_values = array_values($speedycache->image['metadata']['sizes']);
			$speedycache->image['name'] = preg_replace('/-'.$array_values[0]['width'].'x'.$array_values[0]['height'].'.+/', '', $array_values[0]['file']);

			if(!$speedycache->image['name']){
				$speedycache->image['name'] = substr($speedycache->image['metadata']['file'], strrpos($speedycache->image['metadata']['file'], '/') + 1);
			}
			
			return;
		}

		$info = pathinfo($speedycache->image['metadata']['file']);
		$speedycache->image['name'] =  basename($speedycache->image['metadata']['file'],'.'.$info['extension']);

		//$this->name = substr($this->metadata['file'], strrpos($this->metadata['file'], '/') + 1);
	}

	static function set_meta_data(){
		global $speedycache;
		
		$speedycache->image['metadata'] = wp_get_attachment_metadata($speedycache->image['id']);
	}

	//to get last image which is not optimized
	static function get_first_id(){

		$query_image = new \WP_Query(array(
			'order' => 'DESC',
			'orderby' => 'ID',
			'post_type' => 'attachment', 
			'post_mime_type' => 'image/jpeg, image/png, image/gif', 
			'post_status' => 'inherit',
			'posts_per_page' => 1,
			'meta_query' => array(
				array(
					'key' => 'speedycache_optimisation',
					'compare' => 'NOT EXISTS'
				),
				array(
					'key' => '_wp_attachment_metadata',
					'compare' => 'EXISTS'
				)
			)
		));

		return count($query_image->posts) == 1 ? $query_image->posts[0]->ID : false;
	}

	static function statics_data(){
		$res = array(
			'total_image_number' => self::image_count(),
			'error' => self::error_count(),
			'optimized' => self::optimized_file_count(),
			'uncompressed' => self::uncompressed_count(),
			'reduction' => self::total_reduction(),
			'percent' => 0,
		);

		if($res['optimized'] > 0){
			$res['percent'] = ($res['optimized'] - $res['error']) * 100/$res['optimized'];
		}else{
			$res['percent'] = 0;
		}
		
		$res['percent'] = number_format($res['percent'], 2);
		$res['reduction'] = $res['reduction'];
		
		return $res;
	}

	static function revert_all(){
		global $speedycache;
		
		if(!current_user_can('manage_options')){
			wp_die('Must Be admin');
		}

		$images = new \WP_Query(array(
			'order' => 'DESC',
			'orderby' => 'ID',
			'post_type' => 'attachment',
			'post_mime_type' => array('image/jpeg', 'image/png', 'image/gif'),
			'post_status' => 'inherit',
			'posts_per_page' => -1,
			'meta_query' => array(
				array(
					'key' => 'speedycache_optimisation',
					'compare' => 'EXISTS'
				)
			)
		));

		$failed = true;
		
		if(count($images->posts) <= 100){
			
			if($images->posts && count($images->posts) > 0){
				foreach($images->posts as $key => $post){
					$speedycache->image['id'] = $post->ID;
					$result = self::revert();
					
					if($result['success'] === true){
						$failed = false;
					}
				}
			}
			
			if(!empty($failed)){
				wp_send_json(array('success' => false, 'message' => __('Files can\'t be reverted', 'speedycache'))); 
			}
			
			wp_send_json(array('success' => true));
		}

		$schedule_posts = [];
		foreach($images->posts as $key => $post){
			
			if(100 === count($schedule_posts) || !empty($erase)){
				$schedule_posts = [];
			}

			$erase = false; // Flag to unset the $scheduled_posts
			
			$schedule_posts[] = $post->ID;

			// Check if we have reached 99 and make sure its not the last index
			if(count($schedule_posts) <= 99 && $key !== (count($images->posts) - 1)){
				continue;
			}
			
			// Skip if alredy on schedule list.
			if(wp_next_scheduled('speedycache_img_delete', array($schedule_posts))){
				$erase = true;
				continue;
			}
		
			$scheduled = self::get_optimization_schedule(array('speedycache_img_delete'));
			$time = time();
		
			if(!empty($scheduled) && isset(end($scheduled)['time'])){
				// getting the last index to get the last scheduled event
				$time = end($scheduled)['time'];
			}
			
			$final_schd_time = $time + 10;
		
			if(!wp_next_scheduled('speedycache_img_delete', array($schedule_posts))){
				wp_schedule_single_event($final_schd_time, 'speedycache_img_delete', array($schedule_posts));
				
				continue;
			}
		}

		wp_send_json(array('success' => true));
	}

	// Schedule deletion of image to reduce load on the server at a single time.
	static function scheduled_delete($img_id){
		global $speedycache;
		
		if(empty($img_id)){
			return;
		}

		if(is_scalar($img_id)){
			$speedycache->image['id'] = $img_id;
			self::revert();
			return;
		}
		
		foreach($img_id as $id){
			$speedycache->image['id'] = $id;
			self::revert();
		}
	}

	// Reverts a single image
	static function revert(){
		global $speedycache;
		
		if(empty($speedycache->image['id'])){
			return array('success' => false);
		}
		
		$optimization_data = get_post_meta($speedycache->image['id'], 'speedycache_optimisation', true);

		// optm = optimization
		$optm_json = base64_decode($optimization_data);
		$optm_json = json_decode($optm_json, true);
		
		if(empty($optm_json)){
			return array('success' => false);
		}

		if(!empty($optm_json) && is_array($optm_json) && count($optm_json) == 1 && !empty($optm_json[0])){
			if(!empty($optm_json[0]['error_code']) && $optm_json[0]['error_code'] == 18){
				delete_post_meta($speedycache->image['id'], 'speedycache_optimisation');
				delete_post_meta($speedycache->image['id'], 'speedycache_optimisation_reduction');

				return array('success' => true);
			}
		}

		$result = false;

		$optm_json = array_reverse($optm_json);
		$error_numbers = 0;
		
		foreach($optm_json as $key => $image){

			if(@!is_writable($image['file'])){
				if(isset($speedycache->image['metadata']['file']) && preg_match('/'.preg_quote($speedycache->image['metadata']['file'], '/').'/', $image['url'])){
					if(file_exists($image['file'])){
						$result = array('success' => true, 'message' => $image['file'].' is not writable');
						break;
					}
					
					delete_post_meta($speedycache->image['id'], 'speedycache_optimisation');
					delete_post_meta($speedycache->image['id'], 'speedycache_optimisation_reduction');
				}
			}

			if(
				!empty($image['url']) && 
				!preg_match('/\.webp$/', $image['url']) && 
				isset($image['destination_path']) && 
				file_exists($image['destination_path']) &&
				(pathinfo($image['destination_path'], PATHINFO_EXTENSION) == 'webp')
			){
				@unlink($image['file']);

				delete_post_meta($speedycache->image['id'], 'speedycache_optimisation');
				delete_post_meta($speedycache->image['id'], 'speedycache_optimisation_reduction');
				$result = array('success' => true);
				
				continue;
			}

			if(!empty($image['error_code'])){
				if(isset($speedycache->image['metadata']['file']) && preg_match('/'.preg_quote($speedycache->image['metadata']['file'], '/').'/', $image['url'])){
					delete_post_meta($speedycache->image['id'], 'speedycache_optimisation');
					delete_post_meta($speedycache->image['id'], 'speedycache_optimisation_reduction');
					$result = array('success' => true);
				}else{
					$error_numbers++;

					if($error_numbers == count($optm_json)){
						delete_post_meta($speedycache->image['id'], 'speedycache_optimisation');
						delete_post_meta($speedycache->image['id'], 'speedycache_optimisation_reduction');
						$result = array('success' => true);
					}
				}
				
				continue;
			}

			if(preg_match('/'.preg_quote($speedycache->image['metadata']['file'], '/').'/', $image['url'])){
				delete_post_meta($speedycache->image['id'], 'speedycache_optimisation');
				delete_post_meta($speedycache->image['id'], 'speedycache_optimisation_reduction');
				$result = array('success' => true);
			}

		}
		
		return $result;
	}

	static function revert_on_delete($id){
		global $speedycache;
		
		if(!wp_attachment_is_image($id)){
			return;
		}
		
		$speedycache->image['id'] = $id;
		
		self::revert();
	}

	static function get_error_text($id){
		
		//Error Codes
		$errors = array(
			2 => __('In backup folder parent folder not writable', 'speedycache'),
			3 => __('No need to optimize', 'speedycache'),
			4 => __('Source is not writable', 'speedycache'),
			5 => __('Destination is not writable', 'speedycache'),
			6 => __('ImageMagick library is not avaliable', 'speedycache'),
			7 => __('Error via api', 'speedycache'),
			8 => __('Source file does not exist', 'speedycache'),
			9 => __('Image size exceed 20mb limit while processing', 'speedycache'),
		   11 => __('Empty Name', 'speedycache'),
		   12 => __('Forbidden', 'speedycache'),
		   13 => __('CloudFlare to restrict access', 'speedycache'),
		   14 => __('No Extension', 'speedycache'),
		   15 => __('Image size is 0Kb', 'speedycache'),
		   16 => __('Corrupted Image', 'speedycache'),
		   17 => __('Empty metadata', 'speedycache'),
		   18 => __('No Image', 'speedycache'),
		   19 => __('destination_move_source_path is not saved', 'speedycache'),
		   20 => __('file size of destination_move_source_path is zero', 'speedycache'),
		   21 => __('Unacceptable file type', 'speedycache'),
		   23 => __('WEBP create by other tool', 'speedycache'),
		);

		return isset($errors[$id]) ? $errors[$id] : 'Unkown error code';
	}

	// TODO:: Will use it when we will do non-webp compression
	static function backup_folder_exist(){
		global $speedycache;
		
		$backup_folder_path = $speedycache->image['upload_dir']['basedir'].'/speedycache-backup';

		if(is_dir($backup_folder_path)){
			return true;
		}

		if(@mkdir($backup_folder_path, 0755, true)){
			return true;
		}
		return false;

	}

	static function push_main_image($arr){
		if(!isset($arr[0]) || isset($arr[0]->error_code)){
			return $arr;
		}

		$main = clone $arr[0];
		$total_reduction = 0;

		foreach($arr as $std_key => $std_value){
			if(!isset($std_value->error_code)){
				if(isset($std_value->reduction) && $std_value->reduction){
					$total_reduction = $total_reduction + $std_value->reduction;
				}
			}
		}

		$main->reduction = $total_reduction;

		array_unshift($arr, $main);

		return $arr;
	}

	static function list_content($query_images_args = array()){
		global $speedycache;
		
		remove_filter('posts_fields', '\SpeedyCache\Image::count_posts_fields'); //was causing bug
		
		$query_image = new \WP_Query( $query_images_args );
		$return_output = '';
		
		if(empty($query_image->posts) || count($query_image->posts) <= 0){
			return self::get_empty_row();
		}
		
		$count = 0;
		foreach($query_image->posts as $key => $post){
			$count++;
			$value_json = get_post_meta($post->ID, 'speedycache_optimisation', true);
			$tmpvalue_json = base64_decode($value_json);
			
			$std = json_decode($tmpvalue_json);

			$revert = true;

			$std = self::push_main_image($std);
			
			foreach($std as $std_key => $std_value){
				
				$content = ($std_key === 0) ? self::get_row() : self::get_child_row();

				if(empty($content)){
					continue;
				}

				$std_value->destination_path = isset($std_value->destination_path) ? $std_value->destination_path : '';
				$std_value->reduction = isset($std_value->reduction) ? $std_value->reduction : 0;
				
				if($std_key === 0 && $revert){
					$revert_button = '';
				}else{
					$revert_button = 'display:none;';
				}

				if(isset($std_value->error_code) && $std_value->error_code == 8){
					$revert_button = 'display:none;';
				}

				if(file_exists($std_value->destination_path)){
					$backup_url = $std_value->url.'?v='.time();
					$backup_title = 'Original Image';
					$backup_error_style = '';
				}else{
					if(isset($std_value->error_code) && $std_value->error_code){
						$backup_url = get_edit_post_link($std_value->id);
						$backup_title = self::get_error_text($std_value->error_code);
						$backup_error_style = 'color: #FF0000;cursor:pointer;font-weight:bold;';
					}else{
						$backup_url = '#';
						$backup_title = '';
						$backup_error_style = '';
					}
				}
				
				$std_value->file = preg_replace('/.(jpg|jpeg|png|gif)$/','.webp', $std_value->file);
				
				if(file_exists($std_value->file)){
					$std_value->url = preg_replace('/.(jpg|jpeg|png|gif)$/','.webp', $std_value->url).'?v='.time();
				}else{
					$std_value->url = SPEEDYCACHE_PRO_URL.'/assets/images/no-image.png';
				}

				$short_code = array(
					'{{post_id}}',
					'{{attachment}}',
					'{{post_title}}',
					'{{url}}',
					'{{width}}',
					'{{height}}',
					'{{reduction}}',
					'{{date}}',
					'{{revert_button}}',
					'{{backup_url}}',
					'{{backup_title}}',
					'{{backup_error_style}}'
				);
				
				$datas = array(
					$std_value->id,
					$std_value->url,
					$post->post_title,
					$std_value->url,
					$std_value->width,
					$std_value->height,
					$std_value->reduction/1000,
					date('d-m-Y <br> H:i:s', $std_value->time),
					$revert_button,
					$backup_url,
					$backup_title,
					$backup_error_style
				);
			
				$return_output .= str_replace($short_code, $datas, $content);
			}
		}
		return $return_output;
	}

	static function allowed_mime($filename){
		global $speedycache;
		
		$mimetype = false;

		if(!file_exists($filename)){
			return false;
		}

		if(function_exists('finfo_open')){
		   $finfo = finfo_open(FILEINFO_MIME_TYPE);
		   $mimetype = finfo_file($finfo, $filename);
		   finfo_close($finfo);
		}else if(function_exists('getimagesize')){
		   $img = getimagesize($filename);
		   $mimetype = $img['mime'];
		}else{
			echo 'not found mime_content_type';
			exit;
		}
		
		if($speedycache->image['settings']['compression_method'] === 'cwebp' && self::gif2webp_exists()){
			if(preg_match('/(jpg|jpeg|jpe|png|gif)/i', $mimetype)){
				return true;
			}
			
			return false;
		}

		if(preg_match('/(jpg|jpeg|jpe|png)/i', $mimetype)){
			return true;
		}
		
		return false;
	}

	// Check if the image is available, the response code should be 200
	static function not_found($url){
		return false;
		
		$res = wp_remote_head($url, array('timeout' => 3 ));

		if(is_wp_error($res)){
			$url_header = @get_headers($url);

			if(preg_match('/200\s+OK/i', $url_header[0])){
				return false;
			}
			
			return true;
		}
		
		if($res['response']['code'] == 200){
			return false;
		}

		return true;
	}

	//Checks if the image is Unique
	static function unique_array($images){
		if(count($images) <= 1){
			return $images;
		}

		$arr = array();
		$images_tmp = array();

		foreach($images as $key => $value){
			if(!in_array($value['file'], $arr)){
				array_push($arr, $value['file']);
				array_push($images_tmp, $value);
			}
		}
		
		return $images_tmp;
	}
	//Template static functions Starts Here

	//Table row for the converted Image
	static function get_row(){
		return '<tr class="alternate author-self status-inherit" post-id="{{post_id}}">
			<td class="column-icon media-icon image-icon">
				<img width="39" height="60" src="{{attachment}}" class="attachment-80x60">
			</td>
			<td class="title column-title">
				<p style="margin-bottom: 0;"><a href="{{url}}" target="_blank">{{post_title}}</a></p>
				<p style="margin-bottom: 0;">
					<a style="{{backup_error_style}}" href="{{backup_url}}" target="_blank"><strong>{{backup_title}}</strong></a>
				</p>
			</td>
			<td class="author column-author speedycache-open-image-details" style="text-align: center;cursor: pointer;">{{reduction}}KB<span class="dashicons dashicons-arrow-down-alt2"></span></td>
			<td class="date column-date" style="text-align: center;">{{date}}</td>
			<td class="date column-date" style="text-align: center;">
			<div class="speedycache-revert" style="{{revert_button}}">
				<input type="hidden" value="{{post_id}}">
			</div>
			</td>
		</tr>';
	}

	//table row for different sizes of image.
	static function get_child_row(){
		
		return '<tr class="alternate author-self status-inherit" post-id="{{post_id}}" post-type="detail" style="display: none; padding-left: 20px;">
			<td class="column-icon media-icon" style="font-size:3.5em; color:#ccc;"><i class="fas fa-image"></i></td>
			<td class="title column-title">
				<p style="margin-bottom: 0;"><a href="{{url}}" target="_blank">{{post_title}}</a></p>
				<p style="margin-bottom: 0;">
					<a style="{{backup_error_style}}" href="{{backup_url}}" target="_blank"><strong>{{backup_title}}</strong></a>
				</p>
				<p style="margin-bottom: 0;">{{width}}x{{height}}</p>
			</td>
			<td class="author column-author" style="text-align: center;">{{reduction}}KB</td>
			<td class="date column-date" style="text-align: center;">{{date}}</td>
			<td class="date column-date" style="text-align: center;">
			</td>
		</tr>';
	}

	//No Image optimized
	static function get_empty_row(){
		return '<tr class="author-self status-inherit">
			<td colspan="4">No image has been optimized yet</td>
		</tr>';

	}

	//Paging for the converted Images Table
	static function paging(){ ?>
		<div class="tablenav bottom" style="padding:5px 16px 5px 19px">
			<div style="float:left;">
				<span class="deleteicon">
					<input type="text" style="height:28px;" placeholder="Search" id="speedycache-image-search-input" class="deletable" value="">
					<span class="cleared"></span>
				</span>
				<input type="submit" class="button action" value="Search" id="speedycache-image-search-button" name="filter_action">
			</div>
			<div style="float:left;padding-left:5px;">
				<select id="speedycache-image-list-filter" class="bulk-action-selector-top">
					<option value="" selected="selected">All</option>
					<option value='error_code'>Errors</option>
				</select>
			</div>
			<div style="float:left;padding-left:5px;">
				<select id="speedycache-image-per-page" class="bulk-action-selector-top">
					<option value="5" selected="selected">5</option>
					<option value="10">10</option>
					<option value="25">25</option>
				</select>
			</div>
			<div class="tablenav-pages">
				<span class="pagination-links">
					<a class="tablenav-pages-navspan button first-page disabled speedycache-image-list-first-page" aria-hidden="true" data-page-action="first-page">«</a>
					<a class="tablenav-pages-navspan button prev-page speedycache-image-list-prev-page" aria-hidden="true" data-page-action="prev-page">‹</a>
					<a class="paging-input"><label class="speedycache-current-page">1</label> / <span class="total-pages speedycache-total-pages">1</span></a>
					<a class="next-page button speedycache-image-list-next-page" data-page-action="next-page">›</a>
					<a class="last-page button speedycache-image-list-last-page" data-page-action="last-page">»</a>
				</span>
			</div>
			<br class="clear">
		</div>
	<?php
	}

	//Settings for Image Optimization
	static function settings(){
		global $speedycache, $speedycache_optm_method; 

		?>
		<div class="speedycache-block">
			<div class="speedycache-block-title"><h2><?php _e('Settings', 'speedycache'); ?></h2></div>
			<form class="speedycache-img-opt-settings">
				<div class="speedycache-option-wrap">
					<label for="speedycache_img_automatic_optm" class="speedycache-custom-checkbox">
						<input type="checkbox" id="speedycache_img_automatic_optm" name="img_automatic_optm" <?php echo (isset($speedycache->image['settings']['automatic_optm']) && $speedycache->image['settings']['automatic_optm']) ? ' checked="true"' : '';?>/>
						<div class="speedycache-input-slider"></div>
					</label>
					<div class="speedycache-option-info">
						<span class="speedycache-option-name"><?php esc_html_e('Automatic optimization', 'speedycache'); ?></span>
						<span class="speedycache-option-desc"><?php esc_html_e('Whenever user visits the website and there are images that haven\'t been converted to webp then that image(s) gets converted.', 'speedycache'); ?></span>
					</div>
				</div>
				<div class="speedycache-option-wrap">
					<label for="speedycache_img_on_upload" class="speedycache-custom-checkbox">
						<input type="checkbox" id="speedycache_img_on_upload" name="img_on_upload" <?php echo (isset($speedycache->image['settings']['on_upload']) && $speedycache->image['settings']['on_upload']) ? ' checked="true"' : '';?>/>
						<div class="speedycache-input-slider"></div>
					</label>
					<div class="speedycache-option-info">
						<span class="speedycache-option-name"><?php esc_html_e('Optimize on Image Upload', 'speedycache'); ?></span>
						<span class="speedycache-option-desc"><?php esc_html_e('Images will be added to a queue and will optimized after a certain interval to reduce load on the server.', 'speedycache'); ?></span>
					</div>
				</div>
				
				<div class="speedycache-option-wrap">
					<label for="speedycache_img_url_rewrite" class="speedycache-custom-checkbox">
						<input type="checkbox" id="speedycache_img_url_rewrite" name="img_url_rewrite" <?php echo (isset($speedycache->image['settings']['url_rewrite']) && $speedycache->image['settings']['url_rewrite']) ? ' checked="true"' : '';?>/>
						<div class="speedycache-input-slider"></div>
					</label>
					<div class="speedycache-option-info">
						<span class="speedycache-option-name"><?php esc_html_e('Rewrite Image URL\'s', 'speedycache'); ?></span>
						<span class="speedycache-option-desc"><?php esc_html_e('Rewrites the url of the image on the page to the webp version if webp version is avaliable.', 'speedycache'); ?></span>
					</div>
				</div>

				<div class="speedycache-option-wrap">
					<label for="speedycache_img_quality">
						<input type="number" id="speedycache_img_quality" name="img_compression_quality" value="<?php echo esc_attr($speedycache->image['settings']['compression_quality']);?>" min="50" step="5" max="90"/>
					</label>
					<div class="speedycache-option-info">
						<span class="speedycache-option-name"><?php esc_html_e('Compression Quality', 'speedycache'); ?></span>
						<span class="speedycache-option-desc"><?php esc_html_e('Higher the number higher will be the converted image quality in webp', 'speedycache'); ?></span>
					</div>
				</div>
				
				<div class="speedycache-block-title" style="flex-direction:column">
					<h4><?php esc_html_e('Conversion Methods', 'speedycache'); ?></h4>
					<p style="display:block; font-family: monospace; background-color: #f2f2f2; border-radius:6px; padding:10px;"><span style="color:var(--speedycache-red); font-weight:bold;"><i class="fas fa-exclamation"></i> Note:</span><?php esc_html_e('Only cwebp supports gif conversions to webp. But when you upload an image to WordPress whether it be a jpg, png, or gif format, WordPress creates different sizes of that image on upload so, in the process of resizing some resized version of gifs may lose their animation.', 'speedycache'); ?>
				</div>
				<?php foreach($speedycache_optm_method as $m_key => $method){ ?>
					<div class="speedycache-option-wrap <?php echo !$method['status'] ? ' speedycache-disabled-methods' : '' ?>">
						<label for="speedycache-img-<?php echo esc_attr($m_key);?>">
							<input type="radio" value="<?php echo esc_attr($m_key);?>" name="img_compression_method" id="speedycache-img-<?php echo esc_attr($m_key);?>" <?php echo (isset($speedycache->image['settings']['compression_method']) && $speedycache->image['settings']['compression_method'] == $m_key ? ' checked="true"' : '');?> <?php echo !$method['status'] ? ' disabled' : '' ?>/>
						</label>
						<div class="speedycache-option-info">
							<span class="speedycache-option-name"><?php echo esc_html($method['title']); ?></span>
							<span class="speedycache-option-desc"><?php echo esc_html($method['desc']); ?></span>
						</div>
						<?php 
						// TODO:: Need to fix this _e as it is a dynamic value we will need to use sprintf
						if(!$speedycache_optm_method[$m_key]['status']){ ?>
							<div class="speedycache-more-info" data-info="<?php echo esc_html($speedycache_optm_method[$m_key]['message']);?>" >
								<i class="fas fa-question-circle"></i>
							</div>
						<?php } ?>
							<div class="speedycache-img-method-actions">
						<?php 
						
						if($m_key == 'cwebp'){
							if(defined('SPEEDYCACHE_PRO') && !file_exists(wp_upload_dir()['basedir']. '/speedycache-binary/'.$speedycache->image['cwebp_binary'])){
								echo '<button style="margin-right:5px;" class="speedycache-button speedycache-btn-black speedycache-webp-download">Download Binary</button>';
							}
							
							if(defined('SPEEDYCACHE_PRO') && !self::gif2webp_exists()){
								echo '<button class="speedycache-button speedycache-btn-black speedycache-webp-download" style="margin-top:2px;" data-type="gif">Download Binary for GIF</button>';
							}
						}
						?>
						</div>
					</div>	
				<?php } ?>
			</form>
		</div>
	<?php 
	}


	//Image Optimization Stats
	static function statics(){
		$res = self::statics_data();
		$ring_success = 100 - (int)$res['percent'];
		
		$scheduled = self::get_optimization_schedule(array('speedycache_auto_optm', 'speedycache_img_delete'));
		$scheduled_count = count($scheduled);
		
		//the css below is written in one line to make regex replace easy in js update.
	?>
		<style>
			@keyframes donut1 {
			0%{stroke-dasharray: 0, 100;}
			100%{stroke-dasharray: <?php echo esc_attr($res['percent'] .', ' . $ring_success);?>;}
		}
		</style>
		<div class="speedycache-block">
			<div class="speedycache-img-stats speedycache-admin-row">
				<div class="speedycache-is-block speedycache-img-graph">
					<div class="speedycache-card-body">
						<div class="speedycache-img-start-optm">
							<div class="speedycache-img-stat-info">
								<div class="speedycache-img-main-stat">
									<?php esc_html_e('Success', 'speedycache'); ?>
									<span class="speedycache-img-success-per"><?php echo esc_html($res['percent']);?>%</span>
								</div>
								<div class="speedycache-img-main-stat">
									<?php esc_html_e('Error', 'speedycache');?>
									<span class="speedycache-img-error-count" <?php echo $res['error'] > 0 ? 'style="color:#dc3545"' : '' ?>><?php echo esc_html($res['error']);?></span>
								</div>
								<div class="speedycache-img-main-stat">
									<?php esc_html_e('Scheduled', 'speedycache');?>
									<span class="speedycache-scheduled-count <?php echo $scheduled_count > 0 ? 'speedycache-scheduled-count-indicator' : '';?>" setting-id="speedycache-img-scheduled-modal"><?php echo esc_html($scheduled_count);?></span>
								</div>
							</div>
							<div class="speedycache-img-remain-optm">
								<span class="speedycache_img_optm_status" style="background-color:<?php echo $res['uncompressed'] > 0 ? '#EED202' : '#90ee90'?>"></span>
								<span>
								<?php 
									if($res['uncompressed'] > 0){
										echo esc_html($res['uncompressed']) . ' ';
										esc_html_e('Files needed to be optimized', 'speedycache');
									} else {
										esc_html_e('All images are optimized', 'speedycache');
									}	
								?></span>
									
							</div>
							<div class="speedycache-img-optimize-all" style="margin-left:auto;">
								<button class="speedycache-button speedycache-btn-black speedycache-img-optm-btn" setting-id="speedycache-modal-optimize-all"><?php esc_html_e('Optimize All', 'speedycache'); ?></button>
								<button class="speedycache-img-delete-all-conv speedycache-button speedycache-btn-transparent"><?php esc_html_e('Delete all conversions', 'speedycache'); ?></button>
							</div>
						</div>
					</div>
				</div>
		
				<div class="speedycache-is-block speedycache-img-count">
					<div>
						<div class="speedycache-img-opt-stat">
							<div class="speedycache-img-optm-count"><?php echo esc_html($res['optimized'] . '/' . $res['total_image_number']); ?></div>
							<div class="speedycache-img-optm-count-text"><?php echo esc_html_e('Image(s) optimized', 'speedycache'); ?>
							<?php echo esc_html_e('with total reduction of', 'speedycache'); ?> <span class="speedycache-img-reduced-size"><?php echo esc_html($res['reduction'] > 10000 ? round($res['reduction']/1000, 2).'MB' : $res['reduction'].'KB');?></span></div>
						</div>
					</div>
				</div>
			</div>
		</div>
		
		<div modal-id="speedycache-img-scheduled-modal" class="speedycache-modal">
			<div class="speedycache-modal-wrap">
				<div class="speedycache-modal-header">
					<div><?php esc_html_e('Scheduled Tasks', 'speedycache'); ?></div>
					<div title="Close Modal" class="speedycache-close-modal">
						<span class="dashicons dashicons-no"></span>
					</div>
				</div>
				<div class="speedycache-modal-content speedycache-info-modal">
					<?php if($scheduled_count < 1){ ?>
						<span><?php esc_html_e('No Image Scheduled', 'speedycache'); ?></span>
					<?php } else { ?>
					<!--<p style="text-align:center;"><?php //_e('Time Interval of the Schedule is 1 minute', 'speedycache');?></p>-->
					<table style="margin:auto; width: 100%;">
						<thead>
							<tr>
								<th class="speedycache-table-hitem" scope="col"><?php esc_html_e('Image', 'speedycache'); ?></th>
								<th class="speedycache-table-hitem" scope="col"><?php esc_html_e('Time', 'speedycache'); ?></th>
							</tr>
						</thead>
						<tbody>
							<?php
							foreach($scheduled as $key => $schedule){

								$time = $schedule['time'] - time();

								$time_str = 'in '.$time. ' seconds';
								
								if($time > 59){
									$time_str = 'in '. round($time/60, 1) . ' minute(s)';
								} else if($time <= 0){
									$time_str = 'now';
								}
								?>
							<tr>
								<td class="speedycache-table-item"><?php echo esc_html('Batch ' . ($key + 1)); ?></td>
								<td class="speedycache-table-item" style="text-align:right;"><?php echo esc_html($time_str);?> <i class="fas fa-stopwatch"></i></td>
							</tr>
							<?php } ?>
							
						</tbody>
					</table>
					<?php } ?>
				</div>
			</div>
		</div>
		
		<div modal-id="speedycache-modal-all-img-revert" class="speedycache-modal">
			<div class="speedycache-modal-wrap">
				<div class="speedycache-modal-content">
					<i class="fas fa-info-circle"></i>
					<h1><?php esc_html_e('Revert All Images!', 'speedycache'); ?></h1>
					<p><?php esc_html_e('Once deleted the changes won\'t be reversible.', 'speedycache'); ?></p>
					<div class="speedycache-modal-db-actions">
						<button class="speedycache-btn speedycache-db-confirm-yes"><?php esc_html_e('Yes', 'speedycache'); ?></button>
						<button class="speedycache-btn speedycache-db-confirm-no"><?php esc_html_e('No', 'speedycache'); ?></button>
					</div>
				</div>
			</div>
		</div>
	<?php
	}
	//Templates Ends here

	//Need to create logs for Automatic Optimization
	static function log(){
		
	}

	static function compression_method_checks(){
		global $speedycache, $speedycache_optm_method;
		
		$gd = self::gd_check();
		$speedycache_optm_method['gd'] = array_merge($speedycache_optm_method['gd'], $gd);
		
		if(!$speedycache_optm_method['gd']['status']){
			$speedycache->image['disabled_method']++;
			self::change_method_if_not_available('gd');
		}
		
		$imagick = self::imagick_check();
		$speedycache_optm_method['imagick'] = array_merge($speedycache_optm_method['imagick'], $imagick);
		
		if(!$speedycache_optm_method['imagick']['status']){
			$speedycache->image['disabled_method']++;
			self::change_method_if_not_available('imagick');
		}
		
		$cwebp = self::cwebp_check();
		$speedycache_optm_method['cwebp'] = array_merge($speedycache_optm_method['cwebp'], $cwebp);
		
		if(!$speedycache_optm_method['cwebp']['status']){
			$speedycache->image['disabled_method']++;
			self::change_method_if_not_available('cwebp');
		}
	}

	// GD static function Starts here
	static function gd_check(){
		if(!extension_loaded('gd')){
			return array('status' => false, 'message' => 'You dont have GD PHP extension');
		}

		if(isset(gd_info()['WebP Support']) && !gd_info()['WebP Support']){
			return array('status' => false, 'message' => 'GD extension on your server dosen\'t support WEBP');
		}
		
		if(isset(gd_info()['WebP Support']) && gd_info()['WebP Support']){
			return array('status' => true, 'message' => 'Operational');
		}
	}

	static function gd_webp($file){
		global $speedycache, $speedycache_optm_method;

		if(isset($speedycache_optm_method['gd']['status']) && !$speedycache_optm_method['gd']['status']){
			return array('success' => false, 'error_message' => $speedycache_optm_method['gd']['message']);
		}
		
		$image_size = getimagesize($file);
		$width = $image_size[0];
		$height = $image_size[1];
		
		switch($image_size['mime']){
			case 'image/jpg':
			case 'image/jpeg':
				$source = imagecreatefromjpeg($file);
				break;
			
			case 'image/png':
				$source = imagecreatefrompng($file);
				break;
				
			case 'image/webp': 
				return array('success' => false, 'error_message' => 'File is alredy a WEBP file');
				
			default:
				return array('success' => false, 'error_message' => 'File has unsupported mime'.$image_size['mime']);
		}
		
		if(empty($source)){
			return false;
		}
		
		$dst = imagecreatetruecolor($width, $height);
		
		if(imagealphablending($dst, false) !== false){
			//change the RGB values if you need, but leave alpha at 127
			$transparent = imagecolorallocatealpha($dst, 255, 255, 255, 127);

			if($transparent !== false){
				//simpler than flood fill
				if(imagefilledrectangle($dst, 0, 0, $width, $height, $transparent) !== false){
					//restore default blending
					if(imagealphablending($dst, true) !== false){
						if(imagecopy($dst, $source, 0, 0, 0, 0, $width, $height) !== false){
							$success = true;
						}
					};
				}
			}
		}
		
		if(!$success){
			return array('success' => false, 'error_message' => 'Couldn\'t convert the given image.');
		}
		
		$webp_path = preg_replace('/.(jpe?g|png)$/', '.webp', $file);
		
		imagedestroy($source);
		imagewebp($dst, $webp_path, $speedycache->image['settings']['compression_quality']);
		imagedestroy($dst);
		
		if(!file_exists($webp_path)){
			return array('url' => $webp_path, 'success' => true, 'error_message' => 19);
		}

		return array(
			'url' => $webp_path,
			'success' => true,
			'error_message' => ''
		);
	}
	//GD Ends Here

	//Imagick static functions
	static function imagick_check(){
		
		if(!extension_loaded('imagick')){
			return array('status' => false, 'message' => 'Imagick extension isn\'t installed');
		}
		
		$image = new \Imagick();
		
		if(!in_array('WEBP', $image->queryFormats('WEBP'))){
			$image->clear();
			$image->destroy();
		
			return array('status' => false, 'message' => 'Imagick installed on your system is without WEBP support');
		}
		
		return array('status' => true, 'message' => 'Operational');
	}

	static function change_method_if_not_available($m_name){
		global $speedycache, $speedycache_optm_method;
		
		if($speedycache->image['settings']['compression_method'] != $m_name){
			return;
		}
		
		$valid_method = '';
		
		foreach($speedycache_optm_method as $key => $method){
			if($key == $m_name){
				continue;
			}
			
			if(!empty($method['status'])){
				$speedycache->image['settings']['compression_method'] = $key;
				return;
			}
		}

		$speedycache->image['settings']['compression_method'] = $valid_method;
	}

	//Conversion of image to webp
	static function imagick_webp($file){
		global $speedycache, $speedycache_optm_method;
		
		if(isset($speedycache_optm_method['imagick']['status']) && !$speedycache_optm_method['imagick']['status']){
			return array('success' => false, 'error_message' => $speedycache_optm_method['imagick']['message']);
		}
		
		$dest = preg_replace('/.(png|jpe?g)$/', '.webp', $file);
		
		$image = new \Imagick();
		$image->readImage($file);
		$image->setImageCompressionQuality($speedycache->image['settings']['compression_quality']);
		$image->setImageFormat('WEBP');
		
		if($image->writeImage($dest)){
			$image->clear();
			$image->destroy();
			
			return array('success' => true, 'error_message' => '');
		}
		
		$image->clear();
		$image->destroy();
		
		return array('success' => false, 'error_message' => 'File didn\'t got saved');
	}

	//cwebp static functions
	static function cwebp_check(){
		global $speedycache;
		
		if(!defined('SPEEDYCACHE_PRO')){
			return array('status' => false, 'message' => 'cwebp is a SPEEDYCACHE PRO feature.');
		}
		
		if(!function_exists('exec')){
			return array('status' => false, 'message' => 'You dont have access to exec static function hence you cant use cWebP for Image optimizations');
		}
		
		if(isset($speedycache->image['cwebp_binary'])){
			
			if(!file_exists(wp_upload_dir()['basedir'].'/speedycache-binary/'.$speedycache->image['cwebp_binary'])){
				return array('status' => false, 'message' => 'You don\'t have the cwebp Binary on your server.', 'downloaded' => false);
			} 
		}
		
		return array('status' => true, 'message' => 'Operational');
	}

	static function rewrite_url_to_webp($content){
		if(strpos(speedycache_optserver('HTTP_ACCEPT'), 'image/webp') < 0){
			return $content;
		}
		
		if( ! preg_match_all( '/<img\s[^>]+>/', $content, $matches, PREG_SET_ORDER ) ){
			return $content;
		}
		
		foreach($matches as $match){
			///(?i)(https?:\/\/|www.|\w+\.(png|jpe?g)$)[^\s]+/
			preg_match_all('/https?:\/(\/[^\/]+)+\.(?:jpe?g|png|gif)/', $match[0], $urls, PREG_SET_ORDER); 
			
			foreach($urls as $url){
				$file_url = preg_replace('/.(jpe?g|png|gif)$/', '.webp', $url[0]);
				
				$file_path = explode(SPEEDYCACHE_WP_CONTENT_DIR.'/uploads', $file_url);

				if(!isset($file_path[1]) || !file_exists(wp_upload_dir()['basedir'].$file_path[1])){
					continue;
				}
				
				$content = str_replace($url[0], $file_url, $content);
			}
		
		}
		
		return $content;
	}

	//Adding wp event for automatic optm on image upload
	static function convert_on_upload($id){
		global $speedycache;

		if(!$speedycache->image['settings']['on_upload']){
			return;
		}
		
		if(!wp_attachment_is_image($id)){
			return;
		}
		
		$scheduled = self::get_optimization_schedule(array('speedycache_auto_optm'));
		$time = time();
		
		if(!empty($scheduled) && isset(end($scheduled)['time'])){
			$time = end($scheduled)['time'];
		}
		
		// Convert after 5 minutes of upload
		if(!wp_next_scheduled('speedycache_auto_optm', array($id))){
			wp_schedule_single_event($time + 300, 'speedycache_auto_optm', array($id));
			return;
		}
	}

	//Optimizing image on Upload
	static function auto_optimize($img_id){
		self::optimize_single($img_id);
	}

	//Whenever user visits a page and there are images that dont have a webp versions then those images are set to be converted.
	static function optimize_on_fly($content){
		global $wpdb, $speedycache;

		//Sitepad dosen't have this static function.
		if(function_exists('wp_filter_content_tags')){
			$content = wp_filter_content_tags($content);
		}

		if(!preg_match_all('/<img\s[^>]+>|background:\s*url\(["\']?(.*?)["\']?\)/i', $content, $matches, PREG_SET_ORDER)){
			return $content;
		}

		foreach($matches as $match){
			// pl-image{post-id} will work only after Pagelayer 1.9.0
			if(!preg_match('/(?:wp|pl)-image-([\d]+)/i', $match[0], $post_id)){
				/*
				* This is for compatibility with other editors and for inline css background url
				* what we do here is look for either img src url or background:url()
				* Then we attempt to get id from the URL.
				*/
				//<img(?:[^>]|[^\/>]).*src[\s*]?=[\s*]?"(.+?)" just in case the one used causes bugs
				if(strpos($match[0], 'background:url') === FALSE && !preg_match('/<img.*?src="(.*?)"/', $match[0], $url)){
					continue;
				}
				
				if(strpos($match[0], 'background:url') !== FALSE){
					$image_url = sanitize_url($match[1]);
				} else {
					$image_url = sanitize_url($url[1]);
				}

				$post_id = (int) attachment_url_to_postid($image_url);
				
				if(empty($post_id)){
					$file = basename($image_url);
					$like = '%'.$wpdb->esc_like($file) .'%';
					$query = $wpdb->prepare("SELECT `post_id` FROM `".$wpdb->prefix."postmeta` WHERE `meta_value` LIKE %s", $like);
					$post_id = (int) $wpdb->get_var($query);
				}

				if(empty($post_id)){
					continue;
				}
			}
		
			if(empty($post_id)){
				continue;
			}
			
			// If we captured post id through wp-image|pl-image
			if(is_array($post_id) && isset($post_id[1])){
				$post_id = intval($post_id[1]);
			}

			// If the image is already scheduled for optimization then just skip it.
			if(wp_next_scheduled('speedycache_auto_optm', array($post_id))){
				continue;
			}
			
			if(!get_post($post_id)){
				continue;
			}

			$optimized = (int) $wpdb->get_var($wpdb->prepare("SELECT count(`meta_key`) as optimized FROM `".$wpdb->prefix."postmeta` WHERE `meta_key`= 'speedycache_optimisation' AND `post_id`=%d", $post_id));
			
			if($optimized > 0){
				continue;
			}
			
			$scheduled = self::get_optimization_schedule(array('speedycache_auto_optm'));
			$time = time();
		
			if(!empty($scheduled) && isset(end($scheduled)['time'])){
				// getting the last index to get the last scheduled event
				$time = end($scheduled)['time'];
			}
			
			$final_schd_time = $time + 60;
		
			if(!wp_next_scheduled('speedycache_auto_optm', array($post_id))){
				wp_schedule_single_event($final_schd_time, 'speedycache_auto_optm', array($post_id));
				
				continue;
			}
		}

		return $content;
	}

	// Returns an array of cron event "speedycache_auto_optm"
	static function get_optimization_schedule($event_name){
		$cron = _get_cron_array();
		
		if(empty($cron)){
			return false;
		}
		
		$scheduled = array();
		
		foreach($cron as $key => $crn){
			foreach($crn as $e_key => $event){
				if(!in_array($e_key, $event_name)){
					continue;
				}

				foreach($event as $evt){
					$args = $evt['args'][0];
				}
				
				array_push($scheduled, array('name' => get_the_title($args), 'time' => $key));
			}
		}
		
		return $scheduled;
	}

	static function gif2webp_exists(){
		global $speedycache;
		
		if(file_exists(wp_upload_dir()['basedir']. '/speedycache-binary/'.$speedycache->image['cwebp_gif'])){
			return true;
		}
		
		return false;
	}
	
	static function download_cwebp(){
		global $speedycache;

		check_ajax_referer('speedycache_ajax_nonce', 'security');
		
		$binary_name = $speedycache->image['cwebp_binary'];
		
		$type = speedycache_optget('type');
		
		switch($type){
			case 'gif':
				$binary_name = $speedycache->image['cwebp_gif'];
				break;
				
			case 'cwebp':
				$binary_name = $speedycache->image['cwebp_binary'];
				break;
				
			default:
				return;
		}
		
		$binary_path = wp_upload_dir()['basedir'].'/speedycache-binary';
		
		if(!file_exists($binary_path)){
			@mkdir($binary_path);
		}
		
		//If The binary alredy exists on the server
		if(file_exists($binary_path.'/'.$binary_name)){
			wp_send_json(array('success' => false, 'error_message' => 'Binary Exists already.'));
		}
		
		$resp = wp_remote_get(SPEEDYCACHE_API.'/files/cwebp/'.$binary_name);
		$json = wp_remote_get(SPEEDYCACHE_API.'/files/hash.json');
		
		$hash = json_decode($json['body'], true);
		$file = $resp['body'];
		
		if(!$hash){
			wp_send_json(array('success' => false, 'error_message' => 'Unable to verify the downloaded binary.'));
		}
		
		if(!$file){
			wp_send_json(array('success' => false, 'error_message' => 'Could not download the file please try again later.'));
		}
		
		$binary_file = $binary_path.'/'.$binary_name;
		
		file_put_contents($binary_file, $file);
		
		if(!file_exists($binary_file)){
			wp_send_json(array('success' => false, 'error_message' => 'There was issue downloading the binary.'));
		}
		
		if(hash_file('md5', $binary_file) != $hash[$binary_name]){
			@unlink($binary_path.'/'.$binary_name);
			wp_send_json(array('success' => false, 'error_message' => 'Hash of the file downloaded didn\'t match'));
		}
			
		@chmod($binary_file, 0755);
		
		$output = null;
		$res = null;
		
		if(!function_exists('exec')){
			wp_send_json(array('success' => false, 'error_message' => 'Your server dosen\'t supports exec'));
		}
		
		$exec_name = $type === 'gif' ? 'gf2webp' : 'cwebp';
		
		/*
		* To check if the binary is supported by the server.
		*/
		exec('"'.$binary_file.'"  '.$exec_name.' -version 2>&1', $output, $res);
		
		if($res != 0){
			wp_send_json(array('success' => false, 'error_messsage' => 'The binary for cwebp isn\'t supported by your server'));
		}
		
		if($type = 'gif'){
			$speedycache->image['cwebp_gif'] = $binary_name;
		} else {
			$speedycache->image['cwebp_binary'] = $binary_name;
		}
		
		wp_send_json(array('success' => true));
	}

	static function cwebp_convert($file){
		global $speedycache, $speedycache_optm_method;
		
		if(isset($speedycache_optm_method['cwebp']['status']) && !$speedycache_optm_method['cwebp']['status']){
			return array('success' => false, 'error_message' => $speedycache_optm_method['cwebp']['message']);
		}
			
		$mime = mime_content_type($file);
		
		if($mime == 'image/gif'){
			$binary_path = wp_upload_dir()['basedir']. '/speedycache-binary/'.$speedycache->image['cwebp_gif'];
			$binary_name = 'gif2webp';
		} else {
			$binary_path = wp_upload_dir()['basedir']. '/speedycache-binary/'.$speedycache->image['cwebp_binary'];
			$binary_name = 'cwebp';
		}
		
		$output_file = preg_replace('/.(jpe?g|png|gif)$/', '.webp', $file);
		

		$res = null;
		$output = null;
		
		if(!file_exists($binary_path)){
			return array('success' => false, 'error_message' => 'The binary to use cwebp not found');
		}
		
		/*
		*	-- Use "" around the paths in exec, as without "" can cause a bug on some servers installs. 
		*	-- The Structure of the command below is :- 
		*	"path_of_binary" cwebp -q [quality_in_int] "original_file_path" -o "output_file.webp"
		*	-- 2>&1 is used to redirect stderr to same place as stdout
		*	https://www.brianstorti.com/understanding-shell-script-idiom-redirect/
		*/
		exec('"'.$binary_path.'" '.$binary_name.' -q '.$speedycache->image['settings']['compression_quality'].' "'.$file. '" -o "'. $output_file. '" 2>&1', $output, $res);
		
		if($res != 0){
			return array('success' => false, 'error_message' => 'Couldn\'t convert the given image using cwebp.', 'error_code' => 22);
		}
		
		return array('success' => true, 'error_message' => '', 'dest' => $output_file);
	}
	
	static function list_image_html(){
	?>
	<div id="speedycache-image-list">
		<?php \SpeedyCache\Image::paging(); ?>
		<div style="width:100%; overflow-x:auto;">
			<table class="wp-list-table widefat fixed media" style="width: 95%; margin-left: 20px;">
				<thead>
					<tr style="height: 35px;">
						<th scope="col" id="icon" class="manage-column column-icon" style=""></th>
						<th scope="col" id="title" class="manage-column column-title sortable desc" style="width: 323px;">
							<span style="padding-left: 8px;"><?php esc_html_e('File Name', 'speedycache'); ?></span>
						</th>
						<th scope="col" id="author" class="manage-column column-author sortable desc" style="width: 120px;text-align: center;">
							<span><?php esc_html_e('Reduction', 'speedycache'); ?></span>
						</th>
						<th scope="col" id="date" class="manage-column column-date sortable asc" style="width: 91px;text-align: center;">
							<span><?php esc_html_e('Date', 'speedycache'); ?></span>
						</th>
						<th scope="col" id="date" class="manage-column column-date sortable asc" style="width: 60px;text-align: center;">
							<span><?php esc_html_e('Revert', 'speedycache'); ?></span>
						</th>	
					</tr>
				</thead>
				<tbody id="the-list">
					<?php 
						$query_images_args = array();

						$query_images_args['order'] = 'DESC';
						$query_images_args['orderby'] = 'ID';
						$query_images_args['post_type'] = 'attachment';
						$query_images_args['post_mime_type'] = array('image/jpeg', 'image/png', 'image/gif');
						$query_images_args['post_status'] = 'inherit';
						$query_images_args['posts_per_page'] = 5;
						$query_images_args['meta_query'] = array(
							array(
								'key' => 'speedycache_optimisation',
								'compare' => 'EXISTS'
							)
						);

						echo \SpeedyCache\Image::list_content($query_images_args);
					?>
				</tbody>
			</table>
		</div>
	</div>
	<?php 
	}

}

PK��f\ �[[
index.htmlnu�[���<h1>Powered By SpeedyCache</h1>
Go to <a href="https://speedycache.com">SpeedyCache.Com</a>PK��f\E�
�$�$criticalcss.phpnu�[���<?php

/*
* SPEEDYCACHE
* https://speedycache.com/
* (c) SpeedyCache Team
*/

namespace SpeedyCache;

if(!defined('ABSPATH')){
	die('Hacking Attempt');
}

class CriticalCss extends CommonCss{

	static function generate($urls){
		global $speedycache;

		$time = time() + 50;
		set_time_limit(60);
		
		$api = self::get_endpoint();
		
		if(empty($urls)){
			self::log('speedycache_ccss_logs', 'URL not found');
			return false;
		}

		if(empty($speedycache->license['license'])){
			self::log('speedycache_ccss_logs', 'License Not found, please link your License');
			return false;
		}

		$path = speedycache_cache_path('critical-css/');
		$error = ''; // To hold errors when single Critical CSS is generated
		$attempted_url = []; // Keeping track of URL that have been proccessed to generate CriticalCSS to handle in case of Timeout

		if(!is_dir($path)){
			mkdir($path);
			touch($path . 'index.html');
		}

		foreach($urls as $url){
			// Handeling php timeout here
			if($time < time()){
				$urls = array_diff($urls, $attempted_url);
				self::schedule($urls);
				return;
			}

			$url = trim($url, '/');
			$license = strpos($speedycache->license['license'], 'SPDFY') !== 0 ? '' : $speedycache->license['license'];
			$attempted_url[] = $url;

			$basename = md5($url);
			$file_name = $path . $basename . '.css';

			$response = wp_remote_post($api, array(
				'timeout' => 30,
				'body' => array(
					'url' => $url,
					'license' => $license,
				),
				'sslverify' => false,
			));

			if(is_wp_error($response)){
				$error = $response->get_error_message();
				self::log('speedycache_ccss_logs', $response->get_error_message(), $url);
				continue;
			}

			$body = json_decode(wp_remote_retrieve_body($response), true);
			
			if(empty($body)){
				$error = __('The response recieved is empty.', 'speedycache');
				self::log('speedycache_ccss_logs', __('The response recieved is empty.', 'speedycache'), $url);
				continue;
			}

			if(empty($body['success'])){
				$error = !empty($body['message']) ? wp_strip_all_tags($body['message']) : __('Unable to extract CriticalCss', 'speedycache');
				self::log('speedycache_ccss_logs', !empty($body['message']) ? wp_strip_all_tags($body['message']) : __('Unable to extract CriticalCss', 'speedycache'), $url);
				continue;
			}

			if(empty($body['css']) || strlen($body['css']) < 20){
				$error = __('Was unable to generate Critical CSS', 'speedycache');
				self::log('speedycache_ccss_logs', __('Was unable to generate Critical CSS', 'speedycache'), $url);
				continue;
			}
			
			if(!is_dir($path)){
				mkdir($path);
			}
			
			file_put_contents($file_name, $body['css']);

			self::update_css($url, $body['css']);
			
			self::log('speedycache_ccss_logs', 'success', $url); //Updates the log on success
			
			if(!empty($error)){
				return $error;
			}

			return true;
		}
	}
	
	// Builds up the list to schedule URLs
	static function get_url_list(){
		global $blog_id;
		
		$pages = get_pages(array('child_of' => 0, 'number' => 9));
		
		if(empty($pages)){
			return false;
		}

		$page_to_crawl = [];

		$url = get_home_url(!empty($blog_id) ? $blog_id : null);
		
		if(!empty($url)){
			$page_to_crawl['home'] = $url;
		}

		foreach($pages as $p){
			$page_to_crawl[$p->ID] = get_page_link($p->ID);
		}

		return $page_to_crawl;
	}
	
	// Adds the generated css and asynchronyses the css includes
	static function update_css($url, $css){
		global $speedycache;
		
		if(empty($url)){
			return false;
		}
		
		if(empty($css) && file_exists(speedycache_cache_path('critical-css/') . md5($url) . '.css')){
			$css = file_get_contents(speedycache_cache_path('critical-css/') . md5($url) . '.css');
		}
		
		if(empty($css)){
			return false;
		}

		$css = '<style id="speedycache-generated-criticalcss">'. "\n". wp_strip_all_tags($css) . '</style>';

		$url = parse_url($url);
		$uri = !empty($url['path']) ?  $url['path'] : '';
		$cache_loc = $uri . '/index.html';

		if(empty($cache_loc)){
			return;
		}
		
		if(!empty($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT'] === 'SpeedyCacheTest'){
			$cache_path = speedycache_cache_path('test' . $cache_loc);
		} else {
			$cache_path = speedycache_cache_path('all' . $cache_loc);
		}

		$cache_path = rtrim($cache_path, '/');
		
		// For Desktop
		\SpeedyCache\CriticalCss::update_cached($cache_path, $css);

		if(!empty($speedycache->options['mobile_theme']) && $_SERVER['HTTP_USER_AGENT'] !== 'SpeedyCacheTest'){
			$cache_mobile = speedycache_cache_path('mobile-cache' . $cache_loc);
			
			// For Mobile Cache
			if(file_exists($cache_mobile)){
				\SpeedyCache\CriticalCss::update_cached($cache_mobile, $css);
			}	
		}

	}
	
	// Updates the content of the cached file
	static function update_content($content, $css){
		
		if(strpos($content, 'speedycache-generated-criticalcss') !== FALSE){
			$content = preg_replace('/<style id="speedycache-generated-criticalcss">(.*)<\/style>/sU', $css, $content);
		} else{
			$content = preg_replace('#</title>#iU', "</title>\n". $css, $content);
		}

		$content = \SpeedyCache\CriticalCss::make_css_defer($content);
		
		return $content;
	}
	
	/**
	 * This extracts the stylesheet links and convertes them to preload to make them async,
	 * and add the stylesheet links in noscript if js is disabled in some browsers
	 */
	static function make_css_defer($content){
		
		$css_links = '/(?=<link[^>]*\s(rel\s*=\s*[\'"]stylesheet["\']))<link[^>]*\shref\s*=\s*[\'"]([^\'"]+)[\'"](.*)>/iU';
		
		preg_match_all($css_links, $content, $matches, PREG_SET_ORDER, 0);

		if(empty($matches)){
			return $content;
		}
		
		$noscript_wrap = '<noscript>';

		foreach($matches as $tag){
			$preload = str_replace('stylesheet', 'preload', $tag[1]);
			$onload = preg_replace('~' . preg_quote($tag[3], '~') . '~iU', ' as="style" onload="" ' . $tag[3] . '>', $tag[3]);

			$new_tag = str_replace($tag[3] . '>', $onload, $tag[0]);
			$new_tag = str_replace($tag[1], $preload, $new_tag);
			$new_tag = str_replace('onload=""', 'onload="this.onload=null;this.rel=\'stylesheet\'"', $new_tag);
			$new_tag = preg_replace('/(id\s*=\s*[\"\'](?:[^\"\']*)*[\"\'])/i', '', $new_tag);

			$content = str_replace($tag[0], $new_tag, $content);
			
			$noscript_wrap .= $tag[0];
		}
		
		$noscript_wrap .= '</noscript>';
		
		$content = str_replace($noscript_wrap, '', $content);
		
		return str_replace('</body>', $noscript_wrap . '</body>', $content);

	}
	
	static function status_modal(){
		$html = '<!--SpeedyCache Critical CSS Logs Modal Starts Here-->
	<div modal-id="speedycache_critical_css" class="speedycache-modal">
		<div class="speedycache-modal-wrap">
			<div class="speedycache-modal-header">
				<div>'.esc_html__('Critical Cache Logs', 'speedycache').'</div>
				<div title="Close Modal" class="speedycache-close-modal">
					<span class="dashicons dashicons-no"></span>
				</div>
			</div>
			<div class="speedycache-modal-content" style="min-height:50vh;">
				<div class="speedycache-critical-css-status">';
			
			$generate_ccss = get_option('speedycache_ccss_logs', []);
			
			$scheduled = self::get_schedule(array('speedycache_generate_ccss'));
		
			if(!empty($scheduled)){
				$time = 'now';
				if(!empty($scheduled[0]['time']) && ($scheduled[0]['time'] - time()) > 0){
					$time = 'in ' . ($scheduled[0]['time'] - time()) . 's';
				}

				$html .= '<p style="color:rgb(1, 67, 97); background-color: rgb(229, 246, 253); padding: 10px; border-radius: 6px; font-family: monospace;">'. esc_html__('A process has been scheduled and will be executed', 'speedycache'). ' <strong>' . esc_html($time).'</strong></p>';
			}

			if(count($generate_ccss) < 1){
				$html .= '<span>'.esc_html__('No Logs found for CriticalCss', 'speedycache').'</span>';
			} else {
				$html .='<table style="margin:auto; width: 100%;">
					<thead>
						<tr>
							<th class="speedycache-table-hitem" scope="col">'.esc_html__('Time', 'speedycache').'</th>
							<th class="speedycache-table-hitem" scope="col">'. esc_html__('URLs', 'speedycache').'</th>
							<th class="speedycache-table-hitem" scope="col">'. esc_html__('Status', 'speedycache').'</th>
						</tr>
					</thead>
					<tbody>';
					
					$generate_ccss = array_reverse($generate_ccss);
					
					foreach($generate_ccss as $url => $status){
						$parsed_url = wp_parse_url($url);
						$path = !empty($parsed_url['path']) ? $parsed_url['path'] : '/';
						
						if($status['message'] == 'success'){
							$status_html = '<span class="dashicons dashicons-yes-alt" style="color:	#198754;" title="Success"></span>';
						} else {
							$status_html = '<div class="speedycache-tt"><span class="dashicons dashicons-info" style="color:#DC3545;"></span><span class="speedycache-tt-text">'.esc_html($status['message']).'</span></div>';
						}
						
						$html .= '<tr><td class="speedycache-table-item">'.esc_html($status['time']).'</td>
						<td class="speedycache-table-item">'.esc_html($path).'</td>
						<td class="speedycache-table-item" style="text-align:right;">'.wp_kses_post($status_html).'</td></tr>';
					}

				$html .= '</tbody>
				</table>';
			}
			
			$html .= '</div>
		</div>
	</div>
</div>';

		return $html;
	}

}
PK��f\�����premium.phpnu�[���<?php

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT');
}

global $pagenow;
if(in_array($pagenow, ['post-new.php', 'post.php'], true)){
	add_action('admin_enqueue_scripts', '\SpeedyCache\MetaboxPro::enqueue_scripts');
	add_filter('speedycache_pro_metabox', '\SpeedyCache\MetaboxPro::html', 10, 2);
	add_filter('speedycache_metabox_fields', '\SpeedyCache\MetaboxPro::options');
}PK��f\��Mn+n+object-cache-lib.phpnu�[���<?php

if(!defined( 'WPINC' )){
	die();
}

/**
 * Object Cache API
 *
 * @link https://developer.wordpress.org/reference/classes/wp_object_cache/
 *
 * @package WordPress
 * @subpackage Cache
 */

/** WP_Object_Cache class */
require_once $plugin_dir . '/main/objectcache.php';


function wp_cache_init() {
	$GLOBALS['wp_object_cache'] = WP_Object_Cache::get_instance();
}

function wp_cache_add( $key, $data, $group = '', $expire = 0 ) {
	global $wp_object_cache;

	return $wp_object_cache->add( $key, $data, $group, (int) $expire );
}

function wp_cache_add_multiple( array $data, $group = '', $expire = 0 ) {
	global $wp_object_cache;

	return $wp_object_cache->add_multiple( $data, $group, $expire );
}

function wp_cache_replace( $key, $data, $group = '', $expire = 0 ) {
	global $wp_object_cache;

	return $wp_object_cache->replace( $key, $data, $group, (int) $expire );
}

function wp_cache_set( $key, $data, $group = '', $expire = 0 ) {
	global $wp_object_cache;

	return $wp_object_cache->set( $key, $data, $group, (int) $expire );
}

function wp_cache_set_multiple( array $data, $group = '', $expire = 0 ) {
	global $wp_object_cache;

	return $wp_object_cache->set_multiple( $data, $group, $expire );
}

function wp_cache_get( $key, $group = '', $force = false, &$found = null ) {
	global $wp_object_cache;

	return $wp_object_cache->get( $key, $group, $force, $found );
}

function wp_cache_get_multiple( $keys, $group = '', $force = false ) {
	global $wp_object_cache;

	return $wp_object_cache->get_multiple( $keys, $group, $force );
}

function wp_cache_delete( $key, $group = '' ) {
	global $wp_object_cache;

	return $wp_object_cache->delete( $key, $group );
}

function wp_cache_delete_multiple( array $keys, $group = '' ) {
	global $wp_object_cache;

	return $wp_object_cache->delete_multiple( $keys, $group );
}

function wp_cache_incr( $key, $offset = 1, $group = '' ) {
	global $wp_object_cache;

	return $wp_object_cache->incr( $key, $offset, $group );
}

function wp_cache_decr( $key, $offset = 1, $group = '' ) {
	global $wp_object_cache;

	return $wp_object_cache->decr( $key, $offset, $group );
}


function wp_cache_flush() {
	global $wp_object_cache;

	return $wp_object_cache->flush();
}

function wp_cache_flush_runtime() {
	return wp_cache_flush();
}

function wp_cache_flush_group( $group ) {
	global $wp_object_cache;

	return $wp_object_cache->flush_group( $group );
}

function wp_cache_supports( $feature ) {
	switch ( $feature ) {
		case 'add_multiple':
		case 'set_multiple':
		case 'get_multiple':
		case 'delete_multiple':
		case 'flush_runtime':
		case 'flush_group':
			return true;

		default:
			return false;
	}
}


function wp_cache_close() {
	return true;
}


function wp_cache_add_global_groups( $groups ) {
	global $wp_object_cache;

	$wp_object_cache->add_global_groups( $groups );
}


function wp_cache_add_non_persistent_groups( $groups ) {
	// Default cache doesn't persist so nothing to do here.
}

function wp_cache_switch_to_blog( $blog_id ) {
	global $wp_object_cache;

	$wp_object_cache->switch_to_blog( $blog_id );
}

function wp_cache_reset() {
	_deprecated_function( __FUNCTION__, '3.5.0', 'wp_cache_switch_to_blog()' );

	global $wp_object_cache;

	$wp_object_cache->reset();
}


#[AllowDynamicProperties]
class WP_Object_Cache {

	private $cache = array();
	public $cache_hits = 0;
	public $cache_misses = 0;
	protected $global_groups = array();
	private $blog_prefix;
	private $multisite;
	public $object_cache;
	static $instance;

	public function __construct() {
		$this->object_cache = \SpeedyCache\ObjectCache::get_instance();

		$this->multisite = is_multisite();
		$this->blog_prefix = $this->multisite ? get_current_blog_id() . ':' : '';
	}
	
	static function get_instance(){
		if(self::$instance){
			return self::$instance;
		}
		
		self::$instance = new self;
		
		return self::$instance;
	}

	public function __get( $name ) {
		return $this->$name;
	}

	public function __set( $name, $value ) {
		return $this->$name = $value;
	}

	public function __isset( $name ) {
		return isset( $this->$name );
	}

	public function __unset( $name ) {
		unset( $this->$name );
	}

	protected function is_valid_key( $key ) {

		if ( is_int( $key ) ) {
			return true;
		}

		if ( is_string( $key ) && trim( $key ) !== '' ) {
			return true;
		}

		$type = gettype( $key );

		if ( ! function_exists( '__' ) ) {
			wp_load_translations_early();
		}

		$message = is_string( $key )
			? __( 'Cache key must not be an empty string.' )
			/* translators: %s: The type of the given cache key. */
			: sprintf( __( 'Cache key must be integer or non-empty string, %s given.' ), $type );

		_doing_it_wrong(
			sprintf( '%s::%s', __CLASS__, debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 2 )[1]['function'] ),
			$message,
			'6.1.0'
		);

		return false;
	}

	protected function _exists( $key, $group ) {
		if(!$id = $this->id($key, $group)){
			return false;
		}
		
		return isset($this->cache[$group][$id]);
	}

	public function add( $key, $data, $group = 'default', $expire = 0 ) {
		if(wp_suspend_cache_addition()){
			return false;
		}

		if(! $this->is_valid_key($key)){
			return false;
		}

		if($this->_exists($key, $group)){
			return false;
		}

		return $this->set($key, $data, $group, (int) $expire);
	}

	public function add_multiple( array $data, $group = '', $expire = 0 ) {
		$values = array();

		foreach ( $data as $key => $value ) {
			$values[ $key ] = $this->add( $key, $value, $group, $expire );
		}

		return $values;
	}

	public function replace( $key, $data, $group = 'default', $expire = 0 ) {
		if ( ! $this->is_valid_key( $key ) ) {
			return false;
		}
		
		if(!$id = $this->id($key, $group)){
			return false;
		}

		if (!$this->_exists($key, $group)){
			if(!$this->object_cache::exists($id)){
				return false;
			}
		}

		return $this->set( $key, $data, $group, (int) $expire );
	}

	public function set( $key, $data, $group = 'default', $expire = 0 ) {
		if(! $this->is_valid_key($key)){
			return false;
		}

		if(is_object($data)){
			$data = clone $data;
		}

		if(!$id = $this->id($key, $group)){
			return false;
		}

		if(!in_array($group, $this->object_cache::$non_cache_group)){
			$this->object_cache::set($id, $data, (int) $expire);
		}

		$this->cache[$group][$id] = $data;

		return true;
	}

	public function set_multiple( array $data, $group = '', $expire = 0 ) {
		$values = array();

		foreach ( $data as $key => $value ) {
			$values[ $key ] = $this->set( $key, $value, $group, $expire );
		}

		return $values;
	}

	public function get( $key, $group = 'default', $force = false, &$found = null ) {
		if ( ! $this->is_valid_key( $key ) ) {
			return false;
		}
		
		if(!$id = $this->id($key, $group)){
			$found = false;
			$this->cache_misses += 1;
			return false;
		}
		
		// In memory cache
		if($this->_exists($key, $group)){
			$found = true;
			$this->cache_hits += 1;
			return $this->cache[$group][$id];
		}

		// Non Cache Group check.
		if(empty($this->object_cache) || in_array($group, $this->object_cache::$non_cache_group)){
			$found = false;
			$this->cache_misses += 1;
			return false;
		}
		
		// Fetch cache from redis.
		if($cache = $this->object_cache::get($id)){
			$found = true;
			$this->cache_hits += 1;
			
			if(is_serialized($cache)){
				$cache = maybe_unserialize($cache);
			}

			$this->cache[$group][$id] = $cache;
			return $this->cache[$group][$id];
		}

		$found = false;
		$this->cache_misses += 1;
		return false;
	}

	public function get_multiple($keys, $group = 'default', $force = false) {
		$values = array();

		foreach($keys as $key){
			$values[$key] = $this->get($key, $group, $force);
		}

		return $values;
	}

	public function delete($key, $group = 'default', $deprecated = false) {
		if (! $this->is_valid_key($key)){
			return false;
		}

		if(!$id = $this->id($key, $group)){
			return false;
		}

		if(empty($this->cache[$group]) && empty($this->cache[$group][$id]) && !$this->object_cache::exists($id)) {
			return false;
		}

		unset($this->cache[$group][$id]);
		$this->object_cache::delete($id);
		return true;
	}

	public function delete_multiple(array $keys, $group = ''){
		$values = array();

		foreach($keys as $key){
			$values[$key] = $this->delete($key, $group);
		}

		return $values;
	}

	public function incr($key, $offset = 1, $group = 'default'){
		return $this->incr_desr($key, $offset = 1, $group, true);
	}

	public function decr($key, $offset = 1, $group = 'default'){
		return $this->incr_desr($key, $offset = 1, $group, false);
	}
	
	public function incr_desr($key, $offset = 1, $group = 'default', $incr = true){
		if (! $this->is_valid_key($key)){
			return false;
		}

		$cache_val = $this->get($key, $group);

		if(false === $cache_val){
			return false;
		}

		if(! is_numeric( $cache_val)){
			$cache_val = 0;
		}

		$offset = (int) $offset;

		if($incr){
			$cache_val += $offset;
		}
		else {
			$cache_val -= $offset;
		}

		if ( $cache_val < 0 ) {
			$cache_val = 0;
		}

		$this->set($key, $cache_val, $group);

		return $cache_val;
	}

	public function flush() {
		$this->cache = array();

		if(!empty($this->object_cache)){
			$this->object_cache::flush_db();
		}

		return true;
	}

	public function flush_group($group) {
		unset($this->cache[$group]);

		return true;
	}

	public function add_global_groups($groups){
		$groups = (array) $groups;

		$groups = array_fill_keys($groups, true);
		$this->global_groups = array_merge($this->global_groups, $groups);
	}
	
	public function is_global($group){
		return in_array($group, $this->global_groups);
	}

	public function switch_to_blog($blog_id){
		$blog_id = (int) $blog_id;
		$this->blog_prefix = $this->multisite ? $blog_id . ':' : '';
	}

	public function reset(){
		_deprecated_function(__FUNCTION__, '3.5.0', 'WP_Object_Cache::switch_to_blog()');

		// Clear out non-global caches since the blog ID has changed.
		foreach(array_keys($this->cache) as $group){
			if(! isset( $this->global_groups[$group])){
				unset($this->cache[$group]);
			}
		}
	}

	public function stats() {
		echo '<p>';
		echo "<strong>Cache Hits:</strong> {$this->cache_hits}<br />";
		echo "<strong>Cache Misses:</strong> {$this->cache_misses}<br />";
		echo '</p>';
		echo '<ul>';
		foreach($this->cache as $group => $cache){
			echo '<li><strong>Group:</strong> ' . esc_html($group) . ' - ( ' . number_format(strlen(serialize($cache)) / KB_IN_BYTES, 2 ) . 'k )</li>';
		}
		echo '</ul>';
	}
	
	public function id($key, $group){
		$prefix = $this->is_global($group) ? '' : $this->blog_prefix;
		
		if(empty($group)){
			$group = 'default';
		}

		return  $prefix . $group . '.' . $key;
	}
}PK��f\<1D��logs.phpnu�[���<?php

/*
* SPEEDYCACHE
* https://speedycache.com/
* (c) SpeedyCache Team
*/

namespace SpeedyCache;

if( !defined('SPEEDYCACHE_PRO_VERSION') ){
	die('HACKING ATTEMPT!');
}

class Logs{

	static function log($type){
		global $speedycache;
		
		$speedycache->logs = array();
		$speedycache->logs['type'] = $type;
		$speedycache->logs['name'] = '';
		$speedycache->logs['limit'] = 0;
		$speedycache->logs['logs'] = array();
		
		if($speedycache->logs['type'] == 'delete'){
			$speedycache->logs['name'] = 'speedycache_delete_cache_logs';
			$speedycache->logs['limit'] = 25;
		}
		
		self::set_logs();
	}

	static function update_db(){
		global $speedycache;
		
		if(get_option($speedycache->logs['name'])){
			update_option($speedycache->logs['name'], $speedycache->logs['logs'], false);
		}else{
			update_option($speedycache->logs['name'], $speedycache->logs['logs'], false);
		}
	}

	static function set_logs(){
		global $speedycache;

		if($log = get_option($speedycache->logs['name'])){
			$speedycache->logs['logs'] = $log;
		}
	}

	// To detect which static function called delete_cache()
	static function decode_via($data){

		$return_res = '';
		
		switch($data['function']){
			case 'all_cache':
				$return_res = '- All cache files deleted from Manage Cache';
				break;

			case 'delete_single':
				$return_res = '- Cache of a page got deleted';
				break;
				
			case 'gravatar':
				$return_res = '- Gravatar cache deleted';
				break;
				
			case 'minified':
				$return_res = '- Minified and combined assets deleted';
				break;

			case 'cache':
			
				if(empty($data['args'][0])){
					$return_res = '- Cache of a page got deleted';
					break;
				}
			
				$return_res = '- Cache of a page #ID:'.$data['args'][0].' got deleted';
				break;
				
			case 'purge_varnish':
				$return_res = '- Varnish Cache got Purged Successfully';
				break;
			
			case 'on_status_transitions':
			case 'on_status_change':
				if(empty($data['args'])){
					$return_res = '- Cache of one page has been purged on page status transition';
					break;
				}

				$type = $data['args'][2]->post_type;
			
				if($data['args'][0] == 'publish' && $data['args'][1] == 'publish'){
					$return_res = '- The '.$type.' has been updated- #ID:'.$data['args'][2]->ID.' - One cached file has been removed';
				}else if($data['args'][0] == 'publish' && $data['args'][1] != 'publish'){
					$return_res = '- New '.$type.' has been published - '.$type.' ID:'.$data['args'][2]->ID;
				}else {
					$return_res = '- The '.$type.' status has been changed. - '.$data['args'][1].' > '.$data['args'][0].' #ID:'.$data['args'][2]->ID;
				}
				
				break;
			
			case 'wp_set_comment_status':
			case 'on_comment_status':
				if(empty($data['args'])){
					$return_res = '- Post cache deleted becuase of comment status change';
					break;
				}
			
					
				if(isset($data['args'][2]->comment_ID)){
					$return_res = '- Comment(ID: '.$data['args'][2]->comment_ID.') has been marked as '.$data['args'][1].' - One cached file has been removed';
				}else{
					$return_res = '- Comment has been marked as '.$data['args'][1].' - Comment ID: '.$data['args'][0].' - One cached file has been removed';
				}
				
				break;
		}
		
		if(!empty($return_res)){
			return $return_res;
		}

		return $data['function'];
	}

	static function get_via(){
		$arr = array();
		$via = debug_backtrace();
		
		// TODO: Need to remove unwanted code from this
		if(isset($via[8]) && ($via[8]['function'] == 'wp_set_comment_status') && ($via[2]['function'] == 'home_page_cache') && ($via[3]['function'] == 'speedycache_single_delete_cache')){
			return false;
		}
		
		if($via[3]['function'] == 'speedycache_delete_home_page_cache'){
			return false;
		}

		if($via[4]['function'] == 'clear_cache_after_woocommerce_checkout_order_processed'){
			$arr['args'] = array();
			$arr['function'] = $via[4]['function'];

			$order = wc_get_order($via[4]['args'][0]);

			if($order){
				foreach($order->get_items() as $item_key => $item_values ){
					array_push($arr['args'], $item_values->get_product_id());
				}
			}
		}elseif($via[4]['function'] === 'speedycache_set_schedule'){
			$arr['function'] = $via[4]['function'];
			$arr['args'] = $via[4]['args'];
		}elseif($via[2]['function'] == 'varnish'){
			$arr['function'] = $via[2]['function'];
		}else if($via[3]['function'] == 'on_status_transitions' || $via[3]['function'] == 'speedycache_single_delete_cache'){
			$arr['args'] = $via[3]['args'];
			$arr['function'] = $via[3]['function'];
		}
		else if($via[3]['function'] == 'on_comment_status' || $via[3]['function'] == 'on_status_change'){
			$arr['args'] = $via[3]['args'];
			$arr['function'] = $via[3]['function'];
		}else if($via[4]['function'] == 'speedycache_delete_css_and_js_cache_toolbar' || $via[4]['function'] == 'speedycache_delete_cache_toolbar'){
			$arr['function'] = $via[4]['function'];
		}else if(isset($via[7]) && ($via[7]['function'] == 'wp_set_comment_status')){
			$arr['args'] = $via[7]['args'];
			$arr['function'] = $via[7]['function'];
		}else if(isset($via[6]) && ($via[3]['function'] == 'apply_filters' && $via[6]['function'] == 'speedycache_clear_all_cache')){
			$arr['file'] = $via[6]['file'];
			$arr['function'] = $via[6]['function'];
		}else if(in_array($via[2]['function'], ['all_cache', 'gravatar', 'minified', 'purge_varnish'])){
			$arr['function'] = $via[2]['function'];
		}else if($via[2]['function'] == 'cache'){
			$arr['function'] = $via[2]['function'];
			$arr['args'] = $via[2]['args'];
		}else{
			$arr['function'] = $via[3]['function'];

			if(isset($via[3]['file']) && $via[3]['file']){
				if(preg_match("/\/plugins\/([^\/]+)\//", $via[3]['file'], $plugin_name)){
					$arr['function'] = $arr['function'].' ('.$plugin_name[1].')';
				}
			}
		}

		return $arr;
	}

	static function action($from = ''){
		global $speedycache;
		
		if($speedycache->logs['type'] == 'delete'){
			$log = [];
			$log['date'] = date('d-m-Y @ H:i:s', current_time('timestamp'));
			
			if($from && $from['prefix'] != 'all'){
				$log['via'] = [];
				$log['via']['function'] = '- Cache Timeout / '.$from['prefix'].' '.$from['content'];
			}else{
				$log['via'] = self::get_via();
			}
		}
		
		if($log && $log['via'] !== false){
			
			if(!in_array($log, $speedycache->logs['logs'])){
				array_unshift($speedycache->logs['logs'], $log);

				if($speedycache->logs['limit'] < count($speedycache->logs['logs'])){
					array_pop($speedycache->logs['logs']);
				}

				self::update_db();
			}
		}
	}

	static function print_logs(){
		global $speedycache;

		?>
		<div id="speedycache-delete-logs">
			<div class="speedycache-block">
				<div class="speedycache-block-title">
					<h2>Delete Cache Logs</h2>
				</div>

				<table class="speedycache-log-table">
					<thead>
						<tr>
							<th scope="col">Date</th>
							<th scope="col">Via</th>
						</tr>
					</thead>
					<tbody>
						<?php if($speedycache->logs['logs'] && count($speedycache->logs['logs']) > 0){ ?>
							<?php foreach($speedycache->logs['logs'] as $key => $log){ ?>
								<tr>
									<td scope="row"><?php echo isset($log['date']) ? esc_html($log['date']) : '';?></td>
									<td style="border-right:1px solid #DEDBD1;"><?php echo isset($log['via']) ? esc_html(self::decode_via($log['via'])) : ''; ?></td>
								</tr>
							<?php } ?>
						<?php }else{ ?>
								<tr>
									<td style="border-left:1px solid #DEDBD1;" scope="row"><label>No Log</label></td>
									<td style="border-right:1px solid #DEDBD1;"></td>
								</tr>
						<?php } ?>
					</tbody>
				</table>
			</div>
		</div>
		<?php
	}

}

PK��f\���Fn�n�settingspage.phpnu�[���<?php

namespace SpeedyCache;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class SettingsPage{
	
	static function license_tab(){
		global $speedycache;
		
		echo '<div class="speedycache-tab" id="speedycache-license">
			<h2><img src="'.SPEEDYCACHE_URL.'/assets/images/icons/license.svg" height="32" width="32"/> License</h2>
			<table class="wp-list-table fixed striped users speedycache-license-table" cellspacing="1" border="0" width="78%" cellpadding="10" align="center">
				<tbody>
					<tr>				
						<th align="left" width="25%">'.esc_html__('SpeedyCache Version', 'speedycache').'</th>
						<td>'.SPEEDYCACHE_PRO_VERSION.(defined('SPEEDYCACHE_PRO') ? ' (Pro Version)' : '').'</td>
					</tr>
					<tr>			
						<th align="left" valign="top">'.esc_html__('SpeedyCache License', 'speedycache').'</th>
						<td align="left">
							<form method="post" action="">
								<span style="color:var(--speedycache-red)">
									'.(defined('SPEEDYCACHE_PRO') && empty($speedycache->license) ? '<span style="color:var(--speedycache-red)">Unlicensed</span> &nbsp; &nbsp;' : '').'
								</span>
								<input type="hidden" name="security" value="'.wp_create_nonce('speedycache_license').'"/>
								<input type="hidden" name="action" value="speedycache_verify_license"/>
								<input type="text" name="license" value="'.(empty($speedycache->license) ? empty($_POST['license']) ? '' : \SpeedyCache\Util::sanitize_post('speedycache_license') : $speedycache->license['license']).'" size="30" placeholder="e.g. SPDFY-11111-22222-33333-44444" style="width:300px;">
								<button class="speedycache-button speedycache-btn-black" id="speedycache-license-btn" type="submit">Update License<span class="speedycache-spinner"><span></button>
							</form>';
							if(!empty($speedycache->license)){
								$expires = $speedycache->license['expires'];
								$expires = substr($expires, 0, 4).'/'.substr($expires, 4, 2).'/'.substr($expires, 6);
								
								echo '<div style="margin-top:10px;">License Status : '.(empty($speedycache->license['status_txt']) ? 'N.A.' : wp_kses_post($speedycache->license['status_txt'])).' &nbsp; &nbsp; &nbsp;';
								
								if(empty($speedycache->license['has_plid']) || $speedycache->license['expires'] <= date('Ymd')){
									echo 'License Expires : '.($speedycache->license['expires'] <= date('Ymd') ? '<span style="color:var(--speedycache-red)">'.esc_attr($expires).'</span>' : esc_attr($expires));
								}
								echo '</div>';
							}
						echo '</td>
					</tr>
					<tr>
						<th align="left">URL</th>
						<td>'.get_site_url().'</td>
					</tr>
					<tr>				
						<th align="left">Path</th>
						<td>'.ABSPATH.'</td>
					</tr>
					<tr>				
						<th align="left">Server\'s IP Address</th>
						<td>'.esc_html($_SERVER['SERVER_ADDR']).'</td>
					</tr>
					<tr>				
						<th align="left">.htaccess is writable</th>
						<td>'.(is_writable(ABSPATH.'/.htaccess') ? '<span style="color:var(--speedycache-red)">Yes</span>' : '<span style="color:green">No</span>').'</td>
					</tr>		
				</tbody>
			</table>
		</div>';
	}
	
	// Earlier we use to just log deletion, but now we will log other stuff too.
	static function logs(){
		global $speedycache;
		
		$speedycache->logs['logs'] = get_option('speedycache_delete_cache_logs', []);

		echo '<div class="speedycache-logs">
			<div class="speedycache-logs-header">SpeedyCache Logs</div>
			<div class="speedycache-logs-content">';
			if(!empty($speedycache->logs['logs']) && count($speedycache->logs['logs']) > 0){
				foreach($speedycache->logs['logs'] as $key => $log){
					echo '<div class="speedycache-logs-row">'.(isset($log['date']) ? esc_html($log['date']) : '') . (isset($log['via']) ? esc_html(\SpeedyCache\Logs::decode_via($log['via'])) : '').'</div>';
				}
			}else{
				echo '<div class="speedycache-logs-row">'. esc_html__('No logs found', 'speedycache'). '</div>';
			}

			echo '</div>
		</div>';
	}
	
	static function stats(){
		global $speedycache;
		
		if(!class_exists('\SpeedyCache\Util')){
			return;
		}

		// CACHE SIZE
		$cache_stats = get_option('speedycache_html_size', 0);

		if(empty($cache_stats)){
			$desktop_cache = \SpeedyCache\Util::cache_path('all');
			$cache_stats = 0;

			if(file_exists($desktop_cache)){
				$cache_stats = \SpeedyCache\Util::dir_size($desktop_cache);
			}
			
			$mobile_cache = \SpeedyCache\Util::cache_path('mobile-cache');

			if(file_exists($mobile_cache)){
				$cache_stats += \SpeedyCache\Util::dir_size($mobile_cache);
			}
			
			update_option('speedycache_html_size', $cache_stats);
		}
		
		// MINIFIED SIZE
		$assets_stats = get_option('speedycache_assets_size', 0);

		if(empty($assets_stats)){
			$assets_dir = \SpeedyCache\Util::cache_path('assets');
			$assets_stats = 0;

			if(file_exists($assets_dir)){
				$assets_stats = \SpeedyCache\Util::dir_size($assets_dir);
			}
			
			update_option('speedycache_assets_size', $assets_stats);
		}
		
		$img_count = 0;
		if(class_exists('\SpeedyCache\Image')){
			$img_count = \SpeedyCache\Image::optimized_file_count();
		}

		echo '<div class="speedycache-admin-row">
			<div class="speedycache-stats-block speedycache-is-block">
				<div class="speedycache-stats-name">Cache Stats</div>
				<div class="speedycache-stats-number">'.esc_html(size_format($cache_stats)).'</div>
				<div class="speedycache-stat-status"><span class="speedycache-stat-status-indicator" '.(!empty($speedycache->options['status'])? 'style="background-color:#0c6;"' : '').'></span><span>Enabled</span></div>
			</div>
			<div class="speedycache-stats-block speedycache-is-block">
				<div class="speedycache-stats-name">Assets Stats</div>
				<div class="speedycache-stats-number">'.esc_html(size_format($assets_stats)).'</div>
			</div>
			<div class="speedycache-stats-block speedycache-is-block">
				<div class="speedycache-stats-name">Object Cache Stats</div>
				<div class="speedycache-stats-number">'.esc_html($speedycache->object_memory).'</div>
				<div class="speedycache-stat-status"><span class="speedycache-stat-status-indicator" '.(!empty($speedycache->object['enable'])? 'style="background-color:#0c6;"' : '').'></span><span>Enabled</span></div>
			</div>
			<div class="speedycache-stats-block speedycache-is-block">
				<div class="speedycache-stats-name">Image Stats</div>
				<div class="speedycache-stats-number">'.esc_html($img_count).' IMG</div>
			</div>
		</div>';
	}
	
	static function image_optm(){
		echo '<h2><img src="'.SPEEDYCACHE_URL.'/assets/images/icons/image.svg" height="32" width="32"/> Image Optimization</h2>';
		
		\SpeedyCache\Image::statics();
		\SpeedyCache\Image::settings();
		\SpeedyCache\Image::list_image_html();
	}
	
	static function bloat_tab(){
		global $speedycache;
		
		echo '<h2><img src="'.SPEEDYCACHE_URL.'/assets/images/icons/broom.svg" height="32" width="32"/> Bloat Remover</h2>
		<form method="post">
		<input type="hidden" name="action" value="speedycache_save_bloat_settings"/>';
		wp_nonce_field('speedycache_ajax_nonce');

		if(!defined('SPEEDYCACHE_PRO')){
			return;
		}
		
		$bloat_options = array(
			'disable_xmlrpc' => array(
				'id' => 'speedycache_disable_xmlrpc',
				'title' => __('Disable XML RPC', 'speedycache'),
				'description' => __('XML-RPC can cause performance and security issues'),
			),
			'remove_gfonts' => array(
				'id' => 'speedycache_remove_gfonts',
				'title' => __('Disable Google Fonts', 'speedycache'),
				'description' => __('Use users system fonts to prevent loading of fonts from server', 'speedycache'),
			),
			'disable_jmigrate' => array(
				'id' => 'speedycache_disable_jmigrate',
				'title' => __('Disable jQuery Migrate', 'speedycache'),
				'description' => __('Disable jQuery Migrate for better speed.', 'speedycache'),
				'docs' => 'https://speedycache.com/docs/bloat-remover/how-to-remove-jquery-migrate-in-wordpress/',
			),
			'disable_dashicons' => array(
				'id' => 'speedycache_disable_dashicons',
				'title' => __('Disable DashIcons', 'speedycache'),
				'description' => __('DashIcons are used on WordPress admin and might not be used on Front End.', 'speedycache'),
			),
			'disable_gutenberg' => array(
				'id' => 'speedycache_disable_gutenberg',
				'title' => __('Disable Gutenberg', 'speedycache'),
				'description' => __('Decouple Gutenberg if you use another page builder.', 'speedycache'),
			),
			'disable_block_css' => array(
				'id' => 'speedycache_disable_block_css',
				'title' => __('Disable Block Editor CSS', 'speedycache'),
				'description' => __('Some themes might not use Block Editor CSS on the front.', 'speedycache'),
			),
			'disable_oembeds' => array(
				'id' => 'speedycache_disable_oembeds',
				'title' => __('Disable OEmbeds', 'speedycache'),
				'description' => __('OEmbeds increases load on site if a lot of embeds are being used.', 'speedycache'),
			),
			'update_heartbeat' => array(
				'id' => 'speedycache_update_heartbeat',
				'title' => __('Update Heartbeat', 'speedycache'),
				'description' => __('Change how frequently heartbeat is checked.', 'speedycache'),
				'settings' => 'speedycache_update_heartbeat',
			),
			'limit_post_revision' => array(
				'id' => 'speedycache_limit_post_revision',
				'title' => __('Limit Post Revision', 'speedycache'),
				'description' => __('Change how many post revision you want to keep.', 'speedycache'),
				'settings' => 'speedycache_limit_post_revision',
			),
			'disable_cart_fragment' => array(
				'id' => 'speedycache_disable_cart_fragment',
				'title' => __('Disable Cart Fragments', 'speedycache'),
				'description' => __('Disable WooCommerce cart fragments for better performance.', 'speedycache'),
			),
			'disable_woo_assets' => array(
				'id' => 'speedycache_disable_woo_assets',
				'title' => __('Disable WooCommerce Assets', 'speedycache'),
				'description' => __('Disables WooCommerce assets to reduce unwanted asset loading.', 'speedycache'),
				'docs' => 'https://speedycache.com/docs/bloat-remover/how-to-remove-woocommerce-assets/',
			),
			'disable_rss' => array(
				'id' => 'speedycache_disable_rss',
				'title' => __('Disable RSS feeds', 'speedycache'),
				'description' => __('Disable RSS feeds to reduce request which use server resources.', 'speedycache'),
			),
		);
		
		foreach($bloat_options as $bloat_key => $bloat_option){
			echo '<div class="speedycache-option-wrap">
			<label for="'.esc_attr($bloat_option['id']).'" class="speedycache-custom-checkbox">
				<input type="checkbox" id="'.esc_attr($bloat_option['id']).'" name="'.esc_attr($bloat_key).'" '. (!empty($speedycache->bloat[$bloat_key]) ? ' checked' : '').'/>
				<div class="speedycache-input-slider"></div>
			</label>
			<div class="speedycache-option-info">
				<span class="speedycache-option-name"><span>'.esc_html($bloat_option['title']). '</span>';
				
				// Docs Link here
				if(isset($bloat_option['docs'])){
					echo '<a href="'.esc_url($bloat_option['docs']).'" target="_blank"><span class="dashicons dashicons-info" style="font-size:14px"></span></a>';
				}
				
				// Setting if any
				if(isset($bloat_option['settings'])){
				echo '<span class="speedycache-modal-settings-link" setting-id="'.esc_attr($bloat_option['settings']).'" style="display:'. (!empty($speedycache->bloat[$bloat_key]) ? 'inline-block' : 'none').';">- '.esc_html__('Settings', 'speedycache').'</span>';
				}
				echo '</span>
				<span class="speedycache-option-desc">'. esc_html($bloat_option['description']).'</span> 
			</div>
		</div>';
		}
		
		// Bloat modals
		echo '<div modal-id="speedycache_limit_post_revision" class="speedycache-modal">
			<div class="speedycache-modal-wrap">
				<div class="speedycache-modal-header">
					<div>'.esc_html__('Limit Post Revision', 'speedycache').'</div>
					<div title="Close Modal" class="speedycache-close-modal">
						<span class="dashicons dashicons-no"></span>
					</div>
				</div>
				<div class="speedycache-modal-content">
					<label for="speedycache_post_revision_count">'.esc_html__('Select Post Revision Count', 'speedycache').'</label>
					<select id="speedycache_post_revision_count" name="post_revision_count" value="'.(!empty($speedycache->bloat['post_revision_count']) ? esc_attr($speedycache->bloat['post_revision_count']) : '').'">';
						$post_revision_opts = array(
							'disable' => esc_html__('Disable', 'speedycache'),
							'1' => '1',
							'2' => '2',
							'3' => '3',
							'4' => '4',
							'5' => '5',
							'10' => '10',
							'20' => '20',
						);
						
						foreach($post_revision_opts as $value => $post_revision_opt){
							$selected = '';
							
							if(!empty($speedycache->bloat['post_revision_count']) && $speedycache->bloat['post_revision_count'] == $value){
								$selected = 'selected';
							} elseif(empty($speedycache->bloat['post_revision_count']) && $value == '10'){
								$selected = 'selected';
							}

							echo '<option value="'.esc_attr($value).'" '.esc_attr($selected).'>'.esc_html($post_revision_opt).'</option>';
						}
					echo '</select>
	
				</div>
				<div class="speedycache-modal-footer">
					<button type="button" action="close">
						<span>'.esc_html__('Submit', 'speedycache').'</span>
					</button>
				</div>
			</div>
		</div>
		
		<!-- Modal Settings for heartbeat of WordPress -->
		<div modal-id="speedycache_update_heartbeat" class="speedycache-modal">
			<div class="speedycache-modal-wrap">
				<div class="speedycache-modal-header">
					<div>'.esc_html__('Update HeartBeat', 'speedycache').'</div>
					<div title="Close Modal" class="speedycache-close-modal">
						<span class="dashicons dashicons-no"></span>
					</div>
				</div>
				<div class="speedycache-modal-content">';
					$heartbeat_modes = array(
						'15' => esc_html__('15 Seconds(Default)', 'speedycache'),
						'30' => esc_html__('30 seconds', 'speedycache'),
						'45' => esc_html__('45 Seconds', 'speedycache'),
						'60' => esc_html__('60 seconds', 'speedycache'),
						'120' => esc_html__('2 Minutes', 'speedycache'),
					);
					
					$disable_heartbeat = array(
						'dont' => esc_html__('Do not Disable', 'speedycache'),
						'disable' => esc_html__('Disable', 'speedycache'),
						'editor' => esc_html__('Allow on Editor only', 'speedycache'),
					);

					echo '<table>
					
					<tr>
					<td style="text-align:left;">
					<label for="speedycache_heartbeat_backend">'.esc_html__('Heartbeat Frequency', 'speedycache').'</label></td>
					<td><select id="speedycache_heartbeat_frequency" name="heartbeat_frequency" value="'.(!empty($speedycache->bloat['heartbeat_frequency']) ? esc_attr($speedycache->bloat['heartbeat_frequency']) : '').'">';
						foreach($heartbeat_modes as $value => $heartbeat_mode){
							$selected = '';
							
							if(!empty($speedycache->bloat['heartbeat_frequency']) && $speedycache->bloat['heartbeat_frequency'] == $value){
								$selected = 'selected';
							} elseif(empty($speedycache->bloat['heartbeat_frequency']) && $value == '120'){
								$selected = 'selected';
							}

							echo '<option value="'.esc_attr($value).'" '.esc_attr($selected).'>'.esc_html($heartbeat_mode).'</option>';
						}
					echo '</select></td></tr>';

					echo '<tr><td style="text-align:left;"><label for="speedycache_disable_heartbeat">'.esc_html__('Disable Heartbeat', 'speedycache').'</label></td>
					<td><select id="speedycache_disable_heartbeat" name="disable_heartbeat" value="'.(!empty($speedycache->bloat['disable_heartbeat']) ? esc_attr($speedycache->bloat['disable_heartbeat']) : '').'">';
						foreach($disable_heartbeat as $value => $disable_mode){
							$selected = '';
							
							if(!empty($speedycache->bloat['disable_heartbeat']) && $speedycache->bloat['disable_heartbeat'] == $value){
								$selected = 'selected';
							} elseif(empty($speedycache->bloat['disable_heartbeat']) && $value == 'dont'){
								$selected = 'selected';
							}

							echo '<option value="'.esc_attr($value).'" '.esc_attr($selected).'>'.esc_html($disable_mode).'</option>';
						}
					echo '</select></td></tr></table>';

				echo '</div>
				<div class="speedycache-modal-footer">
					<button type="button" action="close">
						<span>'.esc_html__('Submit', 'speedycache').'</span>
					</button>
				</div>
			</div>
		</div>';
		\SpeedyCache\Settings::save_btn();
		echo '</form>';
	}
	
	static function db_tab(){
		global $wpdb;
		
		echo '<h2><img src="'.SPEEDYCACHE_URL.'/assets/images/icons/db.svg" height="32" width="32"/> Database Optimizer</h2>';
		
		// TODO: Show notice which mentions about the bloat settings as we will slowly migrate the html code of bloat to the Pro version, to prevent the GPL plugin providers from making users fool.
		if(!defined('SPEEDYCACHE_PRO')){
			return;
		}
		
		$statics = array('all_warnings' => 0, 'post_revisions' => 0, 'trashed_contents' => 0, 'trashed_spam_comments' => 0, 'trackback_pingback' => 0, 'transient_options' => 0, 'expired_transient' => 0);
	
		$statics['post_revisions'] = $wpdb->get_var("SELECT COUNT(*) FROM `$wpdb->posts` WHERE post_type = 'revision';");

		$statics['trashed_contents'] = $wpdb->get_var("SELECT COUNT(*) FROM `$wpdb->posts` WHERE post_status = 'trash';");

		$statics['trashed_spam_comments'] = $wpdb->get_var("SELECT COUNT(*) FROM `$wpdb->comments` WHERE comment_approved = 'spam' OR comment_approved = 'trash' ;");

		$statics['trackback_pingback'] = $wpdb->get_var("SELECT COUNT(*) FROM `$wpdb->comments` WHERE comment_type = 'trackback' OR comment_type = 'pingback' ;");

		$element = "SELECT COUNT(*) FROM `$wpdb->options` WHERE option_name LIKE '%\_transient\_%' ;";
		$statics['transient_options'] = $wpdb->get_var( $element ) > 20 ? $wpdb->get_var( $element ) : 0;	

		$statics['expired_transient'] = $wpdb->get_var( "SELECT COUNT(*) FROM `$wpdb->options` WHERE option_name LIKE '_transient_timeout%' AND option_value < " . time() );

		$statics['all_warnings'] = $statics['all_warnings'] + $statics['transient_options'] + $statics['trackback_pingback']+ $statics['trashed_spam_comments']+ $statics['trashed_contents']+ $statics['post_revisions'];
		
		
		
		echo '<div speedycache-db-name="all_warnings" class="speedycache-db-row">
			<div>
				<div class="speedycache-db-info db">
					<div>'.esc_html__('Clean everything', 'speedycache').' <span class="speedycache-db-number">('.esc_html($statics['all_warnings']).')</span></div>
					<div>'.esc_html__('Run the all options', 'speedycache').'</div>
				</div>
			</div>
			<button class="speedycache-button speedycache-btn-black speedycache-db-optm-btn">'.esc_html__('Run optimization', 'speedycache').'<span class="speedycache-spinner"></span></button>
		</div>

		<div speedycache-db-name="post_revisions" class="speedycache-db-row">
			<div>
				<div class="speedycache-db-info db">
					<div>'.esc_html__('Post Revisions', 'speedycache').' <span class="speedycache-db-number">('.esc_html($statics['post_revisions']).')</span></div>
					<div>'.esc_html__('Clean the all post revisions', 'speedycache').'</div>
				</div>
			</div>
			<button class="speedycache-button speedycache-btn-black speedycache-db-optm-btn">'.esc_html__('Run optimization', 'speedycache').'<span class="speedycache-spinner"></span></button>
		</div>

		<div speedycache-db-name="trashed_contents" class="speedycache-db-row">
			<div>
				<div class="speedycache-db-info db">
					<div>'.esc_html__('Trashed Contents', 'speedycache').'<span class="speedycache-db-number">('.esc_html($statics['trashed_contents']).')</span></div>
					<div>'.esc_html__('Clean the all trashed posts & pages', 'speedycache').'</div>
				</div>
			</div>
			<button class="speedycache-button speedycache-btn-black speedycache-db-optm-btn">'.esc_html__('Run optimization', 'speedycache').'<span class="speedycache-spinner"></span></button>
		</div>

		<div speedycache-db-name="trashed_spam_comments" class="speedycache-db-row">
			<div>
				<div class="speedycache-db-info db">
					<div>'.esc_html__('Trashed & Spam Comments', 'speedycache').' <span class="speedycache-db-number">('.esc_html($statics['trashed_spam_comments']).')</span></div>
					<div>'.esc_html__('Clean the all comments from trash & spam', 'speedycache').'</div>
				</div>
			</div>
			<button class="speedycache-button speedycache-btn-black speedycache-db-optm-btn">'.esc_html__('Run optimization', 'speedycache').'<span class="speedycache-spinner"></span></button>
		</div>

		<div speedycache-db-name="trackback_pingback" class="speedycache-db-row">
			<div>
				<div class="speedycache-db-info db">
					<div>'.esc_html__('Trackbacks and Pingbacks', 'speedycache').' <span class="speedycache-db-number">('.esc_html($statics['trackback_pingback']).')</span></div>
					<div>'.esc_html__('Clean the all trackbacks and pingbacks', 'speedycache').'</div>
				</div>
			</div>
			<button class="speedycache-button speedycache-btn-black speedycache-db-optm-btn">'.esc_html__('Run optimization', 'speedycache').'<span class="speedycache-spinner"></span></button>
		</div>

		<div speedycache-db-name="transient_options" class="speedycache-db-row">
			<div>
				<div class="speedycache-db-info db">
					<div>'.esc_html__('Transient Options', 'speedycache').' <span class="speedycache-db-number">('.esc_html($statics['transient_options']).')</span></div>
					<div>'.esc_html__('Clean the all transient options', 'speedycache').'</div>
				</div>
			</div>
			<button class="speedycache-button speedycache-btn-black speedycache-db-optm-btn">'.esc_html__('Run optimization', 'speedycache').'<span class="speedycache-spinner"></span></button>
		</div>
		<div speedycache-db-name="expired_transient" class="speedycache-db-row">
			<div>
				<div class="speedycache-db-info db">
					<div>'.esc_html__('Expired Transients', 'speedycache').' <span class="speedycache-db-number">('.esc_html($statics['expired_transient']).')</span></div>
					<div>'.esc_html__('Clean the expired transients', 'speedycache').'</div>
				</div>
			</div>
			<button class="speedycache-button speedycache-btn-black speedycache-db-optm-btn">'.esc_html__('Run optimization', 'speedycache').'<span class="speedycache-spinner"></span></button>
		</div>';
	}
	
	static function object_tab(){
		global $speedycache;
	
		echo '<h2><img src="'.SPEEDYCACHE_URL.'/assets/images/icons/object.svg" height="32" width="32"/> '.esc_html__('Object Cache', 'speedycache').'</h2>';

		echo '<div class="speedycache-block">
			<div class="speedycache-admin-row">
				<div class="speedycache-is-block speedycache-object-stat">
					<div style="display:flex; justify-content:space-between;">
						<div><strong>Caching Status:</strong>  '.(!empty($speedycache->object['enable']) ? '<span style="color:green;">Enabled</span>' : '<span style="color:red;">Disabled</span>').'</div>
						<div><strong>Memory Usage:</strong> <span>'.esc_html__($speedycache->object_memory).'</span></div>
					</div>
					<div class="speedycache-drop-in"><strong>Drop In:</strong> '.(defined('SPEEDYCACHE_OBJECT_CACHE') ? '<span style="color:green;">Valid</span>' : '<span style="color:red;">Not Valid</span>').'</div>
					<div><strong>phpRedis Status:</strong> '.(empty(phpversion('redis')) ? '<span style="color:red">' . esc_html__('phpRedis Not Found', 'speedycache') : (version_compare(phpversion('redis'), '3.1.1') > 0 ? '<span style="color:green">'. esc_html__('Available', 'speedycache') . '('.esc_html(phpversion('redis')).')' : '<span style="color:red">' . esc_html__('You are using older version of PHPRedis'))).'</span></div>';
					if(!empty($speedycache->object['hashed_prefix'])){
						echo'<div><strong>Hashed Prefix:</strong> <span>'.esc_html($speedycache->object['hashed_prefix']).'</span></div>';
					}
					echo'<button class="speedycache-button speedycache-btn-black speedycache-flush-db">Flush DB<span class="speedycache-spinner"></span></button>
				</div>
			</div>
			<div class="speedycache-object-charts"></div>
		</div>
		
		<div class="speedycache-block">
			<form method="POST">';
			wp_nonce_field('speedycache_ajax_nonce');
			echo '<input type="hidden" value="speedycache_save_object_settings" name="action">

			<div class="speedycache-block-title">
				<h2>'.esc_html__('Settings', 'speedycache').'</h2>
			</div>
			<table class="wp-list-table speedycache-table" style="width:100%;">
				<tr>
					<th><label for="speedycache_enable_object">'.esc_html__('Enable', 'speedycache').'</label></th>
					<td>
						<label for="speedycache_enable_object" class="speedycache-custom-checkbox">
							<input type="checkbox" id="speedycache_enable_object" name="enable_object" '.((isset($speedycache->object['enable']) && $speedycache->object['enable']) ? ' checked="true"' : '').'/>
							<div class="speedycache-input-slider"></div>
						</label>
						<div class="speedycache-option-desc">'.esc_html__('Enables Object caching, if you have full page caching then it might show some conflicts.', 'speedycache').'</div>
					</td>
				</tr>
				
				<tr style="display:none;">
					<th><label for="speedycache_object_driver">'.esc_html__('Driver', 'speedycache').'</label></th>
					<td>
						<label for="speedycache_object_driver">
							<select name="driver" id="speedycache_object_driver">
								<option value="Redis" selected>Redis</option>
							</select>
						</label>
						<div class="speedycache-option-desc">'.esc_html__('Choose which Object Cache Driver you want to use.', 'speedycache').'</div>
					</td>
				</tr>
				
				<tr>
					<th><label for="speedycache_object_host">'.esc_html__('Host', 'speedycache').'</label></th>
					<td>
						<label for="speedycache_object_host">
							<input type="text" name="host" id="speedycache_object_host" value="'.(!empty($speedycache->object['host']) ? esc_attr($speedycache->object['host']) : 'localhost').'"/>
						</label>
						<div class="speedycache-option-desc">'.esc_html__('Your Redis host name or IP address.', 'speedycache').'</div>
					</td>
				</tr>

				<tr>
					<th><label for="speedycache_object_port">'.esc_html__('Port', 'speedycache').'</label></th>
					<td>
						<label for="speedycache_object_port">
							<input type="text" name="port" id="speedycache_object_port" value="'.(!empty($speedycache->object['port']) ? esc_attr($speedycache->object['port']) : '6379').'"/>
						</label>
						<div class="speedycache-option-desc">'.esc_html__('Your Redis host port number', 'speedycache').'</div>
					</td>
				</tr>
				
				<tr>
					<th><label for="speedycache_object_username">'.esc_html__('Username', 'speedycache').'</label></th>
					<td>
						<label for="speedycache_object_username">
							<input type="password" id="speedycache_object_username" name="username" value="'. ((!empty($speedycache->object['username'])) ? esc_html($speedycache->object['username']) : '').'" />
						</label>
						<div class="speedycache-option-desc">'.esc_html__('Username of your Redis acccount.', 'speedycache').'</div>
					</td>
				</tr>
				
				<tr>
					<th><label for="speedycache_object_password">'.esc_html__('Password', 'speedycache').'</label></th>
					<td>
						<label for="speedycache_object_password">
							<input type="password" id="speedycache_object_password" name="password" value="'.((!empty($speedycache->object['password'])) ? esc_html($speedycache->object['password']) : '').'" />
						</label>
						<div class="speedycache-option-desc">'.esc_html__('Password for your Redis Account.', 'speedycache').'</div>
					</td>
				</tr>
				
				<tr>
					<th><label for="speedycache_object_ttl">'.esc_html__('Object Time to live', 'speedycache').'</label></th>
					<td>
						<label for="speedycache_object_ttl">
							<input type="text" name="ttl" id="speedycache_object_ttl" value="'.(!empty($speedycache->object['ttl']) ? esc_attr($speedycache->object['ttl']) : '360').'"/>
						</label>
						<div class="speedycache-option-desc">'.esc_html__('How long you want the cached Object to persist', 'speedycache').'</div>
					</td>
				</tr>
				
				<tr>
					<th><label for="speedycache_object_db_id">'.esc_html__('Redis DB ID', 'speedycache').'</label></th>
					<td>
						<label for="speedycache_object_db_id">
							<input type="text" name="db-id" id="speedycache_object_db_id" value="'. (!empty($speedycache->object['db-id']) ? esc_attr($speedycache->object['db-id']) : '0').'" style="width:45px;"/>
						</label>
						<div class="speedycache-option-desc">'.esc_html__('Set the database number, make sure to keep it different for every website you use it on', 'speedycache').'</div>
					</td>
				</tr>
				
				<tr>
					<th><label for="speedycache_persistant_object">'.esc_html__('Persistent Connection', 'speedycache').'</label></th>
					<td>
						<label for="speedycache_persistent_object" class="speedycache-custom-checkbox">
							<input type="checkbox" id="speedycache_persistent_object" name="persistent" '. ((!empty($speedycache->object['persistent'])) ? ' checked="true"' : '').'/>
							<div class="speedycache-input-slider"></div>
						</label>
						<div class="speedycache-option-desc">'.esc_html__('This will Keep Alive the connection to redis.', 'speedycache').'</div>
					</td>
				</tr>
				
				<tr>
					<th><label for="speedycache_object_admin">'.esc_html__('Cache WP_Admin', 'speedycache').'</label></th>
					<td>
						<label for="speedycache_object_admin" class="speedycache-custom-checkbox">
							<input type="checkbox" id="speedycache_object_admin" name="admin" '.((!empty($speedycache->object['admin'])) ? ' checked="true"' : '').'/>
							<div class="speedycache-input-slider"></div>
						</label>
						<div class="speedycache-option-desc">'.esc_html__('This will cache the admin pages too.', 'speedycache').'</div>
					</td>
				</tr>
				
				<tr>
					<th><label for="speedycache_async_flush">'.esc_html__('Asynchronous Flushing', 'speedycache').'</label></th>
					<td>
						<label for="speedycache_async_flush" class="speedycache-custom-checkbox">
							<input type="checkbox" id="speedycache_async_flush" name="async_flush" '.((!empty($speedycache->object['async_flush'])) ? ' checked="true"' : '').'/>
							<div class="speedycache-input-slider"></div>
						</label>
						<div class="speedycache-option-desc">'.esc_html__('Deletes asynchronously, without blocking', 'speedycache').'</div>
					</td>
				</tr>
				
				<tr>
					<th><label for="speedycache_serialization_method">'.esc_html__('Serialization Method', 'speedycache').'</label></th>
					<td>';
						$serialization_methods = ['SERIALIZER_PHP', 'SERIALIZER_IGBINARY'];

						echo '<label for="speedycache_serialization_method">
						
							<select id="speedycache_serialization_method" name="serialization" value="'. (!empty($speedycache->object['serialization']) ? esc_attr($speedycache->object['serialization']) : 'php').'">
								<option value="none">None</option>';

								foreach($serialization_methods as $method){
									$selected = '';

									if(empty($speedycache->object['serialization']) && $method === 'SERIALIZER_PHP'){
										$selected = 'selected';
									}else if(!empty($speedycache->object['serialization']) && $speedycache->object['serialization'] === $method){
										$selected = 'selected';
									}

									if(defined('Redis::'.$method)){
										echo '<option value="'.esc_attr($method).'" '.esc_attr($selected).'>'.esc_html($method).'</option>';
									}
								}
							echo '</select>
						</label>
						<div class="speedycache-option-desc">'.esc_html('If you don\'t see IG_BINARY option then the phpredis is not built with IG_BINARY, IG_BINARY can save upto 50% space', 'speedycache').'</div>
					</td>
				</tr>

				<tr>
					<th><label for="speedycache_compression_method">'.esc_html__('Compression Method', 'speedycache').'</label>
					</th>
					<td>';
						$serialization_methods = ['None', 'COMPRESSION_ZSTD', 'COMPRESSION_LZ4', 'COMPRESSION_LZF'];

						echo '<label for="speedycache_compression_method">
						
							<select id="speedycache_compression_method" name="compress" value="'. (!empty($speedycache->object['compress']) ? esc_attr($speedycache->object['compress']) : 'php').'">
								<option value="none">None</option>';

								foreach($serialization_methods as $method){
									$selected = '';

									if(empty($speedycache->object['compress']) && $method === 'None'){
										$selected = 'selected';
									}else if(!empty($speedycache->object['compress']) && $speedycache->object['compress'] === $method){
										$selected = 'selected';
									}

									if(defined('Redis::'.$method)){
										echo '<option value="'.esc_attr($method).'" '.esc_attr($selected).'>'.esc_html($method).'</option>';
									}
								}
							echo '</select>
						</label>
						<div class="speedycache-option-desc">'.esc_html('If you dont see any option then your phpredis is not built with compression options', 'speedycache').'</div>
					</td>
				</tr>
				
				<tr>
					<th><label for="speedycache_non_cache_group">'.esc_html__('Do not cache groups', 'speedycache').'</label></th>
					<td>
						<label for="speedycache_non_cache_group">
							<textarea id="speedycache_non_cache_group" name="non_cache_group" rows="5" cols="30">';
								if(empty($speedycache->object['non_cache_group'])){
									$speedycache->object['non_cache_group'] = ['plugins', 'comment', 'counts', 'wc_session_id'];
								}

								foreach($speedycache->object['non_cache_group'] as $group){
									echo esc_html($group) . "\n";
								}
							echo '</textarea>
						</label>
						<div class="speedycache-option-desc">'.esc_html__('These are the groups which should not be cached, One Per Line', 'speedycache').'</div>
					</td>
				</tr>
				
			</table>';

			\SpeedyCache\Settings::save_btn();
			echo '</form>
		</div>';
	}
}
PK��f\�@��:�:lazyload.phpnu�[���<?php
/*
* SPEEDYCACHE
* https://speedycache.com/
* (c) SpeedyCache Team
*/

namespace SpeedyCache;

if( !defined('SPEEDYCACHE_PRO_VERSION') ){
	die('HACKING ATTEMPT!');
}

class LazyLoad{
	static function init(){
		global $speedycache;
		
		$speedycache->lazy_load = array();
		$speedycache->lazy_load['exclude'] = array();
		$speedycache->lazy_load['host'] = '';
		$speedycache->lazy_load['placeholder'] = '';
		$url = parse_url(site_url());
		$speedycache->lazy_load['host'] = $url['host'];

		if(!empty($speedycache->options['lazy_load_keywords']) && $speedycache->options['lazy_load_keywords']){
			if(is_string($speedycache->options['lazy_load_keywords'])){
				$speedycache->lazy_load['exclude'] = explode(',', $speedycache->options['lazy_load_keywords']);
			} else {
				$speedycache->lazy_load['exclude'] = $speedycache->options['lazy_load_keywords'];
			}
		}
		
		self::set_placeholder();
	}

	static function set_placeholder(){
		global $speedycache;
		
		if(!empty($speedycache->options['lazy_load_placeholder']) && $speedycache->options['lazy_load_placeholder']){
			
			if($speedycache->options['lazy_load_placeholder'] === 'default'){
				$speedycache->lazy_load['placeholder'] = SPEEDYCACHE_PRO_URL . '/assets/images/image-palceholder.png';
			} else if($speedycache->options['lazy_load_placeholder'] === 'base64'){
				$speedycache->lazy_load['placeholder'] = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
			} else if($speedycache->options['lazy_load_placeholder'] === 'custom' && !empty($speedycache->options['lazy_load_placeholder_custom_url'])){
				$speedycache->lazy_load['placeholder'] = $speedycache->options['lazy_load_placeholder_custom_url'];
			}
			
			return;
		} 
		
		$speedycache->lazy_load['placeholder'] = SPEEDYCACHE_PRO_URL . '/assets/images/image-palceholder.png';
		return;
	}

	static function instagram($tag){
		$src = false;

		if(preg_match("/src\s*\=\s*[\"\']([^\"\']+sb-instagram\.min\.js)/", $tag, $out)){
			$src = $out[1];
		}

		if(empty($src)){
			return $tag;
		}

		$tmp_script = '<script type="text/javascript">'.
		"window.addEventListener('scroll',function(){".
		"(function(d,s){".
		"if(document.querySelectorAll("."\"script[src='\""." + s + "."\"']\"".").length > 0){return;}".
		"var t = d.createElement('script');".
		't.setAttribute("src", s);'.
		"d.body.appendChild(t);".
		'})(document, "'.$src.'");'.
		"});".
		"</script>\n";

		return $tmp_script;
	}

	static function mark_images($content){
		global $speedycache;

		if(speedycache_is_mobile()){
			return $content;
		}

		preg_match_all('/<img[^\>]+>/i', $content, $matches);

		if(count($matches[0]) <= 0){
			return $content;
		}

		foreach($matches[0] as $img){
			if(self::is_thumbnail($img) || self::is_third_party($img) || !self::is_full($img)){
				continue;
			}

			$tmp_img = $img;

			if(strpos($img, 'decoding') === FALSE){
				$tmp_img = preg_replace("/<img\s/", '<img decoding="async" ', $img);
			}

			$tmp_img = preg_replace("/<img\s/", '<img speedycache-lazyload-disable="true" ', $tmp_img);

			$content = str_replace($img, $tmp_img, $content);
		}

		return $content;
	}

	static function mark_attachment_page_images($attr, $attachment){

		if(speedycache_is_mobile()){
			return $attr;
		}

		if(isset($attr['src'])){
			if(self::is_thumbnail($attr['src'])){
				return $attr;
			}

			if(self::is_third_party($attr['src'])){
				return $attr;
			}

			if(!self::is_full('<img src="' . $attr['src'] . '" class="' . $attr['class'] . '">')){
				return $attr;
			}
		}

		if(empty($attachment)){
			return $attr;
		}

		$attr['speedycache-lazyload-disable'] = 'true';

		return $attr;
	}

	static function is_thumbnail($src){
		
		$resolution_pregs = array(
			'/\-[12]\d{0,2}x[12]\d{0,2}\.(jpg|jpeg|png)/i', // < 299x299
			'/\-[12]\d{0,2}x\d{0,2}\.(jpg|jpeg|png)/i', // < 299x99
			'/\-\d{0,2}x[12]\d{0,2}\.(jpg|jpeg|png)/i', // < 99x299
			'/\-\d{0,2}x\d{0,2}\.(jpg|jpeg|png)/i' // < 99x99
		);
		
		foreach($resolution_pregs as $resolution_preg){
			if(preg_match($resolution_preg, $src)){
				return true;
			}
		}

		return false;
	}

	static function is_third_party($src){
		global $speedycache;
		
		if(preg_match('/' . preg_quote($speedycache->lazy_load['host'], '/') . '/i', $src)){
			return false;
		}

		return true;
	}

	static function is_full($img){
		
		// to check homepage. sometimes is_home() does not work
		if(isset($_SERVER['REQUEST_URI']) && strlen($_SERVER['REQUEST_URI']) < 2){
			return false;
		}

		if(is_home() || is_archive()){
			return false;
		}

		if(preg_match("/-\d+x\d+\.(jpg|jpeg|png)/i", $img)){
			if(preg_match("/\sclass\=[\"\'][^\"\']*size-medium[^\"\']*[\"\']/", $img)){
				return false;
			}
		}

		return true;
	}

	static function is_exclude($source){
		global $speedycache;
		
		/*
			to disable lazy load for rav-slider images
			<img data-bgposition="center center" data-bgparallax="8" data-bgfit="cover" data-bgrepeat="no-repeat"class="rev-slidebg" data-no-retina>
			<img width="1920" height="600" data-parallax="8" class="rev-slidebg" data-no-retina>
		*/
		if(preg_match('/class\="rev-slidebg"/i', $source) && preg_match("/data-(bg)*parallax\=/i", $source)){
			return true;
		}

		/*
			to exclude img tag which exists in json
			var xxx = {"content":"<a href=\"https:\/\/www.abc.com\"><img src='https:\/\/www.abc.com\/img.gif' \/><\/a>"}
		*/
		if(preg_match("/\\\\\//", $source)){
			return true;
		}

		/*
			<img src="my-image.jpg" data-no-lazy="1" alt="" width="100" width="100" />
			<img src="my-image.jpg" data-skip-lazy="1" alt="" width="100" width="100" />
		*/
		if(preg_match("/data-(no|skip)-lazy\s*\=\s*[\"\']\s*1\s*[\"\']/i", $source)){
			return true;
		}

		//Slider Revolution
		//<img src="dummy.png" data-lazyload="transparent.png" data-bgposition="center center" data-bgfit="cover" data-bgrepeat="no-repeat" data-bgparallax="off" class="rev-slidebg" data-no-retina>
		if(preg_match("/\sdata-lazyload\=[\"\']/i", $source)){
			return true;
		}

		//<img src="dummy.png" data-lazy-src="transparent.png">
		//<img src="dummy.png" data-gg-lazy-src="transparent.png">
		if(preg_match("/\sdata-([a-z-]*)lazy-src\=[\"\']/i", $source)){
			return true;
		}

		//<div style="background-image:url(&#039;https://www.g.com/site-data/plugins/bold-page-builder/img/image-palceholder.png&#039;);background-position:top;background-size:cover;" data-background_image_src="https://www.g.com/site-data/1.jpg">
		if(preg_match("/\sdata-background_image_src\=[\"\']/i", $source)){
			return true;
		}

		/*
		Smash Balloon Social Photo Feed
		<img src="https://site.com/site-data/plugins/instagram-feed/img/placeholder.png"
		*/
		if(preg_match('/instagram-feed\/img\/placeholder\.png/i', $source)){
			return true;
		}

		// don't to the replacement if the image is a data-uri
		if(preg_match("/src\=[\'\"]data\:image/i", $source)){
			return true;
		}


		foreach((array)$speedycache->lazy_load['exclude'] as $key => $value){
			if(preg_match('/' . preg_quote($value, '/') . '/i', $source)){
				return true;
			}
		}

		return false;
	}

	static function video($data, $inline_scripts){
		global $speedycache;
		
		if(isset($speedycache->settings['noscript'])){
			$inline_scripts = $inline_scripts . $speedycache->settings['noscript'];
		}

		$video_list = array();
		$video_start_index = false;

		for ($i = 0; $i < strlen($data); $i++){
			if(isset($data[$i - 5])){
				if(substr($data, $i - 5, 6) == '<video'){
					$video_start_index = $i - 5;
				}
			}

			if(isset($data[$i - 7])){
				if($video_start_index){
					if(substr($data, $i - 7, 8) == '</video>'){
						array_push($video_list, array('start' => $video_start_index, 'end' => $i));
						$video_start_index = false;
					}
				}
			}
		}

		if(!empty($video_list)){
			foreach(array_reverse($video_list) as $key => $value){
				$video_html = substr($data, $value['start'], ($value['end'] - $value['start'] + 1));

				if(self::is_exclude($video_html)){
					continue;
				}

				$video_html = '<noscript data-type="speedycache">' . $video_html . '</noscript>';

				$data = substr_replace($data, $video_html, $value['start'], ($value['end'] - $value['start'] + 1));
			}
		}

		return $data;
	}

	static function background($content, $inline_scripts){
		global $speedycache;

		if(isset($speedycache->settings['noscript'])){
			$inline_scripts = $inline_scripts . $speedycache->settings['noscript'];
		}

		preg_match_all('/<(div|span|a|section|li)\s[^\>]*style\s*\=\s*[\"\'][^\"\']*(background\-image\s*\:\s*url\s*\(([^\)\(]+)\)\;?)[^\"\']*[\"\'][^\>]*>/i', $content, $matches, PREG_SET_ORDER);

		if(count($matches) > 0){
			/*
				[0] = full
				[1] = tag
				[2] = backgound image
				[3] = url
			*/
			foreach($matches as $key => $div){
				// don't to the replacement if the image appear in js
				if(preg_match("/" . preg_quote($div[0], '/') . '/i', $inline_scripts)){
					continue;
				}

				if(self::is_exclude($div[0])){
					continue;
				}

				$tmp = $div[0];
				//to remove backgound attribute
				$tmp = str_replace($div[2], '', $tmp);
				//to add lazy load attribute
				$div[3] = preg_replace("/[\"\']/", '', $div[3]);
				$tmp = preg_replace("/<([a-z]{1,4})\s/i", "<$1 data-speedycache-original-src='" . $div[3] . "' ", $tmp);

				$content = str_replace($div[0], $tmp, $content);
			}
		}

		return $content;
	}

	static function images($content, $inline_scripts){
		global $speedycache;

		if(isset($speedycache->settings['noscript'])){
			$inline_scripts = $inline_scripts . $speedycache->settings['noscript'];
		}

		$offset = 2;

		preg_match_all('/<img[^\>]+>/i', $content, $matches);
		$count = 0;
		if(count($matches[0]) > 0){
			foreach($matches[0] as $key => $img){
				$count++;
				$tmp_img = false;
				
				if(preg_match("/onload=[\"\']/i", $img)){
					continue;
				}

				if(preg_match("/src\s*\=\s*[\'\"]\s*[\'\"]/i", $img)){
					continue;
				}
				
				// Excluding images from lazy loading and adding fetchpriority to high,
				// as we need to load that image faster if we are not lazy loading them
				if(!empty($speedycache->options['exclude_above_fold']) && is_numeric($speedycache->options['exclude_above_fold'])){
					if($count < $speedycache->options['exclude_above_fold']){
						$tmp_img = $img;
						$img = preg_replace('/fetchpriority=["\'].*["\']/Us', '', $img);
						$img = preg_replace('/loading=["\'].*["\']/Us', '', $img);
						$img = preg_replace('/decoding=["\'].*["\']/Us', '', $img);
						
						$img = str_replace('<img', '<img fetchpriority="high" loading="eager" decoding="async" ', $img);
						$content = str_replace($tmp_img, $img, $content);

						continue;
					}
				}

				$should_continue = self::replace_img($inline_scripts, $img, $content);
				
				if(!empty($should_continue)){
					continue;
				}

				$tmp_img = preg_replace("/\sspeedycache-lazyload-disable\=[\"\']true[\"\']\s*/", " ", $img);
				$content = str_replace($img, $tmp_img, $content);
			}
		}

		return $content;
	}

	static function inject_data_src($img){
		global $speedycache;
		
		if(!preg_match("/\ssrc\s*\=[\"\'][^\"\']+[\"\']/i", $img)){
			return $img;
		}
		
		if(preg_match("/mc\.yandex\.ru\/watch/i", $img)){
			return $img;
		}

		$tmp_img = $img;
		$tmp_img = preg_replace('/\ssrc\s*\=/i', ' data-speedycache-original-src=', $tmp_img);
		$tmp_img = preg_replace('/\ssrcset\s*\=/i', ' data-speedycache-original-srcset=', $tmp_img);
		$tmp_img = preg_replace('/\ssizes\s*\=/i', ' data-speedycache-original-sizes=', $tmp_img);
		$tmp_img = preg_replace('/<img\s/i', '<img onload="speedycachell.r(this,true);" src="' . $speedycache->lazy_load['placeholder'] . "$2\" ", $tmp_img);

		// to add alt attribute for seo
		$tmp_img = preg_replace('/\salt\s*\=\s*[\"|\']\s*[\"|\']/', ' alt="blank"', $tmp_img);
		if(!preg_match('/\salt\s*\=\s*/i', $tmp_img)){
			$tmp_img = preg_replace('/<img\s+/i', '<img alt="blank" ', $tmp_img);
		}

		return $tmp_img;
	}

	static function replace_img($inline_scripts, $img, &$content){
		
		$tmp_img = false;
		
		// Don't do the replacement if the image appear in js
		if(preg_match('/' . preg_quote($img, '/') . '/i', $inline_scripts)){
			return false;
		}

		// Don't do the replacement if quote of src does not exist
		if(!preg_match("/\ssrc\s*\=[\"\']/i", $img) && preg_match("/<img/i", $img)){
			return true;
		}

		if(self::is_exclude($img)){
			$tmp_img = preg_replace('/\sspeedycache-lazyload-disable\=[\"\']true[\"\']\s*/', ' ', $img);
		} else if(preg_match('/speedycache-lazyload-disable/', $img)){
			$tmp_img = preg_replace('/\sspeedycache-lazyload-disable\=[\"\']true[\"\']\s*/', ' ', $img);
		} else {
			$tmp_img = self::inject_data_src($img);
		}
		
		if($tmp_img){
			$content = str_replace($img, $tmp_img, $content);
		}
		
		return true;
	}

	static function iframe($content, $inline_scripts){
		
		preg_match_all('/<iframe[^\>]+>/i', $content, $matches);

		if(count($matches[0]) > 0){
			foreach($matches[0] as $iframe){
				if(self::is_exclude($iframe)){
					continue;
				}

				self::iframe_replace($inline_scripts, $iframe, $content);
			}
		}

		return $content;
	}

	static function iframe_replace($inline_scripts, $iframe, &$content){
		// don't to the replacement if the frame appear in js
		if(preg_match('/' . preg_quote($iframe, "/") . '/i', $inline_scripts)){
			return;
		}

		if(preg_match("/onload=[\"\']/i", $iframe)){
			return;
		}

		if(preg_match("/(youtube|youtube-nocookie)\.com\/embed/i", $iframe) && !preg_match("/videoseries\?list/i", $iframe)){
			// to exclude /videoseries?list= because of problem with getting thumbnail
			$tmp_iframe = preg_replace("/\ssrc\=[\"\'](https?\:)?\/\/(www\.)?(youtube|youtube-nocookie)\.com\/embed\/([^\"\']+)[\"\']/i", " onload=\"speedycachell.r(this,true);\" data-speedycache-original-src=\"" . SPEEDYCACHE_WP_CONTENT_URL . "/plugins/".SPEEDYCACHE_PRO_BASE_NAME."/main/youtube.html#$4\"", $iframe);
		} else {
			$tmp_iframe = preg_replace("/\ssrc\=/i", " onload=\"speedycachell.r(this,true);\" data-speedycache-original-src=", $iframe);
		}

		$content = str_replace($iframe, $tmp_iframe, $content);

	}

	static function get_js_source(){
		
		$js = "\n<script data-speedycache-render=\"false\">" . file_get_contents(SPEEDYCACHE_PRO_DIR . '/assets/js/lazy-load.js') . "</script>\n";

		/**
		  * Structure of this array is
		  * searchable => replacer
		*/
		$js_replaces = array(
			'/\/\*[^\n]+\*\//' =>  '', //to remove comments
			'/var\sself/' => 'var s',
			'/self\./' => 's.',
			'/speedycache_lazy_load/' => 'speedycachell',
			'/(\.?)init(\:?)/' => '$1i$2',
			'/(\.?)load_images(\:?)/' => '$1li$2',
			'/\s*(\+|\=|\:|\;|\{|\}|\,)\s*/' => '$1',
			'/originalsrcset/' => 'ot',
			'/originalsrc/' => 'oc',
			'/load_sources/' => 'ls',
			'/set_source/' => 'ss',
			'/sources/' => 's',
			'/winH/' => 'w',
			'/number/' => 'n',
			'/elemRect/' => 'er',
			'/parentRect/' => 'pr',
			'/parentOfE/' => 'p',
			'/top(\=|\+)/' => 't$1'
		);
		
		foreach($js_replaces as $search => $replace){
			$js = preg_replace($search, $replace, $js);
		}

		return $js;
	}

}

PK��f\}��߸߸enhanced.phpnu�[���<?php
/*
* SPEEDYCACHE
* https://speedycache.com/
* (c) SpeedyCache Team
*/

namespace SpeedyCache;

if( !defined('SPEEDYCACHE_PRO_VERSION') ){
	die('HACKING ATTEMPT!');
}

class Enhanced{

	static function init(){
		global $speedycache;
		
		$speedycache->enhanced = array();
		$speedycache->enhanced['html'] = '';
		$speedycache->enhanced['head_html'] = '';
		$speedycache->enhanced['body_html'] = '';
		$speedycache->enhanced['inline_scripts'] = '';
		$speedycache->enhanced['cache_speedycache_minified'] = '';
		$speedycache->enhanced['cache_speedycache_minified'] = 'cache/speedycache/'.SPEEDYCACHE_SERVER_HOST. '/assets';
	}
	
	// Removes white space after </html> & \r & any white space 
	static function remove_trailing_html_space($content){
		global $speedycache;
		
		$content = preg_replace("/<\/html>\s+/", '</html>', $content);
		$content = str_replace("\r", '', $content);
		return preg_replace("/^\s+/m", '', ((string) $content));
	}

	static function remove_head_comments(){
		global $speedycache;
		
		$data = $speedycache->enhanced['head_html'];
		$comment_list = array();
		$comment_start_index = false;

		for($i = 0; $i < strlen( $data ); $i++){
			if(isset($data[$i-3])){
				if($data[$i-3].$data[$i-2].$data[$i-1].$data[$i] == '<!--'){
					if(!preg_match("/if\s+|endif\s*\]/", substr($data, $i, 17))){
						$comment_start_index = $i-3;
					}
				}
			}

			if(isset($data[$i-2])){
				if($comment_start_index){
					if($data[$i-2].$data[$i-1].$data[$i] == '-->'){
						array_push($comment_list, array('start' => $comment_start_index, 'end' => $i));
						$comment_start_index = false;
					}
				}
			}
		}

		if(!empty($comment_list)){
			foreach(array_reverse($comment_list) as $key => $value){
				$data = substr_replace($data, '', $value['start'], ($value['end'] - $value['start'] + 1));
			}

			$speedycache->enhanced['html'] = str_replace($speedycache->enhanced['head_html'], $data, $speedycache->enhanced['html']);
		}

		return $speedycache->enhanced['html'];
	}

	static function eliminate_newline($start_string, $end_string, $tmp_html){
		$data = $tmp_html;

		$list = array();
		$start_index = false;
		$end_index = false;

		for($i = 0; $i < strlen( $data ); $i++){
			if(substr($data, $i, strlen($start_string)) == $start_string){
				if(!$end_index){
					$start_index = $i;
				}
			}

			if($start_index && $i > $start_index){
				if(substr($data, $i, strlen($end_string)) == $end_string){
					$end_index = $i + strlen($end_string) - 1;
					$text = substr($data, $start_index, ($end_index - $start_index + 1));
					
					array_push($list, array('start' => $start_index, 'end' => $end_index, 'text' => $text));

					$start_index = false;
					$end_index = false;
				}
			}
		}

		if(isset($list[0])){
			$list = array_reverse($list);

			foreach($list as $key => $value){
				if(preg_match("/(<script|<style|<textarea)/i", $value['text'])){
					continue;
				}

				//var $bodybg=$('<div id="ncf-body-bg"/>').prependTo($body);
				if(preg_match("/\)\.prependTo\(/i", $value['text'])){
					continue;
				}

				//<div class="wp_syntax" style="position:relative;">
				if(preg_match("/<div\s+class\=\"wp\_syntax\"[^\>]*>/i", $value['text'])){
					continue;
				}

				$value['text'] = preg_replace("/\s+/", " ", ((string)$value['text']));

				$tmp_html = substr_replace($tmp_html, $value['text'], $value['start'], ($value['end'] - $value['start'] + 1));
			}
		}

		return $tmp_html;
	}

	static function minify_inline_css($data){
		global $speedycache;
		
		$style_list = array();
		$style_start_index = false;

		for($i = 0; $i < strlen( $data ); $i++){
			if(isset($data[$i-5])){
				if(substr($data, $i - 5, 6) == '<style'){
					$style_start_index = $i - 5;
				}
			}

			if(isset($data[$i-7])){
				if($style_start_index){
					if(substr($data, $i - 7, 8) == '</style>'){
						array_push($style_list, array('start' => $style_start_index, 'end' => $i));
						$style_start_index = false;
					}
				}
			}
		}

		if(!empty($style_list)){
			foreach(array_reverse($style_list) as $key => $value){
				// document.write('<style type="text/css">div{}</style')
				$prev_20_chars = substr($data, $value['start'] - 20, 20);
				
				if(strpos($prev_20_chars, 'document.write') !== false){
					continue;
				}

				$inline_style = substr($data, $value['start'], ($value['end'] - $value['start'] + 1));
				
				if(strlen($inline_style) > 15000){
					$part_of_inline_style = substr($inline_style, 0, 15000);
				}else{
					$part_of_inline_style = $inline_style;
				}

				if(preg_match('/'.preg_quote($part_of_inline_style, '/').'/i', $speedycache->enhanced['inline_scripts'])){
					continue;
				}

				if(preg_match("/<style\s+(amp-boilerplate|amp-custom)>/", $inline_style)){
					continue;	
				}

				$inline_style = \SpeedyCache\Enhanced::minify_css($inline_style);

				$inline_style = preg_replace("/\/\*(.*?)\*\//s", "\n", $inline_style); //replaces comments with \n
				$inline_style = preg_replace("/(<style[^\>]*>)\s+/i", "$1", $inline_style); //removes white space after <style> tag
				$inline_style = preg_replace("/\s+(<\/style[^\>]*>)/i", "$1", $inline_style); //removes white space before </style> tag

				$inline_style = str_replace(' type="text/css"', '', $inline_style);
				$inline_style = str_replace(' type="text/css"', '', $inline_style);

				$data = substr_replace($data, $inline_style, $value['start'], ($value['end'] - $value['start'] + 1));
			}
		}

		return $data;
	}

	static function remove_html_comments($data){
		$comment_list = array();
		$comment_start_index = false;

		for($i = 0; $i < strlen($data); $i++){
			if(isset($data[$i-3])){
				if($data[$i-3].$data[$i-2].$data[$i-1].$data[$i] == "<!--"){
					if(!preg_match("/if\s+|endif\s*\]/", substr($data, $i, 17))){
						$comment_start_index = $i-3;
					}
				}
			}

			if(isset($data[$i-2])){
				if($comment_start_index){
					if($data[$i-2].$data[$i-1].$data[$i] == '-->'){
						array_push($comment_list, array('start' => $comment_start_index, 'end' => $i));
						$comment_start_index = false;
					}
				}
			}
		}

		if(!empty($comment_list)){
			foreach(array_reverse($comment_list) as $key => $value){
				if(($value['end'] - $value['start']) > 4){
					$comment_html = substr($data, $value['start'], ($value['end'] - $value['start'] + 1));

					if(preg_match("/google\_ad\_slot/i", $comment_html)){
					}else{
						$data = substr_replace($data, '', $value['start'], ($value['end'] - $value['start'] + 1));
					}
				}
			}
		}

		return $data;
	}

	static function minify_html(&$content){
		global $speedycache;
		
		if(defined('SPEEDYCACHE_VERSION') && version_compare(SPEEDYCACHE_VERSION, '1.2.0', '<')){
			return $speedycache->enhanced['html'];
		}
		
		$tmp_html = $content;

		$tmp_html = self::remove_trailing_html_space($tmp_html);
		$tmp_html = self::eliminate_newline('<div', '</div>', $tmp_html);
		$tmp_html = self::eliminate_newline('<li', '</li>', $tmp_html);

		$tmp_html = self::minify_inline_js($tmp_html);
		$tmp_html = self::minify_inline_css($tmp_html);

		$tmp_html = self::remove_html_comments($tmp_html);

		$tag_list = 'p|div|span|img|nav|ul|li|header|a|b|i|article|section|footer|style|script|link|meta|body';

		$tmp_html = preg_replace_callback("/\<(".$tag_list.")\s+[^\>\<]+\>/i", '\SpeedyCache\Enhanced::remove_spaces_in_tag', $tmp_html);
		$tmp_html = preg_replace('/\h+<\//', '</', $tmp_html);
		
		// BECAUSE of JsemÂ<span class="label">
		// - need to remove spaces between >  <
		// - need to remove spaces between <span>  Assdfdf </span>
		// $tmp_html = preg_replace("/\h*\<(".$tag_list.")\s+([^\>]+)>\h*/i", "<$1 $2>", $tmp_html);
		// $tmp_html = preg_replace("/\h*\<\/(".$tag_list.")>\h*/i", "</$1>", $tmp_html);
		$tmp_html = preg_replace("/\s*<\/div>\s*/is", "</div>", $tmp_html);
		
		$content = $tmp_html;
	}

	static function search_in_inline_scripts($content){
		global $speedycache;
		
		if(strpos($speedycache->enhanced['inline_scripts'], $content) === false){
			return false;
		}
		
		return true;
	}

	static function remove_spaces_in_tag($matches){
		if(self::search_in_inline_scripts($matches[0])){
			return $matches[0];
		}
		
		/**
		  * Structure of this array is
		  * searchable => replacer
		*/	
		$pregs_replaces = array(
			'/([\"\'])\s+\/>/' => '$1/>', //  <img id="1"  />
			'/\s+/' => ' ', // <div      id="1">
			'/\s+([\"\'])/' => '$1', // <div id="1  ">
			'/([a-z])\=([\"\'])\s+/' => '$1=$2', // <div id="  1"> <img src="data:image/gif;base64,R0lAICRAEAOw==" lazy="image.jpg" />
			'/\h*class\=\'\'\h*/' => ' ', // <ul class="">
			'/\h*class\=\"\"\h*/' => ' ', // <ul class=''>
		);
		
		foreach($pregs_replaces as $searchable => $replacer){
			$matches[0] = preg_replace($searchable, $replacer, $matches[0]);
		}

		// <div style="">
		if(!preg_match("/id\=\"ctf_/", $matches[0])){
			/* 
			to exclude for Custom Twitter Feeds Pro Personal
			<div class="ctf-item ctf-author-msdsmarine ctf-new ctf-hide-avatar ctf-retweet ctf-tc-checked" id="ctf_1323705595325800448" style="">
			*/
			$matches[0] = preg_replace("/\h*style\=[\"\'][\"\']\h*/", " ", $matches[0]);
		}

		// <div id="1"  >
		// <div  >
		$matches[0] = preg_replace("/\h+\>/", ">", $matches[0]);

		// <script src='//bqcmw.js' type="text/javascript"></script>
		//$matches[0] = self::remove_type_attribute_for_js($matches[0]);

		return $matches[0];
	}

	static function remove_type_attribute_for_js($script){
		if(preg_match("/src\s*\=\s*[\"\']/", $script)){
			$script = preg_replace("/\stype\s*\=\s*[\'\"][^\"\']+[\'\"]/", " ", $script);
			$script = preg_replace("/\s+/", " ", $script);
			$script = preg_replace("/([\'\"])\s>/", "$1>", $script);
		}

		return $script;
	}

	static function remove_single_line_comments($html){
		$html = preg_replace("/<!--((?:(?!-->).)+)-->/", '', $html);
		$html = preg_replace("/\/\*((?:(?!\*\/).)+)\*\//", '', $html);
		return $html;
	}

	/* CSS Part Start */
	static function minify_css($source){
		$data = $source;
		$curl_list = array();
		$curl_start_index = false;

		$curl_start_count = 0;
		$curl_end_count = 0;

		for($i = 0; $i < strlen( $data ); $i++){
			if($data[$i] == '{'){
				$curl_start_count++;
				if(!$curl_start_index){
					$curl_start_index = $i;
				}
			}

			if($data[$i] == '}'){
				// .icon-basic-printer:before{content:"}";}
				if(isset($data[$i+1]) && $data[$i+1] != "'" && $data[$i+1] != "'"){
					$curl_end_count++;
				}
			}

			if($curl_start_count && $curl_start_count == $curl_end_count){
				array_push($curl_list, array('start' => $curl_start_index - 3, 'end' => $i + 3));

				$curl_start_count = 0;
				$curl_end_count = 0;
				$curl_start_index = false;
			}
		}

		if(!empty($curl_list)){
			foreach(array_reverse($curl_list) as $key => $value){
				$new_data = substr($data, $value['start'], ($value['end'] - $value['start'] + 1));

				if(!preg_match("/[^\{]+\{[^\{]+\{/", $new_data)){
					$new_data = preg_replace("/\s+/", " ", ((string) $new_data));
					$new_data = preg_replace("/\s+}/", "}", $new_data); //removes white space before "}"
					$new_data = preg_replace("/}\s+/", "} ", $new_data); //removes white space after "}"
					$new_data = preg_replace("/\s*(\{|\;|\:)\s*/", "$1", $new_data);

					$data = substr_replace($data, $new_data, $value['start'], ($value['end'] - $value['start'] + 1));

				}else{
					$first = strpos($new_data, '{');
					$last = strrpos($new_data, '}');
					$new_data_tmp = substr($new_data, $first+1, $last-$first-1);
					$new_data_tmp = \SpeedyCache\Enhanced::minify_css($new_data_tmp);

					$new_data = substr_replace($new_data, $new_data_tmp, $first+1, ($last-$first-1));

					$data = substr_replace($data, $new_data, $value['start'], ($value['end'] - $value['start'] + 1));
				}
			}

			$source = $data;
		}

		//@media (max-width: 767px){
		$source = preg_replace("/\@media\s*\(\s*(max-width|min-width)\s*\:\s*([^\(\)\{\}\s]+)\s*\)\s*\{/", "@media($1:$2){", $source);
		//@media (min-width: 768px) and (max-width: 1018px){
		$source = preg_replace("/\@media\s*\(\s*(max-width|min-width)\s*\:\s*([^\(\)\{\}\s]+)\s*\)\s*and\s*\(\s*(max-width|min-width)\s*\:\s*([^\(\)\{\}\s]+)\s*\)\s*\{/", "@media($1:$2) and ($3:$4){", $source);
		//@media screen and (max-width: 479px){
		$source = preg_replace("/\@media\s+screen\s+and\s*\(\s*(max-width|min-width)\s*\:\s*([^\(\)\{\}\s]+)\s*\)\s*\{/", "@media screen and ($1:$2){", $source);

		/*
		article,
		h2,
		div:first-child,
		.main{padding:0;}
		*/
		$source = preg_replace("/^([a-z0-9\_\.\-\:\>\s]+\,)\s+/im", "$1 ", $source);

		return $source;

		//$source = preg_replace_callback("/\s*\{((?:(?!content|\}).)+)\}\s*/", '\SpeedyCache\Enhanced::eliminate_newline_for_css'), $source);
		//return $source;
	}

	// Regex to replace new line after \n /\s*\;(?:\s*|\n)/
	//Replaces Space before and after { } ; :
	static function eliminate_newline_for_css($matches){
		$matches[0] = preg_replace("/\s+/", " ", ((string) $matches[0]));
		$matches[0] = preg_replace("/\s*{\s*/", "{", $matches[0]);
		$matches[0] = preg_replace("/\s*}\s*/", "}", $matches[0]);
		$matches[0] = preg_replace("/\s*\;\s*/", ";", $matches[0]);
		$matches[0] = preg_replace("/\s*\:\s*/", ":", $matches[0]);

		return $matches[0]."\n";
	}

	static function render_blocking($html, $render_blocking_css = false){
		\SpeedyCache\RenderBlocking::init($html);
		return \SpeedyCache\RenderBlocking::action($render_blocking_css);
	}

	static function google_fonts(){
		//for checking
	}

	static function lazy_load($content){
		global $speedycache;

		\SpeedyCache\LazyLoad::init();
		
		$funcs = array(
			'\SpeedyCache\LazyLoad::images',
			'\SpeedyCache\LazyLoad::iframe',
			'\SpeedyCache\LazyLoad::background',
			'\SpeedyCache\LazyLoad::video'
		);
		
		foreach($funcs as $fn){
			// if(!function_exists($fn)){
				// continue;
			// }

			$fn_res = call_user_func_array($fn, array($content, $speedycache->enhanced['inline_scripts']));
			
			if(empty($fn_res)){
				continue;
			}
			
			$content = $fn_res;
		
		}
		
		return $content;
	}

	/* CSS Part Start */

	/* Js Part Start */
	// TODO:: not used anywhere
	static function single_line_js($source){
		$source = preg_replace("/\n/", '', $source);

		return $source;
	}

	static function minify_js($source, $inline_js = false){
		//$source = preg_replace("/\n\/\/.*/", "", $source);
		//$source = preg_replace("/\/\*.*?\*\//s", "", $source);

		if(preg_match("/dynamicgoogletags\.update\(\)/i", $source)){
			$source = "<script>dynamicgoogletags.update();</script>";
			
			return $source;
		}

		// <script>
		//   (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
		//   (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
		//   m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
		//   })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

		//   ga('create', 'UA-9999-9', 'auto');
		//   ga('send', 'pageview');
		// </script>
		if(preg_match("/<script[^\>]*>\s*\(function\(i,s,o,g,r,a,m\)\{i\[\'GoogleAnalyticsObject\'\]/i", $source)){
			if(preg_match("/ga\(\'send\',\s*\'pageview\'\)\;\s*<\/script>/i", $source)){
				$source = preg_replace("/\s+/", " ", ((string) $source));
				$source = preg_replace("/\s*<(\/?)script([^\>]*)>\s*/", "<$1script$2>", $source);

				return $source;
			}
		}

		// sometimes the lines are ended with "\r" instead of "\n"
		$source = str_replace("\r", "\n", $source);

		$source = preg_replace("/^\s+/m", '', $source);

		if(empty($inline_js)){
			// // --></script> in html
			//$source = preg_replace("/\n\/\/[^\n]+/", "", $source); // to remove single line comments
			$source = preg_replace_callback("/\n\/\/[^\n]+/", '\SpeedyCache\Enhanced::remove_single_line_comments_from_js', $source);
		}

		if(!empty($inline_js)){
			if(preg_match("/var\sptsTables/i", $source) && preg_match("/var\sptsBuildConst/i", $source)){
			}
			//to remove only CDATA from inline js
			$source = preg_replace("/\/\*\s*\<\!\[CDATA\[\s*\*\//", "", $source);
			$source = preg_replace("/\/\*\s*\]\]\>\s*\*\//", "", $source);
		}

		//<script>//alert();</script>
		if(preg_match("/<script[^\>]*>\s*\/\/[^\n]*<\/script>/i", $source)){
			return '';
		}
		
		$source = preg_replace_callback("/([a-z]{4,5}\:)?\/\/[^\n]*/", '\SpeedyCache\Enhanced::remove_single_line_comments_from_js', $source);

		$source = preg_replace("/\}\)\;[^\S\r\n]+/", "});", $source);

		$source = preg_replace("/^\s+/m", "", $source);

		
		$source = preg_replace("/\s*(\!|\=)(\={1,3})\s*/", "$1$2", $source);

		// to remove spaces at the end of the line
		$source = preg_replace("/(\D)[^\S\r\n]+\n/", "$1\n", $source);

		$source = preg_replace("/([^\[\.\?])[^\S\r\n]+\:[^\S\r\n]+([^\]\.\?])/", "$1:$2", $source);

		$source = preg_replace("/([^\s\|])[^\S\r\n]*\&\&[^\S\r\n]*([^\s\|])/", "$1&&$2", $source);
		$source = preg_replace("/([^\s\&])[^\S\r\n]*\|\|[^\S\r\n]*([^\s\&])/", "$1||$2", $source);
		// @media all and (width), maybe later we  can do preg_replace_callback()
		//b.match(/^(<div><br( ?\/), no need to remove the spage between ( and ?
		//dashArray.replace(/( *, *)/g, no need to remove the spage between ( and *
		$source = preg_replace("/[^\S\r\n]*\([^\S\r\n]+([^\?\*\+])/", "($1", $source);
		$source = preg_replace("/and\(/", "and (", $source);
		//------
		$source = preg_replace("/([^\s\=\!])[^\S\r\n]*\=[^\S\r\n]*([^\s\=\!])/", "$1=$2", $source);

		$source = preg_replace("/\)\s+\{/", "){", $source);
		$source = preg_replace("/\}\s+}/s", "}}", $source);
		$source = preg_replace("/\};\s+}/s", "};}", $source);
		$source = preg_replace("/\}\s*else\s*\{/", "}else{", $source);
		$source = preg_replace("/\}[^\S\r\n]*else[^\S\r\n]*if[^\S\r\n]*\(/", "}else if(", $source);
		$source = preg_replace("/if\s*\(\s*/", "if(", $source);
		$source = preg_replace("/[^\S\r\n]+\)/", ")", $source);

		$source = preg_replace("/<script([^\>\<]*)>\s*/i", "<script$1>", $source);
		$source = preg_replace("/\s*<\/script>/i", "</script>", $source);

		// .name( something)
		$source = preg_replace("/(\.[A-Za-z\_]+\()\s{1,2}/", "$1", $source);

		// Muli-Line Comments Start
		$source = preg_replace_callback("/\/\*(.*?)\*\//s", '\SpeedyCache\Enhanced::remove_multi_line_comments_from_js', $source);
		// END

		$source = str_replace("\xEF\xBB\xBF", '', $source);

		$source = preg_replace("/^\s+/m", '', $source);

		//<script><!--
		//var x=5;
		//</script>
		if(!empty($inline_js)){
			if(preg_match("/<script[^\>]*><\!--/i", $source)){
				if(!preg_match("/-->/i", $source)){
					$source = preg_replace("/(<script[^\>]*>)<\!--\n/i", "$1", $source);
				}
			}
		}

		return $source;
	}

	static function minify_inline_js($data){
		global $speedycache;
		
		$script_list = array();
		$script_start_index = false;

		for($i = 0; $i < strlen( $data ); $i++){
			if(isset($data[$i - 6])){
				if(substr($data, $i - 6, 7) == '<script'){
					$script_start_index = $i - 6;
				}
			}

			if(isset($data[$i - 8])){
				if($script_start_index){
					if(substr($data, $i - 8, 9) == '</script>'){
						array_push($script_list, array('start' => $script_start_index, 'end' => $i));
						$script_start_index = false;
					}
				}
			}
		}

		if(!empty($script_list)){
			foreach(array_reverse($script_list) as $key => $value){
				$inline_script = substr($data, $value['start'], ($value['end'] - $value['start'] + 1));
				
				if(preg_match("/google\_ad\_slot/i", $inline_script)){
					$speedycache->enhanced['inline_scripts'] = $speedycache->enhanced['inline_scripts'].$inline_script;
					continue;
				}

				if(preg_match("/<script[^\>]+src=[\'\"][^\>]+>/i", $inline_script)){
					continue;
				}

				if(preg_match("/<script[^\>]+text\/template[^\>]+>/i", $inline_script)){
					continue;
				}

				$speedycache->enhanced['inline_scripts'] = $speedycache->enhanced['inline_scripts'].$inline_script;
					
				$inline_script = \SpeedyCache\Enhanced::minify_js($inline_script, true);

				$inline_script = str_replace(' type="text/javascript"', '', $inline_script);
				$inline_script = str_replace(' type="text/javascript"', '', $inline_script);

				$speedycache->enhanced['inline_scripts'] = $speedycache->enhanced['inline_scripts'].$inline_script;

				$data = substr_replace($data, $inline_script, $value['start'], ($value['end'] - $value['start'] + 1));

			}
		}

		return $data;
	}

	static function remove_multi_line_comments_from_js($matches){

		//segs.unshift('//*[@id="' + elm.getAttribute('id') + '"]');
		if(preg_match("/\/\*\[\@/", $matches[0])){
			return $matches[0];
		}
		
		if(preg_match("/\/\*\@cc_on/i", $matches[0])){
			return $matches[0];
		}

		if(preg_match("/\.exec\(|\.test\(|\.match\(|\.search\(|\.replace\(|\.split/", $matches[0])){
			return $matches[0];
		}

		if(preg_match("/function\(/", $matches[0])){
			return $matches[0];
		}

		//c("unmatched `/*`");
		if(preg_match("/^\/\*\`\"\)\;/", $matches[0])){
			return $matches[0];
		}

		// <script type='text/javascript'>
		// /* <![CDATA[ */
		// var icegram_data = {"custom_js":"<script type=\"text\/javascript\">\/* add your js code here *\/ <\/script>"};
		// /* ]]> */
		// </script>
		if(preg_match("/\\/script>/", $matches[0]) && preg_match("/\*\\//", $matches[0])){
			return $matches[0];
		}

		// {comment:{pattern:/^([ \t]*)\/[\/*].*(?:(?:\r?\n|\r)\1[ \t]+.+)*/m,lookbehind:!0}}
		if(preg_match("/\.\+\)\*\//", $matches[0])){
			return $matches[0];
		}

		// var sourceURL = '\n/*\n//# sourceURL=' + (options.sourceURL || '/lodash/template/source[' + (templateCounter++) + ']') + '\n*/';
		if(preg_match("/\/\*\\\\n\/\/\#\s+sourceURL/i", $matches[0])){
			return $matches[0];
		}

		// function(e){return"/*# sourceURL=".concat(r.sourceRoot).concat(e," */")
		if(preg_match("/\/\*\#\s+sourceURL/i", $matches[0])){
			return $matches[0];
		}

		// /*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(o))))," */
		if(preg_match("/\/\*\#\s+sourceMappingURL/i", $matches[0])){
			return $matches[0];
		}

		// var COMMON_HEADERS = {'Accept': 'application/json, text/plain, */*'};
		if(preg_match("/\/\*\'\}\;/", $matches[0])){
			return $matches[0];
		}

		return '';
	}

	static function remove_single_line_comments_from_js($matches){
		if(preg_match("/\n\/\/[^\n]+/", $matches[0])){
			// // */
			if(preg_match("/\/\/\s*\*\//", $matches[0])){
				return $matches[0];
			}

			return '';
		}

		// // something */
		if(preg_match("/\/\/[^\n\t]*\*\//", $matches[0])){
			return $matches[0];
		}

		// var url = {"name" : "something",
		// 		   "url"  : '//$1/p/$2/media/?size=l'
		// 		  };
		if(preg_match("/\'\h*$/", $matches[0])){
			if(substr_count($matches[0], "'") == 1){
				return $matches[0];
			}
		}

		// ia=/^\.\//;x=Object.prototype;var K=x.toString,
		if(preg_match("/^\/\/\;/", $matches[0])){
			return $matches[0];
		}

		// var snd = new Audio("data:audio/wav;base64,//uQRAAAAWMSLwUIYAAsYkXgoQw3kuZGUAAAAAAAAAACU=");
		if(preg_match("/^\/\/[A-Za-z0-9\+\/\=]+[\'\"]\)\;/", $matches[0])){
			return $matches[0];
		}

		// "data:audio/wave;base64,/UklGRiYAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQIAAAD//w==":"about:blank",
		if(preg_match("/^\/\/w\=\=\"/", $matches[0])){
			return $matches[0];
		}


		// var div = {"background-image":"url(data:image/png;base64,wD/AP+gvatMW2UYx//POaRK5CYII=)"};
		if(preg_match("/^\/\/[A-Za-z0-9\+\/\=]+\)[\'\"]\}/", $matches[0])){
			return $matches[0];
		}

		// base64
		if(preg_match("/^\/\/[A-Za-z0-9\+\/\=]{150}/", $matches[0])){
			return $matches[0];
		}

		// var a = '<a href="javascript://" id="nextLink" title="' + opts.strings.nextLinkTitle + '"></a>';
		if(preg_match("/^cript\:\/\/\"/", $matches[0])){
			return $matches[0];
		}

		// url.replace( /^http:\/\//i, 'https://' );
		//domain = domain.replace(new RegExp(/^http\:\/\/|^https\:\/\/|^ftp\:\/\//i),"");
		if(preg_match("/^\/\/i(\,|\))/", $matches[0])){
			return $matches[0];
		}

		// {pattern:/\/\*[\*!][\s\S]*?\*\//gm,alias:"co2"}
		// d=b?/[&<>"'\/]/g:/&(?!#?\w+;)|<|>|"|'|\//g;
		// replace(/\//g,"")
		// e.match(/^https?:\/\//g)
		if(preg_match("/^\/\/gm?(\,|\)|\;)/", $matches[0])){
			return $matches[0];
		}

		// match(/^https?:\/\//)
		// var pattern = RegExp("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?");
		if(preg_match("/^\/\/(\)|\()/", $matches[0])){
			return $matches[0];
		}

		//src="//about:blank" frameborder="0" allowfullscreen></iframe>'+
		if(preg_match("/^\/\/about\:blank/", $matches[0])){
			return $matches[0];
		}

		//"<img src='http"+(location.href.indexOf('https:')==0?'s://www':'://track')+".websiteceo.com/m/?"+q+"' width='1' height='1' border='0' align='left'>";
		if(preg_match("/^\/\/www\'/", $matches[0])){
			return $matches[0];
		}

		// if(URL.match( /^https?:\/\// ) ){
		if(preg_match("/^\/\/\s*\)\s*\)\s*\{/", $matches[0])){
			return $matches[0];
		}

		// "string".replace(/\//,3);
		if(preg_match("/^\/\/\s*\,/", $matches[0])){
			return $matches[0];
		}

		// src = src.replace('https?://[^./].','');
		if(preg_match("/^\/\/\[[^\]\[]+\]/", $matches[0])){
			return $matches[0];
		}

		// comments: /\/\*[^*]*\*+([^/][^*]*\*+)*\//gi,
		if(preg_match("/^\/\/\s*gi\s*\,/", $matches[0])){
			return $matches[0];
		}

		// var proto = document.location.protocol, host = "whatshelp.io", url = proto + "//static." + host;
		if(preg_match("/^\/\/static\./i", $matches[0])){
			return $matches[0];
		}

		// whatsapp://send?text=
		// NOTE: preg_match_replace gets only 5 chars so we check "tsapp://" instead of "whatsapp://"
		if(preg_match("/^tsapp\:\/\/send/", $matches[0])){
			return $matches[0];
		}

		// sms://?&body="+postTitle+" "+postUrl
		if(preg_match("/^\/\/\?\&/", $matches[0])){
			return $matches[0];
		}

		// viber://forward?text="+postTitle+" "+postUrl
		if(preg_match("/^viber\:\/\//", $matches[0])){
			return $matches[0];
		}

		//threema://compose?text="+postTitle+" "+postUrl
		if(preg_match("/^reema\:\/\//", $matches[0])){
			return $matches[0];
		}

		// weixin://
		if(preg_match("/^eixin\:\/\//", $matches[0])){
			return $matches[0];
		}

		// fb-messenger://share?
		if(preg_match("/^enger\:\/\//", $matches[0])){
			return $matches[0];
		}

		// rtmp://37.77.2.234:1935/redirect/live.flv
		if(preg_match("/^rtmp\:\/\//", $matches[0])){
			return $matches[0];
		}

		// comgooglemaps://?q=40.956572,29.0859053&directionsmode=driving
		if(preg_match("/^emaps\:\/\//", $matches[0])){
			return $matches[0];
		}

		// javascript://
		if(preg_match("/^cript\:\/\//", $matches[0])){
			return $matches[0];
		}

		// jsFileLocation:"//29.59.155.173/~cfo/site-data/plugins/revslider/public/assets/js/",
		if(preg_match("/^\/\/([0-9]{1,3}\.){3}[0-9]{1,3}\/\~/", $matches[0])){
			return $matches[0];
		}

		// var url = /[-a-zA-Z0-9@:%_\+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?/gi;
		if(preg_match("/\/\/\=\]/", $matches[0])){
			return $matches[0];
		}

		if(preg_match("/^maps\:\/\//", $matches[0])){
			return $matches[0];
		}

		// "line://msg/text/" + postTitle + "! " + postUrl
		if(preg_match("/^line\:\/\//", $matches[0])){
			return $matches[0];
		}

		// document.write('<script defer src="//:"></script>');
		if(preg_match("/^\/\/\:\"/", $matches[0])){
			return $matches[0];
		}

		// url: "//$1/p/$2/media/?size=l"
		if(preg_match("/^\/\/\\$/", $matches[0])){
			return $matches[0];
		}
		
		if(preg_match("/^\/\/\//", $matches[0])){
			return $matches[0];
		}
		
		if(preg_match("/^http/", $matches[0])){
			return $matches[0];
		}

		// var xxx={"case":"\nhttp://www.google.com"};
		if(preg_match("/^nhttp/", $matches[0])){
			return $matches[0];
		}

		// var currUrl = 'file://' + "something";
		if(preg_match("/^file\:\/\//i", $matches[0])){
			return $matches[0];
		}

		//<a href="javascript://nop/" class="morelink">
		if(preg_match("/cript\:\/\/nop/i", $matches[0])){
			return $matches[0];
		}

		// Flash.RTMP_RE = /^rtmp[set]?:\/\//i;
		if(preg_match("/^\/\/i\;/", $matches[0])){
			return $matches[0];
		}

		//segs.unshift('//*[@id="' + elm.getAttribute('id') + '"]');
		if(preg_match("/^\/\/\*\[/", $matches[0])){
			return $matches[0];
		}

		// e.write('<!DOCTYPE html "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">')
		if(preg_match("/^\/\/W3C\/\/DTD\s+XHTML/i", $matches[0])){
			return $matches[0];
		}

		// var sourceURL = '\n/*\n//# sourceURL=' + (options.sourceURL || '/lodash/template/source[' + (templateCounter++) + ']') + '\n*/';
		// var xxx = "} catch (e){ throw 'TemplateError: ' + e + ' (on " + name + "' + ' line ' + this.line + ')'; } " + "//@ sourceURL=" + name + "\n" // source map
		if(preg_match("/^\/\/(\#|\@)\s+sourceURL/i", $matches[0])){
			return $matches[0];
		}

		// options.tileLayerThem = '//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
		if(preg_match("/^\/\/\{[^\}]+\}\./", $matches[0])){
			return $matches[0];
		}

		// document.write("<"+"script defer src=\"//:\" id=\"__onload_ie_pixastic__\"></"+"script>");
		if(preg_match("/^\/\/\:\\\\(\"|\')/", $matches[0])){
			return $matches[0];
		}

		// a.src='//cdn.'+w[r+'h']+'/libs/b.js';
		if(preg_match("/^\/\/cdn\./", $matches[0])){
			return $matches[0];
		}

		//<!DOCTYPE svg "-//W3C//DTD SVG 1.1//EN
		if(preg_match("/^\/\/W3C/i", $matches[0])){
			return $matches[0];
		}

		/*
		//# sourceMappingURL=angular.min.js.map
		//# sourceMappingURL=data:application
		*/
		if(preg_match("/sourceMappingURL\s*\=\s*(angular\.min\.js\.map|data\:application)/i", $matches[0])){
			return $matches[0];
		}

		if(preg_match("/\.exec\(|\.test\(|\.match\(|\.search\(|\.replace\(|\.split/", $matches[0])){
			return $matches[0];
		}

		if(preg_match("/^\/\/(?!\-)(?:[a-zA-Z\d\-]{0,62}[a-zA-Z\d]\.){1,126}(?!\d+)[a-zA-Z\d]{1,63}/", $matches[0])){
			return $matches[0];
		}

		if(preg_match("/\'|\"/", $matches[0])){
			// ' something
			if(preg_match("/^\/\/\s*[\'|\"]/", $matches[0])){
				return $matches[0];
			}

			// new Validator.Assert().Regexp('(https?:\\/\\/)?(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{2,256}\\.[a-z]{2,4}\\b([-a-zA-Z0-9@:%_\\+.~#?&//=]*)', 'i');
			if(preg_match("/[\'\"]\,\s*[\'\"]i[\'\"]\)\;/", $matches[0])){
				return $matches[0];
			}

			/*static function speedycache_powerful_html_Uc(a,b){var c=Q&&Q.isAvailable(),d=c&&!(nb.kd||!0===nb.get("previous_websocket_failure"));b.ce&&(c||L("
			wss:// URL used, but browser isn't known to support websockets.  Trying anyway."),d=!0);if(d)a.Mb=[Q];else{var e=a.Mb=[];Vb(Vc,function(a,b){b&&b.isAvailable()&&e.push(b)})}}static function speedycache_powerful_html_Wc(a){if(0<a.Mb.length)return a.Mb[0];throw Error("No transports available");};static function speedycache_powerful_html_Xc(a,b,c,d,e,f){this.id=a;this.e=Mb("c:"+this.id+":");this.Lc=c;this.Ab=d;this.S=e;this.Kc=f;this.M=b;this.fc=[];this.Zc=0;this.yd=new Tc(b);this.ma=0;this.e("Connection created");Yc(this)}
			*/
			if(preg_match("/if\(/", $matches[0]) && preg_match("/this\./", $matches[0]) && preg_match('/function/', $matches[0])){
				return $matches[0];
			}

			// <script defer src="//:" id="__onload_ie_pixastic__">\x3c/script>
			if(preg_match("/x3c\/script>/i", $matches[0])){
				return $matches[0];
			}

			return '';
		}

		if(preg_match("/<\/script>/", $matches[0])){
			return preg_replace("/\/\/[^\<]+<\/script>/", '</script>', $matches[0]);
		}

		return '';
	}

	static function minify_js_in_body($exclude_rules = false){
		global $speedycache;
		
		$data = $speedycache->enhanced['html'];
		$script_list = array();
		$script_start_index = false;

		for($i = 0; $i < strlen( $data ); $i++){
			if(isset($data[$i - 6])){
				if(substr($data, $i - 6, 7) == '<script'){
					$script_start_index = $i - 6;
				}
			}

			if(isset($data[$i - 8]) && !empty($script_start_index)){
				if(substr($data, $i - 8, 9) == '</script>'){
					array_push($script_list, array('start' => $script_start_index, 'end' => $i));
					$script_start_index = false;
				}
			}
		}

		if(empty($script_list)){
			return $speedycache->enhanced['html'];
		}
		
		foreach(array_reverse($script_list) as $key => $value){
			$script_tag = substr($data, $value['start'], ($value['end'] - $value['start'] + 1));

			if(!preg_match("/^<script[^\>\<]+src\=[^\>\<]+>/i", $script_tag) && preg_match("/\/speedycache\-assets\//i", $script_tag)){
				continue;
			}

			preg_match("/src\=[\"\']([^\'\"]+)[\"\']/i", $script_tag, $src);

			$http_host = str_replace(array('http://', 'www.'), '', sanitize_text_field($_SERVER['HTTP_HOST']));
			
			if(!isset($src[1])){
				continue;
			}

			if(!preg_match('/'.preg_quote($http_host, '/').'/i', $src[1])){
				continue;
			}

			if(!empty($exclude_rules)){
				$is_excluded = false;

				foreach((array)$exclude_rules as $exclude_key => $exclude_value){
					if(!empty($exclude_value['prefix']) && $exclude_value['type'] === 'js'){
						if($exclude_value['prefix'] === 'contain'){
							$preg_match_rule = preg_quote($exclude_value['content'], '/');
						}

						if(preg_match('/'.$preg_match_rule.'/i', $src[1])){
							$is_excluded = true;
							break;
						}
					}
				}

				if(!empty($is_excluded)){
					continue;
				}
			}
			
			// Skip if the file is already minified.
			if(strpos($src[1], '.min.') !== FALSE){
				continue;
			}

			if(preg_match("/alexa\.com\/site\_stats/i", $src[1])){
				continue;
			}

			if(preg_match("/wp-spamshield\/js\/jscripts\.php/i", $src[1])){
				continue;
			}

			//amazonjs/components/js/jquery-tmpl/jquery.tmpl.min.js?ver=1.0.0pre
			if(preg_match("/jquery-tmpl\/jquery\.tmpl\.min\.js/i", $src[1])){
				continue;
			}

			//<script src="https://server1.opentracker.net/?site=www.site.com"></script>
			if(preg_match("/[\?\=].*".preg_quote($http_host, '/').'/i', $src[1])){
				continue;
			}
			
			$js_file_name = md5($src[1]);

			$cache_file_path = WP_CONTENT_DIR.'/'.$speedycache->enhanced['cache_speedycache_minified'].'/'.$js_file_name;
			
			if(!defined('SPEEDYCACHE_WP_CONTENT_URL')){
				$js_script = content_url().'/'.$speedycache->enhanced['cache_speedycache_minified'].'/'.$js_file_name;
			}else{
				$js_script = SPEEDYCACHE_WP_CONTENT_URL.'/'.$speedycache->enhanced['cache_speedycache_minified'].'/'.$js_file_name;
			}

			$js_script = str_replace(array('http://', 'https://'), '//', $js_script);
			
			$args = array(
				'src' => $src[1],
				'cache_file_path' => $cache_file_path,
				'js_script' => $js_script,
				'script_tag' => $script_tag,
				'value' => $value
			);
			
			self::fetch_and_minify_js($args);
		}

		return $speedycache->enhanced['html'];
	}


	static function fetch_and_minify_js($args){
		global $speedycache;
		
		$response = wp_remote_get(\SpeedyCache\Enhanced::fix_protocol($args['src']), array('timeout' => 10 ) );

		if(empty($response) || is_wp_error($response)){
			return false;
		}

		if(wp_remote_retrieve_response_code($response) != 200){
			return false;
		}

		$js_content = wp_remote_retrieve_body($response);

		if(preg_match('/<\/\s*html\s*>\s*$/i', $js_content)){
			return false;
		}
		
		$minified_js_content = \SpeedyCache\Enhanced::minify_js($js_content);

		if(!is_dir($args['cache_file_path'])){
			$prefix = time();
			\SpeedyCache\Cache::create_dir($args['cache_file_path'], $minified_js_content, 'js');
		}

		if(file_exists($args['cache_file_path']) && $js_files = @scandir($args['cache_file_path'], 1)){
			$new_script = str_replace($args['src'], $args['js_script'].'/'.$js_files[0], $args['script_tag']);
			$speedycache->enhanced['html'] = substr_replace($speedycache->enhanced['html'], $new_script, $args['value']['start'], ($args['value']['end'] - $args['value']['start'] + 1));
		}

	}

	static function combine_js_in_footer($minify = false){
		global $speedycache;
		
		$footer = strstr($speedycache->enhanced['html'], '<!--SPEEDYCACHE_FOOTER_START-->');

		\SpeedyCache\JS::init($footer, $minify);
		$tmp_footer = \SpeedyCache\JS::combine();
		
		if(!empty($speedycache->options['render_blocking'])){
			\SpeedyCache\RenderBlocking::init($tmp_footer);
			$tmp_footer = \SpeedyCache\RenderBlocking::action(false, true);
		}
		
		$speedycache->enhanced['html'] = str_replace($footer, $tmp_footer, $speedycache->enhanced['html']);
		
		return $speedycache->enhanced['html'];
	}
	/* Js Part End */

	static function fix_protocol($url){
		if(!preg_match('/^\/\//', $url)){
			return $url;
		}

		if(preg_match('/^https:\/\//', home_url())){
			return 'https:'.$url;
		}

		return 'http:'.$url;
	}

	static function set_html($html){
		global $speedycache;
		
		$speedycache->enhanced['html'] = $html;
		self::set_head_html();
		self::set_body_html();
	}

	static function set_body_html(){
		global $speedycache;
		
		preg_match("/<body(.+)<\/body>/si", $speedycache->enhanced['html'], $out);

		if(isset($out[0])){
			$speedycache->enhanced['body_html'] = $out[0];
			return;
		}

		$speedycache->enhanced['body_html'] = '';
	}

	static function set_head_html(){
		global $speedycache;
		
		preg_match("/<head(.+)<\/head>/si", $speedycache->enhanced['html'], $out);

		if(isset($out[0])){
			$speedycache->enhanced['head_html'] = $out[0];
			return;
		}

		$speedycache->enhanced['head_html'] = '';

	}
	
	static function delay_js($content){
		global $speedycache;

		// If Delay js mode is selected and the scripts are empty then return
		if(empty($speedycache->options['delay_js_mode']) || (!empty($speedycache->options['delay_js_mode']) && $speedycache->options['delay_js_mode'] == 'selected' && empty($speedycache->options['delay_js_scripts']))){
			return $content;
		}
		
		$scripts = self::find_tags('<script', '</script>', $content);
		
		if(empty($scripts)){
			return $content;
		}

		foreach($scripts as $tag => $script){
			// Dont process a tag without src
			$is_inline = false;
			
			if(strpos($script['text'], ' src') === FALSE){
				$is_inline = true;
			}
			
			// We dont want to delay structured data
			if(strpos($script['text'], 'application/ld+json') !== FALSE){
				continue;
			}

			if(strpos($script['text'], 'text/template') !== FALSE){
				continue;
			}
			
			// Don't delay a module.
			if(strpos($script['text'], 'type="module"') !== FALSE){
				continue;
			}
			
			// Don't touch any import maps as they are meant to be loaded early.
			if(strpos($script['text'], 'importmap') !== FALSE){
				continue;
			}

			// We dont want to delay jQuery
			if(preg_match('/jquery\./U', $script['text'], $match)){
				continue;
			}

			// Excluding Scripts
			if($speedycache->options['delay_js_mode'] == 'all' && !empty($speedycache->options['delay_js_excludes'])){
				foreach($speedycache->options['delay_js_excludes'] as $to_delay){
					if(empty($to_delay)){
						continue;
					}

					if(strpos($script['text'], trim($to_delay)) !== FALSE){
						continue 2;
					}
				}
			}

			// Delay Selected Scripts
			if($speedycache->options['delay_js_mode'] == 'selected' && !empty($speedycache->options['delay_js_scripts'])){
				$script_found = false;
				foreach($speedycache->options['delay_js_scripts'] as $to_delay){
					if(empty($to_delay)){
						continue;
					}

					if(strpos($script['text'], trim($to_delay)) !== FALSE){
						$script_found = true;
						break;
					}
				}

				if(empty($script_found)){
					continue;
				}
			}

			$new_tag = self::updating_tag($script['text'], $is_inline);

			if(!empty($new_tag)){
				$content = str_replace($script['text'], $new_tag, $content);
			}
		}
		
		// Adds the script which loads the JS files on user interaction
		self::inject_js($content);

		return $content;

	}
	
	static function updating_tag($tag, $is_inline){
		global $speedycache;
	
		if(preg_match('/src=["\'](.*)["\']/U', $tag, $src)){
			return '<script type="speedycache/javascript" data-src="' . esc_url($src[1]) . '"></script>';
		}

		if($is_inline){
			// taking out the attributes
			preg_match_all('/<script([^>]+)?>/i', $tag, $matches);

			$attributes = [];
			// Parsing the attributes
			if(!empty($matches)){
				foreach($matches[1] as $attr_str){
					preg_match_all('/(\w+)(?:=["\']([^"\']*)["\'])?/i', trim($attr_str), $attrs, PREG_SET_ORDER);

					foreach($attrs as $attr){
						$attributes[$attr[1]] = $attr[2] ?? true;
					}
				}
			}

			// Adding our delayjs type
			$attributes['type'] = 'speedycache/javascript';
			
			// Rebulding the attributes
			$script_attr = '';
			foreach($attributes as $name => $value){
				$script_attr .= ' ' . esc_attr($name).'="'.esc_attr($value).'"';
			}

			return preg_replace('/<script([^>]+)?>/i', '<script'.$script_attr.'>', $tag);
		}
		
	}
	
	static function inject_js(&$content){
		$js = file_get_contents(SPEEDYCACHE_PRO_DIR . '/assets/js/delayjs.min.js');

		$js = '<script>'.$js.'</script>';
		$content = str_replace('</body>', $js . "\n</body>", $content);
	}
	
	static function find_tags($start_string, $end_string, $html = false){
		global $speedycache;

		if(!empty($html)){
			$data = $html;
		}

		$list = array();
		$start_index = false;
		$end_index = false;

		for($i = 0; $i < strlen($data); $i++){
			if(substr($data, $i, strlen($start_string)) == $start_string){
				if(!$start_index && !$end_index){
					$start_index = $i;
				}
			}

			if(empty($start_index) || $i < $start_index){
				continue;
			}

			if(substr($data, $i, strlen($end_string)) !== $end_string){
				continue;
			}
			
			$end_index = $i + strlen($end_string) - 1;
			$text = substr($data, $start_index, ($end_index - $start_index + 1));

			if($html === false){
				$tag = self::get_tags($start_index, $text, $end_index);

				if($tag !== FALSE){
					array_push($list, $tag);
				}
			}else{
				array_push($list, array('start' => $start_index, 'end' => $end_index, 'text' => $text));
			}

			$start_index = false;
			$end_index = false;
		}

		return $list;
	}
	
	// Adds Image dimensions to the images where height and width is not present
	// It helps in reducing the Cumulative Layout shift(CLS) as the browser knows how much space to allocate for the image.
	static function image_dimensions($content){
		
		if(!function_exists('getimagesize')){
			return $content;
		}
		
		// Get Images without height and width
		$images_regex = '<img(?:[^>](?!height=[\'\"](?:\S+)[\'\"]))*+>|<img(?:[^>](?!width=[\'\"](?:\S+)[\'\"]))*+>';

		preg_match_all('/'.$images_regex.'/Uis', $content, $image_matches);

		if(empty($image_matches)){
			return $content;
		}

		$images = $image_matches[0];
		$site_url = site_url();
		
		foreach($images as $image){

			// Get the SRC
			if(!preg_match( '/\s+src\s*=\s*[\'"](?<url>[^\'"]+)/i', $image, $src_match)){
				continue;
			}
			
			$url = $src_match['url'];

			// We will proccess image which is uploaded inside wp-content
			if(strpos($url, 'wp-content') === FALSE || strpos($url, '.svg') !== FALSE || strpos($url, $site_url) === FALSE){
				continue;
			}

			$url = str_replace($site_url, '', $url);
			$image_path = str_replace('/wp-content', '', WP_CONTENT_DIR) . $url;
	
			if(!file_exists($image_path)){
				continue;
			}

			$sizes = getimagesize($image_path);

			if(empty($sizes)){
				continue;
			}

			preg_match('/<img.*\sheight=[\'\"]?(?<height>[^\'\"\s]+)[\'\"]?.*>/i', $image, $initial_height);
			preg_match('/<img.*\swidth=[\'\"]?(?<width>[^\'\"\s]+)[\'\"]?.*>/i', $image, $initial_width);

			$dimensions_attr = '';

			if(empty($initial_height['height']) && empty($initial_width['width'])){
				$dimensions_attr = $sizes[3];
			}

			if(!empty($initial_height['height']) && empty($dimensions_attr)){
				if(!is_numeric($initial_height['height'])){
					continue;
				}

				$ratio = $initial_height['height'] / $sizes[1];

				$dimensions_attr = 'width="' . (int) round($sizes[0] * $ratio) . '" height="' . $initial_height['height'] . '"';
			}

			if(!empty($initial_width['width']) && empty($dimensions_attr)){
				if(!is_numeric( $initial_width['width'])){
					continue;
				}

				$ratio = $initial_width['width'] / $sizes[0];

				$dimensions_attr = 'width="' . $initial_width['width'] . '" height="' . (int) round($sizes[1] * $ratio) . '"';
			}
			
			$changed_image = preg_replace('/\s(height|width)=(?:[\'"]?(?:[^\'\"\s]+)*[\'"]?)?/i', '', $image);
			$changed_image = preg_replace('/<\s*img/i', '<img ' . $dimensions_attr, $changed_image);

			if(!empty($changed_image)){
				$content = str_replace($image, $changed_image, $content);
			}

		}
		
		return $content;
	}
	
	// Lazy Loads HTML elements.
	static function lazy_load_html($content){
		global $speedycache;

		$content = str_replace('</head>', '<style>' . implode(',', $speedycache->options['lazy_load_html_elements']) . '{content-visibility:auto;contain-intrinsic-size:1px 1000px;}</style></head>', $content);
		
		return $content;
	}
	
	static function preload_critical_images($content){
		global $speedycache;
		
		preg_match_all('#(<picture.*?)?<img([^>]+?)\/?>(?><\/picture>)?#is', $content, $images, PREG_SET_ORDER);

		if(empty($images)){
			return $content;
		}

		$count = 0;
		$preload_tags = '';
		foreach($images as $image){

			// Break once the Critical Image Count is reached.
			if($count >= $speedycache->options['critical_image_count']){
				break;
			}

			if(strpos($image[0], 'secure.gravatar.com') !== FALSE){
				continue;
			}

			// NOTE:: Will remove this in future, firt we will just support <IMG> tag
			if(strpos($image[0], '<picture>') !== FALSE){
				continue;
			}

			// Excluding base64 image from preloading.
			if(strpos($image[0], ';base64') !== FALSE){
				continue;
			}

			$atts_array = wp_kses_hair($image[2], wp_allowed_protocols());
			$atts = [];

			foreach($atts_array as $name => $attr){
				$atts[$name] = $attr['value'];
			}

			if(empty($atts['src'])){
				continue;
			}
			
			// To preload unique images.
			if(strpos($preload_tags, $atts['src']) === FALSE){
				$preload_tags .= '<link rel="preload" as="image" href="'.esc_attr($atts['src']).'"'. (!empty($atts['srcset']) ? ' imagesrcset="'. esc_attr($atts['srcset']).'"' : '') . (!empty($atts['sizes']) ? 'imagesizes="'.esc_attr($atts['sizes']).'"' : '') . ' />';
			}

			$count++;
		}

		if(empty($preload_tags)){
			return $content;
		}

		// If title tag is not there then don't add the preload.
		if(strpos($content, '</title>') === FALSE){
			return $content;
		}

		$content = str_replace('</title>', '</title>' . $preload_tags, $content);

		return $content;
	}
	
	static function pre_connect_hint($urls, $relation_type){
		global $speedycache;

		if($relation_type !== 'preconnect'){
			return $urls;
		}

		foreach($speedycache->options['pre_connect_list'] as $url) {
			if(empty($url) || empty($url['resource'])){
				continue;
			}
			
			$preconnect = array('href' => $url['resource']);

			if(!empty($url['crossorigin'])){
				$preconnect['crossorigin'] = 'crossorigin'; 
			}
			
			$urls[] = $preconnect;
			
		}

		return $urls;
	}

	static function preload_resource(){
		global $speedycache;

		if(empty($speedycache->options['preload_resource_list']) || !is_array($speedycache->options['preload_resource_list'])){
			return;
		}

		foreach($speedycache->options['preload_resource_list'] as $preload_resource){
			if(empty($preload_resource['resource']) || empty($preload_resource['type'])){
				continue;
			}

			$crossorigin = '';
			if(!empty($preload_resource['crossorigin'])){
				$crossorigin = 'crossorigin';
			}

			echo '<link rel="preload" href="'.esc_url_raw($preload_resource['resource']).'" as="'.esc_attr($preload_resource['type']).'" '.esc_attr($crossorigin) .'/>';
		}
	}

}
PK��f\?����
unusedcss.phpnu�[���<?php

/*
* SPEEDYCACHE
* https://speedycache.com/
* (c) SpeedyCache Team
*/

namespace SpeedyCache;

if(!defined('ABSPATH')){
	die('Hacking Attempt');
}

class UnusedCss extends CommonCss{

	static function generate($urls){
		global $speedycache;

		$time = time() + 50;
		set_time_limit(60);
		
		$api = self::get_endpoint(true);
		
		if(empty($urls)){
			self::log('speedycache_unused_css_logs', 'URL not found');
			return false;
		}

		if(empty($speedycache->license['license'])){
			self::log('speedycache_unused_css_logs', 'License Not found, please link your License');
			return false;
		}

		foreach($urls as $url){
			// Handeling php timeout here
			if($time < time()){
				$urls = array_diff($urls, $attempted_url);
				self::schedule('speedycache_unused_css', $urls);
				return;
			}

			$url = trim($url, '/');
			$license = strpos($speedycache->license['license'], 'SPDFY') !== 0 ? '' : $speedycache->license['license'];
			$attempted_url[] = $url;

			$response = wp_remote_post($api, array(
				'timeout' => 30,
				'body' => array(
					'url' => $url,
					'license' => $license,
					'excludes' => !empty($speedycache->options['unused_css_exclude_stylesheets']) ? json_encode($speedycache->options['unused_css_exclude_stylesheets']) : '',
					'include_selectors' => !empty($speedycache->options['speedycache_unusedcss_include_selector']) ? json_encode($speedycache->options['speedycache_unusedcss_include_selector']) : '',
				),
				'sslverify' => false,
			));

			if(is_wp_error($response)){
				$error = $response->get_error_message();
				self::log('speedycache_unused_css_logs', $response->get_error_message(), $url);
				continue;
			}

			$body = json_decode(wp_remote_retrieve_body($response), true);

			if(empty($body)){
				$error = __('The response recieved is empty.', 'speedycache');
				self::log('speedycache_unused_css_logs', __('The response recieved is empty.', 'speedycache'), $url);
				continue;
			}

			if(empty($body['success'])){
				$error = !empty($body['message']) ? wp_strip_all_tags($body['message']) : __('Unable to extract UsedCSS', 'speedycache');
				self::log('speedycache_unused_css_logs', !empty($body['message']) ? wp_strip_all_tags($body['message']) : __('Unable to extract UsedCSS', 'speedycache'), $url);
				continue;
			}

			if(empty($body['css']) || strlen($body['css']) < 20){
				$error = __('Was unable to generate Used CSS', 'speedycache');
				self::log('speedycache_unused_css_logs', __('Was unable to generate Used CSS', 'speedycache'), $url);
				continue;
			}

			self::update_css($url, $body['css']);

			self::log('speedycache_unused_css_logs', 'success', $url); //Updates the log on success
			
			if(!empty($error)){
				return $error;
			}

			return true;
		}
	}
	
	// Adds the generated css and asynchronyses the css includes
	static function update_css($url, $css){
		global $speedycache;

		if(empty($url)){
			return false;
		}
		
		if(empty($css)){
			return false;
		}

		$css = '<style id="speedycache-used-css">'. "\n". wp_strip_all_tags($css) . '</style>';

		$url = parse_url($url);
		$uri = !empty($url['path']) ?  $url['path'] : '';
		$cache_loc = $uri . '/index.html';

		if(empty($cache_loc)){
			return;
		}
		
		if(!empty($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT'] === 'SpeedyCacheTest'){
			$cache_path = speedycache_cache_path('test' . $cache_loc);
		} else {
			$cache_path = speedycache_cache_path('all' . $cache_loc);
		}
		
		$cache_path = rtrim($cache_path, '/');
		
		// For Desktop
		\SpeedyCache\UnusedCss::update_cached($cache_path, $css);

		if(!empty($speedycache->options['mobile_theme']) && $_SERVER['HTTP_USER_AGENT'] !== 'SpeedyCacheTest'){
			$cache_mobile = speedycache_cache_path('mobile-cache' . $cache_loc);

			// For Mobile Cache
			if(file_exists($cache_mobile)){
				\SpeedyCache\UnusedCss::update_cached($cache_mobile, $css);
			}
		}
	}

	// Updates the content of the cached file
	static function update_content($content, $css){
		global $speedycache;

		// Includes the Used CSS file in the head.
		$content = str_replace('</title>', '</title>' . $css, $content);

		$css_links = '/(?=<link[^>]*\s(rel\s*=\s*[\'"]stylesheet["\']))<link[^>]*\shref\s*=\s*[\'"]([^\'"]+)[\'"](.*)>/iU';
		
		preg_match_all($css_links, $content, $matches, PREG_SET_ORDER, 0);
		
		if(empty($matches)){
			return $content;
		}
		
		$exclude_stylesheets = array(
			'/widget-google-reviews/assets/css/public-main.css',
			'/uploads/elementor/css/post-',
			'/uploads/oxygen/css/',
			'/uploads/bb-plugin/cache/',
			'/et-cache/',
			'woocommerce-smallscreen.css',
			'dashicons.min.css',
			'animations.min.css',
			'/uploads/generateblocks/',
			'woocommerce-mobile.min.css',
			'fonts.googleapis.com',
		);
		
		// Mergeing user added excludes which the one we have.
		if(!empty($speedycache->options['unused_css_exclude_stylesheets']) && !is_array($speedycache->options['unused_css_exclude_stylesheets'])){
			$exclude_stylesheets = array_merge($exclude_stylesheets, $speedycache->options['unused_css_exclude_stylesheets']);
		}
		
		$noscript_wrap = '';
		
		foreach($matches as $tag){

			foreach($exclude_stylesheets as $style){
				if(strpos($tag[0], $style) !== FALSE){
					continue 2;
				}
			}
			
			// We dont want to delay te Used CSS file
			if(strpos($tag[0], 'unused-css') !== FALSE){
				continue;
			}

			// Removing the styles after getting unused css
			if(!empty($speedycache->options['unusedcss_load']) && $speedycache->options['unusedcss_load'] === 'remove'){
				$content = str_replace($tag[0], '', $content);		
			} elseif(!empty($speedycache->options['unusedcss_load']) && $speedycache->options['unusedcss_load'] === 'interaction'){
				$new_tag = preg_replace('#href=([\'"]).+?\1#', 'data-spcdelay="' . $tag[2] . '"',$tag[0]);
			
				$content = str_replace($tag[0], $new_tag, $content);
				
				$noscript_wrap .= $tag[0];
			} else {
				// Loading the Unused CSS Async
				$preload = str_replace('stylesheet', 'preload', $tag[1]);
				$onload = preg_replace('~' . preg_quote($tag[3], '~') . '~iU', ' as="style" onload="" ' . $tag[3] . '>', $tag[3]);

				$new_tag = str_replace($tag[3] . '>', $onload, $tag[0]);
				$new_tag = str_replace($tag[1], $preload, $new_tag);
				$new_tag = str_replace('onload=""', 'onload="this.onload=null;this.rel=\'stylesheet\'"', $new_tag);
				$new_tag = preg_replace('/(id\s*=\s*[\"\'](?:[^\"\']*)*[\"\'])/i', '', $new_tag);

				$content = str_replace($tag[0], $new_tag, $content);
				
				$noscript_wrap .= $tag[0];
			}
		}
		
		if(!empty($noscript_wrap)){
			$noscript_wrap .= '</noscript>';
			
			if(!empty($speedycache->options['unusedcss_load']) && $speedycache->options['unusedcss_load'] === 'interaction'){
				$noscript_wrap .= '<script type="text/javascript" id="speedycache-delayed-styles">!function(){const e=["keydown","mousemove","wheel","touchmove","touchstart","touchend"];function t(){document.querySelectorAll("link[data-spcdelay]").forEach(function(e){e.setAttribute("href",e.getAttribute("data-spcdelay"))}),e.forEach(function(e){window.removeEventListener(e,t,{passive:!0})})}e.forEach(function(e){window.addEventListener(e,t,{passive:!0})})}();</script>';
			}
			
			$noscript_wrap = '<noscript>' . $noscript_wrap;
		
			$content = str_replace($noscript_wrap, '', $content);
			
			$content = str_replace('</body>', $noscript_wrap . '</body>', $content);
		}

		return $content;
	}
}
PK��f\|!UC� � objectcache.phpnu�[���<?php

namespace SpeedyCache;

if(!defined('ABSPATH')){
	die('HACKING ATTEMPT!');
}

class ObjectCache{
	static $oc_driver = 'Redis';
	static $port = '6379';
	static $host = '127.0.0.1';
	static $conn;
	static $ttl = 360; // in seconds
	static $is_multisite = false;
	static $blog_id;
	static $prefix = 'speedycache';
	static $conf_file = WP_CONTENT_DIR . '/.speedycache-object.dat';
	static $conf;
	static $instance;
	static $persistent;
	static $async_flush;
	static $serialize;
	static $non_cache_group;
	
	static function get_instance(){
		if(self::$instance){
			return self::$instance;
		}

		self::$instance = new self();
		
		try{
			self::boot();
		} catch(\Exception $e){
			// Don't need to log here as the error has been already logged before, this it just to prevent error
		}

		return self::$instance;
	}

	static function boot(){
		self::$conf = self::get_conf();

		self::$host = !empty(self::$conf['host']) ? self::$conf['host'] : '127.0.0.1';
		self::$port = !empty(self::$conf['port']) ? self::$conf['port'] : '6379';
		self::$ttl = !empty(self::$conf['ttl']) ? (int) self::$conf['ttl'] : 360;
		self::$persistent = !empty(self::$conf['persistent']) ? true : false;
		self::$async_flush = !empty(self::$conf['async_flush']) ? true : false;
		self::$serialize = !empty(self::$conf['serialization']) ? self::$conf['serialization'] : 'none';
		$compress = !empty(self::$conf['compress']) ? self::$conf['compress'] : 'COMPRESSION_NONE';
		self::$non_cache_group = (!empty(self::$conf['non_cache_group']) && is_array(self::$conf['non_cache_group'])) ? self::$conf['non_cache_group'] : [];
		self::$prefix = !empty(self::$conf['hashed_prefix']) ? self::$conf['hashed_prefix'] : '';

		if(self::$host === 'localhost'){
			self::$host = '127.0.0.1';
		}
		
		if(empty(self::connect())){
			error_log('SpeedyCache: Unable to connect to Redis');
			return false;
		}
		
		try{
			
			switch(self::$serialize){
				case 'SERIALIZER_PHP':
					self::$conn->setOption(self::$conn::OPT_SERIALIZER, self::$conn::SERIALIZER_PHP);
					break;
					
				case 'SERIALIZER_IGBINARY':
					self::$conn->setOption(self::$conn::OPT_SERIALIZER, self::$conn::SERIALIZER_IGBINARY);
					break;
					
				default:
					self::$conn->setOption(self::$conn::OPT_SERIALIZER, self::$conn::SERIALIZER_NONE);
					break;
			}

			switch($compress){
				case 'COMPRESSION_NONE':
					self::$conn->setOption(self::$conn::OPT_COMPRESSION, self::$conn::COMPRESSION_NONE);
					break;
					
				case 'COMPRESSION_ZSTD':
					self::$conn->setOption(self::$conn::OPT_COMPRESSION, self::$conn::COMPRESSION_ZSTD);
					self::$conn->setOption(self::$conn::OPT_COMPRESSION_LEVEL, (string) -5);
					break;
					
				case 'COMPRESSION_LZ4':
					self::$conn->setOption(self::$conn::OPT_COMPRESSION, self::$conn::COMPRESSION_LZ4);
					break;

				case 'COMPRESSION_LZF':
					self::$conn->setOption(self::$conn::OPT_COMPRESSION, self::$conn::COMPRESSION_LZF);
					break;
					
			}

		} catch(\RedisException $e){
			error_log($e->getMessage());
			throw new \Exception($e->getMessage()); // To show on settings page
			return false;
		}

	}
	
	static function get_conf(){
		if(!file_exists(self::$conf_file)){
			return [];
		}

		$conf = file_get_contents(self::$conf_file);
		
		if(empty($conf)){
			error_log('SpeedyCache: Conf file was empty');
			return;
		}

		return json_decode($conf, true);
	}
	
	// Creates a unique id based on blogID, group and key
	static function id($key, $group){
		return self::$prefix  . ':' . self::$blog_id.$group . ':' . $key;
	}
	
	// Updates object-cache.php file at wp-content/object-cache.php
	static function update_file(){
		$file = WP_CONTENT_DIR . '/object-cache.php';
		
		if(!file_exists($file)){
			touch($file);
		}
		
		$code = '<?php

if(!defined("WPINC")){
	die();
}

if(!defined("SPEEDYCACHE_OBJECT_CACHE")){
	define("SPEEDYCACHE_OBJECT_CACHE", true);
}

$plugin_dir = (defined("WP_PLUGIN_DIR") ? WP_PLUGIN_DIR : WP_CONTENT_DIR . "/plugins") . "/speedycache-pro";
$conf_file = WP_CONTENT_DIR . "/.speedycache-object.dat";
$lib_file = $plugin_dir . "/main/object-cache-lib.php";


if(file_exists($plugin_dir) && file_exists($conf_file) && file_exists($lib_file)){
	$spdf_config = file_get_contents($conf_file);
	$spdf_config = json_decode($spdf_config, true);
	
	if (! SPEEDYCACHE_OBJECT_CACHE || (empty($spdf_config["admin"]) && defined("WP_ADMIN"))){
		wp_using_ext_object_cache(false);
	}else if (file_exists($lib_file)) {
		include_once $lib_file;
	}
}';
		file_put_contents($file, $code);

	}
	
	static function connect(){

		if(!empty(self::$conn)){
			return true;
		}
		
		if(!class_exists(self::$oc_driver)){
			error_log('SpeedyCache: The defined driver ' . self::$oc_driver . 'not present');
			return false;
		}
		
		$failed = false;
		$is_socket = false;
		
		if(strpos(self::$host, '.sock')){
			$is_socket = true;
		}

		$persistent = !empty(self::$persistent) ? 'pconnect' : 'connect';

		if(self::$oc_driver == 'Redis'){

			try {
				self::$conn = new \Redis();
				
				if($is_socket){
					self::$conn->{$persistent}(self::$host);
				} else {
					self::$conn->{$persistent}(self::$host, self::$port);
				}
				
				if(!empty(self::$conf['username']) && !empty(self::$conf['password'])){
					self::$conn->auth(['user' => self::$conf['username'], 'pass' => self::$conf['password']]);
				} else if(!empty(self::$conf['password'])){
					self::$conn->auth(self::$conf['password']);
				}

				// Testing if connection worked
				$res = self::$conn->ping();
				
				if(empty($res) && $res !== '+PONG'){
					$failed = true;
				}
				
				if(!empty($failed)){
					self::$conn = null;
					return false;
				}

				self::$conn->select((int) (!empty(self::$conf['db-id']) ? self::$conf['db-id'] : 0));

			}catch(\RedisException $e){
				error_log('SpeedyCache' . $e->getMessage());
				throw new \Exception($e->getMessage()); // To show on settings page
				return false;
			}
			catch(\Exception $e){
				error_log('SpeedyCache  ->>' . $e->getMessage());
				throw new \Exception($e->getMessage()); // To show on settings page
			}
		}
		
		return true;

	}
	
	static function set($key, $data, $expire = 0){
		
		if(empty(self::$conn)){
			return false;
		}

		$ttl = $expire ?: self::$ttl;
		
		if((is_array($data) || is_object($data)) && self::$serialize === 'none'){
			$data = serialize($data);
		}
		
		$key = self::$prefix . $key;

		try{
			$res = self::$conn->setEx($key, $ttl, $data);
		} catch (\RedisException $ex) {
			error_log($ex->getMessage());
		}
	}
	
	static function get($key){
		
		if(empty(self::$conn)){
			return false;
		}
		
		$key = self::$prefix . $key;

		try{
			return self::$conn->get($key);
		}catch(\RedisException $e){
			error_log($e->getMessage());
			return false;
		}
	}
	
	static function exists($key){
		
		if(empty(self::$conn)){
			return false;
		}
		
		$key = self::$prefix . $key;

		try{
			return self::$conn->exists($key);
		}catch(\RedisException $e){
			error_log($e->getMessage());
			return false;
		}
	}
	
	static function delete($key){
		
		$del = self::$async_flush ? 'unlink' : 'del';

		if(empty(self::$conf['enable'])){
			return false;
		}
		
		if(empty(self::$conn)){
			return false;
		}

		$key = self::$prefix . $key;

		try{
			self::$conn->{$del}($key);
		} catch(\RedisException $e){
			error_log($e->getMessage());
			return false;
		}
	}
	
	static function get_memory(){
		self::boot();
		
		if(empty(self::$conn)){
			return 'None';
		}
		
		try{
			$memory = self::$conn->info('memory');
		} catch(\RedisException $e){
			error_log($e->getMessage());
			return 'None';
		}
		
		if(!empty($memory['used_memory'])){
			return size_format($memory['used_memory']);
		}

		return 'None';
	}
	
	// Flushes whole database
	static function flush_db($sync = true){
		if(empty(self::$conf['enable'])){
			return false;
		}

		if(empty(self::$conn)){
			return false;
		}
		
		try{
			return self::$conn->flushDb($sync);
		} catch(\RedisException $e){
			error_log($e->getMessage());
			return false;
		}
	}

}


PKv�f\V�..	promo.phpnu�[���PKv�f\�s?��K�K	gadmin.phpnu�[���PKv�f\�͂�"�"tScdn.phpnu�[���PKv�f\�+�||Lvjs.phpnu�[���PKv�f\tdy�zz��gravatar.phpnu�[���PKv�f\@��q����install.phpnu�[���PKv�f\G[��TiTi��settings.phpnu�[���PKv�f\�\j�	�	>ajax.phpnu�[���PKv�f\�>J^�#�#e%util.phpnu�[���PKv�f\Т k�<�<	)Icache.phpnu�[���PKv�f\B���!�!��htaccess.phpnu�[���PKv�f\�	����advanced-cache.phpnu�[���PKv�f\��.]6]6
:�delete.phpnu�[���PKv�f\w�%����css.phpnu�[���PKv�f\�Acy
y
�preload.phpnu�[���PK��f\xh�ww�license.phpnu�[���PK��f\�Z>P%P%J0email-reports.phpnu�[���PK��f\��P*P*
�Uexport.phpnu�[���PK��f\�_��wwe�gosmtp-init.phpnu�[���PK��f\����%!%!�weekly_email_reports.phpnu�[���PK��f\k�~..��mailer/outlook/auth.phpnu�[���PK��f\����$�$��mailer/outlook/outlook.phpnu�[���PK��f\q���]�]!�mailer/amazonses/emailservice.phpnu�[���PK��f\He�n+n+(7Tmailer/amazonses/emailservicerequest.phpnu�[���PK��f\��Dw�K�K(�mailer/amazonses/emailservicemessage.phpnu�[���PK��f\
��"��?�mailer/amazonses/amazonses.phpnu�[���PK��f\(ގ8�+�+%�mailer/gmail/gmail.phpnu�[���PK��f\_�[  Qmailer/gmail/auth.phpnu�[���PK��f\Gt�OR>R>�!mailer/zoho.phpnu�[���PK��f\p��s�s�G`plugin-update-checker.phpnu�[���PK��f\� !_g:g:
4smtp-logs.phpnu�[���PK��f\����{{
�nlogger.phpnu�[���PK�f\����(b(b\�website.phpnu�[���PK�f\�nx������shortcode_functions.phpnu�[���PK�f\�SL�'='=�post_metas.phpnu�[���PK�f\ag~l''f�getting_started.phpnu�[���PK�f\X�;kk
�functions.phpnu�[���PK�f\���bb�customizer-controls.phpnu�[���PK�f\~y�Y�Ya�woocommerce.phpnu�[���PK�f\�e_bb�Aparse-shortcodes.phpnu�[���PK�f\X�Ն;�;
6Nblocks.phpnu�[���PK�f\��;�D�D���template.phpnu�[���PK�f\�jd��	v(	class.phpnu�[���PK�f\ff��|?	shortcodes.phpnu�[���PK�f\E 3m#m#�Xnav_walker.phpnu�[���PK�f\�[����
�|import.phpnu�[���PK�f\�4�??gcustomizer.phpnu�[���PK�f\��?���Sreplace-media.phpnu�[���PK�f\ 	��V�V�ofont-options.phpnu�[���PK�f\�I�v#v#
��live-body.phpnu�[���PK�f\��66��live.phpnu�[���PKv�f\����**� imageseo.phpnu�[���PKv�f\�6�%	�	�N-settings/statistics.phpnu�[���PKv�f\�O��������settings/titles.phpnu�[���PKv�f\��1����j�settings/analytics.phpnu�[���PKv�f\�4+�EE;�settings/dashboard.phpnu�[���PKv�f\HrҰ����settings/tools.phpnu�[���PKv�f\Gjqβ
�
�settings/util.phpnu�[���PKv�f\�^-�O�O�settings/onboarding.phpnu�[���PKv�f\��ֽ8�8�Ssettings/instant.phpnu�[���PKv�f\��̹�N�N��settings/sitemap.phpnu�[���PKv�f\s������settings/advanced.phpnu�[���PKv�f\���1�f�f�settings/social.phpnu�[���PKv�f\;�4rr�socialmetas.phpnu�[���PKv�f\'��:wtableofcontent.phpnu�[���PKv�f\D�q�l#l#��instantindexing.phpnu�[���PKv�f\u���f�f2�googleanalytics.phpnu�[���PKv�f\wNg6�c�c`generatesitemap.phpnu�[���PKv�f\��� ��d{columns.phpnu�[���PKv�f\������>�metaboxes/analysis.phpnu�[���PKv�f\+mzz0mmetaboxes/settings.phpnu�[���PKv�f\��i
i
�primarycategory.phpnu�[���PKv�f\X��xll��advanced.phpnu�[���PKv�f\ON��R�R�D�titlesmetas.phpnu�[���PK��f\B�AZ���/mailer/sparkpost.phpnu�[���PK��f\�!:FF�Fmailer/mail.phpnu�[���PK��f\
IC-��UJmailer/smtpcom.phpnu�[���PK��f\W�q]��"cmailer/smtp.phpnu�[���PK��f\.ԃ�tttmailer/sendgrid.phpnu�[���PK��f\!Gkaa��mailer/sendinblue.phpnu�[���PK��f\��+��]�mailer/maileroo.phpnu�[���PK��f\�(�|MM0�mailer/mailgun.phpnu�[���PK��f\[�N�::��mailer/postmark.phpnu�[���PK��f\ '�<pp<�mailer/sendlayer.phpnu�[���PK��f\%����2�2�mailer/loader.phpnu�[���PK��f\5w��o_o_	*media.phpnu�[���PK��f\�Sg''	��setup.phpnu�[���PK��f\�f���T�T
��intros.phpnu�[���PK��f\ku��[#[#$ai.phpnu�[���PK��f\Y�����)manage-plugins.phpnu�[���PK��f\5?3&�����;onboarding.phpnu�[���PK��f\&3���disable-comments.phpnu�[���PK��f\��i��(�(	Ebloat.phpnu�[���PK��f\_YзJJ:googlefonts.phpnu�[���PK��f\�|7ll
�Pcommoncss.phpnu�[���PK��f\��f�)	)	D_youtube.htmlnu�[���PK��f\���j���hcli.phpnu�[���PK��f\`J�*��bometaboxpro.phpnu�[���PK��f\���=���wdb.phpnu�[���PK��f\�,Z������renderblocking.phpnu�[���PK��f\���statistics.phpnu�[���PK��f\�dd�#prooptimizations.phpnu�[���PK��f\��ڨFF
�,mobile.phpnu�[���PK��f\V���pp	3image.phpnu�[���PK��f\ �[[
�Kindex.htmlnu�[���PK��f\E�
�$�$ALcriticalcss.phpnu�[���PK��f\�����{qpremium.phpnu�[���PK��f\��Mn+n+<sobject-cache-lib.phpnu�[���PK��f\<1D���logs.phpnu�[���PK��f\���Fn�n�Լsettingspage.phpnu�[���PK��f\�@��:�:�C lazyload.phpnu�[���PK��f\}��߸߸�~ enhanced.phpnu�[���PK��f\?����
�7!unusedcss.phpnu�[���PK��f\|!UC� � �U!objectcache.phpnu�[���PKrr�#�v!