Skip to content

Instantly share code, notes, and snippets.

View saroarhossain57's full-sized avatar
✌️
Coding

Saroar Hossain saroarhossain57

✌️
Coding
View GitHub Profile
@saroarhossain57
saroarhossain57 / index.php
Created March 25, 2024 07:04
Get and Analysis Memory and Execution time in PHP.
<?php
$start_mem = memory_get_usage();
$start = hrtime(true);
$array = range(1, 100000);
$end = hrtime(true);
$end_mem = memory_get_usage();
$mem_usage = $end_mem - $start_mem;
// Calculate the execution time
@saroarhossain57
saroarhossain57 / gist:8f2582125d2b44154d8124fa730fbadb
Created December 31, 2023 18:54
Get visitor location data PHP
function get_ip_location(){
$client_ip = @$_SERVER['HTTP_CLIENT_IP'];
$forward_ip = @$_SERVER['HTTP_X_FORWARDED_FOR'];
$remote_ip = @$_SERVER['REMOTE_ADDR'];
$result = array('country_code'=>'', 'country_name'=>'', 'region'=>'', 'city'=>'');
if(filter_var($client_ip, FILTER_VALIDATE_IP)){
$ip_address = $client_ip;
} elseif(filter_var($forward_ip, FILTER_VALIDATE_IP)){
@saroarhossain57
saroarhossain57 / gist:b372876b538e8ff767ecd8b79b1933f4
Created December 31, 2023 18:53
Switch theme based on visitor location
$themes_settings = [
'default_theme' => 'newsup',
'country_based_themes' => [
"UK" => "blogus",
"BD" => "electro",
]
];
@saroarhossain57
saroarhossain57 / gist:b2e0bfcf97d59a5d36d6e702b5c67353
Created October 21, 2023 07:00
Fix composer minimum required php version issue with valet.
sudo update-alternatives --config php
/*Error management styles*/
.hiring_a_spartechs .validation_error {
display: none;
}
.gform_wrapper .hiring_a_spartechs li.gfield.gfield_error,
.gform_wrapper .hiring_a_spartechs li.gfield.gfield_error.gfield_contains_required.gfield_creditcard_warning {
background-color: inherit;
margin-bottom: inherit;
border-top: inherit;
border-bottom: inherit;
<?php
/************************************************************************
* Example Nested For VC
* vc_map() stuff should only be included when VC is enabled.
*
* This is just for a copy/paste test purpose.
*************************************************************************/
<?php
/*
Plugin Name: Colornews Image Upload
Plugin URI: http://bobl.com.bd/
Description: It is a simple plugin that adds a widget to your favourite sidebar to upload a single image and show it in sidebar location with custom url whatever you want
Version: 1.0
Author: BOBL
Author URI: http://bobl.com.bd/
*/
?>
function btn_shortcode($atts, $content=null){
extract(shortcode_atts(array(
'type' => 'theme',
'link' => '#',
'text' => 'btn theme'
), $atts));
return '<a class="btn btn-'.$type.'" href="'.$link.'">'.$text.'</a>';
}
add_shortcode('btn', 'btn_shortcode');
//This is for a option panel menu
function mytheme_admin_menu(){
add_menu_page('MyTheme Options Page', 'MyTheme Options', 'manage_options', 'myoptions', 'myoption_cb', get_template_directory_uri() . '/img/search_icon.png');
add_submenu_page('myoptions', 'MyTheme Options Page', 'Generel Options', 'manage_options', 'myoptions', 'myoption_cb');
add_submenu_page('myoptions', 'MyTheme Generel Options', 'Header Options', 'manage_options', 'myoption_generel', 'myoption_generel_cb');
}
add_action('admin_menu', 'mytheme_admin_menu');