/*
Theme Name: Wahid Group
Theme URI: https://wahidgroup.org/
Author: Wahid Group
Author URI: https://wahidgroup.org/
Description: With its clean, minimal design and powerful feature set, We enable our every business to build stylish and sophisticated WordPress websites. This is a masterpiece of design and functionality. It features a range of valuable patterns, including hero and portfolio sections, prominent call-to-action buttons, and customer testimonials. Whether you’re building a website for your business, personal brand, or creative project, This is perfect for us to launch quickly and efficiently.
Tags: block-patterns, block-styles, custom-colors, custom-logo, custom-menu, editor-style, full-site-editing, one-column, template-editing, threaded-comments, translation-ready, wide-blocks
Requires at least: 6.7
Tested up to: 6.7
Requires PHP: 7.2
Version: 1.0.10
License: GNU General Public License v3
License URI: https://www.gnu.org/licenses/gpl-3.0.html
Text Domain: wahidgroup
*/


/* Defaults
---------------------------------------- */

*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	scroll-behavior: smooth;
}

a,
button,
input:focus,
input[type="button"],
input[type="submit"],
textarea:focus,
.wp-element-button {
	transition: all 0.2s ease-in-out;
}

a,
a:focus,
a:hover,
a:not(.wp-element-button) {
	text-decoration-thickness: 1px;
}

b,
strong,
th {
	font-weight: var(--wp--custom--font-weight--medium);
}

mark {
	background: linear-gradient(90deg, var(--wp--preset--color--primary) 0%, var(--wp--preset--color--primary) 100%);
	background-position: 0 85%;
	background-repeat: repeat-x;
	background-size: 100% 15%;
}

/* -- Forms -- */

input,
select,
textarea {
	background-color: var(--wp--preset--color--base);
	border: 1px solid var(--wp--preset--color--contrast);
	border-radius: 0;
	color: var(--wp--preset--color--contrast);
	font-family: var(--wp--preset--font-family--primary);
	font-size: var(--wp--preset--font-size--medium);
	font-weight: var(--wp--custom--font-weight--light);
	line-height: var(--wp--custom--line-height--body);
	padding: 10px 20px;
	width: 100%;
}

input:focus,
textarea:focus {
	background-color: var(--wp--preset--color--neutral);
	outline: none;
}

input[type="checkbox"],
input[type="image"],
input[type="radio"] {
	width: auto;
}

input[type="button"],
input[type="email"],
input[type="search"],
input[type="submit"],
input[type="text"],
textarea {
	-webkit-appearance: none;
}

::placeholder {
	color: var(--wp--preset--color--contrast);
	font-size: var(--wp--preset--font-size--small);
	opacity: 0.5;
}

/* Blocks
---------------------------------------- */

/* -- Code -- */

*:not(.wp-block-code) > code {
	background-color: var(--wp--preset--color--neutral);
	font-size: var(--wp--preset--font-size--small);
	padding: 5px 8px;
}

/* -- Navigation -- */

.wp-block-navigation__responsive-container.is-menu-open {
	padding: var(--wp--custom--spacing--gap);
}

.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content {
	padding-top: var(--wp--custom--spacing--gap);
}

.wp-block-navigation__responsive-container-close,
.wp-block-navigation__responsive-container-open {
	border: 1px solid currentColor;
	padding: 2px;
}

.has-background .wp-block-navigation__responsive-container-open:focus,
.has-background .wp-block-navigation__responsive-container-open:hover {
	color: var(--wp--preset--color--base);
}

/* -- Navigation Submenu -- */

.wp-block-navigation:not(.has-background) .wp-block-navigation__submenu-container {
	background-color: var(--wp--preset--color--contrast);
	border: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
	padding: 10px;
}

.wp-block-navigation :where(.wp-block-navigation__submenu-container) a {
	padding: 2px 10px;
}

/* Utility
---------------------------------------- */

/* -- Box Shadow -- */

.is-style-shadow-light {
	box-shadow: var(--wp--preset--shadow--light);
}

.is-style-shadow-solid {
	box-shadow: var(--wp--preset--shadow--solid);
}

/* Media Queries
---------------------------------------- */

@media only screen and (max-width: 600px) {

	/* -- Utility -- */

	.is-style-hidden-mobile {
		display: none !important;
	}

}

@media only screen and (max-width: 782px) {

	/* -- Columns -- */

	.is-style-columns-reverse {
		flex-direction: column-reverse;
	}

}

/* Allow SVG uploads */

	function enable_svg_upload($mimes) {

	$mimes['svg'] = 'image/svg+xml';

	return $mimes;

	}

	add_filter('upload_mimes', 'enable_svg_upload');

/* Fix SVG display in the Media Library */

	function fix_svg_display() {

	echo '<style>

	.attachment-266x266, .thumbnail img {

	width: 100% !important;

	height: auto !important;

	}

	</style>';

	}

	add_action('admin_head', 'fix_svg_display');

/* Restrict Upload Permissions to administrators */

    function limit_svg_upload_to_admins( $mimes ) {
    /* Check if the current user is an administrator */
    if ( current_user_can( 'administrator' ) ) {
    /* Allow SVG upload for administrators */
    $mimes['svg'] = 'image/svg+xml';
    } else {
    // Ensure SVG upload is disabled for other roles
    unset( $mimes['svg'] );
    }
    return $mimes;
    }
    add_filter( 'upload_mimes', 'limit_svg_upload_to_admins' );

/* Restrict Upload Permissions to administrators */
/*post views*/
	function getPostViews($postID){
		$count_key = 'post_views_count';
		$count = get_post_meta($postID, $count_key, true);
		if($count==''){
			delete_post_meta($postID, $count_key);
			add_post_meta($postID, $count_key, '0');
			return "0 View";
		}
		return $count.' Views';
	}
	function setPostViews($postID) {
		$count_key = 'post_views_count';
		$count = get_post_meta($postID, $count_key, true);
		if($count==''){
			$count = 0;
			delete_post_meta($postID, $count_key);
			add_post_meta($postID, $count_key, '0');
		}else{
			$count++;
			update_post_meta($postID, $count_key, $count);
		}
	}
/* Remove issues with prefetching adding extra views */
	remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);

/* Add a new column to the Posts list table */
	function add_views_column($columns) {
		$columns['post_views'] = 'Views';
		return $columns;
	}
	add_filter('manage_posts_columns', 'add_views_column');

/* Display the view count in the column */
	function display_views_column($column_name, $post_id) {
		if ($column_name === 'post_views') {
			$views = get_post_meta($post_id, 'post_views_count', true);
			echo $views ? $views : '0';
		}
	}
	add_action('manage_posts_custom_column', 'display_views_column', 10, 2);

/* Make the column sortable */
	function make_views_column_sortable($columns) {
		$columns['post_views'] = 'Views';
		return $columns;
	}
	add_filter('manage_edit-post_sortable_columns', 'make_views_column_sortable');

/* Handle sorting by view count */
	function sort_views_column_query($query) {
		if (!is_admin()) return;
		$orderby = $query->get('orderby');
		if ('Views' === $orderby || 'post_views' === $orderby) {
			$query->set('meta_key', 'post_views_count');
			$query->set('orderby', 'meta_value_num');
		}
	}
	add_action('pre_get_posts', 'sort_views_column_query');

