<?php
/*-----------------------------------------------*/
/*  EXTHEM.ES
/*  PREMIUM WORDRESS THEMES
/*
/*  STOP DON'T TRY EDIT
/*  IF YOU DON'T KNOW PHP 
/*
/*  As Errors In Your Themes
/*  Are Not The Responsibility
/*  Of The DEVELOPERS
/*  @EXTHEM.ES
/*  
/*  Follow Social Media Exthem.es
/*  Youtube : https://www.youtube.com/channel/UCpcZNXk6ySLtwRSBN6fVyLA
/*  Facebook : https://www.facebook.com/groups/exthem.es
/*  Twitter : https://x.com/bangreyblog
/*  Instagram : https://www.instagram.com/exthem.es/
/*  Telegram : https://t.me/exthemes_helps
/*  TikTok : https://www.tiktok.com/@exthemes
/*	More Premium Themes Visit Now On https://exthem.es/
/*-----------------------------------------------*/
if ( ! defined( 'ABSPATH' ) ) exit; 
// Silence is golden.

if (!function_exists('warna_rgbs')) {
    function warna_rgbs($hex, $asString = true) {
        if (0 === strpos($hex, '#')) {
        $hex		= substr($hex, 1);
        } else if (0 === strpos($hex, '&H')) {
        $hex		= substr($hex, 2);
        }      
        $cutpoint	= ceil(strlen($hex) / 2)-1;
        $rgb		= explode(':', wordwrap($hex, $cutpoint, ':', $cutpoint), 3);
        $rgb[0]		= (isset($rgb[0]) ? hexdec($rgb[0]) : 0);
        $rgb[1]		= (isset($rgb[1]) ? hexdec($rgb[1]) : 0);
        $rgb[2]		= (isset($rgb[2]) ? hexdec($rgb[2]) : 0);
        return ($asString ? "rgba({$rgb[0]},{$rgb[1]},{$rgb[2]}, .8)" : $rgb);
    } 
}

if (!function_exists('formatBytes')) {
    function formatBytes($size, $precision = 2){
        $base 		= log($size, 1024);
        $suffixes 	= array('', 'KB', 'MB', 'GB', 'TB');   
        return round(pow(1024, $base - floor($base)), $precision) .' '. $suffixes[floor($base)];
    }
}

if (!function_exists('unicode_conv')) {
    function unicode_conv($originalString) {
		// The four \\\\ in the pattern here are necessary to match \u in the original string
		$replacedString	= preg_replace("/\\\\u(\w{4})/", "&#$1;", $originalString);
		$unicodeString	= mb_convert_encoding($replacedString, 'UTF-8', 'HTML-ENTITIES');
		return $unicodeString;
    }
}

if (!function_exists('ex_themes_clean')) {
    function ex_themes_clean($string) {
        $string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens.
        $string = preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars.
        return preg_replace('/-+/', '-', $string); // Replaces multiple hyphens with single one.
    }
}

if (!function_exists('upload_mimes_types')) {
    function upload_mimes_types( $mimes ) {
        $mimes['webp']	= 'image/webp';
        $mimes['svg']	= 'image/svg+xml';
        $mimes['apk']	= 'application/vnd.android.package-archive';
        $mimes['apks']	= 'application/vnd.android.package-archive';
        $mimes['xapk']	= 'application/vnd.android.package-archive';
        return $mimes;
    }
add_filter( 'upload_mimes', 'upload_mimes_types' );
}

if (!function_exists('webps_is_displayable')) {
    function webps_is_displayable($result, $path) {
        if ($result === false) {
            $displayable_image_types = array( IMAGETYPE_WEBP );
            $info = @getimagesize( $path );
            if (empty($info)) {
                $result = false;
            } elseif (!in_array($info[2], $displayable_image_types)) {
                $result = false;
            } else {
                $result = true;
            }
        }
        return $result;
    }
add_filter('file_is_displayable_image', 'webps_is_displayable', 10, 2);
}

