<?php


/**
 * add to menu
*/
 
add_action('admin_menu', 'add_init_func_data');

function add_init_func_data(){
	global $option_name;
    add_menu_page(
        __('Configure the site and add basic data', 'THEME_DOMAIN'), // Page Title
        __('Configure first data', 'THEME_DOMAIN'),                  // Menu Title
        'delete_plugins',                                            // Capability
        'add_init_func_data',                                        // Menu Slug
        'DS1__add_init_func_data',                                   // Callback Function
        'dashicons-admin-generic',                                   // Icon (اختياري)
        61                                                           // Position (اختياري)
    );
}


// function DS1__add_init_func_update_values() {
//     $submission 	= ( isset($_POST['data']) && isset( $_POST['data']["data"] )) ? $_POST['data']["data"] : [];
//     $submission 	= ($submission && ! is_array($submission)) ? json_decode($submission) : $submission;

// 	// echo json_encode($submission);
// 	// wp_die();

// 	if(!$submission ) {
// 		$final_st = [
// 			"status"=> false,
// 		];
// 		echo json_encode($final_st);
// 		wp_die();
// 	}
	
// 	// $business_field = (isset($submission["business_field"])) ? $submission["business_field"] 	: 'other';
// 	$builder 		= (isset($submission["builder"])) ? $submission["builder"] : 'other';
// 	$default_language 	= (isset($submission["default_language"])) ? $submission["default_language"] 	: 'en';
// 	$default_description 	= (isset($submission["default_description"])) ? $submission["default_description"] 	: '';
// 	// $acf_installed 	= (isset($submission["acf_installed"])) ? $submission["acf_installed"] 	: true;

// 	define("RM_SERRINGS_SUBMISSIONS", $submission);
// 	define("DEFAULT_LANGUAGE", $default_language);
// 	define("DEFAULT_DESCRIPTION", $default_description);
	
//     $final_result = [];
// 	if(isset($submission["general_options"]) && $submission["general_options"] == "true" ) {
// 		$final_result[] = ds1_init_theme_update_options();
// 		$final_result[] = ds1_init_add_theme_role();
// 		$final_result[] = ds1_init_edit_y_();
// 		$final_result[] = ds1_init_remove_comments();
// 		$final_result[] = ds1_init_reomve_plugins_st_and_themes();
// 		$final_result[] = ds1_init_add_code_to_config();
// 		ds1_init_add_code_to_htaccess();
// 	}

	
// 	if(isset($submission["create_main_menu"]) && $submission["create_main_menu"] == "true" ) {
// 		$final_result[] = ds1_init_theme_create_main_menu();
// 	}

// 	if(isset($submission["create_footer_menu"]) && $submission["create_footer_menu"] == "true" ) {
// 		$final_result[] = ds1_init_theme_create_footer_menu();
// 	}
	

// 	if(isset($submission["cats_and_terms"]) && $submission["cats_and_terms"] == "true" ) {
// 		$final_result[] = ds1_init_theme_terms_actions();
// 	}

// 	if(isset($submission["default_posts_news"]) && $submission["default_posts_news"] == "true" ) {
// 		$final_result[] = ds1_init_theme_create_posts();
// 	}


// 	if(isset($submission["default_posts_pages"]) && $submission["default_posts_pages"] == "true" ) {
// 		$final_result[] = ds1_init_theme_create_pages();
// 	}


// 	if(isset($submission["default_posts_events"]) && $submission["default_posts_events"] == "true" ) {
 
// 		$final_result[] = ds1_init_theme_create_events();
// 	}

    

// 	if(isset($submission["default_posts_realestate"]) && $submission["default_posts_realestate"] == "true" ) {
// 		$final_result[] = ds1_init_theme_create_realestate();
// 	}
    
//     if(isset($submission["cf7"]) && $submission["cf7"] == "true" ) {
//         $final_result[] = ds1_init_theme_cf7();
//     }

//     if(isset($submission["oxygen_templates"]) && $submission["oxygen_templates"] == "true" && $builder == "oxygen" ) {
//         $final_result[] = ds1_oxygen_default_templates();
//         $final_result[] = ds1_oxygen_options();
//     }

//     if(isset($submission["default_user_webmanager"]) && $submission["default_user_webmanager"] == "true" ) {
//         $user_data = (isset($submission['default_user_webmanager_options'] ) ) ? $submission['default_user_webmanager_options'] : [];

//         $username 	= (isset($user_data['username'] ) && !empty($user_data['username'])) ? $user_data['username'] : 'manager';
//         $email 		= (isset($user_data['email'] ) && !empty($user_data['email'])) ? $user_data['email'] : 'sitemanager@'.$web_domain;
//         $password 	= (isset($user_data['password'] ) && !empty($user_data['password'])) ? $user_data['password'] : generateRandomString(8);
        