if (!function_exists('sanitize_title_with_dashes_and_no_special_chars')) {
	function sanitize_title_with_dashes_and_no_special_chars($title) {
		// 1. Convert to Lowercase
		$title = strtolower($title);

		// 2. Remove Accents (using WordPress's remove_accents for demonstration)
		// In a non-WordPress context, you'd need a custom function or library for this.
		// For example: $title = iconv('UTF-8', 'ASCII//TRANSLIT', $title);
		if (function_exists('remove_accents')) {
			$title = remove_accents($title);
		}

		// 3. Replace non-alphanumeric characters (except dashes and spaces) with spaces
		$title = preg_replace('/[^a-z0-9\s-]/', ' ', $title);

		// 4. Replace spaces with dashes
		$title = preg_replace('/\s+/', '-', $title);

		// 5. Remove leading/trailing dashes
		$title = trim($title, '-');

		// 6. Remove multiple consecutive dashes
		$title = preg_replace('/-+/', '-', $title);

		return $title;
	}
}
if (!function_exists('ex_themes_notices_php')) {
    function ex_themes_notices_php() {
		if (!(PHP_VERSION_ID >= 70400)) {
			printf('<div class="notice notice-error is-dismissible"><p><b>'.strtoupper(THEMES_NAMES).'</b> require a PHP version 7.4 or UP. You site running '.PHP_VERSION.'. please update your PHP</p></div> ');
		}
    }
add_action( 'admin_notices', 'ex_themes_notices_php' ); 
}

if (!function_exists('new_apk_extractor')) {
    function new_apk_extractor() { 
        global $opt_themes;
        if($opt_themes['new_apk_extractor']){
        require_once get_template_directory().'/libs/addons/inc/grabs.php'; 
        }
    }
//add_action( 'init', 'new_apk_extractor' ); 
}

if (!function_exists('apps_updates_versions')) {
    function apps_updates_versions() { 
        global $opt_themes;
        if($opt_themes['apps_update_versi']){
        require get_template_directory().'/libs/addons/app_update/update_available.php'; 
        }
    }
add_action( 'init', 'apps_updates_versions' ); 
}

if (!function_exists('shortlinks_forms')) {
    function shortlinks_forms() { 
        global $opt_themes;
        if($opt_themes['shortlink_post']){			
		require get_template_directory().'/libs/addons/inc/flink.php';
        }
    }
add_action( 'init', 'shortlinks_forms' ); 
}

if (!function_exists('apps_updates_versi_post')) {
    function apps_updates_versi_post() { 
        global $opt_themes;
        if($opt_themes['check_updates_versi_post']){
        require get_template_directory().'/libs/addons/inc/versi_post.php';
        }
    }
//add_action( 'init', 'apps_updates_versi_post' ); 
}

if (!function_exists('get_postid')) {
	function get_postid() {
		global $post;
		return $post->ID; 
	}
}
 
require get_template_directory().'/libs/addons/inc/define.php';
require get_template_directory().'/libs/addons/inc/menu.php';
require get_template_directory().'/libs/addons/inc/curl.php';
require get_template_directory().'/libs/addons/inc/curls.php';
require get_template_directory().'/libs/addons/inc/shortlink.php';
require get_template_directory().'/libs/addons/inc/addscript.php';
require get_template_directory().'/libs/addons/inc/background.php';
//require get_template_directory().'/libs/addons/inc/uploadfile.php';
require get_template_directory().'/libs/addons/inc/versi.php';
require get_template_directory().'/libs/addons/inc/upload_file.php'; 
require_once get_template_directory().'/libs/addons/inc/docs.php';
if (!function_exists('file_get_html')) {
require_once get_template_directory().'/libs/addons/inc/dom.php';
}
require_once get_template_directory().'/libs/addons/inc/ssl.php';
require_once get_template_directory().'/libs/addons/inc/noduplicatedpost.php';
require_once get_template_directory().'/libs/addons/vendor/autoload.php';
require_once get_template_directory().'/libs/addons/inc/cloudflare.php';
require_once get_template_directory().'/libs/addons/includes/class/import_data.php';
require_once get_template_directory().'/libs/addons/includes/class/post.data.php';
require_once get_template_directory().'/libs/addons/includes/class/structur_code.php'; 
//require_once get_template_directory().'/libs/addons/inc/inc.php';
//require get_template_directory().'/libs/addons/inc/class-google-drive.php';
//require get_template_directory().'/libs/addons/inc/class_3.php';
//require get_template_directory().'/libs/addons/inc/bulk.php';  
//require_once get_template_directory().'/libs/addons/inc/cari_app_id_by_google.php'; 


  