//         $final_result[] = ds1_init_theme_add_user($username, $email, $password, 'webmanager');
//     }

    
//     if(isset($submission["default_user_siteadmin"]) && $submission["default_user_siteadmin"] == "true" ) {
//         $user_data = (isset($submission['default_user_siteadmin_options'] ) ) ? $submission['default_user_siteadmin_options'] : [];

//         $username 	= (isset($user_data['username'] ) && !empty($user_data['username'])) ? $user_data['username'] : 'siteadmin';
//         $email 		= (isset($user_data['email'] ) && !empty($user_data['email'])) ? $user_data['email'] : 'siteadmin@'.$web_domain;
//         $password 	= (isset($user_data['password'] ) && !empty($user_data['password'])) ? $user_data['password'] : generateRandomString(8);
        
//         $final_result[] = ds1_init_theme_add_user($username, $email, $password);
//     }


//     $final_st = [
//         "status"=> true,
//     ];
//     echo json_encode($final_st);
//     wp_die();
// }
// add_action( 'wp_ajax_DS1__add_init_update_value', 'DS1__add_init_func_update_values' );
// add_action( 'wp_ajax_DS1__add_init_nopriv_update_value', 'DS1__add_init_func_update_values' );




function DS1__add_init_func_data() {
    $admin_url = get_admin_url();
?>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/4.6.1/css/bootstrap.min.css" integrity="sha512-T584yQ/tdRR5QwOpfvDfVQUidzfgc2339Lc8uBDtcp/wYu80d7jwBgAxbyMh0a9YM9F8N3tdErpFI8iaGx6x5g==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/4.6.1/js/bootstrap.min.js" integrity="sha512-UR25UO94eTnCVwjbXozyeVd6ZqpaAE9naiEUBK/A+QDbfSTQFhPGj5lOR6d8tsgbBk84Ggb5A3EkjsOgPRPcKA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>


<link rel="stylesheet" href="https://cdn.form.io/formiojs/formio.full.min.css">
    <!-- <script src="https://cdn.form.io/js/formio.embed.js"></script> -->
	<script src="https://cdn.form.io/formiojs/formio.full.min.js"></script>

    <div class="container">
        <?php
            include('body-parts/general-settings.php');
            
            include('body-parts/plugins.php');
        
            include('body-parts/main-templates.php');
        
            include('body-parts/main-pages.php');
        
            include('body-parts/main-cf7.php');

            include('body-parts/main-users.php');

            include('body-parts/taxonomy.php');

            include('body-parts/main-products.php');

            include('body-parts/general-menus.php');

            include('body-parts/review_and_plugins2.php');
        ?>

        
        <div class="alert alert-primary" role="alert" data-toggle="collapse" data-target="#rmflush" aria-expanded="false" aria-controls="rmflush">
            ريفرش الروابط - تفعيله بعد الانتهاء من التعديلات - افتح الرابط التالي وفقط اعمل تحديث بدون اى تعديل
        </div>
        <div class="collapse" id="rmflush">
        <a class="btn btn-primary btn-sm" href="<?php echo $admin_url; ?>options-permalink.php" role="button" target="_blank">ريفرش للروابط</a>
        </div>

    </div>
	





	<script>
        jQuery('.allcb').change(function () {
            jQuery(this).closest('table').find('tbody tr td input[type="checkbox"]').prop('checked', jQuery(this).prop('checked'));
        });

        jQuery(function () {
            jQuery('[data-toggle="popover"]').popover()
        })





	</script>

	<style>
        .list-group-item, .alert.alert-primary{
            direction: rtl; 
            text-align: right;
        }
        .popover-body {
            white-space: pre-wrap;
        }

        /* .popover-body b {
            color: #c60808;
        } */
        .popover-body em {
            color: #c60808;
            font-weight: bolder;
        }




		input[type=date], input[type=datetime-local], input[type=datetime], input[type=email], input[type=month], input[type=number], input[type=password], input[type=search], input[type=tel], input[type=text], input[type=time], input[type=url], input[type=week] {
			margin: auto;
			min-height: auto;
		}

		.formio-form > .form-group.formio-component-checkbox {
			background: #f1f1f1;
			margin-top: 25px;
		}
		.formio-form > .form-group.formio-component-checkbox .form-check-label {
			margin-bottom: 0;
			display: block;
			padding: 10px;
		}
        
		.formio input[type=checkbox], .formio input[type=radio] {
			margin-top: 0.3rem;
            margin-inline: -1.25rem 10px !important;
		}
		.formio-component-container {
			margin-bottom: 60px;
		}
		.formio-component-container.formio-hidden {
			margin-bottom: 0;
		}
	</style>
<?php
	
}